[syslinux:pathbased] sys/dirent.h: conversion macros between d_type and st_mode

syslinux-bot for H. Peter Anvin hpa at zytor.com
Mon Mar 8 21:06:09 PST 2010


Commit-ID:  2a95944f8d7536868ca51ddf09514f78309af52a
Gitweb:     http://syslinux.zytor.com/commit/2a95944f8d7536868ca51ddf09514f78309af52a
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Mon, 8 Mar 2010 21:04:24 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 8 Mar 2010 21:04:24 -0800

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 <hpa at zytor.com>


---
 com32/include/sys/dirent.h |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

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 <stdint.h>
+#include <sys/types.h>
 
 #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;
 



More information about the Syslinux-commits mailing list