Commit Graph

105 Commits

Author SHA1 Message Date
msaitoh b6620403e7 Add missing free() in error path. 2012-11-09 06:27:17 +00:00
christos e3f7c883f9 include the needed headers 2012-11-04 22:20:03 +00:00
matt cf7ed4c9cc Convert to C89 function definitions 2012-03-20 18:50:30 +00:00
christos 694c2250cf make it compile with SMALLPROG 2011-08-28 10:13:03 +00:00
joerg d2ac3967fe Be more static 2011-08-27 17:43:42 +00:00
elad 34edb026e5 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.
2009-12-29 17:07:17 +00:00
mbalmer 124961627e s/the the/the/ 2009-11-22 18:40:26 +00:00
apb a194a42669 If MAKEDEV exits non-zero, but was nevertheless able to create
/dev/console, then have init(8) just print a warning instead of
exiting.
2009-04-12 09:31:32 +00:00
lukem c6144e484f fix -Wsign-compare issues 2009-01-18 00:24:29 +00:00
lukem 6543a91fea Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)
2008-07-20 01:20:21 +00:00
christos fb30984e82 un-bitrot #if 0 testing code. 2008-03-18 15:38:57 +00:00
apb edf9f9968b No need to pass "-ppax" to MAKEDEV now that MAKEDEV internally defaults
to using pax.
2007-12-09 09:16:28 +00:00
dyoung 7663f13790 KNF. 2007-03-21 03:51:30 +00:00
apb 7c0e506d3c 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.)
2007-03-11 19:02:04 +00:00
dsl 1d350026de 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.
2007-03-02 22:43:24 +00:00
apb c3bbc70fa0 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).
2007-03-01 18:25:58 +00:00
apb c654f7abce 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.
2007-03-01 07:18:07 +00:00
tron e3f6d993ed 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.
2007-02-15 22:39:12 +00:00
cbiere 033e1229b9 Revert previous commit. 2007-02-06 20:24:19 +00:00
cbiere 21f5afe6b9 * 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.
2007-02-05 22:36:18 +00:00
njoly e2ca295958 Fix compilation on 64bit platforms.
ok by elad.
2007-02-05 15:37:20 +00:00
christos 6a075814d9 - close the utmpx file.
- sprinkle void
- use size_t consistently.
2007-02-04 20:53:19 +00:00
isaki d4ba865188 Make it compile without SUPPORT_UTMP nor SUPPORT_UTMPX. 2007-01-20 13:25:28 +00:00
hubertf df06563bc3 Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>
2007-01-17 21:59:49 +00:00
christos 6bc6175052 Don't record runlvl transitions before we have a read-write /var. Noticed
by lrou at x dot ua.
2006-09-28 15:20:14 +00:00
christos 6accae529c 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
2006-09-25 19:42:04 +00:00
he fa8dee8628 Um, correct previous, so that current_state def/use is consistent. 2006-09-23 18:57:26 +00:00
he 54f712bd18 Since current_state is conditionally defined, make sure its uses are as well. 2006-09-23 14:04:26 +00:00
christos c34b6372d0 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.
2006-09-22 21:49:21 +00:00
elad 03917bd261 update comment, thanks freza@. 2006-07-30 20:01:26 +00:00
elad 8bc495196e CTLFLAG_READONLY1 was deprecated in earlier commit, remove it here too 2006-07-30 19:53:19 +00:00
elad 8ffd510349 remove CTLFLAG_READONLY1 usage. pointed out by cube@, thanks.. 2006-07-30 19:46:33 +00:00
salo b0b7590bc7 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/ ).
2006-04-18 11:40:26 +00:00
rumble e948e1b17f Check for allocation failures in malloc, calloc, realloc, asprintf, and
vasprintf and try to handle them.
2006-03-17 15:53:46 +00:00
chris 4727225848 Fix case where argv wasn't returned or freed.
This fixes Coverity CID 2023.

While here also return NULL if the malloc fails.
2006-03-17 02:48:29 +00:00
christos 2c6eadc9ce Move WARNS=3 to the Makefile.inc, and add a little const to the remaining
programs that did not compile before.
2005-06-27 01:00:04 +00:00
xtraeme 83d6c074cb Bump the number of inodes to 1024 in the MFS case, needed to
create more devices in the ramdisk images, ok'ed by thorpej@.
2005-03-15 23:43:50 +00:00
dan 603344819a be explicit about the perms of mfs /dev 2004-10-12 10:08:09 +00:00
mycroft e0fc84bd24 Put back one of the sleep()s -- it doesn't affect us in the usual case. 2004-08-13 17:22:39 +00:00
mycroft f3b5a6849c Replace the sleep(2) in setctty() with a nanosleep(), with a default value of
250ms.
2004-08-13 17:19:15 +00:00
mycroft 40321c3f44 Remove a completely gratuitous 30 delay if you enter the wrong shell path. 2004-08-13 17:11:49 +00:00
christos e53725b6b7 clear_session_logs is not needed when we are small. 2004-06-06 01:42:20 +00:00
dsl 920dff4b7c 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.
2003-10-03 13:31:32 +00:00
dsl 58915e2274 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.
2003-09-11 12:51:51 +00:00
agc 276d62f603 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22308, verified by myself.
2003-08-07 10:04:22 +00:00
dsl 9b8239809b Exit child process if we fail to 'cd /dev' or 'execl sh MAKEDEV'.
Don't really want two processes in the rest of init!
2003-08-05 09:31:48 +00:00
itojun 09401b303a use asprintf, which is easier 2003-07-12 14:46:41 +00:00
christos 9dd592469e Avoid code duplication by factoring out the open/map open/write/unmap functions. 2003-07-01 16:44:48 +00:00
lukem b96069c077 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.
2003-07-01 15:24:22 +00:00
lukem 35c2bddeea 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)
2003-05-26 09:34:55 +00:00