| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
#ifdef HAVE_CONFIG_H |
| 34 |
#include <config.h> |
| 35 |
#endif |
| 36 |
|
| 37 |
#include "probe-api.h" |
| 38 |
#include <stdlib.h> |
| 39 |
#include <string.h> |
| 40 |
#include <stdio.h> |
| 41 |
#include <stdio_ext.h> |
| 42 |
#include <errno.h> |
| 43 |
#include <dirent.h> |
| 44 |
#include <fcntl.h> |
| 45 |
#include <netdb.h> |
| 46 |
#include <arpa/inet.h> |
| 47 |
#include <regex.h> |
| 48 |
#include <sys/systeminfo.h> |
| 49 |
#include "../../../../common/debug_priv.h" |
| 50 |
#include "isainfo_probe.h" |
| 51 |
|
| 52 |
|
| 53 |
#define MAX_STR_RESULT 257 |
| 54 |
|
| 55 |
struct result_info { |
| 56 |
unsigned int bits; |
| 57 |
char kernel_isa[MAX_STR_RESULT]; |
| 58 |
char application_isa[MAX_STR_RESULT]; |
| 59 |
}; |
| 60 |
|
| 61 |
|
| 62 |
static void report_finding(struct result_info *res, probe_ctx *ctx) |
| 63 |
{ |
| 64 |
SEXP_t *item; |
| 65 |
|
| 66 |
item = probe_item_create(OVAL_SOLARIS_ISAINFO, NULL, |
| 67 |
"bits", OVAL_DATATYPE_INTEGER, (int64_t)res->bits, |
| 68 |
"kernel_isa", OVAL_DATATYPE_STRING, res->kernel_isa, |
| 69 |
"application_isa", OVAL_DATATYPE_STRING, res->application_isa, |
| 70 |
NULL); |
| 71 |
probe_item_collect(ctx, item); |
| 72 |
} |
| 73 |
|
| 74 |
int read_sysinfo(probe_ctx *ctx) { |
| 75 |
dD("In read_sysinfo for isainfo probe"); |
| 76 |
|
| 77 |
int err = 1; |
| 78 |
int ret = 0; |
| 79 |
char tmp_buf[MAX_STR_RESULT]; |
| 80 |
struct result_info result; |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
ret = sysinfo(SI_ARCHITECTURE_64, tmp_buf, MAX_STR_RESULT); |
| 85 |
|
| 86 |
if (ret != -1) { |
| 87 |
result.bits = 64; |
| 88 |
} |
| 89 |
else { |
| 90 |
result.bits = 32; |
| 91 |
} |
| 92 |
|
| 93 |
if (sysinfo(SI_ARCHITECTURE_K, result.kernel_isa, MAX_STR_RESULT) == -1) { |
| 94 |
return err; |
| 95 |
} |
| 96 |
#if defined(OS_SOLARIS) |
| 97 |
if ((sysinfo(SI_ARCHITECTURE_32, result.application_isa, MAX_STR_RESULT) == -1) && |
| 98 |
(sysinfo(SI_ARCHITECTURE_64, result.application_isa, MAX_STR_RESULT) == -1)) { |
| 99 |
#else |
| 100 |
if (sysinfo(SI_ARCHITECTURE_NATIVE, result.application_isa, MAX_STR_RESULT) == -1) { |
| 101 |
#endif |
| 102 |
return err; |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
err = 0; |
| 107 |
report_finding(&result, ctx); |
| 108 |
return err; |
| 109 |
} |
| 110 |
|
| 111 |
int isainfo_probe_main(probe_ctx *ctx, void *probe_arg) |
| 112 |
{ |
| 113 |
if (read_sysinfo(ctx)) { |
| 114 |
return PROBE_EACCESS; |
| 115 |
} |
| 116 |
|
| 117 |
return 0; |
| 118 |
} |