ext2fs_vnops.c revision 1.115.2.4 1 /* $NetBSD: ext2fs_vnops.c,v 1.115.2.4 2017/08/28 17:53:16 skrll Exp $ */
2
3 /*
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.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
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.
23 *
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
34 * SUCH DAMAGE.
35 *
36 * @(#)ufs_vnops.c 8.14 (Berkeley) 10/26/94
37 * Modified for ext2fs by Manuel Bouyer.
38 */
39
40 /*
41 * Copyright (c) 1997 Manuel Bouyer.
42 *
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
45 * are met:
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.
51 *
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.
62 *
63 * @(#)ufs_vnops.c 8.14 (Berkeley) 10/26/94
64 * Modified for ext2fs by Manuel Bouyer.
65 */
66
67 #include <sys/cdefs.h>
68 __KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.115.2.4 2017/08/28 17:53:16 skrll Exp $");
69
70 #include <sys/param.h>
71 #include <sys/systm.h>
72 #include <sys/resourcevar.h>
73 #include <sys/kernel.h>
74 #include <sys/file.h>
75 #include <sys/stat.h>
76 #include <sys/buf.h>
77 #include <sys/proc.h>
78 #include <sys/mount.h>
79 #include <sys/namei.h>
80 #include <sys/vnode.h>
81 #include <sys/lockf.h>
82 #include <sys/pool.h>
83 #include <sys/signalvar.h>
84 #include <sys/kauth.h>
85
86 #include <miscfs/fifofs/fifo.h>
87 #include <miscfs/genfs/genfs.h>
88 #include <miscfs/specfs/specdev.h>
89
90 #include <ufs/ufs/inode.h>
91 #include <ufs/ufs/ufs_extern.h>
92 #include <ufs/ufs/ufsmount.h>
93
94 #include <ufs/ext2fs/ext2fs.h>
95 #include <ufs/ext2fs/ext2fs_extern.h>
96 #include <ufs/ext2fs/ext2fs_dir.h>
97 #include <ufs/ext2fs/ext2fs_xattr.h>
98
99 extern int prtactive;
100
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,
103 struct lwp *);
104 static int ext2fs_makeinode(struct vattr *, struct vnode *, struct vnode **,
105 struct componentname *, int);
106
107 union _qcvt {
108 int64_t qcvt;
109 int32_t val[2];
110 };
111
112 #define SETHIGH(q, h) { \
113 union _qcvt tmp; \
114 tmp.qcvt = (q); \
115 tmp.val[_QUAD_HIGHWORD] = (h); \
116 (q) = tmp.qcvt; \
117 }
118 #define SETLOW(q, l) { \
119 union _qcvt tmp; \
120 tmp.qcvt = (q); \
121 tmp.val[_QUAD_LOWWORD] = (l); \
122 (q) = tmp.qcvt; \
123 }
124
125 /*
126 * Create a regular file
127 */
128 int
129 ext2fs_create(void *v)
130 {
131 struct vop_create_v3_args /* {
132 struct vnode *a_dvp;
133 struct vnode **a_vpp;
134 struct componentname *a_cnp;
135 struct vattr *a_vap;
136 } */ *ap = v;
137 int error;
138
139 error = ext2fs_makeinode(ap->a_vap, ap->a_dvp, ap->a_vpp, ap->a_cnp, 1);
140
141 if (error)
142 return error;
143 VN_KNOTE(ap->a_dvp, NOTE_WRITE);
144 VOP_UNLOCK(*ap->a_vpp);
145 return 0;
146 }
147
148 /*
149 * Mknod vnode call
150 */
151 /* ARGSUSED */
152 int
153 ext2fs_mknod(void *v)
154 {
155 struct vop_mknod_v3_args /* {
156 struct vnode *a_dvp;
157 struct vnode **a_vpp;
158 struct componentname *a_cnp;
159 struct vattr *a_vap;
160 } */ *ap = v;
161 struct vattr *vap = ap->a_vap;
162 struct vnode **vpp = ap->a_vpp;
163 struct inode *ip;
164 int error;
165
166 if ((error = ext2fs_makeinode(vap, ap->a_dvp, vpp, ap->a_cnp, 1)) != 0)
167 return error;
168 VN_KNOTE(ap->a_dvp, NOTE_WRITE);
169 ip = VTOI(*vpp);
170 ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
171 VOP_UNLOCK(*vpp);
172 return 0;
173 }
174
175 /*
176 * Open called.
177 *
178 * Just check the APPEND flag.
179 */
180 /* ARGSUSED */
181 int
182 ext2fs_open(void *v)
183 {
184 struct vop_open_args /* {
185 struct vnode *a_vp;
186 int a_mode;
187 kauth_cred_t a_cred;
188 } */ *ap = v;
189
190 /*
191 * Files marked append-only must be opened for appending.
192 */
193 if ((VTOI(ap->a_vp)->i_e2fs_flags & EXT2_APPEND) &&
194 (ap->a_mode & (FWRITE | O_APPEND)) == FWRITE)
195 return EPERM;
196 return 0;
197 }
198
199 static int
200 ext2fs_check_possible(struct vnode *vp, struct inode *ip, mode_t mode)
201 {
202
203 /*
204 * Disallow write attempts on read-only file systems;
205 * unless the file is a socket, fifo, or a block or
206 * character device resident on the file system.
207 */
208 if (mode & VWRITE) {
209 switch (vp->v_type) {
210 case VDIR:
211 case VLNK:
212 case VREG:
213 if (vp->v_mount->mnt_flag & MNT_RDONLY)
214 return EROFS;
215 break;
216 default:
217 break;
218 }
219 }
220
221 /* If immutable bit set, nobody gets to write it. */
222 if ((mode & VWRITE) && (ip->i_e2fs_flags & EXT2_IMMUTABLE))
223 return EPERM;
224
225 return 0;
226 }
227
228 static int
229 ext2fs_check_permitted(struct vnode *vp, struct inode *ip, mode_t mode,
230 kauth_cred_t cred)
231 {
232
233 return kauth_authorize_vnode(cred, KAUTH_ACCESS_ACTION(mode, vp->v_type,
234 ip->i_e2fs_mode & ALLPERMS), vp, NULL, genfs_can_access(vp->v_type,
235 ip->i_e2fs_mode & ALLPERMS, ip->i_uid, ip->i_gid, mode, cred));
236 }
237
238 int
239 ext2fs_access(void *v)
240 {
241 struct vop_access_args /* {
242 struct vnode *a_vp;
243 int a_mode;
244 kauth_cred_t a_cred;
245 } */ *ap = v;
246 struct vnode *vp = ap->a_vp;
247 struct inode *ip = VTOI(vp);
248 mode_t mode = ap->a_mode;
249 int error;
250
251 error = ext2fs_check_possible(vp, ip, mode);
252 if (error)
253 return error;
254
255 error = ext2fs_check_permitted(vp, ip, mode, ap->a_cred);
256
257 return error;
258 }
259
260 /* ARGSUSED */
261 int
262 ext2fs_getattr(void *v)
263 {
264 struct vop_getattr_args /* {
265 struct vnode *a_vp;
266 struct vattr *a_vap;
267 kauth_cred_t a_cred;
268 } */ *ap = v;
269 struct vnode *vp = ap->a_vp;
270 struct inode *ip = VTOI(vp);
271 struct vattr *vap = ap->a_vap;
272
273 EXT2FS_ITIMES(ip, NULL, NULL, NULL);
274 /*
275 * Copy from inode table
276 */
277 vap->va_fsid = ip->i_dev;
278 vap->va_fileid = ip->i_number;
279 vap->va_mode = ip->i_e2fs_mode & ALLPERMS;
280 vap->va_nlink = ip->i_e2fs_nlink;
281 vap->va_uid = ip->i_uid;
282 vap->va_gid = ip->i_gid;
283 vap->va_rdev = (dev_t)fs2h32(ip->i_din.e2fs_din->e2di_rdev);
284 vap->va_size = vp->v_size;
285 EXT2_DINODE_TIME_GET(&vap->va_atime, ip->i_din.e2fs_din, e2di_atime, EXT2_DINODE_SIZE(ip->i_e2fs));
286 EXT2_DINODE_TIME_GET(&vap->va_mtime, ip->i_din.e2fs_din, e2di_mtime, EXT2_DINODE_SIZE(ip->i_e2fs));
287 EXT2_DINODE_TIME_GET(&vap->va_ctime, ip->i_din.e2fs_din, e2di_ctime, EXT2_DINODE_SIZE(ip->i_e2fs));
288 if (EXT2_DINODE_FITS(ip->i_din.e2fs_din, e2di_crtime, EXT2_DINODE_SIZE(ip->i_e2fs))) {
289 EXT2_DINODE_TIME_GET(&vap->va_birthtime, ip->i_din.e2fs_din, e2di_crtime, EXT2_DINODE_SIZE(ip->i_e2fs));
290 }
291
292 vap->va_flags = 0;
293 vap->va_flags |= (ip->i_e2fs_flags & EXT2_NODUMP) ? UF_NODUMP : 0;
294 #ifdef EXT2FS_SYSTEM_FLAGS
295 vap->va_flags |= (ip->i_e2fs_flags & EXT2_IMMUTABLE) ? SF_IMMUTABLE : 0;
296 vap->va_flags |= (ip->i_e2fs_flags & EXT2_APPEND) ? SF_APPEND : 0;
297 #else
298 vap->va_flags |= (ip->i_e2fs_flags & EXT2_IMMUTABLE) ? UF_IMMUTABLE : 0;
299 vap->va_flags |= (ip->i_e2fs_flags & EXT2_APPEND) ? UF_APPEND : 0;
300 #endif
301
302 vap->va_gen = ip->i_e2fs_gen;
303 /* this doesn't belong here */
304 if (vp->v_type == VBLK)
305 vap->va_blocksize = BLKDEV_IOSIZE;
306 else if (vp->v_type == VCHR)
307 vap->va_blocksize = MAXBSIZE;
308 else
309 vap->va_blocksize = vp->v_mount->mnt_stat.f_iosize;
310 vap->va_bytes = dbtob(ext2fs_nblock(ip));
311 vap->va_type = vp->v_type;
312 vap->va_filerev = ip->i_modrev;
313 return 0;
314 }
315
316 /*
317 * Set attribute vnode op. called from several syscalls
318 */
319 int
320 ext2fs_setattr(void *v)
321 {
322 struct vop_setattr_args /* {
323 struct vnode *a_vp;
324 struct vattr *a_vap;
325 kauth_cred_t a_cred;
326 } */ *ap = v;
327 struct vattr *vap = ap->a_vap;
328 struct vnode *vp = ap->a_vp;
329 struct inode *ip = VTOI(vp);
330 kauth_cred_t cred = ap->a_cred;
331 struct lwp *l = curlwp;
332 int error;
333 kauth_action_t action = KAUTH_VNODE_WRITE_FLAGS;
334 bool changing_sysflags = false;
335
336 /*
337 * Check for unsettable attributes.
338 */
339 if ((vap->va_type != VNON) || (vap->va_nlink != (nlink_t)VNOVAL) ||
340 (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) ||
341 (vap->va_blocksize != VNOVAL) || (vap->va_rdev != VNOVAL) ||
342 ((int)vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) {
343 return EINVAL;
344 }
345 if (vap->va_flags != VNOVAL) {
346 if (vp->v_mount->mnt_flag & MNT_RDONLY)
347 return EROFS;
348
349 /*
350 * Check if we're allowed to change the flags.
351 * If EXT2FS_SYSTEM_FLAGS is set, then the flags are treated
352 * as system flags, otherwise they're considered to be user
353 * flags.
354 */
355 #ifdef EXT2FS_SYSTEM_FLAGS
356 /* Indicate we're changing system flags if we are. */
357 if ((vap->va_flags & SF_APPEND) ||
358 (vap->va_flags & SF_IMMUTABLE)) {
359 action |= KAUTH_VNODE_WRITE_SYSFLAGS;
360 changing_sysflags = true;
361 }
362
363 /* Indicate the node has system flags if it does. */
364 if (ip->i_e2fs_flags & (EXT2_APPEND | EXT2_IMMUTABLE)) {
365 action |= KAUTH_VNODE_HAS_SYSFLAGS;
366 }
367 #endif /* EXT2FS_SYSTEM_FLAGS */
368
369 error = kauth_authorize_vnode(cred, action, vp, NULL,
370 genfs_can_chflags(cred, vp->v_type, ip->i_uid,
371 changing_sysflags));
372 if (error)
373 return error;
374
375 ip->i_e2fs_flags &= ~(EXT2_APPEND | EXT2_IMMUTABLE | EXT2_NODUMP);
376 #ifdef EXT2FS_SYSTEM_FLAGS
377 ip->i_e2fs_flags |=
378 (vap->va_flags & SF_APPEND) ? EXT2_APPEND : 0 |
379 (vap->va_flags & SF_IMMUTABLE) ? EXT2_IMMUTABLE : 0;
380 #else
381 ip->i_e2fs_flags |=
382 (vap->va_flags & UF_APPEND) ? EXT2_APPEND : 0 |
383 (vap->va_flags & UF_IMMUTABLE) ? EXT2_IMMUTABLE : 0;
384 #endif
385 ip->i_e2fs_flags |=
386 (vap->va_flags & UF_NODUMP) ? EXT2_NODUMP : 0;
387 ip->i_flag |= IN_CHANGE;
388 if (vap->va_flags & (IMMUTABLE | APPEND))
389 return 0;
390 }
391 if (ip->i_e2fs_flags & (EXT2_APPEND | EXT2_IMMUTABLE))
392 return EPERM;
393 /*
394 * Go through the fields and update iff not VNOVAL.
395 */
396 if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) {
397 if (vp->v_mount->mnt_flag & MNT_RDONLY)
398 return EROFS;
399 error = ext2fs_chown(vp, vap->va_uid, vap->va_gid, cred, l);
400 if (error)
401 return error;
402 }
403 if (vap->va_size != VNOVAL) {
404 /*
405 * Disallow write attempts on read-only file systems;
406 * unless the file is a socket, fifo, or a block or
407 * character device resident on the file system.
408 */
409 switch (vp->v_type) {
410 case VDIR:
411 return EISDIR;
412 case VLNK:
413 case VREG:
414 if (vp->v_mount->mnt_flag & MNT_RDONLY)
415 return EROFS;
416 default:
417 break;
418 }
419 error = ext2fs_truncate(vp, vap->va_size, 0, cred);
420 if (error)
421 return error;
422 }
423 ip = VTOI(vp);
424 if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL || vap->va_birthtime.tv_sec != VNOVAL) {
425 if (vp->v_mount->mnt_flag & MNT_RDONLY)
426 return EROFS;
427 error = kauth_authorize_vnode(cred, KAUTH_VNODE_WRITE_TIMES, vp,
428 NULL, genfs_can_chtimes(vp, vap->va_vaflags, ip->i_uid,
429 cred));
430 if (error)
431 return error;
432 if (vap->va_atime.tv_sec != VNOVAL)
433 if (!(vp->v_mount->mnt_flag & MNT_NOATIME))
434 ip->i_flag |= IN_ACCESS;
435 if (vap->va_mtime.tv_sec != VNOVAL) {
436 ip->i_flag |= IN_CHANGE | IN_UPDATE;
437 if (vp->v_mount->mnt_flag & MNT_RELATIME)
438 ip->i_flag |= IN_ACCESS;
439 }
440 if (vap->va_birthtime.tv_sec != VNOVAL &&
441 EXT2_DINODE_FITS(ip->i_din.e2fs_din, e2di_crtime, EXT2_DINODE_SIZE(ip->i_e2fs))) {
442
443 EXT2_DINODE_TIME_SET(&vap->va_birthtime, ip->i_din.e2fs_din, e2di_crtime, EXT2_DINODE_SIZE(ip->i_e2fs));
444 }
445 error = ext2fs_update(vp, &vap->va_atime, &vap->va_mtime,
446 UPDATE_WAIT);
447 if (error)
448 return error;
449 }
450 error = 0;
451 if (vap->va_mode != (mode_t)VNOVAL) {
452 if (vp->v_mount->mnt_flag & MNT_RDONLY)
453 return EROFS;
454 error = ext2fs_chmod(vp, (int)vap->va_mode, cred, l);
455 }
456 VN_KNOTE(vp, NOTE_ATTRIB);
457 return error;
458 }
459
460 /*
461 * Change the mode on a file.
462 * Inode must be locked before calling.
463 */
464 static int
465 ext2fs_chmod(struct vnode *vp, int mode, kauth_cred_t cred, struct lwp *l)
466 {
467 struct inode *ip = VTOI(vp);
468 int error;
469
470 error = kauth_authorize_vnode(cred, KAUTH_VNODE_WRITE_SECURITY, vp,
471 NULL, genfs_can_chmod(vp->v_type, cred, ip->i_uid, ip->i_gid,
472 mode));
473 if (error)
474 return error;
475
476 ip->i_e2fs_mode &= ~ALLPERMS;
477 ip->i_e2fs_mode |= (mode & ALLPERMS);
478 ip->i_flag |= IN_CHANGE;
479 return 0;
480 }
481
482 /*
483 * Perform chown operation on inode ip;
484 * inode must be locked prior to call.
485 */
486 static int
487 ext2fs_chown(struct vnode *vp, uid_t uid, gid_t gid, kauth_cred_t cred,
488 struct lwp *l)
489 {
490 struct inode *ip = VTOI(vp);
491 uid_t ouid;
492 gid_t ogid;
493 int error;
494
495 if (uid == (uid_t)VNOVAL)
496 uid = ip->i_uid;
497 if (gid == (gid_t)VNOVAL)
498 gid = ip->i_gid;
499
500 error = kauth_authorize_vnode(cred, KAUTH_VNODE_CHANGE_OWNERSHIP, vp,
501 NULL, genfs_can_chown(cred, ip->i_uid, ip->i_gid, uid, gid));
502 if (error)
503 return error;
504
505 ogid = ip->i_gid;
506 ouid = ip->i_uid;
507
508 ip->i_e2fs_gid = gid & 0xffff;
509 ip->i_e2fs_uid = uid & 0xffff;
510 if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0) {
511 ip->i_e2fs_gid_high = (gid >> 16) & 0xffff;
512 ip->i_e2fs_uid_high = (uid >> 16) & 0xffff;
513 } else {
514 ip->i_e2fs_gid_high = 0;
515 ip->i_e2fs_uid_high = 0;
516 }
517 if (ouid != uid || ogid != gid) {
518 ext2fs_set_inode_guid(ip);
519 ip->i_flag |= IN_CHANGE;
520 }
521 if (ouid != uid && (ip->i_e2fs_mode & ISUID) &&
522 kauth_authorize_vnode(cred, KAUTH_VNODE_RETAIN_SUID,
523 vp, NULL, EPERM) != 0)
524 ip->i_e2fs_mode &= ~ISUID;
525 if (ogid != gid && (ip->i_e2fs_mode & ISGID) &&
526 kauth_authorize_vnode(cred, KAUTH_VNODE_RETAIN_SGID,
527 vp, NULL, EPERM) != 0)
528 ip->i_e2fs_mode &= ~ISGID;
529 return 0;
530 }
531
532 int
533 ext2fs_remove(void *v)
534 {
535 struct vop_remove_v2_args /* {
536 struct vnode *a_dvp;
537 struct vnode *a_vp;
538 struct componentname *a_cnp;
539 } */ *ap = v;
540 struct inode *ip;
541 struct vnode *vp = ap->a_vp;
542 struct vnode *dvp = ap->a_dvp;
543 struct ufs_lookup_results *ulr;
544 int error;
545
546 /* XXX should handle this material another way */
547 ulr = &VTOI(dvp)->i_crap;
548 UFS_CHECK_CRAPCOUNTER(VTOI(dvp));
549
550 ip = VTOI(vp);
551 if (vp->v_type == VDIR ||
552 (ip->i_e2fs_flags & (EXT2_IMMUTABLE | EXT2_APPEND)) ||
553 (VTOI(dvp)->i_e2fs_flags & EXT2_APPEND)) {
554 error = EPERM;
555 } else {
556 error = ext2fs_dirremove(dvp, ulr, ap->a_cnp);
557 if (error == 0) {
558 ip->i_e2fs_nlink--;
559 ip->i_flag |= IN_CHANGE;
560 }
561 }
562
563 VN_KNOTE(vp, NOTE_DELETE);
564 VN_KNOTE(dvp, NOTE_WRITE);
565 if (dvp == vp)
566 vrele(vp);
567 else
568 vput(vp);
569 return error;
570 }
571
572 /*
573 * ext2fs_link: create hard link.
574 */
575 int
576 ext2fs_link(void *v)
577 {
578 struct vop_link_v2_args /* {
579 struct vnode *a_dvp;
580 struct vnode *a_vp;
581 struct componentname *a_cnp;
582 } */ *ap = v;
583 struct vnode *dvp = ap->a_dvp;
584 struct vnode *vp = ap->a_vp;
585 struct componentname *cnp = ap->a_cnp;
586 struct inode *ip;
587 int error;
588 struct ufs_lookup_results *ulr;
589
590 KASSERT(dvp != vp);
591 KASSERT(vp->v_type != VDIR);
592 KASSERT(dvp->v_mount == vp->v_mount);
593
594 /* XXX should handle this material another way */
595 ulr = &VTOI(dvp)->i_crap;
596 UFS_CHECK_CRAPCOUNTER(VTOI(dvp));
597
598 error = vn_lock(vp, LK_EXCLUSIVE);
599 if (error) {
600 VOP_ABORTOP(dvp, cnp);
601 goto out2;
602 }
603 ip = VTOI(vp);
604 if ((nlink_t)ip->i_e2fs_nlink >= EXT2FS_LINK_MAX) {
605 VOP_ABORTOP(dvp, cnp);
606 error = EMLINK;
607 goto out1;
608 }
609 if (ip->i_e2fs_flags & (EXT2_IMMUTABLE | EXT2_APPEND)) {
610 VOP_ABORTOP(dvp, cnp);
611 error = EPERM;
612 goto out1;
613 }
614 ip->i_e2fs_nlink++;
615 ip->i_flag |= IN_CHANGE;
616 error = ext2fs_update(vp, NULL, NULL, UPDATE_WAIT);
617 if (!error)
618 error = ext2fs_direnter(ip, dvp, ulr, cnp);
619 if (error) {
620 ip->i_e2fs_nlink--;
621 ip->i_flag |= IN_CHANGE;
622 }
623 out1:
624 VOP_UNLOCK(vp);
625 out2:
626 VN_KNOTE(vp, NOTE_LINK);
627 VN_KNOTE(dvp, NOTE_WRITE);
628 return error;
629 }
630
631 /*
632 * Mkdir system call
633 */
634 int
635 ext2fs_mkdir(void *v)
636 {
637 struct vop_mkdir_v3_args /* {
638 struct vnode *a_dvp;
639 struct vnode **a_vpp;
640 struct componentname *a_cnp;
641 struct vattr *a_vap;
642 } */ *ap = v;
643 struct vnode *dvp = ap->a_dvp;
644 struct componentname *cnp = ap->a_cnp;
645 struct inode *ip, *dp = VTOI(dvp);
646 struct vnode *tvp;
647 struct ext2fs_dirtemplate dirtemplate;
648 int error;
649 struct ufs_lookup_results *ulr;
650
651 /* XXX should handle this material another way */
652 ulr = &VTOI(dvp)->i_crap;
653 UFS_CHECK_CRAPCOUNTER(VTOI(dvp));
654
655 KASSERT(ap->a_vap->va_type == VDIR);
656
657 /*
658 * Acquire the inode, but don't sync/direnter it just yet
659 */
660 error = ext2fs_makeinode(ap->a_vap, ap->a_dvp, &tvp, ap->a_cnp, 0);
661 if (error)
662 goto out;
663
664 /* the link count is going to be 2 when all is done */
665 ip = VTOI(tvp);
666 ip->i_e2fs_nlink = 2;
667
668 /*
669 * Bump link count in parent directory
670 * to reflect work done below. Should
671 * be done before reference is created
672 * so reparation is possible if we crash.
673 */
674 if (dp->i_e2fs_nlink != EXT2FS_LINK_INF)
675 dp->i_e2fs_nlink++;
676
677 /*
678 * If we hit the link limit, for directories just set the nlink
679 * to special value 1, which means the link count is bigger
680 * than EXT2FS_LINK_MAX.
681 */
682 if ((nlink_t)dp->i_e2fs_nlink >= EXT2FS_LINK_MAX) {
683 dp->i_e2fs_nlink = EXT2FS_LINK_INF;
684
685 /* set the feature flag DIR_NLINK if not set already */
686 if (!EXT2F_HAS_ROCOMPAT_FEATURE(dp->i_e2fs, EXT2F_ROCOMPAT_DIR_NLINK)) {
687 dp->i_e2fs->e2fs.e2fs_features_rocompat |= EXT2F_ROCOMPAT_DIR_NLINK;
688 dp->i_e2fs->e2fs_fmod = 1;
689 }
690 }
691
692 dp->i_flag |= IN_CHANGE;
693 if ((error = ext2fs_update(dvp, NULL, NULL, UPDATE_DIROP)) != 0)
694 goto bad;
695
696 /* Initialize directory with "." and ".." from static template. */
697 memset(&dirtemplate, 0, sizeof(dirtemplate));
698 dirtemplate.dot_ino = h2fs32(ip->i_number);
699 dirtemplate.dot_reclen = h2fs16(12);
700 dirtemplate.dot_namlen = 1;
701 if (EXT2F_HAS_INCOMPAT_FEATURE(dp->i_e2fs, EXT2F_INCOMPAT_FTYPE)) {
702 dirtemplate.dot_type = EXT2_FT_DIR;
703 }
704 dirtemplate.dot_name[0] = '.';
705 dirtemplate.dotdot_ino = h2fs32(dp->i_number);
706 dirtemplate.dotdot_reclen = h2fs16(VTOI(dvp)->i_e2fs->e2fs_bsize - 12);
707 dirtemplate.dotdot_namlen = 2;
708 if (EXT2F_HAS_INCOMPAT_FEATURE(dp->i_e2fs, EXT2F_INCOMPAT_FTYPE)) {
709 dirtemplate.dotdot_type = EXT2_FT_DIR;
710 }
711 dirtemplate.dotdot_name[0] = dirtemplate.dotdot_name[1] = '.';
712 error = ufs_bufio(UIO_WRITE, tvp, (void *)&dirtemplate,
713 sizeof (dirtemplate), (off_t)0, IO_NODELOCKED|IO_SYNC,
714 cnp->cn_cred, (size_t *)0, NULL);
715 if (error) {
716 if (dp->i_e2fs_nlink != EXT2FS_LINK_INF)
717 dp->i_e2fs_nlink--;
718 dp->i_flag |= IN_CHANGE;
719 goto bad;
720 }
721 if (VTOI(dvp)->i_e2fs->e2fs_bsize > dvp->v_mount->mnt_stat.f_bsize)
722 panic("ext2fs_mkdir: blksize"); /* XXX should grow with balloc() */
723 else {
724 error = ext2fs_setsize(ip, VTOI(dvp)->i_e2fs->e2fs_bsize);
725 if (error) {
726 if (dp->i_e2fs_nlink != EXT2FS_LINK_INF)
727 dp->i_e2fs_nlink--;
728 dp->i_flag |= IN_CHANGE;
729 goto bad;
730 }
731 ip->i_flag |= IN_CHANGE;
732 uvm_vnp_setsize(tvp, ext2fs_size(ip));
733 }
734
735 /* Directory set up, now install its entry in the parent directory. */
736 error = ext2fs_direnter(ip, dvp, ulr, cnp);
737 if (error != 0) {
738 if (dp->i_e2fs_nlink != EXT2FS_LINK_INF)
739 dp->i_e2fs_nlink--;
740 dp->i_flag |= IN_CHANGE;
741 }
742 bad:
743 /*
744 * No need to do an explicit ext2fs_truncate here, vrele will do this
745 * for us because we set the link count to 0.
746 */
747 if (error) {
748 ip->i_e2fs_nlink = 0;
749 ip->i_flag |= IN_CHANGE;
750 vput(tvp);
751 } else {
752 VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
753 VOP_UNLOCK(tvp);
754 *ap->a_vpp = tvp;
755 }
756 out:
757 return error;
758 }
759
760 /*
761 * Rmdir system call.
762 */
763 int
764 ext2fs_rmdir(void *v)
765 {
766 struct vop_rmdir_v2_args /* {
767 struct vnode *a_dvp;
768 struct vnode *a_vp;
769 struct componentname *a_cnp;
770 } */ *ap = v;
771 struct vnode *vp = ap->a_vp;
772 struct vnode *dvp = ap->a_dvp;
773 struct componentname *cnp = ap->a_cnp;
774 struct inode *ip, *dp;
775 int error;
776 struct ufs_lookup_results *ulr;
777
778 ip = VTOI(vp);
779 dp = VTOI(dvp);
780
781 /* XXX should handle this material another way */
782 ulr = &dp->i_crap;
783 UFS_CHECK_CRAPCOUNTER(dp);
784
785 /*
786 * No rmdir "." please.
787 */
788 if (dp == ip) {
789 vrele(vp);
790 return EINVAL;
791 }
792 /*
793 * Verify the directory is empty (and valid).
794 * (Rmdir ".." won't be valid since
795 * ".." will contain a reference to
796 * the current directory and thus be
797 * non-empty.)
798 */
799 error = 0;
800 if ((ip->i_e2fs_nlink != 2 && ip->i_e2fs_nlink != EXT2FS_LINK_INF) ||
801 !ext2fs_dirempty(ip, dp->i_number, cnp->cn_cred)) {
802 error = ENOTEMPTY;
803 goto out;
804 }
805 if ((dp->i_e2fs_flags & EXT2_APPEND) ||
806 (ip->i_e2fs_flags & (EXT2_IMMUTABLE | EXT2_APPEND))) {
807 error = EPERM;
808 goto out;
809 }
810 /*
811 * Delete reference to directory before purging
812 * inode. If we crash in between, the directory
813 * will be reattached to lost+found,
814 */
815 error = ext2fs_dirremove(dvp, ulr, cnp);
816 if (error != 0)
817 goto out;
818 if (dp->i_e2fs_nlink != EXT2FS_LINK_INF)
819 dp->i_e2fs_nlink--;
820 dp->i_flag |= IN_CHANGE;
821 VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
822 cache_purge(dvp);
823 /*
824 * Truncate inode. The only stuff left
825 * in the directory is "." and "..". The
826 * "." reference is inconsequential since
827 * we're quashing it. The ".." reference
828 * has already been adjusted above. We've
829 * removed the "." reference and the reference
830 * in the parent directory, but there may be
831 * other hard links so decrement by 2 and
832 * worry about them later.
833 */
834 ip->i_e2fs_nlink -= 2;
835 error = ext2fs_truncate(vp, (off_t)0, IO_SYNC, cnp->cn_cred);
836 cache_purge(ITOV(ip));
837 out:
838 VN_KNOTE(vp, NOTE_DELETE);
839 vput(vp);
840 return error;
841 }
842
843 /*
844 * symlink -- make a symbolic link
845 */
846 int
847 ext2fs_symlink(void *v)
848 {
849 struct vop_symlink_v3_args /* {
850 struct vnode *a_dvp;
851 struct vnode **a_vpp;
852 struct componentname *a_cnp;
853 struct vattr *a_vap;
854 char *a_target;
855 } */ *ap = v;
856 struct vnode *vp, **vpp;
857 struct inode *ip;
858 int len, error;
859
860 vpp = ap->a_vpp;
861 KASSERT(ap->a_vap->va_type == VLNK);
862 error = ext2fs_makeinode(ap->a_vap, ap->a_dvp, vpp, ap->a_cnp, 1);
863 if (error)
864 return error;
865 VN_KNOTE(ap->a_dvp, NOTE_WRITE);
866 vp = *vpp;
867 len = strlen(ap->a_target);
868 ip = VTOI(vp);
869 if (len < ip->i_ump->um_maxsymlinklen) {
870 memcpy(ip->i_din.e2fs_din->e2di_shortlink, ap->a_target, len);
871 error = ext2fs_setsize(ip, len);
872 if (error)
873 goto bad;
874 ip->i_flag |= IN_CHANGE | IN_UPDATE;
875 if (vp->v_mount->mnt_flag & MNT_RELATIME)
876 ip->i_flag |= IN_ACCESS;
877 uvm_vnp_setsize(vp, len);
878 } else
879 error = ufs_bufio(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
880 IO_NODELOCKED, ap->a_cnp->cn_cred, (size_t *)0, NULL);
881 bad:
882 VOP_UNLOCK(vp);
883 if (error)
884 vrele(vp);
885 return error;
886 }
887
888 /*
889 * Return target name of a symbolic link
890 */
891 int
892 ext2fs_readlink(void *v)
893 {
894 struct vop_readlink_args /* {
895 struct vnode *a_vp;
896 struct uio *a_uio;
897 kauth_cred_t a_cred;
898 } */ *ap = v;
899 struct vnode *vp = ap->a_vp;
900 struct inode *ip = VTOI(vp);
901 struct ufsmount *ump = ip->i_ump;
902 int isize;
903
904 isize = ext2fs_size(ip);
905 if (isize < ump->um_maxsymlinklen ||
906 (ump->um_maxsymlinklen == 0 && ext2fs_nblock(ip) == 0)) {
907 uiomove(ip->i_din.e2fs_din->e2di_shortlink, isize, ap->a_uio);
908 return 0;
909 }
910 return UFS_BUFRD(vp, ap->a_uio, 0, ap->a_cred);
911 }
912
913 /*
914 * Advisory record locking support
915 */
916 int
917 ext2fs_advlock(void *v)
918 {
919 struct vop_advlock_args /* {
920 struct vnode *a_vp;
921 void * a_id;
922 int a_op;
923 struct flock *a_fl;
924 int a_flags;
925 } */ *ap = v;
926 struct inode *ip = VTOI(ap->a_vp);
927
928 return lf_advlock(ap, &ip->i_lockf, ext2fs_size(ip));
929 }
930
931 int
932 ext2fs_fsync(void *v)
933 {
934 struct vop_fsync_args /* {
935 struct vnode *a_vp;
936 kauth_cred_t a_cred;
937 int a_flags;
938 off_t offlo;
939 off_t offhi;
940 struct proc *a_p;
941 } */ *ap = v;
942 struct vnode *vp = ap->a_vp;
943 int wait;
944 int error;
945
946 wait = (ap->a_flags & FSYNC_WAIT) != 0;
947
948 if (vp->v_type == VBLK)
949 error = spec_fsync(v);
950 else
951 error = vflushbuf(vp, ap->a_flags);
952 if (error == 0 && (ap->a_flags & FSYNC_DATAONLY) == 0)
953 error = ext2fs_update(vp, NULL, NULL, wait ? UPDATE_WAIT : 0);
954
955 if (error == 0 && ap->a_flags & FSYNC_CACHE) {
956 int l = 0;
957 error = VOP_IOCTL(VTOI(vp)->i_devvp, DIOCCACHESYNC, &l, FWRITE,
958 curlwp->l_cred);
959 }
960
961 return error;
962 }
963
964 /*
965 * Initialize the vnode associated with a new inode, handle aliased
966 * vnodes.
967 */
968 int
969 ext2fs_vinit(struct mount *mntp, int (**specops)(void *),
970 int (**fifoops)(void *), struct vnode **vpp)
971 {
972 struct timeval tv;
973 struct inode *ip;
974 struct vnode *vp;
975
976 vp = *vpp;
977 ip = VTOI(vp);
978 switch(vp->v_type = IFTOVT(ip->i_e2fs_mode)) {
979 case VCHR:
980 case VBLK:
981 vp->v_op = specops;
982 spec_node_init(vp, fs2h32(ip->i_din.e2fs_din->e2di_rdev));
983 break;
984 case VFIFO:
985 vp->v_op = fifoops;
986 break;
987 case VNON:
988 case VBAD:
989 case VSOCK:
990 case VLNK:
991 case VDIR:
992 case VREG:
993 break;
994 }
995 if (ip->i_number == UFS_ROOTINO)
996 vp->v_vflag |= VV_ROOT;
997 /*
998 * Initialize modrev times
999 */
1000 getmicrouptime(&tv);
1001 SETHIGH(ip->i_modrev, tv.tv_sec);
1002 SETLOW(ip->i_modrev, tv.tv_usec * 4294);
1003 *vpp = vp;
1004 return 0;
1005 }
1006
1007 /*
1008 * Allocate a new inode.
1009 */
1010 static int
1011 ext2fs_makeinode(struct vattr *vap, struct vnode *dvp, struct vnode **vpp,
1012 struct componentname *cnp, int do_direnter)
1013 {
1014 struct inode *ip, *pdir;
1015 struct vnode *tvp;
1016 int error;
1017 struct ufs_lookup_results *ulr;
1018
1019 pdir = VTOI(dvp);
1020
1021 /* XXX should handle this material another way */
1022 ulr = &pdir->i_crap;
1023 UFS_CHECK_CRAPCOUNTER(pdir);
1024
1025 *vpp = NULL;
1026
1027 error = vcache_new(dvp->v_mount, dvp, vap, cnp->cn_cred, &tvp);
1028 if (error)
1029 return error;
1030 error = vn_lock(tvp, LK_EXCLUSIVE);
1031 if (error) {
1032 vrele(tvp);
1033 return error;
1034 }
1035 ip = VTOI(tvp);
1036 if (do_direnter) {
1037 /*
1038 * Make sure inode goes to disk before directory entry.
1039 */
1040 if ((error = ext2fs_update(tvp, NULL, NULL, UPDATE_WAIT)) != 0)
1041 goto bad;
1042 error = ext2fs_direnter(ip, dvp, ulr, cnp);
1043 if (error != 0)
1044 goto bad;
1045 }
1046
1047 *vpp = tvp;
1048 return 0;
1049
1050 bad:
1051 /*
1052 * Write error occurred trying to update the inode
1053 * or the directory so must deallocate the inode.
1054 */
1055 ip->i_e2fs_nlink = 0;
1056 ip->i_flag |= IN_CHANGE;
1057 vput(tvp);
1058 return error;
1059 }
1060
1061 /*
1062 * Reclaim an inode so that it can be used for other purposes.
1063 */
1064 int
1065 ext2fs_reclaim(void *v)
1066 {
1067 struct vop_reclaim_v2_args /* {
1068 struct vnode *a_vp;
1069 } */ *ap = v;
1070 struct vnode *vp = ap->a_vp;
1071 struct inode *ip = VTOI(vp);
1072 int error;
1073
1074 VOP_UNLOCK(vp);
1075
1076 /*
1077 * The inode must be freed and updated before being removed
1078 * from its hash chain. Other threads trying to gain a hold
1079 * or lock on the inode will be stalled.
1080 */
1081 if (ip->i_omode == 1 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
1082 ext2fs_vfree(vp, ip->i_number, ip->i_e2fs_mode);
1083 if ((error = ufs_reclaim(vp)) != 0)
1084 return error;
1085 if (ip->i_din.e2fs_din != NULL)
1086 kmem_free(ip->i_din.e2fs_din, EXT2_DINODE_SIZE(ip->i_e2fs));
1087 genfs_node_destroy(vp);
1088 pool_put(&ext2fs_inode_pool, vp->v_data);
1089 vp->v_data = NULL;
1090 return 0;
1091 }
1092
1093 /* Global vfs data structures for ext2fs. */
1094 int (**ext2fs_vnodeop_p)(void *);
1095 const struct vnodeopv_entry_desc ext2fs_vnodeop_entries[] = {
1096 { &vop_default_desc, vn_default_error },
1097 { &vop_lookup_desc, ext2fs_lookup }, /* lookup */
1098 { &vop_create_desc, ext2fs_create }, /* create */
1099 { &vop_mknod_desc, ext2fs_mknod }, /* mknod */
1100 { &vop_open_desc, ext2fs_open }, /* open */
1101 { &vop_close_desc, ufs_close }, /* close */
1102 { &vop_access_desc, ext2fs_access }, /* access */
1103 { &vop_getattr_desc, ext2fs_getattr }, /* getattr */
1104 { &vop_setattr_desc, ext2fs_setattr }, /* setattr */
1105 { &vop_read_desc, ext2fs_read }, /* read */
1106 { &vop_write_desc, ext2fs_write }, /* write */
1107 { &vop_fallocate_desc, genfs_eopnotsupp }, /* fallocate */
1108 { &vop_fdiscard_desc, genfs_eopnotsupp }, /* fdiscard */
1109 { &vop_ioctl_desc, ufs_ioctl }, /* ioctl */
1110 { &vop_fcntl_desc, ufs_fcntl }, /* fcntl */
1111 { &vop_poll_desc, ufs_poll }, /* poll */
1112 { &vop_kqfilter_desc, genfs_kqfilter }, /* kqfilter */
1113 { &vop_revoke_desc, ufs_revoke }, /* revoke */
1114 { &vop_mmap_desc, ufs_mmap }, /* mmap */
1115 { &vop_fsync_desc, ext2fs_fsync }, /* fsync */
1116 { &vop_seek_desc, ufs_seek }, /* seek */
1117 { &vop_remove_desc, ext2fs_remove }, /* remove */
1118 { &vop_link_desc, ext2fs_link }, /* link */
1119 { &vop_rename_desc, ext2fs_rename }, /* rename */
1120 { &vop_mkdir_desc, ext2fs_mkdir }, /* mkdir */
1121 { &vop_rmdir_desc, ext2fs_rmdir }, /* rmdir */
1122 { &vop_symlink_desc, ext2fs_symlink }, /* symlink */
1123 { &vop_readdir_desc, ext2fs_readdir }, /* readdir */
1124 { &vop_readlink_desc, ext2fs_readlink }, /* readlink */
1125 { &vop_abortop_desc, ufs_abortop }, /* abortop */
1126 { &vop_inactive_desc, ext2fs_inactive }, /* inactive */
1127 { &vop_reclaim_desc, ext2fs_reclaim }, /* reclaim */
1128 { &vop_lock_desc, ufs_lock }, /* lock */
1129 { &vop_unlock_desc, ufs_unlock }, /* unlock */
1130 { &vop_bmap_desc, ext2fs_bmap }, /* bmap */
1131 { &vop_strategy_desc, ufs_strategy }, /* strategy */
1132 { &vop_print_desc, ufs_print }, /* print */
1133 { &vop_islocked_desc, ufs_islocked }, /* islocked */
1134 { &vop_pathconf_desc, ufs_pathconf }, /* pathconf */
1135 { &vop_advlock_desc, ext2fs_advlock }, /* advlock */
1136 { &vop_bwrite_desc, vn_bwrite }, /* bwrite */
1137 { &vop_getpages_desc, genfs_getpages }, /* getpages */
1138 { &vop_putpages_desc, genfs_putpages }, /* putpages */
1139 { &vop_getextattr_desc, ext2fs_getextattr }, /* getextattr */
1140 { &vop_setextattr_desc, ext2fs_setextattr }, /* setextattr */
1141 { &vop_listextattr_desc, ext2fs_listextattr }, /* listextattr */
1142 { &vop_deleteextattr_desc, ext2fs_deleteextattr },/* deleteextattr */
1143 { NULL, NULL }
1144 };
1145 const struct vnodeopv_desc ext2fs_vnodeop_opv_desc =
1146 { &ext2fs_vnodeop_p, ext2fs_vnodeop_entries };
1147
1148 int (**ext2fs_specop_p)(void *);
1149 const struct vnodeopv_entry_desc ext2fs_specop_entries[] = {
1150 { &vop_default_desc, vn_default_error },
1151 { &vop_lookup_desc, spec_lookup }, /* lookup */
1152 { &vop_create_desc, spec_create }, /* create */
1153 { &vop_mknod_desc, spec_mknod }, /* mknod */
1154 { &vop_open_desc, spec_open }, /* open */
1155 { &vop_close_desc, ufsspec_close }, /* close */
1156 { &vop_access_desc, ext2fs_access }, /* access */
1157 { &vop_getattr_desc, ext2fs_getattr }, /* getattr */
1158 { &vop_setattr_desc, ext2fs_setattr }, /* setattr */
1159 { &vop_read_desc, ufsspec_read }, /* read */
1160 { &vop_write_desc, ufsspec_write }, /* write */
1161 { &vop_fallocate_desc, spec_fallocate }, /* fallocate */
1162 { &vop_fdiscard_desc, spec_fdiscard }, /* fdiscard */
1163 { &vop_ioctl_desc, spec_ioctl }, /* ioctl */
1164 { &vop_fcntl_desc, ufs_fcntl }, /* fcntl */
1165 { &vop_poll_desc, spec_poll }, /* poll */
1166 { &vop_kqfilter_desc, spec_kqfilter }, /* kqfilter */
1167 { &vop_revoke_desc, spec_revoke }, /* revoke */
1168 { &vop_mmap_desc, spec_mmap }, /* mmap */
1169 { &vop_fsync_desc, ext2fs_fsync }, /* fsync */
1170 { &vop_seek_desc, spec_seek }, /* seek */
1171 { &vop_remove_desc, spec_remove }, /* remove */
1172 { &vop_link_desc, spec_link }, /* link */
1173 { &vop_rename_desc, spec_rename }, /* rename */
1174 { &vop_mkdir_desc, spec_mkdir }, /* mkdir */
1175 { &vop_rmdir_desc, spec_rmdir }, /* rmdir */
1176 { &vop_symlink_desc, spec_symlink }, /* symlink */
1177 { &vop_readdir_desc, spec_readdir }, /* readdir */
1178 { &vop_readlink_desc, spec_readlink }, /* readlink */
1179 { &vop_abortop_desc, spec_abortop }, /* abortop */
1180 { &vop_inactive_desc, ext2fs_inactive }, /* inactive */
1181 { &vop_reclaim_desc, ext2fs_reclaim }, /* reclaim */
1182 { &vop_lock_desc, ufs_lock }, /* lock */
1183 { &vop_unlock_desc, ufs_unlock }, /* unlock */
1184 { &vop_bmap_desc, spec_bmap }, /* bmap */
1185 { &vop_strategy_desc, spec_strategy }, /* strategy */
1186 { &vop_print_desc, ufs_print }, /* print */
1187 { &vop_islocked_desc, ufs_islocked }, /* islocked */
1188 { &vop_pathconf_desc, spec_pathconf }, /* pathconf */
1189 { &vop_advlock_desc, spec_advlock }, /* advlock */
1190 { &vop_bwrite_desc, vn_bwrite }, /* bwrite */
1191 { &vop_getpages_desc, spec_getpages }, /* getpages */
1192 { &vop_putpages_desc, spec_putpages }, /* putpages */
1193 { &vop_getextattr_desc, ext2fs_getextattr }, /* getextattr */
1194 { &vop_setextattr_desc, ext2fs_setextattr }, /* setextattr */
1195 { &vop_listextattr_desc, ext2fs_listextattr }, /* listextattr */
1196 { &vop_deleteextattr_desc, ext2fs_deleteextattr },/* deleteextattr */
1197 { NULL, NULL }
1198 };
1199 const struct vnodeopv_desc ext2fs_specop_opv_desc =
1200 { &ext2fs_specop_p, ext2fs_specop_entries };
1201
1202 int (**ext2fs_fifoop_p)(void *);
1203 const struct vnodeopv_entry_desc ext2fs_fifoop_entries[] = {
1204 { &vop_default_desc, vn_default_error },
1205 { &vop_lookup_desc, vn_fifo_bypass }, /* lookup */
1206 { &vop_create_desc, vn_fifo_bypass }, /* create */
1207 { &vop_mknod_desc, vn_fifo_bypass }, /* mknod */
1208 { &vop_open_desc, vn_fifo_bypass }, /* open */
1209 { &vop_close_desc, ufsfifo_close }, /* close */
1210 { &vop_access_desc, ext2fs_access }, /* access */
1211 { &vop_getattr_desc, ext2fs_getattr }, /* getattr */
1212 { &vop_setattr_desc, ext2fs_setattr }, /* setattr */
1213 { &vop_read_desc, ufsfifo_read }, /* read */
1214 { &vop_write_desc, ufsfifo_write }, /* write */
1215 { &vop_fallocate_desc, vn_fifo_bypass }, /* fallocate */
1216 { &vop_fdiscard_desc, vn_fifo_bypass }, /* fdiscard */
1217 { &vop_ioctl_desc, vn_fifo_bypass }, /* ioctl */
1218 { &vop_fcntl_desc, ufs_fcntl }, /* fcntl */
1219 { &vop_poll_desc, vn_fifo_bypass }, /* poll */
1220 { &vop_kqfilter_desc, vn_fifo_bypass }, /* kqfilter */
1221 { &vop_revoke_desc, vn_fifo_bypass }, /* revoke */
1222 { &vop_mmap_desc, vn_fifo_bypass }, /* mmap */
1223 { &vop_fsync_desc, ext2fs_fsync }, /* fsync */
1224 { &vop_seek_desc, vn_fifo_bypass }, /* seek */
1225 { &vop_remove_desc, vn_fifo_bypass }, /* remove */
1226 { &vop_link_desc, vn_fifo_bypass }, /* link */
1227 { &vop_rename_desc, vn_fifo_bypass }, /* rename */
1228 { &vop_mkdir_desc, vn_fifo_bypass }, /* mkdir */
1229 { &vop_rmdir_desc, vn_fifo_bypass }, /* rmdir */
1230 { &vop_symlink_desc, vn_fifo_bypass }, /* symlink */
1231 { &vop_readdir_desc, vn_fifo_bypass }, /* readdir */
1232 { &vop_readlink_desc, vn_fifo_bypass }, /* readlink */
1233 { &vop_abortop_desc, vn_fifo_bypass }, /* abortop */
1234 { &vop_inactive_desc, ext2fs_inactive }, /* inactive */
1235 { &vop_reclaim_desc, ext2fs_reclaim }, /* reclaim */
1236 { &vop_lock_desc, ufs_lock }, /* lock */
1237 { &vop_unlock_desc, ufs_unlock }, /* unlock */
1238 { &vop_bmap_desc, vn_fifo_bypass }, /* bmap */
1239 { &vop_strategy_desc, vn_fifo_bypass }, /* strategy */
1240 { &vop_print_desc, ufs_print }, /* print */
1241 { &vop_islocked_desc, ufs_islocked }, /* islocked */
1242 { &vop_pathconf_desc, vn_fifo_bypass }, /* pathconf */
1243 { &vop_advlock_desc, vn_fifo_bypass }, /* advlock */
1244 { &vop_bwrite_desc, vn_bwrite }, /* bwrite */
1245 { &vop_putpages_desc, vn_fifo_bypass }, /* putpages */
1246 { &vop_getextattr_desc, ext2fs_getextattr }, /* getextattr */
1247 { &vop_setextattr_desc, ext2fs_setextattr }, /* setextattr */
1248 { &vop_listextattr_desc, ext2fs_listextattr }, /* listextattr */
1249 { &vop_deleteextattr_desc, ext2fs_deleteextattr },/* deleteextattr */
1250 { NULL, NULL }
1251 };
1252 const struct vnodeopv_desc ext2fs_fifoop_opv_desc =
1253 { &ext2fs_fifoop_p, ext2fs_fifoop_entries };
1254