]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: (dos) retain existing boot flag when resizing a partition
authorKarel Zak <kzak@redhat.com>
Mon, 13 Apr 2015 08:29:00 +0000 (10:29 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Apr 2015 08:29:00 +0000 (10:29 +0200)
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1210912
Signed-off-by: Karel Zak <kzak@redhat.com>
Co-Author:  awilliam@redhat.com

libfdisk/src/dos.c
libfdisk/src/partition.c

index dce9829eb107860d9484dbfc40bd7f31a7bdda9b..6468071ffbadf54f84142d6973a05a1cc00c6ea1 100644 (file)
@@ -1221,7 +1221,7 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
                }
        }
 
-       set_partition(cxt, n, 0, start, stop, sys, pa && pa->boot == 1 ? 1 : 0);
+       set_partition(cxt, n, 0, start, stop, sys, fdisk_partition_is_bootable(pa));
        if (n > 4) {
                struct pte *pe = self_pte(cxt, n);
                set_partition(cxt, n - 1, 1, pe->offset, stop,
@@ -1963,13 +1963,15 @@ static int dos_set_partition(struct fdisk_context *cxt, size_t n,
 
                set_partition(cxt, n, 0, start, start + size - 1,
                                pa->type  ? pa->type->code : p->sys_ind,
-                               pa->boot == 1);
+                               FDISK_IS_UNDEF(pa->boot) ?
+                                       p->boot_ind == ACTIVE_FLAG :
+                                       fdisk_partition_is_bootable(pa));
        } else {
                DBG(LABEL, ul_debug("DOS: keep size, modify properties"));
                if (pa->type)
                        p->sys_ind = pa->type->code;
                if (!FDISK_IS_UNDEF(pa->boot))
-                       p->boot_ind = pa->boot == 1 ? ACTIVE_FLAG : 0;
+                       p->boot_ind = fdisk_partition_is_bootable(pa) ? ACTIVE_FLAG : 0;
        }
 
        partition_set_changed(cxt, n, 1);
index 640cd5a1dc404591861174173f933a77cad43eb8..114cac56eb822d45d654c67cbd726fe294b36b28 100644 (file)
@@ -757,8 +757,7 @@ int fdisk_partition_to_string(struct fdisk_partition *pa,
                }
                break;
        case FDISK_FIELD_BOOT:
-               if (fdisk_partition_is_bootable(pa))
-                       rc = asprintf(&p, "%c", pa->boot ? '*' : ' ');
+               p = fdisk_partition_is_bootable(pa) ? strdup("*") : NULL;
                break;
        case FDISK_FIELD_START:
                if (fdisk_partition_has_start(pa)) {