From 9854ada7547fab60f8283aad78deff6011ac4d5b Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 22 Sep 2001 21:44:07 +0000 Subject: * dtable.cc (dtable::build_fhandler): Accept an optional path_conv argument. If available, use this to calculate path name and device number. * dtable.h (dtable): Reflect above change. * fhandler.h (fhandler_base): Declare virtual method which accepts path_conv rather than path string as first argument. * fhandler.cc (fhandler_base::open): Define above new method. * syscalls.cc (_open): Set aside a path_conv variable for use in build_fhandler and subsequent call to open. --- winsup/cygwin/ChangeLog | 13 +++++++++++++ winsup/cygwin/dtable.cc | 12 ++++++++++-- winsup/cygwin/dtable.h | 3 ++- winsup/cygwin/fhandler.cc | 6 ++++++ winsup/cygwin/fhandler.h | 1 + winsup/cygwin/syscalls.cc | 18 +++++++++++------- 6 files changed, 43 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ca302eb75..86a49a09b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,16 @@ +Sat Sep 22 17:33:45 2001 Christopher Faylor + Corinna Vinschen + + * dtable.cc (dtable::build_fhandler): Accept an optional path_conv + argument. If available, use this to calculate path name and device + number. + * dtable.h (dtable): Reflect above change. + * fhandler.h (fhandler_base): Declare virtual method which accepts + path_conv rather than path string as first argument. + * fhandler.cc (fhandler_base::open): Define above new method. + * syscalls.cc (_open): Set aside a path_conv variable for use in + build_fhandler and subsequent call to open. + Sat Sep 22 12:44:57 2001 Christopher Faylor * exceptions.cc (setup_handler): Always relinquish lock after we've diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 82009c943..8578cc76e 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -228,12 +228,20 @@ cygwin_attach_handle_to_fd (char *name, int fd, HANDLE handle, mode_t bin, } fhandler_base * -dtable::build_fhandler (int fd, const char *name, HANDLE handle) +dtable::build_fhandler (int fd, const char *name, HANDLE handle, path_conv *pc) { int unit; DWORD devn; - if ((devn = get_device_number (name, unit)) == FH_BAD) + if (!pc) + devn = get_device_number (name, unit); + else + { + pc->check (name); + devn = pc->get_devn (); + } + + if (devn == FH_BAD) { struct sockaddr sa; int sal = sizeof (sa); diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h index 1a51c9249..7e27bf657 100644 --- a/winsup/cygwin/dtable.h +++ b/winsup/cygwin/dtable.h @@ -49,7 +49,8 @@ public: void fixup_after_fork (HANDLE); fhandler_base *build_fhandler (int fd, DWORD dev, const char *name, int unit = -1); - fhandler_base *build_fhandler (int fd, const char *name, HANDLE h); + fhandler_base *build_fhandler (int fd, const char *name, HANDLE h = NULL, + path_conv *pc = NULL); inline int not_open (int fd) { SetResourceLock (LOCK_FD_LIST, READ_LOCK, "not_open"); diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 8ed52ffe9..a670e7860 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -289,6 +289,12 @@ fhandler_base::get_default_fmode (int flags) return __fmode; } +int +fhandler_base::open (path_conv& real_path, int flags, mode_t mode) +{ + return open ((char *) real_path, flags, mode); +} + /* Open system call handler function. Path is now already checked for symlinks */ int diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 79d039e64..1fe6990d0 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -320,6 +320,7 @@ public: { return open (flags, mode); } + virtual int open (path_conv& real_path, int flags, mode_t mode); virtual int open (int flags, mode_t mode = 0); virtual int close (); virtual int fstat (struct stat *buf) { return stat_dev (get_device (), get_unit (), get_namehash (), buf); } diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index a98b23a50..19d259a0a 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -484,15 +484,19 @@ _open (const char *unix_path, int flags, ...) if (fd < 0) set_errno (ENMFILE); - else if ((fh = cygheap->fdtab.build_fhandler (fd, unix_path, NULL)) == NULL) - res = -1; // errno already set - else if (!fh->open (unix_path, flags, (mode & 07777) & ~cygheap->umask)) + else { - cygheap->fdtab.release (fd); - res = -1; + path_conv pc; + if ((fh = cygheap->fdtab.build_fhandler (fd, unix_path, NULL, &pc)) == NULL) + res = -1; // errno already set + else if (!fh->open (pc, flags, (mode & 07777) & ~cygheap->umask)) + { + cygheap->fdtab.release (fd); + res = -1; + } + else if ((res = fd) <= 2) + set_std_handle (res); } - else if ((res = fd) <= 2) - set_std_handle (res); ReleaseResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," open"); } -- cgit v1.2.3