|
|
36520b |
From bc215d06720b346ba0d888a6149cf90f544a90ad Mon Sep 17 00:00:00 2001
|
|
|
36520b |
From: Peter Jones <pjones@redhat.com>
|
|
|
36520b |
Date: Wed, 20 Jun 2018 17:00:24 -0400
|
|
|
36520b |
Subject: [PATCH 16/39] If we can't parse part of the device link, skip it and
|
|
|
36520b |
set DEV_ABBREV_ONLY
|
|
|
36520b |
|
|
|
36520b |
If we can't parse some part of the device symlink, we can't write a full
|
|
|
36520b |
device path, but we can write an abbreviated HD() or File() path. So if
|
|
|
36520b |
we've exausted all possibilities, skip to the next node, set
|
|
|
36520b |
DEV_ABBREV_ONLY in the device's flags, and try parsing again. Then when
|
|
|
36520b |
creator.c checks if that flag conflicts, it'll throw an error if it
|
|
|
36520b |
does.
|
|
|
36520b |
|
|
|
36520b |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
36520b |
---
|
|
|
36520b |
src/linux.c | 62 ++++++++++++++++++++++++++++++++++++++++-------------
|
|
|
36520b |
1 file changed, 47 insertions(+), 15 deletions(-)
|
|
|
36520b |
|
|
|
36520b |
diff --git a/src/linux.c b/src/linux.c
|
|
|
36520b |
index 1e7db4e3f61..8fe21f19f78 100644
|
|
|
36520b |
--- a/src/linux.c
|
|
|
36520b |
+++ b/src/linux.c
|
|
|
36520b |
@@ -429,14 +429,17 @@ struct device HIDDEN
|
|
|
36520b |
|
|
|
36520b |
const char *current = dev->link;
|
|
|
36520b |
bool needs_root = true;
|
|
|
36520b |
+ int last_successful_probe = -1;
|
|
|
36520b |
|
|
|
36520b |
debug(DEBUG, "searching for device nodes in %s", dev->link);
|
|
|
36520b |
for (i = 0; dev_probes[i] && dev_probes[i]->parse; i++) {
|
|
|
36520b |
struct dev_probe *probe = dev_probes[i];
|
|
|
36520b |
ssize_t pos;
|
|
|
36520b |
|
|
|
36520b |
- if (!needs_root && (probe->flags & DEV_PROVIDES_ROOT)) {
|
|
|
36520b |
- debug(DEBUG, "not testing %s because flags is 0x%x", probe->name, probe->flags);
|
|
|
36520b |
+ if (!needs_root &&
|
|
|
36520b |
+ (probe->flags & DEV_PROVIDES_ROOT)) {
|
|
|
36520b |
+ debug(DEBUG, "not testing %s because flags is 0x%x",
|
|
|
36520b |
+ probe->name, probe->flags);
|
|
|
36520b |
continue;
|
|
|
36520b |
}
|
|
|
36520b |
|
|
|
36520b |
@@ -445,22 +448,51 @@ struct device HIDDEN
|
|
|
36520b |
if (pos < 0) {
|
|
|
36520b |
efi_error("parsing %s failed", probe->name);
|
|
|
36520b |
goto err;
|
|
|
36520b |
- } else if (pos == 0) {
|
|
|
36520b |
+ } else if (pos > 0) {
|
|
|
36520b |
+ debug(DEBUG, "%s matched %s", probe->name, current);
|
|
|
36520b |
+ dev->flags |= probe->flags;
|
|
|
36520b |
+
|
|
|
36520b |
+ if (probe->flags & DEV_PROVIDES_HD ||
|
|
|
36520b |
+ probe->flags & DEV_PROVIDES_ROOT ||
|
|
|
36520b |
+ probe->flags & DEV_ABBREV_ONLY)
|
|
|
36520b |
+ needs_root = false;
|
|
|
36520b |
+
|
|
|
36520b |
+ dev->probes[n++] = dev_probes[i];
|
|
|
36520b |
+ current += pos;
|
|
|
36520b |
+ debug(DEBUG, "current:%s", current);
|
|
|
36520b |
+ last_successful_probe = i;
|
|
|
36520b |
+
|
|
|
36520b |
+ if (!*current || !strncmp(current, "block/", 6))
|
|
|
36520b |
+ break;
|
|
|
36520b |
+
|
|
|
36520b |
continue;
|
|
|
36520b |
}
|
|
|
36520b |
- debug(DEBUG, "%s matched %s", probe->name, current);
|
|
|
36520b |
- dev->flags |= probe->flags;
|
|
|
36520b |
|
|
|
36520b |
- if (probe->flags & DEV_PROVIDES_HD ||
|
|
|
36520b |
- probe->flags & DEV_PROVIDES_ROOT ||
|
|
|
36520b |
- probe->flags & DEV_ABBREV_ONLY)
|
|
|
36520b |
- needs_root = false;
|
|
|
36520b |
- dev->probes[n++] = dev_probes[i];
|
|
|
36520b |
- current += pos;
|
|
|
36520b |
- debug(DEBUG, "current:%s", current);
|
|
|
36520b |
-
|
|
|
36520b |
- if (!*current || !strncmp(current, "block/", 6))
|
|
|
36520b |
- break;
|
|
|
36520b |
+ debug(DEBUG, "dev_probes[i+1]: %p dev->interface_type: %d\n",
|
|
|
36520b |
+ dev_probes[i+1], dev->interface_type);
|
|
|
36520b |
+ if (dev_probes[i+1] == NULL && dev->interface_type == unknown) {
|
|
|
36520b |
+ int new_pos = 0;
|
|
|
36520b |
+ rc = sscanf(current, "%*[^/]/%n", &new_pos);
|
|
|
36520b |
+ if (rc < 0) {
|
|
|
36520b |
+ efi_error(
|
|
|
36520b |
+ "Cannot parse device link segment \"%s\"",
|
|
|
36520b |
+ current);
|
|
|
36520b |
+ goto err;
|
|
|
36520b |
+ }
|
|
|
36520b |
+ debug(DEBUG,
|
|
|
36520b |
+ "Cannot parse device link segment \"%s\"",
|
|
|
36520b |
+ current);
|
|
|
36520b |
+ debug(DEBUG, "Skipping to \"%s\"", current + new_pos);
|
|
|
36520b |
+ debug(DEBUG,
|
|
|
36520b |
+ "This means we can only write abbreviated paths");
|
|
|
36520b |
+ if (rc < 0)
|
|
|
36520b |
+ goto err;
|
|
|
36520b |
+ if (new_pos == 0)
|
|
|
36520b |
+ goto err;
|
|
|
36520b |
+ dev->flags |= DEV_ABBREV_ONLY;
|
|
|
36520b |
+ i = last_successful_probe;
|
|
|
36520b |
+ current += new_pos;
|
|
|
36520b |
+ }
|
|
|
36520b |
}
|
|
|
36520b |
|
|
|
36520b |
if (dev->interface_type == unknown) {
|
|
|
36520b |
--
|
|
|
36520b |
2.17.1
|
|
|
36520b |
|