ext4: implement exists() for ext4fs

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>
master
Stephen Warren 10 years ago committed by Tom Rini
parent 89ba42d183
commit 55af5c9313
  1. 8
      fs/ext4/ext4fs.c
  2. 2
      fs/fs.c
  3. 1
      include/ext4fs.h

@ -174,6 +174,14 @@ int ext4fs_ls(const char *dirname)
return 0; 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) int ext4fs_read(char *buf, unsigned len)
{ {
if (ext4fs_root == NULL || ext4fs_file == NULL) if (ext4fs_root == NULL || ext4fs_file == NULL)

@ -102,7 +102,7 @@ static struct fstype_info fstypes[] = {
.probe = ext4fs_probe, .probe = ext4fs_probe,
.close = ext4fs_close, .close = ext4fs_close,
.ls = ext4fs_ls, .ls = ext4fs_ls,
.exists = fs_exists_unsupported, .exists = ext4fs_exists,
.read = ext4_read_file, .read = ext4_read_file,
.write = fs_write_unsupported, .write = fs_write_unsupported,
}, },

@ -134,6 +134,7 @@ int ext4fs_read(char *buf, unsigned len);
int ext4fs_mount(unsigned part_length); int ext4fs_mount(unsigned part_length);
void ext4fs_close(void); void ext4fs_close(void);
int ext4fs_ls(const char *dirname); int ext4fs_ls(const char *dirname);
int ext4fs_exists(const char *filename);
void ext4fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot); 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); 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); void ext4fs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info);

Loading…
Cancel
Save