X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Flib%2Fvserver-internal.h;h=0ea138641442a36163228ebcbabef7c084dec46a;hb=90094dc9db547bea3a4536c12701c212a19e4cb1;hp=394039b82de9cea8c47f20064aa30b18bc615a36;hpb=9cde6b2e1f86d390b0730cb5339eb4920d631886;p=util-vserver.git diff --git a/util-vserver/lib/vserver-internal.h b/util-vserver/lib/vserver-internal.h index 394039b..0ea1386 100644 --- a/util-vserver/lib/vserver-internal.h +++ b/util-vserver/lib/vserver-internal.h @@ -19,15 +19,17 @@ #ifndef H_VSERVER_SYSCALL_INTERNAL_H #define H_VSERVER_SYSCALL_INTERNAL_H -#include -#include -#include -#include #include +#include #include +#include +#include +#include -#ifndef __NR_sys_virtual_context -# define __NR_sys_virtual_context 273 +#include "internal.h" + +#ifndef __NR_vserver +# define __NR_vserver 273 #endif #define VC_PREFIX 0) @@ -39,17 +41,21 @@ #if 1 # define VC_SELECT(ID) case ID: if(1) # define CALL_VC(...) \ - switch (utilvserver_checkCompatVersion()) { \ - case -1 : if (1) break; \ - VC_SUFFIX, __VA_ARGS__ , VC_PREFIX; \ - default : errno = EINVAL; \ - } \ - return -1 + do { \ + switch (utilvserver_checkCompatVersion()&~0xff) { \ + case -1 & ~0xff : if (1) break; \ + VC_SUFFIX, __VA_ARGS__ , VC_PREFIX; \ + default : errno = EINVAL; \ + } \ + return -1; \ + } while (0) #else # define VC_SELECT(ID) if (1) -# define CALL_VC(...) \ - if (1) {} VC_SUFFIX, __VA_ARGS__, VC_PREFIX; \ - errno = ENOSYS; return -1 +# define CALL_VC(...) \ + do { \ + if (1) {} VC_SUFFIX, __VA_ARGS__, VC_PREFIX; \ + errno = ENOSYS; return -1; \ + } while (0) #endif #ifdef VC_ENABLE_API_COMPAT @@ -64,26 +70,58 @@ # define CALL_VC_LEGACY(F,...) CALL_VC_NOOP #endif +#ifdef VC_ENABLE_API_V11 +# define CALL_VC_V11(F,...) CALL_VC_GENERAL(0x00010000, v11, F, __VA_ARGS__) +#else +# define CALL_VC_V11(F,...) CALL_VC_NOOP +#endif +#if 1 +# define CTX_KERNEL2USER(X) (((X)==(uint32_t)(-1)) ? VC_NOCTX : \ + ((X)==(uint32_t)(-2)) ? VC_SAMECTX : \ + (xid_t)(X)) -#ifdef __cplusplus -extern "C" { +# define CTX_USER2KERNEL(X) (((X)==VC_RANDCTX) ? (uint32_t)(-1) : \ + ((X)==VC_SAMECTX) ? (uint32_t)(-2) : \ + (uint32_t)(X)) +#else +# define CTX_USER2KERNEL(X) (X) +# define CTX_KERNEL2USER(X) (X) #endif -#ifndef HAVE_SYS_VIRTUAL_CONTEXT -static UNUSED -_syscall3(int, sys_virtual_context, - uint32_t, cmd, uint32_t, id, void *, data) +#if 1 +# define EXT2FLAGS_USER2KERNEL(X) (((X) & ~(VC_IMMUTABLE_FILE_FL|VC_IMMUTABLE_LINK_FL)) | \ + ((X) & VC_IMMUTABLE_FILE_FL ? EXT2_IMMUTABLE_FILE_FL : 0) | \ + ((X) & VC_IMMUTABLE_LINK_FL ? EXT2_IMMUTABLE_LINK_FL : 0)) +# define EXT2FLAGS_KERNEL2USER(X) (((X) & ~(EXT2_IMMUTABLE_FILE_FL|EXT2_IMMUTABLE_LINK_FL)) | \ + ((X) & EXT2_IMMUTABLE_FILE_FL ? VC_IMMUTABLE_FILE_FL : 0) | \ + ((X) & EXT2_IMMUTABLE_LINK_FL ? VC_IMMUTABLE_LINK_FL : 0)) +#else +# define EXT2FLAGS_KERNEL2USER(X) (X) +# define EXT2FLAGS_USER2KERNEL(X) (X) #endif -size_t utilvserver_uint2str(char *buf, size_t len, - unsigned int val, unsigned char base); -int utilvserver_checkCompatVersion(); -#ifdef __cplusplus +#define EXT2_IOC_GETCONTEXT _IOR('x', 1, long) +#define EXT2_IOC_SETCONTEXT _IOW('x', 2, long) + +#ifndef HAVE_VSERVER +#if defined(__pic__) && defined(__i386) +inline static UNUSED ALWAYSINLINE +int vserver(uint32_t cmd, uint32_t id, void *data) +{ +#if defined __dietlibc__ + extern long int syscall (long int __sysno, ...); +#endif + + return syscall(__NR_vserver, cmd, id, data); } +#else +inline static UNUSED ALWAYSINLINE +_syscall3(int, vserver, + uint32_t, cmd, uint32_t, id, void *, data) +#endif #endif - #endif // H_VSERVER_SYSCALL_INTERNAL_H