Skip to content

Commit 33a7c98

Browse files
de-nordiccfriedt
authored andcommitted
fs/fatfs: Apply changes required for version 0.14b
The commit applies changes that are required by update of ELM Chan's FAT FS driver update to version 0.14b. Signed-off-by: Dominik Ermel <[email protected]>
1 parent c5f707e commit 33a7c98

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

subsys/fs/Kconfig.fatfs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,9 @@ endif # FS_FATFS_LFN
9999

100100
config FS_FATFS_CODEPAGE
101101
int "FatFS code page (character set)"
102-
default 437 if FS_FATFS_LFN
103-
default 1
102+
default 437
104103
help
105104
Valid code page values:
106-
1 - ASCII (No extended character. Non-LFN cfg. only)
107105
437 - U.S.
108106
720 - Arabic
109107
737 - Greek

subsys/fs/fat_fs.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,20 @@ static int fatfs_statvfs(struct fs_mount_t *mountp,
383383
int res = -ENOTSUP;
384384
#if !defined(CONFIG_FS_FATFS_READ_ONLY)
385385
FATFS *fs;
386+
DWORD f_bfree = 0;
386387

387-
res = f_getfree(&mountp->mnt_point[1], &stat->f_bfree, &fs);
388+
res = f_getfree(&mountp->mnt_point[1], &f_bfree, &fs);
388389
if (res != FR_OK) {
389390
return -EIO;
390391
}
391392

393+
stat->f_bfree = f_bfree;
394+
392395
/*
393-
* _MIN_SS holds the sector size. It is one of the configuration
396+
* FF_MIN_SS holds the sector size. It is one of the configuration
394397
* constants used by the FS module
395398
*/
396-
stat->f_bsize = _MIN_SS;
399+
stat->f_bsize = FF_MIN_SS;
397400
stat->f_frsize = fs->csize * stat->f_bsize;
398401
stat->f_blocks = (fs->n_fatent - 2);
399402

@@ -416,10 +419,16 @@ static int fatfs_mount(struct fs_mount_t *mountp)
416419
/* If no file system found then create one */
417420
if (res == FR_NO_FILESYSTEM &&
418421
(mountp->flags & FS_MOUNT_FLAG_NO_FORMAT) == 0) {
419-
uint8_t work[_MAX_SS];
420-
421-
res = f_mkfs(&mountp->mnt_point[1],
422-
(FM_FAT | FM_SFD), 0, work, sizeof(work));
422+
uint8_t work[FF_MAX_SS];
423+
MKFS_PARM mkfs_opt = {
424+
.fmt = FM_FAT | FM_SFD, /* Any suitable FAT */
425+
.n_fat = 1, /* One FAT fs table */
426+
.align = 0, /* Get sector size via diskio query */
427+
.n_root = 512, /* Max 512 root directory entries */
428+
.au_size = 0 /* Auto calculate cluster size */
429+
};
430+
431+
res = f_mkfs(&mountp->mnt_point[1], &mkfs_opt, work, sizeof(work));
423432
if (res == FR_OK) {
424433
res = f_mount((FATFS *)mountp->fs_data,
425434
&mountp->mnt_point[1], 1);
@@ -435,7 +444,7 @@ static int fatfs_unmount(struct fs_mount_t *mountp)
435444
{
436445
FRESULT res;
437446

438-
res = f_mount(NULL, &mountp->mnt_point[1], 1);
447+
res = f_mount(NULL, &mountp->mnt_point[1], 0);
439448

440449
return translate_error(res);
441450
}

0 commit comments

Comments
 (0)