aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2013-07-05 04:00:30 -0400
committerSteve French <smfrench@gmail.com>2013-07-10 14:08:40 -0400
commit226730b4d8adae393dc07092655cdd29d2a2ff07 (patch)
treeeda0aef086114d0309d669e01c22a0ec5d987cc5 /fs
parent63eb3def3267a5744863801e8221898b0ba9d41d (diff)
CIFS: Introduce cifs_open_parms struct
and pass it to the open() call. Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steven French <steven@steven-GA-970A-DS3.(none)>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/cifsglob.h16
-rw-r--r--fs/cifs/dir.c13
-rw-r--r--fs/cifs/file.c26
-rw-r--r--fs/cifs/smb1ops.c29
-rw-r--r--fs/cifs/smb2file.c22
-rw-r--r--fs/cifs/smb2proto.h8
6 files changed, 73 insertions, 41 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index e66b08882548..982fdf92c791 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -194,6 +194,7 @@ struct cifs_writedata;
194struct cifs_io_parms; 194struct cifs_io_parms;
195struct cifs_search_info; 195struct cifs_search_info;
196struct cifsInodeInfo; 196struct cifsInodeInfo;
197struct cifs_open_parms;
197 198
198struct smb_version_operations { 199struct smb_version_operations {
199 int (*send_cancel)(struct TCP_Server_Info *, void *, 200 int (*send_cancel)(struct TCP_Server_Info *, void *,
@@ -307,9 +308,8 @@ struct smb_version_operations {
307 const char *, const char *, 308 const char *, const char *,
308 struct cifs_sb_info *); 309 struct cifs_sb_info *);
309 /* open a file for non-posix mounts */ 310 /* open a file for non-posix mounts */
310 int (*open)(const unsigned int, struct cifs_tcon *, const char *, int, 311 int (*open)(const unsigned int, struct cifs_open_parms *,
311 int, int, struct cifs_fid *, __u32 *, FILE_ALL_INFO *, 312 __u32 *, FILE_ALL_INFO *);
312 struct cifs_sb_info *);
313 /* set fid protocol-specific info */ 313 /* set fid protocol-specific info */
314 void (*set_fid)(struct cifsFileInfo *, struct cifs_fid *, __u32); 314 void (*set_fid)(struct cifsFileInfo *, struct cifs_fid *, __u32);
315 /* close a file */ 315 /* close a file */
@@ -912,6 +912,16 @@ struct cifs_search_info {
912 bool smallBuf:1; /* so we know which buf_release function to call */ 912 bool smallBuf:1; /* so we know which buf_release function to call */
913}; 913};
914 914
915struct cifs_open_parms {
916 struct cifs_tcon *tcon;
917 struct cifs_sb_info *cifs_sb;
918 int disposition;
919 int desired_access;
920 int create_options;
921 const char *path;
922 struct cifs_fid *fid;
923};
924
915struct cifs_fid { 925struct cifs_fid {
916 __u16 netfid; 926 __u16 netfid;
917#ifdef CONFIG_CIFS_SMB2 927#ifdef CONFIG_CIFS_SMB2
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 5175aebf6737..c27c242ac5ba 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -204,6 +204,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
204 struct inode *newinode = NULL; 204 struct inode *newinode = NULL;
205 int disposition; 205 int disposition;
206 struct TCP_Server_Info *server = tcon->ses->server; 206 struct TCP_Server_Info *server = tcon->ses->server;
207 struct cifs_open_parms oparms;
207 208
208 *oplock = 0; 209 *oplock = 0;
209 if (tcon->ses->server->oplocks) 210 if (tcon->ses->server->oplocks)
@@ -319,9 +320,15 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
319 if (backup_cred(cifs_sb)) 320 if (backup_cred(cifs_sb))
320 create_options |= CREATE_OPEN_BACKUP_INTENT; 321 create_options |= CREATE_OPEN_BACKUP_INTENT;
321 322
322 rc = server->ops->open(xid, tcon, full_path, disposition, 323 oparms.tcon = tcon;
323 desired_access, create_options, fid, oplock, 324 oparms.cifs_sb = cifs_sb;
324 buf, cifs_sb); 325 oparms.desired_access = desired_access;
326 oparms.create_options = create_options;
327 oparms.disposition = disposition;
328 oparms.path = full_path;
329 oparms.fid = fid;
330
331 rc = server->ops->open(xid, &oparms, oplock, buf);
325 if (rc) { 332 if (rc) {
326 cifs_dbg(FYI, "cifs_create returned 0x%x\n", rc); 333 cifs_dbg(FYI, "cifs_create returned 0x%x\n", rc);
327 goto out; 334 goto out;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 91d8629e69a2..f36f9a7893da 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -183,6 +183,7 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
183 int create_options = CREATE_NOT_DIR; 183 int create_options = CREATE_NOT_DIR;
184 FILE_ALL_INFO *buf; 184 FILE_ALL_INFO *buf;
185 struct TCP_Server_Info *server = tcon->ses->server; 185 struct TCP_Server_Info *server = tcon->ses->server;
186 struct cifs_open_parms oparms;
186 187
187 if (!server->ops->open) 188 if (!server->ops->open)
188 return -ENOSYS; 189 return -ENOSYS;
@@ -224,9 +225,15 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
224 if (backup_cred(cifs_sb)) 225 if (backup_cred(cifs_sb))
225 create_options |= CREATE_OPEN_BACKUP_INTENT; 226 create_options |= CREATE_OPEN_BACKUP_INTENT;
226 227
227 rc = server->ops->open(xid, tcon, full_path, disposition, 228 oparms.tcon = tcon;
228 desired_access, create_options, fid, oplock, buf, 229 oparms.cifs_sb = cifs_sb;
229 cifs_sb); 230 oparms.desired_access = desired_access;
231 oparms.create_options = create_options;
232 oparms.disposition = disposition;
233 oparms.path = full_path;
234 oparms.fid = fid;
235
236 rc = server->ops->open(xid, &oparms, oplock, buf);
230 237
231 if (rc) 238 if (rc)
232 goto out; 239 goto out;
@@ -588,6 +595,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
588 int disposition = FILE_OPEN; 595 int disposition = FILE_OPEN;
589 int create_options = CREATE_NOT_DIR; 596 int create_options = CREATE_NOT_DIR;
590 struct cifs_fid fid; 597 struct cifs_fid fid;
598 struct cifs_open_parms oparms;
591 599
592 xid = get_xid(); 600 xid = get_xid();
593 mutex_lock(&cfile->fh_mutex); 601 mutex_lock(&cfile->fh_mutex);
@@ -656,6 +664,14 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
656 if (server->ops->get_lease_key) 664 if (server->ops->get_lease_key)
657 server->ops->get_lease_key(inode, &fid); 665 server->ops->get_lease_key(inode, &fid);
658 666
667 oparms.tcon = tcon;
668 oparms.cifs_sb = cifs_sb;
669 oparms.desired_access = desired_access;
670 oparms.create_options = create_options;
671 oparms.disposition = disposition;
672 oparms.path = full_path;
673 oparms.fid = &fid;
674
659 /* 675 /*
660 * Can not refresh inode by passing in file_info buf to be returned by 676 * Can not refresh inode by passing in file_info buf to be returned by
661 * CIFSSMBOpen and then calling get_inode_info with returned buf since 677 * CIFSSMBOpen and then calling get_inode_info with returned buf since
@@ -663,9 +679,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
663 * version of file size can be stale. If we knew for sure that inode was 679 * version of file size can be stale. If we knew for sure that inode was
664 * not dirty locally we could do this. 680 * not dirty locally we could do this.
665 */ 681 */
666 rc = server->ops->open(xid, tcon, full_path, disposition, 682 rc = server->ops->open(xid, &oparms, &oplock, NULL);
667 desired_access, create_options, &fid, &oplock,
668 NULL, cifs_sb);
669 if (rc) { 683 if (rc) {
670 mutex_unlock(&cfile->fh_mutex); 684 mutex_unlock(&cfile->fh_mutex);
671 cifs_dbg(FYI, "cifs_reopen returned 0x%x\n", rc); 685 cifs_dbg(FYI, "cifs_reopen returned 0x%x\n", rc);
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index e813f04511d8..6457690731a2 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -674,20 +674,23 @@ cifs_mkdir_setinfo(struct inode *inode, const char *full_path,
674} 674}
675 675
676static int 676static int
677cifs_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path, 677cifs_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
678 int disposition, int desired_access, int create_options, 678 __u32 *oplock, FILE_ALL_INFO *buf)
679 struct cifs_fid *fid, __u32 *oplock, FILE_ALL_INFO *buf, 679{
680 struct cifs_sb_info *cifs_sb) 680 if (!(oparms->tcon->ses->capabilities & CAP_NT_SMBS))
681{ 681 return SMBLegacyOpen(xid, oparms->tcon, oparms->path,
682 if (!(tcon->ses->capabilities & CAP_NT_SMBS)) 682 oparms->disposition,
683 return SMBLegacyOpen(xid, tcon, path, disposition, 683 oparms->desired_access,
684 desired_access, create_options, 684 oparms->create_options,
685 &fid->netfid, oplock, buf, 685 &oparms->fid->netfid, oplock, buf,
686 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags 686 oparms->cifs_sb->local_nls,
687 oparms->cifs_sb->mnt_cifs_flags
687 & CIFS_MOUNT_MAP_SPECIAL_CHR); 688 & CIFS_MOUNT_MAP_SPECIAL_CHR);
688 return CIFSSMBOpen(xid, tcon, path, disposition, desired_access, 689 return CIFSSMBOpen(xid, oparms->tcon, oparms->path,
689 create_options, &fid->netfid, oplock, buf, 690 oparms->disposition, oparms->desired_access,
690 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & 691 oparms->create_options, &oparms->fid->netfid, oplock,
692 buf, oparms->cifs_sb->local_nls,
693 oparms->cifs_sb->mnt_cifs_flags &
691 CIFS_MOUNT_MAP_SPECIAL_CHR); 694 CIFS_MOUNT_MAP_SPECIAL_CHR);
692} 695}
693 696
diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c
index 150a9b1bc7fa..5bab192f64e8 100644
--- a/fs/cifs/smb2file.c
+++ b/fs/cifs/smb2file.c
@@ -57,17 +57,16 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock)
57} 57}
58 58
59int 59int
60smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path, 60smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
61 int disposition, int desired_access, int create_options, 61 __u32 *oplock, FILE_ALL_INFO *buf)
62 struct cifs_fid *fid, __u32 *oplock, FILE_ALL_INFO *buf,
63 struct cifs_sb_info *cifs_sb)
64{ 62{
65 int rc; 63 int rc;
66 __le16 *smb2_path; 64 __le16 *smb2_path;
67 struct smb2_file_all_info *smb2_data = NULL; 65 struct smb2_file_all_info *smb2_data = NULL;
68 __u8 smb2_oplock[17]; 66 __u8 smb2_oplock[17];
67 struct cifs_fid *fid = oparms->fid;
69 68
70 smb2_path = cifs_convert_path_to_utf16(path, cifs_sb); 69 smb2_path = cifs_convert_path_to_utf16(oparms->path, oparms->cifs_sb);
71 if (smb2_path == NULL) { 70 if (smb2_path == NULL) {
72 rc = -ENOMEM; 71 rc = -ENOMEM;
73 goto out; 72 goto out;
@@ -80,21 +79,22 @@ smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path,
80 goto out; 79 goto out;
81 } 80 }
82 81
83 desired_access |= FILE_READ_ATTRIBUTES; 82 oparms->desired_access |= FILE_READ_ATTRIBUTES;
84 *smb2_oplock = SMB2_OPLOCK_LEVEL_BATCH; 83 *smb2_oplock = SMB2_OPLOCK_LEVEL_BATCH;
85 84
86 if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING) 85 if (oparms->tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
87 memcpy(smb2_oplock + 1, fid->lease_key, SMB2_LEASE_KEY_SIZE); 86 memcpy(smb2_oplock + 1, fid->lease_key, SMB2_LEASE_KEY_SIZE);
88 87
89 rc = SMB2_open(xid, tcon, smb2_path, &fid->persistent_fid, 88 rc = SMB2_open(xid, oparms->tcon, smb2_path, &fid->persistent_fid,
90 &fid->volatile_fid, desired_access, disposition, 89 &fid->volatile_fid, oparms->desired_access,
91 create_options, smb2_oplock, smb2_data); 90 oparms->disposition, oparms->create_options, smb2_oplock,
91 smb2_data);
92 if (rc) 92 if (rc)
93 goto out; 93 goto out;
94 94
95 if (buf) { 95 if (buf) {
96 /* open response does not have IndexNumber field - get it */ 96 /* open response does not have IndexNumber field - get it */
97 rc = SMB2_get_srv_num(xid, tcon, fid->persistent_fid, 97 rc = SMB2_get_srv_num(xid, oparms->tcon, fid->persistent_fid,
98 fid->volatile_fid, 98 fid->volatile_fid,
99 &smb2_data->IndexNumber); 99 &smb2_data->IndexNumber);
100 if (rc) { 100 if (rc) {
diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
index d71a3e2a772d..206efde13f71 100644
--- a/fs/cifs/smb2proto.h
+++ b/fs/cifs/smb2proto.h
@@ -84,11 +84,9 @@ extern int smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
84 const char *from_name, const char *to_name, 84 const char *from_name, const char *to_name,
85 struct cifs_sb_info *cifs_sb); 85 struct cifs_sb_info *cifs_sb);
86 86
87extern int smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, 87extern int smb2_open_file(const unsigned int xid,
88 const char *full_path, int disposition, 88 struct cifs_open_parms *oparms,
89 int desired_access, int create_options, 89 __u32 *oplock, FILE_ALL_INFO *buf);
90 struct cifs_fid *fid, __u32 *oplock,
91 FILE_ALL_INFO *buf, struct cifs_sb_info *cifs_sb);
92extern void smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock); 90extern void smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
93extern int smb2_unlock_range(struct cifsFileInfo *cfile, 91extern int smb2_unlock_range(struct cifsFileInfo *cfile,
94 struct file_lock *flock, const unsigned int xid); 92 struct file_lock *flock, const unsigned int xid);