Re: [PATCH] remove TCGETS
Linus Torvalds <[email protected]> Tue, 28 Oct 2003 17:54:10 -0800 (PST)
| Newsgroups | gmane.linux.file-systems,gmane.comp.file-systems.intermezzo.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 28 Oct 2003, Andrew Sharp wrote:
>
> Can't we add the range of tty ioctls to file_ioctl so that it can return
> ENOTTY so each and every file system driver doesn't have to?
Sure. But the filesystem has to return some error _anyway_ for the other
ioctl's it doesn't understand. So what errno would you suggest?
ENOTTY is the one that is what a regular file returns to _all_ ioctl's it
doesn't understand. That's really my point here. ENOTTY is always the
right thing to return - and it has nothing to do with whether the ioctl
number was for a TTY-specific ioctl or not.
Yeah, it's not a very well-named error, but if you actually look at what
glibc prints out, it says
ENOTTY: Inappropriate ioctl for device
and you can test with this extremely stupid program:
test.c:
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int i;
int fd = open("test.c", O_RDONLY);
srandom(time(NULL));
for (i = 0; i < 100; i++) {
ioctl(fd, random(), 0);
perror("ioctl");
}
}
and verify for youself that it returns ENOTTY regardless of whether the
ioctl number was a TTY-specific one or not.
So to re-iterate: ENOTTY is what everybody _always_ should return if they
don't recognize a number. No "number ranges" involved.
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html