Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party FatFs
提交
ac9f86b3
T
Third Party FatFs
项目概览
OpenHarmony
/
Third Party FatFs
8 个月 前同步成功
通知
2
Star
21
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party FatFs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ac9f86b3
编写于
5月 15, 2021
作者:
O
openharmony_ci
提交者:
Gitee
5月 15, 2021
浏览文件
操作
浏览文件
下载
差异文件
!12 statfs不能正常显示FAT12和FAT16分区的空闲块和有效块
Merge pull request !12 from Far/fatfs
上级
c9c6b40b
eb9b7c3f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
38 deletion
+48
-38
source/ff.c
source/ff.c
+46
-37
source/ff.h
source/ff.h
+2
-1
未找到文件。
source/ff.c
浏览文件 @
ac9f86b3
...
...
@@ -4290,6 +4290,51 @@ FRESULT f_stat (
}
FRESULT
fat_count_free_entries
(
DWORD
*
nclst
,
/* Pointer to a variable to return number of free clusters */
FATFS
*
fs
/* Pointer to corresponding filesystem object */
)
{
DWORD
nfree
,
clst
,
stat
;
QWORD
sect
;
UINT
i
;
FFOBJID
obj
;
FRESULT
res
=
FR_OK
;
nfree
=
0
;
if
(
fs
->
fs_type
==
FS_FAT12
)
{
/* FAT12: Scan bit field FAT entries */
clst
=
2
;
obj
.
fs
=
fs
;
do
{
stat
=
get_fat
(
&
obj
,
clst
);
if
(
stat
==
0xFFFFFFFF
)
{
res
=
FR_DISK_ERR
;
break
;
}
if
(
stat
==
1
)
{
res
=
FR_INT_ERR
;
break
;
}
if
(
stat
==
0
)
nfree
++
;
}
while
(
++
clst
<
fs
->
n_fatent
);
}
else
{
/* FAT16/32: Scan WORD/DWORD FAT entries */
clst
=
fs
->
n_fatent
;
/* Number of entries */
sect
=
fs
->
fatbase
;
/* Top of the FAT */
i
=
0
;
/* Offset in the sector */
do
{
/* Counts numbuer of entries with zero in the FAT */
if
(
i
==
0
)
{
res
=
move_window
(
fs
,
sect
++
);
if
(
res
!=
FR_OK
)
break
;
}
if
(
fs
->
fs_type
==
FS_FAT16
)
{
if
(
ld_word
(
fs
->
win
+
i
)
==
0
)
nfree
++
;
i
+=
2
;
}
else
{
if
((
ld_dword
(
fs
->
win
+
i
)
&
0x0FFFFFFF
)
==
0
)
nfree
++
;
i
+=
4
;
}
i
%=
SS
(
fs
);
}
while
(
--
clst
);
}
*
nclst
=
nfree
;
/* Return the free clusters */
fs
->
free_clst
=
nfree
;
/* Now free_clst is valid */
fs
->
fsi_flag
|=
1
;
/* FAT32: FSInfo is to be updated */
return
res
;
}
#if !FF_FS_READONLY
/*-----------------------------------------------------------------------*/
...
...
@@ -4304,11 +4349,6 @@ FRESULT f_getfree (
{
FRESULT
res
;
FATFS
*
fs
;
DWORD
nfree
,
clst
,
stat
;
QWORD
sect
;
UINT
i
;
FFOBJID
obj
;
/* Get logical drive */
res
=
find_volume
(
&
path
,
&
fs
,
0
);
...
...
@@ -4319,38 +4359,7 @@ FRESULT f_getfree (
*
nclst
=
fs
->
free_clst
;
}
else
{
/* Scan FAT to obtain number of free clusters */
nfree
=
0
;
if
(
fs
->
fs_type
==
FS_FAT12
)
{
/* FAT12: Scan bit field FAT entries */
clst
=
2
;
obj
.
fs
=
fs
;
do
{
stat
=
get_fat
(
&
obj
,
clst
);
if
(
stat
==
0xFFFFFFFF
)
{
res
=
FR_DISK_ERR
;
break
;
}
if
(
stat
==
1
)
{
res
=
FR_INT_ERR
;
break
;
}
if
(
stat
==
0
)
nfree
++
;
}
while
(
++
clst
<
fs
->
n_fatent
);
}
else
{
/* FAT16/32: Scan WORD/DWORD FAT entries */
clst
=
fs
->
n_fatent
;
/* Number of entries */
sect
=
fs
->
fatbase
;
/* Top of the FAT */
i
=
0
;
/* Offset in the sector */
do
{
/* Counts numbuer of entries with zero in the FAT */
if
(
i
==
0
)
{
res
=
move_window
(
fs
,
sect
++
);
if
(
res
!=
FR_OK
)
break
;
}
if
(
fs
->
fs_type
==
FS_FAT16
)
{
if
(
ld_word
(
fs
->
win
+
i
)
==
0
)
nfree
++
;
i
+=
2
;
}
else
{
if
((
ld_dword
(
fs
->
win
+
i
)
&
0x0FFFFFFF
)
==
0
)
nfree
++
;
i
+=
4
;
}
i
%=
SS
(
fs
);
}
while
(
--
clst
);
}
*
nclst
=
nfree
;
/* Return the free clusters */
fs
->
free_clst
=
nfree
;
/* Now free_clst is valid */
fs
->
fsi_flag
|=
1
;
/* FAT32: FSInfo is to be updated */
res
=
fat_count_free_entries
(
nclst
,
fs
);
}
}
...
...
source/ff.h
浏览文件 @
ac9f86b3
...
...
@@ -450,7 +450,8 @@ FRESULT f_getclustinfo (FIL* fp, DWORD* fclust, DWORD* fcount); /* get the clust
FRESULT
f_checkopenlock
(
int
index
);
FRESULT
sync_fs
(
FATFS
*
fs
);
FRESULT
sync_window
(
FATFS
*
fs
);
FRESULT
move_window
(
FATFS
*
fs
,
QWORD
sector
);
FRESULT
move_window
(
FATFS
*
fs
,
QWORD
sector
);
FRESULT
fat_count_free_entries
(
DWORD
*
nclst
,
FATFS
*
fs
);
void
get_fileinfo
(
DIR
*
dp
,
FILINFO
*
fno
);
DWORD
get_fat
(
FFOBJID
*
obj
,
DWORD
clst
);
FRESULT
put_fat
(
FATFS
*
fs
,
DWORD
clst
,
DWORD
val
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录