ssize_t attrs_size = 0;
struct stat from_stat;
- if (stat (from_path, &from_stat) < 0 ||
- chmod (to_path, from_stat.st_mode) < 0 ||
- lchown (to_path, from_stat.st_uid, from_stat.st_gid) < 0) {
+ if (lstat (from_path, &from_stat) < 0)
return FALSE;
+
+ if (!S_ISLNK(from_stat.st_mode)) {
+ if (chmod(to_path, from_stat.st_mode) < 0)
+ return FALSE;
}
+ if (lchown(to_path, from_stat.st_uid, from_stat.st_gid) < 0)
+ return FALSE;
+
/* copy extended attributes */
#if defined(HAVE_LLISTXATTR) && \
defined(HAVE_LGETXATTR) && \