]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: add blkid_probe_set_sectorsize()
authorKarel Zak <kzak@redhat.com>
Fri, 13 Jan 2017 12:26:37 +0000 (13:26 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 13 Jan 2017 12:26:37 +0000 (13:26 +0100)
The usual way is to use ioctl to ask block device for sector size, but
this is useless for disk images (regular files). And the default
(512-bytes) may be pretty wrong for disk images from 4K disks. Let's
support a way how to specify proper sector size.

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/docs/libblkid-sections.txt
libblkid/src/blkid.h.in
libblkid/src/libblkid.sym
libblkid/src/probe.c

index 53cf84b7845b75d2afb9c1cd2c9ce7b0da66f37b..78db25ec98b01442e167865fd57c333d458f8674 100644 (file)
@@ -56,6 +56,7 @@ blkid_probe_get_size
 blkid_probe_get_wholedisk_devno
 blkid_probe_is_wholedisk
 blkid_probe_set_device
+blkid_probe_set_sectorsize
 blkid_probe_step_back
 blkid_reset_probe
 </SECTION>
index d7bbced7ff6f5f5041a142c8738291ab2392709e..06e2c1771d6ddc857ae3c831227ca44358d36083 100644 (file)
@@ -243,6 +243,8 @@ extern blkid_loff_t blkid_probe_get_offset(blkid_probe pr)
                        __ul_attribute__((nonnull));
 extern unsigned int blkid_probe_get_sectorsize(blkid_probe pr)
                        __ul_attribute__((nonnull));
+extern int blkid_probe_set_sectorsize(blkid_probe pr, unsigned int sz)
+                       __ul_attribute__((nonnull));
 extern blkid_loff_t blkid_probe_get_sectors(blkid_probe pr)
                        __ul_attribute__((nonnull));
 
index 6b3cf08054b32484cd45627cf40f57c72964f369..cd76d6592a99293c35887d27f3aace45ed2d0b88 100644 (file)
@@ -164,3 +164,7 @@ global:
 BLKID_2.25 {
        blkid_partlist_get_partition_by_partno;
 } BLKID_2.23;
+
+BLKID_2.30 {
+       blkid_probe_set_sectorsize;
+} BLKID_2.25;
index ea50f5a6b31d43b9cbc341ae2355926f5955141f..df90a82e09446eae24856bfeea99d75f12003c2a 100644 (file)
@@ -1671,6 +1671,22 @@ unsigned int blkid_probe_get_sectorsize(blkid_probe pr)
        return pr->blkssz;
 }
 
+/**
+ * blkid_probe_set_sectorsize:
+ * @pr: probe
+ * @sz: new size (to overwrite system default)
+ *
+ * Note that blkid_probe_set_device() resets this setting. Use it after
+ * blkid_probe_set_device() and before any probing call.
+ *
+ * Returns: 0 or <0 in case of error
+ */
+int blkid_probe_set_sectorsize(blkid_probe pr, unsigned int sz)
+{
+       pr->blkssz = sz;
+       return 0;
+}
+
 /**
  * blkid_probe_get_sectors:
  * @pr: probe