提交 5479dd66 编写于 作者: C chenjing

fix: add liteos_m vfs

Close #I3R493

Change-Id: Ic799182b46c6c04c879d1b2202bda6b1f2cf40df
上级 e7a3659b
......@@ -27,6 +27,12 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
static_library("fs_operations") {
sources = [
"./fs.c",
]
}
declare_args() {
enable_ohos_kernel_liteos_m_fatfs = true
enable_ohos_kernel_liteos_m_littlefs = false
......@@ -34,6 +40,7 @@ declare_args() {
group("fs") {
deps = []
deps += [ ".:fs_operations" ]
if (enable_ohos_kernel_liteos_m_fatfs == true) {
deps += [ "fatfs:fatfs" ]
}
......
......@@ -34,10 +34,10 @@ static_library("fatfs") {
"//third_party/FatFs/source/ffsystem.c",
"//third_party/FatFs/source/ffunicode.c",
"fatfs.c",
"fs.c",
]
include_dirs = [
"../",
"../../../kernel/arch/include",
"../../../kernel/include",
"../../../utils",
......
......@@ -41,9 +41,8 @@
#include "los_compiler.h"
#include "los_debug.h"
#include "cmsis_os2.h"
#include "fs_operations.h"
#define FS_SUCCESS 0
#define FS_FAILURE (-1)
/* the max name length of different parts should not bigger than 32 */
#define FS_DRIVE_NAME_MAX_LEN 32
......@@ -1258,8 +1257,8 @@ OUT:
static int do_truncate(int fd, off_t length, UINT count)
{
FRESULT res;
INT32 ret = FR_OK;
FRESULT res = FR_OK;
INT32 ret = FS_SUCCESS;
DWORD csz;
csz = (DWORD)(g_handle[fd].fil.obj.fs)->csize * SS(g_handle[fd].fil.obj.fs); /* Cluster size */
......@@ -1420,3 +1419,27 @@ OUT:
FsUnlock();
return ret;
}
struct MountOps g_fatfsMnt = {
.Mount = fatfs_mount,
.Umount = fatfs_umount,
.Umount2 = fatfs_umount2,
.Statfs = fatfs_statfs,
};
struct FileOps g_fatfsFops = {
.Mkdir = fatfs_mkdir,
.Unlink = fatfs_unlink,
.Rmdir = fatfs_rmdir,
.Opendir = fatfs_opendir,
.Readdir = fatfs_readdir,
.Closedir = fatfs_closedir,
.Open = fatfs_open,
.Close = fatfs_close,
.Write = fatfs_write,
.Read = fatfs_read,
.Seek = fatfs_lseek,
.Rename = fatfs_rename,
.Getattr = fatfs_stat,
.Fsync = fatfs_fsync,
};
\ No newline at end of file
......@@ -28,7 +28,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "fs_operations.h"
#include "fatfs.h"
#include "dirent.h"
#include "errno.h"
......@@ -42,6 +42,9 @@
#include "sys/stat.h"
#include "unistd.h"
struct FsMap g_fsmap[MAX_FILESYSTEM_LEN] = {0};
struct FsMap *g_fs = NULL;
#ifdef LOSCFG_NET_LWIP_SACK
#include "lwip/lwipopts.h"
#include "lwip/sockets.h"
......@@ -92,12 +95,12 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
size_t tmpLen = strlen(cwd) + strlen(path) + offset;
char *tmpBuf = (char *)malloc(tmpLen);
if (tmpBuf == NULL) {
return 0;
return FS_SUCCESS;
}
if (-1 == sprintf_s(tmpBuf, tmpLen, "/%s/%s/", cwd, path)) {
free(tmpBuf);
return 0;
return FS_SUCCESS;
}
char *p;
......@@ -106,7 +109,7 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
while ((p = strstr(tmpBuf, "/./")) != NULL) {
if (EOK != memmove_s(p, tmpLen - (p - tmpBuf), p + offset, tmpLen - (p - tmpBuf) - offset)) {
free(tmpBuf);
return 0;
return FS_SUCCESS;
}
}
......@@ -114,7 +117,7 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
while ((p = strstr(tmpBuf, "//")) != NULL) {
if (EOK != memmove_s(p, tmpLen - (p - tmpBuf), p + 1, tmpLen - (p - tmpBuf) - 1)) {
free(tmpBuf);
return 0;
return FS_SUCCESS;
}
}
......@@ -127,7 +130,7 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
}
if (EOK != memmove_s(start, tmpLen - (start - tmpBuf), p + offset, tmpLen - (p - tmpBuf) - offset)) {
free(tmpBuf);
return 0;
return FS_SUCCESS;
}
}
......@@ -144,7 +147,7 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
if (EOK != memcpy_s(buf, bufSize, tmpBuf, (((totalLen + 1) > bufSize) ? bufSize : (totalLen + 1)))) {
free(tmpBuf);
return 0;
return FS_SUCCESS;
}
buf[bufSize - 1] = 0;
......@@ -153,21 +156,83 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
}
#endif
static void InitMountInfo(void)
{
extern struct MountOps g_fatfsMnt;
extern struct FileOps g_fatfsFops;
g_fsmap[0].fileSystemtype = strdup("fat");
g_fsmap[0].fsMops = &g_fatfsMnt;
g_fsmap[0].fsFops = &g_fatfsFops;
extern struct MountOps g_lfsMnt;
extern struct FileOps g_lfsFops;
g_fsmap[1].fileSystemtype = strdup("littlefs");
g_fsmap[1].fsMops = &g_lfsMnt;
g_fsmap[1].fsFops = &g_lfsFops;
}
static struct FsMap *MountFindfs(const char *fileSystemtype)
{
struct FsMap *m = NULL;
for (int i = 0; i < MAX_FILESYSTEM_LEN; i++) {
m = &(g_fsmap[i]);
if (m->fileSystemtype && strcmp(fileSystemtype, m->fileSystemtype) == 0) {
return m;
}
}
return NULL;
}
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data)
{
return fatfs_mount(source, target, filesystemtype, mountflags, data);
static int initFlag = 0;
if (initFlag == 0) {
InitMountInfo();
initFlag = 1;
}
g_fs = MountFindfs(filesystemtype);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsMops == NULL || g_fs->fsMops->Mount == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsMops->Mount(source, target, filesystemtype, mountflags, data);
}
int umount(const char *target)
{
return fatfs_umount(target);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsMops == NULL || g_fs->fsMops->Umount == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsMops->Umount(target);
}
int umount2(const char *target, int flag)
{
return fatfs_umount2(target, flag);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsMops == NULL || g_fs->fsMops->Umount2 == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsMops->Umount2(target, flag);
}
int open(const char *path, int oflag, ...)
......@@ -176,30 +241,30 @@ int open(const char *path, int oflag, ...)
unsigned flags = O_RDONLY | O_WRONLY | O_RDWR | O_APPEND | O_CREAT | O_LARGEFILE | O_TRUNC | O_EXCL | O_DIRECTORY;
if ((unsigned)oflag & ~flags) {
errno = EINVAL;
return -1;
return FS_FAILURE;
}
size_t pathLen = strlen(path) + 1;
char *canonicalPath = (char *)malloc(pathLen);
if (!canonicalPath) {
errno = ENOMEM;
return -1;
return FS_FAILURE;
}
if (GetCanonicalPath(NULL, path, canonicalPath, pathLen) == 0) {
FREE_AND_SET_NULL(canonicalPath);
errno = ENOMEM;
return -1;
return FS_FAILURE;
}
if (strcmp(canonicalPath, RANDOM_DEV_PATH) == 0) {
FREE_AND_SET_NULL(canonicalPath);
if ((O_ACCMODE & (unsigned)oflag) != O_RDONLY) {
errno = EPERM;
return -1;
return FS_FAILURE;
}
if ((unsigned)oflag & O_DIRECTORY) {
errno = ENOTDIR;
return -1;
return FS_FAILURE;
}
return RANDOM_DEV_FD;
}
......@@ -207,21 +272,29 @@ int open(const char *path, int oflag, ...)
FREE_AND_SET_NULL(canonicalPath);
if ((unsigned)oflag & O_DIRECTORY) {
errno = EPERM;
return -1;
return FS_FAILURE;
}
errno = EISDIR;
return -1;
return FS_FAILURE;
}
FREE_AND_SET_NULL(canonicalPath);
#endif
return fatfs_open(path, oflag);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Open == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Open(path, oflag);
}
int close(int fd)
{
#ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) {
return 0;
return FS_SUCCESS;
}
#endif
#ifdef LOSCFG_NET_LWIP_SACK
......@@ -229,7 +302,15 @@ int close(int fd)
return closesocket(fd);
}
#endif
return fatfs_close(fd);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Close == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Close(fd);
}
ssize_t read(int fd, void *buf, size_t nbyte)
......@@ -237,11 +318,11 @@ ssize_t read(int fd, void *buf, size_t nbyte)
#ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) {
if (nbyte == 0) {
return 0;
return FS_SUCCESS;
}
if (buf == NULL) {
errno = EINVAL;
return -1;
return FS_FAILURE;
}
if (nbyte > 1024) {
nbyte = 1024; /* hks_generate_random: random_size must <= 1024 */
......@@ -249,7 +330,7 @@ ssize_t read(int fd, void *buf, size_t nbyte)
struct hks_blob key = {HKS_BLOB_TYPE_RAW, (uint8_t *)buf, nbyte};
if (hks_generate_random(&key) != 0) {
errno = EIO;
return -1;
return FS_FAILURE;
}
return (ssize_t)nbyte;
}
......@@ -259,7 +340,15 @@ ssize_t read(int fd, void *buf, size_t nbyte)
return recv(fd, buf, nbyte, 0);
}
#endif
return fatfs_read(fd, buf, nbyte);
if (g_fs->fsFops == NULL || g_fs->fsFops->Read == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
return g_fs->fsFops->Read(fd, buf, nbyte);
}
ssize_t write(int fd, const void *buf, size_t nbyte)
......@@ -267,7 +356,7 @@ ssize_t write(int fd, const void *buf, size_t nbyte)
#ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) {
errno = EBADF; /* "/dev/random" is readonly */
return -1;
return FS_FAILURE;
}
#endif
#ifdef LOSCFG_NET_LWIP_SACK
......@@ -275,70 +364,182 @@ ssize_t write(int fd, const void *buf, size_t nbyte)
return send(fd, buf, nbyte, 0);
}
#endif
return fatfs_write(fd, buf, nbyte);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Write == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Write(fd, buf, nbyte);
}
off_t lseek(int fd, off_t offset, int whence)
{
return fatfs_lseek(fd, offset, whence);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Seek == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Seek(fd, offset, whence);
}
int unlink(const char *path)
{
return fatfs_unlink(path);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Unlink == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Unlink(path);
}
int fstat(int fd, struct stat *buf)
{
return fatfs_fstat(fd, buf);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Fstat == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Fstat(fd, buf);
}
int stat(const char *path, struct stat *buf)
{
return fatfs_stat(path, buf);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Stat == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Stat(path, buf);
}
int fsync(int fd)
{
return fatfs_fsync(fd);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Fsync == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Fsync(fd);
}
int mkdir(const char *path, mode_t mode)
{
return fatfs_mkdir(path, mode);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Mkdir == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Mkdir(path, mode);
}
DIR *opendir(const char *dirName)
{
return fatfs_opendir(dirName);
if (g_fs == NULL) {
errno = ENODEV;
return NULL;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Opendir == NULL) {
errno = ENOSYS;
return NULL;
}
return g_fs->fsFops->Opendir(dirName);
}
struct dirent *readdir(DIR *dir)
{
return fatfs_readdir(dir);
if (g_fs == NULL) {
errno = ENODEV;
return NULL;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Readdir == NULL) {
errno = ENOSYS;
return NULL;
}
return g_fs->fsFops->Readdir(dir);
}
int closedir(DIR *dir)
{
return fatfs_closedir(dir);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Closedir == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Closedir(dir);
}
int rmdir(const char *path)
{
return fatfs_rmdir(path);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Rmdir == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Rmdir(path);
}
int rename(const char *oldName, const char *newName)
{
return fatfs_rename(oldName, newName);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Rename == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Rename(oldName, newName);
}
int statfs(const char *path, struct statfs *buf)
{
return fatfs_statfs(path, buf);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsMops == NULL || g_fs->fsMops->Statfs == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsMops->Statfs(path, buf);
}
int ftruncate(int fd, off_t length)
{
return fatfs_ftruncate(fd, length);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Ftruncate == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Ftruncate(fd, length);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _FS_OPERATIONS_H_
#define _FS_OPERATIONS_H_
#include "fcntl.h"
#include "dirent.h"
#include "unistd.h"
#include "sys/mount.h"
#include "sys/stat.h"
#include "sys/statfs.h"
#define FS_SUCCESS 0
#define FS_FAILURE (-1)
#define MAX_FILESYSTEM_LEN 2
struct MountOps {
int (*Mount)(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags,
const void *data);
int (*Umount)(const char* target);
int (*Umount2)(const char* target, int flag);
int (*Statfs)(const char *path, struct statfs *buf);
};
struct FsMap {
const char *fileSystemtype;
const struct MountOps *fsMops;
const struct FileOps *fsFops;
};
struct FileOps {
int (*Open)(const char *path, int openFlag, ...);
int (*Close)(int fd);
int (*Unlink)(const char *fileName);
int (*Rmdir)(const char *dirName);
int (*Mkdir)(const char *dirName, mode_t mode);
struct dirent *(*Readdir)(DIR *dir);
DIR *(*Opendir)(const char *dirName);
int (*Closedir)(DIR *dir);
int (*Read)(int fd, void *buf, size_t len);
int (*Write)(int fd, const void *buf, size_t len);
off_t (*Seek)(int fd, off_t offset, int whence);
int (*Getattr)(const char *path, struct stat *buf);
int (*Rename)(const char *oldName, const char *newName);
int (*Fsync)(int fd);
int (*Fstat)(int fd, struct stat *buf);
int (*Stat)(const char *path, struct stat *buf);
int (*Ftruncate)(int fd, off_t length);
};
#endif /* _FS_OPERATIONS_H_ */
......@@ -37,7 +37,6 @@ FileDirInfo g_lfsDir[LFS_MAX_OPEN_DIRS] = {0};
FileOpInfo g_fsOp;
static LittleFsHandleStruct g_handle[LITTLE_FS_MAX_OPEN_FILES] = {0};
struct dirent g_nameValue;
struct FsMap g_fsmap[MAX_FILE_SYSTEM_LEN] = {0};
static pthread_mutex_t g_FslocalMutex = PTHREAD_MUTEX_INITIALIZER;
FileOpInfo GetFsOpInfo(void)
......@@ -94,41 +93,12 @@ lfs_dir_t *GetFreeDir()
return NULL;
}
int InitMountInfo(const char *fileSystemType, const struct MountOps *fsMops)
{
int len = strlen(fileSystemType) + 1;
for (int i = 0; i < MAX_FILE_SYSTEM_LEN; i++) {
if (g_fsmap[i].fileSystemtype == NULL) {
g_fsmap[i].fileSystemtype = (char*)malloc(len);
memcpy_s(g_fsmap[i].fileSystemtype, LITTLE_FS_MAX_NAME_LEN, fileSystemType, len);
g_fsmap[i].fsMops = fsMops;
return VFS_OK;
}
}
return VFS_ERROR;
}
const struct FsMap *MountFindfs(const char *fileSystemtype)
{
struct FsMap *m = NULL;
for (int i = 0; i < MAX_FILE_SYSTEM_LEN; i++) {
m = &(g_fsmap[i]);
if (m->fileSystemtype && strcmp(fileSystemtype, m->fileSystemtype) == 0) {
return m;
}
}
return (const struct FsMap *)NULL;
}
const struct MountOps g_fsMnt = {
const struct MountOps g_lfsMnt = {
.Mount = LfsMount,
.Umount = LfsUmount,
};
const struct FileOps g_lfsVops = {
const struct FileOps g_lfsFops = {
.Mkdir = LfsMkdir,
.Unlink = LfsUnlink,
.Rmdir = LfsRmdir,
......@@ -285,7 +255,8 @@ int LfsClose(int fd)
pthread_mutex_lock(&g_FslocalMutex);
ret = lfs_file_close(&g_lfs, &(g_handle[fd].file));
g_handle[fd].useFlag = 0;
if (g_handle[fd].pathName != NULL) {
if (g_handle[fd].pathName != NULL) {
free(g_handle[fd].pathName);
g_handle[fd].pathName = NULL;
}
......
......@@ -59,34 +59,6 @@ typedef struct {
lfs_file_t file;
} LittleFsHandleStruct;
struct MountOps {
int (*Mount)(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags,
const void *data);
int (*Umount)(const char* target);
};
struct FsMap {
const char *fileSystemtype;
const struct MountOps *fsMops;
};
struct FileOps {
int (*Open)(const char *path, int openFlag, int mode);
int (*Close)(int fd);
int (*Unlink)(const char *fileName);
int (*Rmdir)(const char *dirName);
int (*Mkdir)(const char *dirName, mode_t mode);
struct dirent *(*Readdir)(DIR *dir);
DIR *(*Opendir)(const char *dirName);
int (*Closedir)(const DIR *dir);
int (*Read)(int fd, void *buf, size_t len);
int (*Write)(int fd, const void *buf, size_t len);
int (*Seek)(int fd, off_t offset, int whence);
int (*Getattr)(const char *path, struct stat *buf);
int (*Rename)(const char *oldName, const char *newName);
int (*Fsync)(int fd);
};
typedef struct {
struct FileOps *fsVops;
} FileOpInfo;
......@@ -104,7 +76,6 @@ typedef struct {
#define MAX_BUFFER_LEN 100
#define MAX_WRITE_FILE_LEN 500
#define MAX_READ_FILE_LEN 500
#define MAX_FILE_SYSTEM_LEN 2
#ifndef LFS_MAX_OPEN_DIRS
#define LFS_MAX_OPEN_DIRS 10
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册