Skip to content

Commit 630103e

Browse files
committed
Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6
Pull CIFS update from Steve French: "Adds SMB2 rmdir/mkdir capability to the SMB2/SMB2.1 support in cifs. I am holding up a few more days on merging the remainder of the SMB2/SMB2.1 enablement although it is nearing review completion, in order to address some review comments from Jeff Layton on a few of the subsequent SMB2 patches, and also to debug an unrelated cifs problem that Pavel discovered." * 'for-next' of git://git.samba.org/sfrench/cifs-2.6: CIFS: Add SMB2 support for rmdir CIFS: Move rmdir code to ops struct CIFS: Add SMB2 support for mkdir operation CIFS: Separate protocol specific part from mkdir CIFS: Simplify cifs_mkdir call
2 parents 8783b6e + 1a500f0 commit 630103e

8 files changed

Lines changed: 270 additions & 158 deletions

File tree

‎fs/cifs/cifsglob.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,16 @@ struct smb_version_operations {
246246
bool (*can_echo)(struct TCP_Server_Info *);
247247
/* send echo request */
248248
int (*echo)(struct TCP_Server_Info *);
249+
/* create directory */
250+
int (*mkdir)(const unsigned int, struct cifs_tcon *, const char *,
251+
struct cifs_sb_info *);
252+
/* set info on created directory */
253+
void (*mkdir_setinfo)(struct inode *, const char *,
254+
struct cifs_sb_info *, struct cifs_tcon *,
255+
const unsigned int);
256+
/* remove directory */
257+
int (*rmdir)(const unsigned int, struct cifs_tcon *, const char *,
258+
struct cifs_sb_info *);
249259
};
250260

251261
struct smb_version_values {

‎fs/cifs/cifsproto.h‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,15 @@ extern int CIFSSMBUnixSetFileInfo(const unsigned int xid,
289289
u16 fid, u32 pid_of_opener);
290290

291291
extern int CIFSSMBUnixSetPathInfo(const unsigned int xid,
292-
struct cifs_tcon *tcon, char *file_name,
292+
struct cifs_tcon *tcon, const char *file_name,
293293
const struct cifs_unix_set_info_args *args,
294294
const struct nls_table *nls_codepage,
295-
int remap_special_chars);
295+
int remap);
296296

297297
extern int CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon,
298-
const char *newName,
299-
const struct nls_table *nls_codepage,
300-
int remap_special_chars);
298+
const char *name, struct cifs_sb_info *cifs_sb);
301299
extern int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
302-
const char *name, const struct nls_table *nls_codepage,
303-
int remap_special_chars);
300+
const char *name, struct cifs_sb_info *cifs_sb);
304301
extern int CIFSPOSIXDelFile(const unsigned int xid, struct cifs_tcon *tcon,
305302
const char *name, __u16 type,
306303
const struct nls_table *nls_codepage,

‎fs/cifs/cifssmb.c‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -948,15 +948,15 @@ CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon,
948948
}
949949

950950
int
951-
CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
952-
const char *dirName, const struct nls_table *nls_codepage,
953-
int remap)
951+
CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
952+
struct cifs_sb_info *cifs_sb)
954953
{
955954
DELETE_DIRECTORY_REQ *pSMB = NULL;
956955
DELETE_DIRECTORY_RSP *pSMBr = NULL;
957956
int rc = 0;
958957
int bytes_returned;
959958
int name_len;
959+
int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
960960

961961
cFYI(1, "In CIFSSMBRmDir");
962962
RmDirRetry:
@@ -966,14 +966,15 @@ CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
966966
return rc;
967967

968968
if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
969-
name_len = cifsConvertToUTF16((__le16 *) pSMB->DirName, dirName,
970-
PATH_MAX, nls_codepage, remap);
969+
name_len = cifsConvertToUTF16((__le16 *) pSMB->DirName, name,
970+
PATH_MAX, cifs_sb->local_nls,
971+
remap);
971972
name_len++; /* trailing null */
972973
name_len *= 2;
973974
} else { /* BB improve check for buffer overruns BB */
974-
name_len = strnlen(dirName, PATH_MAX);
975+
name_len = strnlen(name, PATH_MAX);
975976
name_len++; /* trailing null */
976-
strncpy(pSMB->DirName, dirName, name_len);
977+
strncpy(pSMB->DirName, name, name_len);
977978
}
978979

979980
pSMB->BufferFormat = 0x04;
@@ -992,14 +993,15 @@ CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
992993
}
993994

994995
int
995-
CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon,
996-
const char *name, const struct nls_table *nls_codepage, int remap)
996+
CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
997+
struct cifs_sb_info *cifs_sb)
997998
{
998999
int rc = 0;
9991000
CREATE_DIRECTORY_REQ *pSMB = NULL;
10001001
CREATE_DIRECTORY_RSP *pSMBr = NULL;
10011002
int bytes_returned;
10021003
int name_len;
1004+
int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
10031005

10041006
cFYI(1, "In CIFSSMBMkDir");
10051007
MkDirRetry:
@@ -1010,7 +1012,8 @@ CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon,
10101012

10111013
if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
10121014
name_len = cifsConvertToUTF16((__le16 *) pSMB->DirName, name,
1013-
PATH_MAX, nls_codepage, remap);
1015+
PATH_MAX, cifs_sb->local_nls,
1016+
remap);
10141017
name_len++; /* trailing null */
10151018
name_len *= 2;
10161019
} else { /* BB improve check for buffer overruns BB */
@@ -5943,7 +5946,7 @@ CIFSSMBUnixSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
59435946

59445947
int
59455948
CIFSSMBUnixSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
5946-
char *fileName,
5949+
const char *file_name,
59475950
const struct cifs_unix_set_info_args *args,
59485951
const struct nls_table *nls_codepage, int remap)
59495952
{
@@ -5964,14 +5967,14 @@ CIFSSMBUnixSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
59645967

59655968
if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
59665969
name_len =
5967-
cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName,
5970+
cifsConvertToUTF16((__le16 *) pSMB->FileName, file_name,
59685971
PATH_MAX, nls_codepage, remap);
59695972
name_len++; /* trailing null */
59705973
name_len *= 2;
59715974
} else { /* BB improve the check for buffer overruns BB */
5972-
name_len = strnlen(fileName, PATH_MAX);
5975+
name_len = strnlen(file_name, PATH_MAX);
59735976
name_len++; /* trailing null */
5974-
strncpy(pSMB->FileName, fileName, name_len);
5977+
strncpy(pSMB->FileName, file_name, name_len);
59755978
}
59765979

59775980
params = 6 + name_len;

0 commit comments

Comments
 (0)