Whamcloud - gitweb
mke2fs: don't fail creating the journal if /etc/mtab is missing
authorTheodore Ts'o <tytso@mit.edu>
Thu, 5 Apr 2012 19:30:02 +0000 (12:30 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 5 Apr 2012 19:30:02 +0000 (12:30 -0700)
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>
lib/ext2fs/ext2fs.h
lib/ext2fs/mkjournal.c
misc/mke2fs.c

index c6b0b24..68e94a3 100644 (file)
@@ -211,6 +211,7 @@ typedef struct ext2_file *ext2_file_t;
  */
 #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;
 
index 838d751..30ccdd2 100644 (file)
@@ -499,8 +499,11 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks, int flags)
        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 @@ main(int argc, char **argv)
                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);
index 0d793f7..60389d4 100644 (file)
@@ -1900,6 +1900,7 @@ profile_error:
        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++) {