1 diff -NurpP --minimal linux-2.6.22.10/Documentation/vserver/debug.txt linux-2.6.22.10-vs2.3.0.29/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.3.0.29/Documentation/vserver/debug.txt 2007-08-05 20:53:12 +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.3.0.29/Makefile
160 --- linux-2.6.22.10/Makefile 2007-10-30 01:57:11 +0100
161 +++ linux-2.6.22.10-vs2.3.0.29/Makefile 2007-10-30 02:41:27 +0100
167 +EXTRAVERSION = .15-vs2.3.0.29
168 NAME = Holy Dancing Manatees, Batman!
171 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/Kconfig linux-2.6.22.10-vs2.3.0.29/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.3.0.29/arch/alpha/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/alpha/kernel/asm-offsets.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/alpha/kernel/entry.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/alpha/kernel/osf_sys.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/alpha/kernel/ptrace.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/alpha/kernel/semaphore.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/alpha/kernel/systbls.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/alpha/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/alpha/mm/fault.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/arm/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/arm/kernel/calls.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/arm/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/arm/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/arm/mm/fault.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/arm26/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/arm26/kernel/calls.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/arm26/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/arm26/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/cris/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/cris/arch-v10/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/cris/arch-v32/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/frv/kernel/kernel_thread.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/h8300/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/h8300/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/i386/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/i386/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/i386/kernel/syscall_table.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/i386/kernel/sysenter.c 2007-09-05 03:06:10 +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.3.0.29/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.3.0.29/arch/i386/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/i386/mm/fault.c 2007-09-05 03:06:10 +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.3.0.29/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.3.0.29/arch/ia64/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ia64/ia32/binfmt_elf32.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ia64/ia32/ia32_entry.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ia64/ia32/sys_ia32.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ia64/kernel/asm-offsets.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ia64/kernel/entry.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ia64/kernel/perfmon.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ia64/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ia64/kernel/ptrace.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ia64/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ia64/mm/fault.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/m32r/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/m32r/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/m68k/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/m68k/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/m68k/kernel/ptrace.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/m68k/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/m68knommu/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/m68knommu/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/m68knommu/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/mips/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/mips/kernel/linux32.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/mips/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/mips/kernel/ptrace.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/mips/kernel/scall32-o32.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/mips/kernel/scall64-64.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/mips/kernel/scall64-n32.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/mips/kernel/scall64-o32.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/mips/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/mips/mm/fault.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/parisc/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/parisc/kernel/entry.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/parisc/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/parisc/kernel/sys_parisc32.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/parisc/kernel/syscall_table.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/parisc/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/parisc/mm/fault.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/powerpc/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/powerpc/kernel/asm-offsets.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/powerpc/kernel/irq.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/powerpc/kernel/misc_32.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/powerpc/kernel/misc_64.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/powerpc/kernel/process.c 2007-09-30 14:57:55 +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.3.0.29/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.3.0.29/arch/powerpc/kernel/sys_ppc32.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/powerpc/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/powerpc/kernel/vdso.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/powerpc/mm/fault.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ppc/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ppc/kernel/asm-offsets.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ppc/kernel/misc.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ppc/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/ppc/mm/fault.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/s390/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/s390/kernel/compat_linux.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/s390/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/s390/kernel/ptrace.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/s390/kernel/syscalls.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/s390/mm/fault.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sh/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sh/kernel/irq.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sh/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sh/kernel/vsyscall/vsyscall.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sh/mm/fault.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sh64/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sh64/mm/fault.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc/kernel/ptrace.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc/kernel/systbls.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc/kernel/traps.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc/mm/fault.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc64/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc64/kernel/binfmt_aout32.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc64/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc64/kernel/ptrace.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc64/kernel/sys_sparc32.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc64/kernel/systbls.S 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/sparc64/kernel/traps.c 2007-09-05 03:06:11 +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.3.0.29/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.3.0.29/arch/sparc64/mm/fault.c 2007-09-05 03:06:11 +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.3.0.29/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.3.0.29/arch/sparc64/solaris/fs.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/um/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/um/kernel/trap.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/v850/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/v850/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/v850/kernel/ptrace.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/x86_64/Kconfig 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/x86_64/ia32/ia32_aout.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/x86_64/ia32/ia32_binfmt.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/x86_64/ia32/ia32entry.S 2007-09-30 14:57:59 +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.3.0.29/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.3.0.29/arch/x86_64/ia32/sys_ia32.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/x86_64/ia32/syscall32.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/x86_64/kernel/process.c 2007-08-05 20:53:12 +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.3.0.29/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.3.0.29/arch/x86_64/kernel/traps.c 2007-09-30 17:11:18 +0200
2011 #include <linux/uaccess.h>
2012 #include <linux/bug.h>
2013 #include <linux/kdebug.h>
2014 +#include <linux/vs_context.h>
2015 +#include <linux/vserver/history.h>
2017 #include <asm/system.h>
2019 @@ -413,8 +415,9 @@ void show_registers(struct pt_regs *regs
2021 printk("CPU %d ", cpu);
2023 - printk("Process %s (pid: %d, threadinfo %p, task %p)\n",
2024 - cur->comm, cur->pid, task_thread_info(cur), cur);
2025 + printk("Process %s (pid: %d[#%u], threadinfo %p, task %p)\n",
2026 + cur->comm, cur->pid, cur->xid,
2027 + task_thread_info(cur), cur);
2030 * When in-kernel, we also print out the stack and code at the
2031 @@ -518,6 +521,7 @@ void __kprobes __die(const char * str, s
2033 notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV);
2034 show_registers(regs);
2035 + vxh_dump_history();
2036 /* Executive summary in case the oops scrolled away */
2037 printk(KERN_ALERT "RIP ");
2038 printk_address(regs->rip);
2039 @@ -530,6 +534,7 @@ void die(const char * str, struct pt_reg
2041 unsigned long flags = oops_begin();
2044 if (!user_mode(regs))
2045 report_bug(regs->rip);
2047 @@ -542,12 +547,14 @@ void __kprobes die_nmi(char *str, struct
2049 unsigned long flags = oops_begin();
2053 * We are in trouble anyway, lets at least try
2054 * to get a message out.
2056 printk(str, smp_processor_id());
2057 show_registers(regs);
2058 + vxh_dump_history();
2059 if (kexec_should_crash(current))
2061 if (do_panic || panic_on_oops)
2062 @@ -580,8 +587,8 @@ static void __kprobes do_trap(int trapnr
2064 if (exception_trace && unhandled_signal(tsk, signr))
2066 - "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
2067 - tsk->comm, tsk->pid, str,
2068 + "%s[%d:#%u] trap %s rip:%lx rsp:%lx error:%lx\n",
2069 + tsk->comm, tsk->pid, tsk->xid, str,
2070 regs->rip, regs->rsp, error_code);
2073 @@ -684,8 +691,8 @@ asmlinkage void __kprobes do_general_pro
2075 if (exception_trace && unhandled_signal(tsk, SIGSEGV))
2077 - "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
2078 - tsk->comm, tsk->pid,
2079 + "%s[%d:#%u] general protection rip:%lx rsp:%lx error:%lx\n",
2080 + tsk->comm, tsk->pid, tsk->xid,
2081 regs->rip, regs->rsp, error_code);
2083 force_sig(SIGSEGV, tsk);
2084 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/x86_64/mm/fault.c
2085 --- linux-2.6.22.10/arch/x86_64/mm/fault.c 2007-07-09 13:18:08 +0200
2086 +++ linux-2.6.22.10-vs2.3.0.29/arch/x86_64/mm/fault.c 2007-08-05 20:53:12 +0200
2087 @@ -497,10 +497,10 @@ bad_area_nosemaphore:
2089 if (exception_trace && unhandled_signal(tsk, SIGSEGV)) {
2091 - "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
2092 + "%s%s[%d:#%u]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
2093 tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
2094 - tsk->comm, tsk->pid, address, regs->rip,
2095 - regs->rsp, error_code);
2096 + tsk->comm, tsk->pid, tsk->xid, address,
2097 + regs->rip, regs->rsp, error_code);
2100 tsk->thread.cr2 = address;
2101 @@ -567,7 +567,8 @@ out_of_memory:
2105 - printk("VM: killing process %s\n", tsk->comm);
2106 + printk("VM: killing process %s(%d:#%u)\n",
2107 + tsk->comm, tsk->pid, tsk->xid);
2111 Files linux-2.6.22.10/core and linux-2.6.22.10-vs2.3.0.29/core differ
2112 diff -NurpP --minimal linux-2.6.22.10/drivers/block/Kconfig linux-2.6.22.10-vs2.3.0.29/drivers/block/Kconfig
2113 --- linux-2.6.22.10/drivers/block/Kconfig 2007-07-09 13:18:16 +0200
2114 +++ linux-2.6.22.10-vs2.3.0.29/drivers/block/Kconfig 2007-08-05 20:53:12 +0200
2115 @@ -311,6 +311,13 @@ config BLK_DEV_CRYPTOLOOP
2116 instead, which can be configured to be on-disk compatible with the
2119 +config BLK_DEV_VROOT
2120 + tristate "Virtual Root device support"
2121 + depends on QUOTACTL
2123 + Saying Y here will allow you to use quota/fs ioctls on a shared
2124 + partition within a virtual server without compromising security.
2127 tristate "Network block device support"
2129 diff -NurpP --minimal linux-2.6.22.10/drivers/block/Makefile linux-2.6.22.10-vs2.3.0.29/drivers/block/Makefile
2130 --- linux-2.6.22.10/drivers/block/Makefile 2007-02-06 03:00:26 +0100
2131 +++ linux-2.6.22.10-vs2.3.0.29/drivers/block/Makefile 2007-08-05 20:53:12 +0200
2132 @@ -28,4 +28,5 @@ obj-$(CONFIG_BLK_DEV_CRYPTOLOOP) += cryp
2133 obj-$(CONFIG_VIODASD) += viodasd.o
2134 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
2135 obj-$(CONFIG_BLK_DEV_UB) += ub.o
2136 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
2138 diff -NurpP --minimal linux-2.6.22.10/drivers/block/loop.c linux-2.6.22.10-vs2.3.0.29/drivers/block/loop.c
2139 --- linux-2.6.22.10/drivers/block/loop.c 2007-07-09 13:18:16 +0200
2140 +++ linux-2.6.22.10-vs2.3.0.29/drivers/block/loop.c 2007-08-16 04:06:51 +0200
2142 #include <linux/highmem.h>
2143 #include <linux/gfp.h>
2144 #include <linux/kthread.h>
2145 +#include <linux/vs_context.h>
2147 #include <asm/uaccess.h>
2149 @@ -790,6 +791,7 @@ static int loop_set_fd(struct loop_devic
2150 lo->lo_blocksize = lo_blocksize;
2151 lo->lo_device = bdev;
2152 lo->lo_flags = lo_flags;
2153 + lo->lo_xid = vx_current_xid();
2154 lo->lo_backing_file = file;
2155 lo->transfer = transfer_none;
2157 @@ -909,6 +911,7 @@ static int loop_clr_fd(struct loop_devic
2158 lo->lo_encrypt_key_size = 0;
2160 lo->lo_thread = NULL;
2162 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
2163 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
2164 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
2165 @@ -930,7 +933,7 @@ loop_set_status(struct loop_device *lo,
2166 struct loop_func_table *xfer;
2168 if (lo->lo_encrypt_key_size && lo->lo_key_owner != current->uid &&
2169 - !capable(CAP_SYS_ADMIN))
2170 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
2172 if (lo->lo_state != Lo_bound)
2174 @@ -1010,7 +1013,8 @@ loop_get_status(struct loop_device *lo,
2175 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
2176 info->lo_encrypt_type =
2177 lo->lo_encryption ? lo->lo_encryption->number : 0;
2178 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
2179 + if (lo->lo_encrypt_key_size &&
2180 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
2181 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
2182 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
2183 lo->lo_encrypt_key_size);
2184 @@ -1321,6 +1325,9 @@ static int lo_open(struct inode *inode,
2186 struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
2188 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID))
2191 mutex_lock(&lo->lo_ctl_mutex);
2193 mutex_unlock(&lo->lo_ctl_mutex);
2194 diff -NurpP --minimal linux-2.6.22.10/drivers/block/vroot.c linux-2.6.22.10-vs2.3.0.29/drivers/block/vroot.c
2195 --- linux-2.6.22.10/drivers/block/vroot.c 1970-01-01 01:00:00 +0100
2196 +++ linux-2.6.22.10-vs2.3.0.29/drivers/block/vroot.c 2007-08-05 20:53:12 +0200
2199 + * linux/drivers/block/vroot.c
2201 + * written by Herbert Pötzl, 9/11/2002
2202 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
2204 + * based on the loop.c code by Theodore Ts'o.
2206 + * Copyright (C) 2002-2007 by Herbert Pötzl.
2207 + * Redistribution of this file is permitted under the
2208 + * GNU General Public License.
2212 +#include <linux/module.h>
2213 +#include <linux/moduleparam.h>
2214 +#include <linux/file.h>
2215 +#include <linux/major.h>
2216 +#include <linux/blkdev.h>
2218 +#include <linux/vroot.h>
2219 +#include <linux/vs_context.h>
2222 +static int max_vroot = 8;
2224 +static struct vroot_device *vroot_dev;
2225 +static struct gendisk **disks;
2228 +static int vroot_set_dev(
2229 + struct vroot_device *vr,
2230 + struct file *vr_file,
2231 + struct block_device *bdev,
2234 + struct block_device *real_bdev;
2235 + struct file *file;
2236 + struct inode *inode;
2240 + if (vr->vr_state != Vr_unbound)
2249 + inode = file->f_dentry->d_inode;
2252 + if (S_ISBLK(inode->i_mode)) {
2253 + real_bdev = inode->i_bdev;
2254 + vr->vr_device = real_bdev;
2255 + __iget(real_bdev->bd_inode);
2259 + vxdprintk(VXD_CBIT(misc, 0),
2260 + "vroot[%d]_set_dev: dev=" VXF_DEV,
2261 + vr->vr_number, VXD_DEV(real_bdev));
2263 + vr->vr_state = Vr_bound;
2272 +static int vroot_clr_dev(
2273 + struct vroot_device *vr,
2274 + struct file *vr_file,
2275 + struct block_device *bdev)
2277 + struct block_device *real_bdev;
2279 + if (vr->vr_state != Vr_bound)
2281 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
2284 + real_bdev = vr->vr_device;
2286 + vxdprintk(VXD_CBIT(misc, 0),
2287 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
2288 + vr->vr_number, VXD_DEV(real_bdev));
2291 + vr->vr_state = Vr_unbound;
2292 + vr->vr_device = NULL;
2297 +static int vr_ioctl(struct inode *inode, struct file *file,
2298 + unsigned int cmd, unsigned long arg)
2300 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
2303 + down(&vr->vr_ctl_mutex);
2305 + case VROOT_SET_DEV:
2306 + err = vroot_set_dev(vr, file, inode->i_bdev, arg);
2308 + case VROOT_CLR_DEV:
2309 + err = vroot_clr_dev(vr, file, inode->i_bdev);
2315 + up(&vr->vr_ctl_mutex);
2319 +static int vr_open(struct inode *inode, struct file *file)
2321 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
2323 + down(&vr->vr_ctl_mutex);
2325 + up(&vr->vr_ctl_mutex);
2329 +static int vr_release(struct inode *inode, struct file *file)
2331 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
2333 + down(&vr->vr_ctl_mutex);
2335 + up(&vr->vr_ctl_mutex);
2339 +static struct block_device_operations vr_fops = {
2340 + .owner = THIS_MODULE,
2342 + .release = vr_release,
2343 + .ioctl = vr_ioctl,
2346 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
2348 + struct inode *inode = bdev->bd_inode;
2349 + struct vroot_device *vr;
2350 + struct block_device *real_bdev;
2351 + int minor = iminor(inode);
2353 + vr = &vroot_dev[minor];
2354 + real_bdev = vr->vr_device;
2356 + vxdprintk(VXD_CBIT(misc, 0),
2357 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
2358 + vr->vr_number, VXD_DEV(real_bdev));
2360 + if (vr->vr_state != Vr_bound)
2361 + return ERR_PTR(-ENXIO);
2363 + __iget(real_bdev->bd_inode);
2368 + * And now the modules code and kernel interface.
2371 +module_param(max_vroot, int, 0);
2373 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
2374 +MODULE_LICENSE("GPL");
2375 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
2377 +MODULE_AUTHOR ("Herbert Pötzl");
2378 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
2381 +int __init vroot_init(void)
2385 + if (max_vroot < 1 || max_vroot > 256) {
2386 + max_vroot = MAX_VROOT_DEFAULT;
2387 + printk(KERN_WARNING "vroot: invalid max_vroot "
2388 + "(must be between 1 and 256), "
2389 + "using default (%d)\n", max_vroot);
2392 + if (register_blkdev(VROOT_MAJOR, "vroot"))
2396 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
2399 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
2401 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
2405 + for (i = 0; i < max_vroot; i++) {
2406 + disks[i] = alloc_disk(1);
2411 + for (i = 0; i < max_vroot; i++) {
2412 + struct vroot_device *vr = &vroot_dev[i];
2413 + struct gendisk *disk = disks[i];
2415 + memset(vr, 0, sizeof(*vr));
2416 + init_MUTEX(&vr->vr_ctl_mutex);
2417 + vr->vr_number = i;
2418 + disk->major = VROOT_MAJOR;
2419 + disk->first_minor = i;
2420 + disk->fops = &vr_fops;
2421 + sprintf(disk->disk_name, "vroot%d", i);
2422 + disk->private_data = vr;
2425 + err = register_vroot_grb(&__vroot_get_real_bdev);
2429 + for (i = 0; i < max_vroot; i++)
2430 + add_disk(disks[i]);
2431 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
2436 + put_disk(disks[i]);
2441 + unregister_blkdev(VROOT_MAJOR, "vroot");
2442 + printk(KERN_ERR "vroot: ran out of memory\n");
2446 +void vroot_exit(void)
2450 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
2451 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
2453 + for (i = 0; i < max_vroot; i++) {
2454 + del_gendisk(disks[i]);
2455 + put_disk(disks[i]);
2457 + if (unregister_blkdev(VROOT_MAJOR, "vroot"))
2458 + printk(KERN_WARNING "vroot: cannot unregister blkdev\n");
2464 +module_init(vroot_init);
2465 +module_exit(vroot_exit);
2469 +static int __init max_vroot_setup(char *str)
2471 + max_vroot = simple_strtol(str, NULL, 0);
2475 +__setup("max_vroot=", max_vroot_setup);
2479 diff -NurpP --minimal linux-2.6.22.10/drivers/char/sysrq.c linux-2.6.22.10-vs2.3.0.29/drivers/char/sysrq.c
2480 --- linux-2.6.22.10/drivers/char/sysrq.c 2007-07-09 13:18:20 +0200
2481 +++ linux-2.6.22.10-vs2.3.0.29/drivers/char/sysrq.c 2007-08-05 20:53:12 +0200
2483 #include <linux/kexec.h>
2484 #include <linux/irq.h>
2485 #include <linux/hrtimer.h>
2486 +#include <linux/vserver/debug.h>
2488 #include <asm/ptrace.h>
2489 #include <asm/irq_regs.h>
2490 @@ -309,6 +310,21 @@ static struct sysrq_key_op sysrq_unrt_op
2491 .enable_mask = SYSRQ_ENABLE_RTNICE,
2495 +#ifdef CONFIG_VSERVER_DEBUG
2496 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
2498 + dump_vx_info_inactive((key == 'x')?0:1);
2501 +static struct sysrq_key_op sysrq_showvxinfo_op = {
2502 + .handler = sysrq_handle_vxinfo,
2503 + .help_msg = "conteXt",
2504 + .action_msg = "Show Context Info",
2505 + .enable_mask = SYSRQ_ENABLE_DUMP,
2509 /* Key Operations table and lock */
2510 static DEFINE_SPINLOCK(sysrq_key_table_lock);
2512 @@ -357,7 +373,11 @@ static struct sysrq_key_op *sysrq_key_ta
2513 /* x: May be registered on ppc/powerpc for xmon */
2517 +#ifdef CONFIG_VSERVER_DEBUG
2518 + &sysrq_showvxinfo_op, /* z */
2524 /* key2index calculation, -1 on invalid index */
2525 @@ -369,6 +389,8 @@ static int sysrq_key_table_key2index(int
2527 else if ((key >= 'a') && (key <= 'z'))
2528 retval = key + 10 - 'a';
2529 + else if ((key >= 'A') && (key <= 'Z'))
2530 + retval = key + 10 - 'A';
2534 diff -NurpP --minimal linux-2.6.22.10/drivers/char/tty_io.c linux-2.6.22.10-vs2.3.0.29/drivers/char/tty_io.c
2535 --- linux-2.6.22.10/drivers/char/tty_io.c 2007-07-09 13:18:20 +0200
2536 +++ linux-2.6.22.10-vs2.3.0.29/drivers/char/tty_io.c 2007-08-05 20:53:12 +0200
2538 #include <linux/selection.h>
2540 #include <linux/kmod.h>
2541 +#include <linux/vs_pid.h>
2543 #undef TTY_DEBUG_HANGUP
2545 @@ -3049,13 +3050,15 @@ unlock:
2547 static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
2551 * (tty == real_tty) is a cheap way of
2552 * testing if the tty is NOT a master pty.
2554 if (tty == real_tty && current->signal->tty != real_tty)
2556 - return put_user(pid_nr(real_tty->pgrp), p);
2557 + pgrp = vx_map_pid(pid_nr(real_tty->pgrp));
2558 + return put_user(pgrp, p);
2562 @@ -3086,6 +3089,7 @@ static int tiocspgrp(struct tty_struct *
2564 if (get_user(pgrp_nr, p))
2566 + pgrp_nr = vx_rmap_pid(pgrp_nr);
2570 diff -NurpP --minimal linux-2.6.22.10/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.22.10-vs2.3.0.29/drivers/infiniband/hw/ipath/ipath_user_pages.c
2571 --- linux-2.6.22.10/drivers/infiniband/hw/ipath/ipath_user_pages.c 2007-02-06 03:00:37 +0100
2572 +++ linux-2.6.22.10-vs2.3.0.29/drivers/infiniband/hw/ipath/ipath_user_pages.c 2007-08-05 20:53:12 +0200
2575 #include <linux/mm.h>
2576 #include <linux/device.h>
2577 +#include <linux/vs_memory.h>
2579 #include "ipath_kernel.h"
2581 @@ -61,7 +62,8 @@ static int __get_user_pages(unsigned lon
2582 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
2585 - if (num_pages > lock_limit) {
2586 + if (num_pages > lock_limit ||
2587 + !vx_vmlocked_avail(current->mm, num_pages)) {
2591 @@ -78,7 +80,7 @@ static int __get_user_pages(unsigned lon
2595 - current->mm->locked_vm += num_pages;
2596 + vx_vmlocked_add(current->mm, num_pages);
2600 @@ -203,7 +205,7 @@ void ipath_release_user_pages(struct pag
2602 __ipath_release_user_pages(p, num_pages, 1);
2604 - current->mm->locked_vm -= num_pages;
2605 + vx_vmlocked_sub(current->mm, num_pages);
2607 up_write(¤t->mm->mmap_sem);
2609 @@ -220,7 +222,7 @@ static void user_pages_account(struct wo
2610 container_of(_work, struct ipath_user_pages_work, work);
2612 down_write(&work->mm->mmap_sem);
2613 - work->mm->locked_vm -= work->num_pages;
2614 + vx_vmlocked_sub(work->mm, work->num_pages);
2615 up_write(&work->mm->mmap_sem);
2618 diff -NurpP --minimal linux-2.6.22.10/drivers/md/dm-ioctl.c linux-2.6.22.10-vs2.3.0.29/drivers/md/dm-ioctl.c
2619 --- linux-2.6.22.10/drivers/md/dm-ioctl.c 2007-05-02 19:24:50 +0200
2620 +++ linux-2.6.22.10-vs2.3.0.29/drivers/md/dm-ioctl.c 2007-08-05 20:53:12 +0200
2622 #include <linux/slab.h>
2623 #include <linux/dm-ioctl.h>
2624 #include <linux/hdreg.h>
2625 +#include <linux/vs_context.h>
2627 #include <asm/uaccess.h>
2629 @@ -100,7 +101,8 @@ static struct hash_cell *__get_name_cell
2630 unsigned int h = hash_str(str);
2632 list_for_each_entry (hc, _name_buckets + h, name_list)
2633 - if (!strcmp(hc->name, str)) {
2634 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
2635 + !strcmp(hc->name, str)) {
2639 @@ -114,7 +116,8 @@ static struct hash_cell *__get_uuid_cell
2640 unsigned int h = hash_str(str);
2642 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
2643 - if (!strcmp(hc->uuid, str)) {
2644 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
2645 + !strcmp(hc->uuid, str)) {
2649 @@ -349,6 +352,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
2651 static int remove_all(struct dm_ioctl *param, size_t param_size)
2653 + if (!vx_check(0, VS_ADMIN))
2656 dm_hash_remove_all(1);
2657 param->data_size = 0;
2659 @@ -396,6 +402,8 @@ static int list_devices(struct dm_ioctl
2661 for (i = 0; i < NUM_BUCKETS; i++) {
2662 list_for_each_entry (hc, _name_buckets + i, name_list) {
2663 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2665 needed += sizeof(struct dm_name_list);
2666 needed += strlen(hc->name) + 1;
2667 needed += ALIGN_MASK;
2668 @@ -419,6 +427,8 @@ static int list_devices(struct dm_ioctl
2670 for (i = 0; i < NUM_BUCKETS; i++) {
2671 list_for_each_entry (hc, _name_buckets + i, name_list) {
2672 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2675 old_nl->next = (uint32_t) ((void *) nl -
2677 @@ -609,10 +619,11 @@ static struct hash_cell *__find_device_h
2681 - mdptr = dm_get_mdptr(md);
2682 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
2683 + mdptr = dm_get_mdptr(md);
2691 @@ -1409,8 +1420,8 @@ static int ctl_ioctl(struct inode *inode
2695 - /* only root can play with this */
2696 - if (!capable(CAP_SYS_ADMIN))
2697 + /* only root and certain contexts can play with this */
2698 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
2701 if (_IOC_TYPE(command) != DM_IOCTL)
2702 diff -NurpP --minimal linux-2.6.22.10/drivers/md/dm.c linux-2.6.22.10-vs2.3.0.29/drivers/md/dm.c
2703 --- linux-2.6.22.10/drivers/md/dm.c 2007-10-30 01:57:13 +0100
2704 +++ linux-2.6.22.10-vs2.3.0.29/drivers/md/dm.c 2007-08-11 22:41:50 +0200
2706 #include <linux/hdreg.h>
2707 #include <linux/blktrace_api.h>
2708 #include <linux/smp_lock.h>
2709 +#include <linux/vs_base.h>
2711 #define DM_MSG_PREFIX "core"
2713 @@ -77,6 +78,7 @@ struct mapped_device {
2716 atomic_t open_count;
2719 unsigned long flags;
2721 @@ -223,6 +225,7 @@ static void __exit dm_exit(void)
2722 static int dm_blk_open(struct inode *inode, struct file *file)
2724 struct mapped_device *md;
2727 spin_lock(&_minor_lock);
2729 @@ -231,18 +234,19 @@ static int dm_blk_open(struct inode *ino
2732 if (test_bit(DMF_FREEING, &md->flags) ||
2733 - test_bit(DMF_DELETING, &md->flags)) {
2735 + test_bit(DMF_DELETING, &md->flags))
2739 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
2744 atomic_inc(&md->open_count);
2748 spin_unlock(&_minor_lock);
2750 - return md ? 0 : -ENXIO;
2754 static int dm_blk_close(struct inode *inode, struct file *file)
2755 @@ -438,6 +442,14 @@ int dm_set_geometry(struct mapped_device
2760 + * Get the xid associated with a dm device
2762 +xid_t dm_get_xid(struct mapped_device *md)
2767 /*-----------------------------------------------------------------
2769 * A more elegant soln is in the works that uses the queue
2770 @@ -1000,6 +1012,7 @@ static struct mapped_device *alloc_dev(i
2771 atomic_set(&md->holders, 1);
2772 atomic_set(&md->open_count, 0);
2773 atomic_set(&md->event_nr, 0);
2774 + md->xid = vx_current_xid();
2776 md->queue = blk_alloc_queue(GFP_KERNEL);
2778 diff -NurpP --minimal linux-2.6.22.10/drivers/md/dm.h linux-2.6.22.10-vs2.3.0.29/drivers/md/dm.h
2779 --- linux-2.6.22.10/drivers/md/dm.h 2007-02-06 03:00:41 +0100
2780 +++ linux-2.6.22.10-vs2.3.0.29/drivers/md/dm.h 2007-08-05 20:53:12 +0200
2781 @@ -91,6 +91,8 @@ void dm_put_target_type(struct target_ty
2782 int dm_target_iterate(void (*iter_func)(struct target_type *tt,
2783 void *param), void *param);
2785 +xid_t dm_get_xid(struct mapped_device *md);
2787 /*-----------------------------------------------------------------
2789 *---------------------------------------------------------------*/
2790 diff -NurpP --minimal linux-2.6.22.10/fs/attr.c linux-2.6.22.10-vs2.3.0.29/fs/attr.c
2791 --- linux-2.6.22.10/fs/attr.c 2007-07-09 13:19:22 +0200
2792 +++ linux-2.6.22.10-vs2.3.0.29/fs/attr.c 2007-10-25 17:05:55 +0200
2794 #include <linux/fcntl.h>
2795 #include <linux/quotaops.h>
2796 #include <linux/security.h>
2797 +#include <linux/proc_fs.h>
2798 +#include <linux/devpts_fs.h>
2799 +#include <linux/vs_base.h>
2801 /* Taken over from the old code... */
2803 @@ -55,6 +58,27 @@ int inode_change_ok(struct inode *inode,
2804 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
2808 + /* Check for evil vserver activity */
2809 + if (vx_check(0, VS_ADMIN))
2812 + if (IS_BARRIER(inode)) {
2813 + vxwprintk_task(1, "messing with the barrier.");
2816 + switch (inode->i_sb->s_magic) {
2817 + case PROC_SUPER_MAGIC:
2818 + /* maybe allow that in the future? */
2819 + vxwprintk_task(1, "messing with the procfs.");
2821 + case DEVPTS_SUPER_MAGIC:
2822 + /* devpts is xid tagged */
2823 + if (vx_check((xid_t)inode->i_tag, VS_IDENT))
2825 + vxwprintk_task(1, "messing with the devpts.");
2831 @@ -78,6 +102,8 @@ int inode_setattr(struct inode * inode,
2832 inode->i_uid = attr->ia_uid;
2833 if (ia_valid & ATTR_GID)
2834 inode->i_gid = attr->ia_gid;
2835 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2836 + inode->i_tag = attr->ia_tag;
2837 if (ia_valid & ATTR_ATIME)
2838 inode->i_atime = timespec_trunc(attr->ia_atime,
2839 inode->i_sb->s_time_gran);
2840 @@ -152,7 +178,8 @@ int notify_change(struct dentry * dentry
2841 error = security_inode_setattr(dentry, attr);
2843 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2844 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
2845 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2846 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
2847 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
2849 error = inode_setattr(inode, attr);
2850 diff -NurpP --minimal linux-2.6.22.10/fs/binfmt_aout.c linux-2.6.22.10-vs2.3.0.29/fs/binfmt_aout.c
2851 --- linux-2.6.22.10/fs/binfmt_aout.c 2007-02-06 03:01:16 +0100
2852 +++ linux-2.6.22.10-vs2.3.0.29/fs/binfmt_aout.c 2007-08-05 20:53:12 +0200
2854 #include <linux/binfmts.h>
2855 #include <linux/personality.h>
2856 #include <linux/init.h>
2857 +#include <linux/vs_memory.h>
2859 #include <asm/system.h>
2860 #include <asm/uaccess.h>
2861 diff -NurpP --minimal linux-2.6.22.10/fs/binfmt_elf.c linux-2.6.22.10-vs2.3.0.29/fs/binfmt_elf.c
2862 --- linux-2.6.22.10/fs/binfmt_elf.c 2007-07-09 13:19:22 +0200
2863 +++ linux-2.6.22.10-vs2.3.0.29/fs/binfmt_elf.c 2007-08-05 20:53:12 +0200
2865 #include <linux/random.h>
2866 #include <linux/elf.h>
2867 #include <linux/utsname.h>
2868 +#include <linux/vs_memory.h>
2869 #include <asm/uaccess.h>
2870 #include <asm/param.h>
2871 #include <asm/page.h>
2872 diff -NurpP --minimal linux-2.6.22.10/fs/binfmt_flat.c linux-2.6.22.10-vs2.3.0.29/fs/binfmt_flat.c
2873 --- linux-2.6.22.10/fs/binfmt_flat.c 2007-07-09 13:19:22 +0200
2874 +++ linux-2.6.22.10-vs2.3.0.29/fs/binfmt_flat.c 2007-08-05 20:53:12 +0200
2876 #include <linux/init.h>
2877 #include <linux/flat.h>
2878 #include <linux/syscalls.h>
2879 +#include <linux/vs_memory.h>
2881 #include <asm/byteorder.h>
2882 #include <asm/system.h>
2883 diff -NurpP --minimal linux-2.6.22.10/fs/binfmt_som.c linux-2.6.22.10-vs2.3.0.29/fs/binfmt_som.c
2884 --- linux-2.6.22.10/fs/binfmt_som.c 2006-11-30 21:19:19 +0100
2885 +++ linux-2.6.22.10-vs2.3.0.29/fs/binfmt_som.c 2007-08-05 20:53:12 +0200
2887 #include <linux/shm.h>
2888 #include <linux/personality.h>
2889 #include <linux/init.h>
2890 +#include <linux/vs_memory.h>
2892 #include <asm/a.out.h>
2893 #include <asm/uaccess.h>
2894 diff -NurpP --minimal linux-2.6.22.10/fs/block_dev.c linux-2.6.22.10-vs2.3.0.29/fs/block_dev.c
2895 --- linux-2.6.22.10/fs/block_dev.c 2007-07-09 13:19:22 +0200
2896 +++ linux-2.6.22.10-vs2.3.0.29/fs/block_dev.c 2007-10-11 01:10:22 +0200
2898 #include <linux/uio.h>
2899 #include <linux/namei.h>
2900 #include <linux/log2.h>
2901 +#include <linux/vs_device.h>
2902 #include <asm/uaccess.h>
2903 #include "internal.h"
2905 @@ -572,6 +573,7 @@ struct block_device *bdget(dev_t dev)
2906 bdev->bd_invalidated = 0;
2907 inode->i_mode = S_IFBLK;
2908 inode->i_rdev = dev;
2909 + inode->i_mdev = dev;
2910 inode->i_bdev = bdev;
2911 inode->i_data.a_ops = &def_blk_aops;
2912 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2913 @@ -610,6 +612,11 @@ EXPORT_SYMBOL(bdput);
2914 static struct block_device *bd_acquire(struct inode *inode)
2916 struct block_device *bdev;
2919 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2921 + inode->i_mdev = mdev;
2923 spin_lock(&bdev_lock);
2924 bdev = inode->i_bdev;
2925 @@ -620,7 +627,7 @@ static struct block_device *bd_acquire(s
2927 spin_unlock(&bdev_lock);
2929 - bdev = bdget(inode->i_rdev);
2930 + bdev = bdget(mdev);
2932 spin_lock(&bdev_lock);
2933 if (!inode->i_bdev) {
2934 diff -NurpP --minimal linux-2.6.22.10/fs/char_dev.c linux-2.6.22.10-vs2.3.0.29/fs/char_dev.c
2935 --- linux-2.6.22.10/fs/char_dev.c 2007-05-02 19:25:16 +0200
2936 +++ linux-2.6.22.10-vs2.3.0.29/fs/char_dev.c 2007-10-11 01:10:22 +0200
2938 #include <linux/cdev.h>
2939 #include <linux/mutex.h>
2940 #include <linux/backing-dev.h>
2941 +#include <linux/vs_device.h>
2944 #include <linux/kmod.h>
2945 @@ -363,14 +364,21 @@ int chrdev_open(struct inode * inode, st
2947 struct cdev *new = NULL;
2951 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2953 + inode->i_mdev = mdev;
2955 spin_lock(&cdev_lock);
2958 struct kobject *kobj;
2961 spin_unlock(&cdev_lock);
2962 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2964 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2967 new = container_of(kobj, struct cdev, kobj);
2968 diff -NurpP --minimal linux-2.6.22.10/fs/dcache.c linux-2.6.22.10-vs2.3.0.29/fs/dcache.c
2969 --- linux-2.6.22.10/fs/dcache.c 2007-07-09 13:19:23 +0200
2970 +++ linux-2.6.22.10-vs2.3.0.29/fs/dcache.c 2007-08-05 20:53:12 +0200
2972 #include <linux/seqlock.h>
2973 #include <linux/swap.h>
2974 #include <linux/bootmem.h>
2975 +#include <linux/vs_limit.h>
2976 #include "internal.h"
2979 @@ -176,6 +177,7 @@ void dput(struct dentry *dentry)
2983 + vx_dentry_dec(dentry);
2985 if (atomic_read(&dentry->d_count) == 1)
2987 @@ -189,6 +191,8 @@ repeat:
2991 + vx_dentry_dec(dentry);
2994 * AV: ->d_delete() is _NOT_ allowed to block now.
2996 @@ -288,6 +292,7 @@ static inline struct dentry * __dget_loc
2997 if (!list_empty(&dentry->d_lru)) {
2998 dentry_stat.nr_unused--;
2999 list_del_init(&dentry->d_lru);
3000 + vx_dentry_inc(dentry);
3004 @@ -898,6 +903,9 @@ struct dentry *d_alloc(struct dentry * p
3005 struct dentry *dentry;
3008 + if (!vx_dentry_avail(1))
3011 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
3014 @@ -946,6 +954,7 @@ struct dentry *d_alloc(struct dentry * p
3016 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
3017 dentry_stat.nr_dentry++;
3018 + vx_dentry_inc(dentry);
3019 spin_unlock(&dcache_lock);
3022 @@ -1295,6 +1304,7 @@ struct dentry * __d_lookup(struct dentry
3024 if (!d_unhashed(dentry)) {
3025 atomic_inc(&dentry->d_count);
3026 + vx_dentry_inc(dentry);
3029 spin_unlock(&dentry->d_lock);
3030 diff -NurpP --minimal linux-2.6.22.10/fs/devpts/inode.c linux-2.6.22.10-vs2.3.0.29/fs/devpts/inode.c
3031 --- linux-2.6.22.10/fs/devpts/inode.c 2007-07-09 13:19:23 +0200
3032 +++ linux-2.6.22.10-vs2.3.0.29/fs/devpts/inode.c 2007-10-18 00:59:53 +0200
3034 #include <linux/namei.h>
3035 #include <linux/mount.h>
3036 #include <linux/tty.h>
3037 +#include <linux/magic.h>
3038 #include <linux/devpts_fs.h>
3039 #include <linux/parser.h>
3040 #include <linux/fsnotify.h>
3041 +#include <linux/vs_base.h>
3043 -#define DEVPTS_SUPER_MAGIC 0x1cd1
3045 +static int devpts_permission(struct inode *inode, int mask, struct nameidata *nd)
3047 + int ret = -EACCES;
3049 + /* devpts is xid tagged */
3050 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
3051 + ret = generic_permission(inode, mask, NULL);
3055 +static struct inode_operations devpts_file_inode_operations = {
3056 + .permission = devpts_permission,
3059 static struct vfsmount *devpts_mnt;
3060 static struct dentry *devpts_root;
3061 @@ -92,6 +107,25 @@ static int devpts_remount(struct super_b
3065 +static int devpts_filter(struct dentry *de)
3067 + /* devpts is xid tagged */
3068 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
3071 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
3073 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
3076 +static struct file_operations devpts_dir_operations = {
3077 + .open = dcache_dir_open,
3078 + .release = dcache_dir_close,
3079 + .llseek = dcache_dir_lseek,
3080 + .read = generic_read_dir,
3081 + .readdir = devpts_readdir,
3084 static const struct super_operations devpts_sops = {
3085 .statfs = simple_statfs,
3086 .remount_fs = devpts_remount,
3087 @@ -117,8 +151,10 @@ devpts_fill_super(struct super_block *s,
3088 inode->i_uid = inode->i_gid = 0;
3089 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
3090 inode->i_op = &simple_dir_inode_operations;
3091 - inode->i_fop = &simple_dir_operations;
3092 + inode->i_fop = &devpts_dir_operations;
3094 + /* devpts is xid tagged */
3095 + inode->i_tag = (tag_t)vx_current_xid();
3097 devpts_root = s->s_root = d_alloc_root(inode);
3099 @@ -176,6 +212,9 @@ int devpts_pty_new(struct tty_struct *tt
3100 inode->i_gid = config.setgid ? config.gid : current->fsgid;
3101 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
3102 init_special_inode(inode, S_IFCHR|config.mode, device);
3103 + /* devpts is xid tagged */
3104 + inode->i_tag = (tag_t)vx_current_xid();
3105 + inode->i_op = &devpts_file_inode_operations;
3106 inode->i_private = tty;
3108 dentry = get_node(number);
3109 diff -NurpP --minimal linux-2.6.22.10/fs/ecryptfs/inode.c linux-2.6.22.10-vs2.3.0.29/fs/ecryptfs/inode.c
3110 --- linux-2.6.22.10/fs/ecryptfs/inode.c 2007-10-30 01:57:14 +0100
3111 +++ linux-2.6.22.10-vs2.3.0.29/fs/ecryptfs/inode.c 2007-08-11 22:41:51 +0200
3112 @@ -423,7 +423,7 @@ static int ecryptfs_link(struct dentry *
3113 dget(lower_new_dentry);
3114 lower_dir_dentry = lock_parent(lower_new_dentry);
3115 rc = vfs_link(lower_old_dentry, lower_dir_dentry->d_inode,
3116 - lower_new_dentry);
3117 + lower_new_dentry, NULL);
3118 if (rc || !lower_new_dentry->d_inode)
3120 rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0);
3121 @@ -451,7 +451,7 @@ static int ecryptfs_unlink(struct inode
3122 struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
3124 lock_parent(lower_dentry);
3125 - rc = vfs_unlink(lower_dir_inode, lower_dentry);
3126 + rc = vfs_unlink(lower_dir_inode, lower_dentry, NULL);
3128 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
3130 @@ -488,7 +488,7 @@ static int ecryptfs_symlink(struct inode
3133 rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry,
3134 - encoded_symname, mode);
3135 + encoded_symname, mode, NULL);
3136 kfree(encoded_symname);
3137 if (rc || !lower_dentry->d_inode)
3139 @@ -513,7 +513,7 @@ static int ecryptfs_mkdir(struct inode *
3141 lower_dentry = ecryptfs_dentry_to_lower(dentry);
3142 lower_dir_dentry = lock_parent(lower_dentry);
3143 - rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode);
3144 + rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode, NULL);
3145 if (rc || !lower_dentry->d_inode)
3147 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
3148 @@ -539,7 +539,7 @@ static int ecryptfs_rmdir(struct inode *
3150 lower_dir_dentry = lock_parent(lower_dentry);
3152 - rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry);
3153 + rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry, NULL);
3156 d_delete(lower_dentry);
3157 @@ -561,7 +561,7 @@ ecryptfs_mknod(struct inode *dir, struct
3159 lower_dentry = ecryptfs_dentry_to_lower(dentry);
3160 lower_dir_dentry = lock_parent(lower_dentry);
3161 - rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev);
3162 + rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev, NULL);
3163 if (rc || !lower_dentry->d_inode)
3165 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
3166 diff -NurpP --minimal linux-2.6.22.10/fs/exec.c linux-2.6.22.10-vs2.3.0.29/fs/exec.c
3167 --- linux-2.6.22.10/fs/exec.c 2007-10-30 01:57:14 +0100
3168 +++ linux-2.6.22.10-vs2.3.0.29/fs/exec.c 2007-10-04 23:47:06 +0200
3170 #include <linux/cn_proc.h>
3171 #include <linux/audit.h>
3172 #include <linux/signalfd.h>
3173 +#include <linux/vs_memory.h>
3175 #include <asm/uaccess.h>
3176 #include <asm/mmu_context.h>
3177 @@ -440,7 +441,8 @@ int setup_arg_pages(struct linux_binprm
3178 kmem_cache_free(vm_area_cachep, mpnt);
3181 - mm->stack_vm = mm->total_vm = vma_pages(mpnt);
3182 + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt));
3183 + mm->stack_vm = mm->total_vm;
3186 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
3187 @@ -1336,7 +1338,7 @@ static int format_corename(char *corenam
3188 /* UNIX time of coredump */
3191 - do_gettimeofday(&tv);
3192 + vx_gettimeofday(&tv);
3193 rc = snprintf(out_ptr, out_end - out_ptr,
3195 if (rc > out_end - out_ptr)
3196 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/balloc.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/balloc.c
3197 --- linux-2.6.22.10/fs/ext2/balloc.c 2007-05-02 19:25:17 +0200
3198 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/balloc.c 2007-08-05 20:53:12 +0200
3200 #include <linux/sched.h>
3201 #include <linux/buffer_head.h>
3202 #include <linux/capability.h>
3203 +#include <linux/vs_dlimit.h>
3204 +#include <linux/vs_tag.h>
3207 * balloc.c contains the blocks allocation and deallocation routines
3208 @@ -102,12 +104,13 @@ static int reserve_blocks(struct super_b
3210 struct ext2_sb_info *sbi = EXT2_SB(sb);
3211 struct ext2_super_block *es = sbi->s_es;
3212 - unsigned free_blocks;
3213 - unsigned root_blocks;
3214 + unsigned long long free_blocks, root_blocks;
3216 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
3217 root_blocks = le32_to_cpu(es->s_r_blocks_count);
3219 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
3221 if (free_blocks < count)
3222 count = free_blocks;
3224 @@ -258,6 +261,7 @@ do_more:
3228 + DLIMIT_FREE_BLOCK(inode, freed);
3229 release_blocks(sb, freed);
3230 DQUOT_FREE_BLOCK(inode, freed);
3232 @@ -361,6 +365,10 @@ int ext2_new_block(struct inode *inode,
3236 + if (DLIMIT_ALLOC_BLOCK(inode, es_alloc)) {
3241 ext2_debug ("goal=%lu.\n", goal);
3243 @@ -508,6 +516,8 @@ got_block:
3246 group_release_blocks(sb, group_no, desc, gdp_bh, group_alloc);
3247 + DLIMIT_FREE_BLOCK(inode, es_alloc);
3249 release_blocks(sb, es_alloc);
3251 DQUOT_FREE_BLOCK(inode, dq_alloc);
3252 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/ext2.h linux-2.6.22.10-vs2.3.0.29/fs/ext2/ext2.h
3253 --- linux-2.6.22.10/fs/ext2/ext2.h 2007-07-09 13:19:23 +0200
3254 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/ext2.h 2007-08-05 20:53:12 +0200
3255 @@ -167,6 +167,7 @@ extern const struct file_operations ext2
3256 extern const struct address_space_operations ext2_aops;
3257 extern const struct address_space_operations ext2_aops_xip;
3258 extern const struct address_space_operations ext2_nobh_aops;
3259 +extern int ext2_sync_flags(struct inode *inode);
3262 extern const struct inode_operations ext2_dir_inode_operations;
3263 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/file.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/file.c
3264 --- linux-2.6.22.10/fs/ext2/file.c 2007-05-02 19:25:17 +0200
3265 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/file.c 2007-09-12 20:04:16 +0200
3266 @@ -85,4 +85,5 @@ const struct inode_operations ext2_file_
3268 .setattr = ext2_setattr,
3269 .permission = ext2_permission,
3270 + .sync_flags = ext2_sync_flags,
3272 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/ialloc.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/ialloc.c
3273 --- linux-2.6.22.10/fs/ext2/ialloc.c 2006-11-30 21:19:19 +0100
3274 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/ialloc.c 2007-08-05 20:53:12 +0200
3276 #include <linux/backing-dev.h>
3277 #include <linux/buffer_head.h>
3278 #include <linux/random.h>
3279 +#include <linux/vs_dlimit.h>
3280 +#include <linux/vs_tag.h>
3284 @@ -125,6 +127,7 @@ void ext2_free_inode (struct inode * ino
3285 ext2_xattr_delete_inode(inode);
3286 DQUOT_FREE_INODE(inode);
3288 + DLIMIT_FREE_INODE(inode);
3291 es = EXT2_SB(sb)->s_es;
3292 @@ -464,6 +467,11 @@ struct inode *ext2_new_inode(struct inod
3294 return ERR_PTR(-ENOMEM);
3296 + inode->i_tag = dx_current_fstag(sb);
3297 + if (DLIMIT_ALLOC_INODE(inode)) {
3304 @@ -577,7 +585,8 @@ got:
3305 inode->i_blocks = 0;
3306 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
3307 memset(ei->i_data, 0, sizeof(ei->i_data));
3308 - ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
3309 + ei->i_flags = EXT2_I(dir)->i_flags &
3310 + ~(EXT2_BTREE_FL|EXT2_IUNLINK_FL|EXT2_BARRIER_FL);
3312 ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
3313 /* dirsync is only applied to directories */
3314 @@ -625,12 +634,15 @@ fail_free_drop:
3318 + DLIMIT_FREE_INODE(inode);
3319 inode->i_flags |= S_NOQUOTA;
3322 return ERR_PTR(err);
3325 + DLIMIT_FREE_INODE(inode);
3327 make_bad_inode(inode);
3329 return ERR_PTR(err);
3330 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/inode.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/inode.c
3331 --- linux-2.6.22.10/fs/ext2/inode.c 2007-07-09 13:19:23 +0200
3332 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/inode.c 2007-08-18 02:52:34 +0200
3334 #include <linux/writeback.h>
3335 #include <linux/buffer_head.h>
3336 #include <linux/mpage.h>
3337 +#include <linux/vs_tag.h>
3341 @@ -913,7 +914,7 @@ void ext2_truncate (struct inode * inode
3343 if (ext2_inode_is_fast_symlink(inode))
3345 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3346 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3349 ext2_discard_prealloc(inode);
3350 @@ -1042,13 +1043,20 @@ void ext2_set_inode_flags(struct inode *
3352 unsigned int flags = EXT2_I(inode)->i_flags;
3354 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3355 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
3356 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3358 + if (flags & EXT2_IMMUTABLE_FL)
3359 + inode->i_flags |= S_IMMUTABLE;
3360 + if (flags & EXT2_IUNLINK_FL)
3361 + inode->i_flags |= S_IUNLINK;
3362 + if (flags & EXT2_BARRIER_FL)
3363 + inode->i_flags |= S_BARRIER;
3365 if (flags & EXT2_SYNC_FL)
3366 inode->i_flags |= S_SYNC;
3367 if (flags & EXT2_APPEND_FL)
3368 inode->i_flags |= S_APPEND;
3369 - if (flags & EXT2_IMMUTABLE_FL)
3370 - inode->i_flags |= S_IMMUTABLE;
3371 if (flags & EXT2_NOATIME_FL)
3372 inode->i_flags |= S_NOATIME;
3373 if (flags & EXT2_DIRSYNC_FL)
3374 @@ -1074,12 +1082,37 @@ void ext2_get_inode_flags(struct ext2_in
3375 ei->i_flags |= EXT2_DIRSYNC_FL;
3378 +int ext2_sync_flags(struct inode *inode)
3380 + unsigned int oldflags, newflags;
3382 + oldflags = EXT2_I(inode)->i_flags;
3383 + newflags = oldflags & ~(EXT2_IMMUTABLE_FL |
3384 + EXT2_IUNLINK_FL | EXT2_BARRIER_FL);
3386 + if (IS_IMMUTABLE(inode))
3387 + newflags |= EXT2_IMMUTABLE_FL;
3388 + if (IS_IUNLINK(inode))
3389 + newflags |= EXT2_IUNLINK_FL;
3390 + if (IS_BARRIER(inode))
3391 + newflags |= EXT2_BARRIER_FL;
3393 + if (oldflags ^ newflags) {
3394 + EXT2_I(inode)->i_flags = newflags;
3395 + inode->i_ctime = CURRENT_TIME;
3396 + mark_inode_dirty(inode);
3401 void ext2_read_inode (struct inode * inode)
3403 struct ext2_inode_info *ei = EXT2_I(inode);
3404 ino_t ino = inode->i_ino;
3405 struct buffer_head * bh;
3406 struct ext2_inode * raw_inode = ext2_get_inode(inode->i_sb, ino, &bh);
3411 #ifdef CONFIG_EXT2_FS_POSIX_ACL
3412 @@ -1090,12 +1123,17 @@ void ext2_read_inode (struct inode * ino
3415 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3416 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3417 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3418 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3419 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3420 if (!(test_opt (inode->i_sb, NO_UID32))) {
3421 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3422 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3423 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3424 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3426 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3427 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3428 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3429 + le16_to_cpu(raw_inode->i_raw_tag));
3431 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3432 inode->i_size = le32_to_cpu(raw_inode->i_size);
3433 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3434 @@ -1192,8 +1230,8 @@ static int ext2_update_inode(struct inod
3435 struct ext2_inode_info *ei = EXT2_I(inode);
3436 struct super_block *sb = inode->i_sb;
3437 ino_t ino = inode->i_ino;
3438 - uid_t uid = inode->i_uid;
3439 - gid_t gid = inode->i_gid;
3440 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3441 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3442 struct buffer_head * bh;
3443 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
3445 @@ -1229,6 +1267,9 @@ static int ext2_update_inode(struct inod
3446 raw_inode->i_uid_high = 0;
3447 raw_inode->i_gid_high = 0;
3449 +#ifdef CONFIG_TAGGING_INTERN
3450 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3452 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3453 raw_inode->i_size = cpu_to_le32(inode->i_size);
3454 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3455 @@ -1315,7 +1356,8 @@ int ext2_setattr(struct dentry *dentry,
3458 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3459 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3460 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3461 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3462 error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0;
3465 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/ioctl.c
3466 --- linux-2.6.22.10/fs/ext2/ioctl.c 2007-07-09 13:19:23 +0200
3467 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/ioctl.c 2007-08-05 20:53:12 +0200
3469 #include <linux/sched.h>
3470 #include <linux/compat.h>
3471 #include <linux/smp_lock.h>
3472 +#include <linux/mount.h>
3473 #include <asm/current.h>
3474 #include <asm/uaccess.h>
3476 @@ -33,7 +34,8 @@ int ext2_ioctl (struct inode * inode, st
3477 case EXT2_IOC_SETFLAGS: {
3478 unsigned int oldflags;
3480 - if (IS_RDONLY(inode))
3481 + if (IS_RDONLY(inode) ||
3482 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3485 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3486 @@ -54,7 +56,9 @@ int ext2_ioctl (struct inode * inode, st
3488 * This test looks nicer. Thanks to Pauline Middelink
3490 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
3491 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
3492 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
3493 + EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL))) {
3494 if (!capable(CAP_LINUX_IMMUTABLE)) {
3495 mutex_unlock(&inode->i_mutex);
3497 @@ -76,7 +80,8 @@ int ext2_ioctl (struct inode * inode, st
3498 case EXT2_IOC_SETVERSION:
3499 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3501 - if (IS_RDONLY(inode))
3502 + if (IS_RDONLY(inode) ||
3503 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3505 if (get_user(inode->i_generation, (int __user *) arg))
3507 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/namei.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/namei.c
3508 --- linux-2.6.22.10/fs/ext2/namei.c 2007-05-02 19:25:17 +0200
3509 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/namei.c 2007-08-05 20:53:12 +0200
3513 #include <linux/pagemap.h>
3514 +#include <linux/vs_tag.h>
3518 @@ -66,6 +67,7 @@ static struct dentry *ext2_lookup(struct
3519 inode = iget(dir->i_sb, ino);
3521 return ERR_PTR(-EACCES);
3522 + dx_propagate_tag(nd, inode);
3524 return d_splice_alias(inode, dentry);
3526 @@ -391,6 +393,7 @@ const struct inode_operations ext2_dir_i
3528 .setattr = ext2_setattr,
3529 .permission = ext2_permission,
3530 + .sync_flags = ext2_sync_flags,
3533 const struct inode_operations ext2_special_inode_operations = {
3534 @@ -402,4 +405,5 @@ const struct inode_operations ext2_speci
3536 .setattr = ext2_setattr,
3537 .permission = ext2_permission,
3538 + .sync_flags = ext2_sync_flags,
3540 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/super.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/super.c
3541 --- linux-2.6.22.10/fs/ext2/super.c 2007-07-09 13:19:23 +0200
3542 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/super.c 2007-08-05 20:53:12 +0200
3543 @@ -321,7 +321,7 @@ enum {
3544 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3545 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3546 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3547 - Opt_usrquota, Opt_grpquota
3548 + Opt_usrquota, Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3551 static match_table_t tokens = {
3552 @@ -349,6 +349,9 @@ static match_table_t tokens = {
3554 {Opt_noacl, "noacl"},
3557 + {Opt_notag, "notag"},
3558 + {Opt_tagid, "tagid=%u"},
3559 {Opt_grpquota, "grpquota"},
3560 {Opt_ignore, "noquota"},
3561 {Opt_quota, "quota"},
3562 @@ -417,6 +420,20 @@ static int parse_options (char * options
3564 set_opt (sbi->s_mount_opt, NO_UID32);
3566 +#ifndef CONFIG_TAGGING_NONE
3568 + set_opt (sbi->s_mount_opt, TAGGED);
3571 + clear_opt (sbi->s_mount_opt, TAGGED);
3574 +#ifdef CONFIG_PROPAGATE
3577 + set_opt (sbi->s_mount_opt, TAGGED);
3581 clear_opt (sbi->s_mount_opt, CHECK);
3583 @@ -727,6 +744,8 @@ static int ext2_fill_super(struct super_
3584 if (!parse_options ((char *) data, sbi))
3587 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3588 + sb->s_flags |= MS_TAGGED;
3589 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3590 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3592 @@ -1035,6 +1054,13 @@ static int ext2_remount (struct super_bl
3596 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3597 + !(sb->s_flags & MS_TAGGED)) {
3598 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3603 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3604 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3606 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/symlink.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/symlink.c
3607 --- linux-2.6.22.10/fs/ext2/symlink.c 2007-05-02 19:25:17 +0200
3608 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/symlink.c 2007-08-05 20:53:12 +0200
3609 @@ -38,6 +38,7 @@ const struct inode_operations ext2_symli
3610 .listxattr = ext2_listxattr,
3611 .removexattr = generic_removexattr,
3613 + .sync_flags = ext2_sync_flags,
3616 const struct inode_operations ext2_fast_symlink_inode_operations = {
3617 @@ -49,4 +50,5 @@ const struct inode_operations ext2_fast_
3618 .listxattr = ext2_listxattr,
3619 .removexattr = generic_removexattr,
3621 + .sync_flags = ext2_sync_flags,
3623 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/xattr.c
3624 --- linux-2.6.22.10/fs/ext2/xattr.c 2007-02-06 03:01:18 +0100
3625 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/xattr.c 2007-08-05 20:53:12 +0200
3627 #include <linux/mbcache.h>
3628 #include <linux/quotaops.h>
3629 #include <linux/rwsem.h>
3630 +#include <linux/vs_dlimit.h>
3634 @@ -641,8 +642,12 @@ ext2_xattr_set2(struct inode *inode, str
3636 ea_bdebug(new_bh, "reusing block");
3639 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3642 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
3643 + DLIMIT_FREE_BLOCK(inode, 1);
3644 unlock_buffer(new_bh);
3647 @@ -736,6 +741,7 @@ ext2_xattr_set2(struct inode *inode, str
3648 le32_to_cpu(HDR(old_bh)->h_refcount) - 1);
3650 mb_cache_entry_release(ce);
3651 + DLIMIT_FREE_BLOCK(inode, 1);
3652 DQUOT_FREE_BLOCK(inode, 1);
3653 mark_buffer_dirty(old_bh);
3654 ea_bdebug(old_bh, "refcount now=%d",
3655 @@ -800,6 +806,7 @@ ext2_xattr_delete_inode(struct inode *in
3656 mark_buffer_dirty(bh);
3658 sync_dirty_buffer(bh);
3659 + DLIMIT_FREE_BLOCK(inode, 1);
3660 DQUOT_FREE_BLOCK(inode, 1);
3662 EXT2_I(inode)->i_file_acl = 0;
3663 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/balloc.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/balloc.c
3664 --- linux-2.6.22.10/fs/ext3/balloc.c 2007-05-02 19:25:17 +0200
3665 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/balloc.c 2007-08-05 20:53:12 +0200
3667 #include <linux/ext3_jbd.h>
3668 #include <linux/quotaops.h>
3669 #include <linux/buffer_head.h>
3670 +#include <linux/vs_dlimit.h>
3671 +#include <linux/vs_tag.h>
3674 * balloc.c contains the blocks allocation and deallocation routines
3675 @@ -613,8 +615,10 @@ void ext3_free_blocks(handle_t *handle,
3678 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
3679 - if (dquot_freed_blocks)
3680 + if (dquot_freed_blocks) {
3681 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
3682 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
3687 @@ -1353,18 +1357,33 @@ out:
3689 * Check if filesystem has at least 1 free block available for allocation.
3691 -static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
3692 +static int ext3_has_free_blocks(struct super_block *sb)
3694 - ext3_fsblk_t free_blocks, root_blocks;
3695 + struct ext3_sb_info *sbi = EXT3_SB(sb);
3696 + unsigned long long free_blocks, root_blocks;
3699 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
3700 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
3701 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
3703 + vxdprintk(VXD_CBIT(dlim, 3),
3704 + "ext3_has_free_blocks(%p): free=%llu, root=%llu",
3705 + sb, free_blocks, root_blocks);
3707 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
3709 + cond = (free_blocks < root_blocks + 1 &&
3710 + !capable(CAP_SYS_RESOURCE) &&
3711 sbi->s_resuid != current->fsuid &&
3712 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
3716 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
3718 + vxdprintk(VXD_CBIT(dlim, 3),
3719 + "ext3_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
3720 + sb, free_blocks, root_blocks,
3721 + !capable(CAP_SYS_RESOURCE)?'1':'0',
3722 + sbi->s_resuid, current->fsuid, cond?0:1);
3724 + return (cond ? 0 : 1);
3728 @@ -1381,7 +1400,7 @@ static int ext3_has_free_blocks(struct e
3730 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
3732 - if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
3733 + if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
3736 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
3737 @@ -1444,6 +1463,8 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
3741 + if (DLIMIT_ALLOC_BLOCK(inode, num))
3745 es = EXT3_SB(sb)->s_es;
3746 @@ -1460,7 +1481,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
3747 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
3748 my_rsv = &block_i->rsv_window_node;
3750 - if (!ext3_has_free_blocks(sbi)) {
3751 + if (!ext3_has_free_blocks(sb)) {
3755 @@ -1647,12 +1668,16 @@ allocated:
3758 DQUOT_FREE_BLOCK(inode, *count-num);
3759 + DLIMIT_FREE_BLOCK(inode, *count-num);
3766 + if (!performed_allocation)
3767 + DLIMIT_FREE_BLOCK(inode, *count);
3771 ext3_std_error(sb, fatal);
3772 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/file.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/file.c
3773 --- linux-2.6.22.10/fs/ext3/file.c 2007-05-02 19:25:17 +0200
3774 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/file.c 2007-09-12 20:04:16 +0200
3775 @@ -135,5 +135,6 @@ const struct inode_operations ext3_file_
3776 .removexattr = generic_removexattr,
3778 .permission = ext3_permission,
3779 + .sync_flags = ext3_sync_flags,
3782 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/ialloc.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/ialloc.c
3783 --- linux-2.6.22.10/fs/ext3/ialloc.c 2006-11-30 21:19:19 +0100
3784 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/ialloc.c 2007-08-05 20:53:12 +0200
3786 #include <linux/buffer_head.h>
3787 #include <linux/random.h>
3788 #include <linux/bitops.h>
3789 +#include <linux/vs_dlimit.h>
3790 +#include <linux/vs_tag.h>
3792 #include <asm/byteorder.h>
3794 @@ -127,6 +129,7 @@ void ext3_free_inode (handle_t *handle,
3795 ext3_xattr_delete_inode(handle, inode);
3796 DQUOT_FREE_INODE(inode);
3798 + DLIMIT_FREE_INODE(inode);
3800 is_directory = S_ISDIR(inode->i_mode);
3802 @@ -445,6 +448,12 @@ struct inode *ext3_new_inode(handle_t *h
3803 inode = new_inode(sb);
3805 return ERR_PTR(-ENOMEM);
3807 + inode->i_tag = dx_current_fstag(sb);
3808 + if (DLIMIT_ALLOC_INODE(inode)) {
3815 @@ -566,7 +575,8 @@ got:
3816 ei->i_dir_start_lookup = 0;
3819 - ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
3820 + ei->i_flags = EXT3_I(dir)->i_flags &
3821 + ~(EXT3_INDEX_FL|EXT3_IUNLINK_FL|EXT3_BARRIER_FL);
3823 ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
3824 /* dirsync only applies to directories */
3825 @@ -621,6 +631,8 @@ got:
3827 ext3_std_error(sb, err);
3829 + DLIMIT_FREE_INODE(inode);
3834 @@ -632,6 +644,7 @@ fail_free_drop:
3838 + DLIMIT_FREE_INODE(inode);
3839 inode->i_flags |= S_NOQUOTA;
3842 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/inode.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/inode.c
3843 --- linux-2.6.22.10/fs/ext3/inode.c 2007-07-09 13:19:23 +0200
3844 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/inode.c 2007-08-18 02:52:34 +0200
3846 #include <linux/mpage.h>
3847 #include <linux/uio.h>
3848 #include <linux/bio.h>
3849 +#include <linux/vs_tag.h>
3853 @@ -2237,7 +2238,7 @@ void ext3_truncate(struct inode *inode)
3855 if (ext3_inode_is_fast_symlink(inode))
3857 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3858 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3862 @@ -2559,13 +2560,20 @@ void ext3_set_inode_flags(struct inode *
3864 unsigned int flags = EXT3_I(inode)->i_flags;
3866 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3867 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
3868 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3870 + if (flags & EXT3_IMMUTABLE_FL)
3871 + inode->i_flags |= S_IMMUTABLE;
3872 + if (flags & EXT3_IUNLINK_FL)
3873 + inode->i_flags |= S_IUNLINK;
3874 + if (flags & EXT3_BARRIER_FL)
3875 + inode->i_flags |= S_BARRIER;
3877 if (flags & EXT3_SYNC_FL)
3878 inode->i_flags |= S_SYNC;
3879 if (flags & EXT3_APPEND_FL)
3880 inode->i_flags |= S_APPEND;
3881 - if (flags & EXT3_IMMUTABLE_FL)
3882 - inode->i_flags |= S_IMMUTABLE;
3883 if (flags & EXT3_NOATIME_FL)
3884 inode->i_flags |= S_NOATIME;
3885 if (flags & EXT3_DIRSYNC_FL)
3886 @@ -2591,6 +2599,45 @@ void ext3_get_inode_flags(struct ext3_in
3887 ei->i_flags |= EXT3_DIRSYNC_FL;
3890 +int ext3_sync_flags(struct inode *inode)
3892 + unsigned int oldflags, newflags;
3895 + oldflags = EXT3_I(inode)->i_flags;
3896 + newflags = oldflags & ~(EXT3_IMMUTABLE_FL |
3897 + EXT3_IUNLINK_FL | EXT3_BARRIER_FL);
3899 + if (IS_IMMUTABLE(inode))
3900 + newflags |= EXT3_IMMUTABLE_FL;
3901 + if (IS_IUNLINK(inode))
3902 + newflags |= EXT3_IUNLINK_FL;
3903 + if (IS_BARRIER(inode))
3904 + newflags |= EXT3_BARRIER_FL;
3906 + if (oldflags ^ newflags) {
3908 + struct ext3_iloc iloc;
3910 + handle = ext3_journal_start(inode, 1);
3911 + if (IS_ERR(handle))
3912 + return PTR_ERR(handle);
3913 + if (IS_SYNC(inode))
3914 + handle->h_sync = 1;
3915 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3919 + EXT3_I(inode)->i_flags = newflags;
3920 + inode->i_ctime = CURRENT_TIME;
3922 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3924 + ext3_journal_stop(handle);
3929 void ext3_read_inode(struct inode * inode)
3931 struct ext3_iloc iloc;
3932 @@ -2598,6 +2645,8 @@ void ext3_read_inode(struct inode * inod
3933 struct ext3_inode_info *ei = EXT3_I(inode);
3934 struct buffer_head *bh;
3939 #ifdef CONFIG_EXT3_FS_POSIX_ACL
3940 ei->i_acl = EXT3_ACL_NOT_CACHED;
3941 @@ -2610,12 +2659,17 @@ void ext3_read_inode(struct inode * inod
3943 raw_inode = ext3_raw_inode(&iloc);
3944 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3945 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3946 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3947 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3948 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3949 if(!(test_opt (inode->i_sb, NO_UID32))) {
3950 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3951 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3952 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3953 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3955 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3956 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3957 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3958 + le16_to_cpu(raw_inode->i_raw_tag));
3960 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3961 inode->i_size = le32_to_cpu(raw_inode->i_size);
3962 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3963 @@ -2741,6 +2795,8 @@ static int ext3_do_update_inode(handle_t
3964 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3965 struct ext3_inode_info *ei = EXT3_I(inode);
3966 struct buffer_head *bh = iloc->bh;
3967 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3968 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3969 int err = 0, rc, block;
3971 /* For fields not not tracking in the in-memory inode,
3972 @@ -2751,29 +2807,32 @@ static int ext3_do_update_inode(handle_t
3973 ext3_get_inode_flags(ei);
3974 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3975 if(!(test_opt(inode->i_sb, NO_UID32))) {
3976 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3977 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3978 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3979 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3981 * Fix up interoperability with old kernels. Otherwise, old inodes get
3982 * re-used with the upper 16 bits of the uid/gid intact
3985 raw_inode->i_uid_high =
3986 - cpu_to_le16(high_16_bits(inode->i_uid));
3987 + cpu_to_le16(high_16_bits(uid));
3988 raw_inode->i_gid_high =
3989 - cpu_to_le16(high_16_bits(inode->i_gid));
3990 + cpu_to_le16(high_16_bits(gid));
3992 raw_inode->i_uid_high = 0;
3993 raw_inode->i_gid_high = 0;
3996 raw_inode->i_uid_low =
3997 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3998 + cpu_to_le16(fs_high2lowuid(uid));
3999 raw_inode->i_gid_low =
4000 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4001 + cpu_to_le16(fs_high2lowgid(gid));
4002 raw_inode->i_uid_high = 0;
4003 raw_inode->i_gid_high = 0;
4005 +#ifdef CONFIG_TAGGING_INTERN
4006 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4008 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4009 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4010 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4011 @@ -2926,7 +2985,8 @@ int ext3_setattr(struct dentry *dentry,
4014 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4015 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4016 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4017 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4020 /* (user+group)*(old+new) structure, inode write (sb,
4021 @@ -2948,6 +3008,8 @@ int ext3_setattr(struct dentry *dentry,
4022 inode->i_uid = attr->ia_uid;
4023 if (attr->ia_valid & ATTR_GID)
4024 inode->i_gid = attr->ia_gid;
4025 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4026 + inode->i_tag = attr->ia_tag;
4027 error = ext3_mark_inode_dirty(handle, inode);
4028 ext3_journal_stop(handle);
4030 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/ioctl.c
4031 --- linux-2.6.22.10/fs/ext3/ioctl.c 2007-07-09 13:19:23 +0200
4032 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/ioctl.c 2007-08-05 20:53:12 +0200
4036 #include <linux/fs.h>
4037 +#include <linux/mount.h>
4038 #include <linux/jbd.h>
4039 #include <linux/capability.h>
4040 #include <linux/ext3_fs.h>
4042 #include <linux/time.h>
4043 #include <linux/compat.h>
4044 #include <linux/smp_lock.h>
4045 +#include <linux/vs_tag.h>
4046 #include <asm/uaccess.h>
4048 int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
4049 @@ -38,7 +40,8 @@ int ext3_ioctl (struct inode * inode, st
4050 unsigned int oldflags;
4053 - if (IS_RDONLY(inode))
4054 + if (IS_RDONLY(inode) ||
4055 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4058 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4059 @@ -62,7 +65,9 @@ int ext3_ioctl (struct inode * inode, st
4061 * This test looks nicer. Thanks to Pauline Middelink
4063 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
4064 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
4065 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
4066 + EXT3_IMMUTABLE_FL | EXT3_IUNLINK_FL))) {
4067 if (!capable(CAP_LINUX_IMMUTABLE)) {
4068 mutex_unlock(&inode->i_mutex);
4070 @@ -124,7 +129,8 @@ flags_err:
4072 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4074 - if (IS_RDONLY(inode))
4075 + if (IS_RDONLY(inode) ||
4076 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4078 if (get_user(generation, (int __user *) arg))
4080 @@ -178,7 +184,8 @@ flags_err:
4081 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
4084 - if (IS_RDONLY(inode))
4085 + if (IS_RDONLY(inode) ||
4086 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4089 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4090 @@ -213,7 +220,8 @@ flags_err:
4091 if (!capable(CAP_SYS_RESOURCE))
4094 - if (IS_RDONLY(inode))
4095 + if (IS_RDONLY(inode) ||
4096 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4099 if (get_user(n_blocks_count, (__u32 __user *)arg))
4100 @@ -234,7 +242,8 @@ flags_err:
4101 if (!capable(CAP_SYS_RESOURCE))
4104 - if (IS_RDONLY(inode))
4105 + if (IS_RDONLY(inode) ||
4106 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4109 if (copy_from_user(&input, (struct ext3_new_group_input __user *)arg,
4110 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/namei.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/namei.c
4111 --- linux-2.6.22.10/fs/ext3/namei.c 2007-10-30 01:57:14 +0100
4112 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/namei.c 2007-09-30 14:58:01 +0200
4114 #include <linux/quotaops.h>
4115 #include <linux/buffer_head.h>
4116 #include <linux/bio.h>
4117 +#include <linux/vs_tag.h>
4121 @@ -1052,6 +1053,7 @@ static struct dentry *ext3_lookup(struct
4124 return ERR_PTR(-EACCES);
4125 + dx_propagate_tag(nd, inode);
4127 return d_splice_alias(inode, dentry);
4129 @@ -2443,6 +2445,7 @@ const struct inode_operations ext3_dir_i
4130 .removexattr = generic_removexattr,
4132 .permission = ext3_permission,
4133 + .sync_flags = ext3_sync_flags,
4136 const struct inode_operations ext3_special_inode_operations = {
4137 @@ -2454,4 +2457,5 @@ const struct inode_operations ext3_speci
4138 .removexattr = generic_removexattr,
4140 .permission = ext3_permission,
4141 + .sync_flags = ext3_sync_flags,
4143 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/super.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/super.c
4144 --- linux-2.6.22.10/fs/ext3/super.c 2007-07-09 13:19:23 +0200
4145 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/super.c 2007-08-05 20:53:12 +0200
4146 @@ -674,7 +674,7 @@ enum {
4147 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4148 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
4149 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
4151 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
4154 static match_table_t tokens = {
4155 @@ -724,6 +724,9 @@ static match_table_t tokens = {
4156 {Opt_quota, "quota"},
4157 {Opt_usrquota, "usrquota"},
4158 {Opt_barrier, "barrier=%u"},
4160 + {Opt_notag, "notag"},
4161 + {Opt_tagid, "tagid=%u"},
4163 {Opt_resize, "resize"},
4165 @@ -817,6 +820,20 @@ static int parse_options (char *options,
4167 set_opt (sbi->s_mount_opt, NO_UID32);
4169 +#ifndef CONFIG_TAGGING_NONE
4171 + set_opt (sbi->s_mount_opt, TAGGED);
4174 + clear_opt (sbi->s_mount_opt, TAGGED);
4177 +#ifdef CONFIG_PROPAGATE
4180 + set_opt (sbi->s_mount_opt, TAGGED);
4184 clear_opt (sbi->s_mount_opt, CHECK);
4186 @@ -1487,6 +1504,9 @@ static int ext3_fill_super (struct super
4190 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
4191 + sb->s_flags |= MS_TAGGED;
4193 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4194 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4196 @@ -2302,6 +2322,12 @@ static int ext3_remount (struct super_bl
4198 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
4199 ext3_abort(sb, __FUNCTION__, "Abort forced by user");
4200 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
4201 + !(sb->s_flags & MS_TAGGED)) {
4202 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
4207 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4208 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4209 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/symlink.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/symlink.c
4210 --- linux-2.6.22.10/fs/ext3/symlink.c 2007-05-02 19:25:17 +0200
4211 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/symlink.c 2007-08-05 20:53:12 +0200
4212 @@ -40,6 +40,7 @@ const struct inode_operations ext3_symli
4213 .listxattr = ext3_listxattr,
4214 .removexattr = generic_removexattr,
4216 + .sync_flags = ext3_sync_flags,
4219 const struct inode_operations ext3_fast_symlink_inode_operations = {
4220 @@ -51,4 +52,5 @@ const struct inode_operations ext3_fast_
4221 .listxattr = ext3_listxattr,
4222 .removexattr = generic_removexattr,
4224 + .sync_flags = ext3_sync_flags,
4226 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/xattr.c
4227 --- linux-2.6.22.10/fs/ext3/xattr.c 2007-05-02 19:25:17 +0200
4228 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/xattr.c 2007-08-05 20:53:12 +0200
4230 #include <linux/mbcache.h>
4231 #include <linux/quotaops.h>
4232 #include <linux/rwsem.h>
4233 +#include <linux/vs_dlimit.h>
4237 @@ -497,6 +498,7 @@ ext3_xattr_release_block(handle_t *handl
4238 error = ext3_journal_dirty_metadata(handle, bh);
4241 + DLIMIT_FREE_BLOCK(inode, 1);
4242 DQUOT_FREE_BLOCK(inode, 1);
4243 ea_bdebug(bh, "refcount now=%d; releasing",
4244 le32_to_cpu(BHDR(bh)->h_refcount));
4245 @@ -771,11 +773,14 @@ inserted:
4246 if (new_bh == bs->bh)
4247 ea_bdebug(new_bh, "keeping");
4250 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
4252 /* The old block is released after updating
4255 if (DQUOT_ALLOC_BLOCK(inode, 1))
4257 + goto cleanup_dlimit;
4258 error = ext3_journal_get_write_access(handle,
4261 @@ -852,6 +857,8 @@ cleanup:
4264 DQUOT_FREE_BLOCK(inode, 1);
4266 + DLIMIT_FREE_BLOCK(inode, 1);
4270 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/balloc.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/balloc.c
4271 --- linux-2.6.22.10/fs/ext4/balloc.c 2007-07-09 13:19:23 +0200
4272 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/balloc.c 2007-08-05 20:53:12 +0200
4274 #include <linux/ext4_jbd2.h>
4275 #include <linux/quotaops.h>
4276 #include <linux/buffer_head.h>
4277 +#include <linux/vs_dlimit.h>
4278 +#include <linux/vs_tag.h>
4281 * balloc.c contains the blocks allocation and deallocation routines
4282 @@ -630,8 +632,10 @@ void ext4_free_blocks(handle_t *handle,
4285 ext4_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
4286 - if (dquot_freed_blocks)
4287 + if (dquot_freed_blocks) {
4288 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
4289 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
4294 @@ -1370,18 +1374,33 @@ out:
4296 * Check if filesystem has at least 1 free block available for allocation.
4298 -static int ext4_has_free_blocks(struct ext4_sb_info *sbi)
4299 +static int ext4_has_free_blocks(struct super_block *sb)
4301 + struct ext4_sb_info *sbi = EXT4_SB(sb);
4302 ext4_fsblk_t free_blocks, root_blocks;
4305 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
4306 root_blocks = ext4_r_blocks_count(sbi->s_es);
4307 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
4309 + vxdprintk(VXD_CBIT(dlim, 3),
4310 + "ext4_has_free_blocks(%p): free=%llu, root=%llu",
4311 + sb, free_blocks, root_blocks);
4313 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
4315 + cond = (free_blocks < root_blocks + 1 &&
4316 + !capable(CAP_SYS_RESOURCE) &&
4317 sbi->s_resuid != current->fsuid &&
4318 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
4322 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
4324 + vxdprintk(VXD_CBIT(dlim, 3),
4325 + "ext4_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
4326 + sb, free_blocks, root_blocks,
4327 + !capable(CAP_SYS_RESOURCE)?'1':'0',
4328 + sbi->s_resuid, current->fsuid, cond?0:1);
4330 + return (cond ? 0 : 1);
4334 @@ -1398,7 +1417,7 @@ static int ext4_has_free_blocks(struct e
4336 int ext4_should_retry_alloc(struct super_block *sb, int *retries)
4338 - if (!ext4_has_free_blocks(EXT4_SB(sb)) || (*retries)++ > 3)
4339 + if (!ext4_has_free_blocks(sb) || (*retries)++ > 3)
4342 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
4343 @@ -1461,6 +1480,8 @@ ext4_fsblk_t ext4_new_blocks(handle_t *h
4347 + if (DLIMIT_ALLOC_BLOCK(inode, num))
4351 es = EXT4_SB(sb)->s_es;
4352 @@ -1477,7 +1498,7 @@ ext4_fsblk_t ext4_new_blocks(handle_t *h
4353 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
4354 my_rsv = &block_i->rsv_window_node;
4356 - if (!ext4_has_free_blocks(sbi)) {
4357 + if (!ext4_has_free_blocks(sb)) {
4361 @@ -1661,12 +1682,16 @@ allocated:
4364 DQUOT_FREE_BLOCK(inode, *count-num);
4365 + DLIMIT_FREE_BLOCK(inode, *count-num);
4372 + if (!performed_allocation)
4373 + DLIMIT_FREE_BLOCK(inode, *count);
4377 ext4_std_error(sb, fatal);
4378 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/file.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/file.c
4379 --- linux-2.6.22.10/fs/ext4/file.c 2007-05-02 19:25:17 +0200
4380 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/file.c 2007-09-12 20:04:16 +0200
4381 @@ -135,5 +135,6 @@ const struct inode_operations ext4_file_
4382 .removexattr = generic_removexattr,
4384 .permission = ext4_permission,
4385 + .sync_flags = ext4_sync_flags,
4388 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/ialloc.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/ialloc.c
4389 --- linux-2.6.22.10/fs/ext4/ialloc.c 2006-11-30 21:19:20 +0100
4390 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/ialloc.c 2007-08-05 20:53:12 +0200
4392 #include <linux/random.h>
4393 #include <linux/bitops.h>
4394 #include <linux/blkdev.h>
4395 +#include <linux/vs_dlimit.h>
4396 +#include <linux/vs_tag.h>
4397 #include <asm/byteorder.h>
4400 @@ -127,6 +129,7 @@ void ext4_free_inode (handle_t *handle,
4401 ext4_xattr_delete_inode(handle, inode);
4402 DQUOT_FREE_INODE(inode);
4404 + DLIMIT_FREE_INODE(inode);
4406 is_directory = S_ISDIR(inode->i_mode);
4408 @@ -448,6 +451,12 @@ struct inode *ext4_new_inode(handle_t *h
4409 inode = new_inode(sb);
4411 return ERR_PTR(-ENOMEM);
4413 + inode->i_tag = dx_current_fstag(sb);
4414 + if (DLIMIT_ALLOC_INODE(inode)) {
4421 @@ -569,7 +578,8 @@ got:
4422 ei->i_dir_start_lookup = 0;
4425 - ei->i_flags = EXT4_I(dir)->i_flags & ~EXT4_INDEX_FL;
4426 + ei->i_flags = EXT4_I(dir)->i_flags &
4427 + ~(EXT4_INDEX_FL|EXT4_IUNLINK_FL|EXT4_BARRIER_FL);
4429 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
4430 /* dirsync only applies to directories */
4431 @@ -635,6 +645,8 @@ got:
4433 ext4_std_error(sb, err);
4435 + DLIMIT_FREE_INODE(inode);
4440 @@ -646,6 +658,7 @@ fail_free_drop:
4444 + DLIMIT_FREE_INODE(inode);
4445 inode->i_flags |= S_NOQUOTA;
4448 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/inode.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/inode.c
4449 --- linux-2.6.22.10/fs/ext4/inode.c 2007-07-09 13:19:23 +0200
4450 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/inode.c 2007-08-18 02:52:34 +0200
4452 #include <linux/mpage.h>
4453 #include <linux/uio.h>
4454 #include <linux/bio.h>
4455 +#include <linux/vs_tag.h>
4459 @@ -2244,7 +2245,7 @@ void ext4_truncate(struct inode *inode)
4461 if (ext4_inode_is_fast_symlink(inode))
4463 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4464 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4468 @@ -2570,19 +2571,65 @@ void ext4_set_inode_flags(struct inode *
4470 unsigned int flags = EXT4_I(inode)->i_flags;
4472 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4473 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
4474 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4476 + if (flags & EXT4_IMMUTABLE_FL)
4477 + inode->i_flags |= S_IMMUTABLE;
4478 + if (flags & EXT4_IUNLINK_FL)
4479 + inode->i_flags |= S_IUNLINK;
4480 + if (flags & EXT4_BARRIER_FL)
4481 + inode->i_flags |= S_BARRIER;
4483 if (flags & EXT4_SYNC_FL)
4484 inode->i_flags |= S_SYNC;
4485 if (flags & EXT4_APPEND_FL)
4486 inode->i_flags |= S_APPEND;
4487 - if (flags & EXT4_IMMUTABLE_FL)
4488 - inode->i_flags |= S_IMMUTABLE;
4489 if (flags & EXT4_NOATIME_FL)
4490 inode->i_flags |= S_NOATIME;
4491 if (flags & EXT4_DIRSYNC_FL)
4492 inode->i_flags |= S_DIRSYNC;
4495 +int ext4_sync_flags(struct inode *inode)
4497 + unsigned int oldflags, newflags;
4500 + oldflags = EXT4_I(inode)->i_flags;
4501 + newflags = oldflags & ~(EXT4_IMMUTABLE_FL |
4502 + EXT4_IUNLINK_FL | EXT4_BARRIER_FL);
4504 + if (IS_IMMUTABLE(inode))
4505 + newflags |= EXT4_IMMUTABLE_FL;
4506 + if (IS_IUNLINK(inode))
4507 + newflags |= EXT4_IUNLINK_FL;
4508 + if (IS_BARRIER(inode))
4509 + newflags |= EXT4_BARRIER_FL;
4511 + if (oldflags ^ newflags) {
4513 + struct ext4_iloc iloc;
4515 + handle = ext4_journal_start(inode, 1);
4516 + if (IS_ERR(handle))
4517 + return PTR_ERR(handle);
4518 + if (IS_SYNC(inode))
4519 + handle->h_sync = 1;
4520 + err = ext4_reserve_inode_write(handle, inode, &iloc);
4524 + EXT4_I(inode)->i_flags = newflags;
4525 + inode->i_ctime = CURRENT_TIME;
4527 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
4529 + ext4_journal_stop(handle);
4534 void ext4_read_inode(struct inode * inode)
4536 struct ext4_iloc iloc;
4537 @@ -2590,6 +2637,8 @@ void ext4_read_inode(struct inode * inod
4538 struct ext4_inode_info *ei = EXT4_I(inode);
4539 struct buffer_head *bh;
4544 #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
4545 ei->i_acl = EXT4_ACL_NOT_CACHED;
4546 @@ -2602,12 +2651,17 @@ void ext4_read_inode(struct inode * inod
4548 raw_inode = ext4_raw_inode(&iloc);
4549 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4550 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4551 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4552 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4553 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4554 if(!(test_opt (inode->i_sb, NO_UID32))) {
4555 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4556 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4557 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4558 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4560 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4561 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4562 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4563 + le16_to_cpu(raw_inode->i_raw_tag));
4565 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4566 inode->i_size = le32_to_cpu(raw_inode->i_size);
4567 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4568 @@ -2737,6 +2791,8 @@ static int ext4_do_update_inode(handle_t
4569 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
4570 struct ext4_inode_info *ei = EXT4_I(inode);
4571 struct buffer_head *bh = iloc->bh;
4572 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4573 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4574 int err = 0, rc, block;
4576 /* For fields not not tracking in the in-memory inode,
4577 @@ -2746,29 +2802,32 @@ static int ext4_do_update_inode(handle_t
4579 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4580 if(!(test_opt(inode->i_sb, NO_UID32))) {
4581 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4582 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4583 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4584 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4586 * Fix up interoperability with old kernels. Otherwise, old inodes get
4587 * re-used with the upper 16 bits of the uid/gid intact
4590 raw_inode->i_uid_high =
4591 - cpu_to_le16(high_16_bits(inode->i_uid));
4592 + cpu_to_le16(high_16_bits(uid));
4593 raw_inode->i_gid_high =
4594 - cpu_to_le16(high_16_bits(inode->i_gid));
4595 + cpu_to_le16(high_16_bits(gid));
4597 raw_inode->i_uid_high = 0;
4598 raw_inode->i_gid_high = 0;
4601 raw_inode->i_uid_low =
4602 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
4603 + cpu_to_le16(fs_high2lowuid(uid));
4604 raw_inode->i_gid_low =
4605 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4606 + cpu_to_le16(fs_high2lowgid(gid));
4607 raw_inode->i_uid_high = 0;
4608 raw_inode->i_gid_high = 0;
4610 +#ifdef CONFIG_TAGGING_INTERN
4611 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4613 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4614 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4615 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4616 @@ -2925,7 +2984,8 @@ int ext4_setattr(struct dentry *dentry,
4619 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4620 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4621 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4622 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4625 /* (user+group)*(old+new) structure, inode write (sb,
4626 @@ -2947,6 +3007,8 @@ int ext4_setattr(struct dentry *dentry,
4627 inode->i_uid = attr->ia_uid;
4628 if (attr->ia_valid & ATTR_GID)
4629 inode->i_gid = attr->ia_gid;
4630 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4631 + inode->i_tag = attr->ia_tag;
4632 error = ext4_mark_inode_dirty(handle, inode);
4633 ext4_journal_stop(handle);
4635 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/ioctl.c
4636 --- linux-2.6.22.10/fs/ext4/ioctl.c 2007-02-06 03:01:18 +0100
4637 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/ioctl.c 2007-08-05 20:53:12 +0200
4641 #include <linux/fs.h>
4642 +#include <linux/mount.h>
4643 #include <linux/jbd2.h>
4644 #include <linux/capability.h>
4645 #include <linux/ext4_fs.h>
4647 #include <linux/time.h>
4648 #include <linux/compat.h>
4649 #include <linux/smp_lock.h>
4650 +#include <linux/vs_tag.h>
4651 #include <asm/uaccess.h>
4653 int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
4654 @@ -37,7 +39,8 @@ int ext4_ioctl (struct inode * inode, st
4655 unsigned int oldflags;
4658 - if (IS_RDONLY(inode))
4659 + if (IS_RDONLY(inode) ||
4660 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4663 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4664 @@ -61,7 +64,9 @@ int ext4_ioctl (struct inode * inode, st
4666 * This test looks nicer. Thanks to Pauline Middelink
4668 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
4669 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
4670 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
4671 + EXT4_IMMUTABLE_FL | EXT4_IUNLINK_FL))) {
4672 if (!capable(CAP_LINUX_IMMUTABLE)) {
4673 mutex_unlock(&inode->i_mutex);
4675 @@ -123,7 +128,8 @@ flags_err:
4677 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4679 - if (IS_RDONLY(inode))
4680 + if (IS_RDONLY(inode) ||
4681 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4683 if (get_user(generation, (int __user *) arg))
4685 @@ -177,7 +183,8 @@ flags_err:
4686 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
4689 - if (IS_RDONLY(inode))
4690 + if (IS_RDONLY(inode) ||
4691 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4694 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4695 @@ -212,7 +219,8 @@ flags_err:
4696 if (!capable(CAP_SYS_RESOURCE))
4699 - if (IS_RDONLY(inode))
4700 + if (IS_RDONLY(inode) ||
4701 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4704 if (get_user(n_blocks_count, (__u32 __user *)arg))
4705 @@ -233,7 +241,8 @@ flags_err:
4706 if (!capable(CAP_SYS_RESOURCE))
4709 - if (IS_RDONLY(inode))
4710 + if (IS_RDONLY(inode) ||
4711 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4714 if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg,
4715 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/namei.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/namei.c
4716 --- linux-2.6.22.10/fs/ext4/namei.c 2007-10-30 01:57:14 +0100
4717 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/namei.c 2007-09-30 14:58:01 +0200
4719 #include <linux/quotaops.h>
4720 #include <linux/buffer_head.h>
4721 #include <linux/bio.h>
4722 +#include <linux/vs_tag.h>
4726 @@ -1050,6 +1051,7 @@ static struct dentry *ext4_lookup(struct
4729 return ERR_PTR(-EACCES);
4730 + dx_propagate_tag(nd, inode);
4732 return d_splice_alias(inode, dentry);
4734 @@ -2441,6 +2443,7 @@ const struct inode_operations ext4_dir_i
4735 .removexattr = generic_removexattr,
4737 .permission = ext4_permission,
4738 + .sync_flags = ext4_sync_flags,
4741 const struct inode_operations ext4_special_inode_operations = {
4742 @@ -2452,4 +2455,5 @@ const struct inode_operations ext4_speci
4743 .removexattr = generic_removexattr,
4745 .permission = ext4_permission,
4746 + .sync_flags = ext4_sync_flags,
4748 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/super.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/super.c
4749 --- linux-2.6.22.10/fs/ext4/super.c 2007-07-09 13:19:23 +0200
4750 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/super.c 2007-08-05 20:53:12 +0200
4751 @@ -725,7 +725,7 @@ enum {
4752 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4753 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
4754 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
4755 - Opt_grpquota, Opt_extents,
4756 + Opt_grpquota, Opt_extents, Opt_tag, Opt_notag, Opt_tagid
4759 static match_table_t tokens = {
4760 @@ -776,6 +776,9 @@ static match_table_t tokens = {
4761 {Opt_usrquota, "usrquota"},
4762 {Opt_barrier, "barrier=%u"},
4763 {Opt_extents, "extents"},
4765 + {Opt_notag, "notag"},
4766 + {Opt_tagid, "tagid=%u"},
4768 {Opt_resize, "resize"},
4770 @@ -869,6 +872,20 @@ static int parse_options (char *options,
4772 set_opt (sbi->s_mount_opt, NO_UID32);
4774 +#ifndef CONFIG_TAGGING_NONE
4776 + set_opt (sbi->s_mount_opt, TAGGED);
4779 + clear_opt (sbi->s_mount_opt, TAGGED);
4782 +#ifdef CONFIG_PROPAGATE
4785 + set_opt (sbi->s_mount_opt, TAGGED);
4789 clear_opt (sbi->s_mount_opt, CHECK);
4791 @@ -1546,6 +1563,9 @@ static int ext4_fill_super (struct super
4795 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
4796 + sb->s_flags |= MS_TAGGED;
4798 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4799 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4801 @@ -2377,6 +2397,12 @@ static int ext4_remount (struct super_bl
4803 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
4804 ext4_abort(sb, __FUNCTION__, "Abort forced by user");
4805 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
4806 + !(sb->s_flags & MS_TAGGED)) {
4807 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
4812 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4813 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4814 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/symlink.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/symlink.c
4815 --- linux-2.6.22.10/fs/ext4/symlink.c 2007-05-02 19:25:17 +0200
4816 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/symlink.c 2007-08-05 20:53:12 +0200
4817 @@ -40,6 +40,7 @@ const struct inode_operations ext4_symli
4818 .listxattr = ext4_listxattr,
4819 .removexattr = generic_removexattr,
4821 + .sync_flags = ext4_sync_flags,
4824 const struct inode_operations ext4_fast_symlink_inode_operations = {
4825 @@ -51,4 +52,5 @@ const struct inode_operations ext4_fast_
4826 .listxattr = ext4_listxattr,
4827 .removexattr = generic_removexattr,
4829 + .sync_flags = ext4_sync_flags,
4831 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/xattr.c
4832 --- linux-2.6.22.10/fs/ext4/xattr.c 2007-05-02 19:25:17 +0200
4833 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/xattr.c 2007-08-05 20:53:12 +0200
4835 #include <linux/mbcache.h>
4836 #include <linux/quotaops.h>
4837 #include <linux/rwsem.h>
4838 +#include <linux/vs_dlimit.h>
4842 @@ -496,6 +497,7 @@ ext4_xattr_release_block(handle_t *handl
4843 error = ext4_journal_dirty_metadata(handle, bh);
4846 + DLIMIT_FREE_BLOCK(inode, 1);
4847 DQUOT_FREE_BLOCK(inode, 1);
4848 ea_bdebug(bh, "refcount now=%d; releasing",
4849 le32_to_cpu(BHDR(bh)->h_refcount));
4850 @@ -769,11 +771,14 @@ inserted:
4851 if (new_bh == bs->bh)
4852 ea_bdebug(new_bh, "keeping");
4855 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
4857 /* The old block is released after updating
4860 if (DQUOT_ALLOC_BLOCK(inode, 1))
4862 + goto cleanup_dlimit;
4863 error = ext4_journal_get_write_access(handle,
4866 @@ -850,6 +855,8 @@ cleanup:
4869 DQUOT_FREE_BLOCK(inode, 1);
4871 + DLIMIT_FREE_BLOCK(inode, 1);
4875 diff -NurpP --minimal linux-2.6.22.10/fs/fcntl.c linux-2.6.22.10-vs2.3.0.29/fs/fcntl.c
4876 --- linux-2.6.22.10/fs/fcntl.c 2007-02-06 03:01:18 +0100
4877 +++ linux-2.6.22.10-vs2.3.0.29/fs/fcntl.c 2007-08-05 20:53:12 +0200
4879 #include <linux/ptrace.h>
4880 #include <linux/signal.h>
4881 #include <linux/rcupdate.h>
4882 +#include <linux/vs_limit.h>
4884 #include <asm/poll.h>
4885 #include <asm/siginfo.h>
4886 @@ -84,6 +85,8 @@ repeat:
4888 if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
4890 + if (!vx_files_avail(1))
4893 error = expand_files(files, newfd);
4895 @@ -124,6 +127,7 @@ static int dupfd(struct file *file, unsi
4896 FD_SET(fd, fdt->open_fds);
4897 FD_CLR(fd, fdt->close_on_exec);
4898 spin_unlock(&files->file_lock);
4899 + vx_openfd_inc(fd);
4900 fd_install(fd, file);
4902 spin_unlock(&files->file_lock);
4903 @@ -176,6 +180,9 @@ asmlinkage long sys_dup2(unsigned int ol
4906 filp_close(tofree, files);
4908 + vx_openfd_inc(newfd); /* fd was unused */
4913 diff -NurpP --minimal linux-2.6.22.10/fs/file_table.c linux-2.6.22.10-vs2.3.0.29/fs/file_table.c
4914 --- linux-2.6.22.10/fs/file_table.c 2007-07-09 13:19:23 +0200
4915 +++ linux-2.6.22.10-vs2.3.0.29/fs/file_table.c 2007-08-05 20:53:12 +0200
4917 #include <linux/fsnotify.h>
4918 #include <linux/sysctl.h>
4919 #include <linux/percpu_counter.h>
4920 +#include <linux/vs_limit.h>
4921 +#include <linux/vs_context.h>
4923 #include <asm/atomic.h>
4925 @@ -119,6 +121,8 @@ struct file *get_empty_filp(void)
4926 f->f_gid = tsk->fsgid;
4927 eventpoll_init_file(f);
4928 /* f->f_version: 0 */
4929 + f->f_xid = vx_current_xid();
4934 @@ -174,6 +178,8 @@ void fastcall __fput(struct file *file)
4935 if (file->f_mode & FMODE_WRITE)
4936 put_write_access(inode);
4937 put_pid(file->f_owner.pid);
4938 + vx_files_dec(file);
4941 file->f_path.dentry = NULL;
4942 file->f_path.mnt = NULL;
4943 @@ -239,6 +245,8 @@ void put_filp(struct file *file)
4945 if (atomic_dec_and_test(&file->f_count)) {
4946 security_file_free(file);
4947 + vx_files_dec(file);
4952 diff -NurpP --minimal linux-2.6.22.10/fs/hfsplus/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/hfsplus/ioctl.c
4953 --- linux-2.6.22.10/fs/hfsplus/ioctl.c 2006-11-30 21:19:25 +0100
4954 +++ linux-2.6.22.10-vs2.3.0.29/fs/hfsplus/ioctl.c 2007-08-05 20:53:12 +0200
4956 #include <linux/fs.h>
4957 #include <linux/sched.h>
4958 #include <linux/xattr.h>
4959 +#include <linux/mount.h>
4960 #include <asm/uaccess.h>
4961 #include "hfsplus_fs.h"
4963 @@ -35,7 +36,8 @@ int hfsplus_ioctl(struct inode *inode, s
4964 flags |= FS_NODUMP_FL; /* EXT2_NODUMP_FL */
4965 return put_user(flags, (int __user *)arg);
4966 case HFSPLUS_IOC_EXT2_SETFLAGS: {
4967 - if (IS_RDONLY(inode))
4968 + if (IS_RDONLY(inode) ||
4969 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4972 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4973 diff -NurpP --minimal linux-2.6.22.10/fs/inode.c linux-2.6.22.10-vs2.3.0.29/fs/inode.c
4974 --- linux-2.6.22.10/fs/inode.c 2007-07-09 13:19:24 +0200
4975 +++ linux-2.6.22.10-vs2.3.0.29/fs/inode.c 2007-10-11 01:10:22 +0200
4976 @@ -115,6 +115,9 @@ static struct inode *alloc_inode(struct
4977 struct address_space * const mapping = &inode->i_data;
4981 + /* essential because of inode slab reuse */
4983 inode->i_blkbits = sb->s_blocksize_bits;
4985 atomic_set(&inode->i_count, 1);
4986 @@ -133,6 +136,7 @@ static struct inode *alloc_inode(struct
4987 inode->i_bdev = NULL;
4988 inode->i_cdev = NULL;
4990 + inode->i_mdev = 0;
4991 inode->dirtied_when = 0;
4992 if (security_inode_alloc(inode)) {
4993 if (inode->i_sb->s_op->destroy_inode)
4994 @@ -231,6 +235,8 @@ void __iget(struct inode * inode)
4995 inodes_stat.nr_unused--;
4998 +EXPORT_SYMBOL_GPL(__iget);
5001 * clear_inode - clear an inode
5002 * @inode: inode to clear
5003 @@ -1405,9 +1411,11 @@ void init_special_inode(struct inode *in
5004 if (S_ISCHR(mode)) {
5005 inode->i_fop = &def_chr_fops;
5006 inode->i_rdev = rdev;
5007 + inode->i_mdev = rdev;
5008 } else if (S_ISBLK(mode)) {
5009 inode->i_fop = &def_blk_fops;
5010 inode->i_rdev = rdev;
5011 + inode->i_mdev = rdev;
5012 } else if (S_ISFIFO(mode))
5013 inode->i_fop = &def_fifo_fops;
5014 else if (S_ISSOCK(mode))
5015 diff -NurpP --minimal linux-2.6.22.10/fs/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/ioctl.c
5016 --- linux-2.6.22.10/fs/ioctl.c 2007-07-09 13:19:24 +0200
5017 +++ linux-2.6.22.10-vs2.3.0.29/fs/ioctl.c 2007-08-05 20:53:12 +0200
5019 #include <linux/security.h>
5020 #include <linux/module.h>
5021 #include <linux/kallsyms.h>
5022 +#include <linux/proc_fs.h>
5023 +#include <linux/vserver/inode.h>
5024 +#include <linux/vs_tag.h>
5026 #include <asm/uaccess.h>
5027 #include <asm/ioctls.h>
5028 diff -NurpP --minimal linux-2.6.22.10/fs/ioprio.c linux-2.6.22.10-vs2.3.0.29/fs/ioprio.c
5029 --- linux-2.6.22.10/fs/ioprio.c 2007-05-02 19:25:18 +0200
5030 +++ linux-2.6.22.10-vs2.3.0.29/fs/ioprio.c 2007-08-05 20:53:12 +0200
5032 #include <linux/capability.h>
5033 #include <linux/syscalls.h>
5034 #include <linux/security.h>
5035 +#include <linux/vs_base.h>
5037 static int set_task_ioprio(struct task_struct *task, int ioprio)
5039 @@ -103,6 +104,8 @@ asmlinkage long sys_ioprio_set(int which
5041 pgrp = find_pid(who);
5042 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
5043 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5045 ret = set_task_ioprio(p, ioprio);
5048 @@ -112,7 +115,7 @@ asmlinkage long sys_ioprio_set(int which
5050 user = current->user;
5052 - user = find_user(who);
5053 + user = find_user(vx_current_xid(), who);
5057 @@ -190,6 +193,8 @@ asmlinkage long sys_ioprio_get(int which
5059 pgrp = find_pid(who);
5060 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
5061 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5063 tmpio = get_task_ioprio(p);
5066 @@ -203,7 +208,7 @@ asmlinkage long sys_ioprio_get(int which
5068 user = current->user;
5070 - user = find_user(who);
5071 + user = find_user(vx_current_xid(), who);
5075 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/dir.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/dir.c
5076 --- linux-2.6.22.10/fs/jffs2/dir.c 2007-07-09 13:19:26 +0200
5077 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/dir.c 2007-10-05 15:07:22 +0200
5078 @@ -32,7 +32,9 @@ static int jffs2_mkdir (struct inode *,s
5079 static int jffs2_rmdir (struct inode *,struct dentry *);
5080 static int jffs2_mknod (struct inode *,struct dentry *,int,dev_t);
5081 static int jffs2_rename (struct inode *, struct dentry *,
5082 - struct inode *, struct dentry *);
5083 + struct inode *, struct dentry *);
5085 +extern int jffs2_sync_flags(struct inode *);
5087 const struct file_operations jffs2_dir_operations =
5089 @@ -56,6 +58,7 @@ const struct inode_operations jffs2_dir_
5090 .rename = jffs2_rename,
5091 .permission = jffs2_permission,
5092 .setattr = jffs2_setattr,
5093 + .sync_flags = jffs2_sync_flags,
5094 .setxattr = jffs2_setxattr,
5095 .getxattr = jffs2_getxattr,
5096 .listxattr = jffs2_listxattr,
5097 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/file.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/file.c
5098 --- linux-2.6.22.10/fs/jffs2/file.c 2007-07-09 13:19:26 +0200
5099 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/file.c 2007-10-01 20:52:25 +0200
5101 #include <linux/highmem.h>
5102 #include <linux/crc32.h>
5103 #include <linux/jffs2.h>
5104 +#include <linux/vs_tag.h>
5105 #include "nodelist.h"
5107 static int jffs2_commit_write (struct file *filp, struct page *pg,
5108 @@ -25,6 +26,9 @@ static int jffs2_prepare_write (struct f
5109 unsigned start, unsigned end);
5110 static int jffs2_readpage (struct file *filp, struct page *pg);
5112 +extern int jffs2_sync_flags(struct inode *);
5115 int jffs2_fsync(struct file *filp, struct dentry *dentry, int datasync)
5117 struct inode *inode = dentry->d_inode;
5118 @@ -47,7 +51,9 @@ const struct file_operations jffs2_file_
5119 .ioctl = jffs2_ioctl,
5120 .mmap = generic_file_readonly_mmap,
5121 .fsync = jffs2_fsync,
5122 - .sendfile = generic_file_sendfile
5123 + .sendfile = generic_file_sendfile,
5124 + .splice_read = generic_file_splice_read,
5125 + .splice_write = generic_file_splice_write
5128 /* jffs2_file_inode_operations */
5129 @@ -56,6 +62,7 @@ const struct inode_operations jffs2_file
5131 .permission = jffs2_permission,
5132 .setattr = jffs2_setattr,
5133 + .sync_flags = jffs2_sync_flags,
5134 .setxattr = jffs2_setxattr,
5135 .getxattr = jffs2_getxattr,
5136 .listxattr = jffs2_listxattr,
5137 @@ -157,12 +164,14 @@ static int jffs2_prepare_write (struct f
5138 ri.mode = cpu_to_jemode(inode->i_mode);
5139 ri.uid = cpu_to_je16(inode->i_uid);
5140 ri.gid = cpu_to_je16(inode->i_gid);
5141 + ri.tag = cpu_to_je16(TAGINO_TAG(DX_TAG(inode), inode->i_tag));
5142 ri.isize = cpu_to_je32(max((uint32_t)inode->i_size, pageofs));
5143 ri.atime = ri.ctime = ri.mtime = cpu_to_je32(get_seconds());
5144 ri.offset = cpu_to_je32(inode->i_size);
5145 ri.dsize = cpu_to_je32(pageofs - inode->i_size);
5146 ri.csize = cpu_to_je32(0);
5147 ri.compr = JFFS2_COMPR_ZERO;
5148 + ri.flags = cpu_to_je16(f->flags);
5149 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
5150 ri.data_crc = cpu_to_je32(0);
5152 @@ -248,8 +257,10 @@ static int jffs2_commit_write (struct fi
5153 ri->mode = cpu_to_jemode(inode->i_mode);
5154 ri->uid = cpu_to_je16(inode->i_uid);
5155 ri->gid = cpu_to_je16(inode->i_gid);
5156 + ri->tag = cpu_to_je16(TAGINO_TAG(DX_TAG(inode), inode->i_tag));
5157 ri->isize = cpu_to_je32((uint32_t)inode->i_size);
5158 ri->atime = ri->ctime = ri->mtime = cpu_to_je32(get_seconds());
5159 + ri->flags = cpu_to_je16(f->flags);
5161 /* In 2.4, it was already kmapped by generic_file_write(). Doesn't
5162 hurt to do it again. The alternative is ifdefs, which are ugly. */
5163 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/fs.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/fs.c
5164 --- linux-2.6.22.10/fs/jffs2/fs.c 2007-10-30 01:57:14 +0100
5165 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/fs.c 2007-09-30 14:58:01 +0200
5167 #include <linux/vmalloc.h>
5168 #include <linux/vfs.h>
5169 #include <linux/crc32.h>
5170 +#include <linux/vs_tag.h>
5171 #include "nodelist.h"
5173 static int jffs2_flash_setup(struct jffs2_sb_info *c);
5174 @@ -97,6 +98,7 @@ static int jffs2_do_setattr (struct inod
5176 ri->uid = cpu_to_je16((ivalid & ATTR_UID)?iattr->ia_uid:inode->i_uid);
5177 ri->gid = cpu_to_je16((ivalid & ATTR_GID)?iattr->ia_gid:inode->i_gid);
5178 + ri->tag = cpu_to_je16((ivalid & ATTR_TAG)?iattr->ia_tag:inode->i_tag);
5180 if (ivalid & ATTR_MODE)
5181 if (iattr->ia_mode & S_ISGID &&
5182 @@ -116,6 +118,8 @@ static int jffs2_do_setattr (struct inod
5183 ri->offset = cpu_to_je32(0);
5184 ri->csize = ri->dsize = cpu_to_je32(mdatalen);
5185 ri->compr = JFFS2_COMPR_NONE;
5186 + ri->flags = cpu_to_je16(f->flags);
5188 if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {
5189 /* It's an extension. Make it a hole node */
5190 ri->compr = JFFS2_COMPR_ZERO;
5191 @@ -145,6 +149,7 @@ static int jffs2_do_setattr (struct inod
5192 inode->i_mode = jemode_to_cpu(ri->mode);
5193 inode->i_uid = je16_to_cpu(ri->uid);
5194 inode->i_gid = je16_to_cpu(ri->gid);
5195 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), 0, 0, je16_to_cpu(ri->tag));
5198 old_metadata = f->metadata;
5199 @@ -179,6 +184,48 @@ static int jffs2_do_setattr (struct inod
5203 +void jffs2_set_inode_flags(struct inode *inode)
5205 + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
5206 + unsigned int flags = f->flags;
5208 + inode->i_flags &= ~(JFFS2_INO_FLAG_IMMUTABLE |
5209 + JFFS2_INO_FLAG_IUNLINK | JFFS2_INO_FLAG_BARRIER);
5211 + if (flags & JFFS2_INO_FLAG_IMMUTABLE)
5212 + inode->i_flags |= S_IMMUTABLE;
5213 + if (flags & JFFS2_INO_FLAG_IUNLINK)
5214 + inode->i_flags |= S_IUNLINK;
5215 + if (flags & JFFS2_INO_FLAG_BARRIER)
5216 + inode->i_flags |= S_BARRIER;
5219 +int jffs2_sync_flags(struct inode *inode)
5221 + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
5222 + unsigned int oldflags, newflags;
5224 + oldflags = f->flags;
5225 + newflags = oldflags & ~(JFFS2_INO_FLAG_IMMUTABLE |
5226 + JFFS2_INO_FLAG_IUNLINK | JFFS2_INO_FLAG_BARRIER);
5228 + if (IS_IMMUTABLE(inode))
5229 + newflags |= JFFS2_INO_FLAG_IMMUTABLE;
5230 + if (IS_IUNLINK(inode))
5231 + newflags |= JFFS2_INO_FLAG_IUNLINK;
5232 + if (IS_BARRIER(inode))
5233 + newflags |= JFFS2_INO_FLAG_BARRIER;
5235 + if (oldflags ^ newflags) {
5236 + f->flags = newflags;
5237 + inode->i_ctime = CURRENT_TIME;
5238 + /* strange requirement, see jffs2_dirty_inode() */
5239 + inode->i_state |= I_DIRTY_DATASYNC;
5240 + mark_inode_dirty(inode);
5245 int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
5248 @@ -254,6 +301,8 @@ void jffs2_read_inode (struct inode *ino
5249 inode->i_mode = jemode_to_cpu(latest_node.mode);
5250 inode->i_uid = je16_to_cpu(latest_node.uid);
5251 inode->i_gid = je16_to_cpu(latest_node.gid);
5252 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), 0, 0,
5253 + je16_to_cpu(latest_node.tag));
5254 inode->i_size = je32_to_cpu(latest_node.isize);
5255 inode->i_atime = ITIME(je32_to_cpu(latest_node.atime));
5256 inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
5257 @@ -285,6 +334,7 @@ void jffs2_read_inode (struct inode *ino
5259 inode->i_op = &jffs2_dir_inode_operations;
5260 inode->i_fop = &jffs2_dir_operations;
5261 + f->flags = je16_to_cpu(latest_node.flags);
5265 @@ -292,6 +342,7 @@ void jffs2_read_inode (struct inode *ino
5266 inode->i_fop = &jffs2_file_operations;
5267 inode->i_mapping->a_ops = &jffs2_file_address_operations;
5268 inode->i_mapping->nrpages = 0;
5269 + f->flags = je16_to_cpu(latest_node.flags);
5273 @@ -328,7 +379,7 @@ void jffs2_read_inode (struct inode *ino
5275 printk(KERN_WARNING "jffs2_read_inode(): Bogus imode %o for ino %lu\n", inode->i_mode, (unsigned long)inode->i_ino);
5278 + jffs2_set_inode_flags(inode);
5281 D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n"));
5282 @@ -345,10 +396,11 @@ void jffs2_dirty_inode(struct inode *ino
5284 D1(printk(KERN_DEBUG "jffs2_dirty_inode() calling setattr() for ino #%lu\n", inode->i_ino));
5286 - iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME;
5287 + iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME|ATTR_TAG;
5288 iattr.ia_mode = inode->i_mode;
5289 iattr.ia_uid = inode->i_uid;
5290 iattr.ia_gid = inode->i_gid;
5291 + iattr.ia_tag = inode->i_tag;
5292 iattr.ia_atime = inode->i_atime;
5293 iattr.ia_mtime = inode->i_mtime;
5294 iattr.ia_ctime = inode->i_ctime;
5295 @@ -422,6 +474,7 @@ struct inode *jffs2_new_inode (struct in
5297 memset(ri, 0, sizeof(*ri));
5298 /* Set OS-specific defaults for new inodes */
5299 + ri->tag = cpu_to_je16(dx_current_tag());
5300 ri->uid = cpu_to_je16(current->fsuid);
5302 if (dir_i->i_mode & S_ISGID) {
5303 @@ -443,14 +496,16 @@ struct inode *jffs2_new_inode (struct in
5304 inode->i_mode = jemode_to_cpu(ri->mode);
5305 inode->i_gid = je16_to_cpu(ri->gid);
5306 inode->i_uid = je16_to_cpu(ri->uid);
5307 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), 0, 0, je16_to_cpu(ri->tag));
5308 inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
5309 ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime));
5311 inode->i_blocks = 0;
5314 + f->flags = je16_to_cpu(ri->flags);
5315 + jffs2_set_inode_flags(inode);
5316 insert_inode_hash(inode);
5321 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/gc.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/gc.c
5322 --- linux-2.6.22.10/fs/jffs2/gc.c 2007-07-09 13:19:26 +0200
5323 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/gc.c 2007-08-05 20:53:12 +0200
5324 @@ -735,6 +735,7 @@ static int jffs2_garbage_collect_metadat
5325 ri.mode = cpu_to_jemode(JFFS2_F_I_MODE(f));
5326 ri.uid = cpu_to_je16(JFFS2_F_I_UID(f));
5327 ri.gid = cpu_to_je16(JFFS2_F_I_GID(f));
5328 + ri.tag = cpu_to_je16(JFFS2_F_I_TAG(f));
5329 ri.isize = cpu_to_je32(ilen);
5330 ri.atime = cpu_to_je32(JFFS2_F_I_ATIME(f));
5331 ri.ctime = cpu_to_je32(JFFS2_F_I_CTIME(f));
5332 @@ -998,6 +999,7 @@ static int jffs2_garbage_collect_hole(st
5333 ri.mode = cpu_to_jemode(JFFS2_F_I_MODE(f));
5334 ri.uid = cpu_to_je16(JFFS2_F_I_UID(f));
5335 ri.gid = cpu_to_je16(JFFS2_F_I_GID(f));
5336 + ri.tag = cpu_to_je16(JFFS2_F_I_TAG(f));
5337 ri.isize = cpu_to_je32(ilen);
5338 ri.atime = cpu_to_je32(JFFS2_F_I_ATIME(f));
5339 ri.ctime = cpu_to_je32(JFFS2_F_I_CTIME(f));
5340 @@ -1256,6 +1258,7 @@ static int jffs2_garbage_collect_dnode(s
5341 ri.mode = cpu_to_jemode(JFFS2_F_I_MODE(f));
5342 ri.uid = cpu_to_je16(JFFS2_F_I_UID(f));
5343 ri.gid = cpu_to_je16(JFFS2_F_I_GID(f));
5344 + ri.tag = cpu_to_je16(JFFS2_F_I_TAG(f));
5345 ri.isize = cpu_to_je32(JFFS2_F_I_SIZE(f));
5346 ri.atime = cpu_to_je32(JFFS2_F_I_ATIME(f));
5347 ri.ctime = cpu_to_je32(JFFS2_F_I_CTIME(f));
5348 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/ioctl.c
5349 --- linux-2.6.22.10/fs/jffs2/ioctl.c 2007-07-09 13:19:26 +0200
5350 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/ioctl.c 2007-08-05 20:53:12 +0200
5354 #include <linux/fs.h>
5355 +#include <linux/types.h>
5356 +#include <linux/mount.h>
5357 +#include <linux/jffs2.h>
5358 +#include <linux/uaccess.h>
5359 +#include <linux/vs_base.h>
5360 +#include "jffs2_fs_sb.h"
5361 +#include "jffs2_fs_i.h"
5363 +#include "os-linux.h"
5365 +extern void jffs2_set_inode_flags(struct inode *);
5367 int jffs2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
5370 - /* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which
5371 - will include compression support etc. */
5373 + struct jffs2_inode_info *j = JFFS2_INODE_INFO(inode);
5374 + unsigned int flags, oldflags, newflags;
5377 + case JFFS2_IOC_GETFLAGS:
5378 + flags = j->flags & JFFS2_USER_VISIBLE;
5379 + return put_user(flags, (int __user *) arg);
5381 + case JFFS2_IOC_SETFLAGS:
5382 + if (IS_RDONLY(inode) ||
5383 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
5386 + if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
5389 + if (get_user(flags, (int __user *) arg))
5392 + oldflags = j->flags;
5393 + newflags = flags & JFFS2_USER_MODIFIABLE;
5394 + newflags |= oldflags & ~JFFS2_USER_MODIFIABLE;
5397 + * The IMMUTABLE flags can only be changed by
5398 + * the relevant capability.
5400 + if (((oldflags ^ newflags) &
5401 + (JFFS2_INO_FLAG_IMMUTABLE | JFFS2_INO_FLAG_IUNLINK)) ||
5402 + (oldflags & JFFS2_INO_FLAG_IMMUTABLE)) {
5403 + if (!capable(CAP_LINUX_IMMUTABLE))
5407 + if (oldflags ^ newflags) {
5408 + j->flags = newflags;
5409 + inode->i_ctime = CURRENT_TIME;
5410 + /* strange requirement, see jffs2_dirty_inode() */
5411 + inode->i_state |= I_DIRTY_DATASYNC;
5412 + mark_inode_dirty(inode);
5413 + jffs2_set_inode_flags(inode);
5422 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/jffs2_fs_sb.h linux-2.6.22.10-vs2.3.0.29/fs/jffs2/jffs2_fs_sb.h
5423 --- linux-2.6.22.10/fs/jffs2/jffs2_fs_sb.h 2007-07-09 13:19:26 +0200
5424 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/jffs2_fs_sb.h 2007-08-05 20:53:12 +0200
5425 @@ -39,6 +39,7 @@ struct jffs2_sb_info {
5426 uint32_t checked_ino;
5429 + unsigned int s_mount_opt;
5431 struct task_struct *gc_task; /* GC task struct */
5432 struct completion gc_thread_start; /* GC thread start completion */
5433 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/nodelist.h linux-2.6.22.10-vs2.3.0.29/fs/jffs2/nodelist.h
5434 --- linux-2.6.22.10/fs/jffs2/nodelist.h 2007-07-09 13:19:26 +0200
5435 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/nodelist.h 2007-08-05 20:53:12 +0200
5437 #elif defined(JFFS2_BIG_ENDIAN)
5438 #define cpu_to_je16(x) ((jint16_t){cpu_to_be16(x)})
5439 #define cpu_to_je32(x) ((jint32_t){cpu_to_be32(x)})
5440 -#define cpu_to_jemode(x) ((jmode_t){cpu_to_be32(os_to_jffs2_mode(x))})
5441 +#define cpu_to_jemode(x) ((jmode_t){cpu_to_be16(os_to_jffs2_mode(x))})
5443 #define constant_cpu_to_je16(x) ((jint16_t){__constant_cpu_to_be16(x)})
5444 #define constant_cpu_to_je32(x) ((jint32_t){__constant_cpu_to_be32(x)})
5446 #define je16_to_cpu(x) (be16_to_cpu(x.v16))
5447 #define je32_to_cpu(x) (be32_to_cpu(x.v32))
5448 -#define jemode_to_cpu(x) (be32_to_cpu(jffs2_to_os_mode((x).m)))
5449 +#define jemode_to_cpu(x) (be16_to_cpu(jffs2_to_os_mode((x).m)))
5450 #elif defined(JFFS2_LITTLE_ENDIAN)
5451 #define cpu_to_je16(x) ((jint16_t){cpu_to_le16(x)})
5452 #define cpu_to_je32(x) ((jint32_t){cpu_to_le32(x)})
5453 -#define cpu_to_jemode(x) ((jmode_t){cpu_to_le32(os_to_jffs2_mode(x))})
5454 +#define cpu_to_jemode(x) ((jmode_t){cpu_to_le16(os_to_jffs2_mode(x))})
5456 #define constant_cpu_to_je16(x) ((jint16_t){__constant_cpu_to_le16(x)})
5457 #define constant_cpu_to_je32(x) ((jint32_t){__constant_cpu_to_le32(x)})
5459 #define je16_to_cpu(x) (le16_to_cpu(x.v16))
5460 #define je32_to_cpu(x) (le32_to_cpu(x.v32))
5461 -#define jemode_to_cpu(x) (le32_to_cpu(jffs2_to_os_mode((x).m)))
5462 +#define jemode_to_cpu(x) (le16_to_cpu(jffs2_to_os_mode((x).m)))
5466 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/os-linux.h linux-2.6.22.10-vs2.3.0.29/fs/jffs2/os-linux.h
5467 --- linux-2.6.22.10/fs/jffs2/os-linux.h 2007-07-09 13:19:26 +0200
5468 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/os-linux.h 2007-08-05 20:53:12 +0200
5469 @@ -29,6 +29,7 @@ struct kvec;
5470 #define JFFS2_F_I_MODE(f) (OFNI_EDONI_2SFFJ(f)->i_mode)
5471 #define JFFS2_F_I_UID(f) (OFNI_EDONI_2SFFJ(f)->i_uid)
5472 #define JFFS2_F_I_GID(f) (OFNI_EDONI_2SFFJ(f)->i_gid)
5473 +#define JFFS2_F_I_TAG(f) (OFNI_EDONI_2SFFJ(f)->i_tag)
5474 #define JFFS2_F_I_RDEV(f) (OFNI_EDONI_2SFFJ(f)->i_rdev)
5476 #define ITIME(sec) ((struct timespec){sec, 0})
5477 @@ -204,6 +205,9 @@ int jffs2_flash_direct_writev(struct jff
5478 int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len,
5479 size_t *retlen, const u_char *buf);
5481 +#define JFFS2_IOC_GETFLAGS FS_IOC_GETFLAGS
5482 +#define JFFS2_IOC_SETFLAGS FS_IOC_SETFLAGS
5484 #endif /* __JFFS2_OS_LINUX_H__ */
5487 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/readinode.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/readinode.c
5488 --- linux-2.6.22.10/fs/jffs2/readinode.c 2007-07-09 13:19:26 +0200
5489 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/readinode.c 2007-08-05 20:53:12 +0200
5490 @@ -1182,6 +1182,8 @@ static int jffs2_do_read_inode_internal(
5491 latest_node->isize = cpu_to_je32(0);
5492 latest_node->gid = cpu_to_je16(0);
5493 latest_node->uid = cpu_to_je16(0);
5494 + latest_node->tag = cpu_to_je16(0);
5495 + latest_node->flags = cpu_to_je16(0);
5496 if (f->inocache->state == INO_STATE_READING)
5497 jffs2_set_inocache_state(c, f->inocache, INO_STATE_PRESENT);
5499 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/super.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/super.c
5500 --- linux-2.6.22.10/fs/jffs2/super.c 2007-07-09 13:19:26 +0200
5501 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/super.c 2007-08-05 20:53:12 +0200
5503 #include <linux/mtd/super.h>
5504 #include <linux/ctype.h>
5505 #include <linux/namei.h>
5506 +#include <linux/parser.h>
5508 #include "nodelist.h"
5510 @@ -75,6 +76,49 @@ static const struct super_operations jff
5511 .sync_fs = jffs2_sync_fs,
5515 + Opt_tag, Opt_notag, Opt_ignore, Opt_err
5518 +static match_table_t tokens = {
5520 + {Opt_notag, "notag"},
5524 +static int parse_options (char * options,
5525 + struct jffs2_sb_info *sbi)
5528 + substring_t args[MAX_OPT_ARGS];
5533 + while ((p = strsep (&options, ",")) != NULL) {
5538 + token = match_token(p, tokens, args);
5540 +#ifndef CONFIG_TAGGING_NONE
5542 + set_opt (sbi->s_mount_opt, TAGGED);
5545 + clear_opt (sbi->s_mount_opt, TAGGED);
5558 * fill in the superblock
5560 @@ -109,6 +153,12 @@ static int jffs2_fill_super(struct super
5561 #ifdef CONFIG_JFFS2_FS_POSIX_ACL
5562 sb->s_flags |= MS_POSIXACL;
5564 + if (!parse_options ((char *) data, c))
5567 + if (c->s_mount_opt & JFFS2_MOUNT_TAGGED)
5568 + sb->s_flags |= MS_TAGGED;
5570 return jffs2_do_fill_super(sb, data, silent);
5573 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/write.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/write.c
5574 --- linux-2.6.22.10/fs/jffs2/write.c 2007-10-30 01:57:14 +0100
5575 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/write.c 2007-09-05 03:06:11 +0200
5576 @@ -44,6 +44,7 @@ int jffs2_do_new_inode(struct jffs2_sb_i
5577 ri->totlen = cpu_to_je32(PAD(sizeof(*ri)));
5578 ri->hdr_crc = cpu_to_je32(crc32(0, ri, sizeof(struct jffs2_unknown_node)-4));
5579 ri->mode = cpu_to_jemode(mode);
5580 + ri->flags = cpu_to_je16(0);
5582 f->highest_version = 1;
5583 ri->version = cpu_to_je32(f->highest_version);
5584 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/acl.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/acl.c
5585 --- linux-2.6.22.10/fs/jfs/acl.c 2006-11-30 21:19:25 +0100
5586 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/acl.c 2007-08-05 20:53:12 +0200
5587 @@ -232,7 +232,8 @@ int jfs_setattr(struct dentry *dentry, s
5590 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
5591 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
5592 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
5593 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
5594 if (DQUOT_TRANSFER(inode, iattr))
5597 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/file.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/file.c
5598 --- linux-2.6.22.10/fs/jfs/file.c 2007-05-02 19:25:18 +0200
5599 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/file.c 2007-09-12 20:04:16 +0200
5600 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
5601 .setattr = jfs_setattr,
5602 .permission = jfs_permission,
5604 + .sync_flags = jfs_sync_flags,
5607 const struct file_operations jfs_file_operations = {
5608 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/inode.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/inode.c
5609 --- linux-2.6.22.10/fs/jfs/inode.c 2007-07-09 13:19:26 +0200
5610 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/inode.c 2007-08-05 20:53:12 +0200
5612 #include <linux/buffer_head.h>
5613 #include <linux/pagemap.h>
5614 #include <linux/quotaops.h>
5615 +#include <linux/vs_dlimit.h>
5616 #include "jfs_incore.h"
5617 #include "jfs_inode.h"
5618 #include "jfs_filsys.h"
5619 @@ -143,6 +144,7 @@ void jfs_delete_inode(struct inode *inod
5621 DQUOT_FREE_INODE(inode);
5623 + DLIMIT_FREE_INODE(inode);
5627 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/ioctl.c
5628 --- linux-2.6.22.10/fs/jfs/ioctl.c 2007-07-09 13:19:27 +0200
5629 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/ioctl.c 2007-08-05 20:53:12 +0200
5631 #include <linux/capability.h>
5632 #include <linux/time.h>
5633 #include <linux/sched.h>
5634 +#include <linux/mount.h>
5635 #include <asm/current.h>
5636 #include <asm/uaccess.h>
5638 @@ -66,7 +67,8 @@ int jfs_ioctl(struct inode * inode, stru
5639 case JFS_IOC_SETFLAGS: {
5640 unsigned int oldflags;
5642 - if (IS_RDONLY(inode))
5643 + if (IS_RDONLY(inode) ||
5644 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
5647 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
5648 @@ -87,8 +89,8 @@ int jfs_ioctl(struct inode * inode, stru
5649 * the relevant capability.
5651 if ((oldflags & JFS_IMMUTABLE_FL) ||
5652 - ((flags ^ oldflags) &
5653 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
5654 + ((flags ^ oldflags) & (JFS_APPEND_FL |
5655 + JFS_IMMUTABLE_FL | JFS_IUNLINK_FL))) {
5656 if (!capable(CAP_LINUX_IMMUTABLE))
5659 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_dinode.h linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_dinode.h
5660 --- linux-2.6.22.10/fs/jfs/jfs_dinode.h 2006-11-30 21:19:25 +0100
5661 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_dinode.h 2007-08-05 20:53:12 +0200
5662 @@ -162,9 +162,12 @@ struct dinode {
5663 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
5664 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
5666 -#define JFS_FL_USER_VISIBLE 0x03F80000
5667 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
5668 +#define JFS_IUNLINK_FL 0x08000000 /* Immutable unlink */
5670 +#define JFS_FL_USER_VISIBLE 0x0FF80000
5671 #define JFS_FL_USER_MODIFIABLE 0x03F80000
5672 -#define JFS_FL_INHERIT 0x03C80000
5673 +#define JFS_FL_INHERIT 0x0BC80000
5675 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
5676 #define JFS_IOC_GETFLAGS _IOR('f', 1, long)
5677 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_dtree.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_dtree.c
5678 --- linux-2.6.22.10/fs/jfs/jfs_dtree.c 2007-02-06 03:01:24 +0100
5679 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_dtree.c 2007-08-05 20:53:12 +0200
5682 #include <linux/fs.h>
5683 #include <linux/quotaops.h>
5684 +#include <linux/vs_dlimit.h>
5685 #include "jfs_incore.h"
5686 #include "jfs_superblock.h"
5687 #include "jfs_filsys.h"
5688 @@ -383,10 +384,10 @@ static u32 add_index(tid_t tid, struct i
5690 if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage))
5692 - if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
5693 - DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
5696 + if (DLIMIT_ALLOC_BLOCK(ip, sbi->nbperpage))
5697 + goto clean_up_dquot;
5698 + if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr))
5699 + goto clean_up_dlimit;
5702 * Save the table, we're going to overwrite it with the
5703 @@ -479,6 +480,12 @@ static u32 add_index(tid_t tid, struct i
5708 + DLIMIT_FREE_BLOCK(ip, sbi->nbperpage);
5711 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
5715 jfs_ip->next_index--;
5716 @@ -952,6 +959,7 @@ static int dtSplitUp(tid_t tid,
5719 int quota_allocation = 0;
5720 + int dlimit_allocation = 0;
5722 /* get split page */
5724 @@ -1036,6 +1044,12 @@ static int dtSplitUp(tid_t tid,
5726 quota_allocation += n;
5728 + if (DLIMIT_ALLOC_BLOCK(ip, n)) {
5732 + dlimit_allocation += n;
5734 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
5737 @@ -1309,6 +1323,9 @@ static int dtSplitUp(tid_t tid,
5741 + /* Rollback dlimit allocation */
5742 + if (rc && dlimit_allocation)
5743 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
5744 /* Rollback quota allocation */
5745 if (rc && quota_allocation)
5746 DQUOT_FREE_BLOCK(ip, quota_allocation);
5747 @@ -1376,6 +1393,12 @@ static int dtSplitPage(tid_t tid, struct
5748 release_metapage(rmp);
5751 + /* Allocate blocks to dlimit. */
5752 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5753 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
5754 + release_metapage(rmp);
5758 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
5760 @@ -1926,6 +1949,12 @@ static int dtSplitRoot(tid_t tid,
5761 release_metapage(rmp);
5764 + /* Allocate blocks to dlimit. */
5765 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5766 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
5767 + release_metapage(rmp);
5771 BT_MARK_DIRTY(rmp, ip);
5773 @@ -2292,6 +2321,8 @@ static int dtDeleteUp(tid_t tid, struct
5775 xlen = lengthPXD(&fp->header.self);
5777 + /* Free dlimit allocation. */
5778 + DLIMIT_FREE_BLOCK(ip, xlen);
5779 /* Free quota allocation. */
5780 DQUOT_FREE_BLOCK(ip, xlen);
5782 @@ -2368,6 +2399,8 @@ static int dtDeleteUp(tid_t tid, struct
5784 xlen = lengthPXD(&p->header.self);
5786 + /* Free dlimit allocation */
5787 + DLIMIT_FREE_BLOCK(ip, xlen);
5788 /* Free quota allocation */
5789 DQUOT_FREE_BLOCK(ip, xlen);
5791 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_extent.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_extent.c
5792 --- linux-2.6.22.10/fs/jfs/jfs_extent.c 2006-11-30 21:19:25 +0100
5793 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_extent.c 2007-08-05 20:53:12 +0200
5796 #include <linux/fs.h>
5797 #include <linux/quotaops.h>
5798 +#include <linux/vs_dlimit.h>
5799 #include "jfs_incore.h"
5800 #include "jfs_inode.h"
5801 #include "jfs_superblock.h"
5802 @@ -147,6 +148,14 @@ extAlloc(struct inode *ip, s64 xlen, s64
5806 + /* Allocate blocks to dlimit. */
5807 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
5808 + DQUOT_FREE_BLOCK(ip, nxlen);
5809 + dbFree(ip, nxaddr, (s64) nxlen);
5810 + mutex_unlock(&JFS_IP(ip)->commit_mutex);
5814 /* determine the value of the extent flag */
5815 xflag = abnr ? XAD_NOTRECORDED : 0;
5817 @@ -164,6 +173,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
5820 dbFree(ip, nxaddr, nxlen);
5821 + DLIMIT_FREE_BLOCK(ip, nxlen);
5822 DQUOT_FREE_BLOCK(ip, nxlen);
5823 mutex_unlock(&JFS_IP(ip)->commit_mutex);
5825 @@ -261,6 +271,13 @@ int extRealloc(struct inode *ip, s64 nxl
5826 mutex_unlock(&JFS_IP(ip)->commit_mutex);
5829 + /* Allocate blocks to dlimit. */
5830 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
5831 + DQUOT_FREE_BLOCK(ip, nxlen);
5832 + dbFree(ip, nxaddr, (s64) nxlen);
5833 + up(&JFS_IP(ip)->commit_sem);
5837 delta = nxlen - xlen;
5839 @@ -297,6 +314,7 @@ int extRealloc(struct inode *ip, s64 nxl
5840 /* extend the extent */
5841 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
5842 dbFree(ip, xaddr + xlen, delta);
5843 + DLIMIT_FREE_BLOCK(ip, nxlen);
5844 DQUOT_FREE_BLOCK(ip, nxlen);
5847 @@ -308,6 +326,7 @@ int extRealloc(struct inode *ip, s64 nxl
5849 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
5850 dbFree(ip, nxaddr, nxlen);
5851 + DLIMIT_FREE_BLOCK(ip, nxlen);
5852 DQUOT_FREE_BLOCK(ip, nxlen);
5855 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_filsys.h linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_filsys.h
5856 --- linux-2.6.22.10/fs/jfs/jfs_filsys.h 2007-02-06 03:01:24 +0100
5857 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_filsys.h 2007-08-05 20:53:12 +0200
5859 #define JFS_NAME_MAX 255
5860 #define JFS_PATH_MAX BPSIZE
5862 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
5865 * file system state (superblock state)
5866 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_imap.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_imap.c
5867 --- linux-2.6.22.10/fs/jfs/jfs_imap.c 2007-07-09 13:19:27 +0200
5868 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_imap.c 2007-08-05 20:53:12 +0200
5870 #include <linux/buffer_head.h>
5871 #include <linux/pagemap.h>
5872 #include <linux/quotaops.h>
5873 +#include <linux/vs_tag.h>
5875 #include "jfs_incore.h"
5876 #include "jfs_inode.h"
5877 @@ -3075,6 +3076,8 @@ static int copy_from_dinode(struct dinod
5879 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
5880 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
5884 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
5885 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
5886 @@ -3095,14 +3098,18 @@ static int copy_from_dinode(struct dinod
5888 ip->i_nlink = le32_to_cpu(dip->di_nlink);
5890 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
5891 + uid = le32_to_cpu(dip->di_uid);
5892 + gid = le32_to_cpu(dip->di_gid);
5893 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
5895 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
5897 ip->i_uid = jfs_ip->saved_uid;
5899 ip->i_uid = sbi->uid;
5902 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
5903 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
5905 ip->i_gid = jfs_ip->saved_gid;
5907 @@ -3167,14 +3174,12 @@ static void copy_to_dinode(struct dinode
5908 dip->di_size = cpu_to_le64(ip->i_size);
5909 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
5910 dip->di_nlink = cpu_to_le32(ip->i_nlink);
5911 - if (sbi->uid == -1)
5912 - dip->di_uid = cpu_to_le32(ip->i_uid);
5914 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
5915 - if (sbi->gid == -1)
5916 - dip->di_gid = cpu_to_le32(ip->i_gid);
5918 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
5920 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
5921 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
5922 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
5923 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
5925 jfs_get_inode_flags(jfs_ip);
5927 * mode2 is only needed for storing the higher order bits.
5928 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_inode.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_inode.c
5929 --- linux-2.6.22.10/fs/jfs/jfs_inode.c 2007-07-09 13:19:27 +0200
5930 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_inode.c 2007-08-05 20:53:12 +0200
5933 #include <linux/fs.h>
5934 #include <linux/quotaops.h>
5935 +#include <linux/vs_dlimit.h>
5936 +#include <linux/vs_tag.h>
5937 #include "jfs_incore.h"
5938 #include "jfs_inode.h"
5939 #include "jfs_filsys.h"
5940 @@ -30,19 +32,47 @@ void jfs_set_inode_flags(struct inode *i
5942 unsigned int flags = JFS_IP(inode)->mode2;
5944 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
5945 - S_NOATIME | S_DIRSYNC | S_SYNC);
5946 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
5947 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5949 if (flags & JFS_IMMUTABLE_FL)
5950 inode->i_flags |= S_IMMUTABLE;
5951 + if (flags & JFS_IUNLINK_FL)
5952 + inode->i_flags |= S_IUNLINK;
5953 + if (flags & JFS_BARRIER_FL)
5954 + inode->i_flags |= S_BARRIER;
5956 + if (flags & JFS_SYNC_FL)
5957 + inode->i_flags |= S_SYNC;
5958 if (flags & JFS_APPEND_FL)
5959 inode->i_flags |= S_APPEND;
5960 if (flags & JFS_NOATIME_FL)
5961 inode->i_flags |= S_NOATIME;
5962 if (flags & JFS_DIRSYNC_FL)
5963 inode->i_flags |= S_DIRSYNC;
5964 - if (flags & JFS_SYNC_FL)
5965 - inode->i_flags |= S_SYNC;
5968 +int jfs_sync_flags(struct inode *inode)
5970 + unsigned int oldflags, newflags;
5972 + oldflags = JFS_IP(inode)->mode2;
5973 + newflags = oldflags & ~(JFS_IMMUTABLE_FL |
5974 + JFS_IUNLINK_FL | JFS_BARRIER_FL);
5976 + if (IS_IMMUTABLE(inode))
5977 + newflags |= JFS_IMMUTABLE_FL;
5978 + if (IS_IUNLINK(inode))
5979 + newflags |= JFS_IUNLINK_FL;
5980 + if (IS_BARRIER(inode))
5981 + newflags |= JFS_BARRIER_FL;
5983 + if (oldflags ^ newflags) {
5984 + JFS_IP(inode)->mode2 = newflags;
5985 + inode->i_ctime = CURRENT_TIME;
5986 + mark_inode_dirty(inode);
5991 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
5992 @@ -108,10 +138,17 @@ struct inode *ialloc(struct inode *paren
5993 jfs_inode->saved_uid = inode->i_uid;
5994 jfs_inode->saved_gid = inode->i_gid;
5996 + inode->i_tag = dx_current_fstag(sb);
5997 + if (DLIMIT_ALLOC_INODE(inode)) {
5999 + return ERR_PTR(-ENOSPC);
6003 * Allocate inode to quota.
6005 if (DQUOT_ALLOC_INODE(inode)) {
6006 + DLIMIT_FREE_INODE(inode);
6008 inode->i_flags |= S_NOQUOTA;
6010 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_inode.h linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_inode.h
6011 --- linux-2.6.22.10/fs/jfs/jfs_inode.h 2007-07-09 13:19:27 +0200
6012 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_inode.h 2007-08-05 20:53:12 +0200
6013 @@ -33,6 +33,7 @@ extern void jfs_free_zero_link(struct in
6014 extern struct dentry *jfs_get_parent(struct dentry *dentry);
6015 extern void jfs_get_inode_flags(struct jfs_inode_info *);
6016 extern void jfs_set_inode_flags(struct inode *);
6017 +extern int jfs_sync_flags(struct inode *);
6018 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
6020 extern const struct address_space_operations jfs_aops;
6021 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_xtree.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_xtree.c
6022 --- linux-2.6.22.10/fs/jfs/jfs_xtree.c 2007-05-02 19:25:18 +0200
6023 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_xtree.c 2007-08-05 20:53:12 +0200
6026 #include <linux/fs.h>
6027 #include <linux/quotaops.h>
6028 +#include <linux/vs_dlimit.h>
6029 #include "jfs_incore.h"
6030 #include "jfs_filsys.h"
6031 #include "jfs_metapage.h"
6032 @@ -846,7 +847,12 @@ int xtInsert(tid_t tid, /* transaction
6034 if ((rc = DQUOT_ALLOC_BLOCK(ip, xlen)))
6036 + if ((rc = DLIMIT_ALLOC_BLOCK(ip, xlen))) {
6037 + DQUOT_FREE_BLOCK(ip, xlen);
6040 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
6041 + DLIMIT_FREE_BLOCK(ip, xlen);
6042 DQUOT_FREE_BLOCK(ip, xlen);
6045 @@ -876,6 +882,7 @@ int xtInsert(tid_t tid, /* transaction
6046 /* undo data extent allocation */
6048 dbFree(ip, xaddr, (s64) xlen);
6049 + DLIMIT_FREE_BLOCK(ip, xlen);
6050 DQUOT_FREE_BLOCK(ip, xlen);
6053 @@ -1236,6 +1243,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
6055 struct xtlock *sxtlck = NULL, *rxtlck = NULL;
6056 int quota_allocation = 0;
6057 + int dlimit_allocation = 0;
6060 sp = XT_PAGE(ip, smp);
6061 @@ -1255,6 +1263,13 @@ xtSplitPage(tid_t tid, struct inode *ip,
6063 quota_allocation += lengthPXD(pxd);
6065 + /* Allocate blocks to dlimit. */
6066 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
6070 + dlimit_allocation += lengthPXD(pxd);
6073 * allocate the new right page for the split
6075 @@ -1456,6 +1471,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
6079 + /* Rollback dlimit allocation. */
6080 + if (dlimit_allocation)
6081 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
6082 /* Rollback quota allocation. */
6083 if (quota_allocation)
6084 DQUOT_FREE_BLOCK(ip, quota_allocation);
6085 @@ -1520,6 +1538,12 @@ xtSplitRoot(tid_t tid,
6086 release_metapage(rmp);
6089 + /* Allocate blocks to dlimit. */
6090 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
6091 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
6092 + release_metapage(rmp);
6096 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
6098 @@ -3951,6 +3975,8 @@ s64 xtTruncate(tid_t tid, struct inode *
6100 ip->i_size = newsize;
6102 + /* update dlimit allocation to reflect freed blocks */
6103 + DLIMIT_FREE_BLOCK(ip, nfreed);
6104 /* update quota allocation to reflect freed blocks */
6105 DQUOT_FREE_BLOCK(ip, nfreed);
6107 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/namei.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/namei.c
6108 --- linux-2.6.22.10/fs/jfs/namei.c 2007-05-02 19:25:18 +0200
6109 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/namei.c 2007-08-05 20:53:12 +0200
6111 #include <linux/fs.h>
6112 #include <linux/ctype.h>
6113 #include <linux/quotaops.h>
6114 +#include <linux/vs_tag.h>
6115 #include "jfs_incore.h"
6116 #include "jfs_superblock.h"
6117 #include "jfs_inode.h"
6118 @@ -1469,6 +1470,7 @@ static struct dentry *jfs_lookup(struct
6119 return ERR_PTR(-EACCES);
6122 + dx_propagate_tag(nd, ip);
6123 dentry = d_splice_alias(ip, dentry);
6125 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
6126 @@ -1521,6 +1523,7 @@ const struct inode_operations jfs_dir_in
6127 .setattr = jfs_setattr,
6128 .permission = jfs_permission,
6130 + .sync_flags = jfs_sync_flags,
6133 const struct file_operations jfs_dir_operations = {
6134 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/super.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/super.c
6135 --- linux-2.6.22.10/fs/jfs/super.c 2007-07-09 13:19:27 +0200
6136 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/super.c 2007-08-05 20:53:12 +0200
6137 @@ -194,7 +194,8 @@ static void jfs_put_super(struct super_b
6139 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
6140 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
6141 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
6142 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
6143 + Opt_tag, Opt_notag, Opt_tagid
6146 static match_table_t tokens = {
6147 @@ -204,6 +205,10 @@ static match_table_t tokens = {
6148 {Opt_resize, "resize=%u"},
6149 {Opt_resize_nosize, "resize"},
6150 {Opt_errors, "errors=%s"},
6152 + {Opt_notag, "notag"},
6153 + {Opt_tagid, "tagid=%u"},
6154 + {Opt_tag, "tagxid"},
6155 {Opt_ignore, "noquota"},
6156 {Opt_ignore, "quota"},
6157 {Opt_usrquota, "usrquota"},
6158 @@ -338,6 +343,20 @@ static int parse_options(char *options,
6162 +#ifndef CONFIG_TAGGING_NONE
6164 + *flag |= JFS_TAGGED;
6167 + *flag &= JFS_TAGGED;
6170 +#ifdef CONFIG_PROPAGATE
6173 + *flag |= JFS_TAGGED;
6177 printk("jfs: Unrecognized mount option \"%s\" "
6178 " or missing value\n", p);
6179 @@ -368,6 +387,13 @@ static int jfs_remount(struct super_bloc
6180 if (!parse_options(data, sb, &newLVSize, &flag)) {
6184 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
6185 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
6191 if (sb->s_flags & MS_RDONLY) {
6193 @@ -439,6 +465,9 @@ static int jfs_fill_super(struct super_b
6194 #ifdef CONFIG_JFS_POSIX_ACL
6195 sb->s_flags |= MS_POSIXACL;
6197 + /* map mount option tagxid */
6198 + if (sbi->flag & JFS_TAGGED)
6199 + sb->s_flags |= MS_TAGGED;
6202 printk(KERN_ERR "resize option for remount only\n");
6203 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/xattr.c
6204 --- linux-2.6.22.10/fs/jfs/xattr.c 2006-11-30 21:19:26 +0100
6205 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/xattr.c 2007-08-05 20:53:12 +0200
6207 #include <linux/posix_acl_xattr.h>
6208 #include <linux/quotaops.h>
6209 #include <linux/security.h>
6210 +#include <linux/vs_dlimit.h>
6211 #include "jfs_incore.h"
6212 #include "jfs_superblock.h"
6213 #include "jfs_dmap.h"
6214 @@ -263,9 +264,16 @@ static int ea_write(struct inode *ip, st
6215 if (DQUOT_ALLOC_BLOCK(ip, nblocks)) {
6218 + /* Allocate new blocks to dlimit. */
6219 + if (DLIMIT_ALLOC_BLOCK(ip, nblocks)) {
6220 + DQUOT_FREE_BLOCK(ip, nblocks);
6224 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
6226 + /*Rollback dlimit allocation. */
6227 + DLIMIT_FREE_BLOCK(ip, nblocks);
6228 /*Rollback quota allocation. */
6229 DQUOT_FREE_BLOCK(ip, nblocks);
6231 @@ -332,6 +340,8 @@ static int ea_write(struct inode *ip, st
6234 /* Rollback quota allocation. */
6235 + DLIMIT_FREE_BLOCK(ip, nblocks);
6236 + /* Rollback quota allocation. */
6237 DQUOT_FREE_BLOCK(ip, nblocks);
6239 dbFree(ip, blkno, nblocks);
6240 @@ -468,6 +478,7 @@ static int ea_get(struct inode *inode, s
6243 int quota_allocation = 0;
6244 + int dlimit_allocation = 0;
6246 /* When fsck.jfs clears a bad ea, it doesn't clear the size */
6247 if (ji->ea.flag == 0)
6248 @@ -543,6 +554,12 @@ static int ea_get(struct inode *inode, s
6250 quota_allocation = blocks_needed;
6252 + /* Allocate new blocks to dlimit. */
6254 + if (DLIMIT_ALLOC_BLOCK(inode, blocks_needed))
6256 + dlimit_allocation = blocks_needed;
6258 rc = dbAlloc(inode, INOHINT(inode), (s64) blocks_needed,
6261 @@ -599,6 +616,9 @@ static int ea_get(struct inode *inode, s
6265 + /* Rollback dlimit allocation */
6266 + if (dlimit_allocation)
6267 + DLIMIT_FREE_BLOCK(inode, dlimit_allocation);
6268 /* Rollback quota allocation */
6269 if (quota_allocation)
6270 DQUOT_FREE_BLOCK(inode, quota_allocation);
6271 @@ -675,8 +695,10 @@ static int ea_put(tid_t tid, struct inod
6274 /* If old blocks exist, they must be removed from quota allocation. */
6277 + DLIMIT_FREE_BLOCK(inode, old_blocks);
6278 DQUOT_FREE_BLOCK(inode, old_blocks);
6281 inode->i_ctime = CURRENT_TIME;
6283 diff -NurpP --minimal linux-2.6.22.10/fs/libfs.c linux-2.6.22.10-vs2.3.0.29/fs/libfs.c
6284 --- linux-2.6.22.10/fs/libfs.c 2007-07-09 13:19:27 +0200
6285 +++ linux-2.6.22.10-vs2.3.0.29/fs/libfs.c 2007-08-05 20:53:12 +0200
6286 @@ -124,7 +124,8 @@ static inline unsigned char dt_type(stru
6287 * both impossible due to the lock on directory.
6290 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
6291 +static inline int do_dcache_readdir_filter(struct file *filp,
6292 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
6294 struct dentry *dentry = filp->f_path.dentry;
6295 struct dentry *cursor = filp->private_data;
6296 @@ -157,6 +158,8 @@ int dcache_readdir(struct file * filp, v
6297 next = list_entry(p, struct dentry, d_u.d_child);
6298 if (d_unhashed(next) || !next->d_inode)
6300 + if (filter && !filter(next))
6303 spin_unlock(&dcache_lock);
6304 if (filldir(dirent, next->d_name.name,
6305 @@ -175,6 +178,18 @@ int dcache_readdir(struct file * filp, v
6309 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
6311 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
6314 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
6315 + int (*filter)(struct dentry *))
6317 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
6321 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
6324 @@ -640,6 +655,7 @@ EXPORT_SYMBOL(dcache_dir_close);
6325 EXPORT_SYMBOL(dcache_dir_lseek);
6326 EXPORT_SYMBOL(dcache_dir_open);
6327 EXPORT_SYMBOL(dcache_readdir);
6328 +EXPORT_SYMBOL(dcache_readdir_filter);
6329 EXPORT_SYMBOL(generic_read_dir);
6330 EXPORT_SYMBOL(get_sb_pseudo);
6331 EXPORT_SYMBOL(simple_commit_write);
6332 diff -NurpP --minimal linux-2.6.22.10/fs/locks.c linux-2.6.22.10-vs2.3.0.29/fs/locks.c
6333 --- linux-2.6.22.10/fs/locks.c 2007-10-30 01:57:14 +0100
6334 +++ linux-2.6.22.10-vs2.3.0.29/fs/locks.c 2007-10-05 15:07:22 +0200
6336 #include <linux/syscalls.h>
6337 #include <linux/time.h>
6338 #include <linux/rcupdate.h>
6339 +#include <linux/vs_base.h>
6340 +#include <linux/vs_limit.h>
6342 #include <asm/semaphore.h>
6343 #include <asm/uaccess.h>
6344 @@ -147,6 +149,8 @@ static struct kmem_cache *filelock_cache
6345 /* Allocate an empty lock structure. */
6346 static struct file_lock *locks_alloc_lock(void)
6348 + if (!vx_locks_avail(1))
6350 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6353 @@ -172,6 +176,7 @@ static void locks_free_lock(struct file_
6354 BUG_ON(!list_empty(&fl->fl_block));
6355 BUG_ON(!list_empty(&fl->fl_link));
6358 locks_release_private(fl);
6359 kmem_cache_free(filelock_cache, fl);
6361 @@ -191,6 +196,7 @@ void locks_init_lock(struct file_lock *f
6362 fl->fl_start = fl->fl_end = 0;
6364 fl->fl_lmops = NULL;
6368 EXPORT_SYMBOL(locks_init_lock);
6369 @@ -244,6 +250,7 @@ void locks_copy_lock(struct file_lock *n
6370 new->fl_file = fl->fl_file;
6371 new->fl_ops = fl->fl_ops;
6372 new->fl_lmops = fl->fl_lmops;
6373 + new->fl_xid = fl->fl_xid;
6375 locks_copy_private(new, fl);
6377 @@ -282,6 +289,11 @@ static int flock_make_lock(struct file *
6378 fl->fl_flags = FL_FLOCK;
6380 fl->fl_end = OFFSET_MAX;
6382 + vxd_assert(filp->f_xid == vx_current_xid(),
6383 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6384 + fl->fl_xid = filp->f_xid;
6389 @@ -447,6 +459,7 @@ static int lease_init(struct file *filp,
6391 fl->fl_owner = current->files;
6392 fl->fl_pid = current->tgid;
6393 + fl->fl_xid = vx_current_xid();
6396 fl->fl_flags = FL_LEASE;
6397 @@ -466,6 +479,11 @@ static int lease_alloc(struct file *filp
6401 + fl->fl_xid = vx_current_xid();
6403 + vxd_assert(filp->f_xid == fl->fl_xid,
6404 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
6406 error = lease_init(filp, type, fl);
6408 locks_free_lock(fl);
6409 @@ -769,6 +787,7 @@ static int flock_lock_file(struct file *
6413 + new_fl->fl_xid = -1;
6415 for_each_lock(inode, before) {
6416 struct file_lock *fl = *before;
6417 @@ -787,6 +806,7 @@ find_conflict:
6419 locks_copy_lock(new_fl, request);
6420 locks_insert_lock(before, new_fl);
6421 + vx_locks_inc(new_fl);
6425 @@ -797,7 +817,8 @@ out:
6429 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
6430 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
6431 + struct file_lock *conflock, xid_t xid)
6433 struct file_lock *fl;
6434 struct file_lock *new_fl = NULL;
6435 @@ -807,6 +828,8 @@ static int __posix_lock_file(struct inod
6436 struct file_lock **before;
6437 int error, added = 0;
6439 + vxd_assert(xid == vx_current_xid(),
6440 + "xid(%d) == current(%d)", xid, vx_current_xid());
6442 * We may need two file_lock structures for this operation,
6443 * so we get them in advance to avoid races.
6444 @@ -817,7 +840,11 @@ static int __posix_lock_file(struct inod
6445 (request->fl_type != F_UNLCK ||
6446 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
6447 new_fl = locks_alloc_lock();
6448 + new_fl->fl_xid = xid;
6449 + vx_locks_inc(new_fl);
6450 new_fl2 = locks_alloc_lock();
6451 + new_fl2->fl_xid = xid;
6452 + vx_locks_inc(new_fl2);
6456 @@ -1016,7 +1043,8 @@ static int __posix_lock_file(struct inod
6457 int posix_lock_file(struct file *filp, struct file_lock *fl,
6458 struct file_lock *conflock)
6460 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
6461 + return __posix_lock_file(filp->f_path.dentry->d_inode,
6462 + fl, conflock, filp->f_xid);
6464 EXPORT_SYMBOL(posix_lock_file);
6466 @@ -1106,7 +1134,7 @@ int locks_mandatory_area(int read_write,
6467 fl.fl_end = offset + count - 1;
6470 - error = __posix_lock_file(inode, &fl, NULL);
6471 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
6472 if (error != -EAGAIN)
6474 if (!(fl.fl_flags & FL_SLEEP))
6475 @@ -1410,8 +1438,8 @@ static int __setlease(struct file *filp,
6478 locks_copy_lock(fl, lease);
6480 locks_insert_lock(before, fl);
6485 @@ -1738,6 +1766,11 @@ int fcntl_setlk(unsigned int fd, struct
6486 if (file_lock == NULL)
6489 + vxd_assert(filp->f_xid == vx_current_xid(),
6490 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6491 + file_lock->fl_xid = filp->f_xid;
6492 + vx_locks_inc(file_lock);
6495 * This might block, so we do it before checking the inode.
6497 @@ -1864,6 +1897,11 @@ int fcntl_setlk64(unsigned int fd, struc
6498 if (file_lock == NULL)
6501 + vxd_assert(filp->f_xid == vx_current_xid(),
6502 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6503 + file_lock->fl_xid = filp->f_xid;
6504 + vx_locks_inc(file_lock);
6507 * This might block, so we do it before checking the inode.
6509 @@ -2168,6 +2206,10 @@ int get_locks_status(char *buffer, char
6510 list_for_each(tmp, &file_lock_list) {
6511 struct list_head *btmp;
6512 struct file_lock *fl = list_entry(tmp, struct file_lock, fl_link);
6514 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6517 lock_get_status(q, fl, ++i, "");
6518 move_lock_status(&q, &pos, offset);
6520 diff -NurpP --minimal linux-2.6.22.10/fs/namei.c linux-2.6.22.10-vs2.3.0.29/fs/namei.c
6521 --- linux-2.6.22.10/fs/namei.c 2007-07-09 13:19:27 +0200
6522 +++ linux-2.6.22.10-vs2.3.0.29/fs/namei.c 2007-10-29 23:41:56 +0100
6524 #include <linux/file.h>
6525 #include <linux/fcntl.h>
6526 #include <linux/namei.h>
6527 +#include <linux/proc_fs.h>
6528 +#include <linux/vserver/inode.h>
6529 +#include <linux/vs_base.h>
6530 +#include <linux/vs_tag.h>
6531 +#include <linux/vs_cowbl.h>
6532 +#include <linux/vs_device.h>
6533 +#include <linux/vs_context.h>
6534 #include <asm/namei.h>
6535 #include <asm/uaccess.h>
6537 @@ -224,6 +231,28 @@ int generic_permission(struct inode *ino
6541 +static inline int dx_barrier(struct inode *inode)
6543 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN)) {
6544 + vxwprintk_task(1, "did hit the barrier.");
6550 +static inline int dx_permission(struct inode *inode, int mask, struct nameidata *nd)
6552 + if (dx_barrier(inode))
6554 + if (dx_notagcheck(nd) ||
6555 + dx_check(inode->i_tag, DX_HOSTID|DX_ADMIN|DX_WATCH|DX_IDENT))
6558 + vxwprintk_task(1, "denied access to %p[#%d,%lu] »%s«.",
6559 + inode, inode->i_tag, inode->i_ino, vxd_cond_path(nd));
6563 int permission(struct inode *inode, int mask, struct nameidata *nd)
6565 umode_t mode = inode->i_mode;
6566 @@ -234,14 +263,14 @@ int permission(struct inode *inode, int
6568 * Nobody gets write access to a read-only fs.
6570 - if (IS_RDONLY(inode) &&
6571 + if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
6572 (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
6576 * Nobody gets write access to an immutable file.
6578 - if (IS_IMMUTABLE(inode))
6579 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6583 @@ -257,6 +286,12 @@ int permission(struct inode *inode, int
6585 /* Ordinary permission routines do not understand MAY_APPEND. */
6586 submask = mask & ~MAY_APPEND;
6588 + if ((inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC) &&
6589 + (inode->i_sb->s_magic != PROC_SUPER_MAGIC) &&
6590 + (retval = dx_permission(inode, mask, nd)))
6593 if (inode->i_op && inode->i_op->permission)
6594 retval = inode->i_op->permission(inode, submask, nd);
6596 @@ -432,6 +467,8 @@ static int exec_permission_lite(struct i
6598 umode_t mode = inode->i_mode;
6600 + if (dx_barrier(inode))
6602 if (inode->i_op && inode->i_op->permission)
6605 @@ -732,7 +769,8 @@ static __always_inline void follow_dotdo
6606 if (nd->dentry == fs->root &&
6607 nd->mnt == fs->rootmnt) {
6608 read_unlock(&fs->lock);
6610 + /* for sane '/' avoid follow_mount() */
6613 read_unlock(&fs->lock);
6614 spin_lock(&dcache_lock);
6615 @@ -769,16 +807,39 @@ static int do_lookup(struct nameidata *n
6617 struct vfsmount *mnt = nd->mnt;
6618 struct dentry *dentry = __d_lookup(nd->dentry, name);
6619 + struct inode *inode;
6623 if (dentry->d_op && dentry->d_op->d_revalidate)
6624 goto need_revalidate;
6625 + inode = dentry->d_inode;
6629 + if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6630 + struct proc_dir_entry *de = PDE(inode);
6632 + if (de && !vx_hide_check(0, de->vx_flags))
6634 + } else if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
6635 + if (!vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
6638 + if (!dx_notagcheck(nd) && !dx_check(inode->i_tag,
6639 + DX_WATCH | DX_ADMIN | DX_HOSTID | DX_IDENT))
6644 path->dentry = dentry;
6645 __follow_mount(path);
6648 + vxwprintk_task(1, "did lookup hidden %p[#%d,%lu] »%s«.",
6649 + inode, inode->i_tag, inode->i_ino, vxd_path(dentry, mnt));
6654 dentry = real_lookup(nd->dentry, name, nd);
6655 @@ -1399,7 +1460,8 @@ static inline int check_sticky(struct in
6656 * 10. We don't allow removal of NFS sillyrenamed files; it's handled by
6657 * nfs_async_unlink().
6659 -static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
6660 +static int may_delete(struct inode *dir, struct dentry *victim,
6661 + int isdir, struct nameidata *nd)
6665 @@ -1409,13 +1471,13 @@ static int may_delete(struct inode *dir,
6666 BUG_ON(victim->d_parent->d_inode != dir);
6667 audit_inode_child(victim->d_name.name, victim->d_inode, dir);
6669 - error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
6670 + error = permission(dir,MAY_WRITE | MAY_EXEC, nd);
6675 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6676 - IS_IMMUTABLE(victim->d_inode))
6677 + IS_IXORUNLINK(victim->d_inode))
6680 if (!S_ISDIR(victim->d_inode->i_mode))
6681 @@ -1546,6 +1608,14 @@ int may_open(struct nameidata *nd, int a
6682 if (S_ISDIR(inode->i_mode) && (flag & FMODE_WRITE))
6685 +#ifdef CONFIG_VSERVER_COWBL
6686 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
6687 + if (IS_COW_LINK(inode))
6689 + inode->i_flags &= ~(S_IUNLINK|S_IMMUTABLE);
6690 + mark_inode_dirty(inode);
6693 error = vfs_permission(nd, acc_mode);
6696 @@ -1562,7 +1632,8 @@ int may_open(struct nameidata *nd, int a
6700 - } else if (IS_RDONLY(inode) && (flag & FMODE_WRITE))
6701 + } else if ((IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
6702 + && (flag & FMODE_WRITE))
6705 * An append-only file must be opened in append mode for writing.
6706 @@ -1650,6 +1721,11 @@ int open_namei(int dfd, const char *path
6710 +#ifdef CONFIG_VSERVER_COWBL
6715 acc_mode = ACC_MODE(flag);
6717 /* O_TRUNC implies we need access checks for write permissions */
6718 @@ -1743,6 +1819,22 @@ do_last:
6721 error = may_open(nd, acc_mode, flag);
6722 +#ifdef CONFIG_VSERVER_COWBL
6723 + if (error == -EMLINK) {
6724 + struct dentry *dentry;
6725 + dentry = cow_break_link(pathname);
6726 + if (IS_ERR(dentry)) {
6727 + error = PTR_ERR(dentry);
6731 + release_open_intent(nd);
6741 @@ -1854,16 +1946,25 @@ fail:
6743 EXPORT_SYMBOL_GPL(lookup_create);
6745 -int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
6746 +int vfs_mknod(struct inode *dir, struct dentry *dentry,
6747 + int mode, dev_t dev, struct nameidata *nd)
6749 - int error = may_create(dir, dentry, NULL);
6750 + int error = may_create(dir, dentry, nd);
6755 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
6756 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
6759 + if (!capable(CAP_MKNOD))
6762 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
6764 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
6767 if (!dir->i_op || !dir->i_op->mknod)
6770 @@ -1906,11 +2007,12 @@ asmlinkage long sys_mknodat(int dfd, con
6771 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
6773 case S_IFCHR: case S_IFBLK:
6774 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
6775 - new_decode_dev(dev));
6776 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
6777 + new_decode_dev(dev), &nd);
6779 case S_IFIFO: case S_IFSOCK:
6780 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
6781 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
6786 @@ -1933,9 +2035,10 @@ asmlinkage long sys_mknod(const char __u
6787 return sys_mknodat(AT_FDCWD, filename, mode, dev);
6790 -int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
6791 +int vfs_mkdir(struct inode *dir, struct dentry *dentry,
6792 + int mode, struct nameidata *nd)
6794 - int error = may_create(dir, dentry, NULL);
6795 + int error = may_create(dir, dentry, nd);
6799 @@ -1977,7 +2080,7 @@ asmlinkage long sys_mkdirat(int dfd, con
6801 if (!IS_POSIXACL(nd.dentry->d_inode))
6802 mode &= ~current->fs->umask;
6803 - error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
6804 + error = vfs_mkdir(nd.dentry->d_inode, dentry, mode, &nd);
6807 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6808 @@ -2020,9 +2123,10 @@ void dentry_unhash(struct dentry *dentry
6809 spin_unlock(&dcache_lock);
6812 -int vfs_rmdir(struct inode *dir, struct dentry *dentry)
6813 +int vfs_rmdir(struct inode *dir, struct dentry *dentry,
6814 + struct nameidata *nd)
6816 - int error = may_delete(dir, dentry, 1);
6817 + int error = may_delete(dir, dentry, 1, nd);
6821 @@ -2084,7 +2188,7 @@ static long do_rmdir(int dfd, const char
6822 error = PTR_ERR(dentry);
6825 - error = vfs_rmdir(nd.dentry->d_inode, dentry);
6826 + error = vfs_rmdir(nd.dentry->d_inode, dentry, &nd);
6829 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6830 @@ -2100,9 +2204,10 @@ asmlinkage long sys_rmdir(const char __u
6831 return do_rmdir(AT_FDCWD, pathname);
6834 -int vfs_unlink(struct inode *dir, struct dentry *dentry)
6835 +int vfs_unlink(struct inode *dir, struct dentry *dentry,
6836 + struct nameidata *nd)
6838 - int error = may_delete(dir, dentry, 0);
6839 + int error = may_delete(dir, dentry, 0, nd);
6843 @@ -2164,7 +2269,7 @@ static long do_unlinkat(int dfd, const c
6844 inode = dentry->d_inode;
6846 atomic_inc(&inode->i_count);
6847 - error = vfs_unlink(nd.dentry->d_inode, dentry);
6848 + error = vfs_unlink(nd.dentry->d_inode, dentry, &nd);
6852 @@ -2199,9 +2304,10 @@ asmlinkage long sys_unlink(const char __
6853 return do_unlinkat(AT_FDCWD, pathname);
6856 -int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, int mode)
6857 +int vfs_symlink(struct inode *dir, struct dentry *dentry,
6858 + const char *oldname, int mode, struct nameidata *nd)
6860 - int error = may_create(dir, dentry, NULL);
6861 + int error = may_create(dir, dentry, nd);
6865 @@ -2245,7 +2351,7 @@ asmlinkage long sys_symlinkat(const char
6869 - error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
6870 + error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO, &nd);
6873 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6874 @@ -2262,7 +2368,8 @@ asmlinkage long sys_symlink(const char _
6875 return sys_symlinkat(oldname, AT_FDCWD, newname);
6878 -int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
6879 +int vfs_link(struct dentry *old_dentry, struct inode *dir,
6880 + struct dentry *new_dentry, struct nameidata *nd)
6882 struct inode *inode = old_dentry->d_inode;
6884 @@ -2270,7 +2377,7 @@ int vfs_link(struct dentry *old_dentry,
6888 - error = may_create(dir, new_dentry, NULL);
6889 + error = may_create(dir, new_dentry, nd);
6893 @@ -2280,7 +2387,7 @@ int vfs_link(struct dentry *old_dentry,
6895 * A link to an append-only or immutable file cannot be created.
6897 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6898 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6900 if (!dir->i_op || !dir->i_op->link)
6902 @@ -2340,7 +2447,7 @@ asmlinkage long sys_linkat(int olddfd, c
6903 error = PTR_ERR(new_dentry);
6904 if (IS_ERR(new_dentry))
6906 - error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
6907 + error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry, &nd);
6910 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6911 @@ -2472,14 +2579,14 @@ int vfs_rename(struct inode *old_dir, st
6912 if (old_dentry->d_inode == new_dentry->d_inode)
6915 - error = may_delete(old_dir, old_dentry, is_dir);
6916 + error = may_delete(old_dir, old_dentry, is_dir, NULL);
6920 if (!new_dentry->d_inode)
6921 error = may_create(new_dir, new_dentry, NULL);
6923 - error = may_delete(new_dir, new_dentry, is_dir);
6924 + error = may_delete(new_dir, new_dentry, is_dir, NULL);
6928 @@ -2557,6 +2664,9 @@ static int do_rename(int olddfd, const c
6930 if (old_dentry == trap)
6933 + if (MNT_IS_RDONLY(newnd.mnt))
6935 new_dentry = lookup_hash(&newnd);
6936 error = PTR_ERR(new_dentry);
6937 if (IS_ERR(new_dentry))
6938 @@ -2650,6 +2760,216 @@ int vfs_follow_link(struct nameidata *nd
6939 return __vfs_follow_link(nd, link);
6943 +#ifdef CONFIG_VSERVER_COWBL
6945 +#include <linux/file.h>
6948 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6952 + return do_splice_direct(in, &ppos, out, len, 0);
6955 +struct dentry *cow_break_link(const char *pathname)
6957 + int ret, mode, pathlen, redo = 0;
6958 + struct nameidata old_nd, dir_nd;
6959 + struct dentry *old_dentry, *new_dentry;
6960 + struct dentry *dir, *res = NULL;
6961 + struct vfsmount *old_mnt, *new_mnt;
6962 + struct file *old_file;
6963 + struct file *new_file;
6964 + char *to, *path, pad='\251';
6967 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
6968 + path = kmalloc(PATH_MAX, GFP_KERNEL);
6973 + /* old_nd will have refs to dentry and mnt */
6974 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6975 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
6977 + goto out_free_path;
6979 + old_dentry = old_nd.dentry;
6980 + old_mnt = old_nd.mnt;
6981 + mode = old_dentry->d_inode->i_mode;
6983 + to = d_path(old_dentry, old_mnt, path, PATH_MAX-2);
6984 + pathlen = strlen(to);
6985 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
6986 + old_dentry->d_name.len, old_dentry->d_name.name,
6987 + old_dentry->d_name.len);
6989 + to[pathlen + 1] = 0;
6991 + to[pathlen] = pad--;
6993 + if (pad <= '\240')
6996 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
6997 + /* dir_nd will have refs to dentry and mnt */
6998 + ret = path_lookup(to,
6999 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
7000 + vxdprintk(VXD_CBIT(misc, 2),
7001 + "path_lookup(new): %d", ret);
7005 + /* this puppy downs the inode mutex */
7006 + new_dentry = lookup_create(&dir_nd, 0);
7007 + vxdprintk(VXD_CBIT(misc, 2),
7008 + "lookup_create(new): %p [»%.*s«:%d]", new_dentry,
7009 + new_dentry->d_name.len, new_dentry->d_name.name,
7010 + new_dentry->d_name.len);
7011 + if (!new_dentry || IS_ERR(new_dentry)) {
7012 + path_release(&dir_nd);
7015 + dir = dir_nd.dentry;
7017 + ret = vfs_create(dir_nd.dentry->d_inode, new_dentry, mode, &dir_nd);
7018 + vxdprintk(VXD_CBIT(misc, 2),
7019 + "vfs_create(new): %d", ret);
7020 + if (ret == -EEXIST) {
7021 + mutex_unlock(&dir->d_inode->i_mutex);
7023 + path_release(&dir_nd);
7027 + goto out_unlock_new;
7029 + /* drop out early, ret passes ENOENT */
7031 + if ((redo = d_unhashed(old_dentry)))
7032 + goto out_unlock_new;
7034 + new_mnt = dir_nd.mnt;
7037 + /* this one cleans up the dentry/mnt in case of failure */
7038 + old_file = dentry_open(old_dentry, old_mnt, O_RDONLY);
7039 + vxdprintk(VXD_CBIT(misc, 2),
7040 + "dentry_open(old): %p", old_file);
7041 + if (!old_file || IS_ERR(old_file)) {
7042 + res = IS_ERR(old_file) ? (void *) old_file : res;
7043 + goto out_unlock_new;
7048 + /* this one cleans up the dentry/mnt in case of failure */
7049 + new_file = dentry_open(new_dentry, new_mnt, O_WRONLY);
7050 + vxdprintk(VXD_CBIT(misc, 2),
7051 + "dentry_open(new): %p", new_file);
7053 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
7054 + if (!new_file || IS_ERR(new_file))
7055 + goto out_fput_old;
7057 + size = i_size_read(old_file->f_dentry->d_inode);
7058 + ret = do_cow_splice(old_file, new_file, size);
7059 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
7061 + goto out_fput_both;
7062 + } else if (ret < size) {
7064 + goto out_fput_both;
7066 + struct inode *old_inode = old_dentry->d_inode;
7067 + struct inode *new_inode = new_dentry->d_inode;
7068 + struct iattr attr = {
7069 + .ia_uid = old_inode->i_uid,
7070 + .ia_gid = old_inode->i_gid,
7071 + .ia_valid = ATTR_UID | ATTR_GID
7074 + ret = inode_setattr(new_inode, &attr);
7076 + goto out_fput_both;
7079 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
7081 + /* drop out late */
7083 + if ((redo = d_unhashed(old_dentry)))
7086 + vxdprintk(VXD_CBIT(misc, 2),
7087 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
7088 + new_dentry->d_name.len, new_dentry->d_name.name,
7089 + new_dentry->d_name.len,
7090 + old_dentry->d_name.len, old_dentry->d_name.name,
7091 + old_dentry->d_name.len);
7092 + ret = vfs_rename(dir_nd.dentry->d_inode, new_dentry,
7093 + old_nd.dentry->d_parent->d_inode, old_dentry);
7094 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
7098 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
7101 + vxdprintk(VXD_CBIT(misc, 3),
7102 + "fput(new_file=%p[#%d])", new_file,
7103 + atomic_read(&new_file->f_count));
7107 + vxdprintk(VXD_CBIT(misc, 3),
7108 + "fput(old_file=%p[#%d])", old_file,
7109 + atomic_read(&old_file->f_count));
7113 + mutex_unlock(&dir->d_inode->i_mutex);
7117 + /* error path cleanup */
7118 + vfs_unlink(dir->d_inode, new_dentry, &dir_nd);
7123 + goto out_rel_both;
7124 + /* lookup dentry once again */
7125 + path_release(&old_nd);
7126 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
7128 + goto out_rel_both;
7130 + new_dentry = old_nd.dentry;
7131 + vxdprintk(VXD_CBIT(misc, 2),
7132 + "path_lookup(redo): %p [»%.*s«:%d]", new_dentry,
7133 + new_dentry->d_name.len, new_dentry->d_name.name,
7134 + new_dentry->d_name.len);
7139 + path_release(&dir_nd);
7141 + path_release(&old_nd);
7146 + res = ERR_PTR(ret);
7152 /* get the link contents into pagecache */
7153 static char *page_getlink(struct dentry * dentry, struct page **ppage)
7155 diff -NurpP --minimal linux-2.6.22.10/fs/namespace.c linux-2.6.22.10-vs2.3.0.29/fs/namespace.c
7156 --- linux-2.6.22.10/fs/namespace.c 2007-07-09 13:19:27 +0200
7157 +++ linux-2.6.22.10-vs2.3.0.29/fs/namespace.c 2007-09-05 02:29:17 +0200
7159 #include <linux/security.h>
7160 #include <linux/mount.h>
7161 #include <linux/ramfs.h>
7162 +#include <linux/vs_base.h>
7163 +#include <linux/vs_context.h>
7164 +#include <linux/vs_tag.h>
7165 +#include <linux/vserver/space.h>
7166 +#include <linux/vserver/global.h>
7167 #include <asm/uaccess.h>
7168 #include <asm/unistd.h>
7170 @@ -240,6 +245,7 @@ static struct vfsmount *clone_mnt(struct
7171 mnt->mnt_root = dget(root);
7172 mnt->mnt_mountpoint = mnt->mnt_root;
7173 mnt->mnt_parent = mnt;
7174 + mnt->mnt_tag = old->mnt_tag;
7176 if (flag & CL_SLAVE) {
7177 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
7178 @@ -348,48 +354,91 @@ static inline void mangle(struct seq_fil
7179 seq_escape(m, s, " \t\n\\");
7182 +static int mnt_is_reachable(struct vfsmount *mnt)
7184 + struct vfsmount *root_mnt;
7185 + struct dentry *root, *point;
7188 + if (mnt == mnt->mnt_ns->root)
7191 + spin_lock(&vfsmount_lock);
7192 + root_mnt = current->fs->rootmnt;
7193 + root = current->fs->root;
7196 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
7197 + point = mnt->mnt_mountpoint;
7198 + mnt = mnt->mnt_parent;
7201 + ret = (mnt == root_mnt) && is_subdir(point, root);
7203 + spin_unlock(&vfsmount_lock);
7208 static int show_vfsmnt(struct seq_file *m, void *v)
7210 struct vfsmount *mnt = v;
7212 static struct proc_fs_info {
7220 - { MS_SYNCHRONOUS, ",sync" },
7221 - { MS_DIRSYNC, ",dirsync" },
7222 - { MS_MANDLOCK, ",mand" },
7225 - static struct proc_fs_info mnt_info[] = {
7226 - { MNT_NOSUID, ",nosuid" },
7227 - { MNT_NODEV, ",nodev" },
7228 - { MNT_NOEXEC, ",noexec" },
7229 - { MNT_NOATIME, ",noatime" },
7230 - { MNT_NODIRATIME, ",nodiratime" },
7231 - { MNT_RELATIME, ",relatime" },
7233 + { MS_RDONLY, MNT_RDONLY, "ro", "rw" },
7234 + { MS_SYNCHRONOUS, 0, ",sync", NULL },
7235 + { MS_DIRSYNC, 0, ",dirsync", NULL },
7236 + { MS_MANDLOCK, 0, ",mand", NULL },
7237 + { MS_TAGGED, 0, ",tag", NULL },
7238 + { MS_NOATIME, MNT_NOATIME, ",noatime", NULL },
7239 + { MS_NODIRATIME, MNT_NODIRATIME, ",nodiratime", NULL },
7240 + { MS_RELATIME, MNT_RELATIME, ",relatime", NULL },
7241 + { 0, MNT_NOSUID, ",nosuid", NULL },
7242 + { 0, MNT_NODEV, ",nodev", NULL },
7243 + { 0, MNT_NOEXEC, ",noexec", NULL },
7244 + { 0, 0, NULL, NULL }
7246 - struct proc_fs_info *fs_infop;
7247 + struct proc_fs_info *p;
7248 + unsigned long s_flags = mnt->mnt_sb->s_flags;
7249 + int mnt_flags = mnt->mnt_flags;
7251 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7253 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7255 - mangle(m, mnt->mnt_sb->s_type->name);
7256 - if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
7258 - mangle(m, mnt->mnt_sb->s_subtype);
7260 - seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? " ro" : " rw");
7261 - for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
7262 - if (mnt->mnt_sb->s_flags & fs_infop->flag)
7263 - seq_puts(m, fs_infop->str);
7264 + if (vx_flags(VXF_HIDE_MOUNT, 0))
7266 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7269 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7270 + mnt == current->fs->rootmnt) {
7271 + seq_puts(m, "/dev/root / ");
7273 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7275 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7278 + if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
7280 + mangle(m, mnt->mnt_sb->s_subtype);
7283 - for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
7284 - if (mnt->mnt_flags & fs_infop->flag)
7285 - seq_puts(m, fs_infop->str);
7286 + mangle(m, mnt->mnt_sb->s_type->name);
7288 + for (p = fs_info; (p->s_flag | p->mnt_flag) ; p++) {
7289 + if ((s_flags & p->s_flag) || (mnt_flags & p->mnt_flag)) {
7291 + seq_puts(m, p->set_str);
7294 + seq_puts(m, p->unset_str);
7297 + if (mnt->mnt_flags & MNT_TAGID)
7298 + seq_printf(m, ",tag=%d", mnt->mnt_tag);
7299 if (mnt->mnt_sb->s_op->show_options)
7300 err = mnt->mnt_sb->s_op->show_options(m, mnt);
7301 seq_puts(m, " 0 0\n");
7302 @@ -408,17 +457,27 @@ static int show_vfsstat(struct seq_file
7303 struct vfsmount *mnt = v;
7307 - if (mnt->mnt_devname) {
7308 - seq_puts(m, "device ");
7309 - mangle(m, mnt->mnt_devname);
7311 - seq_puts(m, "no device");
7312 + if (vx_flags(VXF_HIDE_MOUNT, 0))
7314 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7318 - seq_puts(m, " mounted on ");
7319 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7321 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7322 + mnt == current->fs->rootmnt) {
7323 + seq_puts(m, "device /dev/root mounted on / ");
7326 + if (mnt->mnt_devname) {
7327 + seq_puts(m, "device ");
7328 + mangle(m, mnt->mnt_devname);
7330 + seq_puts(m, "no device");
7333 + seq_puts(m, " mounted on ");
7334 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7338 /* file system type */
7339 seq_puts(m, "with fstype ");
7340 @@ -648,7 +707,7 @@ asmlinkage long sys_umount(char __user *
7344 - if (!capable(CAP_SYS_ADMIN))
7345 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7348 retval = do_umount(nd.mnt, flags);
7349 @@ -672,7 +731,7 @@ asmlinkage long sys_oldumount(char __use
7351 static int mount_is_safe(struct nameidata *nd)
7353 - if (capable(CAP_SYS_ADMIN))
7354 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7358 @@ -904,11 +963,13 @@ static int do_change_type(struct nameida
7360 * do loopback mount.
7362 -static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
7363 +static int do_loopback(struct nameidata *nd, char *old_name, tag_t tag,
7364 + unsigned long flags, int mnt_flags)
7366 struct nameidata old_nd;
7367 struct vfsmount *mnt = NULL;
7368 int err = mount_is_safe(nd);
7369 + int recurse = flags & MS_REC;
7372 if (!old_name || !*old_name)
7373 @@ -934,6 +995,12 @@ static int do_loopback(struct nameidata
7377 + mnt->mnt_flags = mnt_flags;
7378 + if (flags & MS_TAGID) {
7379 + mnt->mnt_tag = tag;
7380 + mnt->mnt_flags |= MNT_TAGID;
7383 err = graft_tree(mnt, nd);
7385 LIST_HEAD(umount_list);
7386 @@ -942,6 +1009,7 @@ static int do_loopback(struct nameidata
7387 spin_unlock(&vfsmount_lock);
7388 release_mounts(&umount_list);
7390 + mnt->mnt_flags = mnt_flags;
7393 up_write(&namespace_sem);
7394 @@ -955,12 +1023,12 @@ out:
7395 * on it - tough luck.
7397 static int do_remount(struct nameidata *nd, int flags, int mnt_flags,
7399 + void *data, xid_t xid)
7402 struct super_block *sb = nd->mnt->mnt_sb;
7404 - if (!capable(CAP_SYS_ADMIN))
7405 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
7408 if (!check_mnt(nd->mnt))
7409 @@ -994,7 +1062,7 @@ static int do_move_mount(struct nameidat
7410 struct nameidata old_nd, parent_nd;
7413 - if (!capable(CAP_SYS_ADMIN))
7414 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7416 if (!old_name || !*old_name)
7418 @@ -1074,7 +1142,7 @@ static int do_new_mount(struct nameidata
7421 /* we need capabilities... */
7422 - if (!capable(CAP_SYS_ADMIN))
7423 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7426 mnt = do_kern_mount(type, flags, name, data);
7427 @@ -1386,6 +1454,7 @@ long do_mount(char *dev_name, char *dir_
7428 struct nameidata nd;
7434 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
7435 @@ -1401,7 +1470,17 @@ long do_mount(char *dev_name, char *dir_
7437 ((char *)data_page)[PAGE_SIZE - 1] = 0;
7439 + retval = dx_parse_tag(data_page, &tag, 1);
7441 + mnt_flags |= retval;
7442 + /* FIXME: bind and re-mounts get the tag flag? */
7443 + if (flags & (MS_BIND|MS_REMOUNT))
7444 + flags |= MS_TAGID;
7447 /* Separate the per-mountpoint flags */
7448 + if (flags & MS_RDONLY)
7449 + mnt_flags |= MNT_RDONLY;
7450 if (flags & MS_NOSUID)
7451 mnt_flags |= MNT_NOSUID;
7452 if (flags & MS_NODEV)
7453 @@ -1415,6 +1494,8 @@ long do_mount(char *dev_name, char *dir_
7454 if (flags & MS_RELATIME)
7455 mnt_flags |= MNT_RELATIME;
7457 + if (!capable(CAP_SYS_ADMIN))
7458 + mnt_flags |= MNT_NODEV;
7459 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
7460 MS_NOATIME | MS_NODIRATIME | MS_RELATIME);
7462 @@ -1429,9 +1510,9 @@ long do_mount(char *dev_name, char *dir_
7464 if (flags & MS_REMOUNT)
7465 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
7468 else if (flags & MS_BIND)
7469 - retval = do_loopback(&nd, dev_name, flags & MS_REC);
7470 + retval = do_loopback(&nd, dev_name, tag, flags, mnt_flags);
7471 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
7472 retval = do_change_type(&nd, flags);
7473 else if (flags & MS_MOVE)
7474 @@ -1504,6 +1585,7 @@ static struct mnt_namespace *dup_mnt_ns(
7475 q = next_mnt(q, new_ns->root);
7477 up_write(&namespace_sem);
7478 + atomic_inc(&vs_global_mnt_ns);
7482 @@ -1866,5 +1948,6 @@ void __put_mnt_ns(struct mnt_namespace *
7483 spin_unlock(&vfsmount_lock);
7484 up_write(&namespace_sem);
7485 release_mounts(&umount_list);
7486 + atomic_dec(&vs_global_mnt_ns);
7489 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/client.c linux-2.6.22.10-vs2.3.0.29/fs/nfs/client.c
7490 --- linux-2.6.22.10/fs/nfs/client.c 2007-07-09 13:19:27 +0200
7491 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/client.c 2007-08-05 20:53:13 +0200
7492 @@ -521,6 +521,9 @@ static int nfs_init_server_rpcclient(str
7493 if (server->flags & NFS4_MOUNT_INTR)
7494 server->client->cl_intr = 1;
7496 + server->client->cl_tag = 0;
7497 + if (server->flags & NFS_MOUNT_TAGGED)
7498 + server->client->cl_tag = 1;
7502 @@ -678,6 +681,10 @@ static void nfs_server_set_fsinfo(struct
7503 server->acdirmin = server->acdirmax = 0;
7506 + /* FIXME: needs fsinfo
7507 + if (server->flags & NFS_MOUNT_TAGGED)
7508 + sb->s_flags |= MS_TAGGED; */
7510 server->maxfilesize = fsinfo->maxfilesize;
7512 /* We're airborne Set socket buffersize */
7513 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/dir.c linux-2.6.22.10-vs2.3.0.29/fs/nfs/dir.c
7514 --- linux-2.6.22.10/fs/nfs/dir.c 2007-07-09 13:19:27 +0200
7515 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/dir.c 2007-08-05 20:53:13 +0200
7517 #include <linux/namei.h>
7518 #include <linux/mount.h>
7519 #include <linux/sched.h>
7520 +#include <linux/vs_tag.h>
7522 #include "nfs4_fs.h"
7523 #include "delegation.h"
7524 @@ -956,6 +957,7 @@ static struct dentry *nfs_lookup(struct
7528 + dx_propagate_tag(nd, inode);
7530 res = d_materialise_unique(dentry, inode);
7532 @@ -998,7 +1000,8 @@ static int is_atomic_open(struct inode *
7533 if (nd->flags & LOOKUP_DIRECTORY)
7535 /* Are we trying to write to a read only partition? */
7536 - if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
7537 + if ((IS_RDONLY(dir) || MNT_IS_RDONLY(nd->mnt)) &&
7538 + (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
7542 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/inode.c linux-2.6.22.10-vs2.3.0.29/fs/nfs/inode.c
7543 --- linux-2.6.22.10/fs/nfs/inode.c 2007-07-09 13:19:27 +0200
7544 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/inode.c 2007-08-05 20:53:13 +0200
7546 #include <linux/vfs.h>
7547 #include <linux/inet.h>
7548 #include <linux/nfs_xdr.h>
7549 +#include <linux/vs_tag.h>
7551 #include <asm/system.h>
7552 #include <asm/uaccess.h>
7553 @@ -285,8 +286,10 @@ nfs_fhget(struct super_block *sb, struct
7554 nfsi->change_attr = fattr->change_attr;
7555 inode->i_size = nfs_size_to_loff_t(fattr->size);
7556 inode->i_nlink = fattr->nlink;
7557 - inode->i_uid = fattr->uid;
7558 - inode->i_gid = fattr->gid;
7559 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7560 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7561 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7562 + /* maybe fattr->xid someday */
7563 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
7565 * report the blocks in 512byte units
7566 @@ -377,6 +380,8 @@ void nfs_setattr_update_inode(struct ino
7567 inode->i_uid = attr->ia_uid;
7568 if ((attr->ia_valid & ATTR_GID) != 0)
7569 inode->i_gid = attr->ia_gid;
7570 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7571 + inode->i_tag = attr->ia_tag;
7572 spin_lock(&inode->i_lock);
7573 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7574 spin_unlock(&inode->i_lock);
7575 @@ -825,6 +830,9 @@ static int nfs_check_inode_attributes(st
7576 struct nfs_inode *nfsi = NFS_I(inode);
7577 loff_t cur_size, new_isize;
7584 /* Has the inode gone and changed behind our back? */
7585 @@ -852,10 +860,15 @@ static int nfs_check_inode_attributes(st
7586 if (cur_size != new_isize && nfsi->npages == 0)
7587 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7589 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7590 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7591 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7593 /* Have any file permissions changed? */
7594 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
7595 - || inode->i_uid != fattr->uid
7596 - || inode->i_gid != fattr->gid)
7597 + || inode->i_uid != uid
7598 + || inode->i_gid != gid
7599 + || inode->i_tag != tag)
7600 nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7602 /* Has the link count changed? */
7603 @@ -946,6 +959,9 @@ static int nfs_update_inode(struct inode
7604 unsigned int invalid = 0;
7605 unsigned long now = jiffies;
7611 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7612 __FUNCTION__, inode->i_sb->s_id, inode->i_ino,
7613 @@ -1022,15 +1038,21 @@ static int nfs_update_inode(struct inode
7615 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7617 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7618 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7619 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7621 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
7622 - inode->i_uid != fattr->uid ||
7623 - inode->i_gid != fattr->gid)
7624 + inode->i_uid != uid ||
7625 + inode->i_gid != gid ||
7626 + inode->i_tag != tag)
7627 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7629 inode->i_mode = fattr->mode;
7630 inode->i_nlink = fattr->nlink;
7631 - inode->i_uid = fattr->uid;
7632 - inode->i_gid = fattr->gid;
7633 + inode->i_uid = uid;
7634 + inode->i_gid = gid;
7635 + inode->i_tag = tag;
7637 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
7639 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/nfs3xdr.c linux-2.6.22.10-vs2.3.0.29/fs/nfs/nfs3xdr.c
7640 --- linux-2.6.22.10/fs/nfs/nfs3xdr.c 2007-07-09 13:19:27 +0200
7641 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/nfs3xdr.c 2007-08-05 20:53:13 +0200
7643 #include <linux/nfs3.h>
7644 #include <linux/nfs_fs.h>
7645 #include <linux/nfsacl.h>
7646 +#include <linux/vs_tag.h>
7647 #include "internal.h"
7649 #define NFSDBG_FACILITY NFSDBG_XDR
7650 @@ -178,7 +179,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
7653 static inline __be32 *
7654 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
7655 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
7657 if (attr->ia_valid & ATTR_MODE) {
7659 @@ -186,15 +187,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
7663 - if (attr->ia_valid & ATTR_UID) {
7664 + if (attr->ia_valid & ATTR_UID ||
7665 + (tag && (attr->ia_valid & ATTR_TAG))) {
7667 - *p++ = htonl(attr->ia_uid);
7668 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
7672 - if (attr->ia_valid & ATTR_GID) {
7673 + if (attr->ia_valid & ATTR_GID ||
7674 + (tag && (attr->ia_valid & ATTR_TAG))) {
7676 - *p++ = htonl(attr->ia_gid);
7677 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
7681 @@ -279,7 +282,8 @@ static int
7682 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
7684 p = xdr_encode_fhandle(p, args->fh);
7685 - p = xdr_encode_sattr(p, args->sattr);
7686 + p = xdr_encode_sattr(p, args->sattr,
7687 + req->rq_task->tk_client->cl_tag);
7688 *p++ = htonl(args->guard);
7690 p = xdr_encode_time3(p, &args->guardtime);
7691 @@ -370,7 +374,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
7692 *p++ = args->verifier[0];
7693 *p++ = args->verifier[1];
7695 - p = xdr_encode_sattr(p, args->sattr);
7696 + p = xdr_encode_sattr(p, args->sattr,
7697 + req->rq_task->tk_client->cl_tag);
7699 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7701 @@ -384,7 +389,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
7703 p = xdr_encode_fhandle(p, args->fh);
7704 p = xdr_encode_array(p, args->name, args->len);
7705 - p = xdr_encode_sattr(p, args->sattr);
7706 + p = xdr_encode_sattr(p, args->sattr,
7707 + req->rq_task->tk_client->cl_tag);
7708 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7711 @@ -397,7 +403,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
7713 p = xdr_encode_fhandle(p, args->fromfh);
7714 p = xdr_encode_array(p, args->fromname, args->fromlen);
7715 - p = xdr_encode_sattr(p, args->sattr);
7716 + p = xdr_encode_sattr(p, args->sattr,
7717 + req->rq_task->tk_client->cl_tag);
7718 *p++ = htonl(args->pathlen);
7719 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7721 @@ -415,7 +422,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
7722 p = xdr_encode_fhandle(p, args->fh);
7723 p = xdr_encode_array(p, args->name, args->len);
7724 *p++ = htonl(args->type);
7725 - p = xdr_encode_sattr(p, args->sattr);
7726 + p = xdr_encode_sattr(p, args->sattr,
7727 + req->rq_task->tk_client->cl_tag);
7728 if (args->type == NF3CHR || args->type == NF3BLK) {
7729 *p++ = htonl(MAJOR(args->rdev));
7730 *p++ = htonl(MINOR(args->rdev));
7731 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/nfsroot.c linux-2.6.22.10-vs2.3.0.29/fs/nfs/nfsroot.c
7732 --- linux-2.6.22.10/fs/nfs/nfsroot.c 2007-07-09 13:19:27 +0200
7733 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/nfsroot.c 2007-08-05 20:53:13 +0200
7734 @@ -118,12 +118,12 @@ static int mount_port __initdata = 0; /
7736 /* Options that take integer arguments */
7737 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
7738 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
7739 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
7740 /* Options that take no arguments */
7741 Opt_soft, Opt_hard, Opt_intr,
7742 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
7743 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
7744 - Opt_acl, Opt_noacl,
7745 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
7749 @@ -160,6 +160,9 @@ static match_table_t __initdata tokens =
7752 {Opt_noacl, "noacl"},
7754 + {Opt_notag, "notag"},
7755 + {Opt_tagid, "tagid=%u"},
7759 @@ -274,6 +277,20 @@ static int __init root_nfs_parse(char *n
7761 nfs_data.flags |= NFS_MOUNT_NOACL;
7763 +#ifndef CONFIG_TAGGING_NONE
7765 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7768 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
7771 +#ifdef CONFIG_PROPAGATE
7774 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7778 printk(KERN_WARNING "Root-NFS: unknown "
7780 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/super.c linux-2.6.22.10-vs2.3.0.29/fs/nfs/super.c
7781 --- linux-2.6.22.10/fs/nfs/super.c 2007-10-30 01:57:14 +0100
7782 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/super.c 2007-09-30 14:58:01 +0200
7784 #include <linux/nfs_xdr.h>
7785 #include <linux/magic.h>
7786 #include <linux/parser.h>
7787 +#include <linux/vs_tag.h>
7789 #include <asm/system.h>
7790 #include <asm/uaccess.h>
7791 @@ -291,6 +292,7 @@ static void nfs_show_mount_options(struc
7792 { NFS_MOUNT_NOACL, ",noacl", "" },
7793 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7794 { NFS_MOUNT_UNSHARED, ",nosharecache", ""},
7795 + { NFS_MOUNT_TAGGED, ",tag", "" },
7798 const struct proc_nfs_info *nfs_infop;
7799 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/auth.c linux-2.6.22.10-vs2.3.0.29/fs/nfsd/auth.c
7800 --- linux-2.6.22.10/fs/nfsd/auth.c 2006-06-18 04:54:42 +0200
7801 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/auth.c 2007-08-05 20:53:13 +0200
7803 #include <linux/sunrpc/svc.h>
7804 #include <linux/sunrpc/svcauth.h>
7805 #include <linux/nfsd/nfsd.h>
7806 +#include <linux/vs_tag.h>
7808 #define CAP_NFSD_MASK (CAP_FS_MASK|CAP_TO_MASK(CAP_SYS_RESOURCE))
7810 @@ -41,19 +42,22 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7811 get_group_info(cred.cr_group_info);
7813 if (cred.cr_uid != (uid_t) -1)
7814 - current->fsuid = cred.cr_uid;
7815 + current->fsuid = INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
7817 current->fsuid = exp->ex_anon_uid;
7818 if (cred.cr_gid != (gid_t) -1)
7819 - current->fsgid = cred.cr_gid;
7820 + current->fsgid = INOTAG_GID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
7822 current->fsgid = exp->ex_anon_gid;
7824 + /* this desperately needs a tag :) */
7825 + current->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7827 if (!cred.cr_group_info)
7829 ret = set_current_groups(cred.cr_group_info);
7830 put_group_info(cred.cr_group_info);
7831 - if ((cred.cr_uid)) {
7832 + if (INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid)) {
7833 cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
7835 cap_t(current->cap_effective) |= (CAP_NFSD_MASK &
7836 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/nfs3xdr.c linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs3xdr.c
7837 --- linux-2.6.22.10/fs/nfsd/nfs3xdr.c 2007-07-09 13:19:27 +0200
7838 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs3xdr.c 2007-08-05 20:53:13 +0200
7840 #include <linux/sunrpc/svc.h>
7841 #include <linux/nfsd/nfsd.h>
7842 #include <linux/nfsd/xdr3.h>
7843 +#include <linux/vs_tag.h>
7845 #define NFSDDBG_FACILITY NFSDDBG_XDR
7847 @@ -107,6 +108,8 @@ static __be32 *
7848 decode_sattr3(__be32 *p, struct iattr *iap)
7856 @@ -116,12 +119,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7859 iap->ia_valid |= ATTR_UID;
7860 - iap->ia_uid = ntohl(*p++);
7861 + uid = ntohl(*p++);
7864 iap->ia_valid |= ATTR_GID;
7865 - iap->ia_gid = ntohl(*p++);
7866 + gid = ntohl(*p++);
7868 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7869 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7870 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7874 @@ -180,8 +186,10 @@ encode_fattr3(struct svc_rqst *rqstp, __
7875 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7876 *p++ = htonl((u32) stat->mode);
7877 *p++ = htonl((u32) stat->nlink);
7878 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7879 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7880 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7881 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7882 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7883 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7884 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7885 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7887 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/nfs4recover.c linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs4recover.c
7888 --- linux-2.6.22.10/fs/nfsd/nfs4recover.c 2007-07-09 13:19:27 +0200
7889 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs4recover.c 2007-08-05 20:53:13 +0200
7890 @@ -156,7 +156,7 @@ nfsd4_create_clid_dir(struct nfs4_client
7891 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n");
7894 - status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU);
7895 + status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU, NULL);
7899 @@ -260,7 +260,7 @@ nfsd4_remove_clid_file(struct dentry *di
7902 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
7903 - status = vfs_unlink(dir->d_inode, dentry);
7904 + status = vfs_unlink(dir->d_inode, dentry, NULL);
7905 mutex_unlock(&dir->d_inode->i_mutex);
7908 @@ -275,7 +275,7 @@ nfsd4_clear_clid_dir(struct dentry *dir,
7909 * a kernel from the future.... */
7910 nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file);
7911 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
7912 - status = vfs_rmdir(dir->d_inode, dentry);
7913 + status = vfs_rmdir(dir->d_inode, dentry, NULL);
7914 mutex_unlock(&dir->d_inode->i_mutex);
7917 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/nfs4xdr.c linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs4xdr.c
7918 --- linux-2.6.22.10/fs/nfsd/nfs4xdr.c 2007-07-09 13:19:27 +0200
7919 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs4xdr.c 2007-08-05 20:53:13 +0200
7921 #include <linux/nfs4_acl.h>
7922 #include <linux/sunrpc/gss_api.h>
7923 #include <linux/sunrpc/svcauth_gss.h>
7924 +#include <linux/vs_tag.h>
7926 #define NFSDDBG_FACILITY NFSDDBG_XDR
7928 @@ -1727,14 +1728,18 @@ out_acl:
7929 WRITE32(stat.nlink);
7931 if (bmval1 & FATTR4_WORD1_OWNER) {
7932 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7933 + status = nfsd4_encode_user(rqstp,
7934 + TAGINO_UID(DX_TAG(dentry->d_inode),
7935 + stat.uid, stat.tag), &p, &buflen);
7936 if (status == nfserr_resource)
7941 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7942 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7943 + status = nfsd4_encode_group(rqstp,
7944 + TAGINO_GID(DX_TAG(dentry->d_inode),
7945 + stat.gid, stat.tag), &p, &buflen);
7946 if (status == nfserr_resource)
7949 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/nfsxdr.c linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfsxdr.c
7950 --- linux-2.6.22.10/fs/nfsd/nfsxdr.c 2007-07-09 13:19:27 +0200
7951 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfsxdr.c 2007-08-05 20:53:13 +0200
7953 #include <linux/nfsd/nfsd.h>
7954 #include <linux/nfsd/xdr.h>
7955 #include <linux/mm.h>
7956 +#include <linux/vs_tag.h>
7958 #define NFSDDBG_FACILITY NFSDDBG_XDR
7960 @@ -97,6 +98,8 @@ static __be32 *
7961 decode_sattr(__be32 *p, struct iattr *iap)
7969 @@ -110,12 +113,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7971 if ((tmp = ntohl(*p++)) != (u32)-1) {
7972 iap->ia_valid |= ATTR_UID;
7973 - iap->ia_uid = tmp;
7976 if ((tmp = ntohl(*p++)) != (u32)-1) {
7977 iap->ia_valid |= ATTR_GID;
7978 - iap->ia_gid = tmp;
7981 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7982 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7983 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7984 if ((tmp = ntohl(*p++)) != (u32)-1) {
7985 iap->ia_valid |= ATTR_SIZE;
7987 @@ -160,8 +166,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7988 *p++ = htonl(nfs_ftypes[type >> 12]);
7989 *p++ = htonl((u32) stat->mode);
7990 *p++ = htonl((u32) stat->nlink);
7991 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7992 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7993 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7994 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7995 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7996 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7998 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7999 *p++ = htonl(NFS_MAXPATHLEN);
8000 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/vfs.c linux-2.6.22.10-vs2.3.0.29/fs/nfsd/vfs.c
8001 --- linux-2.6.22.10/fs/nfsd/vfs.c 2007-10-30 01:57:14 +0100
8002 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/vfs.c 2007-08-11 22:41:51 +0200
8003 @@ -1186,13 +1186,13 @@ nfsd_create(struct svc_rqst *rqstp, stru
8004 host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
8007 - host_err = vfs_mkdir(dirp, dchild, iap->ia_mode);
8008 + host_err = vfs_mkdir(dirp, dchild, iap->ia_mode, NULL);
8014 - host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
8015 + host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev, NULL);
8018 printk("nfsd: bad file type %o in nfsd_create\n", type);
8019 @@ -1466,11 +1466,13 @@ nfsd_symlink(struct svc_rqst *rqstp, str
8021 strncpy(path_alloced, path, plen);
8022 path_alloced[plen] = 0;
8023 - host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
8024 + host_err = vfs_symlink(dentry->d_inode, dnew,
8025 + path_alloced, mode, NULL);
8026 kfree(path_alloced);
8029 - host_err = vfs_symlink(dentry->d_inode, dnew, path, mode);
8030 + host_err = vfs_symlink(dentry->d_inode, dnew,
8031 + path, mode, NULL);
8034 if (EX_ISSYNC(fhp->fh_export))
8035 @@ -1529,7 +1531,7 @@ nfsd_link(struct svc_rqst *rqstp, struct
8036 dold = tfhp->fh_dentry;
8037 dest = dold->d_inode;
8039 - host_err = vfs_link(dold, dirp, dnew);
8040 + host_err = vfs_link(dold, dirp, dnew, NULL);
8042 if (EX_ISSYNC(ffhp->fh_export)) {
8043 err = nfserrno(nfsd_sync_dir(ddir));
8044 @@ -1694,9 +1696,9 @@ nfsd_unlink(struct svc_rqst *rqstp, stru
8048 - host_err = vfs_unlink(dirp, rdentry);
8049 + host_err = vfs_unlink(dirp, rdentry, NULL);
8050 } else { /* It's RMDIR */
8051 - host_err = vfs_rmdir(dirp, rdentry);
8052 + host_err = vfs_rmdir(dirp, rdentry, NULL);
8056 @@ -1807,7 +1809,8 @@ nfsd_permission(struct svc_export *exp,
8058 if (!(acc & MAY_LOCAL_ACCESS))
8059 if (acc & (MAY_WRITE | MAY_SATTR | MAY_TRUNC)) {
8060 - if (EX_RDONLY(exp, rqstp) || IS_RDONLY(inode))
8061 + if (EX_RDONLY(exp, rqstp) || IS_RDONLY(inode)
8062 + || MNT_IS_RDONLY(exp->ex_mnt))
8064 if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE(inode))
8066 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/dlm/dlmfs.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlm/dlmfs.c
8067 --- linux-2.6.22.10/fs/ocfs2/dlm/dlmfs.c 2007-07-09 13:19:28 +0200
8068 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlm/dlmfs.c 2007-08-05 20:53:13 +0200
8070 #include <linux/init.h>
8071 #include <linux/string.h>
8072 #include <linux/backing-dev.h>
8073 +#include <linux/vs_tag.h>
8075 #include <asm/uaccess.h>
8077 @@ -331,6 +332,7 @@ static struct inode *dlmfs_get_root_inod
8078 inode->i_mode = mode;
8079 inode->i_uid = current->fsuid;
8080 inode->i_gid = current->fsgid;
8081 + inode->i_tag = dx_current_fstag(sb);
8082 inode->i_blocks = 0;
8083 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
8084 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
8085 @@ -357,6 +359,7 @@ static struct inode *dlmfs_get_inode(str
8086 inode->i_mode = mode;
8087 inode->i_uid = current->fsuid;
8088 inode->i_gid = current->fsgid;
8089 + inode->i_tag = dx_current_fstag(sb);
8090 inode->i_blocks = 0;
8091 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
8092 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
8093 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/dlmglue.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlmglue.c
8094 --- linux-2.6.22.10/fs/ocfs2/dlmglue.c 2007-07-09 13:19:28 +0200
8095 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlmglue.c 2007-08-05 20:53:13 +0200
8096 @@ -1475,6 +1475,7 @@ static void __ocfs2_stuff_meta_lvb(struc
8097 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
8098 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
8099 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
8100 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
8101 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
8102 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
8103 lvb->lvb_iatime_packed =
8104 @@ -1527,6 +1528,7 @@ static void ocfs2_refresh_inode_from_lvb
8106 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
8107 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
8108 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
8109 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
8110 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
8111 ocfs2_unpack_timespec(&inode->i_atime,
8112 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/dlmglue.h linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlmglue.h
8113 --- linux-2.6.22.10/fs/ocfs2/dlmglue.h 2007-07-09 13:19:28 +0200
8114 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlmglue.h 2007-08-05 20:53:13 +0200
8116 struct ocfs2_meta_lvb {
8119 - __be16 lvb_reserved1;
8121 __be32 lvb_iclusters;
8124 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/file.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/file.c
8125 --- linux-2.6.22.10/fs/ocfs2/file.c 2007-10-30 01:57:14 +0100
8126 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/file.c 2007-09-05 03:06:11 +0200
8127 @@ -943,13 +943,15 @@ int ocfs2_setattr(struct dentry *dentry,
8128 mlog(0, "uid change: %d\n", attr->ia_uid);
8129 if (attr->ia_valid & ATTR_GID)
8130 mlog(0, "gid change: %d\n", attr->ia_gid);
8131 + if (attr->ia_valid & ATTR_TAG)
8132 + mlog(0, "tag change: %d\n", attr->ia_tag);
8133 if (attr->ia_valid & ATTR_SIZE)
8134 mlog(0, "size change...\n");
8135 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
8136 mlog(0, "time change...\n");
8138 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
8139 - | ATTR_GID | ATTR_UID | ATTR_MODE)
8140 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
8141 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
8142 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
8144 @@ -1805,6 +1807,7 @@ bail:
8145 const struct inode_operations ocfs2_file_iops = {
8146 .setattr = ocfs2_setattr,
8147 .getattr = ocfs2_getattr,
8148 + .sync_flags = ocfs2_sync_flags,
8149 .permission = ocfs2_permission,
8152 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/inode.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/inode.c
8153 --- linux-2.6.22.10/fs/ocfs2/inode.c 2007-07-09 13:19:28 +0200
8154 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/inode.c 2007-08-05 20:53:13 +0200
8156 #include <linux/slab.h>
8157 #include <linux/highmem.h>
8158 #include <linux/pagemap.h>
8159 +#include <linux/vs_tag.h>
8161 #include <asm/byteorder.h>
8165 #include "heartbeat.h"
8168 #include "journal.h"
8170 #include "suballoc.h"
8171 @@ -77,6 +79,10 @@ void ocfs2_set_inode_flags(struct inode
8173 if (flags & OCFS2_IMMUTABLE_FL)
8174 inode->i_flags |= S_IMMUTABLE;
8175 + if (flags & OCFS2_IUNLINK_FL)
8176 + inode->i_flags |= S_IUNLINK;
8177 + if (flags & OCFS2_BARRIER_FL)
8178 + inode->i_flags |= S_BARRIER;
8180 if (flags & OCFS2_SYNC_FL)
8181 inode->i_flags |= S_SYNC;
8182 @@ -107,6 +113,27 @@ void ocfs2_get_inode_flags(struct ocfs2_
8183 oi->ip_attr |= OCFS2_DIRSYNC_FL;
8186 +int ocfs2_sync_flags(struct inode *inode)
8188 + unsigned int oldflags, newflags;
8190 + oldflags = OCFS2_I(inode)->ip_flags;
8191 + newflags = oldflags & ~(OCFS2_IMMUTABLE_FL |
8192 + OCFS2_IUNLINK_FL | OCFS2_BARRIER_FL);
8194 + if (IS_IMMUTABLE(inode))
8195 + newflags |= OCFS2_IMMUTABLE_FL;
8196 + if (IS_IUNLINK(inode))
8197 + newflags |= OCFS2_IUNLINK_FL;
8198 + if (IS_BARRIER(inode))
8199 + newflags |= OCFS2_BARRIER_FL;
8201 + if (oldflags ^ newflags)
8202 + return ocfs2_set_inode_attr(inode,
8203 + newflags, OCFS2_FL_MASK);
8207 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags)
8209 struct inode *inode = NULL;
8210 @@ -212,6 +239,8 @@ int ocfs2_populate_inode(struct inode *i
8211 struct super_block *sb;
8212 struct ocfs2_super *osb;
8213 int status = -EINVAL;
8217 mlog_entry("(0x%p, size:%llu)\n", inode,
8218 (unsigned long long)le64_to_cpu(fe->i_size));
8219 @@ -246,8 +275,12 @@ int ocfs2_populate_inode(struct inode *i
8220 inode->i_generation = le32_to_cpu(fe->i_generation);
8221 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
8222 inode->i_mode = le16_to_cpu(fe->i_mode);
8223 - inode->i_uid = le32_to_cpu(fe->i_uid);
8224 - inode->i_gid = le32_to_cpu(fe->i_gid);
8225 + uid = le32_to_cpu(fe->i_uid);
8226 + gid = le32_to_cpu(fe->i_gid);
8227 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8228 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8229 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
8230 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
8232 /* Fast symlinks will have i_size but no allocated clusters. */
8233 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
8234 @@ -1224,8 +1257,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
8236 fe->i_size = cpu_to_le64(i_size_read(inode));
8237 fe->i_links_count = cpu_to_le16(inode->i_nlink);
8238 - fe->i_uid = cpu_to_le32(inode->i_uid);
8239 - fe->i_gid = cpu_to_le32(inode->i_gid);
8240 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
8241 + inode->i_uid, inode->i_tag));
8242 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
8243 + inode->i_gid, inode->i_tag));
8244 + /* i_tag = = cpu_to_le16(inode->i_tag); */
8245 fe->i_mode = cpu_to_le16(inode->i_mode);
8246 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
8247 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
8248 @@ -1253,15 +1289,24 @@ leave:
8249 void ocfs2_refresh_inode(struct inode *inode,
8250 struct ocfs2_dinode *fe)
8255 spin_lock(&OCFS2_I(inode)->ip_lock);
8257 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
8258 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
8259 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
8260 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
8261 ocfs2_set_inode_flags(inode);
8262 i_size_write(inode, le64_to_cpu(fe->i_size));
8263 inode->i_nlink = le16_to_cpu(fe->i_links_count);
8264 - inode->i_uid = le32_to_cpu(fe->i_uid);
8265 - inode->i_gid = le32_to_cpu(fe->i_gid);
8266 + uid = le32_to_cpu(fe->i_uid);
8267 + gid = le32_to_cpu(fe->i_gid);
8268 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8269 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8270 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
8271 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
8272 inode->i_mode = le16_to_cpu(fe->i_mode);
8273 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
8274 inode->i_blocks = 0;
8275 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/inode.h linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/inode.h
8276 --- linux-2.6.22.10/fs/ocfs2/inode.h 2007-07-09 13:19:28 +0200
8277 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/inode.h 2007-08-05 20:53:13 +0200
8278 @@ -142,6 +142,7 @@ int ocfs2_aio_write(struct file *file, s
8280 void ocfs2_set_inode_flags(struct inode *inode);
8281 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
8282 +int ocfs2_sync_flags(struct inode *inode);
8284 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
8286 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ioctl.c
8287 --- linux-2.6.22.10/fs/ocfs2/ioctl.c 2007-07-09 13:19:28 +0200
8288 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ioctl.c 2007-08-05 20:53:13 +0200
8289 @@ -39,7 +39,7 @@ static int ocfs2_get_inode_attr(struct i
8293 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8294 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8297 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
8298 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/ioctl.h linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ioctl.h
8299 --- linux-2.6.22.10/fs/ocfs2/ioctl.h 2007-07-09 13:19:28 +0200
8300 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ioctl.h 2007-08-05 20:53:13 +0200
8302 #ifndef OCFS2_IOCTL_H
8303 #define OCFS2_IOCTL_H
8305 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8308 int ocfs2_ioctl(struct inode * inode, struct file * filp,
8309 unsigned int cmd, unsigned long arg);
8310 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
8311 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/namei.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/namei.c
8312 --- linux-2.6.22.10/fs/ocfs2/namei.c 2007-07-09 13:19:28 +0200
8313 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/namei.c 2007-08-05 20:53:13 +0200
8315 #include <linux/types.h>
8316 #include <linux/slab.h>
8317 #include <linux/highmem.h>
8318 +#include <linux/vs_tag.h>
8320 #define MLOG_MASK_PREFIX ML_NAMEI
8321 #include <cluster/masklog.h>
8322 @@ -483,6 +484,9 @@ static int ocfs2_mknod_locked(struct ocf
8325 struct inode *inode = NULL;
8330 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
8331 (unsigned long)dev, dentry->d_name.len,
8332 @@ -542,13 +546,19 @@ static int ocfs2_mknod_locked(struct ocf
8333 fe->i_blkno = cpu_to_le64(fe_blkno);
8334 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
8335 fe->i_suballoc_slot = cpu_to_le16(osb->slot_num);
8336 - fe->i_uid = cpu_to_le32(current->fsuid);
8338 + tag = dx_current_fstag(osb->sb);
8339 + uid = current->fsuid;
8340 if (dir->i_mode & S_ISGID) {
8341 - fe->i_gid = cpu_to_le32(dir->i_gid);
8346 - fe->i_gid = cpu_to_le32(current->fsgid);
8347 + gid = current->fsgid;
8349 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), uid, tag));
8350 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), gid, tag));
8351 + inode->i_tag = tag;
8352 fe->i_mode = cpu_to_le16(mode);
8353 if (S_ISCHR(mode) || S_ISBLK(mode))
8354 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
8355 @@ -2316,5 +2326,6 @@ const struct inode_operations ocfs2_dir_
8356 .rename = ocfs2_rename,
8357 .setattr = ocfs2_setattr,
8358 .getattr = ocfs2_getattr,
8359 + .sync_flags = ocfs2_sync_flags,
8360 .permission = ocfs2_permission,
8362 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/ocfs2.h linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ocfs2.h
8363 --- linux-2.6.22.10/fs/ocfs2/ocfs2.h 2007-07-09 13:19:28 +0200
8364 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ocfs2.h 2007-08-05 20:53:13 +0200
8365 @@ -170,6 +170,7 @@ enum ocfs2_mount_options
8366 OCFS2_MOUNT_NOINTR = 1 << 2, /* Don't catch signals */
8367 OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */
8368 OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */
8369 + OCFS2_MOUNT_TAGGED = 1 << 8, /* use tagging */
8372 #define OCFS2_OSB_SOFT_RO 0x0001
8373 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/ocfs2_fs.h linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ocfs2_fs.h
8374 --- linux-2.6.22.10/fs/ocfs2/ocfs2_fs.h 2007-07-09 13:19:28 +0200
8375 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ocfs2_fs.h 2007-08-05 20:53:13 +0200
8376 @@ -152,8 +152,12 @@
8377 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
8378 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
8380 +#define OCFS2_BARRIER_FL (0x04000000) /* Barrier for chroot() */
8381 +#define OCFS2_IUNLINK_FL (0x08000000) /* Immutable unlink */
8383 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
8384 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
8385 +#define OCFS2_FL_MASK (0x0F0100FF)
8388 * Extent record flags (e_node.leaf.flags)
8389 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/super.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/super.c
8390 --- linux-2.6.22.10/fs/ocfs2/super.c 2007-07-09 13:19:28 +0200
8391 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/super.c 2007-08-05 20:53:13 +0200
8392 @@ -140,6 +140,7 @@ enum {
8396 + Opt_tag, Opt_notag, Opt_tagid,
8400 @@ -154,6 +155,9 @@ static match_table_t tokens = {
8401 {Opt_data_ordered, "data=ordered"},
8402 {Opt_data_writeback, "data=writeback"},
8403 {Opt_atime_quantum, "atime_quantum=%u"},
8405 + {Opt_notag, "notag"},
8406 + {Opt_tagid, "tagid=%u"},
8410 @@ -362,6 +366,13 @@ static int ocfs2_remount(struct super_bl
8414 + if ((parsed_options & OCFS2_MOUNT_TAGGED) &&
8415 + !(sb->s_flags & MS_TAGGED)) {
8417 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
8421 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
8422 (parsed_options & OCFS2_MOUNT_HB_LOCAL)) {
8424 @@ -654,6 +665,9 @@ static int ocfs2_fill_super(struct super
8426 ocfs2_complete_mount_recovery(osb);
8428 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
8429 + sb->s_flags |= MS_TAGGED;
8431 if (ocfs2_mount_local(osb))
8432 snprintf(nodestr, sizeof(nodestr), "local");
8434 @@ -782,6 +796,20 @@ static int ocfs2_parse_options(struct su
8436 osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
8438 +#ifndef CONFIG_TAGGING_NONE
8440 + *mount_opt |= OCFS2_MOUNT_TAGGED;
8443 + *mount_opt &= ~OCFS2_MOUNT_TAGGED;
8446 +#ifdef CONFIG_PROPAGATE
8449 + *mount_opt |= OCFS2_MOUNT_TAGGED;
8454 "Unrecognized mount option \"%s\" "
8455 diff -NurpP --minimal linux-2.6.22.10/fs/open.c linux-2.6.22.10-vs2.3.0.29/fs/open.c
8456 --- linux-2.6.22.10/fs/open.c 2007-07-09 13:19:28 +0200
8457 +++ linux-2.6.22.10-vs2.3.0.29/fs/open.c 2007-08-05 20:53:13 +0200
8459 #include <linux/syscalls.h>
8460 #include <linux/rcupdate.h>
8461 #include <linux/audit.h>
8462 +#include <linux/vs_base.h>
8463 +#include <linux/vs_limit.h>
8464 +#include <linux/vs_dlimit.h>
8465 +#include <linux/vs_tag.h>
8466 +#include <linux/vs_cowbl.h>
8468 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
8470 int retval = -ENODEV;
8473 + struct super_block *sb = dentry->d_sb;
8476 - if (dentry->d_sb->s_op->statfs) {
8477 + if (sb->s_op->statfs) {
8478 memset(buf, 0, sizeof(*buf));
8479 retval = security_sb_statfs(dentry);
8482 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
8483 + retval = sb->s_op->statfs(dentry, buf);
8484 if (retval == 0 && buf->f_frsize == 0)
8485 buf->f_frsize = buf->f_bsize;
8487 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
8488 + vx_vsi_statfs(sb, buf);
8492 @@ -248,7 +257,7 @@ static long do_sys_truncate(const char _
8496 - if (IS_RDONLY(inode))
8497 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
8501 @@ -397,7 +406,7 @@ asmlinkage long sys_faccessat(int dfd, c
8502 special_file(nd.dentry->d_inode->i_mode))
8503 goto out_path_release;
8505 - if(IS_RDONLY(nd.dentry->d_inode))
8506 + if(IS_RDONLY(nd.dentry->d_inode) || MNT_IS_RDONLY(nd.mnt))
8510 @@ -511,7 +520,7 @@ asmlinkage long sys_fchmod(unsigned int
8511 audit_inode(NULL, inode);
8514 - if (IS_RDONLY(inode))
8515 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(file->f_vfsmnt))
8518 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8519 @@ -541,11 +550,11 @@ asmlinkage long sys_fchmodat(int dfd, co
8520 error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
8523 - inode = nd.dentry->d_inode;
8526 - if (IS_RDONLY(inode))
8527 + error = cow_check_and_break(&nd);
8530 + inode = nd.dentry->d_inode;
8533 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8534 @@ -570,7 +579,8 @@ asmlinkage long sys_chmod(const char __u
8535 return sys_fchmodat(AT_FDCWD, filename, mode);
8538 -static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
8539 +static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
8540 + uid_t user, gid_t group)
8542 struct inode * inode;
8544 @@ -582,7 +592,7 @@ static int chown_common(struct dentry *
8548 - if (IS_RDONLY(inode))
8549 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
8552 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8553 @@ -590,11 +600,11 @@ static int chown_common(struct dentry *
8554 newattrs.ia_valid = ATTR_CTIME;
8555 if (user != (uid_t) -1) {
8556 newattrs.ia_valid |= ATTR_UID;
8557 - newattrs.ia_uid = user;
8558 + newattrs.ia_uid = dx_map_uid(user);
8560 if (group != (gid_t) -1) {
8561 newattrs.ia_valid |= ATTR_GID;
8562 - newattrs.ia_gid = group;
8563 + newattrs.ia_gid = dx_map_gid(group);
8565 if (!S_ISDIR(inode->i_mode))
8566 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
8567 @@ -613,7 +623,11 @@ asmlinkage long sys_chown(const char __u
8568 error = user_path_walk(filename, &nd);
8571 - error = chown_common(nd.dentry, user, group);
8572 +#ifdef CONFIG_VSERVER_COWBL
8573 + error = cow_check_and_break(&nd);
8576 + error = chown_common(nd.dentry, nd.mnt, user, group);
8580 @@ -633,7 +647,11 @@ asmlinkage long sys_fchownat(int dfd, co
8581 error = __user_walk_fd(dfd, filename, follow, &nd);
8584 - error = chown_common(nd.dentry, user, group);
8585 +#ifdef CONFIG_VSERVER_COWBL
8586 + error = cow_check_and_break(&nd);
8589 + error = chown_common(nd.dentry, nd.mnt, user, group);
8593 @@ -647,7 +665,11 @@ asmlinkage long sys_lchown(const char __
8594 error = user_path_walk_link(filename, &nd);
8597 - error = chown_common(nd.dentry, user, group);
8598 +#ifdef CONFIG_VSERVER_COWBL
8599 + error = cow_check_and_break(&nd);
8602 + error = chown_common(nd.dentry, nd.mnt, user, group);
8606 @@ -666,7 +688,7 @@ asmlinkage long sys_fchown(unsigned int
8608 dentry = file->f_path.dentry;
8609 audit_inode(NULL, dentry->d_inode);
8610 - error = chown_common(dentry, user, group);
8611 + error = chown_common(dentry, file->f_vfsmnt, user, group);
8615 @@ -893,6 +915,7 @@ repeat:
8616 FD_SET(fd, fdt->open_fds);
8617 FD_CLR(fd, fdt->close_on_exec);
8618 files->next_fd = fd + 1;
8619 + vx_openfd_inc(fd);
8622 if (fdt->fd[fd] != NULL) {
8623 @@ -915,6 +938,7 @@ static void __put_unused_fd(struct files
8624 __FD_CLR(fd, fdt->open_fds);
8625 if (fd < files->next_fd)
8626 files->next_fd = fd;
8627 + vx_openfd_dec(fd);
8630 void fastcall put_unused_fd(unsigned int fd)
8631 diff -NurpP --minimal linux-2.6.22.10/fs/proc/array.c linux-2.6.22.10-vs2.3.0.29/fs/proc/array.c
8632 --- linux-2.6.22.10/fs/proc/array.c 2007-07-09 13:19:28 +0200
8633 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/array.c 2007-10-05 15:07:22 +0200
8635 #include <linux/cpuset.h>
8636 #include <linux/rcupdate.h>
8637 #include <linux/delayacct.h>
8638 +#include <linux/vs_context.h>
8639 +#include <linux/vs_network.h>
8641 #include <asm/uaccess.h>
8642 #include <asm/pgtable.h>
8643 @@ -134,8 +136,9 @@ static const char *task_state_array[] =
8644 "D (disk sleep)", /* 2 */
8645 "T (stopped)", /* 4 */
8646 "T (tracing stop)", /* 8 */
8647 - "Z (zombie)", /* 16 */
8648 - "X (dead)" /* 32 */
8649 + "H (on hold)", /* 16 */
8650 + "Z (zombie)", /* 32 */
8651 + "X (dead)", /* 64 */
8654 static inline const char * get_task_state(struct task_struct *tsk)
8655 @@ -144,7 +147,8 @@ static inline const char * get_task_stat
8656 TASK_INTERRUPTIBLE |
8657 TASK_UNINTERRUPTIBLE |
8662 (tsk->exit_state & (EXIT_ZOMBIE |
8664 const char **p = &task_state_array[0];
8665 @@ -161,8 +165,16 @@ static inline char * task_state(struct t
8666 struct group_info *group_info;
8668 struct fdtable *fdt = NULL;
8669 + pid_t pid, ptgid, tppid, tgid;
8672 + tgid = vx_map_tgid(p->tgid);
8673 + pid = vx_map_pid(p->pid);
8674 + ptgid = vx_map_pid(pid_alive(p) ?
8675 + rcu_dereference(p->real_parent)->tgid : 0);
8676 + tppid = vx_map_pid(pid_alive(p) && p->ptrace ?
8677 + rcu_dereference(p->parent)->pid : 0);
8679 buffer += sprintf(buffer,
8681 "SleepAVG:\t%lu%%\n"
8682 @@ -174,9 +186,7 @@ static inline char * task_state(struct t
8683 "Gid:\t%d\t%d\t%d\t%d\n",
8685 (p->sleep_avg/1024)*100/(1020000000/1024),
8687 - pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0,
8688 - pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0,
8689 + tgid, pid, (pid > 1) ? ptgid : 0, tppid,
8690 p->uid, p->euid, p->suid, p->fsuid,
8691 p->gid, p->egid, p->sgid, p->fsgid);
8693 @@ -283,12 +293,15 @@ static inline char * task_sig(struct tas
8695 static inline char *task_cap(struct task_struct *p, char *buffer)
8697 - return buffer + sprintf(buffer, "CapInh:\t%016x\n"
8698 - "CapPrm:\t%016x\n"
8699 - "CapEff:\t%016x\n",
8700 - cap_t(p->cap_inheritable),
8701 - cap_t(p->cap_permitted),
8702 - cap_t(p->cap_effective));
8703 + struct vx_info *vxi = p->vx_info;
8705 + return buffer + sprintf(buffer,
8706 + "CapInh:\t%016x\n"
8707 + "CapPrm:\t%016x\n"
8708 + "CapEff:\t%016x\n",
8709 + (unsigned)vx_info_mbcap(vxi, p->cap_inheritable),
8710 + (unsigned)vx_info_mbcap(vxi, p->cap_permitted),
8711 + (unsigned)vx_info_mbcap(vxi, p->cap_effective));
8714 int proc_pid_status(struct task_struct *task, char * buffer)
8715 @@ -306,6 +319,12 @@ int proc_pid_status(struct task_struct *
8716 buffer = task_sig(task, buffer);
8717 buffer = task_cap(task, buffer);
8718 buffer = cpuset_task_status_allowed(task, buffer);
8720 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8722 + buffer += sprintf (buffer,"VxID: %d\n", vx_task_xid(task));
8723 + buffer += sprintf (buffer,"NxID: %d\n", nx_task_nid(task));
8725 #if defined(CONFIG_S390)
8726 buffer = task_show_regs(task, buffer);
8728 @@ -320,7 +339,7 @@ static int do_task_stat(struct task_stru
8729 sigset_t sigign, sigcatch;
8732 - pid_t ppid = 0, pgid = -1, sid = -1;
8733 + pid_t pid = 0, ppid = 0, pgid = -1, sid = -1;
8734 int num_threads = 0;
8735 struct mm_struct *mm;
8736 unsigned long long start_time;
8737 @@ -382,8 +401,10 @@ static int do_task_stat(struct task_stru
8740 sid = signal_session(sig);
8741 - pgid = process_group(task);
8742 - ppid = rcu_dereference(task->real_parent)->tgid;
8743 + pid = vx_info_map_pid(task->vx_info, task->pid);
8744 + pgid = vx_info_map_pid(task->vx_info, process_group(task));
8745 + ppid = (pid > 1) ? vx_info_map_tgid(task->vx_info,
8746 + rcu_dereference(task->real_parent)->tgid) : 0;
8748 unlock_task_sighand(task, &flags);
8750 @@ -410,10 +431,21 @@ static int do_task_stat(struct task_stru
8751 /* convert nsec -> ticks */
8752 start_time = nsec_to_clock_t(start_time);
8754 + /* fixup start time for virt uptime */
8755 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8756 + unsigned long long bias =
8757 + current->vx_info->cvirt.bias_clock;
8759 + if (start_time > bias)
8760 + start_time -= bias;
8765 res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %u %lu \
8766 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8767 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu\n",
8773 diff -NurpP --minimal linux-2.6.22.10/fs/proc/base.c linux-2.6.22.10-vs2.3.0.29/fs/proc/base.c
8774 --- linux-2.6.22.10/fs/proc/base.c 2007-07-09 13:19:28 +0200
8775 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/base.c 2007-09-05 02:49:29 +0200
8777 #include <linux/poll.h>
8778 #include <linux/nsproxy.h>
8779 #include <linux/oom.h>
8780 +#include <linux/vs_context.h>
8781 +#include <linux/vs_network.h>
8783 #include "internal.h"
8786 @@ -1049,6 +1052,8 @@ static struct inode *proc_pid_make_inode
8787 inode->i_uid = task->euid;
8788 inode->i_gid = task->egid;
8790 + /* procfs is xid tagged */
8791 + inode->i_tag = (tag_t)vx_task_xid(task);
8792 security_task_to_inode(task, inode);
8795 @@ -1082,6 +1087,8 @@ static int pid_getattr(struct vfsmount *
8799 +static unsigned name_to_int(struct dentry *dentry);
8802 * Exceptional case: normally we are not allowed to unhash a busy
8803 * directory. In this case, however, we can do it - no aliasing problems
8804 @@ -1102,6 +1109,12 @@ static int pid_revalidate(struct dentry
8805 struct inode *inode = dentry->d_inode;
8806 struct task_struct *task = get_proc_task(inode);
8808 + unsigned pid = name_to_int(dentry);
8809 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
8810 + put_task_struct(task);
8814 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
8815 task_dumpable(task)) {
8816 inode->i_uid = task->euid;
8817 @@ -1115,6 +1128,7 @@ static int pid_revalidate(struct dentry
8818 put_task_struct(task);
8825 @@ -1595,6 +1609,13 @@ static struct dentry *proc_pident_lookup
8829 + /* TODO: maybe we can come up with a generic approach? */
8830 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8831 + (dentry->d_name.len == 5) &&
8832 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8833 + !memcmp(dentry->d_name.name, "ninfo", 5)))
8837 * Yes, it does not scale. And it should not. Don't add
8838 * new entries into /proc/<tgid>/ without very good reasons.
8839 @@ -1790,14 +1811,14 @@ static int proc_self_readlink(struct den
8842 char tmp[PROC_NUMBUF];
8843 - sprintf(tmp, "%d", current->tgid);
8844 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
8845 return vfs_readlink(dentry,buffer,buflen,tmp);
8848 static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
8850 char tmp[PROC_NUMBUF];
8851 - sprintf(tmp, "%d", current->tgid);
8852 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
8853 return ERR_PTR(vfs_follow_link(nd,tmp));
8856 @@ -1891,7 +1912,7 @@ out_iput:
8857 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8859 struct dentry *error;
8860 - struct task_struct *task = get_proc_task(dir);
8861 + struct task_struct *task = get_proc_task_real(dir);
8862 const struct pid_entry *p, *last;
8864 error = ERR_PTR(-ENOENT);
8865 @@ -1956,6 +1977,9 @@ static int proc_pid_io_accounting(struct
8866 static const struct file_operations proc_task_operations;
8867 static const struct inode_operations proc_task_inode_operations;
8869 +extern int proc_pid_vx_info(struct task_struct *, char *);
8870 +extern int proc_pid_nx_info(struct task_struct *, char *);
8872 static const struct pid_entry tgid_base_stuff[] = {
8873 DIR("task", S_IRUGO|S_IXUGO, task),
8874 DIR("fd", S_IRUSR|S_IXUSR, fd),
8875 @@ -1995,6 +2019,8 @@ static const struct pid_entry tgid_base_
8876 #ifdef CONFIG_CPUSETS
8877 REG("cpuset", S_IRUGO, cpuset),
8879 + INF("vinfo", S_IRUGO, pid_vx_info),
8880 + INF("ninfo", S_IRUGO, pid_nx_info),
8881 INF("oom_score", S_IRUGO, oom_score),
8882 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust),
8883 #ifdef CONFIG_AUDITSYSCALL
8884 @@ -2141,9 +2167,11 @@ struct dentry *proc_pid_lookup(struct in
8885 tgid = name_to_int(dentry);
8888 + if (vx_current_initpid(tgid))
8892 - task = find_task_by_pid(tgid);
8893 + task = vx_find_proc_task_by_pid(tgid);
8895 get_task_struct(task);
8897 @@ -2198,7 +2226,7 @@ static int proc_pid_fill_cache(struct fi
8898 struct task_struct *task, int tgid)
8900 char name[PROC_NUMBUF];
8901 - int len = snprintf(name, sizeof(name), "%d", tgid);
8902 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(tgid));
8903 return proc_fill_cache(filp, dirent, filldir, name, len,
8904 proc_pid_instantiate, task, NULL);
8906 @@ -2207,7 +2235,7 @@ static int proc_pid_fill_cache(struct fi
8907 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
8909 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8910 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
8911 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8912 struct task_struct *task;
8915 @@ -2226,6 +2254,8 @@ int proc_pid_readdir(struct file * filp,
8916 put_task_struct(task), task = next_tgid(tgid + 1)) {
8918 filp->f_pos = tgid + TGID_OFFSET;
8919 + if (!vx_proc_task_visible(task))
8921 if (proc_pid_fill_cache(filp, dirent, filldir, task, tgid) < 0) {
8922 put_task_struct(task);
8924 @@ -2352,9 +2382,11 @@ static struct dentry *proc_task_lookup(s
8925 tid = name_to_int(dentry);
8928 + if (vx_current_initpid(tid))
8932 - task = find_task_by_pid(tid);
8933 + task = vx_find_proc_task_by_pid(tid);
8935 get_task_struct(task);
8937 @@ -2499,7 +2531,7 @@ static int proc_task_readdir(struct file
8938 for (task = first_tid(leader, tid, pos - 2);
8940 task = next_tid(task), pos++) {
8942 + tid = vx_map_pid(task->pid);
8943 if (proc_task_fill_cache(filp, dirent, filldir, task, tid) < 0) {
8944 /* returning this tgid failed, save it as the first
8945 * pid for the next readir call */
8946 diff -NurpP --minimal linux-2.6.22.10/fs/proc/generic.c linux-2.6.22.10-vs2.3.0.29/fs/proc/generic.c
8947 --- linux-2.6.22.10/fs/proc/generic.c 2007-07-09 13:19:28 +0200
8948 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/generic.c 2007-08-05 20:53:13 +0200
8950 #include <linux/namei.h>
8951 #include <linux/bitops.h>
8952 #include <linux/spinlock.h>
8953 +#include <linux/vserver/inode.h>
8954 #include <asm/uaccess.h>
8956 #include "internal.h"
8957 @@ -395,6 +396,8 @@ struct dentry *proc_lookup(struct inode
8958 for (de = de->subdir; de ; de = de->next) {
8959 if (de->namelen != dentry->d_name.len)
8961 + if (!vx_hide_check(0, de->vx_flags))
8963 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
8964 unsigned int ino = de->low_ino;
8966 @@ -402,6 +405,8 @@ struct dentry *proc_lookup(struct inode
8967 spin_unlock(&proc_subdir_lock);
8969 inode = proc_get_inode(dir->i_sb, ino, de);
8970 + /* generic proc entries belong to the host */
8972 spin_lock(&proc_subdir_lock);
8975 @@ -482,6 +487,8 @@ int proc_readdir(struct file * filp,
8977 /* filldir passes info to user space */
8979 + if (!vx_hide_check(0, de->vx_flags))
8981 spin_unlock(&proc_subdir_lock);
8982 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8983 de->low_ino, de->mode >> 12) < 0) {
8984 @@ -489,6 +496,7 @@ int proc_readdir(struct file * filp,
8987 spin_lock(&proc_subdir_lock);
8992 @@ -613,6 +621,7 @@ static struct proc_dir_entry *proc_creat
8996 + ent->vx_flags = IATTR_PROC_DEFAULT;
9000 @@ -633,7 +642,8 @@ struct proc_dir_entry *proc_symlink(cons
9006 + ent->vx_flags = IATTR_PROC_SYMLINK;
9010 diff -NurpP --minimal linux-2.6.22.10/fs/proc/inode.c linux-2.6.22.10-vs2.3.0.29/fs/proc/inode.c
9011 --- linux-2.6.22.10/fs/proc/inode.c 2007-07-09 13:19:28 +0200
9012 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/inode.c 2007-08-05 20:53:13 +0200
9013 @@ -160,6 +160,8 @@ struct inode *proc_get_inode(struct supe
9014 inode->i_uid = de->uid;
9015 inode->i_gid = de->gid;
9018 + PROC_I(inode)->vx_flags = de->vx_flags;
9020 inode->i_size = de->size;
9022 diff -NurpP --minimal linux-2.6.22.10/fs/proc/internal.h linux-2.6.22.10-vs2.3.0.29/fs/proc/internal.h
9023 --- linux-2.6.22.10/fs/proc/internal.h 2007-07-09 13:19:28 +0200
9024 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/internal.h 2007-08-05 20:53:13 +0200
9028 #include <linux/proc_fs.h>
9029 +#include <linux/vs_pid.h>
9031 #ifdef CONFIG_PROC_SYSCTL
9032 extern int proc_sys_init(void);
9033 @@ -64,11 +65,16 @@ static inline struct pid *proc_pid(struc
9034 return PROC_I(inode)->pid;
9037 -static inline struct task_struct *get_proc_task(struct inode *inode)
9038 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
9040 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
9043 +static inline struct task_struct *get_proc_task(struct inode *inode)
9045 + return vx_get_proc_task(inode, proc_pid(inode));
9048 static inline int proc_fd(struct inode *inode)
9050 return PROC_I(inode)->fd;
9051 diff -NurpP --minimal linux-2.6.22.10/fs/proc/proc_misc.c linux-2.6.22.10-vs2.3.0.29/fs/proc/proc_misc.c
9052 --- linux-2.6.22.10/fs/proc/proc_misc.c 2007-07-09 13:19:28 +0200
9053 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/proc_misc.c 2007-08-05 20:53:13 +0200
9055 #include <asm/div64.h>
9056 #include "internal.h"
9058 +#include <linux/vs_cvirt.h>
9060 #define LOAD_INT(x) ((x) >> FSHIFT)
9061 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
9063 @@ -82,17 +84,32 @@ static int proc_calc_metrics(char *page,
9064 static int loadavg_read_proc(char *page, char **start, off_t off,
9065 int count, int *eof, void *data)
9067 + unsigned int running, threads;
9071 - a = avenrun[0] + (FIXED_1/200);
9072 - b = avenrun[1] + (FIXED_1/200);
9073 - c = avenrun[2] + (FIXED_1/200);
9074 - len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
9075 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
9076 + struct vx_info *vxi = current->vx_info;
9078 + a = vxi->cvirt.load[0] + (FIXED_1/200);
9079 + b = vxi->cvirt.load[1] + (FIXED_1/200);
9080 + c = vxi->cvirt.load[2] + (FIXED_1/200);
9082 + running = atomic_read(&vxi->cvirt.nr_running);
9083 + threads = atomic_read(&vxi->cvirt.nr_threads);
9085 + a = avenrun[0] + (FIXED_1/200);
9086 + b = avenrun[1] + (FIXED_1/200);
9087 + c = avenrun[2] + (FIXED_1/200);
9089 + running = nr_running();
9090 + threads = nr_threads;
9092 + len = sprintf(page,"%d.%02d %d.%02d %d.%02d %d/%d %d\n",
9093 LOAD_INT(a), LOAD_FRAC(a),
9094 LOAD_INT(b), LOAD_FRAC(b),
9095 LOAD_INT(c), LOAD_FRAC(c),
9096 - nr_running(), nr_threads, current->nsproxy->pid_ns->last_pid);
9097 + running, threads, current->nsproxy->pid_ns->last_pid);
9098 return proc_calc_metrics(page, start, off, count, eof, len);
9101 @@ -106,6 +123,9 @@ static int uptime_read_proc(char *page,
9103 do_posix_clock_monotonic_gettime(&uptime);
9104 cputime_to_timespec(idletime, &idle);
9105 + if (vx_flags(VXF_VIRT_UPTIME, 0))
9106 + vx_vsi_uptime(&uptime, &idle);
9108 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
9109 (unsigned long) uptime.tv_sec,
9110 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
9111 @@ -137,7 +157,7 @@ static int meminfo_read_proc(char *page,
9113 cached = global_page_state(NR_FILE_PAGES) -
9114 total_swapcache_pages - i.bufferram;
9116 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
9119 get_vmalloc_info(&vmi);
9120 diff -NurpP --minimal linux-2.6.22.10/fs/proc/root.c linux-2.6.22.10-vs2.3.0.29/fs/proc/root.c
9121 --- linux-2.6.22.10/fs/proc/root.c 2007-05-02 19:25:21 +0200
9122 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/root.c 2007-08-05 20:53:13 +0200
9124 #include "internal.h"
9126 struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
9127 +struct proc_dir_entry *proc_virtual;
9129 +extern void proc_vx_init(void);
9131 static int proc_get_sb(struct file_system_type *fs_type,
9132 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
9133 @@ -79,6 +82,7 @@ void __init proc_root_init(void)
9134 proc_device_tree_init();
9136 proc_bus = proc_mkdir("bus", NULL);
9141 diff -NurpP --minimal linux-2.6.22.10/fs/quota.c linux-2.6.22.10-vs2.3.0.29/fs/quota.c
9142 --- linux-2.6.22.10/fs/quota.c 2007-07-09 13:19:28 +0200
9143 +++ linux-2.6.22.10-vs2.3.0.29/fs/quota.c 2007-08-05 20:53:13 +0200
9145 #include <linux/buffer_head.h>
9146 #include <linux/capability.h>
9147 #include <linux/quotaops.h>
9148 +#include <linux/vs_context.h>
9150 /* Check validity of generic quotactl commands */
9151 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
9152 @@ -80,11 +81,11 @@ static int generic_quotactl_valid(struct
9153 if (cmd == Q_GETQUOTA) {
9154 if (((type == USRQUOTA && current->euid != id) ||
9155 (type == GRPQUOTA && !in_egroup_p(id))) &&
9156 - !capable(CAP_SYS_ADMIN))
9157 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9160 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
9161 - if (!capable(CAP_SYS_ADMIN))
9162 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9166 @@ -131,10 +132,10 @@ static int xqm_quotactl_valid(struct sup
9167 if (cmd == Q_XGETQUOTA) {
9168 if (((type == XQM_USRQUOTA && current->euid != id) ||
9169 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
9170 - !capable(CAP_SYS_ADMIN))
9171 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9173 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
9174 - if (!capable(CAP_SYS_ADMIN))
9175 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9179 @@ -327,6 +328,46 @@ static int do_quotactl(struct super_bloc
9183 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
9185 +#include <linux/vroot.h>
9186 +#include <linux/major.h>
9187 +#include <linux/module.h>
9188 +#include <linux/kallsyms.h>
9189 +#include <linux/vserver/debug.h>
9191 +static vroot_grb_func *vroot_get_real_bdev = NULL;
9193 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
9195 +int register_vroot_grb(vroot_grb_func *func) {
9198 + spin_lock(&vroot_grb_lock);
9199 + if (!vroot_get_real_bdev) {
9200 + vroot_get_real_bdev = func;
9203 + spin_unlock(&vroot_grb_lock);
9206 +EXPORT_SYMBOL(register_vroot_grb);
9208 +int unregister_vroot_grb(vroot_grb_func *func) {
9209 + int ret = -EINVAL;
9211 + spin_lock(&vroot_grb_lock);
9212 + if (vroot_get_real_bdev) {
9213 + vroot_get_real_bdev = NULL;
9216 + spin_unlock(&vroot_grb_lock);
9219 +EXPORT_SYMBOL(unregister_vroot_grb);
9224 * look up a superblock on which quota ops will be performed
9225 * - use the name of a block device to find the superblock thereon
9226 @@ -344,6 +385,22 @@ static inline struct super_block *quotac
9229 return ERR_PTR(PTR_ERR(bdev));
9230 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
9231 + if (bdev && bdev->bd_inode &&
9232 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
9233 + struct block_device *bdnew = (void *)-EINVAL;
9235 + if (vroot_get_real_bdev)
9236 + bdnew = vroot_get_real_bdev(bdev);
9238 + vxdprintk(VXD_CBIT(misc, 0),
9239 + "vroot_get_real_bdev not set");
9241 + if (IS_ERR(bdnew))
9242 + return ERR_PTR(PTR_ERR(bdnew));
9246 sb = get_super(bdev);
9249 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/bitmap.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/bitmap.c
9250 --- linux-2.6.22.10/fs/reiserfs/bitmap.c 2007-02-06 03:01:29 +0100
9251 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/bitmap.c 2007-10-05 15:07:22 +0200
9253 #include <linux/reiserfs_fs_sb.h>
9254 #include <linux/reiserfs_fs_i.h>
9255 #include <linux/quotaops.h>
9256 +#include <linux/vs_dlimit.h>
9258 #define PREALLOCATION_SIZE 9
9260 @@ -425,8 +426,10 @@ static void _reiserfs_free_block(struct
9261 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
9263 journal_mark_dirty(th, s, sbh);
9264 - if (for_unformatted)
9265 + if (for_unformatted) {
9266 + DLIMIT_FREE_BLOCK(inode, 1);
9267 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
9271 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
9272 @@ -1034,6 +1037,7 @@ static inline int blocknrs_and_prealloc_
9273 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
9275 int nr_allocated = 0;
9278 determine_prealloc_size(hint);
9279 if (!hint->formatted_node) {
9280 @@ -1043,19 +1047,30 @@ static inline int blocknrs_and_prealloc_
9281 "reiserquota: allocating %d blocks id=%u",
9282 amount_needed, hint->inode->i_uid);
9285 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
9286 - if (quota_ret) /* Quota exceeded? */
9287 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
9290 return QUOTA_EXCEEDED;
9291 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
9292 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
9294 + return NO_DISK_SPACE;
9297 if (hint->preallocate && hint->prealloc_size) {
9298 #ifdef REISERQUOTA_DEBUG
9299 reiserfs_debug(s, REISERFS_DEBUG_CODE,
9300 "reiserquota: allocating (prealloc) %d blocks id=%u",
9301 hint->prealloc_size, hint->inode->i_uid);
9304 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
9305 - hint->prealloc_size);
9306 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
9307 + hint->prealloc_size);
9309 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
9310 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
9311 + hint->prealloc_size);
9315 hint->preallocate = hint->prealloc_size = 0;
9317 @@ -1087,7 +1102,10 @@ static inline int blocknrs_and_prealloc_
9319 hint->inode->i_uid);
9321 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
9322 + /* Free not allocated blocks */
9323 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
9324 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
9325 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
9327 while (nr_allocated--)
9328 reiserfs_free_block(hint->th, hint->inode,
9329 @@ -1118,10 +1136,10 @@ static inline int blocknrs_and_prealloc_
9330 REISERFS_I(hint->inode)->i_prealloc_count,
9331 hint->inode->i_uid);
9333 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
9334 - hint->prealloc_size - nr_allocated -
9335 - REISERFS_I(hint->inode)->
9336 - i_prealloc_count);
9337 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
9338 + REISERFS_I(hint->inode)->i_prealloc_count;
9339 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
9340 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
9344 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/file.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/file.c
9345 --- linux-2.6.22.10/fs/reiserfs/file.c 2007-07-09 13:19:28 +0200
9346 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/file.c 2007-09-12 20:04:16 +0200
9347 @@ -1546,4 +1546,5 @@ const struct inode_operations reiserfs_f
9348 .listxattr = reiserfs_listxattr,
9349 .removexattr = reiserfs_removexattr,
9350 .permission = reiserfs_permission,
9351 + .sync_flags = reiserfs_sync_flags,
9353 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/inode.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/inode.c
9354 --- linux-2.6.22.10/fs/reiserfs/inode.c 2007-07-09 13:19:28 +0200
9355 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/inode.c 2007-08-05 20:53:13 +0200
9357 #include <linux/mpage.h>
9358 #include <linux/writeback.h>
9359 #include <linux/quotaops.h>
9360 +#include <linux/vs_dlimit.h>
9361 +#include <linux/vs_tag.h>
9363 static int reiserfs_commit_write(struct file *f, struct page *page,
9364 unsigned from, unsigned to);
9365 @@ -50,6 +52,7 @@ void reiserfs_delete_inode(struct inode
9366 * stat data deletion */
9368 DQUOT_FREE_INODE(inode);
9369 + DLIMIT_FREE_INODE(inode);
9371 if (journal_end(&th, inode->i_sb, jbegin_count))
9373 @@ -1112,6 +1115,8 @@ static void init_inode(struct inode *ino
9374 struct buffer_head *bh;
9375 struct item_head *ih;
9379 //int version = ITEM_VERSION_1;
9381 bh = PATH_PLAST_BUFFER(path);
9382 @@ -1135,12 +1140,13 @@ static void init_inode(struct inode *ino
9383 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
9384 unsigned long blocks;
9386 + uid = sd_v1_uid(sd);
9387 + gid = sd_v1_gid(sd);
9389 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
9390 set_inode_sd_version(inode, STAT_DATA_V1);
9391 inode->i_mode = sd_v1_mode(sd);
9392 inode->i_nlink = sd_v1_nlink(sd);
9393 - inode->i_uid = sd_v1_uid(sd);
9394 - inode->i_gid = sd_v1_gid(sd);
9395 inode->i_size = sd_v1_size(sd);
9396 inode->i_atime.tv_sec = sd_v1_atime(sd);
9397 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
9398 @@ -1182,11 +1188,12 @@ static void init_inode(struct inode *ino
9399 // (directories and symlinks)
9400 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
9402 + uid = sd_v2_uid(sd);
9403 + gid = sd_v2_gid(sd);
9405 inode->i_mode = sd_v2_mode(sd);
9406 inode->i_nlink = sd_v2_nlink(sd);
9407 - inode->i_uid = sd_v2_uid(sd);
9408 inode->i_size = sd_v2_size(sd);
9409 - inode->i_gid = sd_v2_gid(sd);
9410 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
9411 inode->i_atime.tv_sec = sd_v2_atime(sd);
9412 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
9413 @@ -1216,6 +1223,10 @@ static void init_inode(struct inode *ino
9414 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
9417 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
9418 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
9419 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
9422 if (S_ISREG(inode->i_mode)) {
9423 inode->i_op = &reiserfs_file_inode_operations;
9424 @@ -1238,13 +1249,15 @@ static void init_inode(struct inode *ino
9425 static void inode2sd(void *sd, struct inode *inode, loff_t size)
9427 struct stat_data *sd_v2 = (struct stat_data *)sd;
9428 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
9429 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
9432 + set_sd_v2_uid(sd_v2, uid);
9433 + set_sd_v2_gid(sd_v2, gid);
9434 set_sd_v2_mode(sd_v2, inode->i_mode);
9435 set_sd_v2_nlink(sd_v2, inode->i_nlink);
9436 - set_sd_v2_uid(sd_v2, inode->i_uid);
9437 set_sd_v2_size(sd_v2, size);
9438 - set_sd_v2_gid(sd_v2, inode->i_gid);
9439 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
9440 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
9441 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
9442 @@ -1775,6 +1788,10 @@ int reiserfs_new_inode(struct reiserfs_t
9444 BUG_ON(!th->t_trans_id);
9446 + if (DLIMIT_ALLOC_INODE(inode)) {
9448 + goto out_bad_dlimit;
9450 if (DQUOT_ALLOC_INODE(inode)) {
9453 @@ -1960,6 +1977,9 @@ int reiserfs_new_inode(struct reiserfs_t
9454 DQUOT_FREE_INODE(inode);
9457 + DLIMIT_FREE_INODE(inode);
9460 journal_end(th, th->t_super, th->t_blocks_allocated);
9461 /* Drop can be outside and it needs more credits so it's better to have it outside */
9463 @@ -2690,6 +2710,14 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
9464 inode->i_flags |= S_IMMUTABLE;
9466 inode->i_flags &= ~S_IMMUTABLE;
9467 + if (sd_attrs & REISERFS_IUNLINK_FL)
9468 + inode->i_flags |= S_IUNLINK;
9470 + inode->i_flags &= ~S_IUNLINK;
9471 + if (sd_attrs & REISERFS_BARRIER_FL)
9472 + inode->i_flags |= S_BARRIER;
9474 + inode->i_flags &= ~S_BARRIER;
9475 if (sd_attrs & REISERFS_APPEND_FL)
9476 inode->i_flags |= S_APPEND;
9478 @@ -2712,6 +2740,14 @@ void i_attrs_to_sd_attrs(struct inode *i
9479 *sd_attrs |= REISERFS_IMMUTABLE_FL;
9481 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
9482 + if (inode->i_flags & S_IUNLINK)
9483 + *sd_attrs |= REISERFS_IUNLINK_FL;
9485 + *sd_attrs &= ~REISERFS_IUNLINK_FL;
9486 + if (inode->i_flags & S_BARRIER)
9487 + *sd_attrs |= REISERFS_BARRIER_FL;
9489 + *sd_attrs &= ~REISERFS_BARRIER_FL;
9490 if (inode->i_flags & S_SYNC)
9491 *sd_attrs |= REISERFS_SYNC_FL;
9493 @@ -2891,6 +2927,22 @@ static ssize_t reiserfs_direct_IO(int rw
9494 reiserfs_get_blocks_direct_io, NULL);
9497 +int reiserfs_sync_flags(struct inode *inode)
9499 + u16 oldflags, newflags;
9501 + oldflags = REISERFS_I(inode)->i_attrs;
9502 + newflags = oldflags;
9503 + i_attrs_to_sd_attrs(inode, &newflags);
9505 + if (oldflags ^ newflags) {
9506 + REISERFS_I(inode)->i_attrs = newflags;
9507 + inode->i_ctime = CURRENT_TIME_SEC;
9508 + mark_inode_dirty(inode);
9513 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
9515 struct inode *inode = dentry->d_inode;
9516 @@ -2940,9 +2992,11 @@ int reiserfs_setattr(struct dentry *dent
9519 error = inode_change_ok(inode, attr);
9522 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
9523 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
9524 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
9525 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
9526 error = reiserfs_chown_xattrs(inode, attr);
9529 @@ -2972,6 +3026,9 @@ int reiserfs_setattr(struct dentry *dent
9530 inode->i_uid = attr->ia_uid;
9531 if (attr->ia_valid & ATTR_GID)
9532 inode->i_gid = attr->ia_gid;
9533 + if ((attr->ia_valid & ATTR_TAG) &&
9535 + inode->i_tag = attr->ia_tag;
9536 mark_inode_dirty(inode);
9538 journal_end(&th, inode->i_sb, jbegin_count);
9539 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/ioctl.c
9540 --- linux-2.6.22.10/fs/reiserfs/ioctl.c 2007-02-06 03:01:29 +0100
9541 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/ioctl.c 2007-08-05 20:53:13 +0200
9543 #include <linux/fs.h>
9544 #include <linux/reiserfs_fs.h>
9545 #include <linux/time.h>
9546 +#include <linux/mount.h>
9547 #include <asm/uaccess.h>
9548 #include <linux/pagemap.h>
9549 #include <linux/smp_lock.h>
9550 @@ -24,7 +25,7 @@ static int reiserfs_unpack(struct inode
9551 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
9554 - unsigned int flags;
9555 + unsigned int flags, oldflags;
9558 case REISERFS_IOC_UNPACK:
9559 @@ -43,12 +44,14 @@ int reiserfs_ioctl(struct inode *inode,
9561 flags = REISERFS_I(inode)->i_attrs;
9562 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
9563 + flags &= REISERFS_FL_USER_VISIBLE;
9564 return put_user(flags, (int __user *)arg);
9565 case REISERFS_IOC_SETFLAGS:{
9566 if (!reiserfs_attrs(inode->i_sb))
9569 - if (IS_RDONLY(inode))
9570 + if (IS_RDONLY(inode) ||
9571 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
9574 if ((current->fsuid != inode->i_uid)
9575 @@ -58,10 +61,12 @@ int reiserfs_ioctl(struct inode *inode,
9576 if (get_user(flags, (int __user *)arg))
9579 - if (((flags ^ REISERFS_I(inode)->
9580 - i_attrs) & (REISERFS_IMMUTABLE_FL |
9581 - REISERFS_APPEND_FL))
9582 - && !capable(CAP_LINUX_IMMUTABLE))
9583 + oldflags = REISERFS_I(inode) -> i_attrs;
9584 + if (((oldflags & REISERFS_IMMUTABLE_FL) ||
9585 + ((flags ^ oldflags) &
9586 + (REISERFS_IMMUTABLE_FL | REISERFS_IUNLINK_FL |
9587 + REISERFS_APPEND_FL))) &&
9588 + !capable(CAP_LINUX_IMMUTABLE))
9591 if ((flags & REISERFS_NOTAIL_FL) &&
9592 @@ -72,6 +77,9 @@ int reiserfs_ioctl(struct inode *inode,
9597 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
9598 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
9599 sd_attrs_to_i_attrs(flags, inode);
9600 REISERFS_I(inode)->i_attrs = flags;
9601 inode->i_ctime = CURRENT_TIME_SEC;
9602 @@ -83,7 +91,8 @@ int reiserfs_ioctl(struct inode *inode,
9603 case REISERFS_IOC_SETVERSION:
9604 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
9606 - if (IS_RDONLY(inode))
9607 + if (IS_RDONLY(inode) ||
9608 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
9610 if (get_user(inode->i_generation, (int __user *)arg))
9612 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/namei.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/namei.c
9613 --- linux-2.6.22.10/fs/reiserfs/namei.c 2007-07-09 13:19:28 +0200
9614 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/namei.c 2007-08-05 20:53:13 +0200
9616 #include <linux/reiserfs_acl.h>
9617 #include <linux/reiserfs_xattr.h>
9618 #include <linux/quotaops.h>
9619 +#include <linux/vs_tag.h>
9621 #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; }
9622 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
9623 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
9624 reiserfs_write_unlock(dir->i_sb);
9625 return ERR_PTR(-EACCES);
9627 + dx_propagate_tag(nd, inode);
9629 /* Propogate the priv_object flag so we know we're in the priv tree */
9630 if (is_reiserfs_priv_object(dir))
9631 @@ -595,6 +597,7 @@ static int new_inode_init(struct inode *
9633 inode->i_gid = current->fsgid;
9635 + inode->i_tag = dx_current_fstag(inode->i_sb);
9639 @@ -1541,6 +1544,7 @@ const struct inode_operations reiserfs_d
9640 .listxattr = reiserfs_listxattr,
9641 .removexattr = reiserfs_removexattr,
9642 .permission = reiserfs_permission,
9643 + .sync_flags = reiserfs_sync_flags,
9647 @@ -1557,6 +1561,7 @@ const struct inode_operations reiserfs_s
9648 .listxattr = reiserfs_listxattr,
9649 .removexattr = reiserfs_removexattr,
9650 .permission = reiserfs_permission,
9651 + .sync_flags = reiserfs_sync_flags,
9655 @@ -1570,5 +1575,6 @@ const struct inode_operations reiserfs_s
9656 .listxattr = reiserfs_listxattr,
9657 .removexattr = reiserfs_removexattr,
9658 .permission = reiserfs_permission,
9659 + .sync_flags = reiserfs_sync_flags,
9662 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/stree.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/stree.c
9663 --- linux-2.6.22.10/fs/reiserfs/stree.c 2007-07-09 13:19:28 +0200
9664 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/stree.c 2007-08-05 20:53:13 +0200
9666 #include <linux/reiserfs_fs.h>
9667 #include <linux/buffer_head.h>
9668 #include <linux/quotaops.h>
9669 +#include <linux/vs_dlimit.h>
9671 /* Does the buffer contain a disk block which is in the tree. */
9672 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
9673 @@ -1296,6 +1297,7 @@ int reiserfs_delete_item(struct reiserfs
9674 "reiserquota delete_item(): freeing %u, id=%u type=%c",
9675 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
9677 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
9678 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
9680 /* Return deleted body length */
9681 @@ -1384,6 +1386,7 @@ void reiserfs_delete_solid_item(struct r
9683 DQUOT_FREE_SPACE_NODIRTY(inode,
9685 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
9689 @@ -1737,6 +1740,7 @@ int reiserfs_cut_from_item(struct reiser
9690 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
9691 quota_cut_bytes, p_s_inode->i_uid, '?');
9693 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
9694 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
9697 @@ -1978,6 +1982,11 @@ int reiserfs_paste_into_item(struct reis
9698 pathrelse(p_s_search_path);
9701 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
9702 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
9703 + pathrelse(p_s_search_path);
9706 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
9708 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
9709 @@ -2030,6 +2039,7 @@ int reiserfs_paste_into_item(struct reis
9710 n_pasted_size, inode->i_uid,
9711 key2type(&(p_s_key->on_disk_key)));
9713 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
9714 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
9717 @@ -2067,6 +2077,11 @@ int reiserfs_insert_item(struct reiserfs
9718 pathrelse(p_s_path);
9721 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
9722 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
9723 + pathrelse(p_s_path);
9727 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
9728 IH_SIZE + ih_item_len(p_s_ih));
9729 @@ -2114,7 +2129,9 @@ int reiserfs_insert_item(struct reiserfs
9730 "reiserquota insert_item(): freeing %u id=%u type=%c",
9731 quota_bytes, inode->i_uid, head2type(p_s_ih));
9735 + DLIMIT_FREE_SPACE(inode, quota_bytes);
9736 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
9740 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/super.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/super.c
9741 --- linux-2.6.22.10/fs/reiserfs/super.c 2007-07-09 13:19:28 +0200
9742 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/super.c 2007-08-05 20:53:13 +0200
9743 @@ -882,6 +882,14 @@ static int reiserfs_parse_options(struct
9744 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9745 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9747 +#ifndef CONFIG_TAGGING_NONE
9748 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9749 + {"tag",.setmask = 1 << REISERFS_TAGGED},
9750 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
9752 +#ifdef CONFIG_PROPAGATE
9753 + {"tag",.arg_required = 'T',.values = NULL},
9755 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9756 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9757 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9758 @@ -1143,6 +1151,12 @@ static int reiserfs_remount(struct super
9762 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
9763 + !(s->s_flags & MS_TAGGED)) {
9764 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
9770 /* Add options that are safe here */
9771 @@ -1591,6 +1605,10 @@ static int reiserfs_fill_super(struct su
9775 + /* map mount option tagxid */
9776 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9777 + s->s_flags |= MS_TAGGED;
9779 rs = SB_DISK_SUPER_BLOCK(s);
9780 /* Let's do basic sanity check to verify that underlying device is not
9781 smaller than the filesystem. If the check fails then abort and scream,
9782 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/xattr.c
9783 --- linux-2.6.22.10/fs/reiserfs/xattr.c 2007-07-09 13:19:28 +0200
9784 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/xattr.c 2007-08-05 20:53:13 +0200
9786 #include <linux/namei.h>
9787 #include <linux/errno.h>
9788 #include <linux/fs.h>
9789 +#include <linux/mount.h>
9790 #include <linux/file.h>
9791 #include <linux/pagemap.h>
9792 #include <linux/xattr.h>
9793 @@ -775,7 +776,7 @@ int reiserfs_delete_xattrs(struct inode
9794 if (dir->d_inode->i_nlink <= 2) {
9795 root = get_xa_root(inode->i_sb, XATTR_REPLACE);
9796 reiserfs_write_lock_xattrs(inode->i_sb);
9797 - err = vfs_rmdir(root->d_inode, dir);
9798 + err = vfs_rmdir(root->d_inode, dir, NULL);
9799 reiserfs_write_unlock_xattrs(inode->i_sb);
9802 diff -NurpP --minimal linux-2.6.22.10/fs/stat.c linux-2.6.22.10-vs2.3.0.29/fs/stat.c
9803 --- linux-2.6.22.10/fs/stat.c 2007-07-09 13:19:28 +0200
9804 +++ linux-2.6.22.10-vs2.3.0.29/fs/stat.c 2007-08-05 20:53:13 +0200
9805 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9806 stat->nlink = inode->i_nlink;
9807 stat->uid = inode->i_uid;
9808 stat->gid = inode->i_gid;
9809 + stat->tag = inode->i_tag;
9810 stat->rdev = inode->i_rdev;
9811 stat->atime = inode->i_atime;
9812 stat->mtime = inode->i_mtime;
9813 diff -NurpP --minimal linux-2.6.22.10/fs/super.c linux-2.6.22.10-vs2.3.0.29/fs/super.c
9814 --- linux-2.6.22.10/fs/super.c 2007-07-09 13:19:28 +0200
9815 +++ linux-2.6.22.10-vs2.3.0.29/fs/super.c 2007-10-20 00:00:59 +0200
9817 #include <linux/idr.h>
9818 #include <linux/kobject.h>
9819 #include <linux/mutex.h>
9820 +#include <linux/devpts_fs.h>
9821 +#include <linux/proc_fs.h>
9822 +#include <linux/vs_context.h>
9823 #include <asm/uaccess.h>
9826 @@ -860,12 +863,18 @@ struct vfsmount *
9827 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
9829 struct vfsmount *mnt;
9830 + struct super_block *sb;
9831 char *secdata = NULL;
9835 return ERR_PTR(-ENODEV);
9838 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
9839 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
9843 mnt = alloc_vfsmnt(name);
9845 @@ -885,7 +894,14 @@ vfs_kern_mount(struct file_system_type *
9847 goto out_free_secdata;
9849 - error = security_sb_kern_mount(mnt->mnt_sb, secdata);
9852 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
9853 + (sb->s_magic != PROC_SUPER_MAGIC) &&
9854 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
9857 + error = security_sb_kern_mount(sb, secdata);
9861 diff -NurpP --minimal linux-2.6.22.10/fs/sysfs/mount.c linux-2.6.22.10-vs2.3.0.29/fs/sysfs/mount.c
9862 --- linux-2.6.22.10/fs/sysfs/mount.c 2007-07-09 13:19:28 +0200
9863 +++ linux-2.6.22.10-vs2.3.0.29/fs/sysfs/mount.c 2007-08-05 20:53:13 +0200
9868 -/* Random magic number */
9869 -#define SYSFS_MAGIC 0x62656572
9871 struct vfsmount *sysfs_mount;
9872 struct super_block * sysfs_sb = NULL;
9873 @@ -48,7 +46,7 @@ static int sysfs_fill_super(struct super
9875 sb->s_blocksize = PAGE_CACHE_SIZE;
9876 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9877 - sb->s_magic = SYSFS_MAGIC;
9878 + sb->s_magic = SYSFS_SUPER_MAGIC;
9879 sb->s_op = &sysfs_ops;
9880 sb->s_time_gran = 1;
9882 diff -NurpP --minimal linux-2.6.22.10/fs/utimes.c linux-2.6.22.10-vs2.3.0.29/fs/utimes.c
9883 --- linux-2.6.22.10/fs/utimes.c 2007-07-09 13:19:29 +0200
9884 +++ linux-2.6.22.10-vs2.3.0.29/fs/utimes.c 2007-08-05 20:53:13 +0200
9886 #include <linux/sched.h>
9887 #include <linux/stat.h>
9888 #include <linux/utime.h>
9889 +#include <linux/mount.h>
9890 +#include <linux/vs_cowbl.h>
9891 #include <asm/uaccess.h>
9892 #include <asm/unistd.h>
9894 @@ -70,11 +72,13 @@ long do_utimes(int dfd, char __user *fil
9898 + error = cow_check_and_break(&nd);
9900 + goto dput_and_out;
9904 inode = dentry->d_inode;
9907 if (IS_RDONLY(inode))
9909 diff -NurpP --minimal linux-2.6.22.10/fs/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/xattr.c
9910 --- linux-2.6.22.10/fs/xattr.c 2007-07-09 13:19:29 +0200
9911 +++ linux-2.6.22.10-vs2.3.0.29/fs/xattr.c 2007-08-05 20:53:13 +0200
9913 #include <linux/module.h>
9914 #include <linux/fsnotify.h>
9915 #include <linux/audit.h>
9916 +#include <linux/mount.h>
9917 #include <asm/uaccess.h>
9920 @@ -194,7 +195,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
9923 setxattr(struct dentry *d, char __user *name, void __user *value,
9924 - size_t size, int flags)
9925 + size_t size, int flags, struct vfsmount *mnt)
9928 void *kvalue = NULL;
9929 @@ -221,6 +222,9 @@ setxattr(struct dentry *d, char __user *
9933 + if (MNT_IS_RDONLY(mnt))
9936 error = vfs_setxattr(d, kname, kvalue, size, flags);
9939 @@ -236,7 +240,7 @@ sys_setxattr(char __user *path, char __u
9940 error = user_path_walk(path, &nd);
9943 - error = setxattr(nd.dentry, name, value, size, flags);
9944 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
9948 @@ -251,7 +255,7 @@ sys_lsetxattr(char __user *path, char __
9949 error = user_path_walk_link(path, &nd);
9952 - error = setxattr(nd.dentry, name, value, size, flags);
9953 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
9957 @@ -269,7 +273,7 @@ sys_fsetxattr(int fd, char __user *name,
9959 dentry = f->f_path.dentry;
9960 audit_inode(NULL, dentry->d_inode);
9961 - error = setxattr(dentry, name, value, size, flags);
9962 + error = setxattr(dentry, name, value, size, flags, f->f_vfsmnt);
9966 @@ -433,7 +437,7 @@ sys_flistxattr(int fd, char __user *list
9967 * Extended attribute REMOVE operations
9970 -removexattr(struct dentry *d, char __user *name)
9971 +removexattr(struct dentry *d, char __user *name, struct vfsmount *mnt)
9974 char kname[XATTR_NAME_MAX + 1];
9975 @@ -444,6 +448,9 @@ removexattr(struct dentry *d, char __use
9979 + if (MNT_IS_RDONLY(mnt))
9982 return vfs_removexattr(d, kname);
9985 @@ -456,7 +463,7 @@ sys_removexattr(char __user *path, char
9986 error = user_path_walk(path, &nd);
9989 - error = removexattr(nd.dentry, name);
9990 + error = removexattr(nd.dentry, name, nd.mnt);
9994 @@ -470,7 +477,7 @@ sys_lremovexattr(char __user *path, char
9995 error = user_path_walk_link(path, &nd);
9998 - error = removexattr(nd.dentry, name);
9999 + error = removexattr(nd.dentry, name, nd.mnt);
10003 @@ -487,7 +494,7 @@ sys_fremovexattr(int fd, char __user *na
10005 dentry = f->f_path.dentry;
10006 audit_inode(NULL, dentry->d_inode);
10007 - error = removexattr(dentry, name);
10008 + error = removexattr(dentry, name, f->f_vfsmnt);
10012 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_ioctl.c
10013 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_ioctl.c 2007-05-02 19:25:22 +0200
10014 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_ioctl.c 2007-08-05 20:53:13 +0200
10015 @@ -1128,6 +1128,10 @@ xfs_di2lxflags(
10017 if (di_flags & XFS_DIFLAG_IMMUTABLE)
10018 flags |= FS_IMMUTABLE_FL;
10019 + if (di_flags & XFS_DIFLAG_IUNLINK)
10020 + flags |= FS_IUNLINK_FL;
10021 + if (di_flags & XFS_DIFLAG_BARRIER)
10022 + flags |= FS_BARRIER_FL;
10023 if (di_flags & XFS_DIFLAG_APPEND)
10024 flags |= FS_APPEND_FL;
10025 if (di_flags & XFS_DIFLAG_SYNC)
10026 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_iops.c
10027 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_iops.c 2007-05-02 19:25:22 +0200
10028 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_iops.c 2007-08-05 20:53:13 +0200
10030 #include <linux/xattr.h>
10031 #include <linux/namei.h>
10032 #include <linux/security.h>
10033 +#include <linux/vs_tag.h>
10036 * Get a XFS inode from a given vnode.
10037 @@ -400,6 +401,7 @@ xfs_vn_lookup(
10038 d_add(dentry, NULL);
10041 + dx_propagate_tag(nd, vn_to_inode(cvp));
10043 return d_splice_alias(vn_to_inode(cvp), dentry);
10045 @@ -657,6 +659,10 @@ xfs_vn_setattr(
10049 + error = inode_change_ok(inode, attr);
10053 if (ia_valid & ATTR_UID) {
10054 vattr.va_mask |= XFS_AT_UID;
10055 vattr.va_uid = attr->ia_uid;
10056 @@ -665,6 +671,10 @@ xfs_vn_setattr(
10057 vattr.va_mask |= XFS_AT_GID;
10058 vattr.va_gid = attr->ia_gid;
10060 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode)) {
10061 + vattr.va_mask |= XFS_AT_TAG;
10062 + vattr.va_tag = attr->ia_tag;
10064 if (ia_valid & ATTR_SIZE) {
10065 vattr.va_mask |= XFS_AT_SIZE;
10066 vattr.va_size = attr->ia_size;
10067 @@ -710,6 +720,42 @@ xfs_vn_truncate(
10071 +xfs_vn_sync_flags(struct inode *inode)
10073 + unsigned int oldflags, newflags;
10076 + bhv_vattr_t vattr;
10077 + bhv_vnode_t *vp = vn_from_inode(inode);
10079 + memset(&vattr, 0, sizeof vattr);
10081 + vattr.va_mask = XFS_AT_XFLAGS;
10082 + error = bhv_vop_getattr(vp, &vattr, 0, NULL);
10086 + oldflags = vattr.va_xflags;
10087 + newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE |
10088 + XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER);
10090 + if (IS_IMMUTABLE(inode))
10091 + newflags |= XFS_XFLAG_IMMUTABLE;
10092 + if (IS_IUNLINK(inode))
10093 + newflags |= XFS_XFLAG_IUNLINK;
10094 + if (IS_BARRIER(inode))
10095 + newflags |= XFS_XFLAG_BARRIER;
10097 + if (oldflags ^ newflags) {
10098 + vattr.va_xflags = newflags;
10099 + vattr.va_mask |= XFS_AT_XFLAGS;
10100 + error = bhv_vop_setattr(vp, &vattr, flags, NULL);
10102 + vn_revalidate(vp);
10108 struct dentry *dentry,
10110 @@ -822,6 +868,7 @@ const struct inode_operations xfs_inode_
10111 .getxattr = xfs_vn_getxattr,
10112 .listxattr = xfs_vn_listxattr,
10113 .removexattr = xfs_vn_removexattr,
10114 + .sync_flags = xfs_vn_sync_flags,
10117 const struct inode_operations xfs_dir_inode_operations = {
10118 @@ -841,6 +888,7 @@ const struct inode_operations xfs_dir_in
10119 .getxattr = xfs_vn_getxattr,
10120 .listxattr = xfs_vn_listxattr,
10121 .removexattr = xfs_vn_removexattr,
10122 + .sync_flags = xfs_vn_sync_flags,
10125 const struct inode_operations xfs_symlink_inode_operations = {
10126 @@ -854,4 +902,5 @@ const struct inode_operations xfs_symlin
10127 .getxattr = xfs_vn_getxattr,
10128 .listxattr = xfs_vn_listxattr,
10129 .removexattr = xfs_vn_removexattr,
10130 + .sync_flags = xfs_vn_sync_flags,
10132 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_linux.h
10133 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_linux.h 2007-05-02 19:25:22 +0200
10134 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_linux.h 2007-08-05 20:53:13 +0200
10135 @@ -129,6 +129,7 @@
10136 #define current_pid() (current->pid)
10137 #define current_fsuid(cred) (current->fsuid)
10138 #define current_fsgid(cred) (current->fsgid)
10139 +#define current_fstag(cred,vp) (dx_current_fstag(vn_to_inode(vp)->i_sb))
10140 #define current_test_flags(f) (current->flags & (f))
10141 #define current_set_flags_nested(sp, f) \
10142 (*(sp) = current->flags, current->flags |= (f))
10143 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_super.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_super.c
10144 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_super.c 2007-07-09 13:19:29 +0200
10145 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_super.c 2007-08-05 20:53:13 +0200
10146 @@ -157,6 +157,7 @@ xfs_revalidate_inode(
10147 inode->i_nlink = ip->i_d.di_nlink;
10148 inode->i_uid = ip->i_d.di_uid;
10149 inode->i_gid = ip->i_d.di_gid;
10150 + inode->i_tag = ip->i_d.di_tag;
10152 switch (inode->i_mode & S_IFMT) {
10154 @@ -184,6 +185,14 @@ xfs_revalidate_inode(
10155 inode->i_flags |= S_IMMUTABLE;
10157 inode->i_flags &= ~S_IMMUTABLE;
10158 + if (ip->i_d.di_flags & XFS_DIFLAG_IUNLINK)
10159 + inode->i_flags |= S_IUNLINK;
10161 + inode->i_flags &= ~S_IUNLINK;
10162 + if (ip->i_d.di_flags & XFS_DIFLAG_BARRIER)
10163 + inode->i_flags |= S_BARRIER;
10165 + inode->i_flags &= ~S_BARRIER;
10166 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
10167 inode->i_flags |= S_APPEND;
10169 @@ -712,6 +721,12 @@ xfs_fs_remount(
10172 error = bhv_vfs_parseargs(vfsp, options, args, 1);
10173 + if ((args->flags2 & XFSMNT2_TAGGED) &&
10174 + !(sb->s_flags & MS_TAGGED)) {
10175 + printk("XFS: %s: tagging not permitted on remount.\n",
10180 error = bhv_vfs_mntupdate(vfsp, flags, args);
10181 kmem_free(args, sizeof(*args));
10182 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_vnode.c
10183 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.c 2007-05-02 19:25:22 +0200
10184 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_vnode.c 2007-08-05 20:53:13 +0200
10185 @@ -119,6 +119,7 @@ vn_revalidate_core(
10186 inode->i_nlink = vap->va_nlink;
10187 inode->i_uid = vap->va_uid;
10188 inode->i_gid = vap->va_gid;
10189 + inode->i_tag = vap->va_tag;
10190 inode->i_blocks = vap->va_nblocks;
10191 inode->i_mtime = vap->va_mtime;
10192 inode->i_ctime = vap->va_ctime;
10193 @@ -126,6 +127,14 @@ vn_revalidate_core(
10194 inode->i_flags |= S_IMMUTABLE;
10196 inode->i_flags &= ~S_IMMUTABLE;
10197 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
10198 + inode->i_flags |= S_IUNLINK;
10200 + inode->i_flags &= ~S_IUNLINK;
10201 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
10202 + inode->i_flags |= S_BARRIER;
10204 + inode->i_flags &= ~S_BARRIER;
10205 if (vap->va_xflags & XFS_XFLAG_APPEND)
10206 inode->i_flags |= S_APPEND;
10208 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.h linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_vnode.h
10209 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.h 2007-07-09 13:19:29 +0200
10210 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_vnode.h 2007-08-05 20:53:13 +0200
10211 @@ -350,6 +350,7 @@ typedef struct bhv_vattr {
10212 xfs_nlink_t va_nlink; /* number of references to file */
10213 uid_t va_uid; /* owner user id */
10214 gid_t va_gid; /* owner group id */
10215 + tag_t va_tag; /* owner group id */
10216 xfs_ino_t va_nodeid; /* file id */
10217 xfs_off_t va_size; /* file size in bytes */
10218 u_long va_blocksize; /* blocksize preferred for i/o */
10219 @@ -398,13 +399,15 @@ typedef struct bhv_vattr {
10220 #define XFS_AT_PROJID 0x04000000
10221 #define XFS_AT_SIZE_NOPERM 0x08000000
10222 #define XFS_AT_GENCOUNT 0x10000000
10223 +#define XFS_AT_TAG 0x20000000
10225 #define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
10226 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
10227 XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
10228 XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
10229 XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
10230 - XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
10231 + XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT\
10234 #define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
10235 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
10236 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/quota/xfs_qm_syscalls.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/quota/xfs_qm_syscalls.c
10237 --- linux-2.6.22.10/fs/xfs/quota/xfs_qm_syscalls.c 2007-07-09 13:19:29 +0200
10238 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/quota/xfs_qm_syscalls.c 2007-08-05 20:53:13 +0200
10242 #include <linux/capability.h>
10243 +#include <linux/vs_context.h>
10246 #include "xfs_fs.h"
10247 @@ -211,7 +212,7 @@ xfs_qm_scall_quotaoff(
10248 xfs_qoff_logitem_t *qoffstart;
10251 - if (!force && !capable(CAP_SYS_ADMIN))
10252 + if (!force && !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10253 return XFS_ERROR(EPERM);
10255 * No file system can have quotas enabled on disk but not in core.
10256 @@ -380,7 +381,7 @@ xfs_qm_scall_trunc_qfiles(
10260 - if (!capable(CAP_SYS_ADMIN))
10261 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10262 return XFS_ERROR(EPERM);
10264 if (!XFS_SB_VERSION_HASQUOTA(&mp->m_sb) || flags == 0) {
10265 @@ -425,7 +426,7 @@ xfs_qm_scall_quotaon(
10269 - if (!capable(CAP_SYS_ADMIN))
10270 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10271 return XFS_ERROR(EPERM);
10273 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
10274 @@ -594,7 +595,7 @@ xfs_qm_scall_setqlim(
10276 xfs_qcnt_t hard, soft;
10278 - if (!capable(CAP_SYS_ADMIN))
10279 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10280 return XFS_ERROR(EPERM);
10282 if ((newlim->d_fieldmask &
10283 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_clnt.h linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_clnt.h
10284 --- linux-2.6.22.10/fs/xfs/xfs_clnt.h 2006-06-18 04:54:50 +0200
10285 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_clnt.h 2007-08-05 20:53:13 +0200
10286 @@ -99,5 +99,7 @@ struct xfs_mount_args {
10288 #define XFSMNT2_COMPAT_IOSIZE 0x00000001 /* don't report large preferred
10289 * I/O size in stat(2) */
10290 +#define XFSMNT2_TAGGED 0x80000000 /* context tagging */
10293 #endif /* __XFS_CLNT_H__ */
10294 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_dinode.h linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_dinode.h
10295 --- linux-2.6.22.10/fs/xfs/xfs_dinode.h 2006-09-20 16:58:40 +0200
10296 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_dinode.h 2007-08-05 20:53:13 +0200
10297 @@ -53,7 +53,8 @@ typedef struct xfs_dinode_core
10298 __uint32_t di_gid; /* owner's group id */
10299 __uint32_t di_nlink; /* number of links to file */
10300 __uint16_t di_projid; /* owner's project id */
10301 - __uint8_t di_pad[8]; /* unused, zeroed space */
10302 + __uint16_t di_tag; /* context tagging */
10303 + __uint8_t di_pad[6]; /* unused, zeroed space */
10304 __uint16_t di_flushiter; /* incremented on flush */
10305 xfs_timestamp_t di_atime; /* time last accessed */
10306 xfs_timestamp_t di_mtime; /* time last modified */
10307 @@ -257,6 +258,9 @@ typedef enum xfs_dinode_fmt
10308 #define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */
10309 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
10310 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
10311 +#define XFS_DIFLAG_BARRIER_BIT 14 /* chroot() barrier */
10312 +#define XFS_DIFLAG_IUNLINK_BIT 15 /* immutable unlink */
10314 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
10315 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
10316 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
10317 @@ -271,12 +275,15 @@ typedef enum xfs_dinode_fmt
10318 #define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT)
10319 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
10320 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
10321 +#define XFS_DIFLAG_BARRIER (1 << XFS_DIFLAG_BARRIER_BIT)
10322 +#define XFS_DIFLAG_IUNLINK (1 << XFS_DIFLAG_IUNLINK_BIT)
10324 #define XFS_DIFLAG_ANY \
10325 (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \
10326 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
10327 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
10328 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
10329 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG)
10330 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_BARRIER | \
10331 + XFS_DIFLAG_IUNLINK)
10333 #endif /* __XFS_DINODE_H__ */
10334 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_fs.h linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_fs.h
10335 --- linux-2.6.22.10/fs/xfs/xfs_fs.h 2006-11-30 21:19:29 +0100
10336 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_fs.h 2007-08-05 20:53:13 +0200
10337 @@ -66,6 +66,8 @@ struct fsxattr {
10338 #define XFS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */
10339 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
10340 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
10341 +#define XFS_XFLAG_BARRIER 0x00004000 /* chroot() barrier */
10342 +#define XFS_XFLAG_IUNLINK 0x00008000 /* immutable unlink */
10343 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
10346 @@ -294,7 +296,8 @@ typedef struct xfs_bstat {
10347 __s32 bs_extents; /* number of extents */
10348 __u32 bs_gen; /* generation count */
10349 __u16 bs_projid; /* project id */
10350 - unsigned char bs_pad[14]; /* pad space, unused */
10351 + __u16 bs_tag; /* context tagging */
10352 + unsigned char bs_pad[12]; /* pad space, unused */
10353 __u32 bs_dmevmask; /* DMIG event mask */
10354 __u16 bs_dmstate; /* DMIG state info */
10355 __u16 bs_aextents; /* attribute number of extents */
10356 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_inode.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_inode.c
10357 --- linux-2.6.22.10/fs/xfs/xfs_inode.c 2007-07-09 13:19:34 +0200
10358 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_inode.c 2007-08-05 20:53:13 +0200
10360 #include "xfs_quota.h"
10361 #include "xfs_acl.h"
10363 +#include <linux/vs_tag.h>
10365 kmem_zone_t *xfs_ifork_zone;
10366 kmem_zone_t *xfs_inode_zone;
10367 @@ -736,20 +737,35 @@ xfs_xlate_dinode_core(
10368 xfs_dinode_core_t *buf_core = (xfs_dinode_core_t *)buf;
10369 xfs_dinode_core_t *mem_core = (xfs_dinode_core_t *)dip;
10370 xfs_arch_t arch = ARCH_CONVERT;
10371 + uint32_t uid = 0, gid = 0;
10372 + uint16_t tag = 0;
10377 + tag = mem_core->di_tag;
10378 + /* FIXME: supposed to use superblock flag */
10379 + uid = TAGINO_UID(1, mem_core->di_uid, tag);
10380 + gid = TAGINO_GID(1, mem_core->di_gid, tag);
10381 + tag = TAGINO_TAG(1, tag);
10384 INT_XLATE(buf_core->di_magic, mem_core->di_magic, dir, arch);
10385 INT_XLATE(buf_core->di_mode, mem_core->di_mode, dir, arch);
10386 INT_XLATE(buf_core->di_version, mem_core->di_version, dir, arch);
10387 INT_XLATE(buf_core->di_format, mem_core->di_format, dir, arch);
10388 INT_XLATE(buf_core->di_onlink, mem_core->di_onlink, dir, arch);
10389 - INT_XLATE(buf_core->di_uid, mem_core->di_uid, dir, arch);
10390 - INT_XLATE(buf_core->di_gid, mem_core->di_gid, dir, arch);
10391 + INT_XLATE(buf_core->di_uid, uid, dir, arch);
10392 + INT_XLATE(buf_core->di_gid, gid, dir, arch);
10393 + INT_XLATE(buf_core->di_tag, tag, dir, arch);
10394 INT_XLATE(buf_core->di_nlink, mem_core->di_nlink, dir, arch);
10395 INT_XLATE(buf_core->di_projid, mem_core->di_projid, dir, arch);
10398 + /* FIXME: supposed to use superblock flag */
10399 + mem_core->di_uid = INOTAG_UID(1, uid, gid);
10400 + mem_core->di_gid = INOTAG_GID(1, uid, gid);
10401 + mem_core->di_tag = INOTAG_TAG(1, uid, gid, tag);
10402 memcpy(mem_core->di_pad, buf_core->di_pad,
10403 sizeof(buf_core->di_pad));
10405 @@ -797,6 +813,10 @@ _xfs_dic2xflags(
10406 flags |= XFS_XFLAG_PREALLOC;
10407 if (di_flags & XFS_DIFLAG_IMMUTABLE)
10408 flags |= XFS_XFLAG_IMMUTABLE;
10409 + if (di_flags & XFS_DIFLAG_IUNLINK)
10410 + flags |= XFS_XFLAG_IUNLINK;
10411 + if (di_flags & XFS_DIFLAG_BARRIER)
10412 + flags |= XFS_XFLAG_BARRIER;
10413 if (di_flags & XFS_DIFLAG_APPEND)
10414 flags |= XFS_XFLAG_APPEND;
10415 if (di_flags & XFS_DIFLAG_SYNC)
10416 @@ -1129,6 +1149,7 @@ xfs_ialloc(
10417 ASSERT(ip->i_d.di_nlink == nlink);
10418 ip->i_d.di_uid = current_fsuid(cr);
10419 ip->i_d.di_gid = current_fsgid(cr);
10420 + ip->i_d.di_tag = current_fstag(cr, vp);
10421 ip->i_d.di_projid = prid;
10422 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
10424 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_itable.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_itable.c
10425 --- linux-2.6.22.10/fs/xfs/xfs_itable.c 2007-07-09 13:19:34 +0200
10426 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_itable.c 2007-08-05 20:53:13 +0200
10427 @@ -89,6 +89,7 @@ xfs_bulkstat_one_iget(
10428 buf->bs_mode = dic->di_mode;
10429 buf->bs_uid = dic->di_uid;
10430 buf->bs_gid = dic->di_gid;
10431 + buf->bs_tag = dic->di_tag;
10432 buf->bs_size = dic->di_size;
10433 vn_atime_to_bstime(vp, &buf->bs_atime);
10434 buf->bs_mtime.tv_sec = dic->di_mtime.t_sec;
10435 @@ -163,6 +164,7 @@ xfs_bulkstat_one_dinode(
10436 buf->bs_mode = INT_GET(dic->di_mode, ARCH_CONVERT);
10437 buf->bs_uid = INT_GET(dic->di_uid, ARCH_CONVERT);
10438 buf->bs_gid = INT_GET(dic->di_gid, ARCH_CONVERT);
10439 + buf->bs_tag = INT_GET(dic->di_tag, ARCH_CONVERT);
10440 buf->bs_size = INT_GET(dic->di_size, ARCH_CONVERT);
10441 buf->bs_atime.tv_sec = INT_GET(dic->di_atime.t_sec, ARCH_CONVERT);
10442 buf->bs_atime.tv_nsec = INT_GET(dic->di_atime.t_nsec, ARCH_CONVERT);
10443 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_mount.h linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_mount.h
10444 --- linux-2.6.22.10/fs/xfs/xfs_mount.h 2007-05-02 19:25:23 +0200
10445 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_mount.h 2007-08-05 20:53:13 +0200
10446 @@ -464,6 +464,7 @@ typedef struct xfs_mount {
10447 #define XFS_MOUNT_NO_PERCPU_SB (1ULL << 23) /* don't use per-cpu superblock
10450 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
10453 * Default minimum read and write sizes.
10454 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_vfsops.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_vfsops.c
10455 --- linux-2.6.22.10/fs/xfs/xfs_vfsops.c 2007-07-09 13:19:34 +0200
10456 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_vfsops.c 2007-08-05 20:53:13 +0200
10457 @@ -300,6 +300,8 @@ xfs_start_flags(
10459 if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
10460 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
10461 + if (ap->flags2 & XFSMNT2_TAGGED)
10462 + mp->m_flags |= XFS_MOUNT_TAGGED;
10465 * no recovery flag requires a read-only mount
10466 @@ -394,6 +396,8 @@ xfs_finish_flags(
10467 return XFS_ERROR(EINVAL);
10470 + if (ap->flags2 & XFSMNT2_TAGGED)
10471 + vfs->vfs_super->s_flags |= MS_TAGGED;
10475 @@ -1645,6 +1649,9 @@ xfs_vget(
10477 #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
10478 #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
10479 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
10480 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
10481 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
10483 STATIC unsigned long
10484 suffix_strtoul(char *s, char **endp, unsigned int base)
10485 @@ -1831,6 +1838,19 @@ xfs_parseargs(
10486 args->flags |= XFSMNT_ATTR2;
10487 } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
10488 args->flags &= ~XFSMNT_ATTR2;
10489 +#ifndef CONFIG_TAGGING_NONE
10490 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
10491 + args->flags2 |= XFSMNT2_TAGGED;
10492 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
10493 + args->flags2 &= ~XFSMNT2_TAGGED;
10494 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
10495 + args->flags2 |= XFSMNT2_TAGGED;
10497 +#ifdef CONFIG_PROPAGATE
10498 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
10500 + args->flags2 |= XFSMNT2_TAGGED;
10502 } else if (!strcmp(this_char, "osyncisdsync")) {
10503 /* no-op, this is now the default */
10505 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_vnodeops.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_vnodeops.c
10506 --- linux-2.6.22.10/fs/xfs/xfs_vnodeops.c 2007-07-09 13:19:34 +0200
10507 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_vnodeops.c 2007-08-05 20:53:13 +0200
10508 @@ -159,6 +159,7 @@ xfs_getattr(
10509 vap->va_mode = ip->i_d.di_mode;
10510 vap->va_uid = ip->i_d.di_uid;
10511 vap->va_gid = ip->i_d.di_gid;
10512 + vap->va_tag = ip->i_d.di_tag;
10513 vap->va_projid = ip->i_d.di_projid;
10516 @@ -259,6 +260,7 @@ xfs_setattr(
10517 uint commit_flags=0;
10518 uid_t uid=0, iuid=0;
10519 gid_t gid=0, igid=0;
10520 + tag_t tag=0, itag=0;
10523 xfs_prid_t projid=0, iprojid=0;
10524 @@ -315,6 +317,7 @@ xfs_setattr(
10525 (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID))) {
10528 + /* TODO: handle tagging? */
10529 if ((mask & XFS_AT_UID) && XFS_IS_UQUOTA_ON(mp)) {
10531 qflags |= XFS_QMOPT_UQUOTA;
10532 @@ -394,6 +397,8 @@ xfs_setattr(
10534 (XFS_AT_MODE|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_UID|
10535 XFS_AT_GID|XFS_AT_PROJID)) {
10536 + /* TODO: handle tagging? */
10539 * CAP_FOWNER overrides the following restrictions:
10541 @@ -442,7 +447,7 @@ xfs_setattr(
10542 * and can change the group id only to a group of which he
10543 * or she is a member.
10545 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
10546 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
10548 * These IDs could have changed since we last looked at them.
10549 * But, we're assured that if the ownership did change
10550 @@ -450,10 +455,12 @@ xfs_setattr(
10551 * would have changed also.
10553 iuid = ip->i_d.di_uid;
10554 - iprojid = ip->i_d.di_projid;
10555 igid = ip->i_d.di_gid;
10556 - gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
10557 + itag = ip->i_d.di_tag;
10558 + iprojid = ip->i_d.di_projid;
10559 uid = (mask & XFS_AT_UID) ? vap->va_uid : iuid;
10560 + gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
10561 + tag = (mask & XFS_AT_TAG) ? vap->va_tag : itag;
10562 projid = (mask & XFS_AT_PROJID) ? (xfs_prid_t)vap->va_projid :
10565 @@ -481,6 +488,7 @@ xfs_setattr(
10566 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
10567 (XFS_IS_PQUOTA_ON(mp) && iprojid != projid) ||
10568 (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
10569 + /* TODO: handle tagging? */
10571 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
10572 capable(CAP_FOWNER) ?
10573 @@ -706,7 +714,7 @@ xfs_setattr(
10574 * and can change the group id only to a group of which he
10575 * or she is a member.
10577 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
10578 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
10580 * CAP_FSETID overrides the following restrictions:
10582 @@ -722,6 +730,9 @@ xfs_setattr(
10583 * Change the ownerships and register quota modifications
10584 * in the transaction.
10586 + if (itag != tag) {
10587 + ip->i_d.di_tag = tag;
10590 if (XFS_IS_UQUOTA_ON(mp)) {
10591 ASSERT(mask & XFS_AT_UID);
10592 @@ -802,6 +813,10 @@ xfs_setattr(
10593 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
10594 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
10595 di_flags |= XFS_DIFLAG_IMMUTABLE;
10596 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
10597 + di_flags |= XFS_DIFLAG_IUNLINK;
10598 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
10599 + di_flags |= XFS_DIFLAG_BARRIER;
10600 if (vap->va_xflags & XFS_XFLAG_APPEND)
10601 di_flags |= XFS_DIFLAG_APPEND;
10602 if (vap->va_xflags & XFS_XFLAG_SYNC)
10603 diff -NurpP --minimal linux-2.6.22.10/include/asm-alpha/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-alpha/socket.h
10604 --- linux-2.6.22.10/include/asm-alpha/socket.h 2007-07-09 13:19:35 +0200
10605 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-alpha/socket.h 2007-08-05 20:53:13 +0200
10607 #define SO_TIMESTAMPNS 35
10608 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10610 +#define SO_PEERTAG 36
10612 /* Security levels - as per NRL IPv6 - don't actually do anything */
10613 #define SO_SECURITY_AUTHENTICATION 19
10614 #define SO_SECURITY_ENCRYPTION_TRANSPORT 20
10615 diff -NurpP --minimal linux-2.6.22.10/include/asm-arm/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-arm/socket.h
10616 --- linux-2.6.22.10/include/asm-arm/socket.h 2007-07-09 13:19:39 +0200
10617 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-arm/socket.h 2007-08-05 20:53:13 +0200
10619 #define SO_TIMESTAMPNS 35
10620 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10622 +#define SO_PEERTAG 36
10624 #endif /* _ASM_SOCKET_H */
10625 diff -NurpP --minimal linux-2.6.22.10/include/asm-arm/tlb.h linux-2.6.22.10-vs2.3.0.29/include/asm-arm/tlb.h
10626 --- linux-2.6.22.10/include/asm-arm/tlb.h 2006-06-18 04:54:58 +0200
10627 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-arm/tlb.h 2007-08-05 20:53:13 +0200
10629 #else /* !CONFIG_MMU */
10631 #include <asm/pgalloc.h>
10632 +#include <linux/vs_memory.h>
10635 * TLB handling. This allows us to remove pages from the page
10636 diff -NurpP --minimal linux-2.6.22.10/include/asm-arm26/tlb.h linux-2.6.22.10-vs2.3.0.29/include/asm-arm26/tlb.h
10637 --- linux-2.6.22.10/include/asm-arm26/tlb.h 2006-01-03 17:30:02 +0100
10638 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-arm26/tlb.h 2007-08-05 20:53:13 +0200
10641 #include <asm/pgalloc.h>
10642 #include <asm/tlbflush.h>
10643 +#include <linux/vs_memory.h>
10646 * TLB handling. This allows us to remove pages from the page
10647 diff -NurpP --minimal linux-2.6.22.10/include/asm-arm26/unistd.h linux-2.6.22.10-vs2.3.0.29/include/asm-arm26/unistd.h
10648 --- linux-2.6.22.10/include/asm-arm26/unistd.h 2007-02-06 03:01:35 +0100
10649 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-arm26/unistd.h 2007-08-05 20:53:13 +0200
10650 @@ -302,6 +302,8 @@
10651 #define __NR_mq_getsetattr (__NR_SYSCALL_BASE+279)
10652 #define __NR_waitid (__NR_SYSCALL_BASE+280)
10654 +#define __NR_vserver (__NR_SYSCALL_BASE+313)
10657 * The following SWIs are ARM private. FIXME - make appropriate for arm26
10659 diff -NurpP --minimal linux-2.6.22.10/include/asm-cris/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-cris/socket.h
10660 --- linux-2.6.22.10/include/asm-cris/socket.h 2007-07-09 13:19:40 +0200
10661 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-cris/socket.h 2007-08-05 20:53:13 +0200
10663 #define SO_TIMESTAMPNS 35
10664 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10666 +#define SO_PEERTAG 36
10668 #endif /* _ASM_SOCKET_H */
10671 diff -NurpP --minimal linux-2.6.22.10/include/asm-frv/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-frv/socket.h
10672 --- linux-2.6.22.10/include/asm-frv/socket.h 2007-07-09 13:19:40 +0200
10673 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-frv/socket.h 2007-08-05 20:53:13 +0200
10675 #define SO_TIMESTAMPNS 35
10676 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10678 +#define SO_PEERTAG 36
10680 #endif /* _ASM_SOCKET_H */
10682 diff -NurpP --minimal linux-2.6.22.10/include/asm-generic/tlb.h linux-2.6.22.10-vs2.3.0.29/include/asm-generic/tlb.h
10683 --- linux-2.6.22.10/include/asm-generic/tlb.h 2006-11-30 21:19:31 +0100
10684 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-generic/tlb.h 2007-08-05 20:53:13 +0200
10686 #define _ASM_GENERIC__TLB_H
10688 #include <linux/swap.h>
10689 +#include <linux/vs_memory.h>
10690 #include <asm/pgalloc.h>
10691 #include <asm/tlbflush.h>
10693 diff -NurpP --minimal linux-2.6.22.10/include/asm-h8300/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-h8300/socket.h
10694 --- linux-2.6.22.10/include/asm-h8300/socket.h 2007-07-09 13:19:40 +0200
10695 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-h8300/socket.h 2007-08-05 20:53:13 +0200
10697 #define SO_TIMESTAMPNS 35
10698 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10700 +#define SO_PEERTAG 36
10702 #endif /* _ASM_SOCKET_H */
10703 diff -NurpP --minimal linux-2.6.22.10/include/asm-i386/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-i386/socket.h
10704 --- linux-2.6.22.10/include/asm-i386/socket.h 2007-07-09 13:19:42 +0200
10705 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-i386/socket.h 2007-08-05 20:53:13 +0200
10707 #define SO_TIMESTAMPNS 35
10708 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10710 +#define SO_PEERTAG 36
10712 #endif /* _ASM_SOCKET_H */
10713 diff -NurpP --minimal linux-2.6.22.10/include/asm-ia64/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-ia64/socket.h
10714 --- linux-2.6.22.10/include/asm-ia64/socket.h 2007-07-09 13:19:43 +0200
10715 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-ia64/socket.h 2007-08-05 20:53:13 +0200
10717 #define SO_TIMESTAMPNS 35
10718 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10720 +#define SO_PEERTAG 36
10722 #endif /* _ASM_IA64_SOCKET_H */
10723 diff -NurpP --minimal linux-2.6.22.10/include/asm-ia64/tlb.h linux-2.6.22.10-vs2.3.0.29/include/asm-ia64/tlb.h
10724 --- linux-2.6.22.10/include/asm-ia64/tlb.h 2006-09-20 16:58:40 +0200
10725 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-ia64/tlb.h 2007-08-05 20:53:13 +0200
10727 #include <linux/mm.h>
10728 #include <linux/pagemap.h>
10729 #include <linux/swap.h>
10730 +#include <linux/vs_memory.h>
10732 #include <asm/pgalloc.h>
10733 #include <asm/processor.h>
10734 diff -NurpP --minimal linux-2.6.22.10/include/asm-m32r/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-m32r/socket.h
10735 --- linux-2.6.22.10/include/asm-m32r/socket.h 2007-07-09 13:19:43 +0200
10736 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-m32r/socket.h 2007-08-05 20:53:13 +0200
10738 #define SO_TIMESTAMPNS 35
10739 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10741 +#define SO_PEERTAG 36
10743 #endif /* _ASM_M32R_SOCKET_H */
10744 diff -NurpP --minimal linux-2.6.22.10/include/asm-mips/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-mips/socket.h
10745 --- linux-2.6.22.10/include/asm-mips/socket.h 2007-07-09 13:19:44 +0200
10746 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-mips/socket.h 2007-08-05 20:53:13 +0200
10747 @@ -73,6 +73,8 @@ To add: #define SO_REUSEPORT 0x0200 /* A
10748 #define SO_TIMESTAMPNS 35
10749 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10751 +#define SO_PEERTAG 36
10755 /** sock_type - Socket types
10756 diff -NurpP --minimal linux-2.6.22.10/include/asm-parisc/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-parisc/socket.h
10757 --- linux-2.6.22.10/include/asm-parisc/socket.h 2007-07-09 13:19:44 +0200
10758 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-parisc/socket.h 2007-08-05 20:53:13 +0200
10761 #define SO_PEERSEC 0x401d
10762 #define SO_PASSSEC 0x401e
10763 +#define SO_PEERTAG 0x401f
10765 #endif /* _ASM_SOCKET_H */
10766 diff -NurpP --minimal linux-2.6.22.10/include/asm-powerpc/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/socket.h
10767 --- linux-2.6.22.10/include/asm-powerpc/socket.h 2007-07-09 13:19:44 +0200
10768 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/socket.h 2007-08-05 20:53:13 +0200
10770 #define SO_TIMESTAMPNS 35
10771 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10773 +#define SO_PEERTAG 36
10775 #endif /* _ASM_POWERPC_SOCKET_H */
10776 diff -NurpP --minimal linux-2.6.22.10/include/asm-powerpc/systbl.h linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/systbl.h
10777 --- linux-2.6.22.10/include/asm-powerpc/systbl.h 2007-07-09 13:19:44 +0200
10778 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/systbl.h 2007-08-05 20:53:13 +0200
10779 @@ -260,7 +260,7 @@ COMPAT_SYS_SPU(fstatfs64)
10780 SYSX(sys_ni_syscall, ppc_fadvise64_64, ppc_fadvise64_64)
10782 OLDSYS(debug_setcontext)
10783 -SYSCALL(ni_syscall)
10784 +SYSX(sys_vserver, sys32_vserver, sys_vserver)
10785 COMPAT_SYS(migrate_pages)
10787 COMPAT_SYS(get_mempolicy)
10788 diff -NurpP --minimal linux-2.6.22.10/include/asm-powerpc/unistd.h linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/unistd.h
10789 --- linux-2.6.22.10/include/asm-powerpc/unistd.h 2007-07-09 13:19:45 +0200
10790 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/unistd.h 2007-08-05 20:53:13 +0200
10791 @@ -275,7 +275,7 @@
10793 #define __NR_rtas 255
10794 #define __NR_sys_debug_setcontext 256
10795 -/* Number 257 is reserved for vserver */
10796 +#define __NR_vserver 257
10797 #define __NR_migrate_pages 258
10798 #define __NR_mbind 259
10799 #define __NR_get_mempolicy 260
10800 diff -NurpP --minimal linux-2.6.22.10/include/asm-s390/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-s390/socket.h
10801 --- linux-2.6.22.10/include/asm-s390/socket.h 2007-07-09 13:19:45 +0200
10802 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-s390/socket.h 2007-08-05 20:53:13 +0200
10804 #define SO_TIMESTAMPNS 35
10805 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10807 +#define SO_PEERTAG 36
10809 #endif /* _ASM_SOCKET_H */
10810 diff -NurpP --minimal linux-2.6.22.10/include/asm-s390/unistd.h linux-2.6.22.10-vs2.3.0.29/include/asm-s390/unistd.h
10811 --- linux-2.6.22.10/include/asm-s390/unistd.h 2007-07-09 13:19:45 +0200
10812 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-s390/unistd.h 2007-08-05 20:53:13 +0200
10813 @@ -202,7 +202,7 @@
10814 #define __NR_clock_gettime (__NR_timer_create+6)
10815 #define __NR_clock_getres (__NR_timer_create+7)
10816 #define __NR_clock_nanosleep (__NR_timer_create+8)
10817 -/* Number 263 is reserved for vserver */
10818 +#define __NR_vserver 263
10819 #define __NR_statfs64 265
10820 #define __NR_fstatfs64 266
10821 #define __NR_remap_file_pages 267
10822 diff -NurpP --minimal linux-2.6.22.10/include/asm-sh/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-sh/socket.h
10823 --- linux-2.6.22.10/include/asm-sh/socket.h 2007-07-09 13:19:45 +0200
10824 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sh/socket.h 2007-08-05 20:53:13 +0200
10826 #define SO_TIMESTAMPNS 35
10827 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10829 +#define SO_PEERTAG 36
10831 #endif /* __ASM_SH_SOCKET_H */
10832 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-sparc/socket.h
10833 --- linux-2.6.22.10/include/asm-sparc/socket.h 2007-07-09 13:19:54 +0200
10834 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc/socket.h 2007-08-05 20:53:13 +0200
10836 #define SO_TIMESTAMPNS 0x0021
10837 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10839 +#define SO_PEERTAG 36
10841 /* Security levels - as per NRL IPv6 - don't actually do anything */
10842 #define SO_SECURITY_AUTHENTICATION 0x5001
10843 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
10844 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc/unistd.h linux-2.6.22.10-vs2.3.0.29/include/asm-sparc/unistd.h
10845 --- linux-2.6.22.10/include/asm-sparc/unistd.h 2007-07-09 13:19:54 +0200
10846 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc/unistd.h 2007-08-05 20:53:13 +0200
10847 @@ -283,7 +283,7 @@
10848 #define __NR_timer_getoverrun 264
10849 #define __NR_timer_delete 265
10850 #define __NR_timer_create 266
10851 -/* #define __NR_vserver 267 Reserved for VSERVER */
10852 +#define __NR_vserver 267
10853 #define __NR_io_setup 268
10854 #define __NR_io_destroy 269
10855 #define __NR_io_submit 270
10856 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc64/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/socket.h
10857 --- linux-2.6.22.10/include/asm-sparc64/socket.h 2007-07-09 13:19:54 +0200
10858 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/socket.h 2007-08-05 20:53:13 +0200
10860 #define SO_TIMESTAMPNS 0x0021
10861 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10863 +#define SO_PEERTAG 0x0022
10865 /* Security levels - as per NRL IPv6 - don't actually do anything */
10866 #define SO_SECURITY_AUTHENTICATION 0x5001
10867 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
10868 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc64/tlb.h linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/tlb.h
10869 --- linux-2.6.22.10/include/asm-sparc64/tlb.h 2007-07-09 13:19:54 +0200
10870 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/tlb.h 2007-08-05 20:53:13 +0200
10873 #include <linux/swap.h>
10874 #include <linux/pagemap.h>
10875 +#include <linux/vs_memory.h>
10876 #include <asm/pgalloc.h>
10877 #include <asm/tlbflush.h>
10878 #include <asm/mmu_context.h>
10879 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc64/unistd.h linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/unistd.h
10880 --- linux-2.6.22.10/include/asm-sparc64/unistd.h 2007-07-09 13:19:54 +0200
10881 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/unistd.h 2007-08-05 20:53:13 +0200
10882 @@ -285,7 +285,7 @@
10883 #define __NR_timer_getoverrun 264
10884 #define __NR_timer_delete 265
10885 #define __NR_timer_create 266
10886 -/* #define __NR_vserver 267 Reserved for VSERVER */
10887 +#define __NR_vserver 267
10888 #define __NR_io_setup 268
10889 #define __NR_io_destroy 269
10890 #define __NR_io_submit 270
10891 diff -NurpP --minimal linux-2.6.22.10/include/asm-v850/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-v850/socket.h
10892 --- linux-2.6.22.10/include/asm-v850/socket.h 2007-07-09 13:19:55 +0200
10893 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-v850/socket.h 2007-08-05 20:53:13 +0200
10895 #define SO_TIMESTAMPNS 35
10896 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10898 +#define SO_PEERTAG 36
10900 #endif /* __V850_SOCKET_H__ */
10901 diff -NurpP --minimal linux-2.6.22.10/include/asm-x86_64/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-x86_64/socket.h
10902 --- linux-2.6.22.10/include/asm-x86_64/socket.h 2007-07-09 13:19:55 +0200
10903 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-x86_64/socket.h 2007-08-05 20:53:13 +0200
10905 #define SO_TIMESTAMPNS 35
10906 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10908 +#define SO_PEERTAG 36
10910 #endif /* _ASM_SOCKET_H */
10911 diff -NurpP --minimal linux-2.6.22.10/include/asm-x86_64/unistd.h linux-2.6.22.10-vs2.3.0.29/include/asm-x86_64/unistd.h
10912 --- linux-2.6.22.10/include/asm-x86_64/unistd.h 2007-07-09 13:19:55 +0200
10913 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-x86_64/unistd.h 2007-08-05 20:53:13 +0200
10914 @@ -532,7 +532,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
10915 #define __NR_utimes 235
10916 __SYSCALL(__NR_utimes, sys_utimes)
10917 #define __NR_vserver 236
10918 -__SYSCALL(__NR_vserver, sys_ni_syscall)
10919 +__SYSCALL(__NR_vserver, sys_vserver)
10920 #define __NR_mbind 237
10921 __SYSCALL(__NR_mbind, sys_mbind)
10922 #define __NR_set_mempolicy 238
10923 diff -NurpP --minimal linux-2.6.22.10/include/asm-xtensa/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-xtensa/socket.h
10924 --- linux-2.6.22.10/include/asm-xtensa/socket.h 2007-07-09 13:19:55 +0200
10925 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-xtensa/socket.h 2007-08-05 20:53:13 +0200
10927 #define SO_TIMESTAMPNS 35
10928 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10930 +#define SO_PEERTAG 36
10932 #endif /* _XTENSA_SOCKET_H */
10933 diff -NurpP --minimal linux-2.6.22.10/include/linux/Kbuild linux-2.6.22.10-vs2.3.0.29/include/linux/Kbuild
10934 --- linux-2.6.22.10/include/linux/Kbuild 2007-10-30 01:57:14 +0100
10935 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/Kbuild 2007-09-30 14:58:01 +0200
10936 @@ -351,3 +351,6 @@ unifdef-y += xattr.h
10937 unifdef-y += xfrm.h
10939 objhdr-y += version.h
10941 +header-y += vserver/
10943 diff -NurpP --minimal linux-2.6.22.10/include/linux/capability.h linux-2.6.22.10-vs2.3.0.29/include/linux/capability.h
10944 --- linux-2.6.22.10/include/linux/capability.h 2007-07-09 13:19:55 +0200
10945 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/capability.h 2007-08-05 20:53:13 +0200
10946 @@ -237,6 +237,7 @@ typedef __u32 kernel_cap_t;
10947 arbitrary SCSI commands */
10948 /* Allow setting encryption key on loopback filesystem */
10949 /* Allow setting zone reclaim policy */
10950 +/* Allow the selection of a security context */
10952 #define CAP_SYS_ADMIN 21
10954 @@ -290,6 +291,11 @@ typedef __u32 kernel_cap_t;
10956 #define CAP_AUDIT_CONTROL 30
10958 +/* Allow context manipulations */
10959 +/* Allow changing context info on files */
10961 +#define CAP_CONTEXT 31
10966 diff -NurpP --minimal linux-2.6.22.10/include/linux/devpts_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/devpts_fs.h
10967 --- linux-2.6.22.10/include/linux/devpts_fs.h 2004-08-14 12:55:59 +0200
10968 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/devpts_fs.h 2007-10-06 18:19:52 +0200
10969 @@ -30,5 +30,4 @@ static inline void devpts_pty_kill(int n
10974 #endif /* _LINUX_DEVPTS_FS_H */
10975 diff -NurpP --minimal linux-2.6.22.10/include/linux/ext2_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/ext2_fs.h
10976 --- linux-2.6.22.10/include/linux/ext2_fs.h 2006-11-30 21:19:37 +0100
10977 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/ext2_fs.h 2007-10-05 15:07:22 +0200
10978 @@ -188,6 +188,8 @@ struct ext2_group_desc
10979 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
10980 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
10981 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
10982 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
10983 +#define EXT2_IUNLINK_FL FS_IUNLINK_FL /* Immutable unlink */
10984 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
10986 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
10987 @@ -244,7 +246,7 @@ struct ext2_inode {
10989 __u8 l_i_frag; /* Fragment number */
10990 __u8 l_i_fsize; /* Fragment size */
10992 + __u16 l_i_tag; /* Context Tag */
10993 __le16 l_i_uid_high; /* these 2 fields */
10994 __le16 l_i_gid_high; /* were reserved2[0] */
10995 __u32 l_i_reserved2;
10996 @@ -276,6 +278,7 @@ struct ext2_inode {
10997 #define i_gid_low i_gid
10998 #define i_uid_high osd2.linux2.l_i_uid_high
10999 #define i_gid_high osd2.linux2.l_i_gid_high
11000 +#define i_raw_tag osd2.linux2.l_i_tag
11001 #define i_reserved2 osd2.linux2.l_i_reserved2
11004 @@ -317,8 +320,9 @@ struct ext2_inode {
11005 #define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */
11006 #define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */
11007 #define EXT2_MOUNT_XIP 0x010000 /* Execute in place */
11008 -#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
11009 -#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
11010 +#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
11011 +#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
11012 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11015 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
11016 diff -NurpP --minimal linux-2.6.22.10/include/linux/ext3_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/ext3_fs.h
11017 --- linux-2.6.22.10/include/linux/ext3_fs.h 2007-07-09 13:19:56 +0200
11018 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/ext3_fs.h 2007-08-05 20:53:13 +0200
11019 @@ -177,6 +177,8 @@ struct ext3_group_desc
11020 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
11021 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
11022 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11023 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11024 +#define EXT3_IUNLINK_FL 0x08000000 /* Immutable unlink */
11025 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
11027 #define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
11028 @@ -296,7 +298,7 @@ struct ext3_inode {
11030 __u8 l_i_frag; /* Fragment number */
11031 __u8 l_i_fsize; /* Fragment size */
11033 + __u16 l_i_tag; /* Context Tag */
11034 __le16 l_i_uid_high; /* these 2 fields */
11035 __le16 l_i_gid_high; /* were reserved2[0] */
11036 __u32 l_i_reserved2;
11037 @@ -330,6 +332,7 @@ struct ext3_inode {
11038 #define i_gid_low i_gid
11039 #define i_uid_high osd2.linux2.l_i_uid_high
11040 #define i_gid_high osd2.linux2.l_i_gid_high
11041 +#define i_raw_tag osd2.linux2.l_i_tag
11042 #define i_reserved2 osd2.linux2.l_i_reserved2
11044 #elif defined(__GNU__)
11045 @@ -384,6 +387,7 @@ struct ext3_inode {
11046 #define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
11047 #define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
11048 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
11049 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11051 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
11052 #ifndef _LINUX_EXT2_FS_H
11053 @@ -812,6 +816,7 @@ struct buffer_head * ext3_bread (handle_
11054 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
11055 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
11056 int create, int extend_disksize);
11057 +extern int ext3_sync_flags(struct inode *inode);
11059 extern void ext3_read_inode (struct inode *);
11060 extern int ext3_write_inode (struct inode *, int);
11061 diff -NurpP --minimal linux-2.6.22.10/include/linux/ext4_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/ext4_fs.h
11062 --- linux-2.6.22.10/include/linux/ext4_fs.h 2007-07-09 13:19:56 +0200
11063 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/ext4_fs.h 2007-08-05 20:53:13 +0200
11064 @@ -189,8 +189,10 @@ struct ext4_group_desc
11065 #define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
11066 #define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
11067 #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11068 -#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
11069 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
11070 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11071 +#define EXT4_IUNLINK_FL 0x08000000 /* Immutable unlink */
11072 +#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
11074 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
11075 #define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
11076 @@ -312,7 +314,8 @@ struct ext4_inode {
11077 __le16 l_i_file_acl_high;
11078 __le16 l_i_uid_high; /* these 2 fields */
11079 __le16 l_i_gid_high; /* were reserved2[0] */
11080 - __u32 l_i_reserved2;
11081 + __u16 l_i_tag; /* Context Tag */
11082 + __u16 l_i_reserved2;
11085 __u8 h_i_frag; /* Fragment number */
11086 @@ -344,6 +347,7 @@ struct ext4_inode {
11087 #define i_gid_low i_gid
11088 #define i_uid_high osd2.linux2.l_i_uid_high
11089 #define i_gid_high osd2.linux2.l_i_gid_high
11090 +#define i_raw_tag osd2.linux2.l_i_tag
11091 #define i_reserved2 osd2.linux2.l_i_reserved2
11093 #elif defined(__GNU__)
11094 @@ -400,6 +404,7 @@ struct ext4_inode {
11095 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
11096 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
11097 #define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
11098 +#define EXT4_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11100 /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
11101 #ifndef _LINUX_EXT2_FS_H
11102 @@ -850,6 +855,7 @@ struct buffer_head * ext4_bread (handle_
11103 int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
11104 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
11105 int create, int extend_disksize);
11106 +extern int ext4_sync_flags(struct inode *inode);
11108 extern void ext4_read_inode (struct inode *);
11109 extern int ext4_write_inode (struct inode *, int);
11110 diff -NurpP --minimal linux-2.6.22.10/include/linux/fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/fs.h
11111 --- linux-2.6.22.10/include/linux/fs.h 2007-07-09 13:19:56 +0200
11112 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/fs.h 2007-10-20 00:01:05 +0200
11113 @@ -123,6 +123,8 @@ extern int dir_notify_enable;
11114 #define MS_SLAVE (1<<19) /* change to slave */
11115 #define MS_SHARED (1<<20) /* change to shared */
11116 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
11117 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
11118 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
11119 #define MS_ACTIVE (1<<30)
11120 #define MS_NOUSER (1<<31)
11122 @@ -149,6 +151,8 @@ extern int dir_notify_enable;
11123 #define S_NOCMTIME 128 /* Do not update file c/mtime */
11124 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
11125 #define S_PRIVATE 512 /* Inode is fs-internal */
11126 +#define S_BARRIER 1024 /* Barrier for chroot() */
11127 +#define S_IUNLINK 2048 /* Immutable unlink */
11130 * Note that nosuid etc flags are inode-specific: setting some file-system
11131 @@ -165,24 +169,36 @@ extern int dir_notify_enable;
11133 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
11135 -#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
11136 +#define IS_RDONLY(inode) __IS_FLG(inode, MS_RDONLY)
11137 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
11138 ((inode)->i_flags & S_SYNC))
11139 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
11140 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
11141 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
11142 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
11143 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
11144 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
11146 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
11147 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
11148 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
11149 +#define IS_IUNLINK(inode) ((inode)->i_flags & S_IUNLINK)
11150 +#define IS_IXORUNLINK(inode) ((IS_IUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
11151 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
11153 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_flags & S_BARRIER))
11154 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
11155 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
11156 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
11157 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
11159 +#ifdef CONFIG_VSERVER_COWBL
11160 +# define IS_COW(inode) (IS_IUNLINK(inode) && IS_IMMUTABLE(inode))
11161 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
11163 +# define IS_COW(inode) (0)
11164 +# define IS_COW_LINK(inode) (0)
11167 /* the read-only stuff doesn't really belong here, but any other place is
11168 probably as bad and I don't want to create yet another include file. */
11170 @@ -256,12 +272,13 @@ extern int dir_notify_enable;
11171 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11172 #define FS_EXTENT_FL 0x00080000 /* Extents */
11173 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
11174 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11175 +#define FS_IUNLINK_FL 0x08000000 /* Immutable unlink */
11176 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
11178 #define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
11179 #define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
11182 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
11183 #define SYNC_FILE_RANGE_WRITE 2
11184 #define SYNC_FILE_RANGE_WAIT_AFTER 4
11185 @@ -327,6 +344,7 @@ typedef void (dio_iodone_t)(struct kiocb
11186 #define ATTR_KILL_SUID 2048
11187 #define ATTR_KILL_SGID 4096
11188 #define ATTR_FILE 8192
11189 +#define ATTR_TAG 16384
11192 * This is the Inode Attributes structure, used for notify_change(). It
11193 @@ -342,6 +360,7 @@ struct iattr {
11199 struct timespec ia_atime;
11200 struct timespec ia_mtime;
11201 @@ -355,6 +374,9 @@ struct iattr {
11202 struct file *ia_file;
11205 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
11206 +#define ATTR_FLAG_IUNLINK 1024 /* Immutable unlink */
11209 * Includes for diskquotas.
11211 @@ -537,7 +559,9 @@ struct inode {
11212 unsigned int i_nlink;
11218 unsigned long i_version;
11220 #ifdef __NEED_I_SIZE_ORDERED
11221 @@ -672,12 +696,12 @@ static inline void i_size_write(struct i
11223 static inline unsigned iminor(const struct inode *inode)
11225 - return MINOR(inode->i_rdev);
11226 + return MINOR(inode->i_mdev);
11229 static inline unsigned imajor(const struct inode *inode)
11231 - return MAJOR(inode->i_rdev);
11232 + return MAJOR(inode->i_mdev);
11235 extern struct block_device *I_BDEV(struct inode *inode);
11236 @@ -728,6 +752,7 @@ struct file {
11238 struct fown_struct f_owner;
11239 unsigned int f_uid, f_gid;
11241 struct file_ra_state f_ra;
11243 unsigned long f_version;
11244 @@ -811,6 +836,7 @@ struct file_lock {
11245 unsigned char fl_type;
11250 struct fasync_struct * fl_fasync; /* for lease break notifications */
11251 unsigned long fl_break_time; /* for nonblocking lease breaks */
11252 @@ -993,12 +1019,12 @@ extern void unlock_super(struct super_bl
11254 extern int vfs_permission(struct nameidata *, int);
11255 extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
11256 -extern int vfs_mkdir(struct inode *, struct dentry *, int);
11257 -extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
11258 -extern int vfs_symlink(struct inode *, struct dentry *, const char *, int);
11259 -extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
11260 -extern int vfs_rmdir(struct inode *, struct dentry *);
11261 -extern int vfs_unlink(struct inode *, struct dentry *);
11262 +extern int vfs_mkdir(struct inode *, struct dentry *, int, struct nameidata *);
11263 +extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t, struct nameidata *);
11264 +extern int vfs_symlink(struct inode *, struct dentry *, const char *, int, struct nameidata *);
11265 +extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct nameidata *);
11266 +extern int vfs_rmdir(struct inode *, struct dentry *, struct nameidata *);
11267 +extern int vfs_unlink(struct inode *, struct dentry *, struct nameidata *);
11268 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
11271 @@ -1138,6 +1164,7 @@ struct inode_operations {
11272 ssize_t (*listxattr) (struct dentry *, char *, size_t);
11273 int (*removexattr) (struct dentry *, const char *);
11274 void (*truncate_range)(struct inode *, loff_t, loff_t);
11275 + int (*sync_flags) (struct inode *);
11279 @@ -1153,6 +1180,7 @@ extern ssize_t vfs_readv(struct file *,
11280 unsigned long, loff_t *);
11281 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
11282 unsigned long, loff_t *);
11283 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
11286 * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
11287 @@ -1898,6 +1926,7 @@ extern int dcache_dir_open(struct inode
11288 extern int dcache_dir_close(struct inode *, struct file *);
11289 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
11290 extern int dcache_readdir(struct file *, void *, filldir_t);
11291 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
11292 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
11293 extern int simple_statfs(struct dentry *, struct kstatfs *);
11294 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
11295 diff -NurpP --minimal linux-2.6.22.10/include/linux/init_task.h linux-2.6.22.10-vs2.3.0.29/include/linux/init_task.h
11296 --- linux-2.6.22.10/include/linux/init_task.h 2007-07-09 13:19:56 +0200
11297 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/init_task.h 2007-08-05 20:53:13 +0200
11298 @@ -169,6 +169,10 @@ extern struct group_info init_groups;
11300 INIT_TRACE_IRQFLAGS \
11303 + .vx_info = NULL, \
11305 + .nx_info = NULL, \
11309 diff -NurpP --minimal linux-2.6.22.10/include/linux/ipc.h linux-2.6.22.10-vs2.3.0.29/include/linux/ipc.h
11310 --- linux-2.6.22.10/include/linux/ipc.h 2007-07-09 13:19:56 +0200
11311 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/ipc.h 2007-08-05 20:53:13 +0200
11312 @@ -63,6 +63,7 @@ struct kern_ipc_perm
11320 diff -NurpP --minimal linux-2.6.22.10/include/linux/jffs2.h linux-2.6.22.10-vs2.3.0.29/include/linux/jffs2.h
11321 --- linux-2.6.22.10/include/linux/jffs2.h 2006-11-30 21:19:38 +0100
11322 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/jffs2.h 2007-10-05 15:07:22 +0200
11323 @@ -82,12 +82,36 @@
11324 //#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
11327 -#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
11328 +#define JFFS2_INO_FLAG_PREREAD 0x01 /* Do read_inode() for this one at
11329 mount time, don't wait for it to
11331 -#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
11332 +#define JFFS2_INO_FLAG_USERCOMPR 0x02 /* User has requested a specific
11333 compression type */
11335 +#define JFFS2_INO_FLAG_IMMUTABLE 0x10 /* immutable node */
11336 +#define JFFS2_INO_FLAG_IUNLINK 0x20 /* immutable unlink */
11337 +#define JFFS2_INO_FLAG_BARRIER 0x40 /* barrier */
11339 +#define JFFS2_USER_VISIBLE 0x10
11340 +#define JFFS2_USER_MODIFIABLE 0x10
11345 +#define JFFS2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11347 +#define clear_opt(o, opt) o &= ~JFFS2_MOUNT_##opt
11348 +#define set_opt(o, opt) o |= JFFS2_MOUNT_##opt
11351 + * Maximal mount counts between two filesystem checks
11353 +#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
11354 +#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
11357 + * Behaviour when detecting errors
11360 /* These can go once we've made sure we've caught all uses without
11362 @@ -97,7 +121,7 @@ typedef struct {
11363 } __attribute__((packed)) jint32_t;
11368 } __attribute__((packed)) jmode_t;
11371 @@ -145,7 +169,8 @@ struct jffs2_raw_inode
11373 jint32_t ino; /* Inode number. */
11374 jint32_t version; /* Version number. */
11375 - jmode_t mode; /* The file's type or mode. */
11376 + jmode_t mode; /* The file's type or mode. */
11377 + jint16_t tag; /* context tagging */
11378 jint16_t uid; /* The file's owner. */
11379 jint16_t gid; /* The file's group. */
11380 jint32_t isize; /* Total resultant size of this inode (used for truncations) */
11381 diff -NurpP --minimal linux-2.6.22.10/include/linux/loop.h linux-2.6.22.10-vs2.3.0.29/include/linux/loop.h
11382 --- linux-2.6.22.10/include/linux/loop.h 2007-07-09 13:19:56 +0200
11383 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/loop.h 2007-08-05 20:53:13 +0200
11384 @@ -45,6 +45,7 @@ struct loop_device {
11385 struct loop_func_table *lo_encryption;
11387 uid_t lo_key_owner; /* Who set the key */
11389 int (*ioctl)(struct loop_device *, int cmd,
11390 unsigned long arg);
11392 diff -NurpP --minimal linux-2.6.22.10/include/linux/magic.h linux-2.6.22.10-vs2.3.0.29/include/linux/magic.h
11393 --- linux-2.6.22.10/include/linux/magic.h 2007-07-09 13:19:56 +0200
11394 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/magic.h 2007-10-06 18:19:33 +0200
11397 #define ADFS_SUPER_MAGIC 0xadf5
11398 #define AFFS_SUPER_MAGIC 0xadff
11399 -#define AFS_SUPER_MAGIC 0x5346414F
11400 +#define AFS_SUPER_MAGIC 0x5346414F
11401 #define AUTOFS_SUPER_MAGIC 0x0187
11402 #define CODA_SUPER_MAGIC 0x73757245
11403 #define EFS_SUPER_MAGIC 0x414A53
11405 #define NFS_SUPER_MAGIC 0x6969
11406 #define OPENPROM_SUPER_MAGIC 0x9fa1
11407 #define PROC_SUPER_MAGIC 0x9fa0
11408 +#define DEVPTS_SUPER_MAGIC 0x1cd1
11409 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
11411 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
11412 diff -NurpP --minimal linux-2.6.22.10/include/linux/major.h linux-2.6.22.10-vs2.3.0.29/include/linux/major.h
11413 --- linux-2.6.22.10/include/linux/major.h 2007-07-09 13:19:56 +0200
11414 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/major.h 2007-08-05 20:53:13 +0200
11416 #define HD_MAJOR IDE0_MAJOR
11417 #define PTY_SLAVE_MAJOR 3
11418 #define TTY_MAJOR 4
11419 +#define VROOT_MAJOR 4
11420 #define TTYAUX_MAJOR 5
11422 #define VCS_MAJOR 7
11423 diff -NurpP --minimal linux-2.6.22.10/include/linux/mount.h linux-2.6.22.10-vs2.3.0.29/include/linux/mount.h
11424 --- linux-2.6.22.10/include/linux/mount.h 2007-07-09 13:19:56 +0200
11425 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/mount.h 2007-09-05 02:29:04 +0200
11426 @@ -28,6 +28,9 @@ struct mnt_namespace;
11427 #define MNT_NOATIME 0x08
11428 #define MNT_NODIRATIME 0x10
11429 #define MNT_RELATIME 0x20
11430 +#define MNT_RDONLY 0x40
11432 +#define MNT_IS_RDONLY(m) ((m) && ((m)->mnt_flags & MNT_RDONLY))
11434 #define MNT_SHRINKABLE 0x100
11436 @@ -35,6 +38,10 @@ struct mnt_namespace;
11437 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
11438 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
11440 +#define MNT_TAGID 0x10000
11441 +#define MNT_NOTAG 0x20000
11442 +#define MNT_NOTAGCHECK 0x40000
11445 struct list_head mnt_hash;
11446 struct vfsmount *mnt_parent; /* fs we are mounted on */
11447 @@ -61,6 +68,7 @@ struct vfsmount {
11448 atomic_t mnt_count;
11449 int mnt_expiry_mark; /* true if marked for expiry */
11451 + tag_t mnt_tag; /* tagging used for vfsmount */
11454 static inline struct vfsmount *mntget(struct vfsmount *mnt)
11455 diff -NurpP --minimal linux-2.6.22.10/include/linux/net.h linux-2.6.22.10-vs2.3.0.29/include/linux/net.h
11456 --- linux-2.6.22.10/include/linux/net.h 2007-07-09 13:19:56 +0200
11457 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/net.h 2007-08-05 20:53:13 +0200
11458 @@ -63,6 +63,7 @@ typedef enum {
11459 #define SOCK_NOSPACE 2
11460 #define SOCK_PASSCRED 3
11461 #define SOCK_PASSSEC 4
11462 +#define SOCK_USER_SOCKET 5
11464 #ifndef ARCH_HAS_SOCKET_TYPES
11466 diff -NurpP --minimal linux-2.6.22.10/include/linux/nfs_mount.h linux-2.6.22.10-vs2.3.0.29/include/linux/nfs_mount.h
11467 --- linux-2.6.22.10/include/linux/nfs_mount.h 2007-07-09 13:20:00 +0200
11468 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/nfs_mount.h 2007-08-05 20:53:13 +0200
11469 @@ -62,6 +62,7 @@ struct nfs_mount_data {
11470 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
11471 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
11472 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
11473 -#define NFS_MOUNT_FLAGMASK 0xFFFF
11474 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
11475 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
11478 diff -NurpP --minimal linux-2.6.22.10/include/linux/nsproxy.h linux-2.6.22.10-vs2.3.0.29/include/linux/nsproxy.h
11479 --- linux-2.6.22.10/include/linux/nsproxy.h 2007-07-09 13:20:00 +0200
11480 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/nsproxy.h 2007-08-05 20:53:13 +0200
11483 #include <linux/spinlock.h>
11484 #include <linux/sched.h>
11485 +#include <linux/vserver/debug.h>
11487 struct mnt_namespace;
11488 struct uts_namespace;
11489 @@ -32,26 +33,46 @@ struct nsproxy {
11490 extern struct nsproxy init_nsproxy;
11492 int copy_namespaces(int flags, struct task_struct *tsk);
11493 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
11494 void get_task_namespaces(struct task_struct *tsk);
11495 void free_nsproxy(struct nsproxy *ns);
11496 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
11497 struct fs_struct *);
11499 -static inline void put_nsproxy(struct nsproxy *ns)
11500 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
11502 +static inline void __get_nsproxy(struct nsproxy *ns,
11503 + const char *_file, int _line)
11505 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
11506 + ns, atomic_read(&ns->count), _file, _line);
11507 + atomic_inc(&ns->count);
11510 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
11512 +static inline void __put_nsproxy(struct nsproxy *ns,
11513 + const char *_file, int _line)
11515 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
11516 + ns, atomic_read(&ns->count), _file, _line);
11517 if (atomic_dec_and_test(&ns->count)) {
11522 -static inline void exit_task_namespaces(struct task_struct *p)
11523 +#define exit_task_namespaces(p) __exit_task_namespaces(p, __FILE__, __LINE__)
11525 +static inline void __exit_task_namespaces(struct task_struct *p,
11526 + const char *_file, int _line)
11528 struct nsproxy *ns = p->nsproxy;
11534 + __put_nsproxy(ns, _file, _line);
11539 diff -NurpP --minimal linux-2.6.22.10/include/linux/pid.h linux-2.6.22.10-vs2.3.0.29/include/linux/pid.h
11540 --- linux-2.6.22.10/include/linux/pid.h 2007-07-09 13:20:00 +0200
11541 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/pid.h 2007-08-05 20:53:13 +0200
11542 @@ -8,7 +8,8 @@ enum pid_type
11552 diff -NurpP --minimal linux-2.6.22.10/include/linux/proc_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/proc_fs.h
11553 --- linux-2.6.22.10/include/linux/proc_fs.h 2007-07-09 13:20:00 +0200
11554 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/proc_fs.h 2007-08-05 20:53:13 +0200
11555 @@ -54,6 +54,7 @@ struct proc_dir_entry {
11561 const struct inode_operations *proc_iops;
11562 const struct file_operations *proc_fops;
11563 @@ -246,13 +247,20 @@ static inline void kclist_add(struct kco
11564 extern void kclist_add(struct kcore_list *, void *, size_t);
11571 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
11572 int (*proc_read)(struct task_struct *task, char *page);
11573 + int (*proc_vs_read)(char *page);
11574 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
11575 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
11578 struct proc_inode {
11583 struct proc_dir_entry *pde;
11584 diff -NurpP --minimal linux-2.6.22.10/include/linux/reiserfs_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/reiserfs_fs.h
11585 --- linux-2.6.22.10/include/linux/reiserfs_fs.h 2007-05-02 19:25:34 +0200
11586 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/reiserfs_fs.h 2007-08-05 20:53:13 +0200
11587 @@ -821,6 +821,10 @@ struct stat_data_v1 {
11588 #define REISERFS_COMPR_FL FS_COMPR_FL
11589 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
11591 +/* unfortunately reiserfs sdattr is only 16 bit */
11592 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
11593 +#define REISERFS_IUNLINK_FL (FS_IUNLINK_FL >> 16)
11595 /* persistent flags that file inherits from the parent directory */
11596 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
11597 REISERFS_SYNC_FL | \
11598 @@ -830,6 +834,9 @@ struct stat_data_v1 {
11599 REISERFS_COMPR_FL | \
11600 REISERFS_NOTAIL_FL )
11602 +#define REISERFS_FL_USER_VISIBLE 0x80FF
11603 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
11605 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
11608 @@ -1901,6 +1908,7 @@ static inline void reiserfs_update_sd(st
11609 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
11610 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
11611 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
11612 +int reiserfs_sync_flags(struct inode *inode);
11615 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
11616 diff -NurpP --minimal linux-2.6.22.10/include/linux/reiserfs_fs_sb.h linux-2.6.22.10-vs2.3.0.29/include/linux/reiserfs_fs_sb.h
11617 --- linux-2.6.22.10/include/linux/reiserfs_fs_sb.h 2007-07-09 13:20:00 +0200
11618 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/reiserfs_fs_sb.h 2007-08-05 20:53:13 +0200
11619 @@ -458,6 +458,7 @@ enum reiserfs_mount_options {
11621 REISERFS_BARRIER_NONE,
11622 REISERFS_BARRIER_FLUSH,
11625 /* Actions on error */
11626 REISERFS_ERROR_PANIC,
11627 diff -NurpP --minimal linux-2.6.22.10/include/linux/sched.h linux-2.6.22.10-vs2.3.0.29/include/linux/sched.h
11628 --- linux-2.6.22.10/include/linux/sched.h 2007-07-09 13:20:01 +0200
11629 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sched.h 2007-10-04 23:47:06 +0200
11631 #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
11632 #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
11633 #define CLONE_NEWIPC 0x08000000 /* New ipcs */
11634 +#define CLONE_KTHREAD 0x10000000 /* clone a kernel thread */
11637 * Scheduling policies
11638 @@ -94,7 +95,7 @@ struct bio;
11639 * List of flags we want to share for kernel threads,
11640 * if only because they are not used by them anyway.
11642 -#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
11643 +#define CLONE_KERNEL (CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_KTHREAD)
11646 * These are the constant used to fake the fixed-point load-average
11647 @@ -146,12 +147,13 @@ extern unsigned long weighted_cpuload(co
11648 #define TASK_UNINTERRUPTIBLE 2
11649 #define TASK_STOPPED 4
11650 #define TASK_TRACED 8
11651 +#define TASK_ONHOLD 16
11652 /* in tsk->exit_state */
11653 -#define EXIT_ZOMBIE 16
11654 -#define EXIT_DEAD 32
11655 +#define EXIT_ZOMBIE 32
11656 +#define EXIT_DEAD 64
11657 /* in tsk->state again */
11658 -#define TASK_NONINTERACTIVE 64
11659 -#define TASK_DEAD 128
11660 +#define TASK_NONINTERACTIVE 128
11661 +#define TASK_DEAD 256
11663 #define __set_task_state(tsk, state_value) \
11664 do { (tsk)->state = (state_value); } while (0)
11665 @@ -287,27 +289,30 @@ extern void arch_unmap_area_topdown(stru
11666 * The mm counters are not protected by its page_table_lock,
11667 * so must be incremented atomically.
11669 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
11670 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
11671 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
11672 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
11673 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
11674 typedef atomic_long_t mm_counter_t;
11675 +#define __set_mm_counter(mm, member, value) \
11676 + atomic_long_set(&(mm)->_##member, value)
11677 +#define get_mm_counter(mm, member) \
11678 + ((unsigned long)atomic_long_read(&(mm)->_##member))
11680 #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11682 * The mm counters are protected by its page_table_lock,
11683 * so can be incremented directly.
11685 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
11686 -#define get_mm_counter(mm, member) ((mm)->_##member)
11687 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
11688 -#define inc_mm_counter(mm, member) (mm)->_##member++
11689 -#define dec_mm_counter(mm, member) (mm)->_##member--
11690 typedef unsigned long mm_counter_t;
11691 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
11692 +#define get_mm_counter(mm, member) ((mm)->_##member)
11694 #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11696 +#define set_mm_counter(mm, member, value) \
11697 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
11698 +#define add_mm_counter(mm, member, value) \
11699 + vx_ ## member ## pages_add((mm), (value))
11700 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
11701 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
11703 #define get_mm_rss(mm) \
11704 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
11705 #define update_hiwater_rss(mm) do { \
11706 @@ -365,6 +370,7 @@ struct mm_struct {
11708 /* Architecture-specific MM context */
11709 mm_context_t context;
11710 + struct vx_info *mm_vx_info;
11712 /* Swap token stuff */
11714 @@ -570,9 +576,10 @@ struct user_struct {
11715 /* Hash table maintenance information */
11716 struct list_head uidhash_list;
11721 -extern struct user_struct *find_user(uid_t);
11722 +extern struct user_struct *find_user(xid_t, uid_t);
11724 extern struct user_struct root_user;
11725 #define INIT_USER (&root_user)
11726 @@ -969,6 +976,15 @@ struct task_struct {
11729 struct audit_context *audit_context;
11731 +/* vserver context data */
11732 + struct vx_info *vx_info;
11733 + struct nx_info *nx_info;
11741 /* Thread group tracking */
11742 @@ -1290,12 +1306,16 @@ extern struct task_struct init_task;
11744 extern struct mm_struct init_mm;
11746 -#define find_task_by_pid(nr) find_task_by_pid_type(PIDTYPE_PID, nr)
11747 +#define find_task_by_real_pid(nr) \
11748 + find_task_by_pid_type(PIDTYPE_REALPID, nr)
11749 +#define find_task_by_pid(nr) \
11750 + find_task_by_pid_type(PIDTYPE_PID, nr)
11752 extern struct task_struct *find_task_by_pid_type(int type, int pid);
11753 extern void __set_special_pids(pid_t session, pid_t pgrp);
11755 /* per-UID process charging. */
11756 -extern struct user_struct * alloc_uid(uid_t);
11757 +extern struct user_struct * alloc_uid(xid_t, uid_t);
11758 static inline struct user_struct *get_uid(struct user_struct *u)
11760 atomic_inc(&u->__count);
11761 diff -NurpP --minimal linux-2.6.22.10/include/linux/shmem_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/shmem_fs.h
11762 --- linux-2.6.22.10/include/linux/shmem_fs.h 2006-11-30 21:19:39 +0100
11763 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/shmem_fs.h 2007-08-05 20:53:13 +0200
11766 #define SHMEM_NR_DIRECT 16
11768 +#define TMPFS_SUPER_MAGIC 0x01021994
11771 struct shmem_inode_info {
11773 unsigned long flags;
11774 diff -NurpP --minimal linux-2.6.22.10/include/linux/stat.h linux-2.6.22.10-vs2.3.0.29/include/linux/stat.h
11775 --- linux-2.6.22.10/include/linux/stat.h 2007-07-09 13:20:01 +0200
11776 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/stat.h 2007-08-05 20:53:13 +0200
11777 @@ -66,6 +66,7 @@ struct kstat {
11778 unsigned int nlink;
11784 struct timespec atime;
11785 diff -NurpP --minimal linux-2.6.22.10/include/linux/sunrpc/auth.h linux-2.6.22.10-vs2.3.0.29/include/linux/sunrpc/auth.h
11786 --- linux-2.6.22.10/include/linux/sunrpc/auth.h 2006-11-30 21:19:40 +0100
11787 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sunrpc/auth.h 2007-08-05 20:53:13 +0200
11793 struct group_info *group_info;
11796 diff -NurpP --minimal linux-2.6.22.10/include/linux/sunrpc/clnt.h linux-2.6.22.10-vs2.3.0.29/include/linux/sunrpc/clnt.h
11797 --- linux-2.6.22.10/include/linux/sunrpc/clnt.h 2007-07-09 13:20:01 +0200
11798 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sunrpc/clnt.h 2007-08-05 20:53:13 +0200
11799 @@ -43,7 +43,8 @@ struct rpc_clnt {
11800 unsigned int cl_softrtry : 1,/* soft timeouts */
11801 cl_intr : 1,/* interruptible */
11802 cl_discrtry : 1,/* disconnect before retry */
11803 - cl_autobind : 1;/* use getport() */
11804 + cl_autobind : 1,/* use getport() */
11805 + cl_tag : 1;/* context tagging */
11807 struct rpc_rtt * cl_rtt; /* RTO estimator data */
11809 diff -NurpP --minimal linux-2.6.22.10/include/linux/syscalls.h linux-2.6.22.10-vs2.3.0.29/include/linux/syscalls.h
11810 --- linux-2.6.22.10/include/linux/syscalls.h 2007-07-09 13:20:01 +0200
11811 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/syscalls.h 2007-08-05 20:53:13 +0200
11812 @@ -294,6 +294,8 @@ asmlinkage long sys_symlink(const char _
11813 asmlinkage long sys_unlink(const char __user *pathname);
11814 asmlinkage long sys_rename(const char __user *oldname,
11815 const char __user *newname);
11816 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
11818 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
11819 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
11821 diff -NurpP --minimal linux-2.6.22.10/include/linux/sysctl.h linux-2.6.22.10-vs2.3.0.29/include/linux/sysctl.h
11822 --- linux-2.6.22.10/include/linux/sysctl.h 2007-07-09 13:20:01 +0200
11823 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sysctl.h 2007-08-05 20:53:13 +0200
11824 @@ -106,6 +106,7 @@ enum
11825 KERN_CAP_BSET=14, /* int: capability bounding set */
11826 KERN_PANIC=15, /* int: panic timeout */
11827 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
11828 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
11830 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
11831 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
11832 diff -NurpP --minimal linux-2.6.22.10/include/linux/sysfs.h linux-2.6.22.10-vs2.3.0.29/include/linux/sysfs.h
11833 --- linux-2.6.22.10/include/linux/sysfs.h 2007-07-09 13:20:01 +0200
11834 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sysfs.h 2007-08-05 20:53:13 +0200
11836 #include <linux/list.h>
11837 #include <asm/atomic.h>
11839 +#define SYSFS_SUPER_MAGIC 0x62656572
11844 diff -NurpP --minimal linux-2.6.22.10/include/linux/time.h linux-2.6.22.10-vs2.3.0.29/include/linux/time.h
11845 --- linux-2.6.22.10/include/linux/time.h 2007-07-09 13:20:01 +0200
11846 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/time.h 2007-08-05 20:53:13 +0200
11847 @@ -176,6 +176,9 @@ static inline void timespec_add_ns(struc
11852 +#include <linux/vs_time.h>
11854 #endif /* __KERNEL__ */
11856 #define NFDBITS __NFDBITS
11857 diff -NurpP --minimal linux-2.6.22.10/include/linux/types.h linux-2.6.22.10-vs2.3.0.29/include/linux/types.h
11858 --- linux-2.6.22.10/include/linux/types.h 2007-02-06 03:01:52 +0100
11859 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/types.h 2007-08-05 20:53:13 +0200
11860 @@ -39,6 +39,9 @@ typedef __kernel_uid32_t uid_t;
11861 typedef __kernel_gid32_t gid_t;
11862 typedef __kernel_uid16_t uid16_t;
11863 typedef __kernel_gid16_t gid16_t;
11864 +typedef unsigned int xid_t;
11865 +typedef unsigned int nid_t;
11866 +typedef unsigned int tag_t;
11868 #ifdef CONFIG_UID16
11869 /* This is defined by include/asm-{arch}/posix_types.h */
11870 diff -NurpP --minimal linux-2.6.22.10/include/linux/vroot.h linux-2.6.22.10-vs2.3.0.29/include/linux/vroot.h
11871 --- linux-2.6.22.10/include/linux/vroot.h 1970-01-01 01:00:00 +0100
11872 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vroot.h 2007-08-05 20:53:13 +0200
11876 + * include/linux/vroot.h
11878 + * written by Herbert Pötzl, 9/11/2002
11879 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
11881 + * Copyright (C) 2002-2007 by Herbert Pötzl.
11882 + * Redistribution of this file is permitted under the
11883 + * GNU General Public License.
11886 +#ifndef _LINUX_VROOT_H
11887 +#define _LINUX_VROOT_H
11892 +/* Possible states of device */
11898 +struct vroot_device {
11902 + struct semaphore vr_ctl_mutex;
11903 + struct block_device *vr_device;
11908 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
11910 +extern int register_vroot_grb(vroot_grb_func *);
11911 +extern int unregister_vroot_grb(vroot_grb_func *);
11913 +#endif /* __KERNEL__ */
11915 +#define MAX_VROOT_DEFAULT 8
11918 + * IOCTL commands --- we will commandeer 0x56 ('V')
11921 +#define VROOT_SET_DEV 0x5600
11922 +#define VROOT_CLR_DEV 0x5601
11924 +#endif /* _LINUX_VROOT_H */
11925 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_base.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_base.h
11926 --- linux-2.6.22.10/include/linux/vs_base.h 1970-01-01 01:00:00 +0100
11927 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_base.h 2007-08-05 20:53:13 +0200
11929 +#ifndef _VS_BASE_H
11930 +#define _VS_BASE_H
11932 +#include "vserver/base.h"
11933 +#include "vserver/debug.h"
11936 +#warning duplicate inclusion
11938 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_context.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_context.h
11939 --- linux-2.6.22.10/include/linux/vs_context.h 1970-01-01 01:00:00 +0100
11940 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_context.h 2007-10-01 14:57:41 +0200
11942 +#ifndef _VS_CONTEXT_H
11943 +#define _VS_CONTEXT_H
11945 +#include "vserver/base.h"
11946 +#include "vserver/context.h"
11947 +#include "vserver/history.h"
11948 +#include "vserver/debug.h"
11951 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
11953 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
11954 + const char *_file, int _line, void *_here)
11959 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
11960 + vxi, vxi ? vxi->vx_id : 0,
11961 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11963 + __vxh_get_vx_info(vxi, _here);
11965 + atomic_inc(&vxi->vx_usecnt);
11970 +extern void free_vx_info(struct vx_info *);
11972 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
11974 +static inline void __put_vx_info(struct vx_info *vxi,
11975 + const char *_file, int _line, void *_here)
11980 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
11981 + vxi, vxi ? vxi->vx_id : 0,
11982 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11984 + __vxh_put_vx_info(vxi, _here);
11986 + if (atomic_dec_and_test(&vxi->vx_usecnt))
11987 + free_vx_info(vxi);
11991 +#define init_vx_info(p, i) \
11992 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11994 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11995 + const char *_file, int _line, void *_here)
11998 + vxlprintk(VXD_CBIT(xid, 3),
11999 + "init_vx_info(%p[#%d.%d])",
12000 + vxi, vxi ? vxi->vx_id : 0,
12001 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12003 + __vxh_init_vx_info(vxi, vxp, _here);
12005 + atomic_inc(&vxi->vx_usecnt);
12011 +#define set_vx_info(p, i) \
12012 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
12014 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
12015 + const char *_file, int _line, void *_here)
12017 + struct vx_info *vxo;
12022 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
12023 + vxi, vxi ? vxi->vx_id : 0,
12024 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12026 + __vxh_set_vx_info(vxi, vxp, _here);
12028 + atomic_inc(&vxi->vx_usecnt);
12029 + vxo = xchg(vxp, vxi);
12034 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
12036 +static inline void __clr_vx_info(struct vx_info **vxp,
12037 + const char *_file, int _line, void *_here)
12039 + struct vx_info *vxo;
12041 + vxo = xchg(vxp, NULL);
12045 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
12046 + vxo, vxo ? vxo->vx_id : 0,
12047 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
12049 + __vxh_clr_vx_info(vxo, vxp, _here);
12051 + if (atomic_dec_and_test(&vxo->vx_usecnt))
12052 + free_vx_info(vxo);
12056 +#define claim_vx_info(v, p) \
12057 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
12059 +static inline void __claim_vx_info(struct vx_info *vxi,
12060 + struct task_struct *task,
12061 + const char *_file, int _line, void *_here)
12063 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
12064 + vxi, vxi ? vxi->vx_id : 0,
12065 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12066 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
12067 + task, _file, _line);
12068 + __vxh_claim_vx_info(vxi, task, _here);
12070 + atomic_inc(&vxi->vx_tasks);
12074 +extern void unhash_vx_info(struct vx_info *);
12076 +#define release_vx_info(v, p) \
12077 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
12079 +static inline void __release_vx_info(struct vx_info *vxi,
12080 + struct task_struct *task,
12081 + const char *_file, int _line, void *_here)
12083 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
12084 + vxi, vxi ? vxi->vx_id : 0,
12085 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12086 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
12087 + task, _file, _line);
12088 + __vxh_release_vx_info(vxi, task, _here);
12092 + if (atomic_dec_and_test(&vxi->vx_tasks))
12093 + unhash_vx_info(vxi);
12097 +#define task_get_vx_info(p) \
12098 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
12100 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
12101 + const char *_file, int _line, void *_here)
12103 + struct vx_info *vxi;
12106 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
12107 + p, _file, _line);
12108 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
12114 +static inline void __wakeup_vx_info(struct vx_info *vxi)
12116 + if (waitqueue_active(&vxi->vx_wait))
12117 + wake_up_interruptible(&vxi->vx_wait);
12121 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
12123 +static inline void __enter_vx_info(struct vx_info *vxi,
12124 + struct vx_info_save *vxis, const char *_file, int _line)
12126 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
12127 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
12128 + current->xid, current->vx_info, _file, _line);
12129 + vxis->vxi = xchg(¤t->vx_info, vxi);
12130 + vxis->xid = current->xid;
12131 + current->xid = vxi ? vxi->vx_id : 0;
12134 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
12136 +static inline void __leave_vx_info(struct vx_info_save *vxis,
12137 + const char *_file, int _line)
12139 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
12140 + vxis, vxis->xid, vxis->vxi, current,
12141 + current->xid, current->vx_info, _file, _line);
12142 + (void)xchg(¤t->vx_info, vxis->vxi);
12143 + current->xid = vxis->xid;
12147 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
12149 + vxis->vxi = xchg(¤t->vx_info, NULL);
12150 + vxis->xid = xchg(¤t->xid, (xid_t)0);
12153 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
12155 + (void)xchg(¤t->xid, vxis->xid);
12156 + (void)xchg(¤t->vx_info, vxis->vxi);
12159 +extern void exit_vx_info(struct task_struct *, int);
12160 +extern void exit_vx_info_early(struct task_struct *, int);
12164 +#warning duplicate inclusion
12166 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_cowbl.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_cowbl.h
12167 --- linux-2.6.22.10/include/linux/vs_cowbl.h 1970-01-01 01:00:00 +0100
12168 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_cowbl.h 2007-08-05 20:53:13 +0200
12170 +#ifndef _VS_COWBL_H
12171 +#define _VS_COWBL_H
12173 +#include <linux/fs.h>
12174 +#include <linux/dcache.h>
12175 +#include <linux/namei.h>
12177 +extern struct dentry *cow_break_link(const char *pathname);
12179 +static inline int cow_check_and_break(struct nameidata *nd)
12181 + struct inode *inode = nd->dentry->d_inode;
12183 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
12185 + if (IS_COW(inode)) {
12186 + if (IS_COW_LINK(inode)) {
12187 + struct dentry *new_dentry, *old_dentry = nd->dentry;
12188 + char *path, *buf;
12190 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
12194 + path = d_path(nd->dentry, nd->mnt, buf, PATH_MAX);
12195 + new_dentry = cow_break_link(path);
12197 + if (!IS_ERR(new_dentry)) {
12198 + nd->dentry = new_dentry;
12199 + dput(old_dentry);
12201 + error = PTR_ERR(new_dentry);
12203 + inode->i_flags &= ~(S_IUNLINK | S_IMMUTABLE);
12204 + inode->i_ctime = CURRENT_TIME;
12205 + mark_inode_dirty(inode);
12212 +#warning duplicate inclusion
12214 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_cvirt.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_cvirt.h
12215 --- linux-2.6.22.10/include/linux/vs_cvirt.h 1970-01-01 01:00:00 +0100
12216 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_cvirt.h 2007-08-05 20:53:13 +0200
12218 +#ifndef _VS_CVIRT_H
12219 +#define _VS_CVIRT_H
12221 +#include "vserver/cvirt.h"
12222 +#include "vserver/context.h"
12223 +#include "vserver/base.h"
12224 +#include "vserver/debug.h"
12227 +static inline void vx_activate_task(struct task_struct *p)
12229 + struct vx_info *vxi;
12231 + if ((vxi = p->vx_info)) {
12232 + vx_update_load(vxi);
12233 + atomic_inc(&vxi->cvirt.nr_running);
12237 +static inline void vx_deactivate_task(struct task_struct *p)
12239 + struct vx_info *vxi;
12241 + if ((vxi = p->vx_info)) {
12242 + vx_update_load(vxi);
12243 + atomic_dec(&vxi->cvirt.nr_running);
12247 +static inline void vx_uninterruptible_inc(struct task_struct *p)
12249 + struct vx_info *vxi;
12251 + if ((vxi = p->vx_info))
12252 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
12255 +static inline void vx_uninterruptible_dec(struct task_struct *p)
12257 + struct vx_info *vxi;
12259 + if ((vxi = p->vx_info))
12260 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
12265 +#warning duplicate inclusion
12267 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_device.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_device.h
12268 --- linux-2.6.22.10/include/linux/vs_device.h 1970-01-01 01:00:00 +0100
12269 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_device.h 2007-10-11 01:10:22 +0200
12271 +#ifndef _VS_DEVICE_H
12272 +#define _VS_DEVICE_H
12274 +#include "vserver/base.h"
12275 +#include "vserver/device.h"
12276 +#include "vserver/debug.h"
12279 +#ifdef CONFIG_VSERVER_DEVICE
12281 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
12283 +#define vs_device_perm(v, d, m, p) \
12284 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
12289 +int vs_map_device(struct vx_info *vxi,
12290 + dev_t device, dev_t *target, umode_t mode)
12293 + *target = device;
12297 +#define vs_device_perm(v, d, m, p) ((p) == (p))
12302 +#define vs_map_chrdev(d, t, p) \
12303 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
12304 +#define vs_map_blkdev(d, t, p) \
12305 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
12307 +#define vs_chrdev_perm(d, p) \
12308 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
12309 +#define vs_blkdev_perm(d, p) \
12310 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
12314 +#warning duplicate inclusion
12316 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_dlimit.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_dlimit.h
12317 --- linux-2.6.22.10/include/linux/vs_dlimit.h 1970-01-01 01:00:00 +0100
12318 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_dlimit.h 2007-08-15 22:04:43 +0200
12320 +#ifndef _VS_DLIMIT_H
12321 +#define _VS_DLIMIT_H
12323 +#include <linux/fs.h>
12325 +#include "vserver/dlimit.h"
12326 +#include "vserver/base.h"
12327 +#include "vserver/debug.h"
12330 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
12332 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
12333 + const char *_file, int _line)
12337 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
12338 + dli, dli ? dli->dl_tag : 0,
12339 + dli ? atomic_read(&dli->dl_usecnt) : 0,
12341 + atomic_inc(&dli->dl_usecnt);
12346 +#define free_dl_info(i) \
12347 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
12349 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
12351 +static inline void __put_dl_info(struct dl_info *dli,
12352 + const char *_file, int _line)
12356 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
12357 + dli, dli ? dli->dl_tag : 0,
12358 + dli ? atomic_read(&dli->dl_usecnt) : 0,
12360 + if (atomic_dec_and_test(&dli->dl_usecnt))
12361 + free_dl_info(dli);
12365 +#define __dlimit_char(d) ((d) ? '*' : ' ')
12367 +static inline int __dl_alloc_space(struct super_block *sb,
12368 + tag_t tag, dlsize_t nr, const char *file, int line)
12370 + struct dl_info *dli = NULL;
12375 + dli = locate_dl_info(sb, tag);
12379 + spin_lock(&dli->dl_lock);
12380 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
12382 + dli->dl_space_used += nr;
12383 + spin_unlock(&dli->dl_lock);
12384 + put_dl_info(dli);
12386 + vxlprintk(VXD_CBIT(dlim, 1),
12387 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
12388 + sb, tag, __dlimit_char(dli), (long long)nr,
12389 + ret, file, line);
12393 +static inline void __dl_free_space(struct super_block *sb,
12394 + tag_t tag, dlsize_t nr, const char *_file, int _line)
12396 + struct dl_info *dli = NULL;
12400 + dli = locate_dl_info(sb, tag);
12404 + spin_lock(&dli->dl_lock);
12405 + if (dli->dl_space_used > nr)
12406 + dli->dl_space_used -= nr;
12408 + dli->dl_space_used = 0;
12409 + spin_unlock(&dli->dl_lock);
12410 + put_dl_info(dli);
12412 + vxlprintk(VXD_CBIT(dlim, 1),
12413 + "FREE (%p,#%d)%c %lld bytes",
12414 + sb, tag, __dlimit_char(dli), (long long)nr,
12418 +static inline int __dl_alloc_inode(struct super_block *sb,
12419 + tag_t tag, const char *_file, int _line)
12421 + struct dl_info *dli;
12424 + dli = locate_dl_info(sb, tag);
12428 + spin_lock(&dli->dl_lock);
12429 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
12431 + dli->dl_inodes_used++;
12432 + spin_unlock(&dli->dl_lock);
12433 + put_dl_info(dli);
12435 + vxlprintk(VXD_CBIT(dlim, 0),
12436 + "ALLOC (%p,#%d)%c inode (%d)",
12437 + sb, tag, __dlimit_char(dli), ret, _file, _line);
12441 +static inline void __dl_free_inode(struct super_block *sb,
12442 + tag_t tag, const char *_file, int _line)
12444 + struct dl_info *dli;
12446 + dli = locate_dl_info(sb, tag);
12450 + spin_lock(&dli->dl_lock);
12451 + if (dli->dl_inodes_used > 1)
12452 + dli->dl_inodes_used--;
12454 + dli->dl_inodes_used = 0;
12455 + spin_unlock(&dli->dl_lock);
12456 + put_dl_info(dli);
12458 + vxlprintk(VXD_CBIT(dlim, 0),
12459 + "FREE (%p,#%d)%c inode",
12460 + sb, tag, __dlimit_char(dli), _file, _line);
12463 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
12464 + unsigned long long *free_blocks, unsigned long long *root_blocks,
12465 + const char *_file, int _line)
12467 + struct dl_info *dli;
12468 + uint64_t broot, bfree;
12470 + dli = locate_dl_info(sb, tag);
12474 + spin_lock(&dli->dl_lock);
12475 + broot = (dli->dl_space_total -
12476 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
12477 + >> sb->s_blocksize_bits;
12478 + bfree = (dli->dl_space_total - dli->dl_space_used)
12479 + >> sb->s_blocksize_bits;
12480 + spin_unlock(&dli->dl_lock);
12482 + vxlprintk(VXD_CBIT(dlim, 2),
12483 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
12484 + (long long)bfree, (long long)broot,
12485 + *free_blocks, *root_blocks, dli->dl_nrlmult,
12487 + if (free_blocks) {
12488 + if (*free_blocks > bfree)
12489 + *free_blocks = bfree;
12491 + if (root_blocks) {
12492 + if (*root_blocks > broot)
12493 + *root_blocks = broot;
12495 + put_dl_info(dli);
12498 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
12499 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
12500 + __FILE__, __LINE__ )
12502 +#define DLIMIT_FREE_SPACE(in, bytes) \
12503 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
12504 + __FILE__, __LINE__ )
12506 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
12507 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
12508 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
12509 + __FILE__, __LINE__ )
12511 +#define DLIMIT_FREE_BLOCK(in, nr) \
12512 + __dl_free_space((in)->i_sb, (in)->i_tag, \
12513 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
12514 + __FILE__, __LINE__ )
12517 +#define DLIMIT_ALLOC_INODE(in) \
12518 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
12520 +#define DLIMIT_FREE_INODE(in) \
12521 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
12524 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
12525 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
12529 +#warning duplicate inclusion
12531 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_inet.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_inet.h
12532 --- linux-2.6.22.10/include/linux/vs_inet.h 1970-01-01 01:00:00 +0100
12533 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_inet.h 2007-10-05 15:07:22 +0200
12535 +#ifndef _VS_INET_H
12536 +#define _VS_INET_H
12538 +#include "vserver/base.h"
12539 +#include "vserver/network.h"
12540 +#include "vserver/debug.h"
12542 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
12544 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
12545 + NIPQUAD((a)->mask), (a)->type
12546 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
12550 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
12552 + __be32 ip = nxa->ip[0].s_addr;
12553 + __be32 mask = nxa->mask.s_addr;
12554 + __be32 bcast = ip | ~mask;
12557 + switch (nxa->type & tmask) {
12558 + case NXA_TYPE_MASK:
12559 + ret = (ip == (addr & mask));
12561 + case NXA_TYPE_ADDR:
12565 + /* fall through to broadcast */
12566 + case NXA_MOD_BCAST:
12567 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
12569 + case NXA_TYPE_RANGE:
12570 + ret = ((nxa->ip[0].s_addr <= addr) &&
12571 + (nxa->ip[1].s_addr > addr));
12573 + case NXA_TYPE_ANY:
12578 + vxdprintk(VXD_CBIT(net, 0),
12579 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
12580 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
12585 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
12587 + struct nx_addr_v4 *nxa;
12594 + /* allow 127.0.0.1 when remapping lback */
12595 + if ((tmask & NXA_LOOPBACK) &&
12596 + (addr == IPI_LOOPBACK) &&
12597 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
12600 + /* check for lback address */
12601 + if ((tmask & NXA_MOD_LBACK) &&
12602 + (nxi->v4_lback.s_addr == addr))
12605 + /* check for broadcast address */
12606 + if ((tmask & NXA_MOD_BCAST) &&
12607 + (nxi->v4_bcast.s_addr == addr))
12610 + /* check for v4 addresses */
12611 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
12612 + if (v4_addr_match(nxa, addr, tmask))
12616 + vxdprintk(VXD_CBIT(net, 0),
12617 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
12618 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
12623 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
12625 + /* FIXME: needs full range checks */
12626 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
12630 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
12632 + struct nx_addr_v4 *ptr;
12634 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
12635 + if (v4_nx_addr_match(ptr, nxa, mask))
12640 +#include <net/inet_sock.h>
12643 + * Check if a given address matches for a socket
12645 + * nxi: the socket's nx_info if any
12646 + * addr: to be verified address
12649 +int v4_sock_addr_match (
12650 + struct nx_info *nxi,
12651 + struct inet_sock *inet,
12654 + __be32 saddr = inet->rcv_saddr;
12655 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
12657 + if (addr && (saddr == addr || bcast == addr))
12660 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
12665 +/* inet related checks and helpers */
12669 +struct net_device;
12672 +#ifdef CONFIG_INET
12674 +#include <linux/netdevice.h>
12675 +#include <linux/inetdevice.h>
12676 +#include <net/inet_timewait_sock.h>
12679 +int dev_in_nx_info(struct net_device *, struct nx_info *);
12680 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
12681 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
12685 + * check if address is covered by socket
12687 + * sk: the socket to check against
12688 + * addr: the address in question (must be != 0)
12692 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
12694 + struct nx_info *nxi = sk->sk_nx_info;
12695 + __be32 saddr = inet_rcv_saddr(sk);
12697 + vxdprintk(VXD_CBIT(net, 5),
12698 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
12699 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
12700 + (sk->sk_socket?sk->sk_socket->flags:0));
12702 + if (saddr) { /* direct address match */
12703 + return v4_addr_match(nxa, saddr, -1);
12704 + } else if (nxi) { /* match against nx_info */
12705 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
12706 + } else { /* unrestricted any socket */
12714 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
12716 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
12717 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
12718 + nxi ? dev_in_nx_info(dev, nxi) : 0);
12720 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
12722 + if (dev_in_nx_info(dev, nxi))
12729 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
12735 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
12739 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
12741 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
12742 + nxi, nxi ? nxi->nx_id : 0, ifa,
12743 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
12745 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
12747 + if (v4_ifa_in_nx_info(ifa, nxi))
12753 +struct nx_v4_sock_addr {
12754 + __be32 saddr; /* Address used for validation */
12755 + __be32 baddr; /* Address used for socket bind */
12759 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
12760 + struct nx_v4_sock_addr *nsa)
12762 + struct sock *sk = &inet->sk;
12763 + struct nx_info *nxi = sk->sk_nx_info;
12764 + __be32 saddr = addr->sin_addr.s_addr;
12765 + __be32 baddr = saddr;
12767 + vxdprintk(VXD_CBIT(net, 3),
12768 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
12769 + sk, sk->sk_nx_info, sk->sk_socket,
12770 + (sk->sk_socket ? sk->sk_socket->flags : 0),
12774 + if (saddr == INADDR_ANY) {
12775 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
12776 + baddr = nxi->v4.ip[0].s_addr;
12777 + } else if (saddr == IPI_LOOPBACK) {
12778 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
12779 + baddr = nxi->v4_lback.s_addr;
12780 + } else { /* normal address bind */
12781 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
12782 + return -EADDRNOTAVAIL;
12786 + vxdprintk(VXD_CBIT(net, 3),
12787 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
12788 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
12790 + nsa->saddr = saddr;
12791 + nsa->baddr = baddr;
12796 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
12798 + inet->saddr = nsa->baddr;
12799 + inet->rcv_saddr = nsa->baddr;
12804 + * helper to simplify inet_lookup_listener
12806 + * nxi: the socket's nx_info if any
12807 + * addr: to be verified address
12808 + * saddr: socket address
12810 +static inline int v4_inet_addr_match (
12811 + struct nx_info *nxi,
12815 + if (addr && (saddr == addr))
12818 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
12822 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
12824 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
12825 + (addr == nxi->v4_lback.s_addr))
12826 + return IPI_LOOPBACK;
12831 +int nx_info_has_v4(struct nx_info *nxi)
12835 + if (NX_IPV4(nxi))
12837 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
12842 +#else /* CONFIG_INET */
12845 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
12851 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
12857 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
12863 +int nx_info_has_v4(struct nx_info *nxi)
12868 +#endif /* CONFIG_INET */
12870 +#define current_nx_info_has_v4() \
12871 + nx_info_has_v4(current_nx_info())
12874 +#warning duplicate inclusion
12876 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_inet6.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_inet6.h
12877 --- linux-2.6.22.10/include/linux/vs_inet6.h 1970-01-01 01:00:00 +0100
12878 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_inet6.h 2007-10-05 14:54:36 +0200
12880 +#ifndef _VS_INET6_H
12881 +#define _VS_INET6_H
12883 +#include <net/ipv6.h>
12884 +#include "vserver/base.h"
12885 +#include "vserver/network.h"
12886 +#include "vserver/debug.h"
12888 +#define NXAV6(a) NIP6((a)->ip), NIP6((a)->mask), (a)->prefix, (a)->type
12889 +#define NXAV6_FMT "[" NIP6_FMT "/" NIP6_FMT "/%d:%04x]"
12892 +#ifdef CONFIG_IPV6
12895 +int v6_addr_match(struct nx_addr_v6 *nxa,
12896 + const struct in6_addr *addr, uint16_t mask)
12898 + switch (nxa->type & mask) {
12899 + case NXA_TYPE_MASK:
12900 + return ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
12901 + case NXA_TYPE_ADDR:
12902 + return ipv6_addr_equal(&nxa->ip, addr);
12903 + case NXA_TYPE_ANY:
12911 +int v6_addr_in_nx_info(struct nx_info *nxi,
12912 + const struct in6_addr *addr, uint16_t mask)
12914 + struct nx_addr_v6 *nxa;
12918 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
12919 + if (v6_addr_match(nxa, addr, mask))
12925 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
12927 + /* FIXME: needs full range checks */
12928 + return v6_addr_match(nxa, &addr->ip, mask);
12932 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
12934 + struct nx_addr_v6 *ptr;
12936 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
12937 + if (v6_nx_addr_match(ptr, nxa, mask))
12944 + * Check if a given address matches for a socket
12946 + * nxi: the socket's nx_info if any
12947 + * addr: to be verified address
12950 +int v6_sock_addr_match (
12951 + struct nx_info *nxi,
12952 + struct inet_sock *inet,
12953 + struct in6_addr *addr)
12955 + struct sock *sk = &inet->sk;
12956 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
12958 + if (!ipv6_addr_any(addr) &&
12959 + ipv6_addr_equal(saddr, addr))
12961 + if (ipv6_addr_any(saddr))
12962 + return v6_addr_in_nx_info(nxi, addr, -1);
12967 + * check if address is covered by socket
12969 + * sk: the socket to check against
12970 + * addr: the address in question (must be != 0)
12974 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
12976 + struct nx_info *nxi = sk->sk_nx_info;
12977 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
12979 + vxdprintk(VXD_CBIT(net, 5),
12980 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:" NIP6_FMT " %p;%lx",
12981 + sk, NXAV6(nxa), nxi, NIP6(*saddr), sk->sk_socket,
12982 + (sk->sk_socket?sk->sk_socket->flags:0));
12984 + if (!ipv6_addr_any(saddr)) { /* direct address match */
12985 + return v6_addr_match(nxa, saddr, -1);
12986 + } else if (nxi) { /* match against nx_info */
12987 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
12988 + } else { /* unrestricted any socket */
12994 +/* inet related checks and helpers */
12998 +struct net_device;
13002 +#include <linux/netdevice.h>
13003 +#include <linux/inetdevice.h>
13004 +#include <net/inet_timewait_sock.h>
13007 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13008 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13009 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13014 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13020 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13024 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13026 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13028 + if (v6_ifa_in_nx_info(ifa, nxi))
13034 +struct nx_v6_sock_addr {
13035 + struct in6_addr saddr; /* Address used for validation */
13036 + struct in6_addr baddr; /* Address used for socket bind */
13040 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13041 + struct nx_v6_sock_addr *nsa)
13043 + // struct sock *sk = &inet->sk;
13044 + // struct nx_info *nxi = sk->sk_nx_info;
13045 + struct in6_addr saddr = addr->sin6_addr;
13046 + struct in6_addr baddr = saddr;
13048 + nsa->saddr = saddr;
13049 + nsa->baddr = baddr;
13054 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13056 + // struct sock *sk = &inet->sk;
13057 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13059 + // *saddr = nsa->baddr;
13060 + // inet->saddr = nsa->baddr;
13064 +int nx_info_has_v6(struct nx_info *nxi)
13068 + if (NX_IPV6(nxi))
13073 +#else /* CONFIG_IPV6 */
13076 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13083 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13089 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13095 +int nx_info_has_v6(struct nx_info *nxi)
13100 +#endif /* CONFIG_IPV6 */
13102 +#define current_nx_info_has_v6() \
13103 + nx_info_has_v6(current_nx_info())
13106 +#warning duplicate inclusion
13108 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_limit.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_limit.h
13109 --- linux-2.6.22.10/include/linux/vs_limit.h 1970-01-01 01:00:00 +0100
13110 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_limit.h 2007-08-05 20:53:13 +0200
13112 +#ifndef _VS_LIMIT_H
13113 +#define _VS_LIMIT_H
13115 +#include "vserver/limit.h"
13116 +#include "vserver/base.h"
13117 +#include "vserver/context.h"
13118 +#include "vserver/debug.h"
13119 +#include "vserver/context.h"
13120 +#include "vserver/limit_int.h"
13123 +#define vx_acc_cres(v, d, p, r) \
13124 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
13126 +#define vx_acc_cres_cond(x, d, p, r) \
13127 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
13128 + r, d, p, __FILE__, __LINE__)
13131 +#define vx_add_cres(v, a, p, r) \
13132 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
13133 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
13135 +#define vx_add_cres_cond(x, a, p, r) \
13136 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
13137 + r, a, p, __FILE__, __LINE__)
13138 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
13141 +/* process and file limits */
13143 +#define vx_nproc_inc(p) \
13144 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
13146 +#define vx_nproc_dec(p) \
13147 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
13149 +#define vx_files_inc(f) \
13150 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
13152 +#define vx_files_dec(f) \
13153 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
13155 +#define vx_locks_inc(l) \
13156 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
13158 +#define vx_locks_dec(l) \
13159 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
13161 +#define vx_openfd_inc(f) \
13162 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
13164 +#define vx_openfd_dec(f) \
13165 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
13168 +#define vx_cres_avail(v, n, r) \
13169 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
13172 +#define vx_nproc_avail(n) \
13173 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
13175 +#define vx_files_avail(n) \
13176 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
13178 +#define vx_locks_avail(n) \
13179 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
13181 +#define vx_openfd_avail(n) \
13182 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
13185 +/* dentry limits */
13187 +#define vx_dentry_inc(d) do { \
13188 + if (atomic_read(&d->d_count) == 1) \
13189 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
13192 +#define vx_dentry_dec(d) do { \
13193 + if (atomic_read(&d->d_count) == 0) \
13194 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
13197 +#define vx_dentry_avail(n) \
13198 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
13201 +/* socket limits */
13203 +#define vx_sock_inc(s) \
13204 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
13206 +#define vx_sock_dec(s) \
13207 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
13209 +#define vx_sock_avail(n) \
13210 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
13213 +/* ipc resource limits */
13215 +#define vx_ipcmsg_add(v, u, a) \
13216 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
13218 +#define vx_ipcmsg_sub(v, u, a) \
13219 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
13221 +#define vx_ipcmsg_avail(v, a) \
13222 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
13225 +#define vx_ipcshm_add(v, k, a) \
13226 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13228 +#define vx_ipcshm_sub(v, k, a) \
13229 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13231 +#define vx_ipcshm_avail(v, a) \
13232 + vx_cres_avail(v, a, VLIMIT_SHMEM)
13235 +#define vx_semary_inc(a) \
13236 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
13238 +#define vx_semary_dec(a) \
13239 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
13242 +#define vx_nsems_add(a,n) \
13243 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
13245 +#define vx_nsems_sub(a,n) \
13246 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
13250 +#warning duplicate inclusion
13252 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_memory.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_memory.h
13253 --- linux-2.6.22.10/include/linux/vs_memory.h 1970-01-01 01:00:00 +0100
13254 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_memory.h 2007-08-05 20:53:13 +0200
13256 +#ifndef _VS_MEMORY_H
13257 +#define _VS_MEMORY_H
13259 +#include "vserver/limit.h"
13260 +#include "vserver/base.h"
13261 +#include "vserver/context.h"
13262 +#include "vserver/debug.h"
13263 +#include "vserver/context.h"
13264 +#include "vserver/limit_int.h"
13267 +#define __acc_add_long(a, v) (*(v) += (a))
13268 +#define __acc_inc_long(v) (++*(v))
13269 +#define __acc_dec_long(v) (--*(v))
13271 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
13272 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
13273 +#define __acc_inc_atomic(v) atomic_long_inc(v)
13274 +#define __acc_dec_atomic(v) atomic_long_dec(v)
13275 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
13276 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
13277 +#define __acc_inc_atomic(v) __acc_inc_long(v)
13278 +#define __acc_dec_atomic(v) __acc_dec_long(v)
13279 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
13282 +#define vx_acc_page(m, d, v, r) do { \
13284 + __acc_inc_long(&(m)->v); \
13286 + __acc_dec_long(&(m)->v); \
13287 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
13290 +#define vx_acc_page_atomic(m, d, v, r) do { \
13292 + __acc_inc_atomic(&(m)->v); \
13294 + __acc_dec_atomic(&(m)->v); \
13295 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
13299 +#define vx_acc_pages(m, p, v, r) do { \
13300 + unsigned long __p = (p); \
13301 + __acc_add_long(__p, &(m)->v); \
13302 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
13305 +#define vx_acc_pages_atomic(m, p, v, r) do { \
13306 + unsigned long __p = (p); \
13307 + __acc_add_atomic(__p, &(m)->v); \
13308 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
13313 +#define vx_acc_vmpage(m, d) \
13314 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
13315 +#define vx_acc_vmlpage(m, d) \
13316 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
13317 +#define vx_acc_file_rsspage(m, d) \
13318 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
13319 +#define vx_acc_anon_rsspage(m, d) \
13320 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
13322 +#define vx_acc_vmpages(m, p) \
13323 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
13324 +#define vx_acc_vmlpages(m, p) \
13325 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
13326 +#define vx_acc_file_rsspages(m, p) \
13327 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
13328 +#define vx_acc_anon_rsspages(m, p) \
13329 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
13331 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
13332 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
13334 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
13335 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
13336 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
13337 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
13339 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
13340 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
13341 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
13342 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
13344 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
13345 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
13346 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
13347 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
13349 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
13350 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
13351 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
13352 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
13355 +#define vx_pages_avail(m, p, r) \
13356 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
13358 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
13359 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
13360 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
13361 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
13363 +#define vx_rss_avail(m, p) \
13364 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
13368 + VXPT_UNKNOWN = 0,
13377 +#define vx_page_fault(mm, vma, type, ret)
13381 +void __vx_page_fault(struct mm_struct *mm,
13382 + struct vm_area_struct *vma, int type, int ret)
13384 + struct vx_info *vxi = mm->mm_vx_info;
13387 + static char *page_type[6] =
13388 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
13389 + static char *page_what[4] =
13390 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
13396 + what = (ret & 0x3);
13398 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
13399 + type, what, ret, page_type[type], page_what[what]);
13401 + if (ret & VM_FAULT_WRITE)
13403 + atomic_inc(&vxi->cacct.page[type][what]);
13406 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
13410 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
13413 +#warning duplicate inclusion
13415 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_network.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_network.h
13416 --- linux-2.6.22.10/include/linux/vs_network.h 1970-01-01 01:00:00 +0100
13417 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_network.h 2007-08-05 20:53:13 +0200
13419 +#ifndef _NX_VS_NETWORK_H
13420 +#define _NX_VS_NETWORK_H
13422 +#include "vserver/context.h"
13423 +#include "vserver/network.h"
13424 +#include "vserver/base.h"
13425 +#include "vserver/debug.h"
13428 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
13430 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
13431 + const char *_file, int _line)
13436 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
13437 + nxi, nxi ? nxi->nx_id : 0,
13438 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13441 + atomic_inc(&nxi->nx_usecnt);
13446 +extern void free_nx_info(struct nx_info *);
13448 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
13450 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
13455 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
13456 + nxi, nxi ? nxi->nx_id : 0,
13457 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13460 + if (atomic_dec_and_test(&nxi->nx_usecnt))
13461 + free_nx_info(nxi);
13465 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
13467 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
13468 + const char *_file, int _line)
13471 + vxlprintk(VXD_CBIT(nid, 3),
13472 + "init_nx_info(%p[#%d.%d])",
13473 + nxi, nxi ? nxi->nx_id : 0,
13474 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13477 + atomic_inc(&nxi->nx_usecnt);
13483 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
13485 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
13486 + const char *_file, int _line)
13488 + struct nx_info *nxo;
13493 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
13494 + nxi, nxi ? nxi->nx_id : 0,
13495 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13498 + atomic_inc(&nxi->nx_usecnt);
13499 + nxo = xchg(nxp, nxi);
13503 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
13505 +static inline void __clr_nx_info(struct nx_info **nxp,
13506 + const char *_file, int _line)
13508 + struct nx_info *nxo;
13510 + nxo = xchg(nxp, NULL);
13514 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
13515 + nxo, nxo ? nxo->nx_id : 0,
13516 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
13519 + if (atomic_dec_and_test(&nxo->nx_usecnt))
13520 + free_nx_info(nxo);
13524 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
13526 +static inline void __claim_nx_info(struct nx_info *nxi,
13527 + struct task_struct *task, const char *_file, int _line)
13529 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
13530 + nxi, nxi ? nxi->nx_id : 0,
13531 + nxi?atomic_read(&nxi->nx_usecnt):0,
13532 + nxi?atomic_read(&nxi->nx_tasks):0,
13533 + task, _file, _line);
13535 + atomic_inc(&nxi->nx_tasks);
13539 +extern void unhash_nx_info(struct nx_info *);
13541 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
13543 +static inline void __release_nx_info(struct nx_info *nxi,
13544 + struct task_struct *task, const char *_file, int _line)
13546 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
13547 + nxi, nxi ? nxi->nx_id : 0,
13548 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13549 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
13550 + task, _file, _line);
13554 + if (atomic_dec_and_test(&nxi->nx_tasks))
13555 + unhash_nx_info(nxi);
13559 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
13561 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
13562 + const char *_file, int _line)
13564 + struct nx_info *nxi;
13567 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
13568 + p, _file, _line);
13569 + nxi = __get_nx_info(p->nx_info, _file, _line);
13575 +static inline void exit_nx_info(struct task_struct *p)
13578 + release_nx_info(p->nx_info, p);
13583 +#warning duplicate inclusion
13585 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_pid.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_pid.h
13586 --- linux-2.6.22.10/include/linux/vs_pid.h 1970-01-01 01:00:00 +0100
13587 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_pid.h 2007-09-05 02:49:29 +0200
13592 +#include "vserver/base.h"
13593 +#include "vserver/context.h"
13594 +#include "vserver/debug.h"
13595 +#include <linux/pid_namespace.h>
13598 +/* pid faking stuff */
13601 +#define vx_info_map_pid(v, p) \
13602 + __vx_info_map_pid((v), (p), __FUNC__, __FILE__, __LINE__)
13603 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13604 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
13605 +#define vx_map_tgid(p) vx_map_pid(p)
13607 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13608 + const char *func, const char *file, int line)
13610 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13611 + vxfprintk(VXD_CBIT(cvirt, 2),
13612 + "vx_map_tgid: %p/%llx: %d -> %d",
13613 + vxi, (long long)vxi->vx_flags, pid,
13614 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13615 + func, file, line);
13618 + if (pid == vxi->vx_initpid)
13624 +#define vx_info_rmap_pid(v, p) \
13625 + __vx_info_rmap_pid((v), (p), __FUNC__, __FILE__, __LINE__)
13626 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
13627 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13629 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13630 + const char *func, const char *file, int line)
13632 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13633 + vxfprintk(VXD_CBIT(cvirt, 2),
13634 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13635 + vxi, (long long)vxi->vx_flags, pid,
13636 + (pid == 1) ? vxi->vx_initpid : pid,
13637 + func, file, line);
13638 + if ((pid == 1) && vxi->vx_initpid)
13639 + return vxi->vx_initpid;
13640 + if (pid == vxi->vx_initpid)
13647 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
13650 +int vx_proc_task_visible(struct task_struct *task)
13652 + if ((task->pid == 1) &&
13653 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
13654 + /* show a blend through init */
13656 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
13664 +struct task_struct *vx_find_proc_task_by_pid(int pid)
13666 + struct task_struct *task = find_task_by_pid(pid);
13668 + if (task && !vx_proc_task_visible(task)) {
13669 + vxdprintk(VXD_CBIT(misc, 6),
13670 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
13671 + task, task->xid, task->pid,
13672 + current, current->xid, current->pid);
13679 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
13681 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
13683 + if (task && !vx_proc_task_visible(task)) {
13684 + vxdprintk(VXD_CBIT(misc, 6),
13685 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
13686 + task, task->xid, task->pid,
13687 + current, current->xid, current->pid);
13688 + put_task_struct(task);
13696 +struct task_struct *vx_child_reaper(struct task_struct *p)
13698 + struct vx_info *vxi = p->vx_info;
13699 + struct task_struct *reaper = child_reaper(p);
13704 + BUG_ON(!p->vx_info->vx_reaper);
13706 + /* child reaper for the guest reaper */
13707 + if (vxi->vx_reaper == p)
13710 + reaper = vxi->vx_reaper;
13712 + vxdprintk(VXD_CBIT(xid, 7),
13713 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
13714 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
13720 +#warning duplicate inclusion
13722 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_sched.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_sched.h
13723 --- linux-2.6.22.10/include/linux/vs_sched.h 1970-01-01 01:00:00 +0100
13724 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_sched.h 2007-08-05 20:53:13 +0200
13726 +#ifndef _VS_SCHED_H
13727 +#define _VS_SCHED_H
13729 +#include "vserver/base.h"
13730 +#include "vserver/context.h"
13731 +#include "vserver/sched.h"
13734 +#define VAVAVOOM_RATIO 50
13736 +#define MAX_PRIO_BIAS 20
13737 +#define MIN_PRIO_BIAS -20
13740 +#ifdef CONFIG_VSERVER_HARDCPU
13743 + * effective_prio - return the priority that is based on the static
13744 + * priority but is modified by bonuses/penalties.
13746 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
13747 + * into a -4 ... 0 ... +4 bonus/penalty range.
13749 + * Additionally, we scale another amount based on the number of
13750 + * CPU tokens currently held by the context, if the process is
13751 + * part of a context (and the appropriate SCHED flag is set).
13752 + * This ranges from -5 ... 0 ... +15, quadratically.
13754 + * So, the total bonus is -9 .. 0 .. +19
13755 + * We use ~50% of the full 0...39 priority range so that:
13757 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
13758 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
13759 + * unless that context is far exceeding its CPU allocation.
13761 + * Both properties are important to certain workloads.
13764 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
13766 + int vavavoom, max;
13768 + /* lots of tokens = lots of vavavoom
13769 + * no tokens = no vavavoom */
13770 + if ((vavavoom = sched_pc->tokens) >= 0) {
13771 + max = sched_pc->tokens_max;
13772 + vavavoom = max - vavavoom;
13774 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
13775 + * (vavavoom*vavavoom - (max >> 2)) / max;
13783 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
13785 + struct vx_info *vxi = p->vx_info;
13786 + struct _vx_sched_pc *sched_pc;
13791 + sched_pc = &vx_cpu(vxi, sched_pc);
13792 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
13793 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
13795 + sched_pc->vavavoom = vavavoom;
13796 + prio += vavavoom;
13798 + prio += sched_pc->prio_bias;
13802 +#else /* !CONFIG_VSERVER_HARDCPU */
13805 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
13807 + struct vx_info *vxi = p->vx_info;
13810 + prio += vx_cpu(vxi, sched_pc).prio_bias;
13814 +#endif /* CONFIG_VSERVER_HARDCPU */
13817 +static inline void vx_account_user(struct vx_info *vxi,
13818 + cputime_t cputime, int nice)
13822 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
13825 +static inline void vx_account_system(struct vx_info *vxi,
13826 + cputime_t cputime, int idle)
13830 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
13834 +#warning duplicate inclusion
13836 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_socket.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_socket.h
13837 --- linux-2.6.22.10/include/linux/vs_socket.h 1970-01-01 01:00:00 +0100
13838 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_socket.h 2007-08-05 20:53:13 +0200
13840 +#ifndef _VS_SOCKET_H
13841 +#define _VS_SOCKET_H
13843 +#include "vserver/debug.h"
13844 +#include "vserver/base.h"
13845 +#include "vserver/cacct.h"
13846 +#include "vserver/context.h"
13847 +#include "vserver/tag.h"
13850 +/* socket accounting */
13852 +#include <linux/socket.h>
13854 +static inline int vx_sock_type(int family)
13856 + switch (family) {
13858 + return VXA_SOCK_UNSPEC;
13860 + return VXA_SOCK_UNIX;
13862 + return VXA_SOCK_INET;
13864 + return VXA_SOCK_INET6;
13866 + return VXA_SOCK_PACKET;
13868 + return VXA_SOCK_OTHER;
13872 +#define vx_acc_sock(v, f, p, s) \
13873 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
13875 +static inline void __vx_acc_sock(struct vx_info *vxi,
13876 + int family, int pos, int size, char *file, int line)
13879 + int type = vx_sock_type(family);
13881 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
13882 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
13886 +#define vx_sock_recv(sk, s) \
13887 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
13888 +#define vx_sock_send(sk, s) \
13889 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
13890 +#define vx_sock_fail(sk, s) \
13891 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
13894 +#define sock_vx_init(s) do { \
13895 + (s)->sk_xid = 0; \
13896 + (s)->sk_vx_info = NULL; \
13899 +#define sock_nx_init(s) do { \
13900 + (s)->sk_nid = 0; \
13901 + (s)->sk_nx_info = NULL; \
13905 +int vx_socket_peer_tag(struct socket *sock, int level,
13906 + char __user *optval, int __user *optlen, int len)
13908 + struct peer_tag tag;
13910 + tag.xid = sock->sk->sk_xid;
13911 + tag.nid = sock->sk->sk_nid;
13912 + if (copy_to_user(optval, &tag, sizeof(tag)))
13918 +#warning duplicate inclusion
13920 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_tag.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_tag.h
13921 --- linux-2.6.22.10/include/linux/vs_tag.h 1970-01-01 01:00:00 +0100
13922 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_tag.h 2007-08-15 19:11:32 +0200
13927 +#include <linux/vserver/tag.h>
13929 +/* check conditions */
13931 +#define DX_ADMIN 0x0001
13932 +#define DX_WATCH 0x0002
13933 +#define DX_HOSTID 0x0008
13935 +#define DX_IDENT 0x0010
13937 +#define DX_ARG_MASK 0x0010
13940 +#define dx_task_tag(t) ((t)->tag)
13942 +#define dx_current_tag() dx_task_tag(current)
13944 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
13946 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
13950 + * check current context for ADMIN/WATCH and
13951 + * optionally against supplied argument
13953 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
13955 + if (mode & DX_ARG_MASK) {
13956 + if ((mode & DX_IDENT) && (id == cid))
13959 + return (((mode & DX_ADMIN) && (cid == 0)) ||
13960 + ((mode & DX_WATCH) && (cid == 1)) ||
13961 + ((mode & DX_HOSTID) && (id == 0)));
13965 +#warning duplicate inclusion
13967 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_time.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_time.h
13968 --- linux-2.6.22.10/include/linux/vs_time.h 1970-01-01 01:00:00 +0100
13969 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_time.h 2007-08-05 20:53:13 +0200
13971 +#ifndef _VS_TIME_H
13972 +#define _VS_TIME_H
13975 +/* time faking stuff */
13977 +#ifdef CONFIG_VSERVER_VTIME
13979 +extern void vx_gettimeofday(struct timeval *tv);
13980 +extern int vx_settimeofday(struct timespec *ts);
13983 +#define vx_gettimeofday(t) do_gettimeofday(t)
13984 +#define vx_settimeofday(t) do_settimeofday(t)
13988 +#warning duplicate inclusion
13990 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/Kbuild linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/Kbuild
13991 --- linux-2.6.22.10/include/linux/vserver/Kbuild 1970-01-01 01:00:00 +0100
13992 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/Kbuild 2007-10-11 01:10:22 +0200
13995 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
13996 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
13997 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
13998 + debug_cmd.h device_cmd.h
14000 +unifdef-y += switch.h network.h monitor.h inode.h device.h
14002 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/base.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/base.h
14003 --- linux-2.6.22.10/include/linux/vserver/base.h 1970-01-01 01:00:00 +0100
14004 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/base.h 2007-09-17 14:07:30 +0200
14006 +#ifndef _VX_BASE_H
14007 +#define _VX_BASE_H
14010 +/* context state changes */
14021 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
14023 +/* check conditions */
14025 +#define VS_ADMIN 0x0001
14026 +#define VS_WATCH 0x0002
14027 +#define VS_HIDE 0x0004
14028 +#define VS_HOSTID 0x0008
14030 +#define VS_IDENT 0x0010
14031 +#define VS_EQUIV 0x0020
14032 +#define VS_PARENT 0x0040
14033 +#define VS_CHILD 0x0080
14035 +#define VS_ARG_MASK 0x00F0
14037 +#ifdef CONFIG_VSERVER_PRIVACY
14038 +#define VS_ADMIN_P (0)
14039 +#define VS_WATCH_P (0)
14041 +#define VS_ADMIN_P VS_ADMIN
14042 +#define VS_WATCH_P VS_WATCH
14045 +#define VS_HARDIRQ 0x1000
14046 +#define VS_SOFTIRQ 0x2000
14047 +#define VS_IRQ 0x4000
14049 +#define VS_IRQ_MASK 0xF000
14051 +#include <linux/hardirq.h>
14054 + * check current context for ADMIN/WATCH and
14055 + * optionally against supplied argument
14057 +static inline int __vs_check(int cid, int id, unsigned int mode)
14059 + if (mode & VS_ARG_MASK) {
14060 + if ((mode & VS_IDENT) && (id == cid))
14063 + if (mode & VS_IRQ_MASK) {
14064 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
14066 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
14068 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
14071 + return (((mode & VS_ADMIN) && (cid == 0)) ||
14072 + ((mode & VS_WATCH) && (cid == 1)) ||
14073 + ((mode & VS_HOSTID) && (id == 0)));
14076 +#define vx_task_xid(t) ((t)->xid)
14078 +#define vx_current_xid() vx_task_xid(current)
14080 +#define current_vx_info() (current->vx_info)
14083 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
14085 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
14088 +#define nx_task_nid(t) ((t)->nid)
14090 +#define nx_current_nid() nx_task_nid(current)
14092 +#define current_nx_info() (current->nx_info)
14095 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
14097 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
14101 +/* generic flag merging */
14103 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
14105 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
14107 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
14109 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
14112 +/* context flags */
14114 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
14116 +#define vx_current_flags() __vx_flags(current->vx_info)
14118 +#define vx_info_flags(v, m, f) \
14119 + vs_check_flags(__vx_flags(v), m, f)
14121 +#define task_vx_flags(t, m, f) \
14122 + ((t) && vx_info_flags((t)->vx_info, m, f))
14124 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
14127 +/* context caps */
14129 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
14131 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
14133 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
14135 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
14139 +/* network flags */
14141 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
14143 +#define nx_current_flags() __nx_flags(current->nx_info)
14145 +#define nx_info_flags(n, m, f) \
14146 + vs_check_flags(__nx_flags(n), m, f)
14148 +#define task_nx_flags(t, m, f) \
14149 + ((t) && nx_info_flags((t)->nx_info, m, f))
14151 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
14154 +/* network caps */
14156 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
14158 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
14160 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
14162 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
14165 +/* context mask capabilities */
14167 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
14169 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
14171 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
14174 +/* context bcap mask */
14176 +#define __vx_bcaps(v) ((v) ? (v)->vx_bcaps : ~0 )
14178 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
14180 +#define vx_info_bcaps(v, c) (__vx_bcaps(v) & (c))
14182 +#define vx_bcaps(c) vx_info_bcaps(current->vx_info, c)
14185 +#define vx_info_cap_bset(v) ((v) ? (v)->vx_cap_bset : cap_bset)
14187 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
14190 +#define __vx_info_mbcap(v, b) \
14191 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
14192 + vx_info_bcaps(v, b) : (b))
14194 +#define vx_info_mbcap(v, b) __vx_info_mbcap(v, cap_t(b))
14196 +#define task_vx_mbcap(t, b) \
14197 + vx_info_mbcap((t)->vx_info, (t)->b)
14199 +#define vx_mbcap(b) task_vx_mbcap(current, b)
14201 +#define vx_cap_raised(v, c, f) (vx_info_mbcap(v, c) & CAP_TO_MASK(f))
14203 +#define vx_capable(b, c) (capable(b) || \
14204 + (cap_raised(current->cap_effective, b) && vx_ccaps(c)))
14206 +#define nx_capable(b, c) (capable(b) || \
14207 + (cap_raised(current->cap_effective, b) && nx_ncaps(c)))
14209 +#define vx_current_initpid(n) \
14210 + (current->vx_info && \
14211 + (current->vx_info->vx_initpid == (n)))
14214 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
14216 +#define vx_info_state(v, m) (__vx_state(v) & (m))
14219 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
14221 +#define nx_info_state(n, m) (__nx_state(n) & (m))
14224 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cacct.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct.h
14225 --- linux-2.6.22.10/include/linux/vserver/cacct.h 1970-01-01 01:00:00 +0100
14226 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct.h 2007-08-05 20:53:13 +0200
14228 +#ifndef _VX_CACCT_H
14229 +#define _VX_CACCT_H
14232 +enum sock_acc_field {
14233 + VXA_SOCK_UNSPEC = 0,
14239 + VXA_SOCK_SIZE /* array size */
14242 +#endif /* _VX_CACCT_H */
14243 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cacct_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_cmd.h
14244 --- linux-2.6.22.10/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00 +0100
14245 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_cmd.h 2007-08-05 20:53:13 +0200
14247 +#ifndef _VX_CACCT_CMD_H
14248 +#define _VX_CACCT_CMD_H
14251 +/* virtual host info name commands */
14253 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
14255 +struct vcmd_sock_stat_v0 {
14257 + uint32_t count[3];
14258 + uint64_t total[3];
14264 +#include <linux/compiler.h>
14266 +extern int vc_sock_stat(struct vx_info *, void __user *);
14268 +#endif /* __KERNEL__ */
14269 +#endif /* _VX_CACCT_CMD_H */
14270 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cacct_def.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_def.h
14271 --- linux-2.6.22.10/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00 +0100
14272 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_def.h 2007-08-05 20:53:13 +0200
14274 +#ifndef _VX_CACCT_DEF_H
14275 +#define _VX_CACCT_DEF_H
14277 +#include <asm/atomic.h>
14278 +#include <linux/vserver/cacct.h>
14281 +struct _vx_sock_acc {
14282 + atomic_long_t count;
14283 + atomic_long_t total;
14286 +/* context sub struct */
14288 +struct _vx_cacct {
14289 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
14290 + atomic_t slab[8];
14291 + atomic_t page[6][8];
14294 +#ifdef CONFIG_VSERVER_DEBUG
14296 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
14300 + printk("\t_vx_cacct:");
14301 + for (i = 0; i < 6; i++) {
14302 + struct _vx_sock_acc *ptr = cacct->sock[i];
14304 + printk("\t [%d] =", i);
14305 + for (j = 0; j < 3; j++) {
14306 + printk(" [%d] = %8lu, %8lu", j,
14307 + atomic_long_read(&ptr[j].count),
14308 + atomic_long_read(&ptr[j].total));
14316 +#endif /* _VX_CACCT_DEF_H */
14317 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cacct_int.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_int.h
14318 --- linux-2.6.22.10/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00 +0100
14319 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_int.h 2007-08-05 20:53:13 +0200
14321 +#ifndef _VX_CACCT_INT_H
14322 +#define _VX_CACCT_INT_H
14328 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
14330 + return atomic_long_read(&cacct->sock[type][pos].count);
14335 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
14337 + return atomic_long_read(&cacct->sock[type][pos].total);
14340 +#endif /* __KERNEL__ */
14341 +#endif /* _VX_CACCT_INT_H */
14342 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/context.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/context.h
14343 --- linux-2.6.22.10/include/linux/vserver/context.h 1970-01-01 01:00:00 +0100
14344 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/context.h 2007-10-11 01:10:22 +0200
14346 +#ifndef _VX_CONTEXT_H
14347 +#define _VX_CONTEXT_H
14349 +#include <linux/types.h>
14350 +#include <linux/capability.h>
14353 +/* context flags */
14355 +#define VXF_INFO_SCHED 0x00000002
14356 +#define VXF_INFO_NPROC 0x00000004
14357 +#define VXF_INFO_PRIVATE 0x00000008
14359 +#define VXF_INFO_INIT 0x00000010
14360 +#define VXF_INFO_HIDE 0x00000020
14361 +#define VXF_INFO_ULIMIT 0x00000040
14362 +#define VXF_INFO_NSPACE 0x00000080
14364 +#define VXF_SCHED_HARD 0x00000100
14365 +#define VXF_SCHED_PRIO 0x00000200
14366 +#define VXF_SCHED_PAUSE 0x00000400
14368 +#define VXF_VIRT_MEM 0x00010000
14369 +#define VXF_VIRT_UPTIME 0x00020000
14370 +#define VXF_VIRT_CPU 0x00040000
14371 +#define VXF_VIRT_LOAD 0x00080000
14372 +#define VXF_VIRT_TIME 0x00100000
14374 +#define VXF_HIDE_MOUNT 0x01000000
14375 +/* was VXF_HIDE_NETIF 0x02000000 */
14376 +#define VXF_HIDE_VINFO 0x04000000
14378 +#define VXF_STATE_SETUP (1ULL << 32)
14379 +#define VXF_STATE_INIT (1ULL << 33)
14380 +#define VXF_STATE_ADMIN (1ULL << 34)
14382 +#define VXF_SC_HELPER (1ULL << 36)
14383 +#define VXF_REBOOT_KILL (1ULL << 37)
14384 +#define VXF_PERSISTENT (1ULL << 38)
14386 +#define VXF_FORK_RSS (1ULL << 48)
14387 +#define VXF_PROLIFIC (1ULL << 49)
14389 +#define VXF_IGNEG_NICE (1ULL << 52)
14391 +#define VXF_ONE_TIME (0x0007ULL << 32)
14393 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
14396 +/* context migration */
14398 +#define VXM_SET_INIT 0x00000001
14399 +#define VXM_SET_REAPER 0x00000002
14401 +/* context caps */
14403 +#define VXC_CAP_MASK 0x00000000
14405 +#define VXC_SET_UTSNAME 0x00000001
14406 +#define VXC_SET_RLIMIT 0x00000002
14408 +/* was VXC_RAW_ICMP 0x00000100 */
14409 +#define VXC_SYSLOG 0x00001000
14411 +#define VXC_SECURE_MOUNT 0x00010000
14412 +#define VXC_SECURE_REMOUNT 0x00020000
14413 +#define VXC_BINARY_MOUNT 0x00040000
14415 +#define VXC_QUOTA_CTL 0x00100000
14416 +#define VXC_ADMIN_MAPPER 0x00200000
14417 +#define VXC_ADMIN_CLOOP 0x00400000
14419 +#define VXC_KTHREAD 0x01000000
14424 +#include <linux/list.h>
14425 +#include <linux/spinlock.h>
14426 +#include <linux/rcupdate.h>
14428 +#include "limit_def.h"
14429 +#include "sched_def.h"
14430 +#include "cvirt_def.h"
14431 +#include "cacct_def.h"
14432 +#include "device_def.h"
14434 +struct _vx_info_pc {
14435 + struct _vx_sched_pc sched_pc;
14436 + struct _vx_cvirt_pc cvirt_pc;
14440 + struct hlist_node vx_hlist; /* linked list of contexts */
14441 + xid_t vx_id; /* context id */
14442 + atomic_t vx_usecnt; /* usage count */
14443 + atomic_t vx_tasks; /* tasks count */
14444 + struct vx_info *vx_parent; /* parent context */
14445 + int vx_state; /* context state */
14447 + unsigned long vx_nsmask; /* assignment mask */
14448 + struct nsproxy *vx_nsproxy; /* private namespace */
14449 + struct fs_struct *vx_fs; /* private namespace fs */
14451 + uint64_t vx_flags; /* context flags */
14452 + uint64_t vx_bcaps; /* bounding caps (system) */
14453 + uint64_t vx_ccaps; /* context caps (vserver) */
14454 + kernel_cap_t vx_cap_bset; /* the guest's bset */
14456 + struct task_struct *vx_reaper; /* guest reaper process */
14457 + pid_t vx_initpid; /* PID of guest init */
14458 + int64_t vx_badness_bias; /* OOM points bias */
14460 + struct _vx_limit limit; /* vserver limits */
14461 + struct _vx_sched sched; /* vserver scheduler */
14462 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
14463 + struct _vx_cacct cacct; /* context accounting */
14465 + struct _vx_device dmap; /* default device map targets */
14467 +#ifndef CONFIG_SMP
14468 + struct _vx_info_pc info_pc; /* per cpu data */
14470 + struct _vx_info_pc *ptr_pc; /* per cpu array */
14473 + wait_queue_head_t vx_wait; /* context exit waitqueue */
14474 + int reboot_cmd; /* last sys_reboot() cmd */
14475 + int exit_code; /* last process exit code */
14477 + char vx_name[65]; /* vserver name */
14480 +#ifndef CONFIG_SMP
14481 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
14482 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
14484 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
14485 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
14488 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
14491 +struct vx_info_save {
14492 + struct vx_info *vxi;
14497 +/* status flags */
14499 +#define VXS_HASHED 0x0001
14500 +#define VXS_PAUSED 0x0010
14501 +#define VXS_SHUTDOWN 0x0100
14502 +#define VXS_HELPER 0x1000
14503 +#define VXS_RELEASED 0x8000
14506 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
14507 +extern void release_vx_info(struct vx_info *, struct task_struct *);
14509 +extern struct vx_info *lookup_vx_info(int);
14510 +extern struct vx_info *lookup_or_create_vx_info(int);
14512 +extern int get_xid_list(int, unsigned int *, int);
14513 +extern int xid_is_hashed(xid_t);
14515 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
14517 +extern long vs_state_change(struct vx_info *, unsigned int);
14520 +#endif /* __KERNEL__ */
14521 +#endif /* _VX_CONTEXT_H */
14522 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/context_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/context_cmd.h
14523 --- linux-2.6.22.10/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00 +0100
14524 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/context_cmd.h 2007-08-19 00:40:28 +0200
14526 +#ifndef _VX_CONTEXT_CMD_H
14527 +#define _VX_CONTEXT_CMD_H
14530 +/* vinfo commands */
14532 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
14535 +extern int vc_task_xid(uint32_t);
14537 +#endif /* __KERNEL__ */
14539 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
14541 +struct vcmd_vx_info_v0 {
14543 + uint32_t initpid;
14544 + /* more to come */
14548 +extern int vc_vx_info(struct vx_info *, void __user *);
14550 +#endif /* __KERNEL__ */
14552 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
14554 +struct vcmd_ctx_stat_v0 {
14557 + /* more to come */
14561 +extern int vc_ctx_stat(struct vx_info *, void __user *);
14563 +#endif /* __KERNEL__ */
14565 +/* context commands */
14567 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
14568 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
14570 +struct vcmd_ctx_create {
14571 + uint64_t flagword;
14574 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
14575 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
14577 +struct vcmd_ctx_migrate {
14578 + uint64_t flagword;
14582 +extern int vc_ctx_create(uint32_t, void __user *);
14583 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
14585 +#endif /* __KERNEL__ */
14588 +/* flag commands */
14590 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
14591 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
14593 +struct vcmd_ctx_flags_v0 {
14594 + uint64_t flagword;
14599 +extern int vc_get_cflags(struct vx_info *, void __user *);
14600 +extern int vc_set_cflags(struct vx_info *, void __user *);
14602 +#endif /* __KERNEL__ */
14605 +/* context caps commands */
14607 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
14608 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
14610 +struct vcmd_ctx_caps_v1 {
14616 +extern int vc_get_ccaps(struct vx_info *, void __user *);
14617 +extern int vc_set_ccaps(struct vx_info *, void __user *);
14619 +#endif /* __KERNEL__ */
14622 +/* bcaps commands */
14624 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
14625 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
14627 +struct vcmd_bcaps {
14633 +extern int vc_get_bcaps(struct vx_info *, void __user *);
14634 +extern int vc_set_bcaps(struct vx_info *, void __user *);
14636 +#endif /* __KERNEL__ */
14641 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
14642 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
14644 +struct vcmd_badness_v0 {
14649 +extern int vc_get_badness(struct vx_info *, void __user *);
14650 +extern int vc_set_badness(struct vx_info *, void __user *);
14652 +#endif /* __KERNEL__ */
14653 +#endif /* _VX_CONTEXT_CMD_H */
14654 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cvirt.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt.h
14655 --- linux-2.6.22.10/include/linux/vserver/cvirt.h 1970-01-01 01:00:00 +0100
14656 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt.h 2007-08-05 20:53:13 +0200
14658 +#ifndef _VX_CVIRT_H
14659 +#define _VX_CVIRT_H
14666 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14671 +void vx_update_load(struct vx_info *);
14674 +int vx_do_syslog(int, char __user *, int);
14676 +#endif /* __KERNEL__ */
14677 +#endif /* _VX_CVIRT_H */
14678 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cvirt_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt_cmd.h
14679 --- linux-2.6.22.10/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00 +0100
14680 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt_cmd.h 2007-08-05 20:53:13 +0200
14682 +#ifndef _VX_CVIRT_CMD_H
14683 +#define _VX_CVIRT_CMD_H
14686 +/* virtual host info name commands */
14688 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
14689 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
14691 +struct vcmd_vhi_name_v0 {
14697 +enum vhi_name_field {
14698 + VHIN_CONTEXT = 0,
14710 +#include <linux/compiler.h>
14712 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
14713 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
14715 +#endif /* __KERNEL__ */
14717 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
14719 +struct vcmd_virt_stat_v0 {
14722 + uint32_t nr_threads;
14723 + uint32_t nr_running;
14724 + uint32_t nr_uninterruptible;
14725 + uint32_t nr_onhold;
14726 + uint32_t nr_forks;
14727 + uint32_t load[3];
14731 +extern int vc_virt_stat(struct vx_info *, void __user *);
14733 +#endif /* __KERNEL__ */
14734 +#endif /* _VX_CVIRT_CMD_H */
14735 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cvirt_def.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt_def.h
14736 --- linux-2.6.22.10/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00 +0100
14737 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt_def.h 2007-08-05 20:53:13 +0200
14739 +#ifndef _VX_CVIRT_DEF_H
14740 +#define _VX_CVIRT_DEF_H
14742 +#include <linux/jiffies.h>
14743 +#include <linux/spinlock.h>
14744 +#include <linux/wait.h>
14745 +#include <linux/time.h>
14746 +#include <linux/utsname.h>
14747 +#include <asm/atomic.h>
14750 +struct _vx_usage_stat {
14754 + uint64_t softirq;
14760 +struct _vx_syslog {
14761 + wait_queue_head_t log_wait;
14762 + spinlock_t logbuf_lock; /* lock for the log buffer */
14764 + unsigned long log_start; /* next char to be read by syslog() */
14765 + unsigned long con_start; /* next char to be sent to consoles */
14766 + unsigned long log_end; /* most-recently-written-char + 1 */
14767 + unsigned long logged_chars; /* #chars since last read+clear operation */
14769 + char log_buf[1024];
14773 +/* context sub struct */
14775 +struct _vx_cvirt {
14776 + atomic_t nr_threads; /* number of current threads */
14777 + atomic_t nr_running; /* number of running threads */
14778 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
14780 + atomic_t nr_onhold; /* processes on hold */
14781 + uint32_t onhold_last; /* jiffies when put on hold */
14783 + struct timeval bias_tv; /* time offset to the host */
14784 + struct timespec bias_idle;
14785 + struct timespec bias_uptime; /* context creation point */
14786 + uint64_t bias_clock; /* offset in clock_t */
14788 + spinlock_t load_lock; /* lock for the load averages */
14789 + atomic_t load_updates; /* nr of load updates done so far */
14790 + uint32_t load_last; /* last time load was calculated */
14791 + uint32_t load[3]; /* load averages 1,5,15 */
14793 + atomic_t total_forks; /* number of forks so far */
14795 + struct _vx_syslog syslog;
14798 +struct _vx_cvirt_pc {
14799 + struct _vx_usage_stat cpustat;
14803 +#ifdef CONFIG_VSERVER_DEBUG
14805 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
14807 + printk("\t_vx_cvirt:\n");
14808 + printk("\t threads: %4d, %4d, %4d, %4d\n",
14809 + atomic_read(&cvirt->nr_threads),
14810 + atomic_read(&cvirt->nr_running),
14811 + atomic_read(&cvirt->nr_uninterruptible),
14812 + atomic_read(&cvirt->nr_onhold));
14813 + /* add rest here */
14814 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
14819 +#endif /* _VX_CVIRT_DEF_H */
14820 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/debug.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/debug.h
14821 --- linux-2.6.22.10/include/linux/vserver/debug.h 1970-01-01 01:00:00 +0100
14822 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/debug.h 2007-10-25 17:05:55 +0200
14824 +#ifndef _VX_DEBUG_H
14825 +#define _VX_DEBUG_H
14828 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
14829 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
14830 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
14832 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
14833 + imajor((d)->bd_inode), iminor((d)->bd_inode)
14834 +#define VXF_DEV "%p[%lu,%d:%d]"
14837 +#define __FUNC__ __func__
14840 +#define vxd_path(d, m) \
14841 + ({ static char _buffer[PATH_MAX]; \
14842 + d_path(d, m, _buffer, sizeof(_buffer)); })
14844 +#define vxd_cond_path(n) \
14845 + ((n) ? vxd_path((n)->dentry, (n)->mnt) : "<null>" )
14848 +#ifdef CONFIG_VSERVER_DEBUG
14850 +extern unsigned int vx_debug_switch;
14851 +extern unsigned int vx_debug_xid;
14852 +extern unsigned int vx_debug_nid;
14853 +extern unsigned int vx_debug_tag;
14854 +extern unsigned int vx_debug_net;
14855 +extern unsigned int vx_debug_limit;
14856 +extern unsigned int vx_debug_cres;
14857 +extern unsigned int vx_debug_dlim;
14858 +extern unsigned int vx_debug_quota;
14859 +extern unsigned int vx_debug_cvirt;
14860 +extern unsigned int vx_debug_space;
14861 +extern unsigned int vx_debug_misc;
14864 +#define VX_LOGLEVEL "vxD: "
14865 +#define VX_PROC_FMT "%p: "
14866 +#define VX_PROCESS current
14868 +#define vxdprintk(c, f, x...) \
14871 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
14872 + VX_PROCESS , ##x); \
14875 +#define vxlprintk(c, f, x...) \
14878 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
14881 +#define vxfprintk(c, f, x...) \
14884 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
14890 +void dump_vx_info(struct vx_info *, int);
14891 +void dump_vx_info_inactive(int);
14893 +#else /* CONFIG_VSERVER_DEBUG */
14895 +#define vx_debug_switch 0
14896 +#define vx_debug_xid 0
14897 +#define vx_debug_nid 0
14898 +#define vx_debug_tag 0
14899 +#define vx_debug_net 0
14900 +#define vx_debug_limit 0
14901 +#define vx_debug_cres 0
14902 +#define vx_debug_dlim 0
14903 +#define vx_debug_cvirt 0
14905 +#define vxdprintk(x...) do { } while (0)
14906 +#define vxlprintk(x...) do { } while (0)
14907 +#define vxfprintk(x...) do { } while (0)
14909 +#endif /* CONFIG_VSERVER_DEBUG */
14912 +#ifdef CONFIG_VSERVER_WARN
14914 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
14915 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
14916 +#define VX_WARN_XID "[xid #%u] "
14917 +#define VX_WARN_NID "[nid #%u] "
14918 +#define VX_WARN_TAG "[tag #%u] "
14920 +#define vxwprintk(c, f, x...) \
14923 + printk(VX_WARNLEVEL f "\n", ##x); \
14926 +#else /* CONFIG_VSERVER_WARN */
14928 +#define vxwprintk(x...) do { } while (0)
14930 +#endif /* CONFIG_VSERVER_WARN */
14932 +#define vxwprintk_task(c, f, x...) \
14933 + vxwprintk(c, VX_WARN_TASK f, \
14934 + current->comm, current->pid, \
14935 + current->xid, current->nid, current->tag, ##x)
14936 +#define vxwprintk_xid(c, f, x...) \
14937 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
14938 +#define vxwprintk_nid(c, f, x...) \
14939 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
14940 +#define vxwprintk_tag(c, f, x...) \
14941 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
14943 +#ifdef CONFIG_VSERVER_DEBUG
14944 +#define vxd_assert_lock(l) assert_spin_locked(l)
14945 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
14946 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
14948 +#define vxd_assert_lock(l) do { } while (0)
14949 +#define vxd_assert(c, f, x...) do { } while (0)
14953 +#endif /* _VX_DEBUG_H */
14954 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/debug_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/debug_cmd.h
14955 --- linux-2.6.22.10/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00 +0100
14956 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/debug_cmd.h 2007-08-05 20:53:13 +0200
14958 +#ifndef _VX_DEBUG_CMD_H
14959 +#define _VX_DEBUG_CMD_H
14962 +/* debug commands */
14964 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
14966 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
14967 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
14969 +struct vcmd_read_history_v0 {
14972 + char __user *data;
14975 +struct vcmd_read_monitor_v0 {
14978 + char __user *data;
14984 +#ifdef CONFIG_COMPAT
14986 +#include <asm/compat.h>
14988 +struct vcmd_read_history_v0_x32 {
14991 + compat_uptr_t data_ptr;
14994 +struct vcmd_read_monitor_v0_x32 {
14997 + compat_uptr_t data_ptr;
15000 +#endif /* CONFIG_COMPAT */
15002 +extern int vc_dump_history(uint32_t);
15004 +extern int vc_read_history(uint32_t, void __user *);
15005 +extern int vc_read_monitor(uint32_t, void __user *);
15007 +#ifdef CONFIG_COMPAT
15009 +extern int vc_read_history_x32(uint32_t, void __user *);
15010 +extern int vc_read_monitor_x32(uint32_t, void __user *);
15012 +#endif /* CONFIG_COMPAT */
15014 +#endif /* __KERNEL__ */
15015 +#endif /* _VX_DEBUG_CMD_H */
15016 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/device.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device.h
15017 --- linux-2.6.22.10/include/linux/vserver/device.h 1970-01-01 01:00:00 +0100
15018 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device.h 2007-10-11 01:10:22 +0200
15020 +#ifndef _VX_DEVICE_H
15021 +#define _VX_DEVICE_H
15024 +#define DATTR_CREATE 0x00000001
15025 +#define DATTR_OPEN 0x00000002
15027 +#define DATTR_REMAP 0x00000010
15029 +#define DATTR_MASK 0x00000013
15032 +#else /* _VX_DEVICE_H */
15033 +#warning duplicate inclusion
15034 +#endif /* _VX_DEVICE_H */
15035 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/device_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device_cmd.h
15036 --- linux-2.6.22.10/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00 +0100
15037 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device_cmd.h 2007-10-11 01:10:22 +0200
15039 +#ifndef _VX_DEVICE_CMD_H
15040 +#define _VX_DEVICE_CMD_H
15043 +/* device vserver commands */
15045 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
15046 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
15048 +struct vcmd_set_mapping_v0 {
15049 + const char __user *device;
15050 + const char __user *target;
15057 +#ifdef CONFIG_COMPAT
15059 +#include <asm/compat.h>
15061 +struct vcmd_set_mapping_v0_x32 {
15062 + compat_uptr_t device_ptr;
15063 + compat_uptr_t target_ptr;
15067 +#endif /* CONFIG_COMPAT */
15069 +#include <linux/compiler.h>
15071 +extern int vc_set_mapping(struct vx_info *, void __user *);
15072 +extern int vc_unset_mapping(struct vx_info *, void __user *);
15074 +#ifdef CONFIG_COMPAT
15076 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
15077 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
15079 +#endif /* CONFIG_COMPAT */
15081 +#endif /* __KERNEL__ */
15082 +#endif /* _VX_DEVICE_CMD_H */
15083 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/device_def.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device_def.h
15084 --- linux-2.6.22.10/include/linux/vserver/device_def.h 1970-01-01 01:00:00 +0100
15085 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device_def.h 2007-10-11 01:10:22 +0200
15087 +#ifndef _VX_DEVICE_DEF_H
15088 +#define _VX_DEVICE_DEF_H
15090 +#include <linux/types.h>
15092 +struct vx_dmap_target {
15097 +struct _vx_device {
15098 +#ifdef CONFIG_VSERVER_DEVICE
15099 + struct vx_dmap_target targets[2];
15103 +#endif /* _VX_DEVICE_DEF_H */
15104 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/dlimit.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/dlimit.h
15105 --- linux-2.6.22.10/include/linux/vserver/dlimit.h 1970-01-01 01:00:00 +0100
15106 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/dlimit.h 2007-08-15 22:03:58 +0200
15108 +#ifndef _VX_DLIMIT_H
15109 +#define _VX_DLIMIT_H
15111 +#include "switch.h"
15116 +/* keep in sync with CDLIM_INFINITY */
15118 +#define DLIM_INFINITY (~0ULL)
15120 +#include <linux/spinlock.h>
15121 +#include <linux/rcupdate.h>
15123 +struct super_block;
15126 + struct hlist_node dl_hlist; /* linked list of contexts */
15127 + struct rcu_head dl_rcu; /* the rcu head */
15128 + tag_t dl_tag; /* context tag */
15129 + atomic_t dl_usecnt; /* usage count */
15130 + atomic_t dl_refcnt; /* reference count */
15132 + struct super_block *dl_sb; /* associated superblock */
15134 + spinlock_t dl_lock; /* protect the values */
15136 + unsigned long long dl_space_used; /* used space in bytes */
15137 + unsigned long long dl_space_total; /* maximum space in bytes */
15138 + unsigned long dl_inodes_used; /* used inodes */
15139 + unsigned long dl_inodes_total; /* maximum inodes */
15141 + unsigned int dl_nrlmult; /* non root limit mult */
15146 +extern void rcu_free_dl_info(struct rcu_head *);
15147 +extern void unhash_dl_info(struct dl_info *);
15149 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
15154 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
15156 +typedef uint64_t dlsize_t;
15158 +#endif /* __KERNEL__ */
15159 +#else /* _VX_DLIMIT_H */
15160 +#warning duplicate inclusion
15161 +#endif /* _VX_DLIMIT_H */
15162 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/dlimit_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/dlimit_cmd.h
15163 --- linux-2.6.22.10/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00 +0100
15164 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/dlimit_cmd.h 2007-08-05 20:53:13 +0200
15166 +#ifndef _VX_DLIMIT_CMD_H
15167 +#define _VX_DLIMIT_CMD_H
15170 +/* dlimit vserver commands */
15172 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
15173 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
15175 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
15176 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
15178 +struct vcmd_ctx_dlimit_base_v0 {
15179 + const char __user *name;
15183 +struct vcmd_ctx_dlimit_v0 {
15184 + const char __user *name;
15185 + uint32_t space_used; /* used space in kbytes */
15186 + uint32_t space_total; /* maximum space in kbytes */
15187 + uint32_t inodes_used; /* used inodes */
15188 + uint32_t inodes_total; /* maximum inodes */
15189 + uint32_t reserved; /* reserved for root in % */
15193 +#define CDLIM_UNSET ((uint32_t)0UL)
15194 +#define CDLIM_INFINITY ((uint32_t)~0UL)
15195 +#define CDLIM_KEEP ((uint32_t)~1UL)
15199 +#ifdef CONFIG_COMPAT
15201 +#include <asm/compat.h>
15203 +struct vcmd_ctx_dlimit_base_v0_x32 {
15204 + compat_uptr_t name_ptr;
15208 +struct vcmd_ctx_dlimit_v0_x32 {
15209 + compat_uptr_t name_ptr;
15210 + uint32_t space_used; /* used space in kbytes */
15211 + uint32_t space_total; /* maximum space in kbytes */
15212 + uint32_t inodes_used; /* used inodes */
15213 + uint32_t inodes_total; /* maximum inodes */
15214 + uint32_t reserved; /* reserved for root in % */
15218 +#endif /* CONFIG_COMPAT */
15220 +#include <linux/compiler.h>
15222 +extern int vc_add_dlimit(uint32_t, void __user *);
15223 +extern int vc_rem_dlimit(uint32_t, void __user *);
15225 +extern int vc_set_dlimit(uint32_t, void __user *);
15226 +extern int vc_get_dlimit(uint32_t, void __user *);
15228 +#ifdef CONFIG_COMPAT
15230 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
15231 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
15233 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
15234 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
15236 +#endif /* CONFIG_COMPAT */
15238 +#endif /* __KERNEL__ */
15239 +#endif /* _VX_DLIMIT_CMD_H */
15240 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/global.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/global.h
15241 --- linux-2.6.22.10/include/linux/vserver/global.h 1970-01-01 01:00:00 +0100
15242 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/global.h 2007-08-05 20:53:13 +0200
15244 +#ifndef _VX_GLOBAL_H
15245 +#define _VX_GLOBAL_H
15248 +extern atomic_t vx_global_ctotal;
15249 +extern atomic_t vx_global_cactive;
15251 +extern atomic_t nx_global_ctotal;
15252 +extern atomic_t nx_global_cactive;
15254 +extern atomic_t vs_global_nsproxy;
15255 +extern atomic_t vs_global_fs;
15256 +extern atomic_t vs_global_mnt_ns;
15257 +extern atomic_t vs_global_uts_ns;
15258 +extern atomic_t vs_global_ipc_ns;
15261 +#endif /* _VX_GLOBAL_H */
15262 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/history.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/history.h
15263 --- linux-2.6.22.10/include/linux/vserver/history.h 1970-01-01 01:00:00 +0100
15264 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/history.h 2007-08-05 20:53:13 +0200
15266 +#ifndef _VX_HISTORY_H
15267 +#define _VX_HISTORY_H
15272 + VXH_THROW_OOPS = 1,
15276 + VXH_INIT_VX_INFO,
15279 + VXH_CLAIM_VX_INFO,
15280 + VXH_RELEASE_VX_INFO,
15281 + VXH_ALLOC_VX_INFO,
15282 + VXH_DEALLOC_VX_INFO,
15283 + VXH_HASH_VX_INFO,
15284 + VXH_UNHASH_VX_INFO,
15286 + VXH_LOOKUP_VX_INFO,
15287 + VXH_CREATE_VX_INFO,
15290 +struct _vxhe_vxi {
15291 + struct vx_info *ptr;
15297 +struct _vxhe_set_clr {
15301 +struct _vxhe_loc_lookup {
15305 +struct _vx_hist_entry {
15307 + unsigned short seq;
15308 + unsigned short type;
15309 + struct _vxhe_vxi vxi;
15311 + struct _vxhe_set_clr sc;
15312 + struct _vxhe_loc_lookup ll;
15316 +#ifdef CONFIG_VSERVER_HISTORY
15318 +extern unsigned volatile int vxh_active;
15320 +struct _vx_hist_entry *vxh_advance(void *loc);
15324 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
15326 + entry->vxi.ptr = vxi;
15328 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
15329 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
15330 + entry->vxi.xid = vxi->vx_id;
15335 +#define __HERE__ current_text_addr()
15337 +#define __VXH_BODY(__type, __data, __here) \
15338 + struct _vx_hist_entry *entry; \
15340 + preempt_disable(); \
15341 + entry = vxh_advance(__here); \
15343 + entry->type = __type; \
15344 + preempt_enable();
15347 + /* pass vxi only */
15349 +#define __VXH_SMPL \
15350 + __vxh_copy_vxi(entry, vxi)
15353 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
15355 + __VXH_BODY(__type, __VXH_SMPL, __here)
15358 + /* pass vxi and data (void *) */
15360 +#define __VXH_DATA \
15361 + __vxh_copy_vxi(entry, vxi); \
15362 + entry->sc.data = data
15365 +void __vxh_data(struct vx_info *vxi, void *data,
15366 + int __type, void *__here)
15368 + __VXH_BODY(__type, __VXH_DATA, __here)
15371 + /* pass vxi and arg (long) */
15373 +#define __VXH_LONG \
15374 + __vxh_copy_vxi(entry, vxi); \
15375 + entry->ll.arg = arg
15378 +void __vxh_long(struct vx_info *vxi, long arg,
15379 + int __type, void *__here)
15381 + __VXH_BODY(__type, __VXH_LONG, __here)
15386 +void __vxh_throw_oops(void *__here)
15388 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
15389 + /* prevent further acquisition */
15394 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
15396 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
15397 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
15399 +#define __vxh_init_vx_info(v, d, h) \
15400 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
15401 +#define __vxh_set_vx_info(v, d, h) \
15402 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
15403 +#define __vxh_clr_vx_info(v, d, h) \
15404 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
15406 +#define __vxh_claim_vx_info(v, d, h) \
15407 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
15408 +#define __vxh_release_vx_info(v, d, h) \
15409 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
15411 +#define vxh_alloc_vx_info(v) \
15412 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
15413 +#define vxh_dealloc_vx_info(v) \
15414 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
15416 +#define vxh_hash_vx_info(v) \
15417 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
15418 +#define vxh_unhash_vx_info(v) \
15419 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
15421 +#define vxh_loc_vx_info(v, l) \
15422 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
15423 +#define vxh_lookup_vx_info(v, l) \
15424 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
15425 +#define vxh_create_vx_info(v, l) \
15426 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
15428 +extern void vxh_dump_history(void);
15431 +#else /* CONFIG_VSERVER_HISTORY */
15433 +#define __HERE__ 0
15435 +#define vxh_throw_oops() do { } while (0)
15437 +#define __vxh_get_vx_info(v, h) do { } while (0)
15438 +#define __vxh_put_vx_info(v, h) do { } while (0)
15440 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
15441 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
15442 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
15444 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
15445 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
15447 +#define vxh_alloc_vx_info(v) do { } while (0)
15448 +#define vxh_dealloc_vx_info(v) do { } while (0)
15450 +#define vxh_hash_vx_info(v) do { } while (0)
15451 +#define vxh_unhash_vx_info(v) do { } while (0)
15453 +#define vxh_loc_vx_info(v, l) do { } while (0)
15454 +#define vxh_lookup_vx_info(v, l) do { } while (0)
15455 +#define vxh_create_vx_info(v, l) do { } while (0)
15457 +#define vxh_dump_history() do { } while (0)
15460 +#endif /* CONFIG_VSERVER_HISTORY */
15462 +#endif /* _VX_HISTORY_H */
15463 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/inode.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/inode.h
15464 --- linux-2.6.22.10/include/linux/vserver/inode.h 1970-01-01 01:00:00 +0100
15465 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/inode.h 2007-08-05 20:53:13 +0200
15467 +#ifndef _VX_INODE_H
15468 +#define _VX_INODE_H
15471 +#define IATTR_TAG 0x01000000
15473 +#define IATTR_ADMIN 0x00000001
15474 +#define IATTR_WATCH 0x00000002
15475 +#define IATTR_HIDE 0x00000004
15476 +#define IATTR_FLAGS 0x00000007
15478 +#define IATTR_BARRIER 0x00010000
15479 +#define IATTR_IUNLINK 0x00020000
15480 +#define IATTR_IMMUTABLE 0x00040000
15485 +#ifdef CONFIG_VSERVER_PROC_SECURE
15486 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
15487 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
15489 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
15490 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
15493 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
15495 +#endif /* __KERNEL__ */
15497 +/* inode ioctls */
15499 +#define FIOC_GETXFLG _IOR('x', 5, long)
15500 +#define FIOC_SETXFLG _IOW('x', 6, long)
15502 +#else /* _VX_INODE_H */
15503 +#warning duplicate inclusion
15504 +#endif /* _VX_INODE_H */
15505 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/inode_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/inode_cmd.h
15506 --- linux-2.6.22.10/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00 +0100
15507 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/inode_cmd.h 2007-08-15 18:08:31 +0200
15509 +#ifndef _VX_INODE_CMD_H
15510 +#define _VX_INODE_CMD_H
15513 +/* inode vserver commands */
15515 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
15516 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
15518 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
15519 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
15521 +struct vcmd_ctx_iattr_v1 {
15522 + const char __user *name;
15528 +struct vcmd_ctx_fiattr_v0 {
15538 +#ifdef CONFIG_COMPAT
15540 +#include <asm/compat.h>
15542 +struct vcmd_ctx_iattr_v1_x32 {
15543 + compat_uptr_t name_ptr;
15549 +#endif /* CONFIG_COMPAT */
15551 +#include <linux/compiler.h>
15553 +extern int vc_get_iattr(void __user *);
15554 +extern int vc_set_iattr(void __user *);
15556 +extern int vc_fget_iattr(uint32_t, void __user *);
15557 +extern int vc_fset_iattr(uint32_t, void __user *);
15559 +#ifdef CONFIG_COMPAT
15561 +extern int vc_get_iattr_x32(void __user *);
15562 +extern int vc_set_iattr_x32(void __user *);
15564 +#endif /* CONFIG_COMPAT */
15566 +#endif /* __KERNEL__ */
15567 +#endif /* _VX_INODE_CMD_H */
15568 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/limit.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit.h
15569 --- linux-2.6.22.10/include/linux/vserver/limit.h 1970-01-01 01:00:00 +0100
15570 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit.h 2007-08-15 22:27:29 +0200
15572 +#ifndef _VX_LIMIT_H
15573 +#define _VX_LIMIT_H
15575 +#define VLIMIT_NSOCK 16
15576 +#define VLIMIT_OPENFD 17
15577 +#define VLIMIT_ANON 18
15578 +#define VLIMIT_SHMEM 19
15579 +#define VLIMIT_SEMARY 20
15580 +#define VLIMIT_NSEMS 21
15581 +#define VLIMIT_DENTRY 22
15582 +#define VLIMIT_MAPPED 23
15587 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
15589 +/* keep in sync with CRLIM_INFINITY */
15591 +#define VLIM_INFINITY (~0ULL)
15593 +#include <asm/atomic.h>
15594 +#include <asm/resource.h>
15596 +#ifndef RLIM_INFINITY
15597 +#warning RLIM_INFINITY is undefined
15600 +#define __rlim_val(l, r, v) ((l)->res[r].v)
15602 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
15603 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
15605 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
15606 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
15607 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
15609 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
15610 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
15612 +typedef atomic_long_t rlim_atomic_t;
15613 +typedef unsigned long rlim_t;
15615 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
15616 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
15617 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
15618 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
15619 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
15620 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
15623 +#if (RLIM_INFINITY == VLIM_INFINITY)
15624 +#define VX_VLIM(r) ((long long)(long)(r))
15625 +#define VX_RLIM(v) ((rlim_t)(v))
15627 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
15628 + ? VLIM_INFINITY : (long long)(r))
15629 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
15630 + ? RLIM_INFINITY : (rlim_t)(v))
15635 +void vx_vsi_meminfo(struct sysinfo *);
15636 +void vx_vsi_swapinfo(struct sysinfo *);
15638 +#define NUM_LIMITS 24
15640 +#endif /* __KERNEL__ */
15641 +#endif /* _VX_LIMIT_H */
15642 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/limit_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_cmd.h
15643 --- linux-2.6.22.10/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00 +0100
15644 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_cmd.h 2007-08-05 20:53:13 +0200
15646 +#ifndef _VX_LIMIT_CMD_H
15647 +#define _VX_LIMIT_CMD_H
15650 +/* rlimit vserver commands */
15652 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
15653 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
15654 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
15655 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
15657 +struct vcmd_ctx_rlimit_v0 {
15659 + uint64_t minimum;
15660 + uint64_t softlimit;
15661 + uint64_t maximum;
15664 +struct vcmd_ctx_rlimit_mask_v0 {
15665 + uint32_t minimum;
15666 + uint32_t softlimit;
15667 + uint32_t maximum;
15670 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
15672 +struct vcmd_rlimit_stat_v0 {
15676 + uint64_t minimum;
15677 + uint64_t maximum;
15680 +#define CRLIM_UNSET (0ULL)
15681 +#define CRLIM_INFINITY (~0ULL)
15682 +#define CRLIM_KEEP (~1ULL)
15686 +#ifdef CONFIG_IA32_EMULATION
15688 +struct vcmd_ctx_rlimit_v0_x32 {
15690 + uint64_t minimum;
15691 + uint64_t softlimit;
15692 + uint64_t maximum;
15693 +} __attribute__ ((aligned (4)));
15695 +#endif /* CONFIG_IA32_EMULATION */
15697 +#include <linux/compiler.h>
15699 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
15700 +extern int vc_get_rlimit(struct vx_info *, void __user *);
15701 +extern int vc_set_rlimit(struct vx_info *, void __user *);
15702 +extern int vc_reset_minmax(struct vx_info *, void __user *);
15704 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
15706 +#ifdef CONFIG_IA32_EMULATION
15708 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
15709 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
15711 +#endif /* CONFIG_IA32_EMULATION */
15713 +#endif /* __KERNEL__ */
15714 +#endif /* _VX_LIMIT_CMD_H */
15715 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/limit_def.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_def.h
15716 --- linux-2.6.22.10/include/linux/vserver/limit_def.h 1970-01-01 01:00:00 +0100
15717 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_def.h 2007-08-05 20:53:13 +0200
15719 +#ifndef _VX_LIMIT_DEF_H
15720 +#define _VX_LIMIT_DEF_H
15722 +#include <asm/atomic.h>
15723 +#include <asm/resource.h>
15725 +#include "limit.h"
15728 +struct _vx_res_limit {
15729 + rlim_t soft; /* Context soft limit */
15730 + rlim_t hard; /* Context hard limit */
15732 + rlim_atomic_t rcur; /* Current value */
15733 + rlim_t rmin; /* Context minimum */
15734 + rlim_t rmax; /* Context maximum */
15736 + atomic_t lhit; /* Limit hits */
15739 +/* context sub struct */
15741 +struct _vx_limit {
15742 + struct _vx_res_limit res[NUM_LIMITS];
15745 +#ifdef CONFIG_VSERVER_DEBUG
15747 +static inline void __dump_vx_limit(struct _vx_limit *limit)
15751 + printk("\t_vx_limit:");
15752 + for (i = 0; i < NUM_LIMITS; i++) {
15753 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
15754 + i, (unsigned long)__rlim_get(limit, i),
15755 + (unsigned long)__rlim_rmin(limit, i),
15756 + (unsigned long)__rlim_rmax(limit, i),
15757 + (long)__rlim_soft(limit, i),
15758 + (long)__rlim_hard(limit, i),
15759 + atomic_read(&__rlim_lhit(limit, i)));
15765 +#endif /* _VX_LIMIT_DEF_H */
15766 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/limit_int.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_int.h
15767 --- linux-2.6.22.10/include/linux/vserver/limit_int.h 1970-01-01 01:00:00 +0100
15768 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_int.h 2007-08-05 20:53:13 +0200
15770 +#ifndef _VX_LIMIT_INT_H
15771 +#define _VX_LIMIT_INT_H
15773 +#include "context.h"
15777 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
15778 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
15780 +extern const char *vlimit_name[NUM_LIMITS];
15782 +static inline void __vx_acc_cres(struct vx_info *vxi,
15783 + int res, int dir, void *_data, char *_file, int _line)
15785 + if (VXD_RCRES_COND(res))
15786 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
15787 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
15788 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
15789 + (dir > 0) ? "++" : "--", _data, _file, _line);
15794 + __rlim_inc(&vxi->limit, res);
15796 + __rlim_dec(&vxi->limit, res);
15799 +static inline void __vx_add_cres(struct vx_info *vxi,
15800 + int res, int amount, void *_data, char *_file, int _line)
15802 + if (VXD_RCRES_COND(res))
15803 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
15804 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
15805 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
15806 + amount, _data, _file, _line);
15811 + __rlim_add(&vxi->limit, res, amount);
15815 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
15817 + int cond = (value > __rlim_rmax(limit, res));
15820 + __rlim_rmax(limit, res) = value;
15825 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
15827 + int cond = (value < __rlim_rmin(limit, res));
15830 + __rlim_rmin(limit, res) = value;
15835 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
15837 + if (!__vx_cres_adjust_max(limit, res, value))
15838 + __vx_cres_adjust_min(limit, res, value);
15843 + +1 ... no limit hit
15844 + -1 ... over soft limit
15845 + 0 ... over hard limit */
15847 +static inline int __vx_cres_avail(struct vx_info *vxi,
15848 + int res, int num, char *_file, int _line)
15850 + struct _vx_limit *limit;
15853 + if (VXD_RLIMIT_COND(res))
15854 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
15855 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
15856 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
15857 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
15858 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
15859 + num, _file, _line);
15863 + limit = &vxi->limit;
15864 + value = __rlim_get(limit, res);
15866 + if (!__vx_cres_adjust_max(limit, res, value))
15867 + __vx_cres_adjust_min(limit, res, value);
15872 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
15874 + if (value + num <= __rlim_soft(limit, res))
15877 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
15879 + if (value + num <= __rlim_hard(limit, res))
15882 + __rlim_hit(limit, res);
15887 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
15890 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
15892 + rlim_t value, sum = 0;
15895 + while ((res = *array++)) {
15896 + value = __rlim_get(limit, res);
15897 + __vx_cres_fixup(limit, res, value);
15904 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
15906 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
15907 + int res = *array;
15909 + if (value == __rlim_get(limit, res))
15912 + __rlim_set(limit, res, value);
15913 + /* now adjust min/max */
15914 + if (!__vx_cres_adjust_max(limit, res, value))
15915 + __vx_cres_adjust_min(limit, res, value);
15920 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
15921 + const int *array, int num, char *_file, int _line)
15923 + struct _vx_limit *limit;
15924 + rlim_t value = 0;
15932 + limit = &vxi->limit;
15934 + value = __vx_cres_array_sum(limit, array + 1);
15936 + __rlim_set(limit, res, value);
15937 + __vx_cres_fixup(limit, res, value);
15939 + return __vx_cres_avail(vxi, res, num, _file, _line);
15943 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
15948 + /* complex resources first */
15949 + if ((id < 0) || (id == RLIMIT_RSS))
15950 + __vx_cres_array_fixup(limit, VLA_RSS);
15952 + for (res = 0; res < NUM_LIMITS; res++) {
15953 + if ((id > 0) && (res != id))
15956 + value = __rlim_get(limit, res);
15957 + __vx_cres_fixup(limit, res, value);
15959 + /* not supposed to happen, maybe warn? */
15960 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
15961 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
15966 +#endif /* __KERNEL__ */
15967 +#endif /* _VX_LIMIT_INT_H */
15968 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/monitor.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/monitor.h
15969 --- linux-2.6.22.10/include/linux/vserver/monitor.h 1970-01-01 01:00:00 +0100
15970 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/monitor.h 2007-08-15 23:16:12 +0200
15972 +#ifndef _VX_MONITOR_H
15973 +#define _VX_MONITOR_H
15975 +#include <linux/types.h>
15982 + VXM_UPDATE = 0x20,
15986 + VXM_RQINFO_1 = 0x24,
15989 + VXM_ACTIVATE = 0x40,
15996 + VXM_MIGRATE = 0x48,
15999 + /* all other bits are flags */
16000 + VXM_SCHED = 0x80,
16003 +struct _vxm_update_1 {
16004 + uint32_t tokens_max;
16005 + uint32_t fill_rate;
16006 + uint32_t interval;
16009 +struct _vxm_update_2 {
16010 + uint32_t tokens_min;
16011 + uint32_t fill_rate;
16012 + uint32_t interval;
16015 +struct _vxm_rqinfo_1 {
16016 + uint16_t running;
16020 + uint32_t idle_tokens;
16023 +struct _vxm_rqinfo_2 {
16024 + uint32_t norm_time;
16025 + uint32_t idle_time;
16026 + uint32_t idle_skip;
16029 +struct _vxm_sched {
16031 + uint32_t norm_time;
16032 + uint32_t idle_time;
16035 +struct _vxm_task {
16040 +struct _vxm_event {
16049 + struct _vxm_task tsk;
16053 +struct _vx_mon_entry {
16057 + struct _vxm_event ev;
16058 + struct _vxm_sched sd;
16059 + struct _vxm_update_1 u1;
16060 + struct _vxm_update_2 u2;
16061 + struct _vxm_rqinfo_1 q1;
16062 + struct _vxm_rqinfo_2 q2;
16067 +#endif /* _VX_MONITOR_H */
16068 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/network.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/network.h
16069 --- linux-2.6.22.10/include/linux/vserver/network.h 1970-01-01 01:00:00 +0100
16070 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/network.h 2007-10-05 12:29:05 +0200
16072 +#ifndef _VX_NETWORK_H
16073 +#define _VX_NETWORK_H
16075 +#include <linux/types.h>
16078 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
16081 +/* network flags */
16083 +#define NXF_INFO_PRIVATE 0x00000008
16085 +#define NXF_SINGLE_IP 0x00000100
16086 +#define NXF_LBACK_REMAP 0x00000200
16088 +#define NXF_HIDE_NETIF 0x02000000
16089 +#define NXF_HIDE_LBACK 0x04000000
16091 +#define NXF_STATE_SETUP (1ULL << 32)
16092 +#define NXF_STATE_ADMIN (1ULL << 34)
16094 +#define NXF_SC_HELPER (1ULL << 36)
16095 +#define NXF_PERSISTENT (1ULL << 38)
16097 +#define NXF_ONE_TIME (0x0005ULL << 32)
16100 +#define NXF_INIT_SET (__nxf_init_set())
16102 +static inline uint64_t __nxf_init_set(void) {
16103 + return NXF_STATE_ADMIN
16104 +#ifdef CONFIG_VSERVER_AUTO_LBACK
16105 + | NXF_LBACK_REMAP
16108 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
16111 + | NXF_HIDE_NETIF;
16115 +/* network caps */
16117 +#define NXC_RAW_ICMP 0x00000100
16120 +/* address types */
16122 +#define NXA_TYPE_IPV4 0x0001
16123 +#define NXA_TYPE_IPV6 0x0002
16125 +#define NXA_TYPE_NONE 0x0000
16126 +#define NXA_TYPE_ANY 0x00FF
16128 +#define NXA_TYPE_ADDR 0x0010
16129 +#define NXA_TYPE_MASK 0x0020
16130 +#define NXA_TYPE_RANGE 0x0040
16132 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
16134 +#define NXA_MOD_BCAST 0x0100
16135 +#define NXA_MOD_LBACK 0x0200
16137 +#define NXA_LOOPBACK 0x1000
16139 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
16140 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
16144 +#include <linux/list.h>
16145 +#include <linux/spinlock.h>
16146 +#include <linux/rcupdate.h>
16147 +#include <linux/in.h>
16148 +#include <linux/in6.h>
16149 +#include <asm/atomic.h>
16151 +struct nx_addr_v4 {
16152 + struct nx_addr_v4 *next;
16153 + struct in_addr ip[2];
16154 + struct in_addr mask;
16159 +struct nx_addr_v6 {
16160 + struct nx_addr_v6 *next;
16161 + struct in6_addr ip;
16162 + struct in6_addr mask;
16169 + struct hlist_node nx_hlist; /* linked list of nxinfos */
16170 + nid_t nx_id; /* vnet id */
16171 + atomic_t nx_usecnt; /* usage count */
16172 + atomic_t nx_tasks; /* tasks count */
16173 + int nx_state; /* context state */
16175 + uint64_t nx_flags; /* network flag word */
16176 + uint64_t nx_ncaps; /* network capabilities */
16178 + struct in_addr v4_lback; /* Loopback address */
16179 + struct in_addr v4_bcast; /* Broadcast address */
16180 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
16181 +#ifdef CONFIG_IPV6
16182 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
16184 + char nx_name[65]; /* network context name */
16188 +/* status flags */
16190 +#define NXS_HASHED 0x0001
16191 +#define NXS_SHUTDOWN 0x0100
16192 +#define NXS_RELEASED 0x8000
16194 +extern struct nx_info *lookup_nx_info(int);
16196 +extern int get_nid_list(int, unsigned int *, int);
16197 +extern int nid_is_hashed(nid_t);
16199 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
16201 +extern long vs_net_change(struct nx_info *, unsigned int);
16206 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
16207 +#ifdef CONFIG_IPV6
16208 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
16210 +#define NX_IPV6(n) (0)
16213 +#endif /* __KERNEL__ */
16214 +#endif /* _VX_NETWORK_H */
16215 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/network_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/network_cmd.h
16216 --- linux-2.6.22.10/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00 +0100
16217 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/network_cmd.h 2007-08-15 20:08:10 +0200
16219 +#ifndef _VX_NETWORK_CMD_H
16220 +#define _VX_NETWORK_CMD_H
16223 +/* vinfo commands */
16225 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
16228 +extern int vc_task_nid(uint32_t);
16230 +#endif /* __KERNEL__ */
16232 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
16234 +struct vcmd_nx_info_v0 {
16236 + /* more to come */
16240 +extern int vc_nx_info(struct nx_info *, void __user *);
16242 +#endif /* __KERNEL__ */
16244 +#include <linux/in.h>
16245 +#include <linux/in6.h>
16247 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
16248 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
16250 +struct vcmd_net_create {
16251 + uint64_t flagword;
16254 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
16256 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
16257 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
16259 +struct vcmd_net_addr_v0 {
16262 + struct in_addr ip[4];
16263 + struct in_addr mask[4];
16266 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
16267 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
16269 +struct vcmd_net_addr_ipv4_v1 {
16272 + struct in_addr ip;
16273 + struct in_addr mask;
16276 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
16277 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
16279 +struct vcmd_net_addr_ipv6_v1 {
16283 + struct in6_addr ip;
16284 + struct in6_addr mask;
16287 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
16288 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
16290 +struct vcmd_match_ipv4_v0 {
16295 + struct in_addr ip;
16296 + struct in_addr ip2;
16297 + struct in_addr mask;
16300 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
16301 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
16303 +struct vcmd_match_ipv6_v0 {
16308 + struct in6_addr ip;
16309 + struct in6_addr ip2;
16310 + struct in6_addr mask;
16315 +extern int vc_net_create(uint32_t, void __user *);
16316 +extern int vc_net_migrate(struct nx_info *, void __user *);
16318 +extern int vc_net_add(struct nx_info *, void __user *);
16319 +extern int vc_net_remove(struct nx_info *, void __user *);
16321 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
16322 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
16324 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
16325 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
16327 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
16328 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
16330 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
16331 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
16333 +#endif /* __KERNEL__ */
16336 +/* flag commands */
16338 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
16339 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
16341 +struct vcmd_net_flags_v0 {
16342 + uint64_t flagword;
16347 +extern int vc_get_nflags(struct nx_info *, void __user *);
16348 +extern int vc_set_nflags(struct nx_info *, void __user *);
16350 +#endif /* __KERNEL__ */
16353 +/* network caps commands */
16355 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
16356 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
16358 +struct vcmd_net_caps_v0 {
16364 +extern int vc_get_ncaps(struct nx_info *, void __user *);
16365 +extern int vc_set_ncaps(struct nx_info *, void __user *);
16367 +#endif /* __KERNEL__ */
16368 +#endif /* _VX_CONTEXT_CMD_H */
16369 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/percpu.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/percpu.h
16370 --- linux-2.6.22.10/include/linux/vserver/percpu.h 1970-01-01 01:00:00 +0100
16371 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/percpu.h 2007-08-05 20:53:13 +0200
16373 +#ifndef _VX_PERCPU_H
16374 +#define _VX_PERCPU_H
16376 +#include "cvirt_def.h"
16377 +#include "sched_def.h"
16379 +struct _vx_percpu {
16380 + struct _vx_cvirt_pc cvirt;
16381 + struct _vx_sched_pc sched;
16384 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
16386 +#endif /* _VX_PERCPU_H */
16387 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/sched.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched.h
16388 --- linux-2.6.22.10/include/linux/vserver/sched.h 1970-01-01 01:00:00 +0100
16389 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched.h 2007-08-05 20:53:13 +0200
16391 +#ifndef _VX_SCHED_H
16392 +#define _VX_SCHED_H
16399 +void vx_vsi_uptime(struct timespec *, struct timespec *);
16404 +void vx_update_load(struct vx_info *);
16407 +int vx_tokens_recalc(struct _vx_sched_pc *,
16408 + unsigned long *, unsigned long *, int [2]);
16410 +void vx_update_sched_param(struct _vx_sched *sched,
16411 + struct _vx_sched_pc *sched_pc);
16413 +#endif /* __KERNEL__ */
16414 +#else /* _VX_SCHED_H */
16415 +#warning duplicate inclusion
16416 +#endif /* _VX_SCHED_H */
16417 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/sched_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched_cmd.h
16418 --- linux-2.6.22.10/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00 +0100
16419 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched_cmd.h 2007-08-05 20:53:13 +0200
16421 +#ifndef _VX_SCHED_CMD_H
16422 +#define _VX_SCHED_CMD_H
16425 +/* sched vserver commands */
16427 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
16428 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
16429 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
16431 +struct vcmd_set_sched_v2 {
16432 + int32_t fill_rate;
16433 + int32_t interval;
16435 + int32_t tokens_min;
16436 + int32_t tokens_max;
16437 + uint64_t cpu_mask;
16440 +struct vcmd_set_sched_v3 {
16441 + uint32_t set_mask;
16442 + int32_t fill_rate;
16443 + int32_t interval;
16445 + int32_t tokens_min;
16446 + int32_t tokens_max;
16447 + int32_t priority_bias;
16450 +struct vcmd_set_sched_v4 {
16451 + uint32_t set_mask;
16452 + int32_t fill_rate;
16453 + int32_t interval;
16455 + int32_t tokens_min;
16456 + int32_t tokens_max;
16457 + int32_t prio_bias;
16459 + int32_t bucket_id;
16462 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
16463 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
16465 +struct vcmd_sched_v5 {
16468 + int32_t bucket_id;
16469 + int32_t fill_rate[2];
16470 + int32_t interval[2];
16472 + int32_t tokens_min;
16473 + int32_t tokens_max;
16474 + int32_t prio_bias;
16477 +#define VXSM_FILL_RATE 0x0001
16478 +#define VXSM_INTERVAL 0x0002
16479 +#define VXSM_FILL_RATE2 0x0004
16480 +#define VXSM_INTERVAL2 0x0008
16481 +#define VXSM_TOKENS 0x0010
16482 +#define VXSM_TOKENS_MIN 0x0020
16483 +#define VXSM_TOKENS_MAX 0x0040
16484 +#define VXSM_PRIO_BIAS 0x0100
16486 +#define VXSM_IDLE_TIME 0x0200
16487 +#define VXSM_FORCE 0x0400
16489 +#define VXSM_V3_MASK 0x0173
16490 +#define VXSM_SET_MASK 0x01FF
16492 +#define VXSM_CPU_ID 0x1000
16493 +#define VXSM_BUCKET_ID 0x2000
16495 +#define VXSM_MSEC 0x4000
16497 +#define SCHED_KEEP (-2) /* only for v2 */
16501 +#include <linux/compiler.h>
16503 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
16504 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
16505 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
16506 +extern int vc_set_sched(struct vx_info *, void __user *);
16507 +extern int vc_get_sched(struct vx_info *, void __user *);
16509 +#endif /* __KERNEL__ */
16511 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
16513 +struct vcmd_sched_info {
16515 + int32_t bucket_id;
16516 + uint64_t user_msec;
16517 + uint64_t sys_msec;
16518 + uint64_t hold_msec;
16519 + uint32_t token_usec;
16520 + int32_t vavavoom;
16525 +extern int vc_sched_info(struct vx_info *, void __user *);
16527 +#endif /* __KERNEL__ */
16528 +#endif /* _VX_SCHED_CMD_H */
16529 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/sched_def.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched_def.h
16530 --- linux-2.6.22.10/include/linux/vserver/sched_def.h 1970-01-01 01:00:00 +0100
16531 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched_def.h 2007-08-05 20:53:13 +0200
16533 +#ifndef _VX_SCHED_DEF_H
16534 +#define _VX_SCHED_DEF_H
16536 +#include <linux/spinlock.h>
16537 +#include <linux/jiffies.h>
16538 +#include <linux/cpumask.h>
16539 +#include <asm/atomic.h>
16540 +#include <asm/param.h>
16543 +/* context sub struct */
16545 +struct _vx_sched {
16546 + spinlock_t tokens_lock; /* lock for token bucket */
16548 + int tokens; /* number of CPU tokens */
16549 + int fill_rate[2]; /* Fill rate: add X tokens... */
16550 + int interval[2]; /* Divisor: per Y jiffies */
16551 + int tokens_min; /* Limit: minimum for unhold */
16552 + int tokens_max; /* Limit: no more than N tokens */
16554 + int prio_bias; /* bias offset for priority */
16556 + unsigned update_mask; /* which features should be updated */
16557 + cpumask_t update; /* CPUs which should update */
16560 +struct _vx_sched_pc {
16561 + int tokens; /* number of CPU tokens */
16562 + int flags; /* bucket flags */
16564 + int fill_rate[2]; /* Fill rate: add X tokens... */
16565 + int interval[2]; /* Divisor: per Y jiffies */
16566 + int tokens_min; /* Limit: minimum for unhold */
16567 + int tokens_max; /* Limit: no more than N tokens */
16569 + int prio_bias; /* bias offset for priority */
16570 + int vavavoom; /* last calculated vavavoom */
16572 + unsigned long norm_time; /* last time accounted */
16573 + unsigned long idle_time; /* non linear time for fair sched */
16574 + unsigned long token_time; /* token time for accounting */
16575 + unsigned long onhold; /* jiffies when put on hold */
16577 + uint64_t user_ticks; /* token tick events */
16578 + uint64_t sys_ticks; /* token tick events */
16579 + uint64_t hold_ticks; /* token ticks paused */
16583 +#define VXSF_ONHOLD 0x0001
16584 +#define VXSF_IDLE_TIME 0x0100
16586 +#ifdef CONFIG_VSERVER_DEBUG
16588 +static inline void __dump_vx_sched(struct _vx_sched *sched)
16590 + printk("\t_vx_sched:\n");
16591 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
16592 + sched->fill_rate[0], sched->interval[0],
16593 + sched->fill_rate[1], sched->interval[1],
16594 + sched->tokens_min, sched->tokens_max);
16595 + printk("\t priority = %4d\n", sched->prio_bias);
16600 +#endif /* _VX_SCHED_DEF_H */
16601 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/signal.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/signal.h
16602 --- linux-2.6.22.10/include/linux/vserver/signal.h 1970-01-01 01:00:00 +0100
16603 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/signal.h 2007-08-05 20:53:13 +0200
16605 +#ifndef _VX_SIGNAL_H
16606 +#define _VX_SIGNAL_H
16613 +int vx_info_kill(struct vx_info *, int, int);
16615 +#endif /* __KERNEL__ */
16616 +#else /* _VX_SIGNAL_H */
16617 +#warning duplicate inclusion
16618 +#endif /* _VX_SIGNAL_H */
16619 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/signal_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/signal_cmd.h
16620 --- linux-2.6.22.10/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00 +0100
16621 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/signal_cmd.h 2007-08-05 20:53:13 +0200
16623 +#ifndef _VX_SIGNAL_CMD_H
16624 +#define _VX_SIGNAL_CMD_H
16627 +/* signalling vserver commands */
16629 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
16630 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
16632 +struct vcmd_ctx_kill_v0 {
16637 +struct vcmd_wait_exit_v0 {
16638 + int32_t reboot_cmd;
16639 + int32_t exit_code;
16644 +extern int vc_ctx_kill(struct vx_info *, void __user *);
16645 +extern int vc_wait_exit(struct vx_info *, void __user *);
16647 +#endif /* __KERNEL__ */
16649 +/* process alteration commands */
16651 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
16652 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
16654 +struct vcmd_pflags_v0 {
16655 + uint32_t flagword;
16661 +extern int vc_get_pflags(uint32_t pid, void __user *);
16662 +extern int vc_set_pflags(uint32_t pid, void __user *);
16664 +#endif /* __KERNEL__ */
16665 +#endif /* _VX_SIGNAL_CMD_H */
16666 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/space.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/space.h
16667 --- linux-2.6.22.10/include/linux/vserver/space.h 1970-01-01 01:00:00 +0100
16668 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/space.h 2007-08-05 20:53:13 +0200
16670 +#ifndef _VX_SPACE_H
16671 +#define _VX_SPACE_H
16674 +#include <linux/types.h>
16678 +int vx_set_space(struct vx_info *vxi, unsigned long mask);
16680 +#else /* _VX_SPACE_H */
16681 +#warning duplicate inclusion
16682 +#endif /* _VX_SPACE_H */
16683 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/space_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/space_cmd.h
16684 --- linux-2.6.22.10/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00 +0100
16685 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/space_cmd.h 2007-08-05 20:53:13 +0200
16687 +#ifndef _VX_SPACE_CMD_H
16688 +#define _VX_SPACE_CMD_H
16691 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
16692 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 1)
16694 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
16695 +#define VCMD_set_space VC_CMD(PROCALT, 3, 1)
16697 +#define VCMD_get_space_mask VC_CMD(PROCALT, 4, 0)
16700 +struct vcmd_space_mask {
16707 +extern int vc_enter_space(struct vx_info *, void __user *);
16708 +extern int vc_set_space(struct vx_info *, void __user *);
16709 +extern int vc_get_space_mask(struct vx_info *, void __user *);
16711 +#endif /* __KERNEL__ */
16712 +#endif /* _VX_SPACE_CMD_H */
16713 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/switch.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/switch.h
16714 --- linux-2.6.22.10/include/linux/vserver/switch.h 1970-01-01 01:00:00 +0100
16715 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/switch.h 2007-10-11 01:10:22 +0200
16717 +#ifndef _VX_SWITCH_H
16718 +#define _VX_SWITCH_H
16720 +#include <linux/types.h>
16723 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
16724 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
16725 +#define VC_VERSION(c) ((c) & 0xFFF)
16727 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
16728 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
16732 + Syscall Matrix V2.8
16734 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
16735 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
16736 + |INFO |SETUP | |MOVE | | | | | |
16737 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16738 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
16739 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
16740 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16741 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
16742 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
16743 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16744 + MEMORY | | | | |MEMCTRL| | |SWAP | |
16745 + | 16| 17| 18| 19| 20| 21| | 22| 23|
16746 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16747 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
16748 + | 24| 25| 26| 27| 28| 29| | 30| 31|
16749 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16750 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
16751 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
16752 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16753 + OTHER |VSTAT | | | | | | |VINFO | |
16754 + | 40| 41| 42| 43| 44| 45| | 46| 47|
16755 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
16756 + SPECIAL|EVENT | | | |FLAGS | | | | |
16757 + | 48| 49| 50| 51| 52| 53| | 54| 55|
16758 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16759 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
16760 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
16761 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16765 +#define VC_CAT_VERSION 0
16767 +#define VC_CAT_VSETUP 1
16768 +#define VC_CAT_VHOST 2
16770 +#define VC_CAT_DEVICE 6
16772 +#define VC_CAT_VPROC 9
16773 +#define VC_CAT_PROCALT 10
16774 +#define VC_CAT_PROCMIG 11
16775 +#define VC_CAT_PROCTRL 12
16777 +#define VC_CAT_SCHED 14
16778 +#define VC_CAT_MEMCTRL 20
16780 +#define VC_CAT_VNET 25
16781 +#define VC_CAT_NETALT 26
16782 +#define VC_CAT_NETMIG 27
16783 +#define VC_CAT_NETCTRL 28
16785 +#define VC_CAT_TAGMIG 35
16786 +#define VC_CAT_DLIMIT 36
16787 +#define VC_CAT_INODE 38
16789 +#define VC_CAT_VSTAT 40
16790 +#define VC_CAT_VINFO 46
16791 +#define VC_CAT_EVENT 48
16793 +#define VC_CAT_FLAGS 52
16794 +#define VC_CAT_DEBUG 56
16795 +#define VC_CAT_RLIMIT 60
16797 +#define VC_CAT_SYSTEST 61
16798 +#define VC_CAT_COMPAT 63
16800 +/* query version */
16802 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
16803 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
16808 +#include <linux/errno.h>
16811 +#else /* __KERNEL__ */
16813 +#endif /* __KERNEL__ */
16815 +#endif /* _VX_SWITCH_H */
16816 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/tag.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/tag.h
16817 --- linux-2.6.22.10/include/linux/vserver/tag.h 1970-01-01 01:00:00 +0100
16818 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/tag.h 2007-10-10 19:05:04 +0200
16823 +#include <linux/types.h>
16826 +#define DX_TAG(in) (IS_TAGGED(in))
16829 +#ifdef CONFIG_DX_TAG_NFSD
16830 +#define DX_TAG_NFSD 1
16832 +#define DX_TAG_NFSD 0
16836 +#ifdef CONFIG_TAGGING_NONE
16838 +#define MAX_UID 0xFFFFFFFF
16839 +#define MAX_GID 0xFFFFFFFF
16841 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
16843 +#define TAGINO_UID(cond, uid, tag) (uid)
16844 +#define TAGINO_GID(cond, gid, tag) (gid)
16849 +#ifdef CONFIG_TAGGING_GID16
16851 +#define MAX_UID 0xFFFFFFFF
16852 +#define MAX_GID 0x0000FFFF
16854 +#define INOTAG_TAG(cond, uid, gid, tag) \
16855 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
16857 +#define TAGINO_UID(cond, uid, tag) (uid)
16858 +#define TAGINO_GID(cond, gid, tag) \
16859 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
16864 +#ifdef CONFIG_TAGGING_ID24
16866 +#define MAX_UID 0x00FFFFFF
16867 +#define MAX_GID 0x00FFFFFF
16869 +#define INOTAG_TAG(cond, uid, gid, tag) \
16870 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
16872 +#define TAGINO_UID(cond, uid, tag) \
16873 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
16874 +#define TAGINO_GID(cond, gid, tag) \
16875 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
16880 +#ifdef CONFIG_TAGGING_UID16
16882 +#define MAX_UID 0x0000FFFF
16883 +#define MAX_GID 0xFFFFFFFF
16885 +#define INOTAG_TAG(cond, uid, gid, tag) \
16886 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
16888 +#define TAGINO_UID(cond, uid, tag) \
16889 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
16890 +#define TAGINO_GID(cond, gid, tag) (gid)
16895 +#ifdef CONFIG_TAGGING_INTERN
16897 +#define MAX_UID 0xFFFFFFFF
16898 +#define MAX_GID 0xFFFFFFFF
16900 +#define INOTAG_TAG(cond, uid, gid, tag) \
16901 + ((cond) ? (tag) : 0)
16903 +#define TAGINO_UID(cond, uid, tag) (uid)
16904 +#define TAGINO_GID(cond, gid, tag) (gid)
16909 +#ifndef CONFIG_TAGGING_NONE
16910 +#define dx_current_fstag(sb) \
16911 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
16913 +#define dx_current_fstag(sb) (0)
16916 +#ifndef CONFIG_TAGGING_INTERN
16917 +#define TAGINO_TAG(cond, tag) (0)
16919 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
16922 +#define INOTAG_UID(cond, uid, gid) \
16923 + ((cond) ? ((uid) & MAX_UID) : (uid))
16924 +#define INOTAG_GID(cond, uid, gid) \
16925 + ((cond) ? ((gid) & MAX_GID) : (gid))
16928 +static inline uid_t dx_map_uid(uid_t uid)
16930 + if ((uid > MAX_UID) && (uid != -1))
16932 + return (uid & MAX_UID);
16935 +static inline gid_t dx_map_gid(gid_t gid)
16937 + if ((gid > MAX_GID) && (gid != -1))
16939 + return (gid & MAX_GID);
16947 +#define dx_notagcheck(nd) \
16948 + ((nd) && (nd)->mnt && ((nd)->mnt->mnt_flags & MNT_NOTAGCHECK))
16950 +int dx_parse_tag(char *string, tag_t *tag, int remove);
16952 +#ifdef CONFIG_PROPAGATE
16954 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
16956 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
16959 +#define dx_propagate_tag(n, i) do { } while (0)
16962 +#endif /* _DX_TAG_H */
16963 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/tag_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/tag_cmd.h
16964 --- linux-2.6.22.10/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00 +0100
16965 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/tag_cmd.h 2007-08-15 20:16:43 +0200
16967 +#ifndef _VX_TAG_CMD_H
16968 +#define _VX_TAG_CMD_H
16971 +/* vinfo commands */
16973 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
16976 +extern int vc_task_tag(uint32_t);
16978 +#endif /* __KERNEL__ */
16980 +/* context commands */
16982 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
16985 +extern int vc_tag_migrate(uint32_t);
16987 +#endif /* __KERNEL__ */
16988 +#endif /* _VX_TAG_CMD_H */
16989 diff -NurpP --minimal linux-2.6.22.10/include/net/addrconf.h linux-2.6.22.10-vs2.3.0.29/include/net/addrconf.h
16990 --- linux-2.6.22.10/include/net/addrconf.h 2007-07-09 13:20:01 +0200
16991 +++ linux-2.6.22.10-vs2.3.0.29/include/net/addrconf.h 2007-08-12 00:22:19 +0200
16992 @@ -69,10 +69,12 @@ extern struct inet6_ifaddr * ipv6_get_if
16994 extern int ipv6_get_saddr(struct dst_entry *dst,
16995 struct in6_addr *daddr,
16996 - struct in6_addr *saddr);
16997 + struct in6_addr *saddr,
16998 + struct nx_info *nxi);
16999 extern int ipv6_dev_get_saddr(struct net_device *dev,
17000 struct in6_addr *daddr,
17001 - struct in6_addr *saddr);
17002 + struct in6_addr *saddr,
17003 + struct nx_info *nxi);
17004 extern int ipv6_get_lladdr(struct net_device *dev,
17005 struct in6_addr *addr,
17006 unsigned char banned_flags);
17007 diff -NurpP --minimal linux-2.6.22.10/include/net/af_unix.h linux-2.6.22.10-vs2.3.0.29/include/net/af_unix.h
17008 --- linux-2.6.22.10/include/net/af_unix.h 2007-07-09 13:20:01 +0200
17009 +++ linux-2.6.22.10-vs2.3.0.29/include/net/af_unix.h 2007-08-05 20:53:13 +0200
17011 #include <linux/socket.h>
17012 #include <linux/un.h>
17013 #include <linux/mutex.h>
17014 +#include <linux/vs_base.h>
17015 #include <net/sock.h>
17017 extern void unix_inflight(struct file *fp);
17018 @@ -17,9 +18,9 @@ extern spinlock_t unix_table_lock;
17020 extern atomic_t unix_tot_inflight;
17022 -static inline struct sock *first_unix_socket(int *i)
17023 +static inline struct sock *next_unix_socket_table(int *i)
17025 - for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
17026 + for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
17027 if (!hlist_empty(&unix_socket_table[*i]))
17028 return __sk_head(&unix_socket_table[*i]);
17030 @@ -28,16 +29,19 @@ static inline struct sock *first_unix_so
17032 static inline struct sock *next_unix_socket(int *i, struct sock *s)
17034 - struct sock *next = sk_next(s);
17035 - /* More in this chain? */
17038 - /* Look for next non-empty chain. */
17039 - for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
17040 - if (!hlist_empty(&unix_socket_table[*i]))
17041 - return __sk_head(&unix_socket_table[*i]);
17048 + s = next_unix_socket_table(i);
17049 + } while (s && !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT));
17053 +static inline struct sock *first_unix_socket(int *i)
17056 + return next_unix_socket(i, NULL);
17059 #define forall_unix_sockets(i, s) \
17060 diff -NurpP --minimal linux-2.6.22.10/include/net/inet_timewait_sock.h linux-2.6.22.10-vs2.3.0.29/include/net/inet_timewait_sock.h
17061 --- linux-2.6.22.10/include/net/inet_timewait_sock.h 2007-05-02 19:25:35 +0200
17062 +++ linux-2.6.22.10-vs2.3.0.29/include/net/inet_timewait_sock.h 2007-08-05 20:53:13 +0200
17063 @@ -115,6 +115,10 @@ struct inet_timewait_sock {
17064 #define tw_refcnt __tw_common.skc_refcnt
17065 #define tw_hash __tw_common.skc_hash
17066 #define tw_prot __tw_common.skc_prot
17067 +#define tw_xid __tw_common.skc_xid
17068 +#define tw_vx_info __tw_common.skc_vx_info
17069 +#define tw_nid __tw_common.skc_nid
17070 +#define tw_nx_info __tw_common.skc_nx_info
17071 volatile unsigned char tw_substate;
17072 /* 3 bits hole, try to pack */
17073 unsigned char tw_rcv_wscale;
17074 diff -NurpP --minimal linux-2.6.22.10/include/net/route.h linux-2.6.22.10-vs2.3.0.29/include/net/route.h
17075 --- linux-2.6.22.10/include/net/route.h 2007-05-02 19:25:35 +0200
17076 +++ linux-2.6.22.10-vs2.3.0.29/include/net/route.h 2007-09-18 03:52:05 +0200
17077 @@ -27,12 +27,16 @@
17078 #include <net/dst.h>
17079 #include <net/inetpeer.h>
17080 #include <net/flow.h>
17081 +#include <net/inet_sock.h>
17082 #include <linux/in_route.h>
17083 #include <linux/rtnetlink.h>
17084 #include <linux/route.h>
17085 #include <linux/ip.h>
17086 #include <linux/cache.h>
17087 #include <linux/security.h>
17088 +#include <linux/vs_base.h>
17089 +#include <linux/vs_inet.h>
17090 +#include <linux/in.h>
17093 #warning This file is not supposed to be used outside of kernel.
17094 @@ -143,6 +147,8 @@ static inline char rt_tos2priority(u8 to
17095 return ip_tos2prio[IPTOS_TOS(tos)>>1];
17098 +extern int ip_v4_find_src(struct nx_info *, struct rtable **, struct flowi *);
17100 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
17101 __be32 src, u32 tos, int oif, u8 protocol,
17102 __be16 sport, __be16 dport, struct sock *sk,
17103 @@ -158,7 +164,21 @@ static inline int ip_route_connect(struc
17104 .dport = dport } } };
17107 - if (!dst || !src) {
17108 + struct nx_info *nx_info = current->nx_info;
17111 + nx_info = sk->sk_nx_info;
17113 + vxdprintk(VXD_CBIT(net, 4),
17114 + "ip_route_connect(%p) %p,%p;%lx",
17115 + sk, nx_info, sk->sk_socket,
17116 + (sk->sk_socket?sk->sk_socket->flags:0));
17118 + err = ip_v4_find_src(nx_info, rp, &fl);
17122 + if (!fl.fl4_dst || !fl.fl4_src) {
17123 err = __ip_route_output_key(rp, &fl);
17126 diff -NurpP --minimal linux-2.6.22.10/include/net/sock.h linux-2.6.22.10-vs2.3.0.29/include/net/sock.h
17127 --- linux-2.6.22.10/include/net/sock.h 2007-07-09 13:20:02 +0200
17128 +++ linux-2.6.22.10-vs2.3.0.29/include/net/sock.h 2007-08-05 20:53:13 +0200
17129 @@ -119,6 +119,10 @@ struct sock_common {
17130 atomic_t skc_refcnt;
17131 unsigned int skc_hash;
17132 struct proto *skc_prot;
17134 + struct vx_info *skc_vx_info;
17136 + struct nx_info *skc_nx_info;
17140 @@ -195,6 +199,10 @@ struct sock {
17141 #define sk_refcnt __sk_common.skc_refcnt
17142 #define sk_hash __sk_common.skc_hash
17143 #define sk_prot __sk_common.skc_prot
17144 +#define sk_xid __sk_common.skc_xid
17145 +#define sk_vx_info __sk_common.skc_vx_info
17146 +#define sk_nid __sk_common.skc_nid
17147 +#define sk_nx_info __sk_common.skc_nx_info
17148 unsigned char sk_shutdown : 2,
17151 diff -NurpP --minimal linux-2.6.22.10/init/main.c linux-2.6.22.10-vs2.3.0.29/init/main.c
17152 --- linux-2.6.22.10/init/main.c 2007-07-09 13:20:03 +0200
17153 +++ linux-2.6.22.10-vs2.3.0.29/init/main.c 2007-08-05 20:53:13 +0200
17155 #include <linux/pid_namespace.h>
17156 #include <linux/device.h>
17157 #include <linux/kthread.h>
17158 +#include <linux/vserver/percpu.h>
17160 #include <asm/io.h>
17161 #include <asm/bugs.h>
17162 @@ -364,12 +365,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
17164 static void __init setup_per_cpu_areas(void)
17166 - unsigned long size, i;
17167 + unsigned long size, vspc, i;
17169 unsigned long nr_possible_cpus = num_possible_cpus();
17171 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
17173 /* Copy section for each CPU (we discard the original) */
17174 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
17175 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
17176 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
17178 for_each_possible_cpu(i) {
17179 diff -NurpP --minimal linux-2.6.22.10/ipc/mqueue.c linux-2.6.22.10-vs2.3.0.29/ipc/mqueue.c
17180 --- linux-2.6.22.10/ipc/mqueue.c 2007-07-09 13:20:03 +0200
17181 +++ linux-2.6.22.10-vs2.3.0.29/ipc/mqueue.c 2007-10-01 14:57:41 +0200
17183 #include <linux/audit.h>
17184 #include <linux/signal.h>
17185 #include <linux/mutex.h>
17186 +#include <linux/vs_context.h>
17187 +#include <linux/vs_limit.h>
17189 #include <net/sock.h>
17191 @@ -151,17 +153,20 @@ static struct inode *mqueue_get_inode(st
17192 spin_lock(&mq_lock);
17193 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
17194 u->mq_bytes + mq_bytes >
17195 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
17196 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
17197 + !vx_ipcmsg_avail(p->vx_info, mq_bytes)) {
17198 spin_unlock(&mq_lock);
17201 u->mq_bytes += mq_bytes;
17202 + vx_ipcmsg_add(p->vx_info, u, mq_bytes);
17203 spin_unlock(&mq_lock);
17205 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
17206 if (!info->messages) {
17207 spin_lock(&mq_lock);
17208 u->mq_bytes -= mq_bytes;
17209 + vx_ipcmsg_sub(p->vx_info, u, mq_bytes);
17210 spin_unlock(&mq_lock);
17213 @@ -257,10 +262,14 @@ static void mqueue_delete_inode(struct i
17214 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
17217 + struct vx_info *vxi = lookup_vx_info(user->xid);
17219 spin_lock(&mq_lock);
17220 user->mq_bytes -= mq_bytes;
17221 + vx_ipcmsg_sub(vxi, user, mq_bytes);
17223 spin_unlock(&mq_lock);
17224 + put_vx_info(vxi);
17228 @@ -748,7 +757,7 @@ asmlinkage long sys_mq_unlink(const char
17230 atomic_inc(&inode->i_count);
17232 - err = vfs_unlink(dentry->d_parent->d_inode, dentry);
17233 + err = vfs_unlink(dentry->d_parent->d_inode, dentry, NULL);
17237 diff -NurpP --minimal linux-2.6.22.10/ipc/msg.c linux-2.6.22.10-vs2.3.0.29/ipc/msg.c
17238 --- linux-2.6.22.10/ipc/msg.c 2007-02-06 03:01:55 +0100
17239 +++ linux-2.6.22.10-vs2.3.0.29/ipc/msg.c 2007-08-05 20:53:13 +0200
17241 #include <linux/seq_file.h>
17242 #include <linux/mutex.h>
17243 #include <linux/nsproxy.h>
17244 +#include <linux/vs_base.h>
17246 #include <asm/current.h>
17247 #include <asm/uaccess.h>
17248 @@ -149,6 +150,7 @@ static int newque (struct ipc_namespace
17250 msq->q_perm.mode = msgflg & S_IRWXUGO;
17251 msq->q_perm.key = key;
17252 + msq->q_perm.xid = vx_current_xid();
17254 msq->q_perm.security = NULL;
17255 retval = security_msg_queue_alloc(msq);
17256 diff -NurpP --minimal linux-2.6.22.10/ipc/sem.c linux-2.6.22.10-vs2.3.0.29/ipc/sem.c
17257 --- linux-2.6.22.10/ipc/sem.c 2007-07-09 13:20:03 +0200
17258 +++ linux-2.6.22.10-vs2.3.0.29/ipc/sem.c 2007-08-05 20:53:13 +0200
17260 #include <linux/seq_file.h>
17261 #include <linux/mutex.h>
17262 #include <linux/nsproxy.h>
17263 +#include <linux/vs_base.h>
17264 +#include <linux/vs_limit.h>
17266 #include <asm/uaccess.h>
17268 @@ -229,6 +231,7 @@ static int newary (struct ipc_namespace
17270 sma->sem_perm.mode = (semflg & S_IRWXUGO);
17271 sma->sem_perm.key = key;
17272 + sma->sem_perm.xid = vx_current_xid();
17274 sma->sem_perm.security = NULL;
17275 retval = security_sem_alloc(sma);
17276 @@ -244,6 +247,9 @@ static int newary (struct ipc_namespace
17279 ns->used_sems += nsems;
17280 + /* FIXME: obsoleted? */
17281 + vx_semary_inc(sma);
17282 + vx_nsems_add(sma, nsems);
17284 sma->sem_id = sem_buildid(ns, id, sma->sem_perm.seq);
17285 sma->sem_base = (struct sem *) &sma[1];
17286 @@ -525,6 +531,9 @@ static void freeary (struct ipc_namespac
17289 ns->used_sems -= sma->sem_nsems;
17290 + /* FIXME: obsoleted? */
17291 + vx_nsems_sub(sma, sma->sem_nsems);
17292 + vx_semary_dec(sma);
17293 size = sizeof (*sma) + sma->sem_nsems * sizeof (struct sem);
17294 security_sem_free(sma);
17295 ipc_rcu_putref(sma);
17296 diff -NurpP --minimal linux-2.6.22.10/ipc/shm.c linux-2.6.22.10-vs2.3.0.29/ipc/shm.c
17297 --- linux-2.6.22.10/ipc/shm.c 2007-10-30 01:57:14 +0100
17298 +++ linux-2.6.22.10-vs2.3.0.29/ipc/shm.c 2007-10-01 14:57:41 +0200
17300 #include <linux/mutex.h>
17301 #include <linux/nsproxy.h>
17302 #include <linux/mount.h>
17303 +#include <linux/vs_context.h>
17304 +#include <linux/vs_limit.h>
17306 #include <asm/uaccess.h>
17308 @@ -185,7 +187,12 @@ static void shm_open(struct vm_area_stru
17310 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
17312 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
17313 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
17314 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
17316 + vx_ipcshm_sub(vxi, shp, numpages);
17317 + ns->shm_tot -= numpages;
17319 shm_rmid(ns, shp->id);
17321 if (!is_file_hugepages(shp->shm_file))
17322 @@ -195,6 +202,7 @@ static void shm_destroy(struct ipc_names
17324 fput (shp->shm_file);
17325 security_shm_free(shp);
17326 + put_vx_info(vxi);
17327 ipc_rcu_putref(shp);
17330 @@ -351,11 +359,15 @@ static int newseg (struct ipc_namespace
17331 if (ns->shm_tot + numpages > ns->shm_ctlall)
17334 + if (!vx_ipcshm_avail(current->vx_info, numpages))
17337 shp = ipc_rcu_alloc(sizeof(*shp));
17341 shp->shm_perm.key = key;
17342 + shp->shm_perm.xid = vx_current_xid();
17343 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
17344 shp->mlock_user = NULL;
17346 @@ -406,6 +418,7 @@ static int newseg (struct ipc_namespace
17347 file->f_dentry->d_inode->i_ino = shp->id;
17349 ns->shm_tot += numpages;
17350 + vx_ipcshm_add(current->vx_info, key, numpages);
17354 diff -NurpP --minimal linux-2.6.22.10/ipc/util.c linux-2.6.22.10-vs2.3.0.29/ipc/util.c
17355 --- linux-2.6.22.10/ipc/util.c 2007-07-09 13:20:03 +0200
17356 +++ linux-2.6.22.10-vs2.3.0.29/ipc/util.c 2007-08-05 20:53:13 +0200
17358 #include <linux/proc_fs.h>
17359 #include <linux/audit.h>
17360 #include <linux/nsproxy.h>
17361 +#include <linux/vs_base.h>
17362 +#include <linux/vserver/global.h>
17364 #include <asm/unistd.h>
17366 @@ -72,6 +74,7 @@ static struct ipc_namespace *clone_ipc_n
17369 kref_init(&ns->kref);
17370 + atomic_inc(&vs_global_ipc_ns);
17374 @@ -108,6 +111,7 @@ void free_ipc_ns(struct kref *kref)
17378 + atomic_dec(&vs_global_ipc_ns);
17382 diff -NurpP --minimal linux-2.6.22.10/kernel/Makefile linux-2.6.22.10-vs2.3.0.29/kernel/Makefile
17383 --- linux-2.6.22.10/kernel/Makefile 2007-07-09 13:20:03 +0200
17384 +++ linux-2.6.22.10-vs2.3.0.29/kernel/Makefile 2007-08-05 20:53:13 +0200
17385 @@ -10,6 +10,8 @@ obj-y = sched.o fork.o exec_domain.o
17386 kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
17387 hrtimer.o rwsem.o latency.o nsproxy.o srcu.o die_notifier.o
17391 obj-$(CONFIG_STACKTRACE) += stacktrace.o
17393 obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o
17394 diff -NurpP --minimal linux-2.6.22.10/kernel/capability.c linux-2.6.22.10-vs2.3.0.29/kernel/capability.c
17395 --- linux-2.6.22.10/kernel/capability.c 2007-05-02 19:25:37 +0200
17396 +++ linux-2.6.22.10-vs2.3.0.29/kernel/capability.c 2007-08-05 20:53:13 +0200
17398 #include <linux/module.h>
17399 #include <linux/security.h>
17400 #include <linux/syscalls.h>
17401 +#include <linux/vs_context.h>
17402 #include <asm/uaccess.h>
17404 unsigned securebits = SECUREBITS_DEFAULT; /* systemwide security settings */
17405 @@ -103,6 +104,8 @@ static inline int cap_set_pg(int pgrp_nr
17407 pgrp = find_pid(pgrp_nr);
17408 do_each_pid_task(pgrp, PIDTYPE_PGID, g) {
17409 + if (!vx_check(g->xid, VS_ADMIN_P | VS_IDENT))
17412 while_each_thread(g, target) {
17413 if (!security_capset_check(target, effective,
17414 @@ -246,8 +249,12 @@ int __capable(struct task_struct *t, int
17416 EXPORT_SYMBOL(__capable);
17418 +#include <linux/vserver/base.h>
17419 int capable(int cap)
17421 + /* here for now so we don't require task locking */
17422 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
17424 return __capable(current, cap);
17426 EXPORT_SYMBOL(capable);
17427 diff -NurpP --minimal linux-2.6.22.10/kernel/compat.c linux-2.6.22.10-vs2.3.0.29/kernel/compat.c
17428 --- linux-2.6.22.10/kernel/compat.c 2007-07-09 13:20:03 +0200
17429 +++ linux-2.6.22.10-vs2.3.0.29/kernel/compat.c 2007-08-05 20:53:13 +0200
17430 @@ -846,7 +846,7 @@ asmlinkage long compat_sys_time(compat_t
17434 - do_gettimeofday(&tv);
17435 + vx_gettimeofday(&tv);
17439 @@ -870,7 +870,7 @@ asmlinkage long compat_sys_stime(compat_
17443 - do_settimeofday(&tv);
17444 + vx_settimeofday(&tv);
17448 diff -NurpP --minimal linux-2.6.22.10/kernel/exit.c linux-2.6.22.10-vs2.3.0.29/kernel/exit.c
17449 --- linux-2.6.22.10/kernel/exit.c 2007-07-09 13:20:03 +0200
17450 +++ linux-2.6.22.10-vs2.3.0.29/kernel/exit.c 2007-10-01 18:31:46 +0200
17452 #include <linux/resource.h>
17453 #include <linux/blkdev.h>
17454 #include <linux/task_io_accounting_ops.h>
17455 +#include <linux/vs_limit.h>
17456 +#include <linux/vs_context.h>
17457 +#include <linux/vs_network.h>
17458 +#include <linux/vs_pid.h>
17459 +#include <linux/vserver/global.h>
17461 #include <asm/uaccess.h>
17462 #include <asm/unistd.h>
17463 @@ -443,9 +448,11 @@ static void close_files(struct files_str
17464 filp_close(file, files);
17467 + vx_openfd_dec(i);
17475 @@ -525,6 +532,7 @@ static inline void __put_fs_struct(struc
17477 mntput(fs->altrootmnt);
17479 + atomic_dec(&vs_global_fs);
17480 kmem_cache_free(fs_cachep, fs);
17483 @@ -596,6 +604,14 @@ static void exit_mm(struct task_struct *
17485 choose_new_parent(struct task_struct *p, struct task_struct *reaper)
17487 + /* check for reaper context */
17488 + vxwprintk((p->xid != reaper->xid) && (reaper != child_reaper(p)),
17489 + "rogue reaper: %p[%d,#%u] <> %p[%d,#%u]",
17490 + p, p->pid, p->xid, reaper, reaper->pid, reaper->xid);
17493 + reaper = vx_child_reaper(p);
17496 * Make sure we're not reparenting to ourselves and that
17497 * the parent is not a zombie.
17498 @@ -687,7 +703,7 @@ forget_original_parent(struct task_struc
17500 reaper = next_thread(reaper);
17501 if (reaper == father) {
17502 - reaper = child_reaper(father);
17503 + reaper = vx_child_reaper(father);
17506 } while (reaper->exit_state);
17507 @@ -964,6 +980,8 @@ fastcall NORET_TYPE void do_exit(long co
17508 tsk->exit_code = code;
17509 proc_exit_connector(tsk);
17510 exit_task_namespaces(tsk);
17511 + /* needs to stay before exit_notify() */
17512 + exit_vx_info_early(tsk, code);
17515 mpol_free(tsk->mempolicy);
17516 @@ -994,6 +1012,10 @@ fastcall NORET_TYPE void do_exit(long co
17517 if (tsk->splice_pipe)
17518 __free_pipe_info(tsk->splice_pipe);
17520 + /* needs to stay after exit_notify() */
17521 + exit_vx_info(tsk, code);
17522 + exit_nx_info(tsk);
17525 /* causes final put_task_struct in finish_task_switch(). */
17526 tsk->state = TASK_DEAD;
17527 diff -NurpP --minimal linux-2.6.22.10/kernel/fork.c linux-2.6.22.10-vs2.3.0.29/kernel/fork.c
17528 --- linux-2.6.22.10/kernel/fork.c 2007-07-09 13:20:03 +0200
17529 +++ linux-2.6.22.10-vs2.3.0.29/kernel/fork.c 2007-10-25 17:05:55 +0200
17531 #include <linux/delayacct.h>
17532 #include <linux/taskstats_kern.h>
17533 #include <linux/random.h>
17534 +#include <linux/vs_context.h>
17535 +#include <linux/vs_network.h>
17536 +#include <linux/vs_limit.h>
17537 +#include <linux/vs_memory.h>
17538 +#include <linux/vserver/global.h>
17540 #include <asm/pgtable.h>
17541 #include <asm/pgalloc.h>
17542 @@ -108,6 +113,8 @@ void free_task(struct task_struct *tsk)
17544 free_thread_info(tsk->stack);
17545 rt_mutex_debug_task_free(tsk);
17546 + clr_vx_info(&tsk->vx_info);
17547 + clr_nx_info(&tsk->nx_info);
17548 free_task_struct(tsk);
17550 EXPORT_SYMBOL(free_task);
17551 @@ -215,6 +222,8 @@ static inline int dup_mmap(struct mm_str
17552 mm->free_area_cache = oldmm->mmap_base;
17553 mm->cached_hole_size = ~0UL;
17555 + __set_mm_counter(mm, file_rss, 0);
17556 + __set_mm_counter(mm, anon_rss, 0);
17557 cpus_clear(mm->cpu_vm_mask);
17558 mm->mm_rb = RB_ROOT;
17559 rb_link = &mm->mm_rb.rb_node;
17560 @@ -226,7 +235,7 @@ static inline int dup_mmap(struct mm_str
17562 if (mpnt->vm_flags & VM_DONTCOPY) {
17563 long pages = vma_pages(mpnt);
17564 - mm->total_vm -= pages;
17565 + vx_vmpages_sub(mm, pages);
17566 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
17569 @@ -327,7 +336,7 @@ static inline void mm_free_pgd(struct mm
17571 #include <linux/init_task.h>
17573 -static struct mm_struct * mm_init(struct mm_struct * mm)
17574 +static struct mm_struct * mm_init(struct mm_struct * mm, struct vx_info *vxi)
17576 atomic_set(&mm->mm_users, 1);
17577 atomic_set(&mm->mm_count, 1);
17578 @@ -335,8 +344,8 @@ static struct mm_struct * mm_init(struct
17579 INIT_LIST_HEAD(&mm->mmlist);
17580 mm->core_waiters = 0;
17582 - set_mm_counter(mm, file_rss, 0);
17583 - set_mm_counter(mm, anon_rss, 0);
17584 + __set_mm_counter(mm, file_rss, 0);
17585 + __set_mm_counter(mm, anon_rss, 0);
17586 spin_lock_init(&mm->page_table_lock);
17587 rwlock_init(&mm->ioctx_list_lock);
17588 mm->ioctx_list = NULL;
17589 @@ -345,6 +354,7 @@ static struct mm_struct * mm_init(struct
17591 if (likely(!mm_alloc_pgd(mm))) {
17593 + set_vx_info(&mm->mm_vx_info, vxi);
17597 @@ -361,7 +371,7 @@ struct mm_struct * mm_alloc(void)
17598 mm = allocate_mm();
17600 memset(mm, 0, sizeof(*mm));
17601 - mm = mm_init(mm);
17602 + mm = mm_init(mm, current->vx_info);
17606 @@ -376,6 +386,7 @@ void fastcall __mmdrop(struct mm_struct
17607 BUG_ON(mm == &init_mm);
17609 destroy_context(mm);
17610 + clr_vx_info(&mm->mm_vx_info);
17614 @@ -490,12 +501,13 @@ static struct mm_struct *dup_mm(struct t
17617 memcpy(mm, oldmm, sizeof(*mm));
17618 + mm->mm_vx_info = NULL;
17620 /* Initializing for Swap token stuff */
17621 mm->token_priority = 0;
17622 mm->last_interval = 0;
17624 - if (!mm_init(mm))
17625 + if (!mm_init(mm, oldmm->mm_vx_info))
17628 if (init_new_context(tsk, mm))
17629 @@ -521,6 +533,7 @@ fail_nocontext:
17630 * If init_new_context() failed, we cannot use mmput() to free the mm
17631 * because it calls destroy_context()
17633 + clr_vx_info(&mm->mm_vx_info);
17637 @@ -591,6 +604,7 @@ static inline struct fs_struct *__copy_f
17638 fs->altroot = NULL;
17640 read_unlock(&old->lock);
17641 + atomic_inc(&vs_global_fs);
17645 @@ -709,6 +723,8 @@ static struct files_struct *dup_fd(struc
17646 struct file *f = *old_fds++;
17649 + /* TODO: sum it first for check and performance */
17650 + vx_openfd_inc(open_files - i);
17653 * The fd may be claimed in the fd bitmap but not yet
17654 @@ -961,6 +977,8 @@ static struct task_struct *copy_process(
17657 struct task_struct *p = NULL;
17658 + struct vx_info *vxi;
17659 + struct nx_info *nxi;
17661 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
17662 return ERR_PTR(-EINVAL);
17663 @@ -995,12 +1013,30 @@ static struct task_struct *copy_process(
17664 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
17665 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
17667 + init_vx_info(&p->vx_info, current->vx_info);
17668 + init_nx_info(&p->nx_info, current->nx_info);
17670 + /* check vserver memory */
17671 + if (p->mm && !(clone_flags & CLONE_VM)) {
17672 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
17673 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17675 + goto bad_fork_free;
17677 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
17678 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
17679 + goto bad_fork_cleanup_vm;
17683 + if (!vx_nproc_avail(1))
17684 + goto bad_fork_cleanup_vm;
17686 if (atomic_read(&p->user->processes) >=
17687 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
17688 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
17689 p->user != &root_user)
17690 - goto bad_fork_free;
17691 + goto bad_fork_cleanup_vm;
17694 atomic_inc(&p->user->__count);
17695 @@ -1265,6 +1301,18 @@ static struct task_struct *copy_process(
17698 spin_unlock(¤t->sighand->siglock);
17700 + /* p is copy of current */
17701 + vxi = p->vx_info;
17703 + claim_vx_info(vxi, p);
17704 + atomic_inc(&vxi->cvirt.nr_threads);
17705 + atomic_inc(&vxi->cvirt.total_forks);
17708 + nxi = p->nx_info;
17710 + claim_nx_info(nxi, p);
17711 write_unlock_irq(&tasklist_lock);
17712 proc_fork_connector(p);
17714 @@ -1306,6 +1354,9 @@ bad_fork_cleanup_count:
17715 put_group_info(p->group_info);
17716 atomic_dec(&p->user->processes);
17718 +bad_fork_cleanup_vm:
17719 + if (p->mm && !(clone_flags & CLONE_VM))
17720 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17724 @@ -1367,6 +1418,15 @@ long do_fork(unsigned long clone_flags,
17729 + /* kernel threads are host only */
17730 + if ((clone_flags & CLONE_KTHREAD) &&
17731 + !vx_capable(CAP_SYS_ADMIN, VXC_KTHREAD)) {
17732 + vxwprintk_task(1, "tried to spawn a kernel thread.");
17738 if (unlikely(current->ptrace)) {
17739 trace = fork_traceflag (clone_flags);
17740 diff -NurpP --minimal linux-2.6.22.10/kernel/kthread.c linux-2.6.22.10-vs2.3.0.29/kernel/kthread.c
17741 --- linux-2.6.22.10/kernel/kthread.c 2007-07-09 13:20:03 +0200
17742 +++ linux-2.6.22.10-vs2.3.0.29/kernel/kthread.c 2007-08-05 20:53:13 +0200
17743 @@ -96,7 +96,7 @@ static void create_kthread(struct kthrea
17745 wait_for_completion(&create->started);
17746 read_lock(&tasklist_lock);
17747 - create->result = find_task_by_pid(pid);
17748 + create->result = find_task_by_real_pid(pid);
17749 read_unlock(&tasklist_lock);
17751 complete(&create->done);
17752 diff -NurpP --minimal linux-2.6.22.10/kernel/nsproxy.c linux-2.6.22.10-vs2.3.0.29/kernel/nsproxy.c
17753 --- linux-2.6.22.10/kernel/nsproxy.c 2007-07-09 13:20:03 +0200
17754 +++ linux-2.6.22.10-vs2.3.0.29/kernel/nsproxy.c 2007-08-05 20:53:13 +0200
17755 @@ -20,14 +20,11 @@
17756 #include <linux/mnt_namespace.h>
17757 #include <linux/utsname.h>
17758 #include <linux/pid_namespace.h>
17759 +#include <linux/vserver/global.h>
17760 +#include <linux/vserver/debug.h>
17762 struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
17764 -static inline void get_nsproxy(struct nsproxy *ns)
17766 - atomic_inc(&ns->count);
17769 void get_task_namespaces(struct task_struct *tsk)
17771 struct nsproxy *ns = tsk->nsproxy;
17772 @@ -46,6 +43,9 @@ static inline struct nsproxy *clone_nspr
17773 ns = kmemdup(orig, sizeof(struct nsproxy), GFP_KERNEL);
17775 atomic_set(&ns->count, 1);
17776 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
17777 + orig, atomic_read(&orig->count), ns);
17778 + atomic_inc(&vs_global_nsproxy);
17782 @@ -54,28 +54,32 @@ static inline struct nsproxy *clone_nspr
17783 * Return the newly created nsproxy. Do not attach this to the task,
17784 * leave it to the caller to do proper locking and attach it to task.
17786 -static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
17787 +static struct nsproxy *unshare_namespaces(int flags, struct nsproxy *orig,
17788 struct fs_struct *new_fs)
17790 struct nsproxy *new_nsp;
17792 - new_nsp = clone_nsproxy(tsk->nsproxy);
17793 + vxdprintk(VXD_CBIT(space, 4),
17794 + "unshare_namespaces(0x%08x,%p,%p)",
17795 + flags, orig, new_fs);
17797 + new_nsp = clone_nsproxy(orig);
17799 return ERR_PTR(-ENOMEM);
17801 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
17802 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
17803 if (IS_ERR(new_nsp->mnt_ns))
17806 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
17807 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
17808 if (IS_ERR(new_nsp->uts_ns))
17811 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
17812 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
17813 if (IS_ERR(new_nsp->ipc_ns))
17816 - new_nsp->pid_ns = copy_pid_ns(flags, tsk->nsproxy->pid_ns);
17817 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
17818 if (IS_ERR(new_nsp->pid_ns))
17821 @@ -95,6 +99,33 @@ out_ns:
17822 return ERR_PTR(-ENOMEM);
17825 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
17826 + struct fs_struct *new_fs)
17828 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
17832 + * copies the nsproxy, setting refcount to 1, and grabbing a
17833 + * reference to all contained namespaces.
17835 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
17837 + struct nsproxy *ns = clone_nsproxy(orig);
17841 + get_mnt_ns(ns->mnt_ns);
17843 + get_uts_ns(ns->uts_ns);
17845 + get_ipc_ns(ns->ipc_ns);
17847 + get_pid_ns(ns->pid_ns);
17853 * called from clone. This now handles copy for nsproxy and all
17854 * namespaces therein.
17855 @@ -102,9 +133,12 @@ out_ns:
17856 int copy_namespaces(int flags, struct task_struct *tsk)
17858 struct nsproxy *old_ns = tsk->nsproxy;
17859 - struct nsproxy *new_ns;
17860 + struct nsproxy *new_ns = NULL;
17863 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08x,%p[%p])",
17864 + flags, tsk, old_ns);
17869 @@ -127,6 +161,9 @@ int copy_namespaces(int flags, struct ta
17870 tsk->nsproxy = new_ns;
17872 put_nsproxy(old_ns);
17873 + vxdprintk(VXD_CBIT(space, 3),
17874 + "copy_namespaces(0x%08x,%p[%p]) = %d [%p]",
17875 + flags, tsk, old_ns, err, new_ns);
17879 @@ -140,6 +177,7 @@ void free_nsproxy(struct nsproxy *ns)
17880 put_ipc_ns(ns->ipc_ns);
17882 put_pid_ns(ns->pid_ns);
17883 + atomic_dec(&vs_global_nsproxy);
17887 @@ -152,6 +190,10 @@ int unshare_nsproxy_namespaces(unsigned
17891 + vxdprintk(VXD_CBIT(space, 4),
17892 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
17893 + unshare_flags, current->nsproxy);
17895 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC)))
17898 diff -NurpP --minimal linux-2.6.22.10/kernel/pid.c linux-2.6.22.10-vs2.3.0.29/kernel/pid.c
17899 --- linux-2.6.22.10/kernel/pid.c 2007-07-09 13:20:03 +0200
17900 +++ linux-2.6.22.10-vs2.3.0.29/kernel/pid.c 2007-08-05 20:53:13 +0200
17902 #include <linux/hash.h>
17903 #include <linux/pid_namespace.h>
17904 #include <linux/init_task.h>
17905 +#include <linux/vs_pid.h>
17907 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
17908 static struct hlist_head *pid_hash;
17909 @@ -295,6 +296,9 @@ void fastcall transfer_pid(struct task_s
17910 struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type)
17912 struct task_struct *result = NULL;
17914 + if (type == PIDTYPE_REALPID)
17915 + type = PIDTYPE_PID;
17917 struct hlist_node *first;
17918 first = rcu_dereference(pid->tasks[type].first);
17919 @@ -309,7 +313,17 @@ struct task_struct * fastcall pid_task(s
17921 struct task_struct *find_task_by_pid_type(int type, int nr)
17923 - return pid_task(find_pid(nr), type);
17924 + struct task_struct *task;
17926 + if (type == PIDTYPE_PID)
17927 + nr = vx_rmap_pid(nr);
17929 + task = pid_task(find_pid(nr), type);
17930 + if (task && (type != PIDTYPE_REALPID) &&
17931 + /* maybe VS_WATCH_P in the future? */
17932 + !vx_check(task->xid, VS_WATCH|VS_IDENT))
17937 EXPORT_SYMBOL(find_task_by_pid_type);
17938 diff -NurpP --minimal linux-2.6.22.10/kernel/posix-timers.c linux-2.6.22.10-vs2.3.0.29/kernel/posix-timers.c
17939 --- linux-2.6.22.10/kernel/posix-timers.c 2007-07-09 13:20:03 +0200
17940 +++ linux-2.6.22.10-vs2.3.0.29/kernel/posix-timers.c 2007-10-01 15:41:45 +0200
17942 #include <linux/wait.h>
17943 #include <linux/workqueue.h>
17944 #include <linux/module.h>
17945 +#include <linux/vs_context.h>
17948 * Management arrays for POSIX timers. Timers are kept in slab memory
17949 @@ -297,6 +298,12 @@ void do_schedule_next_timer(struct sigin
17951 int posix_timer_event(struct k_itimer *timr,int si_private)
17953 + struct vx_info_save vxis;
17954 + struct vx_info *vxi;
17957 + vxi = task_get_vx_info(timr->it_process);
17958 + enter_vx_info(vxi, &vxis);
17959 memset(&timr->sigq->info, 0, sizeof(siginfo_t));
17960 timr->sigq->info.si_sys_private = si_private;
17961 /* Send signal to the process that owns this timer.*/
17962 @@ -309,11 +316,11 @@ int posix_timer_event(struct k_itimer *t
17964 if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
17965 struct task_struct *leader;
17966 - int ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
17967 - timr->it_process);
17969 + ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
17970 + timr->it_process);
17971 if (likely(ret >= 0))
17975 timr->it_sigev_notify = SIGEV_SIGNAL;
17976 leader = timr->it_process->group_leader;
17977 @@ -321,8 +328,12 @@ int posix_timer_event(struct k_itimer *t
17978 timr->it_process = leader;
17981 - return send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
17982 + ret = send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
17985 + leave_vx_info(&vxis);
17986 + put_vx_info(vxi);
17989 EXPORT_SYMBOL_GPL(posix_timer_event);
17991 @@ -402,7 +413,7 @@ static struct task_struct * good_sigeven
17992 struct task_struct *rtn = current->group_leader;
17994 if ((event->sigev_notify & SIGEV_THREAD_ID ) &&
17995 - (!(rtn = find_task_by_pid(event->sigev_notify_thread_id)) ||
17996 + (!(rtn = find_task_by_real_pid(event->sigev_notify_thread_id)) ||
17997 rtn->tgid != current->tgid ||
17998 (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL))
18000 diff -NurpP --minimal linux-2.6.22.10/kernel/printk.c linux-2.6.22.10-vs2.3.0.29/kernel/printk.c
18001 --- linux-2.6.22.10/kernel/printk.c 2007-07-09 13:20:03 +0200
18002 +++ linux-2.6.22.10-vs2.3.0.29/kernel/printk.c 2007-08-05 20:53:13 +0200
18004 #include <linux/bootmem.h>
18005 #include <linux/syscalls.h>
18006 #include <linux/jiffies.h>
18007 +#include <linux/vs_cvirt.h>
18009 #include <asm/uaccess.h>
18011 @@ -182,18 +183,13 @@ int do_syslog(int type, char __user *buf
18012 unsigned long i, j, limit, count;
18018 error = security_syslog(type);
18023 - case 0: /* Close log */
18025 - case 1: /* Open log */
18027 - case 2: /* Read from log */
18028 + if ((type >= 2) && (type <= 4)) {
18030 if (!buf || len < 0)
18032 @@ -204,6 +200,16 @@ int do_syslog(int type, char __user *buf
18037 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
18038 + return vx_do_syslog(type, buf, len);
18041 + case 0: /* Close log */
18043 + case 1: /* Open log */
18045 + case 2: /* Read from log */
18046 error = wait_event_interruptible(log_wait,
18047 (log_start - log_end));
18049 @@ -228,16 +234,6 @@ int do_syslog(int type, char __user *buf
18052 case 3: /* Read last kernel messages */
18054 - if (!buf || len < 0)
18059 - if (!access_ok(VERIFY_WRITE, buf, len)) {
18064 if (count > log_buf_len)
18065 count = log_buf_len;
18066 diff -NurpP --minimal linux-2.6.22.10/kernel/ptrace.c linux-2.6.22.10-vs2.3.0.29/kernel/ptrace.c
18067 --- linux-2.6.22.10/kernel/ptrace.c 2007-07-09 13:20:03 +0200
18068 +++ linux-2.6.22.10-vs2.3.0.29/kernel/ptrace.c 2007-08-05 20:53:13 +0200
18070 #include <linux/security.h>
18071 #include <linux/signal.h>
18072 #include <linux/audit.h>
18073 +#include <linux/vs_context.h>
18075 #include <asm/pgtable.h>
18076 #include <asm/uaccess.h>
18077 @@ -145,6 +146,11 @@ static int may_attach(struct task_struct
18078 dumpable = task->mm->dumpable;
18079 if (!dumpable && !capable(CAP_SYS_PTRACE))
18081 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
18083 + if (!vx_check(task->xid, VS_IDENT) &&
18084 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
18087 return security_ptrace(current, task);
18089 @@ -471,6 +477,10 @@ asmlinkage long sys_ptrace(long request,
18094 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
18095 + goto out_put_task_struct;
18097 if (request == PTRACE_ATTACH) {
18098 ret = ptrace_attach(child);
18099 goto out_put_task_struct;
18100 diff -NurpP --minimal linux-2.6.22.10/kernel/sched.c linux-2.6.22.10-vs2.3.0.29/kernel/sched.c
18101 --- linux-2.6.22.10/kernel/sched.c 2007-07-09 13:20:03 +0200
18102 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sched.c 2007-08-05 20:53:13 +0200
18105 #include <asm/tlb.h>
18106 #include <asm/unistd.h>
18107 +#include <linux/vs_sched.h>
18108 +#include <linux/vs_cvirt.h>
18111 * Scheduler clock - returns current time in nanosec units.
18112 @@ -281,6 +283,16 @@ struct rq {
18113 struct task_struct *migration_thread;
18114 struct list_head migration_queue;
18116 + unsigned long norm_time;
18117 + unsigned long idle_time;
18118 +#ifdef CONFIG_VSERVER_IDLETIME
18121 +#ifdef CONFIG_VSERVER_HARDCPU
18122 + struct list_head hold_queue;
18123 + unsigned long nr_onhold;
18127 #ifdef CONFIG_SCHEDSTATS
18128 /* latency stats */
18129 @@ -714,6 +726,7 @@ sched_info_switch(struct task_struct *pr
18131 static void dequeue_task(struct task_struct *p, struct prio_array *array)
18133 + BUG_ON(p->state & TASK_ONHOLD);
18134 array->nr_active--;
18135 list_del(&p->run_list);
18136 if (list_empty(array->queue + p->prio))
18137 @@ -722,6 +735,7 @@ static void dequeue_task(struct task_str
18139 static void enqueue_task(struct task_struct *p, struct prio_array *array)
18141 + BUG_ON(p->state & TASK_ONHOLD);
18142 sched_info_queued(p);
18143 list_add_tail(&p->run_list, array->queue + p->prio);
18144 __set_bit(p->prio, array->bitmap);
18145 @@ -735,12 +749,14 @@ static void enqueue_task(struct task_str
18147 static void requeue_task(struct task_struct *p, struct prio_array *array)
18149 + BUG_ON(p->state & TASK_ONHOLD);
18150 list_move_tail(&p->run_list, array->queue + p->prio);
18154 enqueue_task_head(struct task_struct *p, struct prio_array *array)
18156 + BUG_ON(p->state & TASK_ONHOLD);
18157 list_add(&p->run_list, array->queue + p->prio);
18158 __set_bit(p->prio, array->bitmap);
18159 array->nr_active++;
18160 @@ -769,6 +785,10 @@ static inline int __normal_prio(struct t
18161 bonus = CURRENT_BONUS(p) - MAX_BONUS / 2;
18163 prio = p->static_prio - bonus;
18165 + /* adjust effective priority */
18166 + prio = vx_adjust_prio(p, prio, MAX_USER_PRIO);
18168 if (prio < MAX_RT_PRIO)
18169 prio = MAX_RT_PRIO;
18170 if (prio > MAX_PRIO-1)
18171 @@ -878,6 +898,9 @@ static int effective_prio(struct task_st
18175 +#include "sched_mon.h"
18179 * __activate_task - move a task to the runqueue.
18181 @@ -887,6 +910,7 @@ static void __activate_task(struct task_
18184 target = rq->expired;
18185 + vxm_activate_task(p, rq);
18186 enqueue_task(p, target);
18187 inc_nr_running(p, rq);
18189 @@ -896,6 +920,7 @@ static void __activate_task(struct task_
18191 static inline void __activate_idle_task(struct task_struct *p, struct rq *rq)
18193 + vxm_activate_idle(p, rq);
18194 enqueue_task_head(p, rq->active);
18195 inc_nr_running(p, rq);
18197 @@ -1030,19 +1055,30 @@ static void activate_task(struct task_st
18199 p->timestamp = now;
18201 + vx_activate_task(p);
18202 __activate_task(p, rq);
18206 - * deactivate_task - remove a task from the runqueue.
18207 + * __deactivate_task - remove a task from the runqueue.
18209 -static void deactivate_task(struct task_struct *p, struct rq *rq)
18210 +static void __deactivate_task(struct task_struct *p, struct rq *rq)
18212 dec_nr_running(p, rq);
18213 dequeue_task(p, p->array);
18214 + vxm_deactivate_task(p, rq);
18219 +void deactivate_task(struct task_struct *p, struct rq *rq)
18221 + vx_deactivate_task(p);
18222 + __deactivate_task(p, rq);
18225 +#include "sched_hard.h"
18228 * resched_task - mark a task 'to be rescheduled now'.
18230 @@ -1129,6 +1165,7 @@ migrate_task(struct task_struct *p, int
18232 struct rq *rq = task_rq(p);
18234 + vxm_migrate_task(p, rq, dest_cpu);
18236 * If the task is not on a runqueue (and not running), then
18237 * it is sufficient to simply update the task's cpu field.
18238 @@ -1518,6 +1555,12 @@ static int try_to_wake_up(struct task_st
18240 rq = task_rq_lock(p, &flags);
18241 old_state = p->state;
18243 + /* we need to unhold suspended tasks */
18244 + if (old_state & TASK_ONHOLD) {
18245 + vx_unhold_task(p, rq);
18246 + old_state = p->state;
18248 if (!(old_state & state))
18251 @@ -1625,6 +1668,7 @@ out_activate:
18252 #endif /* CONFIG_SMP */
18253 if (old_state == TASK_UNINTERRUPTIBLE) {
18254 rq->nr_uninterruptible--;
18255 + vx_uninterruptible_dec(p);
18257 * Tasks on involuntary sleep don't earn
18258 * sleep_avg beyond just interactive state.
18259 @@ -1676,7 +1720,7 @@ int fastcall wake_up_state(struct task_s
18260 return try_to_wake_up(p, state, 0);
18263 -static void task_running_tick(struct rq *rq, struct task_struct *p);
18264 +static void task_running_tick(struct rq *rq, struct task_struct *p, int cpu);
18266 * Perform scheduler related setup for a newly forked process p.
18267 * p is forked by current.
18268 @@ -1737,7 +1781,7 @@ void fastcall sched_fork(struct task_str
18269 * runqueue lock is not a problem.
18271 current->time_slice = 1;
18272 - task_running_tick(cpu_rq(cpu), current);
18273 + task_running_tick(cpu_rq(cpu), current, cpu);
18275 local_irq_enable();
18277 @@ -1772,6 +1816,7 @@ void fastcall wake_up_new_task(struct ta
18279 p->prio = effective_prio(p);
18281 + vx_activate_task(p);
18282 if (likely(cpu == this_cpu)) {
18283 if (!(clone_flags & CLONE_VM)) {
18285 @@ -1783,6 +1828,7 @@ void fastcall wake_up_new_task(struct ta
18286 __activate_task(p, rq);
18288 p->prio = current->prio;
18289 + BUG_ON(p->state & TASK_ONHOLD);
18290 p->normal_prio = current->normal_prio;
18291 list_add_tail(&p->run_list, ¤t->run_list);
18292 p->array = current->array;
18293 @@ -3351,13 +3397,16 @@ static inline int expired_starving(struc
18294 void account_user_time(struct task_struct *p, cputime_t cputime)
18296 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
18297 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
18299 + int nice = (TASK_NICE(p) > 0);
18301 p->utime = cputime_add(p->utime, cputime);
18302 + vx_account_user(vxi, cputime, nice);
18304 /* Add user time to cpustat. */
18305 tmp = cputime_to_cputime64(cputime);
18306 - if (TASK_NICE(p) > 0)
18308 cpustat->nice = cputime64_add(cpustat->nice, tmp);
18310 cpustat->user = cputime64_add(cpustat->user, tmp);
18311 @@ -3373,10 +3422,12 @@ void account_system_time(struct task_str
18314 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
18315 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
18316 struct rq *rq = this_rq();
18319 p->stime = cputime_add(p->stime, cputime);
18320 + vx_account_system(vxi, cputime, (p == rq->idle));
18322 /* Add system time to cpustat. */
18323 tmp = cputime_to_cputime64(cputime);
18324 @@ -3415,7 +3466,7 @@ void account_steal_time(struct task_stru
18325 cpustat->steal = cputime64_add(cpustat->steal, tmp);
18328 -static void task_running_tick(struct rq *rq, struct task_struct *p)
18329 +static void task_running_tick(struct rq *rq, struct task_struct *p, int cpu)
18331 if (p->array != rq->active) {
18332 /* Task has expired but was not scheduled yet */
18333 @@ -3445,7 +3496,7 @@ static void task_running_tick(struct rq
18337 - if (!--p->time_slice) {
18338 + if (vx_need_resched(p, --p->time_slice, cpu)) {
18339 dequeue_task(p, rq->active);
18340 set_tsk_need_resched(p);
18341 p->prio = effective_prio(p);
18342 @@ -3506,9 +3557,12 @@ void scheduler_tick(void)
18343 struct rq *rq = cpu_rq(cpu);
18345 update_cpu_clock(p, rq, now);
18346 + vxm_sync(now, cpu);
18348 - if (!idle_at_tick)
18349 - task_running_tick(rq, p);
18350 + if (idle_at_tick)
18351 + vx_idle_resched(rq);
18353 + task_running_tick(rq, p, cpu);
18356 rq->idle_at_tick = idle_at_tick;
18357 @@ -3630,14 +3684,25 @@ need_resched_nonpreemptible:
18358 unlikely(signal_pending(prev))))
18359 prev->state = TASK_RUNNING;
18361 - if (prev->state == TASK_UNINTERRUPTIBLE)
18362 + if (prev->state == TASK_UNINTERRUPTIBLE) {
18363 rq->nr_uninterruptible++;
18364 + vx_uninterruptible_inc(prev);
18366 deactivate_task(prev, rq);
18370 cpu = smp_processor_id();
18371 + vx_set_rq_time(rq, jiffies);
18373 + vx_try_unhold(rq, cpu);
18376 if (unlikely(!rq->nr_running)) {
18377 + /* can we skip idle time? */
18378 + if (vx_try_skip(rq, cpu))
18381 idle_balance(cpu, rq);
18382 if (!rq->nr_running) {
18384 @@ -3663,6 +3728,10 @@ need_resched_nonpreemptible:
18385 queue = array->queue + idx;
18386 next = list_entry(queue->next, struct task_struct, run_list);
18388 + /* check before we schedule this context */
18389 + if (!vx_schedule(next, rq, cpu))
18392 if (!rt_task(next) && interactive_sleep(next->sleep_type)) {
18393 unsigned long long delta = now - next->timestamp;
18394 if (unlikely((long long)(now - next->timestamp) < 0))
18395 @@ -4263,7 +4332,7 @@ asmlinkage long sys_nice(int increment)
18398 if (increment < 0 && !can_nice(current, nice))
18400 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
18402 retval = security_task_setnice(current, nice);
18404 @@ -4435,6 +4504,7 @@ recheck:
18406 __setscheduler(p, policy, param->sched_priority);
18408 + vx_activate_task(p);
18409 __activate_task(p, rq);
18411 * Reschedule if we are currently running on this runqueue and
18412 @@ -5188,6 +5258,7 @@ static int __migrate_task(struct task_st
18413 p->timestamp = p->timestamp - rq_src->most_recent_timestamp
18414 + rq_dest->most_recent_timestamp;
18415 deactivate_task(p, rq_src);
18416 + vx_activate_task(p);
18417 __activate_task(p, rq_dest);
18418 if (TASK_PREEMPTS_CURR(p, rq_dest))
18419 resched_task(rq_dest->curr);
18420 @@ -7058,7 +7129,10 @@ void __init sched_init(void)
18421 INIT_LIST_HEAD(&rq->migration_queue);
18423 atomic_set(&rq->nr_iowait, 0);
18425 +#ifdef CONFIG_VSERVER_HARDCPU
18426 + INIT_LIST_HEAD(&rq->hold_queue);
18427 + rq->nr_onhold = 0;
18429 for (j = 0; j < 2; j++) {
18430 array = rq->arrays + j;
18431 for (k = 0; k < MAX_PRIO; k++) {
18432 @@ -7144,6 +7218,7 @@ void normalize_rt_tasks(void)
18433 deactivate_task(p, task_rq(p));
18434 __setscheduler(p, SCHED_NORMAL, 0);
18436 + vx_activate_task(p);
18437 __activate_task(p, task_rq(p));
18438 resched_task(rq->curr);
18440 diff -NurpP --minimal linux-2.6.22.10/kernel/sched_hard.h linux-2.6.22.10-vs2.3.0.29/kernel/sched_hard.h
18441 --- linux-2.6.22.10/kernel/sched_hard.h 1970-01-01 01:00:00 +0100
18442 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sched_hard.h 2007-08-05 20:53:13 +0200
18445 +#ifdef CONFIG_VSERVER_IDLELIMIT
18448 + * vx_idle_resched - reschedule after maxidle
18451 +void vx_idle_resched(struct rq *rq)
18453 + /* maybe have a better criterion for paused */
18454 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
18455 + set_need_resched();
18458 +#else /* !CONFIG_VSERVER_IDLELIMIT */
18460 +#define vx_idle_resched(rq)
18462 +#endif /* CONFIG_VSERVER_IDLELIMIT */
18466 +#ifdef CONFIG_VSERVER_IDLETIME
18468 +#define vx_set_rq_min_skip(rq, min) \
18469 + (rq)->idle_skip = (min)
18471 +#define vx_save_min_skip(ret, min, val) \
18472 + __vx_save_min_skip(ret, min, val)
18475 +void __vx_save_min_skip(int ret, int *min, int val)
18479 + if ((*min > val) || !*min)
18484 +int vx_try_skip(struct rq *rq, int cpu)
18486 + /* artificially advance time */
18487 + if (rq->idle_skip > 0) {
18488 + vxdprintk(list_empty(&rq->hold_queue),
18489 + "hold queue empty on cpu %d", cpu);
18490 + rq->idle_time += rq->idle_skip;
18491 + vxm_idle_skip(rq, cpu);
18497 +#else /* !CONFIG_VSERVER_IDLETIME */
18499 +#define vx_set_rq_min_skip(rq, min) \
18500 + ({ int dummy = (min); dummy; })
18502 +#define vx_save_min_skip(ret, min, val)
18505 +int vx_try_skip(struct rq *rq, int cpu)
18510 +#endif /* CONFIG_VSERVER_IDLETIME */
18514 +#ifdef CONFIG_VSERVER_HARDCPU
18516 +#define vx_set_rq_max_idle(rq, max) \
18517 + (rq)->idle_tokens = (max)
18519 +#define vx_save_max_idle(ret, min, val) \
18520 + __vx_save_max_idle(ret, min, val)
18523 +void __vx_save_max_idle(int ret, int *min, int val)
18531 + * vx_hold_task - put a task on the hold queue
18534 +void vx_hold_task(struct task_struct *p, struct rq *rq)
18536 + __deactivate_task(p, rq);
18537 + p->state |= TASK_ONHOLD;
18538 + /* a new one on hold */
18540 + vxm_hold_task(p, rq);
18541 + list_add_tail(&p->run_list, &rq->hold_queue);
18545 + * vx_unhold_task - put a task back to the runqueue
18548 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
18550 + list_del(&p->run_list);
18551 + /* one less waiting */
18553 + p->state &= ~TASK_ONHOLD;
18554 + enqueue_task(p, rq->expired);
18555 + inc_nr_running(p, rq);
18556 + vxm_unhold_task(p, rq);
18558 + if (p->static_prio < rq->best_expired_prio)
18559 + rq->best_expired_prio = p->static_prio;
18562 +unsigned long nr_onhold(void)
18564 + unsigned long i, sum = 0;
18566 + for_each_online_cpu(i)
18567 + sum += cpu_rq(i)->nr_onhold;
18575 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
18577 + return sched_pc->tokens;
18581 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
18583 + sched_pc->tokens--;
18587 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
18589 + struct vx_info *vxi = p->vx_info;
18591 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
18592 + struct _vx_sched_pc *sched_pc =
18593 + &vx_per_cpu(vxi, sched_pc, cpu);
18596 + /* maybe we can simplify that to decrement
18597 + the token counter unconditional? */
18599 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
18600 + __vx_consume_token(sched_pc);
18602 + /* for tokens > 0, one token was consumed */
18606 + vxm_need_resched(p, slice, cpu);
18607 + return (slice == 0);
18611 +#define vx_set_rq_time(rq, time) do { \
18612 + rq->norm_time = time; \
18617 +void vx_try_unhold(struct rq *rq, int cpu)
18619 + struct vx_info *vxi = NULL;
18620 + struct list_head *l, *n;
18621 + int maxidle = HZ;
18624 + /* nothing to do? what about pause? */
18625 + if (list_empty(&rq->hold_queue))
18628 + list_for_each_safe(l, n, &rq->hold_queue) {
18629 + int ret, delta_min[2];
18630 + struct _vx_sched_pc *sched_pc;
18631 + struct task_struct *p;
18633 + p = list_entry(l, struct task_struct, run_list);
18634 + /* don't bother with same context */
18635 + if (vxi == p->vx_info)
18638 + vxi = p->vx_info;
18639 + /* ignore paused contexts */
18640 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
18643 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18645 + /* recalc tokens */
18646 + vxm_sched_info(sched_pc, vxi, cpu);
18647 + ret = vx_tokens_recalc(sched_pc,
18648 + &rq->norm_time, &rq->idle_time, delta_min);
18649 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18652 + /* we found a runable context */
18653 + vx_unhold_task(p, rq);
18656 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
18657 + vx_save_min_skip(ret, &minskip, delta_min[1]);
18659 + vx_set_rq_max_idle(rq, maxidle);
18660 + vx_set_rq_min_skip(rq, minskip);
18661 + vxm_rq_max_min(rq, cpu);
18666 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
18668 + struct vx_info *vxi = next->vx_info;
18669 + struct _vx_sched_pc *sched_pc;
18670 + int delta_min[2];
18676 + flags = vxi->vx_flags;
18678 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
18679 + goto put_on_hold;
18680 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
18683 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18685 + /* update scheduler params */
18686 + if (cpu_isset(cpu, vxi->sched.update)) {
18687 + vx_update_sched_param(&vxi->sched, sched_pc);
18688 + vxm_update_sched(sched_pc, vxi, cpu);
18689 + cpu_clear(cpu, vxi->sched.update);
18692 + vxm_sched_info(sched_pc, vxi, cpu);
18693 + ret = vx_tokens_recalc(sched_pc,
18694 + &rq->norm_time, &rq->idle_time, delta_min);
18695 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18697 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
18700 + if (unlikely(ret < 0)) {
18701 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
18702 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
18703 + vxm_rq_max_min(rq, cpu);
18705 + vx_hold_task(next, rq);
18712 +#else /* CONFIG_VSERVER_HARDCPU */
18715 +void vx_hold_task(struct task_struct *p, struct rq *rq)
18721 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
18726 +unsigned long nr_onhold(void)
18733 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
18735 + return (slice == 0);
18739 +#define vx_set_rq_time(rq, time)
18742 +void vx_try_unhold(struct rq *rq, int cpu)
18748 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
18750 + struct vx_info *vxi = next->vx_info;
18751 + struct _vx_sched_pc *sched_pc;
18752 + int delta_min[2];
18755 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
18758 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18759 + vxm_sched_info(sched_pc, vxi, cpu);
18760 + ret = vx_tokens_recalc(sched_pc,
18761 + &rq->norm_time, &rq->idle_time, delta_min);
18762 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18766 +#endif /* CONFIG_VSERVER_HARDCPU */
18768 diff -NurpP --minimal linux-2.6.22.10/kernel/sched_mon.h linux-2.6.22.10-vs2.3.0.29/kernel/sched_mon.h
18769 --- linux-2.6.22.10/kernel/sched_mon.h 1970-01-01 01:00:00 +0100
18770 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sched_mon.h 2007-08-05 20:53:13 +0200
18773 +#include <linux/vserver/monitor.h>
18775 +#ifdef CONFIG_VSERVER_MONITOR
18777 +#ifdef CONFIG_VSERVER_HARDCPU
18778 +#define HARDCPU(x) (x)
18780 +#define HARDCPU(x) (0)
18783 +#ifdef CONFIG_VSERVER_IDLETIME
18784 +#define IDLETIME(x) (x)
18786 +#define IDLETIME(x) (0)
18789 +struct _vx_mon_entry *vxm_advance(int cpu);
18793 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
18795 + entry->type = type;
18796 + entry->xid = xid;
18800 +void __vxm_sync(int cpu)
18802 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18804 + __vxm_basic(entry, 0, VXM_SYNC);
18805 + entry->ev.sec = xtime.tv_sec;
18806 + entry->ev.nsec = xtime.tv_nsec;
18810 +void __vxm_task(struct task_struct *p, int type)
18812 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
18814 + __vxm_basic(entry, p->xid, type);
18815 + entry->ev.tsk.pid = p->pid;
18816 + entry->ev.tsk.state = p->state;
18820 +void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18822 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18824 + __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
18825 + entry->sd.tokens = s->tokens;
18826 + entry->sd.norm_time = s->norm_time;
18827 + entry->sd.idle_time = s->idle_time;
18831 +void __vxm_rqinfo1(struct rq *q, int cpu)
18833 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18835 + entry->type = VXM_RQINFO_1;
18836 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
18837 + entry->q1.running = q->nr_running;
18838 + entry->q1.onhold = HARDCPU(q->nr_onhold);
18839 + entry->q1.iowait = atomic_read(&q->nr_iowait);
18840 + entry->q1.uintr = q->nr_uninterruptible;
18841 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
18845 +void __vxm_rqinfo2(struct rq *q, int cpu)
18847 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18849 + entry->type = VXM_RQINFO_2;
18850 + entry->xid = (unsigned long)q & 0xffff;
18851 + entry->q2.norm_time = q->norm_time;
18852 + entry->q2.idle_time = q->idle_time;
18853 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
18857 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18859 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18861 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
18862 + entry->ev.tokens = s->tokens;
18866 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18868 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18870 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
18871 + entry->u1.tokens_max = s->tokens_max;
18872 + entry->u1.fill_rate = s->fill_rate[0];
18873 + entry->u1.interval = s->interval[0];
18877 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18879 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18881 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
18882 + entry->u2.tokens_min = s->tokens_min;
18883 + entry->u2.fill_rate = s->fill_rate[1];
18884 + entry->u2.interval = s->interval[1];
18888 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
18889 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
18890 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
18891 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
18892 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
18895 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
18897 + __vxm_task(p, VXM_MIGRATE);
18898 + __vxm_rqinfo1(rq, task_cpu(p));
18899 + __vxm_rqinfo2(rq, task_cpu(p));
18903 +void vxm_idle_skip(struct rq *rq, int cpu)
18905 + __vxm_rqinfo1(rq, cpu);
18906 + __vxm_rqinfo2(rq, cpu);
18910 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
18915 + __vxm_task(p, VXM_RESCHED);
18919 +void vxm_sync(unsigned long now, int cpu)
18921 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
18922 + (now % CONFIG_VSERVER_MONITOR_SYNC))
18928 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
18931 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
18932 + struct vx_info *vxi, int cpu)
18934 + __vxm_sched(s, vxi, cpu);
18935 + __vxm_rqinfo2(rq, cpu);
18939 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18941 + __vxm_sched(s, vxi, cpu);
18942 + __vxm_update(s, vxi, cpu);
18943 + __vxm_update1(s, vxi, cpu);
18944 + __vxm_update2(s, vxi, cpu);
18948 +void vxm_rq_max_min(struct rq *rq, int cpu)
18950 + __vxm_rqinfo1(rq, cpu);
18951 + __vxm_rqinfo2(rq, cpu);
18954 +#else /* CONFIG_VSERVER_MONITOR */
18956 +#define vxm_activate_task(t,q) do { } while (0)
18957 +#define vxm_activate_idle(t,q) do { } while (0)
18958 +#define vxm_deactivate_task(t,q) do { } while (0)
18959 +#define vxm_hold_task(t,q) do { } while (0)
18960 +#define vxm_unhold_task(t,q) do { } while (0)
18961 +#define vxm_migrate_task(t,q,d) do { } while (0)
18962 +#define vxm_idle_skip(q,c) do { } while (0)
18963 +#define vxm_need_resched(t,s,c) do { } while (0)
18964 +#define vxm_sync(s,c) do { } while (0)
18965 +#define vxm_sched_info(s,v,c) do { } while (0)
18966 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
18967 +#define vxm_update_sched(s,v,c) do { } while (0)
18968 +#define vxm_rq_max_min(q,c) do { } while (0)
18970 +#endif /* CONFIG_VSERVER_MONITOR */
18972 diff -NurpP --minimal linux-2.6.22.10/kernel/signal.c linux-2.6.22.10-vs2.3.0.29/kernel/signal.c
18973 --- linux-2.6.22.10/kernel/signal.c 2007-10-30 01:57:15 +0100
18974 +++ linux-2.6.22.10-vs2.3.0.29/kernel/signal.c 2007-09-30 14:58:01 +0200
18976 #include <linux/freezer.h>
18977 #include <linux/pid_namespace.h>
18978 #include <linux/nsproxy.h>
18979 +#include <linux/vs_context.h>
18980 +#include <linux/vs_pid.h>
18982 #include <asm/param.h>
18983 #include <asm/uaccess.h>
18984 @@ -523,19 +525,34 @@ static int check_kill_permission(int sig
18985 if (!valid_signal(sig))
18988 + if ((info != SEND_SIG_NOINFO) &&
18989 + (is_si_special(info) || !SI_FROMUSER(info)))
18992 + vxdprintk(VXD_CBIT(misc, 7),
18993 + "check_kill_permission(%d,%p,%p[#%u,%u])",
18994 + sig, info, t, vx_task_xid(t), t->pid);
18996 error = audit_signal_info(sig, t); /* Let audit system see the signal */
19001 - if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
19002 - && ((sig != SIGCONT) ||
19003 + if (((sig != SIGCONT) ||
19004 (process_session(current) != process_session(t)))
19005 && (current->euid ^ t->suid) && (current->euid ^ t->uid)
19006 && (current->uid ^ t->suid) && (current->uid ^ t->uid)
19007 && !capable(CAP_KILL))
19011 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
19012 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
19013 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
19014 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
19018 return security_task_kill(t, info, sig, 0);
19021 @@ -1043,7 +1060,7 @@ int kill_pid_info(int sig, struct siginf
19023 p = pid_task(pid, PIDTYPE_PID);
19026 + if (p && vx_check(vx_task_xid(p), VS_IDENT))
19027 error = group_send_sig_info(sig, info, p);
19029 if (unlikely(sig_needs_tasklist(sig)))
19030 @@ -1057,7 +1074,7 @@ kill_proc_info(int sig, struct siginfo *
19034 - error = kill_pid_info(sig, info, find_pid(pid));
19035 + error = kill_pid_info(sig, info, find_pid(vx_rmap_pid(pid)));
19039 @@ -1118,7 +1135,8 @@ static int kill_something_info(int sig,
19041 read_lock(&tasklist_lock);
19042 for_each_process(p) {
19043 - if (p->pid > 1 && p->tgid != current->tgid) {
19044 + if (vx_check(vx_task_xid(p), VS_ADMIN_P|VS_IDENT) &&
19045 + p->pid > 1 && p->tgid != current->tgid) {
19046 int err = group_send_sig_info(sig, info, p);
19049 @@ -1814,6 +1832,11 @@ relock:
19050 if (current == child_reaper(current))
19053 + /* virtual init is protected against user signals */
19054 + if ((info->si_code == SI_USER) &&
19055 + vx_current_initpid(current->pid))
19058 if (sig_kernel_stop(signr)) {
19060 * The default action is to stop all threads in
19061 diff -NurpP --minimal linux-2.6.22.10/kernel/softirq.c linux-2.6.22.10-vs2.3.0.29/kernel/softirq.c
19062 --- linux-2.6.22.10/kernel/softirq.c 2007-07-09 13:20:03 +0200
19063 +++ linux-2.6.22.10-vs2.3.0.29/kernel/softirq.c 2007-08-05 20:53:13 +0200
19065 #include <linux/rcupdate.h>
19066 #include <linux/smp.h>
19067 #include <linux/tick.h>
19068 +#include <linux/vs_context.h>
19070 #include <asm/irq.h>
19072 diff -NurpP --minimal linux-2.6.22.10/kernel/sys.c linux-2.6.22.10-vs2.3.0.29/kernel/sys.c
19073 --- linux-2.6.22.10/kernel/sys.c 2007-10-30 01:57:15 +0100
19074 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sys.c 2007-10-30 01:21:54 +0100
19076 #include <linux/compat.h>
19077 #include <linux/syscalls.h>
19078 #include <linux/kprobes.h>
19079 +#include <linux/vs_pid.h>
19081 #include <asm/uaccess.h>
19082 #include <asm/io.h>
19083 @@ -639,7 +640,10 @@ static int set_one_prio(struct task_stru
19086 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
19088 + if (vx_flags(VXF_IGNEG_NICE, 0))
19094 no_nice = security_task_setnice(p, niceval);
19095 @@ -687,6 +691,8 @@ asmlinkage long sys_setpriority(int whic
19097 pgrp = task_pgrp(current);
19098 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
19099 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
19101 error = set_one_prio(p, niceval, error);
19102 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
19104 @@ -695,7 +701,8 @@ asmlinkage long sys_setpriority(int whic
19106 who = current->uid;
19108 - if ((who != current->uid) && !(user = find_user(who)))
19109 + if ((who != current->uid) &&
19110 + !(user = find_user(vx_current_xid(), who)))
19111 goto out_unlock; /* No processes for this user */
19113 do_each_thread(g, p)
19114 @@ -747,6 +754,8 @@ asmlinkage long sys_getpriority(int whic
19116 pgrp = task_pgrp(current);
19117 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
19118 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
19120 niceval = 20 - task_nice(p);
19121 if (niceval > retval)
19123 @@ -757,7 +766,8 @@ asmlinkage long sys_getpriority(int whic
19125 who = current->uid;
19127 - if ((who != current->uid) && !(user = find_user(who)))
19128 + if ((who != current->uid) &&
19129 + !(user = find_user(vx_current_xid(), who)))
19130 goto out_unlock; /* No processes for this user */
19132 do_each_thread(g, p)
19133 @@ -871,6 +881,9 @@ void kernel_power_off(void)
19134 machine_power_off();
19136 EXPORT_SYMBOL_GPL(kernel_power_off);
19138 +long vs_reboot(unsigned int, void __user *);
19141 * Reboot system call: for obvious reasons only root may call it,
19142 * and even root needs to set up some magic numbers in the registers
19143 @@ -901,6 +914,9 @@ asmlinkage long sys_reboot(int magic1, i
19144 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
19145 cmd = LINUX_REBOOT_CMD_HALT;
19147 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
19148 + return vs_reboot(cmd, arg);
19152 case LINUX_REBOOT_CMD_RESTART:
19153 @@ -1080,7 +1096,7 @@ static int set_user(uid_t new_ruid, int
19155 struct user_struct *new_user;
19157 - new_user = alloc_uid(new_ruid);
19158 + new_user = alloc_uid(vx_current_xid(), new_ruid);
19162 @@ -1434,15 +1450,18 @@ asmlinkage long sys_setpgid(pid_t pid, p
19164 struct task_struct *p;
19165 struct task_struct *group_leader = current->group_leader;
19170 - pid = group_leader->pid;
19171 + pid = vx_map_pid(group_leader->pid);
19177 + rpgid = vx_rmap_pid(pgid);
19179 /* From this point forward we keep holding onto the tasklist lock
19180 * so that our parent does not change from under us. -DaveM
19182 @@ -1476,20 +1495,20 @@ asmlinkage long sys_setpgid(pid_t pid, p
19185 struct task_struct *g =
19186 - find_task_by_pid_type(PIDTYPE_PGID, pgid);
19187 + find_task_by_pid_type(PIDTYPE_PGID, rpgid);
19189 if (!g || task_session(g) != task_session(group_leader))
19193 - err = security_task_setpgid(p, pgid);
19194 + err = security_task_setpgid(p, rpgid);
19198 - if (process_group(p) != pgid) {
19199 + if (process_group(p) != rpgid) {
19200 detach_pid(p, PIDTYPE_PGID);
19201 - p->signal->pgrp = pgid;
19202 - attach_pid(p, PIDTYPE_PGID, find_pid(pgid));
19203 + p->signal->pgrp = rpgid;
19204 + attach_pid(p, PIDTYPE_PGID, find_pid(rpgid));
19208 @@ -1502,7 +1521,7 @@ out:
19209 asmlinkage long sys_getpgid(pid_t pid)
19212 - return process_group(current);
19213 + return vx_rmap_pid(process_group(current));
19216 struct task_struct *p;
19217 @@ -1514,7 +1533,7 @@ asmlinkage long sys_getpgid(pid_t pid)
19219 retval = security_task_getpgid(p);
19221 - retval = process_group(p);
19222 + retval = vx_rmap_pid(process_group(p));
19224 read_unlock(&tasklist_lock);
19226 @@ -1865,7 +1884,7 @@ asmlinkage long sys_sethostname(char __u
19228 char tmp[__NEW_UTS_LEN];
19230 - if (!capable(CAP_SYS_ADMIN))
19231 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
19233 if (len < 0 || len > __NEW_UTS_LEN)
19235 @@ -1910,7 +1929,7 @@ asmlinkage long sys_setdomainname(char _
19237 char tmp[__NEW_UTS_LEN];
19239 - if (!capable(CAP_SYS_ADMIN))
19240 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
19242 if (len < 0 || len > __NEW_UTS_LEN)
19244 @@ -1977,7 +1996,7 @@ asmlinkage long sys_setrlimit(unsigned i
19246 old_rlim = current->signal->rlim + resource;
19247 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
19248 - !capable(CAP_SYS_RESOURCE))
19249 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
19251 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
19253 diff -NurpP --minimal linux-2.6.22.10/kernel/sysctl.c linux-2.6.22.10-vs2.3.0.29/kernel/sysctl.c
19254 --- linux-2.6.22.10/kernel/sysctl.c 2007-07-09 13:20:03 +0200
19255 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sysctl.c 2007-08-05 20:53:13 +0200
19256 @@ -89,6 +89,7 @@ static int ngroups_max = NGROUPS_MAX;
19258 extern char modprobe_path[];
19260 +extern char vshelper_path[];
19261 #ifdef CONFIG_CHR_DEV_SG
19262 extern int sg_big_buff;
19264 @@ -343,6 +344,15 @@ static ctl_table kern_table[] = {
19265 .strategy = &sysctl_string,
19269 + .ctl_name = KERN_VSHELPER,
19270 + .procname = "vshelper",
19271 + .data = &vshelper_path,
19274 + .proc_handler = &proc_dostring,
19275 + .strategy = &sysctl_string,
19277 #ifdef CONFIG_CHR_DEV_SG
19279 .ctl_name = KERN_SG_BIG_BUFF,
19280 diff -NurpP --minimal linux-2.6.22.10/kernel/time.c linux-2.6.22.10-vs2.3.0.29/kernel/time.c
19281 --- linux-2.6.22.10/kernel/time.c 2007-07-09 13:20:03 +0200
19282 +++ linux-2.6.22.10-vs2.3.0.29/kernel/time.c 2007-08-05 20:53:13 +0200
19283 @@ -60,7 +60,7 @@ asmlinkage long sys_time(time_t __user *
19287 - do_gettimeofday(&tv);
19288 + vx_gettimeofday(&tv);
19292 @@ -91,7 +91,7 @@ asmlinkage long sys_stime(time_t __user
19296 - do_settimeofday(&tv);
19297 + vx_settimeofday(&tv);
19301 @@ -101,7 +101,7 @@ asmlinkage long sys_gettimeofday(struct
19303 if (likely(tv != NULL)) {
19304 struct timeval ktv;
19305 - do_gettimeofday(&ktv);
19306 + vx_gettimeofday(&ktv);
19307 if (copy_to_user(tv, &ktv, sizeof(ktv)))
19310 @@ -175,7 +175,7 @@ int do_sys_settimeofday(struct timespec
19311 /* SMP safe, again the code in arch/foo/time.c should
19312 * globally block out interrupts when it runs.
19314 - return do_settimeofday(tv);
19315 + return vx_settimeofday(tv);
19319 @@ -388,7 +388,7 @@ void getnstimeofday(struct timespec *tv)
19323 - do_gettimeofday(&x);
19324 + vx_gettimeofday(&x);
19325 tv->tv_sec = x.tv_sec;
19326 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
19328 diff -NurpP --minimal linux-2.6.22.10/kernel/timer.c linux-2.6.22.10-vs2.3.0.29/kernel/timer.c
19329 --- linux-2.6.22.10/kernel/timer.c 2007-07-09 13:20:04 +0200
19330 +++ linux-2.6.22.10-vs2.3.0.29/kernel/timer.c 2007-08-05 20:53:13 +0200
19332 #include <linux/delay.h>
19333 #include <linux/tick.h>
19334 #include <linux/kallsyms.h>
19335 +#include <linux/vs_base.h>
19336 +#include <linux/vs_cvirt.h>
19337 +#include <linux/vs_pid.h>
19338 +#include <linux/vserver/sched.h>
19340 #include <asm/uaccess.h>
19341 #include <asm/unistd.h>
19342 @@ -921,12 +925,6 @@ asmlinkage unsigned long sys_alarm(unsig
19349 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
19350 - * should be moved into arch/i386 instead?
19354 * sys_getpid - return the thread group id of the current process
19355 @@ -939,7 +937,7 @@ asmlinkage unsigned long sys_alarm(unsig
19357 asmlinkage long sys_getpid(void)
19359 - return current->tgid;
19360 + return vx_map_tgid(current->tgid);
19364 @@ -955,10 +953,23 @@ asmlinkage long sys_getppid(void)
19366 pid = rcu_dereference(current->real_parent)->tgid;
19368 + return vx_map_pid(pid);
19375 + * The Alpha uses getxpid, getxuid, and getxgid instead.
19378 +asmlinkage long do_getxpid(long *ppid)
19380 + *ppid = sys_getppid();
19381 + return sys_getpid();
19384 +#else /* _alpha_ */
19386 asmlinkage long sys_getuid(void)
19388 /* Only we change this so SMP safe */
19389 @@ -1118,6 +1129,8 @@ int do_sysinfo(struct sysinfo *info)
19390 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
19393 + if (vx_flags(VXF_VIRT_UPTIME, 0))
19394 + vx_vsi_uptime(&tp, NULL);
19395 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
19397 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
19398 diff -NurpP --minimal linux-2.6.22.10/kernel/user.c linux-2.6.22.10-vs2.3.0.29/kernel/user.c
19399 --- linux-2.6.22.10/kernel/user.c 2007-02-06 03:01:56 +0100
19400 +++ linux-2.6.22.10-vs2.3.0.29/kernel/user.c 2007-08-05 20:53:13 +0200
19402 #define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 8)
19403 #define UIDHASH_SZ (1 << UIDHASH_BITS)
19404 #define UIDHASH_MASK (UIDHASH_SZ - 1)
19405 -#define __uidhashfn(uid) (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
19406 -#define uidhashentry(uid) (uidhash_table + __uidhashfn((uid)))
19407 +#define __uidhashfn(xid,uid) ((((uid) >> UIDHASH_BITS) + ((uid)^(xid))) & UIDHASH_MASK)
19408 +#define uidhashentry(xid,uid) (uidhash_table + __uidhashfn((xid),(uid)))
19410 static struct kmem_cache *uid_cachep;
19411 static struct list_head uidhash_table[UIDHASH_SZ];
19412 @@ -66,7 +66,7 @@ static inline void uid_hash_remove(struc
19413 list_del(&up->uidhash_list);
19416 -static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *hashent)
19417 +static inline struct user_struct *uid_hash_find(xid_t xid, uid_t uid, struct list_head *hashent)
19419 struct list_head *up;
19421 @@ -75,7 +75,7 @@ static inline struct user_struct *uid_ha
19423 user = list_entry(up, struct user_struct, uidhash_list);
19425 - if(user->uid == uid) {
19426 + if(user->uid == uid && user->xid == xid) {
19427 atomic_inc(&user->__count);
19430 @@ -90,13 +90,13 @@ static inline struct user_struct *uid_ha
19432 * If the user_struct could not be found, return NULL.
19434 -struct user_struct *find_user(uid_t uid)
19435 +struct user_struct *find_user(xid_t xid, uid_t uid)
19437 struct user_struct *ret;
19438 unsigned long flags;
19440 spin_lock_irqsave(&uidhash_lock, flags);
19441 - ret = uid_hash_find(uid, uidhashentry(uid));
19442 + ret = uid_hash_find(xid, uid, uidhashentry(xid, uid));
19443 spin_unlock_irqrestore(&uidhash_lock, flags);
19446 @@ -120,13 +120,13 @@ void free_uid(struct user_struct *up)
19450 -struct user_struct * alloc_uid(uid_t uid)
19451 +struct user_struct * alloc_uid(xid_t xid, uid_t uid)
19453 - struct list_head *hashent = uidhashentry(uid);
19454 + struct list_head *hashent = uidhashentry(xid, uid);
19455 struct user_struct *up;
19457 spin_lock_irq(&uidhash_lock);
19458 - up = uid_hash_find(uid, hashent);
19459 + up = uid_hash_find(xid, uid, hashent);
19460 spin_unlock_irq(&uidhash_lock);
19463 @@ -136,6 +136,7 @@ struct user_struct * alloc_uid(uid_t uid
19468 atomic_set(&new->__count, 1);
19469 atomic_set(&new->processes, 0);
19470 atomic_set(&new->files, 0);
19471 @@ -158,7 +159,7 @@ struct user_struct * alloc_uid(uid_t uid
19472 * on adding the same user already..
19474 spin_lock_irq(&uidhash_lock);
19475 - up = uid_hash_find(uid, hashent);
19476 + up = uid_hash_find(xid, uid, hashent);
19478 key_put(new->uid_keyring);
19479 key_put(new->session_keyring);
19480 @@ -215,7 +216,7 @@ static int __init uid_cache_init(void)
19482 /* Insert the root user immediately (init already runs as root) */
19483 spin_lock_irq(&uidhash_lock);
19484 - uid_hash_insert(&root_user, uidhashentry(0));
19485 + uid_hash_insert(&root_user, uidhashentry(0,0));
19486 spin_unlock_irq(&uidhash_lock);
19489 diff -NurpP --minimal linux-2.6.22.10/kernel/utsname.c linux-2.6.22.10-vs2.3.0.29/kernel/utsname.c
19490 --- linux-2.6.22.10/kernel/utsname.c 2007-07-09 13:20:04 +0200
19491 +++ linux-2.6.22.10-vs2.3.0.29/kernel/utsname.c 2007-08-05 20:53:13 +0200
19493 #include <linux/uts.h>
19494 #include <linux/utsname.h>
19495 #include <linux/version.h>
19496 +#include <linux/vserver/global.h>
19499 * Clone a new ns copying an original utsname, setting refcount to 1
19500 @@ -27,6 +28,7 @@ static struct uts_namespace *clone_uts_n
19502 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
19503 kref_init(&ns->kref);
19504 + atomic_inc(&vs_global_uts_ns);
19508 @@ -58,5 +60,6 @@ void free_uts_ns(struct kref *kref)
19509 struct uts_namespace *ns;
19511 ns = container_of(kref, struct uts_namespace, kref);
19512 + atomic_dec(&vs_global_uts_ns);
19515 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/Kconfig linux-2.6.22.10-vs2.3.0.29/kernel/vserver/Kconfig
19516 --- linux-2.6.22.10/kernel/vserver/Kconfig 1970-01-01 01:00:00 +0100
19517 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/Kconfig 2007-10-11 01:10:22 +0200
19520 +# Linux VServer configuration
19523 +menu "Linux VServer"
19525 +config VSERVER_AUTO_LBACK
19526 + bool "Automatically Assign Loopback IP"
19529 + Automatically assign a guest specific loopback
19530 + IP and add it to the kernel network stack on
19533 +config VSERVER_AUTO_SINGLE
19534 + bool "Automatic Single IP Special Casing"
19535 + depends on EXPERIMENTAL
19538 + This allows network contexts with a single IP to
19539 + automatically remap 0.0.0.0 bindings to that IP,
19540 + avoiding further network checks and improving
19543 + (note: such guests do not allow to change the ip
19544 + on the fly and do not show loopback addresses)
19546 +config VSERVER_COWBL
19547 + bool "Enable COW Immutable Link Breaking"
19550 + This enables the COW (Copy-On-Write) link break code.
19551 + It allows you to treat unified files like normal files
19552 + when writing to them (which will implicitely break the
19553 + link and create a copy of the unified file)
19555 +config VSERVER_VTIME
19556 + bool "Enable Virtualized Guest Time"
19557 + depends on EXPERIMENTAL
19560 + This enables per guest time offsets to allow for
19561 + adjusting the system clock individually per guest.
19562 + this adds some overhead to the time functions and
19563 + therefore should not be enabled without good reason.
19565 +config VSERVER_DEVICE
19566 + bool "Enable Guest Device Mapping"
19567 + depends on EXPERIMENTAL
19570 + This enables generic device remapping.
19572 +config VSERVER_PROC_SECURE
19573 + bool "Enable Proc Security"
19574 + depends on PROC_FS
19577 + This configures ProcFS security to initially hide
19578 + non-process entries for all contexts except the main and
19579 + spectator context (i.e. for all guests), which is a secure
19582 + (note: on 1.2x the entries were visible by default)
19584 +config VSERVER_HARDCPU
19585 + bool "Enable Hard CPU Limits"
19588 + Activate the Hard CPU Limits
19590 + This will compile in code that allows the Token Bucket
19591 + Scheduler to put processes on hold when a context's
19592 + tokens are depleted (provided that its per-context
19593 + sched_hard flag is set).
19595 + Processes belonging to that context will not be able
19596 + to consume CPU resources again until a per-context
19597 + configured minimum of tokens has been reached.
19599 +config VSERVER_IDLETIME
19600 + bool "Avoid idle CPUs by skipping Time"
19601 + depends on VSERVER_HARDCPU
19604 + This option allows the scheduler to artificially
19605 + advance time (per cpu) when otherwise the idle
19606 + task would be scheduled, thus keeping the cpu
19607 + busy and sharing the available resources among
19608 + certain contexts.
19610 +config VSERVER_IDLELIMIT
19611 + bool "Limit the IDLE task"
19612 + depends on VSERVER_HARDCPU
19615 + Limit the idle slices, so the the next context
19616 + will be scheduled as soon as possible.
19618 + This might improve interactivity and latency, but
19619 + will also marginally increase scheduling overhead.
19622 + prompt "Persistent Inode Tagging"
19623 + default TAGGING_ID24
19625 + This adds persistent context information to filesystems
19626 + mounted with the tagxid option. Tagging is a requirement
19627 + for per-context disk limits and per-context quota.
19630 +config TAGGING_NONE
19633 + do not store per-context information in inodes.
19635 +config TAGGING_UID16
19636 + bool "UID16/GID32"
19638 + reduces UID to 16 bit, but leaves GID at 32 bit.
19640 +config TAGGING_GID16
19641 + bool "UID32/GID16"
19643 + reduces GID to 16 bit, but leaves UID at 32 bit.
19645 +config TAGGING_ID24
19646 + bool "UID24/GID24"
19648 + uses the upper 8bit from UID and GID for XID tagging
19649 + which leaves 24bit for UID/GID each, which should be
19650 + more than sufficient for normal use.
19652 +config TAGGING_INTERN
19653 + bool "UID32/GID32"
19655 + this uses otherwise reserved inode fields in the on
19656 + disk representation, which limits the use to a few
19657 + filesystems (currently ext2 and ext3)
19662 + bool "Tag NFSD User Auth and Files"
19665 + Enable this if you do want the in-kernel NFS
19666 + Server to use the tagging specified above.
19667 + (will require patched clients too)
19669 +config VSERVER_PRIVACY
19670 + bool "Honor Privacy Aspects of Guests"
19673 + When enabled, most context checks will disallow
19674 + access to structures assigned to a specific context,
19675 + like ptys or loop devices.
19677 +config VSERVER_CONTEXTS
19678 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
19680 + default "768" if 64BIT
19683 + This setting will optimize certain data structures
19684 + and memory allocations according to the expected
19687 + note: this is not a strict upper limit.
19689 +config VSERVER_WARN
19690 + bool "VServer Warnings"
19693 + This enables various runtime warnings, which will
19694 + notify about potential manipulation attempts or
19695 + resource shortage. It is generally considered to
19696 + be a good idea to have that enabled.
19698 +config VSERVER_DEBUG
19699 + bool "VServer Debugging Code"
19702 + Set this to yes if you want to be able to activate
19703 + debugging output at runtime. It adds a very small
19704 + overhead to all vserver related functions and
19705 + increases the kernel size by about 20k.
19707 +config VSERVER_HISTORY
19708 + bool "VServer History Tracing"
19709 + depends on VSERVER_DEBUG
19712 + Set this to yes if you want to record the history of
19713 + linux-vserver activities, so they can be replayed in
19714 + the event of a kernel panic or oops.
19716 +config VSERVER_HISTORY_SIZE
19717 + int "Per-CPU History Size (32-65536)"
19718 + depends on VSERVER_HISTORY
19722 + This allows you to specify the number of entries in
19723 + the per-CPU history buffer.
19725 +config VSERVER_MONITOR
19726 + bool "VServer Scheduling Monitor"
19727 + depends on VSERVER_DEBUG
19730 + Set this to yes if you want to record the scheduling
19731 + decisions, so that they can be relayed to userspace
19732 + for detailed analysis.
19734 +config VSERVER_MONITOR_SIZE
19735 + int "Per-CPU Monitor Queue Size (32-65536)"
19736 + depends on VSERVER_MONITOR
19740 + This allows you to specify the number of entries in
19741 + the per-CPU scheduling monitor buffer.
19743 +config VSERVER_MONITOR_SYNC
19744 + int "Per-CPU Monitor Sync Interval (0-65536)"
19745 + depends on VSERVER_MONITOR
19749 + This allows you to specify the interval in ticks
19750 + when a time sync entry is inserted.
19762 +config VSERVER_SECURITY
19764 + depends on SECURITY
19766 + select SECURITY_CAPABILITIES
19768 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/Makefile linux-2.6.22.10-vs2.3.0.29/kernel/vserver/Makefile
19769 --- linux-2.6.22.10/kernel/vserver/Makefile 1970-01-01 01:00:00 +0100
19770 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/Makefile 2007-10-11 01:10:22 +0200
19773 +# Makefile for the Linux vserver routines.
19777 +obj-y += vserver.o
19779 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
19780 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
19783 +vserver-$(CONFIG_INET) += inet.o
19784 +vserver-$(CONFIG_PROC_FS) += proc.o
19785 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
19786 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
19787 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
19788 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
19790 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cacct.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct.c
19791 --- linux-2.6.22.10/kernel/vserver/cacct.c 1970-01-01 01:00:00 +0100
19792 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct.c 2007-08-15 21:54:31 +0200
19795 + * linux/kernel/vserver/cacct.c
19797 + * Virtual Server: Context Accounting
19799 + * Copyright (C) 2006-2007 Herbert Pötzl
19801 + * V0.01 added accounting stats
19805 +#include <linux/types.h>
19806 +#include <linux/vs_context.h>
19807 +#include <linux/vserver/cacct_cmd.h>
19808 +#include <linux/vserver/cacct_int.h>
19810 +#include <asm/errno.h>
19811 +#include <asm/uaccess.h>
19814 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
19816 + struct vcmd_sock_stat_v0 vc_data;
19819 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19822 + field = vc_data.field;
19823 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
19826 + for (j = 0; j < 3; j++) {
19827 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
19828 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
19831 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19836 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cacct_init.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct_init.h
19837 --- linux-2.6.22.10/kernel/vserver/cacct_init.h 1970-01-01 01:00:00 +0100
19838 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct_init.h 2007-08-05 20:53:13 +0200
19842 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
19847 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
19848 + for (j = 0; j < 3; j++) {
19849 + atomic_set(&cacct->sock[i][j].count, 0);
19850 + atomic_set(&cacct->sock[i][j].total, 0);
19853 + for (i = 0; i < 8; i++)
19854 + atomic_set(&cacct->slab[i], 0);
19855 + for (i = 0; i < 5; i++)
19856 + for (j = 0; j < 4; j++)
19857 + atomic_set(&cacct->page[i][j], 0);
19860 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
19865 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cacct_proc.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct_proc.h
19866 --- linux-2.6.22.10/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00 +0100
19867 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct_proc.h 2007-08-05 20:53:13 +0200
19869 +#ifndef _VX_CACCT_PROC_H
19870 +#define _VX_CACCT_PROC_H
19872 +#include <linux/vserver/cacct_int.h>
19875 +#define VX_SOCKA_TOP \
19876 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
19878 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
19880 + int i, j, length = 0;
19881 + static char *type[VXA_SOCK_SIZE] = {
19882 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
19885 + length += sprintf(buffer + length, VX_SOCKA_TOP);
19886 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
19887 + length += sprintf(buffer + length, "%s:", type[i]);
19888 + for (j = 0; j < 3; j++) {
19889 + length += sprintf(buffer + length,
19890 + "\t%10lu/%-10lu",
19891 + vx_sock_count(cacct, i, j),
19892 + vx_sock_total(cacct, i, j));
19894 + buffer[length++] = '\n';
19897 + length += sprintf(buffer + length, "\n");
19898 + length += sprintf(buffer + length,
19899 + "slab:\t %8u %8u %8u %8u\n",
19900 + atomic_read(&cacct->slab[1]),
19901 + atomic_read(&cacct->slab[4]),
19902 + atomic_read(&cacct->slab[0]),
19903 + atomic_read(&cacct->slab[2]));
19905 + length += sprintf(buffer + length, "\n");
19906 + for (i = 0; i < 5; i++) {
19907 + length += sprintf(buffer + length,
19908 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
19909 + atomic_read(&cacct->page[i][0]),
19910 + atomic_read(&cacct->page[i][1]),
19911 + atomic_read(&cacct->page[i][2]),
19912 + atomic_read(&cacct->page[i][3]),
19913 + atomic_read(&cacct->page[i][4]),
19914 + atomic_read(&cacct->page[i][5]),
19915 + atomic_read(&cacct->page[i][6]),
19916 + atomic_read(&cacct->page[i][7]));
19921 +#endif /* _VX_CACCT_PROC_H */
19922 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/context.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/context.c
19923 --- linux-2.6.22.10/kernel/vserver/context.c 1970-01-01 01:00:00 +0100
19924 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/context.c 2007-10-05 14:54:36 +0200
19927 + * linux/kernel/vserver/context.c
19929 + * Virtual Server: Context Support
19931 + * Copyright (C) 2003-2007 Herbert Pötzl
19933 + * V0.01 context helper
19934 + * V0.02 vx_ctx_kill syscall command
19935 + * V0.03 replaced context_info calls
19936 + * V0.04 redesign of struct (de)alloc
19937 + * V0.05 rlimit basic implementation
19938 + * V0.06 task_xid and info commands
19939 + * V0.07 context flags and caps
19940 + * V0.08 switch to RCU based hash
19941 + * V0.09 revert to non RCU for now
19942 + * V0.10 and back to working RCU hash
19943 + * V0.11 and back to locking again
19944 + * V0.12 referenced context store
19945 + * V0.13 separate per cpu data
19946 + * V0.14 changed vcmds to vxi arg
19947 + * V0.15 added context stat
19948 + * V0.16 have __create claim() the vxi
19949 + * V0.17 removed older and legacy stuff
19953 +#include <linux/slab.h>
19954 +#include <linux/types.h>
19955 +#include <linux/pid_namespace.h>
19957 +#include <linux/vserver/context.h>
19958 +#include <linux/vserver/network.h>
19959 +#include <linux/vserver/debug.h>
19960 +#include <linux/vserver/limit.h>
19961 +#include <linux/vserver/limit_int.h>
19962 +#include <linux/vserver/space.h>
19964 +#include <linux/vs_context.h>
19965 +#include <linux/vs_limit.h>
19966 +#include <linux/vserver/context_cmd.h>
19968 +#include "cvirt_init.h"
19969 +#include "cacct_init.h"
19970 +#include "limit_init.h"
19971 +#include "sched_init.h"
19974 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
19975 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
19978 +/* now inactive context structures */
19980 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
19982 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
19985 +/* __alloc_vx_info()
19987 + * allocate an initialized vx_info struct
19988 + * doesn't make it visible (hash) */
19990 +static struct vx_info *__alloc_vx_info(xid_t xid)
19992 + struct vx_info *new = NULL;
19995 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
19997 + /* would this benefit from a slab cache? */
19998 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
20002 + memset(new, 0, sizeof(struct vx_info));
20004 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
20005 + if (!new->ptr_pc)
20008 + new->vx_id = xid;
20009 + INIT_HLIST_NODE(&new->vx_hlist);
20010 + atomic_set(&new->vx_usecnt, 0);
20011 + atomic_set(&new->vx_tasks, 0);
20012 + new->vx_parent = NULL;
20013 + new->vx_state = 0;
20014 + init_waitqueue_head(&new->vx_wait);
20016 + /* prepare reaper */
20017 + get_task_struct(init_pid_ns.child_reaper);
20018 + new->vx_reaper = init_pid_ns.child_reaper;
20019 + new->vx_badness_bias = 0;
20021 + /* rest of init goes here */
20022 + vx_info_init_limit(&new->limit);
20023 + vx_info_init_sched(&new->sched);
20024 + vx_info_init_cvirt(&new->cvirt);
20025 + vx_info_init_cacct(&new->cacct);
20027 + /* per cpu data structures */
20028 + for_each_possible_cpu(cpu) {
20029 + vx_info_init_sched_pc(
20030 + &vx_per_cpu(new, sched_pc, cpu), cpu);
20031 + vx_info_init_cvirt_pc(
20032 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
20035 + new->vx_flags = VXF_INIT_SET;
20036 + new->vx_bcaps = CAP_INIT_EFF_SET;
20037 + new->vx_ccaps = 0;
20038 + new->vx_cap_bset = cap_bset;
20040 + new->reboot_cmd = 0;
20041 + new->exit_code = 0;
20043 + new->vx_nsproxy = copy_nsproxy(current->nsproxy);
20045 + vxdprintk(VXD_CBIT(xid, 0),
20046 + "alloc_vx_info(%d) = %p", xid, new);
20047 + vxh_alloc_vx_info(new);
20048 + atomic_inc(&vx_global_ctotal);
20057 +/* __dealloc_vx_info()
20059 + * final disposal of vx_info */
20061 +static void __dealloc_vx_info(struct vx_info *vxi)
20065 + vxdprintk(VXD_CBIT(xid, 0),
20066 + "dealloc_vx_info(%p)", vxi);
20067 + vxh_dealloc_vx_info(vxi);
20071 + vx_info_exit_limit(&vxi->limit);
20072 + vx_info_exit_sched(&vxi->sched);
20073 + vx_info_exit_cvirt(&vxi->cvirt);
20074 + vx_info_exit_cacct(&vxi->cacct);
20076 + for_each_possible_cpu(cpu) {
20077 + vx_info_exit_sched_pc(
20078 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
20079 + vx_info_exit_cvirt_pc(
20080 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
20083 + vxi->vx_state |= VXS_RELEASED;
20086 + free_percpu(vxi->ptr_pc);
20089 + atomic_dec(&vx_global_ctotal);
20092 +static void __shutdown_vx_info(struct vx_info *vxi)
20094 + struct nsproxy *nsproxy;
20095 + struct fs_struct *fs;
20099 + vxi->vx_state |= VXS_SHUTDOWN;
20100 + vs_state_change(vxi, VSC_SHUTDOWN);
20102 + nsproxy = xchg(&vxi->vx_nsproxy, NULL);
20103 + fs = xchg(&vxi->vx_fs, NULL);
20106 + put_nsproxy(nsproxy);
20108 + put_fs_struct(fs);
20111 +/* exported stuff */
20113 +void free_vx_info(struct vx_info *vxi)
20115 + unsigned long flags;
20117 + /* check for reference counts first */
20118 + BUG_ON(atomic_read(&vxi->vx_usecnt));
20119 + BUG_ON(atomic_read(&vxi->vx_tasks));
20121 + /* context must not be hashed */
20122 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
20124 + /* context shutdown is mandatory */
20125 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
20127 + BUG_ON(vxi->vx_nsproxy);
20128 + BUG_ON(vxi->vx_fs);
20130 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
20131 + hlist_del(&vxi->vx_hlist);
20132 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
20134 + __dealloc_vx_info(vxi);
20138 +/* hash table for vx_info hash */
20140 +#define VX_HASH_SIZE 13
20142 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
20143 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
20145 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
20148 +static inline unsigned int __hashval(xid_t xid)
20150 + return (xid % VX_HASH_SIZE);
20155 +/* __hash_vx_info()
20157 + * add the vxi to the global hash table
20158 + * requires the hash_lock to be held */
20160 +static inline void __hash_vx_info(struct vx_info *vxi)
20162 + struct hlist_head *head;
20164 + vxd_assert_lock(&vx_info_hash_lock);
20165 + vxdprintk(VXD_CBIT(xid, 4),
20166 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
20167 + vxh_hash_vx_info(vxi);
20169 + /* context must not be hashed */
20170 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
20172 + vxi->vx_state |= VXS_HASHED;
20173 + head = &vx_info_hash[__hashval(vxi->vx_id)];
20174 + hlist_add_head(&vxi->vx_hlist, head);
20175 + atomic_inc(&vx_global_cactive);
20178 +/* __unhash_vx_info()
20180 + * remove the vxi from the global hash table
20181 + * requires the hash_lock to be held */
20183 +static inline void __unhash_vx_info(struct vx_info *vxi)
20185 + unsigned long flags;
20187 + vxd_assert_lock(&vx_info_hash_lock);
20188 + vxdprintk(VXD_CBIT(xid, 4),
20189 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
20190 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
20191 + vxh_unhash_vx_info(vxi);
20193 + /* context must be hashed */
20194 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
20195 + /* but without tasks */
20196 + BUG_ON(atomic_read(&vxi->vx_tasks));
20198 + vxi->vx_state &= ~VXS_HASHED;
20199 + hlist_del_init(&vxi->vx_hlist);
20200 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
20201 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
20202 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
20203 + atomic_dec(&vx_global_cactive);
20207 +/* __lookup_vx_info()
20209 + * requires the hash_lock to be held
20210 + * doesn't increment the vx_refcnt */
20212 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
20214 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
20215 + struct hlist_node *pos;
20216 + struct vx_info *vxi;
20218 + vxd_assert_lock(&vx_info_hash_lock);
20219 + hlist_for_each(pos, head) {
20220 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
20222 + if (vxi->vx_id == xid)
20227 + vxdprintk(VXD_CBIT(xid, 0),
20228 + "__lookup_vx_info(#%u): %p[#%u]",
20229 + xid, vxi, vxi ? vxi->vx_id : 0);
20230 + vxh_lookup_vx_info(vxi, xid);
20235 +/* __create_vx_info()
20237 + * create the requested context
20238 + * get(), claim() and hash it */
20240 +static struct vx_info *__create_vx_info(int id)
20242 + struct vx_info *new, *vxi = NULL;
20244 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
20246 + if (!(new = __alloc_vx_info(id)))
20247 + return ERR_PTR(-ENOMEM);
20249 + /* required to make dynamic xids unique */
20250 + spin_lock(&vx_info_hash_lock);
20252 + /* static context requested */
20253 + if ((vxi = __lookup_vx_info(id))) {
20254 + vxdprintk(VXD_CBIT(xid, 0),
20255 + "create_vx_info(%d) = %p (already there)", id, vxi);
20256 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
20257 + vxi = ERR_PTR(-EBUSY);
20259 + vxi = ERR_PTR(-EEXIST);
20262 + /* new context */
20263 + vxdprintk(VXD_CBIT(xid, 0),
20264 + "create_vx_info(%d) = %p (new)", id, new);
20265 + claim_vx_info(new, NULL);
20266 + __hash_vx_info(get_vx_info(new));
20267 + vxi = new, new = NULL;
20270 + spin_unlock(&vx_info_hash_lock);
20271 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
20273 + __dealloc_vx_info(new);
20278 +/* exported stuff */
20281 +void unhash_vx_info(struct vx_info *vxi)
20283 + __shutdown_vx_info(vxi);
20284 + spin_lock(&vx_info_hash_lock);
20285 + __unhash_vx_info(vxi);
20286 + spin_unlock(&vx_info_hash_lock);
20287 + __wakeup_vx_info(vxi);
20291 +/* lookup_vx_info()
20293 + * search for a vx_info and get() it
20294 + * negative id means current */
20296 +struct vx_info *lookup_vx_info(int id)
20298 + struct vx_info *vxi = NULL;
20301 + vxi = get_vx_info(current->vx_info);
20302 + } else if (id > 1) {
20303 + spin_lock(&vx_info_hash_lock);
20304 + vxi = get_vx_info(__lookup_vx_info(id));
20305 + spin_unlock(&vx_info_hash_lock);
20310 +/* xid_is_hashed()
20312 + * verify that xid is still hashed */
20314 +int xid_is_hashed(xid_t xid)
20318 + spin_lock(&vx_info_hash_lock);
20319 + hashed = (__lookup_vx_info(xid) != NULL);
20320 + spin_unlock(&vx_info_hash_lock);
20324 +#ifdef CONFIG_PROC_FS
20328 + * get a subset of hashed xids for proc
20329 + * assumes size is at least one */
20331 +int get_xid_list(int index, unsigned int *xids, int size)
20333 + int hindex, nr_xids = 0;
20335 + /* only show current and children */
20336 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
20339 + xids[nr_xids] = vx_current_xid();
20343 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
20344 + struct hlist_head *head = &vx_info_hash[hindex];
20345 + struct hlist_node *pos;
20347 + spin_lock(&vx_info_hash_lock);
20348 + hlist_for_each(pos, head) {
20349 + struct vx_info *vxi;
20354 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
20355 + xids[nr_xids] = vxi->vx_id;
20356 + if (++nr_xids >= size) {
20357 + spin_unlock(&vx_info_hash_lock);
20361 + /* keep the lock time short */
20362 + spin_unlock(&vx_info_hash_lock);
20369 +#ifdef CONFIG_VSERVER_DEBUG
20371 +void dump_vx_info_inactive(int level)
20373 + struct hlist_node *entry, *next;
20375 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
20376 + struct vx_info *vxi =
20377 + list_entry(entry, struct vx_info, vx_hlist);
20379 + dump_vx_info(vxi, level);
20385 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
20387 + struct user_struct *new_user, *old_user;
20392 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
20395 + new_user = alloc_uid(vxi->vx_id, p->uid);
20399 + old_user = p->user;
20400 + if (new_user != old_user) {
20401 + atomic_inc(&new_user->processes);
20402 + atomic_dec(&old_user->processes);
20403 + p->user = new_user;
20405 + free_uid(old_user);
20409 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
20411 + p->cap_effective &= vxi->vx_cap_bset;
20412 + p->cap_inheritable &= vxi->vx_cap_bset;
20413 + p->cap_permitted &= vxi->vx_cap_bset;
20417 +#include <linux/file.h>
20419 +static int vx_openfd_task(struct task_struct *tsk)
20421 + struct files_struct *files = tsk->files;
20422 + struct fdtable *fdt;
20423 + const unsigned long *bptr;
20424 + int count, total;
20426 + /* no rcu_read_lock() because of spin_lock() */
20427 + spin_lock(&files->file_lock);
20428 + fdt = files_fdtable(files);
20429 + bptr = fdt->open_fds->fds_bits;
20430 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
20431 + for (total = 0; count > 0; count--) {
20433 + total += hweight_long(*bptr);
20436 + spin_unlock(&files->file_lock);
20441 +/* for *space compatibility */
20443 +asmlinkage long sys_unshare(unsigned long);
20446 + * migrate task to new context
20447 + * gets vxi, puts old_vxi on change
20448 + * optionally unshares namespaces (hack)
20451 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
20453 + struct vx_info *old_vxi;
20459 + vxdprintk(VXD_CBIT(xid, 5),
20460 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
20461 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
20463 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
20464 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
20467 + if (vx_info_state(vxi, VXS_SHUTDOWN))
20470 + old_vxi = task_get_vx_info(p);
20471 + if (old_vxi == vxi)
20474 + if (!(ret = vx_migrate_user(p, vxi))) {
20478 + openfd = vx_openfd_task(p);
20481 + atomic_dec(&old_vxi->cvirt.nr_threads);
20482 + atomic_dec(&old_vxi->cvirt.nr_running);
20483 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
20484 + /* FIXME: what about the struct files here? */
20485 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
20486 + /* account for the executable */
20487 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
20489 + atomic_inc(&vxi->cvirt.nr_threads);
20490 + atomic_inc(&vxi->cvirt.nr_running);
20491 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
20492 + /* FIXME: what about the struct files here? */
20493 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
20494 + /* account for the executable */
20495 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
20498 + release_vx_info(old_vxi, p);
20499 + clr_vx_info(&p->vx_info);
20501 + claim_vx_info(vxi, p);
20502 + set_vx_info(&p->vx_info, vxi);
20503 + p->xid = vxi->vx_id;
20505 + vxdprintk(VXD_CBIT(xid, 5),
20506 + "moved task %p into vxi:%p[#%d]",
20507 + p, vxi, vxi->vx_id);
20509 + vx_mask_cap_bset(vxi, p);
20512 + /* hack for *spaces to provide compatibility */
20514 + struct nsproxy *old_nsp, *new_nsp;
20516 + ret = unshare_nsproxy_namespaces(
20517 + CLONE_NEWUTS | CLONE_NEWIPC,
20522 + old_nsp = xchg(&p->nsproxy, new_nsp);
20523 + vx_set_space(vxi, CLONE_NEWUTS | CLONE_NEWIPC);
20524 + put_nsproxy(old_nsp);
20528 + put_vx_info(old_vxi);
20532 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
20534 + struct task_struct *old_reaper;
20539 + vxdprintk(VXD_CBIT(xid, 6),
20540 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
20541 + vxi, vxi->vx_id, p, p->xid, p->pid);
20543 + old_reaper = vxi->vx_reaper;
20544 + if (old_reaper == p)
20547 + /* set new child reaper */
20548 + get_task_struct(p);
20549 + vxi->vx_reaper = p;
20550 + put_task_struct(old_reaper);
20554 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
20559 + vxdprintk(VXD_CBIT(xid, 6),
20560 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
20561 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
20563 + vxi->vx_flags &= ~VXF_STATE_INIT;
20564 + vxi->vx_initpid = p->tgid;
20568 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
20570 + vxdprintk(VXD_CBIT(xid, 6),
20571 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
20572 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
20574 + vxi->exit_code = code;
20575 + vxi->vx_initpid = 0;
20579 +void vx_set_persistent(struct vx_info *vxi)
20581 + vxdprintk(VXD_CBIT(xid, 6),
20582 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
20584 + get_vx_info(vxi);
20585 + claim_vx_info(vxi, NULL);
20588 +void vx_clear_persistent(struct vx_info *vxi)
20590 + vxdprintk(VXD_CBIT(xid, 6),
20591 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
20593 + release_vx_info(vxi, NULL);
20594 + put_vx_info(vxi);
20597 +void vx_update_persistent(struct vx_info *vxi)
20599 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
20600 + vx_set_persistent(vxi);
20602 + vx_clear_persistent(vxi);
20606 +/* task must be current or locked */
20608 +void exit_vx_info(struct task_struct *p, int code)
20610 + struct vx_info *vxi = p->vx_info;
20613 + atomic_dec(&vxi->cvirt.nr_threads);
20616 + vxi->exit_code = code;
20617 + release_vx_info(vxi, p);
20621 +void exit_vx_info_early(struct task_struct *p, int code)
20623 + struct vx_info *vxi = p->vx_info;
20626 + if (vxi->vx_initpid == p->tgid)
20627 + vx_exit_init(vxi, p, code);
20628 + if (vxi->vx_reaper == p)
20629 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
20634 +/* vserver syscall commands below here */
20636 +/* taks xid and vx_info functions */
20638 +#include <asm/uaccess.h>
20641 +int vc_task_xid(uint32_t id)
20646 + struct task_struct *tsk;
20648 + read_lock(&tasklist_lock);
20649 + tsk = find_task_by_real_pid(id);
20650 + xid = (tsk) ? tsk->xid : -ESRCH;
20651 + read_unlock(&tasklist_lock);
20653 + xid = vx_current_xid();
20658 +int vc_vx_info(struct vx_info *vxi, void __user *data)
20660 + struct vcmd_vx_info_v0 vc_data;
20662 + vc_data.xid = vxi->vx_id;
20663 + vc_data.initpid = vxi->vx_initpid;
20665 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20671 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
20673 + struct vcmd_ctx_stat_v0 vc_data;
20675 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
20676 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
20678 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20684 +/* context functions */
20686 +int vc_ctx_create(uint32_t xid, void __user *data)
20688 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
20689 + struct vx_info *new_vxi;
20692 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20695 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
20698 + new_vxi = __create_vx_info(xid);
20699 + if (IS_ERR(new_vxi))
20700 + return PTR_ERR(new_vxi);
20702 + /* initial flags */
20703 + new_vxi->vx_flags = vc_data.flagword;
20706 + if (vs_state_change(new_vxi, VSC_STARTUP))
20709 + ret = vx_migrate_task(current, new_vxi, (!data));
20713 + /* return context id on success */
20714 + ret = new_vxi->vx_id;
20716 + /* get a reference for persistent contexts */
20717 + if ((vc_data.flagword & VXF_PERSISTENT))
20718 + vx_set_persistent(new_vxi);
20720 + release_vx_info(new_vxi, NULL);
20721 + put_vx_info(new_vxi);
20726 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
20728 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
20731 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20734 + ret = vx_migrate_task(current, vxi, 0);
20737 + if (vc_data.flagword & VXM_SET_INIT)
20738 + ret = vx_set_init(vxi, current);
20741 + if (vc_data.flagword & VXM_SET_REAPER)
20742 + ret = vx_set_reaper(vxi, current);
20747 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
20749 + struct vcmd_ctx_flags_v0 vc_data;
20751 + vc_data.flagword = vxi->vx_flags;
20753 + /* special STATE flag handling */
20754 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
20756 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20761 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
20763 + struct vcmd_ctx_flags_v0 vc_data;
20764 + uint64_t mask, trigger;
20766 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20769 + /* special STATE flag handling */
20770 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
20771 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
20773 + if (vxi == current->vx_info) {
20774 + if (trigger & VXF_STATE_SETUP)
20775 + vx_mask_cap_bset(vxi, current);
20776 + if (trigger & VXF_STATE_INIT) {
20779 + ret = vx_set_init(vxi, current);
20782 + ret = vx_set_reaper(vxi, current);
20788 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
20789 + vc_data.flagword, mask);
20790 + if (trigger & VXF_PERSISTENT)
20791 + vx_update_persistent(vxi);
20796 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
20799 + *bcaps = vxi->vx_bcaps;
20801 + *ccaps = vxi->vx_ccaps;
20806 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
20808 + struct vcmd_ctx_caps_v1 vc_data;
20811 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
20814 + vc_data.cmask = ~0ULL;
20816 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20821 +static int do_set_caps(struct vx_info *vxi,
20822 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
20824 + vxi->vx_bcaps = vs_mask_flags(vxi->vx_bcaps, bcaps, bmask);
20825 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
20830 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
20832 + struct vcmd_ctx_caps_v1 vc_data;
20834 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20837 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
20840 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
20842 + struct vcmd_bcaps vc_data;
20845 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
20848 + vc_data.bmask = ~0ULL;
20850 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20855 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
20857 + struct vcmd_bcaps vc_data;
20859 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20862 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
20866 +int vc_get_badness(struct vx_info *vxi, void __user *data)
20868 + struct vcmd_badness_v0 vc_data;
20870 + vc_data.bias = vxi->vx_badness_bias;
20872 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20877 +int vc_set_badness(struct vx_info *vxi, void __user *data)
20879 + struct vcmd_badness_v0 vc_data;
20881 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20884 + vxi->vx_badness_bias = vc_data.bias;
20888 +#include <linux/module.h>
20890 +EXPORT_SYMBOL_GPL(free_vx_info);
20892 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cvirt.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt.c
20893 --- linux-2.6.22.10/kernel/vserver/cvirt.c 1970-01-01 01:00:00 +0100
20894 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt.c 2007-08-15 22:00:34 +0200
20897 + * linux/kernel/vserver/cvirt.c
20899 + * Virtual Server: Context Virtualization
20901 + * Copyright (C) 2004-2007 Herbert Pötzl
20903 + * V0.01 broken out from limit.c
20904 + * V0.02 added utsname stuff
20905 + * V0.03 changed vcmds to vxi arg
20909 +#include <linux/types.h>
20910 +#include <linux/vs_cvirt.h>
20911 +#include <linux/vserver/switch.h>
20912 +#include <linux/vserver/cvirt_cmd.h>
20914 +#include <asm/uaccess.h>
20917 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
20919 + struct vx_info *vxi = current->vx_info;
20921 + set_normalized_timespec(uptime,
20922 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
20923 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
20926 + set_normalized_timespec(idle,
20927 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
20928 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
20932 +uint64_t vx_idle_jiffies(void)
20934 + return init_task.utime + init_task.stime;
20939 +static inline uint32_t __update_loadavg(uint32_t load,
20940 + int wsize, int delta, int n)
20942 + unsigned long long calc, prev;
20944 + /* just set it to n */
20945 + if (unlikely(delta >= wsize))
20946 + return (n << FSHIFT);
20948 + calc = delta * n;
20950 + prev = (wsize - delta);
20953 + do_div(calc, wsize);
20958 +void vx_update_load(struct vx_info *vxi)
20960 + uint32_t now, last, delta;
20961 + unsigned int nr_running, nr_uninterruptible;
20962 + unsigned int total;
20963 + unsigned long flags;
20965 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
20968 + last = vxi->cvirt.load_last;
20969 + delta = now - last;
20971 + if (delta < 5*HZ)
20974 + nr_running = atomic_read(&vxi->cvirt.nr_running);
20975 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
20976 + total = nr_running + nr_uninterruptible;
20978 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
20979 + 60*HZ, delta, total);
20980 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
20981 + 5*60*HZ, delta, total);
20982 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
20983 + 15*60*HZ, delta, total);
20985 + vxi->cvirt.load_last = now;
20987 + atomic_inc(&vxi->cvirt.load_updates);
20988 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
20993 + * Commands to do_syslog:
20995 + * 0 -- Close the log. Currently a NOP.
20996 + * 1 -- Open the log. Currently a NOP.
20997 + * 2 -- Read from the log.
20998 + * 3 -- Read all messages remaining in the ring buffer.
20999 + * 4 -- Read and clear all messages remaining in the ring buffer
21000 + * 5 -- Clear ring buffer.
21001 + * 6 -- Disable printk's to console
21002 + * 7 -- Enable printk's to console
21003 + * 8 -- Set level of messages printed to console
21004 + * 9 -- Return number of unread characters in the log buffer
21005 + * 10 -- Return size of the log buffer
21007 +int vx_do_syslog(int type, char __user *buf, int len)
21010 + int do_clear = 0;
21011 + struct vx_info *vxi = current->vx_info;
21012 + struct _vx_syslog *log;
21016 + log = &vxi->cvirt.syslog;
21019 + case 0: /* Close log */
21020 + case 1: /* Open log */
21022 + case 2: /* Read from log */
21023 + error = wait_event_interruptible(log->log_wait,
21024 + (log->log_start - log->log_end));
21027 + spin_lock_irq(&log->logbuf_lock);
21028 + spin_unlock_irq(&log->logbuf_lock);
21030 + case 4: /* Read/clear last kernel messages */
21032 + /* fall through */
21033 + case 3: /* Read last kernel messages */
21036 + case 5: /* Clear ring buffer */
21039 + case 6: /* Disable logging to console */
21040 + case 7: /* Enable logging to console */
21041 + case 8: /* Set level of messages printed to console */
21044 + case 9: /* Number of chars in the log buffer */
21046 + case 10: /* Size of the log buffer */
21056 +/* virtual host info names */
21058 +static char *vx_vhi_name(struct vx_info *vxi, int id)
21060 + struct nsproxy *nsproxy;
21061 + struct uts_namespace *uts;
21064 + if (id == VHIN_CONTEXT)
21065 + return vxi->vx_name;
21067 + nsproxy = vxi->vx_nsproxy;
21071 + uts = nsproxy->uts_ns;
21076 + case VHIN_SYSNAME:
21077 + return uts->name.sysname;
21078 + case VHIN_NODENAME:
21079 + return uts->name.nodename;
21080 + case VHIN_RELEASE:
21081 + return uts->name.release;
21082 + case VHIN_VERSION:
21083 + return uts->name.version;
21084 + case VHIN_MACHINE:
21085 + return uts->name.machine;
21086 + case VHIN_DOMAINNAME:
21087 + return uts->name.domainname;
21094 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
21096 + struct vcmd_vhi_name_v0 vc_data;
21099 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21102 + name = vx_vhi_name(vxi, vc_data.field);
21106 + memcpy(name, vc_data.name, 65);
21110 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
21112 + struct vcmd_vhi_name_v0 vc_data;
21115 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21118 + name = vx_vhi_name(vxi, vc_data.field);
21122 + memcpy(vc_data.name, name, 65);
21123 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21129 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
21131 + struct vcmd_virt_stat_v0 vc_data;
21132 + struct _vx_cvirt *cvirt = &vxi->cvirt;
21133 + struct timespec uptime;
21135 + do_posix_clock_monotonic_gettime(&uptime);
21136 + set_normalized_timespec(&uptime,
21137 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
21138 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
21140 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
21141 + vc_data.uptime = timespec_to_ns(&uptime);
21142 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
21143 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
21144 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
21145 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
21146 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
21147 + vc_data.load[0] = cvirt->load[0];
21148 + vc_data.load[1] = cvirt->load[1];
21149 + vc_data.load[2] = cvirt->load[2];
21151 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21157 +#ifdef CONFIG_VSERVER_VTIME
21159 +/* virtualized time base */
21161 +void vx_gettimeofday(struct timeval *tv)
21163 + do_gettimeofday(tv);
21164 + if (!vx_flags(VXF_VIRT_TIME, 0))
21167 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
21168 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
21170 + if (tv->tv_usec >= USEC_PER_SEC) {
21172 + tv->tv_usec -= USEC_PER_SEC;
21173 + } else if (tv->tv_usec < 0) {
21175 + tv->tv_usec += USEC_PER_SEC;
21179 +int vx_settimeofday(struct timespec *ts)
21181 + struct timeval tv;
21183 + if (!vx_flags(VXF_VIRT_TIME, 0))
21184 + return do_settimeofday(ts);
21186 + do_gettimeofday(&tv);
21187 + current->vx_info->cvirt.bias_tv.tv_sec =
21188 + ts->tv_sec - tv.tv_sec;
21189 + current->vx_info->cvirt.bias_tv.tv_usec =
21190 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
21196 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cvirt_init.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt_init.h
21197 --- linux-2.6.22.10/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00 +0100
21198 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt_init.h 2007-10-25 17:05:55 +0200
21202 +extern uint64_t vx_idle_jiffies(void);
21204 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
21206 + uint64_t idle_jiffies = vx_idle_jiffies();
21207 + uint64_t nsuptime;
21209 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
21210 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
21211 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
21212 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
21213 + cvirt->bias_tv.tv_sec = 0;
21214 + cvirt->bias_tv.tv_usec = 0;
21216 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
21217 + atomic_set(&cvirt->nr_threads, 0);
21218 + atomic_set(&cvirt->nr_running, 0);
21219 + atomic_set(&cvirt->nr_uninterruptible, 0);
21220 + atomic_set(&cvirt->nr_onhold, 0);
21222 + spin_lock_init(&cvirt->load_lock);
21223 + cvirt->load_last = jiffies;
21224 + atomic_set(&cvirt->load_updates, 0);
21225 + cvirt->load[0] = 0;
21226 + cvirt->load[1] = 0;
21227 + cvirt->load[2] = 0;
21228 + atomic_set(&cvirt->total_forks, 0);
21230 + spin_lock_init(&cvirt->syslog.logbuf_lock);
21231 + init_waitqueue_head(&cvirt->syslog.log_wait);
21232 + cvirt->syslog.log_start = 0;
21233 + cvirt->syslog.log_end = 0;
21234 + cvirt->syslog.con_start = 0;
21235 + cvirt->syslog.logged_chars = 0;
21239 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
21241 + // cvirt_pc->cpustat = { 0 };
21244 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
21248 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
21249 + "!!! cvirt: %p[nr_threads] = %d on exit.",
21251 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
21252 + "!!! cvirt: %p[nr_running] = %d on exit.",
21254 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
21255 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
21257 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
21258 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
21264 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
21269 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cvirt_proc.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt_proc.h
21270 --- linux-2.6.22.10/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00 +0100
21271 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt_proc.h 2007-08-05 20:53:13 +0200
21273 +#ifndef _VX_CVIRT_PROC_H
21274 +#define _VX_CVIRT_PROC_H
21276 +#include <linux/nsproxy.h>
21277 +#include <linux/mnt_namespace.h>
21278 +#include <linux/utsname.h>
21279 +#include <linux/ipc.h>
21283 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
21285 + struct mnt_namespace *ns;
21286 + struct uts_namespace *uts;
21287 + struct ipc_namespace *ipc;
21288 + struct vfsmount *mnt;
21289 + char *path, *root;
21295 + length += sprintf(buffer + length,
21296 + "NSProxy:\t%p [%p,%p,%p]\n",
21297 + nsproxy, nsproxy->mnt_ns,
21298 + nsproxy->uts_ns, nsproxy->ipc_ns);
21300 + ns = nsproxy->mnt_ns;
21304 + path = kmalloc(PATH_MAX, GFP_KERNEL);
21309 + root = d_path(mnt->mnt_root, mnt->mnt_parent, path, PATH_MAX - 2);
21310 + length += sprintf(buffer + length,
21311 + "Namespace:\t%p [#%u]\n"
21312 + "RootPath:\t%s\n",
21313 + ns, atomic_read(&ns->count),
21318 + uts = nsproxy->uts_ns;
21322 + length += sprintf(buffer + length,
21323 + "SysName:\t%.*s\n"
21324 + "NodeName:\t%.*s\n"
21325 + "Release:\t%.*s\n"
21326 + "Version:\t%.*s\n"
21327 + "Machine:\t%.*s\n"
21328 + "DomainName:\t%.*s\n",
21329 + __NEW_UTS_LEN, uts->name.sysname,
21330 + __NEW_UTS_LEN, uts->name.nodename,
21331 + __NEW_UTS_LEN, uts->name.release,
21332 + __NEW_UTS_LEN, uts->name.version,
21333 + __NEW_UTS_LEN, uts->name.machine,
21334 + __NEW_UTS_LEN, uts->name.domainname);
21337 + ipc = nsproxy->ipc_ns;
21341 + length += sprintf(buffer + length,
21342 + "SEMS:\t\t%d %d %d %d %d\n"
21343 + "MSG:\t\t%d %d %d\n"
21344 + "SHM:\t\t%lu %lu %d %d\n",
21345 + ipc->sem_ctls[0], ipc->sem_ctls[1],
21346 + ipc->sem_ctls[2], ipc->sem_ctls[3],
21348 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
21349 + (unsigned long)ipc->shm_ctlmax,
21350 + (unsigned long)ipc->shm_ctlall,
21351 + ipc->shm_ctlmni, ipc->shm_tot);
21358 +#include <linux/sched.h>
21360 +#define LOAD_INT(x) ((x) >> FSHIFT)
21361 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
21364 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
21369 + length += sprintf(buffer + length,
21370 + "BiasUptime:\t%lu.%02lu\n",
21371 + (unsigned long)cvirt->bias_uptime.tv_sec,
21372 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
21374 + a = cvirt->load[0] + (FIXED_1 / 200);
21375 + b = cvirt->load[1] + (FIXED_1 / 200);
21376 + c = cvirt->load[2] + (FIXED_1 / 200);
21377 + length += sprintf(buffer + length,
21378 + "nr_threads:\t%d\n"
21379 + "nr_running:\t%d\n"
21380 + "nr_unintr:\t%d\n"
21381 + "nr_onhold:\t%d\n"
21382 + "load_updates:\t%d\n"
21383 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
21384 + "total_forks:\t%d\n",
21385 + atomic_read(&cvirt->nr_threads),
21386 + atomic_read(&cvirt->nr_running),
21387 + atomic_read(&cvirt->nr_uninterruptible),
21388 + atomic_read(&cvirt->nr_onhold),
21389 + atomic_read(&cvirt->load_updates),
21390 + LOAD_INT(a), LOAD_FRAC(a),
21391 + LOAD_INT(b), LOAD_FRAC(b),
21392 + LOAD_INT(c), LOAD_FRAC(c),
21393 + atomic_read(&cvirt->total_forks));
21398 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
21399 + char *buffer, int cpu)
21405 +#endif /* _VX_CVIRT_PROC_H */
21406 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/debug.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/debug.c
21407 --- linux-2.6.22.10/kernel/vserver/debug.c 1970-01-01 01:00:00 +0100
21408 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/debug.c 2007-10-01 14:57:41 +0200
21411 + * kernel/vserver/debug.c
21413 + * Copyright (C) 2005-2007 Herbert Pötzl
21415 + * V0.01 vx_info dump support
21419 +#include <linux/module.h>
21421 +#include <linux/vserver/context.h>
21424 +void dump_vx_info(struct vx_info *vxi, int level)
21426 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
21427 + atomic_read(&vxi->vx_usecnt),
21428 + atomic_read(&vxi->vx_tasks),
21431 + __dump_vx_limit(&vxi->limit);
21432 + __dump_vx_sched(&vxi->sched);
21433 + __dump_vx_cvirt(&vxi->cvirt);
21434 + __dump_vx_cacct(&vxi->cacct);
21440 +EXPORT_SYMBOL_GPL(dump_vx_info);
21442 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/device.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/device.c
21443 --- linux-2.6.22.10/kernel/vserver/device.c 1970-01-01 01:00:00 +0100
21444 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/device.c 2007-10-11 01:10:22 +0200
21447 + * linux/kernel/vserver/device.c
21449 + * Linux-VServer: Device Support
21451 + * Copyright (C) 2006 Herbert Pötzl
21452 + * Copyright (C) 2007 Daniel Hokka Zakrisson
21454 + * V0.01 device mapping basics
21455 + * V0.02 added defaults
21459 +#include <linux/slab.h>
21460 +#include <linux/rcupdate.h>
21461 +#include <linux/fs.h>
21462 +#include <linux/namei.h>
21463 +#include <linux/hash.h>
21465 +#include <asm/errno.h>
21466 +#include <asm/uaccess.h>
21467 +#include <linux/vserver/base.h>
21468 +#include <linux/vserver/debug.h>
21469 +#include <linux/vserver/context.h>
21470 +#include <linux/vserver/device.h>
21471 +#include <linux/vserver/device_cmd.h>
21474 +#define DMAP_HASH_BITS 4
21477 +struct vs_mapping {
21479 + struct hlist_node hlist;
21480 + struct list_head list;
21482 +#define dm_hlist u.hlist
21483 +#define dm_list u.list
21486 + struct vx_dmap_target target;
21490 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
21492 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
21494 +static struct vx_dmap_target dmap_defaults[2] = {
21495 + { .flags = DATTR_OPEN },
21496 + { .flags = DATTR_OPEN },
21500 +struct kmem_cache *dmap_cachep __read_mostly;
21502 +int __init dmap_cache_init(void)
21504 + dmap_cachep = kmem_cache_create("dmap_cache",
21505 + sizeof(struct vs_mapping), 0,
21506 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
21510 +__initcall(dmap_cache_init);
21513 +static inline unsigned int __hashval(dev_t dev, int bits)
21515 + return hash_long((unsigned long)dev, bits);
21519 +/* __hash_mapping()
21520 + * add the mapping to the hash table
21522 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
21524 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21525 + struct hlist_head *head, *hash = dmap_main_hash;
21526 + int device = vdm->device;
21528 + spin_lock(hash_lock);
21529 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
21530 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
21532 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
21533 + hlist_add_head(&vdm->dm_hlist, head);
21534 + spin_unlock(hash_lock);
21538 +static inline int __mode_to_default(umode_t mode)
21551 +/* __set_default()
21554 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
21555 + struct vx_dmap_target *vdmt)
21557 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21558 + spin_lock(hash_lock);
21561 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
21563 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
21566 + spin_unlock(hash_lock);
21568 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
21569 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
21573 +/* __remove_default()
21574 + * remove a default
21576 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
21578 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21579 + spin_lock(hash_lock);
21582 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
21583 + else /* remove == reset */
21584 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
21586 + spin_unlock(hash_lock);
21591 +/* __find_mapping()
21592 + * find a mapping in the hash table
21594 + * caller must hold hash_lock
21596 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
21597 + struct vs_mapping **local, struct vs_mapping **global)
21599 + struct hlist_head *hash = dmap_main_hash;
21600 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
21601 + struct hlist_node *pos;
21602 + struct vs_mapping *vdm;
21608 + hlist_for_each(pos, head) {
21609 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
21611 + if ((vdm->device == device) &&
21612 + !((vdm->target.flags ^ mode) & S_IFMT)) {
21613 + if (vdm->xid == xid) {
21616 + } else if (global && vdm->xid == 0)
21621 + if (global && *global)
21628 +/* __lookup_mapping()
21629 + * find a mapping and store the result in target and flags
21631 +static inline int __lookup_mapping(struct vx_info *vxi,
21632 + dev_t device, dev_t *target, int *flags, umode_t mode)
21634 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21635 + struct vs_mapping *vdm, *global;
21636 + struct vx_dmap_target *vdmt;
21638 + xid_t xid = vxi->vx_id;
21641 + spin_lock(hash_lock);
21642 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
21644 + vdmt = &vdm->target;
21648 + index = __mode_to_default(mode);
21649 + if (vxi && vxi->dmap.targets[index].flags) {
21651 + vdmt = &vxi->dmap.targets[index];
21652 + } else if (global) {
21654 + vdmt = &global->target;
21658 + vdmt = &dmap_defaults[index];
21662 + if (target && (vdmt->flags & DATTR_REMAP))
21663 + *target = vdmt->target;
21665 + *target = device;
21667 + *flags = vdmt->flags;
21669 + spin_unlock(hash_lock);
21675 +/* __remove_mapping()
21676 + * remove a mapping from the hash table
21678 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
21681 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21682 + struct vs_mapping *vdm = NULL;
21685 + spin_lock(hash_lock);
21687 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
21689 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
21690 + vxi, vxi ? vxi->vx_id : 0, device, mode);
21693 + hlist_del(&vdm->dm_hlist);
21696 + spin_unlock(hash_lock);
21698 + kmem_cache_free(dmap_cachep, vdm);
21704 +int vs_map_device(struct vx_info *vxi,
21705 + dev_t device, dev_t *target, umode_t mode)
21707 + int ret, flags = DATTR_MASK;
21711 + *target = device;
21714 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
21715 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
21716 + device, target ? *target : 0, flags, mode, ret);
21718 + return (flags & DATTR_MASK);
21723 +static int do_set_mapping(struct vx_info *vxi,
21724 + dev_t device, dev_t target, int flags, umode_t mode)
21727 + struct vs_mapping *new;
21729 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
21733 + INIT_HLIST_NODE(&new->dm_hlist);
21734 + new->device = device;
21735 + new->target.target = target;
21736 + new->target.flags = flags | mode;
21737 + new->xid = (vxi ? vxi->vx_id : 0);
21739 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
21740 + __hash_mapping(vxi, new);
21742 + struct vx_dmap_target new = {
21743 + .target = target,
21744 + .flags = flags | mode,
21746 + __set_default(vxi, mode, &new);
21752 +static int do_unset_mapping(struct vx_info *vxi,
21753 + dev_t device, dev_t target, int flags, umode_t mode)
21755 + int ret = -EINVAL;
21758 + ret = __remove_mapping(vxi, device, mode);
21762 + ret = __remove_default(vxi, mode);
21772 +static inline int __user_device(const char __user *name, dev_t *dev,
21775 + struct nameidata nd;
21782 + ret = user_path_walk_link(name, &nd);
21785 + if (nd.dentry->d_inode) {
21786 + *dev = nd.dentry->d_inode->i_rdev;
21787 + *mode = nd.dentry->d_inode->i_mode;
21789 + path_release(&nd);
21793 +static inline int __mapping_mode(dev_t device, dev_t target,
21794 + umode_t device_mode, umode_t target_mode, umode_t *mode)
21797 + *mode = device_mode & S_IFMT;
21799 + *mode = target_mode & S_IFMT;
21803 + /* if both given, device and target mode have to match */
21804 + if (device && target &&
21805 + ((device_mode ^ target_mode) & S_IFMT))
21811 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
21812 + const char __user *target_path, int flags, int set)
21814 + dev_t device = ~0, target = ~0;
21815 + umode_t device_mode = 0, target_mode = 0, mode;
21818 + ret = __user_device(device_path, &device, &device_mode);
21821 + ret = __user_device(target_path, &target, &target_mode);
21825 + ret = __mapping_mode(device, target,
21826 + device_mode, target_mode, &mode);
21831 + return do_set_mapping(vxi, device, target,
21834 + return do_unset_mapping(vxi, device, target,
21839 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
21841 + struct vcmd_set_mapping_v0 vc_data;
21843 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21846 + return do_mapping(vxi, vc_data.device, vc_data.target,
21847 + vc_data.flags, 1);
21850 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
21852 + struct vcmd_set_mapping_v0 vc_data;
21854 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21857 + return do_mapping(vxi, vc_data.device, vc_data.target,
21858 + vc_data.flags, 0);
21862 +#ifdef CONFIG_COMPAT
21864 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
21866 + struct vcmd_set_mapping_v0_x32 vc_data;
21868 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21871 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
21872 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
21875 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
21877 + struct vcmd_set_mapping_v0_x32 vc_data;
21879 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21882 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
21883 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
21886 +#endif /* CONFIG_COMPAT */
21889 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/dlimit.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/dlimit.c
21890 --- linux-2.6.22.10/kernel/vserver/dlimit.c 1970-01-01 01:00:00 +0100
21891 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/dlimit.c 2007-08-15 22:07:58 +0200
21894 + * linux/kernel/vserver/dlimit.c
21896 + * Virtual Server: Context Disk Limits
21898 + * Copyright (C) 2004-2007 Herbert Pötzl
21900 + * V0.01 initial version
21901 + * V0.02 compat32 splitup
21905 +#include <linux/statfs.h>
21906 +#include <linux/vs_tag.h>
21907 +#include <linux/vs_dlimit.h>
21908 +#include <linux/vserver/dlimit_cmd.h>
21910 +#include <asm/uaccess.h>
21912 +/* __alloc_dl_info()
21914 + * allocate an initialized dl_info struct
21915 + * doesn't make it visible (hash) */
21917 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
21919 + struct dl_info *new = NULL;
21921 + vxdprintk(VXD_CBIT(dlim, 5),
21922 + "alloc_dl_info(%p,%d)*", sb, tag);
21924 + /* would this benefit from a slab cache? */
21925 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
21929 + memset(new, 0, sizeof(struct dl_info));
21930 + new->dl_tag = tag;
21932 + INIT_RCU_HEAD(&new->dl_rcu);
21933 + INIT_HLIST_NODE(&new->dl_hlist);
21934 + spin_lock_init(&new->dl_lock);
21935 + atomic_set(&new->dl_refcnt, 0);
21936 + atomic_set(&new->dl_usecnt, 0);
21938 + /* rest of init goes here */
21940 + vxdprintk(VXD_CBIT(dlim, 4),
21941 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
21945 +/* __dealloc_dl_info()
21947 + * final disposal of dl_info */
21949 +static void __dealloc_dl_info(struct dl_info *dli)
21951 + vxdprintk(VXD_CBIT(dlim, 4),
21952 + "dealloc_dl_info(%p)", dli);
21954 + dli->dl_hlist.next = LIST_POISON1;
21955 + dli->dl_tag = -1;
21958 + BUG_ON(atomic_read(&dli->dl_usecnt));
21959 + BUG_ON(atomic_read(&dli->dl_refcnt));
21965 +/* hash table for dl_info hash */
21967 +#define DL_HASH_SIZE 13
21969 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
21971 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
21974 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
21976 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
21981 +/* __hash_dl_info()
21983 + * add the dli to the global hash table
21984 + * requires the hash_lock to be held */
21986 +static inline void __hash_dl_info(struct dl_info *dli)
21988 + struct hlist_head *head;
21990 + vxdprintk(VXD_CBIT(dlim, 6),
21991 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
21992 + get_dl_info(dli);
21993 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
21994 + hlist_add_head_rcu(&dli->dl_hlist, head);
21997 +/* __unhash_dl_info()
21999 + * remove the dli from the global hash table
22000 + * requires the hash_lock to be held */
22002 +static inline void __unhash_dl_info(struct dl_info *dli)
22004 + vxdprintk(VXD_CBIT(dlim, 6),
22005 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
22006 + hlist_del_rcu(&dli->dl_hlist);
22007 + put_dl_info(dli);
22011 +/* __lookup_dl_info()
22013 + * requires the rcu_read_lock()
22014 + * doesn't increment the dl_refcnt */
22016 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
22018 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
22019 + struct hlist_node *pos;
22020 + struct dl_info *dli;
22022 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
22024 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
22032 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
22034 + struct dl_info *dli;
22037 + dli = get_dl_info(__lookup_dl_info(sb, tag));
22038 + vxdprintk(VXD_CBIT(dlim, 7),
22039 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
22040 + rcu_read_unlock();
22044 +void rcu_free_dl_info(struct rcu_head *head)
22046 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
22047 + int usecnt, refcnt;
22049 + BUG_ON(!dli || !head);
22051 + usecnt = atomic_read(&dli->dl_usecnt);
22052 + BUG_ON(usecnt < 0);
22054 + refcnt = atomic_read(&dli->dl_refcnt);
22055 + BUG_ON(refcnt < 0);
22057 + vxdprintk(VXD_CBIT(dlim, 3),
22058 + "rcu_free_dl_info(%p)", dli);
22060 + __dealloc_dl_info(dli);
22062 + printk("!!! rcu didn't free\n");
22068 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
22069 + uint32_t flags, int add)
22071 + struct nameidata nd;
22074 + ret = user_path_walk_link(name, &nd);
22076 + struct super_block *sb;
22077 + struct dl_info *dli;
22080 + if (!nd.dentry->d_inode)
22081 + goto out_release;
22082 + if (!(sb = nd.dentry->d_inode->i_sb))
22083 + goto out_release;
22086 + dli = __alloc_dl_info(sb, id);
22087 + spin_lock(&dl_info_hash_lock);
22090 + if (__lookup_dl_info(sb, id))
22092 + __hash_dl_info(dli);
22095 + spin_lock(&dl_info_hash_lock);
22096 + dli = __lookup_dl_info(sb, id);
22101 + __unhash_dl_info(dli);
22105 + spin_unlock(&dl_info_hash_lock);
22107 + __dealloc_dl_info(dli);
22109 + path_release(&nd);
22114 +int vc_add_dlimit(uint32_t id, void __user *data)
22116 + struct vcmd_ctx_dlimit_base_v0 vc_data;
22118 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22121 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
22124 +int vc_rem_dlimit(uint32_t id, void __user *data)
22126 + struct vcmd_ctx_dlimit_base_v0 vc_data;
22128 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22131 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
22134 +#ifdef CONFIG_COMPAT
22136 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
22138 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
22140 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22143 + return do_addrem_dlimit(id,
22144 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
22147 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
22149 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
22151 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22154 + return do_addrem_dlimit(id,
22155 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
22158 +#endif /* CONFIG_COMPAT */
22162 +int do_set_dlimit(uint32_t id, const char __user *name,
22163 + uint32_t space_used, uint32_t space_total,
22164 + uint32_t inodes_used, uint32_t inodes_total,
22165 + uint32_t reserved, uint32_t flags)
22167 + struct nameidata nd;
22170 + ret = user_path_walk_link(name, &nd);
22172 + struct super_block *sb;
22173 + struct dl_info *dli;
22176 + if (!nd.dentry->d_inode)
22177 + goto out_release;
22178 + if (!(sb = nd.dentry->d_inode->i_sb))
22179 + goto out_release;
22180 + if ((reserved != CDLIM_KEEP &&
22181 + reserved > 100) ||
22182 + (inodes_used != CDLIM_KEEP &&
22183 + inodes_used > inodes_total) ||
22184 + (space_used != CDLIM_KEEP &&
22185 + space_used > space_total))
22186 + goto out_release;
22189 + dli = locate_dl_info(sb, id);
22191 + goto out_release;
22193 + spin_lock(&dli->dl_lock);
22195 + if (inodes_used != CDLIM_KEEP)
22196 + dli->dl_inodes_used = inodes_used;
22197 + if (inodes_total != CDLIM_KEEP)
22198 + dli->dl_inodes_total = inodes_total;
22199 + if (space_used != CDLIM_KEEP) {
22200 + dli->dl_space_used = space_used;
22201 + dli->dl_space_used <<= 10;
22203 + if (space_total == CDLIM_INFINITY)
22204 + dli->dl_space_total = DLIM_INFINITY;
22205 + else if (space_total != CDLIM_KEEP) {
22206 + dli->dl_space_total = space_total;
22207 + dli->dl_space_total <<= 10;
22209 + if (reserved != CDLIM_KEEP)
22210 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
22212 + spin_unlock(&dli->dl_lock);
22214 + put_dl_info(dli);
22218 + path_release(&nd);
22223 +int vc_set_dlimit(uint32_t id, void __user *data)
22225 + struct vcmd_ctx_dlimit_v0 vc_data;
22227 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22230 + return do_set_dlimit(id, vc_data.name,
22231 + vc_data.space_used, vc_data.space_total,
22232 + vc_data.inodes_used, vc_data.inodes_total,
22233 + vc_data.reserved, vc_data.flags);
22236 +#ifdef CONFIG_COMPAT
22238 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
22240 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
22242 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22245 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
22246 + vc_data.space_used, vc_data.space_total,
22247 + vc_data.inodes_used, vc_data.inodes_total,
22248 + vc_data.reserved, vc_data.flags);
22251 +#endif /* CONFIG_COMPAT */
22255 +int do_get_dlimit(uint32_t id, const char __user *name,
22256 + uint32_t *space_used, uint32_t *space_total,
22257 + uint32_t *inodes_used, uint32_t *inodes_total,
22258 + uint32_t *reserved, uint32_t *flags)
22260 + struct nameidata nd;
22263 + ret = user_path_walk_link(name, &nd);
22265 + struct super_block *sb;
22266 + struct dl_info *dli;
22269 + if (!nd.dentry->d_inode)
22270 + goto out_release;
22271 + if (!(sb = nd.dentry->d_inode->i_sb))
22272 + goto out_release;
22275 + dli = locate_dl_info(sb, id);
22277 + goto out_release;
22279 + spin_lock(&dli->dl_lock);
22280 + *inodes_used = dli->dl_inodes_used;
22281 + *inodes_total = dli->dl_inodes_total;
22282 + *space_used = dli->dl_space_used >> 10;
22283 + if (dli->dl_space_total == DLIM_INFINITY)
22284 + *space_total = CDLIM_INFINITY;
22286 + *space_total = dli->dl_space_total >> 10;
22288 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
22289 + spin_unlock(&dli->dl_lock);
22291 + put_dl_info(dli);
22296 + path_release(&nd);
22302 +int vc_get_dlimit(uint32_t id, void __user *data)
22304 + struct vcmd_ctx_dlimit_v0 vc_data;
22307 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22310 + ret = do_get_dlimit(id, vc_data.name,
22311 + &vc_data.space_used, &vc_data.space_total,
22312 + &vc_data.inodes_used, &vc_data.inodes_total,
22313 + &vc_data.reserved, &vc_data.flags);
22317 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22322 +#ifdef CONFIG_COMPAT
22324 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
22326 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
22329 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22332 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
22333 + &vc_data.space_used, &vc_data.space_total,
22334 + &vc_data.inodes_used, &vc_data.inodes_total,
22335 + &vc_data.reserved, &vc_data.flags);
22339 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22344 +#endif /* CONFIG_COMPAT */
22347 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
22349 + struct dl_info *dli;
22350 + __u64 blimit, bfree, bavail;
22353 + dli = locate_dl_info(sb, dx_current_tag());
22357 + spin_lock(&dli->dl_lock);
22358 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
22361 + /* reduce max inodes available to limit */
22362 + if (buf->f_files > dli->dl_inodes_total)
22363 + buf->f_files = dli->dl_inodes_total;
22365 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
22366 + /* reduce free inodes to min */
22367 + if (ifree < buf->f_ffree)
22368 + buf->f_ffree = ifree;
22371 + if (dli->dl_space_total == DLIM_INFINITY)
22374 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
22376 + if (dli->dl_space_total < dli->dl_space_used)
22379 + bfree = (dli->dl_space_total - dli->dl_space_used)
22380 + >> sb->s_blocksize_bits;
22382 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
22383 + if (bavail < dli->dl_space_used)
22386 + bavail = (bavail - dli->dl_space_used)
22387 + >> sb->s_blocksize_bits;
22389 + /* reduce max space available to limit */
22390 + if (buf->f_blocks > blimit)
22391 + buf->f_blocks = blimit;
22393 + /* reduce free space to min */
22394 + if (bfree < buf->f_bfree)
22395 + buf->f_bfree = bfree;
22397 + /* reduce avail space to min */
22398 + if (bavail < buf->f_bavail)
22399 + buf->f_bavail = bavail;
22402 + spin_unlock(&dli->dl_lock);
22403 + put_dl_info(dli);
22408 +#include <linux/module.h>
22410 +EXPORT_SYMBOL_GPL(locate_dl_info);
22411 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
22413 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/helper.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/helper.c
22414 --- linux-2.6.22.10/kernel/vserver/helper.c 1970-01-01 01:00:00 +0100
22415 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/helper.c 2007-08-15 22:12:01 +0200
22418 + * linux/kernel/vserver/helper.c
22420 + * Virtual Context Support
22422 + * Copyright (C) 2004-2007 Herbert Pötzl
22424 + * V0.01 basic helper
22428 +#include <linux/kmod.h>
22429 +#include <linux/reboot.h>
22430 +#include <linux/vs_context.h>
22431 +#include <linux/vs_network.h>
22432 +#include <linux/vserver/signal.h>
22435 +char vshelper_path[255] = "/sbin/vshelper";
22438 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
22442 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
22443 + printk( KERN_WARNING
22444 + "%s: (%s %s) returned %s with %d\n",
22445 + name, argv[1], argv[2],
22446 + sync ? "sync" : "async", ret);
22448 + vxdprintk(VXD_CBIT(switch, 4),
22449 + "%s: (%s %s) returned %s with %d",
22450 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
22455 + * vshelper path is set via /proc/sys
22456 + * invoked by vserver sys_reboot(), with
22457 + * the following arguments
22459 + * argv [0] = vshelper_path;
22460 + * argv [1] = action: "restart", "halt", "poweroff", ...
22461 + * argv [2] = context identifier
22463 + * envp [*] = type-specific parameters
22466 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
22468 + char id_buf[8], cmd_buf[16];
22469 + char uid_buf[16], pid_buf[16];
22472 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22473 + char *envp[] = {"HOME=/", "TERM=linux",
22474 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
22475 + uid_buf, pid_buf, cmd_buf, 0};
22477 + if (vx_info_state(vxi, VXS_HELPER))
22479 + vxi->vx_state |= VXS_HELPER;
22481 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
22483 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22484 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
22485 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
22488 + case LINUX_REBOOT_CMD_RESTART:
22489 + argv[1] = "restart";
22492 + case LINUX_REBOOT_CMD_HALT:
22493 + argv[1] = "halt";
22496 + case LINUX_REBOOT_CMD_POWER_OFF:
22497 + argv[1] = "poweroff";
22500 + case LINUX_REBOOT_CMD_SW_SUSPEND:
22501 + argv[1] = "swsusp";
22505 + vxi->vx_state &= ~VXS_HELPER;
22509 + ret = do_vshelper(vshelper_path, argv, envp, 0);
22510 + vxi->vx_state &= ~VXS_HELPER;
22511 + __wakeup_vx_info(vxi);
22512 + return (ret) ? -EPERM : 0;
22516 +long vs_reboot(unsigned int cmd, void __user *arg)
22518 + struct vx_info *vxi = current->vx_info;
22521 + vxdprintk(VXD_CBIT(misc, 5),
22522 + "vs_reboot(%p[#%d],%d)",
22523 + vxi, vxi ? vxi->vx_id : 0, cmd);
22525 + ret = vs_reboot_helper(vxi, cmd, arg);
22529 + vxi->reboot_cmd = cmd;
22530 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
22532 + case LINUX_REBOOT_CMD_RESTART:
22533 + case LINUX_REBOOT_CMD_HALT:
22534 + case LINUX_REBOOT_CMD_POWER_OFF:
22535 + vx_info_kill(vxi, 0, SIGKILL);
22536 + vx_info_kill(vxi, 1, SIGKILL);
22546 + * argv [0] = vshelper_path;
22547 + * argv [1] = action: "startup", "shutdown"
22548 + * argv [2] = context identifier
22550 + * envp [*] = type-specific parameters
22553 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
22555 + char id_buf[8], cmd_buf[16];
22556 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22557 + char *envp[] = {"HOME=/", "TERM=linux",
22558 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
22560 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
22563 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
22564 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22567 + case VSC_STARTUP:
22568 + argv[1] = "startup";
22570 + case VSC_SHUTDOWN:
22571 + argv[1] = "shutdown";
22577 + return do_vshelper(vshelper_path, argv, envp, 1);
22582 + * argv [0] = vshelper_path;
22583 + * argv [1] = action: "netup", "netdown"
22584 + * argv [2] = context identifier
22586 + * envp [*] = type-specific parameters
22589 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
22591 + char id_buf[8], cmd_buf[16];
22592 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22593 + char *envp[] = {"HOME=/", "TERM=linux",
22594 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
22596 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
22599 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
22600 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22604 + argv[1] = "netup";
22606 + case VSC_NETDOWN:
22607 + argv[1] = "netdown";
22613 + return do_vshelper(vshelper_path, argv, envp, 1);
22616 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/history.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/history.c
22617 --- linux-2.6.22.10/kernel/vserver/history.c 1970-01-01 01:00:00 +0100
22618 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/history.c 2007-08-15 22:13:54 +0200
22621 + * kernel/vserver/history.c
22623 + * Virtual Context History Backtrace
22625 + * Copyright (C) 2004-2007 Herbert Pötzl
22627 + * V0.01 basic structure
22628 + * V0.02 hash/unhash and trace
22629 + * V0.03 preemption fixes
22633 +#include <linux/module.h>
22634 +#include <asm/uaccess.h>
22636 +#include <linux/vserver/context.h>
22637 +#include <linux/vserver/debug.h>
22638 +#include <linux/vserver/debug_cmd.h>
22639 +#include <linux/vserver/history.h>
22642 +#ifdef CONFIG_VSERVER_HISTORY
22643 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
22645 +#define VXH_SIZE 64
22648 +struct _vx_history {
22649 + unsigned int counter;
22651 + struct _vx_hist_entry entry[VXH_SIZE + 1];
22655 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
22657 +unsigned volatile int vxh_active = 1;
22659 +static atomic_t sequence = ATOMIC_INIT(0);
22664 + * requires disabled preemption */
22666 +struct _vx_hist_entry *vxh_advance(void *loc)
22668 + unsigned int cpu = smp_processor_id();
22669 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
22670 + struct _vx_hist_entry *entry;
22671 + unsigned int index;
22673 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
22674 + entry = &hist->entry[index];
22676 + entry->seq = atomic_inc_return(&sequence);
22677 + entry->loc = loc;
22681 +EXPORT_SYMBOL_GPL(vxh_advance);
22684 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
22686 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
22689 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
22691 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
22692 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
22693 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
22694 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
22696 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
22698 + switch (e->type) {
22699 + case VXH_THROW_OOPS:
22700 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
22703 + case VXH_GET_VX_INFO:
22704 + case VXH_PUT_VX_INFO:
22705 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
22707 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
22708 + VXH_VXI_ARGS(e));
22711 + case VXH_INIT_VX_INFO:
22712 + case VXH_SET_VX_INFO:
22713 + case VXH_CLR_VX_INFO:
22714 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
22716 + (e->type == VXH_INIT_VX_INFO) ? "init" :
22717 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
22718 + VXH_VXI_ARGS(e), e->sc.data);
22721 + case VXH_CLAIM_VX_INFO:
22722 + case VXH_RELEASE_VX_INFO:
22723 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
22725 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
22726 + VXH_VXI_ARGS(e), e->sc.data);
22729 + case VXH_ALLOC_VX_INFO:
22730 + case VXH_DEALLOC_VX_INFO:
22731 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
22733 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
22734 + VXH_VXI_ARGS(e));
22737 + case VXH_HASH_VX_INFO:
22738 + case VXH_UNHASH_VX_INFO:
22739 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
22741 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
22742 + VXH_VXI_ARGS(e));
22745 + case VXH_LOC_VX_INFO:
22746 + case VXH_LOOKUP_VX_INFO:
22747 + case VXH_CREATE_VX_INFO:
22748 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
22750 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
22751 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
22752 + e->ll.arg, VXH_VXI_ARGS(e));
22757 +static void __vxh_dump_history(void)
22759 + unsigned int i, cpu;
22761 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
22762 + atomic_read(&sequence), NR_CPUS);
22764 + for (i = 0; i < VXH_SIZE; i++) {
22765 + for_each_online_cpu(cpu) {
22766 + struct _vx_history *hist =
22767 + &per_cpu(vx_history_buffer, cpu);
22768 + unsigned int index = (hist->counter - i) % VXH_SIZE;
22769 + struct _vx_hist_entry *entry = &hist->entry[index];
22771 + vxh_dump_entry(entry, cpu);
22776 +void vxh_dump_history(void)
22780 + local_irq_enable();
22782 + local_irq_disable();
22784 + __vxh_dump_history();
22788 +/* vserver syscall commands below here */
22791 +int vc_dump_history(uint32_t id)
22794 + __vxh_dump_history();
22801 +int do_read_history(struct __user _vx_hist_entry *data,
22802 + int cpu, uint32_t *index, uint32_t *count)
22804 + int pos, ret = 0;
22805 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
22806 + int end = hist->counter;
22807 + int start = end - VXH_SIZE + 2;
22808 + int idx = *index;
22810 + /* special case: get current pos */
22816 + /* have we lost some data? */
22820 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22821 + struct _vx_hist_entry *entry =
22822 + &hist->entry[idx % VXH_SIZE];
22824 + /* send entry to userspace */
22825 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22829 + /* save new index and count */
22832 + return ret ? ret : (*index < end);
22835 +int vc_read_history(uint32_t id, void __user *data)
22837 + struct vcmd_read_history_v0 vc_data;
22840 + if (id >= NR_CPUS)
22843 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22846 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
22847 + id, &vc_data.index, &vc_data.count);
22849 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22854 +#ifdef CONFIG_COMPAT
22856 +int vc_read_history_x32(uint32_t id, void __user *data)
22858 + struct vcmd_read_history_v0_x32 vc_data;
22861 + if (id >= NR_CPUS)
22864 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22867 + ret = do_read_history((struct __user _vx_hist_entry *)
22868 + compat_ptr(vc_data.data_ptr),
22869 + id, &vc_data.index, &vc_data.count);
22871 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22876 +#endif /* CONFIG_COMPAT */
22878 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/inet.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/inet.c
22879 --- linux-2.6.22.10/kernel/vserver/inet.c 1970-01-01 01:00:00 +0100
22880 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/inet.c 2007-10-10 23:55:30 +0200
22883 +#include <linux/in.h>
22884 +#include <linux/inetdevice.h>
22885 +#include <linux/vs_inet6.h>
22886 +#include <linux/vserver/debug.h>
22887 +#include <net/route.h>
22888 +#include <net/addrconf.h>
22891 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
22895 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
22898 + struct nx_addr_v4 *ptr;
22900 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
22901 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
22908 + vxdprintk(VXD_CBIT(net, 2),
22909 + "nx_v4_addr_conflict(%p,%p): %d",
22910 + nxi1, nxi2, ret);
22916 +#ifdef CONFIG_IPV6
22918 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
22922 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
22925 + struct nx_addr_v6 *ptr;
22927 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
22928 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
22935 + vxdprintk(VXD_CBIT(net, 2),
22936 + "nx_v6_addr_conflict(%p,%p): %d",
22937 + nxi1, nxi2, ret);
22944 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
22946 + struct in_device *in_dev;
22947 + struct in_ifaddr **ifap;
22948 + struct in_ifaddr *ifa;
22953 + in_dev = in_dev_get(dev);
22957 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
22958 + ifap = &ifa->ifa_next) {
22959 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
22964 + in_dev_put(in_dev);
22970 +#ifdef CONFIG_IPV6
22972 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
22974 + struct inet6_dev *in_dev;
22975 + struct inet6_ifaddr **ifap;
22976 + struct inet6_ifaddr *ifa;
22981 + in_dev = in6_dev_get(dev);
22985 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
22986 + ifap = &ifa->if_next) {
22987 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
22992 + in6_dev_put(in_dev);
22999 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
23005 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
23007 +#ifdef CONFIG_IPV6
23009 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
23014 + vxdprintk(VXD_CBIT(net, 3),
23015 + "dev_in_nx_info(%p,%p[#%d]) = %d",
23016 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
23020 +int ip_v4_find_src(struct nx_info *nxi, struct rtable **rp, struct flowi *fl)
23025 + /* FIXME: handle lback only case */
23026 + if (!NX_IPV4(nxi))
23029 + vxdprintk(VXD_CBIT(net, 4),
23030 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
23031 + nxi, nxi ? nxi->nx_id : 0,
23032 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
23034 + /* single IP is unconditional */
23035 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
23036 + (fl->fl4_src == INADDR_ANY))
23037 + fl->fl4_src = nxi->v4.ip[0].s_addr;
23039 + if (fl->fl4_src == INADDR_ANY) {
23040 + struct nx_addr_v4 *ptr;
23044 + err = __ip_route_output_key(rp, fl);
23046 + found = (*rp)->rt_src;
23048 + vxdprintk(VXD_CBIT(net, 4),
23049 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
23050 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
23051 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
23055 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
23056 + __be32 primary = ptr->ip[0].s_addr;
23057 + __be32 mask = ptr->mask.s_addr;
23058 + __be32 net = primary & mask;
23060 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
23061 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
23062 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
23063 + NIPQUAD(mask), NIPQUAD(net));
23064 + if ((found & mask) != net)
23067 + fl->fl4_src = primary;
23068 + err = __ip_route_output_key(rp, fl);
23069 + vxdprintk(VXD_CBIT(net, 4),
23070 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
23071 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
23073 + found = (*rp)->rt_src;
23075 + if (found == primary)
23079 + /* still no source ip? */
23080 + found = LOOPBACK(fl->fl4_dst)
23081 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
23083 + /* assign src ip to flow */
23084 + fl->fl4_src = found;
23087 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
23091 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
23092 + if (LOOPBACK(fl->fl4_dst))
23093 + fl->fl4_dst = nxi->v4_lback.s_addr;
23094 + if (LOOPBACK(fl->fl4_src))
23095 + fl->fl4_src = nxi->v4_lback.s_addr;
23096 + } else if (LOOPBACK(fl->fl4_dst))
23102 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
23104 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/init.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/init.c
23105 --- linux-2.6.22.10/kernel/vserver/init.c 1970-01-01 01:00:00 +0100
23106 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/init.c 2007-08-15 22:15:36 +0200
23109 + * linux/kernel/init.c
23111 + * Virtual Server Init
23113 + * Copyright (C) 2004-2007 Herbert Pötzl
23115 + * V0.01 basic structure
23119 +#include <linux/init.h>
23121 +int vserver_register_sysctl(void);
23122 +void vserver_unregister_sysctl(void);
23125 +static int __init init_vserver(void)
23129 +#ifdef CONFIG_VSERVER_DEBUG
23130 + vserver_register_sysctl();
23136 +static void __exit exit_vserver(void)
23139 +#ifdef CONFIG_VSERVER_DEBUG
23140 + vserver_unregister_sysctl();
23145 +/* FIXME: GFP_ZONETYPES gone
23146 +long vx_slab[GFP_ZONETYPES]; */
23150 +module_init(init_vserver);
23151 +module_exit(exit_vserver);
23153 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/inode.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/inode.c
23154 --- linux-2.6.22.10/kernel/vserver/inode.c 1970-01-01 01:00:00 +0100
23155 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/inode.c 2007-09-11 17:57:41 +0200
23158 + * linux/kernel/vserver/inode.c
23160 + * Virtual Server: File System Support
23162 + * Copyright (C) 2004-2007 Herbert Pötzl
23164 + * V0.01 separated from vcontext V0.05
23165 + * V0.02 moved to tag (instead of xid)
23169 +#include <linux/tty.h>
23170 +#include <linux/proc_fs.h>
23171 +#include <linux/devpts_fs.h>
23172 +#include <linux/fs.h>
23173 +#include <linux/file.h>
23174 +#include <linux/mount.h>
23175 +#include <linux/parser.h>
23176 +#include <linux/vserver/inode.h>
23177 +#include <linux/vserver/inode_cmd.h>
23178 +#include <linux/vs_base.h>
23179 +#include <linux/vs_tag.h>
23181 +#include <asm/uaccess.h>
23184 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
23186 + struct proc_dir_entry *entry;
23188 + if (!in || !in->i_sb)
23191 + *flags = IATTR_TAG
23192 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
23193 + | (IS_IUNLINK(in) ? IATTR_IUNLINK : 0)
23194 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
23195 + *mask = IATTR_IUNLINK | IATTR_IMMUTABLE;
23197 + if (S_ISDIR(in->i_mode))
23198 + *mask |= IATTR_BARRIER;
23200 + if (IS_TAGGED(in)) {
23201 + *tag = in->i_tag;
23202 + *mask |= IATTR_TAG;
23205 + switch (in->i_sb->s_magic) {
23206 + case PROC_SUPER_MAGIC:
23207 + entry = PROC_I(in)->pde;
23209 + /* check for specific inodes? */
23211 + *mask |= IATTR_FLAGS;
23213 + *flags |= (entry->vx_flags & IATTR_FLAGS);
23215 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
23218 + case DEVPTS_SUPER_MAGIC:
23219 + *tag = in->i_tag;
23220 + *mask |= IATTR_TAG;
23229 +int vc_get_iattr(void __user *data)
23231 + struct nameidata nd;
23232 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
23235 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23238 + ret = user_path_walk_link(vc_data.name, &nd);
23240 + ret = __vc_get_iattr(nd.dentry->d_inode,
23241 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23242 + path_release(&nd);
23247 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23252 +#ifdef CONFIG_COMPAT
23254 +int vc_get_iattr_x32(void __user *data)
23256 + struct nameidata nd;
23257 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
23260 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23263 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
23265 + ret = __vc_get_iattr(nd.dentry->d_inode,
23266 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23267 + path_release(&nd);
23272 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23277 +#endif /* CONFIG_COMPAT */
23280 +int vc_fget_iattr(uint32_t fd, void __user *data)
23282 + struct file *filp;
23283 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
23286 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23290 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
23293 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
23294 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23298 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23304 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
23306 + struct inode *in = de->d_inode;
23307 + int error = 0, is_proc = 0, has_tag = 0;
23308 + struct iattr attr = { 0 };
23310 + if (!in || !in->i_sb)
23313 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
23314 + if ((*mask & IATTR_FLAGS) && !is_proc)
23317 + has_tag = IS_TAGGED(in) ||
23318 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
23319 + if ((*mask & IATTR_TAG) && !has_tag)
23322 + mutex_lock(&in->i_mutex);
23323 + if (*mask & IATTR_TAG) {
23324 + attr.ia_tag = *tag;
23325 + attr.ia_valid |= ATTR_TAG;
23328 + if (*mask & IATTR_FLAGS) {
23329 + struct proc_dir_entry *entry = PROC_I(in)->pde;
23330 + unsigned int iflags = PROC_I(in)->vx_flags;
23332 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
23333 + | (*flags & IATTR_FLAGS);
23334 + PROC_I(in)->vx_flags = iflags;
23336 + entry->vx_flags = iflags;
23339 + if (*mask & (IATTR_BARRIER | IATTR_IUNLINK | IATTR_IMMUTABLE)) {
23340 + if (*mask & IATTR_IMMUTABLE) {
23341 + if (*flags & IATTR_IMMUTABLE)
23342 + in->i_flags |= S_IMMUTABLE;
23344 + in->i_flags &= ~S_IMMUTABLE;
23346 + if (*mask & IATTR_IUNLINK) {
23347 + if (*flags & IATTR_IUNLINK)
23348 + in->i_flags |= S_IUNLINK;
23350 + in->i_flags &= ~S_IUNLINK;
23352 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
23353 + if (*flags & IATTR_BARRIER)
23354 + in->i_flags |= S_BARRIER;
23356 + in->i_flags &= ~S_BARRIER;
23358 + if (in->i_op && in->i_op->sync_flags) {
23359 + error = in->i_op->sync_flags(in);
23365 + if (attr.ia_valid) {
23366 + if (in->i_op && in->i_op->setattr)
23367 + error = in->i_op->setattr(de, &attr);
23369 + error = inode_change_ok(in, &attr);
23371 + error = inode_setattr(in, &attr);
23376 + mutex_unlock(&in->i_mutex);
23380 +int vc_set_iattr(void __user *data)
23382 + struct nameidata nd;
23383 + struct vcmd_ctx_iattr_v1 vc_data;
23386 + if (!capable(CAP_LINUX_IMMUTABLE))
23388 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23391 + ret = user_path_walk_link(vc_data.name, &nd);
23393 + ret = __vc_set_iattr(nd.dentry,
23394 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23395 + path_release(&nd);
23398 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23403 +#ifdef CONFIG_COMPAT
23405 +int vc_set_iattr_x32(void __user *data)
23407 + struct nameidata nd;
23408 + struct vcmd_ctx_iattr_v1_x32 vc_data;
23411 + if (!capable(CAP_LINUX_IMMUTABLE))
23413 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23416 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
23418 + ret = __vc_set_iattr(nd.dentry,
23419 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23420 + path_release(&nd);
23423 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23428 +#endif /* CONFIG_COMPAT */
23430 +int vc_fset_iattr(uint32_t fd, void __user *data)
23432 + struct file *filp;
23433 + struct vcmd_ctx_fiattr_v0 vc_data;
23436 + if (!capable(CAP_LINUX_IMMUTABLE))
23438 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23442 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
23445 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
23446 + &vc_data.flags, &vc_data.mask);
23450 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23456 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
23458 +static match_table_t tokens = {
23459 + {Opt_notagcheck, "notagcheck"},
23460 +#ifdef CONFIG_PROPAGATE
23461 + {Opt_notag, "notag"},
23462 + {Opt_tag, "tag"},
23463 + {Opt_tagid, "tagid=%u"},
23469 +static void __dx_parse_remove(char *string, char *opt)
23471 + char *p = strstr(string, opt);
23475 + while (*q != '\0' && *q != ',')
23485 +int __dx_parse_tag(char *string, tag_t *tag, int remove)
23487 + substring_t args[MAX_OPT_ARGS];
23488 + int token, option = 0;
23493 + token = match_token(string, tokens, args);
23495 + vxdprintk(VXD_CBIT(tag, 7),
23496 + "dx_parse_tag(»%s«): %d:#%d",
23497 + string, token, option);
23504 + __dx_parse_remove(string, "tag");
23505 + return MNT_TAGID;
23508 + __dx_parse_remove(string, "notag");
23509 + return MNT_NOTAG;
23510 + case Opt_notagcheck:
23512 + __dx_parse_remove(string, "notagcheck");
23513 + return MNT_NOTAGCHECK;
23515 + if (tag && !match_int(args, &option))
23518 + __dx_parse_remove(string, "tagid");
23519 + return MNT_TAGID;
23524 +int dx_parse_tag(char *string, tag_t *tag, int remove)
23526 + int retval, flags = 0;
23528 + while ((retval = __dx_parse_tag(string, tag, remove)))
23533 +#ifdef CONFIG_PROPAGATE
23535 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
23537 + tag_t new_tag = 0;
23538 + struct vfsmount *mnt;
23547 + propagate = (mnt->mnt_flags & MNT_TAGID);
23549 + new_tag = mnt->mnt_tag;
23551 + vxdprintk(VXD_CBIT(tag, 7),
23552 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
23553 + inode, inode->i_ino, inode->i_tag,
23554 + new_tag, (propagate) ? 1 : 0);
23557 + inode->i_tag = new_tag;
23560 +#include <linux/module.h>
23562 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
23564 +#endif /* CONFIG_PROPAGATE */
23566 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/limit.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit.c
23567 --- linux-2.6.22.10/kernel/vserver/limit.c 1970-01-01 01:00:00 +0100
23568 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit.c 2007-08-19 00:08:19 +0200
23571 + * linux/kernel/vserver/limit.c
23573 + * Virtual Server: Context Limits
23575 + * Copyright (C) 2004-2007 Herbert Pötzl
23577 + * V0.01 broken out from vcontext V0.05
23578 + * V0.02 changed vcmds to vxi arg
23582 +#include <linux/module.h>
23583 +#include <linux/vs_limit.h>
23584 +#include <linux/vserver/limit.h>
23585 +#include <linux/vserver/limit_cmd.h>
23587 +#include <asm/uaccess.h>
23590 +const char *vlimit_name[NUM_LIMITS] = {
23591 + [RLIMIT_CPU] = "CPU",
23592 + [RLIMIT_RSS] = "RSS",
23593 + [RLIMIT_NPROC] = "NPROC",
23594 + [RLIMIT_NOFILE] = "NOFILE",
23595 + [RLIMIT_MEMLOCK] = "VML",
23596 + [RLIMIT_AS] = "VM",
23597 + [RLIMIT_LOCKS] = "LOCKS",
23598 + [RLIMIT_SIGPENDING] = "SIGP",
23599 + [RLIMIT_MSGQUEUE] = "MSGQ",
23601 + [VLIMIT_NSOCK] = "NSOCK",
23602 + [VLIMIT_OPENFD] = "OPENFD",
23603 + [VLIMIT_ANON] = "ANON",
23604 + [VLIMIT_SHMEM] = "SHMEM",
23605 + [VLIMIT_DENTRY] = "DENTRY",
23608 +EXPORT_SYMBOL_GPL(vlimit_name);
23610 +#define MASK_ENTRY(x) (1 << (x))
23612 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
23615 + , /* softlimit */
23616 + MASK_ENTRY( RLIMIT_RSS ) |
23617 + MASK_ENTRY( VLIMIT_ANON ) |
23620 + MASK_ENTRY( RLIMIT_RSS ) |
23621 + MASK_ENTRY( RLIMIT_NPROC ) |
23622 + MASK_ENTRY( RLIMIT_NOFILE ) |
23623 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
23624 + MASK_ENTRY( RLIMIT_AS ) |
23625 + MASK_ENTRY( RLIMIT_LOCKS ) |
23626 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
23628 + MASK_ENTRY( VLIMIT_NSOCK ) |
23629 + MASK_ENTRY( VLIMIT_OPENFD ) |
23630 + MASK_ENTRY( VLIMIT_ANON ) |
23631 + MASK_ENTRY( VLIMIT_SHMEM ) |
23632 + MASK_ENTRY( VLIMIT_DENTRY ) |
23635 + /* accounting only */
23636 +uint32_t account_mask =
23637 + MASK_ENTRY( VLIMIT_SEMARY ) |
23638 + MASK_ENTRY( VLIMIT_NSEMS ) |
23639 + MASK_ENTRY( VLIMIT_MAPPED ) |
23643 +static int is_valid_vlimit(int id)
23645 + uint32_t mask = vlimit_mask.minimum |
23646 + vlimit_mask.softlimit | vlimit_mask.maximum;
23647 + return mask & (1 << id);
23650 +static int is_accounted_vlimit(int id)
23652 + if (is_valid_vlimit(id))
23654 + return account_mask & (1 << id);
23658 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
23660 + rlim_t limit = __rlim_soft(&vxi->limit, id);
23661 + return VX_VLIM(limit);
23664 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
23666 + rlim_t limit = __rlim_hard(&vxi->limit, id);
23667 + return VX_VLIM(limit);
23670 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
23671 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
23673 + if (!is_valid_vlimit(id))
23677 + *minimum = CRLIM_UNSET;
23679 + *softlimit = vc_get_soft(vxi, id);
23681 + *maximum = vc_get_hard(vxi, id);
23685 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
23687 + struct vcmd_ctx_rlimit_v0 vc_data;
23690 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23693 + ret = do_get_rlimit(vxi, vc_data.id,
23694 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
23698 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23703 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
23704 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
23706 + if (!is_valid_vlimit(id))
23709 + if (maximum != CRLIM_KEEP)
23710 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
23711 + if (softlimit != CRLIM_KEEP)
23712 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
23714 + /* clamp soft limit */
23715 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
23716 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
23721 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
23723 + struct vcmd_ctx_rlimit_v0 vc_data;
23725 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23728 + return do_set_rlimit(vxi, vc_data.id,
23729 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
23732 +#ifdef CONFIG_IA32_EMULATION
23734 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
23736 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
23738 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23741 + return do_set_rlimit(vxi, vc_data.id,
23742 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
23745 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
23747 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
23750 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23753 + ret = do_get_rlimit(vxi, vc_data.id,
23754 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
23758 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23763 +#endif /* CONFIG_IA32_EMULATION */
23766 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
23768 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
23774 +static inline void vx_reset_minmax(struct _vx_limit *limit)
23779 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23780 + value = __rlim_get(limit, lim);
23781 + __rlim_rmax(limit, lim) = value;
23782 + __rlim_rmin(limit, lim) = value;
23787 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
23789 + vx_reset_minmax(&vxi->limit);
23794 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
23796 + struct vcmd_rlimit_stat_v0 vc_data;
23797 + struct _vx_limit *limit = &vxi->limit;
23800 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23804 + if (!is_accounted_vlimit(id))
23807 + vx_limit_fixup(limit, id);
23808 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
23809 + vc_data.value = __rlim_get(limit, id);
23810 + vc_data.minimum = __rlim_rmin(limit, id);
23811 + vc_data.maximum = __rlim_rmax(limit, id);
23813 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23819 +void vx_vsi_meminfo(struct sysinfo *val)
23821 + struct vx_info *vxi = current->vx_info;
23822 + unsigned long totalram, freeram;
23825 + /* we blindly accept the max */
23826 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23827 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
23829 + /* total minus used equals free */
23830 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23831 + freeram = (v < totalram) ? totalram - v : 0;
23833 + val->totalram = totalram;
23834 + val->freeram = freeram;
23835 + val->bufferram = 0;
23836 + val->totalhigh = 0;
23837 + val->freehigh = 0;
23841 +void vx_vsi_swapinfo(struct sysinfo *val)
23843 + struct vx_info *vxi = current->vx_info;
23844 + unsigned long totalswap, freeswap;
23847 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23848 + if (v == RLIM_INFINITY) {
23849 + val->freeswap = val->totalswap;
23853 + /* we blindly accept the max */
23854 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
23855 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
23857 + /* currently 'used' swap */
23858 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23859 + w -= (w > v) ? v : w;
23861 + /* total minus used equals free */
23862 + freeswap = (w < totalswap) ? totalswap - w : 0;
23864 + val->totalswap = totalswap;
23865 + val->freeswap = freeswap;
23870 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
23872 + struct vx_info *vxi = mm->mm_vx_info;
23873 + unsigned long points;
23879 + points = vxi->vx_badness_bias;
23881 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23882 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23883 + points += (v > w) ? (v - w) : 0;
23888 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/limit_init.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit_init.h
23889 --- linux-2.6.22.10/kernel/vserver/limit_init.h 1970-01-01 01:00:00 +0100
23890 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit_init.h 2007-10-25 17:05:55 +0200
23894 +static inline void vx_info_init_limit(struct _vx_limit *limit)
23898 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23899 + __rlim_soft(limit, lim) = RLIM_INFINITY;
23900 + __rlim_hard(limit, lim) = RLIM_INFINITY;
23901 + __rlim_set(limit, lim, 0);
23902 + atomic_set(&__rlim_lhit(limit, lim), 0);
23903 + __rlim_rmin(limit, lim) = 0;
23904 + __rlim_rmax(limit, lim) = 0;
23908 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
23910 +#ifdef CONFIG_VSERVER_WARN
23914 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23915 + if ((1 << lim) & VLIM_NOCHECK)
23917 + value = __rlim_get(limit, lim);
23918 + vxwprintk_xid(value,
23919 + "!!! limit: %p[%s,%d] = %ld on exit.",
23920 + limit, vlimit_name[lim], lim, (long)value);
23925 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/limit_proc.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit_proc.h
23926 --- linux-2.6.22.10/kernel/vserver/limit_proc.h 1970-01-01 01:00:00 +0100
23927 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit_proc.h 2007-08-05 20:53:13 +0200
23929 +#ifndef _VX_LIMIT_PROC_H
23930 +#define _VX_LIMIT_PROC_H
23932 +#include <linux/vserver/limit_int.h>
23935 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
23936 +#define VX_LIMIT_TOP \
23937 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
23939 +#define VX_LIMIT_ARG(r) \
23940 + (unsigned long)__rlim_get(limit, r), \
23941 + (unsigned long)__rlim_rmin(limit, r), \
23942 + (unsigned long)__rlim_rmax(limit, r), \
23943 + VX_VLIM(__rlim_soft(limit, r)), \
23944 + VX_VLIM(__rlim_hard(limit, r)), \
23945 + atomic_read(&__rlim_lhit(limit, r))
23947 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
23949 + vx_limit_fixup(limit, -1);
23950 + return sprintf(buffer, VX_LIMIT_TOP
23951 + "PROC" VX_LIMIT_FMT
23952 + "VM" VX_LIMIT_FMT
23953 + "VML" VX_LIMIT_FMT
23954 + "RSS" VX_LIMIT_FMT
23955 + "ANON" VX_LIMIT_FMT
23956 + "RMAP" VX_LIMIT_FMT
23957 + "FILES" VX_LIMIT_FMT
23958 + "OFD" VX_LIMIT_FMT
23959 + "LOCKS" VX_LIMIT_FMT
23960 + "SOCK" VX_LIMIT_FMT
23961 + "MSGQ" VX_LIMIT_FMT
23962 + "SHM" VX_LIMIT_FMT
23963 + "SEMA" VX_LIMIT_FMT
23964 + "SEMS" VX_LIMIT_FMT
23965 + "DENT" VX_LIMIT_FMT,
23966 + VX_LIMIT_ARG(RLIMIT_NPROC),
23967 + VX_LIMIT_ARG(RLIMIT_AS),
23968 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
23969 + VX_LIMIT_ARG(RLIMIT_RSS),
23970 + VX_LIMIT_ARG(VLIMIT_ANON),
23971 + VX_LIMIT_ARG(VLIMIT_MAPPED),
23972 + VX_LIMIT_ARG(RLIMIT_NOFILE),
23973 + VX_LIMIT_ARG(VLIMIT_OPENFD),
23974 + VX_LIMIT_ARG(RLIMIT_LOCKS),
23975 + VX_LIMIT_ARG(VLIMIT_NSOCK),
23976 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
23977 + VX_LIMIT_ARG(VLIMIT_SHMEM),
23978 + VX_LIMIT_ARG(VLIMIT_SEMARY),
23979 + VX_LIMIT_ARG(VLIMIT_NSEMS),
23980 + VX_LIMIT_ARG(VLIMIT_DENTRY));
23983 +#endif /* _VX_LIMIT_PROC_H */
23986 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/monitor.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/monitor.c
23987 --- linux-2.6.22.10/kernel/vserver/monitor.c 1970-01-01 01:00:00 +0100
23988 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/monitor.c 2007-08-15 23:18:20 +0200
23991 + * kernel/vserver/monitor.c
23993 + * Virtual Context Scheduler Monitor
23995 + * Copyright (C) 2006-2007 Herbert Pötzl
23997 + * V0.01 basic design
24001 +#include <linux/module.h>
24002 +#include <linux/jiffies.h>
24003 +#include <asm/uaccess.h>
24004 +#include <asm/atomic.h>
24006 +#include <linux/vserver/monitor.h>
24007 +#include <linux/vserver/debug_cmd.h>
24010 +#ifdef CONFIG_VSERVER_MONITOR
24011 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
24013 +#define VXM_SIZE 64
24016 +struct _vx_monitor {
24017 + unsigned int counter;
24019 + struct _vx_mon_entry entry[VXM_SIZE+1];
24023 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
24025 +unsigned volatile int vxm_active = 1;
24027 +static atomic_t sequence = ATOMIC_INIT(0);
24032 + * requires disabled preemption */
24034 +struct _vx_mon_entry *vxm_advance(int cpu)
24036 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
24037 + struct _vx_mon_entry *entry;
24038 + unsigned int index;
24040 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
24041 + entry = &mon->entry[index];
24043 + entry->ev.seq = atomic_inc_return(&sequence);
24044 + entry->ev.jif = jiffies;
24048 +EXPORT_SYMBOL_GPL(vxm_advance);
24051 +int do_read_monitor(struct __user _vx_mon_entry *data,
24052 + int cpu, uint32_t *index, uint32_t *count)
24054 + int pos, ret = 0;
24055 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
24056 + int end = mon->counter;
24057 + int start = end - VXM_SIZE + 2;
24058 + int idx = *index;
24060 + /* special case: get current pos */
24066 + /* have we lost some data? */
24070 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
24071 + struct _vx_mon_entry *entry =
24072 + &mon->entry[idx % VXM_SIZE];
24074 + /* send entry to userspace */
24075 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
24079 + /* save new index and count */
24082 + return ret ? ret : (*index < end);
24085 +int vc_read_monitor(uint32_t id, void __user *data)
24087 + struct vcmd_read_monitor_v0 vc_data;
24090 + if (id >= NR_CPUS)
24093 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24096 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
24097 + id, &vc_data.index, &vc_data.count);
24099 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24104 +#ifdef CONFIG_COMPAT
24106 +int vc_read_monitor_x32(uint32_t id, void __user *data)
24108 + struct vcmd_read_monitor_v0_x32 vc_data;
24111 + if (id >= NR_CPUS)
24114 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24117 + ret = do_read_monitor((struct __user _vx_mon_entry *)
24118 + compat_ptr(vc_data.data_ptr),
24119 + id, &vc_data.index, &vc_data.count);
24121 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24126 +#endif /* CONFIG_COMPAT */
24128 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/network.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/network.c
24129 --- linux-2.6.22.10/kernel/vserver/network.c 1970-01-01 01:00:00 +0100
24130 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/network.c 2007-10-05 14:54:36 +0200
24133 + * linux/kernel/vserver/network.c
24135 + * Virtual Server: Network Support
24137 + * Copyright (C) 2003-2007 Herbert Pötzl
24139 + * V0.01 broken out from vcontext V0.05
24140 + * V0.02 cleaned up implementation
24141 + * V0.03 added equiv nx commands
24142 + * V0.04 switch to RCU based hash
24143 + * V0.05 and back to locking again
24144 + * V0.06 changed vcmds to nxi arg
24145 + * V0.07 have __create claim() the nxi
24149 +#include <linux/err.h>
24150 +#include <linux/slab.h>
24151 +#include <linux/rcupdate.h>
24153 +#include <linux/vs_network.h>
24154 +#include <linux/vserver/network_cmd.h>
24157 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
24158 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
24160 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
24161 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
24164 +static int __init init_network(void)
24166 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
24167 + sizeof(struct nx_addr_v4), 0, SLAB_PANIC, NULL, NULL);
24168 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
24169 + sizeof(struct nx_addr_v6), 0, SLAB_PANIC, NULL, NULL);
24174 +/* __alloc_nx_addr_v4() */
24176 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
24178 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
24179 + nx_addr_v4_cachep, GFP_KERNEL);
24181 + if (!IS_ERR(nxa))
24182 + memset(nxa, 0, sizeof(*nxa));
24186 +/* __dealloc_nx_addr_v4() */
24188 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
24190 + kmem_cache_free(nx_addr_v4_cachep, nxa);
24193 +/* __dealloc_nx_addr_v4_all() */
24195 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
24198 + struct nx_addr_v4 *next = nxa->next;
24200 + __dealloc_nx_addr_v4(nxa);
24206 +#ifdef CONFIG_IPV6
24208 +/* __alloc_nx_addr_v6() */
24210 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
24212 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
24213 + nx_addr_v6_cachep, GFP_KERNEL);
24215 + if (!IS_ERR(nxa))
24216 + memset(nxa, 0, sizeof(*nxa));
24220 +/* __dealloc_nx_addr_v6() */
24222 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
24224 + kmem_cache_free(nx_addr_v6_cachep, nxa);
24227 +/* __dealloc_nx_addr_v6_all() */
24229 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
24232 + struct nx_addr_v6 *next = nxa->next;
24234 + __dealloc_nx_addr_v6(nxa);
24239 +#endif /* CONFIG_IPV6 */
24242 +/* __alloc_nx_info()
24244 + * allocate an initialized nx_info struct
24245 + * doesn't make it visible (hash) */
24247 +static struct nx_info *__alloc_nx_info(nid_t nid)
24249 + struct nx_info *new = NULL;
24251 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
24253 + /* would this benefit from a slab cache? */
24254 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
24258 + memset(new, 0, sizeof(struct nx_info));
24259 + new->nx_id = nid;
24260 + INIT_HLIST_NODE(&new->nx_hlist);
24261 + atomic_set(&new->nx_usecnt, 0);
24262 + atomic_set(&new->nx_tasks, 0);
24263 + new->nx_state = 0;
24265 + new->nx_flags = NXF_INIT_SET;
24267 + /* rest of init goes here */
24269 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
24270 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
24272 + vxdprintk(VXD_CBIT(nid, 0),
24273 + "alloc_nx_info(%d) = %p", nid, new);
24274 + atomic_inc(&nx_global_ctotal);
24278 +/* __dealloc_nx_info()
24280 + * final disposal of nx_info */
24282 +static void __dealloc_nx_info(struct nx_info *nxi)
24284 + vxdprintk(VXD_CBIT(nid, 0),
24285 + "dealloc_nx_info(%p)", nxi);
24287 + nxi->nx_hlist.next = LIST_POISON1;
24290 + BUG_ON(atomic_read(&nxi->nx_usecnt));
24291 + BUG_ON(atomic_read(&nxi->nx_tasks));
24293 + __dealloc_nx_addr_v4_all(nxi->v4.next);
24295 + nxi->nx_state |= NXS_RELEASED;
24297 + atomic_dec(&nx_global_ctotal);
24300 +static void __shutdown_nx_info(struct nx_info *nxi)
24302 + nxi->nx_state |= NXS_SHUTDOWN;
24303 + vs_net_change(nxi, VSC_NETDOWN);
24306 +/* exported stuff */
24308 +void free_nx_info(struct nx_info *nxi)
24310 + /* context shutdown is mandatory */
24311 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
24313 + /* context must not be hashed */
24314 + BUG_ON(nxi->nx_state & NXS_HASHED);
24316 + BUG_ON(atomic_read(&nxi->nx_usecnt));
24317 + BUG_ON(atomic_read(&nxi->nx_tasks));
24319 + __dealloc_nx_info(nxi);
24323 +void __nx_set_lback(struct nx_info *nxi)
24325 + int nid = nxi->nx_id;
24326 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
24328 + nxi->v4_lback.s_addr = lback;
24331 +extern int __nx_inet_add_lback(__be32 addr);
24332 +extern int __nx_inet_del_lback(__be32 addr);
24335 +/* hash table for nx_info hash */
24337 +#define NX_HASH_SIZE 13
24339 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
24341 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
24344 +static inline unsigned int __hashval(nid_t nid)
24346 + return (nid % NX_HASH_SIZE);
24351 +/* __hash_nx_info()
24353 + * add the nxi to the global hash table
24354 + * requires the hash_lock to be held */
24356 +static inline void __hash_nx_info(struct nx_info *nxi)
24358 + struct hlist_head *head;
24360 + vxd_assert_lock(&nx_info_hash_lock);
24361 + vxdprintk(VXD_CBIT(nid, 4),
24362 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
24364 + /* context must not be hashed */
24365 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
24367 + nxi->nx_state |= NXS_HASHED;
24368 + head = &nx_info_hash[__hashval(nxi->nx_id)];
24369 + hlist_add_head(&nxi->nx_hlist, head);
24370 + atomic_inc(&nx_global_cactive);
24373 +/* __unhash_nx_info()
24375 + * remove the nxi from the global hash table
24376 + * requires the hash_lock to be held */
24378 +static inline void __unhash_nx_info(struct nx_info *nxi)
24380 + vxd_assert_lock(&nx_info_hash_lock);
24381 + vxdprintk(VXD_CBIT(nid, 4),
24382 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
24383 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
24385 + /* context must be hashed */
24386 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
24387 + /* but without tasks */
24388 + BUG_ON(atomic_read(&nxi->nx_tasks));
24390 + nxi->nx_state &= ~NXS_HASHED;
24391 + hlist_del(&nxi->nx_hlist);
24392 + atomic_dec(&nx_global_cactive);
24396 +/* __lookup_nx_info()
24398 + * requires the hash_lock to be held
24399 + * doesn't increment the nx_refcnt */
24401 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
24403 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
24404 + struct hlist_node *pos;
24405 + struct nx_info *nxi;
24407 + vxd_assert_lock(&nx_info_hash_lock);
24408 + hlist_for_each(pos, head) {
24409 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
24411 + if (nxi->nx_id == nid)
24416 + vxdprintk(VXD_CBIT(nid, 0),
24417 + "__lookup_nx_info(#%u): %p[#%u]",
24418 + nid, nxi, nxi ? nxi->nx_id : 0);
24423 +/* __create_nx_info()
24425 + * create the requested context
24426 + * get(), claim() and hash it */
24428 +static struct nx_info *__create_nx_info(int id)
24430 + struct nx_info *new, *nxi = NULL;
24432 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
24434 + if (!(new = __alloc_nx_info(id)))
24435 + return ERR_PTR(-ENOMEM);
24437 + /* required to make dynamic xids unique */
24438 + spin_lock(&nx_info_hash_lock);
24440 + /* static context requested */
24441 + if ((nxi = __lookup_nx_info(id))) {
24442 + vxdprintk(VXD_CBIT(nid, 0),
24443 + "create_nx_info(%d) = %p (already there)", id, nxi);
24444 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
24445 + nxi = ERR_PTR(-EBUSY);
24447 + nxi = ERR_PTR(-EEXIST);
24450 + /* new context */
24451 + vxdprintk(VXD_CBIT(nid, 0),
24452 + "create_nx_info(%d) = %p (new)", id, new);
24453 + claim_nx_info(new, NULL);
24454 + __nx_set_lback(new);
24455 + __hash_nx_info(get_nx_info(new));
24456 + nxi = new, new = NULL;
24459 + spin_unlock(&nx_info_hash_lock);
24461 + __dealloc_nx_info(new);
24467 +/* exported stuff */
24470 +void unhash_nx_info(struct nx_info *nxi)
24472 + __shutdown_nx_info(nxi);
24473 + spin_lock(&nx_info_hash_lock);
24474 + __unhash_nx_info(nxi);
24475 + spin_unlock(&nx_info_hash_lock);
24478 +/* lookup_nx_info()
24480 + * search for a nx_info and get() it
24481 + * negative id means current */
24483 +struct nx_info *lookup_nx_info(int id)
24485 + struct nx_info *nxi = NULL;
24488 + nxi = get_nx_info(current->nx_info);
24489 + } else if (id > 1) {
24490 + spin_lock(&nx_info_hash_lock);
24491 + nxi = get_nx_info(__lookup_nx_info(id));
24492 + spin_unlock(&nx_info_hash_lock);
24497 +/* nid_is_hashed()
24499 + * verify that nid is still hashed */
24501 +int nid_is_hashed(nid_t nid)
24505 + spin_lock(&nx_info_hash_lock);
24506 + hashed = (__lookup_nx_info(nid) != NULL);
24507 + spin_unlock(&nx_info_hash_lock);
24512 +#ifdef CONFIG_PROC_FS
24516 + * get a subset of hashed nids for proc
24517 + * assumes size is at least one */
24519 +int get_nid_list(int index, unsigned int *nids, int size)
24521 + int hindex, nr_nids = 0;
24523 + /* only show current and children */
24524 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
24527 + nids[nr_nids] = nx_current_nid();
24531 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
24532 + struct hlist_head *head = &nx_info_hash[hindex];
24533 + struct hlist_node *pos;
24535 + spin_lock(&nx_info_hash_lock);
24536 + hlist_for_each(pos, head) {
24537 + struct nx_info *nxi;
24542 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
24543 + nids[nr_nids] = nxi->nx_id;
24544 + if (++nr_nids >= size) {
24545 + spin_unlock(&nx_info_hash_lock);
24549 + /* keep the lock time short */
24550 + spin_unlock(&nx_info_hash_lock);
24559 + * migrate task to new network
24560 + * gets nxi, puts old_nxi on change
24563 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
24565 + struct nx_info *old_nxi;
24571 + vxdprintk(VXD_CBIT(nid, 5),
24572 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
24573 + p, nxi, nxi->nx_id,
24574 + atomic_read(&nxi->nx_usecnt),
24575 + atomic_read(&nxi->nx_tasks));
24577 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
24578 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
24581 + if (nx_info_state(nxi, NXS_SHUTDOWN))
24584 + /* maybe disallow this completely? */
24585 + old_nxi = task_get_nx_info(p);
24586 + if (old_nxi == nxi)
24591 + clr_nx_info(&p->nx_info);
24592 + claim_nx_info(nxi, p);
24593 + set_nx_info(&p->nx_info, nxi);
24594 + p->nid = nxi->nx_id;
24597 + vxdprintk(VXD_CBIT(nid, 5),
24598 + "moved task %p into nxi:%p[#%d]",
24599 + p, nxi, nxi->nx_id);
24602 + release_nx_info(old_nxi, p);
24605 + put_nx_info(old_nxi);
24610 +void nx_set_persistent(struct nx_info *nxi)
24612 + vxdprintk(VXD_CBIT(nid, 6),
24613 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
24615 + get_nx_info(nxi);
24616 + claim_nx_info(nxi, NULL);
24619 +void nx_clear_persistent(struct nx_info *nxi)
24621 + vxdprintk(VXD_CBIT(nid, 6),
24622 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
24624 + release_nx_info(nxi, NULL);
24625 + put_nx_info(nxi);
24628 +void nx_update_persistent(struct nx_info *nxi)
24630 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
24631 + nx_set_persistent(nxi);
24633 + nx_clear_persistent(nxi);
24636 +/* vserver syscall commands below here */
24638 +/* taks nid and nx_info functions */
24640 +#include <asm/uaccess.h>
24643 +int vc_task_nid(uint32_t id)
24648 + struct task_struct *tsk;
24650 + read_lock(&tasklist_lock);
24651 + tsk = find_task_by_real_pid(id);
24652 + nid = (tsk) ? tsk->nid : -ESRCH;
24653 + read_unlock(&tasklist_lock);
24655 + nid = nx_current_nid();
24660 +int vc_nx_info(struct nx_info *nxi, void __user *data)
24662 + struct vcmd_nx_info_v0 vc_data;
24664 + vc_data.nid = nxi->nx_id;
24666 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24672 +/* network functions */
24674 +int vc_net_create(uint32_t nid, void __user *data)
24676 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
24677 + struct nx_info *new_nxi;
24680 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24683 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
24686 + new_nxi = __create_nx_info(nid);
24687 + if (IS_ERR(new_nxi))
24688 + return PTR_ERR(new_nxi);
24690 + /* initial flags */
24691 + new_nxi->nx_flags = vc_data.flagword;
24694 + if (vs_net_change(new_nxi, VSC_NETUP))
24697 + ret = nx_migrate_task(current, new_nxi);
24701 + /* return context id on success */
24702 + ret = new_nxi->nx_id;
24704 + /* get a reference for persistent contexts */
24705 + if ((vc_data.flagword & NXF_PERSISTENT))
24706 + nx_set_persistent(new_nxi);
24708 + release_nx_info(new_nxi, NULL);
24709 + put_nx_info(new_nxi);
24714 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
24716 + return nx_migrate_task(current, nxi);
24721 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
24722 + uint16_t type, uint16_t flags)
24724 + struct nx_addr_v4 *nxa = &nxi->v4;
24726 + if (NX_IPV4(nxi)) {
24727 + /* locate last entry */
24728 + for (; nxa->next; nxa = nxa->next);
24729 + nxa->next = __alloc_nx_addr_v4();
24733 + return PTR_ERR(nxa);
24736 + if (nxi->v4.next)
24737 + /* remove single ip for ip list */
24738 + nxi->nx_flags &= ~NXF_SINGLE_IP;
24740 + nxa->ip[0].s_addr = ip;
24741 + nxa->ip[1].s_addr = ip2;
24742 + nxa->mask.s_addr = mask;
24743 + nxa->type = type;
24744 + nxa->flags = flags;
24749 +int vc_net_add(struct nx_info *nxi, void __user *data)
24751 + struct vcmd_net_addr_v0 vc_data;
24752 + int index, ret = 0;
24754 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24757 + switch (vc_data.type) {
24758 + case NXA_TYPE_IPV4:
24759 + if ((vc_data.count < 1) || (vc_data.count > 4))
24763 + while (index < vc_data.count) {
24764 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
24765 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
24773 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
24774 + nxi->v4_bcast = vc_data.ip[0];
24778 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
24779 + nxi->v4_lback = vc_data.ip[0];
24790 +int vc_net_remove(struct nx_info *nxi, void __user *data)
24792 + struct vcmd_net_addr_v0 vc_data;
24794 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24797 + switch (vc_data.type) {
24798 + case NXA_TYPE_ANY:
24799 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
24800 + memset(&nxi->v4, 0, sizeof(nxi->v4));
24810 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
24812 + struct vcmd_net_addr_ipv4_v1 vc_data;
24814 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24817 + switch (vc_data.type) {
24818 + case NXA_TYPE_ADDR:
24819 + case NXA_TYPE_RANGE:
24820 + case NXA_TYPE_MASK:
24821 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
24822 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
24824 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
24825 + nxi->v4_bcast = vc_data.ip;
24828 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
24829 + nxi->v4_lback = vc_data.ip;
24838 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
24840 + struct vcmd_net_addr_ipv4_v1 vc_data;
24842 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24845 + switch (vc_data.type) {
24846 +/* case NXA_TYPE_ADDR:
24849 + case NXA_TYPE_ANY:
24850 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
24851 + memset(&nxi->v4, 0, sizeof(nxi->v4));
24861 +#ifdef CONFIG_IPV6
24863 +int do_add_v6_addr(struct nx_info *nxi,
24864 + struct in6_addr *ip, struct in6_addr *mask,
24865 + uint32_t prefix, uint16_t type, uint16_t flags)
24867 + struct nx_addr_v6 *nxa = &nxi->v6;
24869 + if (NX_IPV6(nxi)) {
24870 + /* locate last entry */
24871 + for (; nxa->next; nxa = nxa->next);
24872 + nxa->next = __alloc_nx_addr_v6();
24876 + return PTR_ERR(nxa);
24880 + nxa->mask = *mask;
24881 + nxa->prefix = prefix;
24882 + nxa->type = type;
24883 + nxa->flags = flags;
24888 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
24890 + struct vcmd_net_addr_ipv6_v1 vc_data;
24892 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24895 + switch (vc_data.type) {
24896 + case NXA_TYPE_ADDR:
24897 + case NXA_TYPE_MASK:
24898 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
24899 + vc_data.prefix, vc_data.type, vc_data.flags);
24906 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
24908 + struct vcmd_net_addr_ipv6_v1 vc_data;
24910 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24913 + switch (vc_data.type) {
24914 + case NXA_TYPE_ANY:
24915 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
24916 + memset(&nxi->v6, 0, sizeof(nxi->v6));
24925 +#endif /* CONFIG_IPV6 */
24928 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
24930 + struct vcmd_net_flags_v0 vc_data;
24932 + vc_data.flagword = nxi->nx_flags;
24934 + /* special STATE flag handling */
24935 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
24937 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24942 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
24944 + struct vcmd_net_flags_v0 vc_data;
24945 + uint64_t mask, trigger;
24947 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24950 + /* special STATE flag handling */
24951 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
24952 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
24954 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
24955 + vc_data.flagword, mask);
24956 + if (trigger & NXF_PERSISTENT)
24957 + nx_update_persistent(nxi);
24962 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
24964 + struct vcmd_net_caps_v0 vc_data;
24966 + vc_data.ncaps = nxi->nx_ncaps;
24967 + vc_data.cmask = ~0ULL;
24969 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24974 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
24976 + struct vcmd_net_caps_v0 vc_data;
24978 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24981 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
24982 + vc_data.ncaps, vc_data.cmask);
24987 +#include <linux/module.h>
24989 +module_init(init_network);
24991 +EXPORT_SYMBOL_GPL(free_nx_info);
24992 +EXPORT_SYMBOL_GPL(unhash_nx_info);
24994 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/proc.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/proc.c
24995 --- linux-2.6.22.10/kernel/vserver/proc.c 1970-01-01 01:00:00 +0100
24996 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/proc.c 2007-10-05 14:54:36 +0200
24999 + * linux/kernel/vserver/proc.c
25001 + * Virtual Context Support
25003 + * Copyright (C) 2003-2007 Herbert Pötzl
25005 + * V0.01 basic structure
25006 + * V0.02 adaptation vs1.3.0
25007 + * V0.03 proc permissions
25008 + * V0.04 locking/generic
25009 + * V0.05 next generation procfs
25010 + * V0.06 inode validation
25011 + * V0.07 generic rewrite vid
25012 + * V0.08 remove inode type
25016 +#include <linux/proc_fs.h>
25017 +#include <asm/unistd.h>
25019 +#include <linux/vs_context.h>
25020 +#include <linux/vs_network.h>
25021 +#include <linux/vs_cvirt.h>
25022 +#include <linux/vs_inet.h>
25023 +#include <linux/vs_inet6.h>
25025 +#include <linux/vserver/global.h>
25027 +#include "cvirt_proc.h"
25028 +#include "cacct_proc.h"
25029 +#include "limit_proc.h"
25030 +#include "sched_proc.h"
25031 +#include "vci_config.h"
25033 +static struct proc_dir_entry *proc_virtual;
25035 +static struct proc_dir_entry *proc_virtnet;
25038 +/* first the actual feeds */
25041 +static int proc_vci(char *buffer)
25043 + return sprintf(buffer,
25044 + "VCIVersion:\t%04x:%04x\n"
25045 + "VCISyscall:\t%d\n"
25046 + "VCIKernel:\t%08x\n",
25047 + VCI_VERSION >> 16,
25048 + VCI_VERSION & 0xFFFF,
25050 + vci_kernel_config());
25053 +static int proc_virtual_info(char *buffer)
25055 + return proc_vci(buffer);
25058 +static int proc_virtual_status(char *buffer)
25060 + return sprintf(buffer,
25062 + "#CActive:\t%d\n"
25063 + "#NSProxy:\t%d\t%d %d %d %d\n",
25064 + atomic_read(&vx_global_ctotal),
25065 + atomic_read(&vx_global_cactive),
25066 + atomic_read(&vs_global_nsproxy),
25067 + atomic_read(&vs_global_fs),
25068 + atomic_read(&vs_global_mnt_ns),
25069 + atomic_read(&vs_global_uts_ns),
25070 + atomic_read(&vs_global_ipc_ns));
25074 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
25078 + length = sprintf(buffer,
25086 + vxi->vx_badness_bias);
25090 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
25094 + length = sprintf(buffer,
25097 + "Flags:\t%016llx\n"
25098 + "BCaps:\t%016llx\n"
25099 + "CCaps:\t%016llx\n"
25100 + "Spaces:\t%08lx\n",
25101 + atomic_read(&vxi->vx_usecnt),
25102 + atomic_read(&vxi->vx_tasks),
25103 + (unsigned long long)vxi->vx_flags,
25104 + (unsigned long long)vxi->vx_bcaps,
25105 + (unsigned long long)vxi->vx_ccaps,
25110 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
25112 + return vx_info_proc_limit(&vxi->limit, buffer);
25115 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
25119 + length = vx_info_proc_sched(&vxi->sched, buffer);
25120 + for_each_online_cpu(cpu) {
25121 + length += vx_info_proc_sched_pc(
25122 + &vx_per_cpu(vxi, sched_pc, cpu),
25123 + buffer + length, cpu);
25128 +int proc_vxi_nsproxy(struct vx_info *vxi, char *buffer)
25130 + return vx_info_proc_nsproxy(vxi->vx_nsproxy, buffer);
25133 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
25137 + vx_update_load(vxi);
25138 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
25139 + for_each_online_cpu(cpu) {
25140 + length += vx_info_proc_cvirt_pc(
25141 + &vx_per_cpu(vxi, cvirt_pc, cpu),
25142 + buffer + length, cpu);
25147 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
25149 + return vx_info_proc_cacct(&vxi->cacct, buffer);
25153 +static int proc_virtnet_info(char *buffer)
25155 + return proc_vci(buffer);
25158 +static int proc_virtnet_status(char *buffer)
25160 + return sprintf(buffer,
25162 + "#CActive:\t%d\n",
25163 + atomic_read(&nx_global_ctotal),
25164 + atomic_read(&nx_global_cactive));
25167 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
25169 + struct nx_addr_v4 *v4a;
25170 +#ifdef CONFIG_IPV6
25171 + struct nx_addr_v6 *v6a;
25175 + length = sprintf(buffer,
25178 + "Bcast:\t" NIPQUAD_FMT "\n"
25179 + "Lback:\t" NIPQUAD_FMT "\n",
25182 + NIPQUAD(nxi->v4_bcast.s_addr),
25183 + NIPQUAD(nxi->v4_lback.s_addr));
25185 + if (!NX_IPV4(nxi))
25187 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
25188 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
25191 +#ifdef CONFIG_IPV6
25192 + if (!NX_IPV6(nxi))
25194 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
25195 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
25202 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
25206 + length = sprintf(buffer,
25209 + "Flags:\t%016llx\n"
25210 + "NCaps:\t%016llx\n",
25211 + atomic_read(&nxi->nx_usecnt),
25212 + atomic_read(&nxi->nx_tasks),
25213 + (unsigned long long)nxi->nx_flags,
25214 + (unsigned long long)nxi->nx_ncaps);
25220 +/* here the inode helpers */
25226 + struct inode_operations *iop;
25227 + struct file_operations *fop;
25228 + union proc_op op;
25231 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
25233 + struct inode *inode = new_inode(sb);
25238 + inode->i_mode = p->mode;
25240 + inode->i_op = p->iop;
25242 + inode->i_fop = p->fop;
25244 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
25245 + inode->i_flags |= S_IMMUTABLE;
25247 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
25249 + inode->i_uid = 0;
25250 + inode->i_gid = 0;
25251 + inode->i_tag = 0;
25256 +static struct dentry *vs_proc_instantiate(struct inode *dir,
25257 + struct dentry *dentry, int id, void *ptr)
25259 + struct vs_entry *p = ptr;
25260 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
25261 + struct dentry *error = ERR_PTR(-EINVAL);
25266 + PROC_I(inode)->op = p->op;
25267 + PROC_I(inode)->fd = id;
25268 + d_add(dentry, inode);
25276 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
25279 + * Fill a directory entry.
25281 + * If possible create the dcache entry and derive our inode number and
25282 + * file type from dcache entry.
25284 + * Since all of the proc inode numbers are dynamically generated, the inode
25285 + * numbers do not exist until the inode is cache. This means creating the
25286 + * the dcache entry in readdir is necessary to keep the inode numbers
25287 + * reported by readdir in sync with the inode numbers reported
25290 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
25291 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
25293 + struct dentry *child, *dir = filp->f_dentry;
25294 + struct inode *inode;
25295 + struct qstr qname;
25297 + unsigned type = DT_UNKNOWN;
25299 + qname.name = name;
25301 + qname.hash = full_name_hash(name, len);
25303 + child = d_lookup(dir, &qname);
25305 + struct dentry *new;
25306 + new = d_alloc(dir, &qname);
25308 + child = instantiate(dir->d_inode, new, id, ptr);
25315 + if (!child || IS_ERR(child) || !child->d_inode)
25316 + goto end_instantiate;
25317 + inode = child->d_inode;
25319 + ino = inode->i_ino;
25320 + type = inode->i_mode >> 12;
25325 + ino = find_inode_number(dir, &qname);
25328 + return filldir(dirent, name, len, filp->f_pos, ino, type);
25333 +/* get and revalidate vx_info/xid */
25336 +struct vx_info *get_proc_vx_info(struct inode *inode)
25338 + return lookup_vx_info(PROC_I(inode)->fd);
25341 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
25343 + struct inode *inode = dentry->d_inode;
25344 + xid_t xid = PROC_I(inode)->fd;
25346 + if (!xid || xid_is_hashed(xid))
25353 +/* get and revalidate nx_info/nid */
25355 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
25357 + struct inode *inode = dentry->d_inode;
25358 + nid_t nid = PROC_I(inode)->fd;
25360 + if (!nid || nid_is_hashed(nid))
25368 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
25370 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
25371 + size_t count, loff_t *ppos)
25373 + struct inode *inode = file->f_dentry->d_inode;
25374 + unsigned long page;
25375 + ssize_t length = 0;
25377 + if (count > PROC_BLOCK_SIZE)
25378 + count = PROC_BLOCK_SIZE;
25380 + /* fade that out as soon as stable */
25381 + WARN_ON(PROC_I(inode)->fd);
25383 + if (!(page = __get_free_page(GFP_KERNEL)))
25386 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
25387 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
25390 + length = simple_read_from_buffer(buf, count, ppos,
25391 + (char *)page, length);
25397 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
25398 + size_t count, loff_t *ppos)
25400 + struct inode *inode = file->f_dentry->d_inode;
25401 + struct vx_info *vxi = NULL;
25402 + xid_t xid = PROC_I(inode)->fd;
25403 + unsigned long page;
25404 + ssize_t length = 0;
25406 + if (count > PROC_BLOCK_SIZE)
25407 + count = PROC_BLOCK_SIZE;
25409 + /* fade that out as soon as stable */
25411 + vxi = lookup_vx_info(xid);
25415 + length = -ENOMEM;
25416 + if (!(page = __get_free_page(GFP_KERNEL)))
25419 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
25420 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
25423 + length = simple_read_from_buffer(buf, count, ppos,
25424 + (char *)page, length);
25428 + put_vx_info(vxi);
25433 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
25434 + size_t count, loff_t *ppos)
25436 + struct inode *inode = file->f_dentry->d_inode;
25437 + struct nx_info *nxi = NULL;
25438 + nid_t nid = PROC_I(inode)->fd;
25439 + unsigned long page;
25440 + ssize_t length = 0;
25442 + if (count > PROC_BLOCK_SIZE)
25443 + count = PROC_BLOCK_SIZE;
25445 + /* fade that out as soon as stable */
25447 + nxi = lookup_nx_info(nid);
25451 + length = -ENOMEM;
25452 + if (!(page = __get_free_page(GFP_KERNEL)))
25455 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
25456 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
25459 + length = simple_read_from_buffer(buf, count, ppos,
25460 + (char *)page, length);
25464 + put_nx_info(nxi);
25471 +/* here comes the lower level */
25474 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
25475 + .len = sizeof(NAME) - 1, \
25476 + .name = (NAME), \
25484 +#define DIR(NAME, MODE, OTYPE) \
25485 + NOD(NAME, (S_IFDIR | (MODE)), \
25486 + &proc_ ## OTYPE ## _inode_operations, \
25487 + &proc_ ## OTYPE ## _file_operations, { } )
25489 +#define INF(NAME, MODE, OTYPE) \
25490 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25491 + &proc_vs_info_file_operations, \
25492 + { .proc_vs_read = &proc_##OTYPE } )
25494 +#define VINF(NAME, MODE, OTYPE) \
25495 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25496 + &proc_vx_info_file_operations, \
25497 + { .proc_vxi_read = &proc_##OTYPE } )
25499 +#define NINF(NAME, MODE, OTYPE) \
25500 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25501 + &proc_nx_info_file_operations, \
25502 + { .proc_nxi_read = &proc_##OTYPE } )
25505 +static struct file_operations proc_vs_info_file_operations = {
25506 + .read = proc_vs_info_read,
25509 +static struct file_operations proc_vx_info_file_operations = {
25510 + .read = proc_vx_info_read,
25513 +static struct dentry_operations proc_xid_dentry_operations = {
25514 + .d_revalidate = proc_xid_revalidate,
25517 +static struct vs_entry vx_base_stuff[] = {
25518 + VINF("info", S_IRUGO, vxi_info),
25519 + VINF("status", S_IRUGO, vxi_status),
25520 + VINF("limit", S_IRUGO, vxi_limit),
25521 + VINF("sched", S_IRUGO, vxi_sched),
25522 + VINF("nsproxy", S_IRUGO, vxi_nsproxy),
25523 + VINF("cvirt", S_IRUGO, vxi_cvirt),
25524 + VINF("cacct", S_IRUGO, vxi_cacct),
25531 +static struct dentry *proc_xid_instantiate(struct inode *dir,
25532 + struct dentry *dentry, int id, void *ptr)
25534 + dentry->d_op = &proc_xid_dentry_operations;
25535 + return vs_proc_instantiate(dir, dentry, id, ptr);
25538 +static struct dentry *proc_xid_lookup(struct inode *dir,
25539 + struct dentry *dentry, struct nameidata *nd)
25541 + struct vs_entry *p = vx_base_stuff;
25542 + struct dentry *error = ERR_PTR(-ENOENT);
25544 + for (; p->name; p++) {
25545 + if (p->len != dentry->d_name.len)
25547 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25553 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
25558 +static int proc_xid_readdir(struct file *filp,
25559 + void *dirent, filldir_t filldir)
25561 + struct dentry *dentry = filp->f_dentry;
25562 + struct inode *inode = dentry->d_inode;
25563 + struct vs_entry *p = vx_base_stuff;
25564 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
25568 + pos = filp->f_pos;
25571 + ino = inode->i_ino;
25572 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25575 + /* fall through */
25577 + ino = parent_ino(dentry);
25578 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25581 + /* fall through */
25584 + if (index >= size)
25586 + for (p += index; p->name; p++) {
25587 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25588 + vs_proc_instantiate, PROC_I(inode)->fd, p))
25594 + filp->f_pos = pos;
25600 +static struct file_operations proc_nx_info_file_operations = {
25601 + .read = proc_nx_info_read,
25604 +static struct dentry_operations proc_nid_dentry_operations = {
25605 + .d_revalidate = proc_nid_revalidate,
25608 +static struct vs_entry nx_base_stuff[] = {
25609 + NINF("info", S_IRUGO, nxi_info),
25610 + NINF("status", S_IRUGO, nxi_status),
25615 +static struct dentry *proc_nid_instantiate(struct inode *dir,
25616 + struct dentry *dentry, int id, void *ptr)
25618 + dentry->d_op = &proc_nid_dentry_operations;
25619 + return vs_proc_instantiate(dir, dentry, id, ptr);
25622 +static struct dentry *proc_nid_lookup(struct inode *dir,
25623 + struct dentry *dentry, struct nameidata *nd)
25625 + struct vs_entry *p = nx_base_stuff;
25626 + struct dentry *error = ERR_PTR(-ENOENT);
25628 + for (; p->name; p++) {
25629 + if (p->len != dentry->d_name.len)
25631 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25637 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
25642 +static int proc_nid_readdir(struct file *filp,
25643 + void *dirent, filldir_t filldir)
25645 + struct dentry *dentry = filp->f_dentry;
25646 + struct inode *inode = dentry->d_inode;
25647 + struct vs_entry *p = nx_base_stuff;
25648 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
25652 + pos = filp->f_pos;
25655 + ino = inode->i_ino;
25656 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25659 + /* fall through */
25661 + ino = parent_ino(dentry);
25662 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25665 + /* fall through */
25668 + if (index >= size)
25670 + for (p += index; p->name; p++) {
25671 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25672 + vs_proc_instantiate, PROC_I(inode)->fd, p))
25678 + filp->f_pos = pos;
25683 +#define MAX_MULBY10 ((~0U - 9) / 10)
25685 +static inline int atovid(const char *str, int len)
25690 + while (len-- > 0) {
25695 + if (vid >= MAX_MULBY10)
25705 +/* now the upper level (virtual) */
25708 +static struct file_operations proc_xid_file_operations = {
25709 + .read = generic_read_dir,
25710 + .readdir = proc_xid_readdir,
25713 +static struct inode_operations proc_xid_inode_operations = {
25714 + .lookup = proc_xid_lookup,
25717 +static struct vs_entry vx_virtual_stuff[] = {
25718 + INF("info", S_IRUGO, virtual_info),
25719 + INF("status", S_IRUGO, virtual_status),
25720 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
25724 +static struct dentry *proc_virtual_lookup(struct inode *dir,
25725 + struct dentry *dentry, struct nameidata *nd)
25727 + struct vs_entry *p = vx_virtual_stuff;
25728 + struct dentry *error = ERR_PTR(-ENOENT);
25731 + for (; p->name; p++) {
25732 + if (p->len != dentry->d_name.len)
25734 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25738 + goto instantiate;
25740 + id = atovid(dentry->d_name.name, dentry->d_name.len);
25741 + if ((id < 0) || !xid_is_hashed(id))
25745 + error = proc_xid_instantiate(dir, dentry, id, p);
25750 +static struct file_operations proc_nid_file_operations = {
25751 + .read = generic_read_dir,
25752 + .readdir = proc_nid_readdir,
25755 +static struct inode_operations proc_nid_inode_operations = {
25756 + .lookup = proc_nid_lookup,
25759 +static struct vs_entry nx_virtnet_stuff[] = {
25760 + INF("info", S_IRUGO, virtnet_info),
25761 + INF("status", S_IRUGO, virtnet_status),
25762 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
25766 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
25767 + struct dentry *dentry, struct nameidata *nd)
25769 + struct vs_entry *p = nx_virtnet_stuff;
25770 + struct dentry *error = ERR_PTR(-ENOENT);
25773 + for (; p->name; p++) {
25774 + if (p->len != dentry->d_name.len)
25776 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25780 + goto instantiate;
25782 + id = atovid(dentry->d_name.name, dentry->d_name.len);
25783 + if ((id < 0) || !nid_is_hashed(id))
25787 + error = proc_nid_instantiate(dir, dentry, id, p);
25794 +#define PROC_NUMBUF 10
25795 +#define PROC_MAXVIDS 32
25797 +int proc_virtual_readdir(struct file *filp,
25798 + void *dirent, filldir_t filldir)
25800 + struct dentry *dentry = filp->f_dentry;
25801 + struct inode *inode = dentry->d_inode;
25802 + struct vs_entry *p = vx_virtual_stuff;
25803 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
25805 + unsigned int xid_array[PROC_MAXVIDS];
25806 + char buf[PROC_NUMBUF];
25807 + unsigned int nr_xids, i;
25810 + pos = filp->f_pos;
25813 + ino = inode->i_ino;
25814 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25817 + /* fall through */
25819 + ino = parent_ino(dentry);
25820 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25823 + /* fall through */
25826 + if (index >= size)
25828 + for (p += index; p->name; p++) {
25829 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25830 + vs_proc_instantiate, 0, p))
25835 + index = pos - size;
25836 + p = &vx_virtual_stuff[size - 1];
25837 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
25838 + for (i = 0; i < nr_xids; i++) {
25839 + int n, xid = xid_array[i];
25840 + unsigned int j = PROC_NUMBUF;
25844 + buf[--j] = '0' + (n % 10);
25847 + if (proc_fill_cache(filp, dirent, filldir,
25848 + buf + j, PROC_NUMBUF - j,
25849 + vs_proc_instantiate, xid, p))
25855 + filp->f_pos = pos;
25859 +static int proc_virtual_getattr(struct vfsmount *mnt,
25860 + struct dentry *dentry, struct kstat *stat)
25862 + struct inode *inode = dentry->d_inode;
25864 + generic_fillattr(inode, stat);
25865 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
25869 +static struct file_operations proc_virtual_dir_operations = {
25870 + .read = generic_read_dir,
25871 + .readdir = proc_virtual_readdir,
25874 +static struct inode_operations proc_virtual_dir_inode_operations = {
25875 + .getattr = proc_virtual_getattr,
25876 + .lookup = proc_virtual_lookup,
25883 +int proc_virtnet_readdir(struct file *filp,
25884 + void *dirent, filldir_t filldir)
25886 + struct dentry *dentry = filp->f_dentry;
25887 + struct inode *inode = dentry->d_inode;
25888 + struct vs_entry *p = nx_virtnet_stuff;
25889 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
25891 + unsigned int nid_array[PROC_MAXVIDS];
25892 + char buf[PROC_NUMBUF];
25893 + unsigned int nr_nids, i;
25896 + pos = filp->f_pos;
25899 + ino = inode->i_ino;
25900 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25903 + /* fall through */
25905 + ino = parent_ino(dentry);
25906 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25909 + /* fall through */
25912 + if (index >= size)
25914 + for (p += index; p->name; p++) {
25915 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25916 + vs_proc_instantiate, 0, p))
25921 + index = pos - size;
25922 + p = &nx_virtnet_stuff[size - 1];
25923 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
25924 + for (i = 0; i < nr_nids; i++) {
25925 + int n, nid = nid_array[i];
25926 + unsigned int j = PROC_NUMBUF;
25930 + buf[--j] = '0' + (n % 10);
25933 + if (proc_fill_cache(filp, dirent, filldir,
25934 + buf + j, PROC_NUMBUF - j,
25935 + vs_proc_instantiate, nid, p))
25941 + filp->f_pos = pos;
25945 +static int proc_virtnet_getattr(struct vfsmount *mnt,
25946 + struct dentry *dentry, struct kstat *stat)
25948 + struct inode *inode = dentry->d_inode;
25950 + generic_fillattr(inode, stat);
25951 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
25955 +static struct file_operations proc_virtnet_dir_operations = {
25956 + .read = generic_read_dir,
25957 + .readdir = proc_virtnet_readdir,
25960 +static struct inode_operations proc_virtnet_dir_inode_operations = {
25961 + .getattr = proc_virtnet_getattr,
25962 + .lookup = proc_virtnet_lookup,
25967 +void proc_vx_init(void)
25969 + struct proc_dir_entry *ent;
25971 + ent = proc_mkdir("virtual", 0);
25973 + ent->proc_fops = &proc_virtual_dir_operations;
25974 + ent->proc_iops = &proc_virtual_dir_inode_operations;
25976 + proc_virtual = ent;
25978 + ent = proc_mkdir("virtnet", 0);
25980 + ent->proc_fops = &proc_virtnet_dir_operations;
25981 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
25983 + proc_virtnet = ent;
25989 +/* per pid info */
25992 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
25994 + struct vx_info *vxi;
25995 + char *orig = buffer;
25997 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
25999 + vxi = task_get_vx_info(p);
26003 + buffer += sprintf(buffer, "BCaps:\t%016llx\n",
26004 + (unsigned long long)vxi->vx_bcaps);
26005 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
26006 + (unsigned long long)vxi->vx_ccaps);
26007 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
26008 + (unsigned long long)vxi->vx_flags);
26009 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
26011 + put_vx_info(vxi);
26013 + return buffer - orig;
26017 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
26019 + struct nx_info *nxi;
26020 + struct nx_addr_v4 *v4a;
26021 +#ifdef CONFIG_IPV6
26022 + struct nx_addr_v6 *v6a;
26024 + char *orig = buffer;
26027 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
26029 + nxi = task_get_nx_info(p);
26033 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
26034 + (unsigned long long)nxi->nx_ncaps);
26035 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
26036 + (unsigned long long)nxi->nx_flags);
26038 + buffer += sprintf(buffer,
26039 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
26040 + NIPQUAD(nxi->v4_bcast.s_addr));
26041 + buffer += sprintf (buffer,
26042 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
26043 + NIPQUAD(nxi->v4_lback.s_addr));
26044 + if (!NX_IPV4(nxi))
26046 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
26047 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
26050 +#ifdef CONFIG_IPV6
26051 + if (!NX_IPV6(nxi))
26053 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
26054 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
26058 + put_nx_info(nxi);
26060 + return buffer - orig;
26063 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/sched.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched.c
26064 --- linux-2.6.22.10/kernel/vserver/sched.c 1970-01-01 01:00:00 +0100
26065 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched.c 2007-08-15 23:32:49 +0200
26068 + * linux/kernel/vserver/sched.c
26070 + * Virtual Server: Scheduler Support
26072 + * Copyright (C) 2004-2007 Herbert Pötzl
26074 + * V0.01 adapted Sam Vilains version to 2.6.3
26075 + * V0.02 removed legacy interface
26076 + * V0.03 changed vcmds to vxi arg
26077 + * V0.04 removed older and legacy interfaces
26081 +#include <linux/vs_context.h>
26082 +#include <linux/vs_sched.h>
26083 +#include <linux/vserver/sched_cmd.h>
26085 +#include <asm/uaccess.h>
26088 +#define vxd_check_range(val, min, max) do { \
26089 + vxlprintk((val < min) || (val > max), \
26090 + "check_range(%ld,%ld,%ld)", \
26091 + (long)val, (long)min, (long)max, \
26092 + __FILE__, __LINE__); \
26096 +void vx_update_sched_param(struct _vx_sched *sched,
26097 + struct _vx_sched_pc *sched_pc)
26099 + unsigned int set_mask = sched->update_mask;
26101 + if (set_mask & VXSM_FILL_RATE)
26102 + sched_pc->fill_rate[0] = sched->fill_rate[0];
26103 + if (set_mask & VXSM_INTERVAL)
26104 + sched_pc->interval[0] = sched->interval[0];
26105 + if (set_mask & VXSM_FILL_RATE2)
26106 + sched_pc->fill_rate[1] = sched->fill_rate[1];
26107 + if (set_mask & VXSM_INTERVAL2)
26108 + sched_pc->interval[1] = sched->interval[1];
26109 + if (set_mask & VXSM_TOKENS)
26110 + sched_pc->tokens = sched->tokens;
26111 + if (set_mask & VXSM_TOKENS_MIN)
26112 + sched_pc->tokens_min = sched->tokens_min;
26113 + if (set_mask & VXSM_TOKENS_MAX)
26114 + sched_pc->tokens_max = sched->tokens_max;
26115 + if (set_mask & VXSM_PRIO_BIAS)
26116 + sched_pc->prio_bias = sched->prio_bias;
26118 + if (set_mask & VXSM_IDLE_TIME)
26119 + sched_pc->flags |= VXSF_IDLE_TIME;
26121 + sched_pc->flags &= ~VXSF_IDLE_TIME;
26124 + sched_pc->norm_time = jiffies;
26129 + * recalculate the context's scheduling tokens
26131 + * ret > 0 : number of tokens available
26132 + * ret < 0 : on hold, check delta_min[]
26133 + * -1 only jiffies
26134 + * -2 also idle time
26137 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
26138 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
26142 + int flags = sched_pc->flags;
26144 + /* how much time did pass? */
26145 + delta = *norm_time - sched_pc->norm_time;
26146 + vxd_check_range(delta, 0, INT_MAX);
26148 + if (delta >= sched_pc->interval[0]) {
26149 + long tokens, integral;
26151 + /* calc integral token part */
26152 + tokens = delta / sched_pc->interval[0];
26153 + integral = tokens * sched_pc->interval[0];
26154 + tokens *= sched_pc->fill_rate[0];
26155 +#ifdef CONFIG_VSERVER_HARDCPU
26156 + delta_min[0] = delta - integral;
26157 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
26159 + /* advance time */
26160 + sched_pc->norm_time += delta;
26163 + sched_pc->tokens += tokens;
26164 + sched_pc->token_time += tokens;
26166 + delta_min[0] = delta;
26168 +#ifdef CONFIG_VSERVER_IDLETIME
26169 + if (!(flags & VXSF_IDLE_TIME))
26172 + /* how much was the idle skip? */
26173 + delta = *idle_time - sched_pc->idle_time;
26174 + vxd_check_range(delta, 0, INT_MAX);
26176 + if (delta >= sched_pc->interval[1]) {
26177 + long tokens, integral;
26179 + /* calc fair share token part */
26180 + tokens = delta / sched_pc->interval[1];
26181 + integral = tokens * sched_pc->interval[1];
26182 + tokens *= sched_pc->fill_rate[1];
26183 + delta_min[1] = delta - integral;
26184 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
26186 + /* advance idle time */
26187 + sched_pc->idle_time += integral;
26190 + sched_pc->tokens += tokens;
26191 + sched_pc->token_time += tokens;
26193 + delta_min[1] = delta;
26197 + /* clip at maximum */
26198 + if (sched_pc->tokens > sched_pc->tokens_max)
26199 + sched_pc->tokens = sched_pc->tokens_max;
26200 + tokens = sched_pc->tokens;
26202 + if ((flags & VXSF_ONHOLD)) {
26203 + /* can we unhold? */
26204 + if (tokens >= sched_pc->tokens_min) {
26205 + flags &= ~VXSF_ONHOLD;
26206 + sched_pc->hold_ticks +=
26207 + *norm_time - sched_pc->onhold;
26211 + /* put on hold? */
26212 + if (tokens <= 0) {
26213 + flags |= VXSF_ONHOLD;
26214 + sched_pc->onhold = *norm_time;
26218 + sched_pc->flags = flags;
26222 + tokens = sched_pc->tokens_min - tokens;
26223 + sched_pc->flags = flags;
26224 + BUG_ON(tokens < 0);
26226 +#ifdef CONFIG_VSERVER_HARDCPU
26227 + /* next interval? */
26228 + if (!sched_pc->fill_rate[0])
26229 + delta_min[0] = HZ;
26230 + else if (tokens > sched_pc->fill_rate[0])
26231 + delta_min[0] += sched_pc->interval[0] *
26232 + tokens / sched_pc->fill_rate[0];
26234 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
26235 + vxd_check_range(delta_min[0], 0, INT_MAX);
26237 +#ifdef CONFIG_VSERVER_IDLETIME
26238 + if (!(flags & VXSF_IDLE_TIME))
26241 + /* next interval? */
26242 + if (!sched_pc->fill_rate[1])
26243 + delta_min[1] = HZ;
26244 + else if (tokens > sched_pc->fill_rate[1])
26245 + delta_min[1] += sched_pc->interval[1] *
26246 + tokens / sched_pc->fill_rate[1];
26248 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
26249 + vxd_check_range(delta_min[1], 0, INT_MAX);
26254 +#endif /* CONFIG_VSERVER_IDLETIME */
26257 +#endif /* CONFIG_VSERVER_HARDCPU */
26260 +static inline unsigned long msec_to_ticks(unsigned long msec)
26262 + return msecs_to_jiffies(msec);
26265 +static inline unsigned long ticks_to_msec(unsigned long ticks)
26267 + return jiffies_to_msecs(ticks);
26270 +static inline unsigned long ticks_to_usec(unsigned long ticks)
26272 + return jiffies_to_usecs(ticks);
26276 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
26278 + unsigned int set_mask = data->mask;
26279 + unsigned int update_mask;
26282 + /* Sanity check data values */
26283 + if (data->tokens_max <= 0)
26284 + data->tokens_max = HZ;
26285 + if (data->tokens_min < 0)
26286 + data->tokens_min = HZ / 3;
26287 + if (data->tokens_min >= data->tokens_max)
26288 + data->tokens_min = data->tokens_max;
26290 + if (data->prio_bias > MAX_PRIO_BIAS)
26291 + data->prio_bias = MAX_PRIO_BIAS;
26292 + if (data->prio_bias < MIN_PRIO_BIAS)
26293 + data->prio_bias = MIN_PRIO_BIAS;
26295 + spin_lock(&vxi->sched.tokens_lock);
26297 + /* sync up on delayed updates */
26298 + for_each_cpu_mask(cpu, vxi->sched.update)
26299 + vx_update_sched_param(&vxi->sched,
26300 + &vx_per_cpu(vxi, sched_pc, cpu));
26302 + if (set_mask & VXSM_FILL_RATE)
26303 + vxi->sched.fill_rate[0] = data->fill_rate[0];
26304 + if (set_mask & VXSM_FILL_RATE2)
26305 + vxi->sched.fill_rate[1] = data->fill_rate[1];
26306 + if (set_mask & VXSM_INTERVAL)
26307 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
26308 + msec_to_ticks(data->interval[0]) : data->interval[0];
26309 + if (set_mask & VXSM_INTERVAL2)
26310 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
26311 + msec_to_ticks(data->interval[1]) : data->interval[1];
26312 + if (set_mask & VXSM_TOKENS)
26313 + vxi->sched.tokens = data->tokens;
26314 + if (set_mask & VXSM_TOKENS_MIN)
26315 + vxi->sched.tokens_min = data->tokens_min;
26316 + if (set_mask & VXSM_TOKENS_MAX)
26317 + vxi->sched.tokens_max = data->tokens_max;
26318 + if (set_mask & VXSM_PRIO_BIAS)
26319 + vxi->sched.prio_bias = data->prio_bias;
26321 + /* Sanity check rate/interval */
26322 + for (i = 0; i < 2; i++) {
26323 + if (data->fill_rate[i] < 0)
26324 + data->fill_rate[i] = 0;
26325 + if (data->interval[i] <= 0)
26326 + data->interval[i] = HZ;
26329 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
26330 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
26331 + vxi->sched.update_mask = update_mask;
26335 + if (set_mask & VXSM_CPU_ID) {
26336 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
26337 + cpus_and(vxi->sched.update, cpu_online_map,
26338 + vxi->sched.update);
26340 + vxi->sched.update = cpu_online_map;
26342 + /* forced reload? */
26343 + if (set_mask & VXSM_FORCE) {
26344 + for_each_cpu_mask(cpu, vxi->sched.update)
26345 + vx_update_sched_param(&vxi->sched,
26346 + &vx_per_cpu(vxi, sched_pc, cpu));
26347 + vxi->sched.update = CPU_MASK_NONE;
26350 + /* on UP we update immediately */
26351 + vx_update_sched_param(&vxi->sched,
26352 + &vx_per_cpu(vxi, sched_pc, 0));
26355 + spin_unlock(&vxi->sched.tokens_lock);
26360 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
26361 +#define COPY_PRI(C) C(prio_bias)
26362 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
26363 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
26364 + C(fill_rate[1]); C(interval[1]);
26366 +#define COPY_VALUE(name) vc_data.name = data->name
26368 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
26370 + struct vcmd_sched_v5 vc_data;
26372 + vc_data.mask = data->set_mask;
26373 + COPY_IDS(COPY_VALUE);
26374 + COPY_PRI(COPY_VALUE);
26375 + COPY_TOK(COPY_VALUE);
26376 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
26377 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
26378 + return do_set_sched(vxi, &vc_data);
26381 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
26383 + struct vcmd_set_sched_v4 vc_data;
26385 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26388 + return do_set_sched_v4(vxi, &vc_data);
26391 + /* latest interface is v5 */
26393 +int vc_set_sched(struct vx_info *vxi, void __user *data)
26395 + struct vcmd_sched_v5 vc_data;
26397 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26400 + return do_set_sched(vxi, &vc_data);
26404 +#define COPY_PRI(C) C(prio_bias)
26405 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
26406 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
26407 + C(fill_rate[1]); C(interval[1]);
26409 +#define COPY_VALUE(name) vc_data.name = data->name
26412 +int vc_get_sched(struct vx_info *vxi, void __user *data)
26414 + struct vcmd_sched_v5 vc_data;
26416 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26419 + if (vc_data.mask & VXSM_CPU_ID) {
26420 + int cpu = vc_data.cpu_id;
26421 + struct _vx_sched_pc *data;
26423 + if (!cpu_possible(cpu))
26426 + data = &vx_per_cpu(vxi, sched_pc, cpu);
26427 + COPY_TOK(COPY_VALUE);
26428 + COPY_PRI(COPY_VALUE);
26429 + COPY_FRI(COPY_VALUE);
26431 + if (data->flags & VXSF_IDLE_TIME)
26432 + vc_data.mask |= VXSM_IDLE_TIME;
26434 + struct _vx_sched *data = &vxi->sched;
26436 + COPY_TOK(COPY_VALUE);
26437 + COPY_PRI(COPY_VALUE);
26438 + COPY_FRI(COPY_VALUE);
26441 + if (vc_data.mask & VXSM_MSEC) {
26442 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
26443 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
26446 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26452 +int vc_sched_info(struct vx_info *vxi, void __user *data)
26454 + struct vcmd_sched_info vc_data;
26457 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26460 + cpu = vc_data.cpu_id;
26461 + if (!cpu_possible(cpu))
26465 + struct _vx_sched_pc *sched_pc =
26466 + &vx_per_cpu(vxi, sched_pc, cpu);
26468 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
26469 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
26470 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
26471 + vc_data.vavavoom = sched_pc->vavavoom;
26473 + vc_data.token_usec = ticks_to_usec(1);
26475 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26480 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/sched_init.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched_init.h
26481 --- linux-2.6.22.10/kernel/vserver/sched_init.h 1970-01-01 01:00:00 +0100
26482 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched_init.h 2007-08-05 20:53:13 +0200
26485 +static inline void vx_info_init_sched(struct _vx_sched *sched)
26487 + static struct lock_class_key tokens_lock_key;
26489 + /* scheduling; hard code starting values as constants */
26490 + sched->fill_rate[0] = 1;
26491 + sched->interval[0] = 4;
26492 + sched->fill_rate[1] = 1;
26493 + sched->interval[1] = 8;
26494 + sched->tokens = HZ >> 2;
26495 + sched->tokens_min = HZ >> 4;
26496 + sched->tokens_max = HZ >> 1;
26497 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
26498 + sched->prio_bias = 0;
26500 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
26504 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
26506 + sched_pc->fill_rate[0] = 1;
26507 + sched_pc->interval[0] = 4;
26508 + sched_pc->fill_rate[1] = 1;
26509 + sched_pc->interval[1] = 8;
26510 + sched_pc->tokens = HZ >> 2;
26511 + sched_pc->tokens_min = HZ >> 4;
26512 + sched_pc->tokens_max = HZ >> 1;
26513 + sched_pc->prio_bias = 0;
26514 + sched_pc->vavavoom = 0;
26515 + sched_pc->token_time = 0;
26516 + sched_pc->idle_time = 0;
26517 + sched_pc->norm_time = jiffies;
26519 + sched_pc->user_ticks = 0;
26520 + sched_pc->sys_ticks = 0;
26521 + sched_pc->hold_ticks = 0;
26524 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
26530 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
26534 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/sched_proc.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched_proc.h
26535 --- linux-2.6.22.10/kernel/vserver/sched_proc.h 1970-01-01 01:00:00 +0100
26536 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched_proc.h 2007-08-05 20:53:13 +0200
26538 +#ifndef _VX_SCHED_PROC_H
26539 +#define _VX_SCHED_PROC_H
26543 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
26547 + length += sprintf(buffer,
26548 + "FillRate:\t%8d,%d\n"
26549 + "Interval:\t%8d,%d\n"
26550 + "TokensMin:\t%8d\n"
26551 + "TokensMax:\t%8d\n"
26552 + "PrioBias:\t%8d\n",
26553 + sched->fill_rate[0],
26554 + sched->fill_rate[1],
26555 + sched->interval[0],
26556 + sched->interval[1],
26557 + sched->tokens_min,
26558 + sched->tokens_max,
26559 + sched->prio_bias);
26564 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
26565 + char *buffer, int cpu)
26569 + length += sprintf(buffer + length,
26570 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
26571 + (unsigned long long)sched_pc->user_ticks,
26572 + (unsigned long long)sched_pc->sys_ticks,
26573 + (unsigned long long)sched_pc->hold_ticks,
26574 + sched_pc->token_time,
26575 + sched_pc->idle_time);
26576 + length += sprintf(buffer + length,
26577 + " %c%c %d %d %d %d/%d %d/%d",
26578 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
26579 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
26580 + sched_pc->tokens,
26581 + sched_pc->tokens_min,
26582 + sched_pc->tokens_max,
26583 + sched_pc->fill_rate[0],
26584 + sched_pc->interval[0],
26585 + sched_pc->fill_rate[1],
26586 + sched_pc->interval[1]);
26587 + length += sprintf(buffer + length,
26589 + sched_pc->prio_bias,
26590 + sched_pc->vavavoom);
26594 +#endif /* _VX_SCHED_PROC_H */
26595 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/signal.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/signal.c
26596 --- linux-2.6.22.10/kernel/vserver/signal.c 1970-01-01 01:00:00 +0100
26597 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/signal.c 2007-08-15 23:34:41 +0200
26600 + * linux/kernel/vserver/signal.c
26602 + * Virtual Server: Signal Support
26604 + * Copyright (C) 2003-2007 Herbert Pötzl
26606 + * V0.01 broken out from vcontext V0.05
26607 + * V0.02 changed vcmds to vxi arg
26608 + * V0.03 adjusted siginfo for kill
26612 +#include <asm/uaccess.h>
26614 +#include <linux/vs_context.h>
26615 +#include <linux/vserver/signal_cmd.h>
26618 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
26620 + int retval, count = 0;
26621 + struct task_struct *p;
26622 + struct siginfo *sip = SEND_SIG_PRIV;
26625 + vxdprintk(VXD_CBIT(misc, 4),
26626 + "vx_info_kill(%p[#%d],%d,%d)*",
26627 + vxi, vxi->vx_id, pid, sig);
26628 + read_lock(&tasklist_lock);
26632 + for_each_process(p) {
26635 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
26636 + (pid && vxi->vx_initpid == p->pid))
26639 + err = group_send_sig_info(sig, sip, p);
26641 + if (err != -EPERM)
26647 + if (vxi->vx_initpid) {
26648 + pid = vxi->vx_initpid;
26649 + /* for now, only SIGINT to private init ... */
26650 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
26651 + /* ... as long as there are tasks left */
26652 + (atomic_read(&vxi->vx_tasks) > 1))
26655 + /* fallthrough */
26657 + p = find_task_by_real_pid(pid);
26659 + if (vx_task_xid(p) == vxi->vx_id)
26660 + retval = group_send_sig_info(sig, sip, p);
26664 + read_unlock(&tasklist_lock);
26665 + vxdprintk(VXD_CBIT(misc, 4),
26666 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
26667 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
26671 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
26673 + struct vcmd_ctx_kill_v0 vc_data;
26675 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26678 + /* special check to allow guest shutdown */
26679 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
26680 + /* forbid killall pid=0 when init is present */
26681 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
26682 + (vc_data.pid > 1)))
26685 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
26689 +static int __wait_exit(struct vx_info *vxi)
26691 + DECLARE_WAITQUEUE(wait, current);
26694 + add_wait_queue(&vxi->vx_wait, &wait);
26695 + set_current_state(TASK_INTERRUPTIBLE);
26698 + if (vx_info_state(vxi,
26699 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
26701 + if (signal_pending(current)) {
26702 + ret = -ERESTARTSYS;
26709 + set_current_state(TASK_RUNNING);
26710 + remove_wait_queue(&vxi->vx_wait, &wait);
26716 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
26718 + struct vcmd_wait_exit_v0 vc_data;
26721 + ret = __wait_exit(vxi);
26722 + vc_data.reboot_cmd = vxi->reboot_cmd;
26723 + vc_data.exit_code = vxi->exit_code;
26725 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26730 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/space.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/space.c
26731 --- linux-2.6.22.10/kernel/vserver/space.c 1970-01-01 01:00:00 +0100
26732 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/space.c 2007-08-15 23:39:13 +0200
26735 + * linux/kernel/vserver/space.c
26737 + * Virtual Server: Context Space Support
26739 + * Copyright (C) 2003-2007 Herbert Pötzl
26741 + * V0.01 broken out from context.c 0.07
26742 + * V0.02 added task locking for namespace
26743 + * V0.03 broken out vx_enter_namespace
26744 + * V0.04 added *space support and commands
26748 +#include <linux/utsname.h>
26749 +#include <linux/nsproxy.h>
26750 +#include <linux/err.h>
26751 +#include <asm/uaccess.h>
26753 +#include <linux/vs_context.h>
26754 +#include <linux/vserver/space.h>
26755 +#include <linux/vserver/space_cmd.h>
26758 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
26759 +atomic_t vs_global_fs = ATOMIC_INIT(0);
26760 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
26761 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
26762 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
26765 +/* namespace functions */
26767 +#include <linux/mnt_namespace.h>
26769 +const struct vcmd_space_mask space_mask = {
26770 + .mask = CLONE_NEWNS |
26778 + * build a new nsproxy mix
26779 + * assumes that both proxies are 'const'
26780 + * does not touch nsproxy refcounts
26781 + * will hold a reference on the result.
26784 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
26785 + struct nsproxy *new_nsproxy, unsigned long mask)
26787 + struct mnt_namespace *old_ns;
26788 + struct uts_namespace *old_uts;
26789 + struct ipc_namespace *old_ipc;
26790 + struct nsproxy *nsproxy;
26792 + nsproxy = copy_nsproxy(old_nsproxy);
26796 + if (mask & CLONE_NEWNS) {
26797 + old_ns = nsproxy->mnt_ns;
26798 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
26799 + if (nsproxy->mnt_ns)
26800 + get_mnt_ns(nsproxy->mnt_ns);
26804 + if (mask & CLONE_NEWUTS) {
26805 + old_uts = nsproxy->uts_ns;
26806 + nsproxy->uts_ns = new_nsproxy->uts_ns;
26807 + if (nsproxy->uts_ns)
26808 + get_uts_ns(nsproxy->uts_ns);
26812 + if (mask & CLONE_NEWIPC) {
26813 + old_ipc = nsproxy->ipc_ns;
26814 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
26815 + if (nsproxy->ipc_ns)
26816 + get_ipc_ns(nsproxy->ipc_ns);
26821 + put_mnt_ns(old_ns);
26823 + put_uts_ns(old_uts);
26825 + put_ipc_ns(old_ipc);
26832 + * merge two nsproxy structs into a new one.
26833 + * will hold a reference on the result.
26837 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
26838 + struct nsproxy *proxy, unsigned long mask)
26840 + struct nsproxy null_proxy = { .mnt_ns = NULL };
26846 + /* vs_mix_nsproxy returns with reference */
26847 + return vs_mix_nsproxy(old ? old : &null_proxy,
26850 + get_nsproxy(proxy);
26855 + * merge two fs structs into a new one.
26856 + * will take a reference on the result.
26860 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
26861 + struct fs_struct *fs, unsigned long mask)
26863 + if (!(mask & CLONE_FS)) {
26865 + atomic_inc(&old->count);
26872 + return copy_fs_struct(fs);
26876 +int vx_enter_space(struct vx_info *vxi, unsigned long mask)
26878 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
26879 + struct fs_struct *fs, *fs_cur, *fs_new;
26882 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
26886 + mask = vxi->vx_nsmask;
26888 + if ((mask & vxi->vx_nsmask) != mask)
26891 + proxy = vxi->vx_nsproxy;
26894 + task_lock(current);
26895 + fs_cur = current->fs;
26896 + atomic_inc(&fs_cur->count);
26897 + proxy_cur = current->nsproxy;
26898 + get_nsproxy(proxy_cur);
26899 + task_unlock(current);
26901 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
26902 + if (IS_ERR(fs_new)) {
26903 + ret = PTR_ERR(fs_new);
26907 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
26908 + if (IS_ERR(proxy_new)) {
26909 + ret = PTR_ERR(proxy_new);
26913 + fs_new = xchg(¤t->fs, fs_new);
26914 + proxy_new = xchg(¤t->nsproxy, proxy_new);
26918 + put_nsproxy(proxy_new);
26921 + put_fs_struct(fs_new);
26924 + put_nsproxy(proxy_cur);
26926 + put_fs_struct(fs_cur);
26931 +int vx_set_space(struct vx_info *vxi, unsigned long mask)
26933 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
26934 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
26938 + mask = space_mask.mask;
26940 + if ((mask & space_mask.mask) != mask)
26943 + proxy_vxi = vxi->vx_nsproxy;
26944 + fs_vxi = vxi->vx_fs;
26946 + task_lock(current);
26947 + fs_cur = current->fs;
26948 + atomic_inc(&fs_cur->count);
26949 + proxy_cur = current->nsproxy;
26950 + get_nsproxy(proxy_cur);
26951 + task_unlock(current);
26953 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
26954 + if (IS_ERR(fs_new)) {
26955 + ret = PTR_ERR(fs_new);
26959 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
26960 + if (IS_ERR(proxy_new)) {
26961 + ret = PTR_ERR(proxy_new);
26965 + fs_new = xchg(&vxi->vx_fs, fs_new);
26966 + proxy_new = xchg(&vxi->vx_nsproxy, proxy_new);
26967 + vxi->vx_nsmask |= mask;
26971 + put_nsproxy(proxy_new);
26974 + put_fs_struct(fs_new);
26977 + put_nsproxy(proxy_cur);
26979 + put_fs_struct(fs_cur);
26984 +int vc_enter_space(struct vx_info *vxi, void __user *data)
26986 + struct vcmd_space_mask vc_data = { .mask = 0 };
26988 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
26991 + return vx_enter_space(vxi, vc_data.mask);
26994 +int vc_set_space(struct vx_info *vxi, void __user *data)
26996 + struct vcmd_space_mask vc_data = { .mask = 0 };
26998 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
27001 + return vx_set_space(vxi, vc_data.mask);
27004 +int vc_get_space_mask(struct vx_info *vxi, void __user *data)
27006 + if (copy_to_user(data, &space_mask, sizeof(space_mask)))
27011 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/switch.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/switch.c
27012 --- linux-2.6.22.10/kernel/vserver/switch.c 1970-01-01 01:00:00 +0100
27013 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/switch.c 2007-10-25 17:05:55 +0200
27016 + * linux/kernel/vserver/switch.c
27018 + * Virtual Server: Syscall Switch
27020 + * Copyright (C) 2003-2007 Herbert Pötzl
27022 + * V0.01 syscall switch
27023 + * V0.02 added signal to context
27024 + * V0.03 added rlimit functions
27025 + * V0.04 added iattr, task/xid functions
27026 + * V0.05 added debug/history stuff
27027 + * V0.06 added compat32 layer
27028 + * V0.07 vcmd args and perms
27029 + * V0.08 added status commands
27030 + * V0.09 added tag commands
27031 + * V0.10 added oom bias
27032 + * V0.11 added device commands
27036 +#include <linux/vs_context.h>
27037 +#include <linux/vs_network.h>
27038 +#include <linux/vserver/switch.h>
27040 +#include "vci_config.h"
27044 +int vc_get_version(uint32_t id)
27046 + return VCI_VERSION;
27050 +int vc_get_vci(uint32_t id)
27052 + return vci_kernel_config();
27055 +#include <linux/vserver/context_cmd.h>
27056 +#include <linux/vserver/cvirt_cmd.h>
27057 +#include <linux/vserver/cacct_cmd.h>
27058 +#include <linux/vserver/limit_cmd.h>
27059 +#include <linux/vserver/network_cmd.h>
27060 +#include <linux/vserver/sched_cmd.h>
27061 +#include <linux/vserver/debug_cmd.h>
27062 +#include <linux/vserver/inode_cmd.h>
27063 +#include <linux/vserver/dlimit_cmd.h>
27064 +#include <linux/vserver/signal_cmd.h>
27065 +#include <linux/vserver/space_cmd.h>
27066 +#include <linux/vserver/tag_cmd.h>
27067 +#include <linux/vserver/device_cmd.h>
27069 +#include <linux/vserver/inode.h>
27070 +#include <linux/vserver/dlimit.h>
27073 +#ifdef CONFIG_COMPAT
27074 +#define __COMPAT(name, id, data, compat) \
27075 + (compat) ? name ## _x32(id, data) : name(id, data)
27076 +#define __COMPAT_NO_ID(name, data, compat) \
27077 + (compat) ? name ## _x32(data) : name(data)
27079 +#define __COMPAT(name, id, data, compat) \
27081 +#define __COMPAT_NO_ID(name, data, compat) \
27087 +long do_vcmd(uint32_t cmd, uint32_t id,
27088 + struct vx_info *vxi, struct nx_info *nxi,
27089 + void __user *data, int compat)
27093 + case VCMD_get_version:
27094 + return vc_get_version(id);
27095 + case VCMD_get_vci:
27096 + return vc_get_vci(id);
27098 + case VCMD_task_xid:
27099 + return vc_task_xid(id);
27100 + case VCMD_vx_info:
27101 + return vc_vx_info(vxi, data);
27103 + case VCMD_task_nid:
27104 + return vc_task_nid(id);
27105 + case VCMD_nx_info:
27106 + return vc_nx_info(nxi, data);
27108 + case VCMD_task_tag:
27109 + return vc_task_tag(id);
27111 + /* this is version 1 */
27112 + case VCMD_set_space:
27113 + return vc_set_space(vxi, data);
27115 + case VCMD_get_space_mask:
27116 + return vc_get_space_mask(vxi, data);
27118 +#ifdef CONFIG_IA32_EMULATION
27119 + case VCMD_get_rlimit:
27120 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
27121 + case VCMD_set_rlimit:
27122 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
27124 + case VCMD_get_rlimit:
27125 + return vc_get_rlimit(vxi, data);
27126 + case VCMD_set_rlimit:
27127 + return vc_set_rlimit(vxi, data);
27129 + case VCMD_get_rlimit_mask:
27130 + return vc_get_rlimit_mask(id, data);
27131 + case VCMD_reset_minmax:
27132 + return vc_reset_minmax(vxi, data);
27134 + case VCMD_get_vhi_name:
27135 + return vc_get_vhi_name(vxi, data);
27136 + case VCMD_set_vhi_name:
27137 + return vc_set_vhi_name(vxi, data);
27139 + case VCMD_ctx_stat:
27140 + return vc_ctx_stat(vxi, data);
27141 + case VCMD_virt_stat:
27142 + return vc_virt_stat(vxi, data);
27143 + case VCMD_sock_stat:
27144 + return vc_sock_stat(vxi, data);
27145 + case VCMD_rlimit_stat:
27146 + return vc_rlimit_stat(vxi, data);
27148 + case VCMD_set_cflags:
27149 + return vc_set_cflags(vxi, data);
27150 + case VCMD_get_cflags:
27151 + return vc_get_cflags(vxi, data);
27153 + /* this is version 1 */
27154 + case VCMD_set_ccaps:
27155 + return vc_set_ccaps(vxi, data);
27156 + /* this is version 1 */
27157 + case VCMD_get_ccaps:
27158 + return vc_get_ccaps(vxi, data);
27159 + case VCMD_set_bcaps:
27160 + return vc_set_bcaps(vxi, data);
27161 + case VCMD_get_bcaps:
27162 + return vc_get_bcaps(vxi, data);
27164 + case VCMD_set_badness:
27165 + return vc_set_badness(vxi, data);
27166 + case VCMD_get_badness:
27167 + return vc_get_badness(vxi, data);
27169 + case VCMD_set_nflags:
27170 + return vc_set_nflags(nxi, data);
27171 + case VCMD_get_nflags:
27172 + return vc_get_nflags(nxi, data);
27174 + case VCMD_set_ncaps:
27175 + return vc_set_ncaps(nxi, data);
27176 + case VCMD_get_ncaps:
27177 + return vc_get_ncaps(nxi, data);
27179 + case VCMD_set_sched_v4:
27180 + return vc_set_sched_v4(vxi, data);
27181 + /* this is version 5 */
27182 + case VCMD_set_sched:
27183 + return vc_set_sched(vxi, data);
27184 + case VCMD_get_sched:
27185 + return vc_get_sched(vxi, data);
27186 + case VCMD_sched_info:
27187 + return vc_sched_info(vxi, data);
27189 + case VCMD_add_dlimit:
27190 + return __COMPAT(vc_add_dlimit, id, data, compat);
27191 + case VCMD_rem_dlimit:
27192 + return __COMPAT(vc_rem_dlimit, id, data, compat);
27193 + case VCMD_set_dlimit:
27194 + return __COMPAT(vc_set_dlimit, id, data, compat);
27195 + case VCMD_get_dlimit:
27196 + return __COMPAT(vc_get_dlimit, id, data, compat);
27198 + case VCMD_ctx_kill:
27199 + return vc_ctx_kill(vxi, data);
27201 + case VCMD_wait_exit:
27202 + return vc_wait_exit(vxi, data);
27204 + case VCMD_get_iattr:
27205 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
27206 + case VCMD_set_iattr:
27207 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
27209 + case VCMD_fget_iattr:
27210 + return vc_fget_iattr(id, data);
27211 + case VCMD_fset_iattr:
27212 + return vc_fset_iattr(id, data);
27214 + case VCMD_enter_space_v0:
27215 + return vc_enter_space(vxi, NULL);
27216 + /* this is version 1 */
27217 + case VCMD_enter_space:
27218 + return vc_enter_space(vxi, data);
27220 + case VCMD_ctx_create_v0:
27221 + return vc_ctx_create(id, NULL);
27222 + case VCMD_ctx_create:
27223 + return vc_ctx_create(id, data);
27224 + case VCMD_ctx_migrate_v0:
27225 + return vc_ctx_migrate(vxi, NULL);
27226 + case VCMD_ctx_migrate:
27227 + return vc_ctx_migrate(vxi, data);
27229 + case VCMD_net_create_v0:
27230 + return vc_net_create(id, NULL);
27231 + case VCMD_net_create:
27232 + return vc_net_create(id, data);
27233 + case VCMD_net_migrate:
27234 + return vc_net_migrate(nxi, data);
27236 + case VCMD_tag_migrate:
27237 + return vc_tag_migrate(id);
27239 + case VCMD_net_add:
27240 + return vc_net_add(nxi, data);
27241 + case VCMD_net_remove:
27242 + return vc_net_remove(nxi, data);
27244 + case VCMD_net_add_ipv4:
27245 + return vc_net_add_ipv4(nxi, data);
27246 + case VCMD_net_remove_ipv4:
27247 + return vc_net_remove_ipv4(nxi, data);
27248 +#ifdef CONFIG_IPV6
27249 + case VCMD_net_add_ipv6:
27250 + return vc_net_add_ipv6(nxi, data);
27251 + case VCMD_net_remove_ipv6:
27252 + return vc_net_remove_ipv6(nxi, data);
27254 +/* case VCMD_add_match_ipv4:
27255 + return vc_add_match_ipv4(nxi, data);
27256 + case VCMD_get_match_ipv4:
27257 + return vc_get_match_ipv4(nxi, data);
27258 +#ifdef CONFIG_IPV6
27259 + case VCMD_add_match_ipv6:
27260 + return vc_add_match_ipv6(nxi, data);
27261 + case VCMD_get_match_ipv6:
27262 + return vc_get_match_ipv6(nxi, data);
27265 +#ifdef CONFIG_VSERVER_DEVICE
27266 + case VCMD_set_mapping:
27267 + return __COMPAT(vc_set_mapping, vxi, data, compat);
27268 + case VCMD_unset_mapping:
27269 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
27271 +#ifdef CONFIG_VSERVER_HISTORY
27272 + case VCMD_dump_history:
27273 + return vc_dump_history(id);
27274 + case VCMD_read_history:
27275 + return __COMPAT(vc_read_history, id, data, compat);
27277 +#ifdef CONFIG_VSERVER_MONITOR
27278 + case VCMD_read_monitor:
27279 + return __COMPAT(vc_read_monitor, id, data, compat);
27282 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
27283 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
27289 +#define __VCMD(vcmd, _perm, _args, _flags) \
27290 + case VCMD_ ## vcmd: perm = _perm; \
27291 + args = _args; flags = _flags; break
27294 +#define VCA_NONE 0x00
27295 +#define VCA_VXI 0x01
27296 +#define VCA_NXI 0x02
27298 +#define VCF_NONE 0x00
27299 +#define VCF_INFO 0x01
27300 +#define VCF_ADMIN 0x02
27301 +#define VCF_ARES 0x06 /* includes admin */
27302 +#define VCF_SETUP 0x08
27304 +#define VCF_ZIDOK 0x10 /* zero id okay */
27308 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
27311 + int permit = -1, state = 0;
27312 + int perm = -1, args = 0, flags = 0;
27313 + struct vx_info *vxi = NULL;
27314 + struct nx_info *nxi = NULL;
27317 + /* unpriviledged commands */
27318 + __VCMD(get_version, 0, VCA_NONE, 0);
27319 + __VCMD(get_vci, 0, VCA_NONE, 0);
27320 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
27321 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
27323 + /* info commands */
27324 + __VCMD(task_xid, 2, VCA_NONE, 0);
27325 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
27326 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
27327 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
27328 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
27329 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
27330 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
27331 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
27332 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
27334 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
27335 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
27336 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
27337 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
27339 + __VCMD(task_nid, 2, VCA_NONE, 0);
27340 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
27341 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
27342 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
27344 + __VCMD(task_tag, 2, VCA_NONE, 0);
27346 + __VCMD(get_iattr, 2, VCA_NONE, 0);
27347 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
27348 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
27349 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
27350 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
27352 + /* lower admin commands */
27353 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
27354 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
27355 + __VCMD(ctx_create, 5, VCA_NONE, 0);
27356 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
27357 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
27358 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
27359 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
27361 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
27362 + __VCMD(net_create, 5, VCA_NONE, 0);
27363 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
27365 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
27367 + /* higher admin commands */
27368 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
27369 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27371 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27372 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27373 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27374 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27376 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27377 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27378 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27379 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27381 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
27382 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
27383 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27384 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27385 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27386 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27387 +#ifdef CONFIG_IPV6
27388 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27389 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27391 + __VCMD(set_iattr, 7, VCA_NONE, 0);
27392 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
27393 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
27394 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
27395 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
27397 +#ifdef CONFIG_VSERVER_DEVICE
27398 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
27399 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
27401 + /* debug level admin commands */
27402 +#ifdef CONFIG_VSERVER_HISTORY
27403 + __VCMD(dump_history, 9, VCA_NONE, 0);
27404 + __VCMD(read_history, 9, VCA_NONE, 0);
27406 +#ifdef CONFIG_VSERVER_MONITOR
27407 + __VCMD(read_monitor, 9, VCA_NONE, 0);
27414 + vxdprintk(VXD_CBIT(switch, 0),
27415 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
27416 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
27417 + VC_VERSION(cmd), id, data, compat,
27418 + perm, args, flags);
27425 + if (!capable(CAP_CONTEXT))
27429 + /* moved here from the individual commands */
27431 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
27435 + /* vcmd involves resource management */
27437 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
27441 + /* various legacy exceptions */
27443 + /* will go away when spectator is a cap */
27444 + case VCMD_ctx_migrate_v0:
27445 + case VCMD_ctx_migrate:
27447 + current->xid = 1;
27453 + /* will go away when spectator is a cap */
27454 + case VCMD_net_migrate:
27456 + current->nid = 1;
27463 + /* vcmds are fine by default */
27466 + /* admin type vcmds require admin ... */
27467 + if (flags & VCF_ADMIN)
27468 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
27470 + /* ... but setup type vcmds override that */
27471 + if (!permit && (flags & VCF_SETUP))
27472 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
27480 + if (!id && (flags & VCF_ZIDOK))
27484 + if (args & VCA_VXI) {
27485 + vxi = lookup_vx_info(id);
27489 + if ((flags & VCF_ADMIN) &&
27490 + /* special case kill for shutdown */
27491 + (cmd != VCMD_ctx_kill) &&
27492 + /* can context be administrated? */
27493 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
27499 + if (args & VCA_NXI) {
27500 + nxi = lookup_nx_info(id);
27504 + if ((flags & VCF_ADMIN) &&
27505 + /* can context be administrated? */
27506 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
27513 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
27516 + if ((args & VCA_NXI) && nxi)
27517 + put_nx_info(nxi);
27519 + if ((args & VCA_VXI) && vxi)
27520 + put_vx_info(vxi);
27522 + vxdprintk(VXD_CBIT(switch, 1),
27523 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
27524 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
27525 + VC_VERSION(cmd), ret, ret, state, permit);
27530 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
27532 + return do_vserver(cmd, id, data, 0);
27535 +#ifdef CONFIG_COMPAT
27538 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
27540 + return do_vserver(cmd, id, data, 1);
27543 +#endif /* CONFIG_COMPAT */
27544 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/sysctl.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sysctl.c
27545 --- linux-2.6.22.10/kernel/vserver/sysctl.c 1970-01-01 01:00:00 +0100
27546 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sysctl.c 2007-08-15 23:42:57 +0200
27549 + * kernel/vserver/sysctl.c
27551 + * Virtual Context Support
27553 + * Copyright (C) 2004-2007 Herbert Pötzl
27555 + * V0.01 basic structure
27559 +#include <linux/module.h>
27560 +#include <linux/ctype.h>
27561 +#include <linux/sysctl.h>
27562 +#include <linux/parser.h>
27563 +#include <asm/uaccess.h>
27566 +#define CTL_VSERVER 4242 /* unused? */
27569 + CTL_DEBUG_ERROR = 0,
27570 + CTL_DEBUG_SWITCH = 1,
27585 +unsigned int vx_debug_switch = 0;
27586 +unsigned int vx_debug_xid = 0;
27587 +unsigned int vx_debug_nid = 0;
27588 +unsigned int vx_debug_tag = 0;
27589 +unsigned int vx_debug_net = 0;
27590 +unsigned int vx_debug_limit = 0;
27591 +unsigned int vx_debug_cres = 0;
27592 +unsigned int vx_debug_dlim = 0;
27593 +unsigned int vx_debug_quota = 0;
27594 +unsigned int vx_debug_cvirt = 0;
27595 +unsigned int vx_debug_space = 0;
27596 +unsigned int vx_debug_misc = 0;
27599 +static struct ctl_table_header *vserver_table_header;
27600 +static ctl_table vserver_table[];
27603 +void vserver_register_sysctl(void)
27605 + if (!vserver_table_header) {
27606 + vserver_table_header = register_sysctl_table(vserver_table);
27611 +void vserver_unregister_sysctl(void)
27613 + if (vserver_table_header) {
27614 + unregister_sysctl_table(vserver_table_header);
27615 + vserver_table_header = NULL;
27620 +static int proc_dodebug(ctl_table *table, int write,
27621 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
27623 + char tmpbuf[20], *p, c;
27624 + unsigned int value;
27625 + size_t left, len;
27627 + if ((*ppos && !write) || !*lenp) {
27635 + if (!access_ok(VERIFY_READ, buffer, left))
27637 + p = (char *)buffer;
27638 + while (left && __get_user(c, p) >= 0 && isspace(c))
27643 + if (left > sizeof(tmpbuf) - 1)
27645 + if (copy_from_user(tmpbuf, p, left))
27647 + tmpbuf[left] = '\0';
27649 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
27650 + value = 10 * value + (*p - '0');
27651 + if (*p && !isspace(*p))
27653 + while (left && isspace(*p))
27655 + *(unsigned int *)table->data = value;
27657 + if (!access_ok(VERIFY_WRITE, buffer, left))
27659 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
27662 + if (__copy_to_user(buffer, tmpbuf, len))
27664 + if ((left -= len) > 0) {
27665 + if (put_user('\n', (char *)buffer + len))
27678 +#define CTL_ENTRY(ctl, name) \
27680 + .ctl_name = ctl, \
27681 + .procname = #name, \
27682 + .data = &vx_ ## name, \
27683 + .maxlen = sizeof(int), \
27685 + .proc_handler = &proc_dodebug \
27688 +static ctl_table debug_table[] = {
27689 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
27690 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
27691 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
27692 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
27693 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
27694 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
27695 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
27696 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
27697 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
27698 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
27699 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
27700 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
27701 + { .ctl_name = 0 }
27704 +static ctl_table vserver_table[] = {
27706 + .ctl_name = CTL_VSERVER,
27707 + .procname = "vserver",
27709 + .child = debug_table
27711 + { .ctl_name = 0 }
27715 +static match_table_t tokens = {
27716 + { CTL_DEBUG_SWITCH, "switch=%x" },
27717 + { CTL_DEBUG_XID, "xid=%x" },
27718 + { CTL_DEBUG_NID, "nid=%x" },
27719 + { CTL_DEBUG_TAG, "tag=%x" },
27720 + { CTL_DEBUG_NET, "net=%x" },
27721 + { CTL_DEBUG_LIMIT, "limit=%x" },
27722 + { CTL_DEBUG_CRES, "cres=%x" },
27723 + { CTL_DEBUG_DLIM, "dlim=%x" },
27724 + { CTL_DEBUG_QUOTA, "quota=%x" },
27725 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
27726 + { CTL_DEBUG_SPACE, "space=%x" },
27727 + { CTL_DEBUG_MISC, "misc=%x" },
27728 + { CTL_DEBUG_ERROR, NULL }
27731 +#define HANDLE_CASE(id, name, val) \
27732 + case CTL_DEBUG_ ## id: \
27733 + vx_debug_ ## name = val; \
27734 + printk("vs_debug_" #name "=0x%x\n", val); \
27738 +static int __init vs_debug_setup(char *str)
27743 + printk("vs_debug_setup(%s)\n", str);
27744 + while ((p = strsep(&str, ",")) != NULL) {
27745 + substring_t args[MAX_OPT_ARGS];
27746 + unsigned int value;
27751 + token = match_token(p, tokens, args);
27752 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
27755 + HANDLE_CASE(SWITCH, switch, value);
27756 + HANDLE_CASE(XID, xid, value);
27757 + HANDLE_CASE(NID, nid, value);
27758 + HANDLE_CASE(TAG, tag, value);
27759 + HANDLE_CASE(NET, net, value);
27760 + HANDLE_CASE(LIMIT, limit, value);
27761 + HANDLE_CASE(CRES, cres, value);
27762 + HANDLE_CASE(DLIM, dlim, value);
27763 + HANDLE_CASE(QUOTA, quota, value);
27764 + HANDLE_CASE(CVIRT, cvirt, value);
27765 + HANDLE_CASE(SPACE, space, value);
27766 + HANDLE_CASE(MISC, misc, value);
27775 +__setup("vsdebug=", vs_debug_setup);
27779 +EXPORT_SYMBOL_GPL(vx_debug_switch);
27780 +EXPORT_SYMBOL_GPL(vx_debug_xid);
27781 +EXPORT_SYMBOL_GPL(vx_debug_nid);
27782 +EXPORT_SYMBOL_GPL(vx_debug_net);
27783 +EXPORT_SYMBOL_GPL(vx_debug_limit);
27784 +EXPORT_SYMBOL_GPL(vx_debug_cres);
27785 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
27786 +EXPORT_SYMBOL_GPL(vx_debug_quota);
27787 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
27788 +EXPORT_SYMBOL_GPL(vx_debug_space);
27789 +EXPORT_SYMBOL_GPL(vx_debug_misc);
27791 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/tag.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/tag.c
27792 --- linux-2.6.22.10/kernel/vserver/tag.c 1970-01-01 01:00:00 +0100
27793 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/tag.c 2007-10-05 14:54:36 +0200
27796 + * linux/kernel/vserver/tag.c
27798 + * Virtual Server: Shallow Tag Space
27800 + * Copyright (C) 2007 Herbert Pötzl
27802 + * V0.01 basic implementation
27806 +#include <linux/sched.h>
27807 +#include <linux/vserver/debug.h>
27808 +#include <linux/vs_tag.h>
27810 +#include <linux/vserver/tag_cmd.h>
27813 +int dx_migrate_task(struct task_struct *p, tag_t tag)
27818 + vxdprintk(VXD_CBIT(tag, 5),
27819 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
27825 + vxdprintk(VXD_CBIT(tag, 5),
27826 + "moved task %p into [#%d]", p, tag);
27830 +/* vserver syscall commands below here */
27832 +/* taks xid and vx_info functions */
27835 +int vc_task_tag(uint32_t id)
27840 + struct task_struct *tsk;
27841 + read_lock(&tasklist_lock);
27842 + tsk = find_task_by_real_pid(id);
27843 + tag = (tsk) ? tsk->tag : -ESRCH;
27844 + read_unlock(&tasklist_lock);
27846 + tag = dx_current_tag();
27851 +int vc_tag_migrate(uint32_t tag)
27853 + return dx_migrate_task(current, tag & 0xFFFF);
27857 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/vci_config.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/vci_config.h
27858 --- linux-2.6.22.10/kernel/vserver/vci_config.h 1970-01-01 01:00:00 +0100
27859 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/vci_config.h 2007-08-16 03:56:22 +0200
27862 +/* interface version */
27864 +#define VCI_VERSION 0x00020302
27868 + VCI_KCBIT_NO_DYNAMIC = 0,
27870 + VCI_KCBIT_PROC_SECURE = 4,
27871 + VCI_KCBIT_HARDCPU = 5,
27872 + VCI_KCBIT_IDLELIMIT = 6,
27873 + VCI_KCBIT_IDLETIME = 7,
27875 + VCI_KCBIT_COWBL = 8,
27876 + VCI_KCBIT_FULLCOWBL = 9,
27877 + VCI_KCBIT_SPACES = 10,
27878 + VCI_KCBIT_NETV2 = 11,
27880 + VCI_KCBIT_DEBUG = 16,
27881 + VCI_KCBIT_HISTORY = 20,
27882 + VCI_KCBIT_TAGGED = 24,
27883 + VCI_KCBIT_PPTAG = 28,
27885 + VCI_KCBIT_MORE = 31,
27889 +static inline uint32_t vci_kernel_config(void)
27892 + (1 << VCI_KCBIT_NO_DYNAMIC) |
27894 + /* configured features */
27895 +#ifdef CONFIG_VSERVER_PROC_SECURE
27896 + (1 << VCI_KCBIT_PROC_SECURE) |
27898 +#ifdef CONFIG_VSERVER_HARDCPU
27899 + (1 << VCI_KCBIT_HARDCPU) |
27901 +#ifdef CONFIG_VSERVER_IDLELIMIT
27902 + (1 << VCI_KCBIT_IDLELIMIT) |
27904 +#ifdef CONFIG_VSERVER_IDLETIME
27905 + (1 << VCI_KCBIT_IDLETIME) |
27907 +#ifdef CONFIG_VSERVER_COWBL
27908 + (1 << VCI_KCBIT_COWBL) |
27909 + (1 << VCI_KCBIT_FULLCOWBL) |
27911 + (1 << VCI_KCBIT_SPACES) |
27912 + (1 << VCI_KCBIT_NETV2) |
27914 + /* debug options */
27915 +#ifdef CONFIG_VSERVER_DEBUG
27916 + (1 << VCI_KCBIT_DEBUG) |
27918 +#ifdef CONFIG_VSERVER_HISTORY
27919 + (1 << VCI_KCBIT_HISTORY) |
27922 + /* inode context tagging */
27923 +#if defined(CONFIG_TAGGING_NONE)
27924 + (0 << VCI_KCBIT_TAGGED) |
27925 +#elif defined(CONFIG_TAGGING_UID16)
27926 + (1 << VCI_KCBIT_TAGGED) |
27927 +#elif defined(CONFIG_TAGGING_GID16)
27928 + (2 << VCI_KCBIT_TAGGED) |
27929 +#elif defined(CONFIG_TAGGING_ID24)
27930 + (3 << VCI_KCBIT_TAGGED) |
27931 +#elif defined(CONFIG_TAGGING_INTERN)
27932 + (4 << VCI_KCBIT_TAGGED) |
27933 +#elif defined(CONFIG_TAGGING_RUNTIME)
27934 + (5 << VCI_KCBIT_TAGGED) |
27936 + (7 << VCI_KCBIT_TAGGED) |
27938 + (1 << VCI_KCBIT_PPTAG) |
27942 diff -NurpP --minimal linux-2.6.22.10/mm/filemap_xip.c linux-2.6.22.10-vs2.3.0.29/mm/filemap_xip.c
27943 --- linux-2.6.22.10/mm/filemap_xip.c 2007-07-09 13:20:04 +0200
27944 +++ linux-2.6.22.10-vs2.3.0.29/mm/filemap_xip.c 2007-08-05 20:53:13 +0200
27946 #include <linux/uio.h>
27947 #include <linux/rmap.h>
27948 #include <linux/sched.h>
27949 +#include <linux/vs_memory.h>
27950 #include <asm/tlbflush.h>
27951 #include "filemap.h"
27953 diff -NurpP --minimal linux-2.6.22.10/mm/fremap.c linux-2.6.22.10-vs2.3.0.29/mm/fremap.c
27954 --- linux-2.6.22.10/mm/fremap.c 2007-02-06 03:01:56 +0100
27955 +++ linux-2.6.22.10-vs2.3.0.29/mm/fremap.c 2007-08-05 20:53:13 +0200
27957 #include <linux/rmap.h>
27958 #include <linux/module.h>
27959 #include <linux/syscalls.h>
27960 +#include <linux/vs_memory.h>
27962 #include <asm/mmu_context.h>
27963 #include <asm/cacheflush.h>
27964 @@ -74,6 +75,8 @@ int install_page(struct mm_struct *mm, s
27966 if (page_mapcount(page) > INT_MAX/2)
27968 + if (!vx_rss_avail(mm, 1))
27971 if (pte_none(*pte) || !zap_pte(mm, vma, addr, pte))
27972 inc_mm_counter(mm, file_rss);
27973 diff -NurpP --minimal linux-2.6.22.10/mm/hugetlb.c linux-2.6.22.10-vs2.3.0.29/mm/hugetlb.c
27974 --- linux-2.6.22.10/mm/hugetlb.c 2007-10-30 01:57:15 +0100
27975 +++ linux-2.6.22.10-vs2.3.0.29/mm/hugetlb.c 2007-08-11 22:41:51 +0200
27977 #include <asm/pgtable.h>
27979 #include <linux/hugetlb.h>
27980 +#include <linux/vs_memory.h>
27981 #include "internal.h"
27983 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
27984 diff -NurpP --minimal linux-2.6.22.10/mm/memory.c linux-2.6.22.10-vs2.3.0.29/mm/memory.c
27985 --- linux-2.6.22.10/mm/memory.c 2007-07-09 13:20:04 +0200
27986 +++ linux-2.6.22.10-vs2.3.0.29/mm/memory.c 2007-08-05 20:53:13 +0200
27987 @@ -498,6 +498,9 @@ static int copy_pte_range(struct mm_stru
27991 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
27995 rss[1] = rss[0] = 0;
27996 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
27997 @@ -2157,6 +2160,11 @@ static int do_swap_page(struct mm_struct
27998 count_vm_event(PGMAJFAULT);
28001 + if (!vx_rss_avail(mm, 1)) {
28002 + ret = VM_FAULT_OOM;
28006 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
28007 mark_page_accessed(page);
28009 @@ -2229,6 +2237,8 @@ static int do_anonymous_page(struct mm_s
28010 /* Allocate our own private page. */
28011 pte_unmap(page_table);
28013 + if (!vx_rss_avail(mm, 1))
28015 if (unlikely(anon_vma_prepare(vma)))
28017 page = alloc_zeroed_user_highpage(vma, address);
28018 @@ -2302,6 +2312,9 @@ static int do_no_page(struct mm_struct *
28019 pte_unmap(page_table);
28020 BUG_ON(vma->vm_flags & VM_PFNMAP);
28022 + if (!vx_rss_avail(mm, 1))
28023 + return VM_FAULT_OOM;
28025 if (vma->vm_file) {
28026 mapping = vma->vm_file->f_mapping;
28027 sequence = mapping->truncate_count;
28028 @@ -2527,6 +2540,7 @@ static inline int handle_pte_fault(struc
28032 + int ret, type = VXPT_UNKNOWN;
28035 if (!pte_present(entry)) {
28036 @@ -2555,9 +2569,12 @@ static inline int handle_pte_fault(struc
28037 if (unlikely(!pte_same(*pte, entry)))
28039 if (write_access) {
28040 - if (!pte_write(entry))
28041 - return do_wp_page(mm, vma, address,
28042 + if (!pte_write(entry)) {
28043 + ret = do_wp_page(mm, vma, address,
28044 pte, pmd, ptl, entry);
28045 + type = VXPT_WRITE;
28048 entry = pte_mkdirty(entry);
28050 entry = pte_mkyoung(entry);
28051 @@ -2576,7 +2593,10 @@ static inline int handle_pte_fault(struc
28054 pte_unmap_unlock(pte, ptl);
28055 - return VM_FAULT_MINOR;
28056 + ret = VM_FAULT_MINOR;
28058 + vx_page_fault(mm, vma, type, ret);
28063 diff -NurpP --minimal linux-2.6.22.10/mm/mlock.c linux-2.6.22.10-vs2.3.0.29/mm/mlock.c
28064 --- linux-2.6.22.10/mm/mlock.c 2007-10-30 01:57:15 +0100
28065 +++ linux-2.6.22.10-vs2.3.0.29/mm/mlock.c 2007-08-11 22:41:51 +0200
28067 #include <linux/syscalls.h>
28068 #include <linux/sched.h>
28069 #include <linux/module.h>
28070 +#include <linux/vs_memory.h>
28072 int can_do_mlock(void)
28074 @@ -76,7 +77,7 @@ success:
28075 ret = make_pages_present(start, end);
28078 - mm->locked_vm -= pages;
28079 + vx_vmlocked_sub(mm, pages);
28081 if (ret == -ENOMEM)
28083 @@ -134,7 +135,7 @@ static int do_mlock(unsigned long start,
28085 asmlinkage long sys_mlock(unsigned long start, size_t len)
28087 - unsigned long locked;
28088 + unsigned long locked, grow;
28089 unsigned long lock_limit;
28090 int error = -ENOMEM;
28092 @@ -145,8 +146,10 @@ asmlinkage long sys_mlock(unsigned long
28093 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
28094 start &= PAGE_MASK;
28096 - locked = len >> PAGE_SHIFT;
28097 - locked += current->mm->locked_vm;
28098 + grow = len >> PAGE_SHIFT;
28099 + if (!vx_vmlocked_avail(current->mm, grow))
28101 + locked = current->mm->locked_vm + grow;
28103 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
28104 lock_limit >>= PAGE_SHIFT;
28105 @@ -154,6 +157,7 @@ asmlinkage long sys_mlock(unsigned long
28106 /* check against resource limits */
28107 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
28108 error = do_mlock(start, len, 1);
28110 up_write(¤t->mm->mmap_sem);
28113 @@ -213,6 +217,8 @@ asmlinkage long sys_mlockall(int flags)
28114 lock_limit >>= PAGE_SHIFT;
28117 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
28119 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
28120 capable(CAP_IPC_LOCK))
28121 ret = do_mlockall(flags);
28122 diff -NurpP --minimal linux-2.6.22.10/mm/mmap.c linux-2.6.22.10-vs2.3.0.29/mm/mmap.c
28123 --- linux-2.6.22.10/mm/mmap.c 2007-07-09 13:20:04 +0200
28124 +++ linux-2.6.22.10-vs2.3.0.29/mm/mmap.c 2007-08-05 20:53:13 +0200
28125 @@ -1144,10 +1144,10 @@ munmap_back:
28126 kmem_cache_free(vm_area_cachep, vma);
28129 - mm->total_vm += len >> PAGE_SHIFT;
28130 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
28131 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
28132 if (vm_flags & VM_LOCKED) {
28133 - mm->locked_vm += len >> PAGE_SHIFT;
28134 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
28135 make_pages_present(addr, addr + len);
28137 if (flags & MAP_POPULATE) {
28138 @@ -1502,9 +1502,9 @@ static int acct_stack_growth(struct vm_a
28141 /* Ok, everything looks good - let it rip */
28142 - mm->total_vm += grow;
28143 + vx_vmpages_add(mm, grow);
28144 if (vma->vm_flags & VM_LOCKED)
28145 - mm->locked_vm += grow;
28146 + vx_vmlocked_add(mm, grow);
28147 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
28150 @@ -1662,9 +1662,9 @@ static void remove_vma_list(struct mm_st
28152 long nrpages = vma_pages(vma);
28154 - mm->total_vm -= nrpages;
28155 + vx_vmpages_sub(mm, nrpages);
28156 if (vma->vm_flags & VM_LOCKED)
28157 - mm->locked_vm -= nrpages;
28158 + vx_vmlocked_sub(mm, nrpages);
28159 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
28160 vma = remove_vma(vma);
28162 @@ -1903,6 +1903,8 @@ unsigned long do_brk(unsigned long addr,
28163 lock_limit >>= PAGE_SHIFT;
28164 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
28166 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
28171 @@ -1929,7 +1931,8 @@ unsigned long do_brk(unsigned long addr,
28172 if (mm->map_count > sysctl_max_map_count)
28175 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
28176 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
28177 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
28180 /* Can we just expand an old private anonymous mapping? */
28181 @@ -1955,9 +1958,9 @@ unsigned long do_brk(unsigned long addr,
28182 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)];
28183 vma_link(mm, vma, prev, rb_link, rb_parent);
28185 - mm->total_vm += len >> PAGE_SHIFT;
28186 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
28187 if (flags & VM_LOCKED) {
28188 - mm->locked_vm += len >> PAGE_SHIFT;
28189 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
28190 make_pages_present(addr, addr + len);
28193 @@ -1986,6 +1989,11 @@ void exit_mmap(struct mm_struct *mm)
28194 free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, 0);
28195 tlb_finish_mmu(tlb, 0, end);
28197 + set_mm_counter(mm, file_rss, 0);
28198 + set_mm_counter(mm, anon_rss, 0);
28199 + vx_vmpages_sub(mm, mm->total_vm);
28200 + vx_vmlocked_sub(mm, mm->locked_vm);
28203 * Walk the list again, actually closing and freeing it,
28204 * with preemption enabled, without holding any MM locks.
28205 @@ -2025,7 +2033,8 @@ int insert_vm_struct(struct mm_struct *
28206 if (__vma && __vma->vm_start < vma->vm_end)
28208 if ((vma->vm_flags & VM_ACCOUNT) &&
28209 - security_vm_enough_memory(vma_pages(vma)))
28210 + (security_vm_enough_memory(vma_pages(vma)) ||
28211 + !vx_vmpages_avail(mm, vma_pages(vma))))
28213 vma_link(mm, vma, prev, rb_link, rb_parent);
28215 @@ -2098,6 +2107,8 @@ int may_expand_vm(struct mm_struct *mm,
28217 if (cur + npages > lim)
28219 + if (!vx_vmpages_avail(mm, npages))
28224 @@ -2168,7 +2179,6 @@ int install_special_mapping(struct mm_st
28228 - mm->total_vm += len >> PAGE_SHIFT;
28230 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
28233 diff -NurpP --minimal linux-2.6.22.10/mm/mremap.c linux-2.6.22.10-vs2.3.0.29/mm/mremap.c
28234 --- linux-2.6.22.10/mm/mremap.c 2007-02-06 03:01:56 +0100
28235 +++ linux-2.6.22.10-vs2.3.0.29/mm/mremap.c 2007-08-05 20:53:13 +0200
28237 #include <linux/highmem.h>
28238 #include <linux/security.h>
28239 #include <linux/syscalls.h>
28240 +#include <linux/vs_memory.h>
28242 #include <asm/uaccess.h>
28243 #include <asm/cacheflush.h>
28244 @@ -212,7 +213,7 @@ static unsigned long move_vma(struct vm_
28245 * If this were a serious issue, we'd add a flag to do_munmap().
28247 hiwater_vm = mm->hiwater_vm;
28248 - mm->total_vm += new_len >> PAGE_SHIFT;
28249 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
28250 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
28252 if (do_munmap(mm, old_addr, old_len) < 0) {
28253 @@ -230,7 +231,7 @@ static unsigned long move_vma(struct vm_
28256 if (vm_flags & VM_LOCKED) {
28257 - mm->locked_vm += new_len >> PAGE_SHIFT;
28258 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
28259 if (new_len > old_len)
28260 make_pages_present(new_addr + old_len,
28261 new_addr + new_len);
28262 @@ -337,6 +338,9 @@ unsigned long do_mremap(unsigned long ad
28264 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
28266 + if (!vx_vmlocked_avail(current->mm,
28267 + (new_len - old_len) >> PAGE_SHIFT))
28270 if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
28272 @@ -365,10 +369,10 @@ unsigned long do_mremap(unsigned long ad
28273 vma_adjust(vma, vma->vm_start,
28274 addr + new_len, vma->vm_pgoff, NULL);
28276 - mm->total_vm += pages;
28277 + vx_vmpages_add(mm, pages);
28278 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
28279 if (vma->vm_flags & VM_LOCKED) {
28280 - mm->locked_vm += pages;
28281 + vx_vmlocked_add(mm, pages);
28282 make_pages_present(addr + old_len,
28285 diff -NurpP --minimal linux-2.6.22.10/mm/nommu.c linux-2.6.22.10-vs2.3.0.29/mm/nommu.c
28286 --- linux-2.6.22.10/mm/nommu.c 2007-07-09 13:20:04 +0200
28287 +++ linux-2.6.22.10-vs2.3.0.29/mm/nommu.c 2007-08-05 20:53:13 +0200
28288 @@ -936,7 +936,7 @@ unsigned long do_mmap_pgoff(struct file
28289 realalloc += kobjsize(vma);
28290 askedalloc += sizeof(*vma);
28292 - current->mm->total_vm += len >> PAGE_SHIFT;
28293 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
28295 add_nommu_vma(vma);
28297 @@ -1061,7 +1061,7 @@ int do_munmap(struct mm_struct *mm, unsi
28300 update_hiwater_vm(mm);
28301 - mm->total_vm -= len >> PAGE_SHIFT;
28302 + vx_vmpages_sub(mm, len >> PAGE_SHIFT);
28305 show_process_blocks();
28306 @@ -1093,7 +1093,7 @@ void exit_mmap(struct mm_struct * mm)
28307 printk("Exit_mmap:\n");
28310 - mm->total_vm = 0;
28311 + vx_vmpages_sub(mm, mm->total_vm);
28313 while ((tmp = mm->context.vmlist)) {
28314 mm->context.vmlist = tmp->next;
28315 diff -NurpP --minimal linux-2.6.22.10/mm/oom_kill.c linux-2.6.22.10-vs2.3.0.29/mm/oom_kill.c
28316 --- linux-2.6.22.10/mm/oom_kill.c 2007-07-09 13:20:04 +0200
28317 +++ linux-2.6.22.10-vs2.3.0.29/mm/oom_kill.c 2007-08-05 20:53:13 +0200
28319 #include <linux/cpuset.h>
28320 #include <linux/module.h>
28321 #include <linux/notifier.h>
28322 +#include <linux/vs_memory.h>
28324 int sysctl_panic_on_oom;
28325 /* #define DEBUG */
28326 @@ -66,6 +67,12 @@ unsigned long badness(struct task_struct
28327 points = mm->total_vm;
28330 + * add points for context badness
28333 + points += vx_badness(p, mm);
28336 * After this unlock we can no longer dereference local variable `mm'
28339 @@ -156,8 +163,8 @@ unsigned long badness(struct task_struct
28343 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %d points\n",
28344 - p->pid, p->comm, points);
28345 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
28346 + p->pid, p->xid, p->comm, points);
28350 @@ -288,7 +295,8 @@ static void __oom_kill_task(struct task_
28354 - printk(KERN_ERR "Killed process %d (%s)\n", p->pid, p->comm);
28355 + printk(KERN_ERR "Killed process %d:#%u (%s)\n",
28356 + p->pid, p->xid, p->comm);
28359 * We give our sacrificial lamb high priority and access to
28360 @@ -358,8 +366,8 @@ static int oom_kill_process(struct task_
28364 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
28365 - message, p->pid, p->comm, points);
28366 + printk(KERN_ERR "%s: kill process %d:#%u (%s) score %li or a child\n",
28367 + message, p->pid, p->xid, p->comm, points);
28369 /* Try to kill a child first */
28370 list_for_each(tsk, &p->children) {
28371 diff -NurpP --minimal linux-2.6.22.10/mm/page_alloc.c linux-2.6.22.10-vs2.3.0.29/mm/page_alloc.c
28372 --- linux-2.6.22.10/mm/page_alloc.c 2007-07-09 13:20:04 +0200
28373 +++ linux-2.6.22.10-vs2.3.0.29/mm/page_alloc.c 2007-08-05 20:53:13 +0200
28375 #include <linux/pfn.h>
28376 #include <linux/backing-dev.h>
28377 #include <linux/fault-inject.h>
28378 +#include <linux/vs_base.h>
28379 +#include <linux/vs_limit.h>
28381 #include <asm/tlbflush.h>
28382 #include <asm/div64.h>
28383 @@ -1488,6 +1490,9 @@ void si_meminfo(struct sysinfo *val)
28384 val->totalhigh = totalhigh_pages;
28385 val->freehigh = nr_free_highpages();
28386 val->mem_unit = PAGE_SIZE;
28388 + if (vx_flags(VXF_VIRT_MEM, 0))
28389 + vx_vsi_meminfo(val);
28392 EXPORT_SYMBOL(si_meminfo);
28393 @@ -1508,6 +1513,9 @@ void si_meminfo_node(struct sysinfo *val
28396 val->mem_unit = PAGE_SIZE;
28398 + if (vx_flags(VXF_VIRT_MEM, 0))
28399 + vx_vsi_meminfo(val);
28403 diff -NurpP --minimal linux-2.6.22.10/mm/rmap.c linux-2.6.22.10-vs2.3.0.29/mm/rmap.c
28404 --- linux-2.6.22.10/mm/rmap.c 2007-07-09 13:20:04 +0200
28405 +++ linux-2.6.22.10-vs2.3.0.29/mm/rmap.c 2007-08-05 20:53:13 +0200
28407 #include <linux/rcupdate.h>
28408 #include <linux/module.h>
28409 #include <linux/kallsyms.h>
28410 +#include <linux/vs_memory.h>
28412 #include <asm/tlbflush.h>
28414 diff -NurpP --minimal linux-2.6.22.10/mm/shmem.c linux-2.6.22.10-vs2.3.0.29/mm/shmem.c
28415 --- linux-2.6.22.10/mm/shmem.c 2007-07-09 13:20:04 +0200
28416 +++ linux-2.6.22.10-vs2.3.0.29/mm/shmem.c 2007-08-05 20:53:13 +0200
28418 #include <asm/pgtable.h>
28420 /* This magic number is used in glibc for posix shared memory */
28421 -#define TMPFS_MAGIC 0x01021994
28423 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
28424 #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
28425 @@ -1734,7 +1733,7 @@ static int shmem_statfs(struct dentry *d
28427 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
28429 - buf->f_type = TMPFS_MAGIC;
28430 + buf->f_type = TMPFS_SUPER_MAGIC;
28431 buf->f_bsize = PAGE_CACHE_SIZE;
28432 buf->f_namelen = NAME_MAX;
28433 spin_lock(&sbinfo->stat_lock);
28434 @@ -2308,7 +2307,7 @@ static int shmem_fill_super(struct super
28435 sb->s_maxbytes = SHMEM_MAX_BYTES;
28436 sb->s_blocksize = PAGE_CACHE_SIZE;
28437 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
28438 - sb->s_magic = TMPFS_MAGIC;
28439 + sb->s_magic = TMPFS_SUPER_MAGIC;
28440 sb->s_op = &shmem_ops;
28441 sb->s_time_gran = 1;
28442 #ifdef CONFIG_TMPFS_POSIX_ACL
28443 diff -NurpP --minimal linux-2.6.22.10/mm/slab.c linux-2.6.22.10-vs2.3.0.29/mm/slab.c
28444 --- linux-2.6.22.10/mm/slab.c 2007-07-09 13:20:04 +0200
28445 +++ linux-2.6.22.10-vs2.3.0.29/mm/slab.c 2007-08-05 20:53:13 +0200
28446 @@ -510,6 +510,8 @@ struct kmem_cache {
28447 #define STATS_INC_FREEMISS(x) do { } while (0)
28450 +#include "slab_vs.h"
28455 @@ -3314,6 +3316,7 @@ retry:
28457 obj = slab_get_obj(cachep, slabp, nodeid);
28458 check_slabp(cachep, slabp);
28459 + vx_slab_alloc(cachep, flags);
28460 l3->free_objects--;
28461 /* move slabp to correct slabp list: */
28462 list_del(&slabp->list);
28463 @@ -3386,6 +3389,7 @@ __cache_alloc_node(struct kmem_cache *ca
28464 /* ___cache_alloc_node can fall back to other nodes */
28465 ptr = ____cache_alloc_node(cachep, flags, nodeid);
28467 + vx_slab_alloc(cachep, flags);
28468 local_irq_restore(save_flags);
28469 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
28471 @@ -3551,6 +3555,7 @@ static inline void __cache_free(struct k
28474 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
28475 + vx_slab_free(cachep);
28477 if (cache_free_alien(cachep, objp))
28479 diff -NurpP --minimal linux-2.6.22.10/mm/slab_vs.h linux-2.6.22.10-vs2.3.0.29/mm/slab_vs.h
28480 --- linux-2.6.22.10/mm/slab_vs.h 1970-01-01 01:00:00 +0100
28481 +++ linux-2.6.22.10-vs2.3.0.29/mm/slab_vs.h 2007-08-05 20:53:13 +0200
28484 +#include <linux/vserver/context.h>
28486 +#include <linux/vs_context.h>
28489 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
28491 + int what = gfp_zone(cachep->gfpflags);
28493 + if (!current->vx_info)
28496 + atomic_add(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
28500 +void vx_slab_free(struct kmem_cache *cachep)
28502 + int what = gfp_zone(cachep->gfpflags);
28504 + if (!current->vx_info)
28507 + atomic_sub(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
28510 diff -NurpP --minimal linux-2.6.22.10/mm/swapfile.c linux-2.6.22.10-vs2.3.0.29/mm/swapfile.c
28511 --- linux-2.6.22.10/mm/swapfile.c 2007-07-09 13:20:04 +0200
28512 +++ linux-2.6.22.10-vs2.3.0.29/mm/swapfile.c 2007-08-05 20:53:13 +0200
28514 #include <asm/pgtable.h>
28515 #include <asm/tlbflush.h>
28516 #include <linux/swapops.h>
28517 +#include <linux/vs_base.h>
28518 +#include <linux/vs_memory.h>
28520 DEFINE_SPINLOCK(swap_lock);
28521 unsigned int nr_swapfiles;
28522 @@ -1712,6 +1714,8 @@ void si_swapinfo(struct sysinfo *val)
28523 val->freeswap = nr_swap_pages + nr_to_be_unused;
28524 val->totalswap = total_swap_pages + nr_to_be_unused;
28525 spin_unlock(&swap_lock);
28526 + if (vx_flags(VXF_VIRT_MEM, 0))
28527 + vx_vsi_swapinfo(val);
28531 diff -NurpP --minimal linux-2.6.22.10/net/core/dev.c linux-2.6.22.10-vs2.3.0.29/net/core/dev.c
28532 --- linux-2.6.22.10/net/core/dev.c 2007-10-30 01:57:15 +0100
28533 +++ linux-2.6.22.10-vs2.3.0.29/net/core/dev.c 2007-09-05 03:06:12 +0200
28534 @@ -117,6 +117,7 @@
28535 #include <linux/err.h>
28536 #include <linux/ctype.h>
28537 #include <linux/if_arp.h>
28538 +#include <linux/vs_inet.h>
28541 * The list of packet types we will receive (as opposed to discard)
28542 @@ -2120,6 +2121,8 @@ static int dev_ifconf(char __user *arg)
28545 for_each_netdev(dev) {
28546 + if (!nx_dev_visible(current->nx_info, dev))
28548 for (i = 0; i < NPROTO; i++) {
28549 if (gifconf_list[i]) {
28551 @@ -2184,6 +2187,9 @@ static void dev_seq_printf_stats(struct
28553 struct net_device_stats *stats = dev->get_stats(dev);
28555 + if (!nx_dev_visible(current->nx_info, dev))
28558 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
28559 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
28560 dev->name, stats->rx_bytes, stats->rx_packets,
28561 diff -NurpP --minimal linux-2.6.22.10/net/core/rtnetlink.c linux-2.6.22.10-vs2.3.0.29/net/core/rtnetlink.c
28562 --- linux-2.6.22.10/net/core/rtnetlink.c 2007-07-09 13:20:05 +0200
28563 +++ linux-2.6.22.10-vs2.3.0.29/net/core/rtnetlink.c 2007-08-05 20:53:13 +0200
28564 @@ -537,6 +537,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
28567 for_each_netdev(dev) {
28568 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
28572 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
28573 @@ -797,6 +799,9 @@ void rtmsg_ifinfo(int type, struct net_d
28574 struct sk_buff *skb;
28575 int err = -ENOBUFS;
28577 + if (!nx_dev_visible(current->nx_info, dev))
28580 skb = nlmsg_new(if_nlmsg_size(), GFP_KERNEL);
28583 diff -NurpP --minimal linux-2.6.22.10/net/core/sock.c linux-2.6.22.10-vs2.3.0.29/net/core/sock.c
28584 --- linux-2.6.22.10/net/core/sock.c 2007-07-09 13:20:05 +0200
28585 +++ linux-2.6.22.10-vs2.3.0.29/net/core/sock.c 2007-10-01 14:57:43 +0200
28586 @@ -125,6 +125,10 @@
28587 #include <linux/ipsec.h>
28589 #include <linux/filter.h>
28590 +#include <linux/vs_socket.h>
28591 +#include <linux/vs_limit.h>
28592 +#include <linux/vs_context.h>
28593 +#include <linux/vs_network.h>
28596 #include <net/tcp.h>
28597 @@ -812,6 +816,9 @@ int sock_getsockopt(struct socket *sock,
28599 return security_socket_getpeersec_stream(sock, optval, optlen, len);
28602 + return vx_socket_peer_tag(sock, level, optval, optlen, len);
28605 return -ENOPROTOOPT;
28607 @@ -869,6 +876,8 @@ struct sock *sk_alloc(int family, gfp_t
28608 sk->sk_prot = sk->sk_prot_creator = prot;
28609 sock_lock_init(sk);
28611 + sock_vx_init(sk);
28612 + sock_nx_init(sk);
28614 if (security_sk_alloc(sk, family, priority))
28616 @@ -907,6 +916,11 @@ void sk_free(struct sock *sk)
28617 __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
28619 security_sk_free(sk);
28621 + clr_vx_info(&sk->sk_vx_info);
28623 + clr_nx_info(&sk->sk_nx_info);
28625 if (sk->sk_prot_creator->slab != NULL)
28626 kmem_cache_free(sk->sk_prot_creator->slab, sk);
28628 @@ -924,6 +938,8 @@ struct sock *sk_clone(const struct sock
28629 sock_copy(newsk, sk);
28632 + sock_vx_init(newsk);
28633 + sock_nx_init(newsk);
28634 sk_node_init(&newsk->sk_node);
28635 sock_lock_init(newsk);
28636 bh_lock_sock(newsk);
28637 @@ -969,6 +985,12 @@ struct sock *sk_clone(const struct sock
28638 newsk->sk_priority = 0;
28639 atomic_set(&newsk->sk_refcnt, 2);
28641 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
28642 + newsk->sk_xid = sk->sk_xid;
28643 + vx_sock_inc(newsk);
28644 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
28645 + newsk->sk_nid = sk->sk_nid;
28648 * Increment the counter in the same struct proto as the master
28649 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
28650 @@ -1551,6 +1573,11 @@ void sock_init_data(struct socket *sock,
28652 sk->sk_stamp = ktime_set(-1L, -1L);
28654 + set_vx_info(&sk->sk_vx_info, current->vx_info);
28655 + sk->sk_xid = vx_current_xid();
28657 + set_nx_info(&sk->sk_nx_info, current->nx_info);
28658 + sk->sk_nid = nx_current_nid();
28659 atomic_set(&sk->sk_refcnt, 1);
28662 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/af_inet.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/af_inet.c
28663 --- linux-2.6.22.10/net/ipv4/af_inet.c 2007-10-30 01:57:15 +0100
28664 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/af_inet.c 2007-10-05 14:54:36 +0200
28665 @@ -115,6 +115,7 @@
28666 #ifdef CONFIG_IP_MROUTE
28667 #include <linux/mroute.h>
28669 +#include <linux/vs_limit.h>
28671 DEFINE_SNMP_STAT(struct linux_mib, net_statistics) __read_mostly;
28673 @@ -308,9 +309,12 @@ lookup_protocol:
28677 + if ((protocol == IPPROTO_ICMP) &&
28678 + nx_capable(answer->capability, NXC_RAW_ICMP))
28680 if (answer->capability > 0 && !capable(answer->capability))
28681 goto out_rcu_unlock;
28684 sock->ops = answer->ops;
28685 answer_prot = answer->prot;
28686 answer_no_check = answer->no_check;
28687 @@ -424,6 +428,7 @@ int inet_bind(struct socket *sock, struc
28688 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
28689 struct sock *sk = sock->sk;
28690 struct inet_sock *inet = inet_sk(sk);
28691 + struct nx_v4_sock_addr nsa;
28692 unsigned short snum;
28695 @@ -437,7 +442,11 @@ int inet_bind(struct socket *sock, struc
28696 if (addr_len < sizeof(struct sockaddr_in))
28699 - chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr);
28700 + err = v4_map_sock_addr(inet, addr, &nsa);
28704 + chk_addr_ret = inet_addr_type(nsa.saddr);
28706 /* Not specified by any standard per-se, however it breaks too
28707 * many applications when removed. It is unfortunate since
28708 @@ -449,7 +458,7 @@ int inet_bind(struct socket *sock, struc
28709 err = -EADDRNOTAVAIL;
28710 if (!sysctl_ip_nonlocal_bind &&
28712 - addr->sin_addr.s_addr != INADDR_ANY &&
28713 + nsa.saddr != INADDR_ANY &&
28714 chk_addr_ret != RTN_LOCAL &&
28715 chk_addr_ret != RTN_MULTICAST &&
28716 chk_addr_ret != RTN_BROADCAST)
28717 @@ -474,7 +483,7 @@ int inet_bind(struct socket *sock, struc
28718 if (sk->sk_state != TCP_CLOSE || inet->num)
28719 goto out_release_sock;
28721 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
28722 + v4_set_sock_addr(inet, &nsa);
28723 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
28724 inet->saddr = 0; /* Use device */
28726 @@ -667,11 +676,13 @@ int inet_getname(struct socket *sock, st
28729 sin->sin_port = inet->dport;
28730 - sin->sin_addr.s_addr = inet->daddr;
28731 + sin->sin_addr.s_addr =
28732 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
28734 __be32 addr = inet->rcv_saddr;
28736 addr = inet->saddr;
28737 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
28738 sin->sin_port = inet->sport;
28739 sin->sin_addr.s_addr = addr;
28741 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/devinet.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/devinet.c
28742 --- linux-2.6.22.10/net/ipv4/devinet.c 2007-10-30 01:57:15 +0100
28743 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/devinet.c 2007-09-30 14:58:01 +0200
28744 @@ -427,6 +427,7 @@ struct in_device *inetdev_by_index(int i
28749 /* Called only from RTNL semaphored context. No locks. */
28751 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
28752 @@ -676,6 +677,8 @@ int devinet_ioctl(unsigned int cmd, void
28755 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
28756 + struct nx_info *nxi = current->nx_info;
28758 if (tryaddrmatch) {
28759 /* Matthias Andree */
28760 /* compare label and address (4.4BSD style) */
28761 @@ -684,6 +687,8 @@ int devinet_ioctl(unsigned int cmd, void
28762 This is checked above. */
28763 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
28764 ifap = &ifa->ifa_next) {
28765 + if (!nx_v4_ifa_visible(nxi, ifa))
28767 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
28768 sin_orig.sin_addr.s_addr ==
28769 ifa->ifa_address) {
28770 @@ -696,9 +701,12 @@ int devinet_ioctl(unsigned int cmd, void
28771 comparing just the label */
28773 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
28774 - ifap = &ifa->ifa_next)
28775 + ifap = &ifa->ifa_next) {
28776 + if (!nx_v4_ifa_visible(nxi, ifa))
28778 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
28784 @@ -849,6 +857,8 @@ static int inet_gifconf(struct net_devic
28787 for (; ifa; ifa = ifa->ifa_next) {
28788 + if (!nx_v4_ifa_visible(current->nx_info, ifa))
28791 done += sizeof(ifr);
28793 @@ -1179,6 +1189,7 @@ static int inet_dump_ifaddr(struct sk_bu
28794 struct net_device *dev;
28795 struct in_device *in_dev;
28796 struct in_ifaddr *ifa;
28797 + struct sock *sk = skb->sk;
28798 int s_ip_idx, s_idx = cb->args[0];
28800 s_ip_idx = ip_idx = cb->args[1];
28801 @@ -1193,6 +1204,8 @@ static int inet_dump_ifaddr(struct sk_bu
28803 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
28804 ifa = ifa->ifa_next, ip_idx++) {
28805 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
28807 if (ip_idx < s_ip_idx)
28809 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
28810 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/fib_hash.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/fib_hash.c
28811 --- linux-2.6.22.10/net/ipv4/fib_hash.c 2007-07-09 13:20:05 +0200
28812 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/fib_hash.c 2007-08-05 20:53:13 +0200
28813 @@ -1012,7 +1012,7 @@ static int fib_seq_show(struct seq_file
28814 prefix = f->fn_key;
28815 mask = FZ_MASK(iter->zone);
28816 flags = fib_flag_trans(fa->fa_type, mask, fi);
28818 + if (fi && nx_dev_visible(current->nx_info, fi->fib_dev))
28819 snprintf(bf, sizeof(bf),
28820 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u",
28821 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
28822 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/inet_connection_sock.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_connection_sock.c
28823 --- linux-2.6.22.10/net/ipv4/inet_connection_sock.c 2007-07-09 13:20:05 +0200
28824 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_connection_sock.c 2007-10-18 01:28:12 +0200
28825 @@ -34,10 +34,40 @@ EXPORT_SYMBOL(inet_csk_timer_bug_msg);
28827 int sysctl_local_port_range[2] = { 32768, 61000 };
28829 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
28831 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
28832 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
28834 + if (inet_v6_ipv6only(sk2))
28837 + if (sk1_rcv_saddr &&
28839 + sk1_rcv_saddr == sk2_rcv_saddr)
28842 + if (sk1_rcv_saddr &&
28843 + !sk2_rcv_saddr &&
28844 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
28847 + if (sk2_rcv_saddr &&
28848 + !sk1_rcv_saddr &&
28849 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
28852 + if (!sk1_rcv_saddr &&
28853 + !sk2_rcv_saddr &&
28854 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
28860 int inet_csk_bind_conflict(const struct sock *sk,
28861 const struct inet_bind_bucket *tb)
28863 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
28865 struct hlist_node *node;
28866 int reuse = sk->sk_reuse;
28867 @@ -50,9 +80,7 @@ int inet_csk_bind_conflict(const struct
28868 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
28869 if (!reuse || !sk2->sk_reuse ||
28870 sk2->sk_state == TCP_LISTEN) {
28871 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
28872 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
28873 - sk2_rcv_saddr == sk_rcv_saddr)
28874 + if (ipv4_rcv_saddr_equal(sk, sk2))
28878 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/inet_diag.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_diag.c
28879 --- linux-2.6.22.10/net/ipv4/inet_diag.c 2007-10-30 01:57:15 +0100
28880 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_diag.c 2007-10-30 02:36:32 +0100
28881 @@ -98,8 +98,8 @@ static int inet_csk_diag_fill(struct soc
28883 r->id.idiag_sport = inet->sport;
28884 r->id.idiag_dport = inet->dport;
28885 - r->id.idiag_src[0] = inet->rcv_saddr;
28886 - r->id.idiag_dst[0] = inet->daddr;
28887 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, inet->rcv_saddr);
28888 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
28890 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
28891 if (r->idiag_family == AF_INET6) {
28892 @@ -186,8 +186,8 @@ static int inet_twsk_diag_fill(struct in
28893 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
28894 r->id.idiag_sport = tw->tw_sport;
28895 r->id.idiag_dport = tw->tw_dport;
28896 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
28897 - r->id.idiag_dst[0] = tw->tw_daddr;
28898 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
28899 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
28900 r->idiag_state = tw->tw_substate;
28901 r->idiag_timer = 3;
28902 r->idiag_expires = (tmo * 1000 + HZ - 1) / HZ;
28903 @@ -239,6 +239,7 @@ static int inet_diag_get_exact(struct sk
28904 hashinfo = handler->idiag_hashinfo;
28906 if (req->idiag_family == AF_INET) {
28907 + /* TODO: lback */
28908 sk = inet_lookup(hashinfo, req->id.idiag_dst[0],
28909 req->id.idiag_dport, req->id.idiag_src[0],
28910 req->id.idiag_sport, req->id.idiag_if);
28911 @@ -478,6 +479,7 @@ static int inet_csk_diag_dump(struct soc
28915 + /* TODO: lback */
28916 entry.saddr = &inet->rcv_saddr;
28917 entry.daddr = &inet->daddr;
28919 @@ -514,6 +516,7 @@ static int inet_twsk_diag_dump(struct in
28923 + /* TODO: lback */
28924 entry.saddr = &tw->tw_rcv_saddr;
28925 entry.daddr = &tw->tw_daddr;
28927 @@ -560,8 +563,8 @@ static int inet_diag_fill_req(struct sk_
28929 r->id.idiag_sport = inet->sport;
28930 r->id.idiag_dport = ireq->rmt_port;
28931 - r->id.idiag_src[0] = ireq->loc_addr;
28932 - r->id.idiag_dst[0] = ireq->rmt_addr;
28933 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
28934 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
28935 r->idiag_expires = jiffies_to_msecs(tmo);
28936 r->idiag_rqueue = 0;
28937 r->idiag_wqueue = 0;
28938 @@ -631,6 +634,7 @@ static int inet_diag_dump_reqs(struct sk
28942 + /* TODO: lback */
28944 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
28945 (entry.family == AF_INET6) ?
28946 @@ -697,6 +701,8 @@ static int inet_diag_dump(struct sk_buff
28947 sk_for_each(sk, node, &hashinfo->listening_hash[i]) {
28948 struct inet_sock *inet = inet_sk(sk);
28950 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28955 @@ -757,6 +763,8 @@ skip_listen_ht:
28956 sk_for_each(sk, node, &head->chain) {
28957 struct inet_sock *inet = inet_sk(sk);
28959 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28963 if (!(r->idiag_states & (1 << sk->sk_state)))
28964 @@ -781,6 +789,8 @@ next_normal:
28965 inet_twsk_for_each(tw, node,
28968 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
28972 if (r->id.idiag_sport != tw->tw_sport &&
28973 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/inet_hashtables.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_hashtables.c
28974 --- linux-2.6.22.10/net/ipv4/inet_hashtables.c 2007-05-02 19:25:40 +0200
28975 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_hashtables.c 2007-08-05 20:53:13 +0200
28976 @@ -140,11 +140,10 @@ static struct sock *inet_lookup_listener
28977 const __be32 rcv_saddr = inet->rcv_saddr;
28978 int score = sk->sk_family == PF_INET ? 1 : 0;
28981 - if (rcv_saddr != daddr)
28983 + if (v4_inet_addr_match(sk->sk_nx_info, daddr, rcv_saddr))
28988 if (sk->sk_bound_dev_if) {
28989 if (sk->sk_bound_dev_if != dif)
28991 @@ -175,7 +174,7 @@ struct sock *__inet_lookup_listener(stru
28992 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
28994 if (inet->num == hnum && !sk->sk_node.next &&
28995 - (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
28996 + v4_inet_addr_match(sk->sk_nx_info, daddr, inet->rcv_saddr) &&
28997 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
28998 !sk->sk_bound_dev_if)
29000 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/raw.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/raw.c
29001 --- linux-2.6.22.10/net/ipv4/raw.c 2007-07-09 13:20:06 +0200
29002 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/raw.c 2007-10-05 12:29:05 +0200
29003 @@ -112,7 +112,7 @@ struct sock *__raw_v4_lookup(struct sock
29005 if (inet->num == num &&
29006 !(inet->daddr && inet->daddr != raddr) &&
29007 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
29008 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
29009 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
29010 goto found; /* gotcha */
29012 @@ -314,6 +314,12 @@ static int raw_send_hdrinc(struct sock *
29013 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
29017 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
29018 + sk->sk_nx_info &&
29019 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
29022 err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
29025 @@ -325,6 +331,7 @@ out:
29032 IP_INC_STATS(IPSTATS_MIB_OUTDISCARDS);
29033 @@ -491,6 +498,12 @@ static int raw_sendmsg(struct kiocb *ioc
29036 security_sk_classify_flow(sk, &fl);
29037 + if (sk->sk_nx_info) {
29038 + err = ip_v4_find_src(sk->sk_nx_info, &rt, &fl);
29043 err = ip_route_output_flow(&rt, &fl, sk, 1);
29046 @@ -553,17 +566,19 @@ static int raw_bind(struct sock *sk, str
29048 struct inet_sock *inet = inet_sk(sk);
29049 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
29050 + struct nx_v4_sock_addr nsa = { 0 };
29054 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
29056 - chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr);
29057 + v4_map_sock_addr(inet, addr, &nsa);
29058 + chk_addr_ret = inet_addr_type(nsa.saddr);
29059 ret = -EADDRNOTAVAIL;
29060 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
29061 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
29062 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
29064 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
29065 + v4_set_sock_addr(inet, &nsa);
29066 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
29067 inet->saddr = 0; /* Use device */
29069 @@ -615,7 +630,8 @@ static int raw_recvmsg(struct kiocb *ioc
29070 /* Copy the address. */
29072 sin->sin_family = AF_INET;
29073 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
29074 + sin->sin_addr.s_addr =
29075 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
29077 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
29079 @@ -795,7 +811,8 @@ static struct sock *raw_get_first(struct
29080 struct hlist_node *node;
29082 sk_for_each(sk, node, &raw_v4_htable[state->bucket])
29083 - if (sk->sk_family == PF_INET)
29084 + if (sk->sk_family == PF_INET &&
29085 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29089 @@ -811,7 +828,8 @@ static struct sock *raw_get_next(struct
29093 - } while (sk && sk->sk_family != PF_INET);
29094 + } while (sk && (sk->sk_family != PF_INET ||
29095 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
29097 if (!sk && ++state->bucket < RAWV4_HTABLE_SIZE) {
29098 sk = sk_head(&raw_v4_htable[state->bucket]);
29099 @@ -863,7 +881,10 @@ static __inline__ char *get_raw_sock(str
29101 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29102 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
29103 - i, src, srcp, dest, destp, sp->sk_state,
29105 + nx_map_sock_lback(current_nx_info(), src), srcp,
29106 + nx_map_sock_lback(current_nx_info(), dest), destp,
29108 atomic_read(&sp->sk_wmem_alloc),
29109 atomic_read(&sp->sk_rmem_alloc),
29110 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
29111 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/tcp.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp.c
29112 --- linux-2.6.22.10/net/ipv4/tcp.c 2007-10-30 01:57:15 +0100
29113 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp.c 2007-09-05 03:06:12 +0200
29114 @@ -258,6 +258,7 @@
29115 #include <linux/cache.h>
29116 #include <linux/err.h>
29117 #include <linux/crypto.h>
29118 +#include <linux/in.h>
29120 #include <net/icmp.h>
29121 #include <net/tcp.h>
29122 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/tcp_ipv4.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp_ipv4.c
29123 --- linux-2.6.22.10/net/ipv4/tcp_ipv4.c 2007-10-30 01:57:15 +0100
29124 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp_ipv4.c 2007-09-05 03:06:12 +0200
29125 @@ -1975,6 +1975,12 @@ static void *listening_get_next(struct s
29126 req = req->dl_next;
29129 + vxdprintk(VXD_CBIT(net, 6),
29130 + "sk,req: %p [#%d] (from %d)", req->sk,
29131 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
29133 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
29135 if (req->rsk_ops->family == st->family) {
29138 @@ -1999,6 +2005,10 @@ get_req:
29141 sk_for_each_from(sk, node) {
29142 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
29143 + sk, sk->sk_nid, nx_current_nid());
29144 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29146 if (sk->sk_family == st->family) {
29149 @@ -2050,18 +2060,26 @@ static void *established_get_first(struc
29151 read_lock(&tcp_hashinfo.ehash[st->bucket].lock);
29152 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
29153 - if (sk->sk_family != st->family) {
29154 + vxdprintk(VXD_CBIT(net, 6),
29155 + "sk,egf: %p [#%d] (from %d)",
29156 + sk, sk->sk_nid, nx_current_nid());
29157 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29159 + if (sk->sk_family != st->family)
29165 st->state = TCP_SEQ_STATE_TIME_WAIT;
29166 inet_twsk_for_each(tw, node,
29167 &tcp_hashinfo.ehash[st->bucket].twchain) {
29168 - if (tw->tw_family != st->family) {
29169 + vxdprintk(VXD_CBIT(net, 6),
29170 + "tw: %p [#%d] (from %d)",
29171 + tw, tw->tw_nid, nx_current_nid());
29172 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
29174 + if (tw->tw_family != st->family)
29180 @@ -2085,7 +2103,8 @@ static void *established_get_next(struct
29184 - while (tw && tw->tw_family != st->family) {
29185 + while (tw && (tw->tw_family != st->family ||
29186 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
29190 @@ -2109,6 +2128,11 @@ get_tw:
29193 sk_for_each_from(sk, node) {
29194 + vxdprintk(VXD_CBIT(net, 6),
29195 + "sk,egn: %p [#%d] (from %d)",
29196 + sk, sk->sk_nid, nx_current_nid());
29197 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29199 if (sk->sk_family == st->family)
29202 @@ -2284,9 +2308,9 @@ static void get_openreq4(struct sock *sk
29203 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29204 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p",
29207 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
29208 ntohs(inet_sk(sk)->sport),
29210 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
29211 ntohs(ireq->rmt_port),
29213 0, 0, /* could print option size, but that is af dependent. */
29214 @@ -2328,7 +2352,10 @@ static void get_tcp4_sock(struct sock *s
29216 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
29217 "%08X %5d %8d %lu %d %p %u %u %u %u %d",
29218 - i, src, srcp, dest, destp, sk->sk_state,
29220 + nx_map_sock_lback(current_nx_info(), src), srcp,
29221 + nx_map_sock_lback(current_nx_info(), dest), destp,
29223 tp->write_seq - tp->snd_una,
29224 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
29225 (tp->rcv_nxt - tp->copied_seq),
29226 @@ -2363,7 +2390,10 @@ static void get_timewait4_sock(struct in
29228 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29229 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p",
29230 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
29232 + nx_map_sock_lback(current_nx_info(), src), srcp,
29233 + nx_map_sock_lback(current_nx_info(), dest), destp,
29234 + tw->tw_substate, 0, 0,
29235 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
29236 atomic_read(&tw->tw_refcnt), tw);
29238 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/tcp_minisocks.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp_minisocks.c
29239 --- linux-2.6.22.10/net/ipv4/tcp_minisocks.c 2007-07-09 13:20:06 +0200
29240 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp_minisocks.c 2007-08-05 20:53:13 +0200
29242 #include <net/inet_common.h>
29243 #include <net/xfrm.h>
29245 +#include <linux/vs_limit.h>
29246 +#include <linux/vs_socket.h>
29247 +#include <linux/vs_context.h>
29249 #ifdef CONFIG_SYSCTL
29250 #define SYNC_INIT 0 /* let the user enable it */
29252 @@ -293,6 +297,11 @@ void tcp_time_wait(struct sock *sk, int
29253 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
29254 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
29256 + tw->tw_xid = sk->sk_xid;
29257 + tw->tw_vx_info = NULL;
29258 + tw->tw_nid = sk->sk_nid;
29259 + tw->tw_nx_info = NULL;
29261 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
29262 if (tw->tw_family == PF_INET6) {
29263 struct ipv6_pinfo *np = inet6_sk(sk);
29264 diff -NurpP --minimal linux-2.6.22.10/net/ipv4/udp.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/udp.c
29265 --- linux-2.6.22.10/net/ipv4/udp.c 2007-07-09 13:20:06 +0200
29266 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/udp.c 2007-10-09 14:09:19 +0200
29267 @@ -219,14 +219,7 @@ int udp_get_port(struct sock *sk, unsign
29268 return __udp_lib_get_port(sk, snum, udp_hash, &udp_port_rover, scmp);
29271 -int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
29273 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
29275 - return ( !ipv6_only_sock(sk2) &&
29276 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
29277 - inet1->rcv_saddr == inet2->rcv_saddr ));
29279 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
29281 static inline int udp_v4_get_port(struct sock *sk, unsigned short snum)
29283 @@ -246,15 +239,22 @@ static struct sock *__udp4_lib_lookup(__
29286 read_lock(&udp_hash_lock);
29288 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
29289 struct inet_sock *inet = inet_sk(sk);
29291 if (sk->sk_hash == hnum && !ipv6_only_sock(sk)) {
29292 int score = (sk->sk_family == PF_INET ? 1 : 0);
29294 if (inet->rcv_saddr) {
29295 if (inet->rcv_saddr != daddr)
29299 + /* block non nx_info ips */
29300 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
29301 + daddr, NXA_MASK_BIND))
29305 if (inet->daddr != saddr)
29306 @@ -280,6 +280,7 @@ static struct sock *__udp4_lib_lookup(__
29313 read_unlock(&udp_hash_lock);
29314 @@ -301,7 +302,7 @@ static inline struct sock *udp_v4_mcast_
29315 if (s->sk_hash != hnum ||
29316 (inet->daddr && inet->daddr != rmt_addr) ||
29317 (inet->dport != rmt_port && inet->dport) ||
29318 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
29319 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
29320 ipv6_only_sock(s) ||
29321 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
29323 @@ -631,7 +632,14 @@ int udp_sendmsg(struct kiocb *iocb, stru
29324 .uli_u = { .ports =
29325 { .sport = inet->sport,
29326 .dport = dport } } };
29327 + struct nx_info *nxi = sk->sk_nx_info;
29329 security_sk_classify_flow(sk, &fl);
29331 + err = ip_v4_find_src(nxi, &rt, &fl);
29335 err = ip_route_output_flow(&rt, &fl, sk, 1);
29337 if (err == -ENETUNREACH)
29338 @@ -871,7 +879,8 @@ try_again:
29340 sin->sin_family = AF_INET;
29341 sin->sin_port = udp_hdr(skb)->source;
29342 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
29343 + sin->sin_addr.s_addr = nx_map_sock_lback(
29344 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
29345 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
29347 if (inet->cmsg_flags)
29348 @@ -1551,7 +1560,8 @@ static struct sock *udp_get_first(struct
29349 for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) {
29350 struct hlist_node *node;
29351 sk_for_each(sk, node, state->hashtable + state->bucket) {
29352 - if (sk->sk_family == state->family)
29353 + if (sk->sk_family == state->family &&
29354 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29358 @@ -1568,7 +1578,8 @@ static struct sock *udp_get_next(struct
29362 - } while (sk && sk->sk_family != state->family);
29363 + } while (sk && (sk->sk_family != state->family ||
29364 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
29366 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
29367 sk = sk_head(state->hashtable + state->bucket);
29368 @@ -1681,7 +1692,10 @@ static void udp4_format_sock(struct sock
29370 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29371 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
29372 - bucket, src, srcp, dest, destp, sp->sk_state,
29374 + nx_map_sock_lback(current_nx_info(), src), srcp,
29375 + nx_map_sock_lback(current_nx_info(), dest), destp,
29377 atomic_read(&sp->sk_wmem_alloc),
29378 atomic_read(&sp->sk_rmem_alloc),
29379 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
29380 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/Kconfig linux-2.6.22.10-vs2.3.0.29/net/ipv6/Kconfig
29381 --- linux-2.6.22.10/net/ipv6/Kconfig 2007-07-09 13:20:06 +0200
29382 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/Kconfig 2007-08-05 20:53:13 +0200
29385 # IPv6 as module will cause a CRASH if you try to unload it
29387 - tristate "The IPv6 protocol"
29389 + bool "The IPv6 protocol"
29392 This is complemental support for the IP version 6.
29393 You will still be able to do traditional IPv4 networking as well.
29394 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/addrconf.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/addrconf.c
29395 --- linux-2.6.22.10/net/ipv6/addrconf.c 2007-10-30 01:57:15 +0100
29396 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/addrconf.c 2007-10-05 14:54:36 +0200
29399 #include <linux/proc_fs.h>
29400 #include <linux/seq_file.h>
29401 +#include <linux/vs_inet6.h>
29403 /* Set to 3 to get tracing... */
29404 #define ACONF_DEBUG 2
29405 @@ -897,7 +898,8 @@ static inline int ipv6_saddr_label(const
29408 int ipv6_dev_get_saddr(struct net_device *daddr_dev,
29409 - struct in6_addr *daddr, struct in6_addr *saddr)
29410 + struct in6_addr *daddr, struct in6_addr *saddr,
29411 + struct nx_info *nxi)
29413 struct ipv6_saddr_score hiscore;
29414 struct inet6_ifaddr *ifa_result = NULL;
29415 @@ -942,6 +944,10 @@ int ipv6_dev_get_saddr(struct net_device
29417 score.addr_type = __ipv6_addr_type(&ifa->addr);
29419 + /* Use only addresses assigned to the context */
29420 + if (!v6_ifa_in_nx_info(ifa, nxi))
29424 * - Tentative Address (RFC2462 section 5.4)
29425 * - A tentative address is not considered
29426 @@ -1155,9 +1161,10 @@ record_it:
29429 int ipv6_get_saddr(struct dst_entry *dst,
29430 - struct in6_addr *daddr, struct in6_addr *saddr)
29431 + struct in6_addr *daddr, struct in6_addr *saddr,
29432 + struct nx_info *nxi)
29434 - return ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, daddr, saddr);
29435 + return ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, daddr, saddr, nxi);
29438 EXPORT_SYMBOL(ipv6_get_saddr);
29439 @@ -1253,35 +1260,46 @@ struct inet6_ifaddr * ipv6_get_ifaddr(st
29443 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
29445 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
29447 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
29448 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
29449 - __be32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr;
29450 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
29451 int sk_ipv6only = ipv6_only_sock(sk);
29452 int sk2_ipv6only = inet_v6_ipv6only(sk2);
29453 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
29454 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
29456 - if (!sk2_rcv_saddr && !sk_ipv6only)
29457 + /* FIXME: needs handling for v4 ANY */
29458 + if (!sk2_rcv_saddr && !sk_ipv6only && !sk2->sk_nx_info)
29461 if (addr_type2 == IPV6_ADDR_ANY &&
29462 - !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
29463 + !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED) &&
29464 + v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1))
29467 if (addr_type == IPV6_ADDR_ANY &&
29468 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
29469 + !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED) &&
29470 + (sk2_rcv_saddr6 && v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1)))
29473 + if (addr_type == IPV6_ADDR_ANY &&
29474 + addr_type2 == IPV6_ADDR_ANY &&
29475 + nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info))
29478 if (sk2_rcv_saddr6 &&
29479 + addr_type != IPV6_ADDR_ANY &&
29480 + addr_type != IPV6_ADDR_ANY &&
29481 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
29484 if (addr_type == IPV6_ADDR_MAPPED &&
29486 - (!sk2_rcv_saddr || !sk_rcv_saddr || sk_rcv_saddr == sk2_rcv_saddr))
29487 + ipv4_rcv_saddr_equal(sk, sk2))
29491 @@ -2772,7 +2790,10 @@ static void if6_seq_stop(struct seq_file
29492 static int if6_seq_show(struct seq_file *seq, void *v)
29494 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
29497 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
29498 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
29500 NIP6_SEQFMT " %02x %02x %02x %02x %8s\n",
29502 ifp->idev->dev->ifindex,
29503 @@ -3254,6 +3275,11 @@ static int inet6_dump_addr(struct sk_buf
29504 struct inet6_ifaddr *ifa;
29505 struct ifmcaddr6 *ifmca;
29506 struct ifacaddr6 *ifaca;
29507 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
29509 + /* disable ipv6 on non v6 guests */
29510 + if (nxi && !nx_info_has_v6(nxi))
29513 s_idx = cb->args[0];
29514 s_ip_idx = ip_idx = cb->args[1];
29515 @@ -3275,6 +3301,8 @@ static int inet6_dump_addr(struct sk_buf
29516 ifa = ifa->if_next, ip_idx++) {
29517 if (ip_idx < s_ip_idx)
29519 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
29521 if ((err = inet6_fill_ifaddr(skb, ifa,
29522 NETLINK_CB(cb->skb).pid,
29523 cb->nlh->nlmsg_seq, RTM_NEWADDR,
29524 @@ -3288,6 +3316,8 @@ static int inet6_dump_addr(struct sk_buf
29525 ifmca = ifmca->next, ip_idx++) {
29526 if (ip_idx < s_ip_idx)
29528 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
29530 if ((err = inet6_fill_ifmcaddr(skb, ifmca,
29531 NETLINK_CB(cb->skb).pid,
29532 cb->nlh->nlmsg_seq, RTM_GETMULTICAST,
29533 @@ -3301,6 +3331,8 @@ static int inet6_dump_addr(struct sk_buf
29534 ifaca = ifaca->aca_next, ip_idx++) {
29535 if (ip_idx < s_ip_idx)
29537 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
29539 if ((err = inet6_fill_ifacaddr(skb, ifaca,
29540 NETLINK_CB(cb->skb).pid,
29541 cb->nlh->nlmsg_seq, RTM_GETANYCAST,
29542 @@ -3577,12 +3609,19 @@ static int inet6_dump_ifinfo(struct sk_b
29543 int s_idx = cb->args[0];
29544 struct net_device *dev;
29545 struct inet6_dev *idev;
29546 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
29548 + /* FIXME: maybe disable ipv6 on non v6 guests?
29549 + if (skb->sk && skb->sk->sk_vx_info)
29550 + return skb->len; */
29552 read_lock(&dev_base_lock);
29554 for_each_netdev(dev) {
29557 + if (!v6_dev_in_nx_info(dev, nxi))
29559 if ((idev = in6_dev_get(dev)) == NULL)
29561 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
29562 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/af_inet6.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/af_inet6.c
29563 --- linux-2.6.22.10/net/ipv6/af_inet6.c 2007-10-30 01:57:15 +0100
29564 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/af_inet6.c 2007-10-05 12:29:05 +0200
29566 #include <linux/netdevice.h>
29567 #include <linux/icmpv6.h>
29568 #include <linux/netfilter_ipv6.h>
29569 +#include <linux/vs_inet6.h>
29571 #include <net/ip.h>
29572 #include <net/ipv6.h>
29573 @@ -150,9 +151,12 @@ lookup_protocol:
29577 + if ((protocol == IPPROTO_ICMPV6) &&
29578 + nx_capable(answer->capability, NXC_RAW_ICMP))
29580 if (answer->capability > 0 && !capable(answer->capability))
29581 goto out_rcu_unlock;
29584 sock->ops = answer->ops;
29585 answer_prot = answer->prot;
29586 answer_no_check = answer->no_check;
29587 @@ -250,6 +254,7 @@ int inet6_bind(struct socket *sock, stru
29588 struct sock *sk = sock->sk;
29589 struct inet_sock *inet = inet_sk(sk);
29590 struct ipv6_pinfo *np = inet6_sk(sk);
29591 + struct nx_v6_sock_addr nsa;
29593 unsigned short snum;
29595 @@ -261,6 +266,11 @@ int inet6_bind(struct socket *sock, stru
29597 if (addr_len < SIN6_LEN_RFC2133)
29600 + err = v6_map_sock_addr(inet, addr, &nsa);
29604 addr_type = ipv6_addr_type(&addr->sin6_addr);
29605 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
29607 @@ -284,6 +294,10 @@ int inet6_bind(struct socket *sock, stru
29608 err = -EADDRNOTAVAIL;
29611 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
29612 + err = -EADDRNOTAVAIL;
29616 if (addr_type != IPV6_ADDR_ANY) {
29617 struct net_device *dev = NULL;
29618 @@ -309,6 +323,11 @@ int inet6_bind(struct socket *sock, stru
29622 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
29623 + err = -EADDRNOTAVAIL;
29627 /* ipv4 addr of the socket is invalid. Only the
29628 * unspecified and mapped address have a v4 equivalent.
29630 @@ -326,6 +345,8 @@ int inet6_bind(struct socket *sock, stru
29634 + v6_set_sock_addr(inet, &nsa);
29636 inet->rcv_saddr = v4addr;
29637 inet->saddr = v4addr;
29639 @@ -420,9 +441,11 @@ int inet6_getname(struct socket *sock, s
29641 sin->sin6_port = inet->dport;
29642 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
29643 + /* FIXME: remap lback? */
29645 sin->sin6_flowinfo = np->flow_label;
29647 + /* FIXME: remap lback? */
29648 if (ipv6_addr_any(&np->rcv_saddr))
29649 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
29651 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/fib6_rules.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/fib6_rules.c
29652 --- linux-2.6.22.10/net/ipv6/fib6_rules.c 2007-07-09 13:20:06 +0200
29653 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/fib6_rules.c 2007-08-12 00:22:19 +0200
29654 @@ -107,7 +107,7 @@ static int fib6_rule_action(struct fib_r
29655 r->src.plen && !(flags & RT6_LOOKUP_F_HAS_SADDR)) {
29656 struct in6_addr saddr;
29657 if (ipv6_get_saddr(&rt->u.dst, &flp->fl6_dst,
29661 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
29663 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/inet6_hashtables.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/inet6_hashtables.c
29664 --- linux-2.6.22.10/net/ipv6/inet6_hashtables.c 2007-05-02 19:25:45 +0200
29665 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/inet6_hashtables.c 2007-08-05 20:53:13 +0200
29668 #include <linux/module.h>
29669 #include <linux/random.h>
29670 +#include <linux/vs_inet6.h>
29672 #include <net/inet_connection_sock.h>
29673 #include <net/inet_hashtables.h>
29674 @@ -121,6 +122,9 @@ struct sock *inet6_lookup_listener(struc
29675 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
29679 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
29682 if (sk->sk_bound_dev_if) {
29683 if (sk->sk_bound_dev_if != dif)
29684 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/ip6_output.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/ip6_output.c
29685 --- linux-2.6.22.10/net/ipv6/ip6_output.c 2007-10-30 01:57:15 +0100
29686 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/ip6_output.c 2007-09-30 14:58:01 +0200
29687 @@ -884,7 +884,7 @@ static int ip6_dst_lookup_tail(struct so
29688 goto out_err_release;
29690 if (ipv6_addr_any(&fl->fl6_src)) {
29691 - err = ipv6_get_saddr(*dst, &fl->fl6_dst, &fl->fl6_src);
29692 + err = ipv6_get_saddr(*dst, &fl->fl6_dst, &fl->fl6_src, sk->sk_nx_info);
29694 goto out_err_release;
29696 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/ndisc.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/ndisc.c
29697 --- linux-2.6.22.10/net/ipv6/ndisc.c 2007-10-30 01:57:15 +0100
29698 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/ndisc.c 2007-09-30 14:58:01 +0200
29699 @@ -531,7 +531,7 @@ static void ndisc_send_na(struct net_dev
29703 - if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr))
29704 + if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr, NULL))
29706 src_addr = &tmpaddr;
29708 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/route.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/route.c
29709 --- linux-2.6.22.10/net/ipv6/route.c 2007-07-09 13:20:06 +0200
29710 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/route.c 2007-08-12 00:22:19 +0200
29711 @@ -2182,7 +2182,7 @@ static int rt6_fill_node(struct sk_buff
29712 NLA_PUT_U32(skb, RTA_IIF, iif);
29714 struct in6_addr saddr_buf;
29715 - if (ipv6_get_saddr(&rt->u.dst, dst, &saddr_buf) == 0)
29716 + if (ipv6_get_saddr(&rt->u.dst, dst, &saddr_buf, skb->sk->sk_nx_info) == 0)
29717 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
29720 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/tcp_ipv6.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/tcp_ipv6.c
29721 --- linux-2.6.22.10/net/ipv6/tcp_ipv6.c 2007-10-30 01:57:15 +0100
29722 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/tcp_ipv6.c 2007-09-18 12:32:20 +0200
29725 #include <linux/crypto.h>
29726 #include <linux/scatterlist.h>
29727 +#include <linux/vs_inet6.h>
29729 /* Socket used for sending RSTs and ACKs */
29730 static struct socket *tcp6_socket;
29731 @@ -160,8 +161,15 @@ static int tcp_v6_connect(struct sock *s
29732 * connect() to INADDR_ANY means loopback (BSD'ism).
29735 - if(ipv6_addr_any(&usin->sin6_addr))
29736 - usin->sin6_addr.s6_addr[15] = 0x1;
29737 + if(ipv6_addr_any(&usin->sin6_addr)) {
29738 + struct nx_info *nxi = sk->sk_nx_info;
29740 + if (nxi && nx_info_has_v6(nxi))
29741 + /* FIXME: remap lback? */
29742 + usin->sin6_addr = nxi->v6.ip;
29744 + usin->sin6_addr.s6_addr[15] = 0x1;
29747 addr_type = ipv6_addr_type(&usin->sin6_addr);
29749 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/udp.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/udp.c
29750 --- linux-2.6.22.10/net/ipv6/udp.c 2007-07-09 13:20:06 +0200
29751 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/udp.c 2007-08-12 03:34:32 +0200
29754 #include <linux/proc_fs.h>
29755 #include <linux/seq_file.h>
29756 +#include <linux/vs_inet6.h>
29757 #include "udp_impl.h"
29759 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
29760 @@ -82,6 +83,10 @@ static struct sock *__udp6_lib_lookup(st
29761 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
29765 + /* block non nx_info ips */
29766 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
29769 if (!ipv6_addr_any(&np->daddr)) {
29770 if (!ipv6_addr_equal(&np->daddr, saddr))
29771 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/xfrm6_policy.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/xfrm6_policy.c
29772 --- linux-2.6.22.10/net/ipv6/xfrm6_policy.c 2007-07-09 13:20:06 +0200
29773 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/xfrm6_policy.c 2007-08-12 00:22:19 +0200
29774 @@ -49,7 +49,7 @@ static int xfrm6_get_saddr(xfrm_address_
29776 if (!xfrm6_dst_lookup((struct xfrm_dst **)&rt, &fl_tunnel)) {
29777 ipv6_get_saddr(&rt->u.dst, (struct in6_addr *)&daddr->a6,
29778 - (struct in6_addr *)&saddr->a6);
29779 + (struct in6_addr *)&saddr->a6, NULL);
29780 dst_release(&rt->u.dst);
29783 diff -NurpP --minimal linux-2.6.22.10/net/netlink/af_netlink.c linux-2.6.22.10-vs2.3.0.29/net/netlink/af_netlink.c
29784 --- linux-2.6.22.10/net/netlink/af_netlink.c 2007-07-09 13:20:07 +0200
29785 +++ linux-2.6.22.10-vs2.3.0.29/net/netlink/af_netlink.c 2007-08-05 20:53:13 +0200
29787 #include <linux/audit.h>
29788 #include <linux/selinux.h>
29789 #include <linux/mutex.h>
29790 +#include <linux/vs_context.h>
29791 +#include <linux/vs_network.h>
29792 +#include <linux/vs_limit.h>
29794 #include <net/sock.h>
29795 #include <net/scm.h>
29796 diff -NurpP --minimal linux-2.6.22.10/net/sctp/ipv6.c linux-2.6.22.10-vs2.3.0.29/net/sctp/ipv6.c
29797 --- linux-2.6.22.10/net/sctp/ipv6.c 2007-10-30 01:57:15 +0100
29798 +++ linux-2.6.22.10-vs2.3.0.29/net/sctp/ipv6.c 2007-08-12 00:22:19 +0200
29799 @@ -303,7 +303,7 @@ static void sctp_v6_get_saddr(struct sct
29800 __FUNCTION__, asoc, dst, NIP6(daddr->v6.sin6_addr));
29803 - ipv6_get_saddr(dst, &daddr->v6.sin6_addr,&saddr->v6.sin6_addr);
29804 + ipv6_get_saddr(dst, &daddr->v6.sin6_addr,&saddr->v6.sin6_addr, asoc->base.sk->sk_nx_info);
29805 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: " NIP6_FMT "\n",
29806 NIP6(saddr->v6.sin6_addr));
29808 diff -NurpP --minimal linux-2.6.22.10/net/socket.c linux-2.6.22.10-vs2.3.0.29/net/socket.c
29809 --- linux-2.6.22.10/net/socket.c 2007-10-30 01:57:15 +0100
29810 +++ linux-2.6.22.10-vs2.3.0.29/net/socket.c 2007-09-05 03:06:12 +0200
29813 #include <net/sock.h>
29814 #include <linux/netfilter.h>
29815 +#include <linux/vs_base.h>
29816 +#include <linux/vs_socket.h>
29817 +#include <linux/vs_inet.h>
29818 +#include <linux/vs_inet6.h>
29820 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
29821 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
29822 @@ -543,7 +547,7 @@ static inline int __sock_sendmsg(struct
29823 struct msghdr *msg, size_t size)
29825 struct sock_iocb *si = kiocb_to_siocb(iocb);
29831 @@ -554,7 +558,22 @@ static inline int __sock_sendmsg(struct
29835 - return sock->ops->sendmsg(iocb, sock, msg, size);
29836 + len = sock->ops->sendmsg(iocb, sock, msg, size);
29839 + vx_sock_send(sock->sk, size);
29841 + vx_sock_fail(sock->sk, size);
29843 + vxdprintk(VXD_CBIT(net, 7),
29844 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29846 + (sock->sk)?sock->sk->sk_nx_info:0,
29847 + (sock->sk)?sock->sk->sk_vx_info:0,
29848 + (sock->sk)?sock->sk->sk_xid:0,
29849 + (sock->sk)?sock->sk->sk_nid:0,
29850 + (unsigned int)size, len);
29854 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
29855 @@ -623,7 +642,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
29856 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
29857 struct msghdr *msg, size_t size, int flags)
29861 struct sock_iocb *si = kiocb_to_siocb(iocb);
29864 @@ -636,7 +655,18 @@ static inline int __sock_recvmsg(struct
29868 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
29869 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
29870 + if ((len >= 0) && sock->sk)
29871 + vx_sock_recv(sock->sk, len);
29872 + vxdprintk(VXD_CBIT(net, 7),
29873 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29875 + (sock->sk)?sock->sk->sk_nx_info:0,
29876 + (sock->sk)?sock->sk->sk_vx_info:0,
29877 + (sock->sk)?sock->sk->sk_xid:0,
29878 + (sock->sk)?sock->sk->sk_nid:0,
29879 + (unsigned int)size, len);
29883 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
29884 @@ -1090,6 +1120,13 @@ static int __sock_create(int family, int
29885 if (type < 0 || type >= SOCK_MAX)
29888 + if (!nx_check(0, VS_ADMIN)) {
29889 + if (family == PF_INET && !current_nx_info_has_v4())
29890 + return -EAFNOSUPPORT;
29891 + if (family == PF_INET6 && !current_nx_info_has_v6())
29892 + return -EAFNOSUPPORT;
29897 This uglymoron is moved from INET layer to here to avoid
29898 @@ -1207,6 +1244,7 @@ asmlinkage long sys_socket(int family, i
29902 + set_bit(SOCK_USER_SOCKET, &sock->flags);
29903 retval = sock_map_fd(sock);
29906 @@ -1239,10 +1277,12 @@ asmlinkage long sys_socketpair(int famil
29907 err = sock_create(family, type, protocol, &sock1);
29910 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
29912 err = sock_create(family, type, protocol, &sock2);
29914 goto out_release_1;
29915 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
29917 err = sock1->ops->socketpair(sock1, sock2);
29919 diff -NurpP --minimal linux-2.6.22.10/net/sunrpc/auth.c linux-2.6.22.10-vs2.3.0.29/net/sunrpc/auth.c
29920 --- linux-2.6.22.10/net/sunrpc/auth.c 2007-05-02 19:25:48 +0200
29921 +++ linux-2.6.22.10-vs2.3.0.29/net/sunrpc/auth.c 2007-08-05 20:53:13 +0200
29923 #include <linux/errno.h>
29924 #include <linux/sunrpc/clnt.h>
29925 #include <linux/spinlock.h>
29926 +#include <linux/vs_tag.h>
29929 # define RPCDBG_FACILITY RPCDBG_AUTH
29930 @@ -263,6 +264,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
29931 struct auth_cred acred = {
29932 .uid = current->fsuid,
29933 .gid = current->fsgid,
29934 + .tag = dx_current_tag(),
29935 .group_info = current->group_info,
29937 struct rpc_cred *ret;
29938 @@ -282,6 +284,7 @@ rpcauth_bindcred(struct rpc_task *task)
29939 struct auth_cred acred = {
29940 .uid = current->fsuid,
29941 .gid = current->fsgid,
29942 + .tag = dx_current_tag(),
29943 .group_info = current->group_info,
29945 struct rpc_cred *ret;
29946 diff -NurpP --minimal linux-2.6.22.10/net/sunrpc/auth_unix.c linux-2.6.22.10-vs2.3.0.29/net/sunrpc/auth_unix.c
29947 --- linux-2.6.22.10/net/sunrpc/auth_unix.c 2007-05-02 19:25:48 +0200
29948 +++ linux-2.6.22.10-vs2.3.0.29/net/sunrpc/auth_unix.c 2007-08-05 20:53:13 +0200
29949 @@ -11,12 +11,14 @@
29950 #include <linux/module.h>
29951 #include <linux/sunrpc/clnt.h>
29952 #include <linux/sunrpc/auth.h>
29953 +#include <linux/vs_tag.h>
29955 #define NFS_NGROUPS 16
29958 struct rpc_cred uc_base;
29961 gid_t uc_gids[NFS_NGROUPS];
29963 #define uc_uid uc_base.cr_uid
29964 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
29965 if (flags & RPCAUTH_LOOKUP_ROOTCREDS) {
29968 + cred->uc_tag = dx_current_tag();
29969 cred->uc_gids[0] = NOGROUP;
29971 int groups = acred->group_info->ngroups;
29972 @@ -87,6 +90,7 @@ unx_create_cred(struct rpc_auth *auth, s
29974 cred->uc_uid = acred->uid;
29975 cred->uc_gid = acred->gid;
29976 + cred->uc_tag = acred->tag;
29977 for (i = 0; i < groups; i++)
29978 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
29979 if (i < NFS_NGROUPS)
29980 @@ -118,7 +122,8 @@ unx_match(struct auth_cred *acred, struc
29983 if (cred->uc_uid != acred->uid
29984 - || cred->uc_gid != acred->gid)
29985 + || cred->uc_gid != acred->gid
29986 + || cred->uc_tag != acred->tag)
29989 groups = acred->group_info->ngroups;
29990 @@ -144,7 +149,7 @@ unx_marshal(struct rpc_task *task, __be3
29991 struct rpc_clnt *clnt = task->tk_client;
29992 struct unx_cred *cred = (struct unx_cred *) task->tk_msg.rpc_cred;
29993 __be32 *base, *hold;
29997 *p++ = htonl(RPC_AUTH_UNIX);
29999 @@ -154,9 +159,12 @@ unx_marshal(struct rpc_task *task, __be3
30000 * Copy the UTS nodename captured when the client was created.
30002 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
30003 + tag = task->tk_client->cl_tag;
30005 - *p++ = htonl((u32) cred->uc_uid);
30006 - *p++ = htonl((u32) cred->uc_gid);
30007 + *p++ = htonl((u32) TAGINO_UID(tag,
30008 + cred->uc_uid, cred->uc_tag));
30009 + *p++ = htonl((u32) TAGINO_GID(tag,
30010 + cred->uc_gid, cred->uc_tag));
30012 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
30013 *p++ = htonl((u32) cred->uc_gids[i]);
30014 diff -NurpP --minimal linux-2.6.22.10/net/sunrpc/clnt.c linux-2.6.22.10-vs2.3.0.29/net/sunrpc/clnt.c
30015 --- linux-2.6.22.10/net/sunrpc/clnt.c 2007-07-09 13:20:13 +0200
30016 +++ linux-2.6.22.10-vs2.3.0.29/net/sunrpc/clnt.c 2007-08-05 20:53:13 +0200
30018 #include <linux/smp_lock.h>
30019 #include <linux/utsname.h>
30020 #include <linux/workqueue.h>
30021 +#include <linux/vs_cvirt.h>
30023 #include <linux/sunrpc/clnt.h>
30024 #include <linux/sunrpc/rpc_pipe_fs.h>
30025 @@ -249,7 +250,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
30026 clnt->cl_oneshot = 1;
30027 if (args->flags & RPC_CLNT_CREATE_DISCRTRY)
30028 clnt->cl_discrtry = 1;
30030 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
30031 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
30032 + clnt->cl_tag = 1; */
30035 EXPORT_SYMBOL_GPL(rpc_create);
30036 diff -NurpP --minimal linux-2.6.22.10/net/unix/af_unix.c linux-2.6.22.10-vs2.3.0.29/net/unix/af_unix.c
30037 --- linux-2.6.22.10/net/unix/af_unix.c 2007-07-09 13:20:13 +0200
30038 +++ linux-2.6.22.10-vs2.3.0.29/net/unix/af_unix.c 2007-08-05 20:53:13 +0200
30039 @@ -115,6 +115,8 @@
30040 #include <linux/mount.h>
30041 #include <net/checksum.h>
30042 #include <linux/security.h>
30043 +#include <linux/vs_context.h>
30044 +#include <linux/vs_limit.h>
30046 int sysctl_unix_max_dgram_qlen __read_mostly = 10;
30048 @@ -252,6 +254,8 @@ static struct sock *__unix_find_socket_b
30049 sk_for_each(s, node, &unix_socket_table[hash ^ type]) {
30050 struct unix_sock *u = unix_sk(s);
30052 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
30054 if (u->addr->len == len &&
30055 !memcmp(u->addr->name, sunname, len))
30057 @@ -807,7 +811,7 @@ static int unix_bind(struct socket *sock
30060 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
30061 - err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
30062 + err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0, NULL);
30064 goto out_mknod_dput;
30065 mutex_unlock(&nd.dentry->d_inode->i_mutex);
30066 diff -NurpP --minimal linux-2.6.22.10/net/x25/af_x25.c linux-2.6.22.10-vs2.3.0.29/net/x25/af_x25.c
30067 --- linux-2.6.22.10/net/x25/af_x25.c 2007-07-09 13:20:13 +0200
30068 +++ linux-2.6.22.10-vs2.3.0.29/net/x25/af_x25.c 2007-08-05 20:53:13 +0200
30069 @@ -500,7 +500,10 @@ static int x25_create(struct socket *soc
30073 - sock_init_data(sock, sk);
30074 + sk->sk_socket = sock;
30075 + sk->sk_type = sock->type;
30076 + sk->sk_sleep = &sock->wait;
30079 x25_init_timers(sk);
30081 diff -NurpP --minimal linux-2.6.22.10/security/Kconfig linux-2.6.22.10-vs2.3.0.29/security/Kconfig
30082 --- linux-2.6.22.10/security/Kconfig 2006-11-30 21:19:47 +0100
30083 +++ linux-2.6.22.10-vs2.3.0.29/security/Kconfig 2007-08-05 20:53:13 +0200
30084 @@ -6,6 +6,7 @@ menu "Security options"
30087 bool "Enable access key retention support"
30088 + depends on !VSERVER_SECURITY
30090 This option provides support for retaining authentication tokens and
30091 access keys in the kernel.
30092 diff -NurpP --minimal linux-2.6.22.10/security/commoncap.c linux-2.6.22.10-vs2.3.0.29/security/commoncap.c
30093 --- linux-2.6.22.10/security/commoncap.c 2007-07-09 13:20:14 +0200
30094 +++ linux-2.6.22.10-vs2.3.0.29/security/commoncap.c 2007-08-05 20:53:13 +0200
30095 @@ -22,10 +22,11 @@
30096 #include <linux/ptrace.h>
30097 #include <linux/xattr.h>
30098 #include <linux/hugetlb.h>
30099 +#include <linux/vs_context.h>
30101 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
30103 - NETLINK_CB(skb).eff_cap = current->cap_effective;
30104 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
30108 @@ -43,7 +44,7 @@ EXPORT_SYMBOL(cap_netlink_recv);
30109 int cap_capable (struct task_struct *tsk, int cap)
30111 /* Derived from include/linux/sched.h:capable. */
30112 - if (cap_raised(tsk->cap_effective, cap))
30113 + if (vx_cap_raised(tsk->vx_info, tsk->cap_effective, cap))
30117 @@ -141,7 +142,8 @@ void cap_bprm_apply_creds (struct linux_
30118 /* Derived from fs/exec.c:compute_creds. */
30119 kernel_cap_t new_permitted, working;
30121 - new_permitted = cap_intersect (bprm->cap_permitted, cap_bset);
30122 + new_permitted = cap_intersect (bprm->cap_permitted,
30123 + vx_current_cap_bset());
30124 working = cap_intersect (bprm->cap_inheritable,
30125 current->cap_inheritable);
30126 new_permitted = cap_combine (new_permitted, working);
30127 @@ -310,7 +312,8 @@ void cap_task_reparent_to_init (struct t
30129 int cap_syslog (int type)
30131 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
30132 + if ((type != 3 && type != 10) &&
30133 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
30137 diff -NurpP --minimal linux-2.6.22.10/security/dummy.c linux-2.6.22.10-vs2.3.0.29/security/dummy.c
30138 --- linux-2.6.22.10/security/dummy.c 2007-05-02 19:25:51 +0200
30139 +++ linux-2.6.22.10-vs2.3.0.29/security/dummy.c 2007-08-05 20:53:13 +0200
30141 #include <linux/hugetlb.h>
30142 #include <linux/ptrace.h>
30143 #include <linux/file.h>
30144 +#include <linux/vs_context.h>
30146 static int dummy_ptrace (struct task_struct *parent, struct task_struct *child)
30148 @@ -678,7 +679,7 @@ static int dummy_sem_semop (struct sem_a
30150 static int dummy_netlink_send (struct sock *sk, struct sk_buff *skb)
30152 - NETLINK_CB(skb).eff_cap = current->cap_effective;
30153 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
30157 diff -NurpP --minimal linux-2.6.22.10/security/selinux/hooks.c linux-2.6.22.10-vs2.3.0.29/security/selinux/hooks.c
30158 --- linux-2.6.22.10/security/selinux/hooks.c 2007-10-30 01:57:15 +0100
30159 +++ linux-2.6.22.10-vs2.3.0.29/security/selinux/hooks.c 2007-10-30 01:21:54 +0100
30161 #include <linux/dccp.h>
30162 #include <linux/quota.h>
30163 #include <linux/un.h> /* for Unix socket types */
30164 -#include <net/af_unix.h> /* for Unix socket types */
30165 #include <linux/parser.h>
30166 #include <linux/nfs_mount.h>
30167 #include <net/ipv6.h>