Skip to content

Commit 0750287

Browse files
committed
fix to work on netbsd/current
1 parent df68846 commit 0750287

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

ksyms_subr.c

+18-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#include <stdio.h>
33
#include <stdlib.h>
44
#include <string.h>
5+
#include <unistd.h>
56

7+
#define _PATH_CAT "/bin/cat"
68
#define _PATH_NM "/usr/bin/nm"
79
#define _PATH_SORT "/usr/bin/sort"
810

@@ -123,12 +125,24 @@ int
123125
ksyms_load(void)
124126
{
125127
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" */
127131
char linebuf[1024];
132+
pid_t pid = getpid();
128133

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);
130137

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;
132146

133147
while (fgets(linebuf, sizeof(linebuf), fh) != NULL) {
134148
#define MAXPARAMS 8
@@ -168,7 +182,7 @@ main(int argc, char *argv[])
168182
{
169183
ksyms_load();
170184

171-
printf("%s\n", ksyms_lookupsym(0xffffffff815c9b88ULL));
185+
printf("%s\n", ksyms_lookupsym(0xffffffff80e38440ULL));
172186
printf("0x%llx\n", ksyms_lookup("sigill_debug"));
173187

174188
}

ksyms_subr.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
int ksyms_load(void);
55
void ksyms_destroy(void);
66
void ksyms_dump(void);
7-
const char *ksyms_lookupsym(uintptr_t);
7+
const char *ksyms_lookupsym(unsigned long);
88
uintptr_t ksyms_lookup(const char *);
99

1010
#endif /* _KSYMS_SUBR_H_ */

0 commit comments

Comments
 (0)