]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: add blkid_partitions_get_name()
authorSami Kerola <kerolasa@iki.fi>
Thu, 13 Apr 2017 16:52:35 +0000 (17:52 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 2 May 2017 22:22:04 +0000 (23:22 +0100)
This new function can be use to enquiry what partition names libblkid is
aware of.  First use of this information will be in partx(8) to make bash
completion to work without a magic list.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
libblkid/docs/libblkid-sections.txt
libblkid/src/blkid.h.in
libblkid/src/libblkid.sym
libblkid/src/partitions/partitions.c

index 78db25ec98b01442e167865fd57c333d458f8674..00d553ee10954238f03d87bd2fb052cf98954343 100644 (file)
@@ -86,6 +86,7 @@ blkid_probe_invert_partitions_filter
 blkid_probe_reset_partitions_filter
 <SUBSECTION>
 blkid_known_pttype
+blkid_partitions_get_name
 <SUBSECTION>
 blkid_partition_get_name
 blkid_partition_get_flags
index 06e2c1771d6ddc857ae3c831227ca44358d36083..e8e8fa5634dd183b2d815c33fe139b81df694765 100644 (file)
@@ -326,6 +326,7 @@ extern unsigned long blkid_topology_get_physical_sector_size(blkid_topology tp)
  * partitions probing
  */
 extern int blkid_known_pttype(const char *pttype);
+extern int blkid_partitions_get_name(const size_t idx, const char **name);
 
 extern int blkid_probe_enable_partitions(blkid_probe pr, int enable)
                        __ul_attribute__((nonnull));
index cd76d6592a99293c35887d27f3aace45ed2d0b88..164e115b575376a2ee2db970d106b9a79b17eb47 100644 (file)
@@ -167,4 +167,5 @@ BLKID_2.25 {
 
 BLKID_2.30 {
        blkid_probe_set_sectorsize;
+       blkid_partitions_get_name;
 } BLKID_2.25;
index 533209761cfdd79951d32f4d02fd05c6b279bada..e2453ba8a32f252e921bb2ccc7cded7a9cba206e 100644 (file)
@@ -886,6 +886,22 @@ int blkid_known_pttype(const char *pttype)
        return 0;
 }
 
+/**
+ * blkid_partitions_get_name:
+ * @idx: number >= 0
+ * @name: returns name of a supported partition
+ *
+ * Returns: -1 if @idx is out of range, or 0 on success.
+ */
+int blkid_partitions_get_name(const size_t idx, const char **name)
+{
+       if (idx < ARRAY_SIZE(idinfos)) {
+               *name = idinfos[idx]->name;
+               return 0;
+       }
+       return -1;
+}
+
 /**
  * blkid_partlist_numof_partitions:
  * @ls: partitions list