mke2fs.c (parse_extended_opts): Rename the -R option to -E. Fix

the resize= raid/extended option so it actually works.
	(The patch from Fedora e2fsprogs-1.35-11.2 claimed it
	worked, but it was a placebo, despite the claim that it
	worked in the usage message.)
This commit is contained in:
Theodore Ts'o 2005-01-05 11:12:20 -05:00
parent bc1b803214
commit c6a44136b9
3 changed files with 74 additions and 37 deletions

View File

@ -1,5 +1,11 @@
2005-01-05 Theodore Ts'o <tytso@mit.edu>
* mke2fs.c (parse_extended_opts): Rename the -R option to -E. Fix
the resize= raid/extended option so it actually works.
(The patch from Fedora e2fsprogs-1.35-11.2 claimed it
worked, but it was a placebo option, despite the claim
that it worked in the usage message.)
* e2initrd_helper.c: Fix gcc -Wall nits.
* e2image.c (main): Fix gcc -Wall nits. Fix e2image so that

View File

@ -63,8 +63,8 @@ mke2fs \- create an ext2/ext3 filesystem
.I fs-revision-level
]
[
.B \-R
.I raid-options
.B \-E
.I extended-options
]
[
.B \-v
@ -147,7 +147,9 @@ the expected usage of the filesystem (see the
.B \-T
option). If
.I block-size
is negative, then mke2fs will use heuristics to determine the
is negative, then
.B mke2fs
will use heuristics to determine the
appropriate block size, with the constraint that the block size will be
at least
.I block-size
@ -159,6 +161,30 @@ Check the device for bad blocks before creating the file system. If
this option is specified twice, then a slower, read-write
test is used instead of a fast read-only test.
.TP
.BI \-E " extended-options"
Set extended options for the filesystem. Extended options are comma
separated, and may take an argument using the equals ('=') sign. The
.B -E
option used to be
.B -R
in earlier versions of
.BR mke2fs .
The
.B -R
option is still accepted for backwards compatibility. The
following extended options are supported:
.RS 1.2i
.TP
.BI stride= stripe-size
Configure the filesystem for a RAID array with
.I stripe-size
filesystem blocks per stripe.
.TP
.BI resize= max-online-resize
Reserve enough space so that the block group descriptor table can grow
to support a filesystem that has max-online-resize blocks.
.RE
.TP
.BI \-f " fragment-size"
Specify the size of fragments in bytes.
.TP
@ -361,18 +387,6 @@ Set the filesystem revision for the new filesystem. Note that 1.2
kernels only support revision 0 filesystems. The default is to
create revision 1 filesystems.
.TP
.BI \-R " raid-options"
Set raid-related options for the filesystem. Raid options are comma
separated, and may take an argument using the equals ('=') sign. The
following options are supported:
.RS 1.2i
.TP
.BI stride= stripe-size
Configure the filesystem for a RAID array with
.I stripe-size
filesystem blocks per stripe.
.RE
.TP
.B \-S
Write superblock and group descriptors only. This is useful if all of
the superblock and backup superblocks are corrupted, and a last-ditch

View File

@ -774,7 +774,8 @@ static int set_os(struct ext2_super_block *sb, char *os)
#define PATH_SET "PATH=/sbin"
static void parse_r_opts(struct ext2_super_block *param, const char *opts)
static void parse_extended_opts(struct ext2_super_block *param,
const char *opts)
{
char *buf, *token, *next, *p, *arg;
int len;
@ -813,8 +814,10 @@ static void parse_r_opts(struct ext2_super_block *param, const char *opts)
continue;
}
} else if (!strcmp(token, "resize")) {
unsigned long resize = 1;
int tmp;
unsigned long resize, bpg, rsv_groups;
unsigned long group_desc_count, desc_blocks;
unsigned int gdpb, blocksize;
int rsv_gdb;
if (!arg) {
r_usage++;
@ -831,21 +834,34 @@ static void parse_r_opts(struct ext2_super_block *param, const char *opts)
r_usage++;
continue;
}
param->s_feature_compat |=
EXT2_FEATURE_COMPAT_RESIZE_INODE;
tmp = param->s_blocks_per_group;
if (tmp > EXT2_MAX_BLOCKS_PER_GROUP(param))
tmp = EXT2_MAX_BLOCKS_PER_GROUP(param);
resize = (resize + tmp - 1) / tmp;
tmp = (1 << param->s_log_block_size) /
sizeof(struct ext2_group_desc);
resize = (resize + tmp - 1) / tmp;
/* XXX param->s_res_gdt_blocks = resize - existing
cur_groups = (resize - sb->s_first_data_block +
EXT2_BLOCKS_PER_GROUP(super) - 1) /bpg;
cur_gdb = (cur_groups + gdpb - 1) / gdpb;
*/
if (resize <= param->s_blocks_count) {
fprintf(stderr,
_("The resize maximum must be greater than the filesystem size.\n"));
r_usage++;
continue;
}
blocksize = EXT2_BLOCK_SIZE(param);
bpg = param->s_blocks_per_group;
if (!bpg)
bpg = blocksize * 8;
gdpb = blocksize / sizeof(struct ext2_group_desc);
group_desc_count = (param->s_blocks_count +
bpg - 1) / bpg;
desc_blocks = (group_desc_count +
gdpb - 1) / gdpb;
rsv_groups = (resize + bpg - 1) / bpg;
rsv_gdb = (rsv_groups + gdpb - 1) / gdpb -
desc_blocks;
if (rsv_gdb > EXT2_ADDR_PER_BLOCK(param))
rsv_gdb = EXT2_ADDR_PER_BLOCK(param);
if (rsv_gdb > 0) {
param->s_feature_compat |=
EXT2_FEATURE_COMPAT_RESIZE_INODE;
param->s_reserved_gdt_blocks = rsv_gdb;
}
} else
r_usage++;
}
@ -886,7 +902,7 @@ static void PRS(int argc, char *argv[])
ext2_ino_t num_inodes = 0;
errcode_t retval;
char * oldpath = getenv("PATH");
char * r_opts = 0;
char * extended_opts = 0;
const char * fs_type = 0;
blk_t dev_size;
#ifdef __linux__
@ -956,7 +972,7 @@ static void PRS(int argc, char *argv[])
}
while ((c = getopt (argc, argv,
"b:cf:g:i:jl:m:no:qr:R:s:tvI:J:ST:FL:M:N:O:V")) != EOF) {
"b:cE:f:g:i:jl:m:no:qr:R:s:tvI:J:ST:FL:M:N:O:V")) != EOF) {
switch (c) {
case 'b':
blocksize = strtol(optarg, &tmp, 0);
@ -1111,8 +1127,9 @@ static void PRS(int argc, char *argv[])
exit(1);
}
break;
case 'E':
case 'R':
r_opts = optarg;
extended_opts = optarg;
break;
case 'S':
super_only = 1;
@ -1298,8 +1315,8 @@ static void PRS(int argc, char *argv[])
set_fs_defaults(fs_type, &param, blocksize, sector_size, &inode_ratio);
blocksize = EXT2_BLOCK_SIZE(&param);
if (r_opts)
parse_r_opts(&param, r_opts);
if (extended_opts)
parse_extended_opts(&param, extended_opts);
/* Since sparse_super is the default, we would only have a problem
* here if it was explicitly disabled.