plan 9 kernel history: overview | file list | diff list

2000/0506/boot/local.c (diff list | history)

boot/local.c on 1992/0317
1992/0317    
#include <u.h> 
#include <libc.h> 
#include <../boot/boot.h> 
 
1994/0312    
static char diskname[2*NAMELEN]; 
1992/0317    
static char *disk; 
 
void 
configlocal(Method *mp) 
{ 
1994/0312    
	char *p; 
	int n; 
 
1995/02021    
	if(*sys == '/' || *sys == '#'){ 
		/* 
		 *  if the user specifies the disk in the boot cmd or 
		 * 'root is from' prompt, use it 
		 */ 
		disk = sys; 
	} else if(strncmp(argv0, "dksc(0,", 7) == 0){ 
		/* 
		 *  on many mips arg0 of the boot command specifies the 
		 *  scsi logical unit number 
		 */ 
1994/0312    
		p = strchr(argv0, ','); 
		n = strtoul(p+1, 0, 10); 
		sprint(diskname, "#w%d/sd%dfs", n, n); 
		disk = diskname; 
1995/02021    
	} else if(mp->arg){ 
		/* 
		 *  a default is supplied when the kernel is made 
		 */ 
		disk = mp->arg; 
	} else if(*bootdisk){ 
		/* 
		 *  an environment variable from a pc's plan9.ini or 
		 *  from the mips nvram or generated by the kernel 
		 *  is the last resort. 
		 */ 
		disk = bootdisk; 
1994/0312    
	} 
1995/02021    
 
	/* if we've decided on one, pass it on to all programs */ 
1994/0312    
	if(disk) 
		setenv("bootdisk", disk); 
1995/02021    
 
1992/0317    
	USED(mp); 
} 
 
int 
authlocal(void) 
{ 
	return -1; 
} 
 
int 
connectlocal(void) 
{ 
	int p[2]; 
2000/0506    
	Dir dir; 
1992/0317    
	char d[DIRLEN]; 
	char partition[2*NAMELEN]; 
1992/0902    
	char *dev; 
1993/0403    
	char *args[16], **argp; 
1992/0317    
 
1999/0501    
	if(stat("/kfs", d) < 0) 
1992/0317    
		return -1; 
1992/0902    
 
	dev = disk ? disk : bootdisk; 
	sprint(partition, "%sfs", dev); 
2000/0506    
	if(dirstat(partition, &dir) < 0){ 
1992/0902    
		strcpy(partition, dev); 
2000/0506    
		if(dirstat(partition, &dir) < 0) 
1992/0902    
			return -1; 
	} 
2000/0506    
	if(dir.mode & CHDIR) 
		return -1; 
1992/0902    
 
1999/0501    
	print("kfs..."); 
1992/0317    
	if(bind("#c", "/dev", MREPL) < 0) 
		fatal("bind #c"); 
	if(bind("#p", "/proc", MREPL) < 0) 
		fatal("bind #p"); 
	if(pipe(p)<0) 
		fatal("pipe"); 
	switch(fork()){ 
	case -1: 
		fatal("fork"); 
	case 0: 
1992/0902    
		dup(p[0], 0); 
		dup(p[1], 1); 
		close(p[0]); 
		close(p[1]); 
1993/0403    
		argp = args; 
1999/0501    
		*argp++ = "kfs"; 
1993/0403    
		*argp++ = "-f"; 
		*argp++ = partition; 
		*argp++ = "-s"; 
		*argp = 0; 
1999/0501    
		exec("/kfs", args); 
		fatal("can't exec kfs"); 
1992/0317    
	default: 
		break; 
	} 
 
	close(p[1]); 
	return p[0]; 
} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)