Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Tue, 15 Jan 2002 15:12:14 -0500 From: Chris Faylor To: cygwin AT cygwin DOT com Subject: Re: [benoit DOT perrin AT windriver DOT com: 1.3.6-6: fchdir broken] Message-ID: <20020115201214.GA23455@redhat.com> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <20020115210928 DOT R2015 AT cygbert DOT vinschen DOT de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020115210928.R2015@cygbert.vinschen.de> User-Agent: Mutt/1.3.23.1i On Tue, Jan 15, 2002 at 09:09:28PM +0100, Corinna Vinschen wrote: >----- Forwarded message from Benoit Perrin ----- >Date: Tue, 15 Jan 2002 16:09:41 +0100 >From: Benoit Perrin >Subject: 1.3.6-6: fchdir broken >To: cygwin AT cygwin DOT com > >Hello, > >fchdir() function is broken for version 1.3.6-6. The symptom is the same >as for the early 1.3.3: > >chdir("/some/dir/foo") >fd=open(".", RDONLY) >chdir("/some/dir/bar") >fchdir(fd) will not change to "/some/dir/foo" but remain in >"/some/dir/bar". > >[...] >----- End forwarded message ----- > >the problem here is that dtable::build_fhandler_from_name() >sets fhandler::unix_path_name to just the name given as parameter. >To work correctly with fchdir() it would have to set the full path >instead. How should we do that with a minimum of effort? > >The general solution could look like: > >Index: dtable.cc >=================================================================== >RCS file: /cvs/src/src/winsup/cygwin/dtable.cc,v >retrieving revision 1.75 >diff -u -p -r1.75 dtable.cc >--- dtable.cc 2002/01/13 20:03:03 1.75 >+++ dtable.cc 2002/01/15 19:57:41 >@@ -259,7 +259,9 @@ dtable::build_fhandler_from_name (int fd > } > > fhandler_base *fh = build_fhandler (fd, pc.get_devn (), name, pc.get_unitn ()); >- fh->set_name (name, pc, pc.get_unitn ()); >+ char full_path[MAX_PATH + 1]; >+ cygwin_conv_to_full_posix_path (pc, full_path); >+ fh->set_name (full_path, pc, pc.get_unitn ()); > return fh; > } > > >OTOH, that would cost a lot of extra time perhaps, so we could >also just change it for directories which would be far less >time consuming since opening a directory doesn't happen that often: > >Index: fhandler_disk_file.cc >=================================================================== >RCS file: /cvs/src/src/winsup/cygwin/fhandler_disk_file.cc,v >retrieving revision 1.5 >diff -u -p -r1.5 fhandler_disk_file.cc >--- fhandler_disk_file.cc 2002/01/14 20:39:59 1.5 >+++ fhandler_disk_file.cc 2002/01/15 20:04:58 >@@ -368,7 +368,17 @@ fhandler_disk_file::open (path_conv *rea > set_isremote (real_path->isremote ()); > > if (real_path->isdir ()) >- flags |= O_DIROPEN; >+ { >+ flags |= O_DIROPEN; >+ char full_path[MAX_PATH + 1]; >+ cygwin_conv_to_full_posix_path (*real_path, full_path); >+ if (unix_path_name) >+ { >+ cfree (unix_path_name); >+ unix_path_name = NULL; >+ } >+ set_name (full_path, *real_path, real_path->get_unitn ()); >+ } > > int res = this->fhandler_base::open (real_path, flags, mode); > > >What's your preferred way? Why not just have fchdir call chdir with the win32 path? cgf -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/