Commit d81b8a40 authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Steve French

CIFS: Cleanup cifs open codepath

Rename CIFSSMBOpen to CIFS_open and make it take
cifs_open_parms structure as a parm.
Signed-off-by: default avatarPavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
parent 0360d605
...@@ -895,9 +895,10 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, ...@@ -895,9 +895,10 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
int oplock = 0; int oplock = 0;
unsigned int xid; unsigned int xid;
int rc, create_options = 0; int rc, create_options = 0;
__u16 fid;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
struct cifs_fid fid;
struct cifs_open_parms oparms;
if (IS_ERR(tlink)) if (IS_ERR(tlink))
return ERR_CAST(tlink); return ERR_CAST(tlink);
...@@ -908,12 +909,19 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, ...@@ -908,12 +909,19 @@ static struct cifs_ntsd *get_cifs_acl_by_path(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 = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, oparms.tcon = tcon;
create_options, &fid, &oplock, NULL, cifs_sb->local_nls, oparms.cifs_sb = cifs_sb;
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); oparms.desired_access = READ_CONTROL;
oparms.create_options = create_options;
oparms.disposition = FILE_OPEN;
oparms.path = path;
oparms.fid = &fid;
oparms.reconnect = false;
rc = CIFS_open(xid, &oparms, &oplock, NULL);
if (!rc) { if (!rc) {
rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen); rc = CIFSSMBGetCIFSACL(xid, tcon, fid.netfid, &pntsd, pacllen);
CIFSSMBClose(xid, tcon, fid); CIFSSMBClose(xid, tcon, fid.netfid);
} }
cifs_put_tlink(tlink); cifs_put_tlink(tlink);
...@@ -950,10 +958,11 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, ...@@ -950,10 +958,11 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
int oplock = 0; int oplock = 0;
unsigned int xid; unsigned int xid;
int rc, access_flags, create_options = 0; int rc, access_flags, create_options = 0;
__u16 fid;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
struct cifs_fid fid;
struct cifs_open_parms oparms;
if (IS_ERR(tlink)) if (IS_ERR(tlink))
return PTR_ERR(tlink); return PTR_ERR(tlink);
...@@ -969,18 +978,25 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, ...@@ -969,18 +978,25 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
else else
access_flags = WRITE_DAC; access_flags = WRITE_DAC;
rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, access_flags, oparms.tcon = tcon;
create_options, &fid, &oplock, NULL, cifs_sb->local_nls, oparms.cifs_sb = cifs_sb;
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); oparms.desired_access = access_flags;
oparms.create_options = create_options;
oparms.disposition = FILE_OPEN;
oparms.path = path;
oparms.fid = &fid;
oparms.reconnect = false;
rc = CIFS_open(xid, &oparms, &oplock, NULL);
if (rc) { if (rc) {
cifs_dbg(VFS, "Unable to open file to set ACL\n"); cifs_dbg(VFS, "Unable to open file to set ACL\n");
goto out; goto out;
} }
rc = CIFSSMBSetCIFSACL(xid, tcon, fid, pnntsd, acllen, aclflag); rc = CIFSSMBSetCIFSACL(xid, tcon, fid.netfid, pnntsd, acllen, aclflag);
cifs_dbg(NOISY, "SetCIFSACL rc = %d\n", rc); cifs_dbg(NOISY, "SetCIFSACL rc = %d\n", rc);
CIFSSMBClose(xid, tcon, fid); CIFSSMBClose(xid, tcon, fid.netfid);
out: out:
free_xid(xid); free_xid(xid);
cifs_put_tlink(tlink); cifs_put_tlink(tlink);
......
...@@ -362,11 +362,8 @@ extern int CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -362,11 +362,8 @@ extern int CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon,
const struct nls_table *nls_codepage); const struct nls_table *nls_codepage);
extern int CIFSSMB_set_compression(const unsigned int xid, extern int CIFSSMB_set_compression(const unsigned int xid,
struct cifs_tcon *tcon, __u16 fid); struct cifs_tcon *tcon, __u16 fid);
extern int CIFSSMBOpen(const unsigned int xid, struct cifs_tcon *tcon, extern int CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms,
const char *path, const int disposition, int *oplock, FILE_ALL_INFO *buf);
const int desired_access, const int create_options,
__u16 *netfid, int *oplock, FILE_ALL_INFO *buf,
const struct nls_table *nls, int remap);
extern int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon, extern int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon,
const char *fileName, const int disposition, const char *fileName, const int disposition,
const int access_flags, const int omode, const int access_flags, const int omode,
......
...@@ -1273,10 +1273,8 @@ SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -1273,10 +1273,8 @@ SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon,
} }
int int
CIFSSMBOpen(const unsigned int xid, struct cifs_tcon *tcon, CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms, int *oplock,
const char *path, const int disposition, const int desired_access, FILE_ALL_INFO *buf)
const int create_options, __u16 *netfid, int *oplock,
FILE_ALL_INFO *buf, const struct nls_table *nls, int remap)
{ {
int rc = -EACCES; int rc = -EACCES;
OPEN_REQ *req = NULL; OPEN_REQ *req = NULL;
...@@ -1284,6 +1282,14 @@ CIFSSMBOpen(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -1284,6 +1282,14 @@ CIFSSMBOpen(const unsigned int xid, struct cifs_tcon *tcon,
int bytes_returned; int bytes_returned;
int name_len; int name_len;
__u16 count; __u16 count;
struct cifs_sb_info *cifs_sb = oparms->cifs_sb;
struct cifs_tcon *tcon = oparms->tcon;
int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
const struct nls_table *nls = cifs_sb->local_nls;
int create_options = oparms->create_options;
int desired_access = oparms->desired_access;
int disposition = oparms->disposition;
const char *path = oparms->path;
openRetry: openRetry:
rc = smb_init(SMB_COM_NT_CREATE_ANDX, 24, tcon, (void **)&req, rc = smb_init(SMB_COM_NT_CREATE_ANDX, 24, tcon, (void **)&req,
...@@ -1367,7 +1373,7 @@ CIFSSMBOpen(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -1367,7 +1373,7 @@ CIFSSMBOpen(const unsigned int xid, struct cifs_tcon *tcon,
/* 1 byte no need to le_to_cpu */ /* 1 byte no need to le_to_cpu */
*oplock = rsp->OplockLevel; *oplock = rsp->OplockLevel;
/* cifs fid stays in le */ /* cifs fid stays in le */
*netfid = rsp->Fid; oparms->fid->netfid = rsp->Fid;
/* Let caller know file was created so we can set the mode. */ /* Let caller know file was created so we can set the mode. */
/* Do we care about the CreateAction in any other cases? */ /* Do we care about the CreateAction in any other cases? */
......
...@@ -570,7 +570,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, ...@@ -570,7 +570,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
char *full_path = NULL; char *full_path = NULL;
struct inode *newinode = NULL; struct inode *newinode = NULL;
int oplock = 0; int oplock = 0;
u16 netfid; struct cifs_fid fid;
struct cifs_open_parms oparms;
FILE_ALL_INFO *buf = NULL; FILE_ALL_INFO *buf = NULL;
unsigned int bytes_written; unsigned int bytes_written;
struct win_dev *pdev; struct win_dev *pdev;
...@@ -640,10 +641,16 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, ...@@ -640,10 +641,16 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
if (backup_cred(cifs_sb)) if (backup_cred(cifs_sb))
create_options |= CREATE_OPEN_BACKUP_INTENT; create_options |= CREATE_OPEN_BACKUP_INTENT;
rc = CIFSSMBOpen(xid, tcon, full_path, FILE_CREATE, oparms.tcon = tcon;
GENERIC_WRITE, create_options, oparms.cifs_sb = cifs_sb;
&netfid, &oplock, buf, cifs_sb->local_nls, oparms.desired_access = GENERIC_WRITE;
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); oparms.create_options = create_options;
oparms.disposition = FILE_CREATE;
oparms.path = full_path;
oparms.fid = &fid;
oparms.reconnect = false;
rc = CIFS_open(xid, &oparms, &oplock, buf);
if (rc) if (rc)
goto mknod_out; goto mknod_out;
...@@ -653,7 +660,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, ...@@ -653,7 +660,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
*/ */
pdev = (struct win_dev *)buf; pdev = (struct win_dev *)buf;
io_parms.netfid = netfid; io_parms.netfid = fid.netfid;
io_parms.pid = current->tgid; io_parms.pid = current->tgid;
io_parms.tcon = tcon; io_parms.tcon = tcon;
io_parms.offset = 0; io_parms.offset = 0;
...@@ -671,7 +678,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, ...@@ -671,7 +678,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
rc = CIFSSMBWrite(xid, &io_parms, &bytes_written, (char *)pdev, rc = CIFSSMBWrite(xid, &io_parms, &bytes_written, (char *)pdev,
NULL, 0); NULL, 0);
} /* else if (S_ISFIFO) */ } /* else if (S_ISFIFO) */
CIFSSMBClose(xid, tcon, netfid); CIFSSMBClose(xid, tcon, fid.netfid);
d_drop(direntry); d_drop(direntry);
/* FIXME: add code here to set EAs */ /* FIXME: add code here to set EAs */
......
...@@ -678,7 +678,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) ...@@ -678,7 +678,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
/* /*
* 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 * ops->open and then calling get_inode_info with returned buf since
* file might have write behind data that needs to be flushed and server * file might have write behind data that needs to be flushed and server
* 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.
......
...@@ -409,9 +409,10 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, ...@@ -409,9 +409,10 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
{ {
int rc; int rc;
int oplock = 0; int oplock = 0;
__u16 netfid;
struct tcon_link *tlink; struct tcon_link *tlink;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
struct cifs_fid fid;
struct cifs_open_parms oparms;
struct cifs_io_parms io_parms; struct cifs_io_parms io_parms;
char buf[24]; char buf[24];
unsigned int bytes_read; unsigned int bytes_read;
...@@ -437,18 +438,23 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, ...@@ -437,18 +438,23 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
return PTR_ERR(tlink); return PTR_ERR(tlink);
tcon = tlink_tcon(tlink); tcon = tlink_tcon(tlink);
rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, GENERIC_READ, oparms.tcon = tcon;
CREATE_NOT_DIR, &netfid, &oplock, NULL, oparms.cifs_sb = cifs_sb;
cifs_sb->local_nls, oparms.desired_access = GENERIC_READ;
cifs_sb->mnt_cifs_flags & oparms.create_options = CREATE_NOT_DIR;
CIFS_MOUNT_MAP_SPECIAL_CHR); oparms.disposition = FILE_OPEN;
oparms.path = path;
oparms.fid = &fid;
oparms.reconnect = false;
rc = CIFS_open(xid, &oparms, &oplock, NULL);
if (rc) { if (rc) {
cifs_put_tlink(tlink); cifs_put_tlink(tlink);
return rc; return rc;
} }
/* Read header */ /* Read header */
io_parms.netfid = netfid; io_parms.netfid = fid.netfid;
io_parms.pid = current->tgid; io_parms.pid = current->tgid;
io_parms.tcon = tcon; io_parms.tcon = tcon;
io_parms.offset = 0; io_parms.offset = 0;
...@@ -494,7 +500,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, ...@@ -494,7 +500,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
fattr->cf_dtype = DT_REG; fattr->cf_dtype = DT_REG;
rc = -EOPNOTSUPP; /* or some unknown SFU type */ rc = -EOPNOTSUPP; /* or some unknown SFU type */
} }
CIFSSMBClose(xid, tcon, netfid); CIFSSMBClose(xid, tcon, fid.netfid);
cifs_put_tlink(tlink); cifs_put_tlink(tlink);
return rc; return rc;
} }
...@@ -1035,7 +1041,8 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, ...@@ -1035,7 +1041,8 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
{ {
int oplock = 0; int oplock = 0;
int rc; int rc;
__u16 netfid; struct cifs_fid fid;
struct cifs_open_parms oparms;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct cifsInodeInfo *cifsInode = CIFS_I(inode); struct cifsInodeInfo *cifsInode = CIFS_I(inode);
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
...@@ -1058,10 +1065,16 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, ...@@ -1058,10 +1065,16 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
goto out; goto out;
} }
rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN, oparms.tcon = tcon;
DELETE|FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR, oparms.cifs_sb = cifs_sb;
&netfid, &oplock, NULL, cifs_sb->local_nls, oparms.desired_access = DELETE | FILE_WRITE_ATTRIBUTES;
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); oparms.create_options = CREATE_NOT_DIR;
oparms.disposition = FILE_OPEN;
oparms.path = full_path;
oparms.fid = &fid;
oparms.reconnect = false;
rc = CIFS_open(xid, &oparms, &oplock, NULL);
if (rc != 0) if (rc != 0)
goto out; goto out;
...@@ -1082,7 +1095,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, ...@@ -1082,7 +1095,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
goto out_close; goto out_close;
} }
info_buf->Attributes = cpu_to_le32(dosattr); info_buf->Attributes = cpu_to_le32(dosattr);
rc = CIFSSMBSetFileInfo(xid, tcon, info_buf, netfid, rc = CIFSSMBSetFileInfo(xid, tcon, info_buf, fid.netfid,
current->tgid); current->tgid);
/* although we would like to mark the file hidden /* although we would like to mark the file hidden
if that fails we will still try to rename it */ if that fails we will still try to rename it */
...@@ -1093,7 +1106,8 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, ...@@ -1093,7 +1106,8 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
} }
/* rename the file */ /* rename the file */
rc = CIFSSMBRenameOpenFile(xid, tcon, netfid, NULL, cifs_sb->local_nls, rc = CIFSSMBRenameOpenFile(xid, tcon, fid.netfid, NULL,
cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc != 0) { if (rc != 0) {
...@@ -1103,7 +1117,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, ...@@ -1103,7 +1117,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
/* try to set DELETE_ON_CLOSE */ /* try to set DELETE_ON_CLOSE */
if (!cifsInode->delete_pending) { if (!cifsInode->delete_pending) {
rc = CIFSSMBSetFileDisposition(xid, tcon, true, netfid, rc = CIFSSMBSetFileDisposition(xid, tcon, true, fid.netfid,
current->tgid); current->tgid);
/* /*
* some samba versions return -ENOENT when we try to set the * some samba versions return -ENOENT when we try to set the
...@@ -1123,7 +1137,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, ...@@ -1123,7 +1137,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
} }
out_close: out_close:
CIFSSMBClose(xid, tcon, netfid); CIFSSMBClose(xid, tcon, fid.netfid);
out: out:
kfree(info_buf); kfree(info_buf);
cifs_put_tlink(tlink); cifs_put_tlink(tlink);
...@@ -1135,13 +1149,13 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, ...@@ -1135,13 +1149,13 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
* them anyway. * them anyway.
*/ */
undo_rename: undo_rename:
CIFSSMBRenameOpenFile(xid, tcon, netfid, dentry->d_name.name, CIFSSMBRenameOpenFile(xid, tcon, fid.netfid, dentry->d_name.name,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
undo_setattr: undo_setattr:
if (dosattr != origattr) { if (dosattr != origattr) {
info_buf->Attributes = cpu_to_le32(origattr); info_buf->Attributes = cpu_to_le32(origattr);
if (!CIFSSMBSetFileInfo(xid, tcon, info_buf, netfid, if (!CIFSSMBSetFileInfo(xid, tcon, info_buf, fid.netfid,
current->tgid)) current->tgid))
cifsInode->cifsAttrs = origattr; cifsInode->cifsAttrs = origattr;
} }
...@@ -1552,7 +1566,8 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry, ...@@ -1552,7 +1566,8 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
struct tcon_link *tlink; struct tcon_link *tlink;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
struct TCP_Server_Info *server; struct TCP_Server_Info *server;
__u16 srcfid; struct cifs_fid fid;
struct cifs_open_parms oparms;
int oplock, rc; int oplock, rc;
tlink = cifs_sb_tlink(cifs_sb); tlink = cifs_sb_tlink(cifs_sb);
...@@ -1579,17 +1594,23 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry, ...@@ -1579,17 +1594,23 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
if (to_dentry->d_parent != from_dentry->d_parent) if (to_dentry->d_parent != from_dentry->d_parent)
goto do_rename_exit; goto do_rename_exit;
oparms.tcon = tcon;
oparms.cifs_sb = cifs_sb;
/* open the file to be renamed -- we need DELETE perms */ /* open the file to be renamed -- we need DELETE perms */
rc = CIFSSMBOpen(xid, tcon, from_path, FILE_OPEN, DELETE, oparms.desired_access = DELETE;
CREATE_NOT_DIR, &srcfid, &oplock, NULL, oparms.create_options = CREATE_NOT_DIR;
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & oparms.disposition = FILE_OPEN;
CIFS_MOUNT_MAP_SPECIAL_CHR); oparms.path = from_path;
oparms.fid = &fid;
oparms.reconnect = false;
rc = CIFS_open(xid, &oparms, &oplock, NULL);
if (rc == 0) { if (rc == 0) {
rc = CIFSSMBRenameOpenFile(xid, tcon, srcfid, rc = CIFSSMBRenameOpenFile(xid, tcon, fid.netfid,
(const char *) to_dentry->d_name.name, (const char *) to_dentry->d_name.name,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
CIFSSMBClose(xid, tcon, srcfid); CIFSSMBClose(xid, tcon, fid.netfid);
} }
do_rename_exit: do_rename_exit:
cifs_put_tlink(tlink); cifs_put_tlink(tlink);
......
...@@ -320,16 +320,22 @@ cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, ...@@ -320,16 +320,22 @@ cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
{ {
int rc; int rc;
int oplock = 0; int oplock = 0;
__u16 netfid = 0; struct cifs_fid fid;
struct cifs_open_parms oparms;
struct cifs_io_parms io_parms; struct cifs_io_parms io_parms;
int buf_type = CIFS_NO_BUFFER; int buf_type = CIFS_NO_BUFFER;
FILE_ALL_INFO file_info; FILE_ALL_INFO file_info;
rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, GENERIC_READ, oparms.tcon = tcon;
CREATE_NOT_DIR, &netfid, &oplock, &file_info, oparms.cifs_sb = cifs_sb;
cifs_sb->local_nls, oparms.desired_access = GENERIC_READ;
cifs_sb->mnt_cifs_flags & oparms.create_options = CREATE_NOT_DIR;
CIFS_MOUNT_MAP_SPECIAL_CHR); oparms.disposition = FILE_OPEN;
oparms.path = path;
oparms.fid = &fid;
oparms.reconnect = false;
rc = CIFS_open(xid, &oparms, &oplock, &file_info);
if (rc) if (rc)
return rc; return rc;
...@@ -337,7 +343,7 @@ cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, ...@@ -337,7 +343,7 @@ cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
/* it's not a symlink */ /* it's not a symlink */
goto out; goto out;
io_parms.netfid = netfid; io_parms.netfid = fid.netfid;
io_parms.pid = current->tgid; io_parms.pid = current->tgid;
io_parms.tcon = tcon; io_parms.tcon = tcon;
io_parms.offset = 0; io_parms.offset = 0;
...@@ -345,7 +351,7 @@ cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, ...@@ -345,7 +351,7 @@ cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
rc = CIFSSMBRead(xid, &io_parms, pbytes_read, &pbuf, &buf_type); rc = CIFSSMBRead(xid, &io_parms, pbytes_read, &pbuf, &buf_type);
out: out:
CIFSSMBClose(xid, tcon, netfid); CIFSSMBClose(xid, tcon, fid.netfid);
return rc; return rc;
} }
...@@ -356,29 +362,35 @@ cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, ...@@ -356,29 +362,35 @@ cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
{ {
int rc; int rc;
int oplock = 0; int oplock = 0;
__u16 netfid = 0; struct cifs_fid fid;
struct cifs_open_parms oparms;
struct cifs_io_parms io_parms; struct cifs_io_parms io_parms;
int create_options = CREATE_NOT_DIR; int create_options = CREATE_NOT_DIR;
if (backup_cred(cifs_sb)) if (backup_cred(cifs_sb))
create_options |= CREATE_OPEN_BACKUP_INTENT; create_options |= CREATE_OPEN_BACKUP_INTENT;
rc = CIFSSMBOpen(xid, tcon, path, FILE_CREATE, GENERIC_WRITE, oparms.tcon = tcon;
create_options, &netfid, &oplock, NULL, oparms.cifs_sb = cifs_sb;
cifs_sb->local_nls, oparms.desired_access = GENERIC_WRITE;
cifs_sb->mnt_cifs_flags & oparms.create_options = create_options;
CIFS_MOUNT_MAP_SPECIAL_CHR); oparms.disposition = FILE_OPEN;
oparms.path = path;
oparms.fid = &fid;
oparms.reconnect = false;
rc = CIFS_open(xid, &oparms, &oplock, NULL);
if (rc) if (rc)
return rc; return rc;
io_parms.netfid = netfid; io_parms.netfid = fid.netfid;
io_parms.pid = current->tgid; io_parms.pid = current->tgid;
io_parms.tcon = tcon; io_parms.tcon = tcon;
io_parms.offset = 0; io_parms.offset = 0;
io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE; io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
rc = CIFSSMBWrite(xid, &io_parms, pbytes_written, pbuf, NULL, 0); rc = CIFSSMBWrite(xid, &io_parms, pbytes_written, pbuf, NULL, 0);
CIFSSMBClose(xid, tcon, netfid); CIFSSMBClose(xid, tcon, fid.netfid);
return rc; return rc;
} }
......
...@@ -560,17 +560,24 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -560,17 +560,24 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
if (!rc && (le32_to_cpu(data->Attributes) & ATTR_REPARSE)) { if (!rc && (le32_to_cpu(data->Attributes) & ATTR_REPARSE)) {
int tmprc; int tmprc;
int oplock = 0; int oplock = 0;
__u16 netfid; struct cifs_fid fid;
struct cifs_open_parms oparms;
oparms.tcon = tcon;
oparms.cifs_sb = cifs_sb;
oparms.desired_access = FILE_READ_ATTRIBUTES;
oparms.create_options = 0;
oparms.disposition = FILE_OPEN;
oparms.path = full_path;
oparms.fid = &fid;
oparms.reconnect = false;
/* Need to check if this is a symbolic link or not */ /* Need to check if this is a symbolic link or not */
tmprc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN, tmprc = CIFS_open(xid, &oparms, &oplock, NULL);
FILE_READ_ATTRIBUTES, 0, &netfid, &oplock,
NULL, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
if (tmprc == -EOPNOTSUPP) if (tmprc == -EOPNOTSUPP)
*symlink = true; *symlink = true;
else else
CIFSSMBClose(xid, tcon, netfid); CIFSSMBClose(xid, tcon, fid.netfid);
} }
return rc; return rc;
...@@ -705,12 +712,7 @@ cifs_open_file(const unsigned int xid, struct cifs_open_parms *oparms, ...@@ -705,12 +712,7 @@ cifs_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
oparms->cifs_sb->local_nls, oparms->cifs_sb->local_nls,
oparms->cifs_sb->mnt_cifs_flags oparms->cifs_sb->mnt_cifs_flags
& CIFS_MOUNT_MAP_SPECIAL_CHR); & CIFS_MOUNT_MAP_SPECIAL_CHR);
return CIFSSMBOpen(xid, oparms->tcon, oparms->path, return CIFS_open(xid, oparms, oplock, buf);
oparms->disposition, oparms->desired_access,
oparms->create_options, &oparms->fid->netfid, oplock,
buf, oparms->cifs_sb->local_nls,
oparms->cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
} }
static void static void
...@@ -761,8 +763,9 @@ smb_set_file_info(struct inode *inode, const char *full_path, ...@@ -761,8 +763,9 @@ smb_set_file_info(struct inode *inode, const char *full_path,
{ {
int oplock = 0; int oplock = 0;
int rc; int rc;
__u16 netfid;
__u32 netpid; __u32 netpid;
struct cifs_fid fid;
struct cifs_open_parms oparms;
struct cifsFileInfo *open_file; struct cifsFileInfo *open_file;
struct cifsInodeInfo *cinode = CIFS_I(inode); struct cifsInodeInfo *cinode = CIFS_I(inode);
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
...@@ -772,7 +775,7 @@ smb_set_file_info(struct inode *inode, const char *full_path, ...@@ -772,7 +775,7 @@ smb_set_file_info(struct inode *inode, const char *full_path,
/* if the file is already open for write, just use that fileid */ /* if the file is already open for write, just use that fileid */
open_file = find_writable_file(cinode, true); open_file = find_writable_file(cinode, true);
if (open_file) { if (open_file) {
netfid = open_file->fid.netfid; fid.netfid = open_file->fid.netfid;
netpid = open_file->pid; netpid = open_file->pid;
tcon = tlink_tcon(open_file->tlink); tcon = tlink_tcon(open_file->tlink);
goto set_via_filehandle; goto set_via_filehandle;
...@@ -796,12 +799,17 @@ smb_set_file_info(struct inode *inode, const char *full_path, ...@@ -796,12 +799,17 @@ smb_set_file_info(struct inode *inode, const char *full_path,
goto out; goto out;
} }
cifs_dbg(FYI, "calling SetFileInfo since SetPathInfo for times not supported by this server\n"); oparms.tcon = tcon;
rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN, oparms.cifs_sb = cifs_sb;
SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR, oparms.desired_access = SYNCHRONIZE | FILE_WRITE_ATTRIBUTES;
&netfid, &oplock, NULL, cifs_sb->local_nls, oparms.create_options = CREATE_NOT_DIR;
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); oparms.disposition = FILE_OPEN;
oparms.path = full_path;
oparms.fid = &fid;
oparms.reconnect = false;
cifs_dbg(FYI, "calling SetFileInfo since SetPathInfo for times not supported by this server\n");
rc = CIFS_open(xid, &oparms, &oplock, NULL);
if (rc != 0) { if (rc != 0) {
if (rc == -EIO) if (rc == -EIO)
rc = -EINVAL; rc = -EINVAL;
...@@ -811,12 +819,12 @@ smb_set_file_info(struct inode *inode, const char *full_path, ...@@ -811,12 +819,12 @@ smb_set_file_info(struct inode *inode, const char *full_path,
netpid = current->tgid; netpid = current->tgid;
set_via_filehandle: set_via_filehandle:
rc = CIFSSMBSetFileInfo(xid, tcon, buf, netfid, netpid); rc = CIFSSMBSetFileInfo(xid, tcon, buf, fid.netfid, netpid);
if (!rc) if (!rc)
cinode->cifsAttrs = le32_to_cpu(buf->Attributes); cinode->cifsAttrs = le32_to_cpu(buf->Attributes);
if (open_file == NULL) if (open_file == NULL)
CIFSSMBClose(xid, tcon, netfid); CIFSSMBClose(xid, tcon, fid.netfid);
else else
cifsFileInfo_put(open_file); cifsFileInfo_put(open_file);
out: out:
...@@ -941,7 +949,8 @@ cifs_query_symlink(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -941,7 +949,8 @@ cifs_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
{ {
int rc; int rc;
int oplock = 0; int oplock = 0;
__u16 netfid; struct cifs_fid fid;
struct cifs_open_parms oparms;
cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path); cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);
...@@ -957,21 +966,27 @@ cifs_query_symlink(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -957,21 +966,27 @@ cifs_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
goto out; goto out;
} }
rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN, oparms.tcon = tcon;
FILE_READ_ATTRIBUTES, OPEN_REPARSE_POINT, &netfid, oparms.cifs_sb = cifs_sb;
&oplock, NULL, cifs_sb->local_nls, oparms.desired_access = FILE_READ_ATTRIBUTES;
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); oparms.create_options = OPEN_REPARSE_POINT;
oparms.disposition = FILE_OPEN;
oparms.path = full_path;
oparms.fid = &fid;
oparms.reconnect = false;
rc = CIFS_open(xid, &oparms, &oplock, NULL);
if (rc) if (rc)
goto out; goto out;
rc = CIFSSMBQuerySymLink(xid, tcon, netfid, target_path, rc = CIFSSMBQuerySymLink(xid, tcon, fid.netfid, target_path,
cifs_sb->local_nls); cifs_sb->local_nls);
if (rc) if (rc)
goto out_close; goto out_close;
convert_delimiter(*target_path, '/'); convert_delimiter(*target_path, '/');
out_close: out_close:
CIFSSMBClose(xid, tcon, netfid); CIFSSMBClose(xid, tcon, fid.netfid);
out: out:
if (!rc) if (!rc)
cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path); cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);
......
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