diff options
-rw-r--r-- | discover/device-handler.c | 5 | ||||
-rw-r--r-- | discover/sysinfo.c | 34 | ||||
-rw-r--r-- | discover/sysinfo.h | 2 | ||||
-rw-r--r-- | test/parser/handler.c | 8 |
4 files changed, 49 insertions, 0 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c index 725e491..9033c4f 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -23,6 +23,7 @@ #include "parser.h" #include "resource.h" #include "paths.h" +#include "sysinfo.h" #include "boot.h" struct device_handler { @@ -602,6 +603,10 @@ int device_handler_discover(struct device_handler *handler, if (rc) goto out; + /* add this device to our system info */ + system_info_register_blockdev(dev->device->id, dev->uuid, + dev->mount_path); + /* run the parsers. This will populate the ctx's boot_option list. */ iterate_parsers(ctx); diff --git a/discover/sysinfo.c b/discover/sysinfo.c index 870e9a1..3c13277 100644 --- a/discover/sysinfo.c +++ b/discover/sysinfo.c @@ -53,6 +53,40 @@ void system_info_register_interface(unsigned int hwaddr_size, uint8_t *hwaddr, discover_server_notify_system_info(server, sysinfo); } +void system_info_register_blockdev(const char *name, const char *uuid, + const char *mountpoint) +{ + struct blockdev_info *bd_info; + unsigned int i; + + for (i = 0; i < sysinfo->n_blockdevs; i++) { + bd_info = sysinfo->blockdevs[i]; + + if (strcmp(bd_info->name, name)) + continue; + + /* update the mountpoint and UUID, and we're done */ + talloc_free(bd_info->mountpoint); + bd_info->uuid = talloc_strdup(bd_info, uuid); + bd_info->mountpoint = talloc_strdup(bd_info, mountpoint); + discover_server_notify_system_info(server, sysinfo); + return; + } + + bd_info = talloc_zero(sysinfo, struct blockdev_info); + bd_info->name = talloc_strdup(bd_info, name); + bd_info->uuid = talloc_strdup(bd_info, uuid); + bd_info->mountpoint = talloc_strdup(bd_info, mountpoint); + + sysinfo->n_blockdevs++; + sysinfo->blockdevs = talloc_realloc(sysinfo, sysinfo->blockdevs, + struct blockdev_info *, + sysinfo->n_blockdevs); + sysinfo->blockdevs[sysinfo->n_blockdevs - 1] = bd_info; + + discover_server_notify_system_info(server, sysinfo); +} + static void system_info_set_identifier(struct system_info *info) { struct process *process; diff --git a/discover/sysinfo.h b/discover/sysinfo.h index 2764784..d8ba33d 100644 --- a/discover/sysinfo.h +++ b/discover/sysinfo.h @@ -9,6 +9,8 @@ const struct system_info *system_info_get(void); void system_info_register_interface(unsigned hwaddr_size, uint8_t *hwaddr, const char *name); +void system_info_register_blockdev(const char *name, const char *uuid, + const char *mountpoint); void system_info_init(struct discover_server *server); diff --git a/test/parser/handler.c b/test/parser/handler.c index 97ae388..68d882b 100644 --- a/test/parser/handler.c +++ b/test/parser/handler.c @@ -43,6 +43,14 @@ void discover_server_notify_config(struct discover_server *server, (void)config; } +void system_info_register_blockdev(const char *name, const char *uuid, + const char *mountpoint) +{ + (void)name; + (void)uuid; + (void)mountpoint; +} + void parser_init(void) { } |