Commit 4d907025d6a530c0f3d2e869331e863c3e3cc3c2
Committed by
Simon Glass
1 parent
dbb7234b2a
Exists in
v2017.01-smarct4x
and in
40 other branches
sandbox: restore ability to access host fs through standard commands
Commit 95fac6ab4589 "sandbox: Use os functions to read host device tree" removed the ability for get_device_and_partition() to handle the "host" device type, and redirect accesses to it to the host filesystem. This broke some unit tests that use this feature. So, revert that change. The code added back by this patch is slightly different to pacify checkpatch. However, we're then left with "host" being both: - A pseudo device that accesses the hosts real filesystem. - An emulated block device, which accesses "sectors" inside a file stored on the host. In order to resolve this discrepancy, rename the pseudo device from host to hostfs, and adjust the unit-tests for this change. The "help sb" output is modified to reflect this rename, and state where the host and hostfs devices should be used. Signed-off-by: Stephen Warren <swarren@nvidia.com> Tested-by: Josh Wu <josh.wu@atmel.com> Acked-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
Showing 4 changed files with 30 additions and 9 deletions Side-by-side Diff
common/cmd_sandbox.c
... | ... | @@ -114,12 +114,14 @@ |
114 | 114 | U_BOOT_CMD( |
115 | 115 | sb, 8, 1, do_sandbox, |
116 | 116 | "Miscellaneous sandbox commands", |
117 | - "load host <dev> <addr> <filename> [<bytes> <offset>] - " | |
117 | + "load hostfs - <addr> <filename> [<bytes> <offset>] - " | |
118 | 118 | "load a file from host\n" |
119 | - "sb ls host <filename> - list files on host\n" | |
120 | - "sb save host <dev> <filename> <addr> <bytes> [<offset>] - " | |
119 | + "sb ls hostfs - <filename> - list files on host\n" | |
120 | + "sb save hostfs - <filename> <addr> <bytes> [<offset>] - " | |
121 | 121 | "save a file to host\n" |
122 | 122 | "sb bind <dev> [<filename>] - bind \"host\" device to file\n" |
123 | - "sb info [<dev>] - show device binding & info" | |
123 | + "sb info [<dev>] - show device binding & info\n" | |
124 | + "sb commands use the \"hostfs\" device. The \"host\" device is used\n" | |
125 | + "with standard IO commands such as fatls or ext2load" | |
124 | 126 | ); |
disk/part.c
... | ... | @@ -510,6 +510,25 @@ |
510 | 510 | int part; |
511 | 511 | disk_partition_t tmpinfo; |
512 | 512 | |
513 | + /* | |
514 | + * Special-case a psuedo block device "hostfs", to allow access to the | |
515 | + * host's own filesystem. | |
516 | + */ | |
517 | + if (0 == strcmp(ifname, "hostfs")) { | |
518 | + *dev_desc = NULL; | |
519 | + info->start = 0; | |
520 | + info->size = 0; | |
521 | + info->blksz = 0; | |
522 | + info->bootable = 0; | |
523 | + strcpy((char *)info->type, BOOT_PART_TYPE); | |
524 | + strcpy((char *)info->name, "Sandbox host"); | |
525 | +#ifdef CONFIG_PARTITION_UUIDS | |
526 | + info->uuid[0] = 0; | |
527 | +#endif | |
528 | + | |
529 | + return 0; | |
530 | + } | |
531 | + | |
513 | 532 | /* If no dev_part_str, use bootdevice environment variable */ |
514 | 533 | if (!dev_part_str || !strlen(dev_part_str) || |
515 | 534 | !strcmp(dev_part_str, "-")) |
test/command_ut.c
... | ... | @@ -165,12 +165,12 @@ |
165 | 165 | |
166 | 166 | #ifdef CONFIG_SANDBOX |
167 | 167 | /* File existence */ |
168 | - HUSH_TEST(e, "-e host - creating_this_file_breaks_uboot_unit_test", n); | |
169 | - run_command("sb save host - creating_this_file_breaks_uboot_unit_test 0 1", 0); | |
170 | - HUSH_TEST(e, "-e host - creating_this_file_breaks_uboot_unit_test", y); | |
168 | + HUSH_TEST(e, "-e hostfs - creating_this_file_breaks_uboot_unit_test", n); | |
169 | + run_command("sb save hostfs - creating_this_file_breaks_uboot_unit_test 0 1", 0); | |
170 | + HUSH_TEST(e, "-e hostfs - creating_this_file_breaks_uboot_unit_test", y); | |
171 | 171 | /* Perhaps this could be replaced by an "rm" shell command one day */ |
172 | 172 | assert(!os_unlink("creating_this_file_breaks_uboot_unit_test")); |
173 | - HUSH_TEST(e, "-e host - creating_this_file_breaks_uboot_unit_test", n); | |
173 | + HUSH_TEST(e, "-e hostfs - creating_this_file_breaks_uboot_unit_test", n); | |
174 | 174 | #endif |
175 | 175 | #endif |
176 | 176 |
test/vboot/vboot_test.sh