1 /* 2 * Copyright (c) 1989, 1991, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)ffs_vfsops.c 8.31 (Berkeley) 5/20/95 30 * $FreeBSD: src/sys/ufs/ffs/ffs_vfsops.c,v 1.117.2.10 2002/06/23 22:34:52 iedowse Exp $ 31 */ 32 33 #include "opt_quota.h" 34 35 #include <sys/disk.h> 36 #include <sys/param.h> 37 #include <sys/systm.h> 38 #include <sys/proc.h> 39 #include <sys/nlookup.h> 40 #include <sys/kernel.h> 41 #include <sys/vnode.h> 42 #include <sys/mount.h> 43 #include <sys/buf.h> 44 #include <sys/conf.h> 45 #include <sys/fcntl.h> 46 #include <sys/diskslice.h> 47 #include <sys/malloc.h> 48 49 #include "quota.h" 50 #include "ufsmount.h" 51 #include "inode.h" 52 #include "ufs_extern.h" 53 54 #include "fs.h" 55 #include "ffs_extern.h" 56 57 #include <vm/vm.h> 58 #include <vm/vm_page.h> 59 #include <vm/vm_zone.h> 60 61 #include <sys/buf2.h> 62 63 static MALLOC_DEFINE(M_FFSNODE, "FFS node", "FFS vnode private part"); 64 65 static int ffs_sbupdate (struct ufsmount *, int); 66 static int ffs_reload (struct mount *, struct ucred *); 67 static int ffs_oldfscompat (struct fs *); 68 static int ffs_mount (struct mount *, char *, caddr_t, struct ucred *); 69 static int ffs_init (struct vfsconf *); 70 71 static struct vfsops ufs_vfsops = { 72 .vfs_flags = 0, 73 .vfs_mount = ffs_mount, 74 .vfs_unmount = ffs_unmount, 75 .vfs_root = ufs_root, 76 .vfs_quotactl = ufs_quotactl, 77 .vfs_statfs = ffs_statfs, 78 .vfs_sync = ffs_sync, 79 .vfs_vget = ffs_vget, 80 .vfs_fhtovp = ffs_fhtovp, 81 .vfs_checkexp = ufs_check_export, 82 .vfs_vptofh = ffs_vptofh, 83 .vfs_init = ffs_init, 84 }; 85 86 VFS_SET(ufs_vfsops, ufs, 0); 87 MODULE_VERSION(ufs, 1); 88 89 extern struct vop_ops ffs_vnode_vops; 90 extern struct vop_ops ffs_spec_vops; 91 extern struct vop_ops ffs_fifo_vops; 92 93 /* 94 * ffs_mount 95 * 96 * Called when mounting local physical media 97 * 98 * PARAMETERS: 99 * mountroot 100 * mp mount point structure 101 * path NULL (flag for root mount!!!) 102 * data <unused> 103 * p process (user credentials check [statfs]) 104 * 105 * mount 106 * mp mount point structure 107 * path path to mount point 108 * data pointer to argument struct in user space 109 * p process (user credentials check) 110 * 111 * RETURNS: 0 Success 112 * !0 error number (errno.h) 113 * 114 * LOCK STATE: 115 * 116 * ENTRY 117 * mount point is locked 118 * EXIT 119 * mount point is locked 120 * 121 * NOTES: 122 * A NULL path can be used for a flag since the mount 123 * system call will fail with EFAULT in copyinstr in 124 * nlookup() if it is a genuine NULL from the user. 125 */ 126 static int 127 ffs_mount(struct mount *mp, /* mount struct pointer */ 128 char *path, /* path to mount point */ 129 caddr_t data, /* arguments to FS specific mount */ 130 struct ucred *cred) /* process requesting mount */ 131 { 132 size_t size; 133 int error; 134 struct vnode *devvp; 135 136 struct ufs_args args; 137 struct ufsmount *ump = NULL; 138 struct fs *fs; 139 int flags, ronly = 0; 140 mode_t accessmode; 141 struct nlookupdata nd; 142 struct vnode *rootvp; 143 144 devvp = NULL; 145 error = 0; 146 147 /* 148 * Use NULL path to flag a root mount 149 */ 150 if (path == NULL) { 151 /* 152 *** 153 * Mounting root filesystem 154 *** 155 */ 156 157 if ((error = bdevvp(rootdev, &rootvp))) { 158 kprintf("ffs_mountroot: can't find rootvp\n"); 159 return (error); 160 } 161 162 if( ( error = ffs_mountfs(rootvp, mp, M_FFSNODE)) != 0) { 163 /* fs specific cleanup (if any)*/ 164 goto error_1; 165 } 166 devvp = rootvp; 167 168 goto dostatfs; /* success*/ 169 170 } 171 172 /* 173 *** 174 * Mounting non-root filesystem or updating a filesystem 175 *** 176 */ 177 178 /* copy in user arguments*/ 179 error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args)); 180 if (error) 181 goto error_1; /* can't get arguments*/ 182 183 /* 184 * If updating, check whether changing from read-only to 185 * read/write; if there is no device name, that's all we do. 186 */ 187 if (mp->mnt_flag & MNT_UPDATE) { 188 ump = VFSTOUFS(mp); 189 fs = ump->um_fs; 190 devvp = ump->um_devvp; 191 error = 0; 192 ronly = fs->fs_ronly; /* MNT_RELOAD might change this */ 193 if (ronly == 0 && (mp->mnt_flag & MNT_RDONLY)) { 194 /* 195 * Flush any dirty data. 196 */ 197 VFS_SYNC(mp, MNT_WAIT); 198 /* 199 * Check for and optionally get rid of files open 200 * for writing. 201 */ 202 flags = WRITECLOSE; 203 if (mp->mnt_flag & MNT_FORCE) 204 flags |= FORCECLOSE; 205 if (mp->mnt_flag & MNT_SOFTDEP) { 206 error = softdep_flushfiles(mp, flags); 207 } else { 208 error = ffs_flushfiles(mp, flags); 209 } 210 ronly = 1; 211 } 212 if (!error && (mp->mnt_flag & MNT_RELOAD)) { 213 error = ffs_reload(mp, NULL); 214 } 215 if (error) { 216 goto error_1; 217 } 218 if (ronly && (mp->mnt_kern_flag & MNTK_WANTRDWR)) { 219 /* 220 * If upgrade to read-write by non-root, then verify 221 * that user has necessary permissions on the device. 222 */ 223 if (cred->cr_uid != 0) { 224 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); 225 if ((error = VOP_EACCESS(devvp, VREAD | VWRITE, 226 cred)) != 0) { 227 vn_unlock(devvp); 228 return (error); 229 } 230 vn_unlock(devvp); 231 } 232 233 fs->fs_flags &= ~FS_UNCLEAN; 234 if (fs->fs_clean == 0) { 235 fs->fs_flags |= FS_UNCLEAN; 236 if (mp->mnt_flag & MNT_FORCE) { 237 kprintf( 238 "WARNING: %s was not properly dismounted\n", 239 fs->fs_fsmnt); 240 } else { 241 kprintf( 242 "WARNING: R/W mount of %s denied. Filesystem is not clean - run fsck\n", 243 fs->fs_fsmnt); 244 error = EPERM; 245 goto error_1; 246 } 247 } 248 249 /* check to see if we need to start softdep */ 250 if (fs->fs_flags & FS_DOSOFTDEP) { 251 error = softdep_mount(devvp, mp, fs); 252 if (error) 253 goto error_1; 254 } 255 ronly = 0; 256 } 257 /* 258 * Soft updates is incompatible with "async", 259 * so if we are doing softupdates stop the user 260 * from setting the async flag in an update. 261 * Softdep_mount() clears it in an initial mount 262 * or ro->rw remount. 263 */ 264 if (mp->mnt_flag & MNT_SOFTDEP) { 265 mp->mnt_flag &= ~MNT_ASYNC; 266 } 267 /* if not updating name...*/ 268 if (args.fspec == NULL) { 269 /* 270 * Process export requests. Jumping to "success" 271 * will return the vfs_export() error code. 272 */ 273 error = vfs_export(mp, &ump->um_export, &args.export); 274 goto success; 275 } 276 } 277 278 /* 279 * Not an update, or updating the name: look up the name 280 * and verify that it refers to a sensible block device. 281 */ 282 devvp = NULL; 283 error = nlookup_init(&nd, args.fspec, UIO_USERSPACE, NLC_FOLLOW); 284 if (error == 0) 285 error = nlookup(&nd); 286 if (error == 0) 287 error = cache_vref(&nd.nl_nch, nd.nl_cred, &devvp); 288 nlookup_done(&nd); 289 if (error) 290 goto error_1; 291 292 if (!vn_isdisk(devvp, &error)) 293 goto error_2; 294 295 /* 296 * If mount by non-root, then verify that user has necessary 297 * permissions on the device. 298 */ 299 if (cred->cr_uid != 0) { 300 accessmode = VREAD; 301 if ((mp->mnt_flag & MNT_RDONLY) == 0) 302 accessmode |= VWRITE; 303 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); 304 if ((error = VOP_EACCESS(devvp, accessmode, cred)) != 0) { 305 vput(devvp); 306 return (error); 307 } 308 vn_unlock(devvp); 309 } 310 311 if (mp->mnt_flag & MNT_UPDATE) { 312 /* 313 * UPDATE - make sure the resolved vnode represents the same 314 * device. Since devfs, devvp->v_rdev can be used directly as 315 * it is always associated as long as the vnode exists. 316 * 317 * Our current open/writecount state is associated with 318 * um_devvp, so continue using um_devvp and throw away devvp. 319 */ 320 if (devvp != ump->um_devvp) { 321 if (devvp->v_rdev == ump->um_devvp->v_rdev) { 322 vrele(devvp); 323 devvp = ump->um_devvp; 324 } else { 325 kprintf("cannot update mount, v_rdev does" 326 " not match (%p vs %p)\n", 327 devvp->v_rdev, ump->um_devvp->v_rdev); 328 error = EINVAL; /* needs translation */ 329 } 330 } else { 331 vrele(devvp); 332 } 333 /* 334 * Update device name only on success 335 */ 336 if (!error) { 337 /* Save "mounted from" info for mount point (NULL pad)*/ 338 copyinstr( args.fspec, 339 mp->mnt_stat.f_mntfromname, 340 MNAMELEN - 1, 341 &size); 342 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); 343 } 344 } else { 345 /* 346 ******************** 347 * NEW MOUNT 348 ******************** 349 */ 350 351 /* Save "mounted from" info for mount point (NULL pad)*/ 352 copyinstr( args.fspec, /* device name*/ 353 mp->mnt_stat.f_mntfromname, /* save area*/ 354 MNAMELEN - 1, /* max size*/ 355 &size); /* real size*/ 356 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); 357 358 /* Save "last mounted on" info for mount point (NULL pad)*/ 359 bzero(mp->mnt_stat.f_mntonname, 360 sizeof(mp->mnt_stat.f_mntonname)); 361 if (path) { 362 copyinstr(path, mp->mnt_stat.f_mntonname, 363 sizeof(mp->mnt_stat.f_mntonname) - 1, 364 &size); 365 } else { /* Root mount */ 366 mp->mnt_stat.f_mntonname[0] = '/'; 367 } 368 369 error = ffs_mountfs(devvp, mp, M_FFSNODE); 370 } 371 if (error) { 372 goto error_2; 373 } 374 375 dostatfs: 376 /* 377 * Initialize FS stat information in mount struct; uses 378 * mp->mnt_stat.f_mntfromname. 379 * 380 * This code is common to root and non-root mounts 381 */ 382 (void)VFS_STATFS(mp, &mp->mnt_stat, cred); 383 384 goto success; 385 386 387 error_2: /* error with devvp held*/ 388 389 /* release devvp before failing*/ 390 vrele(devvp); 391 392 error_1: /* no state to back out*/ 393 394 success: 395 if (!error && path && (mp->mnt_flag & MNT_UPDATE)) { 396 /* Update clean flag after changing read-onlyness. */ 397 fs = ump->um_fs; 398 if (ronly != fs->fs_ronly) { 399 fs->fs_ronly = ronly; 400 fs->fs_clean = ronly && 401 (fs->fs_flags & FS_UNCLEAN) == 0 ? 1 : 0; 402 403 /* 404 * The device must be re-opened as appropriate or 405 * the device close at unmount time will panic. 406 */ 407 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); 408 if (ronly) { 409 VOP_OPEN(devvp, FREAD, FSCRED, NULL); 410 VOP_CLOSE(devvp, FREAD|FWRITE, NULL); 411 } else { 412 VOP_OPEN(devvp, FREAD|FWRITE, FSCRED, NULL); 413 VOP_CLOSE(devvp, FREAD, NULL); 414 } 415 vn_unlock(devvp); 416 ffs_sbupdate(ump, MNT_WAIT); 417 } 418 } 419 return (error); 420 } 421 422 /* 423 * Reload all incore data for a filesystem (used after running fsck on 424 * the root filesystem and finding things to fix). The filesystem must 425 * be mounted read-only. 426 * 427 * Things to do to update the mount: 428 * 1) invalidate all cached meta-data. 429 * 2) re-read superblock from disk. 430 * 3) re-read summary information from disk. 431 * 4) invalidate all inactive vnodes. 432 * 5) invalidate all cached file data. 433 * 6) re-read inode data for all active vnodes. 434 */ 435 436 static int ffs_reload_scan2(struct mount *mp, struct vnode *vp, void *data); 437 438 struct scaninfo { 439 int rescan; 440 struct fs *fs; 441 struct vnode *devvp; 442 int waitfor; 443 int allerror; 444 }; 445 446 static int 447 ffs_reload(struct mount *mp, struct ucred *cred) 448 { 449 struct vnode *devvp; 450 void *space; 451 struct buf *bp; 452 struct fs *fs, *newfs; 453 int i, blks, size, error; 454 struct scaninfo scaninfo; 455 int32_t *lp; 456 457 if ((mp->mnt_flag & MNT_RDONLY) == 0) 458 return (EINVAL); 459 /* 460 * Step 1: invalidate all cached meta-data. 461 */ 462 devvp = VFSTOUFS(mp)->um_devvp; 463 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); 464 error = vinvalbuf(devvp, 0, 0, 0); 465 vn_unlock(devvp); 466 if (error) 467 panic("ffs_reload: dirty1"); 468 469 /* 470 * The backing device must be VMIO-capable because we use getblk(). 471 * NOTE: the MFS driver now returns a VMIO-enabled descriptor. 472 */ 473 if (devvp->v_object == NULL) 474 panic("ffs_reload: devvp has no VM object!"); 475 476 /* 477 * Step 2: re-read superblock from disk. 478 */ 479 if ((error = bread(devvp, SBOFF, SBSIZE, &bp)) != 0) { 480 brelse(bp); 481 return (error); 482 } 483 newfs = (struct fs *)bp->b_data; 484 if (newfs->fs_magic != FS_MAGIC || newfs->fs_bsize > MAXBSIZE || 485 newfs->fs_bsize < sizeof(struct fs)) { 486 brelse(bp); 487 return (EIO); /* XXX needs translation */ 488 } 489 fs = VFSTOUFS(mp)->um_fs; 490 /* 491 * Copy pointer fields back into superblock before copying in XXX 492 * new superblock. These should really be in the ufsmount. XXX 493 * Note that important parameters (eg fs_ncg) are unchanged. 494 */ 495 newfs->fs_csp = fs->fs_csp; 496 newfs->fs_maxcluster = fs->fs_maxcluster; 497 newfs->fs_contigdirs = fs->fs_contigdirs; 498 /* The filesystem is still read-only. */ 499 newfs->fs_ronly = 1; 500 bcopy(newfs, fs, (uint)fs->fs_sbsize); 501 if (fs->fs_sbsize < SBSIZE) 502 bp->b_flags |= B_INVAL; 503 brelse(bp); 504 mp->mnt_maxsymlinklen = fs->fs_maxsymlinklen; 505 ffs_oldfscompat(fs); 506 /* An old fsck may have zeroed these fields, so recheck them. */ 507 if (fs->fs_avgfilesize <= 0) /* XXX */ 508 fs->fs_avgfilesize = AVFILESIZ; /* XXX */ 509 if (fs->fs_avgfpdir <= 0) /* XXX */ 510 fs->fs_avgfpdir = AFPDIR; /* XXX */ 511 512 /* 513 * Step 3: re-read summary information from disk. 514 */ 515 blks = howmany(fs->fs_cssize, fs->fs_fsize); 516 space = fs->fs_csp; 517 for (i = 0; i < blks; i += fs->fs_frag) { 518 size = fs->fs_bsize; 519 if (i + fs->fs_frag > blks) 520 size = (blks - i) * fs->fs_fsize; 521 error = bread(devvp, fsbtodoff(fs, fs->fs_csaddr + i), size, &bp); 522 if (error) { 523 brelse(bp); 524 return (error); 525 } 526 bcopy(bp->b_data, space, (uint)size); 527 space = (char *)space + size; 528 brelse(bp); 529 } 530 /* 531 * We no longer know anything about clusters per cylinder group. 532 */ 533 if (fs->fs_contigsumsize > 0) { 534 lp = fs->fs_maxcluster; 535 for (i = 0; i < fs->fs_ncg; i++) 536 *lp++ = fs->fs_contigsumsize; 537 } 538 539 scaninfo.rescan = 0; 540 scaninfo.fs = fs; 541 scaninfo.devvp = devvp; 542 while (error == 0 && scaninfo.rescan) { 543 scaninfo.rescan = 0; 544 error = vmntvnodescan(mp, VMSC_GETVX, 545 NULL, ffs_reload_scan2, &scaninfo); 546 } 547 return(error); 548 } 549 550 static int 551 ffs_reload_scan2(struct mount *mp, struct vnode *vp, void *data) 552 { 553 struct scaninfo *info = data; 554 struct inode *ip; 555 struct buf *bp; 556 int error; 557 558 /* 559 * Try to recycle 560 */ 561 if (vrecycle(vp)) 562 return(0); 563 564 if (vinvalbuf(vp, 0, 0, 0)) 565 panic("ffs_reload: dirty2"); 566 /* 567 * Step 6: re-read inode data for all active vnodes. 568 */ 569 ip = VTOI(vp); 570 error = bread(info->devvp, 571 fsbtodoff(info->fs, ino_to_fsba(info->fs, ip->i_number)), 572 (int)info->fs->fs_bsize, &bp); 573 if (error) { 574 brelse(bp); 575 return (error); 576 } 577 ip->i_din = *((struct ufs1_dinode *)bp->b_data + 578 ino_to_fsbo(info->fs, ip->i_number)); 579 ip->i_effnlink = ip->i_nlink; 580 brelse(bp); 581 return(0); 582 } 583 584 /* 585 * Common code for mount and mountroot 586 */ 587 int 588 ffs_mountfs(struct vnode *devvp, struct mount *mp, struct malloc_type *mtype) 589 { 590 struct mount *mptmp; 591 struct ufsmount *ump; 592 struct buf *bp; 593 struct fs *fs; 594 cdev_t dev; 595 void *space; 596 int error, i, blks, size, ronly; 597 int32_t *lp; 598 uint64_t maxfilesize; /* XXX */ 599 600 /* 601 * Disallow multiple mounts of the same device. 602 * Disallow mounting of a device that is currently in use 603 * Flush out any old buffers remaining from a previous use. 604 */ 605 error = vfs_mountedon(devvp); 606 if (error) 607 return (error); 608 if (vcount(devvp) > 0) 609 return (EBUSY); 610 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); 611 error = vinvalbuf(devvp, V_SAVE, 0, 0); 612 vn_unlock(devvp); 613 if (error) 614 return (error); 615 616 ronly = (mp->mnt_flag & MNT_RDONLY) != 0; 617 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); 618 error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, NULL); 619 vn_unlock(devvp); 620 if (error) 621 return (error); 622 dev = devvp->v_rdev; 623 if (dev->si_iosize_max != 0) 624 mp->mnt_iosize_max = dev->si_iosize_max; 625 if (mp->mnt_iosize_max > MAXPHYS) 626 mp->mnt_iosize_max = MAXPHYS; 627 628 /* 629 * Filesystem supports native FSMIDs 630 */ 631 mp->mnt_kern_flag |= MNTK_FSMID; 632 633 /* 634 * The backing device must be VMIO-capable because we use getblk(). 635 * NOTE: the MFS driver now returns a VMIO-enabled descriptor. 636 * The VOP_OPEN() call above should have associated a VM object 637 * with devvp. 638 */ 639 if (devvp->v_object == NULL) 640 panic("ffs_reload: devvp has no VM object!"); 641 642 bp = NULL; 643 ump = NULL; 644 if ((error = bread(devvp, SBOFF, SBSIZE, &bp)) != 0) 645 goto out; 646 fs = (struct fs *)bp->b_data; 647 if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE || 648 fs->fs_bsize < sizeof(struct fs)) { 649 error = EINVAL; /* XXX needs translation */ 650 goto out; 651 } 652 fs->fs_fmod = 0; 653 fs->fs_flags &= ~FS_UNCLEAN; 654 if (fs->fs_clean == 0) { 655 fs->fs_flags |= FS_UNCLEAN; 656 if (ronly || (mp->mnt_flag & MNT_FORCE)) { 657 kprintf( 658 "WARNING: %s was not properly dismounted\n", 659 fs->fs_fsmnt); 660 } else { 661 kprintf( 662 "WARNING: R/W mount of %s denied. Filesystem is not clean - run fsck\n", 663 fs->fs_fsmnt); 664 error = EPERM; 665 goto out; 666 } 667 } 668 /* XXX updating 4.2 FFS superblocks trashes rotational layout tables */ 669 if (fs->fs_postblformat == FS_42POSTBLFMT && !ronly) { 670 error = EROFS; /* needs translation */ 671 goto out; 672 } 673 ump = kmalloc(sizeof *ump, M_UFSMNT, M_WAITOK | M_ZERO); 674 ump->um_malloctype = mtype; 675 ump->um_i_effnlink_valid = 1; 676 ump->um_fs = kmalloc((u_long)fs->fs_sbsize, M_UFSMNT, 677 M_WAITOK); 678 bcopy(bp->b_data, ump->um_fs, (uint)fs->fs_sbsize); 679 if (fs->fs_sbsize < SBSIZE) 680 bp->b_flags |= B_INVAL; 681 brelse(bp); 682 bp = NULL; 683 fs = ump->um_fs; 684 fs->fs_ronly = ronly; 685 size = fs->fs_cssize; 686 blks = howmany(size, fs->fs_fsize); 687 if (fs->fs_contigsumsize > 0) 688 size += fs->fs_ncg * sizeof(int32_t); 689 size += fs->fs_ncg * sizeof(uint8_t); 690 space = kmalloc((u_long)size, M_UFSMNT, M_WAITOK); 691 fs->fs_csp = space; 692 for (i = 0; i < blks; i += fs->fs_frag) { 693 size = fs->fs_bsize; 694 if (i + fs->fs_frag > blks) 695 size = (blks - i) * fs->fs_fsize; 696 if ((error = bread(devvp, fsbtodoff(fs, fs->fs_csaddr + i), 697 size, &bp)) != 0) { 698 kfree(fs->fs_csp, M_UFSMNT); 699 goto out; 700 } 701 bcopy(bp->b_data, space, (uint)size); 702 space = (char *)space + size; 703 brelse(bp); 704 bp = NULL; 705 } 706 if (fs->fs_contigsumsize > 0) { 707 fs->fs_maxcluster = lp = space; 708 for (i = 0; i < fs->fs_ncg; i++) 709 *lp++ = fs->fs_contigsumsize; 710 space = lp; 711 } 712 size = fs->fs_ncg * sizeof(uint8_t); 713 fs->fs_contigdirs = (uint8_t *)space; 714 bzero(fs->fs_contigdirs, size); 715 /* Compatibility for old filesystems XXX */ 716 if (fs->fs_avgfilesize <= 0) /* XXX */ 717 fs->fs_avgfilesize = AVFILESIZ; /* XXX */ 718 if (fs->fs_avgfpdir <= 0) /* XXX */ 719 fs->fs_avgfpdir = AFPDIR; /* XXX */ 720 mp->mnt_data = (qaddr_t)ump; 721 mp->mnt_stat.f_fsid.val[0] = fs->fs_id[0]; 722 mp->mnt_stat.f_fsid.val[1] = fs->fs_id[1]; 723 if (fs->fs_id[0] == 0 || fs->fs_id[1] == 0) { 724 vfs_getnewfsid(mp); 725 } else if ((mptmp = vfs_getvfs(&mp->mnt_stat.f_fsid)) != NULL) { 726 vfs_getnewfsid(mp); 727 mount_drop(mptmp); 728 } 729 mp->mnt_maxsymlinklen = fs->fs_maxsymlinklen; 730 mp->mnt_flag |= MNT_LOCAL; 731 ump->um_mountp = mp; 732 ump->um_dev = dev; 733 ump->um_devvp = devvp; 734 ump->um_nindir = fs->fs_nindir; 735 ump->um_bptrtodb = fs->fs_fsbtodb; 736 ump->um_seqinc = fs->fs_frag; 737 for (i = 0; i < MAXQUOTAS; i++) 738 ump->um_quotas[i] = NULLVP; 739 dev->si_mountpoint = mp; 740 ffs_oldfscompat(fs); 741 742 /* restore "last mounted on" here */ 743 bzero(fs->fs_fsmnt, sizeof(fs->fs_fsmnt)); 744 ksnprintf(fs->fs_fsmnt, sizeof(fs->fs_fsmnt), 745 "%s", mp->mnt_stat.f_mntonname); 746 747 if( mp->mnt_flag & MNT_ROOTFS) { 748 /* 749 * Root mount; update timestamp in mount structure. 750 * this will be used by the common root mount code 751 * to update the system clock. 752 */ 753 mp->mnt_time = fs->fs_time; 754 } 755 756 ufs_ihashinit(ump); 757 ump->um_savedmaxfilesize = fs->fs_maxfilesize; /* XXX */ 758 maxfilesize = (uint64_t)0x40000000 * fs->fs_bsize - 1; /* XXX */ 759 /* Enforce limit caused by vm object backing (32 bits vm_pindex_t). */ 760 if (maxfilesize > (uint64_t)0x80000000u * PAGE_SIZE - 1) 761 maxfilesize = (uint64_t)0x80000000u * PAGE_SIZE - 1; 762 if (fs->fs_maxfilesize > maxfilesize) /* XXX */ 763 fs->fs_maxfilesize = maxfilesize; /* XXX */ 764 if (ronly == 0) { 765 if ((fs->fs_flags & FS_DOSOFTDEP) && 766 (error = softdep_mount(devvp, mp, fs)) != 0) { 767 kfree(fs->fs_csp, M_UFSMNT); 768 goto out; 769 } 770 fs->fs_fmod = 1; 771 fs->fs_clean = 0; 772 (void) ffs_sbupdate(ump, MNT_WAIT); 773 } 774 vfs_add_vnodeops(mp, &ffs_vnode_vops, &mp->mnt_vn_norm_ops); 775 vfs_add_vnodeops(mp, &ffs_spec_vops, &mp->mnt_vn_spec_ops); 776 vfs_add_vnodeops(mp, &ffs_fifo_vops, &mp->mnt_vn_fifo_ops); 777 778 return (0); 779 out: 780 dev->si_mountpoint = NULL; 781 if (bp) 782 brelse(bp); 783 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); 784 VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NULL); 785 vn_unlock(devvp); 786 if (ump) { 787 ufs_ihashuninit(ump); 788 kfree(ump->um_fs, M_UFSMNT); 789 kfree(ump, M_UFSMNT); 790 mp->mnt_data = (qaddr_t)0; 791 } 792 return (error); 793 } 794 795 /* 796 * Sanity checks for old filesystems. 797 * 798 * XXX - goes away some day. 799 */ 800 static int 801 ffs_oldfscompat(struct fs *fs) 802 { 803 fs->fs_npsect = max(fs->fs_npsect, fs->fs_nsect); /* XXX */ 804 fs->fs_interleave = max(fs->fs_interleave, 1); /* XXX */ 805 if (fs->fs_postblformat == FS_42POSTBLFMT) /* XXX */ 806 fs->fs_nrpos = 8; /* XXX */ 807 if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ 808 #if 0 809 int i; /* XXX */ 810 uint64_t sizepb = fs->fs_bsize; /* XXX */ 811 /* XXX */ 812 fs->fs_maxfilesize = fs->fs_bsize * UFS_NDADDR - 1; /* XXX */ 813 for (i = 0; i < UFS_NIADDR; i++) { /* XXX */ 814 sizepb *= NINDIR(fs); /* XXX */ 815 fs->fs_maxfilesize += sizepb; /* XXX */ 816 } /* XXX */ 817 #endif 818 fs->fs_maxfilesize = (u_quad_t) 1LL << 39; 819 fs->fs_qbmask = ~fs->fs_bmask; /* XXX */ 820 fs->fs_qfmask = ~fs->fs_fmask; /* XXX */ 821 } /* XXX */ 822 return (0); 823 } 824 825 /* 826 * unmount system call 827 */ 828 int 829 ffs_unmount(struct mount *mp, int mntflags) 830 { 831 struct ufsmount *ump; 832 struct fs *fs; 833 int error, flags; 834 835 flags = 0; 836 if (mntflags & MNT_FORCE) { 837 flags |= FORCECLOSE; 838 } 839 if (mp->mnt_flag & MNT_SOFTDEP) { 840 if ((error = softdep_flushfiles(mp, flags)) != 0) 841 return (error); 842 } else { 843 if ((error = ffs_flushfiles(mp, flags)) != 0) 844 return (error); 845 } 846 ump = VFSTOUFS(mp); 847 fs = ump->um_fs; 848 if (fs->fs_ronly == 0) { 849 fs->fs_clean = fs->fs_flags & FS_UNCLEAN ? 0 : 1; 850 error = ffs_sbupdate(ump, MNT_WAIT); 851 if (error) { 852 fs->fs_clean = 0; 853 return (error); 854 } 855 } 856 ump->um_devvp->v_rdev->si_mountpoint = NULL; 857 858 vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY); 859 vinvalbuf(ump->um_devvp, V_SAVE, 0, 0); 860 error = VOP_CLOSE(ump->um_devvp, 861 fs->fs_ronly ? FREAD : FREAD|FWRITE, 862 NULL); 863 vn_unlock(ump->um_devvp); 864 865 vrele(ump->um_devvp); 866 867 ufs_ihashuninit(ump); 868 kfree(fs->fs_csp, M_UFSMNT); 869 kfree(fs, M_UFSMNT); 870 kfree(ump, M_UFSMNT); 871 mp->mnt_data = (qaddr_t)0; 872 mp->mnt_flag &= ~MNT_LOCAL; 873 return (error); 874 } 875 876 /* 877 * Flush out all the files in a filesystem. 878 */ 879 int 880 ffs_flushfiles(struct mount *mp, int flags) 881 { 882 struct ufsmount *ump; 883 int error; 884 885 ump = VFSTOUFS(mp); 886 #ifdef QUOTA 887 if (mp->mnt_flag & MNT_QUOTA) { 888 int i; 889 error = vflush(mp, 0, SKIPSYSTEM|flags); 890 if (error) 891 return (error); 892 /* Find out how many quota files we have open. */ 893 for (i = 0; i < MAXQUOTAS; i++) { 894 if (ump->um_quotas[i] == NULLVP) 895 continue; 896 ufs_quotaoff(mp, i); 897 } 898 /* 899 * Here we fall through to vflush again to ensure 900 * that we have gotten rid of all the system vnodes. 901 */ 902 } 903 #endif 904 /* 905 * Flush all the files. 906 */ 907 if ((error = vflush(mp, 0, flags)) != 0) 908 return (error); 909 /* 910 * Flush filesystem metadata. 911 */ 912 vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY); 913 error = VOP_FSYNC(ump->um_devvp, MNT_WAIT, 0); 914 vn_unlock(ump->um_devvp); 915 return (error); 916 } 917 918 /* 919 * Get filesystem statistics. 920 */ 921 int 922 ffs_statfs(struct mount *mp, struct statfs *sbp, struct ucred *cred) 923 { 924 struct ufsmount *ump; 925 struct fs *fs; 926 927 ump = VFSTOUFS(mp); 928 fs = ump->um_fs; 929 if (fs->fs_magic != FS_MAGIC) 930 panic("ffs_statfs"); 931 sbp->f_bsize = fs->fs_fsize; 932 sbp->f_iosize = fs->fs_bsize; 933 sbp->f_blocks = fs->fs_dsize; 934 sbp->f_bfree = fs->fs_cstotal.cs_nbfree * fs->fs_frag + 935 fs->fs_cstotal.cs_nffree; 936 sbp->f_bavail = freespace(fs, fs->fs_minfree); 937 sbp->f_files = fs->fs_ncg * fs->fs_ipg - UFS_ROOTINO; 938 sbp->f_ffree = fs->fs_cstotal.cs_nifree; 939 if (sbp != &mp->mnt_stat) { 940 sbp->f_type = mp->mnt_vfc->vfc_typenum; 941 bcopy((caddr_t)mp->mnt_stat.f_mntfromname, 942 (caddr_t)&sbp->f_mntfromname[0], MNAMELEN); 943 } 944 return (0); 945 } 946 947 /* 948 * Go through the disk queues to initiate sandbagged IO; 949 * go through the inodes to write those that have been modified; 950 * initiate the writing of the super block if it has been modified. 951 * 952 * Note: we are always called with the filesystem marked `MPBUSY'. 953 */ 954 955 956 static int ffs_sync_scan1(struct mount *mp, struct vnode *vp, void *data); 957 static int ffs_sync_scan2(struct mount *mp, struct vnode *vp, void *data); 958 959 int 960 ffs_sync(struct mount *mp, int waitfor) 961 { 962 struct ufsmount *ump = VFSTOUFS(mp); 963 struct fs *fs; 964 int error; 965 struct scaninfo scaninfo; 966 967 fs = ump->um_fs; 968 if (fs->fs_fmod != 0 && fs->fs_ronly != 0) { /* XXX */ 969 kprintf("fs = %s\n", fs->fs_fsmnt); 970 panic("ffs_sync: rofs mod"); 971 } 972 973 /* 974 * Write back each (modified) inode. 975 */ 976 scaninfo.allerror = 0; 977 scaninfo.rescan = 1; 978 scaninfo.waitfor = waitfor; 979 while (scaninfo.rescan) { 980 scaninfo.rescan = 0; 981 vmntvnodescan(mp, VMSC_GETVP|VMSC_NOWAIT, 982 ffs_sync_scan1, ffs_sync_scan2, &scaninfo); 983 } 984 985 /* 986 * Force stale filesystem control information to be flushed. 987 */ 988 if ((waitfor & MNT_LAZY) == 0) { 989 if (ump->um_mountp->mnt_flag & MNT_SOFTDEP) 990 waitfor = MNT_NOWAIT; 991 vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY); 992 if ((error = VOP_FSYNC(ump->um_devvp, waitfor, 0)) != 0) 993 scaninfo.allerror = error; 994 vn_unlock(ump->um_devvp); 995 } 996 #ifdef QUOTA 997 ufs_qsync(mp); 998 #endif 999 /* 1000 * Write back modified superblock. 1001 */ 1002 if (fs->fs_fmod != 0 && (error = ffs_sbupdate(ump, waitfor)) != 0) 1003 scaninfo.allerror = error; 1004 return (scaninfo.allerror); 1005 } 1006 1007 static int 1008 ffs_sync_scan1(struct mount *mp, struct vnode *vp, void *data) 1009 { 1010 struct inode *ip; 1011 1012 /* 1013 * Depend on the mount list's vnode lock to keep things stable 1014 * enough for a quick test. Since there might be hundreds of 1015 * thousands of vnodes, we cannot afford even a subroutine 1016 * call unless there's a good chance that we have work to do. 1017 */ 1018 ip = VTOI(vp); 1019 /* Restart out whole search if this guy is locked 1020 * or is being reclaimed. 1021 */ 1022 if (vp->v_type == VNON || (ip == NULL) || ((ip->i_flag & 1023 (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 && 1024 RB_EMPTY(&vp->v_rbdirty_tree))) { 1025 return(-1); 1026 } 1027 return(0); 1028 } 1029 1030 static int 1031 ffs_sync_scan2(struct mount *mp, struct vnode *vp, void *data) 1032 { 1033 struct scaninfo *info = data; 1034 struct inode *ip; 1035 int error; 1036 1037 /* 1038 * We have to recheck after having obtained the vnode interlock. 1039 */ 1040 ip = VTOI(vp); 1041 if (vp->v_type == VNON || vp->v_type == VBAD || 1042 ((ip->i_flag & 1043 (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 && 1044 RB_EMPTY(&vp->v_rbdirty_tree))) { 1045 return(0); 1046 } 1047 if (vp->v_type != VCHR) { 1048 if ((error = VOP_FSYNC(vp, info->waitfor, 0)) != 0) 1049 info->allerror = error; 1050 } else { 1051 /* 1052 * We must reference the vp to prevent it from 1053 * getting ripped out from under ffs_update, since 1054 * we are not holding a vnode lock. 1055 */ 1056 /* ffs_update(vp, waitfor == MNT_WAIT); */ 1057 ffs_update(vp, 0); 1058 } 1059 return(0); 1060 } 1061 1062 /* 1063 * Look up a FFS dinode number to find its incore vnode, otherwise read it 1064 * in from disk. If it is in core, wait for the lock bit to clear, then 1065 * return the inode locked. Detection and handling of mount points must be 1066 * done by the calling routine. 1067 */ 1068 1069 int 1070 ffs_vget(struct mount *mp, struct vnode *dvp, ino_t ino, struct vnode **vpp) 1071 { 1072 struct fs *fs; 1073 struct inode *ip; 1074 struct ufsmount *ump; 1075 struct buf *bp; 1076 struct vnode *vp; 1077 cdev_t dev; 1078 int error; 1079 1080 ump = VFSTOUFS(mp); 1081 dev = ump->um_dev; 1082 1083 retry: 1084 if ((*vpp = ufs_ihashget(ump, dev, ino)) != NULL) { 1085 return (0); 1086 } 1087 1088 /* 1089 * If this MALLOC() is performed after the getnewvnode() 1090 * it might block, leaving a vnode with a NULL v_data to be 1091 * found by ffs_sync() if a sync happens to fire right then, 1092 * which will cause a panic because ffs_sync() blindly 1093 * dereferences vp->v_data (as well it should). 1094 * 1095 * XXX this may no longer be true since getnewvnode returns a 1096 * VX locked vnode now. 1097 */ 1098 ip = kmalloc(sizeof(struct inode), ump->um_malloctype, 1099 M_WAITOK | M_ZERO); 1100 1101 /* Allocate a new vnode/inode. */ 1102 error = getnewvnode(VT_UFS, mp, &vp, VLKTIMEOUT, LK_CANRECURSE); 1103 if (error) { 1104 *vpp = NULL; 1105 kfree(ip, ump->um_malloctype); 1106 return (error); 1107 } 1108 ip->i_vnode = vp; 1109 ip->i_fs = fs = ump->um_fs; 1110 ip->i_dev = dev; 1111 ip->i_number = ino; 1112 #ifdef QUOTA 1113 { 1114 int i; 1115 for (i = 0; i < MAXQUOTAS; i++) 1116 ip->i_dquot[i] = NODQUOT; 1117 } 1118 #endif 1119 1120 /* 1121 * Insert it into the inode hash table. 1122 */ 1123 if (ufs_ihashins(ump, ip) != 0) { 1124 kprintf("debug: ufs ihashins collision, retrying inode %ld\n", 1125 (long) ip->i_number); 1126 *vpp = NULL; 1127 vp->v_type = VBAD; 1128 vx_put(vp); 1129 kfree(ip, ump->um_malloctype); 1130 goto retry; 1131 } 1132 vp->v_data = ip; 1133 1134 /* Read in the disk contents for the inode, copy into the inode. */ 1135 error = bread(ump->um_devvp, fsbtodoff(fs, ino_to_fsba(fs, ino)), 1136 (int)fs->fs_bsize, &bp); 1137 if (error) { 1138 /* 1139 * The inode does not contain anything useful, so it would 1140 * be misleading to leave it on its hash chain. With mode 1141 * still zero, it will be unlinked and returned to the free 1142 * list by vput(). 1143 */ 1144 vp->v_type = VBAD; 1145 brelse(bp); 1146 vx_put(vp); 1147 *vpp = NULL; 1148 return (error); 1149 } 1150 ip->i_din = *((struct ufs1_dinode *)bp->b_data + ino_to_fsbo(fs, ino)); 1151 if (DOINGSOFTDEP(vp)) 1152 softdep_load_inodeblock(ip); 1153 else 1154 ip->i_effnlink = ip->i_nlink; 1155 bqrelse(bp); 1156 1157 /* 1158 * Initialize the vnode from the inode, check for aliases. 1159 * Note that the underlying vnode may have changed. 1160 */ 1161 error = ufs_vinit(mp, &vp); 1162 if (error) { 1163 vp->v_type = VBAD; 1164 vx_put(vp); 1165 *vpp = NULL; 1166 return (error); 1167 } 1168 /* 1169 * Finish inode initialization now that aliasing has been resolved. 1170 */ 1171 ip->i_devvp = ump->um_devvp; 1172 vref(ip->i_devvp); 1173 /* 1174 * Set up a generation number for this inode if it does not 1175 * already have one. This should only happen on old filesystems. 1176 */ 1177 if (ip->i_gen == 0) { 1178 ip->i_gen = krandom() / 2 + 1; 1179 if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) 1180 ip->i_flag |= IN_MODIFIED; 1181 } 1182 /* 1183 * Ensure that uid and gid are correct. This is a temporary 1184 * fix until fsck has been changed to do the update. 1185 */ 1186 if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ 1187 ip->i_uid = ip->i_din.di_ouid; /* XXX */ 1188 ip->i_gid = ip->i_din.di_ogid; /* XXX */ 1189 } /* XXX */ 1190 1191 /* 1192 * return a VX locked and refd vnode (VX == same as normal vget() 1193 * vnode so we are ok) 1194 */ 1195 vx_downgrade(vp); 1196 *vpp = vp; 1197 1198 return (0); 1199 } 1200 1201 /* 1202 * File handle to vnode 1203 * 1204 * Have to be really careful about stale file handles: 1205 * - check that the inode number is valid 1206 * - call ffs_vget() to get the locked inode 1207 * - check for an unallocated inode (i_mode == 0) 1208 * - check that the given client host has export rights and return 1209 * those rights via. exflagsp and credanonp 1210 */ 1211 int 1212 ffs_fhtovp(struct mount *mp, struct vnode *rootvp, 1213 struct fid *fhp, struct vnode **vpp) 1214 { 1215 struct ufid *ufhp; 1216 struct fs *fs; 1217 1218 ufhp = (struct ufid *)fhp; 1219 fs = VFSTOUFS(mp)->um_fs; 1220 if (ufhp->ufid_ino < UFS_ROOTINO || 1221 ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg) 1222 return (ESTALE); 1223 return (ufs_fhtovp(mp, rootvp, ufhp, vpp)); 1224 } 1225 1226 /* 1227 * Vnode pointer to File handle 1228 */ 1229 /* ARGSUSED */ 1230 int 1231 ffs_vptofh(struct vnode *vp, struct fid *fhp) 1232 { 1233 struct inode *ip; 1234 struct ufid *ufhp; 1235 1236 ip = VTOI(vp); 1237 ufhp = (struct ufid *)fhp; 1238 ufhp->ufid_len = sizeof(struct ufid); 1239 ufhp->ufid_ino = ip->i_number; 1240 ufhp->ufid_gen = ip->i_gen; 1241 return (0); 1242 } 1243 1244 /* 1245 * Initialize the filesystem; just use ufs_init. 1246 */ 1247 static int 1248 ffs_init(struct vfsconf *vfsp) 1249 { 1250 softdep_initialize(); 1251 kmalloc_raise_limit(M_FFSNODE, 0); 1252 return (ufs_init(vfsp)); 1253 } 1254 1255 /* 1256 * Write a superblock and associated information back to disk. 1257 */ 1258 static int 1259 ffs_sbupdate(struct ufsmount *mp, int waitfor) 1260 { 1261 struct fs *dfs, *fs = mp->um_fs; 1262 struct buf *bp; 1263 int blks; 1264 void *space; 1265 int i, size, error, allerror = 0; 1266 1267 /* 1268 * First write back the summary information. 1269 * 1270 * NOTE: the getblk is relative to the device vnode so bio1 1271 * contains the device block number. 1272 */ 1273 blks = howmany(fs->fs_cssize, fs->fs_fsize); 1274 space = fs->fs_csp; 1275 for (i = 0; i < blks; i += fs->fs_frag) { 1276 size = fs->fs_bsize; 1277 if (i + fs->fs_frag > blks) 1278 size = (blks - i) * fs->fs_fsize; 1279 bp = getblk(mp->um_devvp, fsbtodoff(fs, fs->fs_csaddr + i), 1280 size, 0, 0); 1281 bcopy(space, bp->b_data, (uint)size); 1282 space = (char *)space + size; 1283 if (waitfor != MNT_WAIT) 1284 bawrite(bp); 1285 else if ((error = bwrite(bp)) != 0) 1286 allerror = error; 1287 } 1288 /* 1289 * Now write back the superblock itself. If any errors occurred 1290 * up to this point, then fail so that the superblock avoids 1291 * being written out as clean. 1292 */ 1293 if (allerror) 1294 return (allerror); 1295 bp = getblk(mp->um_devvp, SBOFF, (int)fs->fs_sbsize, 0, 0); 1296 fs->fs_fmod = 0; 1297 fs->fs_time = time_second; 1298 bcopy((caddr_t)fs, bp->b_data, (uint)fs->fs_sbsize); 1299 /* Restore compatibility to old filesystems. XXX */ 1300 dfs = (struct fs *)bp->b_data; /* XXX */ 1301 if (fs->fs_postblformat == FS_42POSTBLFMT) /* XXX */ 1302 dfs->fs_nrpos = -1; /* XXX */ 1303 if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ 1304 int32_t *lp, tmp; /* XXX */ 1305 /* XXX */ 1306 lp = (int32_t *)&dfs->fs_qbmask; /* XXX */ 1307 tmp = lp[4]; /* XXX */ 1308 for (i = 4; i > 0; i--) /* XXX */ 1309 lp[i] = lp[i-1]; /* XXX */ 1310 lp[0] = tmp; /* XXX */ 1311 } /* XXX */ 1312 dfs->fs_maxfilesize = mp->um_savedmaxfilesize; /* XXX */ 1313 if (waitfor != MNT_WAIT) 1314 bawrite(bp); 1315 else if ((error = bwrite(bp)) != 0) 1316 allerror = error; 1317 return (allerror); 1318 } 1319