Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/boot/bootcache.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname boot/bootcache.c 2000/0405
## diff -e /dev/null /n/emeliedump/2000/0405/sys/src/9/boot/bootcache.c
0a
#include <u.h>
#include <libc.h>
#include <../boot/boot.h>

int
cache(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;
}
.
## diffname boot/bootcache.c 2001/0527
## diff -e /n/emeliedump/2000/0405/sys/src/9/boot/bootcache.c /n/emeliedump/2001/0527/sys/src/9/boot/bootcache.c
46c
			if(stat(partition, statbuf, sizeof statbuf) < 0)
.
41c
			if(stat(partition, statbuf, sizeof statbuf) < 0)
.
22c
			else if(stat(argv[i], statbuf, sizeof statbuf) >= 0){
.
11c
	if(stat("/cfs", statbuf, sizeof statbuf) < 0)
.
9c
	char *argv[5], bd[32], buf[256], partition[64], *pp;
.
4a
uchar statbuf[STATMAX];

.
## diffname boot/bootcache.c 2001/0819
## diff -e /n/emeliedump/2001/0527/sys/src/9/boot/bootcache.c /n/emeliedump/2001/0819/sys/src/9/boot/bootcache.c
68c
			execl("/cfs", "bootcfs", "-ds", "-f", partition, 0);
.
## diffname boot/bootcache.c 2001/0820
## diff -e /n/emeliedump/2001/0819/sys/src/9/boot/bootcache.c /n/emeliedump/2001/0820/sys/src/9/boot/bootcache.c
68c
			execl("/cfs", "bootcfs", "-s", "-f", partition, 0);
.
5c
uchar statbuf[Statsz];
.
## diffname boot/bootcache.c 2001/1117
## diff -e /n/emeliedump/2001/0820/sys/src/9/boot/bootcache.c /n/emeliedump/2001/1117/sys/src/9/boot/bootcache.c
20c
		argc = tokenize(buf, argv, 4);
.
## diffname boot/bootcache.c 2002/1130
## diff -e /n/emeliedump/2001/1117/sys/src/9/boot/bootcache.c /n/emeliedump/2002/1130/sys/src/9/boot/bootcache.c
68c
			execl("/boot/cfs", "bootcfs", "-s", "-f", partition, 0);
.
66c
			execl("/boot/cfs", "bootcfs", "-rs", "-f", partition, 0);
.
13c
	if(stat("/boot/cfs", statbuf, sizeof statbuf) < 0)
.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].