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