SCCS-vsn: sbin/shutdown/shutdown.c 5.2
#endif not lint
#ifndef lint
#endif not lint
#ifndef lint
-static char sccsid[] = "@(#)shutdown.c 5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)shutdown.c 5.2 (Berkeley) %G%";
#endif not lint
#include <stdio.h>
#endif not lint
#include <stdio.h>
int killflg = 1;
int reboot = 0;
int halt = 0;
int killflg = 1;
int reboot = 0;
int halt = 0;
+int fast = 0;
+char *nosync = NULL;
+char nosyncflag[] = "-n";
char term[sizeof tpath + sizeof utmp.ut_line];
char tbuf[BUFSIZ];
char nolog1[] = "\n\nNO LOGINS: System going down at %5.5s\n\n";
char *nolog2[NLOG+1];
#ifdef DEBUG
char nologin[] = "nologin";
char term[sizeof tpath + sizeof utmp.ut_line];
char tbuf[BUFSIZ];
char nolog1[] = "\n\nNO LOGINS: System going down at %5.5s\n\n";
char *nolog2[NLOG+1];
#ifdef DEBUG
char nologin[] = "nologin";
+char fastboot[] = "fastboot";
#else
char nologin[] = "/etc/nologin";
#else
char nologin[] = "/etc/nologin";
+char fastboot[] = "/fastboot";
#endif
time_t nowtime;
jmp_buf alarmbuf;
#endif
time_t nowtime;
jmp_buf alarmbuf;
case 'k':
killflg = 0;
continue;
case 'k':
killflg = 0;
continue;
+ case 'n':
+ nosync = nosyncflag;
+ continue;
+ case 'f':
+ fast = 1;
+ continue;
case 'r':
reboot = 1;
continue;
case 'r':
reboot = 1;
continue;
argc--, argv++;
}
if (argc < 1) {
argc--, argv++;
}
if (argc < 1) {
- printf("Usage: %s [ -krh ] shutdowntime [ message ]\n",
- argv[0]);
+ /* argv[0] is not available after the argument handling. */
+ printf("Usage: shutdown [ -krhfn ] shutdowntime [ message ]\n");
+ finish();
+ }
+ if (fast && (nosync == nosyncflag)) {
+ printf ("shutdown: Incompatible switches 'fast' & 'nosync'\n");
finish();
}
if (geteuid()) {
finish();
}
if (geteuid()) {
printf("but you'll have to do it yourself\n");
finish();
}
printf("but you'll have to do it yourself\n");
finish();
}
+ if (fast)
+ doitfast();
#ifndef DEBUG
kill(-1, SIGTERM); /* terminate everyone */
sleep(5); /* & wait while they die */
if (reboot)
#ifndef DEBUG
kill(-1, SIGTERM); /* terminate everyone */
sleep(5); /* & wait while they die */
if (reboot)
- execle(REBOOT, "reboot", 0, 0);
+ execle(REBOOT, "reboot", nosync, 0, 0);
- execle(HALT, "halt", 0, 0);
+ execle(HALT, "halt", nosync, 0, 0);
kill(1, SIGTERM); /* sync */
kill(1, SIGTERM); /* sync */
sleep(20);
#else
printf("EXTERMINATE EXTERMINATE\n");
kill(1, SIGTERM); /* sync */
kill(1, SIGTERM); /* sync */
sleep(20);
#else
printf("EXTERMINATE EXTERMINATE\n");
+ if (reboot)
+ printf("REBOOT");
+ if (halt)
+ printf(" HALT");
+ if (fast)
+ printf(" %s (without fsck's)\n", nosync);
+ else
+ printf(" %s\n", nosync);
+
fprintf(term, "System going down IMMEDIATELY\r\n");
}
fprintf(term, "System going down IMMEDIATELY\r\n");
}
+doitfast()
+{
+ FILE *fastd;
+
+ if ((fastd = fopen(fastboot, "w")) != NULL) {
+ putc('\n', fastd);
+ fclose(fastd);
+ }
+}
+