Make CacheFS return the right error upon invalid mount
A message that is not in the archive (sent off-list or not yet received): [email protected]
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.
Signed-off-by David Howells <[email protected]>
---
super.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-)
fs/cachefs/super.c +11 -11
@@ -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);