summaryrefslogtreecommitdiffstats
path: root/sys/gnu/fs/reiserfs/reiserfs_item_ops.c
blob: f3593c3b1bd3c849642bd272d8c78e0eeccf031a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*-
 * Copyright 2000 Hans Reiser
 * See README for licensing and copyright details
 * 
 * Ported to FreeBSD by Jean-Sébastien Pédron <jspedron@club-internet.fr>
 * 
 * $FreeBSD$
 */

#include <gnu/fs/reiserfs/reiserfs_fs.h>

/* -------------------------------------------------------------------
 * Stat data functions
 * -------------------------------------------------------------------*/

static int
sd_bytes_number(struct item_head *ih, int block_size)
{ 

	return (0);
}

struct item_operations stat_data_ops = {
	.bytes_number      = sd_bytes_number,
	//.decrement_key     = sd_decrement_key,
	//.is_left_mergeable = sd_is_left_mergeable,
	//.print_item        = sd_print_item,
	//.check_item        = sd_check_item,

	//.create_vi         = sd_create_vi,
	//.check_left        = sd_check_left,
	//.check_right       = sd_check_right,
	//.part_size         = sd_part_size,
	//.unit_num          = sd_unit_num,
	//.print_vi          = sd_print_vi
};

/* -------------------------------------------------------------------
 * Direct item functions
 * -------------------------------------------------------------------*/

static int
direct_bytes_number(struct item_head *ih, int block_size)
{

	return (ih_item_len(ih));
}

struct item_operations direct_ops = {
	.bytes_number      = direct_bytes_number,
	//.decrement_key     = direct_decrement_key,
	//.is_left_mergeable = direct_is_left_mergeable,
	//.print_item        = direct_print_item,
	//.check_item        = direct_check_item,

	//.create_vi         = direct_create_vi,
	//.check_left        = direct_check_left,
	//.check_right       = direct_check_right,
	//.part_size         = direct_part_size,
	//.unit_num          = direct_unit_num,
	//.print_vi          = direct_print_vi
};

/* -------------------------------------------------------------------
 * Indirect item functions
 * -------------------------------------------------------------------*/

static int
indirect_bytes_number(struct item_head *ih, int block_size)
{

	return (ih_item_len(ih) / UNFM_P_SIZE * block_size);
}

struct item_operations indirect_ops = {
	.bytes_number      = indirect_bytes_number,
	//.decrement_key     = indirect_decrement_key,
	//.is_left_mergeable = indirect_is_left_mergeable,
	//.print_item        = indirect_print_item,
	//.check_item        = indirect_check_item,

	//.create_vi         = indirect_create_vi,
	//.check_left        = indirect_check_left,
	//.check_right       = indirect_check_right,
	//.part_size         = indirect_part_size,
	//.unit_num          = indirect_unit_num,
	//.print_vi          = indirect_print_vi
};

/* -------------------------------------------------------------------
 * Direntry functions
 * -------------------------------------------------------------------*/

static int
direntry_bytes_number(struct item_head *ih, int block_size)
{

	reiserfs_log(LOG_WARNING, "bytes number is asked for direntry\n");
	return (0);
}

struct item_operations direntry_ops = {
	.bytes_number      = direntry_bytes_number,
	//.decrement_key     = direntry_decrement_key,
	//.is_left_mergeable = direntry_is_left_mergeable,
	//.print_item        = direntry_print_item,
	//.check_item        = direntry_check_item,

	//.create_vi         = direntry_create_vi,
	//.check_left        = direntry_check_left,
	//.check_right       = direntry_check_right,
	//.part_size         = direntry_part_size,
	//.unit_num          = direntry_unit_num,
	//.print_vi          = direntry_print_vi
};

/* -------------------------------------------------------------------
 * Error catching functions to catch errors caused by incorrect item
 * types.
 * -------------------------------------------------------------------*/

static int
errcatch_bytes_number(struct item_head *ih, int block_size)
{

	reiserfs_log(LOG_WARNING, "invalid item type observed, run fsck ASAP");
	return (0);
}

struct item_operations errcatch_ops = {
	errcatch_bytes_number,
	//errcatch_decrement_key,
	//errcatch_is_left_mergeable,
	//errcatch_print_item,
	//errcatch_check_item,

	//errcatch_create_vi,
	//errcatch_check_left,
	//errcatch_check_right,
	//errcatch_part_size,
	//errcatch_unit_num,
	//errcatch_print_vi
};

#if !(TYPE_STAT_DATA == 0 && TYPE_INDIRECT == 1 &&			\
    TYPE_DIRECT == 2 && TYPE_DIRENTRY == 3)
#error
#endif

struct item_operations *item_ops[TYPE_ANY + 1] = {
	&stat_data_ops,
	&indirect_ops,
	&direct_ops,
	&direntry_ops,
	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
	&errcatch_ops /* This is to catch errors with invalid type (15th
			 entry for TYPE_ANY) */
};
OpenPOWER on IntegriCloud