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
|
/* Copyright (C) 2001-2005 by Hans Reiser, licensing governed by
reiser4progs/COPYING.
plain40.c -- reiser4 plain file body (aka formatting) item plugin. */
#include "plain40.h"
#include "plain40_repair.h"
#include <plugin/item/body40/body40.h>
#include <plugin/item/tail40/tail40.h>
#include <plugin/item/tail40/tail40_repair.h>
reiser4_core_t *plain40_core = NULL;
#ifndef ENABLE_MINIMAL
/* Return 1 if two tail items are mergeable. Otherwise 0 will be returned. This
method is used in balancing to determine if two border items may be
merged. */
static int plain40_mergeable(reiser4_place_t *place1, reiser4_place_t *place2) {
aal_assert("umka-2201", place1 != NULL);
aal_assert("umka-2202", place2 != NULL);
return body40_mergeable(place1, place2);
}
/* Estimates how many bytes in tree is needed to write @hint->count bytes of
data. This function considers, that tail item is not expandable one. That is,
tail will not be splitted at insert point, but will be rewritten instead. */
errno_t plain40_prep_write(reiser4_place_t *place, trans_hint_t *hint) {
place->off = 0;
return tail40_prep_write(place, hint);
}
/* Estimates how many bytes may be shifted from @stc_place to @dst_place. */
errno_t plain40_prep_shift(reiser4_place_t *src_place,
reiser4_place_t *dst_place,
shift_hint_t *hint)
{
if (dst_place)
dst_place->off = 0;
return tail40_prep_shift(src_place, dst_place, hint);
}
#endif
static item_balance_ops_t balance_ops = {
#ifndef ENABLE_MINIMAL
.merge = NULL,
.update_key = NULL,
.mergeable = plain40_mergeable,
.maxreal_key = tail40_maxreal_key,
.prep_shift = plain40_prep_shift,
.shift_units = tail40_shift_units,
.collision = NULL,
.overhead = NULL,
#endif
.init = NULL,
.units = tail40_units,
.lookup = tail40_lookup,
.fetch_key = tail40_fetch_key,
.maxposs_key = tail40_maxposs_key
};
static item_object_ops_t object_ops = {
#ifndef ENABLE_MINIMAL
.size = tail40_size,
.bytes = tail40_size,
.prep_write = plain40_prep_write,
.write_units = tail40_write_units,
.trunc_units = tail40_trunc_units,
.prep_insert = NULL,
.insert_units = NULL,
.remove_units = NULL,
.update_units = NULL,
.layout = NULL,
#endif
.fetch_units = NULL,
.read_units = tail40_read_units
};
#ifndef ENABLE_MINIMAL
static item_repair_ops_t repair_ops = {
.check_struct = tail40_check_struct,
.check_layout = NULL,
.prep_insert_raw = plain40_prep_insert_raw,
.insert_raw = tail40_insert_raw,
.pack = tail40_pack,
.unpack = tail40_unpack
};
static item_debug_ops_t debug_ops = {
.print = NULL
};
#endif
reiser4_item_plug_t plain40_plug = {
.p = {
.id = {ITEM_PLAIN40_ID, TAIL_ITEM, ITEM_PLUG_TYPE},
#ifndef ENABLE_MINIMAL
.label = "plain40",
.desc = "Plain file body item plugin.",
#endif
},
.object = &object_ops,
.balance = &balance_ops,
#ifndef ENABLE_MINIMAL
.repair = &repair_ops,
.debug = &debug_ops,
#endif
};
|