libfdisk: fix fdisk_set_wipe_area() calls

The function expects size in sectors rather than in bytes.

Addresses: https://github.com/karelzak/util-linux/issues/410
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2017-02-10 16:45:18 +01:00
parent 91cce31a8e
commit bd3457b8d9
2 changed files with 7 additions and 9 deletions

View File

@ -343,16 +343,12 @@ int fdisk_enable_bootbits_protection(struct fdisk_context *cxt, int enable)
* @cxt: fdisk context
* @enable: 1 or 0
*
* The library removes all filesystem/RAID signatures before it writes
* partition table. The probing area where it looks for filesystem/RAID is from
* The library removes all PT/filesystem/RAID signatures before it writes
* partition table. The probing area where it looks for signatures is from
* the begin of the disk. The device is wiped by libblkid.
*
* See also fdisk_wipe_partition().
*
* This is no-op if any collision has not been detected by
* fdisk_assign_device(). See fdisk_get_collision(). The default is not wipe a
* device.
*
* Returns: 0 on success, < 0 on error.
*/
int fdisk_enable_wipe(struct fdisk_context *cxt, int enable)
@ -360,7 +356,7 @@ int fdisk_enable_wipe(struct fdisk_context *cxt, int enable)
if (!cxt)
return -EINVAL;
fdisk_set_wipe_area(cxt, 0, cxt->total_sectors * cxt->sector_size, enable);
fdisk_set_wipe_area(cxt, 0, cxt->total_sectors, enable);
return 0;
}
@ -377,7 +373,7 @@ int fdisk_has_wipe(struct fdisk_context *cxt)
if (!cxt)
return 0;
return fdisk_has_wipe_area(cxt, 0, cxt->total_sectors * cxt->sector_size);
return fdisk_has_wipe_area(cxt, 0, cxt->total_sectors);
}

View File

@ -123,8 +123,10 @@ int fdisk_do_wipe(struct fdisk_context *cxt)
(uintmax_t) start, (uintmax_t) size));
rc = blkid_probe_set_device(pr, cxt->dev_fd, start, size);
if (rc)
if (rc) {
DBG(WIPE, ul_debugobj(wp, "blkid_probe_set_device() failed [rc=%d]", rc));
return rc;
}
blkid_probe_enable_superblocks(pr, 1);
blkid_probe_set_superblocks_flags(pr, BLKID_SUBLKS_MAGIC);