strerror(errno):获取errno对应的错误

  1. #include <string.h> /* for strerror */
  2. #include <errno.h>
  3. #include <stdio.h>
  4.  
  5. int main(int argc, char ** argv) {
  6. int i = ;
  7. for(i = ; i < ; i++)
  8. printf("errno.%02d is: %s/n", i, strerror(i));
  9. return ;
  10. }

错误对照表:

  1. errno0 : Success
  2.  
  3. errno1 : Operation not permitted
  4.  
  5. errno2 : No such file or directory
  6.  
  7. errno3 : No such process
  8.  
  9. errno4 : Interrupted system call
  10.  
  11. errno5 : Input/output error
  12.  
  13. errno6 : No such device or address
  14.  
  15. errno7 : Argument list too long
  16.  
  17. errno8 : Exec format error
  18.  
  19. errno9 : Bad file descriptor
  20.  
  21. errno10 : No child processes
  22.  
  23. errno11 : Resource temporarily unavailable
  24.  
  25. errno12 : Cannot allocate memory
  26.  
  27. errno13 : Permission denied
  28.  
  29. errno14 : Bad address
  30.  
  31. errno15 : Block device required
  32.  
  33. errno16 : Device or resource busy
  34.  
  35. errno17 : File exists
  36.  
  37. errno18 : Invalid cross-device link
  38.  
  39. errno19 : No such device
  40.  
  41. errno20 : Not a directory
  42.  
  43. errno21 : Is a directory
  44.  
  45. errno22 : Invalid argument
  46.  
  47. errno23 : Too many open files in system
  48.  
  49. errno24 : Too many open files
  50.  
  51. errno25 : Inappropriate ioctl for device
  52.  
  53. errno26 : Text file busy
  54.  
  55. errno27 : File too large
  56.  
  57. errno28 : No space left on device
  58.  
  59. errno29 : Illegal seek
  60.  
  61. errno30 : Read-only file system
  62.  
  63. errno31 : Too many links
  64.  
  65. errno32 : Broken pipe
  66.  
  67. errno33 : Numerical argument out of domain
  68.  
  69. errno34 : Numerical result out of range
  70.  
  71. errno35 : Resource deadlock avoided
  72.  
  73. errno36 : File name too long
  74.  
  75. errno37 : No locks available
  76.  
  77. errno38 : Function not implemented
  78.  
  79. errno39 : Directory not empty
  80.  
  81. errno40 : Too many levels of symbolic links
  82.  
  83. errno41 : Unknown error
  84.  
  85. errno42 : No message of desired type
  86.  
  87. errno43 : Identifier removed
  88.  
  89. errno44 : Channel number out of range
  90.  
  91. errno45 : Level not synchronized
  92.  
  93. errno46 : Level halted
  94.  
  95. errno47 : Level reset
  96.  
  97. errno48 : Link number out of range
  98.  
  99. errno49 : Protocol driver not attached
  100.  
  101. errno50 : No CSI structure available
  102.  
  103. errno51 : Level halted
  104.  
  105. errno52 : Invalid exchange
  106.  
  107. errno53 : Invalid request descriptor
  108.  
  109. errno54 : Exchange full
  110.  
  111. errno55 : No anode
  112.  
  113. errno56 : Invalid request code
  114.  
  115. errno57 : Invalid slot
  116.  
  117. errno58 : Unknown error
  118.  
  119. errno59 : Bad font file format
  120.  
  121. errno60 : Device not a stream
  122.  
  123. errno61 : No data available
  124.  
  125. errno62 : Timer expired
  126.  
  127. errno63 : Out of streams resources
  128.  
  129. errno64 : Machine is not on the network
  130.  
  131. errno65 : Package not installed
  132.  
  133. errno66 : Object is remote
  134.  
  135. errno67 : Link has been severed
  136.  
  137. errno68 : Advertise error
  138.  
  139. errno69 : Srmount error
  140.  
  141. errno70 : Communication error on send
  142.  
  143. errno71 : Protocol error
  144.  
  145. errno72 : Multihop attempted
  146.  
  147. errno73 : RFS specific error
  148.  
  149. errno74 : Bad message
  150.  
  151. errno75 : Value too large for defined datatype
  152.  
  153. errno76 : Name not unique on network
  154.  
  155. errno77 : File descriptor in bad state
  156.  
  157. errno78 : Remote address changed
  158.  
  159. errno79 : Can not access a needed sharedlibrary
  160.  
  161. errno80 : Accessing a corrupted sharedlibrary
  162.  
  163. errno81 : .lib section in a.out corrupted
  164.  
  165. errno82 : Attempting to link in too manyshared libraries
  166.  
  167. errno83 : Cannot exec a shared librarydirectly
  168.  
  169. errno84 : Invalid or incomplete multibyte orwide character
  170.  
  171. errno85 : Interrupted system call should berestarted
  172.  
  173. errno86 : Streams pipe error
  174.  
  175. errno87 : Too many users
  176.  
  177. errno88 : Socket operation on non-socket
  178.  
  179. errno89 : Destinationaddress required
  180.  
  181. errno90 : Message too long
  182.  
  183. errno91 : Protocol wrong type for socket
  184.  
  185. errno92 : Protocol not available
  186.  
  187. errno93 : Protocol not supported
  188.  
  189. errno94 : Socket type not supported
  190.  
  191. errno95 : Operation not supported
  192.  
  193. errno96 : Protocol family not supported
  194.  
  195. errno97 : Address family not supported byprotocol
  196.  
  197. errno98 : Address already in use
  198.  
  199. errno99 : Cannot assign requested address
  200.  
  201. errno100 : Network is down
  202.  
  203. errno101 : Network is unreachable
  204.  
  205. errno102 : Network dropped connection onreset
  206.  
  207. errno103 : Software caused connection abort
  208.  
  209. errno104 : Connection reset by peer
  210.  
  211. errno105 : No buffer space available
  212.  
  213. errno106 : Transport endpoint is alreadyconnected
  214.  
  215. errno107 : Transport endpoint is notconnected
  216.  
  217. errno108 : Cannot send after transportendpoint shutdown
  218.  
  219. errno109 : Too many references: cannot splice
  220.  
  221. errno110 : Connection timed out
  222.  
  223. errno111 : Connection refused
  224.  
  225. errno112 : Host is down
  226.  
  227. errno113 : No route to host
  228.  
  229. errno114 : Operation already in progress
  230.  
  231. errno115 : Operation now in progress
  232.  
  233. errno116 : Stale NFS file handle
  234.  
  235. errno117 : Structure needs cleaning
  236.  
  237. errno118 : Not a XENIX named type file
  238.  
  239. errno119 : No XENIX semaphores available
  240.  
  241. errno120 : Is a named type file
  242.  
  243. errno121 : Remote I/O error
  244.  
  245. errno122 : Disk quota exceeded
  246.  
  247. errno123 : No medium found
  248.  
  249. errno124 : Wrong medium type
  250.  
  251. errno125 : Operation canceled
  252.  
  253. errno126 : Required key not available
  254.  
  255. errno127 : Key has expired
  256.  
  257. errno128 : Key has been revoked
  258.  
  259. errno129 : Key was rejected by service
  260.  
  261. errno130 : Owner died
  262.  
  263. errno131 : State not recoverable
  264.  
  265. errno132 : Operation not possible due toRF-kill
  266.  
  267. errno133 : Unknown error
  268.  
  269. errno134 : Unknown error
  270.  
  271. errno135 : Unknown error
  272.  
  273. errno136 : Unknown error
  274.  
  275. errno137 : Unknown error
  276.  
  277. errno138 : Unknown error
  278.  
  279. errno139 : Unknown error

具体宏定义如下:

头文件 /usr/include/asm-generic/errno-base.h 的源码:

  1. #ifndef _ASM_GENERIC_ERRNO_BASE_H
  2. #define _ASM_GENERIC_ERRNO_BASE_H
  3.  
  4. #define EPERM 1 /* Operation not permitted */
  5. #define ENOENT2 /* No such file or directory */
  6. #define ESRCH 3 /* No such process */
  7. #define EINTR 4 /* Interrupted system call */
  8. #define EIO 5 /* I/O error */
  9. #define ENXIO 6 /* No such device or address */
  10. #define E2BIG 7 /* Argument list too long */
  11. #define ENOEXEC8 /* Exec format error */
  12. #define EBADF 9 /* Bad file number */
  13. #define ECHILD10 /* No child processes */
  14. #define EAGAIN11 /* Try again */
  15. #define ENOMEM12 /* Out of memory */
  16. #define EACCES13 /* Permission denied */
  17. #define EFAULT14 /* Bad address */
  18. #define ENOTBLK15 /* Block device required */
  19. #define EBUSY 16 /* Device or resource busy */
  20. #define EEXIST17 /* File exists */
  21. #define EXDEV 18 /* Cross-device link */
  22. #define ENODEV19 /* No such device */
  23. #define ENOTDIR20 /* Not a directory */
  24. #define EISDIR21 /* Is a directory */
  25. #define EINVAL22 /* Invalid argument */
  26. #define ENFILE23 /* File table overflow */
  27. #define EMFILE24 /* Too many open files */
  28. #define ENOTTY25 /* Not a typewriter */
  29. #define ETXTBSY26 /* Text file busy */
  30. #define EFBIG 27 /* File too large */
  31. #define ENOSPC28 /* No space left on device */
  32. #define ESPIPE29 /* Illegal seek */
  33. #define EROFS 30 /* Read-only file system */
  34. #define EMLINK31 /* Too many links */
  35. #define EPIPE 32 /* Broken pipe */
  36. #define EDOM 33 /* Math argument out of domain of func */
  37. #define ERANGE34 /* Math result not representable */
  38.  
  39. #endif

头文件/usr/include/asm-generic/erno.h源码:

  1. #ifndef _ASM_GENERIC_ERRNO_H
  2. #define _ASM_GENERIC_ERRNO_H
  3.  
  4. #include <asm-generic/errno-base.h>
  5.  
  6. #define EDEADLK35 /* Resource deadlock would occur */
  7. #define ENAMETOOLONG36 /* File name too long */
  8. #define ENOLCK37 /* No record locks available */
  9. #define ENOSYS38 /* Function not implemented */
  10. #define ENOTEMPTY39 /* Directory not empty */
  11. #define ELOOP 40 /* Too many symbolic links encountered */
  12. #define EWOULDBLOCKEAGAIN /* Operation would block */
  13. #define ENOMSG42 /* No message of desired type */
  14. #define EIDRM 43 /* Identifier removed */
  15. #define ECHRNG44 /* Channel number out of range */
  16. #define EL2NSYNC45 /* Level 2 not synchronized */
  17. #define EL3HLT46 /* Level 3 halted */
  18. #define EL3RST47 /* Level 3 reset */
  19. #define ELNRNG48 /* Link number out of range */
  20. #define EUNATCH49 /* Protocol driver not attached */
  21. #define ENOCSI50 /* No CSI structure available */
  22. #define EL2HLT51 /* Level 2 halted */
  23. #define EBADE 52 /* Invalid exchange */
  24. #define EBADR 53 /* Invalid request descriptor */
  25. #define EXFULL54 /* Exchange full */
  26. #define ENOANO55 /* No anode */
  27. #define EBADRQC56 /* Invalid request code */
  28. #define EBADSLT57 /* Invalid slot */
  29.  
  30. #define EDEADLOCKEDEADLK
  31.  
  32. #define EBFONT59 /* Bad font file format */
  33. #define ENOSTR60 /* Device not a stream */
  34. #define ENODATA61 /* No data available */
  35. #define ETIME 62 /* Timer expired */
  36. #define ENOSR 63 /* Out of streams resources */
  37. #define ENONET64 /* Machine is not on the network */
  38. #define ENOPKG65 /* Package not installed */
  39. #define EREMOTE66 /* Object is remote */
  40. #define ENOLINK67 /* Link has been severed */
  41. #define EADV 68 /* Advertise error */
  42. #define ESRMNT69 /* Srmount error */
  43. #define ECOMM 70 /* Communication error on send */
  44. #define EPROTO71 /* Protocol error */
  45. #define EMULTIHOP72 /* Multihop attempted */
  46. #define EDOTDOT73 /* RFS specific error */
  47. #define EBADMSG74 /* Not a data message */
  48. #define EOVERFLOW75 /* Value too large for defined data type */
  49. #define ENOTUNIQ76 /* Name not unique on network */
  50. #define EBADFD77 /* File descriptor in bad state */
  51. #define EREMCHG78 /* Remote address changed */
  52. #define ELIBACC79 /* Can not access a needed shared library */
  53. #define ELIBBAD80 /* Accessing a corrupted shared library */
  54. #define ELIBSCN81 /* .lib section in a.out corrupted */
  55. #define ELIBMAX82 /* Attempting to link in too many shared libraries */
  56. #define ELIBEXEC83 /* Cannot exec a shared library directly */
  57. #define EILSEQ84 /* Illegal byte sequence */
  58. #define ERESTART85 /* Interrupted system call should be restarted */
  59. #define ESTRPIPE86 /* Streams pipe error */
  60. #define EUSERS87 /* Too many users */
  61. #define ENOTSOCK88 /* Socket operation on non-socket */
  62. #define EDESTADDRREQ89 /* Destination address required */
  63. #define EMSGSIZE90 /* Message too long */
  64. #define EPROTOTYPE91 /* Protocol wrong type for socket */
  65. #define ENOPROTOOPT92 /* Protocol not available */
  66. #define EPROTONOSUPPORT93 /* Protocol not supported */
  67. #define ESOCKTNOSUPPORT94 /* Socket type not supported */
  68. #define EOPNOTSUPP95 /* Operation not supported on transport endpoint */
  69. #define EPFNOSUPPORT96 /* Protocol family not supported */
  70. #define EAFNOSUPPORT97 /* Address family not supported by protocol */
  71. #define EADDRINUSE98 /* Address already in use */
  72. #define EADDRNOTAVAIL99 /* Cannot assign requested address */
  73. #define ENETDOWN100 /* Network is down */
  74. #define ENETUNREACH101 /* Network is unreachable */
  75. #define ENETRESET102 /* Network dropped connection because of reset */
  76. #define ECONNABORTED103 /* Software caused connection abort */
  77. #define ECONNRESET104 /* Connection reset by peer */
  78. #define ENOBUFS105 /* No buffer space available */
  79. #define EISCONN106 /* Transport endpoint is already connected */
  80. #define ENOTCONN107 /* Transport endpoint is not connected */
  81. #define ESHUTDOWN108 /* Cannot send after transport endpoint shutdown */
  82. #define ETOOMANYREFS109 /* Too many references: cannot splice */
  83. #define ETIMEDOUT110 /* Connection timed out */
  84. #define ECONNREFUSED111 /* Connection refused */
  85. #define EHOSTDOWN112 /* Host is down */
  86. #define EHOSTUNREACH113 /* No route to host */
  87. #define EALREADY114 /* Operation already in progress */
  88. #define EINPROGRESS115 /* Operation now in progress */
  89. #define ESTALE116 /* Stale NFS file handle */
  90. #define EUCLEAN117 /* Structure needs cleaning */
  91. #define ENOTNAM118 /* Not a XENIX named type file */
  92. #define ENAVAIL119 /* No XENIX semaphores available */
  93. #define EISNAM120 /* Is a named type file */
  94. #define EREMOTEIO121 /* Remote I/O error */
  95. #define EDQUOT122 /* Quota exceeded */
  96. #define ENOMEDIUM123 /* No medium found */
  97. #define EMEDIUMTYPE124 /* Wrong medium type */
  98. #define ECANCELED125 /* Operation Canceled */
  99. #define ENOKEY126 /* Required key not available */
  100. #define EKEYEXPIRED127 /* Key has expired */
  101. #define EKEYREVOKED128 /* Key has been revoked */
  102. #define EKEYREJECTED129 /* Key was rejected by service */ /* for robust mutexes */ #define EOWNERDEAD130 /* Owner died */
  103. #define ENOTRECOVERABLE131 /* State not recoverable */
  104. #define ERFKILL 132/* Operation not possible due to RF-kill */
  105.  
  106. #endif

linux 下各errno的意义的更多相关文章

  1. linux 下各errno的意义(转)

    linux 下各errno的意义(转)   本文转自:http://blog.csdn.net/kofiory/article/details/5790409 strerror(errno):获取er ...

  2. linux 下信号处理命令trap && linux下各种信号的意义

    1.用途说明 trap是一个shell内建命令,它用来在脚本中指定信号如何处理.比如,按Ctrl+C会使脚本终止执行,实际上系统发送了SIGINT信号给脚本进程,SIGINT信号的默认处理方式就是退出 ...

  3. linux下错误的捕获:errno(errno.h)和strerror(string.h)的使用

    参考:http://blog.csdn.net/starstar1992/article/details/52756387 linux下错误的捕获:errno和strerror的使用 经常在调用lin ...

  4. linux下各种颜色文件的意义

    linux下的文件颜色的意义 蓝色表示目录;绿色表示可执行文件;红色表示压缩文件;浅蓝色表示链接文件;灰色表示其它文件;红色闪烁表示链接的文件有问题了;黄色是设备文件,包括block, char, f ...

  5. Linux下文件的三个时间意义及用法

    Linux下文件的三个时间参数: (1)modification time(mtime):内容修改时间        这里的修改时间指的是文件的内容发生变化,而更新的时间. (2)change tim ...

  6. Linux下c开发 之 线程通信(转)

    Linux下c开发 之 线程通信(转) 1.Linux“线程” 进程与线程之间是有区别的,不过Linux内核只提供了轻量进程的支持,未实现线程模型.Linux是一种“多进程单线程”的操作系统.Linu ...

  7. Linux下的C编程实战

    Linux下的C编程实战(一) ――开发平台搭建 1.引言 Linux操作系统在服务器领域的应用和普及已经有较长的历史,这源于它的开源特点以及其超越Windows的安全性和稳定性.而近年来, Linu ...

  8. Linux下串口编制【转】

    串行口是计算机一种常用的接口,具有连接线少,通讯简单,得到广泛的使用.常用的串口是RS-232-C接口(又称EIA RS-232-C)它是在1970年由美国电子工业协会(EIA)联合贝尔系统.调制解调 ...

  9. linux下的struct sigaction

    工作中使用案例: struct sigaction act; act.sa_sigaction = handleSignal; act.sa_flags = SA_SIGINFO; sigemptys ...

随机推荐

  1. Linux常用命令大全(2)

    系统信息arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS / ...

  2. Laravel PHP Web开发框架

    Laravel是一套简洁.优雅的PHP Web开发框架(PHP Web Framework).它可以让你从面条一样杂乱的代码中解脱出来:它可以帮你构建一个完美的网络APP,而且每行代码都可以简洁.富于 ...

  3. 使用PHP预定义变量得到url地址及相关参数

    获取url地址栏参数多种方法:$_SERVER["SERVER_PORT"]//获取端口$_SERVER['HTTP_HOST']//获取域名或主机地址 如www.sina.com ...

  4. sphinx 简介以及安装 以及php拓展开启

    一 sphinx 简介   在 使用mysql数据库过程中,如果想实现全文检索的优化,可以使用mysql自带全文索引,但是不支持中文..关于sphinx的安装网上很多教程写的都 不错比如:http:/ ...

  5. Day12 线程池、RabbitMQ和SQLAlchemy

    1.with实现上下文管理 #!/usr/bin/env python# -*- coding: utf-8 -*-# Author: wanghuafeng #with实现上下文管理import c ...

  6. Python Tutorial 学习(四)--More Control Flow Tools

    4.1 if 表达式 作为最为人熟知的if.你肯定对这样的一些表达式不感到陌生: >>> x = int(raw_input("Please enter an intege ...

  7. Inna and Sequence

    Codeforces Round #220 (Div. 2) D:http://codeforces.com/contest/374/problem/D 题意:给你m个数,这m个数是递增的.然后给你n ...

  8. All in All

    Crawling in process... Crawling failed Description You have devised a new encryption technique which ...

  9. xp下删除windows7,无法删除windows7文件夹,无法删除windows7文件,双系统卸载,取得文件权限

    http://blog.csdn.net/lanmanck/article/details/5722050 ---------------------------------------------- ...

  10. 开启SQL Server 2012的远程连接

    有个远程的SQL Server服务器需要连接,因为SQL server默认是把远程连接关闭的. 以下有文档,照着做了,但是还是连不上, http://www.2cto.com/database/201 ...