Patchwork Filo: rework device string parser

login
register
about
Submitter Patrick Georgi
Date 2011-03-17 13:08:34
Message ID <1300367314.2421.11.camel@linux-0a8x.site>
Download mbox | patch
Permalink /patch/2799/
State Not Applicable
Headers show

Comments

Patrick Georgi - 2011-03-17 13:08:34
Hi,

attached patches rework the device string parser in FILO so it should be
easier to understand, and adds some more ways to specify
devices/partitions. Specifically:

2-refactor-dev-parsing.diff:
- copy_path_to_filo_bootline() erases the target location instead
  of expecting the callers to do so
- callers of copy_path_to_filo_bootline() don't erase the target
  variables themselves.

This fixes an issue where the function is called without the variable
being erased. I couldn't think of any plausible scenario in which the
old behaviour is desirable.


3-rewrite-drive-specification-parser.diff:
- copy_path_to_filo_bootline is rewritten for clarity.
- copy_path_to_filo_bootline now supports @address syntax in grub-style
  device names.
- use strtoul instead of a custom number parser (theoretically allows
  for >99 disks/partitions, but I guess we'll never have to work with
  that)

The old implementation of the function was a mess of hidden state
dragged around in incidental configuration in variables. The current
code flow should be easier to follow.

4-handle-partition-only-changes.diff:
- Allow new syntax "(,N)" (grub-style) or "N:" (filo/linux-style) which
  simply switches to a different partition on the current device.

Use case: one partition with filo.lst, another with kernels, filo.lst
references the kernel as "5:/boot/kernel" and it works no matter the
drive name.

Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com>

Patch

Index: filo/main/grub/builtins.c

===================================================================
--- filo.orig/main/grub/builtins.c

+++ filo/main/grub/builtins.c

@@ -747,6 +747,12 @@  void copy_path_to_filo_bootline(char *ar

 		arg += i;
 	}
 
+	if ((disk == -1) && (part != -1) && (strlen(drivername) == 0)) {

+		// special case for partition-only identifiers:

+		// take driver and disk number from root_device

+		i = parse_linux_style_driver(root_device, drivername, &disk);

+ 	}

+

 	path[0] = 0;
 	if ((use_rootdev == 1) && (strlen(drivername) == 0)) {
 		strncpy(path, root_device, BOOT_LINE_LENGTH);