aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Mertz <scott@cyngn.com>2016-02-02 14:40:31 -0800
committerScott Mertz <scott@cyngn.com>2016-02-03 11:03:53 -0800
commit8e523414ba060de519fec8073b69c69c924c22df (patch)
tree0bd63e56ee16cc591441a9a6d614c50285e3ce42
parent5849efb428103bb3d906747f23b32dd621be96cc (diff)
downloadandroid_external_toybox-stable/cm-13.0-ZNH0E.tar.gz
android_external_toybox-stable/cm-13.0-ZNH0E.tar.bz2
android_external_toybox-stable/cm-13.0-ZNH0E.zip
Don't exit with failure code when cp ownership preservation failsstable/cm-13.0-ZNH0E
POSIX spec states that it is unspecified whether '-p' prints errors to stderr when preserving ownership fails. GNU coreutils implementation does not write anything to stderr when this fails. Additionally, '-a' is only specified in GNU coreutils & specifies nothing is to be written to stderr in the case of failure. Switch the implementation to align with GNU coreutils while still satisfying POSIX. OPO-358 Change-Id: Ibb7c94fbf553a178b3f88a724ef6f737275a4205 (cherry picked from commit b90823e298988ff365cdf8e6d7c17687c3897d55)
-rw-r--r--toys/posix/cp.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index 9260d04b..a9966bab 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -332,15 +332,9 @@ int cp_node(struct dirtree *try)
// permission bits already correct for mknod and don't apply to symlink
// If we can't get a filehandle to the actual object, use racy functions
if (fdout == AT_FDCWD)
- rc = fchownat(cfd, catch, try->st.st_uid, try->st.st_gid,
+ fchownat(cfd, catch, try->st.st_uid, try->st.st_gid,
AT_SYMLINK_NOFOLLOW);
- else rc = fchown(fdout, try->st.st_uid, try->st.st_gid);
- if (rc) {
- char *pp;
-
- perror_msg("chown '%s'", pp = dirtree_path(try, 0));
- free(pp);
- }
+ else fchown(fdout, try->st.st_uid, try->st.st_gid);
}
// timestamp