fix: 修复littlefs编译fs.c缺少头文件件依赖配置+若干musl库的缺失问题+多分区规格宏配置问题
close:#I3VT11 Signed-off-by: li_zan <371442490@qq.com>
This commit is contained in:
parent
6e162a9318
commit
7259289bd9
|
@ -32,6 +32,14 @@ static_library("fs_operations") {
|
|||
"./fs.c",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"../../../kernel/arch/include",
|
||||
"../../../kernel/include",
|
||||
"../../../utils",
|
||||
"../../../kal/posix/include",
|
||||
"./",
|
||||
]
|
||||
|
||||
deps = [ "//kernel/liteos_m/kal/posix" ]
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "fs_operations.h"
|
||||
#include "los_config.h"
|
||||
#ifdef LOSCFG_SUPPORT_FATFS
|
||||
#include "fatfs.h"
|
||||
#endif
|
||||
|
@ -426,11 +427,11 @@ int stat(const char *path, struct stat *buf)
|
|||
errno = ENODEV;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
if (g_fs->fsFops == NULL || g_fs->fsFops->Stat == NULL) {
|
||||
if (g_fs->fsFops == NULL || g_fs->fsFops->Getattr == NULL) {
|
||||
errno = ENOSYS;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
return g_fs->fsFops->Stat(path, buf);
|
||||
return g_fs->fsFops->Getattr(path, buf);
|
||||
}
|
||||
|
||||
int fsync(int fd)
|
||||
|
|
|
@ -39,7 +39,6 @@ static_library("littlefs") {
|
|||
"../../../kernel/include",
|
||||
"../../../utils",
|
||||
"../../../kal/cmsis",
|
||||
"../../../kal",
|
||||
"../../../kal/posix/include",
|
||||
"./",
|
||||
"../",
|
||||
|
|
|
@ -31,15 +31,16 @@
|
|||
|
||||
#define _GNU_SOURCE 1
|
||||
#include "lfs_api.h"
|
||||
#include "los_config.h"
|
||||
|
||||
lfs_t g_lfs;
|
||||
FileDirInfo g_lfsDir[LFS_MAX_OPEN_DIRS] = {0};
|
||||
|
||||
struct FileOpInfo g_fsOp[LFS_MAX_MOUNT_SIZE] = {0};
|
||||
struct FileOpInfo g_fsOp[LOSCFG_LFS_MAX_MOUNT_SIZE] = {0};
|
||||
static LittleFsHandleStruct g_handle[LITTLE_FS_MAX_OPEN_FILES] = {0};
|
||||
struct dirent g_nameValue;
|
||||
static pthread_mutex_t g_FslocalMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static const char *g_littlefsMntName[LFS_MAX_MOUNT_SIZE] = {"/a","/b","/c"};
|
||||
static const char *g_littlefsMntName[LOSCFG_LFS_MAX_MOUNT_SIZE] = {"/a","/b","/c"};
|
||||
|
||||
LittleFsHandleStruct *LfsAllocFd(const char *fileName, int *fd)
|
||||
{
|
||||
|
@ -126,7 +127,7 @@ BOOL CheckPathIsMounted(const char *pathName, struct FileOpInfo **fileOpInfo)
|
|||
int len = strlen(pathName) + 1;
|
||||
|
||||
pthread_mutex_lock(&g_FslocalMutex);
|
||||
for (int i = 0; i < LFS_MAX_MOUNT_SIZE; i++) {
|
||||
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
|
||||
if (g_fsOp[i].useFlag == 1) {
|
||||
mountPathNameLen = strlen(g_fsOp[i].dirName);
|
||||
if (len < mountPathNameLen + 1) {
|
||||
|
@ -151,7 +152,7 @@ BOOL CheckPathIsMounted(const char *pathName, struct FileOpInfo **fileOpInfo)
|
|||
struct FileOpInfo *AllocMountRes(const char* target, struct FileOps *fileOps)
|
||||
{
|
||||
pthread_mutex_lock(&g_FslocalMutex);
|
||||
for (int i = 0; i < LFS_MAX_MOUNT_SIZE; i++) {
|
||||
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
|
||||
if (g_fsOp[i].useFlag == 0 && strcmp(target, g_littlefsMntName[i]) == 0) {
|
||||
g_fsOp[i].useFlag = 1;
|
||||
g_fsOp[i].fsVops = fileOps;
|
||||
|
@ -167,7 +168,7 @@ struct FileOpInfo *AllocMountRes(const char* target, struct FileOps *fileOps)
|
|||
|
||||
int SetDefaultMountPath(int pathNameIndex, const char* target)
|
||||
{
|
||||
if (pathNameIndex >= LFS_MAX_MOUNT_SIZE) {
|
||||
if (pathNameIndex >= LOSCFG_LFS_MAX_MOUNT_SIZE) {
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
|
@ -180,7 +181,7 @@ int SetDefaultMountPath(int pathNameIndex, const char* target)
|
|||
struct FileOpInfo *GetMountRes(const char *target, int *mountIndex)
|
||||
{
|
||||
pthread_mutex_lock(&g_FslocalMutex);
|
||||
for (int i = 0; i < LFS_MAX_MOUNT_SIZE; i++) {
|
||||
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
|
||||
if (g_fsOp[i].useFlag == 1) {
|
||||
if (g_fsOp[i].dirName && strcmp(target, g_fsOp[i].dirName) == 0) {
|
||||
*mountIndex = i;
|
||||
|
@ -196,7 +197,7 @@ struct FileOpInfo *GetMountRes(const char *target, int *mountIndex)
|
|||
|
||||
int FreeMountResByIndex(int mountIndex)
|
||||
{
|
||||
if (mountIndex < 0 || mountIndex >= LFS_MAX_MOUNT_SIZE) {
|
||||
if (mountIndex < 0 || mountIndex >= LOSCFG_LFS_MAX_MOUNT_SIZE) {
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
|
@ -214,7 +215,7 @@ int FreeMountResByIndex(int mountIndex)
|
|||
int FreeMountRes(const char *target)
|
||||
{
|
||||
pthread_mutex_lock(&g_FslocalMutex);
|
||||
for (int i = 0; i < LFS_MAX_MOUNT_SIZE; i++) {
|
||||
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
|
||||
if (g_fsOp[i].useFlag == 1) {
|
||||
if (g_fsOp[i].dirName && strcmp(target, g_fsOp[i].dirName) == 0) {
|
||||
g_fsOp[i].useFlag = 0;
|
||||
|
|
|
@ -91,11 +91,6 @@ typedef struct {
|
|||
#define LFS_MAX_OPEN_DIRS 10
|
||||
#endif
|
||||
|
||||
#ifndef LFS_MAX_MOUNT_SIZE
|
||||
#define LFS_MAX_MOUNT_SIZE 3
|
||||
#endif
|
||||
|
||||
|
||||
LittleFsHandleStruct *GetFreeFd(int *fd);
|
||||
|
||||
int InitMountInfo(const char *fileSystemType, const struct MountOps *fsMops);
|
||||
|
|
|
@ -590,6 +590,12 @@ extern UINT8 *m_aucSysMem0;
|
|||
#ifndef LOSCFG_SUPPORT_LITTLEFS
|
||||
#define LOSCFG_SUPPORT_LITTLEFS 1
|
||||
#endif
|
||||
|
||||
#ifndef LOSCFG_LFS_MAX_MOUNT_SIZE
|
||||
#define LOSCFG_LFS_MAX_MOUNT_SIZE 3
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup los_config
|
||||
* Configuration trace tool
|
||||
|
|
Loading…
Reference in New Issue