From 9145a2db71a85064aa6a198c44da3cf753241131 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sat, 24 Oct 2009 14:10:25 +0000 Subject: Fixes for OpenSolaris 0906 --- common/config-parser.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'common/config-parser.c') diff --git a/common/config-parser.c b/common/config-parser.c index b5852b7..fbb9c70 100644 --- a/common/config-parser.c +++ b/common/config-parser.c @@ -245,6 +245,7 @@ parse_dir_internal(const char* subdir, void* data) { char path[MAXPATHLEN]; struct dirent* dire; + int is_dir, is_reg, is_lnk; struct stat st; char* memory; DIR* dir; @@ -271,8 +272,16 @@ parse_dir_internal(const char* subdir, void* data) else strlcpy(path, dire->d_name, MAXPATHLEN); - /* for non BSD compliant filesystem: stat() only if dirent->d_type is unknown */ - if(dire->d_type == DT_UNKNOWN) + is_dir = is_reg = is_lnk = 0; +#ifdef HAVE_STRUCT_DIRENT_D_TYPE + if(dire->d_type != DT_UNKNOWN) + { + is_dir = (dire->d_type == DT_DIR); + is_reg = (dire->d_type == DT_REG); + is_lnk = (dire->d_type == DT_LNK); + } + else +#endif { if(stat(path, &st) < 0) { @@ -281,15 +290,15 @@ parse_dir_internal(const char* subdir, void* data) } if(S_ISREG(st.st_mode)) - dire->d_type = DT_REG; + is_reg = 1; else if(S_ISDIR(st.st_mode)) - dire->d_type = DT_DIR; - else - continue; + is_dir = 1; + else if(S_ISLNK(st.st_mode)) + is_lnk = 1; } /* Descend into each sub directory */ - if(dire->d_type == DT_DIR) + if(is_dir) { /* No hidden or dot directories */ if(dire->d_name[0] == '.') @@ -302,7 +311,7 @@ parse_dir_internal(const char* subdir, void* data) continue; } - if(dire->d_type != DT_REG && dire->d_type != DT_LNK) + if(!is_reg && !is_lnk) continue; /* Build a happy path name */ -- cgit v1.2.3