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 Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <430DC3F8.3090903@byu.net> Date: Thu, 25 Aug 2005 07:13:28 -0600 From: Eric Blake User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: bugs in realpath Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 By my reading of POSIX, realpath() has several bugs. realpath("//", buf) should output "//", but currently resolves to /cygdrive/c/ realpath("nonexistent", buf) should fail with ENOENT, but currently resolves to `pwd`/nonexistent realpath(NULL, buf) should fail with EINVAL, but currently fails with EFAULT realpath("linktofile/x", buf) should fail with ENOTDIR, but currently resolves to `pwd`/file/x realpath("c:..", buf) should resolve to "/cygdrive" (or whatever cygdrive-prefix is, of course), but currently resolves to "/cygdrive/c" realpath("c:/..", buf) should resolve to "/cygdrive", but for me resolved to a bogus "/tmp/ca" (Plus the issue that .. is resolved incorrectly on symlinks, but fixing that is a much bigger task and affects more than realpath) I tested these using: #include #include #include #include #include #include int main (int argc, char* argv[]) { char resolved[PATH_MAX]; int i; if (argc == 1) argc = 2; for (i = 1; i < argc; i++) { char *res; errno = 0; res = realpath(argv[i], resolved); printf("'%s': %s (%s), %d %s\n", argv[i] ? argv[i] : "NULL", res ? res : "NULL", res == resolved ? "same" : resolved, errno, strerror(errno)); } return 0; } - -- Life is short - so eat dessert first! Eric Blake ebb9 AT byu DOT net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDDcP484KuGfSFAYARAvgVAKCK7jVk7hvyez7ieZvQ49rFxuwfkACcDoP2 7vyspKQDRJR6n4dg6E3boYA= =7Xt4 -----END PGP SIGNATURE----- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/