]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Snapshot work in progress: Find core files dropped on Linux, which always
authorRuss Allbery <rra@debian.org>
Tue, 16 Oct 2007 07:03:45 +0000 (07:03 +0000)
committerRuss Allbery <rra@debian.org>
Tue, 16 Oct 2007 07:03:45 +0000 (07:03 +0000)
have the PID added since they're from multithreaded programs.

debian/patches/find-core-files [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/find-core-files b/debian/patches/find-core-files
new file mode 100644 (file)
index 0000000..80d4122
--- /dev/null
@@ -0,0 +1,70 @@
+--- openafs.orig/src/bozo/bnode.c
++++ openafs/src/bozo/bnode.c
+@@ -28,6 +28,7 @@
+ #include <time.h>
+ #endif
+ #include <sys/stat.h>
++#include <dirent.h>
+ #ifdef HAVE_STRING_H
+ #include <string.h>
+@@ -105,13 +106,45 @@
+     char tbuffer[256];
+     struct stat tstat;
+     register afs_int32 code;
++    char *corefile = NULL;
+ #ifdef BOZO_SAVE_CORES
+     struct timeval Start;
+     struct tm *TimeFields;
+     char FileName[256];
+ #endif
++    /* Linux always appends the PID to core dumps from threaded processes, so
++     * we have to scan the directory to find core files under another name. */
+     code = stat(AFSDIR_SERVER_CORELOG_FILEPATH, &tstat);
++    if (code) {
++        DIR *logdir;
++        struct dirent *file;
++        char *p;
++        size_t length;
++
++        logdir = opendir(AFSDIR_LOGS_DIR);
++        if (logdir == NULL)
++            return;
++        while ((file = readdir(logdir)) != NULL) {
++            if (strncmp(file->d_name, "core.", 5) != 0)
++                continue;
++            p = file->d_name + 5;
++            do {
++                if (!isdigit((unsigned int) *p))
++                    break;
++                p++;
++            } while (*p != '\0');
++            if (*p == '\0') {
++                length = strlen(AFSDIR_LOGS_DIR) + strlen(file->d_name) + 2;
++                corefile = malloc(length);
++                if (corefile == NULL)
++                    return;
++                sprintf(corefile, "%s/%s", AFSDIR_LOGS_DIR, file->d_name);
++                code = 0;
++                break;
++            }
++        }
++    }
+     if (code)
+       return;
+@@ -124,7 +157,12 @@
+           TimeFields->tm_hour, TimeFields->tm_min, TimeFields->tm_sec);
+     strcpy(tbuffer, FileName);
+ #endif
+-    code = renamefile(AFSDIR_SERVER_CORELOG_FILEPATH, tbuffer);
++    if (corefile == NULL)
++        code = renamefile(AFSDIR_SERVER_CORELOG_FILEPATH, tbuffer);
++    else {
++        code = renamefile(corefile, tbuffer);
++        free(corefile);
++    }
+ }
+ int
index 0179e9a06a7fff925c18223d8de7b34b9b2bea56..7ca93e5290403b1b4a4bd073d4da98d8bcaaecb7 100644 (file)
@@ -7,3 +7,4 @@ bos-permissions
 compiler-flags
 no-admin-reference
 ucontext-everywhere
+find-core-files