156 lines
4.0 KiB
C
156 lines
4.0 KiB
C
/*================================================================
|
|
Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
|
|
Quectel Wireless Solutions Proprietary and Confidential.
|
|
=================================================================*/
|
|
|
|
#ifndef _QUEC_FS_H
|
|
#define _QUEC_FS_H
|
|
|
|
#include "quec_rtos.h"
|
|
#include "lfs.h"
|
|
#include "lfs_api.h"
|
|
|
|
typedef unsigned int File_Handle;
|
|
|
|
|
|
#define QFS_ID_MAX 3
|
|
|
|
#define EXTERNAL_NORFLASH 1
|
|
#define INTERNAL_NORFLASH 0
|
|
|
|
|
|
#ifdef QUEC_FS_WEAR_BALANCE_VERIFY
|
|
#define FS_FLASH_BLOCK_SIZE (1024*4) //each block size:4K byte
|
|
#endif
|
|
|
|
//freddy @20200713 Add for external fs
|
|
typedef struct
|
|
{
|
|
unsigned int start_addr;//外部spi的起始地址
|
|
unsigned int size;//挂载为文件系统的大小
|
|
unsigned char spi_port;//SPI端口
|
|
}ex_spifs_info;
|
|
|
|
typedef struct
|
|
{
|
|
quec_mutex_t mutex;
|
|
char disk_sym;
|
|
lfs_t lfs;
|
|
struct lfs_config cfg;
|
|
lfs_flash_info flash_info;
|
|
bool is_inited;
|
|
char *patition_name;
|
|
unsigned char is_exflash;
|
|
ex_spifs_info spi_info;//外部SPI的信息
|
|
} qfs_ctx_t;
|
|
|
|
typedef struct
|
|
{
|
|
int fs_id;
|
|
lfs_file_t file;
|
|
} QFILE;
|
|
|
|
typedef struct
|
|
{
|
|
int fs_id;
|
|
lfs_dir_t dir;
|
|
} QDIR;
|
|
|
|
#define GET_FILE_PATH(path) (path+2)
|
|
|
|
#define FILE_OPEN_FLAGS_R (LFS_O_RDONLY)
|
|
#define FILE_OPEN_FLAGS_W (LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC)
|
|
#define FILE_OPEN_FLAGS_A (LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND)
|
|
#define FILE_OPEN_FLAGS_RPluse (LFS_O_RDWR)
|
|
#define FILE_OPEN_FLAGS_WPluse (LFS_O_RDWR | LFS_O_CREAT | LFS_O_TRUNC)
|
|
#define FILE_OPEN_FLAGS_APluse (LFS_O_RDWR | LFS_O_CREAT | LFS_O_APPEND)
|
|
|
|
#define U_DISK_SYM 'U'
|
|
#define B_DISK_SYM 'B'
|
|
|
|
int qfs_per_init(int fs_id, char disk_sym, unsigned char is_format);
|
|
|
|
void qfs_per_deinit(int fs_id);
|
|
|
|
int qfs_deinit(char disk_sym);
|
|
|
|
int qfs_get_fs_id_from_disk_sym(char disk_sym);
|
|
|
|
int qfs_init(char disk_sym, char *patition_name, unsigned char is_format);
|
|
|
|
int qextfs_init(char disk_sym, char *patition_name, unsigned char is_format, unsigned char spi_port, unsigned int startaddr, unsigned int size);
|
|
|
|
int qfs_format(int fs_id);
|
|
|
|
int qfs_mount(int fs_id);
|
|
|
|
int qfs_unmount(int fs_id);
|
|
|
|
int qfs_size(int fs_id);
|
|
|
|
int qfs_used_size(int fs_id);
|
|
|
|
int qfs_free_size(int fs_id);
|
|
|
|
int qfs_remove(int fs_id, const char *path);
|
|
|
|
int qfs_rename(int fs_id, const char *oldpath, const char *newpath);
|
|
|
|
int qfs_copy(int old_fs_id, int new_fs_id, const char *oldpath, const char *newpath);
|
|
|
|
int qfs_access(int fs_id, const char *path);
|
|
|
|
int qfs_stat(int fs_id, const char *path, struct lfs_info *info);
|
|
|
|
int qfs_file_open(int fs_id, lfs_file_t *file,
|
|
const char *path, int flags);
|
|
|
|
int qfs_file_opencfg(int fs_id, lfs_file_t *file,
|
|
const char *path, int flags,
|
|
const struct lfs_file_config *config);
|
|
|
|
int qfs_file_close(int fs_id, lfs_file_t *file);
|
|
|
|
int qfs_file_sync(int fs_id, lfs_file_t *file);
|
|
|
|
lfs_ssize_t qfs_file_read(int fs_id, lfs_file_t *file,
|
|
void *buffer, lfs_size_t size);
|
|
|
|
lfs_ssize_t qfs_file_write(int fs_id, lfs_file_t *file,
|
|
const void *buffer, lfs_size_t size);
|
|
|
|
lfs_soff_t qfs_file_seek(int fs_id, lfs_file_t *file,
|
|
lfs_soff_t off, int whence);
|
|
|
|
int qfs_file_truncate(int fs_id, lfs_file_t *file, lfs_off_t size);
|
|
|
|
lfs_soff_t qfs_file_tell(int fs_id, lfs_file_t *file);
|
|
|
|
int qfs_file_rewind(int fs_id, lfs_file_t *file);
|
|
|
|
lfs_soff_t qfs_file_size(int fs_id, lfs_file_t *file);
|
|
|
|
int qfs_mkdir(int fs_id, const char *path);
|
|
|
|
int qfs_dir_open(int fs_id, lfs_dir_t *dir, const char *path);
|
|
|
|
int qfs_dir_close(int fs_id, lfs_dir_t *dir);
|
|
|
|
int qfs_dir_read(int fs_id, lfs_dir_t *dir, struct lfs_info *info);
|
|
|
|
int qfs_dir_seek(int fs_id, lfs_dir_t *dir, lfs_off_t off);
|
|
|
|
lfs_soff_t qfs_dir_tell(int fs_id, lfs_dir_t *dir);
|
|
|
|
int qfs_dir_rewind(int fs_id, lfs_dir_t *dir);
|
|
|
|
int qfs_traverse(int fs_id, int (*cb)(void*, lfs_block_t), void *data);
|
|
|
|
int qfs_deorphan(int fs_id);
|
|
|
|
int qfs_set_flash_atomic_size(unsigned int read_size,unsigned int prog_size);
|
|
|
|
#endif
|
|
|
|
|