* fhandler.h (fhandler_virtual::exists): Eliminate path argument.

(fhandler_proc::exists): Ditto.
(fhandler_registry::exists): Ditto.
(fhandler_process::exists): Ditto.
* fhandler_proc.cc (fhandler_proc::exists): Ditto.  Use built-in name.
* fhandler_process.cc (fhandler_process::exists): Ditto.
(fstat): Ditto.
* fhandler_registry.cc (fhandler_registry::exists): Ditto.
(fhandler_registry::fstat): Ditto.
* fhandler_virtual.cc (fhandler_virtual::opendir): Ditto.
* path.cc (path_conv::check): Ditto.  Add debugging.
* syscalls.cc (dup): Always call dup2 for error handling.
This commit is contained in:
Christopher Faylor 2002-05-22 22:09:58 +00:00
parent 41dc939161
commit fc240f584b
8 changed files with 40 additions and 24 deletions

View File

@ -1,3 +1,21 @@
2002-05-22 Christopher Faylor <cgf@redhat.com>
* fhandler.h (fhandler_virtual::exists): Eliminate path argument.
(fhandler_proc::exists): Ditto.
(fhandler_registry::exists): Ditto.
(fhandler_process::exists): Ditto.
* fhandler_proc.cc (fhandler_proc::exists): Ditto. Use built-in name.
* fhandler_process.cc (fhandler_process::exists): Ditto.
(fstat): Ditto.
* fhandler_registry.cc (fhandler_registry::exists): Ditto.
(fhandler_registry::fstat): Ditto.
* fhandler_virtual.cc (fhandler_virtual::opendir): Ditto.
* path.cc (path_conv::check): Ditto. Add debugging.
2002-05-22 Christopher Faylor <cgf@redhat.com>
* syscalls.cc (dup): Always call dup2 for error handling.
2002-05-22 Corinna Vinschen <corinna@vinschen.de> 2002-05-22 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/types.h: Revert previous patch. * include/cygwin/types.h: Revert previous patch.
@ -9,7 +27,7 @@
2002-05-19 Pierre Humblet <pierre.humblet@ieee.org> 2002-05-19 Pierre Humblet <pierre.humblet@ieee.org>
* security.cc (open_local_policy): Initialize lsa to * security.cc (open_local_policy): Initialize lsa to
INVALID_HANDLE_VALUE instead of NULL. INVALID_HANDLE_VALUE instead of NULL.
(get_logon_server_and_user_domain): Test for INVALID_HANDLE_VALUE (get_logon_server_and_user_domain): Test for INVALID_HANDLE_VALUE
instead of NULL. instead of NULL.
@ -70,7 +88,7 @@
* cygwin.din: Add strlcat and strlcpy. * cygwin.din: Add strlcat and strlcpy.
* include/cygwin/version.h: Increment API minor version number. * include/cygwin/version.h: Increment API minor version number.
2002-05-09 Pierre Humblet <pierre.humblet@ieee.org> 2002-05-09 Pierre Humblet <pierre.humblet@ieee.org>
* shared.cc (__sec_user): Split into sec_acl() and call orig_sid(). * shared.cc (__sec_user): Split into sec_acl() and call orig_sid().
(sec_acl): Create from part of __sec_user(), except creator/owner. (sec_acl): Create from part of __sec_user(), except creator/owner.

View File

@ -1051,7 +1051,7 @@ class fhandler_virtual : public fhandler_base
fhandler_virtual (DWORD devtype); fhandler_virtual (DWORD devtype);
virtual ~fhandler_virtual(); virtual ~fhandler_virtual();
virtual int exists(const char *path); virtual int exists();
DIR *opendir (path_conv& pc); DIR *opendir (path_conv& pc);
__off64_t telldir (DIR *); __off64_t telldir (DIR *);
void seekdir (DIR *, __off64_t); void seekdir (DIR *, __off64_t);
@ -1072,7 +1072,7 @@ class fhandler_proc: public fhandler_virtual
public: public:
fhandler_proc (); fhandler_proc ();
fhandler_proc (DWORD devtype); fhandler_proc (DWORD devtype);
int exists(const char *path); int exists();
struct dirent *readdir (DIR *); struct dirent *readdir (DIR *);
static DWORD get_proc_fhandler(const char *path); static DWORD get_proc_fhandler(const char *path);
@ -1085,7 +1085,7 @@ class fhandler_registry: public fhandler_proc
{ {
public: public:
fhandler_registry (); fhandler_registry ();
int exists(const char *path); int exists();
struct dirent *readdir (DIR *); struct dirent *readdir (DIR *);
__off64_t telldir (DIR *); __off64_t telldir (DIR *);
void seekdir (DIR *, __off64_t); void seekdir (DIR *, __off64_t);
@ -1106,7 +1106,7 @@ class fhandler_process: public fhandler_proc
_pinfo *saved_p; _pinfo *saved_p;
public: public:
fhandler_process (); fhandler_process ();
int exists(const char *path); int exists();
struct dirent *readdir (DIR *); struct dirent *readdir (DIR *);
int open (path_conv *real_path, int flags, mode_t mode = 0); int open (path_conv *real_path, int flags, mode_t mode = 0);
int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));

View File

@ -135,8 +135,9 @@ fhandler_proc::get_proc_fhandler (const char *path)
* <0 if path is a file. * <0 if path is a file.
*/ */
int int
fhandler_proc::exists (const char *path) fhandler_proc::exists ()
{ {
const char *path = get_name ();
debug_printf ("exists (%s)", path); debug_printf ("exists (%s)", path);
path += proc_len; path += proc_len;
if (*path == 0) if (*path == 0)

View File

@ -74,8 +74,9 @@ static bool get_mem_values(DWORD dwProcessId, unsigned long *vmsize, unsigned lo
* <0 if path is a file. * <0 if path is a file.
*/ */
int int
fhandler_process::exists (const char *path) fhandler_process::exists ()
{ {
const char *path = get_name ();
debug_printf ("exists (%s)", path); debug_printf ("exists (%s)", path);
path += proc_len + 1; path += proc_len + 1;
while (*path != 0 && !SLASH_P (*path)) while (*path != 0 && !SLASH_P (*path))
@ -98,7 +99,7 @@ int
fhandler_process::fstat (struct __stat64 *buf, path_conv *pc) fhandler_process::fstat (struct __stat64 *buf, path_conv *pc)
{ {
const char *path = get_name (); const char *path = get_name ();
int file_type = exists (path); int file_type = exists ();
(void) fhandler_base::fstat (buf, pc); (void) fhandler_base::fstat (buf, pc);
path += proc_len + 1; path += proc_len + 1;
int pid = atoi (path); int pid = atoi (path);

View File

@ -93,7 +93,7 @@ static const char *DEFAULT_VALUE_NAME = "@";
* to the final key in the path. * to the final key in the path.
*/ */
int int
fhandler_registry::exists (const char *path) fhandler_registry::exists ()
{ {
int file_type = 0, index = 0, pathlen; int file_type = 0, index = 0, pathlen;
DWORD buf_size = MAX_PATH; DWORD buf_size = MAX_PATH;
@ -102,6 +102,7 @@ fhandler_registry::exists (const char *path)
const char *file; const char *file;
HKEY hKey = (HKEY) INVALID_HANDLE_VALUE; HKEY hKey = (HKEY) INVALID_HANDLE_VALUE;
const char *path = get_name ();
debug_printf ("exists (%s)", path); debug_printf ("exists (%s)", path);
path += proc_len + 1 + registry_len; path += proc_len + 1 + registry_len;
@ -187,7 +188,7 @@ fhandler_registry::fstat (struct __stat64 *buf, path_conv *pc)
{ {
this->fhandler_base::fstat (buf, pc); this->fhandler_base::fstat (buf, pc);
buf->st_mode &= ~_IFMT & NO_W; buf->st_mode &= ~_IFMT & NO_W;
int file_type = exists (get_name ()); int file_type = exists ();
switch (file_type) switch (file_type)
{ {
case 0: case 0:

View File

@ -46,7 +46,7 @@ fhandler_virtual::opendir (path_conv& pc)
DIR *res = NULL; DIR *res = NULL;
size_t len; size_t len;
if (exists (get_name ()) <= 0) if (exists () <= 0)
set_errno (ENOTDIR); set_errno (ENOTDIR);
else if ((len = strlen (get_name ())) > MAX_PATH - 3) else if ((len = strlen (get_name ())) > MAX_PATH - 3)
set_errno (ENAMETOOLONG); set_errno (ENAMETOOLONG);
@ -216,7 +216,7 @@ fhandler_virtual::open (path_conv *, int flags, mode_t mode)
} }
int int
fhandler_virtual::exists (const char *path) fhandler_virtual::exists ()
{ {
return 0; return 0;
} }

View File

@ -520,7 +520,7 @@ path_conv::check (const char *src, unsigned opt,
/* FIXME: Calling build_fhandler here is not the right way to handle this. */ /* FIXME: Calling build_fhandler here is not the right way to handle this. */
fhandler_virtual *fh = fhandler_virtual *fh =
(fhandler_virtual *) cygheap->fdtab.build_fhandler (-1, devn, path_copy, NULL, unit); (fhandler_virtual *) cygheap->fdtab.build_fhandler (-1, devn, path_copy, NULL, unit);
int file_type = fh->exists (path_copy); int file_type = fh->exists ();
switch (file_type) switch (file_type)
{ {
case 1: case 1:
@ -725,7 +725,10 @@ path_conv::check (const char *src, unsigned opt,
out: out:
if (opt & PC_POSIX) if (opt & PC_POSIX)
normalized_path = cstrdup (path_copy); {
normalized_path = cstrdup (path_copy);
debug_printf ("path_copy %s", path_copy);
}
/* Deal with Windows stupidity which considers filename\. to be valid /* Deal with Windows stupidity which considers filename\. to be valid
even when "filename" is not a directory. */ even when "filename" is not a directory. */
if (!need_directory || error) if (!need_directory || error)

View File

@ -83,15 +83,7 @@ check_pty_fds (void)
int int
dup (int fd) dup (int fd)
{ {
int res; return cygheap->fdtab.dup2 (fd, cygheap_fdnew ());
cygheap_fdnew newfd;
if (newfd < 0)
res = -1;
else
res = dup2 (fd, newfd);
return res;
} }
int int