keep files
authorArjan van de Ven <arjan@linux.intel.com>
Sun, 8 Mar 2009 00:20:25 +0000 (16:20 -0800)
committerArjan van de Ven <arjan@linux.intel.com>
Sun, 8 Mar 2009 00:20:25 +0000 (16:20 -0800)
configfile.c
coredump.c
corewatcher.conf

index abd0d96..6055338 100644 (file)
@@ -37,7 +37,7 @@
 int opted_in;
 int allow_distro_to_pass_on;
 char *submit_url;
-
+extern int do_unlink;
 
 void read_config_file(char *filename)
 {
@@ -72,6 +72,12 @@ void read_config_file(char *filename)
                        if (strstr(c, "yes"))
                                allow_distro_to_pass_on = 1;
                }
+               c = strstr(line, "unlink ");
+               if (c) {
+                       c += 14;
+                       if (strstr(c, "yes"))
+                               do_unlink = 1;
+               }
                c = strstr(line, "submit-url ");
                if (c) {
                        c += 11;
index fb394ee..55c9330 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "corewatcher.h"
 
+int do_unlink = 0;
 
 #define MAX(A,B) ((A) > (B) ? (A) : (B))
 
@@ -103,6 +104,7 @@ char *extract_core(char *corefile)
 void process_corefile(char *filename)
 {
        char *ptr;
+       char newfile[8192];
        ptr = extract_core(filename);
 
        if (!ptr)
@@ -110,7 +112,11 @@ void process_corefile(char *filename)
 
        queue_backtrace(ptr);
        printf("-%s-\n", ptr);
-       unlink(filename);
+       sprintf(newfile,"%s.processed", filename);
+       if (do_unlink)
+               unlink(filename);
+       else
+               rename(filename, newfile);
 
        free(ptr);
 }
@@ -133,6 +139,8 @@ int scan_dmesg(void __unused *unused)
                        break;
                if (entry->d_name[0] == '.')
                        continue;
+               if (strstr(entry->d_name, "processed"))
+                       continue;
                sprintf(path, "/var/cores/%s", entry->d_name);
                printf("Looking at %s\n", path);
                process_corefile(path);
index 12fae29..097010d 100644 (file)
@@ -29,6 +29,10 @@ allow-submit = ask
 allow-pass-on = yes
 
 #
+# Delete the coredumps after processing
+#
+unlink = no
+#
 # URL for submitting the backtraces
 #