running out of space dd'ing JFFS2 image to /dev/mtdblock/0

Jörn Engel joern at wohnheim.fh-wedel.de
Mon Jan 31 11:39:19 EST 2005


On Mon, 31 January 2005 11:14:49 -0500, Robert P. J. Day wrote:
> 
> first, it's necessary to define a simple standard, so what about
> something like the following?  any size values in *any* of the
> JFFS2-related programs shall be in one of the following formats:
> 
>   ###		(interpreted as bytes)
>   ###KiB	(obvious)
>   ###MiB	(obvious)
> 
> at the moment, this is not being followed.  for instance, mkfs.jffs2
> has the --pad=SIZE option, where a simple number is treated as KiB.
> anyway, you get idea -- it's pretty confusing.
> 
> so, do we at least have some agreement on a standard?  which would
> hold across *all* programs and modules?  i'm not even going to
> *consider* looking at patches to do this unless i'm convinced everyone
> agrees, since changes like this will clearly force people to change
> the way they do some things.  and i know how fond some people are of
> *that* idea. :-)

I agree on a standard, if that helps you:

0x[0-9]...	hex
0[1-9]...	octal
[1-9]...	decimal

If followed by "ki", "Mi", or "Gi", they are multiplied by 1024, etc.

Example code, taken from phram:

static int ustrtoul(const char *cp, char **endp, unsigned int base)
{
	unsigned long result = simple_strtoul(cp, endp, base);

	switch (**endp) {
	case 'G':
		result *= 1024;
	case 'M':
		result *= 1024;
	case 'k':
		result *= 1024;
	/* By dwmw2 editorial decree, "ki", "Mi" or "Gi" are to be used. */
		if ((*endp)[1] == 'i')
			(*endp) += 2;
	}
	return result;
}

static int parse_num32(uint32_t *num32, const char *token)
{
	char *endp;
	unsigned long n;

	n = ustrtoul(token, &endp, 0);
	if (*endp)
		return -EINVAL;

	*num32 = n;
	return 0;
}

This allows different people with different taste to specify numbers
in various simple formats.  If you think you can improve on this,
please send me a patch.

Jörn

-- 
But this is not to say that the main benefit of Linux and other GPL
software is lower-cost. Control is the main benefit--cost is secondary.
-- Bruce Perens




More information about the linux-mtd mailing list