[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250831123602.14037-15-pali@kernel.org>
Date: Sun, 31 Aug 2025 14:35:41 +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 14/35] cifs: Extend CIFSSMBRenameOpenFile() function for overwrite parameter
Currently CIFSSMBRenameOpenFile() function always overwrite the target
location. This new overwrite parameter allows to specify if the rename
should fail when the target location exists. This new parameter would be
used in follow up changes.
No functional change.
Signed-off-by: Pali Rohár <pali@...nel.org>
---
fs/smb/client/cifsproto.h | 2 +-
fs/smb/client/cifssmb.c | 4 ++--
fs/smb/client/inode.c | 3 +++
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h
index f467b24fd984..f248b18f1cf3 100644
--- a/fs/smb/client/cifsproto.h
+++ b/fs/smb/client/cifsproto.h
@@ -470,7 +470,7 @@ int CIFSSMBRename(const unsigned int xid, struct cifs_tcon *tcon,
const char *from_name, const char *to_name,
struct cifs_sb_info *cifs_sb);
extern int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *tcon,
- int netfid, const char *target_name,
+ int netfid, const char *target_name, bool overwrite,
const struct nls_table *nls_codepage,
int remap_special_chars);
int CIFSCreateHardLink(const unsigned int xid,
diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c
index 8d9f6f28c17e..f12bc0f4d0c1 100644
--- a/fs/smb/client/cifssmb.c
+++ b/fs/smb/client/cifssmb.c
@@ -2313,7 +2313,7 @@ int CIFSSMBRename(const unsigned int xid, struct cifs_tcon *tcon,
}
int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *pTcon,
- int netfid, const char *target_name,
+ int netfid, const char *target_name, bool overwrite,
const struct nls_table *nls_codepage, int remap)
{
struct smb_com_transaction2_sfi_req *pSMB = NULL;
@@ -2353,7 +2353,7 @@ int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *pTcon,
pSMB->TotalParameterCount = pSMB->ParameterCount;
pSMB->ParameterOffset = cpu_to_le16(param_offset);
pSMB->DataOffset = cpu_to_le16(offset);
- rename_info->overwrite = cpu_to_le32(1);
+ rename_info->overwrite = cpu_to_le32(overwrite);
rename_info->root_fid = 0;
/* unicode only call */
len_of_str = cifsConvertToUTF16((__le16 *)rename_info->target_name,
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 2889fa6625af..be8e5e5ca6cd 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -1793,6 +1793,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
/* rename the file */
rc = CIFSSMBRenameOpenFile(xid, tcon, fid.netfid, sillyname,
+ true /* overwrite */,
cifs_sb->local_nls,
cifs_remap(cifs_sb));
if (rc != 0) {
@@ -1834,6 +1835,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
*/
undo_rename:
CIFSSMBRenameOpenFile(xid, tcon, fid.netfid, dentry->d_name.name,
+ true /* overwrite */,
cifs_sb->local_nls, cifs_remap(cifs_sb));
undo_setattr:
if (dosattr != origattr) {
@@ -2374,6 +2376,7 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
if (rc == 0) {
rc = CIFSSMBRenameOpenFile(xid, tcon, fid.netfid,
(const char *) to_dentry->d_name.name,
+ true /* overwrite */,
cifs_sb->local_nls, cifs_remap(cifs_sb));
CIFSSMBClose(xid, tcon, fid.netfid);
}
--
2.20.1
Powered by blists - more mailing lists