diff options
-rw-r--r-- | discover/device-handler.c | 41 | ||||
-rw-r--r-- | discover/network.c | 1 | ||||
-rw-r--r-- | discover/udev.c | 6 | ||||
-rw-r--r-- | discover/udev.h | 2 |
4 files changed, 49 insertions, 1 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c index 352a477..f5dc32c 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -57,6 +57,7 @@ static int mount_device(struct discover_device *dev); static int umount_device(struct discover_device *dev); static int device_handler_init_sources(struct device_handler *handler); +static void device_handler_reinit_sources(struct device_handler *handler); void discover_context_add_boot_option(struct discover_context *ctx, struct discover_boot_option *boot_option) @@ -293,6 +294,31 @@ struct device_handler *device_handler_init(struct discover_server *server, return handler; } +static void device_handler_reinit(struct device_handler *handler) +{ + struct discover_boot_option *opt, *tmp; + unsigned int i; + + device_handler_cancel_default(handler); + + /* free unresolved boot options */ + list_for_each_entry_safe(&handler->unresolved_boot_options, + opt, tmp, list) + talloc_free(opt); + list_init(&handler->unresolved_boot_options); + + /* drop all devices */ + for (i = 0; i < handler->n_devices; i++) + discover_server_notify_device_remove(handler->server, + handler->devices[i]->device); + + talloc_free(handler->devices); + handler->devices = NULL; + handler->n_devices = 0; + + device_handler_reinit_sources(handler); +} + void device_handler_remove(struct device_handler *handler, struct discover_device *device) { @@ -763,6 +789,7 @@ void device_handler_update_config(struct device_handler *handler, { config_set(config); discover_server_notify_config(handler->server, config); + device_handler_reinit(handler); } #ifndef PETITBOOT_TEST @@ -786,6 +813,15 @@ static int device_handler_init_sources(struct device_handler *handler) return 0; } +static void device_handler_reinit_sources(struct device_handler *handler) +{ + udev_reinit(handler->udev); + + network_shutdown(handler->network); + handler->network = network_init(handler, handler->waitset, + handler->dry_run); +} + static bool check_existing_mount(struct discover_device *dev) { struct stat devstat, mntstat; @@ -953,6 +989,11 @@ static int device_handler_init_sources( return 0; } +static void device_handler_reinit_sources( + struct device_handler *handler __attribute__((unused))) +{ +} + static int umount_device(struct discover_device *dev __attribute__((unused))) { return 0; diff --git a/discover/network.c b/discover/network.c index 9acd4cb..ca4cc44 100644 --- a/discover/network.c +++ b/discover/network.c @@ -584,7 +584,6 @@ err: return NULL; } - int network_shutdown(struct network *network) { struct interface *interface; diff --git a/discover/udev.c b/discover/udev.c index 320dffd..7db36a7 100644 --- a/discover/udev.c +++ b/discover/udev.c @@ -469,3 +469,9 @@ fail_new: talloc_free(udev); return NULL; } + +void udev_reinit(struct pb_udev *udev) +{ + pb_log("udev: reinit requested, starting enumeration\n"); + udev_enumerate(udev->udev); +} diff --git a/discover/udev.h b/discover/udev.h index edd18fa..c0fa5c0 100644 --- a/discover/udev.h +++ b/discover/udev.h @@ -8,4 +8,6 @@ struct waitset; struct pb_udev *udev_init(struct device_handler *handler, struct waitset *waitset); +void udev_reinit(struct pb_udev *udev); + #endif /* _UDEV_H */ |