Many files:
ext2fs.h: Remove definition of ext2fs_sb. Note: this may break source
(but not binary) compatibility of some users of the ext2 library.
They should just simply do a global search and replace of struct
ext2fs_sb with struct ext2_super_block, and use their own private copy
of ext2_fs.h if they aren't already.
closefs.c, initialize.c, link.c, newdir.c, openfs.c, swapfs.c: Replace
use of ext2fs_sb with ext2_super_block.
ChangeLog, main.c:
main.c (main): Replace use of struct ext2fs_sb with struct ext2_super_block.
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index ad68b17..6ec6d29 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,15 @@
+2001-01-01 <tytso@snap.thunk.org>
+
+ * ext2fs.h: Remove definition of ext2fs_sb. Note: this may break
+ source (but not binary) compatibility of some users of the
+ ext2 library. They should just simply do a global search
+ and replace of struct ext2fs_sb with struct
+ ext2_super_block, and use their own private copy of
+ ext2_fs.h if they aren't already.
+
+ * closefs.c, initialize.c, link.c, newdir.c, openfs.c, swapfs.c:
+ Replace use of ext2fs_sb with ext2_super_block.
+
2000-12-31 <tytso@snap.thunk.org>
* ext2fs.h: Cleaned up header file by removing definitions of
diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
index d66f422..e12f57f 100644
--- a/lib/ext2fs/closefs.c
+++ b/lib/ext2fs/closefs.c
@@ -39,11 +39,8 @@
int ext2fs_bg_has_super(ext2_filsys fs, int group_block)
{
-#ifdef EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
- struct ext2fs_sb *s;
-
- s = (struct ext2fs_sb *) fs->super;
- if (!(s->s_feature_ro_compat & EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))
+ if (!(fs->super->s_feature_ro_compat &
+ EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))
return 1;
if (test_root(group_block, 3) || (test_root(group_block, 5)) ||
@@ -51,9 +48,6 @@
return 1;
return 0;
-#else
- return 1;
-#endif
}
/*
@@ -133,15 +127,13 @@
struct ext2_super_block *super_shadow = 0;
struct ext2_group_desc *group_shadow = 0;
struct ext2_group_desc *s, *t;
- struct ext2fs_sb *sb, *sb_shadow;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
fs_state = fs->super->s_state;
fs->super->s_wtime = time(NULL);
- sb = (struct ext2fs_sb *) fs->super;
- sb->s_block_group_nr = 0;
+ fs->super->s_block_group_nr = 0;
if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
retval = EXT2_ET_NO_MEMORY;
retval = ext2fs_get_mem(SUPERBLOCK_SIZE,
@@ -159,7 +151,6 @@
/* swap the superblock */
*super_shadow = *fs->super;
ext2fs_swap_super(super_shadow);
- sb_shadow = (struct ext2fs_sb *) super_shadow;
/* swap the group descriptors */
for (j=0, s=fs->group_desc, t=group_shadow;
@@ -169,7 +160,6 @@
}
} else {
super_shadow = fs->super;
- sb_shadow = (struct ext2fs_sb *) fs->super;
group_shadow = fs->group_desc;
}
@@ -208,9 +198,9 @@
if (sgrp > ((1 << 16) - 1))
sgrp = (1 << 16) - 1;
if (fs->flags & EXT2_FLAG_SWAP_BYTES)
- sb_shadow->s_block_group_nr = ext2fs_swab16(sgrp);
+ super_shadow->s_block_group_nr = ext2fs_swab16(sgrp);
else
- sb->s_block_group_nr = sgrp;
+ fs->super->s_block_group_nr = sgrp;
if (i !=0 ) {
retval = io_channel_write_blk(fs->io, group_block,
@@ -231,7 +221,7 @@
next_group:
group_block += EXT2_BLOCKS_PER_GROUP(fs->super);
}
- sb->s_block_group_nr = 0;
+ fs->super->s_block_group_nr = 0;
/*
* If the write_bitmaps() function is present, call it to
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index c2be085..067fc13 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -37,7 +37,7 @@
* The last ext2fs revision level that this version of the library is
* able to support.
*/
-#define EXT2_LIB_CURRENT_REV 0
+#define EXT2_LIB_CURRENT_REV EXT2_DYNAMIC_REV
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -388,77 +388,8 @@
/*
- * The ext2fs library private definition of the ext2 superblock, so we
- * don't have to depend on the kernel's definition of the superblock,
- * which might not have the latest features.
+ * For ext2 compression support
*/
-struct ext2fs_sb {
- __u32 s_inodes_count; /* Inodes count */
- __u32 s_blocks_count; /* Blocks count */
- __u32 s_r_blocks_count; /* Reserved blocks count */
- __u32 s_free_blocks_count; /* Free blocks count */
- __u32 s_free_inodes_count; /* Free inodes count */
- __u32 s_first_data_block; /* First Data Block */
- __u32 s_log_block_size; /* Block size */
- __s32 s_log_frag_size; /* Fragment size */
- __u32 s_blocks_per_group; /* # Blocks per group */
- __u32 s_frags_per_group; /* # Fragments per group */
- __u32 s_inodes_per_group; /* # Inodes per group */
- __u32 s_mtime; /* Mount time */
- __u32 s_wtime; /* Write time */
- __u16 s_mnt_count; /* Mount count */
- __s16 s_max_mnt_count; /* Maximal mount count */
- __u16 s_magic; /* Magic signature */
- __u16 s_state; /* File system state */
- __u16 s_errors; /* Behaviour when detecting errors */
- __u16 s_minor_rev_level; /* minor revision level */
- __u32 s_lastcheck; /* time of last check */
- __u32 s_checkinterval; /* max. time between checks */
- __u32 s_creator_os; /* OS */
- __u32 s_rev_level; /* Revision level */
- __u16 s_def_resuid; /* Default uid for reserved blocks */
- __u16 s_def_resgid; /* Default gid for reserved blocks */
- /*
- * These fields are for EXT2_DYNAMIC_REV superblocks only.
- *
- * Note: the difference between the compatible feature set and
- * the incompatible feature set is that if there is a bit set
- * in the incompatible feature set that the kernel doesn't
- * know about, it should refuse to mount the filesystem.
- *
- * e2fsck's requirements are more strict; if it doesn't know
- * about a feature in either the compatible or incompatible
- * feature set, it must abort and not try to meddle with
- * things it doesn't understand...
- */
- __u32 s_first_ino; /* First non-reserved inode */
- __u16 s_inode_size; /* size of inode structure */
- __u16 s_block_group_nr; /* block group # of this superblock */
- __u32 s_feature_compat; /* compatible feature set */
- __u32 s_feature_incompat; /* incompatible feature set */
- __u32 s_feature_ro_compat; /* readonly-compatible feature set */
- __u8 s_uuid[16]; /* 128-bit uuid for volume */
- char s_volume_name[16]; /* volume name */
- char s_last_mounted[64]; /* directory where last mounted */
- __u32 s_algorithm_usage_bitmap; /* For compression */
- /*
- * Performance hints. Directory preallocation should only
- * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
- */
- __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
- __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
- __u16 s_padding1;
- /*
- * Journaling support.
- */
- __u8 s_journal_uuid[16]; /* uuid of journal superblock */
- __u32 s_journal_inum; /* inode number of journal file */
- __u32 s_journal_dev; /* device number of journal file */
- __u32 s_last_orphan; /* start of list of inodes to delete */
-
- __u32 s_reserved[197]; /* Padding to the end of the block */
-};
-
#define EXT2FS_COMPRESSED_BLKADDR ((blk_t) 0xffffffff)
#define HOLE_BLKADDR(_b) ((_b) == 0 || (_b) == EXT2FS_COMPRESSED_BLKADDR)
diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index 228c318..9fe76a4 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -110,7 +110,6 @@
set_field(s_first_data_block, super->s_log_block_size ? 0 : 1);
set_field(s_max_mnt_count, EXT2_DFL_MAX_MNT_COUNT);
set_field(s_errors, EXT2_ERRORS_DEFAULT);
-#ifdef EXT2_DYNAMIC_REV
set_field(s_feature_compat, 0);
set_field(s_feature_incompat, 0);
set_field(s_feature_ro_compat, 0);
@@ -124,7 +123,6 @@
set_field(s_first_ino, EXT2_GOOD_OLD_FIRST_INO);
set_field(s_inode_size, EXT2_GOOD_OLD_INODE_SIZE);
}
-#endif
set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL);
super->s_lastcheck = time(NULL);
diff --git a/lib/ext2fs/link.c b/lib/ext2fs/link.c
index 293a085..f8d760d 100644
--- a/lib/ext2fs/link.c
+++ b/lib/ext2fs/link.c
@@ -29,7 +29,7 @@
ino_t inode;
int flags;
int done;
- struct ext2fs_sb *sb;
+ struct ext2_super_block *sb;
};
static int link_proc(struct ext2_dir_entry *dirent,
@@ -115,7 +115,7 @@
ls.inode = ino;
ls.flags = flags;
ls.done = 0;
- ls.sb = (struct ext2fs_sb *) fs->super;
+ ls.sb = fs->super;
retval = ext2fs_dir_iterate(fs, dir, DIRENT_FLAG_INCLUDE_EMPTY,
0, link_proc, &ls);
diff --git a/lib/ext2fs/newdir.c b/lib/ext2fs/newdir.c
index 230ebaf..ec7b52d 100644
--- a/lib/ext2fs/newdir.c
+++ b/lib/ext2fs/newdir.c
@@ -38,7 +38,6 @@
char *buf;
int rec_len;
int filetype = 0;
- struct ext2fs_sb *sb;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -50,8 +49,8 @@
dir->rec_len = fs->blocksize;
if (dir_ino) {
- sb = (struct ext2fs_sb *) fs->super;
- if (sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_FILETYPE)
+ if (fs->super->s_feature_incompat &
+ EXT2_FEATURE_INCOMPAT_FILETYPE)
filetype = EXT2_FT_DIR << 8;
/*
* Set up entry for '.'
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index cc98311..1b1430d 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -50,7 +50,6 @@
blk_t group_block;
char *dest;
struct ext2_group_desc *gdp;
- struct ext2fs_sb *s;
EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER);
@@ -119,30 +118,22 @@
retval = EXT2_ET_BAD_MAGIC;
goto cleanup;
}
-#ifdef EXT2_DYNAMIC_REV
- if (fs->super->s_rev_level > EXT2_DYNAMIC_REV) {
- retval = EXT2_ET_REV_TOO_HIGH;
- goto cleanup;
- }
-#else
-#ifdef EXT2_CURRENT_REV
if (fs->super->s_rev_level > EXT2_LIB_CURRENT_REV) {
retval = EXT2_ET_REV_TOO_HIGH;
goto cleanup;
}
-#endif
-#endif
+
/*
* Check for feature set incompatibility
*/
if (!(flags & EXT2_FLAG_FORCE)) {
- s = (struct ext2fs_sb *) fs->super;
- if (s->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
+ if (fs->super->s_feature_incompat &
+ ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
retval = EXT2_ET_UNSUPP_FEATURE;
goto cleanup;
}
if ((flags & EXT2_FLAG_RW) &&
- (s->s_feature_ro_compat &
+ (fs->super->s_feature_ro_compat &
~EXT2_LIB_FEATURE_RO_COMPAT_SUPP)) {
retval = EXT2_ET_RO_UNSUPP_FEATURE;
goto cleanup;
diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c
index 45e87ba..75369c4 100644
--- a/lib/ext2fs/swapfs.c
+++ b/lib/ext2fs/swapfs.c
@@ -23,47 +23,43 @@
#include "ext2fs.h"
-void ext2fs_swap_super(struct ext2_super_block * super)
+void ext2fs_swap_super(struct ext2_super_block * sb)
{
- struct ext2fs_sb *s = (struct ext2fs_sb *) super;
-
- super->s_inodes_count = ext2fs_swab32(super->s_inodes_count);
- super->s_blocks_count = ext2fs_swab32(super->s_blocks_count);
- super->s_r_blocks_count = ext2fs_swab32(super->s_r_blocks_count);
- super->s_free_blocks_count = ext2fs_swab32(super->s_free_blocks_count);
- super->s_free_inodes_count = ext2fs_swab32(super->s_free_inodes_count);
- super->s_first_data_block = ext2fs_swab32(super->s_first_data_block);
- super->s_log_block_size = ext2fs_swab32(super->s_log_block_size);
- super->s_log_frag_size = ext2fs_swab32(super->s_log_frag_size);
- super->s_blocks_per_group = ext2fs_swab32(super->s_blocks_per_group);
- super->s_frags_per_group = ext2fs_swab32(super->s_frags_per_group);
- super->s_inodes_per_group = ext2fs_swab32(super->s_inodes_per_group);
- super->s_mtime = ext2fs_swab32(super->s_mtime);
- super->s_wtime = ext2fs_swab32(super->s_wtime);
- super->s_mnt_count = ext2fs_swab16(super->s_mnt_count);
- super->s_max_mnt_count = ext2fs_swab16(super->s_max_mnt_count);
- super->s_magic = ext2fs_swab16(super->s_magic);
- super->s_state = ext2fs_swab16(super->s_state);
- super->s_errors = ext2fs_swab16(super->s_errors);
- s->s_minor_rev_level = ext2fs_swab16(s->s_minor_rev_level);
- super->s_lastcheck = ext2fs_swab32(super->s_lastcheck);
- super->s_checkinterval = ext2fs_swab32(super->s_checkinterval);
- super->s_creator_os = ext2fs_swab32(super->s_creator_os);
- super->s_rev_level = ext2fs_swab32(super->s_rev_level);
-#ifdef EXT2_DEF_RESUID
- super->s_def_resuid = ext2fs_swab16(super->s_def_resuid);
- super->s_def_resgid = ext2fs_swab16(super->s_def_resgid);
-#endif
- s->s_first_ino = ext2fs_swab32(s->s_first_ino);
- s->s_inode_size = ext2fs_swab16(s->s_inode_size);
- s->s_block_group_nr = ext2fs_swab16(s->s_block_group_nr);
- s->s_feature_compat = ext2fs_swab32(s->s_feature_compat);
- s->s_feature_incompat = ext2fs_swab32(s->s_feature_incompat);
- s->s_feature_ro_compat = ext2fs_swab32(s->s_feature_ro_compat);
- s->s_algorithm_usage_bitmap = ext2fs_swab32(s->s_algorithm_usage_bitmap);
- s->s_journal_inum = ext2fs_swab32(s->s_journal_inum);
- s->s_journal_dev = ext2fs_swab32(s->s_journal_dev);
- s->s_last_orphan = ext2fs_swab32(s->s_last_orphan);
+ sb->s_inodes_count = ext2fs_swab32(sb->s_inodes_count);
+ sb->s_blocks_count = ext2fs_swab32(sb->s_blocks_count);
+ sb->s_r_blocks_count = ext2fs_swab32(sb->s_r_blocks_count);
+ sb->s_free_blocks_count = ext2fs_swab32(sb->s_free_blocks_count);
+ sb->s_free_inodes_count = ext2fs_swab32(sb->s_free_inodes_count);
+ sb->s_first_data_block = ext2fs_swab32(sb->s_first_data_block);
+ sb->s_log_block_size = ext2fs_swab32(sb->s_log_block_size);
+ sb->s_log_frag_size = ext2fs_swab32(sb->s_log_frag_size);
+ sb->s_blocks_per_group = ext2fs_swab32(sb->s_blocks_per_group);
+ sb->s_frags_per_group = ext2fs_swab32(sb->s_frags_per_group);
+ sb->s_inodes_per_group = ext2fs_swab32(sb->s_inodes_per_group);
+ sb->s_mtime = ext2fs_swab32(sb->s_mtime);
+ sb->s_wtime = ext2fs_swab32(sb->s_wtime);
+ sb->s_mnt_count = ext2fs_swab16(sb->s_mnt_count);
+ sb->s_max_mnt_count = ext2fs_swab16(sb->s_max_mnt_count);
+ sb->s_magic = ext2fs_swab16(sb->s_magic);
+ sb->s_state = ext2fs_swab16(sb->s_state);
+ sb->s_errors = ext2fs_swab16(sb->s_errors);
+ sb->s_minor_rev_level = ext2fs_swab16(sb->s_minor_rev_level);
+ sb->s_lastcheck = ext2fs_swab32(sb->s_lastcheck);
+ sb->s_checkinterval = ext2fs_swab32(sb->s_checkinterval);
+ sb->s_creator_os = ext2fs_swab32(sb->s_creator_os);
+ sb->s_rev_level = ext2fs_swab32(sb->s_rev_level);
+ sb->s_def_resuid = ext2fs_swab16(sb->s_def_resuid);
+ sb->s_def_resgid = ext2fs_swab16(sb->s_def_resgid);
+ sb->s_first_ino = ext2fs_swab32(sb->s_first_ino);
+ sb->s_inode_size = ext2fs_swab16(sb->s_inode_size);
+ sb->s_block_group_nr = ext2fs_swab16(sb->s_block_group_nr);
+ sb->s_feature_compat = ext2fs_swab32(sb->s_feature_compat);
+ sb->s_feature_incompat = ext2fs_swab32(sb->s_feature_incompat);
+ sb->s_feature_ro_compat = ext2fs_swab32(sb->s_feature_ro_compat);
+ sb->s_algorithm_usage_bitmap = ext2fs_swab32(sb->s_algorithm_usage_bitmap);
+ sb->s_journal_inum = ext2fs_swab32(sb->s_journal_inum);
+ sb->s_journal_dev = ext2fs_swab32(sb->s_journal_dev);
+ sb->s_last_orphan = ext2fs_swab32(sb->s_last_orphan);
}
void ext2fs_swap_group_desc(struct ext2_group_desc *gdp)
diff --git a/resize/ChangeLog b/resize/ChangeLog
index 4227113..c53df05 100644
--- a/resize/ChangeLog
+++ b/resize/ChangeLog
@@ -1,3 +1,8 @@
+2001-01-01 <tytso@snap.thunk.org>
+
+ * main.c (main): Replace use of struct ext2fs_sb with struct
+ ext2_super_block.
+
2000-12-08 <tytso@snap.thunk.org>
* Makefile.in: Fix so that top-level "make check" works correctly.
diff --git a/resize/main.c b/resize/main.c
index f092c10..726ae3e 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -4,7 +4,7 @@
* Copyright (C) 1997, 1998 by Theodore Ts'o and
* PowerQuest, Inc.
*
- * Copyright (C) 1999, 2000 by Theosore Ts'o
+ * Copyright (C) 1999, 2000, 2001 by Theosore Ts'o
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
@@ -120,7 +120,6 @@
blk_t max_size = 0;
io_manager io_ptr;
char *tmp;
- struct ext2fs_sb *s;
initialize_ext2_error_table();
@@ -208,9 +207,8 @@
* Check for compatibility with the feature sets. We need to
* be more stringent than ext2fs_open().
*/
- s = (struct ext2fs_sb *) fs->super;
- if ((s->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP) ||
- (s->s_feature_incompat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP)) {
+ if ((fs->super->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP) ||
+ (fs->super->s_feature_incompat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP)) {
com_err(program_name, EXT2_ET_UNSUPP_FEATURE,
"(%s)", device_name);
exit(1);