Skip to contentSkip to conversation

Make CacheFS return the right error upon invalid mount

PATCH New David Howells 1 participant 1 message Sep 8, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 Make CacheFS return the right error upon invalid mount

The attached patch makes CacheFS return -EINVAL if the magic number on disc doesn't match what it's expecting (rather than -EIO). Also it moves the check that the partition is not read-only further down to avoid a return of -EROFS instead or -EINVAL.

---

 super.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
fs/cachefs/super.c +11 -11
diff -u linux-2.6.9-rc1-mm4/fs/cachefs/super.c linux-2.6.9-rc1-mm4-afs/fs/cachefs/super.c
@@ -232,16 +232,6 @@
 
 	_enter("");
 
-	if (bdev_read_only(sb->s_bdev)) {
-		printk("CacheFS: blockdev read-only\n");
-		return -EROFS;
-	}
-
-	if (sb->s_flags & MS_RDONLY) {
-		printk("CacheFS: filesystem mounted read-only\n");
-		return -EROFS;
-	}
-
 	/* we want the block size to be at least as big as the size of a
 	 * journal entry */
 	if (!sb_min_blocksize(sb,
@@ -398,10 +388,20 @@
 	}
 	else {
 		printk("CacheFS: Wrong magic number on cache\n");
-		ret = -EIO;
+		ret = -EINVAL;
 		goto error;
 	}
 
+	/* a read-only cache isn't a lot of use */
+	ret = -EROFS;
+	if (bdev_read_only(sb->s_bdev)) {
+		printk("CacheFS: blockdev read-only\n");
+	}
+
+	if (sb->s_flags & MS_RDONLY) {
+		printk("CacheFS: filesystem mounted read-only\n");
+	}
+
 	/* replay the journal if the cache was initialised */
 	super->ujnl_jsof = super->layout->bix_ujournal;
 	super->ujnl_jsof <<= (PAGE_SHIFT - super->sb->s_blocksize_bits);