VirtualBox

source: kBuild/trunk/src/lib/nt/nthlpcore.c

Last change on this file was 3534, checked in by bird, 3 years ago

nt/nthlpcore.c: warning.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 18.8 KB
Line 
1/* $Id: nthlpcore.c 3534 2021-12-20 23:31:55Z bird $ */
2/** @file
3 * MSC + NT core helpers functions and globals.
4 */
5
6/*
7 * Copyright (c) 2005-2013 knut st. osmundsen <[email protected]>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * IN THE SOFTWARE.
26 *
27 * Alternatively, the content of this file may be used under the terms of the
28 * GPL version 2 or later, or LGPL version 2.1 or later.
29 */
30
31/*******************************************************************************
32* Header Files *
33*******************************************************************************/
34#include <errno.h>
35#include "nthlp.h"
36#ifndef NDEBUG
37# include <stdio.h>
38#endif
39
40
41/*******************************************************************************
42* Global Variables *
43*******************************************************************************/
44MY_NTSTATUS (WINAPI *g_pfnNtClose)(HANDLE);
45MY_NTSTATUS (WINAPI *g_pfnNtCreateFile)(PHANDLE, MY_ACCESS_MASK, MY_OBJECT_ATTRIBUTES *, MY_IO_STATUS_BLOCK *,
46 PLARGE_INTEGER, ULONG, ULONG, ULONG, ULONG, PVOID, ULONG);
47MY_NTSTATUS (WINAPI *g_pfnNtDeleteFile)(MY_OBJECT_ATTRIBUTES *);
48MY_NTSTATUS (WINAPI *g_pfnNtDuplicateObject)(HANDLE hSrcProc, HANDLE hSrc, HANDLE hDstProc, HANDLE *phRet,
49 MY_ACCESS_MASK fDesiredAccess, ULONG fAttribs, ULONG fOptions);
50MY_NTSTATUS (WINAPI *g_pfnNtReadFile)(HANDLE hFile, HANDLE hEvent, MY_IO_APC_ROUTINE *pfnApc, PVOID pvApcCtx,
51 MY_IO_STATUS_BLOCK *, PVOID pvBuf, ULONG cbToRead, PLARGE_INTEGER poffFile,
52 PULONG puKey);
53MY_NTSTATUS (WINAPI *g_pfnNtQueryInformationFile)(HANDLE, MY_IO_STATUS_BLOCK *, PVOID, LONG, MY_FILE_INFORMATION_CLASS);
54MY_NTSTATUS (WINAPI *g_pfnNtQueryVolumeInformationFile)(HANDLE, MY_IO_STATUS_BLOCK *, PVOID, LONG, MY_FS_INFORMATION_CLASS);
55MY_NTSTATUS (WINAPI *g_pfnNtQueryDirectoryFile)(HANDLE, HANDLE, MY_IO_APC_ROUTINE *, PVOID, MY_IO_STATUS_BLOCK *,
56 PVOID, ULONG, MY_FILE_INFORMATION_CLASS, BOOLEAN,
57 MY_UNICODE_STRING *, BOOLEAN);
58MY_NTSTATUS (WINAPI *g_pfnNtQueryAttributesFile)(MY_OBJECT_ATTRIBUTES *, MY_FILE_BASIC_INFORMATION *);
59MY_NTSTATUS (WINAPI *g_pfnNtQueryFullAttributesFile)(MY_OBJECT_ATTRIBUTES *, MY_FILE_NETWORK_OPEN_INFORMATION *);
60MY_NTSTATUS (WINAPI *g_pfnNtSetInformationFile)(HANDLE, MY_IO_STATUS_BLOCK *, PVOID, LONG, MY_FILE_INFORMATION_CLASS);
61BOOLEAN (WINAPI *g_pfnRtlDosPathNameToNtPathName_U)(PCWSTR, MY_UNICODE_STRING *, PCWSTR *, MY_RTL_RELATIVE_NAME_U *);
62MY_NTSTATUS (WINAPI *g_pfnRtlAnsiStringToUnicodeString)(MY_UNICODE_STRING *, MY_ANSI_STRING const *, BOOLEAN);
63MY_NTSTATUS (WINAPI *g_pfnRtlUnicodeStringToAnsiString)(MY_ANSI_STRING *, MY_UNICODE_STRING *, BOOLEAN);
64BOOLEAN (WINAPI *g_pfnRtlEqualUnicodeString)(MY_UNICODE_STRING const *, MY_UNICODE_STRING const *, BOOLEAN);
65BOOLEAN (WINAPI *g_pfnRtlEqualString)(MY_ANSI_STRING const *, MY_ANSI_STRING const *, BOOLEAN);
66UCHAR (WINAPI *g_pfnRtlUpperChar)(UCHAR uch);
67ULONG (WINAPI *g_pfnRtlNtStatusToDosError)(MY_NTSTATUS rcNt);
68VOID (WINAPI *g_pfnRtlAcquirePebLock)(VOID);
69VOID (WINAPI *g_pfnRtlReleasePebLock)(VOID);
70
71static struct
72{
73 FARPROC *ppfn;
74 const char *pszName;
75} const g_apfnDynamicNtdll[] =
76{
77 { (FARPROC *)&g_pfnNtClose, "NtClose" },
78 { (FARPROC *)&g_pfnNtCreateFile, "NtCreateFile" },
79 { (FARPROC *)&g_pfnNtDeleteFile, "NtDeleteFile" },
80 { (FARPROC *)&g_pfnNtDuplicateObject, "NtDuplicateObject" },
81 { (FARPROC *)&g_pfnNtReadFile, "NtReadFile" },
82 { (FARPROC *)&g_pfnNtQueryInformationFile, "NtQueryInformationFile" },
83 { (FARPROC *)&g_pfnNtQueryVolumeInformationFile, "NtQueryVolumeInformationFile" },
84 { (FARPROC *)&g_pfnNtQueryDirectoryFile, "NtQueryDirectoryFile" },
85 { (FARPROC *)&g_pfnNtQueryAttributesFile, "NtQueryAttributesFile" },
86 { (FARPROC *)&g_pfnNtQueryFullAttributesFile, "NtQueryFullAttributesFile" },
87 { (FARPROC *)&g_pfnNtSetInformationFile, "NtSetInformationFile" },
88 { (FARPROC *)&g_pfnRtlDosPathNameToNtPathName_U, "RtlDosPathNameToNtPathName_U" },
89 { (FARPROC *)&g_pfnRtlAnsiStringToUnicodeString, "RtlAnsiStringToUnicodeString" },
90 { (FARPROC *)&g_pfnRtlUnicodeStringToAnsiString, "RtlUnicodeStringToAnsiString" },
91 { (FARPROC *)&g_pfnRtlEqualUnicodeString, "RtlEqualUnicodeString" },
92 { (FARPROC *)&g_pfnRtlEqualString, "RtlEqualString" },
93 { (FARPROC *)&g_pfnRtlUpperChar, "RtlUpperChar" },
94 { (FARPROC *)&g_pfnRtlNtStatusToDosError, "RtlNtStatusToDosError" },
95 { (FARPROC *)&g_pfnRtlAcquirePebLock, "RtlAcquirePebLock" },
96 { (FARPROC *)&g_pfnRtlReleasePebLock, "RtlReleasePebLock" },
97};
98/** Set to 1 if we've successfully resolved the imports, otherwise 0. */
99int g_fResolvedNtImports = 0;
100
101
102
103void birdResolveImportsWorker(void)
104{
105 HMODULE hMod = LoadLibraryW(L"ntdll.dll");
106 int i = sizeof(g_apfnDynamicNtdll) / sizeof(g_apfnDynamicNtdll[0]);
107 while (i-- > 0)
108 {
109 const char *pszSym = g_apfnDynamicNtdll[i].pszName;
110 FARPROC pfn;
111 *g_apfnDynamicNtdll[i].ppfn = pfn = GetProcAddress(hMod, pszSym);
112 if (!pfn)
113 {
114 /* Write short message and die. */
115 static const char s_szMsg[] = "\r\nFatal error resolving NTDLL.DLL symbols!\r\nSymbol: ";
116 DWORD cbWritten;
117 if ( !WriteFile(GetStdHandle(STD_ERROR_HANDLE), s_szMsg, sizeof(s_szMsg) - 1, &cbWritten, NULL)
118 || !WriteFile(GetStdHandle(STD_ERROR_HANDLE), pszSym, (DWORD)strlen(pszSym), &cbWritten, NULL)
119 || !WriteFile(GetStdHandle(STD_ERROR_HANDLE), "\r\n", sizeof("\r\n") - 1, &cbWritten, NULL)
120 )
121 *(void **)(size_t)i = NULL;
122 ExitProcess(127);
123 }
124 }
125
126 g_fResolvedNtImports = 1;
127}
128
129
130void *birdTmpAlloc(size_t cb)
131{
132 return malloc(cb);
133}
134
135
136void birdTmpFree(void *pv)
137{
138 if (pv)
139 free(pv);
140}
141
142
143void *birdMemAlloc(size_t cb)
144{
145 return malloc(cb);
146}
147
148
149void *birdMemAllocZ(size_t cb)
150{
151 return calloc(cb, 1);
152}
153
154
155void birdMemFree(void *pv)
156{
157 if (pv)
158 free(pv);
159}
160
161
162int birdErrnoFromNtStatus(MY_NTSTATUS rcNt)
163{
164 switch (rcNt)
165 {
166 /* EPERM = 1 */
167 case STATUS_CANNOT_DELETE:
168 return EPERM;
169 /* ENOENT = 2 */
170 case STATUS_NOT_FOUND:
171 case STATUS_OBJECT_NAME_NOT_FOUND:
172 case STATUS_OBJECT_PATH_NOT_FOUND:
173 case STATUS_OBJECT_NAME_INVALID:
174 case STATUS_INVALID_COMPUTER_NAME:
175 case STATUS_VARIABLE_NOT_FOUND:
176 case STATUS_MESSAGE_NOT_FOUND:
177 case STATUS_DLL_NOT_FOUND:
178 case STATUS_ORDINAL_NOT_FOUND:
179 case STATUS_ENTRYPOINT_NOT_FOUND:
180 case STATUS_PATH_NOT_COVERED:
181 case STATUS_BAD_NETWORK_PATH:
182 case STATUS_DFS_EXIT_PATH_FOUND:
183 case RPC_NT_OBJECT_NOT_FOUND:
184 case STATUS_DELETE_PENDING:
185 return ENOENT;
186 /* ESRCH = 3 */
187 case STATUS_PROCESS_NOT_IN_JOB:
188 return ESRCH;
189 /* EINTR = 4 */
190 case STATUS_ALERTED:
191 case STATUS_USER_APC:
192 return EINTR;
193 /* EIO = 5 */
194 /* ENXIO = 6 */
195 /* E2BIG = 7 */
196 /* ENOEXEC = 8 */
197 case STATUS_INVALID_IMAGE_FORMAT:
198 case STATUS_INVALID_IMAGE_NE_FORMAT:
199 case STATUS_INVALID_IMAGE_LE_FORMAT:
200 case STATUS_INVALID_IMAGE_NOT_MZ:
201 case STATUS_INVALID_IMAGE_PROTECT:
202 case STATUS_INVALID_IMAGE_WIN_16:
203 case STATUS_IMAGE_SUBSYSTEM_NOT_PRESENT:
204 case STATUS_IMAGE_CHECKSUM_MISMATCH:
205 case STATUS_IMAGE_MP_UP_MISMATCH:
206 case STATUS_IMAGE_MACHINE_TYPE_MISMATCH:
207 case STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE:
208 case STATUS_SYSTEM_IMAGE_BAD_SIGNATURE:
209 case STATUS_SECTION_NOT_IMAGE:
210 case STATUS_INVALID_IMAGE_WIN_32:
211 case STATUS_INVALID_IMAGE_WIN_64:
212 case STATUS_INVALID_IMAGE_HASH:
213 case STATUS_IMAGE_CERT_REVOKED:
214 return ENOEXEC;
215 /* EBADF = 9 */
216 case STATUS_INVALID_HANDLE:
217 case STATUS_PORT_CLOSED:
218 case STATUS_OPLOCK_HANDLE_CLOSED:
219 case STATUS_HANDLES_CLOSED:
220 case STATUS_FILE_FORCED_CLOSED:
221 return EBADF;
222 /* ECHILD = 10 */
223 /* EAGAIN = 11 */
224 case STATUS_WMI_TRY_AGAIN:
225 case STATUS_GRAPHICS_TRY_AGAIN_LATER:
226 case STATUS_GRAPHICS_TRY_AGAIN_NOW:
227 return EAGAIN;
228 /* ENOMEM = 12 */
229 case STATUS_NO_MEMORY:
230 case STATUS_HV_INSUFFICIENT_MEMORY:
231 case STATUS_INSUFFICIENT_RESOURCES:
232 case STATUS_REMOTE_RESOURCES:
233 case STATUS_INSUFF_SERVER_RESOURCES:
234 return ENOMEM;
235 /* EACCES = 13 */
236 case STATUS_ACCESS_DENIED:
237 case STATUS_NETWORK_ACCESS_DENIED:
238 case RPC_NT_PROXY_ACCESS_DENIED:
239 case STATUS_CTX_SHADOW_DENIED:
240 case STATUS_CTX_WINSTATION_ACCESS_DENIED:
241 return EACCES;
242 /* EFAULT = 14 */
243 case STATUS_ACCESS_VIOLATION:
244 case STATUS_HARDWARE_MEMORY_ERROR:
245 return EFAULT;
246 /* EBUSY = 16 */
247 case STATUS_PIPE_BUSY:
248 case STATUS_RESOURCE_IN_USE:
249 return EBUSY;
250 /* EEXIST = 17 */
251 case STATUS_OBJECT_NAME_EXISTS:
252 case STATUS_OBJECT_NAME_COLLISION:
253 case STATUS_DUPLICATE_NAME:
254 return EEXIST;
255 /* EXDEV = 18 */
256 case STATUS_NOT_SAME_DEVICE:
257 return EXDEV;
258 /* ENODEV = 19 */
259 /* ENOTDIR = 20 */
260 case STATUS_NOT_A_DIRECTORY:
261 case STATUS_DIRECTORY_IS_A_REPARSE_POINT:
262 case STATUS_OBJECT_PATH_SYNTAX_BAD:
263 case STATUS_OBJECT_PATH_INVALID:
264 case STATUS_OBJECT_TYPE_MISMATCH:
265 return ENOTDIR;
266 /* EISDIR = 21 */
267 case STATUS_FILE_IS_A_DIRECTORY:
268 return EISDIR;
269 /* EINVAL = 22 */
270 case STATUS_INVALID_PARAMETER:
271 case STATUS_INVALID_PARAMETER_1:
272 case STATUS_INVALID_PARAMETER_2:
273 case STATUS_INVALID_PARAMETER_3:
274 case STATUS_INVALID_PARAMETER_4:
275 case STATUS_INVALID_PARAMETER_5:
276 case STATUS_INVALID_PARAMETER_6:
277 case STATUS_INVALID_PARAMETER_7:
278 case STATUS_INVALID_PARAMETER_8:
279 case STATUS_INVALID_PARAMETER_9:
280 case STATUS_INVALID_PARAMETER_10:
281 case STATUS_INVALID_PARAMETER_11:
282 case STATUS_INVALID_PARAMETER_12:
283 case STATUS_INVALID_PARAMETER_MIX:
284 return EINVAL;
285 /* ENFILE = 23 */
286 /* EMFILE = 24 */
287 case STATUS_TOO_MANY_OPENED_FILES:
288 return EMFILE;
289 /* ENOTTY = 25 */
290 /* EFBIG = 27 */
291 /* ENOSPC = 28 */
292 case STATUS_DISK_FULL:
293 return ENOSPC;
294 /* ESPIPE = 29 */
295 /* EROFS = 30 */
296 /* EMLINK = 31 */
297 /* EPIPE = 32 */
298 case STATUS_PIPE_BROKEN:
299 case RPC_NT_PIPE_CLOSED:
300 return EPIPE;
301 /* EDOM = 33 */
302 /* ERANGE = 34 */
303 /* EDEADLK = 36 */
304 case STATUS_POSSIBLE_DEADLOCK:
305 return EDEADLK;
306 /* ENAMETOOLONG = 38 */
307 case STATUS_NAME_TOO_LONG:
308 return ENAMETOOLONG;
309 /* ENOLCK = 39 */
310 /* ENOSYS = 40 */
311 case STATUS_NOT_SUPPORTED:
312 return ENOSYS;
313 /* ENOTEMPTY = 41 */
314 case STATUS_DIRECTORY_NOT_EMPTY:
315 return ENOTEMPTY;
316 /* EILSEQ = 42 */
317 /* EADDRINUSE = 100 */
318 /* EADDRNOTAVAIL = 101 */
319 /* EAFNOSUPPORT = 102 */
320 /* EALREADY = 103 */
321 case STATUS_INTERRUPT_VECTOR_ALREADY_CONNECTED:
322 case STATUS_DEVICE_ALREADY_ATTACHED:
323 case STATUS_PORT_ALREADY_SET:
324 case STATUS_IMAGE_ALREADY_LOADED:
325 case STATUS_TOKEN_ALREADY_IN_USE:
326 case STATUS_IMAGE_ALREADY_LOADED_AS_DLL:
327 case STATUS_ADDRESS_ALREADY_EXISTS:
328 case STATUS_ADDRESS_ALREADY_ASSOCIATED:
329 return EALREADY;
330 /* EBADMSG = 104 */
331 /* ECANCELED = 105 */
332 /* ECONNABORTED = 106 */
333 /* ECONNREFUSED = 107 */
334 /* ECONNRESET = 108 */
335 /* EDESTADDRREQ = 109 */
336 /* EHOSTUNREACH = 110 */
337 case STATUS_HOST_UNREACHABLE:
338 return EHOSTUNREACH;
339 /* EIDRM = 111 */
340 /* EINPROGRESS = 112 */
341 /* EISCONN = 113 */
342 /* ELOOP = 114 */
343 /* EMSGSIZE = 115 */
344 /* ENETDOWN = 116 */
345 /* ENETRESET = 117 */
346 /* ENETUNREACH = 118 */
347 case STATUS_NETWORK_UNREACHABLE:
348 return ENETUNREACH;
349 /* ENOBUFS = 119 */
350 /* ENODATA = 120 */
351 /* ENOLINK = 121 */
352 /* ENOMSG = 122 */
353 /* ENOPROTOOPT = 123 */
354 /* ENOSR = 124 */
355 /* ENOSTR = 125 */
356 /* ENOTCONN = 126 */
357 /* ENOTRECOVERABLE = 127 */
358 /* ENOTSOCK = 128 */
359 /* ENOTSUP = 129 */
360 /* EOPNOTSUPP = 130 */
361 /* EOTHER = 131 */
362 /* EOVERFLOW = 132 */
363 /* EOWNERDEAD = 133 */
364 /* EPROTO = 134 */
365 /* EPROTONOSUPPORT = 135 */
366 /* EPROTOTYPE = 136 */
367 /* ETIME = 137 */
368 /* ETIMEDOUT = 138 */
369 case STATUS_VIRTUAL_CIRCUIT_CLOSED:
370 case STATUS_TIMEOUT:
371 return ETIMEDOUT;
372
373 /* ETXTBSY = 139 */
374 case STATUS_SHARING_VIOLATION:
375 return ETXTBSY;
376 /* EWOULDBLOCK = 140 */
377 }
378
379#ifndef NDEBUG
380 __debugbreak();
381 fprintf(stderr, "rcNt=%#x (%d)\n", rcNt, rcNt);
382#endif
383 return EINVAL;
384}
385
386
387int birdSetErrnoFromNt(MY_NTSTATUS rcNt)
388{
389 errno = birdErrnoFromNtStatus(rcNt);
390#if 0
391 {
392 ULONG rcWin32;
393 _doserrno = rcWin32 = g_pfnRtlNtStatusToDosError(rcNt);
394 SetLastError(rcWin32);
395 }
396#endif
397 return -1;
398}
399
400
401int birdSetErrnoFromWin32(DWORD dwErr)
402{
403 switch (dwErr)
404 {
405 default:
406 case ERROR_INVALID_FUNCTION: errno = EINVAL; break;
407 case ERROR_FILE_NOT_FOUND: errno = ENOENT; break;
408 case ERROR_PATH_NOT_FOUND: errno = ENOENT; break;
409 case ERROR_TOO_MANY_OPEN_FILES: errno = EMFILE; break;
410 case ERROR_ACCESS_DENIED: errno = EACCES; break;
411 case ERROR_INVALID_HANDLE: errno = EBADF; break;
412 case ERROR_ARENA_TRASHED: errno = ENOMEM; break;
413 case ERROR_NOT_ENOUGH_MEMORY: errno = ENOMEM; break;
414 case ERROR_INVALID_BLOCK: errno = ENOMEM; break;
415 case ERROR_BAD_ENVIRONMENT: errno = E2BIG; break;
416 case ERROR_BAD_FORMAT: errno = ENOEXEC; break;
417 case ERROR_INVALID_ACCESS: errno = EINVAL; break;
418 case ERROR_INVALID_DATA: errno = EINVAL; break;
419 case ERROR_INVALID_DRIVE: errno = ENOENT; break;
420 case ERROR_CURRENT_DIRECTORY: errno = EACCES; break;
421 case ERROR_NOT_SAME_DEVICE: errno = EXDEV; break;
422 case ERROR_NO_MORE_FILES: errno = ENOENT; break;
423 case ERROR_LOCK_VIOLATION: errno = EACCES; break;
424 case ERROR_BAD_NETPATH: errno = ENOENT; break;
425 case ERROR_NETWORK_ACCESS_DENIED: errno = EACCES; break;
426 case ERROR_BAD_NET_NAME: errno = ENOENT; break;
427 case ERROR_FILE_EXISTS: errno = EEXIST; break;
428 case ERROR_CANNOT_MAKE: errno = EACCES; break;
429 case ERROR_FAIL_I24: errno = EACCES; break;
430 case ERROR_INVALID_PARAMETER: errno = EINVAL; break;
431 case ERROR_NO_PROC_SLOTS: errno = EAGAIN; break;
432 case ERROR_DRIVE_LOCKED: errno = EACCES; break;
433 case ERROR_BROKEN_PIPE: errno = EPIPE; break;
434 case ERROR_DISK_FULL: errno = ENOSPC; break;
435 case ERROR_INVALID_TARGET_HANDLE: errno = EBADF; break;
436 case ERROR_WAIT_NO_CHILDREN: errno = ECHILD; break;
437 case ERROR_CHILD_NOT_COMPLETE: errno = ECHILD; break;
438 case ERROR_DIRECT_ACCESS_HANDLE: errno = EBADF; break;
439 case ERROR_NEGATIVE_SEEK: errno = EINVAL; break;
440 case ERROR_SEEK_ON_DEVICE: errno = EACCES; break;
441 case ERROR_DIR_NOT_EMPTY: errno = ENOTEMPTY; break;
442 case ERROR_NOT_LOCKED: errno = EACCES; break;
443 case ERROR_BAD_PATHNAME: errno = ENOENT; break;
444 case ERROR_MAX_THRDS_REACHED: errno = EAGAIN; break;
445 case ERROR_LOCK_FAILED: errno = EACCES; break;
446 case ERROR_ALREADY_EXISTS: errno = EEXIST; break;
447 case ERROR_FILENAME_EXCED_RANGE: errno = ENOENT; break;
448 case ERROR_NESTING_NOT_ALLOWED: errno = EAGAIN; break;
449#ifdef EMLINK
450 case ERROR_TOO_MANY_LINKS: errno = EMLINK; break;
451#endif
452
453 case ERROR_SHARING_VIOLATION:
454 errno = ETXTBSY;
455 break;
456 }
457
458 return -1;
459}
460
461
462int birdSetErrnoToNoMem(void)
463{
464 errno = ENOMEM;
465 return -1;
466}
467
468
469int birdSetErrnoToInvalidArg(void)
470{
471 errno = EINVAL;
472 return -1;
473}
474
475
476int birdSetErrnoToBadFileNo(void)
477{
478 errno = EBADF;
479 return -1;
480}
481
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette