!220 statfs不能正常显示FAT12和FAT16分区的空闲块和有效块
Merge pull request !220 from Far/fatfs
This commit is contained in:
commit
616ca955d5
|
@ -1141,6 +1141,9 @@ int fatfs_umount(struct Mount *mnt, struct Vnode **blkdriver)
|
||||||
int fatfs_statfs(struct Mount *mnt, struct statfs *info)
|
int fatfs_statfs(struct Mount *mnt, struct statfs *info)
|
||||||
{
|
{
|
||||||
FATFS *fs = (FATFS *)mnt->data;
|
FATFS *fs = (FATFS *)mnt->data;
|
||||||
|
DWORD nclst = 0;
|
||||||
|
FRESULT result = FR_OK;
|
||||||
|
int ret;
|
||||||
|
|
||||||
info->f_type = MSDOS_SUPER_MAGIC;
|
info->f_type = MSDOS_SUPER_MAGIC;
|
||||||
#if FF_MAX_SS != FF_MIN_SS
|
#if FF_MAX_SS != FF_MIN_SS
|
||||||
|
@ -1149,8 +1152,17 @@ int fatfs_statfs(struct Mount *mnt, struct statfs *info)
|
||||||
info->f_bsize = FF_MIN_SS * fs->csize;
|
info->f_bsize = FF_MIN_SS * fs->csize;
|
||||||
#endif
|
#endif
|
||||||
info->f_blocks = fs->n_fatent;
|
info->f_blocks = fs->n_fatent;
|
||||||
|
ret = lock_fs(fs);
|
||||||
|
if (ret == FALSE) {
|
||||||
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
/* free cluster is unavailable, update it */
|
||||||
|
if (fs->free_clst == DISK_ERROR) {
|
||||||
|
result = fat_count_free_entries(&nclst, fs);
|
||||||
|
}
|
||||||
info->f_bfree = fs->free_clst;
|
info->f_bfree = fs->free_clst;
|
||||||
info->f_bavail = fs->free_clst;
|
info->f_bavail = fs->free_clst;
|
||||||
|
unlock_fs(fs, result);
|
||||||
|
|
||||||
#if FF_USE_LFN
|
#if FF_USE_LFN
|
||||||
/* Maximum length of filenames */
|
/* Maximum length of filenames */
|
||||||
|
@ -1166,7 +1178,7 @@ int fatfs_statfs(struct Mount *mnt, struct statfs *info)
|
||||||
info->f_ffree = 0;
|
info->f_ffree = 0;
|
||||||
info->f_flags = mnt->mountFlags;
|
info->f_flags = mnt->mountFlags;
|
||||||
|
|
||||||
return 0;
|
return -fatfs_2_vfs(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int GET_SECONDS(WORD ftime)
|
static inline int GET_SECONDS(WORD ftime)
|
||||||
|
|
Loading…
Reference in New Issue