vserver.h

Go to the documentation of this file.
00001 // Copyright 2005-2006 Benedikt Böhm <hollow@gentoo.org>
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the
00015 // Free Software Foundation, Inc.,
00016 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 
00018 /*!
00019  * @file vserver.h
00020  * @brief Interface to the vserver syscalls
00021  */
00022 #ifndef _VSERVER_H
00023 #define _VSERVER_H
00024 
00025 #include <sys/types.h>
00026 #include <stdint.h>
00027 
00028 #define LIBVSERVER_API_MAJOR 2  /*!< API major version */
00029 #define LIBVSERVER_API_MINOR 0  /*!< API minor version */
00030 
00031 /*!
00032  * @brief Main vserver syscall interface
00033  *
00034  * @param cmd  Command number
00035  * @param id   Context ID (sometimes process id)
00036  * @param data Data structures
00037  *
00038  * @return Syscall return code
00039  *
00040  * @see \htmlonly
00041  *   <a class="el" href="file:///usr/include/linux/vserver/switch.h">
00042  *     &lt;linux/vserver/switch.h&gt;
00043  *   </a>
00044  * \endhtmlonly
00045  */
00046 int vserver(uint32_t cmd, uint32_t id, void *data);
00047 
00048 /*!
00049  * @brief Clone system call
00050  *
00051  * @param flags         Clone flags
00052  * @param child_stack   Child stack
00053  *
00054  * @return Process ID in parent, 0 in child, -1 on error
00055  *
00056  * @see clone(2)
00057  */
00058 #if defined (__s390__)
00059 int clone(void *child_stack, int flags);
00060 #else
00061 int clone(int flags, void *child_stack);
00062 #endif
00063 
00064 /*!
00065  * @brief Get vserver version of running kernel
00066  *
00067  * @return Kernel version
00068  */
00069 int vs_get_version(void);
00070 
00071 /*!
00072  * @brief Get vserver configuration of running kernel
00073  *
00074  * @return Kernel configuration
00075  */
00076 int vs_get_config(void);
00077 
00078 
00079 
00080 /*!
00081  * @defgroup syscall_context Context commands
00082  * @{
00083  */
00084 #ifndef _LINUX_CAPABILITY_H
00085 #define CAP_CHOWN            0
00086 #define CAP_DAC_OVERRIDE     1
00087 #define CAP_DAC_READ_SEARCH  2
00088 #define CAP_FOWNER           3
00089 #define CAP_FSETID           4
00090 #define CAP_KILL             5
00091 #define CAP_SETGID           6
00092 #define CAP_SETUID           7
00093 #define CAP_SETPCAP          8
00094 #define CAP_LINUX_IMMUTABLE  9
00095 #define CAP_NET_BIND_SERVICE 10
00096 #define CAP_NET_BROADCAST    11
00097 #define CAP_NET_ADMIN        12
00098 #define CAP_NET_RAW          13
00099 #define CAP_IPC_LOCK         14
00100 #define CAP_IPC_OWNER        15
00101 #define CAP_SYS_MODULE       16
00102 #define CAP_SYS_RAWIO        17
00103 #define CAP_SYS_CHROOT       18
00104 #define CAP_SYS_PTRACE       19
00105 #define CAP_SYS_PACCT        20
00106 #define CAP_SYS_ADMIN        21
00107 #define CAP_SYS_BOOT         22
00108 #define CAP_SYS_NICE         23
00109 #define CAP_SYS_RESOURCE     24
00110 #define CAP_SYS_TIME         25
00111 #define CAP_SYS_TTY_CONFIG   26
00112 #define CAP_MKNOD            27
00113 #define CAP_LEASE            28
00114 #define CAP_AUDIT_WRITE      29
00115 #define CAP_AUDIT_CONTROL    30
00116 #define CAP_CONTEXT          31
00117 #endif
00118 
00119 #ifndef _VX_CONTEXT_H
00120 #define VXC_SET_UTSNAME    0x00000001  /*!< Allow setdomainname(2) and sethostname(2) */
00121 #define VXC_SET_RLIMIT     0x00000002  /*!< Allow setrlimit(2) */
00122 #define VXC_RAW_ICMP       0x00000100  /*!< Allow raw ICMP sockets */
00123 #define VXC_SYSLOG         0x00001000  /*!< Allow syslog(2) */
00124 #define VXC_SECURE_MOUNT   0x00010000  /*!< Allow secure mount(2) */
00125 #define VXC_SECURE_REMOUNT 0x00020000  /*!< Allow secure remount */
00126 #define VXC_BINARY_MOUNT   0x00040000  /*!< Allow binary/network mounts */
00127 #define VXC_QUOTA_CTL      0x00100000  /*!< Allow quota ioctl */
00128 #define VXC_ADMIN_MAPPER   0x00200000  /*!< Allow access to device mapper */
00129 #define VXC_ADMIN_CLOOP    0x00400000  /*!< Allow access to loop devices */
00130 
00131 #define VXF_INFO_SCHED   0x00000002  /*!< Account all processes as one (L) */
00132 #define VXF_INFO_NPROC   0x00000004  /*!< Apply process limits to context (L) */
00133 #define VXF_INFO_PRIVATE 0x00000008  /*!< Context cannot be entered */
00134 #define VXF_INFO_INIT    0x00000010  /*!< Show a fake init process */
00135 #define VXF_INFO_HIDE    0x00000020  /*!< Hide context information in task status */
00136 #define VXF_INFO_ULIMIT  0x00000040  /*!< Apply ulimits to context (L) */
00137 #define VXF_INFO_NSPACE  0x00000080  /*!< Use private namespace (L) */
00138 #define VXF_SCHED_HARD   0x00000100  /*!< Enable hard scheduler */
00139 #define VXF_SCHED_PRIO   0x00000200  /*!< Enable priority scheduler */
00140 #define VXF_SCHED_PAUSE  0x00000400  /*!< Pause context (unschedule) */
00141 #define VXF_VIRT_MEM     0x00010000  /*!< Virtualize memory information */
00142 #define VXF_VIRT_UPTIME  0x00020000  /*!< Virtualize uptime information */
00143 #define VXF_VIRT_CPU     0x00040000  /*!< Virtualize cpu usage information */
00144 #define VXF_VIRT_LOAD    0x00080000  /*!< Virtualize load average information */
00145 #define VXF_VIRT_TIME    0x00100000  /*!< Allow per guest time offsets */
00146 #define VXF_HIDE_MOUNT   0x01000000  /*!< Hide entries in /proc/$pid/mounts */
00147 #define VXF_HIDE_NETIF   0x02000000  /*!< Hide foreign network interfaces */
00148 #define VXF_HIDE_VINFO   0x04000000  /*!< Hide context information in task status */
00149 #define VXF_STATE_SETUP  (1ULL<<32)  /*!< Enable setup state */
00150 #define VXF_STATE_INIT   (1ULL<<33)  /*!< Enable init state */
00151 #define VXF_STATE_ADMIN  (1ULL<<34)  /*!< Enable admin state */
00152 #define VXF_SC_HELPER    (1ULL<<36)  /*!< Context state change helper */
00153 #define VXF_REBOOT_KILL  (1ULL<<37)  /*!< Kill all processes on reboot(2) */
00154 #define VXF_PERSISTENT   (1ULL<<38)  /*!< Make context persistent */
00155 #define VXF_FORK_RSS     (1ULL<<48)  /*!< Block fork when over RSS */
00156 #define VXF_PROLIFIC     (1ULL<<49)  /*!< Allow context to create new contexts */
00157 #define VXF_IGNEG_NICE   (1ULL<<52)  /*!< Ignore priority raise */
00158 
00159 #define VXM_SET_INIT     0x00000001  /*!< Make current process the new init */
00160 #define VXM_SET_REAPER   0x00000002  /*!< Make current process the new reaper */
00161 #endif
00162 
00163 #ifndef _VX_CVIRT_CMD_H
00164 #define VHIN_CONTEXT     0
00165 #define VHIN_SYSNAME     1
00166 #define VHIN_NODENAME    2
00167 #define VHIN_RELEASE     3
00168 #define VHIN_VERSION     4
00169 #define VHIN_MACHINE     5
00170 #define VHIN_DOMAINNAME  6
00171 #endif
00172 
00173 typedef uint32_t xid_t; /*!< Context ID type */
00174 
00175 /*!
00176  * @brief Context information
00177  */
00178 typedef struct _vx_info {
00179         xid_t xid;     /*!< Context ID */
00180         pid_t initpid; /*!< Process ID of init */
00181 } vx_info_t;
00182 
00183 /*!
00184  * @brief Context statistics
00185  */
00186 typedef struct _vx_stat {
00187         uint32_t usecnt;     /*!< Number of context references */
00188         uint32_t tasks;      /*!< Number of tasks */
00189         uint32_t nr_threads; /*!< Total number of threads */
00190         uint32_t nr_running; /*!< Number of running threads */
00191         uint32_t nr_unintr;  /*!< Number of uninterruptible threads */
00192         uint32_t nr_onhold;  /*!< Number of threads being held */
00193         uint32_t nr_forks;   /*!< Total number of forks since context startup */
00194         uint32_t load[3];    /*!< Load average */
00195         uint64_t offset;     /*!< Offset to the system time */
00196         uint64_t uptime;     /*!< Context uptime */
00197 } vx_stat_t;
00198 
00199 /*!
00200  * @brief Context/migration flags
00201  */
00202 typedef struct _vx_flags {
00203         uint64_t flags; /*!< Flags */
00204         uint64_t mask;  /*!< Set mask */
00205 } vx_flags_t;
00206 
00207 /*!
00208  * @brief Virtual system information data
00209  */
00210 typedef struct _vx_uname {
00211         uint32_t id;    /*!< Name ID */
00212         char value[65]; /*!< Name value */
00213 } vx_uname_t;
00214 
00215 /*!
00216  * @brief Wait results
00217  */
00218 typedef struct _vx_wait {
00219         int32_t reboot_cmd; /*!< Context reboot command */
00220         int32_t exit_code;  /*!< Context exit code */
00221 } vx_wait_t;
00222 
00223 /*!
00224  * @brief Create a new context
00225  *
00226  * @param xid  Context ID
00227  * @param data Initial context flags
00228  */
00229 int vx_create(xid_t xid, vx_flags_t *data);
00230 
00231 /*!
00232  * @brief Migrate to an existing context
00233  *
00234  * @param xid  Context ID
00235  * @param data Migration flags
00236  */
00237 int vx_migrate(xid_t xid, vx_flags_t *data);
00238 
00239 /*!
00240  * @brief Get the context ID of a process
00241  *
00242  * @param pid Process ID
00243  *
00244  * @return Context ID
00245  */
00246 int vx_task_xid(pid_t pid);
00247 
00248 /*!
00249  * @brief Get context information
00250  *
00251  * @param xid  Context ID
00252  * @param data Empty vx_info_t struct to be filled
00253  */
00254 int vx_info(xid_t xid, vx_info_t *data);
00255 
00256 /*!
00257  * @brief Get context statistics
00258  *
00259  * @param xid  Context ID
00260  * @param data Empty vx_stat_t struct to be filled
00261  */
00262 int vx_stat(xid_t xid, vx_stat_t *data);
00263 
00264 /*!
00265  * @brief Set system capabilities
00266  *
00267  * @param xid  Context ID
00268  * @param data System capabilities
00269  */
00270 int vx_bcaps_set(xid_t xid, vx_flags_t *data);
00271 
00272 /*!
00273  * @brief Get system capabilities
00274  *
00275  * @param xid  Context ID
00276  * @param data Empty vx_flags_t struct to be filled
00277  */
00278 int vx_bcaps_get(xid_t xid, vx_flags_t *data);
00279 
00280 /*!
00281  * @brief Set context capabilities
00282  *
00283  * @param xid  Context ID
00284  * @param data Context capabilities
00285  */
00286 int vx_ccaps_set(xid_t xid, vx_flags_t *data);
00287 
00288 /*!
00289  * @brief Get context capabilities
00290  *
00291  * @param xid  Context ID
00292  * @param data Empty vx_flags_t struct to be filled
00293  */
00294 int vx_ccaps_get(xid_t xid, vx_flags_t *data);
00295 
00296 /*!
00297  * @brief Set context flags
00298  *
00299  * @param xid  Context ID
00300  * @param data Context flags
00301  */
00302 int vx_flags_set(xid_t xid, vx_flags_t *data);
00303 
00304 /*!
00305  * @brief Get context flags
00306  *
00307  * @param xid   Context ID
00308  * @param data Empty vx_flags_t struct to be filled
00309  */
00310 int vx_flags_get(xid_t xid, vx_flags_t *data);
00311 
00312 /*!
00313  * @brief Set virtual system information
00314  *
00315  * @param xid  Context ID
00316  * @param data Virtual system information data
00317  */
00318 int vx_uname_set(xid_t xid, vx_uname_t *data);
00319 
00320 /*!
00321  * @brief Get virtual system information
00322  *
00323  * @param xid  Context ID
00324  * @param data Empty vx_uname_t struct to be filled
00325  */
00326 int vx_uname_get(xid_t xid, vx_uname_t *data);
00327 
00328 /*!
00329  * @brief Kill one or more processes
00330  *
00331  * @param xid Context ID
00332  * @param pid Process ID
00333  * @param sig Signal number
00334  */
00335 int vx_kill(xid_t xid, pid_t pid, int sig);
00336 
00337 /*!
00338  * @brief Wait for context death
00339  *
00340  * @param xid  Context ID
00341  * @param data Empty vx_wait_t struct to be filled
00342  */
00343 int vx_wait(xid_t xid, vx_wait_t *data);
00344 /*! @} syscall_context */
00345 
00346 
00347 
00348 /*!
00349  * @defgroup syscall_sched CPU scheduler commands
00350  * @{
00351  */
00352 #ifndef _VX_SCHED_CMD_H
00353 #define VXSM_FILL_RATE  0x0001  /*!< Fill Rate */
00354 #define VXSM_INTERVAL   0x0002  /*!< Interval */
00355 #define VXSM_FILL_RATE2 0x0004  /*!< IDLE Fill Rate */
00356 #define VXSM_INTERVAL2  0x0008  /*!< IDLE Interval */
00357 #define VXSM_TOKENS     0x0010  /*!< Amount of tokens */
00358 #define VXSM_TOKENS_MIN 0x0020  /*!< Minimum amount of tokens */
00359 #define VXSM_TOKENS_MAX 0x0040  /*!< Maximum amount of tokens */
00360 #define VXSM_PRIO_BIAS  0x0100  /*!< Priority bias */
00361 
00362 #define VXSM_IDLE_TIME  0x0200  /*!< Use IDLE time settings */
00363 #define VXSM_FORCE      0x0400  /*!< Force scheduler reload (SMP only) */
00364 #define VXSM_CPU_ID     0x1000  /*!< CPU ID (SMP only) */
00365 #define VXSM_BUCKET_ID  0x2000  /*!< Bucket ID */
00366 #define VXSM_MSEC       0x4000  /*!< ?? */
00367 
00368 #define VXSM_V3_MASK    0x0173  /*!< Mask all fields for scheduler v3 */
00369 #define VXSM_SET_MASK   0x01FF  /*!< Mask all fields for set_sched */
00370 #endif
00371 
00372 /*!
00373  * @brief Scheduler values
00374  */
00375 typedef struct _vx_sched {
00376         uint32_t mask;        /*!< Set mask */
00377         int32_t cpu_id;       /*!< CPU ID (for SMP machines) */
00378         int32_t bucket_id;    /*!< Token Bucket ID */
00379         int32_t fill_rate[2]; /*!< Fill rate */
00380         int32_t interval[2];  /*!< Interval between fills */
00381         int32_t tokens;       /*!< Number of tokens in the bucket */
00382         int32_t tokens_min;   /*!< Minimum tokens to unhold the context */
00383         int32_t tokens_max;   /*!< Maximum number of tokens in the bucket */
00384         int32_t prio_bias;    /*!< Priority bias */
00385 } vx_sched_t;
00386 
00387 /*!
00388  * @brief Scheduler information
00389  */
00390 typedef struct _vx_sched_info {
00391         int32_t cpu_id;
00392         int32_t bucket_id;
00393         uint64_t user_msec;
00394         uint64_t sys_msec;
00395         uint64_t hold_msec;
00396         uint32_t token_usec;
00397         int32_t vavavoom;
00398 } vx_sched_info_t;
00399 
00400 /*!
00401  * @brief Set scheduler values
00402  *
00403  * @param xid  Context ID
00404  * @param data Scheduler values
00405  */
00406 int vx_sched_set(xid_t xid, vx_sched_t *data);
00407 
00408 /*!
00409  * @brief Get scheduler values
00410  *
00411  * @param xid  Context ID
00412  * @param data Scheduler values
00413  */
00414 int vx_sched_get(xid_t xid, vx_sched_t *data);
00415 
00416 /*!
00417  * @brief Get scheduler information
00418  *
00419  * @param xid  Context ID
00420  * @param data Scheduler information
00421  */
00422 int vx_sched_info(xid_t xid, vx_sched_info_t *data);
00423 
00424 
00425 /*! @} syscall_sched */
00426 
00427 
00428 
00429 /*!
00430  * @defgroup syscall_rlimit Resource limit commands
00431  * @{
00432  */
00433 #ifndef _VX_LIMIT_CMD_H
00434 #define CRLIM_UNSET     (0ULL)  /*!< Unset resource limit */
00435 #define CRLIM_INFINITY (~0ULL)  /*!< Infinity (no limit) */
00436 #define CRLIM_KEEP     (~1ULL)  /*!< Keep current value */
00437 #endif
00438 
00439 #ifndef _VX_LIMIT_H
00440 #define VLIMIT_NSOCK  16  /*!< Number of open sockets */
00441 #define VLIMIT_OPENFD 17  /*!< Number of open file descriptors */
00442 #define VLIMIT_ANON   18  /*!< Amount of anonymous memory */
00443 #define VLIMIT_SHMEM  19  /*!< Amount of shared memory */
00444 #define VLIMIT_SEMARY 20  /*!< Size of semary */
00445 #define VLIMIT_NSEMS  21  /*!< Number of semaphores */
00446 #define VLIMIT_DENTRY 22  /*!< Size of the dentry cache */
00447 #define VLIMIT_MAPPED 23  /*!< ?? */
00448 #endif
00449 
00450 /*!
00451  * @brief Resource limits
00452  */
00453 typedef struct _vx_limit {
00454         uint32_t id;        /*!< Limit ID */
00455         uint64_t minimum;   /*!< Minimum */
00456         uint64_t softlimit; /*!< Softlimit */
00457         uint64_t maximum;   /*!< Maximum */
00458 } vx_limit_t;
00459 
00460 /*!
00461  * @brief Resource limit accounting
00462  */
00463 typedef struct _vx_limit_stat {
00464         uint32_t id;      /*!< Limit ID */
00465         uint32_t hits;    /*!< Number of hits */
00466         uint64_t value;   /*!< Current value */
00467         uint64_t minimum; /*!< Minimum value */
00468         uint64_t maximum; /*!< Maximum value */
00469 } vx_limit_stat_t;
00470 
00471 /*!
00472  * @brief Get resource limits mask
00473  *
00474  * @param data Empty vx_limit_t struct to be filled
00475  */
00476 int vx_limit_mask_get(vx_limit_t *data);
00477 
00478 /*!
00479  * @brief Set resource limit
00480  *
00481  * @param xid  Context ID
00482  * @param data Resource limits
00483  */
00484 int vx_limit_set(xid_t xid, vx_limit_t *data);
00485 
00486 /*!
00487  * @brief Get resource limits
00488  *
00489  * @param xid  Context ID
00490  * @param data Empty vx_limit_t struct to be filled
00491  */
00492 int vx_limit_get(xid_t xid, vx_limit_t *data);
00493 
00494 /*!
00495  * @brief Get resource limit accounting data
00496  *
00497  * @param xid  Context ID
00498  * @param data Empty vx_limit_stat_t struct to be filled
00499  */
00500 int vx_limit_stat(xid_t xid, vx_limit_stat_t *data);
00501 
00502 /*!
00503  * @brief Reset resource limit accounting data
00504  *
00505  * @param xid Context ID
00506  */
00507 int vx_limit_reset(xid_t xid);
00508 /*! @} syscall_rlimit */
00509 
00510 
00511 
00512 /*!
00513  * @defgroup syscall_dlimit Disk limit commands
00514  * @{
00515  */
00516 #ifndef _VX_DLIMIT_CMD_H
00517 #define CDLIM_UNSET    ((uint32_t)0UL)   /*!< Unset disk limit */
00518 #define CDLIM_INFINITY ((uint32_t)~0UL)  /*!< Infinity (no limit) */
00519 #define CDLIM_KEEP     ((uint32_t)~1UL)  /*!< Keep current value */
00520 #endif
00521 
00522 /*!
00523  * @brief Disk limit values
00524  */
00525 typedef struct _dx_limit {
00526         const char *filename;  /*!< Mount point */
00527         uint32_t space_used;   /*!< Currently used space */
00528         uint32_t space_total;  /*!< Total space */
00529         uint32_t inodes_used;  /*!< Currently used inodes */
00530         uint32_t inodes_total; /*!< Total inodes */
00531         uint32_t reserved;     /*!< Space reserved for the root user */
00532         uint32_t flags;        /*!< Disk limit flags */
00533 } dx_limit_t;
00534 
00535 /*!
00536  * @brief Add disk limit entry
00537  *
00538  * @param xid  Context ID
00539  * @param data Disk limit information
00540  */
00541 int dx_limit_add(xid_t xid, dx_limit_t *data);
00542 
00543 /*!
00544  * @brief Remove disk limit
00545  *
00546  * @param xid  Context ID
00547  * @param data Disk limit information
00548  */
00549 int dx_limit_remove(xid_t xid, dx_limit_t *data);
00550 
00551 /*!
00552  * @brief Set disk limit values
00553  *
00554  * @param xid  Context ID
00555  * @param data Disk limit values
00556  */
00557 int dx_limit_set(xid_t xid, dx_limit_t *data);
00558 
00559 /*!
00560  * @brief Get disk limit values
00561  *
00562  * @param xid  Context ID
00563  * @param data Empty dx_limit_t struct to be filled
00564  */
00565 int dx_limit_get(xid_t xid, dx_limit_t *data);
00566 /*! @} syscall_dlimit */
00567 
00568 
00569 
00570 /*!
00571  * @defgroup syscall_inode Inode attribute commands
00572  * @{
00573  */
00574 #ifndef _VX_INODE_H
00575 #define IATTR_TAG       0x01000000  /*!< File is xid tagged */
00576 #define IATTR_ADMIN     0x00000001  /*!< Accessible in xid=0 (only for /proc) */
00577 #define IATTR_WATCH     0x00000002  /*!< Accessible in xid=1 (only for /proc) */
00578 #define IATTR_HIDE      0x00000004  /*!< Not Accessible in xid!=(0|1) (only for /proc) */
00579 #define IATTR_FLAGS     0x00000007  /*!< Flag mask for /proc flags */
00580 #define IATTR_BARRIER   0x00010000  /*!< Directory barrier */
00581 #define IATTR_IUNLINK   0x00020000  /*!< Unlink file */
00582 #define IATTR_IMMUTABLE 0x00040000  /*!< File is immutable */
00583 #endif
00584 
00585 /*!
00586  * @brief Inode attributes
00587  */
00588 typedef struct _ix_attr {
00589         const char *filename; /*!< Filename */
00590         xid_t xid;            /*!< Context ID */
00591         uint32_t flags;       /*!< Inode flags */
00592         uint32_t mask;        /*!< Set mask */
00593 } ix_attr_t;
00594 
00595 /*!
00596  * @brief Set inode attributes
00597  *
00598  * @param data Inode attributes
00599  */
00600 int ix_attr_set(ix_attr_t *data);
00601 
00602 /*!
00603  * @brief Get inode attributes
00604  *
00605  * @param data Empty ix_attr_t struct to be filled
00606  */
00607 int ix_attr_get(ix_attr_t *data);
00608 /*! @} syscall_inode */
00609 
00610 
00611 
00612 /*!
00613  * @defgroup syscall_space Namespace commands
00614  * @{
00615  */
00616 #ifndef _LINUX_SCHED_H
00617 #define CLONE_VM        0x00000100
00618 #define CLONE_FS        0x00000200
00619 #define CLONE_FILES     0x00000400
00620 #define CLONE_SIGHAND   0x00000800
00621 #define CLONE_PTRACE    0x00002000
00622 #define CLONE_VFORK     0x00004000
00623 #define CLONE_PARENT    0x00008000
00624 #define CLONE_THREAD    0x00010000
00625 #define CLONE_NEWNS     0x00020000
00626 #define CLONE_SYSVSEM   0x00040000
00627 #define CLONE_SETTLS    0x00080000
00628 #define CLONE_PARENT_SETTID     0x00100000
00629 #define CLONE_CHILD_CLEARTID    0x00200000
00630 #define CLONE_DETACHED          0x00400000
00631 #define CLONE_UNTRACED          0x00800000
00632 #define CLONE_CHILD_SETTID      0x01000000
00633 #define CLONE_STOPPED           0x02000000
00634 #define CLONE_NEWUTS            0x04000000
00635 #define CLONE_NEWIPC            0x08000000
00636 #define CLONE_KTHREAD           0x10000000
00637 #endif
00638 
00639 /*!
00640  * @brief Clone the current namespace (FS/IPC/UTS)
00641  *
00642  * @param flags       Clone flags
00643  * @param child_stack Child stack
00644  */
00645 int ns_clone(int flags, void *child_stack);
00646 
00647 /*!
00648  * @brief Enter namespace
00649  *
00650  * @param xid Context ID
00651  */
00652 int ns_enter(xid_t xid, uint64_t mask);
00653 
00654 /*!
00655  * @brief Set namespace
00656  *
00657  * @param xid Context ID
00658  */
00659 int ns_set(xid_t xid, uint64_t mask);
00660 /*! @} syscall_namespace */
00661 
00662 
00663 
00664 /*!
00665  * @defgroup syscall_network Network context commands
00666  * @{
00667  */
00668 #ifndef _VX_NETWORK_H
00669 #define NXF_INFO_PRIVATE 0x00000008  /*!< Network context cannot be entered */
00670 #define NXF_STATE_SETUP  (1ULL<<32)  /*!< Network context is in setup state */
00671 #define NXF_STATE_ADMIN  (1ULL<<34)  /*!< Context is in admin state */
00672 #define NXF_SC_HELPER    (1ULL<<36)  /*!< Network state change helper */
00673 #define NXF_PERSISTENT   (1ULL<<38)  /*!< Make network context persistent */
00674 
00675 #define NXA_TYPE_IPV4  1              /*!< Address is IPv4 */
00676 #define NXA_TYPE_IPV6  2              /*!< Address is IPv6 */
00677 #define NXA_MOD_BCAST (1<<8)          /*!< Address is Broadcast*/
00678 #define NXA_TYPE_ANY  ((uint16_t)-1)  /*!< Matches any address */
00679 #endif
00680 
00681 #ifndef _VX_CACCT_H
00682 #define VXA_SOCK_UNSPEC 0
00683 #define VXA_SOCK_UNIX   1
00684 #define VXA_SOCK_INET   2
00685 #define VXA_SOCK_INET6  3
00686 #define VXA_SOCK_PACKET 4
00687 #define VXA_SOCK_OTHER  5
00688 #endif
00689 
00690 #define NXA_SOCK_UNSPEC VXA_SOCK_UNSPEC
00691 #define NXA_SOCK_UNIX   VXA_SOCK_UNIX
00692 #define NXA_SOCK_INET   VXA_SOCK_INET
00693 #define NXA_SOCK_INET6  VXA_SOCK_INET6
00694 #define NXA_SOCK_PACKET VXA_SOCK_PACKET
00695 #define NXA_SOCK_OTHER  VXA_SOCK_OTHER
00696 
00697 typedef uint32_t nid_t; /*!< Network context ID type */
00698 
00699 /*!
00700  * @brief Network context information
00701  */
00702 typedef struct _nx_info {
00703         nid_t nid; /*!< Network context ID */
00704 } nx_info_t;
00705 
00706 /*!
00707  * @brief Network address information
00708  */
00709 typedef struct _nx_addr {
00710         uint16_t type;    /*!< Address type */
00711         uint16_t count;   /*!< Number of addresses in ip/mask */
00712         uint32_t ip[4];   /*!< Up to four adresses */
00713         uint32_t mask[4]; /*!< Up to four netmasks */
00714 } nx_addr_t;
00715 
00716 /*!
00717  * @brief Network context flags
00718  */
00719 typedef struct _nx_flags {
00720         uint64_t flags; /*!< Network context flags */
00721         uint64_t mask;  /*!< Set mask */
00722 } nx_flags_t;
00723 
00724 /*!
00725  * @brief Accounting data
00726  */
00727 typedef struct _nx_sock_stat {
00728         uint32_t id;       /*!< Socket type ID */
00729         uint32_t count[3]; /*!< Number of packets */
00730         uint64_t total[3]; /*!< Number of bytes */
00731 } nx_sock_stat_t;
00732 
00733 /*!
00734  * @brief Create network context
00735  *
00736  * @param nid  Network context ID
00737  * @param data Initial network context flags
00738  */
00739 int nx_create(nid_t nid, nx_flags_t *data);
00740 
00741 /*!
00742  * @brief Migrate to an existing network context
00743  *
00744  * @param nid Network context ID
00745  */
00746 int nx_migrate(nid_t nid);
00747 
00748 /*!
00749  * @brief Get the network context ID of a process
00750  *
00751  * @param pid Process ID
00752  *
00753  * @return Network context ID
00754  */
00755 int nx_task_nid(pid_t pid);
00756 
00757 /*!
00758  * @brief Get network context information
00759  *
00760  * @param nid  Network context ID
00761  * @param data Empty nx_info_t struct to be filled
00762  */
00763 int nx_info(nid_t nid, nx_info_t *data);
00764 
00765 /*!
00766  * @brief Add network context addresses
00767  *
00768  * @param nid  Network context ID
00769  * @param data Network address information
00770  */
00771 int nx_addr_add(nid_t nid, nx_addr_t *data);
00772 
00773 /*!
00774  * @brief Remove network context addresses
00775  *
00776  * @param nid  Network context ID
00777  * @param data Network address information
00778  */
00779 int nx_addr_remove(nid_t nid, nx_addr_t *data);
00780 
00781 /*!
00782  * @brief Set network context flags
00783  *
00784  * @param nid  Network context ID
00785  * @param data Network context flags
00786  */
00787 int nx_flags_set(nid_t nid, nx_flags_t *data);
00788 
00789 /*!
00790  * @brief Get network context flags
00791  *
00792  * @param nid  Network context ID
00793  * @param data Empty nx_flags_t struct to be filled
00794  */
00795 int nx_flags_get(nid_t nid, nx_flags_t *data);
00796 
00797 /*!
00798  * @brief Set network context capabilities
00799  *
00800  * @param nid  Network context ID
00801  * @param data Network context capabilities
00802  */
00803 int nx_caps_set(nid_t nid, nx_flags_t *data);
00804 
00805 /*!
00806  * @brief Get network context capabilities
00807  *
00808  * @param nid  Network context ID
00809  * @param data Empty nx_flags_t struct to be filled
00810  */
00811 int nx_caps_get(nid_t nid, nx_flags_t *data);
00812 
00813 /*!
00814  * @brief Get network socket accounting data
00815  *
00816  * @param nid  Network context ID
00817  * @param data Empty nx_sock_stat_t struct to be filled
00818  */
00819 int nx_sock_stat(nid_t nid, nx_sock_stat_t *data);
00820 /*! @} syscall_network */
00821 
00822 #endif /* _VSERVER_H_ */

Generated on Wed Jun 20 19:50:08 2007 for libvserver by  doxygen 1.5.2