Commit | Line | Data |
---|---|---|
805e021f CE |
1 | /* |
2 | * Copyright 2000, International Business Machines Corporation and others. | |
3 | * All Rights Reserved. | |
4 | * | |
5 | * This software has been released under the terms of the IBM Public | |
6 | * License. For details, see the LICENSE file in the top-level source | |
7 | * directory or online at http://www.openafs.org/dl/license10.html | |
8 | */ | |
9 | ||
10 | #include <afsconfig.h> | |
11 | #include <afs/param.h> | |
12 | ||
13 | ||
14 | #include <windows.h> | |
15 | #include <afs/errmap_nt.h> | |
16 | ||
17 | int nterr_lastNTError = 0; /* Useful for core dumps from LWP based binaries */ | |
18 | ||
19 | /* | |
20 | * nterr_nt2unix() -- convert NT error code to a Unix-ish value. | |
21 | * | |
22 | * RETURN CODES: translated code, or 'defaultErr' if no translation available. | |
23 | */ | |
24 | ||
25 | int | |
26 | nterr_nt2unix(long ntErr, int defaultErr) | |
27 | { | |
28 | int ucode; | |
29 | ||
30 | nterr_lastNTError = ntErr; | |
31 | switch (ntErr) { | |
32 | case ERROR_SUCCESS: | |
33 | ucode = 0; | |
34 | break; | |
35 | case ERROR_INVALID_PARAMETER: | |
36 | case ERROR_BAD_COMMAND: | |
37 | ucode = EINVAL; | |
38 | break; | |
39 | case ERROR_FILE_NOT_FOUND: | |
40 | case ERROR_PATH_NOT_FOUND: | |
41 | case ERROR_INVALID_DRIVE: | |
42 | ucode = ENOENT; | |
43 | break; | |
44 | case ERROR_FILE_EXISTS: | |
45 | case ERROR_ALREADY_EXISTS: | |
46 | ucode = EEXIST; | |
47 | break; | |
48 | case ERROR_ACCESS_DENIED: | |
49 | ucode = EACCES; | |
50 | break; | |
51 | case ERROR_WRITE_PROTECT: | |
52 | ucode = EROFS; | |
53 | break; | |
54 | case ERROR_NOT_SUPPORTED: | |
55 | ucode = ENOTTY; | |
56 | break; | |
57 | case ERROR_INVALID_HANDLE: | |
58 | ucode = EBADF; | |
59 | break; | |
60 | case ERROR_TOO_MANY_OPEN_FILES: | |
61 | ucode = EMFILE; | |
62 | break; | |
63 | case ERROR_DISK_FULL: | |
64 | case ERROR_HANDLE_DISK_FULL: | |
65 | ucode = ENOSPC; | |
66 | break; | |
67 | case ERROR_OUTOFMEMORY: | |
68 | case ERROR_NOT_ENOUGH_MEMORY: | |
69 | ucode = ENOMEM; | |
70 | break; | |
71 | case ERROR_SHARING_VIOLATION: | |
72 | case ERROR_PIPE_BUSY: | |
73 | ucode = EBUSY; | |
74 | break; | |
75 | case ERROR_BROKEN_PIPE: | |
76 | case ERROR_BAD_PIPE: | |
77 | case ERROR_PIPE_NOT_CONNECTED: | |
78 | ucode = EPIPE; | |
79 | break; | |
80 | default: | |
81 | ucode = defaultErr; | |
82 | break; | |
83 | } | |
84 | ||
85 | return ucode; | |
86 | } |