Bug#989612: mke2fs -E offset=N still warns about existing partition table at the beginning
On Wed, Jul 21, 2021 at 10:24:32PM -0400, Theodore Ts'o wrote: > Thanks for reporting this bug. The following commit should fix the > issue. > > - Ted > > commit 942b00cb9d2f2b52f4c58877d523145ee59a89b0 > Author: Theodore Ts'o > Date: Wed Jul 21 15:46:09 2021 -0400 > > mke2fs: do not warn about a pre-existing partition table when using a > non-zero offset > > 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. Thank you!
Bug#989612: mke2fs -E offset=N still warns about existing partition table at the beginning
tags 989612 +pending thanks Thanks for reporting this bug. The following commit should fix the issue. - Ted commit 942b00cb9d2f2b52f4c58877d523145ee59a89b0 Author: Theodore Ts'o Date: Wed Jul 21 15:46:09 2021 -0400 mke2fs: do not warn about a pre-existing partition table when using a non-zero offset 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 diff --git a/lib/support/plausible.c b/lib/support/plausible.c index 2a3ae140..bbed2a70 100644 --- a/lib/support/plausible.c +++ b/lib/support/plausible.c @@ -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; } diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 5a35e9ef..c7b32316 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1973,18 +1973,8 @@ profile_error: profile_get_integer(profile, "options", "proceed_delay", 0, 0, _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, _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, _device) && !force) + proceed_question(proceed_delay); } static int should_do_undo(const char *name)
Bug#989612: mke2fs -E offset=N still warns about existing partition table at the beginning
On Thu, 17 Jun 2021 10:39:20 +0200 Paul Gevers wrote: > On Tue, 08 Jun 2021 09:14:41 -0700 Josh Triplett > wrote: > > mke2fs with -E offset=N does not seem to take the offset into account > > when checking the target to see if it seems to already contain > > something. > > Same as for bug 989630, do you know if this is a regression? Definitely not a regression, no.
Bug#989612: mke2fs -E offset=N still warns about existing partition table at the beginning
On Thu, Jun 17, 2021 at 10:39:20AM +0200, Paul Gevers wrote: > Control: block 988830 by -1 > > Hi Josh, Theodore, > > On Tue, 08 Jun 2021 09:14:41 -0700 Josh Triplett > wrote: > > mke2fs with -E offset=N does not seem to take the offset into account > > when checking the target to see if it seems to already contain > > something. > > Same as for bug 989630, do you know if this is a regression? Nope, this has been around since 2013, and Josh is the first person to have noticed and complained. The offset feature is super-rare, and most of the time it's used only as part of an automated image-building script where the image contains a partition table as well as one or more file systems. - Ted
Bug#989612: mke2fs -E offset=N still warns about existing partition table at the beginning
Control: block 988830 by -1 Hi Josh, Theodore, On Tue, 08 Jun 2021 09:14:41 -0700 Josh Triplett wrote: > mke2fs with -E offset=N does not seem to take the offset into account > when checking the target to see if it seems to already contain > something. Same as for bug 989630, do you know if this is a regression? Paul OpenPGP_signature Description: OpenPGP digital signature
Bug#989612: mke2fs -E offset=N still warns about existing partition table at the beginning
Package: e2fsprogs Version: 1.46.2-2 Severity: normal File: /sbin/mke2fs X-Debbugs-Cc: j...@joshtriplett.org mke2fs with -E offset=N does not seem to take the offset into account when checking the target to see if it seems to already contain something. For instance: /tmp$ truncate -s 1G disk.img /tmp$ echo '8,+,L' | sfdisk --lock --no-reread --no-tell-kernel disk.img Disk disk.img: 1 GiB, 1073741824 bytes, 2097152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes >>> Created a new DOS disklabel with disk identifier 0x729c5118. disk.img1: Created a new partition 1 of type 'Linux' and of size 1024 MiB. disk.img2: Done. New situation: Disklabel type: dos Disk identifier: 0x729c5118 Device Boot Start End Sectors Size Id Type disk.img1 8 2097151 2097144 1024M 83 Linux The partition table has been altered. /tmp$ mkfs.ext4 -E offset=4096 disk.img mke2fs 1.46.2 (28-Feb-2021) Found a dos partition table in disk.img Proceed anyway? (y,N) I deeply appreciate that mke2fs checks for existing data before overwriting it, and I'd prefer to not just pass -F here. I think the "plausible" checks should take the offset into account. -- System Information: Debian Release: 11.0 APT prefers unstable-debug APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental-debug'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: arm64 Kernel: Linux 5.12.8 (SMP w/4 CPU threads) Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages e2fsprogs depends on: ii libblkid12.36.1-7 ii libc62.31-12 ii libcom-err2 1.46.2-2 ii libext2fs2 1.46.2-2 ii libss2 1.46.2-2 ii libuuid1 2.36.1-7 ii logsave 1.46.2-2 Versions of packages e2fsprogs recommends: pn e2fsprogs-l10n Versions of packages e2fsprogs suggests: pn e2fsck-static pn fuse2fs pn gpart ii parted 3.4-1 -- no debconf information