[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250831123602.14037-20-pali@kernel.org>
Date: Sun, 31 Aug 2025 14:35:46 +0200
From: Pali Rohár <pali@...nel.org>
To: Steve French <sfrench@...ba.org>,
Paulo Alcantara <pc@...guebit.com>,
ronnie sahlberg <ronniesahlberg@...il.com>
Cc: linux-cifs@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 19/35] cifs: Fix cifs_rename_pending_delete() for files with more hardlinks
Do not set ATTR_HIDDEN when the file has more links. These attributes are
shared across all links, they are not direntry specific. So changing
attribute on one hardlink affects all other hardlinks.
The cifs_rename_pending_delete() function called from unlink() should
affect only the path passed to unlink(), and not other links.
Signed-off-by: Pali Rohár <pali@...nel.org>
---
fs/smb/client/inode.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 89d1b82ac55c..4658af632098 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -1769,16 +1769,26 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
if (rc != 0)
goto out;
- origattr = cifsInode->cifsAttrs;
- if (origattr == 0)
- origattr |= ATTR_NORMAL;
+ origattr = cifsInode->cifsAttrs & ~ATTR_NORMAL;
+ /* clear ATTR_READONLY, needed for opening file with DELETE access */
dosattr = origattr & ~ATTR_READONLY;
+
+ /*
+ * Set ATTR_HIDDEN to hide the file, but only if this is not a hardlink
+ * because all hardlinked directory entries shares same attribues and
+ * we do not want to mark all hardlinked entries as hidden.
+ */
+ if (inode->i_nlink <= 1)
+ dosattr |= ATTR_HIDDEN;
+
+ /* clearing all attributes is done via ATTR_NORMAL value */
+ if (origattr == 0)
+ origattr |= ATTR_NORMAL;
if (dosattr == 0)
dosattr |= ATTR_NORMAL;
- dosattr |= ATTR_HIDDEN;
- /* set ATTR_HIDDEN and clear ATTR_READONLY, but only if needed */
+ /* change dosattr, but only if needed */
if (dosattr != origattr) {
info_buf.Attributes = cpu_to_le32(dosattr);
rc = CIFSSMBSetFileInfo(xid, tcon, &info_buf, fid.netfid,
--
2.20.1
Powered by blists - more mailing lists