feat: 支持select.h的FD_SETSIZE宏配置
1. FD_SETSIZE由普通文件+网络文件的文件句柄个数之和决定。 2. 以前vfs_config.h引入fatfs.h和lfs_api.h又会引入其他头文件, 导致变异问题。因此需要将配置宏拆分出来放到fatfs_conf.h和 lfs_conf.h 头文件中。 3. lwipopts.h会提供网络的句柄个数,依赖FD_SETSIZE,而select.h会提供FD_SETSIZE, 依赖网络句柄个数,因此会形成相互依赖的情况,需要通过顺序来解决。 4. 网络中新增ntohl的定义。 close: #I4RYK4 Signed-off-by: likailong <likailong@huawei.com>
This commit is contained in:
parent
e133ce6865
commit
05642f05ae
1
BUILD.gn
1
BUILD.gn
|
@ -143,6 +143,7 @@ config("kconfig_config") {
|
|||
"$LITEOS_MENUCONFIG_H",
|
||||
]
|
||||
asmflags = cflags
|
||||
cflags_cc = cflags
|
||||
}
|
||||
|
||||
config("warn_config") {
|
||||
|
|
|
@ -32,28 +32,21 @@
|
|||
#ifndef _FATFS_H
|
||||
#define _FATFS_H
|
||||
|
||||
#include "fcntl.h"
|
||||
#include "dirent.h"
|
||||
#include "unistd.h"
|
||||
#include "fatfs_conf.h"
|
||||
#include "fcntl.h"
|
||||
#include "fs_config.h"
|
||||
#include "sys/mount.h"
|
||||
#include "sys/stat.h"
|
||||
#include "sys/statfs.h"
|
||||
#include "fs_config.h"
|
||||
#include "unistd.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef FAT_MAX_OPEN_FILES
|
||||
#define FAT_MAX_OPEN_FILES 50
|
||||
#endif /* FAT_MAX_OPEN_FILES */
|
||||
|
||||
/* Format options */
|
||||
#define FMT_FAT 0x01
|
||||
#define FMT_FAT32 0x02
|
||||
#define FMT_ANY 0x07
|
||||
|
||||
int fatfs_mount(const char *source, const char *target,
|
||||
const char *filesystemtype, unsigned long mountflags,
|
||||
const void *data);
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2022-2022 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 _FATFS_CONF_H
|
||||
#define _FATFS_CONF_H
|
||||
|
||||
#ifndef FAT_MAX_OPEN_FILES
|
||||
#define FAT_MAX_OPEN_FILES 50
|
||||
#endif /* FAT_MAX_OPEN_FILES */
|
||||
|
||||
/* Format options */
|
||||
#define FMT_FAT 0x01
|
||||
#define FMT_FAT32 0x02
|
||||
#define FMT_ANY 0x07
|
||||
|
||||
#endif // _FATFS_CONF_H
|
|
@ -39,6 +39,7 @@
|
|||
#include "errno.h"
|
||||
#include "fs_operations.h"
|
||||
#include "lfs.h"
|
||||
#include "lfs_conf.h"
|
||||
#include "lfs_util.h"
|
||||
#include "memory.h"
|
||||
#include "pthread.h"
|
||||
|
@ -74,20 +75,6 @@ typedef struct {
|
|||
lfs_dir_t dir;
|
||||
} FileDirInfo;
|
||||
|
||||
#define LITTLE_FS_MAX_OPEN_FILES 100
|
||||
#define LITTLE_FS_STANDARD_NAME_LENGTH 50
|
||||
#define LITTLE_FS_MAX_NAME_LEN 255
|
||||
|
||||
#define MAX_DEF_BUF_NUM 21
|
||||
#define MAX_BUFFER_LEN 100
|
||||
#define MAX_WRITE_FILE_LEN 500
|
||||
#define MAX_READ_FILE_LEN 500
|
||||
#define LITTLEFS_MAX_LFN_LEN 255
|
||||
|
||||
#ifndef LFS_MAX_OPEN_DIRS
|
||||
#define LFS_MAX_OPEN_DIRS 10
|
||||
#endif
|
||||
|
||||
LittleFsHandleStruct *GetFreeFd(int *fd);
|
||||
|
||||
int LfsMount(const char *source, const char *target, const char *fileSystemType, unsigned long mountflags,
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2022-2022 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 _LFS_CONF_H
|
||||
#define _LFS_CONF_H
|
||||
|
||||
#define LITTLE_FS_MAX_OPEN_FILES 100
|
||||
#define LITTLE_FS_STANDARD_NAME_LENGTH 50
|
||||
#define LITTLE_FS_MAX_NAME_LEN 255
|
||||
|
||||
#define MAX_DEF_BUF_NUM 21
|
||||
#define MAX_WRITE_FILE_LEN 500
|
||||
#define MAX_READ_FILE_LEN 500
|
||||
#define LITTLEFS_MAX_LFN_LEN 255
|
||||
|
||||
#ifndef LFS_MAX_OPEN_DIRS
|
||||
#define LFS_MAX_OPEN_DIRS 10
|
||||
#endif
|
||||
|
||||
#endif // _LFS_CONF_H
|
|
@ -98,14 +98,14 @@
|
|||
/* max numbers of other descriptors except socket descriptors */
|
||||
|
||||
#ifdef LOSCFG_FS_FAT
|
||||
#include "fatfs.h"
|
||||
#include "fatfs_conf.h"
|
||||
#define __FAT_NFILE FAT_MAX_OPEN_FILES
|
||||
#else
|
||||
#define __FAT_NFILE 0
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_FS_LITTLEFS
|
||||
#include "lfs_api.h"
|
||||
#include "lfs_conf.h"
|
||||
#define __LFS_NFILE LITTLE_FS_MAX_OPEN_FILES
|
||||
#else
|
||||
#define __LFS_NFILE 0
|
||||
|
@ -123,12 +123,10 @@
|
|||
|
||||
#define CONFIG_NQUEUE_DESCRIPTORS 256
|
||||
|
||||
#undef FD_SETSIZE
|
||||
#define FD_SETSIZE (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)
|
||||
#define TIMER_FD_OFFSET (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)
|
||||
#define FD_SET_TOTAL_SIZE (TIMER_FD_OFFSET + CONFIG_NEXPANED_DESCRIPTORS)
|
||||
#define MQUEUE_FD_OFFSET (TIMER_FD_OFFSET + CONFIG_NTIME_DESCRIPTORS)
|
||||
|
||||
/* directory configure */
|
||||
|
||||
|
|
|
@ -134,10 +134,6 @@
|
|||
#define LWIP_NETIF_LOOPBACK 1
|
||||
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
|
||||
#define LWIP_RAW 1
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
#include "vfs_config.h"
|
||||
#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
|
||||
#endif
|
||||
#define LWIP_SO_RCVBUF 1
|
||||
#define LWIP_SO_RCVTIMEO 1
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
|
@ -234,4 +230,9 @@
|
|||
// use PBUF_RAM instead of PBUF_POOL in udp_input
|
||||
#define USE_PBUF_RAM_UDP_INPUT 1
|
||||
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
#include "vfs_config.h"
|
||||
#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
|
||||
#endif
|
||||
|
||||
#endif /* _LWIP_PORTING_LWIPOPTS_H_ */
|
||||
|
|
|
@ -37,6 +37,7 @@ kernel_module(module_name) {
|
|||
"porting/src/malloc.c",
|
||||
"porting/src/network/htonl.c",
|
||||
"porting/src/network/htons.c",
|
||||
"porting/src/network/ntohl.c",
|
||||
"porting/src/network/ntohs.c",
|
||||
"porting/src/other_adapt.c",
|
||||
"porting/src/pthread.c",
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2021-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 _ADAPT_SYS_SELECT_H
|
||||
#define _ADAPT_SYS_SELECT_H
|
||||
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
#include "vfs_config.h"
|
||||
|
||||
#undef FD_SETSIZE
|
||||
#define FD_SETSIZE TIMER_FD_OFFSET
|
||||
|
||||
#else
|
||||
|
||||
#undef FD_SETSIZE
|
||||
#define FD_SETSIZE 1024
|
||||
|
||||
#endif
|
||||
|
||||
#include_next <sys/select.h>
|
||||
|
||||
#endif //_ADAPT_SYS_SELECT_H
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2022-2022 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.
|
||||
*/
|
||||
|
||||
#include <sys/features.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
uint32_t ntohl(uint32_t n)
|
||||
{
|
||||
union { int i; char c; } u = { 1 };
|
||||
return u.c ? bswap_32(n) : n;
|
||||
}
|
Loading…
Reference in New Issue