(re_protect): Don't fail for non-root when chown fails due
authorJim Meyering <jim@meyering.net>
Sun, 25 Jan 1998 09:27:57 +0000 (09:27 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 25 Jan 1998 09:27:57 +0000 (09:27 +0000)
not only to lack of permission (EPERM), but also to lack of support
(EINVAL).  Reported by Bengt Martensson.

src/cp.c

index cc2e4ea..1e64cf4 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -247,9 +247,10 @@ re_protect (const char *const_dst_path, int src_offset,
            }
 
          /* If non-root uses -p, it's ok if we can't preserve ownership.
-            But root probably wants to know, e.g. if NFS disallows it.  */
+            But root probably wants to know, e.g. if NFS disallows it,
+            or if the target system doesn't support file ownership.  */
          if (chown (dst_path, src_sb.st_uid, src_sb.st_gid)
-             && (errno != EPERM || myeuid == 0))
+             && ((errno != EPERM && errno != EINVAL) || myeuid == 0))
            {
              error (0, errno, _("preserving ownership for %s"), dst_path);
              return 1;