sandbox: implement exists() function
authorStephen Warren <swarren@nvidia.com>
Mon, 3 Feb 2014 20:21:07 +0000 (13:21 -0700)
committerChanho Park <chanho61.park@samsung.com>
Thu, 6 Aug 2015 11:16:22 +0000 (20:16 +0900)
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 acd3eb58a33dba08afe3c1b2bbc69ade108a2027..05a50d331b2a3f994acb6453854069aca74de24f 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,
        },
 #endif
index 02d26ff851eeecaf8c9b250155cec855f2a3bee6..57ba608073eaec3fcb452e457c187f72ee59e842 100644 (file)
@@ -65,6 +65,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 f5213ac10750d53086bfd7481127164ead8b926d..12d9b1563de26b29e3609e3e7b56247bea8af1c3 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);
 
 #endif