Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e12eddb authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Steve French
Browse files

CIFS: Simplify cifs_open code



Make the code more general for use in posix and non-posix open.

Reviewed-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarPavel Shilovsky <piastryyy@gmail.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent eeb910a6
Loading
Loading
Loading
Loading
+23 −31
Original line number Diff line number Diff line
@@ -340,6 +340,7 @@ int cifs_open(struct inode *inode, struct file *file)
	struct cifsFileInfo *pCifsFile = NULL;
	struct cifsInodeInfo *pCifsInode;
	char *full_path = NULL;
	bool posix_open_ok = false;
	__u16 netfid;

	xid = GetXid();
@@ -378,17 +379,7 @@ int cifs_open(struct inode *inode, struct file *file)
				file->f_flags, &oplock, &netfid, xid);
		if (rc == 0) {
			cFYI(1, "posix open succeeded");

			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;
			posix_open_ok = true;
		} else if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
			if (tcon->ses->serverNOS)
				cERROR(1, "server %s of type %s returned"
@@ -405,23 +396,25 @@ int cifs_open(struct inode *inode, struct file *file)
		   or DFS errors */
	}

	rc = cifs_nt_open(full_path, inode, cifs_sb, tcon, file->f_flags,
			  &oplock, &netfid, xid);
	if (!posix_open_ok) {
		rc = cifs_nt_open(full_path, inode, cifs_sb, tcon,
				  file->f_flags, &oplock, &netfid, xid);
		if (rc)
			goto out;
	}

	pCifsFile = cifs_new_fileinfo(netfid, file, tlink, oplock);
	if (pCifsFile == NULL) {
		CIFSSMBClose(xid, tcon, netfid);
		rc = -ENOMEM;
		goto out;
	}

	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
		   problems creating new read-only files */
		if (tcon->unix_ext) {
		struct cifs_unix_set_info_args args = {
			.mode	= inode->i_mode,
			.uid	= NO_CHANGE_64,
@@ -436,7 +429,6 @@ int cifs_open(struct inode *inode, struct file *file)
				       cifs_sb->mnt_cifs_flags &
					CIFS_MOUNT_MAP_SPECIAL_CHR);
	}
	}

out:
	kfree(full_path);