]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: allow to start freespace for zero
authorKarel Zak <kzak@redhat.com>
Thu, 11 Jan 2018 14:18:00 +0000 (15:18 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 11 Jan 2018 14:18:00 +0000 (15:18 +0100)
This is necessary for disk labels like SUN where whole disk is possible
to address by partitions.

Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/context.c
libfdisk/src/sun.c
libfdisk/src/table.c

index 95d17acde90b26e548c9fd30c8b6cd9215a186e0..ee9c40ea63006cb21aa66ce7a8faaf437c875cbb 100644 (file)
@@ -301,6 +301,8 @@ int __fdisk_switch_label(struct fdisk_context *cxt, struct fdisk_label *lb)
        }
        cxt->label = lb;
        DBG(CXT, ul_debugobj(cxt, "--> switching context to %s!", lb->name));
+
+       fdisk_apply_label_device_properties(cxt);
        return 0;
 }
 
index a247dbcf570155082db8946cc21a96d917bc570a..7257081f3f0ada6e98f5d4d3749928ea2b21fa7d 100644 (file)
@@ -507,6 +507,8 @@ static int sun_add_partition(
        size_t i;
        unsigned int first, last;
 
+       DBG(LABEL, ul_debug("SUN adding partition"));
+
        rc = fdisk_partition_next_partno(pa, cxt, &n);
        if (rc)
                return rc;
@@ -704,6 +706,8 @@ static int sun_add_partition(
        if (whole_disk)
                sys = SUN_TAG_WHOLEDISK;
 
+       DBG(LABEL, ul_debug("SUN new partition #%zu: first=%u, last=%u, sys=%d", n, first, last, sys));
+
        set_partition(cxt, n, first, last, sys);
        cxt->label->nparts_cur = count_used_partitions(cxt);
        if (partno)
@@ -1088,6 +1092,7 @@ static int sun_set_partition(
 
 static int sun_reset_alignment(struct fdisk_context *cxt __attribute__((__unused__)))
 {
+       fdisk_set_first_lba(cxt, 0);
        return 0;
 }
 
index c5ad382cae050751f00e3abd2df0aa87bc6f4abc..4881db68e2acb759050d142e95d1824c02c826eb 100644 (file)
@@ -411,7 +411,7 @@ static int new_freespace(struct fdisk_context *cxt,
        if (start == end)
                return 0;
 
-       assert(start);
+       assert(start >= cxt->first_lba);
        assert(end);
        assert(end > start);