Commit 226730b4 authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Steve French

CIFS: Introduce cifs_open_parms struct

and pass it to the open() call.
Signed-off-by: default avatarPavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: default avatarSteven French <steven@steven-GA-970A-DS3.(none)>
parent 63eb3def
...@@ -194,6 +194,7 @@ struct cifs_writedata; ...@@ -194,6 +194,7 @@ struct cifs_writedata;
struct cifs_io_parms; struct cifs_io_parms;
struct cifs_search_info; struct cifs_search_info;
struct cifsInodeInfo; struct cifsInodeInfo;
struct cifs_open_parms;
struct smb_version_operations { struct smb_version_operations {
int (*send_cancel)(struct TCP_Server_Info *, void *, int (*send_cancel)(struct TCP_Server_Info *, void *,
...@@ -307,9 +308,8 @@ struct smb_version_operations { ...@@ -307,9 +308,8 @@ struct smb_version_operations {
const char *, const char *, const char *, const char *,
struct cifs_sb_info *); struct cifs_sb_info *);
/* open a file for non-posix mounts */ /* open a file for non-posix mounts */
int (*open)(const unsigned int, struct cifs_tcon *, const char *, int, int (*open)(const unsigned int, struct cifs_open_parms *,
int, int, struct cifs_fid *, __u32 *, FILE_ALL_INFO *, __u32 *, FILE_ALL_INFO *);
struct cifs_sb_info *);
/* set fid protocol-specific info */ /* set fid protocol-specific info */
void (*set_fid)(struct cifsFileInfo *, struct cifs_fid *, __u32); void (*set_fid)(struct cifsFileInfo *, struct cifs_fid *, __u32);
/* close a file */ /* close a file */
...@@ -912,6 +912,16 @@ struct cifs_search_info { ...@@ -912,6 +912,16 @@ struct cifs_search_info {
bool smallBuf:1; /* so we know which buf_release function to call */ bool smallBuf:1; /* so we know which buf_release function to call */
}; };
struct cifs_open_parms {
struct cifs_tcon *tcon;
struct cifs_sb_info *cifs_sb;
int disposition;
int desired_access;
int create_options;
const char *path;
struct cifs_fid *fid;
};
struct cifs_fid { struct cifs_fid {
__u16 netfid; __u16 netfid;
#ifdef CONFIG_CIFS_SMB2 #ifdef CONFIG_CIFS_SMB2
......
...@@ -204,6 +204,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, ...@@ -204,6 +204,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
struct inode *newinode = NULL; struct inode *newinode = NULL;
int disposition; int disposition;
struct TCP_Server_Info *server = tcon->ses->server; struct TCP_Server_Info *server = tcon->ses->server;
struct cifs_open_parms oparms;
*oplock = 0; *oplock = 0;
if (tcon->ses->server->oplocks) if (tcon->ses->server->oplocks)
...@@ -319,9 +320,15 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, ...@@ -319,9 +320,15 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
if (backup_cred(cifs_sb)) if (backup_cred(cifs_sb))
create_options |= CREATE_OPEN_BACKUP_INTENT; create_options |= CREATE_OPEN_BACKUP_INTENT;
rc = server->ops->open(xid, tcon, full_path, disposition, oparms.tcon = tcon;
desired_access, create_options, fid, oplock, oparms.cifs_sb = cifs_sb;
buf, cifs_sb); oparms.desired_access = desired_access;
oparms.create_options = create_options;
oparms.disposition = disposition;
oparms.path = full_path;
oparms.fid = fid;
rc = server->ops->open(xid, &oparms, oplock, buf);
if (rc) { if (rc) {
cifs_dbg(FYI, "cifs_create returned 0x%x\n", rc); cifs_dbg(FYI, "cifs_create returned 0x%x\n", rc);
goto out; goto out;
......
...@@ -183,6 +183,7 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb, ...@@ -183,6 +183,7 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
int create_options = CREATE_NOT_DIR; int create_options = CREATE_NOT_DIR;
FILE_ALL_INFO *buf; FILE_ALL_INFO *buf;
struct TCP_Server_Info *server = tcon->ses->server; struct TCP_Server_Info *server = tcon->ses->server;
struct cifs_open_parms oparms;
if (!server->ops->open) if (!server->ops->open)
return -ENOSYS; return -ENOSYS;
...@@ -224,9 +225,15 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb, ...@@ -224,9 +225,15 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
if (backup_cred(cifs_sb)) if (backup_cred(cifs_sb))
create_options |= CREATE_OPEN_BACKUP_INTENT; create_options |= CREATE_OPEN_BACKUP_INTENT;
rc = server->ops->open(xid, tcon, full_path, disposition, oparms.tcon = tcon;
desired_access, create_options, fid, oplock, buf, oparms.cifs_sb = cifs_sb;
cifs_sb); oparms.desired_access = desired_access;
oparms.create_options = create_options;
oparms.disposition = disposition;
oparms.path = full_path;
oparms.fid = fid;
rc = server->ops->open(xid, &oparms, oplock, buf);
if (rc) if (rc)
goto out; goto out;
...@@ -588,6 +595,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) ...@@ -588,6 +595,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
int disposition = FILE_OPEN; int disposition = FILE_OPEN;
int create_options = CREATE_NOT_DIR; int create_options = CREATE_NOT_DIR;
struct cifs_fid fid; struct cifs_fid fid;
struct cifs_open_parms oparms;
xid = get_xid(); xid = get_xid();
mutex_lock(&cfile->fh_mutex); mutex_lock(&cfile->fh_mutex);
...@@ -656,6 +664,14 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) ...@@ -656,6 +664,14 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
if (server->ops->get_lease_key) if (server->ops->get_lease_key)
server->ops->get_lease_key(inode, &fid); server->ops->get_lease_key(inode, &fid);
oparms.tcon = tcon;
oparms.cifs_sb = cifs_sb;
oparms.desired_access = desired_access;
oparms.create_options = create_options;
oparms.disposition = disposition;
oparms.path = full_path;
oparms.fid = &fid;
/* /*
* Can not refresh inode by passing in file_info buf to be returned by * Can not refresh inode by passing in file_info buf to be returned by
* CIFSSMBOpen and then calling get_inode_info with returned buf since * 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,9 +679,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
* version of file size can be stale. If we knew for sure that inode was * version of file size can be stale. If we knew for sure that inode was
* not dirty locally we could do this. * not dirty locally we could do this.
*/ */
rc = server->ops->open(xid, tcon, full_path, disposition, rc = server->ops->open(xid, &oparms, &oplock, NULL);
desired_access, create_options, &fid, &oplock,
NULL, cifs_sb);
if (rc) { if (rc) {
mutex_unlock(&cfile->fh_mutex); mutex_unlock(&cfile->fh_mutex);
cifs_dbg(FYI, "cifs_reopen returned 0x%x\n", rc); cifs_dbg(FYI, "cifs_reopen returned 0x%x\n", rc);
......
...@@ -674,20 +674,23 @@ cifs_mkdir_setinfo(struct inode *inode, const char *full_path, ...@@ -674,20 +674,23 @@ cifs_mkdir_setinfo(struct inode *inode, const char *full_path,
} }
static int static int
cifs_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path, cifs_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
int disposition, int desired_access, int create_options, __u32 *oplock, FILE_ALL_INFO *buf)
struct cifs_fid *fid, __u32 *oplock, FILE_ALL_INFO *buf, {
struct cifs_sb_info *cifs_sb) if (!(oparms->tcon->ses->capabilities & CAP_NT_SMBS))
{ return SMBLegacyOpen(xid, oparms->tcon, oparms->path,
if (!(tcon->ses->capabilities & CAP_NT_SMBS)) oparms->disposition,
return SMBLegacyOpen(xid, tcon, path, disposition, oparms->desired_access,
desired_access, create_options, oparms->create_options,
&fid->netfid, oplock, buf, &oparms->fid->netfid, oplock, buf,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags oparms->cifs_sb->local_nls,
oparms->cifs_sb->mnt_cifs_flags
& CIFS_MOUNT_MAP_SPECIAL_CHR); & CIFS_MOUNT_MAP_SPECIAL_CHR);
return CIFSSMBOpen(xid, tcon, path, disposition, desired_access, return CIFSSMBOpen(xid, oparms->tcon, oparms->path,
create_options, &fid->netfid, oplock, buf, oparms->disposition, oparms->desired_access,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & oparms->create_options, &oparms->fid->netfid, oplock,
buf, oparms->cifs_sb->local_nls,
oparms->cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
} }
......
...@@ -57,17 +57,16 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock) ...@@ -57,17 +57,16 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock)
} }
int int
smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path, smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
int disposition, int desired_access, int create_options, __u32 *oplock, FILE_ALL_INFO *buf)
struct cifs_fid *fid, __u32 *oplock, FILE_ALL_INFO *buf,
struct cifs_sb_info *cifs_sb)
{ {
int rc; int rc;
__le16 *smb2_path; __le16 *smb2_path;
struct smb2_file_all_info *smb2_data = NULL; struct smb2_file_all_info *smb2_data = NULL;
__u8 smb2_oplock[17]; __u8 smb2_oplock[17];
struct cifs_fid *fid = oparms->fid;
smb2_path = cifs_convert_path_to_utf16(path, cifs_sb); smb2_path = cifs_convert_path_to_utf16(oparms->path, oparms->cifs_sb);
if (smb2_path == NULL) { if (smb2_path == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -80,21 +79,22 @@ smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path, ...@@ -80,21 +79,22 @@ smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path,
goto out; goto out;
} }
desired_access |= FILE_READ_ATTRIBUTES; oparms->desired_access |= FILE_READ_ATTRIBUTES;
*smb2_oplock = SMB2_OPLOCK_LEVEL_BATCH; *smb2_oplock = SMB2_OPLOCK_LEVEL_BATCH;
if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING) if (oparms->tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
memcpy(smb2_oplock + 1, fid->lease_key, SMB2_LEASE_KEY_SIZE); memcpy(smb2_oplock + 1, fid->lease_key, SMB2_LEASE_KEY_SIZE);
rc = SMB2_open(xid, tcon, smb2_path, &fid->persistent_fid, rc = SMB2_open(xid, oparms->tcon, smb2_path, &fid->persistent_fid,
&fid->volatile_fid, desired_access, disposition, &fid->volatile_fid, oparms->desired_access,
create_options, smb2_oplock, smb2_data); oparms->disposition, oparms->create_options, smb2_oplock,
smb2_data);
if (rc) if (rc)
goto out; goto out;
if (buf) { if (buf) {
/* open response does not have IndexNumber field - get it */ /* open response does not have IndexNumber field - get it */
rc = SMB2_get_srv_num(xid, tcon, fid->persistent_fid, rc = SMB2_get_srv_num(xid, oparms->tcon, fid->persistent_fid,
fid->volatile_fid, fid->volatile_fid,
&smb2_data->IndexNumber); &smb2_data->IndexNumber);
if (rc) { if (rc) {
......
...@@ -84,11 +84,9 @@ extern int smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -84,11 +84,9 @@ extern int smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
const char *from_name, const char *to_name, const char *from_name, const char *to_name,
struct cifs_sb_info *cifs_sb); struct cifs_sb_info *cifs_sb);
extern int smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, extern int smb2_open_file(const unsigned int xid,
const char *full_path, int disposition, struct cifs_open_parms *oparms,
int desired_access, int create_options, __u32 *oplock, FILE_ALL_INFO *buf);
struct cifs_fid *fid, __u32 *oplock,
FILE_ALL_INFO *buf, struct cifs_sb_info *cifs_sb);
extern void smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock); extern void smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
extern int smb2_unlock_range(struct cifsFileInfo *cfile, extern int smb2_unlock_range(struct cifsFileInfo *cfile,
struct file_lock *flock, const unsigned int xid); struct file_lock *flock, const unsigned int xid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment