summaryrefslogtreecommitdiffstats
path: root/shlibs/blkid/src/partitions
diff options
context:
space:
mode:
authorKarel Zak2010-04-23 13:35:20 +0200
committerKarel Zak2010-04-23 13:35:20 +0200
commit19f87d1d366694d0ad8b504f7fd88476e3cdc018 (patch)
tree6943a75c8f3a9fc946c4c4c5ba9e0ac735141c2e /shlibs/blkid/src/partitions
parentlibblkid: don't gather PART_ENTRY_* values for binary interface (diff)
downloadkernel-qcow2-util-linux-19f87d1d366694d0ad8b504f7fd88476e3cdc018.tar.gz
kernel-qcow2-util-linux-19f87d1d366694d0ad8b504f7fd88476e3cdc018.tar.xz
kernel-qcow2-util-linux-19f87d1d366694d0ad8b504f7fd88476e3cdc018.zip
libblkid: add blkid_partlist_get_table()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/partitions')
-rw-r--r--shlibs/blkid/src/partitions/partitions.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/shlibs/blkid/src/partitions/partitions.c b/shlibs/blkid/src/partitions/partitions.c
index 259284d84..9c151ef62 100644
--- a/shlibs/blkid/src/partitions/partitions.c
+++ b/shlibs/blkid/src/partitions/partitions.c
@@ -278,9 +278,6 @@ int blkid_probe_filter_partitions_type(blkid_probe pr, int flag, char *names[])
* use more blkid_partlist objects in the same time you have to create
* more blkid_probe handlers (see blkid_new_probe()).
*
- * TODO: add blkid_ref() and blkid_unref() to allows to use blkid_partlist
- * independently on libblkid probing stuff.
- *
* Returns: list of partitions, or NULL in case of error.
*/
blkid_partlist blkid_probe_get_partitions(blkid_probe pr)
@@ -607,9 +604,10 @@ static int partitions_probe(blkid_probe pr, struct blkid_chain *chn)
name = idinfos[i]->name;
/* all checks passed */
- blkid_probe_set_value(pr, "PTTYPE",
- (unsigned char *) name, strlen(name) + 1);
-
+ if (!chn->binary)
+ blkid_probe_set_value(pr, "PTTYPE",
+ (unsigned char *) name,
+ strlen(name) + 1);
DBG(DEBUG_LOWPROBE,
printf("<-- leaving probing loop (type=%s) [PARTS idx=%d]\n",
name, chn->idx));
@@ -879,17 +877,30 @@ int blkid_partlist_numof_partitions(blkid_partlist ls)
}
/**
+ * blkid_partlist_get_table:
+ *
+ * Returns top-level partition table or NULL of there is not a partition table
+ * on the device.
+ */
+blkid_parttable blkid_partlist_get_table(blkid_partlist ls)
+{
+ if (!ls || list_empty(&ls->l_tabs))
+ return NULL;
+
+ return list_entry(ls->l_tabs.next,
+ struct blkid_struct_parttable, t_tabs);
+}
+
+
+/**
* blkid_partlist_get_partition:
* @ls: partitions list
* @n: partition number in range 0..N, where 'N' is blkid_partlist_numof_partitions().
*
* It's possible that the list of partitions is *empty*, but there is a valid
* partition table on the disk. This happen when on-disk details about
- * partitions are unknown, but we are able to detect partition table magic
- * string only. The nice example is AIX. If your question is: "Is there any
- * partition table?", use:
- *
- * blkid_probe_lookup_value(pr, "PTTYPE", &type, NULL);
+ * partitions are unknown or the partition table is empty. The nice example is
+ * AIX. See also blkid_partlist_get_table().
*
* Returns: partition object or NULL in case or error.
*/