-#define filename_escape(s) xescape((s), "./ ")
-
-static int make_coredump_path(sd_journal *j, char **ret) {
- _cleanup_free_ char
- *pid = NULL, *boot_id = NULL, *tstamp = NULL, *comm = NULL,
- *p = NULL, *b = NULL, *t = NULL, *c = NULL;
- const void *d;
- size_t l;
- char *fn;
-
- assert(j);
- assert(ret);
-
- SD_JOURNAL_FOREACH_DATA(j, d, l) {
- retrieve(d, l, "COREDUMP_COMM", &comm);
- retrieve(d, l, "COREDUMP_PID", &pid);
- retrieve(d, l, "COREDUMP_TIMESTAMP", &tstamp);
- retrieve(d, l, "_BOOT_ID", &boot_id);
- }
-
- if (!pid || !comm || !tstamp || !boot_id) {
- log_error("Failed to retrieve necessary fields to find coredump on disk.");
- return -ENOENT;
- }
-
- p = filename_escape(pid);
- if (!p)
- return log_oom();
-
- t = filename_escape(tstamp);
- if (!t)
- return log_oom();
-
- c = filename_escape(comm);
- if (!t)
- return log_oom();
-
- b = filename_escape(boot_id);
- if (!b)
- return log_oom();
-
- fn = strjoin("/var/lib/systemd/coredump/core.", c, ".", b, ".", p, ".", t, NULL);
- if (!fn)
- return log_oom();
-
- *ret = fn;
- return 0;
-}
-