9fans archive / 2000 / 08 / 43 / prev next
From: presotto@pla...
Subject: Re: [9fans] Re: your mail
Date: Tue, 1 Aug 2000 21:24:42 -0400
We changed the cpu protocol between editions. The change was
to get rid of the second connection for notes. This was a good
suggestion from Dave Mazieres at MIT.
You can convert the 2ed cpu.c to run on 3ed. Here's the
diffs:
% diff cpu.c /sys/src/cmd/ocpu.c
21a22
> int filter(int);
26a28
> int fflag;
30,31c32,33
< char *srvname = "cpu";
< char *notesrv = "cpunote";
---
> char *srvname = "ocpu";
> char *notesrv = "ocpunote";
39a42
> int fdd;
50a54,56
> case 'f':
> fflag++;
> break;
109a116,118
> if(fflag)
> data = filter(data);
>
124a134
> va_list arg;
126c136,138
< doprint(buf, buf+sizeof(buf), fmt, (&fmt+1));
---
> va_start(arg, fmt);
> doprint(buf, buf+sizeof(buf), fmt, arg);
> va_end(arg);
183a196
>
185c198,202
< if(amount(fd, "/mnt/term", MREPL, "") < 0)
---
>
> /* push fcall */
> if(fflag)
> fd = filter(fd);
> if(amount(fd, "/mnt/term", MCREATE|MREPL, "") < 0)
282a300
> char dir[4*NAMELEN];
285c303
< if((*fd = dial(na, 0, 0, 0)) < 0)
---
> if((*fd = dial(na, 0, dir, 0)) < 0)
288a307,308
> if(strstr(dir, "tcp"))
> fflag = 1;
318a339,366
>
> /* Network on fd1, mount driver on fd0 */
> int
> filter(int fd)
> {
> int p[2];
>
> if(pipe(p) < 0)
> fatal(1, "pipe");
>
> switch(rfork(RFNOWAIT|RFPROC|RFFDG)) {
> case -1:
> fatal(1, "rfork record module");
> case 0:
> dup(fd, 1);
> close(fd);
> dup(p[0], 0);
> close(p[0]);
> close(p[1]);
> execl("/bin/aux/fcall", "fcall", 0);
> fatal(1, "exec record module");
> default:
> close(fd);
> close(p[0]);
> }
> return p[1];
> }
>
You also need to create the /rc/bin/service files on 3ed for
the 2ed ports:
% cat > /rc/bin/service/il17006 << EOF
#!/bin/rc
exec /bin/ocpu -R
EOF
% cat > /rc/bin/service/il17006 << EOF
#!/bin/ocpu -N
EOF
% cat > /rc/bin/service/tcp17005 << EOF
#!/bin/rc
exec /bin/ocpu -f -R
EOF
% cat > /rc/bin/service/tcp17006 << EOF
#!/bin/ocpu -N
EOF
% chmod +x /rc/bin/service/*1700[56]
You can then use ocpu to get back to 2ed.
I'll put these puppies in the next update.