ext2_vfsops.c revision 125786
1/* 2 * modified for EXT2FS support in Lites 1.1 3 * 4 * Aug 1995, Godmar Back (gback@cs.utah.edu) 5 * University of Utah, Department of Computer Science 6 */ 7/* 8 * Copyright (c) 1989, 1991, 1993, 1994 9 * The Regents of the University of California. All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the University of 22 * California, Berkeley and its contributors. 23 * 4. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)ffs_vfsops.c 8.8 (Berkeley) 4/18/94 40 * $FreeBSD: head/sys/gnu/fs/ext2fs/ext2_vfsops.c 125786 2004-02-13 20:23:16Z bde $ 41 */ 42 43#include <sys/param.h> 44#include <sys/systm.h> 45#include <sys/namei.h> 46#include <sys/proc.h> 47#include <sys/kernel.h> 48#include <sys/vnode.h> 49#include <sys/mount.h> 50#include <sys/bio.h> 51#include <sys/buf.h> 52#include <sys/conf.h> 53#include <sys/fcntl.h> 54#include <sys/malloc.h> 55#include <sys/stat.h> 56#include <sys/mutex.h> 57 58#include <gnu/ext2fs/ext2_mount.h> 59#include <gnu/ext2fs/inode.h> 60 61#include <gnu/ext2fs/fs.h> 62#include <gnu/ext2fs/ext2_extern.h> 63#include <gnu/ext2fs/ext2_fs.h> 64#include <gnu/ext2fs/ext2_fs_sb.h> 65 66static int ext2_flushfiles(struct mount *mp, int flags, struct thread *td); 67static int ext2_mountfs(struct vnode *, struct mount *, struct thread *); 68static int ext2_reload(struct mount *mp, struct ucred *cred, struct thread *td); 69static int ext2_sbupdate(struct ext2mount *, int); 70 71static vfs_unmount_t ext2_unmount; 72static vfs_root_t ext2_root; 73static vfs_statfs_t ext2_statfs; 74static vfs_sync_t ext2_sync; 75static vfs_vget_t ext2_vget; 76static vfs_fhtovp_t ext2_fhtovp; 77static vfs_vptofh_t ext2_vptofh; 78static vfs_init_t ext2_init; 79static vfs_uninit_t ext2_uninit; 80static vfs_nmount_t ext2_mount; 81 82MALLOC_DEFINE(M_EXT2NODE, "EXT2 node", "EXT2 vnode private part"); 83static MALLOC_DEFINE(M_EXT2MNT, "EXT2 mount", "EXT2 mount structure"); 84 85static struct vfsops ext2fs_vfsops = { 86 .vfs_fhtovp = ext2_fhtovp, 87 .vfs_init = ext2_init, 88 .vfs_nmount = ext2_mount, 89 .vfs_root = ext2_root, /* root inode via vget */ 90 .vfs_statfs = ext2_statfs, 91 .vfs_sync = ext2_sync, 92 .vfs_uninit = ext2_uninit, 93 .vfs_unmount = ext2_unmount, 94 .vfs_vget = ext2_vget, 95 .vfs_vptofh = ext2_vptofh, 96}; 97 98VFS_SET(ext2fs_vfsops, ext2fs, 0); 99#define bsd_malloc malloc 100#define bsd_free free 101 102static int ext2fs_inode_hash_lock; 103 104static int ext2_check_sb_compat(struct ext2_super_block *es, dev_t dev, 105 int ronly); 106static int compute_sb_data(struct vnode * devvp, 107 struct ext2_super_block * es, struct ext2_sb_info * fs); 108 109#ifdef notyet 110static int ext2_mountroot(void); 111 112/* 113 * Called by main() when ext2fs is going to be mounted as root. 114 * 115 * Name is updated by mount(8) after booting. 116 */ 117#define ROOTNAME "root_device" 118 119static int 120ext2_mountroot() 121{ 122 struct ext2_sb_info *fs; 123 struct mount *mp; 124 struct thread *td = curthread; 125 struct ext2mount *ump; 126 u_int size; 127 int error; 128 129 if ((error = bdevvp(rootdev, &rootvp))) { 130 printf("ext2_mountroot: can't find rootvp\n"); 131 return (error); 132 } 133 mp = bsd_malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK); 134 bzero((char *)mp, (u_long)sizeof(struct mount)); 135 TAILQ_INIT(&mp->mnt_nvnodelist); 136 TAILQ_INIT(&mp->mnt_reservedvnlist); 137 mp->mnt_op = &ext2fs_vfsops; 138 mp->mnt_flag = MNT_RDONLY; 139 if (error = ext2_mountfs(rootvp, mp, td)) { 140 bsd_free(mp, M_MOUNT); 141 return (error); 142 } 143 if (error = vfs_lock(mp)) { 144 (void)ext2_unmount(mp, 0, td); 145 bsd_free(mp, M_MOUNT); 146 return (error); 147 } 148 TAILQ_INSERT_HEAD(&mountlist, mp, mnt_list); 149 mp->mnt_flag |= MNT_ROOTFS; 150 mp->mnt_vnodecovered = NULLVP; 151 ump = VFSTOEXT2(mp); 152 fs = ump->um_e2fs; 153 bzero(fs->fs_fsmnt, sizeof(fs->fs_fsmnt)); 154 fs->fs_fsmnt[0] = '/'; 155 bcopy((caddr_t)fs->fs_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname, 156 MNAMELEN); 157 (void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, 158 &size); 159 bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); 160 (void)ext2_statfs(mp, &mp->mnt_stat, td); 161 vfs_unlock(mp); 162 inittodr(fs->s_es->s_wtime); /* this helps to set the time */ 163 return (0); 164} 165#endif 166 167/* 168 * VFS Operations. 169 * 170 * mount system call 171 */ 172static int 173ext2_mount(mp, ndp, td) 174 struct mount *mp; 175 struct nameidata *ndp; 176 struct thread *td; 177{ 178 struct export_args *export; 179 struct vfsoptlist *opts; 180 struct vnode *devvp; 181 struct ext2mount *ump = 0; 182 struct ext2_sb_info *fs; 183 char *path, *fspec; 184 size_t size; 185 int error, flags, len; 186 mode_t accessmode; 187 188 opts = mp->mnt_optnew; 189 190 vfs_getopt(opts, "fspath", (void **)&path, NULL); 191 /* Double-check the length of path.. */ 192 if (strlen(path) >= MAXMNTLEN - 1) 193 return (ENAMETOOLONG); 194 195 fspec = NULL; 196 error = vfs_getopt(opts, "from", (void **)&fspec, &len); 197 if (!error && fspec[len - 1] != '\0') 198 return (EINVAL); 199 200 /* 201 * If updating, check whether changing from read-only to 202 * read/write; if there is no device name, that's all we do. 203 */ 204 if (mp->mnt_flag & MNT_UPDATE) { 205 ump = VFSTOEXT2(mp); 206 fs = ump->um_e2fs; 207 error = 0; 208 if (fs->s_rd_only == 0 && (mp->mnt_flag & MNT_RDONLY)) { 209 flags = WRITECLOSE; 210 if (mp->mnt_flag & MNT_FORCE) 211 flags |= FORCECLOSE; 212 if (vfs_busy(mp, LK_NOWAIT, 0, td)) 213 return (EBUSY); 214 error = ext2_flushfiles(mp, flags, td); 215 vfs_unbusy(mp, td); 216 if (!error && fs->s_wasvalid) { 217 fs->s_es->s_state |= EXT2_VALID_FS; 218 ext2_sbupdate(ump, MNT_WAIT); 219 } 220 fs->s_rd_only = 1; 221 } 222 if (!error && (mp->mnt_flag & MNT_RELOAD)) 223 error = ext2_reload(mp, ndp->ni_cnd.cn_cred, td); 224 if (error) 225 return (error); 226 devvp = ump->um_devvp; 227 if (ext2_check_sb_compat(fs->s_es, devvp->v_rdev, 228 (mp->mnt_kern_flag & MNTK_WANTRDWR) == 0) != 0) 229 return (EPERM); 230 if (fs->s_rd_only && (mp->mnt_kern_flag & MNTK_WANTRDWR)) { 231 /* 232 * If upgrade to read-write by non-root, then verify 233 * that user has necessary permissions on the device. 234 */ 235 if (suser(td)) { 236 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); 237 if ((error = VOP_ACCESS(devvp, VREAD | VWRITE, 238 td->td_ucred, td)) != 0) { 239 VOP_UNLOCK(devvp, 0, td); 240 return (error); 241 } 242 VOP_UNLOCK(devvp, 0, td); 243 } 244 245 if ((fs->s_es->s_state & EXT2_VALID_FS) == 0 || 246 (fs->s_es->s_state & EXT2_ERROR_FS)) { 247 if (mp->mnt_flag & MNT_FORCE) { 248 printf( 249"WARNING: %s was not properly dismounted\n", 250 fs->fs_fsmnt); 251 } else { 252 printf( 253"WARNING: R/W mount of %s denied. Filesystem is not clean - run fsck\n", 254 fs->fs_fsmnt); 255 return (EPERM); 256 } 257 } 258 fs->s_es->s_state &= ~EXT2_VALID_FS; 259 ext2_sbupdate(ump, MNT_WAIT); 260 fs->s_rd_only = 0; 261 } 262 if (fspec == NULL) { 263 error = vfs_getopt(opts, "export", (void **)&export, 264 &len); 265 if (error || len != sizeof(struct export_args)) 266 return (EINVAL); 267 /* Process export requests. */ 268 return (vfs_export(mp, export)); 269 } 270 } 271 /* 272 * Not an update, or updating the name: look up the name 273 * and verify that it refers to a sensible disk device. 274 */ 275 if (fspec == NULL) 276 return (EINVAL); 277 NDINIT(ndp, LOOKUP, FOLLOW, UIO_SYSSPACE, fspec, td); 278 if ((error = namei(ndp)) != 0) 279 return (error); 280 NDFREE(ndp, NDF_ONLY_PNBUF); 281 devvp = ndp->ni_vp; 282 283 if (!vn_isdisk(devvp, &error)) { 284 vrele(devvp); 285 return (error); 286 } 287 288 /* 289 * If mount by non-root, then verify that user has necessary 290 * permissions on the device. 291 */ 292 if (suser(td)) { 293 accessmode = VREAD; 294 if ((mp->mnt_flag & MNT_RDONLY) == 0) 295 accessmode |= VWRITE; 296 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); 297 if ((error = VOP_ACCESS(devvp, accessmode, td->td_ucred, td)) != 0) { 298 vput(devvp); 299 return (error); 300 } 301 VOP_UNLOCK(devvp, 0, td); 302 } 303 304 if ((mp->mnt_flag & MNT_UPDATE) == 0) { 305 error = ext2_mountfs(devvp, mp, td); 306 } else { 307 if (devvp != ump->um_devvp) 308 error = EINVAL; /* needs translation */ 309 else 310 vrele(devvp); 311 } 312 if (error) { 313 vrele(devvp); 314 return (error); 315 } 316 ump = VFSTOEXT2(mp); 317 fs = ump->um_e2fs; 318 /* 319 * Note that this strncpy() is ok because of a check at the start 320 * of ext2_mount(). 321 */ 322 strncpy(fs->fs_fsmnt, path, MAXMNTLEN); 323 fs->fs_fsmnt[MAXMNTLEN - 1] = '\0'; 324 (void)copystr(fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); 325 bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); 326 (void)ext2_statfs(mp, &mp->mnt_stat, td); 327 return (0); 328} 329 330/* 331 * checks that the data in the descriptor blocks make sense 332 * this is taken from ext2/super.c 333 */ 334static int ext2_check_descriptors (struct ext2_sb_info * sb) 335{ 336 int i; 337 int desc_block = 0; 338 unsigned long block = sb->s_es->s_first_data_block; 339 struct ext2_group_desc * gdp = NULL; 340 341 /* ext2_debug ("Checking group descriptors"); */ 342 343 for (i = 0; i < sb->s_groups_count; i++) 344 { 345 /* examine next descriptor block */ 346 if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0) 347 gdp = (struct ext2_group_desc *) 348 sb->s_group_desc[desc_block++]->b_data; 349 if (gdp->bg_block_bitmap < block || 350 gdp->bg_block_bitmap >= block + EXT2_BLOCKS_PER_GROUP(sb)) 351 { 352 printf ("ext2_check_descriptors: " 353 "Block bitmap for group %d" 354 " not in group (block %lu)!\n", 355 i, (unsigned long) gdp->bg_block_bitmap); 356 return 0; 357 } 358 if (gdp->bg_inode_bitmap < block || 359 gdp->bg_inode_bitmap >= block + EXT2_BLOCKS_PER_GROUP(sb)) 360 { 361 printf ("ext2_check_descriptors: " 362 "Inode bitmap for group %d" 363 " not in group (block %lu)!\n", 364 i, (unsigned long) gdp->bg_inode_bitmap); 365 return 0; 366 } 367 if (gdp->bg_inode_table < block || 368 gdp->bg_inode_table + sb->s_itb_per_group >= 369 block + EXT2_BLOCKS_PER_GROUP(sb)) 370 { 371 printf ("ext2_check_descriptors: " 372 "Inode table for group %d" 373 " not in group (block %lu)!\n", 374 i, (unsigned long) gdp->bg_inode_table); 375 return 0; 376 } 377 block += EXT2_BLOCKS_PER_GROUP(sb); 378 gdp++; 379 } 380 return 1; 381} 382 383static int 384ext2_check_sb_compat(es, dev, ronly) 385 struct ext2_super_block *es; 386 dev_t dev; 387 int ronly; 388{ 389 390 if (es->s_magic != EXT2_SUPER_MAGIC) { 391 printf("ext2fs: %s: wrong magic number %#x (expected %#x)\n", 392 devtoname(dev), es->s_magic, EXT2_SUPER_MAGIC); 393 return (1); 394 } 395 if (es->s_rev_level > EXT2_GOOD_OLD_REV) { 396 if (es->s_feature_incompat & ~EXT2_FEATURE_INCOMPAT_SUPP) { 397 printf( 398"WARNING: mount of %s denied due to unsupported optional features\n", 399 devtoname(dev)); 400 return (1); 401 } 402 if (!ronly && 403 (es->s_feature_ro_compat & ~EXT2_FEATURE_RO_COMPAT_SUPP)) { 404 printf( 405"WARNING: R/W mount of %s denied due to unsupported optional features\n", 406 devtoname(dev)); 407 return (1); 408 } 409 } 410 return (0); 411} 412 413/* 414 * this computes the fields of the ext2_sb_info structure from the 415 * data in the ext2_super_block structure read in 416 */ 417static int compute_sb_data(devvp, es, fs) 418 struct vnode * devvp; 419 struct ext2_super_block * es; 420 struct ext2_sb_info * fs; 421{ 422 int db_count, error; 423 int i, j; 424 int logic_sb_block = 1; /* XXX for now */ 425 426#if 1 427#define V(v) 428#else 429#define V(v) printf(#v"= %d\n", fs->v); 430#endif 431 432 fs->s_blocksize = EXT2_MIN_BLOCK_SIZE << es->s_log_block_size; 433 V(s_blocksize) 434 fs->s_bshift = EXT2_MIN_BLOCK_LOG_SIZE + es->s_log_block_size; 435 V(s_bshift) 436 fs->s_fsbtodb = es->s_log_block_size + 1; 437 V(s_fsbtodb) 438 fs->s_qbmask = fs->s_blocksize - 1; 439 V(s_bmask) 440 fs->s_blocksize_bits = EXT2_BLOCK_SIZE_BITS(es); 441 V(s_blocksize_bits) 442 fs->s_frag_size = EXT2_MIN_FRAG_SIZE << es->s_log_frag_size; 443 V(s_frag_size) 444 if (fs->s_frag_size) 445 fs->s_frags_per_block = fs->s_blocksize / fs->s_frag_size; 446 V(s_frags_per_block) 447 fs->s_blocks_per_group = es->s_blocks_per_group; 448 V(s_blocks_per_group) 449 fs->s_frags_per_group = es->s_frags_per_group; 450 V(s_frags_per_group) 451 fs->s_inodes_per_group = es->s_inodes_per_group; 452 V(s_inodes_per_group) 453 fs->s_inodes_per_block = fs->s_blocksize / EXT2_INODE_SIZE; 454 V(s_inodes_per_block) 455 fs->s_itb_per_group = fs->s_inodes_per_group /fs->s_inodes_per_block; 456 V(s_itb_per_group) 457 fs->s_desc_per_block = fs->s_blocksize / sizeof (struct ext2_group_desc); 458 V(s_desc_per_block) 459 /* s_resuid / s_resgid ? */ 460 fs->s_groups_count = (es->s_blocks_count - 461 es->s_first_data_block + 462 EXT2_BLOCKS_PER_GROUP(fs) - 1) / 463 EXT2_BLOCKS_PER_GROUP(fs); 464 V(s_groups_count) 465 db_count = (fs->s_groups_count + EXT2_DESC_PER_BLOCK(fs) - 1) / 466 EXT2_DESC_PER_BLOCK(fs); 467 fs->s_db_per_group = db_count; 468 V(s_db_per_group) 469 470 fs->s_group_desc = bsd_malloc(db_count * sizeof (struct buf *), 471 M_EXT2MNT, M_WAITOK); 472 473 /* adjust logic_sb_block */ 474 if(fs->s_blocksize > SBSIZE) 475 /* Godmar thinks: if the blocksize is greater than 1024, then 476 the superblock is logically part of block zero. 477 */ 478 logic_sb_block = 0; 479 480 for (i = 0; i < db_count; i++) { 481 error = bread(devvp , fsbtodb(fs, logic_sb_block + i + 1), 482 fs->s_blocksize, NOCRED, &fs->s_group_desc[i]); 483 if(error) { 484 for (j = 0; j < i; j++) 485 brelse(fs->s_group_desc[j]); 486 bsd_free(fs->s_group_desc, M_EXT2MNT); 487 printf("EXT2-fs: unable to read group descriptors (%d)\n", error); 488 return EIO; 489 } 490 LCK_BUF(fs->s_group_desc[i]) 491 } 492 if(!ext2_check_descriptors(fs)) { 493 for (j = 0; j < db_count; j++) 494 ULCK_BUF(fs->s_group_desc[j]) 495 bsd_free(fs->s_group_desc, M_EXT2MNT); 496 printf("EXT2-fs: (ext2_check_descriptors failure) " 497 "unable to read group descriptors\n"); 498 return EIO; 499 } 500 501 for (i = 0; i < EXT2_MAX_GROUP_LOADED; i++) { 502 fs->s_inode_bitmap_number[i] = 0; 503 fs->s_inode_bitmap[i] = NULL; 504 fs->s_block_bitmap_number[i] = 0; 505 fs->s_block_bitmap[i] = NULL; 506 } 507 fs->s_loaded_inode_bitmaps = 0; 508 fs->s_loaded_block_bitmaps = 0; 509 return 0; 510} 511 512/* 513 * Reload all incore data for a filesystem (used after running fsck on 514 * the root filesystem and finding things to fix). The filesystem must 515 * be mounted read-only. 516 * 517 * Things to do to update the mount: 518 * 1) invalidate all cached meta-data. 519 * 2) re-read superblock from disk. 520 * 3) re-read summary information from disk. 521 * 4) invalidate all inactive vnodes. 522 * 5) invalidate all cached file data. 523 * 6) re-read inode data for all active vnodes. 524 */ 525static int 526ext2_reload(mp, cred, td) 527 struct mount *mp; 528 struct ucred *cred; 529 struct thread *td; 530{ 531 struct vnode *vp, *nvp, *devvp; 532 struct inode *ip; 533 struct buf *bp; 534 struct ext2_super_block * es; 535 struct ext2_sb_info *fs; 536 int error; 537 538 if ((mp->mnt_flag & MNT_RDONLY) == 0) 539 return (EINVAL); 540 /* 541 * Step 1: invalidate all cached meta-data. 542 */ 543 devvp = VFSTOEXT2(mp)->um_devvp; 544 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); 545 if (vinvalbuf(devvp, 0, cred, td, 0, 0) != 0) 546 panic("ext2_reload: dirty1"); 547 VOP_UNLOCK(devvp, 0, td); 548 549 /* 550 * Step 2: re-read superblock from disk. 551 * constants have been adjusted for ext2 552 */ 553 if ((error = bread(devvp, SBLOCK, SBSIZE, NOCRED, &bp)) != 0) 554 return (error); 555 es = (struct ext2_super_block *)bp->b_data; 556 if (ext2_check_sb_compat(es, devvp->v_rdev, 0) != 0) { 557 brelse(bp); 558 return (EIO); /* XXX needs translation */ 559 } 560 fs = VFSTOEXT2(mp)->um_e2fs; 561 bcopy(bp->b_data, fs->s_es, sizeof(struct ext2_super_block)); 562 563 if((error = compute_sb_data(devvp, es, fs)) != 0) { 564 brelse(bp); 565 return error; 566 } 567#ifdef UNKLAR 568 if (fs->fs_sbsize < SBSIZE) 569 bp->b_flags |= B_INVAL; 570#endif 571 brelse(bp); 572 573loop: 574 MNT_ILOCK(mp); 575 for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist); vp != NULL; vp = nvp) { 576 if (vp->v_mount != mp) { 577 MNT_IUNLOCK(mp); 578 goto loop; 579 } 580 nvp = TAILQ_NEXT(vp, v_nmntvnodes); 581 VI_LOCK(vp); 582 if (vp->v_iflag & VI_XLOCK) { 583 VI_UNLOCK(vp); 584 continue; 585 } 586 MNT_IUNLOCK(mp); 587 /* 588 * Step 4: invalidate all inactive vnodes. 589 */ 590 if (vp->v_usecount == 0) { 591 vgonel(vp, td); 592 goto loop; 593 } 594 /* 595 * Step 5: invalidate all cached file data. 596 */ 597 if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) { 598 goto loop; 599 } 600 if (vinvalbuf(vp, 0, cred, td, 0, 0)) 601 panic("ext2_reload: dirty2"); 602 /* 603 * Step 6: re-read inode data for all active vnodes. 604 */ 605 ip = VTOI(vp); 606 error = 607 bread(devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), 608 (int)fs->s_blocksize, NOCRED, &bp); 609 if (error) { 610 VOP_UNLOCK(vp, 0, td); 611 vrele(vp); 612 return (error); 613 } 614 ext2_ei2i((struct ext2_inode *) ((char *)bp->b_data + 615 EXT2_INODE_SIZE * ino_to_fsbo(fs, ip->i_number)), ip); 616 brelse(bp); 617 VOP_UNLOCK(vp, 0, td); 618 vrele(vp); 619 MNT_ILOCK(mp); 620 } 621 MNT_IUNLOCK(mp); 622 return (0); 623} 624 625/* 626 * Common code for mount and mountroot 627 */ 628static int 629ext2_mountfs(devvp, mp, td) 630 struct vnode *devvp; 631 struct mount *mp; 632 struct thread *td; 633{ 634 struct ext2mount *ump; 635 struct buf *bp; 636 struct ext2_sb_info *fs; 637 struct ext2_super_block * es; 638 dev_t dev = devvp->v_rdev; 639 int error; 640 int ronly; 641 642 /* 643 * Disallow multiple mounts of the same device. 644 * Disallow mounting of a device that is currently in use 645 * (except for root, which might share swap device for miniroot). 646 * Flush out any old buffers remaining from a previous use. 647 */ 648 if ((error = vfs_mountedon(devvp)) != 0) 649 return (error); 650 if (vcount(devvp) > 1 && devvp != rootvp) 651 return (EBUSY); 652 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); 653 error = vinvalbuf(devvp, V_SAVE, td->td_ucred, td, 0, 0); 654 if (error) { 655 VOP_UNLOCK(devvp, 0, td); 656 return (error); 657 } 658#ifdef READONLY 659/* turn on this to force it to be read-only */ 660 mp->mnt_flag |= MNT_RDONLY; 661#endif 662 663 ronly = (mp->mnt_flag & MNT_RDONLY) != 0; 664 /* 665 * XXX: open the device with read and write access even if only 666 * read access is needed now. Write access is needed if the 667 * filesystem is ever mounted read/write, and we don't change the 668 * access mode for remounts. 669 */ 670#ifdef notyet 671 error = VOP_OPEN(devvp, ronly ? FREAD : FREAD | FWRITE, FSCRED, td, -1); 672#else 673 error = VOP_OPEN(devvp, FREAD | FWRITE, FSCRED, td, -1); 674#endif 675 VOP_UNLOCK(devvp, 0, td); 676 if (error) 677 return (error); 678 if (devvp->v_rdev->si_iosize_max != 0) 679 mp->mnt_iosize_max = devvp->v_rdev->si_iosize_max; 680 if (mp->mnt_iosize_max > MAXPHYS) 681 mp->mnt_iosize_max = MAXPHYS; 682 683 bp = NULL; 684 ump = NULL; 685 if ((error = bread(devvp, SBLOCK, SBSIZE, NOCRED, &bp)) != 0) 686 goto out; 687 es = (struct ext2_super_block *)bp->b_data; 688 if (ext2_check_sb_compat(es, dev, ronly) != 0) { 689 error = EINVAL; /* XXX needs translation */ 690 goto out; 691 } 692 if ((es->s_state & EXT2_VALID_FS) == 0 || 693 (es->s_state & EXT2_ERROR_FS)) { 694 if (ronly || (mp->mnt_flag & MNT_FORCE)) { 695 printf( 696"WARNING: Filesystem was not properly dismounted\n"); 697 } else { 698 printf( 699"WARNING: R/W mount denied. Filesystem is not clean - run fsck\n"); 700 error = EPERM; 701 goto out; 702 } 703 } 704 ump = bsd_malloc(sizeof *ump, M_EXT2MNT, M_WAITOK); 705 bzero((caddr_t)ump, sizeof *ump); 706 /* I don't know whether this is the right strategy. Note that 707 we dynamically allocate both an ext2_sb_info and an ext2_super_block 708 while Linux keeps the super block in a locked buffer 709 */ 710 ump->um_e2fs = bsd_malloc(sizeof(struct ext2_sb_info), 711 M_EXT2MNT, M_WAITOK); 712 ump->um_e2fs->s_es = bsd_malloc(sizeof(struct ext2_super_block), 713 M_EXT2MNT, M_WAITOK); 714 bcopy(es, ump->um_e2fs->s_es, (u_int)sizeof(struct ext2_super_block)); 715 if ((error = compute_sb_data(devvp, ump->um_e2fs->s_es, ump->um_e2fs))) 716 goto out; 717 /* 718 * We don't free the group descriptors allocated by compute_sb_data() 719 * until ext2_unmount(). This is OK since the mount will succeed. 720 */ 721 brelse(bp); 722 bp = NULL; 723 fs = ump->um_e2fs; 724 fs->s_rd_only = ronly; /* ronly is set according to mnt_flags */ 725 /* if the fs is not mounted read-only, make sure the super block is 726 always written back on a sync() 727 */ 728 fs->s_wasvalid = fs->s_es->s_state & EXT2_VALID_FS ? 1 : 0; 729 if (ronly == 0) { 730 fs->s_dirt = 1; /* mark it modified */ 731 fs->s_es->s_state &= ~EXT2_VALID_FS; /* set fs invalid */ 732 } 733 mp->mnt_data = (qaddr_t)ump; 734 mp->mnt_stat.f_fsid.val[0] = dev2udev(dev); 735 mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; 736 mp->mnt_maxsymlinklen = EXT2_MAXSYMLINKLEN; 737 mp->mnt_flag |= MNT_LOCAL; 738 ump->um_mountp = mp; 739 ump->um_dev = dev; 740 ump->um_devvp = devvp; 741 /* setting those two parameters allowed us to use 742 ufs_bmap w/o changse ! 743 */ 744 ump->um_nindir = EXT2_ADDR_PER_BLOCK(fs); 745 ump->um_bptrtodb = fs->s_es->s_log_block_size + 1; 746 ump->um_seqinc = EXT2_FRAGS_PER_BLOCK(fs); 747 devvp->v_rdev->si_mountpoint = mp; 748 if (ronly == 0) 749 ext2_sbupdate(ump, MNT_WAIT); 750 return (0); 751out: 752 if (bp) 753 brelse(bp); 754 /* XXX: see comment above VOP_OPEN. */ 755#ifdef notyet 756 (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD | FWRITE, NOCRED, td); 757#else 758 (void)VOP_CLOSE(devvp, FREAD | FWRITE, NOCRED, td); 759#endif 760 if (ump) { 761 bsd_free(ump->um_e2fs->s_es, M_EXT2MNT); 762 bsd_free(ump->um_e2fs, M_EXT2MNT); 763 bsd_free(ump, M_EXT2MNT); 764 mp->mnt_data = (qaddr_t)0; 765 } 766 return (error); 767} 768 769/* 770 * unmount system call 771 */ 772static int 773ext2_unmount(mp, mntflags, td) 774 struct mount *mp; 775 int mntflags; 776 struct thread *td; 777{ 778 struct ext2mount *ump; 779 struct ext2_sb_info *fs; 780 int error, flags, ronly, i; 781 782 flags = 0; 783 if (mntflags & MNT_FORCE) { 784 if (mp->mnt_flag & MNT_ROOTFS) 785 return (EINVAL); 786 flags |= FORCECLOSE; 787 } 788 if ((error = ext2_flushfiles(mp, flags, td)) != 0) 789 return (error); 790 ump = VFSTOEXT2(mp); 791 fs = ump->um_e2fs; 792 ronly = fs->s_rd_only; 793 if (ronly == 0) { 794 if (fs->s_wasvalid) 795 fs->s_es->s_state |= EXT2_VALID_FS; 796 ext2_sbupdate(ump, MNT_WAIT); 797 } 798 799 /* release buffers containing group descriptors */ 800 for(i = 0; i < fs->s_db_per_group; i++) 801 ULCK_BUF(fs->s_group_desc[i]) 802 bsd_free(fs->s_group_desc, M_EXT2MNT); 803 804 /* release cached inode/block bitmaps */ 805 for (i = 0; i < EXT2_MAX_GROUP_LOADED; i++) 806 if (fs->s_inode_bitmap[i]) 807 ULCK_BUF(fs->s_inode_bitmap[i]) 808 809 for (i = 0; i < EXT2_MAX_GROUP_LOADED; i++) 810 if (fs->s_block_bitmap[i]) 811 ULCK_BUF(fs->s_block_bitmap[i]) 812 813 ump->um_devvp->v_rdev->si_mountpoint = NULL; 814 /* XXX: see comment above VOP_OPEN. */ 815#ifdef notyet 816 error = VOP_CLOSE(ump->um_devvp, ronly ? FREAD : FREAD | FWRITE, 817 NOCRED, td); 818#else 819 error = VOP_CLOSE(ump->um_devvp, FREAD | FWRITE, NOCRED, td); 820#endif 821 vrele(ump->um_devvp); 822 bsd_free(fs->s_es, M_EXT2MNT); 823 bsd_free(fs, M_EXT2MNT); 824 bsd_free(ump, M_EXT2MNT); 825 mp->mnt_data = (qaddr_t)0; 826 mp->mnt_flag &= ~MNT_LOCAL; 827 return (error); 828} 829 830/* 831 * Flush out all the files in a filesystem. 832 */ 833static int 834ext2_flushfiles(mp, flags, td) 835 struct mount *mp; 836 int flags; 837 struct thread *td; 838{ 839 int error; 840 841 error = vflush(mp, 0, flags); 842 return (error); 843} 844 845/* 846 * Get file system statistics. 847 * taken from ext2/super.c ext2_statfs 848 */ 849static int 850ext2_statfs(mp, sbp, td) 851 struct mount *mp; 852 struct statfs *sbp; 853 struct thread *td; 854{ 855 unsigned long overhead; 856 struct ext2mount *ump; 857 struct ext2_sb_info *fs; 858 struct ext2_super_block *es; 859 int i, nsb; 860 861 ump = VFSTOEXT2(mp); 862 fs = ump->um_e2fs; 863 es = fs->s_es; 864 865 if (es->s_magic != EXT2_SUPER_MAGIC) 866 panic("ext2_statfs - magic number spoiled"); 867 868 /* 869 * Compute the overhead (FS structures) 870 */ 871 if (es->s_feature_ro_compat & EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER) { 872 nsb = 0; 873 for (i = 0 ; i < fs->s_groups_count; i++) 874 if (ext2_group_sparse(i)) 875 nsb++; 876 } else 877 nsb = fs->s_groups_count; 878 overhead = es->s_first_data_block + 879 /* Superblocks and block group descriptors: */ 880 nsb * (1 + fs->s_db_per_group) + 881 /* Inode bitmap, block bitmap, and inode table: */ 882 fs->s_groups_count * (1 + 1 + fs->s_itb_per_group); 883 884 sbp->f_bsize = EXT2_FRAG_SIZE(fs); 885 sbp->f_iosize = EXT2_BLOCK_SIZE(fs); 886 sbp->f_blocks = es->s_blocks_count - overhead; 887 sbp->f_bfree = es->s_free_blocks_count; 888 sbp->f_bavail = sbp->f_bfree - es->s_r_blocks_count; 889 sbp->f_files = es->s_inodes_count; 890 sbp->f_ffree = es->s_free_inodes_count; 891 if (sbp != &mp->mnt_stat) { 892 sbp->f_type = mp->mnt_vfc->vfc_typenum; 893 bcopy((caddr_t)mp->mnt_stat.f_mntonname, 894 (caddr_t)&sbp->f_mntonname[0], MNAMELEN); 895 bcopy((caddr_t)mp->mnt_stat.f_mntfromname, 896 (caddr_t)&sbp->f_mntfromname[0], MNAMELEN); 897 } 898 return (0); 899} 900 901/* 902 * Go through the disk queues to initiate sandbagged IO; 903 * go through the inodes to write those that have been modified; 904 * initiate the writing of the super block if it has been modified. 905 * 906 * Note: we are always called with the filesystem marked `MPBUSY'. 907 */ 908static int 909ext2_sync(mp, waitfor, cred, td) 910 struct mount *mp; 911 int waitfor; 912 struct ucred *cred; 913 struct thread *td; 914{ 915 struct vnode *nvp, *vp; 916 struct inode *ip; 917 struct ext2mount *ump = VFSTOEXT2(mp); 918 struct ext2_sb_info *fs; 919 int error, allerror = 0; 920 921 fs = ump->um_e2fs; 922 if (fs->s_dirt != 0 && fs->s_rd_only != 0) { /* XXX */ 923 printf("fs = %s\n", fs->fs_fsmnt); 924 panic("ext2_sync: rofs mod"); 925 } 926 /* 927 * Write back each (modified) inode. 928 */ 929 MNT_ILOCK(mp); 930loop: 931 for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist); vp != NULL; vp = nvp) { 932 /* 933 * If the vnode that we are about to sync is no longer 934 * associated with this mount point, start over. 935 */ 936 if (vp->v_mount != mp) 937 goto loop; 938 nvp = TAILQ_NEXT(vp, v_nmntvnodes); 939 VI_LOCK(vp); 940 if (vp->v_iflag & VI_XLOCK) { 941 VI_UNLOCK(vp); 942 continue; 943 } 944 MNT_IUNLOCK(mp); 945 ip = VTOI(vp); 946 if (vp->v_type == VNON || 947 ((ip->i_flag & 948 (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 && 949 (TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY))) { 950 VI_UNLOCK(vp); 951 MNT_ILOCK(mp); 952 continue; 953 } 954 error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, td); 955 if (error) { 956 MNT_ILOCK(mp); 957 if (error == ENOENT) 958 goto loop; 959 continue; 960 } 961 if ((error = VOP_FSYNC(vp, cred, waitfor, td)) != 0) 962 allerror = error; 963 VOP_UNLOCK(vp, 0, td); 964 vrele(vp); 965 MNT_ILOCK(mp); 966 } 967 MNT_IUNLOCK(mp); 968 /* 969 * Force stale file system control information to be flushed. 970 */ 971 if (waitfor != MNT_LAZY) { 972 vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, td); 973 if ((error = VOP_FSYNC(ump->um_devvp, cred, waitfor, td)) != 0) 974 allerror = error; 975 VOP_UNLOCK(ump->um_devvp, 0, td); 976 } 977 /* 978 * Write back modified superblock. 979 */ 980 if (fs->s_dirt != 0) { 981 fs->s_dirt = 0; 982 fs->s_es->s_wtime = time_second; 983 if ((error = ext2_sbupdate(ump, waitfor)) != 0) 984 allerror = error; 985 } 986 return (allerror); 987} 988 989/* 990 * Look up an EXT2FS dinode number to find its incore vnode, otherwise read it 991 * in from disk. If it is in core, wait for the lock bit to clear, then 992 * return the inode locked. Detection and handling of mount points must be 993 * done by the calling routine. 994 */ 995static int 996ext2_vget(mp, ino, flags, vpp) 997 struct mount *mp; 998 ino_t ino; 999 int flags; 1000 struct vnode **vpp; 1001{ 1002 struct ext2_sb_info *fs; 1003 struct inode *ip; 1004 struct ext2mount *ump; 1005 struct buf *bp; 1006 struct vnode *vp; 1007 dev_t dev; 1008 int i, error; 1009 int used_blocks; 1010 1011 ump = VFSTOEXT2(mp); 1012 dev = ump->um_dev; 1013restart: 1014 if ((error = ext2_ihashget(dev, ino, flags, vpp)) != 0) 1015 return (error); 1016 if (*vpp != NULL) 1017 return (0); 1018 1019 /* 1020 * Lock out the creation of new entries in the FFS hash table in 1021 * case getnewvnode() or MALLOC() blocks, otherwise a duplicate 1022 * may occur! 1023 */ 1024 if (ext2fs_inode_hash_lock) { 1025 while (ext2fs_inode_hash_lock) { 1026 ext2fs_inode_hash_lock = -1; 1027 tsleep(&ext2fs_inode_hash_lock, PVM, "e2vget", 0); 1028 } 1029 goto restart; 1030 } 1031 ext2fs_inode_hash_lock = 1; 1032 1033 /* 1034 * If this MALLOC() is performed after the getnewvnode() 1035 * it might block, leaving a vnode with a NULL v_data to be 1036 * found by ext2_sync() if a sync happens to fire right then, 1037 * which will cause a panic because ext2_sync() blindly 1038 * dereferences vp->v_data (as well it should). 1039 */ 1040 MALLOC(ip, struct inode *, sizeof(struct inode), M_EXT2NODE, M_WAITOK); 1041 1042 /* Allocate a new vnode/inode. */ 1043 if ((error = getnewvnode("ext2fs", mp, ext2_vnodeop_p, &vp)) != 0) { 1044 if (ext2fs_inode_hash_lock < 0) 1045 wakeup(&ext2fs_inode_hash_lock); 1046 ext2fs_inode_hash_lock = 0; 1047 *vpp = NULL; 1048 FREE(ip, M_EXT2NODE); 1049 return (error); 1050 } 1051 bzero((caddr_t)ip, sizeof(struct inode)); 1052 vp->v_data = ip; 1053 ip->i_vnode = vp; 1054 ip->i_e2fs = fs = ump->um_e2fs; 1055 ip->i_dev = dev; 1056 ip->i_number = ino; 1057 /* 1058 * Put it onto its hash chain and lock it so that other requests for 1059 * this inode will block if they arrive while we are sleeping waiting 1060 * for old data structures to be purged or for the contents of the 1061 * disk portion of this inode to be read. 1062 */ 1063 ext2_ihashins(ip); 1064 1065 if (ext2fs_inode_hash_lock < 0) 1066 wakeup(&ext2fs_inode_hash_lock); 1067 ext2fs_inode_hash_lock = 0; 1068 1069 /* Read in the disk contents for the inode, copy into the inode. */ 1070#if 0 1071printf("ext2_vget(%d) dbn= %d ", ino, fsbtodb(fs, ino_to_fsba(fs, ino))); 1072#endif 1073 if ((error = bread(ump->um_devvp, fsbtodb(fs, ino_to_fsba(fs, ino)), 1074 (int)fs->s_blocksize, NOCRED, &bp)) != 0) { 1075 /* 1076 * The inode does not contain anything useful, so it would 1077 * be misleading to leave it on its hash chain. With mode 1078 * still zero, it will be unlinked and returned to the free 1079 * list by vput(). 1080 */ 1081 vput(vp); 1082 brelse(bp); 1083 *vpp = NULL; 1084 return (error); 1085 } 1086 /* convert ext2 inode to dinode */ 1087 ext2_ei2i((struct ext2_inode *) ((char *)bp->b_data + EXT2_INODE_SIZE * 1088 ino_to_fsbo(fs, ino)), ip); 1089 ip->i_block_group = ino_to_cg(fs, ino); 1090 ip->i_next_alloc_block = 0; 1091 ip->i_next_alloc_goal = 0; 1092 ip->i_prealloc_count = 0; 1093 ip->i_prealloc_block = 0; 1094 /* now we want to make sure that block pointers for unused 1095 blocks are zeroed out - ext2_balloc depends on this 1096 although for regular files and directories only 1097 */ 1098 if(S_ISDIR(ip->i_mode) || S_ISREG(ip->i_mode)) { 1099 used_blocks = (ip->i_size+fs->s_blocksize-1) / fs->s_blocksize; 1100 for(i = used_blocks; i < EXT2_NDIR_BLOCKS; i++) 1101 ip->i_db[i] = 0; 1102 } 1103/* 1104 ext2_print_inode(ip); 1105*/ 1106 brelse(bp); 1107 1108 /* 1109 * Initialize the vnode from the inode, check for aliases. 1110 * Note that the underlying vnode may have changed. 1111 */ 1112 if ((error = ext2_vinit(mp, ext2_specop_p, ext2_fifoop_p, &vp)) != 0) { 1113 vput(vp); 1114 *vpp = NULL; 1115 return (error); 1116 } 1117 /* 1118 * Finish inode initialization now that aliasing has been resolved. 1119 */ 1120 ip->i_devvp = ump->um_devvp; 1121 VREF(ip->i_devvp); 1122 /* 1123 * Set up a generation number for this inode if it does not 1124 * already have one. This should only happen on old filesystems. 1125 */ 1126 if (ip->i_gen == 0) { 1127 ip->i_gen = random() / 2 + 1; 1128 if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) 1129 ip->i_flag |= IN_MODIFIED; 1130 } 1131 *vpp = vp; 1132 return (0); 1133} 1134 1135/* 1136 * File handle to vnode 1137 * 1138 * Have to be really careful about stale file handles: 1139 * - check that the inode number is valid 1140 * - call ext2_vget() to get the locked inode 1141 * - check for an unallocated inode (i_mode == 0) 1142 * - check that the given client host has export rights and return 1143 * those rights via. exflagsp and credanonp 1144 */ 1145static int 1146ext2_fhtovp(mp, fhp, vpp) 1147 struct mount *mp; 1148 struct fid *fhp; 1149 struct vnode **vpp; 1150{ 1151 struct inode *ip; 1152 struct ufid *ufhp; 1153 struct vnode *nvp; 1154 struct ext2_sb_info *fs; 1155 int error; 1156 1157 ufhp = (struct ufid *)fhp; 1158 fs = VFSTOEXT2(mp)->um_e2fs; 1159 if (ufhp->ufid_ino < ROOTINO || 1160 ufhp->ufid_ino > fs->s_groups_count * fs->s_es->s_inodes_per_group) 1161 return (ESTALE); 1162 1163 error = VFS_VGET(mp, ufhp->ufid_ino, LK_EXCLUSIVE, &nvp); 1164 if (error) { 1165 *vpp = NULLVP; 1166 return (error); 1167 } 1168 ip = VTOI(nvp); 1169 if (ip->i_mode == 0 || 1170 ip->i_gen != ufhp->ufid_gen || ip->i_nlink <= 0) { 1171 vput(nvp); 1172 *vpp = NULLVP; 1173 return (ESTALE); 1174 } 1175 *vpp = nvp; 1176 return (0); 1177} 1178 1179/* 1180 * Vnode pointer to File handle 1181 */ 1182/* ARGSUSED */ 1183static int 1184ext2_vptofh(vp, fhp) 1185 struct vnode *vp; 1186 struct fid *fhp; 1187{ 1188 struct inode *ip; 1189 struct ufid *ufhp; 1190 1191 ip = VTOI(vp); 1192 ufhp = (struct ufid *)fhp; 1193 ufhp->ufid_len = sizeof(struct ufid); 1194 ufhp->ufid_ino = ip->i_number; 1195 ufhp->ufid_gen = ip->i_gen; 1196 return (0); 1197} 1198 1199/* 1200 * Write a superblock and associated information back to disk. 1201 */ 1202static int 1203ext2_sbupdate(mp, waitfor) 1204 struct ext2mount *mp; 1205 int waitfor; 1206{ 1207 struct ext2_sb_info *fs = mp->um_e2fs; 1208 struct ext2_super_block *es = fs->s_es; 1209 struct buf *bp; 1210 int error = 0; 1211/* 1212printf("\nupdating superblock, waitfor=%s\n", waitfor == MNT_WAIT ? "yes":"no"); 1213*/ 1214 bp = getblk(mp->um_devvp, SBLOCK, SBSIZE, 0, 0, 0); 1215 bcopy((caddr_t)es, bp->b_data, (u_int)sizeof(struct ext2_super_block)); 1216 if (waitfor == MNT_WAIT) 1217 error = bwrite(bp); 1218 else 1219 bawrite(bp); 1220 1221 /* 1222 * The buffers for group descriptors, inode bitmaps and block bitmaps 1223 * are not busy at this point and are (hopefully) written by the 1224 * usual sync mechanism. No need to write them here 1225 */ 1226 1227 return (error); 1228} 1229 1230/* 1231 * Return the root of a filesystem. 1232 */ 1233static int 1234ext2_root(mp, vpp) 1235 struct mount *mp; 1236 struct vnode **vpp; 1237{ 1238 struct vnode *nvp; 1239 int error; 1240 1241 error = VFS_VGET(mp, (ino_t)ROOTINO, LK_EXCLUSIVE, &nvp); 1242 if (error) 1243 return (error); 1244 *vpp = nvp; 1245 return (0); 1246} 1247 1248static int 1249ext2_init(struct vfsconf *vfsp) 1250{ 1251 1252 ext2_ihashinit(); 1253 return (0); 1254} 1255 1256static int 1257ext2_uninit(struct vfsconf *vfsp) 1258{ 1259 1260 ext2_ihashuninit(); 1261 return (0); 1262} 1263