From aab382c32ed0fb795d12191c7a59265f574e8466 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 30 Aug 2021 22:27:09 -0400 Subject: [PATCH 1/2] [rtlibc] remove libc_dirent.h --- components/dfs/include/dfs.h | 19 +++++----------- components/dfs/include/dfs_posix.h | 8 ------- components/libc/compilers/common/dirent.h | 27 +++++++++++++++-------- include/libc/libc_dirent.h | 17 -------------- include/rtlibc.h | 1 - 5 files changed, 24 insertions(+), 48 deletions(-) delete mode 100644 include/libc/libc_dirent.h diff --git a/components/dfs/include/dfs.h b/components/dfs/include/dfs.h index 80dc433787..6af8bbd99f 100644 --- a/components/dfs/include/dfs.h +++ b/components/dfs/include/dfs.h @@ -16,10 +16,13 @@ #include #include -#include -#include +#include #include +#ifdef __cplusplus +extern "C" { +#endif + #ifndef DFS_FILESYSTEMS_MAX #define DFS_FILESYSTEMS_MAX 2 #endif @@ -63,9 +66,7 @@ #define DFS_F_EOF 0x04000000 #define DFS_F_ERR 0x08000000 -#ifdef __cplusplus -extern "C" { -#endif +#include struct statfs { @@ -74,14 +75,6 @@ struct statfs size_t f_bfree; /* free blocks in file system */ }; -struct dirent -{ - uint8_t d_type; /* The type of the file */ - uint8_t d_namlen; /* The length of the not including the terminating null file name */ - uint16_t d_reclen; /* length of this record */ - char d_name[DFS_PATH_MAX]; /* The null-terminated file name */ -}; - struct dfs_fdtable { uint32_t maxfd; diff --git a/components/dfs/include/dfs_posix.h b/components/dfs/include/dfs_posix.h index 0475460d95..ec7cdc9de4 100644 --- a/components/dfs/include/dfs_posix.h +++ b/components/dfs/include/dfs_posix.h @@ -21,14 +21,6 @@ extern "C" { #endif -typedef struct -{ - int fd; /* directory file */ - char buf[512]; - int num; - int cur; -} DIR; - /* directory api*/ int mkdir(const char *path, mode_t mode); DIR *opendir(const char *name); diff --git a/components/libc/compilers/common/dirent.h b/components/libc/compilers/common/dirent.h index bfba586093..6727d96788 100644 --- a/components/libc/compilers/common/dirent.h +++ b/components/libc/compilers/common/dirent.h @@ -6,10 +6,14 @@ * Change Logs: * Date Author Notes */ -#ifndef __RTT_DIRENT_H__ -#define __RTT_DIRENT_H__ +#ifndef __DIRENT_H__ +#define __DIRENT_H__ -#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* * dirent.h - format of directory entries @@ -26,27 +30,32 @@ #define DT_REG 0x01 #define DT_DIR 0x02 -#ifdef __cplusplus -extern "C" { -#endif - #ifndef HAVE_DIR_STRUCTURE +#define HAVE_DIR_STRUCTURE typedef struct { int fd; /* directory file */ char buf[512]; int num; int cur; -} DIR; +}DIR; #endif #ifndef HAVE_DIRENT_STRUCTURE +#define HAVE_DIRENT_STRUCTURE + +#ifdef DFS_PATH_MAX +#define DIRENT_NAME_MAX DFS_PATH_MAX +#else +#define DIRENT_NAME_MAX 256 +#endif + struct dirent { rt_uint8_t d_type; /* The type of the file */ rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */ rt_uint16_t d_reclen; /* length of this record */ - char d_name[256]; /* The null-terminated file name */ + char d_name[DIRENT_NAME_MAX]; /* The null-terminated file name */ }; #endif diff --git a/include/libc/libc_dirent.h b/include/libc/libc_dirent.h deleted file mode 100644 index a86332e633..0000000000 --- a/include/libc/libc_dirent.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ - -#ifndef LIBC_DIRENT_H__ -#define LIBC_DIRENT_H__ - -#define DT_UNKNOWN 0x00 -#define DT_REG 0x01 -#define DT_DIR 0x02 - -#endif diff --git a/include/rtlibc.h b/include/rtlibc.h index 4b145b1b1b..b59a29dadb 100644 --- a/include/rtlibc.h +++ b/include/rtlibc.h @@ -14,7 +14,6 @@ /* definitions for libc if toolchain has no these definitions */ #include "libc/libc_stat.h" #include "libc/libc_fcntl.h" -#include "libc/libc_dirent.h" #ifndef RT_USING_LIBC #if defined(__ARMCC_VERSION) || defined(__IAR_SYSTEMS_ICC__) From dd9db58a865775a0756d1b1ce4f1ef021542f54b Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 1 Sep 2021 09:28:16 -0400 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96dfs.h=E5=92=8Cdirent.h?= =?UTF-8?q?=E7=9A=84=E5=8C=85=E5=90=AB=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/include/dfs.h | 10 ++++------ components/libc/compilers/common/dirent.h | 4 ---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/components/dfs/include/dfs.h b/components/dfs/include/dfs.h index 6af8bbd99f..0fd8c2dccc 100644 --- a/components/dfs/include/dfs.h +++ b/components/dfs/include/dfs.h @@ -15,7 +15,7 @@ #include #include #include - +#include #include #include @@ -24,11 +24,11 @@ extern "C" { #endif #ifndef DFS_FILESYSTEMS_MAX -#define DFS_FILESYSTEMS_MAX 2 +#define DFS_FILESYSTEMS_MAX 4 #endif #ifndef DFS_FD_MAX -#define DFS_FD_MAX 4 +#define DFS_FD_MAX 16 #endif /* @@ -39,7 +39,7 @@ extern "C" { #endif #ifndef DFS_PATH_MAX -#define DFS_PATH_MAX 256 +#define DFS_PATH_MAX DIRENT_NAME_MAX #endif #ifndef SECTOR_SIZE @@ -66,8 +66,6 @@ extern "C" { #define DFS_F_EOF 0x04000000 #define DFS_F_ERR 0x08000000 -#include - struct statfs { size_t f_bsize; /* block size */ diff --git a/components/libc/compilers/common/dirent.h b/components/libc/compilers/common/dirent.h index 6727d96788..a6353fd6f8 100644 --- a/components/libc/compilers/common/dirent.h +++ b/components/libc/compilers/common/dirent.h @@ -44,11 +44,7 @@ typedef struct #ifndef HAVE_DIRENT_STRUCTURE #define HAVE_DIRENT_STRUCTURE -#ifdef DFS_PATH_MAX -#define DIRENT_NAME_MAX DFS_PATH_MAX -#else #define DIRENT_NAME_MAX 256 -#endif struct dirent {