CIFS: Separate protocol specific part from mkdir
Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Steve French <smfrench@gmail.com>
This commit is contained in:
parent
ff691e9694
commit
f436720e94
@ -246,6 +246,13 @@ struct smb_version_operations {
|
|||||||
bool (*can_echo)(struct TCP_Server_Info *);
|
bool (*can_echo)(struct TCP_Server_Info *);
|
||||||
/* send echo request */
|
/* send echo request */
|
||||||
int (*echo)(struct TCP_Server_Info *);
|
int (*echo)(struct TCP_Server_Info *);
|
||||||
|
/* create directory */
|
||||||
|
int (*mkdir)(const unsigned int, struct cifs_tcon *, const char *,
|
||||||
|
struct cifs_sb_info *);
|
||||||
|
/* set info on created directory */
|
||||||
|
void (*mkdir_setinfo)(struct inode *, const char *,
|
||||||
|
struct cifs_sb_info *, struct cifs_tcon *,
|
||||||
|
const unsigned int);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct smb_version_values {
|
struct smb_version_values {
|
||||||
|
@ -295,9 +295,7 @@ extern int CIFSSMBUnixSetPathInfo(const unsigned int xid,
|
|||||||
int remap);
|
int remap);
|
||||||
|
|
||||||
extern int CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon,
|
extern int CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon,
|
||||||
const char *newName,
|
const char *name, struct cifs_sb_info *cifs_sb);
|
||||||
const struct nls_table *nls_codepage,
|
|
||||||
int remap_special_chars);
|
|
||||||
extern int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
|
extern int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
|
||||||
const char *name, const struct nls_table *nls_codepage,
|
const char *name, const struct nls_table *nls_codepage,
|
||||||
int remap_special_chars);
|
int remap_special_chars);
|
||||||
|
@ -992,14 +992,15 @@ RmDirRetry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon,
|
CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
|
||||||
const char *name, const struct nls_table *nls_codepage, int remap)
|
struct cifs_sb_info *cifs_sb)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
CREATE_DIRECTORY_REQ *pSMB = NULL;
|
CREATE_DIRECTORY_REQ *pSMB = NULL;
|
||||||
CREATE_DIRECTORY_RSP *pSMBr = NULL;
|
CREATE_DIRECTORY_RSP *pSMBr = NULL;
|
||||||
int bytes_returned;
|
int bytes_returned;
|
||||||
int name_len;
|
int name_len;
|
||||||
|
int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
|
||||||
|
|
||||||
cFYI(1, "In CIFSSMBMkDir");
|
cFYI(1, "In CIFSSMBMkDir");
|
||||||
MkDirRetry:
|
MkDirRetry:
|
||||||
@ -1010,7 +1011,8 @@ MkDirRetry:
|
|||||||
|
|
||||||
if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
|
if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
|
||||||
name_len = cifsConvertToUTF16((__le16 *) pSMB->DirName, name,
|
name_len = cifsConvertToUTF16((__le16 *) pSMB->DirName, name,
|
||||||
PATH_MAX, nls_codepage, remap);
|
PATH_MAX, cifs_sb->local_nls,
|
||||||
|
remap);
|
||||||
name_len++; /* trailing null */
|
name_len++; /* trailing null */
|
||||||
name_len *= 2;
|
name_len *= 2;
|
||||||
} else { /* BB improve check for buffer overruns BB */
|
} else { /* BB improve check for buffer overruns BB */
|
||||||
|
@ -1272,24 +1272,11 @@ cifs_mkdir_qinfo(struct inode *inode, struct dentry *dentry, umode_t mode,
|
|||||||
cifs_sb->mnt_cifs_flags &
|
cifs_sb->mnt_cifs_flags &
|
||||||
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
||||||
} else {
|
} else {
|
||||||
|
struct TCP_Server_Info *server = tcon->ses->server;
|
||||||
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) &&
|
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) &&
|
||||||
(mode & S_IWUGO) == 0) {
|
(mode & S_IWUGO) == 0 && server->ops->mkdir_setinfo)
|
||||||
FILE_BASIC_INFO info;
|
server->ops->mkdir_setinfo(newinode, full_path, cifs_sb,
|
||||||
struct cifsInodeInfo *cifsInode;
|
tcon, xid);
|
||||||
u32 dosattrs;
|
|
||||||
int tmprc;
|
|
||||||
|
|
||||||
memset(&info, 0, sizeof(info));
|
|
||||||
cifsInode = CIFS_I(newinode);
|
|
||||||
dosattrs = cifsInode->cifsAttrs|ATTR_READONLY;
|
|
||||||
info.Attributes = cpu_to_le32(dosattrs);
|
|
||||||
tmprc = CIFSSMBSetPathInfo(xid, tcon, full_path, &info,
|
|
||||||
cifs_sb->local_nls,
|
|
||||||
cifs_sb->mnt_cifs_flags &
|
|
||||||
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
||||||
if (tmprc == 0)
|
|
||||||
cifsInode->cifsAttrs = dosattrs;
|
|
||||||
}
|
|
||||||
if (dentry->d_inode) {
|
if (dentry->d_inode) {
|
||||||
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
|
||||||
dentry->d_inode->i_mode = (mode | S_IFDIR);
|
dentry->d_inode->i_mode = (mode | S_IFDIR);
|
||||||
@ -1377,6 +1364,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, umode_t mode)
|
|||||||
struct cifs_sb_info *cifs_sb;
|
struct cifs_sb_info *cifs_sb;
|
||||||
struct tcon_link *tlink;
|
struct tcon_link *tlink;
|
||||||
struct cifs_tcon *tcon;
|
struct cifs_tcon *tcon;
|
||||||
|
struct TCP_Server_Info *server;
|
||||||
char *full_path;
|
char *full_path;
|
||||||
|
|
||||||
cFYI(1, "In cifs_mkdir, mode = 0x%hx inode = 0x%p", mode, inode);
|
cFYI(1, "In cifs_mkdir, mode = 0x%hx inode = 0x%p", mode, inode);
|
||||||
@ -1403,9 +1391,15 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, umode_t mode)
|
|||||||
goto mkdir_out;
|
goto mkdir_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server = tcon->ses->server;
|
||||||
|
|
||||||
|
if (!server->ops->mkdir) {
|
||||||
|
rc = -ENOSYS;
|
||||||
|
goto mkdir_out;
|
||||||
|
}
|
||||||
|
|
||||||
/* BB add setting the equivalent of mode via CreateX w/ACLs */
|
/* BB add setting the equivalent of mode via CreateX w/ACLs */
|
||||||
rc = CIFSSMBMkDir(xid, tcon, full_path, cifs_sb->local_nls,
|
rc = server->ops->mkdir(xid, tcon, full_path, cifs_sb);
|
||||||
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
cFYI(1, "cifs_mkdir returned 0x%x", rc);
|
cFYI(1, "cifs_mkdir returned 0x%x", rc);
|
||||||
d_drop(direntry);
|
d_drop(direntry);
|
||||||
|
@ -586,6 +586,27 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cifs_mkdir_setinfo(struct inode *inode, const char *full_path,
|
||||||
|
struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon,
|
||||||
|
const unsigned int xid)
|
||||||
|
{
|
||||||
|
FILE_BASIC_INFO info;
|
||||||
|
struct cifsInodeInfo *cifsInode;
|
||||||
|
u32 dosattrs;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
memset(&info, 0, sizeof(info));
|
||||||
|
cifsInode = CIFS_I(inode);
|
||||||
|
dosattrs = cifsInode->cifsAttrs|ATTR_READONLY;
|
||||||
|
info.Attributes = cpu_to_le32(dosattrs);
|
||||||
|
rc = CIFSSMBSetPathInfo(xid, tcon, full_path, &info, cifs_sb->local_nls,
|
||||||
|
cifs_sb->mnt_cifs_flags &
|
||||||
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
||||||
|
if (rc == 0)
|
||||||
|
cifsInode->cifsAttrs = dosattrs;
|
||||||
|
}
|
||||||
|
|
||||||
struct smb_version_operations smb1_operations = {
|
struct smb_version_operations smb1_operations = {
|
||||||
.send_cancel = send_nt_cancel,
|
.send_cancel = send_nt_cancel,
|
||||||
.compare_fids = cifs_compare_fids,
|
.compare_fids = cifs_compare_fids,
|
||||||
@ -620,6 +641,8 @@ struct smb_version_operations smb1_operations = {
|
|||||||
.get_srv_inum = cifs_get_srv_inum,
|
.get_srv_inum = cifs_get_srv_inum,
|
||||||
.build_path_to_root = cifs_build_path_to_root,
|
.build_path_to_root = cifs_build_path_to_root,
|
||||||
.echo = CIFSSMBEcho,
|
.echo = CIFSSMBEcho,
|
||||||
|
.mkdir = CIFSSMBMkDir,
|
||||||
|
.mkdir_setinfo = cifs_mkdir_setinfo,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct smb_version_values smb1_values = {
|
struct smb_version_values smb1_values = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user