public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
To: Josh Boyer <jdub@us.ibm.com>
Cc: MTD mailing list <linux-mtd@lists.infradead.org>,
	tglx@linutronix.de, David Woodhouse <dwmw2@infradead.org>,
	"Robert P. J. Day" <rpjday@mindspring.com>
Subject: Re: running out of space dd'ing JFFS2 image to /dev/mtdblock/0
Date: Mon, 31 Jan 2005 18:38:51 +0100	[thread overview]
Message-ID: <20050131173851.GL6694@wohnheim.fh-wedel.de> (raw)
In-Reply-To: <1107192551.7567.31.camel@windu.rchland.ibm.com>

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

  reply	other threads:[~2005-01-31 17:38 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-31 15:14 running out of space dd'ing JFFS2 image to /dev/mtdblock/0 Robert P. J. Day
2005-01-31 15:21 ` Josh Boyer
2005-01-31 15:43   ` Robert P. J. Day
2005-01-31 15:54     ` Artem B. Bityuckiy
2005-01-31 16:14       ` Robert P. J. Day
2005-01-31 16:22         ` Artem B. Bityuckiy
2005-01-31 16:22         ` Thomas Gleixner
2005-01-31 16:26           ` David Woodhouse
2005-01-31 16:51             ` Robert P. J. Day
2005-01-31 17:11               ` Artem B. Bityuckiy
2005-01-31 17:21                 ` Jörn Engel
2005-01-31 17:25                   ` Artem B. Bityuckiy
2005-01-31 17:29                     ` Josh Boyer
2005-01-31 17:38                       ` Jörn Engel [this message]
2005-01-31 17:29                     ` Jörn Engel
2005-01-31 17:43                 ` Robert P. J. Day
2005-01-31 17:52                   ` Jörn Engel
2005-01-31 18:22                     ` Robert P. J. Day
2005-01-31 18:31                   ` David Woodhouse
2005-01-31 19:02                     ` Robert P. J. Day
2005-01-31 22:30           ` Robert P. J. Day
2005-01-31 16:39         ` Jörn Engel
2005-02-01  0:19           ` David Woodhouse
2005-02-01  0:43             ` Josh Boyer
2005-02-01 13:03             ` Jörn Engel
2005-01-31 16:01     ` Jörn Engel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050131173851.GL6694@wohnheim.fh-wedel.de \
    --to=joern@wohnheim.fh-wedel.de \
    --cc=dwmw2@infradead.org \
    --cc=jdub@us.ibm.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=rpjday@mindspring.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox