mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kaih@khms.westfalen.de (Kai Henningsen)
To: linux-kernel@vger.kernel.org
Subject: Re: 2.5.28 and partitions
Date: 01 Aug 2002 14:31:00 +0200	[thread overview]
Message-ID: <8U0hkQ6Hw-B@khms.westfalen.de> (raw)
In-Reply-To: <3D490894.9030506@evision.ag>

dalecki@evision.ag (Marcin Dalecki)  wrote on 01.08.02 in <3D490894.9030506@evision.ag>:

> Alexander Viro wrote:
> >
> > On Thu, 1 Aug 2002, Peter Chubb wrote:
> >
> >
> >>Maybe we need to roll our own?  I suggest something like:
> >>      struct linux_volume_header {
> >>	     char  volname[16];
> >>	     __u32 nparts;
> >>	     __u32 blocksize;
> >>	     struct linux_partition {
> >>		    char partname[16]
> >>		    __u64  start;
> >>		    __u64  len;
> >>		    __u32  usage;
> >>		    __u32  flags;
> >>	    } parts[]
> >>    }
> >
> >
> > Oh, ferchrissake!  WHY???  People, we'd seen a lot of demonstrations
> > of the reasons why binary structures are *bad* for such stuff.
> >
> > What the bleedin' hell is wrong with <name> <start> <len>\n - all in
> > ASCII? Terminated by \0.  No need for flags, no need for endianness crap,
> > no need to worry about field becoming too narrow...
> >
> > What, parsing that would be too slow?  Right.  Sure.  How many times do
> > we parse partition table?  How many times do we end up reading it from
> > disk?  How does IO time compare to the "overhead" of trivial sscanf loop?
> >
> > Furrfu...  "ASCII is tough, let's go shopping"...
>
> Whats wrong with ASCII processing? Easy to tell:
>
> 1. Look at bagtraq. (www.securityfocus.com)

I can't see how that can possibly apply to this case. Getting a parser for  
*this* format wrong enough to allow for an attack needs incredible  
stupidity.

And remember, this is not something for generic applications to parse:  
possibly the bootloader (unless it's LILO), the kernel, and fdisk. That's  
it.

> 2. It's making data *not agnostic* against i18n issues. This is
> something most people forgett about. /proc is LANG=en_US. ISO8859-1 - I
> do not like this language.

I18n in partition names? Because that's certainly the only part in there  
that seems to even be possible. Just define that text in partition names  
is supposed to be UTF-8, and if there's ever anything that needs to be  
understood by programs (as opposed to just handed straight through between  
user and disk), make that be ASCII.

(However, I'd put the name as the _last_ field, possibly with a different  
separator [in case we ever want more fields], so I'd not need to think  
about any special characters in there.)

Oh, and don't forget some kind of magic string at the beginning. And  
possibly add some (optional) uuid. Helps with partitions moving around if  
the filesystem hasn't one.

> 3. For some as of jet undiscovered reason actual application programmers
> hate processing it.

Very few of them need to.

> 4. Answer 1. should be actually sufficient.

Not even remotely.


Ok, that makes a format proposal as follows:

#*Partition table*#
512 156258637 547af-d65e78-8978af =My Volume Label\n
0 3 ptable\n
4 7868 6562-adfea-898809aa =Bootloader\n
7872 150000000 a6f5-c9ba-6532 =Linux root
150007872 6250765\n
\0

That would be a 512-bytes-per block volume of around 80 GB (assuming I  
didn't miscalculate), with two data partitions and some free space at the  
end, and with both uuid and name fields being optional, except that an  
uuid of "ptable" marks the partition table partition.

Every line after the magic parses as /^\s*\d+\s+\d+\s*(\s\w+\s*)(=.*)$/  
(in Perl notation). It's free space if it only has the first two fields;  
the first line describes the whole volume and uses the first field for the  
block size. (Obviously, if you need boot code at the beginning of the  
disk, the partition table will need to start at some later sector. So that  
field has actual meaning.)

As for finding where to boot from - either have the bootloader define a  
partition name it wants to see, or put the relevant name into the boot  
loader config. No need to define that in the partition format. That's  
trivial: even MS-DOS did that (finding IO.SYS and MSDOS.SYS from the boot  
loader)! And neither scanning for '=' and '\n' nor comparing one string  
nor converting one number from decimal is any kind of hardship. Maybe half  
a screen of assembler, tops.

MfG Kai

  reply	other threads:[~2002-08-01 16:42 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <15688.25919.138565.6427@wombat.chubb.wattle.id.au>
2002-07-31 22:39 ` Alexander Viro
2002-08-01 10:08   ` Marcin Dalecki
2002-08-01 12:31     ` Kai Henningsen [this message]
2002-08-01 19:29   ` Thunder from the hill
2002-08-01 20:31     ` Alexander Viro
2002-08-01 20:45       ` Thunder from the hill
2002-08-01 21:08         ` Alexander Viro
2002-08-01 21:25           ` Marcin Dalecki
2002-08-01 21:41             ` Alexander Viro
2002-08-02 19:40               ` Mike Touloumtzis
2002-08-01 21:02       ` Marcin Dalecki
2002-08-01 21:27         ` Alexander Viro
2002-08-01 21:45           ` Marcin Dalecki
2002-08-02  5:21           ` Ryan Anderson
2002-08-01 21:24       ` Albert D. Cahalan
2002-08-02 19:47         ` Mike Touloumtzis
2002-08-02 20:49           ` Albert D. Cahalan
2002-08-02 21:21             ` Mike Touloumtzis
2002-08-02 21:36               ` [RFC] " Thunder from the hill
2002-08-02 22:12               ` Albert D. Cahalan
2002-08-02 22:53                 ` Mike Touloumtzis
2002-08-02 14:54 Jesse Pollard
2002-08-02 18:33 ` Kai Henningsen
     [not found] <15688.27022.143541.447952@wombat.chubb.wattle.id.au>
2002-07-31 23:42 ` Alexander Viro
  -- strict thread matches above, loose matches on Subject: below --
2002-07-31 23:38 Matt_Domsch
     [not found] <F44891A593A6DE4B99FDCB7CC537BBBBB839AC@AUSXMPS308.aus.amer .dell.com>
2002-07-31 22:58 ` Anton Altaparmakov
2002-07-31 22:47 Matt_Domsch
2002-07-25 17:50 Andries.Brouwer
2002-07-25 13:24 Petr Vandrovec
2002-07-25 13:45 ` Anton Altaparmakov
2002-07-26  5:13   ` Adrian Bunk
2002-07-25 12:43 Petr Vandrovec
2002-07-25  3:22 Matt_Domsch
2002-07-25  5:27 ` Linus Torvalds
2002-07-25 11:44   ` Alexander Viro
2002-07-25 15:57     ` Linus Torvalds
2002-07-30  9:58     ` Pavel Machek
     [not found]   ` <Pine.GSO.4.21.0207250739390.17037-100000@weyl.math.psu.edu >
2002-07-25 13:03     ` Anton Altaparmakov
2002-07-25 16:50       ` Alexander Viro
2002-07-25 17:35         ` Jason L Tibbitts III
2002-07-25 17:57         ` Rik van Riel
2002-07-25 18:27           ` Alexander Viro
2002-07-27  5:56         ` Austin Gonyou
     [not found]       ` <Pine.GSO.4.21.0207251245530.17621-100000@weyl.math.psu.edu >
2002-07-25 17:39         ` Anton Altaparmakov
2002-07-25 10:42 ` Alan Cox
2002-07-24 22:42 Andries.Brouwer
2002-07-24 23:42 ` Alexander Viro
2002-07-25  0:20   ` kwijibo
2002-07-25  4:00   ` Jason L Tibbitts III
     [not found] ` <Pine.GSO.4.21.0207241925450.14656-100000@weyl.math.psu.edu >
2002-07-25  2:11   ` Anton Altaparmakov
2002-07-25  5:15     ` Linus Torvalds
     [not found]     ` <Pine.LNX.4.44.0207242213540.1231-100000@home.transmeta.com >
2002-07-25  8:43       ` Anton Altaparmakov

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=8U0hkQ6Hw-B@khms.westfalen.de \
    --to=kaih@khms.westfalen.de \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®