操作系統OS Error問題

在筆者使用腳本的過程中,經常會遇到OS Error問題,包括Windows/Linux操作系統。因此,本篇文章僅對OS Error做一個彙總。

Windows操作系統

Windows Error Code定義在 WinError.h頭文件中,0-100的錯誤碼意義如下(直接通過 Error Code搜索)。

ERROR_SUCCESS
0 (0x0)
The operation completed successfully.
ERROR_INVALID_FUNCTION
1 (0x1)
Incorrect function.
ERROR_FILE_NOT_FOUND
2 (0x2)
The system cannot find the file specified.
ERROR_PATH_NOT_FOUND
3 (0x3)
The system cannot find the path specified.
ERROR_TOO_MANY_OPEN_FILES
4 (0x4)
The system cannot open the file.
ERROR_ACCESS_DENIED
5 (0x5)
Access is denied.
ERROR_INVALID_HANDLE
6 (0x6)
The handle is invalid.
ERROR_ARENA_TRASHED
7 (0x7)
The storage control blocks were destroyed.
ERROR_NOT_ENOUGH_MEMORY
8 (0x8)
Not enough storage is available to process this command.
ERROR_INVALID_BLOCK
9 (0x9)
The storage control block address is invalid.
ERROR_BAD_ENVIRONMENT
10 (0xA)
The environment is incorrect.
ERROR_BAD_FORMAT
11 (0xB)
An attempt was made to load a program with an incorrect format.
ERROR_INVALID_ACCESS
12 (0xC)
The access code is invalid.
ERROR_INVALID_DATA
13 (0xD)
The data is invalid.
ERROR_OUTOFMEMORY
14 (0xE)
Not enough storage is available to complete this operation.
ERROR_INVALID_DRIVE
15 (0xF)
The system cannot find the drive specified.
ERROR_CURRENT_DIRECTORY
16 (0x10)
The directory cannot be removed.
ERROR_NOT_SAME_DEVICE
17 (0x11)
The system cannot move the file to a different disk drive.
ERROR_NO_MORE_FILES
18 (0x12)
There are no more files.
ERROR_WRITE_PROTECT
19 (0x13)
The media is write protected.
ERROR_BAD_UNIT
20 (0x14)
The system cannot find the device specified.
ERROR_NOT_READY
21 (0x15)
The device is not ready.
ERROR_BAD_COMMAND
22 (0x16)
The device does not recognize the command.
ERROR_CRC
23 (0x17)
Data error (cyclic redundancy check).
ERROR_BAD_LENGTH
24 (0x18)
The program issued a command but the command length is incorrect.
ERROR_SEEK
25 (0x19)
The drive cannot locate a specific area or track on the disk.
ERROR_NOT_DOS_DISK
26 (0x1A)
The specified disk or diskette cannot be accessed.
ERROR_SECTOR_NOT_FOUND
27 (0x1B)
The drive cannot find the sector requested.
ERROR_OUT_OF_PAPER
28 (0x1C)
The printer is out of paper.
ERROR_WRITE_FAULT
29 (0x1D)
The system cannot write to the specified device.
ERROR_READ_FAULT
30 (0x1E)
The system cannot read from the specified device.
ERROR_GEN_FAILURE
31 (0x1F)
A device attached to the system is not functioning.
ERROR_SHARING_VIOLATION
32 (0x20)
The process cannot access the file because it is being used by another process.
ERROR_LOCK_VIOLATION
33 (0x21)
The process cannot access the file because another process has locked a portion of the file.
ERROR_WRONG_DISK
34 (0x22)
The wrong diskette is in the drive. Insert %2 (Volume Serial Number: %3) into drive %1.
ERROR_SHARING_BUFFER_EXCEEDED
36 (0x24)
Too many files opened for sharing.
ERROR_HANDLE_EOF
38 (0x26)
Reached the end of the file.
ERROR_HANDLE_DISK_FULL
39 (0x27)
The disk is full.
ERROR_NOT_SUPPORTED
50 (0x32)
The request is not supported.
ERROR_REM_NOT_LIST
51 (0x33)
Windows cannot find the network path. Verify that the network path is correct and the destination computer is not busy or turned off. If Windows still cannot find the network path, contact your network administrator.
ERROR_DUP_NAME
52 (0x34)
You were not connected because a duplicate name exists on the network. If joining a domain, go to System in Control Panel to change the computer name and try again. If joining a workgroup, choose another workgroup name.
ERROR_BAD_NETPATH
53 (0x35)
The network path was not found.
ERROR_NETWORK_BUSY
54 (0x36)
The network is busy.
ERROR_DEV_NOT_EXIST
55 (0x37)
The specified network resource or device is no longer available.
ERROR_TOO_MANY_CMDS
56 (0x38)
The network BIOS command limit has been reached.
ERROR_ADAP_HDW_ERR
57 (0x39)
A network adapter hardware error occurred.
ERROR_BAD_NET_RESP
58 (0x3A)
The specified server cannot perform the requested operation.
ERROR_UNEXP_NET_ERR
59 (0x3B)
An unexpected network error occurred.
ERROR_BAD_REM_ADAP
60 (0x3C)
The remote adapter is not compatible.
ERROR_PRINTQ_FULL
61 (0x3D)
The printer queue is full.
ERROR_NO_SPOOL_SPACE
62 (0x3E)
Space to store the file waiting to be printed is not available on the server.
ERROR_PRINT_CANCELLED
63 (0x3F)
Your file waiting to be printed was deleted.
ERROR_NETNAME_DELETED
64 (0x40)
The specified network name is no longer available.
ERROR_NETWORK_ACCESS_DENIED
65 (0x41)
Network access is denied.
ERROR_BAD_DEV_TYPE
66 (0x42)
The network resource type is not correct.
ERROR_BAD_NET_NAME
67 (0x43)
The network name cannot be found.
ERROR_TOO_MANY_NAMES
68 (0x44)
The name limit for the local computer network adapter card was exceeded.
ERROR_TOO_MANY_SESS
69 (0x45)
The network BIOS session limit was exceeded.
ERROR_SHARING_PAUSED
70 (0x46)
The remote server has been paused or is in the process of being started.
ERROR_REQ_NOT_ACCEP
71 (0x47)
No more connections can be made to this remote computer at this time because there are already as many connections as the computer can accept.
ERROR_REDIR_PAUSED
72 (0x48)
The specified printer or disk device has been paused.
ERROR_FILE_EXISTS
80 (0x50)
The file exists.
ERROR_CANNOT_MAKE
82 (0x52)
The directory or file cannot be created.
ERROR_FAIL_I24
83 (0x53)
Fail on INT 24.
ERROR_OUT_OF_STRUCTURES
84 (0x54)
Storage to process this request is not available.
ERROR_ALREADY_ASSIGNED
85 (0x55)
The local device name is already in use.
ERROR_INVALID_PASSWORD
86 (0x56)
The specified network password is not correct.
ERROR_INVALID_PARAMETER
87 (0x57)
The parameter is incorrect.
ERROR_NET_WRITE_FAULT
88 (0x58)
A write fault occurred on the network.
ERROR_NO_PROC_SLOTS
89 (0x59)
The system cannot start another process at this time.
ERROR_TOO_MANY_SEMAPHORES
100 (0x64)
Cannot create another system semaphore.

Linux操作系統

Linux Error Code的定義文件是:/usr/include/asm/errno.h。以筆者使用的Centos 6.6爲例,該頭文件內容是#include <asm-generic/errno.h>,對應的真實路徑是:/usr/include/asm-generic/errno.h。 以下是Linux 0-100錯誤碼對應的定義:

#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      /* Level 2 not synchronized */
#define EL3HLT          46      /* Level 3 halted */
#define EL3RST          47      /* Level 3 reset */
#define ELNRNG          48      /* Link number out of range */
#define EUNATCH         49      /* Protocol driver not attached */
#define ENOCSI          50      /* No CSI structure available */
#define EL2HLT          51      /* 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 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      /* .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 operation on non-socket */
#define EDESTADDRREQ    89      /* Destination address required */
#define EMSGSIZE        90      /* Message too long */

參考

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章