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

📄 bootcache.c

📁 著名操作系统Plan 9的第三版的部分核心源代码。现在很难找到了。Plan 9是bell实验室开发的Unix后继者。
💻 C
字号:
#include <u.h>#include <libc.h>#include <../boot/boot.h>intcache(int fd){	int argc, i, p[2];	char *argv[5], bd[NAMELEN], buf[256], d[DIRLEN], partition[2*NAMELEN], *pp;	if(stat("/cfs", d) < 0)		return fd;	*partition = 0;	readfile("#e/cfs", buf, sizeof(buf));	if(*buf){		argc = getfields(buf, argv, 4, 1, " ");		for(i = 0; i < argc; i++){			if(strcmp(argv[i], "off") == 0)				return fd;			else if(stat(argv[i], d) >= 0){				strncpy(partition, argv[i], sizeof(partition)-1);				partition[sizeof(partition)-1] = 0;			}		}	}	if(*partition == 0){		readfile("#e/bootdisk", bd, sizeof(bd));		if(*bd){			if(pp = strchr(bd, ':'))				*pp = 0;			/* damned artificial intelligence */			i = strlen(bd);			if(strcmp("disk", &bd[i-4]) == 0)				bd[i-4] = 0;			else if(strcmp("fs", &bd[i-2]) == 0)				bd[i-2] = 0;			sprint(partition, "%scache", bd);			if(stat(partition, d) < 0)				*bd = 0;		}		if(*bd == 0){			sprint(partition, "%scache", bootdisk);			if(stat(partition, d) < 0)				return fd;		}	}	print("cfs...");	if(pipe(p)<0)		fatal("pipe");	switch(fork()){	case -1:		fatal("fork");	case 0:		close(p[1]);		dup(fd, 0);		close(fd);		dup(p[0], 1);		close(p[0]);		if(fflag)			execl("/cfs", "bootcfs", "-rs", "-f", partition, 0);		else			execl("/cfs", "bootcfs", "-s", "-f", partition, 0);		break;	default:		close(p[0]);		close(fd);		fd = p[1];		break;	}	return fd;}

⌨️ 快捷键说明

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