]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/zfs_acl.c
cstyle: Resolve C style issues
[mirror_zfs.git] / module / zfs / zfs_acl.c
index db6331ea595c665dd6d6d5b876a4e5cabed352ba..c5f76036fcbb6ddb253e4bbe8264c1957b9465c7 100644 (file)
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
  */
 
 
@@ -676,7 +677,7 @@ zfs_copy_ace_2_fuid(zfs_sb_t *zsb, umode_t obj_mode, zfs_acl_t *aclp,
                 */
                if (zfs_ace_valid(obj_mode, aclp, aceptr->z_hdr.z_type,
                    aceptr->z_hdr.z_flags) != B_TRUE)
-                       return (EINVAL);
+                       return (SET_ERROR(EINVAL));
 
                switch (acep->a_type) {
                case ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE:
@@ -783,7 +784,7 @@ zfs_copy_ace_2_oldace(umode_t obj_mode, zfs_acl_t *aclp, ace_t *acep,
                 */
                if (zfs_ace_valid(obj_mode, aclp, aceptr->z_type,
                    aceptr->z_flags) != B_TRUE)
-                       return (EINVAL);
+                       return (SET_ERROR(EINVAL));
        }
        *size = (caddr_t)aceptr - (caddr_t)z_acl;
        return (0);
@@ -1056,8 +1057,8 @@ zfs_acl_node_read(znode_t *zp, boolean_t have_lock, zfs_acl_t **aclpp,
     boolean_t will_modify)
 {
        zfs_acl_t       *aclp;
-       int             aclsize;
-       int             acl_count;
+       int             aclsize = 0;
+       int             acl_count = 0;
        zfs_acl_node_t  *aclnode;
        zfs_acl_phys_t  znode_acl;
        int             version;
@@ -1117,7 +1118,7 @@ zfs_acl_node_read(znode_t *zp, boolean_t have_lock, zfs_acl_t **aclpp,
                zfs_acl_node_free(aclnode);
                /* convert checksum errors into IO errors */
                if (error == ECKSUM)
-                       error = EIO;
+                       error = SET_ERROR(EIO);
                goto done;
        }
 
@@ -1155,12 +1156,16 @@ zfs_acl_chown_setattr(znode_t *zp)
        int error;
        zfs_acl_t *aclp;
 
+       if (ZTOZSB(zp)->z_acl_type == ZFS_ACLTYPE_POSIXACL)
+               return (0);
+
        ASSERT(MUTEX_HELD(&zp->z_lock));
        ASSERT(MUTEX_HELD(&zp->z_acl_lock));
 
        if ((error = zfs_acl_node_read(zp, B_TRUE, &aclp, B_FALSE)) == 0)
                zp->z_mode = zfs_mode_compute(zp->z_mode, aclp,
                    &zp->z_pflags, zp->z_uid, zp->z_gid);
+
        return (error);
 }
 
@@ -1472,7 +1477,8 @@ zfs_acl_chmod(zfs_sb_t *zsb, uint64_t mode, zfs_acl_t *aclp)
                zacep = (void *)((uintptr_t)zacep + abstract_size);
                new_count++;
                new_bytes += abstract_size;
-       } if (deny1) {
+       }
+       if (deny1) {
                zfs_set_ace(aclp, zacep, deny1, DENY, -1, ACE_OWNER);
                zacep = (void *)((uintptr_t)zacep + abstract_size);
                new_count++;
@@ -1869,7 +1875,7 @@ zfs_acl_ids_overquota(zfs_sb_t *zsb, zfs_acl_ids_t *acl_ids)
 }
 
 /*
- * Retrieve a files ACL
+ * Retrieve a file's ACL
  */
 int
 zfs_getacl(znode_t *zp, vsecattr_t *vsecp, boolean_t skipaclchk, cred_t *cr)
@@ -1884,7 +1890,7 @@ zfs_getacl(znode_t *zp, vsecattr_t *vsecp, boolean_t skipaclchk, cred_t *cr)
            VSA_ACE_ACLFLAGS | VSA_ACE_ALLTYPES);
 
        if (mask == 0)
-               return (ENOSYS);
+               return (SET_ERROR(ENOSYS));
 
        if ((error = zfs_zaccess(zp, ACE_READ_ACL, 0, skipaclchk, cr)))
                return (error);
@@ -1978,7 +1984,7 @@ zfs_vsec_2_aclp(zfs_sb_t *zsb, umode_t obj_mode,
        int error;
 
        if (vsecp->vsa_aclcnt > MAX_ACL_ENTRIES || vsecp->vsa_aclcnt <= 0)
-               return (EINVAL);
+               return (SET_ERROR(EINVAL));
 
        aclp = zfs_acl_alloc(zfs_acl_version(zsb->z_version));
 
@@ -2024,7 +2030,7 @@ zfs_vsec_2_aclp(zfs_sb_t *zsb, umode_t obj_mode,
 }
 
 /*
- * Set a files ACL
+ * Set a file's ACL
  */
 int
 zfs_setacl(znode_t *zp, vsecattr_t *vsecp, boolean_t skipaclchk, cred_t *cr)
@@ -2040,10 +2046,10 @@ zfs_setacl(znode_t *zp, vsecattr_t *vsecp, boolean_t skipaclchk, cred_t *cr)
        uint64_t        acl_obj;
 
        if (mask == 0)
-               return (ENOSYS);
+               return (SET_ERROR(ENOSYS));
 
        if (zp->z_pflags & ZFS_IMMUTABLE)
-               return (EPERM);
+               return (SET_ERROR(EPERM));
 
        if ((error = zfs_zaccess(zp, ACE_WRITE_ACL, 0, skipaclchk, cr)))
                return (error);
@@ -2139,7 +2145,7 @@ zfs_zaccess_dataset_check(znode_t *zp, uint32_t v4_mode)
        if ((v4_mode & WRITE_MASK) && (zfs_is_readonly(ZTOZSB(zp))) &&
            (!S_ISDEV(ZTOI(zp)->i_mode) ||
            (S_ISDEV(ZTOI(zp)->i_mode) && (v4_mode & WRITE_MASK_ATTRS)))) {
-               return (EROFS);
+               return (SET_ERROR(EROFS));
        }
 
        /*
@@ -2150,17 +2156,17 @@ zfs_zaccess_dataset_check(znode_t *zp, uint32_t v4_mode)
            (zp->z_pflags & (ZFS_READONLY | ZFS_IMMUTABLE))) ||
            (S_ISDIR(ZTOI(zp)->i_mode) &&
            (zp->z_pflags & ZFS_IMMUTABLE)))) {
-               return (EPERM);
+               return (SET_ERROR(EPERM));
        }
 
        if ((v4_mode & (ACE_DELETE | ACE_DELETE_CHILD)) &&
            (zp->z_pflags & ZFS_NOUNLINK)) {
-               return (EPERM);
+               return (SET_ERROR(EPERM));
        }
 
        if (((v4_mode & (ACE_READ_DATA|ACE_EXECUTE)) &&
            (zp->z_pflags & ZFS_AV_QUARANTINED))) {
-               return (EACCES);
+               return (SET_ERROR(EACCES));
        }
 
        return (0);
@@ -2269,7 +2275,7 @@ zfs_zaccess_aces_check(znode_t *zp, uint32_t *working_mode,
                                break;
                        } else {
                                mutex_exit(&zp->z_acl_lock);
-                               return (EIO);
+                               return (SET_ERROR(EIO));
                        }
                }
 
@@ -2303,7 +2309,7 @@ zfs_zaccess_aces_check(znode_t *zp, uint32_t *working_mode,
        /* Put the found 'denies' back on the working mode */
        if (deny_mask) {
                *working_mode |= deny_mask;
-               return (EACCES);
+               return (SET_ERROR(EACCES));
        } else if (*working_mode) {
                return (-1);
        }
@@ -2370,7 +2376,7 @@ zfs_zaccess_append(znode_t *zp, uint32_t *working_mode, boolean_t *check_privs,
     cred_t *cr)
 {
        if (*working_mode != ACE_WRITE_DATA)
-               return (EACCES);
+               return (SET_ERROR(EACCES));
 
        return (zfs_zaccess_common(zp, ACE_APPEND_DATA, working_mode,
            check_privs, B_FALSE, cr));
@@ -2386,7 +2392,7 @@ zfs_fastaccesschk_execute(znode_t *zdp, cred_t *cr)
        int error;
 
        if (zdp->z_pflags & ZFS_AV_QUARANTINED)
-               return (EACCES);
+               return (SET_ERROR(EACCES));
 
        is_attr = ((zdp->z_pflags & ZFS_XATTR) &&
            (S_ISDIR(ZTOI(zdp)->i_mode)));
@@ -2445,6 +2451,7 @@ slow:
 
 /*
  * Determine whether Access should be granted/denied.
+ *
  * The least priv subsytem is always consulted as a basic privilege
  * can define any form of access.
  */
@@ -2492,7 +2499,7 @@ zfs_zaccess(znode_t *zp, int mode, int flags, boolean_t skipaclchk, cred_t *cr)
                         */
                        error = zfs_zget(ZTOZSB(zp), parent, &check_zp);
                        if (error)
-                               return (error);
+                               return (error);
 
                        rw_enter(&zp->z_xattr_lock, RW_WRITER);
                        if (zp->z_xattr_parent == NULL)
@@ -2598,7 +2605,7 @@ zfs_zaccess(znode_t *zp, int mode, int flags, boolean_t skipaclchk, cred_t *cr)
                         * for are still present.  If so then return EACCES
                         */
                        if (working_mode & ~(ZFS_CHECKED_MASKS)) {
-                               error = EACCES;
+                               error = SET_ERROR(EACCES);
                        }
                }
        } else if (error == 0) {
@@ -2652,7 +2659,6 @@ zfs_delete_final_check(znode_t *zp, znode_t *dzp,
  * Determine whether Access should be granted/deny, without
  * consulting least priv subsystem.
  *
- *
  * The following chart is the recommended NFSv4 enforcement for
  * ability to delete an object.
  *
@@ -2708,7 +2714,7 @@ zfs_zaccess_delete(znode_t *dzp, znode_t *zp, cred_t *cr)
         */
 
        if (zp->z_pflags & (ZFS_IMMUTABLE | ZFS_NOUNLINK))
-               return (EPERM);
+               return (SET_ERROR(EPERM));
 
        /*
         * First row
@@ -2775,7 +2781,7 @@ zfs_zaccess_rename(znode_t *sdzp, znode_t *szp, znode_t *tdzp,
        int error;
 
        if (szp->z_pflags & ZFS_AV_QUARANTINED)
-               return (EACCES);
+               return (SET_ERROR(EACCES));
 
        add_perm = S_ISDIR(ZTOI(szp)->i_mode) ?
            ACE_ADD_SUBDIRECTORY : ACE_ADD_FILE;