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 /* Caller assumes responsibility for ensuring access (VEXEC). */
95 dnode = VP_TO_TMPFS_DIR(dvp);
98 /* We cannot be requesting the parent directory of the root node. */
99 MPASS(IMPLIES(dnode->tn_type == VDIR &&
100 dnode->tn_dir.tn_parent == dnode,
101 !(cnp->cn_flags & ISDOTDOT)));
103 TMPFS_ASSERT_LOCKED(dnode);
104 if (dnode->tn_dir.tn_parent == NULL) {
108 if (cnp->cn_flags & ISDOTDOT) {
109 tm = VFS_TO_TMPFS(dvp->v_mount);
110 pnode = dnode->tn_dir.tn_parent;
111 tmpfs_ref_node(pnode);
112 error = vn_vget_ino_gen(dvp, tmpfs_vn_get_ino_alloc,
113 pnode, cnp->cn_lkflags, vpp);
114 tmpfs_free_node(tm, pnode);
117 } else if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
122 de = tmpfs_dir_lookup(dnode, NULL, cnp);
123 if (de != NULL && de->td_node == NULL)
124 cnp->cn_flags |= ISWHITEOUT;
125 if (de == NULL || de->td_node == NULL) {
127 * The entry was not found in the directory.
128 * This is OK if we are creating or renaming an
129 * entry and are working on the last component of
132 if ((cnp->cn_flags & ISLASTCN) &&
133 (cnp->cn_nameiop == CREATE || \
134 cnp->cn_nameiop == RENAME ||
135 (cnp->cn_nameiop == DELETE &&
136 cnp->cn_flags & DOWHITEOUT &&
137 cnp->cn_flags & ISWHITEOUT))) {
138 error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred,
144 * Keep the component name in the buffer for
147 cnp->cn_flags |= SAVENAME;
153 struct tmpfs_node *tnode;
156 * The entry was found, so get its associated
162 * If we are not at the last path component and
163 * found a non-directory or non-link entry (which
164 * may itself be pointing to a directory), raise
167 if ((tnode->tn_type != VDIR &&
168 tnode->tn_type != VLNK) &&
169 !(cnp->cn_flags & ISLASTCN)) {
175 * If we are deleting or renaming the entry, keep
176 * track of its tmpfs_dirent so that it can be
177 * easily deleted later.
179 if ((cnp->cn_flags & ISLASTCN) &&
180 (cnp->cn_nameiop == DELETE ||
181 cnp->cn_nameiop == RENAME)) {
182 error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred,
187 /* Allocate a new vnode on the matching entry. */
188 error = tmpfs_alloc_vp(dvp->v_mount, tnode,
189 cnp->cn_lkflags, vpp);
193 if ((dnode->tn_mode & S_ISTXT) &&
194 VOP_ACCESS(dvp, VADMIN, cnp->cn_cred,
195 cnp->cn_thread) && VOP_ACCESS(*vpp, VADMIN,
196 cnp->cn_cred, cnp->cn_thread)) {
202 cnp->cn_flags |= SAVENAME;
204 error = tmpfs_alloc_vp(dvp->v_mount, tnode,
205 cnp->cn_lkflags, vpp);
213 * Store the result of this lookup in the cache. Avoid this if the
214 * request was for creation, as it does not improve timings on
217 if ((cnp->cn_flags & MAKEENTRY) != 0 && tmpfs_use_nc(dvp))
218 cache_enter(dvp, *vpp, cnp);
222 * If there were no errors, *vpp cannot be null and it must be
225 MPASS(IFF(error == 0, *vpp != NULLVP && VOP_ISLOCKED(*vpp)));
231 tmpfs_cached_lookup(struct vop_cachedlookup_args *v)
234 return (tmpfs_lookup1(v->a_dvp, v->a_vpp, v->a_cnp));
238 tmpfs_lookup(struct vop_lookup_args *v)
240 struct vnode *dvp = v->a_dvp;
241 struct vnode **vpp = v->a_vpp;
242 struct componentname *cnp = v->a_cnp;
245 /* Check accessibility of requested node as a first step. */
246 error = vn_dir_check_exec(dvp, cnp);
250 return (tmpfs_lookup1(dvp, vpp, cnp));
254 tmpfs_create(struct vop_create_args *v)
256 struct vnode *dvp = v->a_dvp;
257 struct vnode **vpp = v->a_vpp;
258 struct componentname *cnp = v->a_cnp;
259 struct vattr *vap = v->a_vap;
262 MPASS(vap->va_type == VREG || vap->va_type == VSOCK);
264 error = tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL);
265 if (error == 0 && (cnp->cn_flags & MAKEENTRY) != 0 && tmpfs_use_nc(dvp))
266 cache_enter(dvp, *vpp, cnp);
271 tmpfs_mknod(struct vop_mknod_args *v)
273 struct vnode *dvp = v->a_dvp;
274 struct vnode **vpp = v->a_vpp;
275 struct componentname *cnp = v->a_cnp;
276 struct vattr *vap = v->a_vap;
278 if (vap->va_type != VBLK && vap->va_type != VCHR &&
279 vap->va_type != VFIFO)
282 return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL);
285 struct fileops tmpfs_fnops;
288 tmpfs_open(struct vop_open_args *v)
291 struct tmpfs_node *node;
297 node = VP_TO_TMPFS_NODE(vp);
300 * The file is still active but all its names have been removed
301 * (e.g. by a "rmdir $(pwd)"). It cannot be opened any more as
302 * it is about to die.
304 if (node->tn_links < 1)
307 /* If the file is marked append-only, deny write requests. */
308 if (node->tn_flags & APPEND && (mode & (FWRITE | O_APPEND)) == FWRITE)
312 /* For regular files, the call below is nop. */
313 KASSERT(vp->v_type != VREG || (node->tn_reg.tn_aobj->flags &
314 OBJ_DEAD) == 0, ("dead object"));
315 vnode_create_vobject(vp, node->tn_size, v->a_td);
319 MPASS(fp == NULL || fp->f_data == NULL);
320 if (error == 0 && fp != NULL && vp->v_type == VREG) {
321 tmpfs_ref_node(node);
322 finit_vnode(fp, mode, node, &tmpfs_fnops);
329 tmpfs_close(struct vop_close_args *v)
331 struct vnode *vp = v->a_vp;
333 /* Update node times. */
340 tmpfs_fo_close(struct file *fp, struct thread *td)
342 struct tmpfs_node *node;
346 MPASS(node->tn_type == VREG);
347 tmpfs_free_node(node->tn_reg.tn_tmp, node);
349 return (vnops.fo_close(fp, td));
353 * VOP_FPLOOKUP_VEXEC routines are subject to special circumstances, see
354 * the comment above cache_fplookup for details.
357 tmpfs_fplookup_vexec(struct vop_fplookup_vexec_args *v)
360 struct tmpfs_node *node;
365 node = VP_TO_TMPFS_NODE_SMR(vp);
366 if (__predict_false(node == NULL))
369 all_x = S_IXUSR | S_IXGRP | S_IXOTH;
370 mode = atomic_load_short(&node->tn_mode);
371 if (__predict_true((mode & all_x) == all_x))
375 return (vaccess_vexec_smr(mode, node->tn_uid, node->tn_gid, cred));
379 tmpfs_access(struct vop_access_args *v)
381 struct vnode *vp = v->a_vp;
382 accmode_t accmode = v->a_accmode;
383 struct ucred *cred = v->a_cred;
384 mode_t all_x = S_IXUSR | S_IXGRP | S_IXOTH;
386 struct tmpfs_node *node;
388 MPASS(VOP_ISLOCKED(vp));
390 node = VP_TO_TMPFS_NODE(vp);
393 * Common case path lookup.
395 if (__predict_true(accmode == VEXEC && (node->tn_mode & all_x) == all_x))
398 switch (vp->v_type) {
404 if (accmode & VWRITE && vp->v_mount->mnt_flag & MNT_RDONLY) {
424 if (accmode & VWRITE && node->tn_flags & IMMUTABLE) {
429 error = vaccess(vp->v_type, node->tn_mode, node->tn_uid, node->tn_gid,
433 MPASS(VOP_ISLOCKED(vp));
439 tmpfs_stat(struct vop_stat_args *v)
441 struct vnode *vp = v->a_vp;
442 struct stat *sb = v->a_sb;
444 struct tmpfs_node *node;
447 node = VP_TO_TMPFS_NODE(vp);
449 tmpfs_update_getattr(vp);
451 error = vop_stat_helper_pre(v);
452 if (__predict_false(error))
455 sb->st_dev = vp->v_mount->mnt_stat.f_fsid.val[0];
456 sb->st_ino = node->tn_id;
457 sb->st_mode = node->tn_mode | VTTOIF(vp->v_type);
458 sb->st_nlink = node->tn_links;
459 sb->st_uid = node->tn_uid;
460 sb->st_gid = node->tn_gid;
461 sb->st_rdev = (vp->v_type == VBLK || vp->v_type == VCHR) ?
462 node->tn_rdev : NODEV;
463 sb->st_size = node->tn_size;
464 sb->st_atim.tv_sec = node->tn_atime.tv_sec;
465 sb->st_atim.tv_nsec = node->tn_atime.tv_nsec;
466 sb->st_mtim.tv_sec = node->tn_mtime.tv_sec;
467 sb->st_mtim.tv_nsec = node->tn_mtime.tv_nsec;
468 sb->st_ctim.tv_sec = node->tn_ctime.tv_sec;
469 sb->st_ctim.tv_nsec = node->tn_ctime.tv_nsec;
470 sb->st_birthtim.tv_sec = node->tn_birthtime.tv_sec;
471 sb->st_birthtim.tv_nsec = node->tn_birthtime.tv_nsec;
472 sb->st_blksize = PAGE_SIZE;
473 sb->st_flags = node->tn_flags;
474 sb->st_gen = node->tn_gen;
475 if (vp->v_type == VREG) {
476 obj = node->tn_reg.tn_aobj;
477 sb->st_blocks = (u_quad_t)obj->resident_page_count * PAGE_SIZE;
479 sb->st_blocks = node->tn_size;
480 sb->st_blocks /= S_BLKSIZE;
481 return (vop_stat_helper_post(v, error));
485 tmpfs_getattr(struct vop_getattr_args *v)
487 struct vnode *vp = v->a_vp;
488 struct vattr *vap = v->a_vap;
490 struct tmpfs_node *node;
492 node = VP_TO_TMPFS_NODE(vp);
494 tmpfs_update_getattr(vp);
496 vap->va_type = vp->v_type;
497 vap->va_mode = node->tn_mode;
498 vap->va_nlink = node->tn_links;
499 vap->va_uid = node->tn_uid;
500 vap->va_gid = node->tn_gid;
501 vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
502 vap->va_fileid = node->tn_id;
503 vap->va_size = node->tn_size;
504 vap->va_blocksize = PAGE_SIZE;
505 vap->va_atime = node->tn_atime;
506 vap->va_mtime = node->tn_mtime;
507 vap->va_ctime = node->tn_ctime;
508 vap->va_birthtime = node->tn_birthtime;
509 vap->va_gen = node->tn_gen;
510 vap->va_flags = node->tn_flags;
511 vap->va_rdev = (vp->v_type == VBLK || vp->v_type == VCHR) ?
512 node->tn_rdev : NODEV;
513 if (vp->v_type == VREG) {
514 obj = node->tn_reg.tn_aobj;
515 vap->va_bytes = (u_quad_t)obj->resident_page_count * PAGE_SIZE;
517 vap->va_bytes = node->tn_size;
524 tmpfs_setattr(struct vop_setattr_args *v)
526 struct vnode *vp = v->a_vp;
527 struct vattr *vap = v->a_vap;
528 struct ucred *cred = v->a_cred;
529 struct thread *td = curthread;
533 MPASS(VOP_ISLOCKED(vp));
534 ASSERT_VOP_IN_SEQC(vp);
538 /* Abort if any unsettable attribute is given. */
539 if (vap->va_type != VNON ||
540 vap->va_nlink != VNOVAL ||
541 vap->va_fsid != VNOVAL ||
542 vap->va_fileid != VNOVAL ||
543 vap->va_blocksize != VNOVAL ||
544 vap->va_gen != VNOVAL ||
545 vap->va_rdev != VNOVAL ||
546 vap->va_bytes != VNOVAL)
549 if (error == 0 && (vap->va_flags != VNOVAL))
550 error = tmpfs_chflags(vp, vap->va_flags, cred, td);
552 if (error == 0 && (vap->va_size != VNOVAL))
553 error = tmpfs_chsize(vp, vap->va_size, cred, td);
555 if (error == 0 && (vap->va_uid != VNOVAL || vap->va_gid != VNOVAL))
556 error = tmpfs_chown(vp, vap->va_uid, vap->va_gid, cred, td);
558 if (error == 0 && (vap->va_mode != (mode_t)VNOVAL))
559 error = tmpfs_chmod(vp, vap->va_mode, cred, td);
561 if (error == 0 && ((vap->va_atime.tv_sec != VNOVAL &&
562 vap->va_atime.tv_nsec != VNOVAL) ||
563 (vap->va_mtime.tv_sec != VNOVAL &&
564 vap->va_mtime.tv_nsec != VNOVAL) ||
565 (vap->va_birthtime.tv_sec != VNOVAL &&
566 vap->va_birthtime.tv_nsec != VNOVAL)))
567 error = tmpfs_chtimes(vp, vap, cred, td);
570 * Update the node times. We give preference to the error codes
571 * generated by this function rather than the ones that may arise
576 MPASS(VOP_ISLOCKED(vp));
582 tmpfs_read(struct vop_read_args *v)
586 struct tmpfs_node *node;
589 if (vp->v_type != VREG)
592 if (uio->uio_offset < 0)
594 node = VP_TO_TMPFS_NODE(vp);
595 tmpfs_set_accessed(VFS_TO_TMPFS(vp->v_mount), node);
596 return (uiomove_object(node->tn_reg.tn_aobj, node->tn_size, uio));
600 tmpfs_read_pgcache(struct vop_read_pgcache_args *v)
603 struct tmpfs_node *node;
609 VNPASS((vn_irflag_read(vp) & VIRF_PGREAD) != 0, vp);
611 if (v->a_uio->uio_offset < 0)
617 node = VP_TO_TMPFS_NODE_SMR(vp);
620 MPASS(node->tn_type == VREG);
621 MPASS(node->tn_refcount >= 1);
622 object = node->tn_reg.tn_aobj;
626 MPASS((object->flags & (OBJ_ANON | OBJ_DEAD | OBJ_TMPFS_NODE)) ==
628 if (!VN_IS_DOOMED(vp)) {
629 /* size cannot become shorter due to rangelock. */
630 size = node->tn_size;
631 tmpfs_set_accessed(node->tn_reg.tn_tmp, node);
633 error = uiomove_object(object, size, v->a_uio);
642 tmpfs_write(struct vop_write_args *v)
646 struct tmpfs_node *node;
653 ioflag = v->a_ioflag;
655 node = VP_TO_TMPFS_NODE(vp);
656 oldsize = node->tn_size;
658 if (uio->uio_offset < 0 || vp->v_type != VREG)
660 if (uio->uio_resid == 0)
662 if (ioflag & IO_APPEND)
663 uio->uio_offset = node->tn_size;
664 if (uio->uio_offset + uio->uio_resid >
665 VFS_TO_TMPFS(vp->v_mount)->tm_maxfilesize)
667 if (vn_rlimit_fsize(vp, uio, uio->uio_td))
669 if (uio->uio_offset + uio->uio_resid > node->tn_size) {
670 error = tmpfs_reg_resize(vp, uio->uio_offset + uio->uio_resid,
676 error = uiomove_object(node->tn_reg.tn_aobj, node->tn_size, uio);
677 node->tn_status |= TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED;
678 node->tn_accessed = true;
679 if (node->tn_mode & (S_ISUID | S_ISGID)) {
680 if (priv_check_cred(v->a_cred, PRIV_VFS_RETAINSUGID)) {
681 newmode = node->tn_mode & ~(S_ISUID | S_ISGID);
682 vn_seqc_write_begin(vp);
683 atomic_store_short(&node->tn_mode, newmode);
684 vn_seqc_write_end(vp);
688 (void)tmpfs_reg_resize(vp, oldsize, TRUE);
691 MPASS(IMPLIES(error == 0, uio->uio_resid == 0));
692 MPASS(IMPLIES(error != 0, oldsize == node->tn_size));
698 tmpfs_fsync(struct vop_fsync_args *v)
700 struct vnode *vp = v->a_vp;
702 MPASS(VOP_ISLOCKED(vp));
704 tmpfs_check_mtime(vp);
711 tmpfs_remove(struct vop_remove_args *v)
713 struct vnode *dvp = v->a_dvp;
714 struct vnode *vp = v->a_vp;
717 struct tmpfs_dirent *de;
718 struct tmpfs_mount *tmp;
719 struct tmpfs_node *dnode;
720 struct tmpfs_node *node;
722 MPASS(VOP_ISLOCKED(dvp));
723 MPASS(VOP_ISLOCKED(vp));
725 if (vp->v_type == VDIR) {
730 dnode = VP_TO_TMPFS_DIR(dvp);
731 node = VP_TO_TMPFS_NODE(vp);
732 tmp = VFS_TO_TMPFS(vp->v_mount);
733 de = tmpfs_dir_lookup(dnode, node, v->a_cnp);
736 /* Files marked as immutable or append-only cannot be deleted. */
737 if ((node->tn_flags & (IMMUTABLE | APPEND | NOUNLINK)) ||
738 (dnode->tn_flags & APPEND)) {
743 /* Remove the entry from the directory; as it is a file, we do not
744 * have to change the number of hard links of the directory. */
745 tmpfs_dir_detach(dvp, de);
746 if (v->a_cnp->cn_flags & DOWHITEOUT)
747 tmpfs_dir_whiteout_add(dvp, v->a_cnp);
749 /* Free the directory entry we just deleted. Note that the node
750 * referred by it will not be removed until the vnode is really
752 tmpfs_free_dirent(tmp, de);
754 node->tn_status |= TMPFS_NODE_CHANGED;
755 node->tn_accessed = true;
763 tmpfs_link(struct vop_link_args *v)
765 struct vnode *dvp = v->a_tdvp;
766 struct vnode *vp = v->a_vp;
767 struct componentname *cnp = v->a_cnp;
770 struct tmpfs_dirent *de;
771 struct tmpfs_node *node;
773 MPASS(VOP_ISLOCKED(dvp));
774 MPASS(cnp->cn_flags & HASBUF);
775 MPASS(dvp != vp); /* XXX When can this be false? */
776 node = VP_TO_TMPFS_NODE(vp);
778 /* Ensure that we do not overflow the maximum number of links imposed
780 MPASS(node->tn_links <= TMPFS_LINK_MAX);
781 if (node->tn_links == TMPFS_LINK_MAX) {
786 /* We cannot create links of files marked immutable or append-only. */
787 if (node->tn_flags & (IMMUTABLE | APPEND)) {
792 /* Allocate a new directory entry to represent the node. */
793 error = tmpfs_alloc_dirent(VFS_TO_TMPFS(vp->v_mount), node,
794 cnp->cn_nameptr, cnp->cn_namelen, &de);
798 /* Insert the new directory entry into the appropriate directory. */
799 if (cnp->cn_flags & ISWHITEOUT)
800 tmpfs_dir_whiteout_remove(dvp, cnp);
801 tmpfs_dir_attach(dvp, de);
803 /* vp link count has changed, so update node times. */
804 node->tn_status |= TMPFS_NODE_CHANGED;
814 * We acquire all but fdvp locks using non-blocking acquisitions. If we
815 * fail to acquire any lock in the path we will drop all held locks,
816 * acquire the new lock in a blocking fashion, and then release it and
817 * restart the rename. This acquire/release step ensures that we do not
818 * spin on a lock waiting for release. On error release all vnode locks
819 * and decrement references the way tmpfs_rename() would do.
822 tmpfs_rename_relock(struct vnode *fdvp, struct vnode **fvpp,
823 struct vnode *tdvp, struct vnode **tvpp,
824 struct componentname *fcnp, struct componentname *tcnp)
828 struct tmpfs_dirent *de;
829 int error, restarts = 0;
832 if (*tvpp != NULL && *tvpp != tdvp)
838 error = vn_lock(fdvp, LK_EXCLUSIVE);
841 if (vn_lock(tdvp, LK_EXCLUSIVE | LK_NOWAIT) != 0) {
843 error = vn_lock(tdvp, LK_EXCLUSIVE);
850 * Re-resolve fvp to be certain it still exists and fetch the
853 de = tmpfs_dir_lookup(VP_TO_TMPFS_DIR(fdvp), NULL, fcnp);
857 if ((fcnp->cn_flags & ISDOTDOT) != 0 ||
858 (fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.'))
864 error = tmpfs_alloc_vp(mp, de->td_node, LK_EXCLUSIVE | LK_NOWAIT, &nvp);
870 error = tmpfs_alloc_vp(mp, de->td_node, LK_EXCLUSIVE, &nvp);
875 * Concurrent rename race.
890 * Re-resolve tvp and acquire the vnode lock if present.
892 de = tmpfs_dir_lookup(VP_TO_TMPFS_DIR(tdvp), NULL, tcnp);
894 * If tvp disappeared we just carry on.
896 if (de == NULL && *tvpp != NULL) {
901 * Get the tvp ino if the lookup succeeded. We may have to restart
902 * if the non-blocking acquire fails.
906 error = tmpfs_alloc_vp(mp, de->td_node,
907 LK_EXCLUSIVE | LK_NOWAIT, &nvp);
916 error = tmpfs_alloc_vp(mp, de->td_node, LK_EXCLUSIVE,
922 * fdvp contains fvp, thus tvp (=fdvp) is not empty.
931 tmpfs_rename_restarts += restarts;
941 tmpfs_rename_restarts += restarts;
947 tmpfs_rename(struct vop_rename_args *v)
949 struct vnode *fdvp = v->a_fdvp;
950 struct vnode *fvp = v->a_fvp;
951 struct componentname *fcnp = v->a_fcnp;
952 struct vnode *tdvp = v->a_tdvp;
953 struct vnode *tvp = v->a_tvp;
954 struct componentname *tcnp = v->a_tcnp;
956 struct tmpfs_dirent *de;
957 struct tmpfs_mount *tmp;
958 struct tmpfs_node *fdnode;
959 struct tmpfs_node *fnode;
960 struct tmpfs_node *tnode;
961 struct tmpfs_node *tdnode;
965 MPASS(VOP_ISLOCKED(tdvp));
966 MPASS(IMPLIES(tvp != NULL, VOP_ISLOCKED(tvp)));
967 MPASS(fcnp->cn_flags & HASBUF);
968 MPASS(tcnp->cn_flags & HASBUF);
970 want_seqc_end = false;
973 * Disallow cross-device renames.
974 * XXX Why isn't this done by the caller?
976 if (fvp->v_mount != tdvp->v_mount ||
977 (tvp != NULL && fvp->v_mount != tvp->v_mount)) {
982 /* If source and target are the same file, there is nothing to do. */
989 * If we need to move the directory between entries, lock the
990 * source so that we can safely operate on it.
992 if (fdvp != tdvp && fdvp != tvp) {
993 if (vn_lock(fdvp, LK_EXCLUSIVE | LK_NOWAIT) != 0) {
994 error = tmpfs_rename_relock(fdvp, &fvp, tdvp, &tvp,
998 ASSERT_VOP_ELOCKED(fdvp,
999 "tmpfs_rename: fdvp not locked");
1000 ASSERT_VOP_ELOCKED(tdvp,
1001 "tmpfs_rename: tdvp not locked");
1003 ASSERT_VOP_ELOCKED(tvp,
1004 "tmpfs_rename: tvp not locked");
1013 vn_seqc_write_begin(tvp);
1014 vn_seqc_write_begin(tdvp);
1015 vn_seqc_write_begin(fvp);
1016 vn_seqc_write_begin(fdvp);
1017 want_seqc_end = true;
1019 tmp = VFS_TO_TMPFS(tdvp->v_mount);
1020 tdnode = VP_TO_TMPFS_DIR(tdvp);
1021 tnode = (tvp == NULL) ? NULL : VP_TO_TMPFS_NODE(tvp);
1022 fdnode = VP_TO_TMPFS_DIR(fdvp);
1023 fnode = VP_TO_TMPFS_NODE(fvp);
1024 de = tmpfs_dir_lookup(fdnode, fnode, fcnp);
1027 * Entry can disappear before we lock fdvp,
1028 * also avoid manipulating '.' and '..' entries.
1031 if ((fcnp->cn_flags & ISDOTDOT) != 0 ||
1032 (fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.'))
1038 MPASS(de->td_node == fnode);
1041 * If re-naming a directory to another preexisting directory
1042 * ensure that the target directory is empty so that its
1043 * removal causes no side effects.
1044 * Kern_rename guarantees the destination to be a directory
1045 * if the source is one.
1048 MPASS(tnode != NULL);
1050 if ((tnode->tn_flags & (NOUNLINK | IMMUTABLE | APPEND)) ||
1051 (tdnode->tn_flags & (APPEND | IMMUTABLE))) {
1056 if (fnode->tn_type == VDIR && tnode->tn_type == VDIR) {
1057 if (tnode->tn_size > 0) {
1061 } else if (fnode->tn_type == VDIR && tnode->tn_type != VDIR) {
1064 } else if (fnode->tn_type != VDIR && tnode->tn_type == VDIR) {
1068 MPASS(fnode->tn_type != VDIR &&
1069 tnode->tn_type != VDIR);
1073 if ((fnode->tn_flags & (NOUNLINK | IMMUTABLE | APPEND))
1074 || (fdnode->tn_flags & (APPEND | IMMUTABLE))) {
1080 * Ensure that we have enough memory to hold the new name, if it
1081 * has to be changed.
1083 if (fcnp->cn_namelen != tcnp->cn_namelen ||
1084 bcmp(fcnp->cn_nameptr, tcnp->cn_nameptr, fcnp->cn_namelen) != 0) {
1085 newname = malloc(tcnp->cn_namelen, M_TMPFSNAME, M_WAITOK);
1090 * If the node is being moved to another directory, we have to do
1093 if (fdnode != tdnode) {
1095 * In case we are moving a directory, we have to adjust its
1096 * parent to point to the new parent.
1098 if (de->td_node->tn_type == VDIR) {
1099 struct tmpfs_node *n;
1102 * Ensure the target directory is not a child of the
1103 * directory being moved. Otherwise, we'd end up
1108 * TMPFS_LOCK guaranties that no nodes are freed while
1109 * traversing the list. Nodes can only be marked as
1110 * removed: tn_parent == NULL.
1114 while (n != n->tn_dir.tn_parent) {
1115 struct tmpfs_node *parent;
1118 TMPFS_NODE_UNLOCK(n);
1121 if (newname != NULL)
1122 free(newname, M_TMPFSNAME);
1125 parent = n->tn_dir.tn_parent;
1126 TMPFS_NODE_UNLOCK(n);
1127 if (parent == NULL) {
1131 TMPFS_NODE_LOCK(parent);
1132 if (parent->tn_dir.tn_parent == NULL) {
1133 TMPFS_NODE_UNLOCK(parent);
1142 if (newname != NULL)
1143 free(newname, M_TMPFSNAME);
1146 TMPFS_NODE_UNLOCK(n);
1148 /* Adjust the parent pointer. */
1149 TMPFS_VALIDATE_DIR(fnode);
1150 TMPFS_NODE_LOCK(de->td_node);
1151 de->td_node->tn_dir.tn_parent = tdnode;
1152 TMPFS_NODE_UNLOCK(de->td_node);
1155 * As a result of changing the target of the '..'
1156 * entry, the link count of the source and target
1157 * directories has to be adjusted.
1159 TMPFS_NODE_LOCK(tdnode);
1160 TMPFS_ASSERT_LOCKED(tdnode);
1162 TMPFS_NODE_UNLOCK(tdnode);
1164 TMPFS_NODE_LOCK(fdnode);
1165 TMPFS_ASSERT_LOCKED(fdnode);
1167 TMPFS_NODE_UNLOCK(fdnode);
1172 * Do the move: just remove the entry from the source directory
1173 * and insert it into the target one.
1175 tmpfs_dir_detach(fdvp, de);
1177 if (fcnp->cn_flags & DOWHITEOUT)
1178 tmpfs_dir_whiteout_add(fdvp, fcnp);
1179 if (tcnp->cn_flags & ISWHITEOUT)
1180 tmpfs_dir_whiteout_remove(tdvp, tcnp);
1183 * If the name has changed, we need to make it effective by changing
1184 * it in the directory entry.
1186 if (newname != NULL) {
1187 MPASS(tcnp->cn_namelen <= MAXNAMLEN);
1189 free(de->ud.td_name, M_TMPFSNAME);
1190 de->ud.td_name = newname;
1191 tmpfs_dirent_init(de, tcnp->cn_nameptr, tcnp->cn_namelen);
1193 fnode->tn_status |= TMPFS_NODE_CHANGED;
1194 tdnode->tn_status |= TMPFS_NODE_MODIFIED;
1198 * If we are overwriting an entry, we have to remove the old one
1199 * from the target directory.
1202 struct tmpfs_dirent *tde;
1204 /* Remove the old entry from the target directory. */
1205 tde = tmpfs_dir_lookup(tdnode, tnode, tcnp);
1206 tmpfs_dir_detach(tdvp, tde);
1209 * Free the directory entry we just deleted. Note that the
1210 * node referred by it will not be removed until the vnode is
1213 tmpfs_free_dirent(VFS_TO_TMPFS(tvp->v_mount), tde);
1216 tmpfs_dir_attach(tdvp, de);
1218 if (tmpfs_use_nc(fvp)) {
1219 cache_vop_rename(fdvp, fvp, tdvp, tvp, fcnp, tcnp);
1225 if (fdvp != tdvp && fdvp != tvp)
1229 if (want_seqc_end) {
1231 vn_seqc_write_end(tvp);
1232 vn_seqc_write_end(tdvp);
1233 vn_seqc_write_end(fvp);
1234 vn_seqc_write_end(fdvp);
1238 * Release target nodes.
1239 * XXX: I don't understand when tdvp can be the same as tvp, but
1240 * other code takes care of this...
1249 /* Release source nodes. */
1257 tmpfs_mkdir(struct vop_mkdir_args *v)
1259 struct vnode *dvp = v->a_dvp;
1260 struct vnode **vpp = v->a_vpp;
1261 struct componentname *cnp = v->a_cnp;
1262 struct vattr *vap = v->a_vap;
1264 MPASS(vap->va_type == VDIR);
1266 return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL);
1270 tmpfs_rmdir(struct vop_rmdir_args *v)
1272 struct vnode *dvp = v->a_dvp;
1273 struct vnode *vp = v->a_vp;
1276 struct tmpfs_dirent *de;
1277 struct tmpfs_mount *tmp;
1278 struct tmpfs_node *dnode;
1279 struct tmpfs_node *node;
1281 MPASS(VOP_ISLOCKED(dvp));
1282 MPASS(VOP_ISLOCKED(vp));
1284 tmp = VFS_TO_TMPFS(dvp->v_mount);
1285 dnode = VP_TO_TMPFS_DIR(dvp);
1286 node = VP_TO_TMPFS_DIR(vp);
1288 /* Directories with more than two entries ('.' and '..') cannot be
1290 if (node->tn_size > 0) {
1295 if ((dnode->tn_flags & APPEND)
1296 || (node->tn_flags & (NOUNLINK | IMMUTABLE | APPEND))) {
1301 /* This invariant holds only if we are not trying to remove "..".
1302 * We checked for that above so this is safe now. */
1303 MPASS(node->tn_dir.tn_parent == dnode);
1305 /* Get the directory entry associated with node (vp). This was
1306 * filled by tmpfs_lookup while looking up the entry. */
1307 de = tmpfs_dir_lookup(dnode, node, v->a_cnp);
1308 MPASS(TMPFS_DIRENT_MATCHES(de,
1309 v->a_cnp->cn_nameptr,
1310 v->a_cnp->cn_namelen));
1312 /* Check flags to see if we are allowed to remove the directory. */
1313 if ((dnode->tn_flags & APPEND) != 0 ||
1314 (node->tn_flags & (NOUNLINK | IMMUTABLE | APPEND)) != 0) {
1319 /* Detach the directory entry from the directory (dnode). */
1320 tmpfs_dir_detach(dvp, de);
1321 if (v->a_cnp->cn_flags & DOWHITEOUT)
1322 tmpfs_dir_whiteout_add(dvp, v->a_cnp);
1324 /* No vnode should be allocated for this entry from this point */
1325 TMPFS_NODE_LOCK(node);
1327 node->tn_dir.tn_parent = NULL;
1328 node->tn_status |= TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED;
1329 node->tn_accessed = true;
1331 TMPFS_NODE_UNLOCK(node);
1333 TMPFS_NODE_LOCK(dnode);
1335 dnode->tn_status |= TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED;
1336 dnode->tn_accessed = true;
1337 TMPFS_NODE_UNLOCK(dnode);
1339 if (tmpfs_use_nc(dvp)) {
1340 cache_vop_rmdir(dvp, vp);
1343 /* Free the directory entry we just deleted. Note that the node
1344 * referred by it will not be removed until the vnode is really
1346 tmpfs_free_dirent(tmp, de);
1348 /* Release the deleted vnode (will destroy the node, notify
1349 * interested parties and clean it from the cache). */
1351 dnode->tn_status |= TMPFS_NODE_CHANGED;
1361 tmpfs_symlink(struct vop_symlink_args *v)
1363 struct vnode *dvp = v->a_dvp;
1364 struct vnode **vpp = v->a_vpp;
1365 struct componentname *cnp = v->a_cnp;
1366 struct vattr *vap = v->a_vap;
1367 const char *target = v->a_target;
1369 #ifdef notyet /* XXX FreeBSD BUG: kern_symlink is not setting VLNK */
1370 MPASS(vap->va_type == VLNK);
1372 vap->va_type = VLNK;
1375 return tmpfs_alloc_file(dvp, vpp, vap, cnp, target);
1379 tmpfs_readdir(struct vop_readdir_args *va)
1383 struct tmpfs_mount *tm;
1384 struct tmpfs_node *node;
1386 int *eofflag, *ncookies;
1388 int error, maxcookies;
1392 eofflag = va->a_eofflag;
1393 cookies = va->a_cookies;
1394 ncookies = va->a_ncookies;
1396 /* This operation only makes sense on directory nodes. */
1397 if (vp->v_type != VDIR)
1401 node = VP_TO_TMPFS_DIR(vp);
1402 tm = VFS_TO_TMPFS(vp->v_mount);
1404 startresid = uio->uio_resid;
1406 /* Allocate cookies for NFS and compat modules. */
1407 if (cookies != NULL && ncookies != NULL) {
1408 maxcookies = howmany(node->tn_size,
1409 sizeof(struct tmpfs_dirent)) + 2;
1410 *cookies = malloc(maxcookies * sizeof(**cookies), M_TEMP,
1415 if (cookies == NULL)
1416 error = tmpfs_dir_getdents(tm, node, uio, 0, NULL, NULL);
1418 error = tmpfs_dir_getdents(tm, node, uio, maxcookies, *cookies,
1421 /* Buffer was filled without hitting EOF. */
1422 if (error == EJUSTRETURN)
1423 error = (uio->uio_resid != startresid) ? 0 : EINVAL;
1425 if (error != 0 && cookies != NULL && ncookies != NULL) {
1426 free(*cookies, M_TEMP);
1431 if (eofflag != NULL)
1433 (error == 0 && uio->uio_offset == TMPFS_DIRCOOKIE_EOF);
1439 tmpfs_readlink(struct vop_readlink_args *v)
1441 struct vnode *vp = v->a_vp;
1442 struct uio *uio = v->a_uio;
1445 struct tmpfs_node *node;
1447 MPASS(uio->uio_offset == 0);
1448 MPASS(vp->v_type == VLNK);
1450 node = VP_TO_TMPFS_NODE(vp);
1452 error = uiomove(node->tn_link_target, MIN(node->tn_size, uio->uio_resid),
1454 tmpfs_set_accessed(VFS_TO_TMPFS(vp->v_mount), node);
1460 * VOP_FPLOOKUP_SYMLINK routines are subject to special circumstances, see
1461 * the comment above cache_fplookup for details.
1463 * Check tmpfs_alloc_node for tmpfs-specific synchronisation notes.
1466 tmpfs_fplookup_symlink(struct vop_fplookup_symlink_args *v)
1469 struct tmpfs_node *node;
1473 node = VP_TO_TMPFS_NODE_SMR(vp);
1474 if (__predict_false(node == NULL))
1476 if (!atomic_load_char(&node->tn_link_smr))
1478 symlink = atomic_load_ptr(&node->tn_link_target);
1479 if (symlink == NULL)
1482 return (cache_symlink_resolve(v->a_fpl, symlink, node->tn_size));
1486 tmpfs_inactive(struct vop_inactive_args *v)
1489 struct tmpfs_node *node;
1492 node = VP_TO_TMPFS_NODE(vp);
1493 if (node->tn_links == 0)
1496 tmpfs_check_mtime(vp);
1501 tmpfs_need_inactive(struct vop_need_inactive_args *ap)
1504 struct tmpfs_node *node;
1505 struct vm_object *obj;
1508 node = VP_TO_TMPFS_NODE(vp);
1509 if (node->tn_links == 0)
1511 if (vp->v_type == VREG) {
1513 if (obj->generation != obj->cleangeneration)
1522 tmpfs_reclaim(struct vop_reclaim_args *v)
1525 struct tmpfs_mount *tmp;
1526 struct tmpfs_node *node;
1527 bool unlock, tm_locked;
1530 node = VP_TO_TMPFS_NODE(vp);
1531 tmp = VFS_TO_TMPFS(vp->v_mount);
1534 if (vp->v_type == VREG)
1535 tmpfs_destroy_vobject(vp, node->tn_reg.tn_aobj);
1536 vp->v_object = NULL;
1539 TMPFS_NODE_LOCK(node);
1540 if (!tm_locked && node->tn_links == 0 &&
1541 (node->tn_vpstate & TMPFS_VNODE_ALLOCATING) == 0) {
1542 TMPFS_NODE_UNLOCK(node);
1550 * If the node referenced by this vnode was deleted by the user,
1551 * we must free its associated data structures (now that the vnode
1552 * is being reclaimed).
1554 if (node->tn_links == 0 &&
1555 (node->tn_vpstate & TMPFS_VNODE_ALLOCATING) == 0) {
1557 node->tn_vpstate = TMPFS_VNODE_DOOMED;
1558 unlock = !tmpfs_free_node_locked(tmp, node, true);
1564 TMPFS_NODE_UNLOCK(node);
1569 MPASS(vp->v_data == NULL);
1574 tmpfs_print(struct vop_print_args *v)
1576 struct vnode *vp = v->a_vp;
1578 struct tmpfs_node *node;
1580 node = VP_TO_TMPFS_NODE(vp);
1582 printf("tag VT_TMPFS, tmpfs_node %p, flags 0x%lx, links %jd\n",
1583 node, node->tn_flags, (uintmax_t)node->tn_links);
1584 printf("\tmode 0%o, owner %d, group %d, size %jd, status 0x%x\n",
1585 node->tn_mode, node->tn_uid, node->tn_gid,
1586 (intmax_t)node->tn_size, node->tn_status);
1588 if (vp->v_type == VFIFO)
1597 tmpfs_pathconf(struct vop_pathconf_args *v)
1599 struct vnode *vp = v->a_vp;
1600 int name = v->a_name;
1601 long *retval = v->a_retval;
1609 *retval = TMPFS_LINK_MAX;
1617 if (vp->v_type == VDIR || vp->v_type == VFIFO)
1623 case _PC_CHOWN_RESTRICTED:
1635 case _PC_FILESIZEBITS:
1640 error = vop_stdpathconf(v);
1647 tmpfs_vptofh(struct vop_vptofh_args *ap)
1650 IN struct vnode *a_vp;
1651 IN struct fid *a_fhp;
1655 struct tmpfs_fid_data tfd;
1656 struct tmpfs_node *node;
1659 node = VP_TO_TMPFS_NODE(ap->a_vp);
1661 fhp->fid_len = sizeof(tfd);
1664 * Copy into fid_data from the stack to avoid unaligned pointer use.
1665 * See the comment in sys/mount.h on struct fid for details.
1667 tfd.tfd_id = node->tn_id;
1668 tfd.tfd_gen = node->tn_gen;
1669 memcpy(fhp->fid_data, &tfd, fhp->fid_len);
1675 tmpfs_whiteout(struct vop_whiteout_args *ap)
1677 struct vnode *dvp = ap->a_dvp;
1678 struct componentname *cnp = ap->a_cnp;
1679 struct tmpfs_dirent *de;
1681 switch (ap->a_flags) {
1685 de = tmpfs_dir_lookup(VP_TO_TMPFS_DIR(dvp), NULL, cnp);
1687 return (de->td_node == NULL ? 0 : EEXIST);
1688 return (tmpfs_dir_whiteout_add(dvp, cnp));
1690 tmpfs_dir_whiteout_remove(dvp, cnp);
1693 panic("tmpfs_whiteout: unknown op");
1698 tmpfs_vptocnp_dir(struct tmpfs_node *tn, struct tmpfs_node *tnp,
1699 struct tmpfs_dirent **pde)
1701 struct tmpfs_dir_cursor dc;
1702 struct tmpfs_dirent *de;
1704 for (de = tmpfs_dir_first(tnp, &dc); de != NULL;
1705 de = tmpfs_dir_next(tnp, &dc)) {
1706 if (de->td_node == tn) {
1715 tmpfs_vptocnp_fill(struct vnode *vp, struct tmpfs_node *tn,
1716 struct tmpfs_node *tnp, char *buf, size_t *buflen, struct vnode **dvp)
1718 struct tmpfs_dirent *de;
1721 error = vn_vget_ino_gen(vp, tmpfs_vn_get_ino_alloc, tnp, LK_SHARED,
1725 error = tmpfs_vptocnp_dir(tn, tnp, &de);
1728 i -= de->td_namelen;
1732 bcopy(de->ud.td_name, buf + i, de->td_namelen);
1749 tmpfs_vptocnp(struct vop_vptocnp_args *ap)
1751 struct vnode *vp, **dvp;
1752 struct tmpfs_node *tn, *tnp, *tnp1;
1753 struct tmpfs_dirent *de;
1754 struct tmpfs_mount *tm;
1762 buflen = ap->a_buflen;
1764 tm = VFS_TO_TMPFS(vp->v_mount);
1765 tn = VP_TO_TMPFS_NODE(vp);
1766 if (tn->tn_type == VDIR) {
1767 tnp = tn->tn_dir.tn_parent;
1770 tmpfs_ref_node(tnp);
1771 error = tmpfs_vptocnp_fill(vp, tn, tn->tn_dir.tn_parent, buf,
1773 tmpfs_free_node(tm, tnp);
1779 LIST_FOREACH_SAFE(tnp, &tm->tm_nodes_used, tn_entries, tnp1) {
1780 if (tnp->tn_type != VDIR)
1782 TMPFS_NODE_LOCK(tnp);
1783 tmpfs_ref_node(tnp);
1786 * tn_vnode cannot be instantiated while we hold the
1787 * node lock, so the directory cannot be changed while
1788 * we iterate over it. Do this to avoid instantiating
1789 * vnode for directories which cannot point to our
1792 error = tnp->tn_vnode == NULL ? tmpfs_vptocnp_dir(tn, tnp,
1796 TMPFS_NODE_UNLOCK(tnp);
1798 error = tmpfs_vptocnp_fill(vp, tn, tnp, buf, buflen,
1801 tmpfs_free_node(tm, tnp);
1804 if (VN_IS_DOOMED(vp)) {
1805 tmpfs_free_node(tm, tnp);
1809 TMPFS_NODE_LOCK(tnp);
1811 if (tmpfs_free_node_locked(tm, tnp, false)) {
1814 KASSERT(tnp->tn_refcount > 0,
1815 ("node %p refcount zero", tnp));
1816 if (tnp->tn_attached) {
1817 tnp1 = LIST_NEXT(tnp, tn_entries);
1818 TMPFS_NODE_UNLOCK(tnp);
1820 TMPFS_NODE_UNLOCK(tnp);
1821 goto restart_locked;
1830 * Vnode operations vector used for files stored in a tmpfs file system.
1832 struct vop_vector tmpfs_vnodeop_entries = {
1833 .vop_default = &default_vnodeops,
1834 .vop_lookup = vfs_cache_lookup,
1835 .vop_cachedlookup = tmpfs_cached_lookup,
1836 .vop_create = tmpfs_create,
1837 .vop_mknod = tmpfs_mknod,
1838 .vop_open = tmpfs_open,
1839 .vop_close = tmpfs_close,
1840 .vop_fplookup_vexec = tmpfs_fplookup_vexec,
1841 .vop_fplookup_symlink = tmpfs_fplookup_symlink,
1842 .vop_access = tmpfs_access,
1843 .vop_stat = tmpfs_stat,
1844 .vop_getattr = tmpfs_getattr,
1845 .vop_setattr = tmpfs_setattr,
1846 .vop_read = tmpfs_read,
1847 .vop_read_pgcache = tmpfs_read_pgcache,
1848 .vop_write = tmpfs_write,
1849 .vop_fsync = tmpfs_fsync,
1850 .vop_remove = tmpfs_remove,
1851 .vop_link = tmpfs_link,
1852 .vop_rename = tmpfs_rename,
1853 .vop_mkdir = tmpfs_mkdir,
1854 .vop_rmdir = tmpfs_rmdir,
1855 .vop_symlink = tmpfs_symlink,
1856 .vop_readdir = tmpfs_readdir,
1857 .vop_readlink = tmpfs_readlink,
1858 .vop_inactive = tmpfs_inactive,
1859 .vop_need_inactive = tmpfs_need_inactive,
1860 .vop_reclaim = tmpfs_reclaim,
1861 .vop_print = tmpfs_print,
1862 .vop_pathconf = tmpfs_pathconf,
1863 .vop_vptofh = tmpfs_vptofh,
1864 .vop_whiteout = tmpfs_whiteout,
1865 .vop_bmap = VOP_EOPNOTSUPP,
1866 .vop_vptocnp = tmpfs_vptocnp,
1867 .vop_lock1 = vop_lock,
1868 .vop_unlock = vop_unlock,
1869 .vop_islocked = vop_islocked,
1871 VFS_VOP_VECTOR_REGISTER(tmpfs_vnodeop_entries);
1874 * Same vector for mounts which do not use namecache.
1876 struct vop_vector tmpfs_vnodeop_nonc_entries = {
1877 .vop_default = &tmpfs_vnodeop_entries,
1878 .vop_lookup = tmpfs_lookup,
1880 VFS_VOP_VECTOR_REGISTER(tmpfs_vnodeop_nonc_entries);