inode.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  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. static struct dentry * get_dentry(struct dentry *parent, const char *name)
  396. {
  397. struct qstr qstr;
  398. qstr.name = name;
  399. qstr.len = strlen(name);
  400. qstr.hash = full_name_hash(name,qstr.len);
  401. return lookup_hash(&qstr,parent);
  402. }
  403. /*
  404. * fs_create_by_name - create a file, given a name
  405. * @name: name of file
  406. * @mode: type of file
  407. * @parent: dentry of directory to create it in
  408. * @dentry: resulting dentry of file
  409. *
  410. * This function handles both regular files and directories.
  411. */
  412. static int fs_create_by_name (const char *name, mode_t mode,
  413. struct dentry *parent, struct dentry **dentry)
  414. {
  415. int error = 0;
  416. /* If the parent is not specified, we create it in the root.
  417. * We need the root dentry to do this, which is in the super
  418. * block. A pointer to that is in the struct vfsmount that we
  419. * have around.
  420. */
  421. if (!parent ) {
  422. if (usbfs_mount && usbfs_mount->mnt_sb) {
  423. parent = usbfs_mount->mnt_sb->s_root;
  424. }
  425. }
  426. if (!parent) {
  427. dbg("Ah! can not find a parent!");
  428. return -EFAULT;
  429. }
  430. *dentry = NULL;
  431. down(&parent->d_inode->i_sem);
  432. *dentry = get_dentry (parent, name);
  433. if (!IS_ERR(dentry)) {
  434. if ((mode & S_IFMT) == S_IFDIR)
  435. error = usbfs_mkdir (parent->d_inode, *dentry, mode);
  436. else
  437. error = usbfs_create (parent->d_inode, *dentry, mode);
  438. } else
  439. error = PTR_ERR(dentry);
  440. up(&parent->d_inode->i_sem);
  441. return error;
  442. }
  443. static struct dentry *fs_create_file (const char *name, mode_t mode,
  444. struct dentry *parent, void *data,
  445. struct file_operations *fops,
  446. uid_t uid, gid_t gid)
  447. {
  448. struct dentry *dentry;
  449. int error;
  450. dbg("creating file '%s'",name);
  451. error = fs_create_by_name (name, mode, parent, &dentry);
  452. if (error) {
  453. dentry = NULL;
  454. } else {
  455. if (dentry->d_inode) {
  456. if (data)
  457. dentry->d_inode->u.generic_ip = data;
  458. if (fops)
  459. dentry->d_inode->i_fop = fops;
  460. dentry->d_inode->i_uid = uid;
  461. dentry->d_inode->i_gid = gid;
  462. }
  463. }
  464. return dentry;
  465. }
  466. static void fs_remove_file (struct dentry *dentry)
  467. {
  468. struct dentry *parent = dentry->d_parent;
  469. if (!parent || !parent->d_inode)
  470. return;
  471. down(&parent->d_inode->i_sem);
  472. if (usbfs_positive(dentry)) {
  473. if (dentry->d_inode) {
  474. if (S_ISDIR(dentry->d_inode->i_mode))
  475. usbfs_rmdir(parent->d_inode, dentry);
  476. else
  477. usbfs_unlink(parent->d_inode, dentry);
  478. dput(dentry);
  479. }
  480. }
  481. up(&parent->d_inode->i_sem);
  482. }
  483. /* --------------------------------------------------------------------- */
  484. static struct super_block *usb_get_sb(struct file_system_type *fs_type,
  485. int flags, const char *dev_name, void *data)
  486. {
  487. return get_sb_single(fs_type, flags, data, usbfs_fill_super);
  488. }
  489. static struct file_system_type usb_fs_type = {
  490. .owner = THIS_MODULE,
  491. .name = "usbfs",
  492. .get_sb = usb_get_sb,
  493. .kill_sb = kill_litter_super,
  494. };
  495. /* --------------------------------------------------------------------- */
  496. static int create_special_files (void)
  497. {
  498. struct dentry *parent;
  499. int retval;
  500. /* the simple_pin_fs calls will call remount with no options
  501. * without this flag that would overwrite the real mount options (if any)
  502. */
  503. ignore_mount = 1;
  504. /* create the devices special file */
  505. retval = simple_pin_fs("usbfs", &usbfs_mount, &usbfs_mount_count);
  506. if (retval) {
  507. err ("Unable to get usbfs mount");
  508. goto exit;
  509. }
  510. ignore_mount = 0;
  511. parent = usbfs_mount->mnt_sb->s_root;
  512. devices_usbfs_dentry = fs_create_file ("devices",
  513. listmode | S_IFREG, parent,
  514. NULL, &usbfs_devices_fops,
  515. listuid, listgid);
  516. if (devices_usbfs_dentry == NULL) {
  517. err ("Unable to create devices usbfs file");
  518. retval = -ENODEV;
  519. goto error_clean_mounts;
  520. }
  521. goto exit;
  522. error_clean_mounts:
  523. simple_release_fs(&usbfs_mount, &usbfs_mount_count);
  524. exit:
  525. return retval;
  526. }
  527. static void remove_special_files (void)
  528. {
  529. if (devices_usbfs_dentry)
  530. fs_remove_file (devices_usbfs_dentry);
  531. devices_usbfs_dentry = NULL;
  532. simple_release_fs(&usbfs_mount, &usbfs_mount_count);
  533. }
  534. void usbfs_update_special (void)
  535. {
  536. struct inode *inode;
  537. if (devices_usbfs_dentry) {
  538. inode = devices_usbfs_dentry->d_inode;
  539. if (inode)
  540. inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  541. }
  542. }
  543. void usbfs_add_bus(struct usb_bus *bus)
  544. {
  545. struct dentry *parent;
  546. char name[8];
  547. int retval;
  548. /* create the special files if this is the first bus added */
  549. if (num_buses == 0) {
  550. retval = create_special_files();
  551. if (retval)
  552. return;
  553. }
  554. ++num_buses;
  555. sprintf (name, "%03d", bus->busnum);
  556. parent = usbfs_mount->mnt_sb->s_root;
  557. bus->usbfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent,
  558. bus, NULL, busuid, busgid);
  559. if (bus->usbfs_dentry == NULL) {
  560. err ("error creating usbfs bus entry");
  561. return;
  562. }
  563. usbfs_update_special();
  564. usbfs_conn_disc_event();
  565. }
  566. void usbfs_remove_bus(struct usb_bus *bus)
  567. {
  568. if (bus->usbfs_dentry) {
  569. fs_remove_file (bus->usbfs_dentry);
  570. bus->usbfs_dentry = NULL;
  571. }
  572. --num_buses;
  573. if (num_buses <= 0) {
  574. remove_special_files();
  575. num_buses = 0;
  576. }
  577. usbfs_update_special();
  578. usbfs_conn_disc_event();
  579. }
  580. void usbfs_add_device(struct usb_device *dev)
  581. {
  582. char name[8];
  583. int i;
  584. int i_size;
  585. sprintf (name, "%03d", dev->devnum);
  586. dev->usbfs_dentry = fs_create_file (name, devmode | S_IFREG,
  587. dev->bus->usbfs_dentry, dev,
  588. &usbfs_device_file_operations,
  589. devuid, devgid);
  590. if (dev->usbfs_dentry == NULL) {
  591. err ("error creating usbfs device entry");
  592. return;
  593. }
  594. /* Set the size of the device's file to be
  595. * equal to the size of the device descriptors. */
  596. i_size = sizeof (struct usb_device_descriptor);
  597. for (i = 0; i < dev->descriptor.bNumConfigurations; ++i) {
  598. struct usb_config_descriptor *config =
  599. (struct usb_config_descriptor *)dev->rawdescriptors[i];
  600. i_size += le16_to_cpu(config->wTotalLength);
  601. }
  602. if (dev->usbfs_dentry->d_inode)
  603. dev->usbfs_dentry->d_inode->i_size = i_size;
  604. usbfs_update_special();
  605. usbfs_conn_disc_event();
  606. }
  607. void usbfs_remove_device(struct usb_device *dev)
  608. {
  609. struct dev_state *ds;
  610. struct siginfo sinfo;
  611. if (dev->usbfs_dentry) {
  612. fs_remove_file (dev->usbfs_dentry);
  613. dev->usbfs_dentry = NULL;
  614. }
  615. while (!list_empty(&dev->filelist)) {
  616. ds = list_entry(dev->filelist.next, struct dev_state, list);
  617. wake_up_all(&ds->wait);
  618. list_del_init(&ds->list);
  619. if (ds->discsignr) {
  620. sinfo.si_signo = SIGPIPE;
  621. sinfo.si_errno = EPIPE;
  622. sinfo.si_code = SI_ASYNCIO;
  623. sinfo.si_addr = ds->disccontext;
  624. send_sig_info(ds->discsignr, &sinfo, ds->disctask);
  625. }
  626. }
  627. usbfs_update_special();
  628. usbfs_conn_disc_event();
  629. }
  630. /* --------------------------------------------------------------------- */
  631. static struct proc_dir_entry *usbdir = NULL;
  632. int __init usbfs_init(void)
  633. {
  634. int retval;
  635. retval = usb_register(&usbfs_driver);
  636. if (retval)
  637. return retval;
  638. retval = register_filesystem(&usb_fs_type);
  639. if (retval) {
  640. usb_deregister(&usbfs_driver);
  641. return retval;
  642. }
  643. /* create mount point for usbfs */
  644. usbdir = proc_mkdir("usb", proc_bus);
  645. return 0;
  646. }
  647. void usbfs_cleanup(void)
  648. {
  649. usb_deregister(&usbfs_driver);
  650. unregister_filesystem(&usb_fs_type);
  651. if (usbdir)
  652. remove_proc_entry("usb", proc_bus);
  653. }