]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect: add --quiet mode
authorLennart Poettering <lennart@poettering.net>
Fri, 7 Feb 2025 18:44:13 +0000 (19:44 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 21 Feb 2025 08:57:02 +0000 (09:57 +0100)
man/systemd-dissect.xml
src/dissect/dissect.c

index 84f4a4ab10884a26c20fd01fc43c3d610031f081..b0a67da594c49686ecdfb18c4608bafee8f3ca9d 100644 (file)
 
         <listitem><para>Attach the specified disk image to an automatically allocated loopback block device,
         and print the path to the loopback block device to standard output. This is similar to an invocation
-        of <command>losetup --find --show</command>, but will validate the image as DDI before attaching, and
-        derive the correct sector size to use automatically. Moreover, it ensures the per-partition block
-        devices are created before returning. Takes a path to a disk image file.</para>
+        of <command>losetup --find --show --partscan</command>, but will validate the image as DDI before
+        attaching, and derive the correct sector size to use automatically. Moreover, it ensures the
+        per-partition block devices are created before returning and attempts to enable direct IO mode, if
+        possible. Takes a path to a disk image file.</para>
+
+        <para>If combined with <option>--quiet</option> output of the block device name is suppressed.</para>
 
         <xi:include href="version-info.xml" xpointer="v254"/></listitem>
       </varlistentry>
         <xi:include href="version-info.xml" xpointer="v258"/></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>--quiet</option></term>
+        <term><option>-q</option></term>
+
+        <listitem><para>If combined with <option>--attach</option>, suppresses output of the used loopback
+        block device path.</para>
+
+        <xi:include href="version-info.xml" xpointer="v258"/></listitem>
+      </varlistentry>
+
       <xi:include href="standard-options.xml" xpointer="image-policy-open" />
       <xi:include href="standard-options.xml" xpointer="no-pager" />
       <xi:include href="standard-options.xml" xpointer="no-legend" />
index cc538c4b92a11c3be72695558c04edaa36943dd3..6d238ecddfb141e0fb2141ab2103e6166fc49c22 100644 (file)
@@ -101,6 +101,7 @@ static bool arg_via_service = false;
 static RuntimeScope arg_runtime_scope = _RUNTIME_SCOPE_INVALID;
 static bool arg_all = false;
 static uid_t arg_uid_base = UID_INVALID;
+static bool arg_quiet = false;
 
 STATIC_DESTRUCTOR_REGISTER(arg_image, freep);
 STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
@@ -181,6 +182,7 @@ static int help(void) {
                "     --discover           Discover DDIs in well known directories\n"
                "     --validate           Validate image and image policy\n"
                "     --shift              Shift UID range to selected base\n"
+               "  -q --quiet              Suppress output of chosen loopback block device\n"
                "\nSee the %2$s for details.\n",
                program_invocation_short_name,
                link,
@@ -329,6 +331,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "system",        no_argument,       NULL, ARG_SYSTEM        },
                 { "user",          no_argument,       NULL, ARG_USER          },
                 { "all",           no_argument,       NULL, ARG_ALL           },
+                { "quiet",         no_argument,       NULL, 'q'               },
                 {}
         };
 
@@ -343,7 +346,7 @@ static int parse_argv(int argc, char *argv[]) {
         if (r < 0)
                 return r;
 
-        while ((c = getopt_long(argc, argv, "hmurMUlxa", options, NULL)) >= 0) {
+        while ((c = getopt_long(argc, argv, "hmurMUlxaq", options, NULL)) >= 0) {
 
                 switch (c) {
 
@@ -585,6 +588,10 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_all = true;
                         break;
 
+                case 'q':
+                        arg_quiet = true;
+                        break;
+
                 case '?':
                         return -EINVAL;
 
@@ -1991,7 +1998,9 @@ static int action_attach(DissectedImage *m, LoopDevice *d) {
         if (r < 0)
                 return log_error_errno(r, "Failed to relinquish DM and loopback block devices: %m");
 
-        puts(d->node);
+        if (!arg_quiet)
+                puts(d->node);
+
         return 0;
 }