// linux\include\uapi\asm-generic\errno-base.h
#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _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 错误 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 EAGAIN 11 /* 再试一次 Try again */
#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 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 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 /* 数学参数超出 func 域 Math argument out of domain of func */
#define ERANGE 34 /* 数学结果不可表示 Math result not representable */
#endif
// linux\include\uapi\asm-generic\errno.h
#ifndef _ASM_GENERIC_ERRNO_H
#define _ASM_GENERIC_ERRNO_H
#include <asm-generic/errno-base.h>
#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 /* 2 级不同步 Level 2 not synchronized */
#define EL3HLT 46 /* 3 级停止 Level 3 halted */
#define EL3RST 47 /* 3 级复位 Level 3 reset */
#define ELNRNG 48 /* 链接号超出范围 Link number out of range */
#define EUNATCH 49 /* 未附加协议驱动程序 Protocol driver not attached */
#define ENOCSI 50 /* 没有可用的 CSI 结构 No CSI structure available */
#define EL2HLT 51 /* 2 级停止 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 */
#define ENODATA 61 /* 无可用数据 No data available */
#define ETIME 62 /* 定时器过期 Timer expired */
#define ENOSR 63 /* 流资源不足 Out of streams resources */
#define ENONET 64 /* 机器不在网络上 Machine is not on the network */
#define ENOPKG 65 /* 软件包未安装 Package not installed */
#define EREMOTE 66 /* 对象是远程的 Object is remote */
#define ENOLINK 67 /* 链接已被切断 Link has been severed */
#define EADV 68 /* 通告错误 Advertise error */
#define ESRMNT 69 /* 挂载错误 Srmount error */
#define ECOMM 70 /* 发送时通信错误 Communication error on send */
#define EPROTO 71 /* 协议错误 Protocol error */
#define EMULTIHOP 72 /* 尝试多跳 Multihop attempted */
#define EDOTDOT 73 /* RFS 特定错误 RFS specific error */
#define EBADMSG 74 /* 不是数据消息 Not a data message */
#define EOVERFLOW 75 /* 值对于定义的数据类型来说太大 Value too large for defined data type */
#define ENOTUNIQ 76 /* 名称在网络上不唯一 Name not unique on network */
#define EBADFD 77 /* 文件描述符处于错误状态 File descriptor in bad state */
#define EREMCHG 78 /* 远程地址已更改 Remote address changed */
#define ELIBACC 79 /* 无法访问所需的共享库 Can not access a needed shared library */
#define ELIBBAD 80 /* 访问损坏的共享库 Accessing a corrupted shared library */
#define ELIBSCN 81 /* a.out 中的 .lib 部分已损坏 .lib section in a.out corrupted */
#define ELIBMAX 82 /* 尝试链接太多共享库 Attempting to link in too many shared libraries */
#define ELIBEXEC 83 /* 不能直接执行共享库 Cannot exec a shared library directly */
#define EILSEQ 84 /* 非法字节序列 Illegal byte sequence */
#define ERESTART 85 /* 中断的系统调用应该重新启动 Interrupted system call should be restarted */
#define ESTRPIPE 86 /* 流管道错误 Streams pipe error */
#define EUSERS 87 /* 用户太多 Too many users */
#define ENOTSOCK 88 /* 非socket上的socket操作 Socket operation on non-socket */
#define EDESTADDRREQ 89 /* 需要目标地址 Destination address required */
#define EMSGSIZE 90 /* 消息太长 Message too long */
#define EPROTOTYPE 91 /* 套接字的协议类型错误 Protocol wrong type for socket */
#define ENOPROTOOPT 92 /* 协议不可用 Protocol not available */
#define EPROTONOSUPPORT 93 /* 不支持协议 Protocol not supported */
#define ESOCKTNOSUPPORT 94 /* 不支持的套接字类型 Socket type not supported */
#define EOPNOTSUPP 95 /* 传输端点不支持操作 Operation not supported on transport endpoint */
#define EPFNOSUPPORT 96 /* 不支持协议族 Protocol family not supported */
#define EAFNOSUPPORT 97 /* 协议不支持的地址族 Address family not supported by protocol */
#define EADDRINUSE 98 /* 地址已在使用 Address already in use */
#define EADDRNOTAVAIL 99 /* 无法分配请求的地址 Cannot assign requested address */
#define ENETDOWN 100 /* 网络已关闭 Network is down */
#define ENETUNREACH 101 /* 网络不可达 Network is unreachable */
#define ENETRESET 102 /* 网络因重置而断开连接 Network dropped connection because of reset */
#define ECONNABORTED 103 /* 软件导致连接中止 Software caused connection abort */
#define ECONNRESET 104 /* 连接被对等方重置 Connection reset by peer */
#define ENOBUFS 105 /* 没有可用的缓冲区空间 No buffer space available */
#define EISCONN 106 /* 传输端点已连接 Transport endpoint is already connected */
#define ENOTCONN 107 /* 传输端点未连接 Transport endpoint is not connected */
#define ESHUTDOWN 108 /* 传输端点关闭后无法发送 Cannot send after transport endpoint shutdown */
#define ETOOMANYREFS 109 /* 引用过多:无法拼接 Too many references: cannot splice */
#define ETIMEDOUT 110 /* 连接超时 Connection timed out */
#define ECONNREFUSED 111 /* 连接被拒绝 Connection refused */
#define EHOSTDOWN 112 /* 主机已关闭 Host is down */
#define EHOSTUNREACH 113 /* 没有到主机的路由 No route to host */
#define EALREADY 114 /* 操作已在进行中 Operation already in progress */
#define EINPROGRESS 115 /* 操作正在进行中 Operation now in progress */
#define ESTALE 116 /* 过时文件句柄 Stale file handle */
#define EUCLEAN 117 /* 结构需要清洁 Structure needs cleaning */
#define ENOTNAM 118 /* 不是 XENIX 命名类型文件 Not a XENIX named type file */
#define ENAVAIL 119 /* 没有可用的 XENIX 信号量 No XENIX semaphores available */
#define EISNAM 120 /* 是命名类型文件 Is a named type file */
#define EREMOTEIO 121 /* 远程 I/O 错误 Remote I/O error */
#define EDQUOT 122 /* 超出配额 Quota exceeded */
#define ENOMEDIUM 123 /* 未找到介质 No medium found */
#define EMEDIUMTYPE 124 /* 错误的介质类型 Wrong medium type */
#define ECANCELED 125 /* 操作取消 Operation Canceled */
#define ENOKEY 126 /* 所需的密钥不可用 Required key not available */
#define EKEYEXPIRED 127 /* 密钥已过期 Key has expired */
#define EKEYREVOKED 128 /* 密钥已被撤销 Key has been revoked */
#define EKEYREJECTED 129 /* 密钥被服务拒绝 Key was rejected by service */
/* for robust mutexes */
#define EOWNERDEAD 130 /* 拥有者死亡 Owner died */
#define ENOTRECOVERABLE 131 /* 状态不可恢复 State not recoverable */
#define ERFKILL 132 /* 由于 RF-kill 而无法进行操作 Operation not possible due to RF-kill */
#define EHWPOISON 133 /* 内存页有硬件错误 Memory page has hardware error */
#endif
把errno的数字转换成直观的字符串
1、 使用strerror函数
函数原型:
char * strerror(int errno)
使用方法:
fprintf(stderr, "%s", strerror(errno));
通过标准错误的标号,获得错误的描述字符串 ,将单纯的错误标号转为字符串描述,方便用户查找错误。
2、 使用perror函数
函数原型:
void perror(const char *s)
使用说明
参数s指定的字符串是要先打印出来的信息,可以由我么自己定义,然后系统会在s字符串后加上错误原因的字符串。