diff options
author | Christopher Faylor <me@cgf.cx> | 2000-08-22 03:58:47 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-08-22 03:58:47 +0000 |
commit | 9e2baf8dfad8c1d2ebb00363a83be49767eca77f (patch) | |
tree | a66c765b39b52aec0e0cc28b40522a7964b06b0c /winsup/cygwin/errno.cc | |
parent | 6b85369f8267a463c02571f2bd4b2406d185ee9a (diff) | |
download | newlib-9e2baf8dfad8c1d2ebb00363a83be49767eca77f.zip newlib-9e2baf8dfad8c1d2ebb00363a83be49767eca77f.tar.gz newlib-9e2baf8dfad8c1d2ebb00363a83be49767eca77f.tar.bz2 |
* cygerrno.h: New file. Use this throughout whenever errno manipulation is
required.
* errno.cc: Use DWORD to hold Windows errors.
(geterrno_from_win_error): New function.
(seterrno_from_win_error): Use geterrno_from_win_error to convert supplied
windows error (suggested by Corinna Vinschen).
* path.cc (symlink_info): Add error element.
* path.cc (path_conv::check): Remove errno setting. Use new symlink_info errno
element to set path_conv error, where appropriate.
(symlink_info::check): Set error element rather than attempting to manipulate
errno. Add more checks for trailing / and /.. even though they are currently
useless. Avoid setting EINVAL.
* path.cc (normalize_posix_path): Correct check for trailing /.
Diffstat (limited to 'winsup/cygwin/errno.cc')
-rw-r--r-- | winsup/cygwin/errno.cc | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index 1485c19..25dcf70 100644 --- a/winsup/cygwin/errno.cc +++ b/winsup/cygwin/errno.cc @@ -12,6 +12,7 @@ details. */ #define _REENT_ONLY #include <stdio.h> #include <errno.h> +#include "cygerrno.h" /* Table to map Windows error codes to Errno values. */ /* FIXME: Doing things this way is a little slow. It's trivial to change @@ -21,7 +22,7 @@ details. */ static const struct { - int w; /* windows version of error */ + DWORD w; /* windows version of error */ const char *s; /* text of windows version */ int e; /* errno version of error */ } @@ -108,34 +109,33 @@ errmap[] = { 0, NULL, 0} }; -/* seterrno_from_win_error: Given a Windows error code, set errno - as appropriate. */ -void -seterrno_from_win_error (const char *file, int line, int code) +int __stdcall +geterrno_from_win_error (DWORD code, int deferrno) { - int i; - - for (i = 0; errmap[i].w != 0; ++i) + for (int i = 0; errmap[i].w != 0; ++i) if (code == errmap[i].w) - break; + { + syscall_printf ("windows error %u == errno %d", code, errmap[i].e); + return errmap[i].e; + } - if (errmap[i].w != 0) - { - if (strace.active) - strace.prntf (_STRACE_SYSCALL, NULL, "%s:%d seterrno: %d (%s) -> %d", - file, line, code, errmap[i].s, errmap[i].e); - set_errno (errmap[i].e); - } - else - { - if (strace.active) - strace.prntf (_STRACE_SYSCALL, NULL, "%s:%d seterrno: unknown error %d", file, line, code); - set_errno (EACCES); - } + syscall_printf ("unknown windows error %u, setting errno to %d", code, + deferrno); + return deferrno; /* FIXME: what's so special about EACCESS? */ +} + +/* seterrno_from_win_error: Given a Windows error code, set errno + as appropriate. */ +void __stdcall +seterrno_from_win_error (const char *file, int line, DWORD code) +{ + syscall_printf ("%s:%d \b"); + set_errno (geterrno_from_win_error (code, EACCES)); + return; } /* seterrno: Set `errno' based on GetLastError (). */ -void +void __stdcall seterrno (const char *file, int line) { seterrno_from_win_error (file, line, GetLastError ()); @@ -672,4 +672,3 @@ strerror (int errnum) include files. */ return (char *) error; } - |