From 2a95944f8d7536868ca51ddf09514f78309af52a Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 8 Mar 2010 21:04:24 -0800 Subject: [PATCH] sys/dirent.h: conversion macros between d_type and st_mode Conversion macros to change between d_type and st_mode values. Signed-off-by: H. Peter Anvin --- com32/include/sys/dirent.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/com32/include/sys/dirent.h b/com32/include/sys/dirent.h index 0a27c66..bb5e52c 100644 --- a/com32/include/sys/dirent.h +++ b/com32/include/sys/dirent.h @@ -6,6 +6,7 @@ #define DIRENT_H #include +#include #ifndef NAME_MAX #define NAME_MAX 255 @@ -19,7 +20,7 @@ struct dirent { char d_name[NAME_MAX + 1]; }; -enum dirent_types { +enum dirent_type { DT_UNKNOWN = 0, DT_FIFO = 1, DT_CHR = 2, @@ -31,6 +32,13 @@ enum dirent_types { DT_WHT = 14, }; +/* + * Convert between stat structure mode types and directory types. + * The stat structure mode types are the same as in Linux. + */ +#define IFTODT(mode) (((mode) & 0170000) >> 12) +#define DTTOIF(dt) ((dt) << 12) + struct _DIR_; typedef struct _DIR_ DIR; -- 2.7.4