summaryrefslogtreecommitdiffstats
path: root/0009-sandbox-implement-fs_exists-and-sb-exists-shell-func.patch
diff options
context:
space:
mode:
Diffstat (limited to '0009-sandbox-implement-fs_exists-and-sb-exists-shell-func.patch')
-rw-r--r--0009-sandbox-implement-fs_exists-and-sb-exists-shell-func.patch90
1 files changed, 90 insertions, 0 deletions
diff --git a/0009-sandbox-implement-fs_exists-and-sb-exists-shell-func.patch b/0009-sandbox-implement-fs_exists-and-sb-exists-shell-func.patch
new file mode 100644
index 0000000..63b2d3c
--- /dev/null
+++ b/0009-sandbox-implement-fs_exists-and-sb-exists-shell-func.patch
@@ -0,0 +1,90 @@
+From f52cf070507513fa86debe8cce61f71ca2771b44 Mon Sep 17 00:00:00 2001
+From: Stephen Warren <swarren@nvidia.com>
+Date: Thu, 23 Jan 2014 12:56:58 -0700
+Subject: [PATCH 09/13] sandbox: implement fs_exists() and 'sb exists' shell
+ function
+
+This hooks into the generic "file exists" support added in the previous
+patch, and provides an implementation for the sandbox test environment.
+
+Signed-off-by: Stephen Warren <swarren@nvidia.com>
+Acked-by: Simon Glass <sjg@chromium.org>
+---
+ common/cmd_sandbox.c | 7 +++++++
+ fs/fs.c | 2 +-
+ fs/sandbox/sandboxfs.c | 8 ++++++++
+ include/sandboxfs.h | 1 +
+ 4 files changed, 17 insertions(+), 1 deletion(-)
+
+diff --git a/common/cmd_sandbox.c b/common/cmd_sandbox.c
+index 00982b1..c8d36b7 100644
+--- a/common/cmd_sandbox.c
++++ b/common/cmd_sandbox.c
+@@ -22,6 +22,12 @@ static int do_sandbox_ls(cmd_tbl_t *cmdtp, int flag, int argc,
+ return do_ls(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);
+ }
+
++static int do_sandbox_exists(cmd_tbl_t *cmdtp, int flag, int argc,
++ char * const argv[])
++{
++ return do_exists(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);
++}
++
+ static int do_sandbox_save(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+ {
+@@ -88,6 +94,7 @@ static int do_sandbox_info(cmd_tbl_t *cmdtp, int flag, int argc,
+ static cmd_tbl_t cmd_sandbox_sub[] = {
+ U_BOOT_CMD_MKENT(load, 7, 0, do_sandbox_load, "", ""),
+ U_BOOT_CMD_MKENT(ls, 3, 0, do_sandbox_ls, "", ""),
++ U_BOOT_CMD_MKENT(exists, 3, 0, do_sandbox_exists, "", ""),
+ U_BOOT_CMD_MKENT(save, 6, 0, do_sandbox_save, "", ""),
+ U_BOOT_CMD_MKENT(bind, 3, 0, do_sandbox_bind, "", ""),
+ U_BOOT_CMD_MKENT(info, 3, 0, do_sandbox_info, "", ""),
+diff --git a/fs/fs.c b/fs/fs.c
+index f3d9a1c..4f344c6 100644
+--- a/fs/fs.c
++++ b/fs/fs.c
+@@ -102,7 +102,7 @@ static struct fstype_info fstypes[] = {
+ .probe = sandbox_fs_set_blk_dev,
+ .close = sandbox_fs_close,
+ .ls = sandbox_fs_ls,
+- .exists = fs_exists_unsupported,
++ .exists = sandbox_fs_exists,
+ .read = fs_read_sandbox,
+ .write = fs_write_sandbox,
+ },
+diff --git a/fs/sandbox/sandboxfs.c b/fs/sandbox/sandboxfs.c
+index dd028da..7940c93 100644
+--- a/fs/sandbox/sandboxfs.c
++++ b/fs/sandbox/sandboxfs.c
+@@ -72,6 +72,14 @@ int sandbox_fs_ls(const char *dirname)
+ return 0;
+ }
+
++int sandbox_fs_exists(const char *filename)
++{
++ ssize_t sz;
++
++ sz = os_get_filesize(filename);
++ return (sz >= 0) ? 0 : -1;
++}
++
+ void sandbox_fs_close(void)
+ {
+ }
+diff --git a/include/sandboxfs.h b/include/sandboxfs.h
+index 8ea8cb7..a51ad13 100644
+--- a/include/sandboxfs.h
++++ b/include/sandboxfs.h
+@@ -25,6 +25,7 @@ long sandbox_fs_read_at(const char *filename, unsigned long pos,
+
+ void sandbox_fs_close(void);
+ int sandbox_fs_ls(const char *dirname);
++int sandbox_fs_exists(const char *filename);
+ int fs_read_sandbox(const char *filename, void *buf, int offset, int len);
+ int fs_write_sandbox(const char *filename, void *buf, int offset, int len);
+
+--
+1.8.5.3
+