* fhandler.cc (fhandler_base::fork_fixup): Don't protect handle.

* dlfcn.cc: Fix to confirm to coding standards.  Reorganize includes throughout
to accomodate new cygheap.h usage.
* cygheap.h (cygheap_fdmanip): New class: simplifies locking and retrieval of
fds from cygheap->fdtab.
(cygheap_fdget): Ditto.
(cygheap_fdnew): Ditto.
* fcntl.cc (_fcntl): Use new method to lock fdtab and retrieve info.
* ioctl.cc (ioctl): Ditto.
* mmap.cc (mmap): Ditto.
* net.cc: Ditto, throughout.
* passwd.cc (getpass): Ditto.
* path.cc (fchdir): Ditto.
* pipe.cc (make_pipe): Ditto.
* sec_acl.cc (facl): Ditto.
* syscalls.cc: Ditto, throughout.
* termios.cc: Ditto, throughout.
This commit is contained in:
Christopher Faylor 2001-10-15 23:39:33 +00:00
parent fff126983e
commit df63bd490a
24 changed files with 398 additions and 396 deletions

View File

@ -1,3 +1,25 @@
2001-10-15 Christopher Faylor <cgf@redhat.com>
* fhandler.cc (fhandler_base::fork_fixup): Don't protect handle.
* dlfcn.cc: Fix to confirm to coding standards.
Reorganize includes throughout to accomodate new cygheap.h usage.
* cygheap.h (cygheap_fdmanip): New class: simplifies locking and
retrieval of fds from cygheap->fdtab.
(cygheap_fdget): Ditto.
(cygheap_fdnew): Ditto.
* fcntl.cc (_fcntl): Use new method to lock fdtab and retrieve info.
* ioctl.cc (ioctl): Ditto.
* mmap.cc (mmap): Ditto.
* net.cc: Ditto, throughout.
* passwd.cc (getpass): Ditto.
* path.cc (fchdir): Ditto.
* pipe.cc (make_pipe): Ditto.
* sec_acl.cc (facl): Ditto.
* syscalls.cc: Ditto, throughout.
* termios.cc: Ditto, throughout.
2001-10-15 Corinna Vinschen <corinna@vinschen.de>
* uname.cc (uname): Use `wProcessorLevel' unless OS sets it wrong.
@ -9,6 +31,7 @@
* dtable.cc (dtable::build_fhandler_from_name): Use PC_FULL to
determine path name.
* path.cc (fchdir): Remove rel -> abs path conversion.
Sun Oct 14 08:10:12 2001 Gary R. Van Sickle

View File

@ -17,10 +17,10 @@
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
#include "cygerrno.h"
#include "cygheap.h"
#include "child_info.h"
#include "heap.h"
#include "cygerrno.h"
#include "sync.h"
#include "shared_info.h"

View File

@ -176,6 +176,79 @@ struct init_cygheap
extern init_cygheap *cygheap;
extern void *cygheap_max;
class cygheap_fdmanip
{
protected:
int fd;
fhandler_base **fh;
bool locked;
public:
cygheap_fdmanip () {}
virtual ~cygheap_fdmanip ()
{
if (locked)
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "cygheap_fdmanip");
}
void release ()
{
cygheap->fdtab.release (fd);
}
operator int &() {return fd;}
operator fhandler_base* &() {return *fh;}
void operator = (fhandler_base *fh) {*this->fh = fh;}
fhandler_base *operator -> () const {return *fh;}
};
class cygheap_fdnew : public cygheap_fdmanip
{
public:
cygheap_fdnew (int seed_fd = -1, bool lockit = true)
{
if (lockit)
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "cygheap_fdnew");
if (seed_fd < 0)
fd = cygheap->fdtab.find_unused_handle ();
else
fd = cygheap->fdtab.find_unused_handle (seed_fd + 1);
if (fd >= 0)
{
locked = lockit;
fh = cygheap->fdtab + fd;
}
else
{
set_errno (EMFILE);
if (lockit)
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "cygheap_fdnew");
locked = false;
}
}
};
class cygheap_fdget : public cygheap_fdmanip
{
public:
cygheap_fdget (int fd, bool lockit = false)
{
if (lockit)
SetResourceLock (LOCK_FD_LIST, READ_LOCK, "cygheap_fdget");
if (fd >= 0 && fd < (int) cygheap->fdtab.size
&& *(fh = cygheap->fdtab + fd) != NULL)
{
this->fd = fd;
locked = lockit;
}
else
{
this->fd = -1;
set_errno (EBADF);
if (lockit)
ReleaseResourceLock (LOCK_FD_LIST, READ_LOCK, "cygheap_fdget");
locked = false;
}
}
};
class child_info;
void *__stdcall cygheap_setup_for_child (child_info *ci, bool dup_later) __attribute__ ((regparm(2)));
void __stdcall cygheap_setup_for_child_cleanup (void *, child_info *, bool) __attribute__ ((regparm(3)));

View File

@ -17,6 +17,7 @@ details. */
#include <limits.h>
#include <wingdi.h>
#include <winuser.h>
#include <errno.h>
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"

View File

@ -22,8 +22,8 @@ details. */
#include "dll_init.h"
#include "cygerrno.h"
#define _dl_error _reent_winsup()->_dl_error
#define _dl_buffer _reent_winsup()->_dl_buffer
#define _dl_error _reent_winsup ()->_dl_error
#define _dl_buffer _reent_winsup ()->_dl_buffer
static void __stdcall
set_dl_error (const char *str)
@ -85,7 +85,7 @@ get_full_path_of_dll (const char* str, char *name)
void *
dlopen (const char *name, int)
{
SetResourceLock(LOCK_DLL_LIST,READ_LOCK|WRITE_LOCK," dlopen");
SetResourceLock (LOCK_DLL_LIST, READ_LOCK | WRITE_LOCK, "dlopen");
void *ret;
@ -110,7 +110,7 @@ dlopen (const char *name, int)
set_dl_error ("dlopen");
debug_printf ("ret %p", ret);
ReleaseResourceLock(LOCK_DLL_LIST,READ_LOCK|WRITE_LOCK," dlopen");
ReleaseResourceLock (LOCK_DLL_LIST, READ_LOCK | WRITE_LOCK, "dlopen");
return ret;
}
@ -127,7 +127,7 @@ dlsym (void *handle, const char *name)
int
dlclose (void *handle)
{
SetResourceLock(LOCK_DLL_LIST,READ_LOCK|WRITE_LOCK," dlclose");
SetResourceLock (LOCK_DLL_LIST, READ_LOCK | WRITE_LOCK, "dlclose");
int ret = -1;
void *temphandle = (void *) GetModuleHandle (NULL);
@ -137,7 +137,7 @@ dlclose (void *handle)
set_dl_error ("dlclose");
CloseHandle ((HMODULE) temphandle);
ReleaseResourceLock(LOCK_DLL_LIST,READ_LOCK|WRITE_LOCK," dlclose");
ReleaseResourceLock (LOCK_DLL_LIST, READ_LOCK | WRITE_LOCK, "dlclose");
return ret;
}

View File

@ -8,6 +8,7 @@ details. */
#include "winsup.h"
#include <stdlib.h>
#include <errno.h>
#include "exceptions.h"
#include "cygerrno.h"
#include "perprocess.h"

View File

@ -17,8 +17,8 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
#include "cygheap.h"
#include "cygerrno.h"
#include "cygheap.h"
#include "thread.h"
extern "C"
@ -29,22 +29,26 @@ _fcntl (int fd, int cmd,...)
va_list args;
int res;
if (cygheap->fdtab.not_open (fd))
cygheap_fdget cfd (fd, true);
if (cfd < 0)
{
set_errno (EBADF);
res = -1;
goto done;
}
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK, "_fcntl");
va_start (args, cmd);
arg = va_arg (args, void *);
if (cmd == F_DUPFD)
res = dup2 (fd, cygheap->fdtab.find_unused_handle ((int) arg));
if (cmd != F_DUPFD)
res = cfd->fcntl(cmd, arg);
else
res = cygheap->fdtab[fd]->fcntl(cmd, arg);
{
cygheap_fdnew newfd;
if (newfd >= 0)
res = dup2 (fd, newfd);
else
res = -1;
}
va_end (args);
ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"_fcntl");
done:
syscall_printf ("%d = fcntl (%d, %d, %p)", res, fd, cmd, arg);

View File

@ -1639,7 +1639,7 @@ fhandler_base::fork_fixup (HANDLE parent, HANDLE &h, const char *name)
else
{
debug_printf ("%s success - oldh %p, h %p", get_name (), oh, h);
ProtectHandle1 (h, name);
// someday, maybe ProtectHandle2 (h, name);
setclexec_pid (h, !get_close_on_exec ());
}
#endif

View File

@ -24,8 +24,8 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
#include "cygheap.h"
#include "cygerrno.h"
#include "cygheap.h"
#include "pwdgrp.h"
/* Read /etc/group only once for better performance. This is done

View File

@ -25,15 +25,12 @@ details. */
extern "C" int
ioctl (int fd, int cmd, void *buf)
{
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
return -1;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
return -1;
debug_printf ("fd %d, cmd %x\n", fd, cmd);
fhandler_base *fh = cygheap->fdtab[fd];
if (fh->is_tty () && fh->get_device () != FH_PTYM)
if (cfd->is_tty () && cfd->get_device () != FH_PTYM)
switch (cmd)
{
case TCGETA:
@ -46,5 +43,5 @@ ioctl (int fd, int cmd, void *buf)
return tcsetattr (fd, TCSAFLUSH, (struct termios *) buf);
}
return fh->ioctl (cmd, buf);
return cfd->ioctl (cmd, buf);
}

View File

@ -18,6 +18,8 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
#include <errno.h>
#include "cygerrno.h"
#include "cygheap.h"
#include "heap.h"
#include "sync.h"

View File

@ -452,22 +452,21 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
if (fd != -1)
{
/* Ensure that fd is open */
if (cygheap->fdtab.not_open (fd))
cygheap_fdget cfd (fd);
if (cfd < 0)
{
set_errno (EBADF);
syscall_printf ("-1 = mmap(): EBADF");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return MAP_FAILED;
}
fh = cygheap->fdtab[fd];
if (fh->get_device () == FH_DISK)
if (cfd->get_device () == FH_DISK)
{
DWORD fsiz = GetFileSize (fh->get_handle (), NULL);
fsiz -= gran_off;
if (gran_len > fsiz)
gran_len = fsiz;
}
else if (fh->get_device () == FH_ZERO)
else if (cfd->get_device () == FH_ZERO)
/* mmap /dev/zero is like MAP_ANONYMOUS. */
fd = -1;
}

View File

@ -496,7 +496,7 @@ cygwin_getprotobynumber (int number)
}
fhandler_socket *
fdsock (int fd, const char *name, SOCKET soc)
fdsock (int& fd, const char *name, SOCKET soc)
{
if (!winsock2_active)
soc = set_socket_inheritance (soc);
@ -516,15 +516,11 @@ extern "C" int
cygwin_socket (int af, int type, int protocol)
{
int res = -1;
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "socket");
SOCKET soc = 0;
int fd = cygheap->fdtab.find_unused_handle ();
cygheap_fdnew fd;
if (fd < 0)
set_errno (EMFILE);
else
if (fd >= 0)
{
debug_printf ("socket (%d, %d, %d)", af, type, protocol);
@ -548,7 +544,6 @@ cygwin_socket (int af, int type, int protocol)
done:
syscall_printf ("%d = socket (%d, %d, %d)", res, af, type, protocol);
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "socket");
return res;
}
@ -698,13 +693,11 @@ cygwin_recvfrom (int fd,
fhandler_socket *
get (int fd)
{
if (cygheap->fdtab.not_open (fd))
{
set_errno (EINVAL);
return 0;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
return 0;
return cygheap->fdtab[fd]->is_socket ();
return cfd->is_socket ();
}
/* exported as setsockopt: standards? */
@ -1206,12 +1199,10 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
}
}
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "accept");
int res_fd = cygheap->fdtab.find_unused_handle ();
if (res_fd == -1)
/* FIXME: what is correct errno? */
set_errno (EMFILE);
cygheap_fdnew res_fd;
if (res_fd < 0)
/* FIXME: what is correct errno? */;
else if ((SOCKET) res == (SOCKET) INVALID_SOCKET)
set_winsock_errno ();
else
@ -1220,7 +1211,6 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
res_fh->set_addr_family (sock->get_addr_family ());
res = res_fd;
}
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "accept");
}
done:
syscall_printf ("%d = accept (%d, %x, %x)", res, fd, peer, len);
@ -2110,19 +2100,19 @@ cygwin_rcmd (char **ahost, unsigned short inport, char *locuser,
SOCKET fd2s;
sigframe thisframe (mainthread);
int res_fd = cygheap->fdtab.find_unused_handle ();
if (res_fd == -1)
cygheap_fdnew res_fd;
if (res_fd < 0)
goto done;
if (fd2p)
{
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "cygwin_rcmd");
*fd2p = cygheap->fdtab.find_unused_handle (res_fd + 1);
if (*fd2p == -1)
cygheap_fdnew newfd (res_fd, false);
if (*fd2p < 0)
goto done;
*fd2p = newfd;
}
res = rcmd (ahost, inport, locuser, remuser, cmd, fd2p? &fd2s: NULL);
res = rcmd (ahost, inport, locuser, remuser, cmd, fd2p ? &fd2s : NULL);
if (res == (int) INVALID_SOCKET)
goto done;
else
@ -2130,11 +2120,11 @@ cygwin_rcmd (char **ahost, unsigned short inport, char *locuser,
fdsock (res_fd, "/dev/tcp", res);
res = res_fd;
}
if (fd2p)
fdsock (*fd2p, "/dev/tcp", fd2s);
done:
if (fd2p)
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "cygwin_rcmd");
syscall_printf ("%d = rcmd (...)", res);
return res;
}
@ -2143,24 +2133,23 @@ done:
extern "C" int
cygwin_rresvport (int *port)
{
int res = -1;
int res;
sigframe thisframe (mainthread);
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "cygwin_rresvport");
int res_fd = cygheap->fdtab.find_unused_handle ();
if (res_fd == -1)
goto done;
res = rresvport (port);
if (res == (int) INVALID_SOCKET)
goto done;
cygheap_fdnew res_fd;
if (res_fd < 0)
res = -1;
else
{
fdsock (res_fd, "/dev/tcp", res);
res = res_fd;
res = rresvport (port);
if (res != (int) INVALID_SOCKET)
{
fdsock (res_fd, "/dev/tcp", res);
res = res_fd;
}
}
done:
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "cygwin_rresvport");
syscall_printf ("%d = rresvport (%d)", res, port ? *port : 0);
return res;
}
@ -2174,15 +2163,15 @@ cygwin_rexec (char **ahost, unsigned short inport, char *locuser,
SOCKET fd2s;
sigframe thisframe (mainthread);
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "cygwin_rexec");
int res_fd = cygheap->fdtab.find_unused_handle ();
if (res_fd == -1)
cygheap_fdnew res_fd;
if (res_fd < 0)
goto done;
if (fd2p)
{
*fd2p = cygheap->fdtab.find_unused_handle (res_fd + 1);
if (*fd2p == -1)
cygheap_fdnew newfd (res_fd);
if (newfd < 0)
goto done;
*fd2p = newfd;
}
res = rexec (ahost, inport, locuser, password, cmd, fd2p ? &fd2s : NULL);
if (res == (int) INVALID_SOCKET)
@ -2196,7 +2185,6 @@ cygwin_rexec (char **ahost, unsigned short inport, char *locuser,
fdsock (*fd2p, "/dev/tcp", fd2s);
done:
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "cygwin_rexec");
syscall_printf ("%d = rexec (...)", res);
return res;
}
@ -2211,21 +2199,18 @@ socketpair (int, int type, int, int *sb)
struct sockaddr_in sock_in;
int len = sizeof (sock_in);
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "socketpair");
sb[0] = cygheap->fdtab.find_unused_handle ();
if (sb[0] == -1)
cygheap_fdnew sb0;
if (sb0 < 0)
goto done;
else
{
set_errno (EMFILE);
goto done;
}
sb[1] = cygheap->fdtab.find_unused_handle (sb[0] + 1);
if (sb[1] == -1)
{
set_errno (EMFILE);
goto done;
}
sb[0] = sb0;
cygheap_fdnew sb1 (sb0, false);
if (sb1 < 0)
goto done;
sb[1] = sb1;
}
/* create a listening socket */
newsock = socket (AF_INET, type, 0);
if (newsock == INVALID_SOCKET)
@ -2300,7 +2285,6 @@ socketpair (int, int type, int, int *sb)
done:
syscall_printf ("%d = socketpair (...)", res);
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "socketpair");
return res;
}

View File

@ -385,14 +385,12 @@ getpass (const char * prompt)
if (passwd_state <= initializing)
read_etc_passwd ();
if (cygheap->fdtab.not_open (0))
{
set_errno (EBADF);
pass[0] = '\0';
}
cygheap_fdget fhstdin (0);
if (fhstdin < 0)
pass[0] = '\0';
else
{
fhandler_base *fhstdin = cygheap->fdtab[0];
fhstdin->tcgetattr (&ti);
newti = ti;
newti.c_lflag &= ~ECHO;

View File

@ -3136,19 +3136,17 @@ extern "C"
int
fchdir (int fd)
{
int res;
sigframe thisframe (mainthread);
if (cygheap->fdtab.not_open (fd))
{
syscall_printf ("-1 = fchdir (%d)", fd);
set_errno (EBADF);
return -1;
}
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fchdir");
int ret = chdir (cygheap->fdtab[fd]->get_name ());
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fchdir");
syscall_printf ("%d = fchdir (%d)", ret, fd);
return ret;
cygheap_fdget cfd (fd);
if (cfd >= 0)
res = chdir (cfd->get_name ());
else
res = -1;
syscall_printf ("%d = fchdir (%d)", res, fd);
return res;
}
/******************** Exported Path Routines *********************/

View File

@ -128,51 +128,53 @@ fhandler_pipe::dup (fhandler_base *child)
int
make_pipe (int fildes[2], unsigned int psize, int mode)
{
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "make_pipe");
HANDLE r, w;
int fdr = -1, fdw = -1;
SECURITY_ATTRIBUTES *sa = (mode & O_NOINHERIT) ? &sec_none_nih : &sec_none;
int res = -1;
if ((fdr = cygheap->fdtab.find_unused_handle ()) < 0)
set_errno (ENMFILE);
else if ((fdw = cygheap->fdtab.find_unused_handle (fdr + 1)) < 0)
set_errno (ENMFILE);
else if (!CreatePipe (&r, &w, sa, psize))
__seterrno ();
cygheap_fdnew fdr;
if (fdr < 0)
/* saw an error */;
else
{
fhandler_pipe *fhr = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdr, FH_PIPER, "/dev/piper");
fhandler_pipe *fhw = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdw, FH_PIPEW, "/dev/pipew");
int binmode = mode & O_TEXT ? 0 : 1;
fhr->init (r, GENERIC_READ, binmode);
fhw->init (w, GENERIC_WRITE, binmode);
if (mode & O_NOINHERIT)
{
fhr->set_close_on_exec_flag (1);
fhw->set_close_on_exec_flag (1);
}
fildes[0] = fdr;
fildes[1] = fdw;
res = 0;
fhr->create_guard (sa);
if (wincap.has_unreliable_pipes ())
cygheap_fdnew fdw (fdr, false);
if (fdw < 0)
set_errno (ENMFILE);
else if (!CreatePipe (&r, &w, sa, psize))
__seterrno ();
else
{
char buf[80];
int count = pipecount++; /* FIXME: Should this be InterlockedIncrement? */
__small_sprintf (buf, pipeid_fmt, myself->pid, count);
fhw->writepipe_exists = CreateEvent (sa, TRUE, FALSE, buf);
fhr->orig_pid = myself->pid;
fhr->id = count;
fhandler_pipe *fhr = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdr, FH_PIPER, "/dev/piper");
fhandler_pipe *fhw = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdw, FH_PIPEW, "/dev/pipew");
int binmode = mode & O_TEXT ? 0 : 1;
fhr->init (r, GENERIC_READ, binmode);
fhw->init (w, GENERIC_WRITE, binmode);
if (mode & O_NOINHERIT)
{
fhr->set_close_on_exec_flag (1);
fhw->set_close_on_exec_flag (1);
}
fildes[0] = fdr;
fildes[1] = fdw;
res = 0;
fhr->create_guard (sa);
if (wincap.has_unreliable_pipes ())
{
char buf[80];
int count = pipecount++; /* FIXME: Should this be InterlockedIncrement? */
__small_sprintf (buf, pipeid_fmt, myself->pid, count);
fhw->writepipe_exists = CreateEvent (sa, TRUE, FALSE, buf);
fhr->orig_pid = myself->pid;
fhr->id = count;
}
}
}
syscall_printf ("%d = make_pipe ([%d, %d], %d, %p)", res, fdr, fdw, psize, mode);
ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "make_pipe");
syscall_printf ("%d = make_pipe ([%d, %d], %d, %p)", res, fildes[0],
fildes[1], psize, mode);
return res;
}

View File

@ -16,8 +16,8 @@
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
#include "cygheap.h"
#include "cygerrno.h"
#include "cygheap.h"
#include "sigproc.h"
extern "C"

View File

@ -577,13 +577,13 @@ extern "C"
int
facl (int fd, int cmd, int nentries, aclent_t *aclbufp)
{
if (cygheap->fdtab.not_open (fd))
cygheap_fdget cfd (fd);
if (cfd < 0)
{
syscall_printf ("-1 = facl (%d)", fd);
set_errno (EBADF);
return -1;
}
const char *path = cygheap->fdtab[fd]->get_name ();
const char *path = cfd->get_name ();
if (path == NULL)
{
syscall_printf ("-1 = facl (%d) (no name)", fd);

View File

@ -14,6 +14,7 @@ details. */
#include <stdlib.h>
#include <grp.h>
#include <pwd.h>
#include <errno.h>
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
@ -21,6 +22,7 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
#include "cygerrno.h"
#include "cygheap.h"
#include "heap.h"
#include "shared_info.h"

View File

@ -73,7 +73,7 @@ check_pty_fds (void)
fhandler_base *fh;
for (int i = 0; i < (int) cygheap->fdtab.size; i++)
if ((fh = cygheap->fdtab[i]) != NULL &&
(fh->get_device() == FH_TTYS || fh->get_device() == FH_PTYM))
(fh->get_device () == FH_TTYS || fh->get_device () == FH_PTYM))
{
res = TRUE;
break;
@ -86,11 +86,12 @@ int
dup (int fd)
{
int res;
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup");
cygheap_fdnew newfd;
res = dup2 (fd, cygheap->fdtab.find_unused_handle ());
ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup");
if (newfd < 0)
res = -1;
else
res = dup2 (fd, newfd);
return res;
}
@ -287,7 +288,6 @@ extern "C" ssize_t
_read (int fd, void *ptr, size_t len)
{
int res;
fhandler_base *fh;
extern int sigcatchers;
int e = get_errno ();
@ -295,22 +295,18 @@ _read (int fd, void *ptr, size_t len)
{
sigframe thisframe (mainthread);
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
return -1;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
return -1;
// set_sig_errno (0);
fh = cygheap->fdtab[fd];
DWORD wait = fh->is_nonblocking () ? 0 : INFINITE;
DWORD wait = cfd->is_nonblocking () ? 0 : INFINITE;
/* Could block, so let user know we at least got here. */
syscall_printf ("read (%d, %p, %d) %sblocking, sigcatchers %d", fd, ptr, len, wait ? "" : "non", sigcatchers);
if (wait && (/*!sigcatchers || */!fh->is_slow () || fh->get_r_no_interrupt ()))
if (wait && (/*!sigcatchers || */!cfd->is_slow () || cfd->get_r_no_interrupt ()))
debug_printf ("non-interruptible read\n");
else if (!fh->ready_for_read (fd, wait, 0))
else if (!cfd->ready_for_read (fd, wait, 0))
{
if (!wait)
set_sig_errno (EAGAIN); /* Don't really need 'set_sig_errno' here, but... */
@ -322,11 +318,11 @@ _read (int fd, void *ptr, size_t len)
/* Check to see if this is a background read from a "tty",
sending a SIGTTIN, if appropriate */
res = fh->bg_check (SIGTTIN);
res = cfd->bg_check (SIGTTIN);
if (res > bg_eof)
{
myself->process_state |= PID_TTYIN;
res = fh->read (ptr, len);
res = cfd->read (ptr, len);
myself->process_state &= ~PID_TTYIN;
}
@ -336,8 +332,8 @@ _read (int fd, void *ptr, size_t len)
set_errno (e);
}
syscall_printf ("%d = read (%d<%s>, %p, %d), bin %d, errno %d", res, fd, fh->get_name (),
ptr, len, fh->get_r_binary (), get_errno ());
syscall_printf ("%d = read (%d, %p, %d), errno %d", res, fd, ptr, len,
get_errno ());
MALLOC_CHECK;
return res;
}
@ -348,11 +344,9 @@ _write (int fd, const void *ptr, size_t len)
int res = -1;
sigframe thisframe (mainthread);
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
goto done;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
goto done;
/* Could block, so let user know we at least got here. */
if (fd == 1 || fd == 2)
@ -360,15 +354,12 @@ _write (int fd, const void *ptr, size_t len)
else
syscall_printf ("write (%d, %p, %d)", fd, ptr, len);
fhandler_base *fh;
fh = cygheap->fdtab[fd];
res = fh->bg_check (SIGTTOU);
res = cfd->bg_check (SIGTTOU);
if (res > bg_eof)
{
myself->process_state |= PID_TTYOU;
res = fh->write (ptr, len);
res = cfd->write (ptr, len);
myself->process_state &= ~PID_TTYOU;
}
@ -378,7 +369,7 @@ done:
else
syscall_printf ("%d = write (%d, %p, %d)", res, fd, ptr, len);
return (ssize_t)res;
return (ssize_t) res;
}
/*
@ -475,24 +466,21 @@ readv (int fd, const struct iovec *iov, int iovcnt)
extern "C" int
_open (const char *unix_path, int flags, ...)
{
int fd;
int res = -1;
va_list ap;
mode_t mode = 0;
fhandler_base *fh;
sigframe thisframe (mainthread);
syscall_printf ("open (%s, %p)", unix_path, flags);
if (!check_null_empty_str_errno (unix_path))
{
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, " open ");
/* check for optional mode argument */
va_start (ap, flags);
mode = va_arg (ap, mode_t);
va_end (ap);
fd = cygheap->fdtab.find_unused_handle ();
fhandler_base *fh;
cygheap_fdnew fd;
if (fd < 0)
set_errno (ENMFILE);
@ -504,13 +492,12 @@ _open (const char *unix_path, int flags, ...)
res = -1; // errno already set
else if (!fh->open (&pc, flags, (mode & 07777) & ~cygheap->umask))
{
cygheap->fdtab.release (fd);
fd.release ();
res = -1;
}
else if ((res = fd) <= 2)
set_std_handle (res);
}
ReleaseResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," open");
}
syscall_printf ("%d = open (%s, %p)", res, unix_path, flags);
@ -528,14 +515,13 @@ _lseek (int fd, off_t pos, int dir)
set_errno (EINVAL);
res = -1;
}
else if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
res = -1;
}
else
{
res = cygheap->fdtab[fd]->lseek (pos, dir);
cygheap_fdget cfd (fd);
if (cfd >= 0)
res = cfd->lseek (pos, dir);
else
res = -1;
}
syscall_printf ("%d = lseek (%d, %d, %d)", res, fd, pos, dir);
@ -551,18 +537,14 @@ _close (int fd)
syscall_printf ("close (%d)", fd);
MALLOC_CHECK;
if (cygheap->fdtab.not_open (fd))
{
debug_printf ("handle %d not open", fd);
set_errno (EBADF);
res = -1;
}
cygheap_fdget cfd (fd, true);
if (cfd < 0)
res = -1;
else
{
SetResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close");
res = cygheap->fdtab[fd]->close ();
cygheap->fdtab.release (fd);
ReleaseResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close");
cfd->close ();
cfd.release ();
res = 0;
}
syscall_printf ("%d = close (%d)", res, fd);
@ -576,13 +558,11 @@ isatty (int fd)
int res;
sigframe thisframe (mainthread);
if (cygheap->fdtab.not_open (fd))
{
syscall_printf ("0 = isatty (%d)", fd);
return 0;
}
res = cygheap->fdtab[fd]->is_tty ();
cygheap_fdget cfd (fd);
if (cfd < 0)
res = 0;
else
res = cfd->is_tty ();
syscall_printf ("%d = isatty (%d)", res, fd);
return res;
}
@ -823,14 +803,14 @@ extern "C" int
fchown (int fd, uid_t uid, gid_t gid)
{
sigframe thisframe (mainthread);
if (cygheap->fdtab.not_open (fd))
cygheap_fdget cfd (fd);
if (cfd < 0)
{
syscall_printf ("-1 = fchown (%d,...)", fd);
set_errno (EBADF);
return -1;
}
const char *path = cygheap->fdtab[fd]->get_name ();
const char *path = cfd->get_name ();
if (path == NULL)
{
@ -932,14 +912,14 @@ extern "C" int
fchmod (int fd, mode_t mode)
{
sigframe thisframe (mainthread);
if (cygheap->fdtab.not_open (fd))
cygheap_fdget cfd (fd);
if (cfd < 0)
{
syscall_printf ("-1 = fchmod (%d, 0%o)", fd, mode);
set_errno (EBADF);
return -1;
}
const char *path = cygheap->fdtab[fd]->get_name ();
const char *path = cfd->get_name ();
if (path == NULL)
{
@ -956,23 +936,20 @@ fchmod (int fd, mode_t mode)
extern "C" int
_fstat (int fd, struct stat *buf)
{
int r;
int res;
sigframe thisframe (mainthread);
if (cygheap->fdtab.not_open (fd))
{
syscall_printf ("-1 = fstat (%d, %p)", fd, buf);
set_errno (EBADF);
r = -1;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
res = -1;
else
{
memset (buf, 0, sizeof (struct stat));
r = cygheap->fdtab[fd]->fstat (buf, NULL);
syscall_printf ("%d = fstat (%d, %x)", r, fd, buf);
res = cfd->fstat (buf, NULL);
}
return r;
syscall_printf ("%d = fstat (%d, %p)", res, fd, buf);
return res;
}
/* fsync: P96 6.6.1.1 */
@ -980,16 +957,14 @@ extern "C" int
fsync (int fd)
{
sigframe thisframe (mainthread);
if (cygheap->fdtab.not_open (fd))
cygheap_fdget cfd (fd);
if (cfd < 0)
{
syscall_printf ("-1 = fsync (%d)", fd);
set_errno (EBADF);
return -1;
}
HANDLE h = cygheap->fdtab[fd]->get_handle ();
if (FlushFileBuffers (h) == 0)
if (FlushFileBuffers (cfd->get_handle ()) == 0)
{
__seterrno ();
return -1;
@ -1364,11 +1339,9 @@ check_posix_perm (const char *fname, int v)
extern "C" long int
fpathconf (int fd, int v)
{
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
return -1;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
return -1;
switch (v)
{
case _PC_LINK_MAX:
@ -1391,7 +1364,7 @@ fpathconf (int fd, int v)
case _PC_NO_TRUNC:
return -1;
case _PC_VDISABLE:
if (isatty (fd))
if (cfd->is_tty ())
return -1;
else
{
@ -1400,13 +1373,10 @@ fpathconf (int fd, int v)
}
case _PC_POSIX_PERMISSIONS:
case _PC_POSIX_SECURITY:
{
fhandler_base *fh = cygheap->fdtab[fd];
if (fh->get_device () == FH_DISK)
return check_posix_perm (fh->get_win32_name (), v);
set_errno (EINVAL);
return -1;
}
if (cfd->get_device () == FH_DISK)
return check_posix_perm (cfd->get_win32_name (), v);
set_errno (EINVAL);
return -1;
default:
set_errno (EINVAL);
return -1;
@ -1459,11 +1429,12 @@ pathconf (const char *file, int v)
extern "C" char *
ttyname (int fd)
{
if (cygheap->fdtab.not_open (fd) || !cygheap->fdtab[fd]->is_tty ())
cygheap_fdget cfd (fd);
if (cfd < 0 || !cfd->is_tty ())
{
return 0;
}
return (char *) (cygheap->fdtab[fd]->ttyname ());
return (char *) (cfd->ttyname ());
}
extern "C" char *
@ -1490,21 +1461,20 @@ _cygwin_istext_for_stdio (int fd)
return 0; /* we do it for old apps, due to getc/putc macros */
}
if (cygheap->fdtab.not_open (fd))
cygheap_fdget cfd (fd);
if (cfd < 0)
{
syscall_printf (" _cifs: fd not open\n");
return 0;
}
fhandler_base *p = cygheap->fdtab[fd];
if (p->get_device () != FH_DISK)
if (cfd->get_device () != FH_DISK)
{
syscall_printf (" _cifs: fd not disk file\n");
return 0;
}
if (p->get_w_binary () || p->get_r_binary ())
if (cfd->get_w_binary () || cfd->get_r_binary ())
{
syscall_printf (" _cifs: get_*_binary\n");
return 0;
@ -1538,13 +1508,11 @@ setmode_helper (FILE *f)
extern "C" int
getmode (int fd)
{
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
return -1;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
return -1;
return cygheap->fdtab[fd]->get_flags () & (O_BINARY | O_TEXT);
return cfd->get_flags () & (O_BINARY | O_TEXT);
}
/* Set a file descriptor into text or binary mode, returning the
@ -1553,43 +1521,39 @@ getmode (int fd)
extern "C" int
setmode (int fd, int mode)
{
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
return -1;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
return -1;
if (mode != O_BINARY && mode != O_TEXT && mode != 0)
{
set_errno (EINVAL);
return -1;
}
fhandler_base *p = cygheap->fdtab[fd];
/* Note that we have no way to indicate the case that writes are
binary but not reads, or vice-versa. These cases can arise when
using the tty or console interface. People using those
interfaces should not use setmode. */
int res;
if (p->get_w_binary () && p->get_r_binary ())
if (cfd->get_w_binary () && cfd->get_r_binary ())
res = O_BINARY;
else if (p->get_w_binset () && p->get_r_binset ())
else if (cfd->get_w_binset () && cfd->get_r_binset ())
res = O_TEXT; /* Specifically set O_TEXT */
else
res = 0;
if (!mode)
p->reset_to_open_binmode ();
cfd->reset_to_open_binmode ();
else if (mode & O_BINARY)
{
p->set_w_binary (1);
p->set_r_binary (1);
cfd->set_w_binary (1);
cfd->set_r_binary (1);
}
else
{
p->set_w_binary (0);
p->set_r_binary (0);
cfd->set_w_binary (0);
cfd->set_r_binary (0);
}
if (_cygwin_istext_for_stdio (fd))
@ -1599,7 +1563,7 @@ setmode (int fd, int mode)
setmode_file = fd;
_fwalk (_REENT, setmode_helper);
syscall_printf ("setmode (%d<%s>, %s) returns %s\n", fd, p->get_name (),
syscall_printf ("setmode (%d<%s>, %s) returns %s\n", fd, cfd->get_name (),
mode & O_TEXT ? "text" : "binary",
res & O_TEXT ? "text" : "binary");
return res;
@ -1613,37 +1577,32 @@ ftruncate (int fd, off_t length)
int res = -1;
if (length < 0)
{
set_errno (EINVAL);
}
else if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
}
set_errno (EINVAL);
else
{
HANDLE h = cygheap->fdtab[fd]->get_handle ();
off_t prev_loc;
if (h)
cygheap_fdget cfd (fd);
if (cfd >= 0)
{
/* remember curr file pointer location */
prev_loc = cygheap->fdtab[fd]->lseek (0, SEEK_CUR);
HANDLE h = cygheap->fdtab[fd]->get_handle ();
cygheap->fdtab[fd]->lseek (length, SEEK_SET);
if (!SetEndOfFile (h))
if (cfd->get_handle ())
{
__seterrno ();
}
else
res = 0;
/* remember curr file pointer location */
off_t prev_loc = cfd->lseek (0, SEEK_CUR);
/* restore original file pointer location */
cygheap->fdtab[fd]->lseek (prev_loc, 0);
cfd->lseek (length, SEEK_SET);
if (!SetEndOfFile (h))
__seterrno ();
else
res = 0;
/* restore original file pointer location */
cfd->lseek (prev_loc, 0);
}
}
}
syscall_printf ("%d = ftruncate (%d, %d)", res, fd, length);
syscall_printf ("%d = ftruncate (%d, %d)", res, fd, length);
return res;
}
@ -1672,12 +1631,13 @@ truncate (const char *pathname, off_t length)
extern "C" long
get_osfhandle (int fd)
{
long res = -1;
long res;
if (cygheap->fdtab.not_open (fd))
set_errno (EBADF);
cygheap_fdget cfd (fd);
if (cfd >= 0)
res = (long) cfd->get_handle ();
else
res = (long) cygheap->fdtab[fd]->get_handle ();
res = -1;
syscall_printf ("%d = get_osfhandle (%d)", res, fd);
return res;
@ -1728,13 +1688,10 @@ extern "C" int
fstatfs (int fd, struct statfs *sfs)
{
sigframe thisframe (mainthread);
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
return -1;
}
fhandler_disk_file *f = (fhandler_disk_file *) cygheap->fdtab[fd];
return statfs (f->get_name (), sfs);
cygheap_fdget cfd (fd);
if (cfd < 0)
return -1;
return statfs (cfd->get_name (), sfs);
}
/* setpgid: POSIX 4.3.3.1 */
@ -1814,12 +1771,10 @@ extern "C" char *
ptsname (int fd)
{
sigframe thisframe (mainthread);
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
return 0;
}
return (char *) (cygheap->fdtab[fd]->ptsname ());
cygheap_fdget cfd (fd);
if (cfd < 0)
return 0;
return (char *) (cfd->ptsname ());
}
/* FIXME: what is this? */

View File

@ -18,8 +18,8 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
#include "cygheap.h"
#include "cygerrno.h"
#include "cygheap.h"
#include "ntdll.h"
/* sysconf: POSIX 4.8.1.1 */

View File

@ -14,6 +14,7 @@ details. */
#include <syslog.h>
#include <stdarg.h>
#include <unistd.h>
#include <errno.h>
#include "security.h"
#include "fhandler.h"
#include "path.h"

View File

@ -30,22 +30,14 @@ tcsendbreak (int fd, int duration)
{
int res = -1;
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
goto out;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
goto out;
fhandler_base *fh;
fh = cygheap->fdtab[fd];
if (!fh->is_tty ())
if (!cfd->is_tty ())
set_errno (ENOTTY);
else
{
if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
res = fh->tcsendbreak (duration);
}
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcsendbreak (duration);
out:
syscall_printf ("%d = tcsendbreak (%d, %d)", res, fd, duration);
@ -60,22 +52,14 @@ tcdrain (int fd)
termios_printf ("tcdrain");
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
goto out;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
goto out;
fhandler_base *fh;
fh = cygheap->fdtab[fd];
if (!fh->is_tty ())
if (!cfd->is_tty ())
set_errno (ENOTTY);
else
{
if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
res = fh->tcdrain ();
}
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcdrain ();
out:
syscall_printf ("%d = tcdrain (%d)", res, fd);
@ -88,22 +72,14 @@ tcflush (int fd, int queue)
{
int res = -1;
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
goto out;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
goto out;
fhandler_base *fh;
fh = cygheap->fdtab[fd];
if (!fh->is_tty ())
if (!cfd->is_tty ())
set_errno (ENOTTY);
else
{
if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
res = fh->tcflush (queue);
}
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcflush (queue);
out:
termios_printf ("%d = tcflush (%d, %d)", res, fd, queue);
@ -116,22 +92,14 @@ tcflow (int fd, int action)
{
int res = -1;
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
goto out;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
goto out;
fhandler_base *fh;
fh = cygheap->fdtab[fd];
if (!fh->is_tty ())
if (!cfd->is_tty ())
set_errno (ENOTTY);
else
{
if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
res = fh->tcflow (action);
}
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcflow (action);
out:
syscall_printf ("%d = tcflow (%d, %d)", res, fd, action);
@ -144,24 +112,16 @@ tcsetattr (int fd, int a, const struct termios *t)
{
int res = -1;
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
goto out;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
goto out;
t = __tonew_termios (t);
fhandler_base *fh;
fh = cygheap->fdtab[fd];
if (!fh->is_tty ())
if (!cfd->is_tty ())
set_errno (ENOTTY);
else
{
if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
res = fh->tcsetattr (a, t);
}
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcsetattr (a, t);
out:
termios_printf ("iflag %x, oflag %x, cflag %x, lflag %x, VMIN %d, VTIME %d",
@ -178,15 +138,13 @@ tcgetattr (int fd, struct termios *in_t)
int res = -1;
struct termios *t = __makenew_termios (in_t);
if (cygheap->fdtab.not_open (fd))
set_errno (EBADF);
else if (!cygheap->fdtab[fd]->is_tty ())
cygheap_fdget cfd (fd);
if (cfd < 0)
/* saw an error */;
else if (!cfd->is_tty ())
set_errno (ENOTTY);
else
{
if ((res = cygheap->fdtab[fd]->tcgetattr (t)) == 0)
(void) __toapp_termios (in_t, t);
}
else if ((res = cfd->tcgetattr (t)) == 0)
(void) __toapp_termios (in_t, t);
if (res)
termios_printf ("%d = tcgetattr (%d, %p)", res, fd, in_t);
@ -204,12 +162,13 @@ tcgetpgrp (int fd)
{
int res = -1;
if (cygheap->fdtab.not_open (fd))
set_errno (EBADF);
else if (!cygheap->fdtab[fd]->is_tty ())
cygheap_fdget cfd (fd);
if (cfd < 0)
/* saw an error */;
else if (!cfd->is_tty ())
set_errno (ENOTTY);
else
res = cygheap->fdtab[fd]->tcgetpgrp ();
res = cfd->tcgetpgrp ();
termios_printf ("%d = tcgetpgrp (%d)", res, fd);
return res;
@ -221,12 +180,13 @@ tcsetpgrp (int fd, pid_t pgid)
{
int res = -1;
if (cygheap->fdtab.not_open (fd))
set_errno (EBADF);
else if (!cygheap->fdtab[fd]->is_tty ())
cygheap_fdget cfd (fd);
if (cfd < 0)
/* saw an error */;
else if (!cfd->is_tty ())
set_errno (ENOTTY);
else
res = cygheap->fdtab[fd]->tcsetpgrp (pgid);
res = cfd->tcsetpgrp (pgid);
termios_printf ("%d = tcsetpgrp (%d, %x)", res, fd, pgid);
return res;

View File

@ -17,6 +17,7 @@ details. */
#include <limits.h>
#include <stdlib.h>
#include <lm.h>
#include <errno.h>
#include <sys/cygwin.h>
#include "sync.h"
#include "sigproc.h"
@ -25,6 +26,7 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
#include "cygerrno.h"
#include "cygheap.h"
#include "registry.h"