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