Getting EEXIST out of make_bak_dir()

Mike Bombich mike at bombich.com
Mon Mar 8 09:02:26 MST 2010


I have users running rsync 3.0.6 on Mac OS 10.5 and 10.6 with the following arguments (for example):

rsync -aNHAXx --fileflags --force-change --no-inc-recursive --delete-during --filter="P _Archive*" --filter="P /*" --backup --backup-dir="_Archive_2010_March_07_22-27-43" / /Volumes/Backup

I can't seem to figure out how make_bak_dir could be returning this error for a handful of them:

rsync: make_bak_dir mkdir "/Volumes/Backup/_Archive_2010_March_07_22-27-43/Users/jsmith/Library/Mail/Mailboxes/   Orchestra" failed: File exists
rsync: keep_backup failed: "/Volumes/Backup/Users/jsmith/Library/Mail/Mailboxes/   Orchestra/    * New Mexico Concert/Assistant - John Smith.mbox/Messages/269981.emlx" -> "_Archive_2010_March_07_22-27-43/Users/jsmith/Library/Mail/Mailboxes/   Orchestra/    * New Mexico Concert/Assistant - John Smith.mbox/Messages/269981.emlx": No such file or directory
rsync: stat "/Volumes/Backup/_Archive_2010_March_07_22-27-43/Users/jsmith/Library/Mail/Mailboxes/   Orchestra/    * New Mexico Concert/Assistant - John Smith.mbox/Messages/269981.emlx" failed: No such file or directory

Here's another example from a different user:

rsync: make_bak_dir mkdir "/Volumes/LaCie 1TB/_Archive_2010_March_04_18-30-22/Users/jdoe/Library/Caches" failed: File exists
rsync: keep_backup failed: "/Volumes/LaCie 1TB/Users/jdoe/Library/Caches/Adobe/Color/ACEConfigCache1" -> "_Archive_2010_March_04_18-30-22/Users/jdoe/Library/Caches/Adobe/Color/ACEConfigCache1": No such file or directory
rsync: stat "/Volumes/LaCie 1TB/_Archive_2010_March_04_18-30-22/Users/jdoe/Library/Caches/Adobe/Color/ACEConfigCache1" failed: No such file or directory


Because everywhere that make_bak_dir is called, there's a test that the previous open() that was called failed with ENOENT.  For example, from receiver.c:

if ((f_copy = do_open(backupptr, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600)) < 0) {
	int save_errno = errno ? errno : EINVAL; /* 0 paranoia */
	if (errno == ENOENT && make_bak_dir(backupptr) == 0) {

Does make_bak_dir simply need to trap for that error, like:

/* Try to find an existing dir, starting from the deepest dir. */
while (1) {
	if (--p == fbuf)
		return -1;
	if (*p == '/') {
		*p = '\0';
		if (mkdir_defmode(fbuf) == 0 || errno == EEXIST) // <-- Trap for EEXIST?
			break;
		if (errno != ENOENT) {
			rsyserr(FERROR, errno,
				"make_bak_dir mkdir %s failed",
				full_fname(fbuf));
			return -1;
		}
	}
}

Thanks,
Mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/rsync/attachments/20100308/55c611d1/attachment.html>


More information about the rsync mailing list