aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2014-03-13 17:08:43 -0400
committerJeff Mahoney <jeffm@suse.com>2014-03-13 17:42:58 -0400
commit6daa8a9c5a0979fe16684151058a9a81a0671e06 (patch)
tree2105b246605d42658351edac79f024d0315951fd
parent9b52a79ba23f92ae76297ab812b9eeaf9b6607bb (diff)
downloadreiserfsprogs-6daa8a9c5a0979fe16684151058a9a81a0671e06.tar.gz
reiserfscore: constify struct pointer arguments
There are many cases where functions take pointers to keys, item heads, paths, etc and don't modify them. Let's annotate them properly. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
-rw-r--r--debugreiserfs/scan.c17
-rw-r--r--fsck/check_tree.c4
-rw-r--r--fsck/fsck.h7
-rw-r--r--fsck/pass0.c2
-rw-r--r--fsck/pass2.c8
-rw-r--r--fsck/pass4.c2
-rw-r--r--fsck/semantic_check.c21
-rw-r--r--fsck/semantic_rebuild.c19
-rw-r--r--fsck/ufile.c6
-rw-r--r--include/reiserfs_fs.h22
-rw-r--r--include/reiserfs_lib.h30
-rw-r--r--reiserfscore/do_balan.c4
-rw-r--r--reiserfscore/node_formats.c14
-rw-r--r--reiserfscore/prints.c2
-rw-r--r--reiserfscore/reiserfslib.c22
-rw-r--r--reiserfscore/stree.c8
16 files changed, 97 insertions, 91 deletions
diff --git a/debugreiserfs/scan.c b/debugreiserfs/scan.c
index de346f2..dcf05dd 100644
--- a/debugreiserfs/scan.c
+++ b/debugreiserfs/scan.c
@@ -47,8 +47,8 @@ struct saved_name {
};
/* attach item to every name in the list */
-static void store_item(struct saved_name *name, struct buffer_head *bh,
- struct item_head *ih, int pos)
+static void store_item(struct saved_name *name, const struct buffer_head *bh,
+ const struct item_head *ih, int pos)
{
struct saved_item *new;
void *vp;
@@ -248,7 +248,7 @@ static void scan_for_name(struct buffer_head *bh)
return;
}
-static struct saved_name *scan_for_key(struct reiserfs_key *key)
+static struct saved_name *scan_for_key(const struct reiserfs_key *key)
{
char *name;
struct saved_name *new, *name_in;
@@ -293,8 +293,9 @@ static struct saved_name *scan_for_key(struct reiserfs_key *key)
return new;
}
-static int comp_token_key(struct buffer_head *bh, struct item_head *ih,
- struct reiserfs_key *key)
+static int comp_token_key(const struct buffer_head *bh,
+ const struct item_head *ih,
+ const struct reiserfs_key *key)
{
struct reiserfs_de_head *deh;
int j, ih_entry_count = 0;
@@ -333,7 +334,7 @@ static int comp_token_key(struct buffer_head *bh, struct item_head *ih,
/* take every item, look for its key in the key index, if it is found - store
item in the sorted list of items of a file */
-static void scan_items(struct buffer_head *bh, struct reiserfs_key *key)
+static void scan_items(const struct buffer_head *bh, const struct reiserfs_key *key)
{
int i, i_num, pos;
struct item_head *ih;
@@ -582,8 +583,8 @@ static void map_one_item(struct saved_item *item)
// flush map which is in variable map
static void flush_map(reiserfs_filsys_t fs,
- struct reiserfs_key *dir,
- char *name, struct reiserfs_key *key)
+ const struct reiserfs_key *dir,
+ const char *name, const struct reiserfs_key *key)
{
int i;
FILE *fp;
diff --git a/fsck/check_tree.c b/fsck/check_tree.c
index a15f26b..5b6bddf 100644
--- a/fsck/check_tree.c
+++ b/fsck/check_tree.c
@@ -1008,7 +1008,7 @@ static int bad_node(reiserfs_filsys_t fs, struct buffer_head **path, int h)
}
/* internal node bh must point to block */
-static int get_pos(struct buffer_head *bh, unsigned long block)
+static int get_pos(const struct buffer_head *bh, unsigned long block)
{
int i;
@@ -1052,7 +1052,7 @@ static struct reiserfs_key *rkey(struct buffer_head **path, int h)
static int bad_path(reiserfs_filsys_t fs, struct buffer_head **path, int h1)
{
int h = 0;
- struct reiserfs_key *dk;
+ const struct reiserfs_key *dk;
int pos = 0;
while (path[h])
diff --git a/fsck/fsck.h b/fsck/fsck.h
index 4265dd2..cc016e4 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -129,8 +129,8 @@ void link_relocated_files(void);
int should_relocate(struct item_head *ih);
void relocate_dir(struct item_head *ih, int change_ih);
-extern __u32 objectid_for_relocation(struct reiserfs_key *key);
-extern void linked_already(struct reiserfs_key *new_key);
+extern __u32 objectid_for_relocation(const struct reiserfs_key *key);
+extern void linked_already(const struct reiserfs_key *new_key);
/* file.c */
struct si {
@@ -178,7 +178,8 @@ int is_dot(char *name, int namelen);
struct reiserfs_path *path, struct reiserfs_key *key);*/
int rebuild_check_regular_file(struct reiserfs_path *path, void *sd,
struct item_head *new_ih);
-int rebuild_semantic_pass(struct reiserfs_key *key, struct reiserfs_key *parent,
+int rebuild_semantic_pass(struct reiserfs_key *key,
+ const struct reiserfs_key *parent,
int is_dot_dot, struct item_head *new_ih);
/* lost+found.c */
diff --git a/fsck/pass0.c b/fsck/pass0.c
index 795c762..9949d69 100644
--- a/fsck/pass0.c
+++ b/fsck/pass0.c
@@ -597,7 +597,7 @@ static __inline__ int does_it_fit_into_dev(__u64 offset, __u64 fs_size)
fs_size) ? 1 : 0;
}
-static int is_wrong_short_key(struct reiserfs_key *key)
+static int is_wrong_short_key(const struct reiserfs_key *key)
{
if (get_key_dirid(key) == 0 || get_key_objectid(key) == 0
|| get_key_objectid(key) == 1 || get_key_dirid(key) == ~(__u32) 0
diff --git a/fsck/pass2.c b/fsck/pass2.c
index 506f09a..d34a92f 100644
--- a/fsck/pass2.c
+++ b/fsck/pass2.c
@@ -33,7 +33,7 @@ struct relocated {
beginning of semantic pass */
static struct relocated *relocated_list = NULL;
-static __u32 get_relocated_objectid_from_list(struct reiserfs_key *key)
+static __u32 get_relocated_objectid_from_list(const struct reiserfs_key *key)
{
struct relocated *cur = relocated_list;
@@ -48,7 +48,7 @@ static __u32 get_relocated_objectid_from_list(struct reiserfs_key *key)
}
/* return objectid the object has to be remapped with */
-__u32 objectid_for_relocation(struct reiserfs_key * key)
+__u32 objectid_for_relocation(const struct reiserfs_key * key)
{
struct relocated *cur;
__u32 cur_id;
@@ -89,7 +89,7 @@ static __u64 link_one(struct relocated *file)
return len;
}
-void linked_already(struct reiserfs_key *new_key /*, link_func_t link_func */ )
+void linked_already(const struct reiserfs_key *new_key /*, link_func_t link_func */ )
{
struct relocated *cur = relocated_list;
struct relocated *prev = NULL;
@@ -170,7 +170,7 @@ struct si *save_and_delete_file_item(struct si *si, struct reiserfs_path *path)
int should_relocate(struct item_head *ih)
{
struct reiserfs_key key;
- struct reiserfs_key *rkey;
+ const struct reiserfs_key *rkey;
struct reiserfs_path path;
struct item_head *path_ih;
diff --git a/fsck/pass4.c b/fsck/pass4.c
index a8f7bae..8a6cf5a 100644
--- a/fsck/pass4.c
+++ b/fsck/pass4.c
@@ -13,7 +13,7 @@ void pass_4_check_unaccessed_items(void)
struct buffer_head *bh;
struct item_head *ih;
unsigned long items;
- struct reiserfs_key *rdkey;
+ const struct reiserfs_key *rdkey;
path.path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
key = root_dir_key;
diff --git a/fsck/semantic_check.c b/fsck/semantic_check.c
index 22431e0..92f18b9 100644
--- a/fsck/semantic_check.c
+++ b/fsck/semantic_check.c
@@ -7,13 +7,14 @@
static struct reiserfs_key *trunc_links = NULL;
static __u32 links_num = 0;
-int wrong_mode(struct reiserfs_key *key, __u16 * mode, __u64 real_size,
+int wrong_mode(const struct reiserfs_key *key, __u16 * mode, __u64 real_size,
int symlink);
-int wrong_st_blocks(struct reiserfs_key *key, __u32 * blocks, __u32 sd_blocks,
- __u16 mode, int new_format);
-int wrong_st_size(struct reiserfs_key *key, unsigned long long max_file_size,
- int blocksize, __u64 * size, __u64 sd_size, int type);
-int wrong_first_direct_byte(struct reiserfs_key *key, int blocksize,
+int wrong_st_blocks(const struct reiserfs_key *key, __u32 * blocks,
+ __u32 sd_blocks, __u16 mode, int new_format);
+int wrong_st_size(const struct reiserfs_key *key,
+ unsigned long long max_file_size, int blocksize,
+ __u64 * size, __u64 sd_size, int type);
+int wrong_first_direct_byte(const struct reiserfs_key *key, int blocksize,
__u32 * first_direct_byte,
__u32 sd_first_direct_byte, __u32 size);
void get_object_key(struct reiserfs_de_head *deh, struct reiserfs_key *key,
@@ -32,7 +33,7 @@ struct reiserfs_path_key {
static struct reiserfs_path_key *head_key = NULL;
static struct reiserfs_path_key *tail_key = NULL;
-static int check_path_key(struct reiserfs_key *key)
+static int check_path_key(const struct reiserfs_key *key)
{
struct reiserfs_path_key *cur = head_key;
@@ -48,7 +49,7 @@ static int check_path_key(struct reiserfs_key *key)
return 0;
}
-static int add_path_key(struct reiserfs_key *key)
+static int add_path_key(const struct reiserfs_key *key)
{
if (check_path_key(key))
return LOOP_FOUND;
@@ -228,7 +229,7 @@ static int check_check_regular_file(struct reiserfs_path *path, void *sd,
/* returns buffer, containing found directory item.*/
static char *get_next_directory_item(struct reiserfs_key *key, /* on return this will contain key of next item in the tree */
- struct reiserfs_key *parent,
+ const struct reiserfs_key *parent,
struct item_head *ih, __u32 * pos_in_item,
int dir_format)
{
@@ -382,7 +383,7 @@ start_again:
/* semantic pass of --check */
static int check_semantic_pass(struct reiserfs_key *key,
- struct reiserfs_key *parent, int dot_dot,
+ const struct reiserfs_key *parent, int dot_dot,
struct item_head *new_ih)
{
struct reiserfs_path path;
diff --git a/fsck/semantic_rebuild.c b/fsck/semantic_rebuild.c
index bea4183..3cc00bb 100644
--- a/fsck/semantic_rebuild.c
+++ b/fsck/semantic_rebuild.c
@@ -97,7 +97,8 @@ void erase_name(int len)
}
/* *size is "real" file size, sd_size - size from stat data */
-int wrong_st_size(struct reiserfs_key *key, unsigned long long max_file_size,
+int wrong_st_size(const struct reiserfs_key *key,
+ unsigned long long max_file_size,
int blocksize, __u64 * size, __u64 sd_size, int type)
{
if (sd_size <= max_file_size) {
@@ -175,8 +176,8 @@ int wrong_st_size(struct reiserfs_key *key, unsigned long long max_file_size,
| file, dir, link | blocks | generation | blocks |
|------------------------------------------------------------------|
*/
-int wrong_st_blocks(struct reiserfs_key *key, __u32 * blocks, __u32 sd_blocks,
- __u16 mode, int new_format)
+int wrong_st_blocks(const struct reiserfs_key *key, __u32 * blocks,
+ __u32 sd_blocks, __u16 mode, int new_format)
{
int ret = 0;
@@ -231,7 +232,7 @@ int wrong_st_rdev (struct reiserfs_key *key, __u32 * sd_rdev, __u16 mode, int ne
*/
/* only regular files and symlinks may have items but stat
data. Symlink should have body */
-int wrong_mode(struct reiserfs_key *key, __u16 * mode, __u64 real_size,
+int wrong_mode(const struct reiserfs_key *key, __u16 * mode, __u64 real_size,
int symlink)
{
int retval = 0;
@@ -269,7 +270,7 @@ int wrong_mode(struct reiserfs_key *key, __u16 * mode, __u64 real_size,
}
/* key is a key of last file item */
-int wrong_first_direct_byte(struct reiserfs_key *key, int blocksize,
+int wrong_first_direct_byte(const struct reiserfs_key *key, int blocksize,
__u32 * first_direct_byte,
__u32 sd_first_direct_byte, __u32 size)
{
@@ -539,7 +540,7 @@ int rebuild_check_regular_file(struct reiserfs_path *path, void *sd,
return retval;
}
-static int is_rootdir_key(struct reiserfs_key *key)
+static int is_rootdir_key(const struct reiserfs_key *key)
{
if (comp_keys(key, &root_dir_key))
return 0;
@@ -550,7 +551,8 @@ static int is_rootdir_key(struct reiserfs_key *key)
static char *get_next_directory_item(struct reiserfs_key *key, /* on return this will
contain key of next item
in the tree */
- struct reiserfs_key *parent, struct item_head *ih, /*not in tree */
+ const struct reiserfs_key *parent,
+ struct item_head *ih, /*not in tree */
__u32 * pos_in_item)
{
INITIALIZE_REISERFS_PATH(path);
@@ -724,7 +726,8 @@ int fix_obviously_wrong_sd_mode(struct reiserfs_path *path)
object, STAT_DATA_NOT_FOUND if stat data was not found or RELOCATED when
file was relocated because its objectid was already marked as used by
another file */
-int rebuild_semantic_pass(struct reiserfs_key *key, struct reiserfs_key *parent,
+int rebuild_semantic_pass(struct reiserfs_key *key,
+ const struct reiserfs_key *parent,
int dot_dot, struct item_head *new_ih)
{
struct reiserfs_path path;
diff --git a/fsck/ufile.c b/fsck/ufile.c
index 0e482da..f93d0d6 100644
--- a/fsck/ufile.c
+++ b/fsck/ufile.c
@@ -5,13 +5,13 @@
#include "fsck.h"
-static int do_items_have_the_same_type(struct item_head *ih,
- struct reiserfs_key *key)
+static int do_items_have_the_same_type(const struct item_head *ih,
+ const struct reiserfs_key *key)
{
return (get_type(&ih->ih_key) == get_type(key)) ? 1 : 0;
}
-static int are_items_in_the_same_node(struct reiserfs_path *path)
+static int are_items_in_the_same_node(const struct reiserfs_path *path)
{
return (PATH_LAST_POSITION(path) <
B_NR_ITEMS(PATH_PLAST_BUFFER(path)) - 1) ? 1 : 0;
diff --git a/include/reiserfs_fs.h b/include/reiserfs_fs.h
index 2d9eb22..bbf50db 100644
--- a/include/reiserfs_fs.h
+++ b/include/reiserfs_fs.h
@@ -1436,11 +1436,11 @@ struct reiserfs_acl_header {
/* stree.c */
void padd_item (char * item, int total_length, int length);
-int B_IS_IN_TREE(struct buffer_head *);
+int B_IS_IN_TREE(const struct buffer_head *);
const struct reiserfs_key *get_rkey(const struct reiserfs_path *p_s_chk_path,
const reiserfs_filsys_t );
-int bin_search (void * p_v_key, void * p_v_base, int p_n_num, int p_n_width, unsigned int * p_n_pos);
-int search_by_key (reiserfs_filsys_t , struct reiserfs_key *, struct reiserfs_path *, int);
+int bin_search (const void * p_v_key, const void * p_v_base, int p_n_num, int p_n_width, unsigned int * p_n_pos);
+int search_by_key (reiserfs_filsys_t , const struct reiserfs_key *, struct reiserfs_path *, int);
int search_by_entry_key (reiserfs_filsys_t , struct reiserfs_key *, struct reiserfs_path *);
int search_for_position_by_key (reiserfs_filsys_t , struct reiserfs_key *, struct reiserfs_path *);
int search_by_objectid (reiserfs_filsys_t , struct reiserfs_key *, struct reiserfs_path *, int *);
@@ -1507,8 +1507,8 @@ int balance_internal (struct tree_balance * , int, int, struct item_head * ,
void do_balance (struct tree_balance * tb,
struct item_head * ih, const char * body, int flag, int zeros_num);
void reiserfs_invalidate_buffer (struct tree_balance * tb, struct buffer_head * bh);
-int get_left_neighbor_position (struct tree_balance * tb, int h);
-int get_right_neighbor_position (struct tree_balance * tb, int h);
+int get_left_neighbor_position (const struct tree_balance * tb, int h);
+int get_right_neighbor_position (const struct tree_balance * tb, int h);
void replace_key (reiserfs_filsys_t , struct buffer_head *, int, struct buffer_head *, int);
void replace_lkey (struct tree_balance *, int, struct item_head *);
void replace_rkey (struct tree_balance *, int, struct item_head *);
@@ -1535,7 +1535,7 @@ extern unsigned int get_journal_new_start_must (reiserfs_filsys_t fs);
extern unsigned int get_journal_start_must (reiserfs_filsys_t fs);
/*extern hashf_t hashes [];*/
-static inline void buffer_info_init_left(struct tree_balance *tb,
+static inline void buffer_info_init_left(const struct tree_balance *tb,
struct buffer_info *bi, int h)
{
bi->bi_fs = tb->tb_fs;
@@ -1544,7 +1544,7 @@ static inline void buffer_info_init_left(struct tree_balance *tb,
bi->bi_position = get_left_neighbor_position(tb, h);
}
-static inline void buffer_info_init_right(struct tree_balance *tb,
+static inline void buffer_info_init_right(const struct tree_balance *tb,
struct buffer_info *bi, int h)
{
bi->bi_fs = tb->tb_fs;
@@ -1553,7 +1553,7 @@ static inline void buffer_info_init_right(struct tree_balance *tb,
bi->bi_position = get_right_neighbor_position(tb, h);
}
-static inline void buffer_info_init_last(struct tree_balance *tb,
+static inline void buffer_info_init_last(const struct tree_balance *tb,
struct buffer_info *bi)
{
bi->bi_fs = tb->tb_fs;
@@ -1562,7 +1562,7 @@ static inline void buffer_info_init_last(struct tree_balance *tb,
bi->bi_position = PATH_H_B_ITEM_ORDER(tb->tb_path, 0);
}
-static inline void buffer_info_init_tbSh(struct tree_balance *tb,
+static inline void buffer_info_init_tbSh(const struct tree_balance *tb,
struct buffer_info *bi, int h)
{
bi->bi_fs = tb->tb_fs;
@@ -1571,13 +1571,13 @@ static inline void buffer_info_init_tbSh(struct tree_balance *tb,
bi->bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
}
-static inline void buffer_info_init_tbS0(struct tree_balance *tb,
+static inline void buffer_info_init_tbS0(const struct tree_balance *tb,
struct buffer_info *bi)
{
buffer_info_init_tbSh(tb, bi, 0);
}
-static inline void buffer_info_init_bh(struct tree_balance *tb,
+static inline void buffer_info_init_bh(const struct tree_balance *tb,
struct buffer_info *bi,
struct buffer_head *bh)
{
diff --git a/include/reiserfs_lib.h b/include/reiserfs_lib.h
index 003ff8c..f66d46a 100644
--- a/include/reiserfs_lib.h
+++ b/include/reiserfs_lib.h
@@ -113,15 +113,15 @@ void reiserfs_insert_item(reiserfs_filsys_t , struct reiserfs_path *path,
int reiserfs_locate_entry(reiserfs_filsys_t , struct reiserfs_key *dir,
const char *name, struct reiserfs_path *path);
-int reiserfs_find_entry(reiserfs_filsys_t , struct reiserfs_key *dir,
+int reiserfs_find_entry(reiserfs_filsys_t , const struct reiserfs_key *dir,
const char *name, unsigned int *min_gen_counter,
struct reiserfs_key *key);
-int reiserfs_add_entry(reiserfs_filsys_t , struct reiserfs_key *dir,
- const char *name, int name_len, struct reiserfs_key *key,
- __u16 fsck_need);
+int reiserfs_add_entry(reiserfs_filsys_t , const struct reiserfs_key *dir,
+ const char *name, int name_len,
+ const struct reiserfs_key *key, __u16 fsck_need);
-struct reiserfs_key *uget_lkey(struct reiserfs_path *path);
-struct reiserfs_key *uget_rkey(struct reiserfs_path *path);
+struct reiserfs_key *uget_lkey(const struct reiserfs_path *path);
+struct reiserfs_key *uget_rkey(const struct reiserfs_path *path);
int reiserfs_search_by_key_3(reiserfs_filsys_t , const struct reiserfs_key *key,
struct reiserfs_path *path);
int reiserfs_search_by_key_4(reiserfs_filsys_t , const struct reiserfs_key *key,
@@ -131,7 +131,7 @@ int reiserfs_search_by_entry_key(reiserfs_filsys_t,
struct reiserfs_path *path);
int reiserfs_search_by_position(reiserfs_filsys_t , struct reiserfs_key *key,
int version, struct reiserfs_path *path);
-struct reiserfs_key *reiserfs_next_key(struct reiserfs_path *path);
+struct reiserfs_key *reiserfs_next_key(const struct reiserfs_path *path);
void copy_key(void *to, const void *from);
void copy_short_key(void *to, const void *from);
int comp_keys(const void *k1, const void *k2);
@@ -142,7 +142,7 @@ int comp_items(struct item_head *p_s_ih, struct reiserfs_path *p_s_path);
__u32 hash_value(hashf_t func, const char *name, int namelen);
int create_dir_sd(reiserfs_filsys_t fs,
- struct reiserfs_path *path, struct reiserfs_key *key,
+ struct reiserfs_path *path, const struct reiserfs_key *key,
void (*modify_item) (struct item_head *, void *));
void make_sure_root_dir_exists(reiserfs_filsys_t fs,
void (*modyfy_item) (struct item_head *, void *),
@@ -234,7 +234,7 @@ int is_stage_magic_correct(FILE * fp);
reiserfs_bitmap_t *reiserfs_bitmap_load(FILE * fp);
void reiserfs_bitmap_invert(reiserfs_bitmap_t *bm);
-int reiserfs_remove_entry(reiserfs_filsys_t , struct reiserfs_key *key);
+int reiserfs_remove_entry(reiserfs_filsys_t, const struct reiserfs_key *key);
/* node_formats.c */
@@ -260,7 +260,7 @@ int who_is_this(const char *buf, int blocksize);
int leaf_count_ih(const char *buf, int blocksize);
int leaf_free_space_estimate(const char *buf, int blocksize);
int is_a_leaf(const char *buf, int blocksize);
-int leaf_item_number_estimate(struct buffer_head *bh);
+int leaf_item_number_estimate(const struct buffer_head *bh);
char *which_block(int code);
int get_journal_size(reiserfs_filsys_t );
@@ -293,7 +293,7 @@ int uniqueness2type(__u32 uniqueness);
__u32 type2uniqueness(int type);
int get_type(const struct reiserfs_key *key);
char *key_of_what(const struct reiserfs_key *key);
-int type_unknown(struct reiserfs_key *key);
+int type_unknown(const struct reiserfs_key *key);
void set_type(int format, struct reiserfs_key *key, int type);
void set_offset(int format, struct reiserfs_key *key, loff_t offset);
void set_type_and_offset(int format, struct reiserfs_key *key, loff_t offset,
@@ -314,11 +314,11 @@ hashf_t name2func(const char *hash);
int find_hash_in_use(const char *name, int namelen, __u32 deh_offset,
unsigned int code_to_try_first);
-int entry_length(struct item_head *ih, struct reiserfs_de_head *deh,
+int entry_length(const struct item_head *ih, const struct reiserfs_de_head *deh,
int pos_in_item);
-char *name_in_entry(struct reiserfs_de_head *deh, int pos_in_item);
-int name_in_entry_length(struct item_head *ih,
- struct reiserfs_de_head *deh, int pos_in_item);
+char *name_in_entry(const struct reiserfs_de_head *deh, int pos_in_item);
+int name_in_entry_length(const struct item_head *ih,
+ const struct reiserfs_de_head *deh, int pos_in_item);
int name_length(const char *name, int key_format);
/* access to stat data fields */
diff --git a/reiserfscore/do_balan.c b/reiserfscore/do_balan.c
index de39c61..79a5e72 100644
--- a/reiserfscore/do_balan.c
+++ b/reiserfscore/do_balan.c
@@ -1452,7 +1452,7 @@ void reiserfs_invalidate_buffer(struct tree_balance *tb, struct buffer_head *bh)
reiserfs_free_block(tb->tb_fs, bh->b_blocknr);
}
-int get_left_neighbor_position(struct tree_balance *tb, int h)
+int get_left_neighbor_position(const struct tree_balance *tb, int h)
{
int Sh_position = PATH_H_POSITION(tb->tb_path, h + 1);
@@ -1462,7 +1462,7 @@ int get_left_neighbor_position(struct tree_balance *tb, int h)
return Sh_position - 1;
}
-int get_right_neighbor_position(struct tree_balance *tb, int h)
+int get_right_neighbor_position(const struct tree_balance *tb, int h)
{
int Sh_position = PATH_H_POSITION(tb->tb_path, h + 1);
diff --git a/reiserfscore/node_formats.c b/reiserfscore/node_formats.c
index 3e70954..c6eb900 100644
--- a/reiserfscore/node_formats.c
+++ b/reiserfscore/node_formats.c
@@ -82,13 +82,13 @@ int is_a_leaf(const char *buf, int blocksize)
return counted ? HAS_IH_ARRAY : 0;
}
-int leaf_item_number_estimate(struct buffer_head *bh)
+int leaf_item_number_estimate(const struct buffer_head *bh)
{
const struct block_head *blkh;
int nr;
nr = leaf_count_ih(bh->b_data, bh->b_size);
- blkh = (struct block_head *)bh->b_data;
+ blkh = (const struct block_head *)bh->b_data;
return nr >= get_blkh_nr_items(blkh) ? get_blkh_nr_items(blkh) : nr;
}
@@ -938,7 +938,7 @@ char *key_of_what(const struct reiserfs_key *key)
}
}
-int type_unknown(struct reiserfs_key *key)
+int type_unknown(const struct reiserfs_key *key)
{
int type = get_type(key);
@@ -988,7 +988,7 @@ void set_type_and_offset(int format, struct reiserfs_key *key, loff_t offset,
following entry in the calculation. See picture above.*/
// NOTE: this is not name length. This is length of whole entry
-int entry_length(struct item_head *ih, struct reiserfs_de_head *deh,
+int entry_length(const struct item_head *ih, const struct reiserfs_de_head *deh,
int pos_in_item)
{
if (pos_in_item)
@@ -996,13 +996,13 @@ int entry_length(struct item_head *ih, struct reiserfs_de_head *deh,
return (get_ih_item_len(ih) - get_deh_location(deh));
}
-char *name_in_entry(struct reiserfs_de_head *deh, int pos_in_item)
+char *name_in_entry(const struct reiserfs_de_head *deh, int pos_in_item)
{
return ((char *)(deh - pos_in_item) + get_deh_location(deh));
}
-int name_in_entry_length(struct item_head *ih,
- struct reiserfs_de_head *deh, int pos_in_item)
+int name_in_entry_length(const struct item_head *ih,
+ const struct reiserfs_de_head *deh, int pos_in_item)
{
int len, i;
char *name;
diff --git a/reiserfscore/prints.c b/reiserfscore/prints.c
index 4c1625a..1d7f16f 100644
--- a/reiserfscore/prints.c
+++ b/reiserfscore/prints.c
@@ -402,7 +402,7 @@ void reiserfs_print_item(FILE * fp, struct buffer_head *bh,
/* this prints internal nodes (4 keys/items in line) (dc_number,
dc_size)[k_dirid, k_objectid, k_offset, k_uniqueness](dc_number,
dc_size)...*/
-static int print_internal(FILE * fp, struct buffer_head *bh, int first,
+static int print_internal(FILE * fp, const struct buffer_head *bh, int first,
int last)
{
struct reiserfs_key *key;
diff --git a/reiserfscore/reiserfslib.c b/reiserfscore/reiserfslib.c
index 1a84b73..2ee2e49 100644
--- a/reiserfscore/reiserfslib.c
+++ b/reiserfscore/reiserfslib.c
@@ -604,10 +604,10 @@ static int comp_dir_entries(const void *p1, const void *p2)
return 0;
}
-struct reiserfs_key *uget_lkey(struct reiserfs_path *path)
+struct reiserfs_key *uget_lkey(const struct reiserfs_path *path)
{
int pos, offset = path->path_length;
- struct buffer_head *bh;
+ const struct buffer_head *bh;
if (offset < FIRST_PATH_ELEMENT_OFFSET)
die("uget_lkey: illegal offset in the path (%d)", offset);
@@ -642,7 +642,7 @@ struct reiserfs_key *uget_lkey(struct reiserfs_path *path)
return NULL;
}
-struct reiserfs_key *uget_rkey(struct reiserfs_path *path)
+struct reiserfs_key *uget_rkey(const struct reiserfs_path *path)
{
int pos, offset = path->path_length;
struct buffer_head *bh;
@@ -679,7 +679,7 @@ struct reiserfs_key *uget_rkey(struct reiserfs_path *path)
return NULL;
}
-struct reiserfs_key *reiserfs_next_key(struct reiserfs_path *path)
+struct reiserfs_key *reiserfs_next_key(const struct reiserfs_path *path)
{
if (get_item_pos(path) < B_NR_ITEMS(get_bh(path)) - 1)
return leaf_key(get_bh(path), get_item_pos(path) + 1);
@@ -803,7 +803,7 @@ void init_tb_struct(struct tree_balance *tb, reiserfs_filsys_t fs,
tb->insert_size[0] = size;
}
-int reiserfs_remove_entry(reiserfs_filsys_t fs, struct reiserfs_key *key)
+int reiserfs_remove_entry(reiserfs_filsys_t fs, const struct reiserfs_key *key)
{
struct reiserfs_path path;
struct tree_balance tb;
@@ -943,7 +943,7 @@ int reiserfs_locate_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
found. Stores key found in the entry in 'key'. Returns minimal not used
generation counter in 'min_gen_counter'. dies if found object is not a
directory. */
-int reiserfs_find_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
+int reiserfs_find_entry(reiserfs_filsys_t fs, const struct reiserfs_key *dir,
const char *name, unsigned int *min_gen_counter,
struct reiserfs_key *key)
{
@@ -1040,8 +1040,8 @@ int reiserfs_find_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
}
/* compose directory entry: dir entry head and name itself */
-static char *make_entry(char *entry, const char *name, struct reiserfs_key *key,
- __u32 offset)
+static char *make_entry(char *entry, const char *name,
+ const struct reiserfs_key *key, __u32 offset)
{
struct reiserfs_de_head *deh;
__u16 state;
@@ -1067,9 +1067,9 @@ static char *make_entry(char *entry, const char *name, struct reiserfs_key *key,
/* add new name into a directory. If it exists in a directory - do
nothing */
-int reiserfs_add_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
+int reiserfs_add_entry(reiserfs_filsys_t fs, const struct reiserfs_key *dir,
const char *name, int name_len,
- struct reiserfs_key *key, __u16 fsck_need)
+ const struct reiserfs_key *key, __u16 fsck_need)
{
struct item_head entry_ih = { {0,}, };
char *entry;
@@ -1151,7 +1151,7 @@ void copy_short_key(void *to, const void *from)
/* inserts new or old stat data of a directory (unreachable, nlinks == 0) */
int create_dir_sd(reiserfs_filsys_t fs,
- struct reiserfs_path *path, struct reiserfs_key *key,
+ struct reiserfs_path *path, const struct reiserfs_key *key,
void (*modify_item) (struct item_head *, void *))
{
struct item_head ih;
diff --git a/reiserfscore/stree.c b/reiserfscore/stree.c
index ea928c4..b82df76 100644
--- a/reiserfscore/stree.c
+++ b/reiserfscore/stree.c
@@ -38,7 +38,7 @@
#include "includes.h"
/* Does the buffer contain a disk block which is in the tree. */
-inline int B_IS_IN_TREE(struct buffer_head *p_s_bh)
+inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
{
return (get_blkh_level(B_BLK_HEAD(p_s_bh)) != FREE_LEVEL);
}
@@ -133,8 +133,8 @@ int comp_keys(const void *p1, const void *p2)
there are no possible items, and we have not found it. With each examination we
cut the number of possible items it could be by one more than half rounded down,
or we find it. */
-int bin_search(void *p_v_key, /* Key to search for. */
- void *p_v_base, /* First item in the array. */
+int bin_search(const void *p_v_key, /* Key to search for. */
+ const void *p_v_base, /* First item in the array. */
int p_n_num, /* Number of items in the array. */
int p_n_width, /* Item size in the array.
searched. Lest the reader be
@@ -318,7 +318,7 @@ void pathrelse(struct reiserfs_path *p_s_search_path)
key. search_by_key returns a path that must be checked for the
correctness of the top of the path but need not be checked for the
correctness of the bottom of the path */
-int search_by_key(reiserfs_filsys_t fs, struct reiserfs_key *p_s_key, /* Key to search */
+int search_by_key(reiserfs_filsys_t fs, const struct reiserfs_key *p_s_key, /* Key to search */
struct reiserfs_path *p_s_search_path, /* This structure was
allocated and
initialized by the