diff mbox series

[CIFS] allow creating FIFOs when "sfu" mount option specified

Message ID CAH2r5mvve4euMUqsBBqRr2VWgz7ukEZ15vZRVDO=zbzY=XhF1Q@mail.gmail.com (mailing list archive)
State New, archived
Headers show
Series [CIFS] allow creating FIFOs when "sfu" mount option specified | expand

Commit Message

Steve French Oct. 20, 2023, 4:32 a.m. UTC
mb3: 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).

See attached.

Comments

Steve French Oct. 31, 2023, 1:30 p.m. UTC | #1
Adding linux-cifs mailing list (the updated patch was only sent to
samba-technical)

On Sun, Oct 29, 2023 at 4:12 PM Steve French <smfrench@gmail.com> wrote:
>
> updated patch attached
>
>
> On Sun, Oct 29, 2023 at 4:06 PM Steve French <smfrench@gmail.com> wrote:
> >
> > Good catch - yes that was a typo - will fix.
> >
> > On Fri, Oct 20, 2023 at 10:07 AM Brown, James William via
> > samba-technical <samba-technical@lists.samba.org> wrote:
> > >
> > > On 10/20/2023 12:32 AM, Steve French via samba-technical wrote:
> > > > CAUTION: This email originated from outside the organization. DO NOT CLICK ON LINKS or OPEN ATTACHMENTS unless you know and trust the sender.
> > > >
> > > > mb3: 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).
> > > >
> > > > @@ -5135,6 +5135,12 @@ smb2_make_node(unsigned int xid, struct inode *inode,
> > > >               pdev->minor = cpu_to_le64(MINOR(dev));
> > > >               rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
> > > >                                                       &bytes_written, iov, 1);
> > > > +     } else if (S_ISBLK(mode)) {
> > > > +             memcpy(pdev->type, "LnxFIFO", 8);
> > > > +             pdev->major = 0;
> > > > +             pdev->minor = 0;
> > > > +             rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
> > > > +                                                     &bytes_written, iov, 1);
> > > >       }
> > > >       tcon->ses->server->ops->close(xid, tcon, &fid);
> > > >       d_drop(dentry);
> > > > --
> > > Shouldn't "else if (S_ISBLK(mode))" be "S_ISFIFO"?
> > >
> > > else if (S_ISBLK(mode))
> > >
> > > else if (S_ISBLK(mode))
> > >
> >
> >
> > --
> > Thanks,
> >
> > Steve
>
>
>
> --
> Thanks,
>
> Steve
diff mbox series

Patch

From a788de3252552abeacb757f5547316ced7170911 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Thu, 19 Oct 2023 23:01:49 -0500
Subject: [PATCH] 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: stable@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/smb/client/cifspdu.h | 2 +-
 fs/smb/client/inode.c   | 4 ++++
 fs/smb/client/smb2ops.c | 8 +++++++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index e17222fec9d2..a75220db5c1e 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -2570,7 +2570,7 @@  typedef struct {
 
 
 struct win_dev {
-	unsigned char type[8]; /* IntxCHR or IntxBLK */
+	unsigned char type[8]; /* IntxCHR or IntxBLK or LnxFIFO*/
 	__le64 major;
 	__le64 minor;
 } __attribute__((packed));
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index d7c302442c1e..c03a286ed418 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -592,6 +592,10 @@  cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
 			cifs_dbg(FYI, "Symlink\n");
 			fattr->cf_mode |= S_IFLNK;
 			fattr->cf_dtype = DT_LNK;
+		} else if (memcmp("LnxFIFO", pbuf, 8) == 0) {
+			cifs_dbg(FYI, "FIFO\n");
+			fattr->cf_mode |= S_IFIFO;
+			fattr->cf_dtype = DT_FIFO;
 		} else {
 			fattr->cf_mode |= S_IFREG; /* file? */
 			fattr->cf_dtype = DT_REG;
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 9aeecee6b91b..28985dc81c09 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -5087,7 +5087,7 @@  smb2_make_node(unsigned int xid, struct inode *inode,
 	 * over SMB2/SMB3 and Samba will do this with SMB3.1.1 POSIX Extensions
 	 */
 
-	if (!S_ISCHR(mode) && !S_ISBLK(mode))
+	if (!S_ISCHR(mode) && !S_ISBLK(mode) && !S_ISFIFO(mode))
 		return rc;
 
 	cifs_dbg(FYI, "sfu compat create special file\n");
@@ -5135,6 +5135,12 @@  smb2_make_node(unsigned int xid, struct inode *inode,
 		pdev->minor = cpu_to_le64(MINOR(dev));
 		rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
 							&bytes_written, iov, 1);
+	} else if (S_ISBLK(mode)) {
+		memcpy(pdev->type, "LnxFIFO", 8);
+		pdev->major = 0;
+		pdev->minor = 0;
+		rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
+							&bytes_written, iov, 1);
 	}
 	tcon->ses->server->ops->close(xid, tcon, &fid);
 	d_drop(dentry);
-- 
2.39.2