Skip to content

Commit 72bc63f

Browse files
author
Steve French
committed
smb3: fix creating FIFOs when mounting with "sfu" mount option
Fixes some xfstests including generic/564 and generic/157 The "sfu" mount option can be useful for creating special files (character and block devices in particular) but could not create FIFOs. It did recognize existing empty files with the "system" attribute flag as FIFOs but this is too general, so to support creating FIFOs more safely use a new tag (but the same length as those for char and block devices ie "IntxLNK" and "IntxBLK") "LnxFIFO" to indicate that the file should be treated as a FIFO (when mounted with the "sfu"). For some additional context note that "sfu" followed the way that "Services for Unix" on Windows handled these special files (at least for character and block devices and symlinks), which is different than newer Windows which can handle special files as reparse points (which isn't an option to many servers). Cc: [email protected] Reviewed-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 7588b83 commit 72bc63f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

fs/smb/client/cifspdu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2570,7 +2570,7 @@ typedef struct {
25702570

25712571

25722572
struct win_dev {
2573-
unsigned char type[8]; /* IntxCHR or IntxBLK */
2573+
unsigned char type[8]; /* IntxCHR or IntxBLK or LnxFIFO*/
25742574
__le64 major;
25752575
__le64 minor;
25762576
} __attribute__((packed));

fs/smb/client/inode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,10 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
592592
cifs_dbg(FYI, "Symlink\n");
593593
fattr->cf_mode |= S_IFLNK;
594594
fattr->cf_dtype = DT_LNK;
595+
} else if (memcmp("LnxFIFO", pbuf, 8) == 0) {
596+
cifs_dbg(FYI, "FIFO\n");
597+
fattr->cf_mode |= S_IFIFO;
598+
fattr->cf_dtype = DT_FIFO;
595599
} else {
596600
fattr->cf_mode |= S_IFREG; /* file? */
597601
fattr->cf_dtype = DT_REG;

fs/smb/client/smb2ops.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5087,7 +5087,7 @@ smb2_make_node(unsigned int xid, struct inode *inode,
50875087
* over SMB2/SMB3 and Samba will do this with SMB3.1.1 POSIX Extensions
50885088
*/
50895089

5090-
if (!S_ISCHR(mode) && !S_ISBLK(mode))
5090+
if (!S_ISCHR(mode) && !S_ISBLK(mode) && !S_ISFIFO(mode))
50915091
return rc;
50925092

50935093
cifs_dbg(FYI, "sfu compat create special file\n");
@@ -5135,6 +5135,12 @@ smb2_make_node(unsigned int xid, struct inode *inode,
51355135
pdev->minor = cpu_to_le64(MINOR(dev));
51365136
rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
51375137
&bytes_written, iov, 1);
5138+
} else if (S_ISFIFO(mode)) {
5139+
memcpy(pdev->type, "LnxFIFO", 8);
5140+
pdev->major = 0;
5141+
pdev->minor = 0;
5142+
rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
5143+
&bytes_written, iov, 1);
51385144
}
51395145
tcon->ses->server->ops->close(xid, tcon, &fid);
51405146
d_drop(dentry);

0 commit comments

Comments
 (0)