From owner-freebsd-current Sat Apr 6 05:35:36 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id FAA28989 for current-outgoing; Sat, 6 Apr 1996 05:35:36 -0800 (PST) Received: from irz301.inf.tu-dresden.de (irz301.inf.tu-dresden.de [141.76.1.11]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id FAA28979 for ; Sat, 6 Apr 1996 05:35:33 -0800 (PST) Received: from sax.sax.de by irz301.inf.tu-dresden.de (8.6.12/8.6.12-s1) with ESMTP id PAA13231 for ; Sat, 6 Apr 1996 15:35:31 +0200 Received: by sax.sax.de (8.6.11/8.6.12-s1) with UUCP id PAA19293 for freebsd-current@FreeBSD.org; Sat, 6 Apr 1996 15:35:30 +0200 Received: (from j@localhost) by uriah.heep.sax.de (8.7.5/8.6.9) id PAA00612 for freebsd-current@FreeBSD.org; Sat, 6 Apr 1996 15:27:19 +0200 (MET DST) From: J Wunsch Message-Id: <199604061327.PAA00612@uriah.heep.sax.de> Subject: devfs questions To: freebsd-current@FreeBSD.org (FreeBSD-current users) Date: Sat, 6 Apr 1996 15:27:15 +0200 (MET DST) Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) X-Phone: +49-351-2012 669 X-Mailer: ELM [version 2.4 PL24 ME8a] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk 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 +#include #include #include @@ -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. ;-)