Perform whitespace cleanup throughout.

* dcrt0.cc (signal_shift_subtract): Eliminate ancient backwards compatibility.
(check_sanity_and_sync): Ditto.
* winsup.h (SIGTOMASK): Ditto.  Just use constant in signal calculation.
* include/cygwin/version: Remove backwards signal mask compatibility define.
* path.cc (symlink_info::check_sysfile): Cosmetic change.
* registry.cc (get_registry_hive_path): Remove unneeded variable.
* exceptions.cc (handle_sigsuspend): Eliminate thread signal mask and use
either main sigmask or current thread sigmask.
(set_process_mask): Ditto.
(sighold): Ditto.
(sigrelse): Ditto.
(sigset): Ditto.
(set_process_mask_delta): Ditto.
(_cygtls::call_signal_handler): Ditto.
* fhandler_process.cc (format_process_status): Ditto.
* fhandler_termios.cc (fhandler_termios::bg_check): Ditto.
* pinfo.h (class pinfo): Ditto.
* select.cc (pselect): Ditto.
* signal.cc (sigprocmask): Ditto.
(abort): Ditto.
(sigpause): Ditto.
(sigsend): Ditto.
(wait_sig): Ditto.
* thread.h (pthread::parent_tls): New member.
* thread.cc (pthread::pthread): Record parent_tls here.
(pthread::thread_init_wrapper): Initialize sigmask from parent thread.
This commit is contained in:
Christopher Faylor 2008-02-15 17:53:11 +00:00
parent d039978069
commit 70300fdb1c
45 changed files with 315 additions and 315 deletions

View File

@ -1,3 +1,40 @@
2008-02-15 Christopher Faylor <me+cygwin@cgf.cx>
Perform whitespace cleanup throughout.
* dcrt0.cc (signal_shift_subtract): Eliminate ancient backwards
compatibility.
(check_sanity_and_sync): Ditto.
* winsup.h (SIGTOMASK): Ditto. Just use constant in signal
calculation.
* include/cygwin/version: Remove backwards signal mask compatibility
define.
* path.cc (symlink_info::check_sysfile): Cosmetic change.
* registry.cc (get_registry_hive_path): Remove unneeded variable.
* exceptions.cc (handle_sigsuspend): Eliminate thread signal mask and
use either main sigmask or current thread sigmask.
(set_process_mask): Ditto.
(sighold): Ditto.
(sigrelse): Ditto.
(sigset): Ditto.
(set_process_mask_delta): Ditto.
(_cygtls::call_signal_handler): Ditto.
* fhandler_process.cc (format_process_status): Ditto.
* fhandler_termios.cc (fhandler_termios::bg_check): Ditto.
* pinfo.h (class pinfo): Ditto.
* select.cc (pselect): Ditto.
* signal.cc (sigprocmask): Ditto.
(abort): Ditto.
(sigpause): Ditto.
(sigsend): Ditto.
(wait_sig): Ditto.
* thread.h (pthread::parent_tls): New member.
* thread.cc (pthread::pthread): Record parent_tls here.
(pthread::thread_init_wrapper): Initialize sigmask from parent thread.
2008-02-14 Corinna Vinschen <corinna@vinschen.de>
* cygheap.cc (cwcsdup): New function.
@ -243,7 +280,7 @@
(cwdstuff::get_handle): New method.
* path.cc (cwdstuff::set): When doit is true, always try to get
directory handle. Fail if duplicating handle fails. Store handle
in dir. Fix potential SEGV when setting drive_length.
in dir. Fix potential SEGV when setting drive_length.
2008-01-28 Corinna Vinschen <corinna@vinschen.de>

View File

@ -49,9 +49,9 @@ typedef struct _LSA_SECPKG_FUNCS
NTSTATUS (NTAPI *AllocateClientBuffer)(PLSA_CLIENT_REQUEST, ULONG, PVOID *);
NTSTATUS (NTAPI *FreeClientBuffer)(PLSA_CLIENT_REQUEST, PVOID);
NTSTATUS (NTAPI *CopyToClientBuffer)(PLSA_CLIENT_REQUEST, ULONG,
PVOID, PVOID);
PVOID, PVOID);
NTSTATUS (NTAPI *CopyFromClientBuffer)(PLSA_CLIENT_REQUEST, ULONG,
PVOID, PVOID);
PVOID, PVOID);
NTSTATUS (NTAPI *ImpersonateClient)(VOID);
NTSTATUS (NTAPI *UnloadPackage)(VOID);
NTSTATUS (NTAPI *DuplicateHandle)(HANDLE,PHANDLE);

View File

@ -5,4 +5,4 @@ sed -e '1,4d' -e '/KR_reset.*;/d' -e '/KR_output_statistics.*;/d' \
-e '/KR_reset.*)/,/}/d' -e '/KR_output_statistics.*)/,/}/d' \
-e '/# *line/d' "$c" > $2 &&
rm -f "$c"
# -e "s%$c"'"%'"$2"'"%g'
# -e "s%$c"'"%'"$2"'"%g'

View File

@ -74,14 +74,6 @@ _cygtls NO_COPY *_main_tls;
bool NO_COPY cygwin_finished_initializing;
/* Used in SIGTOMASK for generating a bit for insertion into a sigset_t.
This is subtracted from the signal number prior to shifting the bit.
In older versions of cygwin, the signal was used as-is to shift the
bit for masking. So, we'll temporarily detect this and set it to zero
for programs that are linked using older cygwins. This is just a stopgap
measure to allow an orderly transfer to the new, correct sigmask method. */
unsigned NO_COPY int signal_shift_subtract = 1;
MTinterface _mtinterf;
bool NO_COPY _cygwin_testing;
@ -443,10 +435,6 @@ check_sanity_and_sync (per_process *p)
if (p->api_major > cygwin_version.api_major)
api_fatal ("cygwin DLL and APP are out of sync -- API version mismatch %d > %d",
p->api_major, cygwin_version.api_major);
if (CYGWIN_VERSION_DLL_MAKE_COMBINED (p->dll_major, p->dll_minor) <=
CYGWIN_VERSION_DLL_BAD_SIGNAL_MASK)
signal_shift_subtract = 0;
}
child_info NO_COPY *child_proc_info = NULL;

View File

@ -43452,39 +43452,39 @@ device::parsedisk (int drive, int part)
int base;
if (drive < ('q' - 'a')) /* /dev/sda -to- /dev/sdp */
base = DEV_SD_MAJOR;
else if (drive < 32) /* /dev/sdq -to- /dev/sdaf */
else if (drive < 32) /* /dev/sdq -to- /dev/sdaf */
{
base = DEV_SD1_MAJOR;
drive -= 'q' - 'a';
}
else if (drive < 48) /* /dev/sdag -to- /dev/sdav */
else if (drive < 48) /* /dev/sdag -to- /dev/sdav */
{
base = DEV_SD2_MAJOR;
drive -= 32;
}
else if (drive < 64) /* /dev/sdaw -to- /dev/sdbl */
else if (drive < 64) /* /dev/sdaw -to- /dev/sdbl */
{
base = DEV_SD3_MAJOR;
drive -= 48;
}
else if (drive < 80) /* /dev/sdbm -to- /dev/sdcb */
else if (drive < 80) /* /dev/sdbm -to- /dev/sdcb */
{
base = DEV_SD4_MAJOR;
drive -= 64;
}
else if (drive < 96) /* /dev/sdcc -to- /dev/sdcr */
else if (drive < 96) /* /dev/sdcc -to- /dev/sdcr */
{
base = DEV_SD5_MAJOR;
drive -= 80;
}
else if (drive < 112) /* /dev/sdcs -to- /dev/sddh */
else if (drive < 112) /* /dev/sdcs -to- /dev/sddh */
{
base = DEV_SD6_MAJOR;
drive -= 96;
}
/* NOTE: This will cause multiple /dev/sddx entries in
/proc/partitions if there are more than 128 devices */
else /* /dev/sddi -to- /dev/sddx */
/proc/partitions if there are more than 128 devices */
else /* /dev/sddi -to- /dev/sddx */
{
base = DEV_SD7_MAJOR;
drive -= 112;

View File

@ -159,39 +159,39 @@ device::parsedisk (int drive, int part)
int base;
if (drive < ('q' - 'a')) /* /dev/sda -to- /dev/sdp */
base = DEV_SD_MAJOR;
else if (drive < 32) /* /dev/sdq -to- /dev/sdaf */
else if (drive < 32) /* /dev/sdq -to- /dev/sdaf */
{
base = DEV_SD1_MAJOR;
drive -= 'q' - 'a';
}
else if (drive < 48) /* /dev/sdag -to- /dev/sdav */
else if (drive < 48) /* /dev/sdag -to- /dev/sdav */
{
base = DEV_SD2_MAJOR;
drive -= 32;
}
else if (drive < 64) /* /dev/sdaw -to- /dev/sdbl */
else if (drive < 64) /* /dev/sdaw -to- /dev/sdbl */
{
base = DEV_SD3_MAJOR;
drive -= 48;
}
else if (drive < 80) /* /dev/sdbm -to- /dev/sdcb */
else if (drive < 80) /* /dev/sdbm -to- /dev/sdcb */
{
base = DEV_SD4_MAJOR;
drive -= 64;
}
else if (drive < 96) /* /dev/sdcc -to- /dev/sdcr */
else if (drive < 96) /* /dev/sdcc -to- /dev/sdcr */
{
base = DEV_SD5_MAJOR;
drive -= 80;
}
else if (drive < 112) /* /dev/sdcs -to- /dev/sddh */
else if (drive < 112) /* /dev/sdcs -to- /dev/sddh */
{
base = DEV_SD6_MAJOR;
drive -= 96;
}
/* NOTE: This will cause multiple /dev/sddx entries in
/proc/partitions if there are more than 128 devices */
else /* /dev/sddi -to- /dev/sddx */
/proc/partitions if there are more than 128 devices */
else /* /dev/sddi -to- /dev/sddx */
{
base = DEV_SD7_MAJOR;
drive -= 112;

View File

@ -45,7 +45,7 @@ for my $k (sort {$section{$a}{-idx} <=> $section{$b}{-idx}} keys %section) {
$vma = $section{$k}{-vma};
}
if ($vma != $section{$k}{-vma}) {
my $newvma = align($vma, $section{$k}{-algn});
my $newvma = align($vma, $section{$k}{-algn});
if ($newvma != $vma) {
printf STDERR "$0: ERROR $k VMA 0x%08x != 0x%08x\n", $vma, $newvma;
exit 1;

View File

@ -340,7 +340,7 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
access = GENERIC_READ | GENERIC_WRITE;
else if (fd == 0)
access = GENERIC_READ;
else
else
access = GENERIC_WRITE; /* Should be rdwr for stderr but not sure that's
possible for some versions of handles */
fh->init (handle, access, bin);

View File

@ -682,9 +682,9 @@ handle_sigsuspend (sigset_t tempmask)
return -1;
}
sigset_t oldmask = myself->getsigmask (); // Remember for restoration
sigset_t oldmask = _my_tls.sigmask; // Remember for restoration
set_signal_mask (tempmask, myself->getsigmask ());
set_signal_mask (tempmask, _my_tls.sigmask);
sigproc_printf ("oldmask %p, newmask %p", oldmask, tempmask);
pthread_testcancel ();
@ -995,8 +995,7 @@ ctrl_c_handler (DWORD type)
extern "C" void __stdcall
set_process_mask (sigset_t newmask)
{
set_signal_mask (newmask, myself->getsigmask ());
sigproc_printf ("mask now %p\n", myself->getsigmask ());
set_signal_mask (newmask, _my_tls.sigmask);
}
extern "C" int
@ -1010,9 +1009,9 @@ sighold (int sig)
return -1;
}
mask_sync.acquire (INFINITE);
sigset_t mask = myself->getsigmask ();
sigset_t mask = _my_tls.sigmask;
sigaddset (&mask, sig);
set_signal_mask (mask, myself->getsigmask ());
set_signal_mask (mask, _my_tls.sigmask);
mask_sync.release ();
return 0;
}
@ -1028,9 +1027,9 @@ sigrelse (int sig)
return -1;
}
mask_sync.acquire (INFINITE);
sigset_t mask = myself->getsigmask ();
sigset_t mask = _my_tls.sigmask;
sigdelset (&mask, sig);
set_signal_mask (mask, myself->getsigmask ());
set_signal_mask (mask, _my_tls.sigmask);
mask_sync.release ();
return 0;
}
@ -1050,7 +1049,7 @@ sigset (int sig, _sig_func_ptr func)
}
mask_sync.acquire (INFINITE);
sigset_t mask = myself->getsigmask ();
sigset_t mask = _my_tls.sigmask;
/* If sig was in the signal mask return SIG_HOLD, otherwise return the
previous disposition. */
if (sigismember (&mask, sig))
@ -1068,7 +1067,7 @@ sigset (int sig, _sig_func_ptr func)
signal (sig, func);
sigdelset (&mask, sig);
}
set_signal_mask (mask, myself->getsigmask ());
set_signal_mask (mask, _my_tls.sigmask);
mask_sync.release ();
return prev;
}
@ -1090,11 +1089,11 @@ set_process_mask_delta ()
if (_my_tls.deltamask & SIG_NONMASKABLE)
oldmask = _my_tls.oldmask; /* from handle_sigsuspend */
else
oldmask = myself->getsigmask ();
oldmask = _my_tls.sigmask;
newmask = (oldmask | _my_tls.deltamask) & ~SIG_NONMASKABLE;
sigproc_printf ("oldmask %p, newmask %p, deltamask %p", oldmask, newmask,
_my_tls.deltamask);
myself->setsigmask (newmask);
_my_tls.sigmask = newmask;
mask_sync.release ();
return oldmask;
}
@ -1362,7 +1361,7 @@ _cygtls::call_signal_handler ()
sigact (thissig, &thissi, NULL);
}
incyg = 1;
set_signal_mask (this_oldmask, myself->getsigmask ());
set_signal_mask (this_oldmask, _my_tls.sigmask);
if (this_errno >= 0)
set_errno (this_errno);
}

View File

@ -940,7 +940,7 @@ fhandler_base::lseek (_off64_t offset, int whence)
status = NtQueryInformationFile (get_handle (), &io, &fpi, sizeof fpi,
FilePositionInformation);
if (!NT_SUCCESS (status))
{
{
__seterrno_from_nt_status (status);
return -1;
}
@ -950,7 +950,7 @@ fhandler_base::lseek (_off64_t offset, int whence)
status = NtQueryInformationFile (get_handle (), &io, &fsi, sizeof fsi,
FileStandardInformation);
if (!NT_SUCCESS (status))
{
{
__seterrno_from_nt_status (status);
return -1;
}

View File

@ -233,7 +233,7 @@ fhandler_dev_clipboard::read (void *ptr, size_t& len)
PWCHAR buf;
buf = (PWCHAR) GlobalLock (hglb);
size_t glen = GlobalSize (hglb) / sizeof (WCHAR) - 1;
/* This loop is necessary because the number of bytes returned
by WideCharToMultiByte does not indicate the number of wide
chars used for it, so we could potentially drop wide chars. */

View File

@ -1428,7 +1428,7 @@ beep ()
}
/* This gets called when we found an invalid UTF-8 character. We try with
the default ANSI codepage. If that fails we just print a question mark.
the default ANSI codepage. If that fails we just print a question mark.
Looks ugly but is a neat and alomst sane fallback for many languages. */
void
fhandler_console::write_replacement_char (const unsigned char *char_p)
@ -1456,7 +1456,7 @@ fhandler_console::write_normal (const unsigned char *src,
const unsigned char *nfound;
UINT cp = dev_state->get_console_cp ();
/* First check if we have cached lead bytes of a former try to write
/* First check if we have cached lead bytes of a former try to write
a truncated multibyte sequence. If so, process it. */
if (trunc_buf.len)
{
@ -1465,7 +1465,7 @@ fhandler_console::write_normal (const unsigned char *src,
nfound = next_char (cp, trunc_buf.buf,
trunc_buf.buf + trunc_buf.len + cp_len);
if (!nfound) /* Invalid multibyte sequence. */
{ /* Give up and print replacement chars. */
{ /* Give up and print replacement chars. */
for (int i = 0; i < trunc_buf.len; ++i)
write_replacement_char (trunc_buf.buf + i);
}
@ -1495,7 +1495,7 @@ fhandler_console::write_normal (const unsigned char *src,
if (!nfound) /* Invalid multibyte sequence. */
break;
if (nfound == found) /* Truncated multibyte sequence. */
{ /* Stick to it until the next write. */
{ /* Stick to it until the next write. */
trunc_buf.len = end - found;
memcpy (trunc_buf.buf, found, trunc_buf.len);
return end;

View File

@ -75,7 +75,7 @@ public:
~__DIR_mounts ()
{
for (int i = 0; i < count; ++i)
RtlFreeUnicodeString (&mounts[i]);
RtlFreeUnicodeString (&mounts[i]);
RtlFreeUnicodeString (&cygdrive);
}
__ino64_t check_mount (PUNICODE_STRING fname, __ino64_t ino,
@ -306,7 +306,7 @@ fhandler_base::fstat_by_handle (struct __stat64 *buf)
pfai->BasicInformation.FileAttributes);
}
debug_printf ("%p = NtQueryInformationFile(%S)",
status, pc.get_nt_native_path ());
status, pc.get_nt_native_path ());
return -1;
}
@ -354,7 +354,7 @@ fhandler_base::fstat_by_name (struct __stat64 *buf)
TRUE, &basename, TRUE)))
FileId = pfdi->FileId;
else if (NT_SUCCESS (status = NtQueryDirectoryFile (dir, NULL, NULL, 0, &io,
pfdi, fdi_size,
pfdi, fdi_size,
FileBothDirectoryInformation,
TRUE, &basename, TRUE)))
FileId.QuadPart = 0; /* get_namehash is called in fstat_helper. */
@ -421,7 +421,7 @@ fhandler_base::fstat_fs (struct __stat64 *buf)
if (get_handle ())
{
if (!nohandle () && !is_fs_special ())
res = fstat_by_handle (buf);
res = fstat_by_handle (buf);
if (res)
res = fstat_by_name (buf);
return res;
@ -581,7 +581,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
InitializeObjectAttributes (&attr, &same, 0, get_handle (), NULL);
if (NT_SUCCESS (NtOpenFile (&h, FILE_READ_DATA, &attr, &io,
FILE_SHARE_VALID_FLAGS, 0)))
{
{
LARGE_INTEGER off = { QuadPart:0LL };
char magic[3];
@ -1132,7 +1132,7 @@ fhandler_disk_file::link (const char *newpath)
if (!NT_SUCCESS (status))
{
if (status == STATUS_INVALID_DEVICE_REQUEST)
{
{
/* FS doesn't support hard links. Try to copy file. */
WCHAR pcw[pc.get_nt_native_path ()->Length + 1];
WCHAR newpcw[newpc.get_nt_native_path ()->Length + 1];
@ -1148,7 +1148,7 @@ fhandler_disk_file::link (const char *newpath)
| FILE_ATTRIBUTE_READONLY);
}
else
{
{
__seterrno_from_nt_status (status);
return -1;
}
@ -1523,7 +1523,7 @@ fhandler_disk_file::rmdir ()
(pc.get_object_attr (attr, sec_none_nih), &fbi)))
status = STATUS_DIRECTORY_NOT_EMPTY;
else
status = STATUS_SUCCESS;
status = STATUS_SUCCESS;
}
if (!NT_SUCCESS (status))
{
@ -1691,7 +1691,7 @@ readdir_get_ino (const char *path, bool dot_dot)
fname = (char *) alloca (strlen (path) + 4);
char *c = stpcpy (fname, path);
if (c[-1] != '/')
*c++ = '/';
*c++ = '/';
strcpy (c, "..");
path = fname;
}
@ -1786,7 +1786,7 @@ fhandler_disk_file::readdir_helper (DIR *dir, dirent *de, DWORD w32_err,
}
char tmp[NAME_MAX + 1];
sys_wcstombs (tmp, NAME_MAX, fname->Buffer, fname->Length / sizeof (WCHAR));
sys_wcstombs (tmp, NAME_MAX, fname->Buffer, fname->Length / sizeof (WCHAR));
if (pc.isencoded ())
fnunmunge (de->d_name, tmp);
else

View File

@ -22,6 +22,7 @@ details. */
#include "dtable.h"
#include "cygheap.h"
#include "ntdll.h"
#include "cygtls.h"
#include <sys/param.h>
#include <assert.h>
#include <sys/sysmacros.h>
@ -812,7 +813,7 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
p->gid, p->gid, p->gid, p->gid,
vmsize >> 10, 0, vmrss >> 10, vmdata >> 10, 0,
vmtext >> 10, vmlib >> 10,
0, 0, p->getsigmask ()
0, 0, _my_tls.sigmask
);
}

View File

@ -426,7 +426,7 @@ search_wsa_event_slot (LONG new_serial_number)
if (!wsa_slot_mtx)
{
wsa_slot_mtx = CreateMutex (&sec_all, FALSE,
shared_name (name, "sock", 0));
shared_name (name, "sock", 0));
if (!wsa_slot_mtx)
api_fatal ("Couldn't create/open shared socket mutex, %E");
}
@ -1218,13 +1218,13 @@ fhandler_socket::recv_internal (WSABUF *wsabuf, DWORD wsacnt, DWORD flags,
if (waitall)
{
if (get_socket_type () != SOCK_STREAM)
{
{
WSASetLastError (WSAEOPNOTSUPP);
set_winsock_errno ();
return SOCKET_ERROR;
}
if (is_nonblocking () || (flags & (MSG_OOB | MSG_PEEK)))
waitall = false;
waitall = false;
}
/* Note: Don't call WSARecvFrom(MSG_PEEK) without actually having data
@ -1249,7 +1249,7 @@ fhandler_socket::recv_internal (WSABUF *wsabuf, DWORD wsacnt, DWORD flags,
wret = 0;
}
else
{
{
wret -= wsabuf->len;
++wsabuf;
--wsacnt;

View File

@ -156,7 +156,7 @@ fhandler_termios::bg_check (int sig)
int pgid_gone = !pid_exists (myself->pgid);
int sigs_ignored =
((void *) global_sigs[sig].sa_handler == (void *) SIG_IGN) ||
(myself->getsigmask () & SIGTOMASK (sig));
(_main_tls->sigmask & SIGTOMASK (sig));
if (pgid_gone)
goto setEIO;

View File

@ -25,11 +25,11 @@ extern "C" {
which will be used throughout the library whereever there is a _r
version of a function that takes _REENT. This saves the overhead
of a function call for what amounts to a simple computation.
The definition below is essentially equivalent to the one in cygtls.h
(&_my_tls.local_clib) however it uses a fixed precomputed
offset rather than dereferencing a field of a structure.
Including tlsoffets.h here in order to get this constant offset
tls_local_clib is a bit of a hack, but the alternative would require
dragging the entire definition of struct _cygtls (a large and complex

View File

@ -62,8 +62,6 @@ details. */
/* Every version of cygwin <= this uses an old, incorrect method
to determine signal masks. */
#define CYGWIN_VERSION_DLL_BAD_SIGNAL_MASK 19005
#define CYGWIN_VERSION_USER_API_VERSION_COMBINED \
CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor)
@ -311,7 +309,7 @@ details. */
169: Export confstr.
170: Export insque, remque.
171: Export exp10, exp10f, pow10, pow10f, strcasestr, funopen,
fopencookie.
fopencookie.
172: Export getifaddrs, freeifaddrs.
173: Export __assert_func.
174: Export stpcpy, stpncpy.

View File

@ -25,7 +25,7 @@ int _EXFUN(bcmp,(const void *, const void *, size_t));
void _EXFUN(bcopy,(const void *, void *, size_t));
void _EXFUN(bzero,(void *, size_t));
int _EXFUN(ffs,(int));
char *_EXFUN(index,(const char *, int));
char *_EXFUN(index,(const char *, int));
char *_EXFUN(rindex,(const char *, int));
int _EXFUN(strcasecmp,(const char *, const char *));
int _EXFUN(strncasecmp,(const char *, const char *, size_t));

View File

@ -20,15 +20,15 @@ details. */
#if !defined(__SINGLE_THREAD__)
# if !defined(_flockfile)
# define _flockfile(fp) ({ if (!((fp)->_flags & __SSTR)) \
__cygwin_lock_lock ((_LOCK_T *)&(fp)->_lock); })
__cygwin_lock_lock ((_LOCK_T *)&(fp)->_lock); })
# endif
# if !defined(_ftrylockfile)
# define _ftrylockfile(fp) (((fp)->_flags & __SSTR) ? 0 : \
__cygwin_lock_trylock ((_LOCK_T *)&(fp)->_lock))
__cygwin_lock_trylock ((_LOCK_T *)&(fp)->_lock))
# endif
# if !defined(_funlockfile)
# define _funlockfile(fp) ({ if (!((fp)->_flags & __SSTR)) \
__cygwin_lock_unlock ((_LOCK_T *)&(fp)->_lock); })
__cygwin_lock_unlock ((_LOCK_T *)&(fp)->_lock); })
# endif
#endif

View File

@ -30,9 +30,7 @@ details. */
#include <sys/cygwin.h>
/***********************************************************************
*
write_record: Translates a Windows DNS record into a compressed record
* write_record: Translates a Windows DNS record into a compressed record
***********************************************************************/
#define PUTDOMAIN(d,p)\
@ -63,7 +61,7 @@ static u_char * write_record(unsigned char * ptr, PDNS_RECORD rr, unsigned char
ptr += 2; /* Placeholder for RDLENGTH */
/* The default case uses an undocumented feature of the Windows
resolver for types greater than 16.
resolver for types greater than 16.
The DNS_RECORD Data contains the record in wire format. */
switch(rr->wType) {
@ -181,7 +179,7 @@ static u_char * write_record(unsigned char * ptr, PDNS_RECORD rr, unsigned char
cygwin_query: implements res_nquery by calling DnsQuery
***********************************************************************/
static int cygwin_query(res_state statp, const char * DomName, int Class, int Type,
static int cygwin_query(res_state statp, const char * DomName, int Class, int Type,
unsigned char * AnsPtr, int AnsLength)
{
DNS_STATUS res;
@ -191,7 +189,7 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty
dnptrs[0] = AnsPtr;
dnptrs[1] = NULL;
if (Class != ns_c_in) {
errno = ENOSYS;
statp->res_h_errno = NETDB_INTERNAL;
@ -205,7 +203,7 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty
#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
#define NO_DATA 4 /* Valid name, no data record of requested type */
#define NO_DATA 4 /* Valid name, no data record of requested type */
#endif
DPRINTF(debug, "DnsQuery: %lu (Windows)\n", res);
@ -259,8 +257,8 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty
PUTSHORT(ns_c_in, ptr);
counts[0] = 1;
}
DPRINTF(debug, "%s Section %d Type %u Windows Record Length %u\n",
DPRINTF(debug, "%s Section %d Type %u Windows Record Length %u\n",
rr->pName, rr->Flags.DW & 0x3, rr->wType, rr->wDataLength);
/* Check the records are in correct section order */
@ -270,7 +268,7 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty
}
section = rr->Flags.DW & 0x3;
ptr = write_record(ptr, rr, AnsPtr + AnsLength, dnptrs,
ptr = write_record(ptr, rr, AnsPtr + AnsLength, dnptrs,
&dnptrs[DIM(dnptrs) - 1], debug);
counts[section]++;
@ -293,24 +291,24 @@ done:
/***********************************************************************
*
get_registry_items: returns dns items from the registry
kHey: Handle to registry key
KeyValue: key value to read
what: 0 addresses ; 1 search list
***********************************************************************/
static void get_registry_dns_items(HKEY hKey, LPCTSTR KeyValue,
static void get_registry_dns_items(HKEY hKey, LPCTSTR KeyValue,
res_state statp, int what)
{
DWORD size = 0;
LONG res;
LPBYTE list;
int debug = statp->options & RES_DEBUG;
res = RegQueryValueEx( hKey, KeyValue, NULL, NULL, NULL, &size);
DPRINTF(debug, "value %s, error %lu (Windows), size %lu\n",
DPRINTF(debug, "value %s, error %lu (Windows), size %lu\n",
KeyValue, res, size);
if ((res == ERROR_SUCCESS) && (size > 1)) {
if ((res == ERROR_SUCCESS) && (size > 1)) {
if (!(list = (LPBYTE) alloca(size))) {
DPRINTF(debug, "alloca: %s\n", strerror(errno));
}
@ -322,7 +320,7 @@ static void get_registry_dns_items(HKEY hKey, LPCTSTR KeyValue,
BYTE *ap, *srch;
int numAddresses = 0;
for (ap = list; ap < list + size && *ap; ap = srch) {
/* The separation character can be 0, ' ', or ','. */
/* The separation character can be 0, ' ', or ','. */
for (srch = ap; *srch && (isdigit(*srch) || *srch == '.' ); srch++);
*srch++ = 0;
if (numAddresses < DIM(statp->nsaddr_list)) {
@ -331,35 +329,35 @@ static void get_registry_dns_items(HKEY hKey, LPCTSTR KeyValue,
if ( statp->nsaddr_list[numAddresses].sin_addr.s_addr != 0 )
numAddresses++;
}
else
else
DPRINTF(debug, "no space for server \"%s\"\n", ap);
}
statp->nscount = numAddresses;
}
else /* Parse the search line */
minires_get_search(list, statp);
minires_get_search(list, statp);
}
return;
}
/***********************************************************************
*
get_registry_dns:
get_registry_dns:
Read the registry to get dns server addresses in Network Byte Order,
and set statp->nscount (for NT <= 4.0)
Read the registry SearchList
***********************************************************************/
static void get_registry_dns(res_state statp)
{
HKEY hKey;
HKEY hKey;
DWORD res;
const char *keyName = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters";
DPRINTF(statp->options & RES_DEBUG, "key %s\n", keyName);
if ((res = RegOpenKeyEx( HKEY_LOCAL_MACHINE, keyName, 0,
if ((res = RegOpenKeyEx( HKEY_LOCAL_MACHINE, keyName, 0,
KEY_QUERY_VALUE | KEY_READ, &hKey)) != ERROR_SUCCESS) {
DPRINTF(statp->options & RES_DEBUG, "RegOpenKeyEx: error %lu (Windows)\n", res);
return;
@ -367,7 +365,7 @@ static void get_registry_dns(res_state statp)
if (statp->nscount == 0)
get_registry_dns_items(hKey, "NameServer", statp, 0);
if (statp->nscount == 0)
if (statp->nscount == 0)
get_registry_dns_items(hKey, "DhcpNameServer", statp, 0);
if (statp->dnsrch[0] == NULL)
get_registry_dns_items(hKey, "SearchList", statp, 1);
@ -380,9 +378,9 @@ static void get_registry_dns(res_state statp)
/***********************************************************************
*
get_dns_info: Get the search list or the domain name
and the dns server addresses in Network Byte Order
and the dns server addresses in Network Byte Order
Set statp->os_query if DnsQuery is available.
***********************************************************************/
void get_dns_info(res_state statp)
{
@ -443,7 +441,7 @@ void get_dns_info(res_state statp)
statp->nscount++;
}
}
else
else
DPRINTF(debug, "no space for server \"%s\"\n", pIPAddr->IpAddress.String);
}

View File

@ -24,7 +24,7 @@ dprintf
void minires_dprintf(const char * format, ...)
{
va_list args;
va_start(args, format);
fprintf(stderr, "Minires: ");
vfprintf(stderr, format, args);
@ -36,7 +36,7 @@ void minires_dprintf(const char * format, ...)
scanline
Put pointers in list[] to the beginning of each space or comma delimited
word in "in", and put the lengths in sizes[] (counting the final 0).
Return the number of words found
Return the number of words found
***********************************************************************/
static int scanline(char * in, char **list, int * sizes, int maxnum)
{
@ -44,12 +44,12 @@ static int scanline(char * in, char **list, int * sizes, int maxnum)
char * startp;
for (i = 0; i < maxnum; i++) {
while((*in) && (isspace(*in) || *in == ',')) in++;
if (*in == 0)
if (*in == 0)
break;
startp = in++;
while((*in) && !isspace(*in) && *in != ',') in++;
list[i] = startp;
sizes[i] = in - startp + 1;
sizes[i] = in - startp + 1;
if (*in)
*in++ = 0;
}
@ -70,7 +70,7 @@ void minires_get_search(char * string, res_state statp)
i = scanline(string, words, sizes, MAXDNSRCH+1);
ptr = statp->defdname;
for (j = 0; j < i; j++) {
if (j < MAXDNSRCH
if (j < MAXDNSRCH
&& ptr + sizes[j] < &statp->defdname[DIM(statp->defdname)]) {
statp->dnsrch[j] = strcpy(ptr, words[j]);
statp->dnsrch[j+1] = NULL;
@ -108,7 +108,7 @@ static void get_options(res_state statp, int i, char **words)
if ((ptr = strchr(words[i], ':'))) {
*ptr++ = 0;
value = atoi(ptr);
/* Not supported
/* Not supported
if (!strcasecmp("ndots", words[i])) {
statp->ndots = value;
continue;
@ -141,7 +141,7 @@ We only look for nameserver, domain, search and options
***********************************************************************/
#if MAXNS > MAXDNSRCH + 1
#define MAXSIZE MAXNS
#else
#else
#define MAXSIZE MAXDNSRCH + 1 /* Make unused one visible */
#endif
static void get_resolv(res_state statp)
@ -163,7 +163,7 @@ static void get_resolv(res_state statp)
while ( fgets(line, sizeof(line), fd) != 0) {
DPRINTF(debug, "resolv.conf %s", line);
if ((i = scanline(line, words, sizes, DIM(words))) > 0) {
if (!have_address
if (!have_address
&& !strncasecmp("nameserver", words[0], sizes[0])) {
for ( j = 1; j < i ; j++) {
unsigned int address;
@ -181,7 +181,7 @@ static void get_resolv(res_state statp)
}
}
}
else if (!have_search
else if (!have_search
&& (!strncasecmp("search", words[0], sizes[0])
|| !strncasecmp("domain", words[0], sizes[0]))) {
ptr = statp->defdname;
@ -208,7 +208,7 @@ static void get_resolv(res_state statp)
}
/****************************************************************************/
/*
/*
open_sock()
Create a datagram socket and call bind.
@ -217,7 +217,7 @@ static void get_resolv(res_state statp)
static int open_sock(struct sockaddr_in *CliAddr, int debug)
{
int fd;
DPRINTF(debug, "opening UDP socket\n");
/* Create a datagram socket */
@ -257,7 +257,7 @@ struct __res_state *__res_state(void)
int res_ninit(res_state statp)
{
int i;
statp->res_h_errno = NETDB_SUCCESS;
statp->nscount = 0;
statp->os_query = NULL;
@ -273,11 +273,11 @@ int res_ninit(res_state statp)
get_resolv(statp);
/* Get dns servers and search list from an os-specific routine, set os_query */
get_dns_info(statp);
if (statp->nscount == 0 && !statp->os_query) {
errno = ENONET;
statp->res_h_errno = NETDB_INTERNAL;
DPRINTF(statp->options & RES_DEBUG, "no dns server found\n");
DPRINTF(statp->options & RES_DEBUG, "no dns server found\n");
return -1;
}
for (i = 0; i < statp->nscount; i++) {
@ -308,7 +308,7 @@ void res_nclose(res_state statp)
int res;
if (statp->sockfd != -1) {
res = close(statp->sockfd);
DPRINTF(statp->options & RES_DEBUG, "close sockfd %d: %s\n",
DPRINTF(statp->options & RES_DEBUG, "close sockfd %d: %s\n",
statp->sockfd, (res == 0)?"OK":strerror(errno));
statp->sockfd = -1;
}
@ -317,7 +317,7 @@ void res_nclose(res_state statp)
void res_close()
{
res_nclose(& res);
}
}
/*****************************************************************
*
@ -344,7 +344,7 @@ static int get_tcp_buf(int fd, unsigned char *buf, int size, int debug)
get_tcp()
*****************************************************************/
static int get_tcp(struct sockaddr_in *CliAddr,
static int get_tcp(struct sockaddr_in *CliAddr,
const unsigned char * MsgPtr, int MsgLength,
unsigned char * AnsPtr, int AnsLength, int debug)
{
@ -379,7 +379,7 @@ static int get_tcp(struct sockaddr_in *CliAddr,
ans_length = ntohs(len_buf.len);
/* Read the answer */
if (get_tcp_buf(fd, AnsPtr, MIN(ans_length, AnsLength), debug))
if (get_tcp_buf(fd, AnsPtr, MIN(ans_length, AnsLength), debug))
goto done;
res = ans_length;
@ -393,9 +393,9 @@ static int get_tcp(struct sockaddr_in *CliAddr,
res_send
Assumes that the message is a query starting with a short id.
Handles retransmissions until that id is received.
*****************************************************************/
int res_nsend( res_state statp, const unsigned char * MsgPtr,
int res_nsend( res_state statp, const unsigned char * MsgPtr,
int MsgLength, unsigned char * AnsPtr, int AnsLength)
{
/* Current server, shared by all tasks */
@ -403,13 +403,13 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr,
int tcp;
const int debug = statp->options & RES_DEBUG;
fd_set fdset_read;
fd_set fdset_read;
int rslt, addrLen, transNum, wServ;
struct sockaddr_in mySockAddr, dnsSockAddr;
struct timeval timeOut;
statp->res_h_errno = NETDB_SUCCESS;
if (((statp->options & RES_INIT) == 0) && (res_ninit(statp) != 0))
if (((statp->options & RES_INIT) == 0) && (res_ninit(statp) != 0))
return -1;
/* Close the socket if it had been opened before a fork.
@ -428,7 +428,7 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr,
}
/* Set close on exec flag */
if (fcntl(statp->sockfd, F_SETFD, 1) == -1) {
DPRINTF(debug, "fcntl: %s\n",
DPRINTF(debug, "fcntl: %s\n",
strerror(errno));
statp->res_h_errno = NETDB_INTERNAL;
return -1;
@ -438,17 +438,17 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr,
SServ = statp->mypid % statp->nscount;
}
transNum = 0;
transNum = 0;
while ( transNum++ < statp->retry) {
if ((wServ = SServ + 1) >= statp->nscount)
if ((wServ = SServ + 1) >= statp->nscount)
wServ = 0;
SServ = wServ;
/* Send the message */
rslt = cygwin_sendto(statp->sockfd, MsgPtr, MsgLength, 0,
rslt = cygwin_sendto(statp->sockfd, MsgPtr, MsgLength, 0,
(struct sockaddr *) &statp->nsaddr_list[wServ],
sizeof(struct sockaddr_in));
DPRINTF(debug, "sendto: server %08x sockfd %d %s\n",
statp->nsaddr_list[wServ].sin_addr.s_addr,
statp->nsaddr_list[wServ].sin_addr.s_addr,
statp->sockfd, (rslt == MsgLength)?"OK":strerror(errno));
if (rslt != MsgLength) {
statp->res_h_errno = NETDB_INTERNAL;
@ -474,15 +474,15 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr,
}
addrLen = sizeof(dnsSockAddr);
rslt = cygwin_recvfrom(statp->sockfd, AnsPtr, AnsLength, 0,
rslt = cygwin_recvfrom(statp->sockfd, AnsPtr, AnsLength, 0,
(struct sockaddr *) & dnsSockAddr, & addrLen);
if (rslt <= 0) {
DPRINTF(debug, "recvfrom: %s\n", strerror(errno));
statp->res_h_errno = NETDB_INTERNAL;
return -1;
}
/*
Prepare to retry with tcp
/*
Prepare to retry with tcp
*/
for (tcp = 0; tcp < 2; tcp++) {
/* Check if this is the message we expected */
@ -497,14 +497,14 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr,
&& ((AnsPtr[2] & QR) != 0)) {
DPRINTF(debug, "answer %u from %08x. Error %d. Count %d.\n",
rslt, dnsSockAddr.sin_addr.s_addr,
rslt, dnsSockAddr.sin_addr.s_addr,
AnsPtr[3] & ERR_MASK, AnsPtr[6]*256 + AnsPtr[7]);
#if 0
NETDB_INTERNAL -1 /* see errno */
NETDB_SUCCESS 0 /* no problem */
HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
Also seen returned by some servers when the name is too long
Also seen returned by some servers when the name is too long
NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
NO_DATA 4 /* Valid name, no data record of requested type */
#endif
@ -512,27 +512,27 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr,
if ((AnsPtr[2] & TC) && !(statp->options & RES_IGNTC)) { /* Truncated. Try TCP */
rslt = get_tcp(&statp->nsaddr_list[wServ], MsgPtr, MsgLength,
AnsPtr, AnsLength, statp->options & RES_DEBUG);
continue;
continue;
}
else if ((AnsPtr[6] | AnsPtr[7])!= 0)
else if ((AnsPtr[6] | AnsPtr[7])!= 0)
return rslt;
else
else
statp->res_h_errno = NO_DATA;
}
else {
/* return HOST_NOT_FOUND even for non-authoritative answers */
if ((AnsPtr[3] & ERR_MASK) == NXDOMAIN)
if ((AnsPtr[3] & ERR_MASK) == NXDOMAIN)
statp->res_h_errno = HOST_NOT_FOUND;
else if ((AnsPtr[3] & ERR_MASK) == SERVFAIL)
else if ((AnsPtr[3] & ERR_MASK) == SERVFAIL)
statp->res_h_errno = TRY_AGAIN;
else
else
statp->res_h_errno = NO_RECOVERY;
}
return -1;
}
else {
DPRINTF(debug, "unexpected answer %u from %x to query to %x\n",
rslt, dnsSockAddr.sin_addr.s_addr,
rslt, dnsSockAddr.sin_addr.s_addr,
statp->nsaddr_list[wServ].sin_addr.s_addr);
break;
}
@ -543,7 +543,7 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr,
return -1;
}
int res_send( const unsigned char * MsgPtr, int MsgLength,
int res_send( const unsigned char * MsgPtr, int MsgLength,
unsigned char * AnsPtr, int AnsLength)
{
int r = res_nsend(& res, MsgPtr, MsgLength, AnsPtr, AnsLength);
@ -556,10 +556,10 @@ int res_send( const unsigned char * MsgPtr, int MsgLength,
res_mkquery
Return: packet size
-1 name format is incorrect
-1 name format is incorrect
*****************************************************************/
int res_nmkquery (res_state statp,
int op, const char * dnameptr, int qclass, int qtype,
int op, const char * dnameptr, int qclass, int qtype,
const unsigned char * dataptr, int datalen,
const unsigned char * newrr, unsigned char * buf, int buflen)
{
@ -570,7 +570,7 @@ int res_nmkquery (res_state statp,
/* Write the name and verify buffer length */
len = dn_comp(dnameptr, buf + HFIXEDSZ, buflen - HFIXEDSZ - QFIXEDSZ, NULL, NULL);
if (len < 0) {
DPRINTF(statp->options & RES_DEBUG,
DPRINTF(statp->options & RES_DEBUG,
"\"%s\" invalid or buffer too short\n", dnameptr);
statp->res_h_errno = NETDB_INTERNAL;
return -1;
@ -578,7 +578,7 @@ int res_nmkquery (res_state statp,
/* Fill the header */
id = statp->id;
PUTSHORT(id, buf);
PUTSHORT(RD, buf);
PUTSHORT(RD, buf);
PUTSHORT(1, buf); /* Number of questions */
for (i = 0; i < 3; i++)
PUTSHORT(0, buf); /* Number of answers */
@ -596,11 +596,11 @@ int res_nmkquery (res_state statp,
}
}
int res_mkquery (int op, const char * dnameptr, int qclass, int qtype,
int res_mkquery (int op, const char * dnameptr, int qclass, int qtype,
const unsigned char * dataptr, int datalen,
const unsigned char * newrr, unsigned char * buf, int buflen)
{
int r = res_nmkquery (& res, op, dnameptr, qclass, qtype,
int r = res_nmkquery (& res, op, dnameptr, qclass, qtype,
dataptr, datalen, newrr, buf, buflen);
h_errno = res.res_h_errno;
return r;
@ -608,17 +608,15 @@ int res_mkquery (int op, const char * dnameptr, int qclass, int qtype,
}
/*****************************************************************
*
res_query()
* res_query()
*****************************************************************/
int res_nquery( res_state statp, const char * DomName, int Class, int Type,
int res_nquery( res_state statp, const char * DomName, int Class, int Type,
unsigned char * AnsPtr, int AnsLength)
{
u_char packet[PACKETSZ];
int len;
DPRINTF(statp->options & RES_DEBUG, "query \"%s\" type %d\n", DomName, Type);
statp->res_h_errno = NETDB_SUCCESS;
@ -626,7 +624,7 @@ int res_nquery( res_state statp, const char * DomName, int Class, int Type,
if (statp->os_query)
return ((os_query_t *) statp->os_query)(statp, DomName, Class, Type, AnsPtr, AnsLength);
if ((len = res_nmkquery (statp, QUERY, DomName, Class, Type,
if ((len = res_nmkquery (statp, QUERY, DomName, Class, Type,
0, 0, 0, packet, PACKETSZ)) < 0)
return -1;
return res_nsend( statp, packet, len, AnsPtr, AnsLength);
@ -640,9 +638,7 @@ int res_query( const char * DomName, int Class, int Type, unsigned char * AnsPtr
}
/*****************************************************************
*
res_querydomain()
* res_querydomain()
*****************************************************************/
int res_nquerydomain( res_state statp, const char * Name, const char * DomName,
int Class, int Type, unsigned char * AnsPtr, int AnsLength)
@ -657,7 +653,7 @@ int res_nquerydomain( res_state statp, const char * Name, const char * DomName,
else {
strcpy(fqdn, Name);
ptr = &fqdn[nlen];
if (nlen && *(ptr - 1) != '.')
if (nlen && *(ptr - 1) != '.')
*(ptr++ - 1) = '.';
fqdn[sizeof(fqdn) - 1] = 0;
strncpy(ptr, DomName, sizeof(fqdn) - (ptr - fqdn));
@ -689,7 +685,7 @@ int res_querydomain( const char * Name, const char * DomName, int Class,
*****************************************************************/
int res_nsearch( res_state statp, const char * DomName, int Class, int Type,
int res_nsearch( res_state statp, const char * DomName, int Class, int Type,
unsigned char * AnsPtr, int AnsLength)
{
int len, stat, i;
@ -697,31 +693,31 @@ int res_nsearch( res_state statp, const char * DomName, int Class, int Type,
DPRINTF(statp->options & RES_DEBUG, "search \"%s\" type %d\n", DomName, Type);
if (((statp->options & RES_INIT) == 0) && (res_ninit(statp) != 0))
if (((statp->options & RES_INIT) == 0) && (res_ninit(statp) != 0))
return -1;
stat = res_nquery( statp, DomName, Class, Type, AnsPtr, AnsLength);
/* Check if will skip search */
if (statp->res_h_errno != HOST_NOT_FOUND /* Success or hard failure */
|| ((ptr = strrchr(DomName, '.')) && (!*(ptr+1))) /* Final dot */
|| ((ptr = strrchr(DomName, '.')) && (!*(ptr+1))) /* Final dot */
|| (((statp->options & RES_DNSRCH) == 0) /* Or no search */
&& ((ptr != NULL) /* And some dot */
|| ((statp->options & RES_DEFNAMES) == 0)))/* or no def domain */
|| (!(sptr = statp->dnsrch[0])))
|| (!(sptr = statp->dnsrch[0])))
return stat;
len = strlen(DomName);
if (len >= MAXDNAME - 1) /* Space for next dot */
goto error;
strcpy(fullDomName, DomName);
strcpy(fullDomName, DomName);
fullDomName[len++] = '.';
fullDomName[MAXDNAME - 1] = 0; /* Overflow indicator */
i = 0;
do {
strncpy(fullDomName + len, sptr, MAXDNAME - len);
if (fullDomName[MAXDNAME - 1])
goto error;
goto error;
stat = res_nquery(statp, fullDomName, Class, Type, AnsPtr, AnsLength);
} while ((sptr = statp->dnsrch[++i]) != NULL
&& statp->res_h_errno == HOST_NOT_FOUND
@ -737,7 +733,7 @@ int res_nsearch( res_state statp, const char * DomName, int Class, int Type,
return -1;
}
int res_search( const char * DomName, int Class, int Type,
int res_search( const char * DomName, int Class, int Type,
unsigned char * AnsPtr, int AnsLength)
{
int r = res_nsearch(& res, DomName, Class, Type, AnsPtr, AnsLength);
@ -746,13 +742,11 @@ int res_search( const char * DomName, int Class, int Type,
}
/*****************************************************************
*
dn_expand
* dn_expand
*****************************************************************/
int dn_expand(const unsigned char *msg, const unsigned char *eomorig,
const unsigned char *comp_dn, char *exp_dn, int length)
const unsigned char *comp_dn, char *exp_dn, int length)
{
unsigned int len, complen = 0;
const unsigned char *comp_dn_orig = comp_dn;
@ -767,31 +761,31 @@ int dn_expand(const unsigned char *msg, const unsigned char *eomorig,
if (len <= MAXLABEL) {
if ((length -= (len + 1)) > 0 /* Need space for final . */
&& comp_dn + len <= eomorig) {
do { *exp_dn++ = *comp_dn++; } while (--len != 0);
*exp_dn++ = '.';
do { *exp_dn++ = *comp_dn++; } while (--len != 0);
*exp_dn++ = '.';
}
else
else
goto expand_fail;
}
else if (len >= (128+64)) {
if (!complen) /* Still in the original field? */
complen = (comp_dn - comp_dn_orig) + 1;
complen = (comp_dn - comp_dn_orig) + 1;
comp_dn = msg + (((len & ~(128+64)) << 8) + *comp_dn);
if (comp_dn >= eomorig)
if (comp_dn >= eomorig)
goto expand_fail;
}
else
else
goto expand_fail;
} while ((len = *comp_dn++) != 0);
/* Replace last . with a 0 */
*(--exp_dn) = 0;
if (!complen)
if (!complen)
complen = comp_dn - comp_dn_orig;
/* fprintf(stderr, "dn_expand %s\n", exp_start); */
return complen;
expand_fail:
/* fprintf(stderr, "dn_expand fails\n"); */
/* fprintf(stderr, "dn_expand fails\n"); */
return -1;
}
@ -806,13 +800,13 @@ expand_fail:
preserve the letter cases.
*****************************************************************/
int dn_comp(const char * exp_dn, u_char * comp_dn, int length,
int dn_comp(const char * exp_dn, u_char * comp_dn, int length,
u_char ** dnptrs, u_char ** lastdnptr)
{
u_char *cptr = comp_dn, *dptr, *lptr, *rptr;
unsigned int i, len;
u_char * const eptr = comp_dn + length - 1; /* Last valid */
errno = EINVAL;
if (*exp_dn == '.' && !*(exp_dn + 1))
@ -837,7 +831,7 @@ int dn_comp(const char * exp_dn, u_char * comp_dn, int length,
if (*dptr++ != *rptr++)
goto next_dn;
} while (--len);
len = *dptr++;
len = *dptr++;
if (len == 0) { /* last label */
if (!*rptr || (*rptr == '.' && !*(rptr + 1))) { /* Full match */
len = (dnptrs[i] - dnptrs[0]) | 0xC000;
@ -903,7 +897,7 @@ int dn_skipname(const unsigned char *comp_dn, const unsigned char *eom)
}
if (len > MAXLABEL ||
(comp_dn += len) > eom)
return -1;
return -1;
} while (len != 0);
return comp_dn - comp_dn_orig;

View File

@ -27,7 +27,7 @@ details. */
#include <stdio.h>
#include <stdarg.h>
#include <sys/unistd.h>
#include <netdb.h>
#include <netdb.h>
#include <arpa/nameser.h>
#include <resolv.h>

View File

@ -23,7 +23,7 @@ insque (void *velement, void *vpred)
if (pred)
{
if ((succ = element->q_forw = pred->q_forw))
succ->q_back = element;
succ->q_back = element;
pred->q_forw = element;
}
else

View File

@ -217,14 +217,14 @@ is_cp_multibyte (UINT cp)
/* OMYGOD! CharNextExA is not UTF-8 aware! It only works fine with
double byte charsets. So we have to do it ourselves for UTF-8.
While being at it, we do more. If a double-byte or multibyte
sequence is truncated due to an early end, we need a way to recognize
it. The reason is that multiple buffered write statements might
accidentally stop and start in the middle of a single character byte
sequence. If we have to interpret the byte sequences (as in
fhandler_console), we would print wrong output in these cases.
So we have four possible return values here:
ret = end if str >= end
@ -249,7 +249,7 @@ next_char (UINT cp, const unsigned char *str, const unsigned char *end)
case 950:
case 1361:
if (*str <= 0x7f)
ret = str + 1;
ret = str + 1;
else if (str == end - 1 && IsDBCSLeadByteEx (cp, *str))
ret = str;
else

View File

@ -1088,7 +1088,7 @@ munmap (void *addr, size_t len)
DWORD u_len;
LIST_FOREACH_SAFE (rec, &map_list->recs, mr_next, next_rec)
{
{
if (!rec->match ((caddr_t) addr, len, u_addr, u_len))
continue;
if (rec->unmap_pages (u_addr, u_len))
@ -1207,7 +1207,7 @@ mprotect (void *addr, size_t len, int prot)
DWORD u_len;
LIST_FOREACH (rec, &map_list->recs, mr_next)
{
{
if (!rec->match ((caddr_t) addr, len, u_addr, u_len))
continue;
in_mapped = true;
@ -1649,7 +1649,7 @@ fhandler_dev_mem::mmap (caddr_t *addr, size_t len, int prot,
}
void *base = MapView (h, *addr, len, get_access (), prot,
flags | MAP_ANONYMOUS, off);
flags | MAP_ANONYMOUS, off);
if (!base || (fixed (flags) && base != *addr))
{
if (!base)

View File

@ -790,7 +790,7 @@ extern "C"
PIO_STATUS_BLOCK, ULONG, ULONG, ULONG,
PLARGE_INTEGER);
NTSTATUS NTAPI NtCreateSection (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
PLARGE_INTEGER, ULONG, ULONG, HANDLE);
PLARGE_INTEGER, ULONG, ULONG, HANDLE);
NTSTATUS NTAPI NtCreateToken (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
TOKEN_TYPE, PLUID, PLARGE_INTEGER, PTOKEN_USER,
PTOKEN_GROUPS, PTOKEN_PRIVILEGES, PTOKEN_OWNER,
@ -804,11 +804,11 @@ extern "C"
PLARGE_INTEGER, PULONG, SECTION_INHERIT,
ULONG, ULONG);
NTSTATUS NTAPI NtNotifyChangeDirectoryFile (HANDLE, HANDLE, PIO_APC_ROUTINE,
PVOID, PIO_STATUS_BLOCK,
PVOID, PIO_STATUS_BLOCK,
PFILE_NOTIFY_INFORMATION, ULONG,
ULONG, BOOLEAN);
NTSTATUS NTAPI NtOpenDirectoryObject (PHANDLE, ACCESS_MASK,
POBJECT_ATTRIBUTES);
POBJECT_ATTRIBUTES);
NTSTATUS NTAPI NtOpenFile (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
PIO_STATUS_BLOCK, ULONG, ULONG);
NTSTATUS NTAPI NtOpenSection (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES);
@ -821,7 +821,7 @@ extern "C"
FILE_INFORMATION_CLASS, BOOLEAN,
PUNICODE_STRING, BOOLEAN);
NTSTATUS NTAPI NtQueryDirectoryObject (HANDLE, PVOID, ULONG, BOOLEAN,
BOOLEAN, PULONG, PULONG);
BOOLEAN, PULONG, PULONG);
NTSTATUS NTAPI NtQueryEaFile (HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG,
BOOLEAN, PVOID, ULONG, PULONG, BOOLEAN);
NTSTATUS NTAPI NtQueryFullAttributesFile (POBJECT_ATTRIBUTES,
@ -835,7 +835,7 @@ extern "C"
NTSTATUS NTAPI NtQuerySystemInformation (SYSTEM_INFORMATION_CLASS,
PVOID, ULONG, PULONG);
NTSTATUS NTAPI NtQuerySecurityObject (HANDLE, SECURITY_INFORMATION,
PSECURITY_DESCRIPTOR, ULONG, PULONG);
PSECURITY_DESCRIPTOR, ULONG, PULONG);
NTSTATUS NTAPI NtQueryVirtualMemory (HANDLE, PVOID, MEMORY_INFORMATION_CLASS,
PVOID, ULONG, PULONG);
NTSTATUS NTAPI NtQueryVolumeInformationFile (HANDLE, IO_STATUS_BLOCK *,
@ -912,7 +912,7 @@ extern "C"
If you know it's 0-terminated, just use RtlInitUnicodeString(). */
inline
VOID NTAPI RtlInitCountedUnicodeString (PUNICODE_STRING dest, PCWSTR buf,
USHORT len)
USHORT len)
{
dest->Length = dest->MaximumLength = len;
dest->Buffer = (PWSTR) buf;
@ -920,7 +920,7 @@ extern "C"
/* Split path into dirname and basename part. This function does not
copy anything! It just initializes the dirname and basename
UNICODE_STRINGs so that their Buffer members point to the right spot
into path's Buffer, and the Length (and MaximumLength) members are set
into path's Buffer, and the Length (and MaximumLength) members are set
to match the dirname part and the basename part.
Note that dirname's Length is set so that it also includes the trailing
backslash. If you don't need it, just subtract sizeof(WCHAR) from

View File

@ -57,10 +57,10 @@ read_ea (HANDLE hdl, path_conv &pc, const char *name, char *value, size_t size)
pc.get_object_attr (attr, sec_none_nih);
debug_printf ("read_ea (%S, %s, %p, %lu)",
attr.ObjectName, name, value, size);
attr.ObjectName, name, value, size);
fea = (PFILE_FULL_EA_INFORMATION) alloca (EA_BUFSIZ);
if (name)
{
size_t nlen;
@ -78,7 +78,7 @@ read_ea (HANDLE hdl, path_conv &pc, const char *name, char *value, size_t size)
}
if ((nlen = strlen (name)) >= MAX_EA_NAME_LEN)
{
{
set_errno (EINVAL);
return -1;
}
@ -112,7 +112,7 @@ read_ea (HANDLE hdl, path_conv &pc, const char *name, char *value, size_t size)
else if (status == STATUS_NONEXISTENT_EA_ENTRY)
/* Actually this error code is either never generated, or it was only
generated in some old and long forgotton NT version. See below. */
set_errno (ENOATTR);
set_errno (ENOATTR);
else
__seterrno_from_nt_status (status);
goto out;
@ -146,7 +146,7 @@ read_ea (HANDLE hdl, path_conv &pc, const char *name, char *value, size_t size)
{
ret = 0;
do
{
{
if (pc.fs_is_samba ()) /* See below. */
fea->EaNameLength += 5;
if (size > 0)
@ -186,7 +186,7 @@ out:
if (!hdl)
CloseHandle (h);
debug_printf ("%d = read_ea (%S, %s, %p, %lu)",
ret, attr.ObjectName, name, value, size);
ret, attr.ObjectName, name, value, size);
return ret;
}
@ -210,7 +210,7 @@ write_ea (HANDLE hdl, path_conv &pc, const char *name, const char *value,
pc.get_object_attr (attr, sec_none_nih);
debug_printf ("write_ea (%S, %s, %p, %lu, %d)",
attr.ObjectName, name, value, size, flags);
attr.ObjectName, name, value, size, flags);
/* Samba hides the user namespace from Windows clients. If we get a
user namespace item, we remove the leading namespace from the name.
@ -238,7 +238,7 @@ write_ea (HANDLE hdl, path_conv &pc, const char *name, const char *value,
}
ssize_t rret = read_ea (hdl, pc, name, NULL, 0);
if (flags == XATTR_CREATE && rret > 0)
{
{
set_errno (EEXIST);
goto out;
}
@ -297,7 +297,7 @@ out:
if (!hdl)
CloseHandle (h);
debug_printf ("%d = write_ea (%S, %s, %p, %lu, %d)",
ret, attr.ObjectName, name, value, size, flags);
ret, attr.ObjectName, name, value, size, flags);
return ret;
}
@ -316,7 +316,7 @@ getxattr_worker (path_conv &pc, const char *name, void *value, size_t size)
fhandler_base *fh;
if (!(fh = build_fh_pc (pc)))
return -1;
return -1;
res = fh->fgetxattr (name, value, size);
delete fh;
@ -411,7 +411,7 @@ setxattr_worker (path_conv &pc, const char *name, const void *value,
fhandler_base *fh;
if (!(fh = build_fh_pc (pc)))
return -1;
return -1;
res = fh->fsetxattr (name, value, size, flags);
delete fh;

View File

@ -419,7 +419,7 @@ fs_info::update (PUNICODE_STRING upath, bool exists)
RtlSplitUnicodePath (attr.ObjectName, &dir, NULL);
attr.ObjectName = &dir;
if (status == STATUS_NO_MEDIA_IN_DEVICE)
{
{
no_media = true;
dir.Length = 6 * sizeof (WCHAR);
}
@ -437,7 +437,7 @@ fs_info::update (PUNICODE_STRING upath, bool exists)
return false;
}
status = NtQueryVolumeInformationFile (vol, &io, &ffdi, sizeof ffdi,
FileFsDeviceInformation);
FileFsDeviceInformation);
if (!NT_SUCCESS (status))
ffdi.DeviceType = ffdi.Characteristics = 0;
@ -1996,7 +1996,7 @@ mount_info::conv_to_posix_path (PWCHAR src_path, char *posix_path,
{
src_path += 4;
if (!wcsncmp (src_path, L"UNC\\", 4))
{
{
src_path += 2;
src_path[0] = L'\\';
changed = true;
@ -2990,7 +2990,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
}
syscall_printf ("symlink (%s, %S)", oldpath,
win32_newpath.get_nt_native_path ());
win32_newpath.get_nt_native_path ());
if ((!isdevice && win32_newpath.exists ())
|| win32_newpath.is_auto_device ())
@ -3007,11 +3007,11 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
char desc[MAX_PATH + 1], *relpath;
if (!isdevice)
{
{
/* First create an IDLIST to learn how big our shortcut is
going to be. */
IShellFolder *psl;
/* The symlink target is relative to the directory in which
the symlink gets created, not relative to the cwd. Therefore
we have to mangle the path quite a bit before calling path_conv. */
@ -3131,7 +3131,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
/* Note that the terminating nul is written. */
cp = stpcpy (stpcpy (buf, SYMLINK_COOKIE), oldpath) + 1;
}
if (isdevice && win32_newpath.exists ())
{
status = NtOpenFile (&fh, FILE_WRITE_ATTRIBUTES,
@ -3181,7 +3181,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
status = NtSetInformationFile (fh, &io, &fbi, sizeof fbi,
FileBasicInformation);
if (!NT_SUCCESS (status))
debug_printf ("Setting attributes failed, status = %p", status);
debug_printf ("Setting attributes failed, status = %p", status);
res = 0;
}
else
@ -3191,7 +3191,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
status = NtSetInformationFile (fh, &io, &fdi, sizeof fdi,
FileDispositionInformation);
if (!NT_SUCCESS (status))
debug_printf ("Setting delete dispostion failed, status = %p", status);
debug_printf ("Setting delete dispostion failed, status = %p", status);
}
NtClose (fh);
@ -3313,10 +3313,7 @@ symlink_info::check_sysfile (HANDLE h)
set_error (EIO);
}
else if (io.Information > SYMLINK_MAX + 1)
{
debug_printf ("symlink string too long");
}
debug_printf ("symlink string too long");
else
res = posixify (srcbuf);
}
@ -3650,7 +3647,7 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt)
get_nt_native_path (suffix.path, upath);
status = NtQueryAttributesFile (&attr, &fbi);
if (NT_SUCCESS (status))
fileattr = fbi.FileAttributes;
fileattr = fbi.FileAttributes;
else
{
debug_printf ("%p = NtQueryAttributesFile (%S)", status, &upath);
@ -3693,12 +3690,12 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt)
| FILE_OPEN_FOR_BACKUP_INTENT
| FILE_DIRECTORY_FILE);
if (!NT_SUCCESS (status))
{
{
debug_printf ("%p = NtOpenFile(%S)", status, &dirname);
fileattr = 0;
}
else
{
{
status = NtQueryDirectoryFile (dir, NULL, NULL, 0, &io,
&fdi, sizeof fdi,
FileDirectoryInformation,
@ -3726,7 +3723,7 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt)
goto file_not_symlink;
}
if (set_error (geterrno_from_win_error
(RtlNtStatusToDosError (status), EACCES)))
(RtlNtStatusToDosError (status), EACCES)))
continue;
}
@ -4487,7 +4484,7 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit)
For now, we just don't store the path in the PEB and proceed as
usual. */
&& len <= MAX_PATH - (nat_cwd->Buffer[len - 1] == L'\\' ? 1 : 2))
{
{
/* Convert to a Win32 path. */
upath.Buffer += upath.Length / sizeof (WCHAR) - len;
if (upath.Buffer[1] == L'\\') /* UNC path */
@ -4792,7 +4789,7 @@ basename (char *path)
if (c && (c > bs || c[1]))
return c + 1;
}
else if (!bs[0])
else if (!bs[0])
{
stpncpy (buf, path, bs - path);
stpcpy (buf + (bs - path), ".");

View File

@ -96,16 +96,6 @@ public:
inline void set_has_pgid_children (bool val) {has_pgid_children = val;}
inline sigset_t& getsigmask ()
{
return sig_mask;
}
inline void setsigmask (sigset_t mask)
{
sig_mask = mask;
}
commune_result commune_request (__uint32_t, ...);
bool alive ();
fhandler_pipe *pipe_fhandler (HANDLE, size_t &);
@ -128,8 +118,6 @@ public:
HANDLE sendsig;
HANDLE exec_sendsig;
DWORD exec_dwProcessId;
private:
sigset_t sig_mask;
public:
HANDLE wr_proc_pipe;
DWORD wr_proc_pipe_owner;

View File

@ -114,7 +114,6 @@ pipe_handler (LPVOID in_ps)
SetLastError (err);
return 0;
}
pipesync::pipesync (HANDLE f, DWORD is_reader):
reader (false), ret_handle (NULL)

View File

@ -1308,7 +1308,7 @@ NTFS supports hardlinks. </para>
files.</para>
<para><function>setuid</function> is only safe against reverting the user
switch after a call to one of the exec(2) functions took place. Windows
switch after a call to one of the exec(2) functions took place. Windows
doesn't support a non-revertable user switch within the context of Win32
processes.</para>

View File

@ -221,7 +221,6 @@ get_registry_hive_path (const PWCHAR name, PWCHAR path)
if (!RegOpenKeyExW (HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hkey))
{
WCHAR buf[NT_MAX_PATH];
WCHAR tmp[NT_MAX_PATH];
DWORD type, siz;
path[0] = L'\0';

View File

@ -505,26 +505,26 @@ get_setgroups_sidlist (cygsidlist &tmp_list, PSID usersid, struct passwd *pw,
static ULONG sys_privs[] = {
SE_CREATE_TOKEN_PRIVILEGE,
SE_ASSIGNPRIMARYTOKEN_PRIVILEGE,
SE_LOCK_MEMORY_PRIVILEGE,
SE_INCREASE_QUOTA_PRIVILEGE,
SE_TCB_PRIVILEGE,
SE_SECURITY_PRIVILEGE,
SE_TAKE_OWNERSHIP_PRIVILEGE,
SE_LOAD_DRIVER_PRIVILEGE,
SE_ASSIGNPRIMARYTOKEN_PRIVILEGE,
SE_LOCK_MEMORY_PRIVILEGE,
SE_INCREASE_QUOTA_PRIVILEGE,
SE_TCB_PRIVILEGE,
SE_SECURITY_PRIVILEGE,
SE_TAKE_OWNERSHIP_PRIVILEGE,
SE_LOAD_DRIVER_PRIVILEGE,
SE_SYSTEM_PROFILE_PRIVILEGE, /* Vista ONLY */
SE_SYSTEMTIME_PRIVILEGE,
SE_PROF_SINGLE_PROCESS_PRIVILEGE,
SE_INC_BASE_PRIORITY_PRIVILEGE,
SE_CREATE_PAGEFILE_PRIVILEGE,
SE_CREATE_PERMANENT_PRIVILEGE,
SE_BACKUP_PRIVILEGE,
SE_RESTORE_PRIVILEGE,
SE_SHUTDOWN_PRIVILEGE,
SE_DEBUG_PRIVILEGE,
SE_AUDIT_PRIVILEGE,
SE_SYSTEM_ENVIRONMENT_PRIVILEGE,
SE_CHANGE_NOTIFY_PRIVILEGE,
SE_SYSTEMTIME_PRIVILEGE,
SE_PROF_SINGLE_PROCESS_PRIVILEGE,
SE_INC_BASE_PRIORITY_PRIVILEGE,
SE_CREATE_PAGEFILE_PRIVILEGE,
SE_CREATE_PERMANENT_PRIVILEGE,
SE_BACKUP_PRIVILEGE,
SE_RESTORE_PRIVILEGE,
SE_SHUTDOWN_PRIVILEGE,
SE_DEBUG_PRIVILEGE,
SE_AUDIT_PRIVILEGE,
SE_SYSTEM_ENVIRONMENT_PRIVILEGE,
SE_CHANGE_NOTIFY_PRIVILEGE,
SE_UNDOCK_PRIVILEGE,
SE_MANAGE_VOLUME_PRIVILEGE,
SE_IMPERSONATE_PRIVILEGE,

View File

@ -106,7 +106,7 @@ cygpsid::string (PWCHAR nsidstr) const
{
UNICODE_STRING sid;
if (!psid || !nsidstr)
if (!psid || !nsidstr)
return NULL;
RtlInitEmptyUnicodeString (&sid, nsidstr, 256);
RtlConvertSidToUnicodeString (&sid, psid, FALSE);

View File

@ -55,7 +55,7 @@ get_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd)
{
set_errno (ENOMEM);
break;
}
}
status = NtQuerySecurityObject (fh, ALL_SECURITY_INFORMATION,
sd, len, &len);
}
@ -66,7 +66,7 @@ get_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd)
}
}
if (!retry)
{
{
OBJECT_ATTRIBUTES attr;
IO_STATUS_BLOCK io;
@ -98,7 +98,7 @@ set_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd)
for (; retry < 2; ++retry)
{
if (fh)
{
{
status = NtSetSecurityObject (fh, ALL_SECURITY_INFORMATION, sd);
if (NT_SUCCESS (status))
{
@ -107,7 +107,7 @@ set_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd)
}
}
if (!retry)
{
{
OBJECT_ATTRIBUTES attr;
IO_STATUS_BLOCK io;
@ -338,7 +338,7 @@ get_file_attribute (HANDLE handle, path_conv &pc,
return 0;
}
else
{
{
if (uidret)
*uidret = ILLEGAL_UID;
if (gidret)

View File

@ -206,11 +206,11 @@ public:
cygsid above. */
BOOL operator+= (cygsid &si) { return add ((PSID) si, false); }
BOOL operator+= (const char *sidstr) { cygsid nsi (sidstr);
return add ((PSID) nsi, false); }
return add ((PSID) nsi, false); }
BOOL operator+= (const PSID psid) { return add (psid, false); }
BOOL operator*= (cygsid &si) { return add ((PSID) si, true); }
BOOL operator*= (const char *sidstr) { cygsid nsi (sidstr);
return add ((PSID) nsi, true); }
return add ((PSID) nsi, true); }
BOOL operator*= (const PSID psid) { return add (psid, true); }
void count (int ncnt)
@ -220,7 +220,7 @@ public:
{
int wcnt = 0;
for (int i = 0; i < cnt; ++i)
if (!sids[i].is_well_known_sid ())
if (!sids[i].is_well_known_sid ())
++wcnt;
return wcnt;
}
@ -236,7 +236,7 @@ public:
int next_non_well_known_sid (int idx)
{
while (++idx < cnt)
if (!sids[idx].is_well_known_sid ())
if (!sids[idx].is_well_known_sid ())
return idx;
return -1;
}

View File

@ -160,7 +160,7 @@ pselect(int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
const struct timespec *ts, const sigset_t *set)
{
struct timeval tv;
sigset_t oldset = myself->getsigmask ();
sigset_t oldset = _my_tls.sigmask;
myfault efault;
if (efault.faulted (EFAULT))
@ -171,11 +171,11 @@ pselect(int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
tv.tv_usec = ts->tv_nsec / 1000;
}
if (set)
set_signal_mask (*set, myself->getsigmask ());
set_signal_mask (*set, _my_tls.sigmask);
int ret = cygwin_select (maxfds, readfds, writefds, exceptfds,
ts ? &tv : NULL);
if (set)
set_signal_mask (oldset, myself->getsigmask ());
set_signal_mask (oldset, _my_tls.sigmask);
return ret;
}

View File

@ -147,7 +147,7 @@ usleep (useconds_t useconds)
extern "C" int
sigprocmask (int how, const sigset_t *set, sigset_t *oldset)
{
return handle_sigprocmask (how, set, oldset, myself->getsigmask ());
return handle_sigprocmask (how, set, oldset, _my_tls.sigmask);
}
int __stdcall
@ -342,7 +342,7 @@ abort (void)
sigset_t sig_mask;
sigfillset (&sig_mask);
sigdelset (&sig_mask, SIGABRT);
set_signal_mask (sig_mask, myself->getsigmask ());
set_signal_mask (sig_mask, _my_tls.sigmask);
raise (SIGABRT);
_my_tls.call_signal_handler (); /* Call any signal handler */
@ -485,7 +485,7 @@ sigpause (int signal_mask)
extern "C" int
pause (void)
{
return handle_sigsuspend (myself->getsigmask ());
return handle_sigsuspend (_my_tls.sigmask);
}
extern "C" int

View File

@ -663,7 +663,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
else if (si.si_signo == __SIGPENDING)
pack.mask = &pending;
else if (si.si_signo == __SIGFLUSH || si.si_signo > 0)
pack.mask = &myself->getsigmask ();
pack.mask = &_my_tls.sigmask;
else
pack.mask = NULL;
@ -1118,7 +1118,7 @@ pending_signals::add (sigpacket& pack)
return;
se = sigs + pack.si.si_signo;
*se = pack;
se->mask = &myself->getsigmask ();
se->mask = &pack.tls->sigmask;
se->next = NULL;
if (end)
end->next = se;
@ -1199,7 +1199,7 @@ wait_sig (VOID *)
sigset_t dummy_mask;
if (!pack.mask)
{
dummy_mask = myself->getsigmask ();
dummy_mask = _main_tls->sigmask;
pack.mask = &dummy_mask;
}
@ -1218,7 +1218,7 @@ wait_sig (VOID *)
unsigned bit;
sigq.reset ();
while ((q = sigq.next ()))
if (myself->getsigmask () & (bit = SIGTOMASK (q->si.si_signo)))
if (pack.tls->sigmask & (bit = SIGTOMASK (q->si.si_signo)))
*pack.mask |= bit;
break;
case __SIGHOLD:

View File

@ -55,9 +55,9 @@ sys_wcstombs (char *tgt, int tlen, const PWCHAR src, int slen)
The "type" argument determines where the resulting buffer is stored.
It's either one of the cygheap_types values, or it's "HEAP_NOTHEAP".
In the latter case the allocation uses simple calloc.
Note that this code is shared by cygserver (which requires it via
__small_vsprintf) and so when built there plain calloc is the
__small_vsprintf) and so when built there plain calloc is the
only choice. */
int __stdcall
sys_wcstombs_alloc (char **tgt_p, int type, const PWCHAR src, int slen)
@ -70,11 +70,11 @@ sys_wcstombs_alloc (char **tgt_p, int type, const PWCHAR src, int slen)
size_t tlen = (slen == -1 ? ret : ret + 1);
if (type == HEAP_NOTHEAP)
*tgt_p = (char *) calloc (tlen, sizeof (char));
*tgt_p = (char *) calloc (tlen, sizeof (char));
else
*tgt_p = (char *) ccalloc ((cygheap_types) type, tlen, sizeof (char));
*tgt_p = (char *) ccalloc ((cygheap_types) type, tlen, sizeof (char));
if (!*tgt_p)
return 0;
return 0;
ret = sys_wcstombs (*tgt_p, tlen, src, slen);
}
return ret;
@ -97,11 +97,11 @@ sys_mbstowcs_alloc (PWCHAR *tgt_p, int type, const char *src)
if (ret)
{
if (type == HEAP_NOTHEAP)
*tgt_p = (PWCHAR) calloc (ret, sizeof (WCHAR));
*tgt_p = (PWCHAR) calloc (ret, sizeof (WCHAR));
else
*tgt_p = (PWCHAR) ccalloc ((cygheap_types) type, ret, sizeof (WCHAR));
*tgt_p = (PWCHAR) ccalloc ((cygheap_types) type, ret, sizeof (WCHAR));
if (!*tgt_p)
return 0;
return 0;
ret = sys_mbstowcs (*tgt_p, src, ret);
}
return ret;

View File

@ -183,9 +183,9 @@ try_to_bin (path_conv &win32_path, HANDLE h)
if (wincap.has_recycle_dot_bin ()) /* NTFS and FAT since Vista */
RtlAppendUnicodeToString (&recycler, L"\\$Recycle.Bin\\");
else if (win32_path.fs_is_ntfs ()) /* NTFS up to 2K3 */
RtlAppendUnicodeToString (&recycler, L"\\RECYCLER\\");
RtlAppendUnicodeToString (&recycler, L"\\RECYCLER\\");
else if (win32_path.fs_is_fat ()) /* FAT up to 2K3 */
RtlAppendUnicodeToString (&recycler, L"\\Recycled\\");
RtlAppendUnicodeToString (&recycler, L"\\Recycled\\");
else
goto out;
/* Is the file a subdir of the recycler? */
@ -287,9 +287,9 @@ try_to_bin (path_conv &win32_path, HANDLE h)
goto out;
}
/* Next, if necessary, check if the recycler/SID dir exists and
create it if not. */
create it if not. */
if (win32_path.fs_is_ntfs ())
{
{
NtClose (recyclerdir);
recycler.Length = recycler_user_len;
status = NtCreateFile (&recyclerdir, READ_CONTROL | FILE_ADD_FILE,
@ -306,10 +306,10 @@ try_to_bin (path_conv &win32_path, HANDLE h)
}
}
/* The desktop.ini and INFO2 (pre-Vista) files are expected by
Windows Explorer. Otherwise, the created bin is treated as
Windows Explorer. Otherwise, the created bin is treated as
corrupted */
if (io.Information == FILE_CREATED)
{
{
HANDLE fh;
RtlInitUnicodeString (&fname, L"desktop.ini");
InitializeObjectAttributes (&attr, &fname, OBJ_CASE_INSENSITIVE,
@ -326,7 +326,7 @@ try_to_bin (path_conv &win32_path, HANDLE h)
status = NtWriteFile (fh, NULL, NULL, NULL, &io, desktop_ini,
sizeof desktop_ini - 1, NULL, NULL);
if (!NT_SUCCESS (status))
debug_printf ("NtWriteFile (%S) failed, %08x", &fname, status);
debug_printf ("NtWriteFile (%S) failed, %08x", &fname, status);
NtClose (fh);
}
if (!wincap.has_recycle_dot_bin ()) /* No INFO2 file since Vista */
@ -455,7 +455,7 @@ unlink_nt (path_conv &pc)
{
status = check_dir_not_empty (fh);
if (!NT_SUCCESS (status))
{
{
NtClose (fh);
return status;
}
@ -1504,7 +1504,7 @@ rename (const char *oldpath, const char *newpath)
{
stpcpy (oldbuf = (char *) alloca (olen + 1), oldpath);
while (olen > 0 && isdirsep (oldbuf[olen - 1]))
oldbuf[--olen] = '\0';
oldbuf[--olen] = '\0';
oldpath = oldbuf;
old_dir_requested = true;
}
@ -1539,7 +1539,7 @@ rename (const char *oldpath, const char *newpath)
{
stpcpy (newbuf = (char *) alloca (nlen + 1), newpath);
while (nlen > 0 && isdirsep (newbuf[nlen - 1]))
newbuf[--nlen] = '\0';
newbuf[--nlen] = '\0';
newpath = newbuf;
new_dir_requested = true;
}
@ -1593,7 +1593,7 @@ rename (const char *oldpath, const char *newpath)
&& newpc.get_nt_native_path ()->Length >
oldpc.get_nt_native_path ()->Length
&& *(PWCHAR) ((PBYTE) newpc.get_nt_native_path ()->Buffer
+ oldpc.get_nt_native_path ()->Length) == L'\\')
+ oldpc.get_nt_native_path ()->Length) == L'\\')
{
set_errno (EINVAL);
goto out;
@ -1615,12 +1615,12 @@ rename (const char *oldpath, const char *newpath)
else if (oldpc.is_lnk_symlink ()
&& !RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (),
L".lnk", TRUE))
rename_append_suffix (newpc, newpath, nlen, ".lnk");
rename_append_suffix (newpc, newpath, nlen, ".lnk");
else if (oldpc.is_binary ()
&& !RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (),
L".exe", TRUE))
/* NOTE: No way to rename an executable foo.exe to foo. */
rename_append_suffix (newpc, newpath, nlen, ".exe");
rename_append_suffix (newpc, newpath, nlen, ".exe");
}
else if (newpc.isdir ())
{
@ -1641,7 +1641,7 @@ rename (const char *oldpath, const char *newpath)
}
}
else if (oldpc.is_lnk_symlink ())
{
{
if (!newpc.is_lnk_symlink ()
&& !RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (),
L".lnk", TRUE))
@ -1658,9 +1658,9 @@ rename (const char *oldpath, const char *newpath)
rename_append_suffix (new2pc, newpath, nlen, ".exe");
removepc = &newpc;
}
}
}
else
{
{
if ((RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (),
L".lnk", TRUE)
|| RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (),
@ -1712,7 +1712,7 @@ rename (const char *oldpath, const char *newpath)
| (dstpc->is_rep_symlink ()
? FILE_OPEN_REPARSE_POINT : 0));
if (!NT_SUCCESS (status))
{
{
__seterrno_from_nt_status (status);
goto out;
}
@ -1726,7 +1726,7 @@ rename (const char *oldpath, const char *newpath)
FileBasicInformation);
NtClose (nfh);
if (!NT_SUCCESS (status))
{
{
__seterrno_from_nt_status (status);
goto out;
}
@ -1749,7 +1749,7 @@ rename (const char *oldpath, const char *newpath)
&io, FILE_SHARE_VALID_FLAGS,
FILE_OPEN_FOR_BACKUP_INTENT
| ((removepc ?: dstpc)->is_rep_symlink ()
? FILE_OPEN_REPARSE_POINT : 0))))
? FILE_OPEN_REPARSE_POINT : 0))))
{
static const size_t vsiz = sizeof (FILE_FS_VOLUME_INFORMATION)
+ 32 * sizeof (WCHAR);

View File

@ -376,6 +376,7 @@ pthread::pthread ():verifyable_object (PTHREAD_MAGIC), win32_obj_id (0),
{
if (this != pthread_null::get_null_pthread ())
threads.insert (this);
parent_tls = &_my_tls;
}
pthread::~pthread ()
@ -1738,6 +1739,7 @@ pthread::thread_init_wrapper (void *arg)
// if thread is detached force cleanup on exit
if (thread->attr.joinable == PTHREAD_CREATE_DETACHED && thread->joiner == NULL)
thread->joiner = thread;
_my_tls.sigmask = thread->parent_tls->sigmask;
thread->mutex.unlock ();
thread_printf ("started thread %p %p %p %p %p %p", arg, &_my_tls.local_clib,

View File

@ -434,6 +434,7 @@ private:
DWORD thread_id;
__pthread_cleanup_handler *cleanup_stack;
pthread_mutex mutex;
_cygtls *parent_tls;
void suspend_except_self ();
void resume ();

View File

@ -179,8 +179,7 @@ extern HANDLE tty_mutex;
})
/* Convert a signal to a signal mask */
#define SIGTOMASK(sig) (1 << ((sig) - signal_shift_subtract))
extern unsigned int signal_shift_subtract;
#define SIGTOMASK(sig) (1 << ((sig) - 1))
extern int __api_fatal_exit_val;
#define set_api_fatal_return(n) do {extern int __api_fatal_exit_val; __api_fatal_exit_val = (n);} while (0)