xref: /trueos/sys/gnu/fs/reiserfs/reiserfs_item_ops.c (revision 94d2b7f64912987093f1a98573737a32e4e5d8d1)
1 /*-
2  * Copyright 2000 Hans Reiser
3  * See README for licensing and copyright details
4  *
5  * Ported to FreeBSD by Jean-Sébastien Pédron <jspedron@club-internet.fr>
6  *
7  * $FreeBSD$
8  */
9 
10 #include <gnu/fs/reiserfs/reiserfs_fs.h>
11 
12 /* -------------------------------------------------------------------
13  * Stat data functions
14  * -------------------------------------------------------------------*/
15 
16 static int
sd_bytes_number(struct item_head * ih,int block_size)17 sd_bytes_number(struct item_head *ih, int block_size)
18 {
19 
20 	return (0);
21 }
22 
23 struct item_operations stat_data_ops = {
24 	.bytes_number      = sd_bytes_number,
25 	//.decrement_key     = sd_decrement_key,
26 	//.is_left_mergeable = sd_is_left_mergeable,
27 	//.print_item        = sd_print_item,
28 	//.check_item        = sd_check_item,
29 
30 	//.create_vi         = sd_create_vi,
31 	//.check_left        = sd_check_left,
32 	//.check_right       = sd_check_right,
33 	//.part_size         = sd_part_size,
34 	//.unit_num          = sd_unit_num,
35 	//.print_vi          = sd_print_vi
36 };
37 
38 /* -------------------------------------------------------------------
39  * Direct item functions
40  * -------------------------------------------------------------------*/
41 
42 static int
direct_bytes_number(struct item_head * ih,int block_size)43 direct_bytes_number(struct item_head *ih, int block_size)
44 {
45 
46 	return (ih_item_len(ih));
47 }
48 
49 struct item_operations direct_ops = {
50 	.bytes_number      = direct_bytes_number,
51 	//.decrement_key     = direct_decrement_key,
52 	//.is_left_mergeable = direct_is_left_mergeable,
53 	//.print_item        = direct_print_item,
54 	//.check_item        = direct_check_item,
55 
56 	//.create_vi         = direct_create_vi,
57 	//.check_left        = direct_check_left,
58 	//.check_right       = direct_check_right,
59 	//.part_size         = direct_part_size,
60 	//.unit_num          = direct_unit_num,
61 	//.print_vi          = direct_print_vi
62 };
63 
64 /* -------------------------------------------------------------------
65  * Indirect item functions
66  * -------------------------------------------------------------------*/
67 
68 static int
indirect_bytes_number(struct item_head * ih,int block_size)69 indirect_bytes_number(struct item_head *ih, int block_size)
70 {
71 
72 	return (ih_item_len(ih) / UNFM_P_SIZE * block_size);
73 }
74 
75 struct item_operations indirect_ops = {
76 	.bytes_number      = indirect_bytes_number,
77 	//.decrement_key     = indirect_decrement_key,
78 	//.is_left_mergeable = indirect_is_left_mergeable,
79 	//.print_item        = indirect_print_item,
80 	//.check_item        = indirect_check_item,
81 
82 	//.create_vi         = indirect_create_vi,
83 	//.check_left        = indirect_check_left,
84 	//.check_right       = indirect_check_right,
85 	//.part_size         = indirect_part_size,
86 	//.unit_num          = indirect_unit_num,
87 	//.print_vi          = indirect_print_vi
88 };
89 
90 /* -------------------------------------------------------------------
91  * Direntry functions
92  * -------------------------------------------------------------------*/
93 
94 static int
direntry_bytes_number(struct item_head * ih,int block_size)95 direntry_bytes_number(struct item_head *ih, int block_size)
96 {
97 
98 	reiserfs_log(LOG_WARNING, "bytes number is asked for direntry\n");
99 	return (0);
100 }
101 
102 struct item_operations direntry_ops = {
103 	.bytes_number      = direntry_bytes_number,
104 	//.decrement_key     = direntry_decrement_key,
105 	//.is_left_mergeable = direntry_is_left_mergeable,
106 	//.print_item        = direntry_print_item,
107 	//.check_item        = direntry_check_item,
108 
109 	//.create_vi         = direntry_create_vi,
110 	//.check_left        = direntry_check_left,
111 	//.check_right       = direntry_check_right,
112 	//.part_size         = direntry_part_size,
113 	//.unit_num          = direntry_unit_num,
114 	//.print_vi          = direntry_print_vi
115 };
116 
117 /* -------------------------------------------------------------------
118  * Error catching functions to catch errors caused by incorrect item
119  * types.
120  * -------------------------------------------------------------------*/
121 
122 static int
errcatch_bytes_number(struct item_head * ih,int block_size)123 errcatch_bytes_number(struct item_head *ih, int block_size)
124 {
125 
126 	reiserfs_log(LOG_WARNING, "invalid item type observed, run fsck ASAP");
127 	return (0);
128 }
129 
130 struct item_operations errcatch_ops = {
131 	errcatch_bytes_number,
132 	//errcatch_decrement_key,
133 	//errcatch_is_left_mergeable,
134 	//errcatch_print_item,
135 	//errcatch_check_item,
136 
137 	//errcatch_create_vi,
138 	//errcatch_check_left,
139 	//errcatch_check_right,
140 	//errcatch_part_size,
141 	//errcatch_unit_num,
142 	//errcatch_print_vi
143 };
144 
145 #if !(TYPE_STAT_DATA == 0 && TYPE_INDIRECT == 1 &&			\
146     TYPE_DIRECT == 2 && TYPE_DIRENTRY == 3)
147 #error
148 #endif
149 
150 struct item_operations *item_ops[TYPE_ANY + 1] = {
151 	&stat_data_ops,
152 	&indirect_ops,
153 	&direct_ops,
154 	&direntry_ops,
155 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
156 	&errcatch_ops /* This is to catch errors with invalid type (15th
157 			 entry for TYPE_ANY) */
158 };
159