summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-12-09 02:40:08 +0000
committerStef Walter <stef@memberwebs.com>2006-12-09 02:40:08 +0000
commit4440efc5d227000eb0d842394fff10bf7fb98236 (patch)
tree56f54c32bdd0464e6e7d1309e67dadd01571655a
parent87e34f02c04da9dc2d254bf9f4e543ac014d712f (diff)
- Fix bug where config files are not enumerated on reiserfs [benj]
-rw-r--r--ChangeLog1
-rw-r--r--common/config-parser.c19
-rw-r--r--common/usuals.h1
3 files changed, 20 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 74b4741..92e8214 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
- Fixed asynchronous resolving on FreeBSD
- Fix bug where rrdbot-create ignored '-c' argument [benj]
- Remove pid file when exiting [benj]
+ - Fix bug where config files are not enumerated on reiserfs [benj]
0.4
- Reduced memory usage of SNMP requests
diff --git a/common/config-parser.c b/common/config-parser.c
index c8f2155..c59d071 100644
--- a/common/config-parser.c
+++ b/common/config-parser.c
@@ -41,6 +41,7 @@
#include <syslog.h>
#include <stdarg.h>
#include <dirent.h>
+#include <sys/stat.h>
#include <bsnmp/asn1.h>
#include <bsnmp/snmp.h>
@@ -242,6 +243,7 @@ parse_dir_internal(const char* subdir, void* data)
{
char path[MAXPATHLEN];
struct dirent* dire;
+ struct stat buf;
char* memory;
DIR* dir;
int r;
@@ -267,6 +269,23 @@ 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)
+ {
+ if(stat(path, &buf) < 0)
+ {
+ errmsg(NULL, data, "couldn't stat directory: %s", path);
+ return -1;
+ }
+
+ if(S_ISREG(buf.st_mode))
+ dire->d_type = DT_REG;
+ else if(S_ISDIR(buf.st_mode))
+ dire->d_type = DT_DIR;
+ else
+ continue;
+ }
+
/* Descend into each sub directory */
if(dire->d_type == DT_DIR)
{
diff --git a/common/usuals.h b/common/usuals.h
index 5fece3f..ef1f2d9 100644
--- a/common/usuals.h
+++ b/common/usuals.h
@@ -43,7 +43,6 @@
#include "config.h"
-#include <sys/types.h>
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>