From 72a73102334a7e531e566defcd92dcb822c4e388 Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Fri, 24 Feb 2017 11:48:45 +0900 Subject: blkzone: Reset all zones when length is not specified 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 --- sys-utils/blkzone.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sys-utils/blkzone.c') diff --git a/sys-utils/blkzone.c b/sys-utils/blkzone.c index ddb13fc04..1c3a7ef7d 100644 --- a/sys-utils/blkzone.c +++ b/sys-utils/blkzone.c @@ -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; -- cgit v1.2.3-55-g7522