@@ -505,12 +505,11 @@ static int copy(const char *path,
505
505
}
506
506
507
507
/* Convert basename to appropriate volume encoding */
508
- if (dvolume .vol -> v_path ) {
509
- if ((convert_dots_encoding (& svolume , & dvolume , to .p_path , MAXPATHLEN )) == -1 ) {
510
- SLOG ("Error converting name for %s" , to .p_path );
511
- badcp = rval = 1 ;
512
- return -1 ;
513
- }
508
+ if (dvolume .vol -> v_path
509
+ && (convert_dots_encoding (& svolume , & dvolume , to .p_path , MAXPATHLEN )) == -1 ) {
510
+ SLOG ("Error converting name for %s" , to .p_path );
511
+ badcp = rval = 1 ;
512
+ return -1 ;
514
513
}
515
514
516
515
switch (statp -> st_mode & S_IFMT ) {
@@ -557,13 +556,12 @@ static int copy(const char *path,
557
556
bdestroy (addir );
558
557
}
559
558
560
- if (svolume .vol -> v_path && ADVOL_V2_OR_EA (svolume .vol -> v_adouble )) {
561
- /* copy metadata file */
562
- if (dvolume .vol -> vfs -> vfs_copyfile (dvolume .vol , -1 , path , to .p_path )) {
563
- SLOG ("Error copying adouble for %s -> %s" , path , to .p_path );
564
- badcp = rval = 1 ;
565
- break ;
566
- }
559
+ /* copy metadata file */
560
+ if (svolume .vol -> v_path && ADVOL_V2_OR_EA (svolume .vol -> v_adouble )
561
+ && dvolume .vol -> vfs -> vfs_copyfile (dvolume .vol , -1 , path , to .p_path )) {
562
+ SLOG ("Error copying adouble for %s -> %s" , path , to .p_path );
563
+ badcp = rval = 1 ;
564
+ break ;
567
565
}
568
566
569
567
/* Get CNID of Parent and add new childir to CNID database */
@@ -607,11 +605,8 @@ static int copy(const char *path,
607
605
umask (omask );
608
606
}
609
607
610
- if (pflag ) {
611
- if (setfile (statp , -1 )) {
612
- rval = 1 ;
613
- }
614
-
608
+ if (pflag && setfile (statp , -1 )) {
609
+ rval = 1 ;
615
610
#if 0
616
611
617
612
if (preserve_dir_acls (statp , curr -> fts_accpath , to .p_path ) != 0 ) {
@@ -644,13 +639,12 @@ static int copy(const char *path,
644
639
if (dvolume .vol -> v_path && ADVOL_V2_OR_EA (dvolume .vol -> v_adouble )) {
645
640
mode_t omask = umask (0 );
646
641
647
- if (svolume .vol -> v_path && ADVOL_V2_OR_EA (svolume .vol -> v_adouble )) {
648
- /* copy ad-file */
649
- if (dvolume .vol -> vfs -> vfs_copyfile (dvolume .vol , -1 , path , to .p_path )) {
650
- SLOG ("Error copying adouble for %s -> %s" , path , to .p_path );
651
- badcp = rval = 1 ;
652
- break ;
653
- }
642
+ /* copy ad-file */
643
+ if (svolume .vol -> v_path && ADVOL_V2_OR_EA (svolume .vol -> v_adouble )
644
+ && dvolume .vol -> vfs -> vfs_copyfile (dvolume .vol , -1 , path , to .p_path )) {
645
+ SLOG ("Error copying adouble for %s -> %s" , path , to .p_path );
646
+ badcp = rval = 1 ;
647
+ break ;
654
648
}
655
649
656
650
/* Get CNID of Parent and add new childir to CNID database */
@@ -1002,34 +996,33 @@ static int setfile(const struct stat *fs, int fd)
1002
996
* the mode; current BSD behavior is to remove all setuid bits on
1003
997
* chown. If chown fails, lose setuid/setgid bits.
1004
998
*/
1005
- if (!gotstat || fs -> st_uid != ts .st_uid || fs -> st_gid != ts .st_gid )
1006
- if (fdval ? fchown (fd , fs -> st_uid , fs -> st_gid ) :
1007
- (islink ? lchown (to .p_path , fs -> st_uid , fs -> st_gid ) :
1008
- chown (to .p_path , fs -> st_uid , fs -> st_gid ))) {
1009
- if (errno != EPERM ) {
1010
- SLOG ("chown: %s: %s" , to .p_path , strerror (errno ));
1011
- rval = 1 ;
1012
- }
1013
-
1014
- mode &= ~(S_ISUID | S_ISGID );
1015
- }
1016
-
1017
- if (!gotstat || mode != ts .st_mode )
1018
- if (fdval ? fchmod (fd , mode ) : chmod (to .p_path , mode )) {
1019
- SLOG ("chmod: %s: %s" , to .p_path , strerror (errno ));
999
+ if (!gotstat || fs -> st_uid != ts .st_uid || fs -> st_gid != ts .st_gid
1000
+ && fdval ? fchown (fd , fs -> st_uid , fs -> st_gid ) :
1001
+ (islink ? lchown (to .p_path , fs -> st_uid , fs -> st_gid ) :
1002
+ chown (to .p_path , fs -> st_uid , fs -> st_gid ))) {
1003
+ if (errno != EPERM ) {
1004
+ SLOG ("chown: %s: %s" , to .p_path , strerror (errno ));
1020
1005
rval = 1 ;
1021
1006
}
1022
1007
1008
+ mode &= ~(S_ISUID | S_ISGID );
1009
+ }
1010
+
1011
+ if ((!gotstat || mode != ts .st_mode )
1012
+ && (fdval ? fchmod (fd , mode ) : chmod (to .p_path , mode ))) {
1013
+ SLOG ("chmod: %s: %s" , to .p_path , strerror (errno ));
1014
+ rval = 1 ;
1015
+ }
1016
+
1023
1017
#ifdef HAVE_ST_FLAGS
1024
1018
1025
- if (!gotstat || fs -> st_flags != ts .st_flags )
1026
- if (fdval ?
1027
- fchflags (fd , fs -> st_flags ) :
1028
- (islink ? lchflags (to .p_path , fs -> st_flags ) :
1029
- chflags (to .p_path , fs -> st_flags ))) {
1030
- SLOG ("chflags: %s: %s" , to .p_path , strerror (errno ));
1031
- rval = 1 ;
1032
- }
1019
+ if (!gotstat || fs -> st_flags != ts .st_flags ) & & fdval ?
1020
+ fchflags (fd , fs -> st_flags ) :
1021
+ (islink ? lchflags (to .p_path , fs -> st_flags ) :
1022
+ chflags (to .p_path , fs -> st_flags ))) {
1023
+ SLOG ("chflags: %s: %s" , to .p_path , strerror (errno ));
1024
+ rval = 1 ;
1025
+ }
1033
1026
1034
1027
#endif
1035
1028
return rval ;
0 commit comments