lkml.org 
[lkml]   [2009]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH 25/20] sysfs: Only support removing emtpy sysfs directories.
From: Eric W. Biederman <ebiederm@xmission.com>

I have looked and I have not found a single legitimate case today where
we remove sysfs directories with anything in them. The only case I have
found to date was a bug. It was a problem of ownership. The files in
the directory where not owned by the directory itself. Leaving open
the potential for double deletion of the directory contents.

Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
---
fs/sysfs/dir.c | 24 ++++--------------------
1 files changed, 4 insertions(+), 20 deletions(-)
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index b3058f5..6b3e038 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -617,30 +617,14 @@ const struct inode_operations sysfs_dir_inode_operations = {
.permission = sysfs_permission,
};

-static struct sysfs_dirent *sysfs_get_one(struct sysfs_dirent *dir_sd)
-{
- struct sysfs_dirent *sd = dir_sd;
- mutex_lock(&sysfs_mutex);
- while ((sysfs_type(sd) == SYSFS_DIR) && sd->s_dir.children)
- sd = sd->s_dir.children;
- if (sd != dir_sd)
- sysfs_get(sd);
- else
- sd = NULL;
- mutex_unlock(&sysfs_mutex);
- return sd;
-}
-
static void remove_dir(struct sysfs_dirent *dir_sd)
{
- struct sysfs_dirent *sd;
-
pr_debug("sysfs %s: removing dir\n", dir_sd->s_name);

- while ((sd = sysfs_get_one(dir_sd))) {
- sysfs_remove_one(sd);
- sysfs_put(sd);
- }
+ WARN(dir_sd->s_dir.children,
+ KERN_WARNING "sysfs: removing non-empty dir: %s\n",
+ dir_sd->s_name);
+
sysfs_remove_one(dir_sd);
}

--
1.6.3.1.54.g99dd.dirty


\
 
 \ /
  Last update: 2009-05-23 22:19    [W:0.266 / U:0.236 seconds]
©2003-2014 Jasper Spaans. Advertise on this site