util-vserver (libvserver)  0.30.216-pre3126
Functions
Syscall wrappers

Functions

int vc_syscall (uint32_t cmd, xid_t xid, void *data)
 The generic vserver syscallThis function executes the generic vserver syscall. It uses the correct syscallnumber (which may differ between the different architectures). More...
 
int vc_get_version ()
 Returns the version of the current kernel API. More...
 
vc_vci_t vc_get_vci ()
 Returns the kernel configuration bits. More...
 
xid_t vc_new_s_context (xid_t ctx, unsigned int remove_cap, unsigned int flags)
 Moves current process into a contextPuts current process into context ctx, removes the capabilities given in remove_cap and sets flags. More...
 
int vc_set_ipv4root (uint32_t bcast, size_t nb, struct vc_ip_mask_pair const *ips)
 Sets the ipv4root information. More...
 
xid_t vc_ctx_create (xid_t xid, struct vc_ctx_flags *flags)
 Creates a context without starting it.This functions initializes a new context. When already in a freshly created context, this old context will be discarded. More...
 
int vc_ctx_migrate (xid_t xid, uint_least64_t flags)
 Moves the current process into the specified context. More...
 
int vc_ctx_stat (xid_t xid, struct vc_ctx_stat *stat)
 Get some statistics about a context. More...
 
int vc_virt_stat (xid_t xid, struct vc_virt_stat *stat)
 Get more statistics about a context. More...
 
int vc_ctx_kill (xid_t ctx, pid_t pid, int sig)
 Sends a signal to a context/pidSpecial values for pid are: More...
 
xid_t vc_get_task_xid (pid_t pid)
 Returns the context of the given process. More...
 
int vc_wait_exit (xid_t xid)
 Waits for the end of a context.
 
int vc_get_rlimit (xid_t xid, int resource, struct vc_rlimit *lim)
 Returns the limits of resource. More...
 
int vc_set_rlimit (xid_t xid, int resource, struct vc_rlimit const *lim)
 Sets the limits of resource. More...
 
int vc_rlimit_stat (xid_t xid, int resource, struct vc_rlimit_stat *stat)
 Returns the current stats of resource. More...
 
int vc_reset_minmax (xid_t xid)
 Resets the minimum and maximum observed values of all resources. More...
 
int vc_get_iattr (char const *filename, xid_t *xid, uint_least32_t *flags, uint_least32_t *mask)
 Returns information about attributes and assigned context of a file.This function returns the VC_IATTR_XXX flags and about the assigned context of a file. To request an information, the appropriate bit in mask must be set and the corresponding parameter (xid or flags) must not be NULL. More...
 
xid_t vc_getfilecontext (char const *filename)
 Returns the context of filename This function calls vc_get_iattr() with appropriate arguments to determine the context of filename. In error-case or when no context is assigned, VC_NOCTX will be returned. To differ between both cases, errno must be examined. More...
 

Detailed Description

Functions which are calling the vserver syscall directly.

Function Documentation

xid_t vc_ctx_create ( xid_t  xid,
struct vc_ctx_flags flags 
)

Creates a context without starting it.This functions initializes a new context. When already in a freshly created context, this old context will be discarded.

Parameters
xidThe new context; special values are:
  • VC_DYNAMIC_XID which means to create a dynamic context
Returns
the xid of the created context, or VC_NOCTX on errors. errno will be set appropriately.
int vc_ctx_kill ( xid_t  ctx,
pid_t  pid,
int  sig 
)

Sends a signal to a context/pidSpecial values for pid are:

  • -1 which means every process in ctx except the init-process
  • 0 which means every process in ctx inclusive the init-process
int vc_ctx_migrate ( xid_t  xid,
uint_least64_t  flags 
)

Moves the current process into the specified context.

Parameters
xidThe new context
flagsThe flags, see VC_VXM_*
Returns
0 on success, -1 on errors
int vc_ctx_stat ( xid_t  xid,
struct vc_ctx_stat stat 
)

Get some statistics about a context.

Parameters
xidThe context to get stats about
statWhere to store the result
Returns
0 on success, -1 on errors.
int vc_get_iattr ( char const *  filename,
xid_t xid,
uint_least32_t *  flags,
uint_least32_t *  mask 
)

Returns information about attributes and assigned context of a file.This function returns the VC_IATTR_XXX flags and about the assigned context of a file. To request an information, the appropriate bit in mask must be set and the corresponding parameter (xid or flags) must not be NULL.

E.g. to receive the assigned context, the VC_IATTR_XID bit must be set in mask, and xid must point to valid memory.

Possible flags are VC_IATTR_ADMIN, VC_IATTR_WATCH , VC_IATTR_HIDE, VC_IATTR_BARRIER, VC_IATTR_IUNLINK and VC_IATTR_IMMUTABLE.

Parameters
filenameThe name of the file whose attributes shall be determined.
xidWhen non-zero and the VC_IATTR_XID bit is set in mask, the assigned context of filename will be stored there.
flagsWhen non-zero, a bitmask of current attributes will be stored there. These attributes must be requested explicitly by setting the appropriate bit in mask
maskPoints to a bitmask which tells which attributes shall be determined. On return, it will masquerade the attributes which were determined.
Precondition
mask!=0 && !((*mask&VC_IATTR_XID) && xid==0) && !((*mask&~VC_IATTR_XID) && flags==0)
int vc_get_rlimit ( xid_t  xid,
int  resource,
struct vc_rlimit lim 
)

Returns the limits of resource.

Parameters
xidThe id of the context
resourceThe resource which will be queried
limThe result which will be filled with the limits
Returns
0 on success, and -1 on errors.
xid_t vc_get_task_xid ( pid_t  pid)

Returns the context of the given process.

Parameters
pidthe process-id whose xid shall be determined; pid==0 means the current process.
Returns
the xid of process pid or -1 on errors
vc_vci_t vc_get_vci ( )

Returns the kernel configuration bits.

Returns
The kernel configuration bits
int vc_get_version ( )

Returns the version of the current kernel API.

Returns
The versionnumber of the kernel API
xid_t vc_getfilecontext ( char const *  filename)

Returns the context of filename This function calls vc_get_iattr() with appropriate arguments to determine the context of filename. In error-case or when no context is assigned, VC_NOCTX will be returned. To differ between both cases, errno must be examined.

WARNING: this function can modify errno although no error happened.

Parameters
filenameThe file to check
Returns
The assigned context, or VC_NOCTX when an error occured or no such assignment exists. errno will be 0 in the latter case
xid_t vc_new_s_context ( xid_t  ctx,
unsigned int  remove_cap,
unsigned int  flags 
)

Moves current process into a contextPuts current process into context ctx, removes the capabilities given in remove_cap and sets flags.

Parameters
ctxThe new context; special values for are
  • VC_SAMECTX which means the current context (just for changing caps and flags)
  • VC_DYNAMIC_XID which means the next free context; this value can be used by ordinary users also
remove_capThe linux capabilities which will be removed.
flagsSpecial flags which will be set.
Returns
The new context-id, or VC_NOCTX on errors; errno will be set appropriately

See http://vserver.13thfloor.at/Stuff/Logic.txt for details

int vc_reset_minmax ( xid_t  xid)

Resets the minimum and maximum observed values of all resources.

Parameters
xidThe id of the context
Returns
0 on success, and -1 on errors.
int vc_rlimit_stat ( xid_t  xid,
int  resource,
struct vc_rlimit_stat stat 
)

Returns the current stats of resource.

Parameters
xidThe id of the context
resourceThe resource which will be queried
statThe result which will be filled with the stats
Returns
0 on success, and -1 on errors.
int vc_set_ipv4root ( uint32_t  bcast,
size_t  nb,
struct vc_ip_mask_pair const *  ips 
)

Sets the ipv4root information.

Precondition
nb < NB_IPV4ROOT && ips != 0
int vc_set_rlimit ( xid_t  xid,
int  resource,
struct vc_rlimit const *  lim 
)

Sets the limits of resource.

Parameters
xidThe id of the context
resourceThe resource which will be queried
limThe new limits
Returns
0 on success, and -1 on errors.
int vc_syscall ( uint32_t  cmd,
xid_t  xid,
void *  data 
)

The generic vserver syscallThis function executes the generic vserver syscall. It uses the correct syscallnumber (which may differ between the different architectures).

Parameters
cmdthe command to be executed
xidthe xid on which the cmd shall be applied
dataadditional arguments; depends on cmd
Returns
depends on cmd; usually, -1 stands for an error
int vc_virt_stat ( xid_t  xid,
struct vc_virt_stat stat 
)

Get more statistics about a context.

Parameters
xidThe context to get stats about
statWhere to store the result
Returns
0 on success, -1 on errors.