]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: restore the no-sync option for legacy halt (#3249)
authortblume <Thomas.Blume@suse.com>
Thu, 19 May 2016 14:35:27 +0000 (16:35 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 19 May 2016 14:35:27 +0000 (10:35 -0400)
The sync() call on shutdown had been removed with commit 57371e5829a61e5ee6c9f98404dfc729d6c62608
together with the no-sync option for the shutdown commands.
The sync call was restored in commit 4a3ad39957399c4a30fc472a804e72907ecaa4f9 but the no-sync option
wasn't re-added.
I think we should restore this option at least for the legacy halt command.

man/halt.xml
src/systemctl/systemctl.c

index a06dbd0097e5dc257ac380927ee383b89ba2918e..e3fa60a915b49a1072424dcb89930776007e0763 100644 (file)
         entry.</para></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>-n</option></term>
+        <term><option>--no-sync</option></term>
+
+        <listitem><para>Don't sync hard disks/storage media before
+        halt, power-off, reboot.</para></listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><option>--no-wall</option></term>
 
index 0faf37d320526988d39c4635082adcef35ff4c2a..3b4678c1190fbb5b8bbbc483ac017d8b742bea1a 100644 (file)
@@ -102,6 +102,7 @@ static bool arg_no_block = false;
 static bool arg_no_legend = false;
 static bool arg_no_pager = false;
 static bool arg_no_wtmp = false;
+static bool arg_no_sync = false;
 static bool arg_no_wall = false;
 static bool arg_no_reload = false;
 static bool arg_value = false;
@@ -6926,6 +6927,7 @@ static int halt_parse_argv(int argc, char *argv[]) {
                 { "force",     no_argument,       NULL, 'f'         },
                 { "wtmp-only", no_argument,       NULL, 'w'         },
                 { "no-wtmp",   no_argument,       NULL, 'd'         },
+                { "no-sync",   no_argument,       NULL, 'n'         },
                 { "no-wall",   no_argument,       NULL, ARG_NO_WALL },
                 {}
         };
@@ -6971,13 +6973,16 @@ static int halt_parse_argv(int argc, char *argv[]) {
                         arg_no_wtmp = true;
                         break;
 
+                case 'n':
+                        arg_no_sync = true;
+                        break;
+
                 case ARG_NO_WALL:
                         arg_no_wall = true;
                         break;
 
                 case 'i':
                 case 'h':
-                case 'n':
                         /* Compatibility nops */
                         break;
 
@@ -7496,7 +7501,8 @@ static int halt_now(enum action a) {
         /* The kernel will automaticall flush ATA disks and suchlike
          * on reboot(), but the file systems need to be synce'd
          * explicitly in advance. */
-        (void) sync();
+        if (!arg_no_sync)
+                (void) sync();
 
         /* Make sure C-A-D is handled by the kernel from this point
          * on... */