From: Jim Meyering Date: Sat, 9 Sep 2000 07:29:38 +0000 (+0000) Subject: (SAME_OWNER, SAME_GROUP, SAME_OWNER_AND_GROUP): Define. X-Git-Tag: FILEUTILS-4_0z~15 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=84d9e6f35b7912277d7c56df2dcc443d6dee07fb;p=thirdparty%2Fcoreutils.git (SAME_OWNER, SAME_GROUP, SAME_OWNER_AND_GROUP): Define. (copy_internal): Avoid calling chown if we know it's not necessary. --- diff --git a/src/copy.c b/src/copy.c index 742ff4a24c..2be91a2238 100644 --- a/src/copy.c +++ b/src/copy.c @@ -44,6 +44,10 @@ or if the target system doesn't support file ownership. */ \ && ((errno != EPERM && errno != EINVAL) || x->myeuid == 0)) +#define SAME_OWNER(A, B) ((A).st_uid == (B).st_uid) +#define SAME_GROUP(A, B) ((A).st_gid == (B).st_gid) +#define SAME_OWNER_AND_GROUP(A, B) (SAME_OWNER (A, B) && SAME_GROUP (A, B)) + struct dir_list { struct dir_list *parent; @@ -1078,7 +1082,9 @@ copy_internal (const char *src_path, const char *dst_path, } } - if (x->preserve_owner_and_group) + /* Avoid calling chown if we know it's not necessary. */ + if (x->preserve_owner_and_group + && (new_dst || !SAME_OWNER_AND_GROUP (src_sb, dst_sb))) { if (DO_CHOWN (chown, dst_path, src_sb.st_uid, src_sb.st_gid)) {