Android linux/errno.h 对应error num 解析

adb shell settings put system screen_brightness 1000

100%:250

90%:240

#include <linux/kernel.h>
#include <linux/errno.h>

errno具体定义在:

kernel-4.9\include\uapi\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 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  /* Math argument out of domain of func */

#define ERANGE      34  /* Math result not representable */

#define ERROR_TEXT_ENTRY(errno, err_desc_str) \
    [(errno)] = #errno ", " err_desc_str

static const char * const _error_text[] = {
    [0] = "Success",
    ERROR_TEXT_ENTRY(EPERM, "Operation not permitted"),
    ERROR_TEXT_ENTRY(ENOENT, "No such file or directory"),
    ERROR_TEXT_ENTRY(ESRCH, "No such process"),
    ERROR_TEXT_ENTRY(EINTR, "Interrupted system call"),
    ERROR_TEXT_ENTRY(EIO, "Input/output error"),
    ERROR_TEXT_ENTRY(ENXIO, "No such device or address"),
    ERROR_TEXT_ENTRY(E2BIG, "Argument list too long"),
    ERROR_TEXT_ENTRY(ENOEXEC, "Exec format error"),
    ERROR_TEXT_ENTRY(EBADF, "Bad file descriptor"),
    ERROR_TEXT_ENTRY(ECHILD, "No child processes"),
    ERROR_TEXT_ENTRY(EAGAIN, "Resource temporarily unavailable"),
    ERROR_TEXT_ENTRY(ENOMEM, "Cannot allocate memory"),
    ERROR_TEXT_ENTRY(EACCES, "Permission denied"),
    ERROR_TEXT_ENTRY(EFAULT, "Bad address"),
    ERROR_TEXT_ENTRY(ENOTBLK, "Block device required"),
    ERROR_TEXT_ENTRY(EBUSY, "Device or resource busy"),
    ERROR_TEXT_ENTRY(EEXIST, "File exists"),
    ERROR_TEXT_ENTRY(EXDEV, "Invalid cross-device link"),
    ERROR_TEXT_ENTRY(ENODEV, "No such device"),
    ERROR_TEXT_ENTRY(ENOTDIR, "Not a directory"),
    ERROR_TEXT_ENTRY(EISDIR, "Is a directory"),
    ERROR_TEXT_ENTRY(EINVAL, "Invalid argument"),
    ERROR_TEXT_ENTRY(EMFILE, "Too many open files"),
    ERROR_TEXT_ENTRY(ENFILE, "Too many open files in system"),
    ERROR_TEXT_ENTRY(ENOTTY, "Inappropriate ioctl for device"),
    ERROR_TEXT_ENTRY(ETXTBSY, "Text file busy"),
    ERROR_TEXT_ENTRY(EFBIG, "File too large"),
    ERROR_TEXT_ENTRY(ENOSPC, "No space left on device"),
    ERROR_TEXT_ENTRY(ESPIPE, "Illegal seek"),
    ERROR_TEXT_ENTRY(EROFS, "Read-only file system"),
    ERROR_TEXT_ENTRY(EMLINK, "Too many links"),
    ERROR_TEXT_ENTRY(EPIPE, "Broken pipe"),
    ERROR_TEXT_ENTRY(EDOM, "Numerical argument out of domain"),
    ERROR_TEXT_ENTRY(ERANGE, "Numerical result out of range"),
    ERROR_TEXT_ENTRY(EDEADLK, "Resource deadlock avoided"),
    ERROR_TEXT_ENTRY(ENAMETOOLONG, "File name too long"),
    ERROR_TEXT_ENTRY(ENOLCK, "No locks available"),
    ERROR_TEXT_ENTRY(ENOSYS, "Function not implemented"),
    ERROR_TEXT_ENTRY(ENOTEMPTY, "Directory not empty"),
    ERROR_TEXT_ENTRY(ELOOP, "Too many levels of symbolic links"),
    ERROR_TEXT_ENTRY(EWOULDBLOCK, "Operation would block"),
    ERROR_TEXT_ENTRY(ENOMSG, "No message of desired type"),
    ERROR_TEXT_ENTRY(EIDRM, "Identifier removed"),
    ERROR_TEXT_ENTRY(ECHRNG, "Channel number out of range"),
    ERROR_TEXT_ENTRY(EL2NSYNC, "Level 2 not synchronized"),
    ERROR_TEXT_ENTRY(EL3HLT, "Level 3 halted"),
    ERROR_TEXT_ENTRY(EL3RST, "Level 3 reset"),
    ERROR_TEXT_ENTRY(ELNRNG, "Link number out of range"),
    ERROR_TEXT_ENTRY(EUNATCH, "Protocol driver not attached"),
    ERROR_TEXT_ENTRY(ENOCSI, "No CSI structure available"),
    ERROR_TEXT_ENTRY(EL2HLT, "Level 2 halted"),
    ERROR_TEXT_ENTRY(EBADE, "Invalid exchange"),
    ERROR_TEXT_ENTRY(EBADR, "Invalid request descriptor"),
    ERROR_TEXT_ENTRY(EXFULL, "Exchange full"),
    ERROR_TEXT_ENTRY(ENOANO, "No anode"),
    ERROR_TEXT_ENTRY(EBADRQC, "Invalid request code"),
    ERROR_TEXT_ENTRY(EBADSLT, "Invalid slot"),
    ERROR_TEXT_ENTRY(EDEADLOCK, "File locking deadlock error"),
    ERROR_TEXT_ENTRY(EBFONT, "Bad font file format"),
    ERROR_TEXT_ENTRY(ENOSTR, "Device not a stream"),
    ERROR_TEXT_ENTRY(ENODATA, "No data available"),
    ERROR_TEXT_ENTRY(ETIME, "Timer expired"),
    ERROR_TEXT_ENTRY(ENOSR, "Out of streams resources"),
    ERROR_TEXT_ENTRY(ENONET, "Machine is not on the network"),
    ERROR_TEXT_ENTRY(ENOPKG, "Package not installed"),
    ERROR_TEXT_ENTRY(EREMOTE, "Object is remote"),
    ERROR_TEXT_ENTRY(ENOLINK, "Link has been severed"),
    ERROR_TEXT_ENTRY(EADV, "Advertise error"),
    ERROR_TEXT_ENTRY(ESRMNT, "Srmount error"),
    ERROR_TEXT_ENTRY(ECOMM, "Communication error on send"),
    ERROR_TEXT_ENTRY(EPROTO, "Protocol error"),
    ERROR_TEXT_ENTRY(EMULTIHOP, "Multihop attempted"),
    ERROR_TEXT_ENTRY(EDOTDOT, "RFS specific error"),
    ERROR_TEXT_ENTRY(EBADMSG, "Bad message"),
    ERROR_TEXT_ENTRY(EOVERFLOW, "Value too large for defined data type"),
    ERROR_TEXT_ENTRY(ENOTUNIQ, "Name not unique on network"),
    ERROR_TEXT_ENTRY(EBADFD, "File descriptor in bad state"),
    ERROR_TEXT_ENTRY(EREMCHG, "Remote address changed"),
    ERROR_TEXT_ENTRY(ELIBACC, "Can not access a needed shared library"),
    ERROR_TEXT_ENTRY(ELIBBAD, "Accessing a corrupted shared library"),
    ERROR_TEXT_ENTRY(ELIBSCN, ".lib section in a.out corrupted"),
    ERROR_TEXT_ENTRY(ELIBMAX, "Attempting to link in too many shared libraries"),
    ERROR_TEXT_ENTRY(ELIBEXEC, "Cannot exec a shared library directly"),
    ERROR_TEXT_ENTRY(EILSEQ, "Invalid or incomplete multibyte or wide character"),
    ERROR_TEXT_ENTRY(ERESTART, "Interrupted system call should be restarted"),
    ERROR_TEXT_ENTRY(ESTRPIPE, "Streams pipe error"),
    ERROR_TEXT_ENTRY(EUSERS, "Too many users"),
    ERROR_TEXT_ENTRY(ENOTSOCK, "Socket operation on non-socket"),
    ERROR_TEXT_ENTRY(EDESTADDRREQ, "Destination address required"),
    ERROR_TEXT_ENTRY(EMSGSIZE, "Message too long"),
    ERROR_TEXT_ENTRY(EPROTOTYPE, "Protocol wrong type for socket"),
    ERROR_TEXT_ENTRY(ENOPROTOOPT, "Protocol not available"),
    ERROR_TEXT_ENTRY(EPROTONOSUPPORT, "Protocol not supported"),
    ERROR_TEXT_ENTRY(ESOCKTNOSUPPORT, "Socket type not supported"),
    ERROR_TEXT_ENTRY(EOPNOTSUPP, "Operation not supported"),
    ERROR_TEXT_ENTRY(EPFNOSUPPORT, "Protocol family not supported"),
    ERROR_TEXT_ENTRY(EAFNOSUPPORT, "Address family not supported by protocol"),
    ERROR_TEXT_ENTRY(EADDRINUSE, "Address already in use"),
    ERROR_TEXT_ENTRY(EADDRNOTAVAIL, "Cannot assign requested address"),
    ERROR_TEXT_ENTRY(ENETDOWN, "Network is down"),
    ERROR_TEXT_ENTRY(ENETUNREACH, "Network is unreachable"),
    ERROR_TEXT_ENTRY(ENETRESET, "Network dropped connection on reset"),
    ERROR_TEXT_ENTRY(ECONNABORTED, "Software caused connection abort"),
    ERROR_TEXT_ENTRY(ECONNRESET, "Connection reset by peer"),
    ERROR_TEXT_ENTRY(ENOBUFS, "No buffer space available"),
    ERROR_TEXT_ENTRY(EISCONN, "Transport endpoint is already connected"),
    ERROR_TEXT_ENTRY(ENOTCONN, "Transport endpoint is not connected"),
    ERROR_TEXT_ENTRY(ESHUTDOWN, "Cannot send after transport endpoint shutdown"),
    ERROR_TEXT_ENTRY(ETOOMANYREFS, "Too many references: cannot splice"),
    ERROR_TEXT_ENTRY(ETIMEDOUT, "Connection timed out"),
    ERROR_TEXT_ENTRY(ECONNREFUSED, "Connection refused"),
    ERROR_TEXT_ENTRY(EHOSTDOWN, "Host is down"),
    ERROR_TEXT_ENTRY(EHOSTUNREACH, "No route to host"),
    ERROR_TEXT_ENTRY(EALREADY, "Operation already in progress"),
    ERROR_TEXT_ENTRY(EINPROGRESS, "Operation now in progress"),
    ERROR_TEXT_ENTRY(ESTALE, "Stale file handle"),
    ERROR_TEXT_ENTRY(EUCLEAN, "Structure needs cleaning"),
    ERROR_TEXT_ENTRY(ENOTNAM, "Not a XENIX named type file"),
    ERROR_TEXT_ENTRY(ENAVAIL, "No XENIX semaphores available"),
    ERROR_TEXT_ENTRY(EISNAM, "Is a named type file"),
    ERROR_TEXT_ENTRY(EREMOTEIO, "Remote I/O error"),
    ERROR_TEXT_ENTRY(EDQUOT, "Disk quota exceeded"),
    ERROR_TEXT_ENTRY(ENOMEDIUM, "No medium found"),
    ERROR_TEXT_ENTRY(EMEDIUMTYPE, "Wrong medium type"),
    ERROR_TEXT_ENTRY(ECANCELED, "Operation canceled"),
    ERROR_TEXT_ENTRY(ENOKEY, "Required key not available"),
    ERROR_TEXT_ENTRY(EKEYEXPIRED, "Key has expired"),
    ERROR_TEXT_ENTRY(EKEYREVOKED, "Key has been revoked"),
    ERROR_TEXT_ENTRY(EKEYREJECTED, "Key was rejected by service"),
    ERROR_TEXT_ENTRY(EOWNERDEAD, "Owner died"),
    ERROR_TEXT_ENTRY(ENOTRECOVERABLE, "State not recoverable"),
    ERROR_TEXT_ENTRY(ERFKILL, "Operation not possible due to RF-kill"),
    ERROR_TEXT_ENTRY(EHWPOISON, "Memory page has hardware error"),
    ERROR_TEXT_ENTRY(ERESTARTSYS, "Restart system"),
    ERROR_TEXT_ENTRY(ERESTARTNOINTR, "Restart monitor"),
    ERROR_TEXT_ENTRY(ERESTARTNOHAND, "Restart if no handler"),
    ERROR_TEXT_ENTRY(ENOIOCTLCMD, "No ioctl command"),
    ERROR_TEXT_ENTRY(ERESTART_RESTARTBLOCK, "Restart by calling sys_restart_syscall"),
    ERROR_TEXT_ENTRY(EPROBE_DEFER, "Driver requests probe retry"),
    ERROR_TEXT_ENTRY(EOPENSTALE, "Open found a stale dentry"),

    ERROR_TEXT_ENTRY(EBADHANDLE, "Illegal NFS file handle"),
    ERROR_TEXT_ENTRY(ENOTSYNC, "Update synchronization mismatch"),
    ERROR_TEXT_ENTRY(EBADCOOKIE, "Cookie is stale"),
    ERROR_TEXT_ENTRY(ENOTSUPP, "Operation is not supported"),
    ERROR_TEXT_ENTRY(ETOOSMALL, "Buffer or request is too small"),
    ERROR_TEXT_ENTRY(ESERVERFAULT, "An untranslatable error occurred"),
    ERROR_TEXT_ENTRY(EBADTYPE, "Type not supported by server"),
    ERROR_TEXT_ENTRY(EJUKEBOX, "Request initiated, but will not complete before timeout"),
    ERROR_TEXT_ENTRY(EIOCBQUEUED, "IOCB queued, will get completion event"),
};

#define ERROR_TEXT_ARRAY_SIZE (sizeof(_error_text) / sizeof(_error_text[0]))

const char *cts_strerror(int errno)
{
    if (errno > 0) {
        return "<valid offset/length>";
    } else if (-errno < (int)ERROR_TEXT_ARRAY_SIZE) {
        const char *s = _error_text[-errno];
        if (s) {
            return s;
        }
    }

    return "<Unknown error>";
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值