FW: compare st_mode & 07777, or Aix dirs always differ

Paul Green paulg at sw.stratus.com
Wed Feb 19 05:08:35 EST 2003


>jw schultz [mailto:jw at pegasys.ws] wrote:
>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.

I did some research and found that ALLPERMS is not in POSIX-96 or POSIX-01. Therefore, I don't 
think it is wise to use it in rsync, unless one were to write a full-bore configure test, and 
define it if it is not present.

The POSIX-01 description of chmod() says that it changes S_ISUID, S_ISGID, S_ISVTX, and the 
file permission bits.  My feeling is that it would be ok to use a mask of those 3 macros with 
0777; any implementation that doesn't make the file permission bits the low-order 9 bits with 
their usual definition is insane.

Actually, I think the original definition (below), is just fine, as long as the non-POSIX-96 
macro S_ISVTX is handled.
	
	#define CHMOD_BITS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
	
We already define ACCESSPERMS as 0777 in rsync.h, so I used that macro instead of the 3 S_IRWXx 
macros.  I applied this change, and I also update the call to do_chmod in rsync.c to also mask 
down the bits.  rsync will no longer play with the funky system-specific bits. If people need 
it to do that, I'd ask that we get patches with configure tests for them.

Roderick, would you please grab a copy of rsync from CVS and retest this change?  You can see 
my patch at http://lists.samba.org/pipermail/rsync-cvs/2003-February/date.html


Thanks
PG
--
Paul Green, Senior Technical Consultant, Stratus Technologies.
Voice: +1 978-461-7557; FAX: +1 978-461-3610
Speaking from Stratus not for Stratus





More information about the rsync mailing list