summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2014-02-03 13:21:10 -0700
committerTom Rini <trini@ti.com>2014-02-19 09:47:34 -0500
commitb7b5f3195fa5a31ab1505e0c87054dc6dc71627b (patch)
tree575752ba9711f80028817ee6ac1efd2f404f4452 /fs
parent55af5c9313607f3b6acba2fd915b263ef6a61dd4 (diff)
downloadu-boot-imx-b7b5f3195fa5a31ab1505e0c87054dc6dc71627b.zip
u-boot-imx-b7b5f3195fa5a31ab1505e0c87054dc6dc71627b.tar.gz
u-boot-imx-b7b5f3195fa5a31ab1505e0c87054dc6dc71627b.tar.bz2
fat: implement exists() for FAT fs
This hooks into the generic "file exists" support added in an earlier patch, and provides an implementation for the FAT filesystem. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/fat/fat.c18
-rw-r--r--fs/fs.c2
2 files changed, 15 insertions, 5 deletions
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index b41d62e..54f42ea 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -808,7 +808,7 @@ __u8 do_fat_read_at_block[MAX_CLUSTSIZE]
long
do_fat_read_at(const char *filename, unsigned long pos, void *buffer,
- unsigned long maxsize, int dols)
+ unsigned long maxsize, int dols, int dogetsize)
{
char fnamecopy[2048];
boot_sector bs;
@@ -1152,7 +1152,10 @@ rootdir_done:
subname = nextname;
}
- ret = get_contents(mydata, dentptr, pos, buffer, maxsize);
+ if (dogetsize)
+ ret = FAT2CPU32(dentptr->size);
+ else
+ ret = get_contents(mydata, dentptr, pos, buffer, maxsize);
debug("Size: %d, got: %ld\n", FAT2CPU32(dentptr->size), ret);
exit:
@@ -1163,7 +1166,7 @@ exit:
long
do_fat_read(const char *filename, void *buffer, unsigned long maxsize, int dols)
{
- return do_fat_read_at(filename, 0, buffer, maxsize, dols);
+ return do_fat_read_at(filename, 0, buffer, maxsize, dols, 0);
}
int file_fat_detectfs(void)
@@ -1233,11 +1236,18 @@ int file_fat_ls(const char *dir)
return do_fat_read(dir, NULL, 0, LS_YES);
}
+int fat_exists(const char *filename)
+{
+ int sz;
+ sz = do_fat_read_at(filename, 0, NULL, 0, LS_NO, 1);
+ return sz >= 0;
+}
+
long file_fat_read_at(const char *filename, unsigned long pos, void *buffer,
unsigned long maxsize)
{
printf("reading %s\n", filename);
- return do_fat_read_at(filename, pos, buffer, maxsize, LS_NO);
+ return do_fat_read_at(filename, pos, buffer, maxsize, LS_NO, 0);
}
long file_fat_read(const char *filename, void *buffer, unsigned long maxsize)
diff --git a/fs/fs.c b/fs/fs.c
index 4e9b162..79d432d 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -90,7 +90,7 @@ static struct fstype_info fstypes[] = {
.probe = fat_set_blk_dev,
.close = fat_close,
.ls = file_fat_ls,
- .exists = fs_exists_unsupported,
+ .exists = fat_exists,
.read = fat_read_file,
.write = fs_write_unsupported,
},