iotrack.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 MLock MLock;
  10. typedef struct Iosect Iosect;
  11. typedef struct Iotrack Iotrack;
  12. typedef struct Track Track;
  13. typedef struct Xfs Xfs;
  14. struct MLock
  15. {
  16. char key;
  17. };
  18. struct Iosect
  19. {
  20. Iosect *next;
  21. short flags;
  22. MLock lock;
  23. Iotrack *t;
  24. unsigned char * iobuf;
  25. };
  26. struct Iotrack
  27. {
  28. short flags;
  29. Xfs * xf;
  30. int32_t addr;
  31. Iotrack *next; /* in lru list */
  32. Iotrack *prev;
  33. Iotrack *hnext; /* in hash list */
  34. Iotrack *hprev;
  35. MLock lock;
  36. int ref;
  37. Track *tp;
  38. };
  39. enum{
  40. Sectorsize = 512,
  41. Sect2trk = 9,
  42. Trksize = Sectorsize*Sect2trk
  43. };
  44. struct Track
  45. {
  46. Iosect *p[Sect2trk];
  47. unsigned char buf[Sect2trk][Sectorsize];
  48. };
  49. #define BMOD (1<<0)
  50. #define BIMM (1<<1)
  51. #define BSTALE (1<<2)
  52. Iosect* getiosect(Xfs*, int32_t, int);
  53. Iosect* getosect(Xfs*, int32_t);
  54. Iosect* getsect(Xfs*, int32_t);
  55. Iosect* newsect(void);
  56. Iotrack* getiotrack(Xfs*, int32_t);
  57. int canmlock(MLock*);
  58. int devcheck(Xfs*);
  59. int devread(Xfs*, int32_t, void*, int32_t);
  60. int devwrite(Xfs*, int32_t, void*, int32_t);
  61. int tread(Iotrack*);
  62. int twrite(Iotrack*);
  63. void freesect(Iosect*);
  64. void iotrack_init(void);
  65. void mlock(MLock*);
  66. void purgebuf(Xfs*);
  67. void purgetrack(Iotrack*);
  68. void putsect(Iosect*);
  69. void sync(void);
  70. void unmlock(MLock*);