Commit 6c06be90 authored by Pali Rohár's avatar Pali Rohár Committed by Steve French
Browse files

cifs: Check if server supports reparse points before using them



Do not attempt to query or create reparse point when server fs does not
support it. This will prevent creating unusable empty object on the server.

Signed-off-by: default avatarPali Rohár <pali@kernel.org>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 5eeebd99
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2709,6 +2709,9 @@ int cifs_query_reparse_point(const unsigned int xid,
	if (cap_unix(tcon->ses))
		return -EOPNOTSUPP;

	if (!(le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS))
		return -EOPNOTSUPP;

	oparms = (struct cifs_open_parms) {
		.tcon = tcon,
		.cifs_sb = cifs_sb,
+2 −1
Original line number Diff line number Diff line
@@ -643,7 +643,8 @@ cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
	case CIFS_SYMLINK_TYPE_NATIVE:
	case CIFS_SYMLINK_TYPE_NFS:
	case CIFS_SYMLINK_TYPE_WSL:
		if (server->ops->create_reparse_symlink) {
		if (server->ops->create_reparse_symlink &&
		    (le32_to_cpu(pTcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS)) {
			rc = server->ops->create_reparse_symlink(xid, inode,
								 direntry,
								 pTcon,
+8 −0
Original line number Diff line number Diff line
@@ -1273,6 +1273,14 @@ struct inode *smb2_get_reparse_inode(struct cifs_open_info_data *data,
	int rc;
	int i;

	/*
	 * If server filesystem does not support reparse points then do not
	 * attempt to create reparse point. This will prevent creating unusable
	 * empty object on the server.
	 */
	if (!(le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS))
		return ERR_PTR(-EOPNOTSUPP);

	oparms = CIFS_OPARMS(cifs_sb, tcon, full_path,
			     SYNCHRONIZE | DELETE |
			     FILE_READ_ATTRIBUTES |
+2 −2
Original line number Diff line number Diff line
@@ -5229,7 +5229,7 @@ static int smb2_make_node(unsigned int xid, struct inode *inode,
			  const char *full_path, umode_t mode, dev_t dev)
{
	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
	int rc;
	int rc = -EOPNOTSUPP;

	/*
	 * Check if mounted with mount parm 'sfu' mount parm.
@@ -5240,7 +5240,7 @@ static int smb2_make_node(unsigned int xid, struct inode *inode,
	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
		rc = cifs_sfu_make_node(xid, inode, dentry, tcon,
					full_path, mode, dev);
	} else {
	} else if (le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS) {
		rc = smb2_mknod_reparse(xid, inode, dentry, tcon,
					full_path, mode, dev);
	}