util-vserver (libvserver)  0.30.215+svn2929
vserver.h
Go to the documentation of this file.
00001 /* $Id: vserver.h 2911 2010-08-12 03:05:59Z dhozac $
00002 
00003 *  Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
00004 *   
00005 *  This program is free software; you can redistribute it and/or modify
00006 *  it under the terms of the GNU General Public License as published by
00007 *  the Free Software Foundation; either version 2, or (at your option)
00008 *  any later version.
00009 *   
00010 *  This program is distributed in the hope that it will be useful,
00011 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 *  GNU General Public License for more details.
00014 *   
00015 *  You should have received a copy of the GNU General Public License
00016 *  along with this program; if not, write to the Free Software
00017 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 */
00019 
00024 #ifndef H_VSERVER_SYSCALL_H
00025 #define H_VSERVER_SYSCALL_H
00026 
00027 #include <stdint.h>
00028 #include <stdlib.h>
00029 #include <stdbool.h>
00030 #include <sys/types.h>
00031 #include <sched.h>
00032 #include <netinet/in.h>
00033 
00034 #ifndef IS_DOXYGEN
00035 #if defined(__GNUC__)
00036 #  define VC_ATTR_UNUSED                __attribute__((__unused__))
00037 #  define VC_ATTR_NORETURN              __attribute__((__noreturn__))
00038 #  define VC_ATTR_CONST                 __attribute__((__const__))
00039 #  define VC_ATTR_DEPRECATED            __attribute__((__deprecated__))
00040 #  if __GNUC__*0x10000 + __GNUC_MINOR__*0x100 + __GNUC_PATCHLEVEL__ >= 0x30300
00041 #    define VC_ATTR_NONNULL(ARGS)       __attribute__((__nonnull__ ARGS))
00042 #    define VC_ATTR_ALWAYSINLINE        __attribute__((__always_inline__))
00043 #  else
00044 #    define VC_ATTR_NONNULL(ARGS)
00045 #    define VC_ATTR_ALWAYSINLINE
00046 #  endif
00047 #  if __GNUC__*0x10000 + __GNUC_MINOR__*0x100 + __GNUC_PATCHLEVEL__ >= 0x30303
00048 #    define VC_ATTR_PURE                __attribute__((__pure__))
00049 #  else
00050 #    define VC_ATTR_PURE
00051 #  endif
00052 #else
00053 #  define VC_ATTR_NONNULL(ARGS)
00054 #  define VC_ATTR_UNUSED
00055 #  define VC_ATTR_NORETURN
00056 #  define VC_ATTR_ALWAYSINLINE
00057 #  define VC_ATTR_DEPRECATED
00058 #  define VC_ATTR_PURE
00059 #  define VC_ATTR_CONST
00060 #endif
00061 #endif  // IS_DOXYGEN
00062 
00064 #define VC_NOCTX                ((xid_t)(-1))
00065 #define VC_NOXID                ((xid_t)(-1))
00066 
00067 #define VC_DYNAMIC_XID          ((xid_t)(-1))
00068 
00069 #define VC_SAMECTX              ((xid_t)(-2))
00070 
00071 #define VC_NONID                ((nid_t)(-1))
00072 #define VC_DYNAMIC_NID          ((nid_t)(-1))
00073 
00074 #define VC_LIM_INFINITY         (~0ULL)
00075 #define VC_LIM_KEEP             (~1ULL)
00076 
00077 #define VC_CDLIM_UNSET          (0U)
00078 #define VC_CDLIM_INFINITY       (~0U)
00079 #define VC_CDLIM_KEEP           (~1U)
00080   
00081 #ifndef S_CTX_INFO_LOCK
00082 #  define S_CTX_INFO_LOCK       1
00083 #endif
00084 
00085 #ifndef S_CTX_INFO_SCHED
00086 #  define S_CTX_INFO_SCHED      2
00087 #endif
00088 
00089 #ifndef S_CTX_INFO_NPROC
00090 #  define S_CTX_INFO_NPROC      4
00091 #endif
00092 
00093 #ifndef S_CTX_INFO_PRIVATE
00094 #  define S_CTX_INFO_PRIVATE    8
00095 #endif
00096 
00097 #ifndef S_CTX_INFO_INIT
00098 #  define S_CTX_INFO_INIT       16
00099 #endif
00100 
00101 #ifndef S_CTX_INFO_HIDEINFO
00102 #  define S_CTX_INFO_HIDEINFO   32
00103 #endif
00104 
00105 #ifndef S_CTX_INFO_ULIMIT
00106 #  define S_CTX_INFO_ULIMIT     64
00107 #endif
00108 
00109 #ifndef S_CTX_INFO_NAMESPACE
00110 #  define S_CTX_INFO_NAMESPACE  128
00111 #endif
00112 
00113 #define VC_CAP_CHOWN                     0
00114 #define VC_CAP_DAC_OVERRIDE              1
00115 #define VC_CAP_DAC_READ_SEARCH           2
00116 #define VC_CAP_FOWNER                    3
00117 #define VC_CAP_FSETID                    4
00118 #define VC_CAP_KILL                      5
00119 #define VC_CAP_SETGID                    6
00120 #define VC_CAP_SETUID                    7
00121 #define VC_CAP_SETPCAP                   8
00122 #define VC_CAP_LINUX_IMMUTABLE           9
00123 #define VC_CAP_NET_BIND_SERVICE         10
00124 #define VC_CAP_NET_BROADCAST            11
00125 #define VC_CAP_NET_ADMIN                12
00126 #define VC_CAP_NET_RAW                  13
00127 #define VC_CAP_IPC_LOCK                 14
00128 #define VC_CAP_IPC_OWNER                15
00129 #define VC_CAP_SYS_MODULE               16
00130 #define VC_CAP_SYS_RAWIO                17
00131 #define VC_CAP_SYS_CHROOT               18
00132 #define VC_CAP_SYS_PTRACE               19
00133 #define VC_CAP_SYS_PACCT                20
00134 #define VC_CAP_SYS_ADMIN                21
00135 #define VC_CAP_SYS_BOOT                 22
00136 #define VC_CAP_SYS_NICE                 23
00137 #define VC_CAP_SYS_RESOURCE             24
00138 #define VC_CAP_SYS_TIME                 25
00139 #define VC_CAP_SYS_TTY_CONFIG           26
00140 #define VC_CAP_MKNOD                    27
00141 #define VC_CAP_LEASE                    28
00142 #define VC_CAP_AUDIT_WRITE              29
00143 #define VC_CAP_AUDIT_CONTROL            30
00144 #define VC_CAP_SETFCAP                  31
00145 #define VC_CAP_MAC_OVERRIDE             32
00146 #define VC_CAP_MAC_ADMIN                33
00147 
00148 #define VC_IMMUTABLE_FILE_FL            0x0000010lu
00149 #define VC_IMMUTABLE_LINK_FL            0x0008000lu
00150 #define VC_IMMUTABLE_ALL                (VC_IMMUTABLE_LINK_FL|VC_IMMUTABLE_FILE_FL)
00151 
00152 #define VC_IATTR_XID                    0x01000000u
00153 
00154 #define VC_IATTR_ADMIN                  0x00000001u
00155 #define VC_IATTR_WATCH                  0x00000002u
00156 #define VC_IATTR_HIDE                   0x00000004u
00157 #define VC_IATTR_WRITE                  0x00000008u
00158 #define VC_IATTR_FLAGS                  0x0000000fu
00159 
00160 #define VC_IATTR_BARRIER                0x00010000u
00161 #define VC_IATTR_IUNLINK                0x00020000u
00162 #define VC_IATTR_IMMUTABLE              0x00040000u
00163 #define VC_IATTR_COW                    0x00080000u
00164 
00165 
00166 // the flags
00167 #define VC_VXF_INFO_LOCK                0x00000001ull
00168 #define VC_VXF_INFO_NPROC               0x00000004ull
00169 #define VC_VXF_INFO_PRIVATE             0x00000008ull
00170 #define VC_VXF_INFO_INIT                0x00000010ull
00171 
00172 #define VC_VXF_INFO_HIDEINFO            0x00000020ull
00173 #define VC_VXF_INFO_ULIMIT              0x00000040ull
00174 #define VC_VXF_INFO_NAMESPACE           0x00000080ull
00175 
00176 #define VC_VXF_SCHED_HARD               0x00000100ull
00177 #define VC_VXF_SCHED_PRIO               0x00000200ull
00178 #define VC_VXF_SCHED_PAUSE              0x00000400ull
00179 
00180 #define VC_VXF_VIRT_MEM                 0x00010000ull
00181 #define VC_VXF_VIRT_UPTIME              0x00020000ull
00182 #define VC_VXF_VIRT_CPU                 0x00040000ull
00183 #define VC_VXF_VIRT_LOAD                0x00080000ull
00184 #define VC_VXF_VIRT_TIME                0x00100000ull
00185 
00186 #define VC_VXF_HIDE_MOUNT               0x01000000ull
00187 #define VC_VXF_HIDE_NETIF               0x02000000ull
00188 #define VC_VXF_HIDE_VINFO               0x04000000ull
00189 
00190 #define VC_VXF_STATE_SETUP              (1ULL<<32)
00191 #define VC_VXF_STATE_INIT               (1ULL<<33)
00192 #define VC_VXF_STATE_ADMIN              (1ULL<<34)
00193 
00194 #define VC_VXF_SC_HELPER                (1ULL<<36)
00195 #define VC_VXF_REBOOT_KILL              (1ULL<<37)
00196 #define VC_VXF_PERSISTENT               (1ULL<<38)
00197 
00198 #define VC_VXF_FORK_RSS                 (1ULL<<48)
00199 #define VC_VXF_PROLIFIC                 (1ULL<<49)
00200 
00201 #define VC_VXF_IGNEG_NICE               (1ULL<<52)
00202 #define VC_VXF_IGNEG_IONICE             (1ULL<<53)
00203 
00204 
00205 // the ccapabilities
00206 #define VC_VXC_SET_UTSNAME              0x00000001ull
00207 #define VC_VXC_SET_RLIMIT               0x00000002ull
00208 #define VC_VXC_FS_SECURITY              0x00000004ull
00209 #define VC_VXC_TIOCSTI                  0x00000010ull
00210 
00211 #define VC_VXC_RAW_ICMP                 0x00000100ull
00212 #define VC_VXC_SYSLOG                   0x00001000ull
00213 #define VC_VXC_OOM_ADJUST               0x00002000ull
00214 #define VC_VXC_AUDIT_CONTROL            0x00004000ull
00215 
00216 #define VC_VXC_SECURE_MOUNT             0x00010000ull
00217 #define VC_VXC_SECURE_REMOUNT           0x00020000ull
00218 #define VC_VXC_BINARY_MOUNT             0x00040000ull
00219 
00220 #define VC_VXC_QUOTA_CTL                0x00100000ull
00221 #define VC_VXC_ADMIN_MAPPER             0x00200000ull
00222 #define VC_VXC_ADMIN_CLOOP              0x00400000ull
00223 
00224 #define VC_VXC_KTHREAD                  0x01000000ull
00225 #define VC_VXC_NAMESPACE                0x02000000ull
00226 
00227 
00228 // the scheduler flags
00229 #define VC_VXSM_FILL_RATE               0x0001
00230 #define VC_VXSM_INTERVAL                0x0002
00231 #define VC_VXSM_FILL_RATE2              0x0004
00232 #define VC_VXSM_INTERVAL2               0x0008
00233 #define VC_VXSM_TOKENS                  0x0010
00234 #define VC_VXSM_TOKENS_MIN              0x0020
00235 #define VC_VXSM_TOKENS_MAX              0x0040
00236 #define VC_VXSM_PRIO_BIAS               0x0100
00237 #define VC_VXSM_CPU_ID                  0x1000
00238 #define VC_VXSM_BUCKET_ID               0x2000
00239 
00240 #define VC_VXSM_IDLE_TIME               0x0200
00241 #define VC_VXSM_FORCE                   0x0400
00242 #define VC_VXSM_MSEC                    0x4000
00243 
00244 #define VC_VXSM_V3_MASK                 0x0173
00245 
00246 
00247 // the network flags
00248 #define VC_NXF_INFO_LOCK                0x00000001ull
00249 #define VC_NXF_INFO_PRIVATE             0x00000008ull
00250 
00251 #define VC_NXF_SINGLE_IP                0x00000100ull
00252 #define VC_NXF_LBACK_REMAP              0x00000200ull
00253 #define VC_NXF_LBACK_ALLOW              0x00000400ull
00254 
00255 #define VC_NXF_HIDE_NETIF               0x02000000ull
00256 #define VC_NXF_HIDE_LBACK               0x04000000ull
00257 
00258 #define VC_NXF_STATE_SETUP              (1ULL<<32)
00259 #define VC_NXF_STATE_ADMIN              (1ULL<<34)
00260 
00261 #define VC_NXF_SC_HELPER                (1ULL<<36)
00262 #define VC_NXF_PERSISTENT               (1ULL<<38)
00263 
00264 
00265 // the network capabilities
00266 #define VC_NXC_TUN_CREATE               0x00000001ull
00267 
00268 #define VC_NXC_RAW_ICMP                 0x00000100ull
00269 
00270 
00271 // the vserver specific limits
00272 #define VC_VLIMIT_NSOCK                 16
00273 #define VC_VLIMIT_OPENFD                17
00274 #define VC_VLIMIT_ANON                  18
00275 #define VC_VLIMIT_SHMEM                 19
00276 #define VC_VLIMIT_SEMARY                20
00277 #define VC_VLIMIT_NSEMS                 21
00278 #define VC_VLIMIT_DENTRY                22
00279 #define VC_VLIMIT_MAPPED                23
00280 
00281 
00282 // the VCI bit values
00283 #define VC_VCI_NO_DYNAMIC               (1 << 0)
00284 #define VC_VCI_PROC_SECURE              (1 << 4)
00285 #define VC_VCI_HARDCPU                  (1 << 5)
00286 #define VC_VCI_IDLELIMIT                (1 << 6)
00287 #define VC_VCI_IDLETIME                 (1 << 7)
00288 #define VC_VCI_COWBL                    (1 << 8)
00289 #define VC_VCI_FULLCOWBL                (1 << 9)
00290 #define VC_VCI_SPACES                   (1 << 10)
00291 #define VC_VCI_NETV2                    (1 << 11)
00292 #define VC_VCI_MEMCG                    (1 << 12)
00293 #define VC_VCI_DEBUG                    (1 << 16)
00294 #define VC_VCI_HISTORY                  (1 << 20)
00295 #define VC_VCI_TAGGED                   (1 << 24)
00296 #define VC_VCI_PPTAG                    (1 << 28)
00297 
00298 
00299 // the device mapping flags
00300 #define VC_DATTR_CREATE                 0x00000001
00301 #define VC_DATTR_OPEN                   0x00000002
00302 
00303 #define VC_DATTR_REMAP                  0x00000010
00304 
00305 
00306 // the process context migration flags
00307 #define VC_VXM_SET_INIT                 0x00000001
00308 #define VC_VXM_SET_REAPER               0x00000002
00309 
00310 
00311 // the network address flags
00312 #define VC_NXA_TYPE_IPV4                0x0001
00313 #define VC_NXA_TYPE_IPV6                0x0002
00314 
00315 #define VC_NXA_TYPE_NONE                0x0000
00316 #define VC_NXA_TYPE_ANY                 0x00FF
00317 
00318 #define VC_NXA_TYPE_ADDR                0x0010
00319 #define VC_NXA_TYPE_MASK                0x0020
00320 #define VC_NXA_TYPE_RANGE               0x0040
00321 
00322 #define VC_NXA_MOD_BCAST                0x0100
00323 #define VC_NXA_MOD_LBACK                0x0200
00324 
00325 
00326 #ifndef CLONE_NEWNS
00327 #  define CLONE_NEWNS                   0x00020000
00328 #endif
00329 #ifndef CLONE_NEWUTS
00330 #  define CLONE_NEWUTS                  0x04000000
00331 #endif
00332 #ifndef CLONE_NEWIPC
00333 #  define CLONE_NEWIPC                  0x08000000
00334 #endif
00335 #ifndef CLONE_NEWUSER
00336 #  define CLONE_NEWUSER                 0x10000000
00337 #endif
00338 #ifndef CLONE_NEWPID
00339 #  define CLONE_NEWPID                  0x20000000
00340 #endif
00341 #ifndef CLONE_NEWNET
00342 #  define CLONE_NEWNET                  0x40000000
00343 #endif
00344 
00345 
00346 #define VC_BAD_PERSONALITY              ((uint_least32_t)(-1))
00347 
00348 
00358 #ifdef IS_DOXYGEN
00359 typedef an_unsigned_integer_type        xid_t;
00360 typedef an_unsigned_integer_type        nid_t;
00361 typedef an_unsigned_integer_type        tag_t;
00362 #endif
00363 
00364 #ifdef __cplusplus
00365 extern "C" {
00366 #endif
00367 
00380   int           vc_syscall(uint32_t cmd, xid_t xid, void *data);
00381 
00386   int           vc_get_version();
00387 
00388   typedef       uint64_t vc_vci_t;
00393   vc_vci_t      vc_get_vci();
00394 
00412   xid_t         vc_new_s_context(xid_t ctx, unsigned int remove_cap, unsigned int flags);
00413 
00414   struct vc_ip_mask_pair {
00415       uint32_t  ip;
00416       uint32_t  mask;
00417   };
00418 
00422   int           vc_set_ipv4root(uint32_t  bcast, size_t nb,
00423                         struct vc_ip_mask_pair const *ips) VC_ATTR_NONNULL((3));
00424 
00431   size_t        vc_get_nb_ipv4root() VC_ATTR_CONST VC_ATTR_PURE;
00432 
00433     /* process context */
00436   struct  vc_ctx_flags {
00438       uint_least64_t    flagword;
00442       uint_least64_t    mask;
00443   };
00444 
00456   xid_t         vc_ctx_create(xid_t xid, struct vc_ctx_flags *flags);
00457 
00464   int           vc_ctx_migrate(xid_t xid, uint_least64_t flags);
00465 
00467   struct vc_ctx_stat {
00468       uint_least32_t    usecnt; 
00469       uint_least32_t    tasks;  
00470   };
00471 
00479   int           vc_ctx_stat(xid_t xid, struct vc_ctx_stat /*@out@*/ *stat) VC_ATTR_NONNULL((2));
00480 
00482   struct vc_virt_stat {
00483       uint_least64_t    offset;
00484       uint_least64_t    uptime;
00485       uint_least32_t    nr_threads;
00486       uint_least32_t    nr_running;
00487       uint_least32_t    nr_uninterruptible;
00488       uint_least32_t    nr_onhold;
00489       uint_least32_t    nr_forks;
00490       uint_least32_t    load[3];
00491   };
00492 
00500   int           vc_virt_stat(xid_t xid, struct vc_virt_stat /*@out@*/ *stat) VC_ATTR_NONNULL((2));
00501 
00508   int           vc_ctx_kill(xid_t ctx, pid_t pid, int sig);
00509  
00510   int           vc_get_cflags(xid_t xid, struct vc_ctx_flags /*@out@*/ *)       VC_ATTR_NONNULL((2));
00511   int           vc_set_cflags(xid_t xid, struct vc_ctx_flags /*@in@*/ const *)  VC_ATTR_NONNULL((2));
00512 
00514   struct  vc_ctx_caps {
00516       uint_least64_t    bcaps;
00520       uint_least64_t    bmask;
00522       uint_least64_t    ccaps;
00526       uint_least64_t    cmask;
00527   };
00528 
00529   int           vc_get_ccaps(xid_t xid, struct vc_ctx_caps *);
00530   int           vc_set_ccaps(xid_t xid, struct vc_ctx_caps const *);
00531 
00532   struct vc_vx_info {
00533       xid_t     xid;
00534       pid_t     initpid;
00535   };
00536 
00537   int           vc_get_vx_info(xid_t xid, struct vc_vx_info *info) VC_ATTR_NONNULL((2));
00538   
00546   xid_t         vc_get_task_xid(pid_t pid);
00547 
00551   int           vc_wait_exit(xid_t xid);
00552   
00553     /* rlimit related functions */
00554   
00564   typedef uint_least64_t        vc_limit_t;
00565 
00567   struct  vc_rlimit_mask {
00568       uint_least32_t    min;    
00569       uint_least32_t    soft;   
00570       uint_least32_t    hard;   
00571   };
00572 
00574   int           vc_get_rlimit_mask(xid_t xid,
00575                            struct vc_rlimit_mask /*@out@*/ *lim) VC_ATTR_NONNULL((2));
00576 
00580   struct vc_rlimit {
00581       vc_limit_t        min;    
00582       vc_limit_t        soft;   
00583       vc_limit_t        hard;   
00584   };
00585 
00594   int           vc_get_rlimit(xid_t xid, int resource,
00595                       struct vc_rlimit       /*@out@*/ *lim) VC_ATTR_NONNULL((3));
00604   int           vc_set_rlimit(xid_t xid, int resource,
00605                       struct vc_rlimit const /*@in@*/  *lim) VC_ATTR_NONNULL((3));
00606 
00608   struct  vc_rlimit_stat {
00609       uint_least32_t    hits;    
00610       vc_limit_t        value;   
00611       vc_limit_t        minimum; 
00612       vc_limit_t        maximum; 
00613   };
00614 
00623   int           vc_rlimit_stat(xid_t xid, int resource,
00624                        struct vc_rlimit_stat /*@out@*/ *stat) VC_ATTR_NONNULL((3));
00625 
00632   int           vc_reset_minmax(xid_t xid);
00633 
00653   bool          vc_parseLimit(char const /*@in@*/ *str, vc_limit_t /*@out@*/ *res)      VC_ATTR_NONNULL((1,2));
00654 
00655 
00656     /* network context */
00657   struct vc_nx_info {
00658       nid_t     nid;
00659   };
00660 
00661   nid_t         vc_get_task_nid(pid_t pid);
00662   int           vc_get_nx_info(nid_t nid, struct vc_nx_info *) VC_ATTR_NONNULL((2));
00663 
00664   struct vc_net_addr {
00665       uint16_t                  vna_type;
00666       uint16_t                  vna_flags;
00667       uint16_t                  vna_prefix;
00668       uint16_t                  vna_parent;
00669       struct {
00670         union {
00671           struct in_addr        v4;
00672           struct in6_addr       v6;
00673         } ip;
00674         union {
00675           struct in_addr        v4;
00676           struct in6_addr       v6;
00677         } ip2;
00678         union {
00679           struct in_addr        v4;
00680           struct in6_addr       v6;
00681         } mask;
00682       } s;
00683 #define vna_v4_ip       s.ip.v4
00684 #define vna_v4_ip2      s.ip2.v4
00685 #define vna_v4_mask     s.mask.v4
00686 #define vna_v6_ip       s.ip.v6
00687 #define vna_v6_ip2      s.ip2.v6
00688 #define vna_v6_mask     s.mask.v6
00689   };
00690 
00691   struct vc_net_flags {
00692       uint_least64_t    flagword;
00693       uint_least64_t    mask;
00694   };
00695 
00696   nid_t         vc_net_create(nid_t nid);
00697   int           vc_net_migrate(nid_t nid);
00698 
00699   int           vc_net_add(nid_t nid, struct vc_net_addr const *info);
00700   int           vc_net_remove(nid_t nid, struct vc_net_addr const *info);
00701 
00702   int           vc_get_nflags(nid_t, struct vc_net_flags *);
00703   int           vc_set_nflags(nid_t, struct vc_net_flags const *);
00704 
00705   struct vc_net_caps {
00706       uint_least64_t    ncaps;
00707       uint_least64_t    cmask;
00708   };
00709 
00710   int           vc_get_ncaps(nid_t, struct vc_net_caps *);
00711   int           vc_set_ncaps(nid_t, struct vc_net_caps const *);
00712 
00713 
00714     /* iattr related functions */
00715 
00716   int           vc_set_iattr(char const *filename, xid_t xid,
00717                              uint_least32_t flags, uint_least32_t mask) VC_ATTR_NONNULL((1));
00718 
00719   int           vc_fset_iattr(int fd, xid_t xid,
00720                               uint_least32_t flags, uint_least32_t mask);
00721 
00748   int           vc_get_iattr(char const *filename, xid_t * /*@null@*/ xid,
00749                              uint_least32_t * /*@null@*/ flags,
00750                              uint_least32_t * /*@null@*/ mask) VC_ATTR_NONNULL((1));
00751 
00752   int           vc_fget_iattr(int fd, xid_t * /*@null@*/ xid,
00753                               uint_least32_t * /*@null@*/ flags,
00754                               uint_least32_t * /*@null@*/ mask) VC_ATTR_NONNULL((4));
00755   
00769   xid_t         vc_getfilecontext(char const *filename) VC_ATTR_NONNULL((1));
00770 
00771 
00772     /* vhi related functions */
00773   typedef enum { vcVHI_CONTEXT, vcVHI_SYSNAME, vcVHI_NODENAME,
00774                  vcVHI_RELEASE, vcVHI_VERSION, vcVHI_MACHINE,
00775                  vcVHI_DOMAINNAME }             vc_uts_type;
00776   
00777   int           vc_set_vhi_name(xid_t xid, vc_uts_type type,
00778                                 char const *val, size_t len) VC_ATTR_NONNULL((3));
00779   int           vc_get_vhi_name(xid_t xid, vc_uts_type type,
00780                                 char *val, size_t len)       VC_ATTR_NONNULL((3));
00781 
00782     /* namespace related functions */
00783   int           vc_enter_namespace(xid_t xid, uint_least64_t mask, uint32_t index);
00784   int           vc_set_namespace(xid_t xid, uint_least64_t mask, uint32_t index);
00785   int           vc_cleanup_namespace(void);
00786   uint_least64_t vc_get_space_mask(void);
00787   uint_least64_t vc_get_space_default(void);
00788 
00789 
00790     /* disk limit related things */
00791   struct vc_ctx_dlimit {
00792       uint_least32_t    space_used;
00793       uint_least32_t    space_total;
00794       uint_least32_t    inodes_used;
00795       uint_least32_t    inodes_total;
00796       uint_least32_t    reserved;
00797   };
00798   
00799 
00801   int           vc_add_dlimit(char const *filename, xid_t xid,
00802                               uint_least32_t flags) VC_ATTR_NONNULL((1));
00804   int           vc_rem_dlimit(char const *filename, xid_t xid,
00805                               uint_least32_t flags) VC_ATTR_NONNULL((1));
00806 
00808   int           vc_set_dlimit(char const *filename, xid_t xid,
00809                               uint_least32_t flags,
00810                               struct vc_ctx_dlimit const *limits) VC_ATTR_NONNULL((1,4));
00812   int           vc_get_dlimit(char const *filename, xid_t xid,
00813                               uint_least32_t flags,
00814                               struct vc_ctx_dlimit *limits) VC_ATTR_NONNULL((1));
00815 
00817   tag_t         vc_get_task_tag(pid_t pid);
00818 
00820   int           vc_tag_create(tag_t tag);
00821 
00823   int           vc_tag_migrate(tag_t tag);
00824 
00825     /* scheduler related syscalls */
00826   struct vc_set_sched {
00827       uint_least32_t    set_mask;
00828       int_least32_t     fill_rate;
00829       int_least32_t     interval;
00830       int_least32_t     fill_rate2;
00831       int_least32_t     interval2;
00832       int_least32_t     tokens;
00833       int_least32_t     tokens_min;
00834       int_least32_t     tokens_max;
00835       int_least32_t     priority_bias;
00836       int_least32_t     cpu_id;
00837       int_least32_t     bucket_id;
00838   };
00839 
00840   int           vc_set_sched(xid_t xid, struct vc_set_sched const *) VC_ATTR_NONNULL((2));
00841   int           vc_get_sched(xid_t xid, struct vc_set_sched *) VC_ATTR_NONNULL((2));
00842 
00843   struct vc_sched_info {
00844       int_least32_t     cpu_id;
00845       int_least32_t     bucket_id;
00846       uint_least64_t    user_msec;
00847       uint_least64_t    sys_msec;
00848       uint_least64_t    hold_msec;
00849       uint_least32_t    token_usec;
00850       int_least32_t     vavavoom;
00851   };
00852 
00853   int           vc_sched_info(xid_t xid, struct vc_sched_info *info) VC_ATTR_NONNULL((2));
00854 
00855     /* misc. syscalls */
00856   int           vc_set_mapping(xid_t xid, const char *device, const char *target, uint32_t flags);
00857   int           vc_unset_mapping(xid_t xid, const char *device, const char *target, uint32_t flags);
00858 
00859   int           vc_get_badness(xid_t xid, int64_t *badness);
00860   int           vc_set_badness(xid_t xid, int64_t badness);
00861 
00862 
00866   struct vc_err_listparser {
00867       char const        *ptr;           
00868       size_t            len;            
00869   };
00870 
00881   uint_least64_t        vc_text2bcap(char const *str, size_t len);
00882 
00897   char const *  vc_lobcap2text(uint_least64_t *val) VC_ATTR_NONNULL((1));
00898 
00926   int                   vc_list2bcap(char const *str, size_t len,
00927                                      struct vc_err_listparser *err,
00928                                      struct vc_ctx_caps *cap) VC_ATTR_NONNULL((1,4));
00929 
00930   uint_least64_t        vc_text2ccap(char const *, size_t len);
00931   char const *          vc_loccap2text(uint_least64_t *);
00932   int                   vc_list2ccap(char const *, size_t len,
00933                                      struct vc_err_listparser *err,
00934                                      struct vc_ctx_caps *);
00935 
00936   int                   vc_list2cflag(char const *, size_t len,
00937                                      struct vc_err_listparser *err,
00938                                      struct vc_ctx_flags *flags);
00939   uint_least64_t        vc_text2cflag(char const *, size_t len);
00940   char const *          vc_locflag2text(uint_least64_t *);
00941   
00942   uint_least32_t        vc_list2cflag_compat(char const *, size_t len,
00943                                             struct vc_err_listparser *err);
00944   uint_least32_t        vc_text2cflag_compat(char const *, size_t len);
00945   char const *          vc_hicflag2text_compat(uint_least32_t);
00946 
00947   int                   vc_text2cap(char const *);
00948   char const *          vc_cap2text(unsigned int);
00949 
00950   
00951   int                   vc_list2nflag(char const *, size_t len,
00952                                      struct vc_err_listparser *err,
00953                                      struct vc_net_flags *flags);
00954   uint_least64_t        vc_text2nflag(char const *, size_t len);
00955   char const *          vc_lonflag2text(uint_least64_t *);
00956 
00957   uint_least64_t        vc_text2ncap(char const *, size_t len);
00958   char const *          vc_loncap2text(uint_least64_t *);
00959   int                   vc_list2ncap(char const *, size_t len,
00960                                      struct vc_err_listparser *err,
00961                                      struct vc_net_caps *);
00962 
00963   uint_least64_t                vc_get_insecurebcaps() VC_ATTR_CONST;
00964   inline static uint_least64_t  vc_get_insecureccaps() {
00965     return ~(VC_VXC_SET_UTSNAME|VC_VXC_RAW_ICMP|VC_VXC_AUDIT_CONTROL);
00966   }
00967   
00968   inline static int     vc_setfilecontext(char const *filename, xid_t xid) {
00969     return vc_set_iattr(filename, xid, 0, VC_IATTR_XID);
00970   }
00971 
00972 
00973   uint_least32_t        vc_text2personalityflag(char const *str,
00974                                                 size_t len) VC_ATTR_NONNULL((1));
00975 
00976   char const *          vc_lopersonality2text(uint_least32_t *) VC_ATTR_NONNULL((1));
00977   
00978   int                   vc_list2personalityflag(char const /*@in@*/ *,
00979                                                 size_t len,
00980                                                 uint_least32_t /*@out@*/ *personality,
00981                                                 struct vc_err_listparser /*@out@*/ *err) VC_ATTR_NONNULL((1,3));
00982 
00983   uint_least32_t        vc_str2personalitytype(char const /*@in@*/*,
00984                                                size_t len) VC_ATTR_NONNULL((1));
00985 
00986     
00987   typedef enum { vcFEATURE_VKILL,  vcFEATURE_IATTR,   vcFEATURE_RLIMIT,
00988                  vcFEATURE_COMPAT, vcFEATURE_MIGRATE, vcFEATURE_NAMESPACE,
00989                  vcFEATURE_SCHED,  vcFEATURE_VINFO,   vcFEATURE_VHI,
00990                  vcFEATURE_VSHELPER0, vcFEATURE_VSHELPER, vcFEATURE_VWAIT,
00991                  vcFEATURE_VNET,   vcFEATURE_VSTAT,   vcFEATURE_PPTAG,
00992                  vcFEATURE_PIDSPACE, vcFEATURE_SPACES, vcFEATURE_PERSISTENT,
00993                  vcFEATURE_PIVOT_ROOT, vcFEATURE_MEMCG, vcFEATURE_DYNAMIC,
00994                  }
00995     vcFeatureSet;
00996 
00997   bool          vc_isSupported(vcFeatureSet) VC_ATTR_CONST;
00998   bool          vc_isSupportedString(char const *);
00999 
01000   
01001   typedef enum { vcTYPE_INVALID, vcTYPE_MAIN, vcTYPE_WATCH,
01002                  vcTYPE_STATIC, vcTYPE_DYNAMIC }
01003     vcXidType;
01004   
01005   vcXidType     vc_getXIDType(xid_t xid) VC_ATTR_CONST;
01006 
01008   bool          vc_is_dynamic_xid(xid_t xid);
01009 
01010 
01011   /* The management part */
01012 
01013 #define VC_LIMIT_VSERVER_NAME_LEN       1024
01014   
01015   typedef enum { vcCFG_NONE, vcCFG_AUTO,
01016                  vcCFG_LEGACY,
01017                  vcCFG_RECENT_SHORT,
01018                  vcCFG_RECENT_FULL }            vcCfgStyle;
01019 
01020 
01022   xid_t         vc_xidopt2xid(char const *, bool honor_static, char const **err_info);
01024   nid_t         vc_nidopt2nid(char const *, bool honor_static, char const **err_info);
01026   tag_t         vc_tagopt2tag(char const *, bool honor_static, char const **err_info);
01027 
01028   vcCfgStyle    vc_getVserverCfgStyle(char const *id);
01029   
01032   char *        vc_getVserverName(char const *id, vcCfgStyle style);
01033 
01038   char *        vc_getVserverCfgDir(char const *id, vcCfgStyle style);
01039 
01043   char *        vc_getVserverAppDir(char const *id, vcCfgStyle style, char const *app);
01044 
01047   char *        vc_getVserverVdir(char const *id, vcCfgStyle style, bool physical);
01048 
01049   typedef enum { vcCTX_XID = 1,
01050                  vcCTX_NID,
01051                  vcCTX_TAG,
01052         } vcCtxType;
01053 
01061   xid_t         vc_getVserverCtx(char const *id, vcCfgStyle style,
01062                                  bool honor_static, bool /*@null@*/ *is_running,
01063                                  vcCtxType type);
01064 
01069   char *        vc_getVserverByCtx(xid_t ctx, /*@null@*/vcCfgStyle *style,
01070                                    /*@null@*/char const *revdir);
01071 
01072   int           vc_compareVserverById(char const *lhs, vcCfgStyle lhs_style,
01073                                       char const *rhs, vcCfgStyle rhs_style);
01074 
01075   void          vc_exitLikeProcess(int pid, int ret) VC_ATTR_NORETURN;
01076  
01077 #define vcSKEL_INTERFACES       1u
01078 #define vcSKEL_PKGMGMT          2u
01079 #define vcSKEL_FILESYSTEM       4u
01080 
01083   int           vc_createSkeleton(char const *id, vcCfgStyle style, int flags);
01084 
01085 
01086 #ifdef __cplusplus
01087 }
01088 #endif
01089 
01090 #undef VC_ATTR_PURE
01091 #undef VC_ATTR_ALWAYSINLINE
01092 #undef VC_ATTR_NORETURN
01093 #undef VC_ATTR_UNUSED
01094 #undef VC_ATTR_NONNULL
01095 
01096 #endif