]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: fix fdisk_set_wipe_area() calls
authorKarel Zak <kzak@redhat.com>
Fri, 10 Feb 2017 15:45:18 +0000 (16:45 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 10 Feb 2017 15:45:18 +0000 (16:45 +0100)
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>
libfdisk/src/context.c
libfdisk/src/wipe.c

index 3d0e8754f5ab8ad943ce0d8e8ea4b57bdcd58472..5b0fed928d2c84ed0db48ac9dc5b03f93385c16e 100644 (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);
 }
 
 
index 2c91da57fd02c7df3b3b271c6c12c20679f50305..e773f756db09a811c5b194227a796a0fefb6a42f 100644 (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);