MFC - CPDUP - Fix lack of error reporting if created target directory cannot stat.
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 17 Apr 2009 21:08:31 +0000 (14:08 -0700)
committerThomas Nikolajsen <thomas@dragonflybsd.org>
Mon, 27 Apr 2009 22:50:57 +0000 (00:50 +0200)
Fix a lack of error reporting if a just-created target directory cannot
be stat()'ed or chown()'d.

bin/cpdup/cpdup.c

index c39d544..fb01930 100644 (file)
@@ -875,11 +875,23 @@ relink:
                        r = 1;
                        noLoop = 1;
                    }
+
                    /*
                     * Matt: why don't you check error codes here?
+                    * (Because I'm an idiot... checks added!)
                     */
-                   hc_lstat(&DstHost, dpath, &st2);
-                   hc_chown(&DstHost, dpath, st1.st_uid, st1.st_gid);
+                   if (hc_lstat(&DstHost, dpath, &st2) != 0) {
+                       logerr("%s: lstat of newly made dir failed: %s\n",
+                           (dpath ? dpath : spath), strerror(errno));
+                       r = 1;
+                       noLoop = 1;
+                   }
+                   if (hc_chown(&DstHost, dpath, st1.st_uid, st1.st_gid) != 0){
+                       logerr("%s: chown of newly made dir failed: %s\n",
+                           (dpath ? dpath : spath), strerror(errno));
+                       r = 1;
+                       noLoop = 1;
+                   }
                    CountCopiedItems++;
                } else {
                    /*