From: Mike Touloumtzis <miket@bluemug.com>
To: "Albert D. Cahalan" <acahalan@cs.uml.edu>
Cc: Alexander Viro <viro@math.psu.edu>,
Thunder from the hill <thunder@ngforever.de>,
Peter Chubb <peter@chubb.wattle.id.au>,
Pavel Machek <pavel@ucw.cz>,
Matt_Domsch@Dell.com, Andries.Brouwer@cwi.nl,
linux-kernel@vger.kernel.org
Subject: Re: 2.5.28 and partitions
Date: Fri, 2 Aug 2002 14:21:49 -0700 [thread overview]
Message-ID: <20020802212149.GC4528@bluemug.com> (raw)
In-Reply-To: <200208022049.g72KnHj453650@saturn.cs.uml.edu>
On Fri, Aug 02, 2002 at 04:49:17PM -0400, Albert D. Cahalan wrote:
> Mike Touloumtzis writes:
> > On Thu, Aug 01, 2002 at 05:24:37PM -0400, Albert D. Cahalan wrote:
>
> >> There's just that little overflow problem to worry about,
> >
> > Ummm:
> >
> > -- stuff ASCII digits into u64 (or u32, or whatever)
> > -- if (still more digits)
> > -- printk("partition too big to mount!\n")
> > -- return error
> >
> > How hard is that?
>
> I refer to overflowing the space allowed for your
> partition table. Programs will generate the data,
> then write it out. If the data gets too long, then
> you overwrite part of your first filesystem.
> Alternately, the partition table gets truncated
> at the maximum size -- with or without a '\0'.
Writing the partition table would still have to be done with
knowledge of its maximum size (i.e. the need to worry about
maximum partition table size wouldn't go away, just the need to
set a maximum size for every individual component in the table).
A program should write the ASCII representation into a buffer,
testing at that time for overflow. I certainly wouldn't
recommend:
FILE *f = fopen("/dev/hda", "r+");
fprintf(f, "%u %u %u%c", foo, bar, baz, '\0');
:-)
> But sure, overflowing a u64 is also a problem.
> This will not be checked for. Either the u64 will
> get overflowed, or the parser will take what fits
> and then mis-interpret the remaining digits as
> a second number.
Are you advocating the use of stupid parsers?
> > Don't write garbage into your partition table.
>
> I can see multiple ways for this to happen.
> Take the length of the new data, with or without
> the trailing '\0', and write it out. Write the
> whole partition table, including uninitialized
> data that happens to be in memory. (some other
> program will of course not ignore trailing garbage)
If programs writing the partition table know the amount of disk
allocated to the table they can zero-fill the rest (see above).
> >> encouragement of assumptions about the maximum size...
> >> is that a %d or a %llu or what?
> >
> > See above. Use leading '-' for negative numbers. ASCII has no
> > 2's complement ambiguity issues.
>
> You've got to stuff it into something eventually,
> unless you want to implement ASCII math. Will you
> be using plain C, or C++ operator overloading?
I think you are seeing phantom problems where obvious solutions
exist.
Of course you have to stuff the values into native binary formats
eventually. I'm just talking about on-disk representation,
not in-memory.
On output, you can use the biggest integer size the machine
supports, e.g. %llu, because you wouldn't be able to handle the
partition at all if it was just too big for your machine. Or you
use bignums and something other than printf(3). Your attempt
to smear this approach by illogically associating it with C++
operator overloading is ridiculous.
On input, if a value is too big to handle, you just
fprintf(stderr, "Partition too big, tough luck for you!\n");
Or, in the kernel, you refuse to mount it.
Or if you really want to handle big numbers, you use a bignum
package for fdisk. It's not like there's a magic solution with
_current_ partition tables for handling numbers that are too big.
The current approach to this kind of problem in the kernel is
more or less:
-- Choose a structure which imposes a size limit for every value.
-- When _any_ of those limits overflows, switch to a whole new
structure. Implement new code branches, syscalls, etc. as
needed to handle both old and new versions.
Frankly, that sucks.
> Yeah, just what we need. The /proc mess expanding
> into partition tables. That sounds like a great way
> to increase filesystem destruction performance.
The /proc mess exists because people chose N ad hoc output
formats for /proc files. If they had a consistent format like
s-expressions or one-value-per-file most problems with /proc
would not exist.
I'm just putting my hope in the belief that sooner or later Al Viro
will realize that there's a lot more similarity between the Plan
9 and Lisp/Scheme approaches to simple, architecture-independent
representations than he thinks, and swoop in to clean up this
mess :-).
miket
next prev parent reply other threads:[~2002-08-02 21:18 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 ` 2.5.28 and partitions Alexander Viro
2002-08-01 10:08 ` Marcin Dalecki
2002-08-01 12:31 ` Kai Henningsen
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 [this message]
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=20020802212149.GC4528@bluemug.com \
--to=miket@bluemug.com \
--cc=Andries.Brouwer@cwi.nl \
--cc=Matt_Domsch@Dell.com \
--cc=acahalan@cs.uml.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=peter@chubb.wattle.id.au \
--cc=thunder@ngforever.de \
--cc=viro@math.psu.edu \
/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