aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2013-07-05 04:21:26 -0400
committerSteve French <smfrench@gmail.com>2013-07-10 14:08:39 -0400
commitca81983fe5e095ee90c0f7b6013e7c446af17088 (patch)
treebd2b8d13f0ded75a5de99f9878f9612486078332 /fs/cifs
parentfd55439638a27e34d87b91d618c0ba6b42302940 (diff)
CIFS: Respect create_options in smb2_open_file
and eliminated unused file_attribute parms of SMB2_open. Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steven French <steven@steven-GA-970A-DS3.(none)>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/smb2file.c2
-rw-r--r--fs/cifs/smb2inode.c25
-rw-r--r--fs/cifs/smb2ops.c6
-rw-r--r--fs/cifs/smb2pdu.c10
-rw-r--r--fs/cifs/smb2proto.h4
5 files changed, 25 insertions, 22 deletions
diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c
index 5da1b55a2258..46a4299b7ae8 100644
--- a/fs/cifs/smb2file.c
+++ b/fs/cifs/smb2file.c
@@ -88,7 +88,7 @@ smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path,
88 88
89 rc = SMB2_open(xid, tcon, smb2_path, &fid->persistent_fid, 89 rc = SMB2_open(xid, tcon, smb2_path, &fid->persistent_fid,
90 &fid->volatile_fid, desired_access, disposition, 90 &fid->volatile_fid, desired_access, disposition,
91 0, 0, smb2_oplock, smb2_data); 91 create_options, smb2_oplock, smb2_data);
92 if (rc) 92 if (rc)
93 goto out; 93 goto out;
94 94
diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
index fff6dfba6204..f50eefd9e005 100644
--- a/fs/cifs/smb2inode.c
+++ b/fs/cifs/smb2inode.c
@@ -41,8 +41,7 @@ static int
41smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, 41smb2_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; 47 u64 persistent_fid, volatile_fid;
@@ -54,8 +53,8 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon,
54 return -ENOMEM; 53 return -ENOMEM;
55 54
56 rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid, 55 rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid,
57 desired_access, create_disposition, file_attributes, 56 desired_access, create_disposition, create_options,
58 create_options, &oplock, NULL); 57 &oplock, NULL);
59 if (rc) { 58 if (rc) {
60 kfree(utf16_path); 59 kfree(utf16_path);
61 return rc; 60 return rc;
@@ -129,8 +128,8 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
129 return -ENOMEM; 128 return -ENOMEM;
130 129
131 rc = smb2_open_op_close(xid, tcon, cifs_sb, full_path, 130 rc = smb2_open_op_close(xid, tcon, cifs_sb, full_path,
132 FILE_READ_ATTRIBUTES, FILE_OPEN, 0, 0, 131 FILE_READ_ATTRIBUTES, FILE_OPEN, 0, smb2_data,
133 smb2_data, SMB2_OP_QUERY_INFO); 132 SMB2_OP_QUERY_INFO);
134 if (rc) 133 if (rc)
135 goto out; 134 goto out;
136 135
@@ -145,7 +144,7 @@ smb2_mkdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
145 struct cifs_sb_info *cifs_sb) 144 struct cifs_sb_info *cifs_sb)
146{ 145{
147 return smb2_open_op_close(xid, tcon, cifs_sb, name, 146 return smb2_open_op_close(xid, tcon, cifs_sb, name,
148 FILE_WRITE_ATTRIBUTES, FILE_CREATE, 0, 147 FILE_WRITE_ATTRIBUTES, FILE_CREATE,
149 CREATE_NOT_FILE, NULL, SMB2_OP_MKDIR); 148 CREATE_NOT_FILE, NULL, SMB2_OP_MKDIR);
150} 149}
151 150
@@ -164,7 +163,7 @@ smb2_mkdir_setinfo(struct inode *inode, const char *name,
164 dosattrs = cifs_i->cifsAttrs | ATTR_READONLY; 163 dosattrs = cifs_i->cifsAttrs | ATTR_READONLY;
165 data.Attributes = cpu_to_le32(dosattrs); 164 data.Attributes = cpu_to_le32(dosattrs);
166 tmprc = smb2_open_op_close(xid, tcon, cifs_sb, name, 165 tmprc = smb2_open_op_close(xid, tcon, cifs_sb, name,
167 FILE_WRITE_ATTRIBUTES, FILE_CREATE, 0, 166 FILE_WRITE_ATTRIBUTES, FILE_CREATE,
168 CREATE_NOT_FILE, &data, SMB2_OP_SET_INFO); 167 CREATE_NOT_FILE, &data, SMB2_OP_SET_INFO);
169 if (tmprc == 0) 168 if (tmprc == 0)
170 cifs_i->cifsAttrs = dosattrs; 169 cifs_i->cifsAttrs = dosattrs;
@@ -175,7 +174,7 @@ smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
175 struct cifs_sb_info *cifs_sb) 174 struct cifs_sb_info *cifs_sb)
176{ 175{
177 return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN, 176 return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
178 0, CREATE_NOT_FILE | CREATE_DELETE_ON_CLOSE, 177 CREATE_NOT_FILE | CREATE_DELETE_ON_CLOSE,
179 NULL, SMB2_OP_DELETE); 178 NULL, SMB2_OP_DELETE);
180} 179}
181 180
@@ -184,7 +183,7 @@ smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
184 struct cifs_sb_info *cifs_sb) 183 struct cifs_sb_info *cifs_sb)
185{ 184{
186 return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN, 185 return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
187 0, CREATE_DELETE_ON_CLOSE, NULL, 186 CREATE_DELETE_ON_CLOSE, NULL,
188 SMB2_OP_DELETE); 187 SMB2_OP_DELETE);
189} 188}
190 189
@@ -203,7 +202,7 @@ smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon,
203 } 202 }
204 203
205 rc = smb2_open_op_close(xid, tcon, cifs_sb, from_name, access, 204 rc = smb2_open_op_close(xid, tcon, cifs_sb, from_name, access,
206 FILE_OPEN, 0, 0, smb2_to_name, command); 205 FILE_OPEN, 0, smb2_to_name, command);
207smb2_rename_path: 206smb2_rename_path:
208 kfree(smb2_to_name); 207 kfree(smb2_to_name);
209 return rc; 208 return rc;
@@ -234,7 +233,7 @@ smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
234{ 233{
235 __le64 eof = cpu_to_le64(size); 234 __le64 eof = cpu_to_le64(size);
236 return smb2_open_op_close(xid, tcon, cifs_sb, full_path, 235 return smb2_open_op_close(xid, tcon, cifs_sb, full_path,
237 FILE_WRITE_DATA, FILE_OPEN, 0, 0, &eof, 236 FILE_WRITE_DATA, FILE_OPEN, 0, &eof,
238 SMB2_OP_SET_EOF); 237 SMB2_OP_SET_EOF);
239} 238}
240 239
@@ -250,7 +249,7 @@ smb2_set_file_info(struct inode *inode, const char *full_path,
250 if (IS_ERR(tlink)) 249 if (IS_ERR(tlink))
251 return PTR_ERR(tlink); 250 return PTR_ERR(tlink);
252 rc = smb2_open_op_close(xid, tlink_tcon(tlink), cifs_sb, full_path, 251 rc = smb2_open_op_close(xid, tlink_tcon(tlink), cifs_sb, full_path,
253 FILE_WRITE_ATTRIBUTES, FILE_OPEN, 0, 0, buf, 252 FILE_WRITE_ATTRIBUTES, FILE_OPEN, 0, buf,
254 SMB2_OP_SET_INFO); 253 SMB2_OP_SET_INFO);
255 cifs_put_tlink(tlink); 254 cifs_put_tlink(tlink);
256 return rc; 255 return rc;
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 6d15cab95b99..92bdc7ec5c99 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -222,7 +222,7 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
222 return -ENOMEM; 222 return -ENOMEM;
223 223
224 rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid, 224 rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid,
225 FILE_READ_ATTRIBUTES, FILE_OPEN, 0, 0, &oplock, NULL); 225 FILE_READ_ATTRIBUTES, FILE_OPEN, 0, &oplock, NULL);
226 if (rc) { 226 if (rc) {
227 kfree(utf16_path); 227 kfree(utf16_path);
228 return rc; 228 return rc;
@@ -450,7 +450,7 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
450 return -ENOMEM; 450 return -ENOMEM;
451 451
452 rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid, 452 rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid,
453 FILE_READ_ATTRIBUTES | FILE_READ_DATA, FILE_OPEN, 0, 0, 453 FILE_READ_ATTRIBUTES | FILE_READ_DATA, FILE_OPEN, 0,
454 &oplock, NULL); 454 &oplock, NULL);
455 kfree(utf16_path); 455 kfree(utf16_path);
456 if (rc) { 456 if (rc) {
@@ -533,7 +533,7 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
533 u8 oplock = SMB2_OPLOCK_LEVEL_NONE; 533 u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
534 534
535 rc = SMB2_open(xid, tcon, &srch_path, &persistent_fid, &volatile_fid, 535 rc = SMB2_open(xid, tcon, &srch_path, &persistent_fid, &volatile_fid,
536 FILE_READ_ATTRIBUTES, FILE_OPEN, 0, 0, &oplock, NULL); 536 FILE_READ_ATTRIBUTES, FILE_OPEN, 0, &oplock, NULL);
537 if (rc) 537 if (rc)
538 return rc; 538 return rc;
539 buf->f_type = SMB2_MAGIC_NUMBER; 539 buf->f_type = SMB2_MAGIC_NUMBER;
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 19fafeb767fa..4c046a5b81af 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -881,8 +881,8 @@ parse_lease_state(struct smb2_create_rsp *rsp)
881int 881int
882SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, 882SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path,
883 u64 *persistent_fid, u64 *volatile_fid, __u32 desired_access, 883 u64 *persistent_fid, u64 *volatile_fid, __u32 desired_access,
884 __u32 create_disposition, __u32 file_attributes, __u32 create_options, 884 __u32 create_disposition, __u32 create_options, __u8 *oplock,
885 __u8 *oplock, struct smb2_file_all_info *buf) 885 struct smb2_file_all_info *buf)
886{ 886{
887 struct smb2_create_req *req; 887 struct smb2_create_req *req;
888 struct smb2_create_rsp *rsp; 888 struct smb2_create_rsp *rsp;
@@ -895,6 +895,7 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path,
895 int copy_size; 895 int copy_size;
896 int rc = 0; 896 int rc = 0;
897 int num_iovecs = 2; 897 int num_iovecs = 2;
898 __u32 file_attributes = 0;
898 899
899 cifs_dbg(FYI, "create/open\n"); 900 cifs_dbg(FYI, "create/open\n");
900 901
@@ -907,13 +908,16 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path,
907 if (rc) 908 if (rc)
908 return rc; 909 return rc;
909 910
911 if (create_options & CREATE_OPTION_READONLY)
912 file_attributes |= ATTR_READONLY;
913
910 req->ImpersonationLevel = IL_IMPERSONATION; 914 req->ImpersonationLevel = IL_IMPERSONATION;
911 req->DesiredAccess = cpu_to_le32(desired_access); 915 req->DesiredAccess = cpu_to_le32(desired_access);
912 /* File attributes ignored on open (used in create though) */ 916 /* File attributes ignored on open (used in create though) */
913 req->FileAttributes = cpu_to_le32(file_attributes); 917 req->FileAttributes = cpu_to_le32(file_attributes);
914 req->ShareAccess = FILE_SHARE_ALL_LE; 918 req->ShareAccess = FILE_SHARE_ALL_LE;
915 req->CreateDisposition = cpu_to_le32(create_disposition); 919 req->CreateDisposition = cpu_to_le32(create_disposition);
916 req->CreateOptions = cpu_to_le32(create_options); 920 req->CreateOptions = cpu_to_le32(create_options & CREATE_OPTIONS_MASK);
917 uni_path_len = (2 * UniStrnlen((wchar_t *)path, PATH_MAX)) + 2; 921 uni_path_len = (2 * UniStrnlen((wchar_t *)path, PATH_MAX)) + 2;
918 req->NameOffset = cpu_to_le16(sizeof(struct smb2_create_req) 922 req->NameOffset = cpu_to_le16(sizeof(struct smb2_create_req)
919 - 8 /* pad */ - 4 /* do not count rfc1001 len field */); 923 - 8 /* pad */ - 4 /* do not count rfc1001 len field */);
diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
index d4e1eb807457..d71a3e2a772d 100644
--- a/fs/cifs/smb2proto.h
+++ b/fs/cifs/smb2proto.h
@@ -109,8 +109,8 @@ extern int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon);
109extern int SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, 109extern int SMB2_open(const unsigned int xid, struct cifs_tcon *tcon,
110 __le16 *path, u64 *persistent_fid, u64 *volatile_fid, 110 __le16 *path, u64 *persistent_fid, u64 *volatile_fid,
111 __u32 desired_access, __u32 create_disposition, 111 __u32 desired_access, __u32 create_disposition,
112 __u32 file_attributes, __u32 create_options, 112 __u32 create_options, __u8 *oplock,
113 __u8 *oplock, struct smb2_file_all_info *buf); 113 struct smb2_file_all_info *buf);
114extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, 114extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon,
115 u64 persistent_fid, u64 volatile_fid, u32 opcode, 115 u64 persistent_fid, u64 volatile_fid, u32 opcode,
116 bool is_fsctl, char *in_data, u32 indatalen, 116 bool is_fsctl, char *in_data, u32 indatalen,