diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-07-01 11:55:52 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-07-01 16:39:40 +0200 |
commit | a90682f9819bbbde8717b90498df246bf4650314 (patch) | |
tree | 7732c1f8164446321b466ca0cff94bb80427086d /src/storagetm | |
parent | repart: add --list-devices switch for listing candidate block devices (diff) | |
download | systemd-a90682f9819bbbde8717b90498df246bf4650314.tar.xz systemd-a90682f9819bbbde8717b90498df246bf4650314.zip |
storagetm: add --list-devices command
Diffstat (limited to 'src/storagetm')
-rw-r--r-- | src/storagetm/storagetm.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/storagetm/storagetm.c b/src/storagetm/storagetm.c index 1bb8eec316..910746dc34 100644 --- a/src/storagetm/storagetm.c +++ b/src/storagetm/storagetm.c @@ -5,6 +5,7 @@ #include "af-list.h" #include "alloc-util.h" +#include "blockdev-list.h" #include "blockdev-util.h" #include "build.h" #include "daemon-util.h" @@ -50,6 +51,7 @@ static int help(void) { " --version Show package version\n" " --nqn=STRING Select NQN (NVMe Qualified Name)\n" " -a --all Expose all devices\n" + " --list-devices List candidate block devices to operate on\n" "\nSee the %s for details.\n", program_invocation_short_name, ansi_highlight(), @@ -64,13 +66,15 @@ static int parse_argv(int argc, char *argv[]) { enum { ARG_NQN = 0x100, ARG_VERSION, + ARG_LIST_DEVICES, }; static const struct option options[] = { - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, ARG_VERSION }, - { "nqn", required_argument, NULL, ARG_NQN }, - { "all", no_argument, NULL, 'a' }, + { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, ARG_VERSION }, + { "nqn", required_argument, NULL, ARG_NQN }, + { "all", no_argument, NULL, 'a' }, + { "list-devices", no_argument, NULL, ARG_LIST_DEVICES }, {} }; @@ -102,6 +106,13 @@ static int parse_argv(int argc, char *argv[]) { arg_all++; break; + case ARG_LIST_DEVICES: + r = blockdev_list(BLOCKDEV_LIST_SHOW_SYMLINKS|BLOCKDEV_LIST_IGNORE_ZRAM); + if (r < 0) + return r; + + return 0; + case '?': return -EINVAL; |