mke2fs: don't fail creating the journal if /etc/mtab is missing
The ext2fs_add_journal_inode() function calls
ext2fs_check_mount_point(), which can fail if /etc/mtab is missing.
This causes mke2fs to fail in the middle of the file system format
process; mke2fs calls ext2fs_check_mount_point() already (and has
appropriate fallbacks that calls fails), so add a flag so that mke2fs
can request ext2fs_add_journal_inode() to skip trying to call
e2fsck_check_mount_point().
Addresses-Sourceforge-Bug: #3509398
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index c6b0b24..68e94a3 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -211,6 +211,7 @@
*/
#define EXT2_MKJOURNAL_V1_SUPER 0x0000001 /* create V1 superblock (deprecated) */
#define EXT2_MKJOURNAL_LAZYINIT 0x0000002 /* don't zero journal inode before use*/
+#define EXT2_MKJOURNAL_NO_MNT_CHECK 0x0000004 /* don't check mount status */
struct opaque_ext2_group_desc;
diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c
index 838d751..30ccdd2 100644
--- a/lib/ext2fs/mkjournal.c
+++ b/lib/ext2fs/mkjournal.c
@@ -499,8 +499,11 @@
int mount_flags, f;
int fd = -1;
- if ((retval = ext2fs_check_mount_point(fs->device_name, &mount_flags,
- jfile, sizeof(jfile)-10)))
+ if (flags & EXT2_MKJOURNAL_NO_MNT_CHECK)
+ mount_flags = 0;
+ else if ((retval = ext2fs_check_mount_point(fs->device_name,
+ &mount_flags,
+ jfile, sizeof(jfile)-10)))
return retval;
if (mount_flags & EXT2_MF_MOUNTED) {
@@ -612,7 +615,7 @@
exit(1);
}
- retval = ext2fs_add_journal_inode(fs, 1024);
+ retval = ext2fs_add_journal_inode(fs, 1024, 0);
if (retval) {
com_err(argv[0], retval, "while adding journal to %s",
device_name);
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 0d793f7..60389d4 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1900,6 +1900,7 @@
journal_flags |= get_bool_from_profile(fs_types,
"lazy_journal_init", 0) ?
EXT2_MKJOURNAL_LAZYINIT : 0;
+ journal_flags |= EXT2_MKJOURNAL_NO_MNT_CHECK;
/* Get options from profile */
for (cpp = fs_types; *cpp; cpp++) {