When we have to copyup an open-but-unlinked file, we have to give it a
temporary name, similar to NFS's silly-renamed files. So we generate
temporary file names until we find one that doesn't exist, and use it. The
code had a bug where if the silly-renamed file name already existed, Unionfs
would oops upon copyup to that temp name.
* the name exists in the dest branch, but it'd be nice to catch it
* sooner than later.
*/
+retry:
tmp_dentry = NULL;
do {
char *suffix = name + nlen - countersize;
err = copyup_named_file(dentry->d_parent->d_inode, file, name, bstart,
bindex, file->f_dentry->d_inode->i_size);
- if (err)
+ if (err) {
+ if (err == -EEXIST)
+ goto retry;
goto out;
+ }
/* bring it to the same state as an unlinked file */
hidden_dentry = unionfs_lower_dentry_idx(dentry, dbstart(dentry));