include: posix: Split dirent.h from unistd.h

From POSIX
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dirent.h.html

"""
The <dirent.h> header shall define the following type:
DIR

...

also define the structure dirent
"""

etc.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
Paul Sokolovsky 2018-09-27 17:54:24 +03:00 committed by Anas Nashif
commit c152ebd634
4 changed files with 39 additions and 11 deletions

37
include/posix/dirent.h Normal file
View file

@ -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 <limits.h>
#include "sys/types.h"
#ifdef CONFIG_POSIX_FS
#include <fs.h>
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_ */

View file

@ -16,14 +16,8 @@ extern "C" {
#ifdef CONFIG_POSIX_FS
#include <fs.h>
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);