diff --git a/include/posix/dirent.h b/include/posix/dirent.h new file mode 100644 index 00000000000..8e195f9e1ff --- /dev/null +++ b/include/posix/dirent.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef ZEPHYR_INCLUDE_POSIX_DIRENT_H_ +#define ZEPHYR_INCLUDE_POSIX_DIRENT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "sys/types.h" + +#ifdef CONFIG_POSIX_FS +#include + +typedef struct fs_dir_t DIR; + +struct dirent { + unsigned int d_ino; + char d_name[PATH_MAX + 1]; +}; + +/* Directory related operations */ +extern DIR *opendir(const char *dirname); +extern int closedir(DIR *dirp); +extern struct dirent *readdir(DIR *dirp); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_POSIX_DIRENT_H_ */ diff --git a/include/posix/unistd.h b/include/posix/unistd.h index 672dc4665d4..ca93eb4af1a 100644 --- a/include/posix/unistd.h +++ b/include/posix/unistd.h @@ -16,14 +16,8 @@ extern "C" { #ifdef CONFIG_POSIX_FS #include -typedef struct fs_dir_t DIR; typedef unsigned int mode_t; -struct dirent { - unsigned int d_ino; - char d_name[PATH_MAX + 1]; -}; - /* File related operations */ extern int open(const char *name, int flags); extern int close(int file); @@ -31,11 +25,6 @@ extern ssize_t write(int file, char *buffer, unsigned int count); extern ssize_t read(int file, char *buffer, unsigned int count); extern int lseek(int file, int offset, int whence); -/* Directory related operations */ -extern DIR *opendir(const char *dirname); -extern int closedir(DIR *dirp); -extern struct dirent *readdir(DIR *dirp); - /* File System related operations */ extern int rename(const char *old, const char *newp); extern int unlink(const char *path); diff --git a/lib/posix/fs.c b/lib/posix/fs.c index 0da86aa6432..4d4bc1eee9b 100644 --- a/lib/posix/fs.c +++ b/lib/posix/fs.c @@ -9,6 +9,7 @@ #include #include #include +#include #include BUILD_ASSERT_MSG(PATH_MAX > MAX_FILE_NAME, diff --git a/tests/posix/fs/src/test_fs_dir.c b/tests/posix/fs/src/test_fs_dir.c index 34f2b5b65e1..46e4f0311f3 100644 --- a/tests/posix/fs/src/test_fs_dir.c +++ b/tests/posix/fs/src/test_fs_dir.c @@ -6,6 +6,7 @@ #include #include +#include #include "test_fs.h" extern int test_file_write(void);