diff mbox

[U-Boot,V4,11/12] ext4: implement exists() for ext4fs

Message ID 1391458870-17930-11-git-send-email-swarren@wwwdotorg.org
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Stephen Warren Feb. 3, 2014, 8:21 p.m. UTC
From: Stephen Warren <swarren@nvidia.com>

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>
---
v4: No change.
v3: Invert return value of exists(), per change to previous patch.
v2: No change.
---
 fs/ext4/ext4fs.c | 8 ++++++++
 fs/fs.c          | 2 +-
 include/ext4fs.h | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

Comments

Tom Rini Feb. 4, 2014, 10:07 p.m. UTC | #1
On Mon, Feb 03, 2014 at 01:21:09PM -0700, Stephen Warren wrote:

> From: Stephen Warren <swarren@nvidia.com>
> 
> 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>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 735b2564175b..417ce7b63bf0 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -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 2e60f57bc450..4e9b162d49ff 100644
--- 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,
 	},
diff --git a/include/ext4fs.h b/include/ext4fs.h
index 242938039662..aacb147de24b 100644
--- a/include/ext4fs.h
+++ b/include/ext4fs.h
@@ -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);