aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/inode.c
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2012-09-18 19:20:32 -0400
committerSteve French <smfrench@gmail.com>2012-09-24 22:46:29 -0400
commit6bdf6dbd662176c0da5c3ac8ed10ac94e7776c85 (patch)
tree6972c90f953a9fe5efc9a8feea4613c1b15c83e1 /fs/cifs/inode.c
parentc839ff244ba2d54d0933596e29a4b03e3c846a9a (diff)
CIFS: Move set_file_info to ops struct
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/inode.c')
-rw-r--r--fs/cifs/inode.c79
1 files changed, 6 insertions, 73 deletions
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 85e1b0a405a8..e74e1bceb416 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -886,21 +886,18 @@ int
886cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid, 886cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
887 char *full_path, __u32 dosattr) 887 char *full_path, __u32 dosattr)
888{ 888{
889 int rc;
890 int oplock = 0;
891 __u16 netfid;
892 __u32 netpid;
893 bool set_time = false; 889 bool set_time = false;
894 struct cifsFileInfo *open_file;
895 struct cifsInodeInfo *cifsInode = CIFS_I(inode);
896 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 890 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
897 struct tcon_link *tlink = NULL; 891 struct TCP_Server_Info *server;
898 struct cifs_tcon *pTcon;
899 FILE_BASIC_INFO info_buf; 892 FILE_BASIC_INFO info_buf;
900 893
901 if (attrs == NULL) 894 if (attrs == NULL)
902 return -EINVAL; 895 return -EINVAL;
903 896
897 server = cifs_sb_master_tcon(cifs_sb)->ses->server;
898 if (!server->ops->set_file_info)
899 return -ENOSYS;
900
904 if (attrs->ia_valid & ATTR_ATIME) { 901 if (attrs->ia_valid & ATTR_ATIME) {
905 set_time = true; 902 set_time = true;
906 info_buf.LastAccessTime = 903 info_buf.LastAccessTime =
@@ -931,71 +928,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
931 info_buf.CreationTime = 0; /* don't change */ 928 info_buf.CreationTime = 0; /* don't change */
932 info_buf.Attributes = cpu_to_le32(dosattr); 929 info_buf.Attributes = cpu_to_le32(dosattr);
933 930
934 /* 931 return server->ops->set_file_info(inode, full_path, &info_buf, xid);
935 * If the file is already open for write, just use that fileid
936 */
937 open_file = find_writable_file(cifsInode, true);
938 if (open_file) {
939 netfid = open_file->fid.netfid;
940 netpid = open_file->pid;
941 pTcon = tlink_tcon(open_file->tlink);
942 goto set_via_filehandle;
943 }
944
945 tlink = cifs_sb_tlink(cifs_sb);
946 if (IS_ERR(tlink)) {
947 rc = PTR_ERR(tlink);
948 tlink = NULL;
949 goto out;
950 }
951 pTcon = tlink_tcon(tlink);
952
953 /*
954 * NT4 apparently returns success on this call, but it doesn't
955 * really work.
956 */
957 if (!(pTcon->ses->flags & CIFS_SES_NT4)) {
958 rc = CIFSSMBSetPathInfo(xid, pTcon, full_path,
959 &info_buf, cifs_sb->local_nls,
960 cifs_sb->mnt_cifs_flags &
961 CIFS_MOUNT_MAP_SPECIAL_CHR);
962 if (rc == 0) {
963 cifsInode->cifsAttrs = dosattr;
964 goto out;
965 } else if (rc != -EOPNOTSUPP && rc != -EINVAL)
966 goto out;
967 }
968
969 cFYI(1, "calling SetFileInfo since SetPathInfo for "
970 "times not supported by this server");
971 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
972 SYNCHRONIZE | FILE_WRITE_ATTRIBUTES,
973 CREATE_NOT_DIR, &netfid, &oplock,
974 NULL, cifs_sb->local_nls,
975 cifs_sb->mnt_cifs_flags &
976 CIFS_MOUNT_MAP_SPECIAL_CHR);
977
978 if (rc != 0) {
979 if (rc == -EIO)
980 rc = -EINVAL;
981 goto out;
982 }
983
984 netpid = current->tgid;
985
986set_via_filehandle:
987 rc = CIFSSMBSetFileInfo(xid, pTcon, &info_buf, netfid, netpid);
988 if (!rc)
989 cifsInode->cifsAttrs = dosattr;
990
991 if (open_file == NULL)
992 CIFSSMBClose(xid, pTcon, netfid);
993 else
994 cifsFileInfo_put(open_file);
995out:
996 if (tlink != NULL)
997 cifs_put_tlink(tlink);
998 return rc;
999} 932}
1000 933
1001/* 934/*