1 /* $NetBSD: ext2fs_vnops.c,v 1.90 2009/10/19 18:41:17 bouyer Exp $ */
4 * Copyright (c) 1982, 1986, 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * @(#)ufs_vnops.c 8.14 (Berkeley) 10/26/94
37 * Modified for ext2fs by Manuel Bouyer.
41 * Copyright (c) 1997 Manuel Bouyer.
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
52 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
53 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
54 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
55 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
56 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
57 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
61 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 * @(#)ufs_vnops.c 8.14 (Berkeley) 10/26/94
64 * Modified for ext2fs by Manuel Bouyer.
67 #include <sys/cdefs.h>
68 __KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.90 2009/10/19 18:41:17 bouyer Exp $");
70 #include <sys/param.h>
71 #include <sys/systm.h>
72 #include <sys/resourcevar.h>
73 #include <sys/kernel.h>
78 #include <sys/mount.h>
79 #include <sys/namei.h>
80 #include <sys/vnode.h>
81 #include <sys/lockf.h>
82 #include <sys/malloc.h>
84 #include <sys/signalvar.h>
85 #include <sys/kauth.h>
87 #include <miscfs/fifofs/fifo.h>
88 #include <miscfs/genfs/genfs.h>
89 #include <miscfs/specfs/specdev.h>
91 #include <ufs/ufs/inode.h>
92 #include <ufs/ufs/ufs_extern.h>
93 #include <ufs/ufs/ufsmount.h>
95 #include <ufs/ext2fs/ext2fs.h>
96 #include <ufs/ext2fs/ext2fs_extern.h>
97 #include <ufs/ext2fs/ext2fs_dir.h>
101 static int ext2fs_chmod(struct vnode
*, int, kauth_cred_t
, struct lwp
*);
102 static int ext2fs_chown(struct vnode
*, uid_t
, gid_t
, kauth_cred_t
,
110 #define SETHIGH(q, h) { \
113 tmp.val[_QUAD_HIGHWORD] = (h); \
116 #define SETLOW(q, l) { \
119 tmp.val[_QUAD_LOWWORD] = (l); \
124 * Create a regular file
127 ext2fs_create(void *v
)
129 struct vop_create_args
/* {
131 struct vnode **a_vpp;
132 struct componentname *a_cnp;
138 ext2fs_makeinode(MAKEIMODE(ap
->a_vap
->va_type
, ap
->a_vap
->va_mode
),
139 ap
->a_dvp
, ap
->a_vpp
, ap
->a_cnp
);
143 VN_KNOTE(ap
->a_dvp
, NOTE_WRITE
);
152 ext2fs_mknod(void *v
)
154 struct vop_mknod_args
/* {
156 struct vnode **a_vpp;
157 struct componentname *a_cnp;
160 struct vattr
*vap
= ap
->a_vap
;
161 struct vnode
**vpp
= ap
->a_vpp
;
167 if ((error
= ext2fs_makeinode(MAKEIMODE(vap
->va_type
, vap
->va_mode
),
168 ap
->a_dvp
, vpp
, ap
->a_cnp
)) != 0)
170 VN_KNOTE(ap
->a_dvp
, NOTE_WRITE
);
172 mp
= (*vpp
)->v_mount
;
174 ip
->i_flag
|= IN_ACCESS
| IN_CHANGE
| IN_UPDATE
;
175 if (vap
->va_rdev
!= VNOVAL
) {
177 * Want to be able to use this to make badblock
178 * inodes, so don't truncate the dev number.
180 ip
->i_din
.e2fs_din
->e2di_rdev
= h2fs32(vap
->va_rdev
);
183 * Remove inode so that it will be reloaded by VFS_VGET and
184 * checked to see if it is an alias of an existing entry in
188 (*vpp
)->v_type
= VNON
;
190 error
= VFS_VGET(mp
, ino
, vpp
);
201 * Just check the APPEND flag.
207 struct vop_open_args
/* {
214 * Files marked append-only must be opened for appending.
216 if ((VTOI(ap
->a_vp
)->i_e2fs_flags
& EXT2_APPEND
) &&
217 (ap
->a_mode
& (FWRITE
| O_APPEND
)) == FWRITE
)
223 ext2fs_check_possible(struct vnode
*vp
, struct inode
*ip
, mode_t mode
)
227 * Disallow write attempts on read-only file systems;
228 * unless the file is a socket, fifo, or a block or
229 * character device resident on the file system.
232 switch (vp
->v_type
) {
236 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
)
244 /* If immutable bit set, nobody gets to write it. */
245 if ((mode
& VWRITE
) && (ip
->i_e2fs_flags
& EXT2_IMMUTABLE
))
252 ext2fs_check_permitted(struct vnode
*vp
, struct inode
*ip
, mode_t mode
,
256 return genfs_can_access(vp
->v_type
, ip
->i_e2fs_mode
& ALLPERMS
,
257 ip
->i_uid
, ip
->i_gid
, mode
, cred
);
261 ext2fs_access(void *v
)
263 struct vop_access_args
/* {
268 struct vnode
*vp
= ap
->a_vp
;
269 struct inode
*ip
= VTOI(vp
);
270 mode_t mode
= ap
->a_mode
;
273 error
= ext2fs_check_possible(vp
, ip
, mode
);
277 error
= ext2fs_check_permitted(vp
, ip
, mode
, ap
->a_cred
);
284 ext2fs_getattr(void *v
)
286 struct vop_getattr_args
/* {
291 struct vnode
*vp
= ap
->a_vp
;
292 struct inode
*ip
= VTOI(vp
);
293 struct vattr
*vap
= ap
->a_vap
;
295 EXT2FS_ITIMES(ip
, NULL
, NULL
, NULL
);
297 * Copy from inode table
299 vap
->va_fsid
= ip
->i_dev
;
300 vap
->va_fileid
= ip
->i_number
;
301 vap
->va_mode
= ip
->i_e2fs_mode
& ALLPERMS
;
302 vap
->va_nlink
= ip
->i_e2fs_nlink
;
303 vap
->va_uid
= ip
->i_uid
;
304 vap
->va_gid
= ip
->i_gid
;
305 vap
->va_rdev
= (dev_t
)fs2h32(ip
->i_din
.e2fs_din
->e2di_rdev
);
306 vap
->va_size
= vp
->v_size
;
307 vap
->va_atime
.tv_sec
= ip
->i_e2fs_atime
;
308 vap
->va_atime
.tv_nsec
= 0;
309 vap
->va_mtime
.tv_sec
= ip
->i_e2fs_mtime
;
310 vap
->va_mtime
.tv_nsec
= 0;
311 vap
->va_ctime
.tv_sec
= ip
->i_e2fs_ctime
;
312 vap
->va_ctime
.tv_nsec
= 0;
313 #ifdef EXT2FS_SYSTEM_FLAGS
314 vap
->va_flags
= (ip
->i_e2fs_flags
& EXT2_APPEND
) ? SF_APPEND
: 0;
315 vap
->va_flags
|= (ip
->i_e2fs_flags
& EXT2_IMMUTABLE
) ? SF_IMMUTABLE
: 0;
317 vap
->va_flags
= (ip
->i_e2fs_flags
& EXT2_APPEND
) ? UF_APPEND
: 0;
318 vap
->va_flags
|= (ip
->i_e2fs_flags
& EXT2_IMMUTABLE
) ? UF_IMMUTABLE
: 0;
320 vap
->va_gen
= ip
->i_e2fs_gen
;
321 /* this doesn't belong here */
322 if (vp
->v_type
== VBLK
)
323 vap
->va_blocksize
= BLKDEV_IOSIZE
;
324 else if (vp
->v_type
== VCHR
)
325 vap
->va_blocksize
= MAXBSIZE
;
327 vap
->va_blocksize
= vp
->v_mount
->mnt_stat
.f_iosize
;
328 vap
->va_bytes
= dbtob((u_quad_t
)ip
->i_e2fs_nblock
);
329 vap
->va_type
= vp
->v_type
;
330 vap
->va_filerev
= ip
->i_modrev
;
335 * Set attribute vnode op. called from several syscalls
338 ext2fs_setattr(void *v
)
340 struct vop_setattr_args
/* {
345 struct vattr
*vap
= ap
->a_vap
;
346 struct vnode
*vp
= ap
->a_vp
;
347 struct inode
*ip
= VTOI(vp
);
348 kauth_cred_t cred
= ap
->a_cred
;
349 struct lwp
*l
= curlwp
;
353 * Check for unsettable attributes.
355 if ((vap
->va_type
!= VNON
) || (vap
->va_nlink
!= (nlink_t
)VNOVAL
) ||
356 (vap
->va_fsid
!= VNOVAL
) || (vap
->va_fileid
!= VNOVAL
) ||
357 (vap
->va_blocksize
!= VNOVAL
) || (vap
->va_rdev
!= VNOVAL
) ||
358 ((int)vap
->va_bytes
!= VNOVAL
) || (vap
->va_gen
!= VNOVAL
)) {
361 if (vap
->va_flags
!= VNOVAL
) {
362 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
)
364 if (kauth_cred_geteuid(cred
) != ip
->i_uid
&&
365 (error
= kauth_authorize_generic(cred
, KAUTH_GENERIC_ISSUSER
,
368 #ifdef EXT2FS_SYSTEM_FLAGS
369 if (kauth_authorize_generic(cred
, KAUTH_GENERIC_ISSUSER
,
371 if ((ip
->i_e2fs_flags
&
372 (EXT2_APPEND
| EXT2_IMMUTABLE
)) &&
373 kauth_authorize_system(l
->l_cred
,
374 KAUTH_SYSTEM_CHSYSFLAGS
, 0, NULL
, NULL
, NULL
))
376 ip
->i_e2fs_flags
&= ~(EXT2_APPEND
| EXT2_IMMUTABLE
);
378 (vap
->va_flags
& SF_APPEND
) ? EXT2_APPEND
: 0 |
379 (vap
->va_flags
& SF_IMMUTABLE
) ? EXT2_IMMUTABLE
: 0;
383 ip
->i_e2fs_flags
&= ~(EXT2_APPEND
| EXT2_IMMUTABLE
);
385 (vap
->va_flags
& UF_APPEND
) ? EXT2_APPEND
: 0 |
386 (vap
->va_flags
& UF_IMMUTABLE
) ? EXT2_IMMUTABLE
: 0;
388 ip
->i_flag
|= IN_CHANGE
;
389 if (vap
->va_flags
& (IMMUTABLE
| APPEND
))
392 if (ip
->i_e2fs_flags
& (EXT2_APPEND
| EXT2_IMMUTABLE
))
395 * Go through the fields and update iff not VNOVAL.
397 if (vap
->va_uid
!= (uid_t
)VNOVAL
|| vap
->va_gid
!= (gid_t
)VNOVAL
) {
398 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
)
400 error
= ext2fs_chown(vp
, vap
->va_uid
, vap
->va_gid
, cred
, l
);
404 if (vap
->va_size
!= VNOVAL
) {
406 * Disallow write attempts on read-only file systems;
407 * unless the file is a socket, fifo, or a block or
408 * character device resident on the file system.
410 switch (vp
->v_type
) {
415 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
)
420 error
= ext2fs_truncate(vp
, vap
->va_size
, 0, cred
);
425 if (vap
->va_atime
.tv_sec
!= VNOVAL
|| vap
->va_mtime
.tv_sec
!= VNOVAL
) {
426 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
)
428 error
= genfs_can_chtimes(vp
, vap
->va_vaflags
, ip
->i_uid
, cred
);
431 if (vap
->va_atime
.tv_sec
!= VNOVAL
)
432 if (!(vp
->v_mount
->mnt_flag
& MNT_NOATIME
))
433 ip
->i_flag
|= IN_ACCESS
;
434 if (vap
->va_mtime
.tv_sec
!= VNOVAL
)
435 ip
->i_flag
|= IN_CHANGE
| IN_UPDATE
;
436 error
= ext2fs_update(vp
, &vap
->va_atime
, &vap
->va_mtime
,
442 if (vap
->va_mode
!= (mode_t
)VNOVAL
) {
443 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
)
445 error
= ext2fs_chmod(vp
, (int)vap
->va_mode
, cred
, l
);
447 VN_KNOTE(vp
, NOTE_ATTRIB
);
452 * Change the mode on a file.
453 * Inode must be locked before calling.
456 ext2fs_chmod(struct vnode
*vp
, int mode
, kauth_cred_t cred
, struct lwp
*l
)
458 struct inode
*ip
= VTOI(vp
);
461 error
= genfs_can_chmod(vp
, cred
, ip
->i_uid
, ip
->i_gid
, mode
);
465 ip
->i_e2fs_mode
&= ~ALLPERMS
;
466 ip
->i_e2fs_mode
|= (mode
& ALLPERMS
);
467 ip
->i_flag
|= IN_CHANGE
;
472 * Perform chown operation on inode ip;
473 * inode must be locked prior to call.
476 ext2fs_chown(struct vnode
*vp
, uid_t uid
, gid_t gid
, kauth_cred_t cred
,
479 struct inode
*ip
= VTOI(vp
);
484 if (uid
== (uid_t
)VNOVAL
)
486 if (gid
== (gid_t
)VNOVAL
)
489 error
= genfs_can_chown(vp
, cred
, ip
->i_uid
, ip
->i_gid
, uid
, gid
);
496 ip
->i_e2fs_gid
= gid
& 0xffff;
497 ip
->i_e2fs_uid
= uid
& 0xffff;
498 if (ip
->i_e2fs
->e2fs
.e2fs_rev
> E2FS_REV0
) {
499 ip
->i_e2fs_gid_high
= (gid
>> 16) & 0xffff;
500 ip
->i_e2fs_uid_high
= (uid
>> 16) & 0xffff;
502 ip
->i_e2fs_gid_high
= 0;
503 ip
->i_e2fs_uid_high
= 0;
505 if (ouid
!= uid
|| ogid
!= gid
) {
506 ext2fs_set_inode_guid(ip
);
507 ip
->i_flag
|= IN_CHANGE
;
509 if (ouid
!= uid
&& kauth_authorize_generic(cred
,
510 KAUTH_GENERIC_ISSUSER
, NULL
) != 0)
511 ip
->i_e2fs_mode
&= ~ISUID
;
512 if (ogid
!= gid
&& kauth_authorize_generic(cred
,
513 KAUTH_GENERIC_ISSUSER
, NULL
) != 0)
514 ip
->i_e2fs_mode
&= ~ISGID
;
519 ext2fs_remove(void *v
)
521 struct vop_remove_args
/* {
524 struct componentname *a_cnp;
527 struct vnode
*vp
= ap
->a_vp
;
528 struct vnode
*dvp
= ap
->a_dvp
;
532 if (vp
->v_type
== VDIR
||
533 (ip
->i_e2fs_flags
& (EXT2_IMMUTABLE
| EXT2_APPEND
)) ||
534 (VTOI(dvp
)->i_e2fs_flags
& EXT2_APPEND
)) {
537 error
= ext2fs_dirremove(dvp
, ap
->a_cnp
);
540 ip
->i_flag
|= IN_CHANGE
;
544 VN_KNOTE(vp
, NOTE_DELETE
);
545 VN_KNOTE(dvp
, NOTE_WRITE
);
560 struct vop_link_args
/* {
563 struct componentname *a_cnp;
565 struct vnode
*dvp
= ap
->a_dvp
;
566 struct vnode
*vp
= ap
->a_vp
;
567 struct componentname
*cnp
= ap
->a_cnp
;
572 if ((cnp
->cn_flags
& HASBUF
) == 0)
573 panic("ext2fs_link: no name");
575 if (vp
->v_type
== VDIR
) {
576 VOP_ABORTOP(dvp
, cnp
);
580 if (dvp
->v_mount
!= vp
->v_mount
) {
581 VOP_ABORTOP(dvp
, cnp
);
585 if (dvp
!= vp
&& (error
= vn_lock(vp
, LK_EXCLUSIVE
))) {
586 VOP_ABORTOP(dvp
, cnp
);
590 if ((nlink_t
)ip
->i_e2fs_nlink
>= LINK_MAX
) {
591 VOP_ABORTOP(dvp
, cnp
);
595 if (ip
->i_e2fs_flags
& (EXT2_IMMUTABLE
| EXT2_APPEND
)) {
596 VOP_ABORTOP(dvp
, cnp
);
601 ip
->i_flag
|= IN_CHANGE
;
602 error
= ext2fs_update(vp
, NULL
, NULL
, UPDATE_WAIT
);
604 error
= ext2fs_direnter(ip
, dvp
, cnp
);
607 ip
->i_flag
|= IN_CHANGE
;
609 PNBUF_PUT(cnp
->cn_pnbuf
);
614 VN_KNOTE(vp
, NOTE_LINK
);
615 VN_KNOTE(dvp
, NOTE_WRITE
);
621 * Rename system call.
622 * rename("foo", "bar");
625 * link("foo", "bar");
627 * but ``atomically''. Can't do full commit without saving state in the
628 * inode on disk which isn't feasible at this time. Best we can do is
629 * always guarantee the target exists.
631 * Basic algorithm is:
633 * 1) Bump link count on source while we're linking it to the
634 * target. This also ensure the inode won't be deleted out
635 * from underneath us while we work (it may be truncated by
636 * a concurrent `trunc' or `open' for creation).
637 * 2) Link source to destination. If destination already exists,
639 * 3) Unlink source reference to inode if still around. If a
640 * directory was moved and the parent of the destination
641 * is different from the source, patch the ".." entry in the
645 ext2fs_rename(void *v
)
647 struct vop_rename_args
/* {
648 struct vnode *a_fdvp;
650 struct componentname *a_fcnp;
651 struct vnode *a_tdvp;
653 struct componentname *a_tcnp;
655 struct vnode
*tvp
= ap
->a_tvp
;
656 struct vnode
*tdvp
= ap
->a_tdvp
;
657 struct vnode
*fvp
= ap
->a_fvp
;
658 struct vnode
*fdvp
= ap
->a_fdvp
;
659 struct componentname
*tcnp
= ap
->a_tcnp
;
660 struct componentname
*fcnp
= ap
->a_fcnp
;
661 struct inode
*ip
, *xp
, *dp
;
662 struct ext2fs_dirtemplate dirbuf
;
663 int doingdirectory
= 0, oldparent
= 0, newparent
= 0;
668 if ((tcnp
->cn_flags
& HASBUF
) == 0 ||
669 (fcnp
->cn_flags
& HASBUF
) == 0)
670 panic("ext2fs_rename: no name");
673 * Check for cross-device rename.
675 if ((fvp
->v_mount
!= tdvp
->v_mount
) ||
676 (tvp
&& (fvp
->v_mount
!= tvp
->v_mount
))) {
679 VOP_ABORTOP(tdvp
, tcnp
); /* XXX, why not in NFS? */
686 VOP_ABORTOP(fdvp
, fcnp
); /* XXX, why not in NFS? */
693 * Check if just deleting a link name.
695 if (tvp
&& ((VTOI(tvp
)->i_e2fs_flags
& (EXT2_IMMUTABLE
| EXT2_APPEND
)) ||
696 (VTOI(tdvp
)->i_e2fs_flags
& EXT2_APPEND
))) {
701 if (fvp
->v_type
== VDIR
) {
706 /* Release destination completely. */
707 VOP_ABORTOP(tdvp
, tcnp
);
713 fcnp
->cn_flags
&= ~(MODMASK
| SAVESTART
);
714 fcnp
->cn_flags
|= LOCKPARENT
| LOCKLEAF
;
715 fcnp
->cn_nameiop
= DELETE
;
716 vn_lock(fdvp
, LK_EXCLUSIVE
| LK_RETRY
);
717 if ((error
= relookup(fdvp
, &fvp
, fcnp
))) {
721 return (VOP_REMOVE(fdvp
, fvp
, fcnp
));
723 if ((error
= vn_lock(fvp
, LK_EXCLUSIVE
)) != 0)
727 if ((nlink_t
) ip
->i_e2fs_nlink
>= LINK_MAX
) {
732 if ((ip
->i_e2fs_flags
& (EXT2_IMMUTABLE
| EXT2_APPEND
)) ||
733 (dp
->i_e2fs_flags
& EXT2_APPEND
)) {
738 if ((ip
->i_e2fs_mode
& IFMT
) == IFDIR
) {
739 error
= VOP_ACCESS(fvp
, VWRITE
, tcnp
->cn_cred
);
741 error
= VOP_ACCESS(tvp
, VWRITE
, tcnp
->cn_cred
);
748 * Avoid ".", "..", and aliases of "." for obvious reasons.
750 if ((fcnp
->cn_namelen
== 1 && fcnp
->cn_nameptr
[0] == '.') ||
752 (fcnp
->cn_flags
& ISDOTDOT
) ||
753 (tcnp
->cn_flags
& ISDOTDOT
) ||
754 (ip
->i_flag
& IN_RENAME
)) {
759 ip
->i_flag
|= IN_RENAME
;
760 oldparent
= dp
->i_number
;
763 VN_KNOTE(fdvp
, NOTE_WRITE
); /* XXXLUKEM/XXX: right place? */
766 * When the target exists, both the directory
767 * and target vnodes are returned locked.
775 * 1) Bump link count while we're moving stuff
776 * around. If we crash somewhere before
777 * completing our work, the link count
778 * may be wrong, but correctable.
781 ip
->i_flag
|= IN_CHANGE
;
782 if ((error
= ext2fs_update(fvp
, NULL
, NULL
, UPDATE_WAIT
)) != 0) {
788 * If ".." must be changed (ie the directory gets a new
789 * parent) then the source directory must not be in the
790 * directory hierarchy above the target, as this would
791 * orphan everything below the source directory. Also
792 * the user must have write permission in the source so
793 * as to be able to change "..". We must repeat the call
794 * to namei, as the parent directory is unlocked by the
795 * call to checkpath().
797 error
= VOP_ACCESS(fvp
, VWRITE
, tcnp
->cn_cred
);
799 if (oldparent
!= dp
->i_number
)
800 newparent
= dp
->i_number
;
801 if (doingdirectory
&& newparent
) {
802 if (error
) /* write access check above */
806 vref(tdvp
); /* compensate for the ref checkpath loses */
807 error
= ext2fs_checkpath(ip
, dp
, tcnp
->cn_cred
);
812 tcnp
->cn_flags
&= ~SAVESTART
;
813 vn_lock(tdvp
, LK_EXCLUSIVE
| LK_RETRY
);
814 if ((error
= relookup(tdvp
, &tvp
, tcnp
)) != 0) {
824 * 2) If target doesn't exist, link the target
825 * to the source and unlink the source.
826 * Otherwise, rewrite the target directory
827 * entry to reference the source inode and
828 * expunge the original entry's existence.
831 if (dp
->i_dev
!= ip
->i_dev
)
832 panic("rename: EXDEV");
834 * Account for ".." in new directory.
835 * When source and destination have the same
836 * parent we don't fool with the link count.
838 if (doingdirectory
&& newparent
) {
839 if ((nlink_t
)dp
->i_e2fs_nlink
>= LINK_MAX
) {
844 dp
->i_flag
|= IN_CHANGE
;
845 if ((error
= ext2fs_update(tdvp
, NULL
, NULL
,
849 error
= ext2fs_direnter(ip
, tdvp
, tcnp
);
851 if (doingdirectory
&& newparent
) {
853 dp
->i_flag
|= IN_CHANGE
;
854 (void)ext2fs_update(tdvp
, NULL
, NULL
,
859 VN_KNOTE(tdvp
, NOTE_WRITE
);
862 if (xp
->i_dev
!= dp
->i_dev
|| xp
->i_dev
!= ip
->i_dev
)
863 panic("rename: EXDEV");
865 * Short circuit rename(foo, foo).
867 if (xp
->i_number
== ip
->i_number
)
868 panic("rename: same file");
870 * If the parent directory is "sticky", then the user must
871 * own the parent directory, or the destination of the rename,
872 * otherwise the destination may not be changed (except by
873 * root). This implements append-only directories.
875 if ((dp
->i_e2fs_mode
& S_ISTXT
) &&
876 kauth_authorize_generic(tcnp
->cn_cred
,
877 KAUTH_GENERIC_ISSUSER
, NULL
) != 0 &&
878 kauth_cred_geteuid(tcnp
->cn_cred
) != dp
->i_uid
&&
879 xp
->i_uid
!= kauth_cred_geteuid(tcnp
->cn_cred
)) {
884 * Target must be empty if a directory and have no links
885 * to it. Also, ensure source and target are compatible
886 * (both directories, or both not directories).
888 if ((xp
->i_e2fs_mode
& IFMT
) == IFDIR
) {
889 if (!ext2fs_dirempty(xp
, dp
->i_number
, tcnp
->cn_cred
) ||
890 xp
->i_e2fs_nlink
> 2) {
894 if (!doingdirectory
) {
899 } else if (doingdirectory
) {
903 error
= ext2fs_dirrewrite(dp
, ip
, tcnp
);
907 * If the target directory is in the same
908 * directory as the source directory,
909 * decrement the link count on the parent
910 * of the target directory.
912 if (doingdirectory
&& !newparent
) {
914 dp
->i_flag
|= IN_CHANGE
;
917 * Adjust the link count of the target to
918 * reflect the dirrewrite above. If this is
919 * a directory it is empty and there are
920 * no links to it, so we can squash the inode and
921 * any space associated with it. We disallowed
922 * renaming over top of a directory with links to
923 * it above, as the remaining link would point to
924 * a directory without "." or ".." entries.
927 if (doingdirectory
) {
928 if (--xp
->i_e2fs_nlink
!= 0)
929 panic("rename: linked directory");
930 error
= ext2fs_truncate(tvp
, (off_t
)0, IO_SYNC
,
933 xp
->i_flag
|= IN_CHANGE
;
934 VN_KNOTE(tdvp
, NOTE_WRITE
);
936 VN_KNOTE(tvp
, NOTE_DELETE
);
942 * 3) Unlink the source.
944 fcnp
->cn_flags
&= ~(MODMASK
| SAVESTART
);
945 fcnp
->cn_flags
|= LOCKPARENT
| LOCKLEAF
;
946 vn_lock(fdvp
, LK_EXCLUSIVE
| LK_RETRY
);
947 if ((error
= relookup(fdvp
, &fvp
, fcnp
))) {
957 * From name has disappeared.
960 panic("ext2fs_rename: lost dir entry");
965 * Ensure that the directory entry still exists and has not
966 * changed while the new name has been entered. If the source is
967 * a file then the entry may have been unlinked or renamed. In
968 * either case there is no further work to be done. If the source
969 * is a directory then it cannot have been rmdir'ed; its link
970 * count of three would cause a rmdir to fail with ENOTEMPTY.
971 * The IRENAME flag ensures that it cannot be moved by another
976 panic("ext2fs_rename: lost dir entry");
979 * If the source is a directory with a
980 * new parent, the link count of the old
981 * parent directory must be decremented
982 * and ".." set to point to the new parent.
984 if (doingdirectory
&& newparent
) {
987 dp
->i_flag
|= IN_CHANGE
;
988 error
= vn_rdwr(UIO_READ
, fvp
, (void *)&dirbuf
,
989 sizeof (struct ext2fs_dirtemplate
), (off_t
)0,
990 UIO_SYSSPACE
, IO_NODELOCKED
,
991 tcnp
->cn_cred
, (size_t *)0, NULL
);
993 namlen
= dirbuf
.dotdot_namlen
;
995 dirbuf
.dotdot_name
[0] != '.' ||
996 dirbuf
.dotdot_name
[1] != '.') {
997 ufs_dirbad(xp
, (doff_t
)12,
998 "ext2fs_rename: mangled dir");
1000 dirbuf
.dotdot_ino
= h2fs32(newparent
);
1001 (void) vn_rdwr(UIO_WRITE
, fvp
,
1003 sizeof (struct dirtemplate
),
1004 (off_t
)0, UIO_SYSSPACE
,
1005 IO_NODELOCKED
|IO_SYNC
,
1006 tcnp
->cn_cred
, (size_t *)0,
1012 error
= ext2fs_dirremove(fdvp
, fcnp
);
1015 xp
->i_flag
|= IN_CHANGE
;
1017 xp
->i_flag
&= ~IN_RENAME
;
1019 VN_KNOTE(fvp
, NOTE_RENAME
);
1033 ip
->i_flag
&= ~IN_RENAME
;
1034 if (vn_lock(fvp
, LK_EXCLUSIVE
) == 0) {
1036 ip
->i_flag
|= IN_CHANGE
;
1048 ext2fs_mkdir(void *v
)
1050 struct vop_mkdir_args
/* {
1051 struct vnode *a_dvp;
1052 struct vnode **a_vpp;
1053 struct componentname *a_cnp;
1054 struct vattr *a_vap;
1056 struct vnode
*dvp
= ap
->a_dvp
;
1057 struct vattr
*vap
= ap
->a_vap
;
1058 struct componentname
*cnp
= ap
->a_cnp
;
1059 struct inode
*ip
, *dp
= VTOI(dvp
);
1061 struct ext2fs_dirtemplate dirtemplate
;
1065 if ((cnp
->cn_flags
& HASBUF
) == 0)
1066 panic("ext2fs_mkdir: no name");
1068 if ((nlink_t
)dp
->i_e2fs_nlink
>= LINK_MAX
) {
1072 dmode
= vap
->va_mode
& ACCESSPERMS
;
1075 * Must simulate part of ext2fs_makeinode here to acquire the inode,
1076 * but not have it entered in the parent directory. The entry is
1077 * made later after writing "." and ".." entries.
1079 if ((error
= ext2fs_valloc(dvp
, dmode
, cnp
->cn_cred
, &tvp
)) != 0)
1082 ip
->i_uid
= kauth_cred_geteuid(cnp
->cn_cred
);
1083 ip
->i_e2fs_uid
= ip
->i_uid
& 0xffff;
1084 ip
->i_e2fs_gid
= dp
->i_e2fs_gid
;
1085 if (ip
->i_e2fs
->e2fs
.e2fs_rev
> E2FS_REV0
) {
1086 ip
->i_e2fs_uid_high
= (ip
->i_uid
>> 16) & 0xffff;
1087 ip
->i_e2fs_gid_high
= dp
->i_e2fs_gid_high
;
1089 ip
->i_e2fs_uid_high
= 0;
1090 ip
->i_e2fs_gid_high
= 0;
1092 ip
->i_gid
= ip
->i_e2fs_gid
| (ip
->i_e2fs_gid_high
<< 16);
1093 ip
->i_flag
|= IN_ACCESS
| IN_CHANGE
| IN_UPDATE
;
1094 ip
->i_e2fs_mode
= dmode
;
1095 tvp
->v_type
= VDIR
; /* Rest init'd in getnewvnode(). */
1096 ip
->i_e2fs_nlink
= 2;
1099 * Bump link count in parent directory
1100 * to reflect work done below. Should
1101 * be done before reference is created
1102 * so reparation is possible if we crash.
1105 dp
->i_flag
|= IN_CHANGE
;
1106 if ((error
= ext2fs_update(dvp
, NULL
, NULL
, UPDATE_DIROP
)) != 0)
1109 /* Initialize directory with "." and ".." from static template. */
1110 memset(&dirtemplate
, 0, sizeof(dirtemplate
));
1111 dirtemplate
.dot_ino
= h2fs32(ip
->i_number
);
1112 dirtemplate
.dot_reclen
= h2fs16(12);
1113 dirtemplate
.dot_namlen
= 1;
1114 if (ip
->i_e2fs
->e2fs
.e2fs_rev
> E2FS_REV0
&&
1115 (ip
->i_e2fs
->e2fs
.e2fs_features_incompat
& EXT2F_INCOMPAT_FTYPE
)) {
1116 dirtemplate
.dot_type
= EXT2_FT_DIR
;
1118 dirtemplate
.dot_name
[0] = '.';
1119 dirtemplate
.dotdot_ino
= h2fs32(dp
->i_number
);
1120 dirtemplate
.dotdot_reclen
= h2fs16(VTOI(dvp
)->i_e2fs
->e2fs_bsize
- 12);
1121 dirtemplate
.dotdot_namlen
= 2;
1122 if (ip
->i_e2fs
->e2fs
.e2fs_rev
> E2FS_REV0
&&
1123 (ip
->i_e2fs
->e2fs
.e2fs_features_incompat
& EXT2F_INCOMPAT_FTYPE
)) {
1124 dirtemplate
.dotdot_type
= EXT2_FT_DIR
;
1126 dirtemplate
.dotdot_name
[0] = dirtemplate
.dotdot_name
[1] = '.';
1127 error
= vn_rdwr(UIO_WRITE
, tvp
, (void *)&dirtemplate
,
1128 sizeof (dirtemplate
), (off_t
)0, UIO_SYSSPACE
,
1129 IO_NODELOCKED
|IO_SYNC
, cnp
->cn_cred
, (size_t *)0, NULL
);
1132 dp
->i_flag
|= IN_CHANGE
;
1135 if (VTOI(dvp
)->i_e2fs
->e2fs_bsize
> dvp
->v_mount
->mnt_stat
.f_bsize
)
1136 panic("ext2fs_mkdir: blksize"); /* XXX should grow with balloc() */
1138 error
= ext2fs_setsize(ip
, VTOI(dvp
)->i_e2fs
->e2fs_bsize
);
1141 dp
->i_flag
|= IN_CHANGE
;
1144 ip
->i_flag
|= IN_CHANGE
;
1145 uvm_vnp_setsize(tvp
, ext2fs_size(ip
));
1148 /* Directory set up, now install it's entry in the parent directory. */
1149 error
= ext2fs_direnter(ip
, dvp
, cnp
);
1152 dp
->i_flag
|= IN_CHANGE
;
1156 * No need to do an explicit ext2fs_truncate here, vrele will do this
1157 * for us because we set the link count to 0.
1160 ip
->i_e2fs_nlink
= 0;
1161 ip
->i_flag
|= IN_CHANGE
;
1164 VN_KNOTE(dvp
, NOTE_WRITE
| NOTE_LINK
);
1168 PNBUF_PUT(cnp
->cn_pnbuf
);
1174 * Rmdir system call.
1177 ext2fs_rmdir(void *v
)
1179 struct vop_rmdir_args
/* {
1180 struct vnode *a_dvp;
1182 struct componentname *a_cnp;
1184 struct vnode
*vp
= ap
->a_vp
;
1185 struct vnode
*dvp
= ap
->a_dvp
;
1186 struct componentname
*cnp
= ap
->a_cnp
;
1187 struct inode
*ip
, *dp
;
1193 * No rmdir "." please.
1201 * Verify the directory is empty (and valid).
1202 * (Rmdir ".." won't be valid since
1203 * ".." will contain a reference to
1204 * the current directory and thus be
1208 if (ip
->i_e2fs_nlink
!= 2 ||
1209 !ext2fs_dirempty(ip
, dp
->i_number
, cnp
->cn_cred
)) {
1213 if ((dp
->i_e2fs_flags
& EXT2_APPEND
) ||
1214 (ip
->i_e2fs_flags
& (EXT2_IMMUTABLE
| EXT2_APPEND
))) {
1219 * Delete reference to directory before purging
1220 * inode. If we crash in between, the directory
1221 * will be reattached to lost+found,
1223 error
= ext2fs_dirremove(dvp
, cnp
);
1227 dp
->i_flag
|= IN_CHANGE
;
1228 VN_KNOTE(dvp
, NOTE_WRITE
| NOTE_LINK
);
1233 * Truncate inode. The only stuff left
1234 * in the directory is "." and "..". The
1235 * "." reference is inconsequential since
1236 * we're quashing it. The ".." reference
1237 * has already been adjusted above. We've
1238 * removed the "." reference and the reference
1239 * in the parent directory, but there may be
1240 * other hard links so decrement by 2 and
1241 * worry about them later.
1243 ip
->i_e2fs_nlink
-= 2;
1244 error
= ext2fs_truncate(vp
, (off_t
)0, IO_SYNC
, cnp
->cn_cred
);
1245 cache_purge(ITOV(ip
));
1247 VN_KNOTE(vp
, NOTE_DELETE
);
1255 * symlink -- make a symbolic link
1258 ext2fs_symlink(void *v
)
1260 struct vop_symlink_args
/* {
1261 struct vnode *a_dvp;
1262 struct vnode **a_vpp;
1263 struct componentname *a_cnp;
1264 struct vattr *a_vap;
1267 struct vnode
*vp
, **vpp
;
1272 error
= ext2fs_makeinode(IFLNK
| ap
->a_vap
->va_mode
, ap
->a_dvp
,
1276 VN_KNOTE(ap
->a_dvp
, NOTE_WRITE
);
1278 len
= strlen(ap
->a_target
);
1280 if (len
< ip
->i_ump
->um_maxsymlinklen
) {
1281 memcpy((char *)ip
->i_din
.e2fs_din
->e2di_shortlink
, ap
->a_target
, len
);
1282 error
= ext2fs_setsize(ip
, len
);
1285 ip
->i_flag
|= IN_CHANGE
| IN_UPDATE
;
1286 uvm_vnp_setsize(vp
, len
);
1288 error
= vn_rdwr(UIO_WRITE
, vp
, ap
->a_target
, len
, (off_t
)0,
1289 UIO_SYSSPACE
, IO_NODELOCKED
, ap
->a_cnp
->cn_cred
,
1298 * Return target name of a symbolic link
1301 ext2fs_readlink(void *v
)
1303 struct vop_readlink_args
/* {
1306 kauth_cred_t a_cred;
1308 struct vnode
*vp
= ap
->a_vp
;
1309 struct inode
*ip
= VTOI(vp
);
1310 struct ufsmount
*ump
= ip
->i_ump
;
1313 isize
= ext2fs_size(ip
);
1314 if (isize
< ump
->um_maxsymlinklen
||
1315 (ump
->um_maxsymlinklen
== 0 && ip
->i_e2fs_nblock
== 0)) {
1316 uiomove((char *)ip
->i_din
.e2fs_din
->e2di_shortlink
, isize
, ap
->a_uio
);
1319 return (VOP_READ(vp
, ap
->a_uio
, 0, ap
->a_cred
));
1323 * Advisory record locking support
1326 ext2fs_advlock(void *v
)
1328 struct vop_advlock_args
/* {
1335 struct inode
*ip
= VTOI(ap
->a_vp
);
1337 return lf_advlock(ap
, &ip
->i_lockf
, ext2fs_size(ip
));
1341 ext2fs_fsync(void *v
)
1343 struct vop_fsync_args
/* {
1345 kauth_cred_t a_cred;
1351 struct vnode
*vp
= ap
->a_vp
;
1355 wait
= (ap
->a_flags
& FSYNC_WAIT
) != 0;
1357 if (vp
->v_type
== VBLK
)
1360 vflushbuf(vp
, wait
);
1361 if ((ap
->a_flags
& FSYNC_DATAONLY
) != 0)
1364 error
= ext2fs_update(vp
, NULL
, NULL
, wait
? UPDATE_WAIT
: 0);
1366 if (error
== 0 && ap
->a_flags
& FSYNC_CACHE
) {
1368 error
= VOP_IOCTL(VTOI(vp
)->i_devvp
, DIOCCACHESYNC
, &l
, FWRITE
,
1376 * Initialize the vnode associated with a new inode, handle aliased
1380 ext2fs_vinit(struct mount
*mntp
, int (**specops
)(void *),
1381 int (**fifoops
)(void *), struct vnode
**vpp
)
1389 switch(vp
->v_type
= IFTOVT(ip
->i_e2fs_mode
)) {
1393 spec_node_init(vp
, fs2h32(ip
->i_din
.e2fs_din
->e2di_rdev
));
1406 if (ip
->i_number
== ROOTINO
)
1407 vp
->v_vflag
|= VV_ROOT
;
1409 * Initialize modrev times
1411 getmicrouptime(&tv
);
1412 SETHIGH(ip
->i_modrev
, tv
.tv_sec
);
1413 SETLOW(ip
->i_modrev
, tv
.tv_usec
* 4294);
1419 * Allocate a new inode.
1422 ext2fs_makeinode(int mode
, struct vnode
*dvp
, struct vnode
**vpp
,
1423 struct componentname
*cnp
)
1425 struct inode
*ip
, *pdir
;
1427 int error
, ismember
= 0;
1431 if ((cnp
->cn_flags
& HASBUF
) == 0)
1432 panic("ext2fs_makeinode: no name");
1435 if ((mode
& IFMT
) == 0)
1438 if ((error
= ext2fs_valloc(dvp
, mode
, cnp
->cn_cred
, &tvp
)) != 0) {
1439 PNBUF_PUT(cnp
->cn_pnbuf
);
1444 ip
->i_uid
= kauth_cred_geteuid(cnp
->cn_cred
);
1445 ip
->i_e2fs_uid
= ip
->i_uid
& 0xffff;
1446 ip
->i_e2fs_gid
= pdir
->i_e2fs_gid
;
1447 if (ip
->i_e2fs
->e2fs
.e2fs_rev
> E2FS_REV0
) {
1448 ip
->i_e2fs_uid_high
= (ip
->i_uid
>> 16) & 0xffff;
1449 ip
->i_e2fs_gid_high
= pdir
->i_e2fs_gid_high
;
1451 ip
->i_e2fs_uid_high
= 0;
1452 ip
->i_e2fs_gid_high
= 0;
1454 ip
->i_gid
= ip
->i_e2fs_gid
| (ip
->i_e2fs_gid_high
<< 16);
1455 ip
->i_flag
|= IN_ACCESS
| IN_CHANGE
| IN_UPDATE
;
1456 ip
->i_e2fs_mode
= mode
;
1457 tvp
->v_type
= IFTOVT(mode
); /* Rest init'd in getnewvnode(). */
1458 ip
->i_e2fs_nlink
= 1;
1459 if ((ip
->i_e2fs_mode
& ISGID
) && (kauth_cred_ismember_gid(cnp
->cn_cred
,
1460 ip
->i_gid
, &ismember
) != 0 || !ismember
) &&
1461 kauth_authorize_generic(cnp
->cn_cred
, KAUTH_GENERIC_ISSUSER
, NULL
))
1462 ip
->i_e2fs_mode
&= ~ISGID
;
1465 * Make sure inode goes to disk before directory entry.
1467 if ((error
= ext2fs_update(tvp
, NULL
, NULL
, UPDATE_WAIT
)) != 0)
1469 error
= ext2fs_direnter(ip
, dvp
, cnp
);
1472 if ((cnp
->cn_flags
& SAVESTART
) == 0)
1473 PNBUF_PUT(cnp
->cn_pnbuf
);
1480 * Write error occurred trying to update the inode
1481 * or the directory so must deallocate the inode.
1483 tvp
->v_type
= VNON
; /* Stop explosion if VBLK */
1484 ip
->i_e2fs_nlink
= 0;
1485 ip
->i_flag
|= IN_CHANGE
;
1487 PNBUF_PUT(cnp
->cn_pnbuf
);
1493 * Reclaim an inode so that it can be used for other purposes.
1496 ext2fs_reclaim(void *v
)
1498 struct vop_reclaim_args
/* {
1501 struct vnode
*vp
= ap
->a_vp
;
1502 struct inode
*ip
= VTOI(vp
);
1505 if ((error
= ufs_reclaim(vp
)) != 0)
1507 if (ip
->i_din
.e2fs_din
!= NULL
)
1508 pool_put(&ext2fs_dinode_pool
, ip
->i_din
.e2fs_din
);
1509 genfs_node_destroy(vp
);
1510 pool_put(&ext2fs_inode_pool
, vp
->v_data
);
1515 /* Global vfs data structures for ext2fs. */
1516 int (**ext2fs_vnodeop_p
)(void *);
1517 const struct vnodeopv_entry_desc ext2fs_vnodeop_entries
[] = {
1518 { &vop_default_desc
, vn_default_error
},
1519 { &vop_lookup_desc
, ext2fs_lookup
}, /* lookup */
1520 { &vop_create_desc
, ext2fs_create
}, /* create */
1521 { &vop_mknod_desc
, ext2fs_mknod
}, /* mknod */
1522 { &vop_open_desc
, ext2fs_open
}, /* open */
1523 { &vop_close_desc
, ufs_close
}, /* close */
1524 { &vop_access_desc
, ext2fs_access
}, /* access */
1525 { &vop_getattr_desc
, ext2fs_getattr
}, /* getattr */
1526 { &vop_setattr_desc
, ext2fs_setattr
}, /* setattr */
1527 { &vop_read_desc
, ext2fs_read
}, /* read */
1528 { &vop_write_desc
, ext2fs_write
}, /* write */
1529 { &vop_ioctl_desc
, ufs_ioctl
}, /* ioctl */
1530 { &vop_fcntl_desc
, ufs_fcntl
}, /* fcntl */
1531 { &vop_poll_desc
, ufs_poll
}, /* poll */
1532 { &vop_kqfilter_desc
, genfs_kqfilter
}, /* kqfilter */
1533 { &vop_revoke_desc
, ufs_revoke
}, /* revoke */
1534 { &vop_mmap_desc
, ufs_mmap
}, /* mmap */
1535 { &vop_fsync_desc
, ext2fs_fsync
}, /* fsync */
1536 { &vop_seek_desc
, ufs_seek
}, /* seek */
1537 { &vop_remove_desc
, ext2fs_remove
}, /* remove */
1538 { &vop_link_desc
, ext2fs_link
}, /* link */
1539 { &vop_rename_desc
, ext2fs_rename
}, /* rename */
1540 { &vop_mkdir_desc
, ext2fs_mkdir
}, /* mkdir */
1541 { &vop_rmdir_desc
, ext2fs_rmdir
}, /* rmdir */
1542 { &vop_symlink_desc
, ext2fs_symlink
}, /* symlink */
1543 { &vop_readdir_desc
, ext2fs_readdir
}, /* readdir */
1544 { &vop_readlink_desc
, ext2fs_readlink
}, /* readlink */
1545 { &vop_abortop_desc
, ufs_abortop
}, /* abortop */
1546 { &vop_inactive_desc
, ext2fs_inactive
}, /* inactive */
1547 { &vop_reclaim_desc
, ext2fs_reclaim
}, /* reclaim */
1548 { &vop_lock_desc
, ufs_lock
}, /* lock */
1549 { &vop_unlock_desc
, ufs_unlock
}, /* unlock */
1550 { &vop_bmap_desc
, ext2fs_bmap
}, /* bmap */
1551 { &vop_strategy_desc
, ufs_strategy
}, /* strategy */
1552 { &vop_print_desc
, ufs_print
}, /* print */
1553 { &vop_islocked_desc
, ufs_islocked
}, /* islocked */
1554 { &vop_pathconf_desc
, ufs_pathconf
}, /* pathconf */
1555 { &vop_advlock_desc
, ext2fs_advlock
}, /* advlock */
1556 { &vop_bwrite_desc
, vn_bwrite
}, /* bwrite */
1557 { &vop_getpages_desc
, genfs_getpages
}, /* getpages */
1558 { &vop_putpages_desc
, genfs_putpages
}, /* putpages */
1561 const struct vnodeopv_desc ext2fs_vnodeop_opv_desc
=
1562 { &ext2fs_vnodeop_p
, ext2fs_vnodeop_entries
};
1564 int (**ext2fs_specop_p
)(void *);
1565 const struct vnodeopv_entry_desc ext2fs_specop_entries
[] = {
1566 { &vop_default_desc
, vn_default_error
},
1567 { &vop_lookup_desc
, spec_lookup
}, /* lookup */
1568 { &vop_create_desc
, spec_create
}, /* create */
1569 { &vop_mknod_desc
, spec_mknod
}, /* mknod */
1570 { &vop_open_desc
, spec_open
}, /* open */
1571 { &vop_close_desc
, ufsspec_close
}, /* close */
1572 { &vop_access_desc
, ext2fs_access
}, /* access */
1573 { &vop_getattr_desc
, ext2fs_getattr
}, /* getattr */
1574 { &vop_setattr_desc
, ext2fs_setattr
}, /* setattr */
1575 { &vop_read_desc
, ufsspec_read
}, /* read */
1576 { &vop_write_desc
, ufsspec_write
}, /* write */
1577 { &vop_ioctl_desc
, spec_ioctl
}, /* ioctl */
1578 { &vop_fcntl_desc
, ufs_fcntl
}, /* fcntl */
1579 { &vop_poll_desc
, spec_poll
}, /* poll */
1580 { &vop_kqfilter_desc
, spec_kqfilter
}, /* kqfilter */
1581 { &vop_revoke_desc
, spec_revoke
}, /* revoke */
1582 { &vop_mmap_desc
, spec_mmap
}, /* mmap */
1583 { &vop_fsync_desc
, ext2fs_fsync
}, /* fsync */
1584 { &vop_seek_desc
, spec_seek
}, /* seek */
1585 { &vop_remove_desc
, spec_remove
}, /* remove */
1586 { &vop_link_desc
, spec_link
}, /* link */
1587 { &vop_rename_desc
, spec_rename
}, /* rename */
1588 { &vop_mkdir_desc
, spec_mkdir
}, /* mkdir */
1589 { &vop_rmdir_desc
, spec_rmdir
}, /* rmdir */
1590 { &vop_symlink_desc
, spec_symlink
}, /* symlink */
1591 { &vop_readdir_desc
, spec_readdir
}, /* readdir */
1592 { &vop_readlink_desc
, spec_readlink
}, /* readlink */
1593 { &vop_abortop_desc
, spec_abortop
}, /* abortop */
1594 { &vop_inactive_desc
, ext2fs_inactive
}, /* inactive */
1595 { &vop_reclaim_desc
, ext2fs_reclaim
}, /* reclaim */
1596 { &vop_lock_desc
, ufs_lock
}, /* lock */
1597 { &vop_unlock_desc
, ufs_unlock
}, /* unlock */
1598 { &vop_bmap_desc
, spec_bmap
}, /* bmap */
1599 { &vop_strategy_desc
, spec_strategy
}, /* strategy */
1600 { &vop_print_desc
, ufs_print
}, /* print */
1601 { &vop_islocked_desc
, ufs_islocked
}, /* islocked */
1602 { &vop_pathconf_desc
, spec_pathconf
}, /* pathconf */
1603 { &vop_advlock_desc
, spec_advlock
}, /* advlock */
1604 { &vop_bwrite_desc
, vn_bwrite
}, /* bwrite */
1605 { &vop_getpages_desc
, spec_getpages
}, /* getpages */
1606 { &vop_putpages_desc
, spec_putpages
}, /* putpages */
1609 const struct vnodeopv_desc ext2fs_specop_opv_desc
=
1610 { &ext2fs_specop_p
, ext2fs_specop_entries
};
1612 int (**ext2fs_fifoop_p
)(void *);
1613 const struct vnodeopv_entry_desc ext2fs_fifoop_entries
[] = {
1614 { &vop_default_desc
, vn_default_error
},
1615 { &vop_lookup_desc
, fifo_lookup
}, /* lookup */
1616 { &vop_create_desc
, fifo_create
}, /* create */
1617 { &vop_mknod_desc
, fifo_mknod
}, /* mknod */
1618 { &vop_open_desc
, fifo_open
}, /* open */
1619 { &vop_close_desc
, ufsfifo_close
}, /* close */
1620 { &vop_access_desc
, ext2fs_access
}, /* access */
1621 { &vop_getattr_desc
, ext2fs_getattr
}, /* getattr */
1622 { &vop_setattr_desc
, ext2fs_setattr
}, /* setattr */
1623 { &vop_read_desc
, ufsfifo_read
}, /* read */
1624 { &vop_write_desc
, ufsfifo_write
}, /* write */
1625 { &vop_ioctl_desc
, fifo_ioctl
}, /* ioctl */
1626 { &vop_fcntl_desc
, ufs_fcntl
}, /* fcntl */
1627 { &vop_poll_desc
, fifo_poll
}, /* poll */
1628 { &vop_kqfilter_desc
, fifo_kqfilter
}, /* kqfilter */
1629 { &vop_revoke_desc
, fifo_revoke
}, /* revoke */
1630 { &vop_mmap_desc
, fifo_mmap
}, /* mmap */
1631 { &vop_fsync_desc
, ext2fs_fsync
}, /* fsync */
1632 { &vop_seek_desc
, fifo_seek
}, /* seek */
1633 { &vop_remove_desc
, fifo_remove
}, /* remove */
1634 { &vop_link_desc
, fifo_link
}, /* link */
1635 { &vop_rename_desc
, fifo_rename
}, /* rename */
1636 { &vop_mkdir_desc
, fifo_mkdir
}, /* mkdir */
1637 { &vop_rmdir_desc
, fifo_rmdir
}, /* rmdir */
1638 { &vop_symlink_desc
, fifo_symlink
}, /* symlink */
1639 { &vop_readdir_desc
, fifo_readdir
}, /* readdir */
1640 { &vop_readlink_desc
, fifo_readlink
}, /* readlink */
1641 { &vop_abortop_desc
, fifo_abortop
}, /* abortop */
1642 { &vop_inactive_desc
, ext2fs_inactive
}, /* inactive */
1643 { &vop_reclaim_desc
, ext2fs_reclaim
}, /* reclaim */
1644 { &vop_lock_desc
, ufs_lock
}, /* lock */
1645 { &vop_unlock_desc
, ufs_unlock
}, /* unlock */
1646 { &vop_bmap_desc
, fifo_bmap
}, /* bmap */
1647 { &vop_strategy_desc
, fifo_strategy
}, /* strategy */
1648 { &vop_print_desc
, ufs_print
}, /* print */
1649 { &vop_islocked_desc
, ufs_islocked
}, /* islocked */
1650 { &vop_pathconf_desc
, fifo_pathconf
}, /* pathconf */
1651 { &vop_advlock_desc
, fifo_advlock
}, /* advlock */
1652 { &vop_bwrite_desc
, vn_bwrite
}, /* bwrite */
1653 { &vop_putpages_desc
, fifo_putpages
}, /* putpages */
1656 const struct vnodeopv_desc ext2fs_fifoop_opv_desc
=
1657 { &ext2fs_fifoop_p
, ext2fs_fifoop_entries
};