mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-01 03:50:28 +08:00
Throughout, change fdtab references to cygheap->fdtab.
* child_info.h (cygheap_exec_info): Eliminate special fdtab stuff. * spawn.cc (spawn_guts): Ditto. * cygheap.cc (cygheap_init): Initialize fdtab, if appropriate. * cygheap.h (CYGHEAPSIZE): Include size of init_cygheap. (_cmalloc_entry): Include fdtab here. * dtable.h (dtable): Declare/define new methods. * dtable.cc (dtable::vfork_child_fixup): New method. (dtable::fixup_after_exec): Remove unneeded extra arguments. * dcrt0.cc (dll_crt0_1): Ditto. * environ.cc (getwinenv): Use case sensitive comparison. (winenv): Make a copy of environment cache to avoid realloc problems when duplicate environment variables exist in the environment. (From Egor Duda) * net.cc (cygwin_socket): Revert Apr 14 change. * include/sys/file.h: Protect against previous X_OK definition. * passwd.cc: Eliminate passwd_sem throughout. * security.cc: Ditto. * cygwin.din: Export New functions. * passwd.cc (read_etc_passwd): Make race safe. (getpwuid_r): New function. (getpwnam_r): New function.
This commit is contained in:
parent
a2d47fe9d9
commit
0381fec68f
@ -1,3 +1,37 @@
|
|||||||
|
Wed Apr 18 16:53:54 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
Throughout, change fdtab references to cygheap->fdtab.
|
||||||
|
* child_info.h (cygheap_exec_info): Eliminate special fdtab stuff.
|
||||||
|
* spawn.cc (spawn_guts): Ditto.
|
||||||
|
* cygheap.cc (cygheap_init): Initialize fdtab, if appropriate.
|
||||||
|
* cygheap.h (CYGHEAPSIZE): Include size of init_cygheap.
|
||||||
|
(_cmalloc_entry): Include fdtab here.
|
||||||
|
* dtable.h (dtable): Declare/define new methods.
|
||||||
|
* dtable.cc (dtable::vfork_child_fixup): New method.
|
||||||
|
(dtable::fixup_after_exec): Remove unneeded extra arguments.
|
||||||
|
* dcrt0.cc (dll_crt0_1): Ditto.
|
||||||
|
|
||||||
|
* environ.cc (getwinenv): Use case sensitive comparison.
|
||||||
|
(winenv): Make a copy of environment cache to avoid realloc problems
|
||||||
|
when duplicate environment variables exist in the environment. (From
|
||||||
|
Egor Duda)
|
||||||
|
|
||||||
|
* net.cc (cygwin_socket): Revert Apr 14 change.
|
||||||
|
|
||||||
|
* include/sys/file.h: Protect against previous X_OK definition.
|
||||||
|
|
||||||
|
Tue Apr 17 12:18:28 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* passwd.cc: Eliminate passwd_sem throughout.
|
||||||
|
* security.cc: Ditto.
|
||||||
|
|
||||||
|
Tue Apr 17 12:18:28 2001 Robert Collins <rbtcollins@hotmail.com>
|
||||||
|
|
||||||
|
* cygwin.din: Export New functions.
|
||||||
|
* passwd.cc (read_etc_passwd): Make race safe.
|
||||||
|
(getpwuid_r): New function.
|
||||||
|
(getpwnam_r): New function.
|
||||||
|
|
||||||
2001-04-18 Egor Duda <deo@logos-m.ru>
|
2001-04-18 Egor Duda <deo@logos-m.ru>
|
||||||
|
|
||||||
* grp.cc (getgroups): Avoid crash if passwd field if /etc/group is
|
* grp.cc (getgroups): Avoid crash if passwd field if /etc/group is
|
||||||
|
@ -61,8 +61,6 @@ class cygheap_exec_info
|
|||||||
public:
|
public:
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
char *old_title;
|
char *old_title;
|
||||||
fhandler_base **fds;
|
|
||||||
size_t nfds;
|
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
int envc;
|
int envc;
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include <fhandler.h>
|
#include <fhandler.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
@ -66,6 +68,8 @@ cygheap_init ()
|
|||||||
{
|
{
|
||||||
cygheap_protect = new_muto (FALSE, "cygheap_protect");
|
cygheap_protect = new_muto (FALSE, "cygheap_protect");
|
||||||
_csbrk (0);
|
_csbrk (0);
|
||||||
|
if (!cygheap->fdtab)
|
||||||
|
cygheap->fdtab.init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copyright (C) 1997, 2000 DJ Delorie */
|
/* Copyright (C) 1997, 2000 DJ Delorie */
|
||||||
|
@ -24,8 +24,6 @@ enum cygheap_types
|
|||||||
HEAP_1_MAX = 100
|
HEAP_1_MAX = 100
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CYGHEAPSIZE ((4000 * sizeof (fhandler_union)) + (2 * 65536))
|
|
||||||
|
|
||||||
#define incygheap(s) (cygheap && ((char *) (s) >= (char *) cygheap) && ((char *) (s) <= ((char *) cygheap_max)))
|
#define incygheap(s) (cygheap && ((char *) (s) >= (char *) cygheap) && ((char *) (s) <= ((char *) cygheap_max)))
|
||||||
|
|
||||||
struct _cmalloc_entry
|
struct _cmalloc_entry
|
||||||
@ -124,8 +122,11 @@ struct init_cygheap
|
|||||||
HANDLE shared_h;
|
HANDLE shared_h;
|
||||||
HANDLE console_h;
|
HANDLE console_h;
|
||||||
cwdstuff cwd;
|
cwdstuff cwd;
|
||||||
|
dtable fdtab;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define CYGHEAPSIZE (sizeof (init_cygheap) + (4000 * sizeof (fhandler_union)) + (2 * 65536))
|
||||||
|
|
||||||
extern init_cygheap *cygheap;
|
extern init_cygheap *cygheap;
|
||||||
extern void *cygheap_max;
|
extern void *cygheap_max;
|
||||||
|
|
||||||
|
@ -933,8 +933,10 @@ getpwduid
|
|||||||
_getpwduid = getpwduid
|
_getpwduid = getpwduid
|
||||||
getpwnam
|
getpwnam
|
||||||
_getpwnam = getpwnam
|
_getpwnam = getpwnam
|
||||||
|
getpwnam_r
|
||||||
getpwuid
|
getpwuid
|
||||||
_getpwuid = getpwuid
|
_getpwuid = getpwuid
|
||||||
|
getpwuid_r
|
||||||
getpgrp
|
getpgrp
|
||||||
_getpgrp = getpgrp
|
_getpgrp = getpgrp
|
||||||
getgrent
|
getgrent
|
||||||
|
@ -20,16 +20,16 @@ details. */
|
|||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "cygheap.h"
|
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "child_info.h"
|
|
||||||
#define NEED_VFORK
|
#define NEED_VFORK
|
||||||
#include "perthread.h"
|
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "path.h"
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
|
#include "child_info.h"
|
||||||
|
#include "path.h"
|
||||||
|
#include "perthread.h"
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
#include "cygwin_version.h"
|
#include "cygwin_version.h"
|
||||||
#include "dll_init.h"
|
#include "dll_init.h"
|
||||||
@ -701,8 +701,7 @@ dll_crt0_1 ()
|
|||||||
__argv = spawn_info->moreinfo->argv;
|
__argv = spawn_info->moreinfo->argv;
|
||||||
envp = spawn_info->moreinfo->envp;
|
envp = spawn_info->moreinfo->envp;
|
||||||
envc = spawn_info->moreinfo->envc;
|
envc = spawn_info->moreinfo->envc;
|
||||||
fdtab.fixup_after_exec (spawn_info->parent, spawn_info->moreinfo->nfds,
|
cygheap->fdtab.fixup_after_exec (spawn_info->parent);
|
||||||
spawn_info->moreinfo->fds);
|
|
||||||
signal_fixup_after_exec (child_proc_info->type == PROC_SPAWN);
|
signal_fixup_after_exec (child_proc_info->type == PROC_SPAWN);
|
||||||
CloseHandle (spawn_info->parent);
|
CloseHandle (spawn_info->parent);
|
||||||
if (spawn_info->moreinfo->old_title)
|
if (spawn_info->moreinfo->old_title)
|
||||||
@ -716,7 +715,6 @@ dll_crt0_1 ()
|
|||||||
cygheap->user.set_sid (NULL);
|
cygheap->user.set_sid (NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// fdtab.vfork_child_fixup ();
|
|
||||||
}
|
}
|
||||||
ProtectHandle (hMainProc);
|
ProtectHandle (hMainProc);
|
||||||
ProtectHandle (hMainThread);
|
ProtectHandle (hMainThread);
|
||||||
@ -727,6 +725,7 @@ dll_crt0_1 ()
|
|||||||
/* Initialize the cygwin subsystem if this is the first process,
|
/* Initialize the cygwin subsystem if this is the first process,
|
||||||
or attach to shared data structures if it's already running. */
|
or attach to shared data structures if it's already running. */
|
||||||
memory_init ();
|
memory_init ();
|
||||||
|
cygheap->fdtab.vfork_child_fixup ();
|
||||||
|
|
||||||
(void) SetErrorMode (SEM_FAILCRITICALERRORS);
|
(void) SetErrorMode (SEM_FAILCRITICALERRORS);
|
||||||
|
|
||||||
@ -770,7 +769,7 @@ dll_crt0_1 ()
|
|||||||
if (!old_title && GetConsoleTitle (title_buf, TITLESIZE))
|
if (!old_title && GetConsoleTitle (title_buf, TITLESIZE))
|
||||||
old_title = title_buf;
|
old_title = title_buf;
|
||||||
|
|
||||||
/* Allocate fdtab */
|
/* Allocate cygheap->fdtab */
|
||||||
dtable_init ();
|
dtable_init ();
|
||||||
|
|
||||||
/* Initialize uid, gid. */
|
/* Initialize uid, gid. */
|
||||||
|
@ -25,6 +25,7 @@ details. */
|
|||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
|
||||||
/* Cygwin internal */
|
/* Cygwin internal */
|
||||||
|
@ -24,14 +24,12 @@ details. */
|
|||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "cygheap.h"
|
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
dtable fdtab;
|
|
||||||
|
|
||||||
static DWORD std_consts[] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
|
static DWORD std_consts[] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
|
||||||
STD_ERROR_HANDLE};
|
STD_ERROR_HANDLE};
|
||||||
@ -40,17 +38,17 @@ static DWORD std_consts[] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
|
|||||||
void
|
void
|
||||||
dtable_init (void)
|
dtable_init (void)
|
||||||
{
|
{
|
||||||
if (!fdtab.size)
|
if (!cygheap->fdtab.size)
|
||||||
fdtab.extend(NOFILE_INCR);
|
cygheap->fdtab.extend(NOFILE_INCR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __stdcall
|
void __stdcall
|
||||||
set_std_handle (int fd)
|
set_std_handle (int fd)
|
||||||
{
|
{
|
||||||
if (fd == 0)
|
if (fd == 0)
|
||||||
SetStdHandle (std_consts[fd], fdtab[fd]->get_handle ());
|
SetStdHandle (std_consts[fd], cygheap->fdtab[fd]->get_handle ());
|
||||||
else if (fd <= 2)
|
else if (fd <= 2)
|
||||||
SetStdHandle (std_consts[fd], fdtab[fd]->get_output_handle ());
|
SetStdHandle (std_consts[fd], cygheap->fdtab[fd]->get_output_handle ());
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -99,7 +97,7 @@ stdio_init (void)
|
|||||||
HANDLE out = GetStdHandle (STD_OUTPUT_HANDLE);
|
HANDLE out = GetStdHandle (STD_OUTPUT_HANDLE);
|
||||||
HANDLE err = GetStdHandle (STD_ERROR_HANDLE);
|
HANDLE err = GetStdHandle (STD_ERROR_HANDLE);
|
||||||
|
|
||||||
fdtab.init_std_file_from_handle (0, in, GENERIC_READ, "{stdin}");
|
cygheap->fdtab.init_std_file_from_handle (0, in, GENERIC_READ, "{stdin}");
|
||||||
|
|
||||||
/* STD_ERROR_HANDLE has been observed to be the same as
|
/* STD_ERROR_HANDLE has been observed to be the same as
|
||||||
STD_OUTPUT_HANDLE. We need separate handles (e.g. using pipes
|
STD_OUTPUT_HANDLE. We need separate handles (e.g. using pipes
|
||||||
@ -117,19 +115,19 @@ stdio_init (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fdtab.init_std_file_from_handle (1, out, GENERIC_WRITE, "{stdout}");
|
cygheap->fdtab.init_std_file_from_handle (1, out, GENERIC_WRITE, "{stdout}");
|
||||||
fdtab.init_std_file_from_handle (2, err, GENERIC_WRITE, "{stderr}");
|
cygheap->fdtab.init_std_file_from_handle (2, err, GENERIC_WRITE, "{stderr}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dtable::not_open (int fd)
|
dtable::not_open (int fd)
|
||||||
{
|
{
|
||||||
SetResourceLock(LOCK_FD_LIST,READ_LOCK," not_open");
|
SetResourceLock(LOCK_FD_LIST, READ_LOCK, "not_open");
|
||||||
|
|
||||||
int res = fd < 0 || fd >= (int)size || fds[fd] == NULL;
|
int res = fd < 0 || fd >= (int)size || fds[fd] == NULL;
|
||||||
|
|
||||||
ReleaseResourceLock(LOCK_FD_LIST,READ_LOCK," not open");
|
ReleaseResourceLock(LOCK_FD_LIST, READ_LOCK, "not open");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,8 +212,8 @@ cygwin_attach_handle_to_fd (char *name, int fd, HANDLE handle, mode_t bin,
|
|||||||
DWORD myaccess)
|
DWORD myaccess)
|
||||||
{
|
{
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
fd = fdtab.find_unused_handle();
|
fd = cygheap->fdtab.find_unused_handle();
|
||||||
fhandler_base *res = fdtab.build_fhandler (fd, name, handle);
|
fhandler_base *res = cygheap->fdtab.build_fhandler (fd, name, handle);
|
||||||
res->init (handle, myaccess, bin);
|
res->init (handle, myaccess, bin);
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
@ -377,18 +375,18 @@ dtable::dup2 (int oldfd, int newfd)
|
|||||||
|
|
||||||
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup");
|
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup");
|
||||||
|
|
||||||
if ((size_t) newfd >= fdtab.size || newfd < 0)
|
if ((size_t) newfd >= cygheap->fdtab.size || newfd < 0)
|
||||||
{
|
{
|
||||||
syscall_printf ("new fd out of bounds: %d", newfd);
|
syscall_printf ("new fd out of bounds: %d", newfd);
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((size_t) newfd >= fdtab.size)
|
if ((size_t) newfd >= cygheap->fdtab.size)
|
||||||
{
|
{
|
||||||
int inc_size = NOFILE_INCR * ((newfd + NOFILE_INCR - 1) / NOFILE_INCR) -
|
int inc_size = NOFILE_INCR * ((newfd + NOFILE_INCR - 1) / NOFILE_INCR) -
|
||||||
fdtab.size;
|
cygheap->fdtab.size;
|
||||||
fdtab.extend (inc_size);
|
cygheap->fdtab.extend (inc_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!not_open (newfd))
|
if (!not_open (newfd))
|
||||||
@ -468,7 +466,7 @@ dtable::select_except (int fd, select_record *s)
|
|||||||
void
|
void
|
||||||
dtable::fixup_before_fork (DWORD target_proc_id)
|
dtable::fixup_before_fork (DWORD target_proc_id)
|
||||||
{
|
{
|
||||||
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup");
|
SetResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fixup_before_fork");
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
for (size_t i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
if ((fh = fds[i]) != NULL)
|
if ((fh = fds[i]) != NULL)
|
||||||
@ -476,28 +474,26 @@ dtable::fixup_before_fork (DWORD target_proc_id)
|
|||||||
debug_printf ("fd %d(%s)", i, fh->get_name ());
|
debug_printf ("fd %d(%s)", i, fh->get_name ());
|
||||||
fh->fixup_before_fork_exec (target_proc_id);
|
fh->fixup_before_fork_exec (target_proc_id);
|
||||||
}
|
}
|
||||||
ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup");
|
ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fixup_before_fork");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dtable::fixup_before_exec (DWORD target_proc_id)
|
dtable::fixup_before_exec (DWORD target_proc_id)
|
||||||
{
|
{
|
||||||
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup");
|
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fixup_before_exec");
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
for (size_t i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
if ((fh = fds[i]) != NULL && (!fh->get_close_on_exec ()))
|
if ((fh = fds[i]) != NULL && !fh->get_close_on_exec ())
|
||||||
{
|
{
|
||||||
debug_printf ("fd %d(%s)", i, fh->get_name ());
|
debug_printf ("fd %d(%s)", i, fh->get_name ());
|
||||||
fh->fixup_before_fork_exec (target_proc_id);
|
fh->fixup_before_fork_exec (target_proc_id);
|
||||||
}
|
}
|
||||||
ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup");
|
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fixup_before_exec");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dtable::fixup_after_exec (HANDLE parent, size_t sz, fhandler_base **f)
|
dtable::fixup_after_exec (HANDLE parent)
|
||||||
{
|
{
|
||||||
size = sz;
|
|
||||||
fds = f;
|
|
||||||
first_fd_for_open = 0;
|
first_fd_for_open = 0;
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
for (size_t i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
@ -520,7 +516,6 @@ dtable::fixup_after_exec (HANDLE parent, size_t sz, fhandler_base **f)
|
|||||||
void
|
void
|
||||||
dtable::fixup_after_fork (HANDLE parent)
|
dtable::fixup_after_fork (HANDLE parent)
|
||||||
{
|
{
|
||||||
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup");
|
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
for (size_t i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
if ((fh = fds[i]) != NULL)
|
if ((fh = fds[i]) != NULL)
|
||||||
@ -531,7 +526,6 @@ dtable::fixup_after_fork (HANDLE parent)
|
|||||||
fh->fixup_after_fork (parent);
|
fh->fixup_after_fork (parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -541,7 +535,7 @@ dtable::vfork_child_dup ()
|
|||||||
newtable = (fhandler_base **) ccalloc (HEAP_ARGV, size, sizeof(fds[0]));
|
newtable = (fhandler_base **) ccalloc (HEAP_ARGV, size, sizeof(fds[0]));
|
||||||
int res = 1;
|
int res = 1;
|
||||||
|
|
||||||
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup");
|
SetResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup");
|
||||||
for (size_t i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
if (not_open (i))
|
if (not_open (i))
|
||||||
continue;
|
continue;
|
||||||
@ -555,14 +549,14 @@ dtable::vfork_child_dup ()
|
|||||||
fds_on_hold = fds;
|
fds_on_hold = fds;
|
||||||
fds = newtable;
|
fds = newtable;
|
||||||
out:
|
out:
|
||||||
ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup");
|
ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dtable::vfork_parent_restore ()
|
dtable::vfork_parent_restore ()
|
||||||
{
|
{
|
||||||
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup");
|
SetResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "restore");
|
||||||
|
|
||||||
close_all_files ();
|
close_all_files ();
|
||||||
fhandler_base **deleteme = fds;
|
fhandler_base **deleteme = fds;
|
||||||
@ -570,6 +564,30 @@ dtable::vfork_parent_restore ()
|
|||||||
fds_on_hold = NULL;
|
fds_on_hold = NULL;
|
||||||
cfree (deleteme);
|
cfree (deleteme);
|
||||||
|
|
||||||
ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup");
|
ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "restore");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dtable::vfork_child_fixup ()
|
||||||
|
{
|
||||||
|
if (!fds_on_hold)
|
||||||
|
return;
|
||||||
|
fhandler_base **saveme = fds;
|
||||||
|
fds = fds_on_hold;
|
||||||
|
|
||||||
|
fhandler_base *fh;
|
||||||
|
for (int i = 0; i < (int) cygheap->fdtab.size; i++)
|
||||||
|
if ((fh = cygheap->fdtab[i]) != NULL)
|
||||||
|
{
|
||||||
|
fh->close ();
|
||||||
|
fh->clear_readahead ();
|
||||||
|
cygheap->fdtab.release (i);
|
||||||
|
}
|
||||||
|
|
||||||
|
fds = saveme;
|
||||||
|
cfree (fds_on_hold);
|
||||||
|
fds_on_hold = NULL;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ public:
|
|||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
dtable () : first_fd_for_open(3), cnt_need_fixup_before(0) {}
|
dtable () : first_fd_for_open(3), cnt_need_fixup_before(0) {}
|
||||||
|
void init () {first_fd_for_open = 3;}
|
||||||
|
|
||||||
void dec_need_fixup_before ()
|
void dec_need_fixup_before ()
|
||||||
{ if (cnt_need_fixup_before > 0) --cnt_need_fixup_before; }
|
{ if (cnt_need_fixup_before > 0) --cnt_need_fixup_before; }
|
||||||
@ -31,6 +32,7 @@ public:
|
|||||||
|
|
||||||
int vfork_child_dup ();
|
int vfork_child_dup ();
|
||||||
void vfork_parent_restore ();
|
void vfork_parent_restore ();
|
||||||
|
void vfork_child_fixup ();
|
||||||
fhandler_base *dup_worker (fhandler_base *oldfh);
|
fhandler_base *dup_worker (fhandler_base *oldfh);
|
||||||
int extend (int howmuch);
|
int extend (int howmuch);
|
||||||
void fixup_before_exec (DWORD win_proc_id);
|
void fixup_before_exec (DWORD win_proc_id);
|
||||||
@ -45,7 +47,7 @@ public:
|
|||||||
void release (int fd);
|
void release (int fd);
|
||||||
void init_std_file_from_handle (int fd, HANDLE handle, DWORD access, const char *name);
|
void init_std_file_from_handle (int fd, HANDLE handle, DWORD access, const char *name);
|
||||||
int dup2 (int oldfd, int newfd);
|
int dup2 (int oldfd, int newfd);
|
||||||
void fixup_after_exec (HANDLE, size_t, fhandler_base **);
|
void fixup_after_exec (HANDLE);
|
||||||
inline fhandler_base *operator [](int fd) { return fds[fd]; }
|
inline fhandler_base *operator [](int fd) { return fds[fd]; }
|
||||||
select_record *select_read (int fd, select_record *s);
|
select_record *select_read (int fd, select_record *s);
|
||||||
select_record *select_write (int fd, select_record *s);
|
select_record *select_write (int fd, select_record *s);
|
||||||
|
@ -22,6 +22,7 @@ details. */
|
|||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "registry.h"
|
#include "registry.h"
|
||||||
#include "environ.h"
|
#include "environ.h"
|
||||||
@ -105,7 +106,7 @@ getwinenv (const char *env, const char *in_posix)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (int i = 0; conv_envvars[i].name != NULL; i++)
|
for (int i = 0; conv_envvars[i].name != NULL; i++)
|
||||||
if (strncasematch (env, conv_envvars[i].name, conv_envvars[i].namelen))
|
if (strncmp (env, conv_envvars[i].name, conv_envvars[i].namelen) == 0)
|
||||||
{
|
{
|
||||||
win_env *we = conv_envvars + i;
|
win_env *we = conv_envvars + i;
|
||||||
const char *val;
|
const char *val;
|
||||||
@ -735,10 +736,14 @@ winenv (const char * const *envp, int keep_posix)
|
|||||||
len = strcspn (*srcp, "=") + 1;
|
len = strcspn (*srcp, "=") + 1;
|
||||||
win_env *conv;
|
win_env *conv;
|
||||||
|
|
||||||
if (!keep_posix && (conv = getwinenv (*srcp, *srcp + len)))
|
if (keep_posix || !(conv = getwinenv (*srcp, *srcp + len)))
|
||||||
*dstp = conv->native;
|
|
||||||
else
|
|
||||||
*dstp = *srcp;
|
*dstp = *srcp;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *p = (char *) alloca (strlen (conv->native) + 1);
|
||||||
|
strcpy (p, conv->native);
|
||||||
|
*dstp = p;
|
||||||
|
}
|
||||||
tl += strlen (*dstp) + 1;
|
tl += strlen (*dstp) + 1;
|
||||||
if ((*dstp)[0] == '!' && isdrive ((*dstp) + 1) && (*dstp)[3] == '=')
|
if ((*dstp)[0] == '!' && isdrive ((*dstp) + 1) && (*dstp)[3] == '=')
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@ details. */
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ _fcntl (int fd, int cmd,...)
|
|||||||
va_list args;
|
va_list args;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
res = -1;
|
res = -1;
|
||||||
@ -37,9 +38,9 @@ _fcntl (int fd, int cmd,...)
|
|||||||
va_start (args, cmd);
|
va_start (args, cmd);
|
||||||
arg = va_arg (args, void *);
|
arg = va_arg (args, void *);
|
||||||
if (cmd == F_DUPFD)
|
if (cmd == F_DUPFD)
|
||||||
res = dup2 (fd, fdtab.find_unused_handle ((int) arg));
|
res = dup2 (fd, cygheap->fdtab.find_unused_handle ((int) arg));
|
||||||
else
|
else
|
||||||
res = fdtab[fd]->fcntl(cmd, arg);
|
res = cygheap->fdtab[fd]->fcntl(cmd, arg);
|
||||||
va_end (args);
|
va_end (args);
|
||||||
ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"_fcntl");
|
ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"_fcntl");
|
||||||
|
|
||||||
|
@ -13,12 +13,13 @@ details. */
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "cygheap.h"
|
|
||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
#include "host_dependent.h"
|
#include "host_dependent.h"
|
||||||
@ -77,7 +78,7 @@ fhandler_base::get_readahead ()
|
|||||||
{
|
{
|
||||||
int chret = -1;
|
int chret = -1;
|
||||||
if (raixget < ralen)
|
if (raixget < ralen)
|
||||||
chret = ((unsigned char)rabuf[raixget++]) & 0xff;
|
chret = ((unsigned char) rabuf[raixget++]) & 0xff;
|
||||||
/* FIXME - not thread safe */
|
/* FIXME - not thread safe */
|
||||||
if (raixget >= ralen)
|
if (raixget >= ralen)
|
||||||
raixget = raixput = ralen = 0;
|
raixget = raixput = ralen = 0;
|
||||||
|
@ -21,9 +21,10 @@ details. */
|
|||||||
#include <winnls.h> // MultiByteToWideChar () and friends
|
#include <winnls.h> // MultiByteToWideChar () and friends
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include "cygheap.h"
|
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
|
@ -16,10 +16,11 @@
|
|||||||
|
|
||||||
#include <cygwin/rdevio.h>
|
#include <cygwin/rdevio.h>
|
||||||
#include <sys/mtio.h>
|
#include <sys/mtio.h>
|
||||||
#include "cygheap.h"
|
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
/* static wrapper functions to hide the effect of media changes and
|
/* static wrapper functions to hide the effect of media changes and
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#define USE_SYS_TYPES_FD_SET
|
#define USE_SYS_TYPES_FD_SET
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include "cygheap.h"
|
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
|
|
||||||
#define SECRET_EVENT_NAME "cygwin.local_socket.secret.%d.%08x-%08x-%08x-%08x"
|
#define SECRET_EVENT_NAME "cygwin.local_socket.secret.%d.%08x-%08x-%08x-%08x"
|
||||||
|
@ -16,10 +16,11 @@ details. */
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <sys/mtio.h>
|
#include <sys/mtio.h>
|
||||||
#include "cygheap.h"
|
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
@ -1173,7 +1173,7 @@ fhandler_tty_master::fixup_after_exec (HANDLE)
|
|||||||
int
|
int
|
||||||
fhandler_tty_master::init_console ()
|
fhandler_tty_master::init_console ()
|
||||||
{
|
{
|
||||||
console = (fhandler_console *) fdtab.build_fhandler (-1, FH_CONSOLE, "/dev/ttym");
|
console = (fhandler_console *) cygheap->fdtab.build_fhandler (-1, FH_CONSOLE, "/dev/ttym");
|
||||||
if (console == NULL)
|
if (console == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
|
|||||||
MALLOC_CHECK;
|
MALLOC_CHECK;
|
||||||
|
|
||||||
pinfo_fixup_after_fork ();
|
pinfo_fixup_after_fork ();
|
||||||
fdtab.fixup_after_fork (hParent);
|
cygheap->fdtab.fixup_after_fork (hParent);
|
||||||
signal_fixup_after_fork ();
|
signal_fixup_after_fork ();
|
||||||
|
|
||||||
MALLOC_CHECK;
|
MALLOC_CHECK;
|
||||||
@ -377,7 +377,7 @@ fork_parent (void *stack_here, HANDLE& hParent, dll *&first_dll,
|
|||||||
parent after CreateProcess and before copying the datastructures
|
parent after CreateProcess and before copying the datastructures
|
||||||
to the child. So we have to start the child in suspend state,
|
to the child. So we have to start the child in suspend state,
|
||||||
unfortunately, to avoid a race condition. */
|
unfortunately, to avoid a race condition. */
|
||||||
if (fdtab.need_fixup_before ())
|
if (cygheap->fdtab.need_fixup_before ())
|
||||||
c_flags |= CREATE_SUSPENDED;
|
c_flags |= CREATE_SUSPENDED;
|
||||||
|
|
||||||
/* Create an inheritable handle to pass to the child process. This will
|
/* Create an inheritable handle to pass to the child process. This will
|
||||||
@ -490,9 +490,9 @@ out:
|
|||||||
|
|
||||||
/* Fixup the parent datastructure if needed and resume the child's
|
/* Fixup the parent datastructure if needed and resume the child's
|
||||||
main thread. */
|
main thread. */
|
||||||
if (fdtab.need_fixup_before ())
|
if (cygheap->fdtab.need_fixup_before ())
|
||||||
{
|
{
|
||||||
fdtab.fixup_before_fork (pi.dwProcessId);
|
cygheap->fdtab.fixup_before_fork (pi.dwProcessId);
|
||||||
ResumeThread (pi.hThread);
|
ResumeThread (pi.hThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -708,10 +708,10 @@ vfork ()
|
|||||||
for (pp = (char **)vf->frame, esp = vf->vfork_esp;
|
for (pp = (char **)vf->frame, esp = vf->vfork_esp;
|
||||||
esp <= vf->vfork_ebp + 1; pp++, esp++)
|
esp <= vf->vfork_ebp + 1; pp++, esp++)
|
||||||
*pp = *esp;
|
*pp = *esp;
|
||||||
return fdtab.vfork_child_dup () ? 0 : -1;
|
return cygheap->fdtab.vfork_child_dup () ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fdtab.vfork_parent_restore ();
|
cygheap->fdtab.vfork_parent_restore ();
|
||||||
|
|
||||||
vf = get_vfork_val ();
|
vf = get_vfork_val ();
|
||||||
if (vf->pid < 0)
|
if (vf->pid < 0)
|
||||||
|
@ -19,6 +19,8 @@ details. */
|
|||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#if defined (__CYGWIN__) || defined (__INSIDE_CYGWIN__)
|
#if defined (__CYGWIN__) || defined (__INSIDE_CYGWIN__)
|
||||||
# define X_OK _X_OK /* Check for execute permission. */
|
# define X_OK _X_OK /* Check for execute permission. */
|
||||||
#else
|
#else
|
||||||
|
# undef X_OK
|
||||||
extern const unsigned _cygwin_X_OK;
|
extern const unsigned _cygwin_X_OK;
|
||||||
# define X_OK _cygwin_X_OK
|
# define X_OK _cygwin_X_OK
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,19 +17,20 @@ details. */
|
|||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include <sys/termios.h>
|
#include <sys/termios.h>
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
ioctl (int fd, int cmd, void *buf)
|
ioctl (int fd, int cmd, void *buf)
|
||||||
{
|
{
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_printf ("fd %d, cmd %x\n", fd, cmd);
|
debug_printf ("fd %d, cmd %x\n", fd, cmd);
|
||||||
fhandler_base *fh = fdtab[fd];
|
fhandler_base *fh = cygheap->fdtab[fd];
|
||||||
if (fh->is_tty () && fh->get_device () != FH_PTYM)
|
if (fh->is_tty () && fh->get_device () != FH_PTYM)
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,8 @@ details. */
|
|||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
|
@ -61,8 +61,8 @@ class mmap_record
|
|||||||
base_address_ (b),
|
base_address_ (b),
|
||||||
map_map_ (NULL)
|
map_map_ (NULL)
|
||||||
{
|
{
|
||||||
if (fd >= 0 && !fdtab.not_open (fd))
|
if (fd >= 0 && !cygheap->fdtab.not_open (fd))
|
||||||
devtype_ = fdtab[fd]->get_device ();
|
devtype_ = cygheap->fdtab[fd]->get_device ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Default Copy constructor/operator=/destructor are ok */
|
/* Default Copy constructor/operator=/destructor are ok */
|
||||||
@ -231,7 +231,7 @@ mmap_record::alloc_fh ()
|
|||||||
the call to fork(). This requires creating a fhandler
|
the call to fork(). This requires creating a fhandler
|
||||||
of the correct type to be sure to call the method of the
|
of the correct type to be sure to call the method of the
|
||||||
correct class. */
|
correct class. */
|
||||||
return fdtab.build_fhandler (-1, get_device (), "", 0);
|
return cygheap->fdtab.build_fhandler (-1, get_device (), "", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -355,7 +355,7 @@ map::get_list_by_fd (int fd)
|
|||||||
#else /* so we use the name hash value to identify the file unless
|
#else /* so we use the name hash value to identify the file unless
|
||||||
it's not an anonymous mapping. */
|
it's not an anonymous mapping. */
|
||||||
if ((fd == -1 && lists[i]->fd == -1)
|
if ((fd == -1 && lists[i]->fd == -1)
|
||||||
|| (fd != -1 && lists[i]->hash == fdtab[fd]->get_namehash ()))
|
|| (fd != -1 && lists[i]->hash == cygheap->fdtab[fd]->get_namehash ()))
|
||||||
#endif
|
#endif
|
||||||
return lists[i];
|
return lists[i];
|
||||||
return 0;
|
return 0;
|
||||||
@ -366,7 +366,7 @@ map::add_list (list *l, int fd)
|
|||||||
{
|
{
|
||||||
l->fd = fd;
|
l->fd = fd;
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
l->hash = fdtab[fd]->get_namehash ();
|
l->hash = cygheap->fdtab[fd]->get_namehash ();
|
||||||
if (nlists == maxlists)
|
if (nlists == maxlists)
|
||||||
{
|
{
|
||||||
maxlists += 5;
|
maxlists += 5;
|
||||||
@ -471,14 +471,14 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
|
|||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
{
|
{
|
||||||
/* Ensure that fd is open */
|
/* Ensure that fd is open */
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
syscall_printf ("-1 = mmap(): EBADF");
|
syscall_printf ("-1 = mmap(): EBADF");
|
||||||
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
|
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
|
||||||
return MAP_FAILED;
|
return MAP_FAILED;
|
||||||
}
|
}
|
||||||
fh = fdtab[fd];
|
fh = cygheap->fdtab[fd];
|
||||||
if (fh->get_device () == FH_DISK)
|
if (fh->get_device () == FH_DISK)
|
||||||
{
|
{
|
||||||
DWORD fsiz = GetFileSize (fh->get_handle (), NULL);
|
DWORD fsiz = GetFileSize (fh->get_handle (), NULL);
|
||||||
|
@ -24,12 +24,12 @@ details. */
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#define USE_SYS_TYPES_FD_SET
|
#define USE_SYS_TYPES_FD_SET
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include "cygheap.h"
|
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
@ -327,10 +327,10 @@ fdsock (int fd, const char *name, SOCKET soc)
|
|||||||
{
|
{
|
||||||
if (wsadata.wVersion < 512) /* < Winsock 2.0 */
|
if (wsadata.wVersion < 512) /* < Winsock 2.0 */
|
||||||
soc = set_socket_inheritance (soc);
|
soc = set_socket_inheritance (soc);
|
||||||
fhandler_socket *fh = (fhandler_socket *) fdtab.build_fhandler (fd, FH_SOCKET, name);
|
fhandler_socket *fh = (fhandler_socket *) cygheap->fdtab.build_fhandler (fd, FH_SOCKET, name);
|
||||||
fh->set_io_handle ((HANDLE) soc);
|
fh->set_io_handle ((HANDLE) soc);
|
||||||
fh->set_flags (O_RDWR);
|
fh->set_flags (O_RDWR);
|
||||||
fdtab.inc_need_fixup_before ();
|
cygheap->fdtab.inc_need_fixup_before ();
|
||||||
return fh;
|
return fh;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ cygwin_socket (int af, int type, int protocol)
|
|||||||
|
|
||||||
SOCKET soc;
|
SOCKET soc;
|
||||||
|
|
||||||
int fd = fdtab.find_unused_handle ();
|
int fd = cygheap->fdtab.find_unused_handle ();
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
set_errno (EMFILE);
|
set_errno (EMFILE);
|
||||||
@ -363,12 +363,7 @@ cygwin_socket (int af, int type, int protocol)
|
|||||||
if (af == AF_INET)
|
if (af == AF_INET)
|
||||||
name = (type == SOCK_STREAM ? "/dev/tcp" : "/dev/udp");
|
name = (type == SOCK_STREAM ? "/dev/tcp" : "/dev/udp");
|
||||||
else
|
else
|
||||||
{
|
name = (type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket");
|
||||||
name = (type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket");
|
|
||||||
/* Set LINGER with 0 timeout for hard close */
|
|
||||||
struct linger tmp = {1, 0}; /* On, 0 delay */
|
|
||||||
(void) setsockopt (soc, SOL_SOCKET, SO_LINGER, (char *)&tmp, sizeof(tmp));
|
|
||||||
}
|
|
||||||
|
|
||||||
fdsock (fd, name, soc)->set_addr_family (af);
|
fdsock (fd, name, soc)->set_addr_family (af);
|
||||||
res = fd;
|
res = fd;
|
||||||
@ -435,7 +430,7 @@ cygwin_sendto (int fd,
|
|||||||
const struct sockaddr *to,
|
const struct sockaddr *to,
|
||||||
int tolen)
|
int tolen)
|
||||||
{
|
{
|
||||||
fhandler_socket *h = (fhandler_socket *) fdtab[fd];
|
fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
|
||||||
sockaddr_in sin;
|
sockaddr_in sin;
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
@ -461,7 +456,7 @@ cygwin_recvfrom (int fd,
|
|||||||
struct sockaddr *from,
|
struct sockaddr *from,
|
||||||
int *fromlen)
|
int *fromlen)
|
||||||
{
|
{
|
||||||
fhandler_socket *h = (fhandler_socket *) fdtab[fd];
|
fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
debug_printf ("recvfrom %d", h->get_socket ());
|
debug_printf ("recvfrom %d", h->get_socket ());
|
||||||
@ -480,13 +475,13 @@ cygwin_recvfrom (int fd,
|
|||||||
fhandler_socket *
|
fhandler_socket *
|
||||||
get (int fd)
|
get (int fd)
|
||||||
{
|
{
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fdtab[fd]->is_socket ();
|
return cygheap->fdtab[fd]->is_socket ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exported as setsockopt: standards? */
|
/* exported as setsockopt: standards? */
|
||||||
@ -823,7 +818,7 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
|
|||||||
|
|
||||||
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "accept");
|
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "accept");
|
||||||
|
|
||||||
int res_fd = fdtab.find_unused_handle ();
|
int res_fd = cygheap->fdtab.find_unused_handle ();
|
||||||
if (res_fd == -1)
|
if (res_fd == -1)
|
||||||
{
|
{
|
||||||
/* FIXME: what is correct errno? */
|
/* FIXME: what is correct errno? */
|
||||||
@ -1021,7 +1016,7 @@ cygwin_hstrerror (int err)
|
|||||||
extern "C" void
|
extern "C" void
|
||||||
cygwin_herror (const char *s)
|
cygwin_herror (const char *s)
|
||||||
{
|
{
|
||||||
if (fdtab.not_open (2))
|
if (cygheap->fdtab.not_open (2))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
@ -1053,7 +1048,7 @@ cygwin_herror (const char *s)
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
cygwin_getpeername (int fd, struct sockaddr *name, int *len)
|
cygwin_getpeername (int fd, struct sockaddr *name, int *len)
|
||||||
{
|
{
|
||||||
fhandler_socket *h = (fhandler_socket *) fdtab[fd];
|
fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
|
||||||
|
|
||||||
debug_printf ("getpeername %d", h->get_socket ());
|
debug_printf ("getpeername %d", h->get_socket ());
|
||||||
int res = getpeername (h->get_socket (), name, len);
|
int res = getpeername (h->get_socket (), name, len);
|
||||||
@ -1068,7 +1063,7 @@ cygwin_getpeername (int fd, struct sockaddr *name, int *len)
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
cygwin_recv (int fd, void *buf, int len, unsigned int flags)
|
cygwin_recv (int fd, void *buf, int len, unsigned int flags)
|
||||||
{
|
{
|
||||||
fhandler_socket *h = (fhandler_socket *) fdtab[fd];
|
fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
int res = recv (h->get_socket (), (char *) buf, len, flags);
|
int res = recv (h->get_socket (), (char *) buf, len, flags);
|
||||||
@ -1093,7 +1088,7 @@ cygwin_recv (int fd, void *buf, int len, unsigned int flags)
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
cygwin_send (int fd, const void *buf, int len, unsigned int flags)
|
cygwin_send (int fd, const void *buf, int len, unsigned int flags)
|
||||||
{
|
{
|
||||||
fhandler_socket *h = (fhandler_socket *) fdtab[fd];
|
fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
int res = send (h->get_socket (), (const char *) buf, len, flags);
|
int res = send (h->get_socket (), (const char *) buf, len, flags);
|
||||||
@ -1728,13 +1723,13 @@ cygwin_rcmd (char **ahost, unsigned short inport, char *locuser,
|
|||||||
SOCKET fd2s;
|
SOCKET fd2s;
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
int res_fd = fdtab.find_unused_handle ();
|
int res_fd = cygheap->fdtab.find_unused_handle ();
|
||||||
if (res_fd == -1)
|
if (res_fd == -1)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (fd2p)
|
if (fd2p)
|
||||||
{
|
{
|
||||||
*fd2p = fdtab.find_unused_handle (res_fd + 1);
|
*fd2p = cygheap->fdtab.find_unused_handle (res_fd + 1);
|
||||||
if (*fd2p == -1)
|
if (*fd2p == -1)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -1763,7 +1758,7 @@ cygwin_rresvport (int *port)
|
|||||||
int res = -1;
|
int res = -1;
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
int res_fd = fdtab.find_unused_handle ();
|
int res_fd = cygheap->fdtab.find_unused_handle ();
|
||||||
if (res_fd == -1)
|
if (res_fd == -1)
|
||||||
goto done;
|
goto done;
|
||||||
res = rresvport (port);
|
res = rresvport (port);
|
||||||
@ -1789,12 +1784,12 @@ cygwin_rexec (char **ahost, unsigned short inport, char *locuser,
|
|||||||
SOCKET fd2s;
|
SOCKET fd2s;
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
int res_fd = fdtab.find_unused_handle ();
|
int res_fd = cygheap->fdtab.find_unused_handle ();
|
||||||
if (res_fd == -1)
|
if (res_fd == -1)
|
||||||
goto done;
|
goto done;
|
||||||
if (fd2p)
|
if (fd2p)
|
||||||
{
|
{
|
||||||
*fd2p = fdtab.find_unused_handle (res_fd + 1);
|
*fd2p = cygheap->fdtab.find_unused_handle (res_fd + 1);
|
||||||
if (*fd2p == -1)
|
if (*fd2p == -1)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -1826,13 +1821,13 @@ socketpair (int, int type, int, int *sb)
|
|||||||
|
|
||||||
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "socketpair");
|
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "socketpair");
|
||||||
|
|
||||||
sb[0] = fdtab.find_unused_handle ();
|
sb[0] = cygheap->fdtab.find_unused_handle ();
|
||||||
if (sb[0] == -1)
|
if (sb[0] == -1)
|
||||||
{
|
{
|
||||||
set_errno (EMFILE);
|
set_errno (EMFILE);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
sb[1] = fdtab.find_unused_handle (sb[0] + 1);
|
sb[1] = cygheap->fdtab.find_unused_handle (sb[0] + 1);
|
||||||
if (sb[1] == -1)
|
if (sb[1] == -1)
|
||||||
{
|
{
|
||||||
set_errno (EMFILE);
|
set_errno (EMFILE);
|
||||||
|
@ -35,6 +35,7 @@ static int max_lines = 0;
|
|||||||
and read in the password file if it isn't set. */
|
and read in the password file if it isn't set. */
|
||||||
enum pwd_state {
|
enum pwd_state {
|
||||||
uninitialized = 0,
|
uninitialized = 0,
|
||||||
|
initializing,
|
||||||
emulated,
|
emulated,
|
||||||
loaded
|
loaded
|
||||||
};
|
};
|
||||||
@ -120,34 +121,54 @@ add_pwd_line (char *line)
|
|||||||
void
|
void
|
||||||
read_etc_passwd ()
|
read_etc_passwd ()
|
||||||
{
|
{
|
||||||
extern int passwd_sem;
|
|
||||||
char linebuf[1024];
|
char linebuf[1024];
|
||||||
++passwd_sem;
|
/* A mutex is ok for speed here - pthreads will use critical sections not mutex's
|
||||||
FILE *f = fopen ("/etc/passwd", "rt");
|
* for non-shared mutexs in the future. Also, this function will at most be called
|
||||||
--passwd_sem;
|
* once from each thread, after that the passwd_state test will succeed
|
||||||
|
*/
|
||||||
|
static pthread_mutex_t etc_passwd_mutex = (pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
pthread_mutex_lock (&etc_passwd_mutex);
|
||||||
|
|
||||||
if (f)
|
/* if we got blocked by the mutex, then etc_passwd may have been processed */
|
||||||
|
if (passwd_state != uninitialized)
|
||||||
{
|
{
|
||||||
while (fgets (linebuf, sizeof (linebuf), f) != NULL)
|
pthread_mutex_unlock(&etc_passwd_mutex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (passwd_state != initializing)
|
||||||
|
{
|
||||||
|
passwd_state = initializing;
|
||||||
|
|
||||||
|
FILE *f = fopen ("/etc/passwd", "rt");
|
||||||
|
|
||||||
|
if (f)
|
||||||
{
|
{
|
||||||
if (strlen (linebuf))
|
while (fgets (linebuf, sizeof (linebuf), f) != NULL)
|
||||||
add_pwd_line (linebuf);
|
{
|
||||||
|
if (strlen (linebuf))
|
||||||
|
add_pwd_line (linebuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose (f);
|
||||||
|
passwd_state = loaded;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debug_printf ("Emulating /etc/passwd");
|
||||||
|
snprintf (linebuf, sizeof (linebuf), "%s::%u:%u::%s:/bin/sh", cygheap->user.name (),
|
||||||
|
DEFAULT_UID, DEFAULT_GID, getenv ("HOME") ?: "/");
|
||||||
|
add_pwd_line (linebuf);
|
||||||
|
passwd_state = emulated;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (f);
|
|
||||||
passwd_state = loaded;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
debug_printf ("Emulating /etc/passwd");
|
|
||||||
snprintf (linebuf, sizeof (linebuf), "%s::%u:%u::%s:/bin/sh", cygheap->user.name (),
|
|
||||||
DEFAULT_UID, DEFAULT_GID, getenv ("HOME") ?: "/");
|
|
||||||
add_pwd_line (linebuf);
|
|
||||||
passwd_state = emulated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock (&etc_passwd_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cygwin internal */
|
/* Cygwin internal */
|
||||||
|
/* If this ever becomes non-reentrant, update all the getpw*_r functions */
|
||||||
static struct passwd *
|
static struct passwd *
|
||||||
search_for (uid_t uid, const char *name)
|
search_for (uid_t uid, const char *name)
|
||||||
{
|
{
|
||||||
@ -182,25 +203,98 @@ search_for (uid_t uid, const char *name)
|
|||||||
extern "C" struct passwd *
|
extern "C" struct passwd *
|
||||||
getpwuid (uid_t uid)
|
getpwuid (uid_t uid)
|
||||||
{
|
{
|
||||||
if (passwd_state == uninitialized)
|
if (passwd_state <= initializing)
|
||||||
read_etc_passwd ();
|
read_etc_passwd ();
|
||||||
|
|
||||||
return search_for (uid, 0);
|
return search_for (uid, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" int
|
||||||
|
getpwuid_r (uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
|
||||||
|
{
|
||||||
|
*result = NULL;
|
||||||
|
|
||||||
|
if (!pwd || !buffer)
|
||||||
|
return ERANGE;
|
||||||
|
|
||||||
|
if (passwd_state <= initializing)
|
||||||
|
read_etc_passwd ();
|
||||||
|
|
||||||
|
struct passwd *temppw = search_for (uid, 0);
|
||||||
|
|
||||||
|
if (!temppw)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* check needed buffer size. */
|
||||||
|
size_t needsize = strlen (temppw->pw_name) + strlen (temppw->pw_dir) + strlen (temppw->pw_shell);
|
||||||
|
if (needsize > bufsize)
|
||||||
|
return ERANGE;
|
||||||
|
|
||||||
|
/* make a copy of temppw */
|
||||||
|
*result = pwd;
|
||||||
|
pwd->pw_uid = temppw->pw_uid;
|
||||||
|
pwd->pw_gid = temppw->pw_gid;
|
||||||
|
pwd->pw_name = buffer;
|
||||||
|
pwd->pw_dir = buffer + strlen (temppw->pw_name);
|
||||||
|
pwd->pw_shell = buffer + strlen (temppw->pw_name) + strlen (temppw->pw_dir);
|
||||||
|
strcpy (pwd->pw_name, temppw->pw_name);
|
||||||
|
strcpy (pwd->pw_dir, temppw->pw_dir);
|
||||||
|
strcpy (pwd->pw_shell, temppw->pw_shell);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" struct passwd *
|
extern "C" struct passwd *
|
||||||
getpwnam (const char *name)
|
getpwnam (const char *name)
|
||||||
{
|
{
|
||||||
if (passwd_state == uninitialized)
|
if (passwd_state <= initializing)
|
||||||
read_etc_passwd ();
|
read_etc_passwd ();
|
||||||
|
|
||||||
return search_for (0, name);
|
return search_for (0, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* the max size buffer we can expect to
|
||||||
|
* use is returned via sysconf with _SC_GETPW_R_SIZE_MAX.
|
||||||
|
* This may need updating! - Rob Collins April 2001.
|
||||||
|
*/
|
||||||
|
extern "C" int
|
||||||
|
getpwnam_r (const char *nam, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
|
||||||
|
{
|
||||||
|
*result = NULL;
|
||||||
|
|
||||||
|
if (!pwd || !buffer || !nam)
|
||||||
|
return ERANGE;
|
||||||
|
|
||||||
|
if (passwd_state <= initializing)
|
||||||
|
read_etc_passwd ();
|
||||||
|
|
||||||
|
struct passwd *temppw = search_for (0, nam);
|
||||||
|
|
||||||
|
if (!temppw)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* check needed buffer size. */
|
||||||
|
size_t needsize = strlen (temppw->pw_name) + strlen (temppw->pw_dir) + strlen (temppw->pw_shell);
|
||||||
|
if (needsize > bufsize)
|
||||||
|
return ERANGE;
|
||||||
|
|
||||||
|
/* make a copy of temppw */
|
||||||
|
*result = pwd;
|
||||||
|
pwd->pw_uid = temppw->pw_uid;
|
||||||
|
pwd->pw_gid = temppw->pw_gid;
|
||||||
|
pwd->pw_name = buffer;
|
||||||
|
pwd->pw_dir = buffer + strlen (temppw->pw_name);
|
||||||
|
pwd->pw_shell = buffer + strlen (temppw->pw_name) + strlen (temppw->pw_dir);
|
||||||
|
strcpy (pwd->pw_name, temppw->pw_name);
|
||||||
|
strcpy (pwd->pw_dir, temppw->pw_dir);
|
||||||
|
strcpy (pwd->pw_shell, temppw->pw_shell);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" struct passwd *
|
extern "C" struct passwd *
|
||||||
getpwent (void)
|
getpwent (void)
|
||||||
{
|
{
|
||||||
if (passwd_state == uninitialized)
|
if (passwd_state <= initializing)
|
||||||
read_etc_passwd ();
|
read_etc_passwd ();
|
||||||
|
|
||||||
if (pw_pos < curr_lines)
|
if (pw_pos < curr_lines)
|
||||||
@ -212,7 +306,7 @@ getpwent (void)
|
|||||||
extern "C" struct passwd *
|
extern "C" struct passwd *
|
||||||
getpwduid (uid_t)
|
getpwduid (uid_t)
|
||||||
{
|
{
|
||||||
if (passwd_state == uninitialized)
|
if (passwd_state <= initializing)
|
||||||
read_etc_passwd ();
|
read_etc_passwd ();
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -221,7 +315,7 @@ getpwduid (uid_t)
|
|||||||
extern "C" void
|
extern "C" void
|
||||||
setpwent (void)
|
setpwent (void)
|
||||||
{
|
{
|
||||||
if (passwd_state == uninitialized)
|
if (passwd_state <= initializing)
|
||||||
read_etc_passwd ();
|
read_etc_passwd ();
|
||||||
|
|
||||||
pw_pos = 0;
|
pw_pos = 0;
|
||||||
@ -230,7 +324,7 @@ setpwent (void)
|
|||||||
extern "C" void
|
extern "C" void
|
||||||
endpwent (void)
|
endpwent (void)
|
||||||
{
|
{
|
||||||
if (passwd_state == uninitialized)
|
if (passwd_state <= initializing)
|
||||||
read_etc_passwd ();
|
read_etc_passwd ();
|
||||||
|
|
||||||
pw_pos = 0;
|
pw_pos = 0;
|
||||||
@ -239,7 +333,7 @@ endpwent (void)
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
setpassent ()
|
setpassent ()
|
||||||
{
|
{
|
||||||
if (passwd_state == uninitialized)
|
if (passwd_state <= initializing)
|
||||||
read_etc_passwd ();
|
read_etc_passwd ();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -255,17 +349,17 @@ getpass (const char * prompt)
|
|||||||
#endif
|
#endif
|
||||||
struct termios ti, newti;
|
struct termios ti, newti;
|
||||||
|
|
||||||
if (passwd_state == uninitialized)
|
if (passwd_state <= initializing)
|
||||||
read_etc_passwd ();
|
read_etc_passwd ();
|
||||||
|
|
||||||
if (fdtab.not_open (0))
|
if (cygheap->fdtab.not_open (0))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
pass[0] = '\0';
|
pass[0] = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fhandler_base *fhstdin = fdtab[0];
|
fhandler_base *fhstdin = cygheap->fdtab[0];
|
||||||
fhstdin->tcgetattr (&ti);
|
fhstdin->tcgetattr (&ti);
|
||||||
newti = ti;
|
newti = ti;
|
||||||
newti.c_lflag &= ~ECHO;
|
newti.c_lflag &= ~ECHO;
|
||||||
|
@ -70,6 +70,7 @@ details. */
|
|||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
#include "registry.h"
|
#include "registry.h"
|
||||||
|
@ -15,6 +15,7 @@ details. */
|
|||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
|
||||||
@ -28,16 +29,16 @@ make_pipe (int fildes[2], unsigned int psize, int mode)
|
|||||||
SECURITY_ATTRIBUTES *sa = (mode & O_NOINHERIT) ? &sec_none_nih : &sec_none;
|
SECURITY_ATTRIBUTES *sa = (mode & O_NOINHERIT) ? &sec_none_nih : &sec_none;
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
|
||||||
if ((fdr = fdtab.find_unused_handle ()) < 0)
|
if ((fdr = cygheap->fdtab.find_unused_handle ()) < 0)
|
||||||
set_errno (ENMFILE);
|
set_errno (ENMFILE);
|
||||||
else if ((fdw = fdtab.find_unused_handle (fdr + 1)) < 0)
|
else if ((fdw = cygheap->fdtab.find_unused_handle (fdr + 1)) < 0)
|
||||||
set_errno (ENMFILE);
|
set_errno (ENMFILE);
|
||||||
else if (!CreatePipe (&r, &w, sa, psize))
|
else if (!CreatePipe (&r, &w, sa, psize))
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fhandler_base *fhr = fdtab.build_fhandler (fdr, FH_PIPER, "/dev/piper");
|
fhandler_base *fhr = cygheap->fdtab.build_fhandler (fdr, FH_PIPER, "/dev/piper");
|
||||||
fhandler_base *fhw = fdtab.build_fhandler (fdw, FH_PIPEW, "/dev/pipew");
|
fhandler_base *fhw = cygheap->fdtab.build_fhandler (fdw, FH_PIPEW, "/dev/pipew");
|
||||||
|
|
||||||
int binmode = mode & O_TEXT ? 0 : 1;
|
int binmode = mode & O_TEXT ? 0 : 1;
|
||||||
fhr->init (r, GENERIC_READ, binmode);
|
fhr->init (r, GENERIC_READ, binmode);
|
||||||
@ -72,7 +73,7 @@ _pipe (int filedes[2], unsigned int psize, int mode)
|
|||||||
int res = make_pipe (filedes, psize, mode);
|
int res = make_pipe (filedes, psize, mode);
|
||||||
/* This type of pipe is not interruptible so set the appropriate flag. */
|
/* This type of pipe is not interruptible so set the appropriate flag. */
|
||||||
if (!res)
|
if (!res)
|
||||||
fdtab[filedes[0]]->set_r_no_interrupt (1);
|
cygheap->fdtab[filedes[0]]->set_r_no_interrupt (1);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ dup (int fd)
|
|||||||
int res;
|
int res;
|
||||||
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," dup");
|
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," dup");
|
||||||
|
|
||||||
res = dup2 (fd, fdtab.find_unused_handle ());
|
res = dup2 (fd, cygheap->fdtab.find_unused_handle ());
|
||||||
|
|
||||||
ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," dup");
|
ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," dup");
|
||||||
|
|
||||||
@ -92,5 +93,5 @@ dup (int fd)
|
|||||||
int
|
int
|
||||||
dup2 (int oldfd, int newfd)
|
dup2 (int oldfd, int newfd)
|
||||||
{
|
{
|
||||||
return fdtab.dup2 (oldfd, newfd);
|
return cygheap->fdtab.dup2 (oldfd, newfd);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
|
|||||||
memset (except_fds, 0, fds_size);
|
memset (except_fds, 0, fds_size);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < nfds; ++i)
|
for (unsigned int i = 0; i < nfds; ++i)
|
||||||
if (!fdtab.not_open (fds[i].fd))
|
if (!cygheap->fdtab.not_open (fds[i].fd))
|
||||||
{
|
{
|
||||||
FD_SET (fds[i].fd, open_fds);
|
FD_SET (fds[i].fd, open_fds);
|
||||||
if (fds[i].events & POLLIN)
|
if (fds[i].events & POLLIN)
|
||||||
@ -67,7 +68,7 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
|
|||||||
{
|
{
|
||||||
if (!FD_ISSET (fds[i].fd, open_fds))
|
if (!FD_ISSET (fds[i].fd, open_fds))
|
||||||
fds[i].revents = POLLNVAL;
|
fds[i].revents = POLLNVAL;
|
||||||
else if (fdtab.not_open(fds[i].fd))
|
else if (cygheap->fdtab.not_open(fds[i].fd))
|
||||||
fds[i].revents = POLLHUP;
|
fds[i].revents = POLLHUP;
|
||||||
else if (ret < 0)
|
else if (ret < 0)
|
||||||
fds[i].revents = POLLERR;
|
fds[i].revents = POLLERR;
|
||||||
|
@ -185,7 +185,6 @@ get_world_sid ()
|
|||||||
return world_sid;
|
return world_sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
int passwd_sem = 0;
|
|
||||||
int group_sem = 0;
|
int group_sem = 0;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -207,10 +206,6 @@ get_id_from_sid (PSID psid, BOOL search_grp, int *type)
|
|||||||
|
|
||||||
if (!search_grp)
|
if (!search_grp)
|
||||||
{
|
{
|
||||||
if (passwd_sem > 0)
|
|
||||||
return 0;
|
|
||||||
++passwd_sem;
|
|
||||||
|
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
while ((pw = getpwent ()) != NULL)
|
while ((pw = getpwent ()) != NULL)
|
||||||
{
|
{
|
||||||
@ -221,7 +216,6 @@ get_id_from_sid (PSID psid, BOOL search_grp, int *type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
endpwent ();
|
endpwent ();
|
||||||
--passwd_sem;
|
|
||||||
if (id >= 0)
|
if (id >= 0)
|
||||||
{
|
{
|
||||||
if (type)
|
if (type)
|
||||||
@ -330,7 +324,7 @@ is_grp_member (uid_t uid, gid_t gid)
|
|||||||
extern int getgroups (int, gid_t *, gid_t, const char *);
|
extern int getgroups (int, gid_t *, gid_t, const char *);
|
||||||
BOOL grp_member = TRUE;
|
BOOL grp_member = TRUE;
|
||||||
|
|
||||||
if (!group_sem && !passwd_sem)
|
if (!group_sem)
|
||||||
{
|
{
|
||||||
struct passwd *pw = getpwuid (uid);
|
struct passwd *pw = getpwuid (uid);
|
||||||
gid_t grps[NGROUPS_MAX];
|
gid_t grps[NGROUPS_MAX];
|
||||||
@ -1745,13 +1739,13 @@ extern "C"
|
|||||||
int
|
int
|
||||||
facl (int fd, int cmd, int nentries, aclent_t *aclbufp)
|
facl (int fd, int cmd, int nentries, aclent_t *aclbufp)
|
||||||
{
|
{
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
syscall_printf ("-1 = facl (%d)", fd);
|
syscall_printf ("-1 = facl (%d)", fd);
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const char *path = fdtab[fd]->get_name ();
|
const char *path = cygheap->fdtab[fd]->get_name ();
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
{
|
{
|
||||||
syscall_printf ("-1 = facl (%d) (no name)", fd);
|
syscall_printf ("-1 = facl (%d) (no name)", fd);
|
||||||
|
@ -36,6 +36,7 @@ details. */
|
|||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "perthread.h"
|
#include "perthread.h"
|
||||||
@ -92,7 +93,7 @@ fhandler_##what::ready_for_read (int fd, DWORD howlong, int ignra) \
|
|||||||
me.fd = fd; \
|
me.fd = fd; \
|
||||||
(void) select_read (&me); \
|
(void) select_read (&me); \
|
||||||
while (!peek_##what (&me, ignra) && howlong == INFINITE) \
|
while (!peek_##what (&me, ignra) && howlong == INFINITE) \
|
||||||
if (fd >= 0 && fdtab.not_open (fd)) \
|
if (fd >= 0 && cygheap->fdtab.not_open (fd)) \
|
||||||
break; \
|
break; \
|
||||||
else if (WaitForSingleObject (signal_arrived, 10) == WAIT_OBJECT_0) \
|
else if (WaitForSingleObject (signal_arrived, 10) == WAIT_OBJECT_0) \
|
||||||
break; \
|
break; \
|
||||||
@ -101,7 +102,7 @@ fhandler_##what::ready_for_read (int fd, DWORD howlong, int ignra) \
|
|||||||
|
|
||||||
#define set_handle_or_return_if_not_open(h, s) \
|
#define set_handle_or_return_if_not_open(h, s) \
|
||||||
h = (s)->fh->get_handle (); \
|
h = (s)->fh->get_handle (); \
|
||||||
if (fdtab.not_open ((s)->fd)) \
|
if (cygheap->fdtab.not_open ((s)->fd)) \
|
||||||
{ \
|
{ \
|
||||||
(s)->saw_error = TRUE; \
|
(s)->saw_error = TRUE; \
|
||||||
set_errno (EBADF); \
|
set_errno (EBADF); \
|
||||||
@ -211,11 +212,11 @@ select_stuff::test_and_set (int i, fd_set *readfds, fd_set *writefds,
|
|||||||
fd_set *exceptfds)
|
fd_set *exceptfds)
|
||||||
{
|
{
|
||||||
select_record *s = NULL;
|
select_record *s = NULL;
|
||||||
if (UNIX_FD_ISSET (i, readfds) && (s = fdtab.select_read (i, s)) == NULL)
|
if (UNIX_FD_ISSET (i, readfds) && (s = cygheap->fdtab.select_read (i, s)) == NULL)
|
||||||
return 0; /* error */
|
return 0; /* error */
|
||||||
if (UNIX_FD_ISSET (i, writefds) && (s = fdtab.select_write (i, s)) == NULL)
|
if (UNIX_FD_ISSET (i, writefds) && (s = cygheap->fdtab.select_write (i, s)) == NULL)
|
||||||
return 0; /* error */
|
return 0; /* error */
|
||||||
if (UNIX_FD_ISSET (i, exceptfds) && (s = fdtab.select_except (i, s)) == NULL)
|
if (UNIX_FD_ISSET (i, exceptfds) && (s = cygheap->fdtab.select_except (i, s)) == NULL)
|
||||||
return 0; /* error */
|
return 0; /* error */
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return 1; /* nothing to do */
|
return 1; /* nothing to do */
|
||||||
|
@ -17,6 +17,8 @@ details. */
|
|||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
|
@ -21,6 +21,8 @@ details. */
|
|||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "child_info.h"
|
#include "child_info.h"
|
||||||
#include "perthread.h"
|
#include "perthread.h"
|
||||||
|
@ -151,7 +151,7 @@ out:
|
|||||||
static HANDLE
|
static HANDLE
|
||||||
handle (int n, int direction)
|
handle (int n, int direction)
|
||||||
{
|
{
|
||||||
fhandler_base *fh = fdtab[n];
|
fhandler_base *fh = cygheap->fdtab[n];
|
||||||
|
|
||||||
if (!fh)
|
if (!fh)
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
@ -340,8 +340,6 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
|
|||||||
|
|
||||||
ciresrv.moreinfo = (cygheap_exec_info *) ccalloc (HEAP_1_EXEC, 1, sizeof (cygheap_exec_info));
|
ciresrv.moreinfo = (cygheap_exec_info *) ccalloc (HEAP_1_EXEC, 1, sizeof (cygheap_exec_info));
|
||||||
ciresrv.moreinfo->old_title = NULL;
|
ciresrv.moreinfo->old_title = NULL;
|
||||||
ciresrv.moreinfo->fds = fdtab;
|
|
||||||
ciresrv.moreinfo->nfds = fdtab.size;
|
|
||||||
|
|
||||||
/* CreateProcess takes one long string that is the command line (sigh).
|
/* CreateProcess takes one long string that is the command line (sigh).
|
||||||
We need to quote any argument that has whitespace or embedded "'s. */
|
We need to quote any argument that has whitespace or embedded "'s. */
|
||||||
@ -563,7 +561,7 @@ skip_arg_parsing:
|
|||||||
parent after CreateProcess and before copying the datastructures
|
parent after CreateProcess and before copying the datastructures
|
||||||
to the child. So we have to start the child in suspend state,
|
to the child. So we have to start the child in suspend state,
|
||||||
unfortunately, to avoid a race condition. */
|
unfortunately, to avoid a race condition. */
|
||||||
if (fdtab.need_fixup_before ())
|
if (cygheap->fdtab.need_fixup_before ())
|
||||||
flags |= CREATE_SUSPENDED;
|
flags |= CREATE_SUSPENDED;
|
||||||
|
|
||||||
|
|
||||||
@ -690,9 +688,9 @@ skip_arg_parsing:
|
|||||||
|
|
||||||
/* Fixup the parent datastructure if needed and resume the child's
|
/* Fixup the parent datastructure if needed and resume the child's
|
||||||
main thread. */
|
main thread. */
|
||||||
if (fdtab.need_fixup_before ())
|
if (cygheap->fdtab.need_fixup_before ())
|
||||||
{
|
{
|
||||||
fdtab.fixup_before_exec (pi.dwProcessId);
|
cygheap->fdtab.fixup_before_exec (pi.dwProcessId);
|
||||||
if (mode == _P_OVERLAY)
|
if (mode == _P_OVERLAY)
|
||||||
ResumeThread (pi.hThread);
|
ResumeThread (pi.hThread);
|
||||||
}
|
}
|
||||||
|
@ -48,17 +48,17 @@ SYSTEM_INFO system_info;
|
|||||||
void __stdcall
|
void __stdcall
|
||||||
close_all_files (void)
|
close_all_files (void)
|
||||||
{
|
{
|
||||||
SetResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close");
|
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "close_all_files");
|
||||||
|
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
for (int i = 0; i < (int) fdtab.size; i++)
|
for (int i = 0; i < (int) cygheap->fdtab.size; i++)
|
||||||
if ((fh = fdtab[i]) != NULL)
|
if ((fh = cygheap->fdtab[i]) != NULL)
|
||||||
{
|
{
|
||||||
fh->close ();
|
fh->close ();
|
||||||
fdtab.release (i);
|
cygheap->fdtab.release (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close");
|
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "close_all_files");
|
||||||
cygwin_shared->delqueue.process_queue ();
|
cygwin_shared->delqueue.process_queue ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,14 +237,14 @@ _read (int fd, void *ptr, size_t len)
|
|||||||
{
|
{
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set_sig_errno (0);
|
// set_sig_errno (0);
|
||||||
fh = fdtab[fd];
|
fh = cygheap->fdtab[fd];
|
||||||
DWORD wait = (fh->get_flags () & (O_NONBLOCK | OLD_O_NDELAY)) ? 0 : INFINITE;
|
DWORD wait = (fh->get_flags () & (O_NONBLOCK | OLD_O_NDELAY)) ? 0 : INFINITE;
|
||||||
|
|
||||||
/* Could block, so let user know we at least got here. */
|
/* Could block, so let user know we at least got here. */
|
||||||
@ -289,7 +289,7 @@ _write (int fd, const void *ptr, size_t len)
|
|||||||
int res = -1;
|
int res = -1;
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
goto done;
|
goto done;
|
||||||
@ -302,9 +302,10 @@ _write (int fd, const void *ptr, size_t len)
|
|||||||
syscall_printf ("write (%d, %p, %d)", fd, ptr, len);
|
syscall_printf ("write (%d, %p, %d)", fd, ptr, len);
|
||||||
|
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
fh = fdtab[fd];
|
fh = cygheap->fdtab[fd];
|
||||||
|
|
||||||
res = fh->bg_check (SIGTTOU);
|
res = fh->bg_check (SIGTTOU);
|
||||||
|
syscall_printf ("write fh %p, name '%s' bg_check %d, bg_eof %d", fh, fh->get_name(), res, bg_eof);
|
||||||
if (res > bg_eof)
|
if (res > bg_eof)
|
||||||
{
|
{
|
||||||
myself->process_state |= PID_TTYOU;
|
myself->process_state |= PID_TTYOU;
|
||||||
@ -433,15 +434,15 @@ _open (const char *unix_path, int flags, ...)
|
|||||||
mode = va_arg (ap, mode_t);
|
mode = va_arg (ap, mode_t);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
fd = fdtab.find_unused_handle ();
|
fd = cygheap->fdtab.find_unused_handle ();
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
set_errno (ENMFILE);
|
set_errno (ENMFILE);
|
||||||
else if ((fh = fdtab.build_fhandler (fd, unix_path, NULL)) == NULL)
|
else if ((fh = cygheap->fdtab.build_fhandler (fd, unix_path, NULL)) == NULL)
|
||||||
res = -1; // errno already set
|
res = -1; // errno already set
|
||||||
else if (!fh->open (unix_path, flags, (mode & 0777) & ~cygheap->umask))
|
else if (!fh->open (unix_path, flags, (mode & 0777) & ~cygheap->umask))
|
||||||
{
|
{
|
||||||
fdtab.release (fd);
|
cygheap->fdtab.release (fd);
|
||||||
res = -1;
|
res = -1;
|
||||||
}
|
}
|
||||||
else if ((res = fd) <= 2)
|
else if ((res = fd) <= 2)
|
||||||
@ -464,14 +465,14 @@ _lseek (int fd, off_t pos, int dir)
|
|||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
res = -1;
|
res = -1;
|
||||||
}
|
}
|
||||||
else if (fdtab.not_open (fd))
|
else if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
res = -1;
|
res = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = fdtab[fd]->lseek (pos, dir);
|
res = cygheap->fdtab[fd]->lseek (pos, dir);
|
||||||
}
|
}
|
||||||
syscall_printf ("%d = lseek (%d, %d, %d)", res, fd, pos, dir);
|
syscall_printf ("%d = lseek (%d, %d, %d)", res, fd, pos, dir);
|
||||||
|
|
||||||
@ -487,7 +488,7 @@ _close (int fd)
|
|||||||
syscall_printf ("close (%d)", fd);
|
syscall_printf ("close (%d)", fd);
|
||||||
|
|
||||||
MALLOC_CHECK;
|
MALLOC_CHECK;
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
debug_printf ("handle %d not open", fd);
|
debug_printf ("handle %d not open", fd);
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
@ -496,8 +497,8 @@ _close (int fd)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close");
|
SetResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close");
|
||||||
res = fdtab[fd]->close ();
|
res = cygheap->fdtab[fd]->close ();
|
||||||
fdtab.release (fd);
|
cygheap->fdtab.release (fd);
|
||||||
ReleaseResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close");
|
ReleaseResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,13 +513,13 @@ isatty (int fd)
|
|||||||
int res;
|
int res;
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
syscall_printf ("0 = isatty (%d)", fd);
|
syscall_printf ("0 = isatty (%d)", fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = fdtab[fd]->is_tty ();
|
res = cygheap->fdtab[fd]->is_tty ();
|
||||||
syscall_printf ("%d = isatty (%d)", res, fd);
|
syscall_printf ("%d = isatty (%d)", res, fd);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -755,14 +756,14 @@ extern "C" int
|
|||||||
fchown (int fd, uid_t uid, gid_t gid)
|
fchown (int fd, uid_t uid, gid_t gid)
|
||||||
{
|
{
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
syscall_printf ("-1 = fchown (%d,...)", fd);
|
syscall_printf ("-1 = fchown (%d,...)", fd);
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *path = fdtab[fd]->get_name ();
|
const char *path = cygheap->fdtab[fd]->get_name ();
|
||||||
|
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
{
|
{
|
||||||
@ -867,14 +868,14 @@ extern "C" int
|
|||||||
fchmod (int fd, mode_t mode)
|
fchmod (int fd, mode_t mode)
|
||||||
{
|
{
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
syscall_printf ("-1 = fchmod (%d, 0%o)", fd, mode);
|
syscall_printf ("-1 = fchmod (%d, 0%o)", fd, mode);
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *path = fdtab[fd]->get_name ();
|
const char *path = cygheap->fdtab[fd]->get_name ();
|
||||||
|
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
{
|
{
|
||||||
@ -924,7 +925,7 @@ _fstat (int fd, struct stat *buf)
|
|||||||
int r;
|
int r;
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
syscall_printf ("-1 = fstat (%d, %p)", fd, buf);
|
syscall_printf ("-1 = fstat (%d, %p)", fd, buf);
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
@ -933,7 +934,7 @@ _fstat (int fd, struct stat *buf)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset (buf, 0, sizeof (struct stat));
|
memset (buf, 0, sizeof (struct stat));
|
||||||
r = fdtab[fd]->fstat (buf);
|
r = cygheap->fdtab[fd]->fstat (buf);
|
||||||
syscall_printf ("%d = fstat (%d, %x)", r, fd, buf);
|
syscall_printf ("%d = fstat (%d, %x)", r, fd, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -945,14 +946,14 @@ extern "C" int
|
|||||||
fsync (int fd)
|
fsync (int fd)
|
||||||
{
|
{
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
syscall_printf ("-1 = fsync (%d)", fd);
|
syscall_printf ("-1 = fsync (%d)", fd);
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE h = fdtab[fd]->get_handle ();
|
HANDLE h = cygheap->fdtab[fd]->get_handle ();
|
||||||
|
|
||||||
if (FlushFileBuffers (h) == 0)
|
if (FlushFileBuffers (h) == 0)
|
||||||
{
|
{
|
||||||
@ -1379,7 +1380,7 @@ system (const char *cmdstring)
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
setdtablesize (int size)
|
setdtablesize (int size)
|
||||||
{
|
{
|
||||||
if (size <= (int)fdtab.size || fdtab.extend (size - fdtab.size))
|
if (size <= (int)cygheap->fdtab.size || cygheap->fdtab.extend (size - cygheap->fdtab.size))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@ -1388,7 +1389,7 @@ setdtablesize (int size)
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
getdtablesize ()
|
getdtablesize ()
|
||||||
{
|
{
|
||||||
return fdtab.size;
|
return cygheap->fdtab.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" size_t
|
extern "C" size_t
|
||||||
@ -1468,11 +1469,11 @@ fpathconf (int fd, int v)
|
|||||||
}
|
}
|
||||||
case _PC_POSIX_PERMISSIONS:
|
case _PC_POSIX_PERMISSIONS:
|
||||||
case _PC_POSIX_SECURITY:
|
case _PC_POSIX_SECURITY:
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fhandler_base *fh = fdtab[fd];
|
fhandler_base *fh = cygheap->fdtab[fd];
|
||||||
if (fh->get_device () == FH_DISK)
|
if (fh->get_device () == FH_DISK)
|
||||||
return check_posix_perm (fh->get_win32_name (), v);
|
return check_posix_perm (fh->get_win32_name (), v);
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
@ -1530,11 +1531,11 @@ pathconf (const char *file, int v)
|
|||||||
extern "C" char *
|
extern "C" char *
|
||||||
ttyname (int fd)
|
ttyname (int fd)
|
||||||
{
|
{
|
||||||
if (fdtab.not_open (fd) || !fdtab[fd]->is_tty ())
|
if (cygheap->fdtab.not_open (fd) || !cygheap->fdtab[fd]->is_tty ())
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (char *) (fdtab[fd]->ttyname ());
|
return (char *) (cygheap->fdtab[fd]->ttyname ());
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" char *
|
extern "C" char *
|
||||||
@ -1561,13 +1562,13 @@ _cygwin_istext_for_stdio (int fd)
|
|||||||
return 0; /* we do it for old apps, due to getc/putc macros */
|
return 0; /* we do it for old apps, due to getc/putc macros */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
syscall_printf (" _cifs: fd not open\n");
|
syscall_printf (" _cifs: fd not open\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_base *p = fdtab[fd];
|
fhandler_base *p = cygheap->fdtab[fd];
|
||||||
|
|
||||||
if (p->get_device () != FH_DISK)
|
if (p->get_device () != FH_DISK)
|
||||||
{
|
{
|
||||||
@ -1609,13 +1610,13 @@ setmode_helper (FILE *f)
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
getmode (int fd)
|
getmode (int fd)
|
||||||
{
|
{
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fdtab[fd]->get_flags () & (O_BINARY | O_TEXT);
|
return cygheap->fdtab[fd]->get_flags () & (O_BINARY | O_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set a file descriptor into text or binary mode, returning the
|
/* Set a file descriptor into text or binary mode, returning the
|
||||||
@ -1624,7 +1625,7 @@ getmode (int fd)
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
setmode (int fd, int mode)
|
setmode (int fd, int mode)
|
||||||
{
|
{
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
return -1;
|
return -1;
|
||||||
@ -1635,7 +1636,7 @@ setmode (int fd, int mode)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_base *p = fdtab[fd];
|
fhandler_base *p = cygheap->fdtab[fd];
|
||||||
|
|
||||||
/* Note that we have no way to indicate the case that writes are
|
/* 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
|
binary but not reads, or vice-versa. These cases can arise when
|
||||||
@ -1680,21 +1681,21 @@ ftruncate (int fd, off_t length)
|
|||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HANDLE h = fdtab[fd]->get_handle ();
|
HANDLE h = cygheap->fdtab[fd]->get_handle ();
|
||||||
off_t prev_loc;
|
off_t prev_loc;
|
||||||
|
|
||||||
if (h)
|
if (h)
|
||||||
{
|
{
|
||||||
/* remember curr file pointer location */
|
/* remember curr file pointer location */
|
||||||
prev_loc = fdtab[fd]->lseek (0, SEEK_CUR);
|
prev_loc = cygheap->fdtab[fd]->lseek (0, SEEK_CUR);
|
||||||
|
|
||||||
fdtab[fd]->lseek (length, SEEK_SET);
|
cygheap->fdtab[fd]->lseek (length, SEEK_SET);
|
||||||
if (!SetEndOfFile (h))
|
if (!SetEndOfFile (h))
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
@ -1703,7 +1704,7 @@ ftruncate (int fd, off_t length)
|
|||||||
res = 0;
|
res = 0;
|
||||||
|
|
||||||
/* restore original file pointer location */
|
/* restore original file pointer location */
|
||||||
fdtab[fd]->lseek (prev_loc, 0);
|
cygheap->fdtab[fd]->lseek (prev_loc, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
syscall_printf ("%d = ftruncate (%d, %d)", res, fd, length);
|
syscall_printf ("%d = ftruncate (%d, %d)", res, fd, length);
|
||||||
@ -1741,13 +1742,13 @@ get_osfhandle (int fd)
|
|||||||
{
|
{
|
||||||
long res = -1;
|
long res = -1;
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = (long) fdtab[fd]->get_handle ();
|
res = (long) cygheap->fdtab[fd]->get_handle ();
|
||||||
}
|
}
|
||||||
syscall_printf ("%d = get_osfhandle (%d)", res, fd);
|
syscall_printf ("%d = get_osfhandle (%d)", res, fd);
|
||||||
|
|
||||||
@ -1799,12 +1800,12 @@ extern "C" int
|
|||||||
fstatfs (int fd, struct statfs *sfs)
|
fstatfs (int fd, struct statfs *sfs)
|
||||||
{
|
{
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fhandler_disk_file *f = (fhandler_disk_file *) fdtab[fd];
|
fhandler_disk_file *f = (fhandler_disk_file *) cygheap->fdtab[fd];
|
||||||
return statfs (f->get_name (), sfs);
|
return statfs (f->get_name (), sfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1885,12 +1886,12 @@ extern "C" char *
|
|||||||
ptsname (int fd)
|
ptsname (int fd)
|
||||||
{
|
{
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (char *) (fdtab[fd]->ptsname ());
|
return (char *) (cygheap->fdtab[fd]->ptsname ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: what is this? */
|
/* FIXME: what is this? */
|
||||||
|
@ -16,6 +16,7 @@ details. */
|
|||||||
#include <ntdef.h>
|
#include <ntdef.h>
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "ntdll.h"
|
#include "ntdll.h"
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ sysconf (int in)
|
|||||||
/* FIXME: this returns the current limit which can increase
|
/* FIXME: this returns the current limit which can increase
|
||||||
if and when dtable::find_unused_handle is called. Perhaps
|
if and when dtable::find_unused_handle is called. Perhaps
|
||||||
we should return NOFILE or OPEN_MAX instead? */
|
we should return NOFILE or OPEN_MAX instead? */
|
||||||
return fdtab.size;
|
return cygheap->fdtab.size;
|
||||||
case _SC_PAGESIZE:
|
case _SC_PAGESIZE:
|
||||||
return getpagesize ();
|
return getpagesize ();
|
||||||
case _SC_CLK_TCK:
|
case _SC_CLK_TCK:
|
||||||
|
@ -363,7 +363,7 @@ syslog (int priority, const char *message, ...)
|
|||||||
interleaved, we must lock the first byte of the file
|
interleaved, we must lock the first byte of the file
|
||||||
This works on Win32 even if we created the file above.
|
This works on Win32 even if we created the file above.
|
||||||
*/
|
*/
|
||||||
HANDLE fHandle = fdtab[fileno (fp)]->get_handle ();
|
HANDLE fHandle = cygheap->fdtab[fileno (fp)]->get_handle ();
|
||||||
if (LockFile (fHandle, 0, 0, 1, 0) == FALSE)
|
if (LockFile (fHandle, 0, 0, 1, 0) == FALSE)
|
||||||
{
|
{
|
||||||
debug_printf ("failed to lock file %s", get_win95_event_log_path());
|
debug_printf ("failed to lock file %s", get_win95_event_log_path());
|
||||||
|
@ -17,6 +17,7 @@ details. */
|
|||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include <cygwin/version.h>
|
#include <cygwin/version.h>
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include <sys/termios.h>
|
#include <sys/termios.h>
|
||||||
@ -27,14 +28,14 @@ tcsendbreak (int fd, int duration)
|
|||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
fh = fdtab[fd];
|
fh = cygheap->fdtab[fd];
|
||||||
|
|
||||||
if (!fh->is_tty ())
|
if (!fh->is_tty ())
|
||||||
set_errno (ENOTTY);
|
set_errno (ENOTTY);
|
||||||
@ -57,14 +58,14 @@ tcdrain (int fd)
|
|||||||
|
|
||||||
termios_printf ("tcdrain");
|
termios_printf ("tcdrain");
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
fh = fdtab[fd];
|
fh = cygheap->fdtab[fd];
|
||||||
|
|
||||||
if (!fh->is_tty ())
|
if (!fh->is_tty ())
|
||||||
set_errno (ENOTTY);
|
set_errno (ENOTTY);
|
||||||
@ -85,14 +86,14 @@ tcflush (int fd, int queue)
|
|||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
fh = fdtab[fd];
|
fh = cygheap->fdtab[fd];
|
||||||
|
|
||||||
if (!fh->is_tty ())
|
if (!fh->is_tty ())
|
||||||
set_errno (ENOTTY);
|
set_errno (ENOTTY);
|
||||||
@ -113,14 +114,14 @@ tcflow (int fd, int action)
|
|||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
fh = fdtab[fd];
|
fh = cygheap->fdtab[fd];
|
||||||
|
|
||||||
if (!fh->is_tty ())
|
if (!fh->is_tty ())
|
||||||
set_errno (ENOTTY);
|
set_errno (ENOTTY);
|
||||||
@ -142,14 +143,14 @@ tcsetattr (int fd, int a, const struct termios *t)
|
|||||||
int res = -1;
|
int res = -1;
|
||||||
|
|
||||||
t = __tonew_termios (t);
|
t = __tonew_termios (t);
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
fh = fdtab[fd];
|
fh = cygheap->fdtab[fd];
|
||||||
|
|
||||||
if (!fh->is_tty ())
|
if (!fh->is_tty ())
|
||||||
set_errno (ENOTTY);
|
set_errno (ENOTTY);
|
||||||
@ -174,13 +175,13 @@ tcgetattr (int fd, struct termios *in_t)
|
|||||||
int res = -1;
|
int res = -1;
|
||||||
struct termios *t = __makenew_termios (in_t);
|
struct termios *t = __makenew_termios (in_t);
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
else if (!fdtab[fd]->is_tty ())
|
else if (!cygheap->fdtab[fd]->is_tty ())
|
||||||
set_errno (ENOTTY);
|
set_errno (ENOTTY);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((res = fdtab[fd]->tcgetattr (t)) == 0)
|
if ((res = cygheap->fdtab[fd]->tcgetattr (t)) == 0)
|
||||||
(void) __toapp_termios (in_t, t);
|
(void) __toapp_termios (in_t, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,12 +201,12 @@ tcgetpgrp (int fd)
|
|||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
else if (!fdtab[fd]->is_tty ())
|
else if (!cygheap->fdtab[fd]->is_tty ())
|
||||||
set_errno (ENOTTY);
|
set_errno (ENOTTY);
|
||||||
else
|
else
|
||||||
res = fdtab[fd]->tcgetpgrp ();
|
res = cygheap->fdtab[fd]->tcgetpgrp ();
|
||||||
|
|
||||||
termios_printf ("%d = tcgetpgrp (%d)", res, fd);
|
termios_printf ("%d = tcgetpgrp (%d)", res, fd);
|
||||||
return res;
|
return res;
|
||||||
@ -217,12 +218,12 @@ tcsetpgrp (int fd, pid_t pgid)
|
|||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
set_errno (EBADF);
|
set_errno (EBADF);
|
||||||
else if (!fdtab[fd]->is_tty ())
|
else if (!cygheap->fdtab[fd]->is_tty ())
|
||||||
set_errno (ENOTTY);
|
set_errno (ENOTTY);
|
||||||
else
|
else
|
||||||
res = fdtab[fd]->tcsetpgrp (pgid);
|
res = cygheap->fdtab[fd]->tcsetpgrp (pgid);
|
||||||
|
|
||||||
termios_printf ("%d = tcsetpgrp (%d, %x)", res, fd, pgid);
|
termios_printf ("%d = tcsetpgrp (%d, %x)", res, fd, pgid);
|
||||||
return res;
|
return res;
|
||||||
|
@ -18,6 +18,7 @@ details. */
|
|||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
@ -68,7 +69,7 @@ tty_init (void)
|
|||||||
void __stdcall
|
void __stdcall
|
||||||
create_tty_master (int ttynum)
|
create_tty_master (int ttynum)
|
||||||
{
|
{
|
||||||
tty_master = (fhandler_tty_master *) fdtab.build_fhandler (-1, FH_TTYM,
|
tty_master = (fhandler_tty_master *) cygheap->fdtab.build_fhandler (-1, FH_TTYM,
|
||||||
"/dev/ttym", ttynum);
|
"/dev/ttym", ttynum);
|
||||||
if (tty_master->init (ttynum))
|
if (tty_master->init (ttynum))
|
||||||
api_fatal ("Can't create master tty");
|
api_fatal ("Can't create master tty");
|
||||||
|
@ -20,6 +20,8 @@ details. */
|
|||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
|
#include "fhandler.h"
|
||||||
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "registry.h"
|
#include "registry.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user