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

Jörn Engel joern at wohnheim.fh-wedel.de
Mon Jan 31 12:38:51 EST 2005


On Mon, 31 January 2005 11:29:11 -0600, Josh Boyer wrote:
> 
> Because they aren't just commonly used units.  See:
> 
> http://physics.nist.gov/cuu/Units/binary.html

Oh crud!  They also picked the capital K.  All right, standard is
close enough to common sense, who cares.

Below code accepts 'Ki' (standard) and 'ki' (analog to decimal k).  It
also chews the final 'B' if people want to pass it.  Changes are
untested.

And for the curious, the 'u' in ustrtoul stands for "unit".

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':
        case 'k':
                result *= 1024;
        /* By dwmw2 editorial decree, "ki", "Mi" or "Gi" are to be used. */
                if ((*endp)[1] == 'i')
                        (*endp) += 2;
                if (**endp == 'B')
                        (*endp) += 1;
        }
        return result;
}


Jörn

-- 
I don't understand it. Nobody does.
-- Richard P. Feynman




More information about the linux-mtd mailing list