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

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


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

static char *paqfile;

void
configembed(Method *m)
{
	if(*sys == '/' || *sys == '#'){
		/*
		 *  if the user specifies the disk in the boot cmd or
		 * 'root is from' prompt, use it
		 */
		paqfile = sys;
	} else if(m->arg){
		/*
		 *  a default is supplied when the kernel is made
		 */
		paqfile = m->arg;
	}
}

int
connectembed(void)
{
	int i, p[2];
	Dir *dir;
	char **arg, **argp;

	dir = dirstat("/paqfs");
	if(dir == nil)
		return -1;
	free(dir);

	dir = dirstat(paqfile);
	if(dir == nil || dir->mode & DMDIR)
		return -1;
	free(dir);

	print("paqfs...");
	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:
		arg = malloc((bargc+5)*sizeof(char*));
		argp = arg;
		*argp++ = "/paqfs";
		*argp++ = "-iv";
		*argp++ = paqfile;
		for(i=1; i<bargc; i++)
			*argp++ = bargv[i];
		*argp = 0;

		dup(p[0], 0);
		dup(p[1], 1);
		close(p[0]);
		close(p[1]);
		exec("/paqfs", arg);
		fatal("can't exec paqfs");
	default:
		break;
	}
	waitpid();

	close(p[1]);
	return p[0];
}
.
## diffname boot/embed.c 2002/1130
## diff -e /n/emeliedump/2002/0801/sys/src/9/boot/embed.c /n/emeliedump/2002/1130/sys/src/9/boot/embed.c
65c
		exec("/boot/paqfs", arg);
.
54c
		*argp++ = "/boot/paqfs";
.
31c
	dir = dirstat("/boot/paqfs");
.

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].