summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/coredumpctl.xml13
-rw-r--r--src/coredump/coredumpctl.c36
2 files changed, 47 insertions, 2 deletions
diff --git a/man/coredumpctl.xml b/man/coredumpctl.xml
index 52270a3e07..8002549f7d 100644
--- a/man/coredumpctl.xml
+++ b/man/coredumpctl.xml
@@ -256,6 +256,19 @@
</varlistentry>
<varlistentry>
+ <term><option>--image=<replaceable>image</replaceable></option></term>
+
+ <listitem><para>Takes a path to a disk image file or block device node. If specified, all operations
+ are applied to file system in the indicated disk image. This option is similar to
+ <option>--root=</option>, but operates on file systems stored in disk images or block devices. The
+ disk image should either contain just a file system or a set of file systems within a GPT partition
+ table, following the <ulink url="https://systemd.io/DISCOVERABLE_PARTITIONS">Discoverable Partitions
+ Specification</ulink>. For further information on supported disk images, see
+ <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
+ switch of the same name.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>-q</option></term>
<term><option>--quiet</option></term>
diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c
index 1de9106c8b..383d5716c4 100644
--- a/src/coredump/coredumpctl.c
+++ b/src/coredump/coredumpctl.c
@@ -17,6 +17,7 @@
#include "chase-symlinks.h"
#include "compress.h"
#include "def.h"
+#include "dissect-image.h"
#include "fd-util.h"
#include "format-table.h"
#include "fs-util.h"
@@ -26,6 +27,7 @@
#include "log.h"
#include "macro.h"
#include "main-func.h"
+#include "mount-util.h"
#include "pager.h"
#include "parse-argument.h"
#include "parse-util.h"
@@ -51,6 +53,7 @@ static const char *arg_debugger = NULL;
static char **arg_debugger_args = NULL;
static const char *arg_directory = NULL;
static char *arg_root = NULL;
+static char *arg_image = NULL;
static char **arg_file = NULL;
static JsonFormatFlags arg_json_format_flags = JSON_FORMAT_OFF;
static PagerFlags arg_pager_flags = 0;
@@ -212,6 +215,7 @@ static int parse_argv(int argc, char *argv[]) {
ARG_DEBUGGER,
ARG_FILE,
ARG_ROOT,
+ ARG_IMAGE,
ARG_ALL,
};
@@ -234,6 +238,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "quiet", no_argument, NULL, 'q' },
{ "json", required_argument, NULL, ARG_JSON },
{ "root", required_argument, NULL, ARG_ROOT },
+ { "image", required_argument, NULL, ARG_IMAGE },
{ "all", no_argument, NULL, ARG_ALL },
{}
};
@@ -330,6 +335,12 @@ static int parse_argv(int argc, char *argv[]) {
return r;
break;
+ case ARG_IMAGE:
+ r = parse_path_argument(optarg, false, &arg_image);
+ if (r < 0)
+ return r;
+ break;
+
case 'r':
arg_reverse = true;
break;
@@ -361,8 +372,8 @@ static int parse_argv(int argc, char *argv[]) {
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"--since= must be before --until=.");
- if ((!!arg_directory + !!arg_root) > 1)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Please specify either --root= or -D/--directory=, the combination of these options is not supported.");
+ if ((!!arg_directory + !!arg_image + !!arg_root) > 1)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Please specify either --root=, --image= or -D/--directory=, the combination of these options is not supported.");
return 1;
}
@@ -1324,6 +1335,8 @@ static int coredumpctl_main(int argc, char *argv[]) {
}
static int run(int argc, char *argv[]) {
+ _cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL;
+ _cleanup_(umount_and_rmdir_and_freep) char *mounted_dir = NULL;
int r, units_active;
setlocale(LC_ALL, "");
@@ -1340,6 +1353,25 @@ static int run(int argc, char *argv[]) {
units_active = check_units_active(); /* error is treated the same as 0 */
+ if (arg_image) {
+ assert(!arg_root);
+
+ r = mount_image_privately_interactively(
+ arg_image,
+ DISSECT_IMAGE_GENERIC_ROOT |
+ DISSECT_IMAGE_REQUIRE_ROOT |
+ DISSECT_IMAGE_RELAX_VAR_CHECK |
+ DISSECT_IMAGE_VALIDATE_OS,
+ &mounted_dir,
+ &loop_device);
+ if (r < 0)
+ return r;
+
+ arg_root = strdup(mounted_dir);
+ if (!arg_root)
+ return log_oom();
+ }
+
r = coredumpctl_main(argc, argv);
if (units_active > 0)