diff options
author | Christopher Faylor <me@cgf.cx> | 2002-12-29 09:14:25 +0300 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-12-29 09:14:25 +0300 |
commit | 7df8e0165547649cd376a6a20cfadfe5bd966728 (patch) | |
tree | df6d7a2ed387cd40dba8efd1b0b1feeb7998a08b | |
parent | c3e4ae5c9efa2edf6d5605e79d49a6f330f5f7d6 (diff) |
* 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.
-rw-r--r-- | winsup/cygwin/syscalls.cc | 72 |
1 files changed, 64 insertions, 8 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 62c0cc26c..744b14ee3 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -797,7 +797,7 @@ chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid) /* FIXME: This makes chown on a device succeed always. Someday we'll want to actually allow chown to work properly on devices. */ - if (win32_path.is_device ()) + if (win32_path.is_auto_device ()) { res = 0; goto done; @@ -915,7 +915,7 @@ chmod (const char *path, mode_t mode) /* FIXME: This makes chmod on a device succeed always. Someday we'll want to actually allow chmod to work properly on devices. */ - if (win32_path.is_device ()) + if (win32_path.is_auto_device ()) { res = 0; goto done; @@ -1547,7 +1547,7 @@ pathconf (const char *file, int v) set_errno (full_path.error); return -1; } - if (full_path.is_device ()) + if (full_path.is_auto_device ()) { set_errno (EINVAL); return -1; @@ -1927,16 +1927,73 @@ regfree () fileutils) assume its existence so we must provide a stub that always fails. */ extern "C" int -mknod (const char *_path, mode_t mode, dev_t dev) +mknod (const char *path, mode_t mode, dev_t dev) { - set_errno (ENOSYS); - return -1; + if (check_null_empty_str_errno (path)) + return -1; + + if (strlen (path) >= MAX_PATH) + return -1; + + path_conv w32path (path, PC_SYM_NOFOLLOW | PC_FULL); + if (w32path.exists ()) + { + set_errno (EEXIST); + return -1; + } + + mode_t prot = mode & (S_IRWXU | S_IRWXG | S_IRWXO); + mode &= S_IFMT; + if (!mode || mode == S_IFREG) + { + int fd = open (path, O_CREAT, prot); + if (fd < 0) + return -1; + close (fd); + return 0; + } + + char buf[sizeof (":00000000:00000000:X") + MAX_PATH]; + + _devtype_t ch; + if (mode == S_IFCHR) + ch = 'c'; + else if (mode == S_IFBLK) + ch = 'b'; + else if (mode == S_IFIFO) + { + dev = FH_FIFO; + ch = 's'; + } + else + { + set_errno (EINVAL); + return -1; + } + + _major_t major = dev >> 8 /* SIGH. _major (dev) */; + _minor_t minor = dev & 0xff /* SIGH _minor (dev) */; + + sprintf (buf, ":%x:%x:%c", major, minor, ch); + if (symlink_worker (buf, w32path, true, true)) + return -1; + + strcat (w32path, ".lnk"); + if (chmod (w32path, prot)) + return -1; + + if (!SetFileAttributes (w32path, FILE_ATTRIBUTE_READONLY)) + { + __seterrno (); + return -1; + } + + return 0; } extern "C" int mkfifo (const char *_path, mode_t mode) { - set_errno (ENOSYS); return -1; } @@ -1944,7 +2001,6 @@ mkfifo (const char *_path, mode_t mode) extern "C" int seteuid32 (__uid32_t uid) { - debug_printf ("uid: %d myself->gid: %d", uid, myself->gid); if (!wincap.has_security () |