From 982fa97d5a652beb2fcdf23281301a5ea55645fc Mon Sep 17 00:00:00 2001 From: Gyorgy Szombathelyi Date: Sat, 11 Sep 2021 19:30:31 +0200 Subject: [PATCH] Revert "FatFs: fix ext buffer when buf_size>cluster size" This reverts commit 5f3d21330731bdc3a1f6591ee0f15d3266d12ad6. --- FatFs/ff.c | 20 ++++++-------------- FatFs/ff.h | 1 - fat_compat.c | 4 +++- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/FatFs/ff.c b/FatFs/ff.c index 803cd73..e600035 100644 --- a/FatFs/ff.c +++ b/FatFs/ff.c @@ -4564,11 +4564,9 @@ FRESULT f_lseek ( /* Create a Directory Object */ /*-----------------------------------------------------------------------*/ -FRESULT f_opendir_buf ( +FRESULT f_opendir ( DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path, /* Pointer to the directory path */ - BYTE *buf, - WORD buf_size + const TCHAR* path /* Pointer to the directory path */ ) { FRESULT res; @@ -4581,13 +4579,13 @@ FRESULT f_opendir_buf ( /* Get logical drive */ res = mount_volume(&path, &fs, 0); if (res == FR_OK) { + dp->buf = 0; + dp->buf_size = 0; + dp->buf_sect = (LBA_t)0 - 1; dp->obj.fs = fs; INIT_NAMBUF(fs); res = follow_path(dp, path); /* Follow the path to the directory */ if (res == FR_OK) { /* Follow completed */ - dp->buf = buf; - dp->buf_size = buf_size > fs->csize ? fs->csize : buf_size; - dp->buf_sect = (LBA_t)0 - 1; if (!(dp->fn[NSFLAG] & NS_NONAME)) { /* It is not the origin directory itself */ if (dp->obj.attr & AM_DIR) { /* This object is a sub-directory */ #if FF_FS_EXFAT @@ -4628,13 +4626,7 @@ FRESULT f_opendir_buf ( LEAVE_FF(fs, res); } -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - return f_opendir_buf(dp, path, 0, 0); -} + /*-----------------------------------------------------------------------*/ diff --git a/FatFs/ff.h b/FatFs/ff.h index 6eaf738..6788d9e 100644 --- a/FatFs/ff.h +++ b/FatFs/ff.h @@ -312,7 +312,6 @@ FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data t FRESULT f_lseek (FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */ FRESULT f_truncate (FIL* fp); /* Truncate the file */ FRESULT f_sync (FIL* fp); /* Flush cached data of the writing file */ -FRESULT f_opendir_buf (DIR* dp, const TCHAR* path, BYTE* buf, WORD buf_size); /* Open a directory using an external buffer for directory data */ FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ FRESULT f_closedir (DIR* dp); /* Close an open directory */ FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ diff --git a/fat_compat.c b/fat_compat.c index 1215999..52d26ee 100644 --- a/fat_compat.c +++ b/fat_compat.c @@ -326,7 +326,9 @@ char ScanDirectory(unsigned long mode, char *extension, unsigned char options) { iSelectedEntry = 0; for (i = 0; i < MAXDIRENTRIES; i++) sort_table[i] = i; - if (f_opendir_buf(&dir, ".", sector_buffer, SECTOR_BUFFER_SIZE/512) != FR_OK) return 0; + if (f_opendir(&dir, ".") != FR_OK) return 0; + dir.buf = sector_buffer; + dir.buf_size = SECTOR_BUFFER_SIZE/512; } else {