diff options
author | Karel Zak | 2019-07-17 12:11:38 +0200 |
---|---|---|
committer | Karel Zak | 2019-07-17 12:11:38 +0200 |
commit | 7c643ed2855058657798d9e8e80701023de14a08 (patch) | |
tree | b53be6c3afb4013f5b2fd2049640141c08adc463 /libfdisk/src/context.c | |
parent | build-sys: improve hwclock CMOS dependences (diff) | |
download | kernel-qcow2-util-linux-7c643ed2855058657798d9e8e80701023de14a08.tar.gz kernel-qcow2-util-linux-7c643ed2855058657798d9e8e80701023de14a08.tar.xz kernel-qcow2-util-linux-7c643ed2855058657798d9e8e80701023de14a08.zip |
libfdisk: don't use FAT as MBR
The current libfdisk MBR detection is too weak, the result is that it
reuses MBR from FAT. The correct behavior is to create a new MBR, wipe
first sector (on write) and warn about obsolete FAT superblock.
Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/context.c')
-rw-r--r-- | libfdisk/src/context.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index 770aa4d52..bc284f34e 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -619,14 +619,20 @@ static int fdisk_assign_fd(struct fdisk_context *cxt, int fd, if (fdisk_read_firstsector(cxt) < 0) goto fail; + /* warn about obsolete stuff on the device if we aren't in list-only */ + if (!fdisk_is_listonly(cxt) && fdisk_check_collisions(cxt) < 0) + goto fail; + fdisk_probe_labels(cxt); fdisk_apply_label_device_properties(cxt); - /* warn about obsolete stuff on the device if we aren't in - * list-only mode and there is not PT yet */ - if (!fdisk_is_listonly(cxt) && !fdisk_has_label(cxt) - && fdisk_check_collisions(cxt) < 0) - goto fail; + /* Don't report collision if there is already a valid partition table. + * The bootbits are wiped when we create a *new* partition table only. */ + if (fdisk_is_ptcollision(cxt) && fdisk_has_label(cxt)) { + cxt->pt_collision = 0; + free(cxt->collision); + cxt->collision = NULL; + } DBG(CXT, ul_debugobj(cxt, "initialized for %s [%s]", fname, readonly ? "READ-ONLY" : "READ-WRITE")); |