summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2009-10-25 21:41:32 -0400
committerTheodore Ts'o <tytso@mit.edu>2009-10-25 21:41:32 -0400
commite633b58ac75f2f544b7d6572e37d4b63da31e59c (patch)
treeb9dc7c7905f1134bac197d86aadb934a9bf17eec
parent03b9dca63a75731711071e0a7ddef0475d6daf3a (diff)
downloade2fsprogs-e633b58ac75f2f544b7d6572e37d4b63da31e59c.tar.gz
libext2fs: clean up ext2fs_bg_flags_ interfaces
The ext2fs_bg_flag* functions were confusing. Currently we have this: void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags); void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group,__u16 bg_flags); (_set (unused) sets exactly bg_flags; _clear clears all and ignores bg_flags) and these, which can twiddle individual bits in bg_flags: void ext2fs_bg_flag_set(ext2_filsys fs, dgrp_t group, __u16 bg_flag); void ext2fs_bg_flag_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flag); A better interface, after the patch below, is just: ext2fs_bg_flags_zap(fs, group) /* zeros bg_flags */ ext2fs_bg_flags_set(fs, group, flags) /* adds flags to bg_flags */ ext2fs_bg_flags_clear(fs, group, flags) /* clears flags in bg_flags */ and remove the original ext2fs_bg_flags_set / ext2fs_bg_flags_clear. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--e2fsck/pass2.c2
-rw-r--r--e2fsck/pass5.c9
-rw-r--r--e2fsck/super.c12
-rw-r--r--lib/ext2fs/alloc.c4
-rw-r--r--lib/ext2fs/alloc_sb.c2
-rw-r--r--lib/ext2fs/alloc_stats.c4
-rw-r--r--lib/ext2fs/alloc_tables.c6
-rw-r--r--lib/ext2fs/blknum.c36
-rw-r--r--lib/ext2fs/csum.c2
-rw-r--r--lib/ext2fs/ext2fs.h8
-rw-r--r--lib/ext2fs/initialize.c6
-rw-r--r--lib/ext2fs/openfs.c4
-rw-r--r--misc/mke2fs.c2
-rw-r--r--resize/resize2fs.c11
14 files changed, 43 insertions, 65 deletions
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 067a9c71..d45ff744 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -991,7 +991,7 @@ out_htree:
pctx.num = dirent->inode;
if (fix_problem(ctx, PR_2_INOREF_BG_INO_UNINIT,
&cd->pctx)){
- ext2fs_bg_flag_clear(fs, group,
+ ext2fs_bg_flags_clear(fs, group,
EXT2_BG_INODE_UNINIT);
ext2fs_mark_super_dirty(fs);
ctx->flags |= E2F_FLAG_RESTART_LATER;
diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c
index be5a2412..aee4e5fa 100644
--- a/e2fsck/pass5.c
+++ b/e2fsck/pass5.c
@@ -260,8 +260,7 @@ redo_counts:
pctx2.blk = i;
pctx2.group = group;
if (fix_problem(ctx, PR_5_BLOCK_UNINIT,&pctx2)){
- ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT)
- ;
+ ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
skip_group = 0;
}
}
@@ -343,8 +342,7 @@ redo_counts:
if (fix_problem(ctx, PR_5_FREE_BLOCK_COUNT_GROUP,
&pctx)) {
- fs->group_desc[i].bg_free_blocks_count =
- free_array[i];
+ ext2fs_bg_free_blocks_count_set(fs, i, free_array[i]);
ext2fs_mark_super_dirty(fs);
} else
ext2fs_unmark_valid(fs);
@@ -482,8 +480,7 @@ redo_counts:
pctx2.blk = i;
pctx2.group = group;
if (fix_problem(ctx, PR_5_INODE_UNINIT,&pctx2)){
- ext2fs_bg_flag_clear(fs, group, EXT2_BG_INODE_UNINIT)
- ;
+ ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT);
skip_group = 0;
}
}
diff --git a/e2fsck/super.c b/e2fsck/super.c
index 40f65e50..b10539a9 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -638,8 +638,8 @@ void check_super_block(e2fsck_t ctx)
should_be = 0;
if (!ext2fs_group_desc_csum_verify(fs, i)) {
if (fix_problem(ctx, PR_0_GDT_CSUM, &pctx)) {
- ext2fs_bg_flag_clear (fs, i, EXT2_BG_BLOCK_UNINIT);
- ext2fs_bg_flag_clear (fs, i, EXT2_BG_INODE_UNINIT);
+ ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT);
gd->bg_itable_unused = 0;
should_be = 1;
}
@@ -651,8 +651,8 @@ void check_super_block(e2fsck_t ctx)
ext2fs_bg_flag_test(fs, i, EXT2_BG_INODE_UNINIT) ||
gd->bg_itable_unused != 0)){
if (fix_problem(ctx, PR_0_GDT_UNINIT, &pctx)) {
- ext2fs_bg_flag_clear (fs, i, EXT2_BG_BLOCK_UNINIT);
- ext2fs_bg_flag_clear (fs, i, EXT2_BG_INODE_UNINIT);
+ ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT);
gd->bg_itable_unused = 0;
should_be = 1;
}
@@ -662,7 +662,7 @@ void check_super_block(e2fsck_t ctx)
if (i == fs->group_desc_count - 1 &&
ext2fs_bg_flag_test(fs, i, EXT2_BG_BLOCK_UNINIT)) {
if (fix_problem(ctx, PR_0_BB_UNINIT_LAST, &pctx)) {
- ext2fs_bg_flag_clear (fs, i, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT);
should_be = 1;
}
ext2fs_unmark_valid(fs);
@@ -671,7 +671,7 @@ void check_super_block(e2fsck_t ctx)
if (ext2fs_bg_flag_test(fs, i, EXT2_BG_BLOCK_UNINIT) &&
!ext2fs_bg_flag_test(fs, i, EXT2_BG_INODE_UNINIT)) {
if (fix_problem(ctx, PR_0_BB_UNINIT_IB_INIT, &pctx)) {
- ext2fs_bg_flag_clear (fs, i, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT);
should_be = 1;
}
ext2fs_unmark_valid(fs);
diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c
index 24ab05bb..a711d456 100644
--- a/lib/ext2fs/alloc.c
+++ b/lib/ext2fs/alloc.c
@@ -68,7 +68,7 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
else
ext2fs_fast_unmark_block_bitmap2(map, blk);
}
- ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
ext2fs_group_desc_csum_set(fs, group);
}
@@ -89,7 +89,7 @@ static void check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map,
for (i=0; i < fs->super->s_inodes_per_group; i++, ino++)
ext2fs_fast_unmark_inode_bitmap2(map, ino);
- ext2fs_bg_flag_clear(fs, group, EXT2_BG_INODE_UNINIT);
+ ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT);
check_block_uninit(fs, fs->block_map, group);
}
diff --git a/lib/ext2fs/alloc_sb.c b/lib/ext2fs/alloc_sb.c
index 37f21404..b2e1969e 100644
--- a/lib/ext2fs/alloc_sb.c
+++ b/lib/ext2fs/alloc_sb.c
@@ -62,7 +62,7 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
if (old_desc_blk) {
if (fs->super->s_reserved_gdt_blocks && fs->block_map == bmap)
- ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
for (j=0; j < old_desc_blocks; j++)
if (old_desc_blk + j < ext2fs_blocks_count(fs->super))
ext2fs_mark_block_bitmap2(bmap,
diff --git a/lib/ext2fs/alloc_stats.c b/lib/ext2fs/alloc_stats.c
index 0ea06ab2..72293853 100644
--- a/lib/ext2fs/alloc_stats.c
+++ b/lib/ext2fs/alloc_stats.c
@@ -37,7 +37,7 @@ void ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino,
/* We don't strictly need to be clearing the uninit flag if inuse < 0
* (i.e. freeing inodes) but it also means something is bad. */
- ext2fs_bg_flag_clear(fs, group, EXT2_BG_INODE_UNINIT);
+ ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT);
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
ext2_ino_t first_unused_inode = fs->super->s_inodes_per_group -
@@ -77,7 +77,7 @@ void ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse)
else
ext2fs_unmark_block_bitmap2(fs->block_map, blk);
fs->group_desc[group].bg_free_blocks_count -= inuse;
- ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
ext2fs_group_desc_csum_set(fs, group);
ext2fs_free_blocks_count_add(fs->super, -inuse);
diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
index 94aeedae..8141ec34 100644
--- a/lib/ext2fs/alloc_tables.c
+++ b/lib/ext2fs/alloc_tables.c
@@ -143,7 +143,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
dgrp_t gr = ext2fs_group_of_blk(fs, new_blk);
fs->group_desc[gr].bg_free_blocks_count--;
ext2fs_free_blocks_count_add(fs->super, -1);
- ext2fs_bg_flag_clear(fs, gr, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, gr, EXT2_BG_BLOCK_UNINIT);
ext2fs_group_desc_csum_set(fs, gr);
}
}
@@ -171,7 +171,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
dgrp_t gr = ext2fs_group_of_blk(fs, new_blk);
fs->group_desc[gr].bg_free_blocks_count--;
ext2fs_free_blocks_count_add(fs->super, -1);
- ext2fs_bg_flag_clear(fs, gr, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, gr, EXT2_BG_BLOCK_UNINIT);
ext2fs_group_desc_csum_set(fs, gr);
}
}
@@ -205,7 +205,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
dgrp_t gr = ext2fs_group_of_blk(fs, blk);
fs->group_desc[gr].bg_free_blocks_count--;
ext2fs_free_blocks_count_add(fs->super, -1);
- ext2fs_bg_flag_clear(fs, gr,
+ ext2fs_bg_flags_clear(fs, gr,
EXT2_BG_BLOCK_UNINIT);
ext2fs_group_desc_csum_set(fs, gr);
}
diff --git a/lib/ext2fs/blknum.c b/lib/ext2fs/blknum.c
index 9b25ec74..6ebe47eb 100644
--- a/lib/ext2fs/blknum.c
+++ b/lib/ext2fs/blknum.c
@@ -421,25 +421,9 @@ __u16 ext2fs_bg_flags(ext2_filsys fs, dgrp_t group)
}
/*
- * Set the flags for this block group
+ * Zero out the flags for this block group
*/
-void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags)
-{
- if (fs->super->s_desc_size >= EXT2_MIN_DESC_SIZE_64BIT) {
- struct ext4_group_desc *gdp;
- gdp = (struct ext4_group_desc *) (fs->group_desc) + group;
-
- gdp->bg_flags = bg_flags;
- return;
- }
-
- fs->group_desc[group].bg_flags = bg_flags;
-}
-
-/*
- * Clear the flags for this block group
- */
-void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flags)
+void ext2fs_bg_flags_zap(ext2_filsys fs, dgrp_t group)
{
if (fs->super->s_desc_size >= EXT2_MIN_DESC_SIZE_64BIT) {
struct ext4_group_desc *gdp;
@@ -468,35 +452,35 @@ int ext2fs_bg_flag_test(ext2_filsys fs, dgrp_t group, __u16 bg_flag)
}
/*
- * Set a particular flag for this block group
+ * Set a flag or set of flags for this block group
*/
-void ext2fs_bg_flag_set(ext2_filsys fs, dgrp_t group, __u16 bg_flag)
+void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags)
{
if (fs->super->s_desc_size >= EXT2_MIN_DESC_SIZE_64BIT) {
struct ext4_group_desc *gdp;
gdp = (struct ext4_group_desc *) (fs->group_desc) + group;
- gdp->bg_flags |= bg_flag;
+ gdp->bg_flags |= bg_flags;
return;
}
- fs->group_desc[group].bg_flags |= bg_flag;
+ fs->group_desc[group].bg_flags |= bg_flags;
}
/*
- * Clear a particular flag for this block group
+ * Clear a flag or set of flags for this block group
*/
-void ext2fs_bg_flag_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flag)
+void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flags)
{
if (fs->super->s_desc_size >= EXT2_MIN_DESC_SIZE_64BIT) {
struct ext4_group_desc *gdp;
gdp = (struct ext4_group_desc *) (fs->group_desc) + group;
- gdp->bg_flags &= ~bg_flag;
+ gdp->bg_flags &= ~bg_flags;
return;
}
- fs->group_desc[group].bg_flags &= ~bg_flag;
+ fs->group_desc[group].bg_flags &= ~bg_flags;
}
/*
diff --git a/lib/ext2fs/csum.c b/lib/ext2fs/csum.c
index dca42a0f..c2a177db 100644
--- a/lib/ext2fs/csum.c
+++ b/lib/ext2fs/csum.c
@@ -202,7 +202,7 @@ int main(int argc, char **argv)
fs->group_desc[i].bg_free_blocks_count = 31119;
fs->group_desc[i].bg_free_inodes_count = 15701;
fs->group_desc[i].bg_used_dirs_count = 2;
- fs->group_desc[i].bg_flags = 0;
+ ext2fs_bg_flags_zap(fs, i);
};
csum1 = ext2fs_group_desc_csum(fs, 0);
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 488fb6df..eb655b52 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -762,12 +762,10 @@ extern __u32 ext2fs_bg_itable_unused(ext2_filsys fs, dgrp_t group);
extern void ext2fs_bg_itable_unused_set(ext2_filsys fs, dgrp_t group,
__u32 n);
extern __u16 ext2fs_bg_flags(ext2_filsys fs, dgrp_t group);
-extern void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
-extern void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group,
- __u16 bg_flags);
+extern void ext2fs_bg_flags_zap(ext2_filsys fs, dgrp_t group);
extern int ext2fs_bg_flag_test(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
-extern void ext2fs_bg_flag_set(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
-extern void ext2fs_bg_flag_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
+extern void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
+extern void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
extern __u16 ext2fs_bg_checksum(ext2_filsys fs, dgrp_t group);
extern void ext2fs_bg_checksum_set(ext2_filsys fs, dgrp_t group, __u16 checksum);
extern blk64_t ext2fs_file_acl_block(const struct ext2_inode *inode);
diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index edcdd72e..986dd285 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -404,9 +404,9 @@ ipg_retry:
*/
if (csum_flag) {
if (i != fs->group_desc_count - 1)
- ext2fs_bg_flag_set(fs, i, EXT2_BG_BLOCK_UNINIT)
- ;
- ext2fs_bg_flag_set(fs, i, EXT2_BG_INODE_UNINIT);
+ ext2fs_bg_flags_set(fs, i,
+ EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT);
numblocks = super->s_inodes_per_group;
if (i == 0)
numblocks -= super->s_first_ino;
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 8b486176..8b246197 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -351,8 +351,8 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
dgrp_t group;
for (group = 0; group < fs->group_desc_count; group++) {
- ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
- ext2fs_bg_flag_clear(fs, group, EXT2_BG_INODE_UNINIT);
+ ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT);
fs->group_desc[group].bg_itable_unused = 0;
}
ext2fs_mark_super_dirty(fs);
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 2d9107a9..a2e23192 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -323,7 +323,7 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag)
EXT2_BLOCK_SIZE(fs->super));
} else {
/* The kernel doesn't need to zero the itable blocks */
- ext2fs_bg_flag_set(fs, i, EXT2_BG_INODE_ZEROED);
+ ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_ZEROED);
ext2fs_group_desc_csum_set(fs, i);
}
retval = ext2fs_zero_blocks(fs, blk, num, &blk, &num);
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 5a1eb2a8..869ae626 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -112,7 +112,7 @@ errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags,
fix_uninit_block_bitmaps(rfs->new_fs);
/* Clear the block bitmap uninit flag for the last block group */
- ext2fs_bg_flag_clear(rfs->new_fs, rfs->new_fs->group_desc_count - 1,
+ ext2fs_bg_flags_clear(rfs->new_fs, rfs->new_fs->group_desc_count - 1,
EXT2_BG_BLOCK_UNINIT);
*new_size = ext2fs_blocks_count(rfs->new_fs->super);
@@ -499,10 +499,9 @@ retry:
sizeof(struct ext2_group_desc));
adjblocks = 0;
- ext2fs_bg_flags_clear(fs, i, 0);
+ ext2fs_bg_flags_zap(fs, i);
if (csum_flag)
- ext2fs_bg_flag_set(fs, i, EXT2_BG_INODE_UNINIT | EXT2_BG_INODE_ZEROED)
- ;
+ ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT | EXT2_BG_INODE_ZEROED);
if (i == fs->group_desc_count-1) {
numblocks = (ext2fs_blocks_count(fs->super) -
fs->super->s_first_data_block) %
@@ -512,8 +511,8 @@ retry:
} else {
numblocks = fs->super->s_blocks_per_group;
if (csum_flag)
- ext2fs_bg_flag_set(fs, i, EXT2_BG_BLOCK_UNINIT)
- ;
+ ext2fs_bg_flags_set(fs, i,
+ EXT2_BG_BLOCK_UNINIT);
}
has_super = ext2fs_bg_has_super(fs, i);