2000-02-17 20:38:33 +01:00
|
|
|
/* external.cc: Interface to Cygwin internals from external programs.
|
|
|
|
|
* wininfo.h (wininfo::timer_active): Delete.
(wininfo::itv): Ditto.
(wininfo::start_time): Ditto.
(wininfo::window_started): Ditto.
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(wininfo::wininfo): Ditto.
(wininfo::lock): New method.
(wininfo::release): Ditto.
* window.cc: Use new lock/acquire wininfo methods throughout.
(wininfo::wininfo): Delete
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(getitimer): Ditto.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
(wininfo::lock): Define new function.
(wininfo::release): Ditto.
(wininfo::process): Delete WM_TIMER handling.
* timer.cc (struct timetracker): Delete it, flags. Add it_interval,
interval_us, sleepto_us, running, init_muto(), syncthread, and gettime().
(ttstart): Make NO_COPY.
(lock_timer_tracker): New class.
(timer_tracker::timer_tracker): Distinguish ttstart case.
(timer_tracker::~timer_tracker): New destructor. Clean out events, and reset
magic.
(timer_tracker::init_muto): New method.
(to_us): Round up as per POSIX.
(timer_thread): Reorganize to match timer_tracker::settime and
timer_tracker::gettime. Call sig_send without wait. Call auto_release.
(timer_tracker::settime): Reorganize logic to avoid race. Call gettime to
recover old value.
(timer_tracker::gettime): New method.
(timer_create): Properly set errno on invalid timerid. Use new
lock_timer_tracker method.
(timer_delete): Ditto. Simplify code slightly.
(timer_gettime): New function.
(fixup_timers_after_fork): Reinit ttstart.
(getitimer): New implementation.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
* cygwin.din: Export timer_gettime.
* winsup.h: Remove has has_visible_window_station declaration.
* Makefile.in (DLL_OFILES): Add lsearch.o.
* cygthread.h (cygthread::notify_detached): New element.
(cygthread::cygthread): Take optional fourth argument signifying event to
signal on thread completion.
* cygthread.cc (cygthread::stub): Signal notify_detached event, if it exists.
(cygthread::cygthread): Initialize notify_detached from fourth argument.
(cygthread::detach): Wait for notify_detached field is present.
* lsearch.cc: New file.
* search.h: Ditto.
* include/cygwin/version.h: Bump API minor number to 126.
* cygwin.din: Export lsearch, lfind.
2005-03-27 03:57:38 +02:00
|
|
|
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
|
2000-02-17 20:38:33 +01: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"
|
2001-07-26 21:22:24 +02:00
|
|
|
#include "security.h"
|
2000-08-22 07:10:20 +02:00
|
|
|
#include "sigproc.h"
|
2000-08-12 07:35:42 +02:00
|
|
|
#include "pinfo.h"
|
2000-08-25 04:27:42 +02:00
|
|
|
#include <exceptions.h>
|
2000-09-07 18:23:51 +02:00
|
|
|
#include "shared_info.h"
|
2000-09-08 04:56:55 +02:00
|
|
|
#include "cygwin_version.h"
|
|
|
|
#include "perprocess.h"
|
2001-10-24 23:56:54 +02: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 02:37:18 +02:00
|
|
|
#include "fhandler.h"
|
2001-10-24 23:56:54 +02:00
|
|
|
#include "dtable.h"
|
|
|
|
#include "cygheap.h"
|
2002-01-29 03:02:03 +01:00
|
|
|
#include "wincap.h"
|
|
|
|
#include "heap.h"
|
2003-11-08 10:48:48 +01:00
|
|
|
#include "pwdgrp.h"
|
2003-12-23 17:26:31 +01:00
|
|
|
#include "cygtls.h"
|
2005-05-09 03:19:38 +02:00
|
|
|
#include "child_info.h"
|
2005-11-28 23:32:29 +01:00
|
|
|
#include <unistd.h>
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2005-05-09 03:19:38 +02:00
|
|
|
child_info *get_cygwin_startup_info ();
|
2005-03-22 20:00:31 +01:00
|
|
|
|
2005-05-19 03:25:20 +02:00
|
|
|
static winpids pids;
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
static external_pinfo *
|
2000-07-29 18:24:59 +02:00
|
|
|
fillout_pinfo (pid_t pid, int winpid)
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
|
|
|
BOOL nextpid;
|
|
|
|
static external_pinfo ep;
|
|
|
|
|
|
|
|
if ((nextpid = !!(pid & CW_NEXTPID)))
|
|
|
|
pid ^= CW_NEXTPID;
|
2000-07-29 18:24:59 +02:00
|
|
|
|
|
|
|
|
2001-10-08 06:26:27 +02:00
|
|
|
static unsigned int i;
|
2000-09-13 04:35:05 +02:00
|
|
|
if (!pids.npids || !nextpid)
|
2001-10-08 06:26:27 +02:00
|
|
|
{
|
2002-11-29 08:05:26 +01:00
|
|
|
pids.set (winpid);
|
2001-10-08 06:26:27 +02:00
|
|
|
i = 0;
|
|
|
|
}
|
2000-07-29 18:24:59 +02:00
|
|
|
|
2000-08-26 03:36:20 +02:00
|
|
|
if (!pid)
|
|
|
|
i = 0;
|
|
|
|
|
2000-07-29 18:24:59 +02:00
|
|
|
memset (&ep, 0, sizeof ep);
|
2000-11-05 07:42:23 +01:00
|
|
|
while (i < pids.npids)
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
2000-11-05 07:42:23 +01:00
|
|
|
DWORD thispid = pids.winpid (i);
|
|
|
|
_pinfo *p = pids[i];
|
|
|
|
i++;
|
2000-07-29 18:24:59 +02:00
|
|
|
|
2000-08-26 03:36:20 +02:00
|
|
|
if (!p)
|
|
|
|
{
|
2000-11-05 07:42:23 +01:00
|
|
|
if (!nextpid && thispid != (DWORD) pid)
|
2000-08-26 03:36:20 +02:00
|
|
|
continue;
|
2001-05-11 23:01:44 +02:00
|
|
|
ep.pid = cygwin_pid (thispid);
|
|
|
|
ep.dwProcessId = thispid;
|
2000-08-26 03:36:20 +02:00
|
|
|
ep.process_state = PID_IN_USE;
|
|
|
|
ep.ctty = -1;
|
2001-03-18 03:49:29 +01:00
|
|
|
break;
|
2000-08-26 03:36:20 +02:00
|
|
|
}
|
2001-03-18 03:49:29 +01:00
|
|
|
else if (nextpid || p->pid == pid || (winpid && thispid == (DWORD) pid))
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
2001-04-29 01:48:28 +02:00
|
|
|
ep.ctty = p->ctty;
|
2000-08-26 03:36:20 +02: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 06:53:32 +01:00
|
|
|
ep.umask = 0;
|
2000-08-26 03:36:20 +02:00
|
|
|
ep.start_time = p->start_time;
|
|
|
|
ep.rusage_self = p->rusage_self;
|
|
|
|
ep.rusage_children = p->rusage_children;
|
|
|
|
strcpy (ep.progname, p->progname);
|
|
|
|
ep.strace_mask = 0;
|
2002-05-29 23:00:55 +02:00
|
|
|
ep.version = EXTERNAL_PINFO_VERSION;
|
2000-08-26 03:36:20 +02:00
|
|
|
|
|
|
|
ep.process_state = p->process_state;
|
2002-05-29 17:04:29 +02:00
|
|
|
|
|
|
|
ep.uid32 = p->uid;
|
|
|
|
ep.gid32 = p->gid;
|
2001-03-18 03:49:29 +01:00
|
|
|
break;
|
2000-02-17 20:38:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-07-29 18:24:59 +02:00
|
|
|
if (!ep.pid)
|
|
|
|
{
|
2000-08-26 03:36:20 +02:00
|
|
|
i = 0;
|
2000-07-29 18:24:59 +02:00
|
|
|
pids.reset ();
|
|
|
|
return 0;
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
return &ep;
|
|
|
|
}
|
|
|
|
|
2000-07-29 00:33:43 +02:00
|
|
|
static DWORD
|
2000-11-08 21:36:37 +01:00
|
|
|
get_cygdrive_info (char *user, char *system, char *user_flags,
|
2001-09-07 23:32:07 +02:00
|
|
|
char *system_flags)
|
2000-07-29 00:33:43 +02:00
|
|
|
{
|
2001-01-28 06:51:15 +01:00
|
|
|
int res = mount_table->get_cygdrive_info (user, system, user_flags,
|
|
|
|
system_flags);
|
2000-07-29 00:33:43 +02:00
|
|
|
return (res == ERROR_SUCCESS) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2000-11-08 21:36:37 +01:00
|
|
|
static DWORD
|
|
|
|
get_cygdrive_prefixes (char *user, char *system)
|
|
|
|
{
|
2003-11-15 00:40:06 +01:00
|
|
|
char user_flags[CYG_MAX_PATH];
|
|
|
|
char system_flags[CYG_MAX_PATH];
|
2000-11-08 21:36:37 +01:00
|
|
|
DWORD res = get_cygdrive_info (user, system, user_flags, system_flags);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2003-04-03 10:04:41 +02:00
|
|
|
static DWORD
|
|
|
|
check_ntsec (const char *filename)
|
|
|
|
{
|
2003-04-03 10:18:43 +02:00
|
|
|
if (!filename)
|
2004-10-06 03:33:39 +02:00
|
|
|
return allow_ntsec;
|
2003-04-03 10:04:41 +02:00
|
|
|
path_conv pc (filename);
|
2004-10-06 03:33:39 +02:00
|
|
|
return allow_ntsec && pc.has_acls ();
|
2003-04-03 10:04:41 +02:00
|
|
|
}
|
|
|
|
|
2003-03-28 15:21:40 +01:00
|
|
|
extern "C" unsigned long
|
2000-02-17 20:38:33 +01:00
|
|
|
cygwin_internal (cygwin_getinfo_types t, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
va_start (arg, t);
|
|
|
|
|
|
|
|
switch (t)
|
|
|
|
{
|
|
|
|
case CW_LOCK_PINFO:
|
2000-07-29 18:24:59 +02:00
|
|
|
return 1;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
case CW_UNLOCK_PINFO:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case CW_GETTHREADNAME:
|
2002-08-01 18:20:31 +02:00
|
|
|
return (DWORD) cygthread::name (va_arg (arg, DWORD));
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
case CW_SETTHREADNAME:
|
|
|
|
{
|
2002-08-01 18:20:31 +02:00
|
|
|
set_errno (ENOSYS);
|
|
|
|
return 0;
|
2000-02-17 20:38:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
case CW_GETPINFO:
|
2000-07-29 18:24:59 +02:00
|
|
|
return (DWORD) fillout_pinfo (va_arg (arg, DWORD), 0);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
case CW_GETVERSIONINFO:
|
|
|
|
return (DWORD) cygwin_version_strings;
|
|
|
|
|
|
|
|
case CW_READ_V1_MOUNT_TABLES:
|
2002-06-09 02:31:03 +02:00
|
|
|
set_errno (ENOSYS);
|
|
|
|
return 1;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2000-07-08 06:36:27 +02:00
|
|
|
case CW_USER_DATA:
|
|
|
|
return (DWORD) &__cygwin_user_data;
|
|
|
|
|
2000-07-09 07:29:51 +02:00
|
|
|
case CW_PERFILE:
|
|
|
|
perfile_table = va_arg (arg, struct __cygwin_perfile *);
|
|
|
|
return 0;
|
|
|
|
|
2000-07-29 00:33:43 +02:00
|
|
|
case CW_GET_CYGDRIVE_PREFIXES:
|
|
|
|
{
|
|
|
|
char *user = va_arg (arg, char *);
|
|
|
|
char *system = va_arg (arg, char *);
|
|
|
|
return get_cygdrive_prefixes (user, system);
|
|
|
|
}
|
|
|
|
|
2000-07-29 18:24:59 +02:00
|
|
|
case CW_GETPINFO_FULL:
|
|
|
|
return (DWORD) fillout_pinfo (va_arg (arg, pid_t), 1);
|
|
|
|
|
2000-08-25 04:27:42 +02:00
|
|
|
case CW_INIT_EXCEPTIONS:
|
2005-12-03 05:23:35 +01:00
|
|
|
/* noop */ /* init_exceptions (va_arg (arg, exception_list *)); */
|
2000-08-25 04:27:42 +02:00
|
|
|
return 0;
|
|
|
|
|
2000-11-08 21:36:37 +01: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 *);
|
|
|
|
return get_cygdrive_info (user, system, user_flags, system_flags);
|
|
|
|
}
|
|
|
|
|
2001-10-24 23:56:54 +02:00
|
|
|
case CW_SET_CYGWIN_REGISTRY_NAME:
|
|
|
|
case CW_GET_CYGWIN_REGISTRY_NAME:
|
2005-07-04 10:44:06 +02:00
|
|
|
return 0;
|
2001-10-24 23:56:54 +02:00
|
|
|
|
2002-02-14 22:20:06 +01:00
|
|
|
case CW_STRACE_TOGGLE:
|
2002-01-29 03:02:03 +01:00
|
|
|
{
|
|
|
|
pid_t pid = va_arg (arg, pid_t);
|
|
|
|
pinfo p (pid);
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
sig_send (p, __SIGSTRACE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
set_errno (ESRCH);
|
|
|
|
return (DWORD) -1;
|
|
|
|
}
|
|
|
|
}
|
2002-02-14 22:20:06 +01:00
|
|
|
|
2002-02-14 22:31:23 +01:00
|
|
|
case CW_STRACE_ACTIVE:
|
|
|
|
{
|
2005-12-29 21:46:34 +01:00
|
|
|
return strace.active ();
|
2002-02-14 22:31:23 +01:00
|
|
|
}
|
|
|
|
|
2002-01-29 03:02:03 +01:00
|
|
|
case CW_CYGWIN_PID_TO_WINPID:
|
|
|
|
{
|
|
|
|
pinfo p (va_arg (arg, pid_t));
|
|
|
|
return p ? p->dwProcessId : 0;
|
|
|
|
}
|
2002-06-03 19:56:10 +02:00
|
|
|
case CW_EXTRACT_DOMAIN_AND_USER:
|
2002-06-21 07:01:17 +02:00
|
|
|
{
|
2002-06-03 19:56:10 +02:00
|
|
|
struct passwd *pw = va_arg (arg, struct passwd *);
|
|
|
|
char *domain = va_arg (arg, char *);
|
|
|
|
char *user = va_arg (arg, char *);
|
|
|
|
extract_nt_dom_user (pw, domain, user);
|
|
|
|
return 0;
|
|
|
|
}
|
2002-10-30 22:05:18 +01:00
|
|
|
case CW_CMDLINE:
|
|
|
|
{
|
2003-03-08 18:56:13 +01:00
|
|
|
size_t n;
|
2002-10-30 22:05:18 +01:00
|
|
|
pid_t pid = va_arg (arg, pid_t);
|
|
|
|
pinfo p (pid);
|
|
|
|
return (DWORD) p->cmdline (n);
|
|
|
|
}
|
2003-04-03 10:04:41 +02:00
|
|
|
case CW_CHECK_NTSEC:
|
|
|
|
{
|
|
|
|
char *filename = va_arg (arg, char *);
|
|
|
|
return check_ntsec (filename);
|
|
|
|
}
|
2003-10-22 22:32:20 +02:00
|
|
|
case CW_GET_ERRNO_FROM_WINERROR:
|
2004-05-28 21:50:07 +02:00
|
|
|
{
|
2003-10-22 22:32:20 +02:00
|
|
|
int error = va_arg (arg, int);
|
|
|
|
int deferrno = va_arg (arg, int);
|
|
|
|
return geterrno_from_win_error (error, deferrno);
|
|
|
|
}
|
2003-11-04 16:48:19 +01:00
|
|
|
case CW_GET_POSIX_SECURITY_ATTRIBUTE:
|
|
|
|
{
|
2003-11-26 14:23:27 +01:00
|
|
|
security_descriptor sd;
|
2003-11-04 16:48:19 +01: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);
|
2003-11-26 14:23:27 +01:00
|
|
|
set_security_attribute (attribute, psa, sd);
|
|
|
|
if (!psa->lpSecurityDescriptor || sd.size () > sd_buf_size)
|
|
|
|
return sd.size ();
|
|
|
|
memcpy (sd_buf, sd, sd.size ());
|
|
|
|
psa->lpSecurityDescriptor = sd_buf;
|
|
|
|
return 0;
|
2004-05-28 21:50:07 +02:00
|
|
|
}
|
2003-11-06 15:33:16 +01:00
|
|
|
case CW_GET_SHMLBA:
|
2004-05-28 21:50:07 +02:00
|
|
|
{
|
2005-11-28 23:32:29 +01:00
|
|
|
return getpagesize ();
|
2003-11-06 15:33:16 +01:00
|
|
|
}
|
2003-11-08 10:48:48 +01:00
|
|
|
case CW_GET_UID_FROM_SID:
|
2004-05-28 21:50:07 +02:00
|
|
|
{
|
2005-07-04 10:44:06 +02:00
|
|
|
cygpsid psid = va_arg (arg, PSID);
|
|
|
|
return psid.get_id (false, NULL);
|
2003-11-08 10:48:48 +01:00
|
|
|
}
|
|
|
|
case CW_GET_GID_FROM_SID:
|
2004-05-28 21:50:07 +02:00
|
|
|
{
|
2005-07-04 10:44:06 +02:00
|
|
|
cygpsid psid = va_arg (arg, PSID);
|
|
|
|
return psid.get_id (true, NULL);
|
2003-11-08 10:48:48 +01:00
|
|
|
}
|
2004-02-25 02:19:13 +01:00
|
|
|
case CW_GET_BINMODE:
|
|
|
|
{
|
|
|
|
const char *path = va_arg (arg, const char *);
|
2005-05-13 17:46:07 +02:00
|
|
|
path_conv p (path, PC_SYM_FOLLOW | PC_NULLEMPTY);
|
2004-02-25 02:19:13 +01:00
|
|
|
if (p.error)
|
|
|
|
{
|
|
|
|
set_errno (p.error);
|
|
|
|
return (unsigned long) -1;
|
|
|
|
}
|
|
|
|
return p.binmode ();
|
|
|
|
}
|
2005-03-22 20:00:31 +01:00
|
|
|
case CW_HOOK:
|
|
|
|
{
|
|
|
|
const char *name = va_arg (arg, const char *);
|
|
|
|
const void *hookfn = va_arg (arg, const void *);
|
2005-12-21 18:14:34 +01:00
|
|
|
WORD subsys;
|
|
|
|
return (unsigned long) hook_or_detect_cygwin (name, hookfn, subsys);
|
2005-03-22 20:00:31 +01:00
|
|
|
}
|
2005-05-09 03:19:38 +02:00
|
|
|
case CW_ARGV:
|
|
|
|
{
|
|
|
|
child_info_spawn *ci = (child_info_spawn *) get_cygwin_startup_info ();
|
2005-05-17 03:21:06 +02:00
|
|
|
return (unsigned long) (ci ? ci->moreinfo->argv : NULL);
|
2005-05-09 03:19:38 +02:00
|
|
|
}
|
|
|
|
case CW_ENVP:
|
|
|
|
{
|
|
|
|
child_info_spawn *ci = (child_info_spawn *) get_cygwin_startup_info ();
|
2005-05-17 03:21:06 +02:00
|
|
|
return (unsigned long) (ci ? ci->moreinfo->envp : NULL);
|
2005-05-09 03:19:38 +02:00
|
|
|
}
|
2005-05-17 03:21:06 +02:00
|
|
|
case CW_DEBUG_SELF:
|
|
|
|
error_start_init (va_arg (arg, const char *));
|
|
|
|
try_to_debug ();
|
|
|
|
break;
|
2000-02-17 20:38:33 +01:00
|
|
|
default:
|
2005-08-12 04:39:13 +02:00
|
|
|
break;
|
2000-02-17 20:38:33 +01:00
|
|
|
}
|
2005-05-17 10:46:41 +02:00
|
|
|
return (unsigned long) -1;
|
2000-02-17 20:38:33 +01:00
|
|
|
}
|