summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-15 18:11:11 +1300
committerSimon Glass <sjg@chromium.org>2021-03-27 15:04:31 +1300
commit1758551ec9526d56303a2b5cf1f58147e66945ed (patch)
tree8e8b35f4dadae793cd6668d10f958f0337191806 /cmd
parent803e9c1c94d06cfab43606056c653268e12926d8 (diff)
downloadu-boot-1758551ec9526d56303a2b5cf1f58147e66945ed.tar.gz
sandbox: Provide a way to bind fixed/removeable devices
At present when a file is bound to a host device it is always marked as removeable. Arguably the device is removeable, since it can be unbound at will. However while it is bound, it is not considered removable by the user. Also it is useful to be able to model both fixed and removeable devices for code that distinguishes them. Add a -r flag to the 'host bind' command and plumb it through to provide this feature. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/host.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/cmd/host.c b/cmd/host.c
index 847bb1d3b5..6aa3d9167a 100644
--- a/cmd/host.c
+++ b/cmd/host.c
@@ -41,6 +41,7 @@ static int do_host_save(struct cmd_tbl *cmdtp, int flag, int argc,
static int do_host_bind(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
+ bool removable = false;
const char *dev_str;
char *file;
char *ep;
@@ -49,7 +50,16 @@ static int do_host_bind(struct cmd_tbl *cmdtp, int flag, int argc,
/* Skip 'bind' */
argc--;
argv++;
- if (argc < 1 || argv > 2)
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ if (!strcmp(argv[0], "-r")) {
+ removable = true;
+ argc--;
+ argv++;
+ }
+
+ if (argc > 2)
return CMD_RET_USAGE;
dev_str = argv[0];
dev = simple_strtoul(dev_str, &ep, 16);
@@ -59,7 +69,7 @@ static int do_host_bind(struct cmd_tbl *cmdtp, int flag, int argc,
}
file = argc > 1 ? argv[1] : NULL;
- return !!host_dev_bind(dev, file);
+ return !!host_dev_bind(dev, file, removable);
}
static int do_host_info(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -154,7 +164,7 @@ static struct cmd_tbl cmd_host_sub[] = {
U_BOOT_CMD_MKENT(ls, 3, 0, do_host_ls, "", ""),
U_BOOT_CMD_MKENT(save, 6, 0, do_host_save, "", ""),
U_BOOT_CMD_MKENT(size, 3, 0, do_host_size, "", ""),
- U_BOOT_CMD_MKENT(bind, 3, 0, do_host_bind, "", ""),
+ U_BOOT_CMD_MKENT(bind, 4, 0, do_host_bind, "", ""),
U_BOOT_CMD_MKENT(info, 3, 0, do_host_info, "", ""),
U_BOOT_CMD_MKENT(dev, 0, 1, do_host_dev, "", ""),
};
@@ -186,7 +196,8 @@ U_BOOT_CMD(
"host save hostfs - <addr> <filename> <bytes> [<offset>] - "
"save a file to host\n"
"host size hostfs - <filename> - determine size of file on host\n"
- "host bind <dev> [<filename>] - bind \"host\" device to file\n"
+ "host bind [-r] <dev> [<filename>] - bind \"host\" device to file\n"
+ " -r = mark as removable\n"
"host info [<dev>] - show device binding & info\n"
"host dev [<dev>] - Set or retrieve the current host device\n"
"host commands use the \"hostfs\" device. The \"host\" device is used\n"