summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-22 19:54:29 +0200
committerLennart Poettering <lennart@poettering.net>2015-10-24 23:03:49 +0200
commit0f03c2a4c093e3d44f4072144827e943c05c8904 (patch)
tree70232d1b14b4dfcd82983894d13963e2ca9f4fec /src/journal
parent0f4743651081b5367ab06f238827ddfd4da74e74 (diff)
path-util: unify how we process paths specified on the command line
Let's introduce a common function that makes relative paths absolute and warns about any errors while doing so.
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journalctl.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 863c15b738..1307bd5630 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -104,7 +104,7 @@ static const char *arg_field = NULL;
static bool arg_catalog = false;
static bool arg_reverse = false;
static int arg_journal_type = 0;
-static const char *arg_root = NULL;
+static char *arg_root = NULL;
static const char *arg_machine = NULL;
static uint64_t arg_vacuum_size = 0;
static uint64_t arg_vacuum_n_files = 0;
@@ -505,7 +505,9 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_ROOT:
- arg_root = optarg;
+ r = parse_path_argument_and_warn(optarg, true, &arg_root);
+ if (r < 0)
+ return r;
break;
case 'c':
@@ -2247,5 +2249,7 @@ finish:
strv_free(arg_system_units);
strv_free(arg_user_units);
+ free(arg_root);
+
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}