+ struct stat stat_buf;
+ int rc;
+
+ rc = stat(dest_path, &stat_buf);
+ if (rc == 0) {
+ if (S_ISDIR(stat_buf.st_mode))
+ goto out;
+ if (!S_ISDIR(stat_buf.st_mode)) {
+ fprintf(stderr, "error: '%s' is not a directory (%o)\n",
+ dest_path, stat_buf.st_mode);
+ rc = -ENOTDIR;
+ goto out;
+ }
+ } else if (errno != ENOENT) {
+ rc = -errno;
+ fprintf(stderr, "error: error checking directory '%s': %s\n",
+ dest_path, strerror(errno));
+ goto out;
+ }