From: Erez Zadok Date: Fri, 18 May 2007 05:45:18 +0000 (-0400) Subject: bug fix: retry lookup for different silly-renamed files X-Git-Tag: unionfs-2.1.1~125 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=7a6595ee1333f66cbb1acb0fda4383610d4c1cce;p=unionfs-2.6.36.y.git bug fix: retry lookup for different silly-renamed files 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. --- diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c index d824eaa085d..ab92cac1007 100644 --- a/fs/unionfs/commonfops.c +++ b/fs/unionfs/commonfops.c @@ -50,6 +50,7 @@ static int copyup_deleted_file(struct file *file, struct dentry *dentry, * 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; @@ -73,8 +74,11 @@ static int copyup_deleted_file(struct file *file, struct dentry *dentry, 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));