diff mbox

[4/5] mke2fs: teach mke2fs to understand -b 4k and -C 256M

Message ID 1358210232-30578-4-git-send-email-tytso@mit.edu
State Accepted, archived
Headers show

Commit Message

Theodore Ts'o Jan. 15, 2013, 12:37 a.m. UTC
The -b and -C options now use parse_num_blocks2() insteda of strtol,
so that users can specify -C 256M instead of the much less convenient
-C 268435456.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 misc/mke2fs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Eric Sandeen Jan. 15, 2013, 3:11 p.m. UTC | #1
On 1/14/13 6:37 PM, Theodore Ts'o wrote:
> The -b and -C options now use parse_num_blocks2() insteda of strtol,
> so that users can specify -C 256M instead of the much less convenient
> -C 268435456.

Hm and -C isn't in the manpage at all.

Seems like the mke2fs manpage needs an update for bigalloc?

-Eric

> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> ---
>  misc/mke2fs.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/misc/mke2fs.c b/misc/mke2fs.c
> index 5cb49b3..c16ab33 100644
> --- a/misc/mke2fs.c
> +++ b/misc/mke2fs.c
> @@ -1324,10 +1324,10 @@ profile_error:
>  		    "b:cg:i:jl:m:no:qr:s:t:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:V")) != EOF) {
>  		switch (c) {
>  		case 'b':
> -			blocksize = strtol(optarg, &tmp, 0);
> +			blocksize = parse_num_blocks2(optarg, -1);
>  			b = (blocksize > 0) ? blocksize : -blocksize;
>  			if (b < EXT2_MIN_BLOCK_SIZE ||
> -			    b > EXT2_MAX_BLOCK_SIZE || *tmp) {
> +			    b > EXT2_MAX_BLOCK_SIZE) {
>  				com_err(program_name, 0,
>  					_("invalid block size - %s"), optarg);
>  				exit(1);
> @@ -1345,9 +1345,9 @@ profile_error:
>  			cflag++;
>  			break;
>  		case 'C':
> -			cluster_size = strtoul(optarg, &tmp, 0);
> +			cluster_size = parse_num_blocks2(optarg, -1);
>  			if (cluster_size <= EXT2_MIN_CLUSTER_SIZE ||
> -			    cluster_size > EXT2_MAX_CLUSTER_SIZE || *tmp) {
> +			    cluster_size > EXT2_MAX_CLUSTER_SIZE) {
>  				com_err(program_name, 0,
>  					_("invalid cluster size - %s"),
>  					optarg);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Sandeen Jan. 15, 2013, 3:13 p.m. UTC | #2
On 1/15/13 9:11 AM, Eric Sandeen wrote:
> On 1/14/13 6:37 PM, Theodore Ts'o wrote:
>> The -b and -C options now use parse_num_blocks2() insteda of strtol,
>> so that users can specify -C 256M instead of the much less convenient
>> -C 268435456.
> 
> Hm and -C isn't in the manpage at all.
> 
> Seems like the mke2fs manpage needs an update for bigalloc?

I'm sorry, I see that patch has already been sent.  I'll catch
up with my email, now.  :(

-Eric

> -Eric
> 
>> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
>> ---
>>  misc/mke2fs.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/misc/mke2fs.c b/misc/mke2fs.c
>> index 5cb49b3..c16ab33 100644
>> --- a/misc/mke2fs.c
>> +++ b/misc/mke2fs.c
>> @@ -1324,10 +1324,10 @@ profile_error:
>>  		    "b:cg:i:jl:m:no:qr:s:t:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:V")) != EOF) {
>>  		switch (c) {
>>  		case 'b':
>> -			blocksize = strtol(optarg, &tmp, 0);
>> +			blocksize = parse_num_blocks2(optarg, -1);
>>  			b = (blocksize > 0) ? blocksize : -blocksize;
>>  			if (b < EXT2_MIN_BLOCK_SIZE ||
>> -			    b > EXT2_MAX_BLOCK_SIZE || *tmp) {
>> +			    b > EXT2_MAX_BLOCK_SIZE) {
>>  				com_err(program_name, 0,
>>  					_("invalid block size - %s"), optarg);
>>  				exit(1);
>> @@ -1345,9 +1345,9 @@ profile_error:
>>  			cflag++;
>>  			break;
>>  		case 'C':
>> -			cluster_size = strtoul(optarg, &tmp, 0);
>> +			cluster_size = parse_num_blocks2(optarg, -1);
>>  			if (cluster_size <= EXT2_MIN_CLUSTER_SIZE ||
>> -			    cluster_size > EXT2_MAX_CLUSTER_SIZE || *tmp) {
>> +			    cluster_size > EXT2_MAX_CLUSTER_SIZE) {
>>  				com_err(program_name, 0,
>>  					_("invalid cluster size - %s"),
>>  					optarg);
>>
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zheng Liu Jan. 15, 2013, 3:24 p.m. UTC | #3
On Mon, Jan 14, 2013 at 07:37:11PM -0500, Theodore Ts'o wrote:
> The -b and -C options now use parse_num_blocks2() insteda of strtol,
> so that users can specify -C 256M instead of the much less convenient
> -C 268435456.
> 
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Regards,
                                                - Zheng
> ---
>  misc/mke2fs.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/misc/mke2fs.c b/misc/mke2fs.c
> index 5cb49b3..c16ab33 100644
> --- a/misc/mke2fs.c
> +++ b/misc/mke2fs.c
> @@ -1324,10 +1324,10 @@ profile_error:
>  		    "b:cg:i:jl:m:no:qr:s:t:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:V")) != EOF) {
>  		switch (c) {
>  		case 'b':
> -			blocksize = strtol(optarg, &tmp, 0);
> +			blocksize = parse_num_blocks2(optarg, -1);
>  			b = (blocksize > 0) ? blocksize : -blocksize;
>  			if (b < EXT2_MIN_BLOCK_SIZE ||
> -			    b > EXT2_MAX_BLOCK_SIZE || *tmp) {
> +			    b > EXT2_MAX_BLOCK_SIZE) {
>  				com_err(program_name, 0,
>  					_("invalid block size - %s"), optarg);
>  				exit(1);
> @@ -1345,9 +1345,9 @@ profile_error:
>  			cflag++;
>  			break;
>  		case 'C':
> -			cluster_size = strtoul(optarg, &tmp, 0);
> +			cluster_size = parse_num_blocks2(optarg, -1);
>  			if (cluster_size <= EXT2_MIN_CLUSTER_SIZE ||
> -			    cluster_size > EXT2_MAX_CLUSTER_SIZE || *tmp) {
> +			    cluster_size > EXT2_MAX_CLUSTER_SIZE) {
>  				com_err(program_name, 0,
>  					_("invalid cluster size - %s"),
>  					optarg);
> -- 
> 1.7.12.rc0.22.gcdd159b
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 5cb49b3..c16ab33 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1324,10 +1324,10 @@  profile_error:
 		    "b:cg:i:jl:m:no:qr:s:t:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:V")) != EOF) {
 		switch (c) {
 		case 'b':
-			blocksize = strtol(optarg, &tmp, 0);
+			blocksize = parse_num_blocks2(optarg, -1);
 			b = (blocksize > 0) ? blocksize : -blocksize;
 			if (b < EXT2_MIN_BLOCK_SIZE ||
-			    b > EXT2_MAX_BLOCK_SIZE || *tmp) {
+			    b > EXT2_MAX_BLOCK_SIZE) {
 				com_err(program_name, 0,
 					_("invalid block size - %s"), optarg);
 				exit(1);
@@ -1345,9 +1345,9 @@  profile_error:
 			cflag++;
 			break;
 		case 'C':
-			cluster_size = strtoul(optarg, &tmp, 0);
+			cluster_size = parse_num_blocks2(optarg, -1);
 			if (cluster_size <= EXT2_MIN_CLUSTER_SIZE ||
-			    cluster_size > EXT2_MAX_CLUSTER_SIZE || *tmp) {
+			    cluster_size > EXT2_MAX_CLUSTER_SIZE) {
 				com_err(program_name, 0,
 					_("invalid cluster size - %s"),
 					optarg);