newlib/winsup/cygwin/devices.shilka

433 lines
12 KiB
Plaintext
Raw Normal View History

* 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
%import {
#include "winsup.h"
#include <sys/types.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.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", 0, 0, 0, 0};
const device dev_fs_storage =
{"", FH_FS, "", 0, 0, 0, 0};
const device dev_proc_storage =
{"", FH_PROC, "", 0, 0, 0, 0};
const device dev_registry_storage =
{"", FH_REGISTRY, "", 0, 0, 0, 0};
const device dev_process_storage =
{"", FH_PROCESS, "", 0, 0, 0, 0};
const device dev_tcp_storage =
{"/dev/inet/tcp", FH_TCP, "", 0, 0, 0, 0};
const device dev_udp_storage =
{"/dev/inet/udp", FH_UCP, "", 0, 0, 0, 0};
const device dev_icmp_storage =
{"/dev/inet/icmp", FH_ICMP, "", 0, 0, 0, 0};
const device dev_unix_storage =
{"/dev/inet/unix", FH_UNIX, "", 0, 0, 0, 0};
const device dev_stream_storage =
{"/dev/inet/stream", FH_STREAM, "", 0, 0, 0, 0};
const device dev_dgram_storage =
{"/dev/inet/dgram", FH_DGRAM, "", 0, 0, 0, 0};
const device dev_piper_storage =
{"", FH_PIPER, "", 0, 0, 0, 0};
const device dev_pipew_storage =
{"", FH_PIPEW, "", 0, 0, 0, 0};
const device dev_tty_storage =
{"/dev/tty", FH_TTY, "\\dev\\tty", 0, 0, 0, 0};
const device dev_ttys_storage =
{"/dev/ttys", FH_TTYS, "\\dev\\tty%d", 0, 255, 0, 0};
const device dev_console_storage =
{"/dev/console", FH_CONSOLE, "\\dev\\console", 0, 0, 0, 0};
const device dev_ttym_storage =
{"/dev/ttym", FH_TTYM, "\\dev\\ttym", 0, 255, 0, 0};
const device dev_ptym_storage =
{"/dev/ptmx", FH_PTYM, "\\dev\\ptmx", 0, 0, 0, 0};
const device dev_windows_storage =
{"/dev/windows", FH_WINDOWS, "\\dev\\windows", 0, 0, 0, 0};
const device dev_oss_dsp_storage =
{"/dev/dsp", FH_OSS_DSP, "\\dev\\dsp", 0, 0, 0, 0};
const device dev_conin_storage =
{"/dev/conin", FH_CONIN, "conin", 0, 0, 0, 0};
const device dev_conout_storage =
{"/dev/conout", FH_CONOUT, "conout", 0, 0, 0, 0};
const device dev_null_storage =
{"/dev/null", FH_NULL, "nul", 0, 0, 0, 0};
const device dev_zero_storage =
{"/dev/zero", FH_ZERO, "\\dev\\zero", 0, 0, 0, 0};
const device dev_random_storage =
{"/dev/random", FH_RANDOM, "\\dev\\random", 0, 0, 0, 0};
const device dev_urandom_storage =
{"/dev/urandom", FH_URANDOM, "\\dev\\urandom", 0, 0, 0, 0};
const device dev_mem_storage =
{"/dev/mem", FH_MEM, "\\dev\\mem", 0, 0, 0, 0};
const device dev_kmem_storage =
{"/dev/kmem", FH_KMEM, "\\dev\\mem", 0, 0, 0, 0};
const device dev_clipboard_storage =
{"/dev/clipboard", FH_CLIPBOARD, "\\dev\\clipboard", 0, 0, 0, 0};
const device dev_port_storage =
{"/dev/port", FH_PORT, "\\dev\\port", 0, 0, 0, 0};
const device dev_serial_storage =
{"/dev/com", FH_SERIAL, "\\.\\com%d", 1, 99};
const device dev_ttyS_storage =
{"/dev/ttyS", FH_SERIAL, "\\.\\com%d", 0, 99, -1};
const device dev_pipe_storage =
{"/dev/pipe", FH_PIPE, "\\dev\\pipe", 0, 0, 0, 0};
const device dev_fifo_storage =
{"/dev/fifo", FH_FIFO, "\\dev\\fifo", 0, 0, 0, 0};
const device dev_tape_storage =
{"/dev/st", FH_TAPE, "\\Device\\Tape%d", 0, 127};
const device dev_nst_storage =
{"/dev/nst", FH_NTAPE, "\\Device\\Tape%d", 0, 127};
const device dev_floppy_storage =
{"/dev/fd", FH_FLOPPY, "\\Device\\Floppy%d", 0, 15};
const device dev_cdrom_storage =
{"/dev/scd", FH_CDROM, "\\Device\\CdRom%d", 0, 15};
const device dev_sr_storage =
{"/dev/sr", FH_CDROM, "\\Device\\CdRom%d", 0, 15};
const device dev_hda_storage =
{"/dev/hda", FH_SDA, "\\Device\\Harddisk%d\\Partition%d", 1, 16, -1};
const device dev_hdb_storage =
{"/dev/hdb", FH_SDB, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 15};
const device dev_hdc_storage =
{"/dev/hdc", FH_SDC, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 31};
const device dev_hdd_storage =
{"/dev/hdd", FH_SDD, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 47};
const device dev_hde_storage =
{"/dev/hde", FH_SDE, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 63};
const device dev_hdf_storage =
{"/dev/hdf", FH_SDF, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 79};
const device dev_hdg_storage =
{"/dev/hdg", FH_SDG, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 95};
const device dev_hdh_storage =
{"/dev/hdh", FH_SDH, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 111};
const device dev_hdi_storage =
{"/dev/hdi", FH_SDI, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 127};
const device dev_hdj_storage =
{"/dev/hdj", FH_SDJ, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 143};
const device dev_hdk_storage =
{"/dev/hdk", FH_SDK, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 159};
const device dev_hdl_storage =
{"/dev/hdl", FH_SDL, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 175};
const device dev_hdm_storage =
{"/dev/hdm", FH_SDM, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 191};
const device dev_hdn_storage =
{"/dev/hdn", FH_SDN, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 207};
const device dev_hdo_storage =
{"/dev/hdo", FH_SDO, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 223};
const device dev_hdp_storage =
{"/dev/hdp", FH_SDP, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 239};
const device dev_hdq_storage =
{"/dev/hdq", FH_SDQ, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 255 /* FIXME 8 bit lunacy */};
const device dev_hdr_storage =
{"/dev/hdr", FH_SDR, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 271};
const device dev_hds_storage =
{"/dev/hds", FH_SDS, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 287};
const device dev_hdt_storage =
{"/dev/hdt", FH_SDT, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 303};
const device dev_hdu_storage =
{"/dev/hdu", FH_SDU, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 319};
const device dev_hdv_storage =
{"/dev/hdv", FH_SDV, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 335};
const device dev_hdw_storage =
{"/dev/hdw", FH_SDW, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 351};
const device dev_hdx_storage =
{"/dev/hdx", FH_SDX, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 367};
const device dev_hdy_storage =
{"/dev/hdy", FH_SDY, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 383};
const device dev_hdz_storage =
{"/dev/hdz", FH_SDZ, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 399};
const device dev_rawdrive_storage =
{"/dev/rawdrive", FH_RAWDRIVE, "\\DosDevices\\%c:", 0, 0, 0, 0};
const device dev_bad_storage =
{":bad:", FH_BAD, ":bad:", 0, 0, 0, 0};
#define bad_dev (&dev_bad_storage)
const device *unit_devices[] =
{
&dev_cdrom_storage,
&dev_serial_storage,
&dev_ttym_storage,
&dev_ttys_storage,
&dev_floppy_storage,
&dev_tcp_storage,
&dev_rawdrive_storage,
&dev_tape_storage
};
const device *uniq_devices[] =
{
&dev_bad_storage,
&dev_fs_storage,
&dev_process_storage,
&dev_registry_storage,
&dev_proc_storage,
&dev_fifo_storage,
&dev_pipew_storage,
&dev_piper_storage,
&dev_pipe_storage,
&dev_mem_storage,
&dev_kmem_storage,
&dev_null_storage,
&dev_zero_storage,
&dev_port_storage,
&dev_random_storage,
&dev_urandom_storage,
&dev_tty_storage,
&dev_console_storage,
&dev_ptym_storage,
&dev_conout_storage,
&dev_conin_storage,
&dev_clipboard_storage,
&dev_windows_storage,
&dev_oss_dsp_storage,
&dev_serial_storage
};
}
%%
"/dev/tty" = tty {return &dev_tty_storage;}
"/dev/ttys" = ttys {return &dev_ttys_storage;}
"/dev/console" = console {return &dev_console_storage;}
"/dev/ttym" = ttym {return &dev_ttym_storage;}
"/dev/ptmx" = ptmx {return &dev_ptym_storage;}
"/dev/windows" = windows {return &dev_windows_storage;}
"/dev/dsp" = dsp {return &dev_oss_dsp_storage;}
"/dev/conin" = conin {return &dev_conin_storage;}
"/dev/conout" = conout {return &dev_conout_storage;}
"/dev/null" = null {return &dev_null_storage;}
"/dev/zero" = zero {return &dev_zero_storage;}
"/dev/random" = random {return &dev_random_storage;}
"/dev/urandom" = urandom {return &dev_urandom_storage;}
"/dev/mem" = mem {return &dev_mem_storage;}
"/dev/kmem" = kmem {return &dev_kmem_storage;}
"/dev/clipboard" = clipboard {return &dev_clipboard_storage;}
"/dev/port" = port {return &dev_port_storage;}
"/dev/com" = com {return &dev_serial_storage;}
"/dev/ttyS" = ttyS {return &dev_ttyS_storage;}
"/dev/pipe" = pipe {return &dev_pipe_storage;}
"/dev/fifo" = fifo {return &dev_fifo_storage;}
"/dev/st" = st {return &dev_tape_storage;}
"/dev/nst" = nst {return &dev_nst_storage;}
"/dev/fd" = fd {return &dev_floppy_storage;}
"/dev/scd" = scd {return &dev_cdrom_storage;}
"/dev/sr" = sr {return &dev_sr_storage;}
"/dev/hda" = hda {return &dev_hda_storage;}
"/dev/hdb" = hdb {return &dev_hdb_storage;}
"/dev/hdc" = hdc {return &dev_hdc_storage;}
"/dev/hdd" = hdd {return &dev_hdd_storage;}
"/dev/hde" = hde {return &dev_hde_storage;}
"/dev/hdf" = hdf {return &dev_hdf_storage;}
"/dev/hdg" = hdg {return &dev_hdg_storage;}
"/dev/hdh" = hdh {return &dev_hdh_storage;}
"/dev/hdi" = hdi {return &dev_hdi_storage;}
"/dev/hdj" = hdj {return &dev_hdj_storage;}
"/dev/hdk" = hdk {return &dev_hdk_storage;}
"/dev/hdl" = hdl {return &dev_hdl_storage;}
"/dev/hdm" = hdm {return &dev_hdm_storage;}
"/dev/hdn" = hdn {return &dev_hdn_storage;}
"/dev/hdo" = hdo {return &dev_hdo_storage;}
"/dev/hdp" = hdp {return &dev_hdp_storage;}
"/dev/hdq" = hdq {return &dev_hdq_storage;}
"/dev/hdr" = hdr {return &dev_hdr_storage;}
"/dev/hds" = hds {return &dev_hds_storage;}
"/dev/hdt" = hdt {return &dev_hdt_storage;}
"/dev/hdu" = hdu {return &dev_hdu_storage;}
"/dev/hdv" = hdv {return &dev_hdv_storage;}
"/dev/hdw" = hdw {return &dev_hdw_storage;}
"/dev/hdx" = hdx {return &dev_hdx_storage;}
"/dev/hdy" = hdy {return &dev_hdy_storage;}
"/dev/hdz" = hdz {return &dev_hdz_storage;}
"/dev/sda" = hda {return &dev_hda_storage;}
"/dev/sdb" = hdb {return &dev_hdb_storage;}
"/dev/sdc" = hdc {return &dev_hdc_storage;}
"/dev/sdd" = hdd {return &dev_hdd_storage;}
"/dev/sde" = hde {return &dev_hde_storage;}
"/dev/sdf" = hdf {return &dev_hdf_storage;}
"/dev/sdg" = hdg {return &dev_hdg_storage;}
"/dev/sdh" = hdh {return &dev_hdh_storage;}
"/dev/sdi" = hdi {return &dev_hdi_storage;}
"/dev/sdj" = hdj {return &dev_hdj_storage;}
"/dev/sdk" = hdk {return &dev_hdk_storage;}
"/dev/sdl" = hdl {return &dev_hdl_storage;}
"/dev/sdm" = hdm {return &dev_hdm_storage;}
"/dev/sdn" = hdn {return &dev_hdn_storage;}
"/dev/sdo" = hdo {return &dev_hdo_storage;}
"/dev/sdp" = hdp {return &dev_hdp_storage;}
"/dev/sdq" = hdq {return &dev_hdq_storage;}
"/dev/sdr" = hdr {return &dev_hdr_storage;}
"/dev/sds" = hds {return &dev_hds_storage;}
"/dev/sdt" = hdt {return &dev_hdt_storage;}
"/dev/sdu" = hdu {return &dev_hdu_storage;}
"/dev/sdv" = hdv {return &dev_hdv_storage;}
"/dev/sdw" = hdw {return &dev_hdw_storage;}
"/dev/sdx" = hdx {return &dev_hdx_storage;}
"/dev/sdy" = hdy {return &dev_hdy_storage;}
"/dev/sdz" = hdz {return &dev_hdz_storage;}
* 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/rawdrive" = rawdrive {return &dev_rawdrive_storage;}
%other {return NULL;}
%%
void
device::parse (const char *s)
{
size_t len = strlen (s);
const device *dev = KR_find_keyword (s, len);
unsigned unit = 0;
if (!dev || !*dev)
{
size_t prior_len = len;
while (len-- > 0 && isdigit (s[len]))
continue;
if (++len < prior_len)
{
dev = KR_find_keyword (s, len);
if (!dev || (!dev->upper && !dev->devn == FH_TTY))
dev = NULL;
else
{
unsigned n = atoi (s + len);
if (dev->devn == FH_TTY)
dev = ttys_dev; // SIGH
if (n >= dev->lower && n <= dev->upper)
unit = n;
}
}
}
if (!dev || !*dev)
*this = *fs_dev;
else if (dev->devn == FH_TTY)
tty_to_real_device ();
else
{
*this = *dev;
if (!setunit (unit))
devn = 0;
}
}
void
device::init ()
{
/* nothing to do... yet */
}
void
device::parse (_major_t major, _minor_t minor)
{
_dev_t dev = FHDEV (major, 0);
devn = 0;
unsigned i;
for (i = 0; i < (sizeof (unit_devices) / sizeof (unit_devices[0])); i++)
if (unit_devices[i]->devn == dev)
{
*this = *unit_devices[i];
this->setunit (minor);
goto out;
}
dev = FHDEV (major, minor);
for (i = 0; i < (sizeof (uniq_devices) / sizeof (uniq_devices[0])); i++)
if (uniq_devices[i]->devn == dev)
{
*this = *uniq_devices[i];
break;
}
out:
if (!*this)
devn = FHDEV (major, minor);
return;
}
void
device::parse (_dev_t dev)
{
parse (_major (dev), _minor (dev));
}
void
device::tty_to_real_device ()
{
if (!real_tty_attached (myself))
*this = myself->ctty < 0 ? *bad_dev : *console_dev;
else
{
*this = *ttys_dev;
setunit (myself->ctty);
}
}