setup_harddisks_2 proposal

Sam Vilain sam at vilain.net
Thu Jun 8 07:48:17 CEST 2006


Michael Tautschnig wrote:
> Hi all!
>
> I've put my proposal for a new disk configuration file format and some results
> of the discussion in the wiki:
>
> http://faiwiki.debian.net/index.php/Setup_harddisks_2
>
> Regards,
> Michael
>
>   

Here's a quick crack at a conversion of your grammar to
Parse::RecDescent - considered using that module for the parsing of this?

    my $Parser = Parse::RecDescent->new(q{
        file: line(s?) /\Z/
        line: /$/
            | comment /$/
            | config /$/
        comment: /\s*#.*$/
        config:
              'disk_config' disk_config_arg
            | volume
        disk_config_arg:
              'raid'
            | 'lvm'
            | /disk\d+/ option(s?)
            | /\S/ option(s?)
        option:
              /preserve:\d+(,\d+)*/
            | /disklabel:(msdos|sun)/
            | /bootable:\d/
            | 'virtual'
        volume:
              type mountpoint size filesystem mount_options fs_options
            | 'vg' name size
        type: 'primary'
            | 'logical'
            | /raid[0156]/
            | m{[^/\s]+-[^/\s]+}
        mountpoint:
              '-'
            | 'swap'
            | m{/\S*}
        name: /\S+/
        size: /\d+%?(-\d+%?)?(:resize)?/
            | /-\d+%?(:resize)?/
            | /preserve\d+/
            | /[^,:\s]+(:(spare|missing))*(,[^,:\s]+(:(spare|missing))*)*/
        mount_options:
              /\S+/
        filesystem:
              '-'
            | 'swap'
            | \S+
              { if ( !in_path("mkfs.$item[0]") ) {
                    die "unknown/invalid filesystem type '$item[0]'"
                }
              }
        fs_options:
              /.*$/
    });

Something like that, anyway - it still needs generating blocks on each
rule to return a data structure and I'm not sure I got the :spare rule
right, it seems a little odd.

I might have a crack at fitting this parser into the 'old'
setup_harddisks (well, the one I refactored), as well as switching it to
use parted.  Most of the questions about, eg, what order to do things in
are already solved in the functions in that script.

Otherwise, just go ahead and lift out functions from that code for what
you're doing as you find them useful.

Sam.



More information about the linux-fai-devel mailing list