From afea68fe4ccd0443d61ccd35f4a6e8e97e41cf4a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 14 Jan 2014 13:45:26 -0600 Subject: Fix a FAT cluster allocation bug. From Tridge --- nuttx/ChangeLog | 5 ++++- nuttx/fs/fat/fs_fat32.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index b7039d070..9c08ef7c7 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -6433,4 +6433,7 @@ * configs/px4fmu-v2_upstream: Configuration for testing simple configurations on the the PX4FMU v2. This version is incomplete for the PX4 appliation and is not a replacement for the version - in the PX4 GIT repository. \ No newline at end of file + in the PX4 GIT repository. + * fs/fat/fs_fat32.c: A correction to FAT cluster allocation from + Tridge via Lorenz Meier (2014-1-14). + diff --git a/nuttx/fs/fat/fs_fat32.c b/nuttx/fs/fat/fs_fat32.c index 29d5b450f..cbbc3cd89 100644 --- a/nuttx/fs/fat/fs_fat32.c +++ b/nuttx/fs/fat/fs_fat32.c @@ -623,7 +623,7 @@ fat_read_restart: * cluster boundary */ - if (ff->ff_sectorsincluster < 1) + if (buflen > 0 && ff->ff_sectorsincluster < 1) { /* Find the next cluster in the FAT. */ @@ -899,7 +899,7 @@ fat_write_restart: * cluster boundary */ - if (ff->ff_sectorsincluster < 1) + if (buflen > 0 && ff->ff_sectorsincluster < 1) { /* Extend the current cluster by one (unless lseek was used to * move the file position back from the end of the file) -- cgit v1.2.3