diff -NurpP --minimal libvserver-0.1/kernel/context_cmd.h libvserver-0.1.1/kernel/context_cmd.h --- libvserver-0.1/kernel/context_cmd.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/context_cmd.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,73 @@ +#ifndef _VX_CONTEXT_CMD_H +#define _VX_CONTEXT_CMD_H + + +/* vinfo commands */ + +#define VCMD_task_xid VC_CMD(VINFO, 1, 0) + +#ifdef __KERNEL__ +extern int vc_task_xid(uint32_t, void __user *); + +#endif /* __KERNEL__ */ + +#define VCMD_vx_info VC_CMD(VINFO, 5, 0) + +struct vcmd_vx_info_v0 { + uint32_t xid; + uint32_t initpid; + /* more to come */ +}; + +#ifdef __KERNEL__ +extern int vc_vx_info(uint32_t, void __user *); + +#endif /* __KERNEL__ */ + + +/* context commands */ + +#define VCMD_ctx_create VC_CMD(VPROC, 1, 0) +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 0) + +#ifdef __KERNEL__ +extern int vc_ctx_create(uint32_t, void __user *); +extern int vc_ctx_migrate(uint32_t, void __user *); + +#endif /* __KERNEL__ */ + + +/* flag commands */ + +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0) +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0) + +struct vcmd_ctx_flags_v0 { + uint64_t flagword; + uint64_t mask; +}; + +#ifdef __KERNEL__ +extern int vc_get_cflags(uint32_t, void __user *); +extern int vc_set_cflags(uint32_t, void __user *); + +#endif /* __KERNEL__ */ + + +/* context caps commands */ + +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 0) +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 0) + +struct vcmd_ctx_caps_v0 { + uint64_t bcaps; + uint64_t ccaps; + uint64_t cmask; +}; + +#ifdef __KERNEL__ +extern int vc_get_ccaps(uint32_t, void __user *); +extern int vc_set_ccaps(uint32_t, void __user *); + +#endif /* __KERNEL__ */ +#endif /* _VX_CONTEXT_CMD_H */ diff -NurpP --minimal libvserver-0.1/kernel/context.h libvserver-0.1.1/kernel/context.h --- libvserver-0.1/kernel/context.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/context.h 2005-05-25 10:08:12.000000000 +0200 @@ -0,0 +1,154 @@ +#ifndef _VX_CONTEXT_H +#define _VX_CONTEXT_H + +#include + + +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */ +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */ + +#define VX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */ + +/* context flags */ + +#define VXF_INFO_LOCK 0x00000001 +#define VXF_INFO_SCHED 0x00000002 +#define VXF_INFO_NPROC 0x00000004 +#define VXF_INFO_PRIVATE 0x00000008 + +#define VXF_INFO_INIT 0x00000010 +#define VXF_INFO_HIDE 0x00000020 +#define VXF_INFO_ULIMIT 0x00000040 +#define VXF_INFO_NSPACE 0x00000080 + +#define VXF_SCHED_HARD 0x00000100 +#define VXF_SCHED_PRIO 0x00000200 +#define VXF_SCHED_PAUSE 0x00000400 + +#define VXF_VIRT_MEM 0x00010000 +#define VXF_VIRT_UPTIME 0x00020000 +#define VXF_VIRT_CPU 0x00040000 +#define VXF_VIRT_LOAD 0x00080000 + +#define VXF_HIDE_MOUNT 0x01000000 +#define VXF_HIDE_NETIF 0x02000000 + +#define VXF_STATE_SETUP (1ULL<<32) +#define VXF_STATE_INIT (1ULL<<33) + +#define VXF_FORK_RSS (1ULL<<48) +#define VXF_PROLIFIC (1ULL<<49) + +#define VXF_IGNEG_NICE (1ULL<<52) + +#define VXF_ONE_TIME (0x0003ULL<<32) + + +/* context caps */ + +#define VXC_CAP_MASK 0x00000000 + +#define VXC_SET_UTSNAME 0x00000001 +#define VXC_SET_RLIMIT 0x00000002 + +#define VXC_RAW_ICMP 0x00000100 +#define VXC_SYSLOG 0x00001000 + +#define VXC_SECURE_MOUNT 0x00010000 +#define VXC_SECURE_REMOUNT 0x00020000 +#define VXC_BINARY_MOUNT 0x00040000 + +#define VXC_QUOTA_CTL 0x00100000 + + +/* context state changes */ + +enum { + VSC_STARTUP = 1, + VSC_SHUTDOWN, +}; + + +#ifdef __KERNEL__ + +#include +#include +#include + +#include "limit_def.h" +#include "sched_def.h" +#include "cvirt_def.h" + +struct vx_info { + struct hlist_node vx_hlist; /* linked list of contexts */ + xid_t vx_id; /* context id */ + atomic_t vx_usecnt; /* usage count */ + atomic_t vx_tasks; /* tasks count */ + struct vx_info *vx_parent; /* parent context */ + int vx_state; /* context state */ + + struct namespace *vx_namespace; /* private namespace */ + struct fs_struct *vx_fs; /* private namespace fs */ + uint64_t vx_flags; /* context flags */ + uint64_t vx_bcaps; /* bounding caps (system) */ + uint64_t vx_ccaps; /* context caps (vserver) */ + + pid_t vx_initpid; /* PID of fake init process */ + + wait_queue_head_t vx_wait; /* context exit waitqueue */ + + struct _vx_limit limit; /* vserver limits */ + struct _vx_sched sched; /* vserver scheduler */ + struct _vx_cvirt cvirt; /* virtual/bias stuff */ + struct _vx_cacct cacct; /* context accounting */ + + char vx_name[65]; /* vserver name */ +}; + + +/* status flags */ + +#define VXS_HASHED 0x0001 +#define VXS_PAUSED 0x0010 +#define VXS_ONHOLD 0x0020 +#define VXS_SHUTDOWN 0x0100 +#define VXS_RELEASED 0x8000 + +/* check conditions */ + +#define VX_ADMIN 0x0001 +#define VX_WATCH 0x0002 +#define VX_HIDE 0x0004 +#define VX_HOSTID 0x0008 + +#define VX_IDENT 0x0010 +#define VX_EQUIV 0x0020 +#define VX_PARENT 0x0040 +#define VX_CHILD 0x0080 + +#define VX_ARG_MASK 0x00F0 + +#define VX_DYNAMIC 0x0100 +#define VX_STATIC 0x0200 + +#define VX_ATR_MASK 0x0F00 + + +extern void claim_vx_info(struct vx_info *, struct task_struct *); +extern void release_vx_info(struct vx_info *, struct task_struct *); + +extern struct vx_info *locate_vx_info(int); +extern struct vx_info *locate_or_create_vx_info(int); + +extern int get_xid_list(int, unsigned int *, int); +extern int xid_is_hashed(xid_t); + +extern int vx_migrate_task(struct task_struct *, struct vx_info *); + +extern long vs_state_change(struct vx_info *, unsigned int); + + +#endif /* __KERNEL__ */ +#else /* _VX_CONTEXT_H */ +#warning duplicate inclusion +#endif /* _VX_CONTEXT_H */ diff -NurpP --minimal libvserver-0.1/kernel/cvirt_cmd.h libvserver-0.1.1/kernel/cvirt_cmd.h --- libvserver-0.1/kernel/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/cvirt_cmd.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,7 @@ +#ifndef _VX_CVIRT_CMD_H +#define _VX_CVIRT_CMD_H + +/* cvirt vserver commands */ + + +#endif /* _VX_CVIRT_CMD_H */ diff -NurpP --minimal libvserver-0.1/kernel/cvirt_def.h libvserver-0.1.1/kernel/cvirt_def.h --- libvserver-0.1/kernel/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/cvirt_def.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,77 @@ +#ifndef _VX_CVIRT_DEF_H +#define _VX_CVIRT_DEF_H + +#include +#include +#include +#include +#include +#include + + +struct _vx_usage_stat { + uint64_t user; + uint64_t nice; + uint64_t system; + uint64_t softirq; + uint64_t irq; + uint64_t idle; + uint64_t iowait; +}; + +struct _vx_syslog { + wait_queue_head_t log_wait; + spinlock_t logbuf_lock; /* lock for the log buffer */ + + unsigned long log_start; /* next char to be read by syslog() */ + unsigned long con_start; /* next char to be sent to consoles */ + unsigned long log_end; /* most-recently-written-char + 1 */ + unsigned long logged_chars; /* #chars since last read+clear operation */ + + char log_buf[1024]; +}; + + +/* context sub struct */ + +struct _vx_cvirt { + int max_threads; /* maximum allowed threads */ + atomic_t nr_threads; /* number of current threads */ + atomic_t nr_running; /* number of running threads */ + atomic_t nr_uninterruptible; /* number of uninterruptible threads */ + + atomic_t nr_onhold; /* processes on hold */ + uint32_t onhold_last; /* jiffies when put on hold */ + + struct timespec bias_idle; + struct timespec bias_uptime; /* context creation point */ + uint64_t bias_clock; /* offset in clock_t */ + + struct new_utsname utsname; + + spinlock_t load_lock; /* lock for the load averages */ + atomic_t load_updates; /* nr of load updates done so far */ + uint32_t load_last; /* last time load was cacled */ + uint32_t load[3]; /* load averages 1,5,15 */ + + atomic_t total_forks; /* number of forks so far */ + + struct _vx_usage_stat cpustat[NR_CPUS]; + + struct _vx_syslog syslog; +}; + +struct _vx_sock_acc { + atomic_t count; + atomic_t total; +}; + +/* context sub struct */ + +struct _vx_cacct { + unsigned long total_forks; + + struct _vx_sock_acc sock[5][3]; +}; + +#endif /* _VX_CVIRT_DEF_H */ diff -NurpP --minimal libvserver-0.1/kernel/cvirt.h libvserver-0.1.1/kernel/cvirt.h --- libvserver-0.1/kernel/cvirt.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/cvirt.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,25 @@ +#ifndef _VX_CVIRT_H +#define _VX_CVIRT_H + +#ifdef __KERNEL__ + +struct timespec; + +void vx_vsi_uptime(struct timespec *, struct timespec *); + + +struct vx_info; + +void vx_update_load(struct vx_info *); + + +int vx_uts_virt_handler(struct ctl_table *ctl, int write, xid_t xid, + void **datap, size_t *lenp); + + +int vx_do_syslog(int, char __user *, int); + +#endif /* __KERNEL__ */ +#else /* _VX_CVIRT_H */ +#warning duplicate inclusion +#endif /* _VX_CVIRT_H */ diff -NurpP --minimal libvserver-0.1/kernel/dlimit_cmd.h libvserver-0.1.1/kernel/dlimit_cmd.h --- libvserver-0.1/kernel/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/dlimit_cmd.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,68 @@ +#ifndef _VX_DLIMIT_CMD_H +#define _VX_DLIMIT_CMD_H + +/* dlimit vserver commands */ + +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0) +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0) + +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0) +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0) + +struct vcmd_ctx_dlimit_base_v0 { + const char __user *name; + uint32_t flags; +}; + +struct vcmd_ctx_dlimit_v0 { + const char __user *name; + uint32_t space_used; /* used space in kbytes */ + uint32_t space_total; /* maximum space in kbytes */ + uint32_t inodes_used; /* used inodes */ + uint32_t inodes_total; /* maximum inodes */ + uint32_t reserved; /* reserved for root in % */ + uint32_t flags; +}; + + +#ifdef __KERNEL__ + +#ifdef CONFIG_COMPAT + +struct vcmd_ctx_dlimit_base_v0_x32 { + compat_uptr_t name_ptr; + uint32_t flags; +}; + +struct vcmd_ctx_dlimit_v0_x32 { + compat_uptr_t name_ptr; + uint32_t space_used; /* used space in kbytes */ + uint32_t space_total; /* maximum space in kbytes */ + uint32_t inodes_used; /* used inodes */ + uint32_t inodes_total; /* maximum inodes */ + uint32_t reserved; /* reserved for root in % */ + uint32_t flags; +}; + +#endif /* CONFIG_COMPAT */ + +#include + +extern int vc_add_dlimit(uint32_t, void __user *); +extern int vc_rem_dlimit(uint32_t, void __user *); + +extern int vc_set_dlimit(uint32_t, void __user *); +extern int vc_get_dlimit(uint32_t, void __user *); + +#ifdef CONFIG_COMPAT + +extern int vc_add_dlimit_x32(uint32_t, void __user *); +extern int vc_rem_dlimit_x32(uint32_t, void __user *); + +extern int vc_set_dlimit_x32(uint32_t, void __user *); +extern int vc_get_dlimit_x32(uint32_t, void __user *); + +#endif /* CONFIG_COMPAT */ + +#endif /* __KERNEL__ */ +#endif /* _VX_DLIMIT_CMD_H */ diff -NurpP --minimal libvserver-0.1/kernel/dlimit.h libvserver-0.1.1/kernel/dlimit.h --- libvserver-0.1/kernel/dlimit.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/dlimit.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,53 @@ +#ifndef _VX_DLIMIT_H +#define _VX_DLIMIT_H + +#include "switch.h" + +#define CDLIM_UNSET (0ULL) +#define CDLIM_INFINITY (~0ULL) +#define CDLIM_KEEP (~1ULL) + + +#ifdef __KERNEL__ + +#include + +struct super_block; + +struct dl_info { + struct hlist_node dl_hlist; /* linked list of contexts */ + struct rcu_head dl_rcu; /* the rcu head */ + xid_t dl_xid; /* context id */ + atomic_t dl_usecnt; /* usage count */ + atomic_t dl_refcnt; /* reference count */ + + struct super_block *dl_sb; /* associated superblock */ + + spinlock_t dl_lock; /* protect the values */ + + uint64_t dl_space_used; /* used space in bytes */ + uint64_t dl_space_total; /* maximum space in bytes */ + uint32_t dl_inodes_used; /* used inodes */ + uint32_t dl_inodes_total; /* maximum inodes */ + + unsigned int dl_nrlmult; /* non root limit mult */ +}; + +struct rcu_head; + +extern void rcu_free_dl_info(struct rcu_head *); +extern void unhash_dl_info(struct dl_info *); + +extern struct dl_info *locate_dl_info(struct super_block *, xid_t); + + +struct kstatfs; + +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *); + +typedef uint64_t dlsize_t; + +#endif /* __KERNEL__ */ +#else /* _VX_DLIMIT_H */ +#warning duplicate inclusion +#endif /* _VX_DLIMIT_H */ diff -NurpP --minimal libvserver-0.1/kernel/inode_cmd.h libvserver-0.1.1/kernel/inode_cmd.h --- libvserver-0.1/kernel/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/inode_cmd.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,57 @@ +#ifndef _VX_INODE_CMD_H +#define _VX_INODE_CMD_H + +/* inode vserver commands */ + +#define VCMD_get_iattr_v0 VC_CMD(INODE, 1, 0) +#define VCMD_set_iattr_v0 VC_CMD(INODE, 2, 0) + +#define VCMD_get_iattr VC_CMD(INODE, 1, 1) +#define VCMD_set_iattr VC_CMD(INODE, 2, 1) + +struct vcmd_ctx_iattr_v0 { + /* device handle in id */ + uint64_t ino; + uint32_t xid; + uint32_t flags; + uint32_t mask; +}; + +struct vcmd_ctx_iattr_v1 { + const char __user *name; + uint32_t xid; + uint32_t flags; + uint32_t mask; +}; + + +#ifdef __KERNEL__ + +#ifdef CONFIG_COMPAT + +struct vcmd_ctx_iattr_v1_x32 { + compat_uptr_t name_ptr; + uint32_t xid; + uint32_t flags; + uint32_t mask; +}; + +#endif /* CONFIG_COMPAT */ + +#include + +extern int vc_get_iattr_v0(uint32_t, void __user *); +extern int vc_set_iattr_v0(uint32_t, void __user *); + +extern int vc_get_iattr(uint32_t, void __user *); +extern int vc_set_iattr(uint32_t, void __user *); + +#ifdef CONFIG_COMPAT + +extern int vc_get_iattr_x32(uint32_t, void __user *); +extern int vc_set_iattr_x32(uint32_t, void __user *); + +#endif /* CONFIG_COMPAT */ + +#endif /* __KERNEL__ */ +#endif /* _VX_INODE_CMD_H */ diff -NurpP --minimal libvserver-0.1/kernel/inode.h libvserver-0.1.1/kernel/inode.h --- libvserver-0.1/kernel/inode.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/inode.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,41 @@ +#ifndef _VX_INODE_H +#define _VX_INODE_H + + +#define IATTR_XID 0x01000000 + +#define IATTR_ADMIN 0x00000001 +#define IATTR_WATCH 0x00000002 +#define IATTR_HIDE 0x00000004 +#define IATTR_FLAGS 0x00000007 + +#define IATTR_BARRIER 0x00010000 +#define IATTR_IUNLINK 0x00020000 +#define IATTR_IMMUTABLE 0x00040000 + +#ifdef __KERNEL__ + +#ifndef CONFIG_VSERVER +#warning config options missing +#endif + +#ifdef CONFIG_VSERVER_PROC_SECURE +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE ) +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN ) +#else +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN ) +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN ) +#endif + +#define vx_hide_check(c,m) (((m) & IATTR_HIDE) ? vx_check(c,m) : 1) + +#endif /* __KERNEL__ */ + +/* inode ioctls */ + +#define FIOC_GETXFLG _IOR('x', 5, long) +#define FIOC_SETXFLG _IOW('x', 6, long) + +#else /* _VX_INODE_H */ +#warning duplicate inclusion +#endif /* _VX_INODE_H */ diff -NurpP --minimal libvserver-0.1/kernel/limit_cmd.h libvserver-0.1.1/kernel/limit_cmd.h --- libvserver-0.1/kernel/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/limit_cmd.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,36 @@ +#ifndef _VX_LIMIT_CMD_H +#define _VX_LIMIT_CMD_H + +/* rlimit vserver commands */ + +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0) +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0) +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0) + +struct vcmd_ctx_rlimit_v0 { + uint32_t id; + uint64_t minimum; + uint64_t softlimit; + uint64_t maximum; +}; + +struct vcmd_ctx_rlimit_mask_v0 { + uint32_t minimum; + uint32_t softlimit; + uint32_t maximum; +}; + +#define CRLIM_UNSET (0ULL) +#define CRLIM_INFINITY (~0ULL) +#define CRLIM_KEEP (~1ULL) + +#ifdef __KERNEL__ + +#include + +extern int vc_get_rlimit(uint32_t, void __user *); +extern int vc_set_rlimit(uint32_t, void __user *); +extern int vc_get_rlimit_mask(uint32_t, void __user *); + +#endif /* __KERNEL__ */ +#endif /* _VX_LIMIT_CMD_H */ diff -NurpP --minimal libvserver-0.1/kernel/limit_def.h libvserver-0.1.1/kernel/limit_def.h --- libvserver-0.1/kernel/limit_def.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/limit_def.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,21 @@ +#ifndef _VX_LIMIT_DEF_H +#define _VX_LIMIT_DEF_H + +#include +#include + +#include "limit.h" + +/* context sub struct */ + +struct _vx_limit { + atomic_t ticks; + + unsigned long rlim[NUM_LIMITS]; /* Context limit */ + unsigned long rmax[NUM_LIMITS]; /* Context maximum */ + atomic_t rcur[NUM_LIMITS]; /* Current value */ + atomic_t lhit[NUM_LIMITS]; /* Limit hits */ +}; + + +#endif /* _VX_LIMIT_DEF_H */ diff -NurpP --minimal libvserver-0.1/kernel/limit.h libvserver-0.1.1/kernel/limit.h --- libvserver-0.1/kernel/limit.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/limit.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,23 @@ +#ifndef _VX_LIMIT_H +#define _VX_LIMIT_H + +#ifdef __KERNEL__ + +struct sysinfo; + +void vx_vsi_meminfo(struct sysinfo *); +void vx_vsi_swapinfo(struct sysinfo *); + +#define VXD_RLIMIT(r,l) (VXD_CBIT(limit, (l)) && ((r) == (l))) + +#define NUM_LIMITS 24 + +#define VLIMIT_NSOCK 16 +#define VLIMIT_OPENFD 17 +#define VLIMIT_ANON 18 +#define VLIMIT_SHMEM 19 + +extern const char *vlimit_name[NUM_LIMITS]; + +#endif /* __KERNEL__ */ +#endif /* _VX_LIMIT_H */ diff -NurpP --minimal libvserver-0.1/kernel/namespace.h libvserver-0.1.1/kernel/namespace.h --- libvserver-0.1/kernel/namespace.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/namespace.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,58 @@ +#ifndef _VX_NAMESPACE_H +#define _VX_NAMESPACE_H + +#include + + +/* virtual host info names */ + +#define VCMD_vx_set_vhi_name VC_CMD(VHOST, 1, 0) +#define VCMD_vx_get_vhi_name VC_CMD(VHOST, 2, 0) + +struct vcmd_vx_vhi_name_v0 { + uint32_t field; + char name[65]; +}; + + +enum vx_vhi_name_field { + VHIN_CONTEXT=0, + VHIN_SYSNAME, + VHIN_NODENAME, + VHIN_RELEASE, + VHIN_VERSION, + VHIN_MACHINE, + VHIN_DOMAINNAME, +}; + + +#ifdef __KERNEL__ + +#include + +extern int vc_set_vhi_name(uint32_t, void __user *); +extern int vc_get_vhi_name(uint32_t, void __user *); + +#endif /* __KERNEL__ */ + +#define VCMD_enter_namespace VC_CMD(PROCALT, 1, 0) +#define VCMD_cleanup_namespace VC_CMD(PROCALT, 2, 0) +#define VCMD_set_namespace VC_CMD(PROCALT, 3, 0) + +#ifdef __KERNEL__ + +struct vx_info; +struct namespace; +struct fs_struct; +struct vfsmount; + +extern int vx_set_namespace(struct vx_info *, struct namespace *, struct fs_struct *); + +extern int vc_enter_namespace(uint32_t, void __user *); +extern int vc_cleanup_namespace(uint32_t, void __user *); +extern int vc_set_namespace(uint32_t, void __user *); + +#endif /* __KERNEL__ */ +#else /* _VX_NAMESPACE_H */ +#warning duplicate inclusion +#endif /* _VX_NAMESPACE_H */ diff -NurpP --minimal libvserver-0.1/kernel/network_cmd.h libvserver-0.1.1/kernel/network_cmd.h --- libvserver-0.1/kernel/network_cmd.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/network_cmd.h 2005-05-25 10:10:52.000000000 +0200 @@ -0,0 +1,78 @@ +#ifndef _VX_NETWORK_CMD_H +#define _VX_NETWORK_CMD_H + + +/* vinfo commands */ + +#define VCMD_task_nid VC_CMD(VINFO, 2, 0) + +#ifdef __KERNEL__ +extern int vc_task_nid(uint32_t, void __user *); + +#endif /* __KERNEL__ */ + +#define VCMD_nx_info VC_CMD(VINFO, 6, 0) + +struct vcmd_nx_info_v0 { + uint32_t nid; + /* more to come */ +}; + +#ifdef __KERNEL__ +extern int vc_nx_info(uint32_t, void __user *); + +#endif /* __KERNEL__ */ + +#define VCMD_net_create VC_CMD(VNET, 1, 0) +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0) + +#define VCMD_net_add VC_CMD(NETALT, 1, 0) +#define VCMD_net_remove VC_CMD(NETALT, 2, 0) + +struct vcmd_net_nx_v0 { + uint16_t type; + uint16_t count; + uint32_t ip[4]; + uint32_t mask[4]; + /* more to come */ +}; + + +#ifdef __KERNEL__ +extern int vc_net_create(uint32_t, void __user *); +extern int vc_net_migrate(uint32_t, void __user *); + +#endif /* __KERNEL__ */ + +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0) +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0) + +struct vcmd_net_flags_v0 { + uint64_t flagword; + uint64_t mask; +}; + +#ifdef __KERNEL__ +extern int vc_get_nflags(uint32_t, void __user *); +extern int vc_set_nflags(uint32_t, void __user *); + +#endif /* __KERNEL__ */ + +#define IPF_STATE_SETUP (1ULL<<32) + +#define IPF_ONE_TIME (0x0001ULL<<32) + +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0) +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0) + +struct vcmd_net_caps_v0 { + uint64_t ncaps; + uint64_t cmask; +}; + +#ifdef __KERNEL__ +extern int vc_get_ncaps(uint32_t, void __user *); +extern int vc_set_ncaps(uint32_t, void __user *); + +#endif /* __KERNEL__ */ +#endif /* _VX_CONTEXT_CMD_H */ diff -NurpP --minimal libvserver-0.1/kernel/network.h libvserver-0.1.1/kernel/network.h --- libvserver-0.1/kernel/network.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/network.h 2005-05-25 10:08:26.000000000 +0200 @@ -0,0 +1,78 @@ +#ifndef _VX_NETWORK_H +#define _VX_NETWORK_H + +#include + + +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */ + +#define NX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */ + +#define NB_IPV4ROOT 16 + + +/* context flags */ + +#define NXF_STATE_SETUP (1ULL<<32) + + +#ifdef __KERNEL__ + +#include +#include +#include +#include + + +struct nx_info { + struct hlist_node nx_hlist; /* linked list of nxinfos */ + nid_t nx_id; /* vnet id */ + atomic_t nx_usecnt; /* usage count */ + atomic_t nx_tasks; /* tasks count */ + int nx_state; /* context state */ + + uint64_t nx_flags; /* network flag word */ + uint64_t nx_ncaps; /* network capabilities */ + + int nbipv4; + __u32 ipv4[NB_IPV4ROOT]; /* Process can only bind to these IPs */ + /* The first one is used to connect */ + /* and for bind any service */ + /* The other must be used explicity */ + __u32 mask[NB_IPV4ROOT]; /* Netmask for each ipv4 */ + /* Used to select the proper source */ + /* address for sockets */ + __u32 v4_bcast; /* Broadcast address to receive UDP */ + + char nx_name[65]; /* network context name */ +}; + + +/* status flags */ + +#define NXS_HASHED 0x0001 +#define NXS_SHUTDOWN 0x0100 +#define NXS_RELEASED 0x8000 + +extern struct nx_info *locate_nx_info(int); +extern struct nx_info *locate_or_create_nx_info(int); + +extern int get_nid_list(int, unsigned int *, int); +extern int nid_is_hashed(nid_t); + +extern int nx_migrate_task(struct task_struct *, struct nx_info *); + +struct in_ifaddr; +struct net_device; + +int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *); +int dev_in_nx_info(struct net_device *, struct nx_info *); + +struct sock; + +int nx_addr_conflict(struct nx_info *, uint32_t, struct sock *); + +#endif /* __KERNEL__ */ +#else /* _VX_NETWORK_H */ +#warning duplicate inclusion +#endif /* _VX_NETWORK_H */ diff -NurpP --minimal libvserver-0.1/kernel/sched_cmd.h libvserver-0.1.1/kernel/sched_cmd.h --- libvserver-0.1/kernel/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/sched_cmd.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,47 @@ +#ifndef _VX_SCHED_CMD_H +#define _VX_SCHED_CMD_H + +/* sched vserver commands */ + +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2) +#define VCMD_set_sched VC_CMD(SCHED, 1, 3) + +struct vcmd_set_sched_v2 { + int32_t fill_rate; + int32_t interval; + int32_t tokens; + int32_t tokens_min; + int32_t tokens_max; + uint64_t cpu_mask; +}; + +struct vcmd_set_sched_v3 { + uint32_t set_mask; + int32_t fill_rate; + int32_t interval; + int32_t tokens; + int32_t tokens_min; + int32_t tokens_max; + int32_t priority_bias; +}; + + +#define VXSM_FILL_RATE 0x0001 +#define VXSM_INTERVAL 0x0002 +#define VXSM_TOKENS 0x0010 +#define VXSM_TOKENS_MIN 0x0020 +#define VXSM_TOKENS_MAX 0x0040 +#define VXSM_PRIO_BIAS 0x0100 + +#define SCHED_KEEP (-2) + +#ifdef __KERNEL__ + +#include + +extern int vc_set_sched_v1(uint32_t, void __user *); +extern int vc_set_sched_v2(uint32_t, void __user *); +extern int vc_set_sched(uint32_t, void __user *); + +#endif /* __KERNEL__ */ +#endif /* _VX_SCHED_CMD_H */ diff -NurpP --minimal libvserver-0.1/kernel/sched_def.h libvserver-0.1.1/kernel/sched_def.h --- libvserver-0.1/kernel/sched_def.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/sched_def.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,38 @@ +#ifndef _VX_SCHED_DEF_H +#define _VX_SCHED_DEF_H + +#include +#include +#include +#include +#include + + +struct _vx_ticks { + uint64_t user_ticks; /* token tick events */ + uint64_t sys_ticks; /* token tick events */ + uint64_t hold_ticks; /* token ticks paused */ + uint64_t unused[5]; /* cacheline ? */ +}; + +/* context sub struct */ + +struct _vx_sched { + atomic_t tokens; /* number of CPU tokens */ + spinlock_t tokens_lock; /* lock for token bucket */ + + int fill_rate; /* Fill rate: add X tokens... */ + int interval; /* Divisor: per Y jiffies */ + int tokens_min; /* Limit: minimum for unhold */ + int tokens_max; /* Limit: no more than N tokens */ + uint32_t jiffies; /* last time accounted */ + + int priority_bias; /* bias offset for priority */ + int vavavoom; /* last calculated vavavoom */ + + cpumask_t cpus_allowed; /* cpu mask for context */ + + struct _vx_ticks cpu[NR_CPUS]; +}; + +#endif /* _VX_SCHED_DEF_H */ diff -NurpP --minimal libvserver-0.1/kernel/sched.h libvserver-0.1.1/kernel/sched.h --- libvserver-0.1/kernel/sched.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/sched.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,25 @@ +#ifndef _VX_SCHED_H +#define _VX_SCHED_H + +#ifdef __KERNEL__ + +struct timespec; + +void vx_vsi_uptime(struct timespec *, struct timespec *); + + +struct vx_info; + +void vx_update_load(struct vx_info *); + + +struct task_struct; + +int vx_effective_vavavoom(struct vx_info *, int); + +int vx_tokens_recalc(struct vx_info *); + +#endif /* __KERNEL__ */ +#else /* _VX_SCHED_H */ +#warning duplicate inclusion +#endif /* _VX_SCHED_H */ diff -NurpP --minimal libvserver-0.1/kernel/signal_cmd.h libvserver-0.1.1/kernel/signal_cmd.h --- libvserver-0.1/kernel/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/signal_cmd.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,25 @@ +#ifndef _VX_SIGNAL_CMD_H +#define _VX_SIGNAL_CMD_H + +/* signalling vserver commands */ + +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0) +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0) + +struct vcmd_ctx_kill_v0 { + int32_t pid; + int32_t sig; +}; + +struct vcmd_wait_exit_v0 { + int32_t a; + int32_t b; +}; + +#ifdef __KERNEL__ + +extern int vc_ctx_kill(uint32_t, void __user *); +extern int vc_wait_exit(uint32_t, void __user *); + +#endif /* __KERNEL__ */ +#endif /* _VX_SIGNAL_CMD_H */ diff -NurpP --minimal libvserver-0.1/kernel/switch.h libvserver-0.1.1/kernel/switch.h --- libvserver-0.1/kernel/switch.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/switch.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,97 @@ +#ifndef _VX_SWITCH_H +#define _VX_SWITCH_H + +#include + +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F) +#define VC_COMMAND(c) (((c) >> 16) & 0xFF) +#define VC_VERSION(c) ((c) & 0xFFF) + +#define VC_CMD(c,i,v) ((((VC_CAT_ ## c) & 0x3F) << 24) \ + | (((i) & 0xFF) << 16) | ((v) & 0xFFF)) + +/* + + Syscall Matrix V2.8 + + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL| + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | | + |INFO |SETUP | |MOVE | | | | | | + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICES| | + HOST | 00| 01| 02| 03| 04| 05| | 06| 07| + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | | + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15| + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ + MEMORY | | | | | | | |SWAP | | + | 16| 17| 18| 19| 20| 21| | 22| 23| + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | | + | 24| 25| 26| 27| 28| 29| | 30| 31| + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ + DISK | | | | |DLIMIT | | |INODE | | + VFS | 32| 33| 34| 35| 36| 37| | 38| 39| + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ + OTHER | | | | | | | |VINFO | | + | 40| 41| 42| 43| 44| 45| | 46| 47| + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+ + SPECIAL|EVENT | | | |FLAGS | | | | | + | 48| 49| 50| 51| 52| 53| | 54| 55| + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT | + | 56| 57| 58| 59| 60|TEST 61| | 62| 63| + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ + +*/ + +#define VC_CAT_VERSION 0 + +#define VC_CAT_VSETUP 1 +#define VC_CAT_VHOST 2 + +#define VC_CAT_VPROC 9 +#define VC_CAT_PROCALT 10 +#define VC_CAT_PROCMIG 11 +#define VC_CAT_PROCTRL 12 + +#define VC_CAT_SCHED 14 + +#define VC_CAT_VNET 25 +#define VC_CAT_NETALT 26 +#define VC_CAT_NETMIG 27 +#define VC_CAT_NETCTRL 28 + +#define VC_CAT_DLIMIT 36 +#define VC_CAT_INODE 38 + +#define VC_CAT_VINFO 46 +#define VC_CAT_EVENT 48 + +#define VC_CAT_FLAGS 52 +#define VC_CAT_DEBUG 56 +#define VC_CAT_RLIMIT 60 + +#define VC_CAT_SYSTEST 61 +#define VC_CAT_COMPAT 63 + +/* interface version */ + +#define VCI_VERSION 0x00010025 + + +/* query version */ + +#define VCMD_get_version VC_CMD(VERSION, 0, 0) + + +#ifdef __KERNEL__ + +#include + + +#else /* __KERNEL__ */ +#define __user +#endif /* __KERNEL__ */ + +#endif /* _VX_SWITCH_H */ diff -NurpP --minimal libvserver-0.1/kernel/xid.h libvserver-0.1.1/kernel/xid.h --- libvserver-0.1/kernel/xid.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/kernel/xid.h 2005-05-21 04:29:23.000000000 +0200 @@ -0,0 +1,135 @@ +#ifndef _VX_XID_H +#define _VX_XID_H + +#ifndef CONFIG_VSERVER +#warning config options missing +#endif + +#define XID_TAG(in) (!(in) || \ + (((struct inode *)in)->i_sb && \ + (((struct inode *)in)->i_sb->s_flags & MS_TAGXID))) + +#ifdef CONFIG_XID_TAG_NFSD +#define XID_TAG_NFSD 1 +#else +#define XID_TAG_NFSD 0 +#endif + + +#ifdef CONFIG_INOXID_NONE + +#define MAX_UID 0xFFFFFFFF +#define MAX_GID 0xFFFFFFFF + +#define INOXID_XID(tag, uid, gid, xid) (0) + +#define XIDINO_UID(tag, uid, xid) (uid) +#define XIDINO_GID(tag, gid, xid) (gid) + +#endif + + +#ifdef CONFIG_INOXID_GID16 + +#define MAX_UID 0xFFFFFFFF +#define MAX_GID 0x0000FFFF + +#define INOXID_XID(tag, uid, gid, xid) \ + ((tag) ? (((gid) >> 16) & 0xFFFF) : 0) + +#define XIDINO_UID(tag, uid, xid) (uid) +#define XIDINO_GID(tag, gid, xid) \ + ((tag) ? (((gid) & 0xFFFF) | ((xid) << 16)) : (gid)) + +#endif + + +#ifdef CONFIG_INOXID_UGID24 + +#define MAX_UID 0x00FFFFFF +#define MAX_GID 0x00FFFFFF + +#define INOXID_XID(tag, uid, gid, xid) \ + ((tag) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0) + +#define XIDINO_UID(tag, uid, xid) \ + ((tag) ? (((uid) & 0xFFFFFF) | (((xid) & 0xFF00) << 16)) : (uid)) +#define XIDINO_GID(tag, gid, xid) \ + ((tag) ? (((gid) & 0xFFFFFF) | (((xid) & 0x00FF) << 24)) : (gid)) + +#endif + + +#ifdef CONFIG_INOXID_UID16 + +#define MAX_UID 0x0000FFFF +#define MAX_GID 0xFFFFFFFF + +#define INOXID_XID(tag, uid, gid, xid) \ + ((tag) ? (((uid) >> 16) & 0xFFFF) : 0) + +#define XIDINO_UID(tag, uid, xid) \ + ((tag) ? (((uid) & 0xFFFF) | ((xid) << 16)) : (uid)) +#define XIDINO_GID(tag, gid, xid) (gid) + +#endif + + +#ifdef CONFIG_INOXID_INTERN + +#define MAX_UID 0xFFFFFFFF +#define MAX_GID 0xFFFFFFFF + +#define INOXID_XID(tag, uid, gid, xid) \ + ((tag) ? (xid) : 0) + +#define XIDINO_UID(tag, uid, xid) (uid) +#define XIDINO_GID(tag, gid, xid) (gid) + +#endif + + +#ifdef CONFIG_INOXID_RUNTIME + +#define MAX_UID 0xFFFFFFFF +#define MAX_GID 0xFFFFFFFF + +#define INOXID_XID(tag, uid, gid, xid) (0) + +#define XIDINO_UID(tag, uid, xid) (uid) +#define XIDINO_GID(tag, gid, xid) (gid) + +#endif + + +#define INOXID_UID(tag, uid, gid) \ + ((tag) ? ((uid) & MAX_UID) : (uid)) +#define INOXID_GID(tag, uid, gid) \ + ((tag) ? ((gid) & MAX_GID) : (gid)) + + +static inline uid_t vx_map_uid(uid_t uid) +{ + if ((uid > MAX_UID) && (uid != -1)) + uid = -2; + return (uid & MAX_UID); +} + +static inline gid_t vx_map_gid(gid_t gid) +{ + if ((gid > MAX_GID) && (gid != -1)) + gid = -2; + return (gid & MAX_GID); +} + + +#ifdef CONFIG_VSERVER_LEGACY +#define FIOC_GETXID _IOR('x', 1, long) +#define FIOC_SETXID _IOW('x', 2, long) +#define FIOC_SETXIDJ _IOW('x', 3, long) +#endif + +int vx_parse_xid(char *string, xid_t *xid, int remove); +void vx_propagate_xid(struct nameidata *nd, struct inode *inode); + +#endif /* _VX_XID_H */ diff -NurpP --minimal libvserver-0.1/lib/context.c libvserver-0.1.1/lib/context.c --- libvserver-0.1/lib/context.c 2005-06-28 23:41:22.000000000 +0200 +++ libvserver-0.1.1/lib/context.c 2005-07-01 11:02:00.000000000 +0200 @@ -22,7 +22,7 @@ #include #endif -#include "vserver.h" +#include "libvserver.h" int vc_task_xid(pid_t pid) { diff -NurpP --minimal libvserver-0.1/lib/dlimit.c libvserver-0.1.1/lib/dlimit.c --- libvserver-0.1/lib/dlimit.c 2005-06-28 23:41:50.000000000 +0200 +++ libvserver-0.1.1/lib/dlimit.c 2005-07-01 11:02:04.000000000 +0200 @@ -22,7 +22,7 @@ #include #endif -#include "vserver.h" +#include "libvserver.h" int vc_add_dlimit(xid_t xid, struct vcmd_ctx_dlimit_base_v0 *dbase) { diff -NurpP --minimal libvserver-0.1/lib/inode.c libvserver-0.1.1/lib/inode.c --- libvserver-0.1/lib/inode.c 2005-06-28 23:42:00.000000000 +0200 +++ libvserver-0.1.1/lib/inode.c 2005-07-01 11:01:18.000000000 +0200 @@ -22,7 +22,7 @@ #include #endif -#include "vserver.h" +#include "libvserver.h" int vc_get_iattr_v0(struct vcmd_ctx_iattr_v1 *iattr) { diff -NurpP --minimal libvserver-0.1/lib/libvserver.h libvserver-0.1.1/lib/libvserver.h --- libvserver-0.1/lib/libvserver.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/lib/libvserver.h 2005-07-01 11:03:16.000000000 +0200 @@ -0,0 +1,125 @@ +/*************************************************************************** + * Copyright (C) 2005 by Benedikt Boehm * + * hollow@gentoo.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include + +//#include "kernel/context.h" +#include "kernel/context_cmd.h" +//#include "kernel/cvirt.h" +//#include "kernel/cvirt_cmd.h" +//#include "kernel/cvirt_def.h" +//#include "kernel/dlimit.h" +#include "kernel/dlimit_cmd.h" +//#include "kernel/inode.h" +#include "kernel/inode_cmd.h" +//#include "kernel/limit.h" +#include "kernel/limit_cmd.h" +//#include "kernel/limit_def.h" +#include "kernel/namespace.h" +//#include "kernel/network.h" +#include "kernel/network_cmd.h" +//#include "kernel/sched.h" +#include "kernel/sched_cmd.h" +//#include "kernel/sched_def.h" +#include "kernel/signal_cmd.h" +#include "kernel/switch.h" +//#include "kernel/xid.h" + +#include "syscall.h" +#include "vserver.h" + +#define CMD_VERSION \ + printf("%s %s -- %s\n", NAME, VERSION, DESCR); \ + printf("This program is part of libvserver %s\n\n", LIBVSERVER_VERSION); \ + \ + printf("Copyright (c) 2005 Benedikt Boehm \n"); \ + printf("This program is free software; you can redistribute it and/or\n"); \ + printf("modify it under the terms of the GNU General Public License\n"); \ + exit(0); + + +/* Constants */ +#define LIBVSERVER_VERSION "0.1" + +/* Type definitions */ +typedef uint32_t xid_t; +typedef uint32_t nid_t; + +/* context.c */ +extern int vc_task_xid(pid_t pid); +extern int vc_vx_info(xid_t xid, struct vcmd_vx_info_v0 *info); +extern int vc_ctx_create(xid_t xid); +extern int vc_ctx_migrate(xid_t xid); +extern int vc_get_cflags(xid_t xid, struct vcmd_ctx_flags_v0 *cflags); +extern int vc_set_cflags(xid_t xid, struct vcmd_ctx_flags_v0 *cflags); +extern int vc_get_ccaps(xid_t xid, struct vcmd_ctx_caps_v0 *ccaps); +extern int vc_set_ccaps(xid_t xid, struct vcmd_ctx_caps_v0 *ccaps); + +/* dlimit.c */ +extern int vc_add_dlimit(xid_t xid, struct vcmd_ctx_dlimit_base_v0 *dbase); +extern int vc_rem_dlimit(xid_t xid, struct vcmd_ctx_dlimit_base_v0 *dbase); +extern int vc_set_dlimit(xid_t xid, struct vcmd_ctx_dlimit_v0 *dlimit); +extern int vc_get_dlimit(xid_t xid, struct vcmd_ctx_dlimit_v0 *dlimit); + +/* inode.c */ +extern int vc_get_iattr_v0(struct vcmd_ctx_iattr_v1 *iattr); +extern int vc_set_iattr_v0(struct vcmd_ctx_iattr_v1 *iattr); +extern int vc_get_iattr(struct vcmd_ctx_iattr_v0 *iattr); +extern int vc_set_iattr(struct vcmd_ctx_iattr_v0 *iattr); + +/* limit.c */ +extern int vc_get_rlimit(xid_t xid, struct vcmd_ctx_rlimit_v0 *rlimit); +extern int vc_set_rlimit(xid_t xid, struct vcmd_ctx_rlimit_v0 *rlimit); +extern int vc_get_rlimit_mask(xid_t xid, struct vcmd_ctx_rlimit_mask_v0 *rmask); + +/* namespace.c */ +extern int vc_set_vhi_name(xid_t xid, struct vcmd_vx_vhi_name_v0 *vhiname); +extern int vc_get_vhi_name(xid_t xid, struct vcmd_vx_vhi_name_v0 *vhiname); +extern int vc_enter_namespace(xid_t xid); +extern int vc_cleanup_namespace(); +extern int vc_set_namespace(); + +/* network.c */ +extern int vc_task_nid(pid_t pid); +extern int vc_nx_info(nid_t nid, struct vcmd_nx_info_v0 *info); +extern int vc_net_create(nid_t nid); +extern int vc_net_migrate(nid_t nid); +extern int vc_net_add(nid_t nid, struct vcmd_net_nx_v0 *nx); +extern int vc_net_remove(nid_t nid, struct vcmd_net_nx_v0 *nx); +extern int vc_get_nflags(nid_t nid, struct vcmd_net_flags_v0 *flags); +extern int vc_set_nflags(nid_t nid, struct vcmd_net_flags_v0 *flags); +extern int vc_get_ncaps(nid_t nid, struct vcmd_net_caps_v0 *caps); +extern int vc_set_ncaps(nid_t nid, struct vcmd_net_caps_v0 *caps); + +/* sched.c */ +extern int vc_set_sched_v2(xid_t xid, struct vcmd_set_sched_v2 *sched); +extern int vc_set_sched(xid_t xid, struct vcmd_set_sched_v3 *sched); + +/* signal.c */ +extern int vc_ctx_kill(xid_t xid, struct vcmd_ctx_kill_v0 *kill); +extern int vc_wait_exit(xid_t xid, struct vcmd_wait_exit_v0 *wait); + +/* switch.c */ +extern int vc_get_version(); diff -NurpP --minimal libvserver-0.1/lib/limit.c libvserver-0.1.1/lib/limit.c --- libvserver-0.1/lib/limit.c 2005-06-28 23:42:04.000000000 +0200 +++ libvserver-0.1.1/lib/limit.c 2005-07-01 11:01:24.000000000 +0200 @@ -22,7 +22,7 @@ #include #endif -#include "vserver.h" +#include "libvserver.h" int vc_get_rlimit(xid_t xid, struct vcmd_ctx_rlimit_v0 *rlimit) { diff -NurpP --minimal libvserver-0.1/lib/Makefile.am libvserver-0.1.1/lib/Makefile.am --- libvserver-0.1/lib/Makefile.am 2005-06-30 14:51:42.000000000 +0200 +++ libvserver-0.1.1/lib/Makefile.am 2005-07-01 18:58:26.000000000 +0200 @@ -2,12 +2,7 @@ INCLUDES = $(all_includes) # the library search path. -nobase_include_HEADERS = vserver.h vserver/context.h vserver/context_cmd.h \ - vserver/cvirt.h vserver/cvirt_cmd.h vserver/cvirt_def.h vserver/dlimit.h \ - vserver/dlimit_cmd.h vserver/inode.h vserver/inode_cmd.h vserver/limit.h vserver/limit_cmd.h \ - vserver/limit_def.h vserver/namespace.h vserver/network.h vserver/network_cmd.h \ - vserver/sched.h vserver/sched_cmd.h vserver/sched_def.h vserver/signal_cmd.h \ - vserver/switch.h vserver/syscall.h vserver/xid.h +nobase_include_HEADERS = libvserver.h lib_LIBRARIES = libvserver.a libvserver_a_SOURCES = context.c dlimit.c inode.c limit.c namespace.c network.c \ diff -NurpP --minimal libvserver-0.1/lib/Makefile.in libvserver-0.1.1/lib/Makefile.in --- libvserver-0.1/lib/Makefile.in 2005-06-30 15:13:20.000000000 +0200 +++ libvserver-0.1.1/lib/Makefile.in 2005-07-01 19:01:41.000000000 +0200 @@ -185,13 +185,7 @@ target_alias = @target_alias@ INCLUDES = $(all_includes) # the library search path. -nobase_include_HEADERS = vserver.h vserver/context.h vserver/context_cmd.h \ - vserver/cvirt.h vserver/cvirt_cmd.h vserver/cvirt_def.h vserver/dlimit.h \ - vserver/dlimit_cmd.h vserver/inode.h vserver/inode_cmd.h vserver/limit.h vserver/limit_cmd.h \ - vserver/limit_def.h vserver/namespace.h vserver/network.h vserver/network_cmd.h \ - vserver/sched.h vserver/sched_cmd.h vserver/sched_def.h vserver/signal_cmd.h \ - vserver/switch.h vserver/syscall.h vserver/xid.h - +nobase_include_HEADERS = libvserver.h lib_LIBRARIES = libvserver.a libvserver_a_SOURCES = context.c dlimit.c inode.c limit.c namespace.c network.c \ sched.c signal.c switch.c @@ -378,7 +372,6 @@ distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) - $(mkdir_p) $(distdir)/vserver @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ diff -NurpP --minimal libvserver-0.1/lib/namespace.c libvserver-0.1.1/lib/namespace.c --- libvserver-0.1/lib/namespace.c 2005-06-29 08:27:16.000000000 +0200 +++ libvserver-0.1.1/lib/namespace.c 2005-07-01 11:01:29.000000000 +0200 @@ -22,7 +22,7 @@ #include #endif -#include "vserver.h" +#include "libvserver.h" int vc_set_vhi_name(xid_t xid, struct vcmd_vx_vhi_name_v0 *vhiname) { diff -NurpP --minimal libvserver-0.1/lib/network.c libvserver-0.1.1/lib/network.c --- libvserver-0.1/lib/network.c 2005-06-28 23:45:45.000000000 +0200 +++ libvserver-0.1.1/lib/network.c 2005-07-01 11:01:34.000000000 +0200 @@ -22,7 +22,7 @@ #include #endif -#include "vserver.h" +#include "libvserver.h" int vc_task_nid(pid_t pid) { diff -NurpP --minimal libvserver-0.1/lib/sched.c libvserver-0.1.1/lib/sched.c --- libvserver-0.1/lib/sched.c 2005-06-28 23:42:14.000000000 +0200 +++ libvserver-0.1.1/lib/sched.c 2005-07-01 11:01:38.000000000 +0200 @@ -22,7 +22,7 @@ #include #endif -#include "vserver.h" +#include "libvserver.h" int vc_set_sched_v2(xid_t xid, struct vcmd_set_sched_v2 *sched) { diff -NurpP --minimal libvserver-0.1/lib/signal.c libvserver-0.1.1/lib/signal.c --- libvserver-0.1/lib/signal.c 2005-06-28 23:42:19.000000000 +0200 +++ libvserver-0.1.1/lib/signal.c 2005-07-01 11:01:44.000000000 +0200 @@ -22,7 +22,7 @@ #include #endif -#include "vserver.h" +#include "libvserver.h" int vc_ctx_kill(xid_t xid, struct vcmd_ctx_kill_v0 *kill) { diff -NurpP --minimal libvserver-0.1/lib/switch.c libvserver-0.1.1/lib/switch.c --- libvserver-0.1/lib/switch.c 2005-06-28 23:42:25.000000000 +0200 +++ libvserver-0.1.1/lib/switch.c 2005-07-01 11:01:51.000000000 +0200 @@ -22,7 +22,7 @@ #include #endif -#include "vserver.h" +#include "libvserver.h" int vc_get_version() { diff -NurpP --minimal libvserver-0.1/lib/syscall.h libvserver-0.1.1/lib/syscall.h --- libvserver-0.1/lib/syscall.h 1970-01-01 01:00:00.000000000 +0100 +++ libvserver-0.1.1/lib/syscall.h 2005-06-01 14:26:01.000000000 +0200 @@ -0,0 +1,952 @@ + +#ifndef __syscall_retval +#define __syscall_retval(v) do { } while(0) +#endif + +#ifndef __syscall_error +#define __syscall_error(e) do { errno = (e); } while(0) +#endif + +#define __check(pos, reg) \ + ".ifnc\t" pos ", " reg "\n\t" \ + ".err\t/* register assertion failed */\n\t" \ + ".endif\n\t" + +#ifndef __stringify0 +#define __stringify0(val) #val +#endif + +#ifndef __stringify +#define __stringify(val) __stringify0(val) +#endif + +#define __comment(name) \ + "\t/* kernel sys_" #name "[" __stringify(__NR_##name) "] */" + + + /* argument concatenation */ + +#define __arglst_6(x,head,tail...) __arglst_5(x,tail)x(6,head) +#define __arglst_5(x,head,tail...) __arglst_4(x,tail)x(5,head) +#define __arglst_4(x,head,tail...) __arglst_3(x,tail)x(4,head) +#define __arglst_3(x,head,tail...) __arglst_2(x,tail)x(3,head) +#define __arglst_2(x,head,tail...) __arglst_1(x,tail)x(2,head) +#define __arglst_1(x,head,tail...) x(1,head) +#define __arglst_0(x,head,tail...) + + /* string concatenation */ + +#define __concat_6(x) __concat_5(x)x(6) +#define __concat_5(x) __concat_4(x)x(5) +#define __concat_4(x) __concat_3(x)x(4) +#define __concat_3(x) __concat_2(x)x(3) +#define __concat_2(x) __concat_1(x)x(2) +#define __concat_1(x) __concat_0(x)x(1) +#define __concat_0(x) x(0) + + /* argument selection */ + +#define __arg_0(a0,a1,a2,a3,a4,a5,a6) a0 +#define __arg_1(a0,a1,a2,a3,a4,a5,a6) a1 +#define __arg_2(a0,a1,a2,a3,a4,a5,a6) a2 +#define __arg_3(a0,a1,a2,a3,a4,a5,a6) a3 +#define __arg_4(a0,a1,a2,a3,a4,a5,a6) a4 +#define __arg_5(a0,a1,a2,a3,a4,a5,a6) a5 +#define __arg_6(a0,a1,a2,a3,a4,a5,a6) a6 + + +/* ***************************************** + ALPHA ALPHA ALPHA ALPHA * + alpha kernel interface */ + +#if defined(__alpha__) + +/* The Alpha calling convention doesn't use the stack until + after the first six arguments have been passed in registers. + + scnr: a0($0) + args: a1($16), a2($17), a3($18), a4($19), a5($20), a6($21) + sret: r0($0) + serr: e0($19) (!=0, err=sret) + call: callsys + clob: memory +*/ + +#define __syscall_reg_ret "$0" +#define __syscall_reg_err "$19" +#define __syscall_reg_cid "$0" +#define __syscall_cmd_seq "callsys" +#define __syscall_clobbers \ + "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \ + "$22", "$23", "$24", "$25", "$27", "$28", "memory" \ + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "$16", "$17", "$18", "$19", "$20", "$21") +#define __syscall_clb_arg(n) __arg_##n \ + ("", "$16", "$17", "$18", "memory", "$20", "$21") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0%1%2","%3","%4","%5","%6","%7","%8") +#define __syscall_reg_ckr(n) __arg_##n \ + ("$0$19$0","$16","$17","$18","$19","$20","$21") + + + +/* ***************************************** + ARM ARM ARM ARM * + arm kernel interface */ + +#elif defined(__arm__) + +/* The Arm calling convention uses stack args after four arguments + but the Linux kernel gets up to seven arguments in registers. + + scnr: imm + args: a1(r0), a2(r1), a3(r2), a4(r3), a5(r4), a6(r5), + sret: r0(r0) + serr: (sret >= (unsigned)-EMAXERRNO) + call: swi + clob: memory +*/ + +#define __syscall_maxerrno 125 +#define __syscall_regtype long +#define __syscall_reg_res "r0" +#define __syscall_imm_cid +#define __syscall_cmd_seq "swi\t%1" +#define __syscall_clobbers "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "r0", "r1", "r2", "r3", "r4", "r5") +#define __syscall_clb_arg(n) __arg_##n \ + ("", "memory", "r1", "r2", "r3", "r4", "r5") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0","%2","%3","%4","%5","%6","%7") +#define __syscall_reg_ckr(n) __arg_##n \ + ("r0","r0","r1","r2","r3","r4","r5") + + + +/* ***************************************** + CRIS CRIS CRIS CRIS * + cris v10 kernel interface */ + +#elif defined(__cris__) + +/* The Cris calling convention uses stack args after four arguments + but the Linux kernel gets up to six arguments in registers. + + scnr: id(r9) + args: a1(r10), a2(r11), a3(r12), a4(r13), a5(mof), a6(srp), + sret: r0(r10) + serr: (sret >= (unsigned)-EMAXERRNO) + call: break 13 + clob: memory +*/ + +#define __syscall_maxerrno 125 +#define __syscall_reg_res "r0" +#define __syscall_reg_cid "r9" +#define __syscall_cmd_seq "break 13" +#define __syscall_clobbers "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "r10", "r11", "r12", "r13", "mof", "srp") +#define __syscall_clb_arg(n) __arg_##n \ + ("", "memory", "r11", "r12", "r13", "memory", "memory") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0%1","%2","%3","%4","%5","%6","%7") +#define __syscall_reg_ckr(n) __arg_##n \ + ("r9r10","r10","r11","r12","r13","mof","srp") + +#ifndef _syscall5 +#define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5) \ +type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ +{ \ + ____sc_results; \ + { \ + ____sc_reg_ret; \ + ____sc_reg_cid(__NR_##name) \ + ____sc_regs(4, arg4, arg3, arg2, arg1); \ + ____sc_asm ( \ + ____sc_check(4) \ + "move\t%6,$mof\n\t" \ + ____sc_syscall(name) \ + : ____sc_output \ + : ____sc_input_cid(__NR_##name) \ + ____sc_input_4, \ + "g"((__syscall_regtype)(arg5)) \ + : ____sc_clobber_4 \ + ); \ + ____sc_reg_results; \ + } \ + ____sc_return(type) \ +} +#endif + +#ifndef _syscall6 +#define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5, type6, arg6) \ +type name (type1 arg1, type2 arg2, type3 arg3, \ + type4 arg4, type5 arg5, type6 arg6) \ +{ \ + ____sc_results; \ + { \ + ____sc_reg_ret; \ + ____sc_reg_cid(__NR_##name) \ + ____sc_regs(4, arg4, arg3, arg2, arg1); \ + ____sc_asm ( \ + ____sc_check(4) \ + "move\t%6,$mof\n\t" \ + "move\t%7,$srp\n\t" \ + ____sc_syscall(name) \ + : ____sc_output \ + : ____sc_input_cid(__NR_##name) \ + ____sc_input_4, \ + "g"((__syscall_regtype)(arg5)), \ + "g"((__syscall_regtype)(arg6)) \ + : ____sc_clobber_4 \ + ); \ + ____sc_reg_results; \ + } \ + ____sc_return(type) \ +} +#endif + + +/* ***************************************** + FRV FRV FRV FRV * + frv kernel interface */ + +#elif defined(__frv__) + +/* The C calling convention on FR-V uses the gr8-gr13 registers + for the first six arguments, the remainder is spilled onto the + stack. the linux kernel syscall interface does so too. + + scnr: id(gr7) + args: a1(gr8), a2(gr9), a3(gr10), a4(gr11), a5(gr12), a6(gr13) + sret: r0(gr8) + serr: (sret >= (unsigned)-EMAXERRNO) + call: tra gr0,gr0 + clob: memory +*/ + +#define __syscall_maxerrno 125 +#define __syscall_reg_res "gr8" +#define __syscall_reg_cid "gr7" +#define __syscall_cmd_seq "tra\tgr0,gr0" +#define __syscall_clobbers "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "gr8", "gr9", "gr10", "gr11", "gr12", "gr13") +#define __syscall_clb_arg(n) __arg_##n \ + ("", "memory", "gr9", "gr10", "gr11", "gr12", "gr13") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0%1","%2","%3","%4","%5","%6","%7") +#define __syscall_reg_ckr(n) __arg_##n \ + ("gr8gr7","gr8","gr9","gr10","gr11","gr12","gr13") + + +/* ***************************************** + H8300 H8300 H8300 H8300 * + h8/300 kernel interface */ + +#elif defined(__H8300__) + +/* The H8/300 C calling convention passes the first three + arguments in registers. However the linux kernel calling + convention passes the first six arguments in registers + er1-er6 + + scnr: id(er0) + args: a1(er1), a2(er2), a3(er3), a4(er4), a5(er5), a6(er6) + sret: r0(er0) + serr: (sret >= (unsigned)-EMAXERRNO) + call: trapa #0 + clob: memory +*/ + +#define __syscall_maxerrno 125 +#define __syscall_reg_res "er0" +#define __syscall_imm_cid +#define __syscall_cmd_seq "trapa\t#0" +#define __syscall_clobbers "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "memory", "er2", "er3", "er4", "er5", "memory") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0%1","%2","%3","%4","%5","%6","%7") +#define __syscall_reg_ckr(n) __arg_##n \ + ("er0er0","er1","er2","er3","er4","er5","er6") + +#define __sc_prep_0 "mov.l\t%1,er0\n\t" +#define __sc_prep_1 "mov.l\t%2,er1\n\t" __sc_prep_0 +#define __sc_prep_2 "mov.l\t%3,er2\n\t" __sc_prep_1 +#define __sc_prep_3 "mov.l\t%4,er3\n\t" __sc_prep_2 +#define __sc_prep_4 "mov.l\t%5,er4\n\t" __sc_prep_3 +#define __sc_prep_5 "mov.l\t%6,er5\n\t" __sc_prep_4 +#define __sc_prep_6 "mov.l er6,@-sp\n\t" \ + "mov.l\t%7,er6\n\t" __sc_prep_5 + +#define __sc_reg_arg_0(arg) +#define __sc_reg_arg_1(arg) ,"g"(arg) +#define __sc_reg_arg_2(arg) ,"g"(arg) +#define __sc_reg_arg_3(arg) ,"g"(arg) +#define __sc_reg_arg_4(arg) ,"g"(arg) +#define __sc_reg_arg_5(arg) ,"m"(arg) +#define __sc_reg_arg_6(arg) ,"m"(arg) + +#define ____sc_reg_arg(n,arg) __sc_reg_arg_##n(arg) + +#define ____sc_body(numarg, type, name, args...) \ +{ \ + ____sc_results; \ + { \ + ____sc_reg_ret; \ + ____sc_asm ( \ + __sc_prep_##numarg \ + ____sc_sys(name,numarg) \ + : ____sc_output \ + : ____sc_input_cid(__NR_##name) \ + ____sc_regs(numarg,args) \ + : ____sc_clobber_##numarg \ + ); \ + ____sc_reg_results \ + } \ + ____sc_return(type) \ +} + + +/* ***************************************** + I386 I386 I386 I386 * + i386 kernel interface */ + +#elif defined(__i386__) + +/* The x86 calling convention uses stack args for all arguments, + but the Linux kernel passes the first six arguments in the + following registers: ebx, ecx, edx, esi, edi, ebp. + + scnr: id(eax) + args: a1(ebx), a2(ecx), a3(edx), a4(esi), a5(edi), a6(ebp) + sret: r0(eax) + serr: (sret >= (unsigned)-EMAXERRNO) + call: int 0x80 + clob: memory +*/ + +#define __syscall_maxerrno 129 +#define __syscall_reg_res "eax" +#define __syscall_reg_cid "eax" +#define __syscall_cmd_seq "int\t$0x80" +#define __syscall_clobbers "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "ebx", "ecx", "edx", "esi", "edi", "eax") +#define __syscall_clb_arg(n) __arg_##n \ + ("", "ebx", "ecx", "edx", "esi", "edi", "memory") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0%1","%2","%3","%4","%5","%6","") +#define __syscall_reg_ckr(n) __arg_##n \ + ("%%eax%%eax","%%ebx","%%ecx","%%edx","%%esi","%%edi","") + +#ifndef _syscall6 +#define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5, type6, arg6) \ +type name (type1 arg1, type2 arg2, type3 arg3, \ + type4 arg4, type5 arg5, type6 arg6) \ +{ \ + ____sc_results; \ + { \ + ____sc_reg_ret \ + ____sc_regs(6, arg6, arg5, arg4, arg3, arg2, arg1); \ + ____sc_asm ( \ + __check("%0%2%3%4%5%6%7", \ + "%%eax%%ebx%%ecx%%edx%%esi%%edi%%eax") \ + "push\t%%ebp\n\t" \ + "movl\t%%eax,%%ebp\n\t" \ + "movl\t%1,%%eax\n\t" \ + ____sc_syscall(name) "\n\t" \ + "pop\t%%ebp" \ + : ____sc_output \ + : "i"(__NR_##name) ____sc_input_6 \ + : ____sc_clobber_6 \ + ); \ + ____sc_reg_results; \ + } \ + ____sc_return(type) \ +} +#endif + + +/* ***************************************** + IA64 IA64 IA64 IA64 * + ia64 kernel interface */ + +#elif defined(__ia64__) + +/* The ia64 calling convention uses out0-out7 to pass the first + eight arguments (mapped via register windows). + + scnr: id(r15) + args: a1(out0), a2(out1), ... a5(out4), a6(out5) + sret: r0(r8) + serr: e0(r10) + call: break 0x100000 + clob: out6/7, r2/3/9, r11-r14, r16-r31, p6-p15, f6-f15, b6/7 +*/ + +#define __syscall_errcon(err) (err == -1) + +#define __syscall_reg_ret "r8" +#define __syscall_reg_err "r10" +#define __syscall_reg_cid "r15" +#define __syscall_cmd_seq "break.i\t0x100000" + +#define __syscall_clobbers \ + "out6", "out7", "r2", "r3", "r9", "r11", "r12", "r13", \ + "r14", "r16", "r17", "r18", "r19", "r20", "r21", "r22", \ + "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30", \ + "r31", "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", \ + "p14", "p15", "f6", "f7", "f8", "f9", "f10", "f11", "f12", \ + "f13", "f14", "f15", "f16", "b6", "b7", "cc", "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "out0", "out1", "out2", "out3", "out4", "out5") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0%1%2","","","","","","") +#define __syscall_reg_ckr(n) __arg_##n \ + ("r8r10r15","","","","","","") + + +/* ***************************************** + M32R M32R M32R M32R * + m32r kernel interface */ + +#elif defined(__m32r__) + +/* The m32r calling convention uses r0-r7 to pass the first + eight arguments (mapped via register windows). + + scnr: id(r0) + args: a1(r1), a2(r2), a3(r3), a4(r4), a5(r5), a6(r6) + sret: r0(r0) + serr: (sret >= (unsigned)-EMAXERRNO) + call: trap #2 + clob: out6/7, r2/3/9, r11-r14, r16-r31, p6-p15, f6-f15, b6/7 +*/ + +#define __syscall_maxerrno 125 +#define __syscall_reg_res "r0" +#define __syscall_reg_cid "r7" +#define __syscall_cmd_seq "trap #2" +#define __syscall_clobbers "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "r0", "r1", "r2", "r3", "r4", "r5") +#define __syscall_clb_arg(n) "memory" +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0%1","%2","%3","%4","%5","%6","%7") +#define __syscall_reg_ckr(n) __arg_##n \ + ("r0r7","r0","r1","r2","r3","r4","r5") + + +/* ***************************************** + M68K M68K M68K M68K * + m68k kernel interface */ + +#elif defined(__m68000__) + +#warning syscall arch m68k not implemented yet + + +/* ***************************************** + MIPS MIPS MIPS MIPS * + mips kernel interface */ + +#elif defined(__mips__) + +#warning syscall arch mips not implemented yet + + +/* ***************************************** + HPPA HPPA HPPA HPPA * + hppa/64 kernel interface */ + +#elif defined(__hppa__) + +/* The hppa calling convention uses r26-r23 for the first 4 + arguments, the rest is spilled onto the stack. However the + Linux kernel passes the first six arguments in the registers + r26-r21. + + The system call number MUST ALWAYS be loaded in the delay + slot of the ble instruction, or restarting system calls + WILL NOT WORK. + + scnr: id(r20) + args: a1(r26), a2(r25), a3(r24), a4(r23), a5(r22), a6(r21) + sret: r0(r28) + serr: (sret >= (unsigned)-EMAXERRNO) + call: ble 0x100(%%sr2, %%r0) + clob: r1, r2, r4, r20, r29, r31, memory +*/ + +#define __syscall_maxerrno 4095 +#define __syscall_reg_res "r28" +#define __syscall_imm_cid +#define __syscall_cmd_seq "ble 0x100(%%sr2,%%r0)" +#define __syscall_cmd_fin "ldi %1,%%r20" +#define __syscall_clobbers \ + "r1", "r2", "r4", "r20", "r29", "r31", "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "r26", "r25", "r24", "r23", "r22", "r21") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0","%2","%3","%4","%5","%6","%7") +#define __syscall_reg_ckr(n) __arg_##n \ + ("%%r28","%%r26","%%r25","%%r24","%%r23","%%r22","%%r21") + + +/* ***************************************** + PPC PPC PPC PPC * + ppc/64 kernel interface */ + +#elif defined(__powerpc__) + +/* The powerpc calling convention uses r3-r10 to pass the first + eight arguments, the remainder is spilled onto the stack. + + scnr: id(r0) + args: a1(r3), a2(r4), a3(r5), a4(r6), a5(r7), a6(r8) + sret: r0(r3) + serr: (carry) + call: sc + clob: cr0, ctr +*/ + + +#define __syscall_errcon(err) (err & 0x10000000) + +#define __syscall_reg_ret "r3" +#define __syscall_reg_err "r0" +#define __syscall_reg_cid "r0" +#define __syscall_cmd_seq "sc" +#define __syscall_cmd_fin "mfcr %0" +#define __syscall_clobbers \ + "r9", "r10", "r11", "r12", "cr0", "ctr", "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "r3", "r4", "r5", "r6", "r7", "r8") +#define __syscall_clb_arg(n) __arg_##n \ + ("", "memory", "r4", "r5", "r6", "r7", "r8") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0.%1.%2",".%3",".%4",".%5",".%6",".%7",".%8") +#define __syscall_reg_ckr(n) __arg_##n \ + ("3.0.0",".3",".4",".5",".6",".7",".8") + + +/* ***************************************** + S390 S390 S390 S390 * + s390/x kernel interface */ + +#elif defined(__s390__) + +/* The s390x calling convention passes the first five arguments + in r2-r6, the remainder is spilled onto the stack. However + the Linux kernel passes the first six arguments in r2-r7. + + scnr: imm, id(r1) + args: a1(r2), a2(r3), a3(r4), a4(r5), a5(r6), a6(r7) + sret: r0(r2) + serr: (sret >= (unsigned)-EMAXERRNO) + call: svc + clob: memory +*/ + +#define __syscall_maxerrno 4095 +#define __syscall_regtype unsigned long +#define __syscall_reg_res "r2" +#define __syscall_reg_cid "r1" +#define __syscall_cmd_seq "svc\t0" +#define __syscall_clobbers "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "r2", "r3", "r4", "r5", "r6", "r7") +#define __syscall_clb_arg(n) __arg_##n \ + ("", "memory", "r3", "r4", "r5", "r6", "r7") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0%1","%2","%3","%4","%5","%6","%7") +#define __syscall_reg_ckr(n) __arg_##n \ + ("%%r2%%r1","%%r2","%%r3","%%r4","%%r5","%%r6","%%r7") + + + +/* ***************************************** + SH SH SH SH * + sh kernel interface */ + +#elif defined(__sh__) && !defined(__SH5__) + +#warning syscall arch sh not implemented yet + + +/* ***************************************** + SH64 SH64 SH64 SH64 * + sh64 kernel interface */ + +#elif defined(__sh__) && defined(__SH5__) + +#warning syscall arch sh64 not implemented yet + + +/* ***************************************** + SPARC64 SPARC64 SPARC64 SPARC64 * + sparc64 kernel interface */ + +#elif defined(__sparc__) + +/* The sparc/64 calling convention uses o0-o5 to pass the first + six arguments (mapped via register windows). + + scnr: id(g1) + args: a1(o0), a2(o1), a3(o2), a4(o3), a5(o4), a6(o5) + sret: r0(o0) + serr: (carry) + call: ta 0x6d, t 0x10 + clob: g1-g6, g7?, o7?, f0-f31, cc +*/ + +#define __syscall_maxerrno 515 +#define __syscall_reg_ret "o0" +#define __syscall_reg_err "l1" +#define __syscall_reg_cid "g1" +#ifdef __arch64__ +#define __syscall_cmd_seq "ta\t0x6d" +#else +#define __syscall_cmd_seq "t\t0x10" +#endif +#define __syscall_cmd_fin "addx\t%%g0,%%g0,%%l1" + +#define __syscall_clobbers \ + "g2", "g3", "g4", "g5", "g6", \ + "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", \ + "f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16", \ + "f17", "f18", "f19", "f20", "f21", "f22", "f23", "f24", \ + "f25", "f26", "f27", "f28", "f29", "f30", "f31", "f32", \ + "f34", "f36", "f38", "f40", "f42", "f44", "f46", "f48", \ + "f50", "f52", "f54", "f56", "f58", "f60", "f62", \ + "cc", "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "o0", "o1", "o2", "o3", "o4", "o5") +#define __syscall_clb_arg(n) __arg_##n \ + ("", "memory", "o1", "o2", "o3", "o4", "o5") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0%1%2","%3","%4","%5","%6","%7","%8") +#define __syscall_reg_ckr(n) __arg_##n \ + ("%%o0%%l1%%g1","%%o0","%%o1","%%o2","%%o3","%%o4","%%o5") + + +/* ***************************************** + V850 V850 V850 V850 * + v850 kernel interface */ + +#elif defined(__v850__) + +/* The V850 calling convention passes the first four arguments + in registers r6-r9, the rest is spilled onto the stack. + but the Linux kernel interface uses r6-r9 and r13/14. + + scnr: id(r12) + args: a1(r6), a2(r7), a3(r8), a4(r9), a5(r13), a6(r14) + sret: r0(r10) + serr: (sret >= (unsigned)-EMAXERRNO) + call: trap 0, trap 1 + clob: r1, r5, r11, r15-r19 +*/ + +#define __syscall_maxerrno 515 +#define __syscall_reg_res "r10" +#define __syscall_reg_cid "r12" +#define __syscall_cmd_num(n) __arg_##n \ + ("", "trap 0", "trap 0", "trap 0", "trap 0", "trap 1", "trap 1") + +#define __syscall_clobbers \ + "r1", "r5", "r11", "r15", "r16", "r17", "r18", "r19", "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "r6", "r7", "r8", "r9", "r13", "r14") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0%1","%2","%3","%4","%5","%6","%7") +#define __syscall_reg_ckr(n) __arg_##n \ + ("r10r12","r6","r7","r8","r9","r13","r14") + + +/* ***************************************** + X86_64 X86_64 X86_64 X86_64 * + x86_64 kernel interface */ + +#elif defined(__x86_64__) + +/* The x86_64 calling convention uses rdi, rsi, rdx, rcx, r8, r9 + but the Linux kernel interface uses rdi, rsi, rdx, r10, r8, r9. + + scnr: id(rax) + args: a1(rdi), a2(rsi), a3(rdx), a4(r10), a5(r8), a6(r9) + sret: r0(rax) + serr: (err= sret > (unsigned)-EMAXERRNO) + call: syscall + clob: rcx, r11 +*/ + +#define __syscall_maxerrno 4095 +#define __syscall_reg_res "rax" +#define __syscall_reg_cid "rax" +#define __syscall_cmd_seq "syscall" + +#define __syscall_clobbers \ + "cc", "r11", "rcx", "memory" + +#define __syscall_reg_arg(n) __arg_##n \ + ("", "rdi", "rsi", "rdx", "r10", "r8", "r9") +#define __syscall_reg_ckl(n) __arg_##n \ + ("%0%1","%2","%3","%4","%5","%6","%7") +#define __syscall_reg_ckr(n) __arg_##n \ + ("%%rax%%rax","%%rdi","%%rsi","%%rdx","%%r10","%%r8","%%r9") + + +#else +#error unknown kernel arch +#endif + + + + +#ifndef EMAXERRNO +#define EMAXERRNO __syscall_maxerrno +#endif + +#ifndef __syscall_regdef +#define __syscall_regdef(name, reg) \ + register __syscall_regtype __sc_##name asm (reg) +#endif + +#ifndef __syscall_regval +#define __syscall_regval(name, reg, val) \ + register __syscall_regtype __sc_##name asm (reg) = \ + (__syscall_regtype)(val) +#endif + + +#ifndef __syscall_reg_err /* simple result */ + +#define ____sc_results __syscall_regtype __res + +#define ____sc_reg_ret \ + __syscall_regdef(r0, __syscall_reg_res) + +#define ____sc_output "=r"(__sc_r0) +#define ____sc_return(type) __syscall_return(type, __res) + +#ifndef __syscall_stores +#define __syscall_stores __res = __sc_r0; +#endif + +#ifndef __syscall_errcon +#define __syscall_errcon(res) \ + ((unsigned long)(res) >= (unsigned long)(-(__syscall_maxerrno))) +#endif + +#ifndef __syscall_return +#define __syscall_return(type, res) \ + __syscall_retval(res); \ + if (__syscall_errcon(res)) { \ + int __err = -(res); \ + __syscall_error(__err); \ + res = -1; \ + } \ + return (type)(res); +#endif + +#else /* complex result */ + +#define ____sc_results __syscall_regtype __ret, __err + +#define ____sc_reg_ret \ + __syscall_regdef(r0, __syscall_reg_ret); \ + __syscall_regdef(e0, __syscall_reg_err) + +#define ____sc_output "=r"(__sc_r0), "=r"(__sc_e0) +#define ____sc_return(type) __syscall_return(type, __ret, __err) + +#ifndef __syscall_stores +#define __syscall_stores __ret = __sc_r0; __err = __sc_e0; +#endif + +#ifndef __syscall_errcon +#define __syscall_errcon(err) (err) +#endif + +#ifndef __syscall_return +#define __syscall_return(type, ret, err) \ + __syscall_retval(ret); \ + if (__syscall_errcon(err)) { \ + int __err = (ret); \ + __syscall_error(__err); \ + ret = -1; \ + } \ + return (type)(ret); +#endif + +#endif /* simple/complex */ + + +#ifndef __syscall_clb_arg +#define __syscall_clb_arg(n) __syscall_reg_arg(n) +#endif + +#ifndef __syscall_regtype +#define __syscall_regtype long +#endif + +#ifndef __syscall_reg_cid +#define ____sc_reg_cid(__cid) +#ifndef __syscall_imm_cid +#define ____sc_input_cid(__cid) +#else +#ifndef ____sc_input_cid +#define ____sc_input_cid(__cid) "i"(__cid) +#endif +#endif +#else +#define ____sc_reg_cid(__cid) \ + __syscall_regval(id, __syscall_reg_cid, __cid) +#ifndef ____sc_input_cid +#define ____sc_input_cid(__cid) "r"(__sc_id) +#endif +#endif + + +#ifndef ____sc_reg_arg +#define ____sc_reg_arg(n,arg) ; __syscall_regval(a##n, \ + __syscall_reg_arg(n), arg) +#endif + +#ifndef ____sc_regs +#define ____sc_regs(n,args...) __arglst_##n(____sc_reg_arg,args) +#endif + +#define ____sc_check(n) __check( \ + __concat_##n(__syscall_reg_ckl),__concat_##n(__syscall_reg_ckr)) + + +#ifndef ____sc_clobber_0 +#define ____sc_clobber_6 __syscall_clobbers +#define ____sc_clobber_5 __syscall_clb_arg(6), ____sc_clobber_6 +#define ____sc_clobber_4 __syscall_clb_arg(5), ____sc_clobber_5 +#define ____sc_clobber_3 __syscall_clb_arg(4), ____sc_clobber_4 +#define ____sc_clobber_2 __syscall_clb_arg(3), ____sc_clobber_3 +#define ____sc_clobber_1 __syscall_clb_arg(2), ____sc_clobber_2 +#define ____sc_clobber_0 __syscall_clb_arg(1), ____sc_clobber_1 +#endif + +#ifndef ____sc_input_0 +#define ____sc_input_6 ____sc_input_5, "r"(__sc_a6) +#define ____sc_input_5 ____sc_input_4, "r"(__sc_a5) +#define ____sc_input_4 ____sc_input_3, "r"(__sc_a4) +#define ____sc_input_3 ____sc_input_2, "r"(__sc_a3) +#define ____sc_input_2 ____sc_input_1, "r"(__sc_a2) +#define ____sc_input_1 ,"r"(__sc_a1) +#define ____sc_input_0 +#endif + +#define ____sc_asm asm volatile + + +#ifdef __syscall_cmd_fin +#define ____sc_syscall(name) __syscall_cmd_seq __comment(name) "\n\t"\ + __syscall_cmd_fin +#else +#define ____sc_syscall(name) __syscall_cmd_seq __comment(name) +#endif + +#define ____sc_reg_results __syscall_stores + + +#ifndef __syscall_cmd_num +#define ____sc_sys(name,n) ____sc_syscall(name) +#else +#define ____sc_sys(name,n) __syscall_cmd_num(n) __comment(name) +#endif + +#ifndef ____sc_body +#define ____sc_body(numarg, type, name, args...) \ +{ \ + ____sc_results; \ + { \ + ____sc_reg_ret; \ + ____sc_reg_cid(__NR_##name) \ + ____sc_regs(numarg,args); \ + ____sc_asm ( \ + ____sc_check(numarg) \ + ____sc_sys(name,numarg) \ + : ____sc_output \ + : ____sc_input_cid(__NR_##name) \ + ____sc_input_##numarg \ + : ____sc_clobber_##numarg \ + ); \ + ____sc_reg_results; \ + } \ + ____sc_return(type) \ +} +#endif + + +#ifndef _syscall0 +#define _syscall0(type, name) \ +type name(void) \ +____sc_body(0, type, name) +#endif + +#ifndef _syscall1 +#define _syscall1(type, name, type1, arg1) \ +type name(type1 arg1) \ +____sc_body(1, type, name, arg1) +#endif + +#ifndef _syscall2 +#define _syscall2(type, name, type1, arg1, type2, arg2) \ +type name(type1 arg1, type2 arg2) \ +____sc_body(2, type, name, arg2, arg1) +#endif + +#ifndef _syscall3 +#define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ +type name(type1 arg1, type2 arg2, type3 arg3) \ +____sc_body(3, type, name, arg3, arg2, arg1) +#endif + +#ifndef _syscall4 +#define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4) \ +type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +____sc_body(4, type, name, arg4, arg3, arg2, arg1) +#endif + +#ifndef _syscall5 +#define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5) \ +type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ +____sc_body(5, type, name, arg5, arg4, arg3, arg2, arg1) +#endif + +#ifndef _syscall6 +#define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5, type6, arg6) \ +type name (type1 arg1, type2 arg2, type3 arg3, \ + type4 arg4, type5 arg5, type6 arg6) \ +____sc_body(6, type, name, arg6, arg5, arg4, arg3, arg2, arg1) +#endif + diff -NurpP --minimal libvserver-0.1/lib/vserver/context_cmd.h libvserver-0.1.1/lib/vserver/context_cmd.h --- libvserver-0.1/lib/vserver/context_cmd.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,73 +0,0 @@ -#ifndef _VX_CONTEXT_CMD_H -#define _VX_CONTEXT_CMD_H - - -/* vinfo commands */ - -#define VCMD_task_xid VC_CMD(VINFO, 1, 0) - -#ifdef __KERNEL__ -extern int vc_task_xid(uint32_t, void __user *); - -#endif /* __KERNEL__ */ - -#define VCMD_vx_info VC_CMD(VINFO, 5, 0) - -struct vcmd_vx_info_v0 { - uint32_t xid; - uint32_t initpid; - /* more to come */ -}; - -#ifdef __KERNEL__ -extern int vc_vx_info(uint32_t, void __user *); - -#endif /* __KERNEL__ */ - - -/* context commands */ - -#define VCMD_ctx_create VC_CMD(VPROC, 1, 0) -#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 0) - -#ifdef __KERNEL__ -extern int vc_ctx_create(uint32_t, void __user *); -extern int vc_ctx_migrate(uint32_t, void __user *); - -#endif /* __KERNEL__ */ - - -/* flag commands */ - -#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0) -#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0) - -struct vcmd_ctx_flags_v0 { - uint64_t flagword; - uint64_t mask; -}; - -#ifdef __KERNEL__ -extern int vc_get_cflags(uint32_t, void __user *); -extern int vc_set_cflags(uint32_t, void __user *); - -#endif /* __KERNEL__ */ - - -/* context caps commands */ - -#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 0) -#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 0) - -struct vcmd_ctx_caps_v0 { - uint64_t bcaps; - uint64_t ccaps; - uint64_t cmask; -}; - -#ifdef __KERNEL__ -extern int vc_get_ccaps(uint32_t, void __user *); -extern int vc_set_ccaps(uint32_t, void __user *); - -#endif /* __KERNEL__ */ -#endif /* _VX_CONTEXT_CMD_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/context.h libvserver-0.1.1/lib/vserver/context.h --- libvserver-0.1/lib/vserver/context.h 2005-05-25 10:08:12.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/context.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,154 +0,0 @@ -#ifndef _VX_CONTEXT_H -#define _VX_CONTEXT_H - -#include - - -#define MAX_S_CONTEXT 65535 /* Arbitrary limit */ -#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */ - -#define VX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */ - -/* context flags */ - -#define VXF_INFO_LOCK 0x00000001 -#define VXF_INFO_SCHED 0x00000002 -#define VXF_INFO_NPROC 0x00000004 -#define VXF_INFO_PRIVATE 0x00000008 - -#define VXF_INFO_INIT 0x00000010 -#define VXF_INFO_HIDE 0x00000020 -#define VXF_INFO_ULIMIT 0x00000040 -#define VXF_INFO_NSPACE 0x00000080 - -#define VXF_SCHED_HARD 0x00000100 -#define VXF_SCHED_PRIO 0x00000200 -#define VXF_SCHED_PAUSE 0x00000400 - -#define VXF_VIRT_MEM 0x00010000 -#define VXF_VIRT_UPTIME 0x00020000 -#define VXF_VIRT_CPU 0x00040000 -#define VXF_VIRT_LOAD 0x00080000 - -#define VXF_HIDE_MOUNT 0x01000000 -#define VXF_HIDE_NETIF 0x02000000 - -#define VXF_STATE_SETUP (1ULL<<32) -#define VXF_STATE_INIT (1ULL<<33) - -#define VXF_FORK_RSS (1ULL<<48) -#define VXF_PROLIFIC (1ULL<<49) - -#define VXF_IGNEG_NICE (1ULL<<52) - -#define VXF_ONE_TIME (0x0003ULL<<32) - - -/* context caps */ - -#define VXC_CAP_MASK 0x00000000 - -#define VXC_SET_UTSNAME 0x00000001 -#define VXC_SET_RLIMIT 0x00000002 - -#define VXC_RAW_ICMP 0x00000100 -#define VXC_SYSLOG 0x00001000 - -#define VXC_SECURE_MOUNT 0x00010000 -#define VXC_SECURE_REMOUNT 0x00020000 -#define VXC_BINARY_MOUNT 0x00040000 - -#define VXC_QUOTA_CTL 0x00100000 - - -/* context state changes */ - -enum { - VSC_STARTUP = 1, - VSC_SHUTDOWN, -}; - - -#ifdef __KERNEL__ - -#include -#include -#include - -#include "limit_def.h" -#include "sched_def.h" -#include "cvirt_def.h" - -struct vx_info { - struct hlist_node vx_hlist; /* linked list of contexts */ - xid_t vx_id; /* context id */ - atomic_t vx_usecnt; /* usage count */ - atomic_t vx_tasks; /* tasks count */ - struct vx_info *vx_parent; /* parent context */ - int vx_state; /* context state */ - - struct namespace *vx_namespace; /* private namespace */ - struct fs_struct *vx_fs; /* private namespace fs */ - uint64_t vx_flags; /* context flags */ - uint64_t vx_bcaps; /* bounding caps (system) */ - uint64_t vx_ccaps; /* context caps (vserver) */ - - pid_t vx_initpid; /* PID of fake init process */ - - wait_queue_head_t vx_wait; /* context exit waitqueue */ - - struct _vx_limit limit; /* vserver limits */ - struct _vx_sched sched; /* vserver scheduler */ - struct _vx_cvirt cvirt; /* virtual/bias stuff */ - struct _vx_cacct cacct; /* context accounting */ - - char vx_name[65]; /* vserver name */ -}; - - -/* status flags */ - -#define VXS_HASHED 0x0001 -#define VXS_PAUSED 0x0010 -#define VXS_ONHOLD 0x0020 -#define VXS_SHUTDOWN 0x0100 -#define VXS_RELEASED 0x8000 - -/* check conditions */ - -#define VX_ADMIN 0x0001 -#define VX_WATCH 0x0002 -#define VX_HIDE 0x0004 -#define VX_HOSTID 0x0008 - -#define VX_IDENT 0x0010 -#define VX_EQUIV 0x0020 -#define VX_PARENT 0x0040 -#define VX_CHILD 0x0080 - -#define VX_ARG_MASK 0x00F0 - -#define VX_DYNAMIC 0x0100 -#define VX_STATIC 0x0200 - -#define VX_ATR_MASK 0x0F00 - - -extern void claim_vx_info(struct vx_info *, struct task_struct *); -extern void release_vx_info(struct vx_info *, struct task_struct *); - -extern struct vx_info *locate_vx_info(int); -extern struct vx_info *locate_or_create_vx_info(int); - -extern int get_xid_list(int, unsigned int *, int); -extern int xid_is_hashed(xid_t); - -extern int vx_migrate_task(struct task_struct *, struct vx_info *); - -extern long vs_state_change(struct vx_info *, unsigned int); - - -#endif /* __KERNEL__ */ -#else /* _VX_CONTEXT_H */ -#warning duplicate inclusion -#endif /* _VX_CONTEXT_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/cvirt_cmd.h libvserver-0.1.1/lib/vserver/cvirt_cmd.h --- libvserver-0.1/lib/vserver/cvirt_cmd.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +0,0 @@ -#ifndef _VX_CVIRT_CMD_H -#define _VX_CVIRT_CMD_H - -/* cvirt vserver commands */ - - -#endif /* _VX_CVIRT_CMD_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/cvirt_def.h libvserver-0.1.1/lib/vserver/cvirt_def.h --- libvserver-0.1/lib/vserver/cvirt_def.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,77 +0,0 @@ -#ifndef _VX_CVIRT_DEF_H -#define _VX_CVIRT_DEF_H - -#include -#include -#include -#include -#include -#include - - -struct _vx_usage_stat { - uint64_t user; - uint64_t nice; - uint64_t system; - uint64_t softirq; - uint64_t irq; - uint64_t idle; - uint64_t iowait; -}; - -struct _vx_syslog { - wait_queue_head_t log_wait; - spinlock_t logbuf_lock; /* lock for the log buffer */ - - unsigned long log_start; /* next char to be read by syslog() */ - unsigned long con_start; /* next char to be sent to consoles */ - unsigned long log_end; /* most-recently-written-char + 1 */ - unsigned long logged_chars; /* #chars since last read+clear operation */ - - char log_buf[1024]; -}; - - -/* context sub struct */ - -struct _vx_cvirt { - int max_threads; /* maximum allowed threads */ - atomic_t nr_threads; /* number of current threads */ - atomic_t nr_running; /* number of running threads */ - atomic_t nr_uninterruptible; /* number of uninterruptible threads */ - - atomic_t nr_onhold; /* processes on hold */ - uint32_t onhold_last; /* jiffies when put on hold */ - - struct timespec bias_idle; - struct timespec bias_uptime; /* context creation point */ - uint64_t bias_clock; /* offset in clock_t */ - - struct new_utsname utsname; - - spinlock_t load_lock; /* lock for the load averages */ - atomic_t load_updates; /* nr of load updates done so far */ - uint32_t load_last; /* last time load was cacled */ - uint32_t load[3]; /* load averages 1,5,15 */ - - atomic_t total_forks; /* number of forks so far */ - - struct _vx_usage_stat cpustat[NR_CPUS]; - - struct _vx_syslog syslog; -}; - -struct _vx_sock_acc { - atomic_t count; - atomic_t total; -}; - -/* context sub struct */ - -struct _vx_cacct { - unsigned long total_forks; - - struct _vx_sock_acc sock[5][3]; -}; - -#endif /* _VX_CVIRT_DEF_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/cvirt.h libvserver-0.1.1/lib/vserver/cvirt.h --- libvserver-0.1/lib/vserver/cvirt.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,25 +0,0 @@ -#ifndef _VX_CVIRT_H -#define _VX_CVIRT_H - -#ifdef __KERNEL__ - -struct timespec; - -void vx_vsi_uptime(struct timespec *, struct timespec *); - - -struct vx_info; - -void vx_update_load(struct vx_info *); - - -int vx_uts_virt_handler(struct ctl_table *ctl, int write, xid_t xid, - void **datap, size_t *lenp); - - -int vx_do_syslog(int, char __user *, int); - -#endif /* __KERNEL__ */ -#else /* _VX_CVIRT_H */ -#warning duplicate inclusion -#endif /* _VX_CVIRT_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/dlimit_cmd.h libvserver-0.1.1/lib/vserver/dlimit_cmd.h --- libvserver-0.1/lib/vserver/dlimit_cmd.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,68 +0,0 @@ -#ifndef _VX_DLIMIT_CMD_H -#define _VX_DLIMIT_CMD_H - -/* dlimit vserver commands */ - -#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0) -#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0) - -#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0) -#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0) - -struct vcmd_ctx_dlimit_base_v0 { - const char __user *name; - uint32_t flags; -}; - -struct vcmd_ctx_dlimit_v0 { - const char __user *name; - uint32_t space_used; /* used space in kbytes */ - uint32_t space_total; /* maximum space in kbytes */ - uint32_t inodes_used; /* used inodes */ - uint32_t inodes_total; /* maximum inodes */ - uint32_t reserved; /* reserved for root in % */ - uint32_t flags; -}; - - -#ifdef __KERNEL__ - -#ifdef CONFIG_COMPAT - -struct vcmd_ctx_dlimit_base_v0_x32 { - compat_uptr_t name_ptr; - uint32_t flags; -}; - -struct vcmd_ctx_dlimit_v0_x32 { - compat_uptr_t name_ptr; - uint32_t space_used; /* used space in kbytes */ - uint32_t space_total; /* maximum space in kbytes */ - uint32_t inodes_used; /* used inodes */ - uint32_t inodes_total; /* maximum inodes */ - uint32_t reserved; /* reserved for root in % */ - uint32_t flags; -}; - -#endif /* CONFIG_COMPAT */ - -#include - -extern int vc_add_dlimit(uint32_t, void __user *); -extern int vc_rem_dlimit(uint32_t, void __user *); - -extern int vc_set_dlimit(uint32_t, void __user *); -extern int vc_get_dlimit(uint32_t, void __user *); - -#ifdef CONFIG_COMPAT - -extern int vc_add_dlimit_x32(uint32_t, void __user *); -extern int vc_rem_dlimit_x32(uint32_t, void __user *); - -extern int vc_set_dlimit_x32(uint32_t, void __user *); -extern int vc_get_dlimit_x32(uint32_t, void __user *); - -#endif /* CONFIG_COMPAT */ - -#endif /* __KERNEL__ */ -#endif /* _VX_DLIMIT_CMD_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/dlimit.h libvserver-0.1.1/lib/vserver/dlimit.h --- libvserver-0.1/lib/vserver/dlimit.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,53 +0,0 @@ -#ifndef _VX_DLIMIT_H -#define _VX_DLIMIT_H - -#include "switch.h" - -#define CDLIM_UNSET (0ULL) -#define CDLIM_INFINITY (~0ULL) -#define CDLIM_KEEP (~1ULL) - - -#ifdef __KERNEL__ - -#include - -struct super_block; - -struct dl_info { - struct hlist_node dl_hlist; /* linked list of contexts */ - struct rcu_head dl_rcu; /* the rcu head */ - xid_t dl_xid; /* context id */ - atomic_t dl_usecnt; /* usage count */ - atomic_t dl_refcnt; /* reference count */ - - struct super_block *dl_sb; /* associated superblock */ - - spinlock_t dl_lock; /* protect the values */ - - uint64_t dl_space_used; /* used space in bytes */ - uint64_t dl_space_total; /* maximum space in bytes */ - uint32_t dl_inodes_used; /* used inodes */ - uint32_t dl_inodes_total; /* maximum inodes */ - - unsigned int dl_nrlmult; /* non root limit mult */ -}; - -struct rcu_head; - -extern void rcu_free_dl_info(struct rcu_head *); -extern void unhash_dl_info(struct dl_info *); - -extern struct dl_info *locate_dl_info(struct super_block *, xid_t); - - -struct kstatfs; - -extern void vx_vsi_statfs(struct super_block *, struct kstatfs *); - -typedef uint64_t dlsize_t; - -#endif /* __KERNEL__ */ -#else /* _VX_DLIMIT_H */ -#warning duplicate inclusion -#endif /* _VX_DLIMIT_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/inode_cmd.h libvserver-0.1.1/lib/vserver/inode_cmd.h --- libvserver-0.1/lib/vserver/inode_cmd.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,57 +0,0 @@ -#ifndef _VX_INODE_CMD_H -#define _VX_INODE_CMD_H - -/* inode vserver commands */ - -#define VCMD_get_iattr_v0 VC_CMD(INODE, 1, 0) -#define VCMD_set_iattr_v0 VC_CMD(INODE, 2, 0) - -#define VCMD_get_iattr VC_CMD(INODE, 1, 1) -#define VCMD_set_iattr VC_CMD(INODE, 2, 1) - -struct vcmd_ctx_iattr_v0 { - /* device handle in id */ - uint64_t ino; - uint32_t xid; - uint32_t flags; - uint32_t mask; -}; - -struct vcmd_ctx_iattr_v1 { - const char __user *name; - uint32_t xid; - uint32_t flags; - uint32_t mask; -}; - - -#ifdef __KERNEL__ - -#ifdef CONFIG_COMPAT - -struct vcmd_ctx_iattr_v1_x32 { - compat_uptr_t name_ptr; - uint32_t xid; - uint32_t flags; - uint32_t mask; -}; - -#endif /* CONFIG_COMPAT */ - -#include - -extern int vc_get_iattr_v0(uint32_t, void __user *); -extern int vc_set_iattr_v0(uint32_t, void __user *); - -extern int vc_get_iattr(uint32_t, void __user *); -extern int vc_set_iattr(uint32_t, void __user *); - -#ifdef CONFIG_COMPAT - -extern int vc_get_iattr_x32(uint32_t, void __user *); -extern int vc_set_iattr_x32(uint32_t, void __user *); - -#endif /* CONFIG_COMPAT */ - -#endif /* __KERNEL__ */ -#endif /* _VX_INODE_CMD_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/inode.h libvserver-0.1.1/lib/vserver/inode.h --- libvserver-0.1/lib/vserver/inode.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,41 +0,0 @@ -#ifndef _VX_INODE_H -#define _VX_INODE_H - - -#define IATTR_XID 0x01000000 - -#define IATTR_ADMIN 0x00000001 -#define IATTR_WATCH 0x00000002 -#define IATTR_HIDE 0x00000004 -#define IATTR_FLAGS 0x00000007 - -#define IATTR_BARRIER 0x00010000 -#define IATTR_IUNLINK 0x00020000 -#define IATTR_IMMUTABLE 0x00040000 - -#ifdef __KERNEL__ - -#ifndef CONFIG_VSERVER -#warning config options missing -#endif - -#ifdef CONFIG_VSERVER_PROC_SECURE -#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE ) -#define IATTR_PROC_SYMLINK ( IATTR_ADMIN ) -#else -#define IATTR_PROC_DEFAULT ( IATTR_ADMIN ) -#define IATTR_PROC_SYMLINK ( IATTR_ADMIN ) -#endif - -#define vx_hide_check(c,m) (((m) & IATTR_HIDE) ? vx_check(c,m) : 1) - -#endif /* __KERNEL__ */ - -/* inode ioctls */ - -#define FIOC_GETXFLG _IOR('x', 5, long) -#define FIOC_SETXFLG _IOW('x', 6, long) - -#else /* _VX_INODE_H */ -#warning duplicate inclusion -#endif /* _VX_INODE_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/limit_cmd.h libvserver-0.1.1/lib/vserver/limit_cmd.h --- libvserver-0.1/lib/vserver/limit_cmd.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,36 +0,0 @@ -#ifndef _VX_LIMIT_CMD_H -#define _VX_LIMIT_CMD_H - -/* rlimit vserver commands */ - -#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0) -#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0) -#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0) - -struct vcmd_ctx_rlimit_v0 { - uint32_t id; - uint64_t minimum; - uint64_t softlimit; - uint64_t maximum; -}; - -struct vcmd_ctx_rlimit_mask_v0 { - uint32_t minimum; - uint32_t softlimit; - uint32_t maximum; -}; - -#define CRLIM_UNSET (0ULL) -#define CRLIM_INFINITY (~0ULL) -#define CRLIM_KEEP (~1ULL) - -#ifdef __KERNEL__ - -#include - -extern int vc_get_rlimit(uint32_t, void __user *); -extern int vc_set_rlimit(uint32_t, void __user *); -extern int vc_get_rlimit_mask(uint32_t, void __user *); - -#endif /* __KERNEL__ */ -#endif /* _VX_LIMIT_CMD_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/limit_def.h libvserver-0.1.1/lib/vserver/limit_def.h --- libvserver-0.1/lib/vserver/limit_def.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,21 +0,0 @@ -#ifndef _VX_LIMIT_DEF_H -#define _VX_LIMIT_DEF_H - -#include -#include - -#include "limit.h" - -/* context sub struct */ - -struct _vx_limit { - atomic_t ticks; - - unsigned long rlim[NUM_LIMITS]; /* Context limit */ - unsigned long rmax[NUM_LIMITS]; /* Context maximum */ - atomic_t rcur[NUM_LIMITS]; /* Current value */ - atomic_t lhit[NUM_LIMITS]; /* Limit hits */ -}; - - -#endif /* _VX_LIMIT_DEF_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/limit.h libvserver-0.1.1/lib/vserver/limit.h --- libvserver-0.1/lib/vserver/limit.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,23 +0,0 @@ -#ifndef _VX_LIMIT_H -#define _VX_LIMIT_H - -#ifdef __KERNEL__ - -struct sysinfo; - -void vx_vsi_meminfo(struct sysinfo *); -void vx_vsi_swapinfo(struct sysinfo *); - -#define VXD_RLIMIT(r,l) (VXD_CBIT(limit, (l)) && ((r) == (l))) - -#define NUM_LIMITS 24 - -#define VLIMIT_NSOCK 16 -#define VLIMIT_OPENFD 17 -#define VLIMIT_ANON 18 -#define VLIMIT_SHMEM 19 - -extern const char *vlimit_name[NUM_LIMITS]; - -#endif /* __KERNEL__ */ -#endif /* _VX_LIMIT_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/namespace.h libvserver-0.1.1/lib/vserver/namespace.h --- libvserver-0.1/lib/vserver/namespace.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/namespace.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,58 +0,0 @@ -#ifndef _VX_NAMESPACE_H -#define _VX_NAMESPACE_H - -#include - - -/* virtual host info names */ - -#define VCMD_vx_set_vhi_name VC_CMD(VHOST, 1, 0) -#define VCMD_vx_get_vhi_name VC_CMD(VHOST, 2, 0) - -struct vcmd_vx_vhi_name_v0 { - uint32_t field; - char name[65]; -}; - - -enum vx_vhi_name_field { - VHIN_CONTEXT=0, - VHIN_SYSNAME, - VHIN_NODENAME, - VHIN_RELEASE, - VHIN_VERSION, - VHIN_MACHINE, - VHIN_DOMAINNAME, -}; - - -#ifdef __KERNEL__ - -#include - -extern int vc_set_vhi_name(uint32_t, void __user *); -extern int vc_get_vhi_name(uint32_t, void __user *); - -#endif /* __KERNEL__ */ - -#define VCMD_enter_namespace VC_CMD(PROCALT, 1, 0) -#define VCMD_cleanup_namespace VC_CMD(PROCALT, 2, 0) -#define VCMD_set_namespace VC_CMD(PROCALT, 3, 0) - -#ifdef __KERNEL__ - -struct vx_info; -struct namespace; -struct fs_struct; -struct vfsmount; - -extern int vx_set_namespace(struct vx_info *, struct namespace *, struct fs_struct *); - -extern int vc_enter_namespace(uint32_t, void __user *); -extern int vc_cleanup_namespace(uint32_t, void __user *); -extern int vc_set_namespace(uint32_t, void __user *); - -#endif /* __KERNEL__ */ -#else /* _VX_NAMESPACE_H */ -#warning duplicate inclusion -#endif /* _VX_NAMESPACE_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/network_cmd.h libvserver-0.1.1/lib/vserver/network_cmd.h --- libvserver-0.1/lib/vserver/network_cmd.h 2005-05-25 10:10:52.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,78 +0,0 @@ -#ifndef _VX_NETWORK_CMD_H -#define _VX_NETWORK_CMD_H - - -/* vinfo commands */ - -#define VCMD_task_nid VC_CMD(VINFO, 2, 0) - -#ifdef __KERNEL__ -extern int vc_task_nid(uint32_t, void __user *); - -#endif /* __KERNEL__ */ - -#define VCMD_nx_info VC_CMD(VINFO, 6, 0) - -struct vcmd_nx_info_v0 { - uint32_t nid; - /* more to come */ -}; - -#ifdef __KERNEL__ -extern int vc_nx_info(uint32_t, void __user *); - -#endif /* __KERNEL__ */ - -#define VCMD_net_create VC_CMD(VNET, 1, 0) -#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0) - -#define VCMD_net_add VC_CMD(NETALT, 1, 0) -#define VCMD_net_remove VC_CMD(NETALT, 2, 0) - -struct vcmd_net_nx_v0 { - uint16_t type; - uint16_t count; - uint32_t ip[4]; - uint32_t mask[4]; - /* more to come */ -}; - - -#ifdef __KERNEL__ -extern int vc_net_create(uint32_t, void __user *); -extern int vc_net_migrate(uint32_t, void __user *); - -#endif /* __KERNEL__ */ - -#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0) -#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0) - -struct vcmd_net_flags_v0 { - uint64_t flagword; - uint64_t mask; -}; - -#ifdef __KERNEL__ -extern int vc_get_nflags(uint32_t, void __user *); -extern int vc_set_nflags(uint32_t, void __user *); - -#endif /* __KERNEL__ */ - -#define IPF_STATE_SETUP (1ULL<<32) - -#define IPF_ONE_TIME (0x0001ULL<<32) - -#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0) -#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0) - -struct vcmd_net_caps_v0 { - uint64_t ncaps; - uint64_t cmask; -}; - -#ifdef __KERNEL__ -extern int vc_get_ncaps(uint32_t, void __user *); -extern int vc_set_ncaps(uint32_t, void __user *); - -#endif /* __KERNEL__ */ -#endif /* _VX_CONTEXT_CMD_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/network.h libvserver-0.1.1/lib/vserver/network.h --- libvserver-0.1/lib/vserver/network.h 2005-05-25 10:08:26.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/network.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,78 +0,0 @@ -#ifndef _VX_NETWORK_H -#define _VX_NETWORK_H - -#include - - -#define MAX_N_CONTEXT 65535 /* Arbitrary limit */ - -#define NX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */ - -#define NB_IPV4ROOT 16 - - -/* context flags */ - -#define NXF_STATE_SETUP (1ULL<<32) - - -#ifdef __KERNEL__ - -#include -#include -#include -#include - - -struct nx_info { - struct hlist_node nx_hlist; /* linked list of nxinfos */ - nid_t nx_id; /* vnet id */ - atomic_t nx_usecnt; /* usage count */ - atomic_t nx_tasks; /* tasks count */ - int nx_state; /* context state */ - - uint64_t nx_flags; /* network flag word */ - uint64_t nx_ncaps; /* network capabilities */ - - int nbipv4; - __u32 ipv4[NB_IPV4ROOT]; /* Process can only bind to these IPs */ - /* The first one is used to connect */ - /* and for bind any service */ - /* The other must be used explicity */ - __u32 mask[NB_IPV4ROOT]; /* Netmask for each ipv4 */ - /* Used to select the proper source */ - /* address for sockets */ - __u32 v4_bcast; /* Broadcast address to receive UDP */ - - char nx_name[65]; /* network context name */ -}; - - -/* status flags */ - -#define NXS_HASHED 0x0001 -#define NXS_SHUTDOWN 0x0100 -#define NXS_RELEASED 0x8000 - -extern struct nx_info *locate_nx_info(int); -extern struct nx_info *locate_or_create_nx_info(int); - -extern int get_nid_list(int, unsigned int *, int); -extern int nid_is_hashed(nid_t); - -extern int nx_migrate_task(struct task_struct *, struct nx_info *); - -struct in_ifaddr; -struct net_device; - -int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *); -int dev_in_nx_info(struct net_device *, struct nx_info *); - -struct sock; - -int nx_addr_conflict(struct nx_info *, uint32_t, struct sock *); - -#endif /* __KERNEL__ */ -#else /* _VX_NETWORK_H */ -#warning duplicate inclusion -#endif /* _VX_NETWORK_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/sched_cmd.h libvserver-0.1.1/lib/vserver/sched_cmd.h --- libvserver-0.1/lib/vserver/sched_cmd.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,47 +0,0 @@ -#ifndef _VX_SCHED_CMD_H -#define _VX_SCHED_CMD_H - -/* sched vserver commands */ - -#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2) -#define VCMD_set_sched VC_CMD(SCHED, 1, 3) - -struct vcmd_set_sched_v2 { - int32_t fill_rate; - int32_t interval; - int32_t tokens; - int32_t tokens_min; - int32_t tokens_max; - uint64_t cpu_mask; -}; - -struct vcmd_set_sched_v3 { - uint32_t set_mask; - int32_t fill_rate; - int32_t interval; - int32_t tokens; - int32_t tokens_min; - int32_t tokens_max; - int32_t priority_bias; -}; - - -#define VXSM_FILL_RATE 0x0001 -#define VXSM_INTERVAL 0x0002 -#define VXSM_TOKENS 0x0010 -#define VXSM_TOKENS_MIN 0x0020 -#define VXSM_TOKENS_MAX 0x0040 -#define VXSM_PRIO_BIAS 0x0100 - -#define SCHED_KEEP (-2) - -#ifdef __KERNEL__ - -#include - -extern int vc_set_sched_v1(uint32_t, void __user *); -extern int vc_set_sched_v2(uint32_t, void __user *); -extern int vc_set_sched(uint32_t, void __user *); - -#endif /* __KERNEL__ */ -#endif /* _VX_SCHED_CMD_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/sched_def.h libvserver-0.1.1/lib/vserver/sched_def.h --- libvserver-0.1/lib/vserver/sched_def.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,38 +0,0 @@ -#ifndef _VX_SCHED_DEF_H -#define _VX_SCHED_DEF_H - -#include -#include -#include -#include -#include - - -struct _vx_ticks { - uint64_t user_ticks; /* token tick events */ - uint64_t sys_ticks; /* token tick events */ - uint64_t hold_ticks; /* token ticks paused */ - uint64_t unused[5]; /* cacheline ? */ -}; - -/* context sub struct */ - -struct _vx_sched { - atomic_t tokens; /* number of CPU tokens */ - spinlock_t tokens_lock; /* lock for token bucket */ - - int fill_rate; /* Fill rate: add X tokens... */ - int interval; /* Divisor: per Y jiffies */ - int tokens_min; /* Limit: minimum for unhold */ - int tokens_max; /* Limit: no more than N tokens */ - uint32_t jiffies; /* last time accounted */ - - int priority_bias; /* bias offset for priority */ - int vavavoom; /* last calculated vavavoom */ - - cpumask_t cpus_allowed; /* cpu mask for context */ - - struct _vx_ticks cpu[NR_CPUS]; -}; - -#endif /* _VX_SCHED_DEF_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/sched.h libvserver-0.1.1/lib/vserver/sched.h --- libvserver-0.1/lib/vserver/sched.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,25 +0,0 @@ -#ifndef _VX_SCHED_H -#define _VX_SCHED_H - -#ifdef __KERNEL__ - -struct timespec; - -void vx_vsi_uptime(struct timespec *, struct timespec *); - - -struct vx_info; - -void vx_update_load(struct vx_info *); - - -struct task_struct; - -int vx_effective_vavavoom(struct vx_info *, int); - -int vx_tokens_recalc(struct vx_info *); - -#endif /* __KERNEL__ */ -#else /* _VX_SCHED_H */ -#warning duplicate inclusion -#endif /* _VX_SCHED_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/signal_cmd.h libvserver-0.1.1/lib/vserver/signal_cmd.h --- libvserver-0.1/lib/vserver/signal_cmd.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,25 +0,0 @@ -#ifndef _VX_SIGNAL_CMD_H -#define _VX_SIGNAL_CMD_H - -/* signalling vserver commands */ - -#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0) -#define VCMD_wait_exit VC_CMD(EVENT, 99, 0) - -struct vcmd_ctx_kill_v0 { - int32_t pid; - int32_t sig; -}; - -struct vcmd_wait_exit_v0 { - int32_t a; - int32_t b; -}; - -#ifdef __KERNEL__ - -extern int vc_ctx_kill(uint32_t, void __user *); -extern int vc_wait_exit(uint32_t, void __user *); - -#endif /* __KERNEL__ */ -#endif /* _VX_SIGNAL_CMD_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/switch.h libvserver-0.1.1/lib/vserver/switch.h --- libvserver-0.1/lib/vserver/switch.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,97 +0,0 @@ -#ifndef _VX_SWITCH_H -#define _VX_SWITCH_H - -#include - -#define VC_CATEGORY(c) (((c) >> 24) & 0x3F) -#define VC_COMMAND(c) (((c) >> 16) & 0xFF) -#define VC_VERSION(c) ((c) & 0xFFF) - -#define VC_CMD(c,i,v) ((((VC_CAT_ ## c) & 0x3F) << 24) \ - | (((i) & 0xFF) << 16) | ((v) & 0xFFF)) - -/* - - Syscall Matrix V2.8 - - |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL| - |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | | - |INFO |SETUP | |MOVE | | | | | | - -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ - SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICES| | - HOST | 00| 01| 02| 03| 04| 05| | 06| 07| - -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ - CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | | - PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15| - -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ - MEMORY | | | | | | | |SWAP | | - | 16| 17| 18| 19| 20| 21| | 22| 23| - -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ - NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | | - | 24| 25| 26| 27| 28| 29| | 30| 31| - -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ - DISK | | | | |DLIMIT | | |INODE | | - VFS | 32| 33| 34| 35| 36| 37| | 38| 39| - -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ - OTHER | | | | | | | |VINFO | | - | 40| 41| 42| 43| 44| 45| | 46| 47| - =======+=======+=======+=======+=======+=======+=======+ +=======+=======+ - SPECIAL|EVENT | | | |FLAGS | | | | | - | 48| 49| 50| 51| 52| 53| | 54| 55| - -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ - SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT | - | 56| 57| 58| 59| 60|TEST 61| | 62| 63| - -------+-------+-------+-------+-------+-------+-------+ +-------+-------+ - -*/ - -#define VC_CAT_VERSION 0 - -#define VC_CAT_VSETUP 1 -#define VC_CAT_VHOST 2 - -#define VC_CAT_VPROC 9 -#define VC_CAT_PROCALT 10 -#define VC_CAT_PROCMIG 11 -#define VC_CAT_PROCTRL 12 - -#define VC_CAT_SCHED 14 - -#define VC_CAT_VNET 25 -#define VC_CAT_NETALT 26 -#define VC_CAT_NETMIG 27 -#define VC_CAT_NETCTRL 28 - -#define VC_CAT_DLIMIT 36 -#define VC_CAT_INODE 38 - -#define VC_CAT_VINFO 46 -#define VC_CAT_EVENT 48 - -#define VC_CAT_FLAGS 52 -#define VC_CAT_DEBUG 56 -#define VC_CAT_RLIMIT 60 - -#define VC_CAT_SYSTEST 61 -#define VC_CAT_COMPAT 63 - -/* interface version */ - -#define VCI_VERSION 0x00010025 - - -/* query version */ - -#define VCMD_get_version VC_CMD(VERSION, 0, 0) - - -#ifdef __KERNEL__ - -#include - - -#else /* __KERNEL__ */ -#define __user -#endif /* __KERNEL__ */ - -#endif /* _VX_SWITCH_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver/syscall.h libvserver-0.1.1/lib/vserver/syscall.h --- libvserver-0.1/lib/vserver/syscall.h 2005-06-01 14:26:01.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/syscall.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,952 +0,0 @@ - -#ifndef __syscall_retval -#define __syscall_retval(v) do { } while(0) -#endif - -#ifndef __syscall_error -#define __syscall_error(e) do { errno = (e); } while(0) -#endif - -#define __check(pos, reg) \ - ".ifnc\t" pos ", " reg "\n\t" \ - ".err\t/* register assertion failed */\n\t" \ - ".endif\n\t" - -#ifndef __stringify0 -#define __stringify0(val) #val -#endif - -#ifndef __stringify -#define __stringify(val) __stringify0(val) -#endif - -#define __comment(name) \ - "\t/* kernel sys_" #name "[" __stringify(__NR_##name) "] */" - - - /* argument concatenation */ - -#define __arglst_6(x,head,tail...) __arglst_5(x,tail)x(6,head) -#define __arglst_5(x,head,tail...) __arglst_4(x,tail)x(5,head) -#define __arglst_4(x,head,tail...) __arglst_3(x,tail)x(4,head) -#define __arglst_3(x,head,tail...) __arglst_2(x,tail)x(3,head) -#define __arglst_2(x,head,tail...) __arglst_1(x,tail)x(2,head) -#define __arglst_1(x,head,tail...) x(1,head) -#define __arglst_0(x,head,tail...) - - /* string concatenation */ - -#define __concat_6(x) __concat_5(x)x(6) -#define __concat_5(x) __concat_4(x)x(5) -#define __concat_4(x) __concat_3(x)x(4) -#define __concat_3(x) __concat_2(x)x(3) -#define __concat_2(x) __concat_1(x)x(2) -#define __concat_1(x) __concat_0(x)x(1) -#define __concat_0(x) x(0) - - /* argument selection */ - -#define __arg_0(a0,a1,a2,a3,a4,a5,a6) a0 -#define __arg_1(a0,a1,a2,a3,a4,a5,a6) a1 -#define __arg_2(a0,a1,a2,a3,a4,a5,a6) a2 -#define __arg_3(a0,a1,a2,a3,a4,a5,a6) a3 -#define __arg_4(a0,a1,a2,a3,a4,a5,a6) a4 -#define __arg_5(a0,a1,a2,a3,a4,a5,a6) a5 -#define __arg_6(a0,a1,a2,a3,a4,a5,a6) a6 - - -/* ***************************************** - ALPHA ALPHA ALPHA ALPHA * - alpha kernel interface */ - -#if defined(__alpha__) - -/* The Alpha calling convention doesn't use the stack until - after the first six arguments have been passed in registers. - - scnr: a0($0) - args: a1($16), a2($17), a3($18), a4($19), a5($20), a6($21) - sret: r0($0) - serr: e0($19) (!=0, err=sret) - call: callsys - clob: memory -*/ - -#define __syscall_reg_ret "$0" -#define __syscall_reg_err "$19" -#define __syscall_reg_cid "$0" -#define __syscall_cmd_seq "callsys" -#define __syscall_clobbers \ - "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \ - "$22", "$23", "$24", "$25", "$27", "$28", "memory" \ - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "$16", "$17", "$18", "$19", "$20", "$21") -#define __syscall_clb_arg(n) __arg_##n \ - ("", "$16", "$17", "$18", "memory", "$20", "$21") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0%1%2","%3","%4","%5","%6","%7","%8") -#define __syscall_reg_ckr(n) __arg_##n \ - ("$0$19$0","$16","$17","$18","$19","$20","$21") - - - -/* ***************************************** - ARM ARM ARM ARM * - arm kernel interface */ - -#elif defined(__arm__) - -/* The Arm calling convention uses stack args after four arguments - but the Linux kernel gets up to seven arguments in registers. - - scnr: imm - args: a1(r0), a2(r1), a3(r2), a4(r3), a5(r4), a6(r5), - sret: r0(r0) - serr: (sret >= (unsigned)-EMAXERRNO) - call: swi - clob: memory -*/ - -#define __syscall_maxerrno 125 -#define __syscall_regtype long -#define __syscall_reg_res "r0" -#define __syscall_imm_cid -#define __syscall_cmd_seq "swi\t%1" -#define __syscall_clobbers "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "r0", "r1", "r2", "r3", "r4", "r5") -#define __syscall_clb_arg(n) __arg_##n \ - ("", "memory", "r1", "r2", "r3", "r4", "r5") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0","%2","%3","%4","%5","%6","%7") -#define __syscall_reg_ckr(n) __arg_##n \ - ("r0","r0","r1","r2","r3","r4","r5") - - - -/* ***************************************** - CRIS CRIS CRIS CRIS * - cris v10 kernel interface */ - -#elif defined(__cris__) - -/* The Cris calling convention uses stack args after four arguments - but the Linux kernel gets up to six arguments in registers. - - scnr: id(r9) - args: a1(r10), a2(r11), a3(r12), a4(r13), a5(mof), a6(srp), - sret: r0(r10) - serr: (sret >= (unsigned)-EMAXERRNO) - call: break 13 - clob: memory -*/ - -#define __syscall_maxerrno 125 -#define __syscall_reg_res "r0" -#define __syscall_reg_cid "r9" -#define __syscall_cmd_seq "break 13" -#define __syscall_clobbers "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "r10", "r11", "r12", "r13", "mof", "srp") -#define __syscall_clb_arg(n) __arg_##n \ - ("", "memory", "r11", "r12", "r13", "memory", "memory") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0%1","%2","%3","%4","%5","%6","%7") -#define __syscall_reg_ckr(n) __arg_##n \ - ("r9r10","r10","r11","r12","r13","mof","srp") - -#ifndef _syscall5 -#define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ - type4, arg4, type5, arg5) \ -type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ -{ \ - ____sc_results; \ - { \ - ____sc_reg_ret; \ - ____sc_reg_cid(__NR_##name) \ - ____sc_regs(4, arg4, arg3, arg2, arg1); \ - ____sc_asm ( \ - ____sc_check(4) \ - "move\t%6,$mof\n\t" \ - ____sc_syscall(name) \ - : ____sc_output \ - : ____sc_input_cid(__NR_##name) \ - ____sc_input_4, \ - "g"((__syscall_regtype)(arg5)) \ - : ____sc_clobber_4 \ - ); \ - ____sc_reg_results; \ - } \ - ____sc_return(type) \ -} -#endif - -#ifndef _syscall6 -#define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ - type4, arg4, type5, arg5, type6, arg6) \ -type name (type1 arg1, type2 arg2, type3 arg3, \ - type4 arg4, type5 arg5, type6 arg6) \ -{ \ - ____sc_results; \ - { \ - ____sc_reg_ret; \ - ____sc_reg_cid(__NR_##name) \ - ____sc_regs(4, arg4, arg3, arg2, arg1); \ - ____sc_asm ( \ - ____sc_check(4) \ - "move\t%6,$mof\n\t" \ - "move\t%7,$srp\n\t" \ - ____sc_syscall(name) \ - : ____sc_output \ - : ____sc_input_cid(__NR_##name) \ - ____sc_input_4, \ - "g"((__syscall_regtype)(arg5)), \ - "g"((__syscall_regtype)(arg6)) \ - : ____sc_clobber_4 \ - ); \ - ____sc_reg_results; \ - } \ - ____sc_return(type) \ -} -#endif - - -/* ***************************************** - FRV FRV FRV FRV * - frv kernel interface */ - -#elif defined(__frv__) - -/* The C calling convention on FR-V uses the gr8-gr13 registers - for the first six arguments, the remainder is spilled onto the - stack. the linux kernel syscall interface does so too. - - scnr: id(gr7) - args: a1(gr8), a2(gr9), a3(gr10), a4(gr11), a5(gr12), a6(gr13) - sret: r0(gr8) - serr: (sret >= (unsigned)-EMAXERRNO) - call: tra gr0,gr0 - clob: memory -*/ - -#define __syscall_maxerrno 125 -#define __syscall_reg_res "gr8" -#define __syscall_reg_cid "gr7" -#define __syscall_cmd_seq "tra\tgr0,gr0" -#define __syscall_clobbers "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "gr8", "gr9", "gr10", "gr11", "gr12", "gr13") -#define __syscall_clb_arg(n) __arg_##n \ - ("", "memory", "gr9", "gr10", "gr11", "gr12", "gr13") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0%1","%2","%3","%4","%5","%6","%7") -#define __syscall_reg_ckr(n) __arg_##n \ - ("gr8gr7","gr8","gr9","gr10","gr11","gr12","gr13") - - -/* ***************************************** - H8300 H8300 H8300 H8300 * - h8/300 kernel interface */ - -#elif defined(__H8300__) - -/* The H8/300 C calling convention passes the first three - arguments in registers. However the linux kernel calling - convention passes the first six arguments in registers - er1-er6 - - scnr: id(er0) - args: a1(er1), a2(er2), a3(er3), a4(er4), a5(er5), a6(er6) - sret: r0(er0) - serr: (sret >= (unsigned)-EMAXERRNO) - call: trapa #0 - clob: memory -*/ - -#define __syscall_maxerrno 125 -#define __syscall_reg_res "er0" -#define __syscall_imm_cid -#define __syscall_cmd_seq "trapa\t#0" -#define __syscall_clobbers "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "memory", "er2", "er3", "er4", "er5", "memory") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0%1","%2","%3","%4","%5","%6","%7") -#define __syscall_reg_ckr(n) __arg_##n \ - ("er0er0","er1","er2","er3","er4","er5","er6") - -#define __sc_prep_0 "mov.l\t%1,er0\n\t" -#define __sc_prep_1 "mov.l\t%2,er1\n\t" __sc_prep_0 -#define __sc_prep_2 "mov.l\t%3,er2\n\t" __sc_prep_1 -#define __sc_prep_3 "mov.l\t%4,er3\n\t" __sc_prep_2 -#define __sc_prep_4 "mov.l\t%5,er4\n\t" __sc_prep_3 -#define __sc_prep_5 "mov.l\t%6,er5\n\t" __sc_prep_4 -#define __sc_prep_6 "mov.l er6,@-sp\n\t" \ - "mov.l\t%7,er6\n\t" __sc_prep_5 - -#define __sc_reg_arg_0(arg) -#define __sc_reg_arg_1(arg) ,"g"(arg) -#define __sc_reg_arg_2(arg) ,"g"(arg) -#define __sc_reg_arg_3(arg) ,"g"(arg) -#define __sc_reg_arg_4(arg) ,"g"(arg) -#define __sc_reg_arg_5(arg) ,"m"(arg) -#define __sc_reg_arg_6(arg) ,"m"(arg) - -#define ____sc_reg_arg(n,arg) __sc_reg_arg_##n(arg) - -#define ____sc_body(numarg, type, name, args...) \ -{ \ - ____sc_results; \ - { \ - ____sc_reg_ret; \ - ____sc_asm ( \ - __sc_prep_##numarg \ - ____sc_sys(name,numarg) \ - : ____sc_output \ - : ____sc_input_cid(__NR_##name) \ - ____sc_regs(numarg,args) \ - : ____sc_clobber_##numarg \ - ); \ - ____sc_reg_results \ - } \ - ____sc_return(type) \ -} - - -/* ***************************************** - I386 I386 I386 I386 * - i386 kernel interface */ - -#elif defined(__i386__) - -/* The x86 calling convention uses stack args for all arguments, - but the Linux kernel passes the first six arguments in the - following registers: ebx, ecx, edx, esi, edi, ebp. - - scnr: id(eax) - args: a1(ebx), a2(ecx), a3(edx), a4(esi), a5(edi), a6(ebp) - sret: r0(eax) - serr: (sret >= (unsigned)-EMAXERRNO) - call: int 0x80 - clob: memory -*/ - -#define __syscall_maxerrno 129 -#define __syscall_reg_res "eax" -#define __syscall_reg_cid "eax" -#define __syscall_cmd_seq "int\t$0x80" -#define __syscall_clobbers "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "ebx", "ecx", "edx", "esi", "edi", "eax") -#define __syscall_clb_arg(n) __arg_##n \ - ("", "ebx", "ecx", "edx", "esi", "edi", "memory") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0%1","%2","%3","%4","%5","%6","") -#define __syscall_reg_ckr(n) __arg_##n \ - ("%%eax%%eax","%%ebx","%%ecx","%%edx","%%esi","%%edi","") - -#ifndef _syscall6 -#define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ - type4, arg4, type5, arg5, type6, arg6) \ -type name (type1 arg1, type2 arg2, type3 arg3, \ - type4 arg4, type5 arg5, type6 arg6) \ -{ \ - ____sc_results; \ - { \ - ____sc_reg_ret \ - ____sc_regs(6, arg6, arg5, arg4, arg3, arg2, arg1); \ - ____sc_asm ( \ - __check("%0%2%3%4%5%6%7", \ - "%%eax%%ebx%%ecx%%edx%%esi%%edi%%eax") \ - "push\t%%ebp\n\t" \ - "movl\t%%eax,%%ebp\n\t" \ - "movl\t%1,%%eax\n\t" \ - ____sc_syscall(name) "\n\t" \ - "pop\t%%ebp" \ - : ____sc_output \ - : "i"(__NR_##name) ____sc_input_6 \ - : ____sc_clobber_6 \ - ); \ - ____sc_reg_results; \ - } \ - ____sc_return(type) \ -} -#endif - - -/* ***************************************** - IA64 IA64 IA64 IA64 * - ia64 kernel interface */ - -#elif defined(__ia64__) - -/* The ia64 calling convention uses out0-out7 to pass the first - eight arguments (mapped via register windows). - - scnr: id(r15) - args: a1(out0), a2(out1), ... a5(out4), a6(out5) - sret: r0(r8) - serr: e0(r10) - call: break 0x100000 - clob: out6/7, r2/3/9, r11-r14, r16-r31, p6-p15, f6-f15, b6/7 -*/ - -#define __syscall_errcon(err) (err == -1) - -#define __syscall_reg_ret "r8" -#define __syscall_reg_err "r10" -#define __syscall_reg_cid "r15" -#define __syscall_cmd_seq "break.i\t0x100000" - -#define __syscall_clobbers \ - "out6", "out7", "r2", "r3", "r9", "r11", "r12", "r13", \ - "r14", "r16", "r17", "r18", "r19", "r20", "r21", "r22", \ - "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30", \ - "r31", "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", \ - "p14", "p15", "f6", "f7", "f8", "f9", "f10", "f11", "f12", \ - "f13", "f14", "f15", "f16", "b6", "b7", "cc", "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "out0", "out1", "out2", "out3", "out4", "out5") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0%1%2","","","","","","") -#define __syscall_reg_ckr(n) __arg_##n \ - ("r8r10r15","","","","","","") - - -/* ***************************************** - M32R M32R M32R M32R * - m32r kernel interface */ - -#elif defined(__m32r__) - -/* The m32r calling convention uses r0-r7 to pass the first - eight arguments (mapped via register windows). - - scnr: id(r0) - args: a1(r1), a2(r2), a3(r3), a4(r4), a5(r5), a6(r6) - sret: r0(r0) - serr: (sret >= (unsigned)-EMAXERRNO) - call: trap #2 - clob: out6/7, r2/3/9, r11-r14, r16-r31, p6-p15, f6-f15, b6/7 -*/ - -#define __syscall_maxerrno 125 -#define __syscall_reg_res "r0" -#define __syscall_reg_cid "r7" -#define __syscall_cmd_seq "trap #2" -#define __syscall_clobbers "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "r0", "r1", "r2", "r3", "r4", "r5") -#define __syscall_clb_arg(n) "memory" -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0%1","%2","%3","%4","%5","%6","%7") -#define __syscall_reg_ckr(n) __arg_##n \ - ("r0r7","r0","r1","r2","r3","r4","r5") - - -/* ***************************************** - M68K M68K M68K M68K * - m68k kernel interface */ - -#elif defined(__m68000__) - -#warning syscall arch m68k not implemented yet - - -/* ***************************************** - MIPS MIPS MIPS MIPS * - mips kernel interface */ - -#elif defined(__mips__) - -#warning syscall arch mips not implemented yet - - -/* ***************************************** - HPPA HPPA HPPA HPPA * - hppa/64 kernel interface */ - -#elif defined(__hppa__) - -/* The hppa calling convention uses r26-r23 for the first 4 - arguments, the rest is spilled onto the stack. However the - Linux kernel passes the first six arguments in the registers - r26-r21. - - The system call number MUST ALWAYS be loaded in the delay - slot of the ble instruction, or restarting system calls - WILL NOT WORK. - - scnr: id(r20) - args: a1(r26), a2(r25), a3(r24), a4(r23), a5(r22), a6(r21) - sret: r0(r28) - serr: (sret >= (unsigned)-EMAXERRNO) - call: ble 0x100(%%sr2, %%r0) - clob: r1, r2, r4, r20, r29, r31, memory -*/ - -#define __syscall_maxerrno 4095 -#define __syscall_reg_res "r28" -#define __syscall_imm_cid -#define __syscall_cmd_seq "ble 0x100(%%sr2,%%r0)" -#define __syscall_cmd_fin "ldi %1,%%r20" -#define __syscall_clobbers \ - "r1", "r2", "r4", "r20", "r29", "r31", "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "r26", "r25", "r24", "r23", "r22", "r21") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0","%2","%3","%4","%5","%6","%7") -#define __syscall_reg_ckr(n) __arg_##n \ - ("%%r28","%%r26","%%r25","%%r24","%%r23","%%r22","%%r21") - - -/* ***************************************** - PPC PPC PPC PPC * - ppc/64 kernel interface */ - -#elif defined(__powerpc__) - -/* The powerpc calling convention uses r3-r10 to pass the first - eight arguments, the remainder is spilled onto the stack. - - scnr: id(r0) - args: a1(r3), a2(r4), a3(r5), a4(r6), a5(r7), a6(r8) - sret: r0(r3) - serr: (carry) - call: sc - clob: cr0, ctr -*/ - - -#define __syscall_errcon(err) (err & 0x10000000) - -#define __syscall_reg_ret "r3" -#define __syscall_reg_err "r0" -#define __syscall_reg_cid "r0" -#define __syscall_cmd_seq "sc" -#define __syscall_cmd_fin "mfcr %0" -#define __syscall_clobbers \ - "r9", "r10", "r11", "r12", "cr0", "ctr", "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "r3", "r4", "r5", "r6", "r7", "r8") -#define __syscall_clb_arg(n) __arg_##n \ - ("", "memory", "r4", "r5", "r6", "r7", "r8") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0.%1.%2",".%3",".%4",".%5",".%6",".%7",".%8") -#define __syscall_reg_ckr(n) __arg_##n \ - ("3.0.0",".3",".4",".5",".6",".7",".8") - - -/* ***************************************** - S390 S390 S390 S390 * - s390/x kernel interface */ - -#elif defined(__s390__) - -/* The s390x calling convention passes the first five arguments - in r2-r6, the remainder is spilled onto the stack. However - the Linux kernel passes the first six arguments in r2-r7. - - scnr: imm, id(r1) - args: a1(r2), a2(r3), a3(r4), a4(r5), a5(r6), a6(r7) - sret: r0(r2) - serr: (sret >= (unsigned)-EMAXERRNO) - call: svc - clob: memory -*/ - -#define __syscall_maxerrno 4095 -#define __syscall_regtype unsigned long -#define __syscall_reg_res "r2" -#define __syscall_reg_cid "r1" -#define __syscall_cmd_seq "svc\t0" -#define __syscall_clobbers "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "r2", "r3", "r4", "r5", "r6", "r7") -#define __syscall_clb_arg(n) __arg_##n \ - ("", "memory", "r3", "r4", "r5", "r6", "r7") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0%1","%2","%3","%4","%5","%6","%7") -#define __syscall_reg_ckr(n) __arg_##n \ - ("%%r2%%r1","%%r2","%%r3","%%r4","%%r5","%%r6","%%r7") - - - -/* ***************************************** - SH SH SH SH * - sh kernel interface */ - -#elif defined(__sh__) && !defined(__SH5__) - -#warning syscall arch sh not implemented yet - - -/* ***************************************** - SH64 SH64 SH64 SH64 * - sh64 kernel interface */ - -#elif defined(__sh__) && defined(__SH5__) - -#warning syscall arch sh64 not implemented yet - - -/* ***************************************** - SPARC64 SPARC64 SPARC64 SPARC64 * - sparc64 kernel interface */ - -#elif defined(__sparc__) - -/* The sparc/64 calling convention uses o0-o5 to pass the first - six arguments (mapped via register windows). - - scnr: id(g1) - args: a1(o0), a2(o1), a3(o2), a4(o3), a5(o4), a6(o5) - sret: r0(o0) - serr: (carry) - call: ta 0x6d, t 0x10 - clob: g1-g6, g7?, o7?, f0-f31, cc -*/ - -#define __syscall_maxerrno 515 -#define __syscall_reg_ret "o0" -#define __syscall_reg_err "l1" -#define __syscall_reg_cid "g1" -#ifdef __arch64__ -#define __syscall_cmd_seq "ta\t0x6d" -#else -#define __syscall_cmd_seq "t\t0x10" -#endif -#define __syscall_cmd_fin "addx\t%%g0,%%g0,%%l1" - -#define __syscall_clobbers \ - "g2", "g3", "g4", "g5", "g6", \ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", \ - "f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16", \ - "f17", "f18", "f19", "f20", "f21", "f22", "f23", "f24", \ - "f25", "f26", "f27", "f28", "f29", "f30", "f31", "f32", \ - "f34", "f36", "f38", "f40", "f42", "f44", "f46", "f48", \ - "f50", "f52", "f54", "f56", "f58", "f60", "f62", \ - "cc", "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "o0", "o1", "o2", "o3", "o4", "o5") -#define __syscall_clb_arg(n) __arg_##n \ - ("", "memory", "o1", "o2", "o3", "o4", "o5") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0%1%2","%3","%4","%5","%6","%7","%8") -#define __syscall_reg_ckr(n) __arg_##n \ - ("%%o0%%l1%%g1","%%o0","%%o1","%%o2","%%o3","%%o4","%%o5") - - -/* ***************************************** - V850 V850 V850 V850 * - v850 kernel interface */ - -#elif defined(__v850__) - -/* The V850 calling convention passes the first four arguments - in registers r6-r9, the rest is spilled onto the stack. - but the Linux kernel interface uses r6-r9 and r13/14. - - scnr: id(r12) - args: a1(r6), a2(r7), a3(r8), a4(r9), a5(r13), a6(r14) - sret: r0(r10) - serr: (sret >= (unsigned)-EMAXERRNO) - call: trap 0, trap 1 - clob: r1, r5, r11, r15-r19 -*/ - -#define __syscall_maxerrno 515 -#define __syscall_reg_res "r10" -#define __syscall_reg_cid "r12" -#define __syscall_cmd_num(n) __arg_##n \ - ("", "trap 0", "trap 0", "trap 0", "trap 0", "trap 1", "trap 1") - -#define __syscall_clobbers \ - "r1", "r5", "r11", "r15", "r16", "r17", "r18", "r19", "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "r6", "r7", "r8", "r9", "r13", "r14") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0%1","%2","%3","%4","%5","%6","%7") -#define __syscall_reg_ckr(n) __arg_##n \ - ("r10r12","r6","r7","r8","r9","r13","r14") - - -/* ***************************************** - X86_64 X86_64 X86_64 X86_64 * - x86_64 kernel interface */ - -#elif defined(__x86_64__) - -/* The x86_64 calling convention uses rdi, rsi, rdx, rcx, r8, r9 - but the Linux kernel interface uses rdi, rsi, rdx, r10, r8, r9. - - scnr: id(rax) - args: a1(rdi), a2(rsi), a3(rdx), a4(r10), a5(r8), a6(r9) - sret: r0(rax) - serr: (err= sret > (unsigned)-EMAXERRNO) - call: syscall - clob: rcx, r11 -*/ - -#define __syscall_maxerrno 4095 -#define __syscall_reg_res "rax" -#define __syscall_reg_cid "rax" -#define __syscall_cmd_seq "syscall" - -#define __syscall_clobbers \ - "cc", "r11", "rcx", "memory" - -#define __syscall_reg_arg(n) __arg_##n \ - ("", "rdi", "rsi", "rdx", "r10", "r8", "r9") -#define __syscall_reg_ckl(n) __arg_##n \ - ("%0%1","%2","%3","%4","%5","%6","%7") -#define __syscall_reg_ckr(n) __arg_##n \ - ("%%rax%%rax","%%rdi","%%rsi","%%rdx","%%r10","%%r8","%%r9") - - -#else -#error unknown kernel arch -#endif - - - - -#ifndef EMAXERRNO -#define EMAXERRNO __syscall_maxerrno -#endif - -#ifndef __syscall_regdef -#define __syscall_regdef(name, reg) \ - register __syscall_regtype __sc_##name asm (reg) -#endif - -#ifndef __syscall_regval -#define __syscall_regval(name, reg, val) \ - register __syscall_regtype __sc_##name asm (reg) = \ - (__syscall_regtype)(val) -#endif - - -#ifndef __syscall_reg_err /* simple result */ - -#define ____sc_results __syscall_regtype __res - -#define ____sc_reg_ret \ - __syscall_regdef(r0, __syscall_reg_res) - -#define ____sc_output "=r"(__sc_r0) -#define ____sc_return(type) __syscall_return(type, __res) - -#ifndef __syscall_stores -#define __syscall_stores __res = __sc_r0; -#endif - -#ifndef __syscall_errcon -#define __syscall_errcon(res) \ - ((unsigned long)(res) >= (unsigned long)(-(__syscall_maxerrno))) -#endif - -#ifndef __syscall_return -#define __syscall_return(type, res) \ - __syscall_retval(res); \ - if (__syscall_errcon(res)) { \ - int __err = -(res); \ - __syscall_error(__err); \ - res = -1; \ - } \ - return (type)(res); -#endif - -#else /* complex result */ - -#define ____sc_results __syscall_regtype __ret, __err - -#define ____sc_reg_ret \ - __syscall_regdef(r0, __syscall_reg_ret); \ - __syscall_regdef(e0, __syscall_reg_err) - -#define ____sc_output "=r"(__sc_r0), "=r"(__sc_e0) -#define ____sc_return(type) __syscall_return(type, __ret, __err) - -#ifndef __syscall_stores -#define __syscall_stores __ret = __sc_r0; __err = __sc_e0; -#endif - -#ifndef __syscall_errcon -#define __syscall_errcon(err) (err) -#endif - -#ifndef __syscall_return -#define __syscall_return(type, ret, err) \ - __syscall_retval(ret); \ - if (__syscall_errcon(err)) { \ - int __err = (ret); \ - __syscall_error(__err); \ - ret = -1; \ - } \ - return (type)(ret); -#endif - -#endif /* simple/complex */ - - -#ifndef __syscall_clb_arg -#define __syscall_clb_arg(n) __syscall_reg_arg(n) -#endif - -#ifndef __syscall_regtype -#define __syscall_regtype long -#endif - -#ifndef __syscall_reg_cid -#define ____sc_reg_cid(__cid) -#ifndef __syscall_imm_cid -#define ____sc_input_cid(__cid) -#else -#ifndef ____sc_input_cid -#define ____sc_input_cid(__cid) "i"(__cid) -#endif -#endif -#else -#define ____sc_reg_cid(__cid) \ - __syscall_regval(id, __syscall_reg_cid, __cid) -#ifndef ____sc_input_cid -#define ____sc_input_cid(__cid) "r"(__sc_id) -#endif -#endif - - -#ifndef ____sc_reg_arg -#define ____sc_reg_arg(n,arg) ; __syscall_regval(a##n, \ - __syscall_reg_arg(n), arg) -#endif - -#ifndef ____sc_regs -#define ____sc_regs(n,args...) __arglst_##n(____sc_reg_arg,args) -#endif - -#define ____sc_check(n) __check( \ - __concat_##n(__syscall_reg_ckl),__concat_##n(__syscall_reg_ckr)) - - -#ifndef ____sc_clobber_0 -#define ____sc_clobber_6 __syscall_clobbers -#define ____sc_clobber_5 __syscall_clb_arg(6), ____sc_clobber_6 -#define ____sc_clobber_4 __syscall_clb_arg(5), ____sc_clobber_5 -#define ____sc_clobber_3 __syscall_clb_arg(4), ____sc_clobber_4 -#define ____sc_clobber_2 __syscall_clb_arg(3), ____sc_clobber_3 -#define ____sc_clobber_1 __syscall_clb_arg(2), ____sc_clobber_2 -#define ____sc_clobber_0 __syscall_clb_arg(1), ____sc_clobber_1 -#endif - -#ifndef ____sc_input_0 -#define ____sc_input_6 ____sc_input_5, "r"(__sc_a6) -#define ____sc_input_5 ____sc_input_4, "r"(__sc_a5) -#define ____sc_input_4 ____sc_input_3, "r"(__sc_a4) -#define ____sc_input_3 ____sc_input_2, "r"(__sc_a3) -#define ____sc_input_2 ____sc_input_1, "r"(__sc_a2) -#define ____sc_input_1 ,"r"(__sc_a1) -#define ____sc_input_0 -#endif - -#define ____sc_asm asm volatile - - -#ifdef __syscall_cmd_fin -#define ____sc_syscall(name) __syscall_cmd_seq __comment(name) "\n\t"\ - __syscall_cmd_fin -#else -#define ____sc_syscall(name) __syscall_cmd_seq __comment(name) -#endif - -#define ____sc_reg_results __syscall_stores - - -#ifndef __syscall_cmd_num -#define ____sc_sys(name,n) ____sc_syscall(name) -#else -#define ____sc_sys(name,n) __syscall_cmd_num(n) __comment(name) -#endif - -#ifndef ____sc_body -#define ____sc_body(numarg, type, name, args...) \ -{ \ - ____sc_results; \ - { \ - ____sc_reg_ret; \ - ____sc_reg_cid(__NR_##name) \ - ____sc_regs(numarg,args); \ - ____sc_asm ( \ - ____sc_check(numarg) \ - ____sc_sys(name,numarg) \ - : ____sc_output \ - : ____sc_input_cid(__NR_##name) \ - ____sc_input_##numarg \ - : ____sc_clobber_##numarg \ - ); \ - ____sc_reg_results; \ - } \ - ____sc_return(type) \ -} -#endif - - -#ifndef _syscall0 -#define _syscall0(type, name) \ -type name(void) \ -____sc_body(0, type, name) -#endif - -#ifndef _syscall1 -#define _syscall1(type, name, type1, arg1) \ -type name(type1 arg1) \ -____sc_body(1, type, name, arg1) -#endif - -#ifndef _syscall2 -#define _syscall2(type, name, type1, arg1, type2, arg2) \ -type name(type1 arg1, type2 arg2) \ -____sc_body(2, type, name, arg2, arg1) -#endif - -#ifndef _syscall3 -#define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ -type name(type1 arg1, type2 arg2, type3 arg3) \ -____sc_body(3, type, name, arg3, arg2, arg1) -#endif - -#ifndef _syscall4 -#define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \ - type4, arg4) \ -type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ -____sc_body(4, type, name, arg4, arg3, arg2, arg1) -#endif - -#ifndef _syscall5 -#define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ - type4, arg4, type5, arg5) \ -type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ -____sc_body(5, type, name, arg5, arg4, arg3, arg2, arg1) -#endif - -#ifndef _syscall6 -#define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ - type4, arg4, type5, arg5, type6, arg6) \ -type name (type1 arg1, type2 arg2, type3 arg3, \ - type4 arg4, type5 arg5, type6 arg6) \ -____sc_body(6, type, name, arg6, arg5, arg4, arg3, arg2, arg1) -#endif - diff -NurpP --minimal libvserver-0.1/lib/vserver/vserver.h libvserver-0.1.1/lib/vserver/vserver.h --- libvserver-0.1/lib/vserver/vserver.h 2005-06-23 10:08:57.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/vserver.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,49 +0,0 @@ - -#include -#include - -#include "syscall.h" - -#if defined(__alpha__) -#define __NR_vserver 428 -#elif defined(__arm__) -#define __NR_vserver 313 -#elif defined(__cris__) -#define __NR_vserver 273 -#elif defined(__frv__) -#define __NR_vserver 273 -#elif defined(__h8300__) -#define __NR_vserver 273 -#elif defined(__i386__) -#define __NR_vserver 273 -#elif defined(__ia64__) -#define __NR_vserver 1269 -#elif defined(__m32r__) -#define __NR_vserver __m32r_NR_vserver -#elif defined(__mc68000__) -#define __NR_vserver 278 -#elif defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI32) -#define __NR_vserver 277 -#elif defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI64) -#define __NR_vserver 240 -#elif defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_NABI32) -#define __NR_vserver 236 -#elif defined(__hppa__) -#define __NR_vserver __hppa_NR_vserver -#elif defined(__powerpc__) -#define __NR_vserver 257 -#elif defined(__s390__) -#define __NR_vserver 263 -#elif defined(__sh__) -#define __NR_vserver 273 -#elif defined(__sparc__) -#define __NR_vserver 267 -#elif defined(__v850__) -#define __NR_vserver __v850_NR_vserver -#elif defined(__x86_64__) -#define __NR_vserver 236 -#endif - -static inline -_syscall3(int, vserver, uint32_t, cmd, uint32_t, id, void *, data); - diff -NurpP --minimal libvserver-0.1/lib/vserver/xid.h libvserver-0.1.1/lib/vserver/xid.h --- libvserver-0.1/lib/vserver/xid.h 2005-05-21 04:29:23.000000000 +0200 +++ libvserver-0.1.1/lib/vserver/xid.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,135 +0,0 @@ -#ifndef _VX_XID_H -#define _VX_XID_H - -#ifndef CONFIG_VSERVER -#warning config options missing -#endif - -#define XID_TAG(in) (!(in) || \ - (((struct inode *)in)->i_sb && \ - (((struct inode *)in)->i_sb->s_flags & MS_TAGXID))) - -#ifdef CONFIG_XID_TAG_NFSD -#define XID_TAG_NFSD 1 -#else -#define XID_TAG_NFSD 0 -#endif - - -#ifdef CONFIG_INOXID_NONE - -#define MAX_UID 0xFFFFFFFF -#define MAX_GID 0xFFFFFFFF - -#define INOXID_XID(tag, uid, gid, xid) (0) - -#define XIDINO_UID(tag, uid, xid) (uid) -#define XIDINO_GID(tag, gid, xid) (gid) - -#endif - - -#ifdef CONFIG_INOXID_GID16 - -#define MAX_UID 0xFFFFFFFF -#define MAX_GID 0x0000FFFF - -#define INOXID_XID(tag, uid, gid, xid) \ - ((tag) ? (((gid) >> 16) & 0xFFFF) : 0) - -#define XIDINO_UID(tag, uid, xid) (uid) -#define XIDINO_GID(tag, gid, xid) \ - ((tag) ? (((gid) & 0xFFFF) | ((xid) << 16)) : (gid)) - -#endif - - -#ifdef CONFIG_INOXID_UGID24 - -#define MAX_UID 0x00FFFFFF -#define MAX_GID 0x00FFFFFF - -#define INOXID_XID(tag, uid, gid, xid) \ - ((tag) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0) - -#define XIDINO_UID(tag, uid, xid) \ - ((tag) ? (((uid) & 0xFFFFFF) | (((xid) & 0xFF00) << 16)) : (uid)) -#define XIDINO_GID(tag, gid, xid) \ - ((tag) ? (((gid) & 0xFFFFFF) | (((xid) & 0x00FF) << 24)) : (gid)) - -#endif - - -#ifdef CONFIG_INOXID_UID16 - -#define MAX_UID 0x0000FFFF -#define MAX_GID 0xFFFFFFFF - -#define INOXID_XID(tag, uid, gid, xid) \ - ((tag) ? (((uid) >> 16) & 0xFFFF) : 0) - -#define XIDINO_UID(tag, uid, xid) \ - ((tag) ? (((uid) & 0xFFFF) | ((xid) << 16)) : (uid)) -#define XIDINO_GID(tag, gid, xid) (gid) - -#endif - - -#ifdef CONFIG_INOXID_INTERN - -#define MAX_UID 0xFFFFFFFF -#define MAX_GID 0xFFFFFFFF - -#define INOXID_XID(tag, uid, gid, xid) \ - ((tag) ? (xid) : 0) - -#define XIDINO_UID(tag, uid, xid) (uid) -#define XIDINO_GID(tag, gid, xid) (gid) - -#endif - - -#ifdef CONFIG_INOXID_RUNTIME - -#define MAX_UID 0xFFFFFFFF -#define MAX_GID 0xFFFFFFFF - -#define INOXID_XID(tag, uid, gid, xid) (0) - -#define XIDINO_UID(tag, uid, xid) (uid) -#define XIDINO_GID(tag, gid, xid) (gid) - -#endif - - -#define INOXID_UID(tag, uid, gid) \ - ((tag) ? ((uid) & MAX_UID) : (uid)) -#define INOXID_GID(tag, uid, gid) \ - ((tag) ? ((gid) & MAX_GID) : (gid)) - - -static inline uid_t vx_map_uid(uid_t uid) -{ - if ((uid > MAX_UID) && (uid != -1)) - uid = -2; - return (uid & MAX_UID); -} - -static inline gid_t vx_map_gid(gid_t gid) -{ - if ((gid > MAX_GID) && (gid != -1)) - gid = -2; - return (gid & MAX_GID); -} - - -#ifdef CONFIG_VSERVER_LEGACY -#define FIOC_GETXID _IOR('x', 1, long) -#define FIOC_SETXID _IOW('x', 2, long) -#define FIOC_SETXIDJ _IOW('x', 3, long) -#endif - -int vx_parse_xid(char *string, xid_t *xid, int remove); -void vx_propagate_xid(struct nameidata *nd, struct inode *inode); - -#endif /* _VX_XID_H */ diff -NurpP --minimal libvserver-0.1/lib/vserver.h libvserver-0.1.1/lib/vserver.h --- libvserver-0.1/lib/vserver.h 2005-06-29 12:06:36.000000000 +0200 +++ libvserver-0.1.1/lib/vserver.h 2005-06-23 10:08:57.000000000 +0200 @@ -1,125 +1,49 @@ -/*************************************************************************** - * Copyright (C) 2005 by Benedikt Boehm * - * hollow@gentoo.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#include #include -#include -#include -#include -#include - -#include "vserver/syscall.h" -#include "vserver/vserver.h" - -//#include "vserver/context.h" -#include "vserver/context_cmd.h" -//#include "vserver/cvirt.h" -//#include "vserver/cvirt_cmd.h" -//#include "vserver/cvirt_def.h" -//#include "vserver/dlimit.h" -#include "vserver/dlimit_cmd.h" -//#include "vserver/inode.h" -#include "vserver/inode_cmd.h" -//#include "vserver/limit.h" -#include "vserver/limit_cmd.h" -//#include "vserver/limit_def.h" -#include "vserver/namespace.h" -//#include "vserver/network.h" -#include "vserver/network_cmd.h" -//#include "vserver/sched.h" -#include "vserver/sched_cmd.h" -//#include "vserver/sched_def.h" -#include "vserver/signal_cmd.h" -#include "vserver/switch.h" -//#include "vserver/xid.h" - -#define CMD_VERSION \ - printf("%s %s -- %s\n", NAME, VERSION, DESCR); \ - printf("This program is part of libvserver %s\n\n", LIBVSERVER_VERSION); \ - \ - printf("Copyright (c) 2005 Benedikt Boehm \n"); \ - printf("This program is free software; you can redistribute it and/or\n"); \ - printf("modify it under the terms of the GNU General Public License\n"); \ - exit(0); - - -/* Constants */ -#define LIBVSERVER_VERSION "0.1" - -/* Type definitions */ -typedef uint32_t xid_t; -typedef uint32_t nid_t; - -/* context.c */ -extern int vc_task_xid(pid_t pid); -extern int vc_vx_info(xid_t xid, struct vcmd_vx_info_v0 *info); -extern int vc_ctx_create(xid_t xid); -extern int vc_ctx_migrate(xid_t xid); -extern int vc_get_cflags(xid_t xid, struct vcmd_ctx_flags_v0 *cflags); -extern int vc_set_cflags(xid_t xid, struct vcmd_ctx_flags_v0 *cflags); -extern int vc_get_ccaps(xid_t xid, struct vcmd_ctx_caps_v0 *ccaps); -extern int vc_set_ccaps(xid_t xid, struct vcmd_ctx_caps_v0 *ccaps); - -/* dlimit.c */ -extern int vc_add_dlimit(xid_t xid, struct vcmd_ctx_dlimit_base_v0 *dbase); -extern int vc_rem_dlimit(xid_t xid, struct vcmd_ctx_dlimit_base_v0 *dbase); -extern int vc_set_dlimit(xid_t xid, struct vcmd_ctx_dlimit_v0 *dlimit); -extern int vc_get_dlimit(xid_t xid, struct vcmd_ctx_dlimit_v0 *dlimit); - -/* inode.c */ -extern int vc_get_iattr_v0(struct vcmd_ctx_iattr_v1 *iattr); -extern int vc_set_iattr_v0(struct vcmd_ctx_iattr_v1 *iattr); -extern int vc_get_iattr(struct vcmd_ctx_iattr_v0 *iattr); -extern int vc_set_iattr(struct vcmd_ctx_iattr_v0 *iattr); - -/* limit.c */ -extern int vc_get_rlimit(xid_t xid, struct vcmd_ctx_rlimit_v0 *rlimit); -extern int vc_set_rlimit(xid_t xid, struct vcmd_ctx_rlimit_v0 *rlimit); -extern int vc_get_rlimit_mask(xid_t xid, struct vcmd_ctx_rlimit_mask_v0 *rmask); - -/* namespace.c */ -extern int vc_set_vhi_name(xid_t xid, struct vcmd_vx_vhi_name_v0 *vhiname); -extern int vc_get_vhi_name(xid_t xid, struct vcmd_vx_vhi_name_v0 *vhiname); -extern int vc_enter_namespace(xid_t xid); -extern int vc_cleanup_namespace(); -extern int vc_set_namespace(); - -/* network.c */ -extern int vc_task_nid(pid_t pid); -extern int vc_nx_info(nid_t nid, struct vcmd_nx_info_v0 *info); -extern int vc_net_create(nid_t nid); -extern int vc_net_migrate(nid_t nid); -extern int vc_net_add(nid_t nid, struct vcmd_net_nx_v0 *nx); -extern int vc_net_remove(nid_t nid, struct vcmd_net_nx_v0 *nx); -extern int vc_get_nflags(nid_t nid, struct vcmd_net_flags_v0 *flags); -extern int vc_set_nflags(nid_t nid, struct vcmd_net_flags_v0 *flags); -extern int vc_get_ncaps(nid_t nid, struct vcmd_net_caps_v0 *caps); -extern int vc_set_ncaps(nid_t nid, struct vcmd_net_caps_v0 *caps); +#include -/* sched.c */ -extern int vc_set_sched_v2(xid_t xid, struct vcmd_set_sched_v2 *sched); -extern int vc_set_sched(xid_t xid, struct vcmd_set_sched_v3 *sched); +#include "syscall.h" -/* signal.c */ -extern int vc_ctx_kill(xid_t xid, struct vcmd_ctx_kill_v0 *kill); -extern int vc_wait_exit(xid_t xid, struct vcmd_wait_exit_v0 *wait); +#if defined(__alpha__) +#define __NR_vserver 428 +#elif defined(__arm__) +#define __NR_vserver 313 +#elif defined(__cris__) +#define __NR_vserver 273 +#elif defined(__frv__) +#define __NR_vserver 273 +#elif defined(__h8300__) +#define __NR_vserver 273 +#elif defined(__i386__) +#define __NR_vserver 273 +#elif defined(__ia64__) +#define __NR_vserver 1269 +#elif defined(__m32r__) +#define __NR_vserver __m32r_NR_vserver +#elif defined(__mc68000__) +#define __NR_vserver 278 +#elif defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI32) +#define __NR_vserver 277 +#elif defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI64) +#define __NR_vserver 240 +#elif defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_NABI32) +#define __NR_vserver 236 +#elif defined(__hppa__) +#define __NR_vserver __hppa_NR_vserver +#elif defined(__powerpc__) +#define __NR_vserver 257 +#elif defined(__s390__) +#define __NR_vserver 263 +#elif defined(__sh__) +#define __NR_vserver 273 +#elif defined(__sparc__) +#define __NR_vserver 267 +#elif defined(__v850__) +#define __NR_vserver __v850_NR_vserver +#elif defined(__x86_64__) +#define __NR_vserver 236 +#endif -/* switch.c */ -extern int vc_get_version(); +static inline +_syscall3(int, vserver, uint32_t, cmd, uint32_t, id, void *, data); + diff -NurpP --minimal libvserver-0.1/Makefile.am libvserver-0.1.1/Makefile.am --- libvserver-0.1/Makefile.am 2005-06-23 02:16:45.000000000 +0200 +++ libvserver-0.1.1/Makefile.am 2005-07-01 19:01:26.000000000 +0200 @@ -3,3 +3,6 @@ AUTOMAKE_OPTIONS = foreign 1.4 SUBDIRS = lib tools + +vserver_HEADERS = kernel/* +vserverdir = $(includedir)/linux/vserver diff -NurpP --minimal libvserver-0.1/Makefile.in libvserver-0.1.1/Makefile.in --- libvserver-0.1/Makefile.in 2005-06-30 15:13:21.000000000 +0200 +++ libvserver-0.1.1/Makefile.in 2005-07-01 19:01:41.000000000 +0200 @@ -13,6 +13,7 @@ # PARTICULAR PURPOSE. @SET_MAKE@ + srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ @@ -37,9 +38,9 @@ build_triplet = @build@ host_triplet = @host@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ - $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ - TODO config.guess config.sub depcomp install-sh ltmain.sh \ - missing mkinstalldirs + $(top_srcdir)/configure $(vserver_HEADERS) AUTHORS COPYING \ + ChangeLog INSTALL NEWS TODO config.guess config.sub depcomp \ + install-sh ltmain.sh missing mkinstalldirs subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in @@ -58,6 +59,15 @@ RECURSIVE_TARGETS = all-recursive check- install-recursive installcheck-recursive installdirs-recursive \ pdf-recursive ps-recursive uninstall-info-recursive \ uninstall-recursive +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(vserverdir)" +vserverHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(vserver_HEADERS) ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) @@ -173,6 +183,8 @@ target_alias = @target_alias@ # have all needed files, that a GNU package needs AUTOMAKE_OPTIONS = foreign 1.4 SUBDIRS = lib tools +vserver_HEADERS = kernel/* +vserverdir = $(includedir)/linux/vserver all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -237,6 +249,23 @@ clean-libtool: distclean-libtool: -rm -f libtool uninstall-info-am: +install-vserverHEADERS: $(vserver_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(vserverdir)" || $(mkdir_p) "$(DESTDIR)$(vserverdir)" + @list='$(vserver_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(vserverHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(vserverdir)/$$f'"; \ + $(vserverHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(vserverdir)/$$f"; \ + done + +uninstall-vserverHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(vserver_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(vserverdir)/$$f'"; \ + rm -f "$(DESTDIR)$(vserverdir)/$$f"; \ + done # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. @@ -373,6 +402,7 @@ distclean-tags: distdir: $(DISTFILES) $(am__remove_distdir) mkdir $(distdir) + $(mkdir_p) $(distdir)/kernel @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ @@ -513,9 +543,12 @@ distcleancheck: distclean exit 1; } >&2 check-am: all-am check: check-recursive -all-am: Makefile config.h +all-am: Makefile $(HEADERS) config.h installdirs: installdirs-recursive installdirs-am: + for dir in "$(DESTDIR)$(vserverdir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive @@ -560,7 +593,7 @@ info: info-recursive info-am: -install-data-am: +install-data-am: install-vserverHEADERS install-exec-am: @@ -588,7 +621,7 @@ ps: ps-recursive ps-am: -uninstall-am: uninstall-info-am +uninstall-am: uninstall-info-am uninstall-vserverHEADERS uninstall-info: uninstall-info-recursive @@ -601,11 +634,13 @@ uninstall-info: uninstall-info-recursive distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-exec \ install-exec-am install-info install-info-am install-man \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - maintainer-clean-recursive mostlyclean mostlyclean-generic \ - mostlyclean-libtool mostlyclean-recursive pdf pdf-am ps ps-am \ - tags tags-recursive uninstall uninstall-am uninstall-info-am + install-strip install-vserverHEADERS installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive \ + mostlyclean mostlyclean-generic mostlyclean-libtool \ + mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am uninstall-info-am \ + uninstall-vserverHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff -NurpP --minimal libvserver-0.1/tools/vcontext.c libvserver-0.1.1/tools/vcontext.c --- libvserver-0.1/tools/vcontext.c 2005-06-30 14:34:17.000000000 +0200 +++ libvserver-0.1.1/tools/vcontext.c 2005-07-01 11:03:47.000000000 +0200 @@ -24,7 +24,7 @@ #include -#include "vserver.h" +#include "libvserver.h" #include "tools.h" #define NAME "vcontext" diff -NurpP --minimal libvserver-0.1/tools/vdlimit.c libvserver-0.1.1/tools/vdlimit.c --- libvserver-0.1/tools/vdlimit.c 2005-06-30 14:34:08.000000000 +0200 +++ libvserver-0.1.1/tools/vdlimit.c 2005-07-01 11:03:52.000000000 +0200 @@ -25,7 +25,7 @@ #include #include -#include "vserver.h" +#include "libvserver.h" #include "tools.h" #define NAME "vdlimit" diff -NurpP --minimal libvserver-0.1/tools/vinfo.c libvserver-0.1.1/tools/vinfo.c --- libvserver-0.1/tools/vinfo.c 2005-06-30 14:49:48.000000000 +0200 +++ libvserver-0.1.1/tools/vinfo.c 2005-07-01 11:03:57.000000000 +0200 @@ -24,7 +24,7 @@ #include -#include "vserver.h" +#include "libvserver.h" #include "tools.h" #define NAME "vinfo" diff -NurpP --minimal libvserver-0.1/tools/vinode.c libvserver-0.1.1/tools/vinode.c --- libvserver-0.1/tools/vinode.c 2005-06-30 14:49:26.000000000 +0200 +++ libvserver-0.1.1/tools/vinode.c 2005-07-01 11:04:01.000000000 +0200 @@ -24,7 +24,7 @@ #include -#include "vserver.h" +#include "libvserver.h" #include "tools.h" #define NAME "vinode" diff -NurpP --minimal libvserver-0.1/tools/vlimit.c libvserver-0.1.1/tools/vlimit.c --- libvserver-0.1/tools/vlimit.c 2005-06-30 14:48:13.000000000 +0200 +++ libvserver-0.1.1/tools/vlimit.c 2005-07-01 11:04:05.000000000 +0200 @@ -24,7 +24,7 @@ #include -#include "vserver.h" +#include "libvserver.h" #include "tools.h" #define NAME "vlimit" diff -NurpP --minimal libvserver-0.1/tools/vnamespace.c libvserver-0.1.1/tools/vnamespace.c --- libvserver-0.1/tools/vnamespace.c 2005-06-30 14:34:29.000000000 +0200 +++ libvserver-0.1.1/tools/vnamespace.c 2005-07-01 11:04:10.000000000 +0200 @@ -24,7 +24,7 @@ #include -#include "vserver.h" +#include "libvserver.h" #include "tools.h" #define NAME "vnamespace" diff -NurpP --minimal libvserver-0.1/tools/vnetwork.c libvserver-0.1.1/tools/vnetwork.c --- libvserver-0.1/tools/vnetwork.c 2005-06-30 14:48:59.000000000 +0200 +++ libvserver-0.1.1/tools/vnetwork.c 2005-07-01 11:04:15.000000000 +0200 @@ -24,7 +24,7 @@ #include -#include "vserver.h" +#include "libvserver.h" #include "tools.h" #define NAME "vnetwork" diff -NurpP --minimal libvserver-0.1/tools/vsched.c libvserver-0.1.1/tools/vsched.c --- libvserver-0.1/tools/vsched.c 2005-06-30 09:15:31.000000000 +0200 +++ libvserver-0.1.1/tools/vsched.c 2005-07-01 11:04:20.000000000 +0200 @@ -24,7 +24,7 @@ #include -#include "vserver.h" +#include "libvserver.h" #include "tools.h" #define NAME "vsched" diff -NurpP --minimal libvserver-0.1/tools/vsignal.c libvserver-0.1.1/tools/vsignal.c --- libvserver-0.1/tools/vsignal.c 2005-06-30 03:04:46.000000000 +0200 +++ libvserver-0.1.1/tools/vsignal.c 2005-07-01 11:04:27.000000000 +0200 @@ -25,7 +25,7 @@ #include #include -#include "vserver.h" +#include "libvserver.h" #include "tools.h" #define NAME "vsignal"