inode.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. /*****************************************************************************/
  2. /*
  3. * inode.c -- Inode/Dentry functions for the USB device file system.
  4. *
  5. * Copyright (C) 2000 Thomas Sailer (sailer@ife.ee.ethz.ch)
  6. * Copyright (C) 2001,2002,2004 Greg Kroah-Hartman (greg@kroah.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. *
  22. * History:
  23. * 0.1 04.01.2000 Created
  24. * 0.2 10.12.2001 converted to use the vfs layer better
  25. */
  26. /*****************************************************************************/
  27. #include <linux/config.h>
  28. #include <linux/module.h>
  29. #include <linux/fs.h>
  30. #include <linux/mount.h>
  31. #include <linux/pagemap.h>
  32. #include <linux/init.h>
  33. #include <linux/proc_fs.h>
  34. #include <linux/usb.h>
  35. #include <linux/namei.h>
  36. #include <linux/usbdevice_fs.h>
  37. #include <linux/smp_lock.h>
  38. #include <linux/parser.h>
  39. #include <asm/byteorder.h>
  40. #include "usb.h"
  41. #include "hcd.h"
  42. static struct super_operations usbfs_ops;
  43. static struct file_operations default_file_operations;
  44. static struct inode_operations usbfs_dir_inode_operations;
  45. static struct vfsmount *usbfs_mount;
  46. static int usbfs_mount_count; /* = 0 */
  47. static int ignore_mount = 0;
  48. static struct dentry *devices_usbfs_dentry;
  49. static int num_buses; /* = 0 */
  50. static uid_t devuid; /* = 0 */
  51. static uid_t busuid; /* = 0 */
  52. static uid_t listuid; /* = 0 */
  53. static gid_t devgid; /* = 0 */
  54. static gid_t busgid; /* = 0 */
  55. static gid_t listgid; /* = 0 */
  56. static umode_t devmode = S_IWUSR | S_IRUGO;
  57. static umode_t busmode = S_IXUGO | S_IRUGO;
  58. static umode_t listmode = S_IRUGO;
  59. enum {
  60. Opt_devuid, Opt_devgid, Opt_devmode,
  61. Opt_busuid, Opt_busgid, Opt_busmode,
  62. Opt_listuid, Opt_listgid, Opt_listmode,
  63. Opt_err,
  64. };
  65. static match_table_t tokens = {
  66. {Opt_devuid, "devuid=%u"},
  67. {Opt_devgid, "devgid=%u"},
  68. {Opt_devmode, "devmode=%o"},
  69. {Opt_busuid, "busuid=%u"},
  70. {Opt_busgid, "busgid=%u"},
  71. {Opt_busmode, "busmode=%o"},
  72. {Opt_listuid, "listuid=%u"},
  73. {Opt_listgid, "listgid=%u"},
  74. {Opt_listmode, "listmode=%o"},
  75. {Opt_err, NULL}
  76. };
  77. static int parse_options(struct super_block *s, char *data)
  78. {
  79. char *p;
  80. int option;
  81. /* (re)set to defaults. */
  82. devuid = 0;
  83. busuid = 0;
  84. listuid = 0;
  85. devgid = 0;
  86. busgid = 0;
  87. listgid = 0;
  88. devmode = S_IWUSR | S_IRUGO;
  89. busmode = S_IXUGO | S_IRUGO;
  90. listmode = S_IRUGO;
  91. while ((p = strsep(&data, ",")) != NULL) {
  92. substring_t args[MAX_OPT_ARGS];
  93. int token;
  94. if (!*p)
  95. continue;
  96. token = match_token(p, tokens, args);
  97. switch (token) {
  98. case Opt_devuid:
  99. if (match_int(&args[0], &option))
  100. return -EINVAL;
  101. devuid = option;
  102. break;
  103. case Opt_devgid:
  104. if (match_int(&args[0], &option))
  105. return -EINVAL;
  106. devgid = option;
  107. break;
  108. case Opt_devmode:
  109. if (match_octal(&args[0], &option))
  110. return -EINVAL;
  111. devmode = option & S_IRWXUGO;
  112. break;
  113. case Opt_busuid:
  114. if (match_int(&args[0], &option))
  115. return -EINVAL;
  116. busuid = option;
  117. break;
  118. case Opt_busgid:
  119. if (match_int(&args[0], &option))
  120. return -EINVAL;
  121. busgid = option;
  122. break;
  123. case Opt_busmode:
  124. if (match_octal(&args[0], &option))
  125. return -EINVAL;
  126. busmode = option & S_IRWXUGO;
  127. break;
  128. case Opt_listuid:
  129. if (match_int(&args[0], &option))
  130. return -EINVAL;
  131. listuid = option;
  132. break;
  133. case Opt_listgid:
  134. if (match_int(&args[0], &option))
  135. return -EINVAL;
  136. listgid = option;
  137. break;
  138. case Opt_listmode:
  139. if (match_octal(&args[0], &option))
  140. return -EINVAL;
  141. listmode = option & S_IRWXUGO;
  142. break;
  143. default:
  144. err("usbfs: unrecognised mount option \"%s\" "
  145. "or missing value\n", p);
  146. return -EINVAL;
  147. }
  148. }
  149. return 0;
  150. }
  151. static void update_special(struct dentry *special)
  152. {
  153. special->d_inode->i_uid = listuid;
  154. special->d_inode->i_gid = listgid;
  155. special->d_inode->i_mode = S_IFREG | listmode;
  156. }
  157. static void update_dev(struct dentry *dev)
  158. {
  159. dev->d_inode->i_uid = devuid;
  160. dev->d_inode->i_gid = devgid;
  161. dev->d_inode->i_mode = S_IFREG | devmode;
  162. }
  163. static void update_bus(struct dentry *bus)
  164. {
  165. struct dentry *dev = NULL;
  166. bus->d_inode->i_uid = busuid;
  167. bus->d_inode->i_gid = busgid;
  168. bus->d_inode->i_mode = S_IFDIR | busmode;
  169. down(&bus->d_inode->i_sem);
  170. list_for_each_entry(dev, &bus->d_subdirs, d_child)
  171. if (dev->d_inode)
  172. update_dev(dev);
  173. up(&bus->d_inode->i_sem);
  174. }
  175. static void update_sb(struct super_block *sb)
  176. {
  177. struct dentry *root = sb->s_root;
  178. struct dentry *bus = NULL;
  179. if (!root)
  180. return;
  181. down(&root->d_inode->i_sem);
  182. list_for_each_entry(bus, &root->d_subdirs, d_child) {
  183. if (bus->d_inode) {
  184. switch (S_IFMT & bus->d_inode->i_mode) {
  185. case S_IFDIR:
  186. update_bus(bus);
  187. break;
  188. case S_IFREG:
  189. update_special(bus);
  190. break;
  191. default:
  192. warn("Unknown node %s mode %x found on remount!\n",bus->d_name.name,bus->d_inode->i_mode);
  193. break;
  194. }
  195. }
  196. }
  197. up(&root->d_inode->i_sem);
  198. }
  199. static int remount(struct super_block *sb, int *flags, char *data)
  200. {
  201. /* If this is not a real mount,
  202. * i.e. it's a simple_pin_fs from create_special_files,
  203. * then ignore it.
  204. */
  205. if (ignore_mount)
  206. return 0;
  207. if (parse_options(sb, data)) {
  208. warn("usbfs: mount parameter error:");
  209. return -EINVAL;
  210. }
  211. if (usbfs_mount && usbfs_mount->mnt_sb)
  212. update_sb(usbfs_mount->mnt_sb);
  213. return 0;
  214. }
  215. static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t dev)
  216. {
  217. struct inode *inode = new_inode(sb);
  218. if (inode) {
  219. inode->i_mode = mode;
  220. inode->i_uid = current->fsuid;
  221. inode->i_gid = current->fsgid;
  222. inode->i_blksize = PAGE_CACHE_SIZE;
  223. inode->i_blocks = 0;
  224. inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  225. switch (mode & S_IFMT) {
  226. default:
  227. init_special_inode(inode, mode, dev);
  228. break;
  229. case S_IFREG:
  230. inode->i_fop = &default_file_operations;
  231. break;
  232. case S_IFDIR:
  233. inode->i_op = &usbfs_dir_inode_operations;
  234. inode->i_fop = &simple_dir_operations;
  235. /* directory inodes start off with i_nlink == 2 (for "." entry) */
  236. inode->i_nlink++;
  237. break;
  238. }
  239. }
  240. return inode;
  241. }
  242. /* SMP-safe */
  243. static int usbfs_mknod (struct inode *dir, struct dentry *dentry, int mode,
  244. dev_t dev)
  245. {
  246. struct inode *inode = usbfs_get_inode(dir->i_sb, mode, dev);
  247. int error = -EPERM;
  248. if (dentry->d_inode)
  249. return -EEXIST;
  250. if (inode) {
  251. d_instantiate(dentry, inode);
  252. dget(dentry);
  253. error = 0;
  254. }
  255. return error;
  256. }
  257. static int usbfs_mkdir (struct inode *dir, struct dentry *dentry, int mode)
  258. {
  259. int res;
  260. mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR;
  261. res = usbfs_mknod (dir, dentry, mode, 0);
  262. if (!res)
  263. dir->i_nlink++;
  264. return res;
  265. }
  266. static int usbfs_create (struct inode *dir, struct dentry *dentry, int mode)
  267. {
  268. mode = (mode & S_IALLUGO) | S_IFREG;
  269. return usbfs_mknod (dir, dentry, mode, 0);
  270. }
  271. static inline int usbfs_positive (struct dentry *dentry)
  272. {
  273. return dentry->d_inode && !d_unhashed(dentry);
  274. }
  275. static int usbfs_empty (struct dentry *dentry)
  276. {
  277. struct list_head *list;
  278. spin_lock(&dcache_lock);
  279. list_for_each(list, &dentry->d_subdirs) {
  280. struct dentry *de = list_entry(list, struct dentry, d_child);
  281. if (usbfs_positive(de)) {
  282. spin_unlock(&dcache_lock);
  283. return 0;
  284. }
  285. }
  286. spin_unlock(&dcache_lock);
  287. return 1;
  288. }
  289. static int usbfs_unlink (struct inode *dir, struct dentry *dentry)
  290. {
  291. struct inode *inode = dentry->d_inode;
  292. down(&inode->i_sem);
  293. dentry->d_inode->i_nlink--;
  294. dput(dentry);
  295. up(&inode->i_sem);
  296. d_delete(dentry);
  297. return 0;
  298. }
  299. static int usbfs_rmdir(struct inode *dir, struct dentry *dentry)
  300. {
  301. int error = -ENOTEMPTY;
  302. struct inode * inode = dentry->d_inode;
  303. down(&inode->i_sem);
  304. dentry_unhash(dentry);
  305. if (usbfs_empty(dentry)) {
  306. dentry->d_inode->i_nlink -= 2;
  307. dput(dentry);
  308. inode->i_flags |= S_DEAD;
  309. dir->i_nlink--;
  310. error = 0;
  311. }
  312. up(&inode->i_sem);
  313. if (!error)
  314. d_delete(dentry);
  315. dput(dentry);
  316. return error;
  317. }
  318. /* default file operations */
  319. static ssize_t default_read_file (struct file *file, char __user *buf,
  320. size_t count, loff_t *ppos)
  321. {
  322. return 0;
  323. }
  324. static ssize_t default_write_file (struct file *file, const char __user *buf,
  325. size_t count, loff_t *ppos)
  326. {
  327. return count;
  328. }
  329. static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
  330. {
  331. loff_t retval = -EINVAL;
  332. down(&file->f_dentry->d_inode->i_sem);
  333. switch(orig) {
  334. case 0:
  335. if (offset > 0) {
  336. file->f_pos = offset;
  337. retval = file->f_pos;
  338. }
  339. break;
  340. case 1:
  341. if ((offset + file->f_pos) > 0) {
  342. file->f_pos += offset;
  343. retval = file->f_pos;
  344. }
  345. break;
  346. default:
  347. break;
  348. }
  349. up(&file->f_dentry->d_inode->i_sem);
  350. return retval;
  351. }
  352. static int default_open (struct inode *inode, struct file *file)
  353. {
  354. if (inode->u.generic_ip)
  355. file->private_data = inode->u.generic_ip;
  356. return 0;
  357. }
  358. static struct file_operations default_file_operations = {
  359. .read = default_read_file,
  360. .write = default_write_file,
  361. .open = default_open,
  362. .llseek = default_file_lseek,
  363. };
  364. static struct inode_operations usbfs_dir_inode_operations = {
  365. .lookup = simple_lookup,
  366. };
  367. static struct super_operations usbfs_ops = {
  368. .statfs = simple_statfs,
  369. .drop_inode = generic_delete_inode,
  370. .remount_fs = remount,
  371. };
  372. static int usbfs_fill_super(struct super_block *sb, void *data, int silent)
  373. {
  374. struct inode *inode;
  375. struct dentry *root;
  376. sb->s_blocksize = PAGE_CACHE_SIZE;
  377. sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
  378. sb->s_magic = USBDEVICE_SUPER_MAGIC;
  379. sb->s_op = &usbfs_ops;
  380. sb->s_time_gran = 1;
  381. inode = usbfs_get_inode(sb, S_IFDIR | 0755, 0);
  382. if (!inode) {
  383. dbg("%s: could not get inode!",__FUNCTION__);
  384. return -ENOMEM;
  385. }
  386. root = d_alloc_root(inode);
  387. if (!root) {
  388. dbg("%s: could not get root dentry!",__FUNCTION__);
  389. iput(inode);
  390. return -ENOMEM;
  391. }
  392. sb->s_root = root;
  393. return 0;
  394. }
  395. /*
  396. * fs_create_by_name - create a file, given a name
  397. * @name: name of file
  398. * @mode: type of file
  399. * @parent: dentry of directory to create it in
  400. * @dentry: resulting dentry of file
  401. *
  402. * This function handles both regular files and directories.
  403. */
  404. static int fs_create_by_name (const char *name, mode_t mode,
  405. struct dentry *parent, struct dentry **dentry)
  406. {
  407. int error = 0;
  408. /* If the parent is not specified, we create it in the root.
  409. * We need the root dentry to do this, which is in the super
  410. * block. A pointer to that is in the struct vfsmount that we
  411. * have around.
  412. */
  413. if (!parent ) {
  414. if (usbfs_mount && usbfs_mount->mnt_sb) {
  415. parent = usbfs_mount->mnt_sb->s_root;
  416. }
  417. }
  418. if (!parent) {
  419. dbg("Ah! can not find a parent!");
  420. return -EFAULT;
  421. }
  422. *dentry = NULL;
  423. down(&parent->d_inode->i_sem);
  424. *dentry = lookup_one_len(name, parent, strlen(name));
  425. if (!IS_ERR(dentry)) {
  426. if ((mode & S_IFMT) == S_IFDIR)
  427. error = usbfs_mkdir (parent->d_inode, *dentry, mode);
  428. else
  429. error = usbfs_create (parent->d_inode, *dentry, mode);
  430. } else
  431. error = PTR_ERR(dentry);
  432. up(&parent->d_inode->i_sem);
  433. return error;
  434. }
  435. static struct dentry *fs_create_file (const char *name, mode_t mode,
  436. struct dentry *parent, void *data,
  437. struct file_operations *fops,
  438. uid_t uid, gid_t gid)
  439. {
  440. struct dentry *dentry;
  441. int error;
  442. dbg("creating file '%s'",name);
  443. error = fs_create_by_name (name, mode, parent, &dentry);
  444. if (error) {
  445. dentry = NULL;
  446. } else {
  447. if (dentry->d_inode) {
  448. if (data)
  449. dentry->d_inode->u.generic_ip = data;
  450. if (fops)
  451. dentry->d_inode->i_fop = fops;
  452. dentry->d_inode->i_uid = uid;
  453. dentry->d_inode->i_gid = gid;
  454. }
  455. }
  456. return dentry;
  457. }
  458. static void fs_remove_file (struct dentry *dentry)
  459. {
  460. struct dentry *parent = dentry->d_parent;
  461. if (!parent || !parent->d_inode)
  462. return;
  463. down(&parent->d_inode->i_sem);
  464. if (usbfs_positive(dentry)) {
  465. if (dentry->d_inode) {
  466. if (S_ISDIR(dentry->d_inode->i_mode))
  467. usbfs_rmdir(parent->d_inode, dentry);
  468. else
  469. usbfs_unlink(parent->d_inode, dentry);
  470. dput(dentry);
  471. }
  472. }
  473. up(&parent->d_inode->i_sem);
  474. }
  475. /* --------------------------------------------------------------------- */
  476. static struct super_block *usb_get_sb(struct file_system_type *fs_type,
  477. int flags, const char *dev_name, void *data)
  478. {
  479. return get_sb_single(fs_type, flags, data, usbfs_fill_super);
  480. }
  481. static struct file_system_type usb_fs_type = {
  482. .owner = THIS_MODULE,
  483. .name = "usbfs",
  484. .get_sb = usb_get_sb,
  485. .kill_sb = kill_litter_super,
  486. };
  487. /* --------------------------------------------------------------------- */
  488. static int create_special_files (void)
  489. {
  490. struct dentry *parent;
  491. int retval;
  492. /* the simple_pin_fs calls will call remount with no options
  493. * without this flag that would overwrite the real mount options (if any)
  494. */
  495. ignore_mount = 1;
  496. /* create the devices special file */
  497. retval = simple_pin_fs("usbfs", &usbfs_mount, &usbfs_mount_count);
  498. if (retval) {
  499. err ("Unable to get usbfs mount");
  500. goto exit;
  501. }
  502. ignore_mount = 0;
  503. parent = usbfs_mount->mnt_sb->s_root;
  504. devices_usbfs_dentry = fs_create_file ("devices",
  505. listmode | S_IFREG, parent,
  506. NULL, &usbfs_devices_fops,
  507. listuid, listgid);
  508. if (devices_usbfs_dentry == NULL) {
  509. err ("Unable to create devices usbfs file");
  510. retval = -ENODEV;
  511. goto error_clean_mounts;
  512. }
  513. goto exit;
  514. error_clean_mounts:
  515. simple_release_fs(&usbfs_mount, &usbfs_mount_count);
  516. exit:
  517. return retval;
  518. }
  519. static void remove_special_files (void)
  520. {
  521. if (devices_usbfs_dentry)
  522. fs_remove_file (devices_usbfs_dentry);
  523. devices_usbfs_dentry = NULL;
  524. simple_release_fs(&usbfs_mount, &usbfs_mount_count);
  525. }
  526. void usbfs_update_special (void)
  527. {
  528. struct inode *inode;
  529. if (devices_usbfs_dentry) {
  530. inode = devices_usbfs_dentry->d_inode;
  531. if (inode)
  532. inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  533. }
  534. }
  535. void usbfs_add_bus(struct usb_bus *bus)
  536. {
  537. struct dentry *parent;
  538. char name[8];
  539. int retval;
  540. /* create the special files if this is the first bus added */
  541. if (num_buses == 0) {
  542. retval = create_special_files();
  543. if (retval)
  544. return;
  545. }
  546. ++num_buses;
  547. sprintf (name, "%03d", bus->busnum);
  548. parent = usbfs_mount->mnt_sb->s_root;
  549. bus->usbfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent,
  550. bus, NULL, busuid, busgid);
  551. if (bus->usbfs_dentry == NULL) {
  552. err ("error creating usbfs bus entry");
  553. return;
  554. }
  555. usbfs_update_special();
  556. usbfs_conn_disc_event();
  557. }
  558. void usbfs_remove_bus(struct usb_bus *bus)
  559. {
  560. if (bus->usbfs_dentry) {
  561. fs_remove_file (bus->usbfs_dentry);
  562. bus->usbfs_dentry = NULL;
  563. }
  564. --num_buses;
  565. if (num_buses <= 0) {
  566. remove_special_files();
  567. num_buses = 0;
  568. }
  569. usbfs_update_special();
  570. usbfs_conn_disc_event();
  571. }
  572. void usbfs_add_device(struct usb_device *dev)
  573. {
  574. char name[8];
  575. int i;
  576. int i_size;
  577. sprintf (name, "%03d", dev->devnum);
  578. dev->usbfs_dentry = fs_create_file (name, devmode | S_IFREG,
  579. dev->bus->usbfs_dentry, dev,
  580. &usbfs_device_file_operations,
  581. devuid, devgid);
  582. if (dev->usbfs_dentry == NULL) {
  583. err ("error creating usbfs device entry");
  584. return;
  585. }
  586. /* Set the size of the device's file to be
  587. * equal to the size of the device descriptors. */
  588. i_size = sizeof (struct usb_device_descriptor);
  589. for (i = 0; i < dev->descriptor.bNumConfigurations; ++i) {
  590. struct usb_config_descriptor *config =
  591. (struct usb_config_descriptor *)dev->rawdescriptors[i];
  592. i_size += le16_to_cpu(config->wTotalLength);
  593. }
  594. if (dev->usbfs_dentry->d_inode)
  595. dev->usbfs_dentry->d_inode->i_size = i_size;
  596. usbfs_update_special();
  597. usbfs_conn_disc_event();
  598. }
  599. void usbfs_remove_device(struct usb_device *dev)
  600. {
  601. struct dev_state *ds;
  602. struct siginfo sinfo;
  603. if (dev->usbfs_dentry) {
  604. fs_remove_file (dev->usbfs_dentry);
  605. dev->usbfs_dentry = NULL;
  606. }
  607. while (!list_empty(&dev->filelist)) {
  608. ds = list_entry(dev->filelist.next, struct dev_state, list);
  609. wake_up_all(&ds->wait);
  610. list_del_init(&ds->list);
  611. if (ds->discsignr) {
  612. sinfo.si_signo = SIGPIPE;
  613. sinfo.si_errno = EPIPE;
  614. sinfo.si_code = SI_ASYNCIO;
  615. sinfo.si_addr = ds->disccontext;
  616. send_sig_info(ds->discsignr, &sinfo, ds->disctask);
  617. }
  618. }
  619. usbfs_update_special();
  620. usbfs_conn_disc_event();
  621. }
  622. /* --------------------------------------------------------------------- */
  623. static struct proc_dir_entry *usbdir = NULL;
  624. int __init usbfs_init(void)
  625. {
  626. int retval;
  627. retval = register_filesystem(&usb_fs_type);
  628. if (retval)
  629. return retval;
  630. /* create mount point for usbfs */
  631. usbdir = proc_mkdir("usb", proc_bus);
  632. return 0;
  633. }
  634. void usbfs_cleanup(void)
  635. {
  636. unregister_filesystem(&usb_fs_type);
  637. if (usbdir)
  638. remove_proc_entry("usb", proc_bus);
  639. }