summaryrefslogtreecommitdiffstats
path: root/fs/fat/fat.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/fat/fat.c')
-rw-r--r--fs/fat/fat.c76
1 files changed, 24 insertions, 52 deletions
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 394c75ffc4..f3c7f9b863 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -3,9 +3,6 @@
*
* Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
*
- * See file CREDITS for list of people who contributed to this
- * project.
- *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
@@ -68,41 +65,10 @@ DRESULT disk_write(FATFS *fat, const BYTE *buf, DWORD sector, BYTE count)
return 0;
}
-DSTATUS disk_status(FATFS *fat)
-{
- return 0;
-}
-
-DWORD get_fattime(void)
-{
- return 0;
-}
-
-DRESULT disk_ioctl (FATFS *fat, BYTE command, void *buf)
-{
- return 0;
-}
-
-WCHAR ff_convert(WCHAR src, UINT dir)
-{
- if (src <= 0x80)
- return src;
- else
- return '?';
-}
-
-WCHAR ff_wtoupper(WCHAR chr)
-{
- if (chr <= 0x80)
- return toupper(chr);
- else
- return '?';
-}
-
/* ---------------------------------------------------------------*/
#ifdef CONFIG_FS_FAT_WRITE
-static int fat_create(struct device_d *dev, const char *pathname, mode_t mode)
+static int fat_create(struct device *dev, const char *pathname, mode_t mode)
{
struct fat_priv *priv = dev->priv;
FIL f_file;
@@ -117,7 +83,7 @@ static int fat_create(struct device_d *dev, const char *pathname, mode_t mode)
return 0;
}
-static int fat_unlink(struct device_d *dev, const char *pathname)
+static int fat_unlink(struct device *dev, const char *pathname)
{
struct fat_priv *priv = dev->priv;
int ret;
@@ -131,7 +97,7 @@ static int fat_unlink(struct device_d *dev, const char *pathname)
return 0;
}
-static int fat_mkdir(struct device_d *dev, const char *pathname)
+static int fat_mkdir(struct device *dev, const char *pathname)
{
struct fat_priv *priv = dev->priv;
int ret;
@@ -145,7 +111,7 @@ static int fat_mkdir(struct device_d *dev, const char *pathname)
return 0;
}
-static int fat_rmdir(struct device_d *dev, const char *pathname)
+static int fat_rmdir(struct device *dev, const char *pathname)
{
struct fat_priv *priv = dev->priv;
int ret;
@@ -159,7 +125,8 @@ static int fat_rmdir(struct device_d *dev, const char *pathname)
return 0;
}
-static int fat_write(struct device_d *_dev, FILE *f, const void *buf, size_t insize)
+static int fat_write(struct device *_dev, FILE *f, const void *buf,
+ size_t insize)
{
FIL *f_file = f->priv;
int outsize;
@@ -177,7 +144,7 @@ static int fat_write(struct device_d *_dev, FILE *f, const void *buf, size_t ins
return outsize;
}
-static int fat_truncate(struct device_d *dev, FILE *f, loff_t size)
+static int fat_truncate(struct device *dev, FILE *f, loff_t size)
{
FIL *f_file = f->priv;
unsigned long lastofs;
@@ -201,7 +168,7 @@ static int fat_truncate(struct device_d *dev, FILE *f, loff_t size)
}
#endif /* CONFIG_FS_FAT_WRITE */
-static int fat_open(struct device_d *dev, FILE *file, const char *filename)
+static int fat_open(struct device *dev, FILE *file, const char *filename)
{
struct fat_priv *priv = dev->priv;
FIL *f_file;
@@ -230,6 +197,11 @@ static int fat_open(struct device_d *dev, FILE *file, const char *filename)
if (file->flags & O_APPEND) {
ret = f_lseek(f_file, f_file->fsize);
+ if (ret) {
+ f_close(f_file);
+ free(f_file);
+ return -EINVAL;
+ }
}
file->priv = f_file;
@@ -238,7 +210,7 @@ static int fat_open(struct device_d *dev, FILE *file, const char *filename)
return 0;
}
-static int fat_close(struct device_d *dev, FILE *f)
+static int fat_close(struct device *dev, FILE *f)
{
struct fat_priv *priv = dev->priv;
FIL *f_file = f->priv;
@@ -252,7 +224,7 @@ static int fat_close(struct device_d *dev, FILE *f)
return 0;
}
-static int fat_read(struct device_d *_dev, FILE *f, void *buf, size_t insize)
+static int fat_read(struct device *_dev, FILE *f, void *buf, size_t insize)
{
int ret;
FIL *f_file = f->priv;
@@ -268,7 +240,7 @@ static int fat_read(struct device_d *_dev, FILE *f, void *buf, size_t insize)
return outsize;
}
-static int fat_lseek(struct device_d *dev, FILE *f, loff_t pos)
+static int fat_lseek(struct device *dev, FILE *f, loff_t pos)
{
FIL *f_file = f->priv;
int ret;
@@ -280,7 +252,7 @@ static int fat_lseek(struct device_d *dev, FILE *f, loff_t pos)
return 0;
}
-static DIR* fat_opendir(struct device_d *dev, const char *pathname)
+static DIR* fat_opendir(struct device *dev, const char *pathname)
{
struct fat_priv *priv = dev->priv;
DIR *dir;
@@ -305,7 +277,7 @@ static DIR* fat_opendir(struct device_d *dev, const char *pathname)
return dir;
}
-static struct dirent* fat_readdir(struct device_d *dev, DIR *dir)
+static struct dirent* fat_readdir(struct device *dev, DIR *dir)
{
FF_DIR *ff_dir = dir->priv;
FILINFO finfo;
@@ -335,7 +307,7 @@ static struct dirent* fat_readdir(struct device_d *dev, DIR *dir)
return &dir->d;
}
-static int fat_closedir(struct device_d *dev, DIR *dir)
+static int fat_closedir(struct device *dev, DIR *dir)
{
FF_DIR *ff_dir = dir->priv;
@@ -345,7 +317,7 @@ static int fat_closedir(struct device_d *dev, DIR *dir)
return 0;
}
-static int fat_stat(struct device_d *dev, const char *filename, struct stat *s)
+static int fat_stat(struct device *dev, const char *filename, struct stat *s)
{
struct fat_priv *priv = dev->priv;
FILINFO finfo;
@@ -368,9 +340,9 @@ static int fat_stat(struct device_d *dev, const char *filename, struct stat *s)
return 0;
}
-static int fat_probe(struct device_d *dev)
+static int fat_probe(struct device *dev)
{
- struct fs_device_d *fsdev = dev_to_fs_device(dev);
+ struct fs_device *fsdev = dev_to_fs_device(dev);
struct fat_priv *priv = xzalloc(sizeof(struct fat_priv));
int ret;
@@ -396,12 +368,12 @@ err_open:
return ret;
}
-static void fat_remove(struct device_d *dev)
+static void fat_remove(struct device *dev)
{
free(dev->priv);
}
-static struct fs_driver_d fat_driver = {
+static struct fs_driver fat_driver = {
.open = fat_open,
.close = fat_close,
.read = fat_read,