dtype.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <venti.h>
  4. enum {
  5. OVtErrType, /* illegal */
  6. OVtRootType,
  7. OVtDirType,
  8. OVtPointerType0,
  9. OVtPointerType1,
  10. OVtPointerType2,
  11. OVtPointerType3,
  12. OVtPointerType4,
  13. OVtPointerType5,
  14. OVtPointerType6,
  15. OVtPointerType7, /* not used */
  16. OVtPointerType8, /* not used */
  17. OVtPointerType9, /* not used */
  18. OVtDataType,
  19. OVtMaxType
  20. };
  21. uint todisk[] = {
  22. OVtDataType,
  23. OVtPointerType0,
  24. OVtPointerType1,
  25. OVtPointerType2,
  26. OVtPointerType3,
  27. OVtPointerType4,
  28. OVtPointerType5,
  29. OVtPointerType6,
  30. OVtDirType,
  31. OVtPointerType0,
  32. OVtPointerType1,
  33. OVtPointerType2,
  34. OVtPointerType3,
  35. OVtPointerType4,
  36. OVtPointerType5,
  37. OVtPointerType6,
  38. OVtRootType,
  39. };
  40. uint fromdisk[] = {
  41. VtCorruptType,
  42. VtRootType,
  43. VtDirType,
  44. VtDirType+1,
  45. VtDirType+2,
  46. VtDirType+3,
  47. VtDirType+4,
  48. VtDirType+5,
  49. VtDirType+6,
  50. VtDirType+7,
  51. VtCorruptType,
  52. VtCorruptType,
  53. VtCorruptType,
  54. VtDataType,
  55. };
  56. uint
  57. vttodisktype(uint n)
  58. {
  59. if(n >= nelem(todisk))
  60. return VtCorruptType;
  61. return todisk[n];
  62. }
  63. uint
  64. vtfromdisktype(uint n)
  65. {
  66. if(n >= nelem(fromdisk))
  67. return VtCorruptType;
  68. return fromdisk[n];
  69. }