summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/dos.c
diff options
context:
space:
mode:
authorKarel Zak2013-10-15 12:17:03 +0200
committerKarel Zak2013-10-15 12:21:28 +0200
commitf32a9be45aa53abe15fe223affb31b08db097e16 (patch)
tree045eb5fe7e81d65343e657959f322ab5bad29677 /libfdisk/src/dos.c
parentdocs: tweak formatting and grammar of the ipcrm man page (diff)
downloadkernel-qcow2-util-linux-f32a9be45aa53abe15fe223affb31b08db097e16.tar.gz
kernel-qcow2-util-linux-f32a9be45aa53abe15fe223affb31b08db097e16.tar.xz
kernel-qcow2-util-linux-f32a9be45aa53abe15fe223affb31b08db097e16.zip
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 <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/dos.c')
-rw-r--r--libfdisk/src/dos.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
index 3aa40deea..0456ba5f2 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,