From: Karel Zak Date: Tue, 15 Oct 2013 10:17:03 +0000 (+0200) Subject: libfdisk: (dos) all disklabel locate function X-Git-Tag: v2.24~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f32a9be45aa53abe15fe223affb31b08db097e16;p=thirdparty%2Futil-linux.git libfdisk: (dos) all disklabel locate function .. to make 'D'ump expert command usable also for MBR. Yes, we have -rc2 now and this is a new feature, but it's tiny change without any interaction to the rest of the code and without gettext stuff. Signed-off-by: Karel Zak --- diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 3aa40deeae..0456ba5f2f 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -1374,6 +1374,39 @@ done: return rc; } +static int dos_locate_disklabel(struct fdisk_context *cxt, int n, + const char **name, off_t *offset, size_t *size) +{ + assert(cxt); + + *name = NULL; + *offset = 0; + *size = 0; + + switch (n) { + case 0: + *name = "MBR"; + *offset = 0; + *size = 512; + break; + default: + /* extended partitions */ + if (n - 1 + 4 < cxt->label->nparts_max) { + struct pte *pe = self_pte(cxt, n - 1 + 4); + + assert(pe->private_sectorbuffer); + + *name = "EBR"; + *offset = pe->offset * cxt->sector_size; + *size = 512; + } else + return 1; + break; + } + + return 0; +} + static struct fdisk_parttype *dos_get_parttype( struct fdisk_context *cxt, size_t partnum) @@ -1911,6 +1944,7 @@ static const struct fdisk_label_operations dos_operations = .write = dos_write_disklabel, .verify = dos_verify_disklabel, .create = dos_create_disklabel, + .locate = dos_locate_disklabel, .list = dos_list_disklabel, .get_id = dos_get_disklabel_id, .set_id = dos_set_disklabel_id,