jackm@jpl-devvax.jpl.nasa.gov (Jack Morrison) (02/14/89)
Attention device driver wizards: I've written a simple driver for a parallel port card on a Sun. The driver works fine, with one exception: close() returns a -1 with errno == 1. Details: The device entry is c-w--w--w- 1 root 63, 0 Feb 2 13:40 /dev/vs0 My test program does open("/dev/vs0", 1) [which succeeds and returns an fd], write(fd, buf, n) [which succeeds, returning n and actually outputting the data], and close(fd). If I skip the write(), close returns 0. If I *do* write, the date (but not owner) of the /dev/vs0 entry changes; then when I close, I get the error, and the date on /dev/vs0 *goes back* to the way it was. If I'm root when I do this, of course, there is no error on close() and the updated /dev/vs0 entry *stays* updated. Likewise if I manually chown /dev/vs0 to my non-root ID. If I go through the same motions on /dev/null, everything works as expected (i.e. everything is the same except that close() succeeds, even as non-root, and the date on /dev/null stays updated). If I open()/write()/close() the device while another process already has it open, the first one to close() gets a good status back (the device driver is not called in this case), but the last one to close still gets the error. My driver ALWAYS returns zero from vsclose(). I've tried: - changing permissions on /dev/vs0 (777, 666) - opening with append, truncate, ... Any clues????? Thanks much. -- Jack C. Morrison, Jet Propulsion Laboratory