inode.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 Ibuf Ibuf;
  10. typedef struct Imap Imap;
  11. typedef struct Icache Icache;
  12. enum
  13. {
  14. Nicache= 64, /* number of inodes kept in pool */
  15. };
  16. /*
  17. * a cached inode buffer
  18. */
  19. struct Ibuf
  20. {
  21. Lru; /* must be first in structure */
  22. int inuse; /* non-0 if in use */
  23. ulong ino; /* index into inode table */
  24. Inode inode; /* the inode contents */
  25. };
  26. /*
  27. * in-core qid to inode mapping
  28. */
  29. struct Imap
  30. {
  31. Lru; /* must be first in structure */
  32. Qid qid;
  33. Ibuf *b; /* cache buffer */
  34. int inuse; /* non-0 if in use */
  35. };
  36. /*
  37. * the inode cache
  38. */
  39. struct Icache
  40. {
  41. Disk;
  42. int nino; /* number of inodes */
  43. ulong ib0; /* first inode block */
  44. int nib; /* number of inode blocks */
  45. int i2b; /* inodes to a block */
  46. Ibuf ib[Nicache]; /* inode buffers */
  47. Lru blru;
  48. Imap *map; /* inode to qid mapping */
  49. Lru mlru;
  50. };
  51. Ibuf* ialloc(Icache*, uint32_t);
  52. Ibuf* iget(Icache*, Qid);
  53. Ibuf* iread(Icache*, uint32_t);
  54. int iformat(Icache*, int, uint32_t, char*, int, int);
  55. int iinit(Icache*, int, int, char*);
  56. int iremove(Icache*, uint32_t);
  57. int iupdate(Icache*, uint32_t, Qid);
  58. int iwrite(Icache*, Ibuf*);
  59. void ifree(Icache*, Ibuf*);
  60. void iinc(Icache*, Ibuf*);