mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-06 06:37:59 +00:00
CIFS: Simplify cifs_open code
Make the code more general for use in posix and non-posix open. Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Pavel Shilovsky <piastryyy@gmail.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
parent
eeb910a6d4
commit
7e12eddb73
1 changed files with 23 additions and 31 deletions
|
@ -340,6 +340,7 @@ int cifs_open(struct inode *inode, struct file *file)
|
||||||
struct cifsFileInfo *pCifsFile = NULL;
|
struct cifsFileInfo *pCifsFile = NULL;
|
||||||
struct cifsInodeInfo *pCifsInode;
|
struct cifsInodeInfo *pCifsInode;
|
||||||
char *full_path = NULL;
|
char *full_path = NULL;
|
||||||
|
bool posix_open_ok = false;
|
||||||
__u16 netfid;
|
__u16 netfid;
|
||||||
|
|
||||||
xid = GetXid();
|
xid = GetXid();
|
||||||
|
@ -378,17 +379,7 @@ int cifs_open(struct inode *inode, struct file *file)
|
||||||
file->f_flags, &oplock, &netfid, xid);
|
file->f_flags, &oplock, &netfid, xid);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
cFYI(1, "posix open succeeded");
|
cFYI(1, "posix open succeeded");
|
||||||
|
posix_open_ok = true;
|
||||||
pCifsFile = cifs_new_fileinfo(netfid, file, tlink,
|
|
||||||
oplock);
|
|
||||||
if (pCifsFile == NULL) {
|
|
||||||
CIFSSMBClose(xid, tcon, netfid);
|
|
||||||
rc = -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
cifs_fscache_set_inode_cookie(inode, file);
|
|
||||||
|
|
||||||
goto out;
|
|
||||||
} else if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
|
} else if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
|
||||||
if (tcon->ses->serverNOS)
|
if (tcon->ses->serverNOS)
|
||||||
cERROR(1, "server %s of type %s returned"
|
cERROR(1, "server %s of type %s returned"
|
||||||
|
@ -405,37 +396,38 @@ int cifs_open(struct inode *inode, struct file *file)
|
||||||
or DFS errors */
|
or DFS errors */
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = cifs_nt_open(full_path, inode, cifs_sb, tcon, file->f_flags,
|
if (!posix_open_ok) {
|
||||||
&oplock, &netfid, xid);
|
rc = cifs_nt_open(full_path, inode, cifs_sb, tcon,
|
||||||
if (rc)
|
file->f_flags, &oplock, &netfid, xid);
|
||||||
goto out;
|
if (rc)
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
pCifsFile = cifs_new_fileinfo(netfid, file, tlink, oplock);
|
pCifsFile = cifs_new_fileinfo(netfid, file, tlink, oplock);
|
||||||
if (pCifsFile == NULL) {
|
if (pCifsFile == NULL) {
|
||||||
|
CIFSSMBClose(xid, tcon, netfid);
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
cifs_fscache_set_inode_cookie(inode, file);
|
cifs_fscache_set_inode_cookie(inode, file);
|
||||||
|
|
||||||
if (oplock & CIFS_CREATE_ACTION) {
|
if ((oplock & CIFS_CREATE_ACTION) && !posix_open_ok && tcon->unix_ext) {
|
||||||
/* time to set mode which we can not set earlier due to
|
/* time to set mode which we can not set earlier due to
|
||||||
problems creating new read-only files */
|
problems creating new read-only files */
|
||||||
if (tcon->unix_ext) {
|
struct cifs_unix_set_info_args args = {
|
||||||
struct cifs_unix_set_info_args args = {
|
.mode = inode->i_mode,
|
||||||
.mode = inode->i_mode,
|
.uid = NO_CHANGE_64,
|
||||||
.uid = NO_CHANGE_64,
|
.gid = NO_CHANGE_64,
|
||||||
.gid = NO_CHANGE_64,
|
.ctime = NO_CHANGE_64,
|
||||||
.ctime = NO_CHANGE_64,
|
.atime = NO_CHANGE_64,
|
||||||
.atime = NO_CHANGE_64,
|
.mtime = NO_CHANGE_64,
|
||||||
.mtime = NO_CHANGE_64,
|
.device = 0,
|
||||||
.device = 0,
|
};
|
||||||
};
|
CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args,
|
||||||
CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args,
|
cifs_sb->local_nls,
|
||||||
cifs_sb->local_nls,
|
cifs_sb->mnt_cifs_flags &
|
||||||
cifs_sb->mnt_cifs_flags &
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
||||||
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Add table
Reference in a new issue