mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-15 19:09:58 +08:00
44d2fc0a45
* child_info.h: Redefine CURR_CHILD_INFO_MAGIC. (child_info_fork::abort): Rename from handle_failure. Change arguments. * cygtls.h (_local_storage::ttybuf): New field. * dcrt0.cc (vapi_fatal): Split api_fatal. Add "in forked process" to message when appropriate. (api_fatal): Use vapi_fatal. * devices.h: Make multiple inclusion safe. (fh_devices): Add FH_CONS* stuff. Reorder slightly. (device): Eliminate anonymous union. Add more ways to access minor/major. (device::setunit): Accommodate no-longer-anonymous union. (device::is_fs): Ditto. (device::is_fs_special): Ditto. (device::major): New function. (device::minor): Ditto. (device::is_device): New function. (device::not_device): Ditto. (device::operator int): New operator. (device::operator fh_devices): Ditto. (device::operator bool): Ditto. (device::operator DWORD): Ditto. (device::operator =): Ditto. (isproc_dev): New function. (isprocsys_dev): Ditto. (iscons_dev): Ditto. (istty_slave_dev): Ditto. * devices.in: Add new "/dev/cons*" strings. Accommodate no-longer-anonymous union throughout. (BRACK): Use more precise method for initialization. * devices.cc: Regenerate. * dtable.cc (dtable::stdio_init): Use get_cttyp instead of get_tty. (dtable::find_archetype): Use new DWORD operator in device to test archetypes. (dtable::init_std_file_from_handle): Use different method to initialize 'dev'. Adapt to different ctty handling and accommodate /dev/cons*. (fh_alloc): Accommodate no-longer-anonymous union. Adapt to new /dev/cons*. (build_fh_pc): Make debugging output more useful. * exceptions.cc (ctrl_c_handler): Use get_cttyp instead of get_tty. * external.cc (fillout_pinfo): Accommodate new cons* stuff. * fhandler.cc (fhandler_base::read): Eliminate is_slow() test. * fhandler.h (fhandler_base::*): Adapt to changes in device.h. (fhandler_*::is_slow): Delete. ( fhandler_proc::get_proc_fhandler): Return fh_devices type. * fhandler_console.cc (open_shared_console): New function. (console_unit): New class. (console_unit::console_unit): New constructor. (enum_windows): New function. Declare as friend to console_unit. (fhandler_console::set_unit): New function. (fhandler_console::get_tty_stuff): Call set_unit to set the unit number and determine if initialization is needed. Eliminate flags parameter. (tty_list::get_cttyp): Rename (sorta) from get_tty. Return pointer to correct tty_min. (fhandler_console::open): Adapt to elimination of argument to get_tty_stuff. (fhandler_console::output_tcsetattr): Properly detect error condition. (fhandler_console::fixup_after_fork_exec): Adapt to get_tty_stuff() setting tc automatically. * fhandler_proc.cc: Use FH_BAD rather than 0 throughout where using fh_devices enum. (fhandler_proc::get_proc_fhandler): Return fh_devices. Adapt to devices.h changes. * fhandler_process.cc: Adapt to devices.h changes. Use FH_BAD rather than 0 throughout where using fh_devices enum. * fhandler_procnet.cc: Ditto. * fhandler_procsys.cc: Ditto. * fhandler_procsysvipc.cc: Ditto. * fhandler_tape.cc (fhandler_dev_tape::fhandler_dev_tape): Ditto. * fhandler_termios.cc (handler_termios::bg_check): Use tc->ttyname() rather than assuming that we can construct a tty. * fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Just return get_minor() of dev. (fhandler_pty_master::process_slave_output): Add slightly more debugging info. (fhandler_tty_slave::fhandler_tty_slave): Change name from ntty to unit. (fhandler_pty_master::open): Ditto. (fhandler_tty_slave::ioctl): Adapt to change which causes ctty to represent a complete device. (fhandler_tty_master::init_console): Add debugging for failure path. (fhandler_pty_master::setup): Use get_unit() to retrieve unit number rather than relying on raw ntty. (fhandler_pty_master::setup): Ditto. * fhandler_virtual.h (virt_tab_t): Redefine fhandler as fh_devices. * fork.cc: Remove obsolete vfork stuff. (frok::child): Don't assume that a ctty == 0 is valid. * mount.cc (mount_info::conv_to_win32_path): Adapt to device struct changes. (mount_info::conv_to_win32_path): Ditto. * path.cc (path_conv::check): Retrive major/minor numbers via a method rather than accessing them directly from device. Rely on dev operators to set/retrieve device information as required by device struct change. * path.h (isproc_dev): Move to devices.h. (isprocsys_dev): Ditto. (isvirtual_dev): Ditto. (path_conv:{isdevice,isfifo,isspecial,iscygdrive,issocket,get_devn,get_unitn}): Use device methods to access/manipulate devices. * pinfo.cc (pinfo::exit): Don't assume that ctty == 0 is valid. Use iscons_dev to determine if a device is a console. (_pinfo::_ctty): Use device::parse to generate tty/cons name. (_pinfo::set_ctty): Don't assume that ctty == 0 is valid. Remove redundant info from debugging. * shared.cc (offsets): Remove console offset. * shared_info.h (shared_locations): Ditto. * syscalls.cc (umask): Use device methods to manipulate device information. (ctermid): Use device::parse to generate term device name. * tlsoffsets.h: Regenerate. * tty.cc (ttyslot): Return minor number of ctty since ctty now represents a full device. (tty::create_master): Set ctty to a complete device. (tty_list::attach): Rework to detect new /dev/cons* stuff. (tty_list::terminate): Adapt to changes to ctty. (tty_list::init): Adapt to change to setntty - pass in device major number. (tty::exists): Use get_unit() to retrive tty unit number. (tty::open_mutex): Ditto. (tty::open_inuse): Ditto. (tty::create_inuse): Ditto. (tty::get_event): Ditto. (tty_min::ttyname): Define new function. * tty.h (tty_min::ntty): Redefine as fh_devices. (tty::exists): Use get_unit() to retrive tty unit number. (tty::open_mutex): Ditto. (tty::open_inuse): Ditto. (tty::create_inuse): Ditto. (tty::get_event): Ditto. (tty_min::ttyname): Declare new function. (tty::getntty): Declare as const. (tty_list::operator []): Assure that only minor part of argument is used. * dll_init.cc (dll_list::alloc): Detect mismatch of data segments early issuing an explicit error message if necessary. * heap.cc (heap_init): Adapt to changes from fork->handle_failure to fork->abort. * pinfo.h (EXITCODE_FORK_FAILED): New enum. (from Ryan Johnson) * sigproc.cc (child_info_fork::abort): Rename from handle_failure. Change arguments to allow passing in a printf-like message. * winsup.h (api_fatal): Delete macro definition. (api_fatal): Redefine from __api_fatal. (vapi_fatal): Declare new function. * include/sys/strace.h (strace_vprintf): Define new macro. * ntdll.h (_SYSTEM_INFORMATION_CLASS): Add SystemHandleInformation.
195 lines
5.6 KiB
Plaintext
195 lines
5.6 KiB
Plaintext
%import {
|
|
#include "winsup.h"
|
|
#include "devices.h"
|
|
#include "sys/cygwin.h"
|
|
#include "tty.h"
|
|
#include "pinfo.h"
|
|
typedef const device *KR_device_t;
|
|
}
|
|
%type KR_device_t
|
|
%local {
|
|
const device dev_cygdrive_storage =
|
|
{"/cygdrive", {FH_CYGDRIVE}, "/cygdrive"};
|
|
|
|
const device dev_fs_storage =
|
|
{"", {FH_FS}, ""};
|
|
|
|
const device dev_proc_storage =
|
|
{"", {FH_PROC}, ""};
|
|
|
|
const device dev_procnet_storage =
|
|
{"", {FH_PROCNET}, ""};
|
|
|
|
const device dev_procsys_storage =
|
|
{"", {FH_PROCSYS}, ""};
|
|
|
|
const device dev_procsysvipc_storage =
|
|
{"", {FH_PROCSYSVIPC}, ""};
|
|
|
|
const device dev_netdrive_storage =
|
|
{"", {FH_NETDRIVE}, ""};
|
|
|
|
#if 0
|
|
const device dev_dev_storage =
|
|
{"/dev", {FH_DEV}, "/dev"};
|
|
#endif
|
|
|
|
const device dev_registry_storage =
|
|
{"", {FH_REGISTRY}, ""};
|
|
|
|
const device dev_piper_storage =
|
|
{"", {FH_PIPER}, ""};
|
|
|
|
const device dev_pipew_storage =
|
|
{"", {FH_PIPEW}, ""};
|
|
|
|
const device dev_tcp_storage =
|
|
{"", {FH_TCP}, ""};
|
|
|
|
const device dev_udp_storage =
|
|
{"", {FH_UDP}, ""};
|
|
|
|
const device dev_stream_storage =
|
|
{"", {FH_STREAM}, ""};
|
|
|
|
const device dev_dgram_storage =
|
|
{"", {FH_DGRAM}, ""};
|
|
|
|
const device dev_bad_storage =
|
|
{"", {FH_BAD}, ""};
|
|
#define BRACK(x) {devn_int: x}
|
|
|
|
%storage_here
|
|
}
|
|
%%
|
|
"/dev/tty", BRACK(FH_TTY), "/dev/tty"
|
|
"/dev/tty%(0-63)d", BRACK(FHDEV(DEV_TTYS_MAJOR, {$1})), "/dev/tty{$1}", ttys_dev
|
|
"/dev/cons%(0-63)d", BRACK(FHDEV(DEV_CONS_MAJOR, {$1})), "/dev/cons{$1}", cons_dev
|
|
"/dev/console", BRACK(FH_CONSOLE), "/dev/console", console_dev
|
|
"/dev/ttym", BRACK(FH_TTYM), "/dev/ttym", ttym_dev
|
|
"/dev/ptmx", BRACK(FH_PTYM), "/dev/ptmx"
|
|
"/dev/windows", BRACK(FH_WINDOWS), "/dev/windows"
|
|
"/dev/dsp", BRACK(FH_OSS_DSP), "/dev/dsp"
|
|
"/dev/conin", BRACK(FH_CONIN), "/dev/conin"
|
|
"/dev/conout", BRACK(FH_CONOUT), "/dev/conout"
|
|
"/dev/null", BRACK(FH_NULL), "\\Device\\Null"
|
|
"/dev/zero", BRACK(FH_ZERO), "/dev/zero"
|
|
"/dev/full", BRACK(FH_FULL), "/dev/full"
|
|
"/dev/random", BRACK(FH_RANDOM), "/dev/random"
|
|
"/dev/urandom", BRACK(FH_URANDOM), "/dev/urandom", urandom_dev
|
|
"/dev/mem", BRACK(FH_MEM), "/dev/mem"
|
|
"/dev/kmem", BRACK(FH_KMEM), "/dev/mem"
|
|
"/dev/clipboard", BRACK(FH_CLIPBOARD), "/dev/clipboard"
|
|
"/dev/port", BRACK(FH_PORT), "/dev/port"
|
|
"/dev/com%(1-16)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1 - 1})), "\\??\\COM{$1}"
|
|
"/dev/ttyS%(0-63)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1})), "\\??\\COM{$1 + 1}"
|
|
"/dev/pipe", BRACK(FH_PIPE), "/dev/pipe"
|
|
"/dev/fifo", BRACK(FH_FIFO), "/dev/fifo"
|
|
"/dev/st%(0-127)d", BRACK(FHDEV(DEV_TAPE_MAJOR, {$1})), "\\Device\\Tape{$1}"
|
|
"/dev/nst%(0-127)d", BRACK(FHDEV(DEV_TAPE_MAJOR, {$1 + 128})), "\\Device\\Tape{$1}"
|
|
"/dev/fd%(0-15)d", BRACK(FHDEV(DEV_FLOPPY_MAJOR, {$1})), "\\Device\\Floppy{$1}"
|
|
"/dev/scd%(0-15)d", BRACK(FHDEV(DEV_CDROM_MAJOR, {$1})), "\\Device\\CdRom{$1}"
|
|
"/dev/sr%(0-15)d", BRACK(FHDEV(DEV_CDROM_MAJOR, {$1})), "\\Device\\CdRom{$1}"
|
|
"/dev/sd%{a-z}s", BRACK(FH_SD{uc $1}), "\\Device\\Harddisk{ord($1) - ord('a')}\\Partition0"
|
|
"/dev/sda%{a-z}s", BRACK(FH_SDA{uc $1}), "\\Device\\Harddisk{26 + ord($1) - ord('a')}\\Partition0"
|
|
"/dev/sdb%{a-z}s", BRACK(FH_SDB{uc $1}), "\\Device\\Harddisk{52 + ord($1) - ord('a')}\\Partition0"
|
|
"/dev/sdc%{a-z}s", BRACK(FH_SDC{uc $1}), "\\Device\\Harddisk{78 + ord($1) - ord('a')}\\Partition0"
|
|
"/dev/sdd%{a-x}s", BRACK(FH_SDD{uc $1}), "\\Device\\Harddisk{104 + ord($1) - ord('a')}\\Partition0"
|
|
"/dev/sd%{a-z}s%(1-15)d", BRACK(FH_SD{uc $1} | {$2}), "\\Device\\Harddisk{ord($1) - ord('a')}\\Partition{$2 % 16}"
|
|
"/dev/sda%{a-z}s%(1-15)d", BRACK(FH_SDA{uc $1} | {$2}), "\\Device\\Harddisk{26 + ord($1) - ord('a')}\\Partition{$2 % 16}"
|
|
"/dev/sdb%{a-z}s%(1-15)d", BRACK(FH_SDB{uc $1} | {$2}), "\\Device\\Harddisk{52 + ord($1) - ord('a')}\\Partition{$2 % 16}"
|
|
"/dev/sdc%{a-z}s%(1-15)d", BRACK(FH_SDC{uc $1} | {$2}), "\\Device\\Harddisk{78 + ord($1) - ord('a')}\\Partition{$2 % 16}"
|
|
"/dev/sdd%{a-x}s%(1-15)d", BRACK(FH_SDD{uc $1} | {$2}), "\\Device\\Harddisk{104 + ord($1) - ord('a')}\\Partition{$2 % 16}"
|
|
"/dev/kmsg", BRACK(FH_KMSG), "\\Device\\MailSlot\\cygwin\\dev\\kmsg"
|
|
"/dev", BRACK(FH_DEV), "/dev"
|
|
%other {return NULL;}
|
|
%%
|
|
#undef BRACK
|
|
void
|
|
device::parse (const char *s)
|
|
{
|
|
size_t len = strlen (s);
|
|
const device *dev = KR_find_keyword (s, len);
|
|
|
|
if (!dev)
|
|
*this = *fs_dev;
|
|
else
|
|
*this = *dev;
|
|
}
|
|
|
|
void
|
|
device::init ()
|
|
{
|
|
/* nothing to do... yet */
|
|
}
|
|
|
|
void
|
|
device::parse (_major_t major, _minor_t minor)
|
|
{
|
|
_dev_t dev = FHDEV (major, minor);
|
|
|
|
d.devn = 0;
|
|
|
|
for (unsigned i = 0; i < (sizeof (dev_storage) / sizeof (dev_storage[0])); i++)
|
|
if (dev_storage[i].d.devn == dev)
|
|
{
|
|
*this = dev_storage[i];
|
|
break;
|
|
}
|
|
|
|
if (!*this)
|
|
d.devn = FHDEV (major, minor);
|
|
}
|
|
|
|
void
|
|
device::parse (_dev_t dev)
|
|
{
|
|
parse (_major (dev), _minor (dev));
|
|
}
|
|
|
|
void
|
|
device::parsedisk (int drive, int part)
|
|
{
|
|
int base;
|
|
if (drive < ('q' - 'a')) /* /dev/sda -to- /dev/sdp */
|
|
base = DEV_SD_MAJOR;
|
|
else if (drive < 32) /* /dev/sdq -to- /dev/sdaf */
|
|
{
|
|
base = DEV_SD1_MAJOR;
|
|
drive -= 'q' - 'a';
|
|
}
|
|
else if (drive < 48) /* /dev/sdag -to- /dev/sdav */
|
|
{
|
|
base = DEV_SD2_MAJOR;
|
|
drive -= 32;
|
|
}
|
|
else if (drive < 64) /* /dev/sdaw -to- /dev/sdbl */
|
|
{
|
|
base = DEV_SD3_MAJOR;
|
|
drive -= 48;
|
|
}
|
|
else if (drive < 80) /* /dev/sdbm -to- /dev/sdcb */
|
|
{
|
|
base = DEV_SD4_MAJOR;
|
|
drive -= 64;
|
|
}
|
|
else if (drive < 96) /* /dev/sdcc -to- /dev/sdcr */
|
|
{
|
|
base = DEV_SD5_MAJOR;
|
|
drive -= 80;
|
|
}
|
|
else if (drive < 112) /* /dev/sdcs -to- /dev/sddh */
|
|
{
|
|
base = DEV_SD6_MAJOR;
|
|
drive -= 96;
|
|
}
|
|
/* NOTE: This will cause multiple /dev/sddx entries in
|
|
/proc/partitions if there are more than 128 devices */
|
|
else /* /dev/sddi -to- /dev/sddx */
|
|
{
|
|
base = DEV_SD7_MAJOR;
|
|
drive -= 112;
|
|
}
|
|
parse (base, part + (drive * 16));
|
|
}
|