[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating partitions relative to the end of the disk

From: Andrew Clausen
Subject: Re: Creating partitions relative to the end of the disk
Date: Thu, 14 Mar 2002 21:36:38 +1100
User-agent: Mutt/1.3.17i

On Thu, Mar 14, 2002 at 12:28:35AM +1100, Timshel Knoll wrote:
> I've hacked command_line_get_sector to allow specifing partitions
> relative to the end of the disk. If a value has a '-' sign in front of
> it, it is treated as as being a distance from the end of the disk. (ie.
> on a 3000MB disk, -60 will yield 2940 in real terms). The patch is
> trivial, there shouldn't be anything wrong with it (although I haven't
> tested it extensively, there shouldn't be anything that _can_ go wrong,
> as the consistency checks happen after this modification is done ...)

Looks reasonable.  Perhaps there will be i18n issues?  I doubt it.

> An alternative syntax for this could be to implement an expression
> parser in parted's code, and allow for pseudo-variables like "disk.end".
> This way the user could specify things like:
> "mkpart primary linux-swap disk.end - 128 disk.end"
> to create a linux swap partition in the last 128MB of the disk. Hrm,
> maybe this is a reason to write "tmsh" and integrate it as an embedded

* clausen BASHes Timshel(l) over the head

> scripting language within parted (variables, arithmetic, conditionals,
> loops et al ...) ;-)

"Parted is a nice operating system, but lacks a good partitioning tool"

> mkpartfs logical ext3 usr
> if need_var { mkpartfs logical ext3 var }
> mkpartfs logical ext3 home
> <end parted "etmsh" syntax> :-)

Very funny, but no!

> Maybe I need to start honing my lex/yacc skills :-)

My lex/yacc skillz are up-to-scratch.  As much as I love them... NO.
Go use python or something.

>       snprintf (def_str, 16, "%.4f", (float) def / MEGABYTE_SECTORS);
>       input = command_line_get_word (prompt, def ? def_str : NULL, NULL, 1);
>       if (!input)
>               return 0;
> -     valid = sscanf (input, "%Lf", &input_double);
> +     for (i = 0; input[i] != '\0' && isspace (input[i]); i++)
> +             ;

Ugly.  Perhaps command_line_get_word() should be doing that.
(Except when the text is quoted, or something, for partition names,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]