#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;
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);
}