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