Commit 0fe7b4a8 authored by Pavel Shilovsky's avatar Pavel Shilovsky

Update 3.12 sources from stable (v3.12.20)

parent 6a8f951a
...@@ -1029,15 +1029,30 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode, ...@@ -1029,15 +1029,30 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode,
__u32 secdesclen = 0; __u32 secdesclen = 0;
struct cifs_ntsd *pntsd = NULL; /* acl obtained from server */ struct cifs_ntsd *pntsd = NULL; /* acl obtained from server */
struct cifs_ntsd *pnntsd = NULL; /* modified acl to be sent to server */ struct cifs_ntsd *pnntsd = NULL; /* modified acl to be sent to server */
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
struct cifs_tcon *tcon;
if (IS_ERR(tlink))
return PTR_ERR(tlink);
tcon = tlink_tcon(tlink);
cifs_dbg(NOISY, "set ACL from mode for %s\n", path); cifs_dbg(NOISY, "set ACL from mode for %s\n", path);
/* Get the security descriptor */ /* Get the security descriptor */
pntsd = get_cifs_acl(CIFS_SB(inode->i_sb), inode, path, &secdesclen);
if (tcon->ses->server->ops->get_acl == NULL) {
cifs_put_tlink(tlink);
return -EOPNOTSUPP;
}
pntsd = tcon->ses->server->ops->get_acl(cifs_sb, inode, path,
&secdesclen);
if (IS_ERR(pntsd)) { if (IS_ERR(pntsd)) {
rc = PTR_ERR(pntsd); rc = PTR_ERR(pntsd);
cifs_dbg(VFS, "%s: error %d getting sec desc\n", __func__, rc); cifs_dbg(VFS, "%s: error %d getting sec desc\n", __func__, rc);
goto out; cifs_put_tlink(tlink);
return rc;
} }
/* /*
...@@ -1050,6 +1065,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode, ...@@ -1050,6 +1065,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode,
pnntsd = kmalloc(secdesclen, GFP_KERNEL); pnntsd = kmalloc(secdesclen, GFP_KERNEL);
if (!pnntsd) { if (!pnntsd) {
kfree(pntsd); kfree(pntsd);
cifs_put_tlink(tlink);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1058,14 +1074,18 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode, ...@@ -1058,14 +1074,18 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode,
cifs_dbg(NOISY, "build_sec_desc rc: %d\n", rc); cifs_dbg(NOISY, "build_sec_desc rc: %d\n", rc);
if (tcon->ses->server->ops->set_acl == NULL)
rc = -EOPNOTSUPP;
if (!rc) { if (!rc) {
/* Set the security descriptor */ /* Set the security descriptor */
rc = set_cifs_acl(pnntsd, secdesclen, inode, path, aclflag); rc = tcon->ses->server->ops->set_acl(pnntsd, secdesclen, inode,
path, aclflag);
cifs_dbg(NOISY, "set_cifs_acl rc: %d\n", rc); cifs_dbg(NOISY, "set_cifs_acl rc: %d\n", rc);
} }
cifs_put_tlink(tlink);
kfree(pnntsd); kfree(pnntsd);
kfree(pntsd); kfree(pntsd);
out:
return rc; return rc;
} }
...@@ -379,6 +379,16 @@ struct smb_version_operations { ...@@ -379,6 +379,16 @@ struct smb_version_operations {
char * (*create_lease_buf)(u8 *, u8); char * (*create_lease_buf)(u8 *, u8);
/* parse lease context buffer and return oplock/epoch info */ /* parse lease context buffer and return oplock/epoch info */
__u8 (*parse_lease_buf)(void *, unsigned int *); __u8 (*parse_lease_buf)(void *, unsigned int *);
ssize_t (*query_all_EAs)(const unsigned int, struct cifs_tcon *,
const unsigned char *, const unsigned char *, char *,
size_t, const struct nls_table *, int);
int (*set_EA)(const unsigned int, struct cifs_tcon *, const char *,
const char *, const void *, const __u16,
const struct nls_table *, int);
struct cifs_ntsd * (*get_acl)(struct cifs_sb_info *, struct inode *,
const char *, u32 *);
int (*set_acl)(struct cifs_ntsd *, __u32, struct inode *, const char *,
int);
}; };
struct smb_version_values { struct smb_version_values {
......
...@@ -475,9 +475,10 @@ extern int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -475,9 +475,10 @@ extern int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon,
const int netfid, __u64 *pExtAttrBits, __u64 *pMask); const int netfid, __u64 *pExtAttrBits, __u64 *pMask);
extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb); extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb);
extern bool CIFSCouldBeMFSymlink(const struct cifs_fattr *fattr); extern bool CIFSCouldBeMFSymlink(const struct cifs_fattr *fattr);
extern int CIFSCheckMFSymlink(struct cifs_fattr *fattr, extern int CIFSCheckMFSymlink(unsigned int xid, struct cifs_tcon *tcon,
const unsigned char *path, struct cifs_sb_info *cifs_sb,
struct cifs_sb_info *cifs_sb, unsigned int xid); struct cifs_fattr *fattr,
const unsigned char *path);
extern int mdfour(unsigned char *, unsigned char *, int); extern int mdfour(unsigned char *, unsigned char *, int);
extern int E_md4hash(const unsigned char *passwd, unsigned char *p16, extern int E_md4hash(const unsigned char *passwd, unsigned char *p16,
const struct nls_table *codepage); const struct nls_table *codepage);
......
...@@ -3322,11 +3322,13 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL, ...@@ -3322,11 +3322,13 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL,
return 0; return 0;
} }
cifs_acl->version = cpu_to_le16(1); cifs_acl->version = cpu_to_le16(1);
if (acl_type == ACL_TYPE_ACCESS) if (acl_type == ACL_TYPE_ACCESS) {
cifs_acl->access_entry_count = cpu_to_le16(count); cifs_acl->access_entry_count = cpu_to_le16(count);
else if (acl_type == ACL_TYPE_DEFAULT) cifs_acl->default_entry_count = __constant_cpu_to_le16(0xFFFF);
} else if (acl_type == ACL_TYPE_DEFAULT) {
cifs_acl->default_entry_count = cpu_to_le16(count); cifs_acl->default_entry_count = cpu_to_le16(count);
else { cifs_acl->access_entry_count = __constant_cpu_to_le16(0xFFFF);
} else {
cifs_dbg(FYI, "unknown ACL type %d\n", acl_type); cifs_dbg(FYI, "unknown ACL type %d\n", acl_type);
return 0; return 0;
} }
......
...@@ -193,7 +193,7 @@ check_name(struct dentry *direntry) ...@@ -193,7 +193,7 @@ check_name(struct dentry *direntry)
static int static int
cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
struct tcon_link *tlink, unsigned oflags, umode_t mode, struct tcon_link *tlink, unsigned oflags, umode_t mode,
__u32 *oplock, struct cifs_fid *fid, int *created) __u32 *oplock, struct cifs_fid *fid)
{ {
int rc = -ENOENT; int rc = -ENOENT;
int create_options = CREATE_NOT_DIR; int create_options = CREATE_NOT_DIR;
...@@ -354,7 +354,6 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, ...@@ -354,7 +354,6 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
.device = 0, .device = 0,
}; };
*created |= FILE_CREATED;
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
args.uid = current_fsuid(); args.uid = current_fsuid();
if (inode->i_mode & S_ISGID) if (inode->i_mode & S_ISGID)
...@@ -485,13 +484,16 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, ...@@ -485,13 +484,16 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
cifs_add_pending_open(&fid, tlink, &open); cifs_add_pending_open(&fid, tlink, &open);
rc = cifs_do_create(inode, direntry, xid, tlink, oflags, mode, rc = cifs_do_create(inode, direntry, xid, tlink, oflags, mode,
&oplock, &fid, opened); &oplock, &fid);
if (rc) { if (rc) {
cifs_del_pending_open(&open); cifs_del_pending_open(&open);
goto out; goto out;
} }
if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
*opened |= FILE_CREATED;
rc = finish_open(file, direntry, generic_file_open, opened); rc = finish_open(file, direntry, generic_file_open, opened);
if (rc) { if (rc) {
if (server->ops->close) if (server->ops->close)
...@@ -534,7 +536,6 @@ int cifs_create(struct inode *inode, struct dentry *direntry, umode_t mode, ...@@ -534,7 +536,6 @@ int cifs_create(struct inode *inode, struct dentry *direntry, umode_t mode,
struct TCP_Server_Info *server; struct TCP_Server_Info *server;
struct cifs_fid fid; struct cifs_fid fid;
__u32 oplock; __u32 oplock;
int created = FILE_CREATED;
cifs_dbg(FYI, "cifs_create parent inode = 0x%p name is: %s and dentry = 0x%p\n", cifs_dbg(FYI, "cifs_create parent inode = 0x%p name is: %s and dentry = 0x%p\n",
inode, direntry->d_name.name, direntry); inode, direntry->d_name.name, direntry);
...@@ -551,7 +552,7 @@ int cifs_create(struct inode *inode, struct dentry *direntry, umode_t mode, ...@@ -551,7 +552,7 @@ int cifs_create(struct inode *inode, struct dentry *direntry, umode_t mode,
server->ops->new_lease_key(&fid); server->ops->new_lease_key(&fid);
rc = cifs_do_create(inode, direntry, xid, tlink, oflags, mode, rc = cifs_do_create(inode, direntry, xid, tlink, oflags, mode,
&oplock, &fid, &created); &oplock, &fid);
if (!rc && server->ops->close) if (!rc && server->ops->close)
server->ops->close(xid, tcon, &fid); server->ops->close(xid, tcon, &fid);
......
...@@ -2389,7 +2389,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov, ...@@ -2389,7 +2389,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
unsigned long nr_segs, loff_t *poffset) unsigned long nr_segs, loff_t *poffset)
{ {
unsigned long nr_pages, i; unsigned long nr_pages, i;
size_t copied, len, cur_len; size_t bytes, copied, len, cur_len;
ssize_t total_written = 0; ssize_t total_written = 0;
loff_t offset; loff_t offset;
struct iov_iter it; struct iov_iter it;
...@@ -2444,14 +2444,45 @@ cifs_iovec_write(struct file *file, const struct iovec *iov, ...@@ -2444,14 +2444,45 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
save_len = cur_len; save_len = cur_len;
for (i = 0; i < nr_pages; i++) { for (i = 0; i < nr_pages; i++) {
copied = min_t(const size_t, cur_len, PAGE_SIZE); bytes = min_t(const size_t, cur_len, PAGE_SIZE);
copied = iov_iter_copy_from_user(wdata->pages[i], &it, copied = iov_iter_copy_from_user(wdata->pages[i], &it,
0, copied); 0, bytes);
cur_len -= copied; cur_len -= copied;
iov_iter_advance(&it, copied); iov_iter_advance(&it, copied);
/*
* If we didn't copy as much as we expected, then that
* may mean we trod into an unmapped area. Stop copying
* at that point. On the next pass through the big
* loop, we'll likely end up getting a zero-length
* write and bailing out of it.
*/
if (copied < bytes)
break;
} }
cur_len = save_len - cur_len; cur_len = save_len - cur_len;
/*
* If we have no data to send, then that probably means that
* the copy above failed altogether. That's most likely because
* the address in the iovec was bogus. Set the rc to -EFAULT,
* free anything we allocated and bail out.
*/
if (!cur_len) {
for (i = 0; i < nr_pages; i++)
put_page(wdata->pages[i]);
kfree(wdata);
rc = -EFAULT;
break;
}
/*
* i + 1 now represents the number of pages we actually used in
* the copy phase above. Bring nr_pages down to that, and free
* any pages that we didn't use.
*/
for ( ; nr_pages > i + 1; nr_pages--)
put_page(wdata->pages[nr_pages - 1]);
wdata->sync_mode = WB_SYNC_ALL; wdata->sync_mode = WB_SYNC_ALL;
wdata->nr_pages = nr_pages; wdata->nr_pages = nr_pages;
wdata->offset = (__u64)offset; wdata->offset = (__u64)offset;
......
...@@ -383,7 +383,8 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -383,7 +383,8 @@ int cifs_get_inode_info_unix(struct inode **pinode,
/* check for Minshall+French symlinks */ /* check for Minshall+French symlinks */
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) {
int tmprc = CIFSCheckMFSymlink(&fattr, full_path, cifs_sb, xid); int tmprc = CIFSCheckMFSymlink(xid, tcon, cifs_sb, &fattr,
full_path);
if (tmprc) if (tmprc)
cifs_dbg(FYI, "CIFSCheckMFSymlink: %d\n", tmprc); cifs_dbg(FYI, "CIFSCheckMFSymlink: %d\n", tmprc);
} }
...@@ -517,10 +518,15 @@ static int cifs_sfu_mode(struct cifs_fattr *fattr, const unsigned char *path, ...@@ -517,10 +518,15 @@ static int cifs_sfu_mode(struct cifs_fattr *fattr, const unsigned char *path,
return PTR_ERR(tlink); return PTR_ERR(tlink);
tcon = tlink_tcon(tlink); tcon = tlink_tcon(tlink);
rc = CIFSSMBQAllEAs(xid, tcon, path, "SETFILEBITS", if (tcon->ses->server->ops->query_all_EAs == NULL) {
ea_value, 4 /* size of buf */, cifs_sb->local_nls, cifs_put_tlink(tlink);
cifs_sb->mnt_cifs_flags & return -EOPNOTSUPP;
CIFS_MOUNT_MAP_SPECIAL_CHR); }
rc = tcon->ses->server->ops->query_all_EAs(xid, tcon, path,
"SETFILEBITS", ea_value, 4 /* size of buf */,
cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
cifs_put_tlink(tlink); cifs_put_tlink(tlink);
if (rc < 0) if (rc < 0)
return (int)rc; return (int)rc;
...@@ -799,7 +805,8 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, ...@@ -799,7 +805,8 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
/* check for Minshall+French symlinks */ /* check for Minshall+French symlinks */
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) {
tmprc = CIFSCheckMFSymlink(&fattr, full_path, cifs_sb, xid); tmprc = CIFSCheckMFSymlink(xid, tcon, cifs_sb, &fattr,
full_path);
if (tmprc) if (tmprc)
cifs_dbg(FYI, "CIFSCheckMFSymlink: %d\n", tmprc); cifs_dbg(FYI, "CIFSCheckMFSymlink: %d\n", tmprc);
} }
......
...@@ -354,34 +354,30 @@ open_query_close_cifs_symlink(const unsigned char *path, char *pbuf, ...@@ -354,34 +354,30 @@ open_query_close_cifs_symlink(const unsigned char *path, char *pbuf,
int int
CIFSCheckMFSymlink(struct cifs_fattr *fattr, CIFSCheckMFSymlink(unsigned int xid, struct cifs_tcon *tcon,
const unsigned char *path, struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
struct cifs_sb_info *cifs_sb, unsigned int xid) const unsigned char *path)
{ {
int rc = 0; int rc;
u8 *buf = NULL; u8 *buf = NULL;
unsigned int link_len = 0; unsigned int link_len = 0;
unsigned int bytes_read = 0; unsigned int bytes_read = 0;
struct cifs_tcon *ptcon;
if (!CIFSCouldBeMFSymlink(fattr)) if (!CIFSCouldBeMFSymlink(fattr))
/* it's not a symlink */ /* it's not a symlink */
return 0; return 0;
buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL); buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL);
if (!buf) { if (!buf)
rc = -ENOMEM; return -ENOMEM;
goto out;
}
ptcon = tlink_tcon(cifs_sb_tlink(cifs_sb)); if (tcon->ses->server->ops->query_mf_symlink)
if ((ptcon->ses) && (ptcon->ses->server->ops->query_mf_symlink)) rc = tcon->ses->server->ops->query_mf_symlink(path, buf,
rc = ptcon->ses->server->ops->query_mf_symlink(path, buf, &bytes_read, cifs_sb, xid);
&bytes_read, cifs_sb, xid);
else else
goto out; rc = -ENOSYS;
if (rc != 0) if (rc)
goto out; goto out;
if (bytes_read == 0) /* not a symlink */ if (bytes_read == 0) /* not a symlink */
......
...@@ -1006,6 +1006,14 @@ struct smb_version_operations smb1_operations = { ...@@ -1006,6 +1006,14 @@ struct smb_version_operations smb1_operations = {
.push_mand_locks = cifs_push_mandatory_locks, .push_mand_locks = cifs_push_mandatory_locks,
.query_mf_symlink = open_query_close_cifs_symlink, .query_mf_symlink = open_query_close_cifs_symlink,
.is_read_op = cifs_is_read_op, .is_read_op = cifs_is_read_op,
#ifdef CONFIG_CIFS_XATTR
.query_all_EAs = CIFSSMBQAllEAs,
.set_EA = CIFSSMBSetEA,
#endif /* CIFS_XATTR */
#ifdef CONFIG_CIFS_ACL
.get_acl = get_cifs_acl,
.set_acl = set_cifs_acl,
#endif /* CIFS_ACL */
}; };
struct smb_version_values smb1_values = { struct smb_version_values smb1_values = {
......
...@@ -57,4 +57,7 @@ ...@@ -57,4 +57,7 @@
#define SMB2_CMACAES_SIZE (16) #define SMB2_CMACAES_SIZE (16)
#define SMB3_SIGNKEY_SIZE (16) #define SMB3_SIGNKEY_SIZE (16)
/* Maximum buffer size value we can send with 1 credit */
#define SMB2_MAX_BUFFER_SIZE 65536
#endif /* _SMB2_GLOB_H */ #endif /* _SMB2_GLOB_H */
...@@ -182,11 +182,8 @@ smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info) ...@@ -182,11 +182,8 @@ smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
/* start with specified wsize, or default */ /* start with specified wsize, or default */
wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE; wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE;
wsize = min_t(unsigned int, wsize, server->max_write); wsize = min_t(unsigned int, wsize, server->max_write);
/* /* set it to the maximum buffer size value we can send with 1 credit */
* limit write size to 2 ** 16, because we don't support multicredit wsize = min_t(unsigned int, wsize, SMB2_MAX_BUFFER_SIZE);
* requests now.
*/
wsize = min_t(unsigned int, wsize, 2 << 15);
return wsize; return wsize;
} }
...@@ -200,11 +197,8 @@ smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info) ...@@ -200,11 +197,8 @@ smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
/* start with specified rsize, or default */ /* start with specified rsize, or default */
rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE; rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE;
rsize = min_t(unsigned int, rsize, server->max_read); rsize = min_t(unsigned int, rsize, server->max_read);
/* /* set it to the maximum buffer size value we can send with 1 credit */
* limit write size to 2 ** 16, because we don't support multicredit rsize = min_t(unsigned int, rsize, SMB2_MAX_BUFFER_SIZE);
* requests now.
*/
rsize = min_t(unsigned int, rsize, 2 << 15);
return rsize; return rsize;
} }
......
...@@ -413,7 +413,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) ...@@ -413,7 +413,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
/* SMB2 only has an extended negflavor */ /* SMB2 only has an extended negflavor */
server->negflavor = CIFS_NEGFLAVOR_EXTENDED; server->negflavor = CIFS_NEGFLAVOR_EXTENDED;
server->maxBuf = le32_to_cpu(rsp->MaxTransactSize); /* set it to the maximum buffer size value we can send with 1 credit */
server->maxBuf = min_t(unsigned int, le32_to_cpu(rsp->MaxTransactSize),
SMB2_MAX_BUFFER_SIZE);
server->max_read = le32_to_cpu(rsp->MaxReadSize); server->max_read = le32_to_cpu(rsp->MaxReadSize);
server->max_write = le32_to_cpu(rsp->MaxWriteSize); server->max_write = le32_to_cpu(rsp->MaxWriteSize);
/* BB Do we need to validate the SecurityMode? */ /* BB Do we need to validate the SecurityMode? */
......
...@@ -82,9 +82,11 @@ int cifs_removexattr(struct dentry *direntry, const char *ea_name) ...@@ -82,9 +82,11 @@ int cifs_removexattr(struct dentry *direntry, const char *ea_name)
goto remove_ea_exit; goto remove_ea_exit;
ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */ ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, NULL, if (pTcon->ses->server->ops->set_EA)
(__u16)0, cifs_sb->local_nls, rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); full_path, ea_name, NULL, (__u16)0,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
} }
remove_ea_exit: remove_ea_exit:
kfree(full_path); kfree(full_path);
...@@ -149,18 +151,22 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, ...@@ -149,18 +151,22 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
cifs_dbg(FYI, "attempt to set cifs inode metadata\n"); cifs_dbg(FYI, "attempt to set cifs inode metadata\n");
ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */ ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value, if (pTcon->ses->server->ops->set_EA)
(__u16)value_size, cifs_sb->local_nls, rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); full_path, ea_name, ea_value, (__u16)value_size,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
} else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) } else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN)
== 0) { == 0) {
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
goto set_ea_exit; goto set_ea_exit;
ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */ ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */
rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value, if (pTcon->ses->server->ops->set_EA)
(__u16)value_size, cifs_sb->local_nls, rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); full_path, ea_name, ea_value, (__u16)value_size,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
} else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL, } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL,
strlen(CIFS_XATTR_CIFS_ACL)) == 0) { strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
#ifdef CONFIG_CIFS_ACL #ifdef CONFIG_CIFS_ACL
...@@ -170,8 +176,12 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, ...@@ -170,8 +176,12 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
rc = -ENOMEM; rc = -ENOMEM;
} else { } else {
memcpy(pacl, ea_value, value_size); memcpy(pacl, ea_value, value_size);
rc = set_cifs_acl(pacl, value_size, if (pTcon->ses->server->ops->set_acl)
direntry->d_inode, full_path, CIFS_ACL_DACL); rc = pTcon->ses->server->ops->set_acl(pacl,
value_size, direntry->d_inode,
full_path, CIFS_ACL_DACL);
else
rc = -EOPNOTSUPP;
if (rc == 0) /* force revalidate of the inode */ if (rc == 0) /* force revalidate of the inode */
CIFS_I(direntry->d_inode)->time = 0; CIFS_I(direntry->d_inode)->time = 0;
kfree(pacl); kfree(pacl);
...@@ -272,17 +282,21 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, ...@@ -272,17 +282,21 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
/* revalidate/getattr then populate from inode */ /* revalidate/getattr then populate from inode */
} /* BB add else when above is implemented */ } /* BB add else when above is implemented */
ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */ ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value, if (pTcon->ses->server->ops->query_all_EAs)
buf_size, cifs_sb->local_nls, rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); full_path, ea_name, ea_value, buf_size,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
} else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) { } else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) {
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
goto get_ea_exit; goto get_ea_exit;
ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */ ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value, if (pTcon->ses->server->ops->query_all_EAs)
buf_size, cifs_sb->local_nls, rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); full_path, ea_name, ea_value, buf_size,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
} else if (strncmp(ea_name, POSIX_ACL_XATTR_ACCESS, } else if (strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
strlen(POSIX_ACL_XATTR_ACCESS)) == 0) { strlen(POSIX_ACL_XATTR_ACCESS)) == 0) {
#ifdef CONFIG_CIFS_POSIX #ifdef CONFIG_CIFS_POSIX
...@@ -313,8 +327,11 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, ...@@ -313,8 +327,11 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
u32 acllen; u32 acllen;
struct cifs_ntsd *pacl; struct cifs_ntsd *pacl;
pacl = get_cifs_acl(cifs_sb, direntry->d_inode, if (pTcon->ses->server->ops->get_acl == NULL)
full_path, &acllen); goto get_ea_exit; /* rc already EOPNOTSUPP */
pacl = pTcon->ses->server->ops->get_acl(cifs_sb,
direntry->d_inode, full_path, &acllen);
if (IS_ERR(pacl)) { if (IS_ERR(pacl)) {
rc = PTR_ERR(pacl); rc = PTR_ERR(pacl);
cifs_dbg(VFS, "%s: error %zd getting sec desc\n", cifs_dbg(VFS, "%s: error %zd getting sec desc\n",
...@@ -400,11 +417,12 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size) ...@@ -400,11 +417,12 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
/* if proc/fs/cifs/streamstoxattr is set then /* if proc/fs/cifs/streamstoxattr is set then
search server for EAs or streams to search server for EAs or streams to
returns as xattrs */ returns as xattrs */
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, NULL, data,
buf_size, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
if (pTcon->ses->server->ops->query_all_EAs)
rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
full_path, NULL, data, buf_size,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
list_ea_exit: list_ea_exit:
kfree(full_path); kfree(full_path);
free_xid(xid); free_xid(xid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment