diff options
Diffstat (limited to 'drivers/usb')
39 files changed, 25590 insertions, 0 deletions
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c new file mode 100644 index 00000000000..2278dad886e --- /dev/null +++ b/drivers/usb/core/inode.c | |||
| @@ -0,0 +1,776 @@ | |||
| 1 | /*****************************************************************************/ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * inode.c -- Inode/Dentry functions for the USB device file system. | ||
| 5 | * | ||
| 6 | * Copyright (C) 2000 Thomas Sailer (sailer@ife.ee.ethz.ch) | ||
| 7 | * Copyright (C) 2001,2002,2004 Greg Kroah-Hartman (greg@kroah.com) | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License as published by | ||
| 11 | * the Free Software Foundation; either version 2 of the License, or | ||
| 12 | * (at your option) any later version. | ||
| 13 | * | ||
| 14 | * This program is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | * GNU General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public License | ||
| 20 | * along with this program; if not, write to the Free Software | ||
| 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 22 | * | ||
| 23 | * History: | ||
| 24 | * 0.1 04.01.2000 Created | ||
| 25 | * 0.2 10.12.2001 converted to use the vfs layer better | ||
| 26 | */ | ||
| 27 | |||
| 28 | /*****************************************************************************/ | ||
| 29 | |||
| 30 | #include <linux/module.h> | ||
| 31 | #include <linux/fs.h> | ||
| 32 | #include <linux/mount.h> | ||
| 33 | #include <linux/pagemap.h> | ||
| 34 | #include <linux/init.h> | ||
| 35 | #include <linux/proc_fs.h> | ||
| 36 | #include <linux/usb.h> | ||
| 37 | #include <linux/namei.h> | ||
| 38 | #include <linux/usbdevice_fs.h> | ||
| 39 | #include <linux/parser.h> | ||
| 40 | #include <linux/notifier.h> | ||
| 41 | #include <linux/seq_file.h> | ||
| 42 | #include <linux/usb/hcd.h> | ||
| 43 | #include <asm/byteorder.h> | ||
| 44 | #include "usb.h" | ||
| 45 | |||
| 46 | #define USBFS_DEFAULT_DEVMODE (S_IWUSR | S_IRUGO) | ||
| 47 | #define USBFS_DEFAULT_BUSMODE (S_IXUGO | S_IRUGO) | ||
| 48 | #define USBFS_DEFAULT_LISTMODE S_IRUGO | ||
| 49 | |||
| 50 | static const struct file_operations default_file_operations; | ||
| 51 | static struct vfsmount *usbfs_mount; | ||
| 52 | static int usbfs_mount_count; /* = 0 */ | ||
| 53 | static int ignore_mount = 0; | ||
| 54 | |||
| 55 | static struct dentry *devices_usbfs_dentry; | ||
| 56 | static int num_buses; /* = 0 */ | ||
| 57 | |||
| 58 | static uid_t devuid; /* = 0 */ | ||
| 59 | static uid_t busuid; /* = 0 */ | ||
| 60 | static uid_t listuid; /* = 0 */ | ||
| 61 | static gid_t devgid; /* = 0 */ | ||
| 62 | static gid_t busgid; /* = 0 */ | ||
| 63 | static gid_t listgid; /* = 0 */ | ||
| 64 | static umode_t devmode = USBFS_DEFAULT_DEVMODE; | ||
| 65 | static umode_t busmode = USBFS_DEFAULT_BUSMODE; | ||
| 66 | static umode_t listmode = USBFS_DEFAULT_LISTMODE; | ||
| 67 | |||
| 68 | static int usbfs_show_options(struct seq_file *seq, struct vfsmount *mnt) | ||
| 69 | { | ||
| 70 | if (devuid != 0) | ||
| 71 | seq_printf(seq, ",devuid=%u", devuid); | ||
| 72 | if (devgid != 0) | ||
| 73 | seq_printf(seq, ",devgid=%u", devgid); | ||
| 74 | if (devmode != USBFS_DEFAULT_DEVMODE) | ||
| 75 | seq_printf(seq, ",devmode=%o", devmode); | ||
| 76 | if (busuid != 0) | ||
| 77 | seq_printf(seq, ",busuid=%u", busuid); | ||
| 78 | if (busgid != 0) | ||
| 79 | seq_printf(seq, ",busgid=%u", busgid); | ||
| 80 | if (busmode != USBFS_DEFAULT_BUSMODE) | ||
| 81 | seq_printf(seq, ",busmode=%o", busmode); | ||
| 82 | if (listuid != 0) | ||
| 83 | seq_printf(seq, ",listuid=%u", listuid); | ||
| 84 | if (listgid != 0) | ||
| 85 | seq_printf(seq, ",listgid=%u", listgid); | ||
| 86 | if (listmode != USBFS_DEFAULT_LISTMODE) | ||
| 87 | seq_printf(seq, ",listmode=%o", listmode); | ||
| 88 | |||
| 89 | return 0; | ||
| 90 | } | ||
| 91 | |||
| 92 | enum { | ||
| 93 | Opt_devuid, Opt_devgid, Opt_devmode, | ||
| 94 | Opt_busuid, Opt_busgid, Opt_busmode, | ||
| 95 | Opt_listuid, Opt_listgid, Opt_listmode, | ||
| 96 | Opt_err, | ||
| 97 | }; | ||
| 98 | |||
| 99 | static const match_table_t tokens = { | ||
| 100 | {Opt_devuid, "devuid=%u"}, | ||
| 101 | {Opt_devgid, "devgid=%u"}, | ||
| 102 | {Opt_devmode, "devmode=%o"}, | ||
| 103 | {Opt_busuid, "busuid=%u"}, | ||
| 104 | {Opt_busgid, "busgid=%u"}, | ||
| 105 | {Opt_busmode, "busmode=%o"}, | ||
| 106 | {Opt_listuid, "listuid=%u"}, | ||
| 107 | {Opt_listgid, "listgid=%u"}, | ||
| 108 | {Opt_listmode, "listmode=%o"}, | ||
| 109 | {Opt_err, NULL} | ||
| 110 | }; | ||
| 111 | |||
| 112 | static int parse_options(struct super_block *s, char *data) | ||
| 113 | { | ||
| 114 | char *p; | ||
| 115 | int option; | ||
| 116 | |||
| 117 | /* (re)set to defaults. */ | ||
| 118 | devuid = 0; | ||
| 119 | busuid = 0; | ||
| 120 | listuid = 0; | ||
| 121 | devgid = 0; | ||
| 122 | busgid = 0; | ||
| 123 | listgid = 0; | ||
| 124 | devmode = USBFS_DEFAULT_DEVMODE; | ||
| 125 | busmode = USBFS_DEFAULT_BUSMODE; | ||
| 126 | listmode = USBFS_DEFAULT_LISTMODE; | ||
| 127 | |||
| 128 | while ((p = strsep(&data, ",")) != NULL) { | ||
| 129 | substring_t args[MAX_OPT_ARGS]; | ||
| 130 | int token; | ||
| 131 | if (!*p) | ||
| 132 | continue; | ||
| 133 | |||
| 134 | token = match_token(p, tokens, args); | ||
| 135 | switch (token) { | ||
| 136 | case Opt_devuid: | ||
| 137 | if (match_int(&args[0], &option)) | ||
| 138 | return -EINVAL; | ||
| 139 | devuid = option; | ||
| 140 | break; | ||
| 141 | case Opt_devgid: | ||
| 142 | if (match_int(&args[0], &option)) | ||
| 143 | return -EINVAL; | ||
| 144 | devgid = option; | ||
| 145 | break; | ||
| 146 | case Opt_devmode: | ||
| 147 | if (match_octal(&args[0], &option)) | ||
| 148 | return -EINVAL; | ||
| 149 | devmode = option & S_IRWXUGO; | ||
| 150 | break; | ||
| 151 | case Opt_busuid: | ||
| 152 | if (match_int(&args[0], &option)) | ||
| 153 | return -EINVAL; | ||
| 154 | busuid = option; | ||
| 155 | break; | ||
| 156 | case Opt_busgid: | ||
| 157 | if (match_int(&args[0], &option)) | ||
| 158 | return -EINVAL; | ||
| 159 | busgid = option; | ||
| 160 | break; | ||
| 161 | case Opt_busmode: | ||
| 162 | if (match_octal(&args[0], &option)) | ||
| 163 | return -EINVAL; | ||
| 164 | busmode = option & S_IRWXUGO; | ||
| 165 | break; | ||
