OSDN Git Service

libparted: provide a new convenience function: ptt_geom_clear_sectors
authorJim Meyering <meyering@redhat.com>
Wed, 21 Dec 2011 15:56:17 +0000 (16:56 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 12 Jan 2012 18:09:47 +0000 (19:09 +0100)
* libparted/labels/pt-tools.c (ptt_geom_clear_sectors): New function.
* libparted/labels/pt-tools.h: Declare it.

libparted/labels/pt-tools.c
libparted/labels/pt-tools.h

index a8ac4e4..2693151 100644 (file)
@@ -103,6 +103,14 @@ ptt_clear_sectors (PedDevice *dev, PedSector start, PedSector n)
           ? 1 : ped_device_write (dev, zero, start + n_z_sectors * i, rem));
 }
 
+/* Zero N sectors of GEOM->dev, starting with GEOM->start + START.
+   Return nonzero to indicate success, zero otherwise.  */
+int
+ptt_geom_clear_sectors (PedGeometry *geom, PedSector start, PedSector n)
+{
+  return ptt_clear_sectors (geom->dev, geom->start + start, n);
+}
+
 #include "pt-limit.c"
 
 /* Throw an exception and return 0 if PART's starting sector number or
index ba02977..aa31122 100644 (file)
@@ -22,6 +22,8 @@ int ptt_read_sector (PedDevice const *dev, PedSector sector_num, void **buf);
 int ptt_read_sectors (PedDevice const *dev, PedSector start_sector,
                      PedSector n_sectors, void **buf);
 int ptt_clear_sectors (PedDevice *dev, PedSector start, PedSector count);
+int ptt_geom_clear_sectors (PedGeometry *geom, PedSector start,
+                           PedSector count);
 int ptt_partition_max_start_len (char const *label_type,
                 const PedPartition *part);