inode.h 1.1 KB

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