Shift files from /tmp to /var/lib/corewatcher
authorTim Pepper <timothy.c.pepper@linux.intel.com>
Tue, 11 Sep 2012 15:46:39 +0000 (08:46 -0700)
committerTim Pepper <timothy.c.pepper@linux.intel.com>
Tue, 11 Sep 2012 15:46:39 +0000 (08:46 -0700)
Signed-off-by: Tim Pepper <timothy.c.pepper@linux.intel.com>
corewatcher.conf
src/configfile.c
src/coredump.c

index 8bda388..115eb43 100644 (file)
@@ -55,5 +55,5 @@ release-info=/etc/os-release
 # Location to store coredumps after they are processed
 #
 
-core-folder=/tmp/corewatcher/
+core-folder=/var/lib/corewatcher/
 
index 47b0d6e..2372d23 100644 (file)
@@ -118,5 +118,5 @@ void read_config_file(char *filename)
                        url_count++;
        }
        if (!core_folder)
-               core_folder = strdup("/tmp/corewatcher/");
+               core_folder = strdup("/var/lib/corewatcher/");
 }
index 0abd4d6..e071390 100644 (file)
@@ -386,7 +386,7 @@ fixup:                      /* gdb outputs some 0x1a's which break XML */
 }
 
 /*
- * filename is of the form core.XXXX[.blah]
+ * filename is of the form core_XXXX[.blah]
  * we need to get the pid out as we want
  * output of the form XXXX[.ext]
  */
@@ -397,7 +397,7 @@ char *get_core_filename(char *filename, char *ext)
        if (!filename)
                return NULL;
 
-       if (!(s = strstr(filename, ".")))
+       if (!(s = strstr(filename, "_")))
                return NULL;
 
        if (!(++s))
@@ -771,7 +771,7 @@ int scan_corefolders(void __unused *unused)
                if (strncmp(entry->d_name, "core_", 5))
                        continue;
 
-               /* matched core.#### where #### is the processes pid */
+               /* matched core_#### where #### is the pid of the process */
                r = asprintf(&fullpath, "%s%s", tmp_folder, entry->d_name);
                if (r == -1) {
                        fullpath = NULL;
@@ -801,8 +801,12 @@ int scan_corefolders(void __unused *unused)
        if (!core_folder)
                return 1;
        dir = opendir(core_folder);
-       if (!dir)
-               return 1;
+       if (!dir) {
+               if (!mkdir(core_folder, S_IRWXU | S_IRWXG | S_IRWXO)
+                       && errno != EEXIST) {
+                       return 1;
+               }
+       }
 
        fprintf(stderr, "+ scanning %s...\n", core_folder);
        while(1) {