summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMichael Brandt <Michael.Brandt@stericsson.com>2009-11-23 10:31:52 +0100
committerMichael Brandt <Michael.Brandt@stericsson.com>2009-11-23 10:31:52 +0100
commit186d0b5a151545734056f0d1f622f914f4673f2a (patch)
treef360a765aa09e104cdc1a3f0c6de5e342fe0fe29 /common
parent509b586bdead191b624099537525b96b6822e06e (diff)
added ext2info command
Added rudimentary partition info command. It prints currently only basic MBR info.
Diffstat (limited to 'common')
-rw-r--r--common/cmd_ext2.c64
1 files changed, 64 insertions, 0 deletions
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",
+ "<interface> <dev[:part]>\n"
+ " - print partition table info\n"
+);