[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Mon Jul 26 08:06:53 MDT 2010


The branch, master has been updated
       via  b6c4eb3... s3: Log the correct core path on Linux if core_pattern is set
      from  2ef87d8... s3: fix a typo

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit b6c4eb3c5204a5d43af10ba349fedc5f40796607
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 23 12:22:23 2010 +0200

    s3: Log the correct core path on Linux if core_pattern is set
    
    Contributions from Bill Hymas, IBM

-----------------------------------------------------------------------

Summary of changes:
 source3/configure.in |    9 ++++++++
 source3/lib/fault.c  |   57 ++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 64 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/configure.in b/source3/configure.in
index 26e98f5..905ad23 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -1105,6 +1105,15 @@ AC_CHECK_LIB(exc, trace_back_stack)
 # check for sysctlbyname for BSD systems
 AC_CHECK_FUNCS(sysctlbyname)
 
+#################################################
+# Check to see if core dump directory is defined in linux
+# with /proc/sys/kernel/core_pattern
+
+AC_CHECK_FILE([/proc/sys/kernel/core_pattern],
+	AC_DEFINE(HAVE_SYS_KERNEL_PROC_CORE_PATTERN, 1,
+	[Whether Linux kernel uses core_pattern for core files]),
+	 [])
+
 #############################
 # check if building with gpfs
 AC_CHECK_HEADERS(gpfs_gpl.h)
diff --git a/source3/lib/fault.c b/source3/lib/fault.c
index de19a72..02e054b 100644
--- a/source3/lib/fault.c
+++ b/source3/lib/fault.c
@@ -192,6 +192,52 @@ static char *get_freebsd_corepath(void)
 }
 #endif
 
+#if defined(HAVE_SYS_KERNEL_PROC_CORE_PATTERN)
+
+/**
+ * Get the Linux corepath.
+ *
+ * On Linux the contents of /proc/sys/kernel/core_pattern indicates the
+ * location of the core path.
+ */
+static char *get_linux_corepath(void)
+{
+	char *end;
+	int fd;
+	char *result;
+
+	fd = open("/proc/sys/kernel/core_pattern", O_RDONLY, 0);
+	if (fd == -1) {
+		return NULL;
+	}
+
+	result = afdgets(fd, NULL, 0);
+	close(fd);
+
+	if (result == NULL) {
+		return NULL;
+	}
+
+	if (result[0] != '/') {
+		/*
+		 * No absolute path, use the default (cwd)
+		 */
+		TALLOC_FREE(result);
+		return NULL;
+	}
+	/* Strip off the common filename expansion */
+
+	end = strrchr_m(result, '/');
+
+	if ((end != result) /* this would be the only / */
+	    && (end != NULL)) {
+		*end = '\0';
+	}
+	return result;
+}
+#endif
+
+
 /**
  * Try getting system-specific corepath if one exists.
  *
@@ -200,11 +246,18 @@ static char *get_freebsd_corepath(void)
 static char *get_corepath(const char *logbase, const char *progname)
 {
 #if (defined(FREEBSD) && defined(HAVE_SYSCTLBYNAME))
+	char *tmp_corepath = NULL;
+	tmp_corepath = get_freebsd_corepath();
 
-	/* @todo: Add support for the linux corepath. */
+	/* If this has been set correctly, we're done. */
+	if (tmp_corepath) {
+		return tmp_corepath;
+	}
+#endif
 
+#if defined(HAVE_SYS_KERNEL_PROC_CORE_PATTERN)
 	char *tmp_corepath = NULL;
-	tmp_corepath = get_freebsd_corepath();
+	tmp_corepath = get_linux_corepath();
 
 	/* If this has been set correctly, we're done. */
 	if (tmp_corepath) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list