[-mm patch] relayfs: relayfs_remove fix
From: Tom Zanussi (zanussi_at_us.ibm.com)
Date: 08/31/05
- Previous message: Zachary Amsden: "[PATCH 0/2] Trivial cleanups to virtualization tree"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 31 Aug 2005 16:56:01 -0500 To: akpm@osdl.org
This patch makes relayfs_remove use simple_rmdir for removing
directories instead of simple_unlink. Thanks to Nathan Scott for the
original patch.
Andrew, please apply.
Thanks,
Tom
Signed-off-by: Tom Zanussi <zanussi@us.ibm.com>
diff -urpN -X dontdiff linux-2.6.13-rc6-mm2/fs/relayfs/inode.c linux-2.6.13-rc6-mm2-cur/fs/relayfs/inode.c
--- linux-2.6.13-rc6-mm2/fs/relayfs/inode.c 2005-08-25 18:21:31.000000000 -0500
+++ linux-2.6.13-rc6-mm2-cur/fs/relayfs/inode.c 2005-08-31 17:11:12.000000000 -0500
@@ -189,26 +189,39 @@ struct dentry *relayfs_create_dir(const
/**
* relayfs_remove - remove a file or directory in the relay filesystem
* @dentry: file or directory dentry
+ *
+ * Returns 0 if successful, negative otherwise.
*/
int relayfs_remove(struct dentry *dentry)
{
- struct dentry *parent = dentry->d_parent;
+ struct dentry *parent;
+ int error = 0;
+
+ if (!dentry)
+ return -EINVAL;
+ parent = dentry->d_parent;
if (!parent)
return -EINVAL;
parent = dget(parent);
down(&parent->d_inode->i_sem);
if (dentry->d_inode) {
- simple_unlink(parent->d_inode, dentry);
- d_delete(dentry);
+ if (S_ISDIR(dentry->d_inode->i_mode))
+ error = simple_rmdir(parent->d_inode, dentry);
+ else
+ error = simple_unlink(parent->d_inode, dentry);
+ if (!error)
+ d_delete(dentry);
}
- dput(dentry);
+ if (!error)
+ dput(dentry);
up(&parent->d_inode->i_sem);
dput(parent);
- simple_release_fs(&relayfs_mount, &relayfs_mount_count);
+ if (!error)
+ simple_release_fs(&relayfs_mount, &relayfs_mount_count);
- return 0;
+ return error;
}
/**
@@ -219,9 +232,6 @@ int relayfs_remove(struct dentry *dentry
*/
int relayfs_remove_dir(struct dentry *dentry)
{
- if (!dentry)
- return -EINVAL;
-
return relayfs_remove(dentry);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- Previous message: Zachary Amsden: "[PATCH 0/2] Trivial cleanups to virtualization tree"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
- Fix up befs compile.
... * flag is set. ... -static int ... befs_follow_link(struct dentry
*dentry, struct nameidata *nd) ... send the line "unsubscribe linux-kernel" in ...
(Linux-Kernel) - [7/9] Lustre VFS patches for 2.6
... that may need some special handling by filesystems. ... -int do_truncate(struct
dentry *dentry, loff_t length) ... -extern int do_truncate ... send the line
"unsubscribe linux-kernel" in ... (Linux-Kernel) - [PATCH 1/8] VFS: pass file pointer to filesystem from ftruncate()
... and adds an ATTR_FILE validity flag for this member. ... -extern int
do_truncate(struct dentry *, ... send the line "unsubscribe linux-kernel" in ...
(Linux-Kernel) - [PATCH 02/12] HPPFS: dont check sb->s_op in is_pid()
... static int is_pid(struct dentry *dentry) ... send the line "unsubscribe
linux-kernel" in ... (Linux-Kernel) - Re: [PATCH] blk queue io tracing support
... The problem was that relayfs is allowing a directory ... int relayfs_remove(struct
dentry *dentry) ... int relayfs_remove_dir ... send the line "unsubscribe
linux-kernel" in ... (Linux-Kernel)