X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=discover%2Fdevice-handler.c;h=cf379e78ca7f7ecc1f52adbca0fedc2e22903fa8;hb=c4be9490a5d94b662370576157b6e0ed73f2fe77;hp=9c050293df98cf446a44aa560ad3941dbfa4aa89;hpb=70a58a78c951403ae67c44c839caf0e77d0d84db;p=petitboot diff --git a/discover/device-handler.c b/discover/device-handler.c index 9c05029..cf379e7 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -1404,6 +1404,28 @@ int device_handler_dhcp(struct device_handler *handler, return 0; } +struct discover_boot_option *device_handler_find_option_by_name( + struct device_handler *handler, const char *device, + const char *name) +{ + size_t len = strlen(name); + unsigned int i; + + for (i = 0; i < handler->n_devices; i++) { + struct discover_device *dev = handler->devices[i]; + struct discover_boot_option *opt; + + list_for_each_entry(&dev->boot_options, opt, list) + /* Match exactly, partial matches can be quite common */ + if (strlen(opt->option->name) == len && + !strcmp(opt->option->name, name)) + if (!dev || !strcmp(opt->option->device_id, device)) + return opt; + } + + return NULL; +} + static struct discover_boot_option *find_boot_option_by_id( struct device_handler *handler, const char *id) {