reiserfs: Fix signedness issues for large file systems

Now that we handle file systems > 8 TB, we end up printing large negative
numbers instead of actual block numbers. This patch fixes those places
to use unsigned ints for block numbers.

Signed-by: Jeff Mahoney <jeffm@suse.com>
This commit is contained in:
Jeff Mahoney committed 2012-10-11 11:56:48 -04:00
1 parent 5d4f1fa494
commit 0265fd70c1
13 files changed
+47 -44

No files matched your search

+11 -11
View File
@@ -59,11 +59,11 @@ Options:\n\
#if 1 #if 1
struct reiserfs_fsstat { struct reiserfs_fsstat {
int nr_internals; unsigned int nr_internals;
int nr_leaves; unsigned int nr_leaves;
int nr_files; unsigned int nr_files;
int nr_directories; unsigned int nr_directories;
int nr_unformatted; unsigned int nr_unformatted;
} g_stat_info; } g_stat_info;
#endif #endif
@@ -465,14 +465,14 @@ static void init_bitmap (reiserfs_filsys_t * fs)
case ALL_BLOCKS: case ALL_BLOCKS:
input_bitmap (fs) = reiserfs_create_bitmap (block_count); input_bitmap (fs) = reiserfs_create_bitmap (block_count);
reiserfs_bitmap_fill (input_bitmap (fs)); reiserfs_bitmap_fill (input_bitmap (fs));
reiserfs_warning (stderr, "Whole device (%d blocks) is to be scanned\n", reiserfs_warning (stderr, "Whole device (%u blocks) is to be scanned\n",
reiserfs_bitmap_ones (input_bitmap (fs))); reiserfs_bitmap_ones (input_bitmap (fs)));
break; break;
case USED_BLOCKS: case USED_BLOCKS:
reiserfs_warning (stderr, "Loading on-disk bitmap .. "); reiserfs_warning (stderr, "Loading on-disk bitmap .. ");
input_bitmap (fs) = reiserfs_create_bitmap (block_count); input_bitmap (fs) = reiserfs_create_bitmap (block_count);
reiserfs_bitmap_copy (input_bitmap (fs), fs->fs_bitmap2); reiserfs_bitmap_copy (input_bitmap (fs), fs->fs_bitmap2);
reiserfs_warning (stderr, "%d bits set - done\n", reiserfs_warning (stderr, "%lu bits set - done\n",
reiserfs_bitmap_ones (input_bitmap (fs))); reiserfs_bitmap_ones (input_bitmap (fs)));
break; break;
case UNUSED_BLOCKS: case UNUSED_BLOCKS:
@@ -480,7 +480,7 @@ static void init_bitmap (reiserfs_filsys_t * fs)
input_bitmap (fs) = reiserfs_create_bitmap (block_count); input_bitmap (fs) = reiserfs_create_bitmap (block_count);
reiserfs_bitmap_copy (input_bitmap (fs), fs->fs_bitmap2); reiserfs_bitmap_copy (input_bitmap (fs), fs->fs_bitmap2);
reiserfs_bitmap_invert (input_bitmap (fs)); reiserfs_bitmap_invert (input_bitmap (fs));
reiserfs_warning (stderr, "%d bits set - done\n", reiserfs_warning (stderr, "%lu bits set - done\n",
reiserfs_bitmap_ones (input_bitmap (fs))); reiserfs_bitmap_ones (input_bitmap (fs)));
break; break;
case EXTERN_BITMAP: case EXTERN_BITMAP:
@@ -494,7 +494,7 @@ static void init_bitmap (reiserfs_filsys_t * fs)
reiserfs_exit (1, "could not load fitmap from \"%s\"", reiserfs_exit (1, "could not load fitmap from \"%s\"",
input_bitmap_file_name(fs)); input_bitmap_file_name(fs));
} }
reiserfs_warning (stderr, "%d blocks marked in the given bitmap\n", reiserfs_warning (stderr, "%u blocks marked in the given bitmap\n",
reiserfs_bitmap_ones (input_bitmap (fs))); reiserfs_bitmap_ones (input_bitmap (fs)));
fclose (fp); fclose (fp);
break; break;
@@ -554,8 +554,8 @@ static void do_dump_tree (reiserfs_filsys_t * fs)
} }
/* print the statistic */ /* print the statistic */
printf ("\t%d internal + %d leaves + %d " printf ("\t%u internal + %u leaves + %u "
"unformatted nodes = %d blocks\n", "unformatted nodes = %u blocks\n",
g_stat_info.nr_internals, g_stat_info.nr_leaves, g_stat_info.nr_internals, g_stat_info.nr_leaves,
g_stat_info.nr_unformatted, g_stat_info.nr_internals + g_stat_info.nr_unformatted, g_stat_info.nr_internals +
g_stat_info.nr_leaves + g_stat_info.nr_unformatted); g_stat_info.nr_leaves + g_stat_info.nr_unformatted);
+9 -9
View File
@@ -8,7 +8,7 @@
/* counters for each kind of blocks */ /* counters for each kind of blocks */
int packed, unsigned int packed,
packed_leaves, packed_leaves,
full_blocks, full_blocks,
having_ih_array, /* blocks with broken block head */ having_ih_array, /* blocks with broken block head */
@@ -638,7 +638,7 @@ static void pack_frozen_data (reiserfs_filsys_t * fs)
} }
reiserfs_warning (stderr, "ok\n");fflush (stderr); reiserfs_warning (stderr, "ok\n");fflush (stderr);
reiserfs_warning (stderr, reiserfs_warning (stderr,
"Super block, bitmaps, journal - %d blocks - done, %d blocks left\n", "Super block, bitmaps, journal - %u blocks - done, %u blocks left\n",
packed, reiserfs_bitmap_ones (what_to_pack)); packed, reiserfs_bitmap_ones (what_to_pack));
} }
@@ -693,13 +693,13 @@ void pack_partition (reiserfs_filsys_t * fs)
magic16 = END_MAGIC; magic16 = END_MAGIC;
fwrite_le16 (&magic16); fwrite_le16 (&magic16);
fprintf (stderr, "\nPacked %d blocks:\n" fprintf (stderr, "\nPacked %u blocks:\n"
"\tcompessed %d\n" "\tcompessed %u\n"
"\tfull blocks %d\n" "\tfull blocks %u\n"
"\t\tleaves with broken block head %d\n" "\t\tleaves with broken block head %u\n"
"\t\tcorrupted leaves %d\n" "\t\tcorrupted leaves %u\n"
"\t\tinternals %d\n" "\t\tinternals %u\n"
"\t\tdescriptors %d\n", "\t\tdescriptors %u\n",
packed, packed,
packed_leaves, full_blocks, having_ih_array, packed_leaves, full_blocks, having_ih_array,
bad_leaves, internals, descs); bad_leaves, internals, descs);
+1 -1
View File
@@ -1032,7 +1032,7 @@ void do_scan (reiserfs_filsys_t * fs)
/* step 2: */ /* step 2: */
done = 0; done = 0;
total = reiserfs_bitmap_ones (input_bitmap (fs)); total = reiserfs_bitmap_ones (input_bitmap (fs));
printf ("%ld bits set in bitmap\n", total); printf ("%lu bits set in bitmap\n", total);
for (i = 0; i < get_sb_block_count (fs->fs_ondisk_sb); i ++) { for (i = 0; i < get_sb_block_count (fs->fs_ondisk_sb); i ++) {
int type; int type;
+1 -1
View File
@@ -245,7 +245,7 @@ void do_stat (reiserfs_filsys_t * fs)
reiserfs_exit (1, "could not open %s to save bitmap: %m\n", reiserfs_exit (1, "could not open %s to save bitmap: %m\n",
input_bitmap_file_name(fs)); input_bitmap_file_name(fs));
} }
reiserfs_warning (stderr, "Updated bitmap contains %d blocks marked\n", reiserfs_warning (stderr, "Updated bitmap contains %u blocks marked\n",
reiserfs_bitmap_ones (input_bitmap (fs))); reiserfs_bitmap_ones (input_bitmap (fs)));
reiserfs_bitmap_save (fp, input_bitmap (fs)); reiserfs_bitmap_save (fp, input_bitmap (fs));
+3 -3
View File
@@ -119,7 +119,7 @@ static int is_block_free (reiserfs_filsys_t * fs, unsigned long block)
} }
/*static int hits = 0;*/ /*static unsigned int hits = 0;*/
/* we have seen this block in the tree, mark corresponding bit in the /* we have seen this block in the tree, mark corresponding bit in the
control bitmap */ control bitmap */
@@ -156,7 +156,7 @@ static void init_control_bitmap (reiserfs_filsys_t * fs)
for (i = 0; i <= fs->fs_super_bh->b_blocknr; i ++) for (i = 0; i <= fs->fs_super_bh->b_blocknr; i ++)
we_met_it (i); we_met_it (i);
/*printf ("SKIPPED: %d blocks marked used (%d)\n", hits, /*printf ("SKIPPED: %u blocks marked used (%d)\n", hits,
reiserfs_bitmap_zeros (control_bitmap)); reiserfs_bitmap_zeros (control_bitmap));
hits = 0;*/ hits = 0;*/
@@ -172,7 +172,7 @@ static void init_control_bitmap (reiserfs_filsys_t * fs)
block ++; block ++;
} }
/*printf ("BITMAPS: %d blocks marked used (%d)\n", hits, /*printf ("BITMAPS: %u blocks marked used (%d)\n", hits,
reiserfs_bitmap_zeros (control_bitmap)); reiserfs_bitmap_zeros (control_bitmap));
hits = 0;*/ hits = 0;*/
+5 -5
View File
@@ -1759,7 +1759,7 @@ static void init_source_bitmap (reiserfs_filsys_t * fs)
case ALL_BLOCKS: case ALL_BLOCKS:
fsck_source_bitmap (fs) = reiserfs_create_bitmap (block_count); fsck_source_bitmap (fs) = reiserfs_create_bitmap (block_count);
reiserfs_bitmap_fill (fsck_source_bitmap (fs)); reiserfs_bitmap_fill (fsck_source_bitmap (fs));
fsck_progress ("The whole partition (%d blocks) is to be scanned\n", fsck_progress ("The whole partition (%u blocks) is to be scanned\n",
reiserfs_bitmap_ones (fsck_source_bitmap (fs))); reiserfs_bitmap_ones (fsck_source_bitmap (fs)));
break; break;
@@ -1768,7 +1768,7 @@ static void init_source_bitmap (reiserfs_filsys_t * fs)
fsck_source_bitmap (fs) = reiserfs_create_bitmap (block_count); fsck_source_bitmap (fs) = reiserfs_create_bitmap (block_count);
reiserfs_bitmap_copy (fsck_source_bitmap (fs), fs->fs_bitmap2); reiserfs_bitmap_copy (fsck_source_bitmap (fs), fs->fs_bitmap2);
fsck_progress ("ok, %d blocks marked used\n", fsck_progress ("ok, %u blocks marked used\n",
reiserfs_bitmap_ones (fsck_source_bitmap (fs))); reiserfs_bitmap_ones (fsck_source_bitmap (fs)));
break; break;
@@ -1787,7 +1787,7 @@ static void init_source_bitmap (reiserfs_filsys_t * fs)
fsck_data (fs)->rebuild.bitmap_file_name); fsck_data (fs)->rebuild.bitmap_file_name);
} }
fsck_progress ("%d blocks marked used in extern bitmap\n", fsck_progress ("%u blocks marked used in extern bitmap\n",
reiserfs_bitmap_ones (fsck_source_bitmap (fs))); reiserfs_bitmap_ones (fsck_source_bitmap (fs)));
fclose (fp); fclose (fp);
break; break;
@@ -1863,8 +1863,8 @@ static void init_source_bitmap (reiserfs_filsys_t * fs)
fsck_source_bitmap (fs)->bm_set_bits = reiserfs_bitmap_ones (fsck_source_bitmap (fs)); fsck_source_bitmap (fs)->bm_set_bits = reiserfs_bitmap_ones (fsck_source_bitmap (fs));
fsck_progress ("Skipping %d blocks (super block, journal, " fsck_progress ("Skipping %u blocks (super block, journal, "
"bitmaps) %d blocks will be read\n", tmp, fsck_source_bitmap (fs)->bm_set_bits); "bitmaps) %u blocks will be read\n", tmp, fsck_source_bitmap (fs)->bm_set_bits);
} }
+2 -2
View File
@@ -646,8 +646,8 @@ void load_pass_1_result (FILE * fp, reiserfs_filsys_t * fs)
fetch_objectid_map (proper_id_map (fs), fs); fetch_objectid_map (proper_id_map (fs), fs);
*/ */
fsck_progress ("Pass 1 result loaded. %d blocks used, %d allocable, " fsck_progress ("Pass 1 result loaded. %u blocks used, %u allocable, "
"still to be inserted %d\n", "still to be inserted %u\n",
reiserfs_bitmap_ones (fsck_new_bitmap (fs)), reiserfs_bitmap_ones (fsck_new_bitmap (fs)),
reiserfs_bitmap_zeros (fsck_allocable_bitmap (fs)), reiserfs_bitmap_zeros (fsck_allocable_bitmap (fs)),
reiserfs_bitmap_zeros (fsck_uninsertables (fs))); reiserfs_bitmap_zeros (fsck_uninsertables (fs)));
+2
View File
@@ -32,6 +32,8 @@
#ifndef REISERFSPROGS_FS_H #ifndef REISERFSPROGS_FS_H
#define REISERFSPRIGS_FS_H #define REISERFSPRIGS_FS_H
typedef unsigned int blocknr_t;
#ifndef NO_EXTERN_INLINE #ifndef NO_EXTERN_INLINE
# define extern_inline extern inline # define extern_inline extern inline
#else #else
+1 -1
View File
@@ -628,7 +628,7 @@ void close_rollback_file () {
return; return;
fwrite (&rollback_blocks_number, sizeof (rollback_blocksize), 1, s_rollback_file); fwrite (&rollback_blocks_number, sizeof (rollback_blocksize), 1, s_rollback_file);
if (log_file != 0) if (log_file != 0)
fprintf (log_file, "rollback: %d blocks backed up\n", rollback_blocks_number); fprintf (log_file, "rollback: %u blocks backed up\n", rollback_blocks_number);
} }
fclose (s_rollback_file); fclose (s_rollback_file);
+1 -1
View File
@@ -577,7 +577,7 @@ int reiserfs_create_journal(
{ {
/* host device does not contain enough blocks */ /* host device does not contain enough blocks */
reiserfs_warning (stderr, "reiserfs_create_journal: cannot create " reiserfs_warning (stderr, "reiserfs_create_journal: cannot create "
"a journal of %lu blocks with %lu offset on %d blocks\n", "a journal of %lu blocks with %lu offset on %u blocks\n",
len, offset, get_sb_block_count(sb)); len, offset, get_sb_block_count(sb));
return 0; return 0;
} }
+7 -7
View File
@@ -148,7 +148,7 @@ static int print_disk_child (FILE * stream,
int len; int len;
dc = *((const struct disk_child **)(args[0])); dc = *((const struct disk_child **)(args[0]));
len = asprintf (&buffer, "[dc_number=%u, dc_size=%u]", get_dc_child_blocknr (dc), len = asprintf (&buffer, "[dc_number=%lu, dc_size=%u]", get_dc_child_blocknr (dc),
get_dc_child_size (dc)); get_dc_child_size (dc));
FPRINTF; FPRINTF;
} }
@@ -373,9 +373,9 @@ static void print_sequence (FILE * fp, __u32 start, int len)
return; return;
if (len == 1) if (len == 1)
reiserfs_warning (fp, " %d", le32_to_cpu (start)); reiserfs_warning (fp, " %u", le32_to_cpu (start));
else else
reiserfs_warning (fp, " %d(%d)", le32_to_cpu (start), len); reiserfs_warning (fp, " %u(%d)", le32_to_cpu (start), len);
} }
@@ -491,7 +491,7 @@ static int print_internal (FILE * fp, struct buffer_head * bh, int first, int la
to = last < B_NR_ITEMS (bh) ? last : B_NR_ITEMS (bh); to = last < B_NR_ITEMS (bh) ? last : B_NR_ITEMS (bh);
} }
reiserfs_warning (fp, "INTERNAL NODE (%ld) contains %b\n", bh->b_blocknr, bh); reiserfs_warning (fp, "INTERNAL NODE (%lu) contains %b\n", bh->b_blocknr, bh);
dc = B_N_CHILD (bh, from); dc = B_N_CHILD (bh, from);
reiserfs_warning (fp, "PTR %d: %y ", from, dc); reiserfs_warning (fp, "PTR %d: %y ", from, dc);
@@ -527,7 +527,7 @@ static int print_leaf (FILE * fp, reiserfs_filsys_t * fs, struct buffer_head * b
reiserfs_warning (fp, reiserfs_warning (fp,
"\n===================================================================\n"); "\n===================================================================\n");
reiserfs_warning (fp, "LEAF NODE (%ld) contains %b (real items %d)\n", reiserfs_warning (fp, "LEAF NODE (%lu) contains %b (real items %d)\n",
bh->b_blocknr, bh, real_nr); bh->b_blocknr, bh, real_nr);
if (!(print_mode & PRINT_TREE_DETAILS)) { if (!(print_mode & PRINT_TREE_DETAILS)) {
@@ -761,7 +761,7 @@ void print_block (FILE * fp, reiserfs_filsys_t * fs,
if (print_super_block (fp, fs, file_name, bh, 0)) if (print_super_block (fp, fs, file_name, bh, 0))
if (print_leaf (fp, fs, bh, mode, first, last)) if (print_leaf (fp, fs, bh, mode, first, last))
if (print_internal (fp, bh, first, last)) if (print_internal (fp, bh, first, last))
reiserfs_warning (fp, "Block %ld contains unformatted data\n", bh->b_blocknr); reiserfs_warning (fp, "Block %lu contains unformatted data\n", bh->b_blocknr);
} }
@@ -797,7 +797,7 @@ void print_tb (int mode, int item_pos, int pos_in_item, struct tree_balance * tb
tbSh = 0; tbSh = 0;
tbFh = 0; tbFh = 0;
} }
printf ("* %u * %3lu(%2lu) * %3lu(%2lu) * %3lu(%2lu) * %5ld * %5ld * %5ld * %5ld * %5ld *\n", printf ("* %u * %3lu(%2lu) * %3lu(%2lu) * %3lu(%2lu) * %5lu * %5lu * %5lu * %5lu * %5lu *\n",
h, h,
tbSh ? tbSh->b_blocknr : ~0ul, tbSh ? tbSh->b_blocknr : ~0ul,
tbSh ? tbSh->b_count : ~0ul, tbSh ? tbSh->b_count : ~0ul,
+3 -2
View File
@@ -59,7 +59,8 @@ reiserfs_filsys_t * reiserfs_open (char * filename, int flags,
reiserfs_filsys_t * fs; reiserfs_filsys_t * fs;
struct buffer_head * bh; struct buffer_head * bh;
struct reiserfs_super_block * sb; struct reiserfs_super_block * sb;
int fd, i; int fd;
unsigned int i;
/* convert root dir key and parent root dir key to little endian format */ /* convert root dir key and parent root dir key to little endian format */
make_const_keys (); make_const_keys ();
@@ -200,7 +201,7 @@ reiserfs_filsys_t * reiserfs_create (char * filename,
block_size, block_count, 0)) block_size, block_count, 0))
{ {
reiserfs_warning (stderr, "reiserfs_create: can not create that small " reiserfs_warning (stderr, "reiserfs_create: can not create that small "
"(%d blocks) filesystem\n", block_count); "(%u blocks) filesystem\n", block_count);
return 0; return 0;
} }
+1 -1
View File
@@ -313,7 +313,7 @@ int search_by_key (reiserfs_filsys_t * fs,
int n_stop_level) /* How far down the tree to search.*/ int n_stop_level) /* How far down the tree to search.*/
{ {
struct reiserfs_super_block * sb; struct reiserfs_super_block * sb;
int n_block_number, unsigned int n_block_number,
expected_level, expected_level,
n_block_size = fs->fs_blocksize; n_block_size = fs->fs_blocksize;
struct buffer_head * p_s_bh; struct buffer_head * p_s_bh;