Call Error Codes
Contents |
Aug 2004 on RedHat 7.3 #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 linux kernel error codes such device or address */ #define E2BIG 7 /* Arg list too long */ #define ENOEXEC 8 /*
Posix Error Codes
Exec format error */ #define EBADF 9 /* Bad file number */ #define ECHILD 10 /* No child processes */ #define EAGAIN 11 /* Try again */ linux errno example #define ENOMEM 12 /* Out of memory */ #define EACCES 13 /* Permission denied */ #define EFAULT 14 /* Bad address */ #define ENOTBLK 15 /* Block device required */ #define EBUSY 16 /* Device or resource busy */ #define EEXIST 17 /* File
Unix Errno Codes
exists */ #define EXDEV 18 /* Cross-device link */ #define ENODEV 19 /* No such device */ #define ENOTDIR 20 /* Not a directory */ #define EISDIR 21 /* Is a directory */ #define EINVAL 22 /* Invalid argument */ #define ENFILE 23 /* File table overflow */ #define EMFILE 24 /* Too many open files */ #define ENOTTY 25 /* Not a typewriter */ #define ETXTBSY 26 /* Text file busy */ #define EFBIG 27 /* File too large */ #define ENOSPC 28 /* No space left on linux errno to string device */ #define ESPIPE 29 /* Illegal seek */ #define EROFS 30 /* Read-only file system */ #define EMLINK 31 /* Too many links */ #define EPIPE 32 /* Broken pipe */ #define EDOM 33 /* Math argument out of domain of func */ #define ERANGE 34 /* Math result not representable */ #define EDEADLK 35 /* Resource deadlock would occur */ #define ENAMETOOLONG 36 /* File name too long */ #define ENOLCK 37 /* No record locks available */ #define ENOSYS 38 /* Function not implemented */ #define ENOTEMPTY 39 /* Directory not empty */ #define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define ENOMSG 42 /* No message of desired type */ #define EIDRM 43 /* Identifier removed */ #define ECHRNG 44 /* Channel number out of range */ #define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL3HLT 46 /* Level 3 halted */ #define EL3RST 47 /* Level 3 reset */ #define ELNRNG 48 /* Link number out of range */ #define EUNATCH 49 /* Protocol driver not attached */ #define ENOCSI 50 /* No CSI structure available */ #define EL2HLT 51 /* Level 2 halted */ #define EBADE 52 /* Invalid exchange */ #define EBADR 53 /* Invalid request descriptor */ #define EXFULL 54 /* Exchange full */ #define ENOANO 55 /* No anode */ #define EBADRQC 56 /* Invalid request code */ #define EBADSLT 57 /* Invalid slot */ #define EDEADLOCK EDEADLK #define EBFONT 59 /* Bad font file format */ #define ENOSTR 60 /* Device not a stream
In C programming language, there is no direct support for error handling. You have to detect the failure and handle the error. In C programming language, return values represents success or failure. Inside a C program, when
Enxio
a function fails, you should handle the errors accordingly, or at least record the errors
Efault
in a log file. When you are running some program on Linux environment, you might notice that it gives some error number. For errno.h windows example, "Error no is : 17", which doesn't really say much. You really need to know what error number 17 means. This article shows all available error numbers along with it descriptions. This article might be a http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Errors/unix_system_errors.html handy reference for you, when you encounter an error number and you would like to know what it means. In C programming language, there is an external variable called "errno". From this errno variable you can use some error handling functions to find out the error description and handle it appropriately. You have to include errno.h header file to use external variable errno. perror function prints error description in standard error. The strerror function returns a http://www.thegeekstuff.com/2010/10/linux-error-codes/ string describing the error code passed in the argument errnum. The following C code snippet tries to open a file through open system call. There are two flags in the open call. O_CREAT flag is to create a file, if the file does not exist. O_EXCL flag is used with O_CREAT, if the file is already exist open call will fail with the proper error number. $ cat fileopen.c #include
DESCRIPTION top The
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Understand error codes in Linux up vote 4 down vote favorite I am working on Linux (Kernel Version 2.6.32.28) laptop. After I inserted/did file io/removed a SD combo card, I got following errors: mmcblk0: error -123 sending status command mmcblk0: error -123 sending read/write command, response 0x0, card status 0x0 mmcblk0: error -123 sending requesting status Now, I would like to understand what these errors mean. As I saw few standard error codes are located in arch/powerpc/boot/stdio.h and other scattered at various other places.. Is there any systematic way in Linux to track (& understand) the error codes (in the source) ? linux system-calls error-handling share|improve this question edited Feb 11 '12 at 0:00 Gilles 369k676711120 asked Feb 28 '11 at 7:02 TheCottonSilk 13327 migrated from stackoverflow.com Feb 28 '11 at 20:33 This question came from our site for professional and enthusiast programmers. add a comment| 4 Answers 4 active oldest votes up vote 5 down vote accepted There are standard error values, defined in errno.h. You can look at this file on your system to see the numerical values. On most systems, they're in /usr/include/errno.h or a file that it includes. On Linux, most are in /usr/include/asm-generic/errno-base.h or /usr/include/asm-generic/errno.h, with a few more in /usr/include/bits/errno.h. If you have a numerical value, call the standard library function strerror or perror to obtain the corresponding error message (in your current locale). From the command line, a quick way to see an error string is one of perl -MPOSIX -le 'print strerror 123' python -c 'import os; print os.strerror(123)' zmodload