liteos_m文件系统中,components/fs/littlefs/lfs_api.c中新增注册.Fstat = LfsFstat接口。
Change-Id: Ic56364d1df71b369abfa5be617fc63b77a65b27b Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
This commit is contained in:
parent
4e0bf74f4a
commit
36b7577c5e
|
@ -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;
|
||||
}
|
|
@ -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_ */
|
||||
|
|
Loading…
Reference in New Issue