/* * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README */ #include <linux/uaccess.h> #include <linux/string.h> #include <linux/time.h> #include "reiserfs.h" #include <linux/buffer_head.h> /* * copy copy_count entries from source directory item to dest buffer * (creating new item if needed) */ static void leaf_copy_dir_entries(struct buffer_info *dest_bi, struct buffer_head *source, int last_first, int item_num, int from, int copy_count) { … } /* * Copy the first (if last_first == FIRST_TO_LAST) or last * (last_first == LAST_TO_FIRST) item or part of it or nothing * (see the return 0 below) from SOURCE to the end (if last_first) * or beginning (!last_first) of the DEST */ /* returns 1 if anything was copied, else 0 */ static int leaf_copy_boundary_item(struct buffer_info *dest_bi, struct buffer_head *src, int last_first, int bytes_or_entries) { … } /* * copy cpy_mun items from buffer src to buffer dest * last_first == FIRST_TO_LAST means, that we copy cpy_num items beginning * from first-th item in src to tail of dest * last_first == LAST_TO_FIRST means, that we copy cpy_num items beginning * from first-th item in src to head of dest */ static void leaf_copy_items_entirely(struct buffer_info *dest_bi, struct buffer_head *src, int last_first, int first, int cpy_num) { … } /* * This function splits the (liquid) item into two items (useful when * shifting part of an item into another node.) */ static void leaf_item_bottle(struct buffer_info *dest_bi, struct buffer_head *src, int last_first, int item_num, int cpy_bytes) { … } /* * If cpy_bytes equals minus one than copy cpy_num whole items from SOURCE * to DEST. If cpy_bytes not equal to minus one than copy cpy_num-1 whole * items from SOURCE to DEST. From last item copy cpy_num bytes for regular * item and cpy_num directory entries for directory item. */ static int leaf_copy_items(struct buffer_info *dest_bi, struct buffer_head *src, int last_first, int cpy_num, int cpy_bytes) { … } /* * there are types of coping: from S[0] to L[0], from S[0] to R[0], * from R[0] to L[0]. for each of these we have to define parent and * positions of destination and source buffers */ static void leaf_define_dest_src_infos(int shift_mode, struct tree_balance *tb, struct buffer_info *dest_bi, struct buffer_info *src_bi, int *first_last, struct buffer_head *Snew) { … } /* * copy mov_num items and mov_bytes of the (mov_num-1)th item to * neighbor. Delete them from source */ int leaf_move_items(int shift_mode, struct tree_balance *tb, int mov_num, int mov_bytes, struct buffer_head *Snew) { … } /* * Shift shift_num items (and shift_bytes of last shifted item if * shift_bytes != -1) from S[0] to L[0] and replace the delimiting key */ int leaf_shift_left(struct tree_balance *tb, int shift_num, int shift_bytes) { … } /* CLEANING STOPPED HERE */ /* * Shift shift_num (shift_bytes) items from S[0] to the right neighbor, * and replace the delimiting key */ int leaf_shift_right(struct tree_balance *tb, int shift_num, int shift_bytes) { … } static void leaf_delete_items_entirely(struct buffer_info *bi, int first, int del_num); /* * If del_bytes == -1, starting from position 'first' delete del_num * items in whole in buffer CUR. * If not. * If last_first == 0. Starting from position 'first' delete del_num-1 * items in whole. Delete part of body of the first item. Part defined by * del_bytes. Don't delete first item header * If last_first == 1. Starting from position 'first+1' delete del_num-1 * items in whole. Delete part of body of the last item . Part defined by * del_bytes. Don't delete last item header. */ void leaf_delete_items(struct buffer_info *cur_bi, int last_first, int first, int del_num, int del_bytes) { … } /* insert item into the leaf node in position before */ void leaf_insert_into_buf(struct buffer_info *bi, int before, struct item_head * const inserted_item_ih, const char * const inserted_item_body, int zeros_number) { … } /* * paste paste_size bytes to affected_item_num-th item. * When item is a directory, this only prepare space for new entries */ void leaf_paste_in_buffer(struct buffer_info *bi, int affected_item_num, int pos_in_item, int paste_size, const char *body, int zeros_number) { … } /* * cuts DEL_COUNT entries beginning from FROM-th entry. Directory item * does not have free space, so it moves DEHs and remaining records as * necessary. Return value is size of removed part of directory item * in bytes. */ static int leaf_cut_entries(struct buffer_head *bh, struct item_head *ih, int from, int del_count) { … } /* * when cut item is part of regular file * pos_in_item - first byte that must be cut * cut_size - number of bytes to be cut beginning from pos_in_item * * when cut item is part of directory * pos_in_item - number of first deleted entry * cut_size - count of deleted entries */ void leaf_cut_from_buffer(struct buffer_info *bi, int cut_item_num, int pos_in_item, int cut_size) { … } /* delete del_num items from buffer starting from the first'th item */ static void leaf_delete_items_entirely(struct buffer_info *bi, int first, int del_num) { … } /* * paste new_entry_count entries (new_dehs, records) into position * before to item_num-th item */ void leaf_paste_entries(struct buffer_info *bi, int item_num, int before, int new_entry_count, struct reiserfs_de_head *new_dehs, const char *records, int paste_size) { … }