From: Teemu Toivola Date: Fri, 29 Aug 2014 19:57:43 +0000 (+0300) Subject: make filename reservation for possible future feature X-Git-Tag: v1.12~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a7f43680b81b92cdb7972e8da46cdb5b576cddea;p=vnstat make filename reservation for possible future feature --- diff --git a/src/common.h b/src/common.h index d2a0377..53f611b 100644 --- a/src/common.h +++ b/src/common.h @@ -55,6 +55,7 @@ and most can be changed later from the config file. #define DATABASEDIR "/var/lib/vnstat" #endif #endif +#define DATABASEFILE "vnstat.db" /* on which day should months change */ #define MONTHROTATE 1 diff --git a/src/daemon.c b/src/daemon.c index 46095ce..d117acd 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -421,7 +421,7 @@ void preparedatabases(DSTATE *s) /* check if there's something to work with */ s->dbcount = 0; while ((di=readdir(dir))) { - if (di->d_name[0]!='.') { + if ((di->d_name[0]!='.') && (strcmp(di->d_name, DATABASEFILE)!=0)) { s->dbcount++; } } @@ -486,7 +486,7 @@ void filldatabaselist(DSTATE *s) } while ((di=readdir(dir))) { - if (di->d_name[0]=='.') { + if ((di->d_name[0]=='.') || (strcmp(di->d_name, DATABASEFILE)==0)) { continue; } diff --git a/src/vnstat.c b/src/vnstat.c index 25b3ac0..66e6f1a 100644 --- a/src/vnstat.c +++ b/src/vnstat.c @@ -301,7 +301,7 @@ int main(int argc, char *argv[]) { if (debug) printf("Dir OK\n"); while ((di=readdir(dir))) { - if (di->d_name[0]=='.') { + if ((di->d_name[0]=='.') || (strcmp(di->d_name, DATABASEFILE)==0)) { continue; } strncpy_nt(p.definterface, di->d_name, 32); @@ -744,7 +744,7 @@ void handleupdate(PARAMS *p) while ((di=readdir(dir))) { /* ignore backup files, '.' and '..' dirs */ - if (di->d_name[0]=='.') { + if ((di->d_name[0]=='.') || (strcmp(di->d_name, DATABASEFILE)==0)) { continue; } @@ -862,7 +862,7 @@ void handleshowdatabases(PARAMS *p) return; } while ((di=readdir(dir))) { - if (di->d_name[0]=='.') { + if ((di->d_name[0]=='.') || (strcmp(di->d_name, DATABASEFILE)==0)) { continue; } strncpy_nt(p->interface, di->d_name, 32);