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. Signed-off-by: Donggeun Kim <dg77.kim@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
This commit is contained in:
parent
eea63e05d0
commit
c30a15e590
5
README
5
README
@ -1175,6 +1175,11 @@ The following options need to be configured:
|
||||
to disable the command chpart. This is the default when you
|
||||
have not defined a custom partition
|
||||
|
||||
- FAT(File Allocation Table) filesystem write function support:
|
||||
CONFIG_FAT_WRITE
|
||||
Support for saving memory data as a file
|
||||
in FAT formatted partition
|
||||
|
||||
- Keyboard Support:
|
||||
CONFIG_ISA_KEYBOARD
|
||||
|
||||
|
@ -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
|
||||
|
@ -46,6 +46,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;
|
||||
|
||||
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 */
|
||||
|
1090
fs/fat/fat_write.c
Normal file
1090
fs/fat/fat_write.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -99,6 +99,8 @@
|
||||
#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)))
|
||||
@ -210,4 +212,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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user