* realpath on AIX 7.1
@ 2011-06-05 15:27 Bruno Haible
2011-06-06 21:50 ` Eric Blake
0 siblings, 1 reply; 5+ messages in thread
From: Bruno Haible @ 2011-06-05 15:27 UTC (permalink / raw
To: bug-gnulib, Eric Blake
Hi Eric,
On AIX 7.1 I'm seeing this test failure:
test-canonicalize-lgpl.c:69: assertion failed
FAIL: test-canonicalize-lgpl
The reason is apparently a bug in realpath. Here's a test case:
================================================================================
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
int
main ()
{
char *result;
result = realpath ("conftest.dir", NULL);
if (result != NULL) printf ("%s\n", result); else printf ("errno=%d\n", errno);
result = realpath ("conftest.dir//.", NULL);
if (result != NULL) printf ("%s\n", result); else printf ("errno=%d\n", errno)
;
result = realpath ("conftest.dir//./..", NULL);
if (result != NULL) printf ("%s\n", result); else printf ("errno=%d\n", errno)
;
result = realpath ("conftest.dir/./../conftest.dir", NULL);
if (result != NULL) printf ("%s\n", result); else printf ("errno=%d\n", errno)
;
result = realpath ("conftest.dir//./../conftest.dir", NULL);
if (result != NULL) printf ("%s\n", result); else printf ("errno=%d\n", errno)
;
return 0;
}
================================================================================
$ gcc -D_ALL_SOURCE foo.c -Wall
Output:
/home/haible/testdir1/gltests/conftest.dir
/home/haible/testdir1/gltests/conftest.dir/
/home/haible/testdir1/gltests/conftest.dir
/home/haible/testdir1/gltests/conftest.dir
errno=2
Do you think we should work around it?
Bruno
--
In memoriam Eduard Lederer <http://de.wikipedia.org/wiki/Eduard_Lederer>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: realpath on AIX 7.1
2011-06-05 15:27 realpath on AIX 7.1 Bruno Haible
@ 2011-06-06 21:50 ` Eric Blake
2011-06-06 22:32 ` [PATCH] canonicalize-lgpl: work around AIX realpath bug Eric Blake
0 siblings, 1 reply; 5+ messages in thread
From: Eric Blake @ 2011-06-06 21:50 UTC (permalink / raw
To: Bruno Haible; +Cc: bug-gnulib
[-- Attachment #1: Type: text/plain, Size: 1314 bytes --]
On 06/05/2011 09:27 AM, Bruno Haible wrote:
> Hi Eric,
>
> On AIX 7.1 I'm seeing this test failure:
>
> test-canonicalize-lgpl.c:69: assertion failed
> FAIL: test-canonicalize-lgpl
>
> The reason is apparently a bug in realpath. Here's a test case:
>
> result = realpath ("conftest.dir//.", NULL);
> if (result != NULL) printf ("%s\n", result); else printf ("errno=%d\n", errno)
> /home/haible/testdir1/gltests/conftest.dir/
Suspicious to have a trailing slash here when no one else does, but
allowed by POSIX.
> result = realpath ("conftest.dir//./..", NULL);
> if (result != NULL) printf ("%s\n", result); else printf ("errno=%d\n", errno)
> /home/haible/testdir1/gltests/conftest.dir
Flat out wrong. This should be /home/haible/testdir1/gltests.
> result = realpath ("conftest.dir//./../conftest.dir", NULL);
> if (result != NULL) printf ("%s\n", result); else printf ("errno=%d\n", errno)
> errno=2
Flat out wrong. The mere change from / to // in the middle of the
string should have no impact.
>
> Do you think we should work around it?
Yes. I'll work on that, and see if I can come up with anything in the
next hour or so.
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] canonicalize-lgpl: work around AIX realpath bug
2011-06-06 21:50 ` Eric Blake
@ 2011-06-06 22:32 ` Eric Blake
2011-06-06 23:11 ` Bruno Haible
0 siblings, 1 reply; 5+ messages in thread
From: Eric Blake @ 2011-06-06 22:32 UTC (permalink / raw
To: bug-gnulib
AIX 7.1 realpath() gets horribly confused by consecutive /
in the name to be resolved.
* m4/canonicalize.m4 (gl_FUNC_REALPATH_WORKS): Expose AIX bug.
* doc/posix-functions/realpath.texi (realpath): Document it.
Reported by Bruno Haible.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
Not too hard, once I actually got on an AIX machine.
ChangeLog | 5 +++++
doc/posix-functions/realpath.texi | 3 +++
m4/canonicalize.m4 | 11 ++++++++++-
3 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 35497d0..6e466e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2011-06-06 Eric Blake <eblake@redhat.com>
+ canonicalize-lgpl: work around AIX realpath bug
+ * m4/canonicalize.m4 (gl_FUNC_REALPATH_WORKS): Expose AIX bug.
+ * doc/posix-functions/realpath.texi (realpath): Document it.
+ Reported by Bruno Haible.
+
strerror: work around FreeBSD bug
* lib/strerror.c (strerror): Special case 0.
Reported by Bruno Haible.
diff --git a/doc/posix-functions/realpath.texi b/doc/posix-functions/realpath.texi
index cc20709..fd3f160 100644
--- a/doc/posix-functions/realpath.texi
+++ b/doc/posix-functions/realpath.texi
@@ -27,6 +27,9 @@ realpath
This function fails to recognize non-directories followed @samp{..} on
some platforms:
cygwin.
+@item
+This function misbehaves on consecutive slashes on some platforms:
+AIX 7.1.
@end itemize
Portability problems not fixed by Gnulib:
diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4
index 9a099bd..dffdcc3 100644
--- a/m4/canonicalize.m4
+++ b/m4/canonicalize.m4
@@ -1,4 +1,4 @@
-# canonicalize.m4 serial 19
+# canonicalize.m4 serial 20
dnl Copyright (C) 2003-2007, 2009-2011 Free Software Foundation, Inc.
@@ -62,10 +62,12 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS],
AC_CHECK_FUNCS_ONCE([realpath])
AC_CACHE_CHECK([whether realpath works], [gl_cv_func_realpath_works], [
touch conftest.a
+ mkdir conftest.d
AC_RUN_IFELSE([
AC_LANG_PROGRAM([[
]GL_NOCRASH[
#include <stdlib.h>
+ #include <string.h>
]], [[
int result = 0;
{
@@ -83,10 +85,17 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS],
if (name != NULL)
result |= 4;
}
+ {
+ char *name1 = realpath (".", NULL);
+ char *name2 = realpath ("conftest.d//./..", NULL);
+ if (strcmp (name1, name2) != 0)
+ result |= 8;
+ }
return result;
]])
], [gl_cv_func_realpath_works=yes], [gl_cv_func_realpath_works=no],
[gl_cv_func_realpath_works="guessing no"])
+ rm -Rf conftest.a conftest.d
])
if test "$gl_cv_func_realpath_works" = yes; then
AC_DEFINE([FUNC_REALPATH_WORKS], [1], [Define to 1 if realpath()
--
1.7.4.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] canonicalize-lgpl: work around AIX realpath bug
2011-06-06 22:32 ` [PATCH] canonicalize-lgpl: work around AIX realpath bug Eric Blake
@ 2011-06-06 23:11 ` Bruno Haible
2011-06-06 23:17 ` Eric Blake
0 siblings, 1 reply; 5+ messages in thread
From: Bruno Haible @ 2011-06-06 23:11 UTC (permalink / raw
To: bug-gnulib; +Cc: Eric Blake
Eric Blake wrote:
> + rm -Rf conftest.a conftest.d
rm -rf conftest.a conftest.d
would be more portable, I think: The autoconf documentation mentions
`rm'
The `-f' and `-r' options are portable.
whereas it does not say that '-R' is portable.
Bruno
--
In memoriam Robert F. Kennedy <http://en.wikipedia.org/wiki/Robert_F._Kennedy>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] canonicalize-lgpl: work around AIX realpath bug
2011-06-06 23:11 ` Bruno Haible
@ 2011-06-06 23:17 ` Eric Blake
0 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2011-06-06 23:17 UTC (permalink / raw
To: Bruno Haible; +Cc: bug-gnulib
[-- Attachment #1: Type: text/plain, Size: 672 bytes --]
On 06/06/2011 05:11 PM, Bruno Haible wrote:
> Eric Blake wrote:
>> + rm -Rf conftest.a conftest.d
>
> rm -rf conftest.a conftest.d
>
> would be more portable, I think: The autoconf documentation mentions
>
> `rm'
> The `-f' and `-r' options are portable.
>
> whereas it does not say that '-R' is portable.
Fair enough. POSIX requires -R as a synonym to -r, but on the
off-chance that someone still lacks the newer spelling, it would be nice
to know who so that autoconf can give better details. I've made that
change.
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-06-06 23:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-05 15:27 realpath on AIX 7.1 Bruno Haible
2011-06-06 21:50 ` Eric Blake
2011-06-06 22:32 ` [PATCH] canonicalize-lgpl: work around AIX realpath bug Eric Blake
2011-06-06 23:11 ` Bruno Haible
2011-06-06 23:17 ` Eric Blake
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).