diff --git a/include/zephyr/posix/sys/stat.h b/include/zephyr/posix/sys/stat.h new file mode 100644 index 00000000000..cac5aba27d4 --- /dev/null +++ b/include/zephyr/posix/sys/stat.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_POSIX_SYS_STAT_H_ +#define ZEPHYR_POSIX_SYS_STAT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define S_IFBLK 0060000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_IFREG 0100000 +#define S_IFDIR 0040000 +#define S_IFLNK 0120000 +#define S_IFSOCK 0140000 + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +/* File open modes */ +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 + +#define SEEK_SET 0 /* Seek from beginning of file. */ +#define SEEK_CUR 1 /* Seek from current position. */ +#define SEEK_END 2 /* Seek from end of file. */ + +struct stat { + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_mode; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_POSIX_SYS_STAT_H_ */ diff --git a/include/zephyr/posix/unistd.h b/include/zephyr/posix/unistd.h index e2e8fdd8cee..7a7ab4a0ce4 100644 --- a/include/zephyr/posix/unistd.h +++ b/include/zephyr/posix/unistd.h @@ -7,7 +7,7 @@ #define ZEPHYR_INCLUDE_POSIX_UNISTD_H_ #include "posix_types.h" -#include "sys/stat.h" +#include #ifdef CONFIG_NETWORKING /* For zsock_gethostname() */ #include diff --git a/lib/libc/minimal/include/sys/stat.h b/lib/libc/minimal/include/sys/stat.h index 54f05bdd64d..c281d6a148a 100644 --- a/lib/libc/minimal/include/sys/stat.h +++ b/lib/libc/minimal/include/sys/stat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Intel Corporation + * Copyright (c) 2022 Meta * * SPDX-License-Identifier: Apache-2.0 */ @@ -7,43 +7,10 @@ #ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_STAT_H_ #define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_STAT_H_ -#ifdef __cplusplus -extern "C" { +#ifndef CONFIG_POSIX_API +#pragma message("#include without CONFIG_POSIX_API is deprecated. " \ + "Please use CONFIG_POSIX_API or #include ") #endif +#include -#define S_IRWXU 00700 -#define S_IRUSR 00400 -#define S_IWUSR 00200 -#define S_IXUSR 00100 - -#define S_IRWXG 00070 -#define S_IRGRP 00040 -#define S_IWGRP 00020 -#define S_IXGRP 00010 - -#define S_IRWXO 00007 -#define S_IROTH 00004 -#define S_IWOTH 00002 -#define S_IXOTH 00001 - -/* File open modes */ -#define O_ACCMODE 0003 -#define O_RDONLY 00 -#define O_WRONLY 01 -#define O_RDWR 02 - -#define SEEK_SET 0 /* Seek from beginning of file. */ -#define SEEK_CUR 1 /* Seek from current position. */ -#define SEEK_END 2 /* Seek from end of file. */ - -struct stat { - unsigned long st_size; - unsigned long st_blksize; - unsigned long st_blocks; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_STAT_H_ */ +#endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_STAT_H_ */ diff --git a/lib/libc/newlib/libc-hooks.c b/lib/libc/newlib/libc-hooks.c index 92c49c122e9..4d7233657f9 100644 --- a/lib/libc/newlib/libc-hooks.c +++ b/lib/libc/newlib/libc-hooks.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/libc/picolibc/libc-hooks.c b/lib/libc/picolibc/libc-hooks.c index f97e18fc630..8affddb6dd0 100644 --- a/lib/libc/picolibc/libc-hooks.c +++ b/lib/libc/picolibc/libc-hooks.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/posix/fs.c b/lib/posix/fs.c index 04e4b872019..b724b80188b 100644 --- a/lib/posix/fs.c +++ b/lib/posix/fs.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include