<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi members of <span style="color: rgb(0, 0, 0); font-family:
"Times New Roman"; font-size: medium; font-style:
normal; font-variant-ligatures: normal; font-variant-caps:
normal; font-weight: normal; letter-spacing: normal; orphans: 2;
text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: 2; word-spacing: 0px;
-webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
255); text-decoration-style: initial; text-decoration-color:
initial; display: inline !important; float: none;"><span></span></span><a
href="mailto:minicoredumper@linutronix.de" style="font-family:
"Times New Roman"; font-size: medium; font-style:
normal; font-variant-ligatures: normal; font-variant-caps:
normal; font-weight: normal; letter-spacing: normal; orphans: 2;
text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: 2; word-spacing: 0px;
-webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
255);">minicoredumper@linutronix.de</a>,</p>
<p>I started using minicoredumper for our projects. Very nice and
handy tool!</p>
<p>Just an idea on how it could be made even more handy.<br>
</p>
<p>Motivation: <br>
On embedded system an enduser should not see any core dumps on the
device. So core dumps are something you only need for development.<br>
There is a nice feature of minicoredumper that allows to customize
the path where core files are stored. My problem here is that this
path needs to<br>
exist in filesystem. <br>
</p>
<p>What I have done is setting the customized core dump path to
/home/root/crash and patch the minicoredump to not fail if dir
does not exist.<br>
Instead now the sub directory "crash" is created when the first
crash occurs.</p>
<p>For me and my colleagues (especially for fieldtest) this is nice,
because then you see: If a dir crash exists, something went wrong,
else all fine.</p>
<p>To achieve this I patched the minicoredumper source:</p>
<p>From a89bb8711d3521cd11d69ef0531918d0345aa5c9 Mon Sep 17 00:00:00
2001<br>
From: "Bode, Michael (BSH)" <a class="moz-txt-link-rfc2396E" href="mailto:Michael.Bode@bshg.com"><Michael.Bode@bshg.com></a><br>
Date: Sat, 30 Sep 2017 11:03:35 +0200<br>
Subject: [PATCH] Modify mkdir function to generate core dump also
if dir have<br>
not existed before<br>
<br>
---<br>
src/minicoredumper/corestripper.c | 20 +++++++++++++++++++-<br>
1 file changed, 19 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/minicoredumper/corestripper.c
b/src/minicoredumper/corestripper.c<br>
index f4e7fcd..dce1170 100644<br>
--- a/src/minicoredumper/corestripper.c<br>
+++ b/src/minicoredumper/corestripper.c<br>
@@ -308,6 +308,24 @@ out:<br>
return err;<br>
}<br>
<br>
+<br>
+static int mkpath(char *dir, mode_t mode)<br>
+{<br>
+ struct stat sb;<br>
+<br>
+ if (!dir) {<br>
+ errno = EINVAL;<br>
+ return 1;<br>
+ }<br>
+<br>
+ if (!stat(dir, &sb))<br>
+ return 0;<br>
+<br>
+ mkpath(dirname(strdupa(dir)), mode);<br>
+<br>
+ return mkdir(dir, mode);<br>
+}<br>
+<br>
static int init_di(struct dump_info *di, char **argv, int argc)<br>
{<br>
const char *recept;<br>
@@ -430,7 +448,7 @@ static int init_di(struct dump_info *di, char
**argv, int argc)<br>
}<br>
di->dst_dir = tmp_path;<br>
<br>
- if (mkdir(di->dst_dir, 0700) == -1) {<br>
+ if (mkpath(di->dst_dir, 0700) == -1) {<br>
info("unable to create directory \'%s\': %s",
di->dst_dir,<br>
strerror(errno));<br>
return 1;<br>
-- <br>
2.7.4<br>
</p>
<p>Please don't take my implementation proposal too serious. I just
want to give you the idea here. <br>
If you agree that this is an improvement maybe it would be even
better to have an option in JSON file if you want to write
non-existing paths.<br>
</p>
<p>Br,<br>
Michael<br>
</p>
<p><br>
</p>
<p><br>
</p>
</body>
</html>