Date: Sat, 6 Apr 1996 15:27:15 +0200 (MET DST) From: J Wunsch <j@uriah.heep.sax.de> To: freebsd-current@FreeBSD.org (FreeBSD-current users) Subject: devfs questions Message-ID: <199604061327.PAA00612@uriah.heep.sax.de>
next in thread | raw e-mail | index | archive | help
I've started playing with devfs. Find below a patch to init(8) that should allow the system to come up with an empty /dev directory as long as devfs is statically available in the kernel. It tries to mount /dev early in the game, before the first device node (/dev/console) is about to be accessed. I've at least been able to run the single-user shell with it. Alas, the next would be fsck'ing, and so the big question is: how are the slice and partition entries supposed to be created? I've also got a panic when trying to create a hardlink there, but have yet to reproduce it again ("vrele: negative reference cnt"). The previous core dump was unusable. How hard will it be to get symlinks implemented? Index: init/init.c =================================================================== RCS file: /home/ncvs/src/sbin/init/init.c,v retrieving revision 1.11 diff -u -u -r1.11 init.c --- init.c 1995/11/10 07:06:59 1.11 +++ init.c 1996/04/06 12:44:10 @@ -45,6 +45,7 @@ #endif /* not lint */ #include <sys/param.h> +#include <sys/mount.h> #include <sys/sysctl.h> #include <sys/wait.h> @@ -125,6 +126,7 @@ state_t requested_transition = runcom; void setctty __P((char *)); +void check_console __P((void)); typedef struct init_session { int se_index; /* index of entry in ttys file */ @@ -546,6 +548,28 @@ } /* + * Check for the existance of _PATH_CONSOLE. Try mounting devfs if it + * doesn't exist. + */ +void +check_console() +{ + if (access(_PATH_CONSOLE, F_OK) == 0) + return; + + if (getvfsbytype(MOUNT_DEVFS) == NULL) { + stall("%s does not exist, and \"devfs\" is not available", + _PATH_CONSOLE); + _exit(1); + } + if (mount(MOUNT_DEVFS, _PATH_DEV_MNTPNT, 0, NULL) == -1) { + stall("cannot mount \"devfs\", errno = %d", + errno); + _exit(1); + } +} + +/* * Bring the system up single user. */ state_func_t @@ -583,6 +607,7 @@ /* * Start the single user session. */ + check_console(); setctty(_PATH_CONSOLE); #ifdef SECURE @@ -716,6 +741,7 @@ (void) sigaction(SIGTSTP, &sa, (struct sigaction *)0); (void) sigaction(SIGHUP, &sa, (struct sigaction *)0); + check_console(); setctty(_PATH_CONSOLE); argv[0] = "sh"; Index: init/pathnames.h =================================================================== RCS file: /home/ncvs/src/sbin/init/pathnames.h,v retrieving revision 1.1.1.1 diff -u -u -r1.1.1.1 pathnames.h --- pathnames.h 1994/05/26 06:34:19 1.1.1.1 +++ pathnames.h 1996/04/06 12:43:42 @@ -40,3 +40,4 @@ #define _PATH_SLOGGER "/sbin/session_logger" #define _PATH_RUNCOM "/etc/rc" +#define _PATH_DEV_MNTPNT "/dev" /* _PATH_DEV has a trailing slash */ -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604061327.PAA00612>