delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/12/10/15:40:13

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-developers-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com
Message-ID: <385156DC.3A4516EA@vinschen.de>
Date: Fri, 10 Dec 1999 20:39:08 +0100
From: Corinna Vinschen <corinna AT vinschen DOT de>
X-Mailer: Mozilla 4.7 [en] (WinNT; I)
X-Accept-Language: de,en
MIME-Version: 1.0
To: Chris Faylor <cgf AT cygnus DOT com>,
cygdev <cygwin-developers AT sourceware DOT cygnus DOT com>
Subject: Patch: traling backslash

Hi all,

I'm really surprised that nobody has seen this before.
I have found it only by chance.

If a posix path is converted to a windows path that only consists
of a drive letter, it's resolved to "<letter>:" without a
trailing backslash. This is definitely wrong! In this case the
path is not interpreted as the root dir of this drive (as it's
meant by the dll) but DOS and it's sick successors interpret it
as the current working directory on this drive. This yields to
e.g. wrong fstat results:

Imagine
	mount Z: /home

	chmod 777 /home
	ls -ld /home
	drwxrwxrwx  3 who ever 0 today   /home

	mkdir /home/foo
	cd /home/foo
	chmod 700 .
	ls -ld . ..
	drwx------  2 who ever 0 today   .
	drwx------  2 who ever 0 today   ..

The wrong output of .. is a result of the following operation:

	current working dir is Z:\foo
	.. is converted to Z: according to the mount table
	Z: is interpreted by Windows as Z:\foo

Regards,
Corinna

ChangeLog:
==========

Dec 10 20:34:00 1999  Corinna Vinschen  <corinna AT vinschen DOT de>

	* path.cc (path_conv::path_conv): If path is converted to
	only "X:\", don't eliminate trailing backslash. If path is
	converted to only "X:", add trailing backslash.


Index: path.cc
===================================================================
RCS file: /src/cvsroot/winsup-991207/path.cc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 path.cc
--- path.cc     1999/12/08 22:51:38     1.1.1.1
+++ path.cc     1999/12/10 19:18:12
@@ -221,6 +221,15 @@ path_conv::path_conv (const char *src, s

       /* Eat trailing slashes */
       char *tail = strchr (full_path, '\0');
+      /* If path is only a drivename, Windows interprets it as
+         the current working directory on this drive instead of
+         the root dir which is what we want. So we need
+         the trailing backslash in this case. */
+      while (tail > full_path + 3 && (*--tail == '\\'))
+        *tail = '\0';
+      if (full_path[0] && full_path[1] == ':' && full_path[2] == '\0')
+        strcat (full_path, "\\");
+
       while (tail > full_path && (*--tail == '\\'))
        *tail = '\0';

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019