Xref: utzoo unix-pc.sources:364 comp.sys.att:7292 Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!mailrus!rutgers!mit-eddie!bu-cs!att!dptg!holin!bes From: bes@holin.ATT.COM (Bradley Smith) Newsgroups: unix-pc.sources,comp.sys.att Subject: uipc.p4 Message-ID: <651@holin.ATT.COM> Date: 12 Aug 89 16:38:43 GMT Distribution: unix-pc Organization: AT&T Bell Labs, OIL, Holmdel, NJ Lines: 956 : This is a shar archive. Extract with sh, not csh. : This archive ends with exit, so do not worry about trailing junk. echo 'Extracting Files' sed 's/^X//' > Files << '+ END-OF-FILE Files' XSize XInstall XName XFiles XRemove XRemove.orig XVersion XFullname Xlib/libuipc.a Xpty.o Xsupport/socket_init Xuipc/conf.h Xuipc/domain.h Xuipc/fproto.h Xuipc/mbuf.h Xuipc/protosw.h Xuipc/socket.h Xuipc/socketvar.h Xuipc/un.h Xuipc/unpcb.h Xuipc/pty.h Xuipc/number-ptys.h + END-OF-FILE Files chmod 'u=rw,g=r,o=r' 'Files' echo ' -rw-r--r-- 1 bes HSJ 251 Aug 12 10:13 Files (as sent)' echo ' \c' /bin/ls -l Files echo 'Extracting Fullname' sed 's/^X//' > Fullname << '+ END-OF-FILE Fullname' XPty-Socket Driver Version 2.0 X----------------------------- XPty Code by Jens-Uwe Mager X XPty Code modified by Eric H. Herrin II X XSocket Code by Alex Crain. X XSocket Code modified and Pty Code X merged by Bradley Smith + END-OF-FILE Fullname chmod 'u=rw,g=r,o=r' 'Fullname' echo ' -rw-r--r-- 1 bes HSJ 215 Aug 12 10:16 Fullname (as sent)' echo ' \c' /bin/ls -l Fullname echo 'Extracting Install' sed 's/^X//' > Install << '+ END-OF-FILE Install' X# Eric H. Herrin II X# University of Kentucky Mathematical Sciences X# eric@ms.uky.edu, !cbosgd!ukma!eric X# X# Install script for System V Pty driver XSRCDIR=uipc XMODULE=pty X# put the module in the appropriate place Xcp ${MODULE}.o /etc/lddrv/${MODULE}.o Xchmod 700 /etc/lddrv/${MODULE}.o Xchown root /etc/lddrv/${MODULE}.o Xchgrp root /etc/lddrv/${MODULE}.o X# add the entry to the /etc/master file X/etc/masterupd -a char init open release close read write ioctl ${MODULE} X# get the assigned device number XMODULEDEVNO=`/etc/masterupd -c ${MODULE}` Xif [ ! ${MODULEDEVNO} ] Xthen X echo "${MODULEDEVNO} cannot be added to the /etc/master file" X exit 1 Xfi X# NOTE!!!!!!!!!!!!!! X# To change the number of ptys, change the value in number-ptys.h. X# VVVVVVV XPTYCNT=`grep NUMBER_OF_PTYS $SRCDIR/number-ptys.h | \ Xsed -e "s/#define//" -e "s/NUMBER_OF_PTYS//" -e "s/ //g"` Xecho "PTYCNT=$PTYCNT" > Remove Xcat Remove.orig >> Remove X# make the pty device files Xecho "Making pty pseudo device files" Xcnt=0 Xfor x in p q r s t u v w x y z Xdo X for y in 0 1 2 3 4 5 6 7 8 9 a b c d e f X do X i=$x$y X if [ $cnt -ge ${PTYCNT} ] X then X break X fi X /etc/mknod /dev/pty$i c ${MODULEDEVNO}\ X `expr $cnt + $PTYCNT` X /etc/mknod /dev/tty$i c ${MODULEDEVNO} $cnt X chown root /dev/tty$i /dev/pty$i X chgrp root /dev/tty$i /dev/pty$i X chmod 0666 /dev/tty$i /dev/pty$i X cnt=`expr $cnt + 1` X done Xdone X Xecho "Putting entry into InstDrv" X# put an entry in /etc/lddrv/InstDrv for ${MODULE} XV=`cat Version` Xecho "Name=${MODULE} driver: Version ${V}" >> /etc/lddrv/InstDrv Xecho "File=${MODULE}" >> /etc/lddrv/InstDrv Xecho "Comment=Pseudo tty and socket driver" >> /etc/lddrv/InstDrv X( Xcd /etc/lddrv X# allocate and load the module Xecho "Allocating pty module with lddrv" X./lddrv -av -o ${MODULE}.o ${MODULE} Xif [ $? -eq 0 ] Xthen X echo "Driver ${MODULE} successfully loaded" Xelse X echo "Error: Driver ${MODULE} failed loading stage" X exit 1 Xfi X) X X# load the ${MODULE} at boot time Xecho load the ${MODULE} at boot time Xecho ${MODULE} >> /etc/lddrv/drivers X Xecho "Loading support/socket_init to /etc/daemons" Xcp support/socket_init /etc/daemons/socket_init Xchmod 700 /etc/daemons/socket_init Xchown root /etc/daemons/socket_init X/etc/daemons/socket_init X Xecho "Pseudo tty drivers are now installed" X Xecho "Loading Libraries and /usr/include/uipc files" X Xcp lib/libuipc.a /usr/lib/libuipc.a Xchown bin /usr/lib/libuipc.a Xchgrp bin /usr/lib/libuipc.a Xchmod 644 /usr/lib/libuipc.a Xecho "/usr/lib/libuipc.a loaded..." X XUIPC=/usr/include/uipc Xmkdir ${UIPC} Xchown bin ${UIPC} Xchgrp bin ${UIPC} Xchmod 755 ${UIPC} X(cd uipc; find * -print | cpio -pvdum ${UIPC} ) Xchmod 644 ${UIPC}/* Xchown bin ${UIPC}/* Xchgrp bin ${UIPC}/* X X Xmessage -i `cat Fullname|sed 's/\$/\\\\n/'` Xexit 0 + END-OF-FILE Install chmod 'u=rwx,g=rx,o=rx' 'Install' echo ' -rwxr-xr-x 1 bes HSJ 2737 Aug 12 10:15 Install (as sent)' echo ' \c' /bin/ls -l Install echo 'Extracting Makefile' sed 's/^X//' > Makefile << '+ END-OF-FILE Makefile' X# X# @(#)Makefile 1.1 (Alex Crain) 6/20/89 X# X XSHELL=/bin/sh XTAR=/usr/bin/tar XCC=gcc XVFLAG= -v X XVersion=1.1 X XSOURCES=Makefile README BUGS sysconfig.m4 doc lib src test uipc X Xall: X cd src; make all CC=$(CC) VFLAG=$(VFLAG) X cd lib; make all CC=$(CC) VFLAG=$(VFLAG) X cd support;make CC=$(CC) VFLAG=$(VFLAG) X Xclean: X cd src; make clean X cd lib; make clean X cd test; make clean X cd support;make clean X Xremove: X sh Remove X Xinstall: all X sh Install X Xdist: X tar cvf uipc-$(Version).tar $(SOURCES) + END-OF-FILE Makefile chmod 'u=rw,g=r,o=r' 'Makefile' echo ' -rw-r--r-- 1 bes HSJ 489 Aug 12 09:35 Makefile (as sent)' echo ' \c' /bin/ls -l Makefile echo 'Extracting Mkflop' sed 's/^X//' > Mkflop << '+ END-OF-FILE Mkflop' Xecho Figuring out Size file X>Size Xcat Files | while read a;do X du -a $a; Xdone | awk 'BEGIN {X=0}{X+=$1}END{print X}' >Size X Xecho "Insert floppy disk and press return" Xread junk Xfind `cat Files` -print | cpio -oBc > /dev/fp021 + END-OF-FILE Mkflop chmod 'u=rwx,g=rx,o=rx' 'Mkflop' echo ' -rwxr-xr-x 1 bes HSJ 227 Aug 12 09:58 Mkflop (as sent)' echo ' \c' /bin/ls -l Mkflop echo 'Extracting Name' sed 's/^X//' > Name << '+ END-OF-FILE Name' XPty-Socket Driver Version 2.0 + END-OF-FILE Name chmod 'u=rw,g=r,o=r' 'Name' echo ' -rw-r--r-- 1 bes HSJ 30 Aug 12 10:13 Name (as sent)' echo ' \c' /bin/ls -l Name echo 'Extracting README' sed 's/^X//' > README << '+ END-OF-FILE README' XSee the file doc/README for information about this driver + END-OF-FILE README chmod 'u=rw,g=r,o=r' 'README' echo ' -rw-r--r-- 1 bes HSJ 58 Jul 18 23:43 README (as sent)' echo ' \c' /bin/ls -l README echo 'Extracting Remove' sed 's/^X//' > Remove << '+ END-OF-FILE Remove' XPTYCNT=8 X# Eric H. Herrin II X# University of Kentucky Mathematical Sciences X# eric@ms.uky.edu, eric@ms.uky.csnet, !cbosgd!ukma!eric X# X# Remove script for pty driver. XMODULE=pty X# remove the pty device files Xcnt=0 Xecho "Removing the pty device files" Xfor x in p q r s t u v w x y z Xdo X for y in 0 1 2 3 4 5 6 7 8 9 a b c d e f X do X i=$x$y X if [ ${cnt} -ge ${PTYCNT} ] X then X break X fi X /bin/rm -f /dev/pty$i X /bin/rm -f /dev/tty$i X cnt=`expr ${cnt} + 1` X done Xdone X# get rid of stuff in /etc/lddrv Xecho "removing InstDrv entries, etc." X/bin/rm -f /etc/lddrv/${MODULE}.o /etc/lddrv/${MODULE} \ X /etc/lddrv/ifile.${MODULE} Xgrep -v "^${MODULE}" /etc/lddrv/drivers > /tmp/XXX$$ Xmv /tmp/XXX$$ /etc/lddrv/drivers Xgrep -v "${MODULE}" /etc/lddrv/InstDrv > /tmp/XXX$$ Xmv /tmp/XXX$$ /etc/lddrv/InstDrv Xchmod +r /etc/lddrv/drivers /etc/lddrv/InstDrv Xchmod go-w /etc/lddrv/drivers /etc/lddrv/InstDrv Xchown root /etc/lddrv/drivers /etc/lddrv/InstDrv Xecho "Remove support, libraries and include files" Xrm /etc/daemons/socket_init Xrm -rf /usr/lib/libuipc.a /usr/include/uipc Xecho "Unloading Driver in /etc/lddrv" Xsync Xsync Xsync X/etc/lddrv/lddrv -d ${MODULE} Xsync Xsync Xecho "Removing /etc/master entry" X/etc/masterupd -d ${MODULE} + END-OF-FILE Remove chmod 'u=rwx,g=rx,o=rx' 'Remove' echo ' -rwxr-xr-x 1 bes HSJ 1225 Aug 12 10:27 Remove (as sent)' echo ' \c' /bin/ls -l Remove echo 'Extracting Remove.orig' sed 's/^X//' > Remove.orig << '+ END-OF-FILE Remove.orig' X# Eric H. Herrin II X# University of Kentucky Mathematical Sciences X# eric@ms.uky.edu, eric@ms.uky.csnet, !cbosgd!ukma!eric X# X# Remove script for pty driver. XMODULE=pty X# remove the pty device files Xcnt=0 Xecho "Removing the pty device files" Xfor x in p q r s t u v w x y z Xdo X for y in 0 1 2 3 4 5 6 7 8 9 a b c d e f X do X i=$x$y X if [ ${cnt} -ge ${PTYCNT} ] X then X break X fi X /bin/rm -f /dev/pty$i X /bin/rm -f /dev/tty$i X cnt=`expr ${cnt} + 1` X done Xdone X# get rid of stuff in /etc/lddrv Xecho "removing InstDrv entries, etc." X/bin/rm -f /etc/lddrv/${MODULE}.o /etc/lddrv/${MODULE} \ X /etc/lddrv/ifile.${MODULE} Xgrep -v "^${MODULE}" /etc/lddrv/drivers > /tmp/XXX$$ Xmv /tmp/XXX$$ /etc/lddrv/drivers Xgrep -v "${MODULE}" /etc/lddrv/InstDrv > /tmp/XXX$$ Xmv /tmp/XXX$$ /etc/lddrv/InstDrv Xchmod +r /etc/lddrv/drivers /etc/lddrv/InstDrv Xchmod go-w /etc/lddrv/drivers /etc/lddrv/InstDrv Xchown root /etc/lddrv/drivers /etc/lddrv/InstDrv Xecho "Remove support, libraries and include files" Xrm /etc/daemons/socket_init Xrm -rf /usr/lib/libuipc.a /usr/include/uipc Xecho "Unloading Driver in /etc/lddrv" Xsync Xsync Xsync X/etc/lddrv/lddrv -d ${MODULE} Xsync Xsync Xecho "Removing /etc/master entry" X/etc/masterupd -d ${MODULE} + END-OF-FILE Remove.orig chmod 'u=rwx,g=rx,o=rx' 'Remove.orig' echo ' -rwxr-xr-x 1 bes HSJ 1216 Aug 12 09:01 Remove.orig (as sent)' echo ' \c' /bin/ls -l Remove.orig echo 'Extracting Size' sed 's/^X//' > Size << '+ END-OF-FILE Size' X238 + END-OF-FILE Size chmod 'u=rw,g=r,o=r' 'Size' echo ' -rw-r--r-- 1 bes HSJ 4 Aug 12 10:25 Size (as sent)' echo ' \c' /bin/ls -l Size echo 'Extracting Version' sed 's/^X//' > Version << '+ END-OF-FILE Version' X2.0 + END-OF-FILE Version chmod 'u=rw,g=r,o=r' 'Version' echo ' -rw-r--r-- 1 bes HSJ 4 Aug 11 20:07 Version (as sent)' echo ' \c' /bin/ls -l Version if test -f 'doc' then rm 'doc' fi if test -d 'doc' then : else echo 'Making doc/' mkdir 'doc' fi chmod 'u=rwx,g=rx,o=rx' 'doc' echo 'Extracting doc/BUGS' sed 's/^X//' > doc/BUGS << '+ END-OF-FILE doc/BUGS' X X For some reason, the system will sometimes crash when unloading the Xdriver. The cause is always "page fault in kernal". Syncing the disk appears Xto prevent crashes, although I don't understand why. I have had good luck Xusing the following command sequence to unload the driver. X X # cd /etc/lddrv X # sync; X # sync X # sync X # ./lddrv -d uipc X XIf anyone can shed light on why this works, I would love to hear it. + END-OF-FILE doc/BUGS chmod 'u=rw,g=r,o=r' 'doc/BUGS' echo ' -rw-r--r-- 1 bes HSJ 412 Jul 18 23:43 doc/BUGS (as sent)' echo ' \c' /bin/ls -l doc/BUGS echo 'Extracting doc/README-FIRST' sed 's/^X//' > doc/README-FIRST << '+ END-OF-FILE doc/README-FIRST' X XFri Aug 11 20:13:06 EDT 1989 - Bradley Smith XCurrently at bes@holin.att.com or att!holin!bes X X* CURRENT README FILE FOR MERGE PTY & SOCKET LIBRARY/DRIVER X X XThis is a merged driver of the pty code (see Read-pty) and the socket Xcode (see Read-uipc) plus some inhancements. X XThis readme file will state what is new, how it works, what I know Xdoesn't work (because I haven't coded it) and so forth. X X XThe pty driver is the same, I added one thing. This is to get the Xmajor device number upon opening. This make easier for select Xto work (more on this later). The reason for merging pty driver Xis so that one can get at the structures easier. The pty driver Xcould be taken out and figured at load time, but this way I don't Xhave to worry about it. If I get enough complaints about this XI can remove the pty driver from the socket code. X XThe socket code is basically the same execpt for 2 more functions Xwhich are select and sosetup, and a file called linesw.c X X linesw.c is used for initialization, we reassign the linesw X functions of read, write and input so that we can check on X select function if it needs to be woken up. X X sosetup allows me to set the major device number of /dev/window X which on my machine is 7, but might not be on yours. X Also it allows me to set the address of wintty which is used X to see if input is on one of the windows. RIGHT NOW THIS IS X A SECURITY HOLE, IF ONE CALLS THIS FUNCTION AND SETS THE X WRONG NUMBERS, WHO KNOWS WHAT WILL HAPPEN. I PLAN ON FIXING X THIS BUT THE MAIL I AM RECEIVING ON THIS PROMPTS TO SEND IT X OUT NOW. ONCE AGAIN THIS IS FOR DEVELOPEMENT! X X X select(2) has been added. and it works currenly only on the X read bitmask. I plan on added the write soon but mail.... X anyways select works on the read side of the master (I tested X this), stdin of any window (I tested this), and of couse X and socket. Things I haven't tested are slave side of pty X (Code is there and should work, but you never know) and X /dev/tty00? (there is no code at all supporting this here) X and expansion card so I am not sure about anything other than X /dev/tty000) and /dev/ph? (same as /dev/tty000). X X X Also the timeout for select is a long for seconds. ie X X X long t; X X t = 10; X ret = select(32, &readbt, &writebt, &excepbt, &t); X X for timeout in 10 seconds. X X XThere is a support directory that contains the program to be used on Xstartup, install will put it in /etc/daemons so at boot time it gets Xdone. X XAlso I have include a version of vtem (vt100 emulator) which uses Xselect on the master side of pty and stdin. This version uses less Xsystem resources that the one posted which doesn't uses select but Xuses non-blocking i/o instead. X X XNOTE: if select doesn't work on stdin or pty, usually it means that Xthe driver didn't load right. X XMORE: I would like select to be able to use pipes....I will look Xat it but if anyone has an idea on it now, please let me know. X XEVEN MORE: It appears that on unloading the device driver that if you Xswitch windows (ie have more than one window open) it sometimes panics Xon you. Also I have run it under the regular 'cc' (for those who don't Xhave 'gcc') and gcc version 1.31 (yes I need to get a more up to date Xcopy). + END-OF-FILE doc/README-FIRST chmod 'u=rw,g=r,o=r' 'doc/README-FIRST' echo ' -rw-r--r-- 1 bes HSJ 3189 Aug 12 09:15 doc/README-FIRST (as sent)' echo ' \c' /bin/ls -l doc/README-FIRST echo 'Extracting doc/Read-pty' sed 's/^X//' > doc/Read-pty << '+ END-OF-FILE doc/Read-pty' XREADME: Eric H. Herrin II X University of Kentucky Mathematical Sciences Laboratories X 915 Patterson Office Tower X University of Kentucky X Lexington, KY 40506 X eric@ms.uky.edu, ..!cbosgd!ukma!eric X XVersion 2.1 X XThanks to X1. Mike "Ford" Ditto X kenobi!ford@crash.CTS.COM, ...!crash!kenobi!ford X for his bug fix in the ptyrelease routine. X2. Michael Bloom X mb@ttidca.tti.com X for his bug fix to the master read routine in the original driver. X I incorporated this fix and it seems to work fine. X XThis directory contains the PD pty driver for System V, modified for Xuse with the AT&T UnixPC or Convergent Technologies Safari 4 computers, Xrunning Version 3.51 of the UNIX System V OS (it may also work on Xearlier versions, but I have no way of verifying this). Anyone using Xthis driver should have no problems, but I will provide little support. XQuestions should be sent to the above address, either with ground mail Xor real (e-)mail. X X XThis README is intended to mark the changes made to the PD pty driver to Xsatisfy the author's request. It was not easy or feasible to clearly mark Xevery change in the code, thus it was decided that an explanation of the Xprocedure would probably be enough. A brief introduction to UnixPC Xdevice drivers is followed by the list of changes made. A couple of Xhacks will also be explained. X XNOTE: The #ifdef DEBUG statements use eprintf() instead of printf(). X This puts any messages into the error icon's queue of system X errors (the icon is the !! icon at the top of the console). X X XUnixPC device drivers: X X The UnixPC has a different kind of device driver from other XSystem V machines. They can be loaded while the machine is running or Xat boot time, but are always linked into the OS while the kernel is Xactive. However nice this may be, there ARE some problems. X X 1. Loadable device drivers CANNOT communicate with one another. X That is, one driver cannot use a data structure defined in X another driver (IE. they are not in the same identifier X name space). X 2. Conf.c doesn't exist, it is redone by the /etc/lddrv -av X program and relinked into the kernel. Thus, one can't X declare common structures this way. X X XChanges to the PD pty driver: X X The following changes (hacks?) were made to the PD pty driver for Xthe purpose of making it usable on the UnixPC. X X Problem 1 & 2 influenced me to try to make a single driver X (there were two, ptm and pts). How could one do this? X My solution (and I would be very interested if you can X think of a better one) was to create the slave devices X /dev/tty[p-z][0-f] with minor numbers 0-(PTYCNT/2-1) and X master devices /dev/pty[p-z][0-f] with minor numbers X (PTYCNT/2)-(PTYCNT-1). Major numbers of both types of devices X are the same. I can then simply define a macro to determine X whether the dev_t passed to the driver was a slave or master X pty. Once determined, I can perform the appropriate duties. X Also, it was more readable to merge the ptm and pts modules X into a single set of pty[open, close, ioctl, read, write] X routines. I added a release routine so that the kernel will X know the device has properly released if one deallocates X the driver. X Another modification was the addition of ptystate[], which X holds the MRWAIT, MWWAIT, MOPEN flags. This was necessary X because the original author insisted upon using 3 UNUSED X bits in the t_state field of the tty. The UnixPC does not X have any free bits here. X A check for TTIOW was added due to the fix by Michael X Bloom in the master section of the ptyread() routine. Note X his original fixes were for the original pty driver and X most of the changes were already incorporated into this driver. X XMaking alterations to the number of ptys, etc. X The number of ptys is defined in the file number-ptys.h. This X number should not exceed the maximum minor device number divided by X two. Ie. a maximum minor device number of 128 would allow X a maximum of 64 ptys. It is currently defined at only 32, but X I believe this is quite liberal, especially for a machine as X small as a 3b1. One could load the driver multiple times by X calling it a different name in the /etc/master file. One could X have the first 64 ptys with major number 10, the next 64 with X major number 11, etc. I think 64 should do fine for any reasonable X UNIX PC user (good grief, how would one use 64 ptys on a max X 5 user machine? Better yet, how would one get 5 users on the X thing? Yuch!). At any rate, we don't use that many ptys on X a large system with lots of users.... so I really don't see this X as a problem. X X XPty driver generation and installation procedure. X Put the number of ptys you want in the file number-ptys.h. X Type "make" X Type "/bin/sh MKflop" X Insert a floppy diskette. X Use the UA to install the diskette. X (you can skip the floppy part and simply run the Install script X in the same directory the pty.o object is located. But you X won't be able to uninstall it from the UA. There is a X Remove script to do this which you will have to run manually.) X XAcknowledgement: I realize the usage of a single major device number is Xa supreme hack, and I welcome any improvements/solutions. I do not assume Xany responsibility for the changes I have made, nor do I imply any Xliability on the part of the original author. I include a complete set Xof {Install, Remove, etc, etc} scripts so that binary floppies may be Xmade to be installed by the UnixPC user agent. I do not assume any Xresponsibility for these either. I don't assume any responsibility for Xanything even remotely related to this stuff. X X X Eric H. Herrin II X University of Kentucky Mathematical Sciences Laboratories X eric@ms.uky.edu, !cbosgd!ukma!eric X X=======================Orignal pty README=============================== XThis is a pseudo tty driver for system V machines. It works very Xsimilar to ptys on BSD, for instance emacs works fine. To install this Xdriver you will need to modify your `master' and `dfile' file which Xcontains your driver specifications. As these vary from machine to machine, Xyou will have to look up in your manual how to do that. Here is an example Xfor a sperry s5050 alias ncr tower 32 : X XAdd the following two lines to the driver description section in master: Xpts 0 237 244 pts 0 0 28 32 0 tty Xptm 0 37 344 ptm 0 0 29 0 0 X XThis says there are max 32 pts devices at major number 28 having associated Xtty structures and 0 ptm devices having major number 29 with no associated Xdata. The number of ptm devices is not configurable, as this depends on the Xnumber of pts's. X XThe following two lines go in the dfile: Xpts 0 0 0 Xptm 0 0 0 X XProbably you will also want to increase the NCLIST parameter. X XIf your configuration procedure is different, you must change the shell Xscript mkpty, which is used to create the device nodes in /dev. X XThe ptm devices (/dev/pty[p-z][0-9a-f]) are the controlling ones, everything Xwritten there will show up at the associated pts device X(/dev/tty[p-z][0-9a-f]), as well as erverything which is written on the pts Xdevice will show up on the ptm device. The pts side will accept the usual Xtermio ioctl calls. The master side is a bit different, as ioctl calls which Xnormally wait for output to drain flush output. The reason for this funny Xbehaviour is that otherwise the master side will hang. Also the master side Xmay be opened only once, further open calls will result in an EBUSY error. + END-OF-FILE doc/Read-pty chmod 'u=rw,g=r,o=r' 'doc/Read-pty' echo ' -rw-r--r-- 1 bes HSJ 7588 Aug 11 20:12 doc/Read-pty (as sent)' echo ' \c' /bin/ls -l doc/Read-pty echo 'Extracting doc/Read-uipc' sed 's/^X//' > doc/Read-uipc << '+ END-OF-FILE doc/Read-uipc' X %Z%%M% %I% (Alex Crain) %G% X X This package contains a device driver to implement BSD style Xsockets on an AT&T 3b1. It is written for unix release 3.51 and Xcompiled using gcc, I don't know if it will work with a different XOS/compiler combination. X X The code is directly derived from Berkeley kernel source, and Xcarries the Berkeley Copyright. I have added my own Copyright as well, Xalthough I question its legality and I don't really much care what Xhappens to the code as long as nobody *sells* it (giving away is OK) Xand my name stays on it. X X The code is far from complete. At this writing, only the XAF_UNIX domain is supported, and SOCK_RAW is not implemented. Within Xthese restraints, the code implements the following system calls: X X socket () X bind () X listen () X accept () X connect () X socketpair () X sockpipe () X sendto () X send () X recvfrom () X recv () X setsockopt () X getsockopt () X X The code has also not been adaquately tested and surely has Xbugs. Since the interface routines are true system calls, the bugs Xare likely to cause panics and other types of system crashes, so use Xthis driver at your own risk. Bug reports are encouraged, as are Xenhancements and extensions within the realm of BSD compatability. XSend bug reports and patches to: X X alex%nerwin.uucp@umbc3.umbc.edu X X or X X uunet!umbc3!nerwin!alex X X The documentation is miserable, I will try to do better. X X The system files are: X X src/* - the c source files X uipc/* - the header files X lib/* - the user interface library X test/* - misc. test programs X Makefile- the global makefile X sysconfig.m4 - the system configuration file X XTo install the system, type 'make' in the root directory. This will Xcreate two interesting files: src/uipc.o and lib/libuipc.a. uipc.o Xgoes in the /etc/lddrv directory. Add the following line to X/etc/master: X Xuipc 1100 000 000 uipc 0 0 X Xand type: X X cd /etc/lddrv; ./lddrv -av uipc X Xto load the driver. To make the driver load at boot tome, add "uipc" Xto the file /etc/lddrv/drivers. X XPut libuipc.a in /usr/lib, and copy the uipc directory to X/usr/include/uipc. X X X X Again, please be aware that this code is delicate and likely Xto cause crashes. If appropriate precautions are taken, however, it is Xpossible to avoid trashing your system. When testing device drivers Xand code that uses them: X X 1) make sure that the system is quiet. Open files may be Xdamaged or lost when the kernel crashes. Do not test the driver when Xuucico is running. X X 2) don't do two things at once. Get out of the editor before Xtesting new code. X X 3) type "sync" before running new code. This will flush the Xkernels internal buffers. DO NOT run sync immediately after testing Xnew code, because if the kernel has trashed buffers, they will be Xwritten to disk. Instead, run "ls" a few times to see if the system is Xgoing to crash. X X 4) Do not install code that uses this package until it becomes Xmore stable. It might work for a while, but is likely to cause crashes Xat in oppertune times. X X The code is heavily protected with calls to panic(), so it is Xdoubtful that any major damage will result (I have crashed many times Xwhile writing this and have yet to lose a file) if the precautions are Xtaken. The code will be better tested and documented soon, so if you Xdon't want to beta test, you can wait. In any case, X X Enjoy X X Alex Crain + END-OF-FILE doc/Read-uipc chmod 'u=rw,g=rw,o=rw' 'doc/Read-uipc' echo ' -rw-rw-rw- 1 bes HSJ 3338 Jul 18 23:43 doc/Read-uipc (as sent)' echo ' \c' /bin/ls -l doc/Read-uipc echo 'Extracting doc/post1' sed 's/^X//' > doc/post1 << '+ END-OF-FILE doc/post1' X X CALL FOR DISCUSSION X X Topic: Serial line networking of unix-pc's. X X As my efforts to produce a working socket driver for the Xunix-pc are generating positive results (it works), The looming Xquestion of how to interconnect machines is becomming more pertenant. Xlike many people, I bought a large machine and later a small machine Xas a future parts doner, and getting the two of them to talk would be Xright nice. I'm running a uucp network now, but I'd really like some Xkind of packet base protocol. With the TCP driver taking shape, the Xidea is becomming more attractive. X X For myself, I would like to run a bus network around my house, Xconsisting of a single serial line. I will probably purchase a mac as Xa game machine/graphics engine/word processor for my wife in the next Xyear or so, and I would like to pick up a nice printer, an maybe a Xtrailblazer. Also, I never want to buy a peripheral from apple! (nobody Xhas that much money) X X So I'm figureing my network to be: X X HARDWARE X X 1) a bi-directional bus network, or some kind of fault-tolerant ring X that can tell when a host goes down. No star networks. I only want to X have to deal with one port per machine, and I want to be able to splice X in devices. X X 2) RS232 or simular hardware speeds and voltage levels. ($$$) X X 3) hardware support for packet acceptance/rejection, and queueing of X data so that the machines don't die. X X SOFTWARE X X 1) support for virtual circuits and datagrams, with out-of-band X facilities. X X 2) reasonable efficency with in packet overhead. X X 3) gateway/forwarding capability, for dealing with modems and printers. X This means machine addresses and ports. X X 4) virtual files, as in some kind of restricted NFS. X XI think that some kind of minimal hardware support is going to be Xrequired for speed, but I'd like to make that an option, so that poor Xfolks can use the existing RS232. I envision a card that watches the Xnet and screens packets against their address. I would also like at Xleast 16 bytes of buffer space with a timeout, to limit interrupts. X XI'd also like to use an existing protocol, custom protocols are a drag Xunless they catch on, even free ones. The two protocols that come to Xmind are SLIP and Appletalk. SLIP would be in keeping with tradition, Xbut I'm worried about the overhead. I don't know anything about XAppletalk, but the fact that its built around a serial line suggests Xthat its optimized for speed. The fact that I'm looking at a mac also Xmakes Appletalk more desireable :-). X XAlso, Appletalk hardware is pretty close to what I'm looking for, Xalthough I don't know much about it. Appletalk also supports some kind Xof disk sharing that works over a serial line. X XI will probably add the code for SLIP anyway, since much of the code Xis free and available. I'm looking into a protocol developed at CMU Xthats built around Appletalk, and if the code is free, I'll look into Xadding that to, if only for my future mac. X XSo what does everybody think? I want to write something thats going to Xbe *used*, although I won't be charging for it. What are your needs? I Xdon't know diddly about hardware, so I would like to here from the Xhardware guys regarding the interface. Optimally we would see the same Xdeal as the hard disk upgrade, namely a "lenny and gil do it yourself" Xmodel and a "custom PAL on a special board for $$" version. X X X X X + END-OF-FILE doc/post1 chmod 'u=rw,g=rw,o=rw' 'doc/post1' echo ' -rw-rw-rw- 1 bes HSJ 3350 Jul 18 23:43 doc/post1 (as sent)' echo ' \c' /bin/ls -l doc/post1 if test -f 'support' then rm 'support' fi if test -d 'support' then : else echo 'Making support/' mkdir 'support' fi chmod 'u=rwx,g=rx,o=rx' 'support' echo 'Extracting support/Makefile' sed 's/^X//' > support/Makefile << '+ END-OF-FILE support/Makefile' X# CC=gcc XCFLAGS=-O $(VFLAG) X Xsocket_init: X $(CC) $(CFLAGS) -o socket_init socket_init.c ../lib/libuipc.a X X Xclean: X rm -f socket_init core *.o + END-OF-FILE support/Makefile chmod 'u=rw,g=r,o=r' 'support/Makefile' echo ' -rw-r--r-- 1 bes HSJ 142 Aug 12 09:24 support/Makefile (as sent)' echo ' \c' /bin/ls -l support/Makefile echo 'Extracting support/socket_init.c' sed 's/^X//' > support/socket_init.c << '+ END-OF-FILE support/socket_init.c' X#include X#include X#include X#include X#include X X#define WINTTY 0 X X/* struct nlist */ Xstruct nlist nl[] = { X {"wintty"}, X {0} X}; X Xmain() X{ X int ret, i; X unsigned u; X struct stat st; X X ret = nlist("/etc/lddrv/wind", nl); X if(ret < 0) { X perror("nlist on /etc/lddrv/wind"); X exit(1); X } X ret = stat("/dev/window", &st); X if(ret < 0) { X perror("stat on /dev/window failed!"); X exit(1); X } X i = major(st.st_rdev); X u = (unsigned int) nl[0].n_value; X sosetup(i,u); X} + END-OF-FILE support/socket_init.c chmod 'u=rw,g=r,o=r' 'support/socket_init.c' echo ' -rw-r--r-- 1 bes HSJ 530 Aug 11 20:05 support/socket_init.c (as sent)' echo ' \c' /bin/ls -l support/socket_init.c echo 'Extracting sysconfig.m4' sed 's/^X//' > sysconfig.m4 << '+ END-OF-FILE sysconfig.m4' Xifelse(REALTIME,1,`divert(-1)') X# X# @(#)sysconfig.m4 1.1 (Alex Crain) 6/20/89 X# X# System call definition file X# X# each line should be a DEFSYSCALL macro, where the X# arguments are the number of arguments that the X# syscall expects and the syscall name. X# X# the syscall number for syslocal() X# Xdefine(SYSL_SYSCALL, 67) X# X# the offset of the last known local system call. X# Xdefine(SYSENT_OFFSET,18) X# X# the offset of the first new system call in the sysentries[] array X# Xdefine(SYSENT_START,incr(SYSENT_OFFSET)) Xifelse(REALTIME,1,`divert') X XDEFSYSCALL(3,socket) XDEFSYSCALL(3,bind) XDEFSYSCALL(2,listen) XDEFSYSCALL(3,accept) XDEFSYSCALL(3,connect) XDEFSYSCALL(4,socketpair) XDEFSYSCALL(1,sockpipe) XDEFSYSCALL(6,sendto) XDEFSYSCALL(4,send) XDEFSYSCALL(6,recvfrom) XDEFSYSCALL(4,recv) XDEFSYSCALL(5,setsockopt) XDEFSYSCALL(5,getsockopt) XDEFSYSCALL(4,soselect) XDEFSYSCALL(2,sosetup) + END-OF-FILE sysconfig.m4 chmod 'u=rw,g=r,o=r' 'sysconfig.m4' echo ' -rw-r--r-- 1 bes HSJ 868 Aug 11 22:24 sysconfig.m4 (as sent)' echo ' \c' /bin/ls -l sysconfig.m4 exit 0 -- Bradley Smith Computer Systems Offer Integration Laboratory AT&T Bell Labs, Holmdel, NJ 201-949-0090 att!holin!bes or bes@holin.ATT.COM