diff options
author | Maarten Lankhorst <m.b.lankhorst@gmail.com> | 2011-08-03 23:51:10 +0200 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2011-08-08 16:06:23 +0100 |
commit | b9680f1c1dee2905d77ae8c3e16485e90dc400b2 (patch) | |
tree | 8636434fa95f5568223077734cf9ca2f42960d9b | |
parent | ffc71643e27ada252fa06d68f1ca76ceda999c92 (diff) | |
download | efilinux-b9680f1c1dee2905d77ae8c3e16485e90dc400b2.tar.gz |
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@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r-- | fs/fs.c | 34 |
1 files changed, 27 insertions, 7 deletions
@@ -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); |