[rrd-developers] [PATCH 2/2] rrdcached: Create journal directory on startup.

Sebastian Harl sh at tokkee.org
Sat Sep 26 13:10:49 CEST 2009


… rather than abort with an error.
---
 program/src/rrd_daemon.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/program/src/rrd_daemon.c b/program/src/rrd_daemon.c
index 16b5df5..308d3b6 100644
--- a/program/src/rrd_daemon.c
+++ b/program/src/rrd_daemon.c
@@ -2923,18 +2923,17 @@ static int read_options (int argc, char **argv) /* {{{ */
 
       case 'j':
       {
-        struct stat statbuf;
         const char *dir = journal_dir = strdup(optarg);
 
-        status = stat(dir, &statbuf);
+        status = rrd_mkdir_p(dir, 0777);
         if (status != 0)
         {
-          fprintf(stderr, "Cannot stat '%s' : %s\n", dir, rrd_strerror(errno));
+          fprintf(stderr, "Failed to create journal directory '%s': %s\n",
+              dir, rrd_strerror(errno));
           return 6;
         }
 
-        if (!S_ISDIR(statbuf.st_mode)
-            || access(dir, R_OK|W_OK|X_OK) != 0)
+        if (access(dir, R_OK|W_OK|X_OK) != 0)
         {
           fprintf(stderr, "Must specify a writable directory with -j! (%s)\n",
                   errno ? rrd_strerror(errno) : "");
-- 
1.6.5.rc2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20090926/ab0a0fce/attachment-0001.pgp 


More information about the rrd-developers mailing list