~kris/9p

9hist

ref: 2024b222b51463500b3f1e7c046cc36e28a4aadf 9hist/gnot/boot.c -rw-r--r-- 722 bytes
2024b222 — David du Colombier Plan 9 from Bell Labs 1990-03-10 36 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <u.h>
#include <libc.h>

#include "fcall.h"

Fcall	hdr;
char	buf[100];

void	error(char *);

main(int argc, char *argv[])
{
	int cfd, fd, n, fu, f;
	char buf[NAMELEN];
	int p[2];

	open("#c/cons", OREAD);
	open("#c/cons", OWRITE);
	open("#c/cons", OWRITE);

	do{
		print("user: ");
		n = read(0, buf, sizeof buf);
	}while(n==0 || n==1);
	if(n < 0)
		error("can't read #c/cons; please reboot");
	buf[n-1] = 0;
	print("hello %s!\n", buf);
	if(pipe(p) == -1)
		error("pipe");
	if(write(p[1], "hohoHO!", 8) != 8)
		error("write");
	if(read(p[0], buf, 8) != 8)
		error("read");
	print("%s\n", buf);
	for(;;);
}

void
error(char *s)
{
	char buf[64];

	errstr(0, buf);
	fprint(2, "boot: %s: %s\n", s, buf);
	exits(0);
}