From fbb3991a37b1909318935db904cc7e7ca53a1d98 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 25 Jan 2003 18:59:43 +0000 Subject: * Makefile.in (DLL_OFILES): Add fhandler_nodevice.o. * devices.gperf (device::parse): Just set devn to input if device not found -- nonexistent device will be caught later. * dtable.cc (dtable::build_fhandler): Build fhandler_nodevice type when unknown device. * fhandler.h (fhandler_nodevice): New class. (fhandler_union): Add fhandler_nodevice. * path.cc (path_conv::check): Always set device stuff if major/minor are specified. --- winsup/cygwin/ChangeLog.branch | 230 +++++++++++++++++++++++++++++++++++++ winsup/cygwin/Makefile.in | 4 +- winsup/cygwin/devices.gperf | 3 + winsup/cygwin/dtable.cc | 9 +- winsup/cygwin/fhandler.h | 8 ++ winsup/cygwin/fhandler_nodevice.cc | 40 +++++++ winsup/cygwin/path.cc | 11 +- 7 files changed, 287 insertions(+), 18 deletions(-) create mode 100644 winsup/cygwin/ChangeLog.branch create mode 100644 winsup/cygwin/fhandler_nodevice.cc diff --git a/winsup/cygwin/ChangeLog.branch b/winsup/cygwin/ChangeLog.branch new file mode 100644 index 00000000000..57040dcb069 --- /dev/null +++ b/winsup/cygwin/ChangeLog.branch @@ -0,0 +1,230 @@ +2003-01-25 Christopher Faylor + + * Makefile.in (DLL_OFILES): Add fhandler_nodevice.o. + * devices.gperf (device::parse): Just set devn to input if device not + found -- nonexistent device will be caught later. + * dtable.cc (dtable::build_fhandler): Build fhandler_nodevice type when + unknown device. + * fhandler.h (fhandler_nodevice): New class. + (fhandler_union): Add fhandler_nodevice. + * path.cc (path_conv::check): Always set device stuff if major/minor + are specified. + +2003-01-04 Christopher Faylor + + * pinfo.cc (_pinfo::commune_send): Use myself->lock rather than just lock when + leaving. + +2003-01-04 Christopher Faylor + + Replace is_fs_device with is_fs_special throughout. + * Makefile.in (DLL_OFILES): Add fhandler_fifo.o. + * devices.h (fh_devices): Renumber some minor numbers to fit in 8 bits. + * dtable.cc (dtable::build_fhandler): Handle FH_FIFO. Set errno to ENODEV if + device not found. + * dtable::find_fifo: Define new function. + * dtable.h (dtable::find_fifo): Declare new function. + * fhandler.cc (fhandler_base::device_access_denied): Fix O_RDONLY test. + (fhandler_base::write): Use output file handle for writing. + (fhandler_base::fstat): Use is_fs_special rather than is_fs_device. + * fhandler.h (fhandler_base::is_fs_special): Rename from is_fs_device. + (fhandler_pipe): Make private elements protected so that fhandler_fifo can use + them too. + (fhandler_pipe::create): New function derived from make_pipe. + (fhandler_fifo): Add more needed elements. + (fhandler_pty_master::slave): Add to track slave device. + (fhandler_pty_master::get_unit): Define. + * fhandler_tty.cc (fhandler_tty_master::init): Register slave device. + (fhandler_pty_master::open): Ditto. + (symlink_info::parse_device): Handle fifo specially. + * pinfo.cc (_pinfo::commune_recv): Initial fifo implementation. + (_pinfo::commune_send): Ditto. + * pinfo.h (picom): Add PICOM_FIFO. + * pipe.cc (fhandler_pipe::close): Close input handle here specifically. + (fhandler_pipe::create): Rename from make_pipe. Create fhandlers rather than + fds. + (pipe): Use fhandler_pipe::create to create pipe. + (_pipe): Ditto. + * syscalls.cc (mknod): Accommodate fifos. + +2003-01-04 Christopher Faylor + + * fhandler_tty.cc (fhandler_tty_slave::get_unit): Fix test for tty unit number + based on whether this is just a /dev/tty or a /dev/ttyN. + +2003-01-02 Christopher Faylor + + * dtable.h (dtable::in_vfork_cleanup): New function. True if vfork cleanup + needed. + * dtable.cc (dtable::vfork_parent_restore): Remove assertion. + * pipe.cc (fhandler_pipe::close): Don't close read_state during fork_fixup + since it wasn't inherited. + +2003-01-01 Christopher Faylor + + * devices.h (_devtype_t): Eliminate. + (_mode_t): New typedef. + (device::mode): Replace type. + * fhandler.h (fhandler_base::device_access_denied): Declare new function. + * fhandler.cc (fhandler_base::device_access_denied): Define new function. + * fhandler_disk_file.cc (fhandler_base::fstat_helper): Just copy mode directly + from dev.mode to st_mode if it is a disk device. + * path.cc (path_conv::check): Set device mode from sym mode. + (symlink_worker): Let "exists" check happen when file is attempted to be + opened, or not, in the case of creating a device. + (symlink_info::parse_device): Change device type argument to device mode + argument. + (mknod_worker): New function. + (chmod_device): Ditto. + (chmod): Use chmod_device to set protection if it is an fs device. + (mknod): Use mknod_worker to actually create the device. Don't take any + special action with the protection since it is now implicit. + +2003-01-01 Christopher Faylor + + * passwd.cc (getpwuid_r32): Revert previous change. + +2003-01-01 Christopher Faylor + + * sysconf.cc (sysconf): Return arbitrary values for _SC_GETGR_R_SIZE_MAX, + _SC_LOGIN_NAME_MAX, _SC_GETPW_R_SIZE_MAX. + * passwd.cc (getpwuid_r32): Add uid/gid fields to size check calculation. + * exceptions.cc (events_init): Display name of mutex on failure. + * windows.cc (setitimer): Return ENOSYS on invalid argument. + +2002-12-28 Christopher Faylor + + * cygwin-gperf: New file. + * Makefile.in: Use cygwin-gperf script to build devices.cc. + * configure.in: Remove some comments. + * configure: Regenerate. + * devices.gperf: Remove max unit determination from FH_TTY. Add /dev/kmem. + Add /dev/fifo. Add /dev/rawdrive. Remove specific "const device *" + declarations since they are now autogenerated. + (device::parse): Treat FH_TTY specially. Move logic for determining real tty + device to separate function. + (device::init): Reduce to nothing. + (device::parse): New function taking different arguments. + (device::parse): Ditto. + (device::tty_to_real_device): New function. + * devices.h (struct device): Define above new functions. + (device::dev_on_fs): New element. + (device::setfs): New function. + (device::isfs): Ditto. + * dtable.cc (dtable::build_fhandler): Treat FH_TTY specially. + * fhandler.cc (fhandler_base::set_name): Make special determination for + non-disk-resident devices. + * fhandler.h (fhandler_base::isdevice): Renamed from 'is_device'. + (fhandler_disk_file::isdevice): Ditto. + (fhandler_base::is_auto_device): New function. + (fhandler_base::is_fs_device): New function. + (fhandler_tty_slave::get_unit): Declare. + (fhandler_disk_file::readdir): Take special .lnk consideration for devices as + well as symlinks. + * fhandler_tty.cc: Use get_unit () rather than dev.minor throughout. + (fhandler_tty_slave::get_unit): Define new function. + * path.cc (symlink_info::major): New element. + (symlink_info::major): Ditto. + (symlink_info::devtype): Ditto. + (path_conv::check): Handle devices detected by symlink_info::check. + (win32_device_name): Eliminate special FH_TTY handling. + (symlink): Move bulk of procesing to symlink_worker. + (symlink_worker): New function. Handles devices. + (symlink_info::parse_device): Parse info from potential device file into + symlink_info elements. + (symlink_info::check): If contents of .lnk file begin with a ':' then treat the + file as a device file. + * path.h (isdevice): Renamed from is_device. + (is_auto_device): New function. + (is_fs_device): Ditto. + * syscalls.cc (chown_worker): Allow setting of ownership for on-disk devices. + (chmod): Ditto. + (mknod): Implement. + * winsup.h (symlink_worker): Declare. + +2002-12-28 Christopher Faylor + + Eliminate device number argument from fhandler constructors throughout. + +2002-12-28 Christopher Faylor + + Eliminate unit argument and special unit fields from fhandler classes and + constructors throughout. + * fhandler_mem.cc (fhandler_dev_mem::fhandler_dev_mem): Make decisions based on + specific device type rather than unit number. + * fhandler_random.cc (fhandler_dev_random::write): Ditto. + (fhandler_dev_random::read): Ditto. + * fhandler_socket.cc (fhandler_socket::set_connect_secret): Set device type to + "urandom" after construction of entropy_source. + * path.cc (windows_devices_names): Remove. + +2002-12-27 Christopher Faylor + + * Makefile.in: Add devices.gperf. + * devices.h: New file. + * devices.gperf: Ditto. + +2002-12-27 Christopher Faylor + + Introduce device class to cygwin throughout. Rename FH_DISK to FH_FS + throughout. + * dcrt0.cc (dll_crt0_1): Initialize device globals via device::init. + * dtable.cc (dtable::init_std_file_from_handle): Use device numbers rather than + names when they are known. Should speed up process startup slightly. + (dtable::build_fhandler_from_name): Pass path_conv device to build_fhandler. + (dtable::build_fhandler): Accept device argument rather than separate + device/unit arguments. + (dtable::build_fhandler): Ditto. Separate switch statement by devices which + take units and those which don't. Build unix/win32 names from device if + required. + (dtable::dup_worker): Reflect changes to build_fhandler arguments. + * dtable.h (dtable::build_fhandler): Ditto. + * fhandler.cc (fhandler_base::set_name): Eliminate unit argument. Use get_unit + to derive unit. + * fhandler.h: Separate FH device defines into devices.h include. Define + is_slow as appropriate for each fhandler_class. + (fhandler_base::dev): New element. + (fhandler_base::fhandler_base): Eliminate unit argument. + (fhandler_base::get_device): Return device number. + (fhandler_base::get_major): Return device major number. + (fhandler_base::get_minor): Return device minor number. + (fhandler_base::get_unit): Ditto. + (fhandler_base::get_native_name): Return device format field. + (fhandler_fifo): 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_cygdrive::fhandler_cygdrive): Remove unit + initialization. + * fhandler_tty.cc (fhandler_tty_master::init_console): Use "console_dev" global + to initialize captive console used by tty master. + * mmap.cc (mmap_record::devtype_): Remove. + (mmap_record::dev): New. + (mmap_record::mmap_record): Use dev. + (mmap_record::get_device): Implement via dev. + * net.cc (fdsock): Use socket_dev global to initialize socket fhandler. + * path.cc (path_conv::check): Accommodate new path_conv::dev element. + (get_devn): Eliminate. + (get_raw_device_number): Ditto. + (get_device_number): Ditto. + (win32_device_name): Accept dev argument. Use it. Use device::parse to derive + potential device name. + (mount_info::conv_to_win32_path): Accept dev argument. Use it. + * path.h (path_conv::devn): Eliminate. + (path_conv::unit): Ditto. + (path_conv::dev): Declare. + (path_conv::path_conv): Don't initialize deleted members. + (path_conv::is_device): Implement via dev element. + (path_conv::get_devn): Ditto. + (path_conv::get_unitn): Ditto. + * pipe.cc (make_pipe): Use pipe[rw]_dev in fhandler construction. + * select.cc: Use new device_specific_* select class elements + * shared_info.h (CURR_MOUNT_MAGIC): Update. + (mount_info::conv_to_win32_path): Reflect new arguments. + * syscalls.cc (fstat64): Just use get_device() without interpretation for + st_dev element. + (stat_worker): Ditto. + * tty.cc (create_tty_master): Use ttym_dev in fhandler constructor. + (tty::common_init): Check for tty major device number rather than FH_TTYM. diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index a577e76a4dd..f124d74767c 100644 --- a/winsup/cygwin/Makefile.in +++ b/winsup/cygwin/Makefile.in @@ -152,8 +152,8 @@ DLL_OFILES:=assert.o autoload.o cxx.o cygheap.o cygserver_client.o \ exceptions.o exec.o external.o fcntl.o fhandler.o \ fhandler_clipboard.o fhandler_console.o fhandler_disk_file.o \ fhandler_dsp.o fhandler_fifo.o fhandler_floppy.o fhandler_mem.o \ - fhandler_proc.o fhandler_process.o fhandler_random.o \ - fhandler_raw.o fhandler_registry.o fhandler_serial.o \ + fhandler_nodevice.o fhandler_proc.o fhandler_process.o \ + fhandler_random.o fhandler_raw.o fhandler_registry.o fhandler_serial.o \ fhandler_socket.o fhandler_tape.o fhandler_termios.o \ fhandler_tty.o fhandler_virtual.o fhandler_windows.o \ fhandler_zero.o fnmatch.o fork.o glob.o grp.o heap.o init.o ioctl.o \ diff --git a/winsup/cygwin/devices.gperf b/winsup/cygwin/devices.gperf index 4dd2eb278b8..a7d7043566d 100644 --- a/winsup/cygwin/devices.gperf +++ b/winsup/cygwin/devices.gperf @@ -107,6 +107,7 @@ struct device; "//./x:", FH_RAWDRIVE, "\\DosDevices\\%c:", 0, 0, 0, 0 "//./y:", FH_RAWDRIVE, "\\DosDevices\\%c:", 0, 0, 0, 0 "//./z:", FH_RAWDRIVE, "\\DosDevices\\%c:", 0, 0, 0, 0 +":bad:", FH_BAD, ":bad:", 0, 0, 0, 0 %% void device::parse (const char *s) @@ -179,6 +180,8 @@ device::parse (_major_t major, _minor_t minor) } out: + if (!*this) + devn = FHDEV (major, minor); return; } diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 6342e22231f..5f1ffb98ec2 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -431,14 +431,7 @@ dtable::build_fhandler (int fd, const device& dev, char *unix_name, } if (!fh) - { - set_errno (ENODEV); -#ifdef DEBUGGING - system_printf ("unknown device - %p, '%s', upper %d", - (int) dev, dev.name, dev.upper); - return NULL; -#endif - } + fh = cnew (fhandler_nodevice) (); char w32buf[MAX_PATH + 1]; if (!unix_name || !*unix_name) diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 337d40e5adf..930f199b713 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -1168,6 +1168,13 @@ class fhandler_process: public fhandler_proc bool fill_filebuf (); }; +struct fhandler_nodevice: public fhandler_base +{ + fhandler_nodevice (); + int open (path_conv *real_path, int flags, mode_t mode = 0); + // int __stdcall fstat (struct __stat64 *buf, path_conv *); +}; + typedef union { char __base[sizeof (fhandler_base)]; @@ -1196,6 +1203,7 @@ typedef union char __tty_slave[sizeof (fhandler_tty_slave)]; char __virtual[sizeof (fhandler_virtual)]; char __windows[sizeof (fhandler_windows)]; + char __nodevice[sizeof (fhandler_nodevice)]; } fhandler_union; struct select_record diff --git a/winsup/cygwin/fhandler_nodevice.cc b/winsup/cygwin/fhandler_nodevice.cc new file mode 100644 index 00000000000..8f2b26c6dbe --- /dev/null +++ b/winsup/cygwin/fhandler_nodevice.cc @@ -0,0 +1,40 @@ +/* fhandler.cc. See console.cc for fhandler_console functions. + + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. + +This file is part of Cygwin. + +This software is a copyrighted work licensed under the terms of the +Cygwin license. Please consult the file "CYGWIN_LICENSE" for +details. */ + +#include "winsup.h" +#include +#include +#include +#include +#include +#include +#include "cygerrno.h" +#include "perprocess.h" +#include "security.h" +#include "cygwin/version.h" +#include "fhandler.h" +#include "path.h" +#include "dtable.h" +#include "cygheap.h" +#include "shared_info.h" +#include "pinfo.h" +#include +#include + +int +fhandler_nodevice::open (path_conv *, int, mode_t) +{ + set_errno (ENODEV); + return 0; +} + +fhandler_nodevice::fhandler_nodevice () +{ +} diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index a53fa997fa6..319e09ae7fd 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -615,14 +615,9 @@ path_conv::check (const char *src, unsigned opt, if (sym.minor || sym.major) { dev.parse (sym.major, sym.minor); - if (!dev) - error = ENODEV; - else - { - dev.setfs (1); - dev.mode = sym.mode; - fileattr = sym.fileattr; - } + dev.setfs (1); + dev.mode = sym.mode; + fileattr = sym.fileattr; goto out; } -- cgit v1.2.1