未验证 提交 eb0df6b1 编写于 作者: xqyjlj's avatar xqyjlj 提交者: GitHub

feat(components/dfs/filesystems/elmfat/dfs_elm.c): add st_blocks su… (#7091)

上级 1cf26a8e
......@@ -29,6 +29,13 @@
#include <dfs_fs.h>
#include <dfs_file.h>
#undef SS
#if FF_MAX_SS == FF_MIN_SS
#define SS(fs) ((UINT)FF_MAX_SS) /* Fixed sector size */
#else
#define SS(fs) ((fs)->ssize) /* Variable sector size */
#endif
static rt_device_t disk[FF_VOLUMES] = {0};
static int elm_result_to_dfs(FRESULT result)
......@@ -751,9 +758,12 @@ int dfs_elm_rename(struct dfs_filesystem *fs, const char *oldpath, const char *n
int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
{
FATFS *f;
FILINFO file_info;
FRESULT result;
f = (FATFS *)fs->data;
#if FF_VOLUMES > 1
int vol;
char *drivers_fn;
......@@ -793,7 +803,16 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
st->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
st->st_size = file_info.fsize;
st->st_blksize = f->csize * SS(f);
if (file_info.fattrib & AM_ARC)
{
st->st_blocks = file_info.fsize ? ((file_info.fsize - 1) / SS(f) / f->csize + 1) : 0;
st->st_blocks *= (st->st_blksize / 512); // man say st_blocks is number of 512B blocks allocated
}
else
{
st->st_blocks = f->csize;
}
/* get st_mtime. */
{
struct tm tm_file;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册