@@ -652,7 +652,7 @@ static int fd_copy_regular(
652652 r = - errno ;
653653
654654 (void ) futimens (fdt , (struct timespec []) { st -> st_atim , st -> st_mtim });
655- (void ) copy_xattr (fdf , fdt );
655+ (void ) copy_xattr (fdf , fdt , copy_flags );
656656
657657 if (copy_flags & COPY_FSYNC ) {
658658 if (fsync (fdt ) < 0 ) {
@@ -945,7 +945,7 @@ static int fd_copy_directory(
945945 if (fchmod (fdt , st -> st_mode & 07777 ) < 0 )
946946 r = - errno ;
947947
948- (void ) copy_xattr (dirfd (d ), fdt );
948+ (void ) copy_xattr (dirfd (d ), fdt , copy_flags );
949949 (void ) futimens (fdt , (struct timespec []) { st -> st_atim , st -> st_mtim });
950950 }
951951
@@ -1139,7 +1139,7 @@ int copy_file_fd_full(
11391139
11401140 if (S_ISREG (fdt )) {
11411141 (void ) copy_times (fdf , fdt , copy_flags );
1142- (void ) copy_xattr (fdf , fdt );
1142+ (void ) copy_xattr (fdf , fdt , copy_flags );
11431143 }
11441144
11451145 if (copy_flags & COPY_FSYNC_FULL ) {
@@ -1211,7 +1211,7 @@ int copy_file_full(
12111211 goto fail ;
12121212
12131213 (void ) copy_times (fdf , fdt , copy_flags );
1214- (void ) copy_xattr (fdf , fdt );
1214+ (void ) copy_xattr (fdf , fdt , copy_flags );
12151215
12161216 if (chattr_mask != 0 )
12171217 (void ) chattr_fd (fdt , chattr_flags , chattr_mask & ~CHATTR_EARLY_FL , NULL );
@@ -1399,7 +1399,7 @@ int copy_rights_with_fallback(int fdf, int fdt, const char *patht) {
13991399 return fchmod_and_chown_with_fallback (fdt , patht , st .st_mode & 07777 , st .st_uid , st .st_gid );
14001400}
14011401
1402- int copy_xattr (int fdf , int fdt ) {
1402+ int copy_xattr (int fdf , int fdt , CopyFlags copy_flags ) {
14031403 _cleanup_free_ char * names = NULL ;
14041404 int ret = 0 , r ;
14051405 const char * p ;
@@ -1411,7 +1411,7 @@ int copy_xattr(int fdf, int fdt) {
14111411 NULSTR_FOREACH (p , names ) {
14121412 _cleanup_free_ char * value = NULL ;
14131413
1414- if (!startswith (p , "user." ))
1414+ if (!( copy_flags & COPY_ALL_XATTRS ) && ! startswith (p , "user." ))
14151415 continue ;
14161416
14171417 r = fgetxattr_malloc (fdf , p , & value );
0 commit comments