diff options
Diffstat (limited to 'fs/cifs/smb2inode.c')
-rw-r--r-- | fs/cifs/smb2inode.c | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c index fff6dfba6204..c6ec1633309a 100644 --- a/fs/cifs/smb2inode.c +++ b/fs/cifs/smb2inode.c | |||
@@ -41,21 +41,26 @@ static int | |||
41 | smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, | 41 | smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, |
42 | struct cifs_sb_info *cifs_sb, const char *full_path, | 42 | struct cifs_sb_info *cifs_sb, const char *full_path, |
43 | __u32 desired_access, __u32 create_disposition, | 43 | __u32 desired_access, __u32 create_disposition, |
44 | __u32 file_attributes, __u32 create_options, | 44 | __u32 create_options, void *data, int command) |
45 | void *data, int command) | ||
46 | { | 45 | { |
47 | int rc, tmprc = 0; | 46 | int rc, tmprc = 0; |
48 | u64 persistent_fid, volatile_fid; | ||
49 | __le16 *utf16_path; | 47 | __le16 *utf16_path; |
50 | __u8 oplock = SMB2_OPLOCK_LEVEL_NONE; | 48 | __u8 oplock = SMB2_OPLOCK_LEVEL_NONE; |
49 | struct cifs_open_parms oparms; | ||
50 | struct cifs_fid fid; | ||
51 | 51 | ||
52 | utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb); | 52 | utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb); |
53 | if (!utf16_path) | 53 | if (!utf16_path) |
54 | return -ENOMEM; | 54 | return -ENOMEM; |
55 | 55 | ||
56 | rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid, | 56 | oparms.tcon = tcon; |
57 | desired_access, create_disposition, file_attributes, | 57 | oparms.desired_access = desired_access; |
58 | create_options, &oplock, NULL); | 58 | oparms.disposition = create_disposition; |
59 | oparms.create_options = create_options; | ||
60 | oparms.fid = &fid; | ||
61 | oparms.reconnect = false; | ||
62 | |||
63 | rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL); | ||
59 | if (rc) { | 64 | if (rc) { |
60 | kfree(utf16_path); | 65 | kfree(utf16_path); |
61 | return rc; | 66 | return rc; |
@@ -65,8 +70,8 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, | |||
65 | case SMB2_OP_DELETE: | 70 | case SMB2_OP_DELETE: |
66 | break; | 71 | break; |
67 | case SMB2_OP_QUERY_INFO: | 72 | case SMB2_OP_QUERY_INFO: |
68 | tmprc = SMB2_query_info(xid, tcon, persistent_fid, | 73 | tmprc = SMB2_query_info(xid, tcon, fid.persistent_fid, |
69 | volatile_fid, | 74 | fid.volatile_fid, |
70 | (struct smb2_file_all_info *)data); | 75 | (struct smb2_file_all_info *)data); |
71 | break; | 76 | break; |
72 | case SMB2_OP_MKDIR: | 77 | case SMB2_OP_MKDIR: |
@@ -76,19 +81,21 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, | |||
76 | */ | 81 | */ |
77 | break; | 82 | break; |
78 | case SMB2_OP_RENAME: | 83 | case SMB2_OP_RENAME: |
79 | tmprc = SMB2_rename(xid, tcon, persistent_fid, volatile_fid, | 84 | tmprc = SMB2_rename(xid, tcon, fid.persistent_fid, |
80 | (__le16 *)data); | 85 | fid.volatile_fid, (__le16 *)data); |
81 | break; | 86 | break; |
82 | case SMB2_OP_HARDLINK: | 87 | case SMB2_OP_HARDLINK: |
83 | tmprc = SMB2_set_hardlink(xid, tcon, persistent_fid, | 88 | tmprc = SMB2_set_hardlink(xid, tcon, fid.persistent_fid, |
84 | volatile_fid, (__le16 *)data); | 89 | fid.volatile_fid, (__le16 *)data); |
85 | break; | 90 | break; |
86 | case SMB2_OP_SET_EOF: | 91 | case SMB2_OP_SET_EOF: |
87 | tmprc = SMB2_set_eof(xid, tcon, persistent_fid, volatile_fid, | 92 | tmprc = SMB2_set_eof(xid, tcon, fid.persistent_fid, |
88 | current->tgid, (__le64 *)data); | 93 | fid.volatile_fid, current->tgid, |
94 | (__le64 *)data); | ||
89 | break; | 95 | break; |
90 | case SMB2_OP_SET_INFO: | 96 | case SMB2_OP_SET_INFO: |
91 | tmprc = SMB2_set_info(xid, tcon, persistent_fid, volatile_fid, | 97 | tmprc = SMB2_set_info(xid, tcon, fid.persistent_fid, |
98 | fid.volatile_fid, | ||
92 | (FILE_BASIC_INFO *)data); | 99 | (FILE_BASIC_INFO *)data); |
93 | break; | 100 | break; |
94 | default: | 101 | default: |
@@ -96,7 +103,7 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, | |||
96 | break; | 103 | break; |
97 | } | 104 | } |
98 | 105 | ||
99 | rc = SMB2_close(xid, tcon, persistent_fid, volatile_fid); | 106 | rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); |
100 | if (tmprc) | 107 | if (tmprc) |
101 | rc = tmprc; | 108 | rc = tmprc; |
102 | kfree(utf16_path); | 109 | kfree(utf16_path); |
@@ -129,8 +136,8 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
129 | return -ENOMEM; | 136 | return -ENOMEM; |
130 | 137 | ||
131 | rc = smb2_open_op_close(xid, tcon, cifs_sb, full_path, | 138 | rc = smb2_open_op_close(xid, tcon, cifs_sb, full_path, |
132 | FILE_READ_ATTRIBUTES, FILE_OPEN, 0, 0, | 139 | FILE_READ_ATTRIBUTES, FILE_OPEN, 0, smb2_data, |
133 | smb2_data, SMB2_OP_QUERY_INFO); | 140 | SMB2_OP_QUERY_INFO); |
134 | if (rc) | 141 | if (rc) |
135 | goto out; | 142 | goto out; |
136 | 143 | ||
@@ -145,7 +152,7 @@ smb2_mkdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name, | |||
145 | struct cifs_sb_info *cifs_sb) | 152 | struct cifs_sb_info *cifs_sb) |
146 | { | 153 | { |
147 | return smb2_open_op_close(xid, tcon, cifs_sb, name, | 154 | return smb2_open_op_close(xid, tcon, cifs_sb, name, |
148 | FILE_WRITE_ATTRIBUTES, FILE_CREATE, 0, | 155 | FILE_WRITE_ATTRIBUTES, FILE_CREATE, |
149 | CREATE_NOT_FILE, NULL, SMB2_OP_MKDIR); | 156 | CREATE_NOT_FILE, NULL, SMB2_OP_MKDIR); |
150 | } | 157 | } |
151 | 158 | ||
@@ -164,7 +171,7 @@ smb2_mkdir_setinfo(struct inode *inode, const char *name, | |||
164 | dosattrs = cifs_i->cifsAttrs | ATTR_READONLY; | 171 | dosattrs = cifs_i->cifsAttrs | ATTR_READONLY; |
165 | data.Attributes = cpu_to_le32(dosattrs); | 172 | data.Attributes = cpu_to_le32(dosattrs); |
166 | tmprc = smb2_open_op_close(xid, tcon, cifs_sb, name, | 173 | tmprc = smb2_open_op_close(xid, tcon, cifs_sb, name, |
167 | FILE_WRITE_ATTRIBUTES, FILE_CREATE, 0, | 174 | FILE_WRITE_ATTRIBUTES, FILE_CREATE, |
168 | CREATE_NOT_FILE, &data, SMB2_OP_SET_INFO); | 175 | CREATE_NOT_FILE, &data, SMB2_OP_SET_INFO); |
169 | if (tmprc == 0) | 176 | if (tmprc == 0) |
170 | cifs_i->cifsAttrs = dosattrs; | 177 | cifs_i->cifsAttrs = dosattrs; |
@@ -175,7 +182,7 @@ smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name, | |||
175 | struct cifs_sb_info *cifs_sb) | 182 | struct cifs_sb_info *cifs_sb) |
176 | { | 183 | { |
177 | return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN, | 184 | return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN, |
178 | 0, CREATE_NOT_FILE | CREATE_DELETE_ON_CLOSE, | 185 | CREATE_NOT_FILE | CREATE_DELETE_ON_CLOSE, |
179 | NULL, SMB2_OP_DELETE); | 186 | NULL, SMB2_OP_DELETE); |
180 | } | 187 | } |
181 | 188 | ||
@@ -184,7 +191,7 @@ smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name, | |||
184 | struct cifs_sb_info *cifs_sb) | 191 | struct cifs_sb_info *cifs_sb) |
185 | { | 192 | { |
186 | return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN, | 193 | return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN, |
187 | 0, CREATE_DELETE_ON_CLOSE, NULL, | 194 | CREATE_DELETE_ON_CLOSE, NULL, |
188 | SMB2_OP_DELETE); | 195 | SMB2_OP_DELETE); |
189 | } | 196 | } |
190 | 197 | ||
@@ -203,7 +210,7 @@ smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon, | |||
203 | } | 210 | } |
204 | 211 | ||
205 | rc = smb2_open_op_close(xid, tcon, cifs_sb, from_name, access, | 212 | rc = smb2_open_op_close(xid, tcon, cifs_sb, from_name, access, |
206 | FILE_OPEN, 0, 0, smb2_to_name, command); | 213 | FILE_OPEN, 0, smb2_to_name, command); |
207 | smb2_rename_path: | 214 | smb2_rename_path: |
208 | kfree(smb2_to_name); | 215 | kfree(smb2_to_name); |
209 | return rc; | 216 | return rc; |
@@ -234,7 +241,7 @@ smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon, | |||
234 | { | 241 | { |
235 | __le64 eof = cpu_to_le64(size); | 242 | __le64 eof = cpu_to_le64(size); |
236 | return smb2_open_op_close(xid, tcon, cifs_sb, full_path, | 243 | return smb2_open_op_close(xid, tcon, cifs_sb, full_path, |
237 | FILE_WRITE_DATA, FILE_OPEN, 0, 0, &eof, | 244 | FILE_WRITE_DATA, FILE_OPEN, 0, &eof, |
238 | SMB2_OP_SET_EOF); | 245 | SMB2_OP_SET_EOF); |
239 | } | 246 | } |
240 | 247 | ||
@@ -250,7 +257,7 @@ smb2_set_file_info(struct inode *inode, const char *full_path, | |||
250 | if (IS_ERR(tlink)) | 257 | if (IS_ERR(tlink)) |
251 | return PTR_ERR(tlink); | 258 | return PTR_ERR(tlink); |
252 | rc = smb2_open_op_close(xid, tlink_tcon(tlink), cifs_sb, full_path, | 259 | rc = smb2_open_op_close(xid, tlink_tcon(tlink), cifs_sb, full_path, |
253 | FILE_WRITE_ATTRIBUTES, FILE_OPEN, 0, 0, buf, | 260 | FILE_WRITE_ATTRIBUTES, FILE_OPEN, 0, buf, |
254 | SMB2_OP_SET_INFO); | 261 | SMB2_OP_SET_INFO); |
255 | cifs_put_tlink(tlink); | 262 | cifs_put_tlink(tlink); |
256 | return rc; | 263 | return rc; |