Roderick Schertler
2003-Feb-08 03:15 UTC
compare st_mode & 07777, or Aix dirs always differ
Under Aix directories have the mode 024xxxx instead of the customary 04xxxx. Because of this when you sync a directory to or from an Aix system it's never up to date. Here is a patch which fixes this. It causes rsync to look at only the bits that chmod actually influences, 07777, when deciding whether or not the modes differ. I was surprised there wasn't an existing constant for 07777, but I couldn't find one. I thought then to exclude the S_IFMT bits, but on Aix that has the usual value of 0170000, so it wouldn't exclude the problematic 0200000 bit. diff -r -X /home/roderick/.diff-exclude -u rsync-2.5.5/rsync.c rsync/rsync.c --- rsync-2.5.5/rsync.c Thu Dec 20 10:33:13 2001 +++ rsync/rsync.c Fri Feb 7 10:12:50 2003 @@ -203,7 +203,7 @@ #ifdef HAVE_CHMOD if (!S_ISLNK(st->st_mode)) { - if (st->st_mode != file->mode) { + if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) { updated = 1; if (do_chmod(fname,file->mode) != 0) { rprintf(FERROR,"failed to set permissions on %s : %s\n", diff -r -X /home/roderick/.diff-exclude -u rsync-2.5.5/rsync.h rsync/rsync.h --- rsync-2.5.5/rsync.h Mon Mar 25 02:29:43 2002 +++ rsync/rsync.h Fri Feb 7 10:02:09 2003 @@ -488,9 +488,53 @@ #define STDERR_FILENO 2 #endif +#ifndef S_ISUID +#define S_ISUID 04000 +#endif +#ifndef S_ISGID +#define S_ISGID 02000 +#endif +#ifndef S_ISVTX +#define S_ISVTX 01000 +#endif +#ifndef S_IRWXU +#define S_IRWXU 00700 +#endif +#ifndef S_IRUSR +#define S_IRUSR 00400 +#endif #ifndef S_IWUSR -#define S_IWUSR 0200 +#define S_IWUSR 00200 +#endif +#ifndef S_IXUSR +#define S_IXUSR 00100 +#endif +#ifndef S_IRWXG +#define S_IRWXG 00070 +#endif +#ifndef S_IRGRP +#define S_IRGRP 00040 +#endif +#ifndef S_IWGRP +#define S_IWGRP 00020 +#endif +#ifndef S_IXGRP +#define S_IXGRP 00010 +#endif +#ifndef S_IRWXO +#define S_IRWXO 00007 +#endif +#ifndef S_IROTH +#define S_IROTH 00004 +#endif +#ifndef S_IWOTH +#define S_IWOTH 00002 +#endif +#ifndef S_IXOTH +#define S_IXOTH 00001 #endif + +#define CHMOD_BITS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) #ifndef _S_IFMT #define _S_IFMT 0170000 -- Roderick Schertler roderick@argon.org
On Fri, Feb 07, 2003 at 11:15:57AM -0500, Roderick Schertler wrote:> Under Aix directories have the mode 024xxxx instead of the customary > 04xxxx. Because of this when you sync a directory to or from an Aix > system it's never up to date. > > Here is a patch which fixes this. It causes rsync to look at only the > bits that chmod actually influences, 07777, when deciding whether or not > the modes differ. > > I was surprised there wasn't an existing constant for 07777, but I > couldn't find one. I thought then to exclude the S_IFMT bits, but on > Aix that has the usual value of 0170000, so it wouldn't exclude the > problematic 0200000 bit.First, a tecnical note: Instead of all those ifndef,define,endif lines with literals just so you can OR them, cut to the quick with #ifndef ALLPERMS #define ALLPERMS 07777 #endif ALLPERMS is a BSDism that even shows up in the linux headers. Since POSIX and SUSv3 specify that the actual mode_t bits are implementation specific I'm just a trifle leery of adding this in. We support some rather strange systems although ACCESSPERMS and INITACCESSPERMS don't appear to have bitten us so far. My paranoid side says that the actual value should be set in configure and default to ~0. My pragmatic side says so what, we wind up updating the mtime on directories anyway and it is no more data crossing the wire. There you have it. Sans simplification: -1 With simplification: +0.5 -- ________________________________________________________________ J.W. Schultz Pegasystems Technologies email address: jw@pegasys.ws Remember Cernan and Schmitt