(touch): Extend the change of 2001-09-15 to work on
authorJim Meyering <jim@meyering.net>
Sun, 2 Dec 2001 20:05:33 +0000 (20:05 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 2 Dec 2001 20:05:33 +0000 (20:05 +0000)
systems for which errno is set to EPERM in that case.  Thus, e.g.,
`touch /' by non-root gives a better diagnostic on systems like SunOS4.

src/touch.c

index a4225f9..3590cb5 100644 (file)
@@ -146,8 +146,8 @@ touch (const char *file)
       /* Don't save a copy of errno if it's EISDIR, since that would lead
         touch to give a bogus diagnostic for e.g., `touch /' (assuming
         we don't own / or have write access to it).  On Solaris 5.6,
-        and probably other systems, it is EINVAL.  */
-      if (fd == -1 && errno != EISDIR && errno != EINVAL)
+        and probably other systems, it is EINVAL.  On SunOS4, it's EPERM.  */
+      if (fd == -1 && errno != EISDIR && errno != EINVAL && errno != EPERM)
        open_errno = errno;
     }