From e8ae49476e5391fc477adb75d891c6b43543ded8 Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Thu, 11 Nov 2010 10:34:52 -0300 Subject: [PATCH] libblkid: add blkid_probe_get_sectors() This function allows users to obtain the device's 512-byte sector count. Signed-off-by: Davidlohr Bueso Signed-off-by: Karel Zak --- shlibs/blkid/docs/libblkid-sections.txt | 1 + shlibs/blkid/src/blkid.h.in | 1 + shlibs/blkid/src/blkid.sym | 1 + shlibs/blkid/src/probe.c | 11 +++++++++++ 4 files changed, 14 insertions(+) diff --git a/shlibs/blkid/docs/libblkid-sections.txt b/shlibs/blkid/docs/libblkid-sections.txt index c8b0045d..47675f4a 100644 --- a/shlibs/blkid/docs/libblkid-sections.txt +++ b/shlibs/blkid/docs/libblkid-sections.txt @@ -42,6 +42,7 @@ blkid_new_probe blkid_new_probe_from_filename blkid_probe_get_devno blkid_probe_get_sectorsize +blkid_probe_get_sectors blkid_probe_get_size blkid_probe_set_device blkid_reset_probe diff --git a/shlibs/blkid/src/blkid.h.in b/shlibs/blkid/src/blkid.h.in index 7fa2fde6..46cbeb23 100644 --- a/shlibs/blkid/src/blkid.h.in +++ b/shlibs/blkid/src/blkid.h.in @@ -203,6 +203,7 @@ extern int blkid_probe_is_wholedisk(blkid_probe pr); extern blkid_loff_t blkid_probe_get_size(blkid_probe pr); extern blkid_loff_t blkid_probe_get_offset(blkid_probe pr); extern unsigned int blkid_probe_get_sectorsize(blkid_probe pr); +extern blkid_loff_t blkid_probe_get_sectors(blkid_probe pr); extern int blkid_probe_get_fd(blkid_probe pr); diff --git a/shlibs/blkid/src/blkid.sym b/shlibs/blkid/src/blkid.sym index 4085d2ce..f6e488a9 100644 --- a/shlibs/blkid/src/blkid.sym +++ b/shlibs/blkid/src/blkid.sym @@ -100,6 +100,7 @@ global: blkid_probe_get_devno; blkid_probe_get_partitions; blkid_probe_get_sectorsize; + blkid_probe_get_sectors; blkid_probe_get_size; blkid_probe_get_topology; blkid_probe_invert_partitions_filter; diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c index a748f2e2..3698b99b 100644 --- a/shlibs/blkid/src/probe.c +++ b/shlibs/blkid/src/probe.c @@ -1187,6 +1187,17 @@ unsigned int blkid_probe_get_sectorsize(blkid_probe pr) return pr->blkssz; } +/** + * blkid_probe_get_sectors: + * @pr: probe + * + * Returns: 512-byte sector count or -1 in case of error. + */ +blkid_loff_t blkid_probe_get_sectors(blkid_probe pr) +{ + return pr ? pr->size >> 9 : -1; +} + /** * blkid_probe_numof_values: * @pr: probe -- 2.39.5