Commit 1b867c36 authored by Patrick Mochel's avatar Patrick Mochel

sysfs: various updates.

- Don't do extra dget() when creating symlink. 
This is a long-standing bug with a simple and obvious fix. We were doing 
an extra dget() on the dentry after d_instantiate(). It only gets decremented
once on removal, so the dentry was never really going away, and the directory
wasn't, either. 

- Use simple_unlink() instead of sysfs_unlink().

- Use simple_rmdir() instead of our own, unrolled, version. 

- Remove MODULE_LICENSE(), since it's always in the kernel. 
parent f35ce67f
......@@ -135,26 +135,14 @@ static int sysfs_symlink(struct inode * dir, struct dentry *dentry, const char *
if (inode) {
int l = strlen(symname)+1;
error = page_symlink(inode, symname, l);
if (!error) {
if (!error)
d_instantiate(dentry, inode);
dget(dentry);
} else
else
iput(inode);
}
return error;
}
static int sysfs_unlink(struct inode *dir, struct dentry *dentry)
{
struct inode *inode = dentry->d_inode;
down(&inode->i_sem);
dentry->d_inode->i_nlink--;
up(&inode->i_sem);
d_invalidate(dentry);
dput(dentry);
return 0;
}
/**
* sysfs_read_file - read an attribute.
* @file: file pointer.
......@@ -583,7 +571,8 @@ static void hash_and_remove(struct dentry * dir, const char * name)
/* make sure dentry is really there */
if (victim->d_inode &&
(victim->d_parent->d_inode == dir->d_inode)) {
sysfs_unlink(dir->d_inode,victim);
d_invalidate(victim);
simple_unlink(dir->d_inode,victim);
}
}
up(&dir->d_inode->i_sem);
......@@ -641,18 +630,15 @@ void sysfs_remove_dir(struct kobject * kobj)
list_for_each_safe(node,next,&dentry->d_subdirs) {
struct dentry * d = list_entry(node,struct dentry,d_child);
/* make sure dentry is still there */
if (d->d_inode)
sysfs_unlink(dentry->d_inode,d);
if (d->d_inode) {
d_invalidate(d);
simple_unlink(dentry->d_inode,d);
}
}
d_invalidate(dentry);
if (simple_empty(dentry)) {
dentry->d_inode->i_nlink -= 2;
dentry->d_inode->i_flags |= S_DEAD;
parent->d_inode->i_nlink--;
}
up(&dentry->d_inode->i_sem);
dput(dentry);
d_invalidate(dentry);
simple_rmdir(parent->d_inode,dentry);
up(&parent->d_inode->i_sem);
dput(parent);
......@@ -664,4 +650,3 @@ EXPORT_SYMBOL(sysfs_create_link);
EXPORT_SYMBOL(sysfs_remove_link);
EXPORT_SYMBOL(sysfs_create_dir);
EXPORT_SYMBOL(sysfs_remove_dir);
MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment