]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/miscfs/nullfs/null_vfsops.c
xnu-6153.141.1.tar.gz
[apple/xnu.git] / bsd / miscfs / nullfs / null_vfsops.c
index 5a191d2e1c689f3ece6e750ca77c21d4a1895792..8305be1c60a0a16ad1c06e976887134c7a1d618f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Apple Inc. All rights reserved.
+ * Copyright (c) 2019 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
@@ -127,8 +127,9 @@ nullfs_mount(struct mount * mp, __unused vnode_t devvp, user_addr_t user_data, v
 
        NULLFSDEBUG("nullfs_mount(mp = %p) %llx\n", (void *)mp, vfs_flags(mp));
 
-       if (vfs_flags(mp) & MNT_ROOTFS)
-               return (EOPNOTSUPP);
+       if (vfs_flags(mp) & MNT_ROOTFS) {
+               return EOPNOTSUPP;
+       }
 
        /*
         * Update is a no-op
@@ -166,12 +167,11 @@ nullfs_mount(struct mount * mp, __unused vnode_t devvp, user_addr_t user_data, v
        }
 
        /* lowervrootvp has an iocount after vnode_lookup, drop that for a usecount.
-          Keep this to signal what we want to keep around the thing we are mirroring.
-          Drop it in unmount.*/
+        *  Keep this to signal what we want to keep around the thing we are mirroring.
+        *  Drop it in unmount.*/
        error = vnode_ref(lowerrootvp);
        vnode_put(lowerrootvp);
-       if (error)
-       {
+       if (error) {
                // If vnode_ref failed, then null it out so it can't be used anymore in cleanup.
                lowerrootvp = NULL;
                goto error;
@@ -211,7 +211,7 @@ nullfs_mount(struct mount * mp, __unused vnode_t devvp, user_addr_t user_data, v
        xmp->nullm_rootvp = vp;
 
        /* read the flags the user set, but then ignore some of them, we will only
-          allow them if they are set on the lower file system */
+        *  allow them if they are set on the lower file system */
        uint64_t flags      = vfs_flags(mp) & (~(MNT_IGNORE_OWNERSHIP | MNT_LOCAL));
        uint64_t lowerflags = vfs_flags(vnode_mount(lowerrootvp)) & (MNT_LOCAL | MNT_QUARANTINE | MNT_IGNORE_OWNERSHIP | MNT_NOEXEC);
 
@@ -285,7 +285,7 @@ nullfs_mount(struct mount * mp, __unused vnode_t devvp, user_addr_t user_data, v
        MAC_PERFORM(mount_label_associate, cred, vnode_mount(lowerrootvp), vfs_mntlabel(mp));
 
        NULLFSDEBUG("nullfs_mount: lower %s, alias at %s\n", sp->f_mntfromname, sp->f_mntonname);
-       return (0);
+       return 0;
 
 error:
        if (xmp) {
@@ -321,7 +321,7 @@ nullfs_unmount(struct mount * mp, int mntflags, __unused vfs_context_t ctx)
 
        /* check entitlement or superuser*/
        if (!IOTaskHasEntitlement(current_task(), NULLFS_ENTITLEMENT) &&
-               vfs_context_suser(ctx) != 0) {
+           vfs_context_suser(ctx) != 0) {
                return EPERM;
        }
 
@@ -339,14 +339,12 @@ nullfs_unmount(struct mount * mp, int mntflags, __unused vfs_context_t ctx)
        vnode_getalways(vp);
 
        error = vflush(mp, vp, flags);
-       if (error)
-       {
+       if (error) {
                vnode_put(vp);
-               return (error);
+               return error;
        }
 
-       if (vnode_isinuse(vp,1) && flags == 0)
-       {
+       if (vnode_isinuse(vp, 1) && flags == 0) {
                vnode_put(vp);
                return EBUSY;
        }
@@ -376,7 +374,7 @@ nullfs_unmount(struct mount * mp, int mntflags, __unused vfs_context_t ctx)
        uint64_t vflags = vfs_flags(mp);
        vfs_setflags(mp, vflags & ~MNT_LOCAL);
 
-       return (0);
+       return 0;
 }
 
 static int
@@ -393,8 +391,9 @@ nullfs_root(struct mount * mp, struct vnode ** vpp, __unused vfs_context_t ctx)
        vp = MOUNTTONULLMOUNT(mp)->nullm_rootvp;
 
        error = vnode_get(vp);
-       if (error)
+       if (error) {
                return error;
+       }
 
        *vpp = vp;
        return 0;
@@ -409,7 +408,7 @@ nullfs_vfs_getattr(struct mount * mp, struct vfs_attr * vfap, vfs_context_t ctx)
        vol_capabilities_attr_t capabilities;
        struct vfsstatfs * sp = vfs_statfs(mp);
 
-       struct timespec tzero = {0, 0};
+       struct timespec tzero = {.tv_sec = 0, .tv_nsec = 0};
 
        NULLFSDEBUG("%s\n", __FUNCTION__);
 
@@ -436,48 +435,61 @@ nullfs_vfs_getattr(struct mount * mp, struct vfs_attr * vfap, vfs_context_t ctx)
 
                        capabilities.valid[VOL_CAPABILITIES_INTERFACES] &=
                            ~(VOL_CAP_INT_SEARCHFS | VOL_CAP_INT_ATTRLIST | VOL_CAP_INT_READDIRATTR | VOL_CAP_INT_EXCHANGEDATA |
-                             VOL_CAP_INT_COPYFILE | VOL_CAP_INT_ALLOCATE | VOL_CAP_INT_VOL_RENAME | VOL_CAP_INT_ADVLOCK | VOL_CAP_INT_FLOCK);
+                           VOL_CAP_INT_COPYFILE | VOL_CAP_INT_ALLOCATE | VOL_CAP_INT_VOL_RENAME | VOL_CAP_INT_ADVLOCK | VOL_CAP_INT_FLOCK);
                }
        }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_create_time))
+       if (VFSATTR_IS_ACTIVE(vfap, f_create_time)) {
                VFSATTR_RETURN(vfap, f_create_time, tzero);
+       }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_modify_time))
+       if (VFSATTR_IS_ACTIVE(vfap, f_modify_time)) {
                VFSATTR_RETURN(vfap, f_modify_time, tzero);
+       }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_access_time))
+       if (VFSATTR_IS_ACTIVE(vfap, f_access_time)) {
                VFSATTR_RETURN(vfap, f_access_time, tzero);
+       }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_bsize))
+       if (VFSATTR_IS_ACTIVE(vfap, f_bsize)) {
                VFSATTR_RETURN(vfap, f_bsize, sp->f_bsize);
+       }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_iosize))
+       if (VFSATTR_IS_ACTIVE(vfap, f_iosize)) {
                VFSATTR_RETURN(vfap, f_iosize, sp->f_iosize);
+       }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_owner))
+       if (VFSATTR_IS_ACTIVE(vfap, f_owner)) {
                VFSATTR_RETURN(vfap, f_owner, 0);
+       }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_blocks))
+       if (VFSATTR_IS_ACTIVE(vfap, f_blocks)) {
                VFSATTR_RETURN(vfap, f_blocks, sp->f_blocks);
+       }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_bfree))
+       if (VFSATTR_IS_ACTIVE(vfap, f_bfree)) {
                VFSATTR_RETURN(vfap, f_bfree, sp->f_bfree);
+       }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_bavail))
+       if (VFSATTR_IS_ACTIVE(vfap, f_bavail)) {
                VFSATTR_RETURN(vfap, f_bavail, sp->f_bavail);
+       }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_bused))
+       if (VFSATTR_IS_ACTIVE(vfap, f_bused)) {
                VFSATTR_RETURN(vfap, f_bused, sp->f_bused);
+       }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_files))
+       if (VFSATTR_IS_ACTIVE(vfap, f_files)) {
                VFSATTR_RETURN(vfap, f_files, sp->f_files);
+       }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_ffree))
+       if (VFSATTR_IS_ACTIVE(vfap, f_ffree)) {
                VFSATTR_RETURN(vfap, f_ffree, sp->f_ffree);
+       }
 
-       if (VFSATTR_IS_ACTIVE(vfap, f_fssubtype))
+       if (VFSATTR_IS_ACTIVE(vfap, f_fssubtype)) {
                VFSATTR_RETURN(vfap, f_fssubtype, 0);
+       }
 
        if (VFSATTR_IS_ACTIVE(vfap, f_capabilities)) {
                memcpy(&vfap->f_capabilities, &capabilities, sizeof(vol_capabilities_attr_t));
@@ -525,7 +537,7 @@ nullfs_sync(__unused struct mount * mp, __unused int waitfor, __unused vfs_conte
        /*
         * XXX - Assumes no data cached at null layer.
         */
-       return (0);
+       return 0;
 }
 
 
@@ -537,21 +549,20 @@ nullfs_vfs_start(__unused struct mount * mp, __unused int flags, __unused vfs_co
        return 0;
 }
 
-extern struct vnodeopv_desc nullfs_vnodeop_opv_desc;
+extern const struct vnodeopv_desc nullfs_vnodeop_opv_desc;
 
-struct vnodeopv_desc * nullfs_vnodeopv_descs[] = {
-    &nullfs_vnodeop_opv_desc,
+const struct vnodeopv_desc * nullfs_vnodeopv_descs[] = {
+       &nullfs_vnodeop_opv_desc,
 };
 
 struct vfsops nullfs_vfsops = {
-    .vfs_mount              = nullfs_mount,
-    .vfs_unmount            = nullfs_unmount,
-    .vfs_start              = nullfs_vfs_start,
-    .vfs_root               = nullfs_root,
-    .vfs_getattr            = nullfs_vfs_getattr,
-    .vfs_sync               = nullfs_sync,
-    .vfs_init               = nullfs_init,
-    .vfs_sysctl             = NULL,
-    .vfs_setattr            = NULL,
+       .vfs_mount              = nullfs_mount,
+       .vfs_unmount            = nullfs_unmount,
+       .vfs_start              = nullfs_vfs_start,
+       .vfs_root               = nullfs_root,
+       .vfs_getattr            = nullfs_vfs_getattr,
+       .vfs_sync               = nullfs_sync,
+       .vfs_init               = nullfs_init,
+       .vfs_sysctl             = NULL,
+       .vfs_setattr            = NULL,
 };
-