1 diff -NurpP --minimal linux-2.6.22.10/Documentation/vserver/debug.txt linux-2.6.22.10-vs2.2.0.5/Documentation/vserver/debug.txt
2 --- linux-2.6.22.10/Documentation/vserver/debug.txt 1970-01-01 01:00:00 +0100
3 +++ linux-2.6.22.10-vs2.2.0.5/Documentation/vserver/debug.txt 2007-06-15 02:37:02 +0200
8 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
9 + "vx_rmap_tgid: %p/%llx: %d -> %d"
13 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
14 + "FREE (%p,#%d)%c inode"
15 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
16 + "FREE (%p,#%d)%c %lld bytes"
17 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
18 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
19 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
20 + "rcu_free_dl_info(%p)"
21 + 4 10 "alloc_dl_info(%p,%d) = %p"
22 + "dealloc_dl_info(%p)"
23 + "get_dl_info(%p[#%d.%d])"
24 + "put_dl_info(%p[#%d.%d])"
25 + 5 20 "alloc_dl_info(%p,%d)*"
26 + 6 40 "__hash_dl_info: %p[#%d]"
27 + "__unhash_dl_info: %p[#%d]"
28 + 7 80 "locate_dl_info(%p,#%d) = %p"
32 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
33 + "new_dqhash: %p [#0x%08x]"
34 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
35 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
36 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
37 + "vroot_get_real_bdev not set"
38 + 1 2 "cow_break_link(»%s«)"
40 + 2 4 "dentry_open(new): %p"
41 + "dentry_open(old): %p"
42 + "lookup_create(new): %p"
44 + "path_lookup(old): %d"
45 + "vfs_create(new): %d"
48 + 3 8 "fput(new_file=%p[#%d])"
49 + "fput(old_file=%p[#%d])"
50 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
51 + "vx_info_kill(%p[#%d],%d,%d)*"
52 + 5 20 "vs_reboot(%p[#%d],%d)"
53 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
57 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
58 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
59 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
60 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
61 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
62 + 6 40 "sk,egf: %p [#%d] (from %d)"
63 + "sk,egn: %p [#%d] (from %d)"
64 + "sk,req: %p [#%d] (from %d)"
65 + "sk: %p [#%d] (from %d)"
66 + "tw: %p [#%d] (from %d)"
67 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
68 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
72 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
73 + "alloc_nx_info(%d) = %p"
74 + "create_nx_info(%d) (dynamic rejected)"
75 + "create_nx_info(%d) = %p (already there)"
76 + "create_nx_info(%d) = %p (new)"
77 + "dealloc_nx_info(%p)"
78 + 1 2 "alloc_nx_info(%d)*"
79 + "create_nx_info(%d)*"
80 + 2 4 "get_nx_info(%p[#%d.%d])"
81 + "put_nx_info(%p[#%d.%d])"
82 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
83 + "clr_nx_info(%p[#%d.%d])"
84 + "init_nx_info(%p[#%d.%d])"
85 + "release_nx_info(%p[#%d.%d.%d]) %p"
86 + "set_nx_info(%p[#%d.%d])"
87 + 4 10 "__hash_nx_info: %p[#%d]"
88 + "__nx_dynamic_id: [#%d]"
89 + "__unhash_nx_info: %p[#%d.%d.%d]"
90 + 5 20 "moved task %p into nxi:%p[#%d]"
91 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
92 + "task_get_nx_info(%p)"
93 + 6 40 "nx_clear_persistent(%p[#%d])"
97 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
98 + 1 2 "quota_sync_dqh(%p,%d)"
99 + "sync_dquots(%p,%d)"
100 + "sync_dquots_dqh(%p,%d)"
101 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
105 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
106 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
107 + 4 10 "%s: (%s %s) returned %s with %d"
111 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
112 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
116 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
117 + "alloc_vx_info(%d) = %p"
118 + "alloc_vx_info(%d)*"
119 + "create_vx_info(%d) (dynamic rejected)"
120 + "create_vx_info(%d) = %p (already there)"
121 + "create_vx_info(%d) = %p (new)"
122 + "dealloc_vx_info(%p)"
123 + "loc_vx_info(%d) = %p (found)"
124 + "loc_vx_info(%d) = %p (new)"
125 + "loc_vx_info(%d) = %p (not available)"
126 + 1 2 "create_vx_info(%d)*"
128 + 2 4 "get_vx_info(%p[#%d.%d])"
129 + "put_vx_info(%p[#%d.%d])"
130 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
131 + "clr_vx_info(%p[#%d.%d])"
132 + "init_vx_info(%p[#%d.%d])"
133 + "release_vx_info(%p[#%d.%d.%d]) %p"
134 + "set_vx_info(%p[#%d.%d])"
135 + 4 10 "__hash_vx_info: %p[#%d]"
136 + "__unhash_vx_info: %p[#%d.%d.%d]"
137 + "__vx_dynamic_id: [#%d]"
138 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
139 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
140 + "moved task %p into vxi:%p[#%d]"
141 + "task_get_vx_info(%p)"
142 + "vx_migrate_task(%p,%p[#%d.%d])"
143 + 6 40 "vx_clear_persistent(%p[#%d])"
144 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
145 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
146 + "vx_set_persistent(%p[#%d])"
147 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
148 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
153 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
154 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
156 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
157 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
158 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
159 diff -NurpP --minimal linux-2.6.22.10/Makefile linux-2.6.22.10-vs2.2.0.5/Makefile
160 --- linux-2.6.22.10/Makefile 2007-10-30 01:57:11 +0100
161 +++ linux-2.6.22.10-vs2.2.0.5/Makefile 2007-10-30 02:42:06 +0100
167 +EXTRAVERSION = .12-vs2.2.0.5
168 NAME = Holy Dancing Manatees, Batman!
171 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/alpha/Kconfig
172 --- linux-2.6.22.10/arch/alpha/Kconfig 2007-07-09 13:17:31 +0200
173 +++ linux-2.6.22.10-vs2.2.0.5/arch/alpha/Kconfig 2007-06-15 02:37:02 +0200
174 @@ -662,6 +662,8 @@ config DUMMY_CONSOLE
178 +source "kernel/vserver/Kconfig"
180 source "security/Kconfig"
182 source "crypto/Kconfig"
183 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/asm-offsets.c linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/asm-offsets.c
184 --- linux-2.6.22.10/arch/alpha/kernel/asm-offsets.c 2006-02-15 13:54:10 +0100
185 +++ linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/asm-offsets.c 2007-06-15 02:37:02 +0200
186 @@ -36,6 +36,7 @@ void foo(void)
187 DEFINE(PT_PTRACED, PT_PTRACED);
188 DEFINE(CLONE_VM, CLONE_VM);
189 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
190 + DEFINE(CLONE_KTHREAD, CLONE_KTHREAD);
191 DEFINE(SIGCHLD, SIGCHLD);
194 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/entry.S linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/entry.S
195 --- linux-2.6.22.10/arch/alpha/kernel/entry.S 2007-07-09 13:17:31 +0200
196 +++ linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/entry.S 2007-06-15 02:37:02 +0200
197 @@ -643,7 +643,7 @@ kernel_thread:
198 stq $2, 152($sp) /* HAE */
200 /* Shuffle FLAGS to the front; add CLONE_VM. */
201 - ldi $1, CLONE_VM|CLONE_UNTRACED
202 + ldi $1, CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD;
206 @@ -872,24 +872,15 @@ sys_getxgid:
213 - ldq $2, TI_TASK($8)
215 - /* See linux/kernel/timer.c sys_getppid for discussion
216 - about this loop. */
217 - ldq $3, TASK_GROUP_LEADER($2)
218 - ldq $4, TASK_REAL_PARENT($3)
219 - ldl $0, TASK_TGID($2)
220 -1: ldl $1, TASK_TGID($4)
224 - ldq $3, TASK_GROUP_LEADER($2)
225 - ldq $4, TASK_REAL_PARENT($3)
231 + jsr $26, do_getxpid
238 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/osf_sys.c linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/osf_sys.c
239 --- linux-2.6.22.10/arch/alpha/kernel/osf_sys.c 2007-07-09 13:17:31 +0200
240 +++ linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/osf_sys.c 2007-06-15 02:37:02 +0200
241 @@ -883,7 +883,7 @@ osf_gettimeofday(struct timeval32 __user
245 - do_gettimeofday(&ktv);
246 + vx_gettimeofday(&ktv);
247 if (put_tv32(tv, &ktv))
250 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/ptrace.c linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/ptrace.c
251 --- linux-2.6.22.10/arch/alpha/kernel/ptrace.c 2006-04-09 13:49:39 +0200
252 +++ linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/ptrace.c 2007-06-15 02:37:02 +0200
254 #include <linux/slab.h>
255 #include <linux/security.h>
256 #include <linux/signal.h>
257 +#include <linux/vs_base.h>
259 #include <asm/uaccess.h>
260 #include <asm/pgtable.h>
261 @@ -283,6 +284,11 @@ do_sys_ptrace(long request, long pid, lo
265 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
270 if (request == PTRACE_ATTACH) {
271 ret = ptrace_attach(child);
273 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/semaphore.c linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/semaphore.c
274 --- linux-2.6.22.10/arch/alpha/kernel/semaphore.c 2004-08-14 12:55:32 +0200
275 +++ linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/semaphore.c 2007-06-15 02:37:02 +0200
276 @@ -68,8 +68,8 @@ __down_failed(struct semaphore *sem)
277 DECLARE_WAITQUEUE(wait, tsk);
279 #ifdef CONFIG_DEBUG_SEMAPHORE
280 - printk("%s(%d): down failed(%p)\n",
281 - tsk->comm, tsk->pid, sem);
282 + printk("%s(%d:#%u): down failed(%p)\n",
283 + tsk->comm, tsk->pid, tsk->xid, sem);
286 tsk->state = TASK_UNINTERRUPTIBLE;
287 @@ -97,8 +97,8 @@ __down_failed(struct semaphore *sem)
290 #ifdef CONFIG_DEBUG_SEMAPHORE
291 - printk("%s(%d): down acquired(%p)\n",
292 - tsk->comm, tsk->pid, sem);
293 + printk("%s(%d:#%u): down acquired(%p)\n",
294 + tsk->comm, tsk->pid, tsk->xid, sem);
298 @@ -110,8 +110,8 @@ __down_failed_interruptible(struct semap
301 #ifdef CONFIG_DEBUG_SEMAPHORE
302 - printk("%s(%d): down failed(%p)\n",
303 - tsk->comm, tsk->pid, sem);
304 + printk("%s(%d:#%u): down failed(%p)\n",
305 + tsk->comm, tsk->pid, tsk->xid, sem);
308 tsk->state = TASK_INTERRUPTIBLE;
309 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/systbls.S linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/systbls.S
310 --- linux-2.6.22.10/arch/alpha/kernel/systbls.S 2007-07-09 13:17:31 +0200
311 +++ linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/systbls.S 2007-06-15 02:37:02 +0200
312 @@ -446,7 +446,7 @@ sys_call_table:
313 .quad sys_stat64 /* 425 */
316 - .quad sys_ni_syscall /* sys_vserver */
317 + .quad sys_vserver /* sys_vserver */
318 .quad sys_ni_syscall /* sys_mbind */
319 .quad sys_ni_syscall /* sys_get_mempolicy */
320 .quad sys_ni_syscall /* sys_set_mempolicy */
321 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/traps.c
322 --- linux-2.6.22.10/arch/alpha/kernel/traps.c 2006-09-20 16:57:57 +0200
323 +++ linux-2.6.22.10-vs2.2.0.5/arch/alpha/kernel/traps.c 2007-06-15 02:37:02 +0200
324 @@ -182,7 +182,8 @@ die_if_kernel(char * str, struct pt_regs
326 printk("CPU %d ", hard_smp_processor_id());
328 - printk("%s(%d): %s %ld\n", current->comm, current->pid, str, err);
329 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
330 + current->pid, current->xid, str, err);
331 dik_show_regs(regs, r9_15);
332 dik_show_trace((unsigned long *)(regs+1));
333 dik_show_code((unsigned int *)regs->pc);
334 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/alpha/mm/fault.c
335 --- linux-2.6.22.10/arch/alpha/mm/fault.c 2007-07-09 13:17:32 +0200
336 +++ linux-2.6.22.10-vs2.2.0.5/arch/alpha/mm/fault.c 2007-06-15 02:37:02 +0200
337 @@ -197,8 +197,8 @@ do_page_fault(unsigned long address, uns
338 down_read(&mm->mmap_sem);
341 - printk(KERN_ALERT "VM: killing process %s(%d)\n",
342 - current->comm, current->pid);
343 + printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
344 + current->comm, current->pid, current->xid);
345 if (!user_mode(regs))
348 diff -NurpP --minimal linux-2.6.22.10/arch/arm/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/arm/Kconfig
349 --- linux-2.6.22.10/arch/arm/Kconfig 2007-07-09 13:17:32 +0200
350 +++ linux-2.6.22.10-vs2.2.0.5/arch/arm/Kconfig 2007-06-15 02:37:02 +0200
351 @@ -1042,6 +1042,8 @@ source "arch/arm/oprofile/Kconfig"
353 source "arch/arm/Kconfig.debug"
355 +source "kernel/vserver/Kconfig"
357 source "security/Kconfig"
359 source "crypto/Kconfig"
360 diff -NurpP --minimal linux-2.6.22.10/arch/arm/kernel/calls.S linux-2.6.22.10-vs2.2.0.5/arch/arm/kernel/calls.S
361 --- linux-2.6.22.10/arch/arm/kernel/calls.S 2007-07-09 13:17:32 +0200
362 +++ linux-2.6.22.10-vs2.2.0.5/arch/arm/kernel/calls.S 2007-07-07 03:52:53 +0200
364 /* 310 */ CALL(sys_request_key)
366 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
367 -/* vserver */ CALL(sys_ni_syscall)
370 /* 315 */ CALL(sys_ioprio_get)
371 CALL(sys_inotify_init)
372 diff -NurpP --minimal linux-2.6.22.10/arch/arm/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/arm/kernel/process.c
373 --- linux-2.6.22.10/arch/arm/kernel/process.c 2007-07-09 13:17:32 +0200
374 +++ linux-2.6.22.10-vs2.2.0.5/arch/arm/kernel/process.c 2007-07-07 03:52:53 +0200
375 @@ -261,7 +261,8 @@ void __show_regs(struct pt_regs *regs)
376 void show_regs(struct pt_regs * regs)
379 - printk("Pid: %d, comm: %20s\n", current->pid, current->comm);
380 + printk("Pid: %d[#%u], comm: %20s\n",
381 + current->pid, current->xid, current->comm);
385 @@ -423,7 +424,8 @@ pid_t kernel_thread(int (*fn)(void *), v
386 regs.ARM_pc = (unsigned long)kernel_thread_helper;
387 regs.ARM_cpsr = SVC_MODE;
389 - return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
390 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
391 + 0, ®s, 0, NULL, NULL);
393 EXPORT_SYMBOL(kernel_thread);
395 diff -NurpP --minimal linux-2.6.22.10/arch/arm/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/arm/kernel/traps.c
396 --- linux-2.6.22.10/arch/arm/kernel/traps.c 2007-07-09 13:17:32 +0200
397 +++ linux-2.6.22.10-vs2.2.0.5/arch/arm/kernel/traps.c 2007-07-09 13:11:53 +0200
398 @@ -222,8 +222,8 @@ static void __die(const char *str, int e
399 str, err, ++die_counter);
402 - printk("Process %s (pid: %d, stack limit = 0x%p)\n",
403 - tsk->comm, tsk->pid, thread + 1);
404 + printk("Process %s (pid: %d:#%u, stack limit = 0x%p)\n",
405 + tsk->comm, tsk->pid, tsk->xid, thread + 1);
407 if (!user_mode(regs) || in_interrupt()) {
408 dump_mem("Stack: ", regs->ARM_sp,
409 diff -NurpP --minimal linux-2.6.22.10/arch/arm/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/arm/mm/fault.c
410 --- linux-2.6.22.10/arch/arm/mm/fault.c 2007-07-09 13:17:39 +0200
411 +++ linux-2.6.22.10-vs2.2.0.5/arch/arm/mm/fault.c 2007-06-15 02:37:02 +0200
412 @@ -266,7 +266,8 @@ do_page_fault(unsigned long addr, unsign
413 * happened to us that made us unable to handle
414 * the page fault gracefully.
416 - printk("VM: killing process %s\n", tsk->comm);
417 + printk("VM: killing process %s(%d:#%u)\n",
418 + tsk->comm, tsk->pid, tsk->xid);
422 diff -NurpP --minimal linux-2.6.22.10/arch/arm26/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/arm26/Kconfig
423 --- linux-2.6.22.10/arch/arm26/Kconfig 2007-07-09 13:17:40 +0200
424 +++ linux-2.6.22.10-vs2.2.0.5/arch/arm26/Kconfig 2007-06-15 02:37:02 +0200
425 @@ -243,6 +243,8 @@ source "drivers/usb/Kconfig"
427 source "arch/arm26/Kconfig.debug"
429 +source "kernel/vserver/Kconfig"
431 source "security/Kconfig"
433 source "crypto/Kconfig"
434 diff -NurpP --minimal linux-2.6.22.10/arch/arm26/kernel/calls.S linux-2.6.22.10-vs2.2.0.5/arch/arm26/kernel/calls.S
435 --- linux-2.6.22.10/arch/arm26/kernel/calls.S 2005-03-02 12:38:19 +0100
436 +++ linux-2.6.22.10-vs2.2.0.5/arch/arm26/kernel/calls.S 2007-06-15 02:37:02 +0200
437 @@ -257,6 +257,11 @@ __syscall_start:
438 .long sys_lremovexattr
439 .long sys_fremovexattr
442 + .rept 313 - (. - __syscall_start) / 4
443 + .long sys_ni_syscall
445 + .long sys_vserver /* 313 */
448 .rept NR_syscalls - (__syscall_end - __syscall_start) / 4
449 diff -NurpP --minimal linux-2.6.22.10/arch/arm26/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/arm26/kernel/process.c
450 --- linux-2.6.22.10/arch/arm26/kernel/process.c 2006-09-20 16:57:57 +0200
451 +++ linux-2.6.22.10-vs2.2.0.5/arch/arm26/kernel/process.c 2007-06-15 02:37:02 +0200
452 @@ -365,7 +365,8 @@ pid_t kernel_thread(int (*fn)(void *), v
453 regs.ARM_r3 = (unsigned long)do_exit;
454 regs.ARM_pc = (unsigned long)kernel_thread_helper | MODE_SVC26;
456 - return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
457 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
458 + 0, ®s, 0, NULL, NULL);
460 EXPORT_SYMBOL(kernel_thread);
462 diff -NurpP --minimal linux-2.6.22.10/arch/arm26/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/arm26/kernel/traps.c
463 --- linux-2.6.22.10/arch/arm26/kernel/traps.c 2006-09-20 16:57:57 +0200
464 +++ linux-2.6.22.10-vs2.2.0.5/arch/arm26/kernel/traps.c 2007-06-15 02:37:02 +0200
465 @@ -185,8 +185,9 @@ NORET_TYPE void die(const char *str, str
466 printk("Internal error: %s: %x\n", str, err);
467 printk("CPU: %d\n", smp_processor_id());
469 - printk("Process %s (pid: %d, stack limit = 0x%p)\n",
470 - current->comm, current->pid, end_of_stack(tsk));
471 + printk("Process %s (pid: %d[#%u], stack limit = 0x%p)\n",
472 + current->comm, current->pid,
473 + current->xid, end_of_stack(tsk));
475 if (!user_mode(regs) || in_interrupt()) {
476 __dump_stack(tsk, (unsigned long)(regs + 1));
477 diff -NurpP --minimal linux-2.6.22.10/arch/cris/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/cris/Kconfig
478 --- linux-2.6.22.10/arch/cris/Kconfig 2007-05-02 19:24:19 +0200
479 +++ linux-2.6.22.10-vs2.2.0.5/arch/cris/Kconfig 2007-06-15 02:37:02 +0200
480 @@ -200,6 +200,8 @@ source "drivers/usb/Kconfig"
482 source "arch/cris/Kconfig.debug"
484 +source "kernel/vserver/Kconfig"
486 source "security/Kconfig"
488 source "crypto/Kconfig"
489 diff -NurpP --minimal linux-2.6.22.10/arch/cris/arch-v10/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/cris/arch-v10/kernel/process.c
490 --- linux-2.6.22.10/arch/cris/arch-v10/kernel/process.c 2006-09-20 16:57:57 +0200
491 +++ linux-2.6.22.10-vs2.2.0.5/arch/cris/arch-v10/kernel/process.c 2007-06-15 02:37:02 +0200
492 @@ -103,7 +103,8 @@ int kernel_thread(int (*fn)(void *), voi
493 regs.dccr = 1 << I_DCCR_BITNR;
495 /* Ok, create the new process.. */
496 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
497 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
498 + 0, ®s, 0, NULL, NULL);
501 /* setup the child's kernel stack with a pt_regs and switch_stack on it.
502 diff -NurpP --minimal linux-2.6.22.10/arch/cris/arch-v32/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/cris/arch-v32/kernel/process.c
503 --- linux-2.6.22.10/arch/cris/arch-v32/kernel/process.c 2006-09-20 16:57:57 +0200
504 +++ linux-2.6.22.10-vs2.2.0.5/arch/cris/arch-v32/kernel/process.c 2007-06-15 02:37:02 +0200
505 @@ -120,7 +120,8 @@ kernel_thread(int (*fn)(void *), void *
506 regs.ccs = 1 << (I_CCS_BITNR + CCS_SHIFT);
508 /* Create the new process. */
509 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
510 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
511 + 0, ®s, 0, NULL, NULL);
515 diff -NurpP --minimal linux-2.6.22.10/arch/frv/kernel/kernel_thread.S linux-2.6.22.10-vs2.2.0.5/arch/frv/kernel/kernel_thread.S
516 --- linux-2.6.22.10/arch/frv/kernel/kernel_thread.S 2005-03-02 12:38:20 +0100
517 +++ linux-2.6.22.10-vs2.2.0.5/arch/frv/kernel/kernel_thread.S 2007-06-15 02:37:02 +0200
519 #include <asm/unistd.h>
521 #define CLONE_VM 0x00000100 /* set if VM shared between processes */
522 +#define CLONE_KTHREAD 0x10000000 /* kernel thread */
523 +#define CLONE_KT (CLONE_VM | CLONE_KTHREAD) /* kernel thread flags */
524 #define KERN_ERR "<3>"
527 @@ -37,7 +39,7 @@ kernel_thread:
529 # start by forking the current process, but with shared VM
530 setlos.p #__NR_clone,gr7 ; syscall number
531 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
532 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
533 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
535 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
536 diff -NurpP --minimal linux-2.6.22.10/arch/h8300/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/h8300/Kconfig
537 --- linux-2.6.22.10/arch/h8300/Kconfig 2007-07-09 13:17:41 +0200
538 +++ linux-2.6.22.10-vs2.2.0.5/arch/h8300/Kconfig 2007-06-15 02:37:02 +0200
539 @@ -222,6 +222,8 @@ source "fs/Kconfig"
541 source "arch/h8300/Kconfig.debug"
543 +source "kernel/vserver/Kconfig"
545 source "security/Kconfig"
547 source "crypto/Kconfig"
548 diff -NurpP --minimal linux-2.6.22.10/arch/h8300/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/h8300/kernel/process.c
549 --- linux-2.6.22.10/arch/h8300/kernel/process.c 2006-09-20 16:57:58 +0200
550 +++ linux-2.6.22.10-vs2.2.0.5/arch/h8300/kernel/process.c 2007-06-15 02:37:03 +0200
551 @@ -134,7 +134,7 @@ int kernel_thread(int (*fn)(void *), voi
555 - clone_arg = flags | CLONE_VM;
556 + clone_arg = flags | CLONE_VM | CLONE_KTHREAD;
557 __asm__("mov.l sp,er3\n\t"
560 diff -NurpP --minimal linux-2.6.22.10/arch/i386/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/i386/Kconfig
561 --- linux-2.6.22.10/arch/i386/Kconfig 2007-07-09 13:17:41 +0200
562 +++ linux-2.6.22.10-vs2.2.0.5/arch/i386/Kconfig 2007-07-09 13:11:53 +0200
563 @@ -1230,6 +1230,8 @@ endmenu
565 source "arch/i386/Kconfig.debug"
567 +source "kernel/vserver/Kconfig"
569 source "security/Kconfig"
571 source "crypto/Kconfig"
572 diff -NurpP --minimal linux-2.6.22.10/arch/i386/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/i386/kernel/process.c
573 --- linux-2.6.22.10/arch/i386/kernel/process.c 2007-07-09 13:17:42 +0200
574 +++ linux-2.6.22.10-vs2.2.0.5/arch/i386/kernel/process.c 2007-06-15 02:37:03 +0200
575 @@ -302,8 +302,10 @@ void show_regs(struct pt_regs * regs)
576 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
579 - printk("Pid: %d, comm: %20s\n", current->pid, current->comm);
580 - printk("EIP: %04x:[<%08lx>] CPU: %d\n",0xffff & regs->xcs,regs->eip, smp_processor_id());
581 + printk("Pid: %d[#%u], comm: %20s\n",
582 + current->pid, current->xid, current->comm);
583 + printk("EIP: %04x:[<%08lx>] CPU: %d\n",
584 + 0xffff & regs->xcs,regs->eip, smp_processor_id());
585 print_symbol("EIP is at %s\n", regs->eip);
587 if (user_mode_vm(regs))
588 @@ -355,7 +357,8 @@ int kernel_thread(int (*fn)(void *), voi
589 regs.eflags = X86_EFLAGS_IF | X86_EFLAGS_SF | X86_EFLAGS_PF | 0x2;
591 /* Ok, create the new process.. */
592 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
593 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
594 + 0, ®s, 0, NULL, NULL);
596 EXPORT_SYMBOL(kernel_thread);
598 diff -NurpP --minimal linux-2.6.22.10/arch/i386/kernel/syscall_table.S linux-2.6.22.10-vs2.2.0.5/arch/i386/kernel/syscall_table.S
599 --- linux-2.6.22.10/arch/i386/kernel/syscall_table.S 2007-07-09 13:17:42 +0200
600 +++ linux-2.6.22.10-vs2.2.0.5/arch/i386/kernel/syscall_table.S 2007-06-15 02:37:03 +0200
601 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
602 .long sys_tgkill /* 270 */
604 .long sys_fadvise64_64
605 - .long sys_ni_syscall /* sys_vserver */
608 .long sys_get_mempolicy
609 .long sys_set_mempolicy
610 diff -NurpP --minimal linux-2.6.22.10/arch/i386/kernel/sysenter.c linux-2.6.22.10-vs2.2.0.5/arch/i386/kernel/sysenter.c
611 --- linux-2.6.22.10/arch/i386/kernel/sysenter.c 2007-10-30 01:57:12 +0100
612 +++ linux-2.6.22.10-vs2.2.0.5/arch/i386/kernel/sysenter.c 2007-09-05 03:05:52 +0200
614 #include <linux/elf.h>
615 #include <linux/mm.h>
616 #include <linux/module.h>
617 +#include <linux/vs_memory.h>
619 #include <asm/cpufeature.h>
621 diff -NurpP --minimal linux-2.6.22.10/arch/i386/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/i386/kernel/traps.c
622 --- linux-2.6.22.10/arch/i386/kernel/traps.c 2007-07-09 13:17:42 +0200
623 +++ linux-2.6.22.10-vs2.2.0.5/arch/i386/kernel/traps.c 2007-06-15 02:38:37 +0200
625 #include <asm/stacktrace.h>
627 #include <linux/module.h>
628 +#include <linux/vs_context.h>
629 +#include <linux/vserver/history.h>
631 #include "mach_traps.h"
633 @@ -303,8 +305,8 @@ void show_registers(struct pt_regs *regs
634 regs->esi, regs->edi, regs->ebp, esp);
635 printk(KERN_EMERG "ds: %04x es: %04x fs: %04x gs: %04x ss: %04x\n",
636 regs->xds & 0xffff, regs->xes & 0xffff, regs->xfs & 0xffff, gs, ss);
637 - printk(KERN_EMERG "Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)",
638 - TASK_COMM_LEN, current->comm, current->pid,
639 + printk(KERN_EMERG "Process %.*s (pid: %d[#%u], ti=%p task=%p task.ti=%p)",
640 + TASK_COMM_LEN, current->comm, current->pid, current->xid,
641 current_thread_info(), current, task_thread_info(current));
643 * When in-kernel, we also print out the stack and code at the
644 @@ -375,6 +377,8 @@ void die(const char * str, struct pt_reg
650 if (die.lock_owner != raw_smp_processor_id()) {
652 spin_lock_irqsave(&die.lock, flags);
653 @@ -412,9 +416,9 @@ void die(const char * str, struct pt_reg
656 if (notify_die(DIE_OOPS, str, regs, err,
657 - current->thread.trap_no, SIGSEGV) !=
659 + current->thread.trap_no, SIGSEGV) != NOTIFY_STOP) {
660 show_registers(regs);
661 + vxh_dump_history();
662 /* Executive summary in case the oops scrolled away */
663 esp = (unsigned long) (®s->esp);
665 diff -NurpP --minimal linux-2.6.22.10/arch/i386/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/i386/mm/fault.c
666 --- linux-2.6.22.10/arch/i386/mm/fault.c 2007-10-30 01:57:12 +0100
667 +++ linux-2.6.22.10-vs2.2.0.5/arch/i386/mm/fault.c 2007-09-05 03:05:52 +0200
668 @@ -587,7 +587,8 @@ out_of_memory:
669 down_read(&mm->mmap_sem);
672 - printk("VM: killing process %s\n", tsk->comm);
673 + printk("VM: killing process %s(%d:#%u)\n",
674 + tsk->comm, tsk->pid, tsk->xid);
678 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/ia64/Kconfig
679 --- linux-2.6.22.10/arch/ia64/Kconfig 2007-07-09 13:17:43 +0200
680 +++ linux-2.6.22.10-vs2.2.0.5/arch/ia64/Kconfig 2007-06-15 02:37:03 +0200
681 @@ -592,6 +592,8 @@ endmenu
683 source "arch/ia64/Kconfig.debug"
685 +source "kernel/vserver/Kconfig"
687 source "security/Kconfig"
689 source "crypto/Kconfig"
690 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/ia32/binfmt_elf32.c linux-2.6.22.10-vs2.2.0.5/arch/ia64/ia32/binfmt_elf32.c
691 --- linux-2.6.22.10/arch/ia64/ia32/binfmt_elf32.c 2007-05-02 19:24:20 +0200
692 +++ linux-2.6.22.10-vs2.2.0.5/arch/ia64/ia32/binfmt_elf32.c 2007-06-15 02:37:03 +0200
693 @@ -233,7 +233,8 @@ ia32_setup_arg_pages (struct linux_binpr
694 kmem_cache_free(vm_area_cachep, mpnt);
697 - current->mm->stack_vm = current->mm->total_vm = vma_pages(mpnt);
698 + vx_vmpages_sub(current->mm, current->mm->total_vm - vma_pages(mpnt));
699 + current->mm->stack_vm = current->mm->total_vm;
702 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
703 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/ia32/ia32_entry.S linux-2.6.22.10-vs2.2.0.5/arch/ia64/ia32/ia32_entry.S
704 --- linux-2.6.22.10/arch/ia64/ia32/ia32_entry.S 2007-07-09 13:17:43 +0200
705 +++ linux-2.6.22.10-vs2.2.0.5/arch/ia64/ia32/ia32_entry.S 2007-06-15 02:37:03 +0200
706 @@ -446,7 +446,7 @@ ia32_syscall_table:
707 data8 sys_tgkill /* 270 */
708 data8 compat_sys_utimes
709 data8 sys32_fadvise64_64
710 - data8 sys_ni_syscall
711 + data8 sys32_vserver
713 data8 sys_ni_syscall /* 275 */
715 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/ia32/sys_ia32.c linux-2.6.22.10-vs2.2.0.5/arch/ia64/ia32/sys_ia32.c
716 --- linux-2.6.22.10/arch/ia64/ia32/sys_ia32.c 2007-05-02 19:24:20 +0200
717 +++ linux-2.6.22.10-vs2.2.0.5/arch/ia64/ia32/sys_ia32.c 2007-06-15 02:37:03 +0200
718 @@ -1182,7 +1182,7 @@ sys32_gettimeofday (struct compat_timeva
722 - do_gettimeofday(&ktv);
723 + vx_gettimeofday(&ktv);
724 if (put_tv32(tv, &ktv))
727 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/kernel/asm-offsets.c linux-2.6.22.10-vs2.2.0.5/arch/ia64/kernel/asm-offsets.c
728 --- linux-2.6.22.10/arch/ia64/kernel/asm-offsets.c 2007-05-02 19:24:20 +0200
729 +++ linux-2.6.22.10-vs2.2.0.5/arch/ia64/kernel/asm-offsets.c 2007-06-15 02:37:03 +0200
730 @@ -192,6 +192,7 @@ void foo(void)
731 /* for assembly files which can't include sched.h: */
732 DEFINE(IA64_CLONE_VFORK, CLONE_VFORK);
733 DEFINE(IA64_CLONE_VM, CLONE_VM);
734 + DEFINE(IA64_CLONE_KTHREAD, CLONE_KTHREAD);
737 DEFINE(IA64_CPUINFO_NSEC_PER_CYC_OFFSET,
738 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/kernel/entry.S linux-2.6.22.10-vs2.2.0.5/arch/ia64/kernel/entry.S
739 --- linux-2.6.22.10/arch/ia64/kernel/entry.S 2007-07-09 13:17:43 +0200
740 +++ linux-2.6.22.10-vs2.2.0.5/arch/ia64/kernel/entry.S 2007-06-15 02:37:03 +0200
741 @@ -1547,7 +1547,7 @@ sys_call_table:
743 data8 sys_mq_getsetattr
745 - data8 sys_ni_syscall // reserved for vserver
747 data8 sys_waitid // 1270
749 data8 sys_request_key
750 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/kernel/perfmon.c linux-2.6.22.10-vs2.2.0.5/arch/ia64/kernel/perfmon.c
751 --- linux-2.6.22.10/arch/ia64/kernel/perfmon.c 2007-07-09 13:17:43 +0200
752 +++ linux-2.6.22.10-vs2.2.0.5/arch/ia64/kernel/perfmon.c 2007-06-15 02:37:03 +0200
754 #include <linux/capability.h>
755 #include <linux/rcupdate.h>
756 #include <linux/completion.h>
757 +#include <linux/vs_memory.h>
759 #include <asm/errno.h>
760 #include <asm/intrinsics.h>
761 @@ -2395,7 +2396,7 @@ pfm_smpl_buffer_alloc(struct task_struct
763 insert_vm_struct(mm, vma);
765 - mm->total_vm += size >> PAGE_SHIFT;
766 + vx_vmpages_add(mm, size >> PAGE_SHIFT);
767 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
769 up_write(&task->mm->mmap_sem);
770 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/ia64/kernel/process.c
771 --- linux-2.6.22.10/arch/ia64/kernel/process.c 2007-07-09 13:17:43 +0200
772 +++ linux-2.6.22.10-vs2.2.0.5/arch/ia64/kernel/process.c 2007-06-15 02:37:03 +0200
773 @@ -105,7 +105,8 @@ show_regs (struct pt_regs *regs)
774 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
777 - printk("\nPid: %d, CPU %d, comm: %20s\n", current->pid, smp_processor_id(), current->comm);
778 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n",
779 + current->pid, current->xid, smp_processor_id(), current->comm);
780 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s\n",
781 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted());
782 print_symbol("ip is at %s\n", ip);
783 @@ -696,7 +697,8 @@ kernel_thread (int (*fn)(void *), void *
784 regs.sw.ar_fpsr = regs.pt.ar_fpsr = ia64_getreg(_IA64_REG_AR_FPSR);
785 regs.sw.ar_bspstore = (unsigned long) current + IA64_RBS_OFFSET;
786 regs.sw.pr = (1 << PRED_KERNEL_STACK);
787 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s.pt, 0, NULL, NULL);
788 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
789 + 0, ®s.pt, 0, NULL, NULL);
791 EXPORT_SYMBOL(kernel_thread);
793 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/kernel/ptrace.c linux-2.6.22.10-vs2.2.0.5/arch/ia64/kernel/ptrace.c
794 --- linux-2.6.22.10/arch/ia64/kernel/ptrace.c 2007-05-02 19:24:20 +0200
795 +++ linux-2.6.22.10-vs2.2.0.5/arch/ia64/kernel/ptrace.c 2007-06-15 02:37:03 +0200
797 #include <linux/security.h>
798 #include <linux/audit.h>
799 #include <linux/signal.h>
800 +#include <linux/vs_base.h>
802 #include <asm/pgtable.h>
803 #include <asm/processor.h>
804 @@ -1443,6 +1444,9 @@ sys_ptrace (long request, pid_t pid, uns
805 read_unlock(&tasklist_lock);
808 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
812 if (pid == 1) /* no messing around with init! */
814 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/ia64/kernel/traps.c
815 --- linux-2.6.22.10/arch/ia64/kernel/traps.c 2007-07-09 13:17:43 +0200
816 +++ linux-2.6.22.10-vs2.2.0.5/arch/ia64/kernel/traps.c 2007-06-15 02:37:03 +0200
817 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
820 if (++die.lock_owner_depth < 3) {
821 - printk("%s[%d]: %s %ld [%d]\n",
822 - current->comm, current->pid, str, err, ++die_counter);
823 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
824 + current->comm, current->pid, current->xid,
825 + str, err, ++die_counter);
826 (void) notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV);
829 @@ -313,8 +314,9 @@ handle_fpu_swa (int fp_fault, struct pt_
830 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
831 last.time = current_jiffies + 5 * HZ;
833 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
834 - current->comm, current->pid, regs->cr_iip + ia64_psr(regs)->ri, isr);
835 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
836 + current->comm, current->pid, current->xid,
837 + regs->cr_iip + ia64_psr(regs)->ri, isr);
841 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/ia64/mm/fault.c
842 --- linux-2.6.22.10/arch/ia64/mm/fault.c 2007-07-09 13:17:43 +0200
843 +++ linux-2.6.22.10-vs2.2.0.5/arch/ia64/mm/fault.c 2007-06-15 02:39:01 +0200
845 #include <linux/interrupt.h>
846 #include <linux/kprobes.h>
847 #include <linux/kdebug.h>
848 +#include <linux/vs_memory.h>
850 #include <asm/pgtable.h>
851 #include <asm/processor.h>
852 diff -NurpP --minimal linux-2.6.22.10/arch/m32r/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/m32r/kernel/process.c
853 --- linux-2.6.22.10/arch/m32r/kernel/process.c 2007-05-02 19:24:21 +0200
854 +++ linux-2.6.22.10-vs2.2.0.5/arch/m32r/kernel/process.c 2007-06-15 02:37:03 +0200
855 @@ -211,8 +211,8 @@ int kernel_thread(int (*fn)(void *), voi
856 regs.psw = M32R_PSW_BIE;
858 /* Ok, create the new process. */
859 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL,
861 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
862 + 0, ®s, 0, NULL, NULL);
866 diff -NurpP --minimal linux-2.6.22.10/arch/m32r/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/m32r/kernel/traps.c
867 --- linux-2.6.22.10/arch/m32r/kernel/traps.c 2006-11-30 21:18:28 +0100
868 +++ linux-2.6.22.10-vs2.2.0.5/arch/m32r/kernel/traps.c 2007-06-15 02:37:03 +0200
869 @@ -195,8 +195,9 @@ static void show_registers(struct pt_reg
871 printk("SPI: %08lx\n", sp);
873 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
874 - current->comm, current->pid, 0xffff & i, 4096+(unsigned long)current);
875 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
876 + current->comm, current->pid, current->xid,
877 + 0xffff & i, 4096+(unsigned long)current);
880 * When in-kernel, we also print out the stack and code at the
881 diff -NurpP --minimal linux-2.6.22.10/arch/m68k/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/m68k/Kconfig
882 --- linux-2.6.22.10/arch/m68k/Kconfig 2007-07-09 13:17:47 +0200
883 +++ linux-2.6.22.10-vs2.2.0.5/arch/m68k/Kconfig 2007-07-07 03:52:53 +0200
884 @@ -678,6 +678,8 @@ source "fs/Kconfig"
886 source "arch/m68k/Kconfig.debug"
888 +source "kernel/vserver/Kconfig"
890 source "security/Kconfig"
892 source "crypto/Kconfig"
893 diff -NurpP --minimal linux-2.6.22.10/arch/m68k/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/m68k/kernel/process.c
894 --- linux-2.6.22.10/arch/m68k/kernel/process.c 2006-11-30 21:18:28 +0100
895 +++ linux-2.6.22.10-vs2.2.0.5/arch/m68k/kernel/process.c 2007-06-15 02:37:03 +0200
896 @@ -159,7 +159,8 @@ int kernel_thread(int (*fn)(void *), voi
899 register long retval __asm__ ("d0");
900 - register long clone_arg __asm__ ("d1") = flags | CLONE_VM | CLONE_UNTRACED;
901 + register long clone_arg __asm__ ("d1") =
902 + flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD;
906 diff -NurpP --minimal linux-2.6.22.10/arch/m68k/kernel/ptrace.c linux-2.6.22.10-vs2.2.0.5/arch/m68k/kernel/ptrace.c
907 --- linux-2.6.22.10/arch/m68k/kernel/ptrace.c 2007-07-09 13:17:47 +0200
908 +++ linux-2.6.22.10-vs2.2.0.5/arch/m68k/kernel/ptrace.c 2007-06-15 02:37:03 +0200
910 #include <linux/ptrace.h>
911 #include <linux/user.h>
912 #include <linux/signal.h>
913 +#include <linux/vs_base.h>
915 #include <asm/uaccess.h>
916 #include <asm/page.h>
917 @@ -278,6 +279,8 @@ long arch_ptrace(struct task_struct *chi
918 ret = ptrace_request(child, request, addr, data);
921 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
926 diff -NurpP --minimal linux-2.6.22.10/arch/m68k/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/m68k/kernel/traps.c
927 --- linux-2.6.22.10/arch/m68k/kernel/traps.c 2007-05-02 19:24:21 +0200
928 +++ linux-2.6.22.10-vs2.2.0.5/arch/m68k/kernel/traps.c 2007-06-15 02:37:03 +0200
929 @@ -899,8 +899,8 @@ void show_registers(struct pt_regs *regs
930 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
931 regs->d4, regs->d5, regs->a0, regs->a1);
933 - printk("Process %s (pid: %d, task=%p)\n",
934 - current->comm, current->pid, current);
935 + printk("Process %s (pid: %d[#%u], task=%p)\n",
936 + current->comm, current->pid, current->xid, current);
937 addr = (unsigned long)&fp->un;
938 printk("Frame format=%X ", regs->format);
939 switch (regs->format) {
940 diff -NurpP --minimal linux-2.6.22.10/arch/m68knommu/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/m68knommu/Kconfig
941 --- linux-2.6.22.10/arch/m68knommu/Kconfig 2007-07-09 13:17:47 +0200
942 +++ linux-2.6.22.10-vs2.2.0.5/arch/m68knommu/Kconfig 2007-06-15 02:37:03 +0200
943 @@ -670,6 +670,8 @@ source "fs/Kconfig"
945 source "arch/m68knommu/Kconfig.debug"
947 +source "kernel/vserver/Kconfig"
949 source "security/Kconfig"
951 source "crypto/Kconfig"
952 diff -NurpP --minimal linux-2.6.22.10/arch/m68knommu/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/m68knommu/kernel/process.c
953 --- linux-2.6.22.10/arch/m68knommu/kernel/process.c 2007-02-06 03:00:08 +0100
954 +++ linux-2.6.22.10-vs2.2.0.5/arch/m68knommu/kernel/process.c 2007-06-15 02:37:03 +0200
955 @@ -122,7 +122,7 @@ void show_regs(struct pt_regs * regs)
956 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
959 - long clone_arg = flags | CLONE_VM;
960 + long clone_arg = flags | CLONE_VM | CLONE_KTHREAD;
964 diff -NurpP --minimal linux-2.6.22.10/arch/m68knommu/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/m68knommu/kernel/traps.c
965 --- linux-2.6.22.10/arch/m68knommu/kernel/traps.c 2007-05-02 19:24:21 +0200
966 +++ linux-2.6.22.10-vs2.2.0.5/arch/m68knommu/kernel/traps.c 2007-06-15 02:37:03 +0200
967 @@ -80,8 +80,9 @@ void die_if_kernel(char *str, struct pt_
968 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
969 fp->d4, fp->d5, fp->a0, fp->a1);
971 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
972 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
973 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
974 + current->comm, current->pid, current->xid,
975 + PAGE_SIZE+(unsigned long)current);
976 show_stack(NULL, (unsigned long *)fp);
979 diff -NurpP --minimal linux-2.6.22.10/arch/mips/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/mips/Kconfig
980 --- linux-2.6.22.10/arch/mips/Kconfig 2007-07-09 13:17:47 +0200
981 +++ linux-2.6.22.10-vs2.2.0.5/arch/mips/Kconfig 2007-07-07 03:52:53 +0200
982 @@ -1959,6 +1959,8 @@ source "arch/mips/oprofile/Kconfig"
984 source "arch/mips/Kconfig.debug"
986 +source "kernel/vserver/Kconfig"
988 source "security/Kconfig"
990 source "crypto/Kconfig"
991 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/linux32.c linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/linux32.c
992 --- linux-2.6.22.10/arch/mips/kernel/linux32.c 2007-07-09 13:17:48 +0200
993 +++ linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/linux32.c 2007-06-17 05:54:16 +0200
994 @@ -229,7 +229,7 @@ sys32_gettimeofday(struct compat_timeval
998 - do_gettimeofday(&ktv);
999 + vx_gettimeofday(&ktv);
1000 if (put_tv32(tv, &ktv))
1003 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/process.c
1004 --- linux-2.6.22.10/arch/mips/kernel/process.c 2007-05-02 19:24:23 +0200
1005 +++ linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/process.c 2007-06-15 02:37:03 +0200
1006 @@ -236,7 +236,8 @@ long kernel_thread(int (*fn)(void *), vo
1009 /* Ok, create the new process.. */
1010 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
1011 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
1012 + 0, ®s, 0, NULL, NULL);
1016 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/ptrace.c linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/ptrace.c
1017 --- linux-2.6.22.10/arch/mips/kernel/ptrace.c 2007-07-09 13:17:48 +0200
1018 +++ linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/ptrace.c 2007-06-15 02:37:03 +0200
1020 #include <linux/user.h>
1021 #include <linux/security.h>
1022 #include <linux/signal.h>
1023 +#include <linux/vs_base.h>
1025 #include <asm/byteorder.h>
1026 #include <asm/cpu.h>
1027 @@ -171,6 +172,9 @@ long arch_ptrace(struct task_struct *chi
1031 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
1035 /* when I and D space are separate, these will need to be fixed. */
1036 case PTRACE_PEEKTEXT: /* read word at location addr. */
1037 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/scall32-o32.S linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/scall32-o32.S
1038 --- linux-2.6.22.10/arch/mips/kernel/scall32-o32.S 2007-07-09 13:17:48 +0200
1039 +++ linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/scall32-o32.S 2007-06-17 05:54:16 +0200
1040 @@ -619,7 +619,7 @@ einval: li v0, -EINVAL
1041 sys sys_mq_timedreceive 5
1042 sys sys_mq_notify 2 /* 4275 */
1043 sys sys_mq_getsetattr 3
1044 - sys sys_ni_syscall 0 /* sys_vserver */
1047 sys sys_ni_syscall 0 /* available, was setaltroot */
1048 sys sys_add_key 5 /* 4280 */
1049 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/scall64-64.S linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/scall64-64.S
1050 --- linux-2.6.22.10/arch/mips/kernel/scall64-64.S 2007-07-09 13:17:48 +0200
1051 +++ linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/scall64-64.S 2007-06-17 05:54:16 +0200
1052 @@ -434,7 +434,7 @@ sys_call_table:
1053 PTR sys_mq_timedreceive
1055 PTR sys_mq_getsetattr /* 5235 */
1056 - PTR sys_ni_syscall /* sys_vserver */
1059 PTR sys_ni_syscall /* available, was setaltroot */
1061 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/scall64-n32.S linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/scall64-n32.S
1062 --- linux-2.6.22.10/arch/mips/kernel/scall64-n32.S 2007-07-09 13:17:48 +0200
1063 +++ linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/scall64-n32.S 2007-06-17 05:54:16 +0200
1064 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
1065 PTR compat_sys_mq_timedreceive
1066 PTR compat_sys_mq_notify
1067 PTR compat_sys_mq_getsetattr
1068 - PTR sys_ni_syscall /* 6240, sys_vserver */
1069 + PTR sys32_vserver /* 6240 */
1070 PTR compat_sys_waitid
1071 PTR sys_ni_syscall /* available, was setaltroot */
1073 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/scall64-o32.S linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/scall64-o32.S
1074 --- linux-2.6.22.10/arch/mips/kernel/scall64-o32.S 2007-07-09 13:17:48 +0200
1075 +++ linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/scall64-o32.S 2007-06-17 05:54:16 +0200
1076 @@ -482,7 +482,7 @@ sys_call_table:
1077 PTR compat_sys_mq_timedreceive
1078 PTR compat_sys_mq_notify /* 4275 */
1079 PTR compat_sys_mq_getsetattr
1080 - PTR sys_ni_syscall /* sys_vserver */
1083 PTR sys_ni_syscall /* available, was setaltroot */
1084 PTR sys_add_key /* 4280 */
1085 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/traps.c
1086 --- linux-2.6.22.10/arch/mips/kernel/traps.c 2007-07-09 13:17:48 +0200
1087 +++ linux-2.6.22.10-vs2.2.0.5/arch/mips/kernel/traps.c 2007-07-09 13:11:53 +0200
1088 @@ -302,8 +302,9 @@ void show_registers(struct pt_regs *regs
1092 - printk("Process %s (pid: %d, threadinfo=%p, task=%p)\n",
1093 - current->comm, current->pid, current_thread_info(), current);
1094 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p)\n",
1095 + current->comm, current->pid, current->xid,
1096 + current_thread_info(), current);
1097 show_stacktrace(current, regs);
1098 show_code((unsigned int *) regs->cp0_epc);
1100 diff -NurpP --minimal linux-2.6.22.10/arch/mips/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/mips/mm/fault.c
1101 --- linux-2.6.22.10/arch/mips/mm/fault.c 2007-07-09 13:17:48 +0200
1102 +++ linux-2.6.22.10-vs2.2.0.5/arch/mips/mm/fault.c 2007-06-15 02:37:03 +0200
1103 @@ -179,7 +179,8 @@ out_of_memory:
1104 down_read(&mm->mmap_sem);
1107 - printk("VM: killing process %s\n", tsk->comm);
1108 + printk("VM: killing process %s(%d:#%u)\n",
1109 + tsk->comm, tsk->pid, tsk->xid);
1110 if (user_mode(regs))
1113 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/parisc/Kconfig
1114 --- linux-2.6.22.10/arch/parisc/Kconfig 2007-05-02 19:24:26 +0200
1115 +++ linux-2.6.22.10-vs2.2.0.5/arch/parisc/Kconfig 2007-06-15 02:37:03 +0200
1116 @@ -271,6 +271,8 @@ source "arch/parisc/oprofile/Kconfig"
1118 source "arch/parisc/Kconfig.debug"
1120 +source "kernel/vserver/Kconfig"
1122 source "security/Kconfig"
1124 source "crypto/Kconfig"
1125 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/kernel/entry.S linux-2.6.22.10-vs2.2.0.5/arch/parisc/kernel/entry.S
1126 --- linux-2.6.22.10/arch/parisc/kernel/entry.S 2007-07-09 13:17:50 +0200
1127 +++ linux-2.6.22.10-vs2.2.0.5/arch/parisc/kernel/entry.S 2007-06-17 05:54:16 +0200
1128 @@ -761,6 +761,7 @@ END(fault_vector_11)
1130 #define CLONE_VM 0x100 /* Must agree with <linux/sched.h> */
1131 #define CLONE_UNTRACED 0x00800000
1132 +#define CLONE_KTHREAD 0x10000000
1135 ENTRY(__kernel_thread)
1136 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/parisc/kernel/process.c
1137 --- linux-2.6.22.10/arch/parisc/kernel/process.c 2007-07-09 13:17:50 +0200
1138 +++ linux-2.6.22.10-vs2.2.0.5/arch/parisc/kernel/process.c 2007-06-17 05:54:16 +0200
1139 @@ -173,7 +173,7 @@ pid_t kernel_thread(int (*fn)(void *), v
1140 * kernel_thread can become a #define.
1143 - return __kernel_thread(fn, arg, flags);
1144 + return __kernel_thread(fn, arg, flags | CLONE_KTHREAD);
1146 EXPORT_SYMBOL(kernel_thread);
1148 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/kernel/sys_parisc32.c linux-2.6.22.10-vs2.2.0.5/arch/parisc/kernel/sys_parisc32.c
1149 --- linux-2.6.22.10/arch/parisc/kernel/sys_parisc32.c 2007-07-09 13:17:50 +0200
1150 +++ linux-2.6.22.10-vs2.2.0.5/arch/parisc/kernel/sys_parisc32.c 2007-06-17 05:54:16 +0200
1151 @@ -204,11 +204,11 @@ static inline long get_ts32(struct times
1153 sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
1155 - extern void do_gettimeofday(struct timeval *tv);
1156 + extern void vx_gettimeofday(struct timeval *tv);
1160 - do_gettimeofday(&ktv);
1161 + vx_gettimeofday(&ktv);
1162 if (put_compat_timeval(tv, &ktv))
1165 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/kernel/syscall_table.S linux-2.6.22.10-vs2.2.0.5/arch/parisc/kernel/syscall_table.S
1166 --- linux-2.6.22.10/arch/parisc/kernel/syscall_table.S 2007-07-09 13:17:50 +0200
1167 +++ linux-2.6.22.10-vs2.2.0.5/arch/parisc/kernel/syscall_table.S 2007-06-17 05:54:16 +0200
1169 ENTRY_COMP(mbind) /* 260 */
1170 ENTRY_COMP(get_mempolicy)
1171 ENTRY_COMP(set_mempolicy)
1172 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
1173 + ENTRY_DIFF(vserver)
1175 ENTRY_SAME(request_key) /* 265 */
1177 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/parisc/kernel/traps.c
1178 --- linux-2.6.22.10/arch/parisc/kernel/traps.c 2007-07-09 13:17:50 +0200
1179 +++ linux-2.6.22.10-vs2.2.0.5/arch/parisc/kernel/traps.c 2007-06-17 05:54:16 +0200
1180 @@ -218,8 +218,9 @@ void die_if_kernel(char *str, struct pt_
1184 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
1185 - current->comm, current->pid, str, err, regs->iaoq[0]);
1186 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
1187 + current->comm, current->pid, current->xid,
1188 + str, err, regs->iaoq[0]);
1189 #ifdef PRINT_USER_FAULTS
1190 /* XXX for debugging only */
1192 @@ -251,8 +252,8 @@ KERN_CRIT " || |
1193 pdc_console_restart();
1196 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
1197 - current->comm, current->pid, str, err);
1198 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
1199 + current->comm, current->pid, current->xid, str, err);
1201 /* Wot's wrong wif bein' racy? */
1202 if (current->thread.flags & PARISC_KERNEL_DEATH) {
1203 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/parisc/mm/fault.c
1204 --- linux-2.6.22.10/arch/parisc/mm/fault.c 2007-05-02 19:24:26 +0200
1205 +++ linux-2.6.22.10-vs2.2.0.5/arch/parisc/mm/fault.c 2007-06-15 02:37:03 +0200
1206 @@ -209,8 +209,9 @@ bad_area:
1208 #ifdef PRINT_USER_FAULTS
1209 printk(KERN_DEBUG "\n");
1210 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
1211 - tsk->pid, tsk->comm, code, address);
1212 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
1213 + "command='%s' type=%lu address=0x%08lx\n",
1214 + tsk->pid, tsk->xid, tsk->comm, code, address);
1216 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
1217 vma->vm_start, vma->vm_end);
1218 @@ -260,7 +261,8 @@ no_context:
1221 up_read(&mm->mmap_sem);
1222 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
1223 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
1224 + current->comm, current->pid, current->xid);
1225 if (user_mode(regs))
1228 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/powerpc/Kconfig
1229 --- linux-2.6.22.10/arch/powerpc/Kconfig 2007-07-09 13:17:50 +0200
1230 +++ linux-2.6.22.10-vs2.2.0.5/arch/powerpc/Kconfig 2007-06-15 02:37:03 +0200
1231 @@ -906,6 +906,8 @@ endmenu
1233 source "arch/powerpc/Kconfig.debug"
1235 +source "kernel/vserver/Kconfig"
1237 source "security/Kconfig"
1240 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/asm-offsets.c linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/asm-offsets.c
1241 --- linux-2.6.22.10/arch/powerpc/kernel/asm-offsets.c 2007-07-09 13:17:51 +0200
1242 +++ linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/asm-offsets.c 2007-06-15 02:37:03 +0200
1243 @@ -250,6 +250,7 @@ int main(void)
1245 DEFINE(CLONE_VM, CLONE_VM);
1246 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
1247 + DEFINE(CLONE_KTHREAD, CLONE_KTHREAD);
1249 #ifndef CONFIG_PPC64
1250 DEFINE(MM_PGD, offsetof(struct mm_struct, pgd));
1251 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/irq.c linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/irq.c
1252 --- linux-2.6.22.10/arch/powerpc/kernel/irq.c 2007-07-09 13:17:51 +0200
1253 +++ linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/irq.c 2007-07-09 13:11:53 +0200
1255 #include <linux/mutex.h>
1256 #include <linux/bootmem.h>
1257 #include <linux/pci.h>
1258 +#include <linux/vs_context.h>
1260 #include <asm/uaccess.h>
1261 #include <asm/system.h>
1262 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/misc_32.S linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/misc_32.S
1263 --- linux-2.6.22.10/arch/powerpc/kernel/misc_32.S 2007-07-09 13:17:51 +0200
1264 +++ linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/misc_32.S 2007-06-15 02:37:03 +0200
1265 @@ -745,7 +745,7 @@ _GLOBAL(kernel_thread)
1266 mr r30,r3 /* function */
1267 mr r31,r4 /* argument */
1268 ori r3,r5,CLONE_VM /* flags */
1269 - oris r3,r3,CLONE_UNTRACED>>16
1270 + oris r3,r3,(CLONE_UNTRACED|CLONE_KTHREAD)>>16
1271 li r4,0 /* new sp (unused) */
1274 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/misc_64.S linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/misc_64.S
1275 --- linux-2.6.22.10/arch/powerpc/kernel/misc_64.S 2007-05-02 19:24:27 +0200
1276 +++ linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/misc_64.S 2007-06-15 02:37:03 +0200
1277 @@ -434,7 +434,7 @@ _GLOBAL(kernel_thread)
1280 ori r3,r5,CLONE_VM /* flags */
1281 - oris r3,r3,(CLONE_UNTRACED>>16)
1282 + oris r3,r3,(CLONE_UNTRACED|CLONE_KTHREAD)>>16
1283 li r4,0 /* new sp (unused) */
1286 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/process.c
1287 --- linux-2.6.22.10/arch/powerpc/kernel/process.c 2007-10-30 01:57:12 +0100
1288 +++ linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/process.c 2007-10-01 15:25:34 +0200
1289 @@ -422,8 +422,9 @@ void show_regs(struct pt_regs * regs)
1291 if (trap == 0x300 || trap == 0x600)
1292 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
1293 - printk("TASK = %p[%d] '%s' THREAD: %p",
1294 - current, current->pid, current->comm, task_thread_info(current));
1295 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
1296 + current, current->pid, current->xid,
1297 + current->comm, task_thread_info(current));
1300 printk(" CPU: %d", smp_processor_id());
1301 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/sys_ppc32.c linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/sys_ppc32.c
1302 --- linux-2.6.22.10/arch/powerpc/kernel/sys_ppc32.c 2007-07-09 13:17:51 +0200
1303 +++ linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/sys_ppc32.c 2007-07-07 03:52:53 +0200
1304 @@ -205,7 +205,7 @@ asmlinkage long compat_sys_gettimeofday(
1308 - do_gettimeofday(&ktv);
1309 + vx_gettimeofday(&ktv);
1310 if (put_tv32(tv, &ktv))
1313 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/traps.c
1314 --- linux-2.6.22.10/arch/powerpc/kernel/traps.c 2007-07-09 13:17:51 +0200
1315 +++ linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/traps.c 2007-06-15 02:37:03 +0200
1316 @@ -878,8 +878,9 @@ void nonrecoverable_exception(struct pt_
1318 void trace_syscall(struct pt_regs *regs)
1320 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1321 - current, current->pid, regs->nip, regs->link, regs->gpr[0],
1322 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1323 + current, current->pid, current->xid,
1324 + regs->nip, regs->link, regs->gpr[0],
1325 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
1328 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/vdso.c linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/vdso.c
1329 --- linux-2.6.22.10/arch/powerpc/kernel/vdso.c 2007-07-09 13:17:51 +0200
1330 +++ linux-2.6.22.10-vs2.2.0.5/arch/powerpc/kernel/vdso.c 2007-06-15 02:37:03 +0200
1332 #include <linux/elf.h>
1333 #include <linux/security.h>
1334 #include <linux/bootmem.h>
1335 +#include <linux/vs_memory.h>
1337 #include <asm/pgtable.h>
1338 #include <asm/system.h>
1339 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/powerpc/mm/fault.c
1340 --- linux-2.6.22.10/arch/powerpc/mm/fault.c 2007-07-09 13:17:51 +0200
1341 +++ linux-2.6.22.10-vs2.2.0.5/arch/powerpc/mm/fault.c 2007-07-07 03:52:53 +0200
1342 @@ -378,7 +378,8 @@ out_of_memory:
1343 down_read(&mm->mmap_sem);
1346 - printk("VM: killing process %s\n", current->comm);
1347 + printk("VM: killing process %s(%d:#%u)\n",
1348 + current->comm, current->pid, current->xid);
1349 if (user_mode(regs))
1352 diff -NurpP --minimal linux-2.6.22.10/arch/ppc/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/ppc/Kconfig
1353 --- linux-2.6.22.10/arch/ppc/Kconfig 2007-05-02 19:24:28 +0200
1354 +++ linux-2.6.22.10-vs2.2.0.5/arch/ppc/Kconfig 2007-06-15 02:37:03 +0200
1355 @@ -1455,6 +1455,8 @@ source "arch/powerpc/oprofile/Kconfig"
1357 source "arch/ppc/Kconfig.debug"
1359 +source "kernel/vserver/Kconfig"
1361 source "security/Kconfig"
1363 source "crypto/Kconfig"
1364 diff -NurpP --minimal linux-2.6.22.10/arch/ppc/kernel/asm-offsets.c linux-2.6.22.10-vs2.2.0.5/arch/ppc/kernel/asm-offsets.c
1365 --- linux-2.6.22.10/arch/ppc/kernel/asm-offsets.c 2007-07-09 13:18:01 +0200
1366 +++ linux-2.6.22.10-vs2.2.0.5/arch/ppc/kernel/asm-offsets.c 2007-06-15 02:37:03 +0200
1367 @@ -120,6 +120,7 @@ main(void)
1368 DEFINE(TRAP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, trap));
1369 DEFINE(CLONE_VM, CLONE_VM);
1370 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
1371 + DEFINE(CLONE_KTHREAD, CLONE_KTHREAD);
1372 DEFINE(MM_PGD, offsetof(struct mm_struct, pgd));
1374 /* About the CPU features table */
1375 diff -NurpP --minimal linux-2.6.22.10/arch/ppc/kernel/misc.S linux-2.6.22.10-vs2.2.0.5/arch/ppc/kernel/misc.S
1376 --- linux-2.6.22.10/arch/ppc/kernel/misc.S 2006-11-30 21:18:32 +0100
1377 +++ linux-2.6.22.10-vs2.2.0.5/arch/ppc/kernel/misc.S 2007-06-15 02:37:03 +0200
1378 @@ -848,7 +848,7 @@ _GLOBAL(kernel_thread)
1379 mr r30,r3 /* function */
1380 mr r31,r4 /* argument */
1381 ori r3,r5,CLONE_VM /* flags */
1382 - oris r3,r3,CLONE_UNTRACED>>16
1383 + oris r3,r3,(CLONE_UNTRACED|CLONE_KTHREAD)>>16
1384 li r4,0 /* new sp (unused) */
1387 diff -NurpP --minimal linux-2.6.22.10/arch/ppc/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/ppc/kernel/traps.c
1388 --- linux-2.6.22.10/arch/ppc/kernel/traps.c 2007-07-09 13:18:01 +0200
1389 +++ linux-2.6.22.10-vs2.2.0.5/arch/ppc/kernel/traps.c 2007-06-15 02:37:03 +0200
1390 @@ -696,8 +696,9 @@ void nonrecoverable_exception(struct pt_
1392 void trace_syscall(struct pt_regs *regs)
1394 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1395 - current, current->pid, regs->nip, regs->link, regs->gpr[0],
1396 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1397 + current, current->pid, current->xid,
1398 + regs->nip, regs->link, regs->gpr[0],
1399 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
1402 diff -NurpP --minimal linux-2.6.22.10/arch/ppc/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/ppc/mm/fault.c
1403 --- linux-2.6.22.10/arch/ppc/mm/fault.c 2006-11-30 21:18:32 +0100
1404 +++ linux-2.6.22.10-vs2.2.0.5/arch/ppc/mm/fault.c 2007-06-15 02:37:03 +0200
1405 @@ -296,7 +296,8 @@ out_of_memory:
1406 down_read(&mm->mmap_sem);
1409 - printk("VM: killing process %s\n", current->comm);
1410 + printk("VM: killing process %s(%d:#%u)\n",
1411 + current->comm, current->pid, current->xid);
1412 if (user_mode(regs))
1415 diff -NurpP --minimal linux-2.6.22.10/arch/s390/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/s390/Kconfig
1416 --- linux-2.6.22.10/arch/s390/Kconfig 2007-07-09 13:18:02 +0200
1417 +++ linux-2.6.22.10-vs2.2.0.5/arch/s390/Kconfig 2007-06-15 02:37:03 +0200
1418 @@ -551,6 +551,8 @@ endmenu
1420 source "arch/s390/Kconfig.debug"
1422 +source "kernel/vserver/Kconfig"
1424 source "security/Kconfig"
1426 source "crypto/Kconfig"
1427 diff -NurpP --minimal linux-2.6.22.10/arch/s390/kernel/compat_linux.c linux-2.6.22.10-vs2.2.0.5/arch/s390/kernel/compat_linux.c
1428 --- linux-2.6.22.10/arch/s390/kernel/compat_linux.c 2007-07-09 13:18:02 +0200
1429 +++ linux-2.6.22.10-vs2.2.0.5/arch/s390/kernel/compat_linux.c 2007-06-15 02:37:03 +0200
1430 @@ -567,7 +567,7 @@ asmlinkage long sys32_gettimeofday(struc
1434 - do_gettimeofday(&ktv);
1435 + vx_gettimeofday(&ktv);
1436 if (put_tv32(tv, &ktv))
1439 diff -NurpP --minimal linux-2.6.22.10/arch/s390/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/s390/kernel/process.c
1440 --- linux-2.6.22.10/arch/s390/kernel/process.c 2007-07-09 13:18:02 +0200
1441 +++ linux-2.6.22.10-vs2.2.0.5/arch/s390/kernel/process.c 2007-06-15 02:37:03 +0200
1442 @@ -164,9 +164,9 @@ void show_regs(struct pt_regs *regs)
1443 struct task_struct *tsk = current;
1445 printk("CPU: %d %s\n", task_thread_info(tsk)->cpu, print_tainted());
1446 - printk("Process %s (pid: %d, task: %p, ksp: %p)\n",
1447 - current->comm, current->pid, (void *) tsk,
1448 - (void *) tsk->thread.ksp);
1449 + printk("Process %s (pid: %d[#%u], task: %p, ksp: %p)\n",
1450 + current->comm, current->pid, current->xid,
1451 + (void *) tsk, (void *) tsk->thread.ksp);
1453 show_registers(regs);
1454 /* Show stack backtrace if pt_regs is from kernel mode */
1455 @@ -197,7 +197,7 @@ int kernel_thread(int (*fn)(void *), voi
1456 regs.orig_gpr2 = -1;
1458 /* Ok, create the new process.. */
1459 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED,
1460 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
1461 0, ®s, 0, NULL, NULL);
1464 diff -NurpP --minimal linux-2.6.22.10/arch/s390/kernel/ptrace.c linux-2.6.22.10-vs2.2.0.5/arch/s390/kernel/ptrace.c
1465 --- linux-2.6.22.10/arch/s390/kernel/ptrace.c 2007-05-02 19:24:29 +0200
1466 +++ linux-2.6.22.10-vs2.2.0.5/arch/s390/kernel/ptrace.c 2007-06-15 02:37:03 +0200
1468 #include <linux/security.h>
1469 #include <linux/audit.h>
1470 #include <linux/signal.h>
1471 +#include <linux/vs_base.h>
1473 #include <asm/segment.h>
1474 #include <asm/page.h>
1475 @@ -725,7 +726,13 @@ sys_ptrace(long request, long pid, long
1479 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
1484 ret = do_ptrace(child, request, addr, data);
1486 put_task_struct(child);
1489 diff -NurpP --minimal linux-2.6.22.10/arch/s390/kernel/syscalls.S linux-2.6.22.10-vs2.2.0.5/arch/s390/kernel/syscalls.S
1490 --- linux-2.6.22.10/arch/s390/kernel/syscalls.S 2007-07-09 13:18:02 +0200
1491 +++ linux-2.6.22.10-vs2.2.0.5/arch/s390/kernel/syscalls.S 2007-06-15 02:37:03 +0200
1492 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
1493 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
1494 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
1495 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
1496 -NI_SYSCALL /* reserved for vserver */
1497 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
1498 SYSCALL(s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
1499 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
1500 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
1501 diff -NurpP --minimal linux-2.6.22.10/arch/s390/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/s390/mm/fault.c
1502 --- linux-2.6.22.10/arch/s390/mm/fault.c 2007-07-09 13:18:02 +0200
1503 +++ linux-2.6.22.10-vs2.2.0.5/arch/s390/mm/fault.c 2007-06-15 02:37:03 +0200
1504 @@ -216,7 +216,8 @@ static int do_out_of_memory(struct pt_re
1505 down_read(&mm->mmap_sem);
1508 - printk("VM: killing process %s\n", tsk->comm);
1509 + printk("VM: killing process %s(%d:#%u)\n",
1510 + tsk->comm, tsk->pid, tsk->xid);
1511 if (regs->psw.mask & PSW_MASK_PSTATE)
1513 do_no_context(regs, error_code, address);
1514 diff -NurpP --minimal linux-2.6.22.10/arch/sh/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/sh/Kconfig
1515 --- linux-2.6.22.10/arch/sh/Kconfig 2007-07-09 13:18:02 +0200
1516 +++ linux-2.6.22.10-vs2.2.0.5/arch/sh/Kconfig 2007-06-15 02:37:03 +0200
1517 @@ -723,6 +723,8 @@ source "arch/sh/oprofile/Kconfig"
1519 source "arch/sh/Kconfig.debug"
1521 +source "kernel/vserver/Kconfig"
1523 source "security/Kconfig"
1525 source "crypto/Kconfig"
1526 diff -NurpP --minimal linux-2.6.22.10/arch/sh/kernel/irq.c linux-2.6.22.10-vs2.2.0.5/arch/sh/kernel/irq.c
1527 --- linux-2.6.22.10/arch/sh/kernel/irq.c 2007-07-09 13:18:03 +0200
1528 +++ linux-2.6.22.10-vs2.2.0.5/arch/sh/kernel/irq.c 2007-06-15 02:37:03 +0200
1530 #include <linux/kernel_stat.h>
1531 #include <linux/seq_file.h>
1532 #include <linux/irq.h>
1533 +#include <linux/vs_context.h>
1534 #include <asm/processor.h>
1535 #include <asm/machvec.h>
1536 #include <asm/uaccess.h>
1537 diff -NurpP --minimal linux-2.6.22.10/arch/sh/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/sh/kernel/process.c
1538 --- linux-2.6.22.10/arch/sh/kernel/process.c 2007-07-09 13:18:03 +0200
1539 +++ linux-2.6.22.10-vs2.2.0.5/arch/sh/kernel/process.c 2007-06-15 02:37:03 +0200
1540 @@ -118,7 +118,8 @@ void machine_power_off(void)
1541 void show_regs(struct pt_regs * regs)
1544 - printk("Pid : %d, Comm: %20s\n", current->pid, current->comm);
1545 + printk("Pid : %d:#%u, Comm: %20s\n",
1546 + current->pid, current->xid, current->comm);
1547 print_symbol("PC is at %s\n", instruction_pointer(regs));
1548 printk("PC : %08lx SP : %08lx SR : %08lx ",
1549 regs->pc, regs->regs[15], regs->sr);
1550 @@ -179,7 +180,7 @@ int kernel_thread(int (*fn)(void *), voi
1551 regs.sr = (1 << 30);
1553 /* Ok, create the new process.. */
1554 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
1555 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD, 0,
1556 ®s, 0, NULL, NULL);
1559 diff -NurpP --minimal linux-2.6.22.10/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.22.10-vs2.2.0.5/arch/sh/kernel/vsyscall/vsyscall.c
1560 --- linux-2.6.22.10/arch/sh/kernel/vsyscall/vsyscall.c 2007-07-09 13:18:03 +0200
1561 +++ linux-2.6.22.10-vs2.2.0.5/arch/sh/kernel/vsyscall/vsyscall.c 2007-06-15 02:39:24 +0200
1563 #include <linux/module.h>
1564 #include <linux/elf.h>
1565 #include <linux/sched.h>
1566 +#include <linux/vs_memory.h>
1569 * Should the kernel map a VDSO page into processes and pass its
1570 diff -NurpP --minimal linux-2.6.22.10/arch/sh/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/sh/mm/fault.c
1571 --- linux-2.6.22.10/arch/sh/mm/fault.c 2007-07-09 13:18:03 +0200
1572 +++ linux-2.6.22.10-vs2.2.0.5/arch/sh/mm/fault.c 2007-06-15 02:37:03 +0200
1573 @@ -201,7 +201,8 @@ out_of_memory:
1574 down_read(&mm->mmap_sem);
1577 - printk("VM: killing process %s\n", tsk->comm);
1578 + printk("VM: killing process %s(%d:#%u)\n",
1579 + tsk->comm, tsk->pid, tsk->xid);
1580 if (user_mode(regs))
1583 diff -NurpP --minimal linux-2.6.22.10/arch/sh64/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/sh64/kernel/process.c
1584 --- linux-2.6.22.10/arch/sh64/kernel/process.c 2007-07-09 13:18:03 +0200
1585 +++ linux-2.6.22.10-vs2.2.0.5/arch/sh64/kernel/process.c 2007-06-15 02:37:03 +0200
1586 @@ -400,8 +400,8 @@ int kernel_thread(int (*fn)(void *), voi
1587 regs.pc = (unsigned long)kernel_thread_helper;
1588 regs.sr = (1 << 30);
1590 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
1591 - ®s, 0, NULL, NULL);
1592 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
1593 + 0, ®s, 0, NULL, NULL);
1597 diff -NurpP --minimal linux-2.6.22.10/arch/sh64/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/sh64/mm/fault.c
1598 --- linux-2.6.22.10/arch/sh64/mm/fault.c 2007-07-09 13:18:04 +0200
1599 +++ linux-2.6.22.10-vs2.2.0.5/arch/sh64/mm/fault.c 2007-06-15 02:37:03 +0200
1600 @@ -81,7 +81,7 @@ static inline void print_vma(struct vm_a
1602 static inline void print_task(struct task_struct *tsk)
1604 - printk("Task pid %d\n", tsk->pid);
1605 + printk("Task pid %d:#%u\n", tsk->pid, tsk->xid);
1608 static pte_t *lookup_pte(struct mm_struct *mm, unsigned long address)
1609 @@ -330,7 +330,8 @@ out_of_memory:
1610 down_read(&mm->mmap_sem);
1613 - printk("VM: killing process %s\n", tsk->comm);
1614 + printk("VM: killing process %s(%d:#%u)\n",
1615 + tsk->comm, tsk->pid, tsk->xid);
1616 if (user_mode(regs))
1619 diff -NurpP --minimal linux-2.6.22.10/arch/sparc/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/sparc/Kconfig
1620 --- linux-2.6.22.10/arch/sparc/Kconfig 2007-07-09 13:18:04 +0200
1621 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc/Kconfig 2007-06-15 02:37:03 +0200
1622 @@ -317,6 +317,8 @@ endmenu
1624 source "arch/sparc/Kconfig.debug"
1626 +source "kernel/vserver/Kconfig"
1628 source "security/Kconfig"
1630 source "crypto/Kconfig"
1631 diff -NurpP --minimal linux-2.6.22.10/arch/sparc/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/sparc/kernel/process.c
1632 --- linux-2.6.22.10/arch/sparc/kernel/process.c 2007-07-09 13:18:04 +0200
1633 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc/kernel/process.c 2007-06-15 02:37:03 +0200
1634 @@ -705,7 +705,8 @@ pid_t kernel_thread(int (*fn)(void *), v
1635 /* Notreached by child. */
1636 "1: mov %%o0, %0\n\t" :
1638 - "i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED),
1639 + "i" (__NR_clone), "r" (flags |
1640 + CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD),
1641 "i" (__NR_exit), "r" (fn), "r" (arg) :
1642 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
1644 diff -NurpP --minimal linux-2.6.22.10/arch/sparc/kernel/ptrace.c linux-2.6.22.10-vs2.2.0.5/arch/sparc/kernel/ptrace.c
1645 --- linux-2.6.22.10/arch/sparc/kernel/ptrace.c 2007-02-06 03:00:18 +0100
1646 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc/kernel/ptrace.c 2007-06-15 02:37:03 +0200
1648 #include <linux/smp_lock.h>
1649 #include <linux/security.h>
1650 #include <linux/signal.h>
1651 +#include <linux/vs_base.h>
1653 #include <asm/pgtable.h>
1654 #include <asm/system.h>
1655 @@ -302,6 +303,10 @@ asmlinkage void do_ptrace(struct pt_regs
1656 pt_error_return(regs, -ret);
1659 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
1660 + pt_error_return(regs, ESRCH);
1664 if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
1665 || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
1666 diff -NurpP --minimal linux-2.6.22.10/arch/sparc/kernel/systbls.S linux-2.6.22.10-vs2.2.0.5/arch/sparc/kernel/systbls.S
1667 --- linux-2.6.22.10/arch/sparc/kernel/systbls.S 2007-07-09 13:18:04 +0200
1668 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc/kernel/systbls.S 2007-06-15 02:37:03 +0200
1669 @@ -71,7 +71,7 @@ sys_call_table:
1670 /*250*/ .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1671 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1672 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1673 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
1674 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
1675 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
1676 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
1677 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
1678 diff -NurpP --minimal linux-2.6.22.10/arch/sparc/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/sparc/kernel/traps.c
1679 --- linux-2.6.22.10/arch/sparc/kernel/traps.c 2007-07-09 13:18:05 +0200
1680 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc/kernel/traps.c 2007-06-15 02:37:03 +0200
1681 @@ -99,7 +99,8 @@ void die_if_kernel(char *str, struct pt_
1685 - printk("%s(%d): %s [#%d]\n", current->comm, current->pid, str, ++die_counter);
1686 + printk("%s(%d[#%u]): %s [#%d]\n", current->comm,
1687 + current->pid, current->xid, str, ++die_counter);
1690 __SAVE; __SAVE; __SAVE; __SAVE;
1691 diff -NurpP --minimal linux-2.6.22.10/arch/sparc/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/sparc/mm/fault.c
1692 --- linux-2.6.22.10/arch/sparc/mm/fault.c 2007-07-09 13:18:05 +0200
1693 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc/mm/fault.c 2007-06-15 02:37:03 +0200
1694 @@ -367,7 +367,8 @@ no_context:
1697 up_read(&mm->mmap_sem);
1698 - printk("VM: killing process %s\n", tsk->comm);
1699 + printk("VM: killing process %s(%d:#%u)\n",
1700 + tsk->comm, tsk->pid, tsk->xid);
1704 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/sparc64/Kconfig
1705 --- linux-2.6.22.10/arch/sparc64/Kconfig 2007-07-09 13:18:06 +0200
1706 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc64/Kconfig 2007-06-17 05:54:16 +0200
1707 @@ -451,6 +451,8 @@ endmenu
1709 source "arch/sparc64/Kconfig.debug"
1711 +source "kernel/vserver/Kconfig"
1713 source "security/Kconfig"
1715 source "crypto/Kconfig"
1716 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/kernel/binfmt_aout32.c linux-2.6.22.10-vs2.2.0.5/arch/sparc64/kernel/binfmt_aout32.c
1717 --- linux-2.6.22.10/arch/sparc64/kernel/binfmt_aout32.c 2007-02-06 03:00:18 +0100
1718 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc64/kernel/binfmt_aout32.c 2007-06-15 02:37:03 +0200
1720 #include <linux/binfmts.h>
1721 #include <linux/personality.h>
1722 #include <linux/init.h>
1723 +#include <linux/vs_memory.h>
1725 #include <asm/system.h>
1726 #include <asm/uaccess.h>
1727 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/sparc64/kernel/process.c
1728 --- linux-2.6.22.10/arch/sparc64/kernel/process.c 2007-07-09 13:18:06 +0200
1729 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc64/kernel/process.c 2007-06-15 02:37:03 +0200
1730 @@ -707,7 +707,8 @@ pid_t kernel_thread(int (*fn)(void *), v
1731 /* Notreached by child. */
1734 - "i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED),
1735 + "i" (__NR_clone), "r" (flags |
1736 + CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD),
1737 "i" (__NR_exit), "r" (fn), "r" (arg) :
1738 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
1740 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/kernel/ptrace.c linux-2.6.22.10-vs2.2.0.5/arch/sparc64/kernel/ptrace.c
1741 --- linux-2.6.22.10/arch/sparc64/kernel/ptrace.c 2007-02-06 03:00:18 +0100
1742 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc64/kernel/ptrace.c 2007-06-15 02:37:03 +0200
1744 #include <linux/seccomp.h>
1745 #include <linux/audit.h>
1746 #include <linux/signal.h>
1747 +#include <linux/vs_base.h>
1749 #include <asm/asi.h>
1750 #include <asm/pgtable.h>
1751 @@ -215,6 +216,10 @@ asmlinkage void do_ptrace(struct pt_regs
1752 pt_error_return(regs, -ret);
1755 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
1756 + pt_error_return(regs, ESRCH);
1760 if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
1761 || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
1762 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/kernel/sys_sparc32.c linux-2.6.22.10-vs2.2.0.5/arch/sparc64/kernel/sys_sparc32.c
1763 --- linux-2.6.22.10/arch/sparc64/kernel/sys_sparc32.c 2007-07-09 13:18:06 +0200
1764 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc64/kernel/sys_sparc32.c 2007-06-15 02:37:03 +0200
1765 @@ -729,7 +729,7 @@ asmlinkage long sys32_gettimeofday(struc
1769 - do_gettimeofday(&ktv);
1770 + vx_gettimeofday(&ktv);
1771 if (put_tv32(tv, &ktv))
1774 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/kernel/systbls.S linux-2.6.22.10-vs2.2.0.5/arch/sparc64/kernel/systbls.S
1775 --- linux-2.6.22.10/arch/sparc64/kernel/systbls.S 2007-07-09 13:18:06 +0200
1776 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc64/kernel/systbls.S 2007-06-15 02:37:03 +0200
1777 @@ -72,7 +72,7 @@ sys_call_table32:
1778 /*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
1779 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
1780 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
1781 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
1782 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
1783 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
1784 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
1785 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
1786 @@ -144,7 +144,7 @@ sys_call_table:
1787 /*250*/ .word sys64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1788 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1789 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1790 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
1791 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
1792 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
1793 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
1794 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
1795 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/sparc64/kernel/traps.c
1796 --- linux-2.6.22.10/arch/sparc64/kernel/traps.c 2007-10-30 01:57:12 +0100
1797 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc64/kernel/traps.c 2007-09-05 03:05:52 +0200
1798 @@ -2225,7 +2225,8 @@ void die_if_kernel(char *str, struct pt_
1802 - printk("%s(%d): %s [#%d]\n", current->comm, current->pid, str, ++die_counter);
1803 + printk("%s(%d[#%u]): %s [#%d]\n", current->comm,
1804 + current->pid, current->xid, str, ++die_counter);
1805 notify_die(DIE_OOPS, str, regs, 0, 255, SIGSEGV);
1806 __asm__ __volatile__("flushw");
1808 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/sparc64/mm/fault.c
1809 --- linux-2.6.22.10/arch/sparc64/mm/fault.c 2007-10-30 01:57:12 +0100
1810 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc64/mm/fault.c 2007-09-05 03:05:52 +0200
1811 @@ -463,7 +463,8 @@ handle_kernel_fault:
1813 insn = get_fault_insn(regs, insn);
1814 up_read(&mm->mmap_sem);
1815 - printk("VM: killing process %s\n", current->comm);
1816 + printk("VM: killing process %s(%d:#%u)\n",
1817 + current->comm, current->pid, current->xid);
1818 if (!(regs->tstate & TSTATE_PRIV))
1820 goto handle_kernel_fault;
1821 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/solaris/fs.c linux-2.6.22.10-vs2.2.0.5/arch/sparc64/solaris/fs.c
1822 --- linux-2.6.22.10/arch/sparc64/solaris/fs.c 2007-02-06 03:00:21 +0100
1823 +++ linux-2.6.22.10-vs2.2.0.5/arch/sparc64/solaris/fs.c 2007-06-15 02:37:03 +0200
1824 @@ -368,7 +368,7 @@ static int report_statvfs(struct vfsmoun
1828 - if (IS_RDONLY(inode)) i = 1;
1829 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1;
1830 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
1831 if (!sysv_valid_dev(inode->i_sb->s_dev))
1833 @@ -404,7 +404,7 @@ static int report_statvfs64(struct vfsmo
1837 - if (IS_RDONLY(inode)) i = 1;
1838 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1;
1839 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
1840 if (!sysv_valid_dev(inode->i_sb->s_dev))
1842 diff -NurpP --minimal linux-2.6.22.10/arch/um/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/um/Kconfig
1843 --- linux-2.6.22.10/arch/um/Kconfig 2007-07-09 13:18:07 +0200
1844 +++ linux-2.6.22.10-vs2.2.0.5/arch/um/Kconfig 2007-06-17 05:54:16 +0200
1845 @@ -316,6 +316,8 @@ source "drivers/connector/Kconfig"
1849 +source "kernel/vserver/Kconfig"
1851 source "security/Kconfig"
1853 source "crypto/Kconfig"
1854 diff -NurpP --minimal linux-2.6.22.10/arch/um/kernel/trap.c linux-2.6.22.10-vs2.2.0.5/arch/um/kernel/trap.c
1855 --- linux-2.6.22.10/arch/um/kernel/trap.c 2007-07-09 13:18:07 +0200
1856 +++ linux-2.6.22.10-vs2.2.0.5/arch/um/kernel/trap.c 2007-06-15 02:37:03 +0200
1857 @@ -210,7 +210,8 @@ unsigned long segv(struct faultinfo fi,
1858 current->thread.arch.faultinfo = fi;
1859 force_sig_info(SIGBUS, &si, current);
1860 } else if (err == -ENOMEM) {
1861 - printk("VM: killing process %s\n", current->comm);
1862 + printk("VM: killing process %s(%d:#%u)\n",
1863 + current->comm, current->pid, current->xid);
1866 BUG_ON(err != -EFAULT);
1867 diff -NurpP --minimal linux-2.6.22.10/arch/v850/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/v850/Kconfig
1868 --- linux-2.6.22.10/arch/v850/Kconfig 2007-07-09 13:18:08 +0200
1869 +++ linux-2.6.22.10-vs2.2.0.5/arch/v850/Kconfig 2007-06-15 02:37:03 +0200
1870 @@ -333,6 +333,8 @@ source "drivers/usb/Kconfig"
1872 source "arch/v850/Kconfig.debug"
1874 +source "kernel/vserver/Kconfig"
1876 source "security/Kconfig"
1878 source "crypto/Kconfig"
1879 diff -NurpP --minimal linux-2.6.22.10/arch/v850/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/v850/kernel/process.c
1880 --- linux-2.6.22.10/arch/v850/kernel/process.c 2007-07-09 13:18:08 +0200
1881 +++ linux-2.6.22.10-vs2.2.0.5/arch/v850/kernel/process.c 2007-06-15 02:37:03 +0200
1882 @@ -82,7 +82,7 @@ int kernel_thread (int (*fn)(void *), vo
1883 /* Clone this thread. Note that we don't pass the clone syscall's
1884 second argument -- it's ignored for calls from kernel mode (the
1885 child's SP is always set to the top of the kernel stack). */
1886 - arg0 = flags | CLONE_VM;
1887 + arg0 = flags | CLONE_VM | CLONE_KTHREAD;
1888 syscall = __NR_clone;
1889 asm volatile ("trap " SYSCALL_SHORT_TRAP
1890 : "=r" (ret), "=r" (syscall)
1891 diff -NurpP --minimal linux-2.6.22.10/arch/v850/kernel/ptrace.c linux-2.6.22.10-vs2.2.0.5/arch/v850/kernel/ptrace.c
1892 --- linux-2.6.22.10/arch/v850/kernel/ptrace.c 2007-07-09 13:18:08 +0200
1893 +++ linux-2.6.22.10-vs2.2.0.5/arch/v850/kernel/ptrace.c 2007-06-15 02:37:03 +0200
1895 #include <linux/sched.h>
1896 #include <linux/ptrace.h>
1897 #include <linux/signal.h>
1898 +#include <linux/vs_base.h>
1900 #include <asm/errno.h>
1901 #include <asm/ptrace.h>
1902 @@ -116,6 +117,9 @@ long arch_ptrace(struct task_struct *chi
1906 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
1910 unsigned long val, copied;
1912 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/Kconfig linux-2.6.22.10-vs2.2.0.5/arch/x86_64/Kconfig
1913 --- linux-2.6.22.10/arch/x86_64/Kconfig 2007-07-09 13:18:08 +0200
1914 +++ linux-2.6.22.10-vs2.2.0.5/arch/x86_64/Kconfig 2007-06-15 02:37:03 +0200
1915 @@ -782,6 +782,8 @@ endmenu
1917 source "arch/x86_64/Kconfig.debug"
1919 +source "kernel/vserver/Kconfig"
1921 source "security/Kconfig"
1923 source "crypto/Kconfig"
1924 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/ia32/ia32_aout.c linux-2.6.22.10-vs2.2.0.5/arch/x86_64/ia32/ia32_aout.c
1925 --- linux-2.6.22.10/arch/x86_64/ia32/ia32_aout.c 2007-02-06 03:00:21 +0100
1926 +++ linux-2.6.22.10-vs2.2.0.5/arch/x86_64/ia32/ia32_aout.c 2007-06-15 02:37:03 +0200
1928 #include <linux/binfmts.h>
1929 #include <linux/personality.h>
1930 #include <linux/init.h>
1931 +#include <linux/vs_memory.h>
1933 #include <asm/system.h>
1934 #include <asm/uaccess.h>
1935 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/ia32/ia32_binfmt.c linux-2.6.22.10-vs2.2.0.5/arch/x86_64/ia32/ia32_binfmt.c
1936 --- linux-2.6.22.10/arch/x86_64/ia32/ia32_binfmt.c 2007-07-09 13:18:08 +0200
1937 +++ linux-2.6.22.10-vs2.2.0.5/arch/x86_64/ia32/ia32_binfmt.c 2007-06-15 02:37:03 +0200
1938 @@ -324,7 +324,8 @@ int ia32_setup_arg_pages(struct linux_bi
1939 kmem_cache_free(vm_area_cachep, mpnt);
1942 - mm->stack_vm = mm->total_vm = vma_pages(mpnt);
1943 + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt));
1944 + mm->stack_vm = mm->total_vm;
1947 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
1948 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/ia32/ia32entry.S linux-2.6.22.10-vs2.2.0.5/arch/x86_64/ia32/ia32entry.S
1949 --- linux-2.6.22.10/arch/x86_64/ia32/ia32entry.S 2007-10-30 01:57:12 +0100
1950 +++ linux-2.6.22.10-vs2.2.0.5/arch/x86_64/ia32/ia32entry.S 2007-10-01 15:25:34 +0200
1951 @@ -680,7 +680,7 @@ ia32_sys_call_table:
1952 .quad sys_tgkill /* 270 */
1953 .quad compat_sys_utimes
1954 .quad sys32_fadvise64_64
1955 - .quad quiet_ni_syscall /* sys_vserver */
1956 + .quad sys32_vserver
1958 .quad compat_sys_get_mempolicy /* 275 */
1959 .quad sys_set_mempolicy
1960 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/ia32/sys_ia32.c linux-2.6.22.10-vs2.2.0.5/arch/x86_64/ia32/sys_ia32.c
1961 --- linux-2.6.22.10/arch/x86_64/ia32/sys_ia32.c 2007-07-09 13:18:08 +0200
1962 +++ linux-2.6.22.10-vs2.2.0.5/arch/x86_64/ia32/sys_ia32.c 2007-07-07 03:52:53 +0200
1963 @@ -454,7 +454,7 @@ sys32_gettimeofday(struct compat_timeval
1967 - do_gettimeofday(&ktv);
1968 + vx_gettimeofday(&ktv);
1969 if (put_tv32(tv, &ktv))
1972 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/ia32/syscall32.c linux-2.6.22.10-vs2.2.0.5/arch/x86_64/ia32/syscall32.c
1973 --- linux-2.6.22.10/arch/x86_64/ia32/syscall32.c 2007-07-09 13:18:08 +0200
1974 +++ linux-2.6.22.10-vs2.2.0.5/arch/x86_64/ia32/syscall32.c 2007-06-15 02:37:03 +0200
1976 #include <linux/init.h>
1977 #include <linux/stringify.h>
1978 #include <linux/security.h>
1979 +#include <linux/vs_memory.h>
1980 #include <asm/proto.h>
1981 #include <asm/tlbflush.h>
1982 #include <asm/ia32_unistd.h>
1983 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/kernel/process.c linux-2.6.22.10-vs2.2.0.5/arch/x86_64/kernel/process.c
1984 --- linux-2.6.22.10/arch/x86_64/kernel/process.c 2007-07-09 13:18:08 +0200
1985 +++ linux-2.6.22.10-vs2.2.0.5/arch/x86_64/kernel/process.c 2007-06-15 02:37:03 +0200
1988 asmlinkage extern void ret_from_fork(void);
1990 -unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
1991 +unsigned long kernel_thread_flags =
1992 + CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD;
1994 unsigned long boot_option_idle_override = 0;
1995 EXPORT_SYMBOL(boot_option_idle_override);
1996 @@ -310,8 +311,8 @@ void __show_regs(struct pt_regs * regs)
2000 - printk("Pid: %d, comm: %.20s %s %s %.*s\n",
2001 - current->pid, current->comm, print_tainted(),
2002 + printk("Pid: %d:#%u, comm: %.20s %s %s %.*s\n",
2003 + current->pid, current->xid, current->comm, print_tainted(),
2004 init_utsname()->release,
2005 (int)strcspn(init_utsname()->version, " "),
2006 init_utsname()->version);
2007 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/kernel/traps.c linux-2.6.22.10-vs2.2.0.5/arch/x86_64/kernel/traps.c
2008 --- linux-2.6.22.10/arch/x86_64/kernel/traps.c 2007-07-09 13:18:08 +0200
2009 +++ linux-2.6.22.10-vs2.2.0.5/arch/x86_64/kernel/traps.c 2007-06-17 05:54:16 +0200
2010 @@ -413,8 +413,9 @@ void show_registers(struct pt_regs *regs
2012 printk("CPU %d ", cpu);
2014 - printk("Process %s (pid: %d, threadinfo %p, task %p)\n",
2015 - cur->comm, cur->pid, task_thread_info(cur), cur);
2016 + printk("Process %s (pid: %d[#%u], threadinfo %p, task %p)\n",
2017 + cur->comm, cur->pid, cur->xid,
2018 + task_thread_info(cur), cur);
2021 * When in-kernel, we also print out the stack and code at the
2022 @@ -580,8 +581,8 @@ static void __kprobes do_trap(int trapnr
2024 if (exception_trace && unhandled_signal(tsk, signr))
2026 - "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
2027 - tsk->comm, tsk->pid, str,
2028 + "%s[%d:#%u] trap %s rip:%lx rsp:%lx error:%lx\n",
2029 + tsk->comm, tsk->pid, tsk->xid, str,
2030 regs->rip, regs->rsp, error_code);
2033 @@ -684,8 +685,8 @@ asmlinkage void __kprobes do_general_pro
2035 if (exception_trace && unhandled_signal(tsk, SIGSEGV))
2037 - "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
2038 - tsk->comm, tsk->pid,
2039 + "%s[%d:#%u] general protection rip:%lx rsp:%lx error:%lx\n",
2040 + tsk->comm, tsk->pid, tsk->xid,
2041 regs->rip, regs->rsp, error_code);
2043 force_sig(SIGSEGV, tsk);
2044 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/mm/fault.c linux-2.6.22.10-vs2.2.0.5/arch/x86_64/mm/fault.c
2045 --- linux-2.6.22.10/arch/x86_64/mm/fault.c 2007-07-09 13:18:08 +0200
2046 +++ linux-2.6.22.10-vs2.2.0.5/arch/x86_64/mm/fault.c 2007-06-17 05:54:16 +0200
2047 @@ -497,10 +497,10 @@ bad_area_nosemaphore:
2049 if (exception_trace && unhandled_signal(tsk, SIGSEGV)) {
2051 - "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
2052 + "%s%s[%d:#%u]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
2053 tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
2054 - tsk->comm, tsk->pid, address, regs->rip,
2055 - regs->rsp, error_code);
2056 + tsk->comm, tsk->pid, tsk->xid, address,
2057 + regs->rip, regs->rsp, error_code);
2060 tsk->thread.cr2 = address;
2061 @@ -567,7 +567,8 @@ out_of_memory:
2065 - printk("VM: killing process %s\n", tsk->comm);
2066 + printk("VM: killing process %s(%d:#%u)\n",
2067 + tsk->comm, tsk->pid, tsk->xid);
2071 diff -NurpP --minimal linux-2.6.22.10/drivers/block/Kconfig linux-2.6.22.10-vs2.2.0.5/drivers/block/Kconfig
2072 --- linux-2.6.22.10/drivers/block/Kconfig 2007-07-09 13:18:16 +0200
2073 +++ linux-2.6.22.10-vs2.2.0.5/drivers/block/Kconfig 2007-06-15 02:37:03 +0200
2074 @@ -311,6 +311,13 @@ config BLK_DEV_CRYPTOLOOP
2075 instead, which can be configured to be on-disk compatible with the
2078 +config BLK_DEV_VROOT
2079 + tristate "Virtual Root device support"
2080 + depends on QUOTACTL
2082 + Saying Y here will allow you to use quota/fs ioctls on a shared
2083 + partition within a virtual server without compromising security.
2086 tristate "Network block device support"
2088 diff -NurpP --minimal linux-2.6.22.10/drivers/block/Makefile linux-2.6.22.10-vs2.2.0.5/drivers/block/Makefile
2089 --- linux-2.6.22.10/drivers/block/Makefile 2007-02-06 03:00:26 +0100
2090 +++ linux-2.6.22.10-vs2.2.0.5/drivers/block/Makefile 2007-06-15 02:37:03 +0200
2091 @@ -28,4 +28,5 @@ obj-$(CONFIG_BLK_DEV_CRYPTOLOOP) += cryp
2092 obj-$(CONFIG_VIODASD) += viodasd.o
2093 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
2094 obj-$(CONFIG_BLK_DEV_UB) += ub.o
2095 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
2097 diff -NurpP --minimal linux-2.6.22.10/drivers/block/loop.c linux-2.6.22.10-vs2.2.0.5/drivers/block/loop.c
2098 --- linux-2.6.22.10/drivers/block/loop.c 2007-07-09 13:18:16 +0200
2099 +++ linux-2.6.22.10-vs2.2.0.5/drivers/block/loop.c 2007-08-16 04:07:14 +0200
2101 #include <linux/highmem.h>
2102 #include <linux/gfp.h>
2103 #include <linux/kthread.h>
2104 +#include <linux/vs_context.h>
2106 #include <asm/uaccess.h>
2108 @@ -790,6 +791,7 @@ static int loop_set_fd(struct loop_devic
2109 lo->lo_blocksize = lo_blocksize;
2110 lo->lo_device = bdev;
2111 lo->lo_flags = lo_flags;
2112 + lo->lo_xid = vx_current_xid();
2113 lo->lo_backing_file = file;
2114 lo->transfer = transfer_none;
2116 @@ -909,6 +911,7 @@ static int loop_clr_fd(struct loop_devic
2117 lo->lo_encrypt_key_size = 0;
2119 lo->lo_thread = NULL;
2121 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
2122 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
2123 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
2124 @@ -930,7 +933,7 @@ loop_set_status(struct loop_device *lo,
2125 struct loop_func_table *xfer;
2127 if (lo->lo_encrypt_key_size && lo->lo_key_owner != current->uid &&
2128 - !capable(CAP_SYS_ADMIN))
2129 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
2131 if (lo->lo_state != Lo_bound)
2133 @@ -1010,7 +1013,8 @@ loop_get_status(struct loop_device *lo,
2134 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
2135 info->lo_encrypt_type =
2136 lo->lo_encryption ? lo->lo_encryption->number : 0;
2137 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
2138 + if (lo->lo_encrypt_key_size &&
2139 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
2140 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
2141 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
2142 lo->lo_encrypt_key_size);
2143 @@ -1321,6 +1325,9 @@ static int lo_open(struct inode *inode,
2145 struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
2147 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID))
2150 mutex_lock(&lo->lo_ctl_mutex);
2152 mutex_unlock(&lo->lo_ctl_mutex);
2153 diff -NurpP --minimal linux-2.6.22.10/drivers/block/vroot.c linux-2.6.22.10-vs2.2.0.5/drivers/block/vroot.c
2154 --- linux-2.6.22.10/drivers/block/vroot.c 1970-01-01 01:00:00 +0100
2155 +++ linux-2.6.22.10-vs2.2.0.5/drivers/block/vroot.c 2007-06-15 02:37:03 +0200
2158 + * linux/drivers/block/vroot.c
2160 + * written by Herbert Pötzl, 9/11/2002
2161 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
2163 + * based on the loop.c code by Theodore Ts'o.
2165 + * Copyright (C) 2002-2007 by Herbert Pötzl.
2166 + * Redistribution of this file is permitted under the
2167 + * GNU General Public License.
2171 +#include <linux/module.h>
2172 +#include <linux/moduleparam.h>
2173 +#include <linux/file.h>
2174 +#include <linux/major.h>
2175 +#include <linux/blkdev.h>
2177 +#include <linux/vroot.h>
2178 +#include <linux/vs_context.h>
2181 +static int max_vroot = 8;
2183 +static struct vroot_device *vroot_dev;
2184 +static struct gendisk **disks;
2187 +static int vroot_set_dev(
2188 + struct vroot_device *vr,
2189 + struct file *vr_file,
2190 + struct block_device *bdev,
2193 + struct block_device *real_bdev;
2194 + struct file *file;
2195 + struct inode *inode;
2199 + if (vr->vr_state != Vr_unbound)
2208 + inode = file->f_dentry->d_inode;
2211 + if (S_ISBLK(inode->i_mode)) {
2212 + real_bdev = inode->i_bdev;
2213 + vr->vr_device = real_bdev;
2214 + __iget(real_bdev->bd_inode);
2218 + vxdprintk(VXD_CBIT(misc, 0),
2219 + "vroot[%d]_set_dev: dev=" VXF_DEV,
2220 + vr->vr_number, VXD_DEV(real_bdev));
2222 + vr->vr_state = Vr_bound;
2231 +static int vroot_clr_dev(
2232 + struct vroot_device *vr,
2233 + struct file *vr_file,
2234 + struct block_device *bdev)
2236 + struct block_device *real_bdev;
2238 + if (vr->vr_state != Vr_bound)
2240 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
2243 + real_bdev = vr->vr_device;
2245 + vxdprintk(VXD_CBIT(misc, 0),
2246 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
2247 + vr->vr_number, VXD_DEV(real_bdev));
2250 + vr->vr_state = Vr_unbound;
2251 + vr->vr_device = NULL;
2256 +static int vr_ioctl(struct inode *inode, struct file *file,
2257 + unsigned int cmd, unsigned long arg)
2259 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
2262 + down(&vr->vr_ctl_mutex);
2264 + case VROOT_SET_DEV:
2265 + err = vroot_set_dev(vr, file, inode->i_bdev, arg);
2267 + case VROOT_CLR_DEV:
2268 + err = vroot_clr_dev(vr, file, inode->i_bdev);
2274 + up(&vr->vr_ctl_mutex);
2278 +static int vr_open(struct inode *inode, struct file *file)
2280 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
2282 + down(&vr->vr_ctl_mutex);
2284 + up(&vr->vr_ctl_mutex);
2288 +static int vr_release(struct inode *inode, struct file *file)
2290 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
2292 + down(&vr->vr_ctl_mutex);
2294 + up(&vr->vr_ctl_mutex);
2298 +static struct block_device_operations vr_fops = {
2299 + .owner = THIS_MODULE,
2301 + .release = vr_release,
2302 + .ioctl = vr_ioctl,
2305 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
2307 + struct inode *inode = bdev->bd_inode;
2308 + struct vroot_device *vr;
2309 + struct block_device *real_bdev;
2310 + int minor = iminor(inode);
2312 + vr = &vroot_dev[minor];
2313 + real_bdev = vr->vr_device;
2315 + vxdprintk(VXD_CBIT(misc, 0),
2316 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
2317 + vr->vr_number, VXD_DEV(real_bdev));
2319 + if (vr->vr_state != Vr_bound)
2320 + return ERR_PTR(-ENXIO);
2322 + __iget(real_bdev->bd_inode);
2327 + * And now the modules code and kernel interface.
2330 +module_param(max_vroot, int, 0);
2332 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
2333 +MODULE_LICENSE("GPL");
2334 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
2336 +MODULE_AUTHOR ("Herbert Pötzl");
2337 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
2340 +int __init vroot_init(void)
2344 + if (max_vroot < 1 || max_vroot > 256) {
2345 + max_vroot = MAX_VROOT_DEFAULT;
2346 + printk(KERN_WARNING "vroot: invalid max_vroot "
2347 + "(must be between 1 and 256), "
2348 + "using default (%d)\n", max_vroot);
2351 + if (register_blkdev(VROOT_MAJOR, "vroot"))
2355 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
2358 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
2360 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
2364 + for (i = 0; i < max_vroot; i++) {
2365 + disks[i] = alloc_disk(1);
2370 + for (i = 0; i < max_vroot; i++) {
2371 + struct vroot_device *vr = &vroot_dev[i];
2372 + struct gendisk *disk = disks[i];
2374 + memset(vr, 0, sizeof(*vr));
2375 + init_MUTEX(&vr->vr_ctl_mutex);
2376 + vr->vr_number = i;
2377 + disk->major = VROOT_MAJOR;
2378 + disk->first_minor = i;
2379 + disk->fops = &vr_fops;
2380 + sprintf(disk->disk_name, "vroot%d", i);
2381 + disk->private_data = vr;
2384 + err = register_vroot_grb(&__vroot_get_real_bdev);
2388 + for (i = 0; i < max_vroot; i++)
2389 + add_disk(disks[i]);
2390 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
2395 + put_disk(disks[i]);
2400 + unregister_blkdev(VROOT_MAJOR, "vroot");
2401 + printk(KERN_ERR "vroot: ran out of memory\n");
2405 +void vroot_exit(void)
2409 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
2410 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
2412 + for (i = 0; i < max_vroot; i++) {
2413 + del_gendisk(disks[i]);
2414 + put_disk(disks[i]);
2416 + if (unregister_blkdev(VROOT_MAJOR, "vroot"))
2417 + printk(KERN_WARNING "vroot: cannot unregister blkdev\n");
2423 +module_init(vroot_init);
2424 +module_exit(vroot_exit);
2428 +static int __init max_vroot_setup(char *str)
2430 + max_vroot = simple_strtol(str, NULL, 0);
2434 +__setup("max_vroot=", max_vroot_setup);
2438 diff -NurpP --minimal linux-2.6.22.10/drivers/char/sysrq.c linux-2.6.22.10-vs2.2.0.5/drivers/char/sysrq.c
2439 --- linux-2.6.22.10/drivers/char/sysrq.c 2007-07-09 13:18:20 +0200
2440 +++ linux-2.6.22.10-vs2.2.0.5/drivers/char/sysrq.c 2007-06-15 02:37:03 +0200
2442 #include <linux/kexec.h>
2443 #include <linux/irq.h>
2444 #include <linux/hrtimer.h>
2445 +#include <linux/vserver/debug.h>
2447 #include <asm/ptrace.h>
2448 #include <asm/irq_regs.h>
2449 @@ -309,6 +310,21 @@ static struct sysrq_key_op sysrq_unrt_op
2450 .enable_mask = SYSRQ_ENABLE_RTNICE,
2454 +#ifdef CONFIG_VSERVER_DEBUG
2455 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
2457 + dump_vx_info_inactive((key == 'x')?0:1);
2460 +static struct sysrq_key_op sysrq_showvxinfo_op = {
2461 + .handler = sysrq_handle_vxinfo,
2462 + .help_msg = "conteXt",
2463 + .action_msg = "Show Context Info",
2464 + .enable_mask = SYSRQ_ENABLE_DUMP,
2468 /* Key Operations table and lock */
2469 static DEFINE_SPINLOCK(sysrq_key_table_lock);
2471 @@ -357,7 +373,11 @@ static struct sysrq_key_op *sysrq_key_ta
2472 /* x: May be registered on ppc/powerpc for xmon */
2476 +#ifdef CONFIG_VSERVER_DEBUG
2477 + &sysrq_showvxinfo_op, /* z */
2483 /* key2index calculation, -1 on invalid index */
2484 @@ -369,6 +389,8 @@ static int sysrq_key_table_key2index(int
2486 else if ((key >= 'a') && (key <= 'z'))
2487 retval = key + 10 - 'a';
2488 + else if ((key >= 'A') && (key <= 'Z'))
2489 + retval = key + 10 - 'A';
2493 diff -NurpP --minimal linux-2.6.22.10/drivers/char/tty_io.c linux-2.6.22.10-vs2.2.0.5/drivers/char/tty_io.c
2494 --- linux-2.6.22.10/drivers/char/tty_io.c 2007-07-09 13:18:20 +0200
2495 +++ linux-2.6.22.10-vs2.2.0.5/drivers/char/tty_io.c 2007-07-17 03:02:15 +0200
2497 #include <linux/selection.h>
2499 #include <linux/kmod.h>
2500 +#include <linux/vs_pid.h>
2502 #undef TTY_DEBUG_HANGUP
2504 @@ -3049,13 +3050,15 @@ unlock:
2506 static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
2510 * (tty == real_tty) is a cheap way of
2511 * testing if the tty is NOT a master pty.
2513 if (tty == real_tty && current->signal->tty != real_tty)
2515 - return put_user(pid_nr(real_tty->pgrp), p);
2516 + pgrp = vx_map_pid(pid_nr(real_tty->pgrp));
2517 + return put_user(pgrp, p);
2521 @@ -3086,6 +3089,7 @@ static int tiocspgrp(struct tty_struct *
2523 if (get_user(pgrp_nr, p))
2525 + pgrp_nr = vx_rmap_pid(pgrp_nr);
2529 diff -NurpP --minimal linux-2.6.22.10/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.22.10-vs2.2.0.5/drivers/infiniband/hw/ipath/ipath_user_pages.c
2530 --- linux-2.6.22.10/drivers/infiniband/hw/ipath/ipath_user_pages.c 2007-02-06 03:00:37 +0100
2531 +++ linux-2.6.22.10-vs2.2.0.5/drivers/infiniband/hw/ipath/ipath_user_pages.c 2007-06-15 02:37:03 +0200
2534 #include <linux/mm.h>
2535 #include <linux/device.h>
2536 +#include <linux/vs_memory.h>
2538 #include "ipath_kernel.h"
2540 @@ -61,7 +62,8 @@ static int __get_user_pages(unsigned lon
2541 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
2544 - if (num_pages > lock_limit) {
2545 + if (num_pages > lock_limit ||
2546 + !vx_vmlocked_avail(current->mm, num_pages)) {
2550 @@ -78,7 +80,7 @@ static int __get_user_pages(unsigned lon
2554 - current->mm->locked_vm += num_pages;
2555 + vx_vmlocked_add(current->mm, num_pages);
2559 @@ -203,7 +205,7 @@ void ipath_release_user_pages(struct pag
2561 __ipath_release_user_pages(p, num_pages, 1);
2563 - current->mm->locked_vm -= num_pages;
2564 + vx_vmlocked_sub(current->mm, num_pages);
2566 up_write(¤t->mm->mmap_sem);
2568 @@ -220,7 +222,7 @@ static void user_pages_account(struct wo
2569 container_of(_work, struct ipath_user_pages_work, work);
2571 down_write(&work->mm->mmap_sem);
2572 - work->mm->locked_vm -= work->num_pages;
2573 + vx_vmlocked_sub(work->mm, work->num_pages);
2574 up_write(&work->mm->mmap_sem);
2577 diff -NurpP --minimal linux-2.6.22.10/drivers/md/dm-ioctl.c linux-2.6.22.10-vs2.2.0.5/drivers/md/dm-ioctl.c
2578 --- linux-2.6.22.10/drivers/md/dm-ioctl.c 2007-05-02 19:24:50 +0200
2579 +++ linux-2.6.22.10-vs2.2.0.5/drivers/md/dm-ioctl.c 2007-06-15 02:37:03 +0200
2581 #include <linux/slab.h>
2582 #include <linux/dm-ioctl.h>
2583 #include <linux/hdreg.h>
2584 +#include <linux/vs_context.h>
2586 #include <asm/uaccess.h>
2588 @@ -100,7 +101,8 @@ static struct hash_cell *__get_name_cell
2589 unsigned int h = hash_str(str);
2591 list_for_each_entry (hc, _name_buckets + h, name_list)
2592 - if (!strcmp(hc->name, str)) {
2593 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
2594 + !strcmp(hc->name, str)) {
2598 @@ -114,7 +116,8 @@ static struct hash_cell *__get_uuid_cell
2599 unsigned int h = hash_str(str);
2601 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
2602 - if (!strcmp(hc->uuid, str)) {
2603 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
2604 + !strcmp(hc->uuid, str)) {
2608 @@ -349,6 +352,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
2610 static int remove_all(struct dm_ioctl *param, size_t param_size)
2612 + if (!vx_check(0, VS_ADMIN))
2615 dm_hash_remove_all(1);
2616 param->data_size = 0;
2618 @@ -396,6 +402,8 @@ static int list_devices(struct dm_ioctl
2620 for (i = 0; i < NUM_BUCKETS; i++) {
2621 list_for_each_entry (hc, _name_buckets + i, name_list) {
2622 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2624 needed += sizeof(struct dm_name_list);
2625 needed += strlen(hc->name) + 1;
2626 needed += ALIGN_MASK;
2627 @@ -419,6 +427,8 @@ static int list_devices(struct dm_ioctl
2629 for (i = 0; i < NUM_BUCKETS; i++) {
2630 list_for_each_entry (hc, _name_buckets + i, name_list) {
2631 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2634 old_nl->next = (uint32_t) ((void *) nl -
2636 @@ -609,10 +619,11 @@ static struct hash_cell *__find_device_h
2640 - mdptr = dm_get_mdptr(md);
2641 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
2642 + mdptr = dm_get_mdptr(md);
2650 @@ -1409,8 +1420,8 @@ static int ctl_ioctl(struct inode *inode
2654 - /* only root can play with this */
2655 - if (!capable(CAP_SYS_ADMIN))
2656 + /* only root and certain contexts can play with this */
2657 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
2660 if (_IOC_TYPE(command) != DM_IOCTL)
2661 diff -NurpP --minimal linux-2.6.22.10/drivers/md/dm.c linux-2.6.22.10-vs2.2.0.5/drivers/md/dm.c
2662 --- linux-2.6.22.10/drivers/md/dm.c 2007-10-30 01:57:13 +0100
2663 +++ linux-2.6.22.10-vs2.2.0.5/drivers/md/dm.c 2007-08-12 12:21:50 +0200
2665 #include <linux/hdreg.h>
2666 #include <linux/blktrace_api.h>
2667 #include <linux/smp_lock.h>
2668 +#include <linux/vs_base.h>
2670 #define DM_MSG_PREFIX "core"
2672 @@ -77,6 +78,7 @@ struct mapped_device {
2675 atomic_t open_count;
2678 unsigned long flags;
2680 @@ -223,6 +225,7 @@ static void __exit dm_exit(void)
2681 static int dm_blk_open(struct inode *inode, struct file *file)
2683 struct mapped_device *md;
2686 spin_lock(&_minor_lock);
2688 @@ -231,18 +234,19 @@ static int dm_blk_open(struct inode *ino
2691 if (test_bit(DMF_FREEING, &md->flags) ||
2692 - test_bit(DMF_DELETING, &md->flags)) {
2694 + test_bit(DMF_DELETING, &md->flags))
2698 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
2703 atomic_inc(&md->open_count);
2707 spin_unlock(&_minor_lock);
2709 - return md ? 0 : -ENXIO;
2713 static int dm_blk_close(struct inode *inode, struct file *file)
2714 @@ -438,6 +442,14 @@ int dm_set_geometry(struct mapped_device
2719 + * Get the xid associated with a dm device
2721 +xid_t dm_get_xid(struct mapped_device *md)
2726 /*-----------------------------------------------------------------
2728 * A more elegant soln is in the works that uses the queue
2729 @@ -1000,6 +1012,7 @@ static struct mapped_device *alloc_dev(i
2730 atomic_set(&md->holders, 1);
2731 atomic_set(&md->open_count, 0);
2732 atomic_set(&md->event_nr, 0);
2733 + md->xid = vx_current_xid();
2735 md->queue = blk_alloc_queue(GFP_KERNEL);
2737 diff -NurpP --minimal linux-2.6.22.10/drivers/md/dm.h linux-2.6.22.10-vs2.2.0.5/drivers/md/dm.h
2738 --- linux-2.6.22.10/drivers/md/dm.h 2007-02-06 03:00:41 +0100
2739 +++ linux-2.6.22.10-vs2.2.0.5/drivers/md/dm.h 2007-06-15 02:37:03 +0200
2740 @@ -91,6 +91,8 @@ void dm_put_target_type(struct target_ty
2741 int dm_target_iterate(void (*iter_func)(struct target_type *tt,
2742 void *param), void *param);
2744 +xid_t dm_get_xid(struct mapped_device *md);
2746 /*-----------------------------------------------------------------
2748 *---------------------------------------------------------------*/
2749 diff -NurpP --minimal linux-2.6.22.10/fs/attr.c linux-2.6.22.10-vs2.2.0.5/fs/attr.c
2750 --- linux-2.6.22.10/fs/attr.c 2007-07-09 13:19:22 +0200
2751 +++ linux-2.6.22.10-vs2.2.0.5/fs/attr.c 2007-10-29 23:34:23 +0100
2753 #include <linux/fcntl.h>
2754 #include <linux/quotaops.h>
2755 #include <linux/security.h>
2756 +#include <linux/proc_fs.h>
2757 +#include <linux/devpts_fs.h>
2758 +#include <linux/vs_base.h>
2760 /* Taken over from the old code... */
2762 @@ -55,6 +58,27 @@ int inode_change_ok(struct inode *inode,
2763 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
2767 + /* Check for evil vserver activity */
2768 + if (vx_check(0, VS_ADMIN))
2771 + if (IS_BARRIER(inode)) {
2772 + vxwprintk_task(1, "messing with the barrier.");
2775 + switch (inode->i_sb->s_magic) {
2776 + case PROC_SUPER_MAGIC:
2777 + /* maybe allow that in the future? */
2778 + vxwprintk_task(1, "messing with the procfs.");
2780 + case DEVPTS_SUPER_MAGIC:
2781 + /* devpts is xid tagged */
2782 + if (vx_check((xid_t)inode->i_tag, VS_IDENT))
2784 + vxwprintk_task(1, "messing with the devpts.");
2790 @@ -78,6 +102,8 @@ int inode_setattr(struct inode * inode,
2791 inode->i_uid = attr->ia_uid;
2792 if (ia_valid & ATTR_GID)
2793 inode->i_gid = attr->ia_gid;
2794 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2795 + inode->i_tag = attr->ia_tag;
2796 if (ia_valid & ATTR_ATIME)
2797 inode->i_atime = timespec_trunc(attr->ia_atime,
2798 inode->i_sb->s_time_gran);
2799 @@ -152,7 +178,8 @@ int notify_change(struct dentry * dentry
2800 error = security_inode_setattr(dentry, attr);
2802 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2803 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
2804 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2805 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
2806 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
2808 error = inode_setattr(inode, attr);
2809 diff -NurpP --minimal linux-2.6.22.10/fs/binfmt_aout.c linux-2.6.22.10-vs2.2.0.5/fs/binfmt_aout.c
2810 --- linux-2.6.22.10/fs/binfmt_aout.c 2007-02-06 03:01:16 +0100
2811 +++ linux-2.6.22.10-vs2.2.0.5/fs/binfmt_aout.c 2007-06-15 02:37:03 +0200
2813 #include <linux/binfmts.h>
2814 #include <linux/personality.h>
2815 #include <linux/init.h>
2816 +#include <linux/vs_memory.h>
2818 #include <asm/system.h>
2819 #include <asm/uaccess.h>
2820 diff -NurpP --minimal linux-2.6.22.10/fs/binfmt_elf.c linux-2.6.22.10-vs2.2.0.5/fs/binfmt_elf.c
2821 --- linux-2.6.22.10/fs/binfmt_elf.c 2007-07-09 13:19:22 +0200
2822 +++ linux-2.6.22.10-vs2.2.0.5/fs/binfmt_elf.c 2007-07-09 13:11:54 +0200
2824 #include <linux/random.h>
2825 #include <linux/elf.h>
2826 #include <linux/utsname.h>
2827 +#include <linux/vs_memory.h>
2828 #include <asm/uaccess.h>
2829 #include <asm/param.h>
2830 #include <asm/page.h>
2831 diff -NurpP --minimal linux-2.6.22.10/fs/binfmt_flat.c linux-2.6.22.10-vs2.2.0.5/fs/binfmt_flat.c
2832 --- linux-2.6.22.10/fs/binfmt_flat.c 2007-07-09 13:19:22 +0200
2833 +++ linux-2.6.22.10-vs2.2.0.5/fs/binfmt_flat.c 2007-06-17 05:54:17 +0200
2835 #include <linux/init.h>
2836 #include <linux/flat.h>
2837 #include <linux/syscalls.h>
2838 +#include <linux/vs_memory.h>
2840 #include <asm/byteorder.h>
2841 #include <asm/system.h>
2842 diff -NurpP --minimal linux-2.6.22.10/fs/binfmt_som.c linux-2.6.22.10-vs2.2.0.5/fs/binfmt_som.c
2843 --- linux-2.6.22.10/fs/binfmt_som.c 2006-11-30 21:19:19 +0100
2844 +++ linux-2.6.22.10-vs2.2.0.5/fs/binfmt_som.c 2007-06-15 02:37:03 +0200
2846 #include <linux/shm.h>
2847 #include <linux/personality.h>
2848 #include <linux/init.h>
2849 +#include <linux/vs_memory.h>
2851 #include <asm/a.out.h>
2852 #include <asm/uaccess.h>
2853 diff -NurpP --minimal linux-2.6.22.10/fs/dcache.c linux-2.6.22.10-vs2.2.0.5/fs/dcache.c
2854 --- linux-2.6.22.10/fs/dcache.c 2007-07-09 13:19:23 +0200
2855 +++ linux-2.6.22.10-vs2.2.0.5/fs/dcache.c 2007-06-15 02:37:03 +0200
2857 #include <linux/seqlock.h>
2858 #include <linux/swap.h>
2859 #include <linux/bootmem.h>
2860 +#include <linux/vs_limit.h>
2861 #include "internal.h"
2864 @@ -176,6 +177,7 @@ void dput(struct dentry *dentry)
2868 + vx_dentry_dec(dentry);
2870 if (atomic_read(&dentry->d_count) == 1)
2872 @@ -189,6 +191,8 @@ repeat:
2876 + vx_dentry_dec(dentry);
2879 * AV: ->d_delete() is _NOT_ allowed to block now.
2881 @@ -288,6 +292,7 @@ static inline struct dentry * __dget_loc
2882 if (!list_empty(&dentry->d_lru)) {
2883 dentry_stat.nr_unused--;
2884 list_del_init(&dentry->d_lru);
2885 + vx_dentry_inc(dentry);
2889 @@ -898,6 +903,9 @@ struct dentry *d_alloc(struct dentry * p
2890 struct dentry *dentry;
2893 + if (!vx_dentry_avail(1))
2896 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2899 @@ -946,6 +954,7 @@ struct dentry *d_alloc(struct dentry * p
2901 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
2902 dentry_stat.nr_dentry++;
2903 + vx_dentry_inc(dentry);
2904 spin_unlock(&dcache_lock);
2907 @@ -1295,6 +1304,7 @@ struct dentry * __d_lookup(struct dentry
2909 if (!d_unhashed(dentry)) {
2910 atomic_inc(&dentry->d_count);
2911 + vx_dentry_inc(dentry);
2914 spin_unlock(&dentry->d_lock);
2915 diff -NurpP --minimal linux-2.6.22.10/fs/devpts/inode.c linux-2.6.22.10-vs2.2.0.5/fs/devpts/inode.c
2916 --- linux-2.6.22.10/fs/devpts/inode.c 2007-07-09 13:19:23 +0200
2917 +++ linux-2.6.22.10-vs2.2.0.5/fs/devpts/inode.c 2007-06-15 02:41:30 +0200
2919 #include <linux/devpts_fs.h>
2920 #include <linux/parser.h>
2921 #include <linux/fsnotify.h>
2922 +#include <linux/vs_base.h>
2925 -#define DEVPTS_SUPER_MAGIC 0x1cd1
2926 +static int devpts_permission(struct inode *inode, int mask, struct nameidata *nd)
2928 + int ret = -EACCES;
2930 + /* devpts is xid tagged */
2931 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2932 + ret = generic_permission(inode, mask, NULL);
2936 +static struct inode_operations devpts_file_inode_operations = {
2937 + .permission = devpts_permission,
2940 static struct vfsmount *devpts_mnt;
2941 static struct dentry *devpts_root;
2942 @@ -92,6 +106,25 @@ static int devpts_remount(struct super_b
2946 +static int devpts_filter(struct dentry *de)
2948 + /* devpts is xid tagged */
2949 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
2952 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2954 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2957 +static struct file_operations devpts_dir_operations = {
2958 + .open = dcache_dir_open,
2959 + .release = dcache_dir_close,
2960 + .llseek = dcache_dir_lseek,
2961 + .read = generic_read_dir,
2962 + .readdir = devpts_readdir,
2965 static const struct super_operations devpts_sops = {
2966 .statfs = simple_statfs,
2967 .remount_fs = devpts_remount,
2968 @@ -117,8 +150,10 @@ devpts_fill_super(struct super_block *s,
2969 inode->i_uid = inode->i_gid = 0;
2970 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2971 inode->i_op = &simple_dir_inode_operations;
2972 - inode->i_fop = &simple_dir_operations;
2973 + inode->i_fop = &devpts_dir_operations;
2975 + /* devpts is xid tagged */
2976 + inode->i_tag = (tag_t)vx_current_xid();
2978 devpts_root = s->s_root = d_alloc_root(inode);
2980 @@ -176,6 +211,9 @@ int devpts_pty_new(struct tty_struct *tt
2981 inode->i_gid = config.setgid ? config.gid : current->fsgid;
2982 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2983 init_special_inode(inode, S_IFCHR|config.mode, device);
2984 + /* devpts is xid tagged */
2985 + inode->i_tag = (tag_t)vx_current_xid();
2986 + inode->i_op = &devpts_file_inode_operations;
2987 inode->i_private = tty;
2989 dentry = get_node(number);
2990 diff -NurpP --minimal linux-2.6.22.10/fs/ecryptfs/inode.c linux-2.6.22.10-vs2.2.0.5/fs/ecryptfs/inode.c
2991 --- linux-2.6.22.10/fs/ecryptfs/inode.c 2007-10-30 01:57:14 +0100
2992 +++ linux-2.6.22.10-vs2.2.0.5/fs/ecryptfs/inode.c 2007-08-12 12:21:51 +0200
2993 @@ -423,7 +423,7 @@ static int ecryptfs_link(struct dentry *
2994 dget(lower_new_dentry);
2995 lower_dir_dentry = lock_parent(lower_new_dentry);
2996 rc = vfs_link(lower_old_dentry, lower_dir_dentry->d_inode,
2997 - lower_new_dentry);
2998 + lower_new_dentry, NULL);
2999 if (rc || !lower_new_dentry->d_inode)
3001 rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0);
3002 @@ -451,7 +451,7 @@ static int ecryptfs_unlink(struct inode
3003 struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
3005 lock_parent(lower_dentry);
3006 - rc = vfs_unlink(lower_dir_inode, lower_dentry);
3007 + rc = vfs_unlink(lower_dir_inode, lower_dentry, NULL);
3009 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
3011 @@ -488,7 +488,7 @@ static int ecryptfs_symlink(struct inode
3014 rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry,
3015 - encoded_symname, mode);
3016 + encoded_symname, mode, NULL);
3017 kfree(encoded_symname);
3018 if (rc || !lower_dentry->d_inode)
3020 @@ -513,7 +513,7 @@ static int ecryptfs_mkdir(struct inode *
3022 lower_dentry = ecryptfs_dentry_to_lower(dentry);
3023 lower_dir_dentry = lock_parent(lower_dentry);
3024 - rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode);
3025 + rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode, NULL);
3026 if (rc || !lower_dentry->d_inode)
3028 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
3029 @@ -539,7 +539,7 @@ static int ecryptfs_rmdir(struct inode *
3031 lower_dir_dentry = lock_parent(lower_dentry);
3033 - rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry);
3034 + rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry, NULL);
3037 d_delete(lower_dentry);
3038 @@ -561,7 +561,7 @@ ecryptfs_mknod(struct inode *dir, struct
3040 lower_dentry = ecryptfs_dentry_to_lower(dentry);
3041 lower_dir_dentry = lock_parent(lower_dentry);
3042 - rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev);
3043 + rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev, NULL);
3044 if (rc || !lower_dentry->d_inode)
3046 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
3047 diff -NurpP --minimal linux-2.6.22.10/fs/exec.c linux-2.6.22.10-vs2.2.0.5/fs/exec.c
3048 --- linux-2.6.22.10/fs/exec.c 2007-10-30 01:57:14 +0100
3049 +++ linux-2.6.22.10-vs2.2.0.5/fs/exec.c 2007-09-05 03:05:52 +0200
3051 #include <linux/cn_proc.h>
3052 #include <linux/audit.h>
3053 #include <linux/signalfd.h>
3054 +#include <linux/vs_memory.h>
3056 #include <asm/uaccess.h>
3057 #include <asm/mmu_context.h>
3058 @@ -440,7 +441,8 @@ int setup_arg_pages(struct linux_binprm
3059 kmem_cache_free(vm_area_cachep, mpnt);
3062 - mm->stack_vm = mm->total_vm = vma_pages(mpnt);
3063 + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt));
3064 + mm->stack_vm = mm->total_vm;
3067 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
3068 @@ -1336,7 +1338,7 @@ static int format_corename(char *corenam
3069 /* UNIX time of coredump */
3072 - do_gettimeofday(&tv);
3073 + vx_gettimeofday(&tv);
3074 rc = snprintf(out_ptr, out_end - out_ptr,
3076 if (rc > out_end - out_ptr)
3077 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/balloc.c linux-2.6.22.10-vs2.2.0.5/fs/ext2/balloc.c
3078 --- linux-2.6.22.10/fs/ext2/balloc.c 2007-05-02 19:25:17 +0200
3079 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext2/balloc.c 2007-06-15 02:37:03 +0200
3081 #include <linux/sched.h>
3082 #include <linux/buffer_head.h>
3083 #include <linux/capability.h>
3084 +#include <linux/vs_dlimit.h>
3085 +#include <linux/vs_tag.h>
3088 * balloc.c contains the blocks allocation and deallocation routines
3089 @@ -102,12 +104,13 @@ static int reserve_blocks(struct super_b
3091 struct ext2_sb_info *sbi = EXT2_SB(sb);
3092 struct ext2_super_block *es = sbi->s_es;
3093 - unsigned free_blocks;
3094 - unsigned root_blocks;
3095 + unsigned long long free_blocks, root_blocks;
3097 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
3098 root_blocks = le32_to_cpu(es->s_r_blocks_count);
3100 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
3102 if (free_blocks < count)
3103 count = free_blocks;
3105 @@ -258,6 +261,7 @@ do_more:
3109 + DLIMIT_FREE_BLOCK(inode, freed);
3110 release_blocks(sb, freed);
3111 DQUOT_FREE_BLOCK(inode, freed);
3113 @@ -361,6 +365,10 @@ int ext2_new_block(struct inode *inode,
3117 + if (DLIMIT_ALLOC_BLOCK(inode, es_alloc)) {
3122 ext2_debug ("goal=%lu.\n", goal);
3124 @@ -508,6 +516,8 @@ got_block:
3127 group_release_blocks(sb, group_no, desc, gdp_bh, group_alloc);
3128 + DLIMIT_FREE_BLOCK(inode, es_alloc);
3130 release_blocks(sb, es_alloc);
3132 DQUOT_FREE_BLOCK(inode, dq_alloc);
3133 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/ext2.h linux-2.6.22.10-vs2.2.0.5/fs/ext2/ext2.h
3134 --- linux-2.6.22.10/fs/ext2/ext2.h 2007-07-09 13:19:23 +0200
3135 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext2/ext2.h 2007-06-15 02:37:03 +0200
3136 @@ -167,6 +167,7 @@ extern const struct file_operations ext2
3137 extern const struct address_space_operations ext2_aops;
3138 extern const struct address_space_operations ext2_aops_xip;
3139 extern const struct address_space_operations ext2_nobh_aops;
3140 +extern int ext2_sync_flags(struct inode *inode);
3143 extern const struct inode_operations ext2_dir_inode_operations;
3144 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/file.c linux-2.6.22.10-vs2.2.0.5/fs/ext2/file.c
3145 --- linux-2.6.22.10/fs/ext2/file.c 2007-05-02 19:25:17 +0200
3146 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext2/file.c 2007-10-29 23:24:21 +0100
3147 @@ -85,4 +85,5 @@ const struct inode_operations ext2_file_
3149 .setattr = ext2_setattr,
3150 .permission = ext2_permission,
3151 + .sync_flags = ext2_sync_flags,
3153 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/ialloc.c linux-2.6.22.10-vs2.2.0.5/fs/ext2/ialloc.c
3154 --- linux-2.6.22.10/fs/ext2/ialloc.c 2006-11-30 21:19:19 +0100
3155 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext2/ialloc.c 2007-06-15 02:37:03 +0200
3157 #include <linux/backing-dev.h>
3158 #include <linux/buffer_head.h>
3159 #include <linux/random.h>
3160 +#include <linux/vs_dlimit.h>
3161 +#include <linux/vs_tag.h>
3165 @@ -125,6 +127,7 @@ void ext2_free_inode (struct inode * ino
3166 ext2_xattr_delete_inode(inode);
3167 DQUOT_FREE_INODE(inode);
3169 + DLIMIT_FREE_INODE(inode);
3172 es = EXT2_SB(sb)->s_es;
3173 @@ -464,6 +467,11 @@ struct inode *ext2_new_inode(struct inod
3175 return ERR_PTR(-ENOMEM);
3177 + inode->i_tag = dx_current_fstag(sb);
3178 + if (DLIMIT_ALLOC_INODE(inode)) {
3185 @@ -577,7 +585,8 @@ got:
3186 inode->i_blocks = 0;
3187 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
3188 memset(ei->i_data, 0, sizeof(ei->i_data));
3189 - ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
3190 + ei->i_flags = EXT2_I(dir)->i_flags &
3191 + ~(EXT2_BTREE_FL|EXT2_IUNLINK_FL|EXT2_BARRIER_FL);
3193 ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
3194 /* dirsync is only applied to directories */
3195 @@ -625,12 +634,15 @@ fail_free_drop:
3199 + DLIMIT_FREE_INODE(inode);
3200 inode->i_flags |= S_NOQUOTA;
3203 return ERR_PTR(err);
3206 + DLIMIT_FREE_INODE(inode);
3208 make_bad_inode(inode);
3210 return ERR_PTR(err);
3211 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/inode.c linux-2.6.22.10-vs2.2.0.5/fs/ext2/inode.c
3212 --- linux-2.6.22.10/fs/ext2/inode.c 2007-07-09 13:19:23 +0200
3213 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext2/inode.c 2007-06-15 02:57:56 +0200
3215 #include <linux/writeback.h>
3216 #include <linux/buffer_head.h>
3217 #include <linux/mpage.h>
3218 +#include <linux/vs_tag.h>
3222 @@ -913,7 +914,7 @@ void ext2_truncate (struct inode * inode
3224 if (ext2_inode_is_fast_symlink(inode))
3226 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3227 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3230 ext2_discard_prealloc(inode);
3231 @@ -1042,13 +1043,20 @@ void ext2_set_inode_flags(struct inode *
3233 unsigned int flags = EXT2_I(inode)->i_flags;
3235 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3236 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
3237 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3239 + if (flags & EXT2_IMMUTABLE_FL)
3240 + inode->i_flags |= S_IMMUTABLE;
3241 + if (flags & EXT2_IUNLINK_FL)
3242 + inode->i_flags |= S_IUNLINK;
3243 + if (flags & EXT2_BARRIER_FL)
3244 + inode->i_flags |= S_BARRIER;
3246 if (flags & EXT2_SYNC_FL)
3247 inode->i_flags |= S_SYNC;
3248 if (flags & EXT2_APPEND_FL)
3249 inode->i_flags |= S_APPEND;
3250 - if (flags & EXT2_IMMUTABLE_FL)
3251 - inode->i_flags |= S_IMMUTABLE;
3252 if (flags & EXT2_NOATIME_FL)
3253 inode->i_flags |= S_NOATIME;
3254 if (flags & EXT2_DIRSYNC_FL)
3255 @@ -1074,12 +1082,37 @@ void ext2_get_inode_flags(struct ext2_in
3256 ei->i_flags |= EXT2_DIRSYNC_FL;
3259 +int ext2_sync_flags(struct inode *inode)
3261 + unsigned int oldflags, newflags;
3263 + oldflags = EXT2_I(inode)->i_flags;
3264 + newflags = oldflags & ~(EXT2_IMMUTABLE_FL |
3265 + EXT2_IUNLINK_FL | EXT2_BARRIER_FL);
3267 + if (IS_IMMUTABLE(inode))
3268 + newflags |= EXT2_IMMUTABLE_FL;
3269 + if (IS_IUNLINK(inode))
3270 + newflags |= EXT2_IUNLINK_FL;
3271 + if (IS_BARRIER(inode))
3272 + newflags |= EXT2_BARRIER_FL;
3274 + if (oldflags ^ newflags) {
3275 + EXT2_I(inode)->i_flags = newflags;
3276 + inode->i_ctime = CURRENT_TIME;
3277 + mark_inode_dirty(inode);
3282 void ext2_read_inode (struct inode * inode)
3284 struct ext2_inode_info *ei = EXT2_I(inode);
3285 ino_t ino = inode->i_ino;
3286 struct buffer_head * bh;
3287 struct ext2_inode * raw_inode = ext2_get_inode(inode->i_sb, ino, &bh);
3292 #ifdef CONFIG_EXT2_FS_POSIX_ACL
3293 @@ -1090,12 +1123,17 @@ void ext2_read_inode (struct inode * ino
3296 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3297 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3298 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3299 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3300 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3301 if (!(test_opt (inode->i_sb, NO_UID32))) {
3302 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3303 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3304 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3305 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3307 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3308 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3309 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3310 + le16_to_cpu(raw_inode->i_raw_tag));
3312 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3313 inode->i_size = le32_to_cpu(raw_inode->i_size);
3314 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3315 @@ -1192,8 +1230,8 @@ static int ext2_update_inode(struct inod
3316 struct ext2_inode_info *ei = EXT2_I(inode);
3317 struct super_block *sb = inode->i_sb;
3318 ino_t ino = inode->i_ino;
3319 - uid_t uid = inode->i_uid;
3320 - gid_t gid = inode->i_gid;
3321 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3322 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3323 struct buffer_head * bh;
3324 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
3326 @@ -1229,6 +1267,9 @@ static int ext2_update_inode(struct inod
3327 raw_inode->i_uid_high = 0;
3328 raw_inode->i_gid_high = 0;
3330 +#ifdef CONFIG_TAGGING_INTERN
3331 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3333 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3334 raw_inode->i_size = cpu_to_le32(inode->i_size);
3335 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3336 @@ -1315,7 +1356,8 @@ int ext2_setattr(struct dentry *dentry,
3339 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3340 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3341 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3342 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3343 error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0;
3346 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/ioctl.c linux-2.6.22.10-vs2.2.0.5/fs/ext2/ioctl.c
3347 --- linux-2.6.22.10/fs/ext2/ioctl.c 2007-07-09 13:19:23 +0200
3348 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext2/ioctl.c 2007-06-15 02:37:03 +0200
3350 #include <linux/sched.h>
3351 #include <linux/compat.h>
3352 #include <linux/smp_lock.h>
3353 +#include <linux/mount.h>
3354 #include <asm/current.h>
3355 #include <asm/uaccess.h>
3357 @@ -33,7 +34,8 @@ int ext2_ioctl (struct inode * inode, st
3358 case EXT2_IOC_SETFLAGS: {
3359 unsigned int oldflags;
3361 - if (IS_RDONLY(inode))
3362 + if (IS_RDONLY(inode) ||
3363 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3366 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3367 @@ -54,7 +56,9 @@ int ext2_ioctl (struct inode * inode, st
3369 * This test looks nicer. Thanks to Pauline Middelink
3371 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
3372 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
3373 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
3374 + EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL))) {
3375 if (!capable(CAP_LINUX_IMMUTABLE)) {
3376 mutex_unlock(&inode->i_mutex);
3378 @@ -76,7 +80,8 @@ int ext2_ioctl (struct inode * inode, st
3379 case EXT2_IOC_SETVERSION:
3380 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3382 - if (IS_RDONLY(inode))
3383 + if (IS_RDONLY(inode) ||
3384 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3386 if (get_user(inode->i_generation, (int __user *) arg))
3388 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/namei.c linux-2.6.22.10-vs2.2.0.5/fs/ext2/namei.c
3389 --- linux-2.6.22.10/fs/ext2/namei.c 2007-05-02 19:25:17 +0200
3390 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext2/namei.c 2007-06-15 02:37:03 +0200
3394 #include <linux/pagemap.h>
3395 +#include <linux/vs_tag.h>
3399 @@ -66,6 +67,7 @@ static struct dentry *ext2_lookup(struct
3400 inode = iget(dir->i_sb, ino);
3402 return ERR_PTR(-EACCES);
3403 + dx_propagate_tag(nd, inode);
3405 return d_splice_alias(inode, dentry);
3407 @@ -391,6 +393,7 @@ const struct inode_operations ext2_dir_i
3409 .setattr = ext2_setattr,
3410 .permission = ext2_permission,
3411 + .sync_flags = ext2_sync_flags,
3414 const struct inode_operations ext2_special_inode_operations = {
3415 @@ -402,4 +405,5 @@ const struct inode_operations ext2_speci
3417 .setattr = ext2_setattr,
3418 .permission = ext2_permission,
3419 + .sync_flags = ext2_sync_flags,
3421 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/super.c linux-2.6.22.10-vs2.2.0.5/fs/ext2/super.c
3422 --- linux-2.6.22.10/fs/ext2/super.c 2007-07-09 13:19:23 +0200
3423 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext2/super.c 2007-07-07 03:52:53 +0200
3424 @@ -321,7 +321,7 @@ enum {
3425 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3426 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3427 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3428 - Opt_usrquota, Opt_grpquota
3429 + Opt_usrquota, Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3432 static match_table_t tokens = {
3433 @@ -349,6 +349,10 @@ static match_table_t tokens = {
3435 {Opt_noacl, "noacl"},
3438 + {Opt_notag, "notag"},
3439 + {Opt_tagid, "tagid=%u"},
3440 + {Opt_tag, "tagxid"},
3441 {Opt_grpquota, "grpquota"},
3442 {Opt_ignore, "noquota"},
3443 {Opt_quota, "quota"},
3444 @@ -417,6 +421,20 @@ static int parse_options (char * options
3446 set_opt (sbi->s_mount_opt, NO_UID32);
3448 +#ifndef CONFIG_TAGGING_NONE
3450 + set_opt (sbi->s_mount_opt, TAGGED);
3453 + clear_opt (sbi->s_mount_opt, TAGGED);
3456 +#ifdef CONFIG_PROPAGATE
3459 + set_opt (sbi->s_mount_opt, TAGGED);
3463 clear_opt (sbi->s_mount_opt, CHECK);
3465 @@ -727,6 +745,8 @@ static int ext2_fill_super(struct super_
3466 if (!parse_options ((char *) data, sbi))
3469 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3470 + sb->s_flags |= MS_TAGGED;
3471 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3472 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3474 @@ -1035,6 +1055,13 @@ static int ext2_remount (struct super_bl
3478 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3479 + !(sb->s_flags & MS_TAGGED)) {
3480 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3485 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3486 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3488 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/symlink.c linux-2.6.22.10-vs2.2.0.5/fs/ext2/symlink.c
3489 --- linux-2.6.22.10/fs/ext2/symlink.c 2007-05-02 19:25:17 +0200
3490 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext2/symlink.c 2007-06-15 02:37:03 +0200
3491 @@ -38,6 +38,7 @@ const struct inode_operations ext2_symli
3492 .listxattr = ext2_listxattr,
3493 .removexattr = generic_removexattr,
3495 + .sync_flags = ext2_sync_flags,
3498 const struct inode_operations ext2_fast_symlink_inode_operations = {
3499 @@ -49,4 +50,5 @@ const struct inode_operations ext2_fast_
3500 .listxattr = ext2_listxattr,
3501 .removexattr = generic_removexattr,
3503 + .sync_flags = ext2_sync_flags,
3505 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/xattr.c linux-2.6.22.10-vs2.2.0.5/fs/ext2/xattr.c
3506 --- linux-2.6.22.10/fs/ext2/xattr.c 2007-02-06 03:01:18 +0100
3507 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext2/xattr.c 2007-06-15 02:37:03 +0200
3509 #include <linux/mbcache.h>
3510 #include <linux/quotaops.h>
3511 #include <linux/rwsem.h>
3512 +#include <linux/vs_dlimit.h>
3516 @@ -641,8 +642,12 @@ ext2_xattr_set2(struct inode *inode, str
3518 ea_bdebug(new_bh, "reusing block");
3521 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3524 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
3525 + DLIMIT_FREE_BLOCK(inode, 1);
3526 unlock_buffer(new_bh);
3529 @@ -736,6 +741,7 @@ ext2_xattr_set2(struct inode *inode, str
3530 le32_to_cpu(HDR(old_bh)->h_refcount) - 1);
3532 mb_cache_entry_release(ce);
3533 + DLIMIT_FREE_BLOCK(inode, 1);
3534 DQUOT_FREE_BLOCK(inode, 1);
3535 mark_buffer_dirty(old_bh);
3536 ea_bdebug(old_bh, "refcount now=%d",
3537 @@ -800,6 +806,7 @@ ext2_xattr_delete_inode(struct inode *in
3538 mark_buffer_dirty(bh);
3540 sync_dirty_buffer(bh);
3541 + DLIMIT_FREE_BLOCK(inode, 1);
3542 DQUOT_FREE_BLOCK(inode, 1);
3544 EXT2_I(inode)->i_file_acl = 0;
3545 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/balloc.c linux-2.6.22.10-vs2.2.0.5/fs/ext3/balloc.c
3546 --- linux-2.6.22.10/fs/ext3/balloc.c 2007-05-02 19:25:17 +0200
3547 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext3/balloc.c 2007-07-16 06:31:34 +0200
3549 #include <linux/ext3_jbd.h>
3550 #include <linux/quotaops.h>
3551 #include <linux/buffer_head.h>
3552 +#include <linux/vs_dlimit.h>
3553 +#include <linux/vs_tag.h>
3556 * balloc.c contains the blocks allocation and deallocation routines
3557 @@ -613,8 +615,10 @@ void ext3_free_blocks(handle_t *handle,
3560 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
3561 - if (dquot_freed_blocks)
3562 + if (dquot_freed_blocks) {
3563 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
3564 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
3569 @@ -1353,18 +1357,33 @@ out:
3571 * Check if filesystem has at least 1 free block available for allocation.
3573 -static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
3574 +static int ext3_has_free_blocks(struct super_block *sb)
3576 - ext3_fsblk_t free_blocks, root_blocks;
3577 + struct ext3_sb_info *sbi = EXT3_SB(sb);
3578 + unsigned long long free_blocks, root_blocks;
3581 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
3582 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
3583 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
3585 + vxdprintk(VXD_CBIT(dlim, 3),
3586 + "ext3_has_free_blocks(%p): free=%llu, root=%llu",
3587 + sb, free_blocks, root_blocks);
3589 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
3591 + cond = (free_blocks < root_blocks + 1 &&
3592 + !capable(CAP_SYS_RESOURCE) &&
3593 sbi->s_resuid != current->fsuid &&
3594 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
3598 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
3600 + vxdprintk(VXD_CBIT(dlim, 3),
3601 + "ext3_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
3602 + sb, free_blocks, root_blocks,
3603 + !capable(CAP_SYS_RESOURCE)?'1':'0',
3604 + sbi->s_resuid, current->fsuid, cond?0:1);
3606 + return (cond ? 0 : 1);
3610 @@ -1381,7 +1400,7 @@ static int ext3_has_free_blocks(struct e
3612 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
3614 - if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
3615 + if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
3618 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
3619 @@ -1444,6 +1463,8 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
3623 + if (DLIMIT_ALLOC_BLOCK(inode, num))
3627 es = EXT3_SB(sb)->s_es;
3628 @@ -1460,7 +1481,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
3629 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
3630 my_rsv = &block_i->rsv_window_node;
3632 - if (!ext3_has_free_blocks(sbi)) {
3633 + if (!ext3_has_free_blocks(sb)) {
3637 @@ -1647,12 +1668,16 @@ allocated:
3640 DQUOT_FREE_BLOCK(inode, *count-num);
3641 + DLIMIT_FREE_BLOCK(inode, *count-num);
3648 + if (!performed_allocation)
3649 + DLIMIT_FREE_BLOCK(inode, *count);
3653 ext3_std_error(sb, fatal);
3654 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/file.c linux-2.6.22.10-vs2.2.0.5/fs/ext3/file.c
3655 --- linux-2.6.22.10/fs/ext3/file.c 2007-05-02 19:25:17 +0200
3656 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext3/file.c 2007-10-29 23:24:21 +0100
3657 @@ -135,5 +135,6 @@ const struct inode_operations ext3_file_
3658 .removexattr = generic_removexattr,
3660 .permission = ext3_permission,
3661 + .sync_flags = ext3_sync_flags,
3664 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/ialloc.c linux-2.6.22.10-vs2.2.0.5/fs/ext3/ialloc.c
3665 --- linux-2.6.22.10/fs/ext3/ialloc.c 2006-11-30 21:19:19 +0100
3666 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext3/ialloc.c 2007-06-15 02:37:03 +0200
3668 #include <linux/buffer_head.h>
3669 #include <linux/random.h>
3670 #include <linux/bitops.h>
3671 +#include <linux/vs_dlimit.h>
3672 +#include <linux/vs_tag.h>
3674 #include <asm/byteorder.h>
3676 @@ -127,6 +129,7 @@ void ext3_free_inode (handle_t *handle,
3677 ext3_xattr_delete_inode(handle, inode);
3678 DQUOT_FREE_INODE(inode);
3680 + DLIMIT_FREE_INODE(inode);
3682 is_directory = S_ISDIR(inode->i_mode);
3684 @@ -445,6 +448,12 @@ struct inode *ext3_new_inode(handle_t *h
3685 inode = new_inode(sb);
3687 return ERR_PTR(-ENOMEM);
3689 + inode->i_tag = dx_current_fstag(sb);
3690 + if (DLIMIT_ALLOC_INODE(inode)) {
3697 @@ -566,7 +575,8 @@ got:
3698 ei->i_dir_start_lookup = 0;
3701 - ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
3702 + ei->i_flags = EXT3_I(dir)->i_flags &
3703 + ~(EXT3_INDEX_FL|EXT3_IUNLINK_FL|EXT3_BARRIER_FL);
3705 ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
3706 /* dirsync only applies to directories */
3707 @@ -621,6 +631,8 @@ got:
3709 ext3_std_error(sb, err);
3711 + DLIMIT_FREE_INODE(inode);
3716 @@ -632,6 +644,7 @@ fail_free_drop:
3720 + DLIMIT_FREE_INODE(inode);
3721 inode->i_flags |= S_NOQUOTA;
3724 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/inode.c linux-2.6.22.10-vs2.2.0.5/fs/ext3/inode.c
3725 --- linux-2.6.22.10/fs/ext3/inode.c 2007-07-09 13:19:23 +0200
3726 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext3/inode.c 2007-07-07 03:52:53 +0200
3728 #include <linux/mpage.h>
3729 #include <linux/uio.h>
3730 #include <linux/bio.h>
3731 +#include <linux/vs_tag.h>
3735 @@ -2237,7 +2238,7 @@ void ext3_truncate(struct inode *inode)
3737 if (ext3_inode_is_fast_symlink(inode))
3739 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3740 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3744 @@ -2559,13 +2560,20 @@ void ext3_set_inode_flags(struct inode *
3746 unsigned int flags = EXT3_I(inode)->i_flags;
3748 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3749 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
3750 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3752 + if (flags & EXT3_IMMUTABLE_FL)
3753 + inode->i_flags |= S_IMMUTABLE;
3754 + if (flags & EXT3_IUNLINK_FL)
3755 + inode->i_flags |= S_IUNLINK;
3756 + if (flags & EXT3_BARRIER_FL)
3757 + inode->i_flags |= S_BARRIER;
3759 if (flags & EXT3_SYNC_FL)
3760 inode->i_flags |= S_SYNC;
3761 if (flags & EXT3_APPEND_FL)
3762 inode->i_flags |= S_APPEND;
3763 - if (flags & EXT3_IMMUTABLE_FL)
3764 - inode->i_flags |= S_IMMUTABLE;
3765 if (flags & EXT3_NOATIME_FL)
3766 inode->i_flags |= S_NOATIME;
3767 if (flags & EXT3_DIRSYNC_FL)
3768 @@ -2591,6 +2599,45 @@ void ext3_get_inode_flags(struct ext3_in
3769 ei->i_flags |= EXT3_DIRSYNC_FL;
3772 +int ext3_sync_flags(struct inode *inode)
3774 + unsigned int oldflags, newflags;
3777 + oldflags = EXT3_I(inode)->i_flags;
3778 + newflags = oldflags & ~(EXT3_IMMUTABLE_FL |
3779 + EXT3_IUNLINK_FL | EXT3_BARRIER_FL);
3781 + if (IS_IMMUTABLE(inode))
3782 + newflags |= EXT3_IMMUTABLE_FL;
3783 + if (IS_IUNLINK(inode))
3784 + newflags |= EXT3_IUNLINK_FL;
3785 + if (IS_BARRIER(inode))
3786 + newflags |= EXT3_BARRIER_FL;
3788 + if (oldflags ^ newflags) {
3790 + struct ext3_iloc iloc;
3792 + handle = ext3_journal_start(inode, 1);
3793 + if (IS_ERR(handle))
3794 + return PTR_ERR(handle);
3795 + if (IS_SYNC(inode))
3796 + handle->h_sync = 1;
3797 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3801 + EXT3_I(inode)->i_flags = newflags;
3802 + inode->i_ctime = CURRENT_TIME;
3804 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3806 + ext3_journal_stop(handle);
3811 void ext3_read_inode(struct inode * inode)
3813 struct ext3_iloc iloc;
3814 @@ -2598,6 +2645,8 @@ void ext3_read_inode(struct inode * inod
3815 struct ext3_inode_info *ei = EXT3_I(inode);
3816 struct buffer_head *bh;
3821 #ifdef CONFIG_EXT3_FS_POSIX_ACL
3822 ei->i_acl = EXT3_ACL_NOT_CACHED;
3823 @@ -2610,12 +2659,17 @@ void ext3_read_inode(struct inode * inod
3825 raw_inode = ext3_raw_inode(&iloc);
3826 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3827 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3828 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3829 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3830 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3831 if(!(test_opt (inode->i_sb, NO_UID32))) {
3832 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3833 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3834 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3835 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3837 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3838 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3839 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3840 + le16_to_cpu(raw_inode->i_raw_tag));
3842 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3843 inode->i_size = le32_to_cpu(raw_inode->i_size);
3844 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3845 @@ -2741,6 +2795,8 @@ static int ext3_do_update_inode(handle_t
3846 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3847 struct ext3_inode_info *ei = EXT3_I(inode);
3848 struct buffer_head *bh = iloc->bh;
3849 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3850 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3851 int err = 0, rc, block;
3853 /* For fields not not tracking in the in-memory inode,
3854 @@ -2751,29 +2807,32 @@ static int ext3_do_update_inode(handle_t
3855 ext3_get_inode_flags(ei);
3856 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3857 if(!(test_opt(inode->i_sb, NO_UID32))) {
3858 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3859 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3860 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3861 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3863 * Fix up interoperability with old kernels. Otherwise, old inodes get
3864 * re-used with the upper 16 bits of the uid/gid intact
3867 raw_inode->i_uid_high =
3868 - cpu_to_le16(high_16_bits(inode->i_uid));
3869 + cpu_to_le16(high_16_bits(uid));
3870 raw_inode->i_gid_high =
3871 - cpu_to_le16(high_16_bits(inode->i_gid));
3872 + cpu_to_le16(high_16_bits(gid));
3874 raw_inode->i_uid_high = 0;
3875 raw_inode->i_gid_high = 0;
3878 raw_inode->i_uid_low =
3879 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3880 + cpu_to_le16(fs_high2lowuid(uid));
3881 raw_inode->i_gid_low =
3882 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3883 + cpu_to_le16(fs_high2lowgid(gid));
3884 raw_inode->i_uid_high = 0;
3885 raw_inode->i_gid_high = 0;
3887 +#ifdef CONFIG_TAGGING_INTERN
3888 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3890 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3891 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3892 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3893 @@ -2926,7 +2985,8 @@ int ext3_setattr(struct dentry *dentry,
3896 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3897 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3898 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3899 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3902 /* (user+group)*(old+new) structure, inode write (sb,
3903 @@ -2948,6 +3008,8 @@ int ext3_setattr(struct dentry *dentry,
3904 inode->i_uid = attr->ia_uid;
3905 if (attr->ia_valid & ATTR_GID)
3906 inode->i_gid = attr->ia_gid;
3907 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3908 + inode->i_tag = attr->ia_tag;
3909 error = ext3_mark_inode_dirty(handle, inode);
3910 ext3_journal_stop(handle);
3912 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/ioctl.c linux-2.6.22.10-vs2.2.0.5/fs/ext3/ioctl.c
3913 --- linux-2.6.22.10/fs/ext3/ioctl.c 2007-07-09 13:19:23 +0200
3914 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext3/ioctl.c 2007-06-15 02:37:03 +0200
3918 #include <linux/fs.h>
3919 +#include <linux/mount.h>
3920 #include <linux/jbd.h>
3921 #include <linux/capability.h>
3922 #include <linux/ext3_fs.h>
3924 #include <linux/time.h>
3925 #include <linux/compat.h>
3926 #include <linux/smp_lock.h>
3927 +#include <linux/vs_tag.h>
3928 #include <asm/uaccess.h>
3930 int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
3931 @@ -38,7 +40,8 @@ int ext3_ioctl (struct inode * inode, st
3932 unsigned int oldflags;
3935 - if (IS_RDONLY(inode))
3936 + if (IS_RDONLY(inode) ||
3937 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3940 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3941 @@ -62,7 +65,9 @@ int ext3_ioctl (struct inode * inode, st
3943 * This test looks nicer. Thanks to Pauline Middelink
3945 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3946 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3947 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3948 + EXT3_IMMUTABLE_FL | EXT3_IUNLINK_FL))) {
3949 if (!capable(CAP_LINUX_IMMUTABLE)) {
3950 mutex_unlock(&inode->i_mutex);
3952 @@ -124,7 +129,8 @@ flags_err:
3954 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3956 - if (IS_RDONLY(inode))
3957 + if (IS_RDONLY(inode) ||
3958 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3960 if (get_user(generation, (int __user *) arg))
3962 @@ -178,7 +184,8 @@ flags_err:
3963 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
3966 - if (IS_RDONLY(inode))
3967 + if (IS_RDONLY(inode) ||
3968 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3971 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3972 @@ -213,7 +220,8 @@ flags_err:
3973 if (!capable(CAP_SYS_RESOURCE))
3976 - if (IS_RDONLY(inode))
3977 + if (IS_RDONLY(inode) ||
3978 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3981 if (get_user(n_blocks_count, (__u32 __user *)arg))
3982 @@ -234,7 +242,8 @@ flags_err:
3983 if (!capable(CAP_SYS_RESOURCE))
3986 - if (IS_RDONLY(inode))
3987 + if (IS_RDONLY(inode) ||
3988 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3991 if (copy_from_user(&input, (struct ext3_new_group_input __user *)arg,
3992 @@ -249,6 +258,38 @@ flags_err:
3996 +#if defined(CONFIG_VSERVER_LEGACY) && !defined(CONFIG_TAGGING_NONE)
3997 + case EXT3_IOC_SETTAG: {
3999 + struct ext3_iloc iloc;
4003 + /* fixme: if stealth, return -ENOTTY */
4004 + if (!capable(CAP_CONTEXT))
4006 + if (IS_RDONLY(inode))
4008 + if (!(inode->i_sb->s_flags & MS_TAGGED))
4010 + if (get_user(tag, (int __user *) arg))
4013 + handle = ext3_journal_start(inode, 1);
4014 + if (IS_ERR(handle))
4015 + return PTR_ERR(handle);
4016 + err = ext3_reserve_inode_write(handle, inode, &iloc);
4020 + inode->i_tag = (tag & 0xFFFF);
4021 + inode->i_ctime = CURRENT_TIME;
4023 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
4024 + ext3_journal_stop(handle);
4031 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/namei.c linux-2.6.22.10-vs2.2.0.5/fs/ext3/namei.c
4032 --- linux-2.6.22.10/fs/ext3/namei.c 2007-10-30 01:57:14 +0100
4033 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext3/namei.c 2007-10-01 15:25:35 +0200
4035 #include <linux/quotaops.h>
4036 #include <linux/buffer_head.h>
4037 #include <linux/bio.h>
4038 +#include <linux/vs_tag.h>
4042 @@ -1052,6 +1053,7 @@ static struct dentry *ext3_lookup(struct
4045 return ERR_PTR(-EACCES);
4046 + dx_propagate_tag(nd, inode);
4048 return d_splice_alias(inode, dentry);
4050 @@ -2443,6 +2445,7 @@ const struct inode_operations ext3_dir_i
4051 .removexattr = generic_removexattr,
4053 .permission = ext3_permission,
4054 + .sync_flags = ext3_sync_flags,
4057 const struct inode_operations ext3_special_inode_operations = {
4058 @@ -2454,4 +2457,5 @@ const struct inode_operations ext3_speci
4059 .removexattr = generic_removexattr,
4061 .permission = ext3_permission,
4062 + .sync_flags = ext3_sync_flags,
4064 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/super.c linux-2.6.22.10-vs2.2.0.5/fs/ext3/super.c
4065 --- linux-2.6.22.10/fs/ext3/super.c 2007-07-09 13:19:23 +0200
4066 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext3/super.c 2007-06-15 02:37:03 +0200
4067 @@ -674,7 +674,7 @@ enum {
4068 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4069 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
4070 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
4072 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
4075 static match_table_t tokens = {
4076 @@ -724,6 +724,10 @@ static match_table_t tokens = {
4077 {Opt_quota, "quota"},
4078 {Opt_usrquota, "usrquota"},
4079 {Opt_barrier, "barrier=%u"},
4081 + {Opt_notag, "notag"},
4082 + {Opt_tagid, "tagid=%u"},
4083 + {Opt_tag, "tagxid"},
4085 {Opt_resize, "resize"},
4087 @@ -817,6 +821,20 @@ static int parse_options (char *options,
4089 set_opt (sbi->s_mount_opt, NO_UID32);
4091 +#ifndef CONFIG_TAGGING_NONE
4093 + set_opt (sbi->s_mount_opt, TAGGED);
4096 + clear_opt (sbi->s_mount_opt, TAGGED);
4099 +#ifdef CONFIG_PROPAGATE
4102 + set_opt (sbi->s_mount_opt, TAGGED);
4106 clear_opt (sbi->s_mount_opt, CHECK);
4108 @@ -1487,6 +1505,9 @@ static int ext3_fill_super (struct super
4112 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
4113 + sb->s_flags |= MS_TAGGED;
4115 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4116 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4118 @@ -2302,6 +2323,12 @@ static int ext3_remount (struct super_bl
4120 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
4121 ext3_abort(sb, __FUNCTION__, "Abort forced by user");
4122 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
4123 + !(sb->s_flags & MS_TAGGED)) {
4124 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
4129 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4130 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4131 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/symlink.c linux-2.6.22.10-vs2.2.0.5/fs/ext3/symlink.c
4132 --- linux-2.6.22.10/fs/ext3/symlink.c 2007-05-02 19:25:17 +0200
4133 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext3/symlink.c 2007-06-15 02:37:03 +0200
4134 @@ -40,6 +40,7 @@ const struct inode_operations ext3_symli
4135 .listxattr = ext3_listxattr,
4136 .removexattr = generic_removexattr,
4138 + .sync_flags = ext3_sync_flags,
4141 const struct inode_operations ext3_fast_symlink_inode_operations = {
4142 @@ -51,4 +52,5 @@ const struct inode_operations ext3_fast_
4143 .listxattr = ext3_listxattr,
4144 .removexattr = generic_removexattr,
4146 + .sync_flags = ext3_sync_flags,
4148 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/xattr.c linux-2.6.22.10-vs2.2.0.5/fs/ext3/xattr.c
4149 --- linux-2.6.22.10/fs/ext3/xattr.c 2007-05-02 19:25:17 +0200
4150 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext3/xattr.c 2007-06-15 02:37:03 +0200
4152 #include <linux/mbcache.h>
4153 #include <linux/quotaops.h>
4154 #include <linux/rwsem.h>
4155 +#include <linux/vs_dlimit.h>
4159 @@ -497,6 +498,7 @@ ext3_xattr_release_block(handle_t *handl
4160 error = ext3_journal_dirty_metadata(handle, bh);
4163 + DLIMIT_FREE_BLOCK(inode, 1);
4164 DQUOT_FREE_BLOCK(inode, 1);
4165 ea_bdebug(bh, "refcount now=%d; releasing",
4166 le32_to_cpu(BHDR(bh)->h_refcount));
4167 @@ -771,11 +773,14 @@ inserted:
4168 if (new_bh == bs->bh)
4169 ea_bdebug(new_bh, "keeping");
4172 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
4174 /* The old block is released after updating
4177 if (DQUOT_ALLOC_BLOCK(inode, 1))
4179 + goto cleanup_dlimit;
4180 error = ext3_journal_get_write_access(handle,
4183 @@ -852,6 +857,8 @@ cleanup:
4186 DQUOT_FREE_BLOCK(inode, 1);
4188 + DLIMIT_FREE_BLOCK(inode, 1);
4192 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/balloc.c linux-2.6.22.10-vs2.2.0.5/fs/ext4/balloc.c
4193 --- linux-2.6.22.10/fs/ext4/balloc.c 2007-07-09 13:19:23 +0200
4194 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext4/balloc.c 2007-07-16 06:31:34 +0200
4196 #include <linux/ext4_jbd2.h>
4197 #include <linux/quotaops.h>
4198 #include <linux/buffer_head.h>
4199 +#include <linux/vs_dlimit.h>
4200 +#include <linux/vs_tag.h>
4203 * balloc.c contains the blocks allocation and deallocation routines
4204 @@ -630,8 +632,10 @@ void ext4_free_blocks(handle_t *handle,
4207 ext4_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
4208 - if (dquot_freed_blocks)
4209 + if (dquot_freed_blocks) {
4210 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
4211 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
4216 @@ -1370,18 +1374,33 @@ out:
4218 * Check if filesystem has at least 1 free block available for allocation.
4220 -static int ext4_has_free_blocks(struct ext4_sb_info *sbi)
4221 +static int ext4_has_free_blocks(struct super_block *sb)
4223 + struct ext4_sb_info *sbi = EXT4_SB(sb);
4224 ext4_fsblk_t free_blocks, root_blocks;
4227 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
4228 root_blocks = ext4_r_blocks_count(sbi->s_es);
4229 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
4231 + vxdprintk(VXD_CBIT(dlim, 3),
4232 + "ext4_has_free_blocks(%p): free=%llu, root=%llu",
4233 + sb, free_blocks, root_blocks);
4235 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
4237 + cond = (free_blocks < root_blocks + 1 &&
4238 + !capable(CAP_SYS_RESOURCE) &&
4239 sbi->s_resuid != current->fsuid &&
4240 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
4244 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
4246 + vxdprintk(VXD_CBIT(dlim, 3),
4247 + "ext4_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
4248 + sb, free_blocks, root_blocks,
4249 + !capable(CAP_SYS_RESOURCE)?'1':'0',
4250 + sbi->s_resuid, current->fsuid, cond?0:1);
4252 + return (cond ? 0 : 1);
4256 @@ -1398,7 +1417,7 @@ static int ext4_has_free_blocks(struct e
4258 int ext4_should_retry_alloc(struct super_block *sb, int *retries)
4260 - if (!ext4_has_free_blocks(EXT4_SB(sb)) || (*retries)++ > 3)
4261 + if (!ext4_has_free_blocks(sb) || (*retries)++ > 3)
4264 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
4265 @@ -1461,6 +1480,8 @@ ext4_fsblk_t ext4_new_blocks(handle_t *h
4269 + if (DLIMIT_ALLOC_BLOCK(inode, num))
4273 es = EXT4_SB(sb)->s_es;
4274 @@ -1477,7 +1498,7 @@ ext4_fsblk_t ext4_new_blocks(handle_t *h
4275 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
4276 my_rsv = &block_i->rsv_window_node;
4278 - if (!ext4_has_free_blocks(sbi)) {
4279 + if (!ext4_has_free_blocks(sb)) {
4283 @@ -1661,12 +1682,16 @@ allocated:
4286 DQUOT_FREE_BLOCK(inode, *count-num);
4287 + DLIMIT_FREE_BLOCK(inode, *count-num);
4294 + if (!performed_allocation)
4295 + DLIMIT_FREE_BLOCK(inode, *count);
4299 ext4_std_error(sb, fatal);
4300 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/file.c linux-2.6.22.10-vs2.2.0.5/fs/ext4/file.c
4301 --- linux-2.6.22.10/fs/ext4/file.c 2007-05-02 19:25:17 +0200
4302 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext4/file.c 2007-10-29 23:24:21 +0100
4303 @@ -135,5 +135,6 @@ const struct inode_operations ext4_file_
4304 .removexattr = generic_removexattr,
4306 .permission = ext4_permission,
4307 + .sync_flags = ext4_sync_flags,
4310 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/ialloc.c linux-2.6.22.10-vs2.2.0.5/fs/ext4/ialloc.c
4311 --- linux-2.6.22.10/fs/ext4/ialloc.c 2006-11-30 21:19:20 +0100
4312 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext4/ialloc.c 2007-06-15 02:37:03 +0200
4314 #include <linux/random.h>
4315 #include <linux/bitops.h>
4316 #include <linux/blkdev.h>
4317 +#include <linux/vs_dlimit.h>
4318 +#include <linux/vs_tag.h>
4319 #include <asm/byteorder.h>
4322 @@ -127,6 +129,7 @@ void ext4_free_inode (handle_t *handle,
4323 ext4_xattr_delete_inode(handle, inode);
4324 DQUOT_FREE_INODE(inode);
4326 + DLIMIT_FREE_INODE(inode);
4328 is_directory = S_ISDIR(inode->i_mode);
4330 @@ -448,6 +451,12 @@ struct inode *ext4_new_inode(handle_t *h
4331 inode = new_inode(sb);
4333 return ERR_PTR(-ENOMEM);
4335 + inode->i_tag = dx_current_fstag(sb);
4336 + if (DLIMIT_ALLOC_INODE(inode)) {
4343 @@ -569,7 +578,8 @@ got:
4344 ei->i_dir_start_lookup = 0;
4347 - ei->i_flags = EXT4_I(dir)->i_flags & ~EXT4_INDEX_FL;
4348 + ei->i_flags = EXT4_I(dir)->i_flags &
4349 + ~(EXT4_INDEX_FL|EXT4_IUNLINK_FL|EXT4_BARRIER_FL);
4351 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
4352 /* dirsync only applies to directories */
4353 @@ -635,6 +645,8 @@ got:
4355 ext4_std_error(sb, err);
4357 + DLIMIT_FREE_INODE(inode);
4362 @@ -646,6 +658,7 @@ fail_free_drop:
4366 + DLIMIT_FREE_INODE(inode);
4367 inode->i_flags |= S_NOQUOTA;
4370 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/inode.c linux-2.6.22.10-vs2.2.0.5/fs/ext4/inode.c
4371 --- linux-2.6.22.10/fs/ext4/inode.c 2007-07-09 13:19:23 +0200
4372 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext4/inode.c 2007-07-07 03:52:53 +0200
4374 #include <linux/mpage.h>
4375 #include <linux/uio.h>
4376 #include <linux/bio.h>
4377 +#include <linux/vs_tag.h>
4381 @@ -2244,7 +2245,7 @@ void ext4_truncate(struct inode *inode)
4383 if (ext4_inode_is_fast_symlink(inode))
4385 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4386 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4390 @@ -2570,19 +2571,65 @@ void ext4_set_inode_flags(struct inode *
4392 unsigned int flags = EXT4_I(inode)->i_flags;
4394 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4395 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
4396 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4398 + if (flags & EXT4_IMMUTABLE_FL)
4399 + inode->i_flags |= S_IMMUTABLE;
4400 + if (flags & EXT4_IUNLINK_FL)
4401 + inode->i_flags |= S_IUNLINK;
4402 + if (flags & EXT4_BARRIER_FL)
4403 + inode->i_flags |= S_BARRIER;
4405 if (flags & EXT4_SYNC_FL)
4406 inode->i_flags |= S_SYNC;
4407 if (flags & EXT4_APPEND_FL)
4408 inode->i_flags |= S_APPEND;
4409 - if (flags & EXT4_IMMUTABLE_FL)
4410 - inode->i_flags |= S_IMMUTABLE;
4411 if (flags & EXT4_NOATIME_FL)
4412 inode->i_flags |= S_NOATIME;
4413 if (flags & EXT4_DIRSYNC_FL)
4414 inode->i_flags |= S_DIRSYNC;
4417 +int ext4_sync_flags(struct inode *inode)
4419 + unsigned int oldflags, newflags;
4422 + oldflags = EXT4_I(inode)->i_flags;
4423 + newflags = oldflags & ~(EXT4_IMMUTABLE_FL |
4424 + EXT4_IUNLINK_FL | EXT4_BARRIER_FL);
4426 + if (IS_IMMUTABLE(inode))
4427 + newflags |= EXT4_IMMUTABLE_FL;
4428 + if (IS_IUNLINK(inode))
4429 + newflags |= EXT4_IUNLINK_FL;
4430 + if (IS_BARRIER(inode))
4431 + newflags |= EXT4_BARRIER_FL;
4433 + if (oldflags ^ newflags) {
4435 + struct ext4_iloc iloc;
4437 + handle = ext4_journal_start(inode, 1);
4438 + if (IS_ERR(handle))
4439 + return PTR_ERR(handle);
4440 + if (IS_SYNC(inode))
4441 + handle->h_sync = 1;
4442 + err = ext4_reserve_inode_write(handle, inode, &iloc);
4446 + EXT4_I(inode)->i_flags = newflags;
4447 + inode->i_ctime = CURRENT_TIME;
4449 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
4451 + ext4_journal_stop(handle);
4456 void ext4_read_inode(struct inode * inode)
4458 struct ext4_iloc iloc;
4459 @@ -2590,6 +2637,8 @@ void ext4_read_inode(struct inode * inod
4460 struct ext4_inode_info *ei = EXT4_I(inode);
4461 struct buffer_head *bh;
4466 #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
4467 ei->i_acl = EXT4_ACL_NOT_CACHED;
4468 @@ -2602,12 +2651,17 @@ void ext4_read_inode(struct inode * inod
4470 raw_inode = ext4_raw_inode(&iloc);
4471 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4472 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4473 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4474 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4475 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4476 if(!(test_opt (inode->i_sb, NO_UID32))) {
4477 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4478 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4479 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4480 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4482 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4483 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4484 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4485 + le16_to_cpu(raw_inode->i_raw_tag));
4487 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4488 inode->i_size = le32_to_cpu(raw_inode->i_size);
4489 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4490 @@ -2737,6 +2791,8 @@ static int ext4_do_update_inode(handle_t
4491 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
4492 struct ext4_inode_info *ei = EXT4_I(inode);
4493 struct buffer_head *bh = iloc->bh;
4494 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4495 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4496 int err = 0, rc, block;
4498 /* For fields not not tracking in the in-memory inode,
4499 @@ -2746,29 +2802,32 @@ static int ext4_do_update_inode(handle_t
4501 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4502 if(!(test_opt(inode->i_sb, NO_UID32))) {
4503 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4504 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4505 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4506 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4508 * Fix up interoperability with old kernels. Otherwise, old inodes get
4509 * re-used with the upper 16 bits of the uid/gid intact
4512 raw_inode->i_uid_high =
4513 - cpu_to_le16(high_16_bits(inode->i_uid));
4514 + cpu_to_le16(high_16_bits(uid));
4515 raw_inode->i_gid_high =
4516 - cpu_to_le16(high_16_bits(inode->i_gid));
4517 + cpu_to_le16(high_16_bits(gid));
4519 raw_inode->i_uid_high = 0;
4520 raw_inode->i_gid_high = 0;
4523 raw_inode->i_uid_low =
4524 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
4525 + cpu_to_le16(fs_high2lowuid(uid));
4526 raw_inode->i_gid_low =
4527 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4528 + cpu_to_le16(fs_high2lowgid(gid));
4529 raw_inode->i_uid_high = 0;
4530 raw_inode->i_gid_high = 0;
4532 +#ifdef CONFIG_TAGGING_INTERN
4533 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4535 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4536 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4537 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4538 @@ -2925,7 +2984,8 @@ int ext4_setattr(struct dentry *dentry,
4541 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4542 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4543 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4544 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4547 /* (user+group)*(old+new) structure, inode write (sb,
4548 @@ -2947,6 +3007,8 @@ int ext4_setattr(struct dentry *dentry,
4549 inode->i_uid = attr->ia_uid;
4550 if (attr->ia_valid & ATTR_GID)
4551 inode->i_gid = attr->ia_gid;
4552 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4553 + inode->i_tag = attr->ia_tag;
4554 error = ext4_mark_inode_dirty(handle, inode);
4555 ext4_journal_stop(handle);
4557 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/ioctl.c linux-2.6.22.10-vs2.2.0.5/fs/ext4/ioctl.c
4558 --- linux-2.6.22.10/fs/ext4/ioctl.c 2007-02-06 03:01:18 +0100
4559 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext4/ioctl.c 2007-06-15 02:37:03 +0200
4563 #include <linux/fs.h>
4564 +#include <linux/mount.h>
4565 #include <linux/jbd2.h>
4566 #include <linux/capability.h>
4567 #include <linux/ext4_fs.h>
4569 #include <linux/time.h>
4570 #include <linux/compat.h>
4571 #include <linux/smp_lock.h>
4572 +#include <linux/vs_tag.h>
4573 #include <asm/uaccess.h>
4575 int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
4576 @@ -37,7 +39,8 @@ int ext4_ioctl (struct inode * inode, st
4577 unsigned int oldflags;
4580 - if (IS_RDONLY(inode))
4581 + if (IS_RDONLY(inode) ||
4582 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4585 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4586 @@ -61,7 +64,9 @@ int ext4_ioctl (struct inode * inode, st
4588 * This test looks nicer. Thanks to Pauline Middelink
4590 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
4591 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
4592 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
4593 + EXT4_IMMUTABLE_FL | EXT4_IUNLINK_FL))) {
4594 if (!capable(CAP_LINUX_IMMUTABLE)) {
4595 mutex_unlock(&inode->i_mutex);
4597 @@ -123,7 +128,8 @@ flags_err:
4599 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4601 - if (IS_RDONLY(inode))
4602 + if (IS_RDONLY(inode) ||
4603 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4605 if (get_user(generation, (int __user *) arg))
4607 @@ -177,7 +183,8 @@ flags_err:
4608 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
4611 - if (IS_RDONLY(inode))
4612 + if (IS_RDONLY(inode) ||
4613 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4616 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4617 @@ -212,7 +219,8 @@ flags_err:
4618 if (!capable(CAP_SYS_RESOURCE))
4621 - if (IS_RDONLY(inode))
4622 + if (IS_RDONLY(inode) ||
4623 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4626 if (get_user(n_blocks_count, (__u32 __user *)arg))
4627 @@ -233,7 +241,8 @@ flags_err:
4628 if (!capable(CAP_SYS_RESOURCE))
4631 - if (IS_RDONLY(inode))
4632 + if (IS_RDONLY(inode) ||
4633 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4636 if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg,
4637 @@ -248,6 +257,39 @@ flags_err:
4641 +#if defined(CONFIG_VSERVER_LEGACY) && !defined(CONFIG_TAGGING_NONE)
4642 + case EXT4_IOC_SETTAG: {
4644 + struct ext4_iloc iloc;
4648 + /* fixme: if stealth, return -ENOTTY */
4649 + if (!capable(CAP_CONTEXT))
4651 + if (IS_RDONLY(inode))
4653 + if (!(inode->i_sb->s_flags & MS_TAGGED))
4655 + if (get_user(tag, (int __user *) arg))
4658 + handle = ext4_journal_start(inode, 1);
4659 + if (IS_ERR(handle))
4660 + return PTR_ERR(handle);
4661 + err = ext4_reserve_inode_write(handle, inode, &iloc);
4665 + inode->i_tag = (tag & 0xFFFF);
4666 + inode->i_ctime = CURRENT_TIME;
4668 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
4669 + ext4_journal_stop(handle);
4677 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/namei.c linux-2.6.22.10-vs2.2.0.5/fs/ext4/namei.c
4678 --- linux-2.6.22.10/fs/ext4/namei.c 2007-10-30 01:57:14 +0100
4679 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext4/namei.c 2007-10-01 15:25:35 +0200
4681 #include <linux/quotaops.h>
4682 #include <linux/buffer_head.h>
4683 #include <linux/bio.h>
4684 +#include <linux/vs_tag.h>
4688 @@ -1050,6 +1051,7 @@ static struct dentry *ext4_lookup(struct
4691 return ERR_PTR(-EACCES);
4692 + dx_propagate_tag(nd, inode);
4694 return d_splice_alias(inode, dentry);
4696 @@ -2441,6 +2443,7 @@ const struct inode_operations ext4_dir_i
4697 .removexattr = generic_removexattr,
4699 .permission = ext4_permission,
4700 + .sync_flags = ext4_sync_flags,
4703 const struct inode_operations ext4_special_inode_operations = {
4704 @@ -2452,4 +2455,5 @@ const struct inode_operations ext4_speci
4705 .removexattr = generic_removexattr,
4707 .permission = ext4_permission,
4708 + .sync_flags = ext4_sync_flags,
4710 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/super.c linux-2.6.22.10-vs2.2.0.5/fs/ext4/super.c
4711 --- linux-2.6.22.10/fs/ext4/super.c 2007-07-09 13:19:23 +0200
4712 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext4/super.c 2007-06-15 02:37:03 +0200
4713 @@ -725,7 +725,7 @@ enum {
4714 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4715 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
4716 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
4717 - Opt_grpquota, Opt_extents,
4718 + Opt_grpquota, Opt_extents, Opt_tag, Opt_notag, Opt_tagid
4721 static match_table_t tokens = {
4722 @@ -776,6 +776,10 @@ static match_table_t tokens = {
4723 {Opt_usrquota, "usrquota"},
4724 {Opt_barrier, "barrier=%u"},
4725 {Opt_extents, "extents"},
4727 + {Opt_notag, "notag"},
4728 + {Opt_tagid, "tagid=%u"},
4729 + {Opt_tag, "tagxid"},
4731 {Opt_resize, "resize"},
4733 @@ -869,6 +873,20 @@ static int parse_options (char *options,
4735 set_opt (sbi->s_mount_opt, NO_UID32);
4737 +#ifndef CONFIG_TAGGING_NONE
4739 + set_opt (sbi->s_mount_opt, TAGGED);
4742 + clear_opt (sbi->s_mount_opt, TAGGED);
4745 +#ifdef CONFIG_PROPAGATE
4748 + set_opt (sbi->s_mount_opt, TAGGED);
4752 clear_opt (sbi->s_mount_opt, CHECK);
4754 @@ -1546,6 +1564,9 @@ static int ext4_fill_super (struct super
4758 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
4759 + sb->s_flags |= MS_TAGGED;
4761 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4762 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4764 @@ -2377,6 +2398,12 @@ static int ext4_remount (struct super_bl
4766 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
4767 ext4_abort(sb, __FUNCTION__, "Abort forced by user");
4768 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
4769 + !(sb->s_flags & MS_TAGGED)) {
4770 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
4775 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4776 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4777 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/symlink.c linux-2.6.22.10-vs2.2.0.5/fs/ext4/symlink.c
4778 --- linux-2.6.22.10/fs/ext4/symlink.c 2007-05-02 19:25:17 +0200
4779 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext4/symlink.c 2007-06-15 02:37:03 +0200
4780 @@ -40,6 +40,7 @@ const struct inode_operations ext4_symli
4781 .listxattr = ext4_listxattr,
4782 .removexattr = generic_removexattr,
4784 + .sync_flags = ext4_sync_flags,
4787 const struct inode_operations ext4_fast_symlink_inode_operations = {
4788 @@ -51,4 +52,5 @@ const struct inode_operations ext4_fast_
4789 .listxattr = ext4_listxattr,
4790 .removexattr = generic_removexattr,
4792 + .sync_flags = ext4_sync_flags,
4794 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/xattr.c linux-2.6.22.10-vs2.2.0.5/fs/ext4/xattr.c
4795 --- linux-2.6.22.10/fs/ext4/xattr.c 2007-05-02 19:25:17 +0200
4796 +++ linux-2.6.22.10-vs2.2.0.5/fs/ext4/xattr.c 2007-06-15 02:37:03 +0200
4798 #include <linux/mbcache.h>
4799 #include <linux/quotaops.h>
4800 #include <linux/rwsem.h>
4801 +#include <linux/vs_dlimit.h>
4805 @@ -496,6 +497,7 @@ ext4_xattr_release_block(handle_t *handl
4806 error = ext4_journal_dirty_metadata(handle, bh);
4809 + DLIMIT_FREE_BLOCK(inode, 1);
4810 DQUOT_FREE_BLOCK(inode, 1);
4811 ea_bdebug(bh, "refcount now=%d; releasing",
4812 le32_to_cpu(BHDR(bh)->h_refcount));
4813 @@ -769,11 +771,14 @@ inserted:
4814 if (new_bh == bs->bh)
4815 ea_bdebug(new_bh, "keeping");
4818 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
4820 /* The old block is released after updating
4823 if (DQUOT_ALLOC_BLOCK(inode, 1))
4825 + goto cleanup_dlimit;
4826 error = ext4_journal_get_write_access(handle,
4829 @@ -850,6 +855,8 @@ cleanup:
4832 DQUOT_FREE_BLOCK(inode, 1);
4834 + DLIMIT_FREE_BLOCK(inode, 1);
4838 diff -NurpP --minimal linux-2.6.22.10/fs/fcntl.c linux-2.6.22.10-vs2.2.0.5/fs/fcntl.c
4839 --- linux-2.6.22.10/fs/fcntl.c 2007-02-06 03:01:18 +0100
4840 +++ linux-2.6.22.10-vs2.2.0.5/fs/fcntl.c 2007-06-15 02:37:03 +0200
4842 #include <linux/ptrace.h>
4843 #include <linux/signal.h>
4844 #include <linux/rcupdate.h>
4845 +#include <linux/vs_limit.h>
4847 #include <asm/poll.h>
4848 #include <asm/siginfo.h>
4849 @@ -84,6 +85,8 @@ repeat:
4851 if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
4853 + if (!vx_files_avail(1))
4856 error = expand_files(files, newfd);
4858 @@ -124,6 +127,7 @@ static int dupfd(struct file *file, unsi
4859 FD_SET(fd, fdt->open_fds);
4860 FD_CLR(fd, fdt->close_on_exec);
4861 spin_unlock(&files->file_lock);
4862 + vx_openfd_inc(fd);
4863 fd_install(fd, file);
4865 spin_unlock(&files->file_lock);
4866 @@ -176,6 +180,9 @@ asmlinkage long sys_dup2(unsigned int ol
4869 filp_close(tofree, files);
4871 + vx_openfd_inc(newfd); /* fd was unused */
4876 diff -NurpP --minimal linux-2.6.22.10/fs/file_table.c linux-2.6.22.10-vs2.2.0.5/fs/file_table.c
4877 --- linux-2.6.22.10/fs/file_table.c 2007-07-09 13:19:23 +0200
4878 +++ linux-2.6.22.10-vs2.2.0.5/fs/file_table.c 2007-06-15 02:37:03 +0200
4880 #include <linux/fsnotify.h>
4881 #include <linux/sysctl.h>
4882 #include <linux/percpu_counter.h>
4883 +#include <linux/vs_limit.h>
4884 +#include <linux/vs_context.h>
4886 #include <asm/atomic.h>
4888 @@ -119,6 +121,8 @@ struct file *get_empty_filp(void)
4889 f->f_gid = tsk->fsgid;
4890 eventpoll_init_file(f);
4891 /* f->f_version: 0 */
4892 + f->f_xid = vx_current_xid();
4897 @@ -174,6 +178,8 @@ void fastcall __fput(struct file *file)
4898 if (file->f_mode & FMODE_WRITE)
4899 put_write_access(inode);
4900 put_pid(file->f_owner.pid);
4901 + vx_files_dec(file);
4904 file->f_path.dentry = NULL;
4905 file->f_path.mnt = NULL;
4906 @@ -239,6 +245,8 @@ void put_filp(struct file *file)
4908 if (atomic_dec_and_test(&file->f_count)) {
4909 security_file_free(file);
4910 + vx_files_dec(file);
4915 diff -NurpP --minimal linux-2.6.22.10/fs/hfsplus/ioctl.c linux-2.6.22.10-vs2.2.0.5/fs/hfsplus/ioctl.c
4916 --- linux-2.6.22.10/fs/hfsplus/ioctl.c 2006-11-30 21:19:25 +0100
4917 +++ linux-2.6.22.10-vs2.2.0.5/fs/hfsplus/ioctl.c 2007-06-15 02:37:03 +0200
4919 #include <linux/fs.h>
4920 #include <linux/sched.h>
4921 #include <linux/xattr.h>
4922 +#include <linux/mount.h>
4923 #include <asm/uaccess.h>
4924 #include "hfsplus_fs.h"
4926 @@ -35,7 +36,8 @@ int hfsplus_ioctl(struct inode *inode, s
4927 flags |= FS_NODUMP_FL; /* EXT2_NODUMP_FL */
4928 return put_user(flags, (int __user *)arg);
4929 case HFSPLUS_IOC_EXT2_SETFLAGS: {
4930 - if (IS_RDONLY(inode))
4931 + if (IS_RDONLY(inode) ||
4932 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4935 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4936 diff -NurpP --minimal linux-2.6.22.10/fs/inode.c linux-2.6.22.10-vs2.2.0.5/fs/inode.c
4937 --- linux-2.6.22.10/fs/inode.c 2007-07-09 13:19:24 +0200
4938 +++ linux-2.6.22.10-vs2.2.0.5/fs/inode.c 2007-06-15 02:37:03 +0200
4939 @@ -115,6 +115,9 @@ static struct inode *alloc_inode(struct
4940 struct address_space * const mapping = &inode->i_data;
4944 + /* essential because of inode slab reuse */
4946 inode->i_blkbits = sb->s_blocksize_bits;
4948 atomic_set(&inode->i_count, 1);
4949 @@ -231,6 +234,8 @@ void __iget(struct inode * inode)
4950 inodes_stat.nr_unused--;
4953 +EXPORT_SYMBOL_GPL(__iget);
4956 * clear_inode - clear an inode
4957 * @inode: inode to clear
4958 diff -NurpP --minimal linux-2.6.22.10/fs/ioctl.c linux-2.6.22.10-vs2.2.0.5/fs/ioctl.c
4959 --- linux-2.6.22.10/fs/ioctl.c 2007-07-09 13:19:24 +0200
4960 +++ linux-2.6.22.10-vs2.2.0.5/fs/ioctl.c 2007-06-15 03:12:40 +0200
4962 #include <linux/security.h>
4963 #include <linux/module.h>
4964 #include <linux/kallsyms.h>
4965 +#include <linux/proc_fs.h>
4966 +#include <linux/vserver/inode.h>
4967 +#include <linux/vs_tag.h>
4969 #include <asm/uaccess.h>
4970 #include <asm/ioctls.h>
4973 +#ifdef CONFIG_VSERVER_LEGACY
4974 +extern int vx_proc_ioctl(struct inode *, struct file *,
4975 + unsigned int, unsigned long);
4978 static long do_ioctl(struct file *filp, unsigned int cmd,
4981 @@ -152,6 +161,48 @@ int vfs_ioctl(struct file *filp, unsigne
4985 +#ifdef CONFIG_VSERVER_LEGACY
4986 +#ifndef CONFIG_TAGGING_NONE
4987 + case FIOC_GETTAG: {
4988 + struct inode *inode = filp->f_dentry->d_inode;
4990 + /* fixme: if stealth, return -ENOTTY */
4992 + if (capable(CAP_CONTEXT))
4993 + error = put_user(inode->i_tag, (int __user *) arg);
4996 + case FIOC_SETTAG: {
4997 + struct inode *inode = filp->f_dentry->d_inode;
5000 + /* fixme: if stealth, return -ENOTTY */
5002 + if (!capable(CAP_CONTEXT))
5005 + if (IS_RDONLY(inode))
5008 + if (!(inode->i_sb->s_flags & MS_TAGGED))
5011 + if (get_user(tag, (int __user *) arg))
5014 + inode->i_tag = (tag & 0xFFFF);
5015 + inode->i_ctime = CURRENT_TIME;
5016 + mark_inode_dirty(inode);
5020 + case FIOC_GETXFLG:
5021 + case FIOC_SETXFLG:
5023 + if (filp->f_dentry->d_inode->i_sb->s_magic == PROC_SUPER_MAGIC)
5024 + error = vx_proc_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
5028 if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
5029 error = file_ioctl(filp, cmd, arg);
5030 diff -NurpP --minimal linux-2.6.22.10/fs/ioprio.c linux-2.6.22.10-vs2.2.0.5/fs/ioprio.c
5031 --- linux-2.6.22.10/fs/ioprio.c 2007-05-02 19:25:18 +0200
5032 +++ linux-2.6.22.10-vs2.2.0.5/fs/ioprio.c 2007-06-15 02:37:03 +0200
5034 #include <linux/capability.h>
5035 #include <linux/syscalls.h>
5036 #include <linux/security.h>
5037 +#include <linux/vs_base.h>
5039 static int set_task_ioprio(struct task_struct *task, int ioprio)
5041 @@ -103,6 +104,8 @@ asmlinkage long sys_ioprio_set(int which
5043 pgrp = find_pid(who);
5044 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
5045 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5047 ret = set_task_ioprio(p, ioprio);
5050 @@ -112,7 +115,7 @@ asmlinkage long sys_ioprio_set(int which
5052 user = current->user;
5054 - user = find_user(who);
5055 + user = find_user(vx_current_xid(), who);
5059 @@ -190,6 +193,8 @@ asmlinkage long sys_ioprio_get(int which
5061 pgrp = find_pid(who);
5062 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
5063 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5065 tmpio = get_task_ioprio(p);
5068 @@ -203,7 +208,7 @@ asmlinkage long sys_ioprio_get(int which
5070 user = current->user;
5072 - user = find_user(who);
5073 + user = find_user(vx_current_xid(), who);
5077 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/acl.c linux-2.6.22.10-vs2.2.0.5/fs/jfs/acl.c
5078 --- linux-2.6.22.10/fs/jfs/acl.c 2006-11-30 21:19:25 +0100
5079 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/acl.c 2007-06-15 02:37:03 +0200
5080 @@ -232,7 +232,8 @@ int jfs_setattr(struct dentry *dentry, s
5083 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
5084 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
5085 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
5086 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
5087 if (DQUOT_TRANSFER(inode, iattr))
5090 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/file.c linux-2.6.22.10-vs2.2.0.5/fs/jfs/file.c
5091 --- linux-2.6.22.10/fs/jfs/file.c 2007-05-02 19:25:18 +0200
5092 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/file.c 2007-10-29 23:24:21 +0100
5093 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
5094 .setattr = jfs_setattr,
5095 .permission = jfs_permission,
5097 + .sync_flags = jfs_sync_flags,
5100 const struct file_operations jfs_file_operations = {
5101 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/inode.c linux-2.6.22.10-vs2.2.0.5/fs/jfs/inode.c
5102 --- linux-2.6.22.10/fs/jfs/inode.c 2007-07-09 13:19:26 +0200
5103 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/inode.c 2007-06-15 02:37:03 +0200
5105 #include <linux/buffer_head.h>
5106 #include <linux/pagemap.h>
5107 #include <linux/quotaops.h>
5108 +#include <linux/vs_dlimit.h>
5109 #include "jfs_incore.h"
5110 #include "jfs_inode.h"
5111 #include "jfs_filsys.h"
5112 @@ -143,6 +144,7 @@ void jfs_delete_inode(struct inode *inod
5114 DQUOT_FREE_INODE(inode);
5116 + DLIMIT_FREE_INODE(inode);
5120 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/ioctl.c linux-2.6.22.10-vs2.2.0.5/fs/jfs/ioctl.c
5121 --- linux-2.6.22.10/fs/jfs/ioctl.c 2007-07-09 13:19:27 +0200
5122 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/ioctl.c 2007-06-15 02:37:03 +0200
5124 #include <linux/capability.h>
5125 #include <linux/time.h>
5126 #include <linux/sched.h>
5127 +#include <linux/mount.h>
5128 #include <asm/current.h>
5129 #include <asm/uaccess.h>
5131 @@ -66,7 +67,8 @@ int jfs_ioctl(struct inode * inode, stru
5132 case JFS_IOC_SETFLAGS: {
5133 unsigned int oldflags;
5135 - if (IS_RDONLY(inode))
5136 + if (IS_RDONLY(inode) ||
5137 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
5140 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
5141 @@ -87,8 +89,8 @@ int jfs_ioctl(struct inode * inode, stru
5142 * the relevant capability.
5144 if ((oldflags & JFS_IMMUTABLE_FL) ||
5145 - ((flags ^ oldflags) &
5146 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
5147 + ((flags ^ oldflags) & (JFS_APPEND_FL |
5148 + JFS_IMMUTABLE_FL | JFS_IUNLINK_FL))) {
5149 if (!capable(CAP_LINUX_IMMUTABLE))
5152 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_dinode.h linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_dinode.h
5153 --- linux-2.6.22.10/fs/jfs/jfs_dinode.h 2006-11-30 21:19:25 +0100
5154 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_dinode.h 2007-06-15 02:37:03 +0200
5155 @@ -162,9 +162,12 @@ struct dinode {
5156 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
5157 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
5159 -#define JFS_FL_USER_VISIBLE 0x03F80000
5160 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
5161 +#define JFS_IUNLINK_FL 0x08000000 /* Immutable unlink */
5163 +#define JFS_FL_USER_VISIBLE 0x0FF80000
5164 #define JFS_FL_USER_MODIFIABLE 0x03F80000
5165 -#define JFS_FL_INHERIT 0x03C80000
5166 +#define JFS_FL_INHERIT 0x0BC80000
5168 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
5169 #define JFS_IOC_GETFLAGS _IOR('f', 1, long)
5170 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_dtree.c linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_dtree.c
5171 --- linux-2.6.22.10/fs/jfs/jfs_dtree.c 2007-02-06 03:01:24 +0100
5172 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_dtree.c 2007-06-15 02:37:03 +0200
5175 #include <linux/fs.h>
5176 #include <linux/quotaops.h>
5177 +#include <linux/vs_dlimit.h>
5178 #include "jfs_incore.h"
5179 #include "jfs_superblock.h"
5180 #include "jfs_filsys.h"
5181 @@ -383,10 +384,10 @@ static u32 add_index(tid_t tid, struct i
5183 if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage))
5185 - if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
5186 - DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
5189 + if (DLIMIT_ALLOC_BLOCK(ip, sbi->nbperpage))
5190 + goto clean_up_dquot;
5191 + if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr))
5192 + goto clean_up_dlimit;
5195 * Save the table, we're going to overwrite it with the
5196 @@ -479,6 +480,12 @@ static u32 add_index(tid_t tid, struct i
5201 + DLIMIT_FREE_BLOCK(ip, sbi->nbperpage);
5204 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
5208 jfs_ip->next_index--;
5209 @@ -952,6 +959,7 @@ static int dtSplitUp(tid_t tid,
5212 int quota_allocation = 0;
5213 + int dlimit_allocation = 0;
5215 /* get split page */
5217 @@ -1036,6 +1044,12 @@ static int dtSplitUp(tid_t tid,
5219 quota_allocation += n;
5221 + if (DLIMIT_ALLOC_BLOCK(ip, n)) {
5225 + dlimit_allocation += n;
5227 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
5230 @@ -1309,6 +1323,9 @@ static int dtSplitUp(tid_t tid,
5234 + /* Rollback dlimit allocation */
5235 + if (rc && dlimit_allocation)
5236 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
5237 /* Rollback quota allocation */
5238 if (rc && quota_allocation)
5239 DQUOT_FREE_BLOCK(ip, quota_allocation);
5240 @@ -1376,6 +1393,12 @@ static int dtSplitPage(tid_t tid, struct
5241 release_metapage(rmp);
5244 + /* Allocate blocks to dlimit. */
5245 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5246 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
5247 + release_metapage(rmp);
5251 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
5253 @@ -1926,6 +1949,12 @@ static int dtSplitRoot(tid_t tid,
5254 release_metapage(rmp);
5257 + /* Allocate blocks to dlimit. */
5258 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5259 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
5260 + release_metapage(rmp);
5264 BT_MARK_DIRTY(rmp, ip);
5266 @@ -2292,6 +2321,8 @@ static int dtDeleteUp(tid_t tid, struct
5268 xlen = lengthPXD(&fp->header.self);
5270 + /* Free dlimit allocation. */
5271 + DLIMIT_FREE_BLOCK(ip, xlen);
5272 /* Free quota allocation. */
5273 DQUOT_FREE_BLOCK(ip, xlen);
5275 @@ -2368,6 +2399,8 @@ static int dtDeleteUp(tid_t tid, struct
5277 xlen = lengthPXD(&p->header.self);
5279 + /* Free dlimit allocation */
5280 + DLIMIT_FREE_BLOCK(ip, xlen);
5281 /* Free quota allocation */
5282 DQUOT_FREE_BLOCK(ip, xlen);
5284 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_extent.c linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_extent.c
5285 --- linux-2.6.22.10/fs/jfs/jfs_extent.c 2006-11-30 21:19:25 +0100
5286 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_extent.c 2007-06-15 02:37:03 +0200
5289 #include <linux/fs.h>
5290 #include <linux/quotaops.h>
5291 +#include <linux/vs_dlimit.h>
5292 #include "jfs_incore.h"
5293 #include "jfs_inode.h"
5294 #include "jfs_superblock.h"
5295 @@ -147,6 +148,14 @@ extAlloc(struct inode *ip, s64 xlen, s64
5299 + /* Allocate blocks to dlimit. */
5300 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
5301 + DQUOT_FREE_BLOCK(ip, nxlen);
5302 + dbFree(ip, nxaddr, (s64) nxlen);
5303 + mutex_unlock(&JFS_IP(ip)->commit_mutex);
5307 /* determine the value of the extent flag */
5308 xflag = abnr ? XAD_NOTRECORDED : 0;
5310 @@ -164,6 +173,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
5313 dbFree(ip, nxaddr, nxlen);
5314 + DLIMIT_FREE_BLOCK(ip, nxlen);
5315 DQUOT_FREE_BLOCK(ip, nxlen);
5316 mutex_unlock(&JFS_IP(ip)->commit_mutex);
5318 @@ -261,6 +271,13 @@ int extRealloc(struct inode *ip, s64 nxl
5319 mutex_unlock(&JFS_IP(ip)->commit_mutex);
5322 + /* Allocate blocks to dlimit. */
5323 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
5324 + DQUOT_FREE_BLOCK(ip, nxlen);
5325 + dbFree(ip, nxaddr, (s64) nxlen);
5326 + up(&JFS_IP(ip)->commit_sem);
5330 delta = nxlen - xlen;
5332 @@ -297,6 +314,7 @@ int extRealloc(struct inode *ip, s64 nxl
5333 /* extend the extent */
5334 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
5335 dbFree(ip, xaddr + xlen, delta);
5336 + DLIMIT_FREE_BLOCK(ip, nxlen);
5337 DQUOT_FREE_BLOCK(ip, nxlen);
5340 @@ -308,6 +326,7 @@ int extRealloc(struct inode *ip, s64 nxl
5342 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
5343 dbFree(ip, nxaddr, nxlen);
5344 + DLIMIT_FREE_BLOCK(ip, nxlen);
5345 DQUOT_FREE_BLOCK(ip, nxlen);
5348 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_filsys.h linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_filsys.h
5349 --- linux-2.6.22.10/fs/jfs/jfs_filsys.h 2007-02-06 03:01:24 +0100
5350 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_filsys.h 2007-06-15 02:37:03 +0200
5352 #define JFS_NAME_MAX 255
5353 #define JFS_PATH_MAX BPSIZE
5355 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
5358 * file system state (superblock state)
5359 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_imap.c linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_imap.c
5360 --- linux-2.6.22.10/fs/jfs/jfs_imap.c 2007-07-09 13:19:27 +0200
5361 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_imap.c 2007-06-15 03:01:50 +0200
5363 #include <linux/buffer_head.h>
5364 #include <linux/pagemap.h>
5365 #include <linux/quotaops.h>
5366 +#include <linux/vs_tag.h>
5368 #include "jfs_incore.h"
5369 #include "jfs_inode.h"
5370 @@ -3075,6 +3076,8 @@ static int copy_from_dinode(struct dinod
5372 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
5373 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
5377 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
5378 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
5379 @@ -3095,14 +3098,18 @@ static int copy_from_dinode(struct dinod
5381 ip->i_nlink = le32_to_cpu(dip->di_nlink);
5383 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
5384 + uid = le32_to_cpu(dip->di_uid);
5385 + gid = le32_to_cpu(dip->di_gid);
5386 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
5388 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
5390 ip->i_uid = jfs_ip->saved_uid;
5392 ip->i_uid = sbi->uid;
5395 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
5396 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
5398 ip->i_gid = jfs_ip->saved_gid;
5400 @@ -3167,14 +3174,12 @@ static void copy_to_dinode(struct dinode
5401 dip->di_size = cpu_to_le64(ip->i_size);
5402 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
5403 dip->di_nlink = cpu_to_le32(ip->i_nlink);
5404 - if (sbi->uid == -1)
5405 - dip->di_uid = cpu_to_le32(ip->i_uid);
5407 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
5408 - if (sbi->gid == -1)
5409 - dip->di_gid = cpu_to_le32(ip->i_gid);
5411 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
5413 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
5414 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
5415 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
5416 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
5418 jfs_get_inode_flags(jfs_ip);
5420 * mode2 is only needed for storing the higher order bits.
5421 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_inode.c linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_inode.c
5422 --- linux-2.6.22.10/fs/jfs/jfs_inode.c 2007-07-09 13:19:27 +0200
5423 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_inode.c 2007-07-19 08:09:20 +0200
5426 #include <linux/fs.h>
5427 #include <linux/quotaops.h>
5428 +#include <linux/vs_dlimit.h>
5429 +#include <linux/vs_tag.h>
5430 #include "jfs_incore.h"
5431 #include "jfs_inode.h"
5432 #include "jfs_filsys.h"
5433 @@ -30,19 +32,47 @@ void jfs_set_inode_flags(struct inode *i
5435 unsigned int flags = JFS_IP(inode)->mode2;
5437 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
5438 - S_NOATIME | S_DIRSYNC | S_SYNC);
5439 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
5440 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5442 if (flags & JFS_IMMUTABLE_FL)
5443 inode->i_flags |= S_IMMUTABLE;
5444 + if (flags & JFS_IUNLINK_FL)
5445 + inode->i_flags |= S_IUNLINK;
5446 + if (flags & JFS_BARRIER_FL)
5447 + inode->i_flags |= S_BARRIER;
5449 + if (flags & JFS_SYNC_FL)
5450 + inode->i_flags |= S_SYNC;
5451 if (flags & JFS_APPEND_FL)
5452 inode->i_flags |= S_APPEND;
5453 if (flags & JFS_NOATIME_FL)
5454 inode->i_flags |= S_NOATIME;
5455 if (flags & JFS_DIRSYNC_FL)
5456 inode->i_flags |= S_DIRSYNC;
5457 - if (flags & JFS_SYNC_FL)
5458 - inode->i_flags |= S_SYNC;
5461 +int jfs_sync_flags(struct inode *inode)
5463 + unsigned int oldflags, newflags;
5465 + oldflags = JFS_IP(inode)->mode2;
5466 + newflags = oldflags & ~(JFS_IMMUTABLE_FL |
5467 + JFS_IUNLINK_FL | JFS_BARRIER_FL);
5469 + if (IS_IMMUTABLE(inode))
5470 + newflags |= JFS_IMMUTABLE_FL;
5471 + if (IS_IUNLINK(inode))
5472 + newflags |= JFS_IUNLINK_FL;
5473 + if (IS_BARRIER(inode))
5474 + newflags |= JFS_BARRIER_FL;
5476 + if (oldflags ^ newflags) {
5477 + JFS_IP(inode)->mode2 = newflags;
5478 + inode->i_ctime = CURRENT_TIME;
5479 + mark_inode_dirty(inode);
5484 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
5485 @@ -108,10 +138,17 @@ struct inode *ialloc(struct inode *paren
5486 jfs_inode->saved_uid = inode->i_uid;
5487 jfs_inode->saved_gid = inode->i_gid;
5489 + inode->i_tag = dx_current_fstag(sb);
5490 + if (DLIMIT_ALLOC_INODE(inode)) {
5492 + return ERR_PTR(-ENOSPC);
5496 * Allocate inode to quota.
5498 if (DQUOT_ALLOC_INODE(inode)) {
5499 + DLIMIT_FREE_INODE(inode);
5501 inode->i_flags |= S_NOQUOTA;
5503 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_inode.h linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_inode.h
5504 --- linux-2.6.22.10/fs/jfs/jfs_inode.h 2007-07-09 13:19:27 +0200
5505 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_inode.h 2007-06-15 03:02:28 +0200
5506 @@ -33,6 +33,7 @@ extern void jfs_free_zero_link(struct in
5507 extern struct dentry *jfs_get_parent(struct dentry *dentry);
5508 extern void jfs_get_inode_flags(struct jfs_inode_info *);
5509 extern void jfs_set_inode_flags(struct inode *);
5510 +extern int jfs_sync_flags(struct inode *);
5511 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
5513 extern const struct address_space_operations jfs_aops;
5514 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_xtree.c linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_xtree.c
5515 --- linux-2.6.22.10/fs/jfs/jfs_xtree.c 2007-05-02 19:25:18 +0200
5516 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/jfs_xtree.c 2007-06-15 02:37:03 +0200
5519 #include <linux/fs.h>
5520 #include <linux/quotaops.h>
5521 +#include <linux/vs_dlimit.h>
5522 #include "jfs_incore.h"
5523 #include "jfs_filsys.h"
5524 #include "jfs_metapage.h"
5525 @@ -846,7 +847,12 @@ int xtInsert(tid_t tid, /* transaction
5527 if ((rc = DQUOT_ALLOC_BLOCK(ip, xlen)))
5529 + if ((rc = DLIMIT_ALLOC_BLOCK(ip, xlen))) {
5530 + DQUOT_FREE_BLOCK(ip, xlen);
5533 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
5534 + DLIMIT_FREE_BLOCK(ip, xlen);
5535 DQUOT_FREE_BLOCK(ip, xlen);
5538 @@ -876,6 +882,7 @@ int xtInsert(tid_t tid, /* transaction
5539 /* undo data extent allocation */
5541 dbFree(ip, xaddr, (s64) xlen);
5542 + DLIMIT_FREE_BLOCK(ip, xlen);
5543 DQUOT_FREE_BLOCK(ip, xlen);
5546 @@ -1236,6 +1243,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
5548 struct xtlock *sxtlck = NULL, *rxtlck = NULL;
5549 int quota_allocation = 0;
5550 + int dlimit_allocation = 0;
5553 sp = XT_PAGE(ip, smp);
5554 @@ -1255,6 +1263,13 @@ xtSplitPage(tid_t tid, struct inode *ip,
5556 quota_allocation += lengthPXD(pxd);
5558 + /* Allocate blocks to dlimit. */
5559 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5563 + dlimit_allocation += lengthPXD(pxd);
5566 * allocate the new right page for the split
5568 @@ -1456,6 +1471,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
5572 + /* Rollback dlimit allocation. */
5573 + if (dlimit_allocation)
5574 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
5575 /* Rollback quota allocation. */
5576 if (quota_allocation)
5577 DQUOT_FREE_BLOCK(ip, quota_allocation);
5578 @@ -1520,6 +1538,12 @@ xtSplitRoot(tid_t tid,
5579 release_metapage(rmp);
5582 + /* Allocate blocks to dlimit. */
5583 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5584 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
5585 + release_metapage(rmp);
5589 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
5591 @@ -3951,6 +3975,8 @@ s64 xtTruncate(tid_t tid, struct inode *
5593 ip->i_size = newsize;
5595 + /* update dlimit allocation to reflect freed blocks */
5596 + DLIMIT_FREE_BLOCK(ip, nfreed);
5597 /* update quota allocation to reflect freed blocks */
5598 DQUOT_FREE_BLOCK(ip, nfreed);
5600 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/namei.c linux-2.6.22.10-vs2.2.0.5/fs/jfs/namei.c
5601 --- linux-2.6.22.10/fs/jfs/namei.c 2007-05-02 19:25:18 +0200
5602 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/namei.c 2007-06-15 02:37:03 +0200
5604 #include <linux/fs.h>
5605 #include <linux/ctype.h>
5606 #include <linux/quotaops.h>
5607 +#include <linux/vs_tag.h>
5608 #include "jfs_incore.h"
5609 #include "jfs_superblock.h"
5610 #include "jfs_inode.h"
5611 @@ -1469,6 +1470,7 @@ static struct dentry *jfs_lookup(struct
5612 return ERR_PTR(-EACCES);
5615 + dx_propagate_tag(nd, ip);
5616 dentry = d_splice_alias(ip, dentry);
5618 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
5619 @@ -1521,6 +1523,7 @@ const struct inode_operations jfs_dir_in
5620 .setattr = jfs_setattr,
5621 .permission = jfs_permission,
5623 + .sync_flags = jfs_sync_flags,
5626 const struct file_operations jfs_dir_operations = {
5627 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/super.c linux-2.6.22.10-vs2.2.0.5/fs/jfs/super.c
5628 --- linux-2.6.22.10/fs/jfs/super.c 2007-07-09 13:19:27 +0200
5629 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/super.c 2007-06-15 02:37:03 +0200
5630 @@ -194,7 +194,8 @@ static void jfs_put_super(struct super_b
5632 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
5633 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
5634 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
5635 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
5636 + Opt_tag, Opt_notag, Opt_tagid
5639 static match_table_t tokens = {
5640 @@ -204,6 +205,10 @@ static match_table_t tokens = {
5641 {Opt_resize, "resize=%u"},
5642 {Opt_resize_nosize, "resize"},
5643 {Opt_errors, "errors=%s"},
5645 + {Opt_notag, "notag"},
5646 + {Opt_tagid, "tagid=%u"},
5647 + {Opt_tag, "tagxid"},
5648 {Opt_ignore, "noquota"},
5649 {Opt_ignore, "quota"},
5650 {Opt_usrquota, "usrquota"},
5651 @@ -338,6 +343,20 @@ static int parse_options(char *options,
5655 +#ifndef CONFIG_TAGGING_NONE
5657 + *flag |= JFS_TAGGED;
5660 + *flag &= JFS_TAGGED;
5663 +#ifdef CONFIG_PROPAGATE
5666 + *flag |= JFS_TAGGED;
5670 printk("jfs: Unrecognized mount option \"%s\" "
5671 " or missing value\n", p);
5672 @@ -368,6 +387,13 @@ static int jfs_remount(struct super_bloc
5673 if (!parse_options(data, sb, &newLVSize, &flag)) {
5677 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
5678 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
5684 if (sb->s_flags & MS_RDONLY) {
5686 @@ -439,6 +465,9 @@ static int jfs_fill_super(struct super_b
5687 #ifdef CONFIG_JFS_POSIX_ACL
5688 sb->s_flags |= MS_POSIXACL;
5690 + /* map mount option tagxid */
5691 + if (sbi->flag & JFS_TAGGED)
5692 + sb->s_flags |= MS_TAGGED;
5695 printk(KERN_ERR "resize option for remount only\n");
5696 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/xattr.c linux-2.6.22.10-vs2.2.0.5/fs/jfs/xattr.c
5697 --- linux-2.6.22.10/fs/jfs/xattr.c 2006-11-30 21:19:26 +0100
5698 +++ linux-2.6.22.10-vs2.2.0.5/fs/jfs/xattr.c 2007-06-15 02:37:03 +0200
5700 #include <linux/posix_acl_xattr.h>
5701 #include <linux/quotaops.h>
5702 #include <linux/security.h>
5703 +#include <linux/vs_dlimit.h>
5704 #include "jfs_incore.h"
5705 #include "jfs_superblock.h"
5706 #include "jfs_dmap.h"
5707 @@ -263,9 +264,16 @@ static int ea_write(struct inode *ip, st
5708 if (DQUOT_ALLOC_BLOCK(ip, nblocks)) {
5711 + /* Allocate new blocks to dlimit. */
5712 + if (DLIMIT_ALLOC_BLOCK(ip, nblocks)) {
5713 + DQUOT_FREE_BLOCK(ip, nblocks);
5717 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
5719 + /*Rollback dlimit allocation. */
5720 + DLIMIT_FREE_BLOCK(ip, nblocks);
5721 /*Rollback quota allocation. */
5722 DQUOT_FREE_BLOCK(ip, nblocks);
5724 @@ -332,6 +340,8 @@ static int ea_write(struct inode *ip, st
5727 /* Rollback quota allocation. */
5728 + DLIMIT_FREE_BLOCK(ip, nblocks);
5729 + /* Rollback quota allocation. */
5730 DQUOT_FREE_BLOCK(ip, nblocks);
5732 dbFree(ip, blkno, nblocks);
5733 @@ -468,6 +478,7 @@ static int ea_get(struct inode *inode, s
5736 int quota_allocation = 0;
5737 + int dlimit_allocation = 0;
5739 /* When fsck.jfs clears a bad ea, it doesn't clear the size */
5740 if (ji->ea.flag == 0)
5741 @@ -543,6 +554,12 @@ static int ea_get(struct inode *inode, s
5743 quota_allocation = blocks_needed;
5745 + /* Allocate new blocks to dlimit. */
5747 + if (DLIMIT_ALLOC_BLOCK(inode, blocks_needed))
5749 + dlimit_allocation = blocks_needed;
5751 rc = dbAlloc(inode, INOHINT(inode), (s64) blocks_needed,
5754 @@ -599,6 +616,9 @@ static int ea_get(struct inode *inode, s
5758 + /* Rollback dlimit allocation */
5759 + if (dlimit_allocation)
5760 + DLIMIT_FREE_BLOCK(inode, dlimit_allocation);
5761 /* Rollback quota allocation */
5762 if (quota_allocation)
5763 DQUOT_FREE_BLOCK(inode, quota_allocation);
5764 @@ -675,8 +695,10 @@ static int ea_put(tid_t tid, struct inod
5767 /* If old blocks exist, they must be removed from quota allocation. */
5770 + DLIMIT_FREE_BLOCK(inode, old_blocks);
5771 DQUOT_FREE_BLOCK(inode, old_blocks);
5774 inode->i_ctime = CURRENT_TIME;
5776 diff -NurpP --minimal linux-2.6.22.10/fs/libfs.c linux-2.6.22.10-vs2.2.0.5/fs/libfs.c
5777 --- linux-2.6.22.10/fs/libfs.c 2007-07-09 13:19:27 +0200
5778 +++ linux-2.6.22.10-vs2.2.0.5/fs/libfs.c 2007-06-15 02:37:03 +0200
5779 @@ -124,7 +124,8 @@ static inline unsigned char dt_type(stru
5780 * both impossible due to the lock on directory.
5783 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
5784 +static inline int do_dcache_readdir_filter(struct file *filp,
5785 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
5787 struct dentry *dentry = filp->f_path.dentry;
5788 struct dentry *cursor = filp->private_data;
5789 @@ -157,6 +158,8 @@ int dcache_readdir(struct file * filp, v
5790 next = list_entry(p, struct dentry, d_u.d_child);
5791 if (d_unhashed(next) || !next->d_inode)
5793 + if (filter && !filter(next))
5796 spin_unlock(&dcache_lock);
5797 if (filldir(dirent, next->d_name.name,
5798 @@ -175,6 +178,18 @@ int dcache_readdir(struct file * filp, v
5802 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
5804 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
5807 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
5808 + int (*filter)(struct dentry *))
5810 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
5814 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
5817 @@ -640,6 +655,7 @@ EXPORT_SYMBOL(dcache_dir_close);
5818 EXPORT_SYMBOL(dcache_dir_lseek);
5819 EXPORT_SYMBOL(dcache_dir_open);
5820 EXPORT_SYMBOL(dcache_readdir);
5821 +EXPORT_SYMBOL(dcache_readdir_filter);
5822 EXPORT_SYMBOL(generic_read_dir);
5823 EXPORT_SYMBOL(get_sb_pseudo);
5824 EXPORT_SYMBOL(simple_commit_write);
5825 diff -NurpP --minimal linux-2.6.22.10/fs/locks.c linux-2.6.22.10-vs2.2.0.5/fs/locks.c
5826 --- linux-2.6.22.10/fs/locks.c 2007-10-30 01:57:14 +0100
5827 +++ linux-2.6.22.10-vs2.2.0.5/fs/locks.c 2007-10-01 15:26:40 +0200
5829 #include <linux/syscalls.h>
5830 #include <linux/time.h>
5831 #include <linux/rcupdate.h>
5832 +#include <linux/vs_base.h>
5833 +#include <linux/vs_limit.h>
5835 #include <asm/semaphore.h>
5836 #include <asm/uaccess.h>
5837 @@ -147,6 +149,8 @@ static struct kmem_cache *filelock_cache
5838 /* Allocate an empty lock structure. */
5839 static struct file_lock *locks_alloc_lock(void)
5841 + if (!vx_locks_avail(1))
5843 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
5846 @@ -172,6 +176,7 @@ static void locks_free_lock(struct file_
5847 BUG_ON(!list_empty(&fl->fl_block));
5848 BUG_ON(!list_empty(&fl->fl_link));
5851 locks_release_private(fl);
5852 kmem_cache_free(filelock_cache, fl);
5854 @@ -191,6 +196,7 @@ void locks_init_lock(struct file_lock *f
5855 fl->fl_start = fl->fl_end = 0;
5857 fl->fl_lmops = NULL;
5861 EXPORT_SYMBOL(locks_init_lock);
5862 @@ -244,6 +250,7 @@ void locks_copy_lock(struct file_lock *n
5863 new->fl_file = fl->fl_file;
5864 new->fl_ops = fl->fl_ops;
5865 new->fl_lmops = fl->fl_lmops;
5866 + new->fl_xid = fl->fl_xid;
5868 locks_copy_private(new, fl);
5870 @@ -282,6 +289,11 @@ static int flock_make_lock(struct file *
5871 fl->fl_flags = FL_FLOCK;
5873 fl->fl_end = OFFSET_MAX;
5875 + vxd_assert(filp->f_xid == vx_current_xid(),
5876 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5877 + fl->fl_xid = filp->f_xid;
5882 @@ -447,6 +459,7 @@ static int lease_init(struct file *filp,
5884 fl->fl_owner = current->files;
5885 fl->fl_pid = current->tgid;
5886 + fl->fl_xid = vx_current_xid();
5889 fl->fl_flags = FL_LEASE;
5890 @@ -466,6 +479,11 @@ static int lease_alloc(struct file *filp
5894 + fl->fl_xid = vx_current_xid();
5896 + vxd_assert(filp->f_xid == fl->fl_xid,
5897 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
5899 error = lease_init(filp, type, fl);
5901 locks_free_lock(fl);
5902 @@ -769,6 +787,7 @@ static int flock_lock_file(struct file *
5906 + new_fl->fl_xid = -1;
5908 for_each_lock(inode, before) {
5909 struct file_lock *fl = *before;
5910 @@ -787,6 +806,7 @@ find_conflict:
5912 locks_copy_lock(new_fl, request);
5913 locks_insert_lock(before, new_fl);
5914 + vx_locks_inc(new_fl);
5918 @@ -797,7 +817,8 @@ out:
5922 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
5923 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
5924 + struct file_lock *conflock, xid_t xid)
5926 struct file_lock *fl;
5927 struct file_lock *new_fl = NULL;
5928 @@ -807,6 +828,8 @@ static int __posix_lock_file(struct inod
5929 struct file_lock **before;
5930 int error, added = 0;
5932 + vxd_assert(xid == vx_current_xid(),
5933 + "xid(%d) == current(%d)", xid, vx_current_xid());
5935 * We may need two file_lock structures for this operation,
5936 * so we get them in advance to avoid races.
5937 @@ -817,7 +840,11 @@ static int __posix_lock_file(struct inod
5938 (request->fl_type != F_UNLCK ||
5939 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
5940 new_fl = locks_alloc_lock();
5941 + new_fl->fl_xid = xid;
5942 + vx_locks_inc(new_fl);
5943 new_fl2 = locks_alloc_lock();
5944 + new_fl2->fl_xid = xid;
5945 + vx_locks_inc(new_fl2);
5949 @@ -1016,7 +1043,8 @@ static int __posix_lock_file(struct inod
5950 int posix_lock_file(struct file *filp, struct file_lock *fl,
5951 struct file_lock *conflock)
5953 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
5954 + return __posix_lock_file(filp->f_path.dentry->d_inode,
5955 + fl, conflock, filp->f_xid);
5957 EXPORT_SYMBOL(posix_lock_file);
5959 @@ -1106,7 +1134,7 @@ int locks_mandatory_area(int read_write,
5960 fl.fl_end = offset + count - 1;
5963 - error = __posix_lock_file(inode, &fl, NULL);
5964 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
5965 if (error != -EAGAIN)
5967 if (!(fl.fl_flags & FL_SLEEP))
5968 @@ -1410,8 +1438,8 @@ static int __setlease(struct file *filp,
5971 locks_copy_lock(fl, lease);
5973 locks_insert_lock(before, fl);
5978 @@ -1738,6 +1766,11 @@ int fcntl_setlk(unsigned int fd, struct
5979 if (file_lock == NULL)
5982 + vxd_assert(filp->f_xid == vx_current_xid(),
5983 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5984 + file_lock->fl_xid = filp->f_xid;
5985 + vx_locks_inc(file_lock);
5988 * This might block, so we do it before checking the inode.
5990 @@ -1864,6 +1897,11 @@ int fcntl_setlk64(unsigned int fd, struc
5991 if (file_lock == NULL)
5994 + vxd_assert(filp->f_xid == vx_current_xid(),
5995 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5996 + file_lock->fl_xid = filp->f_xid;
5997 + vx_locks_inc(file_lock);
6000 * This might block, so we do it before checking the inode.
6002 @@ -2168,6 +2206,10 @@ int get_locks_status(char *buffer, char
6003 list_for_each(tmp, &file_lock_list) {
6004 struct list_head *btmp;
6005 struct file_lock *fl = list_entry(tmp, struct file_lock, fl_link);
6007 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6010 lock_get_status(q, fl, ++i, "");
6011 move_lock_status(&q, &pos, offset);
6013 diff -NurpP --minimal linux-2.6.22.10/fs/namei.c linux-2.6.22.10-vs2.2.0.5/fs/namei.c
6014 --- linux-2.6.22.10/fs/namei.c 2007-07-09 13:19:27 +0200
6015 +++ linux-2.6.22.10-vs2.2.0.5/fs/namei.c 2007-10-30 02:31:28 +0100
6017 #include <linux/file.h>
6018 #include <linux/fcntl.h>
6019 #include <linux/namei.h>
6020 +#include <linux/proc_fs.h>
6021 +#include <linux/vserver/inode.h>
6022 +#include <linux/vs_base.h>
6023 +#include <linux/vs_tag.h>
6024 +#include <linux/vs_cowbl.h>
6025 +#include <linux/vs_context.h>
6026 #include <asm/namei.h>
6027 #include <asm/uaccess.h>
6029 @@ -224,6 +230,29 @@ int generic_permission(struct inode *ino
6033 +static inline int dx_barrier(struct inode *inode)
6035 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN)) {
6036 + vxwprintk_task(1, "did hit the barrier.");
6042 +static inline int dx_permission(struct inode *inode, int mask, struct nameidata *nd)
6044 + if (dx_barrier(inode))
6046 + if (inode->i_tag == 0)
6048 + if (dx_check(inode->i_tag, DX_ADMIN|DX_WATCH|DX_IDENT))
6051 + vxwprintk_task(1, "denied access to %p[#%d,%lu] »%s«.",
6052 + inode, inode->i_tag, inode->i_ino, vxd_cond_path(nd));
6056 int permission(struct inode *inode, int mask, struct nameidata *nd)
6058 umode_t mode = inode->i_mode;
6059 @@ -234,14 +263,14 @@ int permission(struct inode *inode, int
6061 * Nobody gets write access to a read-only fs.
6063 - if (IS_RDONLY(inode) &&
6064 + if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
6065 (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
6069 * Nobody gets write access to an immutable file.
6071 - if (IS_IMMUTABLE(inode))
6072 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6076 @@ -257,6 +286,8 @@ int permission(struct inode *inode, int
6078 /* Ordinary permission routines do not understand MAY_APPEND. */
6079 submask = mask & ~MAY_APPEND;
6080 + if ((retval = dx_permission(inode, mask, nd)))
6082 if (inode->i_op && inode->i_op->permission)
6083 retval = inode->i_op->permission(inode, submask, nd);
6085 @@ -432,6 +463,8 @@ static int exec_permission_lite(struct i
6087 umode_t mode = inode->i_mode;
6089 + if (dx_barrier(inode))
6091 if (inode->i_op && inode->i_op->permission)
6094 @@ -732,7 +765,8 @@ static __always_inline void follow_dotdo
6095 if (nd->dentry == fs->root &&
6096 nd->mnt == fs->rootmnt) {
6097 read_unlock(&fs->lock);
6099 + /* for sane '/' avoid follow_mount() */
6102 read_unlock(&fs->lock);
6103 spin_lock(&dcache_lock);
6104 @@ -769,16 +803,33 @@ static int do_lookup(struct nameidata *n
6106 struct vfsmount *mnt = nd->mnt;
6107 struct dentry *dentry = __d_lookup(nd->dentry, name);
6108 + struct inode *inode;
6112 if (dentry->d_op && dentry->d_op->d_revalidate)
6113 goto need_revalidate;
6114 + inode = dentry->d_inode;
6117 + if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6118 + struct proc_dir_entry *de = PDE(inode);
6120 + if (de && !vx_hide_check(0, de->vx_flags))
6123 + if (!dx_check(inode->i_tag, DX_WATCH|DX_ADMIN|DX_HOSTID|DX_IDENT))
6127 path->dentry = dentry;
6128 __follow_mount(path);
6131 + vxwprintk_task(1, "did lookup hidden %p[#%d,%lu] »%s«.",
6132 + inode, inode->i_tag, inode->i_ino, vxd_path(dentry, mnt));
6137 dentry = real_lookup(nd->dentry, name, nd);
6138 @@ -1399,7 +1450,8 @@ static inline int check_sticky(struct in
6139 * 10. We don't allow removal of NFS sillyrenamed files; it's handled by
6140 * nfs_async_unlink().
6142 -static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
6143 +static int may_delete(struct inode *dir, struct dentry *victim,
6144 + int isdir, struct nameidata *nd)
6148 @@ -1409,13 +1461,13 @@ static int may_delete(struct inode *dir,
6149 BUG_ON(victim->d_parent->d_inode != dir);
6150 audit_inode_child(victim->d_name.name, victim->d_inode, dir);
6152 - error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
6153 + error = permission(dir,MAY_WRITE | MAY_EXEC, nd);
6158 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6159 - IS_IMMUTABLE(victim->d_inode))
6160 + IS_IXORUNLINK(victim->d_inode))
6163 if (!S_ISDIR(victim->d_inode->i_mode))
6164 @@ -1546,6 +1598,14 @@ int may_open(struct nameidata *nd, int a
6165 if (S_ISDIR(inode->i_mode) && (flag & FMODE_WRITE))
6168 +#ifdef CONFIG_VSERVER_COWBL
6169 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
6170 + if (IS_COW_LINK(inode))
6172 + inode->i_flags &= ~(S_IUNLINK|S_IMMUTABLE);
6173 + mark_inode_dirty(inode);
6176 error = vfs_permission(nd, acc_mode);
6179 @@ -1562,7 +1622,8 @@ int may_open(struct nameidata *nd, int a
6183 - } else if (IS_RDONLY(inode) && (flag & FMODE_WRITE))
6184 + } else if ((IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
6185 + && (flag & FMODE_WRITE))
6188 * An append-only file must be opened in append mode for writing.
6189 @@ -1650,6 +1711,11 @@ int open_namei(int dfd, const char *path
6193 +#ifdef CONFIG_VSERVER_COWBL
6198 acc_mode = ACC_MODE(flag);
6200 /* O_TRUNC implies we need access checks for write permissions */
6201 @@ -1743,6 +1809,22 @@ do_last:
6204 error = may_open(nd, acc_mode, flag);
6205 +#ifdef CONFIG_VSERVER_COWBL
6206 + if (error == -EMLINK) {
6207 + struct dentry *dentry;
6208 + dentry = cow_break_link(pathname);
6209 + if (IS_ERR(dentry)) {
6210 + error = PTR_ERR(dentry);
6214 + release_open_intent(nd);
6224 @@ -1854,9 +1936,10 @@ fail:
6226 EXPORT_SYMBOL_GPL(lookup_create);
6228 -int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
6229 +int vfs_mknod(struct inode *dir, struct dentry *dentry,
6230 + int mode, dev_t dev, struct nameidata *nd)
6232 - int error = may_create(dir, dentry, NULL);
6233 + int error = may_create(dir, dentry, nd);
6237 @@ -1906,11 +1989,12 @@ asmlinkage long sys_mknodat(int dfd, con
6238 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
6240 case S_IFCHR: case S_IFBLK:
6241 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
6242 - new_decode_dev(dev));
6243 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
6244 + new_decode_dev(dev), &nd);
6246 case S_IFIFO: case S_IFSOCK:
6247 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
6248 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
6253 @@ -1933,9 +2017,10 @@ asmlinkage long sys_mknod(const char __u
6254 return sys_mknodat(AT_FDCWD, filename, mode, dev);
6257 -int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
6258 +int vfs_mkdir(struct inode *dir, struct dentry *dentry,
6259 + int mode, struct nameidata *nd)
6261 - int error = may_create(dir, dentry, NULL);
6262 + int error = may_create(dir, dentry, nd);
6266 @@ -1977,7 +2062,7 @@ asmlinkage long sys_mkdirat(int dfd, con
6268 if (!IS_POSIXACL(nd.dentry->d_inode))
6269 mode &= ~current->fs->umask;
6270 - error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
6271 + error = vfs_mkdir(nd.dentry->d_inode, dentry, mode, &nd);
6274 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6275 @@ -2020,9 +2105,10 @@ void dentry_unhash(struct dentry *dentry
6276 spin_unlock(&dcache_lock);
6279 -int vfs_rmdir(struct inode *dir, struct dentry *dentry)
6280 +int vfs_rmdir(struct inode *dir, struct dentry *dentry,
6281 + struct nameidata *nd)
6283 - int error = may_delete(dir, dentry, 1);
6284 + int error = may_delete(dir, dentry, 1, nd);
6288 @@ -2084,7 +2170,7 @@ static long do_rmdir(int dfd, const char
6289 error = PTR_ERR(dentry);
6292 - error = vfs_rmdir(nd.dentry->d_inode, dentry);
6293 + error = vfs_rmdir(nd.dentry->d_inode, dentry, &nd);
6296 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6297 @@ -2100,9 +2186,10 @@ asmlinkage long sys_rmdir(const char __u
6298 return do_rmdir(AT_FDCWD, pathname);
6301 -int vfs_unlink(struct inode *dir, struct dentry *dentry)
6302 +int vfs_unlink(struct inode *dir, struct dentry *dentry,
6303 + struct nameidata *nd)
6305 - int error = may_delete(dir, dentry, 0);
6306 + int error = may_delete(dir, dentry, 0, nd);
6310 @@ -2164,7 +2251,7 @@ static long do_unlinkat(int dfd, const c
6311 inode = dentry->d_inode;
6313 atomic_inc(&inode->i_count);
6314 - error = vfs_unlink(nd.dentry->d_inode, dentry);
6315 + error = vfs_unlink(nd.dentry->d_inode, dentry, &nd);
6319 @@ -2199,9 +2286,10 @@ asmlinkage long sys_unlink(const char __
6320 return do_unlinkat(AT_FDCWD, pathname);
6323 -int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, int mode)
6324 +int vfs_symlink(struct inode *dir, struct dentry *dentry,
6325 + const char *oldname, int mode, struct nameidata *nd)
6327 - int error = may_create(dir, dentry, NULL);
6328 + int error = may_create(dir, dentry, nd);
6332 @@ -2245,7 +2333,7 @@ asmlinkage long sys_symlinkat(const char
6336 - error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
6337 + error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO, &nd);
6340 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6341 @@ -2262,7 +2350,8 @@ asmlinkage long sys_symlink(const char _
6342 return sys_symlinkat(oldname, AT_FDCWD, newname);
6345 -int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
6346 +int vfs_link(struct dentry *old_dentry, struct inode *dir,
6347 + struct dentry *new_dentry, struct nameidata *nd)
6349 struct inode *inode = old_dentry->d_inode;
6351 @@ -2270,7 +2359,7 @@ int vfs_link(struct dentry *old_dentry,
6355 - error = may_create(dir, new_dentry, NULL);
6356 + error = may_create(dir, new_dentry, nd);
6360 @@ -2280,7 +2369,7 @@ int vfs_link(struct dentry *old_dentry,
6362 * A link to an append-only or immutable file cannot be created.
6364 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6365 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6367 if (!dir->i_op || !dir->i_op->link)
6369 @@ -2340,7 +2429,7 @@ asmlinkage long sys_linkat(int olddfd, c
6370 error = PTR_ERR(new_dentry);
6371 if (IS_ERR(new_dentry))
6373 - error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
6374 + error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry, &nd);
6377 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6378 @@ -2472,14 +2561,14 @@ int vfs_rename(struct inode *old_dir, st
6379 if (old_dentry->d_inode == new_dentry->d_inode)
6382 - error = may_delete(old_dir, old_dentry, is_dir);
6383 + error = may_delete(old_dir, old_dentry, is_dir, NULL);
6387 if (!new_dentry->d_inode)
6388 error = may_create(new_dir, new_dentry, NULL);
6390 - error = may_delete(new_dir, new_dentry, is_dir);
6391 + error = may_delete(new_dir, new_dentry, is_dir, NULL);
6395 @@ -2557,6 +2646,9 @@ static int do_rename(int olddfd, const c
6397 if (old_dentry == trap)
6400 + if (MNT_IS_RDONLY(newnd.mnt))
6402 new_dentry = lookup_hash(&newnd);
6403 error = PTR_ERR(new_dentry);
6404 if (IS_ERR(new_dentry))
6405 @@ -2650,6 +2742,217 @@ int vfs_follow_link(struct nameidata *nd
6406 return __vfs_follow_link(nd, link);
6410 +#ifdef CONFIG_VSERVER_COWBL
6412 +#include <linux/file.h>
6415 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6419 + return do_splice_direct(in, &ppos, out, len, 0);
6422 +struct dentry *cow_break_link(const char *pathname)
6424 + int ret, mode, pathlen, redo = 0;
6425 + struct nameidata old_nd, dir_nd;
6426 + struct dentry *old_dentry, *new_dentry;
6427 + struct dentry *dir, *res = NULL;
6428 + struct vfsmount *old_mnt, *new_mnt;
6429 + struct file *old_file;
6430 + struct file *new_file;
6431 + char *to, *path, pad='\251';
6432 + loff_t ppos, size;
6434 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
6435 + path = kmalloc(PATH_MAX, GFP_KERNEL);
6440 + /* old_nd will have refs to dentry and mnt */
6441 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6442 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
6444 + goto out_free_path;
6446 + old_dentry = old_nd.dentry;
6447 + old_mnt = old_nd.mnt;
6448 + mode = old_dentry->d_inode->i_mode;
6450 + to = d_path(old_dentry, old_mnt, path, PATH_MAX-2);
6451 + pathlen = strlen(to);
6452 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
6453 + old_dentry->d_name.len, old_dentry->d_name.name,
6454 + old_dentry->d_name.len);
6456 + to[pathlen + 1] = 0;
6458 + to[pathlen] = pad--;
6460 + if (pad <= '\240')
6463 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
6464 + /* dir_nd will have refs to dentry and mnt */
6465 + ret = path_lookup(to,
6466 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
6467 + vxdprintk(VXD_CBIT(misc, 2),
6468 + "path_lookup(new): %d", ret);
6472 + /* this puppy downs the inode mutex */
6473 + new_dentry = lookup_create(&dir_nd, 0);
6474 + vxdprintk(VXD_CBIT(misc, 2),
6475 + "lookup_create(new): %p [»%.*s«:%d]", new_dentry,
6476 + new_dentry->d_name.len, new_dentry->d_name.name,
6477 + new_dentry->d_name.len);
6478 + if (!new_dentry || IS_ERR(new_dentry)) {
6479 + path_release(&dir_nd);
6482 + dir = dir_nd.dentry;
6484 + ret = vfs_create(dir_nd.dentry->d_inode, new_dentry, mode, &dir_nd);
6485 + vxdprintk(VXD_CBIT(misc, 2),
6486 + "vfs_create(new): %d", ret);
6487 + if (ret == -EEXIST) {
6488 + mutex_unlock(&dir->d_inode->i_mutex);
6490 + path_release(&dir_nd);
6494 + goto out_unlock_new;
6496 + /* drop out early, ret passes ENOENT */
6498 + if ((redo = d_unhashed(old_dentry)))
6499 + goto out_unlock_new;
6501 + new_mnt = dir_nd.mnt;
6504 + /* this one cleans up the dentry/mnt in case of failure */
6505 + old_file = dentry_open(old_dentry, old_mnt, O_RDONLY);
6506 + vxdprintk(VXD_CBIT(misc, 2),
6507 + "dentry_open(old): %p", old_file);
6508 + if (!old_file || IS_ERR(old_file)) {
6509 + res = IS_ERR(old_file) ? (void *) old_file : res;
6510 + goto out_unlock_new;
6515 + /* this one cleans up the dentry/mnt in case of failure */
6516 + new_file = dentry_open(new_dentry, new_mnt, O_WRONLY);
6517 + vxdprintk(VXD_CBIT(misc, 2),
6518 + "dentry_open(new): %p", new_file);
6520 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
6521 + if (!new_file || IS_ERR(new_file))
6522 + goto out_fput_old;
6524 + size = i_size_read(old_file->f_dentry->d_inode);
6526 + ret = do_cow_splice(old_file, new_file, size);
6527 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
6529 + goto out_fput_both;
6530 + } else if (ret < size) {
6532 + goto out_fput_both;
6534 + struct inode *old_inode = old_dentry->d_inode;
6535 + struct inode *new_inode = new_dentry->d_inode;
6536 + struct iattr attr = {
6537 + .ia_uid = old_inode->i_uid,
6538 + .ia_gid = old_inode->i_gid,
6539 + .ia_valid = ATTR_UID | ATTR_GID
6542 + ret = inode_setattr(new_inode, &attr);
6544 + goto out_fput_both;
6547 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
6549 + /* drop out late */
6551 + if ((redo = d_unhashed(old_dentry)))
6554 + vxdprintk(VXD_CBIT(misc, 2),
6555 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
6556 + new_dentry->d_name.len, new_dentry->d_name.name,
6557 + new_dentry->d_name.len,
6558 + old_dentry->d_name.len, old_dentry->d_name.name,
6559 + old_dentry->d_name.len);
6560 + ret = vfs_rename(dir_nd.dentry->d_inode, new_dentry,
6561 + old_nd.dentry->d_parent->d_inode, old_dentry);
6562 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
6566 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
6569 + vxdprintk(VXD_CBIT(misc, 3),
6570 + "fput(new_file=%p[#%d])", new_file,
6571 + atomic_read(&new_file->f_count));
6575 + vxdprintk(VXD_CBIT(misc, 3),
6576 + "fput(old_file=%p[#%d])", old_file,
6577 + atomic_read(&old_file->f_count));
6581 + mutex_unlock(&dir->d_inode->i_mutex);
6585 + /* error path cleanup */
6586 + vfs_unlink(dir->d_inode, new_dentry, &dir_nd);
6591 + goto out_rel_both;
6592 + /* lookup dentry once again */
6593 + path_release(&old_nd);
6594 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6596 + goto out_rel_both;
6598 + new_dentry = old_nd.dentry;
6599 + vxdprintk(VXD_CBIT(misc, 2),
6600 + "path_lookup(redo): %p [»%.*s«:%d]", new_dentry,
6601 + new_dentry->d_name.len, new_dentry->d_name.name,
6602 + new_dentry->d_name.len);
6607 + path_release(&dir_nd);
6609 + path_release(&old_nd);
6614 + res = ERR_PTR(ret);
6620 /* get the link contents into pagecache */
6621 static char *page_getlink(struct dentry * dentry, struct page **ppage)
6623 diff -NurpP --minimal linux-2.6.22.10/fs/namespace.c linux-2.6.22.10-vs2.2.0.5/fs/namespace.c
6624 --- linux-2.6.22.10/fs/namespace.c 2007-07-09 13:19:27 +0200
6625 +++ linux-2.6.22.10-vs2.2.0.5/fs/namespace.c 2007-06-15 03:24:51 +0200
6627 #include <linux/security.h>
6628 #include <linux/mount.h>
6629 #include <linux/ramfs.h>
6630 +#include <linux/vs_base.h>
6631 +#include <linux/vs_context.h>
6632 +#include <linux/vs_tag.h>
6633 +#include <linux/vserver/space.h>
6634 +#include <linux/vserver/global.h>
6635 #include <asm/uaccess.h>
6636 #include <asm/unistd.h>
6638 @@ -240,6 +245,7 @@ static struct vfsmount *clone_mnt(struct
6639 mnt->mnt_root = dget(root);
6640 mnt->mnt_mountpoint = mnt->mnt_root;
6641 mnt->mnt_parent = mnt;
6642 + mnt->mnt_tag = old->mnt_tag;
6644 if (flag & CL_SLAVE) {
6645 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
6646 @@ -348,48 +354,91 @@ static inline void mangle(struct seq_fil
6647 seq_escape(m, s, " \t\n\\");
6650 +static int mnt_is_reachable(struct vfsmount *mnt)
6652 + struct vfsmount *root_mnt;
6653 + struct dentry *root, *point;
6656 + if (mnt == mnt->mnt_ns->root)
6659 + spin_lock(&vfsmount_lock);
6660 + root_mnt = current->fs->rootmnt;
6661 + root = current->fs->root;
6664 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
6665 + point = mnt->mnt_mountpoint;
6666 + mnt = mnt->mnt_parent;
6669 + ret = (mnt == root_mnt) && is_subdir(point, root);
6671 + spin_unlock(&vfsmount_lock);
6676 static int show_vfsmnt(struct seq_file *m, void *v)
6678 struct vfsmount *mnt = v;
6680 static struct proc_fs_info {
6688 - { MS_SYNCHRONOUS, ",sync" },
6689 - { MS_DIRSYNC, ",dirsync" },
6690 - { MS_MANDLOCK, ",mand" },
6693 - static struct proc_fs_info mnt_info[] = {
6694 - { MNT_NOSUID, ",nosuid" },
6695 - { MNT_NODEV, ",nodev" },
6696 - { MNT_NOEXEC, ",noexec" },
6697 - { MNT_NOATIME, ",noatime" },
6698 - { MNT_NODIRATIME, ",nodiratime" },
6699 - { MNT_RELATIME, ",relatime" },
6701 + { MS_RDONLY, MNT_RDONLY, "ro", "rw" },
6702 + { MS_SYNCHRONOUS, 0, ",sync", NULL },
6703 + { MS_DIRSYNC, 0, ",dirsync", NULL },
6704 + { MS_MANDLOCK, 0, ",mand", NULL },
6705 + { MS_TAGGED, 0, ",tag", NULL },
6706 + { MS_NOATIME, MNT_NOATIME, ",noatime", NULL },
6707 + { MS_NODIRATIME, MNT_NODIRATIME, ",nodiratime", NULL },
6708 + { MS_RELATIME, MNT_RELATIME, ",relatime", NULL },
6709 + { 0, MNT_NOSUID, ",nosuid", NULL },
6710 + { 0, MNT_NODEV, ",nodev", NULL },
6711 + { 0, MNT_NOEXEC, ",noexec", NULL },
6712 + { 0, 0, NULL, NULL }
6714 - struct proc_fs_info *fs_infop;
6715 + struct proc_fs_info *p;
6716 + unsigned long s_flags = mnt->mnt_sb->s_flags;
6717 + int mnt_flags = mnt->mnt_flags;
6719 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6721 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
6723 - mangle(m, mnt->mnt_sb->s_type->name);
6724 - if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
6726 - mangle(m, mnt->mnt_sb->s_subtype);
6728 - seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? " ro" : " rw");
6729 - for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
6730 - if (mnt->mnt_sb->s_flags & fs_infop->flag)
6731 - seq_puts(m, fs_infop->str);
6732 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6734 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6737 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6738 + mnt == current->fs->rootmnt) {
6739 + seq_puts(m, "/dev/root / ");
6741 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6743 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
6746 + if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
6748 + mangle(m, mnt->mnt_sb->s_subtype);
6751 - for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
6752 - if (mnt->mnt_flags & fs_infop->flag)
6753 - seq_puts(m, fs_infop->str);
6754 + mangle(m, mnt->mnt_sb->s_type->name);
6756 + for (p = fs_info; (p->s_flag | p->mnt_flag) ; p++) {
6757 + if ((s_flags & p->s_flag) || (mnt_flags & p->mnt_flag)) {
6759 + seq_puts(m, p->set_str);
6762 + seq_puts(m, p->unset_str);
6765 + if (mnt->mnt_flags & MNT_TAGID)
6766 + seq_printf(m, ",tag=%d", mnt->mnt_tag);
6767 if (mnt->mnt_sb->s_op->show_options)
6768 err = mnt->mnt_sb->s_op->show_options(m, mnt);
6769 seq_puts(m, " 0 0\n");
6770 @@ -408,17 +457,27 @@ static int show_vfsstat(struct seq_file
6771 struct vfsmount *mnt = v;
6775 - if (mnt->mnt_devname) {
6776 - seq_puts(m, "device ");
6777 - mangle(m, mnt->mnt_devname);
6779 - seq_puts(m, "no device");
6780 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6782 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6786 - seq_puts(m, " mounted on ");
6787 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
6789 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6790 + mnt == current->fs->rootmnt) {
6791 + seq_puts(m, "device /dev/root mounted on / ");
6794 + if (mnt->mnt_devname) {
6795 + seq_puts(m, "device ");
6796 + mangle(m, mnt->mnt_devname);
6798 + seq_puts(m, "no device");
6801 + seq_puts(m, " mounted on ");
6802 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
6806 /* file system type */
6807 seq_puts(m, "with fstype ");
6808 @@ -648,7 +707,7 @@ asmlinkage long sys_umount(char __user *
6812 - if (!capable(CAP_SYS_ADMIN))
6813 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6816 retval = do_umount(nd.mnt, flags);
6817 @@ -672,7 +731,7 @@ asmlinkage long sys_oldumount(char __use
6819 static int mount_is_safe(struct nameidata *nd)
6821 - if (capable(CAP_SYS_ADMIN))
6822 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6826 @@ -904,11 +963,13 @@ static int do_change_type(struct nameida
6828 * do loopback mount.
6830 -static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
6831 +static int do_loopback(struct nameidata *nd, char *old_name, tag_t tag,
6832 + unsigned long flags, int mnt_flags)
6834 struct nameidata old_nd;
6835 struct vfsmount *mnt = NULL;
6836 int err = mount_is_safe(nd);
6837 + int recurse = flags & MS_REC;
6840 if (!old_name || !*old_name)
6841 @@ -934,6 +995,12 @@ static int do_loopback(struct nameidata
6845 + mnt->mnt_flags = mnt_flags;
6846 + if (flags & MS_TAGID) {
6847 + mnt->mnt_tag = tag;
6848 + mnt->mnt_flags |= MNT_TAGID;
6851 err = graft_tree(mnt, nd);
6853 LIST_HEAD(umount_list);
6854 @@ -942,6 +1009,7 @@ static int do_loopback(struct nameidata
6855 spin_unlock(&vfsmount_lock);
6856 release_mounts(&umount_list);
6858 + mnt->mnt_flags = mnt_flags;
6861 up_write(&namespace_sem);
6862 @@ -955,12 +1023,12 @@ out:
6863 * on it - tough luck.
6865 static int do_remount(struct nameidata *nd, int flags, int mnt_flags,
6867 + void *data, xid_t xid)
6870 struct super_block *sb = nd->mnt->mnt_sb;
6872 - if (!capable(CAP_SYS_ADMIN))
6873 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
6876 if (!check_mnt(nd->mnt))
6877 @@ -994,7 +1062,7 @@ static int do_move_mount(struct nameidat
6878 struct nameidata old_nd, parent_nd;
6881 - if (!capable(CAP_SYS_ADMIN))
6882 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6884 if (!old_name || !*old_name)
6886 @@ -1074,7 +1142,7 @@ static int do_new_mount(struct nameidata
6889 /* we need capabilities... */
6890 - if (!capable(CAP_SYS_ADMIN))
6891 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6894 mnt = do_kern_mount(type, flags, name, data);
6895 @@ -1386,6 +1454,7 @@ long do_mount(char *dev_name, char *dir_
6896 struct nameidata nd;
6902 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
6903 @@ -1401,7 +1470,19 @@ long do_mount(char *dev_name, char *dir_
6905 ((char *)data_page)[PAGE_SIZE - 1] = 0;
6907 +#ifdef CONFIG_PROPAGATE
6908 + retval = dx_parse_tag(data_page, &tag, 1);
6910 + mnt_flags |= MNT_TAGID;
6911 + /* bind and re-mounts get the tag flag */
6912 + if (flags & (MS_BIND|MS_REMOUNT))
6913 + flags |= MS_TAGID;
6917 /* Separate the per-mountpoint flags */
6918 + if (flags & MS_RDONLY)
6919 + mnt_flags |= MNT_RDONLY;
6920 if (flags & MS_NOSUID)
6921 mnt_flags |= MNT_NOSUID;
6922 if (flags & MS_NODEV)
6923 @@ -1415,6 +1496,8 @@ long do_mount(char *dev_name, char *dir_
6924 if (flags & MS_RELATIME)
6925 mnt_flags |= MNT_RELATIME;
6927 + if (!capable(CAP_SYS_ADMIN))
6928 + mnt_flags |= MNT_NODEV;
6929 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
6930 MS_NOATIME | MS_NODIRATIME | MS_RELATIME);
6932 @@ -1429,9 +1512,9 @@ long do_mount(char *dev_name, char *dir_
6934 if (flags & MS_REMOUNT)
6935 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
6938 else if (flags & MS_BIND)
6939 - retval = do_loopback(&nd, dev_name, flags & MS_REC);
6940 + retval = do_loopback(&nd, dev_name, tag, flags, mnt_flags);
6941 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
6942 retval = do_change_type(&nd, flags);
6943 else if (flags & MS_MOVE)
6944 @@ -1504,6 +1587,7 @@ static struct mnt_namespace *dup_mnt_ns(
6945 q = next_mnt(q, new_ns->root);
6947 up_write(&namespace_sem);
6948 + atomic_inc(&vs_global_mnt_ns);
6952 @@ -1866,5 +1950,6 @@ void __put_mnt_ns(struct mnt_namespace *
6953 spin_unlock(&vfsmount_lock);
6954 up_write(&namespace_sem);
6955 release_mounts(&umount_list);
6956 + atomic_dec(&vs_global_mnt_ns);
6959 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/client.c linux-2.6.22.10-vs2.2.0.5/fs/nfs/client.c
6960 --- linux-2.6.22.10/fs/nfs/client.c 2007-07-09 13:19:27 +0200
6961 +++ linux-2.6.22.10-vs2.2.0.5/fs/nfs/client.c 2007-06-15 02:37:03 +0200
6962 @@ -521,6 +521,9 @@ static int nfs_init_server_rpcclient(str
6963 if (server->flags & NFS4_MOUNT_INTR)
6964 server->client->cl_intr = 1;
6966 + server->client->cl_tag = 0;
6967 + if (server->flags & NFS_MOUNT_TAGGED)
6968 + server->client->cl_tag = 1;
6972 @@ -678,6 +681,10 @@ static void nfs_server_set_fsinfo(struct
6973 server->acdirmin = server->acdirmax = 0;
6976 + /* FIXME: needs fsinfo
6977 + if (server->flags & NFS_MOUNT_TAGGED)
6978 + sb->s_flags |= MS_TAGGED; */
6980 server->maxfilesize = fsinfo->maxfilesize;
6982 /* We're airborne Set socket buffersize */
6983 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/dir.c linux-2.6.22.10-vs2.2.0.5/fs/nfs/dir.c
6984 --- linux-2.6.22.10/fs/nfs/dir.c 2007-07-09 13:19:27 +0200
6985 +++ linux-2.6.22.10-vs2.2.0.5/fs/nfs/dir.c 2007-06-15 03:02:49 +0200
6987 #include <linux/namei.h>
6988 #include <linux/mount.h>
6989 #include <linux/sched.h>
6990 +#include <linux/vs_tag.h>
6992 #include "nfs4_fs.h"
6993 #include "delegation.h"
6994 @@ -956,6 +957,7 @@ static struct dentry *nfs_lookup(struct
6998 + dx_propagate_tag(nd, inode);
7000 res = d_materialise_unique(dentry, inode);
7002 @@ -998,7 +1000,8 @@ static int is_atomic_open(struct inode *
7003 if (nd->flags & LOOKUP_DIRECTORY)
7005 /* Are we trying to write to a read only partition? */
7006 - if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
7007 + if ((IS_RDONLY(dir) || MNT_IS_RDONLY(nd->mnt)) &&
7008 + (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
7012 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/inode.c linux-2.6.22.10-vs2.2.0.5/fs/nfs/inode.c
7013 --- linux-2.6.22.10/fs/nfs/inode.c 2007-07-09 13:19:27 +0200
7014 +++ linux-2.6.22.10-vs2.2.0.5/fs/nfs/inode.c 2007-06-15 02:37:03 +0200
7016 #include <linux/vfs.h>
7017 #include <linux/inet.h>
7018 #include <linux/nfs_xdr.h>
7019 +#include <linux/vs_tag.h>
7021 #include <asm/system.h>
7022 #include <asm/uaccess.h>
7023 @@ -285,8 +286,10 @@ nfs_fhget(struct super_block *sb, struct
7024 nfsi->change_attr = fattr->change_attr;
7025 inode->i_size = nfs_size_to_loff_t(fattr->size);
7026 inode->i_nlink = fattr->nlink;
7027 - inode->i_uid = fattr->uid;
7028 - inode->i_gid = fattr->gid;
7029 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7030 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7031 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7032 + /* maybe fattr->xid someday */
7033 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
7035 * report the blocks in 512byte units
7036 @@ -377,6 +380,8 @@ void nfs_setattr_update_inode(struct ino
7037 inode->i_uid = attr->ia_uid;
7038 if ((attr->ia_valid & ATTR_GID) != 0)
7039 inode->i_gid = attr->ia_gid;
7040 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7041 + inode->i_tag = attr->ia_tag;
7042 spin_lock(&inode->i_lock);
7043 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7044 spin_unlock(&inode->i_lock);
7045 @@ -825,6 +830,9 @@ static int nfs_check_inode_attributes(st
7046 struct nfs_inode *nfsi = NFS_I(inode);
7047 loff_t cur_size, new_isize;
7054 /* Has the inode gone and changed behind our back? */
7055 @@ -852,10 +860,15 @@ static int nfs_check_inode_attributes(st
7056 if (cur_size != new_isize && nfsi->npages == 0)
7057 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7059 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7060 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7061 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7063 /* Have any file permissions changed? */
7064 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
7065 - || inode->i_uid != fattr->uid
7066 - || inode->i_gid != fattr->gid)
7067 + || inode->i_uid != uid
7068 + || inode->i_gid != gid
7069 + || inode->i_tag != tag)
7070 nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7072 /* Has the link count changed? */
7073 @@ -946,6 +959,9 @@ static int nfs_update_inode(struct inode
7074 unsigned int invalid = 0;
7075 unsigned long now = jiffies;
7081 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7082 __FUNCTION__, inode->i_sb->s_id, inode->i_ino,
7083 @@ -1022,15 +1038,21 @@ static int nfs_update_inode(struct inode
7085 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7087 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7088 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7089 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7091 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
7092 - inode->i_uid != fattr->uid ||
7093 - inode->i_gid != fattr->gid)
7094 + inode->i_uid != uid ||
7095 + inode->i_gid != gid ||
7096 + inode->i_tag != tag)
7097 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7099 inode->i_mode = fattr->mode;
7100 inode->i_nlink = fattr->nlink;
7101 - inode->i_uid = fattr->uid;
7102 - inode->i_gid = fattr->gid;
7103 + inode->i_uid = uid;
7104 + inode->i_gid = gid;
7105 + inode->i_tag = tag;
7107 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
7109 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/nfs3xdr.c linux-2.6.22.10-vs2.2.0.5/fs/nfs/nfs3xdr.c
7110 --- linux-2.6.22.10/fs/nfs/nfs3xdr.c 2007-07-09 13:19:27 +0200
7111 +++ linux-2.6.22.10-vs2.2.0.5/fs/nfs/nfs3xdr.c 2007-06-15 02:37:03 +0200
7113 #include <linux/nfs3.h>
7114 #include <linux/nfs_fs.h>
7115 #include <linux/nfsacl.h>
7116 +#include <linux/vs_tag.h>
7117 #include "internal.h"
7119 #define NFSDBG_FACILITY NFSDBG_XDR
7120 @@ -178,7 +179,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
7123 static inline __be32 *
7124 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
7125 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
7127 if (attr->ia_valid & ATTR_MODE) {
7129 @@ -186,15 +187,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
7133 - if (attr->ia_valid & ATTR_UID) {
7134 + if (attr->ia_valid & ATTR_UID ||
7135 + (tag && (attr->ia_valid & ATTR_TAG))) {
7137 - *p++ = htonl(attr->ia_uid);
7138 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
7142 - if (attr->ia_valid & ATTR_GID) {
7143 + if (attr->ia_valid & ATTR_GID ||
7144 + (tag && (attr->ia_valid & ATTR_TAG))) {
7146 - *p++ = htonl(attr->ia_gid);
7147 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
7151 @@ -279,7 +282,8 @@ static int
7152 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
7154 p = xdr_encode_fhandle(p, args->fh);
7155 - p = xdr_encode_sattr(p, args->sattr);
7156 + p = xdr_encode_sattr(p, args->sattr,
7157 + req->rq_task->tk_client->cl_tag);
7158 *p++ = htonl(args->guard);
7160 p = xdr_encode_time3(p, &args->guardtime);
7161 @@ -370,7 +374,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
7162 *p++ = args->verifier[0];
7163 *p++ = args->verifier[1];
7165 - p = xdr_encode_sattr(p, args->sattr);
7166 + p = xdr_encode_sattr(p, args->sattr,
7167 + req->rq_task->tk_client->cl_tag);
7169 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7171 @@ -384,7 +389,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
7173 p = xdr_encode_fhandle(p, args->fh);
7174 p = xdr_encode_array(p, args->name, args->len);
7175 - p = xdr_encode_sattr(p, args->sattr);
7176 + p = xdr_encode_sattr(p, args->sattr,
7177 + req->rq_task->tk_client->cl_tag);
7178 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7181 @@ -397,7 +403,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
7183 p = xdr_encode_fhandle(p, args->fromfh);
7184 p = xdr_encode_array(p, args->fromname, args->fromlen);
7185 - p = xdr_encode_sattr(p, args->sattr);
7186 + p = xdr_encode_sattr(p, args->sattr,
7187 + req->rq_task->tk_client->cl_tag);
7188 *p++ = htonl(args->pathlen);
7189 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7191 @@ -415,7 +422,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
7192 p = xdr_encode_fhandle(p, args->fh);
7193 p = xdr_encode_array(p, args->name, args->len);
7194 *p++ = htonl(args->type);
7195 - p = xdr_encode_sattr(p, args->sattr);
7196 + p = xdr_encode_sattr(p, args->sattr,
7197 + req->rq_task->tk_client->cl_tag);
7198 if (args->type == NF3CHR || args->type == NF3BLK) {
7199 *p++ = htonl(MAJOR(args->rdev));
7200 *p++ = htonl(MINOR(args->rdev));
7201 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/nfsroot.c linux-2.6.22.10-vs2.2.0.5/fs/nfs/nfsroot.c
7202 --- linux-2.6.22.10/fs/nfs/nfsroot.c 2007-07-09 13:19:27 +0200
7203 +++ linux-2.6.22.10-vs2.2.0.5/fs/nfs/nfsroot.c 2007-06-15 02:37:03 +0200
7204 @@ -118,12 +118,12 @@ static int mount_port __initdata = 0; /
7206 /* Options that take integer arguments */
7207 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
7208 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
7209 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
7210 /* Options that take no arguments */
7211 Opt_soft, Opt_hard, Opt_intr,
7212 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
7213 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
7214 - Opt_acl, Opt_noacl,
7215 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
7219 @@ -160,6 +160,10 @@ static match_table_t __initdata tokens =
7222 {Opt_noacl, "noacl"},
7224 + {Opt_notag, "notag"},
7225 + {Opt_tagid, "tagid=%u"},
7226 + {Opt_tag, "tagxid"},
7230 @@ -274,6 +278,20 @@ static int __init root_nfs_parse(char *n
7232 nfs_data.flags |= NFS_MOUNT_NOACL;
7234 +#ifndef CONFIG_TAGGING_NONE
7236 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7239 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
7242 +#ifdef CONFIG_PROPAGATE
7245 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7249 printk(KERN_WARNING "Root-NFS: unknown "
7251 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/super.c linux-2.6.22.10-vs2.2.0.5/fs/nfs/super.c
7252 --- linux-2.6.22.10/fs/nfs/super.c 2007-10-30 01:57:14 +0100
7253 +++ linux-2.6.22.10-vs2.2.0.5/fs/nfs/super.c 2007-10-01 15:25:35 +0200
7255 #include <linux/nfs_xdr.h>
7256 #include <linux/magic.h>
7257 #include <linux/parser.h>
7258 +#include <linux/vs_tag.h>
7260 #include <asm/system.h>
7261 #include <asm/uaccess.h>
7262 @@ -452,6 +453,7 @@ static void nfs_show_mount_options(struc
7263 { NFS_MOUNT_NOACL, ",noacl", "" },
7264 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7265 { NFS_MOUNT_UNSHARED, ",nosharecache", ""},
7266 + { NFS_MOUNT_TAGGED, ",tag", "" },
7269 const struct proc_nfs_info *nfs_infop;
7270 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/auth.c linux-2.6.22.10-vs2.2.0.5/fs/nfsd/auth.c
7271 --- linux-2.6.22.10/fs/nfsd/auth.c 2006-06-18 04:54:42 +0200
7272 +++ linux-2.6.22.10-vs2.2.0.5/fs/nfsd/auth.c 2007-06-15 02:37:03 +0200
7274 #include <linux/sunrpc/svc.h>
7275 #include <linux/sunrpc/svcauth.h>
7276 #include <linux/nfsd/nfsd.h>
7277 +#include <linux/vs_tag.h>
7279 #define CAP_NFSD_MASK (CAP_FS_MASK|CAP_TO_MASK(CAP_SYS_RESOURCE))
7281 @@ -41,19 +42,22 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7282 get_group_info(cred.cr_group_info);
7284 if (cred.cr_uid != (uid_t) -1)
7285 - current->fsuid = cred.cr_uid;
7286 + current->fsuid = INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
7288 current->fsuid = exp->ex_anon_uid;
7289 if (cred.cr_gid != (gid_t) -1)
7290 - current->fsgid = cred.cr_gid;
7291 + current->fsgid = INOTAG_GID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
7293 current->fsgid = exp->ex_anon_gid;
7295 + /* this desperately needs a tag :) */
7296 + current->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7298 if (!cred.cr_group_info)
7300 ret = set_current_groups(cred.cr_group_info);
7301 put_group_info(cred.cr_group_info);
7302 - if ((cred.cr_uid)) {
7303 + if (INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid)) {
7304 cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
7306 cap_t(current->cap_effective) |= (CAP_NFSD_MASK &
7307 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/nfs3xdr.c linux-2.6.22.10-vs2.2.0.5/fs/nfsd/nfs3xdr.c
7308 --- linux-2.6.22.10/fs/nfsd/nfs3xdr.c 2007-07-09 13:19:27 +0200
7309 +++ linux-2.6.22.10-vs2.2.0.5/fs/nfsd/nfs3xdr.c 2007-06-15 02:37:03 +0200
7311 #include <linux/sunrpc/svc.h>
7312 #include <linux/nfsd/nfsd.h>
7313 #include <linux/nfsd/xdr3.h>
7314 +#include <linux/vs_tag.h>
7316 #define NFSDDBG_FACILITY NFSDDBG_XDR
7318 @@ -107,6 +108,8 @@ static __be32 *
7319 decode_sattr3(__be32 *p, struct iattr *iap)
7327 @@ -116,12 +119,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7330 iap->ia_valid |= ATTR_UID;
7331 - iap->ia_uid = ntohl(*p++);
7332 + uid = ntohl(*p++);
7335 iap->ia_valid |= ATTR_GID;
7336 - iap->ia_gid = ntohl(*p++);
7337 + gid = ntohl(*p++);
7339 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7340 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7341 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7345 @@ -180,8 +186,10 @@ encode_fattr3(struct svc_rqst *rqstp, __
7346 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7347 *p++ = htonl((u32) stat->mode);
7348 *p++ = htonl((u32) stat->nlink);
7349 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7350 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7351 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7352 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7353 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7354 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7355 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7356 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7358 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/nfs4recover.c linux-2.6.22.10-vs2.2.0.5/fs/nfsd/nfs4recover.c
7359 --- linux-2.6.22.10/fs/nfsd/nfs4recover.c 2007-07-09 13:19:27 +0200
7360 +++ linux-2.6.22.10-vs2.2.0.5/fs/nfsd/nfs4recover.c 2007-06-15 02:37:03 +0200
7361 @@ -156,7 +156,7 @@ nfsd4_create_clid_dir(struct nfs4_client
7362 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n");
7365 - status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU);
7366 + status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU, NULL);
7370 @@ -260,7 +260,7 @@ nfsd4_remove_clid_file(struct dentry *di
7373 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
7374 - status = vfs_unlink(dir->d_inode, dentry);
7375 + status = vfs_unlink(dir->d_inode, dentry, NULL);
7376 mutex_unlock(&dir->d_inode->i_mutex);
7379 @@ -275,7 +275,7 @@ nfsd4_clear_clid_dir(struct dentry *dir,
7380 * a kernel from the future.... */
7381 nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file);
7382 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
7383 - status = vfs_rmdir(dir->d_inode, dentry);
7384 + status = vfs_rmdir(dir->d_inode, dentry, NULL);
7385 mutex_unlock(&dir->d_inode->i_mutex);
7388 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/nfs4xdr.c linux-2.6.22.10-vs2.2.0.5/fs/nfsd/nfs4xdr.c
7389 --- linux-2.6.22.10/fs/nfsd/nfs4xdr.c 2007-07-09 13:19:27 +0200
7390 +++ linux-2.6.22.10-vs2.2.0.5/fs/nfsd/nfs4xdr.c 2007-06-15 02:37:03 +0200
7392 #include <linux/nfs4_acl.h>
7393 #include <linux/sunrpc/gss_api.h>
7394 #include <linux/sunrpc/svcauth_gss.h>
7395 +#include <linux/vs_tag.h>
7397 #define NFSDDBG_FACILITY NFSDDBG_XDR
7399 @@ -1727,14 +1728,18 @@ out_acl:
7400 WRITE32(stat.nlink);
7402 if (bmval1 & FATTR4_WORD1_OWNER) {
7403 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7404 + status = nfsd4_encode_user(rqstp,
7405 + TAGINO_UID(DX_TAG(dentry->d_inode),
7406 + stat.uid, stat.tag), &p, &buflen);
7407 if (status == nfserr_resource)
7412 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7413 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7414 + status = nfsd4_encode_group(rqstp,
7415 + TAGINO_GID(DX_TAG(dentry->d_inode),
7416 + stat.gid, stat.tag), &p, &buflen);
7417 if (status == nfserr_resource)
7420 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/nfsxdr.c linux-2.6.22.10-vs2.2.0.5/fs/nfsd/nfsxdr.c
7421 --- linux-2.6.22.10/fs/nfsd/nfsxdr.c 2007-07-09 13:19:27 +0200
7422 +++ linux-2.6.22.10-vs2.2.0.5/fs/nfsd/nfsxdr.c 2007-06-15 02:37:03 +0200
7424 #include <linux/nfsd/nfsd.h>
7425 #include <linux/nfsd/xdr.h>
7426 #include <linux/mm.h>
7427 +#include <linux/vs_tag.h>
7429 #define NFSDDBG_FACILITY NFSDDBG_XDR
7431 @@ -97,6 +98,8 @@ static __be32 *
7432 decode_sattr(__be32 *p, struct iattr *iap)
7440 @@ -110,12 +113,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7442 if ((tmp = ntohl(*p++)) != (u32)-1) {
7443 iap->ia_valid |= ATTR_UID;
7444 - iap->ia_uid = tmp;
7447 if ((tmp = ntohl(*p++)) != (u32)-1) {
7448 iap->ia_valid |= ATTR_GID;
7449 - iap->ia_gid = tmp;
7452 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7453 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7454 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7455 if ((tmp = ntohl(*p++)) != (u32)-1) {
7456 iap->ia_valid |= ATTR_SIZE;
7458 @@ -160,8 +166,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7459 *p++ = htonl(nfs_ftypes[type >> 12]);
7460 *p++ = htonl((u32) stat->mode);
7461 *p++ = htonl((u32) stat->nlink);
7462 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7463 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7464 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7465 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7466 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7467 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7469 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7470 *p++ = htonl(NFS_MAXPATHLEN);
7471 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/vfs.c linux-2.6.22.10-vs2.2.0.5/fs/nfsd/vfs.c
7472 --- linux-2.6.22.10/fs/nfsd/vfs.c 2007-10-30 01:57:14 +0100
7473 +++ linux-2.6.22.10-vs2.2.0.5/fs/nfsd/vfs.c 2007-08-12 12:21:51 +0200
7474 @@ -1186,13 +1186,13 @@ nfsd_create(struct svc_rqst *rqstp, stru
7475 host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
7478 - host_err = vfs_mkdir(dirp, dchild, iap->ia_mode);
7479 + host_err = vfs_mkdir(dirp, dchild, iap->ia_mode, NULL);
7485 - host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
7486 + host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev, NULL);
7489 printk("nfsd: bad file type %o in nfsd_create\n", type);
7490 @@ -1466,11 +1466,13 @@ nfsd_symlink(struct svc_rqst *rqstp, str
7492 strncpy(path_alloced, path, plen);
7493 path_alloced[plen] = 0;
7494 - host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
7495 + host_err = vfs_symlink(dentry->d_inode, dnew,
7496 + path_alloced, mode, NULL);
7497 kfree(path_alloced);
7500 - host_err = vfs_symlink(dentry->d_inode, dnew, path, mode);
7501 + host_err = vfs_symlink(dentry->d_inode, dnew,
7502 + path, mode, NULL);
7505 if (EX_ISSYNC(fhp->fh_export))
7506 @@ -1529,7 +1531,7 @@ nfsd_link(struct svc_rqst *rqstp, struct
7507 dold = tfhp->fh_dentry;
7508 dest = dold->d_inode;
7510 - host_err = vfs_link(dold, dirp, dnew);
7511 + host_err = vfs_link(dold, dirp, dnew, NULL);
7513 if (EX_ISSYNC(ffhp->fh_export)) {
7514 err = nfserrno(nfsd_sync_dir(ddir));
7515 @@ -1694,9 +1696,9 @@ nfsd_unlink(struct svc_rqst *rqstp, stru
7519 - host_err = vfs_unlink(dirp, rdentry);
7520 + host_err = vfs_unlink(dirp, rdentry, NULL);
7521 } else { /* It's RMDIR */
7522 - host_err = vfs_rmdir(dirp, rdentry);
7523 + host_err = vfs_rmdir(dirp, rdentry, NULL);
7527 @@ -1818,6 +1820,7 @@ nfsd_permission(struct svc_export *exp,
7528 if (!(acc & MAY_LOCAL_ACCESS))
7529 if (acc & (MAY_WRITE | MAY_SATTR | MAY_TRUNC)) {
7530 - if (EX_RDONLY(exp, rqstp) || IS_RDONLY(inode))
7531 + if (EX_RDONLY(exp, rqstp) || IS_RDONLY(inode)
7532 + || MNT_IS_RDONLY(exp->ex_mnt))
7534 if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE(inode))
7536 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/dlm/dlmfs.c linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/dlm/dlmfs.c
7537 --- linux-2.6.22.10/fs/ocfs2/dlm/dlmfs.c 2007-07-09 13:19:28 +0200
7538 +++ linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/dlm/dlmfs.c 2007-06-15 02:37:03 +0200
7540 #include <linux/init.h>
7541 #include <linux/string.h>
7542 #include <linux/backing-dev.h>
7543 +#include <linux/vs_tag.h>
7545 #include <asm/uaccess.h>
7547 @@ -331,6 +332,7 @@ static struct inode *dlmfs_get_root_inod
7548 inode->i_mode = mode;
7549 inode->i_uid = current->fsuid;
7550 inode->i_gid = current->fsgid;
7551 + inode->i_tag = dx_current_fstag(sb);
7552 inode->i_blocks = 0;
7553 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
7554 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
7555 @@ -357,6 +359,7 @@ static struct inode *dlmfs_get_inode(str
7556 inode->i_mode = mode;
7557 inode->i_uid = current->fsuid;
7558 inode->i_gid = current->fsgid;
7559 + inode->i_tag = dx_current_fstag(sb);
7560 inode->i_blocks = 0;
7561 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
7562 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
7563 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/dlmglue.c linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/dlmglue.c
7564 --- linux-2.6.22.10/fs/ocfs2/dlmglue.c 2007-07-09 13:19:28 +0200
7565 +++ linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/dlmglue.c 2007-06-15 02:37:03 +0200
7566 @@ -1475,6 +1475,7 @@ static void __ocfs2_stuff_meta_lvb(struc
7567 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
7568 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
7569 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
7570 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
7571 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
7572 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
7573 lvb->lvb_iatime_packed =
7574 @@ -1527,6 +1528,7 @@ static void ocfs2_refresh_inode_from_lvb
7576 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
7577 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
7578 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
7579 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
7580 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
7581 ocfs2_unpack_timespec(&inode->i_atime,
7582 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/dlmglue.h linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/dlmglue.h
7583 --- linux-2.6.22.10/fs/ocfs2/dlmglue.h 2007-07-09 13:19:28 +0200
7584 +++ linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/dlmglue.h 2007-06-15 02:37:03 +0200
7586 struct ocfs2_meta_lvb {
7589 - __be16 lvb_reserved1;
7591 __be32 lvb_iclusters;
7594 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/file.c linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/file.c
7595 --- linux-2.6.22.10/fs/ocfs2/file.c 2007-10-30 01:57:14 +0100
7596 +++ linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/file.c 2007-09-05 03:05:52 +0200
7597 @@ -943,13 +943,15 @@ int ocfs2_setattr(struct dentry *dentry,
7598 mlog(0, "uid change: %d\n", attr->ia_uid);
7599 if (attr->ia_valid & ATTR_GID)
7600 mlog(0, "gid change: %d\n", attr->ia_gid);
7601 + if (attr->ia_valid & ATTR_TAG)
7602 + mlog(0, "tag change: %d\n", attr->ia_tag);
7603 if (attr->ia_valid & ATTR_SIZE)
7604 mlog(0, "size change...\n");
7605 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
7606 mlog(0, "time change...\n");
7608 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
7609 - | ATTR_GID | ATTR_UID | ATTR_MODE)
7610 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
7611 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
7612 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
7614 @@ -1805,6 +1807,7 @@ bail:
7615 const struct inode_operations ocfs2_file_iops = {
7616 .setattr = ocfs2_setattr,
7617 .getattr = ocfs2_getattr,
7618 + .sync_flags = ocfs2_sync_flags,
7619 .permission = ocfs2_permission,
7622 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/inode.c linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/inode.c
7623 --- linux-2.6.22.10/fs/ocfs2/inode.c 2007-07-09 13:19:28 +0200
7624 +++ linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/inode.c 2007-06-15 03:10:27 +0200
7626 #include <linux/slab.h>
7627 #include <linux/highmem.h>
7628 #include <linux/pagemap.h>
7629 +#include <linux/vs_tag.h>
7631 #include <asm/byteorder.h>
7635 #include "heartbeat.h"
7638 #include "journal.h"
7640 #include "suballoc.h"
7641 @@ -77,6 +79,10 @@ void ocfs2_set_inode_flags(struct inode
7643 if (flags & OCFS2_IMMUTABLE_FL)
7644 inode->i_flags |= S_IMMUTABLE;
7645 + if (flags & OCFS2_IUNLINK_FL)
7646 + inode->i_flags |= S_IUNLINK;
7647 + if (flags & OCFS2_BARRIER_FL)
7648 + inode->i_flags |= S_BARRIER;
7650 if (flags & OCFS2_SYNC_FL)
7651 inode->i_flags |= S_SYNC;
7652 @@ -107,6 +113,27 @@ void ocfs2_get_inode_flags(struct ocfs2_
7653 oi->ip_attr |= OCFS2_DIRSYNC_FL;
7656 +int ocfs2_sync_flags(struct inode *inode)
7658 + unsigned int oldflags, newflags;
7660 + oldflags = OCFS2_I(inode)->ip_flags;
7661 + newflags = oldflags & ~(OCFS2_IMMUTABLE_FL |
7662 + OCFS2_IUNLINK_FL | OCFS2_BARRIER_FL);
7664 + if (IS_IMMUTABLE(inode))
7665 + newflags |= OCFS2_IMMUTABLE_FL;
7666 + if (IS_IUNLINK(inode))
7667 + newflags |= OCFS2_IUNLINK_FL;
7668 + if (IS_BARRIER(inode))
7669 + newflags |= OCFS2_BARRIER_FL;
7671 + if (oldflags ^ newflags)
7672 + return ocfs2_set_inode_attr(inode,
7673 + newflags, OCFS2_FL_MASK);
7677 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags)
7679 struct inode *inode = NULL;
7680 @@ -212,6 +239,8 @@ int ocfs2_populate_inode(struct inode *i
7681 struct super_block *sb;
7682 struct ocfs2_super *osb;
7683 int status = -EINVAL;
7687 mlog_entry("(0x%p, size:%llu)\n", inode,
7688 (unsigned long long)le64_to_cpu(fe->i_size));
7689 @@ -246,8 +275,12 @@ int ocfs2_populate_inode(struct inode *i
7690 inode->i_generation = le32_to_cpu(fe->i_generation);
7691 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
7692 inode->i_mode = le16_to_cpu(fe->i_mode);
7693 - inode->i_uid = le32_to_cpu(fe->i_uid);
7694 - inode->i_gid = le32_to_cpu(fe->i_gid);
7695 + uid = le32_to_cpu(fe->i_uid);
7696 + gid = le32_to_cpu(fe->i_gid);
7697 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7698 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7699 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
7700 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
7702 /* Fast symlinks will have i_size but no allocated clusters. */
7703 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
7704 @@ -1224,8 +1257,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
7706 fe->i_size = cpu_to_le64(i_size_read(inode));
7707 fe->i_links_count = cpu_to_le16(inode->i_nlink);
7708 - fe->i_uid = cpu_to_le32(inode->i_uid);
7709 - fe->i_gid = cpu_to_le32(inode->i_gid);
7710 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
7711 + inode->i_uid, inode->i_tag));
7712 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
7713 + inode->i_gid, inode->i_tag));
7714 + /* i_tag = = cpu_to_le16(inode->i_tag); */
7715 fe->i_mode = cpu_to_le16(inode->i_mode);
7716 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
7717 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
7718 @@ -1253,15 +1289,24 @@ leave:
7719 void ocfs2_refresh_inode(struct inode *inode,
7720 struct ocfs2_dinode *fe)
7725 spin_lock(&OCFS2_I(inode)->ip_lock);
7727 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
7728 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
7729 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
7730 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
7731 ocfs2_set_inode_flags(inode);
7732 i_size_write(inode, le64_to_cpu(fe->i_size));
7733 inode->i_nlink = le16_to_cpu(fe->i_links_count);
7734 - inode->i_uid = le32_to_cpu(fe->i_uid);
7735 - inode->i_gid = le32_to_cpu(fe->i_gid);
7736 + uid = le32_to_cpu(fe->i_uid);
7737 + gid = le32_to_cpu(fe->i_gid);
7738 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7739 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7740 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
7741 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
7742 inode->i_mode = le16_to_cpu(fe->i_mode);
7743 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
7744 inode->i_blocks = 0;
7745 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/inode.h linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/inode.h
7746 --- linux-2.6.22.10/fs/ocfs2/inode.h 2007-07-09 13:19:28 +0200
7747 +++ linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/inode.h 2007-06-15 03:10:53 +0200
7748 @@ -142,6 +142,7 @@ int ocfs2_aio_write(struct file *file, s
7750 void ocfs2_set_inode_flags(struct inode *inode);
7751 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
7752 +int ocfs2_sync_flags(struct inode *inode);
7754 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
7756 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/ioctl.c linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/ioctl.c
7757 --- linux-2.6.22.10/fs/ocfs2/ioctl.c 2007-07-09 13:19:28 +0200
7758 +++ linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/ioctl.c 2007-06-15 02:37:03 +0200
7759 @@ -39,7 +39,7 @@ static int ocfs2_get_inode_attr(struct i
7763 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7764 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7767 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
7768 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/ioctl.h linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/ioctl.h
7769 --- linux-2.6.22.10/fs/ocfs2/ioctl.h 2007-07-09 13:19:28 +0200
7770 +++ linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/ioctl.h 2007-06-15 02:37:03 +0200
7772 #ifndef OCFS2_IOCTL_H
7773 #define OCFS2_IOCTL_H
7775 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7778 int ocfs2_ioctl(struct inode * inode, struct file * filp,
7779 unsigned int cmd, unsigned long arg);
7780 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
7781 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/namei.c linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/namei.c
7782 --- linux-2.6.22.10/fs/ocfs2/namei.c 2007-07-09 13:19:28 +0200
7783 +++ linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/namei.c 2007-06-15 02:37:03 +0200
7785 #include <linux/types.h>
7786 #include <linux/slab.h>
7787 #include <linux/highmem.h>
7788 +#include <linux/vs_tag.h>
7790 #define MLOG_MASK_PREFIX ML_NAMEI
7791 #include <cluster/masklog.h>
7792 @@ -483,6 +484,9 @@ static int ocfs2_mknod_locked(struct ocf
7795 struct inode *inode = NULL;
7800 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
7801 (unsigned long)dev, dentry->d_name.len,
7802 @@ -542,13 +546,19 @@ static int ocfs2_mknod_locked(struct ocf
7803 fe->i_blkno = cpu_to_le64(fe_blkno);
7804 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
7805 fe->i_suballoc_slot = cpu_to_le16(osb->slot_num);
7806 - fe->i_uid = cpu_to_le32(current->fsuid);
7808 + tag = dx_current_fstag(osb->sb);
7809 + uid = current->fsuid;
7810 if (dir->i_mode & S_ISGID) {
7811 - fe->i_gid = cpu_to_le32(dir->i_gid);
7816 - fe->i_gid = cpu_to_le32(current->fsgid);
7817 + gid = current->fsgid;
7819 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), uid, tag));
7820 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), gid, tag));
7821 + inode->i_tag = tag;
7822 fe->i_mode = cpu_to_le16(mode);
7823 if (S_ISCHR(mode) || S_ISBLK(mode))
7824 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
7825 @@ -2316,5 +2326,6 @@ const struct inode_operations ocfs2_dir_
7826 .rename = ocfs2_rename,
7827 .setattr = ocfs2_setattr,
7828 .getattr = ocfs2_getattr,
7829 + .sync_flags = ocfs2_sync_flags,
7830 .permission = ocfs2_permission,
7832 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/ocfs2.h linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/ocfs2.h
7833 --- linux-2.6.22.10/fs/ocfs2/ocfs2.h 2007-07-09 13:19:28 +0200
7834 +++ linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/ocfs2.h 2007-06-15 02:37:03 +0200
7835 @@ -170,6 +170,7 @@ enum ocfs2_mount_options
7836 OCFS2_MOUNT_NOINTR = 1 << 2, /* Don't catch signals */
7837 OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */
7838 OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */
7839 + OCFS2_MOUNT_TAGGED = 1 << 8, /* use tagging */
7842 #define OCFS2_OSB_SOFT_RO 0x0001
7843 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/ocfs2_fs.h linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/ocfs2_fs.h
7844 --- linux-2.6.22.10/fs/ocfs2/ocfs2_fs.h 2007-07-09 13:19:28 +0200
7845 +++ linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/ocfs2_fs.h 2007-06-15 02:37:03 +0200
7846 @@ -152,8 +152,12 @@
7847 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
7848 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
7850 +#define OCFS2_BARRIER_FL (0x04000000) /* Barrier for chroot() */
7851 +#define OCFS2_IUNLINK_FL (0x08000000) /* Immutable unlink */
7853 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
7854 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
7855 +#define OCFS2_FL_MASK (0x0F0100FF)
7858 * Extent record flags (e_node.leaf.flags)
7859 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/super.c linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/super.c
7860 --- linux-2.6.22.10/fs/ocfs2/super.c 2007-07-09 13:19:28 +0200
7861 +++ linux-2.6.22.10-vs2.2.0.5/fs/ocfs2/super.c 2007-06-15 02:37:03 +0200
7862 @@ -140,6 +140,7 @@ enum {
7866 + Opt_tag, Opt_notag, Opt_tagid,
7870 @@ -154,6 +155,10 @@ static match_table_t tokens = {
7871 {Opt_data_ordered, "data=ordered"},
7872 {Opt_data_writeback, "data=writeback"},
7873 {Opt_atime_quantum, "atime_quantum=%u"},
7875 + {Opt_tag, "tagxid"},
7876 + {Opt_notag, "notag"},
7877 + {Opt_tagid, "tagid=%u"},
7881 @@ -362,6 +367,14 @@ static int ocfs2_remount(struct super_bl
7885 + printk("ocfs2_remount: %lx,%lx\n", osb->s_mount_opt, sb->s_flags);
7886 + if ((parsed_options & OCFS2_MOUNT_TAGGED) &&
7887 + !(sb->s_flags & MS_TAGGED)) {
7889 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
7893 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
7894 (parsed_options & OCFS2_MOUNT_HB_LOCAL)) {
7896 @@ -654,6 +667,9 @@ static int ocfs2_fill_super(struct super
7898 ocfs2_complete_mount_recovery(osb);
7900 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
7901 + sb->s_flags |= MS_TAGGED;
7903 if (ocfs2_mount_local(osb))
7904 snprintf(nodestr, sizeof(nodestr), "local");
7906 @@ -782,6 +798,20 @@ static int ocfs2_parse_options(struct su
7908 osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
7910 +#ifndef CONFIG_TAGGING_NONE
7912 + *mount_opt |= OCFS2_MOUNT_TAGGED;
7915 + *mount_opt &= ~OCFS2_MOUNT_TAGGED;
7918 +#ifdef CONFIG_PROPAGATE
7921 + *mount_opt |= OCFS2_MOUNT_TAGGED;
7926 "Unrecognized mount option \"%s\" "
7927 diff -NurpP --minimal linux-2.6.22.10/fs/open.c linux-2.6.22.10-vs2.2.0.5/fs/open.c
7928 --- linux-2.6.22.10/fs/open.c 2007-07-09 13:19:28 +0200
7929 +++ linux-2.6.22.10-vs2.2.0.5/fs/open.c 2007-06-15 02:37:03 +0200
7931 #include <linux/syscalls.h>
7932 #include <linux/rcupdate.h>
7933 #include <linux/audit.h>
7934 +#include <linux/vs_base.h>
7935 +#include <linux/vs_limit.h>
7936 +#include <linux/vs_dlimit.h>
7937 +#include <linux/vs_tag.h>
7938 +#include <linux/vs_cowbl.h>
7940 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
7942 int retval = -ENODEV;
7945 + struct super_block *sb = dentry->d_sb;
7948 - if (dentry->d_sb->s_op->statfs) {
7949 + if (sb->s_op->statfs) {
7950 memset(buf, 0, sizeof(*buf));
7951 retval = security_sb_statfs(dentry);
7954 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
7955 + retval = sb->s_op->statfs(dentry, buf);
7956 if (retval == 0 && buf->f_frsize == 0)
7957 buf->f_frsize = buf->f_bsize;
7959 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7960 + vx_vsi_statfs(sb, buf);
7964 @@ -248,7 +257,7 @@ static long do_sys_truncate(const char _
7968 - if (IS_RDONLY(inode))
7969 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
7973 @@ -397,7 +406,7 @@ asmlinkage long sys_faccessat(int dfd, c
7974 special_file(nd.dentry->d_inode->i_mode))
7975 goto out_path_release;
7977 - if(IS_RDONLY(nd.dentry->d_inode))
7978 + if(IS_RDONLY(nd.dentry->d_inode) || MNT_IS_RDONLY(nd.mnt))
7982 @@ -511,7 +520,7 @@ asmlinkage long sys_fchmod(unsigned int
7983 audit_inode(NULL, inode);
7986 - if (IS_RDONLY(inode))
7987 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(file->f_vfsmnt))
7990 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
7991 @@ -541,11 +550,11 @@ asmlinkage long sys_fchmodat(int dfd, co
7992 error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
7995 - inode = nd.dentry->d_inode;
7998 - if (IS_RDONLY(inode))
7999 + error = cow_check_and_break(&nd);
8002 + inode = nd.dentry->d_inode;
8005 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8006 @@ -570,7 +579,8 @@ asmlinkage long sys_chmod(const char __u
8007 return sys_fchmodat(AT_FDCWD, filename, mode);
8010 -static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
8011 +static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
8012 + uid_t user, gid_t group)
8014 struct inode * inode;
8016 @@ -582,7 +592,7 @@ static int chown_common(struct dentry *
8020 - if (IS_RDONLY(inode))
8021 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
8024 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8025 @@ -590,11 +600,11 @@ static int chown_common(struct dentry *
8026 newattrs.ia_valid = ATTR_CTIME;
8027 if (user != (uid_t) -1) {
8028 newattrs.ia_valid |= ATTR_UID;
8029 - newattrs.ia_uid = user;
8030 + newattrs.ia_uid = dx_map_uid(user);
8032 if (group != (gid_t) -1) {
8033 newattrs.ia_valid |= ATTR_GID;
8034 - newattrs.ia_gid = group;
8035 + newattrs.ia_gid = dx_map_gid(group);
8037 if (!S_ISDIR(inode->i_mode))
8038 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
8039 @@ -613,7 +623,11 @@ asmlinkage long sys_chown(const char __u
8040 error = user_path_walk(filename, &nd);
8043 - error = chown_common(nd.dentry, user, group);
8044 +#ifdef CONFIG_VSERVER_COWBL
8045 + error = cow_check_and_break(&nd);
8048 + error = chown_common(nd.dentry, nd.mnt, user, group);
8052 @@ -633,7 +647,11 @@ asmlinkage long sys_fchownat(int dfd, co
8053 error = __user_walk_fd(dfd, filename, follow, &nd);
8056 - error = chown_common(nd.dentry, user, group);
8057 +#ifdef CONFIG_VSERVER_COWBL
8058 + error = cow_check_and_break(&nd);
8061 + error = chown_common(nd.dentry, nd.mnt, user, group);
8065 @@ -647,7 +665,11 @@ asmlinkage long sys_lchown(const char __
8066 error = user_path_walk_link(filename, &nd);
8069 - error = chown_common(nd.dentry, user, group);
8070 +#ifdef CONFIG_VSERVER_COWBL
8071 + error = cow_check_and_break(&nd);
8074 + error = chown_common(nd.dentry, nd.mnt, user, group);
8078 @@ -666,7 +688,7 @@ asmlinkage long sys_fchown(unsigned int
8080 dentry = file->f_path.dentry;
8081 audit_inode(NULL, dentry->d_inode);
8082 - error = chown_common(dentry, user, group);
8083 + error = chown_common(dentry, file->f_vfsmnt, user, group);
8087 @@ -893,6 +915,7 @@ repeat:
8088 FD_SET(fd, fdt->open_fds);
8089 FD_CLR(fd, fdt->close_on_exec);
8090 files->next_fd = fd + 1;
8091 + vx_openfd_inc(fd);
8094 if (fdt->fd[fd] != NULL) {
8095 @@ -915,6 +938,7 @@ static void __put_unused_fd(struct files
8096 __FD_CLR(fd, fdt->open_fds);
8097 if (fd < files->next_fd)
8098 files->next_fd = fd;
8099 + vx_openfd_dec(fd);
8102 void fastcall put_unused_fd(unsigned int fd)
8103 diff -NurpP --minimal linux-2.6.22.10/fs/proc/array.c linux-2.6.22.10-vs2.2.0.5/fs/proc/array.c
8104 --- linux-2.6.22.10/fs/proc/array.c 2007-07-09 13:19:28 +0200
8105 +++ linux-2.6.22.10-vs2.2.0.5/fs/proc/array.c 2007-06-15 03:04:38 +0200
8107 #include <linux/cpuset.h>
8108 #include <linux/rcupdate.h>
8109 #include <linux/delayacct.h>
8110 +#include <linux/vs_context.h>
8111 +#include <linux/vs_network.h>
8113 #include <asm/uaccess.h>
8114 #include <asm/pgtable.h>
8115 @@ -134,8 +136,9 @@ static const char *task_state_array[] =
8116 "D (disk sleep)", /* 2 */
8117 "T (stopped)", /* 4 */
8118 "T (tracing stop)", /* 8 */
8119 - "Z (zombie)", /* 16 */
8120 - "X (dead)" /* 32 */
8121 + "H (on hold)", /* 16 */
8122 + "Z (zombie)", /* 32 */
8123 + "X (dead)", /* 64 */
8126 static inline const char * get_task_state(struct task_struct *tsk)
8127 @@ -144,7 +147,8 @@ static inline const char * get_task_stat
8128 TASK_INTERRUPTIBLE |
8129 TASK_UNINTERRUPTIBLE |
8134 (tsk->exit_state & (EXIT_ZOMBIE |
8136 const char **p = &task_state_array[0];
8137 @@ -161,8 +165,16 @@ static inline char * task_state(struct t
8138 struct group_info *group_info;
8140 struct fdtable *fdt = NULL;
8141 + pid_t pid, ptgid, tppid, tgid;
8144 + tgid = vx_map_tgid(p->tgid);
8145 + pid = vx_map_pid(p->pid);
8146 + ptgid = vx_map_pid(pid_alive(p) ?
8147 + rcu_dereference(p->real_parent)->tgid : 0);
8148 + tppid = vx_map_pid(pid_alive(p) && p->ptrace ?
8149 + rcu_dereference(p->parent)->pid : 0);
8151 buffer += sprintf(buffer,
8153 "SleepAVG:\t%lu%%\n"
8154 @@ -174,9 +186,7 @@ static inline char * task_state(struct t
8155 "Gid:\t%d\t%d\t%d\t%d\n",
8157 (p->sleep_avg/1024)*100/(1020000000/1024),
8159 - pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0,
8160 - pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0,
8161 + tgid, pid, (pid > 1) ? ptgid : 0, tppid,
8162 p->uid, p->euid, p->suid, p->fsuid,
8163 p->gid, p->egid, p->sgid, p->fsgid);
8165 @@ -283,17 +293,26 @@ static inline char * task_sig(struct tas
8167 static inline char *task_cap(struct task_struct *p, char *buffer)
8169 - return buffer + sprintf(buffer, "CapInh:\t%016x\n"
8170 - "CapPrm:\t%016x\n"
8171 - "CapEff:\t%016x\n",
8172 - cap_t(p->cap_inheritable),
8173 - cap_t(p->cap_permitted),
8174 - cap_t(p->cap_effective));
8175 + struct vx_info *vxi = p->vx_info;
8177 + return buffer + sprintf(buffer,
8178 + "CapInh:\t%016x\n"
8179 + "CapPrm:\t%016x\n"
8180 + "CapEff:\t%016x\n",
8181 + (unsigned)vx_info_mbcap(vxi, p->cap_inheritable),
8182 + (unsigned)vx_info_mbcap(vxi, p->cap_permitted),
8183 + (unsigned)vx_info_mbcap(vxi, p->cap_effective));
8186 int proc_pid_status(struct task_struct *task, char * buffer)
8188 char * orig = buffer;
8189 +#ifdef CONFIG_VSERVER_LEGACY
8190 + struct vx_info *vxi;
8192 +#ifdef CONFIG_VSERVER_LEGACYNET
8193 + struct nx_info *nxi;
8195 struct mm_struct *mm = get_task_mm(task);
8197 buffer = task_name(task, buffer);
8198 @@ -306,6 +325,46 @@ int proc_pid_status(struct task_struct *
8199 buffer = task_sig(task, buffer);
8200 buffer = task_cap(task, buffer);
8201 buffer = cpuset_task_status_allowed(task, buffer);
8203 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8205 +#ifdef CONFIG_VSERVER_LEGACY
8206 + buffer += sprintf (buffer,"s_context: %d\n", vx_task_xid(task));
8207 + vxi = task_get_vx_info(task);
8209 + buffer += sprintf (buffer,"ctxflags: %08llx\n"
8210 + ,(unsigned long long)vxi->vx_flags);
8211 + buffer += sprintf (buffer,"initpid: %d\n"
8212 + ,vxi->vx_initpid);
8214 + buffer += sprintf (buffer,"ctxflags: none\n");
8215 + buffer += sprintf (buffer,"initpid: none\n");
8219 + buffer += sprintf (buffer,"VxID: %d\n", vx_task_xid(task));
8221 +#ifdef CONFIG_VSERVER_LEGACYNET
8222 + nxi = task_get_nx_info(task);
8226 + buffer += sprintf (buffer,"ipv4root:");
8227 + for (i=0; i<nxi->nbipv4; i++){
8228 + buffer += sprintf (buffer," %08x/%08x"
8233 + buffer += sprintf (buffer,"ipv4root_bcast: %08x\n"
8236 + buffer += sprintf (buffer,"ipv4root: 0\n");
8237 + buffer += sprintf (buffer,"ipv4root_bcast: 0\n");
8242 #if defined(CONFIG_S390)
8243 buffer = task_show_regs(task, buffer);
8245 @@ -320,7 +379,7 @@ static int do_task_stat(struct task_stru
8246 sigset_t sigign, sigcatch;
8249 - pid_t ppid = 0, pgid = -1, sid = -1;
8250 + pid_t pid = 0, ppid = 0, pgid = -1, sid = -1;
8251 int num_threads = 0;
8252 struct mm_struct *mm;
8253 unsigned long long start_time;
8254 @@ -382,8 +441,10 @@ static int do_task_stat(struct task_stru
8257 sid = signal_session(sig);
8258 - pgid = process_group(task);
8259 - ppid = rcu_dereference(task->real_parent)->tgid;
8260 + pid = vx_info_map_pid(task->vx_info, task->pid);
8261 + pgid = vx_info_map_pid(task->vx_info, process_group(task));
8262 + ppid = (pid > 1) ? vx_info_map_tgid(task->vx_info,
8263 + rcu_dereference(task->real_parent)->tgid) : 0;
8265 unlock_task_sighand(task, &flags);
8267 @@ -410,10 +471,21 @@ static int do_task_stat(struct task_stru
8268 /* convert nsec -> ticks */
8269 start_time = nsec_to_clock_t(start_time);
8271 + /* fixup start time for virt uptime */
8272 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8273 + unsigned long long bias =
8274 + current->vx_info->cvirt.bias_clock;
8276 + if (start_time > bias)
8277 + start_time -= bias;
8282 res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %u %lu \
8283 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8284 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu\n",
8290 diff -NurpP --minimal linux-2.6.22.10/fs/proc/base.c linux-2.6.22.10-vs2.2.0.5/fs/proc/base.c
8291 --- linux-2.6.22.10/fs/proc/base.c 2007-07-09 13:19:28 +0200
8292 +++ linux-2.6.22.10-vs2.2.0.5/fs/proc/base.c 2007-06-15 03:06:14 +0200
8294 #include <linux/poll.h>
8295 #include <linux/nsproxy.h>
8296 #include <linux/oom.h>
8297 +#include <linux/vs_context.h>
8298 +#include <linux/vs_network.h>
8300 #include "internal.h"
8303 @@ -1049,6 +1052,8 @@ static struct inode *proc_pid_make_inode
8304 inode->i_uid = task->euid;
8305 inode->i_gid = task->egid;
8307 + /* procfs is xid tagged */
8308 + inode->i_tag = (tag_t)vx_task_xid(task);
8309 security_task_to_inode(task, inode);
8312 @@ -1115,6 +1128,7 @@ static int pid_revalidate(struct dentry
8313 put_task_struct(task);
8320 @@ -1595,6 +1600,13 @@ static struct dentry *proc_pident_lookup
8324 + /* TODO: maybe we can come up with a generic approach? */
8325 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8326 + (dentry->d_name.len == 5) &&
8327 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8328 + !memcmp(dentry->d_name.name, "ninfo", 5)))
8332 * Yes, it does not scale. And it should not. Don't add
8333 * new entries into /proc/<tgid>/ without very good reasons.
8334 @@ -1790,14 +1802,14 @@ static int proc_self_readlink(struct den
8337 char tmp[PROC_NUMBUF];
8338 - sprintf(tmp, "%d", current->tgid);
8339 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
8340 return vfs_readlink(dentry,buffer,buflen,tmp);
8343 static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
8345 char tmp[PROC_NUMBUF];
8346 - sprintf(tmp, "%d", current->tgid);
8347 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
8348 return ERR_PTR(vfs_follow_link(nd,tmp));
8351 @@ -1891,7 +1903,7 @@ out_iput:
8352 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8354 struct dentry *error;
8355 - struct task_struct *task = get_proc_task(dir);
8356 + struct task_struct *task = get_proc_task_real(dir);
8357 const struct pid_entry *p, *last;
8359 error = ERR_PTR(-ENOENT);
8360 @@ -1956,6 +1968,9 @@ static int proc_pid_io_accounting(struct
8361 static const struct file_operations proc_task_operations;
8362 static const struct inode_operations proc_task_inode_operations;
8364 +extern int proc_pid_vx_info(struct task_struct *, char *);
8365 +extern int proc_pid_nx_info(struct task_struct *, char *);
8367 static const struct pid_entry tgid_base_stuff[] = {
8368 DIR("task", S_IRUGO|S_IXUGO, task),
8369 DIR("fd", S_IRUSR|S_IXUSR, fd),
8370 @@ -1995,6 +2010,8 @@ static const struct pid_entry tgid_base_
8371 #ifdef CONFIG_CPUSETS
8372 REG("cpuset", S_IRUGO, cpuset),
8374 + INF("vinfo", S_IRUGO, pid_vx_info),
8375 + INF("ninfo", S_IRUGO, pid_nx_info),
8376 INF("oom_score", S_IRUGO, oom_score),
8377 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust),
8378 #ifdef CONFIG_AUDITSYSCALL
8379 @@ -2143,7 +2160,7 @@ struct dentry *proc_pid_lookup(struct in
8383 - task = find_task_by_pid(tgid);
8384 + task = vx_find_proc_task_by_pid(tgid);
8386 get_task_struct(task);
8388 @@ -2207,7 +2224,7 @@ static int proc_pid_fill_cache(struct fi
8389 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
8391 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8392 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
8393 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8394 struct task_struct *task;
8397 @@ -2226,6 +2243,8 @@ int proc_pid_readdir(struct file * filp,
8398 put_task_struct(task), task = next_tgid(tgid + 1)) {
8400 filp->f_pos = tgid + TGID_OFFSET;
8401 + if (!vx_proc_task_visible(task))
8403 if (proc_pid_fill_cache(filp, dirent, filldir, task, tgid) < 0) {
8404 put_task_struct(task);
8406 @@ -2352,9 +2371,11 @@ static struct dentry *proc_task_lookup(s
8407 tid = name_to_int(dentry);
8410 + if (vx_current_initpid(tid))
8414 - task = find_task_by_pid(tid);
8415 + task = vx_find_proc_task_by_pid(tid);
8417 get_task_struct(task);
8419 @@ -2499,7 +2520,7 @@ static int proc_task_readdir(struct file
8420 for (task = first_tid(leader, tid, pos - 2);
8422 task = next_tid(task), pos++) {
8424 + tid = vx_map_pid(task->pid);
8425 if (proc_task_fill_cache(filp, dirent, filldir, task, tid) < 0) {
8426 /* returning this tgid failed, save it as the first
8427 * pid for the next readir call */
8428 diff -NurpP --minimal linux-2.6.22.10/fs/proc/generic.c linux-2.6.22.10-vs2.2.0.5/fs/proc/generic.c
8429 --- linux-2.6.22.10/fs/proc/generic.c 2007-07-09 13:19:28 +0200
8430 +++ linux-2.6.22.10-vs2.2.0.5/fs/proc/generic.c 2007-06-15 03:08:54 +0200
8432 #include <linux/namei.h>
8433 #include <linux/bitops.h>
8434 #include <linux/spinlock.h>
8435 +#include <linux/vserver/inode.h>
8436 #include <asm/uaccess.h>
8438 #include "internal.h"
8439 @@ -395,6 +396,8 @@ struct dentry *proc_lookup(struct inode
8440 for (de = de->subdir; de ; de = de->next) {
8441 if (de->namelen != dentry->d_name.len)
8443 + if (!vx_hide_check(0, de->vx_flags))
8445 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
8446 unsigned int ino = de->low_ino;
8448 @@ -402,6 +405,8 @@ struct dentry *proc_lookup(struct inode
8449 spin_unlock(&proc_subdir_lock);
8451 inode = proc_get_inode(dir->i_sb, ino, de);
8452 + /* generic proc entries belong to the host */
8454 spin_lock(&proc_subdir_lock);
8457 @@ -482,6 +487,8 @@ int proc_readdir(struct file * filp,
8459 /* filldir passes info to user space */
8461 + if (!vx_hide_check(0, de->vx_flags))
8463 spin_unlock(&proc_subdir_lock);
8464 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8465 de->low_ino, de->mode >> 12) < 0) {
8466 @@ -489,6 +496,7 @@ int proc_readdir(struct file * filp,
8469 spin_lock(&proc_subdir_lock);
8474 @@ -613,6 +621,7 @@ static struct proc_dir_entry *proc_creat
8478 + ent->vx_flags = IATTR_PROC_DEFAULT;
8482 @@ -633,7 +642,8 @@ struct proc_dir_entry *proc_symlink(cons
8488 + ent->vx_flags = IATTR_PROC_SYMLINK;
8492 diff -NurpP --minimal linux-2.6.22.10/fs/proc/inode.c linux-2.6.22.10-vs2.2.0.5/fs/proc/inode.c
8493 --- linux-2.6.22.10/fs/proc/inode.c 2007-07-09 13:19:28 +0200
8494 +++ linux-2.6.22.10-vs2.2.0.5/fs/proc/inode.c 2007-06-15 02:37:03 +0200
8495 @@ -160,6 +160,8 @@ struct inode *proc_get_inode(struct supe
8496 inode->i_uid = de->uid;
8497 inode->i_gid = de->gid;
8500 + PROC_I(inode)->vx_flags = de->vx_flags;
8502 inode->i_size = de->size;
8504 diff -NurpP --minimal linux-2.6.22.10/fs/proc/internal.h linux-2.6.22.10-vs2.2.0.5/fs/proc/internal.h
8505 --- linux-2.6.22.10/fs/proc/internal.h 2007-07-09 13:19:28 +0200
8506 +++ linux-2.6.22.10-vs2.2.0.5/fs/proc/internal.h 2007-06-15 02:37:03 +0200
8510 #include <linux/proc_fs.h>
8511 +#include <linux/vs_pid.h>
8513 #ifdef CONFIG_PROC_SYSCTL
8514 extern int proc_sys_init(void);
8515 @@ -64,11 +65,16 @@ static inline struct pid *proc_pid(struc
8516 return PROC_I(inode)->pid;
8519 -static inline struct task_struct *get_proc_task(struct inode *inode)
8520 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
8522 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
8525 +static inline struct task_struct *get_proc_task(struct inode *inode)
8527 + return vx_get_proc_task(inode, proc_pid(inode));
8530 static inline int proc_fd(struct inode *inode)
8532 return PROC_I(inode)->fd;
8533 diff -NurpP --minimal linux-2.6.22.10/fs/proc/proc_misc.c linux-2.6.22.10-vs2.2.0.5/fs/proc/proc_misc.c
8534 --- linux-2.6.22.10/fs/proc/proc_misc.c 2007-07-09 13:19:28 +0200
8535 +++ linux-2.6.22.10-vs2.2.0.5/fs/proc/proc_misc.c 2007-06-15 02:37:03 +0200
8537 #include <asm/div64.h>
8538 #include "internal.h"
8540 +#include <linux/vs_cvirt.h>
8542 #define LOAD_INT(x) ((x) >> FSHIFT)
8543 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
8545 @@ -82,17 +84,32 @@ static int proc_calc_metrics(char *page,
8546 static int loadavg_read_proc(char *page, char **start, off_t off,
8547 int count, int *eof, void *data)
8549 + unsigned int running, threads;
8553 - a = avenrun[0] + (FIXED_1/200);
8554 - b = avenrun[1] + (FIXED_1/200);
8555 - c = avenrun[2] + (FIXED_1/200);
8556 - len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
8557 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
8558 + struct vx_info *vxi = current->vx_info;
8560 + a = vxi->cvirt.load[0] + (FIXED_1/200);
8561 + b = vxi->cvirt.load[1] + (FIXED_1/200);
8562 + c = vxi->cvirt.load[2] + (FIXED_1/200);
8564 + running = atomic_read(&vxi->cvirt.nr_running);
8565 + threads = atomic_read(&vxi->cvirt.nr_threads);
8567 + a = avenrun[0] + (FIXED_1/200);
8568 + b = avenrun[1] + (FIXED_1/200);
8569 + c = avenrun[2] + (FIXED_1/200);
8571 + running = nr_running();
8572 + threads = nr_threads;
8574 + len = sprintf(page,"%d.%02d %d.%02d %d.%02d %d/%d %d\n",
8575 LOAD_INT(a), LOAD_FRAC(a),
8576 LOAD_INT(b), LOAD_FRAC(b),
8577 LOAD_INT(c), LOAD_FRAC(c),
8578 - nr_running(), nr_threads, current->nsproxy->pid_ns->last_pid);
8579 + running, threads, current->nsproxy->pid_ns->last_pid);
8580 return proc_calc_metrics(page, start, off, count, eof, len);
8583 @@ -106,6 +123,9 @@ static int uptime_read_proc(char *page,
8585 do_posix_clock_monotonic_gettime(&uptime);
8586 cputime_to_timespec(idletime, &idle);
8587 + if (vx_flags(VXF_VIRT_UPTIME, 0))
8588 + vx_vsi_uptime(&uptime, &idle);
8590 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
8591 (unsigned long) uptime.tv_sec,
8592 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
8593 @@ -137,7 +157,7 @@ static int meminfo_read_proc(char *page,
8595 cached = global_page_state(NR_FILE_PAGES) -
8596 total_swapcache_pages - i.bufferram;
8598 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
8601 get_vmalloc_info(&vmi);
8602 diff -NurpP --minimal linux-2.6.22.10/fs/proc/root.c linux-2.6.22.10-vs2.2.0.5/fs/proc/root.c
8603 --- linux-2.6.22.10/fs/proc/root.c 2007-05-02 19:25:21 +0200
8604 +++ linux-2.6.22.10-vs2.2.0.5/fs/proc/root.c 2007-06-15 02:37:03 +0200
8606 #include "internal.h"
8608 struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
8609 +struct proc_dir_entry *proc_virtual;
8611 +extern void proc_vx_init(void);
8613 static int proc_get_sb(struct file_system_type *fs_type,
8614 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
8615 @@ -79,6 +82,7 @@ void __init proc_root_init(void)
8616 proc_device_tree_init();
8618 proc_bus = proc_mkdir("bus", NULL);
8623 diff -NurpP --minimal linux-2.6.22.10/fs/quota.c linux-2.6.22.10-vs2.2.0.5/fs/quota.c
8624 --- linux-2.6.22.10/fs/quota.c 2007-07-09 13:19:28 +0200
8625 +++ linux-2.6.22.10-vs2.2.0.5/fs/quota.c 2007-06-15 02:37:03 +0200
8627 #include <linux/buffer_head.h>
8628 #include <linux/capability.h>
8629 #include <linux/quotaops.h>
8630 +#include <linux/vs_context.h>
8632 /* Check validity of generic quotactl commands */
8633 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
8634 @@ -80,11 +81,11 @@ static int generic_quotactl_valid(struct
8635 if (cmd == Q_GETQUOTA) {
8636 if (((type == USRQUOTA && current->euid != id) ||
8637 (type == GRPQUOTA && !in_egroup_p(id))) &&
8638 - !capable(CAP_SYS_ADMIN))
8639 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8642 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
8643 - if (!capable(CAP_SYS_ADMIN))
8644 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8648 @@ -131,10 +132,10 @@ static int xqm_quotactl_valid(struct sup
8649 if (cmd == Q_XGETQUOTA) {
8650 if (((type == XQM_USRQUOTA && current->euid != id) ||
8651 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
8652 - !capable(CAP_SYS_ADMIN))
8653 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8655 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
8656 - if (!capable(CAP_SYS_ADMIN))
8657 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8661 @@ -327,6 +328,46 @@ static int do_quotactl(struct super_bloc
8665 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8667 +#include <linux/vroot.h>
8668 +#include <linux/major.h>
8669 +#include <linux/module.h>
8670 +#include <linux/kallsyms.h>
8671 +#include <linux/vserver/debug.h>
8673 +static vroot_grb_func *vroot_get_real_bdev = NULL;
8675 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
8677 +int register_vroot_grb(vroot_grb_func *func) {
8680 + spin_lock(&vroot_grb_lock);
8681 + if (!vroot_get_real_bdev) {
8682 + vroot_get_real_bdev = func;
8685 + spin_unlock(&vroot_grb_lock);
8688 +EXPORT_SYMBOL(register_vroot_grb);
8690 +int unregister_vroot_grb(vroot_grb_func *func) {
8691 + int ret = -EINVAL;
8693 + spin_lock(&vroot_grb_lock);
8694 + if (vroot_get_real_bdev) {
8695 + vroot_get_real_bdev = NULL;
8698 + spin_unlock(&vroot_grb_lock);
8701 +EXPORT_SYMBOL(unregister_vroot_grb);
8706 * look up a superblock on which quota ops will be performed
8707 * - use the name of a block device to find the superblock thereon
8708 @@ -344,6 +385,22 @@ static inline struct super_block *quotac
8711 return ERR_PTR(PTR_ERR(bdev));
8712 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8713 + if (bdev && bdev->bd_inode &&
8714 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
8715 + struct block_device *bdnew = (void *)-EINVAL;
8717 + if (vroot_get_real_bdev)
8718 + bdnew = vroot_get_real_bdev(bdev);
8720 + vxdprintk(VXD_CBIT(misc, 0),
8721 + "vroot_get_real_bdev not set");
8723 + if (IS_ERR(bdnew))
8724 + return ERR_PTR(PTR_ERR(bdnew));
8728 sb = get_super(bdev);
8731 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/bitmap.c linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/bitmap.c
8732 --- linux-2.6.22.10/fs/reiserfs/bitmap.c 2007-02-06 03:01:29 +0100
8733 +++ linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/bitmap.c 2007-06-15 02:37:03 +0200
8735 #include <linux/reiserfs_fs_sb.h>
8736 #include <linux/reiserfs_fs_i.h>
8737 #include <linux/quotaops.h>
8738 +#include <linux/vs_dlimit.h>
8740 #define PREALLOCATION_SIZE 9
8742 @@ -425,8 +426,10 @@ static void _reiserfs_free_block(struct
8743 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
8745 journal_mark_dirty(th, s, sbh);
8746 - if (for_unformatted)
8747 + if (for_unformatted) {
8748 + DLIMIT_FREE_BLOCK(inode, 1);
8749 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
8753 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
8754 @@ -1034,6 +1037,7 @@ static inline int blocknrs_and_prealloc_
8755 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
8757 int nr_allocated = 0;
8760 determine_prealloc_size(hint);
8761 if (!hint->formatted_node) {
8762 @@ -1043,19 +1047,30 @@ static inline int blocknrs_and_prealloc_
8763 "reiserquota: allocating %d blocks id=%u",
8764 amount_needed, hint->inode->i_uid);
8767 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
8768 - if (quota_ret) /* Quota exceeded? */
8769 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
8772 return QUOTA_EXCEEDED;
8773 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
8774 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
8776 + return NO_DISK_SPACE;
8779 if (hint->preallocate && hint->prealloc_size) {
8780 #ifdef REISERQUOTA_DEBUG
8781 reiserfs_debug(s, REISERFS_DEBUG_CODE,
8782 "reiserquota: allocating (prealloc) %d blocks id=%u",
8783 hint->prealloc_size, hint->inode->i_uid);
8786 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
8787 - hint->prealloc_size);
8788 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
8789 + hint->prealloc_size);
8791 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
8792 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
8793 + hint->prealloc_size);
8797 hint->preallocate = hint->prealloc_size = 0;
8799 @@ -1087,7 +1102,10 @@ static inline int blocknrs_and_prealloc_
8801 hint->inode->i_uid);
8803 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
8804 + /* Free not allocated blocks */
8805 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
8806 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
8807 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
8809 while (nr_allocated--)
8810 reiserfs_free_block(hint->th, hint->inode,
8811 @@ -1118,10 +1136,10 @@ static inline int blocknrs_and_prealloc_
8812 REISERFS_I(hint->inode)->i_prealloc_count,
8813 hint->inode->i_uid);
8815 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
8816 - hint->prealloc_size - nr_allocated -
8817 - REISERFS_I(hint->inode)->
8818 - i_prealloc_count);
8819 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
8820 + REISERFS_I(hint->inode)->i_prealloc_count;
8821 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
8822 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
8826 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/file.c linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/file.c
8827 --- linux-2.6.22.10/fs/reiserfs/file.c 2007-07-09 13:19:28 +0200
8828 +++ linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/file.c 2007-10-29 23:24:21 +0100
8829 @@ -1546,4 +1546,5 @@ const struct inode_operations reiserfs_f
8830 .listxattr = reiserfs_listxattr,
8831 .removexattr = reiserfs_removexattr,
8832 .permission = reiserfs_permission,
8833 + .sync_flags = reiserfs_sync_flags,
8835 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/inode.c linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/inode.c
8836 --- linux-2.6.22.10/fs/reiserfs/inode.c 2007-07-09 13:19:28 +0200
8837 +++ linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/inode.c 2007-06-15 02:37:03 +0200
8839 #include <linux/mpage.h>
8840 #include <linux/writeback.h>
8841 #include <linux/quotaops.h>
8842 +#include <linux/vs_dlimit.h>
8843 +#include <linux/vs_tag.h>
8845 static int reiserfs_commit_write(struct file *f, struct page *page,
8846 unsigned from, unsigned to);
8847 @@ -50,6 +52,7 @@ void reiserfs_delete_inode(struct inode
8848 * stat data deletion */
8850 DQUOT_FREE_INODE(inode);
8851 + DLIMIT_FREE_INODE(inode);
8853 if (journal_end(&th, inode->i_sb, jbegin_count))
8855 @@ -1112,6 +1115,8 @@ static void init_inode(struct inode *ino
8856 struct buffer_head *bh;
8857 struct item_head *ih;
8861 //int version = ITEM_VERSION_1;
8863 bh = PATH_PLAST_BUFFER(path);
8864 @@ -1135,12 +1140,13 @@ static void init_inode(struct inode *ino
8865 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
8866 unsigned long blocks;
8868 + uid = sd_v1_uid(sd);
8869 + gid = sd_v1_gid(sd);
8871 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
8872 set_inode_sd_version(inode, STAT_DATA_V1);
8873 inode->i_mode = sd_v1_mode(sd);
8874 inode->i_nlink = sd_v1_nlink(sd);
8875 - inode->i_uid = sd_v1_uid(sd);
8876 - inode->i_gid = sd_v1_gid(sd);
8877 inode->i_size = sd_v1_size(sd);
8878 inode->i_atime.tv_sec = sd_v1_atime(sd);
8879 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
8880 @@ -1182,11 +1188,12 @@ static void init_inode(struct inode *ino
8881 // (directories and symlinks)
8882 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
8884 + uid = sd_v2_uid(sd);
8885 + gid = sd_v2_gid(sd);
8887 inode->i_mode = sd_v2_mode(sd);
8888 inode->i_nlink = sd_v2_nlink(sd);
8889 - inode->i_uid = sd_v2_uid(sd);
8890 inode->i_size = sd_v2_size(sd);
8891 - inode->i_gid = sd_v2_gid(sd);
8892 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
8893 inode->i_atime.tv_sec = sd_v2_atime(sd);
8894 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
8895 @@ -1216,6 +1223,10 @@ static void init_inode(struct inode *ino
8896 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
8899 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8900 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8901 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
8904 if (S_ISREG(inode->i_mode)) {
8905 inode->i_op = &reiserfs_file_inode_operations;
8906 @@ -1238,13 +1249,15 @@ static void init_inode(struct inode *ino
8907 static void inode2sd(void *sd, struct inode *inode, loff_t size)
8909 struct stat_data *sd_v2 = (struct stat_data *)sd;
8910 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
8911 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
8914 + set_sd_v2_uid(sd_v2, uid);
8915 + set_sd_v2_gid(sd_v2, gid);
8916 set_sd_v2_mode(sd_v2, inode->i_mode);
8917 set_sd_v2_nlink(sd_v2, inode->i_nlink);
8918 - set_sd_v2_uid(sd_v2, inode->i_uid);
8919 set_sd_v2_size(sd_v2, size);
8920 - set_sd_v2_gid(sd_v2, inode->i_gid);
8921 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
8922 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
8923 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
8924 @@ -1775,6 +1788,10 @@ int reiserfs_new_inode(struct reiserfs_t
8926 BUG_ON(!th->t_trans_id);
8928 + if (DLIMIT_ALLOC_INODE(inode)) {
8930 + goto out_bad_dlimit;
8932 if (DQUOT_ALLOC_INODE(inode)) {
8935 @@ -1960,6 +1977,9 @@ int reiserfs_new_inode(struct reiserfs_t
8936 DQUOT_FREE_INODE(inode);
8939 + DLIMIT_FREE_INODE(inode);
8942 journal_end(th, th->t_super, th->t_blocks_allocated);
8943 /* Drop can be outside and it needs more credits so it's better to have it outside */
8945 @@ -2690,6 +2710,14 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
8946 inode->i_flags |= S_IMMUTABLE;
8948 inode->i_flags &= ~S_IMMUTABLE;
8949 + if (sd_attrs & REISERFS_IUNLINK_FL)
8950 + inode->i_flags |= S_IUNLINK;
8952 + inode->i_flags &= ~S_IUNLINK;
8953 + if (sd_attrs & REISERFS_BARRIER_FL)
8954 + inode->i_flags |= S_BARRIER;
8956 + inode->i_flags &= ~S_BARRIER;
8957 if (sd_attrs & REISERFS_APPEND_FL)
8958 inode->i_flags |= S_APPEND;
8960 @@ -2712,6 +2740,14 @@ void i_attrs_to_sd_attrs(struct inode *i
8961 *sd_attrs |= REISERFS_IMMUTABLE_FL;
8963 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
8964 + if (inode->i_flags & S_IUNLINK)
8965 + *sd_attrs |= REISERFS_IUNLINK_FL;
8967 + *sd_attrs &= ~REISERFS_IUNLINK_FL;
8968 + if (inode->i_flags & S_BARRIER)
8969 + *sd_attrs |= REISERFS_BARRIER_FL;
8971 + *sd_attrs &= ~REISERFS_BARRIER_FL;
8972 if (inode->i_flags & S_SYNC)
8973 *sd_attrs |= REISERFS_SYNC_FL;
8975 @@ -2891,6 +2927,22 @@ static ssize_t reiserfs_direct_IO(int rw
8976 reiserfs_get_blocks_direct_io, NULL);
8979 +int reiserfs_sync_flags(struct inode *inode)
8981 + u16 oldflags, newflags;
8983 + oldflags = REISERFS_I(inode)->i_attrs;
8984 + newflags = oldflags;
8985 + i_attrs_to_sd_attrs(inode, &newflags);
8987 + if (oldflags ^ newflags) {
8988 + REISERFS_I(inode)->i_attrs = newflags;
8989 + inode->i_ctime = CURRENT_TIME_SEC;
8990 + mark_inode_dirty(inode);
8995 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
8997 struct inode *inode = dentry->d_inode;
8998 @@ -2940,9 +2992,11 @@ int reiserfs_setattr(struct dentry *dent
9001 error = inode_change_ok(inode, attr);
9004 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
9005 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
9006 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
9007 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
9008 error = reiserfs_chown_xattrs(inode, attr);
9011 @@ -2972,6 +3026,9 @@ int reiserfs_setattr(struct dentry *dent
9012 inode->i_uid = attr->ia_uid;
9013 if (attr->ia_valid & ATTR_GID)
9014 inode->i_gid = attr->ia_gid;
9015 + if ((attr->ia_valid & ATTR_TAG) &&
9017 + inode->i_tag = attr->ia_tag;
9018 mark_inode_dirty(inode);
9020 journal_end(&th, inode->i_sb, jbegin_count);
9021 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/ioctl.c linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/ioctl.c
9022 --- linux-2.6.22.10/fs/reiserfs/ioctl.c 2007-02-06 03:01:29 +0100
9023 +++ linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/ioctl.c 2007-06-15 02:37:03 +0200
9026 #include <linux/capability.h>
9027 #include <linux/fs.h>
9028 +#include <linux/mount.h>
9029 #include <linux/reiserfs_fs.h>
9030 #include <linux/time.h>
9031 #include <asm/uaccess.h>
9032 @@ -24,7 +25,7 @@ static int reiserfs_unpack(struct inode
9033 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
9036 - unsigned int flags;
9037 + unsigned int flags, oldflags;
9040 case REISERFS_IOC_UNPACK:
9041 @@ -43,12 +44,14 @@ int reiserfs_ioctl(struct inode *inode,
9043 flags = REISERFS_I(inode)->i_attrs;
9044 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
9045 + flags &= REISERFS_FL_USER_VISIBLE;
9046 return put_user(flags, (int __user *)arg);
9047 case REISERFS_IOC_SETFLAGS:{
9048 if (!reiserfs_attrs(inode->i_sb))
9051 - if (IS_RDONLY(inode))
9052 + if (IS_RDONLY(inode) ||
9053 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
9056 if ((current->fsuid != inode->i_uid)
9057 @@ -58,10 +61,12 @@ int reiserfs_ioctl(struct inode *inode,
9058 if (get_user(flags, (int __user *)arg))
9061 - if (((flags ^ REISERFS_I(inode)->
9062 - i_attrs) & (REISERFS_IMMUTABLE_FL |
9063 - REISERFS_APPEND_FL))
9064 - && !capable(CAP_LINUX_IMMUTABLE))
9065 + oldflags = REISERFS_I(inode) -> i_attrs;
9066 + if (((oldflags & REISERFS_IMMUTABLE_FL) ||
9067 + ((flags ^ oldflags) &
9068 + (REISERFS_IMMUTABLE_FL | REISERFS_IUNLINK_FL |
9069 + REISERFS_APPEND_FL))) &&
9070 + !capable(CAP_LINUX_IMMUTABLE))
9073 if ((flags & REISERFS_NOTAIL_FL) &&
9074 @@ -72,6 +77,9 @@ int reiserfs_ioctl(struct inode *inode,
9079 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
9080 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
9081 sd_attrs_to_i_attrs(flags, inode);
9082 REISERFS_I(inode)->i_attrs = flags;
9083 inode->i_ctime = CURRENT_TIME_SEC;
9084 @@ -83,7 +91,8 @@ int reiserfs_ioctl(struct inode *inode,
9085 case REISERFS_IOC_SETVERSION:
9086 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
9088 - if (IS_RDONLY(inode))
9089 + if (IS_RDONLY(inode) ||
9090 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
9092 if (get_user(inode->i_generation, (int __user *)arg))
9094 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/namei.c linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/namei.c
9095 --- linux-2.6.22.10/fs/reiserfs/namei.c 2007-07-09 13:19:28 +0200
9096 +++ linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/namei.c 2007-06-15 02:37:03 +0200
9098 #include <linux/reiserfs_acl.h>
9099 #include <linux/reiserfs_xattr.h>
9100 #include <linux/quotaops.h>
9101 +#include <linux/vs_tag.h>
9103 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; }
9104 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
9105 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
9106 reiserfs_write_unlock(dir->i_sb);
9107 return ERR_PTR(-EACCES);
9109 + dx_propagate_tag(nd, inode);
9111 /* Propogate the priv_object flag so we know we're in the priv tree */
9112 if (is_reiserfs_priv_object(dir))
9113 @@ -595,6 +597,7 @@ static int new_inode_init(struct inode *
9115 inode->i_gid = current->fsgid;
9117 + inode->i_tag = dx_current_fstag(inode->i_sb);
9121 @@ -1541,6 +1544,7 @@ const struct inode_operations reiserfs_d
9122 .listxattr = reiserfs_listxattr,
9123 .removexattr = reiserfs_removexattr,
9124 .permission = reiserfs_permission,
9125 + .sync_flags = reiserfs_sync_flags,
9129 @@ -1557,6 +1561,7 @@ const struct inode_operations reiserfs_s
9130 .listxattr = reiserfs_listxattr,
9131 .removexattr = reiserfs_removexattr,
9132 .permission = reiserfs_permission,
9133 + .sync_flags = reiserfs_sync_flags,
9137 @@ -1570,5 +1575,6 @@ const struct inode_operations reiserfs_s
9138 .listxattr = reiserfs_listxattr,
9139 .removexattr = reiserfs_removexattr,
9140 .permission = reiserfs_permission,
9141 + .sync_flags = reiserfs_sync_flags,
9144 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/stree.c linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/stree.c
9145 --- linux-2.6.22.10/fs/reiserfs/stree.c 2007-07-09 13:19:28 +0200
9146 +++ linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/stree.c 2007-06-15 02:37:03 +0200
9148 #include <linux/reiserfs_fs.h>
9149 #include <linux/buffer_head.h>
9150 #include <linux/quotaops.h>
9151 +#include <linux/vs_dlimit.h>
9153 /* Does the buffer contain a disk block which is in the tree. */
9154 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
9155 @@ -1296,6 +1297,7 @@ int reiserfs_delete_item(struct reiserfs
9156 "reiserquota delete_item(): freeing %u, id=%u type=%c",
9157 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
9159 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
9160 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
9162 /* Return deleted body length */
9163 @@ -1384,6 +1386,7 @@ void reiserfs_delete_solid_item(struct r
9165 DQUOT_FREE_SPACE_NODIRTY(inode,
9167 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
9171 @@ -1737,6 +1740,7 @@ int reiserfs_cut_from_item(struct reiser
9172 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
9173 quota_cut_bytes, p_s_inode->i_uid, '?');
9175 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
9176 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
9179 @@ -1978,6 +1982,11 @@ int reiserfs_paste_into_item(struct reis
9180 pathrelse(p_s_search_path);
9183 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
9184 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
9185 + pathrelse(p_s_search_path);
9188 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
9190 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
9191 @@ -2030,6 +2039,7 @@ int reiserfs_paste_into_item(struct reis
9192 n_pasted_size, inode->i_uid,
9193 key2type(&(p_s_key->on_disk_key)));
9195 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
9196 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
9199 @@ -2067,6 +2077,11 @@ int reiserfs_insert_item(struct reiserfs
9200 pathrelse(p_s_path);
9203 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
9204 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
9205 + pathrelse(p_s_path);
9209 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
9210 IH_SIZE + ih_item_len(p_s_ih));
9211 @@ -2114,7 +2129,9 @@ int reiserfs_insert_item(struct reiserfs
9212 "reiserquota insert_item(): freeing %u id=%u type=%c",
9213 quota_bytes, inode->i_uid, head2type(p_s_ih));
9217 + DLIMIT_FREE_SPACE(inode, quota_bytes);
9218 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
9222 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/super.c linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/super.c
9223 --- linux-2.6.22.10/fs/reiserfs/super.c 2007-07-09 13:19:28 +0200
9224 +++ linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/super.c 2007-06-15 02:37:03 +0200
9225 @@ -882,6 +882,14 @@ static int reiserfs_parse_options(struct
9226 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9227 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9229 +#ifndef CONFIG_TAGGING_NONE
9230 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9231 + {"tag",.setmask = 1 << REISERFS_TAGGED},
9232 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
9234 +#ifdef CONFIG_PROPAGATE
9235 + {"tag",.arg_required = 'T',.values = NULL},
9237 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9238 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9239 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9240 @@ -1143,6 +1151,12 @@ static int reiserfs_remount(struct super
9244 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
9245 + !(s->s_flags & MS_TAGGED)) {
9246 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
9252 /* Add options that are safe here */
9253 @@ -1591,6 +1605,10 @@ static int reiserfs_fill_super(struct su
9257 + /* map mount option tagxid */
9258 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9259 + s->s_flags |= MS_TAGGED;
9261 rs = SB_DISK_SUPER_BLOCK(s);
9262 /* Let's do basic sanity check to verify that underlying device is not
9263 smaller than the filesystem. If the check fails then abort and scream,
9264 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/xattr.c linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/xattr.c
9265 --- linux-2.6.22.10/fs/reiserfs/xattr.c 2007-07-09 13:19:28 +0200
9266 +++ linux-2.6.22.10-vs2.2.0.5/fs/reiserfs/xattr.c 2007-06-15 02:37:04 +0200
9268 #include <linux/namei.h>
9269 #include <linux/errno.h>
9270 #include <linux/fs.h>
9271 +#include <linux/mount.h>
9272 #include <linux/file.h>
9273 #include <linux/pagemap.h>
9274 #include <linux/xattr.h>
9275 @@ -775,7 +776,7 @@ int reiserfs_delete_xattrs(struct inode
9276 if (dir->d_inode->i_nlink <= 2) {
9277 root = get_xa_root(inode->i_sb, XATTR_REPLACE);
9278 reiserfs_write_lock_xattrs(inode->i_sb);
9279 - err = vfs_rmdir(root->d_inode, dir);
9280 + err = vfs_rmdir(root->d_inode, dir, NULL);
9281 reiserfs_write_unlock_xattrs(inode->i_sb);
9284 diff -NurpP --minimal linux-2.6.22.10/fs/stat.c linux-2.6.22.10-vs2.2.0.5/fs/stat.c
9285 --- linux-2.6.22.10/fs/stat.c 2007-07-09 13:19:28 +0200
9286 +++ linux-2.6.22.10-vs2.2.0.5/fs/stat.c 2007-06-15 02:37:04 +0200
9287 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9288 stat->nlink = inode->i_nlink;
9289 stat->uid = inode->i_uid;
9290 stat->gid = inode->i_gid;
9291 + stat->tag = inode->i_tag;
9292 stat->rdev = inode->i_rdev;
9293 stat->atime = inode->i_atime;
9294 stat->mtime = inode->i_mtime;
9295 diff -NurpP --minimal linux-2.6.22.10/fs/super.c linux-2.6.22.10-vs2.2.0.5/fs/super.c
9296 --- linux-2.6.22.10/fs/super.c 2007-07-09 13:19:28 +0200
9297 +++ linux-2.6.22.10-vs2.2.0.5/fs/super.c 2007-06-15 03:26:55 +0200
9299 #include <linux/idr.h>
9300 #include <linux/kobject.h>
9301 #include <linux/mutex.h>
9302 +#include <linux/devpts_fs.h>
9303 +#include <linux/proc_fs.h>
9304 +#include <linux/vs_context.h>
9305 #include <asm/uaccess.h>
9308 @@ -860,12 +863,18 @@ struct vfsmount *
9309 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
9311 struct vfsmount *mnt;
9312 + struct super_block *sb;
9313 char *secdata = NULL;
9317 return ERR_PTR(-ENODEV);
9320 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
9321 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
9325 mnt = alloc_vfsmnt(name);
9327 @@ -885,7 +894,14 @@ vfs_kern_mount(struct file_system_type *
9329 goto out_free_secdata;
9331 - error = security_sb_kern_mount(mnt->mnt_sb, secdata);
9334 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
9335 + (sb->s_magic != PROC_SUPER_MAGIC) &&
9336 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
9339 + error = security_sb_kern_mount(sb, secdata);
9343 diff -NurpP --minimal linux-2.6.22.10/fs/sysfs/mount.c linux-2.6.22.10-vs2.2.0.5/fs/sysfs/mount.c
9344 --- linux-2.6.22.10/fs/sysfs/mount.c 2007-07-09 13:19:28 +0200
9345 +++ linux-2.6.22.10-vs2.2.0.5/fs/sysfs/mount.c 2007-06-17 05:54:17 +0200
9350 -/* Random magic number */
9351 -#define SYSFS_MAGIC 0x62656572
9353 struct vfsmount *sysfs_mount;
9354 struct super_block * sysfs_sb = NULL;
9355 @@ -48,7 +46,7 @@ static int sysfs_fill_super(struct super
9357 sb->s_blocksize = PAGE_CACHE_SIZE;
9358 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9359 - sb->s_magic = SYSFS_MAGIC;
9360 + sb->s_magic = SYSFS_SUPER_MAGIC;
9361 sb->s_op = &sysfs_ops;
9362 sb->s_time_gran = 1;
9364 diff -NurpP --minimal linux-2.6.22.10/fs/utimes.c linux-2.6.22.10-vs2.2.0.5/fs/utimes.c
9365 --- linux-2.6.22.10/fs/utimes.c 2007-07-09 13:19:29 +0200
9366 +++ linux-2.6.22.10-vs2.2.0.5/fs/utimes.c 2007-07-09 13:11:54 +0200
9368 #include <linux/sched.h>
9369 #include <linux/stat.h>
9370 #include <linux/utime.h>
9371 +#include <linux/mount.h>
9372 +#include <linux/vs_cowbl.h>
9373 #include <asm/uaccess.h>
9374 #include <asm/unistd.h>
9376 @@ -70,14 +72,16 @@ long do_utimes(int dfd, char __user *fil
9380 + error = cow_check_and_break(&nd);
9382 + goto dput_and_out;
9386 inode = dentry->d_inode;
9389 if (IS_RDONLY(inode))
9390 - goto dput_and_out;
9391 + goto dput_and_out;
9393 /* Don't worry, the checks are done in inode_change_ok() */
9394 newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME;
9395 diff -NurpP --minimal linux-2.6.22.10/fs/xattr.c linux-2.6.22.10-vs2.2.0.5/fs/xattr.c
9396 --- linux-2.6.22.10/fs/xattr.c 2007-07-09 13:19:29 +0200
9397 +++ linux-2.6.22.10-vs2.2.0.5/fs/xattr.c 2007-06-15 02:37:04 +0200
9399 #include <linux/module.h>
9400 #include <linux/fsnotify.h>
9401 #include <linux/audit.h>
9402 +#include <linux/mount.h>
9403 #include <asm/uaccess.h>
9406 @@ -194,7 +195,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
9409 setxattr(struct dentry *d, char __user *name, void __user *value,
9410 - size_t size, int flags)
9411 + size_t size, int flags, struct vfsmount *mnt)
9414 void *kvalue = NULL;
9415 @@ -221,6 +222,9 @@ setxattr(struct dentry *d, char __user *
9419 + if (MNT_IS_RDONLY(mnt))
9422 error = vfs_setxattr(d, kname, kvalue, size, flags);
9425 @@ -236,7 +240,7 @@ sys_setxattr(char __user *path, char __u
9426 error = user_path_walk(path, &nd);
9429 - error = setxattr(nd.dentry, name, value, size, flags);
9430 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
9434 @@ -251,7 +255,7 @@ sys_lsetxattr(char __user *path, char __
9435 error = user_path_walk_link(path, &nd);
9438 - error = setxattr(nd.dentry, name, value, size, flags);
9439 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
9443 @@ -269,7 +273,7 @@ sys_fsetxattr(int fd, char __user *name,
9445 dentry = f->f_path.dentry;
9446 audit_inode(NULL, dentry->d_inode);
9447 - error = setxattr(dentry, name, value, size, flags);
9448 + error = setxattr(dentry, name, value, size, flags, f->f_vfsmnt);
9452 @@ -433,7 +437,7 @@ sys_flistxattr(int fd, char __user *list
9453 * Extended attribute REMOVE operations
9456 -removexattr(struct dentry *d, char __user *name)
9457 +removexattr(struct dentry *d, char __user *name, struct vfsmount *mnt)
9460 char kname[XATTR_NAME_MAX + 1];
9461 @@ -444,6 +448,9 @@ removexattr(struct dentry *d, char __use
9465 + if (MNT_IS_RDONLY(mnt))
9468 return vfs_removexattr(d, kname);
9471 @@ -456,7 +463,7 @@ sys_removexattr(char __user *path, char
9472 error = user_path_walk(path, &nd);
9475 - error = removexattr(nd.dentry, name);
9476 + error = removexattr(nd.dentry, name, nd.mnt);
9480 @@ -470,7 +477,7 @@ sys_lremovexattr(char __user *path, char
9481 error = user_path_walk_link(path, &nd);
9484 - error = removexattr(nd.dentry, name);
9485 + error = removexattr(nd.dentry, name, nd.mnt);
9489 @@ -487,7 +494,7 @@ sys_fremovexattr(int fd, char __user *na
9491 dentry = f->f_path.dentry;
9492 audit_inode(NULL, dentry->d_inode);
9493 - error = removexattr(dentry, name);
9494 + error = removexattr(dentry, name, f->f_vfsmnt);
9498 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.22.10-vs2.2.0.5/fs/xfs/linux-2.6/xfs_ioctl.c
9499 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_ioctl.c 2007-05-02 19:25:22 +0200
9500 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/linux-2.6/xfs_ioctl.c 2007-06-15 02:37:04 +0200
9501 @@ -1128,6 +1128,10 @@ xfs_di2lxflags(
9503 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9504 flags |= FS_IMMUTABLE_FL;
9505 + if (di_flags & XFS_DIFLAG_IUNLINK)
9506 + flags |= FS_IUNLINK_FL;
9507 + if (di_flags & XFS_DIFLAG_BARRIER)
9508 + flags |= FS_BARRIER_FL;
9509 if (di_flags & XFS_DIFLAG_APPEND)
9510 flags |= FS_APPEND_FL;
9511 if (di_flags & XFS_DIFLAG_SYNC)
9512 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.22.10-vs2.2.0.5/fs/xfs/linux-2.6/xfs_iops.c
9513 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_iops.c 2007-05-02 19:25:22 +0200
9514 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/linux-2.6/xfs_iops.c 2007-06-15 02:37:04 +0200
9516 #include <linux/xattr.h>
9517 #include <linux/namei.h>
9518 #include <linux/security.h>
9519 +#include <linux/vs_tag.h>
9522 * Get a XFS inode from a given vnode.
9523 @@ -400,6 +401,7 @@ xfs_vn_lookup(
9524 d_add(dentry, NULL);
9527 + dx_propagate_tag(nd, vn_to_inode(cvp));
9529 return d_splice_alias(vn_to_inode(cvp), dentry);
9531 @@ -657,6 +659,10 @@ xfs_vn_setattr(
9535 + error = inode_change_ok(inode, attr);
9539 if (ia_valid & ATTR_UID) {
9540 vattr.va_mask |= XFS_AT_UID;
9541 vattr.va_uid = attr->ia_uid;
9542 @@ -665,6 +671,10 @@ xfs_vn_setattr(
9543 vattr.va_mask |= XFS_AT_GID;
9544 vattr.va_gid = attr->ia_gid;
9546 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode)) {
9547 + vattr.va_mask |= XFS_AT_TAG;
9548 + vattr.va_tag = attr->ia_tag;
9550 if (ia_valid & ATTR_SIZE) {
9551 vattr.va_mask |= XFS_AT_SIZE;
9552 vattr.va_size = attr->ia_size;
9553 @@ -710,6 +720,42 @@ xfs_vn_truncate(
9557 +xfs_vn_sync_flags(struct inode *inode)
9559 + unsigned int oldflags, newflags;
9562 + bhv_vattr_t vattr;
9563 + bhv_vnode_t *vp = vn_from_inode(inode);
9565 + memset(&vattr, 0, sizeof vattr);
9567 + vattr.va_mask = XFS_AT_XFLAGS;
9568 + error = bhv_vop_getattr(vp, &vattr, 0, NULL);
9572 + oldflags = vattr.va_xflags;
9573 + newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE |
9574 + XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER);
9576 + if (IS_IMMUTABLE(inode))
9577 + newflags |= XFS_XFLAG_IMMUTABLE;
9578 + if (IS_IUNLINK(inode))
9579 + newflags |= XFS_XFLAG_IUNLINK;
9580 + if (IS_BARRIER(inode))
9581 + newflags |= XFS_XFLAG_BARRIER;
9583 + if (oldflags ^ newflags) {
9584 + vattr.va_xflags = newflags;
9585 + vattr.va_mask |= XFS_AT_XFLAGS;
9586 + error = bhv_vop_setattr(vp, &vattr, flags, NULL);
9588 + vn_revalidate(vp);
9594 struct dentry *dentry,
9596 @@ -822,6 +868,7 @@ const struct inode_operations xfs_inode_
9597 .getxattr = xfs_vn_getxattr,
9598 .listxattr = xfs_vn_listxattr,
9599 .removexattr = xfs_vn_removexattr,
9600 + .sync_flags = xfs_vn_sync_flags,
9603 const struct inode_operations xfs_dir_inode_operations = {
9604 @@ -841,6 +888,7 @@ const struct inode_operations xfs_dir_in
9605 .getxattr = xfs_vn_getxattr,
9606 .listxattr = xfs_vn_listxattr,
9607 .removexattr = xfs_vn_removexattr,
9608 + .sync_flags = xfs_vn_sync_flags,
9611 const struct inode_operations xfs_symlink_inode_operations = {
9612 @@ -854,4 +902,5 @@ const struct inode_operations xfs_symlin
9613 .getxattr = xfs_vn_getxattr,
9614 .listxattr = xfs_vn_listxattr,
9615 .removexattr = xfs_vn_removexattr,
9616 + .sync_flags = xfs_vn_sync_flags,
9618 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.22.10-vs2.2.0.5/fs/xfs/linux-2.6/xfs_linux.h
9619 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_linux.h 2007-05-02 19:25:22 +0200
9620 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/linux-2.6/xfs_linux.h 2007-06-15 02:37:04 +0200
9622 #define current_pid() (current->pid)
9623 #define current_fsuid(cred) (current->fsuid)
9624 #define current_fsgid(cred) (current->fsgid)
9625 +#define current_fstag(cred,vp) (dx_current_fstag(vn_to_inode(vp)->i_sb))
9626 #define current_test_flags(f) (current->flags & (f))
9627 #define current_set_flags_nested(sp, f) \
9628 (*(sp) = current->flags, current->flags |= (f))
9629 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_super.c linux-2.6.22.10-vs2.2.0.5/fs/xfs/linux-2.6/xfs_super.c
9630 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_super.c 2007-07-09 13:19:29 +0200
9631 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/linux-2.6/xfs_super.c 2007-06-15 02:37:04 +0200
9632 @@ -157,6 +157,7 @@ xfs_revalidate_inode(
9633 inode->i_nlink = ip->i_d.di_nlink;
9634 inode->i_uid = ip->i_d.di_uid;
9635 inode->i_gid = ip->i_d.di_gid;
9636 + inode->i_tag = ip->i_d.di_tag;
9638 switch (inode->i_mode & S_IFMT) {
9640 @@ -184,6 +185,14 @@ xfs_revalidate_inode(
9641 inode->i_flags |= S_IMMUTABLE;
9643 inode->i_flags &= ~S_IMMUTABLE;
9644 + if (ip->i_d.di_flags & XFS_DIFLAG_IUNLINK)
9645 + inode->i_flags |= S_IUNLINK;
9647 + inode->i_flags &= ~S_IUNLINK;
9648 + if (ip->i_d.di_flags & XFS_DIFLAG_BARRIER)
9649 + inode->i_flags |= S_BARRIER;
9651 + inode->i_flags &= ~S_BARRIER;
9652 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
9653 inode->i_flags |= S_APPEND;
9655 @@ -712,6 +721,12 @@ xfs_fs_remount(
9658 error = bhv_vfs_parseargs(vfsp, options, args, 1);
9659 + if ((args->flags2 & XFSMNT2_TAGGED) &&
9660 + !(sb->s_flags & MS_TAGGED)) {
9661 + printk("XFS: %s: tagging not permitted on remount.\n",
9666 error = bhv_vfs_mntupdate(vfsp, flags, args);
9667 kmem_free(args, sizeof(*args));
9668 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.c linux-2.6.22.10-vs2.2.0.5/fs/xfs/linux-2.6/xfs_vnode.c
9669 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.c 2007-05-02 19:25:22 +0200
9670 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/linux-2.6/xfs_vnode.c 2007-06-15 02:37:04 +0200
9671 @@ -119,6 +119,7 @@ vn_revalidate_core(
9672 inode->i_nlink = vap->va_nlink;
9673 inode->i_uid = vap->va_uid;
9674 inode->i_gid = vap->va_gid;
9675 + inode->i_tag = vap->va_tag;
9676 inode->i_blocks = vap->va_nblocks;
9677 inode->i_mtime = vap->va_mtime;
9678 inode->i_ctime = vap->va_ctime;
9679 @@ -126,6 +127,14 @@ vn_revalidate_core(
9680 inode->i_flags |= S_IMMUTABLE;
9682 inode->i_flags &= ~S_IMMUTABLE;
9683 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
9684 + inode->i_flags |= S_IUNLINK;
9686 + inode->i_flags &= ~S_IUNLINK;
9687 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
9688 + inode->i_flags |= S_BARRIER;
9690 + inode->i_flags &= ~S_BARRIER;
9691 if (vap->va_xflags & XFS_XFLAG_APPEND)
9692 inode->i_flags |= S_APPEND;
9694 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.h linux-2.6.22.10-vs2.2.0.5/fs/xfs/linux-2.6/xfs_vnode.h
9695 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.h 2007-07-09 13:19:29 +0200
9696 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/linux-2.6/xfs_vnode.h 2007-06-15 02:37:04 +0200
9697 @@ -350,6 +350,7 @@ typedef struct bhv_vattr {
9698 xfs_nlink_t va_nlink; /* number of references to file */
9699 uid_t va_uid; /* owner user id */
9700 gid_t va_gid; /* owner group id */
9701 + tag_t va_tag; /* owner group id */
9702 xfs_ino_t va_nodeid; /* file id */
9703 xfs_off_t va_size; /* file size in bytes */
9704 u_long va_blocksize; /* blocksize preferred for i/o */
9705 @@ -398,13 +399,15 @@ typedef struct bhv_vattr {
9706 #define XFS_AT_PROJID 0x04000000
9707 #define XFS_AT_SIZE_NOPERM 0x08000000
9708 #define XFS_AT_GENCOUNT 0x10000000
9709 +#define XFS_AT_TAG 0x20000000
9711 #define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
9712 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
9713 XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
9714 XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
9715 XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
9716 - XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
9717 + XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT\
9720 #define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
9721 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
9722 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/quota/xfs_qm_syscalls.c linux-2.6.22.10-vs2.2.0.5/fs/xfs/quota/xfs_qm_syscalls.c
9723 --- linux-2.6.22.10/fs/xfs/quota/xfs_qm_syscalls.c 2007-07-09 13:19:29 +0200
9724 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/quota/xfs_qm_syscalls.c 2007-06-15 02:37:04 +0200
9728 #include <linux/capability.h>
9729 +#include <linux/vs_context.h>
9733 @@ -211,7 +212,7 @@ xfs_qm_scall_quotaoff(
9734 xfs_qoff_logitem_t *qoffstart;
9737 - if (!force && !capable(CAP_SYS_ADMIN))
9738 + if (!force && !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9739 return XFS_ERROR(EPERM);
9741 * No file system can have quotas enabled on disk but not in core.
9742 @@ -380,7 +381,7 @@ xfs_qm_scall_trunc_qfiles(
9746 - if (!capable(CAP_SYS_ADMIN))
9747 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9748 return XFS_ERROR(EPERM);
9750 if (!XFS_SB_VERSION_HASQUOTA(&mp->m_sb) || flags == 0) {
9751 @@ -425,7 +426,7 @@ xfs_qm_scall_quotaon(
9755 - if (!capable(CAP_SYS_ADMIN))
9756 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9757 return XFS_ERROR(EPERM);
9759 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
9760 @@ -594,7 +595,7 @@ xfs_qm_scall_setqlim(
9762 xfs_qcnt_t hard, soft;
9764 - if (!capable(CAP_SYS_ADMIN))
9765 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9766 return XFS_ERROR(EPERM);
9768 if ((newlim->d_fieldmask &
9769 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_clnt.h linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_clnt.h
9770 --- linux-2.6.22.10/fs/xfs/xfs_clnt.h 2006-06-18 04:54:50 +0200
9771 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_clnt.h 2007-06-15 02:37:04 +0200
9772 @@ -99,5 +99,7 @@ struct xfs_mount_args {
9774 #define XFSMNT2_COMPAT_IOSIZE 0x00000001 /* don't report large preferred
9775 * I/O size in stat(2) */
9776 +#define XFSMNT2_TAGGED 0x80000000 /* context tagging */
9779 #endif /* __XFS_CLNT_H__ */
9780 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_dinode.h linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_dinode.h
9781 --- linux-2.6.22.10/fs/xfs/xfs_dinode.h 2006-09-20 16:58:40 +0200
9782 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_dinode.h 2007-06-15 02:37:04 +0200
9783 @@ -53,7 +53,8 @@ typedef struct xfs_dinode_core
9784 __uint32_t di_gid; /* owner's group id */
9785 __uint32_t di_nlink; /* number of links to file */
9786 __uint16_t di_projid; /* owner's project id */
9787 - __uint8_t di_pad[8]; /* unused, zeroed space */
9788 + __uint16_t di_tag; /* context tagging */
9789 + __uint8_t di_pad[6]; /* unused, zeroed space */
9790 __uint16_t di_flushiter; /* incremented on flush */
9791 xfs_timestamp_t di_atime; /* time last accessed */
9792 xfs_timestamp_t di_mtime; /* time last modified */
9793 @@ -257,6 +258,9 @@ typedef enum xfs_dinode_fmt
9794 #define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */
9795 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
9796 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
9797 +#define XFS_DIFLAG_BARRIER_BIT 14 /* chroot() barrier */
9798 +#define XFS_DIFLAG_IUNLINK_BIT 15 /* immutable unlink */
9800 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
9801 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
9802 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
9803 @@ -271,12 +275,15 @@ typedef enum xfs_dinode_fmt
9804 #define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT)
9805 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
9806 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
9807 +#define XFS_DIFLAG_BARRIER (1 << XFS_DIFLAG_BARRIER_BIT)
9808 +#define XFS_DIFLAG_IUNLINK (1 << XFS_DIFLAG_IUNLINK_BIT)
9810 #define XFS_DIFLAG_ANY \
9811 (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \
9812 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
9813 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
9814 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
9815 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG)
9816 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_BARRIER | \
9817 + XFS_DIFLAG_IUNLINK)
9819 #endif /* __XFS_DINODE_H__ */
9820 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_fs.h linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_fs.h
9821 --- linux-2.6.22.10/fs/xfs/xfs_fs.h 2006-11-30 21:19:29 +0100
9822 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_fs.h 2007-06-15 02:37:04 +0200
9823 @@ -66,6 +66,8 @@ struct fsxattr {
9824 #define XFS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */
9825 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
9826 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
9827 +#define XFS_XFLAG_BARRIER 0x00004000 /* chroot() barrier */
9828 +#define XFS_XFLAG_IUNLINK 0x00008000 /* immutable unlink */
9829 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
9832 @@ -294,7 +296,8 @@ typedef struct xfs_bstat {
9833 __s32 bs_extents; /* number of extents */
9834 __u32 bs_gen; /* generation count */
9835 __u16 bs_projid; /* project id */
9836 - unsigned char bs_pad[14]; /* pad space, unused */
9837 + __u16 bs_tag; /* context tagging */
9838 + unsigned char bs_pad[12]; /* pad space, unused */
9839 __u32 bs_dmevmask; /* DMIG event mask */
9840 __u16 bs_dmstate; /* DMIG state info */
9841 __u16 bs_aextents; /* attribute number of extents */
9842 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_inode.c linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_inode.c
9843 --- linux-2.6.22.10/fs/xfs/xfs_inode.c 2007-07-09 13:19:34 +0200
9844 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_inode.c 2007-06-15 02:37:04 +0200
9846 #include "xfs_quota.h"
9847 #include "xfs_acl.h"
9849 +#include <linux/vs_tag.h>
9851 kmem_zone_t *xfs_ifork_zone;
9852 kmem_zone_t *xfs_inode_zone;
9853 @@ -736,20 +737,35 @@ xfs_xlate_dinode_core(
9854 xfs_dinode_core_t *buf_core = (xfs_dinode_core_t *)buf;
9855 xfs_dinode_core_t *mem_core = (xfs_dinode_core_t *)dip;
9856 xfs_arch_t arch = ARCH_CONVERT;
9857 + uint32_t uid = 0, gid = 0;
9863 + tag = mem_core->di_tag;
9864 + /* FIXME: supposed to use superblock flag */
9865 + uid = TAGINO_UID(1, mem_core->di_uid, tag);
9866 + gid = TAGINO_GID(1, mem_core->di_gid, tag);
9867 + tag = TAGINO_TAG(1, tag);
9870 INT_XLATE(buf_core->di_magic, mem_core->di_magic, dir, arch);
9871 INT_XLATE(buf_core->di_mode, mem_core->di_mode, dir, arch);
9872 INT_XLATE(buf_core->di_version, mem_core->di_version, dir, arch);
9873 INT_XLATE(buf_core->di_format, mem_core->di_format, dir, arch);
9874 INT_XLATE(buf_core->di_onlink, mem_core->di_onlink, dir, arch);
9875 - INT_XLATE(buf_core->di_uid, mem_core->di_uid, dir, arch);
9876 - INT_XLATE(buf_core->di_gid, mem_core->di_gid, dir, arch);
9877 + INT_XLATE(buf_core->di_uid, uid, dir, arch);
9878 + INT_XLATE(buf_core->di_gid, gid, dir, arch);
9879 + INT_XLATE(buf_core->di_tag, tag, dir, arch);
9880 INT_XLATE(buf_core->di_nlink, mem_core->di_nlink, dir, arch);
9881 INT_XLATE(buf_core->di_projid, mem_core->di_projid, dir, arch);
9884 + /* FIXME: supposed to use superblock flag */
9885 + mem_core->di_uid = INOTAG_UID(1, uid, gid);
9886 + mem_core->di_gid = INOTAG_GID(1, uid, gid);
9887 + mem_core->di_tag = INOTAG_TAG(1, uid, gid, tag);
9888 memcpy(mem_core->di_pad, buf_core->di_pad,
9889 sizeof(buf_core->di_pad));
9891 @@ -797,6 +813,10 @@ _xfs_dic2xflags(
9892 flags |= XFS_XFLAG_PREALLOC;
9893 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9894 flags |= XFS_XFLAG_IMMUTABLE;
9895 + if (di_flags & XFS_DIFLAG_IUNLINK)
9896 + flags |= XFS_XFLAG_IUNLINK;
9897 + if (di_flags & XFS_DIFLAG_BARRIER)
9898 + flags |= XFS_XFLAG_BARRIER;
9899 if (di_flags & XFS_DIFLAG_APPEND)
9900 flags |= XFS_XFLAG_APPEND;
9901 if (di_flags & XFS_DIFLAG_SYNC)
9902 @@ -1129,6 +1149,7 @@ xfs_ialloc(
9903 ASSERT(ip->i_d.di_nlink == nlink);
9904 ip->i_d.di_uid = current_fsuid(cr);
9905 ip->i_d.di_gid = current_fsgid(cr);
9906 + ip->i_d.di_tag = current_fstag(cr, vp);
9907 ip->i_d.di_projid = prid;
9908 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
9910 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_itable.c linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_itable.c
9911 --- linux-2.6.22.10/fs/xfs/xfs_itable.c 2007-07-09 13:19:34 +0200
9912 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_itable.c 2007-06-15 02:37:04 +0200
9913 @@ -89,6 +89,7 @@ xfs_bulkstat_one_iget(
9914 buf->bs_mode = dic->di_mode;
9915 buf->bs_uid = dic->di_uid;
9916 buf->bs_gid = dic->di_gid;
9917 + buf->bs_tag = dic->di_tag;
9918 buf->bs_size = dic->di_size;
9919 vn_atime_to_bstime(vp, &buf->bs_atime);
9920 buf->bs_mtime.tv_sec = dic->di_mtime.t_sec;
9921 @@ -163,6 +164,7 @@ xfs_bulkstat_one_dinode(
9922 buf->bs_mode = INT_GET(dic->di_mode, ARCH_CONVERT);
9923 buf->bs_uid = INT_GET(dic->di_uid, ARCH_CONVERT);
9924 buf->bs_gid = INT_GET(dic->di_gid, ARCH_CONVERT);
9925 + buf->bs_tag = INT_GET(dic->di_tag, ARCH_CONVERT);
9926 buf->bs_size = INT_GET(dic->di_size, ARCH_CONVERT);
9927 buf->bs_atime.tv_sec = INT_GET(dic->di_atime.t_sec, ARCH_CONVERT);
9928 buf->bs_atime.tv_nsec = INT_GET(dic->di_atime.t_nsec, ARCH_CONVERT);
9929 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_mount.h linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_mount.h
9930 --- linux-2.6.22.10/fs/xfs/xfs_mount.h 2007-05-02 19:25:23 +0200
9931 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_mount.h 2007-06-15 02:37:04 +0200
9932 @@ -464,6 +464,7 @@ typedef struct xfs_mount {
9933 #define XFS_MOUNT_NO_PERCPU_SB (1ULL << 23) /* don't use per-cpu superblock
9936 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
9939 * Default minimum read and write sizes.
9940 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_vfsops.c linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_vfsops.c
9941 --- linux-2.6.22.10/fs/xfs/xfs_vfsops.c 2007-07-09 13:19:34 +0200
9942 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_vfsops.c 2007-06-15 02:37:04 +0200
9943 @@ -300,6 +300,8 @@ xfs_start_flags(
9945 if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
9946 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
9947 + if (ap->flags2 & XFSMNT2_TAGGED)
9948 + mp->m_flags |= XFS_MOUNT_TAGGED;
9951 * no recovery flag requires a read-only mount
9952 @@ -394,6 +396,8 @@ xfs_finish_flags(
9953 return XFS_ERROR(EINVAL);
9956 + if (ap->flags2 & XFSMNT2_TAGGED)
9957 + vfs->vfs_super->s_flags |= MS_TAGGED;
9961 @@ -1645,6 +1649,9 @@ xfs_vget(
9963 #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
9964 #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
9965 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
9966 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
9967 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
9969 STATIC unsigned long
9970 suffix_strtoul(char *s, char **endp, unsigned int base)
9971 @@ -1831,6 +1838,19 @@ xfs_parseargs(
9972 args->flags |= XFSMNT_ATTR2;
9973 } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
9974 args->flags &= ~XFSMNT_ATTR2;
9975 +#ifndef CONFIG_TAGGING_NONE
9976 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9977 + args->flags2 |= XFSMNT2_TAGGED;
9978 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
9979 + args->flags2 &= ~XFSMNT2_TAGGED;
9980 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
9981 + args->flags2 |= XFSMNT2_TAGGED;
9983 +#ifdef CONFIG_PROPAGATE
9984 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9986 + args->flags2 |= XFSMNT2_TAGGED;
9988 } else if (!strcmp(this_char, "osyncisdsync")) {
9989 /* no-op, this is now the default */
9991 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_vnodeops.c linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_vnodeops.c
9992 --- linux-2.6.22.10/fs/xfs/xfs_vnodeops.c 2007-07-09 13:19:34 +0200
9993 +++ linux-2.6.22.10-vs2.2.0.5/fs/xfs/xfs_vnodeops.c 2007-06-15 02:37:04 +0200
9994 @@ -159,6 +159,7 @@ xfs_getattr(
9995 vap->va_mode = ip->i_d.di_mode;
9996 vap->va_uid = ip->i_d.di_uid;
9997 vap->va_gid = ip->i_d.di_gid;
9998 + vap->va_tag = ip->i_d.di_tag;
9999 vap->va_projid = ip->i_d.di_projid;
10002 @@ -259,6 +260,7 @@ xfs_setattr(
10003 uint commit_flags=0;
10004 uid_t uid=0, iuid=0;
10005 gid_t gid=0, igid=0;
10006 + tag_t tag=0, itag=0;
10009 xfs_prid_t projid=0, iprojid=0;
10010 @@ -315,6 +317,7 @@ xfs_setattr(
10011 (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID))) {
10014 + /* TODO: handle tagging? */
10015 if ((mask & XFS_AT_UID) && XFS_IS_UQUOTA_ON(mp)) {
10017 qflags |= XFS_QMOPT_UQUOTA;
10018 @@ -394,6 +397,8 @@ xfs_setattr(
10020 (XFS_AT_MODE|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_UID|
10021 XFS_AT_GID|XFS_AT_PROJID)) {
10022 + /* TODO: handle tagging? */
10025 * CAP_FOWNER overrides the following restrictions:
10027 @@ -442,7 +447,7 @@ xfs_setattr(
10028 * and can change the group id only to a group of which he
10029 * or she is a member.
10031 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
10032 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
10034 * These IDs could have changed since we last looked at them.
10035 * But, we're assured that if the ownership did change
10036 @@ -450,10 +455,12 @@ xfs_setattr(
10037 * would have changed also.
10039 iuid = ip->i_d.di_uid;
10040 - iprojid = ip->i_d.di_projid;
10041 igid = ip->i_d.di_gid;
10042 - gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
10043 + itag = ip->i_d.di_tag;
10044 + iprojid = ip->i_d.di_projid;
10045 uid = (mask & XFS_AT_UID) ? vap->va_uid : iuid;
10046 + gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
10047 + tag = (mask & XFS_AT_TAG) ? vap->va_tag : itag;
10048 projid = (mask & XFS_AT_PROJID) ? (xfs_prid_t)vap->va_projid :
10051 @@ -481,6 +488,7 @@ xfs_setattr(
10052 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
10053 (XFS_IS_PQUOTA_ON(mp) && iprojid != projid) ||
10054 (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
10055 + /* TODO: handle tagging? */
10057 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
10058 capable(CAP_FOWNER) ?
10059 @@ -706,7 +714,7 @@ xfs_setattr(
10060 * and can change the group id only to a group of which he
10061 * or she is a member.
10063 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
10064 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
10066 * CAP_FSETID overrides the following restrictions:
10068 @@ -722,6 +730,9 @@ xfs_setattr(
10069 * Change the ownerships and register quota modifications
10070 * in the transaction.
10072 + if (itag != tag) {
10073 + ip->i_d.di_tag = tag;
10076 if (XFS_IS_UQUOTA_ON(mp)) {
10077 ASSERT(mask & XFS_AT_UID);
10078 @@ -802,6 +813,10 @@ xfs_setattr(
10079 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
10080 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
10081 di_flags |= XFS_DIFLAG_IMMUTABLE;
10082 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
10083 + di_flags |= XFS_DIFLAG_IUNLINK;
10084 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
10085 + di_flags |= XFS_DIFLAG_BARRIER;
10086 if (vap->va_xflags & XFS_XFLAG_APPEND)
10087 di_flags |= XFS_DIFLAG_APPEND;
10088 if (vap->va_xflags & XFS_XFLAG_SYNC)
10089 diff -NurpP --minimal linux-2.6.22.10/include/asm-arm/tlb.h linux-2.6.22.10-vs2.2.0.5/include/asm-arm/tlb.h
10090 --- linux-2.6.22.10/include/asm-arm/tlb.h 2006-06-18 04:54:58 +0200
10091 +++ linux-2.6.22.10-vs2.2.0.5/include/asm-arm/tlb.h 2007-06-15 02:37:04 +0200
10093 #else /* !CONFIG_MMU */
10095 #include <asm/pgalloc.h>
10096 +#include <linux/vs_memory.h>
10099 * TLB handling. This allows us to remove pages from the page
10100 diff -NurpP --minimal linux-2.6.22.10/include/asm-arm26/tlb.h linux-2.6.22.10-vs2.2.0.5/include/asm-arm26/tlb.h
10101 --- linux-2.6.22.10/include/asm-arm26/tlb.h 2006-01-03 17:30:02 +0100
10102 +++ linux-2.6.22.10-vs2.2.0.5/include/asm-arm26/tlb.h 2007-06-15 02:37:04 +0200
10105 #include <asm/pgalloc.h>
10106 #include <asm/tlbflush.h>
10107 +#include <linux/vs_memory.h>
10110 * TLB handling. This allows us to remove pages from the page
10111 diff -NurpP --minimal linux-2.6.22.10/include/asm-arm26/unistd.h linux-2.6.22.10-vs2.2.0.5/include/asm-arm26/unistd.h
10112 --- linux-2.6.22.10/include/asm-arm26/unistd.h 2007-02-06 03:01:35 +0100
10113 +++ linux-2.6.22.10-vs2.2.0.5/include/asm-arm26/unistd.h 2007-06-15 02:37:04 +0200
10114 @@ -302,6 +302,8 @@
10115 #define __NR_mq_getsetattr (__NR_SYSCALL_BASE+279)
10116 #define __NR_waitid (__NR_SYSCALL_BASE+280)
10118 +#define __NR_vserver (__NR_SYSCALL_BASE+313)
10121 * The following SWIs are ARM private. FIXME - make appropriate for arm26
10123 diff -NurpP --minimal linux-2.6.22.10/include/asm-generic/tlb.h linux-2.6.22.10-vs2.2.0.5/include/asm-generic/tlb.h
10124 --- linux-2.6.22.10/include/asm-generic/tlb.h 2006-11-30 21:19:31 +0100
10125 +++ linux-2.6.22.10-vs2.2.0.5/include/asm-generic/tlb.h 2007-06-15 02:37:04 +0200
10127 #define _ASM_GENERIC__TLB_H
10129 #include <linux/swap.h>
10130 +#include <linux/vs_memory.h>
10131 #include <asm/pgalloc.h>
10132 #include <asm/tlbflush.h>
10134 diff -NurpP --minimal linux-2.6.22.10/include/asm-ia64/tlb.h linux-2.6.22.10-vs2.2.0.5/include/asm-ia64/tlb.h
10135 --- linux-2.6.22.10/include/asm-ia64/tlb.h 2006-09-20 16:58:40 +0200
10136 +++ linux-2.6.22.10-vs2.2.0.5/include/asm-ia64/tlb.h 2007-06-15 02:37:04 +0200
10138 #include <linux/mm.h>
10139 #include <linux/pagemap.h>
10140 #include <linux/swap.h>
10141 +#include <linux/vs_memory.h>
10143 #include <asm/pgalloc.h>
10144 #include <asm/processor.h>
10145 diff -NurpP --minimal linux-2.6.22.10/include/asm-powerpc/systbl.h linux-2.6.22.10-vs2.2.0.5/include/asm-powerpc/systbl.h
10146 --- linux-2.6.22.10/include/asm-powerpc/systbl.h 2007-07-09 13:19:44 +0200
10147 +++ linux-2.6.22.10-vs2.2.0.5/include/asm-powerpc/systbl.h 2007-07-07 03:52:53 +0200
10148 @@ -260,7 +260,7 @@ COMPAT_SYS_SPU(fstatfs64)
10149 SYSX(sys_ni_syscall, ppc_fadvise64_64, ppc_fadvise64_64)
10151 OLDSYS(debug_setcontext)
10152 -SYSCALL(ni_syscall)
10153 +SYSX(sys_vserver, sys32_vserver, sys_vserver)
10154 COMPAT_SYS(migrate_pages)
10156 COMPAT_SYS(get_mempolicy)
10157 diff -NurpP --minimal linux-2.6.22.10/include/asm-powerpc/unistd.h linux-2.6.22.10-vs2.2.0.5/include/asm-powerpc/unistd.h
10158 --- linux-2.6.22.10/include/asm-powerpc/unistd.h 2007-07-09 13:19:45 +0200
10159 +++ linux-2.6.22.10-vs2.2.0.5/include/asm-powerpc/unistd.h 2007-07-07 03:52:53 +0200
10160 @@ -275,7 +275,7 @@
10162 #define __NR_rtas 255
10163 #define __NR_sys_debug_setcontext 256
10164 -/* Number 257 is reserved for vserver */
10165 +#define __NR_vserver 257
10166 #define __NR_migrate_pages 258
10167 #define __NR_mbind 259
10168 #define __NR_get_mempolicy 260
10169 diff -NurpP --minimal linux-2.6.22.10/include/asm-s390/unistd.h linux-2.6.22.10-vs2.2.0.5/include/asm-s390/unistd.h
10170 --- linux-2.6.22.10/include/asm-s390/unistd.h 2007-07-09 13:19:45 +0200
10171 +++ linux-2.6.22.10-vs2.2.0.5/include/asm-s390/unistd.h 2007-06-15 02:37:04 +0200
10172 @@ -202,7 +202,7 @@
10173 #define __NR_clock_gettime (__NR_timer_create+6)
10174 #define __NR_clock_getres (__NR_timer_create+7)
10175 #define __NR_clock_nanosleep (__NR_timer_create+8)
10176 -/* Number 263 is reserved for vserver */
10177 +#define __NR_vserver 263
10178 #define __NR_statfs64 265
10179 #define __NR_fstatfs64 266
10180 #define __NR_remap_file_pages 267
10181 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc/unistd.h linux-2.6.22.10-vs2.2.0.5/include/asm-sparc/unistd.h
10182 --- linux-2.6.22.10/include/asm-sparc/unistd.h 2007-07-09 13:19:54 +0200
10183 +++ linux-2.6.22.10-vs2.2.0.5/include/asm-sparc/unistd.h 2007-06-15 02:37:04 +0200
10184 @@ -283,7 +283,7 @@
10185 #define __NR_timer_getoverrun 264
10186 #define __NR_timer_delete 265
10187 #define __NR_timer_create 266
10188 -/* #define __NR_vserver 267 Reserved for VSERVER */
10189 +#define __NR_vserver 267
10190 #define __NR_io_setup 268
10191 #define __NR_io_destroy 269
10192 #define __NR_io_submit 270
10193 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc64/tlb.h linux-2.6.22.10-vs2.2.0.5/include/asm-sparc64/tlb.h
10194 --- linux-2.6.22.10/include/asm-sparc64/tlb.h 2007-07-09 13:19:54 +0200
10195 +++ linux-2.6.22.10-vs2.2.0.5/include/asm-sparc64/tlb.h 2007-07-07 03:54:19 +0200
10198 #include <linux/swap.h>
10199 #include <linux/pagemap.h>
10200 +#include <linux/vs_memory.h>
10201 #include <asm/pgalloc.h>
10202 #include <asm/tlbflush.h>
10203 #include <asm/mmu_context.h>
10204 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc64/unistd.h linux-2.6.22.10-vs2.2.0.5/include/asm-sparc64/unistd.h
10205 --- linux-2.6.22.10/include/asm-sparc64/unistd.h 2007-07-09 13:19:54 +0200
10206 +++ linux-2.6.22.10-vs2.2.0.5/include/asm-sparc64/unistd.h 2007-06-15 02:37:04 +0200
10207 @@ -285,7 +285,7 @@
10208 #define __NR_timer_getoverrun 264
10209 #define __NR_timer_delete 265
10210 #define __NR_timer_create 266
10211 -/* #define __NR_vserver 267 Reserved for VSERVER */
10212 +#define __NR_vserver 267
10213 #define __NR_io_setup 268
10214 #define __NR_io_destroy 269
10215 #define __NR_io_submit 270
10216 diff -NurpP --minimal linux-2.6.22.10/include/asm-x86_64/unistd.h linux-2.6.22.10-vs2.2.0.5/include/asm-x86_64/unistd.h
10217 --- linux-2.6.22.10/include/asm-x86_64/unistd.h 2007-07-09 13:19:55 +0200
10218 +++ linux-2.6.22.10-vs2.2.0.5/include/asm-x86_64/unistd.h 2007-07-07 03:52:53 +0200
10219 @@ -532,7 +532,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
10220 #define __NR_utimes 235
10221 __SYSCALL(__NR_utimes, sys_utimes)
10222 #define __NR_vserver 236
10223 -__SYSCALL(__NR_vserver, sys_ni_syscall)
10224 +__SYSCALL(__NR_vserver, sys_vserver)
10225 #define __NR_mbind 237
10226 __SYSCALL(__NR_mbind, sys_mbind)
10227 #define __NR_set_mempolicy 238
10228 diff -NurpP --minimal linux-2.6.22.10/include/linux/Kbuild linux-2.6.22.10-vs2.2.0.5/include/linux/Kbuild
10229 --- linux-2.6.22.10/include/linux/Kbuild 2007-10-30 01:57:14 +0100
10230 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/Kbuild 2007-10-01 15:25:35 +0200
10231 @@ -351,3 +351,6 @@ unifdef-y += xattr.h
10232 unifdef-y += xfrm.h
10234 objhdr-y += version.h
10236 +header-y += vserver/
10238 diff -NurpP --minimal linux-2.6.22.10/include/linux/capability.h linux-2.6.22.10-vs2.2.0.5/include/linux/capability.h
10239 --- linux-2.6.22.10/include/linux/capability.h 2007-07-09 13:19:55 +0200
10240 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/capability.h 2007-06-15 02:37:04 +0200
10241 @@ -237,6 +237,7 @@ typedef __u32 kernel_cap_t;
10242 arbitrary SCSI commands */
10243 /* Allow setting encryption key on loopback filesystem */
10244 /* Allow setting zone reclaim policy */
10245 +/* Allow the selection of a security context */
10247 #define CAP_SYS_ADMIN 21
10249 @@ -290,6 +291,11 @@ typedef __u32 kernel_cap_t;
10251 #define CAP_AUDIT_CONTROL 30
10253 +/* Allow context manipulations */
10254 +/* Allow changing context info on files */
10256 +#define CAP_CONTEXT 31
10261 diff -NurpP --minimal linux-2.6.22.10/include/linux/devpts_fs.h linux-2.6.22.10-vs2.2.0.5/include/linux/devpts_fs.h
10262 --- linux-2.6.22.10/include/linux/devpts_fs.h 2004-08-14 12:55:59 +0200
10263 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/devpts_fs.h 2007-06-15 02:37:04 +0200
10264 @@ -30,5 +30,7 @@ static inline void devpts_pty_kill(int n
10268 +#define DEVPTS_SUPER_MAGIC 0x00001cd1
10271 #endif /* _LINUX_DEVPTS_FS_H */
10272 diff -NurpP --minimal linux-2.6.22.10/include/linux/ext2_fs.h linux-2.6.22.10-vs2.2.0.5/include/linux/ext2_fs.h
10273 --- linux-2.6.22.10/include/linux/ext2_fs.h 2006-11-30 21:19:37 +0100
10274 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/ext2_fs.h 2007-06-15 02:37:04 +0200
10275 @@ -188,6 +188,8 @@ struct ext2_group_desc
10276 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
10277 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
10278 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
10279 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
10280 +#define EXT2_IUNLINK_FL FS_IUNLINK_FL /* Immutable unlink */
10281 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
10283 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
10284 @@ -244,7 +246,7 @@ struct ext2_inode {
10286 __u8 l_i_frag; /* Fragment number */
10287 __u8 l_i_fsize; /* Fragment size */
10289 + __u16 l_i_tag; /* Context Tag */
10290 __le16 l_i_uid_high; /* these 2 fields */
10291 __le16 l_i_gid_high; /* were reserved2[0] */
10292 __u32 l_i_reserved2;
10293 @@ -276,6 +278,7 @@ struct ext2_inode {
10294 #define i_gid_low i_gid
10295 #define i_uid_high osd2.linux2.l_i_uid_high
10296 #define i_gid_high osd2.linux2.l_i_gid_high
10297 +#define i_raw_tag osd2.linux2.l_i_tag
10298 #define i_reserved2 osd2.linux2.l_i_reserved2
10301 @@ -317,8 +320,9 @@ struct ext2_inode {
10302 #define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */
10303 #define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */
10304 #define EXT2_MOUNT_XIP 0x010000 /* Execute in place */
10305 -#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
10306 -#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
10307 +#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
10308 +#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
10309 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
10312 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
10313 diff -NurpP --minimal linux-2.6.22.10/include/linux/ext3_fs.h linux-2.6.22.10-vs2.2.0.5/include/linux/ext3_fs.h
10314 --- linux-2.6.22.10/include/linux/ext3_fs.h 2007-07-09 13:19:56 +0200
10315 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/ext3_fs.h 2007-06-15 02:37:04 +0200
10316 @@ -177,10 +177,20 @@ struct ext3_group_desc
10317 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
10318 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
10319 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
10320 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
10321 +#define EXT3_IUNLINK_FL 0x08000000 /* Immutable unlink */
10322 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
10324 +#ifdef CONFIG_VSERVER_LEGACY
10325 +#define EXT3_FL_USER_VISIBLE 0x0803DFFF /* User visible flags */
10326 +#define EXT3_FL_USER_MODIFIABLE 0x080380FF /* User modifiable flags */
10328 #define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
10329 #define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
10331 +#ifdef CONFIG_VSERVER_LEGACY
10332 +#define EXT3_IOC_SETTAG FIOC_SETTAGJ
10336 * Inode dynamic state flags
10337 @@ -296,7 +306,7 @@ struct ext3_inode {
10339 __u8 l_i_frag; /* Fragment number */
10340 __u8 l_i_fsize; /* Fragment size */
10342 + __u16 l_i_tag; /* Context Tag */
10343 __le16 l_i_uid_high; /* these 2 fields */
10344 __le16 l_i_gid_high; /* were reserved2[0] */
10345 __u32 l_i_reserved2;
10346 @@ -330,6 +340,7 @@ struct ext3_inode {
10347 #define i_gid_low i_gid
10348 #define i_uid_high osd2.linux2.l_i_uid_high
10349 #define i_gid_high osd2.linux2.l_i_gid_high
10350 +#define i_raw_tag osd2.linux2.l_i_tag
10351 #define i_reserved2 osd2.linux2.l_i_reserved2
10353 #elif defined(__GNU__)
10354 @@ -384,6 +395,7 @@ struct ext3_inode {
10355 #define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
10356 #define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
10357 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
10358 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
10360 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
10361 #ifndef _LINUX_EXT2_FS_H
10362 @@ -812,6 +824,7 @@ struct buffer_head * ext3_bread (handle_
10363 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
10364 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
10365 int create, int extend_disksize);
10366 +extern int ext3_sync_flags(struct inode *inode);
10368 extern void ext3_read_inode (struct inode *);
10369 extern int ext3_write_inode (struct inode *, int);
10370 diff -NurpP --minimal linux-2.6.22.10/include/linux/ext4_fs.h linux-2.6.22.10-vs2.2.0.5/include/linux/ext4_fs.h
10371 --- linux-2.6.22.10/include/linux/ext4_fs.h 2007-07-09 13:19:56 +0200
10372 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/ext4_fs.h 2007-06-15 02:37:04 +0200
10373 @@ -189,11 +189,21 @@ struct ext4_group_desc
10374 #define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
10375 #define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
10376 #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
10377 -#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
10378 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
10379 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
10380 +#define EXT4_IUNLINK_FL 0x08000000 /* Immutable unlink */
10381 +#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
10383 +#ifdef CONFIG_VSERVER_LEGACY
10384 +#define EXT4_FL_USER_VISIBLE 0x080BDFFF /* User visible flags */
10385 +#define EXT4_FL_USER_MODIFIABLE 0x080380FF /* User modifiable flags */
10387 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
10388 #define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
10390 +#ifdef CONFIG_VSERVER_LEGACY
10391 +#define EXT4_IOC_SETTAG FIOC_SETTAGJ
10395 * Inode dynamic state flags
10396 @@ -312,7 +322,8 @@ struct ext4_inode {
10397 __le16 l_i_file_acl_high;
10398 __le16 l_i_uid_high; /* these 2 fields */
10399 __le16 l_i_gid_high; /* were reserved2[0] */
10400 - __u32 l_i_reserved2;
10401 + __u16 l_i_tag; /* Context Tag */
10402 + __u16 l_i_reserved2;
10405 __u8 h_i_frag; /* Fragment number */
10406 @@ -344,6 +355,7 @@ struct ext4_inode {
10407 #define i_gid_low i_gid
10408 #define i_uid_high osd2.linux2.l_i_uid_high
10409 #define i_gid_high osd2.linux2.l_i_gid_high
10410 +#define i_raw_tag osd2.linux2.l_i_tag
10411 #define i_reserved2 osd2.linux2.l_i_reserved2
10413 #elif defined(__GNU__)
10414 @@ -400,6 +412,7 @@ struct ext4_inode {
10415 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
10416 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
10417 #define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
10418 +#define EXT4_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
10420 /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
10421 #ifndef _LINUX_EXT2_FS_H
10422 @@ -850,6 +863,7 @@ struct buffer_head * ext4_bread (handle_
10423 int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
10424 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
10425 int create, int extend_disksize);
10426 +extern int ext4_sync_flags(struct inode *inode);
10428 extern void ext4_read_inode (struct inode *);
10429 extern int ext4_write_inode (struct inode *, int);
10430 diff -NurpP --minimal linux-2.6.22.10/include/linux/fs.h linux-2.6.22.10-vs2.2.0.5/include/linux/fs.h
10431 --- linux-2.6.22.10/include/linux/fs.h 2007-07-09 13:19:56 +0200
10432 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/fs.h 2007-10-29 23:24:21 +0100
10433 @@ -123,6 +123,8 @@ extern int dir_notify_enable;
10434 #define MS_SLAVE (1<<19) /* change to slave */
10435 #define MS_SHARED (1<<20) /* change to shared */
10436 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
10437 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
10438 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
10439 #define MS_ACTIVE (1<<30)
10440 #define MS_NOUSER (1<<31)
10442 @@ -149,6 +151,8 @@ extern int dir_notify_enable;
10443 #define S_NOCMTIME 128 /* Do not update file c/mtime */
10444 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
10445 #define S_PRIVATE 512 /* Inode is fs-internal */
10446 +#define S_BARRIER 1024 /* Barrier for chroot() */
10447 +#define S_IUNLINK 2048 /* Immutable unlink */
10450 * Note that nosuid etc flags are inode-specific: setting some file-system
10451 @@ -165,24 +169,36 @@ extern int dir_notify_enable;
10453 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
10455 -#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
10456 +#define IS_RDONLY(inode) __IS_FLG(inode, MS_RDONLY)
10457 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
10458 ((inode)->i_flags & S_SYNC))
10459 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
10460 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
10461 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
10462 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10463 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10464 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
10466 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
10467 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
10468 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
10469 +#define IS_IUNLINK(inode) ((inode)->i_flags & S_IUNLINK)
10470 +#define IS_IXORUNLINK(inode) ((IS_IUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
10471 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
10473 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_flags & S_BARRIER))
10474 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
10475 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
10476 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
10477 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
10479 +#ifdef CONFIG_VSERVER_COWBL
10480 +# define IS_COW(inode) (IS_IUNLINK(inode) && IS_IMMUTABLE(inode))
10481 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
10483 +# define IS_COW(inode) (0)
10484 +# define IS_COW_LINK(inode) (0)
10487 /* the read-only stuff doesn't really belong here, but any other place is
10488 probably as bad and I don't want to create yet another include file. */
10490 @@ -256,11 +272,17 @@ extern int dir_notify_enable;
10491 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
10492 #define FS_EXTENT_FL 0x00080000 /* Extents */
10493 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
10494 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
10495 +#define FS_IUNLINK_FL 0x08000000 /* Immutable unlink */
10496 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
10498 +#ifdef CONFIG_VSERVER_LEGACY
10499 +#define FS_FL_USER_VISIBLE 0x0803DFFF /* User visible flags */
10500 +#define FS_FL_USER_MODIFIABLE 0x080380FF /* User modifiable flags */
10502 #define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
10503 #define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
10507 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
10508 #define SYNC_FILE_RANGE_WRITE 2
10509 @@ -327,6 +349,7 @@ typedef void (dio_iodone_t)(struct kiocb
10510 #define ATTR_KILL_SUID 2048
10511 #define ATTR_KILL_SGID 4096
10512 #define ATTR_FILE 8192
10513 +#define ATTR_TAG 16384
10516 * This is the Inode Attributes structure, used for notify_change(). It
10517 @@ -342,6 +365,7 @@ struct iattr {
10523 struct timespec ia_atime;
10524 struct timespec ia_mtime;
10525 @@ -355,6 +379,9 @@ struct iattr {
10526 struct file *ia_file;
10529 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
10530 +#define ATTR_FLAG_IUNLINK 1024 /* Immutable unlink */
10533 * Includes for diskquotas.
10535 @@ -537,6 +564,7 @@ struct inode {
10536 unsigned int i_nlink;
10541 unsigned long i_version;
10543 @@ -728,6 +756,7 @@ struct file {
10545 struct fown_struct f_owner;
10546 unsigned int f_uid, f_gid;
10548 struct file_ra_state f_ra;
10550 unsigned long f_version;
10551 @@ -811,6 +840,7 @@ struct file_lock {
10552 unsigned char fl_type;
10557 struct fasync_struct * fl_fasync; /* for lease break notifications */
10558 unsigned long fl_break_time; /* for nonblocking lease breaks */
10559 @@ -993,12 +1023,12 @@ extern void unlock_super(struct super_bl
10561 extern int vfs_permission(struct nameidata *, int);
10562 extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
10563 -extern int vfs_mkdir(struct inode *, struct dentry *, int);
10564 -extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
10565 -extern int vfs_symlink(struct inode *, struct dentry *, const char *, int);
10566 -extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
10567 -extern int vfs_rmdir(struct inode *, struct dentry *);
10568 -extern int vfs_unlink(struct inode *, struct dentry *);
10569 +extern int vfs_mkdir(struct inode *, struct dentry *, int, struct nameidata *);
10570 +extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t, struct nameidata *);
10571 +extern int vfs_symlink(struct inode *, struct dentry *, const char *, int, struct nameidata *);
10572 +extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct nameidata *);
10573 +extern int vfs_rmdir(struct inode *, struct dentry *, struct nameidata *);
10574 +extern int vfs_unlink(struct inode *, struct dentry *, struct nameidata *);
10575 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
10578 @@ -1138,6 +1168,7 @@ struct inode_operations {
10579 ssize_t (*listxattr) (struct dentry *, char *, size_t);
10580 int (*removexattr) (struct dentry *, const char *);
10581 void (*truncate_range)(struct inode *, loff_t, loff_t);
10582 + int (*sync_flags) (struct inode *);
10586 @@ -1153,6 +1184,7 @@ extern ssize_t vfs_readv(struct file *,
10587 unsigned long, loff_t *);
10588 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
10589 unsigned long, loff_t *);
10590 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
10593 * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
10594 @@ -1898,6 +1930,7 @@ extern int dcache_dir_open(struct inode
10595 extern int dcache_dir_close(struct inode *, struct file *);
10596 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
10597 extern int dcache_readdir(struct file *, void *, filldir_t);
10598 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
10599 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
10600 extern int simple_statfs(struct dentry *, struct kstatfs *);
10601 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
10602 diff -NurpP --minimal linux-2.6.22.10/include/linux/init_task.h linux-2.6.22.10-vs2.2.0.5/include/linux/init_task.h
10603 --- linux-2.6.22.10/include/linux/init_task.h 2007-07-09 13:19:56 +0200
10604 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/init_task.h 2007-06-15 02:37:04 +0200
10605 @@ -169,6 +169,10 @@ extern struct group_info init_groups;
10607 INIT_TRACE_IRQFLAGS \
10610 + .vx_info = NULL, \
10612 + .nx_info = NULL, \
10616 diff -NurpP --minimal linux-2.6.22.10/include/linux/ipc.h linux-2.6.22.10-vs2.2.0.5/include/linux/ipc.h
10617 --- linux-2.6.22.10/include/linux/ipc.h 2007-07-09 13:19:56 +0200
10618 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/ipc.h 2007-06-15 02:37:04 +0200
10619 @@ -63,6 +63,7 @@ struct kern_ipc_perm
10627 diff -NurpP --minimal linux-2.6.22.10/include/linux/loop.h linux-2.6.22.10-vs2.2.0.5/include/linux/loop.h
10628 --- linux-2.6.22.10/include/linux/loop.h 2007-07-09 13:19:56 +0200
10629 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/loop.h 2007-06-15 02:37:04 +0200
10630 @@ -45,6 +45,7 @@ struct loop_device {
10631 struct loop_func_table *lo_encryption;
10633 uid_t lo_key_owner; /* Who set the key */
10635 int (*ioctl)(struct loop_device *, int cmd,
10636 unsigned long arg);
10638 diff -NurpP --minimal linux-2.6.22.10/include/linux/major.h linux-2.6.22.10-vs2.2.0.5/include/linux/major.h
10639 --- linux-2.6.22.10/include/linux/major.h 2007-07-09 13:19:56 +0200
10640 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/major.h 2007-06-15 02:37:04 +0200
10642 #define HD_MAJOR IDE0_MAJOR
10643 #define PTY_SLAVE_MAJOR 3
10644 #define TTY_MAJOR 4
10645 +#define VROOT_MAJOR 4
10646 #define TTYAUX_MAJOR 5
10648 #define VCS_MAJOR 7
10649 diff -NurpP --minimal linux-2.6.22.10/include/linux/mount.h linux-2.6.22.10-vs2.2.0.5/include/linux/mount.h
10650 --- linux-2.6.22.10/include/linux/mount.h 2007-07-09 13:19:56 +0200
10651 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/mount.h 2007-06-15 03:54:15 +0200
10652 @@ -28,12 +28,16 @@ struct mnt_namespace;
10653 #define MNT_NOATIME 0x08
10654 #define MNT_NODIRATIME 0x10
10655 #define MNT_RELATIME 0x20
10656 +#define MNT_RDONLY 0x40
10658 +#define MNT_IS_RDONLY(m) ((m) && ((m)->mnt_flags & MNT_RDONLY))
10660 #define MNT_SHRINKABLE 0x100
10662 #define MNT_SHARED 0x1000 /* if the vfsmount is a shared mount */
10663 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
10664 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
10665 +#define MNT_TAGID 0x8000
10668 struct list_head mnt_hash;
10669 @@ -61,6 +65,7 @@ struct vfsmount {
10670 atomic_t mnt_count;
10671 int mnt_expiry_mark; /* true if marked for expiry */
10673 + tag_t mnt_tag; /* tagging used for vfsmount */
10676 static inline struct vfsmount *mntget(struct vfsmount *mnt)
10677 diff -NurpP --minimal linux-2.6.22.10/include/linux/net.h linux-2.6.22.10-vs2.2.0.5/include/linux/net.h
10678 --- linux-2.6.22.10/include/linux/net.h 2007-07-09 13:19:56 +0200
10679 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/net.h 2007-06-15 02:37:04 +0200
10680 @@ -63,6 +63,7 @@ typedef enum {
10681 #define SOCK_NOSPACE 2
10682 #define SOCK_PASSCRED 3
10683 #define SOCK_PASSSEC 4
10684 +#define SOCK_USER_SOCKET 5
10686 #ifndef ARCH_HAS_SOCKET_TYPES
10688 diff -NurpP --minimal linux-2.6.22.10/include/linux/nfs_mount.h linux-2.6.22.10-vs2.2.0.5/include/linux/nfs_mount.h
10689 --- linux-2.6.22.10/include/linux/nfs_mount.h 2007-07-09 13:20:00 +0200
10690 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/nfs_mount.h 2007-06-15 03:54:39 +0200
10692 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
10693 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
10694 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
10695 +#define NFS_MOUNT_TAGGED 0x8000 /* context tagging */
10696 #define NFS_MOUNT_FLAGMASK 0xFFFF
10699 diff -NurpP --minimal linux-2.6.22.10/include/linux/nsproxy.h linux-2.6.22.10-vs2.2.0.5/include/linux/nsproxy.h
10700 --- linux-2.6.22.10/include/linux/nsproxy.h 2007-07-09 13:20:00 +0200
10701 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/nsproxy.h 2007-07-17 03:02:15 +0200
10704 #include <linux/spinlock.h>
10705 #include <linux/sched.h>
10706 +#include <linux/vserver/debug.h>
10708 struct mnt_namespace;
10709 struct uts_namespace;
10710 @@ -32,26 +33,46 @@ struct nsproxy {
10711 extern struct nsproxy init_nsproxy;
10713 int copy_namespaces(int flags, struct task_struct *tsk);
10714 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
10715 void get_task_namespaces(struct task_struct *tsk);
10716 void free_nsproxy(struct nsproxy *ns);
10717 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
10718 struct fs_struct *);
10720 -static inline void put_nsproxy(struct nsproxy *ns)
10721 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
10723 +static inline void __get_nsproxy(struct nsproxy *ns,
10724 + const char *_file, int _line)
10726 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
10727 + ns, atomic_read(&ns->count), _file, _line);
10728 + atomic_inc(&ns->count);
10731 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
10733 +static inline void __put_nsproxy(struct nsproxy *ns,
10734 + const char *_file, int _line)
10736 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
10737 + ns, atomic_read(&ns->count), _file, _line);
10738 if (atomic_dec_and_test(&ns->count)) {
10743 -static inline void exit_task_namespaces(struct task_struct *p)
10744 +#define exit_task_namespaces(p) __exit_task_namespaces(p, __FILE__, __LINE__)
10746 +static inline void __exit_task_namespaces(struct task_struct *p,
10747 + const char *_file, int _line)
10749 struct nsproxy *ns = p->nsproxy;
10755 + __put_nsproxy(ns, _file, _line);
10760 diff -NurpP --minimal linux-2.6.22.10/include/linux/pid.h linux-2.6.22.10-vs2.2.0.5/include/linux/pid.h
10761 --- linux-2.6.22.10/include/linux/pid.h 2007-07-09 13:20:00 +0200
10762 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/pid.h 2007-06-15 02:37:04 +0200
10763 @@ -8,7 +8,8 @@ enum pid_type
10773 diff -NurpP --minimal linux-2.6.22.10/include/linux/proc_fs.h linux-2.6.22.10-vs2.2.0.5/include/linux/proc_fs.h
10774 --- linux-2.6.22.10/include/linux/proc_fs.h 2007-07-09 13:20:00 +0200
10775 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/proc_fs.h 2007-06-15 02:37:04 +0200
10776 @@ -54,6 +54,7 @@ struct proc_dir_entry {
10782 const struct inode_operations *proc_iops;
10783 const struct file_operations *proc_fops;
10784 @@ -246,13 +247,20 @@ static inline void kclist_add(struct kco
10785 extern void kclist_add(struct kcore_list *, void *, size_t);
10792 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
10793 int (*proc_read)(struct task_struct *task, char *page);
10794 + int (*proc_vs_read)(char *page);
10795 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
10796 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
10799 struct proc_inode {
10804 struct proc_dir_entry *pde;
10805 diff -NurpP --minimal linux-2.6.22.10/include/linux/reiserfs_fs.h linux-2.6.22.10-vs2.2.0.5/include/linux/reiserfs_fs.h
10806 --- linux-2.6.22.10/include/linux/reiserfs_fs.h 2007-05-02 19:25:34 +0200
10807 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/reiserfs_fs.h 2007-06-15 02:37:04 +0200
10808 @@ -821,6 +821,10 @@ struct stat_data_v1 {
10809 #define REISERFS_COMPR_FL FS_COMPR_FL
10810 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
10812 +/* unfortunately reiserfs sdattr is only 16 bit */
10813 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
10814 +#define REISERFS_IUNLINK_FL (FS_IUNLINK_FL >> 16)
10816 /* persistent flags that file inherits from the parent directory */
10817 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
10818 REISERFS_SYNC_FL | \
10819 @@ -830,6 +834,14 @@ struct stat_data_v1 {
10820 REISERFS_COMPR_FL | \
10821 REISERFS_NOTAIL_FL )
10823 +#ifdef CONFIG_VSERVER_LEGACY
10824 +#define REISERFS_FL_USER_VISIBLE (REISERFS_IUNLINK_FL|0x80FF)
10825 +#define REISERFS_FL_USER_MODIFIABLE (REISERFS_IUNLINK_FL|0x80FF)
10827 +#define REISERFS_FL_USER_VISIBLE 0x80FF
10828 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
10831 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
10834 @@ -1901,6 +1913,7 @@ static inline void reiserfs_update_sd(st
10835 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
10836 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
10837 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
10838 +int reiserfs_sync_flags(struct inode *inode);
10841 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
10842 diff -NurpP --minimal linux-2.6.22.10/include/linux/reiserfs_fs_sb.h linux-2.6.22.10-vs2.2.0.5/include/linux/reiserfs_fs_sb.h
10843 --- linux-2.6.22.10/include/linux/reiserfs_fs_sb.h 2007-07-09 13:20:00 +0200
10844 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/reiserfs_fs_sb.h 2007-06-15 02:37:04 +0200
10845 @@ -458,6 +458,7 @@ enum reiserfs_mount_options {
10847 REISERFS_BARRIER_NONE,
10848 REISERFS_BARRIER_FLUSH,
10851 /* Actions on error */
10852 REISERFS_ERROR_PANIC,
10853 diff -NurpP --minimal linux-2.6.22.10/include/linux/sched.h linux-2.6.22.10-vs2.2.0.5/include/linux/sched.h
10854 --- linux-2.6.22.10/include/linux/sched.h 2007-07-09 13:20:01 +0200
10855 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/sched.h 2007-06-17 05:54:19 +0200
10857 #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
10858 #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
10859 #define CLONE_NEWIPC 0x08000000 /* New ipcs */
10860 +#define CLONE_KTHREAD 0x10000000 /* clone a kernel thread */
10863 * Scheduling policies
10864 @@ -94,7 +95,7 @@ struct bio;
10865 * List of flags we want to share for kernel threads,
10866 * if only because they are not used by them anyway.
10868 -#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
10869 +#define CLONE_KERNEL (CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_KTHREAD)
10872 * These are the constant used to fake the fixed-point load-average
10873 @@ -146,12 +147,13 @@ extern unsigned long weighted_cpuload(co
10874 #define TASK_UNINTERRUPTIBLE 2
10875 #define TASK_STOPPED 4
10876 #define TASK_TRACED 8
10877 +#define TASK_ONHOLD 16
10878 /* in tsk->exit_state */
10879 -#define EXIT_ZOMBIE 16
10880 -#define EXIT_DEAD 32
10881 +#define EXIT_ZOMBIE 32
10882 +#define EXIT_DEAD 64
10883 /* in tsk->state again */
10884 -#define TASK_NONINTERACTIVE 64
10885 -#define TASK_DEAD 128
10886 +#define TASK_NONINTERACTIVE 128
10887 +#define TASK_DEAD 256
10889 #define __set_task_state(tsk, state_value) \
10890 do { (tsk)->state = (state_value); } while (0)
10891 @@ -287,27 +289,30 @@ extern void arch_unmap_area_topdown(stru
10892 * The mm counters are not protected by its page_table_lock,
10893 * so must be incremented atomically.
10895 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
10896 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
10897 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
10898 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
10899 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
10900 typedef atomic_long_t mm_counter_t;
10901 +#define __set_mm_counter(mm, member, value) \
10902 + atomic_long_set(&(mm)->_##member, value)
10903 +#define get_mm_counter(mm, member) \
10904 + ((unsigned long)atomic_long_read(&(mm)->_##member))
10906 #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
10908 * The mm counters are protected by its page_table_lock,
10909 * so can be incremented directly.
10911 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
10912 -#define get_mm_counter(mm, member) ((mm)->_##member)
10913 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
10914 -#define inc_mm_counter(mm, member) (mm)->_##member++
10915 -#define dec_mm_counter(mm, member) (mm)->_##member--
10916 typedef unsigned long mm_counter_t;
10917 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
10918 +#define get_mm_counter(mm, member) ((mm)->_##member)
10920 #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
10922 +#define set_mm_counter(mm, member, value) \
10923 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
10924 +#define add_mm_counter(mm, member, value) \
10925 + vx_ ## member ## pages_add((mm), (value))
10926 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
10927 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
10929 #define get_mm_rss(mm) \
10930 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
10931 #define update_hiwater_rss(mm) do { \
10932 @@ -365,6 +370,7 @@ struct mm_struct {
10934 /* Architecture-specific MM context */
10935 mm_context_t context;
10936 + struct vx_info *mm_vx_info;
10938 /* Swap token stuff */
10940 @@ -570,9 +576,10 @@ struct user_struct {
10941 /* Hash table maintenance information */
10942 struct list_head uidhash_list;
10947 -extern struct user_struct *find_user(uid_t);
10948 +extern struct user_struct *find_user(xid_t, uid_t);
10950 extern struct user_struct root_user;
10951 #define INIT_USER (&root_user)
10952 @@ -969,6 +976,14 @@ struct task_struct {
10955 struct audit_context *audit_context;
10957 +/* vserver context data */
10958 + struct vx_info *vx_info;
10959 + struct nx_info *nx_info;
10966 /* Thread group tracking */
10967 @@ -1290,12 +1305,16 @@ extern struct task_struct init_task;
10969 extern struct mm_struct init_mm;
10971 -#define find_task_by_pid(nr) find_task_by_pid_type(PIDTYPE_PID, nr)
10972 +#define find_task_by_real_pid(nr) \
10973 + find_task_by_pid_type(PIDTYPE_REALPID, nr)
10974 +#define find_task_by_pid(nr) \
10975 + find_task_by_pid_type(PIDTYPE_PID, nr)
10977 extern struct task_struct *find_task_by_pid_type(int type, int pid);
10978 extern void __set_special_pids(pid_t session, pid_t pgrp);
10980 /* per-UID process charging. */
10981 -extern struct user_struct * alloc_uid(uid_t);
10982 +extern struct user_struct * alloc_uid(xid_t, uid_t);
10983 static inline struct user_struct *get_uid(struct user_struct *u)
10985 atomic_inc(&u->__count);
10986 diff -NurpP --minimal linux-2.6.22.10/include/linux/shmem_fs.h linux-2.6.22.10-vs2.2.0.5/include/linux/shmem_fs.h
10987 --- linux-2.6.22.10/include/linux/shmem_fs.h 2006-11-30 21:19:39 +0100
10988 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/shmem_fs.h 2007-06-15 02:37:04 +0200
10991 #define SHMEM_NR_DIRECT 16
10993 +#define TMPFS_SUPER_MAGIC 0x01021994
10996 struct shmem_inode_info {
10998 unsigned long flags;
10999 diff -NurpP --minimal linux-2.6.22.10/include/linux/stat.h linux-2.6.22.10-vs2.2.0.5/include/linux/stat.h
11000 --- linux-2.6.22.10/include/linux/stat.h 2007-07-09 13:20:01 +0200
11001 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/stat.h 2007-06-15 02:37:04 +0200
11002 @@ -66,6 +66,7 @@ struct kstat {
11003 unsigned int nlink;
11009 struct timespec atime;
11010 diff -NurpP --minimal linux-2.6.22.10/include/linux/sunrpc/auth.h linux-2.6.22.10-vs2.2.0.5/include/linux/sunrpc/auth.h
11011 --- linux-2.6.22.10/include/linux/sunrpc/auth.h 2006-11-30 21:19:40 +0100
11012 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/sunrpc/auth.h 2007-06-15 02:37:04 +0200
11018 struct group_info *group_info;
11021 diff -NurpP --minimal linux-2.6.22.10/include/linux/sunrpc/clnt.h linux-2.6.22.10-vs2.2.0.5/include/linux/sunrpc/clnt.h
11022 --- linux-2.6.22.10/include/linux/sunrpc/clnt.h 2007-07-09 13:20:01 +0200
11023 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/sunrpc/clnt.h 2007-06-15 02:37:04 +0200
11025 unsigned int cl_softrtry : 1,/* soft timeouts */
11026 cl_intr : 1,/* interruptible */
11027 cl_discrtry : 1,/* disconnect before retry */
11028 - cl_autobind : 1;/* use getport() */
11029 + cl_autobind : 1,/* use getport() */
11030 + cl_tag : 1;/* context tagging */
11032 struct rpc_rtt * cl_rtt; /* RTO estimator data */
11035 diff -NurpP --minimal linux-2.6.22.10/include/linux/syscalls.h linux-2.6.22.10-vs2.2.0.5/include/linux/syscalls.h
11036 --- linux-2.6.22.10/include/linux/syscalls.h 2007-07-09 13:20:01 +0200
11037 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/syscalls.h 2007-07-07 03:52:54 +0200
11038 @@ -294,6 +294,8 @@ asmlinkage long sys_symlink(const char _
11039 asmlinkage long sys_unlink(const char __user *pathname);
11040 asmlinkage long sys_rename(const char __user *oldname,
11041 const char __user *newname);
11042 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
11044 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
11045 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
11047 diff -NurpP --minimal linux-2.6.22.10/include/linux/sysctl.h linux-2.6.22.10-vs2.2.0.5/include/linux/sysctl.h
11048 --- linux-2.6.22.10/include/linux/sysctl.h 2007-07-09 13:20:01 +0200
11049 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/sysctl.h 2007-06-15 02:37:04 +0200
11050 @@ -106,6 +106,7 @@ enum
11051 KERN_CAP_BSET=14, /* int: capability bounding set */
11052 KERN_PANIC=15, /* int: panic timeout */
11053 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
11054 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
11056 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
11057 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
11058 diff -NurpP --minimal linux-2.6.22.10/include/linux/sysfs.h linux-2.6.22.10-vs2.2.0.5/include/linux/sysfs.h
11059 --- linux-2.6.22.10/include/linux/sysfs.h 2007-07-09 13:20:01 +0200
11060 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/sysfs.h 2007-06-15 02:37:04 +0200
11062 #include <linux/list.h>
11063 #include <asm/atomic.h>
11065 +#define SYSFS_SUPER_MAGIC 0x62656572
11070 diff -NurpP --minimal linux-2.6.22.10/include/linux/time.h linux-2.6.22.10-vs2.2.0.5/include/linux/time.h
11071 --- linux-2.6.22.10/include/linux/time.h 2007-07-09 13:20:01 +0200
11072 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/time.h 2007-06-15 02:37:04 +0200
11073 @@ -176,6 +176,9 @@ static inline void timespec_add_ns(struc
11078 +#include <linux/vs_time.h>
11080 #endif /* __KERNEL__ */
11082 #define NFDBITS __NFDBITS
11083 diff -NurpP --minimal linux-2.6.22.10/include/linux/types.h linux-2.6.22.10-vs2.2.0.5/include/linux/types.h
11084 --- linux-2.6.22.10/include/linux/types.h 2007-02-06 03:01:52 +0100
11085 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/types.h 2007-06-15 02:37:04 +0200
11086 @@ -39,6 +39,9 @@ typedef __kernel_uid32_t uid_t;
11087 typedef __kernel_gid32_t gid_t;
11088 typedef __kernel_uid16_t uid16_t;
11089 typedef __kernel_gid16_t gid16_t;
11090 +typedef unsigned int xid_t;
11091 +typedef unsigned int nid_t;
11092 +typedef unsigned int tag_t;
11094 #ifdef CONFIG_UID16
11095 /* This is defined by include/asm-{arch}/posix_types.h */
11096 diff -NurpP --minimal linux-2.6.22.10/include/linux/vroot.h linux-2.6.22.10-vs2.2.0.5/include/linux/vroot.h
11097 --- linux-2.6.22.10/include/linux/vroot.h 1970-01-01 01:00:00 +0100
11098 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vroot.h 2007-06-15 02:37:04 +0200
11102 + * include/linux/vroot.h
11104 + * written by Herbert Pötzl, 9/11/2002
11105 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
11107 + * Copyright (C) 2002-2007 by Herbert Pötzl.
11108 + * Redistribution of this file is permitted under the
11109 + * GNU General Public License.
11112 +#ifndef _LINUX_VROOT_H
11113 +#define _LINUX_VROOT_H
11118 +/* Possible states of device */
11124 +struct vroot_device {
11128 + struct semaphore vr_ctl_mutex;
11129 + struct block_device *vr_device;
11134 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
11136 +extern int register_vroot_grb(vroot_grb_func *);
11137 +extern int unregister_vroot_grb(vroot_grb_func *);
11139 +#endif /* __KERNEL__ */
11141 +#define MAX_VROOT_DEFAULT 8
11144 + * IOCTL commands --- we will commandeer 0x56 ('V')
11147 +#define VROOT_SET_DEV 0x5600
11148 +#define VROOT_CLR_DEV 0x5601
11150 +#endif /* _LINUX_VROOT_H */
11151 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_base.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_base.h
11152 --- linux-2.6.22.10/include/linux/vs_base.h 1970-01-01 01:00:00 +0100
11153 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_base.h 2007-06-15 02:37:04 +0200
11155 +#ifndef _VS_BASE_H
11156 +#define _VS_BASE_H
11158 +#include "vserver/base.h"
11159 +#include "vserver/debug.h"
11162 +#warning duplicate inclusion
11164 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_context.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_context.h
11165 --- linux-2.6.22.10/include/linux/vs_context.h 1970-01-01 01:00:00 +0100
11166 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_context.h 2007-06-15 02:37:04 +0200
11168 +#ifndef _VS_CONTEXT_H
11169 +#define _VS_CONTEXT_H
11171 +#include "vserver/base.h"
11172 +#include "vserver/context.h"
11173 +#include "vserver/history.h"
11174 +#include "vserver/debug.h"
11177 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
11179 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
11180 + const char *_file, int _line, void *_here)
11185 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
11186 + vxi, vxi ? vxi->vx_id : 0,
11187 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11189 + __vxh_get_vx_info(vxi, _here);
11191 + atomic_inc(&vxi->vx_usecnt);
11196 +extern void free_vx_info(struct vx_info *);
11198 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
11200 +static inline void __put_vx_info(struct vx_info *vxi,
11201 + const char *_file, int _line, void *_here)
11206 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
11207 + vxi, vxi ? vxi->vx_id : 0,
11208 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11210 + __vxh_put_vx_info(vxi, _here);
11212 + if (atomic_dec_and_test(&vxi->vx_usecnt))
11213 + free_vx_info(vxi);
11217 +#define init_vx_info(p, i) \
11218 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11220 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11221 + const char *_file, int _line, void *_here)
11224 + vxlprintk(VXD_CBIT(xid, 3),
11225 + "init_vx_info(%p[#%d.%d])",
11226 + vxi, vxi ? vxi->vx_id : 0,
11227 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11229 + __vxh_init_vx_info(vxi, vxp, _here);
11231 + atomic_inc(&vxi->vx_usecnt);
11237 +#define set_vx_info(p, i) \
11238 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11240 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11241 + const char *_file, int _line, void *_here)
11243 + struct vx_info *vxo;
11248 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
11249 + vxi, vxi ? vxi->vx_id : 0,
11250 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11252 + __vxh_set_vx_info(vxi, vxp, _here);
11254 + atomic_inc(&vxi->vx_usecnt);
11255 + vxo = xchg(vxp, vxi);
11260 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
11262 +static inline void __clr_vx_info(struct vx_info **vxp,
11263 + const char *_file, int _line, void *_here)
11265 + struct vx_info *vxo;
11267 + vxo = xchg(vxp, NULL);
11271 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
11272 + vxo, vxo ? vxo->vx_id : 0,
11273 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
11275 + __vxh_clr_vx_info(vxo, vxp, _here);
11277 + if (atomic_dec_and_test(&vxo->vx_usecnt))
11278 + free_vx_info(vxo);
11282 +#define claim_vx_info(v, p) \
11283 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11285 +static inline void __claim_vx_info(struct vx_info *vxi,
11286 + struct task_struct *task,
11287 + const char *_file, int _line, void *_here)
11289 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
11290 + vxi, vxi ? vxi->vx_id : 0,
11291 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11292 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
11293 + task, _file, _line);
11294 + __vxh_claim_vx_info(vxi, task, _here);
11296 + atomic_inc(&vxi->vx_tasks);
11300 +extern void unhash_vx_info(struct vx_info *);
11302 +#define release_vx_info(v, p) \
11303 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11305 +static inline void __release_vx_info(struct vx_info *vxi,
11306 + struct task_struct *task,
11307 + const char *_file, int _line, void *_here)
11309 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
11310 + vxi, vxi ? vxi->vx_id : 0,
11311 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11312 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
11313 + task, _file, _line);
11314 + __vxh_release_vx_info(vxi, task, _here);
11318 + if (atomic_dec_and_test(&vxi->vx_tasks))
11319 + unhash_vx_info(vxi);
11323 +#define task_get_vx_info(p) \
11324 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
11326 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
11327 + const char *_file, int _line, void *_here)
11329 + struct vx_info *vxi;
11332 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
11333 + p, _file, _line);
11334 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
11340 +static inline void __wakeup_vx_info(struct vx_info *vxi)
11342 + if (waitqueue_active(&vxi->vx_wait))
11343 + wake_up_interruptible(&vxi->vx_wait);
11347 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
11349 +static inline void __enter_vx_info(struct vx_info *vxi,
11350 + struct vx_info_save *vxis, const char *_file, int _line)
11352 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
11353 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
11354 + current->xid, current->vx_info, _file, _line);
11355 + vxis->vxi = xchg(¤t->vx_info, vxi);
11356 + vxis->xid = current->xid;
11357 + current->xid = vxi ? vxi->vx_id : 0;
11360 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
11362 +static inline void __leave_vx_info(struct vx_info_save *vxis,
11363 + const char *_file, int _line)
11365 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
11366 + vxis, vxis->xid, vxis->vxi, current,
11367 + current->xid, current->vx_info, _file, _line);
11368 + (void)xchg(¤t->vx_info, vxis->vxi);
11369 + current->xid = vxis->xid;
11373 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
11375 + vxis->vxi = xchg(¤t->vx_info, NULL);
11376 + vxis->xid = xchg(¤t->xid, (xid_t)0);
11379 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
11381 + (void)xchg(¤t->xid, vxis->xid);
11382 + (void)xchg(¤t->vx_info, vxis->vxi);
11385 +extern void exit_vx_info(struct task_struct *, int);
11386 +extern void exit_vx_info_early(struct task_struct *, int);
11390 +#warning duplicate inclusion
11392 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_cowbl.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_cowbl.h
11393 --- linux-2.6.22.10/include/linux/vs_cowbl.h 1970-01-01 01:00:00 +0100
11394 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_cowbl.h 2007-06-15 02:37:04 +0200
11396 +#ifndef _VS_COWBL_H
11397 +#define _VS_COWBL_H
11399 +#include <linux/fs.h>
11400 +#include <linux/dcache.h>
11401 +#include <linux/namei.h>
11403 +extern struct dentry *cow_break_link(const char *pathname);
11405 +static inline int cow_check_and_break(struct nameidata *nd)
11407 + struct inode *inode = nd->dentry->d_inode;
11409 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
11411 + if (IS_COW(inode)) {
11412 + if (IS_COW_LINK(inode)) {
11413 + struct dentry *new_dentry, *old_dentry = nd->dentry;
11414 + char *path, *buf;
11416 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
11420 + path = d_path(nd->dentry, nd->mnt, buf, PATH_MAX);
11421 + new_dentry = cow_break_link(path);
11423 + if (!IS_ERR(new_dentry)) {
11424 + nd->dentry = new_dentry;
11425 + dput(old_dentry);
11427 + error = PTR_ERR(new_dentry);
11429 + inode->i_flags &= ~(S_IUNLINK | S_IMMUTABLE);
11430 + inode->i_ctime = CURRENT_TIME;
11431 + mark_inode_dirty(inode);
11438 +#warning duplicate inclusion
11440 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_cvirt.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_cvirt.h
11441 --- linux-2.6.22.10/include/linux/vs_cvirt.h 1970-01-01 01:00:00 +0100
11442 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_cvirt.h 2007-06-15 02:37:04 +0200
11444 +#ifndef _VS_CVIRT_H
11445 +#define _VS_CVIRT_H
11447 +#include "vserver/cvirt.h"
11448 +#include "vserver/context.h"
11449 +#include "vserver/base.h"
11450 +#include "vserver/debug.h"
11453 +static inline void vx_activate_task(struct task_struct *p)
11455 + struct vx_info *vxi;
11457 + if ((vxi = p->vx_info)) {
11458 + vx_update_load(vxi);
11459 + atomic_inc(&vxi->cvirt.nr_running);
11463 +static inline void vx_deactivate_task(struct task_struct *p)
11465 + struct vx_info *vxi;
11467 + if ((vxi = p->vx_info)) {
11468 + vx_update_load(vxi);
11469 + atomic_dec(&vxi->cvirt.nr_running);
11473 +static inline void vx_uninterruptible_inc(struct task_struct *p)
11475 + struct vx_info *vxi;
11477 + if ((vxi = p->vx_info))
11478 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
11481 +static inline void vx_uninterruptible_dec(struct task_struct *p)
11483 + struct vx_info *vxi;
11485 + if ((vxi = p->vx_info))
11486 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
11491 +#warning duplicate inclusion
11493 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_dlimit.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_dlimit.h
11494 --- linux-2.6.22.10/include/linux/vs_dlimit.h 1970-01-01 01:00:00 +0100
11495 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_dlimit.h 2007-06-15 02:37:04 +0200
11497 +#ifndef _VS_DLIMIT_H
11498 +#define _VS_DLIMIT_H
11500 +#include "vserver/dlimit.h"
11501 +#include "vserver/base.h"
11502 +#include "vserver/debug.h"
11505 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
11507 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
11508 + const char *_file, int _line)
11512 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
11513 + dli, dli ? dli->dl_tag : 0,
11514 + dli ? atomic_read(&dli->dl_usecnt) : 0,
11516 + atomic_inc(&dli->dl_usecnt);
11521 +#define free_dl_info(i) \
11522 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
11524 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
11526 +static inline void __put_dl_info(struct dl_info *dli,
11527 + const char *_file, int _line)
11531 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
11532 + dli, dli ? dli->dl_tag : 0,
11533 + dli ? atomic_read(&dli->dl_usecnt) : 0,
11535 + if (atomic_dec_and_test(&dli->dl_usecnt))
11536 + free_dl_info(dli);
11540 +#define __dlimit_char(d) ((d) ? '*' : ' ')
11542 +static inline int __dl_alloc_space(struct super_block *sb,
11543 + tag_t tag, dlsize_t nr, const char *file, int line)
11545 + struct dl_info *dli = NULL;
11550 + dli = locate_dl_info(sb, tag);
11554 + spin_lock(&dli->dl_lock);
11555 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
11557 + dli->dl_space_used += nr;
11558 + spin_unlock(&dli->dl_lock);
11559 + put_dl_info(dli);
11561 + vxlprintk(VXD_CBIT(dlim, 1),
11562 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
11563 + sb, tag, __dlimit_char(dli), (long long)nr,
11564 + ret, file, line);
11568 +static inline void __dl_free_space(struct super_block *sb,
11569 + tag_t tag, dlsize_t nr, const char *_file, int _line)
11571 + struct dl_info *dli = NULL;
11575 + dli = locate_dl_info(sb, tag);
11579 + spin_lock(&dli->dl_lock);
11580 + if (dli->dl_space_used > nr)
11581 + dli->dl_space_used -= nr;
11583 + dli->dl_space_used = 0;
11584 + spin_unlock(&dli->dl_lock);
11585 + put_dl_info(dli);
11587 + vxlprintk(VXD_CBIT(dlim, 1),
11588 + "FREE (%p,#%d)%c %lld bytes",
11589 + sb, tag, __dlimit_char(dli), (long long)nr,
11593 +static inline int __dl_alloc_inode(struct super_block *sb,
11594 + tag_t tag, const char *_file, int _line)
11596 + struct dl_info *dli;
11599 + dli = locate_dl_info(sb, tag);
11603 + spin_lock(&dli->dl_lock);
11604 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
11606 + dli->dl_inodes_used++;
11607 + spin_unlock(&dli->dl_lock);
11608 + put_dl_info(dli);
11610 + vxlprintk(VXD_CBIT(dlim, 0),
11611 + "ALLOC (%p,#%d)%c inode (%d)",
11612 + sb, tag, __dlimit_char(dli), ret, _file, _line);
11616 +static inline void __dl_free_inode(struct super_block *sb,
11617 + tag_t tag, const char *_file, int _line)
11619 + struct dl_info *dli;
11621 + dli = locate_dl_info(sb, tag);
11625 + spin_lock(&dli->dl_lock);
11626 + if (dli->dl_inodes_used > 1)
11627 + dli->dl_inodes_used--;
11629 + dli->dl_inodes_used = 0;
11630 + spin_unlock(&dli->dl_lock);
11631 + put_dl_info(dli);
11633 + vxlprintk(VXD_CBIT(dlim, 0),
11634 + "FREE (%p,#%d)%c inode",
11635 + sb, tag, __dlimit_char(dli), _file, _line);
11638 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
11639 + unsigned long long *free_blocks, unsigned long long *root_blocks,
11640 + const char *_file, int _line)
11642 + struct dl_info *dli;
11643 + uint64_t broot, bfree;
11645 + dli = locate_dl_info(sb, tag);
11649 + spin_lock(&dli->dl_lock);
11650 + broot = (dli->dl_space_total -
11651 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
11652 + >> sb->s_blocksize_bits;
11653 + bfree = (dli->dl_space_total - dli->dl_space_used)
11654 + >> sb->s_blocksize_bits;
11655 + spin_unlock(&dli->dl_lock);
11657 + vxlprintk(VXD_CBIT(dlim, 2),
11658 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
11659 + (long long)bfree, (long long)broot,
11660 + *free_blocks, *root_blocks, dli->dl_nrlmult,
11662 + if (free_blocks) {
11663 + if (*free_blocks > bfree)
11664 + *free_blocks = bfree;
11666 + if (root_blocks) {
11667 + if (*root_blocks > broot)
11668 + *root_blocks = broot;
11670 + put_dl_info(dli);
11673 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
11674 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11675 + __FILE__, __LINE__ )
11677 +#define DLIMIT_FREE_SPACE(in, bytes) \
11678 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11679 + __FILE__, __LINE__ )
11681 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
11682 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
11683 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
11684 + __FILE__, __LINE__ )
11686 +#define DLIMIT_FREE_BLOCK(in, nr) \
11687 + __dl_free_space((in)->i_sb, (in)->i_tag, \
11688 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
11689 + __FILE__, __LINE__ )
11692 +#define DLIMIT_ALLOC_INODE(in) \
11693 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11695 +#define DLIMIT_FREE_INODE(in) \
11696 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11699 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
11700 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
11704 +#warning duplicate inclusion
11706 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_limit.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_limit.h
11707 --- linux-2.6.22.10/include/linux/vs_limit.h 1970-01-01 01:00:00 +0100
11708 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_limit.h 2007-06-15 02:37:04 +0200
11710 +#ifndef _VS_LIMIT_H
11711 +#define _VS_LIMIT_H
11713 +#include "vserver/limit.h"
11714 +#include "vserver/base.h"
11715 +#include "vserver/context.h"
11716 +#include "vserver/debug.h"
11717 +#include "vserver/context.h"
11718 +#include "vserver/limit_int.h"
11721 +#define vx_acc_cres(v, d, p, r) \
11722 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
11724 +#define vx_acc_cres_cond(x, d, p, r) \
11725 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
11726 + r, d, p, __FILE__, __LINE__)
11729 +#define vx_add_cres(v, a, p, r) \
11730 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
11731 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
11733 +#define vx_add_cres_cond(x, a, p, r) \
11734 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
11735 + r, a, p, __FILE__, __LINE__)
11736 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
11739 +/* process and file limits */
11741 +#define vx_nproc_inc(p) \
11742 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
11744 +#define vx_nproc_dec(p) \
11745 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
11747 +#define vx_files_inc(f) \
11748 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
11750 +#define vx_files_dec(f) \
11751 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
11753 +#define vx_locks_inc(l) \
11754 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
11756 +#define vx_locks_dec(l) \
11757 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
11759 +#define vx_openfd_inc(f) \
11760 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
11762 +#define vx_openfd_dec(f) \
11763 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
11766 +#define vx_cres_avail(v, n, r) \
11767 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
11770 +#define vx_nproc_avail(n) \
11771 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
11773 +#define vx_files_avail(n) \
11774 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
11776 +#define vx_locks_avail(n) \
11777 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
11779 +#define vx_openfd_avail(n) \
11780 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
11783 +/* dentry limits */
11785 +#define vx_dentry_inc(d) do { \
11786 + if (atomic_read(&d->d_count) == 1) \
11787 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
11790 +#define vx_dentry_dec(d) do { \
11791 + if (atomic_read(&d->d_count) == 0) \
11792 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
11795 +#define vx_dentry_avail(n) \
11796 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
11799 +/* socket limits */
11801 +#define vx_sock_inc(s) \
11802 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
11804 +#define vx_sock_dec(s) \
11805 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
11807 +#define vx_sock_avail(n) \
11808 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
11811 +/* ipc resource limits */
11813 +#define vx_ipcmsg_add(v, u, a) \
11814 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
11816 +#define vx_ipcmsg_sub(v, u, a) \
11817 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
11819 +#define vx_ipcmsg_avail(v, a) \
11820 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
11823 +#define vx_ipcshm_add(v, k, a) \
11824 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
11826 +#define vx_ipcshm_sub(v, k, a) \
11827 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
11829 +#define vx_ipcshm_avail(v, a) \
11830 + vx_cres_avail(v, a, VLIMIT_SHMEM)
11833 +#define vx_semary_inc(a) \
11834 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
11836 +#define vx_semary_dec(a) \
11837 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
11840 +#define vx_nsems_add(a,n) \
11841 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
11843 +#define vx_nsems_sub(a,n) \
11844 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
11848 +#warning duplicate inclusion
11850 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_memory.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_memory.h
11851 --- linux-2.6.22.10/include/linux/vs_memory.h 1970-01-01 01:00:00 +0100
11852 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_memory.h 2007-06-15 02:37:04 +0200
11854 +#ifndef _VS_MEMORY_H
11855 +#define _VS_MEMORY_H
11857 +#include "vserver/limit.h"
11858 +#include "vserver/base.h"
11859 +#include "vserver/context.h"
11860 +#include "vserver/debug.h"
11861 +#include "vserver/context.h"
11862 +#include "vserver/limit_int.h"
11865 +#define __acc_add_long(a, v) (*(v) += (a))
11866 +#define __acc_inc_long(v) (++*(v))
11867 +#define __acc_dec_long(v) (--*(v))
11869 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
11870 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
11871 +#define __acc_inc_atomic(v) atomic_long_inc(v)
11872 +#define __acc_dec_atomic(v) atomic_long_dec(v)
11873 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11874 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
11875 +#define __acc_inc_atomic(v) __acc_inc_long(v)
11876 +#define __acc_dec_atomic(v) __acc_dec_long(v)
11877 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11880 +#define vx_acc_page(m, d, v, r) do { \
11882 + __acc_inc_long(&(m)->v); \
11884 + __acc_dec_long(&(m)->v); \
11885 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
11888 +#define vx_acc_page_atomic(m, d, v, r) do { \
11890 + __acc_inc_atomic(&(m)->v); \
11892 + __acc_dec_atomic(&(m)->v); \
11893 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
11897 +#define vx_acc_pages(m, p, v, r) do { \
11898 + unsigned long __p = (p); \
11899 + __acc_add_long(__p, &(m)->v); \
11900 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
11903 +#define vx_acc_pages_atomic(m, p, v, r) do { \
11904 + unsigned long __p = (p); \
11905 + __acc_add_atomic(__p, &(m)->v); \
11906 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
11911 +#define vx_acc_vmpage(m, d) \
11912 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
11913 +#define vx_acc_vmlpage(m, d) \
11914 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
11915 +#define vx_acc_file_rsspage(m, d) \
11916 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
11917 +#define vx_acc_anon_rsspage(m, d) \
11918 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
11920 +#define vx_acc_vmpages(m, p) \
11921 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
11922 +#define vx_acc_vmlpages(m, p) \
11923 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
11924 +#define vx_acc_file_rsspages(m, p) \
11925 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
11926 +#define vx_acc_anon_rsspages(m, p) \
11927 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
11929 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
11930 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
11932 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
11933 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
11934 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
11935 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
11937 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
11938 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
11939 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
11940 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
11942 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
11943 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
11944 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
11945 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
11947 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
11948 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
11949 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
11950 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
11953 +#define vx_pages_avail(m, p, r) \
11954 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
11956 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
11957 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
11958 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
11959 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
11961 +#define vx_rss_avail(m, p) \
11962 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
11966 + VXPT_UNKNOWN = 0,
11975 +#define vx_page_fault(mm, vma, type, ret)
11979 +void __vx_page_fault(struct mm_struct *mm,
11980 + struct vm_area_struct *vma, int type, int ret)
11982 + struct vx_info *vxi = mm->mm_vx_info;
11985 + static char *page_type[6] =
11986 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
11987 + static char *page_what[4] =
11988 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
11994 + what = (ret & 0x3);
11996 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
11997 + type, what, ret, page_type[type], page_what[what]);
11999 + if (ret & VM_FAULT_WRITE)
12001 + atomic_inc(&vxi->cacct.page[type][what]);
12004 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
12008 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
12011 +#warning duplicate inclusion
12013 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_network.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_network.h
12014 --- linux-2.6.22.10/include/linux/vs_network.h 1970-01-01 01:00:00 +0100
12015 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_network.h 2007-06-15 02:37:04 +0200
12017 +#ifndef _NX_VS_NETWORK_H
12018 +#define _NX_VS_NETWORK_H
12020 +#include "vserver/context.h"
12021 +#include "vserver/network.h"
12022 +#include "vserver/base.h"
12023 +#include "vserver/debug.h"
12026 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
12028 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
12029 + const char *_file, int _line)
12034 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
12035 + nxi, nxi ? nxi->nx_id : 0,
12036 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12039 + atomic_inc(&nxi->nx_usecnt);
12044 +extern void free_nx_info(struct nx_info *);
12046 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
12048 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
12053 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
12054 + nxi, nxi ? nxi->nx_id : 0,
12055 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12058 + if (atomic_dec_and_test(&nxi->nx_usecnt))
12059 + free_nx_info(nxi);
12063 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
12065 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
12066 + const char *_file, int _line)
12069 + vxlprintk(VXD_CBIT(nid, 3),
12070 + "init_nx_info(%p[#%d.%d])",
12071 + nxi, nxi ? nxi->nx_id : 0,
12072 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12075 + atomic_inc(&nxi->nx_usecnt);
12081 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
12083 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
12084 + const char *_file, int _line)
12086 + struct nx_info *nxo;
12091 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
12092 + nxi, nxi ? nxi->nx_id : 0,
12093 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12096 + atomic_inc(&nxi->nx_usecnt);
12097 + nxo = xchg(nxp, nxi);
12101 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
12103 +static inline void __clr_nx_info(struct nx_info **nxp,
12104 + const char *_file, int _line)
12106 + struct nx_info *nxo;
12108 + nxo = xchg(nxp, NULL);
12112 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
12113 + nxo, nxo ? nxo->nx_id : 0,
12114 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
12117 + if (atomic_dec_and_test(&nxo->nx_usecnt))
12118 + free_nx_info(nxo);
12122 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
12124 +static inline void __claim_nx_info(struct nx_info *nxi,
12125 + struct task_struct *task, const char *_file, int _line)
12127 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
12128 + nxi, nxi ? nxi->nx_id : 0,
12129 + nxi?atomic_read(&nxi->nx_usecnt):0,
12130 + nxi?atomic_read(&nxi->nx_tasks):0,
12131 + task, _file, _line);
12133 + atomic_inc(&nxi->nx_tasks);
12137 +extern void unhash_nx_info(struct nx_info *);
12139 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
12141 +static inline void __release_nx_info(struct nx_info *nxi,
12142 + struct task_struct *task, const char *_file, int _line)
12144 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
12145 + nxi, nxi ? nxi->nx_id : 0,
12146 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12147 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
12148 + task, _file, _line);
12152 + if (atomic_dec_and_test(&nxi->nx_tasks))
12153 + unhash_nx_info(nxi);
12157 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
12159 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
12160 + const char *_file, int _line)
12162 + struct nx_info *nxi;
12165 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
12166 + p, _file, _line);
12167 + nxi = __get_nx_info(p->nx_info, _file, _line);
12175 +static inline int addr_in_nx_info(struct nx_info *nxi, uint32_t addr)
12183 + if (n && (nxi->ipv4[0] == 0))
12185 + for (i = 0; i < n; i++) {
12186 + if (nxi->ipv4[i] == addr)
12192 +static inline void exit_nx_info(struct task_struct *p)
12195 + release_nx_info(p->nx_info, p);
12200 +#warning duplicate inclusion
12202 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_pid.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_pid.h
12203 --- linux-2.6.22.10/include/linux/vs_pid.h 1970-01-01 01:00:00 +0100
12204 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_pid.h 2007-06-15 02:37:04 +0200
12209 +#include "vserver/base.h"
12210 +#include "vserver/context.h"
12211 +#include "vserver/debug.h"
12212 +#include <linux/pid_namespace.h>
12215 +/* pid faking stuff */
12218 +#define vx_info_map_pid(v, p) \
12219 + __vx_info_map_pid((v), (p), __FUNC__, __FILE__, __LINE__)
12220 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12221 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
12222 +#define vx_map_tgid(p) vx_map_pid(p)
12224 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12225 + const char *func, const char *file, int line)
12227 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12228 + vxfprintk(VXD_CBIT(cvirt, 2),
12229 + "vx_map_tgid: %p/%llx: %d -> %d",
12230 + vxi, (long long)vxi->vx_flags, pid,
12231 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12232 + func, file, line);
12235 + if (pid == vxi->vx_initpid)
12241 +#define vx_info_rmap_pid(v, p) \
12242 + __vx_info_rmap_pid((v), (p), __FUNC__, __FILE__, __LINE__)
12243 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
12244 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12246 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12247 + const char *func, const char *file, int line)
12249 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12250 + vxfprintk(VXD_CBIT(cvirt, 2),
12251 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12252 + vxi, (long long)vxi->vx_flags, pid,
12253 + (pid == 1) ? vxi->vx_initpid : pid,
12254 + func, file, line);
12255 + if ((pid == 1) && vxi->vx_initpid)
12256 + return vxi->vx_initpid;
12257 + if (pid == vxi->vx_initpid)
12264 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
12267 +int vx_proc_task_visible(struct task_struct *task)
12269 + if ((task->pid == 1) &&
12270 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
12271 + /* show a blend through init */
12273 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
12281 +struct task_struct *vx_find_proc_task_by_pid(int pid)
12283 + struct task_struct *task = find_task_by_real_pid(pid);
12285 + if (task && !vx_proc_task_visible(task)) {
12286 + vxdprintk(VXD_CBIT(misc, 6),
12287 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
12288 + task, task->xid, task->pid,
12289 + current, current->xid, current->pid);
12296 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
12298 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
12300 + if (task && !vx_proc_task_visible(task)) {
12301 + vxdprintk(VXD_CBIT(misc, 6),
12302 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
12303 + task, task->xid, task->pid,
12304 + current, current->xid, current->pid);
12305 + put_task_struct(task);
12313 +struct task_struct *vx_child_reaper(struct task_struct *p)
12315 + struct vx_info *vxi = p->vx_info;
12316 + struct task_struct *reaper = child_reaper(p);
12321 + BUG_ON(!p->vx_info->vx_reaper);
12323 + /* child reaper for the guest reaper */
12324 + if (vxi->vx_reaper == p)
12327 + reaper = vxi->vx_reaper;
12329 + vxdprintk(VXD_CBIT(xid, 7),
12330 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
12331 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
12337 +#warning duplicate inclusion
12339 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_sched.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_sched.h
12340 --- linux-2.6.22.10/include/linux/vs_sched.h 1970-01-01 01:00:00 +0100
12341 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_sched.h 2007-06-15 02:37:04 +0200
12343 +#ifndef _VS_SCHED_H
12344 +#define _VS_SCHED_H
12346 +#include "vserver/base.h"
12347 +#include "vserver/context.h"
12348 +#include "vserver/sched.h"
12351 +#define VAVAVOOM_RATIO 50
12353 +#define MAX_PRIO_BIAS 20
12354 +#define MIN_PRIO_BIAS -20
12357 +#ifdef CONFIG_VSERVER_HARDCPU
12360 + * effective_prio - return the priority that is based on the static
12361 + * priority but is modified by bonuses/penalties.
12363 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
12364 + * into a -4 ... 0 ... +4 bonus/penalty range.
12366 + * Additionally, we scale another amount based on the number of
12367 + * CPU tokens currently held by the context, if the process is
12368 + * part of a context (and the appropriate SCHED flag is set).
12369 + * This ranges from -5 ... 0 ... +15, quadratically.
12371 + * So, the total bonus is -9 .. 0 .. +19
12372 + * We use ~50% of the full 0...39 priority range so that:
12374 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
12375 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
12376 + * unless that context is far exceeding its CPU allocation.
12378 + * Both properties are important to certain workloads.
12381 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
12383 + int vavavoom, max;
12385 + /* lots of tokens = lots of vavavoom
12386 + * no tokens = no vavavoom */
12387 + if ((vavavoom = sched_pc->tokens) >= 0) {
12388 + max = sched_pc->tokens_max;
12389 + vavavoom = max - vavavoom;
12391 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
12392 + * (vavavoom*vavavoom - (max >> 2)) / max;
12400 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
12402 + struct vx_info *vxi = p->vx_info;
12403 + struct _vx_sched_pc *sched_pc;
12408 + sched_pc = &vx_cpu(vxi, sched_pc);
12409 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
12410 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
12412 + sched_pc->vavavoom = vavavoom;
12413 + prio += vavavoom;
12415 + prio += sched_pc->prio_bias;
12419 +#else /* !CONFIG_VSERVER_HARDCPU */
12422 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
12424 + struct vx_info *vxi = p->vx_info;
12427 + prio += vx_cpu(vxi, sched_pc).prio_bias;
12431 +#endif /* CONFIG_VSERVER_HARDCPU */
12434 +static inline void vx_account_user(struct vx_info *vxi,
12435 + cputime_t cputime, int nice)
12439 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
12442 +static inline void vx_account_system(struct vx_info *vxi,
12443 + cputime_t cputime, int idle)
12447 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
12451 +#warning duplicate inclusion
12453 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_socket.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_socket.h
12454 --- linux-2.6.22.10/include/linux/vs_socket.h 1970-01-01 01:00:00 +0100
12455 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_socket.h 2007-06-15 02:37:04 +0200
12457 +#ifndef _VS_SOCKET_H
12458 +#define _VS_SOCKET_H
12460 +#include "vserver/debug.h"
12461 +#include "vserver/base.h"
12462 +#include "vserver/cacct.h"
12463 +#include "vserver/context.h"
12466 +/* socket accounting */
12468 +#include <linux/socket.h>
12470 +static inline int vx_sock_type(int family)
12472 + switch (family) {
12474 + return VXA_SOCK_UNSPEC;
12476 + return VXA_SOCK_UNIX;
12478 + return VXA_SOCK_INET;
12480 + return VXA_SOCK_INET6;
12482 + return VXA_SOCK_PACKET;
12484 + return VXA_SOCK_OTHER;
12488 +#define vx_acc_sock(v, f, p, s) \
12489 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
12491 +static inline void __vx_acc_sock(struct vx_info *vxi,
12492 + int family, int pos, int size, char *file, int line)
12495 + int type = vx_sock_type(family);
12497 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
12498 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
12502 +#define vx_sock_recv(sk, s) \
12503 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
12504 +#define vx_sock_send(sk, s) \
12505 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
12506 +#define vx_sock_fail(sk, s) \
12507 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
12510 +#define sock_vx_init(s) do { \
12511 + (s)->sk_xid = 0; \
12512 + (s)->sk_vx_info = NULL; \
12515 +#define sock_nx_init(s) do { \
12516 + (s)->sk_nid = 0; \
12517 + (s)->sk_nx_info = NULL; \
12522 +#warning duplicate inclusion
12524 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_tag.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_tag.h
12525 --- linux-2.6.22.10/include/linux/vs_tag.h 1970-01-01 01:00:00 +0100
12526 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_tag.h 2007-06-15 02:37:04 +0200
12531 +#include <linux/vserver/tag.h>
12533 +/* check conditions */
12535 +#define DX_ADMIN 0x0001
12536 +#define DX_WATCH 0x0002
12537 +#define DX_HOSTID 0x0008
12539 +#define DX_IDENT 0x0010
12541 +#define DX_ARG_MASK 0x0010
12544 +#define dx_task_tag(t) ((t)->xid)
12546 +#define dx_current_tag() dx_task_tag(current)
12548 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
12550 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
12554 + * check current context for ADMIN/WATCH and
12555 + * optionally against supplied argument
12557 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
12559 + if (mode & DX_ARG_MASK) {
12560 + if ((mode & DX_IDENT) && (id == cid))
12563 + return (((mode & DX_ADMIN) && (cid == 0)) ||
12564 + ((mode & DX_WATCH) && (cid == 1)) ||
12565 + ((mode & DX_HOSTID) && (id == 0)));
12569 +#warning duplicate inclusion
12571 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_time.h linux-2.6.22.10-vs2.2.0.5/include/linux/vs_time.h
12572 --- linux-2.6.22.10/include/linux/vs_time.h 1970-01-01 01:00:00 +0100
12573 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vs_time.h 2007-06-15 02:37:04 +0200
12575 +#ifndef _VS_TIME_H
12576 +#define _VS_TIME_H
12579 +/* time faking stuff */
12581 +#ifdef CONFIG_VSERVER_VTIME
12583 +extern void vx_gettimeofday(struct timeval *tv);
12584 +extern int vx_settimeofday(struct timespec *ts);
12587 +#define vx_gettimeofday(t) do_gettimeofday(t)
12588 +#define vx_settimeofday(t) do_settimeofday(t)
12592 +#warning duplicate inclusion
12594 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/Kbuild linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/Kbuild
12595 --- linux-2.6.22.10/include/linux/vserver/Kbuild 1970-01-01 01:00:00 +0100
12596 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/Kbuild 2007-06-16 19:48:30 +0200
12599 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
12600 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
12601 + inode_cmd.h sched_cmd.h signal_cmd.h debug_cmd.h
12603 +unifdef-y += switch.h network.h monitor.h inode.h
12605 +unifdef-y += legacy.h
12607 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/base.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/base.h
12608 --- linux-2.6.22.10/include/linux/vserver/base.h 1970-01-01 01:00:00 +0100
12609 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/base.h 2007-06-15 02:37:04 +0200
12611 +#ifndef _VX_BASE_H
12612 +#define _VX_BASE_H
12615 +/* context state changes */
12626 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
12628 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
12629 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
12631 +#define MIN_D_CONTEXT 65536
12634 +/* check conditions */
12636 +#define VS_ADMIN 0x0001
12637 +#define VS_WATCH 0x0002
12638 +#define VS_HIDE 0x0004
12639 +#define VS_HOSTID 0x0008
12641 +#define VS_IDENT 0x0010
12642 +#define VS_EQUIV 0x0020
12643 +#define VS_PARENT 0x0040
12644 +#define VS_CHILD 0x0080
12646 +#define VS_ARG_MASK 0x00F0
12648 +#define VS_DYNAMIC 0x0100
12649 +#define VS_STATIC 0x0200
12651 +#define VS_ATR_MASK 0x0F00
12653 +#ifdef CONFIG_VSERVER_PRIVACY
12654 +#define VS_ADMIN_P (0)
12655 +#define VS_WATCH_P (0)
12657 +#define VS_ADMIN_P VS_ADMIN
12658 +#define VS_WATCH_P VS_WATCH
12661 +#define VS_HARDIRQ 0x1000
12662 +#define VS_SOFTIRQ 0x2000
12663 +#define VS_IRQ 0x4000
12665 +#define VS_IRQ_MASK 0xF000
12667 +#include <linux/hardirq.h>
12670 + * check current context for ADMIN/WATCH and
12671 + * optionally against supplied argument
12673 +static inline int __vs_check(int cid, int id, unsigned int mode)
12675 + if (mode & VS_ARG_MASK) {
12676 + if ((mode & VS_IDENT) && (id == cid))
12679 + if (mode & VS_ATR_MASK) {
12680 + if ((mode & VS_DYNAMIC) &&
12681 + (id >= MIN_D_CONTEXT) &&
12682 + (id <= MAX_S_CONTEXT))
12684 + if ((mode & VS_STATIC) &&
12685 + (id > 1) && (id < MIN_D_CONTEXT))
12688 + if (mode & VS_IRQ_MASK) {
12689 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
12691 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
12693 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
12696 + return (((mode & VS_ADMIN) && (cid == 0)) ||
12697 + ((mode & VS_WATCH) && (cid == 1)) ||
12698 + ((mode & VS_HOSTID) && (id == 0)));
12701 +#define vx_task_xid(t) ((t)->xid)
12703 +#define vx_current_xid() vx_task_xid(current)
12705 +#define current_vx_info() (current->vx_info)
12708 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
12710 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
12713 +#define nx_task_nid(t) ((t)->nid)
12715 +#define nx_current_nid() nx_task_nid(current)
12717 +#define current_nx_info() (current->nx_info)
12720 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
12722 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
12726 +/* generic flag merging */
12728 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
12730 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
12732 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
12734 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
12737 +/* context flags */
12739 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
12741 +#define vx_current_flags() __vx_flags(current->vx_info)
12743 +#define vx_info_flags(v, m, f) \
12744 + vs_check_flags(__vx_flags(v), m, f)
12746 +#define task_vx_flags(t, m, f) \
12747 + ((t) && vx_info_flags((t)->vx_info, m, f))
12749 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
12752 +/* context caps */
12754 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
12756 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
12758 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
12760 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
12764 +/* network flags */
12766 +#define __nx_flags(v) ((v) ? (v)->nx_flags : 0)
12768 +#define nx_current_flags() __nx_flags(current->nx_info)
12770 +#define nx_info_flags(v, m, f) \
12771 + vs_check_flags(__nx_flags(v), m, f)
12773 +#define task_nx_flags(t, m, f) \
12774 + ((t) && nx_info_flags((t)->nx_info, m, f))
12776 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
12779 +/* network caps */
12781 +#define __nx_ncaps(v) ((v) ? (v)->nx_ncaps : 0)
12783 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
12785 +#define nx_info_ncaps(v, c) (__nx_ncaps(v) & (c))
12787 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
12790 +/* context mask capabilities */
12792 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
12794 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
12796 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
12799 +/* context bcap mask */
12801 +#define __vx_bcaps(v) ((v) ? (v)->vx_bcaps : ~0 )
12803 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
12805 +#define vx_info_bcaps(v, c) (__vx_bcaps(v) & (c))
12807 +#define vx_bcaps(c) vx_info_bcaps(current->vx_info, c)
12810 +#define vx_info_cap_bset(v) ((v) ? (v)->vx_cap_bset : cap_bset)
12812 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
12815 +#define __vx_info_mbcap(v, b) \
12816 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
12817 + vx_info_bcaps(v, b) : (b))
12819 +#define vx_info_mbcap(v, b) __vx_info_mbcap(v, cap_t(b))
12821 +#define task_vx_mbcap(t, b) \
12822 + vx_info_mbcap((t)->vx_info, (t)->b)
12824 +#define vx_mbcap(b) task_vx_mbcap(current, b)
12826 +#define vx_cap_raised(v, c, f) (vx_info_mbcap(v, c) & CAP_TO_MASK(f))
12828 +#define vx_capable(b, c) (capable(b) || \
12829 + (cap_raised(current->cap_effective, b) && vx_ccaps(c)))
12832 +#define vx_current_initpid(n) \
12833 + (current->vx_info && \
12834 + (current->vx_info->vx_initpid == (n)))
12837 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
12839 +#define vx_info_state(v, m) (__vx_state(v) & (m))
12842 +#define __nx_state(v) ((v) ? ((v)->nx_state) : 0)
12844 +#define nx_info_state(v, m) (__nx_state(v) & (m))
12847 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cacct.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cacct.h
12848 --- linux-2.6.22.10/include/linux/vserver/cacct.h 1970-01-01 01:00:00 +0100
12849 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cacct.h 2007-06-15 02:37:04 +0200
12851 +#ifndef _VX_CACCT_H
12852 +#define _VX_CACCT_H
12855 +enum sock_acc_field {
12856 + VXA_SOCK_UNSPEC = 0,
12862 + VXA_SOCK_SIZE /* array size */
12865 +#endif /* _VX_CACCT_H */
12866 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cacct_cmd.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cacct_cmd.h
12867 --- linux-2.6.22.10/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00 +0100
12868 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cacct_cmd.h 2007-06-15 02:37:04 +0200
12870 +#ifndef _VX_CACCT_CMD_H
12871 +#define _VX_CACCT_CMD_H
12874 +/* virtual host info name commands */
12876 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
12878 +struct vcmd_sock_stat_v0 {
12880 + uint32_t count[3];
12881 + uint64_t total[3];
12887 +#include <linux/compiler.h>
12889 +extern int vc_sock_stat(struct vx_info *, void __user *);
12891 +#endif /* __KERNEL__ */
12892 +#endif /* _VX_CACCT_CMD_H */
12893 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cacct_def.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cacct_def.h
12894 --- linux-2.6.22.10/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00 +0100
12895 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cacct_def.h 2007-06-15 02:37:04 +0200
12897 +#ifndef _VX_CACCT_DEF_H
12898 +#define _VX_CACCT_DEF_H
12900 +#include <asm/atomic.h>
12901 +#include <linux/vserver/cacct.h>
12904 +struct _vx_sock_acc {
12905 + atomic_long_t count;
12906 + atomic_long_t total;
12909 +/* context sub struct */
12911 +struct _vx_cacct {
12912 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
12913 + atomic_t slab[8];
12914 + atomic_t page[6][8];
12917 +#ifdef CONFIG_VSERVER_DEBUG
12919 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
12923 + printk("\t_vx_cacct:");
12924 + for (i = 0; i < 6; i++) {
12925 + struct _vx_sock_acc *ptr = cacct->sock[i];
12927 + printk("\t [%d] =", i);
12928 + for (j = 0; j < 3; j++) {
12929 + printk(" [%d] = %8lu, %8lu", j,
12930 + atomic_long_read(&ptr[j].count),
12931 + atomic_long_read(&ptr[j].total));
12939 +#endif /* _VX_CACCT_DEF_H */
12940 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cacct_int.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cacct_int.h
12941 --- linux-2.6.22.10/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00 +0100
12942 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cacct_int.h 2007-06-15 02:37:04 +0200
12944 +#ifndef _VX_CACCT_INT_H
12945 +#define _VX_CACCT_INT_H
12951 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
12953 + return atomic_long_read(&cacct->sock[type][pos].count);
12958 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
12960 + return atomic_long_read(&cacct->sock[type][pos].total);
12963 +#endif /* __KERNEL__ */
12964 +#endif /* _VX_CACCT_INT_H */
12965 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/context.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/context.h
12966 --- linux-2.6.22.10/include/linux/vserver/context.h 1970-01-01 01:00:00 +0100
12967 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/context.h 2007-06-15 02:37:04 +0200
12969 +#ifndef _VX_CONTEXT_H
12970 +#define _VX_CONTEXT_H
12972 +#include <linux/types.h>
12973 +#include <linux/capability.h>
12976 +#define VX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */
12978 +/* context flags */
12980 +#define VXF_INFO_SCHED 0x00000002
12981 +#define VXF_INFO_NPROC 0x00000004
12982 +#define VXF_INFO_PRIVATE 0x00000008
12984 +#define VXF_INFO_INIT 0x00000010
12985 +#define VXF_INFO_HIDE 0x00000020
12986 +#define VXF_INFO_ULIMIT 0x00000040
12987 +#define VXF_INFO_NSPACE 0x00000080
12989 +#define VXF_SCHED_HARD 0x00000100
12990 +#define VXF_SCHED_PRIO 0x00000200
12991 +#define VXF_SCHED_PAUSE 0x00000400
12993 +#define VXF_VIRT_MEM 0x00010000
12994 +#define VXF_VIRT_UPTIME 0x00020000
12995 +#define VXF_VIRT_CPU 0x00040000
12996 +#define VXF_VIRT_LOAD 0x00080000
12997 +#define VXF_VIRT_TIME 0x00100000
12999 +#define VXF_HIDE_MOUNT 0x01000000
13000 +#define VXF_HIDE_NETIF 0x02000000
13001 +#define VXF_HIDE_VINFO 0x04000000
13003 +#define VXF_STATE_SETUP (1ULL << 32)
13004 +#define VXF_STATE_INIT (1ULL << 33)
13005 +#define VXF_STATE_ADMIN (1ULL << 34)
13007 +#define VXF_SC_HELPER (1ULL << 36)
13008 +#define VXF_REBOOT_KILL (1ULL << 37)
13009 +#define VXF_PERSISTENT (1ULL << 38)
13011 +#define VXF_FORK_RSS (1ULL << 48)
13012 +#define VXF_PROLIFIC (1ULL << 49)
13014 +#define VXF_IGNEG_NICE (1ULL << 52)
13016 +#define VXF_ONE_TIME (0x0007ULL << 32)
13018 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
13021 +/* context migration */
13023 +#define VXM_SET_INIT 0x00000001
13024 +#define VXM_SET_REAPER 0x00000002
13026 +/* context caps */
13028 +#define VXC_CAP_MASK 0x00000000
13030 +#define VXC_SET_UTSNAME 0x00000001
13031 +#define VXC_SET_RLIMIT 0x00000002
13033 +#define VXC_RAW_ICMP 0x00000100
13034 +#define VXC_SYSLOG 0x00001000
13036 +#define VXC_SECURE_MOUNT 0x00010000
13037 +#define VXC_SECURE_REMOUNT 0x00020000
13038 +#define VXC_BINARY_MOUNT 0x00040000
13040 +#define VXC_QUOTA_CTL 0x00100000
13041 +#define VXC_ADMIN_MAPPER 0x00200000
13042 +#define VXC_ADMIN_CLOOP 0x00400000
13047 +#include <linux/list.h>
13048 +#include <linux/spinlock.h>
13049 +#include <linux/rcupdate.h>
13051 +#include "limit_def.h"
13052 +#include "sched_def.h"
13053 +#include "cvirt_def.h"
13054 +#include "cacct_def.h"
13056 +struct _vx_info_pc {
13057 + struct _vx_sched_pc sched_pc;
13058 + struct _vx_cvirt_pc cvirt_pc;
13062 + struct hlist_node vx_hlist; /* linked list of contexts */
13063 + xid_t vx_id; /* context id */
13064 + atomic_t vx_usecnt; /* usage count */
13065 + atomic_t vx_tasks; /* tasks count */
13066 + struct vx_info *vx_parent; /* parent context */
13067 + int vx_state; /* context state */
13069 + unsigned long vx_nsmask; /* assignment mask */
13070 + struct nsproxy *vx_nsproxy; /* private namespace */
13071 + struct fs_struct *vx_fs; /* private namespace fs */
13073 + uint64_t vx_flags; /* context flags */
13074 + uint64_t vx_bcaps; /* bounding caps (system) */
13075 + uint64_t vx_ccaps; /* context caps (vserver) */
13076 + kernel_cap_t vx_cap_bset; /* the guest's bset */
13078 + struct task_struct *vx_reaper; /* guest reaper process */
13079 + pid_t vx_initpid; /* PID of guest init */
13081 + struct _vx_limit limit; /* vserver limits */
13082 + struct _vx_sched sched; /* vserver scheduler */
13083 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
13084 + struct _vx_cacct cacct; /* context accounting */
13086 +#ifndef CONFIG_SMP
13087 + struct _vx_info_pc info_pc; /* per cpu data */
13089 + struct _vx_info_pc *ptr_pc; /* per cpu array */
13092 + wait_queue_head_t vx_wait; /* context exit waitqueue */
13093 + int reboot_cmd; /* last sys_reboot() cmd */
13094 + int exit_code; /* last process exit code */
13096 + char vx_name[65]; /* vserver name */
13099 +#ifndef CONFIG_SMP
13100 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
13101 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
13103 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
13104 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
13107 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
13110 +struct vx_info_save {
13111 + struct vx_info *vxi;
13116 +/* status flags */
13118 +#define VXS_HASHED 0x0001
13119 +#define VXS_PAUSED 0x0010
13120 +#define VXS_SHUTDOWN 0x0100
13121 +#define VXS_HELPER 0x1000
13122 +#define VXS_RELEASED 0x8000
13125 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
13126 +extern void release_vx_info(struct vx_info *, struct task_struct *);
13128 +extern struct vx_info *lookup_vx_info(int);
13129 +extern struct vx_info *lookup_or_create_vx_info(int);
13131 +extern int get_xid_list(int, unsigned int *, int);
13132 +extern int xid_is_hashed(xid_t);
13134 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
13136 +extern long vs_state_change(struct vx_info *, unsigned int);
13139 +#endif /* __KERNEL__ */
13140 +#endif /* _VX_CONTEXT_H */
13141 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/context_cmd.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/context_cmd.h
13142 --- linux-2.6.22.10/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00 +0100
13143 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/context_cmd.h 2007-06-15 02:37:04 +0200
13145 +#ifndef _VX_CONTEXT_CMD_H
13146 +#define _VX_CONTEXT_CMD_H
13149 +/* vinfo commands */
13151 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
13154 +extern int vc_task_xid(uint32_t, void __user *);
13156 +#endif /* __KERNEL__ */
13158 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
13160 +struct vcmd_vx_info_v0 {
13162 + uint32_t initpid;
13163 + /* more to come */
13167 +extern int vc_vx_info(struct vx_info *, void __user *);
13169 +#endif /* __KERNEL__ */
13171 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
13173 +struct vcmd_ctx_stat_v0 {
13176 + /* more to come */
13180 +extern int vc_ctx_stat(struct vx_info *, void __user *);
13182 +#endif /* __KERNEL__ */
13184 +/* context commands */
13186 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
13187 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
13189 +struct vcmd_ctx_create {
13190 + uint64_t flagword;
13193 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
13194 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
13196 +struct vcmd_ctx_migrate {
13197 + uint64_t flagword;
13201 +extern int vc_ctx_create(uint32_t, void __user *);
13202 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
13204 +#endif /* __KERNEL__ */
13207 +/* flag commands */
13209 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
13210 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
13212 +struct vcmd_ctx_flags_v0 {
13213 + uint64_t flagword;
13218 +extern int vc_get_cflags(struct vx_info *, void __user *);
13219 +extern int vc_set_cflags(struct vx_info *, void __user *);
13221 +#endif /* __KERNEL__ */
13224 +/* context caps commands */
13226 +#define VCMD_get_ccaps_v0 VC_CMD(FLAGS, 3, 0)
13227 +#define VCMD_set_ccaps_v0 VC_CMD(FLAGS, 4, 0)
13229 +struct vcmd_ctx_caps_v0 {
13235 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
13236 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
13238 +struct vcmd_ctx_caps_v1 {
13244 +extern int vc_get_ccaps_v0(struct vx_info *, void __user *);
13245 +extern int vc_set_ccaps_v0(struct vx_info *, void __user *);
13246 +extern int vc_get_ccaps(struct vx_info *, void __user *);
13247 +extern int vc_set_ccaps(struct vx_info *, void __user *);
13249 +#endif /* __KERNEL__ */
13252 +/* bcaps commands */
13254 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
13255 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
13257 +struct vcmd_bcaps {
13263 +extern int vc_get_bcaps(struct vx_info *, void __user *);
13264 +extern int vc_set_bcaps(struct vx_info *, void __user *);
13266 +#endif /* __KERNEL__ */
13267 +#endif /* _VX_CONTEXT_CMD_H */
13268 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cvirt.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cvirt.h
13269 --- linux-2.6.22.10/include/linux/vserver/cvirt.h 1970-01-01 01:00:00 +0100
13270 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cvirt.h 2007-06-15 02:37:04 +0200
13272 +#ifndef _VX_CVIRT_H
13273 +#define _VX_CVIRT_H
13280 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13285 +void vx_update_load(struct vx_info *);
13288 +int vx_do_syslog(int, char __user *, int);
13290 +#endif /* __KERNEL__ */
13291 +#endif /* _VX_CVIRT_H */
13292 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cvirt_cmd.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cvirt_cmd.h
13293 --- linux-2.6.22.10/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00 +0100
13294 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cvirt_cmd.h 2007-06-15 02:37:04 +0200
13296 +#ifndef _VX_CVIRT_CMD_H
13297 +#define _VX_CVIRT_CMD_H
13300 +/* virtual host info name commands */
13302 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
13303 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
13305 +struct vcmd_vhi_name_v0 {
13311 +enum vhi_name_field {
13312 + VHIN_CONTEXT = 0,
13324 +#include <linux/compiler.h>
13326 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
13327 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
13329 +#endif /* __KERNEL__ */
13331 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
13333 +struct vcmd_virt_stat_v0 {
13336 + uint32_t nr_threads;
13337 + uint32_t nr_running;
13338 + uint32_t nr_uninterruptible;
13339 + uint32_t nr_onhold;
13340 + uint32_t nr_forks;
13341 + uint32_t load[3];
13345 +extern int vc_virt_stat(struct vx_info *, void __user *);
13347 +#endif /* __KERNEL__ */
13348 +#endif /* _VX_CVIRT_CMD_H */
13349 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cvirt_def.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cvirt_def.h
13350 --- linux-2.6.22.10/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00 +0100
13351 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/cvirt_def.h 2007-06-15 02:37:04 +0200
13353 +#ifndef _VX_CVIRT_DEF_H
13354 +#define _VX_CVIRT_DEF_H
13356 +#include <linux/jiffies.h>
13357 +#include <linux/spinlock.h>
13358 +#include <linux/wait.h>
13359 +#include <linux/time.h>
13360 +#include <linux/utsname.h>
13361 +#include <asm/atomic.h>
13364 +struct _vx_usage_stat {
13368 + uint64_t softirq;
13374 +struct _vx_syslog {
13375 + wait_queue_head_t log_wait;
13376 + spinlock_t logbuf_lock; /* lock for the log buffer */
13378 + unsigned long log_start; /* next char to be read by syslog() */
13379 + unsigned long con_start; /* next char to be sent to consoles */
13380 + unsigned long log_end; /* most-recently-written-char + 1 */
13381 + unsigned long logged_chars; /* #chars since last read+clear operation */
13383 + char log_buf[1024];
13387 +/* context sub struct */
13389 +struct _vx_cvirt {
13390 + atomic_t nr_threads; /* number of current threads */
13391 + atomic_t nr_running; /* number of running threads */
13392 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
13394 + atomic_t nr_onhold; /* processes on hold */
13395 + uint32_t onhold_last; /* jiffies when put on hold */
13397 + struct timeval bias_tv; /* time offset to the host */
13398 + struct timespec bias_idle;
13399 + struct timespec bias_uptime; /* context creation point */
13400 + uint64_t bias_clock; /* offset in clock_t */
13402 + spinlock_t load_lock; /* lock for the load averages */
13403 + atomic_t load_updates; /* nr of load updates done so far */
13404 + uint32_t load_last; /* last time load was calculated */
13405 + uint32_t load[3]; /* load averages 1,5,15 */
13407 + atomic_t total_forks; /* number of forks so far */
13409 + struct _vx_syslog syslog;
13412 +struct _vx_cvirt_pc {
13413 + struct _vx_usage_stat cpustat;
13417 +#ifdef CONFIG_VSERVER_DEBUG
13419 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
13421 + printk("\t_vx_cvirt:\n");
13422 + printk("\t threads: %4d, %4d, %4d, %4d\n",
13423 + atomic_read(&cvirt->nr_threads),
13424 + atomic_read(&cvirt->nr_running),
13425 + atomic_read(&cvirt->nr_uninterruptible),
13426 + atomic_read(&cvirt->nr_onhold));
13427 + /* add rest here */
13428 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
13433 +#endif /* _VX_CVIRT_DEF_H */
13434 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/debug.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/debug.h
13435 --- linux-2.6.22.10/include/linux/vserver/debug.h 1970-01-01 01:00:00 +0100
13436 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/debug.h 2007-10-29 23:39:46 +0100
13438 +#ifndef _VX_DEBUG_H
13439 +#define _VX_DEBUG_H
13442 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
13443 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
13444 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
13446 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
13447 + imajor((d)->bd_inode), iminor((d)->bd_inode)
13448 +#define VXF_DEV "%p[%lu,%d:%d]"
13451 +#define __FUNC__ __func__
13454 +#define vxd_path(d, m) \
13455 + ({ static char _buffer[PATH_MAX]; \
13456 + d_path(d, m, _buffer, sizeof(_buffer)); })
13458 +#define vxd_cond_path(n) \
13459 + ((n) ? vxd_path((n)->dentry, (n)->mnt) : "<null>" )
13462 +#ifdef CONFIG_VSERVER_DEBUG
13464 +extern unsigned int vx_debug_switch;
13465 +extern unsigned int vx_debug_xid;
13466 +extern unsigned int vx_debug_nid;
13467 +extern unsigned int vx_debug_tag;
13468 +extern unsigned int vx_debug_net;
13469 +extern unsigned int vx_debug_limit;
13470 +extern unsigned int vx_debug_cres;
13471 +extern unsigned int vx_debug_dlim;
13472 +extern unsigned int vx_debug_quota;
13473 +extern unsigned int vx_debug_cvirt;
13474 +extern unsigned int vx_debug_space;
13475 +extern unsigned int vx_debug_misc;
13478 +#define VX_LOGLEVEL "vxD: "
13480 +#define vxdprintk(c, f, x...) \
13483 + printk(VX_LOGLEVEL f "\n" , ##x); \
13486 +#define vxlprintk(c, f, x...) \
13489 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
13492 +#define vxfprintk(c, f, x...) \
13495 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
13501 +void dump_vx_info(struct vx_info *, int);
13502 +void dump_vx_info_inactive(int);
13504 +#else /* CONFIG_VSERVER_DEBUG */
13506 +#define vx_debug_switch 0
13507 +#define vx_debug_xid 0
13508 +#define vx_debug_nid 0
13509 +#define vx_debug_tag 0
13510 +#define vx_debug_net 0
13511 +#define vx_debug_limit 0
13512 +#define vx_debug_cres 0
13513 +#define vx_debug_dlim 0
13514 +#define vx_debug_cvirt 0
13516 +#define vxdprintk(x...) do { } while (0)
13517 +#define vxlprintk(x...) do { } while (0)
13518 +#define vxfprintk(x...) do { } while (0)
13520 +#endif /* CONFIG_VSERVER_DEBUG */
13523 +#ifdef CONFIG_VSERVER_WARN
13525 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
13526 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u] "
13527 +#define VX_WARN_XID "[xid #%u] "
13528 +#define VX_WARN_NID "[nid #%u] "
13530 +#define vxwprintk(c, f, x...) \
13533 + printk(VX_WARNLEVEL f "\n", ##x); \
13536 +#else /* CONFIG_VSERVER_WARN */
13538 +#define vxwprintk(x...) do { } while (0)
13540 +#endif /* CONFIG_VSERVER_WARN */
13542 +#define vxwprintk_task(c, f, x...) \
13543 + vxwprintk(c, VX_WARN_TASK f, \
13544 + current->comm, current->pid, \
13545 + current->xid, current->nid, ##x)
13546 +#define vxwprintk_xid(c, f, x...) \
13547 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
13548 +#define vxwprintk_nid(c, f, x...) \
13549 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
13551 +#ifdef CONFIG_VSERVER_DEBUG
13552 +#define vxd_assert_lock(l) assert_spin_locked(l)
13553 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
13554 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
13556 +#define vxd_assert_lock(l) do { } while (0)
13557 +#define vxd_assert(c, f, x...) do { } while (0)
13561 +#endif /* _VX_DEBUG_H */
13562 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/debug_cmd.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/debug_cmd.h
13563 --- linux-2.6.22.10/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00 +0100
13564 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/debug_cmd.h 2007-06-15 02:37:04 +0200
13566 +#ifndef _VX_DEBUG_CMD_H
13567 +#define _VX_DEBUG_CMD_H
13570 +/* debug commands */
13572 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
13574 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
13575 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
13577 +struct vcmd_read_history_v0 {
13580 + char __user *data;
13583 +struct vcmd_read_monitor_v0 {
13586 + char __user *data;
13592 +#ifdef CONFIG_COMPAT
13594 +#include <asm/compat.h>
13596 +struct vcmd_read_history_v0_x32 {
13599 + compat_uptr_t data_ptr;
13602 +struct vcmd_read_monitor_v0_x32 {
13605 + compat_uptr_t data_ptr;
13608 +#endif /* CONFIG_COMPAT */
13610 +extern int vc_dump_history(uint32_t);
13612 +extern int vc_read_history(uint32_t, void __user *);
13613 +extern int vc_read_monitor(uint32_t, void __user *);
13615 +#ifdef CONFIG_COMPAT
13617 +extern int vc_read_history_x32(uint32_t, void __user *);
13618 +extern int vc_read_monitor_x32(uint32_t, void __user *);
13620 +#endif /* CONFIG_COMPAT */
13622 +#endif /* __KERNEL__ */
13623 +#endif /* _VX_DEBUG_CMD_H */
13624 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/dlimit.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/dlimit.h
13625 --- linux-2.6.22.10/include/linux/vserver/dlimit.h 1970-01-01 01:00:00 +0100
13626 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/dlimit.h 2007-06-15 02:37:04 +0200
13628 +#ifndef _VX_DLIMIT_H
13629 +#define _VX_DLIMIT_H
13631 +#include "switch.h"
13636 +/* keep in sync with CDLIM_INFINITY */
13638 +#define DLIM_INFINITY (~0ULL)
13640 +#include <linux/spinlock.h>
13642 +struct super_block;
13645 + struct hlist_node dl_hlist; /* linked list of contexts */
13646 + struct rcu_head dl_rcu; /* the rcu head */
13647 + tag_t dl_tag; /* context tag */
13648 + atomic_t dl_usecnt; /* usage count */
13649 + atomic_t dl_refcnt; /* reference count */
13651 + struct super_block *dl_sb; /* associated superblock */
13653 + spinlock_t dl_lock; /* protect the values */
13655 + unsigned long long dl_space_used; /* used space in bytes */
13656 + unsigned long long dl_space_total; /* maximum space in bytes */
13657 + unsigned long dl_inodes_used; /* used inodes */
13658 + unsigned long dl_inodes_total; /* maximum inodes */
13660 + unsigned int dl_nrlmult; /* non root limit mult */
13665 +extern void rcu_free_dl_info(struct rcu_head *);
13666 +extern void unhash_dl_info(struct dl_info *);
13668 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
13673 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
13675 +typedef uint64_t dlsize_t;
13677 +#endif /* __KERNEL__ */
13678 +#else /* _VX_DLIMIT_H */
13679 +#warning duplicate inclusion
13680 +#endif /* _VX_DLIMIT_H */
13681 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/dlimit_cmd.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/dlimit_cmd.h
13682 --- linux-2.6.22.10/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00 +0100
13683 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/dlimit_cmd.h 2007-06-15 02:37:04 +0200
13685 +#ifndef _VX_DLIMIT_CMD_H
13686 +#define _VX_DLIMIT_CMD_H
13689 +/* dlimit vserver commands */
13691 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
13692 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
13694 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
13695 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
13697 +struct vcmd_ctx_dlimit_base_v0 {
13698 + const char __user *name;
13702 +struct vcmd_ctx_dlimit_v0 {
13703 + const char __user *name;
13704 + uint32_t space_used; /* used space in kbytes */
13705 + uint32_t space_total; /* maximum space in kbytes */
13706 + uint32_t inodes_used; /* used inodes */
13707 + uint32_t inodes_total; /* maximum inodes */
13708 + uint32_t reserved; /* reserved for root in % */
13712 +#define CDLIM_UNSET ((uint32_t)0UL)
13713 +#define CDLIM_INFINITY ((uint32_t)~0UL)
13714 +#define CDLIM_KEEP ((uint32_t)~1UL)
13718 +#ifdef CONFIG_COMPAT
13720 +#include <asm/compat.h>
13722 +struct vcmd_ctx_dlimit_base_v0_x32 {
13723 + compat_uptr_t name_ptr;
13727 +struct vcmd_ctx_dlimit_v0_x32 {
13728 + compat_uptr_t name_ptr;
13729 + uint32_t space_used; /* used space in kbytes */
13730 + uint32_t space_total; /* maximum space in kbytes */
13731 + uint32_t inodes_used; /* used inodes */
13732 + uint32_t inodes_total; /* maximum inodes */
13733 + uint32_t reserved; /* reserved for root in % */
13737 +#endif /* CONFIG_COMPAT */
13739 +#include <linux/compiler.h>
13741 +extern int vc_add_dlimit(uint32_t, void __user *);
13742 +extern int vc_rem_dlimit(uint32_t, void __user *);
13744 +extern int vc_set_dlimit(uint32_t, void __user *);
13745 +extern int vc_get_dlimit(uint32_t, void __user *);
13747 +#ifdef CONFIG_COMPAT
13749 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
13750 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
13752 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
13753 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
13755 +#endif /* CONFIG_COMPAT */
13757 +#endif /* __KERNEL__ */
13758 +#endif /* _VX_DLIMIT_CMD_H */
13759 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/global.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/global.h
13760 --- linux-2.6.22.10/include/linux/vserver/global.h 1970-01-01 01:00:00 +0100
13761 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/global.h 2007-06-15 02:37:04 +0200
13763 +#ifndef _VX_GLOBAL_H
13764 +#define _VX_GLOBAL_H
13767 +extern atomic_t vx_global_ctotal;
13768 +extern atomic_t vx_global_cactive;
13770 +extern atomic_t nx_global_ctotal;
13771 +extern atomic_t nx_global_cactive;
13773 +extern atomic_t vs_global_nsproxy;
13774 +extern atomic_t vs_global_fs;
13775 +extern atomic_t vs_global_mnt_ns;
13776 +extern atomic_t vs_global_uts_ns;
13777 +extern atomic_t vs_global_ipc_ns;
13780 +#endif /* _VX_GLOBAL_H */
13781 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/history.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/history.h
13782 --- linux-2.6.22.10/include/linux/vserver/history.h 1970-01-01 01:00:00 +0100
13783 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/history.h 2007-06-15 02:37:04 +0200
13785 +#ifndef _VX_HISTORY_H
13786 +#define _VX_HISTORY_H
13791 + VXH_THROW_OOPS = 1,
13795 + VXH_INIT_VX_INFO,
13798 + VXH_CLAIM_VX_INFO,
13799 + VXH_RELEASE_VX_INFO,
13800 + VXH_ALLOC_VX_INFO,
13801 + VXH_DEALLOC_VX_INFO,
13802 + VXH_HASH_VX_INFO,
13803 + VXH_UNHASH_VX_INFO,
13805 + VXH_LOOKUP_VX_INFO,
13806 + VXH_CREATE_VX_INFO,
13809 +struct _vxhe_vxi {
13810 + struct vx_info *ptr;
13816 +struct _vxhe_set_clr {
13820 +struct _vxhe_loc_lookup {
13824 +struct _vx_hist_entry {
13826 + unsigned short seq;
13827 + unsigned short type;
13828 + struct _vxhe_vxi vxi;
13830 + struct _vxhe_set_clr sc;
13831 + struct _vxhe_loc_lookup ll;
13835 +#ifdef CONFIG_VSERVER_HISTORY
13837 +extern unsigned volatile int vxh_active;
13839 +struct _vx_hist_entry *vxh_advance(void *loc);
13843 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
13845 + entry->vxi.ptr = vxi;
13847 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
13848 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
13849 + entry->vxi.xid = vxi->vx_id;
13854 +#define __HERE__ current_text_addr()
13856 +#define __VXH_BODY(__type, __data, __here) \
13857 + struct _vx_hist_entry *entry; \
13859 + preempt_disable(); \
13860 + entry = vxh_advance(__here); \
13862 + entry->type = __type; \
13863 + preempt_enable();
13866 + /* pass vxi only */
13868 +#define __VXH_SMPL \
13869 + __vxh_copy_vxi(entry, vxi)
13872 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
13874 + __VXH_BODY(__type, __VXH_SMPL, __here)
13877 + /* pass vxi and data (void *) */
13879 +#define __VXH_DATA \
13880 + __vxh_copy_vxi(entry, vxi); \
13881 + entry->sc.data = data
13884 +void __vxh_data(struct vx_info *vxi, void *data,
13885 + int __type, void *__here)
13887 + __VXH_BODY(__type, __VXH_DATA, __here)
13890 + /* pass vxi and arg (long) */
13892 +#define __VXH_LONG \
13893 + __vxh_copy_vxi(entry, vxi); \
13894 + entry->ll.arg = arg
13897 +void __vxh_long(struct vx_info *vxi, long arg,
13898 + int __type, void *__here)
13900 + __VXH_BODY(__type, __VXH_LONG, __here)
13905 +void __vxh_throw_oops(void *__here)
13907 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
13908 + /* prevent further acquisition */
13913 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
13915 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
13916 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
13918 +#define __vxh_init_vx_info(v, d, h) \
13919 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
13920 +#define __vxh_set_vx_info(v, d, h) \
13921 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
13922 +#define __vxh_clr_vx_info(v, d, h) \
13923 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
13925 +#define __vxh_claim_vx_info(v, d, h) \
13926 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
13927 +#define __vxh_release_vx_info(v, d, h) \
13928 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
13930 +#define vxh_alloc_vx_info(v) \
13931 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
13932 +#define vxh_dealloc_vx_info(v) \
13933 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
13935 +#define vxh_hash_vx_info(v) \
13936 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
13937 +#define vxh_unhash_vx_info(v) \
13938 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
13940 +#define vxh_loc_vx_info(v, l) \
13941 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
13942 +#define vxh_lookup_vx_info(v, l) \
13943 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
13944 +#define vxh_create_vx_info(v, l) \
13945 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
13947 +extern void vxh_dump_history(void);
13950 +#else /* CONFIG_VSERVER_HISTORY */
13952 +#define __HERE__ 0
13954 +#define vxh_throw_oops() do { } while (0)
13956 +#define __vxh_get_vx_info(v, h) do { } while (0)
13957 +#define __vxh_put_vx_info(v, h) do { } while (0)
13959 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
13960 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
13961 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
13963 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
13964 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
13966 +#define vxh_alloc_vx_info(v) do { } while (0)
13967 +#define vxh_dealloc_vx_info(v) do { } while (0)
13969 +#define vxh_hash_vx_info(v) do { } while (0)
13970 +#define vxh_unhash_vx_info(v) do { } while (0)
13972 +#define vxh_loc_vx_info(v, l) do { } while (0)
13973 +#define vxh_lookup_vx_info(v, l) do { } while (0)
13974 +#define vxh_create_vx_info(v, l) do { } while (0)
13976 +#define vxh_dump_history() do { } while (0)
13979 +#endif /* CONFIG_VSERVER_HISTORY */
13981 +#endif /* _VX_HISTORY_H */
13982 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/inode.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/inode.h
13983 --- linux-2.6.22.10/include/linux/vserver/inode.h 1970-01-01 01:00:00 +0100
13984 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/inode.h 2007-06-15 02:37:04 +0200
13986 +#ifndef _VX_INODE_H
13987 +#define _VX_INODE_H
13990 +#define IATTR_TAG 0x01000000
13992 +#define IATTR_ADMIN 0x00000001
13993 +#define IATTR_WATCH 0x00000002
13994 +#define IATTR_HIDE 0x00000004
13995 +#define IATTR_FLAGS 0x00000007
13997 +#define IATTR_BARRIER 0x00010000
13998 +#define IATTR_IUNLINK 0x00020000
13999 +#define IATTR_IMMUTABLE 0x00040000
14004 +#ifdef CONFIG_VSERVER_PROC_SECURE
14005 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
14006 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
14008 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
14009 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
14012 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
14014 +#endif /* __KERNEL__ */
14016 +/* inode ioctls */
14018 +#define FIOC_GETXFLG _IOR('x', 5, long)
14019 +#define FIOC_SETXFLG _IOW('x', 6, long)
14021 +#else /* _VX_INODE_H */
14022 +#warning duplicate inclusion
14023 +#endif /* _VX_INODE_H */
14024 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/inode_cmd.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/inode_cmd.h
14025 --- linux-2.6.22.10/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00 +0100
14026 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/inode_cmd.h 2007-07-16 06:38:22 +0200
14028 +#ifndef _VX_INODE_CMD_H
14029 +#define _VX_INODE_CMD_H
14032 +/* inode vserver commands */
14034 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
14035 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
14037 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
14038 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
14040 +struct vcmd_ctx_iattr_v1 {
14041 + const char __user *name;
14047 +struct vcmd_ctx_fiattr_v0 {
14057 +#ifdef CONFIG_COMPAT
14059 +#include <asm/compat.h>
14061 +struct vcmd_ctx_iattr_v1_x32 {
14062 + compat_uptr_t name_ptr;
14068 +#endif /* CONFIG_COMPAT */
14070 +#include <linux/compiler.h>
14072 +extern int vc_get_iattr(void __user *);
14073 +extern int vc_set_iattr(void __user *);
14075 +extern int vc_fget_iattr(uint32_t, void __user *);
14076 +extern int vc_fset_iattr(uint32_t, void __user *);
14078 +#ifdef CONFIG_COMPAT
14080 +extern int vc_get_iattr_x32(void __user *);
14081 +extern int vc_set_iattr_x32(void __user *);
14083 +#endif /* CONFIG_COMPAT */
14085 +#endif /* __KERNEL__ */
14086 +#endif /* _VX_INODE_CMD_H */
14087 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/legacy.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/legacy.h
14088 --- linux-2.6.22.10/include/linux/vserver/legacy.h 1970-01-01 01:00:00 +0100
14089 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/legacy.h 2007-06-15 02:37:04 +0200
14091 +#ifndef _VX_LEGACY_H
14092 +#define _VX_LEGACY_H
14094 +#include "switch.h"
14097 +/* compatibiliy vserver commands */
14099 +#define VCMD_new_s_context VC_CMD(COMPAT, 1, 1)
14100 +#define VCMD_set_ipv4root VC_CMD(COMPAT, 2, 3)
14102 +#define VCMD_create_context VC_CMD(VSETUP, 1, 0)
14104 +/* compatibiliy vserver arguments */
14106 +struct vcmd_new_s_context_v1 {
14107 + uint32_t remove_cap;
14111 +struct vcmd_set_ipv4root_v3 {
14112 + /* number of pairs in id */
14113 + uint32_t broadcast;
14117 + } nx_mask_pair[NB_IPV4ROOT];
14121 +#define VX_INFO_LOCK 1 /* Can't request a new vx_id */
14122 +#define VX_INFO_NPROC 4 /* Limit number of processes in a context */
14123 +#define VX_INFO_PRIVATE 8 /* Noone can join this security context */
14124 +#define VX_INFO_INIT 16 /* This process wants to become the */
14125 + /* logical process 1 of the security */
14127 +#define VX_INFO_HIDEINFO 32 /* Hide some information in /proc */
14128 +#define VX_INFO_ULIMIT 64 /* Use ulimit of the current process */
14129 + /* to become the global limits */
14130 + /* of the context */
14131 +#define VX_INFO_NAMESPACE 128 /* save private namespace */
14135 +extern int vc_new_s_context(uint32_t, void __user *);
14136 +extern int vc_set_ipv4root(uint32_t, void __user *);
14138 +#endif /* __KERNEL__ */
14139 +#endif /* _VX_LEGACY_H */
14140 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/limit.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/limit.h
14141 --- linux-2.6.22.10/include/linux/vserver/limit.h 1970-01-01 01:00:00 +0100
14142 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/limit.h 2007-06-15 02:37:04 +0200
14144 +#ifndef _VX_LIMIT_H
14145 +#define _VX_LIMIT_H
14148 +#define VLIMIT_NSOCK 16
14149 +#define VLIMIT_OPENFD 17
14150 +#define VLIMIT_ANON 18
14151 +#define VLIMIT_SHMEM 19
14152 +#define VLIMIT_SEMARY 20
14153 +#define VLIMIT_NSEMS 21
14154 +#define VLIMIT_DENTRY 22
14155 +#define VLIMIT_MAPPED 23
14160 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
14162 +/* keep in sync with CRLIM_INFINITY */
14164 +#define VLIM_INFINITY (~0ULL)
14166 +#ifndef RLIM_INFINITY
14167 +#warning RLIM_INFINITY is undefined
14170 +#define __rlim_val(l, r, v) ((l)->res[r].v)
14172 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
14173 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
14175 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
14176 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
14177 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
14179 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
14180 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
14182 +typedef atomic_long_t rlim_atomic_t;
14183 +typedef unsigned long rlim_t;
14185 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
14186 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
14187 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
14188 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
14189 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
14190 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
14193 +#if (RLIM_INFINITY == VLIM_INFINITY)
14194 +#define VX_VLIM(r) ((long long)(long)(r))
14195 +#define VX_RLIM(v) ((rlim_t)(v))
14197 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
14198 + ? VLIM_INFINITY : (long long)(r))
14199 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
14200 + ? RLIM_INFINITY : (rlim_t)(v))
14205 +void vx_vsi_meminfo(struct sysinfo *);
14206 +void vx_vsi_swapinfo(struct sysinfo *);
14208 +#define NUM_LIMITS 24
14210 +#endif /* __KERNEL__ */
14211 +#endif /* _VX_LIMIT_H */
14212 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/limit_cmd.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/limit_cmd.h
14213 --- linux-2.6.22.10/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00 +0100
14214 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/limit_cmd.h 2007-06-15 02:37:04 +0200
14216 +#ifndef _VX_LIMIT_CMD_H
14217 +#define _VX_LIMIT_CMD_H
14220 +/* rlimit vserver commands */
14222 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
14223 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
14224 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
14225 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
14227 +struct vcmd_ctx_rlimit_v0 {
14229 + uint64_t minimum;
14230 + uint64_t softlimit;
14231 + uint64_t maximum;
14234 +struct vcmd_ctx_rlimit_mask_v0 {
14235 + uint32_t minimum;
14236 + uint32_t softlimit;
14237 + uint32_t maximum;
14240 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
14242 +struct vcmd_rlimit_stat_v0 {
14246 + uint64_t minimum;
14247 + uint64_t maximum;
14250 +#define CRLIM_UNSET (0ULL)
14251 +#define CRLIM_INFINITY (~0ULL)
14252 +#define CRLIM_KEEP (~1ULL)
14256 +#ifdef CONFIG_IA32_EMULATION
14258 +struct vcmd_ctx_rlimit_v0_x32 {
14260 + uint64_t minimum;
14261 + uint64_t softlimit;
14262 + uint64_t maximum;
14263 +} __attribute__ ((aligned (4)));
14265 +#endif /* CONFIG_IA32_EMULATION */
14267 +#include <linux/compiler.h>
14269 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
14270 +extern int vc_get_rlimit(struct vx_info *, void __user *);
14271 +extern int vc_set_rlimit(struct vx_info *, void __user *);
14272 +extern int vc_reset_minmax(struct vx_info *, void __user *);
14274 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
14276 +#ifdef CONFIG_IA32_EMULATION
14278 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
14279 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
14281 +#endif /* CONFIG_IA32_EMULATION */
14283 +#endif /* __KERNEL__ */
14284 +#endif /* _VX_LIMIT_CMD_H */
14285 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/limit_def.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/limit_def.h
14286 --- linux-2.6.22.10/include/linux/vserver/limit_def.h 1970-01-01 01:00:00 +0100
14287 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/limit_def.h 2007-06-15 02:37:04 +0200
14289 +#ifndef _VX_LIMIT_DEF_H
14290 +#define _VX_LIMIT_DEF_H
14292 +#include <asm/atomic.h>
14293 +#include <asm/resource.h>
14295 +#include "limit.h"
14298 +struct _vx_res_limit {
14299 + rlim_t soft; /* Context soft limit */
14300 + rlim_t hard; /* Context hard limit */
14302 + rlim_atomic_t rcur; /* Current value */
14303 + rlim_t rmin; /* Context minimum */
14304 + rlim_t rmax; /* Context maximum */
14306 + atomic_t lhit; /* Limit hits */
14309 +/* context sub struct */
14311 +struct _vx_limit {
14312 + struct _vx_res_limit res[NUM_LIMITS];
14315 +#ifdef CONFIG_VSERVER_DEBUG
14317 +static inline void __dump_vx_limit(struct _vx_limit *limit)
14321 + printk("\t_vx_limit:");
14322 + for (i = 0; i < NUM_LIMITS; i++) {
14323 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
14324 + i, (unsigned long)__rlim_get(limit, i),
14325 + (unsigned long)__rlim_rmin(limit, i),
14326 + (unsigned long)__rlim_rmax(limit, i),
14327 + (long)__rlim_soft(limit, i),
14328 + (long)__rlim_hard(limit, i),
14329 + atomic_read(&__rlim_lhit(limit, i)));
14335 +#endif /* _VX_LIMIT_DEF_H */
14336 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/limit_int.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/limit_int.h
14337 --- linux-2.6.22.10/include/linux/vserver/limit_int.h 1970-01-01 01:00:00 +0100
14338 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/limit_int.h 2007-06-15 02:37:04 +0200
14340 +#ifndef _VX_LIMIT_INT_H
14341 +#define _VX_LIMIT_INT_H
14343 +#include "context.h"
14347 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
14348 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
14350 +extern const char *vlimit_name[NUM_LIMITS];
14352 +static inline void __vx_acc_cres(struct vx_info *vxi,
14353 + int res, int dir, void *_data, char *_file, int _line)
14355 + if (VXD_RCRES_COND(res))
14356 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
14357 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14358 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14359 + (dir > 0) ? "++" : "--", _data, _file, _line);
14364 + __rlim_inc(&vxi->limit, res);
14366 + __rlim_dec(&vxi->limit, res);
14369 +static inline void __vx_add_cres(struct vx_info *vxi,
14370 + int res, int amount, void *_data, char *_file, int _line)
14372 + if (VXD_RCRES_COND(res))
14373 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
14374 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14375 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14376 + amount, _data, _file, _line);
14381 + __rlim_add(&vxi->limit, res, amount);
14385 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
14387 + int cond = (value > __rlim_rmax(limit, res));
14390 + __rlim_rmax(limit, res) = value;
14395 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
14397 + int cond = (value < __rlim_rmin(limit, res));
14400 + __rlim_rmin(limit, res) = value;
14405 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
14407 + if (!__vx_cres_adjust_max(limit, res, value))
14408 + __vx_cres_adjust_min(limit, res, value);
14413 + +1 ... no limit hit
14414 + -1 ... over soft limit
14415 + 0 ... over hard limit */
14417 +static inline int __vx_cres_avail(struct vx_info *vxi,
14418 + int res, int num, char *_file, int _line)
14420 + struct _vx_limit *limit;
14423 + if (VXD_RLIMIT_COND(res))
14424 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
14425 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14426 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
14427 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
14428 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14429 + num, _file, _line);
14433 + limit = &vxi->limit;
14434 + value = __rlim_get(limit, res);
14436 + if (!__vx_cres_adjust_max(limit, res, value))
14437 + __vx_cres_adjust_min(limit, res, value);
14442 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
14444 + if (value + num <= __rlim_soft(limit, res))
14447 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
14449 + if (value + num <= __rlim_hard(limit, res))
14452 + __rlim_hit(limit, res);
14457 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
14460 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
14462 + rlim_t value, sum = 0;
14465 + while ((res = *array++)) {
14466 + value = __rlim_get(limit, res);
14467 + __vx_cres_fixup(limit, res, value);
14474 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
14476 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
14477 + int res = *array;
14479 + if (value == __rlim_get(limit, res))
14482 + __rlim_set(limit, res, value);
14483 + /* now adjust min/max */
14484 + if (!__vx_cres_adjust_max(limit, res, value))
14485 + __vx_cres_adjust_min(limit, res, value);
14490 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
14491 + const int *array, int num, char *_file, int _line)
14493 + struct _vx_limit *limit;
14494 + rlim_t value = 0;
14502 + limit = &vxi->limit;
14504 + value = __vx_cres_array_sum(limit, array + 1);
14506 + __rlim_set(limit, res, value);
14507 + __vx_cres_fixup(limit, res, value);
14509 + return __vx_cres_avail(vxi, res, num, _file, _line);
14513 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
14518 + /* complex resources first */
14519 + if ((id < 0) || (id == RLIMIT_RSS))
14520 + __vx_cres_array_fixup(limit, VLA_RSS);
14522 + for (res = 0; res < NUM_LIMITS; res++) {
14523 + if ((id > 0) && (res != id))
14526 + value = __rlim_get(limit, res);
14527 + __vx_cres_fixup(limit, res, value);
14529 + /* not supposed to happen, maybe warn? */
14530 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
14531 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
14536 +#endif /* __KERNEL__ */
14537 +#endif /* _VX_LIMIT_INT_H */
14538 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/monitor.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/monitor.h
14539 --- linux-2.6.22.10/include/linux/vserver/monitor.h 1970-01-01 01:00:00 +0100
14540 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/monitor.h 2007-06-15 02:37:04 +0200
14542 +#ifndef _VX_MONITOR_H
14543 +#define _VX_MONITOR_H
14551 + VXM_UPDATE = 0x20,
14555 + VXM_RQINFO_1 = 0x24,
14558 + VXM_ACTIVATE = 0x40,
14565 + VXM_MIGRATE = 0x48,
14568 + /* all other bits are flags */
14569 + VXM_SCHED = 0x80,
14572 +struct _vxm_update_1 {
14573 + uint32_t tokens_max;
14574 + uint32_t fill_rate;
14575 + uint32_t interval;
14578 +struct _vxm_update_2 {
14579 + uint32_t tokens_min;
14580 + uint32_t fill_rate;
14581 + uint32_t interval;
14584 +struct _vxm_rqinfo_1 {
14585 + uint16_t running;
14589 + uint32_t idle_tokens;
14592 +struct _vxm_rqinfo_2 {
14593 + uint32_t norm_time;
14594 + uint32_t idle_time;
14595 + uint32_t idle_skip;
14598 +struct _vxm_sched {
14600 + uint32_t norm_time;
14601 + uint32_t idle_time;
14604 +struct _vxm_task {
14609 +struct _vxm_event {
14618 + struct _vxm_task tsk;
14622 +struct _vx_mon_entry {
14626 + struct _vxm_event ev;
14627 + struct _vxm_sched sd;
14628 + struct _vxm_update_1 u1;
14629 + struct _vxm_update_2 u2;
14630 + struct _vxm_rqinfo_1 q1;
14631 + struct _vxm_rqinfo_2 q2;
14636 +#endif /* _VX_MONITOR_H */
14637 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/network.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/network.h
14638 --- linux-2.6.22.10/include/linux/vserver/network.h 1970-01-01 01:00:00 +0100
14639 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/network.h 2007-06-15 02:37:04 +0200
14641 +#ifndef _VX_NETWORK_H
14642 +#define _VX_NETWORK_H
14644 +#include <linux/types.h>
14647 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
14649 +#define NX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */
14651 +#define NB_IPV4ROOT 16
14654 +/* network flags */
14656 +#define NXF_INFO_PRIVATE 0x00000008
14658 +#define NXF_STATE_SETUP (1ULL << 32)
14659 +#define NXF_STATE_ADMIN (1ULL << 34)
14661 +#define NXF_SC_HELPER (1ULL << 36)
14662 +#define NXF_PERSISTENT (1ULL << 38)
14664 +#define NXF_ONE_TIME (0x0005ULL << 32)
14666 +#define NXF_INIT_SET (NXF_STATE_ADMIN)
14669 +/* address types */
14671 +#define NXA_TYPE_IPV4 1
14672 +#define NXA_TYPE_IPV6 2
14674 +#define NXA_MOD_BCAST (1 << 8)
14676 +#define NXA_TYPE_ANY ((uint16_t)-1)
14681 +#include <linux/list.h>
14682 +#include <linux/spinlock.h>
14683 +#include <linux/rcupdate.h>
14684 +#include <asm/atomic.h>
14688 + struct hlist_node nx_hlist; /* linked list of nxinfos */
14689 + nid_t nx_id; /* vnet id */
14690 + atomic_t nx_usecnt; /* usage count */
14691 + atomic_t nx_tasks; /* tasks count */
14692 + int nx_state; /* context state */
14694 + uint64_t nx_flags; /* network flag word */
14695 + uint64_t nx_ncaps; /* network capabilities */
14698 + __u32 ipv4[NB_IPV4ROOT]; /* Process can only bind to these IPs */
14699 + /* The first one is used to connect */
14700 + /* and for bind any service */
14701 + /* The other must be used explicity */
14702 + __u32 mask[NB_IPV4ROOT]; /* Netmask for each ipv4 */
14703 + /* Used to select the proper source */
14704 + /* address for sockets */
14705 + __u32 v4_bcast; /* Broadcast address to receive UDP */
14707 + char nx_name[65]; /* network context name */
14711 +/* status flags */
14713 +#define NXS_HASHED 0x0001
14714 +#define NXS_SHUTDOWN 0x0100
14715 +#define NXS_RELEASED 0x8000
14717 +/* check conditions */
14719 +#define NX_ADMIN 0x0001
14720 +#define NX_WATCH 0x0002
14721 +#define NX_BLEND 0x0004
14722 +#define NX_HOSTID 0x0008
14724 +#define NX_IDENT 0x0010
14725 +#define NX_EQUIV 0x0020
14726 +#define NX_PARENT 0x0040
14727 +#define NX_CHILD 0x0080
14729 +#define NX_ARG_MASK 0x00F0
14731 +#define NX_DYNAMIC 0x0100
14732 +#define NX_STATIC 0x0200
14734 +#define NX_ATR_MASK 0x0F00
14737 +extern struct nx_info *lookup_nx_info(int);
14739 +extern int get_nid_list(int, unsigned int *, int);
14740 +extern int nid_is_hashed(nid_t);
14742 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
14744 +extern long vs_net_change(struct nx_info *, unsigned int);
14747 +struct net_device;
14749 +#ifdef CONFIG_INET
14750 +int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *);
14751 +int dev_in_nx_info(struct net_device *, struct nx_info *);
14753 +#else /* CONFIG_INET */
14755 +int ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
14761 +int dev_in_nx_info(struct net_device *d, struct nx_info *n)
14765 +#endif /* CONFIG_INET */
14769 +#ifdef CONFIG_INET
14770 +int nx_addr_conflict(struct nx_info *, uint32_t, const struct sock *);
14771 +#else /* CONFIG_INET */
14773 +int nx_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
14777 +#endif /* CONFIG_INET */
14779 +#endif /* __KERNEL__ */
14780 +#else /* _VX_NETWORK_H */
14781 +#warning duplicate inclusion
14782 +#endif /* _VX_NETWORK_H */
14783 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/network_cmd.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/network_cmd.h
14784 --- linux-2.6.22.10/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00 +0100
14785 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/network_cmd.h 2007-06-15 02:37:04 +0200
14787 +#ifndef _VX_NETWORK_CMD_H
14788 +#define _VX_NETWORK_CMD_H
14791 +/* vinfo commands */
14793 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
14796 +extern int vc_task_nid(uint32_t, void __user *);
14798 +#endif /* __KERNEL__ */
14800 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
14802 +struct vcmd_nx_info_v0 {
14804 + /* more to come */
14808 +extern int vc_nx_info(struct nx_info *, void __user *);
14810 +#endif /* __KERNEL__ */
14812 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
14813 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
14815 +struct vcmd_net_create {
14816 + uint64_t flagword;
14819 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
14821 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
14822 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
14824 +struct vcmd_net_addr_v0 {
14828 + uint32_t mask[4];
14829 + /* more to come */
14834 +extern int vc_net_create(uint32_t, void __user *);
14835 +extern int vc_net_migrate(struct nx_info *, void __user *);
14837 +extern int vc_net_add(struct nx_info *, void __user *);
14838 +extern int vc_net_remove(struct nx_info *, void __user *);
14840 +#endif /* __KERNEL__ */
14843 +/* flag commands */
14845 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
14846 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
14848 +struct vcmd_net_flags_v0 {
14849 + uint64_t flagword;
14854 +extern int vc_get_nflags(struct nx_info *, void __user *);
14855 +extern int vc_set_nflags(struct nx_info *, void __user *);
14857 +#endif /* __KERNEL__ */
14860 +/* network caps commands */
14862 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
14863 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
14865 +struct vcmd_net_caps_v0 {
14871 +extern int vc_get_ncaps(struct nx_info *, void __user *);
14872 +extern int vc_set_ncaps(struct nx_info *, void __user *);
14874 +#endif /* __KERNEL__ */
14875 +#endif /* _VX_CONTEXT_CMD_H */
14876 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/percpu.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/percpu.h
14877 --- linux-2.6.22.10/include/linux/vserver/percpu.h 1970-01-01 01:00:00 +0100
14878 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/percpu.h 2007-06-15 02:37:04 +0200
14880 +#ifndef _VX_PERCPU_H
14881 +#define _VX_PERCPU_H
14883 +#include "cvirt_def.h"
14884 +#include "sched_def.h"
14886 +struct _vx_percpu {
14887 + struct _vx_cvirt_pc cvirt;
14888 + struct _vx_sched_pc sched;
14891 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
14893 +#endif /* _VX_PERCPU_H */
14894 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/sched.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/sched.h
14895 --- linux-2.6.22.10/include/linux/vserver/sched.h 1970-01-01 01:00:00 +0100
14896 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/sched.h 2007-06-15 02:37:04 +0200
14898 +#ifndef _VX_SCHED_H
14899 +#define _VX_SCHED_H
14906 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14911 +void vx_update_load(struct vx_info *);
14914 +int vx_tokens_recalc(struct _vx_sched_pc *,
14915 + unsigned long *, unsigned long *, int [2]);
14917 +void vx_update_sched_param(struct _vx_sched *sched,
14918 + struct _vx_sched_pc *sched_pc);
14920 +#endif /* __KERNEL__ */
14921 +#else /* _VX_SCHED_H */
14922 +#warning duplicate inclusion
14923 +#endif /* _VX_SCHED_H */
14924 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/sched_cmd.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/sched_cmd.h
14925 --- linux-2.6.22.10/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00 +0100
14926 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/sched_cmd.h 2007-06-15 02:37:04 +0200
14928 +#ifndef _VX_SCHED_CMD_H
14929 +#define _VX_SCHED_CMD_H
14932 +/* sched vserver commands */
14934 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
14935 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
14936 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
14938 +struct vcmd_set_sched_v2 {
14939 + int32_t fill_rate;
14940 + int32_t interval;
14942 + int32_t tokens_min;
14943 + int32_t tokens_max;
14944 + uint64_t cpu_mask;
14947 +struct vcmd_set_sched_v3 {
14948 + uint32_t set_mask;
14949 + int32_t fill_rate;
14950 + int32_t interval;
14952 + int32_t tokens_min;
14953 + int32_t tokens_max;
14954 + int32_t priority_bias;
14957 +struct vcmd_set_sched_v4 {
14958 + uint32_t set_mask;
14959 + int32_t fill_rate;
14960 + int32_t interval;
14962 + int32_t tokens_min;
14963 + int32_t tokens_max;
14964 + int32_t prio_bias;
14966 + int32_t bucket_id;
14969 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
14970 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
14972 +struct vcmd_sched_v5 {
14975 + int32_t bucket_id;
14976 + int32_t fill_rate[2];
14977 + int32_t interval[2];
14979 + int32_t tokens_min;
14980 + int32_t tokens_max;
14981 + int32_t prio_bias;
14984 +#define VXSM_FILL_RATE 0x0001
14985 +#define VXSM_INTERVAL 0x0002
14986 +#define VXSM_FILL_RATE2 0x0004
14987 +#define VXSM_INTERVAL2 0x0008
14988 +#define VXSM_TOKENS 0x0010
14989 +#define VXSM_TOKENS_MIN 0x0020
14990 +#define VXSM_TOKENS_MAX 0x0040
14991 +#define VXSM_PRIO_BIAS 0x0100
14993 +#define VXSM_IDLE_TIME 0x0200
14994 +#define VXSM_FORCE 0x0400
14996 +#define VXSM_V3_MASK 0x0173
14997 +#define VXSM_SET_MASK 0x01FF
14999 +#define VXSM_CPU_ID 0x1000
15000 +#define VXSM_BUCKET_ID 0x2000
15002 +#define VXSM_MSEC 0x4000
15004 +#define SCHED_KEEP (-2) /* only for v2 */
15008 +#include <linux/compiler.h>
15010 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
15011 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
15012 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
15013 +extern int vc_set_sched(struct vx_info *, void __user *);
15014 +extern int vc_get_sched(struct vx_info *, void __user *);
15016 +#endif /* __KERNEL__ */
15018 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
15020 +struct vcmd_sched_info {
15022 + int32_t bucket_id;
15023 + uint64_t user_msec;
15024 + uint64_t sys_msec;
15025 + uint64_t hold_msec;
15026 + uint32_t token_usec;
15027 + int32_t vavavoom;
15032 +extern int vc_sched_info(struct vx_info *, void __user *);
15034 +#endif /* __KERNEL__ */
15035 +#endif /* _VX_SCHED_CMD_H */
15036 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/sched_def.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/sched_def.h
15037 --- linux-2.6.22.10/include/linux/vserver/sched_def.h 1970-01-01 01:00:00 +0100
15038 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/sched_def.h 2007-06-15 02:37:04 +0200
15040 +#ifndef _VX_SCHED_DEF_H
15041 +#define _VX_SCHED_DEF_H
15043 +#include <linux/spinlock.h>
15044 +#include <linux/jiffies.h>
15045 +#include <linux/cpumask.h>
15046 +#include <asm/atomic.h>
15047 +#include <asm/param.h>
15050 +/* context sub struct */
15052 +struct _vx_sched {
15053 + spinlock_t tokens_lock; /* lock for token bucket */
15055 + int tokens; /* number of CPU tokens */
15056 + int fill_rate[2]; /* Fill rate: add X tokens... */
15057 + int interval[2]; /* Divisor: per Y jiffies */
15058 + int tokens_min; /* Limit: minimum for unhold */
15059 + int tokens_max; /* Limit: no more than N tokens */
15061 + int prio_bias; /* bias offset for priority */
15063 + unsigned update_mask; /* which features should be updated */
15064 + cpumask_t update; /* CPUs which should update */
15067 +struct _vx_sched_pc {
15068 + int tokens; /* number of CPU tokens */
15069 + int flags; /* bucket flags */
15071 + int fill_rate[2]; /* Fill rate: add X tokens... */
15072 + int interval[2]; /* Divisor: per Y jiffies */
15073 + int tokens_min; /* Limit: minimum for unhold */
15074 + int tokens_max; /* Limit: no more than N tokens */
15076 + int prio_bias; /* bias offset for priority */
15077 + int vavavoom; /* last calculated vavavoom */
15079 + unsigned long norm_time; /* last time accounted */
15080 + unsigned long idle_time; /* non linear time for fair sched */
15081 + unsigned long token_time; /* token time for accounting */
15082 + unsigned long onhold; /* jiffies when put on hold */
15084 + uint64_t user_ticks; /* token tick events */
15085 + uint64_t sys_ticks; /* token tick events */
15086 + uint64_t hold_ticks; /* token ticks paused */
15090 +#define VXSF_ONHOLD 0x0001
15091 +#define VXSF_IDLE_TIME 0x0100
15093 +#ifdef CONFIG_VSERVER_DEBUG
15095 +static inline void __dump_vx_sched(struct _vx_sched *sched)
15097 + printk("\t_vx_sched:\n");
15098 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
15099 + sched->fill_rate[0], sched->interval[0],
15100 + sched->fill_rate[1], sched->interval[1],
15101 + sched->tokens_min, sched->tokens_max);
15102 + printk("\t priority = %4d\n", sched->prio_bias);
15107 +#endif /* _VX_SCHED_DEF_H */
15108 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/signal.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/signal.h
15109 --- linux-2.6.22.10/include/linux/vserver/signal.h 1970-01-01 01:00:00 +0100
15110 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/signal.h 2007-06-15 02:37:04 +0200
15112 +#ifndef _VX_SIGNAL_H
15113 +#define _VX_SIGNAL_H
15120 +int vx_info_kill(struct vx_info *, int, int);
15122 +#endif /* __KERNEL__ */
15123 +#else /* _VX_SIGNAL_H */
15124 +#warning duplicate inclusion
15125 +#endif /* _VX_SIGNAL_H */
15126 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/signal_cmd.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/signal_cmd.h
15127 --- linux-2.6.22.10/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00 +0100
15128 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/signal_cmd.h 2007-06-15 02:37:04 +0200
15130 +#ifndef _VX_SIGNAL_CMD_H
15131 +#define _VX_SIGNAL_CMD_H
15134 +/* signalling vserver commands */
15136 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
15137 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
15139 +struct vcmd_ctx_kill_v0 {
15144 +struct vcmd_wait_exit_v0 {
15145 + int32_t reboot_cmd;
15146 + int32_t exit_code;
15151 +extern int vc_ctx_kill(struct vx_info *, void __user *);
15152 +extern int vc_wait_exit(struct vx_info *, void __user *);
15154 +#endif /* __KERNEL__ */
15156 +/* process alteration commands */
15158 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
15159 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
15161 +struct vcmd_pflags_v0 {
15162 + uint32_t flagword;
15168 +extern int vc_get_pflags(uint32_t pid, void __user *);
15169 +extern int vc_set_pflags(uint32_t pid, void __user *);
15171 +#endif /* __KERNEL__ */
15172 +#endif /* _VX_SIGNAL_CMD_H */
15173 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/space.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/space.h
15174 --- linux-2.6.22.10/include/linux/vserver/space.h 1970-01-01 01:00:00 +0100
15175 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/space.h 2007-06-15 02:37:04 +0200
15177 +#ifndef _VX_SPACE_H
15178 +#define _VX_SPACE_H
15181 +#include <linux/types.h>
15185 +int vx_set_space(struct vx_info *vxi, unsigned long mask);
15187 +#else /* _VX_SPACE_H */
15188 +#warning duplicate inclusion
15189 +#endif /* _VX_SPACE_H */
15190 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/space_cmd.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/space_cmd.h
15191 --- linux-2.6.22.10/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00 +0100
15192 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/space_cmd.h 2007-06-15 02:37:04 +0200
15194 +#ifndef _VX_SPACE_CMD_H
15195 +#define _VX_SPACE_CMD_H
15198 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
15199 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 1)
15201 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
15202 +#define VCMD_set_space VC_CMD(PROCALT, 3, 1)
15204 +#define VCMD_get_space_mask VC_CMD(PROCALT, 4, 0)
15207 +struct vcmd_space_mask {
15214 +extern int vc_enter_space(struct vx_info *, void __user *);
15215 +extern int vc_set_space(struct vx_info *, void __user *);
15216 +extern int vc_get_space_mask(struct vx_info *, void __user *);
15218 +#endif /* __KERNEL__ */
15219 +#endif /* _VX_SPACE_CMD_H */
15220 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/switch.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/switch.h
15221 --- linux-2.6.22.10/include/linux/vserver/switch.h 1970-01-01 01:00:00 +0100
15222 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/switch.h 2007-06-15 02:37:04 +0200
15224 +#ifndef _VX_SWITCH_H
15225 +#define _VX_SWITCH_H
15227 +#include <linux/types.h>
15230 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
15231 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
15232 +#define VC_VERSION(c) ((c) & 0xFFF)
15234 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
15235 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
15239 + Syscall Matrix V2.8
15241 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
15242 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
15243 + |INFO |SETUP | |MOVE | | | | | |
15244 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15245 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICES| |
15246 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
15247 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15248 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
15249 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
15250 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15251 + MEMORY | | | | | | | |SWAP | |
15252 + | 16| 17| 18| 19| 20| 21| | 22| 23|
15253 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15254 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
15255 + | 24| 25| 26| 27| 28| 29| | 30| 31|
15256 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15257 + DISK | | | | |DLIMIT | | |INODE | |
15258 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
15259 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15260 + OTHER |VSTAT | | | | | | |VINFO | |
15261 + | 40| 41| 42| 43| 44| 45| | 46| 47|
15262 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
15263 + SPECIAL|EVENT | | | |FLAGS | | | | |
15264 + | 48| 49| 50| 51| 52| 53| | 54| 55|
15265 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15266 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
15267 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
15268 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15272 +#define VC_CAT_VERSION 0
15274 +#define VC_CAT_VSETUP 1
15275 +#define VC_CAT_VHOST 2
15277 +#define VC_CAT_VPROC 9
15278 +#define VC_CAT_PROCALT 10
15279 +#define VC_CAT_PROCMIG 11
15280 +#define VC_CAT_PROCTRL 12
15282 +#define VC_CAT_SCHED 14
15284 +#define VC_CAT_VNET 25
15285 +#define VC_CAT_NETALT 26
15286 +#define VC_CAT_NETMIG 27
15287 +#define VC_CAT_NETCTRL 28
15289 +#define VC_CAT_DLIMIT 36
15290 +#define VC_CAT_INODE 38
15292 +#define VC_CAT_VSTAT 40
15293 +#define VC_CAT_VINFO 46
15294 +#define VC_CAT_EVENT 48
15296 +#define VC_CAT_FLAGS 52
15297 +#define VC_CAT_DEBUG 56
15298 +#define VC_CAT_RLIMIT 60
15300 +#define VC_CAT_SYSTEST 61
15301 +#define VC_CAT_COMPAT 63
15303 +/* query version */
15305 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
15306 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
15311 +#include <linux/errno.h>
15314 +#else /* __KERNEL__ */
15316 +#endif /* __KERNEL__ */
15318 +#endif /* _VX_SWITCH_H */
15319 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/tag.h linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/tag.h
15320 --- linux-2.6.22.10/include/linux/vserver/tag.h 1970-01-01 01:00:00 +0100
15321 +++ linux-2.6.22.10-vs2.2.0.5/include/linux/vserver/tag.h 2007-06-15 02:37:04 +0200
15327 +#define DX_TAG(in) (IS_TAGGED(in))
15330 +#ifdef CONFIG_DX_TAG_NFSD
15331 +#define DX_TAG_NFSD 1
15333 +#define DX_TAG_NFSD 0
15337 +#ifdef CONFIG_TAGGING_NONE
15339 +#define MAX_UID 0xFFFFFFFF
15340 +#define MAX_GID 0xFFFFFFFF
15342 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
15344 +#define TAGINO_UID(cond, uid, tag) (uid)
15345 +#define TAGINO_GID(cond, gid, tag) (gid)
15350 +#ifdef CONFIG_TAGGING_GID16
15352 +#define MAX_UID 0xFFFFFFFF
15353 +#define MAX_GID 0x0000FFFF
15355 +#define INOTAG_TAG(cond, uid, gid, tag) \
15356 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
15358 +#define TAGINO_UID(cond, uid, tag) (uid)
15359 +#define TAGINO_GID(cond, gid, tag) \
15360 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
15365 +#ifdef CONFIG_TAGGING_ID24
15367 +#define MAX_UID 0x00FFFFFF
15368 +#define MAX_GID 0x00FFFFFF
15370 +#define INOTAG_TAG(cond, uid, gid, tag) \
15371 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
15373 +#define TAGINO_UID(cond, uid, tag) \
15374 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
15375 +#define TAGINO_GID(cond, gid, tag) \
15376 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
15381 +#ifdef CONFIG_TAGGING_UID16
15383 +#define MAX_UID 0x0000FFFF
15384 +#define MAX_GID 0xFFFFFFFF
15386 +#define INOTAG_TAG(cond, uid, gid, tag) \
15387 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
15389 +#define TAGINO_UID(cond, uid, tag) \
15390 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
15391 +#define TAGINO_GID(cond, gid, tag) (gid)
15396 +#ifdef CONFIG_TAGGING_INTERN
15398 +#define MAX_UID 0xFFFFFFFF
15399 +#define MAX_GID 0xFFFFFFFF
15401 +#define INOTAG_TAG(cond, uid, gid, tag) \
15402 + ((cond) ? (tag) : 0)
15404 +#define TAGINO_UID(cond, uid, tag) (uid)
15405 +#define TAGINO_GID(cond, gid, tag) (gid)
15410 +#ifndef CONFIG_TAGGING_NONE
15411 +#define dx_current_fstag(sb) \
15412 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
15414 +#define dx_current_fstag(sb) (0)
15417 +#ifndef CONFIG_TAGGING_INTERN
15418 +#define TAGINO_TAG(cond, tag) (0)
15420 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
15423 +#define INOTAG_UID(cond, uid, gid) \
15424 + ((cond) ? ((uid) & MAX_UID) : (uid))
15425 +#define INOTAG_GID(cond, uid, gid) \
15426 + ((cond) ? ((gid) & MAX_GID) : (gid))
15429 +static inline uid_t dx_map_uid(uid_t uid)
15431 + if ((uid > MAX_UID) && (uid != -1))
15433 + return (uid & MAX_UID);
15436 +static inline gid_t dx_map_gid(gid_t gid)
15438 + if ((gid > MAX_GID) && (gid != -1))
15440 + return (gid & MAX_GID);
15444 +#ifdef CONFIG_VSERVER_LEGACY
15445 +#define FIOC_GETTAG _IOR('x', 1, long)
15446 +#define FIOC_SETTAG _IOW('x', 2, long)
15447 +#define FIOC_SETTAGJ _IOW('x', 3, long)
15450 +#ifdef CONFIG_PROPAGATE
15452 +int dx_parse_tag(char *string, tag_t *tag, int remove);
15454 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
15456 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
15459 +#define dx_propagate_tag(n, i) do { } while (0)
15462 +#endif /* _DX_TAG_H */
15463 diff -NurpP --minimal linux-2.6.22.10/include/net/af_unix.h linux-2.6.22.10-vs2.2.0.5/include/net/af_unix.h
15464 --- linux-2.6.22.10/include/net/af_unix.h 2007-07-09 13:20:01 +0200
15465 +++ linux-2.6.22.10-vs2.2.0.5/include/net/af_unix.h 2007-06-15 02:37:04 +0200
15467 #include <linux/socket.h>
15468 #include <linux/un.h>
15469 #include <linux/mutex.h>
15470 +#include <linux/vs_base.h>
15471 #include <net/sock.h>
15473 extern void unix_inflight(struct file *fp);
15474 @@ -17,9 +18,9 @@ extern spinlock_t unix_table_lock;
15476 extern atomic_t unix_tot_inflight;
15478 -static inline struct sock *first_unix_socket(int *i)
15479 +static inline struct sock *next_unix_socket_table(int *i)
15481 - for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
15482 + for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
15483 if (!hlist_empty(&unix_socket_table[*i]))
15484 return __sk_head(&unix_socket_table[*i]);
15486 @@ -28,16 +29,19 @@ static inline struct sock *first_unix_so
15488 static inline struct sock *next_unix_socket(int *i, struct sock *s)
15490 - struct sock *next = sk_next(s);
15491 - /* More in this chain? */
15494 - /* Look for next non-empty chain. */
15495 - for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
15496 - if (!hlist_empty(&unix_socket_table[*i]))
15497 - return __sk_head(&unix_socket_table[*i]);
15504 + s = next_unix_socket_table(i);
15505 + } while (s && !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT));
15509 +static inline struct sock *first_unix_socket(int *i)
15512 + return next_unix_socket(i, NULL);
15515 #define forall_unix_sockets(i, s) \
15516 diff -NurpP --minimal linux-2.6.22.10/include/net/inet_hashtables.h linux-2.6.22.10-vs2.2.0.5/include/net/inet_hashtables.h
15517 --- linux-2.6.22.10/include/net/inet_hashtables.h 2007-05-02 19:25:35 +0200
15518 +++ linux-2.6.22.10-vs2.2.0.5/include/net/inet_hashtables.h 2007-06-15 02:37:04 +0200
15519 @@ -271,6 +271,26 @@ static inline int inet_iif(const struct
15520 return ((struct rtable *)skb->dst)->rt_iif;
15524 + * Check if a given address matches for an inet socket
15526 + * nxi: the socket's nx_info if any
15527 + * addr: to be verified address
15528 + * saddr: socket addresses
15530 +static inline int inet_addr_match (
15531 + struct nx_info *nxi,
15535 + if (addr && (saddr == addr))
15538 + return addr_in_nx_info(nxi, addr);
15543 extern struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo,
15544 const __be32 daddr,
15545 const unsigned short hnum,
15546 diff -NurpP --minimal linux-2.6.22.10/include/net/inet_sock.h linux-2.6.22.10-vs2.2.0.5/include/net/inet_sock.h
15547 --- linux-2.6.22.10/include/net/inet_sock.h 2007-07-09 13:20:01 +0200
15548 +++ linux-2.6.22.10-vs2.2.0.5/include/net/inet_sock.h 2007-06-15 02:37:04 +0200
15549 @@ -113,6 +113,7 @@ struct inet_sock {
15550 /* Socket demultiplex comparisons on incoming packets. */
15553 + __be32 rcv_saddr2; /* Second bound ipv4 addr, for ipv4root */
15557 diff -NurpP --minimal linux-2.6.22.10/include/net/inet_timewait_sock.h linux-2.6.22.10-vs2.2.0.5/include/net/inet_timewait_sock.h
15558 --- linux-2.6.22.10/include/net/inet_timewait_sock.h 2007-05-02 19:25:35 +0200
15559 +++ linux-2.6.22.10-vs2.2.0.5/include/net/inet_timewait_sock.h 2007-06-15 02:37:04 +0200
15560 @@ -115,6 +115,10 @@ struct inet_timewait_sock {
15561 #define tw_refcnt __tw_common.skc_refcnt
15562 #define tw_hash __tw_common.skc_hash
15563 #define tw_prot __tw_common.skc_prot
15564 +#define tw_xid __tw_common.skc_xid
15565 +#define tw_vx_info __tw_common.skc_vx_info
15566 +#define tw_nid __tw_common.skc_nid
15567 +#define tw_nx_info __tw_common.skc_nx_info
15568 volatile unsigned char tw_substate;
15569 /* 3 bits hole, try to pack */
15570 unsigned char tw_rcv_wscale;
15571 diff -NurpP --minimal linux-2.6.22.10/include/net/route.h linux-2.6.22.10-vs2.2.0.5/include/net/route.h
15572 --- linux-2.6.22.10/include/net/route.h 2007-05-02 19:25:35 +0200
15573 +++ linux-2.6.22.10-vs2.2.0.5/include/net/route.h 2007-06-15 02:37:04 +0200
15574 @@ -27,12 +27,16 @@
15575 #include <net/dst.h>
15576 #include <net/inetpeer.h>
15577 #include <net/flow.h>
15578 +#include <net/inet_sock.h>
15579 #include <linux/in_route.h>
15580 #include <linux/rtnetlink.h>
15581 #include <linux/route.h>
15582 #include <linux/ip.h>
15583 #include <linux/cache.h>
15584 #include <linux/security.h>
15585 +#include <linux/vs_base.h>
15586 +#include <linux/vs_network.h>
15587 +#include <linux/in.h>
15590 #warning This file is not supposed to be used outside of kernel.
15591 @@ -143,6 +147,59 @@ static inline char rt_tos2priority(u8 to
15592 return ip_tos2prio[IPTOS_TOS(tos)>>1];
15595 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
15597 +static inline int ip_find_src(struct nx_info *nxi, struct rtable **rp, struct flowi *fl)
15600 + int i, n = nxi->nbipv4;
15601 + u32 ipv4root = nxi->ipv4[0];
15603 + if (ipv4root == 0)
15606 + if (fl->fl4_src == 0) {
15610 + err = __ip_route_output_key(rp, fl);
15612 + fl->fl4_src = ipv4root;
15613 + err = __ip_route_output_key(rp, fl);
15618 + foundsrc = (*rp)->rt_src;
15621 + for (i=0; i<n; i++){
15622 + u32 mask = nxi->mask[i];
15623 + u32 ipv4 = nxi->ipv4[i];
15624 + u32 net4 = ipv4 & mask;
15626 + if (foundsrc == ipv4) {
15627 + fl->fl4_src = ipv4;
15630 + if (!fl->fl4_src && (foundsrc & mask) == net4)
15631 + fl->fl4_src = ipv4;
15634 + if (fl->fl4_src == 0)
15635 + fl->fl4_src = (fl->fl4_dst == IPI_LOOPBACK)
15636 + ? IPI_LOOPBACK : ipv4root;
15638 + for (i=0; i<n; i++) {
15639 + if (nxi->ipv4[i] == fl->fl4_src)
15648 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
15649 __be32 src, u32 tos, int oif, u8 protocol,
15650 __be16 sport, __be16 dport, struct sock *sk,
15651 @@ -158,7 +215,27 @@ static inline int ip_route_connect(struc
15652 .dport = dport } } };
15655 - if (!dst || !src) {
15656 + struct nx_info *nx_info = current->nx_info;
15659 + nx_info = sk->sk_nx_info;
15660 + vxdprintk(VXD_CBIT(net, 4),
15661 + "ip_route_connect(%p) %p,%p;%lx",
15662 + sk, nx_info, sk->sk_socket,
15663 + (sk->sk_socket?sk->sk_socket->flags:0));
15666 + err = ip_find_src(nx_info, rp, &fl);
15669 + if (fl.fl4_dst == IPI_LOOPBACK && !nx_check(0, VS_ADMIN))
15670 + fl.fl4_dst = nx_info->ipv4[0];
15671 +#ifdef CONFIG_VSERVER_REMAP_SADDR
15672 + if (fl.fl4_src == IPI_LOOPBACK && !nx_check(0, VS_ADMIN))
15673 + fl.fl4_src = nx_info->ipv4[0];
15676 + if (!fl.fl4_dst || !fl.fl4_src) {
15677 err = __ip_route_output_key(rp, &fl);
15680 diff -NurpP --minimal linux-2.6.22.10/include/net/sock.h linux-2.6.22.10-vs2.2.0.5/include/net/sock.h
15681 --- linux-2.6.22.10/include/net/sock.h 2007-07-09 13:20:02 +0200
15682 +++ linux-2.6.22.10-vs2.2.0.5/include/net/sock.h 2007-06-15 02:37:04 +0200
15683 @@ -119,6 +119,10 @@ struct sock_common {
15684 atomic_t skc_refcnt;
15685 unsigned int skc_hash;
15686 struct proto *skc_prot;
15688 + struct vx_info *skc_vx_info;
15690 + struct nx_info *skc_nx_info;
15694 @@ -195,6 +199,10 @@ struct sock {
15695 #define sk_refcnt __sk_common.skc_refcnt
15696 #define sk_hash __sk_common.skc_hash
15697 #define sk_prot __sk_common.skc_prot
15698 +#define sk_xid __sk_common.skc_xid
15699 +#define sk_vx_info __sk_common.skc_vx_info
15700 +#define sk_nid __sk_common.skc_nid
15701 +#define sk_nx_info __sk_common.skc_nx_info
15702 unsigned char sk_shutdown : 2,
15705 diff -NurpP --minimal linux-2.6.22.10/init/main.c linux-2.6.22.10-vs2.2.0.5/init/main.c
15706 --- linux-2.6.22.10/init/main.c 2007-07-09 13:20:03 +0200
15707 +++ linux-2.6.22.10-vs2.2.0.5/init/main.c 2007-06-15 04:03:00 +0200
15709 #include <linux/pid_namespace.h>
15710 #include <linux/device.h>
15711 #include <linux/kthread.h>
15712 +#include <linux/vserver/percpu.h>
15714 #include <asm/io.h>
15715 #include <asm/bugs.h>
15716 @@ -364,12 +365,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
15718 static void __init setup_per_cpu_areas(void)
15720 - unsigned long size, i;
15721 + unsigned long size, vspc, i;
15723 unsigned long nr_possible_cpus = num_possible_cpus();
15725 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
15727 /* Copy section for each CPU (we discard the original) */
15728 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
15729 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
15730 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
15732 for_each_possible_cpu(i) {
15733 diff -NurpP --minimal linux-2.6.22.10/ipc/mqueue.c linux-2.6.22.10-vs2.2.0.5/ipc/mqueue.c
15734 --- linux-2.6.22.10/ipc/mqueue.c 2007-07-09 13:20:03 +0200
15735 +++ linux-2.6.22.10-vs2.2.0.5/ipc/mqueue.c 2007-06-15 02:37:04 +0200
15737 #include <linux/audit.h>
15738 #include <linux/signal.h>
15739 #include <linux/mutex.h>
15740 +#include <linux/vs_context.h>
15741 +#include <linux/vs_limit.h>
15743 #include <net/sock.h>
15745 @@ -151,17 +153,20 @@ static struct inode *mqueue_get_inode(st
15746 spin_lock(&mq_lock);
15747 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
15748 u->mq_bytes + mq_bytes >
15749 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
15750 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
15751 + !vx_ipcmsg_avail(p->vx_info, mq_bytes)) {
15752 spin_unlock(&mq_lock);
15755 u->mq_bytes += mq_bytes;
15756 + vx_ipcmsg_add(p->vx_info, u, mq_bytes);
15757 spin_unlock(&mq_lock);
15759 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
15760 if (!info->messages) {
15761 spin_lock(&mq_lock);
15762 u->mq_bytes -= mq_bytes;
15763 + vx_ipcmsg_sub(p->vx_info, u, mq_bytes);
15764 spin_unlock(&mq_lock);
15767 @@ -257,10 +262,14 @@ static void mqueue_delete_inode(struct i
15768 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
15771 + struct vx_info *vxi = lookup_vx_info(user->xid);
15773 spin_lock(&mq_lock);
15774 user->mq_bytes -= mq_bytes;
15775 + vx_ipcmsg_sub(vxi, user, mq_bytes);
15777 spin_unlock(&mq_lock);
15778 + put_vx_info(vxi);
15782 @@ -748,7 +757,7 @@ asmlinkage long sys_mq_unlink(const char
15784 atomic_inc(&inode->i_count);
15786 - err = vfs_unlink(dentry->d_parent->d_inode, dentry);
15787 + err = vfs_unlink(dentry->d_parent->d_inode, dentry, NULL);
15791 diff -NurpP --minimal linux-2.6.22.10/ipc/msg.c linux-2.6.22.10-vs2.2.0.5/ipc/msg.c
15792 --- linux-2.6.22.10/ipc/msg.c 2007-02-06 03:01:55 +0100
15793 +++ linux-2.6.22.10-vs2.2.0.5/ipc/msg.c 2007-06-15 02:37:04 +0200
15795 #include <linux/seq_file.h>
15796 #include <linux/mutex.h>
15797 #include <linux/nsproxy.h>
15798 +#include <linux/vs_base.h>
15800 #include <asm/current.h>
15801 #include <asm/uaccess.h>
15802 @@ -149,6 +150,7 @@ static int newque (struct ipc_namespace
15804 msq->q_perm.mode = msgflg & S_IRWXUGO;
15805 msq->q_perm.key = key;
15806 + msq->q_perm.xid = vx_current_xid();
15808 msq->q_perm.security = NULL;
15809 retval = security_msg_queue_alloc(msq);
15810 diff -NurpP --minimal linux-2.6.22.10/ipc/sem.c linux-2.6.22.10-vs2.2.0.5/ipc/sem.c
15811 --- linux-2.6.22.10/ipc/sem.c 2007-07-09 13:20:03 +0200
15812 +++ linux-2.6.22.10-vs2.2.0.5/ipc/sem.c 2007-06-15 02:37:04 +0200
15814 #include <linux/seq_file.h>
15815 #include <linux/mutex.h>
15816 #include <linux/nsproxy.h>
15817 +#include <linux/vs_base.h>
15818 +#include <linux/vs_limit.h>
15820 #include <asm/uaccess.h>
15822 @@ -229,6 +231,7 @@ static int newary (struct ipc_namespace
15824 sma->sem_perm.mode = (semflg & S_IRWXUGO);
15825 sma->sem_perm.key = key;
15826 + sma->sem_perm.xid = vx_current_xid();
15828 sma->sem_perm.security = NULL;
15829 retval = security_sem_alloc(sma);
15830 @@ -244,6 +247,9 @@ static int newary (struct ipc_namespace
15833 ns->used_sems += nsems;
15834 + /* FIXME: obsoleted? */
15835 + vx_semary_inc(sma);
15836 + vx_nsems_add(sma, nsems);
15838 sma->sem_id = sem_buildid(ns, id, sma->sem_perm.seq);
15839 sma->sem_base = (struct sem *) &sma[1];
15840 @@ -525,6 +531,9 @@ static void freeary (struct ipc_namespac
15843 ns->used_sems -= sma->sem_nsems;
15844 + /* FIXME: obsoleted? */
15845 + vx_nsems_sub(sma, sma->sem_nsems);
15846 + vx_semary_dec(sma);
15847 size = sizeof (*sma) + sma->sem_nsems * sizeof (struct sem);
15848 security_sem_free(sma);
15849 ipc_rcu_putref(sma);
15850 diff -NurpP --minimal linux-2.6.22.10/ipc/shm.c linux-2.6.22.10-vs2.2.0.5/ipc/shm.c
15851 --- linux-2.6.22.10/ipc/shm.c 2007-10-30 01:57:14 +0100
15852 +++ linux-2.6.22.10-vs2.2.0.5/ipc/shm.c 2007-08-12 12:21:52 +0200
15854 #include <linux/mutex.h>
15855 #include <linux/nsproxy.h>
15856 #include <linux/mount.h>
15857 +#include <linux/vs_context.h>
15858 +#include <linux/vs_limit.h>
15860 #include <asm/uaccess.h>
15862 @@ -185,7 +187,12 @@ static void shm_open(struct vm_area_stru
15864 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
15866 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15867 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
15868 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15870 + vx_ipcshm_sub(vxi, shp, numpages);
15871 + ns->shm_tot -= numpages;
15873 shm_rmid(ns, shp->id);
15875 if (!is_file_hugepages(shp->shm_file))
15876 @@ -195,6 +202,7 @@ static void shm_destroy(struct ipc_names
15878 fput (shp->shm_file);
15879 security_shm_free(shp);
15880 + put_vx_info(vxi);
15881 ipc_rcu_putref(shp);
15884 @@ -351,11 +359,15 @@ static int newseg (struct ipc_namespace
15885 if (ns->shm_tot + numpages > ns->shm_ctlall)
15888 + if (!vx_ipcshm_avail(current->vx_info, numpages))
15891 shp = ipc_rcu_alloc(sizeof(*shp));
15895 shp->shm_perm.key = key;
15896 + shp->shm_perm.xid = vx_current_xid();
15897 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
15898 shp->mlock_user = NULL;
15900 @@ -406,6 +418,7 @@ static int newseg (struct ipc_namespace
15901 file->f_dentry->d_inode->i_ino = shp->id;
15903 ns->shm_tot += numpages;
15904 + vx_ipcshm_add(current->vx_info, key, numpages);
15908 diff -NurpP --minimal linux-2.6.22.10/ipc/util.c linux-2.6.22.10-vs2.2.0.5/ipc/util.c
15909 --- linux-2.6.22.10/ipc/util.c 2007-07-09 13:20:03 +0200
15910 +++ linux-2.6.22.10-vs2.2.0.5/ipc/util.c 2007-06-15 02:37:04 +0200
15912 #include <linux/proc_fs.h>
15913 #include <linux/audit.h>
15914 #include <linux/nsproxy.h>
15915 +#include <linux/vs_base.h>
15916 +#include <linux/vserver/global.h>
15918 #include <asm/unistd.h>
15920 @@ -72,6 +74,7 @@ static struct ipc_namespace *clone_ipc_n
15923 kref_init(&ns->kref);
15924 + atomic_inc(&vs_global_ipc_ns);
15928 @@ -108,6 +111,7 @@ void free_ipc_ns(struct kref *kref)
15932 + atomic_dec(&vs_global_ipc_ns);
15936 diff -NurpP --minimal linux-2.6.22.10/kernel/Makefile linux-2.6.22.10-vs2.2.0.5/kernel/Makefile
15937 --- linux-2.6.22.10/kernel/Makefile 2007-07-09 13:20:03 +0200
15938 +++ linux-2.6.22.10-vs2.2.0.5/kernel/Makefile 2007-06-15 02:37:04 +0200
15939 @@ -10,6 +10,8 @@ obj-y = sched.o fork.o exec_domain.o
15940 kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
15941 hrtimer.o rwsem.o latency.o nsproxy.o srcu.o die_notifier.o
15945 obj-$(CONFIG_STACKTRACE) += stacktrace.o
15947 obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o
15948 diff -NurpP --minimal linux-2.6.22.10/kernel/capability.c linux-2.6.22.10-vs2.2.0.5/kernel/capability.c
15949 --- linux-2.6.22.10/kernel/capability.c 2007-05-02 19:25:37 +0200
15950 +++ linux-2.6.22.10-vs2.2.0.5/kernel/capability.c 2007-06-15 02:37:04 +0200
15952 #include <linux/module.h>
15953 #include <linux/security.h>
15954 #include <linux/syscalls.h>
15955 +#include <linux/vs_context.h>
15956 #include <asm/uaccess.h>
15958 unsigned securebits = SECUREBITS_DEFAULT; /* systemwide security settings */
15959 @@ -103,6 +104,8 @@ static inline int cap_set_pg(int pgrp_nr
15961 pgrp = find_pid(pgrp_nr);
15962 do_each_pid_task(pgrp, PIDTYPE_PGID, g) {
15963 + if (!vx_check(g->xid, VS_ADMIN_P | VS_IDENT))
15966 while_each_thread(g, target) {
15967 if (!security_capset_check(target, effective,
15968 @@ -246,8 +249,12 @@ int __capable(struct task_struct *t, int
15970 EXPORT_SYMBOL(__capable);
15972 +#include <linux/vserver/base.h>
15973 int capable(int cap)
15975 + /* here for now so we don't require task locking */
15976 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15978 return __capable(current, cap);
15980 EXPORT_SYMBOL(capable);
15981 diff -NurpP --minimal linux-2.6.22.10/kernel/compat.c linux-2.6.22.10-vs2.2.0.5/kernel/compat.c
15982 --- linux-2.6.22.10/kernel/compat.c 2007-07-09 13:20:03 +0200
15983 +++ linux-2.6.22.10-vs2.2.0.5/kernel/compat.c 2007-06-15 02:37:04 +0200
15984 @@ -846,7 +846,7 @@ asmlinkage long compat_sys_time(compat_t
15988 - do_gettimeofday(&tv);
15989 + vx_gettimeofday(&tv);
15993 @@ -870,7 +870,7 @@ asmlinkage long compat_sys_stime(compat_
15997 - do_settimeofday(&tv);
15998 + vx_settimeofday(&tv);
16002 diff -NurpP --minimal linux-2.6.22.10/kernel/exit.c linux-2.6.22.10-vs2.2.0.5/kernel/exit.c
16003 --- linux-2.6.22.10/kernel/exit.c 2007-07-09 13:20:03 +0200
16004 +++ linux-2.6.22.10-vs2.2.0.5/kernel/exit.c 2007-07-17 03:02:15 +0200
16006 #include <linux/resource.h>
16007 #include <linux/blkdev.h>
16008 #include <linux/task_io_accounting_ops.h>
16009 +#include <linux/vs_limit.h>
16010 +#include <linux/vs_context.h>
16011 +#include <linux/vs_network.h>
16012 +#include <linux/vs_pid.h>
16013 +#include <linux/vserver/global.h>
16015 #include <asm/uaccess.h>
16016 #include <asm/unistd.h>
16017 @@ -443,9 +448,11 @@ static void close_files(struct files_str
16018 filp_close(file, files);
16021 + vx_openfd_dec(i);
16029 @@ -525,6 +532,7 @@ static inline void __put_fs_struct(struc
16031 mntput(fs->altrootmnt);
16033 + atomic_dec(&vs_global_fs);
16034 kmem_cache_free(fs_cachep, fs);
16037 @@ -596,6 +604,14 @@ static void exit_mm(struct task_struct *
16039 choose_new_parent(struct task_struct *p, struct task_struct *reaper)
16041 + /* check for reaper context */
16042 + vxwprintk((p->xid != reaper->xid) && (reaper != child_reaper(p)),
16043 + "rogue reaper: %p[%d,#%u] <> %p[%d,#%u]",
16044 + p, p->pid, p->xid, reaper, reaper->pid, reaper->xid);
16047 + reaper = vx_child_reaper(p);
16050 * Make sure we're not reparenting to ourselves and that
16051 * the parent is not a zombie.
16052 @@ -687,7 +703,7 @@ forget_original_parent(struct task_struc
16054 reaper = next_thread(reaper);
16055 if (reaper == father) {
16056 - reaper = child_reaper(father);
16057 + reaper = vx_child_reaper(father);
16060 } while (reaper->exit_state);
16061 @@ -964,6 +980,8 @@ fastcall NORET_TYPE void do_exit(long co
16062 tsk->exit_code = code;
16063 proc_exit_connector(tsk);
16064 exit_task_namespaces(tsk);
16065 + /* needs to stay before exit_notify() */
16066 + exit_vx_info_early(tsk, code);
16069 mpol_free(tsk->mempolicy);
16070 @@ -994,6 +1012,10 @@ fastcall NORET_TYPE void do_exit(long co
16071 if (tsk->splice_pipe)
16072 __free_pipe_info(tsk->splice_pipe);
16074 + /* needs to stay after exit_notify() */
16075 + exit_vx_info(tsk, code);
16076 + exit_nx_info(tsk);
16079 /* causes final put_task_struct in finish_task_switch(). */
16080 tsk->state = TASK_DEAD;
16081 diff -NurpP --minimal linux-2.6.22.10/kernel/fork.c linux-2.6.22.10-vs2.2.0.5/kernel/fork.c
16082 --- linux-2.6.22.10/kernel/fork.c 2007-07-09 13:20:03 +0200
16083 +++ linux-2.6.22.10-vs2.2.0.5/kernel/fork.c 2007-10-29 23:35:00 +0100
16085 #include <linux/delayacct.h>
16086 #include <linux/taskstats_kern.h>
16087 #include <linux/random.h>
16088 +#include <linux/vs_context.h>
16089 +#include <linux/vs_network.h>
16090 +#include <linux/vs_limit.h>
16091 +#include <linux/vs_memory.h>
16092 +#include <linux/vserver/global.h>
16094 #include <asm/pgtable.h>
16095 #include <asm/pgalloc.h>
16096 @@ -108,6 +113,8 @@ void free_task(struct task_struct *tsk)
16098 free_thread_info(tsk->stack);
16099 rt_mutex_debug_task_free(tsk);
16100 + clr_vx_info(&tsk->vx_info);
16101 + clr_nx_info(&tsk->nx_info);
16102 free_task_struct(tsk);
16104 EXPORT_SYMBOL(free_task);
16105 @@ -215,6 +222,8 @@ static inline int dup_mmap(struct mm_str
16106 mm->free_area_cache = oldmm->mmap_base;
16107 mm->cached_hole_size = ~0UL;
16109 + __set_mm_counter(mm, file_rss, 0);
16110 + __set_mm_counter(mm, anon_rss, 0);
16111 cpus_clear(mm->cpu_vm_mask);
16112 mm->mm_rb = RB_ROOT;
16113 rb_link = &mm->mm_rb.rb_node;
16114 @@ -226,7 +235,7 @@ static inline int dup_mmap(struct mm_str
16116 if (mpnt->vm_flags & VM_DONTCOPY) {
16117 long pages = vma_pages(mpnt);
16118 - mm->total_vm -= pages;
16119 + vx_vmpages_sub(mm, pages);
16120 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
16123 @@ -327,7 +336,7 @@ static inline void mm_free_pgd(struct mm
16125 #include <linux/init_task.h>
16127 -static struct mm_struct * mm_init(struct mm_struct * mm)
16128 +static struct mm_struct * mm_init(struct mm_struct * mm, struct vx_info *vxi)
16130 atomic_set(&mm->mm_users, 1);
16131 atomic_set(&mm->mm_count, 1);
16132 @@ -335,8 +344,8 @@ static struct mm_struct * mm_init(struct
16133 INIT_LIST_HEAD(&mm->mmlist);
16134 mm->core_waiters = 0;
16136 - set_mm_counter(mm, file_rss, 0);
16137 - set_mm_counter(mm, anon_rss, 0);
16138 + __set_mm_counter(mm, file_rss, 0);
16139 + __set_mm_counter(mm, anon_rss, 0);
16140 spin_lock_init(&mm->page_table_lock);
16141 rwlock_init(&mm->ioctx_list_lock);
16142 mm->ioctx_list = NULL;
16143 @@ -345,6 +354,7 @@ static struct mm_struct * mm_init(struct
16145 if (likely(!mm_alloc_pgd(mm))) {
16147 + set_vx_info(&mm->mm_vx_info, vxi);
16151 @@ -361,7 +371,7 @@ struct mm_struct * mm_alloc(void)
16152 mm = allocate_mm();
16154 memset(mm, 0, sizeof(*mm));
16155 - mm = mm_init(mm);
16156 + mm = mm_init(mm, current->vx_info);
16160 @@ -376,6 +386,7 @@ void fastcall __mmdrop(struct mm_struct
16161 BUG_ON(mm == &init_mm);
16163 destroy_context(mm);
16164 + clr_vx_info(&mm->mm_vx_info);
16168 @@ -490,12 +501,13 @@ static struct mm_struct *dup_mm(struct t
16171 memcpy(mm, oldmm, sizeof(*mm));
16172 + mm->mm_vx_info = NULL;
16174 /* Initializing for Swap token stuff */
16175 mm->token_priority = 0;
16176 mm->last_interval = 0;
16178 - if (!mm_init(mm))
16179 + if (!mm_init(mm, oldmm->mm_vx_info))
16182 if (init_new_context(tsk, mm))
16183 @@ -521,6 +533,7 @@ fail_nocontext:
16184 * If init_new_context() failed, we cannot use mmput() to free the mm
16185 * because it calls destroy_context()
16187 + clr_vx_info(&mm->mm_vx_info);
16191 @@ -591,6 +604,7 @@ static inline struct fs_struct *__copy_f
16192 fs->altroot = NULL;
16194 read_unlock(&old->lock);
16195 + atomic_inc(&vs_global_fs);
16199 @@ -709,6 +723,8 @@ static struct files_struct *dup_fd(struc
16200 struct file *f = *old_fds++;
16203 + /* TODO: sum it first for check and performance */
16204 + vx_openfd_inc(open_files - i);
16207 * The fd may be claimed in the fd bitmap but not yet
16208 @@ -961,6 +977,8 @@ static struct task_struct *copy_process(
16211 struct task_struct *p = NULL;
16212 + struct vx_info *vxi;
16213 + struct nx_info *nxi;
16215 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
16216 return ERR_PTR(-EINVAL);
16217 @@ -995,12 +1013,30 @@ static struct task_struct *copy_process(
16218 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
16219 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
16221 + init_vx_info(&p->vx_info, current->vx_info);
16222 + init_nx_info(&p->nx_info, current->nx_info);
16224 + /* check vserver memory */
16225 + if (p->mm && !(clone_flags & CLONE_VM)) {
16226 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
16227 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
16229 + goto bad_fork_free;
16231 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
16232 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
16233 + goto bad_fork_cleanup_vm;
16237 + if (!vx_nproc_avail(1))
16238 + goto bad_fork_cleanup_vm;
16240 if (atomic_read(&p->user->processes) >=
16241 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
16242 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
16243 p->user != &root_user)
16244 - goto bad_fork_free;
16245 + goto bad_fork_cleanup_vm;
16248 atomic_inc(&p->user->__count);
16249 @@ -1265,6 +1301,18 @@ static struct task_struct *copy_process(
16252 spin_unlock(¤t->sighand->siglock);
16254 + /* p is copy of current */
16255 + vxi = p->vx_info;
16257 + claim_vx_info(vxi, p);
16258 + atomic_inc(&vxi->cvirt.nr_threads);
16259 + atomic_inc(&vxi->cvirt.total_forks);
16262 + nxi = p->nx_info;
16264 + claim_nx_info(nxi, p);
16265 write_unlock_irq(&tasklist_lock);
16266 proc_fork_connector(p);
16268 @@ -1306,6 +1354,9 @@ bad_fork_cleanup_count:
16269 put_group_info(p->group_info);
16270 atomic_dec(&p->user->processes);
16272 +bad_fork_cleanup_vm:
16273 + if (p->mm && !(clone_flags & CLONE_VM))
16274 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
16278 @@ -1367,6 +1418,14 @@ long do_fork(unsigned long clone_flags,
16283 + /* kernel threads are host only */
16284 + if ((clone_flags & CLONE_KTHREAD) && !vx_check(0, VS_ADMIN)) {
16285 + vxwprintk_task(1, "tried to spawn a kernel thread.");
16291 if (unlikely(current->ptrace)) {
16292 trace = fork_traceflag (clone_flags);
16293 diff -NurpP --minimal linux-2.6.22.10/kernel/kthread.c linux-2.6.22.10-vs2.2.0.5/kernel/kthread.c
16294 --- linux-2.6.22.10/kernel/kthread.c 2007-07-09 13:20:03 +0200
16295 +++ linux-2.6.22.10-vs2.2.0.5/kernel/kthread.c 2007-06-15 02:37:04 +0200
16296 @@ -96,7 +96,7 @@ static void create_kthread(struct kthrea
16298 wait_for_completion(&create->started);
16299 read_lock(&tasklist_lock);
16300 - create->result = find_task_by_pid(pid);
16301 + create->result = find_task_by_real_pid(pid);
16302 read_unlock(&tasklist_lock);
16304 complete(&create->done);
16305 diff -NurpP --minimal linux-2.6.22.10/kernel/nsproxy.c linux-2.6.22.10-vs2.2.0.5/kernel/nsproxy.c
16306 --- linux-2.6.22.10/kernel/nsproxy.c 2007-07-09 13:20:03 +0200
16307 +++ linux-2.6.22.10-vs2.2.0.5/kernel/nsproxy.c 2007-07-07 04:12:31 +0200
16308 @@ -20,14 +20,11 @@
16309 #include <linux/mnt_namespace.h>
16310 #include <linux/utsname.h>
16311 #include <linux/pid_namespace.h>
16312 +#include <linux/vserver/global.h>
16313 +#include <linux/vserver/debug.h>
16315 struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
16317 -static inline void get_nsproxy(struct nsproxy *ns)
16319 - atomic_inc(&ns->count);
16322 void get_task_namespaces(struct task_struct *tsk)
16324 struct nsproxy *ns = tsk->nsproxy;
16325 @@ -46,6 +43,9 @@ static inline struct nsproxy *clone_nspr
16326 ns = kmemdup(orig, sizeof(struct nsproxy), GFP_KERNEL);
16328 atomic_set(&ns->count, 1);
16329 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
16330 + orig, atomic_read(&orig->count), ns);
16331 + atomic_inc(&vs_global_nsproxy);
16335 @@ -54,28 +54,32 @@ static inline struct nsproxy *clone_nspr
16336 * Return the newly created nsproxy. Do not attach this to the task,
16337 * leave it to the caller to do proper locking and attach it to task.
16339 -static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
16340 +static struct nsproxy *unshare_namespaces(int flags, struct nsproxy *orig,
16341 struct fs_struct *new_fs)
16343 struct nsproxy *new_nsp;
16345 - new_nsp = clone_nsproxy(tsk->nsproxy);
16346 + vxdprintk(VXD_CBIT(space, 4),
16347 + "unshare_namespaces(0x%08x,%p,%p)",
16348 + flags, orig, new_fs);
16350 + new_nsp = clone_nsproxy(orig);
16352 return ERR_PTR(-ENOMEM);
16354 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
16355 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
16356 if (IS_ERR(new_nsp->mnt_ns))
16359 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
16360 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
16361 if (IS_ERR(new_nsp->uts_ns))
16364 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
16365 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
16366 if (IS_ERR(new_nsp->ipc_ns))
16369 - new_nsp->pid_ns = copy_pid_ns(flags, tsk->nsproxy->pid_ns);
16370 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
16371 if (IS_ERR(new_nsp->pid_ns))
16374 @@ -95,6 +99,33 @@ out_ns:
16375 return ERR_PTR(-ENOMEM);
16378 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
16379 + struct fs_struct *new_fs)
16381 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
16385 + * copies the nsproxy, setting refcount to 1, and grabbing a
16386 + * reference to all contained namespaces.
16388 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
16390 + struct nsproxy *ns = clone_nsproxy(orig);
16394 + get_mnt_ns(ns->mnt_ns);
16396 + get_uts_ns(ns->uts_ns);
16398 + get_ipc_ns(ns->ipc_ns);
16400 + get_pid_ns(ns->pid_ns);
16406 * called from clone. This now handles copy for nsproxy and all
16407 * namespaces therein.
16408 @@ -102,9 +133,12 @@ out_ns:
16409 int copy_namespaces(int flags, struct task_struct *tsk)
16411 struct nsproxy *old_ns = tsk->nsproxy;
16412 - struct nsproxy *new_ns;
16413 + struct nsproxy *new_ns = NULL;
16416 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08x,%p[%p])",
16417 + flags, tsk, old_ns);
16422 @@ -127,6 +161,9 @@ int copy_namespaces(int flags, struct ta
16423 tsk->nsproxy = new_ns;
16425 put_nsproxy(old_ns);
16426 + vxdprintk(VXD_CBIT(space, 3),
16427 + "copy_namespaces(0x%08x,%p[%p]) = %d [%p]",
16428 + flags, tsk, old_ns, err, new_ns);
16432 @@ -140,6 +177,7 @@ void free_nsproxy(struct nsproxy *ns)
16433 put_ipc_ns(ns->ipc_ns);
16435 put_pid_ns(ns->pid_ns);
16436 + atomic_dec(&vs_global_nsproxy);
16440 @@ -152,6 +190,10 @@ int unshare_nsproxy_namespaces(unsigned
16444 + vxdprintk(VXD_CBIT(space, 4),
16445 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
16446 + unshare_flags, current->nsproxy);
16448 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC)))
16451 diff -NurpP --minimal linux-2.6.22.10/kernel/pid.c linux-2.6.22.10-vs2.2.0.5/kernel/pid.c
16452 --- linux-2.6.22.10/kernel/pid.c 2007-07-09 13:20:03 +0200
16453 +++ linux-2.6.22.10-vs2.2.0.5/kernel/pid.c 2007-06-15 04:04:09 +0200
16455 #include <linux/hash.h>
16456 #include <linux/pid_namespace.h>
16457 #include <linux/init_task.h>
16458 +#include <linux/vs_pid.h>
16460 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
16461 static struct hlist_head *pid_hash;
16462 @@ -295,6 +296,9 @@ void fastcall transfer_pid(struct task_s
16463 struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type)
16465 struct task_struct *result = NULL;
16467 + if (type == PIDTYPE_REALPID)
16468 + type = PIDTYPE_PID;
16470 struct hlist_node *first;
16471 first = rcu_dereference(pid->tasks[type].first);
16472 @@ -309,7 +313,17 @@ struct task_struct * fastcall pid_task(s
16474 struct task_struct *find_task_by_pid_type(int type, int nr)
16476 - return pid_task(find_pid(nr), type);
16477 + struct task_struct *task;
16479 + if (type == PIDTYPE_PID)
16480 + nr = vx_rmap_pid(nr);
16482 + task = pid_task(find_pid(nr), type);
16483 + if (task && (type != PIDTYPE_REALPID) &&
16484 + /* maybe VS_WATCH_P in the future? */
16485 + !vx_check(task->xid, VS_WATCH|VS_IDENT))
16490 EXPORT_SYMBOL(find_task_by_pid_type);
16491 diff -NurpP --minimal linux-2.6.22.10/kernel/posix-timers.c linux-2.6.22.10-vs2.2.0.5/kernel/posix-timers.c
16492 --- linux-2.6.22.10/kernel/posix-timers.c 2007-07-09 13:20:03 +0200
16493 +++ linux-2.6.22.10-vs2.2.0.5/kernel/posix-timers.c 2007-10-11 14:14:00 +0200
16495 #include <linux/wait.h>
16496 #include <linux/workqueue.h>
16497 #include <linux/module.h>
16498 +#include <linux/vs_context.h>
16501 * Management arrays for POSIX timers. Timers are kept in slab memory
16502 @@ -297,6 +298,12 @@ void do_schedule_next_timer(struct sigin
16504 int posix_timer_event(struct k_itimer *timr,int si_private)
16506 + struct vx_info_save vxis;
16507 + struct vx_info *vxi;
16510 + vxi = task_get_vx_info(timr->it_process);
16511 + enter_vx_info(vxi, &vxis);
16512 memset(&timr->sigq->info, 0, sizeof(siginfo_t));
16513 timr->sigq->info.si_sys_private = si_private;
16514 /* Send signal to the process that owns this timer.*/
16515 @@ -309,11 +316,11 @@ int posix_timer_event(struct k_itimer *t
16517 if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
16518 struct task_struct *leader;
16519 - int ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
16520 - timr->it_process);
16522 + ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
16523 + timr->it_process);
16524 if (likely(ret >= 0))
16528 timr->it_sigev_notify = SIGEV_SIGNAL;
16529 leader = timr->it_process->group_leader;
16530 @@ -321,8 +328,12 @@ int posix_timer_event(struct k_itimer *t
16531 timr->it_process = leader;
16534 - return send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
16535 + ret = send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
16538 + leave_vx_info(&vxis);
16539 + put_vx_info(vxi);
16542 EXPORT_SYMBOL_GPL(posix_timer_event);
16544 @@ -402,7 +413,7 @@ static struct task_struct * good_sigeven
16545 struct task_struct *rtn = current->group_leader;
16547 if ((event->sigev_notify & SIGEV_THREAD_ID ) &&
16548 - (!(rtn = find_task_by_pid(event->sigev_notify_thread_id)) ||
16549 + (!(rtn = find_task_by_real_pid(event->sigev_notify_thread_id)) ||
16550 rtn->tgid != current->tgid ||
16551 (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL))
16553 diff -NurpP --minimal linux-2.6.22.10/kernel/printk.c linux-2.6.22.10-vs2.2.0.5/kernel/printk.c
16554 --- linux-2.6.22.10/kernel/printk.c 2007-07-09 13:20:03 +0200
16555 +++ linux-2.6.22.10-vs2.2.0.5/kernel/printk.c 2007-06-15 02:37:04 +0200
16557 #include <linux/bootmem.h>
16558 #include <linux/syscalls.h>
16559 #include <linux/jiffies.h>
16560 +#include <linux/vs_cvirt.h>
16562 #include <asm/uaccess.h>
16564 @@ -182,18 +183,13 @@ int do_syslog(int type, char __user *buf
16565 unsigned long i, j, limit, count;
16571 error = security_syslog(type);
16576 - case 0: /* Close log */
16578 - case 1: /* Open log */
16580 - case 2: /* Read from log */
16581 + if ((type >= 2) && (type <= 4)) {
16583 if (!buf || len < 0)
16585 @@ -204,6 +200,16 @@ int do_syslog(int type, char __user *buf
16590 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
16591 + return vx_do_syslog(type, buf, len);
16594 + case 0: /* Close log */
16596 + case 1: /* Open log */
16598 + case 2: /* Read from log */
16599 error = wait_event_interruptible(log_wait,
16600 (log_start - log_end));
16602 @@ -228,16 +234,6 @@ int do_syslog(int type, char __user *buf
16605 case 3: /* Read last kernel messages */
16607 - if (!buf || len < 0)
16612 - if (!access_ok(VERIFY_WRITE, buf, len)) {
16617 if (count > log_buf_len)
16618 count = log_buf_len;
16619 diff -NurpP --minimal linux-2.6.22.10/kernel/ptrace.c linux-2.6.22.10-vs2.2.0.5/kernel/ptrace.c
16620 --- linux-2.6.22.10/kernel/ptrace.c 2007-07-09 13:20:03 +0200
16621 +++ linux-2.6.22.10-vs2.2.0.5/kernel/ptrace.c 2007-06-15 04:28:02 +0200
16623 #include <linux/security.h>
16624 #include <linux/signal.h>
16625 #include <linux/audit.h>
16626 +#include <linux/vs_context.h>
16628 #include <asm/pgtable.h>
16629 #include <asm/uaccess.h>
16630 @@ -145,6 +146,11 @@ static int may_attach(struct task_struct
16631 dumpable = task->mm->dumpable;
16632 if (!dumpable && !capable(CAP_SYS_PTRACE))
16634 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
16636 + if (!vx_check(task->xid, VS_IDENT) &&
16637 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
16640 return security_ptrace(current, task);
16642 @@ -471,6 +477,10 @@ asmlinkage long sys_ptrace(long request,
16647 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
16648 + goto out_put_task_struct;
16650 if (request == PTRACE_ATTACH) {
16651 ret = ptrace_attach(child);
16652 goto out_put_task_struct;
16653 diff -NurpP --minimal linux-2.6.22.10/kernel/sched.c linux-2.6.22.10-vs2.2.0.5/kernel/sched.c
16654 --- linux-2.6.22.10/kernel/sched.c 2007-07-09 13:20:03 +0200
16655 +++ linux-2.6.22.10-vs2.2.0.5/kernel/sched.c 2007-07-07 03:52:54 +0200
16658 #include <asm/tlb.h>
16659 #include <asm/unistd.h>
16660 +#include <linux/vs_sched.h>
16661 +#include <linux/vs_cvirt.h>
16664 * Scheduler clock - returns current time in nanosec units.
16665 @@ -281,6 +283,16 @@ struct rq {
16666 struct task_struct *migration_thread;
16667 struct list_head migration_queue;
16669 + unsigned long norm_time;
16670 + unsigned long idle_time;
16671 +#ifdef CONFIG_VSERVER_IDLETIME
16674 +#ifdef CONFIG_VSERVER_HARDCPU
16675 + struct list_head hold_queue;
16676 + unsigned long nr_onhold;
16680 #ifdef CONFIG_SCHEDSTATS
16681 /* latency stats */
16682 @@ -714,6 +726,7 @@ sched_info_switch(struct task_struct *pr
16684 static void dequeue_task(struct task_struct *p, struct prio_array *array)
16686 + BUG_ON(p->state & TASK_ONHOLD);
16687 array->nr_active--;
16688 list_del(&p->run_list);
16689 if (list_empty(array->queue + p->prio))
16690 @@ -722,6 +735,7 @@ static void dequeue_task(struct task_str
16692 static void enqueue_task(struct task_struct *p, struct prio_array *array)
16694 + BUG_ON(p->state & TASK_ONHOLD);
16695 sched_info_queued(p);
16696 list_add_tail(&p->run_list, array->queue + p->prio);
16697 __set_bit(p->prio, array->bitmap);
16698 @@ -735,12 +749,14 @@ static void enqueue_task(struct task_str
16700 static void requeue_task(struct task_struct *p, struct prio_array *array)
16702 + BUG_ON(p->state & TASK_ONHOLD);
16703 list_move_tail(&p->run_list, array->queue + p->prio);
16707 enqueue_task_head(struct task_struct *p, struct prio_array *array)
16709 + BUG_ON(p->state & TASK_ONHOLD);
16710 list_add(&p->run_list, array->queue + p->prio);
16711 __set_bit(p->prio, array->bitmap);
16712 array->nr_active++;
16713 @@ -769,6 +785,10 @@ static inline int __normal_prio(struct t
16714 bonus = CURRENT_BONUS(p) - MAX_BONUS / 2;
16716 prio = p->static_prio - bonus;
16718 + /* adjust effective priority */
16719 + prio = vx_adjust_prio(p, prio, MAX_USER_PRIO);
16721 if (prio < MAX_RT_PRIO)
16722 prio = MAX_RT_PRIO;
16723 if (prio > MAX_PRIO-1)
16724 @@ -878,6 +898,9 @@ static int effective_prio(struct task_st
16728 +#include "sched_mon.h"
16732 * __activate_task - move a task to the runqueue.
16734 @@ -887,6 +910,7 @@ static void __activate_task(struct task_
16737 target = rq->expired;
16738 + vxm_activate_task(p, rq);
16739 enqueue_task(p, target);
16740 inc_nr_running(p, rq);
16742 @@ -896,6 +920,7 @@ static void __activate_task(struct task_
16744 static inline void __activate_idle_task(struct task_struct *p, struct rq *rq)
16746 + vxm_activate_idle(p, rq);
16747 enqueue_task_head(p, rq->active);
16748 inc_nr_running(p, rq);
16750 @@ -1030,19 +1055,30 @@ static void activate_task(struct task_st
16752 p->timestamp = now;
16754 + vx_activate_task(p);
16755 __activate_task(p, rq);
16759 - * deactivate_task - remove a task from the runqueue.
16760 + * __deactivate_task - remove a task from the runqueue.
16762 -static void deactivate_task(struct task_struct *p, struct rq *rq)
16763 +static void __deactivate_task(struct task_struct *p, struct rq *rq)
16765 dec_nr_running(p, rq);
16766 dequeue_task(p, p->array);
16767 + vxm_deactivate_task(p, rq);
16772 +void deactivate_task(struct task_struct *p, struct rq *rq)
16774 + vx_deactivate_task(p);
16775 + __deactivate_task(p, rq);
16778 +#include "sched_hard.h"
16781 * resched_task - mark a task 'to be rescheduled now'.
16783 @@ -1129,6 +1165,7 @@ migrate_task(struct task_struct *p, int
16785 struct rq *rq = task_rq(p);
16787 + vxm_migrate_task(p, rq, dest_cpu);
16789 * If the task is not on a runqueue (and not running), then
16790 * it is sufficient to simply update the task's cpu field.
16791 @@ -1518,6 +1555,12 @@ static int try_to_wake_up(struct task_st
16793 rq = task_rq_lock(p, &flags);
16794 old_state = p->state;
16796 + /* we need to unhold suspended tasks */
16797 + if (old_state & TASK_ONHOLD) {
16798 + vx_unhold_task(p, rq);
16799 + old_state = p->state;
16801 if (!(old_state & state))
16804 @@ -1625,6 +1668,7 @@ out_activate:
16805 #endif /* CONFIG_SMP */
16806 if (old_state == TASK_UNINTERRUPTIBLE) {
16807 rq->nr_uninterruptible--;
16808 + vx_uninterruptible_dec(p);
16810 * Tasks on involuntary sleep don't earn
16811 * sleep_avg beyond just interactive state.
16812 @@ -1676,7 +1720,7 @@ int fastcall wake_up_state(struct task_s
16813 return try_to_wake_up(p, state, 0);
16816 -static void task_running_tick(struct rq *rq, struct task_struct *p);
16817 +static void task_running_tick(struct rq *rq, struct task_struct *p, int cpu);
16819 * Perform scheduler related setup for a newly forked process p.
16820 * p is forked by current.
16821 @@ -1737,7 +1781,7 @@ void fastcall sched_fork(struct task_str
16822 * runqueue lock is not a problem.
16824 current->time_slice = 1;
16825 - task_running_tick(cpu_rq(cpu), current);
16826 + task_running_tick(cpu_rq(cpu), current, cpu);
16828 local_irq_enable();
16830 @@ -1772,6 +1816,7 @@ void fastcall wake_up_new_task(struct ta
16832 p->prio = effective_prio(p);
16834 + vx_activate_task(p);
16835 if (likely(cpu == this_cpu)) {
16836 if (!(clone_flags & CLONE_VM)) {
16838 @@ -1783,6 +1828,7 @@ void fastcall wake_up_new_task(struct ta
16839 __activate_task(p, rq);
16841 p->prio = current->prio;
16842 + BUG_ON(p->state & TASK_ONHOLD);
16843 p->normal_prio = current->normal_prio;
16844 list_add_tail(&p->run_list, ¤t->run_list);
16845 p->array = current->array;
16846 @@ -3351,13 +3397,16 @@ static inline int expired_starving(struc
16847 void account_user_time(struct task_struct *p, cputime_t cputime)
16849 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16850 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16852 + int nice = (TASK_NICE(p) > 0);
16854 p->utime = cputime_add(p->utime, cputime);
16855 + vx_account_user(vxi, cputime, nice);
16857 /* Add user time to cpustat. */
16858 tmp = cputime_to_cputime64(cputime);
16859 - if (TASK_NICE(p) > 0)
16861 cpustat->nice = cputime64_add(cpustat->nice, tmp);
16863 cpustat->user = cputime64_add(cpustat->user, tmp);
16864 @@ -3373,10 +3422,12 @@ void account_system_time(struct task_str
16867 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16868 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16869 struct rq *rq = this_rq();
16872 p->stime = cputime_add(p->stime, cputime);
16873 + vx_account_system(vxi, cputime, (p == rq->idle));
16875 /* Add system time to cpustat. */
16876 tmp = cputime_to_cputime64(cputime);
16877 @@ -3415,7 +3466,7 @@ void account_steal_time(struct task_stru
16878 cpustat->steal = cputime64_add(cpustat->steal, tmp);
16881 -static void task_running_tick(struct rq *rq, struct task_struct *p)
16882 +static void task_running_tick(struct rq *rq, struct task_struct *p, int cpu)
16884 if (p->array != rq->active) {
16885 /* Task has expired but was not scheduled yet */
16886 @@ -3445,7 +3496,7 @@ static void task_running_tick(struct rq
16890 - if (!--p->time_slice) {
16891 + if (vx_need_resched(p, --p->time_slice, cpu)) {
16892 dequeue_task(p, rq->active);
16893 set_tsk_need_resched(p);
16894 p->prio = effective_prio(p);
16895 @@ -3506,9 +3557,12 @@ void scheduler_tick(void)
16896 struct rq *rq = cpu_rq(cpu);
16898 update_cpu_clock(p, rq, now);
16900 - if (!idle_at_tick)
16901 - task_running_tick(rq, p);
16902 + vxm_sync(now, cpu);
16904 + if (idle_at_tick)
16905 + vx_idle_resched(rq);
16907 + task_running_tick(rq, p, cpu);
16910 rq->idle_at_tick = idle_at_tick;
16911 @@ -3630,14 +3684,25 @@ need_resched_nonpreemptible:
16912 unlikely(signal_pending(prev))))
16913 prev->state = TASK_RUNNING;
16915 - if (prev->state == TASK_UNINTERRUPTIBLE)
16916 + if (prev->state == TASK_UNINTERRUPTIBLE) {
16917 rq->nr_uninterruptible++;
16918 + vx_uninterruptible_inc(prev);
16920 deactivate_task(prev, rq);
16924 cpu = smp_processor_id();
16925 + vx_set_rq_time(rq, jiffies);
16927 + vx_try_unhold(rq, cpu);
16930 if (unlikely(!rq->nr_running)) {
16931 + /* can we skip idle time? */
16932 + if (vx_try_skip(rq, cpu))
16935 idle_balance(cpu, rq);
16936 if (!rq->nr_running) {
16938 @@ -3663,6 +3728,10 @@ need_resched_nonpreemptible:
16939 queue = array->queue + idx;
16940 next = list_entry(queue->next, struct task_struct, run_list);
16942 + /* check before we schedule this context */
16943 + if (!vx_schedule(next, rq, cpu))
16946 if (!rt_task(next) && interactive_sleep(next->sleep_type)) {
16947 unsigned long long delta = now - next->timestamp;
16948 if (unlikely((long long)(now - next->timestamp) < 0))
16949 @@ -4263,7 +4332,7 @@ asmlinkage long sys_nice(int increment)
16952 if (increment < 0 && !can_nice(current, nice))
16954 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
16956 retval = security_task_setnice(current, nice);
16958 @@ -4435,6 +4504,7 @@ recheck:
16960 __setscheduler(p, policy, param->sched_priority);
16962 + vx_activate_task(p);
16963 __activate_task(p, rq);
16965 * Reschedule if we are currently running on this runqueue and
16966 @@ -5188,6 +5258,7 @@ static int __migrate_task(struct task_st
16967 p->timestamp = p->timestamp - rq_src->most_recent_timestamp
16968 + rq_dest->most_recent_timestamp;
16969 deactivate_task(p, rq_src);
16970 + vx_activate_task(p);
16971 __activate_task(p, rq_dest);
16972 if (TASK_PREEMPTS_CURR(p, rq_dest))
16973 resched_task(rq_dest->curr);
16974 @@ -7058,7 +7129,10 @@ void __init sched_init(void)
16975 INIT_LIST_HEAD(&rq->migration_queue);
16977 atomic_set(&rq->nr_iowait, 0);
16979 +#ifdef CONFIG_VSERVER_HARDCPU
16980 + INIT_LIST_HEAD(&rq->hold_queue);
16981 + rq->nr_onhold = 0;
16983 for (j = 0; j < 2; j++) {
16984 array = rq->arrays + j;
16985 for (k = 0; k < MAX_PRIO; k++) {
16986 @@ -7144,6 +7218,7 @@ void normalize_rt_tasks(void)
16987 deactivate_task(p, task_rq(p));
16988 __setscheduler(p, SCHED_NORMAL, 0);
16990 + vx_activate_task(p);
16991 __activate_task(p, task_rq(p));
16992 resched_task(rq->curr);
16994 diff -NurpP --minimal linux-2.6.22.10/kernel/sched_hard.h linux-2.6.22.10-vs2.2.0.5/kernel/sched_hard.h
16995 --- linux-2.6.22.10/kernel/sched_hard.h 1970-01-01 01:00:00 +0100
16996 +++ linux-2.6.22.10-vs2.2.0.5/kernel/sched_hard.h 2007-06-15 19:20:10 +0200
16999 +#ifdef CONFIG_VSERVER_IDLELIMIT
17002 + * vx_idle_resched - reschedule after maxidle
17005 +void vx_idle_resched(struct rq *rq)
17007 + /* maybe have a better criterion for paused */
17008 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
17009 + set_need_resched();
17012 +#else /* !CONFIG_VSERVER_IDLELIMIT */
17014 +#define vx_idle_resched(rq)
17016 +#endif /* CONFIG_VSERVER_IDLELIMIT */
17020 +#ifdef CONFIG_VSERVER_IDLETIME
17022 +#define vx_set_rq_min_skip(rq, min) \
17023 + (rq)->idle_skip = (min)
17025 +#define vx_save_min_skip(ret, min, val) \
17026 + __vx_save_min_skip(ret, min, val)
17029 +void __vx_save_min_skip(int ret, int *min, int val)
17033 + if ((*min > val) || !*min)
17038 +int vx_try_skip(struct rq *rq, int cpu)
17040 + /* artificially advance time */
17041 + if (rq->idle_skip > 0) {
17042 + vxdprintk(list_empty(&rq->hold_queue),
17043 + "hold queue empty on cpu %d", cpu);
17044 + rq->idle_time += rq->idle_skip;
17045 + vxm_idle_skip(rq, cpu);
17051 +#else /* !CONFIG_VSERVER_IDLETIME */
17053 +#define vx_set_rq_min_skip(rq, min) \
17054 + ({ int dummy = (min); dummy; })
17056 +#define vx_save_min_skip(ret, min, val)
17059 +int vx_try_skip(struct rq *rq, int cpu)
17064 +#endif /* CONFIG_VSERVER_IDLETIME */
17068 +#ifdef CONFIG_VSERVER_HARDCPU
17070 +#define vx_set_rq_max_idle(rq, max) \
17071 + (rq)->idle_tokens = (max)
17073 +#define vx_save_max_idle(ret, min, val) \
17074 + __vx_save_max_idle(ret, min, val)
17077 +void __vx_save_max_idle(int ret, int *min, int val)
17085 + * vx_hold_task - put a task on the hold queue
17088 +void vx_hold_task(struct task_struct *p, struct rq *rq)
17090 + __deactivate_task(p, rq);
17091 + p->state |= TASK_ONHOLD;
17092 + /* a new one on hold */
17094 + vxm_hold_task(p, rq);
17095 + list_add_tail(&p->run_list, &rq->hold_queue);
17099 + * vx_unhold_task - put a task back to the runqueue
17102 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
17104 + list_del(&p->run_list);
17105 + /* one less waiting */
17107 + p->state &= ~TASK_ONHOLD;
17108 + enqueue_task(p, rq->expired);
17109 + inc_nr_running(p, rq);
17110 + vxm_unhold_task(p, rq);
17112 + if (p->static_prio < rq->best_expired_prio)
17113 + rq->best_expired_prio = p->static_prio;
17116 +unsigned long nr_onhold(void)
17118 + unsigned long i, sum = 0;
17120 + for_each_online_cpu(i)
17121 + sum += cpu_rq(i)->nr_onhold;
17129 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
17131 + return sched_pc->tokens;
17135 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
17137 + sched_pc->tokens--;
17141 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
17143 + struct vx_info *vxi = p->vx_info;
17145 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
17146 + struct _vx_sched_pc *sched_pc =
17147 + &vx_per_cpu(vxi, sched_pc, cpu);
17150 + /* maybe we can simplify that to decrement
17151 + the token counter unconditional? */
17153 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
17154 + __vx_consume_token(sched_pc);
17156 + /* for tokens > 0, one token was consumed */
17160 + vxm_need_resched(p, slice, cpu);
17161 + return (slice == 0);
17165 +#define vx_set_rq_time(rq, time) do { \
17166 + rq->norm_time = time; \
17171 +void vx_try_unhold(struct rq *rq, int cpu)
17173 + struct vx_info *vxi = NULL;
17174 + struct list_head *l, *n;
17175 + int maxidle = HZ;
17178 + /* nothing to do? what about pause? */
17179 + if (list_empty(&rq->hold_queue))
17182 + list_for_each_safe(l, n, &rq->hold_queue) {
17183 + int ret, delta_min[2];
17184 + struct _vx_sched_pc *sched_pc;
17185 + struct task_struct *p;
17187 + p = list_entry(l, struct task_struct, run_list);
17188 + /* don't bother with same context */
17189 + if (vxi == p->vx_info)
17192 + vxi = p->vx_info;
17193 + /* ignore paused contexts */
17194 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
17197 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
17199 + /* recalc tokens */
17200 + vxm_sched_info(sched_pc, vxi, cpu);
17201 + ret = vx_tokens_recalc(sched_pc,
17202 + &rq->norm_time, &rq->idle_time, delta_min);
17203 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
17206 + /* we found a runable context */
17207 + vx_unhold_task(p, rq);
17210 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
17211 + vx_save_min_skip(ret, &minskip, delta_min[1]);
17213 + vx_set_rq_max_idle(rq, maxidle);
17214 + vx_set_rq_min_skip(rq, minskip);
17215 + vxm_rq_max_min(rq, cpu);
17220 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
17222 + struct vx_info *vxi = next->vx_info;
17223 + struct _vx_sched_pc *sched_pc;
17224 + int delta_min[2];
17230 + flags = vxi->vx_flags;
17232 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
17233 + goto put_on_hold;
17234 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
17237 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
17239 + /* update scheduler params */
17240 + if (cpu_isset(cpu, vxi->sched.update)) {
17241 + vx_update_sched_param(&vxi->sched, sched_pc);
17242 + vxm_update_sched(sched_pc, vxi, cpu);
17243 + cpu_clear(cpu, vxi->sched.update);
17246 + vxm_sched_info(sched_pc, vxi, cpu);
17247 + ret = vx_tokens_recalc(sched_pc,
17248 + &rq->norm_time, &rq->idle_time, delta_min);
17249 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
17251 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
17254 + if (unlikely(ret < 0)) {
17255 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
17256 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
17257 + vxm_rq_max_min(rq, cpu);
17259 + vx_hold_task(next, rq);
17266 +#else /* CONFIG_VSERVER_HARDCPU */
17269 +void vx_hold_task(struct task_struct *p, struct rq *rq)
17275 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
17280 +unsigned long nr_onhold(void)
17287 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
17289 + return (slice == 0);
17293 +#define vx_set_rq_time(rq, time)
17296 +void vx_try_unhold(struct rq *rq, int cpu)
17302 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
17304 + struct vx_info *vxi = next->vx_info;
17305 + struct _vx_sched_pc *sched_pc;
17306 + int delta_min[2];
17309 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
17312 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
17313 + vxm_sched_info(sched_pc, vxi, cpu);
17314 + ret = vx_tokens_recalc(sched_pc,
17315 + &rq->norm_time, &rq->idle_time, delta_min);
17316 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
17320 +#endif /* CONFIG_VSERVER_HARDCPU */
17322 diff -NurpP --minimal linux-2.6.22.10/kernel/sched_mon.h linux-2.6.22.10-vs2.2.0.5/kernel/sched_mon.h
17323 --- linux-2.6.22.10/kernel/sched_mon.h 1970-01-01 01:00:00 +0100
17324 +++ linux-2.6.22.10-vs2.2.0.5/kernel/sched_mon.h 2007-06-15 02:37:04 +0200
17327 +#include <linux/vserver/monitor.h>
17329 +#ifdef CONFIG_VSERVER_MONITOR
17331 +#ifdef CONFIG_VSERVER_HARDCPU
17332 +#define HARDCPU(x) (x)
17334 +#define HARDCPU(x) (0)
17337 +#ifdef CONFIG_VSERVER_IDLETIME
17338 +#define IDLETIME(x) (x)
17340 +#define IDLETIME(x) (0)
17343 +struct _vx_mon_entry *vxm_advance(int cpu);
17347 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
17349 + entry->type = type;
17350 + entry->xid = xid;
17354 +void __vxm_sync(int cpu)
17356 + struct _vx_mon_entry *entry = vxm_advance(cpu);
17358 + __vxm_basic(entry, 0, VXM_SYNC);
17359 + entry->ev.sec = xtime.tv_sec;
17360 + entry->ev.nsec = xtime.tv_nsec;
17364 +void __vxm_task(struct task_struct *p, int type)
17366 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
17368 + __vxm_basic(entry, p->xid, type);
17369 + entry->ev.tsk.pid = p->pid;
17370 + entry->ev.tsk.state = p->state;
17374 +void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
17376 + struct _vx_mon_entry *entry = vxm_advance(cpu);
17378 + __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
17379 + entry->sd.tokens = s->tokens;
17380 + entry->sd.norm_time = s->norm_time;
17381 + entry->sd.idle_time = s->idle_time;
17385 +void __vxm_rqinfo1(struct rq *q, int cpu)
17387 + struct _vx_mon_entry *entry = vxm_advance(cpu);
17389 + entry->type = VXM_RQINFO_1;
17390 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
17391 + entry->q1.running = q->nr_running;
17392 + entry->q1.onhold = HARDCPU(q->nr_onhold);
17393 + entry->q1.iowait = atomic_read(&q->nr_iowait);
17394 + entry->q1.uintr = q->nr_uninterruptible;
17395 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
17399 +void __vxm_rqinfo2(struct rq *q, int cpu)
17401 + struct _vx_mon_entry *entry = vxm_advance(cpu);
17403 + entry->type = VXM_RQINFO_2;
17404 + entry->xid = (unsigned long)q & 0xffff;
17405 + entry->q2.norm_time = q->norm_time;
17406 + entry->q2.idle_time = q->idle_time;
17407 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
17411 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
17413 + struct _vx_mon_entry *entry = vxm_advance(cpu);
17415 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
17416 + entry->ev.tokens = s->tokens;
17420 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
17422 + struct _vx_mon_entry *entry = vxm_advance(cpu);
17424 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
17425 + entry->u1.tokens_max = s->tokens_max;
17426 + entry->u1.fill_rate = s->fill_rate[0];
17427 + entry->u1.interval = s->interval[0];
17431 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
17433 + struct _vx_mon_entry *entry = vxm_advance(cpu);
17435 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
17436 + entry->u2.tokens_min = s->tokens_min;
17437 + entry->u2.fill_rate = s->fill_rate[1];
17438 + entry->u2.interval = s->interval[1];
17442 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
17443 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
17444 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
17445 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
17446 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
17449 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
17451 + __vxm_task(p, VXM_MIGRATE);
17452 + __vxm_rqinfo1(rq, task_cpu(p));
17453 + __vxm_rqinfo2(rq, task_cpu(p));
17457 +void vxm_idle_skip(struct rq *rq, int cpu)
17459 + __vxm_rqinfo1(rq, cpu);
17460 + __vxm_rqinfo2(rq, cpu);
17464 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
17469 + __vxm_task(p, VXM_RESCHED);
17473 +void vxm_sync(unsigned long now, int cpu)
17475 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
17476 + (now % CONFIG_VSERVER_MONITOR_SYNC))
17482 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
17485 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
17486 + struct vx_info *vxi, int cpu)
17488 + __vxm_sched(s, vxi, cpu);
17489 + __vxm_rqinfo2(rq, cpu);
17493 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
17495 + __vxm_sched(s, vxi, cpu);
17496 + __vxm_update(s, vxi, cpu);
17497 + __vxm_update1(s, vxi, cpu);
17498 + __vxm_update2(s, vxi, cpu);
17502 +void vxm_rq_max_min(struct rq *rq, int cpu)
17504 + __vxm_rqinfo1(rq, cpu);
17505 + __vxm_rqinfo2(rq, cpu);
17508 +#else /* CONFIG_VSERVER_MONITOR */
17510 +#define vxm_activate_task(t,q) do { } while (0)
17511 +#define vxm_activate_idle(t,q) do { } while (0)
17512 +#define vxm_deactivate_task(t,q) do { } while (0)
17513 +#define vxm_hold_task(t,q) do { } while (0)
17514 +#define vxm_unhold_task(t,q) do { } while (0)
17515 +#define vxm_migrate_task(t,q,d) do { } while (0)
17516 +#define vxm_idle_skip(q,c) do { } while (0)
17517 +#define vxm_need_resched(t,s,c) do { } while (0)
17518 +#define vxm_sync(s,c) do { } while (0)
17519 +#define vxm_sched_info(s,v,c) do { } while (0)
17520 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
17521 +#define vxm_update_sched(s,v,c) do { } while (0)
17522 +#define vxm_rq_max_min(q,c) do { } while (0)
17524 +#endif /* CONFIG_VSERVER_MONITOR */
17526 diff -NurpP --minimal linux-2.6.22.10/kernel/signal.c linux-2.6.22.10-vs2.2.0.5/kernel/signal.c
17527 --- linux-2.6.22.10/kernel/signal.c 2007-10-30 01:57:15 +0100
17528 +++ linux-2.6.22.10-vs2.2.0.5/kernel/signal.c 2007-10-01 15:25:35 +0200
17530 #include <linux/freezer.h>
17531 #include <linux/pid_namespace.h>
17532 #include <linux/nsproxy.h>
17533 +#include <linux/vs_context.h>
17534 +#include <linux/vs_pid.h>
17536 #include <asm/param.h>
17537 #include <asm/uaccess.h>
17538 @@ -523,19 +525,34 @@ static int check_kill_permission(int sig
17539 if (!valid_signal(sig))
17542 + if ((info != SEND_SIG_NOINFO) &&
17543 + (is_si_special(info) || !SI_FROMUSER(info)))
17546 + vxdprintk(VXD_CBIT(misc, 7),
17547 + "check_kill_permission(%d,%p,%p[#%u,%u])",
17548 + sig, info, t, vx_task_xid(t), t->pid);
17550 error = audit_signal_info(sig, t); /* Let audit system see the signal */
17555 - if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
17556 - && ((sig != SIGCONT) ||
17557 + if (((sig != SIGCONT) ||
17558 (process_session(current) != process_session(t)))
17559 && (current->euid ^ t->suid) && (current->euid ^ t->uid)
17560 && (current->uid ^ t->suid) && (current->uid ^ t->uid)
17561 && !capable(CAP_KILL))
17565 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
17566 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
17567 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
17568 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
17572 return security_task_kill(t, info, sig, 0);
17575 @@ -1043,7 +1060,7 @@ int kill_pid_info(int sig, struct siginf
17577 p = pid_task(pid, PIDTYPE_PID);
17580 + if (p && vx_check(vx_task_xid(p), VS_IDENT))
17581 error = group_send_sig_info(sig, info, p);
17583 if (unlikely(sig_needs_tasklist(sig)))
17584 @@ -1057,7 +1074,7 @@ kill_proc_info(int sig, struct siginfo *
17588 - error = kill_pid_info(sig, info, find_pid(pid));
17589 + error = kill_pid_info(sig, info, find_pid(vx_rmap_pid(pid)));
17593 @@ -1118,7 +1135,8 @@ static int kill_something_info(int sig,
17595 read_lock(&tasklist_lock);
17596 for_each_process(p) {
17597 - if (p->pid > 1 && p->tgid != current->tgid) {
17598 + if (vx_check(vx_task_xid(p), VS_ADMIN_P|VS_IDENT) &&
17599 + p->pid > 1 && p->tgid != current->tgid) {
17600 int err = group_send_sig_info(sig, info, p);
17603 @@ -1814,6 +1832,11 @@ relock:
17604 if (current == child_reaper(current))
17607 + /* virtual init is protected against user signals */
17608 + if ((info->si_code == SI_USER) &&
17609 + vx_current_initpid(current->pid))
17612 if (sig_kernel_stop(signr)) {
17614 * The default action is to stop all threads in
17615 diff -NurpP --minimal linux-2.6.22.10/kernel/softirq.c linux-2.6.22.10-vs2.2.0.5/kernel/softirq.c
17616 --- linux-2.6.22.10/kernel/softirq.c 2007-07-09 13:20:03 +0200
17617 +++ linux-2.6.22.10-vs2.2.0.5/kernel/softirq.c 2007-06-15 02:37:04 +0200
17619 #include <linux/rcupdate.h>
17620 #include <linux/smp.h>
17621 #include <linux/tick.h>
17622 +#include <linux/vs_context.h>
17624 #include <asm/irq.h>
17626 diff -NurpP --minimal linux-2.6.22.10/kernel/sys.c linux-2.6.22.10-vs2.2.0.5/kernel/sys.c
17627 --- linux-2.6.22.10/kernel/sys.c 2007-10-30 01:57:15 +0100
17628 +++ linux-2.6.22.10-vs2.2.0.5/kernel/sys.c 2007-10-30 01:24:36 +0100
17630 #include <linux/compat.h>
17631 #include <linux/syscalls.h>
17632 #include <linux/kprobes.h>
17633 +#include <linux/vs_pid.h>
17635 #include <asm/uaccess.h>
17636 #include <asm/io.h>
17637 @@ -639,7 +640,10 @@ static int set_one_prio(struct task_stru
17640 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17642 + if (vx_flags(VXF_IGNEG_NICE, 0))
17648 no_nice = security_task_setnice(p, niceval);
17649 @@ -687,6 +691,8 @@ asmlinkage long sys_setpriority(int whic
17651 pgrp = task_pgrp(current);
17652 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
17653 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17655 error = set_one_prio(p, niceval, error);
17656 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
17658 @@ -695,7 +701,8 @@ asmlinkage long sys_setpriority(int whic
17660 who = current->uid;
17662 - if ((who != current->uid) && !(user = find_user(who)))
17663 + if ((who != current->uid) &&
17664 + !(user = find_user(vx_current_xid(), who)))
17665 goto out_unlock; /* No processes for this user */
17667 do_each_thread(g, p)
17668 @@ -747,6 +754,8 @@ asmlinkage long sys_getpriority(int whic
17670 pgrp = task_pgrp(current);
17671 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
17672 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17674 niceval = 20 - task_nice(p);
17675 if (niceval > retval)
17677 @@ -757,7 +766,8 @@ asmlinkage long sys_getpriority(int whic
17679 who = current->uid;
17681 - if ((who != current->uid) && !(user = find_user(who)))
17682 + if ((who != current->uid) &&
17683 + !(user = find_user(vx_current_xid(), who)))
17684 goto out_unlock; /* No processes for this user */
17686 do_each_thread(g, p)
17687 @@ -871,6 +881,9 @@ void kernel_power_off(void)
17688 machine_power_off();
17690 EXPORT_SYMBOL_GPL(kernel_power_off);
17692 +long vs_reboot(unsigned int, void __user *);
17695 * Reboot system call: for obvious reasons only root may call it,
17696 * and even root needs to set up some magic numbers in the registers
17697 @@ -901,6 +914,9 @@ asmlinkage long sys_reboot(int magic1, i
17698 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17699 cmd = LINUX_REBOOT_CMD_HALT;
17701 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
17702 + return vs_reboot(cmd, arg);
17706 case LINUX_REBOOT_CMD_RESTART:
17707 @@ -1080,7 +1096,7 @@ static int set_user(uid_t new_ruid, int
17709 struct user_struct *new_user;
17711 - new_user = alloc_uid(new_ruid);
17712 + new_user = alloc_uid(vx_current_xid(), new_ruid);
17716 @@ -1434,15 +1450,18 @@ asmlinkage long sys_setpgid(pid_t pid, p
17718 struct task_struct *p;
17719 struct task_struct *group_leader = current->group_leader;
17724 - pid = group_leader->pid;
17725 + pid = vx_map_pid(group_leader->pid);
17731 + rpgid = vx_rmap_pid(pgid);
17733 /* From this point forward we keep holding onto the tasklist lock
17734 * so that our parent does not change from under us. -DaveM
17736 @@ -1476,20 +1495,20 @@ asmlinkage long sys_setpgid(pid_t pid, p
17739 struct task_struct *g =
17740 - find_task_by_pid_type(PIDTYPE_PGID, pgid);
17741 + find_task_by_pid_type(PIDTYPE_PGID, rpgid);
17743 if (!g || task_session(g) != task_session(group_leader))
17747 - err = security_task_setpgid(p, pgid);
17748 + err = security_task_setpgid(p, rpgid);
17752 - if (process_group(p) != pgid) {
17753 + if (process_group(p) != rpgid) {
17754 detach_pid(p, PIDTYPE_PGID);
17755 - p->signal->pgrp = pgid;
17756 - attach_pid(p, PIDTYPE_PGID, find_pid(pgid));
17757 + p->signal->pgrp = rpgid;
17758 + attach_pid(p, PIDTYPE_PGID, find_pid(rpgid));
17762 @@ -1502,7 +1521,7 @@ out:
17763 asmlinkage long sys_getpgid(pid_t pid)
17766 - return process_group(current);
17767 + return vx_rmap_pid(process_group(current));
17770 struct task_struct *p;
17771 @@ -1514,7 +1533,7 @@ asmlinkage long sys_getpgid(pid_t pid)
17773 retval = security_task_getpgid(p);
17775 - retval = process_group(p);
17776 + retval = vx_rmap_pid(process_group(p));
17778 read_unlock(&tasklist_lock);
17780 @@ -1865,7 +1884,7 @@ asmlinkage long sys_sethostname(char __u
17782 char tmp[__NEW_UTS_LEN];
17784 - if (!capable(CAP_SYS_ADMIN))
17785 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17787 if (len < 0 || len > __NEW_UTS_LEN)
17789 @@ -1910,7 +1929,7 @@ asmlinkage long sys_setdomainname(char _
17791 char tmp[__NEW_UTS_LEN];
17793 - if (!capable(CAP_SYS_ADMIN))
17794 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17796 if (len < 0 || len > __NEW_UTS_LEN)
17798 @@ -1977,7 +1996,7 @@ asmlinkage long sys_setrlimit(unsigned i
17800 old_rlim = current->signal->rlim + resource;
17801 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
17802 - !capable(CAP_SYS_RESOURCE))
17803 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17805 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
17807 diff -NurpP --minimal linux-2.6.22.10/kernel/sysctl.c linux-2.6.22.10-vs2.2.0.5/kernel/sysctl.c
17808 --- linux-2.6.22.10/kernel/sysctl.c 2007-07-09 13:20:03 +0200
17809 +++ linux-2.6.22.10-vs2.2.0.5/kernel/sysctl.c 2007-06-15 02:37:04 +0200
17810 @@ -89,6 +89,7 @@ static int ngroups_max = NGROUPS_MAX;
17812 extern char modprobe_path[];
17814 +extern char vshelper_path[];
17815 #ifdef CONFIG_CHR_DEV_SG
17816 extern int sg_big_buff;
17818 @@ -343,6 +344,15 @@ static ctl_table kern_table[] = {
17819 .strategy = &sysctl_string,
17823 + .ctl_name = KERN_VSHELPER,
17824 + .procname = "vshelper",
17825 + .data = &vshelper_path,
17828 + .proc_handler = &proc_dostring,
17829 + .strategy = &sysctl_string,
17831 #ifdef CONFIG_CHR_DEV_SG
17833 .ctl_name = KERN_SG_BIG_BUFF,
17834 diff -NurpP --minimal linux-2.6.22.10/kernel/time.c linux-2.6.22.10-vs2.2.0.5/kernel/time.c
17835 --- linux-2.6.22.10/kernel/time.c 2007-07-09 13:20:03 +0200
17836 +++ linux-2.6.22.10-vs2.2.0.5/kernel/time.c 2007-06-15 02:37:04 +0200
17837 @@ -60,7 +60,7 @@ asmlinkage long sys_time(time_t __user *
17841 - do_gettimeofday(&tv);
17842 + vx_gettimeofday(&tv);
17846 @@ -91,7 +91,7 @@ asmlinkage long sys_stime(time_t __user
17850 - do_settimeofday(&tv);
17851 + vx_settimeofday(&tv);
17855 @@ -101,7 +101,7 @@ asmlinkage long sys_gettimeofday(struct
17857 if (likely(tv != NULL)) {
17858 struct timeval ktv;
17859 - do_gettimeofday(&ktv);
17860 + vx_gettimeofday(&ktv);
17861 if (copy_to_user(tv, &ktv, sizeof(ktv)))
17864 @@ -175,7 +175,7 @@ int do_sys_settimeofday(struct timespec
17865 /* SMP safe, again the code in arch/foo/time.c should
17866 * globally block out interrupts when it runs.
17868 - return do_settimeofday(tv);
17869 + return vx_settimeofday(tv);
17873 @@ -388,7 +388,7 @@ void getnstimeofday(struct timespec *tv)
17877 - do_gettimeofday(&x);
17878 + vx_gettimeofday(&x);
17879 tv->tv_sec = x.tv_sec;
17880 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17882 diff -NurpP --minimal linux-2.6.22.10/kernel/timer.c linux-2.6.22.10-vs2.2.0.5/kernel/timer.c
17883 --- linux-2.6.22.10/kernel/timer.c 2007-07-09 13:20:04 +0200
17884 +++ linux-2.6.22.10-vs2.2.0.5/kernel/timer.c 2007-06-15 02:37:04 +0200
17886 #include <linux/delay.h>
17887 #include <linux/tick.h>
17888 #include <linux/kallsyms.h>
17889 +#include <linux/vs_base.h>
17890 +#include <linux/vs_cvirt.h>
17891 +#include <linux/vs_pid.h>
17892 +#include <linux/vserver/sched.h>
17894 #include <asm/uaccess.h>
17895 #include <asm/unistd.h>
17896 @@ -921,12 +925,6 @@ asmlinkage unsigned long sys_alarm(unsig
17903 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
17904 - * should be moved into arch/i386 instead?
17908 * sys_getpid - return the thread group id of the current process
17909 @@ -939,7 +937,7 @@ asmlinkage unsigned long sys_alarm(unsig
17911 asmlinkage long sys_getpid(void)
17913 - return current->tgid;
17914 + return vx_map_tgid(current->tgid);
17918 @@ -955,10 +953,23 @@ asmlinkage long sys_getppid(void)
17920 pid = rcu_dereference(current->real_parent)->tgid;
17922 + return vx_map_pid(pid);
17929 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17932 +asmlinkage long do_getxpid(long *ppid)
17934 + *ppid = sys_getppid();
17935 + return sys_getpid();
17938 +#else /* _alpha_ */
17940 asmlinkage long sys_getuid(void)
17942 /* Only we change this so SMP safe */
17943 @@ -1118,6 +1129,8 @@ int do_sysinfo(struct sysinfo *info)
17944 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
17947 + if (vx_flags(VXF_VIRT_UPTIME, 0))
17948 + vx_vsi_uptime(&tp, NULL);
17949 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
17951 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
17952 diff -NurpP --minimal linux-2.6.22.10/kernel/user.c linux-2.6.22.10-vs2.2.0.5/kernel/user.c
17953 --- linux-2.6.22.10/kernel/user.c 2007-02-06 03:01:56 +0100
17954 +++ linux-2.6.22.10-vs2.2.0.5/kernel/user.c 2007-06-15 02:37:04 +0200
17956 #define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 8)
17957 #define UIDHASH_SZ (1 << UIDHASH_BITS)
17958 #define UIDHASH_MASK (UIDHASH_SZ - 1)
17959 -#define __uidhashfn(uid) (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
17960 -#define uidhashentry(uid) (uidhash_table + __uidhashfn((uid)))
17961 +#define __uidhashfn(xid,uid) ((((uid) >> UIDHASH_BITS) + ((uid)^(xid))) & UIDHASH_MASK)
17962 +#define uidhashentry(xid,uid) (uidhash_table + __uidhashfn((xid),(uid)))
17964 static struct kmem_cache *uid_cachep;
17965 static struct list_head uidhash_table[UIDHASH_SZ];
17966 @@ -66,7 +66,7 @@ static inline void uid_hash_remove(struc
17967 list_del(&up->uidhash_list);
17970 -static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *hashent)
17971 +static inline struct user_struct *uid_hash_find(xid_t xid, uid_t uid, struct list_head *hashent)
17973 struct list_head *up;
17975 @@ -75,7 +75,7 @@ static inline struct user_struct *uid_ha
17977 user = list_entry(up, struct user_struct, uidhash_list);
17979 - if(user->uid == uid) {
17980 + if(user->uid == uid && user->xid == xid) {
17981 atomic_inc(&user->__count);
17984 @@ -90,13 +90,13 @@ static inline struct user_struct *uid_ha
17986 * If the user_struct could not be found, return NULL.
17988 -struct user_struct *find_user(uid_t uid)
17989 +struct user_struct *find_user(xid_t xid, uid_t uid)
17991 struct user_struct *ret;
17992 unsigned long flags;
17994 spin_lock_irqsave(&uidhash_lock, flags);
17995 - ret = uid_hash_find(uid, uidhashentry(uid));
17996 + ret = uid_hash_find(xid, uid, uidhashentry(xid, uid));
17997 spin_unlock_irqrestore(&uidhash_lock, flags);
18000 @@ -120,13 +120,13 @@ void free_uid(struct user_struct *up)
18004 -struct user_struct * alloc_uid(uid_t uid)
18005 +struct user_struct * alloc_uid(xid_t xid, uid_t uid)
18007 - struct list_head *hashent = uidhashentry(uid);
18008 + struct list_head *hashent = uidhashentry(xid, uid);
18009 struct user_struct *up;
18011 spin_lock_irq(&uidhash_lock);
18012 - up = uid_hash_find(uid, hashent);
18013 + up = uid_hash_find(xid, uid, hashent);
18014 spin_unlock_irq(&uidhash_lock);
18017 @@ -136,6 +136,7 @@ struct user_struct * alloc_uid(uid_t uid
18022 atomic_set(&new->__count, 1);
18023 atomic_set(&new->processes, 0);
18024 atomic_set(&new->files, 0);
18025 @@ -158,7 +159,7 @@ struct user_struct * alloc_uid(uid_t uid
18026 * on adding the same user already..
18028 spin_lock_irq(&uidhash_lock);
18029 - up = uid_hash_find(uid, hashent);
18030 + up = uid_hash_find(xid, uid, hashent);
18032 key_put(new->uid_keyring);
18033 key_put(new->session_keyring);
18034 @@ -215,7 +216,7 @@ static int __init uid_cache_init(void)
18036 /* Insert the root user immediately (init already runs as root) */
18037 spin_lock_irq(&uidhash_lock);
18038 - uid_hash_insert(&root_user, uidhashentry(0));
18039 + uid_hash_insert(&root_user, uidhashentry(0,0));
18040 spin_unlock_irq(&uidhash_lock);
18043 diff -NurpP --minimal linux-2.6.22.10/kernel/utsname.c linux-2.6.22.10-vs2.2.0.5/kernel/utsname.c
18044 --- linux-2.6.22.10/kernel/utsname.c 2007-07-09 13:20:04 +0200
18045 +++ linux-2.6.22.10-vs2.2.0.5/kernel/utsname.c 2007-06-15 02:37:04 +0200
18047 #include <linux/uts.h>
18048 #include <linux/utsname.h>
18049 #include <linux/version.h>
18050 +#include <linux/vserver/global.h>
18053 * Clone a new ns copying an original utsname, setting refcount to 1
18054 @@ -27,6 +28,7 @@ static struct uts_namespace *clone_uts_n
18056 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
18057 kref_init(&ns->kref);
18058 + atomic_inc(&vs_global_uts_ns);
18062 @@ -58,5 +60,6 @@ void free_uts_ns(struct kref *kref)
18063 struct uts_namespace *ns;
18065 ns = container_of(kref, struct uts_namespace, kref);
18066 + atomic_dec(&vs_global_uts_ns);
18069 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/Kconfig linux-2.6.22.10-vs2.2.0.5/kernel/vserver/Kconfig
18070 --- linux-2.6.22.10/kernel/vserver/Kconfig 1970-01-01 01:00:00 +0100
18071 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/Kconfig 2007-06-15 02:37:04 +0200
18074 +# Linux VServer configuration
18077 +menu "Linux VServer"
18079 +config VSERVER_LEGACY
18080 + bool "Enable Legacy Kernel API"
18081 + depends on EXPERIMENTAL
18084 + This enables the legacy API used in vs1.xx, maintaining
18085 + compatibility with older vserver tools, and guest images
18086 + that are configured using the legacy method.
18088 +config VSERVER_LEGACY_VERSION
18089 + bool "Show a Legacy Version ID"
18090 + depends on VSERVER_LEGACY
18093 + This shows a special legacy version to very old tools
18094 + which do not handle the current version correctly.
18096 + Warning: recent tools are not able to utilize the
18097 + newer APIs when this is enabled, so some features will
18098 + not be available. Better avoid it, unless you really,
18099 + really need it for backwards compatibility.
18101 +config VSERVER_DYNAMIC_IDS
18102 + bool "Enable dynamic context IDs"
18103 + depends on EXPERIMENTAL && VSERVER_LEGACY
18106 + This enables support of in kernel dynamic context IDs,
18107 + which is deprecated and will probably be removed in the
18110 +config VSERVER_LEGACYNET
18111 + bool "Enable Legacy Networking Kernel API"
18112 + depends on EXPERIMENTAL
18115 + This enables the legacy networking API which is used
18116 + by older tools (pre 0.30.210) to set up the network
18117 + context (chbind).
18119 +config VSERVER_REMAP_SADDR
18120 + bool "Remap Source IP Address"
18121 + depends on EXPERIMENTAL
18124 + This allows to remap the source IP address of 'local'
18125 + connections from 127.0.0.1 to the first assigned
18128 +config VSERVER_COWBL
18129 + bool "Enable COW Immutable Link Breaking"
18132 + This enables the COW (Copy-On-Write) link break code.
18133 + It allows you to treat unified files like normal files
18134 + when writing to them (which will implicitely break the
18135 + link and create a copy of the unified file)
18137 +config VSERVER_VTIME
18138 + bool "Enable Virtualized Guest Time"
18139 + depends on EXPERIMENTAL
18142 + This enables per guest time offsets to allow for
18143 + adjusting the system clock individually per guest.
18144 + this adds some overhead to the time functions and
18145 + therefore should not be enabled without good reason.
18147 +config VSERVER_PROC_SECURE
18148 + bool "Enable Proc Security"
18149 + depends on PROC_FS
18152 + This configures ProcFS security to initially hide
18153 + non-process entries for all contexts except the main and
18154 + spectator context (i.e. for all guests), which is a secure
18157 + (note: on 1.2x the entries were visible by default)
18159 +config VSERVER_HARDCPU
18160 + bool "Enable Hard CPU Limits"
18163 + Activate the Hard CPU Limits
18165 + This will compile in code that allows the Token Bucket
18166 + Scheduler to put processes on hold when a context's
18167 + tokens are depleted (provided that its per-context
18168 + sched_hard flag is set).
18170 + Processes belonging to that context will not be able
18171 + to consume CPU resources again until a per-context
18172 + configured minimum of tokens has been reached.
18174 +config VSERVER_IDLETIME
18175 + bool "Avoid idle CPUs by skipping Time"
18176 + depends on VSERVER_HARDCPU
18179 + This option allows the scheduler to artificially
18180 + advance time (per cpu) when otherwise the idle
18181 + task would be scheduled, thus keeping the cpu
18182 + busy and sharing the available resources among
18183 + certain contexts.
18185 +config VSERVER_IDLELIMIT
18186 + bool "Limit the IDLE task"
18187 + depends on VSERVER_HARDCPU
18190 + Limit the idle slices, so the the next context
18191 + will be scheduled as soon as possible.
18193 + This might improve interactivity and latency, but
18194 + will also marginally increase scheduling overhead.
18197 + prompt "Persistent Inode Tagging"
18198 + default TAGGING_ID24
18200 + This adds persistent context information to filesystems
18201 + mounted with the tagxid option. Tagging is a requirement
18202 + for per-context disk limits and per-context quota.
18205 +config TAGGING_NONE
18208 + do not store per-context information in inodes.
18210 +config TAGGING_UID16
18211 + bool "UID16/GID32"
18213 + reduces UID to 16 bit, but leaves GID at 32 bit.
18215 +config TAGGING_GID16
18216 + bool "UID32/GID16"
18218 + reduces GID to 16 bit, but leaves UID at 32 bit.
18220 +config TAGGING_ID24
18221 + bool "UID24/GID24"
18223 + uses the upper 8bit from UID and GID for XID tagging
18224 + which leaves 24bit for UID/GID each, which should be
18225 + more than sufficient for normal use.
18227 +config TAGGING_INTERN
18228 + bool "UID32/GID32"
18230 + this uses otherwise reserved inode fields in the on
18231 + disk representation, which limits the use to a few
18232 + filesystems (currently ext2 and ext3)
18237 + bool "Tag NFSD User Auth and Files"
18240 + Enable this if you do want the in-kernel NFS
18241 + Server to use the tagging specified above.
18242 + (will require patched clients too)
18245 + bool "Enable Inode Tag Propagation"
18247 + depends on EXPERIMENTAL
18249 + This allows for the tagid= mount option to specify
18250 + a tagid which is to be used for the entire mount
18253 +config VSERVER_PRIVACY
18254 + bool "Honor Privacy Aspects of Guests"
18257 + When enabled, most context checks will disallow
18258 + access to structures assigned to a specific context,
18259 + like ptys or loop devices.
18261 +config VSERVER_CONTEXTS
18262 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
18264 + default "768" if 64BIT
18267 + This setting will optimize certain data structures
18268 + and memory allocations according to the expected
18271 + note: this is not a strict upper limit.
18273 +config VSERVER_WARN
18274 + bool "VServer Warnings"
18277 + This enables various runtime warnings, which will
18278 + notify about potential manipulation attempts or
18279 + resource shortage. It is generally considered to
18280 + be a good idea to have that enabled.
18282 +config VSERVER_DEBUG
18283 + bool "VServer Debugging Code"
18286 + Set this to yes if you want to be able to activate
18287 + debugging output at runtime. It adds a very small
18288 + overhead to all vserver related functions and
18289 + increases the kernel size by about 20k.
18291 +config VSERVER_HISTORY
18292 + bool "VServer History Tracing"
18293 + depends on VSERVER_DEBUG
18296 + Set this to yes if you want to record the history of
18297 + linux-vserver activities, so they can be replayed in
18298 + the event of a kernel panic or oops.
18300 +config VSERVER_HISTORY_SIZE
18301 + int "Per-CPU History Size (32-65536)"
18302 + depends on VSERVER_HISTORY
18306 + This allows you to specify the number of entries in
18307 + the per-CPU history buffer.
18309 +config VSERVER_MONITOR
18310 + bool "VServer Scheduling Monitor"
18311 + depends on VSERVER_DEBUG
18314 + Set this to yes if you want to record the scheduling
18315 + decisions, so that they can be relayed to userspace
18316 + for detailed analysis.
18318 +config VSERVER_MONITOR_SIZE
18319 + int "Per-CPU Monitor Queue Size (32-65536)"
18320 + depends on VSERVER_MONITOR
18324 + This allows you to specify the number of entries in
18325 + the per-CPU scheduling monitor buffer.
18327 +config VSERVER_MONITOR_SYNC
18328 + int "Per-CPU Monitor Sync Interval (0-65536)"
18329 + depends on VSERVER_MONITOR
18333 + This allows you to specify the interval in ticks
18334 + when a time sync entry is inserted.
18346 +config VSERVER_SECURITY
18348 + depends on SECURITY
18350 + select SECURITY_CAPABILITIES
18352 +config VSERVER_NGNET
18354 + depends on EXPERIMENTAL && !VSERVER_LEGACYNET
18357 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/Makefile linux-2.6.22.10-vs2.2.0.5/kernel/vserver/Makefile
18358 --- linux-2.6.22.10/kernel/vserver/Makefile 1970-01-01 01:00:00 +0100
18359 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/Makefile 2007-06-15 02:37:04 +0200
18362 +# Makefile for the Linux vserver routines.
18366 +obj-y += vserver.o
18368 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
18369 + limit.o cvirt.o cacct.o signal.o helper.o init.o dlimit.o
18371 +vserver-$(CONFIG_PROC_FS) += proc.o
18372 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
18373 +vserver-$(CONFIG_VSERVER_LEGACY) += legacy.o
18374 +vserver-$(CONFIG_VSERVER_LEGACYNET) += legacynet.o
18375 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
18376 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
18378 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cacct.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/cacct.c
18379 --- linux-2.6.22.10/kernel/vserver/cacct.c 1970-01-01 01:00:00 +0100
18380 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/cacct.c 2007-06-15 02:37:04 +0200
18383 + * linux/kernel/vserver/cacct.c
18385 + * Virtual Server: Context Accounting
18387 + * Copyright (C) 2006-2007 Herbert Pötzl
18389 + * V0.01 added accounting stats
18393 +#include <linux/types.h>
18394 +#include <linux/sched.h>
18395 +#include <linux/vs_context.h>
18396 +#include <linux/vserver/switch.h>
18397 +#include <linux/vserver/cacct_cmd.h>
18398 +#include <linux/vserver/cacct_int.h>
18400 +#include <asm/errno.h>
18401 +#include <asm/uaccess.h>
18404 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
18406 + struct vcmd_sock_stat_v0 vc_data;
18409 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18412 + field = vc_data.field;
18413 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
18416 + for (j = 0; j < 3; j++) {
18417 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
18418 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
18421 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18426 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cacct_init.h linux-2.6.22.10-vs2.2.0.5/kernel/vserver/cacct_init.h
18427 --- linux-2.6.22.10/kernel/vserver/cacct_init.h 1970-01-01 01:00:00 +0100
18428 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/cacct_init.h 2007-06-15 02:37:04 +0200
18432 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
18437 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
18438 + for (j = 0; j < 3; j++) {
18439 + atomic_set(&cacct->sock[i][j].count, 0);
18440 + atomic_set(&cacct->sock[i][j].total, 0);
18443 + for (i = 0; i < 8; i++)
18444 + atomic_set(&cacct->slab[i], 0);
18445 + for (i = 0; i < 5; i++)
18446 + for (j = 0; j < 4; j++)
18447 + atomic_set(&cacct->page[i][j], 0);
18450 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
18455 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cacct_proc.h linux-2.6.22.10-vs2.2.0.5/kernel/vserver/cacct_proc.h
18456 --- linux-2.6.22.10/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00 +0100
18457 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/cacct_proc.h 2007-06-15 02:37:04 +0200
18459 +#ifndef _VX_CACCT_PROC_H
18460 +#define _VX_CACCT_PROC_H
18462 +#include <linux/vserver/cacct_int.h>
18465 +#define VX_SOCKA_TOP \
18466 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
18468 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
18470 + int i, j, length = 0;
18471 + static char *type[VXA_SOCK_SIZE] = {
18472 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
18475 + length += sprintf(buffer + length, VX_SOCKA_TOP);
18476 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
18477 + length += sprintf(buffer + length, "%s:", type[i]);
18478 + for (j = 0; j < 3; j++) {
18479 + length += sprintf(buffer + length,
18480 + "\t%10lu/%-10lu",
18481 + vx_sock_count(cacct, i, j),
18482 + vx_sock_total(cacct, i, j));
18484 + buffer[length++] = '\n';
18487 + length += sprintf(buffer + length, "\n");
18488 + length += sprintf(buffer + length,
18489 + "slab:\t %8u %8u %8u %8u\n",
18490 + atomic_read(&cacct->slab[1]),
18491 + atomic_read(&cacct->slab[4]),
18492 + atomic_read(&cacct->slab[0]),
18493 + atomic_read(&cacct->slab[2]));
18495 + length += sprintf(buffer + length, "\n");
18496 + for (i = 0; i < 5; i++) {
18497 + length += sprintf(buffer + length,
18498 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
18499 + atomic_read(&cacct->page[i][0]),
18500 + atomic_read(&cacct->page[i][1]),
18501 + atomic_read(&cacct->page[i][2]),
18502 + atomic_read(&cacct->page[i][3]),
18503 + atomic_read(&cacct->page[i][4]),
18504 + atomic_read(&cacct->page[i][5]),
18505 + atomic_read(&cacct->page[i][6]),
18506 + atomic_read(&cacct->page[i][7]));
18511 +#endif /* _VX_CACCT_PROC_H */
18512 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/context.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/context.c
18513 --- linux-2.6.22.10/kernel/vserver/context.c 1970-01-01 01:00:00 +0100
18514 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/context.c 2007-10-01 15:47:53 +0200
18517 + * linux/kernel/vserver/context.c
18519 + * Virtual Server: Context Support
18521 + * Copyright (C) 2003-2007 Herbert Pötzl
18523 + * V0.01 context helper
18524 + * V0.02 vx_ctx_kill syscall command
18525 + * V0.03 replaced context_info calls
18526 + * V0.04 redesign of struct (de)alloc
18527 + * V0.05 rlimit basic implementation
18528 + * V0.06 task_xid and info commands
18529 + * V0.07 context flags and caps
18530 + * V0.08 switch to RCU based hash
18531 + * V0.09 revert to non RCU for now
18532 + * V0.10 and back to working RCU hash
18533 + * V0.11 and back to locking again
18534 + * V0.12 referenced context store
18535 + * V0.13 separate per cpu data
18536 + * V0.14 changed vcmds to vxi arg
18537 + * V0.15 added context stat
18538 + * V0.16 have __create claim() the vxi
18542 +#include <linux/slab.h>
18543 +#include <linux/types.h>
18544 +#include <linux/mnt_namespace.h>
18545 +#include <linux/pid_namespace.h>
18547 +#include <linux/sched.h>
18548 +#include <linux/vserver/context.h>
18549 +#include <linux/vserver/network.h>
18550 +#include <linux/vserver/legacy.h>
18551 +#include <linux/vserver/debug.h>
18552 +#include <linux/vserver/limit.h>
18553 +#include <linux/vserver/limit_int.h>
18554 +#include <linux/vserver/space.h>
18556 +#include <linux/vs_context.h>
18557 +#include <linux/vs_limit.h>
18558 +#include <linux/vserver/context_cmd.h>
18560 +#include <linux/err.h>
18561 +#include <asm/errno.h>
18563 +#include "cvirt_init.h"
18564 +#include "cacct_init.h"
18565 +#include "limit_init.h"
18566 +#include "sched_init.h"
18569 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
18570 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
18573 +/* now inactive context structures */
18575 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
18577 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
18580 +/* __alloc_vx_info()
18582 + * allocate an initialized vx_info struct
18583 + * doesn't make it visible (hash) */
18585 +static struct vx_info *__alloc_vx_info(xid_t xid)
18587 + struct vx_info *new = NULL;
18590 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
18592 + /* would this benefit from a slab cache? */
18593 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
18597 + memset(new, 0, sizeof(struct vx_info));
18599 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
18600 + if (!new->ptr_pc)
18603 + new->vx_id = xid;
18604 + INIT_HLIST_NODE(&new->vx_hlist);
18605 + atomic_set(&new->vx_usecnt, 0);
18606 + atomic_set(&new->vx_tasks, 0);
18607 + new->vx_parent = NULL;
18608 + new->vx_state = 0;
18609 + init_waitqueue_head(&new->vx_wait);
18611 + /* prepare reaper */
18612 + get_task_struct(init_pid_ns.child_reaper);
18613 + new->vx_reaper = init_pid_ns.child_reaper;
18615 + /* rest of init goes here */
18616 + vx_info_init_limit(&new->limit);
18617 + vx_info_init_sched(&new->sched);
18618 + vx_info_init_cvirt(&new->cvirt);
18619 + vx_info_init_cacct(&new->cacct);
18621 + /* per cpu data structures */
18622 + for_each_possible_cpu(cpu) {
18623 + vx_info_init_sched_pc(
18624 + &vx_per_cpu(new, sched_pc, cpu), cpu);
18625 + vx_info_init_cvirt_pc(
18626 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
18629 + new->vx_flags = VXF_INIT_SET;
18630 + new->vx_bcaps = CAP_INIT_EFF_SET;
18631 + new->vx_ccaps = 0;
18632 + new->vx_cap_bset = cap_bset;
18634 + new->reboot_cmd = 0;
18635 + new->exit_code = 0;
18637 + vxdprintk(VXD_CBIT(xid, 0),
18638 + "alloc_vx_info(%d) = %p", xid, new);
18639 + vxh_alloc_vx_info(new);
18640 + atomic_inc(&vx_global_ctotal);
18649 +/* __dealloc_vx_info()
18651 + * final disposal of vx_info */
18653 +static void __dealloc_vx_info(struct vx_info *vxi)
18657 + vxdprintk(VXD_CBIT(xid, 0),
18658 + "dealloc_vx_info(%p)", vxi);
18659 + vxh_dealloc_vx_info(vxi);
18663 + vx_info_exit_limit(&vxi->limit);
18664 + vx_info_exit_sched(&vxi->sched);
18665 + vx_info_exit_cvirt(&vxi->cvirt);
18666 + vx_info_exit_cacct(&vxi->cacct);
18668 + for_each_possible_cpu(cpu) {
18669 + vx_info_exit_sched_pc(
18670 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
18671 + vx_info_exit_cvirt_pc(
18672 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
18675 + vxi->vx_state |= VXS_RELEASED;
18678 + free_percpu(vxi->ptr_pc);
18681 + atomic_dec(&vx_global_ctotal);
18684 +static void __shutdown_vx_info(struct vx_info *vxi)
18686 + struct nsproxy *nsproxy;
18687 + struct fs_struct *fs;
18691 + vxi->vx_state |= VXS_SHUTDOWN;
18692 + vs_state_change(vxi, VSC_SHUTDOWN);
18694 + nsproxy = xchg(&vxi->vx_nsproxy, NULL);
18695 + fs = xchg(&vxi->vx_fs, NULL);
18698 + put_nsproxy(nsproxy);
18700 + put_fs_struct(fs);
18703 +/* exported stuff */
18705 +void free_vx_info(struct vx_info *vxi)
18707 + unsigned long flags;
18709 + /* check for reference counts first */
18710 + BUG_ON(atomic_read(&vxi->vx_usecnt));
18711 + BUG_ON(atomic_read(&vxi->vx_tasks));
18713 + /* context must not be hashed */
18714 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
18716 + /* context shutdown is mandatory */
18717 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
18719 + BUG_ON(vxi->vx_nsproxy);
18720 + BUG_ON(vxi->vx_fs);
18722 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
18723 + hlist_del(&vxi->vx_hlist);
18724 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18726 + __dealloc_vx_info(vxi);
18730 +/* hash table for vx_info hash */
18732 +#define VX_HASH_SIZE 13
18734 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
18735 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
18737 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
18740 +static inline unsigned int __hashval(xid_t xid)
18742 + return (xid % VX_HASH_SIZE);
18747 +/* __hash_vx_info()
18749 + * add the vxi to the global hash table
18750 + * requires the hash_lock to be held */
18752 +static inline void __hash_vx_info(struct vx_info *vxi)
18754 + struct hlist_head *head;
18756 + vxd_assert_lock(&vx_info_hash_lock);
18757 + vxdprintk(VXD_CBIT(xid, 4),
18758 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
18759 + vxh_hash_vx_info(vxi);
18761 + /* context must not be hashed */
18762 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
18764 + vxi->vx_state |= VXS_HASHED;
18765 + head = &vx_info_hash[__hashval(vxi->vx_id)];
18766 + hlist_add_head(&vxi->vx_hlist, head);
18767 + atomic_inc(&vx_global_cactive);
18770 +/* __unhash_vx_info()
18772 + * remove the vxi from the global hash table
18773 + * requires the hash_lock to be held */
18775 +static inline void __unhash_vx_info(struct vx_info *vxi)
18777 + unsigned long flags;
18779 + vxd_assert_lock(&vx_info_hash_lock);
18780 + vxdprintk(VXD_CBIT(xid, 4),
18781 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
18782 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
18783 + vxh_unhash_vx_info(vxi);
18785 + /* context must be hashed */
18786 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
18787 + /* but without tasks */
18788 + BUG_ON(atomic_read(&vxi->vx_tasks));
18790 + vxi->vx_state &= ~VXS_HASHED;
18791 + hlist_del_init(&vxi->vx_hlist);
18792 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
18793 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
18794 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18795 + atomic_dec(&vx_global_cactive);
18799 +/* __lookup_vx_info()
18801 + * requires the hash_lock to be held
18802 + * doesn't increment the vx_refcnt */
18804 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
18806 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
18807 + struct hlist_node *pos;
18808 + struct vx_info *vxi;
18810 + vxd_assert_lock(&vx_info_hash_lock);
18811 + hlist_for_each(pos, head) {
18812 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18814 + if (vxi->vx_id == xid)
18819 + vxdprintk(VXD_CBIT(xid, 0),
18820 + "__lookup_vx_info(#%u): %p[#%u]",
18821 + xid, vxi, vxi ? vxi->vx_id : 0);
18822 + vxh_lookup_vx_info(vxi, xid);
18827 +/* __vx_dynamic_id()
18829 + * find unused dynamic xid
18830 + * requires the hash_lock to be held */
18832 +static inline xid_t __vx_dynamic_id(void)
18834 + static xid_t seq = MAX_S_CONTEXT;
18835 + xid_t barrier = seq;
18837 + vxd_assert_lock(&vx_info_hash_lock);
18839 + if (++seq > MAX_S_CONTEXT)
18840 + seq = MIN_D_CONTEXT;
18841 + if (!__lookup_vx_info(seq)) {
18842 + vxdprintk(VXD_CBIT(xid, 4),
18843 + "__vx_dynamic_id: [#%d]", seq);
18846 + } while (barrier != seq);
18850 +#ifdef CONFIG_VSERVER_LEGACY
18852 +/* __loc_vx_info()
18854 + * locate or create the requested context
18855 + * get() it and if new hash it */
18857 +static struct vx_info *__loc_vx_info(int id, int *err)
18859 + struct vx_info *new, *vxi = NULL;
18861 + vxdprintk(VXD_CBIT(xid, 1), "loc_vx_info(%d)*", id);
18863 + if (!(new = __alloc_vx_info(id))) {
18868 + /* required to make dynamic xids unique */
18869 + spin_lock(&vx_info_hash_lock);
18871 + /* dynamic context requested */
18872 + if (id == VX_DYNAMIC_ID) {
18873 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
18874 + id = __vx_dynamic_id();
18876 + printk(KERN_ERR "no dynamic context available.\n");
18881 + printk(KERN_ERR "dynamic contexts disabled.\n");
18885 + /* existing context requested */
18886 + else if ((vxi = __lookup_vx_info(id))) {
18887 + /* context in setup is not available */
18888 + if (vxi->vx_flags & VXF_STATE_SETUP) {
18889 + vxdprintk(VXD_CBIT(xid, 0),
18890 + "loc_vx_info(%d) = %p (not available)", id, vxi);
18894 + vxdprintk(VXD_CBIT(xid, 0),
18895 + "loc_vx_info(%d) = %p (found)", id, vxi);
18896 + get_vx_info(vxi);
18902 + /* new context requested */
18903 + vxdprintk(VXD_CBIT(xid, 0),
18904 + "loc_vx_info(%d) = %p (new)", id, new);
18905 + __hash_vx_info(get_vx_info(new));
18906 + vxi = new, new = NULL;
18910 + spin_unlock(&vx_info_hash_lock);
18911 + vxh_loc_vx_info(vxi, id);
18913 + __dealloc_vx_info(new);
18919 +/* __create_vx_info()
18921 + * create the requested context
18922 + * get(), claim() and hash it */
18924 +static struct vx_info *__create_vx_info(int id)
18926 + struct vx_info *new, *vxi = NULL;
18928 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
18930 + if (!(new = __alloc_vx_info(id)))
18931 + return ERR_PTR(-ENOMEM);
18933 + /* required to make dynamic xids unique */
18934 + spin_lock(&vx_info_hash_lock);
18936 + /* dynamic context requested */
18937 + if (id == VX_DYNAMIC_ID) {
18938 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
18939 + id = __vx_dynamic_id();
18941 + printk(KERN_ERR "no dynamic context available.\n");
18942 + vxi = ERR_PTR(-EAGAIN);
18947 + printk(KERN_ERR "dynamic contexts disabled.\n");
18948 + vxi = ERR_PTR(-EINVAL);
18952 + /* static context requested */
18953 + else if ((vxi = __lookup_vx_info(id))) {
18954 + vxdprintk(VXD_CBIT(xid, 0),
18955 + "create_vx_info(%d) = %p (already there)", id, vxi);
18956 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18957 + vxi = ERR_PTR(-EBUSY);
18959 + vxi = ERR_PTR(-EEXIST);
18962 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
18963 + /* dynamic xid creation blocker */
18964 + else if (id >= MIN_D_CONTEXT) {
18965 + vxdprintk(VXD_CBIT(xid, 0),
18966 + "create_vx_info(%d) (dynamic rejected)", id);
18967 + vxi = ERR_PTR(-EINVAL);
18972 + /* new context */
18973 + vxdprintk(VXD_CBIT(xid, 0),
18974 + "create_vx_info(%d) = %p (new)", id, new);
18975 + claim_vx_info(new, NULL);
18976 + __hash_vx_info(get_vx_info(new));
18977 + vxi = new, new = NULL;
18980 + spin_unlock(&vx_info_hash_lock);
18981 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
18983 + __dealloc_vx_info(new);
18988 +/* exported stuff */
18991 +void unhash_vx_info(struct vx_info *vxi)
18993 + __shutdown_vx_info(vxi);
18994 + spin_lock(&vx_info_hash_lock);
18995 + __unhash_vx_info(vxi);
18996 + spin_unlock(&vx_info_hash_lock);
18997 + __wakeup_vx_info(vxi);
19001 +/* lookup_vx_info()
19003 + * search for a vx_info and get() it
19004 + * negative id means current */
19006 +struct vx_info *lookup_vx_info(int id)
19008 + struct vx_info *vxi = NULL;
19011 + vxi = get_vx_info(current->vx_info);
19012 + } else if (id > 1) {
19013 + spin_lock(&vx_info_hash_lock);
19014 + vxi = get_vx_info(__lookup_vx_info(id));
19015 + spin_unlock(&vx_info_hash_lock);
19020 +/* xid_is_hashed()
19022 + * verify that xid is still hashed */
19024 +int xid_is_hashed(xid_t xid)
19028 + spin_lock(&vx_info_hash_lock);
19029 + hashed = (__lookup_vx_info(xid) != NULL);
19030 + spin_unlock(&vx_info_hash_lock);
19034 +#ifdef CONFIG_VSERVER_LEGACY
19036 +struct vx_info *lookup_or_create_vx_info(int id)
19040 + return __loc_vx_info(id, &err);
19045 +#ifdef CONFIG_PROC_FS
19049 + * get a subset of hashed xids for proc
19050 + * assumes size is at least one */
19052 +int get_xid_list(int index, unsigned int *xids, int size)
19054 + int hindex, nr_xids = 0;
19056 + /* only show current and children */
19057 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
19060 + xids[nr_xids] = vx_current_xid();
19064 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
19065 + struct hlist_head *head = &vx_info_hash[hindex];
19066 + struct hlist_node *pos;
19068 + spin_lock(&vx_info_hash_lock);
19069 + hlist_for_each(pos, head) {
19070 + struct vx_info *vxi;
19075 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
19076 + xids[nr_xids] = vxi->vx_id;
19077 + if (++nr_xids >= size) {
19078 + spin_unlock(&vx_info_hash_lock);
19082 + /* keep the lock time short */
19083 + spin_unlock(&vx_info_hash_lock);
19090 +#ifdef CONFIG_VSERVER_DEBUG
19092 +void dump_vx_info_inactive(int level)
19094 + struct hlist_node *entry, *next;
19096 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
19097 + struct vx_info *vxi =
19098 + list_entry(entry, struct vx_info, vx_hlist);
19100 + dump_vx_info(vxi, level);
19106 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
19108 + struct user_struct *new_user, *old_user;
19113 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
19116 + new_user = alloc_uid(vxi->vx_id, p->uid);
19120 + old_user = p->user;
19121 + if (new_user != old_user) {
19122 + atomic_inc(&new_user->processes);
19123 + atomic_dec(&old_user->processes);
19124 + p->user = new_user;
19126 + free_uid(old_user);
19130 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
19132 + p->cap_effective &= vxi->vx_cap_bset;
19133 + p->cap_inheritable &= vxi->vx_cap_bset;
19134 + p->cap_permitted &= vxi->vx_cap_bset;
19138 +#include <linux/file.h>
19140 +static int vx_openfd_task(struct task_struct *tsk)
19142 + struct files_struct *files = tsk->files;
19143 + struct fdtable *fdt;
19144 + const unsigned long *bptr;
19145 + int count, total;
19147 + /* no rcu_read_lock() because of spin_lock() */
19148 + spin_lock(&files->file_lock);
19149 + fdt = files_fdtable(files);
19150 + bptr = fdt->open_fds->fds_bits;
19151 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
19152 + for (total = 0; count > 0; count--) {
19154 + total += hweight_long(*bptr);
19157 + spin_unlock(&files->file_lock);
19162 +/* for *space compatibility */
19164 +asmlinkage long sys_unshare(unsigned long);
19167 + * migrate task to new context
19168 + * gets vxi, puts old_vxi on change
19169 + * optionally unshares namespaces (hack)
19172 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
19174 + struct vx_info *old_vxi;
19180 + vxdprintk(VXD_CBIT(xid, 5),
19181 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
19182 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
19184 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
19185 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
19188 + if (vx_info_state(vxi, VXS_SHUTDOWN))
19191 + old_vxi = task_get_vx_info(p);
19192 + if (old_vxi == vxi)
19195 + if (!(ret = vx_migrate_user(p, vxi))) {
19199 + openfd = vx_openfd_task(p);
19202 + atomic_dec(&old_vxi->cvirt.nr_threads);
19203 + atomic_dec(&old_vxi->cvirt.nr_running);
19204 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
19205 + /* FIXME: what about the struct files here? */
19206 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
19207 + /* account for the executable */
19208 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
19210 + atomic_inc(&vxi->cvirt.nr_threads);
19211 + atomic_inc(&vxi->cvirt.nr_running);
19212 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
19213 + /* FIXME: what about the struct files here? */
19214 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
19215 + /* account for the executable */
19216 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
19219 + release_vx_info(old_vxi, p);
19220 + clr_vx_info(&p->vx_info);
19222 + claim_vx_info(vxi, p);
19223 + set_vx_info(&p->vx_info, vxi);
19224 + p->xid = vxi->vx_id;
19226 + vxdprintk(VXD_CBIT(xid, 5),
19227 + "moved task %p into vxi:%p[#%d]",
19228 + p, vxi, vxi->vx_id);
19230 + vx_mask_cap_bset(vxi, p);
19233 + /* hack for *spaces to provide compatibility */
19235 + struct nsproxy *old_nsp, *new_nsp;
19237 + ret = unshare_nsproxy_namespaces(
19238 + CLONE_NEWUTS | CLONE_NEWIPC,
19243 + old_nsp = xchg(&p->nsproxy, new_nsp);
19244 + vx_set_space(vxi, CLONE_NEWUTS | CLONE_NEWIPC);
19245 + put_nsproxy(old_nsp);
19249 + put_vx_info(old_vxi);
19253 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
19255 + struct task_struct *old_reaper;
19260 + vxdprintk(VXD_CBIT(xid, 6),
19261 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
19262 + vxi, vxi->vx_id, p, p->xid, p->pid);
19264 + old_reaper = vxi->vx_reaper;
19265 + if (old_reaper == p)
19268 + /* set new child reaper */
19269 + get_task_struct(p);
19270 + vxi->vx_reaper = p;
19271 + put_task_struct(old_reaper);
19275 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
19280 + vxdprintk(VXD_CBIT(xid, 6),
19281 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
19282 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
19284 + vxi->vx_flags &= ~VXF_STATE_INIT;
19285 + vxi->vx_initpid = p->tgid;
19289 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
19291 + vxdprintk(VXD_CBIT(xid, 6),
19292 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
19293 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
19295 + vxi->exit_code = code;
19296 + vxi->vx_initpid = 0;
19300 +void vx_set_persistent(struct vx_info *vxi)
19302 + vxdprintk(VXD_CBIT(xid, 6),
19303 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
19305 + get_vx_info(vxi);
19306 + claim_vx_info(vxi, NULL);
19309 +void vx_clear_persistent(struct vx_info *vxi)
19311 + vxdprintk(VXD_CBIT(xid, 6),
19312 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
19314 + release_vx_info(vxi, NULL);
19315 + put_vx_info(vxi);
19318 +void vx_update_persistent(struct vx_info *vxi)
19320 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
19321 + vx_set_persistent(vxi);
19323 + vx_clear_persistent(vxi);
19327 +/* task must be current or locked */
19329 +void exit_vx_info(struct task_struct *p, int code)
19331 + struct vx_info *vxi = p->vx_info;
19334 + atomic_dec(&vxi->cvirt.nr_threads);
19337 + vxi->exit_code = code;
19338 + release_vx_info(vxi, p);
19342 +void exit_vx_info_early(struct task_struct *p, int code)
19344 + struct vx_info *vxi = p->vx_info;
19347 + if (vxi->vx_initpid == p->tgid)
19348 + vx_exit_init(vxi, p, code);
19349 + if (vxi->vx_reaper == p)
19350 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
19355 +/* vserver syscall commands below here */
19357 +/* taks xid and vx_info functions */
19359 +#include <asm/uaccess.h>
19362 +int vc_task_xid(uint32_t id, void __user *data)
19367 + struct task_struct *tsk;
19369 + if (!vx_check(0, VS_ADMIN | VS_WATCH))
19372 + read_lock(&tasklist_lock);
19373 + tsk = find_task_by_real_pid(id);
19374 + xid = (tsk) ? tsk->xid : -ESRCH;
19375 + read_unlock(&tasklist_lock);
19377 + xid = vx_current_xid();
19382 +int vc_vx_info(struct vx_info *vxi, void __user *data)
19384 + struct vcmd_vx_info_v0 vc_data;
19386 + vc_data.xid = vxi->vx_id;
19387 + vc_data.initpid = vxi->vx_initpid;
19389 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19395 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
19397 + struct vcmd_ctx_stat_v0 vc_data;
19399 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
19400 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
19402 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19408 +/* context functions */
19410 +int vc_ctx_create(uint32_t xid, void __user *data)
19412 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
19413 + struct vx_info *new_vxi;
19416 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
19419 + if ((xid > MAX_S_CONTEXT) && (xid != VX_DYNAMIC_ID))
19424 + new_vxi = __create_vx_info(xid);
19425 + if (IS_ERR(new_vxi))
19426 + return PTR_ERR(new_vxi);
19428 + /* initial flags */
19429 + new_vxi->vx_flags = vc_data.flagword;
19432 + if (vs_state_change(new_vxi, VSC_STARTUP))
19435 + ret = vx_migrate_task(current, new_vxi, (!data));
19439 + /* return context id on success */
19440 + ret = new_vxi->vx_id;
19442 + /* get a reference for persistent contexts */
19443 + if ((vc_data.flagword & VXF_PERSISTENT))
19444 + vx_set_persistent(new_vxi);
19446 + release_vx_info(new_vxi, NULL);
19447 + put_vx_info(new_vxi);
19452 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
19454 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
19457 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
19460 + ret = vx_migrate_task(current, vxi, 0);
19463 + if (vc_data.flagword & VXM_SET_INIT)
19464 + ret = vx_set_init(vxi, current);
19467 + if (vc_data.flagword & VXM_SET_REAPER)
19468 + ret = vx_set_reaper(vxi, current);
19473 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
19475 + struct vcmd_ctx_flags_v0 vc_data;
19477 + vc_data.flagword = vxi->vx_flags;
19479 + /* special STATE flag handling */
19480 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
19482 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19487 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
19489 + struct vcmd_ctx_flags_v0 vc_data;
19490 + uint64_t mask, trigger;
19492 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19495 + /* special STATE flag handling */
19496 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
19497 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
19499 + if (vxi == current->vx_info) {
19500 + if (trigger & VXF_STATE_SETUP)
19501 + vx_mask_cap_bset(vxi, current);
19502 + if (trigger & VXF_STATE_INIT) {
19505 + ret = vx_set_init(vxi, current);
19508 + ret = vx_set_reaper(vxi, current);
19514 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
19515 + vc_data.flagword, mask);
19516 + if (trigger & VXF_PERSISTENT)
19517 + vx_update_persistent(vxi);
19522 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
19525 + *bcaps = vxi->vx_bcaps;
19527 + *ccaps = vxi->vx_ccaps;
19532 +int vc_get_ccaps_v0(struct vx_info *vxi, void __user *data)
19534 + struct vcmd_ctx_caps_v0 vc_data;
19537 + ret = do_get_caps(vxi, &vc_data.bcaps, &vc_data.ccaps);
19540 + vc_data.cmask = ~0ULL;
19542 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19547 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
19549 + struct vcmd_ctx_caps_v1 vc_data;
19552 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
19555 + vc_data.cmask = ~0ULL;
19557 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19562 +static int do_set_caps(struct vx_info *vxi,
19563 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
19565 + vxi->vx_bcaps = vs_mask_flags(vxi->vx_bcaps, bcaps, bmask);
19566 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
19571 +int vc_set_ccaps_v0(struct vx_info *vxi, void __user *data)
19573 + struct vcmd_ctx_caps_v0 vc_data;
19575 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19578 + /* simulate old &= behaviour for bcaps */
19579 + return do_set_caps(vxi, 0, ~vc_data.bcaps,
19580 + vc_data.ccaps, vc_data.cmask);
19583 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
19585 + struct vcmd_ctx_caps_v1 vc_data;
19587 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19590 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
19593 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
19595 + struct vcmd_bcaps vc_data;
19598 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
19601 + vc_data.bmask = ~0ULL;
19603 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19608 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
19610 + struct vcmd_bcaps vc_data;
19612 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19615 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
19618 +#include <linux/module.h>
19620 +EXPORT_SYMBOL_GPL(free_vx_info);
19622 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cvirt.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/cvirt.c
19623 --- linux-2.6.22.10/kernel/vserver/cvirt.c 1970-01-01 01:00:00 +0100
19624 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/cvirt.c 2007-06-15 02:37:04 +0200
19627 + * linux/kernel/vserver/cvirt.c
19629 + * Virtual Server: Context Virtualization
19631 + * Copyright (C) 2004-2007 Herbert Pötzl
19633 + * V0.01 broken out from limit.c
19634 + * V0.02 added utsname stuff
19635 + * V0.03 changed vcmds to vxi arg
19639 +#include <linux/sched.h>
19640 +#include <linux/sysctl.h>
19641 +#include <linux/types.h>
19642 +#include <linux/vs_context.h>
19643 +#include <linux/vs_cvirt.h>
19644 +#include <linux/vserver/switch.h>
19645 +#include <linux/vserver/cvirt_cmd.h>
19647 +#include <asm/errno.h>
19648 +#include <asm/uaccess.h>
19651 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
19653 + struct vx_info *vxi = current->vx_info;
19655 + set_normalized_timespec(uptime,
19656 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
19657 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
19660 + set_normalized_timespec(idle,
19661 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
19662 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
19666 +uint64_t vx_idle_jiffies(void)
19668 + return init_task.utime + init_task.stime;
19673 +static inline uint32_t __update_loadavg(uint32_t load,
19674 + int wsize, int delta, int n)
19676 + unsigned long long calc, prev;
19678 + /* just set it to n */
19679 + if (unlikely(delta >= wsize))
19680 + return (n << FSHIFT);
19682 + calc = delta * n;
19684 + prev = (wsize - delta);
19687 + do_div(calc, wsize);
19692 +void vx_update_load(struct vx_info *vxi)
19694 + uint32_t now, last, delta;
19695 + unsigned int nr_running, nr_uninterruptible;
19696 + unsigned int total;
19697 + unsigned long flags;
19699 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
19702 + last = vxi->cvirt.load_last;
19703 + delta = now - last;
19705 + if (delta < 5*HZ)
19708 + nr_running = atomic_read(&vxi->cvirt.nr_running);
19709 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
19710 + total = nr_running + nr_uninterruptible;
19712 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
19713 + 60*HZ, delta, total);
19714 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
19715 + 5*60*HZ, delta, total);
19716 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
19717 + 15*60*HZ, delta, total);
19719 + vxi->cvirt.load_last = now;
19721 + atomic_inc(&vxi->cvirt.load_updates);
19722 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
19727 + * Commands to do_syslog:
19729 + * 0 -- Close the log. Currently a NOP.
19730 + * 1 -- Open the log. Currently a NOP.
19731 + * 2 -- Read from the log.
19732 + * 3 -- Read all messages remaining in the ring buffer.
19733 + * 4 -- Read and clear all messages remaining in the ring buffer
19734 + * 5 -- Clear ring buffer.
19735 + * 6 -- Disable printk's to console
19736 + * 7 -- Enable printk's to console
19737 + * 8 -- Set level of messages printed to console
19738 + * 9 -- Return number of unread characters in the log buffer
19739 + * 10 -- Return size of the log buffer
19741 +int vx_do_syslog(int type, char __user *buf, int len)
19744 + int do_clear = 0;
19745 + struct vx_info *vxi = current->vx_info;
19746 + struct _vx_syslog *log;
19750 + log = &vxi->cvirt.syslog;
19753 + case 0: /* Close log */
19754 + case 1: /* Open log */
19756 + case 2: /* Read from log */
19757 + error = wait_event_interruptible(log->log_wait,
19758 + (log->log_start - log->log_end));
19761 + spin_lock_irq(&log->logbuf_lock);
19762 + spin_unlock_irq(&log->logbuf_lock);
19764 + case 4: /* Read/clear last kernel messages */
19766 + /* fall through */
19767 + case 3: /* Read last kernel messages */
19770 + case 5: /* Clear ring buffer */
19773 + case 6: /* Disable logging to console */
19774 + case 7: /* Enable logging to console */
19775 + case 8: /* Set level of messages printed to console */
19778 + case 9: /* Number of chars in the log buffer */
19780 + case 10: /* Size of the log buffer */
19790 +/* virtual host info names */
19792 +static char *vx_vhi_name(struct vx_info *vxi, int id)
19794 + struct nsproxy *nsproxy;
19795 + struct uts_namespace *uts;
19798 + if (id == VHIN_CONTEXT)
19799 + return vxi->vx_name;
19801 + nsproxy = vxi->vx_nsproxy;
19805 + uts = nsproxy->uts_ns;
19810 + case VHIN_SYSNAME:
19811 + return uts->name.sysname;
19812 + case VHIN_NODENAME:
19813 + return uts->name.nodename;
19814 + case VHIN_RELEASE:
19815 + return uts->name.release;
19816 + case VHIN_VERSION:
19817 + return uts->name.version;
19818 + case VHIN_MACHINE:
19819 + return uts->name.machine;
19820 + case VHIN_DOMAINNAME:
19821 + return uts->name.domainname;
19828 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
19830 + struct vcmd_vhi_name_v0 vc_data;
19833 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19836 + name = vx_vhi_name(vxi, vc_data.field);
19840 + memcpy(name, vc_data.name, 65);
19844 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
19846 + struct vcmd_vhi_name_v0 vc_data;
19849 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19852 + name = vx_vhi_name(vxi, vc_data.field);
19856 + memcpy(vc_data.name, name, 65);
19857 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19863 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
19865 + struct vcmd_virt_stat_v0 vc_data;
19866 + struct _vx_cvirt *cvirt = &vxi->cvirt;
19867 + struct timespec uptime;
19869 + do_posix_clock_monotonic_gettime(&uptime);
19870 + set_normalized_timespec(&uptime,
19871 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
19872 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
19874 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
19875 + vc_data.uptime = timespec_to_ns(&uptime);
19876 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
19877 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
19878 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
19879 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
19880 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
19881 + vc_data.load[0] = cvirt->load[0];
19882 + vc_data.load[1] = cvirt->load[1];
19883 + vc_data.load[2] = cvirt->load[2];
19885 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19891 +#ifdef CONFIG_VSERVER_VTIME
19893 +/* virtualized time base */
19895 +void vx_gettimeofday(struct timeval *tv)
19897 + do_gettimeofday(tv);
19898 + if (!vx_flags(VXF_VIRT_TIME, 0))
19901 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
19902 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
19904 + if (tv->tv_usec >= USEC_PER_SEC) {
19906 + tv->tv_usec -= USEC_PER_SEC;
19907 + } else if (tv->tv_usec < 0) {
19909 + tv->tv_usec += USEC_PER_SEC;
19913 +int vx_settimeofday(struct timespec *ts)
19915 + struct timeval tv;
19917 + if (!vx_flags(VXF_VIRT_TIME, 0))
19918 + return do_settimeofday(ts);
19920 + do_gettimeofday(&tv);
19921 + current->vx_info->cvirt.bias_tv.tv_sec =
19922 + ts->tv_sec - tv.tv_sec;
19923 + current->vx_info->cvirt.bias_tv.tv_usec =
19924 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
19930 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cvirt_init.h linux-2.6.22.10-vs2.2.0.5/kernel/vserver/cvirt_init.h
19931 --- linux-2.6.22.10/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00 +0100
19932 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/cvirt_init.h 2007-10-29 23:34:24 +0100
19936 +extern uint64_t vx_idle_jiffies(void);
19938 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
19940 + uint64_t idle_jiffies = vx_idle_jiffies();
19941 + uint64_t nsuptime;
19943 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
19944 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
19945 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
19946 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
19947 + cvirt->bias_tv.tv_sec = 0;
19948 + cvirt->bias_tv.tv_usec = 0;
19950 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19951 + atomic_set(&cvirt->nr_threads, 0);
19952 + atomic_set(&cvirt->nr_running, 0);
19953 + atomic_set(&cvirt->nr_uninterruptible, 0);
19954 + atomic_set(&cvirt->nr_onhold, 0);
19956 + spin_lock_init(&cvirt->load_lock);
19957 + cvirt->load_last = jiffies;
19958 + atomic_set(&cvirt->load_updates, 0);
19959 + cvirt->load[0] = 0;
19960 + cvirt->load[1] = 0;
19961 + cvirt->load[2] = 0;
19962 + atomic_set(&cvirt->total_forks, 0);
19964 + spin_lock_init(&cvirt->syslog.logbuf_lock);
19965 + init_waitqueue_head(&cvirt->syslog.log_wait);
19966 + cvirt->syslog.log_start = 0;
19967 + cvirt->syslog.log_end = 0;
19968 + cvirt->syslog.con_start = 0;
19969 + cvirt->syslog.logged_chars = 0;
19973 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19975 + // cvirt_pc->cpustat = { 0 };
19978 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19982 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19983 + "!!! cvirt: %p[nr_threads] = %d on exit.",
19985 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19986 + "!!! cvirt: %p[nr_running] = %d on exit.",
19988 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19989 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19991 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19992 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
19998 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
20003 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cvirt_proc.h linux-2.6.22.10-vs2.2.0.5/kernel/vserver/cvirt_proc.h
20004 --- linux-2.6.22.10/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00 +0100
20005 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/cvirt_proc.h 2007-06-15 02:37:04 +0200
20007 +#ifndef _VX_CVIRT_PROC_H
20008 +#define _VX_CVIRT_PROC_H
20010 +#include <linux/nsproxy.h>
20011 +#include <linux/mnt_namespace.h>
20012 +#include <linux/utsname.h>
20013 +#include <linux/ipc.h>
20017 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
20019 + struct mnt_namespace *ns;
20020 + struct uts_namespace *uts;
20021 + struct ipc_namespace *ipc;
20022 + struct vfsmount *mnt;
20023 + char *path, *root;
20029 + length += sprintf(buffer + length,
20030 + "NSProxy:\t%p [%p,%p,%p]\n",
20031 + nsproxy, nsproxy->mnt_ns,
20032 + nsproxy->uts_ns, nsproxy->ipc_ns);
20034 + ns = nsproxy->mnt_ns;
20038 + path = kmalloc(PATH_MAX, GFP_KERNEL);
20043 + root = d_path(mnt->mnt_root, mnt->mnt_parent, path, PATH_MAX - 2);
20044 + length += sprintf(buffer + length,
20045 + "Namespace:\t%p [#%u]\n"
20046 + "RootPath:\t%s\n",
20047 + ns, atomic_read(&ns->count),
20052 + uts = nsproxy->uts_ns;
20056 + length += sprintf(buffer + length,
20057 + "SysName:\t%.*s\n"
20058 + "NodeName:\t%.*s\n"
20059 + "Release:\t%.*s\n"
20060 + "Version:\t%.*s\n"
20061 + "Machine:\t%.*s\n"
20062 + "DomainName:\t%.*s\n",
20063 + __NEW_UTS_LEN, uts->name.sysname,
20064 + __NEW_UTS_LEN, uts->name.nodename,
20065 + __NEW_UTS_LEN, uts->name.release,
20066 + __NEW_UTS_LEN, uts->name.version,
20067 + __NEW_UTS_LEN, uts->name.machine,
20068 + __NEW_UTS_LEN, uts->name.domainname);
20071 + ipc = nsproxy->ipc_ns;
20075 + length += sprintf(buffer + length,
20076 + "SEMS:\t\t%d %d %d %d %d\n"
20077 + "MSG:\t\t%d %d %d\n"
20078 + "SHM:\t\t%lu %lu %d %d\n",
20079 + ipc->sem_ctls[0], ipc->sem_ctls[1],
20080 + ipc->sem_ctls[2], ipc->sem_ctls[3],
20082 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
20083 + (unsigned long)ipc->shm_ctlmax,
20084 + (unsigned long)ipc->shm_ctlall,
20085 + ipc->shm_ctlmni, ipc->shm_tot);
20092 +#include <linux/sched.h>
20094 +#define LOAD_INT(x) ((x) >> FSHIFT)
20095 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
20098 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
20103 + length += sprintf(buffer + length,
20104 + "BiasUptime:\t%lu.%02lu\n",
20105 + (unsigned long)cvirt->bias_uptime.tv_sec,
20106 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
20108 + a = cvirt->load[0] + (FIXED_1 / 200);
20109 + b = cvirt->load[1] + (FIXED_1 / 200);
20110 + c = cvirt->load[2] + (FIXED_1 / 200);
20111 + length += sprintf(buffer + length,
20112 + "nr_threads:\t%d\n"
20113 + "nr_running:\t%d\n"
20114 + "nr_unintr:\t%d\n"
20115 + "nr_onhold:\t%d\n"
20116 + "load_updates:\t%d\n"
20117 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
20118 + "total_forks:\t%d\n",
20119 + atomic_read(&cvirt->nr_threads),
20120 + atomic_read(&cvirt->nr_running),
20121 + atomic_read(&cvirt->nr_uninterruptible),
20122 + atomic_read(&cvirt->nr_onhold),
20123 + atomic_read(&cvirt->load_updates),
20124 + LOAD_INT(a), LOAD_FRAC(a),
20125 + LOAD_INT(b), LOAD_FRAC(b),
20126 + LOAD_INT(c), LOAD_FRAC(c),
20127 + atomic_read(&cvirt->total_forks));
20132 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
20133 + char *buffer, int cpu)
20139 +#endif /* _VX_CVIRT_PROC_H */
20140 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/debug.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/debug.c
20141 --- linux-2.6.22.10/kernel/vserver/debug.c 1970-01-01 01:00:00 +0100
20142 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/debug.c 2007-06-15 02:37:04 +0200
20145 + * kernel/vserver/debug.c
20147 + * Copyright (C) 2005-2007 Herbert Pötzl
20149 + * V0.01 vx_info dump support
20153 +#include <linux/errno.h>
20154 +#include <linux/kernel.h>
20155 +#include <linux/module.h>
20156 +#include <linux/vs_base.h>
20158 +#include <linux/vserver/context.h>
20161 +void dump_vx_info(struct vx_info *vxi, int level)
20163 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
20164 + atomic_read(&vxi->vx_usecnt),
20165 + atomic_read(&vxi->vx_tasks),
20168 + __dump_vx_limit(&vxi->limit);
20169 + __dump_vx_sched(&vxi->sched);
20170 + __dump_vx_cvirt(&vxi->cvirt);
20171 + __dump_vx_cacct(&vxi->cacct);
20177 +EXPORT_SYMBOL_GPL(dump_vx_info);
20179 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/dlimit.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/dlimit.c
20180 --- linux-2.6.22.10/kernel/vserver/dlimit.c 1970-01-01 01:00:00 +0100
20181 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/dlimit.c 2007-07-17 03:02:15 +0200
20184 + * linux/kernel/vserver/dlimit.c
20186 + * Virtual Server: Context Disk Limits
20188 + * Copyright (C) 2004-2007 Herbert Pötzl
20190 + * V0.01 initial version
20191 + * V0.02 compat32 splitup
20195 +#include <linux/fs.h>
20196 +#include <linux/namei.h>
20197 +#include <linux/statfs.h>
20198 +#include <linux/compat.h>
20199 +#include <linux/vserver/switch.h>
20200 +#include <linux/vs_context.h>
20201 +#include <linux/vs_tag.h>
20202 +#include <linux/vs_dlimit.h>
20203 +#include <linux/vserver/dlimit_cmd.h>
20205 +#include <asm/errno.h>
20206 +#include <asm/uaccess.h>
20208 +/* __alloc_dl_info()
20210 + * allocate an initialized dl_info struct
20211 + * doesn't make it visible (hash) */
20213 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
20215 + struct dl_info *new = NULL;
20217 + vxdprintk(VXD_CBIT(dlim, 5),
20218 + "alloc_dl_info(%p,%d)*", sb, tag);
20220 + /* would this benefit from a slab cache? */
20221 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
20225 + memset(new, 0, sizeof(struct dl_info));
20226 + new->dl_tag = tag;
20228 + INIT_RCU_HEAD(&new->dl_rcu);
20229 + INIT_HLIST_NODE(&new->dl_hlist);
20230 + spin_lock_init(&new->dl_lock);
20231 + atomic_set(&new->dl_refcnt, 0);
20232 + atomic_set(&new->dl_usecnt, 0);
20234 + /* rest of init goes here */
20236 + vxdprintk(VXD_CBIT(dlim, 4),
20237 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
20241 +/* __dealloc_dl_info()
20243 + * final disposal of dl_info */
20245 +static void __dealloc_dl_info(struct dl_info *dli)
20247 + vxdprintk(VXD_CBIT(dlim, 4),
20248 + "dealloc_dl_info(%p)", dli);
20250 + dli->dl_hlist.next = LIST_POISON1;
20251 + dli->dl_tag = -1;
20254 + BUG_ON(atomic_read(&dli->dl_usecnt));
20255 + BUG_ON(atomic_read(&dli->dl_refcnt));
20261 +/* hash table for dl_info hash */
20263 +#define DL_HASH_SIZE 13
20265 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
20267 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
20270 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
20272 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
20277 +/* __hash_dl_info()
20279 + * add the dli to the global hash table
20280 + * requires the hash_lock to be held */
20282 +static inline void __hash_dl_info(struct dl_info *dli)
20284 + struct hlist_head *head;
20286 + vxdprintk(VXD_CBIT(dlim, 6),
20287 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
20288 + get_dl_info(dli);
20289 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
20290 + hlist_add_head_rcu(&dli->dl_hlist, head);
20293 +/* __unhash_dl_info()
20295 + * remove the dli from the global hash table
20296 + * requires the hash_lock to be held */
20298 +static inline void __unhash_dl_info(struct dl_info *dli)
20300 + vxdprintk(VXD_CBIT(dlim, 6),
20301 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
20302 + hlist_del_rcu(&dli->dl_hlist);
20303 + put_dl_info(dli);
20307 +/* __lookup_dl_info()
20309 + * requires the rcu_read_lock()
20310 + * doesn't increment the dl_refcnt */
20312 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
20314 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
20315 + struct hlist_node *pos;
20316 + struct dl_info *dli;
20318 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
20320 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
20328 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
20330 + struct dl_info *dli;
20333 + dli = get_dl_info(__lookup_dl_info(sb, tag));
20334 + vxdprintk(VXD_CBIT(dlim, 7),
20335 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
20336 + rcu_read_unlock();
20340 +void rcu_free_dl_info(struct rcu_head *head)
20342 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
20343 + int usecnt, refcnt;
20345 + BUG_ON(!dli || !head);
20347 + usecnt = atomic_read(&dli->dl_usecnt);
20348 + BUG_ON(usecnt < 0);
20350 + refcnt = atomic_read(&dli->dl_refcnt);
20351 + BUG_ON(refcnt < 0);
20353 + vxdprintk(VXD_CBIT(dlim, 3),
20354 + "rcu_free_dl_info(%p)", dli);
20356 + __dealloc_dl_info(dli);
20358 + printk("!!! rcu didn't free\n");
20364 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
20365 + uint32_t flags, int add)
20367 + struct nameidata nd;
20370 + ret = user_path_walk_link(name, &nd);
20372 + struct super_block *sb;
20373 + struct dl_info *dli;
20376 + if (!nd.dentry->d_inode)
20377 + goto out_release;
20378 + if (!(sb = nd.dentry->d_inode->i_sb))
20379 + goto out_release;
20382 + dli = __alloc_dl_info(sb, id);
20383 + spin_lock(&dl_info_hash_lock);
20386 + if (__lookup_dl_info(sb, id))
20388 + __hash_dl_info(dli);
20391 + spin_lock(&dl_info_hash_lock);
20392 + dli = __lookup_dl_info(sb, id);
20397 + __unhash_dl_info(dli);
20401 + spin_unlock(&dl_info_hash_lock);
20403 + __dealloc_dl_info(dli);
20405 + path_release(&nd);
20410 +int vc_add_dlimit(uint32_t id, void __user *data)
20412 + struct vcmd_ctx_dlimit_base_v0 vc_data;
20414 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20417 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
20420 +int vc_rem_dlimit(uint32_t id, void __user *data)
20422 + struct vcmd_ctx_dlimit_base_v0 vc_data;
20424 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20427 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
20430 +#ifdef CONFIG_COMPAT
20432 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
20434 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20436 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20439 + return do_addrem_dlimit(id,
20440 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
20443 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
20445 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20447 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20450 + return do_addrem_dlimit(id,
20451 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
20454 +#endif /* CONFIG_COMPAT */
20458 +int do_set_dlimit(uint32_t id, const char __user *name,
20459 + uint32_t space_used, uint32_t space_total,
20460 + uint32_t inodes_used, uint32_t inodes_total,
20461 + uint32_t reserved, uint32_t flags)
20463 + struct nameidata nd;
20466 + ret = user_path_walk_link(name, &nd);
20468 + struct super_block *sb;
20469 + struct dl_info *dli;
20472 + if (!nd.dentry->d_inode)
20473 + goto out_release;
20474 + if (!(sb = nd.dentry->d_inode->i_sb))
20475 + goto out_release;
20476 + if ((reserved != CDLIM_KEEP &&
20477 + reserved > 100) ||
20478 + (inodes_used != CDLIM_KEEP &&
20479 + inodes_used > inodes_total) ||
20480 + (space_used != CDLIM_KEEP &&
20481 + space_used > space_total))
20482 + goto out_release;
20485 + dli = locate_dl_info(sb, id);
20487 + goto out_release;
20489 + spin_lock(&dli->dl_lock);
20491 + if (inodes_used != CDLIM_KEEP)
20492 + dli->dl_inodes_used = inodes_used;
20493 + if (inodes_total != CDLIM_KEEP)
20494 + dli->dl_inodes_total = inodes_total;
20495 + if (space_used != CDLIM_KEEP) {
20496 + dli->dl_space_used = space_used;
20497 + dli->dl_space_used <<= 10;
20499 + if (space_total == CDLIM_INFINITY)
20500 + dli->dl_space_total = DLIM_INFINITY;
20501 + else if (space_total != CDLIM_KEEP) {
20502 + dli->dl_space_total = space_total;
20503 + dli->dl_space_total <<= 10;
20505 + if (reserved != CDLIM_KEEP)
20506 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20508 + spin_unlock(&dli->dl_lock);
20510 + put_dl_info(dli);
20514 + path_release(&nd);
20519 +int vc_set_dlimit(uint32_t id, void __user *data)
20521 + struct vcmd_ctx_dlimit_v0 vc_data;
20523 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20526 + return do_set_dlimit(id, vc_data.name,
20527 + vc_data.space_used, vc_data.space_total,
20528 + vc_data.inodes_used, vc_data.inodes_total,
20529 + vc_data.reserved, vc_data.flags);
20532 +#ifdef CONFIG_COMPAT
20534 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20536 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20538 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20541 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20542 + vc_data.space_used, vc_data.space_total,
20543 + vc_data.inodes_used, vc_data.inodes_total,
20544 + vc_data.reserved, vc_data.flags);
20547 +#endif /* CONFIG_COMPAT */
20551 +int do_get_dlimit(uint32_t id, const char __user *name,
20552 + uint32_t *space_used, uint32_t *space_total,
20553 + uint32_t *inodes_used, uint32_t *inodes_total,
20554 + uint32_t *reserved, uint32_t *flags)
20556 + struct nameidata nd;
20559 + ret = user_path_walk_link(name, &nd);
20561 + struct super_block *sb;
20562 + struct dl_info *dli;
20565 + if (!nd.dentry->d_inode)
20566 + goto out_release;
20567 + if (!(sb = nd.dentry->d_inode->i_sb))
20568 + goto out_release;
20571 + dli = locate_dl_info(sb, id);
20573 + goto out_release;
20575 + spin_lock(&dli->dl_lock);
20576 + *inodes_used = dli->dl_inodes_used;
20577 + *inodes_total = dli->dl_inodes_total;
20578 + *space_used = dli->dl_space_used >> 10;
20579 + if (dli->dl_space_total == DLIM_INFINITY)
20580 + *space_total = CDLIM_INFINITY;
20582 + *space_total = dli->dl_space_total >> 10;
20584 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20585 + spin_unlock(&dli->dl_lock);
20587 + put_dl_info(dli);
20592 + path_release(&nd);
20598 +int vc_get_dlimit(uint32_t id, void __user *data)
20600 + struct vcmd_ctx_dlimit_v0 vc_data;
20603 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20606 + ret = do_get_dlimit(id, vc_data.name,
20607 + &vc_data.space_used, &vc_data.space_total,
20608 + &vc_data.inodes_used, &vc_data.inodes_total,
20609 + &vc_data.reserved, &vc_data.flags);
20613 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20618 +#ifdef CONFIG_COMPAT
20620 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20622 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20625 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20628 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20629 + &vc_data.space_used, &vc_data.space_total,
20630 + &vc_data.inodes_used, &vc_data.inodes_total,
20631 + &vc_data.reserved, &vc_data.flags);
20635 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20640 +#endif /* CONFIG_COMPAT */
20643 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20645 + struct dl_info *dli;
20646 + __u64 blimit, bfree, bavail;
20649 + dli = locate_dl_info(sb, dx_current_tag());
20653 + spin_lock(&dli->dl_lock);
20654 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20657 + /* reduce max inodes available to limit */
20658 + if (buf->f_files > dli->dl_inodes_total)
20659 + buf->f_files = dli->dl_inodes_total;
20661 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20662 + /* reduce free inodes to min */
20663 + if (ifree < buf->f_ffree)
20664 + buf->f_ffree = ifree;
20667 + if (dli->dl_space_total == DLIM_INFINITY)
20670 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20672 + if (dli->dl_space_total < dli->dl_space_used)
20675 + bfree = (dli->dl_space_total - dli->dl_space_used)
20676 + >> sb->s_blocksize_bits;
20678 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20679 + if (bavail < dli->dl_space_used)
20682 + bavail = (bavail - dli->dl_space_used)
20683 + >> sb->s_blocksize_bits;
20685 + /* reduce max space available to limit */
20686 + if (buf->f_blocks > blimit)
20687 + buf->f_blocks = blimit;
20689 + /* reduce free space to min */
20690 + if (bfree < buf->f_bfree)
20691 + buf->f_bfree = bfree;
20693 + /* reduce avail space to min */
20694 + if (bavail < buf->f_bavail)
20695 + buf->f_bavail = bavail;
20698 + spin_unlock(&dli->dl_lock);
20699 + put_dl_info(dli);
20704 +#include <linux/module.h>
20706 +EXPORT_SYMBOL_GPL(locate_dl_info);
20707 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20709 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/helper.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/helper.c
20710 --- linux-2.6.22.10/kernel/vserver/helper.c 1970-01-01 01:00:00 +0100
20711 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/helper.c 2007-06-15 02:37:04 +0200
20714 + * linux/kernel/vserver/helper.c
20716 + * Virtual Context Support
20718 + * Copyright (C) 2004-2007 Herbert Pötzl
20720 + * V0.01 basic helper
20724 +#include <linux/errno.h>
20725 +#include <linux/kmod.h>
20726 +#include <linux/sched.h>
20727 +#include <linux/reboot.h>
20728 +#include <linux/vs_context.h>
20729 +#include <linux/vs_network.h>
20730 +#include <linux/vserver/signal.h>
20732 +#include <asm/uaccess.h>
20733 +#include <asm/unistd.h>
20736 +char vshelper_path[255] = "/sbin/vshelper";
20739 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20743 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20744 + printk( KERN_WARNING
20745 + "%s: (%s %s) returned %s with %d\n",
20746 + name, argv[1], argv[2],
20747 + sync ? "sync" : "async", ret);
20749 + vxdprintk(VXD_CBIT(switch, 4),
20750 + "%s: (%s %s) returned %s with %d",
20751 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
20756 + * vshelper path is set via /proc/sys
20757 + * invoked by vserver sys_reboot(), with
20758 + * the following arguments
20760 + * argv [0] = vshelper_path;
20761 + * argv [1] = action: "restart", "halt", "poweroff", ...
20762 + * argv [2] = context identifier
20764 + * envp [*] = type-specific parameters
20767 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20769 + char id_buf[8], cmd_buf[16];
20770 + char uid_buf[16], pid_buf[16];
20773 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20774 + char *envp[] = {"HOME=/", "TERM=linux",
20775 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20776 + uid_buf, pid_buf, cmd_buf, 0};
20778 + if (vx_info_state(vxi, VXS_HELPER))
20780 + vxi->vx_state |= VXS_HELPER;
20782 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20784 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20785 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
20786 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20789 + case LINUX_REBOOT_CMD_RESTART:
20790 + argv[1] = "restart";
20793 + case LINUX_REBOOT_CMD_HALT:
20794 + argv[1] = "halt";
20797 + case LINUX_REBOOT_CMD_POWER_OFF:
20798 + argv[1] = "poweroff";
20801 + case LINUX_REBOOT_CMD_SW_SUSPEND:
20802 + argv[1] = "swsusp";
20806 + vxi->vx_state &= ~VXS_HELPER;
20810 +#ifndef CONFIG_VSERVER_LEGACY
20811 + ret = do_vshelper(vshelper_path, argv, envp, 1);
20813 + ret = do_vshelper(vshelper_path, argv, envp, 0);
20815 + vxi->vx_state &= ~VXS_HELPER;
20816 + __wakeup_vx_info(vxi);
20817 + return (ret) ? -EPERM : 0;
20821 +long vs_reboot(unsigned int cmd, void __user *arg)
20823 + struct vx_info *vxi = current->vx_info;
20826 + vxdprintk(VXD_CBIT(misc, 5),
20827 + "vs_reboot(%p[#%d],%d)",
20828 + vxi, vxi ? vxi->vx_id : 0, cmd);
20830 + ret = vs_reboot_helper(vxi, cmd, arg);
20834 + vxi->reboot_cmd = cmd;
20835 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20837 + case LINUX_REBOOT_CMD_RESTART:
20838 + case LINUX_REBOOT_CMD_HALT:
20839 + case LINUX_REBOOT_CMD_POWER_OFF:
20840 + vx_info_kill(vxi, 0, SIGKILL);
20841 + vx_info_kill(vxi, 1, SIGKILL);
20851 + * argv [0] = vshelper_path;
20852 + * argv [1] = action: "startup", "shutdown"
20853 + * argv [2] = context identifier
20855 + * envp [*] = type-specific parameters
20858 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20860 + char id_buf[8], cmd_buf[16];
20861 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20862 + char *envp[] = {"HOME=/", "TERM=linux",
20863 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20865 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20868 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20869 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20872 + case VSC_STARTUP:
20873 + argv[1] = "startup";
20875 + case VSC_SHUTDOWN:
20876 + argv[1] = "shutdown";
20882 + return do_vshelper(vshelper_path, argv, envp, 1);
20887 + * argv [0] = vshelper_path;
20888 + * argv [1] = action: "netup", "netdown"
20889 + * argv [2] = context identifier
20891 + * envp [*] = type-specific parameters
20894 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20896 + char id_buf[8], cmd_buf[16];
20897 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20898 + char *envp[] = {"HOME=/", "TERM=linux",
20899 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20901 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20904 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20905 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20909 + argv[1] = "netup";
20911 + case VSC_NETDOWN:
20912 + argv[1] = "netdown";
20918 + return do_vshelper(vshelper_path, argv, envp, 1);
20921 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/history.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/history.c
20922 --- linux-2.6.22.10/kernel/vserver/history.c 1970-01-01 01:00:00 +0100
20923 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/history.c 2007-06-15 02:37:04 +0200
20926 + * kernel/vserver/history.c
20928 + * Virtual Context History Backtrace
20930 + * Copyright (C) 2004-2007 Herbert Pötzl
20932 + * V0.01 basic structure
20933 + * V0.02 hash/unhash and trace
20934 + * V0.03 preemption fixes
20938 +#include <linux/errno.h>
20939 +#include <linux/module.h>
20940 +#include <linux/types.h>
20941 +#include <linux/ctype.h>
20943 +#include <asm/uaccess.h>
20944 +#include <asm/atomic.h>
20945 +#include <asm/unistd.h>
20947 +#include <linux/vserver/context.h>
20948 +#include <linux/vserver/debug.h>
20949 +#include <linux/vserver/debug_cmd.h>
20950 +#include <linux/vserver/history.h>
20953 +#ifdef CONFIG_VSERVER_HISTORY
20954 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
20956 +#define VXH_SIZE 64
20959 +struct _vx_history {
20960 + unsigned int counter;
20962 + struct _vx_hist_entry entry[VXH_SIZE + 1];
20966 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20968 +unsigned volatile int vxh_active = 1;
20970 +static atomic_t sequence = ATOMIC_INIT(0);
20975 + * requires disabled preemption */
20977 +struct _vx_hist_entry *vxh_advance(void *loc)
20979 + unsigned int cpu = smp_processor_id();
20980 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20981 + struct _vx_hist_entry *entry;
20982 + unsigned int index;
20984 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20985 + entry = &hist->entry[index];
20987 + entry->seq = atomic_inc_return(&sequence);
20988 + entry->loc = loc;
20992 +EXPORT_SYMBOL_GPL(vxh_advance);
20995 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
20997 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
21000 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
21002 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
21003 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
21004 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
21005 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
21007 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
21009 + switch (e->type) {
21010 + case VXH_THROW_OOPS:
21011 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
21014 + case VXH_GET_VX_INFO:
21015 + case VXH_PUT_VX_INFO:
21016 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
21018 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
21019 + VXH_VXI_ARGS(e));
21022 + case VXH_INIT_VX_INFO:
21023 + case VXH_SET_VX_INFO:
21024 + case VXH_CLR_VX_INFO:
21025 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
21027 + (e->type == VXH_INIT_VX_INFO) ? "init" :
21028 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
21029 + VXH_VXI_ARGS(e), e->sc.data);
21032 + case VXH_CLAIM_VX_INFO:
21033 + case VXH_RELEASE_VX_INFO:
21034 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
21036 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
21037 + VXH_VXI_ARGS(e), e->sc.data);
21040 + case VXH_ALLOC_VX_INFO:
21041 + case VXH_DEALLOC_VX_INFO:
21042 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
21044 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
21045 + VXH_VXI_ARGS(e));
21048 + case VXH_HASH_VX_INFO:
21049 + case VXH_UNHASH_VX_INFO:
21050 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
21052 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
21053 + VXH_VXI_ARGS(e));
21056 + case VXH_LOC_VX_INFO:
21057 + case VXH_LOOKUP_VX_INFO:
21058 + case VXH_CREATE_VX_INFO:
21059 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
21061 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
21062 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
21063 + e->ll.arg, VXH_VXI_ARGS(e));
21068 +static void __vxh_dump_history(void)
21070 + unsigned int i, cpu;
21072 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
21073 + atomic_read(&sequence), NR_CPUS);
21075 + for (i = 0; i < VXH_SIZE; i++) {
21076 + for_each_online_cpu(cpu) {
21077 + struct _vx_history *hist =
21078 + &per_cpu(vx_history_buffer, cpu);
21079 + unsigned int index = (hist->counter - i) % VXH_SIZE;
21080 + struct _vx_hist_entry *entry = &hist->entry[index];
21082 + vxh_dump_entry(entry, cpu);
21087 +void vxh_dump_history(void)
21091 + local_irq_enable();
21093 + local_irq_disable();
21095 + __vxh_dump_history();
21099 +/* vserver syscall commands below here */
21102 +int vc_dump_history(uint32_t id)
21105 + __vxh_dump_history();
21112 +int do_read_history(struct __user _vx_hist_entry *data,
21113 + int cpu, uint32_t *index, uint32_t *count)
21115 + int pos, ret = 0;
21116 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
21117 + int end = hist->counter;
21118 + int start = end - VXH_SIZE + 2;
21119 + int idx = *index;
21121 + /* special case: get current pos */
21127 + /* have we lost some data? */
21131 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21132 + struct _vx_hist_entry *entry =
21133 + &hist->entry[idx % VXH_SIZE];
21135 + /* send entry to userspace */
21136 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21140 + /* save new index and count */
21143 + return ret ? ret : (*index < end);
21146 +int vc_read_history(uint32_t id, void __user *data)
21148 + struct vcmd_read_history_v0 vc_data;
21151 + if (id >= NR_CPUS)
21154 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21157 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
21158 + id, &vc_data.index, &vc_data.count);
21160 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21165 +#ifdef CONFIG_COMPAT
21167 +int vc_read_history_x32(uint32_t id, void __user *data)
21169 + struct vcmd_read_history_v0_x32 vc_data;
21172 + if (id >= NR_CPUS)
21175 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21178 + ret = do_read_history((struct __user _vx_hist_entry *)
21179 + compat_ptr(vc_data.data_ptr),
21180 + id, &vc_data.index, &vc_data.count);
21182 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21187 +#endif /* CONFIG_COMPAT */
21189 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/init.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/init.c
21190 --- linux-2.6.22.10/kernel/vserver/init.c 1970-01-01 01:00:00 +0100
21191 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/init.c 2007-06-15 02:37:04 +0200
21194 + * linux/kernel/init.c
21196 + * Virtual Server Init
21198 + * Copyright (C) 2004-2007 Herbert Pötzl
21200 + * V0.01 basic structure
21204 +#include <linux/errno.h>
21205 +#include <linux/init.h>
21206 +#include <linux/module.h>
21208 +int vserver_register_sysctl(void);
21209 +void vserver_unregister_sysctl(void);
21212 +static int __init init_vserver(void)
21216 +#ifdef CONFIG_VSERVER_DEBUG
21217 + vserver_register_sysctl();
21223 +static void __exit exit_vserver(void)
21226 +#ifdef CONFIG_VSERVER_DEBUG
21227 + vserver_unregister_sysctl();
21232 +/* FIXME: GFP_ZONETYPES gone
21233 +long vx_slab[GFP_ZONETYPES]; */
21237 +module_init(init_vserver);
21238 +module_exit(exit_vserver);
21240 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/inode.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/inode.c
21241 --- linux-2.6.22.10/kernel/vserver/inode.c 1970-01-01 01:00:00 +0100
21242 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/inode.c 2007-07-16 06:39:15 +0200
21245 + * linux/kernel/vserver/inode.c
21247 + * Virtual Server: File System Support
21249 + * Copyright (C) 2004-2007 Herbert Pötzl
21251 + * V0.01 separated from vcontext V0.05
21255 +#include <linux/sched.h>
21256 +#include <linux/proc_fs.h>
21257 +#include <linux/devpts_fs.h>
21258 +#include <linux/namei.h>
21259 +#include <linux/mount.h>
21260 +#include <linux/parser.h>
21261 +#include <linux/file.h>
21262 +#include <linux/compat.h>
21263 +#include <linux/vserver/inode.h>
21264 +#include <linux/vserver/inode_cmd.h>
21265 +#include <linux/vs_base.h>
21266 +#include <linux/vs_tag.h>
21268 +#include <asm/errno.h>
21269 +#include <asm/uaccess.h>
21272 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21274 + struct proc_dir_entry *entry;
21276 + if (!in || !in->i_sb)
21279 + *flags = IATTR_TAG
21280 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21281 + | (IS_IUNLINK(in) ? IATTR_IUNLINK : 0)
21282 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
21283 + *mask = IATTR_IUNLINK | IATTR_IMMUTABLE;
21285 + if (S_ISDIR(in->i_mode))
21286 + *mask |= IATTR_BARRIER;
21288 + if (IS_TAGGED(in)) {
21289 + *tag = in->i_tag;
21290 + *mask |= IATTR_TAG;
21293 + switch (in->i_sb->s_magic) {
21294 + case PROC_SUPER_MAGIC:
21295 + entry = PROC_I(in)->pde;
21297 + /* check for specific inodes? */
21299 + *mask |= IATTR_FLAGS;
21301 + *flags |= (entry->vx_flags & IATTR_FLAGS);
21303 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21306 + case DEVPTS_SUPER_MAGIC:
21307 + *tag = in->i_tag;
21308 + *mask |= IATTR_TAG;
21317 +int vc_get_iattr(void __user *data)
21319 + struct nameidata nd;
21320 + struct vcmd_ctx_iattr_v1 vc_data = { .xid = -1 };
21323 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21326 + ret = user_path_walk_link(vc_data.name, &nd);
21328 + ret = __vc_get_iattr(nd.dentry->d_inode,
21329 + &vc_data.xid, &vc_data.flags, &vc_data.mask);
21330 + path_release(&nd);
21335 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21340 +#ifdef CONFIG_COMPAT
21342 +int vc_get_iattr_x32(void __user *data)
21344 + struct nameidata nd;
21345 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .xid = -1 };
21348 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21351 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
21353 + ret = __vc_get_iattr(nd.dentry->d_inode,
21354 + &vc_data.xid, &vc_data.flags, &vc_data.mask);
21355 + path_release(&nd);
21360 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21365 +#endif /* CONFIG_COMPAT */
21368 +int vc_fget_iattr(uint32_t fd, void __user *data)
21370 + struct file *filp;
21371 + struct vcmd_ctx_fiattr_v0 vc_data = { .xid = -1 };
21374 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21378 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21381 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
21382 + &vc_data.xid, &vc_data.flags, &vc_data.mask);
21386 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21392 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21394 + struct inode *in = de->d_inode;
21395 + int error = 0, is_proc = 0, has_tag = 0;
21396 + struct iattr attr = { 0 };
21398 + if (!in || !in->i_sb)
21401 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21402 + if ((*mask & IATTR_FLAGS) && !is_proc)
21405 + has_tag = IS_TAGGED(in) ||
21406 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21407 + if ((*mask & IATTR_TAG) && !has_tag)
21410 + mutex_lock(&in->i_mutex);
21411 + if (*mask & IATTR_TAG) {
21412 + attr.ia_tag = *tag;
21413 + attr.ia_valid |= ATTR_TAG;
21416 + if (*mask & IATTR_FLAGS) {
21417 + struct proc_dir_entry *entry = PROC_I(in)->pde;
21418 + unsigned int iflags = PROC_I(in)->vx_flags;
21420 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
21421 + | (*flags & IATTR_FLAGS);
21422 + PROC_I(in)->vx_flags = iflags;
21424 + entry->vx_flags = iflags;
21427 + if (*mask & (IATTR_BARRIER | IATTR_IUNLINK | IATTR_IMMUTABLE)) {
21428 + if (*mask & IATTR_IMMUTABLE) {
21429 + if (*flags & IATTR_IMMUTABLE)
21430 + in->i_flags |= S_IMMUTABLE;
21432 + in->i_flags &= ~S_IMMUTABLE;
21434 + if (*mask & IATTR_IUNLINK) {
21435 + if (*flags & IATTR_IUNLINK)
21436 + in->i_flags |= S_IUNLINK;
21438 + in->i_flags &= ~S_IUNLINK;
21440 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21441 + if (*flags & IATTR_BARRIER)
21442 + in->i_flags |= S_BARRIER;
21444 + in->i_flags &= ~S_BARRIER;
21446 + if (in->i_op && in->i_op->sync_flags) {
21447 + error = in->i_op->sync_flags(in);
21453 + if (attr.ia_valid) {
21454 + if (in->i_op && in->i_op->setattr)
21455 + error = in->i_op->setattr(de, &attr);
21457 + error = inode_change_ok(in, &attr);
21459 + error = inode_setattr(in, &attr);
21464 + mutex_unlock(&in->i_mutex);
21468 +int vc_set_iattr(void __user *data)
21470 + struct nameidata nd;
21471 + struct vcmd_ctx_iattr_v1 vc_data;
21474 + if (!capable(CAP_LINUX_IMMUTABLE))
21476 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21479 + ret = user_path_walk_link(vc_data.name, &nd);
21481 + ret = __vc_set_iattr(nd.dentry,
21482 + &vc_data.xid, &vc_data.flags, &vc_data.mask);
21483 + path_release(&nd);
21486 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21491 +#ifdef CONFIG_COMPAT
21493 +int vc_set_iattr_x32(void __user *data)
21495 + struct nameidata nd;
21496 + struct vcmd_ctx_iattr_v1_x32 vc_data;
21499 + if (!capable(CAP_LINUX_IMMUTABLE))
21501 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21504 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
21506 + ret = __vc_set_iattr(nd.dentry,
21507 + &vc_data.xid, &vc_data.flags, &vc_data.mask);
21508 + path_release(&nd);
21511 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21516 +#endif /* CONFIG_COMPAT */
21518 +int vc_fset_iattr(uint32_t fd, void __user *data)
21520 + struct file *filp;
21521 + struct vcmd_ctx_fiattr_v0 vc_data;
21524 + if (!capable(CAP_LINUX_IMMUTABLE))
21526 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21530 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21533 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.xid,
21534 + &vc_data.flags, &vc_data.mask);
21538 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21543 +#ifdef CONFIG_VSERVER_LEGACY
21545 +#define PROC_DYNAMIC_FIRST 0xF0000000UL
21547 +int vx_proc_ioctl(struct inode *inode, struct file *filp,
21548 + unsigned int cmd, unsigned long arg)
21550 + struct proc_dir_entry *entry;
21554 + if (inode->i_ino < PROC_DYNAMIC_FIRST)
21557 + entry = PROC_I(inode)->pde;
21562 + case FIOC_GETXFLG: {
21563 + /* fixme: if stealth, return -ENOTTY */
21565 + flags = entry->vx_flags;
21566 + if (capable(CAP_CONTEXT))
21567 + error = put_user(flags, (int __user *) arg);
21570 + case FIOC_SETXFLG: {
21571 + /* fixme: if stealth, return -ENOTTY */
21573 + if (!capable(CAP_CONTEXT))
21576 + if (IS_RDONLY(inode))
21579 + if (get_user(flags, (int __user *) arg))
21582 + entry->vx_flags = flags;
21590 +#endif /* CONFIG_VSERVER_LEGACY */
21592 +#ifdef CONFIG_PROPAGATE
21594 +int dx_parse_tag(char *string, tag_t *tag, int remove)
21596 + static match_table_t tokens = {
21600 + substring_t args[MAX_OPT_ARGS];
21601 + int token, option = 0;
21606 + token = match_token(string, tokens, args);
21607 + if (token && tag && !match_int(args, &option))
21610 + vxdprintk(VXD_CBIT(tag, 7),
21611 + "dx_parse_tag(»%s«): %d:#%d",
21612 + string, token, option);
21614 + if ((token == 1) && remove) {
21615 + char *p = strstr(string, "tagid=");
21619 + while (*q != '\0' && *q != ',')
21630 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21632 + tag_t new_tag = 0;
21633 + struct vfsmount *mnt;
21642 + propagate = (mnt->mnt_flags & MNT_TAGID);
21644 + new_tag = mnt->mnt_tag;
21646 + vxdprintk(VXD_CBIT(tag, 7),
21647 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21648 + inode, inode->i_ino, inode->i_tag,
21649 + new_tag, (propagate) ? 1 : 0);
21652 + inode->i_tag = new_tag;
21655 +#include <linux/module.h>
21657 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21659 +#endif /* CONFIG_PROPAGATE */
21661 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/legacy.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/legacy.c
21662 --- linux-2.6.22.10/kernel/vserver/legacy.c 1970-01-01 01:00:00 +0100
21663 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/legacy.c 2007-06-15 02:37:04 +0200
21666 + * linux/kernel/vserver/legacy.c
21668 + * Virtual Server: Legacy Funtions
21670 + * Copyright (C) 2001-2003 Jacques Gelinas
21671 + * Copyright (C) 2003-2007 Herbert Pötzl
21673 + * V0.01 broken out from vcontext.c V0.05
21674 + * V0.02 updated to spaces *sigh*
21678 +#include <linux/sched.h>
21679 +#include <linux/vs_context.h>
21680 +#include <linux/vs_network.h>
21681 +#include <linux/vserver/legacy.h>
21682 +#include <linux/vserver/space.h>
21683 +// #include <linux/mnt_namespace.h>
21685 +#include <asm/errno.h>
21686 +#include <asm/uaccess.h>
21689 +extern int vx_set_init(struct vx_info *, struct task_struct *);
21691 +static int vx_set_initpid(struct vx_info *vxi, int pid)
21693 + struct task_struct *init;
21695 + init = find_task_by_real_pid(pid);
21698 + return vx_set_init(vxi, init);
21701 +int vc_new_s_context(uint32_t ctx, void __user *data)
21703 + int ret = -ENOMEM;
21704 + struct vcmd_new_s_context_v1 vc_data;
21705 + struct vx_info *new_vxi;
21707 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21710 + /* legacy hack, will be removed soon */
21712 + /* assign flags and initpid */
21713 + if (!current->vx_info)
21716 + if (vc_data.flags & VX_INFO_INIT)
21717 + ret = vx_set_initpid(current->vx_info, current->tgid);
21719 + /* We keep the same vx_id, but lower the capabilities */
21720 + current->vx_info->vx_bcaps &= (~vc_data.remove_cap);
21721 + ret = vx_current_xid();
21722 + current->vx_info->vx_flags |= vc_data.flags;
21727 + if (!vx_check(0, VS_ADMIN) || !capable(CAP_SYS_ADMIN)
21728 + /* might make sense in the future, or not ... */
21729 + || vx_flags(VX_INFO_PRIVATE, 0))
21732 + /* ugly hack for Spectator */
21734 + current->xid = 1;
21738 + if (((ctx > MAX_S_CONTEXT) && (ctx != VX_DYNAMIC_ID)) ||
21742 + if ((ctx == VX_DYNAMIC_ID) || (ctx < MIN_D_CONTEXT))
21743 + new_vxi = lookup_or_create_vx_info(ctx);
21745 + new_vxi = lookup_vx_info(ctx);
21751 + if (!vx_info_flags(new_vxi, VXF_STATE_SETUP, 0) &&
21752 + vx_info_flags(new_vxi, VX_INFO_PRIVATE, 0))
21755 + ret = vx_migrate_task(current, new_vxi,
21756 + vx_info_flags(new_vxi, VXF_STATE_SETUP, 0));
21757 + new_vxi->vx_flags &= ~VXF_STATE_SETUP;
21760 + current->vx_info->vx_bcaps &= (~vc_data.remove_cap);
21761 + new_vxi->vx_flags |= vc_data.flags;
21762 + if (vc_data.flags & VX_INFO_INIT)
21763 + vx_set_initpid(new_vxi, current->tgid);
21764 + if (vc_data.flags & VX_INFO_NAMESPACE)
21765 + vx_set_space(new_vxi, CLONE_NEWNS | CLONE_FS);
21766 + if (vc_data.flags & VX_INFO_NPROC)
21767 + __rlim_set(&new_vxi->limit, RLIMIT_NPROC,
21768 + current->signal->rlim[RLIMIT_NPROC].rlim_max);
21770 + /* tweak some defaults for legacy */
21771 + new_vxi->vx_flags |= (VXF_HIDE_NETIF | VXF_INFO_INIT);
21772 + ret = new_vxi->vx_id;
21775 + put_vx_info(new_vxi);
21779 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/legacynet.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/legacynet.c
21780 --- linux-2.6.22.10/kernel/vserver/legacynet.c 1970-01-01 01:00:00 +0100
21781 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/legacynet.c 2007-06-15 02:37:04 +0200
21785 + * linux/kernel/vserver/legacynet.c
21787 + * Virtual Server: Legacy Network Funtions
21789 + * Copyright (C) 2001-2003 Jacques Gelinas
21790 + * Copyright (C) 2003-2007 Herbert Pötzl
21792 + * V0.01 broken out from legacy.c
21796 +#include <linux/sched.h>
21797 +#include <linux/vs_context.h>
21798 +#include <linux/vs_network.h>
21799 +#include <linux/vserver/legacy.h>
21800 +// #include <linux/mnt_namespace.h>
21801 +#include <linux/err.h>
21803 +#include <asm/errno.h>
21804 +#include <asm/uaccess.h>
21807 +extern struct nx_info *create_nx_info(void);
21809 +/* set ipv4 root (syscall) */
21811 +int vc_set_ipv4root(uint32_t nbip, void __user *data)
21813 + int i, err = -EPERM;
21814 + struct vcmd_set_ipv4root_v3 vc_data;
21815 + struct nx_info *new_nxi, *nxi = current->nx_info;
21817 + if (nbip < 0 || nbip > NB_IPV4ROOT)
21819 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21822 + if (!nxi || nxi->ipv4[0] == 0 || capable(CAP_NET_ADMIN))
21823 + /* We are allowed to change everything */
21828 + /* We are allowed to select a subset of the currently
21829 + installed IP numbers. No new one are allowed
21830 + We can't change the broadcast address though */
21831 + for (i = 0; i < nbip; i++) {
21833 + __u32 nxip = vc_data.nx_mask_pair[i].ip;
21834 + for (j = 0; j < nxi->nbipv4; j++) {
21835 + if (nxip == nxi->ipv4[j]) {
21841 + if ((found == nbip) &&
21842 + (vc_data.broadcast == nxi->v4_bcast))
21848 + new_nxi = create_nx_info();
21849 + if (IS_ERR(new_nxi))
21852 + new_nxi->nbipv4 = nbip;
21853 + for (i = 0; i < nbip; i++) {
21854 + new_nxi->ipv4[i] = vc_data.nx_mask_pair[i].ip;
21855 + new_nxi->mask[i] = vc_data.nx_mask_pair[i].mask;
21857 + new_nxi->v4_bcast = vc_data.broadcast;
21859 + printk("!!! switching nx_info %p->%p\n", nxi, new_nxi);
21861 + nx_migrate_task(current, new_nxi);
21862 + release_nx_info(new_nxi, NULL);
21863 + put_nx_info(new_nxi);
21868 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/limit.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/limit.c
21869 --- linux-2.6.22.10/kernel/vserver/limit.c 1970-01-01 01:00:00 +0100
21870 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/limit.c 2007-06-15 02:37:04 +0200
21873 + * linux/kernel/vserver/limit.c
21875 + * Virtual Server: Context Limits
21877 + * Copyright (C) 2004-2007 Herbert Pötzl
21879 + * V0.01 broken out from vcontext V0.05
21880 + * V0.02 changed vcmds to vxi arg
21884 +#include <linux/module.h>
21885 +#include <linux/vs_context.h>
21886 +#include <linux/vs_limit.h>
21887 +#include <linux/vserver/limit.h>
21888 +#include <linux/vserver/switch.h>
21889 +#include <linux/vserver/limit_cmd.h>
21891 +#include <asm/errno.h>
21892 +#include <asm/uaccess.h>
21895 +const char *vlimit_name[NUM_LIMITS] = {
21896 + [RLIMIT_CPU] = "CPU",
21897 + [RLIMIT_RSS] = "RSS",
21898 + [RLIMIT_NPROC] = "NPROC",
21899 + [RLIMIT_NOFILE] = "NOFILE",
21900 + [RLIMIT_MEMLOCK] = "VML",
21901 + [RLIMIT_AS] = "VM",
21902 + [RLIMIT_LOCKS] = "LOCKS",
21903 + [RLIMIT_SIGPENDING] = "SIGP",
21904 + [RLIMIT_MSGQUEUE] = "MSGQ",
21906 + [VLIMIT_NSOCK] = "NSOCK",
21907 + [VLIMIT_OPENFD] = "OPENFD",
21908 + [VLIMIT_ANON] = "ANON",
21909 + [VLIMIT_SHMEM] = "SHMEM",
21910 + [VLIMIT_DENTRY] = "DENTRY",
21913 +EXPORT_SYMBOL_GPL(vlimit_name);
21915 +#define MASK_ENTRY(x) (1 << (x))
21917 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21920 + , /* softlimit */
21921 + MASK_ENTRY( RLIMIT_RSS ) |
21922 + MASK_ENTRY( VLIMIT_ANON ) |
21925 + MASK_ENTRY( RLIMIT_RSS ) |
21926 + MASK_ENTRY( RLIMIT_NPROC ) |
21927 + MASK_ENTRY( RLIMIT_NOFILE ) |
21928 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
21929 + MASK_ENTRY( RLIMIT_AS ) |
21930 + MASK_ENTRY( RLIMIT_LOCKS ) |
21931 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21933 + MASK_ENTRY( VLIMIT_NSOCK ) |
21934 + MASK_ENTRY( VLIMIT_OPENFD ) |
21935 + MASK_ENTRY( VLIMIT_ANON ) |
21936 + MASK_ENTRY( VLIMIT_SHMEM ) |
21937 + MASK_ENTRY( VLIMIT_DENTRY ) |
21940 + /* accounting only */
21941 +uint32_t account_mask =
21942 + MASK_ENTRY( VLIMIT_SEMARY ) |
21943 + MASK_ENTRY( VLIMIT_NSEMS ) |
21944 + MASK_ENTRY( VLIMIT_MAPPED ) |
21948 +static int is_valid_vlimit(int id)
21950 + uint32_t mask = vlimit_mask.minimum |
21951 + vlimit_mask.softlimit | vlimit_mask.maximum;
21952 + return mask & (1 << id);
21955 +static int is_accounted_vlimit(int id)
21957 + if (is_valid_vlimit(id))
21959 + return account_mask & (1 << id);
21963 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21965 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21966 + return VX_VLIM(limit);
21969 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21971 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21972 + return VX_VLIM(limit);
21975 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21976 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21978 + if (!is_valid_vlimit(id))
21982 + *minimum = CRLIM_UNSET;
21984 + *softlimit = vc_get_soft(vxi, id);
21986 + *maximum = vc_get_hard(vxi, id);
21990 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21992 + struct vcmd_ctx_rlimit_v0 vc_data;
21995 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21998 + ret = do_get_rlimit(vxi, vc_data.id,
21999 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
22003 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22008 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
22009 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
22011 + if (!is_valid_vlimit(id))
22014 + if (maximum != CRLIM_KEEP)
22015 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
22016 + if (softlimit != CRLIM_KEEP)
22017 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
22019 + /* clamp soft limit */
22020 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
22021 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
22026 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
22028 + struct vcmd_ctx_rlimit_v0 vc_data;
22030 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22033 + return do_set_rlimit(vxi, vc_data.id,
22034 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
22037 +#ifdef CONFIG_IA32_EMULATION
22039 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
22041 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
22043 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22046 + return do_set_rlimit(vxi, vc_data.id,
22047 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
22050 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
22052 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
22055 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22058 + ret = do_get_rlimit(vxi, vc_data.id,
22059 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
22063 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22068 +#endif /* CONFIG_IA32_EMULATION */
22071 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
22073 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
22079 +static inline void vx_reset_minmax(struct _vx_limit *limit)
22084 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22085 + value = __rlim_get(limit, lim);
22086 + __rlim_rmax(limit, lim) = value;
22087 + __rlim_rmin(limit, lim) = value;
22092 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
22094 + vx_reset_minmax(&vxi->limit);
22099 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
22101 + struct vcmd_rlimit_stat_v0 vc_data;
22102 + struct _vx_limit *limit = &vxi->limit;
22105 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22109 + if (!is_accounted_vlimit(id))
22112 + vx_limit_fixup(limit, id);
22113 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
22114 + vc_data.value = __rlim_get(limit, id);
22115 + vc_data.minimum = __rlim_rmin(limit, id);
22116 + vc_data.maximum = __rlim_rmax(limit, id);
22118 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22124 +void vx_vsi_meminfo(struct sysinfo *val)
22126 + struct vx_info *vxi = current->vx_info;
22127 + unsigned long totalram, freeram;
22130 + /* we blindly accept the max */
22131 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22132 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
22134 + /* total minus used equals free */
22135 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22136 + freeram = (v < totalram) ? totalram - v : 0;
22138 + val->totalram = totalram;
22139 + val->freeram = freeram;
22140 + val->bufferram = 0;
22141 + val->totalhigh = 0;
22142 + val->freehigh = 0;
22146 +void vx_vsi_swapinfo(struct sysinfo *val)
22148 + struct vx_info *vxi = current->vx_info;
22149 + unsigned long totalswap, freeswap;
22152 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22153 + if (v == RLIM_INFINITY) {
22154 + val->freeswap = val->totalswap;
22158 + /* we blindly accept the max */
22159 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
22160 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
22162 + /* currently 'used' swap */
22163 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22164 + w -= (w > v) ? v : w;
22166 + /* total minus used equals free */
22167 + freeswap = (w < totalswap) ? totalswap - w : 0;
22169 + val->totalswap = totalswap;
22170 + val->freeswap = freeswap;
22175 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
22177 + struct vx_info *vxi = mm->mm_vx_info;
22178 + unsigned long points;
22184 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22185 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22186 + points = (v > w) ? (v - w) : 0;
22191 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/limit_init.h linux-2.6.22.10-vs2.2.0.5/kernel/vserver/limit_init.h
22192 --- linux-2.6.22.10/kernel/vserver/limit_init.h 1970-01-01 01:00:00 +0100
22193 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/limit_init.h 2007-10-29 23:34:24 +0100
22197 +static inline void vx_info_init_limit(struct _vx_limit *limit)
22201 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22202 + __rlim_soft(limit, lim) = RLIM_INFINITY;
22203 + __rlim_hard(limit, lim) = RLIM_INFINITY;
22204 + __rlim_set(limit, lim, 0);
22205 + atomic_set(&__rlim_lhit(limit, lim), 0);
22206 + __rlim_rmin(limit, lim) = 0;
22207 + __rlim_rmax(limit, lim) = 0;
22211 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
22213 +#ifdef CONFIG_VSERVER_WARN
22217 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22218 + if ((1 << lim) & VLIM_NOCHECK)
22220 + value = __rlim_get(limit, lim);
22221 + vxwprintk_xid(value,
22222 + "!!! limit: %p[%s,%d] = %ld on exit.",
22223 + limit, vlimit_name[lim], lim, (long)value);
22228 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/limit_proc.h linux-2.6.22.10-vs2.2.0.5/kernel/vserver/limit_proc.h
22229 --- linux-2.6.22.10/kernel/vserver/limit_proc.h 1970-01-01 01:00:00 +0100
22230 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/limit_proc.h 2007-06-15 02:37:04 +0200
22232 +#ifndef _VX_LIMIT_PROC_H
22233 +#define _VX_LIMIT_PROC_H
22235 +#include <linux/vserver/limit_int.h>
22238 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
22239 +#define VX_LIMIT_TOP \
22240 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
22242 +#define VX_LIMIT_ARG(r) \
22243 + (unsigned long)__rlim_get(limit, r), \
22244 + (unsigned long)__rlim_rmin(limit, r), \
22245 + (unsigned long)__rlim_rmax(limit, r), \
22246 + VX_VLIM(__rlim_soft(limit, r)), \
22247 + VX_VLIM(__rlim_hard(limit, r)), \
22248 + atomic_read(&__rlim_lhit(limit, r))
22250 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
22252 + vx_limit_fixup(limit, -1);
22253 + return sprintf(buffer, VX_LIMIT_TOP
22254 + "PROC" VX_LIMIT_FMT
22255 + "VM" VX_LIMIT_FMT
22256 + "VML" VX_LIMIT_FMT
22257 + "RSS" VX_LIMIT_FMT
22258 + "ANON" VX_LIMIT_FMT
22259 + "RMAP" VX_LIMIT_FMT
22260 + "FILES" VX_LIMIT_FMT
22261 + "OFD" VX_LIMIT_FMT
22262 + "LOCKS" VX_LIMIT_FMT
22263 + "SOCK" VX_LIMIT_FMT
22264 + "MSGQ" VX_LIMIT_FMT
22265 + "SHM" VX_LIMIT_FMT
22266 + "SEMA" VX_LIMIT_FMT
22267 + "SEMS" VX_LIMIT_FMT
22268 + "DENT" VX_LIMIT_FMT,
22269 + VX_LIMIT_ARG(RLIMIT_NPROC),
22270 + VX_LIMIT_ARG(RLIMIT_AS),
22271 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22272 + VX_LIMIT_ARG(RLIMIT_RSS),
22273 + VX_LIMIT_ARG(VLIMIT_ANON),
22274 + VX_LIMIT_ARG(VLIMIT_MAPPED),
22275 + VX_LIMIT_ARG(RLIMIT_NOFILE),
22276 + VX_LIMIT_ARG(VLIMIT_OPENFD),
22277 + VX_LIMIT_ARG(RLIMIT_LOCKS),
22278 + VX_LIMIT_ARG(VLIMIT_NSOCK),
22279 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22280 + VX_LIMIT_ARG(VLIMIT_SHMEM),
22281 + VX_LIMIT_ARG(VLIMIT_SEMARY),
22282 + VX_LIMIT_ARG(VLIMIT_NSEMS),
22283 + VX_LIMIT_ARG(VLIMIT_DENTRY));
22286 +#endif /* _VX_LIMIT_PROC_H */
22289 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/monitor.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/monitor.c
22290 --- linux-2.6.22.10/kernel/vserver/monitor.c 1970-01-01 01:00:00 +0100
22291 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/monitor.c 2007-06-15 05:59:57 +0200
22294 + * kernel/vserver/monitor.c
22296 + * Virtual Context Scheduler Monitor
22298 + * Copyright (C) 2006-2007 Herbert Pötzl
22300 + * V0.01 basic design
22304 +#include <linux/errno.h>
22305 +#include <linux/module.h>
22306 +#include <linux/types.h>
22307 +#include <linux/ctype.h>
22308 +#include <linux/jiffies.h>
22310 +#include <asm/uaccess.h>
22311 +#include <asm/atomic.h>
22312 +#include <asm/unistd.h>
22314 +#include <linux/vserver/monitor.h>
22315 +#include <linux/vserver/debug_cmd.h>
22318 +#ifdef CONFIG_VSERVER_MONITOR
22319 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
22321 +#define VXM_SIZE 64
22324 +struct _vx_monitor {
22325 + unsigned int counter;
22327 + struct _vx_mon_entry entry[VXM_SIZE+1];
22331 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
22333 +unsigned volatile int vxm_active = 1;
22335 +static atomic_t sequence = ATOMIC_INIT(0);
22340 + * requires disabled preemption */
22342 +struct _vx_mon_entry *vxm_advance(int cpu)
22344 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22345 + struct _vx_mon_entry *entry;
22346 + unsigned int index;
22348 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
22349 + entry = &mon->entry[index];
22351 + entry->ev.seq = atomic_inc_return(&sequence);
22352 + entry->ev.jif = jiffies;
22356 +EXPORT_SYMBOL_GPL(vxm_advance);
22359 +int do_read_monitor(struct __user _vx_mon_entry *data,
22360 + int cpu, uint32_t *index, uint32_t *count)
22362 + int pos, ret = 0;
22363 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22364 + int end = mon->counter;
22365 + int start = end - VXM_SIZE + 2;
22366 + int idx = *index;
22368 + /* special case: get current pos */
22374 + /* have we lost some data? */
22378 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22379 + struct _vx_mon_entry *entry =
22380 + &mon->entry[idx % VXM_SIZE];
22382 + /* send entry to userspace */
22383 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22387 + /* save new index and count */
22390 + return ret ? ret : (*index < end);
22393 +int vc_read_monitor(uint32_t id, void __user *data)
22395 + struct vcmd_read_monitor_v0 vc_data;
22398 + if (id >= NR_CPUS)
22401 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22404 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
22405 + id, &vc_data.index, &vc_data.count);
22407 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22412 +#ifdef CONFIG_COMPAT
22414 +int vc_read_monitor_x32(uint32_t id, void __user *data)
22416 + struct vcmd_read_monitor_v0_x32 vc_data;
22419 + if (id >= NR_CPUS)
22422 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22425 + ret = do_read_monitor((struct __user _vx_mon_entry *)
22426 + compat_ptr(vc_data.data_ptr),
22427 + id, &vc_data.index, &vc_data.count);
22429 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22434 +#endif /* CONFIG_COMPAT */
22436 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/network.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/network.c
22437 --- linux-2.6.22.10/kernel/vserver/network.c 1970-01-01 01:00:00 +0100
22438 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/network.c 2007-07-19 07:08:54 +0200
22441 + * linux/kernel/vserver/network.c
22443 + * Virtual Server: Network Support
22445 + * Copyright (C) 2003-2007 Herbert Pötzl
22447 + * V0.01 broken out from vcontext V0.05
22448 + * V0.02 cleaned up implementation
22449 + * V0.03 added equiv nx commands
22450 + * V0.04 switch to RCU based hash
22451 + * V0.05 and back to locking again
22452 + * V0.06 changed vcmds to nxi arg
22453 + * V0.07 have __create claim() the nxi
22457 +#include <linux/slab.h>
22458 +#include <linux/rcupdate.h>
22459 +#include <net/tcp.h>
22461 +#include <asm/errno.h>
22462 +#include <linux/vserver/base.h>
22463 +#include <linux/vserver/network_cmd.h>
22466 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
22467 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
22470 +/* __alloc_nx_info()
22472 + * allocate an initialized nx_info struct
22473 + * doesn't make it visible (hash) */
22475 +static struct nx_info *__alloc_nx_info(nid_t nid)
22477 + struct nx_info *new = NULL;
22479 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22481 + /* would this benefit from a slab cache? */
22482 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22486 + memset(new, 0, sizeof(struct nx_info));
22487 + new->nx_id = nid;
22488 + INIT_HLIST_NODE(&new->nx_hlist);
22489 + atomic_set(&new->nx_usecnt, 0);
22490 + atomic_set(&new->nx_tasks, 0);
22491 + new->nx_state = 0;
22493 + new->nx_flags = NXF_INIT_SET;
22495 + /* rest of init goes here */
22497 + vxdprintk(VXD_CBIT(nid, 0),
22498 + "alloc_nx_info(%d) = %p", nid, new);
22499 + atomic_inc(&nx_global_ctotal);
22503 +/* __dealloc_nx_info()
22505 + * final disposal of nx_info */
22507 +static void __dealloc_nx_info(struct nx_info *nxi)
22509 + vxdprintk(VXD_CBIT(nid, 0),
22510 + "dealloc_nx_info(%p)", nxi);
22512 + nxi->nx_hlist.next = LIST_POISON1;
22515 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22516 + BUG_ON(atomic_read(&nxi->nx_tasks));
22518 + nxi->nx_state |= NXS_RELEASED;
22520 + atomic_dec(&nx_global_ctotal);
22523 +static void __shutdown_nx_info(struct nx_info *nxi)
22525 + nxi->nx_state |= NXS_SHUTDOWN;
22526 + vs_net_change(nxi, VSC_NETDOWN);
22529 +/* exported stuff */
22531 +void free_nx_info(struct nx_info *nxi)
22533 + /* context shutdown is mandatory */
22534 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22536 + /* context must not be hashed */
22537 + BUG_ON(nxi->nx_state & NXS_HASHED);
22539 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22540 + BUG_ON(atomic_read(&nxi->nx_tasks));
22542 + __dealloc_nx_info(nxi);
22546 +/* hash table for nx_info hash */
22548 +#define NX_HASH_SIZE 13
22550 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22552 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
22555 +static inline unsigned int __hashval(nid_t nid)
22557 + return (nid % NX_HASH_SIZE);
22562 +/* __hash_nx_info()
22564 + * add the nxi to the global hash table
22565 + * requires the hash_lock to be held */
22567 +static inline void __hash_nx_info(struct nx_info *nxi)
22569 + struct hlist_head *head;
22571 + vxd_assert_lock(&nx_info_hash_lock);
22572 + vxdprintk(VXD_CBIT(nid, 4),
22573 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22575 + /* context must not be hashed */
22576 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
22578 + nxi->nx_state |= NXS_HASHED;
22579 + head = &nx_info_hash[__hashval(nxi->nx_id)];
22580 + hlist_add_head(&nxi->nx_hlist, head);
22581 + atomic_inc(&nx_global_cactive);
22584 +/* __unhash_nx_info()
22586 + * remove the nxi from the global hash table
22587 + * requires the hash_lock to be held */
22589 +static inline void __unhash_nx_info(struct nx_info *nxi)
22591 + vxd_assert_lock(&nx_info_hash_lock);
22592 + vxdprintk(VXD_CBIT(nid, 4),
22593 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22594 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22596 + /* context must be hashed */
22597 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22598 + /* but without tasks */
22599 + BUG_ON(atomic_read(&nxi->nx_tasks));
22601 + nxi->nx_state &= ~NXS_HASHED;
22602 + hlist_del(&nxi->nx_hlist);
22603 + atomic_dec(&nx_global_cactive);
22607 +/* __lookup_nx_info()
22609 + * requires the hash_lock to be held
22610 + * doesn't increment the nx_refcnt */
22612 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22614 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22615 + struct hlist_node *pos;
22616 + struct nx_info *nxi;
22618 + vxd_assert_lock(&nx_info_hash_lock);
22619 + hlist_for_each(pos, head) {
22620 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22622 + if (nxi->nx_id == nid)
22627 + vxdprintk(VXD_CBIT(nid, 0),
22628 + "__lookup_nx_info(#%u): %p[#%u]",
22629 + nid, nxi, nxi ? nxi->nx_id : 0);
22634 +/* __nx_dynamic_id()
22636 + * find unused dynamic nid
22637 + * requires the hash_lock to be held */
22639 +static inline nid_t __nx_dynamic_id(void)
22641 + static nid_t seq = MAX_N_CONTEXT;
22642 + nid_t barrier = seq;
22644 + vxd_assert_lock(&nx_info_hash_lock);
22646 + if (++seq > MAX_N_CONTEXT)
22647 + seq = MIN_D_CONTEXT;
22648 + if (!__lookup_nx_info(seq)) {
22649 + vxdprintk(VXD_CBIT(nid, 4),
22650 + "__nx_dynamic_id: [#%d]", seq);
22653 + } while (barrier != seq);
22657 +/* __create_nx_info()
22659 + * create the requested context
22660 + * get(), claim() and hash it */
22662 +static struct nx_info *__create_nx_info(int id)
22664 + struct nx_info *new, *nxi = NULL;
22666 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22668 + if (!(new = __alloc_nx_info(id)))
22669 + return ERR_PTR(-ENOMEM);
22671 + /* required to make dynamic xids unique */
22672 + spin_lock(&nx_info_hash_lock);
22674 + /* dynamic context requested */
22675 + if (id == NX_DYNAMIC_ID) {
22676 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
22677 + id = __nx_dynamic_id();
22679 + printk(KERN_ERR "no dynamic context available.\n");
22680 + nxi = ERR_PTR(-EAGAIN);
22685 + printk(KERN_ERR "dynamic contexts disabled.\n");
22686 + nxi = ERR_PTR(-EINVAL);
22690 + /* static context requested */
22691 + else if ((nxi = __lookup_nx_info(id))) {
22692 + vxdprintk(VXD_CBIT(nid, 0),
22693 + "create_nx_info(%d) = %p (already there)", id, nxi);
22694 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22695 + nxi = ERR_PTR(-EBUSY);
22697 + nxi = ERR_PTR(-EEXIST);
22700 + /* dynamic nid creation blocker */
22701 + else if (id >= MIN_D_CONTEXT) {
22702 + vxdprintk(VXD_CBIT(nid, 0),
22703 + "create_nx_info(%d) (dynamic rejected)", id);
22704 + nxi = ERR_PTR(-EINVAL);
22708 + /* new context */
22709 + vxdprintk(VXD_CBIT(nid, 0),
22710 + "create_nx_info(%d) = %p (new)", id, new);
22711 + claim_nx_info(new, NULL);
22712 + __hash_nx_info(get_nx_info(new));
22713 + nxi = new, new = NULL;
22716 + spin_unlock(&nx_info_hash_lock);
22718 + __dealloc_nx_info(new);
22724 +/* exported stuff */
22727 +void unhash_nx_info(struct nx_info *nxi)
22729 + __shutdown_nx_info(nxi);
22730 + spin_lock(&nx_info_hash_lock);
22731 + __unhash_nx_info(nxi);
22732 + spin_unlock(&nx_info_hash_lock);
22735 +#ifdef CONFIG_VSERVER_LEGACYNET
22737 +struct nx_info *create_nx_info(void)
22739 + return __create_nx_info(NX_DYNAMIC_ID);
22744 +/* lookup_nx_info()
22746 + * search for a nx_info and get() it
22747 + * negative id means current */
22749 +struct nx_info *lookup_nx_info(int id)
22751 + struct nx_info *nxi = NULL;
22754 + nxi = get_nx_info(current->nx_info);
22755 + } else if (id > 1) {
22756 + spin_lock(&nx_info_hash_lock);
22757 + nxi = get_nx_info(__lookup_nx_info(id));
22758 + spin_unlock(&nx_info_hash_lock);
22763 +/* nid_is_hashed()
22765 + * verify that nid is still hashed */
22767 +int nid_is_hashed(nid_t nid)
22771 + spin_lock(&nx_info_hash_lock);
22772 + hashed = (__lookup_nx_info(nid) != NULL);
22773 + spin_unlock(&nx_info_hash_lock);
22778 +#ifdef CONFIG_PROC_FS
22782 + * get a subset of hashed nids for proc
22783 + * assumes size is at least one */
22785 +int get_nid_list(int index, unsigned int *nids, int size)
22787 + int hindex, nr_nids = 0;
22789 + /* only show current and children */
22790 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22793 + nids[nr_nids] = nx_current_nid();
22797 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22798 + struct hlist_head *head = &nx_info_hash[hindex];
22799 + struct hlist_node *pos;
22801 + spin_lock(&nx_info_hash_lock);
22802 + hlist_for_each(pos, head) {
22803 + struct nx_info *nxi;
22808 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22809 + nids[nr_nids] = nxi->nx_id;
22810 + if (++nr_nids >= size) {
22811 + spin_unlock(&nx_info_hash_lock);
22815 + /* keep the lock time short */
22816 + spin_unlock(&nx_info_hash_lock);
22825 + * migrate task to new network
22826 + * gets nxi, puts old_nxi on change
22829 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22831 + struct nx_info *old_nxi;
22837 + vxdprintk(VXD_CBIT(nid, 5),
22838 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22839 + p, nxi, nxi->nx_id,
22840 + atomic_read(&nxi->nx_usecnt),
22841 + atomic_read(&nxi->nx_tasks));
22843 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22844 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22847 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22850 + /* maybe disallow this completely? */
22851 + old_nxi = task_get_nx_info(p);
22852 + if (old_nxi == nxi)
22857 + clr_nx_info(&p->nx_info);
22858 + claim_nx_info(nxi, p);
22859 + set_nx_info(&p->nx_info, nxi);
22860 + p->nid = nxi->nx_id;
22863 + vxdprintk(VXD_CBIT(nid, 5),
22864 + "moved task %p into nxi:%p[#%d]",
22865 + p, nxi, nxi->nx_id);
22868 + release_nx_info(old_nxi, p);
22871 + put_nx_info(old_nxi);
22876 +#ifdef CONFIG_INET
22878 +#include <linux/netdevice.h>
22879 +#include <linux/inetdevice.h>
22881 +int ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
22887 + return addr_in_nx_info(nxi, ifa->ifa_local);
22890 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
22892 + struct in_device *in_dev;
22893 + struct in_ifaddr **ifap;
22894 + struct in_ifaddr *ifa;
22902 + in_dev = in_dev_get(dev);
22906 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
22907 + ifap = &ifa->ifa_next) {
22908 + if (addr_in_nx_info(nxi, ifa->ifa_local)) {
22913 + in_dev_put(in_dev);
22919 + * check if address is covered by socket
22921 + * sk: the socket to check against
22922 + * addr: the address in question (must be != 0)
22924 +static inline int __addr_in_socket(const struct sock *sk, uint32_t addr)
22926 + struct nx_info *nxi = sk->sk_nx_info;
22927 + uint32_t saddr = inet_rcv_saddr(sk);
22929 + vxdprintk(VXD_CBIT(net, 5),
22930 + "__addr_in_socket(%p," NIPQUAD_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
22931 + sk, NIPQUAD(addr), nxi, NIPQUAD(saddr), sk->sk_socket,
22932 + (sk->sk_socket ? sk->sk_socket->flags : 0));
22935 + /* direct address match */
22936 + return (saddr == addr);
22937 + } else if (nxi) {
22938 + /* match against nx_info */
22939 + return addr_in_nx_info(nxi, addr);
22941 + /* unrestricted any socket */
22947 +int nx_addr_conflict(struct nx_info *nxi, uint32_t addr, const struct sock *sk)
22949 + vxdprintk(VXD_CBIT(net, 2),
22950 + "nx_addr_conflict(%p,%p) " NIPQUAD_FMT,
22951 + nxi, sk, NIPQUAD(addr));
22954 + /* check real address */
22955 + return __addr_in_socket(sk, addr);
22956 + } else if (nxi) {
22957 + /* check against nx_info */
22958 + int i, n = nxi->nbipv4;
22960 + for (i = 0; i < n; i++)
22961 + if (__addr_in_socket(sk, nxi->ipv4[i]))
22965 + /* check against any */
22970 +#endif /* CONFIG_INET */
22972 +void nx_set_persistent(struct nx_info *nxi)
22974 + vxdprintk(VXD_CBIT(nid, 6),
22975 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22977 + get_nx_info(nxi);
22978 + claim_nx_info(nxi, NULL);
22981 +void nx_clear_persistent(struct nx_info *nxi)
22983 + vxdprintk(VXD_CBIT(nid, 6),
22984 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22986 + release_nx_info(nxi, NULL);
22987 + put_nx_info(nxi);
22990 +void nx_update_persistent(struct nx_info *nxi)
22992 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22993 + nx_set_persistent(nxi);
22995 + nx_clear_persistent(nxi);
22998 +/* vserver syscall commands below here */
23000 +/* taks nid and nx_info functions */
23002 +#include <asm/uaccess.h>
23005 +int vc_task_nid(uint32_t id, void __user *data)
23010 + struct task_struct *tsk;
23012 + if (!nx_check(0, VS_ADMIN | VS_WATCH))
23015 + read_lock(&tasklist_lock);
23016 + tsk = find_task_by_real_pid(id);
23017 + nid = (tsk) ? tsk->nid : -ESRCH;
23018 + read_unlock(&tasklist_lock);
23020 + nid = nx_current_nid();
23025 +int vc_nx_info(struct nx_info *nxi, void __user *data)
23027 + struct vcmd_nx_info_v0 vc_data;
23029 + vc_data.nid = nxi->nx_id;
23031 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23037 +/* network functions */
23039 +int vc_net_create(uint32_t nid, void __user *data)
23041 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
23042 + struct nx_info *new_nxi;
23045 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23048 + if ((nid > MAX_S_CONTEXT) && (nid != NX_DYNAMIC_ID))
23053 + new_nxi = __create_nx_info(nid);
23054 + if (IS_ERR(new_nxi))
23055 + return PTR_ERR(new_nxi);
23057 + /* initial flags */
23058 + new_nxi->nx_flags = vc_data.flagword;
23061 + if (vs_net_change(new_nxi, VSC_NETUP))
23064 + ret = nx_migrate_task(current, new_nxi);
23068 + /* return context id on success */
23069 + ret = new_nxi->nx_id;
23071 + /* get a reference for persistent contexts */
23072 + if ((vc_data.flagword & NXF_PERSISTENT))
23073 + nx_set_persistent(new_nxi);
23075 + release_nx_info(new_nxi, NULL);
23076 + put_nx_info(new_nxi);
23081 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
23083 + return nx_migrate_task(current, nxi);
23086 +int vc_net_add(struct nx_info *nxi, void __user *data)
23088 + struct vcmd_net_addr_v0 vc_data;
23089 + int index, pos, ret = 0;
23091 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23094 + switch (vc_data.type) {
23095 + case NXA_TYPE_IPV4:
23096 + if ((vc_data.count < 1) || (vc_data.count > 4))
23104 + switch (vc_data.type) {
23105 + case NXA_TYPE_IPV4:
23107 + while ((index < vc_data.count) &&
23108 + ((pos = nxi->nbipv4) < NB_IPV4ROOT)) {
23109 + nxi->ipv4[pos] = vc_data.ip[index];
23110 + nxi->mask[pos] = vc_data.mask[index];
23117 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
23118 + nxi->v4_bcast = vc_data.ip[0];
23129 +int vc_net_remove(struct nx_info *nxi, void __user *data)
23131 + struct vcmd_net_addr_v0 vc_data;
23133 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23136 + switch (vc_data.type) {
23137 + case NXA_TYPE_ANY:
23147 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
23149 + struct vcmd_net_flags_v0 vc_data;
23151 + vc_data.flagword = nxi->nx_flags;
23153 + /* special STATE flag handling */
23154 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
23156 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23161 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
23163 + struct vcmd_net_flags_v0 vc_data;
23164 + uint64_t mask, trigger;
23166 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23169 + /* special STATE flag handling */
23170 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
23171 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
23173 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
23174 + vc_data.flagword, mask);
23175 + if (trigger & NXF_PERSISTENT)
23176 + nx_update_persistent(nxi);
23181 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
23183 + struct vcmd_net_caps_v0 vc_data;
23185 + vc_data.ncaps = nxi->nx_ncaps;
23186 + vc_data.cmask = ~0ULL;
23188 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23193 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
23195 + struct vcmd_net_caps_v0 vc_data;
23197 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23200 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
23201 + vc_data.ncaps, vc_data.cmask);
23206 +#include <linux/module.h>
23208 +EXPORT_SYMBOL_GPL(free_nx_info);
23209 +EXPORT_SYMBOL_GPL(unhash_nx_info);
23211 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/proc.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/proc.c
23212 --- linux-2.6.22.10/kernel/vserver/proc.c 1970-01-01 01:00:00 +0100
23213 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/proc.c 2007-06-15 19:20:10 +0200
23216 + * linux/kernel/vserver/proc.c
23218 + * Virtual Context Support
23220 + * Copyright (C) 2003-2007 Herbert Pötzl
23222 + * V0.01 basic structure
23223 + * V0.02 adaptation vs1.3.0
23224 + * V0.03 proc permissions
23225 + * V0.04 locking/generic
23226 + * V0.05 next generation procfs
23227 + * V0.06 inode validation
23228 + * V0.07 generic rewrite vid
23229 + * V0.08 remove inode type
23233 +#include <linux/errno.h>
23234 +#include <linux/proc_fs.h>
23235 +#include <linux/sched.h>
23236 +#include <linux/vs_context.h>
23237 +#include <linux/vs_network.h>
23238 +#include <linux/vs_cvirt.h>
23240 +#include <linux/vserver/switch.h>
23241 +#include <linux/vserver/global.h>
23243 +#include <asm/uaccess.h>
23244 +#include <asm/unistd.h>
23246 +#include "cvirt_proc.h"
23247 +#include "cacct_proc.h"
23248 +#include "limit_proc.h"
23249 +#include "sched_proc.h"
23250 +#include "vci_config.h"
23252 +static struct proc_dir_entry *proc_virtual;
23254 +static struct proc_dir_entry *proc_virtnet;
23257 +/* first the actual feeds */
23260 +static int proc_vci(char *buffer)
23262 + return sprintf(buffer,
23263 + "VCIVersion:\t%04x:%04x\n"
23264 + "VCISyscall:\t%d\n"
23265 + "VCIKernel:\t%08x\n",
23266 + VCI_VERSION >> 16,
23267 + VCI_VERSION & 0xFFFF,
23269 + vci_kernel_config());
23272 +static int proc_virtual_info(char *buffer)
23274 + return proc_vci(buffer);
23277 +static int proc_virtual_status(char *buffer)
23279 + return sprintf(buffer,
23281 + "#CActive:\t%d\n"
23282 + "#NSProxy:\t%d\t%d %d %d %d\n",
23283 + atomic_read(&vx_global_ctotal),
23284 + atomic_read(&vx_global_cactive),
23285 + atomic_read(&vs_global_nsproxy),
23286 + atomic_read(&vs_global_fs),
23287 + atomic_read(&vs_global_mnt_ns),
23288 + atomic_read(&vs_global_uts_ns),
23289 + atomic_read(&vs_global_ipc_ns));
23293 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23297 + length = sprintf(buffer,
23303 + vxi->vx_initpid);
23307 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23311 + length = sprintf(buffer,
23314 + "Flags:\t%016llx\n"
23315 + "BCaps:\t%016llx\n"
23316 + "CCaps:\t%016llx\n"
23317 + "Spaces:\t%08lx\n",
23318 + atomic_read(&vxi->vx_usecnt),
23319 + atomic_read(&vxi->vx_tasks),
23320 + (unsigned long long)vxi->vx_flags,
23321 + (unsigned long long)vxi->vx_bcaps,
23322 + (unsigned long long)vxi->vx_ccaps,
23327 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23329 + return vx_info_proc_limit(&vxi->limit, buffer);
23332 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23336 + length = vx_info_proc_sched(&vxi->sched, buffer);
23337 + for_each_online_cpu(cpu) {
23338 + length += vx_info_proc_sched_pc(
23339 + &vx_per_cpu(vxi, sched_pc, cpu),
23340 + buffer + length, cpu);
23345 +int proc_vxi_nsproxy(struct vx_info *vxi, char *buffer)
23347 + return vx_info_proc_nsproxy(vxi->vx_nsproxy, buffer);
23350 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23354 + vx_update_load(vxi);
23355 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23356 + for_each_online_cpu(cpu) {
23357 + length += vx_info_proc_cvirt_pc(
23358 + &vx_per_cpu(vxi, cvirt_pc, cpu),
23359 + buffer + length, cpu);
23364 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23366 + return vx_info_proc_cacct(&vxi->cacct, buffer);
23370 +static int proc_virtnet_info(char *buffer)
23372 + return proc_vci(buffer);
23375 +static int proc_virtnet_status(char *buffer)
23377 + return sprintf(buffer,
23379 + "#CActive:\t%d\n",
23380 + atomic_read(&nx_global_ctotal),
23381 + atomic_read(&nx_global_cactive));
23384 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23388 + length = sprintf(buffer,
23393 + for (i = 0; i < nxi->nbipv4; i++) {
23394 + length += sprintf(buffer + length,
23395 + "%d:\t" NIPQUAD_FMT "/" NIPQUAD_FMT "\n", i,
23396 + NIPQUAD(nxi->ipv4[i]), NIPQUAD(nxi->mask[i]));
23401 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23405 + length = sprintf(buffer,
23408 + "Flags:\t%016llx\n"
23409 + "NCaps:\t%016llx\n",
23410 + atomic_read(&nxi->nx_usecnt),
23411 + atomic_read(&nxi->nx_tasks),
23412 + (unsigned long long)nxi->nx_flags,
23413 + (unsigned long long)nxi->nx_ncaps);
23419 +/* here the inode helpers */
23425 + struct inode_operations *iop;
23426 + struct file_operations *fop;
23427 + union proc_op op;
23430 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23432 + struct inode *inode = new_inode(sb);
23437 + inode->i_mode = p->mode;
23439 + inode->i_op = p->iop;
23441 + inode->i_fop = p->fop;
23443 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23444 + inode->i_flags |= S_IMMUTABLE;
23446 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23448 + inode->i_uid = 0;
23449 + inode->i_gid = 0;
23450 + inode->i_tag = 0;
23455 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23456 + struct dentry *dentry, int id, void *ptr)
23458 + struct vs_entry *p = ptr;
23459 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23460 + struct dentry *error = ERR_PTR(-EINVAL);
23465 + PROC_I(inode)->op = p->op;
23466 + PROC_I(inode)->fd = id;
23467 + d_add(dentry, inode);
23475 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23478 + * Fill a directory entry.
23480 + * If possible create the dcache entry and derive our inode number and
23481 + * file type from dcache entry.
23483 + * Since all of the proc inode numbers are dynamically generated, the inode
23484 + * numbers do not exist until the inode is cache. This means creating the
23485 + * the dcache entry in readdir is necessary to keep the inode numbers
23486 + * reported by readdir in sync with the inode numbers reported
23489 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23490 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
23492 + struct dentry *child, *dir = filp->f_dentry;
23493 + struct inode *inode;
23494 + struct qstr qname;
23496 + unsigned type = DT_UNKNOWN;
23498 + qname.name = name;
23500 + qname.hash = full_name_hash(name, len);
23502 + child = d_lookup(dir, &qname);
23504 + struct dentry *new;
23505 + new = d_alloc(dir, &qname);
23507 + child = instantiate(dir->d_inode, new, id, ptr);
23514 + if (!child || IS_ERR(child) || !child->d_inode)
23515 + goto end_instantiate;
23516 + inode = child->d_inode;
23518 + ino = inode->i_ino;
23519 + type = inode->i_mode >> 12;
23524 + ino = find_inode_number(dir, &qname);
23527 + return filldir(dirent, name, len, filp->f_pos, ino, type);
23532 +/* get and revalidate vx_info/xid */
23535 +struct vx_info *get_proc_vx_info(struct inode *inode)
23537 + return lookup_vx_info(PROC_I(inode)->fd);
23540 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23542 + struct inode *inode = dentry->d_inode;
23543 + xid_t xid = PROC_I(inode)->fd;
23545 + if (!xid || xid_is_hashed(xid))
23552 +/* get and revalidate nx_info/nid */
23554 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23556 + struct inode *inode = dentry->d_inode;
23557 + nid_t nid = PROC_I(inode)->fd;
23559 + if (!nid || nid_is_hashed(nid))
23567 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23569 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23570 + size_t count, loff_t *ppos)
23572 + struct inode *inode = file->f_dentry->d_inode;
23573 + unsigned long page;
23574 + ssize_t length = 0;
23576 + if (count > PROC_BLOCK_SIZE)
23577 + count = PROC_BLOCK_SIZE;
23579 + /* fade that out as soon as stable */
23580 + WARN_ON(PROC_I(inode)->fd);
23582 + if (!(page = __get_free_page(GFP_KERNEL)))
23585 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23586 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
23589 + length = simple_read_from_buffer(buf, count, ppos,
23590 + (char *)page, length);
23596 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23597 + size_t count, loff_t *ppos)
23599 + struct inode *inode = file->f_dentry->d_inode;
23600 + struct vx_info *vxi = NULL;
23601 + xid_t xid = PROC_I(inode)->fd;
23602 + unsigned long page;
23603 + ssize_t length = 0;
23605 + if (count > PROC_BLOCK_SIZE)
23606 + count = PROC_BLOCK_SIZE;
23608 + /* fade that out as soon as stable */
23610 + vxi = lookup_vx_info(xid);
23614 + length = -ENOMEM;
23615 + if (!(page = __get_free_page(GFP_KERNEL)))
23618 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23619 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23622 + length = simple_read_from_buffer(buf, count, ppos,
23623 + (char *)page, length);
23627 + put_vx_info(vxi);
23632 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23633 + size_t count, loff_t *ppos)
23635 + struct inode *inode = file->f_dentry->d_inode;
23636 + struct nx_info *nxi = NULL;
23637 + nid_t nid = PROC_I(inode)->fd;
23638 + unsigned long page;
23639 + ssize_t length = 0;
23641 + if (count > PROC_BLOCK_SIZE)
23642 + count = PROC_BLOCK_SIZE;
23644 + /* fade that out as soon as stable */
23646 + nxi = lookup_nx_info(nid);
23650 + length = -ENOMEM;
23651 + if (!(page = __get_free_page(GFP_KERNEL)))
23654 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23655 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23658 + length = simple_read_from_buffer(buf, count, ppos,
23659 + (char *)page, length);
23663 + put_nx_info(nxi);
23670 +/* here comes the lower level */
23673 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
23674 + .len = sizeof(NAME) - 1, \
23675 + .name = (NAME), \
23683 +#define DIR(NAME, MODE, OTYPE) \
23684 + NOD(NAME, (S_IFDIR | (MODE)), \
23685 + &proc_ ## OTYPE ## _inode_operations, \
23686 + &proc_ ## OTYPE ## _file_operations, { } )
23688 +#define INF(NAME, MODE, OTYPE) \
23689 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23690 + &proc_vs_info_file_operations, \
23691 + { .proc_vs_read = &proc_##OTYPE } )
23693 +#define VINF(NAME, MODE, OTYPE) \
23694 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23695 + &proc_vx_info_file_operations, \
23696 + { .proc_vxi_read = &proc_##OTYPE } )
23698 +#define NINF(NAME, MODE, OTYPE) \
23699 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23700 + &proc_nx_info_file_operations, \
23701 + { .proc_nxi_read = &proc_##OTYPE } )
23704 +static struct file_operations proc_vs_info_file_operations = {
23705 + .read = proc_vs_info_read,
23708 +static struct file_operations proc_vx_info_file_operations = {
23709 + .read = proc_vx_info_read,
23712 +static struct dentry_operations proc_xid_dentry_operations = {
23713 + .d_revalidate = proc_xid_revalidate,
23716 +static struct vs_entry vx_base_stuff[] = {
23717 + VINF("info", S_IRUGO, vxi_info),
23718 + VINF("status", S_IRUGO, vxi_status),
23719 + VINF("limit", S_IRUGO, vxi_limit),
23720 + VINF("sched", S_IRUGO, vxi_sched),
23721 + VINF("nsproxy", S_IRUGO, vxi_nsproxy),
23722 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23723 + VINF("cacct", S_IRUGO, vxi_cacct),
23730 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23731 + struct dentry *dentry, int id, void *ptr)
23733 + dentry->d_op = &proc_xid_dentry_operations;
23734 + return vs_proc_instantiate(dir, dentry, id, ptr);
23737 +static struct dentry *proc_xid_lookup(struct inode *dir,
23738 + struct dentry *dentry, struct nameidata *nd)
23740 + struct vs_entry *p = vx_base_stuff;
23741 + struct dentry *error = ERR_PTR(-ENOENT);
23743 + for (; p->name; p++) {
23744 + if (p->len != dentry->d_name.len)
23746 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23752 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23757 +static int proc_xid_readdir(struct file *filp,
23758 + void *dirent, filldir_t filldir)
23760 + struct dentry *dentry = filp->f_dentry;
23761 + struct inode *inode = dentry->d_inode;
23762 + struct vs_entry *p = vx_base_stuff;
23763 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23767 + pos = filp->f_pos;
23770 + ino = inode->i_ino;
23771 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23774 + /* fall through */
23776 + ino = parent_ino(dentry);
23777 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23780 + /* fall through */
23783 + if (index >= size)
23785 + for (p += index; p->name; p++) {
23786 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23787 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23793 + filp->f_pos = pos;
23799 +static struct file_operations proc_nx_info_file_operations = {
23800 + .read = proc_nx_info_read,
23803 +static struct dentry_operations proc_nid_dentry_operations = {
23804 + .d_revalidate = proc_nid_revalidate,
23807 +static struct vs_entry nx_base_stuff[] = {
23808 + NINF("info", S_IRUGO, nxi_info),
23809 + NINF("status", S_IRUGO, nxi_status),
23814 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23815 + struct dentry *dentry, int id, void *ptr)
23817 + dentry->d_op = &proc_nid_dentry_operations;
23818 + return vs_proc_instantiate(dir, dentry, id, ptr);
23821 +static struct dentry *proc_nid_lookup(struct inode *dir,
23822 + struct dentry *dentry, struct nameidata *nd)
23824 + struct vs_entry *p = nx_base_stuff;
23825 + struct dentry *error = ERR_PTR(-ENOENT);
23827 + for (; p->name; p++) {
23828 + if (p->len != dentry->d_name.len)
23830 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23836 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23841 +static int proc_nid_readdir(struct file *filp,
23842 + void *dirent, filldir_t filldir)
23844 + struct dentry *dentry = filp->f_dentry;
23845 + struct inode *inode = dentry->d_inode;
23846 + struct vs_entry *p = nx_base_stuff;
23847 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23851 + pos = filp->f_pos;
23854 + ino = inode->i_ino;
23855 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23858 + /* fall through */
23860 + ino = parent_ino(dentry);
23861 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23864 + /* fall through */
23867 + if (index >= size)
23869 + for (p += index; p->name; p++) {
23870 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23871 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23877 + filp->f_pos = pos;
23882 +#define MAX_MULBY10 ((~0U - 9) / 10)
23884 +static inline int atovid(const char *str, int len)
23889 + while (len-- > 0) {
23894 + if (vid >= MAX_MULBY10)
23904 +/* now the upper level (virtual) */
23907 +static struct file_operations proc_xid_file_operations = {
23908 + .read = generic_read_dir,
23909 + .readdir = proc_xid_readdir,
23912 +static struct inode_operations proc_xid_inode_operations = {
23913 + .lookup = proc_xid_lookup,
23916 +static struct vs_entry vx_virtual_stuff[] = {
23917 + INF("info", S_IRUGO, virtual_info),
23918 + INF("status", S_IRUGO, virtual_status),
23919 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23923 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23924 + struct dentry *dentry, struct nameidata *nd)
23926 + struct vs_entry *p = vx_virtual_stuff;
23927 + struct dentry *error = ERR_PTR(-ENOENT);
23930 + for (; p->name; p++) {
23931 + if (p->len != dentry->d_name.len)
23933 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23937 + goto instantiate;
23939 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23940 + if ((id < 0) || !xid_is_hashed(id))
23944 + error = proc_xid_instantiate(dir, dentry, id, p);
23949 +static struct file_operations proc_nid_file_operations = {
23950 + .read = generic_read_dir,
23951 + .readdir = proc_nid_readdir,
23954 +static struct inode_operations proc_nid_inode_operations = {
23955 + .lookup = proc_nid_lookup,
23958 +static struct vs_entry nx_virtnet_stuff[] = {
23959 + INF("info", S_IRUGO, virtnet_info),
23960 + INF("status", S_IRUGO, virtnet_status),
23961 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
23965 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
23966 + struct dentry *dentry, struct nameidata *nd)
23968 + struct vs_entry *p = nx_virtnet_stuff;
23969 + struct dentry *error = ERR_PTR(-ENOENT);
23972 + for (; p->name; p++) {
23973 + if (p->len != dentry->d_name.len)
23975 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23979 + goto instantiate;
23981 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23982 + if ((id < 0) || !nid_is_hashed(id))
23986 + error = proc_nid_instantiate(dir, dentry, id, p);
23993 +#define PROC_NUMBUF 10
23994 +#define PROC_MAXVIDS 32
23996 +int proc_virtual_readdir(struct file *filp,
23997 + void *dirent, filldir_t filldir)
23999 + struct dentry *dentry = filp->f_dentry;
24000 + struct inode *inode = dentry->d_inode;
24001 + struct vs_entry *p = vx_virtual_stuff;
24002 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
24004 + unsigned int xid_array[PROC_MAXVIDS];
24005 + char buf[PROC_NUMBUF];
24006 + unsigned int nr_xids, i;
24009 + pos = filp->f_pos;
24012 + ino = inode->i_ino;
24013 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24016 + /* fall through */
24018 + ino = parent_ino(dentry);
24019 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24022 + /* fall through */
24025 + if (index >= size)
24027 + for (p += index; p->name; p++) {
24028 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24029 + vs_proc_instantiate, 0, p))
24034 + index = pos - size;
24035 + p = &vx_virtual_stuff[size - 1];
24036 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
24037 + for (i = 0; i < nr_xids; i++) {
24038 + int n, xid = xid_array[i];
24039 + unsigned int j = PROC_NUMBUF;
24043 + buf[--j] = '0' + (n % 10);
24046 + if (proc_fill_cache(filp, dirent, filldir,
24047 + buf + j, PROC_NUMBUF - j,
24048 + vs_proc_instantiate, xid, p))
24054 + filp->f_pos = pos;
24058 +static int proc_virtual_getattr(struct vfsmount *mnt,
24059 + struct dentry *dentry, struct kstat *stat)
24061 + struct inode *inode = dentry->d_inode;
24063 + generic_fillattr(inode, stat);
24064 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
24068 +static struct file_operations proc_virtual_dir_operations = {
24069 + .read = generic_read_dir,
24070 + .readdir = proc_virtual_readdir,
24073 +static struct inode_operations proc_virtual_dir_inode_operations = {
24074 + .getattr = proc_virtual_getattr,
24075 + .lookup = proc_virtual_lookup,
24082 +int proc_virtnet_readdir(struct file *filp,
24083 + void *dirent, filldir_t filldir)
24085 + struct dentry *dentry = filp->f_dentry;
24086 + struct inode *inode = dentry->d_inode;
24087 + struct vs_entry *p = nx_virtnet_stuff;
24088 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
24090 + unsigned int nid_array[PROC_MAXVIDS];
24091 + char buf[PROC_NUMBUF];
24092 + unsigned int nr_nids, i;
24095 + pos = filp->f_pos;
24098 + ino = inode->i_ino;
24099 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24102 + /* fall through */
24104 + ino = parent_ino(dentry);
24105 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24108 + /* fall through */
24111 + if (index >= size)
24113 + for (p += index; p->name; p++) {
24114 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24115 + vs_proc_instantiate, 0, p))
24120 + index = pos - size;
24121 + p = &nx_virtnet_stuff[size - 1];
24122 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
24123 + for (i = 0; i < nr_nids; i++) {
24124 + int n, nid = nid_array[i];
24125 + unsigned int j = PROC_NUMBUF;
24129 + buf[--j] = '0' + (n % 10);
24132 + if (proc_fill_cache(filp, dirent, filldir,
24133 + buf + j, PROC_NUMBUF - j,
24134 + vs_proc_instantiate, nid, p))
24140 + filp->f_pos = pos;
24144 +static int proc_virtnet_getattr(struct vfsmount *mnt,
24145 + struct dentry *dentry, struct kstat *stat)
24147 + struct inode *inode = dentry->d_inode;
24149 + generic_fillattr(inode, stat);
24150 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
24154 +static struct file_operations proc_virtnet_dir_operations = {
24155 + .read = generic_read_dir,
24156 + .readdir = proc_virtnet_readdir,
24159 +static struct inode_operations proc_virtnet_dir_inode_operations = {
24160 + .getattr = proc_virtnet_getattr,
24161 + .lookup = proc_virtnet_lookup,
24166 +void proc_vx_init(void)
24168 + struct proc_dir_entry *ent;
24170 + ent = proc_mkdir("virtual", 0);
24172 + ent->proc_fops = &proc_virtual_dir_operations;
24173 + ent->proc_iops = &proc_virtual_dir_inode_operations;
24175 + proc_virtual = ent;
24177 + ent = proc_mkdir("virtnet", 0);
24179 + ent->proc_fops = &proc_virtnet_dir_operations;
24180 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
24182 + proc_virtnet = ent;
24188 +/* per pid info */
24191 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
24193 + struct vx_info *vxi;
24194 + char *orig = buffer;
24196 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
24198 + vxi = task_get_vx_info(p);
24202 + buffer += sprintf(buffer, "BCaps:\t%016llx\n",
24203 + (unsigned long long)vxi->vx_bcaps);
24204 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
24205 + (unsigned long long)vxi->vx_ccaps);
24206 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
24207 + (unsigned long long)vxi->vx_flags);
24208 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
24210 + put_vx_info(vxi);
24212 + return buffer - orig;
24216 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
24218 + struct nx_info *nxi;
24219 + char *orig = buffer;
24222 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24224 + nxi = task_get_nx_info(p);
24228 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24229 + (unsigned long long)nxi->nx_ncaps);
24230 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24231 + (unsigned long long)nxi->nx_flags);
24233 + for (i = 0; i < nxi->nbipv4; i++){
24234 + buffer += sprintf(buffer,
24235 + "V4Root[%d]:\t" NIPQUAD_FMT "/" NIPQUAD_FMT "\n", i,
24236 + NIPQUAD(nxi->ipv4[i]),
24237 + NIPQUAD(nxi->mask[i]));
24239 + buffer += sprintf(buffer,
24240 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24241 + NIPQUAD(nxi->v4_bcast));
24243 + put_nx_info(nxi);
24245 + return buffer - orig;
24248 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/sched.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/sched.c
24249 --- linux-2.6.22.10/kernel/vserver/sched.c 1970-01-01 01:00:00 +0100
24250 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/sched.c 2007-06-15 02:37:04 +0200
24253 + * linux/kernel/vserver/sched.c
24255 + * Virtual Server: Scheduler Support
24257 + * Copyright (C) 2004-2007 Herbert Pötzl
24259 + * V0.01 adapted Sam Vilains version to 2.6.3
24260 + * V0.02 removed legacy interface
24261 + * V0.03 changed vcmds to vxi arg
24265 +#include <linux/sched.h>
24266 +#include <linux/vs_context.h>
24267 +#include <linux/vs_sched.h>
24268 +#include <linux/vserver/sched_cmd.h>
24270 +#include <asm/errno.h>
24271 +#include <asm/uaccess.h>
24273 +#define vxd_check_range(val, min, max) do { \
24274 + vxlprintk((val < min) || (val > max), \
24275 + "check_range(%ld,%ld,%ld)", \
24276 + (long)val, (long)min, (long)max, \
24277 + __FILE__, __LINE__); \
24281 +void vx_update_sched_param(struct _vx_sched *sched,
24282 + struct _vx_sched_pc *sched_pc)
24284 + unsigned int set_mask = sched->update_mask;
24286 + if (set_mask & VXSM_FILL_RATE)
24287 + sched_pc->fill_rate[0] = sched->fill_rate[0];
24288 + if (set_mask & VXSM_INTERVAL)
24289 + sched_pc->interval[0] = sched->interval[0];
24290 + if (set_mask & VXSM_FILL_RATE2)
24291 + sched_pc->fill_rate[1] = sched->fill_rate[1];
24292 + if (set_mask & VXSM_INTERVAL2)
24293 + sched_pc->interval[1] = sched->interval[1];
24294 + if (set_mask & VXSM_TOKENS)
24295 + sched_pc->tokens = sched->tokens;
24296 + if (set_mask & VXSM_TOKENS_MIN)
24297 + sched_pc->tokens_min = sched->tokens_min;
24298 + if (set_mask & VXSM_TOKENS_MAX)
24299 + sched_pc->tokens_max = sched->tokens_max;
24300 + if (set_mask & VXSM_PRIO_BIAS)
24301 + sched_pc->prio_bias = sched->prio_bias;
24303 + if (set_mask & VXSM_IDLE_TIME)
24304 + sched_pc->flags |= VXSF_IDLE_TIME;
24306 + sched_pc->flags &= ~VXSF_IDLE_TIME;
24309 + sched_pc->norm_time = jiffies;
24314 + * recalculate the context's scheduling tokens
24316 + * ret > 0 : number of tokens available
24317 + * ret < 0 : on hold, check delta_min[]
24318 + * -1 only jiffies
24319 + * -2 also idle time
24322 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
24323 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
24327 + int flags = sched_pc->flags;
24329 + /* how much time did pass? */
24330 + delta = *norm_time - sched_pc->norm_time;
24331 + vxd_check_range(delta, 0, INT_MAX);
24333 + if (delta >= sched_pc->interval[0]) {
24334 + long tokens, integral;
24336 + /* calc integral token part */
24337 + tokens = delta / sched_pc->interval[0];
24338 + integral = tokens * sched_pc->interval[0];
24339 + tokens *= sched_pc->fill_rate[0];
24340 +#ifdef CONFIG_VSERVER_HARDCPU
24341 + delta_min[0] = delta - integral;
24342 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
24344 + /* advance time */
24345 + sched_pc->norm_time += delta;
24348 + sched_pc->tokens += tokens;
24349 + sched_pc->token_time += tokens;
24351 + delta_min[0] = delta;
24353 +#ifdef CONFIG_VSERVER_IDLETIME
24354 + if (!(flags & VXSF_IDLE_TIME))
24357 + /* how much was the idle skip? */
24358 + delta = *idle_time - sched_pc->idle_time;
24359 + vxd_check_range(delta, 0, INT_MAX);
24361 + if (delta >= sched_pc->interval[1]) {
24362 + long tokens, integral;
24364 + /* calc fair share token part */
24365 + tokens = delta / sched_pc->interval[1];
24366 + integral = tokens * sched_pc->interval[1];
24367 + tokens *= sched_pc->fill_rate[1];
24368 + delta_min[1] = delta - integral;
24369 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
24371 + /* advance idle time */
24372 + sched_pc->idle_time += integral;
24375 + sched_pc->tokens += tokens;
24376 + sched_pc->token_time += tokens;
24378 + delta_min[1] = delta;
24382 + /* clip at maximum */
24383 + if (sched_pc->tokens > sched_pc->tokens_max)
24384 + sched_pc->tokens = sched_pc->tokens_max;
24385 + tokens = sched_pc->tokens;
24387 + if ((flags & VXSF_ONHOLD)) {
24388 + /* can we unhold? */
24389 + if (tokens >= sched_pc->tokens_min) {
24390 + flags &= ~VXSF_ONHOLD;
24391 + sched_pc->hold_ticks +=
24392 + *norm_time - sched_pc->onhold;
24396 + /* put on hold? */
24397 + if (tokens <= 0) {
24398 + flags |= VXSF_ONHOLD;
24399 + sched_pc->onhold = *norm_time;
24403 + sched_pc->flags = flags;
24407 + tokens = sched_pc->tokens_min - tokens;
24408 + sched_pc->flags = flags;
24409 + BUG_ON(tokens < 0);
24411 +#ifdef CONFIG_VSERVER_HARDCPU
24412 + /* next interval? */
24413 + if (!sched_pc->fill_rate[0])
24414 + delta_min[0] = HZ;
24415 + else if (tokens > sched_pc->fill_rate[0])
24416 + delta_min[0] += sched_pc->interval[0] *
24417 + tokens / sched_pc->fill_rate[0];
24419 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
24420 + vxd_check_range(delta_min[0], 0, INT_MAX);
24422 +#ifdef CONFIG_VSERVER_IDLETIME
24423 + if (!(flags & VXSF_IDLE_TIME))
24426 + /* next interval? */
24427 + if (!sched_pc->fill_rate[1])
24428 + delta_min[1] = HZ;
24429 + else if (tokens > sched_pc->fill_rate[1])
24430 + delta_min[1] += sched_pc->interval[1] *
24431 + tokens / sched_pc->fill_rate[1];
24433 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
24434 + vxd_check_range(delta_min[1], 0, INT_MAX);
24439 +#endif /* CONFIG_VSERVER_IDLETIME */
24442 +#endif /* CONFIG_VSERVER_HARDCPU */
24445 +static inline unsigned long msec_to_ticks(unsigned long msec)
24447 + return msecs_to_jiffies(msec);
24450 +static inline unsigned long ticks_to_msec(unsigned long ticks)
24452 + return jiffies_to_msecs(ticks);
24455 +static inline unsigned long ticks_to_usec(unsigned long ticks)
24457 + return jiffies_to_usecs(ticks);
24461 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
24463 + unsigned int set_mask = data->mask;
24464 + unsigned int update_mask;
24467 + /* Sanity check data values */
24468 + if (data->tokens_max <= 0)
24469 + data->tokens_max = HZ;
24470 + if (data->tokens_min < 0)
24471 + data->tokens_min = HZ / 3;
24472 + if (data->tokens_min >= data->tokens_max)
24473 + data->tokens_min = data->tokens_max;
24475 + if (data->prio_bias > MAX_PRIO_BIAS)
24476 + data->prio_bias = MAX_PRIO_BIAS;
24477 + if (data->prio_bias < MIN_PRIO_BIAS)
24478 + data->prio_bias = MIN_PRIO_BIAS;
24480 + spin_lock(&vxi->sched.tokens_lock);
24482 + /* sync up on delayed updates */
24483 + for_each_cpu_mask(cpu, vxi->sched.update)
24484 + vx_update_sched_param(&vxi->sched,
24485 + &vx_per_cpu(vxi, sched_pc, cpu));
24487 + if (set_mask & VXSM_FILL_RATE)
24488 + vxi->sched.fill_rate[0] = data->fill_rate[0];
24489 + if (set_mask & VXSM_FILL_RATE2)
24490 + vxi->sched.fill_rate[1] = data->fill_rate[1];
24491 + if (set_mask & VXSM_INTERVAL)
24492 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
24493 + msec_to_ticks(data->interval[0]) : data->interval[0];
24494 + if (set_mask & VXSM_INTERVAL2)
24495 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
24496 + msec_to_ticks(data->interval[1]) : data->interval[1];
24497 + if (set_mask & VXSM_TOKENS)
24498 + vxi->sched.tokens = data->tokens;
24499 + if (set_mask & VXSM_TOKENS_MIN)
24500 + vxi->sched.tokens_min = data->tokens_min;
24501 + if (set_mask & VXSM_TOKENS_MAX)
24502 + vxi->sched.tokens_max = data->tokens_max;
24503 + if (set_mask & VXSM_PRIO_BIAS)
24504 + vxi->sched.prio_bias = data->prio_bias;
24506 + /* Sanity check rate/interval */
24507 + for (i = 0; i < 2; i++) {
24508 + if (data->fill_rate[i] < 0)
24509 + data->fill_rate[i] = 0;
24510 + if (data->interval[i] <= 0)
24511 + data->interval[i] = HZ;
24514 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
24515 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
24516 + vxi->sched.update_mask = update_mask;
24519 + if (set_mask & VXSM_CPU_ID) {
24520 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24521 + cpus_and(vxi->sched.update, cpu_online_map,
24522 + vxi->sched.update);
24524 + vxi->sched.update = cpu_online_map;
24526 + /* forced reload? */
24527 + if (set_mask & VXSM_FORCE) {
24528 + for_each_cpu_mask(cpu, vxi->sched.update)
24529 + vx_update_sched_param(&vxi->sched,
24530 + &vx_per_cpu(vxi, sched_pc, cpu));
24531 + vxi->sched.update = CPU_MASK_NONE;
24534 + /* on UP we update immediately */
24535 + vx_update_sched_param(&vxi->sched,
24536 + &vx_per_cpu(vxi, sched_pc, 0));
24539 + spin_unlock(&vxi->sched.tokens_lock);
24543 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
24544 +#define COPY_PRI(C) C(prio_bias)
24545 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24546 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24547 + C(fill_rate[1]); C(interval[1]);
24549 +#define COPY_VALUE(name) vc_data.name = data->name
24551 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
24553 + struct vcmd_sched_v5 vc_data;
24555 + vc_data.mask = data->set_mask;
24556 + COPY_IDS(COPY_VALUE);
24557 + COPY_PRI(COPY_VALUE);
24558 + COPY_TOK(COPY_VALUE);
24559 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
24560 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
24561 + return do_set_sched(vxi, &vc_data);
24564 +#ifdef CONFIG_VSERVER_LEGACY
24566 +#define COPY_MASK_V2(name, mask) \
24567 + if (vc_data.name != SCHED_KEEP) { \
24568 + vc_data_v4.name = vc_data.name; \
24569 + vc_data_v4.set_mask |= mask; \
24572 +int vc_set_sched_v2(struct vx_info *vxi, void __user *data)
24574 + struct vcmd_set_sched_v2 vc_data;
24575 + struct vcmd_set_sched_v4 vc_data_v4 = { .set_mask = 0 };
24577 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24580 + COPY_MASK_V2(fill_rate, VXSM_FILL_RATE);
24581 + COPY_MASK_V2(interval, VXSM_INTERVAL);
24582 + COPY_MASK_V2(tokens, VXSM_TOKENS);
24583 + COPY_MASK_V2(tokens_min, VXSM_TOKENS_MIN);
24584 + COPY_MASK_V2(tokens_max, VXSM_TOKENS_MAX);
24585 + vc_data_v4.bucket_id = 0;
24587 + do_set_sched_v4(vxi, &vc_data_v4);
24592 +int vc_set_sched_v3(struct vx_info *vxi, void __user *data)
24594 + struct vcmd_set_sched_v3 vc_data;
24595 + struct vcmd_set_sched_v4 vc_data_v4;
24597 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24600 + /* structures are binary compatible */
24601 + memcpy(&vc_data_v4, &vc_data, sizeof(vc_data));
24602 + vc_data_v4.set_mask &= VXSM_V3_MASK;
24603 + vc_data_v4.bucket_id = 0;
24605 + return do_set_sched_v4(vxi, &vc_data_v4);
24608 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
24610 + struct vcmd_set_sched_v4 vc_data;
24612 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24615 + return do_set_sched_v4(vxi, &vc_data);
24618 + /* latest interface is v5 */
24620 +int vc_set_sched(struct vx_info *vxi, void __user *data)
24622 + struct vcmd_sched_v5 vc_data;
24624 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24627 + return do_set_sched(vxi, &vc_data);
24631 +int vc_get_sched(struct vx_info *vxi, void __user *data)
24633 + struct vcmd_sched_v5 vc_data;
24635 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24638 + if (vc_data.mask & VXSM_CPU_ID) {
24639 + int cpu = vc_data.cpu_id;
24640 + struct _vx_sched_pc *data;
24642 + if (!cpu_possible(cpu))
24645 + data = &vx_per_cpu(vxi, sched_pc, cpu);
24646 + COPY_TOK(COPY_VALUE);
24647 + COPY_PRI(COPY_VALUE);
24648 + COPY_FRI(COPY_VALUE);
24650 + if (data->flags & VXSF_IDLE_TIME)
24651 + vc_data.mask |= VXSM_IDLE_TIME;
24653 + struct _vx_sched *data = &vxi->sched;
24655 + COPY_TOK(COPY_VALUE);
24656 + COPY_PRI(COPY_VALUE);
24657 + COPY_FRI(COPY_VALUE);
24660 + if (vc_data.mask & VXSM_MSEC) {
24661 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
24662 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
24665 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24671 +int vc_sched_info(struct vx_info *vxi, void __user *data)
24673 + struct vcmd_sched_info vc_data;
24676 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24679 + cpu = vc_data.cpu_id;
24680 + if (!cpu_possible(cpu))
24684 + struct _vx_sched_pc *sched_pc =
24685 + &vx_per_cpu(vxi, sched_pc, cpu);
24687 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
24688 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
24689 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
24690 + vc_data.vavavoom = sched_pc->vavavoom;
24692 + vc_data.token_usec = ticks_to_usec(1);
24694 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24699 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/sched_init.h linux-2.6.22.10-vs2.2.0.5/kernel/vserver/sched_init.h
24700 --- linux-2.6.22.10/kernel/vserver/sched_init.h 1970-01-01 01:00:00 +0100
24701 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/sched_init.h 2007-06-15 02:37:04 +0200
24704 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24706 + static struct lock_class_key tokens_lock_key;
24708 + /* scheduling; hard code starting values as constants */
24709 + sched->fill_rate[0] = 1;
24710 + sched->interval[0] = 4;
24711 + sched->fill_rate[1] = 1;
24712 + sched->interval[1] = 8;
24713 + sched->tokens = HZ >> 2;
24714 + sched->tokens_min = HZ >> 4;
24715 + sched->tokens_max = HZ >> 1;
24716 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
24717 + sched->prio_bias = 0;
24719 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24723 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24725 + sched_pc->fill_rate[0] = 1;
24726 + sched_pc->interval[0] = 4;
24727 + sched_pc->fill_rate[1] = 1;
24728 + sched_pc->interval[1] = 8;
24729 + sched_pc->tokens = HZ >> 2;
24730 + sched_pc->tokens_min = HZ >> 4;
24731 + sched_pc->tokens_max = HZ >> 1;
24732 + sched_pc->prio_bias = 0;
24733 + sched_pc->vavavoom = 0;
24734 + sched_pc->token_time = 0;
24735 + sched_pc->idle_time = 0;
24736 + sched_pc->norm_time = jiffies;
24738 + sched_pc->user_ticks = 0;
24739 + sched_pc->sys_ticks = 0;
24740 + sched_pc->hold_ticks = 0;
24743 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24749 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24753 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/sched_proc.h linux-2.6.22.10-vs2.2.0.5/kernel/vserver/sched_proc.h
24754 --- linux-2.6.22.10/kernel/vserver/sched_proc.h 1970-01-01 01:00:00 +0100
24755 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/sched_proc.h 2007-06-15 02:37:04 +0200
24757 +#ifndef _VX_SCHED_PROC_H
24758 +#define _VX_SCHED_PROC_H
24762 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24766 + length += sprintf(buffer,
24767 + "FillRate:\t%8d,%d\n"
24768 + "Interval:\t%8d,%d\n"
24769 + "TokensMin:\t%8d\n"
24770 + "TokensMax:\t%8d\n"
24771 + "PrioBias:\t%8d\n",
24772 + sched->fill_rate[0],
24773 + sched->fill_rate[1],
24774 + sched->interval[0],
24775 + sched->interval[1],
24776 + sched->tokens_min,
24777 + sched->tokens_max,
24778 + sched->prio_bias);
24783 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24784 + char *buffer, int cpu)
24788 + length += sprintf(buffer + length,
24789 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
24790 + (unsigned long long)sched_pc->user_ticks,
24791 + (unsigned long long)sched_pc->sys_ticks,
24792 + (unsigned long long)sched_pc->hold_ticks,
24793 + sched_pc->token_time,
24794 + sched_pc->idle_time);
24795 + length += sprintf(buffer + length,
24796 + " %c%c %d %d %d %d/%d %d/%d",
24797 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24798 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24799 + sched_pc->tokens,
24800 + sched_pc->tokens_min,
24801 + sched_pc->tokens_max,
24802 + sched_pc->fill_rate[0],
24803 + sched_pc->interval[0],
24804 + sched_pc->fill_rate[1],
24805 + sched_pc->interval[1]);
24806 + length += sprintf(buffer + length,
24808 + sched_pc->prio_bias,
24809 + sched_pc->vavavoom);
24813 +#endif /* _VX_SCHED_PROC_H */
24814 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/signal.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/signal.c
24815 --- linux-2.6.22.10/kernel/vserver/signal.c 1970-01-01 01:00:00 +0100
24816 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/signal.c 2007-06-15 02:37:04 +0200
24819 + * linux/kernel/vserver/signal.c
24821 + * Virtual Server: Signal Support
24823 + * Copyright (C) 2003-2007 Herbert Pötzl
24825 + * V0.01 broken out from vcontext V0.05
24826 + * V0.02 changed vcmds to vxi arg
24827 + * V0.03 adjusted siginfo for kill
24831 +#include <linux/sched.h>
24833 +#include <asm/errno.h>
24834 +#include <asm/uaccess.h>
24836 +#include <linux/vs_context.h>
24837 +#include <linux/vserver/signal_cmd.h>
24840 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24842 + int retval, count = 0;
24843 + struct task_struct *p;
24844 + struct siginfo *sip = SEND_SIG_PRIV;
24847 + vxdprintk(VXD_CBIT(misc, 4),
24848 + "vx_info_kill(%p[#%d],%d,%d)*",
24849 + vxi, vxi->vx_id, pid, sig);
24850 + read_lock(&tasklist_lock);
24854 + for_each_process(p) {
24857 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24858 + (pid && vxi->vx_initpid == p->pid))
24861 + err = group_send_sig_info(sig, sip, p);
24863 + if (err != -EPERM)
24869 + if (vxi->vx_initpid) {
24870 + pid = vxi->vx_initpid;
24871 + /* for now, only SIGINT to private init ... */
24872 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24873 + /* ... as long as there are tasks left */
24874 + (atomic_read(&vxi->vx_tasks) > 1))
24877 + /* fallthrough */
24879 + p = find_task_by_real_pid(pid);
24881 + if (vx_task_xid(p) == vxi->vx_id)
24882 + retval = group_send_sig_info(sig, sip, p);
24886 + read_unlock(&tasklist_lock);
24887 + vxdprintk(VXD_CBIT(misc, 4),
24888 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24889 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24893 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24895 + struct vcmd_ctx_kill_v0 vc_data;
24897 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24900 + /* special check to allow guest shutdown */
24901 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24902 + /* forbid killall pid=0 when init is present */
24903 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24904 + (vc_data.pid > 1)))
24907 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24911 +static int __wait_exit(struct vx_info *vxi)
24913 + DECLARE_WAITQUEUE(wait, current);
24916 + add_wait_queue(&vxi->vx_wait, &wait);
24917 + set_current_state(TASK_INTERRUPTIBLE);
24920 + if (vx_info_state(vxi,
24921 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24923 + if (signal_pending(current)) {
24924 + ret = -ERESTARTSYS;
24931 + set_current_state(TASK_RUNNING);
24932 + remove_wait_queue(&vxi->vx_wait, &wait);
24938 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24940 + struct vcmd_wait_exit_v0 vc_data;
24943 + ret = __wait_exit(vxi);
24944 + vc_data.reboot_cmd = vxi->reboot_cmd;
24945 + vc_data.exit_code = vxi->exit_code;
24947 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24952 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/space.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/space.c
24953 --- linux-2.6.22.10/kernel/vserver/space.c 1970-01-01 01:00:00 +0100
24954 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/space.c 2007-06-16 19:12:02 +0200
24957 + * linux/kernel/vserver/space.c
24959 + * Virtual Server: Context Space Support
24961 + * Copyright (C) 2003-2007 Herbert Pötzl
24963 + * V0.01 broken out from context.c 0.07
24964 + * V0.02 added task locking for namespace
24965 + * V0.03 broken out vx_enter_namespace
24966 + * V0.04 added *space support and commands
24970 +#include <linux/utsname.h>
24971 +#include <linux/sched.h>
24972 +#include <linux/vs_context.h>
24973 +#include <linux/vserver/space.h>
24974 +#include <linux/vserver/space_cmd.h>
24975 +#include <linux/dcache.h>
24976 +#include <linux/mount.h>
24977 +#include <linux/nsproxy.h>
24978 +#include <linux/fs.h>
24980 +#include <asm/errno.h>
24981 +#include <asm/uaccess.h>
24984 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
24985 +atomic_t vs_global_fs = ATOMIC_INIT(0);
24986 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
24987 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
24988 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
24991 +/* namespace functions */
24993 +#include <linux/mnt_namespace.h>
24995 +const struct vcmd_space_mask space_mask = {
24996 + .mask = CLONE_NEWNS |
25004 + * build a new nsproxy mix
25005 + * assumes that both proxies are 'const'
25006 + * does not touch nsproxy refcounts
25007 + * will hold a reference on the result.
25010 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
25011 + struct nsproxy *new_nsproxy, unsigned long mask)
25013 + struct mnt_namespace *old_ns;
25014 + struct uts_namespace *old_uts;
25015 + struct ipc_namespace *old_ipc;
25016 + struct nsproxy *nsproxy;
25018 + nsproxy = copy_nsproxy(old_nsproxy);
25022 + if (mask & CLONE_NEWNS) {
25023 + old_ns = nsproxy->mnt_ns;
25024 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
25025 + if (nsproxy->mnt_ns)
25026 + get_mnt_ns(nsproxy->mnt_ns);
25030 + if (mask & CLONE_NEWUTS) {
25031 + old_uts = nsproxy->uts_ns;
25032 + nsproxy->uts_ns = new_nsproxy->uts_ns;
25033 + if (nsproxy->uts_ns)
25034 + get_uts_ns(nsproxy->uts_ns);
25038 + if (mask & CLONE_NEWIPC) {
25039 + old_ipc = nsproxy->ipc_ns;
25040 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
25041 + if (nsproxy->ipc_ns)
25042 + get_ipc_ns(nsproxy->ipc_ns);
25047 + put_mnt_ns(old_ns);
25049 + put_uts_ns(old_uts);
25051 + put_ipc_ns(old_ipc);
25058 + * merge two nsproxy structs into a new one.
25059 + * will hold a reference on the result.
25063 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
25064 + struct nsproxy *proxy, unsigned long mask)
25066 + struct nsproxy null_proxy = { .mnt_ns = NULL };
25072 + /* vs_mix_nsproxy returns with reference */
25073 + return vs_mix_nsproxy(old ? old : &null_proxy,
25076 + get_nsproxy(proxy);
25081 + * merge two fs structs into a new one.
25082 + * will take a reference on the result.
25086 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
25087 + struct fs_struct *fs, unsigned long mask)
25089 + if (!(mask & CLONE_FS)) {
25091 + atomic_inc(&old->count);
25098 + return copy_fs_struct(fs);
25102 +int vx_enter_space(struct vx_info *vxi, unsigned long mask)
25104 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
25105 + struct fs_struct *fs, *fs_cur, *fs_new;
25108 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
25112 + mask = vxi->vx_nsmask;
25114 + if ((mask & vxi->vx_nsmask) != mask)
25117 + proxy = vxi->vx_nsproxy;
25120 + task_lock(current);
25121 + fs_cur = current->fs;
25122 + atomic_inc(&fs_cur->count);
25123 + proxy_cur = current->nsproxy;
25124 + get_nsproxy(proxy_cur);
25125 + task_unlock(current);
25127 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
25128 + if (IS_ERR(fs_new)) {
25129 + ret = PTR_ERR(fs_new);
25133 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
25134 + if (IS_ERR(proxy_new)) {
25135 + ret = PTR_ERR(proxy_new);
25139 + fs_new = xchg(¤t->fs, fs_new);
25140 + proxy_new = xchg(¤t->nsproxy, proxy_new);
25144 + put_nsproxy(proxy_new);
25147 + put_fs_struct(fs_new);
25150 + put_nsproxy(proxy_cur);
25152 + put_fs_struct(fs_cur);
25157 +int vx_set_space(struct vx_info *vxi, unsigned long mask)
25159 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
25160 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
25164 + mask = space_mask.mask;
25166 + if ((mask & space_mask.mask) != mask)
25169 + proxy_vxi = vxi->vx_nsproxy;
25170 + fs_vxi = vxi->vx_fs;
25172 + task_lock(current);
25173 + fs_cur = current->fs;
25174 + atomic_inc(&fs_cur->count);
25175 + proxy_cur = current->nsproxy;
25176 + get_nsproxy(proxy_cur);
25177 + task_unlock(current);
25179 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
25180 + if (IS_ERR(fs_new)) {
25181 + ret = PTR_ERR(fs_new);
25185 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
25186 + if (IS_ERR(proxy_new)) {
25187 + ret = PTR_ERR(proxy_new);
25191 + fs_new = xchg(&vxi->vx_fs, fs_new);
25192 + proxy_new = xchg(&vxi->vx_nsproxy, proxy_new);
25193 + vxi->vx_nsmask |= mask;
25197 + put_nsproxy(proxy_new);
25200 + put_fs_struct(fs_new);
25203 + put_nsproxy(proxy_cur);
25205 + put_fs_struct(fs_cur);
25210 +int vc_enter_space(struct vx_info *vxi, void __user *data)
25212 + struct vcmd_space_mask vc_data = { .mask = 0 };
25214 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25217 + return vx_enter_space(vxi, vc_data.mask);
25220 +int vc_set_space(struct vx_info *vxi, void __user *data)
25222 + struct vcmd_space_mask vc_data = { .mask = 0 };
25224 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25227 + return vx_set_space(vxi, vc_data.mask);
25230 +int vc_get_space_mask(struct vx_info *vxi, void __user *data)
25232 + if (copy_to_user(data, &space_mask, sizeof(space_mask)))
25237 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/switch.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/switch.c
25238 --- linux-2.6.22.10/kernel/vserver/switch.c 1970-01-01 01:00:00 +0100
25239 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/switch.c 2007-10-29 23:34:24 +0100
25242 + * linux/kernel/vserver/switch.c
25244 + * Virtual Server: Syscall Switch
25246 + * Copyright (C) 2003-2007 Herbert Pötzl
25248 + * V0.01 syscall switch
25249 + * V0.02 added signal to context
25250 + * V0.03 added rlimit functions
25251 + * V0.04 added iattr, task/xid functions
25252 + * V0.05 added debug/history stuff
25253 + * V0.06 added compat32 layer
25254 + * V0.07 vcmd args and perms
25255 + * V0.08 added status commands
25259 +#include <linux/linkage.h>
25260 +#include <linux/sched.h>
25261 +#include <linux/compat.h>
25262 +#include <asm/errno.h>
25264 +#include <linux/vs_context.h>
25265 +#include <linux/vs_network.h>
25266 +#include <linux/vserver/switch.h>
25268 +#include "vci_config.h"
25271 +int vc_get_version(uint32_t id)
25273 +#ifdef CONFIG_VSERVER_LEGACY_VERSION
25275 + return VCI_LEGACY_VERSION;
25277 + return VCI_VERSION;
25281 +int vc_get_vci(uint32_t id)
25283 + return vci_kernel_config();
25286 +#include <linux/vserver/context_cmd.h>
25287 +#include <linux/vserver/cvirt_cmd.h>
25288 +#include <linux/vserver/cacct_cmd.h>
25289 +#include <linux/vserver/limit_cmd.h>
25290 +#include <linux/vserver/network_cmd.h>
25291 +#include <linux/vserver/sched_cmd.h>
25292 +#include <linux/vserver/debug_cmd.h>
25293 +#include <linux/vserver/inode_cmd.h>
25294 +#include <linux/vserver/dlimit_cmd.h>
25295 +#include <linux/vserver/signal_cmd.h>
25296 +#include <linux/vserver/space_cmd.h>
25298 +#include <linux/vserver/legacy.h>
25299 +#include <linux/vserver/inode.h>
25300 +#include <linux/vserver/dlimit.h>
25303 +#ifdef CONFIG_COMPAT
25304 +#define __COMPAT(name, id, data, compat) \
25305 + (compat) ? name ## _x32(id, data) : name(id, data)
25306 +#define __COMPAT_NO_ID(name, data, compat) \
25307 + (compat) ? name ## _x32(data) : name(data)
25309 +#define __COMPAT(name, id, data, compat) \
25311 +#define __COMPAT_NO_ID(name, data, compat) \
25317 +long do_vcmd(uint32_t cmd, uint32_t id,
25318 + struct vx_info *vxi, struct nx_info *nxi,
25319 + void __user *data, int compat)
25323 + case VCMD_get_version:
25324 + return vc_get_version(id);
25325 + case VCMD_get_vci:
25326 + return vc_get_vci(id);
25328 + case VCMD_task_xid:
25329 + return vc_task_xid(id, data);
25330 + case VCMD_vx_info:
25331 + return vc_vx_info(vxi, data);
25333 + case VCMD_task_nid:
25334 + return vc_task_nid(id, data);
25335 + case VCMD_nx_info:
25336 + return vc_nx_info(nxi, data);
25338 + case VCMD_set_space_v0:
25339 + /* this is version 1 */
25340 + case VCMD_set_space:
25341 + return vc_set_space(vxi, data);
25343 + case VCMD_get_space_mask:
25344 + return vc_get_space_mask(vxi, data);
25346 +#ifdef CONFIG_IA32_EMULATION
25347 + case VCMD_get_rlimit:
25348 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
25349 + case VCMD_set_rlimit:
25350 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
25352 + case VCMD_get_rlimit:
25353 + return vc_get_rlimit(vxi, data);
25354 + case VCMD_set_rlimit:
25355 + return vc_set_rlimit(vxi, data);
25357 + case VCMD_get_rlimit_mask:
25358 + return vc_get_rlimit_mask(id, data);
25359 + case VCMD_reset_minmax:
25360 + return vc_reset_minmax(vxi, data);
25362 + case VCMD_get_vhi_name:
25363 + return vc_get_vhi_name(vxi, data);
25364 + case VCMD_set_vhi_name:
25365 + return vc_set_vhi_name(vxi, data);
25367 + case VCMD_ctx_stat:
25368 + return vc_ctx_stat(vxi, data);
25369 + case VCMD_virt_stat:
25370 + return vc_virt_stat(vxi, data);
25371 + case VCMD_sock_stat:
25372 + return vc_sock_stat(vxi, data);
25373 + case VCMD_rlimit_stat:
25374 + return vc_rlimit_stat(vxi, data);
25376 + case VCMD_set_cflags:
25377 + return vc_set_cflags(vxi, data);
25378 + case VCMD_get_cflags:
25379 + return vc_get_cflags(vxi, data);
25381 + case VCMD_set_ccaps_v0:
25382 + return vc_set_ccaps_v0(vxi, data);
25383 + /* this is version 1 */
25384 + case VCMD_set_ccaps:
25385 + return vc_set_ccaps(vxi, data);
25386 + case VCMD_get_ccaps_v0:
25387 + return vc_get_ccaps_v0(vxi, data);
25388 + /* this is version 1 */
25389 + case VCMD_get_ccaps:
25390 + return vc_get_ccaps(vxi, data);
25391 + case VCMD_set_bcaps:
25392 + return vc_set_bcaps(vxi, data);
25393 + case VCMD_get_bcaps:
25394 + return vc_get_bcaps(vxi, data);
25396 + case VCMD_set_nflags:
25397 + return vc_set_nflags(nxi, data);
25398 + case VCMD_get_nflags:
25399 + return vc_get_nflags(nxi, data);
25401 + case VCMD_set_ncaps:
25402 + return vc_set_ncaps(nxi, data);
25403 + case VCMD_get_ncaps:
25404 + return vc_get_ncaps(nxi, data);
25406 +#ifdef CONFIG_VSERVER_LEGACY
25407 + case VCMD_set_sched_v2:
25408 + return vc_set_sched_v2(vxi, data);
25410 + case VCMD_set_sched_v3:
25411 + return vc_set_sched_v3(vxi, data);
25412 + case VCMD_set_sched_v4:
25413 + return vc_set_sched_v4(vxi, data);
25414 + /* this is version 5 */
25415 + case VCMD_set_sched:
25416 + return vc_set_sched(vxi, data);
25417 + case VCMD_get_sched:
25418 + return vc_get_sched(vxi, data);
25419 + case VCMD_sched_info:
25420 + return vc_sched_info(vxi, data);
25422 + case VCMD_add_dlimit:
25423 + return __COMPAT(vc_add_dlimit, id, data, compat);
25424 + case VCMD_rem_dlimit:
25425 + return __COMPAT(vc_rem_dlimit, id, data, compat);
25426 + case VCMD_set_dlimit:
25427 + return __COMPAT(vc_set_dlimit, id, data, compat);
25428 + case VCMD_get_dlimit:
25429 + return __COMPAT(vc_get_dlimit, id, data, compat);
25431 + case VCMD_ctx_kill:
25432 + return vc_ctx_kill(vxi, data);
25434 + case VCMD_wait_exit:
25435 + return vc_wait_exit(vxi, data);
25437 +#ifdef CONFIG_VSERVER_LEGACY
25438 + case VCMD_create_context:
25439 + return vc_ctx_create(id, NULL);
25442 + case VCMD_get_iattr:
25443 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25444 + case VCMD_set_iattr:
25445 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25447 + case VCMD_fget_iattr:
25448 + return vc_fget_iattr(id, data);
25449 + case VCMD_fset_iattr:
25450 + return vc_fset_iattr(id, data);
25452 + case VCMD_enter_space_v0:
25453 + return vc_enter_space(vxi, NULL);
25454 + /* this is version 1 */
25455 + case VCMD_enter_space:
25456 + return vc_enter_space(vxi, data);
25458 + case VCMD_ctx_create_v0:
25459 + return vc_ctx_create(id, NULL);
25460 + case VCMD_ctx_create:
25461 + return vc_ctx_create(id, data);
25462 + case VCMD_ctx_migrate_v0:
25463 + return vc_ctx_migrate(vxi, NULL);
25464 + case VCMD_ctx_migrate:
25465 + return vc_ctx_migrate(vxi, data);
25467 + case VCMD_net_create_v0:
25468 + return vc_net_create(id, NULL);
25469 + case VCMD_net_create:
25470 + return vc_net_create(id, data);
25471 + case VCMD_net_migrate:
25472 + return vc_net_migrate(nxi, data);
25473 + case VCMD_net_add:
25474 + return vc_net_add(nxi, data);
25475 + case VCMD_net_remove:
25476 + return vc_net_remove(nxi, data);
25478 +#ifdef CONFIG_VSERVER_HISTORY
25479 + case VCMD_dump_history:
25480 + return vc_dump_history(id);
25481 + case VCMD_read_history:
25482 + return __COMPAT(vc_read_history, id, data, compat);
25484 +#ifdef CONFIG_VSERVER_MONITOR
25485 + case VCMD_read_monitor:
25486 + return __COMPAT(vc_read_monitor, id, data, compat);
25488 +#ifdef CONFIG_VSERVER_LEGACY
25489 + case VCMD_new_s_context:
25490 + return vc_new_s_context(id, data);
25492 +#ifdef CONFIG_VSERVER_LEGACYNET
25493 + case VCMD_set_ipv4root:
25494 + return vc_set_ipv4root(id, data);
25497 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25498 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25504 +#define __VCMD(vcmd, _perm, _args, _flags) \
25505 + case VCMD_ ## vcmd: perm = _perm; \
25506 + args = _args; flags = _flags; break
25509 +#define VCA_NONE 0x00
25510 +#define VCA_VXI 0x01
25511 +#define VCA_NXI 0x02
25513 +#define VCF_NONE 0x00
25514 +#define VCF_INFO 0x01
25515 +#define VCF_ADMIN 0x02
25516 +#define VCF_ARES 0x06 /* includes admin */
25517 +#define VCF_SETUP 0x08
25519 +#define VCF_ZIDOK 0x10 /* zero id okay */
25523 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25526 + int permit = -1, state = 0;
25527 + int perm = -1, args = 0, flags = 0;
25528 + struct vx_info *vxi = NULL;
25529 + struct nx_info *nxi = NULL;
25532 + /* unpriviledged commands */
25533 + __VCMD(get_version, 0, VCA_NONE, 0);
25534 + __VCMD(get_vci, 0, VCA_NONE, 0);
25535 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
25536 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
25538 + /* info commands */
25539 + __VCMD(task_xid, 2, VCA_NONE, 0);
25540 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
25541 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
25542 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
25543 + __VCMD(get_ccaps_v0, 3, VCA_VXI, VCF_INFO);
25544 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
25545 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
25546 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
25547 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
25549 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
25550 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
25551 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
25552 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
25554 + __VCMD(task_nid, 2, VCA_NONE, 0);
25555 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
25556 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
25557 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
25559 + __VCMD(get_iattr, 2, VCA_NONE, 0);
25560 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
25561 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
25562 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
25563 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
25565 + /* lower admin commands */
25566 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
25567 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
25568 + __VCMD(ctx_create, 5, VCA_NONE, 0);
25569 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
25570 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
25571 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
25572 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
25574 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
25575 + __VCMD(net_create, 5, VCA_NONE, 0);
25576 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
25578 + /* higher admin commands */
25579 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
25580 + __VCMD(set_space_v0, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25581 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25583 + __VCMD(set_ccaps_v0, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25584 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25585 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25586 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25588 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25589 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25590 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25591 + __VCMD(set_sched_v2, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25592 + __VCMD(set_sched_v3, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25593 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25595 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25596 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25597 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25598 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25600 + __VCMD(set_iattr, 7, VCA_NONE, 0);
25601 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
25602 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
25603 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
25604 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
25606 + /* debug level admin commands */
25607 +#ifdef CONFIG_VSERVER_HISTORY
25608 + __VCMD(dump_history, 9, VCA_NONE, 0);
25609 + __VCMD(read_history, 9, VCA_NONE, 0);
25611 +#ifdef CONFIG_VSERVER_MONITOR
25612 + __VCMD(read_monitor, 9, VCA_NONE, 0);
25615 + /* legacy commands */
25616 +#ifdef CONFIG_VSERVER_LEGACY
25617 + __VCMD(new_s_context, 1, VCA_NONE, 0);
25618 + __VCMD(create_context, 5, VCA_NONE, 0);
25620 +#ifdef CONFIG_VSERVER_LEGACYNET
25621 + __VCMD(set_ipv4root, 5, VCA_NONE, 0);
25627 + vxdprintk(VXD_CBIT(switch, 0),
25628 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25629 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25630 + VC_VERSION(cmd), id, data, compat,
25631 + perm, args, flags);
25638 +#ifdef CONFIG_VSERVER_LEGACY
25639 + if (!capable(CAP_CONTEXT) &&
25640 + /* dirty hack for capremove */
25641 + !(cmd == VCMD_new_s_context && id == -2))
25644 + if (!capable(CAP_CONTEXT))
25649 + /* moved here from the individual commands */
25651 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25655 + /* vcmd involves resource management */
25657 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25661 + /* various legacy exceptions */
25663 +#ifdef CONFIG_VSERVER_LEGACY
25664 + case VCMD_set_cflags:
25665 + case VCMD_set_ccaps_v0:
25667 + if (vx_check(0, VS_WATCH))
25671 + case VCMD_ctx_create_v0:
25673 + /* will go away when spectator is a cap */
25674 + case VCMD_ctx_migrate_v0:
25675 + case VCMD_ctx_migrate:
25677 + current->xid = 1;
25683 + /* will go away when spectator is a cap */
25684 + case VCMD_net_migrate:
25686 + current->nid = 1;
25692 + /* legacy special casing */
25693 + case VCMD_set_space_v0:
25698 + /* vcmds are fine by default */
25701 + /* admin type vcmds require admin ... */
25702 + if (flags & VCF_ADMIN)
25703 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25705 + /* ... but setup type vcmds override that */
25706 + if (!permit && (flags & VCF_SETUP))
25707 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25715 + if (!id && (flags & VCF_ZIDOK))
25719 + if (args & VCA_VXI) {
25720 + vxi = lookup_vx_info(id);
25724 + if ((flags & VCF_ADMIN) &&
25725 + /* special case kill for shutdown */
25726 + (cmd != VCMD_ctx_kill) &&
25727 + /* can context be administrated? */
25728 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25734 + if (args & VCA_NXI) {
25735 + nxi = lookup_nx_info(id);
25739 + if ((flags & VCF_ADMIN) &&
25740 + /* can context be administrated? */
25741 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25748 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25751 + if ((args & VCA_NXI) && nxi)
25752 + put_nx_info(nxi);
25754 + if ((args & VCA_VXI) && vxi)
25755 + put_vx_info(vxi);
25757 + vxdprintk(VXD_CBIT(switch, 1),
25758 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25759 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25760 + VC_VERSION(cmd), ret, ret, state, permit);
25765 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25767 + return do_vserver(cmd, id, data, 0);
25770 +#ifdef CONFIG_COMPAT
25773 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25775 + return do_vserver(cmd, id, data, 1);
25778 +#endif /* CONFIG_COMPAT */
25779 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/sysctl.c linux-2.6.22.10-vs2.2.0.5/kernel/vserver/sysctl.c
25780 --- linux-2.6.22.10/kernel/vserver/sysctl.c 1970-01-01 01:00:00 +0100
25781 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/sysctl.c 2007-06-16 05:31:20 +0200
25784 + * kernel/vserver/sysctl.c
25786 + * Virtual Context Support
25788 + * Copyright (C) 2004-2007 Herbert Pötzl
25790 + * V0.01 basic structure
25794 +#include <linux/errno.h>
25795 +#include <linux/module.h>
25796 +#include <linux/types.h>
25797 +#include <linux/ctype.h>
25798 +#include <linux/sysctl.h>
25799 +#include <linux/parser.h>
25800 +#include <linux/fs.h>
25802 +#include <asm/uaccess.h>
25803 +#include <asm/unistd.h>
25806 +#define CTL_VSERVER 4242 /* unused? */
25809 + CTL_DEBUG_ERROR = 0,
25810 + CTL_DEBUG_SWITCH = 1,
25825 +unsigned int vx_debug_switch = 0;
25826 +unsigned int vx_debug_xid = 0;
25827 +unsigned int vx_debug_nid = 0;
25828 +unsigned int vx_debug_tag = 0;
25829 +unsigned int vx_debug_net = 0;
25830 +unsigned int vx_debug_limit = 0;
25831 +unsigned int vx_debug_cres = 0;
25832 +unsigned int vx_debug_dlim = 0;
25833 +unsigned int vx_debug_quota = 0;
25834 +unsigned int vx_debug_cvirt = 0;
25835 +unsigned int vx_debug_space = 0;
25836 +unsigned int vx_debug_misc = 0;
25839 +static struct ctl_table_header *vserver_table_header;
25840 +static ctl_table vserver_table[];
25843 +void vserver_register_sysctl(void)
25845 + if (!vserver_table_header) {
25846 + vserver_table_header = register_sysctl_table(vserver_table);
25851 +void vserver_unregister_sysctl(void)
25853 + if (vserver_table_header) {
25854 + unregister_sysctl_table(vserver_table_header);
25855 + vserver_table_header = NULL;
25860 +static int proc_dodebug(ctl_table *table, int write,
25861 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
25863 + char tmpbuf[20], *p, c;
25864 + unsigned int value;
25865 + size_t left, len;
25867 + if ((*ppos && !write) || !*lenp) {
25875 + if (!access_ok(VERIFY_READ, buffer, left))
25877 + p = (char *)buffer;
25878 + while (left && __get_user(c, p) >= 0 && isspace(c))
25883 + if (left > sizeof(tmpbuf) - 1)
25885 + if (copy_from_user(tmpbuf, p, left))
25887 + tmpbuf[left] = '\0';
25889 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25890 + value = 10 * value + (*p - '0');
25891 + if (*p && !isspace(*p))
25893 + while (left && isspace(*p))
25895 + *(unsigned int *)table->data = value;
25897 + if (!access_ok(VERIFY_WRITE, buffer, left))
25899 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25902 + if (__copy_to_user(buffer, tmpbuf, len))
25904 + if ((left -= len) > 0) {
25905 + if (put_user('\n', (char *)buffer + len))
25918 +#define CTL_ENTRY(ctl, name) \
25920 + .ctl_name = ctl, \
25921 + .procname = #name, \
25922 + .data = &vx_ ## name, \
25923 + .maxlen = sizeof(int), \
25925 + .proc_handler = &proc_dodebug \
25928 +static ctl_table debug_table[] = {
25929 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
25930 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
25931 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
25932 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
25933 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
25934 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
25935 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
25936 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
25937 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
25938 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
25939 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
25940 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
25941 + { .ctl_name = 0 }
25944 +static ctl_table vserver_table[] = {
25946 + .ctl_name = CTL_VSERVER,
25947 + .procname = "vserver",
25949 + .child = debug_table
25951 + { .ctl_name = 0 }
25955 +static match_table_t tokens = {
25956 + { CTL_DEBUG_SWITCH, "switch=%x" },
25957 + { CTL_DEBUG_XID, "xid=%x" },
25958 + { CTL_DEBUG_NID, "nid=%x" },
25959 + { CTL_DEBUG_TAG, "tag=%x" },
25960 + { CTL_DEBUG_NET, "net=%x" },
25961 + { CTL_DEBUG_LIMIT, "limit=%x" },
25962 + { CTL_DEBUG_CRES, "cres=%x" },
25963 + { CTL_DEBUG_DLIM, "dlim=%x" },
25964 + { CTL_DEBUG_QUOTA, "quota=%x" },
25965 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
25966 + { CTL_DEBUG_SPACE, "space=%x" },
25967 + { CTL_DEBUG_MISC, "misc=%x" },
25968 + { CTL_DEBUG_ERROR, NULL }
25971 +#define HANDLE_CASE(id, name, val) \
25972 + case CTL_DEBUG_ ## id: \
25973 + vx_debug_ ## name = val; \
25974 + printk("vs_debug_" #name "=0x%x\n", val); \
25978 +static int __init vs_debug_setup(char *str)
25983 + printk("vs_debug_setup(%s)\n", str);
25984 + while ((p = strsep(&str, ",")) != NULL) {
25985 + substring_t args[MAX_OPT_ARGS];
25986 + unsigned int value;
25991 + token = match_token(p, tokens, args);
25992 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
25995 + HANDLE_CASE(SWITCH, switch, value);
25996 + HANDLE_CASE(XID, xid, value);
25997 + HANDLE_CASE(NID, nid, value);
25998 + HANDLE_CASE(TAG, tag, value);
25999 + HANDLE_CASE(NET, net, value);
26000 + HANDLE_CASE(LIMIT, limit, value);
26001 + HANDLE_CASE(CRES, cres, value);
26002 + HANDLE_CASE(DLIM, dlim, value);
26003 + HANDLE_CASE(QUOTA, quota, value);
26004 + HANDLE_CASE(CVIRT, cvirt, value);
26005 + HANDLE_CASE(SPACE, space, value);
26006 + HANDLE_CASE(MISC, misc, value);
26015 +__setup("vsdebug=", vs_debug_setup);
26019 +EXPORT_SYMBOL_GPL(vx_debug_switch);
26020 +EXPORT_SYMBOL_GPL(vx_debug_xid);
26021 +EXPORT_SYMBOL_GPL(vx_debug_nid);
26022 +EXPORT_SYMBOL_GPL(vx_debug_net);
26023 +EXPORT_SYMBOL_GPL(vx_debug_limit);
26024 +EXPORT_SYMBOL_GPL(vx_debug_cres);
26025 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
26026 +EXPORT_SYMBOL_GPL(vx_debug_quota);
26027 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
26028 +EXPORT_SYMBOL_GPL(vx_debug_space);
26029 +EXPORT_SYMBOL_GPL(vx_debug_misc);
26031 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/vci_config.h linux-2.6.22.10-vs2.2.0.5/kernel/vserver/vci_config.h
26032 --- linux-2.6.22.10/kernel/vserver/vci_config.h 1970-01-01 01:00:00 +0100
26033 +++ linux-2.6.22.10-vs2.2.0.5/kernel/vserver/vci_config.h 2007-06-15 02:37:04 +0200
26036 +/* interface version */
26038 +#define VCI_VERSION 0x00020200
26039 +#define VCI_LEGACY_VERSION 0x000100FF
26043 + VCI_KCBIT_NO_DYNAMIC = 0,
26044 + VCI_KCBIT_LEGACY = 1,
26045 + VCI_KCBIT_LEGACYNET = 2,
26046 + VCI_KCBIT_NGNET = 3,
26048 + VCI_KCBIT_PROC_SECURE = 4,
26049 + VCI_KCBIT_HARDCPU = 5,
26050 + VCI_KCBIT_IDLELIMIT = 6,
26051 + VCI_KCBIT_IDLETIME = 7,
26053 + VCI_KCBIT_COWBL = 8,
26054 + VCI_KCBIT_FULLCOWBL = 9,
26055 + VCI_KCBIT_SPACES = 10,
26057 + VCI_KCBIT_LEGACY_VERSION = 15,
26058 + VCI_KCBIT_DEBUG = 16,
26059 + VCI_KCBIT_HISTORY = 20,
26060 + VCI_KCBIT_TAGGED = 24,
26064 +static inline uint32_t vci_kernel_config(void)
26067 + /* various legacy options */
26068 +#ifndef CONFIG_VSERVER_DYNAMIC_IDS
26069 + (1 << VCI_KCBIT_NO_DYNAMIC) |
26071 +#ifdef CONFIG_VSERVER_LEGACY
26072 + (1 << VCI_KCBIT_LEGACY) |
26074 +#ifdef CONFIG_VSERVER_LEGACYNET
26075 + (1 << VCI_KCBIT_LEGACYNET) |
26077 +#ifdef CONFIG_VSERVER_LEGACY_VERSION
26078 + (1 << VCI_KCBIT_LEGACY_VERSION) |
26081 + /* configured features */
26082 +#ifdef CONFIG_VSERVER_PROC_SECURE
26083 + (1 << VCI_KCBIT_PROC_SECURE) |
26085 +#ifdef CONFIG_VSERVER_HARDCPU
26086 + (1 << VCI_KCBIT_HARDCPU) |
26088 +#ifdef CONFIG_VSERVER_IDLELIMIT
26089 + (1 << VCI_KCBIT_IDLELIMIT) |
26091 +#ifdef CONFIG_VSERVER_IDLETIME
26092 + (1 << VCI_KCBIT_IDLETIME) |
26094 +#ifdef CONFIG_VSERVER_COWBL
26095 + (1 << VCI_KCBIT_COWBL) |
26096 + (1 << VCI_KCBIT_FULLCOWBL) |
26098 + (1 << VCI_KCBIT_SPACES) |
26100 + /* debug options */
26101 +#ifdef CONFIG_VSERVER_DEBUG
26102 + (1 << VCI_KCBIT_DEBUG) |
26104 +#ifdef CONFIG_VSERVER_HISTORY
26105 + (1 << VCI_KCBIT_HISTORY) |
26108 + /* inode context tagging */
26109 +#if defined(CONFIG_TAGGING_NONE)
26110 + (0 << VCI_KCBIT_TAGGED) |
26111 +#elif defined(CONFIG_TAGGING_UID16)
26112 + (1 << VCI_KCBIT_TAGGED) |
26113 +#elif defined(CONFIG_TAGGING_GID16)
26114 + (2 << VCI_KCBIT_TAGGED) |
26115 +#elif defined(CONFIG_TAGGING_ID24)
26116 + (3 << VCI_KCBIT_TAGGED) |
26117 +#elif defined(CONFIG_TAGGING_INTERN)
26118 + (4 << VCI_KCBIT_TAGGED) |
26119 +#elif defined(CONFIG_TAGGING_RUNTIME)
26120 + (5 << VCI_KCBIT_TAGGED) |
26122 + (7 << VCI_KCBIT_TAGGED) |
26127 diff -NurpP --minimal linux-2.6.22.10/mm/filemap_xip.c linux-2.6.22.10-vs2.2.0.5/mm/filemap_xip.c
26128 --- linux-2.6.22.10/mm/filemap_xip.c 2007-07-09 13:20:04 +0200
26129 +++ linux-2.6.22.10-vs2.2.0.5/mm/filemap_xip.c 2007-06-15 05:30:21 +0200
26131 #include <linux/uio.h>
26132 #include <linux/rmap.h>
26133 #include <linux/sched.h>
26134 +#include <linux/vs_memory.h>
26135 #include <asm/tlbflush.h>
26136 #include "filemap.h"
26138 diff -NurpP --minimal linux-2.6.22.10/mm/fremap.c linux-2.6.22.10-vs2.2.0.5/mm/fremap.c
26139 --- linux-2.6.22.10/mm/fremap.c 2007-02-06 03:01:56 +0100
26140 +++ linux-2.6.22.10-vs2.2.0.5/mm/fremap.c 2007-06-15 02:37:04 +0200
26142 #include <linux/rmap.h>
26143 #include <linux/module.h>
26144 #include <linux/syscalls.h>
26145 +#include <linux/vs_memory.h>
26147 #include <asm/mmu_context.h>
26148 #include <asm/cacheflush.h>
26149 @@ -74,6 +75,8 @@ int install_page(struct mm_struct *mm, s
26151 if (page_mapcount(page) > INT_MAX/2)
26153 + if (!vx_rss_avail(mm, 1))
26156 if (pte_none(*pte) || !zap_pte(mm, vma, addr, pte))
26157 inc_mm_counter(mm, file_rss);
26158 diff -NurpP --minimal linux-2.6.22.10/mm/hugetlb.c linux-2.6.22.10-vs2.2.0.5/mm/hugetlb.c
26159 --- linux-2.6.22.10/mm/hugetlb.c 2007-10-30 01:57:15 +0100
26160 +++ linux-2.6.22.10-vs2.2.0.5/mm/hugetlb.c 2007-08-12 12:21:52 +0200
26162 #include <asm/pgtable.h>
26164 #include <linux/hugetlb.h>
26165 +#include <linux/vs_memory.h>
26166 #include "internal.h"
26168 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26169 diff -NurpP --minimal linux-2.6.22.10/mm/memory.c linux-2.6.22.10-vs2.2.0.5/mm/memory.c
26170 --- linux-2.6.22.10/mm/memory.c 2007-07-09 13:20:04 +0200
26171 +++ linux-2.6.22.10-vs2.2.0.5/mm/memory.c 2007-06-17 05:55:53 +0200
26172 @@ -498,6 +498,9 @@ static int copy_pte_range(struct mm_stru
26176 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
26180 rss[1] = rss[0] = 0;
26181 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
26182 @@ -2157,6 +2160,11 @@ static int do_swap_page(struct mm_struct
26183 count_vm_event(PGMAJFAULT);
26186 + if (!vx_rss_avail(mm, 1)) {
26187 + ret = VM_FAULT_OOM;
26191 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
26192 mark_page_accessed(page);
26194 @@ -2229,6 +2237,8 @@ static int do_anonymous_page(struct mm_s
26195 /* Allocate our own private page. */
26196 pte_unmap(page_table);
26198 + if (!vx_rss_avail(mm, 1))
26200 if (unlikely(anon_vma_prepare(vma)))
26202 page = alloc_zeroed_user_highpage(vma, address);
26203 @@ -2302,6 +2312,9 @@ static int do_no_page(struct mm_struct *
26204 pte_unmap(page_table);
26205 BUG_ON(vma->vm_flags & VM_PFNMAP);
26207 + if (!vx_rss_avail(mm, 1))
26208 + return VM_FAULT_OOM;
26210 if (vma->vm_file) {
26211 mapping = vma->vm_file->f_mapping;
26212 sequence = mapping->truncate_count;
26213 @@ -2527,6 +2540,7 @@ static inline int handle_pte_fault(struc
26217 + int ret, type = VXPT_UNKNOWN;
26220 if (!pte_present(entry)) {
26221 @@ -2555,9 +2569,12 @@ static inline int handle_pte_fault(struc
26222 if (unlikely(!pte_same(*pte, entry)))
26224 if (write_access) {
26225 - if (!pte_write(entry))
26226 - return do_wp_page(mm, vma, address,
26227 + if (!pte_write(entry)) {
26228 + ret = do_wp_page(mm, vma, address,
26229 pte, pmd, ptl, entry);
26230 + type = VXPT_WRITE;
26233 entry = pte_mkdirty(entry);
26235 entry = pte_mkyoung(entry);
26236 @@ -2576,7 +2593,10 @@ static inline int handle_pte_fault(struc
26239 pte_unmap_unlock(pte, ptl);
26240 - return VM_FAULT_MINOR;
26241 + ret = VM_FAULT_MINOR;
26243 + vx_page_fault(mm, vma, type, ret);
26248 diff -NurpP --minimal linux-2.6.22.10/mm/mlock.c linux-2.6.22.10-vs2.2.0.5/mm/mlock.c
26249 --- linux-2.6.22.10/mm/mlock.c 2007-10-30 01:57:15 +0100
26250 +++ linux-2.6.22.10-vs2.2.0.5/mm/mlock.c 2007-08-12 12:21:52 +0200
26252 #include <linux/syscalls.h>
26253 #include <linux/sched.h>
26254 #include <linux/module.h>
26255 +#include <linux/vs_memory.h>
26257 int can_do_mlock(void)
26259 @@ -76,7 +77,7 @@ success:
26260 ret = make_pages_present(start, end);
26263 - mm->locked_vm -= pages;
26264 + vx_vmlocked_sub(mm, pages);
26266 if (ret == -ENOMEM)
26268 @@ -134,7 +135,7 @@ static int do_mlock(unsigned long start,
26270 asmlinkage long sys_mlock(unsigned long start, size_t len)
26272 - unsigned long locked;
26273 + unsigned long locked, grow;
26274 unsigned long lock_limit;
26275 int error = -ENOMEM;
26277 @@ -145,8 +146,10 @@ asmlinkage long sys_mlock(unsigned long
26278 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
26279 start &= PAGE_MASK;
26281 - locked = len >> PAGE_SHIFT;
26282 - locked += current->mm->locked_vm;
26283 + grow = len >> PAGE_SHIFT;
26284 + if (!vx_vmlocked_avail(current->mm, grow))
26286 + locked = current->mm->locked_vm + grow;
26288 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
26289 lock_limit >>= PAGE_SHIFT;
26290 @@ -154,6 +157,7 @@ asmlinkage long sys_mlock(unsigned long
26291 /* check against resource limits */
26292 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
26293 error = do_mlock(start, len, 1);
26295 up_write(¤t->mm->mmap_sem);
26298 @@ -213,6 +217,8 @@ asmlinkage long sys_mlockall(int flags)
26299 lock_limit >>= PAGE_SHIFT;
26302 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
26304 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
26305 capable(CAP_IPC_LOCK))
26306 ret = do_mlockall(flags);
26307 diff -NurpP --minimal linux-2.6.22.10/mm/mmap.c linux-2.6.22.10-vs2.2.0.5/mm/mmap.c
26308 --- linux-2.6.22.10/mm/mmap.c 2007-07-09 13:20:04 +0200
26309 +++ linux-2.6.22.10-vs2.2.0.5/mm/mmap.c 2007-07-17 03:02:15 +0200
26310 @@ -1144,10 +1144,10 @@ munmap_back:
26311 kmem_cache_free(vm_area_cachep, vma);
26314 - mm->total_vm += len >> PAGE_SHIFT;
26315 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26316 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
26317 if (vm_flags & VM_LOCKED) {
26318 - mm->locked_vm += len >> PAGE_SHIFT;
26319 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
26320 make_pages_present(addr, addr + len);
26322 if (flags & MAP_POPULATE) {
26323 @@ -1502,9 +1502,9 @@ static int acct_stack_growth(struct vm_a
26326 /* Ok, everything looks good - let it rip */
26327 - mm->total_vm += grow;
26328 + vx_vmpages_add(mm, grow);
26329 if (vma->vm_flags & VM_LOCKED)
26330 - mm->locked_vm += grow;
26331 + vx_vmlocked_add(mm, grow);
26332 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
26335 @@ -1662,9 +1662,9 @@ static void remove_vma_list(struct mm_st
26337 long nrpages = vma_pages(vma);
26339 - mm->total_vm -= nrpages;
26340 + vx_vmpages_sub(mm, nrpages);
26341 if (vma->vm_flags & VM_LOCKED)
26342 - mm->locked_vm -= nrpages;
26343 + vx_vmlocked_sub(mm, nrpages);
26344 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
26345 vma = remove_vma(vma);
26347 @@ -1903,6 +1903,8 @@ unsigned long do_brk(unsigned long addr,
26348 lock_limit >>= PAGE_SHIFT;
26349 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
26351 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
26356 @@ -1929,7 +1931,8 @@ unsigned long do_brk(unsigned long addr,
26357 if (mm->map_count > sysctl_max_map_count)
26360 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
26361 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
26362 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
26365 /* Can we just expand an old private anonymous mapping? */
26366 @@ -1955,9 +1958,9 @@ unsigned long do_brk(unsigned long addr,
26367 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)];
26368 vma_link(mm, vma, prev, rb_link, rb_parent);
26370 - mm->total_vm += len >> PAGE_SHIFT;
26371 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26372 if (flags & VM_LOCKED) {
26373 - mm->locked_vm += len >> PAGE_SHIFT;
26374 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
26375 make_pages_present(addr, addr + len);
26378 @@ -1986,6 +1989,11 @@ void exit_mmap(struct mm_struct *mm)
26379 free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, 0);
26380 tlb_finish_mmu(tlb, 0, end);
26382 + set_mm_counter(mm, file_rss, 0);
26383 + set_mm_counter(mm, anon_rss, 0);
26384 + vx_vmpages_sub(mm, mm->total_vm);
26385 + vx_vmlocked_sub(mm, mm->locked_vm);
26388 * Walk the list again, actually closing and freeing it,
26389 * with preemption enabled, without holding any MM locks.
26390 @@ -2025,7 +2033,8 @@ int insert_vm_struct(struct mm_struct *
26391 if (__vma && __vma->vm_start < vma->vm_end)
26393 if ((vma->vm_flags & VM_ACCOUNT) &&
26394 - security_vm_enough_memory(vma_pages(vma)))
26395 + (security_vm_enough_memory(vma_pages(vma)) ||
26396 + !vx_vmpages_avail(mm, vma_pages(vma))))
26398 vma_link(mm, vma, prev, rb_link, rb_parent);
26400 @@ -2098,6 +2107,8 @@ int may_expand_vm(struct mm_struct *mm,
26402 if (cur + npages > lim)
26404 + if (!vx_vmpages_avail(mm, npages))
26409 @@ -2168,7 +2179,6 @@ int install_special_mapping(struct mm_st
26413 - mm->total_vm += len >> PAGE_SHIFT;
26415 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26418 diff -NurpP --minimal linux-2.6.22.10/mm/mremap.c linux-2.6.22.10-vs2.2.0.5/mm/mremap.c
26419 --- linux-2.6.22.10/mm/mremap.c 2007-02-06 03:01:56 +0100
26420 +++ linux-2.6.22.10-vs2.2.0.5/mm/mremap.c 2007-06-15 02:37:04 +0200
26422 #include <linux/highmem.h>
26423 #include <linux/security.h>
26424 #include <linux/syscalls.h>
26425 +#include <linux/vs_memory.h>
26427 #include <asm/uaccess.h>
26428 #include <asm/cacheflush.h>
26429 @@ -212,7 +213,7 @@ static unsigned long move_vma(struct vm_
26430 * If this were a serious issue, we'd add a flag to do_munmap().
26432 hiwater_vm = mm->hiwater_vm;
26433 - mm->total_vm += new_len >> PAGE_SHIFT;
26434 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
26435 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
26437 if (do_munmap(mm, old_addr, old_len) < 0) {
26438 @@ -230,7 +231,7 @@ static unsigned long move_vma(struct vm_
26441 if (vm_flags & VM_LOCKED) {
26442 - mm->locked_vm += new_len >> PAGE_SHIFT;
26443 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
26444 if (new_len > old_len)
26445 make_pages_present(new_addr + old_len,
26446 new_addr + new_len);
26447 @@ -337,6 +338,9 @@ unsigned long do_mremap(unsigned long ad
26449 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
26451 + if (!vx_vmlocked_avail(current->mm,
26452 + (new_len - old_len) >> PAGE_SHIFT))
26455 if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
26457 @@ -365,10 +369,10 @@ unsigned long do_mremap(unsigned long ad
26458 vma_adjust(vma, vma->vm_start,
26459 addr + new_len, vma->vm_pgoff, NULL);
26461 - mm->total_vm += pages;
26462 + vx_vmpages_add(mm, pages);
26463 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
26464 if (vma->vm_flags & VM_LOCKED) {
26465 - mm->locked_vm += pages;
26466 + vx_vmlocked_add(mm, pages);
26467 make_pages_present(addr + old_len,
26470 diff -NurpP --minimal linux-2.6.22.10/mm/nommu.c linux-2.6.22.10-vs2.2.0.5/mm/nommu.c
26471 --- linux-2.6.22.10/mm/nommu.c 2007-07-09 13:20:04 +0200
26472 +++ linux-2.6.22.10-vs2.2.0.5/mm/nommu.c 2007-06-15 02:37:04 +0200
26473 @@ -936,7 +936,7 @@ unsigned long do_mmap_pgoff(struct file
26474 realalloc += kobjsize(vma);
26475 askedalloc += sizeof(*vma);
26477 - current->mm->total_vm += len >> PAGE_SHIFT;
26478 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
26480 add_nommu_vma(vma);
26482 @@ -1061,7 +1061,7 @@ int do_munmap(struct mm_struct *mm, unsi
26485 update_hiwater_vm(mm);
26486 - mm->total_vm -= len >> PAGE_SHIFT;
26487 + vx_vmpages_sub(mm, len >> PAGE_SHIFT);
26490 show_process_blocks();
26491 @@ -1093,7 +1093,7 @@ void exit_mmap(struct mm_struct * mm)
26492 printk("Exit_mmap:\n");
26495 - mm->total_vm = 0;
26496 + vx_vmpages_sub(mm, mm->total_vm);
26498 while ((tmp = mm->context.vmlist)) {
26499 mm->context.vmlist = tmp->next;
26500 diff -NurpP --minimal linux-2.6.22.10/mm/oom_kill.c linux-2.6.22.10-vs2.2.0.5/mm/oom_kill.c
26501 --- linux-2.6.22.10/mm/oom_kill.c 2007-07-09 13:20:04 +0200
26502 +++ linux-2.6.22.10-vs2.2.0.5/mm/oom_kill.c 2007-06-15 02:37:04 +0200
26504 #include <linux/cpuset.h>
26505 #include <linux/module.h>
26506 #include <linux/notifier.h>
26507 +#include <linux/vs_memory.h>
26509 int sysctl_panic_on_oom;
26510 /* #define DEBUG */
26511 @@ -66,6 +67,12 @@ unsigned long badness(struct task_struct
26512 points = mm->total_vm;
26515 + * add points for context badness
26518 + points += vx_badness(p, mm);
26521 * After this unlock we can no longer dereference local variable `mm'
26524 @@ -156,8 +163,8 @@ unsigned long badness(struct task_struct
26528 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %d points\n",
26529 - p->pid, p->comm, points);
26530 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26531 + p->pid, p->xid, p->comm, points);
26535 @@ -288,7 +295,8 @@ static void __oom_kill_task(struct task_
26539 - printk(KERN_ERR "Killed process %d (%s)\n", p->pid, p->comm);
26540 + printk(KERN_ERR "Killed process %d:#%u (%s)\n",
26541 + p->pid, p->xid, p->comm);
26544 * We give our sacrificial lamb high priority and access to
26545 @@ -358,8 +366,8 @@ static int oom_kill_process(struct task_
26549 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26550 - message, p->pid, p->comm, points);
26551 + printk(KERN_ERR "%s: kill process %d:#%u (%s) score %li or a child\n",
26552 + message, p->pid, p->xid, p->comm, points);
26554 /* Try to kill a child first */
26555 list_for_each(tsk, &p->children) {
26556 diff -NurpP --minimal linux-2.6.22.10/mm/page_alloc.c linux-2.6.22.10-vs2.2.0.5/mm/page_alloc.c
26557 --- linux-2.6.22.10/mm/page_alloc.c 2007-07-09 13:20:04 +0200
26558 +++ linux-2.6.22.10-vs2.2.0.5/mm/page_alloc.c 2007-06-17 05:54:20 +0200
26560 #include <linux/pfn.h>
26561 #include <linux/backing-dev.h>
26562 #include <linux/fault-inject.h>
26563 +#include <linux/vs_base.h>
26564 +#include <linux/vs_limit.h>
26566 #include <asm/tlbflush.h>
26567 #include <asm/div64.h>
26568 @@ -1488,6 +1490,9 @@ void si_meminfo(struct sysinfo *val)
26569 val->totalhigh = totalhigh_pages;
26570 val->freehigh = nr_free_highpages();
26571 val->mem_unit = PAGE_SIZE;
26573 + if (vx_flags(VXF_VIRT_MEM, 0))
26574 + vx_vsi_meminfo(val);
26577 EXPORT_SYMBOL(si_meminfo);
26578 @@ -1508,6 +1513,9 @@ void si_meminfo_node(struct sysinfo *val
26581 val->mem_unit = PAGE_SIZE;
26583 + if (vx_flags(VXF_VIRT_MEM, 0))
26584 + vx_vsi_meminfo(val);
26588 diff -NurpP --minimal linux-2.6.22.10/mm/rmap.c linux-2.6.22.10-vs2.2.0.5/mm/rmap.c
26589 --- linux-2.6.22.10/mm/rmap.c 2007-07-09 13:20:04 +0200
26590 +++ linux-2.6.22.10-vs2.2.0.5/mm/rmap.c 2007-07-07 03:52:54 +0200
26592 #include <linux/rcupdate.h>
26593 #include <linux/module.h>
26594 #include <linux/kallsyms.h>
26595 +#include <linux/vs_memory.h>
26597 #include <asm/tlbflush.h>
26599 diff -NurpP --minimal linux-2.6.22.10/mm/shmem.c linux-2.6.22.10-vs2.2.0.5/mm/shmem.c
26600 --- linux-2.6.22.10/mm/shmem.c 2007-07-09 13:20:04 +0200
26601 +++ linux-2.6.22.10-vs2.2.0.5/mm/shmem.c 2007-06-17 05:54:20 +0200
26603 #include <asm/pgtable.h>
26605 /* This magic number is used in glibc for posix shared memory */
26606 -#define TMPFS_MAGIC 0x01021994
26608 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
26609 #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
26610 @@ -1734,7 +1733,7 @@ static int shmem_statfs(struct dentry *d
26612 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26614 - buf->f_type = TMPFS_MAGIC;
26615 + buf->f_type = TMPFS_SUPER_MAGIC;
26616 buf->f_bsize = PAGE_CACHE_SIZE;
26617 buf->f_namelen = NAME_MAX;
26618 spin_lock(&sbinfo->stat_lock);
26619 @@ -2308,7 +2307,7 @@ static int shmem_fill_super(struct super
26620 sb->s_maxbytes = SHMEM_MAX_BYTES;
26621 sb->s_blocksize = PAGE_CACHE_SIZE;
26622 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26623 - sb->s_magic = TMPFS_MAGIC;
26624 + sb->s_magic = TMPFS_SUPER_MAGIC;
26625 sb->s_op = &shmem_ops;
26626 sb->s_time_gran = 1;
26627 #ifdef CONFIG_TMPFS_POSIX_ACL
26628 diff -NurpP --minimal linux-2.6.22.10/mm/slab.c linux-2.6.22.10-vs2.2.0.5/mm/slab.c
26629 --- linux-2.6.22.10/mm/slab.c 2007-07-09 13:20:04 +0200
26630 +++ linux-2.6.22.10-vs2.2.0.5/mm/slab.c 2007-07-09 13:11:54 +0200
26631 @@ -510,6 +510,8 @@ struct kmem_cache {
26632 #define STATS_INC_FREEMISS(x) do { } while (0)
26635 +#include "slab_vs.h"
26640 @@ -3314,6 +3316,7 @@ retry:
26642 obj = slab_get_obj(cachep, slabp, nodeid);
26643 check_slabp(cachep, slabp);
26644 + vx_slab_alloc(cachep, flags);
26645 l3->free_objects--;
26646 /* move slabp to correct slabp list: */
26647 list_del(&slabp->list);
26648 @@ -3386,6 +3389,7 @@ __cache_alloc_node(struct kmem_cache *ca
26649 /* ___cache_alloc_node can fall back to other nodes */
26650 ptr = ____cache_alloc_node(cachep, flags, nodeid);
26652 + vx_slab_alloc(cachep, flags);
26653 local_irq_restore(save_flags);
26654 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26656 @@ -3551,6 +3555,7 @@ static inline void __cache_free(struct k
26659 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26660 + vx_slab_free(cachep);
26662 if (cache_free_alien(cachep, objp))
26664 diff -NurpP --minimal linux-2.6.22.10/mm/slab_vs.h linux-2.6.22.10-vs2.2.0.5/mm/slab_vs.h
26665 --- linux-2.6.22.10/mm/slab_vs.h 1970-01-01 01:00:00 +0100
26666 +++ linux-2.6.22.10-vs2.2.0.5/mm/slab_vs.h 2007-06-15 02:37:04 +0200
26669 +#include <linux/vserver/context.h>
26671 +#include <linux/vs_context.h>
26674 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26676 + int what = gfp_zone(cachep->gfpflags);
26678 + if (!current->vx_info)
26681 + atomic_add(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26685 +void vx_slab_free(struct kmem_cache *cachep)
26687 + int what = gfp_zone(cachep->gfpflags);
26689 + if (!current->vx_info)
26692 + atomic_sub(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26695 diff -NurpP --minimal linux-2.6.22.10/mm/swapfile.c linux-2.6.22.10-vs2.2.0.5/mm/swapfile.c
26696 --- linux-2.6.22.10/mm/swapfile.c 2007-07-09 13:20:04 +0200
26697 +++ linux-2.6.22.10-vs2.2.0.5/mm/swapfile.c 2007-06-15 02:37:04 +0200
26699 #include <asm/pgtable.h>
26700 #include <asm/tlbflush.h>
26701 #include <linux/swapops.h>
26702 +#include <linux/vs_base.h>
26703 +#include <linux/vs_memory.h>
26705 DEFINE_SPINLOCK(swap_lock);
26706 unsigned int nr_swapfiles;
26707 @@ -1712,6 +1714,8 @@ void si_swapinfo(struct sysinfo *val)
26708 val->freeswap = nr_swap_pages + nr_to_be_unused;
26709 val->totalswap = total_swap_pages + nr_to_be_unused;
26710 spin_unlock(&swap_lock);
26711 + if (vx_flags(VXF_VIRT_MEM, 0))
26712 + vx_vsi_swapinfo(val);
26716 diff -NurpP --minimal linux-2.6.22.10/net/core/dev.c linux-2.6.22.10-vs2.2.0.5/net/core/dev.c
26717 --- linux-2.6.22.10/net/core/dev.c 2007-10-30 01:57:15 +0100
26718 +++ linux-2.6.22.10-vs2.2.0.5/net/core/dev.c 2007-09-05 03:05:53 +0200
26719 @@ -117,6 +117,8 @@
26720 #include <linux/err.h>
26721 #include <linux/ctype.h>
26722 #include <linux/if_arp.h>
26723 +#include <linux/vs_context.h> /* remove with NXF_HIDE_NETIF */
26724 +#include <linux/vs_network.h>
26727 * The list of packet types we will receive (as opposed to discard)
26728 @@ -2120,6 +2122,9 @@ static int dev_ifconf(char __user *arg)
26731 for_each_netdev(dev) {
26732 + if (vx_flags(VXF_HIDE_NETIF, 0) &&
26733 + !dev_in_nx_info(dev, current->nx_info))
26735 for (i = 0; i < NPROTO; i++) {
26736 if (gifconf_list[i]) {
26738 @@ -2183,6 +2188,10 @@ void dev_seq_stop(struct seq_file *seq,
26739 static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
26741 struct net_device_stats *stats = dev->get_stats(dev);
26742 + struct nx_info *nxi = current->nx_info;
26744 + if (vx_flags(VXF_HIDE_NETIF, 0) && !dev_in_nx_info(dev, nxi))
26747 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
26748 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
26749 diff -NurpP --minimal linux-2.6.22.10/net/core/rtnetlink.c linux-2.6.22.10-vs2.2.0.5/net/core/rtnetlink.c
26750 --- linux-2.6.22.10/net/core/rtnetlink.c 2007-07-09 13:20:05 +0200
26751 +++ linux-2.6.22.10-vs2.2.0.5/net/core/rtnetlink.c 2007-06-17 05:54:20 +0200
26753 #include <linux/security.h>
26754 #include <linux/mutex.h>
26755 #include <linux/if_addr.h>
26756 +#include <linux/vs_context.h> /* remove with NXF_HIDE_NETIF */
26758 #include <asm/uaccess.h>
26759 #include <asm/system.h>
26760 @@ -537,6 +538,9 @@ static int rtnl_dump_ifinfo(struct sk_bu
26763 for_each_netdev(dev) {
26764 + if (vx_info_flags(skb->sk->sk_vx_info, VXF_HIDE_NETIF, 0) &&
26765 + !dev_in_nx_info(dev, skb->sk->sk_nx_info))
26769 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26770 diff -NurpP --minimal linux-2.6.22.10/net/core/sock.c linux-2.6.22.10-vs2.2.0.5/net/core/sock.c
26771 --- linux-2.6.22.10/net/core/sock.c 2007-07-09 13:20:05 +0200
26772 +++ linux-2.6.22.10-vs2.2.0.5/net/core/sock.c 2007-06-15 02:37:04 +0200
26773 @@ -125,6 +125,9 @@
26774 #include <linux/ipsec.h>
26776 #include <linux/filter.h>
26777 +#include <linux/vs_socket.h>
26778 +#include <linux/vs_limit.h>
26779 +#include <linux/vs_context.h>
26782 #include <net/tcp.h>
26783 @@ -869,6 +872,8 @@ struct sock *sk_alloc(int family, gfp_t
26784 sk->sk_prot = sk->sk_prot_creator = prot;
26785 sock_lock_init(sk);
26787 + sock_vx_init(sk);
26788 + sock_nx_init(sk);
26790 if (security_sk_alloc(sk, family, priority))
26792 @@ -907,6 +912,11 @@ void sk_free(struct sock *sk)
26793 __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
26795 security_sk_free(sk);
26797 + clr_vx_info(&sk->sk_vx_info);
26799 + clr_nx_info(&sk->sk_nx_info);
26801 if (sk->sk_prot_creator->slab != NULL)
26802 kmem_cache_free(sk->sk_prot_creator->slab, sk);
26804 @@ -924,6 +934,8 @@ struct sock *sk_clone(const struct sock
26805 sock_copy(newsk, sk);
26808 + sock_vx_init(newsk);
26809 + sock_nx_init(newsk);
26810 sk_node_init(&newsk->sk_node);
26811 sock_lock_init(newsk);
26812 bh_lock_sock(newsk);
26813 @@ -969,6 +981,12 @@ struct sock *sk_clone(const struct sock
26814 newsk->sk_priority = 0;
26815 atomic_set(&newsk->sk_refcnt, 2);
26817 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26818 + newsk->sk_xid = sk->sk_xid;
26819 + vx_sock_inc(newsk);
26820 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26821 + newsk->sk_nid = sk->sk_nid;
26824 * Increment the counter in the same struct proto as the master
26825 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26826 @@ -1551,6 +1569,11 @@ void sock_init_data(struct socket *sock,
26828 sk->sk_stamp = ktime_set(-1L, -1L);
26830 + set_vx_info(&sk->sk_vx_info, current->vx_info);
26831 + sk->sk_xid = vx_current_xid();
26833 + set_nx_info(&sk->sk_nx_info, current->nx_info);
26834 + sk->sk_nid = nx_current_nid();
26835 atomic_set(&sk->sk_refcnt, 1);
26838 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/af_inet.c linux-2.6.22.10-vs2.2.0.5/net/ipv4/af_inet.c
26839 --- linux-2.6.22.10/net/ipv4/af_inet.c 2007-10-30 01:57:15 +0100
26840 +++ linux-2.6.22.10-vs2.2.0.5/net/ipv4/af_inet.c 2007-09-05 03:05:54 +0200
26841 @@ -115,6 +115,7 @@
26842 #ifdef CONFIG_IP_MROUTE
26843 #include <linux/mroute.h>
26845 +#include <linux/vs_limit.h>
26847 DEFINE_SNMP_STAT(struct linux_mib, net_statistics) __read_mostly;
26849 @@ -308,9 +309,11 @@ lookup_protocol:
26853 + if ((protocol == IPPROTO_ICMP) && vx_ccaps(VXC_RAW_ICMP))
26855 if (answer->capability > 0 && !capable(answer->capability))
26856 goto out_rcu_unlock;
26859 sock->ops = answer->ops;
26860 answer_prot = answer->prot;
26861 answer_no_check = answer->no_check;
26862 @@ -427,6 +430,10 @@ int inet_bind(struct socket *sock, struc
26863 unsigned short snum;
26866 + __u32 s_addr; /* Address used for validation */
26867 + __u32 s_addr1; /* Address used for socket */
26868 + __u32 s_addr2; /* Broadcast address for the socket */
26869 + struct nx_info *nxi = sk->sk_nx_info;
26871 /* If the socket has its own bind function then use it. (RAW) */
26872 if (sk->sk_prot->bind) {
26873 @@ -437,7 +444,40 @@ int inet_bind(struct socket *sock, struc
26874 if (addr_len < sizeof(struct sockaddr_in))
26877 - chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr);
26878 + s_addr = addr->sin_addr.s_addr;
26879 + s_addr1 = s_addr;
26880 + s_addr2 = 0xffffffffl;
26882 + vxdprintk(VXD_CBIT(net, 3),
26883 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
26884 + sk, sk->sk_nx_info, sk->sk_socket,
26885 + (sk->sk_socket?sk->sk_socket->flags:0),
26886 + NIPQUAD(s_addr));
26888 + __u32 v4_bcast = nxi->v4_bcast;
26889 + __u32 ipv4root = nxi->ipv4[0];
26890 + int nbipv4 = nxi->nbipv4;
26892 + if (s_addr == 0) {
26893 + /* bind to any for 1-n */
26894 + s_addr = ipv4root;
26895 + s_addr1 = (nbipv4 > 1) ? 0 : s_addr;
26896 + s_addr2 = v4_bcast;
26897 + } else if (s_addr == IPI_LOOPBACK) {
26898 + /* rewrite localhost to ipv4root */
26899 + s_addr = ipv4root;
26900 + s_addr1 = ipv4root;
26901 + } else if (s_addr != v4_bcast) {
26902 + /* normal address bind */
26903 + if (!addr_in_nx_info(nxi, s_addr))
26904 + return -EADDRNOTAVAIL;
26907 + chk_addr_ret = inet_addr_type(s_addr);
26909 + vxdprintk(VXD_CBIT(net, 3),
26910 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT ", " NIPQUAD_FMT,
26911 + sk, NIPQUAD(s_addr), NIPQUAD(s_addr1), NIPQUAD(s_addr2));
26913 /* Not specified by any standard per-se, however it breaks too
26914 * many applications when removed. It is unfortunate since
26915 @@ -449,7 +489,7 @@ int inet_bind(struct socket *sock, struc
26916 err = -EADDRNOTAVAIL;
26917 if (!sysctl_ip_nonlocal_bind &&
26919 - addr->sin_addr.s_addr != INADDR_ANY &&
26920 + s_addr != INADDR_ANY &&
26921 chk_addr_ret != RTN_LOCAL &&
26922 chk_addr_ret != RTN_MULTICAST &&
26923 chk_addr_ret != RTN_BROADCAST)
26924 @@ -474,7 +514,8 @@ int inet_bind(struct socket *sock, struc
26925 if (sk->sk_state != TCP_CLOSE || inet->num)
26926 goto out_release_sock;
26928 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
26929 + inet->rcv_saddr = inet->saddr = s_addr1;
26930 + inet->rcv_saddr2 = s_addr2;
26931 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26932 inet->saddr = 0; /* Use device */
26934 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/devinet.c linux-2.6.22.10-vs2.2.0.5/net/ipv4/devinet.c
26935 --- linux-2.6.22.10/net/ipv4/devinet.c 2007-10-30 01:57:15 +0100
26936 +++ linux-2.6.22.10-vs2.2.0.5/net/ipv4/devinet.c 2007-10-01 15:25:35 +0200
26938 #include <linux/sysctl.h>
26940 #include <linux/kmod.h>
26941 +#include <linux/vs_context.h>
26943 #include <net/arp.h>
26944 #include <net/ip.h>
26945 @@ -676,6 +677,9 @@ int devinet_ioctl(unsigned int cmd, void
26948 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
26949 + struct nx_info *nxi = current->nx_info;
26950 + int hide_netif = vx_flags(VXF_HIDE_NETIF, 0);
26952 if (tryaddrmatch) {
26953 /* Matthias Andree */
26954 /* compare label and address (4.4BSD style) */
26955 @@ -684,6 +688,8 @@ int devinet_ioctl(unsigned int cmd, void
26956 This is checked above. */
26957 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26958 ifap = &ifa->ifa_next) {
26959 + if (hide_netif && !ifa_in_nx_info(ifa, nxi))
26961 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26962 sin_orig.sin_addr.s_addr ==
26963 ifa->ifa_address) {
26964 @@ -696,9 +702,12 @@ int devinet_ioctl(unsigned int cmd, void
26965 comparing just the label */
26967 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26968 - ifap = &ifa->ifa_next)
26969 + ifap = &ifa->ifa_next) {
26970 + if (hide_netif && !ifa_in_nx_info(ifa, nxi))
26972 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
26978 @@ -849,6 +858,9 @@ static int inet_gifconf(struct net_devic
26981 for (; ifa; ifa = ifa->ifa_next) {
26982 + if (vx_flags(VXF_HIDE_NETIF, 0) &&
26983 + !ifa_in_nx_info(ifa, current->nx_info))
26986 done += sizeof(ifr);
26988 @@ -1179,6 +1191,7 @@ static int inet_dump_ifaddr(struct sk_bu
26989 struct net_device *dev;
26990 struct in_device *in_dev;
26991 struct in_ifaddr *ifa;
26992 + struct sock *sk = skb->sk;
26993 int s_ip_idx, s_idx = cb->args[0];
26995 s_ip_idx = ip_idx = cb->args[1];
26996 @@ -1193,6 +1206,9 @@ static int inet_dump_ifaddr(struct sk_bu
26998 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
26999 ifa = ifa->ifa_next, ip_idx++) {
27000 + if (sk && vx_info_flags(sk->sk_vx_info, VXF_HIDE_NETIF, 0) &&
27001 + !ifa_in_nx_info(ifa, sk->sk_nx_info))
27003 if (ip_idx < s_ip_idx)
27005 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
27006 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/fib_hash.c linux-2.6.22.10-vs2.2.0.5/net/ipv4/fib_hash.c
27007 --- linux-2.6.22.10/net/ipv4/fib_hash.c 2007-07-09 13:20:05 +0200
27008 +++ linux-2.6.22.10-vs2.2.0.5/net/ipv4/fib_hash.c 2007-06-15 02:37:04 +0200
27010 #include <linux/skbuff.h>
27011 #include <linux/netlink.h>
27012 #include <linux/init.h>
27013 +#include <linux/vs_context.h>
27015 #include <net/ip.h>
27016 #include <net/protocol.h>
27017 @@ -982,6 +983,8 @@ static unsigned fib_flag_trans(int type,
27021 +extern int dev_in_nx_info(struct net_device *, struct nx_info *);
27024 * This outputs /proc/net/route.
27026 @@ -1012,7 +1015,8 @@ static int fib_seq_show(struct seq_file
27027 prefix = f->fn_key;
27028 mask = FZ_MASK(iter->zone);
27029 flags = fib_flag_trans(fa->fa_type, mask, fi);
27031 + if (fi && (!vx_flags(VXF_HIDE_NETIF, 0) ||
27032 + dev_in_nx_info(fi->fib_dev, current->nx_info)))
27033 snprintf(bf, sizeof(bf),
27034 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u",
27035 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
27036 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/inet_connection_sock.c linux-2.6.22.10-vs2.2.0.5/net/ipv4/inet_connection_sock.c
27037 --- linux-2.6.22.10/net/ipv4/inet_connection_sock.c 2007-07-09 13:20:05 +0200
27038 +++ linux-2.6.22.10-vs2.2.0.5/net/ipv4/inet_connection_sock.c 2007-06-15 02:37:04 +0200
27039 @@ -37,7 +37,6 @@ int sysctl_local_port_range[2] = { 32768
27040 int inet_csk_bind_conflict(const struct sock *sk,
27041 const struct inet_bind_bucket *tb)
27043 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
27045 struct hlist_node *node;
27046 int reuse = sk->sk_reuse;
27047 @@ -50,9 +49,8 @@ int inet_csk_bind_conflict(const struct
27048 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
27049 if (!reuse || !sk2->sk_reuse ||
27050 sk2->sk_state == TCP_LISTEN) {
27051 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27052 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
27053 - sk2_rcv_saddr == sk_rcv_saddr)
27054 + if (nx_addr_conflict(sk->sk_nx_info,
27055 + inet_rcv_saddr(sk), sk2))
27059 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/inet_diag.c linux-2.6.22.10-vs2.2.0.5/net/ipv4/inet_diag.c
27060 --- linux-2.6.22.10/net/ipv4/inet_diag.c 2007-10-30 01:57:15 +0100
27061 +++ linux-2.6.22.10-vs2.2.0.5/net/ipv4/inet_diag.c 2007-10-01 15:25:35 +0200
27062 @@ -697,6 +697,8 @@ static int inet_diag_dump(struct sk_buff
27063 sk_for_each(sk, node, &hashinfo->listening_hash[i]) {
27064 struct inet_sock *inet = inet_sk(sk);
27066 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27071 @@ -757,6 +759,8 @@ skip_listen_ht:
27072 sk_for_each(sk, node, &head->chain) {
27073 struct inet_sock *inet = inet_sk(sk);
27075 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27079 if (!(r->idiag_states & (1 << sk->sk_state)))
27080 @@ -781,6 +785,8 @@ next_normal:
27081 inet_twsk_for_each(tw, node,
27084 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27088 if (r->id.idiag_sport != tw->tw_sport &&
27089 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/inet_hashtables.c linux-2.6.22.10-vs2.2.0.5/net/ipv4/inet_hashtables.c
27090 --- linux-2.6.22.10/net/ipv4/inet_hashtables.c 2007-05-02 19:25:40 +0200
27091 +++ linux-2.6.22.10-vs2.2.0.5/net/ipv4/inet_hashtables.c 2007-06-15 02:37:04 +0200
27092 @@ -140,11 +140,10 @@ static struct sock *inet_lookup_listener
27093 const __be32 rcv_saddr = inet->rcv_saddr;
27094 int score = sk->sk_family == PF_INET ? 1 : 0;
27097 - if (rcv_saddr != daddr)
27099 + if (inet_addr_match(sk->sk_nx_info, daddr, rcv_saddr))
27104 if (sk->sk_bound_dev_if) {
27105 if (sk->sk_bound_dev_if != dif)
27107 @@ -175,7 +174,7 @@ struct sock *__inet_lookup_listener(stru
27108 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
27110 if (inet->num == hnum && !sk->sk_node.next &&
27111 - (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
27112 + inet_addr_match(sk->sk_nx_info, daddr, inet->rcv_saddr) &&
27113 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
27114 !sk->sk_bound_dev_if)
27116 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/raw.c linux-2.6.22.10-vs2.2.0.5/net/ipv4/raw.c
27117 --- linux-2.6.22.10/net/ipv4/raw.c 2007-07-09 13:20:06 +0200
27118 +++ linux-2.6.22.10-vs2.2.0.5/net/ipv4/raw.c 2007-06-15 02:37:04 +0200
27119 @@ -101,6 +101,27 @@ static void raw_v4_unhash(struct sock *s
27120 write_unlock_bh(&raw_v4_lock);
27125 + * Check if a given address matches for a socket
27127 + * nxi: the socket's nx_info if any
27128 + * addr: to be verified address
27129 + * saddr/baddr: socket addresses
27131 +static inline int raw_addr_match (
27132 + struct nx_info *nxi,
27137 + if (addr && (saddr == addr || baddr == addr))
27140 + return addr_in_nx_info(nxi, addr);
27144 struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num,
27145 __be32 raddr, __be32 laddr,
27147 @@ -112,7 +133,8 @@ struct sock *__raw_v4_lookup(struct sock
27149 if (inet->num == num &&
27150 !(inet->daddr && inet->daddr != raddr) &&
27151 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
27152 + raw_addr_match(sk->sk_nx_info, laddr,
27153 + inet->rcv_saddr, inet->rcv_saddr2) &&
27154 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
27155 goto found; /* gotcha */
27157 @@ -314,6 +336,11 @@ static int raw_send_hdrinc(struct sock *
27158 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
27162 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW)
27163 + && (!addr_in_nx_info(sk->sk_nx_info, iph->saddr)))
27166 err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
27169 @@ -325,6 +352,7 @@ out:
27176 IP_INC_STATS(IPSTATS_MIB_OUTDISCARDS);
27177 @@ -491,6 +519,12 @@ static int raw_sendmsg(struct kiocb *ioc
27180 security_sk_classify_flow(sk, &fl);
27181 + if (sk->sk_nx_info) {
27182 + err = ip_find_src(sk->sk_nx_info, &rt, &fl);
27187 err = ip_route_output_flow(&rt, &fl, sk, 1);
27190 @@ -795,7 +829,8 @@ static struct sock *raw_get_first(struct
27191 struct hlist_node *node;
27193 sk_for_each(sk, node, &raw_v4_htable[state->bucket])
27194 - if (sk->sk_family == PF_INET)
27195 + if (sk->sk_family == PF_INET &&
27196 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27200 @@ -811,7 +846,8 @@ static struct sock *raw_get_next(struct
27204 - } while (sk && sk->sk_family != PF_INET);
27205 + } while (sk && (sk->sk_family != PF_INET ||
27206 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27208 if (!sk && ++state->bucket < RAWV4_HTABLE_SIZE) {
27209 sk = sk_head(&raw_v4_htable[state->bucket]);
27210 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/tcp.c linux-2.6.22.10-vs2.2.0.5/net/ipv4/tcp.c
27211 --- linux-2.6.22.10/net/ipv4/tcp.c 2007-10-30 01:57:15 +0100
27212 +++ linux-2.6.22.10-vs2.2.0.5/net/ipv4/tcp.c 2007-09-05 03:05:54 +0200
27213 @@ -258,6 +258,7 @@
27214 #include <linux/cache.h>
27215 #include <linux/err.h>
27216 #include <linux/crypto.h>
27217 +#include <linux/in.h>
27219 #include <net/icmp.h>
27220 #include <net/tcp.h>
27221 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/tcp_ipv4.c linux-2.6.22.10-vs2.2.0.5/net/ipv4/tcp_ipv4.c
27222 --- linux-2.6.22.10/net/ipv4/tcp_ipv4.c 2007-10-30 01:57:15 +0100
27223 +++ linux-2.6.22.10-vs2.2.0.5/net/ipv4/tcp_ipv4.c 2007-09-05 03:05:54 +0200
27224 @@ -1975,6 +1975,12 @@ static void *listening_get_next(struct s
27225 req = req->dl_next;
27228 + vxdprintk(VXD_CBIT(net, 6),
27229 + "sk,req: %p [#%d] (from %d)", req->sk,
27230 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27232 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27234 if (req->rsk_ops->family == st->family) {
27237 @@ -1999,6 +2005,10 @@ get_req:
27240 sk_for_each_from(sk, node) {
27241 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27242 + sk, sk->sk_nid, nx_current_nid());
27243 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27245 if (sk->sk_family == st->family) {
27248 @@ -2050,18 +2060,26 @@ static void *established_get_first(struc
27250 read_lock(&tcp_hashinfo.ehash[st->bucket].lock);
27251 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27252 - if (sk->sk_family != st->family) {
27253 + vxdprintk(VXD_CBIT(net, 6),
27254 + "sk,egf: %p [#%d] (from %d)",
27255 + sk, sk->sk_nid, nx_current_nid());
27256 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27258 + if (sk->sk_family != st->family)
27264 st->state = TCP_SEQ_STATE_TIME_WAIT;
27265 inet_twsk_for_each(tw, node,
27266 &tcp_hashinfo.ehash[st->bucket].twchain) {
27267 - if (tw->tw_family != st->family) {
27268 + vxdprintk(VXD_CBIT(net, 6),
27269 + "tw: %p [#%d] (from %d)",
27270 + tw, tw->tw_nid, nx_current_nid());
27271 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27273 + if (tw->tw_family != st->family)
27279 @@ -2085,7 +2103,8 @@ static void *established_get_next(struct
27283 - while (tw && tw->tw_family != st->family) {
27284 + while (tw && (tw->tw_family != st->family ||
27285 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27289 @@ -2109,6 +2128,11 @@ get_tw:
27292 sk_for_each_from(sk, node) {
27293 + vxdprintk(VXD_CBIT(net, 6),
27294 + "sk,egn: %p [#%d] (from %d)",
27295 + sk, sk->sk_nid, nx_current_nid());
27296 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27298 if (sk->sk_family == st->family)
27301 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/tcp_minisocks.c linux-2.6.22.10-vs2.2.0.5/net/ipv4/tcp_minisocks.c
27302 --- linux-2.6.22.10/net/ipv4/tcp_minisocks.c 2007-07-09 13:20:06 +0200
27303 +++ linux-2.6.22.10-vs2.2.0.5/net/ipv4/tcp_minisocks.c 2007-06-15 02:37:04 +0200
27305 #include <net/inet_common.h>
27306 #include <net/xfrm.h>
27308 +#include <linux/vs_limit.h>
27309 +#include <linux/vs_socket.h>
27310 +#include <linux/vs_context.h>
27312 #ifdef CONFIG_SYSCTL
27313 #define SYNC_INIT 0 /* let the user enable it */
27315 @@ -293,6 +297,11 @@ void tcp_time_wait(struct sock *sk, int
27316 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
27317 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27319 + tw->tw_xid = sk->sk_xid;
27320 + tw->tw_vx_info = NULL;
27321 + tw->tw_nid = sk->sk_nid;
27322 + tw->tw_nx_info = NULL;
27324 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27325 if (tw->tw_family == PF_INET6) {
27326 struct ipv6_pinfo *np = inet6_sk(sk);
27327 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/udp.c linux-2.6.22.10-vs2.2.0.5/net/ipv4/udp.c
27328 --- linux-2.6.22.10/net/ipv4/udp.c 2007-07-09 13:20:06 +0200
27329 +++ linux-2.6.22.10-vs2.2.0.5/net/ipv4/udp.c 2007-06-17 06:02:02 +0200
27330 @@ -221,11 +221,8 @@ int udp_get_port(struct sock *sk, unsign
27332 int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27334 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27336 return ( !ipv6_only_sock(sk2) &&
27337 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
27338 - inet1->rcv_saddr == inet2->rcv_saddr ));
27339 + nx_addr_conflict(sk1->sk_nx_info, inet_rcv_saddr(sk1), sk2));
27342 static inline int udp_v4_get_port(struct sock *sk, unsigned short snum)
27343 @@ -246,15 +243,22 @@ static struct sock *__udp4_lib_lookup(__
27346 read_lock(&udp_hash_lock);
27348 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
27349 struct inet_sock *inet = inet_sk(sk);
27351 if (sk->sk_hash == hnum && !ipv6_only_sock(sk)) {
27352 int score = (sk->sk_family == PF_INET ? 1 : 0);
27354 if (inet->rcv_saddr) {
27355 if (inet->rcv_saddr != daddr)
27358 + } else if (sk->sk_nx_info) {
27359 + if (addr_in_nx_info(sk->sk_nx_info, daddr))
27365 if (inet->daddr != saddr)
27366 @@ -280,6 +284,7 @@ static struct sock *__udp4_lib_lookup(__
27373 read_unlock(&udp_hash_lock);
27374 @@ -301,7 +306,8 @@ static inline struct sock *udp_v4_mcast_
27375 if (s->sk_hash != hnum ||
27376 (inet->daddr && inet->daddr != rmt_addr) ||
27377 (inet->dport != rmt_port && inet->dport) ||
27378 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
27379 + (inet->rcv_saddr && inet->rcv_saddr != loc_addr &&
27380 + inet->rcv_saddr2 && inet->rcv_saddr2 != loc_addr) ||
27381 ipv6_only_sock(s) ||
27382 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27384 @@ -631,7 +637,20 @@ int udp_sendmsg(struct kiocb *iocb, stru
27385 .uli_u = { .ports =
27386 { .sport = inet->sport,
27387 .dport = dport } } };
27388 + struct nx_info *nxi = sk->sk_nx_info;
27390 security_sk_classify_flow(sk, &fl);
27392 + err = ip_find_src(nxi, &rt, &fl);
27395 + if (daddr == IPI_LOOPBACK && !nx_check(0, VS_ADMIN))
27396 + daddr = fl.fl4_dst = nxi->ipv4[0];
27397 +#ifdef CONFIG_VSERVER_REMAP_SADDR
27398 + if (saddr == IPI_LOOPBACK && !nx_check(0, VS_ADMIN))
27399 + saddr = fl.fl4_src = nxi->ipv4[0];
27402 err = ip_route_output_flow(&rt, &fl, sk, 1);
27404 if (err == -ENETUNREACH)
27405 @@ -1551,7 +1570,8 @@ static struct sock *udp_get_first(struct
27406 for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) {
27407 struct hlist_node *node;
27408 sk_for_each(sk, node, state->hashtable + state->bucket) {
27409 - if (sk->sk_family == state->family)
27410 + if (sk->sk_family == state->family &&
27411 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27415 @@ -1568,7 +1588,8 @@ static struct sock *udp_get_next(struct
27419 - } while (sk && sk->sk_family != state->family);
27420 + } while (sk && (sk->sk_family != state->family ||
27421 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27423 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
27424 sk = sk_head(state->hashtable + state->bucket);
27425 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/addrconf.c linux-2.6.22.10-vs2.2.0.5/net/ipv6/addrconf.c
27426 --- linux-2.6.22.10/net/ipv6/addrconf.c 2007-10-30 01:57:15 +0100
27427 +++ linux-2.6.22.10-vs2.2.0.5/net/ipv6/addrconf.c 2007-10-01 15:25:35 +0200
27428 @@ -2772,7 +2772,10 @@ static void if6_seq_stop(struct seq_file
27429 static int if6_seq_show(struct seq_file *seq, void *v)
27431 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27434 + /* no ipv6 inside a vserver for now */
27435 + if (nx_check(0, VS_ADMIN|VS_WATCH))
27437 NIP6_SEQFMT " %02x %02x %02x %02x %8s\n",
27439 ifp->idev->dev->ifindex,
27440 @@ -3255,6 +3258,10 @@ static int inet6_dump_addr(struct sk_buf
27441 struct ifmcaddr6 *ifmca;
27442 struct ifacaddr6 *ifaca;
27444 + /* no ipv6 inside a vserver for now */
27445 + if (skb->sk && skb->sk->sk_vx_info)
27448 s_idx = cb->args[0];
27449 s_ip_idx = ip_idx = cb->args[1];
27451 @@ -3578,6 +3585,10 @@ static int inet6_dump_ifinfo(struct sk_b
27452 struct net_device *dev;
27453 struct inet6_dev *idev;
27455 + /* no ipv6 inside a vserver for now */
27456 + if (skb->sk && skb->sk->sk_vx_info)
27459 read_lock(&dev_base_lock);
27461 for_each_netdev(dev) {
27462 diff -NurpP --minimal linux-2.6.22.10/net/netlink/af_netlink.c linux-2.6.22.10-vs2.2.0.5/net/netlink/af_netlink.c
27463 --- linux-2.6.22.10/net/netlink/af_netlink.c 2007-07-09 13:20:07 +0200
27464 +++ linux-2.6.22.10-vs2.2.0.5/net/netlink/af_netlink.c 2007-06-15 05:43:32 +0200
27466 #include <linux/audit.h>
27467 #include <linux/selinux.h>
27468 #include <linux/mutex.h>
27469 +#include <linux/vs_context.h>
27470 +#include <linux/vs_network.h>
27471 +#include <linux/vs_limit.h>
27473 #include <net/sock.h>
27474 #include <net/scm.h>
27475 diff -NurpP --minimal linux-2.6.22.10/net/socket.c linux-2.6.22.10-vs2.2.0.5/net/socket.c
27476 --- linux-2.6.22.10/net/socket.c 2007-10-30 01:57:15 +0100
27477 +++ linux-2.6.22.10-vs2.2.0.5/net/socket.c 2007-09-05 03:05:54 +0200
27480 #include <net/sock.h>
27481 #include <linux/netfilter.h>
27482 +#include <linux/vs_base.h>
27483 +#include <linux/vs_socket.h>
27485 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
27486 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
27487 @@ -543,7 +545,7 @@ static inline int __sock_sendmsg(struct
27488 struct msghdr *msg, size_t size)
27490 struct sock_iocb *si = kiocb_to_siocb(iocb);
27496 @@ -554,7 +556,22 @@ static inline int __sock_sendmsg(struct
27500 - return sock->ops->sendmsg(iocb, sock, msg, size);
27501 + len = sock->ops->sendmsg(iocb, sock, msg, size);
27504 + vx_sock_send(sock->sk, size);
27506 + vx_sock_fail(sock->sk, size);
27508 + vxdprintk(VXD_CBIT(net, 7),
27509 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27511 + (sock->sk)?sock->sk->sk_nx_info:0,
27512 + (sock->sk)?sock->sk->sk_vx_info:0,
27513 + (sock->sk)?sock->sk->sk_xid:0,
27514 + (sock->sk)?sock->sk->sk_nid:0,
27515 + (unsigned int)size, len);
27519 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
27520 @@ -623,7 +640,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
27521 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
27522 struct msghdr *msg, size_t size, int flags)
27526 struct sock_iocb *si = kiocb_to_siocb(iocb);
27529 @@ -636,7 +653,18 @@ static inline int __sock_recvmsg(struct
27533 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
27534 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
27535 + if ((len >= 0) && sock->sk)
27536 + vx_sock_recv(sock->sk, len);
27537 + vxdprintk(VXD_CBIT(net, 7),
27538 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27540 + (sock->sk)?sock->sk->sk_nx_info:0,
27541 + (sock->sk)?sock->sk->sk_vx_info:0,
27542 + (sock->sk)?sock->sk->sk_xid:0,
27543 + (sock->sk)?sock->sk->sk_nid:0,
27544 + (unsigned int)size, len);
27548 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
27549 @@ -1090,6 +1118,10 @@ static int __sock_create(int family, int
27550 if (type < 0 || type >= SOCK_MAX)
27553 + /* disable IPv6 inside vservers for now */
27554 + if (family == PF_INET6 && !nx_check(0, VS_ADMIN))
27555 + return -EAFNOSUPPORT;
27559 This uglymoron is moved from INET layer to here to avoid
27560 @@ -1207,6 +1239,7 @@ asmlinkage long sys_socket(int family, i
27564 + set_bit(SOCK_USER_SOCKET, &sock->flags);
27565 retval = sock_map_fd(sock);
27568 @@ -1239,10 +1272,12 @@ asmlinkage long sys_socketpair(int famil
27569 err = sock_create(family, type, protocol, &sock1);
27572 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
27574 err = sock_create(family, type, protocol, &sock2);
27576 goto out_release_1;
27577 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
27579 err = sock1->ops->socketpair(sock1, sock2);
27581 diff -NurpP --minimal linux-2.6.22.10/net/sunrpc/auth.c linux-2.6.22.10-vs2.2.0.5/net/sunrpc/auth.c
27582 --- linux-2.6.22.10/net/sunrpc/auth.c 2007-05-02 19:25:48 +0200
27583 +++ linux-2.6.22.10-vs2.2.0.5/net/sunrpc/auth.c 2007-06-15 02:37:04 +0200
27585 #include <linux/errno.h>
27586 #include <linux/sunrpc/clnt.h>
27587 #include <linux/spinlock.h>
27588 +#include <linux/vs_tag.h>
27591 # define RPCDBG_FACILITY RPCDBG_AUTH
27592 @@ -263,6 +264,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
27593 struct auth_cred acred = {
27594 .uid = current->fsuid,
27595 .gid = current->fsgid,
27596 + .tag = dx_current_tag(),
27597 .group_info = current->group_info,
27599 struct rpc_cred *ret;
27600 @@ -282,6 +284,7 @@ rpcauth_bindcred(struct rpc_task *task)
27601 struct auth_cred acred = {
27602 .uid = current->fsuid,
27603 .gid = current->fsgid,
27604 + .tag = dx_current_tag(),
27605 .group_info = current->group_info,
27607 struct rpc_cred *ret;
27608 diff -NurpP --minimal linux-2.6.22.10/net/sunrpc/auth_unix.c linux-2.6.22.10-vs2.2.0.5/net/sunrpc/auth_unix.c
27609 --- linux-2.6.22.10/net/sunrpc/auth_unix.c 2007-05-02 19:25:48 +0200
27610 +++ linux-2.6.22.10-vs2.2.0.5/net/sunrpc/auth_unix.c 2007-06-15 02:37:04 +0200
27611 @@ -11,12 +11,14 @@
27612 #include <linux/module.h>
27613 #include <linux/sunrpc/clnt.h>
27614 #include <linux/sunrpc/auth.h>
27615 +#include <linux/vs_tag.h>
27617 #define NFS_NGROUPS 16
27620 struct rpc_cred uc_base;
27623 gid_t uc_gids[NFS_NGROUPS];
27625 #define uc_uid uc_base.cr_uid
27626 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
27627 if (flags & RPCAUTH_LOOKUP_ROOTCREDS) {
27630 + cred->uc_tag = dx_current_tag();
27631 cred->uc_gids[0] = NOGROUP;
27633 int groups = acred->group_info->ngroups;
27634 @@ -87,6 +90,7 @@ unx_create_cred(struct rpc_auth *auth, s
27636 cred->uc_uid = acred->uid;
27637 cred->uc_gid = acred->gid;
27638 + cred->uc_tag = acred->tag;
27639 for (i = 0; i < groups; i++)
27640 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
27641 if (i < NFS_NGROUPS)
27642 @@ -118,7 +122,8 @@ unx_match(struct auth_cred *acred, struc
27645 if (cred->uc_uid != acred->uid
27646 - || cred->uc_gid != acred->gid)
27647 + || cred->uc_gid != acred->gid
27648 + || cred->uc_tag != acred->tag)
27651 groups = acred->group_info->ngroups;
27652 @@ -144,7 +149,7 @@ unx_marshal(struct rpc_task *task, __be3
27653 struct rpc_clnt *clnt = task->tk_client;
27654 struct unx_cred *cred = (struct unx_cred *) task->tk_msg.rpc_cred;
27655 __be32 *base, *hold;
27659 *p++ = htonl(RPC_AUTH_UNIX);
27661 @@ -154,9 +159,12 @@ unx_marshal(struct rpc_task *task, __be3
27662 * Copy the UTS nodename captured when the client was created.
27664 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
27665 + tag = task->tk_client->cl_tag;
27667 - *p++ = htonl((u32) cred->uc_uid);
27668 - *p++ = htonl((u32) cred->uc_gid);
27669 + *p++ = htonl((u32) TAGINO_UID(tag,
27670 + cred->uc_uid, cred->uc_tag));
27671 + *p++ = htonl((u32) TAGINO_GID(tag,
27672 + cred->uc_gid, cred->uc_tag));
27674 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
27675 *p++ = htonl((u32) cred->uc_gids[i]);
27676 diff -NurpP --minimal linux-2.6.22.10/net/sunrpc/clnt.c linux-2.6.22.10-vs2.2.0.5/net/sunrpc/clnt.c
27677 --- linux-2.6.22.10/net/sunrpc/clnt.c 2007-07-09 13:20:13 +0200
27678 +++ linux-2.6.22.10-vs2.2.0.5/net/sunrpc/clnt.c 2007-06-15 02:37:04 +0200
27680 #include <linux/smp_lock.h>
27681 #include <linux/utsname.h>
27682 #include <linux/workqueue.h>
27683 +#include <linux/vs_cvirt.h>
27685 #include <linux/sunrpc/clnt.h>
27686 #include <linux/sunrpc/rpc_pipe_fs.h>
27687 @@ -249,7 +250,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
27688 clnt->cl_oneshot = 1;
27689 if (args->flags & RPC_CLNT_CREATE_DISCRTRY)
27690 clnt->cl_discrtry = 1;
27692 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
27693 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
27694 + clnt->cl_tag = 1; */
27697 EXPORT_SYMBOL_GPL(rpc_create);
27698 diff -NurpP --minimal linux-2.6.22.10/net/unix/af_unix.c linux-2.6.22.10-vs2.2.0.5/net/unix/af_unix.c
27699 --- linux-2.6.22.10/net/unix/af_unix.c 2007-07-09 13:20:13 +0200
27700 +++ linux-2.6.22.10-vs2.2.0.5/net/unix/af_unix.c 2007-06-17 05:54:20 +0200
27701 @@ -115,6 +115,8 @@
27702 #include <linux/mount.h>
27703 #include <net/checksum.h>
27704 #include <linux/security.h>
27705 +#include <linux/vs_context.h>
27706 +#include <linux/vs_limit.h>
27708 int sysctl_unix_max_dgram_qlen __read_mostly = 10;
27710 @@ -252,6 +254,8 @@ static struct sock *__unix_find_socket_b
27711 sk_for_each(s, node, &unix_socket_table[hash ^ type]) {
27712 struct unix_sock *u = unix_sk(s);
27714 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27716 if (u->addr->len == len &&
27717 !memcmp(u->addr->name, sunname, len))
27719 @@ -807,7 +811,7 @@ static int unix_bind(struct socket *sock
27722 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
27723 - err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
27724 + err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0, NULL);
27726 goto out_mknod_dput;
27727 mutex_unlock(&nd.dentry->d_inode->i_mutex);
27728 diff -NurpP --minimal linux-2.6.22.10/net/x25/af_x25.c linux-2.6.22.10-vs2.2.0.5/net/x25/af_x25.c
27729 --- linux-2.6.22.10/net/x25/af_x25.c 2007-07-09 13:20:13 +0200
27730 +++ linux-2.6.22.10-vs2.2.0.5/net/x25/af_x25.c 2007-06-15 02:37:04 +0200
27731 @@ -500,7 +500,10 @@ static int x25_create(struct socket *soc
27735 - sock_init_data(sock, sk);
27736 + sk->sk_socket = sock;
27737 + sk->sk_type = sock->type;
27738 + sk->sk_sleep = &sock->wait;
27741 x25_init_timers(sk);
27743 diff -NurpP --minimal linux-2.6.22.10/security/Kconfig linux-2.6.22.10-vs2.2.0.5/security/Kconfig
27744 --- linux-2.6.22.10/security/Kconfig 2006-11-30 21:19:47 +0100
27745 +++ linux-2.6.22.10-vs2.2.0.5/security/Kconfig 2007-06-15 02:37:04 +0200
27746 @@ -6,6 +6,7 @@ menu "Security options"
27749 bool "Enable access key retention support"
27750 + depends on !VSERVER_SECURITY
27752 This option provides support for retaining authentication tokens and
27753 access keys in the kernel.
27754 diff -NurpP --minimal linux-2.6.22.10/security/commoncap.c linux-2.6.22.10-vs2.2.0.5/security/commoncap.c
27755 --- linux-2.6.22.10/security/commoncap.c 2007-07-09 13:20:14 +0200
27756 +++ linux-2.6.22.10-vs2.2.0.5/security/commoncap.c 2007-06-15 02:37:04 +0200
27757 @@ -22,10 +22,11 @@
27758 #include <linux/ptrace.h>
27759 #include <linux/xattr.h>
27760 #include <linux/hugetlb.h>
27761 +#include <linux/vs_context.h>
27763 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
27765 - NETLINK_CB(skb).eff_cap = current->cap_effective;
27766 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
27770 @@ -43,7 +44,7 @@ EXPORT_SYMBOL(cap_netlink_recv);
27771 int cap_capable (struct task_struct *tsk, int cap)
27773 /* Derived from include/linux/sched.h:capable. */
27774 - if (cap_raised(tsk->cap_effective, cap))
27775 + if (vx_cap_raised(tsk->vx_info, tsk->cap_effective, cap))
27779 @@ -141,7 +142,8 @@ void cap_bprm_apply_creds (struct linux_
27780 /* Derived from fs/exec.c:compute_creds. */
27781 kernel_cap_t new_permitted, working;
27783 - new_permitted = cap_intersect (bprm->cap_permitted, cap_bset);
27784 + new_permitted = cap_intersect (bprm->cap_permitted,
27785 + vx_current_cap_bset());
27786 working = cap_intersect (bprm->cap_inheritable,
27787 current->cap_inheritable);
27788 new_permitted = cap_combine (new_permitted, working);
27789 @@ -310,7 +312,8 @@ void cap_task_reparent_to_init (struct t
27791 int cap_syslog (int type)
27793 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
27794 + if ((type != 3 && type != 10) &&
27795 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
27799 diff -NurpP --minimal linux-2.6.22.10/security/dummy.c linux-2.6.22.10-vs2.2.0.5/security/dummy.c
27800 --- linux-2.6.22.10/security/dummy.c 2007-05-02 19:25:51 +0200
27801 +++ linux-2.6.22.10-vs2.2.0.5/security/dummy.c 2007-06-15 02:37:04 +0200
27803 #include <linux/hugetlb.h>
27804 #include <linux/ptrace.h>
27805 #include <linux/file.h>
27806 +#include <linux/vs_context.h>
27808 static int dummy_ptrace (struct task_struct *parent, struct task_struct *child)
27810 @@ -678,7 +679,7 @@ static int dummy_sem_semop (struct sem_a
27812 static int dummy_netlink_send (struct sock *sk, struct sk_buff *skb)
27814 - NETLINK_CB(skb).eff_cap = current->cap_effective;
27815 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
27819 diff -NurpP --minimal linux-2.6.22.10/security/selinux/hooks.c linux-2.6.22.10-vs2.2.0.5/security/selinux/hooks.c
27820 --- linux-2.6.22.10/security/selinux/hooks.c 2007-10-30 01:57:15 +0100
27821 +++ linux-2.6.22.10-vs2.2.0.5/security/selinux/hooks.c 2007-10-30 01:24:36 +0100
27823 #include <linux/dccp.h>
27824 #include <linux/quota.h>
27825 #include <linux/un.h> /* for Unix socket types */
27826 -#include <net/af_unix.h> /* for Unix socket types */
27827 #include <linux/parser.h>
27828 #include <linux/nfs_mount.h>
27829 #include <net/ipv6.h>