]> git.karo-electronics.de Git - mv-sheeva.git/blob - fs/reiserfs/item_ops.c
reiserfs: rework reiserfs_warning
[mv-sheeva.git] / fs / reiserfs / item_ops.c
1 /*
2  * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
3  */
4
5 #include <linux/time.h>
6 #include <linux/reiserfs_fs.h>
7
8 // this contains item handlers for old item types: sd, direct,
9 // indirect, directory
10
11 /* and where are the comments? how about saying where we can find an
12    explanation of each item handler method? -Hans */
13
14 //////////////////////////////////////////////////////////////////////////////
15 // stat data functions
16 //
17 static int sd_bytes_number(struct item_head *ih, int block_size)
18 {
19         return 0;
20 }
21
22 static void sd_decrement_key(struct cpu_key *key)
23 {
24         key->on_disk_key.k_objectid--;
25         set_cpu_key_k_type(key, TYPE_ANY);
26         set_cpu_key_k_offset(key, (loff_t)(~0ULL >> 1));
27 }
28
29 static int sd_is_left_mergeable(struct reiserfs_key *key, unsigned long bsize)
30 {
31         return 0;
32 }
33
34 static char *print_time(time_t t)
35 {
36         static char timebuf[256];
37
38         sprintf(timebuf, "%ld", t);
39         return timebuf;
40 }
41
42 static void sd_print_item(struct item_head *ih, char *item)
43 {
44         printk("\tmode | size | nlinks | first direct | mtime\n");
45         if (stat_data_v1(ih)) {
46                 struct stat_data_v1 *sd = (struct stat_data_v1 *)item;
47
48                 printk("\t0%-6o | %6u | %2u | %d | %s\n", sd_v1_mode(sd),
49                        sd_v1_size(sd), sd_v1_nlink(sd),
50                        sd_v1_first_direct_byte(sd),
51                        print_time(sd_v1_mtime(sd)));
52         } else {
53                 struct stat_data *sd = (struct stat_data *)item;
54
55                 printk("\t0%-6o | %6Lu | %2u | %d | %s\n", sd_v2_mode(sd),
56                        (unsigned long long)sd_v2_size(sd), sd_v2_nlink(sd),
57                        sd_v2_rdev(sd), print_time(sd_v2_mtime(sd)));
58         }
59 }
60
61 static void sd_check_item(struct item_head *ih, char *item)
62 {
63         // FIXME: type something here!
64 }
65
66 static int sd_create_vi(struct virtual_node *vn,
67                         struct virtual_item *vi,
68                         int is_affected, int insert_size)
69 {
70         vi->vi_index = TYPE_STAT_DATA;
71         //vi->vi_type |= VI_TYPE_STAT_DATA;// not needed?
72         return 0;
73 }
74
75 static int sd_check_left(struct virtual_item *vi, int free,
76                          int start_skip, int end_skip)
77 {
78         BUG_ON(start_skip || end_skip);
79         return -1;
80 }
81
82 static int sd_check_right(struct virtual_item *vi, int free)
83 {
84         return -1;
85 }
86
87 static int sd_part_size(struct virtual_item *vi, int first, int count)
88 {
89         BUG_ON(count);
90         return 0;
91 }
92
93 static int sd_unit_num(struct virtual_item *vi)
94 {
95         return vi->vi_item_len - IH_SIZE;
96 }
97
98 static void sd_print_vi(struct virtual_item *vi)
99 {
100         reiserfs_warning(NULL, "reiserfs-16100",
101                          "STATDATA, index %d, type 0x%x, %h",
102                          vi->vi_index, vi->vi_type, vi->vi_ih);
103 }
104
105 static struct item_operations stat_data_ops = {
106         .bytes_number = sd_bytes_number,
107         .decrement_key = sd_decrement_key,
108         .is_left_mergeable = sd_is_left_mergeable,
109         .print_item = sd_print_item,
110         .check_item = sd_check_item,
111
112         .create_vi = sd_create_vi,
113         .check_left = sd_check_left,
114         .check_right = sd_check_right,
115         .part_size = sd_part_size,
116         .unit_num = sd_unit_num,
117         .print_vi = sd_print_vi
118 };
119
120 //////////////////////////////////////////////////////////////////////////////
121 // direct item functions
122 //
123 static int direct_bytes_number(struct item_head *ih, int block_size)
124 {
125         return ih_item_len(ih);
126 }
127
128 // FIXME: this should probably switch to indirect as well
129 static void direct_decrement_key(struct cpu_key *key)
130 {
131         cpu_key_k_offset_dec(key);
132         if (cpu_key_k_offset(key) == 0)
133                 set_cpu_key_k_type(key, TYPE_STAT_DATA);
134 }
135
136 static int direct_is_left_mergeable(struct reiserfs_key *key,
137                                     unsigned long bsize)
138 {
139         int version = le_key_version(key);
140         return ((le_key_k_offset(version, key) & (bsize - 1)) != 1);
141 }
142
143 static void direct_print_item(struct item_head *ih, char *item)
144 {
145         int j = 0;
146
147 //    return;
148         printk("\"");
149         while (j < ih_item_len(ih))
150                 printk("%c", item[j++]);
151         printk("\"\n");
152 }
153
154 static void direct_check_item(struct item_head *ih, char *item)
155 {
156         // FIXME: type something here!
157 }
158
159 static int direct_create_vi(struct virtual_node *vn,
160                             struct virtual_item *vi,
161                             int is_affected, int insert_size)
162 {
163         vi->vi_index = TYPE_DIRECT;
164         //vi->vi_type |= VI_TYPE_DIRECT;
165         return 0;
166 }
167
168 static int direct_check_left(struct virtual_item *vi, int free,
169                              int start_skip, int end_skip)
170 {
171         int bytes;
172
173         bytes = free - free % 8;
174         return bytes ? : -1;
175 }
176
177 static int direct_check_right(struct virtual_item *vi, int free)
178 {
179         return direct_check_left(vi, free, 0, 0);
180 }
181
182 static int direct_part_size(struct virtual_item *vi, int first, int count)
183 {
184         return count;
185 }
186
187 static int direct_unit_num(struct virtual_item *vi)
188 {
189         return vi->vi_item_len - IH_SIZE;
190 }
191
192 static void direct_print_vi(struct virtual_item *vi)
193 {
194         reiserfs_warning(NULL, "reiserfs-16101",
195                          "DIRECT, index %d, type 0x%x, %h",
196                          vi->vi_index, vi->vi_type, vi->vi_ih);
197 }
198
199 static struct item_operations direct_ops = {
200         .bytes_number = direct_bytes_number,
201         .decrement_key = direct_decrement_key,
202         .is_left_mergeable = direct_is_left_mergeable,
203         .print_item = direct_print_item,
204         .check_item = direct_check_item,
205
206         .create_vi = direct_create_vi,
207         .check_left = direct_check_left,
208         .check_right = direct_check_right,
209         .part_size = direct_part_size,
210         .unit_num = direct_unit_num,
211         .print_vi = direct_print_vi
212 };
213
214 //////////////////////////////////////////////////////////////////////////////
215 // indirect item functions
216 //
217
218 static int indirect_bytes_number(struct item_head *ih, int block_size)
219 {
220         return ih_item_len(ih) / UNFM_P_SIZE * block_size;      //- get_ih_free_space (ih);
221 }
222
223 // decrease offset, if it becomes 0, change type to stat data
224 static void indirect_decrement_key(struct cpu_key *key)
225 {
226         cpu_key_k_offset_dec(key);
227         if (cpu_key_k_offset(key) == 0)
228                 set_cpu_key_k_type(key, TYPE_STAT_DATA);
229 }
230
231 // if it is not first item of the body, then it is mergeable
232 static int indirect_is_left_mergeable(struct reiserfs_key *key,
233                                       unsigned long bsize)
234 {
235         int version = le_key_version(key);
236         return (le_key_k_offset(version, key) != 1);
237 }
238
239 // printing of indirect item
240 static void start_new_sequence(__u32 * start, int *len, __u32 new)
241 {
242         *start = new;
243         *len = 1;
244 }
245
246 static int sequence_finished(__u32 start, int *len, __u32 new)
247 {
248         if (start == INT_MAX)
249                 return 1;
250
251         if (start == 0 && new == 0) {
252                 (*len)++;
253                 return 0;
254         }
255         if (start != 0 && (start + *len) == new) {
256                 (*len)++;
257                 return 0;
258         }
259         return 1;
260 }
261
262 static void print_sequence(__u32 start, int len)
263 {
264         if (start == INT_MAX)
265                 return;
266
267         if (len == 1)
268                 printk(" %d", start);
269         else
270                 printk(" %d(%d)", start, len);
271 }
272
273 static void indirect_print_item(struct item_head *ih, char *item)
274 {
275         int j;
276         __le32 *unp;
277         __u32 prev = INT_MAX;
278         int num = 0;
279
280         unp = (__le32 *) item;
281
282         if (ih_item_len(ih) % UNFM_P_SIZE)
283                 reiserfs_warning(NULL, "reiserfs-16102", "invalid item len");
284
285         printk("%d pointers\n[ ", (int)I_UNFM_NUM(ih));
286         for (j = 0; j < I_UNFM_NUM(ih); j++) {
287                 if (sequence_finished(prev, &num, get_block_num(unp, j))) {
288                         print_sequence(prev, num);
289                         start_new_sequence(&prev, &num, get_block_num(unp, j));
290                 }
291         }
292         print_sequence(prev, num);
293         printk("]\n");
294 }
295
296 static void indirect_check_item(struct item_head *ih, char *item)
297 {
298         // FIXME: type something here!
299 }
300
301 static int indirect_create_vi(struct virtual_node *vn,
302                               struct virtual_item *vi,
303                               int is_affected, int insert_size)
304 {
305         vi->vi_index = TYPE_INDIRECT;
306         //vi->vi_type |= VI_TYPE_INDIRECT;
307         return 0;
308 }
309
310 static int indirect_check_left(struct virtual_item *vi, int free,
311                                int start_skip, int end_skip)
312 {
313         int bytes;
314
315         bytes = free - free % UNFM_P_SIZE;
316         return bytes ? : -1;
317 }
318
319 static int indirect_check_right(struct virtual_item *vi, int free)
320 {
321         return indirect_check_left(vi, free, 0, 0);
322 }
323
324 // return size in bytes of 'units' units. If first == 0 - calculate from the head (left), otherwise - from tail (right)
325 static int indirect_part_size(struct virtual_item *vi, int first, int units)
326 {
327         // unit of indirect item is byte (yet)
328         return units;
329 }
330
331 static int indirect_unit_num(struct virtual_item *vi)
332 {
333         // unit of indirect item is byte (yet)
334         return vi->vi_item_len - IH_SIZE;
335 }
336
337 static void indirect_print_vi(struct virtual_item *vi)
338 {
339         reiserfs_warning(NULL, "reiserfs-16103",
340                          "INDIRECT, index %d, type 0x%x, %h",
341                          vi->vi_index, vi->vi_type, vi->vi_ih);
342 }
343
344 static struct item_operations indirect_ops = {
345         .bytes_number = indirect_bytes_number,
346         .decrement_key = indirect_decrement_key,
347         .is_left_mergeable = indirect_is_left_mergeable,
348         .print_item = indirect_print_item,
349         .check_item = indirect_check_item,
350
351         .create_vi = indirect_create_vi,
352         .check_left = indirect_check_left,
353         .check_right = indirect_check_right,
354         .part_size = indirect_part_size,
355         .unit_num = indirect_unit_num,
356         .print_vi = indirect_print_vi
357 };
358
359 //////////////////////////////////////////////////////////////////////////////
360 // direntry functions
361 //
362
363 static int direntry_bytes_number(struct item_head *ih, int block_size)
364 {
365         reiserfs_warning(NULL, "vs-16090",
366                          "bytes number is asked for direntry");
367         return 0;
368 }
369
370 static void direntry_decrement_key(struct cpu_key *key)
371 {
372         cpu_key_k_offset_dec(key);
373         if (cpu_key_k_offset(key) == 0)
374                 set_cpu_key_k_type(key, TYPE_STAT_DATA);
375 }
376
377 static int direntry_is_left_mergeable(struct reiserfs_key *key,
378                                       unsigned long bsize)
379 {
380         if (le32_to_cpu(key->u.k_offset_v1.k_offset) == DOT_OFFSET)
381                 return 0;
382         return 1;
383
384 }
385
386 static void direntry_print_item(struct item_head *ih, char *item)
387 {
388         int i;
389         int namelen;
390         struct reiserfs_de_head *deh;
391         char *name;
392         static char namebuf[80];
393
394         printk("\n # %-15s%-30s%-15s%-15s%-15s\n", "Name",
395                "Key of pointed object", "Hash", "Gen number", "Status");
396
397         deh = (struct reiserfs_de_head *)item;
398
399         for (i = 0; i < I_ENTRY_COUNT(ih); i++, deh++) {
400                 namelen =
401                     (i ? (deh_location(deh - 1)) : ih_item_len(ih)) -
402                     deh_location(deh);
403                 name = item + deh_location(deh);
404                 if (name[namelen - 1] == 0)
405                         namelen = strlen(name);
406                 namebuf[0] = '"';
407                 if (namelen > sizeof(namebuf) - 3) {
408                         strncpy(namebuf + 1, name, sizeof(namebuf) - 3);
409                         namebuf[sizeof(namebuf) - 2] = '"';
410                         namebuf[sizeof(namebuf) - 1] = 0;
411                 } else {
412                         memcpy(namebuf + 1, name, namelen);
413                         namebuf[namelen + 1] = '"';
414                         namebuf[namelen + 2] = 0;
415                 }
416
417                 printk("%d:  %-15s%-15d%-15d%-15Ld%-15Ld(%s)\n",
418                        i, namebuf,
419                        deh_dir_id(deh), deh_objectid(deh),
420                        GET_HASH_VALUE(deh_offset(deh)),
421                        GET_GENERATION_NUMBER((deh_offset(deh))),
422                        (de_hidden(deh)) ? "HIDDEN" : "VISIBLE");
423         }
424 }
425
426 static void direntry_check_item(struct item_head *ih, char *item)
427 {
428         int i;
429         struct reiserfs_de_head *deh;
430
431         // FIXME: type something here!
432         deh = (struct reiserfs_de_head *)item;
433         for (i = 0; i < I_ENTRY_COUNT(ih); i++, deh++) {
434                 ;
435         }
436 }
437
438 #define DIRENTRY_VI_FIRST_DIRENTRY_ITEM 1
439
440 /*
441  * function returns old entry number in directory item in real node
442  * using new entry number in virtual item in virtual node */
443 static inline int old_entry_num(int is_affected, int virtual_entry_num,
444                                 int pos_in_item, int mode)
445 {
446         if (mode == M_INSERT || mode == M_DELETE)
447                 return virtual_entry_num;
448
449         if (!is_affected)
450                 /* cut or paste is applied to another item */
451                 return virtual_entry_num;
452
453         if (virtual_entry_num < pos_in_item)
454                 return virtual_entry_num;
455
456         if (mode == M_CUT)
457                 return virtual_entry_num + 1;
458
459         RFALSE(mode != M_PASTE || virtual_entry_num == 0,
460                "vs-8015: old_entry_num: mode must be M_PASTE (mode = \'%c\'",
461                mode);
462
463         return virtual_entry_num - 1;
464 }
465
466 /* Create an array of sizes of directory entries for virtual
467    item. Return space used by an item. FIXME: no control over
468    consuming of space used by this item handler */
469 static int direntry_create_vi(struct virtual_node *vn,
470                               struct virtual_item *vi,
471                               int is_affected, int insert_size)
472 {
473         struct direntry_uarea *dir_u = vi->vi_uarea;
474         int i, j;
475         int size = sizeof(struct direntry_uarea);
476         struct reiserfs_de_head *deh;
477
478         vi->vi_index = TYPE_DIRENTRY;
479
480         BUG_ON(!(vi->vi_ih) || !vi->vi_item);
481
482         dir_u->flags = 0;
483         if (le_ih_k_offset(vi->vi_ih) == DOT_OFFSET)
484                 dir_u->flags |= DIRENTRY_VI_FIRST_DIRENTRY_ITEM;
485
486         deh = (struct reiserfs_de_head *)(vi->vi_item);
487
488         /* virtual directory item have this amount of entry after */
489         dir_u->entry_count = ih_entry_count(vi->vi_ih) +
490             ((is_affected) ? ((vn->vn_mode == M_CUT) ? -1 :
491                               (vn->vn_mode == M_PASTE ? 1 : 0)) : 0);
492
493         for (i = 0; i < dir_u->entry_count; i++) {
494                 j = old_entry_num(is_affected, i, vn->vn_pos_in_item,
495                                   vn->vn_mode);
496                 dir_u->entry_sizes[i] =
497                     (j ? deh_location(&(deh[j - 1])) : ih_item_len(vi->vi_ih)) -
498                     deh_location(&(deh[j])) + DEH_SIZE;
499         }
500
501         size += (dir_u->entry_count * sizeof(short));
502
503         /* set size of pasted entry */
504         if (is_affected && vn->vn_mode == M_PASTE)
505                 dir_u->entry_sizes[vn->vn_pos_in_item] = insert_size;
506
507 #ifdef CONFIG_REISERFS_CHECK
508         /* compare total size of entries with item length */
509         {
510                 int k, l;
511
512                 l = 0;
513                 for (k = 0; k < dir_u->entry_count; k++)
514                         l += dir_u->entry_sizes[k];
515
516                 if (l + IH_SIZE != vi->vi_item_len +
517                     ((is_affected
518                       && (vn->vn_mode == M_PASTE
519                           || vn->vn_mode == M_CUT)) ? insert_size : 0)) {
520                         reiserfs_panic(NULL,
521                                        "vs-8025: set_entry_sizes: (mode==%c, insert_size==%d), invalid length of directory item",
522                                        vn->vn_mode, insert_size);
523                 }
524         }
525 #endif
526
527         return size;
528
529 }
530
531 //
532 // return number of entries which may fit into specified amount of
533 // free space, or -1 if free space is not enough even for 1 entry
534 //
535 static int direntry_check_left(struct virtual_item *vi, int free,
536                                int start_skip, int end_skip)
537 {
538         int i;
539         int entries = 0;
540         struct direntry_uarea *dir_u = vi->vi_uarea;
541
542         for (i = start_skip; i < dir_u->entry_count - end_skip; i++) {
543                 if (dir_u->entry_sizes[i] > free)
544                         /* i-th entry doesn't fit into the remaining free space */
545                         break;
546
547                 free -= dir_u->entry_sizes[i];
548                 entries++;
549         }
550
551         if (entries == dir_u->entry_count) {
552                 reiserfs_panic(NULL, "free space %d, entry_count %d\n", free,
553                                dir_u->entry_count);
554         }
555
556         /* "." and ".." can not be separated from each other */
557         if (start_skip == 0 && (dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM)
558             && entries < 2)
559                 entries = 0;
560
561         return entries ? : -1;
562 }
563
564 static int direntry_check_right(struct virtual_item *vi, int free)
565 {
566         int i;
567         int entries = 0;
568         struct direntry_uarea *dir_u = vi->vi_uarea;
569
570         for (i = dir_u->entry_count - 1; i >= 0; i--) {
571                 if (dir_u->entry_sizes[i] > free)
572                         /* i-th entry doesn't fit into the remaining free space */
573                         break;
574
575                 free -= dir_u->entry_sizes[i];
576                 entries++;
577         }
578         BUG_ON(entries == dir_u->entry_count);
579
580         /* "." and ".." can not be separated from each other */
581         if ((dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM)
582             && entries > dir_u->entry_count - 2)
583                 entries = dir_u->entry_count - 2;
584
585         return entries ? : -1;
586 }
587
588 /* sum of entry sizes between from-th and to-th entries including both edges */
589 static int direntry_part_size(struct virtual_item *vi, int first, int count)
590 {
591         int i, retval;
592         int from, to;
593         struct direntry_uarea *dir_u = vi->vi_uarea;
594
595         retval = 0;
596         if (first == 0)
597                 from = 0;
598         else
599                 from = dir_u->entry_count - count;
600         to = from + count - 1;
601
602         for (i = from; i <= to; i++)
603                 retval += dir_u->entry_sizes[i];
604
605         return retval;
606 }
607
608 static int direntry_unit_num(struct virtual_item *vi)
609 {
610         struct direntry_uarea *dir_u = vi->vi_uarea;
611
612         return dir_u->entry_count;
613 }
614
615 static void direntry_print_vi(struct virtual_item *vi)
616 {
617         int i;
618         struct direntry_uarea *dir_u = vi->vi_uarea;
619
620         reiserfs_warning(NULL, "reiserfs-16104",
621                          "DIRENTRY, index %d, type 0x%x, %h, flags 0x%x",
622                          vi->vi_index, vi->vi_type, vi->vi_ih, dir_u->flags);
623         printk("%d entries: ", dir_u->entry_count);
624         for (i = 0; i < dir_u->entry_count; i++)
625                 printk("%d ", dir_u->entry_sizes[i]);
626         printk("\n");
627 }
628
629 static struct item_operations direntry_ops = {
630         .bytes_number = direntry_bytes_number,
631         .decrement_key = direntry_decrement_key,
632         .is_left_mergeable = direntry_is_left_mergeable,
633         .print_item = direntry_print_item,
634         .check_item = direntry_check_item,
635
636         .create_vi = direntry_create_vi,
637         .check_left = direntry_check_left,
638         .check_right = direntry_check_right,
639         .part_size = direntry_part_size,
640         .unit_num = direntry_unit_num,
641         .print_vi = direntry_print_vi
642 };
643
644 //////////////////////////////////////////////////////////////////////////////
645 // Error catching functions to catch errors caused by incorrect item types.
646 //
647 static int errcatch_bytes_number(struct item_head *ih, int block_size)
648 {
649         reiserfs_warning(NULL, "green-16001",
650                          "Invalid item type observed, run fsck ASAP");
651         return 0;
652 }
653
654 static void errcatch_decrement_key(struct cpu_key *key)
655 {
656         reiserfs_warning(NULL, "green-16002",
657                          "Invalid item type observed, run fsck ASAP");
658 }
659
660 static int errcatch_is_left_mergeable(struct reiserfs_key *key,
661                                       unsigned long bsize)
662 {
663         reiserfs_warning(NULL, "green-16003",
664                          "Invalid item type observed, run fsck ASAP");
665         return 0;
666 }
667
668 static void errcatch_print_item(struct item_head *ih, char *item)
669 {
670         reiserfs_warning(NULL, "green-16004",
671                          "Invalid item type observed, run fsck ASAP");
672 }
673
674 static void errcatch_check_item(struct item_head *ih, char *item)
675 {
676         reiserfs_warning(NULL, "green-16005",
677                          "Invalid item type observed, run fsck ASAP");
678 }
679
680 static int errcatch_create_vi(struct virtual_node *vn,
681                               struct virtual_item *vi,
682                               int is_affected, int insert_size)
683 {
684         reiserfs_warning(NULL, "green-16006",
685                          "Invalid item type observed, run fsck ASAP");
686         return 0;               // We might return -1 here as well, but it won't help as create_virtual_node() from where
687         // this operation is called from is of return type void.
688 }
689
690 static int errcatch_check_left(struct virtual_item *vi, int free,
691                                int start_skip, int end_skip)
692 {
693         reiserfs_warning(NULL, "green-16007",
694                          "Invalid item type observed, run fsck ASAP");
695         return -1;
696 }
697
698 static int errcatch_check_right(struct virtual_item *vi, int free)
699 {
700         reiserfs_warning(NULL, "green-16008",
701                          "Invalid item type observed, run fsck ASAP");
702         return -1;
703 }
704
705 static int errcatch_part_size(struct virtual_item *vi, int first, int count)
706 {
707         reiserfs_warning(NULL, "green-16009",
708                          "Invalid item type observed, run fsck ASAP");
709         return 0;
710 }
711
712 static int errcatch_unit_num(struct virtual_item *vi)
713 {
714         reiserfs_warning(NULL, "green-16010",
715                          "Invalid item type observed, run fsck ASAP");
716         return 0;
717 }
718
719 static void errcatch_print_vi(struct virtual_item *vi)
720 {
721         reiserfs_warning(NULL, "green-16011",
722                          "Invalid item type observed, run fsck ASAP");
723 }
724
725 static struct item_operations errcatch_ops = {
726         errcatch_bytes_number,
727         errcatch_decrement_key,
728         errcatch_is_left_mergeable,
729         errcatch_print_item,
730         errcatch_check_item,
731
732         errcatch_create_vi,
733         errcatch_check_left,
734         errcatch_check_right,
735         errcatch_part_size,
736         errcatch_unit_num,
737         errcatch_print_vi
738 };
739
740 //////////////////////////////////////////////////////////////////////////////
741 //
742 //
743 #if ! (TYPE_STAT_DATA == 0 && TYPE_INDIRECT == 1 && TYPE_DIRECT == 2 && TYPE_DIRENTRY == 3)
744 #error Item types must use disk-format assigned values.
745 #endif
746
747 struct item_operations *item_ops[TYPE_ANY + 1] = {
748         &stat_data_ops,
749         &indirect_ops,
750         &direct_ops,
751         &direntry_ops,
752         NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
753         &errcatch_ops           /* This is to catch errors with invalid type (15th entry for TYPE_ANY) */
754 };