diff options
author | Valerie Aurora Henson <vaurora@redhat.com> | 2009-09-07 20:46:34 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-09-07 20:46:34 -0400 |
commit | 4efbac6fed75c29d3d5f1b676b932754653a2ac5 (patch) | |
tree | b5abaa3d97e473970064e649d9ed6f661b447a22 /misc | |
parent | a63745e81cbb476b90c75ca3ca60b9ba4be95cae (diff) | |
download | e2fsprogs-4efbac6fed75c29d3d5f1b676b932754653a2ac5.tar.gz |
Convert uses of super->s_*_blocks_count to ext2fs_*_blocks_count()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'misc')
-rw-r--r-- | misc/Makefile.in | 2 | ||||
-rw-r--r-- | misc/e2freefrag.c | 10 | ||||
-rw-r--r-- | misc/e2image.c | 2 | ||||
-rw-r--r-- | misc/findsuper.c | 15 | ||||
-rw-r--r-- | misc/mke2fs.c | 84 | ||||
-rw-r--r-- | misc/tune2fs.c | 32 | ||||
-rw-r--r-- | misc/util.c | 4 |
7 files changed, 78 insertions, 71 deletions
diff --git a/misc/Makefile.in b/misc/Makefile.in index edcab83f..123922ff 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in @@ -127,7 +127,7 @@ profile.o: findsuper: findsuper.o $(E) " LD $@" - $(Q) $(CC) $(ALL_LDFLAGS) -o findsuper findsuper.o + $(Q) $(CC) $(ALL_LDFLAGS) -o findsuper findsuper.o $(LIBS) partinfo: partinfo.o $(E) " LD $@" diff --git a/misc/e2freefrag.c b/misc/e2freefrag.c index 7e6abe1d..edbe0bb0 100644 --- a/misc/e2freefrag.c +++ b/misc/e2freefrag.c @@ -91,7 +91,7 @@ void update_chunk_stats(struct chunk_info *info, unsigned long chunk_size) void scan_block_bitmap(ext2_filsys fs, struct chunk_info *info) { - unsigned long long blocks_count = fs->super->s_blocks_count; + unsigned long long blocks_count = ext2fs_blocks_count(fs->super); unsigned long long chunks = (blocks_count + info->blks_in_chunk) >> (info->chunkbits - info->blocksize_bits); unsigned long long chunk_num; @@ -149,15 +149,15 @@ errcode_t get_chunk_info(ext2_filsys fs, struct chunk_info *info) scan_block_bitmap(fs, info); - printf("Total blocks: %u\nFree blocks: %u (%0.1f%%)\n", - fs->super->s_blocks_count, fs->super->s_free_blocks_count, + printf("Total blocks: %llu\nFree blocks: %u (%0.1f%%)\n", + ext2fs_blocks_count(fs->super), fs->super->s_free_blocks_count, (double)fs->super->s_free_blocks_count * 100 / - fs->super->s_blocks_count); + ext2fs_blocks_count(fs->super)); if (info->chunkbytes) { printf("\nChunksize: %lu bytes (%u blocks)\n", info->chunkbytes, info->blks_in_chunk); - total_chunks = (fs->super->s_blocks_count + + total_chunks = (ext2fs_blocks_count(fs->super) + info->blks_in_chunk) >> (info->chunkbits - info->blocksize_bits); printf("Total chunks: %lu\nFree chunks: %lu (%0.1f%%)\n", diff --git a/misc/e2image.c b/misc/e2image.c index abbf6410..3802c993 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -421,7 +421,7 @@ static void output_meta_data_blocks(ext2_filsys fs, int fd) exit(1); } memset(zero_buf, 0, fs->blocksize); - for (blk = 0; blk < fs->super->s_blocks_count; blk++) { + for (blk = 0; blk < ext2fs_blocks_count(fs->super); blk++) { if ((blk >= fs->super->s_first_data_block) && ext2fs_test_block_bitmap2(meta_block_map, blk)) { retval = io_channel_read_blk64(fs->io, blk, 1, buf); diff --git a/misc/findsuper.c b/misc/findsuper.c index fbc28a37..e793e3b1 100644 --- a/misc/findsuper.c +++ b/misc/findsuper.c @@ -92,6 +92,7 @@ #include <time.h> #include "ext2fs/ext2_fs.h" +#include "ext2fs/ext2fs.h" #include "nls-enable.h" #undef DEBUG @@ -215,12 +216,14 @@ int main(int argc, char *argv[]) continue; if (ext2.s_log_block_size > 6) WHY("log block size > 6 (%u)\n", ext2.s_log_block_size); - if (ext2.s_r_blocks_count > ext2.s_blocks_count) + if (ext2fs_r_blocks_count(&ext2) > ext2fs_blocks_count(&ext2)) WHY("r_blocks_count > blocks_count (%u > %u)\n", - ext2.s_r_blocks_count, ext2.s_blocks_count); - if (ext2.s_free_blocks_count > ext2.s_blocks_count) + ext2fs_r_blocks_count(&ext2), + ext2fs_blocks_count(&ext2)); + if (ext2fs_free_blocks_count(&ext2) > ext2fs_blocks_count(&ext2)) WHY("free_blocks_count > blocks_count\n (%u > %u)\n", - ext2.s_free_blocks_count, ext2.s_blocks_count); + ext2fs_free_blocks_count(&ext2), + ext2fs_blocks_count(&ext2)); if (ext2.s_free_inodes_count > ext2.s_inodes_count) WHY("free_inodes_count > inodes_count (%u > %u)\n", ext2.s_free_inodes_count, ext2.s_inodes_count); @@ -246,9 +249,9 @@ int main(int argc, char *argv[]) printf("\r%11Lu %11Lu%s %11Lu%s %9u %5Lu %4u%s %s %02x%02x%02x%02x %s\n", sk, sk - ext2.s_block_group_nr * grpsize - sb_offset, jnl_copy ? "*":" ", - sk + ext2.s_blocks_count * bsize - + sk + ext2fs_blocks_count(&ext2) * bsize - ext2.s_block_group_nr * grpsize - sb_offset, - jnl_copy ? "*" : " ", ext2.s_blocks_count, bsize, + jnl_copy ? "*" : " ", ext2fs_blocks_count(&ext2), bsize, ext2.s_block_group_nr, jnl_copy ? "*" : " ", s, ext2.s_uuid[0], ext2.s_uuid[1], ext2.s_uuid[2], ext2.s_uuid[3], ext2.s_volume_name); diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 7287181e..cd97b93f 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -201,9 +201,9 @@ static void test_disk(ext2_filsys fs, badblocks_list *bb_list) errcode_t retval; char buf[1024]; - sprintf(buf, "badblocks -b %d -X %s%s%s %u", fs->blocksize, + sprintf(buf, "badblocks -b %d -X %s%s%s %llu", fs->blocksize, quiet ? "" : "-s ", (cflag > 1) ? "-w " : "", - fs->device_name, fs->super->s_blocks_count-1); + fs->device_name, ext2fs_blocks_count(fs->super)-1); if (verbose) printf(_("Running command: %s\n"), buf); f = popen(buf, "r"); @@ -275,7 +275,7 @@ _("Warning: the backup superblock/group descriptors at block %u contain\n" group = ext2fs_group_of_blk(fs, group_block+j); fs->group_desc[group].bg_free_blocks_count++; ext2fs_group_desc_csum_set(fs, group); - fs->super->s_free_blocks_count++; + ext2fs_free_blocks_count_add(fs->super, 1); } } group_block += fs->super->s_blocks_per_group; @@ -492,7 +492,7 @@ static void create_journal_dev(ext2_filsys fs) int c, count, err_count; retval = ext2fs_create_journal_superblock(fs, - fs->super->s_blocks_count, 0, &buf); + ext2fs_blocks_count(fs->super), 0, &buf); if (retval) { com_err("create_journal_dev", retval, _("while initializing journal superblock")); @@ -502,7 +502,7 @@ static void create_journal_dev(ext2_filsys fs) _("Zeroing journal device: "), ext2fs_blocks_count(fs->super)); blk = 0; - count = fs->super->s_blocks_count; + count = ext2fs_blocks_count(fs->super); while (count > 0) { if (count > 1024) c = 1024; @@ -542,9 +542,9 @@ static void show_stats(ext2_filsys fs) dgrp_t i; int need, col_left; - if (fs_param.s_blocks_count != s->s_blocks_count) - fprintf(stderr, _("warning: %u blocks unused.\n\n"), - fs_param.s_blocks_count - s->s_blocks_count); + if (ext2fs_blocks_count(&fs_param) != ext2fs_blocks_count(s)) + fprintf(stderr, _("warning: %llu blocks unused.\n\n"), + ext2fs_blocks_count(&fs_param) - ext2fs_blocks_count(s)); memset(buf, 0, sizeof(buf)); strncpy(buf, s->s_volume_name, sizeof(s->s_volume_name)); @@ -558,11 +558,11 @@ static void show_stats(ext2_filsys fs) s->s_log_block_size); printf(_("Fragment size=%u (log=%u)\n"), fs->fragsize, s->s_log_frag_size); - printf(_("%u inodes, %u blocks\n"), s->s_inodes_count, - s->s_blocks_count); - printf(_("%u blocks (%2.2f%%) reserved for the super user\n"), - s->s_r_blocks_count, - 100.0 * s->s_r_blocks_count / s->s_blocks_count); + printf(_("%u inodes, %llu blocks\n"), s->s_inodes_count, + ext2fs_blocks_count(s)); + printf(_("%llu blocks (%2.2f%%) reserved for the super user\n"), + ext2fs_r_blocks_count(s), + 100.0 * ext2fs_r_blocks_count(s) / ext2fs_blocks_count(s)); printf(_("First data block=%u\n"), s->s_first_data_block); if (s->s_reserved_gdt_blocks) printf(_("Maximum filesystem blocks=%lu\n"), @@ -702,7 +702,7 @@ static void parse_extended_opts(struct ext2_super_block *param, r_usage++; continue; } - if (resize <= param->s_blocks_count) { + if (resize <= ext2fs_blocks_count(param)) { fprintf(stderr, _("The resize maximum must be greater " "than the filesystem size.\n")); @@ -715,8 +715,8 @@ static void parse_extended_opts(struct ext2_super_block *param, if (!bpg) bpg = blocksize * 8; gdpb = EXT2_DESC_PER_BLOCK(param); - group_desc_count = - ext2fs_div_ceil(param->s_blocks_count, bpg); + group_desc_count = (__u32) ext2fs_div64_ceil( + ext2fs_blocks_count(param), bpg); desc_blocks = (group_desc_count + gdpb - 1) / gdpb; rsv_groups = ext2fs_div_ceil(resize, bpg); @@ -931,9 +931,9 @@ static char **parse_fs_type(const char *fs_type, } meg = (1024 * 1024) / EXT2_BLOCK_SIZE(fs_param); - if (fs_param->s_blocks_count < 3 * meg) + if (ext2fs_blocks_count(fs_param) < 3 * meg) size_type = "floppy"; - else if (fs_param->s_blocks_count < 512 * meg) + else if (ext2fs_blocks_count(fs_param) < 512 * meg) size_type = "small"; else size_type = "default"; @@ -1352,9 +1352,9 @@ static void PRS(int argc, char *argv[]) blocksize, sys_page_size); } if (optind < argc) { - fs_param.s_blocks_count = parse_num_blocks(argv[optind++], - fs_param.s_log_block_size); - if (!fs_param.s_blocks_count) { + ext2fs_blocks_count_set(&fs_param, parse_num_blocks(argv[optind++], + fs_param.s_log_block_size)); + if (!ext2fs_blocks_count(&fs_param)) { com_err(program_name, 0, _("invalid blocks count - %s"), argv[optind - 1]); exit(1); @@ -1369,8 +1369,8 @@ static void PRS(int argc, char *argv[]) fs_param.s_log_frag_size = fs_param.s_log_block_size; - if (noaction && fs_param.s_blocks_count) { - dev_size = fs_param.s_blocks_count; + if (noaction && ext2fs_blocks_count(&fs_param)) { + dev_size = ext2fs_blocks_count(&fs_param); retval = 0; } else { retry: @@ -1414,7 +1414,7 @@ get_size_failure: exit(1); } got_size: - if (!fs_param.s_blocks_count) { + if (!ext2fs_blocks_count(&fs_param)) { if (retval == EXT2_ET_UNIMPLEMENTED) { com_err(program_name, 0, _("Couldn't determine device size; you " @@ -1434,13 +1434,16 @@ got_size: )); exit(1); } - fs_param.s_blocks_count = dev_size; - if (sys_page_size > EXT2_BLOCK_SIZE(&fs_param)) - fs_param.s_blocks_count &= ~((sys_page_size / - EXT2_BLOCK_SIZE(&fs_param))-1); - } + ext2fs_blocks_count_set(&fs_param, dev_size); + if (sys_page_size > EXT2_BLOCK_SIZE(&fs_param)) { + blk64_t tmp = ext2fs_blocks_count(&fs_param); - } else if (!force && (fs_param.s_blocks_count > dev_size)) { + tmp &= ~((blk64_t) ((sys_page_size / + EXT2_BLOCK_SIZE(&fs_param))-1)); + ext2fs_blocks_count_set(&fs_param, tmp); + } + } + } else if (!force && (ext2fs_blocks_count(&fs_param) > dev_size)) { com_err(program_name, 0, _("Filesystem larger than apparent device size.")); proceed_question(); @@ -1564,7 +1567,9 @@ got_size: if ((blocksize < 0) && (use_bsize < (-blocksize))) use_bsize = -blocksize; blocksize = use_bsize; - fs_param.s_blocks_count /= blocksize / 1024; + ext2fs_blocks_count_set(&fs_param, + ext2fs_blocks_count(&fs_param) / + (blocksize / 1024)); } if (inode_ratio == 0) { @@ -1647,7 +1652,7 @@ got_size: /* Make sure number of inodes specified will fit in 32 bits */ if (num_inodes == 0) { unsigned long long n; - n = (unsigned long long) fs_param.s_blocks_count * blocksize / inode_ratio; + n = ext2fs_blocks_count(&fs_param) * blocksize / inode_ratio; if (n > ~0U) { com_err(program_name, 0, _("too many inodes (%llu), raise inode ratio?"), n); @@ -1663,29 +1668,28 @@ got_size: * Calculate number of inodes based on the inode ratio */ fs_param.s_inodes_count = num_inodes ? num_inodes : - ((__u64) fs_param.s_blocks_count * blocksize) - / inode_ratio; + (ext2fs_blocks_count(&fs_param) * blocksize) / inode_ratio; if ((((long long)fs_param.s_inodes_count) * (inode_size ? inode_size : EXT2_GOOD_OLD_INODE_SIZE)) >= - (((long long)fs_param.s_blocks_count) * + ((ext2fs_blocks_count(&fs_param)) * EXT2_BLOCK_SIZE(&fs_param))) { com_err(program_name, 0, _("inode_size (%u) * inodes_count " "(%u) too big for a\n\t" - "filesystem with %lu blocks, " + "filesystem with %llu blocks, " "specify higher inode_ratio (-i)\n\t" "or lower inode count (-N).\n"), inode_size ? inode_size : EXT2_GOOD_OLD_INODE_SIZE, fs_param.s_inodes_count, - (unsigned long) fs_param.s_blocks_count); + (unsigned long long) ext2fs_blocks_count(&fs_param)); exit(1); } /* * Calculate number of blocks to reserve */ - fs_param.s_r_blocks_count = (unsigned int) (reserved_ratio * - fs_param.s_blocks_count / 100.0); + ext2fs_r_blocks_count_set(&fs_param, reserved_ratio * + ext2fs_blocks_count(&fs_param) / 100.0); } static int should_do_undo(const char *name) @@ -1975,7 +1979,7 @@ int main (int argc, char *argv[]) } else { /* rsv must be a power of two (64kB is MD RAID sb alignment) */ unsigned int rsv = 65536 / fs->blocksize; - unsigned long blocks = fs->super->s_blocks_count; + unsigned long blocks = ext2fs_blocks_count(fs->super); unsigned long start; blk_t ret_blk; diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 6da5c072..8daf6324 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -69,7 +69,8 @@ static int I_flag; static time_t last_check_time; static int print_label; static int max_mount_count, mount_count, mount_flags; -static unsigned long interval, reserved_blocks; +static unsigned long interval; +static blk64_t reserved_blocks; static double reserved_ratio; static unsigned long resgid, resuid; static unsigned short errors; @@ -262,7 +263,7 @@ static int release_blocks_proc(ext2_filsys fs, blk_t *blocknr, group = ext2fs_group_of_blk(fs, block); fs->group_desc[group].bg_free_blocks_count++; ext2fs_group_desc_csum_set(fs, group); - fs->super->s_free_blocks_count++; + ext2fs_free_blocks_count_add(fs->super, 1); return 0; } @@ -1008,7 +1009,7 @@ static int get_move_bitmaps(ext2_filsys fs, int new_ino_blks_per_grp, } ext2fs_badblocks_list_free(bb_list); - if (needed_blocks > fs->super->s_free_blocks_count) + if (needed_blocks > ext2fs_free_blocks_count(fs->super)) return ENOSPC; return 0; @@ -1055,7 +1056,7 @@ static int move_block(ext2_filsys fs, ext2fs_block_bitmap bmap) return retval; for (new_blk = blk = fs->super->s_first_data_block; - blk < fs->super->s_blocks_count; blk++) { + blk < ext2fs_blocks_count(fs->super); blk++) { if (!ext2fs_test_block_bitmap2(bmap, blk)) continue; @@ -1336,21 +1337,21 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs) * First calculate the block statistics */ for (blk = fs->super->s_first_data_block; - blk < fs->super->s_blocks_count; blk++) { + blk < ext2fs_blocks_count(fs->super); blk++) { if (!ext2fs_fast_test_block_bitmap2(fs->block_map, blk)) { group_free++; total_free++; } count++; if ((count == fs->super->s_blocks_per_group) || - (blk == fs->super->s_blocks_count-1)) { + (blk == ext2fs_blocks_count(fs->super)-1)) { fs->group_desc[group++].bg_free_blocks_count = group_free; count = 0; group_free = 0; } } - fs->super->s_free_blocks_count = total_free; + ext2fs_free_blocks_count_set(fs->super, total_free); /* * Next, calculate the inode statistics @@ -1658,23 +1659,22 @@ retry_open: interval); } if (m_flag) { - sb->s_r_blocks_count = (unsigned int) (reserved_ratio * - sb->s_blocks_count / 100.0); + ext2fs_r_blocks_count_set(sb, reserved_ratio * + ext2fs_blocks_count(sb) / 100.0); ext2fs_mark_super_dirty(fs); - printf(_("Setting reserved blocks percentage to %g%% " - "(%u blocks)\n"), - reserved_ratio, sb->s_r_blocks_count); + printf (_("Setting reserved blocks percentage to %g%% (%llu blocks)\n"), + reserved_ratio, ext2fs_r_blocks_count(sb)); } if (r_flag) { - if (reserved_blocks >= sb->s_blocks_count/2) { + if (reserved_blocks >= ext2fs_blocks_count(sb)/2) { com_err(program_name, 0, - _("reserved blocks count is too big (%lu)"), + _("reserved blocks count is too big (%llu)"), reserved_blocks); exit(1); } - sb->s_r_blocks_count = reserved_blocks; + ext2fs_r_blocks_count_set(sb, reserved_blocks); ext2fs_mark_super_dirty(fs); - printf(_("Setting reserved blocks count to %lu\n"), + printf(_("Setting reserved blocks count to %llu\n"), reserved_blocks); } if (s_flag == 1) { diff --git a/misc/util.c b/misc/util.c index 837d60fc..b8a3cac9 100644 --- a/misc/util.c +++ b/misc/util.c @@ -253,7 +253,7 @@ unsigned int figure_journal_size(int size, ext2_filsys fs) { int j_blocks; - j_blocks = ext2fs_default_journal_size(fs->super->s_blocks_count); + j_blocks = ext2fs_default_journal_size(ext2fs_blocks_count(fs->super)); if (j_blocks < 0) { fputs(_("\nFilesystem too small for a journal\n"), stderr); return 0; @@ -269,7 +269,7 @@ unsigned int figure_journal_size(int size, ext2_filsys fs) j_blocks); exit(1); } - if ((unsigned) j_blocks > fs->super->s_free_blocks_count / 2) { + if ((unsigned) j_blocks > ext2fs_free_blocks_count(fs->super) / 2) { fputs(_("\nJournal size too big for filesystem.\n"), stderr); exit(1); |