kernel errno ,及native app 执行系统调用错误判断举例sqlite.c Log Error
#define unixLogError(a,b,c) unixLogErrorAtLine(a,b,c,__LINE__) //external/sqlite/dist/orig/sqlite3.c 26558static int unixLogErrorAtLine( 26559 int errcode, /* SQLite error code */ 26560 const char *zFunc, /* Name of OS function that failed */ 26561 const char *zPath, /* File path associated with error */ 26562 int iLine /* Source line number where error occurred */ 26563){ 26564 char *zErr; /* Message from strerror() or equivalent */ 26565 int iErrno = errno; /* Saved syscall error number */
.....................
26601 if( zPath==0 ) zPath = ""; 26602 sqlite3_log(errcode, 26603 "os_unix.c:%d: (%d) %s(%s) - %s", 26604 iLine, iErrno, zFunc, zPath, zErr 26605 ); 26606 26607 return errcode;
uapi/linux/errno.h
#ifndef _ASM_GENERIC_ERRNO_BASE_H 2#define _ASM_GENERIC_ERRNO_BASE_H 3 4#define EPERM 1 /* Operation not permitted */ 5#define ENOENT 2 /* 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 ENOEXEC 8 /* Exec format error */ 12#define EBADF 9 /* Bad file number */ 13#define ECHILD 10 /* No child processes */ 14#define EAGAIN 11 /* Try again */ 15#define ENOMEM 12 /* Out of memory */ 16#define EACCES 13 /* Permission denied */ 17#define EFAULT 14 /* Bad address */ 18#define ENOTBLK 15 /* Block device required */ 19#define EBUSY 16 /* Device or resource busy */ 20#define EEXIST 17 /* File exists */ 21#define EXDEV 18 /* Cross-device link */ 22#define ENODEV 19 /* No such device */ 23#define ENOTDIR 20 /* Not a directory */ 24#define EISDIR 21 /* Is a directory */ 25#define EINVAL 22 /* Invalid argument */ 26#define ENFILE 23 /* File table overflow */ 27#define EMFILE 24 /* Too many open files */ 28#define ENOTTY 25 /* Not a typewriter */ 29#define ETXTBSY 26 /* Text file busy */ 30#define EFBIG 27 /* File too large */ 31#define ENOSPC 28 /* No space left on device */ 32#define ESPIPE 29 /* Illegal seek */ 33#define EROFS 30 /* Read-only file system */ 34#define EMLINK 31 /* Too many links */ 35#define EPIPE 32 /* Broken pipe */ 36#define EDOM 33 /* Math argument out of domain of func */ 37#define ERANGE 34 /* Math result not representable */ 38 39#endif
android.mk :
320 LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
321 LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
kernel generic header file :
uapi/linux/mmc/Kbuild:header-y += ioctl.h
other linux errno :
linux/errno.h
fndef _LINUX_ERRNO_H
#define _LINUX_ERRNO_H
#include <uapi/linux/errno.h>
/*
* These should never be seen by user programs. To return one of ERESTART*
* codes, signal_pending() MUST be set. Note that ptrace can observe these
* at syscall exit tracing, but they will never be left for the debugged user
* process to see.
*/
#define ERESTARTSYS512
#define ERESTARTNOINTR513
#define ERESTARTNOHAND514/* restart if no handler.. */
#define ENOIOCTLCMD515/* No ioctl command */
#define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */
#define EPROBE_DEFER517/* Driver requests probe retry */
#define EOPENSTALE518/* open found a stale dentry */
/* Defined for the NFSv3 protocol */
#define EBADHANDLE521/* Illegal NFS file handle */
#define ENOTSYNC522/* Update synchronization mismatch */
#define EBADCOOKIE523/* Cookie is stale */
#define ENOTSUPP524/* Operation is not supported */
#define ETOOSMALL525/* Buffer or request is too small */
#define ESERVERFAULT526/* An untranslatable error occurred */
#define EBADTYPE527/* Type not supported by server */
#define EJUKEBOX528/* Request initiated, but will not complete before timeout */
#define EIOCBQUEUED529/* iocb queued, will get completion event */
#endif