summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Pierre André <jpandre@users.sourceforge.net>2012-08-22 10:00:22 +0200
committerJean-Pierre André <jpandre@users.sourceforge.net>2012-08-22 10:00:22 +0200
commit5b71fba328f376b08e08670e7e9043e058382a51 (patch)
treebe448c6619594bb1be507cb7549e1ef70aacd8f4
parentd4a42629caa85f9b8f197b15aba5b287f1f16f82 (diff)
downloadillumos-fusefs-5b71fba328f376b08e08670e7e9043e058382a51.tar.gz
Made sure directories are not unlinked
-rw-r--r--kernel/fuse_vnops.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/kernel/fuse_vnops.c b/kernel/fuse_vnops.c
index 06c67aa..d0a4bf8 100644
--- a/kernel/fuse_vnops.c
+++ b/kernel/fuse_vnops.c
@@ -2974,6 +2974,7 @@ fuse_remove(vnode_t *dvp, char *name, cred_t *credp, caller_context_t *ct,
int flags)
{
int err;
+ int seen_err;
fuse_msg_node_t *msgp;
fuse_session_t *sep;
int namelen = strlen(name) + 1;
@@ -2987,6 +2988,15 @@ fuse_remove(vnode_t *dvp, char *name, cred_t *credp, caller_context_t *ct,
return (ENODEV);
}
+ /* Check if we have seen and cached the associated vnode */
+ seen_err = fuse_getvnode(FUSE_NULL_ID, &vp, VNODE_CACHED,
+ 0, sep, dvp->v_vfsp, namelen, name, VNODE_TO_NODEID(dvp), credp);
+
+ /* Do not proceed if this is a directory */
+ if (!seen_err && vp && (vp->v_type == VDIR)) {
+ return (EPERM);
+ }
+
msgp = fuse_setup_message(namelen, FUSE_UNLINK,
VNODE_TO_NODEID(dvp), credp, FUSE_GET_UNIQUE(sep));
@@ -3006,11 +3016,8 @@ fuse_remove(vnode_t *dvp, char *name, cred_t *credp, caller_context_t *ct,
goto cleanup;
}
- /* Check if we have seen and cached the associated vnode */
- err = fuse_getvnode(FUSE_NULL_ID, &vp, VNODE_CACHED,
- 0, sep, dvp->v_vfsp, namelen, name, VNODE_TO_NODEID(dvp), credp);
-
- if (err) {
+ if (seen_err) {
+ err = seen_err;
if (err == ENOENT) {
/*
* This means, we don't have this vnode, so