summaryrefslogtreecommitdiff
path: root/fs/fat/fat_write.c
AgeCommit message (Collapse)Author
2013-05-01fs/fat: Don't multiply fatsize with sector sizeEgbert Eich
Bugfix: Here at this place we need the fat size in sectors not bytes. This was found during code review when adding support for storage devices with blocksizes != 512. Signed-off-by: Egbert Eich <eich@suse.com>
2013-02-04FAT: remove ifdefs to make the code more readableRichard Genoud
ifdefs in the code are making it harder to read. The use of simple if(vfat_enabled) makes no more code and is cleaner. (the code is discarded by the compiler instead of the preprocessor.) NB: if -O0 is used, the code won't be discarded and bonus, now the code compiles even if CONFIG_SUPPORT_VFAT is not defined. Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
2013-02-04FAT: use toupper/tolower instead of recoding themRichard Genoud
toupper/tolower function are already declared, so use them. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Acked-by: Marek Vasut <marex@denx.de> Acked-by: Stefano Babic <sbabic@denx.de>
2012-10-17fs: fat: Fix mkcksum() function parametersMarek Vasut
The mkcksum() function now takes one parameter, the pointer to 11-byte wide character array, which it then operates on. Currently, the function is wrongly passed (dir_entry)->name, which is only 8-byte wide character array. Though by further inspecting the dir_entry structure, it can be noticed that the name[8] entry is immediatelly followed by ext[3] entry. Thus, name[8] and ext[3] in the dir_entry structure actually work as this 11-byte wide array since they're placed right next to each other by current compiler behavior. Depending on this is obviously wrong, thus fix this by correctly passing both (dir_entry)->name and (dir_entry)->ext to the mkcksum() function and adjust the function appropriately. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Tom Rini <trini@ti.com>
2012-09-26FAT: Make it possible to read from any file positionBenoît Thébaudeau
When storage devices contain files larger than the embedded RAM, it is useful to be able to read these files by chunks, e.g. for a software update to the embedded NAND Flash from an external storage device (USB stick, SD card, etc.). Hence, this patch makes it possible by adding a new FAT API to read files from a given position. This patch also adds this feature to the fatload command. Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com> Cc: Wolfgang Denk <wd@denx.de> Signed-off-by: Tom Rini <trini@ti.com>
2012-03-26fs/fat/fat_write.c: Fix GCC 4.6 warningsAnatolij Gustschin
Fix: fat_write.c: In function 'find_directory_entry': fat_write.c:826:8: warning: variable 'prevcksum' set but not used [-Wunused-but-set-variable] fat_write.c: In function 'do_fat_write': fat_write.c:933:6: warning: variable 'root_cluster' set but not used [-Wunused-but-set-variable] fat_write.c:925:12: warning: variable 'slotptr' set but not used [-Wunused-but-set-variable] Signed-off-by: Anatolij Gustschin <agust@denx.de> Cc: Donggeun Kim <dg77.kim@samsung.com> Acked-by: Maximilian Schwerin <mvs@tigris.de> Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
2012-03-24FAT write: Fix compile errorsDonggeun Kim
This patch removes compile errors introduced by commit 9813b750f32c0056f0a35813b9a9ec0f68b664af 'fs/fat: Fix FAT detection to support non-DOS partition tables' fat_write.c: In function 'disk_write': fat_write.c:54: error: 'part_offset' undeclared (first use in this function) fat_write.c:54: error: (Each undeclared identifier is reported only once fat_write.c:54: error: for each function it appears in.) fat_write.c: In function 'do_fat_write': fat_write.c:950: error: 'part_size' undeclared (first use in this function) These errors only appear when this code is enabled by defining CONFIG_FAT_WRITE option. This patch was originally part of http://article.gmane.org/gmane.comp.boot-loaders.u-boot/121847 Signed-off-by: Donggeun Kim <dg77.kim@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Maximilian Schwerin <mvs@tigris.de> Fixed patch author and added all needed SoB from the original patch and also submitter's SoB. Extended commit log. Signed-off-by: Anatolij Gustschin <agust@denx.de>
2012-01-05FAT: update the second FAT when writing a fileDonggeun Kim
After susccessful write to the FAT partition, fsck program may print warning message due to different FAT, provided that the filesystem supports two FATs. This patch makes the second FAT to be same with the first one when writing a file. Signed-off-by: Donggeun Kim <dg77.kim@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2011-12-20FAT: fix some issues in FAT write support codeAnatolij Gustschin
Writing a file to the FAT partition didn't work while a test using a CF card. The test was done on mpc5200 based board (powerpc). There is a number of problems in FAT write code: Compiler warning: fat_write.c: In function 'file_fat_write': fat_write.c:326: warning: 'counter' may be used uninitialized in this function fat_write.c:326: note: 'counter' was declared here 'l_filename' string is not terminated, so a file name with garbage at the end is used as a file name as shown by debug code. Return value of set_contents() is not checked properly so actually a file won't be written at all (as checked using 'fatls' after a write attempt with 'fatwrite' command). do_fat_write() doesn't return the number of written bytes if no error happened. However the return value of this function is used to show the number of written bytes in do_fat_fswrite(). The patch adds some debug code and fixes above mentioned problems and also fixes a typo in error output. NOTE: after a successful write to the FAT partition (under U-Boot) the partition was checked under Linux using fsck. The partition needed fixing FATs: -bash-3.2# fsck -a /dev/sda1 fsck 1.39 (29-May-2006) dosfsck 2.11, 12 Mar 2005, FAT32, LFN FATs differ but appear to be intact. Using first FAT. Performing changes. Signed-off-by: Anatolij Gustschin <agust@denx.de> Cc: Donggeun Kim <dg77.kim@samsung.com> Cc: Aaron Williams <Aaron.Williams@cavium.com> Acked-by: Donggeun Kim <dg77.kim@samsung.com>
2011-10-26FAT: Add FAT write featureDonggeun 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_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>