1 /* $NetBSD: tmpfs_vnops.c,v 1.39 2007/07/23 15:41:01 jmmv Exp $ */
4 * SPDX-License-Identifier: BSD-2-Clause-NetBSD
6 * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Julio M. Merino Vidal, developed as part of Google's Summer of Code
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
36 * tmpfs vnode interface.
38 #include <sys/cdefs.h>
39 __FBSDID("$FreeBSD$");
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/dirent.h>
44 #include <sys/fcntl.h>
46 #include <sys/limits.h>
47 #include <sys/lockf.h>
49 #include <sys/mount.h>
50 #include <sys/namei.h>
53 #include <sys/rwlock.h>
54 #include <sys/sched.h>
56 #include <sys/sysctl.h>
57 #include <sys/unistd.h>
58 #include <sys/vnode.h>
60 #include <security/audit/audit.h>
61 #include <security/mac/mac_framework.h>
64 #include <vm/vm_param.h>
65 #include <vm/vm_object.h>
67 #include <fs/tmpfs/tmpfs_vnops.h>
68 #include <fs/tmpfs/tmpfs.h>
70 SYSCTL_DECL(_vfs_tmpfs);
73 static volatile int tmpfs_rename_restarts;
74 SYSCTL_INT(_vfs_tmpfs, OID_AUTO, rename_restarts, CTLFLAG_RD,
75 __DEVOLATILE(int *, &tmpfs_rename_restarts), 0,
76 "Times rename had to restart due to lock contention");
79 tmpfs_vn_get_ino_alloc(struct mount *mp, void *arg, int lkflags,
83 return (tmpfs_alloc_vp(mp, arg, lkflags, rvp));
87 tmpfs_lookup1(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
89 struct tmpfs_dirent *de;
90 struct tmpfs_node *dnode, *pnode;
91 struct tmpfs_mount *tm;
94 dnode = VP_TO_TMPFS_DIR(dvp);
97 /* Check accessibility of requested node as a first step. */
98 error = vn_dir_check_exec(dvp, cnp);
102 /* We cannot be requesting the parent directory of the root node. */
103 MPASS(IMPLIES(dnode->tn_type == VDIR &&
104 dnode->tn_dir.tn_parent == dnode,
105 !(cnp->cn_flags & ISDOTDOT)));
107 TMPFS_ASSERT_LOCKED(dnode);
108 if (dnode->tn_dir.tn_parent == NULL) {
112 if (cnp->cn_flags & ISDOTDOT) {
113 tm = VFS_TO_TMPFS(dvp->v_mount);
114 pnode = dnode->tn_dir.tn_parent;
115 tmpfs_ref_node(pnode);
116 error = vn_vget_ino_gen(dvp, tmpfs_vn_get_ino_alloc,
117 pnode, cnp->cn_lkflags, vpp);
118 tmpfs_free_node(tm, pnode);
121 } else if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
126 de = tmpfs_dir_lookup(dnode, NULL, cnp);
127 if (de != NULL && de->td_node == NULL)
128 cnp->cn_flags |= ISWHITEOUT;
129 if (de == NULL || de->td_node == NULL) {
131 * The entry was not found in the directory.
132 * This is OK if we are creating or renaming an
133 * entry and are working on the last component of
136 if ((cnp->cn_flags & ISLASTCN) &&
137 (cnp->cn_nameiop == CREATE || \
138 cnp->cn_nameiop == RENAME ||
139 (cnp->cn_nameiop == DELETE &&
140 cnp->cn_flags & DOWHITEOUT &&
141 cnp->cn_flags & ISWHITEOUT))) {
142 error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred,
148 * Keep the component name in the buffer for
151 cnp->cn_flags |= SAVENAME;
157 struct tmpfs_node *tnode;
160 * The entry was found, so get its associated
166 * If we are not at the last path component and
167 * found a non-directory or non-link entry (which
168 * may itself be pointing to a directory), raise
171 if ((tnode->tn_type != VDIR &&
172 tnode->tn_type != VLNK) &&
173 !(cnp->cn_flags & ISLASTCN)) {
179 * If we are deleting or renaming the entry, keep
180 * track of its tmpfs_dirent so that it can be
181 * easily deleted later.
183 if ((cnp->cn_flags & ISLASTCN) &&
184 (cnp->cn_nameiop == DELETE ||
185 cnp->cn_nameiop == RENAME)) {
186 error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred,
191 /* Allocate a new vnode on the matching entry. */
192 error = tmpfs_alloc_vp(dvp->v_mount, tnode,
193 cnp->cn_lkflags, vpp);
197 if ((dnode->tn_mode & S_ISTXT) &&
198 VOP_ACCESS(dvp, VADMIN, cnp->cn_cred,
199 cnp->cn_thread) && VOP_ACCESS(*vpp, VADMIN,
200 cnp->cn_cred, cnp->cn_thread)) {
206 cnp->cn_flags |= SAVENAME;
208 error = tmpfs_alloc_vp(dvp->v_mount, tnode,
209 cnp->cn_lkflags, vpp);
217 * Store the result of this lookup in the cache. Avoid this if the
218 * request was for creation, as it does not improve timings on
221 if ((cnp->cn_flags & MAKEENTRY) != 0 && tmpfs_use_nc(dvp))
222 cache_enter(dvp, *vpp, cnp);
226 * If there were no errors, *vpp cannot be null and it must be
229 MPASS(IFF(error == 0, *vpp != NULLVP && VOP_ISLOCKED(*vpp)));
235 tmpfs_cached_lookup(struct vop_cachedlookup_args *v)
238 return (tmpfs_lookup1(v->a_dvp, v->a_vpp, v->a_cnp));
242 tmpfs_lookup(struct vop_lookup_args *v)
245 return (tmpfs_lookup1(v->a_dvp, v->a_vpp, v->a_cnp));
249 tmpfs_create(struct vop_create_args *v)
251 struct vnode *dvp = v->a_dvp;
252 struct vnode **vpp = v->a_vpp;
253 struct componentname *cnp = v->a_cnp;
254 struct vattr *vap = v->a_vap;
257 MPASS(vap->va_type == VREG || vap->va_type == VSOCK);
259 error = tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL);
260 if (error == 0 && (cnp->cn_flags & MAKEENTRY) != 0 && tmpfs_use_nc(dvp))
261 cache_enter(dvp, *vpp, cnp);
266 tmpfs_mknod(struct vop_mknod_args *v)
268 struct vnode *dvp = v->a_dvp;
269 struct vnode **vpp = v->a_vpp;
270 struct componentname *cnp = v->a_cnp;
271 struct vattr *vap = v->a_vap;
273 if (vap->va_type != VBLK && vap->va_type != VCHR &&
274 vap->va_type != VFIFO)
277 return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL);
280 struct fileops tmpfs_fnops;
283 tmpfs_open(struct vop_open_args *v)
286 struct tmpfs_node *node;
292 node = VP_TO_TMPFS_NODE(vp);
295 * The file is still active but all its names have been removed
296 * (e.g. by a "rmdir $(pwd)"). It cannot be opened any more as
297 * it is about to die.
299 if (node->tn_links < 1)
302 /* If the file is marked append-only, deny write requests. */
303 if (node->tn_flags & APPEND && (mode & (FWRITE | O_APPEND)) == FWRITE)
307 /* For regular files, the call below is nop. */
308 KASSERT(vp->v_type != VREG || (node->tn_reg.tn_aobj->flags &
309 OBJ_DEAD) == 0, ("dead object"));
310 vnode_create_vobject(vp, node->tn_size, v->a_td);
314 if (error == 0 && fp != NULL && vp->v_type == VREG) {
315 tmpfs_ref_node(node);
316 finit_vnode(fp, mode, node, &tmpfs_fnops);
323 tmpfs_close(struct vop_close_args *v)
325 struct vnode *vp = v->a_vp;
327 /* Update node times. */
334 tmpfs_fo_close(struct file *fp, struct thread *td)
336 struct tmpfs_node *node;
340 MPASS(node->tn_type == VREG);
341 tmpfs_free_node(node->tn_reg.tn_tmp, node);
343 return (vnops.fo_close(fp, td));
347 * VOP_FPLOOKUP_VEXEC routines are subject to special circumstances, see
348 * the comment above cache_fplookup for details.
351 tmpfs_fplookup_vexec(struct vop_fplookup_vexec_args *v)
354 struct tmpfs_node *node;
359 node = VP_TO_TMPFS_NODE_SMR(vp);
360 if (__predict_false(node == NULL))
363 all_x = S_IXUSR | S_IXGRP | S_IXOTH;
364 mode = atomic_load_short(&node->tn_mode);
365 if (__predict_true((mode & all_x) == all_x))
369 return (vaccess_vexec_smr(mode, node->tn_uid, node->tn_gid, cred));
373 tmpfs_access(struct vop_access_args *v)
375 struct vnode *vp = v->a_vp;
376 accmode_t accmode = v->a_accmode;
377 struct ucred *cred = v->a_cred;
378 mode_t all_x = S_IXUSR | S_IXGRP | S_IXOTH;
380 struct tmpfs_node *node;
382 MPASS(VOP_ISLOCKED(vp));
384 node = VP_TO_TMPFS_NODE(vp);
387 * Common case path lookup.
389 if (__predict_true(accmode == VEXEC && (node->tn_mode & all_x) == all_x))
392 switch (vp->v_type) {
398 if (accmode & VWRITE && vp->v_mount->mnt_flag & MNT_RDONLY) {
418 if (accmode & VWRITE && node->tn_flags & IMMUTABLE) {
423 error = vaccess(vp->v_type, node->tn_mode, node->tn_uid, node->tn_gid,
427 MPASS(VOP_ISLOCKED(vp));
433 tmpfs_stat(struct vop_stat_args *v)
435 struct vnode *vp = v->a_vp;
436 struct stat *sb = v->a_sb;
438 struct tmpfs_node *node;
441 node = VP_TO_TMPFS_NODE(vp);
443 tmpfs_update_getattr(vp);
445 error = vop_stat_helper_pre(v);
446 if (__predict_false(error))
449 sb->st_dev = vp->v_mount->mnt_stat.f_fsid.val[0];
450 sb->st_ino = node->tn_id;
451 sb->st_mode = node->tn_mode | VTTOIF(vp->v_type);
452 sb->st_nlink = node->tn_links;
453 sb->st_uid = node->tn_uid;
454 sb->st_gid = node->tn_gid;
455 sb->st_rdev = (vp->v_type == VBLK || vp->v_type == VCHR) ?
456 node->tn_rdev : NODEV;
457 sb->st_size = node->tn_size;
458 sb->st_atim.tv_sec = node->tn_atime.tv_sec;
459 sb->st_atim.tv_nsec = node->tn_atime.tv_nsec;
460 sb->st_mtim.tv_sec = node->tn_mtime.tv_sec;
461 sb->st_mtim.tv_nsec = node->tn_mtime.tv_nsec;
462 sb->st_ctim.tv_sec = node->tn_ctime.tv_sec;
463 sb->st_ctim.tv_nsec = node->tn_ctime.tv_nsec;
464 sb->st_birthtim.tv_sec = node->tn_birthtime.tv_sec;
465 sb->st_birthtim.tv_nsec = node->tn_birthtime.tv_nsec;
466 sb->st_blksize = PAGE_SIZE;
467 sb->st_flags = node->tn_flags;
468 sb->st_gen = node->tn_gen;
469 if (vp->v_type == VREG) {
470 obj = node->tn_reg.tn_aobj;
471 sb->st_blocks = (u_quad_t)obj->resident_page_count * PAGE_SIZE;
473 sb->st_blocks = node->tn_size;
474 sb->st_blocks /= S_BLKSIZE;
475 return (vop_stat_helper_post(v, error));
479 tmpfs_getattr(struct vop_getattr_args *v)
481 struct vnode *vp = v->a_vp;
482 struct vattr *vap = v->a_vap;
484 struct tmpfs_node *node;
486 node = VP_TO_TMPFS_NODE(vp);
488 tmpfs_update_getattr(vp);
490 vap->va_type = vp->v_type;
491 vap->va_mode = node->tn_mode;
492 vap->va_nlink = node->tn_links;
493 vap->va_uid = node->tn_uid;
494 vap->va_gid = node->tn_gid;
495 vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
496 vap->va_fileid = node->tn_id;
497 vap->va_size = node->tn_size;
498 vap->va_blocksize = PAGE_SIZE;
499 vap->va_atime = node->tn_atime;
500 vap->va_mtime = node->tn_mtime;
501 vap->va_ctime = node->tn_ctime;
502 vap->va_birthtime = node->tn_birthtime;
503 vap->va_gen = node->tn_gen;
504 vap->va_flags = node->tn_flags;
505 vap->va_rdev = (vp->v_type == VBLK || vp->v_type == VCHR) ?
506 node->tn_rdev : NODEV;
507 if (vp->v_type == VREG) {
508 obj = node->tn_reg.tn_aobj;
509 vap->va_bytes = (u_quad_t)obj->resident_page_count * PAGE_SIZE;
511 vap->va_bytes = node->tn_size;
518 tmpfs_setattr(struct vop_setattr_args *v)
520 struct vnode *vp = v->a_vp;
521 struct vattr *vap = v->a_vap;
522 struct ucred *cred = v->a_cred;
523 struct thread *td = curthread;
527 MPASS(VOP_ISLOCKED(vp));
528 ASSERT_VOP_IN_SEQC(vp);
532 /* Abort if any unsettable attribute is given. */
533 if (vap->va_type != VNON ||
534 vap->va_nlink != VNOVAL ||
535 vap->va_fsid != VNOVAL ||
536 vap->va_fileid != VNOVAL ||
537 vap->va_blocksize != VNOVAL ||
538 vap->va_gen != VNOVAL ||
539 vap->va_rdev != VNOVAL ||
540 vap->va_bytes != VNOVAL)
543 if (error == 0 && (vap->va_flags != VNOVAL))
544 error = tmpfs_chflags(vp, vap->va_flags, cred, td);
546 if (error == 0 && (vap->va_size != VNOVAL))
547 error = tmpfs_chsize(vp, vap->va_size, cred, td);
549 if (error == 0 && (vap->va_uid != VNOVAL || vap->va_gid != VNOVAL))
550 error = tmpfs_chown(vp, vap->va_uid, vap->va_gid, cred, td);
552 if (error == 0 && (vap->va_mode != (mode_t)VNOVAL))
553 error = tmpfs_chmod(vp, vap->va_mode, cred, td);
555 if (error == 0 && ((vap->va_atime.tv_sec != VNOVAL &&
556 vap->va_atime.tv_nsec != VNOVAL) ||
557 (vap->va_mtime.tv_sec != VNOVAL &&
558 vap->va_mtime.tv_nsec != VNOVAL) ||
559 (vap->va_birthtime.tv_sec != VNOVAL &&
560 vap->va_birthtime.tv_nsec != VNOVAL)))
561 error = tmpfs_chtimes(vp, vap, cred, td);
564 * Update the node times. We give preference to the error codes
565 * generated by this function rather than the ones that may arise
570 MPASS(VOP_ISLOCKED(vp));
576 tmpfs_read(struct vop_read_args *v)
580 struct tmpfs_node *node;
583 if (vp->v_type != VREG)
586 if (uio->uio_offset < 0)
588 node = VP_TO_TMPFS_NODE(vp);
589 tmpfs_set_accessed(VFS_TO_TMPFS(vp->v_mount), node);
590 return (uiomove_object(node->tn_reg.tn_aobj, node->tn_size, uio));
594 tmpfs_read_pgcache(struct vop_read_pgcache_args *v)
597 struct tmpfs_node *node;
603 MPASS((vp->v_irflag & VIRF_PGREAD) != 0);
605 if (v->a_uio->uio_offset < 0)
611 node = VP_TO_TMPFS_NODE_SMR(vp);
614 MPASS(node->tn_type == VREG);
615 MPASS(node->tn_refcount >= 1);
616 object = node->tn_reg.tn_aobj;
620 MPASS((object->flags & (OBJ_ANON | OBJ_DEAD | OBJ_TMPFS_NODE)) ==
622 if (!VN_IS_DOOMED(vp)) {
623 /* size cannot become shorter due to rangelock. */
624 size = node->tn_size;
625 tmpfs_set_accessed(node->tn_reg.tn_tmp, node);
627 error = uiomove_object(object, size, v->a_uio);
636 tmpfs_write(struct vop_write_args *v)
640 struct tmpfs_node *node;
647 ioflag = v->a_ioflag;
649 node = VP_TO_TMPFS_NODE(vp);
650 oldsize = node->tn_size;
652 if (uio->uio_offset < 0 || vp->v_type != VREG)
654 if (uio->uio_resid == 0)
656 if (ioflag & IO_APPEND)
657 uio->uio_offset = node->tn_size;
658 if (uio->uio_offset + uio->uio_resid >
659 VFS_TO_TMPFS(vp->v_mount)->tm_maxfilesize)
661 if (vn_rlimit_fsize(vp, uio, uio->uio_td))
663 if (uio->uio_offset + uio->uio_resid > node->tn_size) {
664 error = tmpfs_reg_resize(vp, uio->uio_offset + uio->uio_resid,
670 error = uiomove_object(node->tn_reg.tn_aobj, node->tn_size, uio);
671 node->tn_status |= TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED;
672 node->tn_accessed = true;
673 if (node->tn_mode & (S_ISUID | S_ISGID)) {
674 if (priv_check_cred(v->a_cred, PRIV_VFS_RETAINSUGID)) {
675 newmode = node->tn_mode & ~(S_ISUID | S_ISGID);
676 vn_seqc_write_begin(vp);
677 atomic_store_short(&node->tn_mode, newmode);
678 vn_seqc_write_end(vp);
682 (void)tmpfs_reg_resize(vp, oldsize, TRUE);
685 MPASS(IMPLIES(error == 0, uio->uio_resid == 0));
686 MPASS(IMPLIES(error != 0, oldsize == node->tn_size));
692 tmpfs_fsync(struct vop_fsync_args *v)
694 struct vnode *vp = v->a_vp;
696 MPASS(VOP_ISLOCKED(vp));
698 tmpfs_check_mtime(vp);
705 tmpfs_remove(struct vop_remove_args *v)
707 struct vnode *dvp = v->a_dvp;
708 struct vnode *vp = v->a_vp;
711 struct tmpfs_dirent *de;
712 struct tmpfs_mount *tmp;
713 struct tmpfs_node *dnode;
714 struct tmpfs_node *node;
716 MPASS(VOP_ISLOCKED(dvp));
717 MPASS(VOP_ISLOCKED(vp));
719 if (vp->v_type == VDIR) {
724 dnode = VP_TO_TMPFS_DIR(dvp);
725 node = VP_TO_TMPFS_NODE(vp);
726 tmp = VFS_TO_TMPFS(vp->v_mount);
727 de = tmpfs_dir_lookup(dnode, node, v->a_cnp);
730 /* Files marked as immutable or append-only cannot be deleted. */
731 if ((node->tn_flags & (IMMUTABLE | APPEND | NOUNLINK)) ||
732 (dnode->tn_flags & APPEND)) {
737 /* Remove the entry from the directory; as it is a file, we do not
738 * have to change the number of hard links of the directory. */
739 tmpfs_dir_detach(dvp, de);
740 if (v->a_cnp->cn_flags & DOWHITEOUT)
741 tmpfs_dir_whiteout_add(dvp, v->a_cnp);
743 /* Free the directory entry we just deleted. Note that the node
744 * referred by it will not be removed until the vnode is really
746 tmpfs_free_dirent(tmp, de);
748 node->tn_status |= TMPFS_NODE_CHANGED;
749 node->tn_accessed = true;
757 tmpfs_link(struct vop_link_args *v)
759 struct vnode *dvp = v->a_tdvp;
760 struct vnode *vp = v->a_vp;
761 struct componentname *cnp = v->a_cnp;
764 struct tmpfs_dirent *de;
765 struct tmpfs_node *node;
767 MPASS(VOP_ISLOCKED(dvp));
768 MPASS(cnp->cn_flags & HASBUF);
769 MPASS(dvp != vp); /* XXX When can this be false? */
770 node = VP_TO_TMPFS_NODE(vp);
772 /* Ensure that we do not overflow the maximum number of links imposed
774 MPASS(node->tn_links <= TMPFS_LINK_MAX);
775 if (node->tn_links == TMPFS_LINK_MAX) {
780 /* We cannot create links of files marked immutable or append-only. */
781 if (node->tn_flags & (IMMUTABLE | APPEND)) {
786 /* Allocate a new directory entry to represent the node. */
787 error = tmpfs_alloc_dirent(VFS_TO_TMPFS(vp->v_mount), node,
788 cnp->cn_nameptr, cnp->cn_namelen, &de);
792 /* Insert the new directory entry into the appropriate directory. */
793 if (cnp->cn_flags & ISWHITEOUT)
794 tmpfs_dir_whiteout_remove(dvp, cnp);
795 tmpfs_dir_attach(dvp, de);
797 /* vp link count has changed, so update node times. */
798 node->tn_status |= TMPFS_NODE_CHANGED;
808 * We acquire all but fdvp locks using non-blocking acquisitions. If we
809 * fail to acquire any lock in the path we will drop all held locks,
810 * acquire the new lock in a blocking fashion, and then release it and
811 * restart the rename. This acquire/release step ensures that we do not
812 * spin on a lock waiting for release. On error release all vnode locks
813 * and decrement references the way tmpfs_rename() would do.
816 tmpfs_rename_relock(struct vnode *fdvp, struct vnode **fvpp,
817 struct vnode *tdvp, struct vnode **tvpp,
818 struct componentname *fcnp, struct componentname *tcnp)
822 struct tmpfs_dirent *de;
823 int error, restarts = 0;
826 if (*tvpp != NULL && *tvpp != tdvp)
832 error = vn_lock(fdvp, LK_EXCLUSIVE);
835 if (vn_lock(tdvp, LK_EXCLUSIVE | LK_NOWAIT) != 0) {
837 error = vn_lock(tdvp, LK_EXCLUSIVE);
844 * Re-resolve fvp to be certain it still exists and fetch the
847 de = tmpfs_dir_lookup(VP_TO_TMPFS_DIR(fdvp), NULL, fcnp);
851 if ((fcnp->cn_flags & ISDOTDOT) != 0 ||
852 (fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.'))
858 error = tmpfs_alloc_vp(mp, de->td_node, LK_EXCLUSIVE | LK_NOWAIT, &nvp);
864 error = tmpfs_alloc_vp(mp, de->td_node, LK_EXCLUSIVE, &nvp);
869 * Concurrent rename race.
884 * Re-resolve tvp and acquire the vnode lock if present.
886 de = tmpfs_dir_lookup(VP_TO_TMPFS_DIR(tdvp), NULL, tcnp);
888 * If tvp disappeared we just carry on.
890 if (de == NULL && *tvpp != NULL) {
895 * Get the tvp ino if the lookup succeeded. We may have to restart
896 * if the non-blocking acquire fails.
900 error = tmpfs_alloc_vp(mp, de->td_node,
901 LK_EXCLUSIVE | LK_NOWAIT, &nvp);
910 error = tmpfs_alloc_vp(mp, de->td_node, LK_EXCLUSIVE,
916 * fdvp contains fvp, thus tvp (=fdvp) is not empty.
925 tmpfs_rename_restarts += restarts;
935 tmpfs_rename_restarts += restarts;
941 tmpfs_rename(struct vop_rename_args *v)
943 struct vnode *fdvp = v->a_fdvp;
944 struct vnode *fvp = v->a_fvp;
945 struct componentname *fcnp = v->a_fcnp;
946 struct vnode *tdvp = v->a_tdvp;
947 struct vnode *tvp = v->a_tvp;
948 struct componentname *tcnp = v->a_tcnp;
950 struct tmpfs_dirent *de;
951 struct tmpfs_mount *tmp;
952 struct tmpfs_node *fdnode;
953 struct tmpfs_node *fnode;
954 struct tmpfs_node *tnode;
955 struct tmpfs_node *tdnode;
959 MPASS(VOP_ISLOCKED(tdvp));
960 MPASS(IMPLIES(tvp != NULL, VOP_ISLOCKED(tvp)));
961 MPASS(fcnp->cn_flags & HASBUF);
962 MPASS(tcnp->cn_flags & HASBUF);
964 want_seqc_end = false;
967 * Disallow cross-device renames.
968 * XXX Why isn't this done by the caller?
970 if (fvp->v_mount != tdvp->v_mount ||
971 (tvp != NULL && fvp->v_mount != tvp->v_mount)) {
976 /* If source and target are the same file, there is nothing to do. */
983 * If we need to move the directory between entries, lock the
984 * source so that we can safely operate on it.
986 if (fdvp != tdvp && fdvp != tvp) {
987 if (vn_lock(fdvp, LK_EXCLUSIVE | LK_NOWAIT) != 0) {
988 error = tmpfs_rename_relock(fdvp, &fvp, tdvp, &tvp,
992 ASSERT_VOP_ELOCKED(fdvp,
993 "tmpfs_rename: fdvp not locked");
994 ASSERT_VOP_ELOCKED(tdvp,
995 "tmpfs_rename: tdvp not locked");
997 ASSERT_VOP_ELOCKED(tvp,
998 "tmpfs_rename: tvp not locked");
1007 vn_seqc_write_begin(tvp);
1008 vn_seqc_write_begin(tdvp);
1009 vn_seqc_write_begin(fvp);
1010 vn_seqc_write_begin(fdvp);
1011 want_seqc_end = true;
1013 tmp = VFS_TO_TMPFS(tdvp->v_mount);
1014 tdnode = VP_TO_TMPFS_DIR(tdvp);
1015 tnode = (tvp == NULL) ? NULL : VP_TO_TMPFS_NODE(tvp);
1016 fdnode = VP_TO_TMPFS_DIR(fdvp);
1017 fnode = VP_TO_TMPFS_NODE(fvp);
1018 de = tmpfs_dir_lookup(fdnode, fnode, fcnp);
1021 * Entry can disappear before we lock fdvp,
1022 * also avoid manipulating '.' and '..' entries.
1025 if ((fcnp->cn_flags & ISDOTDOT) != 0 ||
1026 (fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.'))
1032 MPASS(de->td_node == fnode);
1035 * If re-naming a directory to another preexisting directory
1036 * ensure that the target directory is empty so that its
1037 * removal causes no side effects.
1038 * Kern_rename guarantees the destination to be a directory
1039 * if the source is one.
1042 MPASS(tnode != NULL);
1044 if ((tnode->tn_flags & (NOUNLINK | IMMUTABLE | APPEND)) ||
1045 (tdnode->tn_flags & (APPEND | IMMUTABLE))) {
1050 if (fnode->tn_type == VDIR && tnode->tn_type == VDIR) {
1051 if (tnode->tn_size > 0) {
1055 } else if (fnode->tn_type == VDIR && tnode->tn_type != VDIR) {
1058 } else if (fnode->tn_type != VDIR && tnode->tn_type == VDIR) {
1062 MPASS(fnode->tn_type != VDIR &&
1063 tnode->tn_type != VDIR);
1067 if ((fnode->tn_flags & (NOUNLINK | IMMUTABLE | APPEND))
1068 || (fdnode->tn_flags & (APPEND | IMMUTABLE))) {
1074 * Ensure that we have enough memory to hold the new name, if it
1075 * has to be changed.
1077 if (fcnp->cn_namelen != tcnp->cn_namelen ||
1078 bcmp(fcnp->cn_nameptr, tcnp->cn_nameptr, fcnp->cn_namelen) != 0) {
1079 newname = malloc(tcnp->cn_namelen, M_TMPFSNAME, M_WAITOK);
1084 * If the node is being moved to another directory, we have to do
1087 if (fdnode != tdnode) {
1089 * In case we are moving a directory, we have to adjust its
1090 * parent to point to the new parent.
1092 if (de->td_node->tn_type == VDIR) {
1093 struct tmpfs_node *n;
1096 * Ensure the target directory is not a child of the
1097 * directory being moved. Otherwise, we'd end up
1102 * TMPFS_LOCK guaranties that no nodes are freed while
1103 * traversing the list. Nodes can only be marked as
1104 * removed: tn_parent == NULL.
1108 while (n != n->tn_dir.tn_parent) {
1109 struct tmpfs_node *parent;
1112 TMPFS_NODE_UNLOCK(n);
1115 if (newname != NULL)
1116 free(newname, M_TMPFSNAME);
1119 parent = n->tn_dir.tn_parent;
1120 TMPFS_NODE_UNLOCK(n);
1121 if (parent == NULL) {
1125 TMPFS_NODE_LOCK(parent);
1126 if (parent->tn_dir.tn_parent == NULL) {
1127 TMPFS_NODE_UNLOCK(parent);
1136 if (newname != NULL)
1137 free(newname, M_TMPFSNAME);
1140 TMPFS_NODE_UNLOCK(n);
1142 /* Adjust the parent pointer. */
1143 TMPFS_VALIDATE_DIR(fnode);
1144 TMPFS_NODE_LOCK(de->td_node);
1145 de->td_node->tn_dir.tn_parent = tdnode;
1146 TMPFS_NODE_UNLOCK(de->td_node);
1149 * As a result of changing the target of the '..'
1150 * entry, the link count of the source and target
1151 * directories has to be adjusted.
1153 TMPFS_NODE_LOCK(tdnode);
1154 TMPFS_ASSERT_LOCKED(tdnode);
1156 TMPFS_NODE_UNLOCK(tdnode);
1158 TMPFS_NODE_LOCK(fdnode);
1159 TMPFS_ASSERT_LOCKED(fdnode);
1161 TMPFS_NODE_UNLOCK(fdnode);
1166 * Do the move: just remove the entry from the source directory
1167 * and insert it into the target one.
1169 tmpfs_dir_detach(fdvp, de);
1171 if (fcnp->cn_flags & DOWHITEOUT)
1172 tmpfs_dir_whiteout_add(fdvp, fcnp);
1173 if (tcnp->cn_flags & ISWHITEOUT)
1174 tmpfs_dir_whiteout_remove(tdvp, tcnp);
1177 * If the name has changed, we need to make it effective by changing
1178 * it in the directory entry.
1180 if (newname != NULL) {
1181 MPASS(tcnp->cn_namelen <= MAXNAMLEN);
1183 free(de->ud.td_name, M_TMPFSNAME);
1184 de->ud.td_name = newname;
1185 tmpfs_dirent_init(de, tcnp->cn_nameptr, tcnp->cn_namelen);
1187 fnode->tn_status |= TMPFS_NODE_CHANGED;
1188 tdnode->tn_status |= TMPFS_NODE_MODIFIED;
1192 * If we are overwriting an entry, we have to remove the old one
1193 * from the target directory.
1196 struct tmpfs_dirent *tde;
1198 /* Remove the old entry from the target directory. */
1199 tde = tmpfs_dir_lookup(tdnode, tnode, tcnp);
1200 tmpfs_dir_detach(tdvp, tde);
1203 * Free the directory entry we just deleted. Note that the
1204 * node referred by it will not be removed until the vnode is
1207 tmpfs_free_dirent(VFS_TO_TMPFS(tvp->v_mount), tde);
1210 tmpfs_dir_attach(tdvp, de);
1212 if (tmpfs_use_nc(fvp)) {
1213 cache_rename(fdvp, fvp, tdvp, tvp, fcnp, tcnp);
1219 if (fdvp != tdvp && fdvp != tvp)
1223 if (want_seqc_end) {
1225 vn_seqc_write_end(tvp);
1226 vn_seqc_write_end(tdvp);
1227 vn_seqc_write_end(fvp);
1228 vn_seqc_write_end(fdvp);
1232 * Release target nodes.
1233 * XXX: I don't understand when tdvp can be the same as tvp, but
1234 * other code takes care of this...
1243 /* Release source nodes. */
1251 tmpfs_mkdir(struct vop_mkdir_args *v)
1253 struct vnode *dvp = v->a_dvp;
1254 struct vnode **vpp = v->a_vpp;
1255 struct componentname *cnp = v->a_cnp;
1256 struct vattr *vap = v->a_vap;
1258 MPASS(vap->va_type == VDIR);
1260 return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL);
1264 tmpfs_rmdir(struct vop_rmdir_args *v)
1266 struct vnode *dvp = v->a_dvp;
1267 struct vnode *vp = v->a_vp;
1270 struct tmpfs_dirent *de;
1271 struct tmpfs_mount *tmp;
1272 struct tmpfs_node *dnode;
1273 struct tmpfs_node *node;
1275 MPASS(VOP_ISLOCKED(dvp));
1276 MPASS(VOP_ISLOCKED(vp));
1278 tmp = VFS_TO_TMPFS(dvp->v_mount);
1279 dnode = VP_TO_TMPFS_DIR(dvp);
1280 node = VP_TO_TMPFS_DIR(vp);
1282 /* Directories with more than two entries ('.' and '..') cannot be
1284 if (node->tn_size > 0) {
1289 if ((dnode->tn_flags & APPEND)
1290 || (node->tn_flags & (NOUNLINK | IMMUTABLE | APPEND))) {
1295 /* This invariant holds only if we are not trying to remove "..".
1296 * We checked for that above so this is safe now. */
1297 MPASS(node->tn_dir.tn_parent == dnode);
1299 /* Get the directory entry associated with node (vp). This was
1300 * filled by tmpfs_lookup while looking up the entry. */
1301 de = tmpfs_dir_lookup(dnode, node, v->a_cnp);
1302 MPASS(TMPFS_DIRENT_MATCHES(de,
1303 v->a_cnp->cn_nameptr,
1304 v->a_cnp->cn_namelen));
1306 /* Check flags to see if we are allowed to remove the directory. */
1307 if ((dnode->tn_flags & APPEND) != 0 ||
1308 (node->tn_flags & (NOUNLINK | IMMUTABLE | APPEND)) != 0) {
1313 /* Detach the directory entry from the directory (dnode). */
1314 tmpfs_dir_detach(dvp, de);
1315 if (v->a_cnp->cn_flags & DOWHITEOUT)
1316 tmpfs_dir_whiteout_add(dvp, v->a_cnp);
1318 /* No vnode should be allocated for this entry from this point */
1319 TMPFS_NODE_LOCK(node);
1321 node->tn_dir.tn_parent = NULL;
1322 node->tn_status |= TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED;
1323 node->tn_accessed = true;
1325 TMPFS_NODE_UNLOCK(node);
1327 TMPFS_NODE_LOCK(dnode);
1329 dnode->tn_status |= TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED;
1330 dnode->tn_accessed = true;
1331 TMPFS_NODE_UNLOCK(dnode);
1333 if (tmpfs_use_nc(dvp)) {
1337 /* Free the directory entry we just deleted. Note that the node
1338 * referred by it will not be removed until the vnode is really
1340 tmpfs_free_dirent(tmp, de);
1342 /* Release the deleted vnode (will destroy the node, notify
1343 * interested parties and clean it from the cache). */
1345 dnode->tn_status |= TMPFS_NODE_CHANGED;
1355 tmpfs_symlink(struct vop_symlink_args *v)
1357 struct vnode *dvp = v->a_dvp;
1358 struct vnode **vpp = v->a_vpp;
1359 struct componentname *cnp = v->a_cnp;
1360 struct vattr *vap = v->a_vap;
1361 const char *target = v->a_target;
1363 #ifdef notyet /* XXX FreeBSD BUG: kern_symlink is not setting VLNK */
1364 MPASS(vap->va_type == VLNK);
1366 vap->va_type = VLNK;
1369 return tmpfs_alloc_file(dvp, vpp, vap, cnp, target);
1373 tmpfs_readdir(struct vop_readdir_args *va)
1377 struct tmpfs_mount *tm;
1378 struct tmpfs_node *node;
1380 int *eofflag, *ncookies;
1382 int error, maxcookies;
1386 eofflag = va->a_eofflag;
1387 cookies = va->a_cookies;
1388 ncookies = va->a_ncookies;
1390 /* This operation only makes sense on directory nodes. */
1391 if (vp->v_type != VDIR)
1395 node = VP_TO_TMPFS_DIR(vp);
1396 tm = VFS_TO_TMPFS(vp->v_mount);
1398 startresid = uio->uio_resid;
1400 /* Allocate cookies for NFS and compat modules. */
1401 if (cookies != NULL && ncookies != NULL) {
1402 maxcookies = howmany(node->tn_size,
1403 sizeof(struct tmpfs_dirent)) + 2;
1404 *cookies = malloc(maxcookies * sizeof(**cookies), M_TEMP,
1409 if (cookies == NULL)
1410 error = tmpfs_dir_getdents(tm, node, uio, 0, NULL, NULL);
1412 error = tmpfs_dir_getdents(tm, node, uio, maxcookies, *cookies,
1415 /* Buffer was filled without hitting EOF. */
1416 if (error == EJUSTRETURN)
1417 error = (uio->uio_resid != startresid) ? 0 : EINVAL;
1419 if (error != 0 && cookies != NULL && ncookies != NULL) {
1420 free(*cookies, M_TEMP);
1425 if (eofflag != NULL)
1427 (error == 0 && uio->uio_offset == TMPFS_DIRCOOKIE_EOF);
1433 tmpfs_readlink(struct vop_readlink_args *v)
1435 struct vnode *vp = v->a_vp;
1436 struct uio *uio = v->a_uio;
1439 struct tmpfs_node *node;
1441 MPASS(uio->uio_offset == 0);
1442 MPASS(vp->v_type == VLNK);
1444 node = VP_TO_TMPFS_NODE(vp);
1446 error = uiomove(node->tn_link, MIN(node->tn_size, uio->uio_resid),
1448 tmpfs_set_accessed(VFS_TO_TMPFS(vp->v_mount), node);
1454 tmpfs_inactive(struct vop_inactive_args *v)
1457 struct tmpfs_node *node;
1460 node = VP_TO_TMPFS_NODE(vp);
1461 if (node->tn_links == 0)
1464 tmpfs_check_mtime(vp);
1469 tmpfs_need_inactive(struct vop_need_inactive_args *ap)
1472 struct tmpfs_node *node;
1473 struct vm_object *obj;
1476 node = VP_TO_TMPFS_NODE(vp);
1477 if (node->tn_links == 0)
1479 if (vp->v_type == VREG) {
1481 if (obj->generation != obj->cleangeneration)
1490 tmpfs_reclaim(struct vop_reclaim_args *v)
1492 struct vnode *vp = v->a_vp;
1494 struct tmpfs_mount *tmp;
1495 struct tmpfs_node *node;
1497 node = VP_TO_TMPFS_NODE(vp);
1498 tmp = VFS_TO_TMPFS(vp->v_mount);
1500 if (vp->v_type == VREG)
1501 tmpfs_destroy_vobject(vp, node->tn_reg.tn_aobj);
1502 vp->v_object = NULL;
1504 TMPFS_NODE_LOCK(node);
1507 /* If the node referenced by this vnode was deleted by the user,
1508 * we must free its associated data structures (now that the vnode
1509 * is being reclaimed). */
1510 if (node->tn_links == 0 &&
1511 (node->tn_vpstate & TMPFS_VNODE_ALLOCATING) == 0) {
1512 node->tn_vpstate = TMPFS_VNODE_DOOMED;
1513 TMPFS_NODE_UNLOCK(node);
1514 tmpfs_free_node(tmp, node);
1516 TMPFS_NODE_UNLOCK(node);
1518 MPASS(vp->v_data == NULL);
1523 tmpfs_print(struct vop_print_args *v)
1525 struct vnode *vp = v->a_vp;
1527 struct tmpfs_node *node;
1529 node = VP_TO_TMPFS_NODE(vp);
1531 printf("tag VT_TMPFS, tmpfs_node %p, flags 0x%lx, links %jd\n",
1532 node, node->tn_flags, (uintmax_t)node->tn_links);
1533 printf("\tmode 0%o, owner %d, group %d, size %jd, status 0x%x\n",
1534 node->tn_mode, node->tn_uid, node->tn_gid,
1535 (intmax_t)node->tn_size, node->tn_status);
1537 if (vp->v_type == VFIFO)
1546 tmpfs_pathconf(struct vop_pathconf_args *v)
1548 struct vnode *vp = v->a_vp;
1549 int name = v->a_name;
1550 long *retval = v->a_retval;
1558 *retval = TMPFS_LINK_MAX;
1566 if (vp->v_type == VDIR || vp->v_type == VFIFO)
1572 case _PC_CHOWN_RESTRICTED:
1584 case _PC_FILESIZEBITS:
1589 error = vop_stdpathconf(v);
1596 tmpfs_vptofh(struct vop_vptofh_args *ap)
1599 IN struct vnode *a_vp;
1600 IN struct fid *a_fhp;
1604 struct tmpfs_fid_data tfd;
1605 struct tmpfs_node *node;
1608 node = VP_TO_TMPFS_NODE(ap->a_vp);
1610 fhp->fid_len = sizeof(tfd);
1613 * Copy into fid_data from the stack to avoid unaligned pointer use.
1614 * See the comment in sys/mount.h on struct fid for details.
1616 tfd.tfd_id = node->tn_id;
1617 tfd.tfd_gen = node->tn_gen;
1618 memcpy(fhp->fid_data, &tfd, fhp->fid_len);
1624 tmpfs_whiteout(struct vop_whiteout_args *ap)
1626 struct vnode *dvp = ap->a_dvp;
1627 struct componentname *cnp = ap->a_cnp;
1628 struct tmpfs_dirent *de;
1630 switch (ap->a_flags) {
1634 de = tmpfs_dir_lookup(VP_TO_TMPFS_DIR(dvp), NULL, cnp);
1636 return (de->td_node == NULL ? 0 : EEXIST);
1637 return (tmpfs_dir_whiteout_add(dvp, cnp));
1639 tmpfs_dir_whiteout_remove(dvp, cnp);
1642 panic("tmpfs_whiteout: unknown op");
1647 tmpfs_vptocnp_dir(struct tmpfs_node *tn, struct tmpfs_node *tnp,
1648 struct tmpfs_dirent **pde)
1650 struct tmpfs_dir_cursor dc;
1651 struct tmpfs_dirent *de;
1653 for (de = tmpfs_dir_first(tnp, &dc); de != NULL;
1654 de = tmpfs_dir_next(tnp, &dc)) {
1655 if (de->td_node == tn) {
1664 tmpfs_vptocnp_fill(struct vnode *vp, struct tmpfs_node *tn,
1665 struct tmpfs_node *tnp, char *buf, size_t *buflen, struct vnode **dvp)
1667 struct tmpfs_dirent *de;
1670 error = vn_vget_ino_gen(vp, tmpfs_vn_get_ino_alloc, tnp, LK_SHARED,
1674 error = tmpfs_vptocnp_dir(tn, tnp, &de);
1677 i -= de->td_namelen;
1681 bcopy(de->ud.td_name, buf + i, de->td_namelen);
1698 tmpfs_vptocnp(struct vop_vptocnp_args *ap)
1700 struct vnode *vp, **dvp;
1701 struct tmpfs_node *tn, *tnp, *tnp1;
1702 struct tmpfs_dirent *de;
1703 struct tmpfs_mount *tm;
1711 buflen = ap->a_buflen;
1713 tm = VFS_TO_TMPFS(vp->v_mount);
1714 tn = VP_TO_TMPFS_NODE(vp);
1715 if (tn->tn_type == VDIR) {
1716 tnp = tn->tn_dir.tn_parent;
1719 tmpfs_ref_node(tnp);
1720 error = tmpfs_vptocnp_fill(vp, tn, tn->tn_dir.tn_parent, buf,
1722 tmpfs_free_node(tm, tnp);
1727 LIST_FOREACH_SAFE(tnp, &tm->tm_nodes_used, tn_entries, tnp1) {
1728 if (tnp->tn_type != VDIR)
1730 TMPFS_NODE_LOCK(tnp);
1731 tmpfs_ref_node(tnp);
1734 * tn_vnode cannot be instantiated while we hold the
1735 * node lock, so the directory cannot be changed while
1736 * we iterate over it. Do this to avoid instantiating
1737 * vnode for directories which cannot point to our
1740 error = tnp->tn_vnode == NULL ? tmpfs_vptocnp_dir(tn, tnp,
1744 TMPFS_NODE_UNLOCK(tnp);
1746 error = tmpfs_vptocnp_fill(vp, tn, tnp, buf, buflen,
1749 tmpfs_free_node(tm, tnp);
1752 if (VN_IS_DOOMED(vp)) {
1753 tmpfs_free_node(tm, tnp);
1757 TMPFS_NODE_LOCK(tnp);
1759 if (tmpfs_free_node_locked(tm, tnp, false)) {
1762 KASSERT(tnp->tn_refcount > 0,
1763 ("node %p refcount zero", tnp));
1764 tnp1 = LIST_NEXT(tnp, tn_entries);
1765 TMPFS_NODE_UNLOCK(tnp);
1773 * Vnode operations vector used for files stored in a tmpfs file system.
1775 struct vop_vector tmpfs_vnodeop_entries = {
1776 .vop_default = &default_vnodeops,
1777 .vop_lookup = vfs_cache_lookup,
1778 .vop_cachedlookup = tmpfs_cached_lookup,
1779 .vop_create = tmpfs_create,
1780 .vop_mknod = tmpfs_mknod,
1781 .vop_open = tmpfs_open,
1782 .vop_close = tmpfs_close,
1783 .vop_fplookup_vexec = tmpfs_fplookup_vexec,
1784 .vop_access = tmpfs_access,
1785 .vop_stat = tmpfs_stat,
1786 .vop_getattr = tmpfs_getattr,
1787 .vop_setattr = tmpfs_setattr,
1788 .vop_read = tmpfs_read,
1789 .vop_read_pgcache = tmpfs_read_pgcache,
1790 .vop_write = tmpfs_write,
1791 .vop_fsync = tmpfs_fsync,
1792 .vop_remove = tmpfs_remove,
1793 .vop_link = tmpfs_link,
1794 .vop_rename = tmpfs_rename,
1795 .vop_mkdir = tmpfs_mkdir,
1796 .vop_rmdir = tmpfs_rmdir,
1797 .vop_symlink = tmpfs_symlink,
1798 .vop_readdir = tmpfs_readdir,
1799 .vop_readlink = tmpfs_readlink,
1800 .vop_inactive = tmpfs_inactive,
1801 .vop_need_inactive = tmpfs_need_inactive,
1802 .vop_reclaim = tmpfs_reclaim,
1803 .vop_print = tmpfs_print,
1804 .vop_pathconf = tmpfs_pathconf,
1805 .vop_vptofh = tmpfs_vptofh,
1806 .vop_whiteout = tmpfs_whiteout,
1807 .vop_bmap = VOP_EOPNOTSUPP,
1808 .vop_vptocnp = tmpfs_vptocnp,
1809 .vop_lock1 = vop_lock,
1810 .vop_unlock = vop_unlock,
1811 .vop_islocked = vop_islocked,
1813 VFS_VOP_VECTOR_REGISTER(tmpfs_vnodeop_entries);
1816 * Same vector for mounts which do not use namecache.
1818 struct vop_vector tmpfs_vnodeop_nonc_entries = {
1819 .vop_default = &tmpfs_vnodeop_entries,
1820 .vop_lookup = tmpfs_lookup,
1822 VFS_VOP_VECTOR_REGISTER(tmpfs_vnodeop_nonc_entries);