rsync 2.6.9 on OS X. files with xattrs don't retain mtime.

Wesley W. Terpstra terpstra at gkec.informatik.tu-darmstadt.de
Sat Nov 11 15:35:48 GMT 2006


On Nov 10, 2006, at 9:28 PM, Wayne Davison wrote:
> On Fri, Nov 10, 2006 at 04:18:51PM +0100, Wesley W. Terpstra wrote:
>> However, if you sync a file that is identical in all respects except
>> the resource fork (xattrs), then the mtime is wrong for the first
>> run, but not the second (peanut->peanut2).
>
> I would imagine that is because rsync didn't call stat() on the  
> file, so
> it doesn't know that the mtime changed.

Ahh, of course. It did the stat before the setxattr, so didn't think  
the mtime needed updating, because it was correct already/before.

> We might want the set_xattr()
> function to restore the file's mtime (from file->modtime) when it  
> thinks
> that the mtime of the file was affected.

On osx the mtime only seems to get updated if you set things in  
com.apple.*, AFAICT.
However, that's not to say there might not be more!

I just checked on FreeBSD, and it resets the mtime on EVERY attribute  
change:
> terpstra at x86-freebsd1$ ~/rsync-cvs/rsync -a peanut peanut2
> terpstra at x86-freebsd1$ stat peanut*
> 1042 4249 -rw-r--r-- 1 terpstra users 0 0 "Nov 11 07:29:14 2006"  
> "Nov 11 07:28:29 2006" "Nov 11 07:28:51 2006" "Nov 11 07:28:29  
> 2006" 16384 0 0 peanut
> 1042 4251 -rw-r--r-- 1 terpstra users 0 0 "Nov 11 07:29:40 2006"  
> "Nov 11 07:28:29 2006" "Nov 11 07:29:40 2006" "Nov 11 07:28:29  
> 2006" 16384 0 0 peanut2
> terpstra at x86-freebsd1$ setextattr user test value peanut2
> terpstra at x86-freebsd1$ stat peanut*
> 1042 4249 -rw-r--r-- 1 terpstra users 0 0 "Nov 11 07:29:14 2006"  
> "Nov 11 07:28:29 2006" "Nov 11 07:28:51 2006" "Nov 11 07:28:29  
> 2006" 16384 0 0 peanut
> 1042 4251 -rw-r--r-- 1 terpstra users 0 0 "Nov 11 07:29:40 2006"  
> "Nov 11 07:29:58 2006" "Nov 11 07:29:58 2006" "Nov 11 07:28:29  
> 2006" 16384 4 0 peanut2

So, perhaps the sensible thing to do is just assume that the mtime is  
changed if you call set_xattr at all?

> Or have the set_xattr()
> function change the value of the sxp->st.st_mtime variable, and  
> have the
> regular mtime-setting code come after the xattr-setting code.

That makes the most sense to me, as long as there are no side-effects  
to putting the mtime code later.



More information about the rsync mailing list