Thread (4 messages) 4 messages, 3 authors, 2001-02-01

RE: which errno should I use

flat view

From: Ian Abbott <abbotti@mev.co.uk>
Date: 2001-01-31 18:48:23

On Tuesday, January 30, 2001 4:53 PM, Ralph Blach
[off-list ref] wrote:
I am writing a character device driver.  I want this device driver to
return an error if the user request less than say 1024 byte of data.
What errno should I use?  Is it legal to return an error if not enouth
bytes are requested?
I have a similar driver that wants exactly one long's worth of data to
be read. If the supplied buffer is smaller than a long, I return 0,
otherwise I return sizeof(long) (assuming their are no other errors).
Admittedly this does not let the user level distinguish "buffer too
small" from "no data", but I let the programmer at the user level deal
with that! Just mention it in the documentation for your driver, if
there is any.

Wolfgang Denk suggested EINVAL. I didn't use that as the man page for
read(2) says that means "fd is attached to an object which is unsuitable
for reading." There's no harm in overloading this meaning though. Just
document what your driver does.

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help