ext4: implement exists() for ext4fs
authorStephen Warren <swarren@nvidia.com>
Mon, 3 Feb 2014 20:21:09 +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 ext4 filesystem.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
fs/ext4/ext4fs.c
fs/fs.c
include/ext4fs.h

index 735b2564175b1e85a08d8e5bfce5704491ea6b26..417ce7b63bf0215122821cee7236e0062e9ee7ef 100644 (file)
@@ -174,6 +174,14 @@ int ext4fs_ls(const char *dirname)
        return 0;
 }
 
+int ext4fs_exists(const char *filename)
+{
+       int file_len;
+
+       file_len = ext4fs_open(filename);
+       return file_len >= 0;
+}
+
 int ext4fs_read(char *buf, unsigned len)
 {
        if (ext4fs_root == NULL || ext4fs_file == NULL)
diff --git a/fs/fs.c b/fs/fs.c
index 2e60f57bc450dc547e5ac2ff3a84a69991c5472d..4e9b162d49ff40664dabd80036eb93b6c01226e6 100644 (file)
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -102,7 +102,7 @@ static struct fstype_info fstypes[] = {
                .probe = ext4fs_probe,
                .close = ext4fs_close,
                .ls = ext4fs_ls,
-               .exists = fs_exists_unsupported,
+               .exists = ext4fs_exists,
                .read = ext4_read_file,
                .write = fs_write_unsupported,
        },
index 24293803966297480b268145840ad2a8f8a34b64..aacb147de24bae919c42efdac08dd6c4bf3b8b15 100644 (file)
@@ -134,6 +134,7 @@ int ext4fs_read(char *buf, unsigned len);
 int ext4fs_mount(unsigned part_length);
 void ext4fs_close(void);
 int ext4fs_ls(const char *dirname);
+int ext4fs_exists(const char *filename);
 void ext4fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot);
 int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf);
 void ext4fs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info);