]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Add --offroot argument to mdadm
authorJes Sorensen <Jes.Sorensen@redhat.com>
Wed, 25 Jan 2012 14:18:02 +0000 (15:18 +0100)
committerNeilBrown <neilb@suse.de>
Mon, 30 Jan 2012 01:11:16 +0000 (12:11 +1100)
When --offroot is specified, mdadm will change the first character of
argv[0] to '@'. This is used to signal to systemd that mdadm was
launched from initramfs and should not be shut down before returning
to the initramfs.

Acked-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
ReadMe.c
mdadm.8.in
mdadm.c
mdadm.h

index 9aa798b7943e1937f21d436b3361110634b79478..a60e11bb7507f90533f2bc3e8dcf081fb4d46e97 100644 (file)
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -111,6 +111,7 @@ struct option long_options[] = {
     {"kill-subarray", 1, 0, KillSubarray},
     {"update-subarray", 1, 0, UpdateSubarray},
     {"udev-rules", 2, 0, UdevRules},
+    {"offroot", 0, 0, OffRootOpt},
 
     /* synonyms */
     {"monitor",   0, 0, 'F'},
@@ -268,6 +269,10 @@ char OptionHelp[] =
 "  --query       -Q   : Display general information about how a\n"
 "                       device relates to the md driver\n"
 "  --auto-detect      : Start arrays auto-detected by the kernel\n"
+"  --offroot          : Set first character of argv[0] to @ to indicate the\n"
+"                       application was launched from initrd/initramfs and\n"
+"                       should not be shutdown by systemd as part of the\n"
+"                       regular shutdown process.\n"
 ;
 /*
 "\n"
index 27be110fce936c949da7dbf96d8f13a0484e09a4..4f06a8876aa34abf0f42da18274a680e6620b2b7 100644 (file)
@@ -254,6 +254,18 @@ Avoid printing purely informative messages.  With this,
 .I mdadm
 will be silent unless there is something really important to report.
 
+.TP
+.BR \-\-offroot
+Set first character of argv[0] to @ to indicate mdadm was launched
+from initrd/initramfs and should not be shutdown by systemd as part of
+the regular shutdown process. This option is normally only used by
+the system's initscripts. Please see here for more details on how
+systemd handled argv[0]:
+.IP
+.B http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons
+.PP
+
+
 .TP
 .BR \-f ", " \-\-force
 Be more forceful about certain operations.  See the various modes for
diff --git a/mdadm.c b/mdadm.c
index f07fac2abb674ea10ea6c779112a9db71c065310..78f28d5890e6619e9fb57dfd142c395b22a028a4 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -174,6 +174,15 @@ int main(int argc, char *argv[])
                                homehost = optarg;
                        continue;
 
+               /*
+                * --offroot sets first char of argv[0] to @. This is used
+                * by systemd to signal that the tast was launched from
+                * initrd/initramfs and should be preserved during shutdown
+                */
+               case OffRootOpt:
+                       argv[0][0] = '@';
+                       continue;
+
                case ':':
                case '?':
                        fputs(Usage, stderr);
diff --git a/mdadm.h b/mdadm.h
index 381ef8639d2444617fc75a8aa1448cbe1a8d8240..fec93aab476b5f541b3252fc2e63beb3c26dcbb5 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -321,6 +321,7 @@ enum special_options {
        UdevRules,
        FreezeReshape,
        Continue,
+       OffRootOpt,
 };
 
 /* structures read from config file */