initial checkin

This commit is contained in:
gdr 1997-10-04 05:24:01 +00:00
parent 75e4ffde40
commit 3f66072e30
22 changed files with 5346 additions and 0 deletions

11
sbin/init/Makefile Normal file
View File

@ -0,0 +1,11 @@
# @(#)Makefile 8.1 (Berkeley) 7/19/93
PROG= init
MAN8= init.8
DPADD= ${LIBUTIL}
LDADD= -lutil -lcrypt
BINMODE=500
INSTALLFLAGS=-fschg
CFLAGS+=-DDEBUGSHELL -DSECURE
.include <bsd.prog.mk>

112
sbin/init/NOTES Normal file
View File

@ -0,0 +1,112 @@
POSIX and init:
--------------
POSIX.1 does not define 'init' but it mentions it in a few places.
B.2.2.2, p205 line 873:
This is part of the extensive 'job control' glossary entry.
This specific reference says that 'init' must by default provide
protection from job control signals to jobs it starts --
it sets SIGTSTP, SIGTTIN and SIGTTOU to SIG_IGN.
B.2.2.2, p206 line 889:
Here is a reference to 'vhangup'. It says, 'POSIX.1 does
not specify how controlling terminal access is affected by
a user logging out (that is, by a controlling process
terminating).' vhangup() is recognized as one way to handle
the problem. I'm not clear what happens in Reno; I have
the impression that when the controlling process terminates,
references to the controlling terminal are converted to
references to a 'dead' vnode. I don't know whether vhangup()
is required.
B.2.2.2, p206 line 921:
Orphaned process groups bear indirectly on this issue. A
session leader's process group is considered to be orphaned;
that is, it's immune to job control signals from the terminal.
B.2.2.2, p233 line 2055:
'Historically, the implementation-dependent process that
inherits children whose parents have terminated without
waiting on them is called "init" and has a process ID of 1.'
It goes on to note that it used to be the case that 'init'
was responsible for sending SIGHUP to the foreground process
group of a tty whose controlling process has exited, using
vhangup(). It is now the responsibility of the kernel to
do this when the controlling process calls _exit(). The
kernel is also responsible for sending SIGCONT to stopped
process groups that become orphaned. This is like old BSD
but entire process groups are signaled instead of individual
processes.
In general it appears that the kernel now automatically
takes care of orphans, relieving 'init' of any responsibility.
Specifics are listed on the _exit() page (p50).
On setsid():
-----------
It appears that neither getty nor login call setsid(), so init must
do this -- seems reasonable. B.4.3.2 p 248 implies that this is the
way that 'init' should work; it says that setsid() should be called
after forking.
Process group leaders cannot call setsid() -- another reason to
fork! Of course setsid() causes the current process to become a
process group leader, so we can only call setsid() once. Note that
the controlling terminal acquires the session leader's process
group when opened.
Controlling terminals:
---------------------
B.7.1.1.3 p276: 'POSIX.1 does not specify a mechanism by which to
allocate a controlling terminal. This is normally done by a system
utility (such as 'getty') and is considered ... outside the scope
of POSIX.1.' It goes on to say that historically the first open()
of a tty in a session sets the controlling terminal. P130 has the
full details; nothing particularly surprising.
The glossary p12 describes a 'controlling process' as the first
process in a session that acquires a controlling terminal. Access
to the terminal from the session is revoked if the controlling
process exits (see p50, in the discussion of process termination).
Design notes:
------------
your generic finite state machine
we are fascist about which signals we elect to receive,
even signals purportedly generated by hardware
handle fatal errors gracefully if possible (we reboot if we goof!!)
if we get a segmentation fault etc., print a message on the console
and spin for a while before rebooting
(this at least decreases the amount of paper consumed :-)
apply hysteresis to rapidly exiting gettys
check wait status of children we reap
don't wait for stopped children
don't use SIGCHILD, it's too expensive
but it may close windows and avoid races, sigh
look for EINTR in case we need to change state
init is responsible for utmp and wtmp maintenance (ick)
maybe now we can consider replacements? maintain them in parallel
init only removes utmp and closes out wtmp entries...
necessary states and state transitions (gleaned from the man page):
1: single user shell (with password checking?); on exit, go to 2
2: rc script: on exit 0, go to 3; on exit N (error), go to 1
3: read ttys file: on completion, go to 4
4: multi-user operation: on SIGTERM, go to 7; on SIGHUP, go to 5;
on SIGTSTP, go to 6
5: clean up mode (re-read ttys file, killing off controlling processes
on lines that are now 'off', starting them on lines newly 'on')
on completion, go to 4
6: boring mode (no new sessions); signals as in 4
7: death: send SIGHUP to all controlling processes, reap for 30 seconds,
then go to 1 (warn if not all processes died, i.e. wait blocks)
Given the -s flag, we start at state 1; otherwise state 2

296
sbin/init/init.8 Normal file
View File

@ -0,0 +1,296 @@
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Donn Seeley at Berkeley Software Design, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)init.8 8.3 (Berkeley) 4/18/94
.\"
.\" $Id: init.8,v 1.1 1997/10/04 05:23:51 gdr Exp $
.\"
.TH INIT 8 "4 October 1997" GNO "System Administration"
.SH NAME
.BR init
\- process control initialization
.SH SYNOPSIS
.BR init
.SH DESCRIPTION
The
.BR init
program
is the last stage of the boot process.
It normally runs the automatic reboot sequence as described in
.BR reboot (8),
and if this succeeds, begins multi-user operation.
If the reboot scripts fail,
.BR init
commences single user operation by giving
the super-user a shell on the console.
The
.BR init
program may be passed parameters
from the boot program to
prevent the system from going multi-user and to instead execute
a single user shell without starting the normal daemons.
The system is then quiescent for maintenance work and may
later be made to go to multi-user by exiting the
single-user shell (with ^D).
This
causes
.BR init
to run the
.BR /etc/rc
start up command file in fastboot mode (skipping disk checks).
.LP
If the
.BR console
entry in the
.BR ttys (5)
file is marked ``insecure'',
then
.BR init
will require that the superuser password be
entered before the system will start a single-user shell.
The password check is skipped if the
.BR console
is marked as ``secure''.
.LP
The kernel runs with four different levels of security.
Any superuser process can raise the security level, but only
.BR init
can lower it.
Security levels are defined as follows:
.RS
.IP \fB-1\fR
Permanently insecure mode \- always run system in level 0 mode.
.IP \fB0\fR
Insecure mode \- immutable and append-only flags may be turned off.
All devices may be read or written subject to their permissions.
.IP \fB1\fR
Secure mode \- immutable and append-only flags may not be changed;
disks for mounted filesystems,
.BR /dev/mem ,
and
.BR /dev/kmem
are read-only.
.IP \fB2\fR
Highly secure mode \- same as secure mode, plus disks are always
read-only whether mounted or not.
This level precludes tampering with filesystems by unmounting them,
but also inhibits running
.BR newfs (8)
while the system is multi-user.
.RE
.LP
Normally, the system runs in level 0 mode while single user
and in level 1 mode while multiuser.
If the level 2 mode is desired while running multiuser,
it can be set in the startup script
.BR /etc/rc
using
.BR sysctl (8).
If it is desired to run the system in level 0 mode while multiuser,
the administrator must build a kernel with the variable
.BR securelevel
defined in the file
.BR /sys/compile/MACHINE/param.c
and initialize it to -1.
.LP
In multi-user operation,
.BR init
maintains
processes for the terminal ports found in the file
.BR ttys (5).
.BR Init
reads this file, and executes the command found in the second field.
This command is usually
.BR getty (8);
.BR getty
opens and initializes the tty line
and
executes the
.BR login
program.
The
.BR login
program, when a valid user logs in,
executes a shell for that user. When this shell
dies, either because the user logged out
or an abnormal termination occurred (a signal),
the
.BR init
program wakes up, deletes the user
from the
.BR utmp (5)
file of current users and records the logout in the
.BR wtmp
file.
The cycle is
then restarted by
.BR init
executing a new
.BR getty
for the line.
.LP
Line status (on, off, secure, getty, or window information)
may be changed in the
.BR ttys
file without a reboot by sending the signal
.BR SIGHUP
to
.BR init
with the command
.B "kill -HUP 1" .
On receipt of this signal,
.BR init
re-reads the
.BR ttys
file.
When a line is turned off in
.BR ttys ,
.BR init
will send a SIGHUP signal to the controlling process
for the session associated with the line.
For any lines that were previously turned off in the
.BR ttys
file and are now on,
.BR init
executes a new
.BR getty
to enable a new login.
If the getty or window field for a line is changed,
the change takes effect at the end of the current
login session (e.g., the next time
.BR init
starts a process on the line).
If a line is commented out or deleted from
.BR ttys ,
.BR init
will not do anything at all to that line.
However, it will complain that the relationship between lines
in the
.BR ttys
file and records in the
.BR utmp
file is out of sync,
so this practice is not recommended.
.LP
.BR Init
will terminate multi-user operations and resume single-user mode
if sent a terminate TERM
signal, for example,
.BR "kill \-TERM 1" .
If there are processes outstanding that are deadlocked (because of
hardware or software failure),
.BR init
will not wait for them all to die (which might take forever), but
will time out after 30 seconds and print a warning message.
.LP
.BR Init
will cease creating new
.BR getty Ns's
and allow the system to slowly die away, if it is sent a terminal stop
TSTP signal, i.e.
.BR "kill \-TSTP 1" .
A later hangup will resume full
multi-user operations, or a terminate will start a single user shell.
This hook is used by
.BR reboot (8)
and
.BR halt (8).
.LP
.BR Init
will terminate all possible processes (again, it will not wait
for deadlocked processes) and reboot the machine if sent the interrupt
INT signal, i.e.
.BR "kill \-INT 1" .
This is useful for shutting the machine down cleanly from inside the kernel
or from X when the machines appears to be hung.
.LP
The role of
.BR init
is so critical that if it dies, the system will reboot itself
automatically.
If, at bootstrap time, the
.BR init
process cannot be located, the system will panic with the message
``panic: "init died (signal %d, exit %d)''.
.SH DIAGNOSTICS
.RS
.IP "\fIgetty repeating too quickly on port %s, sleeping\fR"
A process being started to service a line is exiting quickly
each time it is started.
This is often caused by a ringing or noisy terminal line.
.IR "Init will sleep for 10 seconds" ,
.IR "then continue trying to start the process" .
.LP
.IP "\fIsome processes would not die; ps axl advised.\fR"
A process
is hung and could not be killed when the system was shutting down.
This condition is usually caused by a process
that is stuck in a device driver because of
a persistent device error condition.
.RE
.SH FILES
.RS
.IP \fB/dev/console\fR
System console device.
.IP \fB/dev/tty*\fR
Terminal ports found in
.BR ttys .
.IP \fB/var/run/utmp\fR
Record of Current users on the system.
.IP \fB/var/log/wtmp\fR
Record of all logins and logouts.
.IP \fB/etc/ttys\fR
The terminal initialization information file.
.IP \fB/etc/rc\fR
System startup commands.
.RE
.SH SEE ALSO
.BR login (1),
.BR kill (1),
.BR sh (1),
.BR ttys (5),
.BR crash (8),
.BR getty (8),
.BR rc (8),
.BR reboot (8),
.BR halt (8),
.BR shutdown (8)
.SH HISTORY
A
.BR init
command appeared in Version 6 AT&T UNIX.
.SH BUGS
Systems without
.BR sysctl
behave as though they have security level \-1.

1422
sbin/init/init.c Normal file

File diff suppressed because it is too large Load Diff

42
sbin/init/pathnames.h Normal file
View File

@ -0,0 +1,42 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Donn Seeley at Berkeley Software Design, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)pathnames.h 8.1 (Berkeley) 6/5/93
*/
#include <paths.h>
#define _PATH_SLOGGER "/sbin/session_logger"
#define _PATH_RUNCOM "/etc/rc"

26
sbin/reboot/Makefile Normal file
View File

@ -0,0 +1,26 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
PROG= reboot
DPADD= ${LIBUTIL}
LDADD= -lutil
MAN8= reboot.8 boot_hp300.8 boot_i386.8 boot_sparc.8 boot_tahoe.8 boot_vax.8
MLINKS= reboot.8 halt.8 reboot.8 fastboot.8 reboot.8 fasthalt.8
ARCH!= uname -m
.if exists (${.CURDIR}/boot_${ARCH}.8)
MLINKS+= boot_${ARCH}.8 boot.8
.endif
LINKS= ${BINDIR}/reboot ${BINDIR}/halt ${BINDIR}/reboot ${BINDIR}/fastboot \
${BINDIR}/reboot ${BINDIR}/fasthalt
XXXBROKENafterinstall:
${MINSTALL} boot_hp300.8 ${DESTDIR}${MANDIR}8/hp300/boot.8
${MINSTALL} boot_i386.8 ${DESTDIR}${MANDIR}8/i386/boot.8
${MINSTALL} boot_sparc.8 ${DESTDIR}${MANDIR}8/sparc/boot.8
${MINSTALL} boot_tahoe.8 ${DESTDIR}${MANDIR}8/tahoe/boot.8
${MINSTALL} boot_vax.8 ${DESTDIR}${MANDIR}8/vax/boot.8
.include <bsd.man.mk>
.include <bsd.prog.mk>

117
sbin/reboot/boot.hp300.8 Normal file
View File

@ -0,0 +1,117 @@
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Systems Programming Group of the University of Utah Computer
.\" Science Department.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)boot_hp300.8 8.2 (Berkeley) 4/19/94
.\"
.Dd April 19, 1994
.Dt BOOT_HP300 8 hp300
.Os
.Sh NAME
.Nm boot
.Nd
system bootstrapping procedures
.Sh DESCRIPTION
.Sy Power fail and crash recovery.
Normally, the system will reboot itself at power-up or after crashes.
An automatic consistency check of the file systems will be performed,
and unless this fails, the system will resume multi-user operations.
.Pp
.Sy Cold starts.
On an HP300, the boot procedure uses the boot ROM to load a boot program
from an
.Tn LIF
format directory at the beginning of an attached disk.
The
.Pa /usr/mdec
directory contains a disk boot programs which should be placed in a
new pack automatically by
.Xr newfs 8
when the ``a'' partition file system on the pack is created.
.Pp
This
.Em boot
program
finds the corresponding file on the given device
.Pf ( Ar kernel
by default),
loads that file into memory,
and starts the program at the entry address specified in the program header.
.Pp
The boot program can be interrupted by typing `^C' (ctrl-C).
This will force the boot program to interactively prompt for a system to boot.
If not interrupted, it will boot from the device from which the boot
program itself was loaded.
.Pp
The file specifications used for an interactive boot are of the form:
.Pp
.Dl device(unit, minor)
.Pp
where
.Ar device
is the type of the device to be searched,
.Ar unit
is 8 * the hpib number plus the unit number of the disk or tape,
and
.Ar minor
is the disk partition or tape file number.
Normal line editing characters can be used when typing the file specification.
Currently, ``rd'' and ``sd'' are the only valid
.Ar device
specifiers.
.Pp
For example,
to boot from the `a' file system of unit 0 on HP-IB 2,
type
.Ql rd(16, 0)kernel
to the boot prompt.
For tapes, the minor device number gives a file offset.
.Pp
In an emergency, the bootstrap methods described in the paper
.%T Installing 4.3bsd on the HP300
can be used to boot from a distribution tape.
.Sh FILES
.Bl -tag -width /usr/mdec/installboot -compact
.It Pa /kernel
system code
.It Pa /usr/mdec/bootrd
.Tn LIF
format boot block
.It Pa /usr/mdec/installboot
program to install boot blocks
.El
.Sh SEE ALSO
.Xr halt 8 ,
.Xr reboot 8 ,
.Xr shutdown 8

169
sbin/reboot/boot.i386.8 Normal file
View File

@ -0,0 +1,169 @@
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software written and contributed
.\" to Berkeley by William Jolitz.
.\"
.\" Almost completely rewritten for FreeBSD 2.1 by Joerg Wunsch.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)boot_i386.8 8.2 (Berkeley) 4/19/94
.\"
.\" $Id: boot.i386.8,v 1.1 1997/10/04 05:23:54 gdr Exp $
.\"
.Dd April 19, 1994
.Dt BOOT 8 i386
.Os
.Sh NAME
.Nm boot
.Nd
system bootstrapping procedures
.Sh DESCRIPTION
.Sy Power fail and crash recovery.
Normally, the system will reboot itself at power-up or after crashes.
An automatic consistency check of the file systems will be performed,
and unless this fails, the system will resume multi-user operations.
.Pp
.Sy Cold starts.
Most 386
.Tn "PC AT"
clones attempt to boot the floppy disk drive 0 (otherwise known as
drive A:) first, and failing that, attempt to boot the hard disk
controller 1, drive 0 (otherwise known as drive C:, or drive 0x80 in
the BIOS). The automatic boot will attempt to load
.Pa /kernel
from partition
.Ql a
of either the floppy or the hard disk.
This boot may be aborted by typing any character on the keyboard
at the
.Ql Boot:
prompt. At this time, the following input will be accepted:
.Bl -tag -offset indent -width 10x
.It \&?
Give a short listing of the files in the root directory of the default
boot device, as a hint about available boot files.
.It Op ctrlr(unit,part) Op /filename Op Fl abcCdhrsv
Specify boot file and flags.
.Bl -tag -offset indent -width 10x -compact
.It ctrlr
The controller to boot from. Note that the controller is required
to have BIOS support since the BIOS services are used to load the
boot file image.
.Pp
Common controller names are:
.Bl -tag -offset indent -width "wdXX" -compact
.It wd
ST506, IDE, ESDI, RLL disks on a WD100[2367] or lookalike
controller
.It fd
5 1/4" or 3 1/2" High density floppies
.It sd
SCSI disk on any supported SCSI controller
.It cd
boot from CDROM
.It hd
Pseudo-controller, must be used to specify that unit number
1 (known to the BIOS as drive 0x81) is on a different controller
than unit number 0. This can happen for the wd vs. sd case.
.El
.It unit
The unit number of the drive on the controller being used. Either 0
or 1 for the wd and fd and most sd controllers, between 0 and 6 for
some newer sd controllers.
.It part
The partition letter inside the BSD portion of the disk. See
.Xr disklabel 8 .
By convention, only partition
.Ql a
contains a bootable image. If sliced disks are used
.Pq Dq fdisk partitions ,
only the first BSD slice can be used to boot from. The partition
letter does always refer to this slice then.
.It /filename
The pathname of the file to boot; must be inside the root directory
of the specified partition. Defaults to
.Pa /kernel .
Symbolic links are not supported (hard links are).
.It Fl abcCdhrsv
Boot flags:
.Bl -tag -offset indent -width "-CXX" -compact
.It Fl a
ask for the device to install as root file system during kernel
initialization
.It Fl b
do not automatically reboot after shutdown or crash
.It Fl c
run UserConfig to modify hardware parameters for the loaded
kernel
.It Fl C
boot from CDROM
.It Fl d
enter the DDB kernel debugger
.Pq see Xr ddb 4
before configuring any device (except the system's console)
.It Fl h
toggle serial/graphics console
.It Fl r
do not establish the root directory of the file system
hierarchy on the device where the boot file is being loaded
from
.It Fl s
boot into single-user mode; if the console is marked as
.Dq insecure
.Pq see Xr ttys 5 ,
the root password must be entered
.It Fl v
be verbose during device probing
.El
.El
.El
.Sh FILES
.Bl -tag -width /kernelxx -compact
.It Pa /kernel
system code
.\" .It Pa /boot
.\" system bootstrap
.El
.Sh SEE ALSO
.Xr ddb 4 ,
.Xr ttys 5 ,
.Xr halt 8 ,
.Xr reboot 8 ,
.Xr shutdown 8 ,
.Xr disklabel 8 .
.Sh BUGS
The disklabel format used by this version of
.Bx
is quite
different from that of other architectures.
.Pp
The boot flags are not very self-explanatory, and the alphabet has
too few characters to implement every potentially useful boot option.

89
sbin/reboot/boot.sparc.8 Normal file
View File

@ -0,0 +1,89 @@
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)boot_sparc.8 8.2 (Berkeley) 4/19/94
.\"
.Dd April 19, 1994
.Dt REBOOT 8 sparc
.Os
.Sh NAME
.Nm reboot
.Nd
.Tn UNIX
bootstrapping procedures
.Sh SYNOPSIS
.Nm reboot
.Op Fl n
.Op Fl q
.Sh DESCRIPTION
.Sy Power fail and crash recovery.
Normally, the system will reboot itself at power-up or after crashes.
An automatic consistency check of the file systems will be performed
as described in
.Xr fsck 8 .
and unless this fails, the system will resume multi-user operations.
.Pp
.Sy Cold starts
The SPARC system currently uses the SunOS bootstrap loaders.
This will be changed in a future version of the system.
The SunOS boot will attempt to load
.Pa kernel
from partition A of the boot device,
which must currently be an ``sd'' disk.
.Pp
The
.Op Fl s
flag to the SunOS boot loader will being the system up in single-user mode.
The
.Op Fl d
flag to the SunOS boot loader will bring the system up in debug mode.
Here it waits for a kernel debugger connect; see
.Xr kgdb 8 .
Other flags are currently ignored.
.Sh FILES
.Bl -tag -width /kernelxx -compact
.It Pa /kernel
system code
.It Pa /boot
system bootstrap
.El
.Sh SEE ALSO
.Xr crash 8 ,
.Xr disklabel 8 ,
.Xr fsck 8 ,
.Xr halt 8 ,
.Xr init 8 ,
.Xr rc 8 ,
.Xr shutdown 8 ,
.Xr syslogd 8
.Sh BUGS
The use of Sun disk labels, without the ability to write them,
is problematic.

152
sbin/reboot/boot.tahoe.8 Normal file
View File

@ -0,0 +1,152 @@
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)boot_tahoe.8 8.2 (Berkeley) 4/19/94
.\"
.Dd April 19, 1994
.Dt BOOT 8 tahoe
.Os
.Sh NAME
.Nm boot
.Nd
system bootstrapping procedures
.Sh DESCRIPTION
.Sy Power fail and crash recovery.
Normally, the system will reboot itself at power-up or after crashes.
An automatic consistency check of the file systems will be performed,
and unless this fails, the system will resume multi-user operations.
.Pp
.Sy Cold starts.
These are processor-type dependent.
On the
.Tn CCI
Power 6/32 and related processors,
the system will do a standard autoboot from drive 0
upon power-up or reset.
This automatic boot may be cancelled by typing a
.Ql \&#
in the first few seconds after reset.
This enters console mode; the console prompt is
.Ql >
or
.Ql \&# .
The boot flags can be set to any hexadecimal value
.Fl n
with the command
.Pp
.Bd -filled -offset indent -compact
.Li \&#> p23
.Ar n .
.Ed
.Pp
The default device may be examined or set; see the Diagnostics and Debugging
manual for the processor for details on device naming and syntax.
After setting the boot flags and/or device,
a bootstrap sequence can be initiated with
.Pp
.Dl #> fb
.Pp
A specific device or bootstrap file may be used; for example,
.Pp
.Dl \&#> \&fb xfd(1,0)
.Pp
would boot from the `a' partition on
.Tn XFD
drive 1.
.Pp
The file specifications used for the boostrap
when loaded with the
.Dq askme
flag
(register 23 set to 1 or 3)
are of the form:
.Pp
.Dl device(adaptor,controller,unit,minor)
.Pp
where
.Ar device
is the type of the device to be searched,
.Ar adaptor
is number of the
.Tn VERSAbus
(or
.Tn VMEbus )
to which the device is attached,
.Ar controller
is the unit number of the controller on that buss,
.Ar unit
is the unit number of the disk or tape,
and
.Ar minor
is the disk partition or tape file number.
Leading adaptor or controller numbers default to 0.
Normal line editing characters can be used when typing the file specification.
The following list of supported devices may vary from installation to
installation:
.Pp
.Bd -unfilled -offset indent -compact
dk SMD or ESDI disks on VDDC or SMD-E
cy tape on Ciprico Tapemaster controller
.Ed
.Pp
For example,
to boot from a file system which starts at cylinder 0
of unit 0 of an
.Tn SMD-E
disk, type
.Ql dk(0,0)kernel
to the boot prompt;
.Ql dk(2,1,0)kernel
would specify drive 1 on
.Tn SMD-E
controller 2.
.Pp
In an emergency, the bootstrap methods described in the paper
.%T "Installing and Operating 4.3 BSD-tahoe UNIX on the Tahoe"
can be used
to boot from a distribution tape.
.Sh FILES
.Bl -tag -width /kernel -compact
.It Pa /kernel
system code
.It Pa /boot
system bootstrap
.El
.Sh SEE ALSO
.Xr halt 8 ,
.Xr reboot 8 ,
.Xr shutdown 8
.Sh BUGS
The disklabel format used by some versions of the console processor
is different than the format used by
.Tn UNIX
and the bootstrap.
.Sh HISTORY

322
sbin/reboot/boot.vax.8 Normal file
View File

@ -0,0 +1,322 @@
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)boot_vax.8 8.2 (Berkeley) 4/19/94
.\"
.Dd April 19, 1994
.Dt BOOT 8 vax
.Os
.Sh NAME
.Nm boot
.Nd
system bootstrapping procedures
.Sh DESCRIPTION
.Sy Power fail and crash recovery.
Normally, the system will reboot itself at power-up or after crashes.
Provided the auto-restart is enabled on the machine front panel,
an automatic consistency check of the file systems will be performed,
and unless this fails, the system will resume multi-user operations.
.Pp
.Sy Cold starts.
These are processor-type dependent.
On an 11/780, there are two floppy files for each disk controller,
both of which cause boots from unit 0 of the root file system
of a controller located on mba0 or uba0.
One gives a single user shell, while the other invokes the multi-user
automatic reboot.
Thus these files are
.Tn HPS
and
.Tn HPM
for the single
and multi-user boot from
.Tn MASSBUS
RP06/RM03/RM05 disks,
.Tn UPS
and
.Tn UPM
for
.Tn UNIBUS
storage module controller and disks
such as the
.Tn EMULEX
SC-21
and
.Tn AMPEX
9300 pair,
.Tn RAS
and
.Tn RAM
to boot from
.Tn MSCP
controllers and disks such as the RA81,
or
.Tn HKS
and
.Tn HKM
for RK07 disks.
There is also a script for booting from the default device,
which is normally a copy of one of the standard multi-user boot scripts,
but which may be modified to perform other actions
or to boot from a different unit.
The situation on the 8600 is similar, with scripts loaded from the console RL02.
.Pp
Giving the command
.Pp
.Dl >>>BOOT HPM
.Pp
would boot the system from (e.g.) an RP06 and run the automatic consistency
check as described in
.Xr fsck 8 .
(Note that it may
be necessary to type control-P
and halt the processor
to gain the attention of the
.Tn LSI-11
before getting the >>> prompt.)
The command
.Pp
.Dl >>>BOOT ANY
.Pp
invokes a version of the boot program in a way which allows you to
specify any system as the system to be booted.
It reads from the console a device specification (see below) followed
immediately by a pathname.
.Pp
The scripts may be modified for local configuration if necessary.
The flags are placed in register 11 (as defined in
.Aq Pa sys/reboot.h ) .
The boot device is specified in register 10.
The encoding of this register is also defined in
.Aq Pa sys/reboot.h .
The current encoding has a historical basis, and is shown in the following
table:
.Pp
.Bd -unfilled -offset indent -compact
bits usage
0-7 boot device type (the device major number)
8-15 disk partition
16-19 drive unit
20-23 controller number
24-27 adaptor number (UNIBUS or MASSBUS as appropriate)
.Ed
.Pp
The adaptor number corresponds to the normal configuration on the 11/750,
and to the order in which adaptors are found on the 11/780 and 8600
(generally the same as the numbers used by
.Tn UNIX ) .
.Pp
On an 11/750, the reset button will boot from the device
selected by the front panel boot device switch. In systems
with RK07's, position B normally selects the RK07 for boot.
This will boot multi-user. To boot from RK07 with boot flags you
may specify
.Pp
.Bd -unfilled -offset indent -compact
.Li \&>>>B/ Ns Fl n No DMA0
.Ed
.Pp
where, giving a
.Ar n
of 1 causes the boot program
to ask for the name of the system to be bootstrapped,
giving a
.Ar n
of 2 causes the boot program to come up single
user, and a
.Ar n
of 3 causes both of these actions to occur.
The ``DM'' specifies RK07, the ``A'' represents the adaptor number
.Pf ( Tn UNIBUS
or
.Tn MASSBUS ) ,
and the ``0'' is the drive unit number.
Other disk types which may be used are DB
.Pq Tn MASSBUS ,
DD (TU58),
and DU
.Pf ( Tn UDA-50/RA
disk).
A non-zero disk partition can be used by adding (partition times 1000 hex)
to
.Ar n .
.Pp
The boot procedure on the Micro
.Tn VAX
II
is similar.
A switch on the back panel sets the power-up action
to autoboot or to halt.
When halted, the processor may be booted using the same syntax
as on the 11/750.
.Pp
The 11/750 boot procedure uses the boot roms to load block 0 off of
the specified device. The /usr/mdec directory contains a number
of bootstrap programs for the various disks which should be placed
in a new pack by
.Xr disklabel 8 .
Similarly, the Micro
.Tn VAX
II boot procedure loads a boot parameter block
from block 0 of the disk.
The
.Xr rdboot
.Dq bootstrap
contains the correct parameters for an
.Tn MSCP
disk such
as the RD53.
.Pp
On any processor, the
.Em boot
program
finds the corresponding file on the given device
.Pf ( Pa kernel
by default), loads that file
into memory location zero, and starts the program at the entry address
specified in the program header (after clearing off the high bit
of the specified entry address).
.Pp
The file specifications used with
.Dq BOOT ANY
or
.Dq \&B/3
are of the form:
.Pp
.Dl device(adaptor,controller,unit,minor)
.Pp
where
.Ar device
is the type of the device to be searched,
.Ar adaptor
is the
.Tn UNIBUS
or
.Tn MASSBUS
number of the adaptor to which the device is attached,
.Ar controller
is the unit number of the controller or
.Tn MASSBUS
tape formatter on that adaptor,
.Ar unit
is the unit number of the disk or transport slave unit of the tape,
and
.Ar minor
is the disk partition or tape file number.
Leading adaptor or controller numbers default to 0.
Normal line editing characters can be used when typing the file specification.
The following list of supported devices may vary from installation to
installation:
.Pp
.Bd -unfilled -offset indent -compact
hp MASSBUS disk drive
up UNIBUS storage module drive
ht TE16,TU45,TU77 on MASSBUS
kra storage module on a KDB50
mt TU78 on MASSBUS
hk RK07 on UNIBUS
ra storage module on a MSCP-compatible UNIBUS controller
rb storage module on a 730 IDC
rl RL02 on UNIBUS
tm TM11 emulation tape drives on UNIBUS
tms TMSCP-compatible tape
ts TS11 on UNIBUS
ut UNIBUS TU45 emulator
.Ed
.Pp
For example,
to boot from a file system which starts at cylinder 0
of unit 0 of a
.Tn MASSBUS
disk, type
.Ql hp(0,0)kernel
to the boot prompt;
.Ql hp(2,0,1,0)kernel
would specify drive 1 on
.Tn MASSBUS
adaptor 2;
.Ql up(0,0)kernel
would specify a
.Tn UNIBUS
drive,
.Ql hk(0,0)kernel
would specify
an RK07 disk drive,
.Ql ra(1,0,0,0)kernel
would specify a
.Tn UDA50
disk drive on a second
.Tn UNIBUS ,
and
.Ql rb(0,0)kernel
would specify a
disk on a 730
.Tn IDC .
For tapes, the minor device number gives a file offset;
.Ql mt(1,2,3,4)
would specify the fifth file on slave 3 of the formatter
at
.Ql drive
2 on mba 1.
.Pp
On an 11/750 with patchable control store,
microcode patches will be installed by
.Em boot
if the file
.Pa psc750.bin
exists in the root of the filesystem from which the system is booted.
.Pp
In an emergency, the bootstrap methods described in the paper
.%T Installing and Operating 4.3bsd
can be used to boot from a distribution tape.
.Sh FILES
.Bl -tag -width /usr/mdec/xxboot -compact
.It Pa /kernel
system code
.It Pa /boot
system bootstrap
.It Pa /usr/mdec/xxboot
sector-0 boot block for 750, xx is disk type
.It Pa /usr/mdec/bootxx
second-stage boot for 750, xx is disk type
.It Pa /pcs750.bin
microcode patch file on 750
.El
.Sh SEE ALSO
.Xr arff 8 ,
.Xr halt 8 ,
.Xr reboot 8 ,
.Xr shutdown 8
.Sh HISTORY
The
.Nm
command appeared in
.Bx 4.0 .

97
sbin/reboot/reboot.8 Normal file
View File

@ -0,0 +1,97 @@
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)reboot.8 8.1 (Berkeley) 6/9/93
.\"
.TH REBOOT 8 "4 October 1997" GNO "System Administration"
.SH NAME
.BR reboot ,
.BR halt
\- stopping and restarting the system
.SH SYNOPSIS
.BR "halt -nq"
.br
.BR "reboot -nq"
.br
.BR "fasthalt -nq"
.br
.BR "fastboot -nq"
.SH DESCRIPTION
The
.BR halt
and
.BR reboot
utilities flush the file system cache to disk, send all running processes
a SIGTERM (and subsequently a SIGKILL) and, respectively, halt or restart
the system.
The action is logged, including entering a shutdown record into the login
accounting file.
.LP
The options are as follows:
.RS
.IP \fBn\fR
If the
.BR n
option is specified,
the file system cache is not flushed.
This option should probably not be used.
.IP \fBq\fR
If the
.B q
option is specified,
the system is halted or restarted quickly and ungracefully, and only
the flushing of the file system cache is performed.
This option should probably not be used.
.RE
.LP
The
.BR fasthalt
and
.BR fastboot
utilities are nothing more than aliases for the
.BR halt
and
.BR reboot
utilities.
.LP
Normally, the
.BR shutdown (8)
utility is used when the system needs to be halted or restarted, giving
users advance warning of their impending doom.
.SH SEE ALSO
.BR utmp (5),
.BR boot (8),
.BR shutdown (8),
.BR sync (8)
.SH HISTORY
A
.BR reboot
command appeared in Version 6 AT&T UNIX.

204
sbin/reboot/reboot.c Normal file
View File

@ -0,0 +1,204 @@
/*
* Copyright (c) 1980, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1980, 1986, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)reboot.c 8.1 (Berkeley) 6/5/93";
#endif /* not lint */
#include <sys/reboot.h>
#include <signal.h>
#include <pwd.h>
#include <errno.h>
#include <syslog.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void err __P((const char *fmt, ...));
void usage __P((void));
int dohalt;
int
main(argc, argv)
int argc;
char *argv[];
{
register int i;
struct passwd *pw;
int ch, howto, lflag, nflag, qflag, sverrno;
char *p, *user;
if (strstr((p = rindex(*argv, '/')) ? p + 1 : *argv, "halt")) {
dohalt = 1;
howto = RB_HALT;
} else
howto = 0;
lflag = nflag = qflag = 0;
while ((ch = getopt(argc, argv, "lnq")) != EOF)
switch(ch) {
case 'l': /* Undocumented; used by shutdown. */
lflag = 1;
break;
case 'n':
nflag = 1;
howto |= RB_NOSYNC;
break;
case 'q':
qflag = 1;
break;
case '?':
default:
usage();
}
argc -= optind;
argv += optind;
if (geteuid())
err("%s", strerror(EPERM));
if (qflag) {
reboot(howto);
err("%s", strerror(errno));
}
/* Log the reboot. */
if (!lflag) {
if ((user = getlogin()) == NULL)
user = (pw = getpwuid(getuid())) ?
pw->pw_name : "???";
if (dohalt) {
openlog("halt", 0, LOG_AUTH | LOG_CONS);
syslog(LOG_CRIT, "halted by %s", user);
} else {
openlog("reboot", 0, LOG_AUTH | LOG_CONS);
syslog(LOG_CRIT, "rebooted by %s", user);
}
}
logwtmp("~", "shutdown", "");
/*
* Do a sync early on, so disks start transfers while we're off
* killing processes. Don't worry about writes done before the
* processes die, the reboot system call syncs the disks.
*/
if (!nflag)
sync();
/* Just stop init -- if we fail, we'll restart it. */
if (kill(1, SIGTSTP) == -1)
err("SIGTSTP init: %s", strerror(errno));
/* Ignore the SIGHUP we get when our parent shell dies. */
(void)signal(SIGHUP, SIG_IGN);
/* Send a SIGTERM first, a chance to save the buffers. */
if (kill(-1, SIGTERM) == -1)
err("SIGTERM processes: %s", strerror(errno));
/*
* After the processes receive the signal, start the rest of the
* buffers on their way. Wait 5 seconds between the SIGTERM and
* the SIGKILL to give everybody a chance.
*/
sleep(2);
if (!nflag)
sync();
sleep(3);
for (i = 1;; ++i) {
if (kill(-1, SIGKILL) == -1) {
if (errno == ESRCH)
break;
goto restart;
}
if (i > 5) {
(void)fprintf(stderr,
"WARNING: some process(es) wouldn't die\n");
break;
}
(void)sleep(2 * i);
}
reboot(howto);
/* FALLTHROUGH */
restart:
sverrno = errno;
err("%s%s", kill(1, SIGHUP) == -1 ? "(can't restart init): " : "",
strerror(sverrno));
/* NOTREACHED */
}
void
usage()
{
(void)fprintf(stderr, "usage: %s [-nq]\n", dohalt ? "halt" : "reboot");
exit(1);
}
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
void
#if __STDC__
err(const char *fmt, ...)
#else
err(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)fprintf(stderr, "%s: ", dohalt ? "halt" : "reboot");
(void)vfprintf(stderr, fmt, ap);
va_end(ap);
(void)fprintf(stderr, "\n");
exit(1);
/* NOTREACHED */
}

9
sbin/shutdown/Makefile Normal file
View File

@ -0,0 +1,9 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
PROG= shutdown
MAN8= shutdown.8