From: Karel Zak Date: Wed, 15 Jan 2014 09:52:47 +0000 (+0100) Subject: partx: use blkid_partlist_get_partition_by_partno() X-Git-Tag: v2.25-rc1~637 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c62f164cf15c23b7bdc03e59707c1d609b472c50;p=thirdparty%2Futil-linux.git partx: use blkid_partlist_get_partition_by_partno() Signed-off-by: Karel Zak --- diff --git a/disk-utils/partx.c b/disk-utils/partx.c index df03e591e3..ec48047c49 100644 --- a/disk-utils/partx.c +++ b/disk-utils/partx.c @@ -412,37 +412,6 @@ static void upd_parts_warnx(const char *device, int first, int last) device, first, last); } -/** - * get_partition_by_partno: - * @ls: partitions list - * @n: the partition number (e.g. 'N' from sda'N') - * - * This does not assume any order of the input blkid_partlist. - * And correctly handles "out of order" partition tables. - * partition N is located after partition N+1 on the disk. - * - * Returns: partition object or NULL in case or error. - */ -blkid_partition get_partition_by_partno(blkid_partlist ls, int n) -{ - int i, nparts; - blkid_partition par; - if (!ls) - return NULL; - - nparts = blkid_partlist_numof_partitions(ls); - if (nparts < 0) - return NULL; - - for (i = 0; i < nparts; i++) { - par = blkid_partlist_get_partition(ls, i); - if (n == blkid_partition_get_partno(par)) { - return par; - } - } - return NULL; -} - static int upd_parts(int fd, const char *device, dev_t devno, blkid_partlist ls, int lower, int upper) { @@ -473,7 +442,7 @@ static int upd_parts(int fd, const char *device, dev_t devno, } for (n = lower; n <= upper; n++) { - par = get_partition_by_partno(ls, n); + par = blkid_partlist_get_partition_by_partno(ls, n); if (!par) { if (verbose) warn(_("%s: no partition #%d"), device, n);