Commit Diff
Diff:
3681e7113772439a7ad7b3fa14a425d31a833845
4583838f31f05b3ff0b94b5b00e9af6fe7559301
Commit:
4583838f31f05b3ff0b94b5b00e9af6fe7559301
Tree:
79939854a4cd480a84bfb1b27c4d8fbff77d9b2f
Author:
pbug <pbug@delphinusdns.org>
Committer:
pbug <pbug@delphinusdns.org>
Date:
Sat Feb 28 20:40:34 2009 UTC
Message:
* do some digging in parse.c to get the device name that our configfile sits on. * LOG_CONS removed, this was a mistake
blob - e4950d9dff6da73994f59dffe4cc953057bcd5de
blob + 5c18341e611b1e026a84d844eaa960be929b197e
--- include.h
+++ include.h
@@ -50,6 +50,7 @@
#include <db.h>
#include <pwd.h>
#include <ifaddrs.h>
+#include <dirent.h>
#ifndef NTOHS
#include "endian.h"
blob - 87067e91f75e9ea43ee243bda26a82810ae61a83
blob + ffe91cd41f51c9396de7e818164b5b4bee530b42
--- main.c
+++ main.c
@@ -65,7 +65,7 @@ extern char *__progname;
static int Wflag = 0;
static int lflag = 0;
-static char rcsid[] = "$Id: main.c,v 1.14 2009/02/26 14:38:24 pbug Exp $";
+static char rcsid[] = "$Id: main.c,v 1.15 2009/02/28 20:40:34 pbug Exp $";
/*
* MAIN - set up arguments, set up database, set up sockets, call mainloop
@@ -146,7 +146,7 @@ main(int argc, char *argv[])
exit(1);
}
- openlog(__progname, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON);
+ openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
syslog(LOG_INFO, "starting up");
#if DB_VERSION_MAJOR == 4
blob - f2d75bc5b940577133f7a556f1ec950d8bfb5222
blob + 7c588aa5dead51649159d748632553555a6a3680
--- parse.c
+++ parse.c
@@ -45,7 +45,7 @@ struct myrr_lookup {
{ NULL, 0 },
};
-static char rcsid[] = "$Id: parse.c,v 1.10 2009/02/26 15:18:34 pbug Exp $";
+static char rcsid[] = "$Id: parse.c,v 1.11 2009/02/28 20:40:34 pbug Exp $";
/*
* PARSE_FILE - parse the configfile XXX rewrite me in yacc :(
@@ -74,11 +74,13 @@ parse_file(DB *db, char *file)
DBT key, data;
FILE *f;
+ DIR *dir;
in_addr_t *ia;
struct domain sdomain;
struct in6_addr *ia6;
- struct stat sb;
+ struct stat sb, sb0;
+ struct dirent *dp;
fd = open(file, O_RDONLY, 0);
if (fd < 0) {
@@ -93,9 +95,33 @@ parse_file(DB *db, char *file)
return -1;
}
+ /* open /dev and get the matching device */
+
+ dir = opendir("/dev/");
+ if (dir == NULL) {
+ syslog(LOG_INFO, "opendir: %m");
+ return -1;
+ }
+
+ while ((dp = readdir(dir)) != NULL) {
+ snprintf(buf, sizeof(buf) - 1, "/dev/%s", dp->d_name);
+ if (stat(buf, &sb0) < 0) {
+ syslog(LOG_INFO, "stat: %m");
+ return -1;
+ }
+
+ if (sb.st_dev == sb0.st_rdev)
+ break;
+ }
+
+ closedir(dir);
+
+ if (sb.st_dev != sb0.st_rdev)
+ snprintf(buf, sizeof(buf) - 1, "%ld", (long)sb.st_dev);
+
syslog(LOG_INFO,
- "opening configfile \"%s\", device: %ld, inode: %ld, ctime: %ld",
- file, (long)sb.st_dev, (long)sb.st_ino, (long)sb.st_ctime);
+ "opening configfile \"%s\", device: %s, inode: %ld, ctime: %ld",
+ file, buf, (long)sb.st_ino, (long)sb.st_ctime);
if ((f = fdopen(fd, "r")) == NULL) {
syslog(LOG_INFO, "fdopen: %m");
repomaster@centroid.eu