chiark / gitweb /
copy: don't eat up error from chown()/chmod()
authorLennart Poettering <lennart@poettering.net>
Thu, 19 Jun 2014 22:20:35 +0000 (00:20 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 19 Jun 2014 22:20:35 +0000 (00:20 +0200)
The idea was to not fail on, nor to ignore errors from chown()/chmod(),
but to proceed and simply return the most recent error...

src/shared/copy.c

index 867e49bf89ee5a7d92d869ef31e270bd5a6f0f58..7c3fab6901020c0db85520dce2224a85829137c2 100644 (file)
@@ -179,6 +179,8 @@ static int fd_copy_directory(int df, const char *from, const struct stat *st, in
         if (fdt < 0)
                 return -errno;
 
+        r = 0;
+
         if (created) {
                 if (fchown(fdt, st->st_uid, st->st_gid) < 0)
                         r = -errno;
@@ -187,7 +189,6 @@ static int fd_copy_directory(int df, const char *from, const struct stat *st, in
                         r = -errno;
         }
 
-        r = 0;
         FOREACH_DIRENT(de, d, return -errno) {
                 struct stat buf;
                 int q;