jackm@jpl-devvax.JPL.NASA.GOV (Jack Morrison) (02/04/89)
Oh mighty wizards of device drivers: I have written a simple driver for a parallel port on a Sun 3/260. Everything works except for one thing: close() returns an error status (-1), with errno=1 (not owner). The device entry is c-w--w--w- 1 root 63, 0 Feb 2 15:07 /dev/vs0 My test program calls open("/dev/vs0", 1), which returns a valid fd. If I then call close(fd), all is fine. If I write(fd, buf, n) first, the time on the /dev entry changes, and the data actually goes out properly; then when I call close, the /dev entry goes back to its previous time and close(fd) returns -1. If I do this as root, or if I chown the /dev entry to my username, close() returns 0. If I go through the same motions with /dev/null, close() returns 0 and the time on the /dev/null entry remains updated after the close (the owner stays root). Changing permissions on /dev/vs0 doesn't help. My driver always returns 0 from a vsclose() call. If more than one process opens /dev/vs0, only the last process to close it gets the error (the kernel shouldn't call the driver close() routine until the last process closes the device). Any ideas? Many thanks. -- Jack C. Morrison, Jet Propulsion Laboratory "How am I typing? Call 1-818-354-3722, or mail jack@robotics.jpl.nasa.gov"
fnf@estinc.UUCP (Fred Fish) (02/06/89)
In article <4369@jpl-devvax.JPL.NASA.GOV> jackm@devvax.JPL.NASA.GOV (Jack Morrison) writes: >I have written a simple driver for a parallel port on a Sun 3/260. >Everything works except for one thing: close() returns an error >status (-1), with errno=1 (not owner). I don't know if it is related or not, but under SunOS 4.0 on a Sun-4, a close() on the tape device /dev/rst8, after writing data to the tape, returns a -1 with errno=EPERM. Apparently none of the standard UNIX utilities that write to the tape drive bother to check the return status of close()... :-( -Fred -- # Fred Fish, 1835 E. Belmont Drive, Tempe, AZ 85284, USA # 1-602-491-0048 asuvax!{nud,mcdphx}!estinc!fnf