On Wed, Jul 1, 2015 at 5:41 PM, Paul Tan <pyoka...@gmail.com> wrote:
> Good point, I agree with this. I'll look into putting the error messages back.

This should work I think. It should take into account that O_RDONLY,
O_WRONLY, O_RDWR is defines as 0, 1, 2 on glibc, while the POSIX spec
also defines that O_RDONLY | O_WRONLY == O_RDWR.

diff --git a/wrapper.c b/wrapper.c
index c867ca9..e451463 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -214,7 +214,13 @@ int xopen(const char *path, int oflag, ...)
             return fd;
         if (errno == EINTR)
             continue;
-        die_errno(_("could not open '%s'"), path);
+
+        if ((oflag & O_RDWR) == O_RDWR)
+            die_errno(_("could not open '%s' for reading and writing"), path);
+        else if ((oflag & O_WRONLY) == O_WRONLY)
+            die_errno(_("could not open '%s' for writing"), path);
+        else
+            die_errno(_("could not open '%s' for reading"), path);
     }
 }

@@ -351,7 +357,13 @@ FILE *xfopen(const char *path, const char *mode)
             return fp;
         if (errno == EINTR)
             continue;
-        die_errno(_("could not open '%s'"), path);
+
+        if (*mode && mode[1] == '+')
+            die_errno(_("could not open '%s' for reading and writing"), path);
+        else if (*mode == 'w' || *mode == 'a')
+            die_errno(_("could not open '%s' for writing"), path);
+        else
+            die_errno(_("could not open '%s' for reading"), path);
     }
 }
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to