提交 36b7577c 编写于 作者: H Hongjin Li

liteos_m文件系统中,components/fs/littlefs/lfs_api.c中新增注册.Fstat = LfsFstat接口。

Change-Id: Ic56364d1df71b369abfa5be617fc63b77a65b27b
Signed-off-by: NHongjin Li <lihongjin1@huawei.com>
上级 4e0bf74f
......@@ -322,6 +322,7 @@ const struct FileOps g_lfsFops = {
.Rename = LfsRename,
.Getattr = LfsStat,
.Fsync = LfsFsync,
.Fstat = LfsFstat,
};
int LfsMount(const char *source, const char *target, const char *fileSystemType, unsigned long mountflags,
......@@ -772,3 +773,33 @@ int LfsFsync(int fd)
}
return ret;
}
int LfsFstat(int fd, struct stat *buf)
{
int ret;
struct lfs_info info;
if (buf == NULL) {
errno = EFAULT;
return FS_FAILURE;
}
if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF;
return VFS_ERROR;
}
ret = lfs_stat(g_handle[fd].lfsHandle, g_handle[fd].pathName, &info);
if (ret == 0) {
buf->st_size = info.size;
if (info.type == LFS_TYPE_REG) {
buf->st_mode = S_IFREG;
} else {
buf->st_mode = S_IFDIR;
}
} else {
errno = LittlefsErrno(ret);
ret = VFS_ERROR;
}
return ret;
}
\ No newline at end of file
......@@ -110,6 +110,7 @@ int LfsClose(int fd);
int LfsRename(const char *oldName, const char *newName);
int LfsStat(const char *path, struct stat *buf);
int LfsFsync(int fd);
int LfsFstat(int fd, struct stat *buf);
int SetDefaultMountPath(int pathNameIndex, const char* target);
#endif /* _LFS_API_H_ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册