Home | History | Annotate | only in /src/sbin/init
History log of /src/sbin/init
RevisionDateAuthorComments
 1.41 03-Jun-2023  lukem bsd.own.mk: rename GCC_NO_* to CC_WNO_*

Rename compiler-warning-disable variables from
GCC_NO_warning
to
CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.40 13-Oct-2019  mrg introduce some common variables for use in GCC warning disables:

GCC_NO_FORMAT_TRUNCATION -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints. many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
 1.39 15-Jul-2013  khorben branches: 1.39.28;
Let init be built easily with the CHROOT capability enabled.

This allows the ramdisk used in the incoming support for full-disk encryption to contain crunched binaries (much like sysinst) while booting a regular system (unlike sysinst).
 1.38 11-Apr-2009  lukem branches: 1.38.6; 1.38.12;
Enable WARNS=4 by default except for:
dump dump_lfs fsck_ffs fsck_lfs fsdb mount_smbfs
newfs_ext2fs newfs_lfs resize_lfs setkey
 1.37 04-Feb-2007  christos branches: 1.37.12; 1.37.22;
warns=4
 1.36 18-Apr-2006  salo Add support for running multi-user in a chroot() environment.

How it works:

- after successful execution of /etc/rc, check the value of "init.root"
sysctl node, if it's different than "/", chroot() into its value and run
/etc/rc inside the chroot(),

- in single-user, return back to the original / file system.

Allows running with / file system on e.g., cgd(4), vnd(4) or ccd(4) volumes.

Idea first discussed with Matt Thomas, implemented by Jachym Holecek <freza
(at) liberouter.org> with some nitpicks by me. Successfully used by me for
almost a year with / on a cgd(4) volume (for more information about the setup
check ftp://ftp.NetBSD.org/pub/NetBSD/misc/salo/init-chroot/ ).
 1.35 13-Jan-2005  lukem Revert previous revert; we don't need RESCUEDIR handling here now
<bsd.prog.mk> has it.
 1.34 10-Jan-2005  lukem Revert previous; init(8) still needs special case handling for RESCUEDIR
otherwise the path to mount_mfs(8) and the standard $PATH will be wrong...
 1.33 19-Aug-2004  christos Remove RESCUEDIR hack; it will be done centrally.
 1.32 26-May-2003  lukem If RESCUEDIR is defined, use that as an alternate path to sh and mount_mfs,
and prepend RESCUEDIR to the default PATH.
(This replaces my _PATH_ALTSHELL mods from rev 1.52 of init.c)
 1.31 24-Aug-2002  lukem if RESCUEDIR is defined, use ${RESCUEDIR}/sh as _PATH_ALTSHELL
 1.30 24-Aug-2002  lukem now that we have working rescue tools, there's no need to force
LDSTATIC=-static for init(8) on people who want LDSTATIC=""
 1.29 02-Aug-2002  christos fix typos that prevented us from cleaning utmpx. Noted by wiz
 1.28 27-Jul-2002  christos add utmpx/wtmpx processing support.
 1.27 03-Feb-2002  lukem .ifdef SMALLPROG, compile without ALTSHELL and SECURE support
 1.26 21-Jan-2002  abs Rename MSDOSFS_ROOT to MFS_DEV_IF_NO_CONSOLE, and rework:
- Always attempt mfs dev if missing /dev/console
- Save and run both MAKEDEV and MAKEDEV.local
- After creating the mfs dev, mknod() and freopen() /dev/console.
- If MAKEDEV is missing do not fail out early, but still create the mfs,
/dev/console.
- If we hit any errors fail out to single user.
This change _only_ affects systems booting without /dev/console.
 1.25 28-Dec-2001  lukem * Add user-controlled mk.conf variables
- SHLIBDIR Location to install shared libraries if ${USE_SHLIBDIR}
is "yes". Defaults to "/usr/lib".

- USE_SHLIBDIR If "yes", install shared libraries in ${SHLIBDIR}
instead of ${LIBDIR}. Defaults to "no".
Sets ${_LIBSODIR} to the appropriate value.
This may be set by individual Makefiles as well.

- SHLINKDIR Location of shared linker. Defaults to "/usr/libexec".
If != "/usr/libexec", change the dynamic-linker
encoded in shared programs

* Set USE_SHLIBDIR for libraries used by /bin and /sbin:
libc libcrypt libcrypto libedit libipsec libkvm libm libmi387
libtermcap libutil libz

* If ${_LIBSODIR} != ${LIBDIR}, add symlinks from ${LIBDIR}/${LIB}.so*
to ${_LIBSODIR}/${LIB}.so* for compatibility.

* Always install /sbin/init statically (for now)


The net effect of these changes depends on how the variables are set:

1.) If nothing is set or changed, there is no change from the
current behaviour:
- Static /bin, /sbin, and bits of /usr/*
- Dynamic rest
- Shared linker is /usr/libexec/ld*so

2.) If the following make variables are set:
LDSTATIC=
SHLINKDIR=/lib
SHLIBDIR=/lib
Then the behaviour becomes:
- Dynamic tools
- .so libraries used by /bin and /sbin are installed to /lib,
with symlinks from /usr/lib/lib*so to -> /lib/lib*so
where appropriate
- Shared linker is /lib/ld*so

3.) As per 2.), but add the following variable:
USE_SHLIBDIR=yes
This forces all .so's to be instaleld in /lib (with compat
symlinks), not just those tagged by their Makefiles to be.
Again, compat symlinks are installed
 1.24 18-Oct-2000  simonb Remove INSTALLFLAGS=-fschg, as per change to usr.bin/ssh/ssh/Makefile.
 1.23 19-Mar-2000  soren branches: 1.23.4;
The mode 0544 workaround has not been necessary since the first BSDi import.
 1.22 11-Oct-1997  mycroft Make these executables world-readable.
 1.21 10-Oct-1997  christos CFLAGS->CPPFLAGS
 1.20 15-Sep-1997  lukem define WARNS?=1 for all of sbin/*
 1.19 30-Jul-1997  christos Support root on msdos filesystems by creating an mfs on /dev and running
MAKEDEV all to create the devices. Idea by Chris Demetriou.
 1.18 19-Jul-1997  perry add WARN=1
 1.17 19-Jul-1997  perry rename DEBUGSHELL to ALTSHELL
 1.16 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.15 22-Dec-1994  cgd specify man pages the new way.
 1.14 11-Jun-1994  mycroft Fix up RCS ids.
 1.13 10-Jun-1994  pk Update to 4.4-lite (basically some copyright changes) + local changes.
 1.12 07-Oct-1993  cgd always use libcrypt
 1.11 07-Aug-1993  cgd merge in changes from netbsd-0-9-ALPHA2
 1.10 01-Aug-1993  mycroft Add RCS identifiers.
 1.9 08-Jul-1993  cgd branches: 1.9.2;
get rid of the bogus changes i made to init. note that /etc/ttys
*must* have an entry for "console", though it should be "off",
prolly.
 1.8 18-Jun-1993  cgd a couple of local mods; always ask for shell in single user, use -lcrypt,
use root's shell rather that /bin/sh when going to single-user, etc.
 1.7 18-Jun-1993  cgd incorporate bsdi's version of init; this is their version, w/no local changes
other than adding Id strings as appropriate
 1.6 10-Jun-1993  cgd add preliminary support for devfs (e.g. MOUNT_DEVFS #define, etc.)
 1.5 26-Apr-1993  cgd changed to use new libcrypt scheme.
 1.4 23-Mar-1993  cgd added secure init patch
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.2.1 30-Jul-1993  cgd get rid of -DDEBUGSHELL
 1.23.4.2 13-Feb-2002  he Pull up revision 1.26 (requested by abs):
Add support to try to set up an MFS based /dev file system if
/dev/console is missing.
Here: enable recently pulled up code to init.c.
 1.23.4.1 18-Oct-2000  tv Pull up 1.24 [simonb]:
Remove INSTALLFLAGS=-fschg.
 1.37.22.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.37.12.1 29-Mar-2008  mjf - etc/devfsd.conf: Add some rules to give nodes like /dev/tty and
/dev/null better default modes, i.e. 0666.

- sbin/init: Run devfsd -s before going to multiuser.

- sys/arch: Provide arm32, i386, sparc with a mem_init() function to request
device nodes for /dev/null, /dev/zero, etc.

- sys/dev: Convert rnd, wd, agp, raid, cd, sd, wsdisplay, wskbd, wsmouse,
wsmux, tty, bpf, swap to devfs New World Order.

- sys/fs/devfs: Make the visibility attribute of device nodes configurable.
Also provide a function to mount a devfs on boot.

- sys/kern: Add a new boot flag, -n. This disables devfs support. Unless
the -n flag is specified the kernel will mount a devfs file
system on boot.
 1.38.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.39.28.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3 18-Apr-2006  salo Add support for running multi-user in a chroot() environment.

How it works:

- after successful execution of /etc/rc, check the value of "init.root"
sysctl node, if it's different than "/", chroot() into its value and run
/etc/rc inside the chroot(),

- in single-user, return back to the original / file system.

Allows running with / file system on e.g., cgd(4), vnd(4) or ccd(4) volumes.

Idea first discussed with Matt Thomas, implemented by Jachym Holecek <freza
(at) liberouter.org> with some nitpicks by me. Successfully used by me for
almost a year with / on a cgd(4) volume (for more information about the setup
check ftp://ftp.NetBSD.org/pub/NetBSD/misc/salo/init-chroot/ ).
 1.2 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.1 10-Jun-1994  pk branches: 1.1.1;
Update to 4.4-lite (basically some copyright changes) + local changes.
 1.1.1.1 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.2 10-Jun-1994  mycroft Clean up deleted files.
 1.1 18-Jun-1993  cgd incorporate bsdi's version of init; this is their version, w/no local changes
other than adding Id strings as appropriate
 1.62 01-Sep-2019  wiz Remove superfluous Pp.
 1.61 01-Sep-2019  sevan grammar
 1.60 11-Sep-2016  sevan branches: 1.60.14; 1.60.16;
init first appeared in V1 UNIX
http://minnie.tuhs.org/cgi-bin/utree.pl?file=V1/init.s
Replace contraction.
Bump date.
 1.59 02-Oct-2013  apb The "-s" flag is passed to init by the kernel, not by the boot loader.
 1.58 02-Oct-2013  apb Document that the kernel may try several paths for init.

XXX: This should be in the kernel documentation, not in the init(8) man page.
 1.57 18-May-2009  wiz branches: 1.57.6; 1.57.12;
Sort SEE ALSO.
 1.56 08-Apr-2009  joerg Remove physical markup.
 1.55 11-Nov-2008  wiz branches: 1.55.2;
Add backslash (minus is "\-").
 1.54 11-Nov-2008  reed Add some details about init's role with securelevel.
Add references to other manual pages for more details.
 1.53 21-Oct-2008  lukem branches: 1.53.2;
xref rescue(8)
 1.52 09-Feb-2008  dholland branches: 1.52.4;
Mention utmpx/wtmpx as well as utmp/wtmp. Suggested by the patches in
PR bin/36551 by Greg A. Woods. Also, while I'm here, fix a miscapitalized
word.
 1.51 15-Dec-2007  snj Sort xrefs.
 1.50 15-Dec-2007  apb Update for the fact that MAKEDEV uses either tmpfs or mfs.
 1.49 09-Dec-2007  apb * init calls "MAKEDEV -MM init", not "MAKEDEV -M init"
* s/filesystem/file system/
* one typo and one markup fix
* bump date
 1.48 24-Mar-2007  hubertf branches: 1.48.4; 1.48.6;
backout previous.
 1.47 23-Mar-2007  hubertf Call the pivot root by it's name.
 1.46 03-Mar-2007  dsl Update info about running MAKEDEV to note that MAKEDEV itself now creates
the mfs filesystem.
 1.45 03-Mar-2007  apb Remove all reference to MAKEDEV.subr. Add a reference to MAKEDEV.local.
 1.44 02-Mar-2007  wiz Bump date for previous.
 1.43 01-Mar-2007  apb When creating /dev in a memory file system, include all three of
MAKEDEV, MAKEDEV.subr and MAKEDEV.local in the set of files that are
copied if they exist.

Now booting an INSTALL kernel with an embedded ramdisk correctly creates
/dev again, fixing a problem introduced when MAKEDEV.subr was created a
few days ago.
 1.42 15-Sep-2006  elad Remove securelevel-related text from init(8) man-page as they're now in
secmodel_bsd44(9).

I'm not sure I agree with the BUGS section, but for now move it to
secmodel_bsd44(9) as well.
 1.41 15-Sep-2006  wiz Bump date for previous.
 1.40 15-Sep-2006  elad Remove sentence no longer true.
 1.39 23-Apr-2006  wiz New sentence, new line.
 1.38 18-Apr-2006  salo Add support for running multi-user in a chroot() environment.

How it works:

- after successful execution of /etc/rc, check the value of "init.root"
sysctl node, if it's different than "/", chroot() into its value and run
/etc/rc inside the chroot(),

- in single-user, return back to the original / file system.

Allows running with / file system on e.g., cgd(4), vnd(4) or ccd(4) volumes.

Idea first discussed with Matt Thomas, implemented by Jachym Holecek <freza
(at) liberouter.org> with some nitpicks by me. Successfully used by me for
almost a year with / on a cgd(4) volume (for more information about the setup
check ftp://ftp.NetBSD.org/pub/NetBSD/misc/salo/init-chroot/ ).
 1.37 13-Nov-2005  elad The securelevel does not affect whether Veriexec's tables can be modified;
this is now controlled by Veriexec's strict level.
 1.36 01-Jul-2005  wiz Mark up more paths with .Pa, and
break a line (<=80 chars per line).
 1.35 30-Jun-2005  snj Use more macros and sort xrefs.
 1.34 30-Jun-2005  christos Patch from Jeremy Reed to describe how MFS /dev works. Thanks!
 1.33 20-Jun-2005  peter Change all .Xr config 8 to .Xr config 1, following the recent move of
config from usr.sbin -> usr.bin.

Reviewed by wiz.
 1.32 01-Apr-2005  abs Fix typo 'and the go' -> 'and then go'
 1.31 19-Feb-2004  lukem veriexec can't be changed at securelevel 1
 1.30 12-Oct-2003  wiz Bump date for previous; new sentence, new line; use more macros; fix a typo.
 1.29 12-Oct-2003  tls Add an explanation of the fundamental purpose of the "security level"
mechanism and attempt to explain how to use it effectively.
 1.28 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.27 14-May-2003  wiz setup -> set up.
 1.26 25-Feb-2003  wiz .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
 1.25 01-Oct-2002  wiz New sentence, new line. By Robert Elz with minimal fixes.
 1.24 16-Nov-2001  wiz Sort sections and SEE ALSO.
 1.23 05-Jun-2001  wiz Drop arguments of .Os.
 1.22 29-Apr-2000  lukem document the conditions for /etc/rc to be called with "autoboot"
 1.21 26-Apr-2000  lukem Using the `NOTES' file and source code as a reference, attempt to more
accurately explain the operation of init(8)'s state machine.
 1.20 19-Mar-2000  soren Remove reference to crash(8).
 1.19 28-Sep-1999  bouyer Note that proc.<pid>.corename susctl node is read-only at securelevel >= 2.
 1.18 14-Nov-1998  tls branches: 1.18.4;
document ipf change at securelevel >= 2
 1.17 14-Nov-1998  tls reflect new securelevel 2 changes
 1.16 17-Jul-1998  perry fix a typo, pointed out in pr-5785 from Mason Loring Bliss
 1.15 25-May-1998  msaitoh fix a bug.
 1.14 29-Apr-1998  fair fix a bad .Xr
 1.13 29-Apr-1998  fair fix bad .Xr references
 1.12 11-Oct-1997  enami Sort items of section 8 in SEE ALSO list alphabetical order.
 1.11 15-Sep-1997  lukem cleanup use of .Nm
 1.10 19-Jul-1997  perry in NetBSD, setting the clock back is inhibited in securelevel 2, not s-lev 1
 1.9 19-Jul-1997  perry (mostly) merge lite-2 changes (except for some silly ones.)
 1.8 30-Jun-1997  phil Better specify which flags can't be change at level 1. (PR 3299)
Make all "multiuser" be "multi-user" to conform with other "multi-user"
usage.
 1.7 17-Jan-1997  perry close pr-2717 from Manuel Bouyer <bouyer@lix.polytechnique.fr>
Replaces reference to hand patching securelevel kernel variable
with reference to options INSECURE.
 1.6 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.5 23-Sep-1994  mycroft Changes to match POSIXication of kill(1).
 1.4 11-Jun-1994  mycroft Fix up RCS ids.
 1.3 10-Jun-1994  pk Update to 4.4-lite (basically some copyright changes) + local changes.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 18-Jun-1993  cgd branches: 1.1.1;
incorporate bsdi's version of init; this is their version, w/no local changes
other than adding Id strings as appropriate
 1.1.1.2 19-Jul-1997  perry imported from 44lite2
 1.1.1.1 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.18.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.48.6.2 18-Feb-2008  mjf Sync with HEAD.
 1.48.6.1 27-Dec-2007  mjf Sync with HEAD.
 1.48.4.2 23-Mar-2008  matt sync with HEAD
 1.48.4.1 09-Jan-2008  matt sync with HEAD
 1.52.4.1 17-Jan-2009  mjf Sync with HEAD.
 1.53.2.2 12-Nov-2008  snj Pull up following revision(s) (requested by reed in ticket #46):
sbin/init/init.8: revision 1.55
Add backslash (minus is "\-").
 1.53.2.1 12-Nov-2008  snj Pull up following revision(s) (requested by reed in ticket #46):
sbin/init/init.8: revision 1.54
Add some details about init's role with securelevel.
Add references to other manual pages for more details.
 1.55.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.57.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.57.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.60.16.1 05-Sep-2019  martin Pull up following revision(s) (requested by sevan in ticket #174):
lib/libc/sys/chmod.2: revision 1.48
lib/libc/sys/stat.2: revision 1.59
lib/libc/sys/unlink.2: revision 1.30
lib/libc/sys/lseek.2: revision 1.25
lib/libc/sys/getuid.2: revision 1.18
lib/libc/sys/chown.2: revision 1.37
lib/libm/man/exp.3: revision 1.32
lib/libm/man/log.3: revision 1.7
lib/libc/sys/open.2: revision 1.60
lib/libc/stdio/fopen.3: revision 1.36
lib/libc/stdio/putc.3: revision 1.14
lib/libc/sys/mount.2: revision 1.51
share/man/man9/copy.9: revision 1.22
share/man/man9/uiomove.9: revision 1.20
lib/libc/sys/setuid.2: revision 1.23
lib/libc/sys/close.2: revision 1.18
sbin/init/init.8: revision 1.61
lib/libc/sys/write.2: revision 1.36
lib/libc/sys/read.2: revision 1.39
sbin/init/init.8: revision 1.62
lib/libc/sys/wait.2: revision 1.40
usr.bin/tty/tty.1: revision 1.10
lib/libc/sys/link.2: revision 1.33
usr.bin/du/du.1: revision 1.24
lib/libc/stdlib/exit.3: revision 1.17
usr.bin/su/su.1: revision 1.53
usr.bin/mail/mail.1: revision 1.66
lib/libc/sys/fork.2: revision 1.25
usr.bin/su/su.1: revision 1.54
usr.bin/mail/mail.1: revision 1.67
lib/libm/man/sin.3: revision 1.15
share/man/man9/intro.9: revision 1.26
share/man/man5/utmp.5: revision 1.17
lib/libc/compat-43/creat.3: revision 1.17
lib/libc/time/ctime.3: revision 1.61
lib/libcompat/4.1/stty.3: revision 1.10
usr.bin/dc/dc.1: revision 1.3
lib/libm/man/cos.3: revision 1.17
lib/libc/sys/chdir.2: revision 1.23
lib/libc/gen/exec.3: revision 1.30
lib/libc/gen/exec.3: revision 1.31
games/bcd/bcd.6: revision 1.18
games/bcd/bcd.6: revision 1.19
usr.bin/write/write.1: revision 1.7
usr.bin/wc/wc.1: revision 1.18
usr.bin/pr/pr.1: revision 1.24
usr.bin/who/who.1: revision 1.25
lib/libc/sys/mkdir.2: revision 1.30
lib/libc/stdio/getc.3: revision 1.13
usr.bin/sort/sort.1: revision 1.40
usr.bin/mesg/mesg.1: revision 1.11
share/man/man5/passwd.5: revision 1.34
sort was there since v1
https://www.bell-labs.com/usr/dmr/www/man61.pdf

dc was in v1
https://www.bell-labs.com/usr/dmr/www/man12.pdf

du was in v1
https://www.bell-labs.com/usr/dmr/www/man12.pdf

mail was in v1
https://www.bell-labs.com/usr/dmr/www/man12.pdf

mesg was in v1
https://www.bell-labs.com/usr/dmr/www/man12.pdf

Document history
https://www.bell-labs.com/usr/dmr/www/man13.pdf

su was in v1
https://www.bell-labs.com/usr/dmr/www/man13.pdf

Document history
https://www.bell-labs.com/usr/dmr/www/man13.pdf

Document history
https://www.bell-labs.com/usr/dmr/www/man14.pdf
Update URL

write was in v1
https://www.bell-labs.com/usr/dmr/www/man14.pdf
grammar

passwd(5) was in v1
https://www.bell-labs.com/usr/dmr/www/man51.pdf

utmp(5) was present in v1
https://www.bell-labs.com/usr/dmr/www/man51.pdf

Earliest version of wtmp I could find was in v3
https://minnie.tuhs.org/cgi-bin/utree.pl?file=V3/man/man5/wtmp.5

Document history of chdir(2)
https://www.bell-labs.com/usr/dmr/www/man21.pdf

Document history of chmod(2)
https://www.bell-labs.com/usr/dmr/www/man21.pdf

Document history of chown(2)
https://www.bell-labs.com/usr/dmr/www/man21.pdf

Document history
https://www.bell-labs.com/usr/dmr/www/man21.pdf

create was present in v1
https://www.bell-labs.com/usr/dmr/www/man21.pdf

Document history of exec()
Move statement on execlpe() & execvpe() to HISTORY section.

Document history
https://www.bell-labs.com/usr/dmr/www/man21.pdf

fork was present in v1
https://www.bell-labs.com/usr/dmr/www/man21.pdf
stat() was present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

document history of fstat()
https://www.bell-labs.com/usr/dmr/www/man21.pdf

getuid was present in v1
https://www.bell-labs.com/usr/dmr/www/man21.pdf

Document history
https://www.bell-labs.com/usr/dmr/www/man21.pdf

Document history
https://www.bell-labs.com/usr/dmr/www/man21.pdf

stty & gtty were around since v1
https://www.bell-labs.com/usr/dmr/www/man21.pdf
https://www.bell-labs.com/usr/dmr/www/man22.pdf

mount & umount were present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

Open was present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

read was present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

seek was present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

setuid was in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

unlink was presen in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

wait was present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

write was present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

start documenting history
exp was present in v1
https://www.bell-labs.com/usr/dmr/www/man31.pdf

Start documenting history
https://www.bell-labs.com/usr/dmr/www/man31.pdf

Start documenting history
https://www.bell-labs.com/usr/dmr/www/man31.pdf

log appeared in v1
https://www.bell-labs.com/usr/dmr/www/man31.pdf

putc & putw were in v1
https://www.bell-labs.com/usr/dmr/www/man31.pdf

putchar was in v4
https://minie.tuhs.org/cgi-bin/utree.pl?file=V4/man/man3/putchr.3

Start documenting history
https://www.bell-labs.com/usr/dmr/www/man31.pdf

Document history.
https://www.bell-labs.com/usr/dmr/www/man11.pdf
Between v1 & v6 UNIX, bcd was rewritten in C, but I don't know if which
version,
hence I've skipped mentioning it.
End sentence with a dot.
Remove superfluous Pp.
Remove superfluous Pp.
Remove superfluous Ns.
Remove superfluous Pp.
fetch(9) -> ufetch(9)
fetch(9) -> ufetch(9). Remove superfluous Pp.
fetch(9) -> ufetch(9). Remove reference to unimplemented ppi(9).
 1.60.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.109 11-Oct-2021  jmcneill Allow getty to exit quickly a few times before deciding that it is exiting
too quickly. Based on a FreeBSD change from 1994.
 1.108 22-Jun-2020  msaitoh s/successfuly/successfully/ in comment. No functional change.
 1.107 14-Oct-2015  christos these are syslog-like
 1.106 16-Jun-2015  christos fix error messages containing \n
 1.105 09-Nov-2012  msaitoh Add missing free() in error path.
 1.104 04-Nov-2012  christos include the needed headers
 1.103 20-Mar-2012  matt branches: 1.103.2;
Convert to C89 function definitions
 1.102 28-Aug-2011  christos branches: 1.102.2; 1.102.4;
make it compile with SMALLPROG
 1.101 27-Aug-2011  joerg Be more static
 1.100 29-Dec-2009  elad Keep an internal variable indicating whether securelevel is present, and
don't blindly try to get/set it. Prevents error messages that don't make
sense if securelevel isn't supported by the kernel.
 1.99 22-Nov-2009  mbalmer s/the the/the/
 1.98 12-Apr-2009  apb If MAKEDEV exits non-zero, but was nevertheless able to create
/dev/console, then have init(8) just print a warning instead of
exiting.
 1.97 18-Jan-2009  lukem branches: 1.97.2;
fix -Wsign-compare issues
 1.96 20-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)
 1.95 18-Mar-2008  christos branches: 1.95.4;
un-bitrot #if 0 testing code.
 1.94 09-Dec-2007  apb branches: 1.94.4; 1.94.6;
No need to pass "-ppax" to MAKEDEV now that MAKEDEV internally defaults
to using pax.
 1.93 21-Mar-2007  dyoung branches: 1.93.4; 1.93.6;
KNF.
 1.92 11-Mar-2007  apb Adapt to the new MAKEDEV interpretation of -M by passing -MM.

Also pass "-ppax" in an attempt to get improved performance,
but this doesn't really work in the typical case, because the
install ramdisk image contains a version of pax(1) that doesn't
support the -M flag. (MAKEDEV detects the failure and falls back
to using mknod(8) as usual.)
 1.91 02-Mar-2007  dsl Instead of creating the mfs /dev here, get MAKEDEV to do it.
Removes a load of code that is easier done as a script.
Whenever init exits, use a different error number. Since it is difficult
for init to output messages when /dev/console is absent, having the exit
code reported by the kernel panic gives a chance of identifying the fault.
Also exit if MAKEDEV fails to create /dev/console.
 1.90 01-Mar-2007  apb When calculating the size of the MFS /dev file system, round file sizes
up to a multiple of 512. (Not doing this before was wrong but probably
asymptomatic, because there was enough slack space to cope with the
error).
 1.89 01-Mar-2007  apb When creating /dev in a memory file system, include all three of
MAKEDEV, MAKEDEV.subr and MAKEDEV.local in the set of files that are
copied if they exist.

Now booting an INSTALL kernel with an embedded ramdisk correctly creates
/dev again, fixing a problem introduced when MAKEDEV.subr was created a
few days ago.
 1.88 15-Feb-2007  tron Increase the numbers of inodes available on the "/dev" MFS to 1280.
This should fix the "sysinst" problems caused by adding more devices
node to resolve PR port-amd64/35532.
 1.87 06-Feb-2007  cbiere Revert previous commit.
 1.86 05-Feb-2007  cbiere * 0/1 -> EXIT_{SUCCESS,FAILURE}
* make_utmpx(): Added comment and slightly simpler construct.
* alrm_handler(): Suppress "unused parameter" warning.
* mapfile():
* Handle st.st_size correctly.
* Avoid unnecessary return statements.
* Removed unnecessary MAP_FILE flag.
* Use S_ISLNK() and check S_ISREG() too.
* Add the terminating NUL rather after readlink() than
before, just in case.
* writefile():
* Avoid unnecessary return statements.
* read_ttys():
* Check S_ISREG() as well.
* Check for st.st_size > 0 rather than != 0.
 1.85 05-Feb-2007  njoly Fix compilation on 64bit platforms.
ok by elad.
 1.84 04-Feb-2007  christos - close the utmpx file.
- sprinkle void
- use size_t consistently.
 1.83 20-Jan-2007  isaki Make it compile without SUPPORT_UTMP nor SUPPORT_UTMPX.
 1.82 17-Jan-2007  hubertf Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>
 1.81 28-Sep-2006  christos branches: 1.81.2;
Don't record runlvl transitions before we have a read-write /var. Noticed
by lrou at x dot ua.
 1.80 25-Sep-2006  christos Error message consistency:
1. don't print the program name in the message [syslog does it]
2. no extraneous \n [syslog takes care of it]
3. quote strings as `%s' [we are using syslog]
4. use %m instead of error = %d
 1.79 23-Sep-2006  he Um, correct previous, so that current_state def/use is consistent.
 1.78 23-Sep-2006  he Since current_state is conditionally defined, make sure its uses are as well.
 1.77 22-Sep-2006  christos Try entertain who(1) because it has been sad since it was swallowed by the
Death Star: add utmpx entries for boot time, down time, run level, login
process.
 1.76 30-Jul-2006  elad update comment, thanks freza@.
 1.75 30-Jul-2006  elad CTLFLAG_READONLY1 was deprecated in earlier commit, remove it here too
 1.74 30-Jul-2006  elad remove CTLFLAG_READONLY1 usage. pointed out by cube@, thanks..
 1.73 18-Apr-2006  salo Add support for running multi-user in a chroot() environment.

How it works:

- after successful execution of /etc/rc, check the value of "init.root"
sysctl node, if it's different than "/", chroot() into its value and run
/etc/rc inside the chroot(),

- in single-user, return back to the original / file system.

Allows running with / file system on e.g., cgd(4), vnd(4) or ccd(4) volumes.

Idea first discussed with Matt Thomas, implemented by Jachym Holecek <freza
(at) liberouter.org> with some nitpicks by me. Successfully used by me for
almost a year with / on a cgd(4) volume (for more information about the setup
check ftp://ftp.NetBSD.org/pub/NetBSD/misc/salo/init-chroot/ ).
 1.72 17-Mar-2006  rumble Check for allocation failures in malloc, calloc, realloc, asprintf, and
vasprintf and try to handle them.
 1.71 17-Mar-2006  chris Fix case where argv wasn't returned or freed.

This fixes Coverity CID 2023.

While here also return NULL if the malloc fails.
 1.70 27-Jun-2005  christos Move WARNS=3 to the Makefile.inc, and add a little const to the remaining
programs that did not compile before.
 1.69 15-Mar-2005  xtraeme Bump the number of inodes to 1024 in the MFS case, needed to
create more devices in the ramdisk images, ok'ed by thorpej@.
 1.68 12-Oct-2004  dan be explicit about the perms of mfs /dev
 1.67 13-Aug-2004  mycroft Put back one of the sleep()s -- it doesn't affect us in the usual case.
 1.66 13-Aug-2004  mycroft Replace the sleep(2) in setctty() with a nanosleep(), with a default value of
250ms.
 1.65 13-Aug-2004  mycroft Remove a completely gratuitous 30 delay if you enter the wrong shell path.
 1.64 06-Jun-2004  christos clear_session_logs is not needed when we are small.
 1.63 03-Oct-2003  dsl branches: 1.63.2;
If /dev/constty exists, use it instead of /dev/console for single user shell.
I'm not 100% certain it should call login_tty() for anything else.
 1.62 11-Sep-2003  dsl If /dev/MAKEDEV is a symlink then preserve the symlink in the mfs /dev.
If /dev/MAKEDEV doesn't exist then try to run /etc/MAKEDEV instead.
Use the (new) '-n inodes' option to mount_mfs and base the size on the number
of inodes and the size of the MAKEDEV script.
 1.61 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.60 05-Aug-2003  dsl Exit child process if we fail to 'cd /dev' or 'execl sh MAKEDEV'.
Don't really want two processes in the rest of init!
 1.59 12-Jul-2003  itojun use asprintf, which is easier
 1.58 01-Jul-2003  christos Avoid code duplication by factoring out the open/map open/write/unmap functions.
 1.57 01-Jul-2003  lukem Always compile in support for attempting to obtain the major device
number of the console from sysctl("machdep.console_device"), rather
than making in optional on the (unused) #ifdef DEBUG.
Certain platforms do not have the console at makedev(0,0) (including
many arm32 and some sh3 platforms), so the "mfs MAKEDEV" hack would
have failed on those.

Noted in private discussion with Quentin Barnes.
 1.56 26-May-2003  lukem If RESCUEDIR is defined, use that as an alternate path to sh and mount_mfs,
and prepend RESCUEDIR to the default PATH.
(This replaces my _PATH_ALTSHELL mods from rev 1.52 of init.c)
 1.55 20-Apr-2003  christos PR/5544: Anders Magnusson: Init segfaults when hupped in single user.
- fix so that session_db is not de-referenced when null, and other
possible null pointer dereferences.
- ignore hup and tstp in single user mode.
 1.54 17-Apr-2003  fvdl Call MAKEDEV with "init"
 1.53 04-Oct-2002  simonb White space nit.
 1.52 24-Aug-2002  lukem - use _PATH_ALTSHELL (which defaults to _PATH_BSHELL) as the default ALTSHELL
(as opposed to _PATH_BSHELL), to allow the ALTSHELL to be changed.
- print the full path to the default shell in the ALTSHELL prompt.
 1.51 02-Aug-2002  christos fix typos that prevented us from cleaning utmpx. Noted by wiz
 1.50 27-Jul-2002  christos add utmpx/wtmpx processing support.
 1.49 16-Apr-2002  mycroft In single-user, after taking a signal and having the `shell' die with
SIGKILL, go into an infinite loop (like in the runcom SIGTERM case), on the
assumption that reboot(8) is in the middle of taking the system down.
This fixes `panic: init died' from sysinst.
 1.48 03-Feb-2002  lukem crank size of mfs from 512 sectors to 768 sectors (large i386 MAKEDEV)
 1.47 26-Jan-2002  christos KNF: - use %m always instead of sometimes using strerror()
- space problems in casts
- don't cast 0, use NULL
- don't have long lines
- don't cast malloc
- use warn/warnx instead of fprintf
- fix bug where a failed mount_mfs would cause the program to continue.
- pass lint
 1.46 23-Jan-2002  lukem fix compilation problems on my alpha
 1.45 21-Jan-2002  abs Rename MSDOSFS_ROOT to MFS_DEV_IF_NO_CONSOLE, and rework:
- Always attempt mfs dev if missing /dev/console
- Save and run both MAKEDEV and MAKEDEV.local
- After creating the mfs dev, mknod() and freopen() /dev/console.
- If MAKEDEV is missing do not fail out early, but still create the mfs,
/dev/console.
- If we hit any errors fail out to single user.
This change _only_ affects systems booting without /dev/console.
 1.44 16-Jan-2002  abs Increase the size of the dev mfs to at least enough for 1.5.2 i386.
bin/15235 by Gavan Fantom.
 1.43 18-Jun-2001  lukem complete conversion to ANSI C
 1.42 10-Jan-2001  lukem deprecate LOG_ODELAY; it's the default
 1.41 30-Dec-2000  wiz Fix typo in v1.38.
 1.40 30-Dec-2000  wiz sprinkle some const's
 1.39 30-Dec-2000  wiz ANSIfy and de-__P()
 1.38 30-Dec-2000  wiz Handle NULL return value by fgets after shell prompt better. Also
improve '\n' slightly. Addresses bin/11847.
 1.37 19-Mar-2000  soren branches: 1.37.4;
Unbreak compilation with -DLETS_GET_SMALL as in PR bin/9639 by Patrick Welche.
 1.36 21-Jan-2000  mycroft Nuke `extern int errno;' in code we compile with -Wstrict-prototypes. We get
the correct definition from errno.h.
 1.35 09-Nov-1999  drochner Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.
 1.34 14-Nov-1998  tls branches: 1.34.2; 1.34.6;
When downgrading from 'highly secure' mode (securelevel >= 2) to 'insecure' mode (securelevel 0) and the root password is set, always require it before giving a shell on the console. Reasoning: if an attacker has access to the machine console, he doesn't necessarily have access to the hardware itself; on a 'highly secure' machine, we may as well make his life hard.
 1.33 18-Sep-1998  thorpej Use sigset_t for signal masks.
 1.32 20-Feb-1998  mycroft Fill in missing (default) mmap(2) flags.
 1.31 06-Feb-1998  perry fix pr4766 from greywolf -- couldn't build without -DALTSHELL
 1.30 01-Nov-1997  drochner Remove the "wait for mfs to be mounted" hack; this is solved in mount_mfs
now.
 1.29 28-Oct-1997  christos PR/4372: Andread Wrede: increase number of inodes in mfs
 1.28 30-Jul-1997  christos branches: 1.28.2;
Support root on msdos filesystems by creating an mfs on /dev and running
MAKEDEV all to create the devices. Idea by Chris Demetriou.
 1.27 19-Jul-1997  perry get rid of "register" declarations.
turn 0 pointers into NULLs
Fix WARN=1 warnings
 1.26 19-Jul-1997  perry 1) change rcsid[] and copyright[] to use __RCSID and __COPYRIGHT
macros.
2) Clean up some gratuitous uses of write() instead of fprintf()
3) Clean up some of the alternative shell code in single_user(),
fixing a couple of bugs in the meanwhile. Also, fix pr-2620 from
Chris Demetriou -- when an alternative shell is exec'ed, it is now
not called "-sh" automatically.
4) rename the DEBUGSHELL option ALTSHELL since its almost always used
in NetBSD.

Notes:
1) It isn't clear that the ALTSHELL code is really ever very useful,
but we seem to have decided to always enable it anyway.
2) The code in init really needs an overall cleanup, but I just don't
have time or energy.
 1.25 19-Jul-1997  perry merge lite-2 changes
 1.24 14-Mar-1997  mycroft Insert some closelog()s, so we don't leave the syslog socket
on fd 0.
 1.23 22-Feb-1997  thorpej If root has no password, don't lock the operator out of single-user
mode if the console is "insecure".
 1.22 15-May-1996  jtc Updated to use <util.h>.
From Greg Hudson <ghudson@MIT.EDU>.
 1.21 05-Oct-1995  mycroft Kill sessions that were deleted when rereading /etc/ttys.
 1.20 28-May-1995  jtc sys_siglist[] -> strsignal()
 1.19 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.18 23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.17 06-Aug-1994  deraadt ensure /sbin is in PATH in single user mode
 1.16 11-Jun-1994  mycroft branches: 1.16.2;
Fix up RCS ids.
 1.15 10-Jun-1994  pk Update to 4.4-lite (basically some copyright changes) + local changes.
 1.14 26-Apr-1994  pk Disabling *all* terminals in /etc/ttys meant disabling them for good:
stuck in `clean tty' => `multi user' => `clean tty' loop.
 1.13 18-Apr-1994  cgd if we want a LETS_GET_SMALL init, allow only single-user
 1.12 01-Mar-1994  cgd Establish an initial user so that programs running single user
do not freak out and die (like passwd).
 1.11 01-Aug-1993  mycroft Add RCS identifiers.
 1.10 08-Jul-1993  cgd get rid of the bogus changes i made to init. note that /etc/ttys
*must* have an entry for "console", though it should be "off",
prolly.
 1.9 18-Jun-1993  cgd a couple of local mods; always ask for shell in single user, use -lcrypt,
use root's shell rather that /bin/sh when going to single-user, etc.
 1.8 18-Jun-1993  cgd incorporate bsdi's version of init; this is their version, w/no local changes
other than adding Id strings as appropriate
 1.7 10-Jun-1993  cgd add preliminary support for devfs (e.g. MOUNT_DEVFS #define, etc.)
 1.6 26-Apr-1993  cgd changed to use new libcrypt scheme.
 1.5 06-Apr-1993  cgd added console security, if SECURE_CONSOLE defined in makefile,
and console not secure in ttys
 1.4 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.3 22-Mar-1993  cgd added rcs ids to all files
 1.2 21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 19-Jul-1997  perry imported from 44lite2
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.16.2.1 06-Aug-1994  mycroft update from trunk
 1.28.2.1 02-Nov-1997  mellon Pull rev 1.29 and 1.30 up from trunk (drochner)
 1.34.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.34.2.1 23-Jan-2000  he Pull up revision 1.36 (requested by mycroft):
Always do the errno indirection hack, so that non-threaded
libraries get the right errno value when linked with -lpthread.
This means "always include <errno.h> and never declare errno
yourself".
 1.37.4.1 09-Feb-2002  he 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.
 1.63.2.1 12-Nov-2004  jmc branches: 1.63.2.1.2;
Pullup rev 1.68 (requested by dan in ticket #914)

Be explicit about the perms of mfs /dev.
 1.63.2.1.2.1 10-May-2005  riz Pull up revision 1.69 (requested by martin in ticket #1331):
Bump the number of inodes to 1024 in the MFS case, needed to
create more devices in the ramdisk images, ok'ed by thorpej@.
 1.81.2.1 16-Feb-2007  riz Pull up following revision(s) (requested by tron in ticket #441):
sbin/init/init.c: revision 1.88
Increase the numbers of inodes available on the "/dev" MFS to 1280.
This should fix the "sysinst" problems caused by adding more devices
node to resolve PR port-amd64/35532.
 1.93.6.1 27-Dec-2007  mjf Sync with HEAD.
 1.93.4.2 23-Mar-2008  matt sync with HEAD
 1.93.4.1 09-Jan-2008  matt sync with HEAD
 1.94.6.4 28-Sep-2008  mjf Sync with HEAD.
 1.94.6.3 04-Apr-2008  mjf * Catch up with selnotify() changes.

* Catch up with some softc changes in HEAD.

* More s/dctl/devfsctl/ changes.

* Remove debugging printfs from init(8) that slipped in by mistake.

* Cosmetic changes in devfsd, allow multiple attributes to be set in
one rule. Switch from err() to syslog() messages.

* Fix etc/devfsd.conf, I'd made some changes previously that had syntax
errors.
 1.94.6.2 03-Apr-2008  mjf Sync with HEAD.
 1.94.6.1 29-Mar-2008  mjf - etc/devfsd.conf: Add some rules to give nodes like /dev/tty and
/dev/null better default modes, i.e. 0666.

- sbin/init: Run devfsd -s before going to multiuser.

- sys/arch: Provide arm32, i386, sparc with a mem_init() function to request
device nodes for /dev/null, /dev/zero, etc.

- sys/dev: Convert rnd, wd, agp, raid, cd, sd, wsdisplay, wskbd, wsmouse,
wsmux, tty, bpf, swap to devfs New World Order.

- sys/fs/devfs: Make the visibility attribute of device nodes configurable.
Also provide a function to mount a devfs on boot.

- sys/kern: Add a new boot flag, -n. This disables devfs support. Unless
the -n flag is specified the kernel will mount a devfs file
system on boot.
 1.94.4.1 24-Mar-2008  keiichi sync with head.
 1.95.4.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.97.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.102.4.1 23-Nov-2012  riz Pull up following revision(s) (requested by msaitoh in ticket #698):
sbin/init/init.c: revision 1.105
Add missing free() in error path.
 1.102.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.102.2.1 17-Apr-2012  yamt sync with head
 1.103.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.5 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.4 11-Jun-1994  mycroft Fix up RCS ids.
 1.3 10-Jun-1994  pk Update to 4.4-lite (basically some copyright changes) + local changes.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 18-Jun-1993  cgd branches: 1.1.1;
incorporate bsdi's version of init; this is their version, w/no local changes
other than adding Id strings as appropriate
 1.1.1.1 13-Jun-1994  mycroft Import 4.4-Lite version.

RSS XML Feed