summaryrefslogtreecommitdiffstats
path: root/discover/sysinfo.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-07-23 14:03:42 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-08-05 10:49:31 +0800
commit6897abaa97a02e0ab8ac07209a5e4966bfe101c5 (patch)
tree6592de1ffd41310aeefdbe58d41928f21baeed71 /discover/sysinfo.c
parent052961eb2e8279f103c091e850c317da335c0207 (diff)
downloadtalos-petitboot-6897abaa97a02e0ab8ac07209a5e4966bfe101c5.tar.gz
talos-petitboot-6897abaa97a02e0ab8ac07209a5e4966bfe101c5.zip
discover: Use platform code to read sysinfo type and identifier
This change uses the platform-specific code to read the system type and identifier, rather than the pb-sysinfo utility. We introduce a new callback for struct platform: int (*get_sysinfo)(struct platform *, struct system_info *); - which populates struct system_info with appropriate information. This means that the system-specific code is kept in one place; rather than having powerpc-specific device-tree-reading code in the pb-sysinfo shell script. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/sysinfo.c')
-rw-r--r--discover/sysinfo.c37
1 files changed, 2 insertions, 35 deletions
diff --git a/discover/sysinfo.c b/discover/sysinfo.c
index be45438..219369a 100644
--- a/discover/sysinfo.c
+++ b/discover/sysinfo.c
@@ -5,13 +5,12 @@
#include <process/process.h>
#include "discover-server.h"
+#include "platform.h"
#include "sysinfo.h"
static struct system_info *sysinfo;
static struct discover_server *server;
-static const char *sysinfo_helper = PKG_LIBEXEC_DIR "/pb-sysinfo";
-
const struct system_info *system_info_get(void)
{
return sysinfo;
@@ -102,41 +101,9 @@ void system_info_register_blockdev(const char *name, const char *uuid,
discover_server_notify_system_info(server, sysinfo);
}
-static void system_info_set_identifier(struct system_info *info)
-{
- struct process *process;
- int rc;
- const char *argv[] = {
- sysinfo_helper, NULL, NULL,
- };
-
- process = process_create(info);
- process->path = sysinfo_helper;
- process->argv = argv;
- process->keep_stdout = true;
-
- argv[1] = "--type";
- rc = process_run_sync(process);
-
- if (!rc) {
- info->type = talloc_strndup(info, process->stdout_buf,
- process->stdout_len);
- }
-
- argv[1] = "--id";
- rc = process_run_sync(process);
-
- if (!rc) {
- info->identifier = talloc_strndup(info, process->stdout_buf,
- process->stdout_len);
- }
-
- process_release(process);
-}
-
void system_info_init(struct discover_server *s)
{
server = s;
sysinfo = talloc_zero(server, struct system_info);
- system_info_set_identifier(sysinfo);
+ platform_get_sysinfo(sysinfo);
}
OpenPOWER on IntegriCloud