⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 local.c

📁 著名操作系统Plan 9的第三版的部分核心源代码。现在很难找到了。Plan 9是bell实验室开发的Unix后继者。
💻 C
字号:
#include <u.h>#include <libc.h>#include <../boot/boot.h>static char diskname[2*NAMELEN];static char *disk;voidconfiglocal(Method *mp){	char *p;	int n;	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		 */		p = strchr(argv0, ',');		n = strtoul(p+1, 0, 10);		sprint(diskname, "#w%d/sd%dfs", n, n);		disk = diskname;	} 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;	}	/* if we've decided on one, pass it on to all programs */	if(disk)		setenv("bootdisk", disk);	USED(mp);}intauthlocal(void){	return -1;}intconnectlocal(void){	int p[2];	Dir dir;	char d[DIRLEN];	char partition[2*NAMELEN];	char *dev;	char *args[16], **argp;	if(stat("/kfs", d) < 0)		return -1;	dev = disk ? disk : bootdisk;	sprint(partition, "%sfs", dev);	if(dirstat(partition, &dir) < 0){		strcpy(partition, dev);		if(dirstat(partition, &dir) < 0)			return -1;	}	if(dir.mode & CHDIR)		return -1;	print("kfs...");	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:		dup(p[0], 0);		dup(p[1], 1);		close(p[0]);		close(p[1]);		argp = args;		*argp++ = "kfs";		*argp++ = "-f";		*argp++ = partition;		*argp++ = "-s";		*argp = 0;		exec("/kfs", args);		fatal("can't exec kfs");	default:		break;	}	close(p[1]);	return p[0];}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -