DWORD proc_retry (HANDLE) __attribute__ ((regparm (2)));
bool isstraced () const {return !!(flag & _CI_STRACED);}
bool iscygwin () const {return !!(flag & _CI_ISCYGWIN);}
- bool saw_ctrl_c () const {return !!(flag & _CI_SAW_CTRL_C);}
+ bool saw_ctrl_c () const {return !!(flag & _CI_SAW_CTRL_C);}
void set_saw_ctrl_c () {flag |= _CI_SAW_CTRL_C;}
};
api_fatal ("fork: can't reserve memory for stack %p - %p, %E",
stacktop, stackbottom);
- new_stack_pointer = (void *) ((LPBYTE) stackbottom - stacksize);
+ new_stack_pointer = (void *) ((LPBYTE) stackbottom - stacksize);
if (!VirtualAlloc (new_stack_pointer, stacksize, MEM_COMMIT,
PAGE_EXECUTE_READWRITE))
api_fatal ("fork: can't commit memory for stack %p(%d), %E",
else if (de->d_name[1] == '.' && de->d_name[2] == '\0')
is_dot_dot = true;
}
-
+
if (is_dot_dot && !(dir->__flags & dirent_isroot))
de->d_ino = readdir_get_ino (dir,
((fhandler_base *) dir->__fh)->get_name (),
true);
else
- {
+ {
/* Compute d_ino by combining filename hash with directory hash. */
de->d_ino = ((fhandler_base *) dir->__fh)->get_namehash ();
if (!is_dot && !is_dot_dot)
DWORD devn = ((fhandler_base *) dir->__fh)->get_device ();
/* Paths below /proc don't have a Win32 pendant. */
if (devn == FH_PROC || devn == FH_PROCESS || devn == FH_REGISTRY)
- de->d_ino = hash_path_name (de->d_ino, "/");
+ de->d_ino = hash_path_name (de->d_ino, "/");
/* A drive's root dir has a trailing backslash already. */
else if (w32name[1] != ':' || w32name[2] != '\\' || w32name[3])
de->d_ino = hash_path_name (de->d_ino, "\\");
MALLOC_CHECK;
return NULL;
}
-
+
/* Primitive getenv before the environment is built. */
static char __stdcall *
si.si_code = BUS_OBJERR;
}
else
- {
+ {
MEMORY_BASIC_INFORMATION m;
VirtualQuery ((PVOID) e->ExceptionInformation[1], &m, sizeof m);
si.si_signo = SIGSEGV;
else
{
/* No error checking. The test which could return SIG_ERR has already
- been made above. */
+ been made above. */
signal (sig, func);
sigdelset (&mask, sig);
}
__ino64_t check_mount (const char *name, __ino64_t ino, bool eval = true)
{
if (parent_dir_len == 1) /* root dir */
- {
+ {
if (strcasematch (name, "proc"))
{
found[__DIR_PROC] = true;
__ino64_t check_missing_mount (char *ret_name, bool eval = true)
{
for (int i = 0; i < count; ++i)
- if (!found[i])
+ if (!found[i])
{
found[i] = true;
strcpy (ret_name, mounts[i]);
return eval ? eval_ino (i) : 1;
}
if (parent_dir_len == 1) /* root dir */
- {
+ {
if (!found[__DIR_PROC])
{
found[__DIR_PROC] = true;
{
found[__DIR_CYGDRIVE] = true;
if (mount_table->cygdrive_len > 1)
- {
+ {
strncpy (ret_name, mount_table->cygdrive + 1,
mount_table->cygdrive_len - 2);
ret_name[mount_table->cygdrive_len - 2] = '\0';
/* We can't trust remote inode numbers of only 32 bit. That means,
all remote inode numbers when running under NT4, as well as remote NT4
NTFS, as well as shares of Samba version < 3.0.
- The known exception are SFU NFS shares, which return the valid 32 bit
+ The known exception are SFU NFS shares, which return the valid 32 bit
inode number from the remote file system unchanged. */
return hasgood_inode () && (ino > UINT32_MAX || !isremote () || fs_is_nfs ());
}
const DWORD fai_size = 2 * CYG_MAX_PATH + sizeof (FILE_ALL_INFORMATION);
PFILE_FS_VOLUME_INFORMATION pfvi = (PFILE_FS_VOLUME_INFORMATION)
- alloca (fvi_size);
+ alloca (fvi_size);
PFILE_ALL_INFORMATION pfai = (PFILE_ALL_INFORMATION) alloca (fai_size);
status = NtQueryVolumeInformationFile (get_handle (), &io, pfvi, fvi_size,
newpc.check (newpath, PC_SYM_NOFOLLOW);
}
else if (transparent_exe
- && !pc.isdir ()
- && GetBinaryType (pc, &bintype)
- && (len = strlen (newpc)) > 4
- && !strcasematch ((const char *) newpc + len - 4, ".exe"))
- {
- /* Executable hack. */
- strcpy (new_buf, newpath);
- strcat (new_buf, ".exe");
- newpath = new_buf;
- newpc.check (newpath, PC_SYM_NOFOLLOW);
- }
+ && !pc.isdir ()
+ && GetBinaryType (pc, &bintype)
+ && (len = strlen (newpc)) > 4
+ && !strcasematch ((const char *) newpc + len - 4, ".exe"))
+ {
+ /* Executable hack. */
+ strcpy (new_buf, newpath);
+ strcat (new_buf, ".exe");
+ newpath = new_buf;
+ newpc.check (newpath, PC_SYM_NOFOLLOW);
+ }
}
query_open (query_write_attributes);
else if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL)
set_errno (ENOMEM);
else if ((dir->__d_dirname = (char *) malloc (wincap.is_winnt ()
- ? sizeof (struct __DIR_cache)
+ ? sizeof (struct __DIR_cache)
: len + 3)) == NULL)
{
set_errno (ENOMEM);
teeny little bit faster. */
len = strlen (d_dirname (dir));
if (len && !isdirsep (d_dirname (dir)[len - 1]))
- strcpy (d_dirname (dir) + len, "\\");
+ strcpy (d_dirname (dir) + len, "\\");
dir->__d_cookie = __DIRENT_COOKIE;
dir->__handle = INVALID_HANDLE_VALUE;
dir->__d_position = 0;
}
/* FileIdBothDirectoryInformation is apparently unsupported on
- XP when accessing directories on UDF. When trying to use it
+ XP when accessing directories on UDF. When trying to use it
so, NtQueryDirectoryFile returns with STATUS_ACCESS_VIOLATION.
It's not clear if the call isn't also unsupported on other
OS/FS combinations (say, Win2K/CDFS or so). Instead of
{
bool added = false;
if ((de->d_ino = d_mounts (dir)->check_missing_mount (fname)))
- added = true;
+ added = true;
if (!added)
return geterrno_from_win_error (w32_err);
{
buf = (PFILE_ID_BOTH_DIR_INFORMATION) (d_cache (dir) + d_cachepos (dir));
if (buf->NextEntryOffset == 0)
- d_cachepos (dir) = 0;
+ d_cachepos (dir) = 0;
else
d_cachepos (dir) += buf->NextEntryOffset;
if ((dir->__flags & dirent_get_d_ino))
FileName = buf->FileName;
if ((dir->__flags & dirent_set_d_ino))
de->d_ino = buf->FileId.QuadPart;
- }
+ }
else
- FileName = ((PFILE_BOTH_DIR_INFORMATION) buf)->FileName;
+ FileName = ((PFILE_BOTH_DIR_INFORMATION) buf)->FileName;
sys_wcstombs (fname, CYG_MAX_PATH - 1, FileName, buf->FileNameLength / 2);
de->d_ino = d_mounts (dir)->check_mount (fname, de->d_ino);
while (true)
{
if (!pdrive || !*pdrive)
- {
+ {
if (!(dir->__flags & dirent_saw_dot))
{
de->d_name[0] = '.';
de->d_ino = 2;
}
return ENMFILE;
- }
+ }
if (GetFileAttributes (pdrive) != INVALID_FILE_ATTRIBUTES)
- break;
+ break;
pdrive = strchr (pdrive, '\0') + 1;
}
*de->d_name = cyg_tolower (*pdrive);
if (!di)
{
/* Up to Win2K, even IOCTL_DISK_GET_DRIVE_GEOMETRY fails when trying
- it on CD or DVD drives. In that case fall back to requesting
+ it on CD or DVD drives. In that case fall back to requesting
simple file system information. */
NTSTATUS status;
IO_STATUS_BLOCK io;
FILE_FS_SIZE_INFORMATION ffsi;
-
+
status = NtQueryVolumeInformationFile (get_handle (), &io, &ffsi,
sizeof ffsi,
FileFsSizeInformation);
if (!NT_SUCCESS (status))
- {
+ {
__seterrno_from_nt_status (status);
return -1;
}
bytes_per_sector = ffsi.BytesPerSector;
drive_size = ffsi.TotalAllocationUnits.QuadPart
* ffsi.SectorsPerAllocationUnit
- * ffsi.BytesPerSector;
+ * ffsi.BytesPerSector;
if (geo)
- {
+ {
geo->heads = 1;
geo->sectors = ffsi.SectorsPerAllocationUnit;
geo->cylinders = ffsi.TotalAllocationUnits.LowPart;
}
}
debug_printf ("drive size: %D", drive_size);
-
+
return 0;
}
|| !isdigit (devname[8]))
continue;
/* Construct path name for partition 0, which is the whole disk,
- and try to open. */
+ and try to open. */
wcscpy (wpath, dbi->ObjectName.Buffer);
wcscpy (wpath + dbi->ObjectName.Length / 2, L"\\Partition0");
upath.Length = 22 + dbi->ObjectName.Length;
{
tab = (PMIB_TCPTABLE) alloca (size);
if (!GetTcpTable (tab, &size, FALSE))
- {
+ {
for (i = tab->dwNumEntries, entry = tab->table; i > 0; --i, ++entry)
if (entry->dwLocalAddr == addr->sin_addr.s_addr
- && entry->dwLocalPort == addr->sin_port
+ && entry->dwLocalPort == addr->sin_port
&& entry->dwState >= MIB_TCP_STATE_LISTEN
&& entry->dwState <= MIB_TCP_STATE_LAST_ACK)
return true;
else
{
/* If the application didn't explicitely call setsockopt (SO_REUSEADDR),
- enforce exclusive local address use using the SO_EXCLUSIVEADDRUSE
+ enforce exclusive local address use using the SO_EXCLUSIVEADDRUSE
socket option, to emulate POSIX socket behaviour more closely.
-
+
KB 870562: Note that this option is only available since NT4 SP4.
Also note that a bug in Win2K SP1-3 and XP up to SP1 only enables
this option for users in the local administrators group. */
if (wincap.has_exclusiveaddruse ())
- {
+ {
if (!saw_reuseaddr ())
{
int on = 1;
{
debug_printf ("SO_REUSEADDR set");
/* There's a bug in SO_REUSEADDR handling in WinSock.
- Per standards, we must not be able to reuse a complete
+ Per standards, we must not be able to reuse a complete
duplicate of a local TCP address (same IP, same port),
even if SO_REUSEADDR has been set. That's unfortunately
possible in WinSock. So we're testing here if the local
only works for OSes with IP Helper support. */
if (get_socket_type () == SOCK_STREAM
&& wincap.has_ip_helper_lib ()
- && address_in_use ((struct sockaddr_in *) name))
- {
+ && address_in_use ((struct sockaddr_in *) name))
+ {
debug_printf ("Local address in use, don't bind");
set_errno (EADDRINUSE);
goto out;
}
if (evts.lNetworkEvents & FD_ACCEPT)
{
- if (evts.iErrorCode[FD_ACCEPT_BIT])
+ if (evts.iErrorCode[FD_ACCEPT_BIT])
wsa_err = evts.iErrorCode[FD_ACCEPT_BIT];
else
ret = 0;
}
if (evts.lNetworkEvents & FD_CONNECT)
{
- if (evts.iErrorCode[FD_CONNECT_BIT])
+ if (evts.iErrorCode[FD_CONNECT_BIT])
wsa_err = evts.iErrorCode[FD_CONNECT_BIT];
else
ret = 0;
/* Various options should be defined here, but the framework to do this
is not laid down so far. Especially notable are the following defines,
- which can be used by the application to switch on or off various
+ which can be used by the application to switch on or off various
datatypes and function prototypes:
-
+
_BSD_SOURCE to include pure BSD functions which are not defined
- under POSIX.
+ under POSIX.
_POSIX_SOURCE if the application requests a POSIX compatible system.
_XOPEN_SOURCE if X/Open functions and datatypes are requested. This
- option includes _POSIX_SOURCE.
+ option includes _POSIX_SOURCE.
_GNU_SOURCE to turn on GNU extensions which might collide with defines
- used in application or library headers. This option
+ used in application or library headers. This option
includes _BSD_SOURCE, _XOPEN_SOURCE and _POSIX_SOURCE.
*/
int tcdrain (int);
int tcflush (int, int);
int tcflow (int, int);
-int cfsetispeed (struct termios *, speed_t);
-int cfsetospeed (struct termios *, speed_t);
+int cfsetispeed (struct termios *, speed_t);
+int cfsetospeed (struct termios *, speed_t);
#ifdef __cplusplus
}
sys_wcstombs (char *tgt, int tlen, const WCHAR *src, int slen)
{
int ret;
-
+
ret = WideCharToMultiByte (get_cp (), 0, src, slen, tgt, tlen, NULL, NULL);
if (ret)
tgt[ret < tlen ? ret : tlen - 1] = '\0';
It neither allows to create reserved pages in the shared memory
area, nor does it allow to create page aligend mappings (in
contrast to granularity aligned mappings).
-
+
Note that this isn't done in WOW64 environments since apparently
WOW64 does not support the AT_ROUND_TO_PAGE flag which is required
to get this right. Too bad. */
IP_DONTFRAGMENT
};
return (optname < 1 || optname > _WS1_IP_DONTFRAGMENT)
- ? optname
+ ? optname
: ws2_optname[optname];
}
syscall_printf ("setsockopt optval=%x", *(long *) optval);
if (res)
- {
+ {
/* KB 248611:
-
+
Windows 2000 and above don't support setting the IP_TOS field
with setsockopt. Additionally, TOS was always (also under 9x
and NT) only implemented for UDP and ICMP, never for TCP.
set_winsock_errno ();
}
else if (level == SOL_SOCKET && optname == SO_REUSEADDR)
- fh->saw_reuseaddr (*(int *) optval);
+ fh->saw_reuseaddr (*(int *) optval);
}
syscall_printf ("%d = setsockopt (%d, %d, %x, %p, %d)",
a problem in Winsock. The bind(2) call does not fail if a local
address is still in TIME_WAIT state, and there's no way to get this
behaviour. Unfortunately the first time when this is detected is when
- the calling application tries to connect.
-
+ the calling application tries to connect.
+
One (also not really foolproof) way around this problem would be to use
the iphlpapi function GetTcpTable and to check if the port in question is
in TIME_WAIT state and if so, choose another port number. But this method
res = (int) INVALID_SOCKET;
}
else if (port)
- *port = myport;
+ *port = myport;
}
if (res != (int) INVALID_SOCKET)
path following Win32 rules. */
const char *last_comp = strrchr (dir, '/');
return last_comp
- && last_comp[1] == '.'
+ && last_comp[1] == '.'
&& (last_comp[2] == '\0'
|| (last_comp[2] == '.' && last_comp[3] == '\0'));
}
else if (!tail)
tail = p;
if (tail && p[1] == '\\')
- {
+ {
if (p > tail || *tail != '.')
{
error = ENOENT;
return;
}
tail = NULL;
- }
+ }
}
if (!tail || tail == path)
mount_item *mi = mount + posix_sorted[i];
char *last_slash = strrchr (mi->posix_path, '/');
if (!last_slash)
- continue;
+ continue;
if (last_slash == mi->posix_path)
- {
+ {
if (parent_dir_len == 1 && mi->posix_pathlen > 1)
mount_points[n_mounts++] = last_slash + 1;
}
if (GetFileAttributes (reloldpath) == INVALID_FILE_ATTRIBUTES)
{
win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW,
- transparent_exe ? stat_suffixes : NULL);
+ transparent_exe ? stat_suffixes : NULL);
if (win32_oldpath.error != ENOENT)
strcpy (use_winsym ? reloldpath : w32oldpath, win32_oldpath);
}
if (use_winsym)
{
win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW,
- transparent_exe ? stat_suffixes : NULL);
+ transparent_exe ? stat_suffixes : NULL);
strcpy (w32oldpath, win32_oldpath);
}
if (cp)
/* Check for the suffix being tacked on. */
int tack_on = 0;
if (!transparent_exe && real_path.known_suffix)
- {
+ {
char *c = strrchr (real_path.normalized_path, '.');
if (!c || !strcasematch (c, real_path.known_suffix))
tack_on = strlen (real_path.known_suffix);
HANDLE hm = CreateFileMapping (h, &sec_none_nih, PAGE_READONLY, 0, 0, NULL);
CloseHandle (h);
if (!hm)
- {
+ {
/* ERROR_FILE_INVALID indicates very likely an empty file. */
if (GetLastError () == ERROR_FILE_INVALID)
{
DWORD devn;
path_conv win32_name (ourname, PC_SYM_NOFOLLOW,
- transparent_exe ? stat_suffixes : NULL);
+ transparent_exe ? stat_suffixes : NULL);
if (win32_name.error)
{
&& GetBinaryType (real_old, &bintype)
&& (len = strlen (real_new)) > 4
&& !strcasematch ((const char *) real_new + len - 4, ".exe"))
- {
+ {
/* Executable hack. */
strcpy (new_buf, newpath);
strcat (new_buf, ".exe");
}
/* Shortcut hack, No. 3, part 2 */
/* If a file with the given name exists, it must be deleted after the
- symlink has been renamed. Otherwise we end up with two files of
+ symlink has been renamed. Otherwise we end up with two files of
the same name in the directory, one file "newpath", which already
exited before rename has been called, and one file "newpath.lnk",
which is the result of the rename operation. */
else if (no_lnk_file_exists)
- {
+ {
lnk_suffix = strrchr (real_new.get_win32 (), '.');
*lnk_suffix = '\0';
DeleteFile (real_new);
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hdl == INVALID_HANDLE_VALUE)
- debug_printf ("CreateFile (%s) failed, %E", (char *) full_path);
+ debug_printf ("CreateFile (%s) failed, %E", (char *) full_path);
else
- {
+ {
NTFS_VOLUME_DATA_BUFFER nvdb;
DWORD bytes;
if (!DeviceIoControl (hdl, FSCTL_GET_NTFS_VOLUME_DATA, NULL,
case _SC_MEMLOCK_RANGE:
return _POSIX_MEMLOCK_RANGE;
case _SC_SEMAPHORES:
- return _POSIX_SEMAPHORES;
+ return _POSIX_SEMAPHORES;
case _SC_THREADS:
- return _POSIX_THREADS;
+ return _POSIX_THREADS;
case _SC_THREAD_ATTR_STACKSIZE:
- return _POSIX_THREAD_ATTR_STACKSIZE;
+ return _POSIX_THREAD_ATTR_STACKSIZE;
case _SC_THREAD_PRIORITY_SCHEDULING:
- return _POSIX_THREAD_PRIORITY_SCHEDULING;
+ return _POSIX_THREAD_PRIORITY_SCHEDULING;
case _SC_THREAD_PROCESS_SHARED:
- return _POSIX_THREAD_PROCESS_SHARED;
+ return _POSIX_THREAD_PROCESS_SHARED;
case _SC_THREAD_SAFE_FUNCTIONS:
- return _POSIX_THREAD_SAFE_FUNCTIONS;
+ return _POSIX_THREAD_SAFE_FUNCTIONS;
case _SC_TIMERS:
- return _POSIX_TIMERS;
+ return _POSIX_TIMERS;
}
/* Invalid input or unimplemented sysconf name */
ret = writev (syslogd_sock, iv, 2);
/* If the syslog daemon has been restarted and /dev/log was
- a stream socket, the connection is broken. In this case,
+ a stream socket, the connection is broken. In this case,
try to reopen the socket and try again. */
if (ret < 0 && syslogd_inited == inited_stream)
{