johnl@ima.UUCP (04/26/85)
The chaosnet implementation for 4.1 was largely my fault (we started with some pretty reasonable code from IIASA, but it had never been near real Chaos hardware before, nor interchanged packets with any other Chaos hosts until we pounded on it at Yale 5 years ago.) There was some surprisingly nice kernel hackery to allow multiple opens on the same I-node for different connections, and to allow the driver to parse the trailing part of /dev/chaos/kaflooga. Passing the "kaflooga" to the driver was simplicity itself. I had but to add one line to nami() which returned a success status if it ever found itself looking at a character special file with the sticky bit set. At that point, the various pointers in the U. block are all set up so that the device open routine can retrieve the rest of the name with uchar(). Truly a great hack, due to the IIASA people. The multiple channel stuff appeared to be adapted from the V7 MPX file stuff. What it did was to pun the seek offset in the kernel's per-open "file" structure to be a pointer to a per-connection structure in the device driver set up at open time. To avoid accidental system crashes, we implemented a FMPX status bit in the file structure (already defined in the V7 source; this had clearly been done before.) This bit disallowed seek calls, since there was no seek pointer for such files, and fiddled the close() logic so that it bypassed the usual logic that avoids calling a device close routine when a special file is multiply open. This was also a minor kernel change, less than 10 lines outside the driver, which did just what we wanted. I'm not going to claim that this pair of kernel tweaks is a substitute for a general scheme which allows a process to completely simulate a file, including processing all of the client's system calls. But if you want to put in something like labelled tapes or the chaos stuff in a finite amount of time, it's not a bad way to go. John Levine, Javelin Software, Cambridge MA 617-494-1400 { decvax!cca | think | ihnp4 | cbosgd }!ima!johnl, Levine@YALE.ARPA