2 * modified for EXT2FS support in Lites 1.1
4 * Aug 1995, Godmar Back (gback@cs.utah.edu)
5 * University of Utah, Department of Computer Science
8 * SPDX-License-Identifier: BSD-3-Clause
10 * Copyright (c) 1989, 1991, 1993, 1994
11 * The Regents of the University of California. All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * @(#)ffs_vfsops.c 8.8 (Berkeley) 4/18/94
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/namei.h>
46 #include <sys/kernel.h>
47 #include <sys/vnode.h>
48 #include <sys/mount.h>
52 #include <sys/endian.h>
53 #include <sys/fcntl.h>
54 #include <sys/malloc.h>
57 #include <sys/mutex.h>
59 #include <geom/geom.h>
60 #include <geom/geom_vfs.h>
62 #include <fs/ext2fs/fs.h>
63 #include <fs/ext2fs/ext2_mount.h>
64 #include <fs/ext2fs/inode.h>
66 #include <fs/ext2fs/ext2fs.h>
67 #include <fs/ext2fs/ext2_dinode.h>
68 #include <fs/ext2fs/ext2_extern.h>
69 #include <fs/ext2fs/ext2_extents.h>
71 SDT_PROVIDER_DECLARE(ext2fs);
74 * arg0: verbosity. Higher numbers give more verbose messages
75 * arg1: Textual message
77 SDT_PROBE_DEFINE2(ext2fs, , vfsops, trace, "int", "char*");
78 SDT_PROBE_DEFINE2(ext2fs, , vfsops, ext2_cg_validate_error, "char*", "int");
79 SDT_PROBE_DEFINE1(ext2fs, , vfsops, ext2_compute_sb_data_error, "char*");
81 static int ext2_flushfiles(struct mount *mp, int flags, struct thread *td);
82 static int ext2_mountfs(struct vnode *, struct mount *);
83 static int ext2_reload(struct mount *mp, struct thread *td);
84 static int ext2_sbupdate(struct ext2mount *, int);
85 static int ext2_cgupdate(struct ext2mount *, int);
86 static vfs_unmount_t ext2_unmount;
87 static vfs_root_t ext2_root;
88 static vfs_statfs_t ext2_statfs;
89 static vfs_sync_t ext2_sync;
90 static vfs_vget_t ext2_vget;
91 static vfs_fhtovp_t ext2_fhtovp;
92 static vfs_mount_t ext2_mount;
94 MALLOC_DEFINE(M_EXT2NODE, "ext2_node", "EXT2 vnode private part");
95 static MALLOC_DEFINE(M_EXT2MNT, "ext2_mount", "EXT2 mount structure");
97 static struct vfsops ext2fs_vfsops = {
98 .vfs_fhtovp = ext2_fhtovp,
99 .vfs_mount = ext2_mount,
100 .vfs_root = ext2_root, /* root inode via vget */
101 .vfs_statfs = ext2_statfs,
102 .vfs_sync = ext2_sync,
103 .vfs_unmount = ext2_unmount,
104 .vfs_vget = ext2_vget,
107 VFS_SET(ext2fs_vfsops, ext2fs, 0);
109 static int ext2_check_sb_compat(struct ext2fs *es, struct cdev *dev,
111 static int ext2_compute_sb_data(struct vnode * devvp,
112 struct ext2fs * es, struct m_ext2fs * fs);
114 static const char *ext2_opts[] = { "acls", "async", "noatime", "noclusterr",
115 "noclusterw", "noexec", "export", "force", "from", "multilabel",
116 "suiddir", "nosymfollow", "sync", "union", NULL };
124 ext2_mount(struct mount *mp)
126 struct vfsoptlist *opts;
129 struct ext2mount *ump = NULL;
131 struct nameidata nd, *ndp = &nd;
134 int error, flags, len;
137 opts = mp->mnt_optnew;
139 if (vfs_filteropt(opts, ext2_opts))
142 vfs_getopt(opts, "fspath", (void **)&path, NULL);
143 /* Double-check the length of path.. */
144 if (strlen(path) >= MAXMNTLEN)
145 return (ENAMETOOLONG);
148 error = vfs_getopt(opts, "from", (void **)&fspec, &len);
149 if (!error && fspec[len - 1] != '\0')
153 * If updating, check whether changing from read-only to
154 * read/write; if there is no device name, that's all we do.
156 if (mp->mnt_flag & MNT_UPDATE) {
160 if (fs->e2fs_ronly == 0 &&
161 vfs_flagopt(opts, "ro", NULL, 0)) {
162 error = VFS_SYNC(mp, MNT_WAIT);
166 if (mp->mnt_flag & MNT_FORCE)
168 error = ext2_flushfiles(mp, flags, td);
169 if (error == 0 && fs->e2fs_wasvalid &&
170 ext2_cgupdate(ump, MNT_WAIT) == 0) {
171 fs->e2fs->e2fs_state =
172 htole16((le16toh(fs->e2fs->e2fs_state) |
174 ext2_sbupdate(ump, MNT_WAIT);
177 vfs_flagopt(opts, "ro", &mp->mnt_flag, MNT_RDONLY);
179 g_access(ump->um_cp, 0, -1, 0);
182 if (!error && (mp->mnt_flag & MNT_RELOAD))
183 error = ext2_reload(mp, td);
186 devvp = ump->um_devvp;
187 if (fs->e2fs_ronly && !vfs_flagopt(opts, "ro", NULL, 0)) {
188 if (ext2_check_sb_compat(fs->e2fs, devvp->v_rdev, 0))
192 * If upgrade to read-write by non-root, then verify
193 * that user has necessary permissions on the device.
195 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
196 error = VOP_ACCESS(devvp, VREAD | VWRITE,
199 error = priv_check(td, PRIV_VFS_MOUNT_PERM);
206 error = g_access(ump->um_cp, 0, 1, 0);
211 if ((le16toh(fs->e2fs->e2fs_state) & E2FS_ISCLEAN) == 0 ||
212 (le16toh(fs->e2fs->e2fs_state) & E2FS_ERRORS)) {
213 if (mp->mnt_flag & MNT_FORCE) {
215 "WARNING: %s was not properly dismounted\n", fs->e2fs_fsmnt);
218 "WARNING: R/W mount of %s denied. Filesystem is not clean - run fsck\n",
223 fs->e2fs->e2fs_state =
224 htole16(le16toh(fs->e2fs->e2fs_state) & ~E2FS_ISCLEAN);
225 (void)ext2_cgupdate(ump, MNT_WAIT);
228 mp->mnt_flag &= ~MNT_RDONLY;
231 if (vfs_flagopt(opts, "export", NULL, 0)) {
232 /* Process export requests in vfs_mount.c. */
238 * Not an update, or updating the name: look up the name
239 * and verify that it refers to a sensible disk device.
243 NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, fspec);
244 if ((error = namei(ndp)) != 0)
249 if (!vn_isdisk_error(devvp, &error)) {
255 * If mount by non-root, then verify that user has necessary
256 * permissions on the device.
258 * XXXRW: VOP_ACCESS() enough?
261 if ((mp->mnt_flag & MNT_RDONLY) == 0)
263 error = VOP_ACCESS(devvp, accmode, td->td_ucred, td);
265 error = priv_check(td, PRIV_VFS_MOUNT_PERM);
271 if ((mp->mnt_flag & MNT_UPDATE) == 0) {
272 error = ext2_mountfs(devvp, mp);
274 if (devvp != ump->um_devvp) {
276 return (EINVAL); /* needs translation */
288 * Note that this strncpy() is ok because of a check at the start
291 strncpy(fs->e2fs_fsmnt, path, MAXMNTLEN);
292 fs->e2fs_fsmnt[MAXMNTLEN - 1] = '\0';
293 vfs_mountedfrom(mp, fspec);
298 ext2_check_sb_compat(struct ext2fs *es, struct cdev *dev, int ronly)
302 if (le16toh(es->e2fs_magic) != E2FS_MAGIC) {
303 printf("ext2fs: %s: wrong magic number %#x (expected %#x)\n",
304 devtoname(dev), le16toh(es->e2fs_magic), E2FS_MAGIC);
307 if (le32toh(es->e2fs_rev) > E2FS_REV0) {
308 mask = le32toh(es->e2fs_features_incompat) & ~(EXT2F_INCOMPAT_SUPP);
310 printf("WARNING: mount of %s denied due to "
311 "unsupported optional features:\n", devtoname(dev));
313 i < sizeof(incompat)/sizeof(struct ext2_feature);
315 if (mask & incompat[i].mask)
316 printf("%s ", incompat[i].name);
320 mask = le32toh(es->e2fs_features_rocompat) & ~EXT2F_ROCOMPAT_SUPP;
321 if (!ronly && mask) {
322 printf("WARNING: R/W mount of %s denied due to "
323 "unsupported optional features:\n", devtoname(dev));
325 i < sizeof(ro_compat)/sizeof(struct ext2_feature);
327 if (mask & ro_compat[i].mask)
328 printf("%s ", ro_compat[i].name);
337 ext2_cg_location(struct m_ext2fs *fs, int number)
339 int cg, descpb, logical_sb, has_super = 0;
342 * Adjust logical superblock block number.
343 * Godmar thinks: if the blocksize is greater than 1024, then
344 * the superblock is logically part of block zero.
346 logical_sb = fs->e2fs_bsize > SBSIZE ? 0 : 1;
348 if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_META_BG) ||
349 number < le32toh(fs->e2fs->e3fs_first_meta_bg))
350 return (logical_sb + number + 1);
352 if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_64BIT))
353 descpb = fs->e2fs_bsize / sizeof(struct ext2_gd);
355 descpb = fs->e2fs_bsize / E2FS_REV0_GD_SIZE;
357 cg = descpb * number;
359 if (ext2_cg_has_sb(fs, cg))
362 return (has_super + cg * (e4fs_daddr_t)EXT2_BLOCKS_PER_GROUP(fs) +
363 le32toh(fs->e2fs->e2fs_first_dblock));
367 ext2_cg_validate(struct m_ext2fs *fs)
372 uint64_t first_block, last_block, last_cg_block;
374 unsigned int i, cg_count;
376 first_block = le32toh(fs->e2fs->e2fs_first_dblock);
377 last_cg_block = ext2_cg_number_gdb(fs, 0);
378 cg_count = fs->e2fs_gcount;
380 for (i = 0; i < fs->e2fs_gcount; i++) {
381 gd = &fs->e2fs_gd[i];
383 if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG) ||
384 i == fs->e2fs_gcount - 1) {
385 last_block = fs->e2fs_bcount - 1;
387 last_block = first_block +
388 (EXT2_BLOCKS_PER_GROUP(fs) - 1);
391 if ((cg_count == fs->e2fs_gcount) &&
392 !(le16toh(gd->ext4bgd_flags) & EXT2_BG_INODE_ZEROED))
395 b_bitmap = e2fs_gd_get_b_bitmap(gd);
397 SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
398 "block bitmap is zero", i);
401 if (b_bitmap <= last_cg_block) {
402 SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
403 "block bitmap overlaps gds", i);
406 if (b_bitmap < first_block || b_bitmap > last_block) {
407 SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
408 "block bitmap not in group", i);
412 i_bitmap = e2fs_gd_get_i_bitmap(gd);
414 SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
415 "inode bitmap is zero", i);
418 if (i_bitmap <= last_cg_block) {
419 SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
420 "inode bitmap overlaps gds", i);
423 if (i_bitmap < first_block || i_bitmap > last_block) {
424 SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
425 "inode bitmap not in group blk", i);
429 i_tables = e2fs_gd_get_i_tables(gd);
431 SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
432 "inode table is zero", i);
435 if (i_tables <= last_cg_block) {
436 SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
437 "inode tables overlaps gds", i);
440 if (i_tables < first_block ||
441 i_tables + fs->e2fs_itpg - 1 > last_block) {
442 SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
443 "inode tables not in group blk", i);
447 if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG))
448 first_block += EXT2_BLOCKS_PER_GROUP(fs);
455 * This computes the fields of the m_ext2fs structure from the
456 * data in the ext2fs structure read in.
459 ext2_compute_sb_data(struct vnode *devvp, struct ext2fs *es,
463 uint32_t e2fs_descpb, e2fs_gdbcount_alloc;
468 /* Check checksum features */
469 if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) &&
470 EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) {
471 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
472 "incorrect checksum features combination");
476 /* Precompute checksum seed for all metadata */
477 ext2_sb_csum_set_seed(fs);
479 /* Verify sb csum if possible */
480 if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) {
481 error = ext2_sb_csum_verify(fs);
487 /* Check for block size = 1K|2K|4K */
488 if (le32toh(es->e2fs_log_bsize) > 2) {
489 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
494 fs->e2fs_bshift = EXT2_MIN_BLOCK_LOG_SIZE + le32toh(es->e2fs_log_bsize);
495 fs->e2fs_bsize = 1U << fs->e2fs_bshift;
496 fs->e2fs_fsbtodb = le32toh(es->e2fs_log_bsize) + 1;
497 fs->e2fs_qbmask = fs->e2fs_bsize - 1;
499 /* Check for fragment size */
500 if (le32toh(es->e2fs_log_fsize) >
501 (EXT2_MAX_FRAG_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE)) {
502 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
503 "invalid log cluster size");
507 fs->e2fs_fsize = EXT2_MIN_FRAG_SIZE << le32toh(es->e2fs_log_fsize);
508 if (fs->e2fs_fsize != fs->e2fs_bsize) {
509 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
510 "fragment size != block size");
514 fs->e2fs_fpb = fs->e2fs_bsize / fs->e2fs_fsize;
516 /* Check reserved gdt blocks for future filesystem expansion */
517 if (le16toh(es->e2fs_reserved_ngdb) > (fs->e2fs_bsize / 4)) {
518 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
519 "number of reserved GDT blocks too large");
523 if (le32toh(es->e2fs_rev) == E2FS_REV0) {
524 fs->e2fs_isize = E2FS_REV0_INODE_SIZE;
526 fs->e2fs_isize = le16toh(es->e2fs_inode_size);
531 if (le32toh(es->e2fs_first_ino) < EXT2_FIRSTINO) {
532 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
533 "invalid first ino");
538 * Simple sanity check for superblock inode size value.
540 if (EXT2_INODE_SIZE(fs) < E2FS_REV0_INODE_SIZE ||
541 EXT2_INODE_SIZE(fs) > fs->e2fs_bsize ||
542 (fs->e2fs_isize & (fs->e2fs_isize - 1)) != 0) {
543 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
544 "invalid inode size");
549 /* Check group descriptors */
550 if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_64BIT) &&
551 le16toh(es->e3fs_desc_size) != E2FS_64BIT_GD_SIZE) {
552 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
553 "unsupported 64bit descriptor size");
557 fs->e2fs_bpg = le32toh(es->e2fs_bpg);
558 fs->e2fs_fpg = le32toh(es->e2fs_fpg);
559 if (fs->e2fs_bpg == 0 || fs->e2fs_fpg == 0) {
560 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
561 "zero blocks/fragments per group");
563 } else if (fs->e2fs_bpg != fs->e2fs_fpg) {
564 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
565 "blocks per group not equal fragments per group");
569 if (fs->e2fs_bpg != fs->e2fs_bsize * 8) {
570 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
571 "non-standard group size unsupported");
575 fs->e2fs_ipb = fs->e2fs_bsize / EXT2_INODE_SIZE(fs);
576 if (fs->e2fs_ipb == 0 ||
577 fs->e2fs_ipb > fs->e2fs_bsize / E2FS_REV0_INODE_SIZE) {
578 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
579 "bad inodes per block size");
583 fs->e2fs_ipg = le32toh(es->e2fs_ipg);
584 if (fs->e2fs_ipg < fs->e2fs_ipb || fs->e2fs_ipg > fs->e2fs_bsize * 8) {
585 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
586 "invalid inodes per group");
590 fs->e2fs_itpg = fs->e2fs_ipg / fs->e2fs_ipb;
592 fs->e2fs_bcount = le32toh(es->e2fs_bcount);
593 fs->e2fs_rbcount = le32toh(es->e2fs_rbcount);
594 fs->e2fs_fbcount = le32toh(es->e2fs_fbcount);
595 if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_64BIT)) {
596 fs->e2fs_bcount |= (uint64_t)(le32toh(es->e4fs_bcount_hi)) << 32;
597 fs->e2fs_rbcount |= (uint64_t)(le32toh(es->e4fs_rbcount_hi)) << 32;
598 fs->e2fs_fbcount |= (uint64_t)(le32toh(es->e4fs_fbcount_hi)) << 32;
600 if (fs->e2fs_rbcount > fs->e2fs_bcount ||
601 fs->e2fs_fbcount > fs->e2fs_bcount) {
602 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
603 "invalid block count");
607 fs->e2fs_ficount = le32toh(es->e2fs_ficount);
608 if (fs->e2fs_ficount > le32toh(es->e2fs_icount)) {
609 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
610 "invalid number of free inodes");
614 if (le32toh(es->e2fs_first_dblock) != (fs->e2fs_bsize > 1024 ? 0 : 1) ||
615 le32toh(es->e2fs_first_dblock) >= fs->e2fs_bcount) {
616 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
617 "first data block out of range");
621 fs->e2fs_gcount = howmany(fs->e2fs_bcount -
622 le32toh(es->e2fs_first_dblock), EXT2_BLOCKS_PER_GROUP(fs));
623 if (fs->e2fs_gcount > ((uint64_t)1 << 32) - EXT2_DESCS_PER_BLOCK(fs)) {
624 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
625 "groups count too large");
629 /* Check for extra isize in big inodes. */
630 if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_EXTRA_ISIZE) &&
631 EXT2_INODE_SIZE(fs) < sizeof(struct ext2fs_dinode)) {
632 SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
633 "no space for extra inode timestamps");
637 /* s_resuid / s_resgid ? */
639 if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_64BIT)) {
640 e2fs_descpb = fs->e2fs_bsize / E2FS_64BIT_GD_SIZE;
641 e2fs_gdbcount_alloc = howmany(fs->e2fs_gcount, e2fs_descpb);
643 e2fs_descpb = fs->e2fs_bsize / E2FS_REV0_GD_SIZE;
644 e2fs_gdbcount_alloc = howmany(fs->e2fs_gcount,
645 fs->e2fs_bsize / sizeof(struct ext2_gd));
647 fs->e2fs_gdbcount = howmany(fs->e2fs_gcount, e2fs_descpb);
648 fs->e2fs_gd = malloc(e2fs_gdbcount_alloc * fs->e2fs_bsize,
649 M_EXT2MNT, M_WAITOK | M_ZERO);
650 fs->e2fs_contigdirs = malloc(fs->e2fs_gcount *
651 sizeof(*fs->e2fs_contigdirs), M_EXT2MNT, M_WAITOK | M_ZERO);
653 for (i = 0; i < fs->e2fs_gdbcount; i++) {
655 fsbtodb(fs, ext2_cg_location(fs, i)),
656 fs->e2fs_bsize, NOCRED, &bp);
659 * fs->e2fs_gd and fs->e2fs_contigdirs
660 * will be freed later by the caller,
661 * because this function could be called from
666 if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_64BIT)) {
668 i * fs->e2fs_bsize / sizeof(struct ext2_gd)],
669 bp->b_data, fs->e2fs_bsize);
671 for (j = 0; j < e2fs_descpb &&
672 g_count < fs->e2fs_gcount; j++, g_count++)
673 memcpy(&fs->e2fs_gd[g_count],
674 bp->b_data + j * E2FS_REV0_GD_SIZE,
681 /* Validate cgs consistency */
682 error = ext2_cg_validate(fs);
687 if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) ||
688 EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) {
689 error = ext2_gd_csum_verify(fs, devvp->v_rdev);
693 /* Initialization for the ext2 Orlov allocator variant. */
694 fs->e2fs_total_dir = 0;
695 for (i = 0; i < fs->e2fs_gcount; i++)
696 fs->e2fs_total_dir += e2fs_gd_get_ndirs(&fs->e2fs_gd[i]);
698 if (le32toh(es->e2fs_rev) == E2FS_REV0 ||
699 !EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_LARGEFILE))
700 fs->e2fs_maxfilesize = 0x7fffffff;
702 fs->e2fs_maxfilesize = 0xffffffffffff;
703 if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE))
704 fs->e2fs_maxfilesize = 0x7fffffffffffffff;
706 if (le32toh(es->e4fs_flags) & E2FS_UNSIGNED_HASH) {
708 } else if ((le32toh(es->e4fs_flags) & E2FS_SIGNED_HASH) == 0) {
709 #ifdef __CHAR_UNSIGNED__
710 es->e4fs_flags = htole32(le32toh(es->e4fs_flags) | E2FS_UNSIGNED_HASH);
713 es->e4fs_flags = htole32(le32toh(es->e4fs_flags) | E2FS_SIGNED_HASH);
716 if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM))
717 error = ext2_sb_csum_verify(fs);
723 * Reload all incore data for a filesystem (used after running fsck on
724 * the root filesystem and finding things to fix). The filesystem must
725 * be mounted read-only.
727 * Things to do to update the mount:
728 * 1) invalidate all cached meta-data.
729 * 2) re-read superblock from disk.
730 * 3) invalidate all cluster summary information.
731 * 4) invalidate all inactive vnodes.
732 * 5) invalidate all cached file data.
733 * 6) re-read inode data for all active vnodes.
734 * XXX we are missing some steps, in particular # 3, this has to be reviewed.
737 ext2_reload(struct mount *mp, struct thread *td)
739 struct vnode *vp, *mvp, *devvp;
748 if ((mp->mnt_flag & MNT_RDONLY) == 0)
751 * Step 1: invalidate all cached meta-data.
753 devvp = VFSTOEXT2(mp)->um_devvp;
754 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
755 if (vinvalbuf(devvp, 0, 0, 0) != 0)
756 panic("ext2_reload: dirty1");
760 * Step 2: re-read superblock from disk.
761 * constants have been adjusted for ext2
763 if ((error = bread(devvp, SBLOCK, SBSIZE, NOCRED, &bp)) != 0)
765 es = (struct ext2fs *)bp->b_data;
766 if (ext2_check_sb_compat(es, devvp->v_rdev, 0) != 0) {
768 return (EIO); /* XXX needs translation */
770 fs = VFSTOEXT2(mp)->um_e2fs;
771 bcopy(bp->b_data, fs->e2fs, sizeof(struct ext2fs));
773 if ((error = ext2_compute_sb_data(devvp, es, fs)) != 0) {
778 if (fs->fs_sbsize < SBSIZE)
779 bp->b_flags |= B_INVAL;
784 * Step 3: invalidate all cluster summary information.
786 if (fs->e2fs_contigsumsize > 0) {
787 lp = fs->e2fs_maxcluster;
788 sump = fs->e2fs_clustersum;
789 for (i = 0; i < fs->e2fs_gcount; i++, sump++) {
790 *lp++ = fs->e2fs_contigsumsize;
792 bzero(sump->cs_sum, fs->e2fs_contigsumsize + 1);
797 MNT_VNODE_FOREACH_ALL(vp, mp, mvp) {
799 * Step 4: invalidate all cached file data.
801 if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK)) {
802 MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp);
805 if (vinvalbuf(vp, 0, 0, 0))
806 panic("ext2_reload: dirty2");
809 * Step 5: re-read inode data for all active vnodes.
812 error = bread(devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)),
813 (int)fs->e2fs_bsize, NOCRED, &bp);
817 MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp);
821 error = ext2_ei2i((struct ext2fs_dinode *)((char *)bp->b_data +
822 EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number)), ip);
829 MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp);
837 * Common code for mount and mountroot.
840 ext2_mountfs(struct vnode *devvp, struct mount *mp)
842 struct ext2mount *ump;
846 struct cdev *dev = devvp->v_rdev;
847 struct g_consumer *cp;
855 int32_t e2fs_maxcontig;
857 ronly = vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0);
858 /* XXX: use VOP_ACESS to check FS perms */
860 error = g_vfs_open(devvp, &cp, "ext2fs", ronly ? 0 : 1);
866 /* XXX: should we check for some sectorsize or 512 instead? */
867 if (((SBSIZE % cp->provider->sectorsize) != 0) ||
868 (SBSIZE < cp->provider->sectorsize)) {
875 bo = &devvp->v_bufobj;
877 bo->bo_ops = g_vfs_bufops;
878 if (devvp->v_rdev->si_iosize_max != 0)
879 mp->mnt_iosize_max = devvp->v_rdev->si_iosize_max;
880 if (mp->mnt_iosize_max > maxphys)
881 mp->mnt_iosize_max = maxphys;
885 if ((error = bread(devvp, SBLOCK, SBSIZE, NOCRED, &bp)) != 0)
887 es = (struct ext2fs *)bp->b_data;
888 if (ext2_check_sb_compat(es, dev, ronly) != 0) {
889 error = EINVAL; /* XXX needs translation */
892 if ((le16toh(es->e2fs_state) & E2FS_ISCLEAN) == 0 ||
893 (le16toh(es->e2fs_state) & E2FS_ERRORS)) {
894 if (ronly || (mp->mnt_flag & MNT_FORCE)) {
896 "WARNING: Filesystem was not properly dismounted\n");
899 "WARNING: R/W mount denied. Filesystem is not clean - run fsck\n");
904 ump = malloc(sizeof(*ump), M_EXT2MNT, M_WAITOK | M_ZERO);
907 * I don't know whether this is the right strategy. Note that
908 * we dynamically allocate both an m_ext2fs and an ext2fs
909 * while Linux keeps the super block in a locked buffer.
911 ump->um_e2fs = malloc(sizeof(struct m_ext2fs),
912 M_EXT2MNT, M_WAITOK | M_ZERO);
913 ump->um_e2fs->e2fs = malloc(sizeof(struct ext2fs),
914 M_EXT2MNT, M_WAITOK);
915 mtx_init(EXT2_MTX(ump), "EXT2FS", "EXT2FS Lock", MTX_DEF);
916 bcopy(es, ump->um_e2fs->e2fs, (u_int)sizeof(struct ext2fs));
917 if ((error = ext2_compute_sb_data(devvp, ump->um_e2fs->e2fs, ump->um_e2fs)))
921 * Calculate the maximum contiguous blocks and size of cluster summary
922 * array. In FFS this is done by newfs; however, the superblock
923 * in ext2fs doesn't have these variables, so we can calculate
926 e2fs_maxcontig = MAX(1, maxphys / ump->um_e2fs->e2fs_bsize);
927 ump->um_e2fs->e2fs_contigsumsize = MIN(e2fs_maxcontig, EXT2_MAXCONTIG);
928 ump->um_e2fs->e2fs_maxsymlinklen = EXT2_MAXSYMLINKLEN;
929 if (ump->um_e2fs->e2fs_contigsumsize > 0) {
930 size = ump->um_e2fs->e2fs_gcount * sizeof(int32_t);
931 ump->um_e2fs->e2fs_maxcluster = malloc(size, M_EXT2MNT, M_WAITOK);
932 size = ump->um_e2fs->e2fs_gcount * sizeof(struct csum);
933 ump->um_e2fs->e2fs_clustersum = malloc(size, M_EXT2MNT, M_WAITOK);
934 lp = ump->um_e2fs->e2fs_maxcluster;
935 sump = ump->um_e2fs->e2fs_clustersum;
936 for (i = 0; i < ump->um_e2fs->e2fs_gcount; i++, sump++) {
937 *lp++ = ump->um_e2fs->e2fs_contigsumsize;
939 sump->cs_sum = malloc((ump->um_e2fs->e2fs_contigsumsize + 1) *
940 sizeof(int32_t), M_EXT2MNT, M_WAITOK | M_ZERO);
947 fs->e2fs_ronly = ronly; /* ronly is set according to mnt_flags */
950 * If the fs is not mounted read-only, make sure the super block is
951 * always written back on a sync().
953 fs->e2fs_wasvalid = le16toh(fs->e2fs->e2fs_state) & E2FS_ISCLEAN ? 1 : 0;
955 fs->e2fs_fmod = 1; /* mark it modified and set fs invalid */
956 fs->e2fs->e2fs_state =
957 htole16(le16toh(fs->e2fs->e2fs_state) & ~E2FS_ISCLEAN);
960 mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
961 mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
963 mp->mnt_flag |= MNT_LOCAL;
967 ump->um_devvp = devvp;
968 ump->um_bo = &devvp->v_bufobj;
972 * Setting those two parameters allowed us to use
973 * ufs_bmap w/o changse!
975 ump->um_nindir = EXT2_ADDR_PER_BLOCK(fs);
976 ump->um_bptrtodb = le32toh(fs->e2fs->e2fs_log_bsize) + 1;
977 ump->um_seqinc = EXT2_FRAGS_PER_BLOCK(fs);
979 ext2_sbupdate(ump, MNT_WAIT);
981 * Initialize filesystem stat information in mount struct.
984 mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED |
997 mtx_destroy(EXT2_MTX(ump));
998 free(ump->um_e2fs->e2fs_gd, M_EXT2MNT);
999 free(ump->um_e2fs->e2fs_contigdirs, M_EXT2MNT);
1000 free(ump->um_e2fs->e2fs, M_EXT2MNT);
1001 free(ump->um_e2fs, M_EXT2MNT);
1002 free(ump, M_EXT2MNT);
1003 mp->mnt_data = NULL;
1009 * Unmount system call.
1012 ext2_unmount(struct mount *mp, int mntflags)
1014 struct ext2mount *ump;
1015 struct m_ext2fs *fs;
1017 int error, flags, i, ronly;
1020 if (mntflags & MNT_FORCE) {
1021 if (mp->mnt_flag & MNT_ROOTFS)
1023 flags |= FORCECLOSE;
1025 if ((error = ext2_flushfiles(mp, flags, curthread)) != 0)
1027 ump = VFSTOEXT2(mp);
1029 ronly = fs->e2fs_ronly;
1030 if (ronly == 0 && ext2_cgupdate(ump, MNT_WAIT) == 0) {
1031 if (fs->e2fs_wasvalid)
1032 fs->e2fs->e2fs_state =
1033 htole16(le16toh(fs->e2fs->e2fs_state) | E2FS_ISCLEAN);
1034 ext2_sbupdate(ump, MNT_WAIT);
1038 g_vfs_close(ump->um_cp);
1039 g_topology_unlock();
1040 vrele(ump->um_devvp);
1041 sump = fs->e2fs_clustersum;
1042 for (i = 0; i < fs->e2fs_gcount; i++, sump++)
1043 free(sump->cs_sum, M_EXT2MNT);
1044 free(fs->e2fs_clustersum, M_EXT2MNT);
1045 free(fs->e2fs_maxcluster, M_EXT2MNT);
1046 free(fs->e2fs_gd, M_EXT2MNT);
1047 free(fs->e2fs_contigdirs, M_EXT2MNT);
1048 free(fs->e2fs, M_EXT2MNT);
1049 free(fs, M_EXT2MNT);
1050 free(ump, M_EXT2MNT);
1051 mp->mnt_data = NULL;
1053 mp->mnt_flag &= ~MNT_LOCAL;
1059 * Flush out all the files in a filesystem.
1062 ext2_flushfiles(struct mount *mp, int flags, struct thread *td)
1066 error = vflush(mp, 0, flags, td);
1071 * Get filesystem statistics.
1074 ext2_statfs(struct mount *mp, struct statfs *sbp)
1076 struct ext2mount *ump;
1077 struct m_ext2fs *fs;
1078 uint32_t overhead, overhead_per_group, ngdb;
1081 ump = VFSTOEXT2(mp);
1083 if (le16toh(fs->e2fs->e2fs_magic) != E2FS_MAGIC)
1084 panic("ext2_statfs");
1087 * Compute the overhead (FS structures)
1089 overhead_per_group =
1090 1 /* block bitmap */ +
1091 1 /* inode bitmap */ +
1093 overhead = le32toh(fs->e2fs->e2fs_first_dblock) +
1094 fs->e2fs_gcount * overhead_per_group;
1095 if (le32toh(fs->e2fs->e2fs_rev) > E2FS_REV0 &&
1096 le32toh(fs->e2fs->e2fs_features_rocompat) & EXT2F_ROCOMPAT_SPARSESUPER) {
1097 for (i = 0, ngroups = 0; i < fs->e2fs_gcount; i++) {
1098 if (ext2_cg_has_sb(fs, i))
1102 ngroups = fs->e2fs_gcount;
1104 ngdb = fs->e2fs_gdbcount;
1105 if (le32toh(fs->e2fs->e2fs_rev) > E2FS_REV0 &&
1106 le32toh(fs->e2fs->e2fs_features_compat) & EXT2F_COMPAT_RESIZE)
1107 ngdb += le16toh(fs->e2fs->e2fs_reserved_ngdb);
1108 overhead += ngroups * (1 /* superblock */ + ngdb);
1110 sbp->f_bsize = EXT2_FRAG_SIZE(fs);
1111 sbp->f_iosize = EXT2_BLOCK_SIZE(fs);
1112 sbp->f_blocks = fs->e2fs_bcount - overhead;
1113 sbp->f_bfree = fs->e2fs_fbcount;
1114 sbp->f_bavail = sbp->f_bfree - fs->e2fs_rbcount;
1115 sbp->f_files = le32toh(fs->e2fs->e2fs_icount);
1116 sbp->f_ffree = fs->e2fs_ficount;
1121 * Go through the disk queues to initiate sandbagged IO;
1122 * go through the inodes to write those that have been modified;
1123 * initiate the writing of the super block if it has been modified.
1125 * Note: we are always called with the filesystem marked `MPBUSY'.
1128 ext2_sync(struct mount *mp, int waitfor)
1130 struct vnode *mvp, *vp;
1133 struct ext2mount *ump = VFSTOEXT2(mp);
1134 struct m_ext2fs *fs;
1135 int error, allerror = 0;
1139 if (fs->e2fs_fmod != 0 && fs->e2fs_ronly != 0) { /* XXX */
1140 panic("ext2_sync: rofs mod fs=%s", fs->e2fs_fsmnt);
1144 * Write back each (modified) inode.
1147 MNT_VNODE_FOREACH_ALL(vp, mp, mvp) {
1148 if (vp->v_type == VNON) {
1154 (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 &&
1155 (vp->v_bufobj.bo_dirty.bv_cnt == 0 ||
1156 waitfor == MNT_LAZY)) {
1160 error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK);
1162 if (error == ENOENT) {
1163 MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp);
1168 if ((error = VOP_FSYNC(vp, waitfor, td)) != 0)
1175 * Force stale filesystem control information to be flushed.
1177 if (waitfor != MNT_LAZY) {
1178 vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY);
1179 if ((error = VOP_FSYNC(ump->um_devvp, waitfor, td)) != 0)
1181 VOP_UNLOCK(ump->um_devvp);
1185 * Write back modified superblock.
1187 if (fs->e2fs_fmod != 0) {
1189 fs->e2fs->e2fs_wtime = htole32(time_second);
1190 if ((error = ext2_cgupdate(ump, waitfor)) != 0)
1197 * Look up an EXT2FS dinode number to find its incore vnode, otherwise read it
1198 * in from disk. If it is in core, wait for the lock bit to clear, then
1199 * return the inode locked. Detection and handling of mount points must be
1200 * done by the calling routine.
1203 ext2_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
1205 struct m_ext2fs *fs;
1207 struct ext2mount *ump;
1211 unsigned int i, used_blocks;
1215 error = vfs_hash_get(mp, ino, flags, td, vpp, NULL, NULL);
1216 if (error || *vpp != NULL)
1219 ump = VFSTOEXT2(mp);
1220 ip = malloc(sizeof(struct inode), M_EXT2NODE, M_WAITOK | M_ZERO);
1222 /* Allocate a new vnode/inode. */
1223 if ((error = getnewvnode("ext2fs", mp, &ext2_vnodeops, &vp)) != 0) {
1225 free(ip, M_EXT2NODE);
1230 ip->i_e2fs = fs = ump->um_e2fs;
1233 cluster_init_vn(&ip->i_clusterw);
1235 lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL);
1236 error = insmntque(vp, mp);
1238 free(ip, M_EXT2NODE);
1242 error = vfs_hash_insert(vp, ino, flags, td, vpp, NULL, NULL);
1243 if (error || *vpp != NULL)
1246 /* Read in the disk contents for the inode, copy into the inode. */
1247 if ((error = bread(ump->um_devvp, fsbtodb(fs, ino_to_fsba(fs, ino)),
1248 (int)fs->e2fs_bsize, NOCRED, &bp)) != 0) {
1250 * The inode does not contain anything useful, so it would
1251 * be misleading to leave it on its hash chain. With mode
1252 * still zero, it will be unlinked and returned to the free
1260 /* convert ext2 inode to dinode */
1261 error = ext2_ei2i((struct ext2fs_dinode *)((char *)bp->b_data +
1262 EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ino)), ip);
1269 ip->i_block_group = ino_to_cg(fs, ino);
1270 ip->i_next_alloc_block = 0;
1271 ip->i_next_alloc_goal = 0;
1274 * Now we want to make sure that block pointers for unused
1275 * blocks are zeroed out - ext2_balloc depends on this
1276 * although for regular files and directories only
1278 * If IN_E4EXTENTS is enabled, unused blocks are not zeroed
1279 * out because we could corrupt the extent tree.
1281 if (!(ip->i_flag & IN_E4EXTENTS) &&
1282 (S_ISDIR(ip->i_mode) || S_ISREG(ip->i_mode))) {
1283 used_blocks = howmany(ip->i_size, fs->e2fs_bsize);
1284 for (i = used_blocks; i < EXT2_NDIR_BLOCKS; i++)
1290 #ifdef EXT2FS_PRINT_EXTENTS
1291 ext2_print_inode(ip);
1292 error = ext4_ext_walk(ip);
1301 * Initialize the vnode from the inode, check for aliases.
1302 * Note that the underlying vnode may have changed.
1304 if ((error = ext2_vinit(mp, &ext2_fifoops, &vp)) != 0) {
1311 * Finish inode initialization.
1319 * File handle to vnode
1321 * Have to be really careful about stale file handles:
1322 * - check that the inode number is valid
1323 * - call ext2_vget() to get the locked inode
1324 * - check for an unallocated inode (i_mode == 0)
1325 * - check that the given client host has export rights and return
1326 * those rights via. exflagsp and credanonp
1329 ext2_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp)
1334 struct m_ext2fs *fs;
1337 ufhp = (struct ufid *)fhp;
1338 fs = VFSTOEXT2(mp)->um_e2fs;
1339 if (ufhp->ufid_ino < EXT2_ROOTINO ||
1340 ufhp->ufid_ino > fs->e2fs_gcount * fs->e2fs_ipg)
1343 error = VFS_VGET(mp, ufhp->ufid_ino, LK_EXCLUSIVE, &nvp);
1349 if (ip->i_mode == 0 ||
1350 ip->i_gen != ufhp->ufid_gen || ip->i_nlink <= 0) {
1356 vnode_create_vobject(*vpp, 0, curthread);
1361 * Write a superblock and associated information back to disk.
1364 ext2_sbupdate(struct ext2mount *mp, int waitfor)
1366 struct m_ext2fs *fs = mp->um_e2fs;
1367 struct ext2fs *es = fs->e2fs;
1371 es->e2fs_bcount = htole32(fs->e2fs_bcount & 0xffffffff);
1372 es->e2fs_rbcount = htole32(fs->e2fs_rbcount & 0xffffffff);
1373 es->e2fs_fbcount = htole32(fs->e2fs_fbcount & 0xffffffff);
1374 if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_64BIT)) {
1375 es->e4fs_bcount_hi = htole32(fs->e2fs_bcount >> 32);
1376 es->e4fs_rbcount_hi = htole32(fs->e2fs_rbcount >> 32);
1377 es->e4fs_fbcount_hi = htole32(fs->e2fs_fbcount >> 32);
1380 es->e2fs_ficount = htole32(fs->e2fs_ficount);
1382 if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM))
1383 ext2_sb_csum_set(fs);
1385 bp = getblk(mp->um_devvp, SBLOCK, SBSIZE, 0, 0, 0);
1386 bcopy((caddr_t)es, bp->b_data, (u_int)sizeof(struct ext2fs));
1387 if (waitfor == MNT_WAIT)
1393 * The buffers for group descriptors, inode bitmaps and block bitmaps
1394 * are not busy at this point and are (hopefully) written by the
1395 * usual sync mechanism. No need to write them here.
1400 ext2_cgupdate(struct ext2mount *mp, int waitfor)
1402 struct m_ext2fs *fs = mp->um_e2fs;
1404 int i, j, g_count = 0, error = 0, allerror = 0;
1406 allerror = ext2_sbupdate(mp, waitfor);
1408 /* Update gd csums */
1409 if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) ||
1410 EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM))
1411 ext2_gd_csum_set(fs);
1413 for (i = 0; i < fs->e2fs_gdbcount; i++) {
1414 bp = getblk(mp->um_devvp, fsbtodb(fs,
1415 ext2_cg_location(fs, i)),
1416 fs->e2fs_bsize, 0, 0, 0);
1417 if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_64BIT)) {
1418 memcpy(bp->b_data, &fs->e2fs_gd[
1419 i * fs->e2fs_bsize / sizeof(struct ext2_gd)],
1422 for (j = 0; j < fs->e2fs_bsize / E2FS_REV0_GD_SIZE &&
1423 g_count < fs->e2fs_gcount; j++, g_count++)
1424 memcpy(bp->b_data + j * E2FS_REV0_GD_SIZE,
1425 &fs->e2fs_gd[g_count], E2FS_REV0_GD_SIZE);
1427 if (waitfor == MNT_WAIT)
1433 if (!allerror && error)
1439 * Return the root of a filesystem.
1442 ext2_root(struct mount *mp, int flags, struct vnode **vpp)
1447 error = VFS_VGET(mp, EXT2_ROOTINO, LK_EXCLUSIVE, &nvp);