]> git.ozlabs.org Git - petitboot/commitdiff
discover: populate sysinfo with block devices
authorJeremy Kerr <jk@ozlabs.org>
Fri, 15 Nov 2013 04:23:54 +0000 (15:23 +1100)
committerJeremy Kerr <jk@ozlabs.org>
Fri, 22 Nov 2013 02:45:54 +0000 (10:45 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/device-handler.c
discover/sysinfo.c
discover/sysinfo.h
test/parser/handler.c

index 725e491d1f6f9c87d11f1918826b049e0ba76885..9033c4fdfb8d3162417ed332e415b6446d33df8e 100644 (file)
@@ -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);
 
index 870e9a122a53a60f316d738770e4cc80daf7bac2..3c132774e21b3599e0c61e45b6ceaba5ebb847c3 100644 (file)
@@ -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;
index 2764784d57c0900b321625e2298a27ad4efdb266..d8ba33db9fd12c4faddfb0ea5711ad2cb0867c48 100644 (file)
@@ -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);
 
index 97ae3885a16f55eb088e0137c2f68893c0a29bb6..68d882b82174937bbdc50846d917876d1c59085a 100644 (file)
@@ -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)
 {
 }