diff options
author | Karel Zak | 2014-04-16 12:51:08 +0200 |
---|---|---|
committer | Karel Zak | 2014-04-16 12:51:08 +0200 |
commit | 8b60872ec01c185b003826adabe3aa4f52c44ad0 (patch) | |
tree | 5dd953e4d49d19f91fbd77425b0921ec3714ecd4 /libfdisk/src/table.c | |
parent | libsmartcols: don't colorize tree ascii art (diff) | |
download | kernel-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.c | 23 |
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 |