Return to User Mode

Each system call must inform the user application whether its routine was executed and with which result. It does this by means of its return code. From the perspective of the application, a normal variable is read using C programming means. However, the kernel, in conjunction with libc, must expend a little more effort to make things just as simple for the user process.

Meaning of Return Values

Generally, the following applies for system call return values. Negative values indicate an error, and positive values (and 0) denote successful termination.

Of course, neither programs nor the kernel itself operates with raw numbers but with symbolic constants defined with the help of the pre-processor in include/asm-generic/errno-base.h and include/asm-generic/errno.h.7 The file named <errno.h> contains several additional error codes, but these are kernel-specific and are never visible to the user application. Error codes up to and including 511 are reserved for general errors; kernel-specific constants use the values above 512.

Because (not surprisingly) there are a very large number of potential errors, only a few constants are listed below:

<asm-generic/errno-base.h>

#define

EPERM

1

/*

Operation not permitted */

#define

ENOENT

2

/*

No such file or directory */

#define

ESRCH

3

/*

No such process */

#define

EINTR

4

/*

Interrupted system call */

#define

EIO

5

/*

I/O error */

#define

ENXIO

6

/*

No such device or address */

#define

E2BIG

7

/*

Argument list too long */

#define

ENOEXEC

8

/*

Exec format error */

#define

EBADF

9

/*

Bad file number */

#define

ECHILD

10

/*

No child processes */

#define

EMLINK

31

/*

Too many links */

#define

EPIPE

32

/*

Broken pipe */

#define

EDOM

33

/*

Math argument out of domain of

#define

ERANGE

34

/*

Math result not representable

The "classic" errors that occur when working with Unix system calls are listed in errno-base.h. On the other hand, errno.h contains more unusual error codes whose meanings are not immediately obvious even to seasoned programmers. Examples such as eopnotsupp — which stands for "Operation not supported on transport endpoint'' — and elnrng — which means "Link number out of range'' — are not what might be classified as common knowledge. Some more examples:

Continue reading here: Info

Was this article helpful?

0 0