]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/miscfs/nullfs/null_vnops.c
xnu-4903.221.2.tar.gz
[apple/xnu.git] / bsd / miscfs / nullfs / null_vnops.c
index 389adb7e4b3b34a12a76560c998ab92b5ac8e13f..05e28abc112c429cac00d090d135cb873089b039 100644 (file)
@@ -1035,3 +1035,36 @@ static struct vnodeopv_entry_desc nullfs_vnodeop_entries[] = {
 };
 
 struct vnodeopv_desc nullfs_vnodeop_opv_desc = {&nullfs_vnodeop_p, nullfs_vnodeop_entries};
+
+//NULLFS Specific helper function
+
+int
+nullfs_getbackingvnode(vnode_t in_vp, vnode_t* out_vpp)
+{
+       int result = EINVAL;
+
+       if (out_vpp == NULL || in_vp == NULL) {
+               goto end;
+       }
+
+       struct vfsstatfs * sp   = NULL;
+       mount_t mp = vnode_mount(in_vp);
+
+       sp = vfs_statfs(mp);
+       //If this isn't a nullfs vnode or it is but it's a special vnode
+       if (strcmp(sp->f_fstypename, "nullfs") != 0 || nullfs_checkspecialvp(in_vp)) {
+               *out_vpp = NULLVP;
+               result = ENOENT;
+               goto end;
+       }
+
+       vnode_t lvp = NULLVPTOLOWERVP(in_vp);
+       if ((result = vnode_getwithvid(lvp, NULLVPTOLOWERVID(in_vp)))) {
+               goto end;
+       }
+
+       *out_vpp = lvp;
+
+end:
+       return result;
+}