2 * Copyright (c) 1982, 1986, 1989, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * @(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95
39 * $FreeBSD: src/sys/ufs/ufs/ufs_vnops.c,v 1.131.2.8 2003/01/02 17:26:19 bde Exp $
40 * $DragonFly: src/sys/vfs/ufs/ufs_vnops.c,v 1.66 2008/06/26 18:53:14 dillon Exp $
43 #include "opt_quota.h"
44 #include "opt_suiddir.h"
47 #include <sys/param.h>
48 #include <sys/systm.h>
49 #include <sys/kernel.h>
50 #include <sys/fcntl.h>
54 #include <sys/namei.h>
55 #include <sys/mount.h>
56 #include <sys/unistd.h>
57 #include <sys/vnode.h>
58 #include <sys/malloc.h>
59 #include <sys/dirent.h>
60 #include <sys/lockf.h>
61 #include <sys/event.h>
64 #include <sys/file.h> /* XXX */
68 #include <vm/vm_extern.h>
70 #include <vfs/fifofs/fifo.h>
76 #include "ufs_extern.h"
77 #include "ffs_extern.h"
82 static int ufs_access (struct vop_access_args
*);
83 static int ufs_advlock (struct vop_advlock_args
*);
84 static int ufs_chmod (struct vnode
*, int, struct ucred
*);
85 static int ufs_chown (struct vnode
*, uid_t
, gid_t
, struct ucred
*);
86 static int ufs_close (struct vop_close_args
*);
87 static int ufs_create (struct vop_old_create_args
*);
88 static int ufs_getattr (struct vop_getattr_args
*);
89 static int ufs_link (struct vop_old_link_args
*);
90 static int ufs_makeinode (int mode
, struct vnode
*, struct vnode
**, struct componentname
*);
91 static int ufs_missingop (struct vop_generic_args
*ap
);
92 static int ufs_mkdir (struct vop_old_mkdir_args
*);
93 static int ufs_mknod (struct vop_old_mknod_args
*);
94 static int ufs_mmap (struct vop_mmap_args
*);
95 static int ufs_open (struct vop_open_args
*);
96 static int ufs_pathconf (struct vop_pathconf_args
*);
97 static int ufs_print (struct vop_print_args
*);
98 static int ufs_readdir (struct vop_readdir_args
*);
99 static int ufs_readlink (struct vop_readlink_args
*);
100 static int ufs_remove (struct vop_old_remove_args
*);
101 static int ufs_rename (struct vop_old_rename_args
*);
102 static int ufs_rmdir (struct vop_old_rmdir_args
*);
103 static int ufs_setattr (struct vop_setattr_args
*);
104 static int ufs_strategy (struct vop_strategy_args
*);
105 static int ufs_symlink (struct vop_old_symlink_args
*);
106 static int ufs_whiteout (struct vop_old_whiteout_args
*);
107 static int ufsfifo_close (struct vop_close_args
*);
108 static int ufsfifo_kqfilter (struct vop_kqfilter_args
*);
109 static int ufsfifo_read (struct vop_read_args
*);
110 static int ufsfifo_write (struct vop_write_args
*);
111 static int ufsspec_close (struct vop_close_args
*);
112 static int ufsspec_read (struct vop_read_args
*);
113 static int ufsspec_write (struct vop_write_args
*);
114 static int filt_ufsread (struct knote
*kn
, long hint
);
115 static int filt_ufswrite (struct knote
*kn
, long hint
);
116 static int filt_ufsvnode (struct knote
*kn
, long hint
);
117 static void filt_ufsdetach (struct knote
*kn
);
118 static int ufs_kqfilter (struct vop_kqfilter_args
*ap
);
124 #define SETHIGH(q, h) { \
127 tmp.val[_QUAD_HIGHWORD] = (h); \
130 #define SETLOW(q, l) { \
133 tmp.val[_QUAD_LOWWORD] = (l); \
136 #define VN_KNOTE(vp, b) \
137 KNOTE(&vp->v_pollinfo.vpi_selinfo.si_note, (b))
139 #define OFSFMT(vp) ((vp)->v_mount->mnt_maxsymlinklen <= 0)
142 * A virgin directory (no blushing please).
144 static struct dirtemplate mastertemplate
= {
145 0, 12, DT_DIR
, 1, ".",
146 0, DIRBLKSIZ
- 12, DT_DIR
, 2, ".."
148 static struct odirtemplate omastertemplate
= {
150 0, DIRBLKSIZ
- 12, 2, ".."
154 ufs_itimes(struct vnode
*vp
)
160 if ((ip
->i_flag
& (IN_ACCESS
| IN_CHANGE
| IN_UPDATE
)) == 0)
162 if ((vp
->v_type
== VBLK
|| vp
->v_type
== VCHR
) && !DOINGSOFTDEP(vp
))
163 ip
->i_flag
|= IN_LAZYMOD
;
165 ip
->i_flag
|= IN_MODIFIED
;
166 if ((vp
->v_mount
->mnt_flag
& MNT_RDONLY
) == 0) {
168 if (ip
->i_flag
& IN_ACCESS
) {
169 ip
->i_atime
= ts
.tv_sec
;
170 ip
->i_atimensec
= ts
.tv_nsec
;
172 if (ip
->i_flag
& IN_UPDATE
) {
173 ip
->i_mtime
= ts
.tv_sec
;
174 ip
->i_mtimensec
= ts
.tv_nsec
;
177 if (ip
->i_flag
& IN_CHANGE
) {
178 ip
->i_ctime
= ts
.tv_sec
;
179 ip
->i_ctimensec
= ts
.tv_nsec
;
182 ip
->i_flag
&= ~(IN_ACCESS
| IN_CHANGE
| IN_UPDATE
);
186 * Create a regular file
188 * ufs_create(struct vnode *a_dvp, struct vnode **a_vpp,
189 * struct componentname *a_cnp, struct vattr *a_vap)
193 ufs_create(struct vop_old_create_args
*ap
)
198 ufs_makeinode(MAKEIMODE(ap
->a_vap
->va_type
, ap
->a_vap
->va_mode
),
199 ap
->a_dvp
, ap
->a_vpp
, ap
->a_cnp
);
202 VN_KNOTE(ap
->a_dvp
, NOTE_WRITE
);
209 * ufs_mknod(struct vnode *a_dvp, struct vnode **a_vpp,
210 * struct componentname *a_cnp, struct vattr *a_vap)
215 ufs_mknod(struct vop_old_mknod_args
*ap
)
217 struct vattr
*vap
= ap
->a_vap
;
218 struct vnode
**vpp
= ap
->a_vpp
;
224 * UFS cannot represent the entire major/minor range supported by
227 if (vap
->va_rmajor
!= VNOVAL
&&
228 makeudev(vap
->va_rmajor
, vap
->va_rminor
) == NOUDEV
) {
232 /* no special directory support */
233 if (vap
->va_type
== VDIR
)
236 error
= ufs_makeinode(MAKEIMODE(vap
->va_type
, vap
->va_mode
),
237 ap
->a_dvp
, vpp
, ap
->a_cnp
);
240 VN_KNOTE(ap
->a_dvp
, NOTE_WRITE
);
242 ip
->i_flag
|= IN_ACCESS
| IN_CHANGE
| IN_UPDATE
;
243 if (vap
->va_rmajor
!= VNOVAL
) {
245 * Want to be able to use this to make badblock
246 * inodes, so don't truncate the dev number.
248 ip
->i_rdev
= makeudev(vap
->va_rmajor
, vap
->va_rminor
);
251 * Remove inode, then reload it through VFS_VGET so it is
252 * checked to see if it is an alias of an existing entry in
255 (*vpp
)->v_type
= VNON
;
256 ino
= ip
->i_number
; /* Save this before vgone() invalidates ip. */
257 vgone_vxlocked(*vpp
);
259 error
= VFS_VGET(ap
->a_dvp
->v_mount
, ino
, vpp
);
272 * ufs_open(struct vnode *a_vp, int a_mode, struct ucred *a_cred,
278 ufs_open(struct vop_open_args
*ap
)
280 struct vnode
*vp
= ap
->a_vp
;
283 * Files marked append-only must be opened for appending.
285 if ((VTOI(vp
)->i_flags
& APPEND
) &&
286 (ap
->a_mode
& (FWRITE
| O_APPEND
)) == FWRITE
) {
290 return (vop_stdopen(ap
));
296 * Update the times on the inode.
298 * ufs_close(struct vnode *a_vp, int a_fflag)
303 ufs_close(struct vop_close_args
*ap
)
305 struct vnode
*vp
= ap
->a_vp
;
307 if (vp
->v_sysref
.refcnt
> 1)
309 return (vop_stdclose(ap
));
313 * ufs_access(struct vnode *a_vp, int a_mode, struct ucred *a_cred)
317 ufs_access(struct vop_access_args
*ap
)
319 struct vnode
*vp
= ap
->a_vp
;
320 struct inode
*ip
= VTOI(vp
);
321 struct ucred
*cred
= ap
->a_cred
;
322 mode_t mask
, mode
= ap
->a_mode
;
330 * Disallow write attempts on read-only filesystems;
331 * unless the file is a socket, fifo, or a block or
332 * character device resident on the filesystem.
335 switch (vp
->v_type
) {
339 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
)
342 if ((error
= ufs_getinoquota(ip
)) != 0)
351 /* If immutable bit set, nobody gets to write it. */
352 if ((mode
& VWRITE
) && (ip
->i_flags
& IMMUTABLE
))
355 /* Otherwise, user id 0 always gets access. */
356 if (cred
->cr_uid
== 0)
361 /* Otherwise, check the owner. */
362 if (cred
->cr_uid
== ip
->i_uid
) {
369 return ((ip
->i_mode
& mask
) == mask
? 0 : EACCES
);
372 /* Otherwise, check the groups. */
373 for (i
= 0, gp
= cred
->cr_groups
; i
< cred
->cr_ngroups
; i
++, gp
++)
374 if (ip
->i_gid
== *gp
) {
381 return ((ip
->i_mode
& mask
) == mask
? 0 : EACCES
);
384 /* Otherwise, check everyone else. */
391 return ((ip
->i_mode
& mask
) == mask
? 0 : EACCES
);
395 * ufs_getattr(struct vnode *a_vp, struct vattr *a_vap)
400 ufs_getattr(struct vop_getattr_args
*ap
)
402 struct vnode
*vp
= ap
->a_vp
;
403 struct inode
*ip
= VTOI(vp
);
404 struct vattr
*vap
= ap
->a_vap
;
407 * This may cause i_fsmid to be updated even if no change (0)
408 * is returned, but we should only write out the inode if non-zero
409 * is returned and if the mount is read-write.
411 if (cache_check_fsmid_vp(vp
, &ip
->i_fsmid
) &&
412 (vp
->v_mount
->mnt_flag
& MNT_RDONLY
) == 0
414 ip
->i_flag
|= IN_LAZYMOD
;
419 * Copy from inode table
421 vap
->va_fsid
= dev2udev(ip
->i_dev
);
422 vap
->va_fileid
= ip
->i_number
;
423 vap
->va_mode
= ip
->i_mode
& ~IFMT
;
424 vap
->va_nlink
= VFSTOUFS(vp
->v_mount
)->um_i_effnlink_valid
?
425 ip
->i_effnlink
: ip
->i_nlink
;
426 vap
->va_uid
= ip
->i_uid
;
427 vap
->va_gid
= ip
->i_gid
;
428 vap
->va_rmajor
= umajor(ip
->i_rdev
);
429 vap
->va_rminor
= uminor(ip
->i_rdev
);
430 vap
->va_size
= ip
->i_din
.di_size
;
431 vap
->va_atime
.tv_sec
= ip
->i_atime
;
432 vap
->va_atime
.tv_nsec
= ip
->i_atimensec
;
433 vap
->va_mtime
.tv_sec
= ip
->i_mtime
;
434 vap
->va_mtime
.tv_nsec
= ip
->i_mtimensec
;
435 vap
->va_ctime
.tv_sec
= ip
->i_ctime
;
436 vap
->va_ctime
.tv_nsec
= ip
->i_ctimensec
;
437 vap
->va_flags
= ip
->i_flags
;
438 vap
->va_gen
= ip
->i_gen
;
439 vap
->va_blocksize
= vp
->v_mount
->mnt_stat
.f_iosize
;
440 vap
->va_bytes
= dbtob((u_quad_t
)ip
->i_blocks
);
441 vap
->va_type
= IFTOVT(ip
->i_mode
);
442 vap
->va_filerev
= ip
->i_modrev
;
443 vap
->va_fsmid
= ip
->i_fsmid
;
448 * Set attribute vnode op. called from several syscalls
450 * ufs_setattr(struct vnode *a_vp, struct vattr *a_vap,
451 * struct ucred *a_cred)
455 ufs_setattr(struct vop_setattr_args
*ap
)
457 struct vattr
*vap
= ap
->a_vap
;
458 struct vnode
*vp
= ap
->a_vp
;
459 struct inode
*ip
= VTOI(vp
);
460 struct ucred
*cred
= ap
->a_cred
;
464 * Check for unsettable attributes.
466 if ((vap
->va_type
!= VNON
) || (vap
->va_nlink
!= VNOVAL
) ||
467 (vap
->va_fsid
!= VNOVAL
) || (vap
->va_fileid
!= VNOVAL
) ||
468 (vap
->va_blocksize
!= VNOVAL
) || (vap
->va_rmajor
!= VNOVAL
) ||
469 ((int)vap
->va_bytes
!= VNOVAL
) || (vap
->va_gen
!= VNOVAL
)) {
472 if (vap
->va_flags
!= VNOVAL
) {
473 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
)
475 if (cred
->cr_uid
!= ip
->i_uid
&&
476 (error
= suser_cred(cred
, PRISON_ROOT
)))
479 * Note that a root chflags becomes a user chflags when
480 * we are jailed, unless the jail.chflags_allowed sysctl
483 if (cred
->cr_uid
== 0 &&
484 (!jailed(cred
) || jail_chflags_allowed
)) {
486 & (SF_NOUNLINK
| SF_IMMUTABLE
| SF_APPEND
)) &&
489 ip
->i_flags
= vap
->va_flags
;
492 & (SF_NOUNLINK
| SF_IMMUTABLE
| SF_APPEND
) ||
493 (vap
->va_flags
& UF_SETTABLE
) != vap
->va_flags
)
495 ip
->i_flags
&= SF_SETTABLE
;
496 ip
->i_flags
|= (vap
->va_flags
& UF_SETTABLE
);
498 ip
->i_flag
|= IN_CHANGE
;
499 if (vap
->va_flags
& (IMMUTABLE
| APPEND
))
502 if (ip
->i_flags
& (IMMUTABLE
| APPEND
))
505 * Go through the fields and update iff not VNOVAL.
507 if (vap
->va_uid
!= (uid_t
)VNOVAL
|| vap
->va_gid
!= (gid_t
)VNOVAL
) {
508 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
)
510 if ((error
= ufs_chown(vp
, vap
->va_uid
, vap
->va_gid
, cred
)) != 0)
513 if (vap
->va_size
!= VNOVAL
) {
515 * Disallow write attempts on read-only filesystems;
516 * unless the file is a socket, fifo, or a block or
517 * character device resident on the filesystem.
519 switch (vp
->v_type
) {
524 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
)
530 if ((error
= ffs_truncate(vp
, vap
->va_size
, 0, cred
)) != 0)
534 if (vap
->va_atime
.tv_sec
!= VNOVAL
|| vap
->va_mtime
.tv_sec
!= VNOVAL
) {
535 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
)
537 if (cred
->cr_uid
!= ip
->i_uid
&&
538 (error
= suser_cred(cred
, PRISON_ROOT
)) &&
539 ((vap
->va_vaflags
& VA_UTIMES_NULL
) == 0 ||
540 (error
= VOP_ACCESS(vp
, VWRITE
, cred
))))
542 if (vap
->va_atime
.tv_sec
!= VNOVAL
)
543 ip
->i_flag
|= IN_ACCESS
;
544 if (vap
->va_mtime
.tv_sec
!= VNOVAL
)
545 ip
->i_flag
|= IN_CHANGE
| IN_UPDATE
;
547 if (vap
->va_atime
.tv_sec
!= VNOVAL
) {
548 ip
->i_atime
= vap
->va_atime
.tv_sec
;
549 ip
->i_atimensec
= vap
->va_atime
.tv_nsec
;
551 if (vap
->va_mtime
.tv_sec
!= VNOVAL
) {
552 ip
->i_mtime
= vap
->va_mtime
.tv_sec
;
553 ip
->i_mtimensec
= vap
->va_mtime
.tv_nsec
;
555 error
= ffs_update(vp
, 0);
560 if (vap
->va_mode
!= (mode_t
)VNOVAL
) {
561 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
)
563 error
= ufs_chmod(vp
, (int)vap
->va_mode
, cred
);
565 VN_KNOTE(vp
, NOTE_ATTRIB
);
570 * Change the mode on a file.
571 * Inode must be locked before calling.
574 ufs_chmod(struct vnode
*vp
, int mode
, struct ucred
*cred
)
576 struct inode
*ip
= VTOI(vp
);
579 if (cred
->cr_uid
!= ip
->i_uid
) {
580 error
= suser_cred(cred
, PRISON_ROOT
);
585 if (vp
->v_type
!= VDIR
&& (mode
& S_ISTXT
))
587 if (!groupmember(ip
->i_gid
, cred
) && (mode
& ISGID
))
590 ip
->i_mode
&= ~ALLPERMS
;
591 ip
->i_mode
|= (mode
& ALLPERMS
);
592 ip
->i_flag
|= IN_CHANGE
;
597 * Perform chown operation on inode ip;
598 * inode must be locked prior to call.
601 ufs_chown(struct vnode
*vp
, uid_t uid
, gid_t gid
, struct ucred
*cred
)
603 struct inode
*ip
= VTOI(vp
);
612 if (uid
== (uid_t
)VNOVAL
)
614 if (gid
== (gid_t
)VNOVAL
)
617 * If we don't own the file, are trying to change the owner
618 * of the file, or are not a member of the target group,
619 * the caller must be superuser or the call fails.
621 if ((cred
->cr_uid
!= ip
->i_uid
|| uid
!= ip
->i_uid
||
622 (gid
!= ip
->i_gid
&& !(cred
->cr_gid
== gid
||
623 groupmember((gid_t
)gid
, cred
)))) &&
624 (error
= suser_cred(cred
, PRISON_ROOT
)))
629 if ((error
= ufs_getinoquota(ip
)) != 0)
632 ufs_dqrele(vp
, ip
->i_dquot
[USRQUOTA
]);
633 ip
->i_dquot
[USRQUOTA
] = NODQUOT
;
636 ufs_dqrele(vp
, ip
->i_dquot
[GRPQUOTA
]);
637 ip
->i_dquot
[GRPQUOTA
] = NODQUOT
;
639 change
= ip
->i_blocks
;
640 (void) ufs_chkdq(ip
, -change
, cred
, CHOWN
);
641 (void) ufs_chkiq(ip
, -1, cred
, CHOWN
);
642 for (i
= 0; i
< MAXQUOTAS
; i
++) {
643 ufs_dqrele(vp
, ip
->i_dquot
[i
]);
644 ip
->i_dquot
[i
] = NODQUOT
;
650 if ((error
= ufs_getinoquota(ip
)) == 0) {
652 ufs_dqrele(vp
, ip
->i_dquot
[USRQUOTA
]);
653 ip
->i_dquot
[USRQUOTA
] = NODQUOT
;
656 ufs_dqrele(vp
, ip
->i_dquot
[GRPQUOTA
]);
657 ip
->i_dquot
[GRPQUOTA
] = NODQUOT
;
659 if ((error
= ufs_chkdq(ip
, change
, cred
, CHOWN
)) == 0) {
660 if ((error
= ufs_chkiq(ip
, 1, cred
, CHOWN
)) == 0)
663 (void)ufs_chkdq(ip
, -change
, cred
, CHOWN
|FORCE
);
665 for (i
= 0; i
< MAXQUOTAS
; i
++) {
666 ufs_dqrele(vp
, ip
->i_dquot
[i
]);
667 ip
->i_dquot
[i
] = NODQUOT
;
672 if (ufs_getinoquota(ip
) == 0) {
674 ufs_dqrele(vp
, ip
->i_dquot
[USRQUOTA
]);
675 ip
->i_dquot
[USRQUOTA
] = NODQUOT
;
678 ufs_dqrele(vp
, ip
->i_dquot
[GRPQUOTA
]);
679 ip
->i_dquot
[GRPQUOTA
] = NODQUOT
;
681 (void) ufs_chkdq(ip
, change
, cred
, FORCE
|CHOWN
);
682 (void) ufs_chkiq(ip
, 1, cred
, FORCE
|CHOWN
);
683 (void) ufs_getinoquota(ip
);
687 if (ufs_getinoquota(ip
))
688 panic("ufs_chown: lost quota");
690 ip
->i_flag
|= IN_CHANGE
;
691 if (cred
->cr_uid
!= 0 && (ouid
!= uid
|| ogid
!= gid
))
692 ip
->i_mode
&= ~(ISUID
| ISGID
);
699 * NB Currently unsupported.
701 * ufs_mmap(struct vnode *a_vp, int a_fflags, struct ucred *a_cred)
706 ufs_mmap(struct vop_mmap_args
*ap
)
712 * ufs_remove(struct vnode *a_dvp, struct vnode *a_vp,
713 * struct componentname *a_cnp)
717 ufs_remove(struct vop_old_remove_args
*ap
)
720 struct vnode
*vp
= ap
->a_vp
;
721 struct vnode
*dvp
= ap
->a_dvp
;
725 if ((ip
->i_flags
& (NOUNLINK
| IMMUTABLE
| APPEND
)) ||
726 (VTOI(dvp
)->i_flags
& APPEND
)) {
730 error
= ufs_dirremove(dvp
, ip
, ap
->a_cnp
->cn_flags
, 0);
731 VN_KNOTE(vp
, NOTE_DELETE
);
732 VN_KNOTE(dvp
, NOTE_WRITE
);
740 * ufs_link(struct vnode *a_tdvp, struct vnode *a_vp,
741 * struct componentname *a_cnp)
745 ufs_link(struct vop_old_link_args
*ap
)
747 struct vnode
*vp
= ap
->a_vp
;
748 struct vnode
*tdvp
= ap
->a_tdvp
;
749 struct componentname
*cnp
= ap
->a_cnp
;
751 struct direct newdir
;
754 if (tdvp
->v_mount
!= vp
->v_mount
) {
758 if (tdvp
!= vp
&& (error
= vn_lock(vp
, LK_EXCLUSIVE
))) {
762 if ((nlink_t
)ip
->i_nlink
>= LINK_MAX
) {
766 if (ip
->i_flags
& (IMMUTABLE
| APPEND
)) {
772 ip
->i_flag
|= IN_CHANGE
;
773 if (DOINGSOFTDEP(vp
))
774 softdep_change_linkcnt(ip
);
775 error
= ffs_update(vp
, !(DOINGSOFTDEP(vp
) | DOINGASYNC(vp
)));
777 ufs_makedirentry(ip
, cnp
, &newdir
);
778 error
= ufs_direnter(tdvp
, vp
, &newdir
, cnp
, NULL
);
784 ip
->i_flag
|= IN_CHANGE
;
785 if (DOINGSOFTDEP(vp
))
786 softdep_change_linkcnt(ip
);
792 VN_KNOTE(vp
, NOTE_LINK
);
793 VN_KNOTE(tdvp
, NOTE_WRITE
);
798 * whiteout vnode call
800 * ufs_whiteout(struct vnode *a_dvp, struct componentname *a_cnp, int a_flags)
804 ufs_whiteout(struct vop_old_whiteout_args
*ap
)
806 struct vnode
*dvp
= ap
->a_dvp
;
807 struct componentname
*cnp
= ap
->a_cnp
;
808 struct direct newdir
;
811 switch (ap
->a_flags
) {
813 /* 4.4 format directories support whiteout operations */
814 if (dvp
->v_mount
->mnt_maxsymlinklen
> 0)
819 /* create a new directory whiteout */
821 if (dvp
->v_mount
->mnt_maxsymlinklen
<= 0)
822 panic("ufs_whiteout: old format filesystem");
826 newdir
.d_namlen
= cnp
->cn_namelen
;
827 bcopy(cnp
->cn_nameptr
, newdir
.d_name
, (unsigned)cnp
->cn_namelen
+ 1);
828 newdir
.d_type
= DT_WHT
;
829 error
= ufs_direnter(dvp
, NULL
, &newdir
, cnp
, NULL
);
833 /* remove an existing directory whiteout */
835 if (dvp
->v_mount
->mnt_maxsymlinklen
<= 0)
836 panic("ufs_whiteout: old format filesystem");
839 cnp
->cn_flags
&= ~CNP_DOWHITEOUT
;
840 error
= ufs_dirremove(dvp
, NULL
, cnp
->cn_flags
, 0);
843 panic("ufs_whiteout: unknown op");
849 * Rename system call.
850 * rename("foo", "bar");
853 * link("foo", "bar");
855 * but ``atomically''. Can't do full commit without saving state in the
856 * inode on disk which isn't feasible at this time. Best we can do is
857 * always guarantee the target exists.
859 * Basic algorithm is:
861 * 1) Bump link count on source while we're linking it to the
862 * target. This also ensure the inode won't be deleted out
863 * from underneath us while we work (it may be truncated by
864 * a concurrent `trunc' or `open' for creation).
865 * 2) Link source to destination. If destination already exists,
867 * 3) Unlink source reference to inode if still around. If a
868 * directory was moved and the parent of the destination
869 * is different from the source, patch the ".." entry in the
872 * ufs_rename(struct vnode *a_fdvp, struct vnode *a_fvp,
873 * struct componentname *a_fcnp, struct vnode *a_tdvp,
874 * struct vnode *a_tvp, struct componentname *a_tcnp)
878 ufs_rename(struct vop_old_rename_args
*ap
)
880 struct vnode
*tvp
= ap
->a_tvp
;
881 struct vnode
*tdvp
= ap
->a_tdvp
;
882 struct vnode
*fvp
= ap
->a_fvp
;
883 struct vnode
*fdvp
= ap
->a_fdvp
;
884 struct componentname
*tcnp
= ap
->a_tcnp
;
885 struct componentname
*fcnp
= ap
->a_fcnp
;
886 struct inode
*ip
, *xp
, *dp
;
887 struct direct newdir
;
888 ino_t oldparent
= 0, newparent
= 0;
889 int doingdirectory
= 0;
890 int error
= 0, ioflag
;
893 * Check for cross-device rename.
895 if ((fvp
->v_mount
!= tdvp
->v_mount
) ||
896 (tvp
&& (fvp
->v_mount
!= tvp
->v_mount
))) {
910 if (tvp
&& ((VTOI(tvp
)->i_flags
& (NOUNLINK
| IMMUTABLE
| APPEND
)) ||
911 (VTOI(tdvp
)->i_flags
& APPEND
))) {
917 * Renaming a file to itself has no effect. The upper layers should
918 * not call us in that case. Temporarily just warn if they do.
921 kprintf("ufs_rename: fvp == tvp (can't happen)\n");
926 if ((error
= vn_lock(fvp
, LK_EXCLUSIVE
)) != 0)
930 * Note: now that fvp is locked we have to be sure to unlock it before
931 * using the 'abortit' target.
935 if (ip
->i_nlink
>= LINK_MAX
) {
940 if ((ip
->i_flags
& (NOUNLINK
| IMMUTABLE
| APPEND
))
941 || (dp
->i_flags
& APPEND
)) {
946 if ((ip
->i_mode
& IFMT
) == IFDIR
) {
948 * Avoid ".", "..", and aliases of "." for obvious reasons.
950 if ((fcnp
->cn_namelen
== 1 && fcnp
->cn_nameptr
[0] == '.') ||
951 dp
== ip
|| (fcnp
->cn_flags
| tcnp
->cn_flags
) & CNP_ISDOTDOT
||
952 (ip
->i_flag
& IN_RENAME
)) {
957 ip
->i_flag
|= IN_RENAME
;
958 oldparent
= dp
->i_number
;
961 VN_KNOTE(fdvp
, NOTE_WRITE
); /* XXX right place? */
964 * fvp still locked. ip->i_flag has IN_RENAME set if doingdirectory.
965 * Cleanup fvp requirements so we can unlock it.
967 * tvp and tdvp are locked. tvp may be NULL. Now that dp and xp
968 * is setup we can use the 'bad' target if we unlock fvp. We cannot
969 * use the abortit target anymore because of IN_RENAME.
978 * 1) Bump link count while we're moving stuff
979 * around. If we crash somewhere before
980 * completing our work, the link count
981 * may be wrong, but correctable.
985 ip
->i_flag
|= IN_CHANGE
;
986 if (DOINGSOFTDEP(fvp
))
987 softdep_change_linkcnt(ip
);
988 if ((error
= ffs_update(fvp
, !(DOINGSOFTDEP(fvp
) |
989 DOINGASYNC(fvp
)))) != 0) {
995 * If ".." must be changed (ie the directory gets a new
996 * parent) then the source directory must not be in the
997 * directory heirarchy above the target, as this would
998 * orphan everything below the source directory. Also
999 * the user must have write permission in the source so
1000 * as to be able to change "..". We must repeat the call
1001 * to namei, as the parent directory is unlocked by the
1002 * call to checkpath().
1004 error
= VOP_ACCESS(fvp
, VWRITE
, tcnp
->cn_cred
);
1008 * We are now back to where we were in that fvp, fdvp are unlocked
1009 * and tvp, tdvp are locked. tvp may be NULL. IN_RENAME may be
1010 * set. Only the bad target or, if we clean up tvp and tdvp, the
1011 * out target, may be used.
1013 if (oldparent
!= dp
->i_number
)
1014 newparent
= dp
->i_number
;
1015 if (doingdirectory
&& newparent
) {
1016 if (error
) /* write access check above */
1020 * Once we start messing with tvp and tdvp we cannot use the
1021 * 'bad' target, only finish cleaning tdvp and tvp up and
1022 * use the 'out' target.
1024 * This cleans up tvp.
1032 * This is a real mess. ufs_checkpath vput's the target
1033 * directory so retain an extra ref and note that tdvp will
1034 * lose its lock on return. This leaves us with one good
1035 * ref after ufs_checkpath returns.
1038 error
= ufs_checkpath(ip
, dp
, tcnp
->cn_cred
);
1039 tcnp
->cn_flags
|= CNP_PDIRUNLOCK
;
1046 * relookup no longer messes with tdvp's refs. tdvp must be
1047 * unlocked on entry and will be locked on a successful
1050 error
= relookup(tdvp
, &tvp
, tcnp
);
1052 if (tcnp
->cn_flags
& CNP_PDIRUNLOCK
)
1058 KKASSERT((tcnp
->cn_flags
& CNP_PDIRUNLOCK
) == 0);
1065 * We are back to fvp, fdvp unlocked, tvp, tdvp locked. tvp may
1066 * be NULL (xp will also be NULL in that case), and IN_RENAME will
1067 * be set if doingdirectory. This means we can use the 'bad' target
1072 * 2) If target doesn't exist, link the target
1073 * to the source and unlink the source.
1074 * Otherwise, rewrite the target directory
1075 * entry to reference the source inode and
1076 * expunge the original entry's existence.
1079 if (dp
->i_dev
!= ip
->i_dev
)
1080 panic("ufs_rename: EXDEV");
1082 * Account for ".." in new directory.
1083 * When source and destination have the same
1084 * parent we don't fool with the link count.
1086 if (doingdirectory
&& newparent
) {
1087 if ((nlink_t
)dp
->i_nlink
>= LINK_MAX
) {
1093 dp
->i_flag
|= IN_CHANGE
;
1094 if (DOINGSOFTDEP(tdvp
))
1095 softdep_change_linkcnt(dp
);
1096 error
= ffs_update(tdvp
, !(DOINGSOFTDEP(tdvp
) |
1101 ufs_makedirentry(ip
, tcnp
, &newdir
);
1102 error
= ufs_direnter(tdvp
, NULL
, &newdir
, tcnp
, NULL
);
1104 if (doingdirectory
&& newparent
) {
1107 dp
->i_flag
|= IN_CHANGE
;
1108 if (DOINGSOFTDEP(tdvp
))
1109 softdep_change_linkcnt(dp
);
1110 (void)ffs_update(tdvp
, 1);
1114 VN_KNOTE(tdvp
, NOTE_WRITE
);
1117 if (xp
->i_dev
!= dp
->i_dev
|| xp
->i_dev
!= ip
->i_dev
)
1118 panic("ufs_rename: EXDEV");
1120 * Short circuit rename(foo, foo).
1122 if (xp
->i_number
== ip
->i_number
)
1123 panic("ufs_rename: same file");
1125 * If the parent directory is "sticky", then the user must
1126 * own the parent directory, or the destination of the rename,
1127 * otherwise the destination may not be changed (except by
1128 * root). This implements append-only directories.
1130 if ((dp
->i_mode
& S_ISTXT
) && tcnp
->cn_cred
->cr_uid
!= 0 &&
1131 tcnp
->cn_cred
->cr_uid
!= dp
->i_uid
&&
1132 xp
->i_uid
!= tcnp
->cn_cred
->cr_uid
) {
1137 * Target must be empty if a directory and have no links
1138 * to it. Also, ensure source and target are compatible
1139 * (both directories, or both not directories).
1141 * Purge the file or directory being replaced from the
1144 if ((xp
->i_mode
&IFMT
) == IFDIR
) {
1145 if ((xp
->i_effnlink
> 2) ||
1146 !ufs_dirempty(xp
, dp
->i_number
, tcnp
->cn_cred
)) {
1150 if (!doingdirectory
) {
1154 /* cache_purge removed - handled by VFS compat layer */
1155 } else if (doingdirectory
== 0) {
1156 /* cache_purge removed - handled by VFS compat layer */
1162 * note: inode passed to ufs_dirrewrite() is 0 for a
1163 * non-directory file rename, 1 for a directory rename
1164 * in the same directory, and > 1 for an inode representing
1165 * the new directory.
1167 error
= ufs_dirrewrite(dp
, xp
, ip
->i_number
,
1169 (doingdirectory
&& newparent
) ?
1170 newparent
: (ino_t
)doingdirectory
);
1173 if (doingdirectory
) {
1176 if (DOINGSOFTDEP(tdvp
))
1177 softdep_change_linkcnt(dp
);
1180 if (DOINGSOFTDEP(tvp
))
1181 softdep_change_linkcnt(xp
);
1183 if (doingdirectory
&& !DOINGSOFTDEP(tvp
)) {
1185 * Truncate inode. The only stuff left in the directory
1186 * is "." and "..". The "." reference is inconsequential
1187 * since we are quashing it. We have removed the "."
1188 * reference and the reference in the parent directory,
1189 * but there may be other hard links. The soft
1190 * dependency code will arrange to do these operations
1191 * after the parent directory entry has been deleted on
1192 * disk, so when running with that code we avoid doing
1197 dp
->i_flag
|= IN_CHANGE
;
1200 xp
->i_flag
|= IN_CHANGE
;
1201 ioflag
= DOINGASYNC(tvp
) ? 0 : IO_SYNC
;
1202 error
= ffs_truncate(tvp
, (off_t
)0, ioflag
,
1207 VN_KNOTE(tdvp
, NOTE_WRITE
);
1209 VN_KNOTE(tvp
, NOTE_DELETE
);
1215 * tvp and tdvp have been cleaned up. only fvp and fdvp (both
1216 * unlocked) remain. We are about to overwrite fvp but we have to
1217 * keep 'ip' intact so we cannot release the old fvp, which is still
1218 * refd and accessible via ap->a_fvp.
1220 * This means we cannot use either 'bad' or 'out' to cleanup any
1225 * 3) Unlink the source.
1227 fcnp
->cn_flags
&= ~CNP_MODMASK
;
1228 fcnp
->cn_flags
|= CNP_LOCKPARENT
;
1229 error
= relookup(fdvp
, &fvp
, fcnp
);
1230 if (error
|| fvp
== NULL
) {
1232 * From name has disappeared. IN_RENAME will not be set if
1233 * we get past the panic so we don't have to clean it up.
1236 panic("ufs_rename: lost dir entry");
1238 if (fcnp
->cn_flags
& CNP_PDIRUNLOCK
)
1244 KKASSERT((fcnp
->cn_flags
& CNP_PDIRUNLOCK
) == 0);
1247 * fdvp and fvp are locked.
1253 * Ensure that the directory entry still exists and has not
1254 * changed while the new name has been entered. If the source is
1255 * a file then the entry may have been unlinked or renamed. In
1256 * either case there is no further work to be done. If the source
1257 * is a directory then it cannot have been rmdir'ed; the IN_RENAME
1258 * flag ensures that it cannot be moved by another rename or removed
1259 * by a rmdir. Cleanup IN_RENAME.
1263 panic("ufs_rename: lost dir entry");
1266 * If the source is a directory with a
1267 * new parent, the link count of the old
1268 * parent directory must be decremented
1269 * and ".." set to point to the new parent.
1271 if (doingdirectory
&& newparent
) {
1272 xp
->i_offset
= mastertemplate
.dot_reclen
;
1273 ufs_dirrewrite(xp
, dp
, newparent
, DT_DIR
, 0);
1274 /* cache_purge removed - handled by VFS compat layer */
1276 error
= ufs_dirremove(fdvp
, xp
, fcnp
->cn_flags
, 0);
1277 xp
->i_flag
&= ~IN_RENAME
;
1280 VN_KNOTE(fvp
, NOTE_RENAME
);
1292 ip
->i_flag
&= ~IN_RENAME
;
1293 if (vn_lock(fvp
, LK_EXCLUSIVE
) == 0) {
1296 ip
->i_flag
|= IN_CHANGE
;
1297 ip
->i_flag
&= ~IN_RENAME
;
1298 if (DOINGSOFTDEP(fvp
))
1299 softdep_change_linkcnt(ip
);
1310 * ufs_mkdir(struct vnode *a_dvp, struct vnode **a_vpp,
1311 * struct componentname *a_cnp, struct vattr *a_vap)
1315 ufs_mkdir(struct vop_old_mkdir_args
*ap
)
1317 struct vnode
*dvp
= ap
->a_dvp
;
1318 struct vattr
*vap
= ap
->a_vap
;
1319 struct componentname
*cnp
= ap
->a_cnp
;
1320 struct inode
*ip
, *dp
;
1323 struct dirtemplate dirtemplate
, *dtp
;
1324 struct direct newdir
;
1329 if ((nlink_t
)dp
->i_nlink
>= LINK_MAX
) {
1333 dmode
= vap
->va_mode
& 0777;
1336 * Must simulate part of ufs_makeinode here to acquire the inode,
1337 * but not have it entered in the parent directory. The entry is
1338 * made later after writing "." and ".." entries.
1340 error
= ffs_valloc(dvp
, dmode
, cnp
->cn_cred
, &tvp
);
1344 ip
->i_gid
= dp
->i_gid
;
1348 struct ucred ucred
, *ucp
;
1352 * If we are hacking owners here, (only do this where told to)
1353 * and we are not giving it TO root, (would subvert quotas)
1354 * then go ahead and give it to the other user.
1355 * The new directory also inherits the SUID bit.
1356 * If user's UID and dir UID are the same,
1357 * 'give it away' so that the SUID is still forced on.
1359 if ((dvp
->v_mount
->mnt_flag
& MNT_SUIDDIR
) &&
1360 (dp
->i_mode
& ISUID
) && dp
->i_uid
) {
1362 ip
->i_uid
= dp
->i_uid
;
1364 if (dp
->i_uid
!= cnp
->cn_cred
->cr_uid
) {
1366 * Make sure the correct user gets charged
1368 * Make a dummy credential for the victim.
1369 * XXX This seems to never be accessed out of
1370 * our context so a stack variable is ok.
1373 ucred
.cr_uid
= ip
->i_uid
;
1374 ucred
.cr_ngroups
= 1;
1375 ucred
.cr_groups
[0] = dp
->i_gid
;
1380 ip
->i_uid
= cnp
->cn_cred
->cr_uid
;
1382 if ((error
= ufs_getinoquota(ip
)) ||
1383 (error
= ufs_chkiq(ip
, 1, ucp
, 0))) {
1384 ffs_vfree(tvp
, ip
->i_number
, dmode
);
1390 #else /* !SUIDDIR */
1391 ip
->i_uid
= cnp
->cn_cred
->cr_uid
;
1393 if ((error
= ufs_getinoquota(ip
)) ||
1394 (error
= ufs_chkiq(ip
, 1, cnp
->cn_cred
, 0))) {
1395 ffs_vfree(tvp
, ip
->i_number
, dmode
);
1400 #endif /* !SUIDDIR */
1401 ip
->i_flag
|= IN_ACCESS
| IN_CHANGE
| IN_UPDATE
;
1403 tvp
->v_type
= VDIR
; /* Rest init'd in getnewvnode(). */
1406 if (DOINGSOFTDEP(tvp
))
1407 softdep_change_linkcnt(ip
);
1408 if (cnp
->cn_flags
& CNP_ISWHITEOUT
)
1409 ip
->i_flags
|= UF_OPAQUE
;
1412 * Bump link count in parent directory to reflect work done below.
1413 * Should be done before reference is created so cleanup is
1414 * possible if we crash.
1418 dp
->i_flag
|= IN_CHANGE
;
1419 if (DOINGSOFTDEP(dvp
))
1420 softdep_change_linkcnt(dp
);
1421 error
= ffs_update(tvp
, !(DOINGSOFTDEP(dvp
) | DOINGASYNC(dvp
)));
1426 * The vnode must have a VM object in order to issue buffer cache
1429 vinitvmio(tvp
, DIRBLKSIZ
);
1432 * Initialize directory with "." and ".." from static template.
1434 if (dvp
->v_mount
->mnt_maxsymlinklen
> 0)
1435 dtp
= &mastertemplate
;
1437 dtp
= (struct dirtemplate
*)&omastertemplate
;
1439 dirtemplate
.dot_ino
= ip
->i_number
;
1440 dirtemplate
.dotdot_ino
= dp
->i_number
;
1441 vnode_pager_setsize(tvp
, DIRBLKSIZ
);
1442 error
= VOP_BALLOC(tvp
, 0LL, DIRBLKSIZ
, cnp
->cn_cred
, B_CLRBUF
, &bp
);
1445 ip
->i_size
= DIRBLKSIZ
;
1446 ip
->i_flag
|= IN_CHANGE
| IN_UPDATE
;
1447 bcopy((caddr_t
)&dirtemplate
, (caddr_t
)bp
->b_data
, sizeof dirtemplate
);
1448 if (DOINGSOFTDEP(tvp
)) {
1450 * Ensure that the entire newly allocated block is a
1451 * valid directory so that future growth within the
1452 * block does not have to ensure that the block is
1453 * written before the inode.
1456 while (blkoff
< bp
->b_bcount
) {
1458 (bp
->b_data
+ blkoff
))->d_reclen
= DIRBLKSIZ
;
1459 blkoff
+= DIRBLKSIZ
;
1462 if ((error
= ffs_update(tvp
, !(DOINGSOFTDEP(tvp
) |
1463 DOINGASYNC(tvp
)))) != 0) {
1468 * Directory set up, now install its entry in the parent directory.
1470 * If we are not doing soft dependencies, then we must write out the
1471 * buffer containing the new directory body before entering the new
1472 * name in the parent. If we are doing soft dependencies, then the
1473 * buffer containing the new directory body will be passed to and
1474 * released in the soft dependency code after the code has attached
1475 * an appropriate ordering dependency to the buffer which ensures that
1476 * the buffer is written before the new name is written in the parent.
1478 if (DOINGASYNC(dvp
))
1480 else if (!DOINGSOFTDEP(dvp
) && (error
= bwrite(bp
)) != 0)
1482 ufs_makedirentry(ip
, cnp
, &newdir
);
1483 error
= ufs_direnter(dvp
, tvp
, &newdir
, cnp
, bp
);
1487 VN_KNOTE(dvp
, NOTE_WRITE
| NOTE_LINK
);
1492 dp
->i_flag
|= IN_CHANGE
;
1493 if (DOINGSOFTDEP(dvp
))
1494 softdep_change_linkcnt(dp
);
1496 * No need to do an explicit VOP_TRUNCATE here, vrele will
1497 * do this for us because we set the link count to 0.
1501 ip
->i_flag
|= IN_CHANGE
;
1502 if (DOINGSOFTDEP(tvp
))
1503 softdep_change_linkcnt(ip
);
1511 * Rmdir system call.
1513 * ufs_rmdir(struct vnode *a_dvp, struct vnode *a_vp,
1514 * struct componentname *a_cnp)
1518 ufs_rmdir(struct vop_old_rmdir_args
*ap
)
1520 struct vnode
*vp
= ap
->a_vp
;
1521 struct vnode
*dvp
= ap
->a_dvp
;
1522 struct componentname
*cnp
= ap
->a_cnp
;
1523 struct inode
*ip
, *dp
;
1530 * Do not remove a directory that is in the process of being renamed.
1531 * Verify the directory is empty (and valid). Rmdir ".." will not be
1532 * valid since ".." will contain a reference to the current directory
1533 * and thus be non-empty. Do not allow the removal of mounted on
1534 * directories (this can happen when an NFS exported filesystem
1535 * tries to remove a locally mounted on directory).
1538 if (ip
->i_flag
& IN_RENAME
) {
1542 if (ip
->i_effnlink
!= 2 ||
1543 !ufs_dirempty(ip
, dp
->i_number
, cnp
->cn_cred
)) {
1547 if ((dp
->i_flags
& APPEND
)
1548 || (ip
->i_flags
& (NOUNLINK
| IMMUTABLE
| APPEND
))) {
1553 * Delete reference to directory before purging
1554 * inode. If we crash in between, the directory
1555 * will be reattached to lost+found,
1559 if (DOINGSOFTDEP(vp
)) {
1560 softdep_change_linkcnt(dp
);
1561 softdep_change_linkcnt(ip
);
1563 error
= ufs_dirremove(dvp
, ip
, cnp
->cn_flags
, 1);
1567 if (DOINGSOFTDEP(vp
)) {
1568 softdep_change_linkcnt(dp
);
1569 softdep_change_linkcnt(ip
);
1573 VN_KNOTE(dvp
, NOTE_WRITE
| NOTE_LINK
);
1575 * Truncate inode. The only stuff left in the directory is "." and
1576 * "..". The "." reference is inconsequential since we are quashing
1577 * it. The soft dependency code will arrange to do these operations
1578 * after the parent directory entry has been deleted on disk, so
1579 * when running with that code we avoid doing them now.
1581 if (!DOINGSOFTDEP(vp
)) {
1583 dp
->i_flag
|= IN_CHANGE
;
1585 ip
->i_flag
|= IN_CHANGE
;
1586 ioflag
= DOINGASYNC(vp
) ? 0 : IO_SYNC
;
1587 error
= ffs_truncate(vp
, (off_t
)0, ioflag
, cnp
->cn_cred
);
1589 /* cache_purge removed - handled by VFS compat layer */
1591 /* Kill any active hash; i_effnlink == 0, so it will not come back. */
1592 if (ip
->i_dirhash
!= NULL
)
1593 ufsdirhash_free(ip
);
1596 VN_KNOTE(vp
, NOTE_DELETE
);
1601 * symlink -- make a symbolic link
1603 * ufs_symlink(struct vnode *a_dvp, struct vnode **a_vpp,
1604 * struct componentname *a_cnp, struct vattr *a_vap,
1609 ufs_symlink(struct vop_old_symlink_args
*ap
)
1611 struct vnode
*vp
, **vpp
= ap
->a_vpp
;
1615 error
= ufs_makeinode(IFLNK
| ap
->a_vap
->va_mode
, ap
->a_dvp
,
1619 VN_KNOTE(ap
->a_dvp
, NOTE_WRITE
);
1621 len
= strlen(ap
->a_target
);
1622 if (len
< vp
->v_mount
->mnt_maxsymlinklen
) {
1624 bcopy(ap
->a_target
, (char *)ip
->i_shortlink
, len
);
1626 ip
->i_flag
|= IN_CHANGE
| IN_UPDATE
;
1629 * Make sure we have a VM object in order to use
1632 if (vp
->v_object
== NULL
)
1634 error
= vn_rdwr(UIO_WRITE
, vp
, ap
->a_target
, len
, (off_t
)0,
1635 UIO_SYSSPACE
, IO_NODELOCKED
,
1636 ap
->a_cnp
->cn_cred
, NULL
);
1644 * Vnode op for reading directories.
1646 * ufs_readdir(struct vnode *a_vp, struct uio *a_uio, struct ucred *a_cred,
1647 * int *a_eofflag, int *ncookies, off_t **a_cookies)
1651 ufs_readdir(struct vop_readdir_args
*ap
)
1653 struct uio
*uio
= ap
->a_uio
;
1654 struct vnode
*vp
= ap
->a_vp
;
1659 int offset
; /* offset into buffer cache buffer */
1660 int eoffset
; /* end of buffer clipped to file EOF */
1661 int pickup
; /* pickup point */
1666 if (uio
->uio_offset
< 0)
1669 * Guess the number of cookies needed. Make sure we compute at
1670 * least 1, and no more then a reasonable limit.
1672 if (ap
->a_ncookies
) {
1673 ncookies
= uio
->uio_resid
/ 16 + 1;
1674 if (ncookies
> 1024)
1676 cookies
= kmalloc(ncookies
* sizeof(off_t
), M_TEMP
, M_WAITOK
);
1678 ncookies
= -1; /* force conditionals below */
1683 if ((error
= vn_lock(vp
, LK_EXCLUSIVE
| LK_RETRY
)) != 0)
1689 if (uio
->uio_offset
>= VTOI(vp
)->i_size
) {
1692 if (ap
->a_ncookies
) {
1693 *ap
->a_ncookies
= cookie_index
;
1694 *ap
->a_cookies
= cookies
;
1700 * Loop until we run out of cookies, we run out of user buffer,
1701 * or we hit the directory EOF.
1703 * Always start scans at the beginning of the buffer, don't trust
1704 * the offset supplied by userland.
1706 while ((error
= ffs_blkatoff_ra(vp
, uio
->uio_offset
, NULL
, &bp
, 2)) == 0) {
1707 pickup
= (int)(uio
->uio_offset
- bp
->b_loffset
);
1710 if (bp
->b_loffset
+ bp
->b_bcount
> VTOI(vp
)->i_size
)
1711 eoffset
= (int)(VTOI(vp
)->i_size
- bp
->b_loffset
);
1713 eoffset
= bp
->b_bcount
;
1715 while (offset
< eoffset
) {
1716 dp
= (struct direct
*)(bp
->b_data
+ offset
);
1717 if (dp
->d_reclen
<= 0 || (dp
->d_reclen
& 3) ||
1718 offset
+ dp
->d_reclen
> bp
->b_bcount
) {
1722 if (offsetof(struct direct
, d_name
[dp
->d_namlen
]) > dp
->d_reclen
) {
1726 if (offset
< pickup
) {
1727 offset
+= dp
->d_reclen
;
1730 #if BYTE_ORDER == LITTLE_ENDIAN
1732 retval
= vop_write_dirent(&error
, uio
,
1733 dp
->d_ino
, dp
->d_namlen
, dp
->d_type
,
1738 retval
= vop_write_dirent(&error
, uio
,
1739 dp
->d_ino
, dp
->d_type
, dp
->d_namlen
,
1745 cookies
[cookie_index
] = bp
->b_loffset
+ offset
;
1747 offset
+= dp
->d_reclen
;
1748 if (cookie_index
== ncookies
)
1753 * This will align the next loop to the beginning of the
1754 * next block, and pickup will calculate to 0.
1756 uio
->uio_offset
= bp
->b_loffset
+ offset
;
1759 if (retval
|| error
|| cookie_index
== ncookies
||
1760 uio
->uio_offset
>= VTOI(vp
)->i_size
) {
1765 *ap
->a_eofflag
= VTOI(vp
)->i_size
<= uio
->uio_offset
;
1768 * Report errors only if we didn't manage to read anything
1770 if (error
&& cookie_index
== 0) {
1772 kfree(cookies
, M_TEMP
);
1773 *ap
->a_ncookies
= 0;
1774 *ap
->a_cookies
= NULL
;
1779 *ap
->a_ncookies
= cookie_index
;
1780 *ap
->a_cookies
= cookies
;
1789 * Return target name of a symbolic link
1791 * ufs_readlink(struct vnode *a_vp, struct uio *a_uio, struct ucred *a_cred)
1795 ufs_readlink(struct vop_readlink_args
*ap
)
1797 struct vnode
*vp
= ap
->a_vp
;
1798 struct inode
*ip
= VTOI(vp
);
1802 if ((isize
< vp
->v_mount
->mnt_maxsymlinklen
) ||
1803 (ip
->i_din
.di_blocks
== 0)) { /* XXX - for old fastlink support */
1804 uiomove((char *)ip
->i_shortlink
, isize
, ap
->a_uio
);
1809 * Perform the equivalent of an OPEN on vp so we can issue a
1812 return (VOP_READ(vp
, ap
->a_uio
, 0, ap
->a_cred
));
1816 * Calculate the logical to physical mapping if not done already,
1817 * then call the device strategy routine.
1819 * In order to be able to swap to a file, the VOP_BMAP operation may not
1820 * deadlock on memory. See ufs_bmap() for details.
1822 * ufs_strategy(struct vnode *a_vp, struct bio *a_bio)
1826 ufs_strategy(struct vop_strategy_args
*ap
)
1828 struct bio
*bio
= ap
->a_bio
;
1830 struct buf
*bp
= bio
->bio_buf
;
1831 struct vnode
*vp
= ap
->a_vp
;
1836 if (vp
->v_type
== VBLK
|| vp
->v_type
== VCHR
)
1837 panic("ufs_strategy: spec");
1838 nbio
= push_bio(bio
);
1839 if (nbio
->bio_offset
== NOOFFSET
) {
1840 error
= VOP_BMAP(vp
, bio
->bio_offset
, &nbio
->bio_offset
,
1841 NULL
, NULL
, bp
->b_cmd
);
1843 bp
->b_error
= error
;
1844 bp
->b_flags
|= B_ERROR
;
1845 /* I/O was never started on nbio, must biodone(bio) */
1849 if (nbio
->bio_offset
== NOOFFSET
)
1852 if (nbio
->bio_offset
== NOOFFSET
) {
1854 * We hit a hole in the file. The buffer has been zero-filled
1855 * so just biodone() it.
1859 vn_strategy(ip
->i_devvp
, nbio
);
1865 * Print out the contents of an inode.
1867 * ufs_print(struct vnode *a_vp)
1871 ufs_print(struct vop_print_args
*ap
)
1873 struct vnode
*vp
= ap
->a_vp
;
1874 struct inode
*ip
= VTOI(vp
);
1876 kprintf("tag VT_UFS, ino %lu, on dev %s (%d, %d)",
1877 (u_long
)ip
->i_number
, devtoname(ip
->i_dev
), major(ip
->i_dev
),
1879 if (vp
->v_type
== VFIFO
)
1881 lockmgr_printinfo(&vp
->v_lock
);
1887 * Read wrapper for special devices.
1889 * ufsspec_read(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
1890 * struct ucred *a_cred)
1894 ufsspec_read(struct vop_read_args
*ap
)
1901 resid
= uio
->uio_resid
;
1902 error
= VOCALL(&spec_vnode_vops
, &ap
->a_head
);
1904 * The inode may have been revoked during the call, so it must not
1905 * be accessed blindly here or in the other wrapper functions.
1907 ip
= VTOI(ap
->a_vp
);
1908 if (ip
!= NULL
&& (uio
->uio_resid
!= resid
|| (error
== 0 && resid
!= 0)))
1909 ip
->i_flag
|= IN_ACCESS
;
1914 * Write wrapper for special devices.
1916 * ufsspec_write(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
1917 * struct ucred *a_cred)
1921 ufsspec_write(struct vop_write_args
*ap
)
1928 resid
= uio
->uio_resid
;
1929 error
= VOCALL(&spec_vnode_vops
, &ap
->a_head
);
1930 ip
= VTOI(ap
->a_vp
);
1931 if (ip
!= NULL
&& (uio
->uio_resid
!= resid
|| (error
== 0 && resid
!= 0)))
1932 VTOI(ap
->a_vp
)->i_flag
|= IN_CHANGE
| IN_UPDATE
;
1937 * Close wrapper for special devices.
1939 * Update the times on the inode then do device close.
1941 * ufsspec_close(struct vnode *a_vp, int a_fflag)
1945 ufsspec_close(struct vop_close_args
*ap
)
1947 struct vnode
*vp
= ap
->a_vp
;
1949 if (vp
->v_sysref
.refcnt
> 1)
1951 return (VOCALL(&spec_vnode_vops
, &ap
->a_head
));
1955 * Read wrapper for fifos.
1957 * ufsfifo_read(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
1958 * struct ucred *a_cred)
1962 ufsfifo_read(struct vop_read_args
*ap
)
1969 resid
= uio
->uio_resid
;
1970 error
= VOCALL(&fifo_vnode_vops
, &ap
->a_head
);
1971 ip
= VTOI(ap
->a_vp
);
1972 if ((ap
->a_vp
->v_mount
->mnt_flag
& MNT_NOATIME
) == 0 && ip
!= NULL
&&
1973 (uio
->uio_resid
!= resid
|| (error
== 0 && resid
!= 0)))
1974 VTOI(ap
->a_vp
)->i_flag
|= IN_ACCESS
;
1979 * Write wrapper for fifos.
1981 * ufsfifo_write(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
1982 * struct ucred *a_cred)
1986 ufsfifo_write(struct vop_write_args
*ap
)
1993 resid
= uio
->uio_resid
;
1994 error
= VOCALL(&fifo_vnode_vops
, &ap
->a_head
);
1995 ip
= VTOI(ap
->a_vp
);
1996 if (ip
!= NULL
&& (uio
->uio_resid
!= resid
|| (error
== 0 && resid
!= 0)))
1997 VTOI(ap
->a_vp
)->i_flag
|= IN_CHANGE
| IN_UPDATE
;
2002 * Close wrapper for fifos.
2004 * Update the times on the inode then do device close.
2006 * ufsfifo_close(struct vnode *a_vp, int a_fflag)
2010 ufsfifo_close(struct vop_close_args
*ap
)
2012 struct vnode
*vp
= ap
->a_vp
;
2014 if (vp
->v_sysref
.refcnt
> 1)
2016 return (VOCALL(&fifo_vnode_vops
, &ap
->a_head
));
2020 * Kqfilter wrapper for fifos.
2022 * Fall through to ufs kqfilter routines if needed
2026 ufsfifo_kqfilter(struct vop_kqfilter_args
*ap
)
2030 error
= VOCALL(&fifo_vnode_vops
, &ap
->a_head
);
2032 error
= ufs_kqfilter(ap
);
2037 * Return POSIX pathconf information applicable to ufs filesystems.
2039 * ufs_pathconf(struct vnode *a_vp, int a_name, int *a_retval)
2043 ufs_pathconf(struct vop_pathconf_args
*ap
)
2045 switch (ap
->a_name
) {
2047 *ap
->a_retval
= LINK_MAX
;
2050 *ap
->a_retval
= NAME_MAX
;
2053 *ap
->a_retval
= PATH_MAX
;
2056 *ap
->a_retval
= PIPE_BUF
;
2058 case _PC_CHOWN_RESTRICTED
:
2071 * Advisory record locking support
2073 * ufs_advlock(struct vnode *a_vp, caddr_t a_id, int a_op, struct flock *a_fl,
2078 ufs_advlock(struct vop_advlock_args
*ap
)
2080 struct inode
*ip
= VTOI(ap
->a_vp
);
2082 return (lf_advlock(ap
, &(ip
->i_lockf
), ip
->i_size
));
2086 * Initialize the vnode associated with a new inode, handle aliased
2089 * Make sure directories have their VM object now rather then later,
2090 * saving us from having to check on all the myrid directory VOPs
2091 * that might be executed without a VOP_OPEN being performed.
2094 ufs_vinit(struct mount
*mntp
, struct vnode
**vpp
)
2103 vp
->v_type
= IFTOVT(ip
->i_mode
);
2105 switch(vp
->v_type
) {
2108 vp
->v_ops
= &mntp
->mnt_vn_spec_ops
;
2109 addaliasu(vp
, umajor(ip
->i_rdev
), uminor(ip
->i_rdev
));
2112 vp
->v_ops
= &mntp
->mnt_vn_fifo_ops
;
2116 vinitvmio(vp
, ip
->i_size
);
2119 if (ip
->i_size
>= vp
->v_mount
->mnt_maxsymlinklen
)
2120 vinitvmio(vp
, ip
->i_size
);
2127 if (ip
->i_number
== ROOTINO
)
2128 vp
->v_flag
|= VROOT
;
2130 * Initialize modrev times
2132 getmicrouptime(&tv
);
2133 SETHIGH(ip
->i_modrev
, tv
.tv_sec
);
2134 SETLOW(ip
->i_modrev
, tv
.tv_usec
* 4294);
2140 * Allocate a new inode.
2144 ufs_makeinode(int mode
, struct vnode
*dvp
, struct vnode
**vpp
,
2145 struct componentname
*cnp
)
2147 struct inode
*ip
, *pdir
;
2148 struct direct newdir
;
2154 if ((mode
& IFMT
) == 0)
2157 error
= ffs_valloc(dvp
, mode
, cnp
->cn_cred
, &tvp
);
2161 ip
->i_flags
= pdir
->i_flags
& (SF_NOHISTORY
|UF_NOHISTORY
|UF_NODUMP
);
2162 ip
->i_gid
= pdir
->i_gid
;
2166 struct ucred ucred
, *ucp
;
2170 * If we are not the owner of the directory,
2171 * and we are hacking owners here, (only do this where told to)
2172 * and we are not giving it TO root, (would subvert quotas)
2173 * then go ahead and give it to the other user.
2174 * Note that this drops off the execute bits for security.
2176 if ((dvp
->v_mount
->mnt_flag
& MNT_SUIDDIR
) &&
2177 (pdir
->i_mode
& ISUID
) &&
2178 (pdir
->i_uid
!= cnp
->cn_cred
->cr_uid
) && pdir
->i_uid
) {
2179 ip
->i_uid
= pdir
->i_uid
;
2183 * Make sure the correct user gets charged
2185 * Quickly knock up a dummy credential for the victim.
2186 * XXX This seems to never be accessed out of our
2187 * context so a stack variable is ok.
2190 ucred
.cr_uid
= ip
->i_uid
;
2191 ucred
.cr_ngroups
= 1;
2192 ucred
.cr_groups
[0] = pdir
->i_gid
;
2196 ip
->i_uid
= cnp
->cn_cred
->cr_uid
;
2199 if ((error
= ufs_getinoquota(ip
)) ||
2200 (error
= ufs_chkiq(ip
, 1, ucp
, 0))) {
2201 ffs_vfree(tvp
, ip
->i_number
, mode
);
2207 #else /* !SUIDDIR */
2208 ip
->i_uid
= cnp
->cn_cred
->cr_uid
;
2210 if ((error
= ufs_getinoquota(ip
)) ||
2211 (error
= ufs_chkiq(ip
, 1, cnp
->cn_cred
, 0))) {
2212 ffs_vfree(tvp
, ip
->i_number
, mode
);
2217 #endif /* !SUIDDIR */
2218 ip
->i_fsmid
= cache_getnewfsmid();
2219 ip
->i_flag
|= IN_ACCESS
| IN_CHANGE
| IN_UPDATE
;
2221 tvp
->v_type
= IFTOVT(mode
); /* Rest init'd in getnewvnode(). */
2224 if (DOINGSOFTDEP(tvp
))
2225 softdep_change_linkcnt(ip
);
2226 if ((ip
->i_mode
& ISGID
) && !groupmember(ip
->i_gid
, cnp
->cn_cred
) &&
2227 suser_cred(cnp
->cn_cred
, 0)) {
2228 ip
->i_mode
&= ~ISGID
;
2231 if (cnp
->cn_flags
& CNP_ISWHITEOUT
)
2232 ip
->i_flags
|= UF_OPAQUE
;
2235 * Regular files and directories need VM objects. Softlinks do
2236 * not (not immediately anyway).
2238 if (tvp
->v_type
== VREG
|| tvp
->v_type
== VDIR
)
2242 * Make sure inode goes to disk before directory entry.
2244 error
= ffs_update(tvp
, !(DOINGSOFTDEP(tvp
) | DOINGASYNC(tvp
)));
2247 ufs_makedirentry(ip
, cnp
, &newdir
);
2248 error
= ufs_direnter(dvp
, tvp
, &newdir
, cnp
, NULL
);
2256 * Write error occurred trying to update the inode
2257 * or the directory so must deallocate the inode.
2261 ip
->i_flag
|= IN_CHANGE
;
2262 if (DOINGSOFTDEP(tvp
))
2263 softdep_change_linkcnt(ip
);
2269 ufs_missingop(struct vop_generic_args
*ap
)
2271 panic("no vop function for %s in ufs child", ap
->a_desc
->sd_name
);
2272 return (EOPNOTSUPP
);
2275 static struct filterops ufsread_filtops
=
2276 { 1, NULL
, filt_ufsdetach
, filt_ufsread
};
2277 static struct filterops ufswrite_filtops
=
2278 { 1, NULL
, filt_ufsdetach
, filt_ufswrite
};
2279 static struct filterops ufsvnode_filtops
=
2280 { 1, NULL
, filt_ufsdetach
, filt_ufsvnode
};
2283 * ufs_kqfilter(struct vnode *a_vp, struct knote *a_kn)
2286 ufs_kqfilter(struct vop_kqfilter_args
*ap
)
2288 struct vnode
*vp
= ap
->a_vp
;
2289 struct knote
*kn
= ap
->a_kn
;
2292 switch (kn
->kn_filter
) {
2294 kn
->kn_fop
= &ufsread_filtops
;
2297 kn
->kn_fop
= &ufswrite_filtops
;
2300 kn
->kn_fop
= &ufsvnode_filtops
;
2306 kn
->kn_hook
= (caddr_t
)vp
;
2308 lwkt_gettoken(&ilock
, &vp
->v_pollinfo
.vpi_token
);
2309 SLIST_INSERT_HEAD(&vp
->v_pollinfo
.vpi_selinfo
.si_note
, kn
, kn_selnext
);
2310 lwkt_reltoken(&ilock
);
2316 filt_ufsdetach(struct knote
*kn
)
2318 struct vnode
*vp
= (struct vnode
*)kn
->kn_hook
;
2321 lwkt_gettoken(&ilock
, &vp
->v_pollinfo
.vpi_token
);
2322 SLIST_REMOVE(&vp
->v_pollinfo
.vpi_selinfo
.si_note
,
2323 kn
, knote
, kn_selnext
);
2324 lwkt_reltoken(&ilock
);
2329 filt_ufsread(struct knote
*kn
, long hint
)
2331 struct vnode
*vp
= (struct vnode
*)kn
->kn_hook
;
2332 struct inode
*ip
= VTOI(vp
);
2335 * filesystem is gone, so set the EOF flag and schedule
2336 * the knote for deletion.
2338 if (hint
== NOTE_REVOKE
) {
2339 kn
->kn_flags
|= (EV_EOF
| EV_ONESHOT
);
2343 kn
->kn_data
= ip
->i_size
- kn
->kn_fp
->f_offset
;
2344 return (kn
->kn_data
!= 0);
2349 filt_ufswrite(struct knote
*kn
, long hint
)
2352 * filesystem is gone, so set the EOF flag and schedule
2353 * the knote for deletion.
2355 if (hint
== NOTE_REVOKE
)
2356 kn
->kn_flags
|= (EV_EOF
| EV_ONESHOT
);
2363 filt_ufsvnode(struct knote
*kn
, long hint
)
2365 if (kn
->kn_sfflags
& hint
)
2366 kn
->kn_fflags
|= hint
;
2367 if (hint
== NOTE_REVOKE
) {
2368 kn
->kn_flags
|= EV_EOF
;
2371 return (kn
->kn_fflags
!= 0);
2374 /* Global vfs data structures for ufs. */
2375 static struct vop_ops ufs_vnode_vops
= {
2376 .vop_default
= vop_defaultop
,
2377 .vop_fsync
= (void *)ufs_missingop
,
2378 .vop_read
= (void *)ufs_missingop
,
2379 .vop_reallocblks
= (void *)ufs_missingop
,
2380 .vop_write
= (void *)ufs_missingop
,
2381 .vop_access
= ufs_access
,
2382 .vop_advlock
= ufs_advlock
,
2383 .vop_bmap
= ufs_bmap
,
2384 .vop_old_lookup
= ufs_lookup
,
2385 .vop_close
= ufs_close
,
2386 .vop_old_create
= ufs_create
,
2387 .vop_getattr
= ufs_getattr
,
2388 .vop_inactive
= ufs_inactive
,
2389 .vop_old_link
= ufs_link
,
2390 .vop_old_mkdir
= ufs_mkdir
,
2391 .vop_old_mknod
= ufs_mknod
,
2392 .vop_mmap
= ufs_mmap
,
2393 .vop_open
= ufs_open
,
2394 .vop_pathconf
= ufs_pathconf
,
2395 .vop_poll
= vop_stdpoll
,
2396 .vop_kqfilter
= ufs_kqfilter
,
2397 .vop_print
= ufs_print
,
2398 .vop_readdir
= ufs_readdir
,
2399 .vop_readlink
= ufs_readlink
,
2400 .vop_reclaim
= ufs_reclaim
,
2401 .vop_old_remove
= ufs_remove
,
2402 .vop_old_rename
= ufs_rename
,
2403 .vop_old_rmdir
= ufs_rmdir
,
2404 .vop_setattr
= ufs_setattr
,
2405 .vop_strategy
= ufs_strategy
,
2406 .vop_old_symlink
= ufs_symlink
,
2407 .vop_old_whiteout
= ufs_whiteout
2410 static struct vop_ops ufs_spec_vops
= {
2411 .vop_default
= spec_vnoperate
,
2412 .vop_fsync
= (void *)ufs_missingop
,
2413 .vop_access
= ufs_access
,
2414 .vop_close
= ufsspec_close
,
2415 .vop_getattr
= ufs_getattr
,
2416 .vop_inactive
= ufs_inactive
,
2417 .vop_print
= ufs_print
,
2418 .vop_read
= ufsspec_read
,
2419 .vop_reclaim
= ufs_reclaim
,
2420 .vop_setattr
= ufs_setattr
,
2421 .vop_write
= ufsspec_write
2424 static struct vop_ops ufs_fifo_vops
= {
2425 .vop_default
= fifo_vnoperate
,
2426 .vop_fsync
= (void *)ufs_missingop
,
2427 .vop_access
= ufs_access
,
2428 .vop_close
= ufsfifo_close
,
2429 .vop_getattr
= ufs_getattr
,
2430 .vop_inactive
= ufs_inactive
,
2431 .vop_kqfilter
= ufsfifo_kqfilter
,
2432 .vop_print
= ufs_print
,
2433 .vop_read
= ufsfifo_read
,
2434 .vop_reclaim
= ufs_reclaim
,
2435 .vop_setattr
= ufs_setattr
,
2436 .vop_write
= ufsfifo_write
2439 VNODEOP_SET(ufs_vnode_vops
);
2440 VNODEOP_SET(ufs_spec_vops
);
2441 VNODEOP_SET(ufs_fifo_vops
);
2447 ufs_vnoperate(struct vop_generic_args
*ap
)
2449 return (VOCALL(&ufs_vnode_vops
, ap
));
2453 * ufs_vnoperatefifo()
2456 ufs_vnoperatefifo(struct vop_generic_args
*ap
)
2458 return (VOCALL(&ufs_fifo_vops
, ap
));
2462 * ufs_vnoperatespec()
2465 ufs_vnoperatespec(struct vop_generic_args
*ap
)
2467 return (VOCALL(&ufs_spec_vops
, ap
));