Upgrade to 4.4.50-rt62
[kvmfornfv.git] / kernel / fs / 9p / acl.c
index 31c0103..929b618 100644 (file)
@@ -212,26 +212,9 @@ int v9fs_acl_mode(struct inode *dir, umode_t *modep,
        return 0;
 }
 
-static int v9fs_remote_get_acl(struct dentry *dentry, const char *name,
-                              void *buffer, size_t size, int type)
-{
-       char *full_name;
-
-       switch (type) {
-       case ACL_TYPE_ACCESS:
-               full_name =  POSIX_ACL_XATTR_ACCESS;
-               break;
-       case ACL_TYPE_DEFAULT:
-               full_name = POSIX_ACL_XATTR_DEFAULT;
-               break;
-       default:
-               BUG();
-       }
-       return v9fs_xattr_get(dentry, full_name, buffer, size);
-}
-
-static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
-                             void *buffer, size_t size, int type)
+static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
+                             struct dentry *dentry, const char *name,
+                             void *buffer, size_t size)
 {
        struct v9fs_session_info *v9ses;
        struct posix_acl *acl;
@@ -245,9 +228,9 @@ static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
         * We allow set/get/list of acl when access=client is not specified
         */
        if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
-               return v9fs_remote_get_acl(dentry, name, buffer, size, type);
+               return v9fs_xattr_get(dentry, handler->prefix, buffer, size);
 
-       acl = v9fs_get_cached_acl(d_inode(dentry), type);
+       acl = v9fs_get_cached_acl(d_inode(dentry), handler->flags);
        if (IS_ERR(acl))
                return PTR_ERR(acl);
        if (acl == NULL)
@@ -258,29 +241,9 @@ static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
        return error;
 }
 
-static int v9fs_remote_set_acl(struct dentry *dentry, const char *name,
-                             const void *value, size_t size,
-                             int flags, int type)
-{
-       char *full_name;
-
-       switch (type) {
-       case ACL_TYPE_ACCESS:
-               full_name =  POSIX_ACL_XATTR_ACCESS;
-               break;
-       case ACL_TYPE_DEFAULT:
-               full_name = POSIX_ACL_XATTR_DEFAULT;
-               break;
-       default:
-               BUG();
-       }
-       return v9fs_xattr_set(dentry, full_name, value, size, flags);
-}
-
-
-static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
-                             const void *value, size_t size,
-                             int flags, int type)
+static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
+                             struct dentry *dentry, const char *name,
+                             const void *value, size_t size, int flags)
 {
        int retval;
        struct posix_acl *acl;
@@ -296,8 +259,8 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
         * xattr value. We leave it to the server to validate
         */
        if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
-               return v9fs_remote_set_acl(dentry, name,
-                                          value, size, flags, type);
+               return v9fs_xattr_set(dentry, handler->prefix, value, size,
+                                     flags);
 
        if (S_ISLNK(inode->i_mode))
                return -EOPNOTSUPP;
@@ -316,40 +279,32 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
        } else
                acl = NULL;
 
-       switch (type) {
+       switch (handler->flags) {
        case ACL_TYPE_ACCESS:
-               name = POSIX_ACL_XATTR_ACCESS;
                if (acl) {
-                       umode_t mode = inode->i_mode;
-                       retval = posix_acl_equiv_mode(acl, &mode);
-                       if (retval < 0)
+                       struct iattr iattr;
+
+                       retval = posix_acl_update_mode(inode, &iattr.ia_mode, &acl);
+                       if (retval)
                                goto err_out;
-                       else {
-                               struct iattr iattr;
-                               if (retval == 0) {
-                                       /*
-                                        * ACL can be represented
-                                        * by the mode bits. So don't
-                                        * update ACL.
-                                        */
-                                       acl = NULL;
-                                       value = NULL;
-                                       size = 0;
-                               }
-                               /* Updte the mode bits */
-                               iattr.ia_mode = ((mode & S_IALLUGO) |
-                                                (inode->i_mode & ~S_IALLUGO));
-                               iattr.ia_valid = ATTR_MODE;
-                               /* FIXME should we update ctime ?
-                                * What is the following setxattr update the
-                                * mode ?
+                       if (!acl) {
+                               /*
+                                * ACL can be represented
+                                * by the mode bits. So don't
+                                * update ACL.
                                 */
-                               v9fs_vfs_setattr_dotl(dentry, &iattr);
+                               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(dentry, &iattr);
                }
                break;
        case ACL_TYPE_DEFAULT:
-               name = POSIX_ACL_XATTR_DEFAULT;
                if (!S_ISDIR(inode->i_mode)) {
                        retval = acl ? -EINVAL : 0;
                        goto err_out;
@@ -358,9 +313,9 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
        default:
                BUG();
        }
-       retval = v9fs_xattr_set(dentry, name, value, size, flags);
+       retval = v9fs_xattr_set(dentry, handler->prefix, value, size, flags);
        if (!retval)
-               set_cached_acl(inode, type, acl);
+               set_cached_acl(inode, handler->flags, acl);
 err_out:
        posix_acl_release(acl);
        return retval;