aboutsummaryrefslogtreecommitdiffstats
path: root/com32/hdt/hdt-cli-disk.c
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2009-04-19 21:13:47 -0700
committerPierre-Alexandre Meyer <pierre@mouraf.org>2009-04-19 21:13:47 -0700
commitc66f28e926c0f9ede0976448b2a74489f0aa0bf0 (patch)
tree266dee156c480d0db11c2126bdca50e271c416d6 /com32/hdt/hdt-cli-disk.c
parentcdddfb9f7db5fc1d28fbdd3229823bb912c49c4d (diff)
downloadhdt-c66f28e926c0f9ede0976448b2a74489f0aa0bf0.tar.gz
hdt-c66f28e926c0f9ede0976448b2a74489f0aa0bf0.tar.xz
hdt-c66f28e926c0f9ede0976448b2a74489f0aa0bf0.zip
hdt: Dump partition tables (CLI)
Use the new disk API to read mbrs and dump information about detected primary partitions. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
Diffstat (limited to 'com32/hdt/hdt-cli-disk.c')
-rw-r--r--com32/hdt/hdt-cli-disk.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/com32/hdt/hdt-cli-disk.c b/com32/hdt/hdt-cli-disk.c
index a035b58c..01db50ba 100644
--- a/com32/hdt/hdt-cli-disk.c
+++ b/com32/hdt/hdt-cli-disk.c
@@ -32,6 +32,8 @@
#include <errno.h>
#include <disk/geom.h>
+#include <disk/read.h>
+#include <disk/util.h>
#include "hdt-cli.h"
#include "hdt-common.h"
@@ -63,6 +65,27 @@ void main_show_disk(int argc __unused, char **argv __unused,
(int) d->edd_params.sectors_per_track);
more_printf(" Host bus: %s, Interface type: %s\n\n",
d->edd_params.host_bus_type, d->edd_params.interface_type);
+
+ char *mbr = read_mbr(d->disk);
+ if (!mbr) {
+ more_printf("Unable to read the mbr.");
+ continue;
+ }
+
+ more_printf(" # Boot Start End Blocks Id Type\n");
+ struct part_entry *ptab = (struct part_entry *)(mbr + PARTITION_TABLES_OFFSET);
+ for (int i = 0; i < 4; i++) {
+ char *parttype;
+ if (ptab[i].ostype) {
+ get_label(ptab[i].ostype, &parttype);
+ more_printf(" %d %s %8d %8d %8d %02X %s\n",
+ i, (ptab[i].active_flag == 0x80) ? " x " : " ",
+ ptab[i].start_lba,
+ ptab[i].start_lba + ptab[i].length, ptab[i].length,
+ ptab[i].ostype, parttype);
+ free(parttype);
+ }
+ }
}
}