diff --git a/man/systemd-sysext.xml b/man/systemd-sysext.xml index 8705fa7275..050e21fafc 100644 --- a/man/systemd-sysext.xml +++ b/man/systemd-sysext.xml @@ -389,8 +389,8 @@ - - Set mutable mode. + + Set mutable mode. The special value help will list the known values. @@ -438,6 +438,12 @@ with the modifications made to the host file system being discarded after unmerge. + + + + list known values and exit immediately. + + diff --git a/shell-completion/bash/systemd-confext b/shell-completion/bash/systemd-confext index d36f70fa09..16dbdf06bb 100644 --- a/shell-completion/bash/systemd-confext +++ b/shell-completion/bash/systemd-confext @@ -36,7 +36,8 @@ _systemd-confext() { [ARG]='--root --json --noexec - --image-policy' + --image-policy + --mutable' ) local -A VERBS=( @@ -59,11 +60,14 @@ _systemd-confext() { comps='pretty short off' ;; --noexec) - comps='false true' + comps='no yes' ;; --image-policy) comps='' ;; + --mutable) + comps=$( systemd-confext --no-legend --mutable=help 2>/dev/null; echo help ) + ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 diff --git a/shell-completion/bash/systemd-sysext b/shell-completion/bash/systemd-sysext index 5c15f076a8..c605237ed6 100644 --- a/shell-completion/bash/systemd-sysext +++ b/shell-completion/bash/systemd-sysext @@ -31,9 +31,13 @@ _systemd-sysext() { [STANDALONE]='-h --help --version --no-pager --no-legend + --no-reload --force' [ARG]='--root - --json' + --json + --noexec + --image-policy + --mutable' ) local -A VERBS=( @@ -55,6 +59,15 @@ _systemd-sysext() { --json) comps='pretty short off' ;; + --noexec) + comps='no yes' + ;; + --image-policy) + comps='' + ;; + --mutable) + comps=$( systemd-sysext --no-legend --mutable=help 2>/dev/null; echo help ) + ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c index 5255ac1df1..c88c104296 100644 --- a/src/sysext/sysext.c +++ b/src/sysext/sysext.c @@ -79,7 +79,7 @@ static const char* const mutable_mode_table[_MUTABLE_MAX] = { [MUTABLE_EPHEMERAL_IMPORT] = "ephemeral-import", }; -DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING_WITH_BOOLEAN(mutable_mode, MutableMode, MUTABLE_YES); +DEFINE_PRIVATE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(mutable_mode, MutableMode, MUTABLE_YES); static char **arg_hierarchies = NULL; /* "/usr" + "/opt" by default for sysext and /etc by default for confext */ static char *arg_root = NULL; @@ -2462,7 +2462,7 @@ static int verb_help(int argc, char **argv, void *userdata) { " -h --help Show this help\n" " --version Show package version\n" "\n%3$sOptions:%4$s\n" - " --mutable=yes|no|auto|import|ephemeral|ephemeral-import\n" + " --mutable=yes|no|auto|import|ephemeral|ephemeral-import|help\n" " Specify a mutability mode of the merged hierarchy\n" " --no-pager Do not pipe output into a pager\n" " --no-legend Do not show the headers and footers\n" @@ -2577,6 +2577,14 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_MUTABLE: + if (streq(optarg, "help")) { + if (arg_legend) + puts("Known mutability modes:"); + + DUMP_STRING_TABLE(mutable_mode, MutableMode, _MUTABLE_MAX); + return 0; + } + r = parse_mutable_mode(optarg); if (r < 0) return log_error_errno(r, "Failed to parse argument to --mutable=: %s", optarg);