summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-04-16 16:58:18 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-04-29 14:41:04 +1000
commit5be946cda7b8e2271ade6188ca3f5dc068826619 (patch)
treea62a64792bb61aa57c5d8dac36c7df9756d01ef8 /discover/device-handler.c
parent4e8b779626da98e2896efbb2df99b64f76e878f6 (diff)
downloadtalos-petitboot-5be946cda7b8e2271ade6188ca3f5dc068826619.tar.gz
talos-petitboot-5be946cda7b8e2271ade6188ca3f5dc068826619.zip
discover: Change parsers to emit resources rather than filenames
This change switches the parsers over to populate the resources in discover_boot_option, rather than the string parameters in boot_option. To do this, we need a few things: * Add struct resources to discover_boot_option for the boot_image, initrd and icon data. * Have the parsers populate the resources, rather than the strings. Currently, parsers can all use the devpath resource type. * Add a resolve_resource callback to parsers; this is how the device handler will attempt to resolve resources. * Change load_file to load_url, as we should be only accessing (resolved) resources by URLs. This then allows us to remove the mount map, and associated lookup code, as well as the UUID and label links to devices. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c71
1 files changed, 4 insertions, 67 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 2b16b2e..950e730 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -130,73 +130,13 @@ const struct discover_device *device_handler_get_device(
return handler->devices[index];
}
-static void setup_device_links(struct discover_device *dev)
-{
- struct link {
- const char *dir, *val;
- } *link, links[] = {
- {
- .dir = "disk/by-uuid",
- .val = dev->uuid,
- },
- {
- .dir = "disk/by-label",
- .val = dev->label,
- },
- {
- .dir = NULL
- }
- };
-
- for (link = links; link->dir; link++) {
- char *enc, *dir, *path;
-
- if (!link->val || !*link->val)
- continue;
-
- enc = encode_label(dev, link->val);
- dir = join_paths(dev, mount_base(), link->dir);
- path = join_paths(dev, dir, enc);
-
- if (!pb_mkdir_recursive(dir)) {
- unlink(path);
- if (symlink(dev->mount_path, path)) {
- pb_log("symlink(%s,%s): %s\n",
- dev->mount_path, path,
- strerror(errno));
- talloc_free(path);
- } else {
- int i = dev->n_links++;
- dev->links = talloc_realloc(dev,
- dev->links, char *,
- dev->n_links);
- dev->links[i] = path;
- }
-
- }
-
- talloc_free(dir);
- talloc_free(enc);
- }
-}
-
-static void remove_device_links(struct discover_device *dev)
-{
- int i;
-
- for (i = 0; i < dev->n_links; i++)
- unlink(dev->links[i]);
-}
-
static int mount_device(struct discover_device *dev)
{
- const char *mountpoint;
const char *argv[6];
- if (!dev->mount_path) {
- mountpoint = mountpoint_for_device(dev->device_path);
- dev->mount_path = talloc_strdup(dev, mountpoint);
- }
+ if (!dev->mount_path)
+ dev->mount_path = join_paths(dev, mount_base(),
+ dev->device_path);
if (pb_mkdir_recursive(dev->mount_path))
pb_log("couldn't create mount directory %s: %s\n",
@@ -222,7 +162,6 @@ static int mount_device(struct discover_device *dev)
goto out_rmdir;
}
- setup_device_links(dev);
return 0;
out_rmdir:
@@ -235,8 +174,6 @@ static int umount_device(struct discover_device *dev)
int status;
pid_t pid;
- remove_device_links(dev);
-
if (!dev->mount_path)
return 0;
@@ -590,5 +527,5 @@ void device_handler_boot(struct device_handler *handler,
opt = find_boot_option_by_id(handler, cmd->option_id);
- boot(handler, opt->option, cmd, handler->dry_run);
+ boot(handler, opt, cmd, handler->dry_run);
}
OpenPOWER on IntegriCloud