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.94 1999/01/05 18:50:03 eivind 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 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); 463 vfs_object_create(devvp, p, p->p_ucred); 464 simple_lock(&devvp->v_interlock); 465 VOP_UNLOCK(devvp, LK_INTERLOCK, p); 466 } 467 468 /* 469 * Step 2: re-read superblock from disk. 470 */ 471 if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0) 472 size = DEV_BSIZE; 473 else 474 size = dpart.disklab->d_secsize; 475 if (error = bread(devvp, (ufs_daddr_t)(SBOFF/size), SBSIZE, NOCRED,&bp)) 476 return (error); 477 newfs = (struct fs *)bp->b_data; 478 if (newfs->fs_magic != FS_MAGIC || newfs->fs_bsize > MAXBSIZE || 479 newfs->fs_bsize < sizeof(struct fs)) { 480 brelse(bp); 481 return (EIO); /* XXX needs translation */ 482 } 483 fs = VFSTOUFS(mp)->um_fs; 484 /* 485 * Copy pointer fields back into superblock before copying in XXX 486 * new superblock. These should really be in the ufsmount. XXX 487 * Note that important parameters (eg fs_ncg) are unchanged. 488 */ 489 bcopy(&fs->fs_csp[0], &newfs->fs_csp[0], sizeof(fs->fs_csp)); 490 newfs->fs_maxcluster = fs->fs_maxcluster; 491 bcopy(newfs, fs, (u_int)fs->fs_sbsize); 492 if (fs->fs_sbsize < SBSIZE) 493 bp->b_flags |= B_INVAL; 494 brelse(bp); 495 mp->mnt_maxsymlinklen = fs->fs_maxsymlinklen; 496 ffs_oldfscompat(fs); 497 498 /* 499 * Step 3: re-read summary information from disk. 500 */ 501 blks = howmany(fs->fs_cssize, fs->fs_fsize); 502 space = fs->fs_csp[0]; 503 for (i = 0; i < blks; i += fs->fs_frag) { 504 size = fs->fs_bsize; 505 if (i + fs->fs_frag > blks) 506 size = (blks - i) * fs->fs_fsize; 507 error = bread(devvp, fsbtodb(fs, fs->fs_csaddr + i), size, 508 NOCRED, &bp); 509 if (error) 510 return (error); 511 bcopy(bp->b_data, fs->fs_csp[fragstoblks(fs, i)], (u_int)size); 512 brelse(bp); 513 } 514 /* 515 * We no longer know anything about clusters per cylinder group. 516 */ 517 if (fs->fs_contigsumsize > 0) { 518 lp = fs->fs_maxcluster; 519 for (i = 0; i < fs->fs_ncg; i++) 520 *lp++ = fs->fs_contigsumsize; 521 } 522 523 loop: 524 simple_lock(&mntvnode_slock); 525 for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) { 526 if (vp->v_mount != mp) { 527 simple_unlock(&mntvnode_slock); 528 goto loop; 529 } 530 nvp = vp->v_mntvnodes.le_next; 531 /* 532 * Step 4: invalidate all inactive vnodes. 533 */ 534 if (vrecycle(vp, &mntvnode_slock, p)) 535 goto loop; 536 /* 537 * Step 5: invalidate all cached file data. 538 */ 539 simple_lock(&vp->v_interlock); 540 simple_unlock(&mntvnode_slock); 541 if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) { 542 goto loop; 543 } 544 if (vinvalbuf(vp, 0, cred, p, 0, 0)) 545 panic("ffs_reload: dirty2"); 546 /* 547 * Step 6: re-read inode data for all active vnodes. 548 */ 549 ip = VTOI(vp); 550 error = 551 bread(devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), 552 (int)fs->fs_bsize, NOCRED, &bp); 553 if (error) { 554 vput(vp); 555 return (error); 556 } 557 ip->i_din = *((struct dinode *)bp->b_data + 558 ino_to_fsbo(fs, ip->i_number)); 559 ip->i_effnlink = ip->i_nlink; 560 brelse(bp); 561 vput(vp); 562 simple_lock(&mntvnode_slock); 563 } 564 simple_unlock(&mntvnode_slock); 565 return (0); 566 } 567 568 /* 569 * Common code for mount and mountroot 570 */ 571 int 572 ffs_mountfs(devvp, mp, p, malloctype) 573 register struct vnode *devvp; 574 struct mount *mp; 575 struct proc *p; 576 struct malloc_type *malloctype; 577 { 578 register struct ufsmount *ump; 579 struct buf *bp; 580 register struct fs *fs; 581 dev_t dev; 582 struct partinfo dpart; 583 caddr_t base, space; 584 int error, i, blks, size, ronly; 585 int32_t *lp; 586 struct ucred *cred; 587 u_int64_t maxfilesize; /* XXX */ 588 size_t strsize; 589 int ncount; 590 591 dev = devvp->v_rdev; 592 cred = p ? p->p_ucred : NOCRED; 593 /* 594 * Disallow multiple mounts of the same device. 595 * Disallow mounting of a device that is currently in use 596 * (except for root, which might share swap device for miniroot). 597 * Flush out any old buffers remaining from a previous use. 598 */ 599 error = vfs_mountedon(devvp); 600 if (error) 601 return (error); 602 ncount = vcount(devvp); 603 604 if (ncount > 1 && devvp != rootvp) 605 return (EBUSY); 606 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); 607 error = vinvalbuf(devvp, V_SAVE, cred, p, 0, 0); 608 VOP_UNLOCK(devvp, 0, p); 609 if (error) 610 return (error); 611 612 /* 613 * Only VMIO the backing device if the backing device is a real 614 * block device. This excludes the original MFS implementation. 615 * Note that it is optional that the backing device be VMIOed. This 616 * increases the opportunity for metadata caching. 617 */ 618 if (devvp->v_tag != VT_MFS && devvp->v_type == VBLK) { 619 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); 620 vfs_object_create(devvp, p, p->p_ucred); 621 simple_lock(&devvp->v_interlock); 622 VOP_UNLOCK(devvp, LK_INTERLOCK, p); 623 } 624 625 ronly = (mp->mnt_flag & MNT_RDONLY) != 0; 626 error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); 627 if (error) 628 return (error); 629 630 if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, cred, p) != 0) 631 size = DEV_BSIZE; 632 else 633 size = dpart.disklab->d_secsize; 634 635 bp = NULL; 636 ump = NULL; 637 if (error = bread(devvp, SBLOCK, SBSIZE, cred, &bp)) 638 goto out; 639 fs = (struct fs *)bp->b_data; 640 if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE || 641 fs->fs_bsize < sizeof(struct fs)) { 642 error = EINVAL; /* XXX needs translation */ 643 goto out; 644 } 645 fs->fs_fmod = 0; 646 fs->fs_flags &= ~FS_UNCLEAN; 647 if (fs->fs_clean == 0) { 648 fs->fs_flags |= FS_UNCLEAN; 649 if (ronly || (mp->mnt_flag & MNT_FORCE)) { 650 printf( 651 "WARNING: %s was not properly dismounted\n", 652 fs->fs_fsmnt); 653 } else { 654 printf( 655 "WARNING: R/W mount of %s denied. Filesystem is not clean - run fsck\n", 656 fs->fs_fsmnt); 657 error = EPERM; 658 goto out; 659 } 660 } 661 /* XXX updating 4.2 FFS superblocks trashes rotational layout tables */ 662 if (fs->fs_postblformat == FS_42POSTBLFMT && !ronly) { 663 error = EROFS; /* needs translation */ 664 goto out; 665 } 666 ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK); 667 bzero((caddr_t)ump, sizeof *ump); 668 ump->um_malloctype = malloctype; 669 ump->um_fs = malloc((u_long)fs->fs_sbsize, M_UFSMNT, 670 M_WAITOK); 671 ump->um_blkatoff = ffs_blkatoff; 672 ump->um_truncate = ffs_truncate; 673 ump->um_update = ffs_update; 674 ump->um_valloc = ffs_valloc; 675 ump->um_vfree = ffs_vfree; 676 bcopy(bp->b_data, ump->um_fs, (u_int)fs->fs_sbsize); 677 if (fs->fs_sbsize < SBSIZE) 678 bp->b_flags |= B_INVAL; 679 brelse(bp); 680 bp = NULL; 681 fs = ump->um_fs; 682 fs->fs_ronly = ronly; 683 if (ronly == 0) { 684 fs->fs_fmod = 1; 685 fs->fs_clean = 0; 686 } 687 size = fs->fs_cssize; 688 blks = howmany(size, fs->fs_fsize); 689 if (fs->fs_contigsumsize > 0) 690 size += fs->fs_ncg * sizeof(int32_t); 691 base = space = malloc((u_long)size, M_UFSMNT, M_WAITOK); 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, fsbtodb(fs, fs->fs_csaddr + i), size, 697 cred, &bp)) { 698 free(base, M_UFSMNT); 699 goto out; 700 } 701 bcopy(bp->b_data, space, (u_int)size); 702 fs->fs_csp[fragstoblks(fs, i)] = (struct csum *)space; 703 space += size; 704 brelse(bp); 705 bp = NULL; 706 } 707 if (fs->fs_contigsumsize > 0) { 708 fs->fs_maxcluster = lp = (int32_t *)space; 709 for (i = 0; i < fs->fs_ncg; i++) 710 *lp++ = fs->fs_contigsumsize; 711 } 712 mp->mnt_data = (qaddr_t)ump; 713 mp->mnt_stat.f_fsid.val[0] = (long)dev; 714 if (fs->fs_id[0] != 0 && fs->fs_id[1] != 0) 715 mp->mnt_stat.f_fsid.val[1] = fs->fs_id[1]; 716 else 717 mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; 718 mp->mnt_maxsymlinklen = fs->fs_maxsymlinklen; 719 mp->mnt_flag |= MNT_LOCAL; 720 ump->um_mountp = mp; 721 ump->um_dev = dev; 722 ump->um_devvp = devvp; 723 ump->um_nindir = fs->fs_nindir; 724 ump->um_bptrtodb = fs->fs_fsbtodb; 725 ump->um_seqinc = fs->fs_frag; 726 for (i = 0; i < MAXQUOTAS; i++) 727 ump->um_quotas[i] = NULLVP; 728 devvp->v_specmountpoint = mp; 729 ffs_oldfscompat(fs); 730 731 /* 732 * Set FS local "last mounted on" information (NULL pad) 733 */ 734 copystr( mp->mnt_stat.f_mntonname, /* mount point*/ 735 fs->fs_fsmnt, /* copy area*/ 736 sizeof(fs->fs_fsmnt) - 1, /* max size*/ 737 &strsize); /* real size*/ 738 bzero( fs->fs_fsmnt + strsize, sizeof(fs->fs_fsmnt) - strsize); 739 740 if( mp->mnt_flag & MNT_ROOTFS) { 741 /* 742 * Root mount; update timestamp in mount structure. 743 * this will be used by the common root mount code 744 * to update the system clock. 745 */ 746 mp->mnt_time = fs->fs_time; 747 } 748 749 ump->um_savedmaxfilesize = fs->fs_maxfilesize; /* XXX */ 750 maxfilesize = (u_int64_t)0x40000000 * fs->fs_bsize - 1; /* XXX */ 751 if (fs->fs_maxfilesize > maxfilesize) /* XXX */ 752 fs->fs_maxfilesize = maxfilesize; /* XXX */ 753 if (ronly == 0) { 754 if ((fs->fs_flags & FS_DOSOFTDEP) && 755 (error = softdep_mount(devvp, mp, fs, cred)) != 0) { 756 free(base, M_UFSMNT); 757 goto out; 758 } 759 fs->fs_clean = 0; 760 (void) ffs_sbupdate(ump, MNT_WAIT); 761 } 762 return (0); 763 out: 764 devvp->v_specmountpoint = NULL; 765 if (bp) 766 brelse(bp); 767 (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, cred, p); 768 if (ump) { 769 free(ump->um_fs, M_UFSMNT); 770 free(ump, M_UFSMNT); 771 mp->mnt_data = (qaddr_t)0; 772 } 773 return (error); 774 } 775 776 /* 777 * Sanity checks for old file systems. 778 * 779 * XXX - goes away some day. 780 */ 781 static int 782 ffs_oldfscompat(fs) 783 struct fs *fs; 784 { 785 786 fs->fs_npsect = max(fs->fs_npsect, fs->fs_nsect); /* XXX */ 787 fs->fs_interleave = max(fs->fs_interleave, 1); /* XXX */ 788 if (fs->fs_postblformat == FS_42POSTBLFMT) /* XXX */ 789 fs->fs_nrpos = 8; /* XXX */ 790 if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ 791 #if 0 792 int i; /* XXX */ 793 u_int64_t sizepb = fs->fs_bsize; /* XXX */ 794 /* XXX */ 795 fs->fs_maxfilesize = fs->fs_bsize * NDADDR - 1; /* XXX */ 796 for (i = 0; i < NIADDR; i++) { /* XXX */ 797 sizepb *= NINDIR(fs); /* XXX */ 798 fs->fs_maxfilesize += sizepb; /* XXX */ 799 } /* XXX */ 800 #endif 801 fs->fs_maxfilesize = (u_quad_t) 1LL << 39; 802 fs->fs_qbmask = ~fs->fs_bmask; /* XXX */ 803 fs->fs_qfmask = ~fs->fs_fmask; /* XXX */ 804 } /* XXX */ 805 return (0); 806 } 807 808 /* 809 * unmount system call 810 */ 811 int 812 ffs_unmount(mp, mntflags, p) 813 struct mount *mp; 814 int mntflags; 815 struct proc *p; 816 { 817 register struct ufsmount *ump; 818 register struct fs *fs; 819 int error, flags; 820 821 flags = 0; 822 if (mntflags & MNT_FORCE) { 823 flags |= FORCECLOSE; 824 } 825 if (mp->mnt_flag & MNT_SOFTDEP) { 826 if ((error = softdep_flushfiles(mp, flags, p)) != 0) 827 return (error); 828 } else { 829 if ((error = ffs_flushfiles(mp, flags, p)) != 0) 830 return (error); 831 } 832 ump = VFSTOUFS(mp); 833 fs = ump->um_fs; 834 if (fs->fs_ronly == 0) { 835 fs->fs_clean = fs->fs_flags & FS_UNCLEAN ? 0 : 1; 836 error = ffs_sbupdate(ump, MNT_WAIT); 837 if (error) { 838 fs->fs_clean = 0; 839 return (error); 840 } 841 } 842 ump->um_devvp->v_specmountpoint = NULL; 843 844 vinvalbuf(ump->um_devvp, V_SAVE, NOCRED, p, 0, 0); 845 error = VOP_CLOSE(ump->um_devvp, fs->fs_ronly ? FREAD : FREAD|FWRITE, 846 NOCRED, p); 847 848 vrele(ump->um_devvp); 849 850 free(fs->fs_csp[0], M_UFSMNT); 851 free(fs, M_UFSMNT); 852 free(ump, M_UFSMNT); 853 mp->mnt_data = (qaddr_t)0; 854 mp->mnt_flag &= ~MNT_LOCAL; 855 return (error); 856 } 857 858 /* 859 * Flush out all the files in a filesystem. 860 */ 861 int 862 ffs_flushfiles(mp, flags, p) 863 register struct mount *mp; 864 int flags; 865 struct proc *p; 866 { 867 register struct ufsmount *ump; 868 int error; 869 870 ump = VFSTOUFS(mp); 871 #ifdef QUOTA 872 if (mp->mnt_flag & MNT_QUOTA) { 873 int i; 874 error = vflush(mp, NULLVP, SKIPSYSTEM|flags); 875 if (error) 876 return (error); 877 for (i = 0; i < MAXQUOTAS; i++) { 878 if (ump->um_quotas[i] == NULLVP) 879 continue; 880 quotaoff(p, mp, i); 881 } 882 /* 883 * Here we fall through to vflush again to ensure 884 * that we have gotten rid of all the system vnodes. 885 */ 886 } 887 #endif 888 /* 889 * Flush all the files. 890 */ 891 if ((error = vflush(mp, NULL, flags)) != 0) 892 return (error); 893 /* 894 * Flush filesystem metadata. 895 */ 896 vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, p); 897 error = VOP_FSYNC(ump->um_devvp, p->p_ucred, MNT_WAIT, p); 898 VOP_UNLOCK(ump->um_devvp, 0, p); 899 return (error); 900 } 901 902 /* 903 * Get file system statistics. 904 */ 905 int 906 ffs_statfs(mp, sbp, p) 907 struct mount *mp; 908 register struct statfs *sbp; 909 struct proc *p; 910 { 911 register struct ufsmount *ump; 912 register struct fs *fs; 913 914 ump = VFSTOUFS(mp); 915 fs = ump->um_fs; 916 if (fs->fs_magic != FS_MAGIC) 917 panic("ffs_statfs"); 918 sbp->f_bsize = fs->fs_fsize; 919 sbp->f_iosize = fs->fs_bsize; 920 sbp->f_blocks = fs->fs_dsize; 921 sbp->f_bfree = fs->fs_cstotal.cs_nbfree * fs->fs_frag + 922 fs->fs_cstotal.cs_nffree; 923 sbp->f_bavail = freespace(fs, fs->fs_minfree); 924 sbp->f_files = fs->fs_ncg * fs->fs_ipg - ROOTINO; 925 sbp->f_ffree = fs->fs_cstotal.cs_nifree; 926 if (sbp != &mp->mnt_stat) { 927 sbp->f_type = mp->mnt_vfc->vfc_typenum; 928 bcopy((caddr_t)mp->mnt_stat.f_mntonname, 929 (caddr_t)&sbp->f_mntonname[0], MNAMELEN); 930 bcopy((caddr_t)mp->mnt_stat.f_mntfromname, 931 (caddr_t)&sbp->f_mntfromname[0], MNAMELEN); 932 } 933 return (0); 934 } 935 936 /* 937 * Go through the disk queues to initiate sandbagged IO; 938 * go through the inodes to write those that have been modified; 939 * initiate the writing of the super block if it has been modified. 940 * 941 * Note: we are always called with the filesystem marked `MPBUSY'. 942 */ 943 int 944 ffs_sync(mp, waitfor, cred, p) 945 struct mount *mp; 946 int waitfor; 947 struct ucred *cred; 948 struct proc *p; 949 { 950 struct vnode *nvp, *vp; 951 struct inode *ip; 952 struct ufsmount *ump = VFSTOUFS(mp); 953 struct fs *fs; 954 int error, allerror = 0; 955 956 fs = ump->um_fs; 957 if (fs->fs_fmod != 0 && fs->fs_ronly != 0) { /* XXX */ 958 printf("fs = %s\n", fs->fs_fsmnt); 959 panic("ffs_sync: rofs mod"); 960 } 961 /* 962 * Write back each (modified) inode. 963 */ 964 simple_lock(&mntvnode_slock); 965 loop: 966 for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) { 967 /* 968 * If the vnode that we are about to sync is no longer 969 * associated with this mount point, start over. 970 */ 971 if (vp->v_mount != mp) 972 goto loop; 973 simple_lock(&vp->v_interlock); 974 nvp = vp->v_mntvnodes.le_next; 975 ip = VTOI(vp); 976 if ((vp->v_type == VNON) || ((ip->i_flag & 977 (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0) && 978 (TAILQ_EMPTY(&vp->v_dirtyblkhd) || (waitfor == MNT_LAZY))) { 979 simple_unlock(&vp->v_interlock); 980 continue; 981 } 982 if (vp->v_type != VCHR) { 983 simple_unlock(&mntvnode_slock); 984 error = 985 vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p); 986 if (error) { 987 simple_lock(&mntvnode_slock); 988 if (error == ENOENT) 989 goto loop; 990 continue; 991 } 992 if (error = VOP_FSYNC(vp, cred, waitfor, p)) 993 allerror = error; 994 VOP_UNLOCK(vp, 0, p); 995 vrele(vp); 996 simple_lock(&mntvnode_slock); 997 } else { 998 simple_unlock(&mntvnode_slock); 999 simple_unlock(&vp->v_interlock); 1000 /* UFS_UPDATE(vp, waitfor == MNT_WAIT); */ 1001 UFS_UPDATE(vp, 0); 1002 simple_lock(&mntvnode_slock); 1003 } 1004 } 1005 simple_unlock(&mntvnode_slock); 1006 /* 1007 * Force stale file system control information to be flushed. 1008 */ 1009 if (waitfor != MNT_LAZY) { 1010 if (ump->um_mountp->mnt_flag & MNT_SOFTDEP) 1011 waitfor = MNT_NOWAIT; 1012 vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, p); 1013 if ((error = VOP_FSYNC(ump->um_devvp, cred, waitfor, p)) != 0) 1014 allerror = error; 1015 VOP_UNLOCK(ump->um_devvp, 0, p); 1016 } 1017 #ifdef QUOTA 1018 qsync(mp); 1019 #endif 1020 /* 1021 * Write back modified superblock. 1022 */ 1023 if (fs->fs_fmod != 0 && (error = ffs_sbupdate(ump, waitfor)) != 0) 1024 allerror = error; 1025 return (allerror); 1026 } 1027 1028 /* 1029 * Look up a FFS dinode number to find its incore vnode, otherwise read it 1030 * in from disk. If it is in core, wait for the lock bit to clear, then 1031 * return the inode locked. Detection and handling of mount points must be 1032 * done by the calling routine. 1033 */ 1034 static int ffs_inode_hash_lock; 1035 1036 int 1037 ffs_vget(mp, ino, vpp) 1038 struct mount *mp; 1039 ino_t ino; 1040 struct vnode **vpp; 1041 { 1042 struct fs *fs; 1043 struct inode *ip; 1044 struct ufsmount *ump; 1045 struct buf *bp; 1046 struct vnode *vp; 1047 dev_t dev; 1048 int error; 1049 1050 ump = VFSTOUFS(mp); 1051 dev = ump->um_dev; 1052 restart: 1053 if ((*vpp = ufs_ihashget(dev, ino)) != NULL) { 1054 return (0); 1055 } 1056 1057 /* 1058 * Lock out the creation of new entries in the FFS hash table in 1059 * case getnewvnode() or MALLOC() blocks, otherwise a duplicate 1060 * may occur! 1061 */ 1062 if (ffs_inode_hash_lock) { 1063 while (ffs_inode_hash_lock) { 1064 ffs_inode_hash_lock = -1; 1065 tsleep(&ffs_inode_hash_lock, PVM, "ffsvgt", 0); 1066 } 1067 goto restart; 1068 } 1069 ffs_inode_hash_lock = 1; 1070 1071 /* 1072 * If this MALLOC() is performed after the getnewvnode() 1073 * it might block, leaving a vnode with a NULL v_data to be 1074 * found by ffs_sync() if a sync happens to fire right then, 1075 * which will cause a panic because ffs_sync() blindly 1076 * dereferences vp->v_data (as well it should). 1077 */ 1078 MALLOC(ip, struct inode *, sizeof(struct inode), 1079 ump->um_malloctype, M_WAITOK); 1080 1081 /* Allocate a new vnode/inode. */ 1082 error = getnewvnode(VT_UFS, mp, ffs_vnodeop_p, &vp); 1083 if (error) { 1084 if (ffs_inode_hash_lock < 0) 1085 wakeup(&ffs_inode_hash_lock); 1086 ffs_inode_hash_lock = 0; 1087 *vpp = NULL; 1088 FREE(ip, ump->um_malloctype); 1089 return (error); 1090 } 1091 bzero((caddr_t)ip, sizeof(struct inode)); 1092 lockinit(&ip->i_lock, PINOD, "inode", 0, 0); 1093 vp->v_data = ip; 1094 ip->i_vnode = vp; 1095 ip->i_fs = fs = ump->um_fs; 1096 ip->i_dev = dev; 1097 ip->i_number = ino; 1098 #ifdef QUOTA 1099 { 1100 int i; 1101 for (i = 0; i < MAXQUOTAS; i++) 1102 ip->i_dquot[i] = NODQUOT; 1103 } 1104 #endif 1105 /* 1106 * Put it onto its hash chain and lock it so that other requests for 1107 * this inode will block if they arrive while we are sleeping waiting 1108 * for old data structures to be purged or for the contents of the 1109 * disk portion of this inode to be read. 1110 */ 1111 ufs_ihashins(ip); 1112 1113 if (ffs_inode_hash_lock < 0) 1114 wakeup(&ffs_inode_hash_lock); 1115 ffs_inode_hash_lock = 0; 1116 1117 /* Read in the disk contents for the inode, copy into the inode. */ 1118 error = bread(ump->um_devvp, fsbtodb(fs, ino_to_fsba(fs, ino)), 1119 (int)fs->fs_bsize, NOCRED, &bp); 1120 if (error) { 1121 /* 1122 * The inode does not contain anything useful, so it would 1123 * be misleading to leave it on its hash chain. With mode 1124 * still zero, it will be unlinked and returned to the free 1125 * list by vput(). 1126 */ 1127 brelse(bp); 1128 vput(vp); 1129 *vpp = NULL; 1130 return (error); 1131 } 1132 ip->i_din = *((struct dinode *)bp->b_data + ino_to_fsbo(fs, ino)); 1133 if (DOINGSOFTDEP(vp)) 1134 softdep_load_inodeblock(ip); 1135 else 1136 ip->i_effnlink = ip->i_nlink; 1137 bqrelse(bp); 1138 1139 /* 1140 * Initialize the vnode from the inode, check for aliases. 1141 * Note that the underlying vnode may have changed. 1142 */ 1143 error = ufs_vinit(mp, ffs_specop_p, ffs_fifoop_p, &vp); 1144 if (error) { 1145 vput(vp); 1146 *vpp = NULL; 1147 return (error); 1148 } 1149 /* 1150 * Finish inode initialization now that aliasing has been resolved. 1151 */ 1152 ip->i_devvp = ump->um_devvp; 1153 VREF(ip->i_devvp); 1154 /* 1155 * Set up a generation number for this inode if it does not 1156 * already have one. This should only happen on old filesystems. 1157 */ 1158 if (ip->i_gen == 0) { 1159 ip->i_gen = random() / 2 + 1; 1160 if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) 1161 ip->i_flag |= IN_MODIFIED; 1162 } 1163 /* 1164 * Ensure that uid and gid are correct. This is a temporary 1165 * fix until fsck has been changed to do the update. 1166 */ 1167 if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ 1168 ip->i_uid = ip->i_din.di_ouid; /* XXX */ 1169 ip->i_gid = ip->i_din.di_ogid; /* XXX */ 1170 } /* XXX */ 1171 1172 *vpp = vp; 1173 return (0); 1174 } 1175 1176 /* 1177 * File handle to vnode 1178 * 1179 * Have to be really careful about stale file handles: 1180 * - check that the inode number is valid 1181 * - call ffs_vget() to get the locked inode 1182 * - check for an unallocated inode (i_mode == 0) 1183 * - check that the given client host has export rights and return 1184 * those rights via. exflagsp and credanonp 1185 */ 1186 int 1187 ffs_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp) 1188 register struct mount *mp; 1189 struct fid *fhp; 1190 struct sockaddr *nam; 1191 struct vnode **vpp; 1192 int *exflagsp; 1193 struct ucred **credanonp; 1194 { 1195 register struct ufid *ufhp; 1196 struct fs *fs; 1197 1198 ufhp = (struct ufid *)fhp; 1199 fs = VFSTOUFS(mp)->um_fs; 1200 if (ufhp->ufid_ino < ROOTINO || 1201 ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg) 1202 return (ESTALE); 1203 return (ufs_check_export(mp, ufhp, nam, vpp, exflagsp, credanonp)); 1204 } 1205 1206 /* 1207 * Vnode pointer to File handle 1208 */ 1209 /* ARGSUSED */ 1210 int 1211 ffs_vptofh(vp, fhp) 1212 struct vnode *vp; 1213 struct fid *fhp; 1214 { 1215 register struct inode *ip; 1216 register struct ufid *ufhp; 1217 1218 ip = VTOI(vp); 1219 ufhp = (struct ufid *)fhp; 1220 ufhp->ufid_len = sizeof(struct ufid); 1221 ufhp->ufid_ino = ip->i_number; 1222 ufhp->ufid_gen = ip->i_gen; 1223 return (0); 1224 } 1225 1226 /* 1227 * Initialize the filesystem; just use ufs_init. 1228 */ 1229 static int 1230 ffs_init(vfsp) 1231 struct vfsconf *vfsp; 1232 { 1233 1234 softdep_initialize(); 1235 return (ufs_init(vfsp)); 1236 } 1237 1238 /* 1239 * Write a superblock and associated information back to disk. 1240 */ 1241 static int 1242 ffs_sbupdate(mp, waitfor) 1243 struct ufsmount *mp; 1244 int waitfor; 1245 { 1246 register struct fs *dfs, *fs = mp->um_fs; 1247 register struct buf *bp; 1248 int blks; 1249 caddr_t space; 1250 int i, size, error, allerror = 0; 1251 1252 /* 1253 * First write back the summary information. 1254 */ 1255 blks = howmany(fs->fs_cssize, fs->fs_fsize); 1256 space = (caddr_t)fs->fs_csp[0]; 1257 for (i = 0; i < blks; i += fs->fs_frag) { 1258 size = fs->fs_bsize; 1259 if (i + fs->fs_frag > blks) 1260 size = (blks - i) * fs->fs_fsize; 1261 bp = getblk(mp->um_devvp, fsbtodb(fs, fs->fs_csaddr + i), 1262 size, 0, 0); 1263 bcopy(space, bp->b_data, (u_int)size); 1264 space += size; 1265 if (waitfor != MNT_WAIT) 1266 bawrite(bp); 1267 else if (error = bwrite(bp)) 1268 allerror = error; 1269 } 1270 /* 1271 * Now write back the superblock itself. If any errors occurred 1272 * up to this point, then fail so that the superblock avoids 1273 * being written out as clean. 1274 */ 1275 if (allerror) 1276 return (allerror); 1277 bp = getblk(mp->um_devvp, SBLOCK, (int)fs->fs_sbsize, 0, 0); 1278 fs->fs_fmod = 0; 1279 fs->fs_time = time_second; 1280 bcopy((caddr_t)fs, bp->b_data, (u_int)fs->fs_sbsize); 1281 /* Restore compatibility to old file systems. XXX */ 1282 dfs = (struct fs *)bp->b_data; /* XXX */ 1283 if (fs->fs_postblformat == FS_42POSTBLFMT) /* XXX */ 1284 dfs->fs_nrpos = -1; /* XXX */ 1285 if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ 1286 int32_t *lp, tmp; /* XXX */ 1287 /* XXX */ 1288 lp = (int32_t *)&dfs->fs_qbmask; /* XXX */ 1289 tmp = lp[4]; /* XXX */ 1290 for (i = 4; i > 0; i--) /* XXX */ 1291 lp[i] = lp[i-1]; /* XXX */ 1292 lp[0] = tmp; /* XXX */ 1293 } /* XXX */ 1294 dfs->fs_maxfilesize = mp->um_savedmaxfilesize; /* XXX */ 1295 if (waitfor != MNT_WAIT) 1296 bawrite(bp); 1297 else if (error = bwrite(bp)) 1298 allerror = error; 1299 return (allerror); 1300 } 1301