Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/sbin/init Pull up revisions 1.38-1.48 (requested by abs):
details: https://anonhg.NetBSD.org/src/rev/13f3b2a2a0ba
branches: netbsd-1-5
changeset: 492741:13f3b2a2a0ba
user: he <he%NetBSD.org@localhost>
date: Sat Feb 09 19:41:22 2002 +0000
description:
Pull up revisions 1.38-1.48 (requested by abs):
Add optional support to try to set up an MFS based /dev file
system if /dev/console is missing. Also fix PR#11847 -- handling
of EOF at altshell prompt, and convert to ANSI C code style.
diffstat:
sbin/init/init.c | 602 ++++++++++++++++++++++++------------------------------
1 files changed, 267 insertions(+), 335 deletions(-)
diffs (truncated from 1324 to 300 lines):
diff -r 476071cfc159 -r 13f3b2a2a0ba sbin/init/init.c
--- a/sbin/init/init.c Sat Feb 09 19:26:05 2002 +0000
+++ b/sbin/init/init.c Sat Feb 09 19:41:22 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.37 2000/03/19 23:21:46 soren Exp $ */
+/* $NetBSD: init.c,v 1.37.4.1 2002/02/09 19:41:22 he Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -46,7 +46,7 @@
#if 0
static char sccsid[] = "@(#)init.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: init.c,v 1.37 2000/03/19 23:21:46 soren Exp $");
+__RCSID("$NetBSD: init.c,v 1.37.4.1 2002/02/09 19:41:22 he Exp $");
#endif
#endif /* not lint */
@@ -76,11 +76,7 @@
#include <paths.h>
#include <err.h>
-#ifdef __STDC__
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#ifdef SECURE
#include <pwd.h>
@@ -97,46 +93,46 @@
#define STALL_TIMEOUT 30 /* wait N secs after warning */
#define DEATH_WATCH 10 /* wait N secs for procs to die */
-int main __P((int, char *[]));
+int main(int, char *[]);
-void handle __P((sig_t, ...));
-void delset __P((sigset_t *, ...));
+void handle(sig_t, ...);
+void delset(sigset_t *, ...);
-void stall __P((const char *, ...))
+void stall(const char *, ...)
__attribute__((__format__(__printf__,1,2)));
-void warning __P((const char *, ...))
+void warning(const char *, ...)
__attribute__((__format__(__printf__,1,2)));
-void emergency __P((const char *, ...))
+void emergency(const char *, ...)
__attribute__((__format__(__printf__,1,2)));
-void disaster __P((int));
-void badsys __P((int));
+void disaster(int);
+void badsys(int);
/*
* We really need a recursive typedef...
* The following at least guarantees that the return type of (*state_t)()
* is sufficiently wide to hold a function pointer.
*/
-typedef long (*state_func_t) __P((void));
-typedef state_func_t (*state_t) __P((void));
+typedef long (*state_func_t)(void);
+typedef state_func_t (*state_t)(void);
-state_func_t single_user __P((void));
-state_func_t runcom __P((void));
-state_func_t read_ttys __P((void));
-state_func_t multi_user __P((void));
-state_func_t clean_ttys __P((void));
-state_func_t catatonia __P((void));
-state_func_t death __P((void));
+state_func_t single_user(void);
+state_func_t runcom(void);
+state_func_t read_ttys(void);
+state_func_t multi_user(void);
+state_func_t clean_ttys(void);
+state_func_t catatonia(void);
+state_func_t death(void);
enum { AUTOBOOT, FASTBOOT } runcom_mode = AUTOBOOT;
-void transition __P((state_t));
+void transition(state_t);
#ifndef LETS_GET_SMALL
state_t requested_transition = runcom;
#else /* LETS_GET_SMALL */
state_t requested_transition = single_user;
#endif /* LETS_GET_SMALL */
-void setctty __P((char *));
+void setctty(const char *);
typedef struct init_session {
int se_index; /* index of entry in ttys file */
@@ -154,40 +150,38 @@
struct init_session *se_next;
} session_t;
-void free_session __P((session_t *));
-session_t *new_session __P((session_t *, int, struct ttyent *));
+void free_session(session_t *);
+session_t *new_session(session_t *, int, struct ttyent *);
session_t *sessions;
-char **construct_argv __P((char *));
-void start_window_system __P((session_t *));
-void collect_child __P((pid_t));
-pid_t start_getty __P((session_t *));
-void transition_handler __P((int));
-void alrm_handler __P((int));
-void setsecuritylevel __P((int));
-int getsecuritylevel __P((void));
-int setupargv __P((session_t *, struct ttyent *));
+char **construct_argv(char *);
+void start_window_system(session_t *);
+void collect_child(pid_t);
+pid_t start_getty(session_t *);
+void transition_handler(int);
+void alrm_handler(int);
+void setsecuritylevel(int);
+int getsecuritylevel(void);
+int setupargv(session_t *, struct ttyent *);
int clang;
-void clear_session_logs __P((session_t *));
+void clear_session_logs(session_t *);
-int start_session_db __P((void));
-void add_session __P((session_t *));
-void del_session __P((session_t *));
-session_t *find_session __P((pid_t));
+int start_session_db(void);
+void add_session(session_t *);
+void del_session(session_t *);
+session_t *find_session(pid_t);
DB *session_db;
-#ifdef MSDOSFS_ROOT
-static void msdosfs_root __P((void));
+#ifdef MFS_DEV_IF_NO_CONSOLE
+static int mfs_dev(void);
#endif
/*
* The mother of all processes.
*/
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char **argv)
{
struct sigaction sa;
sigset_t mask;
@@ -219,8 +213,9 @@
warn("setlogin() failed");
-#ifdef MSDOSFS_ROOT
- msdosfs_root();
+#ifdef MFS_DEV_IF_NO_CONSOLE
+ if (mfs_dev() == -1)
+ requested_transition = single_user;
#endif
#ifndef LETS_GET_SMALL
@@ -228,7 +223,7 @@
* Note that this does NOT open a file...
* Does 'init' deserve its own facility number?
*/
- openlog("init", LOG_CONS|LOG_ODELAY, LOG_AUTH);
+ openlog("init", LOG_CONS, LOG_AUTH);
#endif /* LETS_GET_SMALL */
@@ -265,22 +260,22 @@
SIGBUS, SIGXCPU, SIGXFSZ, 0);
handle(transition_handler, SIGHUP, SIGTERM, SIGTSTP, 0);
handle(alrm_handler, SIGALRM, 0);
- sigfillset(&mask);
+ (void)sigfillset(&mask);
delset(&mask, SIGABRT, SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGSYS,
- SIGXCPU, SIGXFSZ, SIGHUP, SIGTERM, SIGTSTP, SIGALRM, 0);
- sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0);
- sigemptyset(&sa.sa_mask);
+ SIGXCPU, SIGXFSZ, SIGHUP, SIGTERM, SIGTSTP, SIGALRM, 0);
+ (void)sigprocmask(SIG_SETMASK, &mask, NULL);
+ (void)sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = SIG_IGN;
- (void) sigaction(SIGTTIN, &sa, (struct sigaction *)0);
- (void) sigaction(SIGTTOU, &sa, (struct sigaction *)0);
+ (void)sigaction(SIGTTIN, &sa, NULL);
+ (void)sigaction(SIGTTOU, &sa, NULL);
/*
* Paranoia.
*/
- close(0);
- close(1);
- close(2);
+ (void)close(0);
+ (void)close(1);
+ (void)close(2);
/*
* Start the state machine.
@@ -297,34 +292,23 @@
* Associate a function with a signal handler.
*/
void
-#ifdef __STDC__
handle(sig_t handler, ...)
-#else
-handle(va_alist)
- va_dcl
-#endif
{
int sig;
struct sigaction sa;
sigset_t mask_everything;
va_list ap;
-#ifndef __STDC__
- sig_t handler;
- va_start(ap);
- handler = va_arg(ap, sig_t);
-#else
va_start(ap, handler);
-#endif
sa.sa_handler = handler;
- sigfillset(&mask_everything);
+ (void)sigfillset(&mask_everything);
while ((sig = va_arg(ap, int)) != 0) {
sa.sa_mask = mask_everything;
/* XXX SA_RESTART? */
sa.sa_flags = sig == SIGCHLD ? SA_NOCLDSTOP : 0;
- sigaction(sig, &sa, (struct sigaction *) 0);
+ (void)sigaction(sig, &sa, NULL);
}
va_end(ap);
}
@@ -333,26 +317,15 @@
* Delete a set of signals from a mask.
*/
void
-#ifdef __STDC__
delset(sigset_t *maskp, ...)
-#else
-delset(va_alist)
- va_dcl
-#endif
{
int sig;
va_list ap;
-#ifndef __STDC__
- sigset_t *maskp;
- va_start(ap);
- maskp = va_arg(ap, sigset_t *);
-#else
va_start(ap, maskp);
-#endif
while ((sig = va_arg(ap, int)) != 0)
- sigdelset(maskp, sig);
+ (void)sigdelset(maskp, sig);
va_end(ap);
}
@@ -362,26 +335,15 @@
* NB: should send a message to the session logger to avoid blocking.
*/
void
-#ifdef __STDC__
stall(const char *message, ...)
-#else
-stall(va_alist)
- va_dcl
-#endif
{
va_list ap;
-#ifndef __STDC__
- char *message;
- va_start(ap);
- message = va_arg(ap, char *);
-#else
va_start(ap, message);
-#endif
vsyslog(LOG_ALERT, message, ap);
va_end(ap);
closelog();
- sleep(STALL_TIMEOUT);
+ (void)sleep(STALL_TIMEOUT);
}
Home |
Main Index |
Thread Index |
Old Index