[PATCH] ENODEV

Andries.Brouwer@cwi.nl
Sat, 20 Feb 1999 00:12:36 +0100 (MET)


In my previous letter I remarked that the program

#include <fcntl.h>
#include <errno.h>
int main(){
if(open("/dev/hdd", O_RDONLY) < 0) perror("hdd");
if(open("/dev/hde", O_RDONLY) < 0) perror("hde");
return 0;
}

outputs (on a machine with hdc and without hdd and hde):

hdd: Device not configured [ENXIO]
hde: Operation not supported by device [ENODEV]

which looks a bit silly, and suggested that perhaps ide.c
should be adapted. But I changed my mind: the IDE driver is right
and it is devices.c that is wrong.

Look at the definitions of these errors:

ENODEV: An attempt was made to apply an inappropriate
function to a device; for example, trying to
read a write-only device such as a printer.

ENXIO: Input or output on a special file referred to a
device that did not exist, or made a request
beyond the limits of the device.

Clearly then, in devices.c:blkdev_open(), if someone refers to a major
that is unknown, we should return ENXIO.

--- devices.c~ Wed Dec 23 20:39:49 1998
+++ devices.c Fri Feb 19 23:46:56 1999
@@ -228,7 +228,7 @@
*/
int blkdev_open(struct inode * inode, struct file * filp)
{
- int ret = -ENODEV;
+ int ret = -ENXIO;
filp->f_op = get_blkfops(MAJOR(inode->i_rdev));
if (filp->f_op != NULL){
ret = 0;

Andries

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/