From 186d0b5a151545734056f0d1f622f914f4673f2a Mon Sep 17 00:00:00 2001 From: Michael Brandt Date: Mon, 23 Nov 2009 10:31:52 +0100 Subject: added ext2info command Added rudimentary partition info command. It prints currently only basic MBR info. --- common/cmd_ext2.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'common') diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c index b7e4048d6..e37b2b633 100644 --- a/common/cmd_ext2.c +++ b/common/cmd_ext2.c @@ -260,3 +260,67 @@ U_BOOT_CMD( " - load binary file 'filename' from 'dev' on 'interface'\n" " to address 'addr' from ext2 filesystem" ); + +/* + * Ext2fs part info + */ +static int do_ext2info(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int i; + int dev=0; + int part=0; + int startpart, endpart; + char *ep; + disk_partition_t info; + block_dev_desc_t *dev_desc=NULL; + + if (argc < 3) { + cmd_usage(cmdtp); + return 1; + } + dev = (int)simple_strtoul (argv[2], &ep, 16); + dev_desc = get_dev(argv[1],dev); + + if (dev_desc == NULL) { + printf ("\n** Block device %s %d not supported\n", + argv[1], dev); + return 1; + } + + if (*ep) { + if (*ep != ':') { + puts ("\n** Invalid device, use `dev[:part]' **\n"); + return 1; + } + part = (int)simple_strtoul(++ep, NULL, 16); + } + + printf("part: name type start blocks blksize MiB\n"); + if (part == 0) { + startpart = 1; + endpart = 4; + } else { + startpart = part; + endpart = part; + } + for (i = startpart; i <= endpart; i++) { + if (get_partition_info (dev_desc, i, &info)) { + printf ("** Bad partition %d **\n", i); + return 1; + } + + printf("%3d : %s\t%s\t%lu\t%lu\t%d\t%lu\n", i, info.name, + info.type, info.start, info.size, info.blksz, + (unsigned long long) + (info.blksz * info.size) >> 20); + } + + return 0; +} + +U_BOOT_CMD( + ext2info, 3, 1, do_ext2info, + "print partition info", + " \n" + " - print partition table info\n" +); -- cgit v1.2.3