Commit 5add6eb0 authored by Patrick Mochel's avatar Patrick Mochel

driverfs: Do hashed lookup of dentry's when deleting a driverfs file (instead...

driverfs: Do hashed lookup of dentry's when deleting a driverfs file (instead of searching the list we keep)
parent 9a8e1340
...@@ -724,26 +724,29 @@ int driverfs_create_symlink(struct driver_dir_entry * parent, ...@@ -724,26 +724,29 @@ int driverfs_create_symlink(struct driver_dir_entry * parent,
*/ */
void driverfs_remove_file(struct driver_dir_entry * dir, const char * name) void driverfs_remove_file(struct driver_dir_entry * dir, const char * name)
{ {
struct list_head * node; struct dentry * dentry;
struct qstr qstr;
if (!dir->dentry) if (!dir->dentry)
return; return;
down(&dir->dentry->d_inode->i_sem); down(&dir->dentry->d_inode->i_sem);
qstr.name = name;
qstr.len = strlen(name);
qstr.hash = full_name_hash(name,qstr.len);
dentry = lookup_hash(&qstr,dir->dentry);
node = dir->files.next; if (!IS_ERR(dentry)) {
while (node != &dir->files) { struct driver_file_entry * entry = dentry->d_fsdata;
struct driver_file_entry * entry = NULL;
entry = list_entry(node,struct driver_file_entry,node); /* make sure dentry is really there */
if (!strcmp(entry->name,name)) { if (dentry->d_inode &&
list_del_init(node); (dentry->d_parent->d_inode == dir->dentry->d_inode)) {
driverfs_unlink(entry->dentry->d_parent->d_inode,entry->dentry); list_del_init(&entry->node);
dput(entry->dentry); driverfs_unlink(dir->dentry->d_inode,dentry);
dput(dir->dentry);
put_mount(); put_mount();
break;
} }
node = node->next;
} }
up(&dir->dentry->d_inode->i_sem); up(&dir->dentry->d_inode->i_sem);
} }
......
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