2000-02-18 03:38:33 +08:00
|
|
|
/* external.cc: Interface to Cygwin internals from external programs.
|
|
|
|
|
2013-01-21 12:38:31 +08:00
|
|
|
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
2014-02-19 03:39:48 +08:00
|
|
|
2008, 2009, 2010, 2011, 2012, 2014 Red Hat, Inc.
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
Written by Christopher Faylor <cgf@cygnus.com>
|
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
#include "winsup.h"
|
2000-08-22 13:10:20 +08:00
|
|
|
#include "sigproc.h"
|
2000-08-12 13:35:42 +08:00
|
|
|
#include "pinfo.h"
|
2000-09-08 00:23:51 +08:00
|
|
|
#include "shared_info.h"
|
2000-09-08 10:56:55 +08:00
|
|
|
#include "cygwin_version.h"
|
2001-10-25 05:56:54 +08:00
|
|
|
#include "cygerrno.h"
|
|
|
|
#include "path.h"
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
#include "fhandler.h"
|
2001-10-25 05:56:54 +08:00
|
|
|
#include "dtable.h"
|
|
|
|
#include "cygheap.h"
|
2002-01-29 10:02:03 +08:00
|
|
|
#include "heap.h"
|
2003-12-24 00:26:31 +08:00
|
|
|
#include "cygtls.h"
|
2005-05-09 09:19:38 +08:00
|
|
|
#include "child_info.h"
|
2006-02-03 03:55:45 +08:00
|
|
|
#include "environ.h"
|
2008-11-26 18:18:10 +08:00
|
|
|
#include "cygserver_setpwd.h"
|
2014-02-19 03:39:48 +08:00
|
|
|
#include "pwdgrp.h"
|
2005-11-29 06:32:29 +08:00
|
|
|
#include <unistd.h>
|
2006-02-03 03:55:45 +08:00
|
|
|
#include <stdlib.h>
|
2008-03-07 19:24:51 +08:00
|
|
|
#include <wchar.h>
|
2008-07-30 20:10:20 +08:00
|
|
|
#include <iptypes.h>
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2005-05-09 09:19:38 +08:00
|
|
|
child_info *get_cygwin_startup_info ();
|
2009-10-07 05:51:17 +08:00
|
|
|
static void exit_process (UINT, bool) __attribute__((noreturn));
|
2005-03-23 03:00:31 +08:00
|
|
|
|
2005-05-19 09:25:20 +08:00
|
|
|
static winpids pids;
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
static external_pinfo *
|
2000-07-30 00:24:59 +08:00
|
|
|
fillout_pinfo (pid_t pid, int winpid)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
BOOL nextpid;
|
|
|
|
static external_pinfo ep;
|
2008-02-16 17:37:58 +08:00
|
|
|
static char ep_progname_long_buf[NT_MAX_PATH];
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
if ((nextpid = !!(pid & CW_NEXTPID)))
|
|
|
|
pid ^= CW_NEXTPID;
|
2000-07-30 00:24:59 +08:00
|
|
|
|
|
|
|
|
2001-10-08 12:26:27 +08:00
|
|
|
static unsigned int i;
|
2000-09-13 10:35:05 +08:00
|
|
|
if (!pids.npids || !nextpid)
|
2001-10-08 12:26:27 +08:00
|
|
|
{
|
2002-11-29 15:05:26 +08:00
|
|
|
pids.set (winpid);
|
2001-10-08 12:26:27 +08:00
|
|
|
i = 0;
|
|
|
|
}
|
2000-07-30 00:24:59 +08:00
|
|
|
|
2000-08-26 09:36:20 +08:00
|
|
|
if (!pid)
|
|
|
|
i = 0;
|
|
|
|
|
2000-07-30 00:24:59 +08:00
|
|
|
memset (&ep, 0, sizeof ep);
|
2000-11-05 14:42:23 +08:00
|
|
|
while (i < pids.npids)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2000-11-05 14:42:23 +08:00
|
|
|
DWORD thispid = pids.winpid (i);
|
|
|
|
_pinfo *p = pids[i];
|
|
|
|
i++;
|
2000-07-30 00:24:59 +08:00
|
|
|
|
2000-08-26 09:36:20 +08:00
|
|
|
if (!p)
|
|
|
|
{
|
2000-11-05 14:42:23 +08:00
|
|
|
if (!nextpid && thispid != (DWORD) pid)
|
2000-08-26 09:36:20 +08:00
|
|
|
continue;
|
2001-05-12 05:01:44 +08:00
|
|
|
ep.pid = cygwin_pid (thispid);
|
|
|
|
ep.dwProcessId = thispid;
|
2000-08-26 09:36:20 +08:00
|
|
|
ep.process_state = PID_IN_USE;
|
|
|
|
ep.ctty = -1;
|
2001-03-18 10:49:29 +08:00
|
|
|
break;
|
2000-08-26 09:36:20 +08:00
|
|
|
}
|
2001-03-18 10:49:29 +08:00
|
|
|
else if (nextpid || p->pid == pid || (winpid && thispid == (DWORD) pid))
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2011-06-01 09:20:28 +08:00
|
|
|
ep.ctty = (p->ctty < 0 || iscons_dev (p->ctty)) ? p->ctty : device::minor (p->ctty);
|
2000-08-26 09:36:20 +08:00
|
|
|
ep.pid = p->pid;
|
|
|
|
ep.ppid = p->ppid;
|
|
|
|
ep.dwProcessId = p->dwProcessId;
|
|
|
|
ep.uid = p->uid;
|
|
|
|
ep.gid = p->gid;
|
|
|
|
ep.pgid = p->pgid;
|
|
|
|
ep.sid = p->sid;
|
2000-11-14 13:53:32 +08:00
|
|
|
ep.umask = 0;
|
2000-08-26 09:36:20 +08:00
|
|
|
ep.start_time = p->start_time;
|
|
|
|
ep.rusage_self = p->rusage_self;
|
|
|
|
ep.rusage_children = p->rusage_children;
|
2007-12-07 02:24:06 +08:00
|
|
|
ep.progname[0] = '\0';
|
2010-05-18 22:30:51 +08:00
|
|
|
sys_wcstombs(ep.progname, MAX_PATH, p->progname);
|
2000-08-26 09:36:20 +08:00
|
|
|
ep.strace_mask = 0;
|
2002-05-30 05:00:55 +08:00
|
|
|
ep.version = EXTERNAL_PINFO_VERSION;
|
2000-08-26 09:36:20 +08:00
|
|
|
|
|
|
|
ep.process_state = p->process_state;
|
2002-05-29 23:04:29 +08:00
|
|
|
|
|
|
|
ep.uid32 = p->uid;
|
|
|
|
ep.gid32 = p->gid;
|
2007-12-07 02:24:06 +08:00
|
|
|
|
2008-02-16 17:37:58 +08:00
|
|
|
ep.progname_long = ep_progname_long_buf;
|
2011-11-29 01:53:18 +08:00
|
|
|
mount_table->conv_to_posix_path (p->progname, ep.progname_long, 0);
|
2001-03-18 10:49:29 +08:00
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-07-30 00:24:59 +08:00
|
|
|
if (!ep.pid)
|
|
|
|
{
|
2000-08-26 09:36:20 +08:00
|
|
|
i = 0;
|
2000-07-30 00:24:59 +08:00
|
|
|
pids.reset ();
|
2012-07-03 03:48:33 +08:00
|
|
|
return NULL;
|
2000-07-30 00:24:59 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
return &ep;
|
|
|
|
}
|
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
static inline uintptr_t
|
2000-11-09 04:36:37 +08:00
|
|
|
get_cygdrive_info (char *user, char *system, char *user_flags,
|
2001-09-08 05:32:07 +08:00
|
|
|
char *system_flags)
|
2000-07-29 06:33:43 +08:00
|
|
|
{
|
2001-01-28 13:51:15 +08:00
|
|
|
int res = mount_table->get_cygdrive_info (user, system, user_flags,
|
|
|
|
system_flags);
|
2000-07-29 06:33:43 +08:00
|
|
|
return (res == ERROR_SUCCESS) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
static bool
|
2003-04-03 16:04:41 +08:00
|
|
|
check_ntsec (const char *filename)
|
|
|
|
{
|
2003-04-03 16:18:43 +08:00
|
|
|
if (!filename)
|
2008-07-15 04:22:03 +08:00
|
|
|
return true;
|
2003-04-03 16:04:41 +08:00
|
|
|
path_conv pc (filename);
|
2008-07-15 04:22:03 +08:00
|
|
|
return pc.has_acls ();
|
2003-04-03 16:04:41 +08:00
|
|
|
}
|
|
|
|
|
2006-02-03 03:55:45 +08:00
|
|
|
/* Copy cygwin environment variables to the Windows environment. */
|
2011-10-05 20:27:37 +08:00
|
|
|
static PWCHAR
|
|
|
|
create_winenv (const char * const *env)
|
2006-02-03 03:55:45 +08:00
|
|
|
{
|
2006-02-11 01:22:34 +08:00
|
|
|
int unused_envc;
|
2008-03-07 19:24:51 +08:00
|
|
|
PWCHAR envblock = NULL;
|
2011-10-05 20:27:37 +08:00
|
|
|
char **envp = build_env (env ?: cur_environ (), envblock, unused_envc, false);
|
2008-03-07 19:24:51 +08:00
|
|
|
PWCHAR p = envblock;
|
2006-02-03 03:55:45 +08:00
|
|
|
|
2006-02-11 01:22:34 +08:00
|
|
|
if (envp)
|
2006-02-03 03:55:45 +08:00
|
|
|
{
|
2006-02-11 01:22:34 +08:00
|
|
|
for (char **e = envp; *e; e++)
|
|
|
|
cfree (*e);
|
|
|
|
cfree (envp);
|
2006-02-03 03:55:45 +08:00
|
|
|
}
|
2011-10-05 20:27:37 +08:00
|
|
|
/* If we got an env block, just return pointer to win env. */
|
|
|
|
if (env)
|
|
|
|
return envblock;
|
|
|
|
/* Otherwise sync win env of current process with its posix env. */
|
2006-02-11 01:22:34 +08:00
|
|
|
if (!p)
|
2011-10-05 20:27:37 +08:00
|
|
|
return NULL;
|
2006-02-11 01:22:34 +08:00
|
|
|
while (*p)
|
|
|
|
{
|
2008-03-07 19:24:51 +08:00
|
|
|
PWCHAR eq = wcschr (p, L'=');
|
2006-02-11 01:22:34 +08:00
|
|
|
if (eq)
|
|
|
|
{
|
2008-03-07 19:24:51 +08:00
|
|
|
*eq = L'\0';
|
|
|
|
SetEnvironmentVariableW (p, ++eq);
|
2006-02-11 01:22:34 +08:00
|
|
|
p = eq;
|
|
|
|
}
|
2008-03-07 19:24:51 +08:00
|
|
|
p = wcschr (p, L'\0') + 1;
|
2006-02-11 01:22:34 +08:00
|
|
|
}
|
|
|
|
free (envblock);
|
2011-10-05 20:27:37 +08:00
|
|
|
return NULL;
|
2006-02-03 03:55:45 +08:00
|
|
|
}
|
|
|
|
|
2009-10-07 05:51:17 +08:00
|
|
|
/*
|
|
|
|
* Cygwin-specific wrapper for win32 ExitProcess and TerminateProcess.
|
|
|
|
* It ensures that the correct exit code, derived from the specified
|
|
|
|
* status value, will be made available to this process's parent (if
|
|
|
|
* that parent is also a cygwin process). If useTerminateProcess is
|
|
|
|
* true, then TerminateProcess(GetCurrentProcess(),...) will be used;
|
|
|
|
* otherwise, ExitProcess(...) is called.
|
|
|
|
*
|
|
|
|
* Used by startup code for cygwin processes which is linked statically
|
|
|
|
* into applications, and is not part of the cygwin DLL -- which is why
|
|
|
|
* this interface is exposed. "Normal" programs should use ANSI exit(),
|
|
|
|
* ANSI abort(), or POSIX _exit(), rather than this function -- because
|
|
|
|
* calling ExitProcess or TerminateProcess, even through this wrapper,
|
|
|
|
* skips much of the cygwin process cleanup code.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
exit_process (UINT status, bool useTerminateProcess)
|
|
|
|
{
|
|
|
|
pid_t pid = getpid ();
|
2012-07-03 03:48:33 +08:00
|
|
|
external_pinfo *ep = fillout_pinfo (pid, 1);
|
2009-10-07 05:51:17 +08:00
|
|
|
DWORD dwpid = ep ? ep->dwProcessId : pid;
|
|
|
|
pinfo p (pid, PID_MAP_RW);
|
2012-07-03 03:48:33 +08:00
|
|
|
if (ep)
|
|
|
|
pid = ep->pid;
|
|
|
|
if ((dwpid == GetCurrentProcessId()) && (p->pid == pid))
|
2009-10-07 05:51:17 +08:00
|
|
|
p.set_exit_code ((DWORD)status);
|
|
|
|
if (useTerminateProcess)
|
|
|
|
TerminateProcess (GetCurrentProcess(), status);
|
|
|
|
/* avoid 'else' clause to silence warning */
|
|
|
|
ExitProcess (status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
extern "C" uintptr_t
|
2000-02-18 03:38:33 +08:00
|
|
|
cygwin_internal (cygwin_getinfo_types t, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
2010-07-05 01:12:27 +08:00
|
|
|
uintptr_t res = (uintptr_t) -1;
|
2000-02-18 03:38:33 +08:00
|
|
|
va_start (arg, t);
|
|
|
|
|
|
|
|
switch (t)
|
|
|
|
{
|
|
|
|
case CW_LOCK_PINFO:
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 1;
|
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
case CW_UNLOCK_PINFO:
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 1;
|
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
case CW_GETTHREADNAME:
|
2013-04-23 17:44:36 +08:00
|
|
|
res = (uintptr_t) cygthread::name (va_arg (arg, DWORD));
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
case CW_SETTHREADNAME:
|
|
|
|
{
|
2002-08-02 00:20:31 +08:00
|
|
|
set_errno (ENOSYS);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 0;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
case CW_GETPINFO:
|
2013-04-23 17:44:36 +08:00
|
|
|
res = (uintptr_t) fillout_pinfo (va_arg (arg, DWORD), 0);
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
case CW_GETVERSIONINFO:
|
2013-04-23 17:44:36 +08:00
|
|
|
res = (uintptr_t) cygwin_version_strings;
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
case CW_READ_V1_MOUNT_TABLES:
|
2002-06-09 08:31:03 +08:00
|
|
|
set_errno (ENOSYS);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 1;
|
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2000-07-08 12:36:27 +08:00
|
|
|
case CW_USER_DATA:
|
2009-09-21 10:19:31 +08:00
|
|
|
/* This is a kludge to work around a version of _cygwin_common_crt0
|
|
|
|
which overwrote the cxx_malloc field with the local DLL copy.
|
|
|
|
Hilarity ensues if the DLL is not loaded like while the process
|
|
|
|
is forking. */
|
|
|
|
__cygwin_user_data.cxx_malloc = &default_cygwin_cxx_malloc;
|
2013-04-23 17:44:36 +08:00
|
|
|
res = (uintptr_t) &__cygwin_user_data;
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2000-07-08 12:36:27 +08:00
|
|
|
|
2000-07-09 13:29:51 +08:00
|
|
|
case CW_PERFILE:
|
|
|
|
perfile_table = va_arg (arg, struct __cygwin_perfile *);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 0;
|
|
|
|
break;
|
2000-07-09 13:29:51 +08:00
|
|
|
|
2000-07-29 06:33:43 +08:00
|
|
|
case CW_GET_CYGDRIVE_PREFIXES:
|
|
|
|
{
|
|
|
|
char *user = va_arg (arg, char *);
|
|
|
|
char *system = va_arg (arg, char *);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = get_cygdrive_info (user, system, NULL, NULL);
|
2000-07-29 06:33:43 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2000-07-29 06:33:43 +08:00
|
|
|
|
2000-07-30 00:24:59 +08:00
|
|
|
case CW_GETPINFO_FULL:
|
2013-04-23 17:44:36 +08:00
|
|
|
res = (uintptr_t) fillout_pinfo (va_arg (arg, pid_t), 1);
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2000-07-30 00:24:59 +08:00
|
|
|
|
2000-08-25 10:27:42 +08:00
|
|
|
case CW_INIT_EXCEPTIONS:
|
2005-12-03 12:23:35 +08:00
|
|
|
/* noop */ /* init_exceptions (va_arg (arg, exception_list *)); */
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 0;
|
|
|
|
break;
|
2000-08-25 10:27:42 +08:00
|
|
|
|
2000-11-09 04:36:37 +08:00
|
|
|
case CW_GET_CYGDRIVE_INFO:
|
|
|
|
{
|
|
|
|
char *user = va_arg (arg, char *);
|
|
|
|
char *system = va_arg (arg, char *);
|
|
|
|
char *user_flags = va_arg (arg, char *);
|
|
|
|
char *system_flags = va_arg (arg, char *);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = get_cygdrive_info (user, system, user_flags, system_flags);
|
2000-11-09 04:36:37 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2000-11-09 04:36:37 +08:00
|
|
|
|
2001-10-25 05:56:54 +08:00
|
|
|
case CW_SET_CYGWIN_REGISTRY_NAME:
|
|
|
|
case CW_GET_CYGWIN_REGISTRY_NAME:
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 0;
|
|
|
|
break;
|
2001-10-25 05:56:54 +08:00
|
|
|
|
2002-02-15 05:20:06 +08:00
|
|
|
case CW_STRACE_TOGGLE:
|
2002-01-29 10:02:03 +08:00
|
|
|
{
|
|
|
|
pid_t pid = va_arg (arg, pid_t);
|
|
|
|
pinfo p (pid);
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
sig_send (p, __SIGSTRACE);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 0;
|
2002-01-29 10:02:03 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
set_errno (ESRCH);
|
2013-04-23 17:44:36 +08:00
|
|
|
res = (uintptr_t) -1;
|
2002-01-29 10:02:03 +08:00
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2002-02-15 05:20:06 +08:00
|
|
|
|
2002-02-15 05:31:23 +08:00
|
|
|
case CW_STRACE_ACTIVE:
|
|
|
|
{
|
2009-10-14 12:17:05 +08:00
|
|
|
res = strace.active ();
|
2002-02-15 05:31:23 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2002-02-15 05:31:23 +08:00
|
|
|
|
2002-01-29 10:02:03 +08:00
|
|
|
case CW_CYGWIN_PID_TO_WINPID:
|
|
|
|
{
|
|
|
|
pinfo p (va_arg (arg, pid_t));
|
2009-10-14 12:17:05 +08:00
|
|
|
res = p ? p->dwProcessId : 0;
|
2002-01-29 10:02:03 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2002-06-04 01:56:10 +08:00
|
|
|
case CW_EXTRACT_DOMAIN_AND_USER:
|
2002-06-21 13:01:17 +08:00
|
|
|
{
|
2008-07-30 20:10:20 +08:00
|
|
|
WCHAR nt_domain[MAX_DOMAIN_NAME_LEN + 1];
|
|
|
|
WCHAR nt_user[UNLEN + 1];
|
|
|
|
|
2002-06-04 01:56:10 +08:00
|
|
|
struct passwd *pw = va_arg (arg, struct passwd *);
|
|
|
|
char *domain = va_arg (arg, char *);
|
|
|
|
char *user = va_arg (arg, char *);
|
2008-07-30 20:10:20 +08:00
|
|
|
extract_nt_dom_user (pw, nt_domain, nt_user);
|
|
|
|
if (domain)
|
|
|
|
sys_wcstombs (domain, MAX_DOMAIN_NAME_LEN + 1, nt_domain);
|
|
|
|
if (user)
|
|
|
|
sys_wcstombs (user, UNLEN + 1, nt_user);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 0;
|
2002-06-04 01:56:10 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2002-10-31 05:05:18 +08:00
|
|
|
case CW_CMDLINE:
|
|
|
|
{
|
2003-03-09 01:56:13 +08:00
|
|
|
size_t n;
|
2002-10-31 05:05:18 +08:00
|
|
|
pid_t pid = va_arg (arg, pid_t);
|
|
|
|
pinfo p (pid);
|
2013-04-23 17:44:36 +08:00
|
|
|
res = (uintptr_t) p->cmdline (n);
|
2002-10-31 05:05:18 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2003-04-03 16:04:41 +08:00
|
|
|
case CW_CHECK_NTSEC:
|
|
|
|
{
|
|
|
|
char *filename = va_arg (arg, char *);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = check_ntsec (filename);
|
2003-04-03 16:04:41 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2003-10-23 04:32:20 +08:00
|
|
|
case CW_GET_ERRNO_FROM_WINERROR:
|
2004-05-29 03:50:07 +08:00
|
|
|
{
|
2003-10-23 04:32:20 +08:00
|
|
|
int error = va_arg (arg, int);
|
|
|
|
int deferrno = va_arg (arg, int);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = geterrno_from_win_error (error, deferrno);
|
2003-10-23 04:32:20 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2003-11-04 23:48:19 +08:00
|
|
|
case CW_GET_POSIX_SECURITY_ATTRIBUTE:
|
|
|
|
{
|
2008-08-14 22:05:04 +08:00
|
|
|
path_conv dummy;
|
2003-11-26 21:23:27 +08:00
|
|
|
security_descriptor sd;
|
2003-11-04 23:48:19 +08:00
|
|
|
int attribute = va_arg (arg, int);
|
|
|
|
PSECURITY_ATTRIBUTES psa = va_arg (arg, PSECURITY_ATTRIBUTES);
|
|
|
|
void *sd_buf = va_arg (arg, void *);
|
|
|
|
DWORD sd_buf_size = va_arg (arg, DWORD);
|
2008-08-14 22:05:04 +08:00
|
|
|
set_security_attribute (dummy, attribute, psa, sd);
|
2006-10-22 22:57:43 +08:00
|
|
|
if (!psa->lpSecurityDescriptor)
|
2009-10-14 12:17:05 +08:00
|
|
|
res = sd.size ();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
psa->lpSecurityDescriptor = sd_buf;
|
|
|
|
res = sd.copy (sd_buf, sd_buf_size);
|
|
|
|
}
|
2004-05-29 03:50:07 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2003-11-06 22:33:16 +08:00
|
|
|
case CW_GET_SHMLBA:
|
2004-05-29 03:50:07 +08:00
|
|
|
{
|
2011-12-22 19:02:36 +08:00
|
|
|
res = wincap.allocation_granularity ();
|
2003-11-06 22:33:16 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2003-11-08 17:48:48 +08:00
|
|
|
case CW_GET_UID_FROM_SID:
|
2004-05-29 03:50:07 +08:00
|
|
|
{
|
2005-07-04 16:44:06 +08:00
|
|
|
cygpsid psid = va_arg (arg, PSID);
|
2014-02-27 20:57:27 +08:00
|
|
|
res = psid.get_uid (NULL);
|
2003-11-08 17:48:48 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2003-11-08 17:48:48 +08:00
|
|
|
case CW_GET_GID_FROM_SID:
|
2004-05-29 03:50:07 +08:00
|
|
|
{
|
2005-07-04 16:44:06 +08:00
|
|
|
cygpsid psid = va_arg (arg, PSID);
|
2014-02-27 20:57:27 +08:00
|
|
|
res = psid.get_gid (NULL);
|
2003-11-08 17:48:48 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2004-02-25 09:19:13 +08:00
|
|
|
case CW_GET_BINMODE:
|
|
|
|
{
|
|
|
|
const char *path = va_arg (arg, const char *);
|
2005-05-13 23:46:07 +08:00
|
|
|
path_conv p (path, PC_SYM_FOLLOW | PC_NULLEMPTY);
|
2004-02-25 09:19:13 +08:00
|
|
|
if (p.error)
|
|
|
|
{
|
|
|
|
set_errno (p.error);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = (unsigned long) -1;
|
2004-02-25 09:19:13 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
else
|
|
|
|
res = p.binmode ();
|
2004-02-25 09:19:13 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2005-03-23 03:00:31 +08:00
|
|
|
case CW_HOOK:
|
|
|
|
{
|
|
|
|
const char *name = va_arg (arg, const char *);
|
|
|
|
const void *hookfn = va_arg (arg, const void *);
|
2005-12-22 01:14:34 +08:00
|
|
|
WORD subsys;
|
2013-04-23 17:44:36 +08:00
|
|
|
res = (uintptr_t) hook_or_detect_cygwin (name, hookfn, subsys);
|
2005-03-23 03:00:31 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2005-05-09 09:19:38 +08:00
|
|
|
case CW_ARGV:
|
|
|
|
{
|
|
|
|
child_info_spawn *ci = (child_info_spawn *) get_cygwin_startup_info ();
|
2013-04-23 17:44:36 +08:00
|
|
|
res = (uintptr_t) (ci ? ci->moreinfo->argv : NULL);
|
2005-05-09 09:19:38 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2005-05-09 09:19:38 +08:00
|
|
|
case CW_ENVP:
|
|
|
|
{
|
|
|
|
child_info_spawn *ci = (child_info_spawn *) get_cygwin_startup_info ();
|
2013-04-23 17:44:36 +08:00
|
|
|
res = (uintptr_t) (ci ? ci->moreinfo->envp : NULL);
|
2005-05-09 09:19:38 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2005-05-17 09:21:06 +08:00
|
|
|
case CW_DEBUG_SELF:
|
|
|
|
error_start_init (va_arg (arg, const char *));
|
2013-04-23 17:44:36 +08:00
|
|
|
res = try_to_debug ();
|
2005-05-17 09:21:06 +08:00
|
|
|
break;
|
2006-02-11 01:22:34 +08:00
|
|
|
case CW_SYNC_WINENV:
|
2011-10-05 20:27:37 +08:00
|
|
|
create_winenv (NULL);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 0;
|
|
|
|
break;
|
2006-05-25 10:33:13 +08:00
|
|
|
case CW_CYGTLS_PADSIZE:
|
2009-10-14 12:17:05 +08:00
|
|
|
res = CYGTLS_PADSIZE;
|
|
|
|
break;
|
2007-03-30 21:36:06 +08:00
|
|
|
case CW_SET_DOS_FILE_WARNING:
|
|
|
|
{
|
|
|
|
dos_file_warning = va_arg (arg, int);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 0;
|
2007-03-30 21:36:06 +08:00
|
|
|
}
|
|
|
|
break;
|
2008-11-26 18:18:10 +08:00
|
|
|
case CW_SET_PRIV_KEY:
|
|
|
|
{
|
|
|
|
const char *passwd = va_arg (arg, const char *);
|
2011-04-04 17:04:00 +08:00
|
|
|
const char *username = va_arg (arg, const char *);
|
|
|
|
res = setlsapwd (passwd, username);
|
2008-11-26 18:18:10 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2009-01-09 13:18:02 +08:00
|
|
|
case CW_SETERRNO:
|
|
|
|
{
|
|
|
|
const char *file = va_arg (arg, const char *);
|
|
|
|
int line = va_arg (arg, int);
|
|
|
|
seterrno(file, line);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 0;
|
2009-01-09 13:18:02 +08:00
|
|
|
}
|
|
|
|
break;
|
2009-10-07 05:51:17 +08:00
|
|
|
case CW_EXIT_PROCESS:
|
|
|
|
{
|
|
|
|
UINT status = va_arg (arg, UINT);
|
|
|
|
int useTerminateProcess = va_arg (arg, int);
|
|
|
|
exit_process (status, !!useTerminateProcess); /* no return */
|
|
|
|
}
|
2009-10-13 18:23:31 +08:00
|
|
|
case CW_SET_EXTERNAL_TOKEN:
|
|
|
|
{
|
|
|
|
HANDLE token = va_arg (arg, HANDLE);
|
|
|
|
int type = va_arg (arg, int);
|
|
|
|
set_imp_token (token, type);
|
2009-10-14 12:17:05 +08:00
|
|
|
res = 0;
|
2009-10-13 18:23:31 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
break;
|
2009-10-31 21:24:06 +08:00
|
|
|
case CW_GET_INSTKEY:
|
|
|
|
{
|
|
|
|
PWCHAR dest = va_arg (arg, PWCHAR);
|
2012-02-14 19:27:43 +08:00
|
|
|
wcscpy (dest, cygheap->installation_key_buf);
|
2009-10-31 21:24:06 +08:00
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
break;
|
2010-02-08 17:52:40 +08:00
|
|
|
case CW_INT_SETLOCALE:
|
|
|
|
{
|
|
|
|
extern void internal_setlocale ();
|
|
|
|
internal_setlocale ();
|
|
|
|
res = 0;
|
|
|
|
}
|
2010-04-29 16:47:44 +08:00
|
|
|
break;
|
|
|
|
case CW_CVT_MNT_OPTS:
|
|
|
|
{
|
|
|
|
extern bool fstab_read_flags (char **, unsigned &, bool);
|
|
|
|
char **option_string = va_arg (arg, char **);
|
|
|
|
if (!option_string || !*option_string)
|
|
|
|
set_errno (EINVAL);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned *pflags = va_arg (arg, unsigned *);
|
2010-08-24 23:11:24 +08:00
|
|
|
unsigned flags = pflags ? *pflags : 0;
|
2010-04-29 16:47:44 +08:00
|
|
|
if (fstab_read_flags (option_string, flags, true))
|
|
|
|
{
|
|
|
|
if (pflags)
|
|
|
|
*pflags = flags;
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CW_LST_MNT_OPTS:
|
|
|
|
{
|
|
|
|
extern char *fstab_list_flags ();
|
|
|
|
char **option_string = va_arg (arg, char **);
|
|
|
|
if (!option_string)
|
|
|
|
set_errno (EINVAL);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*option_string = fstab_list_flags ();
|
|
|
|
if (*option_string)
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2010-07-05 01:12:27 +08:00
|
|
|
case CW_STRERROR:
|
|
|
|
{
|
|
|
|
int err = va_arg (arg, int);
|
|
|
|
res = (uintptr_t) strerror (err);
|
|
|
|
}
|
|
|
|
break;
|
2007-03-30 21:36:06 +08:00
|
|
|
|
2011-10-05 20:27:37 +08:00
|
|
|
case CW_CVT_ENV_TO_WINENV:
|
|
|
|
{
|
|
|
|
char **posix_env = va_arg (arg, char **);
|
|
|
|
res = (uintptr_t) create_winenv (posix_env);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-12-22 20:25:10 +08:00
|
|
|
case CW_ALLOC_DRIVE_MAP:
|
|
|
|
{
|
|
|
|
dos_drive_mappings *ddm = new dos_drive_mappings ();
|
|
|
|
res = (uintptr_t) ddm;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CW_MAP_DRIVE_MAP:
|
|
|
|
{
|
|
|
|
dos_drive_mappings *ddm = va_arg (arg, dos_drive_mappings *);
|
|
|
|
wchar_t *pathbuf = va_arg (arg, wchar_t *);
|
|
|
|
if (ddm && pathbuf)
|
|
|
|
res = (uintptr_t) ddm->fixup_if_match (pathbuf);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CW_FREE_DRIVE_MAP:
|
|
|
|
{
|
|
|
|
dos_drive_mappings *ddm = va_arg (arg, dos_drive_mappings *);
|
|
|
|
if (ddm)
|
|
|
|
delete ddm;
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-02-19 03:39:48 +08:00
|
|
|
case CW_SETENT:
|
|
|
|
{
|
|
|
|
int group = va_arg (arg, int);
|
|
|
|
int enums = va_arg (arg, int);
|
|
|
|
PCWSTR enum_tdoms = va_arg (arg, PCWSTR);
|
|
|
|
if (group)
|
|
|
|
res = (uintptr_t) setgrent_filtered (enums, enum_tdoms);
|
|
|
|
else
|
|
|
|
res = (uintptr_t) setpwent_filtered (enums, enum_tdoms);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CW_GETENT:
|
|
|
|
{
|
|
|
|
int group = va_arg (arg, int);
|
|
|
|
void *obj = va_arg (arg, void *);
|
|
|
|
if (obj)
|
|
|
|
{
|
|
|
|
if (group)
|
|
|
|
res = (uintptr_t) getgrent_filtered (obj);
|
|
|
|
else
|
|
|
|
res = (uintptr_t) getpwent_filtered (obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CW_ENDENT:
|
|
|
|
{
|
|
|
|
int group = va_arg (arg, int);
|
|
|
|
void *obj = va_arg (arg, void *);
|
|
|
|
if (obj)
|
|
|
|
{
|
|
|
|
if (group)
|
|
|
|
endgrent_filtered (obj);
|
|
|
|
else
|
|
|
|
endpwent_filtered (obj);
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-02-23 03:38:12 +08:00
|
|
|
case CW_GETNSSSEP:
|
|
|
|
res = (uintptr_t) cygheap->pg.nss_separator ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CW_GETPWSID:
|
|
|
|
{
|
|
|
|
int db_only = va_arg (arg, int);
|
|
|
|
PSID psid = va_arg (arg, PSID);
|
|
|
|
cygpsid sid (psid);
|
|
|
|
res = (uintptr_t) (db_only ? internal_getpwsid_from_db (sid)
|
|
|
|
: internal_getpwsid (sid));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CW_GETGRSID:
|
|
|
|
{
|
|
|
|
int db_only = va_arg (arg, int);
|
|
|
|
PSID psid = va_arg (arg, PSID);
|
|
|
|
cygpsid sid (psid);
|
|
|
|
res = (uintptr_t) (db_only ? internal_getgrsid_from_db (sid)
|
|
|
|
: internal_getgrsid (sid));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
default:
|
2009-10-14 12:17:05 +08:00
|
|
|
set_errno (ENOSYS);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2009-10-14 12:17:05 +08:00
|
|
|
va_end (arg);
|
|
|
|
return res;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|