dtype.c 1.5 KB

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