public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* [PATCH/RFC]: Keep cygwin's and native Windows cwd in sync
@ 2006-12-01 14:08 Corinna Vinschen
  2006-12-01 18:00 ` Keith Seitz
  0 siblings, 1 reply; 3+ messages in thread
From: Corinna Vinschen @ 2006-12-01 14:08 UTC (permalink / raw)
  To: insight

Hi,

my latest changes to Cygwin introduce a divergence between the current
working directory of Cygwin applications in contrast to the native
current working directory.  The idea is that Cygwin applications have
the native path set to some "always safe" value instead of the real cwd,
thus allowing to manipulate the current working directory in a POSIXy
way which native Windows doesn't allow.  For instance, under Windows an
application can't rmdir a directory which is the cwd of any other
application, which is now possible in Cygwin as long as only Cygwin
processes are involved.

This introduces a problem to Cygwin tcl.  Cygwin tcl is using a colorful
mix of native Windows and Cygwin system calls.  Due to the above change
in Cygwin, there are suddenly two different ideas of the current working
directory, depending of using the Cygwin getcwd call, or the native
GetCurrentDirectory.  The below patch fixes that by keeping them both
always in sync.

Ok to apply?


Thanks,
Corinna

	* win/tclWin32Dll.c (TclWinInit): Set native cwd to Cygwin's cwd.
	* win/tclWinFile.c (TclpObjChdir): Keep native and Cygwin's cwd
	synched.

Index: win/tclWin32Dll.c
===================================================================
RCS file: /cvs/src/src/tcl/win/tclWin32Dll.c,v
retrieving revision 1.10
diff -p -u -r1.10 tclWin32Dll.c
--- win/tclWin32Dll.c	2 Feb 2006 20:02:09 -0000	1.10
+++ win/tclWin32Dll.c	1 Dec 2006 11:44:09 -0000
@@ -13,6 +13,9 @@
  */
 
 #include "tclWinInt.h"
+#ifdef __CYGWIN__
+#include <sys/cygwin.h>
+#endif
 
 /*
  * The following data structures are used when loading the thunking 
@@ -267,6 +270,14 @@ TclWinInit(hInst)
 	panic("Win32s is not a supported platform");	
     }
 
+#ifdef __CYGWIN__
+    {
+      char cwd_posix[MAX_PATH], cwd_win32[MAX_PATH];
+      cygwin_conv_to_full_win32_path (getcwd (cwd_posix, MAX_PATH), cwd_win32);
+      SetCurrentDirectory (cwd_win32);
+    }
+#endif
+
     tclWinProcs = &asciiProcs;
 }
 \f
Index: win/tclWinFile.c
===================================================================
RCS file: /cvs/src/src/tcl/win/tclWinFile.c,v
retrieving revision 1.11
diff -p -u -r1.11 tclWinFile.c
--- win/tclWinFile.c	12 Feb 2003 04:20:59 -0000	1.11
+++ win/tclWinFile.c	1 Dec 2006 11:44:11 -0000
@@ -1340,14 +1340,16 @@ TclpObjChdir(pathPtr)
 
 
     nativePath = (CONST TCHAR *) Tcl_FSGetNativePath(pathPtr);
+    result = (*tclWinProcs->setCurrentDirectoryProc)(nativePath);
 #ifdef __CYGWIN__
     /* Cygwin chdir only groks POSIX path. */
-    path = Tcl_WinTCharToUtf(nativePath, -1, &ds);
-    cygwin_conv_to_posix_path(path, posixPath);
-    result = (chdir(posixPath) == 0 ? 1 : 0);
-    Tcl_DStringFree(&ds);
-#else /* __CYGWIN__ */
-    result = (*tclWinProcs->setCurrentDirectoryProc)(nativePath);
+    if (result)
+      {
+	path = Tcl_WinTCharToUtf(nativePath, -1, &ds);
+	cygwin_conv_to_posix_path(path, posixPath);
+	(result = (chdir(posixPath) == 0 ? 1 : 0));
+	Tcl_DStringFree(&ds);
+      }
 #endif /* __CYGWIN__ */
 
     if (result == 0) {


-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH/RFC]: Keep cygwin's and native Windows cwd in sync
  2006-12-01 14:08 [PATCH/RFC]: Keep cygwin's and native Windows cwd in sync Corinna Vinschen
@ 2006-12-01 18:00 ` Keith Seitz
  2006-12-01 20:37   ` Corinna Vinschen
  0 siblings, 1 reply; 3+ messages in thread
From: Keith Seitz @ 2006-12-01 18:00 UTC (permalink / raw)
  To: insight, Corinna Vinschen

Corinna Vinschen wrote:
> 
> Ok to apply?

Yes, please do.

Thanks,
Keith

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH/RFC]: Keep cygwin's and native Windows cwd in sync
  2006-12-01 18:00 ` Keith Seitz
@ 2006-12-01 20:37   ` Corinna Vinschen
  0 siblings, 0 replies; 3+ messages in thread
From: Corinna Vinschen @ 2006-12-01 20:37 UTC (permalink / raw)
  To: insight

On Dec  1 09:59, Keith Seitz wrote:
> Corinna Vinschen wrote:
> >
> >Ok to apply?
> 
> Yes, please do.

Applied.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-12-01 20:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-01 14:08 [PATCH/RFC]: Keep cygwin's and native Windows cwd in sync Corinna Vinschen
2006-12-01 18:00 ` Keith Seitz
2006-12-01 20:37   ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).