linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* (no subject)
@ 2003-12-03 15:08 Bloch, Jack
  2003-12-03 15:43 ` your mail Richard B. Johnson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Bloch, Jack @ 2003-12-03 15:08 UTC (permalink / raw)
  To: linux-kernel

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@icn.siemens.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: your mail
  2003-12-03 15:08 Bloch, Jack
@ 2003-12-03 15:43 ` Richard B. Johnson
  2003-12-03 16:03 ` Linus Torvalds
  2003-12-04  4:56 ` Raj
  2 siblings, 0 replies; 4+ messages in thread
From: Richard B. Johnson @ 2003-12-03 15:43 UTC (permalink / raw)
  To: Bloch, Jack; +Cc: linux-kernel

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@icn.siemens.com


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
MACRO).


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]);
        exit(EXIT_FAILURE);
    }
    if((fd = open(argv[1], O_RDONLY)) < 0) {
        save_errno = errno;
        perror("open");
        fprintf(stderr, "Was %d (%s)\n", save_errno, strerror(save_errno));
        exit(EXIT_FAILURE);
    }
    (void)close(fd);
    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
exit
Script done on Wed Dec  3 10:42:12 2003

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: your mail
  2003-12-03 15:08 Bloch, Jack
  2003-12-03 15:43 ` your mail Richard B. Johnson
@ 2003-12-03 16:03 ` Linus Torvalds
  2003-12-04  4:56 ` Raj
  2 siblings, 0 replies; 4+ messages in thread
From: Linus Torvalds @ 2003-12-03 16:03 UTC (permalink / raw)
  To: Bloch, Jack; +Cc: linux-kernel



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?

Because you forgot a "#include <errno.h>"? Or you have something else
wrong in your program that makes "errno" mean the wrong thing?

		Linus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re:
  2003-12-03 15:08 Bloch, Jack
  2003-12-03 15:43 ` your mail Richard B. Johnson
  2003-12-03 16:03 ` Linus Torvalds
@ 2003-12-04  4:56 ` Raj
  2 siblings, 0 replies; 4+ messages in thread
From: Raj @ 2003-12-04  4:56 UTC (permalink / raw)
  To: Bloch, Jack; +Cc: linux-kernel

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?
>
>  
>
I tried this on a 2.6.0-test11 and it works fine. Pls specify your 
kernel version and attach the program if possible.

/Raj


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-12-04  4:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-03 15:08 Bloch, Jack
2003-12-03 15:43 ` your mail Richard B. Johnson
2003-12-03 16:03 ` Linus Torvalds
2003-12-04  4:56 ` Raj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).