b2d352e2286b75661dd5e0dbd2790eb8a9e426a6
[fprobe-ulog.git] / src / vserver.h
1 #ifndef __VSERVER_H__
2 #define __VSERVER_H__
3
4 #define __NR_vserver 273
5
6 #include <sys/syscall.h>
7 #include <stdint.h>
8 #include <stdlib.h>
9 #include <errno.h>
10
11 #define VC_CMD(c, i, v)         (((c & 0x3F) << 24) \
12                                         | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13 #define VC_CMD_GET_VHI_NAME     VC_CMD(2,2,0)
14
15 struct vhi_name_struct {
16         uint32_t field;
17         char name[65];
18 };
19
20 enum vhi_name_field {
21         VHIN_CONTEXT=0,
22         VHIN_SYSNAME,
23         VHIN_NODENAME,
24         VHIN_RELEASE,
25         VHIN_VERSION,
26         VHIN_MACHINE,
27         VHIN_DOMAINNAME,
28 };      
29
30 uint32_t vserver(uint32_t cmd, uint32_t id, void *data)
31 {
32           return syscall(__NR_vserver, cmd, id, data);
33 }
34
35 uint32_t get_vhi_name(uint32_t xid) {
36         struct vhi_name_struct cmd;
37         cmd.field = VHIN_CONTEXT;
38         vserver(VC_CMD_GET_VHI_NAME, xid, &cmd);
39         return (*((uint32_t *) cmd.name));
40 }
41 #endif