usbfs.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. typedef struct Usbfs Usbfs;
  10. typedef struct Fid Fid;
  11. enum
  12. {
  13. Hdrsize = 128, /* plenty of room for headers */
  14. Msgsize = 8216, /* our preferred iounit (also devmnt's) */
  15. Bufsize = Hdrsize + Msgsize,
  16. Namesz = 40,
  17. Errmax = 128,
  18. ONONE = ~0, /* omode in Fid when not open */
  19. };
  20. struct Fid
  21. {
  22. int fid;
  23. Qid qid;
  24. int omode;
  25. Fid* next;
  26. void* aux;
  27. };
  28. struct Usbfs
  29. {
  30. char name[Namesz];
  31. uint64_t qid;
  32. Dev* dev;
  33. void* aux;
  34. int (*walk)(Usbfs *fs, Fid *f, char *name);
  35. void (*clone)(Usbfs *fs, Fid *of, Fid *nf);
  36. void (*clunk)(Usbfs *fs, Fid *f);
  37. int (*open)(Usbfs *fs, Fid *f, int mode);
  38. int32_t (*read)(Usbfs *fs, Fid *f, void *data, int32_t count, int64_t offset);
  39. int32_t (*write)(Usbfs *fs, Fid*f, void *data, int32_t count, int64_t offset);
  40. int (*stat)(Usbfs *fs, Qid q, Dir *d);
  41. void (*end)(Usbfs *fs);
  42. };
  43. typedef int (*Dirgen)(Usbfs*, Qid, int, Dir*, void*);
  44. int32_t usbreadbuf(void *data, int32_t count, int64_t offset, void *buf, int32_t n);
  45. void usbfsadd(Usbfs *dfs);
  46. void usbfsdel(Usbfs *dfs);
  47. int usbdirread(Usbfs*f, Qid q, char *data, int32_t cnt, int64_t off, Dirgen gen, void *arg);
  48. void usbfsinit(char* srv, char *mnt, Usbfs *f, int flag);
  49. void usbfsdirdump(void);
  50. extern char Enotfound[];
  51. extern char Etoosmall[];
  52. extern char Eio[];
  53. extern char Eperm[];
  54. extern char Ebadcall[];
  55. extern char Ebadfid[];
  56. extern char Einuse[];
  57. extern char Eisopen[];
  58. extern char Ebadctl[];
  59. extern Usbfs usbdirfs;
  60. extern int usbfsdebug;