From 59e03d07996f36ae9d8c60cefb6de5a2d648fae0 Mon Sep 17 00:00:00 2001 From: apio Date: Wed, 9 Nov 2022 11:36:41 +0100 Subject: [PATCH] libc: Add DT_* macros to dirent.h --- libs/libc/include/dirent.h | 9 +++++++++ libs/libc/src/dirent.cpp | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/libc/include/dirent.h b/libs/libc/include/dirent.h index ad7a5729..26f3dc0b 100644 --- a/libs/libc/include/dirent.h +++ b/libs/libc/include/dirent.h @@ -14,6 +14,15 @@ struct dirent char d_name[NAME_MAX]; }; +#define DT_BLK 1 // This is a block device. +#define DT_CHR 2 // This is a character device. +#define DT_DIR 3 // This is a directory. +#define DT_FIFO 4 // This is a named pipe (FIFO). +#define DT_LNK 5 // This is a symbolic link. +#define DT_REG 6 // This is a regular file. +#define DT_SOCK 7 // This is a UNIX domain socket. +#define DT_UNKNOWN 0 // The file type could not be determined. + /* A stream representing a directory. */ typedef struct { diff --git a/libs/libc/src/dirent.cpp b/libs/libc/src/dirent.cpp index 221f7cca..48523a19 100644 --- a/libs/libc/src/dirent.cpp +++ b/libs/libc/src/dirent.cpp @@ -46,7 +46,7 @@ extern "C" result.d_ino = ent.inode; result.d_reclen = sizeof(result); result.d_off = ent.offset; - result.d_type = 0; + result.d_type = DT_UNKNOWN; strlcpy(result.d_name, ent.name, NAME_MAX); return &result; }