[syslinux] efilinux release 0.8

Matt Fleming matt at console-pimps.org
Mon Aug 8 08:09:01 PDT 2011


On Wed, 2011-08-03 at 23:51 +0200, Maarten Lankhorst wrote:
> 
> Yuck, it's case sensitive and it requires you to type all that?
> Here's a patch to accept 0:\vmlinuz initrd=0:\initrd.img and zap the sensitivity.
> 
> I alter name in file_open, but it seems nothing else requires it anyhow,
> so I didn't see a need to copy or revert it.
> 
> For what it's worth, it didn't seem to boot on my asrock P67 pro3.
> 
> Signed-off-by: Maarten Lankhorst <m.b.lankhorst at gmail.com>

Thanks! I modified the whitespace a little to be consistent with the
rest of the file and expanded the changelog. Does this look OK to you?
If so I'll apply it.

--------8<--------

>From b9680f1c1dee2905d77ae8c3e16485e90dc400b2 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date: Wed, 3 Aug 2011 23:51:10 +0200
Subject: [PATCH] fs: Add device numbers as synonyms for full device paths

Here's a patch to accept 0:\vmlinuz initrd=0:\initrd.img and zap the
case sensitivity when looking up device paths. The device numbers
correspond to the position of the device in the efilinux -l list.

I alter 'name' in file_open, but it seems nothing else requires it
anyhow, so I didn't see a need to copy or revert it.

Signed-off-by: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Signed-off-by: Matt Fleming <matt.fleming at intel.com>
---
 fs/fs.c |   34 +++++++++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index b799c00..6d6d58c 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -66,6 +66,25 @@ file_open(CHAR16 *name, struct file **file)
 	if (!f)
 		return EFI_OUT_OF_RESOURCES;
 
+	for (dev_len = 0; name[dev_len]; ++dev_len) {
+		if (name[dev_len] == ':')
+			break;
+	}
+
+	if (!name[dev_len] || !dev_len)
+		goto notfound;
+
+	name[dev_len] = 0;
+
+	if (name[0] >= '0' && name[0] <= '9') {
+		i = Atoi(name);
+		if (i >= nr_fs_devices)
+			goto notfound;
+
+		f->handle = fs_devices[i].fh;
+		goto found;
+	}
+
 	for (i = 0; i < nr_fs_devices; i++) {
 		EFI_DEVICE_PATH *path;
 		CHAR16 *dev;
@@ -73,9 +92,8 @@ file_open(CHAR16 *name, struct file **file)
 		path = DevicePathFromHandle(fs_devices[i].handle);
 		dev = DevicePathToStr(path);
 
-		if (!StrnCmp(dev, name, StrLen(dev))) {
+		if (!StriCmp(dev, name)) {
 			f->handle = fs_devices[i].fh;
-			dev_len = StrLen(dev);
 			free_pool(dev);
 			break;
 		}
@@ -83,13 +101,12 @@ file_open(CHAR16 *name, struct file **file)
 		free_pool(dev);
 	}
 
-	if (i == nr_fs_devices) {
-		err = EFI_NOT_FOUND;
-		goto fail;
-	}
+	if (i == nr_fs_devices)
+		goto notfound;
 
+found:
 	/* Strip the device name */
-	filename = name + dev_len;
+	filename = name + dev_len + 1;
 
 	/* skip any path separators */
 	while (*filename == ':' || *filename == '\\')
@@ -104,6 +121,9 @@ file_open(CHAR16 *name, struct file **file)
 	*file = f;
 
 	return err;
+
+notfound:
+	err = EFI_NOT_FOUND;
 fail:
 	Print(L"Unable to open file \"%s\"", name);
 	free(f);
-- 
1.7.4.4





More information about the Syslinux mailing list