diff options
author | Christopher Faylor <me@cgf.cx> | 2003-02-23 07:03:23 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-02-23 07:03:23 +0000 |
commit | 9c79d272120fcebc17b6bc8ad234b18087360437 (patch) | |
tree | 1f7d014063c7112704c3574a8bc5422f30b73371 | |
parent | 0ed07f363baf2965d2387ada0a29a07616e1da0f (diff) | |
download | newlib-9c79d272120fcebc17b6bc8ad234b18087360437.zip newlib-9c79d272120fcebc17b6bc8ad234b18087360437.tar.gz newlib-9c79d272120fcebc17b6bc8ad234b18087360437.tar.bz2 |
* cygwin-gperf: Fix typo in FH_FS static storage.
* devices.gperf (device::parse): Default to fs "device" when nothing else is
found.
* fhandler.cc (fhandler_base::device_access_denied): Use access_worker rather
than access to avoid reparsing pc.
* fhandler_nodevice.cc (fhandler_nodevice::open): Set errno to ENXIO rather
than ENODEV.
* path.cc (path_conv::check): Default to FH_FS rather than FH_BAD.
(mount_info::conv_to_win32_path): Ditto.
(win32_device_name): Don't do device handling if FH_FS.
* path.h (path_conv::get_devn): Just return raw device number.
* syscalls.cc (access_worker): New function, split from access(). Correctly
deal with special devices in light of recent ntsec changes.
(access): Use access_worker.
-rw-r--r-- | winsup/cygwin/ChangeLog.branch | 17 | ||||
-rwxr-xr-x | winsup/cygwin/cygwin-gperf | 2 | ||||
-rw-r--r-- | winsup/cygwin/devices.gperf | 2 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_nodevice.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/path.cc | 12 | ||||
-rw-r--r-- | winsup/cygwin/path.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 40 |
8 files changed, 54 insertions, 27 deletions
diff --git a/winsup/cygwin/ChangeLog.branch b/winsup/cygwin/ChangeLog.branch index c93eb39..83c8445 100644 --- a/winsup/cygwin/ChangeLog.branch +++ b/winsup/cygwin/ChangeLog.branch @@ -1,5 +1,22 @@ 2003-02-23 Christopher Faylor <cgf@redhat.com> + * cygwin-gperf: Fix typo in FH_FS static storage. + * devices.gperf (device::parse): Default to fs "device" when nothing + else is found. + * fhandler.cc (fhandler_base::device_access_denied): Use access_worker + rather than access to avoid reparsing pc. + * fhandler_nodevice.cc (fhandler_nodevice::open): Set errno to ENXIO + rather than ENODEV. + * path.cc (path_conv::check): Default to FH_FS rather than FH_BAD. + (mount_info::conv_to_win32_path): Ditto. + (win32_device_name): Don't do device handling if FH_FS. + * path.h (path_conv::get_devn): Just return raw device number. + * syscalls.cc (access_worker): New function, split from access(). + Correctly deal with special devices in light of recent ntsec changes. + (access): Use access_worker. + +2003-02-23 Christopher Faylor <cgf@redhat.com> + * fhandler.cc (fhandler_base::set_name): Explicitly set posix name. (fhandler_base::dup): Ditto. diff --git a/winsup/cygwin/cygwin-gperf b/winsup/cygwin/cygwin-gperf index 0d490a6..4a989af 100755 --- a/winsup/cygwin/cygwin-gperf +++ b/winsup/cygwin/cygwin-gperf @@ -35,7 +35,7 @@ static const device cygdrive_dev_storage = {"/cygdrive", FH_CYGDRIVE, "/cygdrive", 0, 0, 0, 0}; static const device fs_dev_storage = - {"", FH_CYGDRIVE, "", 0, 0, 0, 0}; + {"", FH_FS, "", 0, 0, 0, 0}; static const device proc_dev_storage = {"", FH_PROC, "", 0, 0, 0, 0}; diff --git a/winsup/cygwin/devices.gperf b/winsup/cygwin/devices.gperf index 8162db5..8e013e3 100644 --- a/winsup/cygwin/devices.gperf +++ b/winsup/cygwin/devices.gperf @@ -104,7 +104,7 @@ device::parse (const char *s) } if (!dev || !*dev) - devn = 0; + *this = *fs_dev; else if (dev->devn == FH_TTY) tty_to_real_device (); else diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 3a9173e..6242d2b 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -320,6 +320,8 @@ bool fhandler_base::device_access_denied (int flags) { int mode = 0; + int access_worker (path_conv&, int); + if (flags & O_RDWR) mode |= R_OK | W_OK; if (flags & (O_WRONLY | O_APPEND)) @@ -327,7 +329,7 @@ fhandler_base::device_access_denied (int flags) if (!mode) mode |= R_OK; - return ::access (get_win32_name (), mode); + return access_worker (pc, mode); } /* Open system call handler function. */ diff --git a/winsup/cygwin/fhandler_nodevice.cc b/winsup/cygwin/fhandler_nodevice.cc index fba7900..22281d5 100644 --- a/winsup/cygwin/fhandler_nodevice.cc +++ b/winsup/cygwin/fhandler_nodevice.cc @@ -31,7 +31,7 @@ details. */ int fhandler_nodevice::open (int, mode_t) { - set_errno (ENODEV); + set_errno (ENXIO); return 0; } diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 5d15e9b..cad759a 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -554,7 +554,7 @@ path_conv::check (const char *src, unsigned opt, fileattr = FILE_ATTRIBUTE_DIRECTORY; else { - dev.devn = FH_BAD; + dev.devn = FH_FS; fileattr = GetFileAttributes (this->path); } goto out; @@ -581,7 +581,7 @@ path_conv::check (const char *src, unsigned opt, goto out; } /* devn should not be a device. If it is, then stop parsing now. */ - else if (dev.devn != FH_BAD) + else if (dev.devn != FH_FS) { fileattr = 0; path_flags = sym.pflags; @@ -795,7 +795,7 @@ out: return; } - if (dev.devn == FH_BAD) + if (dev.devn == FH_FS) { if (!fs.update (path)) { @@ -891,7 +891,7 @@ win32_device_name (const char *src_path, char *win32_path, device& dev) { dev.parse (src_path); - if (dev.devn == FH_BAD) + if (dev.devn == FH_FS) return false; switch (dev.devn) @@ -1176,7 +1176,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev, unsigned dummy_flags; int chroot_ok = !cygheap->root.exists (); - dev.devn = FH_BAD; + dev.devn = FH_FS; if (!flags) flags = &dummy_flags; @@ -1488,7 +1488,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path, if (!*p || !p[1]) nextchar = 0; - else if (*p == '/') + else if (isdirsep (*p)) nextchar = -1; else nextchar = 1; diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index 912ea6b..9836d9e 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -167,7 +167,7 @@ class path_conv operator DWORD &() {return fileattr;} operator int () {return fileattr; } char operator [](int i) const {return path[i];} - DWORD get_devn () {return dev.devn == FH_BAD ? (DWORD) FH_FS : dev.devn;} + DWORD get_devn () {return dev.devn;} short get_unitn () {return dev.minor;} DWORD file_attributes () {return fileattr;} DWORD drive_type () {return fs.drive_type;} diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index c4dc59e..d0846c6 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1179,18 +1179,9 @@ cygwin_lstat (const char *name, struct __stat32 *buf) return ret; } -extern "C" int -access (const char *fn, int flags) +int +access_worker (path_conv& real_path, int flags) { - sigframe thisframe (mainthread); - // flags were incorrectly specified - if (flags & ~(F_OK|R_OK|W_OK|X_OK)) - { - set_errno (EINVAL); - return -1; - } - - path_conv real_path (fn, PC_SYM_FOLLOW | PC_FULL, stat_suffixes); if (real_path.error) { set_errno (real_path.error); @@ -1206,13 +1197,14 @@ access (const char *fn, int flags) if (!(flags & (R_OK | W_OK | X_OK))) return 0; - if (real_path.has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK)) + if (real_path.is_fs_special ()) + /* short circuit */; + else if (real_path.has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK)) { set_errno (EACCES); return -1; } - - if (real_path.has_acls () && allow_ntsec) + else if (real_path.has_acls () && allow_ntsec) return check_file_access (real_path, flags); struct __stat64 st; @@ -1273,6 +1265,21 @@ done: } extern "C" int +access (const char *fn, int flags) +{ + sigframe thisframe (mainthread); + // flags were incorrectly specified + if (flags & ~(F_OK|R_OK|W_OK|X_OK)) + { + set_errno (EINVAL); + return -1; + } + + path_conv pc (fn, PC_SYM_FOLLOW | PC_FULL, stat_suffixes); + return access_worker (pc, flags); +} + +extern "C" int rename (const char *oldpath, const char *newpath) { sigframe thisframe (mainthread); @@ -1413,14 +1420,15 @@ struct system_cleanup_args sigset_t old_mask; }; -static void system_cleanup (void *args) +static void +system_cleanup (void *args) { struct system_cleanup_args *cleanup_args = (struct system_cleanup_args *) args; signal (SIGINT, cleanup_args->oldint); signal (SIGQUIT, cleanup_args->oldquit); (void) sigprocmask (SIG_SETMASK, &cleanup_args->old_mask, 0); -} +} extern "C" int system (const char *cmdstring) |