Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!samsung!aplcen!haven!udel!mmdf From: postmaster@att-in.att.com Newsgroups: comp.os.minix Subject: (none) Message-ID: <8384@nigel.udel.EDU> Date: 16 Jan 90 17:10:55 GMT Sender: mmdf@udel.EDU Lines: 127 Mail to `att.att.com!attmail!mhs!envoy!ics.test/pn=_test_group' alias `att!attmail!mhs!envoy!ics.test/pn=_test_group' from 'VM1.NoDak.EDU!INFO-MINIX%UDEL.EDU' failed. The error message was: destination unknown or forwarding disallowed The message began: Received: from NDSUVM1.BITNET by VM1.NoDak.EDU (IBM VM SMTP R1.2.1MX) with BSMTP id 0558; Tue, 16 Jan 90 06:52:46 CST Received: from NDSUVM1.BITNET by NDSUVM1.BITNET (Mailer R2.03B) with BSMTP id 0545; Tue, 16 Jan 90 06:52:45 CST Date: Sun, 14 Jan 90 23:47:34 GMT Reply-To: INFO-MINIX%UDEL.EDU@VM1.NoDak.EDU Sender: Minix operating system Comments: Warning -- original Sender: tag was info-minix-request@UDEL.EDU From: Tony Mcgregor Subject: Bug in portio.c + fix Comments: To: info-minix@udel.edu To: Multiple recipients of list MINIX-L There is a bug in the 1.5.0 lib/other/portio.c that means port reads and writes can't be mixed within a single program. This caused a problem with readclock. A fix follows. #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # portio.c # portio.crc # This archive created: Mon Jan 15 10:43:38 1990 export PATH; PATH=/bin:/usr/bin:$PATH if test -f 'portio.c' then echo shar: "will not over-write existing file 'portio.c'" else cat << \SHAR_EOF > 'portio.c' /* Port i/o functions using /dev/port. * Callers now ought to check the return values. * Calling either of these functions consumes a file descriptor. */ #include #include #include #include #define P_READ 1 #define P_WRITE 2 PRIVATE int portfd = -1; PRIVATE int mode_opened = 0; int port_in(port, valuep) unsigned port; unsigned *valuep; { unsigned char chvalue; if ( !( mode_opened & P_READ )) { if ( mode_opened & P_WRITE ) { close(portfd); portfd = open("/dev/port", O_RDWR); } else { portfd = open("/dev/port", O_RDONLY); } mode_opened |= P_READ ; } if (portfd < 0 || lseek(portfd, (long) port, 0) < 0 || read(portfd, (char *) &chvalue, (size_t) 1) != 1) return(*valuep = -1); return(*valuep = chvalue); } int port_out(port, value) unsigned port; unsigned value; { unsigned char chvalue; chvalue = value; if ( !( mode_opened & P_WRITE )) { if ( mode_opened & P_READ ) { close(portfd); portfd = open("/dev/port", O_RDWR); } else { portfd = open("/dev/port", O_WRONLY); } mode_opened |= P_WRITE ; } if (portfd < 0 || lseek(portfd, (long) port, 0) < 0 || write(portfd, (char *) &chvalue, (size_t) 1) != 1) return(-1); return(chvalue); } SHAR_EOF fi if test -f 'portio.crc' then echo shar: "will not over-write existing file 'portio.crc'" else cat << \SHAR_EOF > 'portio.crc' CRCS: 61685 1345 1.5.0_portio.c 20209 1350 fixed_portio.c SHAR_EOF fi exit 0 # End of shell archive PS Please forgive me if I stuffed-up; this is my first posting. ---------------------------------------------------------------------------- Tony McGregor Department of Robotics and Digital Tech., Chisholm Institute of Technology PO Box 197, Caulfield East, Vic 3145, Australia Phone: +61 3 5732014 Fax: +61 3 5732748 ACSNET: ajm@cit5.cit.oz ----------------------------------------------------------------------------