summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>1997-04-29 17:48:10 +0000
committerTheodore Ts'o <tytso@mit.edu>1997-04-29 17:48:10 +0000
commit521e36857227b21e7ab47b0a97f788d2af9f9717 (patch)
tree21ca3452b25bd1310df4c2d8cebbbc8ed8a7b217 /misc
parent24757fa0468170e1420087eef36219650dba8c07 (diff)
downloade2fsprogs-521e36857227b21e7ab47b0a97f788d2af9f9717.tar.gz
Many files:
Checked in e2fsprogs 1.08.
Diffstat (limited to 'misc')
-rw-r--r--misc/ChangeLog18
-rw-r--r--misc/dumpe2fs.c22
-rw-r--r--misc/mke2fs.8.in8
-rw-r--r--misc/mke2fs.c45
-rw-r--r--misc/tune2fs.8.in7
-rw-r--r--misc/tune2fs.c51
6 files changed, 135 insertions, 16 deletions
diff --git a/misc/ChangeLog b/misc/ChangeLog
index 8886779d..b761fb47 100644
--- a/misc/ChangeLog
+++ b/misc/ChangeLog
@@ -1,3 +1,21 @@
+Thu Apr 10 07:08:03 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * dumpe2fs.c (list_desc): List the offsets of the inode and block
+ bitmaps, and the inode table. List the block boundaries
+ for the groups.
+
+Sat Apr 5 11:55:52 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * tune2fs.c (main): Implement the -s flag allows the user to
+ set and reset the sparse superblock flag.
+
+ * mke2fs.c (PRS): By default generate DYNAMIC revision
+ filesystems. The -s flag controls whether or not the
+ sparse superblock flag is set.
+ (PRS): Change to allow the user to specify the true
+ maximum number of blocks per group to reflect the
+ blocksize.
+
Wed Mar 12 13:32:05 1997 Theodore Y. Ts'o <tytso@mit.edu>
* Release of E2fsprogs version 1.07
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index 448e4eb1..b71900e7 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -77,18 +77,27 @@ static void print_free (unsigned long group, char * bitmap,
static void list_desc (ext2_filsys fs)
{
unsigned long i;
+ blk_t group_blk, next_blk;
char * block_bitmap = fs->block_map->bitmap;
char * inode_bitmap = fs->inode_map->bitmap;
printf ("\n");
- for (i = 0; i < fs->group_desc_count; i++)
- {
- printf ("Group %lu:\n", i);
- printf (" Block bitmap at %u, Inode bitmap at %u, "
- "Inode table at %u\n",
+ group_blk = fs->super->s_first_data_block;
+ for (i = 0; i < fs->group_desc_count; i++) {
+ next_blk = group_blk + fs->super->s_blocks_per_group;
+ if (next_blk > fs->super->s_blocks_count)
+ next_blk = fs->super->s_blocks_count;
+ printf ("Group %lu: (Blocks %u -- %u)\n", i,
+ group_blk, next_blk -1 );
+ printf (" Block bitmap at %u (+%d), "
+ "Inode bitmap at %u (+%d)\n "
+ "Inode table at %u (+%d)\n",
fs->group_desc[i].bg_block_bitmap,
+ fs->group_desc[i].bg_block_bitmap - group_blk,
fs->group_desc[i].bg_inode_bitmap,
- fs->group_desc[i].bg_inode_table);
+ fs->group_desc[i].bg_inode_bitmap - group_blk,
+ fs->group_desc[i].bg_inode_table,
+ fs->group_desc[i].bg_inode_table - group_blk);
printf (" %d free blocks, %d free inodes, %d directories\n",
fs->group_desc[i].bg_free_blocks_count,
fs->group_desc[i].bg_free_inodes_count,
@@ -102,6 +111,7 @@ static void list_desc (ext2_filsys fs)
print_free (i, inode_bitmap, fs->super->s_inodes_per_group, 1);
inode_bitmap += fs->super->s_inodes_per_group / 8;
printf ("\n");
+ group_blk = next_blk;
}
}
diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
index 55265516..ab139a4c 100644
--- a/misc/mke2fs.8.in
+++ b/misc/mke2fs.8.in
@@ -40,6 +40,9 @@ mke2fs \- create a Linux second extended file system
.B \-q
]
[
+.B -s sparse-super-flag
+]
+[
.B \-v
]
[
@@ -114,6 +117,11 @@ of the mke2fs executable.
.I -q
Quiet execution. Useful if mke2fs is run in a script.
.TP
+.I -s sparse-super-flag
+If sparse-super-flag is 1, then turn on the sparse superblock flag.
+If 0, then turn off the sparse superblock flag. (Currently, the sparse
+superblock flag defaults to off.)
+.TP
.I -v
Verbose execution.
.TP
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 3723af5d..475397d9 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -486,6 +486,8 @@ static void show_stats(ext2_filsys fs)
col_left = 0;
for (i = 1; i < fs->group_desc_count; i++) {
group_block += s->s_blocks_per_group;
+ if (!ext2fs_bg_has_super(fs, i))
+ continue;
if (!col_left--) {
printf("\n\t");
col_left = 8;
@@ -539,11 +541,14 @@ static void PRS(int argc, char *argv[])
char c;
int size;
char * tmp;
+ blk_t max = 8192;
int inode_ratio = 4096;
int reserved_ratio = 5;
errcode_t retval;
+ int sparse_option = -1;
char *oldpath = getenv("PATH");
-
+ struct ext2fs_sb *param_ext2 = (struct ext2fs_sb *) &param;
+
/* Update our PATH to include /sbin */
if (oldpath) {
char *newpath;
@@ -560,6 +565,9 @@ static void PRS(int argc, char *argv[])
setbuf(stderr, NULL);
initialize_ext2_error_table();
memset(&param, 0, sizeof(struct ext2_super_block));
+#ifdef EXT2_DYNAMIC_REV
+ param.s_rev_level = EXT2_DYNAMIC_REV;
+#endif
fprintf (stderr, "mke2fs %s, %s for EXT2 FS %s, %s\n",
E2FSPROGS_VERSION, E2FSPROGS_DATE,
@@ -567,7 +575,7 @@ static void PRS(int argc, char *argv[])
if (argc && *argv)
program_name = *argv;
while ((c = getopt (argc, argv,
- "b:cf:g:i:l:m:o:qr:tvI:SFL:M:")) != EOF)
+ "b:cf:g:i:l:m:o:qr:s:tvI:SFL:M:")) != EOF)
switch (c) {
case 'b':
size = strtoul(optarg, &tmp, 0);
@@ -578,6 +586,7 @@ static void PRS(int argc, char *argv[])
}
param.s_log_block_size =
log2(size >> EXT2_MIN_BLOCK_LOG_SIZE);
+ max = size * 8;
break;
case 'c':
case 't': /* Check for bad blocks */
@@ -602,12 +611,6 @@ static void PRS(int argc, char *argv[])
"Illegal number for blocks per group");
exit(1);
}
- if (param.s_blocks_per_group < 256 ||
- param.s_blocks_per_group > 8192 || *tmp) {
- com_err(program_name, 0,
- "blocks per group count out of range");
- exit(1);
- }
if ((param.s_blocks_per_group % 8) != 0) {
com_err(program_name, 0,
"blocks per group must be multiple of 8");
@@ -647,6 +650,9 @@ static void PRS(int argc, char *argv[])
case 'r':
param.s_rev_level = atoi(optarg);
break;
+ case 's':
+ sparse_option = atoi(optarg);
+ break;
#ifdef EXT2_DYNAMIC_REV
case 'I':
param.s_inode_size = atoi(optarg);
@@ -705,6 +711,15 @@ static void PRS(int argc, char *argv[])
}
}
+ if (param.s_blocks_per_group) {
+ if (param.s_blocks_per_group < 256 ||
+ param.s_blocks_per_group > max || *tmp) {
+ com_err(program_name, 0,
+ "blocks per group count out of range");
+ exit(1);
+ }
+ }
+
/*
* Calculate number of inodes based on the inode ratio
*/
@@ -716,6 +731,20 @@ static void PRS(int argc, char *argv[])
* Calculate number of blocks to reserve
*/
param.s_r_blocks_count = (param.s_blocks_count * reserved_ratio) / 100;
+
+ /*
+ * If we are using revision #1, use the sparse super feature
+ * by default
+ */
+#ifdef EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
+ if ((sparse_option == 1)
+#ifdef EXT2_DYNAMIC_REV
+ || (param.s_rev_level >= EXT2_DYNAMIC_REV) && (!sparse_option)
+#endif
+ )
+ param_ext2->s_feature_ro_compat |=
+ EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
+#endif
}
int main (int argc, char *argv[])
diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in
index 9b927112..0e34085e 100644
--- a/misc/tune2fs.8.in
+++ b/misc/tune2fs.8.in
@@ -31,6 +31,9 @@ tune2fs \- adjust tunable filesystem parameters on second extended filesystems
.I reserved-blocks-count
]
[
+.B -s sparse-super-flag
+]
+[
.B -u
.I user
]
@@ -97,6 +100,10 @@ adjust the reserved blocks percentage on the given device.
.I -r reserved-blocks-count
adjust the reserved blocks count on the given device.
.TP
+.I -s sparse_super_flag
+sets and resets the sparse_superblock flag. The sparse_superblock feature
+saves space on really big filesystems.
+.TP
.I -u user
set the user who can benefit from the reserved blocks.
.I user
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index db3539e0..2cd43a63 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -63,6 +63,7 @@ int L_flag = 0;
int m_flag = 0;
int M_flag = 0;
int r_flag = 0;
+int s_flag = -1;
int u_flag = 0;
int U_flag = 0;
int max_mount_count, mount_count;
@@ -93,7 +94,7 @@ static volatile void usage (void)
{
fprintf (stderr, "Usage: %s [-c max-mounts-count] [-e errors-behavior] "
"[-g group]\n"
- "\t[-i interval[d|m|w]] [-l] [-m reserved-blocks-percent]\n"
+ "\t[-i interval[d|m|w]] [-l] [-s] [-m reserved-blocks-percent]\n"
"\t[-r reserved-blocks-count] [-u user] [-C mount-count]\n"
"\t[-L volume-label] [-M last-mounted-dir] [-U UUID] "
"device\n", program_name);
@@ -117,7 +118,7 @@ void main (int argc, char ** argv)
if (argc && *argv)
program_name = *argv;
initialize_ext2_error_table();
- while ((c = getopt (argc, argv, "c:e:g:i:lm:r:u:C:L:M:U:")) != EOF)
+ while ((c = getopt (argc, argv, "c:e:g:i:lm:r:s:u:C:L:M:U:")) != EOF)
switch (c)
{
case 'c':
@@ -253,6 +254,10 @@ void main (int argc, char ** argv)
r_flag = 1;
open_flag = EXT2_FLAG_RW;
break;
+ case 's':
+ s_flag = atoi(optarg);
+ open_flag = EXT2_FLAG_RW;
+ break;
case 'u':
resuid = strtoul (optarg, &tmp, 0);
if (*tmp)
@@ -355,6 +360,48 @@ void main (int argc, char ** argv)
printf ("Setting reserved blocks count to %lu\n",
reserved_blocks);
}
+ if (s_flag == 1) {
+#ifdef EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
+ if (sb->s_feature_ro_compat &
+ EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)
+ fprintf(stderr, "\nThe filesystem already "
+ " has spare superblocks.\n");
+ else {
+ sb->s_feature_ro_compat |=
+ EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
+ fs->super->s_state &= ~EXT2_VALID_FS;
+ ext2fs_mark_super_dirty(fs);
+ printf("\nSparse superblock flag set. "
+ "Please run e2fsck on the filesystem.\n");
+ }
+#else /* !EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER */
+ com_err (program_name, 0,
+ "The -s option is not supported by this version -- "
+ "Recompile with a newer kernel");
+#endif /* EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER */
+ }
+ if (s_flag == 0) {
+#ifdef EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
+ if (!(sb->s_feature_ro_compat &
+ EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))
+ fprintf(stderr, "\nThe filesystem already "
+ " does not support spare superblocks.\n");
+ else {
+ sb->s_feature_ro_compat &=
+ ~EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
+ fs->super->s_state &= ~EXT2_VALID_FS;
+ fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
+ ext2fs_mark_super_dirty(fs);
+ printf("\nSparse superblock flag cleared. "
+ "Please run e2fsck on the filesystem.\n");
+ }
+#else /* !EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER */
+ com_err (program_name, 0,
+ "The -s option is not supported by this version -- "
+ "Recompile with a newer kernel");
+#endif /* EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER */
+ }
+
if (u_flag)
#ifdef EXT2_DEF_RESUID
{