Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.unix-wizards Subject: Re: Being `well and truly up the creek' Message-ID: <2200@umcp-cs.UUCP> Date: Tue, 12-Nov-85 05:12:49 EST Article-I.D.: umcp-cs.2200 Posted: Tue Nov 12 05:12:49 1985 Date-Received: Wed, 13-Nov-85 20:49:58 EST References: <2968@sun.uucp> Distribution: net Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 51 One of the most, er, `interesting' things that can happen to a root file system is to lose /dev (have it turn into an ordinary file or soemthing). If you have lost /dev, *and nothing else*, it would seem perfectly reasonable that /etc/init could come up single user by creating a new console device. Of course, it will not, and one is forced to recover with standalone programs or a 4.2-style minifs. Here is an *untested* change to init that should be easy enough to install in a 4.2 system to do this. *** /usr/src/etc/init.c Wed Sep 18 21:40:02 1985 --- init.c Tue Nov 12 05:11:46 1985 *************** *** 193,197 **** signal(SIGALRM, SIG_DFL); signal(SIGTSTP, SIG_IGN); ! (void) open(ctty, O_RDWR); dup2(0, 1); dup2(0, 2); --- 193,197 ---- signal(SIGALRM, SIG_DFL); signal(SIGTSTP, SIG_IGN); ! get_console(); dup2(0, 1); dup2(0, 2); *************** *** 203,206 **** --- 203,221 ---- break; } while (xpid == -1); + } + + /* + * Open the console, and if it fails make a last ditch attempt to + * create a new one. Assumes fd 0 is not currently open. + */ + get_console() + { + + if (open(ctty, O_RDWR) == 0) + return; + (void) strcpy(ctty, "/#console"); + (void) mknod(ctty, S_IFCHR|0644, 0); + (void) open(ctty, O_RDWR); + (void) write(0, "WARNING: /dev/console gone, made /#console\n", 43); } -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu