#include <talloc/talloc.h>
#include <list/list.h>
#include <log/log.h>
-#include <pb-protocol/pb-protocol.h>
+#include <types/types.h>
#include <system/system.h>
#include "device-handler.h"
#include "parser.h"
#include "udev.h"
#include "paths.h"
-
-#define MOUNT_BIN "/bin/mount"
-
-#define UMOUNT_BIN "/bin/umount"
+#include "boot.h"
struct device_handler {
struct discover_server *server;
struct list contexts;
};
-struct mount_map {
- char *device_path;
- char *mount_point;
-};
-
/**
* device_handler_add - Add a device to the handler device array.
*/
pb_log("couldn't create mount directory %s: %s\n",
ctx->mount_path, strerror(errno));
- argv[0] = MOUNT_BIN;
+ argv[0] = pb_system_apps.mount;
argv[1] = ctx->device_path;
argv[2] = ctx->mount_path;
argv[3] = "-o";
/* Retry mount without ro option. */
- argv[0] = MOUNT_BIN;
+ argv[0] = pb_system_apps.mount;
argv[1] = ctx->device_path;
argv[2] = ctx->mount_path;
argv[3] = NULL;
}
if (pid == 0) {
- execl(UMOUNT_BIN, UMOUNT_BIN, ctx->mount_path, NULL);
+ execl(pb_system_apps.umount, pb_system_apps.umount,
+ ctx->mount_path, NULL);
exit(EXIT_FAILURE);
}
{
talloc_free(handler);
}
+
+static struct boot_option *find_boot_option_by_id(
+ struct device_handler *handler, const char *id)
+{
+ unsigned int i;
+
+ for (i = 0; i < handler->n_devices; i++) {
+ struct device *dev = handler->devices[i];
+ struct boot_option *opt;
+
+ list_for_each_entry(&dev->boot_options, opt, list)
+ if (!strcmp(opt->id, id))
+ return opt;
+ }
+
+ return NULL;
+}
+
+void device_handler_boot(struct device_handler *handler,
+ struct boot_command *cmd)
+{
+ struct boot_option *opt;
+
+ opt = find_boot_option_by_id(handler, cmd->option_id);
+
+ boot(handler, opt, cmd, 0);
+}