Help: close() returns -1
Jack Morrison
jackm at jpl-devvax.JPL.NASA.GOV
Sat Feb 4 02:46:06 AEST 1989
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 at robotics.jpl.nasa.gov"
More information about the Comp.unix.wizards
mailing list