reiserfscore: constify strings

There are many calls in which strings are passed as "char *" yet aren't
modified. This patch marks them const so callers can depend on it.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
This commit is contained in:
Jeff Mahoney committed 2014-03-13 17:42:57 -04:00
1 parent 6bdb171b9e
commit 9b52a79ba2
9 files changed
+86 -83

No files matched your search

+8 -8
View File
@@ -35,13 +35,13 @@
#define INVAL_PTR (void *)-1 #define INVAL_PTR (void *)-1
void check_memory_msg(void); void check_memory_msg(void);
void die(char *fmt, ...) __attribute__ ((format(printf, 1, 2))); void die(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
void *getmem(int size); void *getmem(int size);
void *mem_alloc(int size); void *mem_alloc(int size);
void freemem(void *p); void freemem(void *p);
void checkmem(char *p, int size); void checkmem(const char *p, int size);
void *expandmem(void *p, int size, int by); void *expandmem(void *p, int size, int by);
unsigned int get_mem_size(char *p); unsigned int get_mem_size(const char *p);
void check_and_free_mem(void); void check_and_free_mem(void);
char *kdevname(int dev); char *kdevname(int dev);
@@ -57,8 +57,8 @@ typedef struct mount_hint {
__u32 flags; /* Mount flags. */ __u32 flags; /* Mount flags. */
} mount_hint_t; } mount_hint_t;
struct mntent *misc_mntent(char *device); struct mntent *misc_mntent(const char *device);
int misc_device_mounted(char *device); int misc_device_mounted(const char *device);
typedef struct dma_info { typedef struct dma_info {
int fd; int fd;
@@ -73,7 +73,7 @@ int get_dma_info(dma_info_t *dma_info);
void clean_after_dma_check(int fd, dma_info_t *dma_info); void clean_after_dma_check(int fd, dma_info_t *dma_info);
int valid_offset(int fd, loff_t offset); int valid_offset(int fd, loff_t offset);
unsigned long count_blocks(char *filename, int blocksize); unsigned long count_blocks(const char *filename, int blocksize);
void print_how_far(FILE * fp, unsigned long *passed, unsigned long total, void print_how_far(FILE * fp, unsigned long *passed, unsigned long total,
unsigned int inc, int quiet); unsigned int inc, int quiet);
@@ -81,7 +81,7 @@ void print_how_fast(unsigned long total, unsigned long passed, int cursor_pos,
int reset_time); int reset_time);
__u32 get_random(void); __u32 get_random(void);
int user_confirmed(FILE * fp, char *q, char *yes); int user_confirmed(FILE * fp, const char *q, const char *yes);
/* Only le bitops operations are used. */ /* Only le bitops operations are used. */
static inline int misc_set_bit(unsigned long long nr, void *addr) static inline int misc_set_bit(unsigned long long nr, void *addr)
@@ -223,7 +223,7 @@ static inline unsigned long long misc_find_next_set_bit(const void *vaddr,
} }
#define STAT_FIELD_H(Field, Type) \ #define STAT_FIELD_H(Field, Type) \
inline Type misc_device_##Field(char *device); inline Type misc_device_##Field(const char *device);
STAT_FIELD_H(mode, mode_t); STAT_FIELD_H(mode, mode_t);
STAT_FIELD_H(rdev, dev_t); STAT_FIELD_H(rdev, dev_t);
+1 -1
View File
@@ -1468,7 +1468,7 @@ void init_path (struct reiserfs_path *);
data items and indirect items */ data items and indirect items */
#define PRINT_DIRECT_ITEMS 0x8 /* print contents of direct items */ #define PRINT_DIRECT_ITEMS 0x8 /* print contents of direct items */
void print_tb (int mode, int item_pos, int pos_in_item, struct tree_balance * tb, char * mes); void print_tb (int mode, int item_pos, int pos_in_item, struct tree_balance * tb, const char * mes);
void print_bmap (FILE * fp, reiserfs_filsys_t fs, int silent); void print_bmap (FILE * fp, reiserfs_filsys_t fs, int silent);
+20 -20
View File
@@ -77,7 +77,7 @@ void init_tb_struct(struct tree_balance *tb, reiserfs_filsys_t ,
reiserfs_filsys_t reiserfs_open(const char *filename, int flags, int *error, reiserfs_filsys_t reiserfs_open(const char *filename, int flags, int *error,
void *vp, int skip_check); void *vp, int skip_check);
reiserfs_filsys_t reiserfs_create(char *filename, int version, reiserfs_filsys_t reiserfs_create(const char *filename, int version,
unsigned long block_count, int block_size, unsigned long block_count, int block_size,
int default_journal, int new_format); int default_journal, int new_format);
void reiserfs_flush(reiserfs_filsys_t ); void reiserfs_flush(reiserfs_filsys_t );
@@ -112,12 +112,12 @@ void reiserfs_insert_item(reiserfs_filsys_t , struct reiserfs_path *path,
struct item_head *ih, const void *body); struct item_head *ih, const void *body);
int reiserfs_locate_entry(reiserfs_filsys_t , struct reiserfs_key *dir, int reiserfs_locate_entry(reiserfs_filsys_t , struct reiserfs_key *dir,
char *name, struct reiserfs_path *path); 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 , struct reiserfs_key *dir,
char *name, unsigned int *min_gen_counter, const char *name, unsigned int *min_gen_counter,
struct reiserfs_key *key); struct reiserfs_key *key);
int reiserfs_add_entry(reiserfs_filsys_t , struct reiserfs_key *dir, int reiserfs_add_entry(reiserfs_filsys_t , struct reiserfs_key *dir,
char *name, int name_len, struct reiserfs_key *key, const char *name, int name_len, struct reiserfs_key *key,
__u16 fsck_need); __u16 fsck_need);
struct reiserfs_key *uget_lkey(struct reiserfs_path *path); struct reiserfs_key *uget_lkey(struct reiserfs_path *path);
@@ -139,7 +139,7 @@ int comp_keys_3(const void *k1, const void *k2);
int comp_short_keys(const void *p_s_key1, const void *p_s_key2); int comp_short_keys(const void *p_s_key1, const void *p_s_key2);
int comp_items(struct item_head *p_s_ih, struct reiserfs_path *p_s_path); int comp_items(struct item_head *p_s_ih, struct reiserfs_path *p_s_path);
__u32 hash_value(hashf_t func, char *name, int namelen); __u32 hash_value(hashf_t func, const char *name, int namelen);
int create_dir_sd(reiserfs_filsys_t fs, int create_dir_sd(reiserfs_filsys_t fs,
struct reiserfs_path *path, struct reiserfs_key *key, struct reiserfs_path *path, struct reiserfs_key *key,
@@ -154,7 +154,7 @@ typedef void (*badblock_func_t) (reiserfs_filsys_t fs,
void mark_badblock(reiserfs_filsys_t fs, struct reiserfs_path *badblock_path, void mark_badblock(reiserfs_filsys_t fs, struct reiserfs_path *badblock_path,
void *data); void *data);
int create_badblock_bitmap(reiserfs_filsys_t fs, char *badblocks_file); int create_badblock_bitmap(reiserfs_filsys_t fs, const char *badblocks_file);
void add_badblock_list(reiserfs_filsys_t fs, int no_badblock_in_tree_yet); void add_badblock_list(reiserfs_filsys_t fs, int no_badblock_in_tree_yet);
void badblock_list(reiserfs_filsys_t fs, badblock_func_t action, void *data); void badblock_list(reiserfs_filsys_t fs, badblock_func_t action, void *data);
#define reiserfs_fs_bmap_nr(fs) reiserfs_bmap_nr(get_sb_block_count(fs->fs_ondisk_sb), fs->fs_blocksize) #define reiserfs_fs_bmap_nr(fs) reiserfs_bmap_nr(get_sb_block_count(fs->fs_ondisk_sb), fs->fs_blocksize)
@@ -221,7 +221,7 @@ void reiserfs_bitmap_fill(reiserfs_bitmap_t *bm);
unsigned int reiserfs_bitmap_ones(reiserfs_bitmap_t *bm); unsigned int reiserfs_bitmap_ones(reiserfs_bitmap_t *bm);
unsigned int reiserfs_bitmap_zeros(reiserfs_bitmap_t *bm); unsigned int reiserfs_bitmap_zeros(reiserfs_bitmap_t *bm);
FILE *open_file(char *filename, char *option); FILE *open_file(const char *filename, char *option);
void close_file(FILE * fp); void close_file(FILE * fp);
void reiserfs_bitmap_save(FILE * fp, reiserfs_bitmap_t *bm); void reiserfs_bitmap_save(FILE * fp, reiserfs_bitmap_t *bm);
@@ -255,11 +255,11 @@ int get_reiserfs_format(struct reiserfs_super_block *sb);
int reiserfs_super_block_size(struct reiserfs_super_block *rs); int reiserfs_super_block_size(struct reiserfs_super_block *rs);
/*int magic_2_version (struct reiserfs_super_block * rs);*/ /*int magic_2_version (struct reiserfs_super_block * rs);*/
int is_prejournaled_reiserfs(struct reiserfs_super_block *rs); int is_prejournaled_reiserfs(struct reiserfs_super_block *rs);
int who_is_this(char *buf, int blocksize); int who_is_this(const char *buf, int blocksize);
int leaf_count_ih(char *buf, int blocksize); int leaf_count_ih(const char *buf, int blocksize);
int leaf_free_space_estimate(char *buf, int blocksize); int leaf_free_space_estimate(const char *buf, int blocksize);
int is_a_leaf(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(struct buffer_head *bh);
char *which_block(int code); char *which_block(int code);
@@ -270,7 +270,7 @@ int block_of_bitmap(reiserfs_filsys_t , unsigned long block);
int block_of_journal(reiserfs_filsys_t , unsigned long block); int block_of_journal(reiserfs_filsys_t , unsigned long block);
int is_tree_node(struct buffer_head *bh, int level); int is_tree_node(struct buffer_head *bh, int level);
int is_properly_hashed(reiserfs_filsys_t , int is_properly_hashed(reiserfs_filsys_t ,
char *name, int namelen, __u32 offset); const char *name, int namelen, __u32 offset);
int dir_entry_bad_location(struct reiserfs_de_head *deh, int dir_entry_bad_location(struct reiserfs_de_head *deh,
struct item_head *ih, int first); struct item_head *ih, int first);
void make_dir_stat_data(int blocksize, int key_format, void make_dir_stat_data(int blocksize, int key_format,
@@ -300,7 +300,7 @@ void set_type_and_offset(int format, struct reiserfs_key *key, loff_t offset,
int type); int type);
typedef int (*check_unfm_func_t) (reiserfs_filsys_t , __u32); typedef int (*check_unfm_func_t) (reiserfs_filsys_t , __u32);
int is_it_bad_item(reiserfs_filsys_t , struct item_head *, char *, int is_it_bad_item(reiserfs_filsys_t , struct item_head *, const char *,
check_unfm_func_t, int bad_dir); check_unfm_func_t, int bad_dir);
#define hash_func_is_unknown(fs) ((fs)->fs_hash_function == NULL) #define hash_func_is_unknown(fs) ((fs)->fs_hash_function == NULL)
@@ -310,8 +310,8 @@ int known_hashes(void);
char *code2name(unsigned int code); char *code2name(unsigned int code);
int func2code(hashf_t func); int func2code(hashf_t func);
hashf_t code2func(unsigned int code); hashf_t code2func(unsigned int code);
hashf_t name2func(char *hash); hashf_t name2func(const char *hash);
int find_hash_in_use(char *name, int namelen, __u32 deh_offset, int find_hash_in_use(const char *name, int namelen, __u32 deh_offset,
unsigned int code_to_try_first); unsigned int code_to_try_first);
int entry_length(struct item_head *ih, struct reiserfs_de_head *deh, int entry_length(struct item_head *ih, struct reiserfs_de_head *deh,
@@ -319,7 +319,7 @@ int entry_length(struct item_head *ih, struct reiserfs_de_head *deh,
char *name_in_entry(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, int name_in_entry_length(struct item_head *ih,
struct reiserfs_de_head *deh, int pos_in_item); struct reiserfs_de_head *deh, int pos_in_item);
int name_length(char *name, int key_format); int name_length(const char *name, int key_format);
/* access to stat data fields */ /* access to stat data fields */
void get_set_sd_field(int field, struct item_head *ih, void *sd, void get_set_sd_field(int field, struct item_head *ih, void *sd,
@@ -371,9 +371,9 @@ typedef void (*action_on_block_t) (reiserfs_filsys_t , reiserfs_trans_t *,
void for_each_block(reiserfs_filsys_t fs, reiserfs_trans_t *trans, void for_each_block(reiserfs_filsys_t fs, reiserfs_trans_t *trans,
action_on_block_t action); action_on_block_t action);
int reiserfs_open_journal(reiserfs_filsys_t , char *, int flags); int reiserfs_open_journal(reiserfs_filsys_t , const char *, int flags);
int reiserfs_journal_params_check(reiserfs_filsys_t fs); int reiserfs_journal_params_check(reiserfs_filsys_t fs);
int reiserfs_create_journal(reiserfs_filsys_t fs, char *j_filename, int reiserfs_create_journal(reiserfs_filsys_t fs, const char *j_filename,
unsigned long offset, unsigned long len, unsigned long offset, unsigned long len,
int transaction_max_size, int force); int transaction_max_size, int force);
int reiserfs_journal_opened(reiserfs_filsys_t ); int reiserfs_journal_opened(reiserfs_filsys_t );
@@ -390,7 +390,7 @@ __u32 advise_journal_max_trans_len(__u32 desired, __u32 journal_size,
/* prints.c */ /* prints.c */
void print_indirect_item(FILE * fp, struct buffer_head *bh, int item_num); void print_indirect_item(FILE * fp, struct buffer_head *bh, int item_num);
void print_block(FILE * fp, reiserfs_filsys_t , struct buffer_head *bh, ...); //int print_mode, int first, int last); void print_block(FILE * fp, reiserfs_filsys_t , struct buffer_head *bh, ...); //int print_mode, int first, int last);
int print_super_block(FILE * fp, reiserfs_filsys_t , char *file_name, int print_super_block(FILE * fp, reiserfs_filsys_t , const char *file_name,
struct buffer_head *bh, int short_print); struct buffer_head *bh, int short_print);
void print_journal(reiserfs_filsys_t ); void print_journal(reiserfs_filsys_t );
void print_journal_header(reiserfs_filsys_t fs); void print_journal_header(reiserfs_filsys_t fs);
@@ -402,7 +402,7 @@ void print_filesystem_state(FILE * fp, reiserfs_filsys_t fs);
void print_one_transaction(reiserfs_filsys_t fs, reiserfs_trans_t *trans); void print_one_transaction(reiserfs_filsys_t fs, reiserfs_trans_t *trans);
void print_journal_params(FILE * fp, struct journal_params *jp); void print_journal_params(FILE * fp, struct journal_params *jp);
char *get_reiserfs_version(__u16 version); char *get_reiserfs_version(__u16 version);
int can_we_format_it(char *device_name, int force); int can_we_format_it(const char *device_name, int force);
#define reiserfs_panic(fmt, list...) \ #define reiserfs_panic(fmt, list...) \
{\ {\
+17 -16
View File
@@ -28,7 +28,7 @@
/* End Debian mods */ /* End Debian mods */
#define STAT_FIELD(Field, Type) \ #define STAT_FIELD(Field, Type) \
inline Type misc_device_##Field(char *device) { \ inline Type misc_device_##Field(const char *device) { \
struct stat st; \ struct stat st; \
\ \
if (stat(device, &st) == 0) \ if (stat(device, &st) == 0) \
@@ -43,7 +43,7 @@ STAT_FIELD(rdev, dev_t);
STAT_FIELD(size, off_t); STAT_FIELD(size, off_t);
STAT_FIELD(blocks, blkcnt_t); STAT_FIELD(blocks, blkcnt_t);
void die(char *fmt, ...) void die(const char *fmt, ...)
{ {
static char buf[1024]; static char buf[1024];
va_list args; va_list args;
@@ -61,18 +61,18 @@ void die(char *fmt, ...)
#define MEM_FREED "__free_" #define MEM_FREED "__free_"
#define CONTROL_SIZE (strlen (MEM_BEGIN) + 1 + sizeof (int) + strlen (MEM_END) + 1) #define CONTROL_SIZE (strlen (MEM_BEGIN) + 1 + sizeof (int) + strlen (MEM_END) + 1)
unsigned int get_mem_size(char *p) unsigned int get_mem_size(const char *p)
{ {
char *begin; const char *begin;
begin = p - strlen(MEM_BEGIN) - 1 - sizeof(int); begin = p - strlen(MEM_BEGIN) - 1 - sizeof(int);
return *(int *)(begin + strlen(MEM_BEGIN) + 1); return *(int *)(begin + strlen(MEM_BEGIN) + 1);
} }
void checkmem(char *p, int size) void checkmem(const char *p, int size)
{ {
char *begin; const char *begin;
char *end; const char *end;
begin = p - strlen(MEM_BEGIN) - 1 - sizeof(int); begin = p - strlen(MEM_BEGIN) - 1 - sizeof(int);
if (strcmp(begin, MEM_BEGIN)) if (strcmp(begin, MEM_BEGIN))
@@ -170,14 +170,15 @@ void freemem(void *vp)
free(p); free(p);
} }
typedef int (*func_t) (char *); typedef int (*func_t) (const char *);
/* Lookup the @file in the @mntfile. @file is mntent.mnt_fsname if @fsname /* Lookup the @file in the @mntfile. @file is mntent.mnt_fsname if @fsname
is set; mntent.mnt_dir otherwise. Return the mnt entry from the @mntfile. is set; mntent.mnt_dir otherwise. Return the mnt entry from the @mntfile.
Warning: if the root fs is mounted RO, the content of /etc/mtab may be Warning: if the root fs is mounted RO, the content of /etc/mtab may be
not correct. */ not correct. */
static struct mntent *misc_mntent_lookup(char *mntfile, char *file, int path) static struct mntent *misc_mntent_lookup(const char *mntfile, const char *file,
int path)
{ {
struct mntent *mnt; struct mntent *mnt;
int name_match = 0; int name_match = 0;
@@ -249,7 +250,7 @@ static struct mntent *misc_mntent_lookup(char *mntfile, char *file, int path)
return mnt; return mnt;
} }
static int misc_root_mounted(char *device) static int misc_root_mounted(const char *device)
{ {
struct stat rootst, devst; struct stat rootst, devst;
@@ -267,7 +268,7 @@ static int misc_root_mounted(char *device)
return 1; return 1;
} }
static int misc_file_ro(char *file) static int misc_file_ro(const char *file)
{ {
if (utime(file, NULL) == -1) { if (utime(file, NULL) == -1) {
if (errno == EROFS) if (errno == EROFS)
@@ -277,7 +278,7 @@ static int misc_file_ro(char *file)
return 0; return 0;
} }
struct mntent *misc_mntent(char *device) struct mntent *misc_mntent(const char *device)
{ {
int proc = 0, path = 0, root = 0; int proc = 0, path = 0, root = 0;
@@ -340,7 +341,7 @@ struct mntent *misc_mntent(char *device)
return (!proc && !path) ? INVAL_PTR : NULL; return (!proc && !path) ? INVAL_PTR : NULL;
} }
int misc_device_mounted(char *device) int misc_device_mounted(const char *device)
{ {
struct mntent *mnt; struct mntent *mnt;
@@ -404,7 +405,7 @@ void print_how_fast(unsigned long passed, unsigned long total,
fflush(stderr); fflush(stderr);
} }
static char *strs[] = static const char *strs[] =
{ "0%", ".", ".", ".", ".", "20%", ".", ".", ".", ".", "40%", ".", ".", ".", { "0%", ".", ".", ".", ".", "20%", ".", ".", ".", ".", "40%", ".", ".", ".",
".", "60%", ".", ".", ".", ".", "80%", ".", ".", ".", ".", "100%" }; ".", "60%", ".", ".", ".", ".", "80%", ".", ".", ".", ".", "100%" };
@@ -488,7 +489,7 @@ int valid_offset(int fd, loff_t offset)
/* calculates number of blocks in a file. Returns 0 for "sparse" /* calculates number of blocks in a file. Returns 0 for "sparse"
regular files and files other than regular files and block devices */ regular files and files other than regular files and block devices */
unsigned long count_blocks(char *filename, int blocksize) unsigned long count_blocks(const char *filename, int blocksize)
{ {
loff_t high, low; loff_t high, low;
unsigned long sz; unsigned long sz;
@@ -814,7 +815,7 @@ void clean_after_dma_check(int fd, dma_info_t *dma_info)
close(dma_info->fd); close(dma_info->fd);
} }
int user_confirmed(FILE * fp, char *q, char *yes) int user_confirmed(FILE * fp, const char *q, const char *yes)
{ {
char *answer = NULL; char *answer = NULL;
size_t n = 0; size_t n = 0;
+1 -1
View File
@@ -414,7 +414,7 @@ void reiserfs_bitmap_fill(reiserfs_bitmap_t *bm)
#define BITMAP_START_MAGIC 374031 #define BITMAP_START_MAGIC 374031
#define BITMAP_END_MAGIC 7786472 #define BITMAP_END_MAGIC 7786472
FILE *open_file(char *filename, char *option) FILE *open_file(const char *filename, char *const option)
{ {
FILE *fp = fopen(filename, option); FILE *fp = fopen(filename, option);
if (!fp) { if (!fp) {
+3 -2
View File
@@ -471,7 +471,8 @@ int reiserfs_journal_params_check(reiserfs_filsys_t fs)
/* read journal header and make sure that it matches with the filesystem /* read journal header and make sure that it matches with the filesystem
opened */ opened */
int reiserfs_open_journal(reiserfs_filsys_t fs, char *j_filename, int flags) int reiserfs_open_journal(reiserfs_filsys_t fs, const char *j_filename,
int flags)
{ {
struct reiserfs_super_block *sb; struct reiserfs_super_block *sb;
__u64 count; __u64 count;
@@ -551,7 +552,7 @@ int reiserfs_open_journal(reiserfs_filsys_t fs, char *j_filename, int flags)
/* initialize super block's journal related fields and journal header fields. /* initialize super block's journal related fields and journal header fields.
* If len is 0 - make journal of default size */ * If len is 0 - make journal of default size */
int reiserfs_create_journal(reiserfs_filsys_t fs, char *j_device, /* journal device name */ int reiserfs_create_journal(reiserfs_filsys_t fs, const char *j_device, /* journal device name */
unsigned long offset, /* journal offset on the j_device */ unsigned long offset, /* journal offset on the j_device */
unsigned long len, /* including journal header */ unsigned long len, /* including journal header */
int transaction_max_size, int force) int transaction_max_size, int force)
+21 -21
View File
@@ -5,9 +5,9 @@
#include "includes.h" #include "includes.h"
int leaf_count_ih(char *buf, int blocksize) int leaf_count_ih(const char *buf, int blocksize)
{ {
struct item_head *ih; const struct item_head *ih;
int prev_location; int prev_location;
int nr; int nr;
@@ -30,10 +30,10 @@ int leaf_count_ih(char *buf, int blocksize)
return nr; return nr;
} }
int leaf_free_space_estimate(char *buf, int blocksize) int leaf_free_space_estimate(const char *buf, int blocksize)
{ {
struct block_head *blkh; const struct block_head *blkh;
struct item_head *ih; const struct item_head *ih;
int nr; int nr;
blkh = (struct block_head *)buf; blkh = (struct block_head *)buf;
@@ -44,7 +44,7 @@ int leaf_free_space_estimate(char *buf, int blocksize)
IH_SIZE * nr; IH_SIZE * nr;
} }
static int leaf_blkh_correct(char *buf, int blocksize) static int leaf_blkh_correct(const char *buf, int blocksize)
{ {
struct block_head *blkh; struct block_head *blkh;
unsigned int nr; unsigned int nr;
@@ -62,9 +62,9 @@ static int leaf_blkh_correct(char *buf, int blocksize)
blocksize) == get_blkh_free_space(blkh); blocksize) == get_blkh_free_space(blkh);
} }
int is_a_leaf(char *buf, int blocksize) int is_a_leaf(const char *buf, int blocksize)
{ {
struct block_head *blkh; const struct block_head *blkh;
int counted; int counted;
blkh = (struct block_head *)buf; blkh = (struct block_head *)buf;
@@ -84,7 +84,7 @@ int is_a_leaf(char *buf, int blocksize)
int leaf_item_number_estimate(struct buffer_head *bh) int leaf_item_number_estimate(struct buffer_head *bh)
{ {
struct block_head *blkh; const struct block_head *blkh;
int nr; int nr;
nr = leaf_count_ih(bh->b_data, bh->b_size); nr = leaf_count_ih(bh->b_data, bh->b_size);
@@ -174,9 +174,9 @@ static int does_node_have_ih_array(char *buf, int blocksize)
#endif #endif
/* returns 1 if buf looks like an internal node, 0 otherwise */ /* returns 1 if buf looks like an internal node, 0 otherwise */
static int is_correct_internal(char *buf, int blocksize) static int is_correct_internal(const char *buf, int blocksize)
{ {
struct block_head *blkh; const struct block_head *blkh;
unsigned int nr; unsigned int nr;
int used_space; int used_space;
@@ -210,9 +210,9 @@ int is_tree_node(struct buffer_head *bh, int level)
return is_correct_internal(bh->b_data, bh->b_size); return is_correct_internal(bh->b_data, bh->b_size);
} }
static int is_desc_block(char *buf, unsigned long buf_size) static int is_desc_block(const char *buf, unsigned long buf_size)
{ {
struct reiserfs_journal_desc *desc = const struct reiserfs_journal_desc *desc =
(struct reiserfs_journal_desc *)buf; (struct reiserfs_journal_desc *)buf;
if (!memcmp(buf + buf_size - 12, JOURNAL_DESC_MAGIC, 8) if (!memcmp(buf + buf_size - 12, JOURNAL_DESC_MAGIC, 8)
&& le32_to_cpu(desc->j2_len) > 0) && le32_to_cpu(desc->j2_len) > 0)
@@ -299,7 +299,7 @@ int does_look_like_super_block(struct reiserfs_super_block *sb)
/* returns code of reiserfs metadata block (leaf, internal, super /* returns code of reiserfs metadata block (leaf, internal, super
block, journal descriptor), unformatted */ block, journal descriptor), unformatted */
int who_is_this(char *buf, int blocksize) int who_is_this(const char *buf, int blocksize)
{ {
int res; int res;
@@ -492,7 +492,7 @@ static int does_ih_look_correct(struct item_head *ih)
/* check item length, ih_free_space for pure 3.5 format, unformatted node /* check item length, ih_free_space for pure 3.5 format, unformatted node
pointers */ pointers */
static int is_bad_indirect(reiserfs_filsys_t fs, struct item_head *ih, static int is_bad_indirect(reiserfs_filsys_t fs, struct item_head *ih,
char *item, check_unfm_func_t check_unfm_func) const char *item, check_unfm_func_t check_unfm_func)
{ {
unsigned int i; unsigned int i;
__le32 *ind = (__le32 *) item; __le32 *ind = (__le32 *) item;
@@ -537,7 +537,7 @@ int known_hashes(void)
/* this also sets hash function */ /* this also sets hash function */
int is_properly_hashed(reiserfs_filsys_t fs, int is_properly_hashed(reiserfs_filsys_t fs,
char *name, int namelen, __u32 offset) const char *name, int namelen, __u32 offset)
{ {
unsigned int i; unsigned int i;
@@ -583,7 +583,7 @@ int is_properly_hashed(reiserfs_filsys_t fs,
return 0; return 0;
} }
int find_hash_in_use(char *name, int namelen, __u32 offset, int find_hash_in_use(const char *name, int namelen, __u32 offset,
unsigned int code_to_try_first) unsigned int code_to_try_first)
{ {
unsigned int i; unsigned int i;
@@ -638,7 +638,7 @@ hashf_t code2func(unsigned int code)
return hashes[code].func; return hashes[code].func;
} }
hashf_t name2func(char *hash) hashf_t name2func(const char *hash)
{ {
unsigned int i; unsigned int i;
@@ -666,7 +666,7 @@ int dir_entry_bad_location(struct reiserfs_de_head *deh, struct item_head *ih,
/* the only corruption which is not considered fatal - is hash mismatching. If /* the only corruption which is not considered fatal - is hash mismatching. If
bad_dir is set - directory item having such names is considered bad */ bad_dir is set - directory item having such names is considered bad */
static int is_bad_directory(reiserfs_filsys_t fs, struct item_head *ih, static int is_bad_directory(reiserfs_filsys_t fs, struct item_head *ih,
char *item, int bad_dir) const char *item, int bad_dir)
{ {
int i; int i;
int namelen; int namelen;
@@ -702,7 +702,7 @@ static int is_bad_directory(reiserfs_filsys_t fs, struct item_head *ih,
} }
/* used by debugreisrefs -p only yet */ /* used by debugreisrefs -p only yet */
int is_it_bad_item(reiserfs_filsys_t fs, struct item_head *ih, char *item, int is_it_bad_item(reiserfs_filsys_t fs, struct item_head *ih, const char *item,
check_unfm_func_t check_unfm, int bad_dir) check_unfm_func_t check_unfm, int bad_dir)
{ {
int retval; int retval;
@@ -1018,7 +1018,7 @@ int name_in_entry_length(struct item_head *ih,
return i; return i;
} }
int name_length(char *name, int key_format) int name_length(const char *name, int key_format)
{ {
if (key_format == KEY_FORMAT_2) if (key_format == KEY_FORMAT_2)
return ROUND_UP(strlen(name)); return ROUND_UP(strlen(name));
+6 -5
View File
@@ -545,7 +545,7 @@ void print_journal_params(FILE * fp, struct journal_params *jp)
} }
/* return 1 if this is not super block */ /* return 1 if this is not super block */
int print_super_block(FILE * fp, reiserfs_filsys_t fs, char *file_name, int print_super_block(FILE * fp, reiserfs_filsys_t fs, const char *file_name,
struct buffer_head *bh, int short_print) struct buffer_head *bh, int short_print)
{ {
struct reiserfs_super_block *sb = struct reiserfs_super_block *sb =
@@ -696,7 +696,7 @@ void print_block(FILE * fp, reiserfs_filsys_t fs, struct buffer_head *bh, ...) /
{ {
va_list args; va_list args;
int mode, first, last; int mode, first, last;
char *file_name; const char *file_name;
va_start(args, bh); va_start(args, bh);
@@ -719,7 +719,7 @@ void print_block(FILE * fp, reiserfs_filsys_t fs, struct buffer_head *bh, ...) /
} }
void print_tb(int mode, int item_pos, int pos_in_item, struct tree_balance *tb, void print_tb(int mode, int item_pos, int pos_in_item, struct tree_balance *tb,
char *mes) const char *mes)
{ {
unsigned int h = 0; unsigned int h = 0;
struct buffer_head *tbSh, *tbFh; struct buffer_head *tbSh, *tbFh;
@@ -806,8 +806,9 @@ void print_tb(int mode, int item_pos, int pos_in_item, struct tree_balance *tb,
("********************** END OF PRINT_TB *******************\n\n"); ("********************** END OF PRINT_TB *******************\n\n");
} }
static void print_bmap_block(FILE * fp, int i, unsigned long block, char *map, static void print_bmap_block(FILE * fp, int i, unsigned long block,
int blocks, int silent, int blocksize) const char *map, int blocks, int silent,
int blocksize)
{ {
int j, k; int j, k;
int bits = blocksize * 8; int bits = blocksize * 8;
+9 -9
View File
@@ -185,7 +185,7 @@ found:
/* creates buffer for super block and fills it up with fields which are /* creates buffer for super block and fills it up with fields which are
constant for given size and version of a filesystem */ constant for given size and version of a filesystem */
reiserfs_filsys_t reiserfs_create(char *filename, reiserfs_filsys_t reiserfs_create(const char *filename,
int version, int version,
unsigned long block_count, unsigned long block_count,
int block_size, int block_size,
@@ -866,7 +866,7 @@ void reiserfs_insert_item(reiserfs_filsys_t fs, struct reiserfs_path *path,
/*===========================================================================*/ /*===========================================================================*/
__u32 hash_value(hashf_t func, char *name, int namelen) __u32 hash_value(hashf_t func, const char *name, int namelen)
{ {
__u32 res; __u32 res;
@@ -881,7 +881,7 @@ __u32 hash_value(hashf_t func, char *name, int namelen)
/* if name is found in a directory - return 1 and set path to the name, /* if name is found in a directory - return 1 and set path to the name,
otherwise return 0 and pathrelse path */ otherwise return 0 and pathrelse path */
int reiserfs_locate_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir, int reiserfs_locate_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
char *name, struct reiserfs_path *path) const char *name, struct reiserfs_path *path)
{ {
struct reiserfs_key entry_key; struct reiserfs_key entry_key;
struct item_head *ih; struct item_head *ih;
@@ -944,7 +944,7 @@ int reiserfs_locate_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
generation counter in 'min_gen_counter'. dies if found object is not a generation counter in 'min_gen_counter'. dies if found object is not a
directory. */ directory. */
int reiserfs_find_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir, int reiserfs_find_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
char *name, unsigned int *min_gen_counter, const char *name, unsigned int *min_gen_counter,
struct reiserfs_key *key) struct reiserfs_key *key)
{ {
struct reiserfs_key entry_key; struct reiserfs_key entry_key;
@@ -1040,7 +1040,7 @@ int reiserfs_find_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
} }
/* compose directory entry: dir entry head and name itself */ /* compose directory entry: dir entry head and name itself */
static char *make_entry(char *entry, char *name, struct reiserfs_key *key, static char *make_entry(char *entry, const char *name, struct reiserfs_key *key,
__u32 offset) __u32 offset)
{ {
struct reiserfs_de_head *deh; struct reiserfs_de_head *deh;
@@ -1068,8 +1068,8 @@ static char *make_entry(char *entry, char *name, struct reiserfs_key *key,
/* add new name into a directory. If it exists in a directory - do /* add new name into a directory. If it exists in a directory - do
nothing */ nothing */
int reiserfs_add_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir, int reiserfs_add_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
char *name, int name_len, struct reiserfs_key *key, const char *name, int name_len,
__u16 fsck_need) struct reiserfs_key *key, __u16 fsck_need)
{ {
struct item_head entry_ih = { {0,}, }; struct item_head entry_ih = { {0,}, };
char *entry; char *entry;
@@ -1229,7 +1229,7 @@ void make_sure_root_dir_exists(reiserfs_filsys_t fs,
/* we only can use a file for filesystem or journal if it is either not /* we only can use a file for filesystem or journal if it is either not
mounted block device or regular file and we are forced to use it */ mounted block device or regular file and we are forced to use it */
int can_we_format_it(char *device_name, int force) int can_we_format_it(const char *device_name, int force)
{ {
mode_t mode; mode_t mode;
dev_t rdev; dev_t rdev;
@@ -1262,7 +1262,7 @@ int can_we_format_it(char *device_name, int force)
return 1; return 1;
} }
int create_badblock_bitmap(reiserfs_filsys_t fs, char *badblocks_file) int create_badblock_bitmap(reiserfs_filsys_t fs, const char *badblocks_file)
{ {
FILE *fd; FILE *fd;
char buf[128]; char buf[128];