This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [benoit.perrin@windriver.com: 1.3.6-6: fchdir broken]


On Tue, Jan 15, 2002 at 09:09:28PM +0100, Corinna Vinschen wrote:
>----- Forwarded message from Benoit Perrin <benoit.perrin@windriver.com> -----
>Date: Tue, 15 Jan 2002 16:09:41 +0100
>From: Benoit Perrin <benoit.perrin@windriver.com>
>Subject: 1.3.6-6: fchdir broken
>To: cygwin@cygwin.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]