- fixed some statements which would fail with 'set -e'
[util-vserver.git] / util-vserver / lib / vserver.h
index e476f4d..283897a 100644 (file)
 #include <stdlib.h>
 #include <sys/types.h>
 
-#define VC_NOCTX       ((ctx_t)(-1))
+#ifndef VC_NOCTX
+#  define VC_NOCTX     ((ctx_t)(-1))
+#endif
+
+#ifndef S_CTX_INFO_LOCK
+#  define S_CTX_INFO_LOCK      1
+#endif
+
+#ifndef S_CTX_INFO_SCHED
+#  define S_CTX_INFO_SCHED     2
+#endif
+
+#ifndef S_CTX_INFO_NPROC
+#  define S_CTX_INFO_NPROC     4
+#endif
+
+#ifndef S_CTX_INFO_PRIVATE
+#  define S_CTX_INFO_PRIVATE   8
+#endif
+
+#ifndef S_CTX_INFO_INIT
+#  define S_CTX_INFO_INIT      16
+#endif
+
+#ifndef S_CTX_INFO_HIDEINFO
+#  define S_CTX_INFO_HIDEINFO  32
+#endif
+
+#ifndef S_CTX_INFO_ULIMIT
+#  define S_CTX_INFO_ULIMIT    64
+#endif
+
+#define VC_CAP_CHOWN                    0
+#define VC_CAP_DAC_OVERRIDE             1
+#define VC_CAP_DAC_READ_SEARCH          2
+#define VC_CAP_FOWNER                   3
+#define VC_CAP_FSETID                   4
+#define VC_CAP_KILL                     5
+#define VC_CAP_SETGID                   6
+#define VC_CAP_SETUID                   7
+#define VC_CAP_SETPCAP                  8
+#define VC_CAP_LINUX_IMMUTABLE          9
+#define VC_CAP_NET_BIND_SERVICE        10
+#define VC_CAP_NET_BROADCAST           11
+#define VC_CAP_NET_ADMIN               12
+#define VC_CAP_NET_RAW                 13
+#define VC_CAP_IPC_LOCK                14
+#define VC_CAP_IPC_OWNER               15
+#define VC_CAP_SYS_MODULE              16
+#define VC_CAP_SYS_RAWIO               17
+#define VC_CAP_SYS_CHROOT              18
+#define VC_CAP_SYS_PTRACE              19
+#define VC_CAP_SYS_PACCT               20
+#define VC_CAP_SYS_ADMIN               21
+#define VC_CAP_SYS_BOOT                22
+#define VC_CAP_SYS_NICE                23
+#define VC_CAP_SYS_RESOURCE            24
+#define VC_CAP_SYS_TIME                25
+#define VC_CAP_SYS_TTY_CONFIG          26
+#define VC_CAP_MKNOD                   27
+#define VC_CAP_LEASE                   28
+#define VC_CAP_QUOTACTL                29
+
 
 #ifdef __cplusplus
 extern "C" {
@@ -52,12 +114,34 @@ extern "C" {
   int  vc_chrootsafe(char const *dir);
 
 
-    /** Returns the context of the given process. */
+    /** Returns the context of the given process. pid==0 means the current process. */
   ctx_t        vc_X_getctx(pid_t pid);
 
-    /** Returns the context of the current process. */
-#define vc_X_getcctx           (getctx(getpid()))
-    
+    /** Returns the pid of the 'init' process */
+  pid_t        vc_X_getinitpid(pid_t pid);
+
+
+  int          vc_text2cap(char const *);
+  char const * vc_cap2text(int);
+
+  
+  // The management part
+
+#define VC_LIMIT_VSERVER_NAME_LEN      1024
+  
+  typedef enum { vcCFG_NONE, vcCFG_AUTO,
+                vcCFG_LEGACY,
+                vcCFG_RECENT_SHORT,
+                vcCFG_RECENT_FULL }            vcCfgStyle;
+
+  vcCfgStyle   vc_getVserverCfgStyle(char const *id);
+  
+  // Resolves the name of the vserver. The result will be allocated and must
+  // be freed by the caller
+  char *       vc_getVserverName(char const *id, vcCfgStyle style);
+
+  char *       vc_getVserverVdir(char const *id, vcCfgStyle style);
+  
 #ifdef __cplusplus
 }
 #endif