0

for example there are some macros in the unistd_64.h

...

#define __NR_semget 64

#define __NR_semop 65

#define __NR_semctl 66

#define __NR_shmdt 67

#define __NR_msgget 68

#define __NR_msgsnd 69

...

when I input a number

64

, it will output

__NR_semget or semget

c/cpp source code is much better,thank you!

Jialin
  • 2,415
  • 2
  • 14
  • 10

2 Answers2

0

One way you can do that is by defining an array of strings representing the name of those definitions. There's no shortcut, unfortunately...

const char *name[] = {

    ...,

    /* this is now the 64th string... */
    "__NR_semget",
    "__NR_semop",

    ...
};

printf("name: %s\n", name[64]);
n3rd4n1
  • 371
  • 2
  • 8
  • I've considered your way before,as you said "There's no shortcut",it's not so good,but it works actually,thanks for your answer. – Jialin Jul 24 '14 at 08:40
  • [https://github.com/linnv/OpenDemo/blob/master/syscall_array/disabled_syscall_x64.h] just like line 347th. – Jialin Jul 24 '14 at 09:15
0

Syscall name and number mapping is largly dependent on the arch you are using.

ausyscall - provides mapping given the syscall number. Maybe you could do something like:

system("ausyscall 64 x86_64")

This should return semget

askb
  • 6,501
  • 30
  • 43