#include #include #include #include #include #include #define VC_CATEGORY(c) (((c) >> 24) & 0x3F) #define VC_COMMAND(c) (((c) >> 16) & 0xFF) #define VC_VERSION(c) ((c) & 0xFFF) #define VC_CMD(c,i,v) ((((VC_CAT_ ## c) & 0x3F) << 24) \ | (((i) & 0xFF) << 16) | ((v) & 0xFFF)) #define VC_CAT_COMPAT 63 #define VCMD_new_s_context VC_CMD(COMPAT, 1, 1) #ifndef __NR_vserver # define __NR_vserver 273 #endif inline static _syscall3(int, vserver, uint32_t, cmd, uint32_t, id, void *, data) struct vcmd_new_s_context_v1 { uint32_t remove_cap; uint32_t flags; }; int main(int argc) { struct vcmd_new_s_context_v1 msg = { 0,0 }; pid_t pid; int ret = 0; vserver(VCMD_new_s_context, -1, &msg); pid = fork(); if (pid==0) { msg.flags |= (argc > 1)?0:16; ret = vserver(VCMD_new_s_context, -2, &msg); printf("ret=%u\n", ret); return 0; } printf("child=%u, parent=%u\n", pid, getpid()); sleep(2); return 0; }