diff options
author | Che-Liang Chiou <clchiou@chromium.org> | 2011-07-20 18:42:29 +0800 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-08-29 10:59:03 -0700 |
commit | bce870b71d2af4ee8a7989db7b0fe2b5e4cdd550 (patch) | |
tree | 2c6873576c0e9ac4e61adceceec1329eac8b8fb5 | |
parent | 7382683d723ce5106d92102c522ed4251551cec4 (diff) |
CHROMIUM: fix error of showing eMMC as a removable disk
It is too bad that I did not catch this when I tested the cleanup patch.
To avoid that from happening again, more checks are added to
"vbexport_test diskinfo" that prints out an error message when the flag
of any probed storage device mismatches the given flag.
BUG=chromium-os:16542
TEST=manual
When no SD card and USB key is inserted, vbexport_test diskinfo prints
"No disk found!" under "Detecting all removable disks..." test.
Change-Id: I0e20a6337c7cd638b883cf36416fdb3ae5bd3071
Reviewed-on: http://gerrit.chromium.org/gerrit/4392
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Tammo Spalink <tammo@chromium.org>
-rw-r--r-- | common/cmd_vbexport_test.c | 10 | ||||
-rw-r--r-- | lib/vbexport/boot_device.c | 14 |
2 files changed, 16 insertions, 8 deletions
diff --git a/common/cmd_vbexport_test.c b/common/cmd_vbexport_test.c index 7da84a09933..72389170ac0 100644 --- a/common/cmd_vbexport_test.c +++ b/common/cmd_vbexport_test.c @@ -185,16 +185,22 @@ static int do_vbexport_test_diskinfo_flags(uint32_t flags) } else { VbExDebug("handle byte/lba lba_count f name\n"); for (i = 0; i < count; i++) { - VbExDebug("%08lx %-9llu %-10llu %-2lu %s\n", + VbExDebug("%08lx %-9llu %-10llu %-2lu %s", info[i].handle, info[i].bytes_per_lba, info[i].lba_count, info[i].flags, info[i].name); + + if (!(flags & info[i].flags)) { + VbExDebug(" INCORRECT: flag mismatched\n"); + ret = 1; + } else + VbExDebug("\n"); } } - return VbExDiskFreeInfo(info, NULL); + return VbExDiskFreeInfo(info, NULL) || ret; } static int do_vbexport_test_diskinfo( diff --git a/lib/vbexport/boot_device.c b/lib/vbexport/boot_device.c index b6aa95b4495..059c521c0f5 100644 --- a/lib/vbexport/boot_device.c +++ b/lib/vbexport/boot_device.c @@ -119,19 +119,20 @@ VbError_t VbExDiskGetInfo(VbDiskInfo** infos_ptr, uint32_t* count_ptr, if (!(disk_flags & VB_DISK_FLAG_REMOVABLE)) iterators[1] = NULL; + /* + * If too many storage devices registered, we return as many disk infos + * as possible. + */ for (func_index = 0; count < max_count && (iter = iterators[func_index]); func_index++) { if (iter == iterate_usb_device) init_usb_storage(); - /* - * If too many storage devices registered, we return as many - * disk infos as possible. - */ - for (i = 0; count < max_count && (dev = iter(&i)); count++) { - flags = get_dev_flags(dev); + i = 0; + while (count < max_count && (dev = iter(&i))) { /* Skip this entry if the flags are not matched. */ + flags = get_dev_flags(dev); if (!(flags & disk_flags)) continue; @@ -140,6 +141,7 @@ VbError_t VbExDiskGetInfo(VbDiskInfo** infos_ptr, uint32_t* count_ptr, infos[count].lba_count = dev->lba; infos[count].flags = flags; infos[count].name = get_dev_name(dev); + count++; } } |