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