]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
blkzone: Reset all zones when length is not specified
authorDamien Le Moal <damien.lemoal@wdc.com>
Fri, 24 Feb 2017 02:48:45 +0000 (11:48 +0900)
committerKarel Zak <kzak@redhat.com>
Fri, 24 Feb 2017 10:53:45 +0000 (11:53 +0100)
If length is 0, operate on all zones starting from offset.
This also fix the maximum length calculation from offset.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
sys-utils/blkzone.c

index ddb13fc040733940586dd792ad25169825004aa9..1c3a7ef7daf0a70192944b1f22446a7e77fcee2f 100644 (file)
@@ -235,10 +235,12 @@ static int blkzone_reset(struct blkzone_control *ctl)
        if (ctl->offset > ctl->total_sectors)
                errx(EXIT_FAILURE, _("%s: offset is greater than device size"), ctl->devname);
 
-       zlen = ctl->length * zonesize;
-
+       if (!ctl->length)
+               zlen = ctl->total_sectors;
+       else
+               zlen = ctl->length * zonesize;
        if (ctl->offset + zlen > ctl->total_sectors)
-               zlen = ctl->total_sectors - ctl->length;
+               zlen = ctl->total_sectors - ctl->offset;
 
        za.sector = ctl->offset;
        za.nr_sectors = zlen;