Skip to content

Commit 8e408fc

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: smb1: Try failing back to SetFileInfo if SetPathInfo fails
RHBZ 1145308 Some very old server may not support SetPathInfo to adjust the timestamps of directories. For these servers, try to open the directory and use SetFileInfo. Minor correction to patch included that was Reported-by: kernel test robot <[email protected]> Signed-off-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]> Tested-by: Kenneth D'souza <[email protected]>
1 parent a3713ec commit 8e408fc

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

fs/cifs/cifsproto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ extern int CIFSSMBQFSPosixInfo(const unsigned int xid, struct cifs_tcon *tcon,
345345
extern int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
346346
const char *fileName, const FILE_BASIC_INFO *data,
347347
const struct nls_table *nls_codepage,
348-
int remap_special_chars);
348+
struct cifs_sb_info *cifs_sb);
349349
extern int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
350350
const FILE_BASIC_INFO *data, __u16 fid,
351351
__u32 pid_of_opener);

fs/cifs/cifssmb.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5913,10 +5913,42 @@ CIFSSMBSetFileDisposition(const unsigned int xid, struct cifs_tcon *tcon,
59135913
return rc;
59145914
}
59155915

5916+
static int
5917+
CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
5918+
const char *fileName, const FILE_BASIC_INFO *data,
5919+
const struct nls_table *nls_codepage,
5920+
struct cifs_sb_info *cifs_sb)
5921+
{
5922+
int oplock = 0;
5923+
struct cifs_open_parms oparms;
5924+
struct cifs_fid fid;
5925+
int rc;
5926+
5927+
oparms.tcon = tcon;
5928+
oparms.cifs_sb = cifs_sb;
5929+
oparms.desired_access = GENERIC_WRITE;
5930+
oparms.create_options = cifs_create_options(cifs_sb, 0);
5931+
oparms.disposition = FILE_OPEN;
5932+
oparms.path = fileName;
5933+
oparms.fid = &fid;
5934+
oparms.reconnect = false;
5935+
5936+
rc = CIFS_open(xid, &oparms, &oplock, NULL);
5937+
if (rc)
5938+
goto out;
5939+
5940+
rc = CIFSSMBSetFileInfo(xid, tcon, data, fid.netfid, current->tgid);
5941+
CIFSSMBClose(xid, tcon, fid.netfid);
5942+
out:
5943+
5944+
return rc;
5945+
}
5946+
59165947
int
59175948
CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
59185949
const char *fileName, const FILE_BASIC_INFO *data,
5919-
const struct nls_table *nls_codepage, int remap)
5950+
const struct nls_table *nls_codepage,
5951+
struct cifs_sb_info *cifs_sb)
59205952
{
59215953
TRANSACTION2_SPI_REQ *pSMB = NULL;
59225954
TRANSACTION2_SPI_RSP *pSMBr = NULL;
@@ -5925,6 +5957,7 @@ CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
59255957
int bytes_returned = 0;
59265958
char *data_offset;
59275959
__u16 params, param_offset, offset, byte_count, count;
5960+
int remap = cifs_remap(cifs_sb);
59285961

59295962
cifs_dbg(FYI, "In SetTimes\n");
59305963

@@ -5987,6 +6020,10 @@ CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
59876020
if (rc == -EAGAIN)
59886021
goto SetTimesRetry;
59896022

6023+
if (rc == -EOPNOTSUPP)
6024+
return CIFSSMBSetPathInfoFB(xid, tcon, fileName, data,
6025+
nls_codepage, cifs_sb);
6026+
59906027
return rc;
59916028
}
59926029

fs/cifs/smb1ops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ cifs_mkdir_setinfo(struct inode *inode, const char *full_path,
688688
dosattrs = cifsInode->cifsAttrs|ATTR_READONLY;
689689
info.Attributes = cpu_to_le32(dosattrs);
690690
rc = CIFSSMBSetPathInfo(xid, tcon, full_path, &info, cifs_sb->local_nls,
691-
cifs_remap(cifs_sb));
691+
cifs_sb);
692692
if (rc == 0)
693693
cifsInode->cifsAttrs = dosattrs;
694694
}
@@ -783,7 +783,7 @@ smb_set_file_info(struct inode *inode, const char *full_path,
783783
tcon = tlink_tcon(tlink);
784784

785785
rc = CIFSSMBSetPathInfo(xid, tcon, full_path, buf, cifs_sb->local_nls,
786-
cifs_remap(cifs_sb));
786+
cifs_sb);
787787
if (rc == 0) {
788788
cinode->cifsAttrs = le32_to_cpu(buf->Attributes);
789789
goto out;

0 commit comments

Comments
 (0)