git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git]
/
drivers
/
usb
/
core
/
inode.c
diff --git
a/drivers/usb/core/inode.c
b/drivers/usb/core/inode.c
index
f9f9561
..
3cf945c
100644
(file)
--- a/
drivers/usb/core/inode.c
+++ b/
drivers/usb/core/inode.c
@@
-39,13
+39,13
@@
#include <linux/usbdevice_fs.h>
#include <linux/smp_lock.h>
#include <linux/parser.h>
#include <linux/usbdevice_fs.h>
#include <linux/smp_lock.h>
#include <linux/parser.h>
+#include <linux/notifier.h>
#include <asm/byteorder.h>
#include "usb.h"
#include "hcd.h"
static struct super_operations usbfs_ops;
static struct file_operations default_file_operations;
#include <asm/byteorder.h>
#include "usb.h"
#include "hcd.h"
static struct super_operations usbfs_ops;
static struct file_operations default_file_operations;
-static struct inode_operations usbfs_dir_inode_operations;
static struct vfsmount *usbfs_mount;
static int usbfs_mount_count; /* = 0 */
static int ignore_mount = 0;
static struct vfsmount *usbfs_mount;
static int usbfs_mount_count; /* = 0 */
static int ignore_mount = 0;
@@
-184,13
+184,13
@@
static void update_bus(struct dentry *bus)
bus->d_inode->i_gid = busgid;
bus->d_inode->i_mode = S_IFDIR | busmode;
bus->d_inode->i_gid = busgid;
bus->d_inode->i_mode = S_IFDIR | busmode;
-
down(&bus->d_inode->i_sem
);
+
mutex_lock(&bus->d_inode->i_mutex
);
- list_for_each_entry(dev, &bus->d_subdirs, d_child)
+ list_for_each_entry(dev, &bus->d_subdirs, d_
u.d_
child)
if (dev->d_inode)
update_dev(dev);
if (dev->d_inode)
update_dev(dev);
-
up(&bus->d_inode->i_sem
);
+
mutex_unlock(&bus->d_inode->i_mutex
);
}
static void update_sb(struct super_block *sb)
}
static void update_sb(struct super_block *sb)
@@
-201,9
+201,9
@@
static void update_sb(struct super_block *sb)
if (!root)
return;
if (!root)
return;
-
down(&root->d_inode->i_sem
);
+
mutex_lock(&root->d_inode->i_mutex
);
- list_for_each_entry(bus, &root->d_subdirs, d_child) {
+ list_for_each_entry(bus, &root->d_subdirs, d_
u.d_
child) {
if (bus->d_inode) {
switch (S_IFMT & bus->d_inode->i_mode) {
case S_IFDIR:
if (bus->d_inode) {
switch (S_IFMT & bus->d_inode->i_mode) {
case S_IFDIR:
@@
-219,7
+219,7
@@
static void update_sb(struct super_block *sb)
}
}
}
}
-
up(&root->d_inode->i_sem
);
+
mutex_unlock(&root->d_inode->i_mutex
);
}
static int remount(struct super_block *sb, int *flags, char *data)
}
static int remount(struct super_block *sb, int *flags, char *data)
@@
-261,7
+261,7
@@
static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de
inode->i_fop = &default_file_operations;
break;
case S_IFDIR:
inode->i_fop = &default_file_operations;
break;
case S_IFDIR:
- inode->i_op = &
usbfs
_dir_inode_operations;
+ inode->i_op = &
simple
_dir_inode_operations;
inode->i_fop = &simple_dir_operations;
/* directory inodes start off with i_nlink == 2 (for "." entry) */
inode->i_fop = &simple_dir_operations;
/* directory inodes start off with i_nlink == 2 (for "." entry) */
@@
-319,7
+319,7
@@
static int usbfs_empty (struct dentry *dentry)
spin_lock(&dcache_lock);
list_for_each(list, &dentry->d_subdirs) {
spin_lock(&dcache_lock);
list_for_each(list, &dentry->d_subdirs) {
- struct dentry *de = list_entry(list, struct dentry, d_child);
+ struct dentry *de = list_entry(list, struct dentry, d_
u.d_
child);
if (usbfs_positive(de)) {
spin_unlock(&dcache_lock);
return 0;
if (usbfs_positive(de)) {
spin_unlock(&dcache_lock);
return 0;
@@
-333,10
+333,10
@@
static int usbfs_empty (struct dentry *dentry)
static int usbfs_unlink (struct inode *dir, struct dentry *dentry)
{
struct inode *inode = dentry->d_inode;
static int usbfs_unlink (struct inode *dir, struct dentry *dentry)
{
struct inode *inode = dentry->d_inode;
-
down(&inode->i_sem
);
+
mutex_lock(&inode->i_mutex
);
dentry->d_inode->i_nlink--;
dput(dentry);
dentry->d_inode->i_nlink--;
dput(dentry);
-
up(&inode->i_sem
);
+
mutex_unlock(&inode->i_mutex
);
d_delete(dentry);
return 0;
}
d_delete(dentry);
return 0;
}
@@
-346,7
+346,7
@@
static int usbfs_rmdir(struct inode *dir, struct dentry *dentry)
int error = -ENOTEMPTY;
struct inode * inode = dentry->d_inode;
int error = -ENOTEMPTY;
struct inode * inode = dentry->d_inode;
-
down(&inode->i_sem
);
+
mutex_lock(&inode->i_mutex
);
dentry_unhash(dentry);
if (usbfs_empty(dentry)) {
dentry->d_inode->i_nlink -= 2;
dentry_unhash(dentry);
if (usbfs_empty(dentry)) {
dentry->d_inode->i_nlink -= 2;
@@
-355,7
+355,7
@@
static int usbfs_rmdir(struct inode *dir, struct dentry *dentry)
dir->i_nlink--;
error = 0;
}
dir->i_nlink--;
error = 0;
}
-
up(&inode->i_sem
);
+
mutex_unlock(&inode->i_mutex
);
if (!error)
d_delete(dentry);
dput(dentry);
if (!error)
d_delete(dentry);
dput(dentry);
@@
-380,7
+380,7
@@
static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
{
loff_t retval = -EINVAL;
{
loff_t retval = -EINVAL;
-
down(&file->f_dentry->d_inode->i_sem
);
+
mutex_lock(&file->f_dentry->d_inode->i_mutex
);
switch(orig) {
case 0:
if (offset > 0) {
switch(orig) {
case 0:
if (offset > 0) {
@@
-397,7
+397,7
@@
static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
default:
break;
}
default:
break;
}
-
up(&file->f_dentry->d_inode->i_sem
);
+
mutex_unlock(&file->f_dentry->d_inode->i_mutex
);
return retval;
}
return retval;
}
@@
-416,10
+416,6
@@
static struct file_operations default_file_operations = {
.llseek = default_file_lseek,
};
.llseek = default_file_lseek,
};
-static struct inode_operations usbfs_dir_inode_operations = {
- .lookup = simple_lookup,
-};
-
static struct super_operations usbfs_ops = {
.statfs = simple_statfs,
.drop_inode = generic_delete_inode,
static struct super_operations usbfs_ops = {
.statfs = simple_statfs,
.drop_inode = generic_delete_inode,
@@
-453,17
+449,6
@@
static int usbfs_fill_super(struct super_block *sb, void *data, int silent)
return 0;
}
return 0;
}
-static struct dentry * get_dentry(struct dentry *parent, const char *name)
-{
- struct qstr qstr;
-
- qstr.name = name;
- qstr.len = strlen(name);
- qstr.hash = full_name_hash(name,qstr.len);
- return lookup_hash(&qstr,parent);
-}
-
-
/*
* fs_create_by_name - create a file, given a name
* @name: name of file
/*
* fs_create_by_name - create a file, given a name
* @name: name of file
@@
-495,8
+480,8
@@
static int fs_create_by_name (const char *name, mode_t mode,
}
*dentry = NULL;
}
*dentry = NULL;
-
down(&parent->d_inode->i_sem
);
- *dentry =
get_dentry (parent, name
);
+
mutex_lock(&parent->d_inode->i_mutex
);
+ *dentry =
lookup_one_len(name, parent, strlen(name)
);
if (!IS_ERR(dentry)) {
if ((mode & S_IFMT) == S_IFDIR)
error = usbfs_mkdir (parent->d_inode, *dentry, mode);
if (!IS_ERR(dentry)) {
if ((mode & S_IFMT) == S_IFDIR)
error = usbfs_mkdir (parent->d_inode, *dentry, mode);
@@
-504,7
+489,7
@@
static int fs_create_by_name (const char *name, mode_t mode,
error = usbfs_create (parent->d_inode, *dentry, mode);
} else
error = PTR_ERR(dentry);
error = usbfs_create (parent->d_inode, *dentry, mode);
} else
error = PTR_ERR(dentry);
-
up(&parent->d_inode->i_sem
);
+
mutex_unlock(&parent->d_inode->i_mutex
);
return error;
}
return error;
}
@@
-543,7
+528,7
@@
static void fs_remove_file (struct dentry *dentry)
if (!parent || !parent->d_inode)
return;
if (!parent || !parent->d_inode)
return;
-
down(&parent->d_inode->i_sem
);
+
mutex_lock(&parent->d_inode->i_mutex
);
if (usbfs_positive(dentry)) {
if (dentry->d_inode) {
if (S_ISDIR(dentry->d_inode->i_mode))
if (usbfs_positive(dentry)) {
if (dentry->d_inode) {
if (S_ISDIR(dentry->d_inode->i_mode))
@@
-553,7
+538,7
@@
static void fs_remove_file (struct dentry *dentry)
dput(dentry);
}
}
dput(dentry);
}
}
-
up(&parent->d_inode->i_sem
);
+
mutex_unlock(&parent->d_inode->i_mutex
);
}
/* --------------------------------------------------------------------- */
}
/* --------------------------------------------------------------------- */
@@
-630,7
+615,7
@@
void usbfs_update_special (void)
}
}
}
}
-void usbfs_add_bus(struct usb_bus *bus)
+
static
void usbfs_add_bus(struct usb_bus *bus)
{
struct dentry *parent;
char name[8];
{
struct dentry *parent;
char name[8];
@@
-653,12
+638,9
@@
void usbfs_add_bus(struct usb_bus *bus)
err ("error creating usbfs bus entry");
return;
}
err ("error creating usbfs bus entry");
return;
}
-
- usbfs_update_special();
- usbfs_conn_disc_event();
}
}
-void usbfs_remove_bus(struct usb_bus *bus)
+
static
void usbfs_remove_bus(struct usb_bus *bus)
{
if (bus->usbfs_dentry) {
fs_remove_file (bus->usbfs_dentry);
{
if (bus->usbfs_dentry) {
fs_remove_file (bus->usbfs_dentry);
@@
-670,12
+652,9
@@
void usbfs_remove_bus(struct usb_bus *bus)
remove_special_files();
num_buses = 0;
}
remove_special_files();
num_buses = 0;
}
-
- usbfs_update_special();
- usbfs_conn_disc_event();
}
}
-void usbfs_add_device(struct usb_device *dev)
+
static
void usbfs_add_device(struct usb_device *dev)
{
char name[8];
int i;
{
char name[8];
int i;
@@
-701,12
+680,9
@@
void usbfs_add_device(struct usb_device *dev)
}
if (dev->usbfs_dentry->d_inode)
dev->usbfs_dentry->d_inode->i_size = i_size;
}
if (dev->usbfs_dentry->d_inode)
dev->usbfs_dentry->d_inode->i_size = i_size;
-
- usbfs_update_special();
- usbfs_conn_disc_event();
}
}
-void usbfs_remove_device(struct usb_device *dev)
+
static
void usbfs_remove_device(struct usb_device *dev)
{
struct dev_state *ds;
struct siginfo sinfo;
{
struct dev_state *ds;
struct siginfo sinfo;
@@
-724,13
+700,36
@@
void usbfs_remove_device(struct usb_device *dev)
sinfo.si_errno = EPIPE;
sinfo.si_code = SI_ASYNCIO;
sinfo.si_addr = ds->disccontext;
sinfo.si_errno = EPIPE;
sinfo.si_code = SI_ASYNCIO;
sinfo.si_addr = ds->disccontext;
-
send_sig_info(ds->discsignr, &sinfo, ds->disctask
);
+
kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid
);
}
}
}
}
+}
+
+static int usbfs_notify(struct notifier_block *self, unsigned long action, void *dev)
+{
+ switch (action) {
+ case USB_DEVICE_ADD:
+ usbfs_add_device(dev);
+ break;
+ case USB_DEVICE_REMOVE:
+ usbfs_remove_device(dev);
+ break;
+ case USB_BUS_ADD:
+ usbfs_add_bus(dev);
+ break;
+ case USB_BUS_REMOVE:
+ usbfs_remove_bus(dev);
+ }
+
usbfs_update_special();
usbfs_conn_disc_event();
usbfs_update_special();
usbfs_conn_disc_event();
+ return NOTIFY_OK;
}
}
+static struct notifier_block usbfs_nb = {
+ .notifier_call = usbfs_notify,
+};
+
/* --------------------------------------------------------------------- */
static struct proc_dir_entry *usbdir = NULL;
/* --------------------------------------------------------------------- */
static struct proc_dir_entry *usbdir = NULL;
@@
-739,15
+738,11
@@
int __init usbfs_init(void)
{
int retval;
{
int retval;
- retval =
usb_register(&usbfs_driver
);
+ retval =
register_filesystem(&usb_fs_type
);
if (retval)
return retval;
if (retval)
return retval;
- retval = register_filesystem(&usb_fs_type);
- if (retval) {
- usb_deregister(&usbfs_driver);
- return retval;
- }
+ usb_register_notify(&usbfs_nb);
/* create mount point for usbfs */
usbdir = proc_mkdir("usb", proc_bus);
/* create mount point for usbfs */
usbdir = proc_mkdir("usb", proc_bus);
@@
-757,7
+752,7
@@
int __init usbfs_init(void)
void usbfs_cleanup(void)
{
void usbfs_cleanup(void)
{
- usb_
deregister(&usbfs_driver
);
+ usb_
unregister_notify(&usbfs_nb
);
unregister_filesystem(&usb_fs_type);
if (usbdir)
remove_proc_entry("usb", proc_bus);
unregister_filesystem(&usb_fs_type);
if (usbdir)
remove_proc_entry("usb", proc_bus);