Matthew Bostrom
2005-Mar-03 20:33 UTC
Why does "rsync -av" always claim (incorrectly?) that it is updating write protected directories?
Hi, I usually run "rsync -av" so I can see all the files that have been modified. However, "rsync -av" always claims to be updating write protected directories, even when they have not been changed. I do not understand why. Here is an example using rsync version 2.6.3 on FreeBSD 5.3. I get similar results with rsync 2.6.0 on Gentoo Linux. -------- $ mkdir dir0 $ touch dir0/file $ rsync -av dir0 dir1 building file list ... done created directory dir1 dir0/ dir0/file sent 127 bytes received 40 bytes 334.00 bytes/sec total size is 0 speedup is 0.00 -------- So I have created dir0 and rsynced it to inside of dir1. This is all okay. -------- $ rsync -av dir0 dir1 building file list ... done sent 87 bytes received 20 bytes 214.00 bytes/sec total size is 0 speedup is 0.00 -------- I have rsynced it again. rsync shows that no files have changed. This is all okay. -------- $ ls -l dir1 total 2 drwxr-xr-x 2 parke parke 512 Mar 3 12:06 dir0 $ chmod -w dir0 $ rsync -av dir0 dir1 building file list ... done sent 87 bytes received 20 bytes 214.00 bytes/sec total size is 0 speedup is 0.00 $ ls -l dir1 total 2 dr-xr-xr-x 2 parke parke 512 Mar 3 12:06 dir0 -------- We see that dir1/dir0 is writable. I "chmod -w dir0". Then I "rsync -av" and rsync does not report that it has changed any files. However, we can see that dir1/dir0 is no longer writable. So rsync did change the permissions on dir1/dir0 (as it should have), it just did not report that it changed the permissions. Why not? -------- $ rsync -av dir0 dir1 building file list ... done dir0/ sent 87 bytes received 20 bytes 214.00 bytes/sec total size is 0 speedup is 0.00 -------- I rsync again. This time rsync claims that it is changing "dir0/". However, as far as I can tell, rsync is NOT changing anything. What am I missing here? -------- $ rsync -av dir0 dir1 building file list ... done dir0/ sent 87 bytes received 20 bytes 214.00 bytes/sec total size is 0 speedup is 0.00 -------- We can repeat the "rsync -av" as many times as we want. rsync will now always claim (incorrectly?) that it is modifying "dir0/". Why? -------- $ chmod u+w dir0 $ rsync -av dir0 dir1 building file list ... done dir0/ sent 87 bytes received 20 bytes 214.00 bytes/sec total size is 0 speedup is 0.00 -------- I make dir0 writable again. I rsync. rsync makes dir1/dir0 writable, as it should. rsync reports that it has changed "dir0/", as it should. Everything is okay here. -------- $ rsync -av dir0 dir1 building file list ... done sent 87 bytes received 20 bytes 214.00 bytes/sec total size is 0 speedup is 0.00 $ rsync -av dir0 dir1 building file list ... done sent 87 bytes received 20 bytes 214.00 bytes/sec total size is 0 speedup is 0.00 -------- Two more rsyncs with nothing to change and no changes reported. This is okay. So... to summarize: When I "rsync -av" write protected directories, rsync always (and incorrectly?) claims that it is changing those directories, even thought, as far as I can tell, rsync is not changing the directories. Is this a bug? Is there something I do not understand? Thanks! Matthew. ______________________________________________________________________ mb@mb.mbostrom.us
Wayne Davison
2005-Mar-06 17:47 UTC
Why does "rsync -av" always claim (incorrectly?) that it is updating write protected directories?
On Thu, Mar 03, 2005 at 12:32:39PM -0800, Matthew Bostrom wrote:> However, "rsync -av" always claims to be updating write > protected directories, even when they have not been changed. I do not > understand why.The reason is that rsync always tries to update the time on the directories in the transfer to match the sender, but it ignores any error generated from that operation because some OSes don't allow the time of a directory to be set to anything other than "now" by a normal user. Thus, rsync attempts to set the time on these dirs on every run. In 2.6.4 (not yet released) there is an option, --omit-dir-times (-O), that turns off the preservation of directory times. Because it is now possible to disable this, rsync no longer hides the error from a failed directory time-set -- it lets you know that it is failing, and you can then choose to use -O to tell rsync that it is OK to not set the times on the dirs (or you might notice the problem and fix it, etc.). ..wayne..