diff options
| author | Anton Kling <anton@kling.gg> | 2023-11-22 21:06:33 +0100 | 
|---|---|---|
| committer | Anton Kling <anton@kling.gg> | 2023-11-22 21:06:33 +0100 | 
| commit | f0af695b6c3289a041e8fce8926721063796c596 (patch) | |
| tree | 7575159d8efbb60ccf1762f2da3e126661f5c7bd /include | |
| parent | b3866b0442f55b97833981a99c601f2143d10315 (diff) | |
Meta: Use dirent as a general include file
This include file is shared by the kernel and libc
Diffstat (limited to 'include')
| -rw-r--r-- | include/dirent.h | 33 | 
1 files changed, 33 insertions, 0 deletions
| 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 <fcntl.h> +#include <limits.h> +#include <stddef.h> +#include <stdlib.h> +#include <sys/types.h> +#ifndef KERNEL +#include <unistd.h> +#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 |