summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/dosfs/fat_file.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-03-13 15:20:20 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-03-21 16:14:44 +0100
commitc38f1fcf8f0fab90785b0aec4361d53673bbc864 (patch)
tree31ad825a1aa3e12afb966fcbdefd3be534da0c61 /cpukit/libfs/src/dosfs/fat_file.c
parentdosfs: Fix msdos_utf8_normalize_and_fold() (diff)
downloadrtems-c38f1fcf8f0fab90785b0aec4361d53673bbc864.tar.bz2
dosfs: Fix fat_file_write()
Remove forced overwrite which leads to file data corruption. The logic to determine a forced overwrite was fundamentally broken. For simplity, disable this feature. Close #2622.
Diffstat (limited to '')
-rw-r--r--cpukit/libfs/src/dosfs/fat_file.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/cpukit/libfs/src/dosfs/fat_file.c b/cpukit/libfs/src/dosfs/fat_file.c
index af71ee239a..cbc0ab3b78 100644
--- a/cpukit/libfs/src/dosfs/fat_file.c
+++ b/cpukit/libfs/src/dosfs/fat_file.c
@@ -403,20 +403,18 @@ static bool
* start - offset(in bytes) to write from
* count - count
* buf - buffer provided by user
- * file_cln_initial - initial current cluster number of the file
*
* RETURNS:
* number of bytes actually written to the file on success, or -1 if
* error occured (errno set appropriately)
*/
static ssize_t
- fat_file_write_fat32_or_non_root_dir(
+fat_file_write_fat32_or_non_root_dir(
fat_fs_info_t *fs_info,
fat_file_fd_t *fat_fd,
const uint32_t start,
const uint32_t count,
- const uint8_t *buf,
- const uint32_t file_cln_initial)
+ const uint8_t *buf)
{
int rc = RC_OK;
uint32_t cmpltd = 0;
@@ -426,35 +424,27 @@ static ssize_t
uint32_t ofs_cln = start - (start_cln << fs_info->vol.bpc_log2);
uint32_t ofs_cln_save = ofs_cln;
uint32_t bytes_to_write = count;
- uint32_t file_cln_cnt;
ssize_t ret;
uint32_t c;
- bool overwrite_cluster = false;
rc = fat_file_lseek(fs_info, fat_fd, start_cln, &cur_cln);
if (RC_OK == rc)
{
- file_cln_cnt = cur_cln - fat_fd->cln;
while ( (RC_OK == rc)
&& (bytes_to_write > 0))
{
c = MIN(bytes_to_write, (fs_info->vol.bpc - ofs_cln));
- if (file_cln_initial < file_cln_cnt)
- overwrite_cluster = true;
-
ret = fat_cluster_write(fs_info,
cur_cln,
ofs_cln,
c,
- &buf[cmpltd],
- overwrite_cluster);
+ &buf[cmpltd]);
if (0 > ret)
rc = -1;
if (RC_OK == rc)
{
- ++file_cln_cnt;
bytes_to_write -= ret;
cmpltd += ret;
save_cln = cur_cln;
@@ -509,7 +499,6 @@ fat_file_write(
uint32_t byte;
uint32_t c = 0;
bool zero_fill = start > fat_fd->fat_file_size;
- uint32_t file_cln_initial = fat_fd->map.file_cln;
uint32_t cln;
@@ -543,8 +532,7 @@ fat_file_write(
cln,
byte,
count,
- buf,
- false);
+ buf);
if (0 > ret)
rc = -1;
else
@@ -556,8 +544,7 @@ fat_file_write(
fat_fd,
start,
count,
- buf,
- file_cln_initial);
+ buf);
if (0 > ret)
rc = -1;
else