Signed-off-by: Karel Zak <kzak@redhat.com>
struct fdisk_table *tb,
struct fdisk_iter *itr,
struct fdisk_partition **pa);
+
+extern struct fdisk_partition *fdisk_table_get_partition(
+ struct fdisk_table *tb,
+ size_t n);
+
/* alignment.c */
extern int fdisk_reset_alignment(struct fdisk_context *cxt);
extern int fdisk_reset_device_properties(struct fdisk_context *cxt);
return rc;
}
+struct fdisk_partition *fdisk_table_get_partition(
+ struct fdisk_table *tb,
+ size_t n)
+{
+ struct fdisk_partition *pa = NULL;
+ struct fdisk_iter itr;
+
+ if (!tb)
+ return NULL;
+
+ fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
+
+ while (fdisk_table_next_partition(tb, &itr, &pa) == 0) {
+ if (n == 0)
+ return pa;
+ n--;
+ }
+
+ return NULL;
+}
+
/**
* fdisk_table_add_partition
* @tb: tab pointer