FAT: Add FAT write feature
PATCH 1/1 FAT: Add FAT write feature
In some cases, saving data in RAM as a file with FAT format is required. This patch allows the file to be written in FAT formatted partition.
The usage is similar with reading a file.
First, fat_register_device function is called before file_fat_write function in order to set target partition.
Then, file_fat_write function is invoked with desired file name, start ram address for writing data, and file size.
--- fs/fat/Makefile | 1 + fs/fat/fat.c | 2 + fs/fat/fat_write.c | 1072 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/fat.h | 2 + 4 files changed, 1077 insertions(+), 0 deletions(-) create mode 100644 fs/fat/fat_write.c
fs/fat/Makefile +1 -0
@@ -25,6 +25,7 @@ LIB = $(obj)libfat.o AOBJS = COBJS-$(CONFIG_CMD_FAT) := fat.o +COBJS-$(CONFIG_FAT_WRITE):= fat_write.o ifndef CONFIG_SPL_BUILD COBJS-$(CONFIG_CMD_FAT) += file.o
fs/fat/fat.c +2 -0
@@ -45,6 +45,7 @@ static void downcase (char *str)static block_dev_desc_t *cur_dev =NULL ;static unsigned long part_offset =0 ; +static unsigned long part_size =0 ;static int cur_part =1 ;
@@ -99,6 +100,7 @@ int fat_register_device (block_dev_desc_t * dev_desc, int part_no)if (!get_partition_info (dev_desc, part_no, &info)) { part_offset = info.start; cur_part = part_no; + part_size = info.size; }else if ((strncmp ((char *)&buffer[DOS_FS_TYPE_OFFSET ],"FAT" ,3 ) ==0 ) || (strncmp ((char *)&buffer[DOS_FS32_TYPE_OFFSET ],"FAT32" ,5 ) ==0 )) {/* ok, we assume we are on a PBR only */
fs/fat/fat_write.c new file +1072 -0
1,072 lines not on this page · raw message
include/fat.h +2 -0
@@ -106,6 +106,7 @@#endif #define TOLOWER (c) if((c) >= 'A' && (c) <= 'Z'){(c)+=('a' - 'A');} +#define TOUPPER (c) if((c) >= 'a' && (c) <= 'z'){(c)-=('a' - 'A');}#define START (dent) (FAT2CPU16((dent)->start) \ + (mydata->fatsize != 32 ? 0 : \ (FAT2CPU16((dent)->starthi) << 16)))
@@ -216,4 +217,5 @@ long file_fat_read(const char *filename, void *buffer, unsigned long maxsize);const char *file_getfsname (int idx);int fat_register_device (block_dev_desc_t *dev_desc,int part_no); +int file_fat_write (const char *filename,void *buffer,unsigned long maxsize);#endif /* _FAT_H_ */
Signature · 1 line
1.7.4.1
PATCH 1/1 FAT: Add FAT write feature
Hello.
Quoted 11 lines · Donggeun Kim
In some cases, saving data in RAM as a file with FAT format is required. This patch allows the file to be written in FAT formatted partition.
The usage is similar with reading a file.
First,fat_register_devicefunction is called beforefile_fat_writefunction in order to set target partition.
Then,file_fat_writefunction is invoked with desired file name, start ram address for writing data, and file size.Signed-off-by Donggeun Kim<[email protected]>Signed-off-by Kyungmin Park<[email protected]>
I have recently submitted the patch fixing FAt code crash with sector
sizes > 512 bytes [1]. You probably should take it into account.
[1] http://marc.info/?l=u-boot&m=131283284822789
WBR, Sergei
PATCH 1/1 FAT: Add FAT write feature
In reply to Donggeun KimDear Donggeun Kim,
Quoted 11 lines · In message <[email protected]> you wrote:
In some cases, saving data in RAM as a file with FAT format is required. This patch allows the file to be written in FAT formatted partition.
The usage is similar with reading a file.
First,fat_register_devicefunction is called beforefile_fat_writefunction in order to set target partition.
Then,file_fat_writefunction is invoked with desired file name, start ram address for writing data, and file size.Signed-off-by Donggeun Kim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>
Quoted 7 lines
--- fs/fat/Makefile | 1 + fs/fat/fat.c | 2 + fs/fat/fat_write.c | 1072 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/fat.h | 2 + 4 files changed, 1077 insertions(+), 0 deletions(-) create mode 100644 fs/fat/fat_write.c
Checkpatch says:
total: 6 errors, 2 warnings, 1105 lines checked
Please clean up and resubmit. Thanks.
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "The good Christian should beware of mathematicians and all those who make empty prophecies. The danger already exists that mathematicians have made a covenant with the devil to darken the spirit and confine man in the bonds of Hell." - Saint Augustine