From 335c87f94dc73e6d6dbe5d29d59a1c221373bcbc Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 3 May 2002 02:43:45 +0000 Subject: [PATCH] * fhandler_proc.cc (fhandler_proc::fstat): Use fhandler name rather than path_conv name. (fhandler_proc::open): Ditto. * fhandler_process.cc (fhandler_process::fstat): Use fhandler name rather than path_conv name. (fhandler_process::open): Ditto. * fhandler_registry.cc (fhandler_registry::fstat): Use fhandler name rather than path_conv name. (fhandler_registry::open): Ditto. * path.cc (path_conv::check): Don't copy posix path when virtual. (mount_info::conv_to_win32_path): Don't zero string when isproc. Just derive normal windows path. * path.h (path_conv::clear_normalized_path): Declare new method. * path.cc (path_conv::clear_normalized_path): Define new method. * dtable.cc (build_fhandler_from_name): Clear normalized path when finished to conserve space. --- winsup/cygwin/ChangeLog | 20 +++++++++++++++++++ winsup/cygwin/dtable.cc | 4 +++- winsup/cygwin/fhandler_proc.cc | 4 ++-- winsup/cygwin/fhandler_process.cc | 4 ++-- winsup/cygwin/fhandler_registry.cc | 6 +++--- winsup/cygwin/fhandler_virtual.cc | 6 +++--- winsup/cygwin/path.cc | 32 ++++++++++++++++++------------ winsup/cygwin/path.h | 1 + 8 files changed, 53 insertions(+), 24 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ed3bff290..7531ceb04 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,23 @@ +2002-05-02 Christopher Faylor + + * fhandler_proc.cc (fhandler_proc::fstat): Use fhandler name rather + than path_conv name. + (fhandler_proc::open): Ditto. + * fhandler_process.cc (fhandler_process::fstat): Use fhandler name + rather than path_conv name. + (fhandler_process::open): Ditto. + * fhandler_registry.cc (fhandler_registry::fstat): Use fhandler name + rather than path_conv name. + (fhandler_registry::open): Ditto. + * path.cc (path_conv::check): Don't copy posix path when virtual. + (mount_info::conv_to_win32_path): Don't zero string when isproc. Just + derive normal windows path. + + * path.h (path_conv::clear_normalized_path): Declare new method. + * path.cc (path_conv::clear_normalized_path): Define new method. + * dtable.cc (build_fhandler_from_name): Clear normalized path when + finished to conserve space. + 2002-05-02 Christopher Faylor * fhandler_proc.cc (fhandler_proc::fstat): Prime with information from diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 93d5602fd..e4f2ddfbc 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -287,7 +287,9 @@ dtable::build_fhandler_from_name (int fd, const char *name, HANDLE handle, return NULL; } - return build_fhandler (fd, pc.get_devn (), pc.normalized_path, pc, pc.get_unitn ()); + fhandler_base *fh = build_fhandler (fd, pc.get_devn (), pc.normalized_path, pc, pc.get_unitn ()); + pc.clear_normalized_path (); + return fh; } #define cnew(name) new ((void *) ccalloc (HEAP_FHANDLER, 1, sizeof (name))) name diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index dd4af7ec5..d781fdf55 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -124,7 +124,7 @@ fhandler_proc::fhandler_proc (DWORD devtype): int fhandler_proc::fstat (struct __stat64 *buf, path_conv *pc) { - debug_printf ("fstat (%s)", (char *) *pc); + debug_printf ("fstat (%s)", get_name ()); const char *path = get_name (); path += proc_len; (void) fhandler_base::fstat (buf, pc); @@ -199,7 +199,7 @@ fhandler_proc::open (path_conv *pc, int flags, mode_t mode) const char *path; - path = (char *) *pc + proc_len; + path = get_name () + proc_len; if (!*path) { diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc index b05e07bf0..b51b17628 100644 --- a/winsup/cygwin/fhandler_process.cc +++ b/winsup/cygwin/fhandler_process.cc @@ -80,7 +80,7 @@ fhandler_process::fhandler_process (): int fhandler_process::fstat (struct __stat64 *buf, path_conv *pc) { - int file_type = exists ((const char *) get_name ()); + int file_type = exists (get_name ()); (void) fhandler_base::fstat (buf, pc); buf->st_mode &= ~_IFMT & NO_W; @@ -126,7 +126,7 @@ fhandler_process::open (path_conv *pc, int flags, mode_t mode) goto out; const char *path; - path = (const char *) *pc + proc_len + 1; + path = get_name () + proc_len + 1; pid = atoi (path); while (*path != 0 && !SLASH_P (*path)) path++; diff --git a/winsup/cygwin/fhandler_registry.cc b/winsup/cygwin/fhandler_registry.cc index 6de3308f6..a7c86f292 100644 --- a/winsup/cygwin/fhandler_registry.cc +++ b/winsup/cygwin/fhandler_registry.cc @@ -161,9 +161,9 @@ fhandler_registry::fhandler_registry (): } int -fhandler_registry::fstat (struct __stat64 *buf, path_conv *path) +fhandler_registry::fstat (struct __stat64 *buf, path_conv *pc) { - this->fhandler_base::fstat (buf, path); + this->fhandler_base::fstat (buf, pc); buf->st_mode &= ~_IFMT & NO_W; int file_type = exists (get_name ()); switch (file_type) @@ -315,7 +315,7 @@ fhandler_registry::open (path_conv *pc, int flags, mode_t mode) goto out; const char *path; - path = (const char *) *pc + proc_len + 1 + registry_len; + path = get_name () + proc_len + 1 + registry_len; if (!*path) { if ((mode & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) diff --git a/winsup/cygwin/fhandler_virtual.cc b/winsup/cygwin/fhandler_virtual.cc index 32798b373..4dd1ffa21 100644 --- a/winsup/cygwin/fhandler_virtual.cc +++ b/winsup/cygwin/fhandler_virtual.cc @@ -45,9 +45,9 @@ fhandler_virtual::opendir (path_conv& pc) DIR *res = NULL; size_t len; - if (exists (pc) <= 0) + if (exists (get_name ()) <= 0) set_errno (ENOTDIR); - else if ((len = strlen (pc)) > MAX_PATH - 3) + else if ((len = strlen (get_name ())) > MAX_PATH - 3) set_errno (ENAMETOOLONG); else if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL) set_errno (ENOMEM); @@ -64,7 +64,7 @@ fhandler_virtual::opendir (path_conv& pc) } else { - strcpy (dir->__d_dirname, pc); + strcpy (dir->__d_dirname, get_name ()); dir->__d_dirent->d_version = __DIRENT_VERSION; cygheap_fdnew fd; fd = this; diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 54451bce8..9299c0159 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -368,10 +368,20 @@ path_conv::update_fs_info (const char* win32_path) } } +void +path_conv::clear_normalized_path () +{ + // not thread safe + if (normalized_path) + { + cfree (normalized_path); + normalized_path = NULL; + } +} + path_conv::~path_conv () { - if (normalized_path) - cfree (normalized_path); + clear_normalized_path (); } /* Convert an arbitrary path SRC to a pure Win32 path, suitable for @@ -526,8 +536,6 @@ path_conv::check (const char *src, unsigned opt, fileattr = 0; } delete fh; - if (!error) - strcpy (path, path_copy); goto out; } /* devn should not be a device. If it is, then stop parsing now. */ @@ -1428,7 +1436,13 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, /* Check if the cygdrive prefix was specified. If so, just strip off the prefix and transform it into an MS-DOS path. */ MALLOC_CHECK; - if (iscygdrive (pathbuf)) + if (isproc (pathbuf)) + { + devn = fhandler_proc::get_proc_fhandler (pathbuf); + if (devn == FH_BAD) + return ENOENT; + } + else if (iscygdrive (pathbuf)) { int n = mount_table->cygdrive_len - 1; if (!pathbuf[n] || @@ -1447,14 +1461,6 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, else if (mount_table->cygdrive_len > 1) return ENOENT; } - if (isproc (pathbuf)) - { - devn = fhandler_proc::get_proc_fhandler (pathbuf); - dst[0] = '\0'; - if (devn == FH_BAD) - return ENOENT; - goto out; - } int chrooted_path_len; chrooted_path_len = 0; diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index 1daaa11d8..79011ec13 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -141,6 +141,7 @@ class path_conv DWORD get_drive_type () {return drive_type;} BOOL fs_fast_ea () {return sym_opt & PC_CHECK_EA;} void set_path (const char *p) {strcpy (path, p);} + void clear_normalized_path (); }; /* Symlink marker */