]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: add --list-devices switch for listing candidate block devices
authorLennart Poettering <lennart@poettering.net>
Mon, 1 Jul 2024 09:54:21 +0000 (11:54 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 1 Jul 2024 14:39:40 +0000 (16:39 +0200)
man/systemd-repart.xml
src/partition/repart.c
test/units/TEST-58-REPART.sh

index 8f48081097bed0c624a97ec14850e809b0925fcf..bad3cf5ed28887c7ef3adaed5d78d6721b3c9bd3 100644 (file)
@@ -19,7 +19,7 @@
   <refnamediv>
     <refname>systemd-repart</refname>
     <refname>systemd-repart.service</refname>
-    <refpurpose>Automatically grow and add partitions</refpurpose>
+    <refpurpose>Automatically grow and add partitions, and generate disk images (DDIs).</refpurpose>
   </refnamediv>
 
   <refsynopsisdiv>
         <xi:include href="version-info.xml" xpointer="v256"/></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 that support partition tables, 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" />
       <xi:include href="standard-options.xml" xpointer="no-pager" />
index ab41769348d147cf360361631133fb2feb470ae6..9a5695d5621ecfe11f5e8a91efe85445892805cf 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "alloc-util.h"
 #include "blkid-util.h"
+#include "blockdev-list.h"
 #include "blockdev-util.h"
 #include "btrfs-util.h"
 #include "build.h"
@@ -6962,6 +6963,7 @@ static int help(void) {
                "     --image-policy=POLICY\n"
                "                          Specify disk image dissection policy\n"
                "     --definitions=DIR    Find partition definitions in specified directory\n"
+               "     --list-devices       List candidate block devices to operate on\n"
                "\n%3$sVerity:%4$s\n"
                "     --private-key=PATH|URI\n"
                "                          Private key to use when generating verity roothash\n"
@@ -7062,6 +7064,7 @@ static int parse_argv(int argc, char *argv[]) {
                 ARG_MAKE_DDI,
                 ARG_GENERATE_FSTAB,
                 ARG_GENERATE_CRYPTTAB,
+                ARG_LIST_DEVICES,
         };
 
         static const struct option options[] = {
@@ -7105,6 +7108,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "make-ddi",             required_argument, NULL, ARG_MAKE_DDI             },
                 { "generate-fstab",       required_argument, NULL, ARG_GENERATE_FSTAB       },
                 { "generate-crypttab",    required_argument, NULL, ARG_GENERATE_CRYPTTAB    },
+                { "list-devices",         no_argument,       NULL, ARG_LIST_DEVICES         },
                 {}
         };
 
@@ -7496,6 +7500,13 @@ static int parse_argv(int argc, char *argv[]) {
                                 return r;
                         break;
 
+                case ARG_LIST_DEVICES:
+                        r = blockdev_list(BLOCKDEV_LIST_REQUIRE_PARTITION_SCANNING|BLOCKDEV_LIST_SHOW_SYMLINKS|BLOCKDEV_LIST_IGNORE_ZRAM);
+                        if (r < 0)
+                                return r;
+
+                        return 0;
+
                 case '?':
                         return -EINVAL;
 
index 77adce47bbcb9732000fafd65402356a5df03fd1..2c69228d4e43459a686daa9346788a979433902b 100755 (executable)
@@ -1308,6 +1308,10 @@ testcase_urandom() {
     [[ "$(sfdisk -q -l "$image" | grep -c "$image")" -eq 1 ]]
 }
 
+testcase_list_devices() {
+    systemd-repart --list-devices
+}
+
 OFFLINE="yes"
 run_testcases