feature: 支持newlib与musl切换
系统支持newlib,并且可以与musl-C自由切换 1. 新增newlib支持,适配newlib的预留钩子,针对系统能力适配newlib头文件(补充宏定义,结构体定义,posix能力开关), 采用标准C与自研posix接口声明与结构体定义混合作为C库 2. 梳理kal的依赖关系,kal作为内核对外提供的标准接口,下属包含cmsis、libc、posix。 cmsis为内核对cmsis接口的支持,libc为内核对三方C库的适配及使用,posix为内核自研提供的posix标准接口。 若采用musl-C,则kal中选取libc/musl,posix共同作为C库对外支持; 若采用newlib-C,则kal中选取libc/newlib,部分posix共同作为C库对外支持。 3. fs整理,components/fs下提供基于posix标准的接口改为内部对外接口,供musl以及newlib切换 适配使用 close: #I4ENQ1 Signed-off-by: arvinzzz <zhaotianyu9@huawei.com> Change-Id: I72eda5ac5499f72c67e800e22b0f39eb288f2b94
This commit is contained in:
@@ -29,24 +29,11 @@
|
||||
|
||||
import("//kernel/liteos_m/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_VFS)
|
||||
module_name = "fs_operations"
|
||||
kernel_module(module_name) {
|
||||
sources = [ "fs.c" ]
|
||||
}
|
||||
|
||||
group("fs") {
|
||||
deps = [ ":$module_name" ]
|
||||
deps += [
|
||||
"fatfs",
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
module_group(module_name) {
|
||||
modules = [
|
||||
"vfs",
|
||||
"littlefs",
|
||||
]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "." ]
|
||||
configs = [
|
||||
"fatfs:public",
|
||||
"littlefs:public",
|
||||
"fatfs",
|
||||
]
|
||||
}
|
||||
|
||||
42
components/fs/Kconfig
Normal file
42
components/fs/Kconfig
Normal file
@@ -0,0 +1,42 @@
|
||||
# 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.
|
||||
|
||||
rsource "vfs/Kconfig"
|
||||
rsource "littlefs/Kconfig"
|
||||
rsource "fatfs/Kconfig"
|
||||
|
||||
config SUPPORT_FATFS
|
||||
bool
|
||||
default n
|
||||
depends on FS_FAT
|
||||
|
||||
config SUPPORT_LITTLEFS
|
||||
bool
|
||||
default n
|
||||
depends on FS_LITTLEFS
|
||||
@@ -1,9 +1,38 @@
|
||||
# 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.
|
||||
|
||||
config FS_FAT
|
||||
bool "Enable FAT"
|
||||
default n
|
||||
depends on FS_VFS
|
||||
select SUPPORT_FATFS
|
||||
select COMPAT_CMSIS
|
||||
select KAL_CMSIS
|
||||
help
|
||||
Answer Y to enable LiteOS support fat filesystem.
|
||||
|
||||
|
||||
44
components/fs/littlefs/Kconfig
Normal file
44
components/fs/littlefs/Kconfig
Normal file
@@ -0,0 +1,44 @@
|
||||
# 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.
|
||||
|
||||
config FS_LITTLEFS
|
||||
bool "Enable Little FS"
|
||||
default n
|
||||
depends on FS_VFS
|
||||
help
|
||||
Answer Y to enable LiteOS support Little FS filesystem.
|
||||
|
||||
if FS_LITTLEFS
|
||||
config LFS_MAX_MOUNT_SIZE
|
||||
int "Maximum number of mount points"
|
||||
default 3
|
||||
help
|
||||
This is a global maximum number of mount points.
|
||||
|
||||
endif # FS_LITTLEFS
|
||||
@@ -45,8 +45,6 @@
|
||||
|
||||
#define INVALID_FD (-1)
|
||||
|
||||
typedef unsigned mode_t;
|
||||
|
||||
#ifndef VFS_ERROR
|
||||
#define VFS_ERROR (-1)
|
||||
#endif
|
||||
|
||||
40
components/fs/vfs/BUILD.gn
Normal file
40
components/fs/vfs/BUILD.gn
Normal file
@@ -0,0 +1,40 @@
|
||||
# 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.
|
||||
|
||||
import("//kernel/liteos_m/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_VFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [ "los_fs.c" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "." ]
|
||||
}
|
||||
34
components/fs/vfs/Kconfig
Normal file
34
components/fs/vfs/Kconfig
Normal file
@@ -0,0 +1,34 @@
|
||||
# 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.
|
||||
|
||||
config FS_VFS
|
||||
bool "Enable FS VFS"
|
||||
default y
|
||||
help
|
||||
Answer Y to enable LiteOS support VFS.
|
||||
@@ -28,8 +28,10 @@
|
||||
* 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 "los_fs.h"
|
||||
#include "los_config.h"
|
||||
#include "fs_operations.h"
|
||||
#if (LOSCFG_SUPPORT_FATFS == 1)
|
||||
#include "fatfs.h"
|
||||
#endif
|
||||
@@ -188,9 +190,9 @@ static struct FsMap *MountFindfs(const char *fileSystemtype)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int mount(const char *source, const char *target,
|
||||
const char *filesystemtype, unsigned long mountflags,
|
||||
const void *data)
|
||||
int LOS_FsMount(const char *source, const char *target,
|
||||
const char *filesystemtype, unsigned long mountflags,
|
||||
const void *data)
|
||||
{
|
||||
static int initFlag = 0;
|
||||
|
||||
@@ -213,7 +215,7 @@ int mount(const char *source, const char *target,
|
||||
return g_fs->fsMops->Mount(source, target, filesystemtype, mountflags, data);
|
||||
}
|
||||
|
||||
int umount(const char *target)
|
||||
int LOS_FsUmount(const char *target)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -226,7 +228,7 @@ int umount(const char *target)
|
||||
return g_fs->fsMops->Umount(target);
|
||||
}
|
||||
|
||||
int umount2(const char *target, int flag)
|
||||
int LOS_FsUmount2(const char *target, int flag)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -239,7 +241,7 @@ int umount2(const char *target, int flag)
|
||||
return g_fs->fsMops->Umount2(target, flag);
|
||||
}
|
||||
|
||||
int open(const char *path, int oflag, ...)
|
||||
int LOS_Open(const char *path, int oflag, ...)
|
||||
{
|
||||
#ifdef LOSCFG_RANDOM_DEV
|
||||
unsigned flags = O_RDONLY | O_WRONLY | O_RDWR | O_APPEND | O_CREAT | O_LARGEFILE | O_TRUNC | O_EXCL | O_DIRECTORY;
|
||||
@@ -294,7 +296,7 @@ int open(const char *path, int oflag, ...)
|
||||
return g_fs->fsFops->Open(path, oflag);
|
||||
}
|
||||
|
||||
int close(int fd)
|
||||
int LOS_Close(int fd)
|
||||
{
|
||||
#ifdef LOSCFG_RANDOM_DEV
|
||||
if (fd == RANDOM_DEV_FD) {
|
||||
@@ -317,7 +319,7 @@ int close(int fd)
|
||||
return g_fs->fsFops->Close(fd);
|
||||
}
|
||||
|
||||
ssize_t read(int fd, void *buf, size_t nbyte)
|
||||
ssize_t LOS_Read(int fd, void *buf, size_t nbyte)
|
||||
{
|
||||
#ifdef LOSCFG_RANDOM_DEV
|
||||
if (fd == RANDOM_DEV_FD) {
|
||||
@@ -355,7 +357,7 @@ ssize_t read(int fd, void *buf, size_t nbyte)
|
||||
return g_fs->fsFops->Read(fd, buf, nbyte);
|
||||
}
|
||||
|
||||
ssize_t write(int fd, const void *buf, size_t nbyte)
|
||||
ssize_t LOS_Write(int fd, const void *buf, size_t nbyte)
|
||||
{
|
||||
#ifdef LOSCFG_RANDOM_DEV
|
||||
if (fd == RANDOM_DEV_FD) {
|
||||
@@ -379,7 +381,7 @@ ssize_t write(int fd, const void *buf, size_t nbyte)
|
||||
return g_fs->fsFops->Write(fd, buf, nbyte);
|
||||
}
|
||||
|
||||
off_t lseek(int fd, off_t offset, int whence)
|
||||
off_t LOS_Lseek(int fd, off_t offset, int whence)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -392,7 +394,7 @@ off_t lseek(int fd, off_t offset, int whence)
|
||||
return g_fs->fsFops->Seek(fd, offset, whence);
|
||||
}
|
||||
|
||||
int unlink(const char *path)
|
||||
int LOS_Unlink(const char *path)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -405,7 +407,7 @@ int unlink(const char *path)
|
||||
return g_fs->fsFops->Unlink(path);
|
||||
}
|
||||
|
||||
int fstat(int fd, struct stat *buf)
|
||||
int LOS_Fstat(int fd, struct stat *buf)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -418,7 +420,7 @@ int fstat(int fd, struct stat *buf)
|
||||
return g_fs->fsFops->Fstat(fd, buf);
|
||||
}
|
||||
|
||||
int stat(const char *path, struct stat *buf)
|
||||
int LOS_Stat(const char *path, struct stat *buf)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -431,7 +433,7 @@ int stat(const char *path, struct stat *buf)
|
||||
return g_fs->fsFops->Getattr(path, buf);
|
||||
}
|
||||
|
||||
int fsync(int fd)
|
||||
int LOS_Fsync(int fd)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -444,7 +446,7 @@ int fsync(int fd)
|
||||
return g_fs->fsFops->Fsync(fd);
|
||||
}
|
||||
|
||||
int mkdir(const char *path, mode_t mode)
|
||||
int LOS_Mkdir(const char *path, mode_t mode)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -457,7 +459,7 @@ int mkdir(const char *path, mode_t mode)
|
||||
return g_fs->fsFops->Mkdir(path, mode);
|
||||
}
|
||||
|
||||
DIR *opendir(const char *dirName)
|
||||
DIR *LOS_Opendir(const char *dirName)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -470,7 +472,7 @@ DIR *opendir(const char *dirName)
|
||||
return g_fs->fsFops->Opendir(dirName);
|
||||
}
|
||||
|
||||
struct dirent *readdir(DIR *dir)
|
||||
struct dirent *LOS_Readdir(DIR *dir)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -483,7 +485,7 @@ struct dirent *readdir(DIR *dir)
|
||||
return g_fs->fsFops->Readdir(dir);
|
||||
}
|
||||
|
||||
int closedir(DIR *dir)
|
||||
int LOS_Closedir(DIR *dir)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -496,7 +498,7 @@ int closedir(DIR *dir)
|
||||
return g_fs->fsFops->Closedir(dir);
|
||||
}
|
||||
|
||||
int rmdir(const char *path)
|
||||
int LOS_Rmdir(const char *path)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -509,7 +511,7 @@ int rmdir(const char *path)
|
||||
return g_fs->fsFops->Rmdir(path);
|
||||
}
|
||||
|
||||
int rename(const char *oldName, const char *newName)
|
||||
int LOS_Rename(const char *oldName, const char *newName)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -522,7 +524,7 @@ int rename(const char *oldName, const char *newName)
|
||||
return g_fs->fsFops->Rename(oldName, newName);
|
||||
}
|
||||
|
||||
int statfs(const char *path, struct statfs *buf)
|
||||
int LOS_Statfs(const char *path, struct statfs *buf)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
@@ -535,7 +537,7 @@ int statfs(const char *path, struct statfs *buf)
|
||||
return g_fs->fsMops->Statfs(path, buf);
|
||||
}
|
||||
|
||||
int ftruncate(int fd, off_t length)
|
||||
int LOS_Ftruncate(int fd, off_t length)
|
||||
{
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
101
components/fs/vfs/los_fs.h
Normal file
101
components/fs/vfs/los_fs.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup los_vfs fs
|
||||
* @ingroup kernel
|
||||
*/
|
||||
|
||||
#ifndef _LOS_VFS_H_
|
||||
#define _LOS_VFS_H_
|
||||
|
||||
#include "los_config.h"
|
||||
#include "dirent.h"
|
||||
#include "sys/mount.h"
|
||||
#include "sys/statfs.h"
|
||||
#include "sys/stat.h"
|
||||
#include "unistd.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int LOS_Open(const char *path, int oflag, ...);
|
||||
|
||||
int LOS_Close(int fd);
|
||||
|
||||
ssize_t LOS_Read(int fd, void *buf, size_t nbyte);
|
||||
|
||||
ssize_t LOS_Write(int fd, const void *buf, size_t nbyte);
|
||||
|
||||
off_t LOS_Lseek(int fd, off_t offset, int whence);
|
||||
|
||||
int LOS_Unlink(const char *path);
|
||||
|
||||
int LOS_Fstat(int fd, struct stat *buf);
|
||||
|
||||
int LOS_Stat(const char *path, struct stat *buf);
|
||||
|
||||
int LOS_Fsync(int fd);
|
||||
|
||||
int LOS_Mkdir(const char *path, mode_t mode);
|
||||
|
||||
DIR *LOS_Opendir(const char *dirName);
|
||||
|
||||
struct dirent *LOS_Readdir(DIR *dir);
|
||||
|
||||
int LOS_Closedir(DIR *dir);
|
||||
|
||||
int LOS_Rmdir(const char *path);
|
||||
|
||||
int LOS_Rename(const char *oldName, const char *newName);
|
||||
|
||||
int LOS_Statfs(const char *path, struct statfs *buf);
|
||||
|
||||
int LOS_Ftruncate(int fd, off_t length);
|
||||
|
||||
int LOS_FsUmount2(const char *target, int flag);
|
||||
|
||||
int LOS_FsUmount(const char *target);
|
||||
|
||||
int LOS_FsMount(const char *source, const char *target,
|
||||
const char *filesystemtype, unsigned long mountflags,
|
||||
const void *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_FS_H_ */
|
||||
@@ -82,12 +82,6 @@
|
||||
#define CONFIG_NUNGET_CHARS 0
|
||||
#define MIN_START_FD 3 // 0,1,2 are used for stdin,stdout,stderr respectively
|
||||
|
||||
#define FD_SET_TOTAL_SIZE (FD_SETSIZE + CONFIG_NEXPANED_DESCRIPTORS)
|
||||
#define FD_SETSIZE (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)
|
||||
#define CONFIG_NEXPANED_DESCRIPTORS (CONFIG_NTIME_DESCRIPTORS + CONFIG_NQUEUE_DESCRIPTORS)
|
||||
#define TIMER_FD_OFFSET FD_SETSIZE
|
||||
#define MQUEUE_FD_OFFSET (FD_SETSIZE + CONFIG_NTIME_DESCRIPTORS)
|
||||
|
||||
/* net configure */
|
||||
|
||||
#ifdef LOSCFG_NET_LWIP_SACK // enable socket and net function
|
||||
@@ -129,6 +123,12 @@
|
||||
|
||||
#define CONFIG_NQUEUE_DESCRIPTORS 256
|
||||
|
||||
#define FD_SETSIZE (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)
|
||||
#define CONFIG_NEXPANED_DESCRIPTORS (CONFIG_NTIME_DESCRIPTORS + CONFIG_NQUEUE_DESCRIPTORS)
|
||||
#define FD_SET_TOTAL_SIZE (FD_SETSIZE + CONFIG_NEXPANED_DESCRIPTORS)
|
||||
#define TIMER_FD_OFFSET FD_SETSIZE
|
||||
#define MQUEUE_FD_OFFSET (FD_SETSIZE + CONFIG_NTIME_DESCRIPTORS)
|
||||
|
||||
/* directory configure */
|
||||
|
||||
#define VFS_USING_WORKDIR // enable current working directory
|
||||
Reference in New Issue
Block a user