SOURCES: sysvinit-rebootconfirmation.patch (NEW) - add "ask for confirmatio...
shadzik
shadzik at pld-linux.org
Wed Aug 20 14:52:06 CEST 2008
Author: shadzik Date: Wed Aug 20 12:52:06 2008 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- add "ask for confirmation on reboot" option
---- Files affected:
SOURCES:
sysvinit-rebootconfirmation.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/sysvinit-rebootconfirmation.patch
diff -u /dev/null SOURCES/sysvinit-rebootconfirmation.patch:1.1
--- /dev/null Wed Aug 20 14:52:06 2008
+++ SOURCES/sysvinit-rebootconfirmation.patch Wed Aug 20 14:52:00 2008
@@ -0,0 +1,61 @@
+--- src/halt.c-dupa 2008-08-20 14:45:39.019976250 +0200
++++ src/halt.c 2008-08-20 14:49:35.418750250 +0200
+@@ -64,7 +64,7 @@
+ */
+ void usage(void)
+ {
+- fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i]%s\n",
++ fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i] [-c]%s\n",
+ progname, strcmp(progname, "halt") ? "" : " [-p]");
+ fprintf(stderr, "\t-n: don't sync before halting the system\n");
+ fprintf(stderr, "\t-w: only write a wtmp reboot record and exit.\n");
+@@ -72,6 +72,7 @@
+ fprintf(stderr, "\t-f: force halt/reboot, don't call shutdown.\n");
+ fprintf(stderr, "\t-h: put harddisks in standby mode.\n");
+ fprintf(stderr, "\t-i: shut down all network interfaces.\n");
++ fprintf(stderr, "\t-c: aks for confirmation.\n");
+ if (!strcmp(progname, "halt"))
+ fprintf(stderr, "\t-p: power down the system (if possible, otherwise halt).\n");
+ exit(1);
+@@ -172,8 +173,10 @@
+ int do_ifdown = 0;
+ int do_hddown = 0;
+ int do_poweroff = 0;
++ int do_confirm = 0;
+ int c;
+ char *tm = NULL;
++ char answer = 'n';
+
+ /*
+ * Find out who we are
+@@ -190,7 +193,7 @@
+ /*
+ * Get flags
+ */
+- while((c = getopt(argc, argv, ":ihdfnpwt:")) != EOF) {
++ while((c = getopt(argc, argv, ":ihdfnpwct:")) != EOF) {
+ switch(c) {
+ case 'n':
+ do_sync = 0;
+@@ -214,6 +217,9 @@
+ case 'p':
+ do_poweroff = 1;
+ break;
++ case 'c':
++ do_confirm = 1;
++ break;
+ case 't':
+ tm = optarg;
+ break;
+@@ -231,6 +237,11 @@
+ (void)chdir("/");
+
+ if (!do_hard && !do_nothing) {
++ if (do_confirm) {
++ fprintf(stderr, "Are you sure you want to reboot? N/y.\n");
++ scanf("%c", &answer);
++ if (tolower(answer) != 'y') exit(1);
++ }
+ /*
+ * See if we are in runlevel 0 or 6.
+ */
================================================================
More information about the pld-cvs-commit
mailing list