2

Error Descriptions for System Calls

 1 year ago
source link: https://bbengfort.github.io/2017/01/syscall-errno/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Error Descriptions for System Calls

January 23, 2017 · 1 min · Benjamin Bengfort

Working with FUSE to build file systems means inevitably you have to deal with (or return) system call errors. The Go FUSE implementation includes helpers and constants for returning these errors, but simply wraps them around the syscall error numbers. I needed descriptions to better understand what was doing what. Pete saved the day by pointing me towards the errno.h header file on my Macbook. Some Python later and we had the descriptions:

#!/usr/bin/env python3 # Reads /usr/include/sys/errno.h and prints out error definitions

import re from collections import namedtuple

ERRLN = re.compile(r'^#define\s+(E[A-Z\d]+)\s+(\d+)\s+/\* (.*) \*/\s*$') ERRNO = "/usr/include/sys/errno.h"

Error = namedtuple("Error", "name, number, description")

def read_errors(path=ERRNO): with open(path, 'r') as f: for line in f: match = ERRLN.match(line) if match: yield Error(*match.groups())

if __name__ == "__main__": for err in read_errors(): print("{1: >3}: {0}: {2}".format(*err))

So that’s a good script to have on your local machine, since now I can just do the following:

$ syserr.py | grep EAGAIN
 35: EAGAIN: Resource temporarily unavailable

To get descriptions for the various errors. However for Google reference, I’ll also provide them here:

1: EPERM: Operation not permitted 2: ENOENT: No such file or directory 3: ESRCH: No such process 4: EINTR: Interrupted system call 5: EIO: Input/output error 6: ENXIO: Device not configured 7: E2BIG: Argument list too long 8: ENOEXEC: Exec format error 9: EBADF: Bad file descriptor 10: ECHILD: No child processes 11: EDEADLK: Resource deadlock avoided 12: ENOMEM: Cannot allocate memory 13: EACCES: Permission denied 14: EFAULT: Bad address 15: ENOTBLK: Block device required 16: EBUSY: Device / Resource busy 17: EEXIST: File exists 18: EXDEV: Cross-device link 19: ENODEV: Operation not supported by device 20: ENOTDIR: Not a directory 21: EISDIR: Is a directory 22: EINVAL: Invalid argument 23: ENFILE: Too many open files in system 24: EMFILE: Too many open files 25: ENOTTY: Inappropriate ioctl for device 26: ETXTBSY: Text file busy 27: EFBIG: File too large 28: ENOSPC: No space left on device 29: ESPIPE: Illegal seek 30: EROFS: Read-only file system 31: EMLINK: Too many links 32: EPIPE: Broken pipe 33: EDOM: Numerical argument out of domain 34: ERANGE: Result too large 35: EAGAIN: Resource temporarily unavailable 36: EINPROGRESS: Operation now in progress 37: EALREADY: Operation already in progress 38: ENOTSOCK: Socket operation on non-socket 39: EDESTADDRREQ: Destination address required 40: EMSGSIZE: Message too long 41: EPROTOTYPE: Protocol wrong type for socket 42: ENOPROTOOPT: Protocol not available 43: EPROTONOSUPPORT: Protocol not supported 44: ESOCKTNOSUPPORT: Socket type not supported 45: ENOTSUP: Operation not supported 46: EPFNOSUPPORT: Protocol family not supported 47: EAFNOSUPPORT: Address family not supported by protocol family 48: EADDRINUSE: Address already in use 49: EADDRNOTAVAIL: Can't assign requested address 50: ENETDOWN: Network is down 51: ENETUNREACH: Network is unreachable 52: ENETRESET: Network dropped connection on reset 53: ECONNABORTED: Software caused connection abort 54: ECONNRESET: Connection reset by peer 55: ENOBUFS: No buffer space available 56: EISCONN: Socket is already connected 57: ENOTCONN: Socket is not connected 58: ESHUTDOWN: Can't send after socket shutdown 59: ETOOMANYREFS: Too many references: can't splice 60: ETIMEDOUT: Operation timed out 61: ECONNREFUSED: Connection refused 62: ELOOP: Too many levels of symbolic links 63: ENAMETOOLONG: File name too long 64: EHOSTDOWN: Host is down 65: EHOSTUNREACH: No route to host 66: ENOTEMPTY: Directory not empty 67: EPROCLIM: Too many processes 68: EUSERS: Too many users 69: EDQUOT: Disc quota exceeded 70: ESTALE: Stale NFS file handle 71: EREMOTE: Too many levels of remote in path 72: EBADRPC: RPC struct is bad 73: ERPCMISMATCH: RPC version wrong 74: EPROGUNAVAIL: RPC prog. not avail 75: EPROGMISMATCH: Program version wrong 76: EPROCUNAVAIL: Bad procedure for program 77: ENOLCK: No locks available 78: ENOSYS: Function not implemented 79: EFTYPE: Inappropriate file type or format 80: EAUTH: Authentication error 81: ENEEDAUTH: Need authenticator 82: EPWROFF: Device power is off 83: EDEVERR: Device error, e.g. paper out 84: EOVERFLOW: Value too large to be stored in data type 85: EBADEXEC: Bad executable 86: EBADARCH: Bad CPU type in executable 87: ESHLIBVERS: Shared library version mismatch 88: EBADMACHO: Malformed Macho file 89: ECANCELED: Operation canceled 90: EIDRM: Identifier removed 91: ENOMSG: No message of desired type 92: EILSEQ: Illegal byte sequence 93: ENOATTR: Attribute not found 94: EBADMSG: Bad message 95: EMULTIHOP: Reserved 96: ENODATA: No message available on STREAM 97: ENOLINK: Reserved 98: ENOSR: No STREAM resources 99: ENOSTR: Not a STREAM 100: EPROTO: Protocol error 101: ETIME: STREAM ioctl timeout 102: EOPNOTSUPP: Operation not supported on socket 103: ENOPOLICY: No such policy registered 104: ENOTRECOVERABLE: State not recoverable 105: EOWNERDEAD: Previous owner died 106: EQFULL: Interface output queue is full 106: ELAST: Must be equal largest errno

End of post.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK