diff options
author | Stef Walter <stef@memberwebs.com> | 2009-10-24 14:10:25 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2009-10-24 14:10:25 +0000 |
commit | 9145a2db71a85064aa6a198c44da3cf753241131 (patch) | |
tree | faa3a1a60475f9e6810a3f6618593d430cc61511 /common/config-parser.c | |
parent | 082ac8f970f9c2cb244ffccc7b382b259e7b4f69 (diff) |
Fixes for OpenSolaris 0906
Diffstat (limited to 'common/config-parser.c')
-rw-r--r-- | common/config-parser.c | 25 |
1 files changed, 17 insertions, 8 deletions
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 */ |