commit 02f12a1f9d9b0f12b114e9e15ab80c58e953eded
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date: Wed Apr 11 18:34:19 2007 -0400
on mount, expect an empty odf dir and create the hierarchy
diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index 7bf3822..a8cf8d0 100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -861,21 +861,13 @@ out_sb:
* b) silly rename if its not physically empty
* c) unlink if not a dir
*/
-int unionfs_force_rm(struct dentry *dentry, struct dentry **hidden_dentry, int
bindex)
+int check_empty_lower(struct dentry *lower_dentry, struct vfsmount *mnt)
{
- struct file *hidden_file;
- struct super_block *sb;
+ struct file *lower_file;
struct unionfs_rdutil_callback *buf = NULL;
int err;
- sb = dentry->d_sb;
- if (!S_ISDIR((*hidden_dentry)->d_inode->i_mode)) {
- err = vfs_unlink((*hidden_dentry)->d_parent->d_inode,
- (*hidden_dentry));
- if (err)
- goto out;
- goto refresh;
- }
+ BUG_ON(!S_ISDIR(lower_dentry->d_inode->i_mode));
/* check if dir is empty */
buf = kmalloc(sizeof(struct unionfs_rdutil_callback), GFP_KERNEL);
@@ -889,29 +881,51 @@ int unionfs_force_rm(struct dentry *dentry, struct dentry
**hidden_dentry, int b
buf->dir = NULL;
buf->filp = NULL;
- dget(*hidden_dentry);
- mntget(unionfs_lower_mnt_idx(dentry, bindex));
- branchget(sb, bindex);
- hidden_file = dentry_open(*hidden_dentry,
- unionfs_lower_mnt_idx(dentry, bindex),
- O_RDONLY);
- if (IS_ERR(hidden_file)) {
- err = PTR_ERR(hidden_file);
- dput(*hidden_dentry);
- branchput(sb, bindex);
+ dget(lower_dentry);
+ mntget(mnt);
+ lower_file = dentry_open(lower_dentry, mnt, O_RDONLY);
+ if (IS_ERR(lower_file)) {
+ err = PTR_ERR(lower_file);
+ dput(lower_dentry);
+ mntput(mnt);
goto out;
}
do {
buf->filldir_called = 0;
- err = vfs_readdir(hidden_file,
- readdir_util_callback, buf);
- if (buf->err)
- err = buf->err;
+ err = vfs_readdir(lower_file, readdir_util_callback, buf);
+ if (buf->err)
+ err = buf->err;
} while ((err >= 0) && buf->filldir_called);
- /* fput calls dput for hidden_dentry */
- fput(hidden_file);
+ fput(lower_file);
+out:
+ kfree(buf);
+ return err;
+}
+
+/* Remove the hidden dentry by:
+ * a) rmdir if its a physically empty dir
+ * b) silly rename if its not physically empty
+ * c) unlink if not a dir
+ */
+int unionfs_force_rm(struct dentry *dentry, struct dentry **hidden_dentry, int
bindex)
+{
+ struct super_block *sb;
+ int err;
+
+ sb = dentry->d_sb;
+ if (!S_ISDIR((*hidden_dentry)->d_inode->i_mode)) {
+ err = vfs_unlink((*hidden_dentry)->d_parent->d_inode,
+ (*hidden_dentry));
+ if (err)
+ goto out;
+ goto refresh;
+ }
+
+ /* check if dir is empty */
+ branchget(sb, bindex);
+ err = check_empty_lower(*hidden_dentry, unionfs_lower_mnt_idx(dentry,
bindex));
branchput(sb, bindex);
if (err == 0)
@@ -939,8 +953,6 @@ refresh:
}
unionfs_set_lower_dentry_idx(dentry, bindex, *hidden_dentry);
out:
- if (buf)
- kfree(buf);
return err;
}
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs