[U-Boot] [PATCH V4 09/12] sandbox: implement exists() function

Stephen Warren swarren at wwwdotorg.org
Mon Feb 3 21:21:07 CET 2014


From: Stephen Warren <swarren at nvidia.com>

This hooks into the generic "file exists" support added in an earlier
patch, and provides an implementation for the sandbox test environment.

Signed-off-by: Stephen Warren <swarren at nvidia.com>
Acked-by: Simon Glass <sjg at chromium.org>
---
v4: No change.
v3:
* Remove "sb exists" command; it's part of "test" now.
* Invert return value of exists(), per change to previous patch.
v2: No change.
---
 fs/fs.c                | 2 +-
 fs/sandbox/sandboxfs.c | 8 ++++++++
 include/sandboxfs.h    | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/fs.c b/fs/fs.c
index aaa6732a879c..2e60f57bc450 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -114,7 +114,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 dd028da8e32b..85079788c990 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;
+}
+
 void sandbox_fs_close(void)
 {
 }
diff --git a/include/sandboxfs.h b/include/sandboxfs.h
index 8ea8cb7e2e62..a51ad13044e1 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.1.5



More information about the U-Boot mailing list