summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/table.c
diff options
context:
space:
mode:
authorKarel Zak2014-04-16 12:51:08 +0200
committerKarel Zak2014-04-16 12:51:08 +0200
commit8b60872ec01c185b003826adabe3aa4f52c44ad0 (patch)
tree5dd953e4d49d19f91fbd77425b0921ec3714ecd4 /libfdisk/src/table.c
parentlibsmartcols: don't colorize tree ascii art (diff)
downloadkernel-qcow2-util-linux-8b60872ec01c185b003826adabe3aa4f52c44ad0.tar.gz
kernel-qcow2-util-linux-8b60872ec01c185b003826adabe3aa4f52c44ad0.tar.xz
kernel-qcow2-util-linux-8b60872ec01c185b003826adabe3aa4f52c44ad0.zip
libfdisk: add generic function to check partitions order
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/table.c')
-rw-r--r--libfdisk/src/table.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libfdisk/src/table.c b/libfdisk/src/table.c
index add6bd983..27365c040 100644
--- a/libfdisk/src/table.c
+++ b/libfdisk/src/table.c
@@ -526,6 +526,29 @@ done:
}
/**
+ * fdisk_table_wrong_order:
+ * @tb: table
+ *
+ * Returns: 1 of the table is not in disk order
+ */
+int fdisk_table_wrong_order(struct fdisk_table *tb)
+{
+ struct fdisk_partition *pa;
+ struct fdisk_iter itr;
+ sector_t last = 0;
+
+ DBG(TAB, ul_debugobj(tb, "wrong older check"));
+
+ fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
+ while (tb && fdisk_table_next_partition(tb, &itr, &pa) == 0) {
+ if (pa->start < last)
+ return 1;
+ last = pa->start;
+ }
+ return 0;
+}
+
+/**
* fdisk_table_to_string
* @tb: table
* @cxt: fdisk context