Skip to content

Commit

Permalink
smb: client: set correct d_type for reparse points under DFS mounts
Browse files Browse the repository at this point in the history
[ Upstream commit 55c7788 ]

Send query dir requests with an info level of
SMB_FIND_FILE_FULL_DIRECTORY_INFO rather than
SMB_FIND_FILE_DIRECTORY_INFO when the client is generating its own
inode numbers (e.g. noserverino) so that reparse tags still
can be parsed directly from the responses, but server won't
send UniqueId (server inode number)

Signed-off-by: Paulo Alcantara <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
pcacjr authored and gregkh committed Mar 1, 2024
1 parent c19453c commit cacc0a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 8 additions & 7 deletions fs/smb/client/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,16 @@ cifs_dir_info_to_fattr(struct cifs_fattr *fattr, FILE_DIRECTORY_INFO *info,
}

static void cifs_fulldir_info_to_fattr(struct cifs_fattr *fattr,
SEARCH_ID_FULL_DIR_INFO *info,
const void *info,
struct cifs_sb_info *cifs_sb)
{
const FILE_FULL_DIRECTORY_INFO *di = info;

__dir_info_to_fattr(fattr, info);

/* See MS-FSCC 2.4.19 FileIdFullDirectoryInformation */
/* See MS-FSCC 2.4.14, 2.4.19 */
if (fattr->cf_cifsattrs & ATTR_REPARSE)
fattr->cf_cifstag = le32_to_cpu(info->EaSize);
fattr->cf_cifstag = le32_to_cpu(di->EaSize);
cifs_fill_common_info(fattr, cifs_sb);
}

Expand Down Expand Up @@ -420,7 +422,7 @@ _initiate_cifs_search(const unsigned int xid, struct file *file,
} else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
cifsFile->srch_inf.info_level = SMB_FIND_FILE_ID_FULL_DIR_INFO;
} else /* not srvinos - BB fixme add check for backlevel? */ {
cifsFile->srch_inf.info_level = SMB_FIND_FILE_DIRECTORY_INFO;
cifsFile->srch_inf.info_level = SMB_FIND_FILE_FULL_DIRECTORY_INFO;
}

search_flags = CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME;
Expand Down Expand Up @@ -1014,10 +1016,9 @@ static int cifs_filldir(char *find_entry, struct file *file,
(FIND_FILE_STANDARD_INFO *)find_entry,
cifs_sb);
break;
case SMB_FIND_FILE_FULL_DIRECTORY_INFO:
case SMB_FIND_FILE_ID_FULL_DIR_INFO:
cifs_fulldir_info_to_fattr(&fattr,
(SEARCH_ID_FULL_DIR_INFO *)find_entry,
cifs_sb);
cifs_fulldir_info_to_fattr(&fattr, find_entry, cifs_sb);
break;
default:
cifs_dir_info_to_fattr(&fattr,
Expand Down
6 changes: 6 additions & 0 deletions fs/smb/client/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -5092,6 +5092,9 @@ int SMB2_query_directory_init(const unsigned int xid,
case SMB_FIND_FILE_POSIX_INFO:
req->FileInformationClass = SMB_FIND_FILE_POSIX_INFO;
break;
case SMB_FIND_FILE_FULL_DIRECTORY_INFO:
req->FileInformationClass = FILE_FULL_DIRECTORY_INFORMATION;
break;
default:
cifs_tcon_dbg(VFS, "info level %u isn't supported\n",
info_level);
Expand Down Expand Up @@ -5161,6 +5164,9 @@ smb2_parse_query_directory(struct cifs_tcon *tcon,
/* note that posix payload are variable size */
info_buf_size = sizeof(struct smb2_posix_info);
break;
case SMB_FIND_FILE_FULL_DIRECTORY_INFO:
info_buf_size = sizeof(FILE_FULL_DIRECTORY_INFO);
break;
default:
cifs_tcon_dbg(VFS, "info level %u isn't supported\n",
srch_inf->info_level);
Expand Down

0 comments on commit cacc0a9

Please sign in to comment.