summaryrefslogtreecommitdiffstats
path: root/sys/gnu/ext2fs
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2000-01-02 17:40:02 +0000
committerbde <bde@FreeBSD.org>2000-01-02 17:40:02 +0000
commit9044ef079ba9c9fdf4e63923cad27b684d51f99f (patch)
tree97f3fe74fc55d82a85efd83688067f0306e1ded9 /sys/gnu/ext2fs
parent169381ef736786333a381f9a567cb8642b783750 (diff)
downloadFreeBSD-src-9044ef079ba9c9fdf4e63923cad27b684d51f99f.zip
FreeBSD-src-9044ef079ba9c9fdf4e63923cad27b684d51f99f.tar.gz
Don't allow mounting (or mounting R/W) of filesystems with unsupported
features (except for file types in directory entries, which will be supported soon). Centralized the magic number and compatibility checking. Dropped support for ancient (pre-0.2b) filesystems, as in the Linux version. Our "support" consisted of printing more details in the error message before failing at mount time.
Diffstat (limited to 'sys/gnu/ext2fs')
-rw-r--r--sys/gnu/ext2fs/ext2_fs.h3
-rw-r--r--sys/gnu/ext2fs/ext2_vfsops.c50
2 files changed, 34 insertions, 19 deletions
diff --git a/sys/gnu/ext2fs/ext2_fs.h b/sys/gnu/ext2fs/ext2_fs.h
index c7262e9..64aff0d 100644
--- a/sys/gnu/ext2fs/ext2_fs.h
+++ b/sys/gnu/ext2fs/ext2_fs.h
@@ -101,9 +101,6 @@
/*
* The second extended file system magic number
*/
-#ifndef notyet
-#define EXT2_PRE_02B_MAGIC 0xEF51
-#endif
#define EXT2_SUPER_MAGIC 0xEF53
/*
diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c
index 9053682..1865dbb 100644
--- a/sys/gnu/ext2fs/ext2_vfsops.c
+++ b/sys/gnu/ext2fs/ext2_vfsops.c
@@ -107,6 +107,8 @@ VFS_SET(ext2fs_vfsops, ext2fs, 0);
static int ext2fs_inode_hash_lock;
+static int ext2_check_sb_compat __P((struct ext2_super_block *es,
+ dev_t dev, int ronly));
static int compute_sb_data __P((struct vnode * devvp,
struct ext2_super_block * es,
struct ext2_sb_info * fs));
@@ -365,6 +367,36 @@ static int ext2_check_descriptors (struct ext2_sb_info * sb)
return 1;
}
+static int
+ext2_check_sb_compat(es, dev, ronly)
+ struct ext2_super_block *es;
+ dev_t dev;
+ int ronly;
+{
+
+ if (es->s_magic != EXT2_SUPER_MAGIC) {
+ printf("ext2fs: %s: wrong magic number %#x (expected %#x)\n",
+ devtoname(dev), es->s_magic, EXT2_SUPER_MAGIC);
+ return (1);
+ }
+ if (es->s_rev_level > EXT2_GOOD_OLD_REV) {
+ if (es->s_feature_incompat & ~EXT2_FEATURE_INCOMPAT_SUPP) {
+ printf(
+"WARNING: mount of %s denied due to unsupported optional features\n",
+ devtoname(dev));
+ return (1);
+ }
+ if (!ronly &&
+ (es->s_feature_ro_compat & ~EXT2_FEATURE_RO_COMPAT_SUPP)) {
+ printf(
+"WARNING: R/W mount of %s denied due to unsupported optional features\n",
+ devtoname(dev));
+ return (1);
+ }
+ }
+ return (0);
+}
+
/*
* this computes the fields of the ext2_sb_info structure from the
* data in the ext2_super_block structure read in
@@ -506,14 +538,7 @@ ext2_reload(mountp, cred, p)
if ((error = bread(devvp, SBLOCK, SBSIZE, NOCRED, &bp)) != 0)
return (error);
es = (struct ext2_super_block *)bp->b_data;
- if (es->s_magic != EXT2_SUPER_MAGIC) {
- if(es->s_magic == EXT2_PRE_02B_MAGIC)
- printf("This filesystem bears the magic number of a pre "
- "0.2b version of ext2. This is not supported by "
- "Lites.\n");
- else
- printf("Wrong magic number: %x (expected %x for ext2 fs\n",
- es->s_magic, EXT2_SUPER_MAGIC);
+ if (ext2_check_sb_compat(es, devvp->v_rdev, 0) != 0) {
brelse(bp);
return (EIO); /* XXX needs translation */
}
@@ -629,14 +654,7 @@ ext2_mountfs(devvp, mp, p)
if ((error = bread(devvp, SBLOCK, SBSIZE, NOCRED, &bp)) != 0)
goto out;
es = (struct ext2_super_block *)bp->b_data;
- if (es->s_magic != EXT2_SUPER_MAGIC) {
- if(es->s_magic == EXT2_PRE_02B_MAGIC)
- printf("This filesystem bears the magic number of a pre "
- "0.2b version of ext2. This is not supported by "
- "Lites.\n");
- else
- printf("Wrong magic number: %x (expected %x for EXT2FS)\n",
- es->s_magic, EXT2_SUPER_MAGIC);
+ if (ext2_check_sb_compat(es, dev, ronly) != 0) {
error = EINVAL; /* XXX needs translation */
goto out;
}
OpenPOWER on IntegriCloud