From patchwork Fri Oct 20 04:32:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 13430046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94916CDB474 for ; Fri, 20 Oct 2023 04:32:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229721AbjJTEct (ORCPT ); Fri, 20 Oct 2023 00:32:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbjJTEcs (ORCPT ); Fri, 20 Oct 2023 00:32:48 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E1861A8 for ; Thu, 19 Oct 2023 21:32:46 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-5079f6efd64so450952e87.2 for ; Thu, 19 Oct 2023 21:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697776364; x=1698381164; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=cJ8v4thUWvHEDZGBSVKt08OJQRuQ1zq3oUS8VnC3WW8=; b=eDJolx0LtSHDJqde6Y6YdYCXZfxQh8BIAE00vquKbwDrV9NmL7IXzQzXGWPnMxYhyV EDYCJlIoSkd80ShOutI5lO15xnFyDmkfzv/xDM+oQJ/r/o3ZKAg+1uXAdEnLLcqCVyP7 KrlcWSseo41JhGZ8JIQN03A2N8hQmEdbZr1J0wWdKbLbGkXvHRlEgMPtjkrfW+nE8yzx SX8MJzayXNJhwhhx8wWKN0/Zv5bo92D2qQF6mwFVTbkG+bDcxNBzQA4mrruNh7oZ6vBY XX/9A8668nmjxc7Ng7COD3HIx9zEmc9CxB0hGSQrI4DQ6oUlfsAInzWSqvVGHOf6XBm1 WECA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697776364; x=1698381164; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cJ8v4thUWvHEDZGBSVKt08OJQRuQ1zq3oUS8VnC3WW8=; b=edDGtPNRzBnKbNdELetBcd8xmNfQIGOKEekwRCmDl05/R96Cjs1EpRMgzQLRAdwY2s tLtoSFh95pCDZ7bWQTgMLJiyhNNkwV2Ua1zcRiQDqQQB6vZz9VB2oO2DUgLZIGRJLc5I mgKb2ksF4HzBSMXL6N/C2SFMDMCPm2w+82GfC9FaoMnCG7GpW+ceAqorhs7Ssti+gXEN kEzUJa+lV2gtCbFWdTIgOXgh9I2cCknKW3nx+ldidc8bZvzAapZiPZqxnmDziUEjchh6 /EkB+AO0YmnZ8pkctaCqwlsrJyuLLmEqvY5oJCxrOAI/gGvdVA+xwaETJyog50Ea2Z/p NPkA== X-Gm-Message-State: AOJu0Yz+/nINfZugAd9UJRN8eDo14cGgwp/IvynbO9UseobN1YN5UUUv pSA5XsNn9pCe4qogY+GoHcBdnjLftFDmt3MR8thFEmuxbcKzEA== X-Google-Smtp-Source: AGHT+IGOTp69NW4A0m+s+fQ2mKgb9bjJnQ0wIIGs9YAWSl20SJpg6PtVkApnjMt1DQrniZvXq0BsY77uLtNki/boFsc= X-Received: by 2002:ac2:5548:0:b0:507:9996:f62b with SMTP id l8-20020ac25548000000b005079996f62bmr395168lfk.56.1697776363599; Thu, 19 Oct 2023 21:32:43 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Thu, 19 Oct 2023 23:32:32 -0500 Message-ID: Subject: [PATCH][CIFS] allow creating FIFOs when "sfu" mount option specified To: CIFS Cc: samba-technical , =?utf-8?q?Aur=C3=A9li?= =?utf-8?q?en_Aptel?= , Pavel Shilovsky Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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. From a788de3252552abeacb757f5547316ced7170911 Mon Sep 17 00:00:00 2001 From: Steve French 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 --- 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