[Ocfs2-tools-devel] [PATCH v2] mount.ocfs2: return -EROFS if file system is readonly
piaojun
piaojun at huawei.com
Thu Dec 28 02:30:22 PST 2017
If metadata is corrupted such as 'invalid inode block', we will get
-EROFS by calling 'mount()'. In this situation we need fix it by fsck,
and mount again rather than doing meaningless retry. In addition, an
indentation problem in 'ocfs2_err.et' is fixed.
Signed-off-by: Jun Piao <piaojun at huawei.com>
---
libocfs2/ocfs2_err.et | 4 ++--
mount.ocfs2/mount.ocfs2.c | 12 +++++++++---
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/libocfs2/ocfs2_err.et b/libocfs2/ocfs2_err.et
index 34cefed..3dc0ce2 100644
--- a/libocfs2/ocfs2_err.et
+++ b/libocfs2/ocfs2_err.et
@@ -168,8 +168,8 @@ ec OCFS2_ET_NO_IONICE,
ec OCFS2_ET_NO_BACKUP_SUPER,
"Backup superblock not found"
-ec OCFS2_ET_TOO_MANY_SLOTS,
- "Too many slots for slot map"
+ec OCFS2_ET_TOO_MANY_SLOTS,
+ "Too many slots for slot map"
ec OCFS2_ET_CANNOT_INLINE_DATA,
"Unable to write the data inline"
diff --git a/mount.ocfs2/mount.ocfs2.c b/mount.ocfs2/mount.ocfs2.c
index e3d8871..c6e8226 100644
--- a/mount.ocfs2/mount.ocfs2.c
+++ b/mount.ocfs2/mount.ocfs2.c
@@ -434,8 +434,14 @@ int main(int argc, char **argv)
o2cb_complete_group_join(&cluster, &desc, errno);
}
block_signals (SIG_UNBLOCK);
- com_err(progname, ret, "while mounting %s on %s. Check 'dmesg' "
- "for more information on this error.", mo.dev, mo.dir);
+ if (ret == -EROFS)
+ com_err(progname, OCFS2_ET_RO_FILESYS, "while mounting %s "
+ "on %s, please try fixing this by fsck.ocfs2 and then "
+ "retry mounting", mo.dev, mo.dir);
+ else
+ com_err(progname, OCFS2_ET_INTERNAL_FAILURE,
+ "while mounting %s on %s. Check 'dmesg' for more "
+ "information on this error.", mo.dev, mo.dir);
goto bail;
}
if (group_join) {
@@ -478,5 +484,5 @@ bail:
if (opts_string)
free(opts_string);
- return ret ? 1 : 0;
+ return ret;
}
--
More information about the Ocfs2-tools-devel
mailing list