From f0af695b6c3289a041e8fce8926721063796c596 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Wed, 22 Nov 2023 21:06:33 +0100 Subject: Meta: Use dirent as a general include file This include file is shared by the kernel and libc --- include/dirent.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 include/dirent.h (limited to 'include/dirent.h') diff --git a/include/dirent.h b/include/dirent.h new file mode 100644 index 0000000..153d36a --- /dev/null +++ b/include/dirent.h @@ -0,0 +1,33 @@ +#ifndef DIRENT_H +#define DIRENT_H +#include +#include +#include +#include +#include +#ifndef KERNEL +#include +#endif + +#define S_ISREG(_m) (_m & (STAT_REG)) +#define S_ISDIR(_m) (_m & (STAT_DIR)) + +struct dirent { + ino_t d_ino; // File serial number. + char d_name[PATH_MAX]; // Filename string of entry. +}; + +typedef struct { + int fd; + struct dirent internal_direntry; + int dir_num; +} DIR; + +DIR *opendir(const char *dirname); +struct dirent *readdir(DIR *dir); +int closedir(DIR *dirp); +int alphasort(const struct dirent **d1, const struct dirent **d2); +int scandir(const char *dir, struct dirent ***namelist, + int (*sel)(const struct dirent *), + int (*compar)(const struct dirent **, const struct dirent **)); +#endif -- cgit v1.2.3