bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: test-open failure on Hurd


From: Eric Blake
Subject: Re: test-open failure on Hurd
Date: Fri, 02 Oct 2009 22:50:17 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 10/2/2009 6:32 PM:
> But meanwhile, the point of test-open was to test that opening
> a non-directory with a trailing slash fails, not whether Hurd complies.
> Therefore, we can fix the testsuite to be more portable by testing
> something other than /dev/null/.

And in the process, testing this on mingw exposed some bugs that need
fixing, as well as some errno values that aren't the normal values, but
which aren't worth working around.  I'm pushing this followup.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrG2AkACgkQ84KuGfSFAYAQiACfSSBeqNOv9dSsryMbWhTHJzSn
x6IAoLecHQChOxP99QdEkKvgnmxnKm5E
=ufpe
-----END PGP SIGNATURE-----
From 14b6206605af50774bc0202b7cbcce9418f8ede5 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 2 Oct 2009 22:41:54 -0600
Subject: [PATCH 1/3] open: fix opening directory on mingw

open(".",O_WRONLY) used uninitialized memory to decide whether
to succeed or fail - never a good idea ;)

* lib/open.c (open) [REPLACE_OPEN_DIRECTORY]: Correct typo.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog  |    3 +++
 lib/open.c |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3ef349e..df080c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-10-02  Eric Blake  <address@hidden>

+       open: fix opening directory on mingw
+       * lib/open.c (open) [REPLACE_OPEN_DIRECTORY]: Correct typo.
+
        test-open: on GNU/Hurd, /dev/null is a directory
        * tests/test-fopen.h (main): Rename...
        (test_fopen): ...to this.  Use a guaranteed non-directory when
diff --git a/lib/open.c b/lib/open.c
index 7cc25bd..8027b47 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -111,7 +111,7 @@ open (const char *filename, int flags, ...)
      override fstat() in fchdir.c to hide the fact that we have a
      dummy.  */
   if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES
-      && (mode & O_ACCMODE) == O_RDONLY)
+      && (flags & O_ACCMODE) == O_RDONLY)
     {
       struct stat statbuf;
       if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
-- 
1.6.5.rc1


From ddf870c4d82b62ad0fbe8a202adab357c7b94a30 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 2 Oct 2009 22:40:01 -0600
Subject: [PATCH 2/3] test-open: support mingw errno values

mingw has non-standard errno values for handling directory opens,
but they weren't worth working around in the gnulib modules.

* tests/test-open.h (test_open): Relax test.
* tests/test-fopen.h (test_fopen): Likewise.
* tests/test-openat-safer.c (main): Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog                 |    5 +++++
 tests/test-fopen.h        |    7 ++++---
 tests/test-open.h         |    7 ++++---
 tests/test-openat-safer.c |    5 +++--
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index df080c8..547a2a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-10-02  Eric Blake  <address@hidden>

+       test-open: support mingw errno values
+       * tests/test-open.h (test_open): Relax test.
+       * tests/test-fopen.h (test_fopen): Likewise.
+       * tests/test-openat-safer.c (main): Likewise.
+
        open: fix opening directory on mingw
        * lib/open.c (open) [REPLACE_OPEN_DIRECTORY]: Correct typo.

diff --git a/tests/test-fopen.h b/tests/test-fopen.h
index 01369f8..1920b27 100644
--- a/tests/test-fopen.h
+++ b/tests/test-fopen.h
@@ -56,17 +56,18 @@ test_fopen (void)
   /* Trailing slash is invalid on non-directory.  */
   errno = 0;
   ASSERT (fopen (BASE "file/", "r") == NULL);
-  ASSERT (errno == ENOTDIR || errno == EISDIR);
+  ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL);

   /* Cannot create a directory.  */
   errno = 0;
   ASSERT (fopen ("nonexist.ent/", "w") == NULL);
-  ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT);
+  ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT
+          || errno == EINVAL);

   /* Directories cannot be opened for writing.  */
   errno = 0;
   ASSERT (fopen (".", "w") == NULL);
-  ASSERT (errno == EISDIR || errno == EINVAL);
+  ASSERT (errno == EISDIR || errno == EINVAL || errno == EACCES);

   /* /dev/null must exist, and be writable.  */
   f = fopen ("/dev/null", "r");
diff --git a/tests/test-open.h b/tests/test-open.h
index 7381037..4dba767 100644
--- a/tests/test-open.h
+++ b/tests/test-open.h
@@ -47,7 +47,8 @@ test_open (void)
   /* Cannot create directory.  */
   errno = 0;
   ASSERT (open ("nonexist.ent/", O_CREAT | O_RDONLY, 0600) == -1);
-  ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT);
+  ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT
+          || errno == EINVAL);

   /* Create a regular file.  */
   fd = open (BASE "file", O_CREAT | O_RDONLY, 0600);
@@ -57,12 +58,12 @@ test_open (void)
   /* Trailing slash handling.  */
   errno = 0;
   ASSERT (open (BASE "file/", O_RDONLY) == -1);
-  ASSERT (errno == ENOTDIR || errno == EISDIR);
+  ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL);

   /* Directories cannot be opened for writing.  */
   errno = 0;
   ASSERT (open (".", O_WRONLY) == -1);
-  ASSERT (errno == EISDIR);
+  ASSERT (errno == EISDIR || errno == EACCES);

   /* /dev/null must exist, and be writable.  */
   fd = open ("/dev/null", O_RDONLY);
diff --git a/tests/test-openat-safer.c b/tests/test-openat-safer.c
index 7e44d67..221a880 100644
--- a/tests/test-openat-safer.c
+++ b/tests/test-openat-safer.c
@@ -101,10 +101,11 @@ main ()
          errno = 0;
          ASSERT (openat (dfd, "nonexist.ent/", O_CREAT | O_RDONLY,
                          S_IRUSR | S_IWUSR) == -1);
-         ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT);
+         ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT
+                 || errno == EINVAL);
          errno = 0;
          ASSERT (openat (dfd, witness "/", O_RDONLY) == -1);
-         ASSERT (errno == ENOTDIR || errno == EISDIR);
+         ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL);
          /* Using a bad directory is okay for absolute paths.  */
          fd = openat (-1, "/dev/null", O_WRONLY);
          ASSERT (STDERR_FILENO < fd);
-- 
1.6.5.rc1


From 881b91b9b370b4b6f26eb44efb5c048ca3783b83 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 2 Oct 2009 22:32:45 -0600
Subject: [PATCH 3/3] fchdir: avoid compiler warning

Using fchdir without canonicalize-lgpl gave a warning.

* lib/fchdir.c (canonicalize_file_name)
[!HAVE_CANONICALIZE_FILE_NAME]: Avoid compiler warning on mingw.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog    |    4 ++++
 lib/fchdir.c |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 547a2a7..8bcb8b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2009-10-02  Eric Blake  <address@hidden>

+       fchdir: avoid compiler warning
+       * lib/fchdir.c (canonicalize_file_name)
+       [!HAVE_CANONICALIZE_FILE_NAME]: Avoid compiler warning on mingw.
+
        test-open: support mingw errno values
        * tests/test-open.h (test_open): Relax test.
        * tests/test-fopen.h (test_fopen): Likewise.
diff --git a/lib/fchdir.c b/lib/fchdir.c
index b7ce188..19f02c3 100644
--- a/lib/fchdir.c
+++ b/lib/fchdir.c
@@ -38,6 +38,7 @@
 #  define HAVE_CANONICALIZE_FILE_NAME 1
 # else
 #  define HAVE_CANONICALIZE_FILE_NAME 0
+#  define canonicalize_file_name(name) NULL
 # endif
 #endif

-- 
1.6.5.rc1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]