aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2015-12-02 08:44:41 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-12-13 19:45:47 -0500
commitc4803c497fbdb37e96af614813a7cfb434b6682a (patch)
tree13ea05af560579eb3728a6c046e2657a06a902b0 /fs/nfs/nfs4proc.c
parent5d92b75c753ae27578ee764df3be650c67fa5877 (diff)
nfs: Move call to security_inode_listsecurity into nfs_listxattr
Add a nfs_listxattr operation. Move the call to security_inode_listsecurity from list operation of the "security.*" xattr handler to nfs_listxattr. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Cc: Trond Myklebust <trond.myklebust@primarydata.com> Cc: Anna Schumaker <anna.schumaker@netapp.com> Cc: linux-nfs@vger.kernel.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c53
1 files changed, 36 insertions, 17 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index f6f40aae92b1..dbfade2602c9 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -6279,10 +6279,6 @@ static size_t nfs4_xattr_list_nfs4_acl(const struct xattr_handler *handler,
6279} 6279}
6280 6280
6281#ifdef CONFIG_NFS_V4_SECURITY_LABEL 6281#ifdef CONFIG_NFS_V4_SECURITY_LABEL
6282static inline int nfs4_server_supports_labels(struct nfs_server *server)
6283{
6284 return server->caps & NFS_CAP_SECURITY_LABEL;
6285}
6286 6282
6287static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler, 6283static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler,
6288 struct dentry *dentry, const char *key, 6284 struct dentry *dentry, const char *key,
@@ -6304,29 +6300,34 @@ static int nfs4_xattr_get_nfs4_label(const struct xattr_handler *handler,
6304 return -EOPNOTSUPP; 6300 return -EOPNOTSUPP;
6305} 6301}
6306 6302
6307static size_t nfs4_xattr_list_nfs4_label(const struct xattr_handler *handler, 6303static ssize_t
6308 struct dentry *dentry, char *list, 6304nfs4_listxattr_nfs4_label(struct inode *inode, char *list, size_t list_len)
6309 size_t list_len, const char *name,
6310 size_t name_len)
6311{ 6305{
6312 size_t len = 0; 6306 int len = 0;
6313 6307
6314 if (nfs_server_capable(d_inode(dentry), NFS_CAP_SECURITY_LABEL)) { 6308 if (nfs_server_capable(inode, NFS_CAP_SECURITY_LABEL)) {
6315 len = security_inode_listsecurity(d_inode(dentry), NULL, 0); 6309 len = security_inode_listsecurity(inode, list, list_len);
6316 if (list && len <= list_len) 6310 if (list_len && len > list_len)
6317 security_inode_listsecurity(d_inode(dentry), list, len); 6311 return -ERANGE;
6318 } 6312 }
6319 return len; 6313 return len;
6320} 6314}
6321 6315
6322static const struct xattr_handler nfs4_xattr_nfs4_label_handler = { 6316static const struct xattr_handler nfs4_xattr_nfs4_label_handler = {
6323 .prefix = XATTR_SECURITY_PREFIX, 6317 .prefix = XATTR_SECURITY_PREFIX,
6324 .list = nfs4_xattr_list_nfs4_label,
6325 .get = nfs4_xattr_get_nfs4_label, 6318 .get = nfs4_xattr_get_nfs4_label,
6326 .set = nfs4_xattr_set_nfs4_label, 6319 .set = nfs4_xattr_set_nfs4_label,
6327}; 6320};
6328#endif
6329 6321
6322#else
6323
6324static ssize_t
6325nfs4_listxattr_nfs4_label(struct inode *inode, char *list, size_t list_len)
6326{
6327 return 0;
6328}
6329
6330#endif
6330 6331
6331/* 6332/*
6332 * nfs_fhget will use either the mounted_on_fileid or the fileid 6333 * nfs_fhget will use either the mounted_on_fileid or the fileid
@@ -8743,6 +8744,24 @@ const struct nfs4_minor_version_ops *nfs_v4_minor_ops[] = {
8743#endif 8744#endif
8744}; 8745};
8745 8746
8747ssize_t nfs4_listxattr(struct dentry *dentry, char *list, size_t size)
8748{
8749 ssize_t error, error2;
8750
8751 error = generic_listxattr(dentry, list, size);
8752 if (error < 0)
8753 return error;
8754 if (list) {
8755 list += error;
8756 size -= error;
8757 }
8758
8759 error2 = nfs4_listxattr_nfs4_label(d_inode(dentry), list, size);
8760 if (error2 < 0)
8761 return error2;
8762 return error + error2;
8763}
8764
8746static const struct inode_operations nfs4_dir_inode_operations = { 8765static const struct inode_operations nfs4_dir_inode_operations = {
8747 .create = nfs_create, 8766 .create = nfs_create,
8748 .lookup = nfs_lookup, 8767 .lookup = nfs_lookup,
@@ -8759,7 +8778,7 @@ static const struct inode_operations nfs4_dir_inode_operations = {
8759 .setattr = nfs_setattr, 8778 .setattr = nfs_setattr,
8760 .getxattr = generic_getxattr, 8779 .getxattr = generic_getxattr,
8761 .setxattr = generic_setxattr, 8780 .setxattr = generic_setxattr,
8762 .listxattr = generic_listxattr, 8781 .listxattr = nfs4_listxattr,
8763 .removexattr = generic_removexattr, 8782 .removexattr = generic_removexattr,
8764}; 8783};
8765 8784
@@ -8769,7 +8788,7 @@ static const struct inode_operations nfs4_file_inode_operations = {
8769 .setattr = nfs_setattr, 8788 .setattr = nfs_setattr,
8770 .getxattr = generic_getxattr, 8789 .getxattr = generic_getxattr,
8771 .setxattr = generic_setxattr, 8790 .setxattr = generic_setxattr,
8772 .listxattr = generic_listxattr, 8791 .listxattr = nfs4_listxattr,
8773 .removexattr = generic_removexattr, 8792 .removexattr = generic_removexattr,
8774}; 8793};
8775 8794