|
2 | 2 | #include <stdio.h>
|
3 | 3 | #include <stdlib.h>
|
4 | 4 | #include <string.h>
|
| 5 | +#include <unistd.h> |
5 | 6 |
|
| 7 | +#define _PATH_CAT "/bin/cat" |
6 | 8 | #define _PATH_NM "/usr/bin/nm"
|
7 | 9 | #define _PATH_SORT "/usr/bin/sort"
|
8 | 10 |
|
@@ -123,12 +125,24 @@ int
|
123 | 125 | ksyms_load(void)
|
124 | 126 | {
|
125 | 127 | FILE *fh;
|
126 |
| - char cmdline[512]; /* "/usr/bin/nm /dev/ksyms | sort" */ |
| 128 | + char tmpfile1[512]; |
| 129 | + char tmpfile2[512]; |
| 130 | + char cmdline[512]; /* "/bin/cat /dev/ksyms > /tmp/$$.2; /usr/bin/nm /tmp/$$.2 | sort > $$.2" */ |
127 | 131 | char linebuf[1024];
|
| 132 | + pid_t pid = getpid(); |
128 | 133 |
|
129 |
| - snprintf(cmdline, sizeof(cmdline), "%s %s | %s", _PATH_NM, _PATH_KSYMS, _PATH_SORT); |
| 134 | + snprintf(tmpfile1, sizeof(tmpfile1), "/tmp/softintdump.tmp1.%u", pid); |
| 135 | + snprintf(tmpfile2, sizeof(tmpfile2), "/tmp/softintdump.tmp2.%u", pid); |
| 136 | + snprintf(cmdline, sizeof(cmdline), "%s %s > %s; %s %s | %s > %s", _PATH_CAT, _PATH_KSYMS, tmpfile1, _PATH_NM, tmpfile1, _PATH_SORT, tmpfile2); |
130 | 137 |
|
131 |
| - fh = popen(cmdline, "r"); |
| 138 | + /* XXX */ |
| 139 | + system(cmdline); |
| 140 | + unlink(tmpfile1); |
| 141 | + fh = fopen(tmpfile2, "r"); |
| 142 | + unlink(tmpfile2); |
| 143 | + |
| 144 | + if (fh == NULL) |
| 145 | + return -1; |
132 | 146 |
|
133 | 147 | while (fgets(linebuf, sizeof(linebuf), fh) != NULL) {
|
134 | 148 | #define MAXPARAMS 8
|
@@ -168,7 +182,7 @@ main(int argc, char *argv[])
|
168 | 182 | {
|
169 | 183 | ksyms_load();
|
170 | 184 |
|
171 |
| - printf("%s\n", ksyms_lookupsym(0xffffffff815c9b88ULL)); |
| 185 | + printf("%s\n", ksyms_lookupsym(0xffffffff80e38440ULL)); |
172 | 186 | printf("0x%llx\n", ksyms_lookup("sigill_debug"));
|
173 | 187 |
|
174 | 188 | }
|
|
0 commit comments