blob: 380a17a245ca5a067c317f34b7434c14f1978ff0 [file] [log] [blame]
sewardj92ef1ed2006-10-17 01:04:15 +00001
2/* A program which prints its own syscall name-to-number bindings.
3 Used to generate the basis of include/vki/vki-scnums-aix5.h and
4 coregrind/m_vkiscnums.c. */
5
6#include <stdio.h>
7#include <sys/types.h>
8#include <unistd.h>
9#include <assert.h>
10
11#include <sys/procfs.h>
12
13#define NN 100000
14char buf[NN];
15int nbuf = 0;
16
17int main ( void )
18{
19 int i;
20 char name[50];
21 sprintf(name, "/proc/%d/sysent", getpid());
22 FILE* f = fopen(name, "r");
23 assert(f);
24 nbuf = fread(buf, 1, NN, f);
25 assert(nbuf > 0 && nbuf <= NN);
26
27 prsysent_t* header = (prsysent_t*)&buf[0];
28 if (0) printf("Found %u syscalls\n\n", header->pr_nsyscalls);
29
30 for (i = 0; i < header->pr_nsyscalls; i++) {
31 printf("%3u %s\n", header->pr_syscall[i].pr_number,
32 &buf[ header->pr_syscall[i].pr_nameoff ]);
33 }
34
35 fclose(f);
36 return 0;
37}