9p: use stub posix acl handlers
authorChristian Brauner <brauner@kernel.org>
Thu, 22 Sep 2022 15:17:26 +0000 (17:17 +0200)
committerChristian Brauner (Microsoft) <brauner@kernel.org>
Thu, 20 Oct 2022 08:13:32 +0000 (10:13 +0200)
Now that 9p supports the get and set acl inode operations and the vfs
has been switched to the new posi api, 9p can simply rely on the stub
posix acl handlers. The custom xattr handlers and associated unused
helpers can be removed.

Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
fs/9p/acl.c
fs/9p/xattr.c
fs/9p/xattr.h

index 135b26cee63a6cc3a438ad63becf4621299d3921..c397c51f80d9143a42e1e144c7f4179a4edb24d7 100644 (file)
@@ -343,124 +343,3 @@ int v9fs_acl_mode(struct inode *dir, umode_t *modep,
        *modep  = mode;
        return 0;
 }
-
-static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
-                             struct dentry *dentry, struct inode *inode,
-                             const char *name, void *buffer, size_t size)
-{
-       struct v9fs_session_info *v9ses;
-       struct posix_acl *acl;
-       int error;
-
-       v9ses = v9fs_dentry2v9ses(dentry);
-       /*
-        * We allow set/get/list of acl when access=client is not specified
-        */
-       if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
-               return v9fs_xattr_get(dentry, handler->name, buffer, size);
-
-       acl = v9fs_get_cached_acl(inode, handler->flags);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-       if (acl == NULL)
-               return -ENODATA;
-       error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
-       posix_acl_release(acl);
-
-       return error;
-}
-
-static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
-                             struct user_namespace *mnt_userns,
-                             struct dentry *dentry, struct inode *inode,
-                             const char *name, const void *value,
-                             size_t size, int flags)
-{
-       int retval;
-       struct posix_acl *acl;
-       struct v9fs_session_info *v9ses;
-
-       v9ses = v9fs_dentry2v9ses(dentry);
-       /*
-        * set the attribute on the remote. Without even looking at the
-        * xattr value. We leave it to the server to validate
-        */
-       if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
-               return v9fs_xattr_set(dentry, handler->name, value, size,
-                                     flags);
-
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-       if (!inode_owner_or_capable(&init_user_ns, inode))
-               return -EPERM;
-       if (value) {
-               /* update the cached acl value */
-               acl = posix_acl_from_xattr(&init_user_ns, value, size);
-               if (IS_ERR(acl))
-                       return PTR_ERR(acl);
-               else if (acl) {
-                       retval = posix_acl_valid(inode->i_sb->s_user_ns, acl);
-                       if (retval)
-                               goto err_out;
-               }
-       } else
-               acl = NULL;
-
-       switch (handler->flags) {
-       case ACL_TYPE_ACCESS:
-               if (acl) {
-                       struct iattr iattr = { 0 };
-                       struct posix_acl *old_acl = acl;
-
-                       retval = posix_acl_update_mode(&init_user_ns, inode,
-                                                      &iattr.ia_mode, &acl);
-                       if (retval)
-                               goto err_out;
-                       if (!acl) {
-                               /*
-                                * ACL can be represented
-                                * by the mode bits. So don't
-                                * update ACL.
-                                */
-                               posix_acl_release(old_acl);
-                               value = NULL;
-                               size = 0;
-                       }
-                       iattr.ia_valid = ATTR_MODE;
-                       /* FIXME should we update ctime ?
-                        * What is the following setxattr update the
-                        * mode ?
-                        */
-                       v9fs_vfs_setattr_dotl(&init_user_ns, dentry, &iattr);
-               }
-               break;
-       case ACL_TYPE_DEFAULT:
-               if (!S_ISDIR(inode->i_mode)) {
-                       retval = acl ? -EINVAL : 0;
-                       goto err_out;
-               }
-               break;
-       default:
-               BUG();
-       }
-       retval = v9fs_xattr_set(dentry, handler->name, value, size, flags);
-       if (!retval)
-               set_cached_acl(inode, handler->flags, acl);
-err_out:
-       posix_acl_release(acl);
-       return retval;
-}
-
-const struct xattr_handler v9fs_xattr_acl_access_handler = {
-       .name   = XATTR_NAME_POSIX_ACL_ACCESS,
-       .flags  = ACL_TYPE_ACCESS,
-       .get    = v9fs_xattr_get_acl,
-       .set    = v9fs_xattr_set_acl,
-};
-
-const struct xattr_handler v9fs_xattr_acl_default_handler = {
-       .name   = XATTR_NAME_POSIX_ACL_DEFAULT,
-       .flags  = ACL_TYPE_DEFAULT,
-       .get    = v9fs_xattr_get_acl,
-       .set    = v9fs_xattr_set_acl,
-};
index 1f9298a4bd4288390c1e98395486931ff4c4ac93..ae6a93871338c1431c52a14140beb38b77ff10d7 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/uio.h>
+#include <linux/posix_acl_xattr.h>
 #include <net/9p/9p.h>
 #include <net/9p/client.h>
 
@@ -182,9 +183,9 @@ static struct xattr_handler v9fs_xattr_security_handler = {
 const struct xattr_handler *v9fs_xattr_handlers[] = {
        &v9fs_xattr_user_handler,
        &v9fs_xattr_trusted_handler,
-#ifdef CONFIG_9P_FS_POSIX_ACL
-       &v9fs_xattr_acl_access_handler,
-       &v9fs_xattr_acl_default_handler,
+#ifdef CONFIG_FS_POSIX_ACL
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
 #endif
 #ifdef CONFIG_9P_FS_SECURITY
        &v9fs_xattr_security_handler,
index 3e11fc3331ebe711b2ecfc6a6e8635b13be643c3..b5636e544c8af042f78e9c08c4275011b7c787e1 100644 (file)
@@ -11,8 +11,6 @@
 #include <net/9p/client.h>
 
 extern const struct xattr_handler *v9fs_xattr_handlers[];
-extern const struct xattr_handler v9fs_xattr_acl_access_handler;
-extern const struct xattr_handler v9fs_xattr_acl_default_handler;
 
 ssize_t v9fs_fid_xattr_get(struct p9_fid *fid, const char *name,
                           void *buffer, size_t buffer_size);