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

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


## diffname boot/local.c 1992/0317
## diff -e /dev/null /n/bootesdump/1992/0317/sys/src/9/boot/local.c
0a
#include <u.h>
#include <libc.h>
#include <../boot/boot.h>

static char *disk;

void
configlocal(Method *mp)
{
	disk = mp->arg;
	USED(mp);
}

int
authlocal(void)
{
	return -1;
}

int
connectlocal(void)
{
	ulong i;
	int p[2];
	char d[DIRLEN];
	char sbuf[32];
	char rbuf[32];
	char *mtpt;
	char partition[2*NAMELEN];

	if(stat("/kfs", d) < 0)
		return -1;
	sprint(partition, "%sfs", mp->arg ? mp->arg : bootdisk);
	if(stat(partition, d) < 0)
		return -1;

	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:
		sprint(sbuf, "%d", p[0]);
		sprint(rbuf, "%d", p[1]);
		execl("/kfs", "kfs", "-f", partition, "-s", sbuf, rbuf, 0);
		fatal("can't exec kfs");
	default:
		break;
	}

	close(p[1]);
	return p[0];
}
.
## diffname boot/local.c 1992/0318
## diff -e /n/bootesdump/1992/0317/sys/src/9/boot/local.c /n/bootesdump/1992/0318/sys/src/9/boot/local.c
33c
	sprint(partition, "%sfs", disk ? disk : bootdisk);
.
## diffname boot/local.c 1992/0321
## diff -e /n/bootesdump/1992/0318/sys/src/9/boot/local.c /n/bootesdump/1992/0321/sys/src/9/boot/local.c
36c
	print("kfs...");
.
## diffname boot/local.c 1992/0728
## diff -e /n/bootesdump/1992/0321/sys/src/9/boot/local.c /n/bootesdump/1992/0728/sys/src/9/boot/local.c
28d
23d
## diffname boot/local.c 1992/0825
## diff -e /n/bootesdump/1992/0728/sys/src/9/boot/local.c /n/bootesdump/1992/0825/sys/src/9/boot/local.c
10c
	disk = *sys ? sys : mp->arg;
.
## diffname boot/local.c 1992/0826
## diff -e /n/bootesdump/1992/0825/sys/src/9/boot/local.c /n/bootesdump/1992/0826/sys/src/9/boot/local.c
10c
	if(*sys == '/' || *sys == '#')
		disk = sys;
	else
		disk = mp->arg;
.
## diffname boot/local.c 1992/0902
## diff -e /n/bootesdump/1992/0826/sys/src/9/boot/local.c /n/bootesdump/1992/0902/sys/src/9/boot/local.c
48,51c
		dup(p[0], 0);
		dup(p[1], 1);
		close(p[0]);
		close(p[1]);
		execl("/fs", "fs", "-f", partition, "-s", 0);
		fatal("can't exec fs");
.
34,37c

	dev = disk ? disk : bootdisk;
	sprint(partition, "%sfs", dev);
	if(stat(partition, d) < 0){
		strcpy(partition, dev);
		if(stat(partition, d) < 0)
			return -1;
	}

	print("fs...");
.
32c
	if(stat("/fs", d) < 0)
.
30a
	char *dev;
.
28,29d
## diffname boot/local.c 1993/0403
## diff -e /n/bootesdump/1992/0902/sys/src/9/boot/local.c /n/bootesdump/1993/0403/sys/src/9/boot/local.c
57c
		argp = args;
		*argp++ = "fs";
		if(niob){
			*argp++ = "-B";
			*argp++ = niob;
		}
		*argp++ = "-f";
		*argp++ = partition;
		*argp++ = "-s";
		*argp = 0;
		exec("/fs", args);
.
29a
	char *args[16], **argp;
.
13a
	if(niob = strchr(disk, ' '))	/* assign = */
		*niob++ = 0;
.
5a
static char *niob;
.
## diffname boot/local.c 1993/0406
## diff -e /n/bootesdump/1993/0403/sys/src/9/boot/local.c /n/bootesdump/1993/0406/sys/src/9/boot/local.c
13,16d
10a
	char *p;
	int n;

	disk = mp->arg;			/* 1st try from config file */
	if(disk && (niob = strchr(disk, ' ')))	/* assign = */
		*niob++ = 0;
	if(strncmp(argv0, "dksc(0,", 7) == 0){
		p = strchr(argv0, ',');
		n = strtoul(p+1, 0, 10);
		sprint(diskname, "#w%d/sd%dfs", n, n);
		disk = diskname;
		/*print("argv0=\"%s\" --> disk = \"%s\"\n", argv0, disk);/**/
	}
.
4a
static char diskname[2*NAMELEN];
.
## diffname boot/local.c 1993/0410
## diff -e /n/bootesdump/1993/0406/sys/src/9/boot/local.c /n/bootesdump/1993/0410/sys/src/9/boot/local.c
26a
	if(disk)
		setenv("bootdisk", disk);
.
## diffname boot/local.c 1993/0501
## diff -e /n/bootesdump/1993/0410/sys/src/9/boot/local.c /n/fornaxdump/1993/0501/sys/src/brazil/boot/local.c
27,28c
	else
		disk = mp->arg;
	if(niob = strchr(disk, ' '))	/* assign = */
		*niob++ = 0;
.
12,24d
5d
## diffname boot/local.c 1994/0312
## diff -e /n/fornaxdump/1993/0501/sys/src/brazil/boot/local.c /n/fornaxdump/1994/0312/sys/src/brazil/boot/local.c
13,16c
	if(disk)
		setenv("bootdisk", disk);
.
10a
	char *p;
	int n;

	disk = mp->arg;			/* 1st try from config file */
	if(disk && (niob = strchr(disk, ' ')))	/* assign = */
		*niob++ = 0;
	if(strncmp(argv0, "dksc(0,", 7) == 0){
		p = strchr(argv0, ',');
		n = strtoul(p+1, 0, 10);
		sprint(diskname, "#w%d/sd%dfs", n, n);
		disk = diskname;
		/*print("argv0=\"%s\" --> disk = \"%s\"\n", argv0, disk);/**/
	}
.
4a
static char diskname[2*NAMELEN];
.
## diffname boot/local.c 1995/02021
## diff -e /n/fornaxdump/1994/0312/sys/src/brazil/boot/local.c /n/fornaxdump/1995/02021/sys/src/brazil/boot/local.c
75,78d
28a

.
25,26c

	/* if we've decided on one, pass it on to all programs */
.
23c
	} 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;
.
15,18c
	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
		 */
.
7d
## diffname boot/local.c 1999/0501
## diff -e /n/fornaxdump/1995/02021/sys/src/brazil/boot/local.c /n/emeliedump/1999/0501/sys/src/brazil/boot/local.c
97,98c
		exec("/kfs", args);
		fatal("can't exec kfs");
.
92c
		*argp++ = "kfs";
.
76c
	print("kfs...");
.
65c
	if(stat("/kfs", d) < 0)
.
## diffname boot/local.c 2000/0506
## diff -e /n/emeliedump/1999/0501/sys/src/brazil/boot/local.c /n/emeliedump/2000/0506/sys/src/9/boot/local.c
74a
	if(dir.mode & CHDIR)
		return -1;
.
72c
		if(dirstat(partition, &dir) < 0)
.
70c
	if(dirstat(partition, &dir) < 0){
.
59a
	Dir dir;
.
## diffname boot/local.c 2000/1018
## diff -e /n/emeliedump/2000/0506/sys/src/9/boot/local.c /n/emeliedump/2000/1018/sys/src/9/boot/local.c
100c

		print("kfs");
		for(argp=arg; *argp; argp++)
			print(" %s", *argp);
		print("\n");

		dup(p[0], 0);
		dup(p[1], 1);
		close(p[0]);
		close(p[1]);
		exec("/kfs", arg);
.
98a
		for(i=1; i<bargc; i++)
			*argp++ = bargv[i];
.
90,94c
		arg = malloc((bargc+5)*sizeof(char*));
		argp = arg;
.
64c
	char **arg, **argp;
.
59c
	int i, p[2];
.
6a
static char **args;
.
## diffname boot/local.c 2000/1129
## diff -e /n/emeliedump/2000/1018/sys/src/9/boot/local.c /n/emeliedump/2000/1129/sys/src/9/boot/local.c
101,105d
## diffname boot/local.c 2001/0119
## diff -e /n/emeliedump/2000/1129/sys/src/9/boot/local.c /n/emeliedump/2001/0119/sys/src/9/boot/local.c
75a
		}
.
74c
		if(dirstat(partition, &dir) < 0){
			print("stat %s fails: %r\n", partition);
			print("(stat %sfs also failed)\n", dev);
.
68a
	}
.
67c
	if(stat("/kfs", d) < 0){
		print("stat /kfs fails: %r\n");
.
## diffname boot/local.c 2001/0527
## diff -e /n/emeliedump/2001/0119/sys/src/9/boot/local.c /n/emeliedump/2001/0527/sys/src/9/boot/local.c
104a

		print("kfs");
		for(argp=arg; *argp; argp++)
			print(" %s", *argp);
		print("\n");
.
82c
	mode = dir->mode;
	free(dir);
	if(mode & DMDIR)
.
80d
76,78c
		dir = dirstat(partition);
		if(dir == nil)
.
73,74c
	snprint(partition, sizeof partition, "%sfs", dev);
	dir = dirstat(partition);
	if(dir == nil){
.
70d
67,68c
	if(stat("/kfs", statbuf, sizeof statbuf) < 0)
.
65a
	ulong mode;
.
61,63c
	Dir *dir;
	char partition[64];
.
5c
static char diskname[64];
.
## diffname boot/local.c 2002/0109
## diff -e /n/emeliedump/2001/0527/sys/src/9/boot/local.c /n/emeliedump/2002/0109/sys/src/9/boot/local.c
52,57d
## diffname boot/local.c 2002/0401
## diff -e /n/emeliedump/2002/0109/sys/src/9/boot/local.c /n/emeliedump/2002/0401/sys/src/9/boot/local.c
112a
	waitpid();
.
## diffname boot/local.c 2002/0414
## diff -e /n/emeliedump/2002/0401/sys/src/9/boot/local.c /n/emeliedump/2002/0414/sys/src/9/boot/local.c
99,103d
## diffname boot/local.c 2002/1130
## diff -e /n/emeliedump/2002/0414/sys/src/9/boot/local.c /n/emeliedump/2002/1130/sys/src/9/boot/local.c
103c
		exec("/boot/kfs", arg);
.
61c
	if(stat("/boot/kfs", 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 webmaster@9p.io.