sandbox: implement exists() function
authorStephen Warren <swarren@nvidia.com>
Mon, 3 Feb 2014 20:21:07 +0000 (13:21 -0700)
committerTom Rini <trini@ti.com>
Wed, 19 Feb 2014 14:47:34 +0000 (09:47 -0500)
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@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
fs/fs.c
fs/sandbox/sandboxfs.c
include/sandboxfs.h

diff --git a/fs/fs.c b/fs/fs.c
index aaa6732a879c7d8c61b310a0b491c1cf17f0f302..2e60f57bc450dc547e5ac2ff3a84a69991c5472d 100644 (file)
--- 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,
        },
index dd028da8e32bbafaea23129b418cd319aaa0677e..85079788c990f712f8711b947539e2886d8684e9 100644 (file)
@@ -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)
 {
 }
index 8ea8cb7e2e627f091bd626421fe1ad1bc8623240..a51ad13044e174440fff9c1f69c7f2cebe16bf23 100644 (file)
@@ -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);