Whamcloud - gitweb
mke2fs: do not warn about a pre-existing partition table when using a non-zero offset
authorTheodore Ts'o <tytso@mit.edu>
Wed, 21 Jul 2021 19:46:09 +0000 (15:46 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 21 Jul 2021 20:24:15 +0000 (16:24 -0400)
The existing code attempted to avoid warning about a pre-existing file
system with a non-zero offset, but because the offset was not set at
the time of the check, this intention was not actually working.  So
this commit will suppress warnings about pre-existing a partition
table as well as pre-existing file system when there is a non-zero
offset.

Addresses-Debian-Bug: #989612
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/support/plausible.c
misc/mke2fs.c

index 2a3ae14..bbed2a7 100644 (file)
@@ -282,11 +282,11 @@ int check_plausibility(const char *device, int flags, int *ret_is_dev)
                return !has_magic;
        }
 #endif
-
-       ret = check_partition_table(device);
-       if (ret >= 0)
-               return ret;
-
+       if (flags & CHECK_FS_EXIST) {
+               ret = check_partition_table(device);
+               if (ret >= 0)
+                       return ret;
+       }
        return 1;
 }
 
index 5a35e9e..c7b3231 100644 (file)
@@ -1973,18 +1973,8 @@ profile_error:
        profile_get_integer(profile, "options", "proceed_delay", 0, 0,
                            &proceed_delay);
 
-       /* The isatty() test is so we don't break existing scripts */
-       flags = CREATE_FILE;
-       if (isatty(0) && isatty(1) && !offset)
-               flags |= CHECK_FS_EXIST;
-       if (!quiet)
-               flags |= VERBOSE_CREATE;
-       if (fs_blocks_count == 0)
-               flags |= NO_SIZE;
-       else
+       if (fs_blocks_count)
                explicit_fssize = 1;
-       if (!check_plausibility(device_name, flags, &is_device) && !force)
-               proceed_question(proceed_delay);
 
        check_mount(device_name, force, _("filesystem"));
 
@@ -2650,6 +2640,17 @@ profile_error:
 
        free(fs_type);
        free(usage_types);
+
+       /* The isatty() test is so we don't break existing scripts */
+       flags = CREATE_FILE;
+       if (isatty(0) && isatty(1) && !offset)
+               flags |= CHECK_FS_EXIST;
+       if (!quiet)
+               flags |= VERBOSE_CREATE;
+       if (!explicit_fssize)
+               flags |= NO_SIZE;
+       if (!check_plausibility(device_name, flags, &is_device) && !force)
+               proceed_question(proceed_delay);
 }
 
 static int should_do_undo(const char *name)