Re: your mail

From: Richard B. Johnson
Date: Wed Dec 03 2003 - 10:46:38 EST

On Wed, 3 Dec 2003, Bloch, Jack wrote:

> I try to open a non-existan device driver node file. The Kernel returns a
> value of -1 (expected). However, when I read the value of errno it contains
> a value of 29. A call to the perror functrion does print out the correct
> error message (a value of 2). Why does this happen?
> Jack Bloch
> Siemens ICN
> phone (561) 923-6550
> e-mail jack.bloch@xxxxxxxxxxxxxxx

Because it doesn't happen! You are likely polluting the errno
variable either with another system call before you test it
or by not including the correct header file (errno may be a

Try this program:

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>

int main(int args, char *argv[])
int fd, save_errno;
if(args < 2) {
fprintf(stderr, "Usage:\n%s <filename>\n", argv[0]);
if((fd = open(argv[1], O_RDONLY)) < 0) {
save_errno = errno;
fprintf(stderr, "Was %d (%s)\n", save_errno, strerror(save_errno));
return 0;

Script started on Wed Dec 3 10:41:24 2003
# ./xxx /dev/XXX
open: No such file or directory
Was 2 (No such file or directory)
# ./xxx /dev/VXI
open: Operation not supported by device
Was 19 (Operation not supported by device)
# exit
Script done on Wed Dec 3 10:42:12 2003

Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at