2000-02-17 20:38:33 +01:00
|
|
|
|
/* net.cc: network-related routines.
|
|
|
|
|
|
2005-02-20 05:25:33 +01:00
|
|
|
|
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
|
|
|
|
2005 Red Hat, Inc.
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
|
|
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. */
|
|
|
|
|
|
|
|
|
|
/* #define DEBUG_NEST_ON 1 */
|
|
|
|
|
|
|
|
|
|
#define __INSIDE_CYGWIN_NET__
|
|
|
|
|
|
2000-08-02 18:28:18 +02:00
|
|
|
|
#include "winsup.h"
|
2003-02-21 15:29:18 +01:00
|
|
|
|
#include <ctype.h>
|
2000-02-17 20:38:33 +01:00
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
#include <sys/un.h>
|
2001-02-07 23:50:50 +01:00
|
|
|
|
#include <iphlpapi.h>
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2001-04-09 09:21:32 +02:00
|
|
|
|
#include <stdlib.h>
|
2003-01-11 02:29:18 +01:00
|
|
|
|
#define gethostname cygwin_gethostname
|
2000-07-29 18:24:59 +02:00
|
|
|
|
#include <unistd.h>
|
2003-01-11 02:29:18 +01:00
|
|
|
|
#undef gethostname
|
2000-02-17 20:38:33 +01:00
|
|
|
|
#include <netdb.h>
|
2001-03-20 20:50:28 +01:00
|
|
|
|
#define USE_SYS_TYPES_FD_SET
|
2000-10-26 12:13:41 +02:00
|
|
|
|
#include <winsock2.h>
|
2003-09-01 00:02:15 +02:00
|
|
|
|
#include <assert.h>
|
2000-08-22 07:10:20 +02:00
|
|
|
|
#include "cygerrno.h"
|
2001-07-26 21:22:24 +02:00
|
|
|
|
#include "security.h"
|
2000-08-22 07:10:20 +02:00
|
|
|
|
#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"
|
2000-08-12 07:35:42 +02:00
|
|
|
|
#include "dtable.h"
|
2001-04-18 23:10:15 +02:00
|
|
|
|
#include "cygheap.h"
|
2000-08-22 07:10:20 +02:00
|
|
|
|
#include "sigproc.h"
|
2000-08-12 07:35:42 +02:00
|
|
|
|
#include "pinfo.h"
|
2000-09-08 04:56:55 +02:00
|
|
|
|
#include "registry.h"
|
2003-12-23 17:26:31 +01:00
|
|
|
|
#include "cygtls.h"
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2002-11-10 14:43:26 +01:00
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
int h_errno;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2002-11-10 14:43:26 +01:00
|
|
|
|
int __stdcall rcmd (char **ahost, unsigned short inport, char *locuser,
|
|
|
|
|
char *remuser, char *cmd, SOCKET * fd2p);
|
|
|
|
|
int __stdcall rexec (char **ahost, unsigned short inport, char *locuser,
|
|
|
|
|
char *password, char *cmd, SOCKET * fd2p);
|
|
|
|
|
int __stdcall rresvport (int *);
|
|
|
|
|
int sscanf (const char *, const char *, ...);
|
|
|
|
|
} /* End of "C" section */
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2001-05-16 07:07:51 +02:00
|
|
|
|
WSADATA wsadata;
|
2000-10-26 12:13:41 +02:00
|
|
|
|
|
2001-11-24 04:11:39 +01:00
|
|
|
|
static fhandler_socket *
|
2002-08-08 19:03:20 +02:00
|
|
|
|
get (const int fd)
|
2001-11-24 04:11:39 +01:00
|
|
|
|
{
|
|
|
|
|
cygheap_fdget cfd (fd);
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2001-11-24 04:11:39 +01:00
|
|
|
|
if (cfd < 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2002-08-08 19:03:20 +02:00
|
|
|
|
fhandler_socket *const fh = cfd->is_socket ();
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2002-08-08 19:03:20 +02:00
|
|
|
|
if (!fh)
|
|
|
|
|
set_errno (ENOTSOCK);
|
|
|
|
|
|
|
|
|
|
return fh;
|
2001-11-24 04:11:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-10-06 21:11:14 +02:00
|
|
|
|
static SOCKET __stdcall
|
|
|
|
|
set_socket_inheritance (SOCKET sock)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2001-10-14 06:14:24 +02:00
|
|
|
|
SOCKET osock = sock;
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2001-10-14 06:14:24 +02:00
|
|
|
|
if (!DuplicateHandle (hMainProc, (HANDLE) sock, hMainProc, (HANDLE *) &sock,
|
2003-01-26 07:42:40 +01:00
|
|
|
|
0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
|
2001-10-14 06:14:24 +02:00
|
|
|
|
system_printf ("DuplicateHandle failed %E");
|
2000-10-06 21:11:14 +02:00
|
|
|
|
else
|
2001-10-14 06:14:24 +02:00
|
|
|
|
debug_printf ("DuplicateHandle succeeded osock %p, sock %p", osock, sock);
|
2004-01-24 00:05:33 +01:00
|
|
|
|
VerifyHandle ((HANDLE) sock);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
return sock;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* htonl: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" unsigned long int
|
2000-02-17 20:38:33 +01:00
|
|
|
|
htonl (unsigned long int x)
|
|
|
|
|
{
|
|
|
|
|
return ((((x & 0x000000ffU) << 24) |
|
2002-11-10 14:43:26 +01:00
|
|
|
|
((x & 0x0000ff00U) << 8) |
|
|
|
|
|
((x & 0x00ff0000U) >> 8) |
|
2000-02-17 20:38:33 +01:00
|
|
|
|
((x & 0xff000000U) >> 24)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ntohl: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" unsigned long int
|
2000-02-17 20:38:33 +01:00
|
|
|
|
ntohl (unsigned long int x)
|
|
|
|
|
{
|
|
|
|
|
return htonl (x);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* htons: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" unsigned short
|
2000-02-17 20:38:33 +01:00
|
|
|
|
htons (unsigned short x)
|
|
|
|
|
{
|
|
|
|
|
return ((((x & 0x000000ffU) << 8) |
|
2003-01-26 07:42:40 +01:00
|
|
|
|
((x & 0x0000ff00U) >> 8)));
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ntohs: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" unsigned short
|
2000-02-17 20:38:33 +01:00
|
|
|
|
ntohs (unsigned short x)
|
|
|
|
|
{
|
|
|
|
|
return htons (x);
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-25 11:23:55 +01:00
|
|
|
|
/* exported as inet_ntoa: BSD 4.3 */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" char *
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_inet_ntoa (struct in_addr in)
|
|
|
|
|
{
|
|
|
|
|
char *res = inet_ntoa (in);
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2003-12-23 17:26:31 +01:00
|
|
|
|
if (_my_tls.locals.ntoa_buf)
|
2001-08-22 17:31:59 +02:00
|
|
|
|
{
|
2003-12-23 17:26:31 +01:00
|
|
|
|
free (_my_tls.locals.ntoa_buf);
|
|
|
|
|
_my_tls.locals.ntoa_buf = NULL;
|
2001-08-22 17:31:59 +02:00
|
|
|
|
}
|
|
|
|
|
if (res)
|
2003-12-23 17:26:31 +01:00
|
|
|
|
_my_tls.locals.ntoa_buf = strdup (res);
|
|
|
|
|
return _my_tls.locals.ntoa_buf;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-11-25 11:23:55 +01:00
|
|
|
|
/* exported as inet_addr: BSD 4.3 */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" unsigned long
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_inet_addr (const char *cp)
|
|
|
|
|
{
|
2001-11-24 22:10:00 +01:00
|
|
|
|
if (check_null_str_errno (cp))
|
|
|
|
|
return INADDR_NONE;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
unsigned long res = inet_addr (cp);
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-25 11:23:55 +01:00
|
|
|
|
/* exported as inet_aton: BSD 4.3
|
|
|
|
|
inet_aton is not exported by wsock32 and ws2_32,
|
|
|
|
|
so it has to be implemented here. */
|
|
|
|
|
extern "C" int
|
|
|
|
|
cygwin_inet_aton (const char *cp, struct in_addr *inp)
|
|
|
|
|
{
|
2001-11-24 04:11:39 +01:00
|
|
|
|
if (check_null_str_errno (cp) || check_null_invalid_struct_errno (inp))
|
|
|
|
|
return 0;
|
|
|
|
|
|
2000-11-25 11:23:55 +01:00
|
|
|
|
unsigned long res = inet_addr (cp);
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2000-11-25 11:23:55 +01:00
|
|
|
|
if (res == INADDR_NONE && strcmp (cp, "255.255.255.255"))
|
2000-11-29 18:15:00 +01:00
|
|
|
|
return 0;
|
2000-11-25 11:23:55 +01:00
|
|
|
|
if (inp)
|
|
|
|
|
inp->s_addr = res;
|
2000-11-29 18:15:00 +01:00
|
|
|
|
return 1;
|
2000-11-25 11:23:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-24 17:44:11 +02:00
|
|
|
|
/* undocumented in wsock32.dll */
|
2002-11-10 14:43:26 +01:00
|
|
|
|
extern "C" unsigned int WINAPI inet_network (const char *);
|
2000-04-24 17:44:11 +02:00
|
|
|
|
|
2000-10-28 07:41:44 +02:00
|
|
|
|
extern "C" unsigned int
|
2000-04-24 17:44:11 +02:00
|
|
|
|
cygwin_inet_network (const char *cp)
|
|
|
|
|
{
|
2001-11-24 04:11:39 +01:00
|
|
|
|
if (check_null_str_errno (cp))
|
2001-11-24 22:10:00 +01:00
|
|
|
|
return INADDR_NONE;
|
2000-04-24 17:44:11 +02:00
|
|
|
|
unsigned int res = inet_network (cp);
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2000-04-24 17:44:11 +02:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
/* inet_netof is in the standard BSD sockets library. It is useless
|
|
|
|
|
for modern networks, since it assumes network values which are no
|
|
|
|
|
longer meaningful, but some existing code calls it. */
|
|
|
|
|
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" unsigned long
|
2000-02-17 20:38:33 +01:00
|
|
|
|
inet_netof (struct in_addr in)
|
|
|
|
|
{
|
|
|
|
|
unsigned long i, res;
|
|
|
|
|
|
|
|
|
|
i = ntohl (in.s_addr);
|
|
|
|
|
if (IN_CLASSA (i))
|
|
|
|
|
res = (i & IN_CLASSA_NET) >> IN_CLASSA_NSHIFT;
|
|
|
|
|
else if (IN_CLASSB (i))
|
|
|
|
|
res = (i & IN_CLASSB_NET) >> IN_CLASSB_NSHIFT;
|
|
|
|
|
else
|
|
|
|
|
res = (i & IN_CLASSC_NET) >> IN_CLASSC_NSHIFT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* inet_makeaddr is in the standard BSD sockets library. It is
|
|
|
|
|
useless for modern networks, since it assumes network values which
|
|
|
|
|
are no longer meaningful, but some existing code calls it. */
|
|
|
|
|
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" struct in_addr
|
2000-02-17 20:38:33 +01:00
|
|
|
|
inet_makeaddr (int net, int lna)
|
|
|
|
|
{
|
|
|
|
|
unsigned long i;
|
2001-11-24 18:31:15 +01:00
|
|
|
|
struct in_addr in;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
|
|
if (net < IN_CLASSA_MAX)
|
|
|
|
|
i = (net << IN_CLASSA_NSHIFT) | (lna & IN_CLASSA_HOST);
|
|
|
|
|
else if (net < IN_CLASSB_MAX)
|
|
|
|
|
i = (net << IN_CLASSB_NSHIFT) | (lna & IN_CLASSB_HOST);
|
|
|
|
|
else if (net < 0x1000000)
|
|
|
|
|
i = (net << IN_CLASSC_NSHIFT) | (lna & IN_CLASSC_HOST);
|
|
|
|
|
else
|
|
|
|
|
i = net | lna;
|
|
|
|
|
|
|
|
|
|
in.s_addr = htonl (i);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct tl
|
|
|
|
|
{
|
|
|
|
|
int w;
|
|
|
|
|
const char *s;
|
|
|
|
|
int e;
|
|
|
|
|
};
|
|
|
|
|
|
2002-11-10 14:43:26 +01:00
|
|
|
|
static NO_COPY struct tl errmap[] = {
|
|
|
|
|
{WSAEINTR, "WSAEINTR", EINTR},
|
|
|
|
|
{WSAEWOULDBLOCK, "WSAEWOULDBLOCK", EWOULDBLOCK},
|
|
|
|
|
{WSAEINPROGRESS, "WSAEINPROGRESS", EINPROGRESS},
|
|
|
|
|
{WSAEALREADY, "WSAEALREADY", EALREADY},
|
|
|
|
|
{WSAENOTSOCK, "WSAENOTSOCK", ENOTSOCK},
|
|
|
|
|
{WSAEDESTADDRREQ, "WSAEDESTADDRREQ", EDESTADDRREQ},
|
|
|
|
|
{WSAEMSGSIZE, "WSAEMSGSIZE", EMSGSIZE},
|
|
|
|
|
{WSAEPROTOTYPE, "WSAEPROTOTYPE", EPROTOTYPE},
|
|
|
|
|
{WSAENOPROTOOPT, "WSAENOPROTOOPT", ENOPROTOOPT},
|
|
|
|
|
{WSAEPROTONOSUPPORT, "WSAEPROTONOSUPPORT", EPROTONOSUPPORT},
|
|
|
|
|
{WSAESOCKTNOSUPPORT, "WSAESOCKTNOSUPPORT", ESOCKTNOSUPPORT},
|
|
|
|
|
{WSAEOPNOTSUPP, "WSAEOPNOTSUPP", EOPNOTSUPP},
|
|
|
|
|
{WSAEPFNOSUPPORT, "WSAEPFNOSUPPORT", EPFNOSUPPORT},
|
|
|
|
|
{WSAEAFNOSUPPORT, "WSAEAFNOSUPPORT", EAFNOSUPPORT},
|
|
|
|
|
{WSAEADDRINUSE, "WSAEADDRINUSE", EADDRINUSE},
|
|
|
|
|
{WSAEADDRNOTAVAIL, "WSAEADDRNOTAVAIL", EADDRNOTAVAIL},
|
|
|
|
|
{WSAENETDOWN, "WSAENETDOWN", ENETDOWN},
|
|
|
|
|
{WSAENETUNREACH, "WSAENETUNREACH", ENETUNREACH},
|
|
|
|
|
{WSAENETRESET, "WSAENETRESET", ENETRESET},
|
|
|
|
|
{WSAECONNABORTED, "WSAECONNABORTED", ECONNABORTED},
|
|
|
|
|
{WSAECONNRESET, "WSAECONNRESET", ECONNRESET},
|
|
|
|
|
{WSAENOBUFS, "WSAENOBUFS", ENOBUFS},
|
|
|
|
|
{WSAEISCONN, "WSAEISCONN", EISCONN},
|
|
|
|
|
{WSAENOTCONN, "WSAENOTCONN", ENOTCONN},
|
|
|
|
|
{WSAESHUTDOWN, "WSAESHUTDOWN", ESHUTDOWN},
|
|
|
|
|
{WSAETOOMANYREFS, "WSAETOOMANYREFS", ETOOMANYREFS},
|
|
|
|
|
{WSAETIMEDOUT, "WSAETIMEDOUT", ETIMEDOUT},
|
|
|
|
|
{WSAECONNREFUSED, "WSAECONNREFUSED", ECONNREFUSED},
|
|
|
|
|
{WSAELOOP, "WSAELOOP", ELOOP},
|
|
|
|
|
{WSAENAMETOOLONG, "WSAENAMETOOLONG", ENAMETOOLONG},
|
|
|
|
|
{WSAEHOSTDOWN, "WSAEHOSTDOWN", EHOSTDOWN},
|
|
|
|
|
{WSAEHOSTUNREACH, "WSAEHOSTUNREACH", EHOSTUNREACH},
|
|
|
|
|
{WSAENOTEMPTY, "WSAENOTEMPTY", ENOTEMPTY},
|
|
|
|
|
{WSAEPROCLIM, "WSAEPROCLIM", EPROCLIM},
|
|
|
|
|
{WSAEUSERS, "WSAEUSERS", EUSERS},
|
|
|
|
|
{WSAEDQUOT, "WSAEDQUOT", EDQUOT},
|
|
|
|
|
{WSAESTALE, "WSAESTALE", ESTALE},
|
|
|
|
|
{WSAEREMOTE, "WSAEREMOTE", EREMOTE},
|
|
|
|
|
{WSAEINVAL, "WSAEINVAL", EINVAL},
|
|
|
|
|
{WSAEFAULT, "WSAEFAULT", EFAULT},
|
|
|
|
|
{0, "NOERROR", 0},
|
|
|
|
|
{0, NULL, 0}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
};
|
|
|
|
|
|
2001-04-03 04:53:25 +02:00
|
|
|
|
static int
|
|
|
|
|
find_winsock_errno (int why)
|
|
|
|
|
{
|
2001-04-23 18:46:30 +02:00
|
|
|
|
for (int i = 0; errmap[i].s != NULL; ++i)
|
2001-04-03 04:53:25 +02:00
|
|
|
|
if (why == errmap[i].w)
|
|
|
|
|
return errmap[i].e;
|
|
|
|
|
|
|
|
|
|
return EPERM;
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
void
|
2000-10-06 21:11:14 +02:00
|
|
|
|
__set_winsock_errno (const char *fn, int ln)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2001-04-03 04:53:25 +02:00
|
|
|
|
DWORD werr = WSAGetLastError ();
|
|
|
|
|
int err = find_winsock_errno (werr);
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2001-04-03 04:53:25 +02:00
|
|
|
|
set_errno (err);
|
|
|
|
|
syscall_printf ("%s:%d - winsock error %d -> errno %d", fn, ln, werr, err);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-10-14 10:55:44 +02:00
|
|
|
|
/*
|
|
|
|
|
* Since the member `s' isn't used for debug output we can use it
|
|
|
|
|
* for the error text returned by herror and hstrerror.
|
|
|
|
|
*/
|
2002-11-10 14:43:26 +01:00
|
|
|
|
static NO_COPY struct tl host_errmap[] = {
|
2000-10-14 10:55:44 +02:00
|
|
|
|
{WSAHOST_NOT_FOUND, "Unknown host", HOST_NOT_FOUND},
|
|
|
|
|
{WSATRY_AGAIN, "Host name lookup failure", TRY_AGAIN},
|
|
|
|
|
{WSANO_RECOVERY, "Unknown server error", NO_RECOVERY},
|
|
|
|
|
{WSANO_DATA, "No address associated with name", NO_DATA},
|
2000-02-23 05:07:13 +01:00
|
|
|
|
{0, NULL, 0}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_host_errno ()
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
int why = WSAGetLastError ();
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2000-10-14 10:55:44 +02:00
|
|
|
|
for (i = 0; host_errmap[i].w != 0; ++i)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
if (why == host_errmap[i].w)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (host_errmap[i].w != 0)
|
|
|
|
|
h_errno = host_errmap[i].e;
|
|
|
|
|
else
|
|
|
|
|
h_errno = NETDB_INTERNAL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-01 00:02:15 +02:00
|
|
|
|
inline int
|
|
|
|
|
DWORD_round (int n)
|
2001-08-22 17:31:59 +02:00
|
|
|
|
{
|
2003-09-01 00:02:15 +02:00
|
|
|
|
return sizeof (DWORD) * (((n + sizeof (DWORD) - 1)) / sizeof (DWORD));
|
2001-08-22 17:31:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-01 00:02:15 +02:00
|
|
|
|
inline int
|
|
|
|
|
strlen_round (const char *s)
|
2001-08-22 17:31:59 +02:00
|
|
|
|
{
|
2003-09-01 00:02:15 +02:00
|
|
|
|
if (!s)
|
|
|
|
|
return 0;
|
|
|
|
|
return DWORD_round (strlen (s) + 1);
|
2001-08-22 17:31:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-01 00:02:15 +02:00
|
|
|
|
#pragma pack(push,2)
|
|
|
|
|
struct pservent
|
2001-08-24 08:57:53 +02:00
|
|
|
|
{
|
2003-09-01 00:02:15 +02:00
|
|
|
|
char *s_name;
|
|
|
|
|
char **s_aliases;
|
|
|
|
|
short s_port;
|
|
|
|
|
char *s_proto;
|
|
|
|
|
};
|
|
|
|
|
#pragma pack(pop)
|
2001-09-07 23:32:07 +02:00
|
|
|
|
|
2003-09-01 00:02:15 +02:00
|
|
|
|
struct unionent
|
|
|
|
|
{
|
|
|
|
|
char *name;
|
|
|
|
|
char **list;
|
|
|
|
|
short port_proto_addrtype;
|
|
|
|
|
short h_len;
|
|
|
|
|
union
|
|
|
|
|
{
|
|
|
|
|
char *s_proto;
|
|
|
|
|
char **h_addr_list;
|
|
|
|
|
};
|
|
|
|
|
};
|
2001-08-24 08:57:53 +02:00
|
|
|
|
|
2003-09-01 01:16:34 +02:00
|
|
|
|
enum struct_type
|
|
|
|
|
{
|
2005-03-16 18:07:32 +01:00
|
|
|
|
t_hostent, t_protoent, t_servent
|
2003-09-01 01:16:34 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char *entnames[] = {"host", "proto", "serv"};
|
|
|
|
|
|
2003-09-01 00:02:15 +02:00
|
|
|
|
/* Generic "dup a {host,proto,serv}ent structure" function.
|
|
|
|
|
This is complicated because we need to be able to free the
|
|
|
|
|
structure at any point and we can't rely on the pointer contents
|
|
|
|
|
being untouched by callers. So, we allocate a chunk of memory
|
|
|
|
|
large enough to hold the structure and all of the stuff it points
|
|
|
|
|
to then we copy the source into this new block of memory.
|
|
|
|
|
The 'unionent' struct is a union of all of the currently used
|
|
|
|
|
*ent structure. */
|
|
|
|
|
|
2005-03-16 18:07:32 +01:00
|
|
|
|
#define dup_ent(old, src, type) __dup_ent ((unionent *&) (_my_tls.locals.old), (unionent *) (src), type)
|
2003-09-01 00:02:15 +02:00
|
|
|
|
#ifdef DEBUGGING
|
|
|
|
|
static void *
|
|
|
|
|
#else
|
|
|
|
|
static inline void *
|
|
|
|
|
#endif
|
2005-03-16 18:07:32 +01:00
|
|
|
|
__dup_ent (unionent *&dst, unionent *src, struct_type type)
|
2001-08-22 17:31:59 +02:00
|
|
|
|
{
|
2005-03-16 18:07:32 +01:00
|
|
|
|
if (dst)
|
|
|
|
|
debug_printf ("old %sent structure \"%s\" %p\n", entnames[type],
|
|
|
|
|
((unionent *) dst)->name, dst);
|
|
|
|
|
|
|
|
|
|
if (!src)
|
2003-09-01 01:16:34 +02:00
|
|
|
|
{
|
2005-03-16 18:07:32 +01:00
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
return NULL;
|
2003-09-01 01:16:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2005-03-10 00:46:51 +01:00
|
|
|
|
debug_printf ("duping %sent \"%s\", %p", entnames[type], src->name, src);
|
2001-08-22 17:31:59 +02:00
|
|
|
|
|
2003-09-01 00:02:15 +02:00
|
|
|
|
/* Find the size of the raw structure minus any character strings, etc. */
|
|
|
|
|
int sz, struct_sz;
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
2005-03-16 18:07:32 +01:00
|
|
|
|
case t_protoent:
|
2003-09-01 00:02:15 +02:00
|
|
|
|
struct_sz = sizeof (protoent);
|
|
|
|
|
break;
|
2005-03-16 18:07:32 +01:00
|
|
|
|
case t_servent:
|
2003-09-01 00:02:15 +02:00
|
|
|
|
struct_sz = sizeof (servent);
|
|
|
|
|
break;
|
2005-03-16 18:07:32 +01:00
|
|
|
|
case t_hostent:
|
2003-09-01 00:02:15 +02:00
|
|
|
|
struct_sz = sizeof (hostent);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
api_fatal ("called with invalid value %d", type);
|
|
|
|
|
break;
|
2001-08-22 17:31:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-01 00:02:15 +02:00
|
|
|
|
/* Every *ent begins with a name. Calculate it's length. */
|
|
|
|
|
int namelen = strlen_round (src->name);
|
|
|
|
|
sz = struct_sz + namelen;
|
2001-08-22 17:31:59 +02:00
|
|
|
|
|
2003-09-01 00:02:15 +02:00
|
|
|
|
char **av;
|
|
|
|
|
/* The next field in every *ent is an argv list of "something".
|
|
|
|
|
Calculate the number of components and how much space the
|
|
|
|
|
character strings will take. */
|
|
|
|
|
int list_len = 0;
|
|
|
|
|
for (av = src->list; av && *av; av++)
|
|
|
|
|
{
|
|
|
|
|
list_len++;
|
|
|
|
|
sz += sizeof (char **) + strlen_round (*av);
|
|
|
|
|
}
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2003-09-01 00:02:15 +02:00
|
|
|
|
/* NULL terminate if there actually was a list */
|
|
|
|
|
if (av)
|
|
|
|
|
{
|
|
|
|
|
sz += sizeof (char **);
|
|
|
|
|
list_len++;
|
|
|
|
|
}
|
2001-08-22 17:31:59 +02:00
|
|
|
|
|
2003-09-01 00:02:15 +02:00
|
|
|
|
/* Do servent/hostent specific processing */
|
|
|
|
|
int protolen = 0;
|
|
|
|
|
int addr_list_len = 0;
|
2003-11-03 22:43:32 +01:00
|
|
|
|
char *s_proto = NULL;
|
2005-03-16 18:07:32 +01:00
|
|
|
|
if (type == t_servent)
|
2003-11-03 22:43:32 +01:00
|
|
|
|
{
|
|
|
|
|
if (src->s_proto)
|
|
|
|
|
{
|
|
|
|
|
/* Windows 95 idiocy. Structure is misaligned on Windows 95.
|
|
|
|
|
Kludge around this by trying a different pointer alignment. */
|
2003-12-03 17:35:52 +01:00
|
|
|
|
if (!IsBadStringPtr (src->s_proto, INT32_MAX))
|
2003-11-03 22:43:32 +01:00
|
|
|
|
s_proto = src->s_proto;
|
2003-12-03 17:35:52 +01:00
|
|
|
|
else if (!IsBadStringPtr (((pservent *) src)->s_proto, INT32_MAX))
|
2003-11-04 14:15:47 +01:00
|
|
|
|
s_proto = ((pservent *) src)->s_proto;
|
|
|
|
|
sz += (protolen = strlen_round (s_proto));
|
2003-11-03 22:43:32 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-03-16 18:07:32 +01:00
|
|
|
|
else if (type == t_hostent)
|
2003-09-01 00:02:15 +02:00
|
|
|
|
{
|
|
|
|
|
/* Calculate the length and storage used for h_addr_list */
|
|
|
|
|
for (av = src->h_addr_list; av && *av; av++)
|
|
|
|
|
{
|
|
|
|
|
addr_list_len++;
|
|
|
|
|
sz += sizeof (char **) + DWORD_round (src->h_len);
|
|
|
|
|
}
|
|
|
|
|
if (av)
|
|
|
|
|
{
|
|
|
|
|
sz += sizeof (char **);
|
|
|
|
|
addr_list_len++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-08-22 17:31:59 +02:00
|
|
|
|
|
2005-03-16 18:07:32 +01:00
|
|
|
|
/* Allocate the storage needed. Allocate a rounded size to attempt to force
|
|
|
|
|
reuse of this buffer so that a poorly-written caller will not be using
|
|
|
|
|
a freed buffer. */
|
|
|
|
|
unsigned rsz = 256 * ((sz + 255) / 256);
|
|
|
|
|
dst = (unionent *) realloc (dst, rsz);
|
2001-08-22 17:31:59 +02:00
|
|
|
|
|
2003-09-01 00:02:15 +02:00
|
|
|
|
/* Hopefully, this worked. */
|
|
|
|
|
if (dst)
|
|
|
|
|
{
|
2005-03-16 18:07:32 +01:00
|
|
|
|
memset (dst, 0, sz);
|
2003-09-01 00:02:15 +02:00
|
|
|
|
/* This field is common to all *ent structures but named differently
|
|
|
|
|
in each, of course. */
|
|
|
|
|
dst->port_proto_addrtype = src->port_proto_addrtype;
|
|
|
|
|
|
|
|
|
|
char *dp = ((char *) dst) + struct_sz;
|
2005-03-10 00:46:51 +01:00
|
|
|
|
if (namelen)
|
|
|
|
|
{
|
|
|
|
|
/* Copy the name field to dst, using space just beyond the end of
|
|
|
|
|
the dst structure. */
|
|
|
|
|
strcpy (dst->name = dp, src->name);
|
|
|
|
|
dp += namelen;
|
|
|
|
|
}
|
2003-09-01 00:02:15 +02:00
|
|
|
|
|
|
|
|
|
/* Copy the 'list' type to dst, using space beyond end of structure
|
|
|
|
|
+ storage for name. */
|
|
|
|
|
if (src->list)
|
|
|
|
|
{
|
|
|
|
|
char **dav = dst->list = (char **) dp;
|
|
|
|
|
dp += sizeof (char **) * list_len;
|
|
|
|
|
for (av = src->list; av && *av; av++)
|
|
|
|
|
{
|
|
|
|
|
int len = strlen (*av) + 1;
|
|
|
|
|
memcpy (*dav++ = dp, *av, len);
|
|
|
|
|
dp += DWORD_round (len);
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-08-22 17:31:59 +02:00
|
|
|
|
|
2005-03-16 18:07:32 +01:00
|
|
|
|
/* Do servent/protoent/hostent specific processing. */
|
|
|
|
|
if (type == t_protoent)
|
|
|
|
|
debug_printf ("protoent %s %x %x", dst->name, dst->list, dst->port_proto_addrtype);
|
|
|
|
|
else if (type == t_servent)
|
2003-09-01 00:02:15 +02:00
|
|
|
|
{
|
2003-11-03 22:43:32 +01:00
|
|
|
|
if (s_proto)
|
2003-09-01 00:02:15 +02:00
|
|
|
|
{
|
|
|
|
|
strcpy (dst->s_proto = dp, s_proto);
|
|
|
|
|
dp += protolen;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-03-16 18:07:32 +01:00
|
|
|
|
else if (type == t_hostent)
|
2003-09-01 00:02:15 +02:00
|
|
|
|
{
|
|
|
|
|
/* Transfer h_len and duplicate contents of h_addr_list, using
|
|
|
|
|
memory after 'list' allocation. */
|
|
|
|
|
dst->h_len = src->h_len;
|
|
|
|
|
char **dav = dst->h_addr_list = (char **) dp;
|
|
|
|
|
dp += sizeof (char **) * addr_list_len;
|
|
|
|
|
for (av = src->h_addr_list; av && *av; av++)
|
|
|
|
|
{
|
|
|
|
|
memcpy (*dav++ = dp, *av, src->h_len);
|
|
|
|
|
dp += DWORD_round (src->h_len);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* Sanity check that we did our bookkeeping correctly. */
|
|
|
|
|
assert ((dp - (char *) dst) == sz);
|
|
|
|
|
}
|
2003-09-01 01:16:34 +02:00
|
|
|
|
debug_printf ("duped %sent \"%s\", %p", entnames[type], dst ? dst->name : "<null!>", dst);
|
2001-08-22 17:31:59 +02:00
|
|
|
|
return dst;
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
/* exported as getprotobyname: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" struct protoent *
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_getprotobyname (const char *p)
|
|
|
|
|
{
|
2001-11-24 04:11:39 +01:00
|
|
|
|
if (check_null_str_errno (p))
|
|
|
|
|
return NULL;
|
2005-03-18 23:42:51 +01:00
|
|
|
|
return (protoent *) dup_ent (protoent_buf, getprotobyname (p), t_protoent);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as getprotobynumber: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" struct protoent *
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_getprotobynumber (int number)
|
|
|
|
|
{
|
2005-03-18 23:42:51 +01:00
|
|
|
|
return (protoent *) dup_ent (protoent_buf, getprotobynumber (number), t_protoent);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
* 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
|
|
|
|
bool
|
|
|
|
|
fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2001-10-14 06:14:24 +02:00
|
|
|
|
if (!winsock2_active)
|
2000-10-26 12:13:41 +02:00
|
|
|
|
soc = set_socket_inheritance (soc);
|
2002-06-10 13:07:44 +02:00
|
|
|
|
else if (wincap.has_set_handle_information ())
|
|
|
|
|
{
|
|
|
|
|
/* NT systems apparently set sockets to inheritable by default */
|
2002-11-10 14:43:26 +01:00
|
|
|
|
SetHandleInformation ((HANDLE) soc, HANDLE_FLAG_INHERIT, 0);
|
|
|
|
|
debug_printf ("reset socket inheritance since winsock2_active %d",
|
|
|
|
|
winsock2_active);
|
2002-06-10 13:07:44 +02:00
|
|
|
|
}
|
2001-10-14 06:14:24 +02:00
|
|
|
|
else
|
2002-11-10 14:43:26 +01:00
|
|
|
|
debug_printf ("not setting socket inheritance since winsock2_active %d",
|
|
|
|
|
winsock2_active);
|
* 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
|
|
|
|
fd = build_fh_dev (*dev);
|
|
|
|
|
if (!fd.isopen ())
|
|
|
|
|
return false;
|
|
|
|
|
fd->set_io_handle ((HANDLE) soc);
|
|
|
|
|
fd->set_flags (O_RDWR | O_BINARY);
|
2004-04-10 15:45:10 +02:00
|
|
|
|
fd->uninterruptible_io (winsock2_active);
|
* 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
|
|
|
|
cygheap->fdtab.inc_need_fixup_before ();
|
|
|
|
|
debug_printf ("fd %d, name '%s', soc %p", (int) fd, dev->name, soc);
|
|
|
|
|
return true;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as socket: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_socket (int af, int type, int protocol)
|
|
|
|
|
{
|
|
|
|
|
int res = -1;
|
2001-10-14 06:14:24 +02:00
|
|
|
|
SOCKET soc = 0;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2003-02-20 15:14:37 +01:00
|
|
|
|
debug_printf ("socket (%d, %d, %d)", af, type, protocol);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2003-02-20 15:14:37 +01:00
|
|
|
|
soc = socket (AF_INET, type, af == AF_LOCAL ? 0 : protocol);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2003-02-20 15:14:37 +01:00
|
|
|
|
if (soc == INVALID_SOCKET)
|
|
|
|
|
{
|
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
* 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
|
|
|
|
const device *dev;
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2003-02-20 15:14:37 +01:00
|
|
|
|
if (af == AF_INET)
|
* 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
|
|
|
|
dev = type == SOCK_STREAM ? tcp_dev : udp_dev;
|
2003-02-20 15:14:37 +01:00
|
|
|
|
else
|
* 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
|
|
|
|
dev = type == SOCK_STREAM ? stream_dev : dgram_dev;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2003-02-20 15:14:37 +01:00
|
|
|
|
{
|
|
|
|
|
cygheap_fdnew fd;
|
* 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
|
|
|
|
if (fd < 0 || !fdsock (fd, dev, soc))
|
|
|
|
|
closesocket (soc);
|
|
|
|
|
else
|
2003-02-20 15:14:37 +01:00
|
|
|
|
{
|
* 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
|
|
|
|
((fhandler_socket *) fd)->set_addr_family (af);
|
|
|
|
|
((fhandler_socket *) fd)->set_socket_type (type);
|
2003-02-20 15:14:37 +01:00
|
|
|
|
res = fd;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
syscall_printf ("%d = socket (%d, %d, %d)", res, af, type, protocol);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as sendto: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2002-08-26 11:57:27 +02:00
|
|
|
|
cygwin_sendto (int fd, const void *buf, int len, int flags,
|
2002-06-26 21:25:09 +02:00
|
|
|
|
const struct sockaddr *to, int tolen)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2001-05-15 10:15:54 +02:00
|
|
|
|
int res;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-08-27 11:24:50 +02:00
|
|
|
|
|
2002-06-26 21:25:09 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2001-11-24 04:11:39 +01:00
|
|
|
|
if ((len && __check_invalid_read_ptr_errno (buf, (unsigned) len))
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|| (to && __check_invalid_read_ptr_errno (to, tolen))
|
2002-06-26 21:25:09 +02:00
|
|
|
|
|| !fh)
|
2001-11-24 04:11:39 +01:00
|
|
|
|
res = -1;
|
2002-08-12 15:54:12 +02:00
|
|
|
|
else if ((res = len) != 0)
|
2002-06-26 21:25:09 +02:00
|
|
|
|
res = fh->sendto (buf, len, flags, to, tolen);
|
2001-05-15 10:15:54 +02:00
|
|
|
|
|
2002-08-26 11:57:27 +02:00
|
|
|
|
syscall_printf ("%d = sendto (%d, %p, %d, %x, %p, %d)",
|
|
|
|
|
res, fd, buf, len, flags, to, tolen);
|
2001-05-15 10:15:54 +02:00
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as recvfrom: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2002-08-26 11:57:27 +02:00
|
|
|
|
cygwin_recvfrom (int fd, void *buf, int len, int flags,
|
|
|
|
|
struct sockaddr *from, int *fromlen)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2001-05-15 10:15:54 +02:00
|
|
|
|
int res;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-08-27 11:24:50 +02:00
|
|
|
|
|
2002-06-26 21:25:09 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2002-08-12 15:54:12 +02:00
|
|
|
|
if ((len && __check_null_invalid_struct_errno (buf, (unsigned) len))
|
2002-08-08 19:03:20 +02:00
|
|
|
|
|| (from
|
|
|
|
|
&& (check_null_invalid_struct_errno (fromlen)
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|| __check_null_invalid_struct_errno (from, (unsigned) *fromlen)))
|
2002-06-26 21:25:09 +02:00
|
|
|
|
|| !fh)
|
2001-11-24 04:11:39 +01:00
|
|
|
|
res = -1;
|
2002-08-12 15:54:12 +02:00
|
|
|
|
else if ((res = len) != 0)
|
2002-06-26 21:25:09 +02:00
|
|
|
|
res = fh->recvfrom (buf, len, flags, from, fromlen);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2002-08-26 11:57:27 +02:00
|
|
|
|
syscall_printf ("%d = recvfrom (%d, %p, %d, %x, %p, %p)",
|
|
|
|
|
res, fd, buf, len, flags, from, fromlen);
|
2001-05-15 10:15:54 +02:00
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as setsockopt: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2002-06-26 21:25:09 +02:00
|
|
|
|
cygwin_setsockopt (int fd, int level, int optname, const void *optval,
|
|
|
|
|
int optlen)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2002-08-08 19:03:20 +02:00
|
|
|
|
int res;
|
2002-06-26 21:25:09 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
const char *name = "error";
|
|
|
|
|
|
2002-08-08 19:03:20 +02:00
|
|
|
|
/* For the following debug_printf */
|
|
|
|
|
switch (optname)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2002-11-10 14:43:26 +01:00
|
|
|
|
case SO_DEBUG:
|
|
|
|
|
name = "SO_DEBUG";
|
|
|
|
|
break;
|
|
|
|
|
case SO_ACCEPTCONN:
|
|
|
|
|
name = "SO_ACCEPTCONN";
|
|
|
|
|
break;
|
|
|
|
|
case SO_REUSEADDR:
|
|
|
|
|
name = "SO_REUSEADDR";
|
|
|
|
|
break;
|
|
|
|
|
case SO_KEEPALIVE:
|
|
|
|
|
name = "SO_KEEPALIVE";
|
|
|
|
|
break;
|
|
|
|
|
case SO_DONTROUTE:
|
|
|
|
|
name = "SO_DONTROUTE";
|
|
|
|
|
break;
|
|
|
|
|
case SO_BROADCAST:
|
|
|
|
|
name = "SO_BROADCAST";
|
|
|
|
|
break;
|
|
|
|
|
case SO_USELOOPBACK:
|
|
|
|
|
name = "SO_USELOOPBACK";
|
|
|
|
|
break;
|
|
|
|
|
case SO_LINGER:
|
|
|
|
|
name = "SO_LINGER";
|
|
|
|
|
break;
|
|
|
|
|
case SO_OOBINLINE:
|
|
|
|
|
name = "SO_OOBINLINE";
|
|
|
|
|
break;
|
|
|
|
|
case SO_ERROR:
|
|
|
|
|
name = "SO_ERROR";
|
|
|
|
|
break;
|
2002-08-08 19:03:20 +02:00
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2002-08-08 19:03:20 +02:00
|
|
|
|
if ((optval && __check_invalid_read_ptr_errno (optval, optlen)) || !fh)
|
|
|
|
|
res = -1;
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-06-26 21:25:09 +02:00
|
|
|
|
res = setsockopt (fh->get_socket (), level, optname,
|
|
|
|
|
(const char *) optval, optlen);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
|
|
if (optlen == 4)
|
|
|
|
|
syscall_printf ("setsockopt optval=%x", *(long *) optval);
|
|
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-26 11:57:27 +02:00
|
|
|
|
syscall_printf ("%d = setsockopt (%d, %d, %x (%s), %p, %d)",
|
2000-02-17 20:38:33 +01:00
|
|
|
|
res, fd, level, optname, name, optval, optlen);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as getsockopt: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2002-06-26 21:25:09 +02:00
|
|
|
|
cygwin_getsockopt (int fd, int level, int optname, void *optval, int *optlen)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2002-08-08 19:03:20 +02:00
|
|
|
|
int res;
|
2002-06-26 21:25:09 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
const char *name = "error";
|
2002-08-08 19:03:20 +02:00
|
|
|
|
|
|
|
|
|
/* For the following debug_printf */
|
|
|
|
|
switch (optname)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2002-11-10 14:43:26 +01:00
|
|
|
|
case SO_DEBUG:
|
|
|
|
|
name = "SO_DEBUG";
|
|
|
|
|
break;
|
|
|
|
|
case SO_ACCEPTCONN:
|
|
|
|
|
name = "SO_ACCEPTCONN";
|
|
|
|
|
break;
|
|
|
|
|
case SO_REUSEADDR:
|
|
|
|
|
name = "SO_REUSEADDR";
|
|
|
|
|
break;
|
|
|
|
|
case SO_KEEPALIVE:
|
|
|
|
|
name = "SO_KEEPALIVE";
|
|
|
|
|
break;
|
|
|
|
|
case SO_DONTROUTE:
|
|
|
|
|
name = "SO_DONTROUTE";
|
|
|
|
|
break;
|
|
|
|
|
case SO_BROADCAST:
|
|
|
|
|
name = "SO_BROADCAST";
|
|
|
|
|
break;
|
|
|
|
|
case SO_USELOOPBACK:
|
|
|
|
|
name = "SO_USELOOPBACK";
|
|
|
|
|
break;
|
|
|
|
|
case SO_LINGER:
|
|
|
|
|
name = "SO_LINGER";
|
|
|
|
|
break;
|
|
|
|
|
case SO_OOBINLINE:
|
|
|
|
|
name = "SO_OOBINLINE";
|
|
|
|
|
break;
|
|
|
|
|
case SO_ERROR:
|
|
|
|
|
name = "SO_ERROR";
|
|
|
|
|
break;
|
2005-02-23 18:39:46 +01:00
|
|
|
|
case SO_PEERCRED:
|
|
|
|
|
name = "SO_PEERCRED";
|
2002-08-08 19:03:20 +02:00
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2002-08-08 19:03:20 +02:00
|
|
|
|
if ((optval
|
|
|
|
|
&& (check_null_invalid_struct_errno (optlen)
|
|
|
|
|
|| __check_null_invalid_struct_errno (optval, (unsigned) *optlen)))
|
|
|
|
|
|| !fh)
|
|
|
|
|
res = -1;
|
2005-02-23 18:39:46 +01:00
|
|
|
|
else if (optname == SO_PEERCRED)
|
|
|
|
|
{
|
|
|
|
|
struct ucred *cred = (struct ucred *) optval;
|
|
|
|
|
res = fh->getpeereid (&cred->pid, &cred->uid, &cred->gid);
|
|
|
|
|
}
|
2002-08-08 19:03:20 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2002-06-26 21:25:09 +02:00
|
|
|
|
res = getsockopt (fh->get_socket (), level, optname, (char *) optval,
|
2002-09-19 05:30:20 +02:00
|
|
|
|
(int *) optlen);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2001-04-03 04:53:25 +02:00
|
|
|
|
if (optname == SO_ERROR)
|
|
|
|
|
{
|
|
|
|
|
int *e = (int *) optval;
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2005-03-24 15:04:06 +01:00
|
|
|
|
debug_printf ("WinSock SO_ERROR = %d", *e);
|
2001-04-03 04:53:25 +02:00
|
|
|
|
*e = find_winsock_errno (*e);
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
if (res)
|
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-26 11:57:27 +02:00
|
|
|
|
syscall_printf ("%d = getsockopt (%d, %d, %x (%s), %p, %p)",
|
2000-02-17 20:38:33 +01:00
|
|
|
|
res, fd, level, optname, name, optval, optlen);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-23 18:39:46 +01:00
|
|
|
|
extern "C" int
|
|
|
|
|
getpeereid (int fd, __uid32_t *euid, __gid32_t *egid)
|
|
|
|
|
{
|
|
|
|
|
sig_dispatch_pending ();
|
|
|
|
|
fhandler_socket *fh = get (fd);
|
|
|
|
|
if (fh)
|
|
|
|
|
return fh->getpeereid (NULL, euid, egid);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
/* exported as connect: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2002-06-26 21:25:09 +02:00
|
|
|
|
cygwin_connect (int fd, const struct sockaddr *name, int namelen)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
|
|
|
|
int res;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-08-27 11:24:50 +02:00
|
|
|
|
|
2002-06-26 21:25:09 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2002-08-08 19:03:20 +02:00
|
|
|
|
if (__check_invalid_read_ptr_errno (name, namelen) || !fh)
|
2001-11-24 04:11:39 +01:00
|
|
|
|
res = -1;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
else
|
2003-06-03 16:05:17 +02:00
|
|
|
|
{
|
|
|
|
|
bool was_blocking = false;
|
|
|
|
|
if (!fh->is_nonblocking ())
|
2003-07-26 06:53:59 +02:00
|
|
|
|
{
|
2003-06-03 16:05:17 +02:00
|
|
|
|
int nonblocking = 1;
|
|
|
|
|
fh->ioctl (FIONBIO, &nonblocking);
|
|
|
|
|
was_blocking = true;
|
|
|
|
|
}
|
|
|
|
|
res = fh->connect (name, namelen);
|
|
|
|
|
if (was_blocking)
|
2003-07-26 06:53:59 +02:00
|
|
|
|
{
|
2003-06-03 16:05:17 +02:00
|
|
|
|
if (res == -1 && get_errno () == EINPROGRESS)
|
|
|
|
|
{
|
|
|
|
|
size_t fds_size = howmany (fd + 1, NFDBITS) * sizeof (fd_mask);
|
|
|
|
|
fd_set *write_fds = (fd_set *) alloca (fds_size);
|
|
|
|
|
fd_set *except_fds = (fd_set *) alloca (fds_size);
|
|
|
|
|
memset (write_fds, 0, fds_size);
|
|
|
|
|
memset (except_fds, 0, fds_size);
|
|
|
|
|
FD_SET (fd, write_fds);
|
|
|
|
|
FD_SET (fd, except_fds);
|
|
|
|
|
res = cygwin_select (fd + 1, NULL, write_fds, except_fds, NULL);
|
|
|
|
|
if (res > 0 && FD_ISSET (fd, except_fds))
|
2003-07-26 06:53:59 +02:00
|
|
|
|
{
|
2003-06-03 16:05:17 +02:00
|
|
|
|
res = -1;
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
int err;
|
|
|
|
|
int len = sizeof err;
|
|
|
|
|
cygwin_getsockopt (fd, SOL_SOCKET, SO_ERROR,
|
|
|
|
|
(void *) &err, &len);
|
|
|
|
|
if (err)
|
2003-07-26 06:53:59 +02:00
|
|
|
|
{
|
2003-06-03 16:05:17 +02:00
|
|
|
|
set_errno (err);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
low_priority_sleep (0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (res > 0)
|
2003-07-26 06:53:59 +02:00
|
|
|
|
res = 0;
|
2003-06-03 16:05:17 +02:00
|
|
|
|
else
|
2003-07-26 06:53:59 +02:00
|
|
|
|
{
|
2003-06-03 16:05:17 +02:00
|
|
|
|
WSASetLastError (WSAEINPROGRESS);
|
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int nonblocking = 0;
|
|
|
|
|
fh->ioctl (FIONBIO, &nonblocking);
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-04-09 09:21:32 +02:00
|
|
|
|
|
2002-08-26 11:57:27 +02:00
|
|
|
|
syscall_printf ("%d = connect (%d, %p, %d)", res, fd, name, namelen);
|
2001-04-09 09:21:32 +02:00
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as getservbyname: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" struct servent *
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_getservbyname (const char *name, const char *proto)
|
|
|
|
|
{
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2001-11-24 04:11:39 +01:00
|
|
|
|
if (check_null_str_errno (name)
|
|
|
|
|
|| (proto != NULL && check_null_str_errno (proto)))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2005-03-16 18:07:32 +01:00
|
|
|
|
dup_ent (servent_buf, getservbyname (name, proto), t_servent);
|
|
|
|
|
syscall_printf ("%p = getservbyname (%s, %s)", _my_tls.locals.servent_buf, name, proto);
|
2003-12-23 17:26:31 +01:00
|
|
|
|
return _my_tls.locals.servent_buf;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as getservbyport: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" struct servent *
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_getservbyport (int port, const char *proto)
|
|
|
|
|
{
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2001-11-24 04:11:39 +01:00
|
|
|
|
if (proto != NULL && check_null_str_errno (proto))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2005-03-16 18:07:32 +01:00
|
|
|
|
dup_ent (servent_buf, getservbyport (port, proto), t_servent);
|
|
|
|
|
syscall_printf ("%p = getservbyport (%d, %s)", _my_tls.locals.servent_buf, port, proto);
|
2003-12-23 17:26:31 +01:00
|
|
|
|
return _my_tls.locals.servent_buf;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_gethostname (char *name, size_t len)
|
|
|
|
|
{
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2001-11-24 04:11:39 +01:00
|
|
|
|
if (__check_null_invalid_struct_errno (name, len))
|
|
|
|
|
return -1;
|
|
|
|
|
|
2003-01-10 13:55:47 +01:00
|
|
|
|
if (gethostname (name, len))
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
|
|
|
|
DWORD local_len = len;
|
|
|
|
|
|
|
|
|
|
if (!GetComputerNameA (name, &local_len))
|
|
|
|
|
{
|
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-30 06:35:18 +02:00
|
|
|
|
debug_printf ("name %s", name);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as gethostbyname: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" struct hostent *
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_gethostbyname (const char *name)
|
|
|
|
|
{
|
2005-03-16 18:07:32 +01:00
|
|
|
|
sig_dispatch_pending ();
|
|
|
|
|
if (check_null_str_errno (name))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2005-02-07 16:27:40 +01:00
|
|
|
|
unsigned char tmp_addr[4];
|
|
|
|
|
struct hostent tmp, *h;
|
|
|
|
|
char *tmp_aliases[1] = {0};
|
|
|
|
|
char *tmp_addr_list[2] = {0,0};
|
|
|
|
|
unsigned int a, b, c, d;
|
|
|
|
|
char dummy;
|
2000-10-05 07:57:00 +02:00
|
|
|
|
|
2005-03-16 18:07:32 +01:00
|
|
|
|
if (sscanf (name, "%u.%u.%u.%u%c", &a, &b, &c, &d, &dummy) != 4
|
|
|
|
|
|| a >= 256 || b >= 256 || c >= 256 || d >= 256)
|
|
|
|
|
h = gethostbyname (name);
|
|
|
|
|
else
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
|
|
|
|
/* In case you don't have DNS, at least x.x.x.x still works */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
memset (&tmp, 0, sizeof (tmp));
|
2000-02-17 20:38:33 +01:00
|
|
|
|
tmp_addr[0] = a;
|
|
|
|
|
tmp_addr[1] = b;
|
|
|
|
|
tmp_addr[2] = c;
|
|
|
|
|
tmp_addr[3] = d;
|
2002-06-10 21:58:21 +02:00
|
|
|
|
tmp_addr_list[0] = (char *) tmp_addr;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
tmp.h_name = name;
|
|
|
|
|
tmp.h_aliases = tmp_aliases;
|
|
|
|
|
tmp.h_addrtype = 2;
|
|
|
|
|
tmp.h_length = 4;
|
|
|
|
|
tmp.h_addr_list = tmp_addr_list;
|
2005-02-07 16:27:40 +01:00
|
|
|
|
h = &tmp;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
2005-02-07 16:27:40 +01:00
|
|
|
|
|
2005-03-16 18:07:32 +01:00
|
|
|
|
if (dup_ent (hostent_buf, h, t_hostent))
|
|
|
|
|
debug_printf ("h_name %s", _my_tls.locals.hostent_buf->h_name);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2005-03-16 18:07:32 +01:00
|
|
|
|
debug_printf ("dup_ent failed for name %s", name);
|
|
|
|
|
set_host_errno ();
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
2003-12-23 17:26:31 +01:00
|
|
|
|
return _my_tls.locals.hostent_buf;
|
2001-08-22 23:51:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as gethostbyaddr: standards? */
|
|
|
|
|
extern "C" struct hostent *
|
|
|
|
|
cygwin_gethostbyaddr (const char *addr, int len, int type)
|
|
|
|
|
{
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-08-08 19:03:20 +02:00
|
|
|
|
if (__check_invalid_read_ptr_errno (addr, len))
|
2001-11-24 04:11:39 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2005-03-16 18:07:32 +01:00
|
|
|
|
if (dup_ent (hostent_buf, gethostbyaddr (addr, len, type), t_hostent))
|
|
|
|
|
debug_printf ("h_name %s", _my_tls.locals.hostent_buf->h_name);
|
2001-08-22 23:51:48 +02:00
|
|
|
|
else
|
2005-03-16 18:07:32 +01:00
|
|
|
|
set_host_errno ();
|
2003-12-23 17:26:31 +01:00
|
|
|
|
return _my_tls.locals.hostent_buf;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as accept: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_accept (int fd, struct sockaddr *peer, int *len)
|
|
|
|
|
{
|
2002-08-08 19:03:20 +02:00
|
|
|
|
int res;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-08-27 11:24:50 +02:00
|
|
|
|
|
2002-06-26 21:25:09 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2002-08-08 19:03:20 +02:00
|
|
|
|
|
|
|
|
|
if ((peer && (check_null_invalid_struct_errno (len)
|
|
|
|
|
|| __check_null_invalid_struct_errno (peer, (unsigned) *len)))
|
|
|
|
|
|| !fh)
|
|
|
|
|
res = -1;
|
|
|
|
|
else
|
2003-06-03 16:05:17 +02:00
|
|
|
|
{
|
|
|
|
|
if (!fh->is_nonblocking ())
|
|
|
|
|
{
|
|
|
|
|
size_t fds_size = howmany (fd + 1, NFDBITS) * sizeof (fd_mask);
|
|
|
|
|
fd_set *read_fds = (fd_set *) alloca (fds_size);
|
|
|
|
|
memset (read_fds, 0, fds_size);
|
|
|
|
|
FD_SET (fd, read_fds);
|
|
|
|
|
res = cygwin_select (fd + 1, read_fds, NULL, NULL, NULL);
|
|
|
|
|
if (res == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
res = fh->accept (peer, len);
|
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2002-08-27 11:24:50 +02:00
|
|
|
|
syscall_printf ("%d = accept (%d, %p, %p)", res, fd, peer, len);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as bind: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2001-01-09 17:00:58 +01:00
|
|
|
|
cygwin_bind (int fd, const struct sockaddr *my_addr, int addrlen)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2002-08-08 19:03:20 +02:00
|
|
|
|
int res;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-06-26 21:25:09 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2002-08-08 19:03:20 +02:00
|
|
|
|
|
|
|
|
|
if (__check_invalid_read_ptr_errno (my_addr, addrlen) || !fh)
|
|
|
|
|
res = -1;
|
|
|
|
|
else
|
2002-06-26 21:25:09 +02:00
|
|
|
|
res = fh->bind (my_addr, addrlen);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2002-08-26 11:57:27 +02:00
|
|
|
|
syscall_printf ("%d = bind (%d, %p, %d)", res, fd, my_addr, addrlen);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as getsockname: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_getsockname (int fd, struct sockaddr *addr, int *namelen)
|
|
|
|
|
{
|
2002-08-08 19:03:20 +02:00
|
|
|
|
int res;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-08-27 11:24:50 +02:00
|
|
|
|
|
2002-06-26 21:25:09 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2002-08-08 19:03:20 +02:00
|
|
|
|
|
|
|
|
|
if (check_null_invalid_struct_errno (namelen)
|
|
|
|
|
|| __check_null_invalid_struct_errno (addr, (unsigned) *namelen)
|
|
|
|
|
|| !fh)
|
|
|
|
|
res = -1;
|
|
|
|
|
else
|
2002-06-26 21:25:09 +02:00
|
|
|
|
res = fh->getsockname (addr, namelen);
|
|
|
|
|
|
2002-08-27 11:24:50 +02:00
|
|
|
|
syscall_printf ("%d = getsockname (%d, %p, %p)", res, fd, addr, namelen);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as listen: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_listen (int fd, int backlog)
|
|
|
|
|
{
|
2002-08-08 19:03:20 +02:00
|
|
|
|
int res;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-06-26 21:25:09 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2002-08-08 19:03:20 +02:00
|
|
|
|
|
|
|
|
|
if (!fh)
|
|
|
|
|
res = -1;
|
|
|
|
|
else
|
2002-06-26 21:25:09 +02:00
|
|
|
|
res = fh->listen (backlog);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
|
|
syscall_printf ("%d = listen (%d, %d)", res, fd, backlog);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as shutdown: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_shutdown (int fd, int how)
|
|
|
|
|
{
|
2002-08-08 19:03:20 +02:00
|
|
|
|
int res;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-08-27 11:24:50 +02:00
|
|
|
|
|
2002-06-26 21:25:09 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2002-08-08 19:03:20 +02:00
|
|
|
|
|
|
|
|
|
if (!fh)
|
|
|
|
|
res = -1;
|
|
|
|
|
else
|
2002-06-26 21:25:09 +02:00
|
|
|
|
res = fh->shutdown (how);
|
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
syscall_printf ("%d = shutdown (%d, %d)", res, fd, how);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-14 10:55:44 +02:00
|
|
|
|
/* exported as hstrerror: BSD 4.3 */
|
|
|
|
|
extern "C" const char *
|
|
|
|
|
cygwin_hstrerror (int err)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; host_errmap[i].e != 0; ++i)
|
|
|
|
|
if (err == host_errmap[i].e)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
return host_errmap[i].s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as herror: BSD 4.3 */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" void
|
2000-10-14 10:55:44 +02:00
|
|
|
|
cygwin_herror (const char *s)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2001-11-24 22:52:28 +01:00
|
|
|
|
if (s && check_null_str (s))
|
2001-11-24 22:10:00 +01:00
|
|
|
|
return;
|
2001-04-18 23:10:15 +02:00
|
|
|
|
if (cygheap->fdtab.not_open (2))
|
2000-10-14 10:55:44 +02:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (s)
|
|
|
|
|
{
|
|
|
|
|
write (2, s, strlen (s));
|
|
|
|
|
write (2, ": ", 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *h_errstr = cygwin_hstrerror (h_errno);
|
|
|
|
|
|
|
|
|
|
if (!h_errstr)
|
|
|
|
|
switch (h_errno)
|
|
|
|
|
{
|
2002-11-10 14:43:26 +01:00
|
|
|
|
case NETDB_INTERNAL:
|
|
|
|
|
h_errstr = "Resolver internal error";
|
|
|
|
|
break;
|
|
|
|
|
case NETDB_SUCCESS:
|
|
|
|
|
h_errstr = "Resolver error 0 (no error)";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
h_errstr = "Unknown resolver error";
|
|
|
|
|
break;
|
2000-10-14 10:55:44 +02:00
|
|
|
|
}
|
|
|
|
|
write (2, h_errstr, strlen (h_errstr));
|
|
|
|
|
write (2, "\n", 1);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as getpeername: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_getpeername (int fd, struct sockaddr *name, int *len)
|
|
|
|
|
{
|
2002-08-08 19:03:20 +02:00
|
|
|
|
int res;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-08-27 11:24:50 +02:00
|
|
|
|
|
2002-08-08 19:03:20 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2002-06-26 21:25:09 +02:00
|
|
|
|
|
2001-11-24 04:11:39 +01:00
|
|
|
|
if (check_null_invalid_struct_errno (len)
|
2002-08-08 19:03:20 +02:00
|
|
|
|
|| __check_null_invalid_struct_errno (name, (unsigned) *len)
|
|
|
|
|
|| !fh)
|
|
|
|
|
res = -1;
|
|
|
|
|
else
|
2002-06-26 21:25:09 +02:00
|
|
|
|
res = fh->getpeername (name, len);
|
2001-11-24 04:11:39 +01:00
|
|
|
|
|
2004-08-19 12:58:37 +02:00
|
|
|
|
syscall_printf ("%d = getpeername (%d) %d", res, fd, (fh ? fh->get_socket () : -1));
|
2000-02-17 20:38:33 +01:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as recv: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2002-08-26 11:57:27 +02:00
|
|
|
|
cygwin_recv (int fd, void *buf, int len, int flags)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2002-08-12 15:54:12 +02:00
|
|
|
|
return cygwin_recvfrom (fd, buf, len, flags, NULL, NULL);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as send: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2002-08-26 11:57:27 +02:00
|
|
|
|
cygwin_send (int fd, const void *buf, int len, int flags)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2002-08-12 15:54:12 +02:00
|
|
|
|
return cygwin_sendto (fd, buf, len, flags, NULL, 0);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* getdomainname: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2002-05-04 05:24:35 +02:00
|
|
|
|
getdomainname (char *domain, size_t len)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* This works for Win95 only if the machine is configured to use MS-TCP.
|
|
|
|
|
* If a third-party TCP is being used this will fail.
|
|
|
|
|
* FIXME: On Win95, is there a way to portably check the TCP stack
|
|
|
|
|
* in use and include paths for the Domain name in each ?
|
|
|
|
|
* Punt for now and assume MS-TCP on Win95.
|
|
|
|
|
*/
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2001-11-24 04:11:39 +01:00
|
|
|
|
if (__check_null_invalid_struct_errno (domain, len))
|
|
|
|
|
return -1;
|
|
|
|
|
|
2003-06-19 02:57:26 +02:00
|
|
|
|
PFIXED_INFO info = NULL;
|
|
|
|
|
ULONG size = 0;
|
|
|
|
|
|
|
|
|
|
if (GetNetworkParams(info, &size) == ERROR_BUFFER_OVERFLOW
|
|
|
|
|
&& (info = (PFIXED_INFO) alloca(size))
|
|
|
|
|
&& GetNetworkParams(info, &size) == ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
strncpy(domain, info->DomainName, len);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This is only used by Win95 and NT <= 4.0.
|
|
|
|
|
The registry names are language independent.
|
2003-07-26 06:53:59 +02:00
|
|
|
|
FIXME: Handle DHCP on Win95. The DhcpDomain(s) may be available
|
2003-06-19 02:57:26 +02:00
|
|
|
|
in ..VxD\DHCP\DhcpInfoXX\OptionInfo, RFC 1533 format */
|
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
reg_key r (HKEY_LOCAL_MACHINE, KEY_READ,
|
* Makefile.in: Build wincap.o.
* wincap.cc: New file.
* wincap.h: Ditto.
* autoload.cc: Add dynamic load statement for `CreateHardLinkA'.
* dcrt0.cc (os_being_run): Eliminated.
(osname): Ditto.
(iswinnt): Ditto.
(set_os_type): Ditto.
(dll_crt0_1): Call wincap.init() instead of set_os_type().
(_dll_crt0): Ditto.
* environ.cc (set_chunksize): New function.
(parse_thing): `forkchunk' setting now invokes function `set_chunksize'.
* fork.cc (chunksize): Eliminated. Moved to be member of wincap.
* host_dependent.h: Removed.
* syscalls.cc (_link): Try using `CreateHardLinkA' first, if available.
* cygheap.cc, dcrt0.cc, delqueue.cc, dir.cc,
environ.cc, fhandler.cc, fhandler.h, fhandler_console.cc,
fhandler_mem.cc, fork.cc, mmap.cc, net.cc, pinfo.cc, pinfo.h,
security.cc, syscalls.cc, sysconf.cc, syslog.cc, thread.cc,
times.cc, tty.cc, uinfo.cc, uname.cc, winsup.h: Use new wincap
capability check throughout.
* winsup.h: Include wincap.h. Eliminate extern declarations of
`os_being_run' and `iswinnt'. Eliminate `os_type" definition.
* include/cygwin/version.h: Bump version to 1.3.4.
2001-09-12 19:46:37 +02:00
|
|
|
|
(!wincap.is_winnt ()) ? "System" : "SYSTEM",
|
2000-02-17 20:38:33 +01:00
|
|
|
|
"CurrentControlSet", "Services",
|
2002-01-29 14:39:41 +01:00
|
|
|
|
(!wincap.is_winnt ()) ? "VxD" : "Tcpip",
|
2002-11-10 14:43:26 +01:00
|
|
|
|
(!wincap.is_winnt ()) ? "MSTCP" : "Parameters", NULL);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2003-06-19 02:57:26 +02:00
|
|
|
|
if (!r.error ())
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2003-06-19 02:57:26 +02:00
|
|
|
|
int res1, res2 = 0; /* Suppress compiler warning */
|
|
|
|
|
res1 = r.get_string ("Domain", domain, len, "");
|
|
|
|
|
if (res1 != ERROR_SUCCESS || !domain[0])
|
|
|
|
|
res2 = r.get_string ("DhcpDomain", domain, len, "");
|
|
|
|
|
if (res1 == ERROR_SUCCESS || res2 == ERROR_SUCCESS)
|
|
|
|
|
return 0;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
2003-06-19 02:57:26 +02:00
|
|
|
|
__seterrno ();
|
|
|
|
|
return -1;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-10-02 22:21:47 +02:00
|
|
|
|
/* Fill out an ifconf struct. */
|
|
|
|
|
|
|
|
|
|
/*
|
2001-02-07 23:50:50 +01:00
|
|
|
|
* IFCONF 98/ME, NTSP4, W2K:
|
|
|
|
|
* Use IP Helper Library
|
2000-02-17 20:38:33 +01:00
|
|
|
|
*/
|
2000-09-28 08:34:38 +02:00
|
|
|
|
static void
|
2000-10-02 22:21:47 +02:00
|
|
|
|
get_2k_ifconf (struct ifconf *ifc, int what)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2001-02-07 23:50:50 +01:00
|
|
|
|
int cnt = 0;
|
2002-11-10 14:43:26 +01:00
|
|
|
|
int ethId = 0, pppId = 0, slpId = 0, tokId = 0;
|
2000-09-28 08:34:38 +02:00
|
|
|
|
|
|
|
|
|
/* Union maps buffer to correct struct */
|
|
|
|
|
struct ifreq *ifr = ifc->ifc_req;
|
|
|
|
|
|
2002-11-10 14:43:26 +01:00
|
|
|
|
DWORD ip_cnt, lip, lnp;
|
2001-02-07 23:50:50 +01:00
|
|
|
|
DWORD siz_ip_table = 0;
|
|
|
|
|
PMIB_IPADDRTABLE ipt;
|
2002-11-10 14:43:26 +01:00
|
|
|
|
PMIB_IFROW ifrow;
|
2001-02-07 23:50:50 +01:00
|
|
|
|
struct sockaddr_in *sa = NULL;
|
|
|
|
|
struct sockaddr *so = NULL;
|
|
|
|
|
|
2002-11-10 14:43:26 +01:00
|
|
|
|
typedef struct ifcount_t
|
|
|
|
|
{
|
|
|
|
|
DWORD ifIndex;
|
|
|
|
|
size_t count;
|
|
|
|
|
unsigned int enumerated; // for eth0:1
|
|
|
|
|
unsigned int classId; // for eth0, tok0 ...
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
ifcount_t *iflist, *ifEntry;
|
|
|
|
|
|
|
|
|
|
if (GetIpAddrTable (NULL, &siz_ip_table, TRUE) == ERROR_INSUFFICIENT_BUFFER
|
|
|
|
|
&& (ifrow = (PMIB_IFROW) alloca (sizeof (MIB_IFROW)))
|
|
|
|
|
&& (ipt = (PMIB_IPADDRTABLE) alloca (siz_ip_table))
|
|
|
|
|
&& !GetIpAddrTable (ipt, &siz_ip_table, TRUE))
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2002-11-10 14:43:26 +01:00
|
|
|
|
iflist =
|
|
|
|
|
(ifcount_t *) alloca (sizeof (ifcount_t) * (ipt->dwNumEntries + 1));
|
|
|
|
|
memset (iflist, 0, sizeof (ifcount_t) * (ipt->dwNumEntries + 1));
|
|
|
|
|
for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
|
2001-11-05 07:09:15 +01:00
|
|
|
|
{
|
2002-11-10 14:43:26 +01:00
|
|
|
|
ifEntry = iflist;
|
|
|
|
|
/* search for matching entry (and stop at first free entry) */
|
|
|
|
|
while (ifEntry->count != 0)
|
2001-02-07 23:50:50 +01:00
|
|
|
|
{
|
2002-11-10 14:43:26 +01:00
|
|
|
|
if (ifEntry->ifIndex == ipt->table[ip_cnt].dwIndex)
|
|
|
|
|
break;
|
|
|
|
|
ifEntry++;
|
|
|
|
|
}
|
|
|
|
|
if (ifEntry->count == 0)
|
|
|
|
|
{
|
|
|
|
|
ifEntry->count = 1;
|
|
|
|
|
ifEntry->ifIndex = ipt->table[ip_cnt].dwIndex;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ifEntry->count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// reset the last element. This is just the stopper for the loop.
|
|
|
|
|
iflist[ipt->dwNumEntries].count = 0;
|
|
|
|
|
|
|
|
|
|
/* Iterate over all configured IP-addresses */
|
|
|
|
|
for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
|
|
|
|
|
{
|
|
|
|
|
memset (ifrow, 0, sizeof (MIB_IFROW));
|
|
|
|
|
ifrow->dwIndex = ipt->table[ip_cnt].dwIndex;
|
|
|
|
|
if (GetIfEntry (ifrow) != NO_ERROR)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
ifcount_t *ifEntry = iflist;
|
|
|
|
|
|
|
|
|
|
/* search for matching entry (and stop at first free entry) */
|
|
|
|
|
while (ifEntry->count != 0)
|
|
|
|
|
{
|
|
|
|
|
if (ifEntry->ifIndex == ipt->table[ip_cnt].dwIndex)
|
|
|
|
|
break;
|
|
|
|
|
ifEntry++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Setup the interface name */
|
|
|
|
|
switch (ifrow->dwType)
|
|
|
|
|
{
|
|
|
|
|
case MIB_IF_TYPE_TOKENRING:
|
|
|
|
|
if (ifEntry->enumerated == 0)
|
|
|
|
|
{
|
|
|
|
|
ifEntry->classId = tokId++;
|
|
|
|
|
__small_sprintf (ifr->ifr_name, "tok%u",
|
|
|
|
|
ifEntry->classId);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
__small_sprintf (ifr->ifr_name, "tok%u:%u",
|
|
|
|
|
ifEntry->classId,
|
|
|
|
|
ifEntry->enumerated - 1);
|
|
|
|
|
}
|
|
|
|
|
ifEntry->enumerated++;
|
|
|
|
|
break;
|
|
|
|
|
case MIB_IF_TYPE_ETHERNET:
|
|
|
|
|
if (ifEntry->enumerated == 0)
|
|
|
|
|
{
|
|
|
|
|
ifEntry->classId = ethId++;
|
|
|
|
|
__small_sprintf (ifr->ifr_name, "eth%u",
|
|
|
|
|
ifEntry->classId);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
__small_sprintf (ifr->ifr_name, "eth%u:%u",
|
|
|
|
|
ifEntry->classId,
|
|
|
|
|
ifEntry->enumerated - 1);
|
|
|
|
|
}
|
|
|
|
|
ifEntry->enumerated++;
|
|
|
|
|
break;
|
|
|
|
|
case MIB_IF_TYPE_PPP:
|
|
|
|
|
if (ifEntry->enumerated == 0)
|
|
|
|
|
{
|
|
|
|
|
ifEntry->classId = pppId++;
|
|
|
|
|
__small_sprintf (ifr->ifr_name, "ppp%u",
|
|
|
|
|
ifEntry->classId);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
__small_sprintf (ifr->ifr_name, "ppp%u:%u",
|
|
|
|
|
ifEntry->classId,
|
|
|
|
|
ifEntry->enumerated - 1);
|
|
|
|
|
}
|
|
|
|
|
ifEntry->enumerated++;
|
|
|
|
|
break;
|
|
|
|
|
case MIB_IF_TYPE_SLIP:
|
|
|
|
|
if (ifEntry->enumerated == 0)
|
|
|
|
|
{
|
|
|
|
|
ifEntry->classId = slpId++;
|
|
|
|
|
__small_sprintf (ifr->ifr_name, "slp%u",
|
|
|
|
|
ifEntry->classId);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
__small_sprintf (ifr->ifr_name, "slp%u:%u",
|
|
|
|
|
ifEntry->classId,
|
|
|
|
|
ifEntry->enumerated - 1);
|
|
|
|
|
}
|
|
|
|
|
ifEntry->enumerated++;
|
|
|
|
|
break;
|
|
|
|
|
case MIB_IF_TYPE_LOOPBACK:
|
|
|
|
|
strcpy (ifr->ifr_name, "lo");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
/* setup sockaddr struct */
|
|
|
|
|
switch (what)
|
|
|
|
|
{
|
|
|
|
|
case SIOCGIFCONF:
|
|
|
|
|
case SIOCGIFADDR:
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
|
|
|
|
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwAddr;
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFBRDADDR:
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
2001-02-07 23:50:50 +01:00
|
|
|
|
#if 0
|
2002-11-10 14:43:26 +01:00
|
|
|
|
/* Unfortunately, the field returns only crap. */
|
|
|
|
|
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwBCastAddr;
|
2001-02-07 23:50:50 +01:00
|
|
|
|
#else
|
2002-11-10 14:43:26 +01:00
|
|
|
|
lip = ipt->table[ip_cnt].dwAddr;
|
|
|
|
|
lnp = ipt->table[ip_cnt].dwMask;
|
|
|
|
|
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
2001-02-07 23:50:50 +01:00
|
|
|
|
#endif
|
2002-11-10 14:43:26 +01:00
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFNETMASK:
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
|
|
|
|
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwMask;
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFHWADDR:
|
|
|
|
|
so = &ifr->ifr_hwaddr;
|
|
|
|
|
for (UINT i = 0; i < IFHWADDRLEN; ++i)
|
|
|
|
|
if (i >= ifrow->dwPhysAddrLen)
|
|
|
|
|
so->sa_data[i] = '\0';
|
|
|
|
|
else
|
|
|
|
|
so->sa_data[i] = ifrow->bPhysAddr[i];
|
|
|
|
|
so->sa_family = AF_INET;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFMETRIC:
|
|
|
|
|
ifr->ifr_metric = 1;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFMTU:
|
|
|
|
|
ifr->ifr_mtu = ifrow->dwMtu;
|
|
|
|
|
break;
|
2001-10-22 14:23:33 +02:00
|
|
|
|
}
|
2002-11-10 14:43:26 +01:00
|
|
|
|
++cnt;
|
|
|
|
|
if ((caddr_t)++ ifr >
|
|
|
|
|
ifc->ifc_buf + ifc->ifc_len - sizeof (struct ifreq))
|
|
|
|
|
goto done;
|
2001-02-07 23:50:50 +01:00
|
|
|
|
}
|
2000-09-28 08:34:38 +02:00
|
|
|
|
}
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2001-02-07 23:50:50 +01:00
|
|
|
|
done:
|
2000-09-28 08:34:38 +02:00
|
|
|
|
/* Set the correct length */
|
|
|
|
|
ifc->ifc_len = cnt * sizeof (struct ifreq);
|
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2000-10-02 22:21:47 +02:00
|
|
|
|
/*
|
2001-02-07 23:50:50 +01:00
|
|
|
|
* IFCONF Windows NT < SP4:
|
2000-10-02 22:21:47 +02:00
|
|
|
|
* Look at the Bind value in
|
|
|
|
|
* HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Linkage\
|
|
|
|
|
* This is a REG_MULTI_SZ with strings of the form:
|
|
|
|
|
* \Device\<Netcard>, where netcard is the name of the net device.
|
|
|
|
|
* Then look under:
|
|
|
|
|
* HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<NetCard>\
|
|
|
|
|
* Parameters\Tcpip
|
|
|
|
|
* at the IPAddress, Subnetmask and DefaultGateway values for the
|
|
|
|
|
* required values.
|
|
|
|
|
*/
|
2000-09-28 08:34:38 +02:00
|
|
|
|
static void
|
2000-10-02 22:21:47 +02:00
|
|
|
|
get_nt_ifconf (struct ifconf *ifc, int what)
|
2000-09-28 08:34:38 +02:00
|
|
|
|
{
|
|
|
|
|
HKEY key;
|
|
|
|
|
unsigned long lip, lnp;
|
2000-10-02 22:21:47 +02:00
|
|
|
|
struct sockaddr_in *sa = NULL;
|
2001-02-07 23:50:50 +01:00
|
|
|
|
struct sockaddr *so = NULL;
|
2000-10-02 22:21:47 +02:00
|
|
|
|
DWORD size;
|
2000-09-28 08:34:38 +02:00
|
|
|
|
int cnt = 1;
|
|
|
|
|
char *binding = (char *) 0;
|
|
|
|
|
|
|
|
|
|
/* Union maps buffer to correct struct */
|
|
|
|
|
struct ifreq *ifr = ifc->ifc_req;
|
|
|
|
|
|
|
|
|
|
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE,
|
2001-06-26 16:47:48 +02:00
|
|
|
|
"SYSTEM\\"
|
|
|
|
|
"CurrentControlSet\\"
|
|
|
|
|
"Services\\"
|
2002-11-10 14:43:26 +01:00
|
|
|
|
"Tcpip\\" "Linkage",
|
2001-06-26 16:47:48 +02:00
|
|
|
|
0, KEY_READ, &key) == ERROR_SUCCESS)
|
2000-09-28 08:34:38 +02:00
|
|
|
|
{
|
|
|
|
|
if (RegQueryValueEx (key, "Bind",
|
2001-06-26 16:47:48 +02:00
|
|
|
|
NULL, NULL,
|
|
|
|
|
NULL, &size) == ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
binding = (char *) alloca (size);
|
|
|
|
|
if (RegQueryValueEx (key, "Bind",
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
(unsigned char *) binding,
|
|
|
|
|
&size) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
binding = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-09-28 08:34:38 +02:00
|
|
|
|
RegCloseKey (key);
|
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2000-09-28 08:34:38 +02:00
|
|
|
|
if (binding)
|
|
|
|
|
{
|
|
|
|
|
char *bp, eth[2] = "/";
|
|
|
|
|
char cardkey[256], ipaddress[256], netmask[256];
|
|
|
|
|
|
2000-10-05 07:57:00 +02:00
|
|
|
|
for (bp = binding; *bp; bp += strlen (bp) + 1)
|
2001-06-26 16:47:48 +02:00
|
|
|
|
{
|
|
|
|
|
bp += strlen ("\\Device\\");
|
|
|
|
|
strcpy (cardkey, "SYSTEM\\CurrentControlSet\\Services\\");
|
|
|
|
|
strcat (cardkey, bp);
|
|
|
|
|
strcat (cardkey, "\\Parameters\\Tcpip");
|
|
|
|
|
|
|
|
|
|
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, cardkey,
|
|
|
|
|
0, KEY_READ, &key) != ERROR_SUCCESS)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (RegQueryValueEx (key, "IPAddress",
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
(unsigned char *) ipaddress,
|
|
|
|
|
(size = 256, &size)) == ERROR_SUCCESS
|
|
|
|
|
&& RegQueryValueEx (key, "SubnetMask",
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
(unsigned char *) netmask,
|
|
|
|
|
(size = 256, &size)) == ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
char *ip, *np;
|
|
|
|
|
char dhcpaddress[256], dhcpnetmask[256];
|
|
|
|
|
|
|
|
|
|
for (ip = ipaddress, np = netmask;
|
|
|
|
|
*ip && *np;
|
|
|
|
|
ip += strlen (ip) + 1, np += strlen (np) + 1)
|
|
|
|
|
{
|
2002-11-10 14:43:26 +01:00
|
|
|
|
if ((caddr_t)++ ifr > ifc->ifc_buf
|
|
|
|
|
+ ifc->ifc_len - sizeof (struct ifreq))
|
2001-06-26 16:47:48 +02:00
|
|
|
|
break;
|
|
|
|
|
|
2002-11-10 14:43:26 +01:00
|
|
|
|
if (!strncmp (bp, "NdisWan", 7))
|
2001-06-26 16:47:48 +02:00
|
|
|
|
{
|
|
|
|
|
strcpy (ifr->ifr_name, "ppp");
|
|
|
|
|
strcat (ifr->ifr_name, bp + 7);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
++*eth;
|
|
|
|
|
strcpy (ifr->ifr_name, "eth");
|
|
|
|
|
strcat (ifr->ifr_name, eth);
|
|
|
|
|
}
|
|
|
|
|
memset (&ifr->ifr_addr, '\0', sizeof ifr->ifr_addr);
|
|
|
|
|
if (cygwin_inet_addr (ip) == 0L
|
|
|
|
|
&& RegQueryValueEx (key, "DhcpIPAddress",
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
(unsigned char *) dhcpaddress,
|
|
|
|
|
(size = 256, &size))
|
|
|
|
|
== ERROR_SUCCESS
|
|
|
|
|
&& RegQueryValueEx (key, "DhcpSubnetMask",
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
(unsigned char *) dhcpnetmask,
|
|
|
|
|
(size = 256, &size))
|
|
|
|
|
== ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
switch (what)
|
|
|
|
|
{
|
2002-11-10 14:43:26 +01:00
|
|
|
|
case SIOCGIFCONF:
|
|
|
|
|
case SIOCGIFADDR:
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
|
|
|
|
sa->sin_addr.s_addr =
|
|
|
|
|
cygwin_inet_addr (dhcpaddress);
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFBRDADDR:
|
|
|
|
|
lip = cygwin_inet_addr (dhcpaddress);
|
|
|
|
|
lnp = cygwin_inet_addr (dhcpnetmask);
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
|
|
|
|
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFNETMASK:
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
|
|
|
|
sa->sin_addr.s_addr =
|
|
|
|
|
cygwin_inet_addr (dhcpnetmask);
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFHWADDR:
|
|
|
|
|
so = &ifr->ifr_hwaddr;
|
|
|
|
|
memset (so->sa_data, 0, IFHWADDRLEN);
|
|
|
|
|
so->sa_family = AF_INET;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFMETRIC:
|
|
|
|
|
ifr->ifr_metric = 1;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFMTU:
|
|
|
|
|
ifr->ifr_mtu = 1500;
|
|
|
|
|
break;
|
2001-06-26 16:47:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (what)
|
|
|
|
|
{
|
2002-11-10 14:43:26 +01:00
|
|
|
|
case SIOCGIFCONF:
|
|
|
|
|
case SIOCGIFADDR:
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
|
|
|
|
sa->sin_addr.s_addr = cygwin_inet_addr (ip);
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFBRDADDR:
|
|
|
|
|
lip = cygwin_inet_addr (ip);
|
|
|
|
|
lnp = cygwin_inet_addr (np);
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
|
|
|
|
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFNETMASK:
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
|
|
|
|
sa->sin_addr.s_addr = cygwin_inet_addr (np);
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFHWADDR:
|
|
|
|
|
so = &ifr->ifr_hwaddr;
|
|
|
|
|
memset (so->sa_data, 0, IFHWADDRLEN);
|
|
|
|
|
so->sa_family = AF_INET;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFMETRIC:
|
|
|
|
|
ifr->ifr_metric = 1;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFMTU:
|
|
|
|
|
ifr->ifr_mtu = 1500;
|
|
|
|
|
break;
|
2001-06-26 16:47:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
++cnt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
RegCloseKey (key);
|
|
|
|
|
}
|
2000-09-28 08:34:38 +02:00
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2000-09-28 08:34:38 +02:00
|
|
|
|
/* Set the correct length */
|
|
|
|
|
ifc->ifc_len = cnt * sizeof (struct ifreq);
|
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2000-10-02 22:21:47 +02:00
|
|
|
|
/*
|
2001-02-07 23:50:50 +01:00
|
|
|
|
* IFCONF Windows 95:
|
2000-10-02 22:21:47 +02:00
|
|
|
|
* HKLM/Enum/Network/MSTCP/"*"
|
2001-09-07 23:32:07 +02:00
|
|
|
|
* -> Value "Driver" enth<EFBFBD>lt Subkey relativ zu
|
|
|
|
|
* HKLM/System/CurrentControlSet/Class/
|
|
|
|
|
* -> In Subkey "Bindings" die Values aufz<EFBFBD>hlen
|
|
|
|
|
* -> Enth<EFBFBD>lt Subkeys der Form "VREDIR\*"
|
|
|
|
|
* Das * ist ein Subkey relativ zu
|
|
|
|
|
* HKLM/System/CurrentControlSet/Class/Net/
|
2000-10-02 22:21:47 +02:00
|
|
|
|
* HKLM/System/CurrentControlSet/Class/"Driver"
|
2001-09-07 23:32:07 +02:00
|
|
|
|
* -> Value "IPAddress"
|
|
|
|
|
* -> Value "IPMask"
|
2000-10-02 22:21:47 +02:00
|
|
|
|
* HKLM/System/CurrentControlSet/Class/Net/"*"(aus "VREDIR\*")
|
2001-09-07 23:32:07 +02:00
|
|
|
|
* -> Wenn Value "AdapterName" == "MS$PPP" -> ppp interface
|
|
|
|
|
* -> Value "DriverDesc" enth<EFBFBD>lt den Namen
|
2000-10-02 22:21:47 +02:00
|
|
|
|
*
|
|
|
|
|
*/
|
2000-09-28 08:34:38 +02:00
|
|
|
|
static void
|
2001-02-07 23:50:50 +01:00
|
|
|
|
get_95_ifconf (struct ifconf *ifc, int what)
|
2000-09-28 08:34:38 +02:00
|
|
|
|
{
|
2000-10-02 22:21:47 +02:00
|
|
|
|
HKEY key;
|
2000-09-28 08:34:38 +02:00
|
|
|
|
unsigned long lip, lnp;
|
2000-10-02 22:21:47 +02:00
|
|
|
|
struct sockaddr_in *sa = NULL;
|
2001-02-07 23:50:50 +01:00
|
|
|
|
struct sockaddr *so = NULL;
|
2000-09-28 08:34:38 +02:00
|
|
|
|
FILETIME update;
|
|
|
|
|
LONG res;
|
2000-10-02 22:21:47 +02:00
|
|
|
|
DWORD size;
|
2000-09-28 08:34:38 +02:00
|
|
|
|
int cnt = 1;
|
2000-10-02 22:21:47 +02:00
|
|
|
|
char ifname[256];
|
|
|
|
|
char eth[2] = "/";
|
|
|
|
|
char ppp[2] = "/";
|
2000-09-28 08:34:38 +02:00
|
|
|
|
|
|
|
|
|
/* Union maps buffer to correct struct */
|
|
|
|
|
struct ifreq *ifr = ifc->ifc_req;
|
|
|
|
|
|
2000-10-02 22:21:47 +02:00
|
|
|
|
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Enum\\Network\\MSTCP",
|
2001-06-26 16:47:48 +02:00
|
|
|
|
0, KEY_READ, &key) != ERROR_SUCCESS)
|
2000-10-02 22:21:47 +02:00
|
|
|
|
{
|
|
|
|
|
/* Set the correct length */
|
|
|
|
|
ifc->ifc_len = cnt * sizeof (struct ifreq);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0;
|
|
|
|
|
(res = RegEnumKeyEx (key, i, ifname,
|
2001-06-26 16:47:48 +02:00
|
|
|
|
(size = sizeof ifname, &size),
|
|
|
|
|
0, 0, 0, &update)) != ERROR_NO_MORE_ITEMS;
|
2000-10-02 22:21:47 +02:00
|
|
|
|
++i)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2000-10-02 22:21:47 +02:00
|
|
|
|
HKEY ifkey, subkey;
|
2001-10-10 21:28:19 +02:00
|
|
|
|
char driver[256], classname[256], netname[256];
|
2000-10-02 22:21:47 +02:00
|
|
|
|
char adapter[256], ip[256], np[256];
|
|
|
|
|
|
|
|
|
|
if (res != ERROR_SUCCESS
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|| RegOpenKeyEx (key, ifname, 0, KEY_READ, &ifkey) != ERROR_SUCCESS)
|
2001-06-26 16:47:48 +02:00
|
|
|
|
continue;
|
2000-10-02 22:21:47 +02:00
|
|
|
|
|
|
|
|
|
if (RegQueryValueEx (ifkey, "Driver", 0,
|
2001-06-26 16:47:48 +02:00
|
|
|
|
NULL, (unsigned char *) driver,
|
|
|
|
|
(size = sizeof driver, &size)) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
RegCloseKey (ifkey);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2000-10-02 22:21:47 +02:00
|
|
|
|
|
|
|
|
|
strcpy (classname, "System\\CurrentControlSet\\Services\\Class\\");
|
|
|
|
|
strcat (classname, driver);
|
|
|
|
|
if ((res = RegOpenKeyEx (HKEY_LOCAL_MACHINE, classname,
|
2001-06-26 16:47:48 +02:00
|
|
|
|
0, KEY_READ, &subkey)) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
RegCloseKey (ifkey);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2000-10-02 22:21:47 +02:00
|
|
|
|
|
|
|
|
|
if (RegQueryValueEx (subkey, "IPAddress", 0,
|
2001-06-26 16:47:48 +02:00
|
|
|
|
NULL, (unsigned char *) ip,
|
|
|
|
|
(size = sizeof ip, &size)) == ERROR_SUCCESS
|
|
|
|
|
&& RegQueryValueEx (subkey, "IPMask", 0,
|
|
|
|
|
NULL, (unsigned char *) np,
|
|
|
|
|
(size = sizeof np, &size)) == ERROR_SUCCESS)
|
|
|
|
|
{
|
2002-11-10 14:43:26 +01:00
|
|
|
|
if ((caddr_t)++ ifr > ifc->ifc_buf
|
|
|
|
|
+ ifc->ifc_len - sizeof (struct ifreq))
|
2001-06-26 16:47:48 +02:00
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
switch (what)
|
|
|
|
|
{
|
2002-11-10 14:43:26 +01:00
|
|
|
|
case SIOCGIFCONF:
|
|
|
|
|
case SIOCGIFADDR:
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
|
|
|
|
sa->sin_addr.s_addr = cygwin_inet_addr (ip);
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFBRDADDR:
|
|
|
|
|
lip = cygwin_inet_addr (ip);
|
|
|
|
|
lnp = cygwin_inet_addr (np);
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
|
|
|
|
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFNETMASK:
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
|
|
|
|
sa->sin_addr.s_addr = cygwin_inet_addr (np);
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFHWADDR:
|
|
|
|
|
so = &ifr->ifr_hwaddr;
|
|
|
|
|
memset (so->sa_data, 0, IFHWADDRLEN);
|
|
|
|
|
so->sa_family = AF_INET;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFMETRIC:
|
|
|
|
|
ifr->ifr_metric = 1;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFMTU:
|
|
|
|
|
ifr->ifr_mtu = 1500;
|
|
|
|
|
break;
|
2001-06-26 16:47:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-10-02 22:21:47 +02:00
|
|
|
|
|
|
|
|
|
RegCloseKey (subkey);
|
|
|
|
|
|
2001-10-10 21:28:19 +02:00
|
|
|
|
strcpy (netname, "System\\CurrentControlSet\\Services\\Class\\Net\\");
|
|
|
|
|
strcat (netname, ifname);
|
2000-10-02 22:21:47 +02:00
|
|
|
|
|
2001-10-10 21:28:19 +02:00
|
|
|
|
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, netname,
|
2002-11-10 14:43:26 +01:00
|
|
|
|
0, KEY_READ, &subkey) != ERROR_SUCCESS)
|
|
|
|
|
{
|
2001-11-05 07:09:15 +01:00
|
|
|
|
RegCloseKey (ifkey);
|
|
|
|
|
--ifr;
|
|
|
|
|
continue;
|
2002-11-10 14:43:26 +01:00
|
|
|
|
}
|
2000-10-02 22:21:47 +02:00
|
|
|
|
|
2001-10-10 21:28:19 +02:00
|
|
|
|
if (RegQueryValueEx (subkey, "AdapterName", 0,
|
2002-11-10 14:43:26 +01:00
|
|
|
|
NULL, (unsigned char *) adapter,
|
|
|
|
|
(size = sizeof adapter, &size)) == ERROR_SUCCESS
|
|
|
|
|
&& strcasematch (adapter, "MS$PPP"))
|
|
|
|
|
{
|
2001-11-05 07:09:15 +01:00
|
|
|
|
++*ppp;
|
|
|
|
|
strcpy (ifr->ifr_name, "ppp");
|
|
|
|
|
strcat (ifr->ifr_name, ppp);
|
2002-11-10 14:43:26 +01:00
|
|
|
|
}
|
2001-10-10 21:28:19 +02:00
|
|
|
|
else
|
2002-11-10 14:43:26 +01:00
|
|
|
|
{
|
2001-11-05 07:09:15 +01:00
|
|
|
|
++*eth;
|
|
|
|
|
strcpy (ifr->ifr_name, "eth");
|
|
|
|
|
strcat (ifr->ifr_name, eth);
|
2002-11-10 14:43:26 +01:00
|
|
|
|
}
|
2001-11-05 07:09:15 +01:00
|
|
|
|
|
2000-10-02 22:21:47 +02:00
|
|
|
|
RegCloseKey (subkey);
|
|
|
|
|
RegCloseKey (ifkey);
|
|
|
|
|
|
|
|
|
|
++cnt;
|
2000-09-28 08:34:38 +02:00
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2000-10-02 22:21:47 +02:00
|
|
|
|
out:
|
|
|
|
|
|
|
|
|
|
RegCloseKey (key);
|
|
|
|
|
|
2000-09-28 08:34:38 +02:00
|
|
|
|
/* Set the correct length */
|
|
|
|
|
ifc->ifc_len = cnt * sizeof (struct ifreq);
|
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2000-10-27 11:50:33 +02:00
|
|
|
|
int
|
2000-09-28 08:34:38 +02:00
|
|
|
|
get_ifconf (struct ifconf *ifc, int what)
|
|
|
|
|
{
|
|
|
|
|
unsigned long lip, lnp;
|
|
|
|
|
struct sockaddr_in *sa;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2001-11-24 04:11:39 +01:00
|
|
|
|
if (check_null_invalid_struct_errno (ifc))
|
|
|
|
|
return -1;
|
|
|
|
|
|
2000-09-28 08:34:38 +02:00
|
|
|
|
/* Union maps buffer to correct struct */
|
|
|
|
|
struct ifreq *ifr = ifc->ifc_req;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2000-09-28 08:34:38 +02:00
|
|
|
|
/* Ensure we have space for two struct ifreqs, fail if not. */
|
|
|
|
|
if (ifc->ifc_len < (int) (2 * sizeof (struct ifreq)))
|
|
|
|
|
{
|
|
|
|
|
set_errno (EFAULT);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2000-09-28 08:34:38 +02:00
|
|
|
|
/* Set up interface lo0 first */
|
2001-02-07 23:50:50 +01:00
|
|
|
|
strcpy (ifr->ifr_name, "lo");
|
2000-09-28 08:34:38 +02:00
|
|
|
|
memset (&ifr->ifr_addr, '\0', sizeof (ifr->ifr_addr));
|
|
|
|
|
switch (what)
|
|
|
|
|
{
|
2002-11-10 14:43:26 +01:00
|
|
|
|
case SIOCGIFCONF:
|
|
|
|
|
case SIOCGIFADDR:
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_addr;
|
|
|
|
|
sa->sin_addr.s_addr = htonl (INADDR_LOOPBACK);
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFBRDADDR:
|
|
|
|
|
lip = htonl (INADDR_LOOPBACK);
|
|
|
|
|
lnp = cygwin_inet_addr ("255.0.0.0");
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
|
|
|
|
|
sa->sin_addr.s_addr = lip & lnp | ~lnp;
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFNETMASK:
|
|
|
|
|
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
|
|
|
|
|
sa->sin_addr.s_addr = cygwin_inet_addr ("255.0.0.0");
|
|
|
|
|
sa->sin_family = AF_INET;
|
|
|
|
|
sa->sin_port = 0;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFHWADDR:
|
|
|
|
|
ifr->ifr_hwaddr.sa_family = AF_INET;
|
|
|
|
|
memset (ifr->ifr_hwaddr.sa_data, 0, IFHWADDRLEN);
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFMETRIC:
|
|
|
|
|
ifr->ifr_metric = 1;
|
|
|
|
|
break;
|
|
|
|
|
case SIOCGIFMTU:
|
|
|
|
|
/* This funny value is returned by `ifconfig lo' on Linux 2.2 kernel. */
|
|
|
|
|
ifr->ifr_mtu = 3924;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
set_errno (EINVAL);
|
|
|
|
|
return -1;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
2000-09-28 08:34:38 +02:00
|
|
|
|
|
|
|
|
|
OSVERSIONINFO os_version_info;
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2000-09-28 08:34:38 +02:00
|
|
|
|
memset (&os_version_info, 0, sizeof os_version_info);
|
|
|
|
|
os_version_info.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
|
|
|
|
GetVersionEx (&os_version_info);
|
* Makefile.in: Build wincap.o.
* wincap.cc: New file.
* wincap.h: Ditto.
* autoload.cc: Add dynamic load statement for `CreateHardLinkA'.
* dcrt0.cc (os_being_run): Eliminated.
(osname): Ditto.
(iswinnt): Ditto.
(set_os_type): Ditto.
(dll_crt0_1): Call wincap.init() instead of set_os_type().
(_dll_crt0): Ditto.
* environ.cc (set_chunksize): New function.
(parse_thing): `forkchunk' setting now invokes function `set_chunksize'.
* fork.cc (chunksize): Eliminated. Moved to be member of wincap.
* host_dependent.h: Removed.
* syscalls.cc (_link): Try using `CreateHardLinkA' first, if available.
* cygheap.cc, dcrt0.cc, delqueue.cc, dir.cc,
environ.cc, fhandler.cc, fhandler.h, fhandler_console.cc,
fhandler_mem.cc, fork.cc, mmap.cc, net.cc, pinfo.cc, pinfo.h,
security.cc, syscalls.cc, sysconf.cc, syslog.cc, thread.cc,
times.cc, tty.cc, uinfo.cc, uname.cc, winsup.h: Use new wincap
capability check throughout.
* winsup.h: Include wincap.h. Eliminate extern declarations of
`os_being_run' and `iswinnt'. Eliminate `os_type" definition.
* include/cygwin/version.h: Bump version to 1.3.4.
2001-09-12 19:46:37 +02:00
|
|
|
|
if (wincap.has_ip_helper_lib ())
|
|
|
|
|
get_2k_ifconf (ifc, what);
|
|
|
|
|
else if (wincap.is_winnt ())
|
2000-10-02 22:21:47 +02:00
|
|
|
|
get_nt_ifconf (ifc, what);
|
2000-09-28 08:34:38 +02:00
|
|
|
|
else
|
* Makefile.in: Build wincap.o.
* wincap.cc: New file.
* wincap.h: Ditto.
* autoload.cc: Add dynamic load statement for `CreateHardLinkA'.
* dcrt0.cc (os_being_run): Eliminated.
(osname): Ditto.
(iswinnt): Ditto.
(set_os_type): Ditto.
(dll_crt0_1): Call wincap.init() instead of set_os_type().
(_dll_crt0): Ditto.
* environ.cc (set_chunksize): New function.
(parse_thing): `forkchunk' setting now invokes function `set_chunksize'.
* fork.cc (chunksize): Eliminated. Moved to be member of wincap.
* host_dependent.h: Removed.
* syscalls.cc (_link): Try using `CreateHardLinkA' first, if available.
* cygheap.cc, dcrt0.cc, delqueue.cc, dir.cc,
environ.cc, fhandler.cc, fhandler.h, fhandler_console.cc,
fhandler_mem.cc, fork.cc, mmap.cc, net.cc, pinfo.cc, pinfo.h,
security.cc, syscalls.cc, sysconf.cc, syslog.cc, thread.cc,
times.cc, tty.cc, uinfo.cc, uname.cc, winsup.h: Use new wincap
capability check throughout.
* winsup.h: Include wincap.h. Eliminate extern declarations of
`os_being_run' and `iswinnt'. Eliminate `os_type" definition.
* include/cygwin/version.h: Bump version to 1.3.4.
2001-09-12 19:46:37 +02:00
|
|
|
|
get_95_ifconf (ifc, what);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as rcmd: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_rcmd (char **ahost, unsigned short inport, char *locuser,
|
2002-11-10 14:43:26 +01:00
|
|
|
|
char *remuser, char *cmd, int *fd2p)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
|
|
|
|
int res = -1;
|
|
|
|
|
SOCKET fd2s;
|
2003-02-20 15:14:37 +01:00
|
|
|
|
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2001-11-24 22:52:28 +01:00
|
|
|
|
if (check_null_invalid_struct_errno (ahost) ||
|
|
|
|
|
check_null_empty_str_errno (*ahost) ||
|
|
|
|
|
(locuser && check_null_empty_str_errno (locuser)) ||
|
|
|
|
|
(remuser && check_null_str_errno (remuser)))
|
|
|
|
|
return (int) INVALID_SOCKET;
|
|
|
|
|
|
2003-02-20 15:14:37 +01:00
|
|
|
|
res = rcmd (ahost, inport, locuser, remuser, cmd, fd2p ? &fd2s : NULL);
|
|
|
|
|
if (res != (int) INVALID_SOCKET)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2003-02-20 15:14:37 +01:00
|
|
|
|
cygheap_fdnew res_fd;
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
* 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
|
|
|
|
if (res_fd >= 0 && fdsock (res_fd, tcp_dev, res))
|
2003-07-05 20:20:13 +02:00
|
|
|
|
{
|
2004-04-10 15:45:10 +02:00
|
|
|
|
((fhandler_socket *) res_fd)->connect_state (connected);
|
2003-07-05 20:20:13 +02:00
|
|
|
|
res = res_fd;
|
|
|
|
|
}
|
2003-02-20 15:14:37 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
closesocket (res);
|
|
|
|
|
res = -1;
|
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2003-02-20 15:14:37 +01:00
|
|
|
|
if (res >= 0 && fd2p)
|
|
|
|
|
{
|
|
|
|
|
cygheap_fdnew newfd (res_fd, false);
|
* 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
|
|
|
|
cygheap_fdget fd (*fd2p);
|
2001-10-16 01:39:33 +02:00
|
|
|
|
|
* 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
|
|
|
|
if (newfd >= 0 && fdsock (newfd, tcp_dev, fd2s))
|
2003-07-05 20:20:13 +02:00
|
|
|
|
{
|
|
|
|
|
*fd2p = newfd;
|
2004-04-10 15:45:10 +02:00
|
|
|
|
((fhandler_socket *) fd2p)->connect_state (connected);
|
2003-07-05 20:20:13 +02:00
|
|
|
|
}
|
2003-02-20 15:14:37 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
closesocket (res);
|
|
|
|
|
closesocket (fd2s);
|
|
|
|
|
res = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-10-16 01:39:33 +02:00
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
syscall_printf ("%d = rcmd (...)", res);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as rresvport: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_rresvport (int *port)
|
|
|
|
|
{
|
2001-10-16 01:39:33 +02:00
|
|
|
|
int res;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2001-11-24 22:10:00 +01:00
|
|
|
|
if (check_null_invalid_struct_errno (port))
|
|
|
|
|
return -1;
|
|
|
|
|
|
2003-02-20 15:14:37 +01:00
|
|
|
|
res = rresvport (port);
|
2002-11-10 14:43:26 +01:00
|
|
|
|
|
2003-02-20 15:14:37 +01:00
|
|
|
|
if (res != (int) INVALID_SOCKET)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2003-02-20 15:14:37 +01:00
|
|
|
|
cygheap_fdnew res_fd;
|
2001-10-16 01:39:33 +02:00
|
|
|
|
|
* 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
|
|
|
|
if (res_fd >= 0 && fdsock (res_fd, tcp_dev, res))
|
2004-05-28 21:50:07 +02:00
|
|
|
|
res = res_fd;
|
2003-02-20 15:14:37 +01:00
|
|
|
|
else
|
|
|
|
|
res = -1;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
2001-10-16 01:39:33 +02:00
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
syscall_printf ("%d = rresvport (%d)", res, port ? *port : 0);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as rexec: standards? */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
|
cygwin_rexec (char **ahost, unsigned short inport, char *locuser,
|
2002-11-10 14:43:26 +01:00
|
|
|
|
char *password, char *cmd, int *fd2p)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
|
|
|
|
int res = -1;
|
|
|
|
|
SOCKET fd2s;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2001-11-24 22:52:28 +01:00
|
|
|
|
if (check_null_invalid_struct_errno (ahost) ||
|
|
|
|
|
check_null_empty_str_errno (*ahost) ||
|
|
|
|
|
(locuser && check_null_empty_str_errno (locuser)) ||
|
|
|
|
|
(password && check_null_str_errno (password)))
|
|
|
|
|
return (int) INVALID_SOCKET;
|
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
res = rexec (ahost, inport, locuser, password, cmd, fd2p ? &fd2s : NULL);
|
2003-02-20 15:14:37 +01:00
|
|
|
|
if (res != (int) INVALID_SOCKET)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2003-02-20 15:14:37 +01:00
|
|
|
|
cygheap_fdnew res_fd;
|
|
|
|
|
|
* 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
|
|
|
|
if (res_fd >= 0 && fdsock (res_fd, tcp_dev, res))
|
2003-07-05 20:20:13 +02:00
|
|
|
|
{
|
2004-04-10 15:45:10 +02:00
|
|
|
|
((fhandler_socket *) res_fd)->connect_state (connected);
|
2003-07-05 20:20:13 +02:00
|
|
|
|
res = res_fd;
|
|
|
|
|
}
|
2003-02-20 15:14:37 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
closesocket (res);
|
|
|
|
|
res = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (res >= 0 && fd2p)
|
|
|
|
|
{
|
|
|
|
|
cygheap_fdnew newfd (res_fd, false);
|
* 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
|
|
|
|
cygheap_fdget fd (*fd2p);
|
2003-02-20 15:14:37 +01:00
|
|
|
|
|
* 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
|
|
|
|
if (newfd >= 0 && fdsock (newfd, tcp_dev, fd2s))
|
2003-07-05 20:20:13 +02:00
|
|
|
|
{
|
2004-04-10 15:45:10 +02:00
|
|
|
|
((fhandler_socket *) fd2p)->connect_state (connected);
|
2003-07-05 20:20:13 +02:00
|
|
|
|
*fd2p = newfd;
|
|
|
|
|
}
|
2003-02-20 15:14:37 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
closesocket (res);
|
|
|
|
|
closesocket (fd2s);
|
|
|
|
|
res = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
2000-12-11 20:45:54 +01:00
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
|
syscall_printf ("%d = rexec (...)", res);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* socketpair: standards? */
|
|
|
|
|
/* Win32 supports AF_INET only, so ignore domain and protocol arguments */
|
2000-10-05 07:57:00 +02:00
|
|
|
|
extern "C" int
|
2002-01-04 17:56:53 +01:00
|
|
|
|
socketpair (int family, int type, int protocol, int *sb)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
|
|
|
|
int res = -1;
|
|
|
|
|
SOCKET insock, outsock, newsock;
|
2002-01-04 17:56:53 +01:00
|
|
|
|
struct sockaddr_in sock_in, sock_out;
|
|
|
|
|
int len;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-09-22 05:38:57 +02:00
|
|
|
|
if (__check_null_invalid_struct_errno (sb, 2 * sizeof (int)))
|
2001-11-24 22:10:00 +01:00
|
|
|
|
return -1;
|
|
|
|
|
|
2002-01-04 17:56:53 +01:00
|
|
|
|
if (family != AF_LOCAL && family != AF_INET)
|
|
|
|
|
{
|
|
|
|
|
set_errno (EAFNOSUPPORT);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
if (type != SOCK_STREAM && type != SOCK_DGRAM)
|
|
|
|
|
{
|
|
|
|
|
set_errno (EPROTOTYPE);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
if ((family == AF_LOCAL && protocol != PF_UNSPEC && protocol != PF_LOCAL)
|
|
|
|
|
|| (family == AF_INET && protocol != PF_UNSPEC && protocol != PF_INET))
|
|
|
|
|
{
|
|
|
|
|
set_errno (EPROTONOSUPPORT);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* create the first socket */
|
2000-02-17 20:38:33 +01:00
|
|
|
|
newsock = socket (AF_INET, type, 0);
|
|
|
|
|
if (newsock == INVALID_SOCKET)
|
|
|
|
|
{
|
2000-10-05 07:57:00 +02:00
|
|
|
|
debug_printf ("first socket call failed");
|
2000-02-17 20:38:33 +01:00
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* bind the socket to any unused port */
|
|
|
|
|
sock_in.sin_family = AF_INET;
|
|
|
|
|
sock_in.sin_port = 0;
|
|
|
|
|
sock_in.sin_addr.s_addr = INADDR_ANY;
|
|
|
|
|
if (bind (newsock, (struct sockaddr *) &sock_in, sizeof (sock_in)) < 0)
|
|
|
|
|
{
|
2000-10-05 07:57:00 +02:00
|
|
|
|
debug_printf ("bind failed");
|
2000-02-17 20:38:33 +01:00
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
closesocket (newsock);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
2002-01-04 17:56:53 +01:00
|
|
|
|
len = sizeof (sock_in);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
if (getsockname (newsock, (struct sockaddr *) &sock_in, &len) < 0)
|
|
|
|
|
{
|
|
|
|
|
debug_printf ("getsockname error");
|
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
closesocket (newsock);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-04 17:56:53 +01:00
|
|
|
|
/* For stream sockets, create a listener */
|
|
|
|
|
if (type == SOCK_STREAM)
|
|
|
|
|
listen (newsock, 2);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
|
|
/* create a connecting socket */
|
|
|
|
|
outsock = socket (AF_INET, type, 0);
|
|
|
|
|
if (outsock == INVALID_SOCKET)
|
|
|
|
|
{
|
2000-10-05 07:57:00 +02:00
|
|
|
|
debug_printf ("second socket call failed");
|
2000-02-17 20:38:33 +01:00
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
closesocket (newsock);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-04 17:56:53 +01:00
|
|
|
|
/* For datagram sockets, bind the 2nd socket to an unused address, too */
|
|
|
|
|
if (type == SOCK_DGRAM)
|
|
|
|
|
{
|
|
|
|
|
sock_out.sin_family = AF_INET;
|
|
|
|
|
sock_out.sin_port = 0;
|
|
|
|
|
sock_out.sin_addr.s_addr = INADDR_ANY;
|
|
|
|
|
if (bind (outsock, (struct sockaddr *) &sock_out, sizeof (sock_out)) < 0)
|
|
|
|
|
{
|
|
|
|
|
debug_printf ("bind failed");
|
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
closesocket (newsock);
|
|
|
|
|
closesocket (outsock);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
len = sizeof (sock_out);
|
|
|
|
|
if (getsockname (outsock, (struct sockaddr *) &sock_out, &len) < 0)
|
|
|
|
|
{
|
|
|
|
|
debug_printf ("getsockname error");
|
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
closesocket (newsock);
|
|
|
|
|
closesocket (outsock);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Force IP address to loopback */
|
2000-02-17 20:38:33 +01:00
|
|
|
|
sock_in.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
|
2002-01-04 17:56:53 +01:00
|
|
|
|
if (type == SOCK_DGRAM)
|
|
|
|
|
sock_out.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2002-01-04 17:56:53 +01:00
|
|
|
|
/* Do a connect */
|
2002-11-10 14:43:26 +01:00
|
|
|
|
if (connect (outsock, (struct sockaddr *) &sock_in, sizeof (sock_in)) < 0)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
|
|
|
|
debug_printf ("connect error");
|
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
closesocket (newsock);
|
|
|
|
|
closesocket (outsock);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-04 17:56:53 +01:00
|
|
|
|
if (type == SOCK_STREAM)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
{
|
2002-01-04 17:56:53 +01:00
|
|
|
|
/* For stream sockets, accept the connection and close the listener */
|
|
|
|
|
len = sizeof (sock_in);
|
|
|
|
|
insock = accept (newsock, (struct sockaddr *) &sock_in, &len);
|
|
|
|
|
if (insock == INVALID_SOCKET)
|
|
|
|
|
{
|
|
|
|
|
debug_printf ("accept error");
|
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
closesocket (newsock);
|
|
|
|
|
closesocket (outsock);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
closesocket (newsock);
|
2002-01-04 17:56:53 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* For datagram sockets, connect the 2nd socket */
|
|
|
|
|
if (connect (newsock, (struct sockaddr *) &sock_out,
|
2002-11-10 14:43:26 +01:00
|
|
|
|
sizeof (sock_out)) < 0)
|
2002-01-04 17:56:53 +01:00
|
|
|
|
{
|
|
|
|
|
debug_printf ("connect error");
|
|
|
|
|
set_winsock_errno ();
|
|
|
|
|
closesocket (newsock);
|
|
|
|
|
closesocket (outsock);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
insock = newsock;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-20 15:14:37 +01:00
|
|
|
|
{
|
|
|
|
|
cygheap_fdnew sb0;
|
* 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
|
|
|
|
const device *dev;
|
2003-02-20 15:14:37 +01:00
|
|
|
|
|
|
|
|
|
if (family == AF_INET)
|
* 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
|
|
|
|
dev = (type == SOCK_STREAM ? tcp_dev : udp_dev);
|
2003-02-20 15:14:37 +01:00
|
|
|
|
else
|
* 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
|
|
|
|
dev = (type == SOCK_STREAM ? stream_dev : dgram_dev);
|
2003-02-20 15:14:37 +01:00
|
|
|
|
|
* 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
|
|
|
|
if (sb0 >= 0 && fdsock (sb0, dev, insock))
|
2003-02-20 15:14:37 +01:00
|
|
|
|
{
|
* 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
|
|
|
|
((fhandler_socket *) sb0)->set_sun_path ("");
|
|
|
|
|
((fhandler_socket *) sb0)->set_addr_family (family);
|
|
|
|
|
((fhandler_socket *) sb0)->set_socket_type (type);
|
2004-04-10 15:45:10 +02:00
|
|
|
|
((fhandler_socket *) sb0)->connect_state (connected);
|
2005-02-28 14:11:50 +01:00
|
|
|
|
if (family == AF_LOCAL && type == SOCK_STREAM)
|
2005-03-24 15:04:06 +01:00
|
|
|
|
((fhandler_socket *) sb0)->af_local_set_sockpair_cred ();
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
2003-02-20 15:14:37 +01:00
|
|
|
|
cygheap_fdnew sb1 (sb0, false);
|
2002-01-04 17:56:53 +01:00
|
|
|
|
|
* 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
|
|
|
|
if (sb1 >= 0 && fdsock (sb1, dev, outsock))
|
2003-02-20 15:14:37 +01:00
|
|
|
|
{
|
* 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
|
|
|
|
((fhandler_socket *) sb1)->set_sun_path ("");
|
|
|
|
|
((fhandler_socket *) sb1)->set_addr_family (family);
|
|
|
|
|
((fhandler_socket *) sb1)->set_socket_type (type);
|
2004-04-10 15:45:10 +02:00
|
|
|
|
((fhandler_socket *) sb1)->connect_state (connected);
|
2005-02-28 14:11:50 +01:00
|
|
|
|
if (family == AF_LOCAL && type == SOCK_STREAM)
|
2005-03-24 15:04:06 +01:00
|
|
|
|
((fhandler_socket *) sb1)->af_local_set_sockpair_cred ();
|
2003-02-20 15:14:37 +01:00
|
|
|
|
|
|
|
|
|
sb[0] = sb0;
|
|
|
|
|
sb[1] = sb1;
|
|
|
|
|
res = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (res == -1)
|
|
|
|
|
{
|
2003-03-09 21:31:07 +01:00
|
|
|
|
closesocket (insock);
|
2003-02-20 15:14:37 +01:00
|
|
|
|
closesocket (outsock);
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
syscall_printf ("%d = socketpair (...)", res);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-26 12:13:41 +02:00
|
|
|
|
/* sethostent: standards? */
|
|
|
|
|
extern "C" void
|
|
|
|
|
sethostent (int)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* endhostent: standards? */
|
|
|
|
|
extern "C" void
|
|
|
|
|
endhostent (void)
|
|
|
|
|
{
|
|
|
|
|
}
|
2002-01-19 17:11:00 +01:00
|
|
|
|
|
|
|
|
|
/* exported as recvmsg: standards? */
|
2002-03-15 22:49:12 +01:00
|
|
|
|
extern "C" int
|
2002-08-08 19:03:20 +02:00
|
|
|
|
cygwin_recvmsg (int fd, struct msghdr *msg, int flags)
|
2002-06-26 21:25:09 +02:00
|
|
|
|
{
|
2002-08-08 19:03:20 +02:00
|
|
|
|
int res;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-08-27 11:24:50 +02:00
|
|
|
|
|
2002-08-08 19:03:20 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2002-01-19 17:11:00 +01:00
|
|
|
|
|
2002-08-08 19:03:20 +02:00
|
|
|
|
if (check_null_invalid_struct_errno (msg)
|
|
|
|
|
|| (msg->msg_name
|
|
|
|
|
&& __check_null_invalid_struct_errno (msg->msg_name,
|
|
|
|
|
(unsigned) msg->msg_namelen))
|
|
|
|
|
|| !fh)
|
|
|
|
|
res = -1;
|
|
|
|
|
else
|
2002-09-04 11:39:35 +02:00
|
|
|
|
{
|
|
|
|
|
res = check_iovec_for_read (msg->msg_iov, msg->msg_iovlen);
|
|
|
|
|
if (res > 0)
|
|
|
|
|
res = fh->recvmsg (msg, flags, res); // res == iovec tot
|
|
|
|
|
}
|
2002-08-08 19:03:20 +02:00
|
|
|
|
|
2002-08-27 11:24:50 +02:00
|
|
|
|
syscall_printf ("%d = recvmsg (%d, %p, %x)", res, fd, msg, flags);
|
2002-08-08 19:03:20 +02:00
|
|
|
|
return res;
|
2002-01-19 17:11:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* exported as sendmsg: standards? */
|
|
|
|
|
extern "C" int
|
2002-08-08 19:03:20 +02:00
|
|
|
|
cygwin_sendmsg (int fd, const struct msghdr *msg, int flags)
|
2002-06-26 21:25:09 +02:00
|
|
|
|
{
|
2002-08-08 19:03:20 +02:00
|
|
|
|
int res;
|
2003-08-19 06:10:42 +02:00
|
|
|
|
sig_dispatch_pending ();
|
2002-09-04 11:39:35 +02:00
|
|
|
|
|
2002-08-08 19:03:20 +02:00
|
|
|
|
fhandler_socket *fh = get (fd);
|
2002-06-26 21:25:09 +02:00
|
|
|
|
|
2002-08-08 19:03:20 +02:00
|
|
|
|
if (__check_invalid_read_ptr_errno (msg, sizeof msg)
|
|
|
|
|
|| (msg->msg_name
|
|
|
|
|
&& __check_invalid_read_ptr_errno (msg->msg_name,
|
|
|
|
|
(unsigned) msg->msg_namelen))
|
|
|
|
|
|| !fh)
|
|
|
|
|
res = -1;
|
2002-09-19 05:30:20 +02:00
|
|
|
|
else
|
2002-09-04 11:39:35 +02:00
|
|
|
|
{
|
|
|
|
|
res = check_iovec_for_write (msg->msg_iov, msg->msg_iovlen);
|
|
|
|
|
if (res > 0)
|
|
|
|
|
res = fh->sendmsg (msg, flags, res); // res == iovec tot
|
|
|
|
|
}
|
2002-08-08 19:03:20 +02:00
|
|
|
|
|
2002-08-27 11:24:50 +02:00
|
|
|
|
syscall_printf ("%d = sendmsg (%d, %p, %x)", res, fd, msg, flags);
|
2002-08-08 19:03:20 +02:00
|
|
|
|
return res;
|
2002-01-21 18:47:53 +01:00
|
|
|
|
}
|