disk.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. /*
  10. * usb/disk - usb mass storage file server
  11. */
  12. #include <u.h>
  13. #include <libc.h>
  14. #include <fcall.h>
  15. #include <thread.h>
  16. #include <disk.h>
  17. #include <usb/scsireq.h>
  18. #include <usb/usb.h>
  19. #include <usb/usbfs.h>
  20. #include <usb/ums.h>
  21. enum
  22. {
  23. Arglen = 80,
  24. };
  25. static void
  26. usage(void)
  27. {
  28. fprint(2, "usage: %s [-Dd] [-N nb] [-m mnt] [-s srv] [dev...]\n", argv0);
  29. threadexitsall("usage");
  30. }
  31. static int csps[] = {
  32. CSP(Clstorage,Subatapi,Protobulk),
  33. CSP(Clstorage,Sub8070,Protobulk),
  34. CSP(Clstorage,Subscsi,Protobulk),
  35. 0,
  36. };
  37. void
  38. threadmain(int argc, char **argv)
  39. {
  40. char args[Arglen];
  41. char *as, *ae, *srv, *mnt;
  42. srv = nil;
  43. mnt = "/n/disk";
  44. quotefmtinstall();
  45. ae = args+sizeof(args);
  46. as = seprint(args, ae, "disk");
  47. ARGBEGIN{
  48. case 'D':
  49. usbfsdebug++;
  50. break;
  51. case 'd':
  52. usbdebug++;
  53. as = seprint(as, ae, " -d");
  54. break;
  55. case 'N':
  56. as = seprint(as, ae, " -N %s", EARGF(usage()));
  57. break;
  58. case 'm':
  59. mnt = EARGF(usage());
  60. break;
  61. case 's':
  62. srv = EARGF(usage());
  63. break;
  64. default:
  65. usage();
  66. }ARGEND
  67. rfork(RFNOTEG);
  68. threadsetgrp(threadid());
  69. fmtinstall('U', Ufmt);
  70. usbfsinit(srv, mnt, &usbdirfs, MBEFORE);
  71. startdevs(args, argv, argc, matchdevcsp, csps, diskmain);
  72. threadexits(nil);
  73. }