Lines Matching defs:vp

149 static int setutimes(vfs_context_t ctx, vnode_t vp, const struct timespec *ts, int nullflag);
159 static int mount_common(char *fstypename, vnode_t pvp, vnode_t vp,
165 int prepare_coveredvp(vnode_t vp, vfs_context_t ctx, struct componentname *cnp, const char *fsname, boolean_t skip_auth);
175 static int place_mount_and_checkdirs(mount_t mp, vnode_t vp, vfs_context_t ctx);
176 static void undo_place_on_covered_vp(mount_t mp, vnode_t vp);
179 static int relocate_imageboot_source(vnode_t pvp, vnode_t vp, struct componentname *cnp, const char *fsname, vfs_context_t ctx, boolean_t is64bit, user_addr_t fsmountargs, boolean_t by_index);
233 kernel_mount(char *fstype, vnode_t pvp, vnode_t vp, const char *path,
246 if (vp == NULLVP) {
250 vp = nd.ni_vp;
261 error = mount_common(fstype, pvp, vp, &nd.ni_cnd, CAST_USER_ADDR_T(data),
265 vnode_put(vp);
323 vnode_t vp = NULL;
354 vp = nd.ni_vp;
360 error = relocate_imageboot_source(pvp, vp, &nd.ni_cnd, fstypename,
403 if ((vp->v_flag & VROOT) &&
404 (vp->v_mount->mnt_flag & MNT_ROOTFS)) {
440 error = mount_common(fstypename, pvp, vp, &nd.ni_cnd, uap->data, flags, 0,
450 if (vp) {
451 vnode_put(vp);
469 * vp covered vnode
478 mount_common(char *fstypename, vnode_t pvp, vnode_t vp,
506 if ((vp->v_flag & VROOT) == 0) {
510 mp = vp->v_mount;
589 if (vp->v_mount->mnt_flag & MNT_NOEXEC)
616 error = prepare_coveredvp(vp, ctx, cnp, fstypename, ((internal_flags & KERNEL_MOUNT_NOAUTH) != 0));
654 mp->mnt_vnodecovered = vp;
884 vnode_lock_spin(vp);
885 CLR(vp->v_flag, VMOUNT);
886 vp->v_mountedhere = mp;
887 vnode_unlock(vp);
893 * vp->v_mountedhere->mnt_realrootvp
901 error = vnode_ref(vp);
908 error = checkdirs(vp, ctx);
987 vnode_lock_spin(vp);
988 CLR(vp->v_flag, VMOUNT);
989 vnode_unlock(vp);
1015 * drop I/O count on the device vp if there was one
1027 * If the mount has been placed on the covered vp,
1042 vnode_lock_spin(vp);
1045 vp->v_mountedhere = (mount_t) 0;
1047 vnode_unlock(vp);
1050 vnode_rele(vp);
1066 mount_dropcrossref(mp, vp, 0);
1089 prepare_coveredvp(vnode_t vp, vfs_context_t ctx, struct componentname *cnp, const char *fsname, boolean_t skip_auth)
1104 if ((error = vnode_getattr(vp, &va, ctx)) ||
1112 if ( (error = VNOP_FSYNC(vp, MNT_WAIT, ctx)) )
1115 if ( (error = buf_invalidateblks(vp, BUF_WRITE_DATA, 0, 0)) )
1118 if (vp->v_type != VDIR) {
1123 if (ISSET(vp->v_flag, VMOUNT) && (vp->v_mountedhere != NULL)) {
1129 error = mac_mount_check_mount(ctx, vp,
1135 vnode_lock_spin(vp);
1136 SET(vp->v_flag, VMOUNT);
1137 vnode_unlock(vp);
1155 vnode_t vp, realdevvp;
1165 vp = nd.ni_vp;
1167 if (!vnode_isblk(vp)) {
1186 if (vnode_specrdev(vp) != vnode_specrdev(realdevvp)) {
1202 if ((error = vnode_authorize(vp, NULL, accessmode, ctx)) != 0) {
1208 *devvpp = vp;
1215 vnode_put(vp);
1226 place_mount_and_checkdirs(mount_t mp, vnode_t vp, vfs_context_t ctx)
1230 mp->mnt_vnodecovered = vp; /* XXX This is normally only set at init-time ... */
1232 vnode_lock_spin(vp);
1233 CLR(vp->v_flag, VMOUNT);
1234 vp->v_mountedhere = mp;
1235 vnode_unlock(vp);
1241 * vp->v_mountedhere->mnt_realrootvp
1249 error = vnode_ref(vp);
1254 error = checkdirs(vp, ctx);
1257 vnode_rele(vp);
1269 undo_place_on_covered_vp(mount_t mp, vnode_t vp)
1271 vnode_rele(vp);
1272 vnode_lock_spin(vp);
1273 vp->v_mountedhere = (mount_t)NULL;
1274 vnode_unlock(vp);
1336 vnode_t vp;
1342 vp = imgsrc_rootvnodes[height];
1343 if ((vp != NULLVP) && (vnode_get(vp) == 0)) {
1344 *rvpp = vp;
1352 relocate_imageboot_source(vnode_t pvp, vnode_t vp, struct componentname *cnp,
1471 error = prepare_coveredvp(vp, ctx, cnp, fsname, FALSE);
1477 IMGSRC_DEBUG("Covered vp OK.\n");
1508 error = place_mount_and_checkdirs(mp, vp, ctx);
1553 /* Rele the vp, clear VMOUNT and v_mountedhere */
1554 undo_place_on_covered_vp(mp, vp);
1556 vnode_lock_spin(vp);
1557 CLR(vp->v_flag, VMOUNT);
1558 vnode_unlock(vp);
1685 /* do not block for exec/fork trans as the vp in cwd & rootdir are not changing */
1709 vnode_t vp;
1720 vp = nd.ni_vp;
1721 mp = vp->v_mount;
1727 vnode_put(vp);
1734 if ((vp->v_flag & VROOT) == 0) {
1735 vnode_put(vp);
1739 vnode_put(vp);
1881 * vp->v_mountedhere->mnt_realrootvp
1957 /* mark the mount point hook in the vp but not drop the ref yet */
2096 vnode_t vp;
2119 vp = smp->mnt_vnodecovered;
2120 if (vp == NULL)
2122 fsid = vnode_mount(vp)->mnt_vfsstat.f_fsid; // Underlying fsid
2396 vnode_t vp;
2403 vp = nd.ni_vp;
2404 mp = vp->v_mount;
2410 vnode_put(vp);
2415 vnode_put(vp);
2426 vnode_t vp;
2433 if ( (error = file_vnode(uap->fd, &vp)) )
2436 error = vnode_getwithref(vp);
2442 AUDIT_ARG(vnpath_withref, vp, ARG_VNODE1);
2444 mp = vp->v_mount;
2458 vnode_put(vp);
2510 vnode_t vp;
2517 vp = nd.ni_vp;
2518 mp = vp->v_mount;
2524 vnode_put(vp);
2529 vnode_put(vp);
2540 struct vnode *vp;
2547 if ( (error = file_vnode(uap->fd, &vp)) )
2550 error = vnode_getwithref(vp);
2556 AUDIT_ARG(vnpath_withref, vp, ARG_VNODE1);
2558 mp = vp->v_mount;
2572 vnode_put(vp);
2844 vnode_t vp;
2850 error = fp_getfvp(p, fd, &fp, &vp);
2854 error = vnode_getwithref(vp);
2861 *vpp = vp;
2923 vnode_t vp;
2951 if ( (error = file_vnode(uap->fd, &vp)) )
2953 if ( (error = vnode_getwithref(vp)) ) {
2958 AUDIT_ARG(vnpath, vp, ARG_VNODE1);
2960 if (vp->v_type != VDIR) {
2966 error = mac_vnode_check_chdir(ctx, vp);
2970 error = vnode_authorize(vp, NULL, KAUTH_VNODE_SEARCH, ctx);
2974 while (!error && (mp = vp->v_mountedhere) != NULL) {
2983 vnode_put(vp);
2984 vp = tdp;
2988 if ( (error = vnode_ref(vp)) )
2990 vnode_put(vp);
2997 uth->uu_cdir = vp;
3000 vnode_rele(vp);
3006 fdp->fd_cdir = vp;
3016 vnode_put(vp);
3198 vnode_t vp;
3204 vp = ndp->ni_vp;
3206 if (vp->v_type != VDIR) {
3207 vnode_put(vp);
3212 error = mac_vnode_check_chdir(ctx, vp);
3214 vnode_put(vp);
3219 error = vnode_authorize(vp, NULL, KAUTH_VNODE_SEARCH, ctx);
3221 vnode_put(vp);
3282 vnode_t vp;
3353 vp = ndp->ni_vp;
3357 fp->f_fglob->fg_data = (caddr_t)vp;
3384 if ((error = VNOP_ADVLOCK(vp, (caddr_t)fp->f_fglob, F_SETLK, &lf, type, ctx, NULL)))
3390 if ((flags & O_TRUNC) && ((error = vnode_setsize(vp, (off_t)0, 0, ctx)) != 0))
3406 * want to set the vp of the tty into the session structure. We have
3407 * a race here because we can't get to the vp for the tp in ttyopen,
3415 sessp->s_ttyvp = vp;
3416 sessp->s_ttyvid = vnode_vid(vp);
3423 if (vnode_vtype(vp) == VDIR) {
3429 vnode_put(vp);
3465 vp, (caddr_t)fp->f_fglob, F_UNLCK, &lf, F_FLOCK, ctx, NULL);
3468 vn_close(vp, fp->f_fglob->fg_flag, &context);
3469 vnode_put(vp);
3778 vnode_t vp, dvp;
3799 vp = nd.ni_vp;
3801 if (vp != NULL) {
3831 if ((error = vn_create(dvp, &vp, &nd, &va, 0, 0, NULL, ctx)) != 0)
3834 if (vp) {
3838 if (vp->v_name == NULL)
3840 if (vp->v_parent == NULLVP)
3844 vnode_update_identity(vp, dvp, nd.ni_cnd.cn_nameptr, nd.ni_cnd.cn_namelen, nd.ni_cnd.cn_hash, update_flags);
3848 FSE_ARG_VNODE, vp,
3860 if (vp)
3861 vnode_put(vp);
3879 vnode_t vp, dvp;
3889 vp = nd.ni_vp;
3892 if (vp != NULL) {
3901 error = vn_create(dvp, &vp, &nd, vap, 0, 0, NULL, ctx);
3909 if (vp)
3910 vnode_put(vp);
4027 printf("safe_getpath: failed to get the path for vp %p (%s) : err %d\n",
4074 vnode_t vp, dvp, lvp;
4085 vp = dvp = lvp = NULLVP;
4095 vp = nd.ni_vp;
4103 if (vp->v_type == VDIR) {
4104 if (!(vp->v_mount->mnt_vtable->vfc_vfsflags & VFC_VFSDIRLINKS)) {
4114 if (vnode_getattr(vp, &dva, ctx) != 0 ||
4137 if ((error = mac_vnode_check_link(ctx, dvp, vp, &nd.ni_cnd)) != 0)
4142 if ((error = vnode_authorize(vp, NULL, KAUTH_VNODE_LINKTARGET, ctx)) != 0)
4151 if (vnode_mount(vp) != vnode_mount(dvp)) {
4161 error = VNOP_LINK(vp, dvp, &nd.ni_cnd, ctx);
4166 (void)mac_vnode_notify_link(ctx, vp, dvp, &nd.ni_cnd);
4198 if (vn_getpath(vp, link_to_path, &link_name_len) == 0) {
4214 if (get_fse_info(vp, &finfo, ctx) == 0) {
4225 if (vp->v_parent) {
4227 FSE_ARG_VNODE, vp->v_parent,
4247 vnode_put(vp);
4282 vnode_t vp, dvp;
4305 vp = nd.ni_vp;
4329 if (vp != NULL) {
4341 error = VNOP_SYMLINK(dvp, &vp, &nd.ni_cnd, &va, path, ctx);
4345 error = vnode_label(vnode_mount(vp), dvp, vp, &nd.ni_cnd, VNODE_LABEL_CREATE, ctx);
4350 error = vnode_setattr_fallback(vp, &va, ctx);
4355 if (vp == NULL) {
4362 vp = nd.ni_vp;
4364 if (vp == NULL)
4393 if (vp->v_name == NULL)
4395 if (vp->v_parent == NULLVP)
4399 vnode_update_identity(vp, dvp, nd.ni_cnd.cn_nameptr, nd.ni_cnd.cn_namelen, nd.ni_cnd.cn_hash, update_flags);
4403 FSE_ARG_VNODE, vp,
4415 if (vp)
4416 vnode_put(vp);
4457 vnode_t vp, dvp;
4488 vp = ndp->ni_vp;
4501 if (vp) {
4502 batched = vnode_compound_remove_available(vp);
4506 if (vp->v_flag & VROOT) {
4511 error = vn_authorize_unlink(dvp, vp, cnp, ctx, NULL);
4520 panic("No vp, but no compound remove?");
4528 if ((vp->v_flag & VISHARDLINK) == 0) {
4530 get_fse_info(vp, &finfo, ctx);
4556 error = vnode_removenamedstream(dvp, vp, XATTR_RESOURCEFORK_NAME, 0, ctx);
4561 vp = ndp->ni_vp;
4571 if (vnode_isdir(vp)) {
4587 (uintptr_t)vp,
4591 if (vp->v_flag & VISHARDLINK) {
4599 vnode_update_identity(vp, NULL, NULL, 0, 0, VNODE_UPDATE_PARENT);
4604 if (vp->v_flag & VISHARDLINK) {
4605 get_fse_info(vp, &finfo, ctx);
4607 vnode_get_fse_info_from_vap(vp, &finfo, vap);
4628 if (vp && (vnode_isnamedstream(vp)) &&
4629 (vp->v_parent != NULLVP) &&
4630 vnode_isshadow(vp)) {
4631 vnode_recycle(vp);
4640 if (vp) {
4641 vnode_put(vp);
4708 vnode_t vp;
4713 if ( (error = fp_getfvp(p,uap->fd, &fp, &vp)) ) {
4718 if (vnode_isfifo(vp)) {
4737 if ( (error = vnode_getwithref(vp)) ) {
4747 if ((error = vnode_size(vp, &file_size, ctx)) != 0)
4766 if (offset < 0 && vp->v_type != VCHR) {
4781 post_event_if_success(vp, error, NOTE_NONE);
4782 (void)vnode_put(vp);
4795 access1(vnode_t vp, vnode_t dvp, int uflags, vfs_context_t ctx)
4809 if (vnode_isdir(vp)) {
4818 if (vnode_isdir(vp)) {
4830 error = mac_vnode_check_access(ctx, vp, uflags);
4837 error = vnode_authorize(vp, dvp, action | KAUTH_VNODE_ACCESS, ctx);
4907 vnode_t vp = NULL;
5038 if (vp) {
5039 vnode_put(vp);
5040 vp = NULL;
5071 vp = nd.ni_vp;
5090 result[i] = access1(vp, dvp, input[i].ad_flags, &context);
5109 if (vp)
5110 vnode_put(vp);
5565 vnode_t vp;
5577 vp = nd.ni_vp;
5584 if (vp->v_type != VLNK) {
5588 error = mac_vnode_check_readlink(ctx, vp);
5591 error = vnode_authorize(vp, NULL, KAUTH_VNODE_READ_DATA,
5594 error = VNOP_READLINK(vp, auio, ctx);
5596 vnode_put(vp);
5627 chflags1(vnode_t vp, int flags, vfs_context_t ctx)
5637 error = mac_vnode_check_setflags(ctx, vp, flags);
5643 if ((error = vnode_authattr(vp, &va, &action, ctx)) != 0)
5650 if (action && ((error = vnode_authorize(vp, NULL, action | KAUTH_VNODE_NOIMMUTABLE, ctx)) != 0))
5652 error = vnode_setattr(vp, &va, ctx);
5658 vnode_put(vp);
5669 vnode_t vp;
5680 vp = nd.ni_vp;
5683 error = chflags1(vp, uap->flags, ctx);
5695 vnode_t vp;
5700 if ( (error = file_vnode(uap->fd, &vp)) )
5703 if ((error = vnode_getwithref(vp))) {
5708 AUDIT_ARG(vnpath, vp, ARG_VNODE1);
5710 error = chflags1(vp, uap->flags, vfs_context_current());
5729 chmod_vnode(vfs_context_t ctx, vnode_t vp, struct vnode_attr *vap)
5739 if (vp->v_flag & VISNAMEDSTREAM) {
5746 (error = mac_vnode_check_setmode(ctx, vp, (mode_t)vap->va_mode)) != 0)
5751 if (((error = vnode_authattr(vp, vap, &action, ctx)) != 0) ||
5752 ((error = vnode_authorize(vp, NULL, action, ctx)) != 0)) {
5758 error = vnode_setattr(vp, vap, ctx);
5891 vnode_t vp;
5896 if ((error = file_vnode(fd, &vp)) != 0)
5898 if ((error = vnode_getwithref(vp)) != 0) {
5902 AUDIT_ARG(vnpath, vp, ARG_VNODE1);
5904 error = chmod_vnode(vfs_context_current(), vp, vap);
5905 (void)vnode_put(vp);
5997 vnode_t vp;
6012 vp = nd.ni_vp;
6023 error = mac_vnode_check_setowner(ctx, vp, uid, gid);
6029 if ((error = vnode_authattr(vp, &va, &action, ctx)) != 0)
6031 if (action && ((error = vnode_authorize(vp, NULL, action, ctx)) != 0))
6033 error = vnode_setattr(vp, &va, ctx);
6043 vnode_put(vp);
6080 vnode_t vp;
6087 if ( (error = file_vnode(uap->fd, &vp)) )
6090 if ( (error = vnode_getwithref(vp)) ) {
6094 AUDIT_ARG(vnpath, vp, ARG_VNODE1);
6104 if (vp->v_flag & VISNAMEDSTREAM) {
6111 error = mac_vnode_check_setowner(ctx, vp, uap->uid, uap->gid);
6117 if ((error = vnode_authattr(vp, &va, &action, ctx)) != 0)
6119 if (action && ((error = vnode_authorize(vp, NULL, action, ctx)) != 0)) {
6124 error = vnode_setattr(vp, &va, ctx);
6127 (void)vnode_put(vp);
6164 setutimes(vfs_context_t ctx, vnode_t vp, const struct timespec *ts,
6171 AUDIT_ARG(vnpath, vp, ARG_VNODE1);
6181 if (vp->v_flag & VISNAMEDSTREAM) {
6188 error = mac_vnode_check_setutimes(ctx, vp, ts[0], ts[1]);
6192 if ((error = vnode_authattr(vp, &va, &action, ctx)) != 0) {
6199 if ((action != 0) && ((error = vnode_authorize(vp, NULL, action, ctx)) != 0)) {
6204 error = vnode_setattr(vp, &va, ctx);
6257 vnode_t vp;
6265 if ((error = file_vnode(uap->fd, &vp)) != 0)
6267 if((error = vnode_getwithref(vp))) {
6272 error = setutimes(vfs_context_current(), vp, ts, usrtvp == 0);
6273 vnode_put(vp);
6285 vnode_t vp;
6298 vp = nd.ni_vp;
6306 error = mac_vnode_check_truncate(ctx, NOCRED, vp);
6311 if ((error = vnode_authattr(vp, &va, &action, ctx)) != 0)
6313 if ((action != 0) && ((error = vnode_authorize(vp, NULL, action, ctx)) != 0))
6315 error = vnode_setattr(vp, &va, ctx);
6317 vnode_put(vp);
6330 vnode_t vp;
6354 vp = (vnode_t)fp->f_fglob->fg_data;
6357 AUDIT_ARG(vnpath_withref, vp, ARG_VNODE1);
6362 if ((error = vnode_getwithref(vp)) != 0) {
6366 AUDIT_ARG(vnpath, vp, ARG_VNODE1);
6370 fp->f_fglob->fg_cred, vp);
6372 (void)vnode_put(vp);
6378 error = vnode_setattr(vp, &va, ctx);
6379 (void)vnode_put(vp);
6452 vnode_t vp;
6459 if ( (error = fp_getfvp(p, uap->fd, &fp, &vp)) )
6461 if ( (error = vnode_getwithref(vp)) ) {
6466 AUDIT_ARG(vnpath, vp, ARG_VNODE1);
6468 error = VNOP_FSYNC(vp, flags, ctx);
6473 (vp->v_flag & VISNAMEDSTREAM) &&
6474 (vp->v_parent != NULLVP) &&
6475 vnode_isshadow(vp) &&
6477 (void) vnode_flushnamedstream(vp->v_parent, vp, ctx);
6481 (void)vnode_put(vp);
7138 vnode_t vp, dvp;
7155 vp = nd.ni_vp;
7157 if (vp != NULL) {
7191 vp = nd.ni_vp;
7203 if ((error = vn_create(dvp, &vp, &nd, vap, 0, 0, NULL, ctx)) != 0) {
7205 nd.ni_vp = vp;
7213 if (vp->v_name == NULL)
7215 if (vp->v_parent == NULLVP)
7219 vnode_update_identity(vp, dvp, nd.ni_cnd.cn_nameptr, nd.ni_cnd.cn_namelen, nd.ni_cnd.cn_hash, update_flags);
7222 add_fsevent(FSE_CREATE_DIR, ctx, FSE_ARG_VNODE, vp, FSE_ARG_DONE);
7232 if (vp)
7233 vnode_put(vp);
7309 vnode_t vp, dvp;
7343 vp = nd.ni_vp;
7345 if (vp) {
7346 batched = vnode_compound_rmdir_available(vp);
7348 if (vp->v_flag & VROOT) {
7357 * Removed a check here; we used to abort if vp's vid
7364 * vp here.
7368 error = vn_authorize_rmdir(dvp, vp, &nd.ni_cnd, ctx, NULL);
7387 get_fse_info(vp, &finfo, ctx);
7416 error = vn_rmdir(dvp, &vp, &nd, vap, ctx);
7417 nd.ni_vp = vp;
7418 if (vp == NULLVP) {
7434 error = rmdir_remove_orphaned_appleDouble(vp, ctx, &restart_flag);
7444 error = vn_rmdir(dvp, &vp, &nd, vap, ctx);
7455 (uintptr_t)vp,
7459 if (vp->v_flag & VISHARDLINK) {
7462 vnode_update_identity(vp, NULL, NULL, 0, 0, VNODE_UPDATE_PARENT);
7468 vnode_get_fse_info_from_vap(vp, &finfo, vap);
7490 if (vp)
7491 vnode_put(vp);
7494 wakeup_one((caddr_t)vp);
7497 tsleep(vp, PVFS, "rm AD", 1);
7521 vnode_readdir64(struct vnode *vp, struct uio *uio, int flags, int *eofflag,
7525 if ((vp->v_mount->mnt_vtable->vfc_vfsflags & VFC_VFSREADDIR_EXTENDED) &&
7526 ((vp->v_mount->mnt_kern_flag & MNTK_DENY_READDIREXT) == 0)) {
7527 return VNOP_READDIR(vp, uio, flags, eofflag, numdirent, ctxp);
7560 error = VNOP_READDIR(vp, auio, 0, eofflag, numdirent, ctxp);
7609 vnode_t vp;
7618 error = fp_getfvp(vfs_context_proc(&context), fd, &fp, &vp);
7623 AUDIT_ARG(vnpath_withref, vp, ARG_VNODE1);
7636 if ( (error = vnode_getwithref(vp)) ) {
7639 AUDIT_ARG(vnpath, vp, ARG_VNODE1);
7642 if (vp->v_type != VDIR) {
7643 (void)vnode_put(vp);
7649 error = mac_vnode_check_readdir(&context, vp);
7651 (void)vnode_put(vp);
7661 error = vnode_readdir64(vp, auio, flags, &eofflag, &numdirent, &context);
7664 error = VNOP_READDIR(vp, auio, 0, &eofflag, &numdirent, &context);
7668 (void)vnode_put(vp);
7674 error = union_dircheckp(&vp, fp, &context);
7681 if ((vp->v_mount->mnt_flag & MNT_UNION)) {
7682 struct vnode *tvp = vp;
7683 if (lookup_traverse_union(tvp, &vp, &context) == 0) {
7684 vnode_ref(vp);
7685 fp->f_fglob->fg_data = (caddr_t) vp;
7691 vp = tvp;
7695 vnode_put(vp);
7816 vnode_t vp;
7827 vp = nd.ni_vp;
7831 if (!(vnode_ischr(vp) || vnode_isblk(vp))) {
7836 if (vnode_isblk(vp) && vnode_ismountedon(vp)) {
7842 error = mac_vnode_check_revoke(ctx, vp);
7849 if ((error = vnode_getattr(vp, &va, ctx)))
7854 if (vp->v_usecount > 0 || (vnode_isaliased(vp)))
7855 VNOP_REVOKE(vp, REVOKEALL, ctx);
7857 vnode_put(vp);
7877 vnode_t vp;
7901 if ( (error = fp_getfvp(p, fd, &fp, &vp)) ) {
7905 AUDIT_ARG(vnpath_withref, vp, ARG_VNODE1);
7919 if ( (error = vnode_getwithref(vp)) )
7922 AUDIT_ARG(vnpath, vp, ARG_VNODE1);
7925 if (vp->v_type != VDIR) {
7926 (void)vnode_put(vp);
7932 error = mac_vnode_check_readdir(ctx, vp);
7934 (void)vnode_put(vp);
7954 if ((error = vnode_authorize(vp, NULL, action, ctx)) == 0) {
7959 error = VNOP_READDIRATTR(vp, &attributelist, auio, count,
7964 (void) vnode_put(vp);
7975 if (eofflag && vp->v_mount->mnt_flag & MNT_UNION) {
7979 struct vnode *tvp = vp;
7980 if (lookup_traverse_union(tvp, &vp, ctx) == 0) {
7981 vnode_ref_ext(vp, fp->f_fglob->fg_flag & O_EVTONLY, 0);
7982 fp->f_fglob->fg_data = (caddr_t) vp;
7989 vp = tvp;
7993 (void)vnode_put(vp);
8171 uint32_t freespace_mb(vnode_t vp);
8174 freespace_mb(vnode_t vp)
8176 vfs_update_vfsstat(vp->v_mount, vfs_context_current(), VFS_USER_EVENT);
8177 return (((uint64_t)vp->v_mount->mnt_vfsstat.f_bavail *
8178 vp->v_mount->mnt_vfsstat.f_bsize) >> 20);
8188 vnode_t vp, tvp;
8344 vp = nd.ni_vp;
8350 error = VFS_ROOT(vnode_mount(vp), &tvp, ctx);
8351 vnode_put(vp);
8354 vp = tvp;
8363 if ((vp->v_mount->mnt_flag & MNT_UNION) == 0)
8365 tvp = vp;
8366 vp = vp->v_mount->mnt_vnodecovered;
8367 if (vp == NULL) {
8372 vnode_getwithref(vp);
8377 error = mac_vnode_check_searchfs(ctx, vp, &searchblock.searchattrs);
8379 vnode_put(vp);
8402 fserror = VNOP_SEARCHFS(vp,
8420 if ((vp->v_mount->mnt_flag & MNT_UNION) && fserror == 0) {
8428 vnode_put(vp);
8474 struct vnode *vp;
8524 static int vn_open_with_vp(vnode_t vp, int fmode, vfs_context_t ctx);
8634 if (nspace_items[i].vp && (nspace_items[i].vp->v_flag & VNEEDSSNAPSHOT)) {
8635 vnode_lock_spin(nspace_items[i].vp);
8636 nspace_items[i].vp->v_flag &= ~VNEEDSSNAPSHOT;
8637 vnode_unlock(nspace_items[i].vp);
8639 nspace_items[i].vp = NULL;
8644 wakeup((caddr_t)&(nspace_items[i].vp));
8655 resolve_nspace_item(struct vnode *vp, uint64_t op)
8657 return resolve_nspace_item_ext(vp, op, NULL);
8661 resolve_nspace_item_ext(struct vnode *vp, uint64_t op, void *arg)
8668 if (vp->v_type != VREG && vp->v_type != VDIR && vp->v_type != VLNK) {
8684 && (vp->v_mount != NULL)
8685 && (vp->v_mount->mnt_kern_flag & MNTK_VIRTUALDEV)
8704 if (vp == nspace_items[i].vp && op == nspace_items[i].op) {
8738 if (vp != nspace_items[i].vp) {
8739 nspace_items[i].vp = vp;
8742 nspace_items[i].vid = vnode_vid(vp);
8747 vnode_lock_spin(vp);
8748 vp->v_flag |= VNEEDSSNAPSHOT;
8749 vnode_unlock(vp);
8767 error = msleep((caddr_t)&(nspace_items[i].vp), &nspace_handler_lock, PVFS|PCATCH, "namespace-done", &ts);
8787 nspace_items[i].vp = NULL; // clear this so that no one will match on it again
8803 get_nspace_item_status(struct vnode *vp, int32_t *status)
8809 if (nspace_items[i].vp == vp) {
8827 build_volfs_path(struct vnode *vp, char *path, int *len)
8836 if (vnode_getattr(vp, &va, vfs_context_kernel()) != 0) {
8856 vn_open_with_vp(vnode_t vp, int fmode, vfs_context_t ctx)
8865 error = mac_vnode_check_open(ctx, vp, fmode);
8889 if ((error = vnode_authorize(vp, NULL, action, ctx)) != 0)
8902 if ((vp->v_flag & VOPENEVT) && (current_proc()->p_flag & P_CHECKOPENEVT)) {
8906 if ( (error = VNOP_OPEN(vp, fmode, ctx)) ) {
8909 if ( (error = vnode_ref_ext(vp, fmode, 0)) ) {
8910 VNOP_CLOSE(vp, fmode, ctx);
8918 mac_vnode_notify_open(ctx, vp, fmode);
8921 (uintptr_t)vp, 0);
8973 if (nspace_items[i].vp) {
8986 error = vnode_getwithvid(nspace_items[i].vp, nspace_items[i].vid);
8991 error = vn_open_with_vp(nspace_items[i].vp, fmode, ctx);
8994 vnode_put(nspace_items[i].vp);
8999 vn_close(nspace_items[i].vp, fmode, ctx);
9000 vnode_put(nspace_items[i].vp);
9007 fp->f_fglob->fg_data = (caddr_t)nspace_items[i].vp;
9047 error = vnode_getattr(nspace_items[i].vp, &va, ctx);
9058 vn_close(nspace_items[i].vp, fmode, ctx);
9063 vnode_put(nspace_items[i].vp);
9068 i, nspace_items[i].vp, error, nspace_items[i].vp->v_name);
9082 if (nspace_items[i].vp && (nspace_items[i].vp->v_flag & VNEEDSSNAPSHOT)) {
9083 vnode_lock_spin(nspace_items[i].vp);
9084 nspace_items[i].vp->v_flag &= ~VNEEDSSNAPSHOT;
9085 vnode_unlock(nspace_items[i].vp);
9087 nspace_items[i].vp = NULL;
9092 wakeup((caddr_t)&(nspace_items[i].vp));
9101 nspace_items[i].vp = NULL;
9106 wakeup((caddr_t)&(nspace_items[i].vp));
9230 vnode_t vp = *arg_vp;
9281 mount_t mp = vp->v_mount;
9284 /* record vid of vp so we can drop it below. */
9285 uint32_t vvid = vp->v_id;
9290 * get into a deadlock because we've never released the root vp
9296 vnode_put(vp);
9308 /* re-obtain vnode iocount on the root vp, if possible */
9309 error = vnode_getwithvid (vp, vvid);
9311 error = VNOP_IOCTL(vp, F_FULLFSYNC, (caddr_t)NULL, 0, ctx);
9312 vnode_put (vp);
9435 if (val == 0 && nspace_items[i].vp) {
9436 vnode_lock_spin(nspace_items[i].vp);
9437 nspace_items[i].vp->v_flag &= ~VNEEDSSNAPSHOT;
9438 vnode_unlock(nspace_items[i].vp);
9441 nspace_items[i].vp = NULL;
9448 wakeup((caddr_t)&(nspace_items[i].vp));
9483 if (nspace_items[i].vp) {
9484 vnode_lock_spin(nspace_items[i].vp);
9485 nspace_items[i].vp->v_flag &= ~VNEEDSSNAPSHOT;
9486 vnode_unlock(nspace_items[i].vp);
9489 nspace_items[i].vp = NULL;
9496 wakeup((caddr_t)&(nspace_items[i].vp));
9540 if (vp->v_mount) {
9541 mount_lock(vp->v_mount);
9543 strlcpy(&vp->v_mount->fstypename_override[0], data, MFSTYPENAMELEN);
9544 vp->v_mount->mnt_kern_flag |= MNTK_TYPENAME_OVERRIDE;
9545 if (vfs_isrdonly(vp->v_mount) && strcmp(vp->v_mount->fstypename_override, "mtmfs") == 0) {
9546 vp->v_mount->mnt_kern_flag |= MNTK_EXTENDED_SECURITY;
9547 vp->v_mount->mnt_kern_flag &= ~MNTK_AUTH_OPAQUE;
9550 if (strcmp(vp->v_mount->fstypename_override, "mtmfs") == 0) {
9551 vp->v_mount->mnt_kern_flag &= ~MNTK_EXTENDED_SECURITY;
9553 vp->v_mount->mnt_kern_flag &= ~MNTK_TYPENAME_OVERRIDE;
9554 vp->v_mount->fstypename_override[0] = '\0';
9556 mount_unlock(vp->v_mount);
9563 error = VNOP_IOCTL(vp, IOCBASECMD(cmd), data, options, ctx);
9589 vnode_t vp = NULL;
9600 vp = nd.ni_vp;
9604 error = mac_mount_check_fsctl(ctx, vnode_mount(vp), uap->cmd);
9610 error = fsctl_internal(p, &vp, uap->cmd, (user_addr_t)uap->data, uap->options, ctx);
9613 if (vp)
9614 vnode_put(vp);
9622 vnode_t vp = NULL;
9631 if ((error = file_vnode(uap->fd, &vp)))
9634 if ((error = vnode_getwithref(vp))) {
9639 error = mac_mount_check_fsctl(ctx, vnode_mount(vp), uap->cmd);
9645 error = fsctl_internal(p, &vp, uap->cmd, (user_addr_t)uap->data, uap->options, ctx);
9651 if (vp)
9652 vnode_put(vp);
9663 vnode_t vp;
9683 vp = nd.ni_vp;
9728 error = vn_getxattr(vp, attrname, auio, &attrsize, uap->options, ctx);
9730 vnode_put(vp);
9747 vnode_t vp;
9759 if ( (error = file_vnode(uap->fd, &vp)) ) {
9762 if ( (error = vnode_getwithref(vp)) ) {
9779 error = vn_getxattr(vp, attrname, auio, &attrsize, uap->options, vfs_context_current());
9781 (void)vnode_put(vp);
9798 vnode_t vp;
9831 vp = nd.ni_vp;
9838 error = vn_setxattr(vp, attrname, auio, uap->options, ctx);
9842 FSE_ARG_VNODE, vp,
9846 vnode_put(vp);
9857 vnode_t vp;
9879 if ( (error = file_vnode(uap->fd, &vp)) ) {
9882 if ( (error = vnode_getwithref(vp)) ) {
9890 error = vn_setxattr(vp, attrname, auio, uap->options, vfs_context_current());
9894 FSE_ARG_VNODE, vp,
9898 vnode_put(vp);
9911 vnode_t vp;
9934 vp = nd.ni_vp;
9937 error = vn_removexattr(vp, attrname, uap->options, ctx);
9941 FSE_ARG_VNODE, vp,
9945 vnode_put(vp);
9957 vnode_t vp;
9974 if ( (error = file_vnode(uap->fd, &vp)) ) {
9977 if ( (error = vnode_getwithref(vp)) ) {
9982 error = vn_removexattr(vp, attrname, uap->options, vfs_context_current());
9986 FSE_ARG_VNODE, vp,
9990 vnode_put(vp);
10003 vnode_t vp;
10021 vp = nd.ni_vp;
10029 error = vn_listxattr(vp, auio, &attrsize, uap->options, ctx);
10031 vnode_put(vp);
10047 vnode_t vp;
10057 if ( (error = file_vnode(uap->fd, &vp)) ) {
10060 if ( (error = vnode_getwithref(vp)) ) {
10070 error = vn_listxattr(vp, auio, &attrsize, uap->options, vfs_context_current());
10072 vnode_put(vp);
10088 vnode_t vp;
10107 error = VFS_ROOT(mp, &vp, ctx);
10109 error = VFS_VGET(mp, (ino64_t)objid, &vp, ctx);
10132 error = mac_vnode_check_fsgetpath(ctx, vp);
10134 vnode_put(vp);
10142 error = build_path(vp, buf, bufsize, &length, bpflags, ctx);
10143 vnode_put(vp);
10166 kdebug_lookup_gen_events(dbg_parms, dbg_namelen, (void *)vp, TRUE);
10512 static int vnode_purge_callback(struct vnode *vp, __unused void *cargs)
10514 ubc_msync(vp, (off_t)0, ubc_getsize(vp), NULL /* off_t *resid_off */, UBC_PUSHALL | UBC_INVALIDATE);