Skip to content

Commit 13909d9

Browse files
committed
SMB3: add support for recognizing WSL reparse tags
The IO_REPARSE_TAG_LX_ tags originally were used by WSL but they are preferred by the Linux client in some cases since, unlike the NFS reparse tag (or EAs), they don't require an extra query to determine which type of special file they represent. Add support for readdir to recognize special file types of FIFO, SOCKET, CHAR, BLOCK and SYMLINK. This can be tested by creating these special files in WSL Linux and then sharing that location on the Windows server and mounting to the Windows server to access them. Prior to this patch all of the special files would show up as being of type 'file' but with this patch they can be seen with the correct file type as can be seen below: brwxr-xr-x 1 root root 0, 0 Oct 21 17:10 block crwxr-xr-x 1 root root 0, 0 Oct 21 17:46 char drwxr-xr-x 2 root root 0 Oct 21 18:27 dir prwxr-xr-x 1 root root 0 Oct 21 16:21 fifo -rwxr-xr-x 1 root root 0 Oct 21 15:48 file lrwxr-xr-x 1 root root 0 Oct 21 15:52 symlink-to-file TODO: go through all documented reparse tags to see if we can reasonably map some of them to directories vs. files vs. symlinks and also add support for device numbers for block and char devices. Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Aurelien Aptel <aaptel@suse.com>
1 parent d367cb9 commit 13909d9

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

fs/cifs/readdir.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,33 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)
168168
fattr->cf_uid = cifs_sb->mnt_uid;
169169
fattr->cf_gid = cifs_sb->mnt_gid;
170170

171+
/*
172+
* The IO_REPARSE_TAG_LX_ tags originally were used by WSL but they
173+
* are preferred by the Linux client in some cases since, unlike
174+
* the NFS reparse tag (or EAs), they don't require an extra query
175+
* to determine which type of special file they represent.
176+
* TODO: go through all documented reparse tags to see if we can
177+
* reasonably map some of them to directories vs. files vs. symlinks
178+
*/
171179
if (fattr->cf_cifsattrs & ATTR_DIRECTORY) {
172180
fattr->cf_mode = S_IFDIR | cifs_sb->mnt_dir_mode;
173181
fattr->cf_dtype = DT_DIR;
174-
} else {
182+
} else if (fattr->cf_cifstag == IO_REPARSE_TAG_LX_SYMLINK) {
183+
fattr->cf_mode |= S_IFLNK | cifs_sb->mnt_file_mode;
184+
fattr->cf_dtype = DT_LNK;
185+
} else if (fattr->cf_cifstag == IO_REPARSE_TAG_LX_FIFO) {
186+
fattr->cf_mode |= S_IFIFO | cifs_sb->mnt_file_mode;
187+
fattr->cf_dtype = DT_FIFO;
188+
} else if (fattr->cf_cifstag == IO_REPARSE_TAG_AF_UNIX) {
189+
fattr->cf_mode |= S_IFSOCK | cifs_sb->mnt_file_mode;
190+
fattr->cf_dtype = DT_SOCK;
191+
} else if (fattr->cf_cifstag == IO_REPARSE_TAG_LX_CHR) {
192+
fattr->cf_mode |= S_IFCHR | cifs_sb->mnt_file_mode;
193+
fattr->cf_dtype = DT_CHR;
194+
} else if (fattr->cf_cifstag == IO_REPARSE_TAG_LX_BLK) {
195+
fattr->cf_mode |= S_IFBLK | cifs_sb->mnt_file_mode;
196+
fattr->cf_dtype = DT_BLK;
197+
} else { /* TODO: should we mark some other reparse points (like DFSR) as directories? */
175198
fattr->cf_mode = S_IFREG | cifs_sb->mnt_file_mode;
176199
fattr->cf_dtype = DT_REG;
177200
}

0 commit comments

Comments
 (0)