From 11a5aa9766f2b6c592eefa7a09475bd598fbb0b1 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sun, 21 Aug 2016 23:03:08 -0700 Subject: [PATCH] FatFs: Apply patch ff12a_p6.diff. --- firmware/chibios-portapack/ext/fatfs/src/ff.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/firmware/chibios-portapack/ext/fatfs/src/ff.c b/firmware/chibios-portapack/ext/fatfs/src/ff.c index f0b927d5..04e197cf 100644 --- a/firmware/chibios-portapack/ext/fatfs/src/ff.c +++ b/firmware/chibios-portapack/ext/fatfs/src/ff.c @@ -4038,11 +4038,16 @@ FRESULT f_lseek ( } if (clst != 0) { while (ofs > bcs) { /* Cluster following loop */ + ofs -= bcs; fp->fptr += bcs; #if !_FS_READONLY if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ + if (_FS_EXFAT && fp->fptr > fp->obj.objsize) { /* No FAT chain object needs correct objsize to generate FAT value */ + fp->obj.objsize = fp->fptr; + fp->flag |= FA_MODIFIED; + } clst = create_chain(&fp->obj, clst); /* Force stretch if in write mode */ if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; + ofs = 0; break; } } else #endif @@ -4050,8 +4055,6 @@ FRESULT f_lseek ( if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR); if (clst <= 1 || clst >= fs->n_fatent) ABORT(fs, FR_INT_ERR); fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; } fp->fptr += ofs; if (ofs % SS(fs)) {