1147476Sdumbbell/*- 2147476Sdumbbell * Copyright 2000 Hans Reiser 3147476Sdumbbell * See README for licensing and copyright details 4147476Sdumbbell * 5230132Suqs * Ported to FreeBSD by Jean-S��bastien P��dron <jspedron@club-internet.fr> 6147476Sdumbbell * 7147476Sdumbbell * $FreeBSD: releng/10.2/sys/gnu/fs/reiserfs/reiserfs_item_ops.c 230132 2012-01-15 13:23:18Z uqs $ 8147476Sdumbbell */ 9147476Sdumbbell 10147476Sdumbbell#include <gnu/fs/reiserfs/reiserfs_fs.h> 11147476Sdumbbell 12147476Sdumbbell/* ------------------------------------------------------------------- 13147476Sdumbbell * Stat data functions 14147476Sdumbbell * -------------------------------------------------------------------*/ 15147476Sdumbbell 16147476Sdumbbellstatic int 17147476Sdumbbellsd_bytes_number(struct item_head *ih, int block_size) 18147476Sdumbbell{ 19147476Sdumbbell 20147476Sdumbbell return (0); 21147476Sdumbbell} 22147476Sdumbbell 23147476Sdumbbellstruct item_operations stat_data_ops = { 24147476Sdumbbell .bytes_number = sd_bytes_number, 25147476Sdumbbell //.decrement_key = sd_decrement_key, 26147476Sdumbbell //.is_left_mergeable = sd_is_left_mergeable, 27147476Sdumbbell //.print_item = sd_print_item, 28147476Sdumbbell //.check_item = sd_check_item, 29147476Sdumbbell 30147476Sdumbbell //.create_vi = sd_create_vi, 31147476Sdumbbell //.check_left = sd_check_left, 32147476Sdumbbell //.check_right = sd_check_right, 33147476Sdumbbell //.part_size = sd_part_size, 34147476Sdumbbell //.unit_num = sd_unit_num, 35147476Sdumbbell //.print_vi = sd_print_vi 36147476Sdumbbell}; 37147476Sdumbbell 38147476Sdumbbell/* ------------------------------------------------------------------- 39147476Sdumbbell * Direct item functions 40147476Sdumbbell * -------------------------------------------------------------------*/ 41147476Sdumbbell 42147476Sdumbbellstatic int 43147476Sdumbbelldirect_bytes_number(struct item_head *ih, int block_size) 44147476Sdumbbell{ 45147476Sdumbbell 46147476Sdumbbell return (ih_item_len(ih)); 47147476Sdumbbell} 48147476Sdumbbell 49147476Sdumbbellstruct item_operations direct_ops = { 50147476Sdumbbell .bytes_number = direct_bytes_number, 51147476Sdumbbell //.decrement_key = direct_decrement_key, 52147476Sdumbbell //.is_left_mergeable = direct_is_left_mergeable, 53147476Sdumbbell //.print_item = direct_print_item, 54147476Sdumbbell //.check_item = direct_check_item, 55147476Sdumbbell 56147476Sdumbbell //.create_vi = direct_create_vi, 57147476Sdumbbell //.check_left = direct_check_left, 58147476Sdumbbell //.check_right = direct_check_right, 59147476Sdumbbell //.part_size = direct_part_size, 60147476Sdumbbell //.unit_num = direct_unit_num, 61147476Sdumbbell //.print_vi = direct_print_vi 62147476Sdumbbell}; 63147476Sdumbbell 64147476Sdumbbell/* ------------------------------------------------------------------- 65147476Sdumbbell * Indirect item functions 66147476Sdumbbell * -------------------------------------------------------------------*/ 67147476Sdumbbell 68147476Sdumbbellstatic int 69147476Sdumbbellindirect_bytes_number(struct item_head *ih, int block_size) 70147476Sdumbbell{ 71147476Sdumbbell 72147476Sdumbbell return (ih_item_len(ih) / UNFM_P_SIZE * block_size); 73147476Sdumbbell} 74147476Sdumbbell 75147476Sdumbbellstruct item_operations indirect_ops = { 76147476Sdumbbell .bytes_number = indirect_bytes_number, 77147476Sdumbbell //.decrement_key = indirect_decrement_key, 78147476Sdumbbell //.is_left_mergeable = indirect_is_left_mergeable, 79147476Sdumbbell //.print_item = indirect_print_item, 80147476Sdumbbell //.check_item = indirect_check_item, 81147476Sdumbbell 82147476Sdumbbell //.create_vi = indirect_create_vi, 83147476Sdumbbell //.check_left = indirect_check_left, 84147476Sdumbbell //.check_right = indirect_check_right, 85147476Sdumbbell //.part_size = indirect_part_size, 86147476Sdumbbell //.unit_num = indirect_unit_num, 87147476Sdumbbell //.print_vi = indirect_print_vi 88147476Sdumbbell}; 89147476Sdumbbell 90147476Sdumbbell/* ------------------------------------------------------------------- 91147476Sdumbbell * Direntry functions 92147476Sdumbbell * -------------------------------------------------------------------*/ 93147476Sdumbbell 94147476Sdumbbellstatic int 95147476Sdumbbelldirentry_bytes_number(struct item_head *ih, int block_size) 96147476Sdumbbell{ 97147476Sdumbbell 98147476Sdumbbell reiserfs_log(LOG_WARNING, "bytes number is asked for direntry\n"); 99147476Sdumbbell return (0); 100147476Sdumbbell} 101147476Sdumbbell 102147476Sdumbbellstruct item_operations direntry_ops = { 103147476Sdumbbell .bytes_number = direntry_bytes_number, 104147476Sdumbbell //.decrement_key = direntry_decrement_key, 105147476Sdumbbell //.is_left_mergeable = direntry_is_left_mergeable, 106147476Sdumbbell //.print_item = direntry_print_item, 107147476Sdumbbell //.check_item = direntry_check_item, 108147476Sdumbbell 109147476Sdumbbell //.create_vi = direntry_create_vi, 110147476Sdumbbell //.check_left = direntry_check_left, 111147476Sdumbbell //.check_right = direntry_check_right, 112147476Sdumbbell //.part_size = direntry_part_size, 113147476Sdumbbell //.unit_num = direntry_unit_num, 114147476Sdumbbell //.print_vi = direntry_print_vi 115147476Sdumbbell}; 116147476Sdumbbell 117147476Sdumbbell/* ------------------------------------------------------------------- 118147476Sdumbbell * Error catching functions to catch errors caused by incorrect item 119147476Sdumbbell * types. 120147476Sdumbbell * -------------------------------------------------------------------*/ 121147476Sdumbbell 122147476Sdumbbellstatic int 123147476Sdumbbellerrcatch_bytes_number(struct item_head *ih, int block_size) 124147476Sdumbbell{ 125147476Sdumbbell 126147476Sdumbbell reiserfs_log(LOG_WARNING, "invalid item type observed, run fsck ASAP"); 127147476Sdumbbell return (0); 128147476Sdumbbell} 129147476Sdumbbell 130147476Sdumbbellstruct item_operations errcatch_ops = { 131147476Sdumbbell errcatch_bytes_number, 132147476Sdumbbell //errcatch_decrement_key, 133147476Sdumbbell //errcatch_is_left_mergeable, 134147476Sdumbbell //errcatch_print_item, 135147476Sdumbbell //errcatch_check_item, 136147476Sdumbbell 137147476Sdumbbell //errcatch_create_vi, 138147476Sdumbbell //errcatch_check_left, 139147476Sdumbbell //errcatch_check_right, 140147476Sdumbbell //errcatch_part_size, 141147476Sdumbbell //errcatch_unit_num, 142147476Sdumbbell //errcatch_print_vi 143147476Sdumbbell}; 144147476Sdumbbell 145147476Sdumbbell#if !(TYPE_STAT_DATA == 0 && TYPE_INDIRECT == 1 && \ 146147476Sdumbbell TYPE_DIRECT == 2 && TYPE_DIRENTRY == 3) 147147476Sdumbbell#error 148147476Sdumbbell#endif 149147476Sdumbbell 150147476Sdumbbellstruct item_operations *item_ops[TYPE_ANY + 1] = { 151147476Sdumbbell &stat_data_ops, 152147476Sdumbbell &indirect_ops, 153147476Sdumbbell &direct_ops, 154147476Sdumbbell &direntry_ops, 155147476Sdumbbell NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 156147476Sdumbbell &errcatch_ops /* This is to catch errors with invalid type (15th 157147476Sdumbbell entry for TYPE_ANY) */ 158147476Sdumbbell}; 159