]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
storagetm: add --list-devices command 33553/head
authorLennart Poettering <lennart@poettering.net>
Mon, 1 Jul 2024 09:55:52 +0000 (11:55 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 1 Jul 2024 14:39:40 +0000 (16:39 +0200)
man/systemd-storagetm.service.xml
src/storagetm/storagetm.c
test/units/TEST-84-STORAGETM.sh

index 6fdbc3dc056c6b4384085a31d486871388581f70..25c5c4e4fc94fe685e8b46244ac5cac5e09013b8 100644 (file)
 
         <xi:include href="version-info.xml" xpointer="v255"/></listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term><option>--list-devices</option></term>
+
+        <listitem><para>Show a list of candidate block devices this command may operate on. Specifically,
+        this enumerates block devices currently present, and shows their device node paths along with any of
+        their symlinks.</para>
+
+        <xi:include href="version-info.xml" xpointer="v257"/></listitem>
+      </varlistentry>
+
       <xi:include href="standard-options.xml" xpointer="help" />
       <xi:include href="standard-options.xml" xpointer="version" />
     </variablelist>
index 1bb8eec3165d5b8be887b485ae9af39b0b7854b1..910746dc346a223d5094b6c4ed44d9c4998a6acc 100644 (file)
@@ -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;
 
index eae87d52341f1b095a3ee58c960b2b59cbfae5ad..1dd2ea61849e69d56f65305f6e9c6ed2838f668a 100755 (executable)
@@ -3,6 +3,8 @@
 set -eux
 set -o pipefail
 
+/usr/lib/systemd/systemd-storagetm --list-devices
+
 modprobe -v nvmet-tcp
 modprobe -v nvme-tcp