Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <../boot/boot.h>
4
 
5
char *fparts[] =
6
{
7
	"add bootldr	0x0000000 0x0040000",
8
	"add params	0x0040000 0x0080000",
9
	"add kernel	0x0080000 0x0140000",
10
	"add user	0x0140000 0x0200000",
11
	"add ramdisk	0x0200000 0x0600000",
12
};
13
 
14
void
15
configpaq(Method*)
16
{
17
	int fd;
18
	int i;
19
 
20
	if(bind("#F", "/dev", MAFTER) < 0)
21
		fatal("bind #c");
22
	if(bind("#p", "/proc", MREPL) < 0)
23
		fatal("bind #p");
24
	fd = open("/dev/flash/flashctl", OWRITE);
25
	if(fd < 0)
26
		fatal("opening flashctl");
27
	for(i = 0; i < nelem(fparts); i++)
28
		if(fprint(fd, fparts[i]) < 0)
29
			fatal(fparts[i]);
30
	close(fd);
31
}
32
 
33
int
34
connectpaq(void)
35
{
36
	int  p[2];
37
	char **arg, **argp;
38
 
39
	print("paq...");
40
	if(pipe(p)<0)
41
		fatal("pipe");
42
	switch(fork()){
43
	case -1:
44
		fatal("fork");
45
	case 0:
46
		arg = malloc(10*sizeof(char*));
47
		argp = arg;
48
		*argp++ = "paqfs";
49
		*argp++ = "-v";
50
		*argp++ = "-i";
51
		*argp++ = "/dev/flash/ramdisk";
52
		*argp = 0;
53
 
54
		dup(p[0], 0);
55
		dup(p[1], 1);
56
		close(p[0]);
57
		close(p[1]);
58
		exec("/boot/paqfs", arg);
59
		fatal("can't exec paqfs");
60
	default:
61
		break;
62
	}
63
	waitpid();
64
 
65
	close(p[1]);
66
	return p[0];
67
}