Problem with --link-dest when syncing AIX to Linux

Wayne Davison wayned at samba.org
Sat Mar 6 08:10:29 GMT 2004


On Fri, Mar 05, 2004 at 05:14:30PM +0100, Markus Marquardt wrote:
>     if(preserve_perms
>         && (st->st_mode & ~_S_IFMT) !=  (file->mode & ~_S_IFMT))
>         return 0;

Hmm, the code in rsync.c uses the define CHMOD_BITS (defined in rsync.h)
instead of ~_S_IFMT.  The former looks safer to me and should solve the
problem you mention of having a 0400000 in the AIX mode.

CHMOD_BITS also looks to be a synonym of the "ALLPERMS" define that (at
least some) systems provide.  I think the attached patch would be an
improvement.

..wayne..
-------------- next part --------------
--- rsync.h	6 Mar 2004 07:43:55 -0000	1.188
+++ rsync.h	6 Mar 2004 08:02:29 -0000
@@ -609,7 +609,9 @@ extern int errno;
 #define S_ISVTX 0
 #endif
 
-#define CHMOD_BITS (S_ISUID | S_ISGID | S_ISVTX | ACCESSPERMS)
+#ifndef ALLPERMS
+#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | ACCESSPERMS)
+#endif
 
 #ifndef _S_IFMT
 #define _S_IFMT        0170000
--- generator.c	27 Feb 2004 08:03:49 -0000	1.76
+++ generator.c	6 Mar 2004 08:02:29 -0000
@@ -53,7 +53,7 @@ static int skip_file(char *fname, struct
 	}
 	if (link_dest) {
 		if (preserve_perms
-		    && (st->st_mode & ~_S_IFMT) != (file->mode & ~_S_IFMT))
+		    && (st->st_mode & ALLPERMS) != (file->mode & ALLPERMS))
 			return 0;
 
 		if (am_root && preserve_uid && st->st_uid != file->uid)
@@ -295,7 +295,7 @@ void recv_generator(char *fname, struct 
 		/* if the file exists already and we aren't perserving
 		 * permissions then act as though the remote end sent
 		 * us the file permissions we already have */
-		file->mode = (file->mode & _S_IFMT) | (st.st_mode & ~_S_IFMT);
+		file->mode = (file->mode & ~ALLPERMS) | (st.st_mode & ALLPERMS);
 	}
 
 	if (S_ISDIR(file->mode)) {
--- rsync.c	25 Feb 2004 21:20:59 -0000	1.133
+++ rsync.c	6 Mar 2004 08:02:29 -0000
@@ -190,9 +190,9 @@ int set_perms(char *fname,struct file_st
 
 #ifdef HAVE_CHMOD
 	if (!S_ISLNK(st->st_mode)) {
-		if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) {
+		if ((st->st_mode & ALLPERMS) != (file->mode & ALLPERMS)) {
 			updated = 1;
-			if (do_chmod(fname,(file->mode & CHMOD_BITS)) != 0) {
+			if (do_chmod(fname,(file->mode & ALLPERMS)) != 0) {
 				rprintf(FERROR, "failed to set permissions on %s: %s\n",
 					full_fname(fname), strerror(errno));
 				return 0;


More information about the rsync mailing list