1 diff -NurpP --minimal linux-2.6.36/Documentation/vserver/debug.txt linux-2.6.36-vs2.3.0.36.38/Documentation/vserver/debug.txt
2 --- linux-2.6.36/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.36-vs2.3.0.36.38/Documentation/vserver/debug.txt 2010-10-21 13:09:36.000000000 +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.36/arch/alpha/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/alpha/Kconfig
160 --- linux-2.6.36/arch/alpha/Kconfig 2010-10-21 13:06:45.000000000 +0200
161 +++ linux-2.6.36-vs2.3.0.36.38/arch/alpha/Kconfig 2010-10-21 13:09:36.000000000 +0200
162 @@ -677,6 +677,8 @@ config DUMMY_CONSOLE
166 +source "kernel/vserver/Kconfig"
168 source "security/Kconfig"
170 source "crypto/Kconfig"
171 diff -NurpP --minimal linux-2.6.36/arch/alpha/kernel/entry.S linux-2.6.36-vs2.3.0.36.38/arch/alpha/kernel/entry.S
172 --- linux-2.6.36/arch/alpha/kernel/entry.S 2010-10-21 13:06:45.000000000 +0200
173 +++ linux-2.6.36-vs2.3.0.36.38/arch/alpha/kernel/entry.S 2010-10-21 13:09:36.000000000 +0200
174 @@ -860,24 +860,15 @@ sys_getxgid:
181 - ldq $2, TI_TASK($8)
183 - /* See linux/kernel/timer.c sys_getppid for discussion
184 - about this loop. */
185 - ldq $3, TASK_GROUP_LEADER($2)
186 - ldq $4, TASK_REAL_PARENT($3)
187 - ldl $0, TASK_TGID($2)
188 -1: ldl $1, TASK_TGID($4)
192 - ldq $3, TASK_GROUP_LEADER($2)
193 - ldq $4, TASK_REAL_PARENT($3)
199 + jsr $26, do_getxpid
206 diff -NurpP --minimal linux-2.6.36/arch/alpha/kernel/ptrace.c linux-2.6.36-vs2.3.0.36.38/arch/alpha/kernel/ptrace.c
207 --- linux-2.6.36/arch/alpha/kernel/ptrace.c 2010-07-07 18:30:51.000000000 +0200
208 +++ linux-2.6.36-vs2.3.0.36.38/arch/alpha/kernel/ptrace.c 2010-10-21 13:09:36.000000000 +0200
210 #include <linux/user.h>
211 #include <linux/security.h>
212 #include <linux/signal.h>
213 +#include <linux/vs_base.h>
215 #include <asm/uaccess.h>
216 #include <asm/pgtable.h>
217 diff -NurpP --minimal linux-2.6.36/arch/alpha/kernel/systbls.S linux-2.6.36-vs2.3.0.36.38/arch/alpha/kernel/systbls.S
218 --- linux-2.6.36/arch/alpha/kernel/systbls.S 2010-10-21 13:06:46.000000000 +0200
219 +++ linux-2.6.36-vs2.3.0.36.38/arch/alpha/kernel/systbls.S 2010-10-21 13:09:36.000000000 +0200
220 @@ -446,7 +446,7 @@ sys_call_table:
221 .quad sys_stat64 /* 425 */
224 - .quad sys_ni_syscall /* sys_vserver */
225 + .quad sys_vserver /* sys_vserver */
226 .quad sys_ni_syscall /* sys_mbind */
227 .quad sys_ni_syscall /* sys_get_mempolicy */
228 .quad sys_ni_syscall /* sys_set_mempolicy */
229 diff -NurpP --minimal linux-2.6.36/arch/alpha/kernel/traps.c linux-2.6.36-vs2.3.0.36.38/arch/alpha/kernel/traps.c
230 --- linux-2.6.36/arch/alpha/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
231 +++ linux-2.6.36-vs2.3.0.36.38/arch/alpha/kernel/traps.c 2010-10-21 13:09:36.000000000 +0200
232 @@ -183,7 +183,8 @@ die_if_kernel(char * str, struct pt_regs
234 printk("CPU %d ", hard_smp_processor_id());
236 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
237 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
238 + task_pid_nr(current), current->xid, str, err);
239 dik_show_regs(regs, r9_15);
240 add_taint(TAINT_DIE);
241 dik_show_trace((unsigned long *)(regs+1));
242 diff -NurpP --minimal linux-2.6.36/arch/arm/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/arm/Kconfig
243 --- linux-2.6.36/arch/arm/Kconfig 2010-10-21 13:06:46.000000000 +0200
244 +++ linux-2.6.36-vs2.3.0.36.38/arch/arm/Kconfig 2010-10-21 13:09:36.000000000 +0200
245 @@ -1803,6 +1803,8 @@ source "fs/Kconfig"
247 source "arch/arm/Kconfig.debug"
249 +source "kernel/vserver/Kconfig"
251 source "security/Kconfig"
253 source "crypto/Kconfig"
254 diff -NurpP --minimal linux-2.6.36/arch/arm/include/asm/tlb.h linux-2.6.36-vs2.3.0.36.38/arch/arm/include/asm/tlb.h
255 --- linux-2.6.36/arch/arm/include/asm/tlb.h 2009-09-10 15:25:15.000000000 +0200
256 +++ linux-2.6.36-vs2.3.0.36.38/arch/arm/include/asm/tlb.h 2010-10-21 13:09:36.000000000 +0200
259 #else /* !CONFIG_MMU */
261 +#include <linux/vs_memory.h>
262 #include <asm/pgalloc.h>
265 diff -NurpP --minimal linux-2.6.36/arch/arm/kernel/calls.S linux-2.6.36-vs2.3.0.36.38/arch/arm/kernel/calls.S
266 --- linux-2.6.36/arch/arm/kernel/calls.S 2010-10-21 13:06:46.000000000 +0200
267 +++ linux-2.6.36-vs2.3.0.36.38/arch/arm/kernel/calls.S 2010-10-21 13:09:36.000000000 +0200
269 /* 310 */ CALL(sys_request_key)
271 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
272 -/* vserver */ CALL(sys_ni_syscall)
275 /* 315 */ CALL(sys_ioprio_get)
276 CALL(sys_inotify_init)
277 diff -NurpP --minimal linux-2.6.36/arch/arm/kernel/process.c linux-2.6.36-vs2.3.0.36.38/arch/arm/kernel/process.c
278 --- linux-2.6.36/arch/arm/kernel/process.c 2010-10-21 13:06:46.000000000 +0200
279 +++ linux-2.6.36-vs2.3.0.36.38/arch/arm/kernel/process.c 2010-10-21 13:09:36.000000000 +0200
280 @@ -295,7 +295,8 @@ void __show_regs(struct pt_regs *regs)
281 void show_regs(struct pt_regs * regs)
284 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
285 + printk("Pid: %d[#%u], comm: %20s\n",
286 + task_pid_nr(current), current->xid, current->comm);
290 diff -NurpP --minimal linux-2.6.36/arch/arm/kernel/traps.c linux-2.6.36-vs2.3.0.36.38/arch/arm/kernel/traps.c
291 --- linux-2.6.36/arch/arm/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
292 +++ linux-2.6.36-vs2.3.0.36.38/arch/arm/kernel/traps.c 2010-10-21 13:09:36.000000000 +0200
293 @@ -244,8 +244,8 @@ static int __die(const char *str, int er
297 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
298 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
299 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
300 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
302 if (!user_mode(regs) || in_interrupt()) {
303 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
304 diff -NurpP --minimal linux-2.6.36/arch/cris/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/cris/Kconfig
305 --- linux-2.6.36/arch/cris/Kconfig 2010-10-21 13:06:51.000000000 +0200
306 +++ linux-2.6.36-vs2.3.0.36.38/arch/cris/Kconfig 2010-10-21 13:09:36.000000000 +0200
307 @@ -694,6 +694,8 @@ source "drivers/staging/Kconfig"
309 source "arch/cris/Kconfig.debug"
311 +source "kernel/vserver/Kconfig"
313 source "security/Kconfig"
315 source "crypto/Kconfig"
316 diff -NurpP --minimal linux-2.6.36/arch/frv/kernel/kernel_thread.S linux-2.6.36-vs2.3.0.36.38/arch/frv/kernel/kernel_thread.S
317 --- linux-2.6.36/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
318 +++ linux-2.6.36-vs2.3.0.36.38/arch/frv/kernel/kernel_thread.S 2010-10-21 13:09:36.000000000 +0200
319 @@ -37,7 +37,7 @@ kernel_thread:
321 # start by forking the current process, but with shared VM
322 setlos.p #__NR_clone,gr7 ; syscall number
323 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
324 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
325 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
327 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
328 diff -NurpP --minimal linux-2.6.36/arch/h8300/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/h8300/Kconfig
329 --- linux-2.6.36/arch/h8300/Kconfig 2010-10-21 13:06:51.000000000 +0200
330 +++ linux-2.6.36-vs2.3.0.36.38/arch/h8300/Kconfig 2010-10-21 13:09:36.000000000 +0200
331 @@ -226,6 +226,8 @@ source "fs/Kconfig"
333 source "arch/h8300/Kconfig.debug"
335 +source "kernel/vserver/Kconfig"
337 source "security/Kconfig"
339 source "crypto/Kconfig"
340 diff -NurpP --minimal linux-2.6.36/arch/ia64/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/ia64/Kconfig
341 --- linux-2.6.36/arch/ia64/Kconfig 2010-10-21 13:06:52.000000000 +0200
342 +++ linux-2.6.36-vs2.3.0.36.38/arch/ia64/Kconfig 2010-10-21 13:09:36.000000000 +0200
343 @@ -671,6 +671,8 @@ source "fs/Kconfig"
345 source "arch/ia64/Kconfig.debug"
347 +source "kernel/vserver/Kconfig"
349 source "security/Kconfig"
351 source "crypto/Kconfig"
352 diff -NurpP --minimal linux-2.6.36/arch/ia64/include/asm/tlb.h linux-2.6.36-vs2.3.0.36.38/arch/ia64/include/asm/tlb.h
353 --- linux-2.6.36/arch/ia64/include/asm/tlb.h 2010-02-25 11:51:26.000000000 +0100
354 +++ linux-2.6.36-vs2.3.0.36.38/arch/ia64/include/asm/tlb.h 2010-10-21 13:09:36.000000000 +0200
356 #include <linux/mm.h>
357 #include <linux/pagemap.h>
358 #include <linux/swap.h>
359 +#include <linux/vs_memory.h>
361 #include <asm/pgalloc.h>
362 #include <asm/processor.h>
363 diff -NurpP --minimal linux-2.6.36/arch/ia64/kernel/entry.S linux-2.6.36-vs2.3.0.36.38/arch/ia64/kernel/entry.S
364 --- linux-2.6.36/arch/ia64/kernel/entry.S 2010-10-21 13:06:52.000000000 +0200
365 +++ linux-2.6.36-vs2.3.0.36.38/arch/ia64/kernel/entry.S 2010-10-21 13:09:36.000000000 +0200
366 @@ -1714,7 +1714,7 @@ sys_call_table:
368 data8 sys_mq_getsetattr
370 - data8 sys_ni_syscall // reserved for vserver
372 data8 sys_waitid // 1270
374 data8 sys_request_key
375 diff -NurpP --minimal linux-2.6.36/arch/ia64/kernel/perfmon.c linux-2.6.36-vs2.3.0.36.38/arch/ia64/kernel/perfmon.c
376 --- linux-2.6.36/arch/ia64/kernel/perfmon.c 2010-10-21 13:06:52.000000000 +0200
377 +++ linux-2.6.36-vs2.3.0.36.38/arch/ia64/kernel/perfmon.c 2010-10-21 13:09:36.000000000 +0200
379 #include <linux/completion.h>
380 #include <linux/tracehook.h>
381 #include <linux/slab.h>
382 +#include <linux/vs_memory.h>
384 #include <asm/errno.h>
385 #include <asm/intrinsics.h>
386 diff -NurpP --minimal linux-2.6.36/arch/ia64/kernel/process.c linux-2.6.36-vs2.3.0.36.38/arch/ia64/kernel/process.c
387 --- linux-2.6.36/arch/ia64/kernel/process.c 2010-10-21 13:06:52.000000000 +0200
388 +++ linux-2.6.36-vs2.3.0.36.38/arch/ia64/kernel/process.c 2010-10-21 13:09:36.000000000 +0200
389 @@ -113,8 +113,8 @@ show_regs (struct pt_regs *regs)
390 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
393 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
394 - smp_processor_id(), current->comm);
395 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
396 + current->xid, smp_processor_id(), current->comm);
397 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
398 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
399 init_utsname()->release);
400 diff -NurpP --minimal linux-2.6.36/arch/ia64/kernel/ptrace.c linux-2.6.36-vs2.3.0.36.38/arch/ia64/kernel/ptrace.c
401 --- linux-2.6.36/arch/ia64/kernel/ptrace.c 2010-08-02 16:52:04.000000000 +0200
402 +++ linux-2.6.36-vs2.3.0.36.38/arch/ia64/kernel/ptrace.c 2010-10-21 13:09:36.000000000 +0200
404 #include <linux/regset.h>
405 #include <linux/elf.h>
406 #include <linux/tracehook.h>
407 +#include <linux/vs_base.h>
409 #include <asm/pgtable.h>
410 #include <asm/processor.h>
411 diff -NurpP --minimal linux-2.6.36/arch/ia64/kernel/traps.c linux-2.6.36-vs2.3.0.36.38/arch/ia64/kernel/traps.c
412 --- linux-2.6.36/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
413 +++ linux-2.6.36-vs2.3.0.36.38/arch/ia64/kernel/traps.c 2010-10-21 13:09:36.000000000 +0200
414 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
417 if (++die.lock_owner_depth < 3) {
418 - printk("%s[%d]: %s %ld [%d]\n",
419 - current->comm, task_pid_nr(current), str, err, ++die_counter);
420 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
421 + current->comm, task_pid_nr(current), current->xid,
422 + str, err, ++die_counter);
423 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
426 @@ -323,8 +324,9 @@ handle_fpu_swa (int fp_fault, struct pt_
427 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
428 last.time = current_jiffies + 5 * HZ;
430 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
431 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
432 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
433 + current->comm, task_pid_nr(current), current->xid,
434 + regs->cr_iip + ia64_psr(regs)->ri, isr);
438 diff -NurpP --minimal linux-2.6.36/arch/ia64/mm/fault.c linux-2.6.36-vs2.3.0.36.38/arch/ia64/mm/fault.c
439 --- linux-2.6.36/arch/ia64/mm/fault.c 2010-08-02 16:52:04.000000000 +0200
440 +++ linux-2.6.36-vs2.3.0.36.38/arch/ia64/mm/fault.c 2010-10-21 13:09:36.000000000 +0200
442 #include <linux/interrupt.h>
443 #include <linux/kprobes.h>
444 #include <linux/kdebug.h>
445 +#include <linux/vs_memory.h>
447 #include <asm/pgtable.h>
448 #include <asm/processor.h>
449 diff -NurpP --minimal linux-2.6.36/arch/m32r/kernel/traps.c linux-2.6.36-vs2.3.0.36.38/arch/m32r/kernel/traps.c
450 --- linux-2.6.36/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
451 +++ linux-2.6.36-vs2.3.0.36.38/arch/m32r/kernel/traps.c 2010-10-21 13:09:36.000000000 +0200
452 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
454 printk("SPI: %08lx\n", sp);
456 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
457 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
458 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
459 + current->comm, task_pid_nr(current), current->xid,
460 + 0xffff & i, 4096+(unsigned long)current);
463 * When in-kernel, we also print out the stack and code at the
464 diff -NurpP --minimal linux-2.6.36/arch/m68k/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/m68k/Kconfig
465 --- linux-2.6.36/arch/m68k/Kconfig 2010-10-21 13:06:52.000000000 +0200
466 +++ linux-2.6.36-vs2.3.0.36.38/arch/m68k/Kconfig 2010-10-21 13:09:36.000000000 +0200
467 @@ -616,6 +616,8 @@ source "fs/Kconfig"
469 source "arch/m68k/Kconfig.debug"
471 +source "kernel/vserver/Kconfig"
473 source "security/Kconfig"
475 source "crypto/Kconfig"
476 diff -NurpP --minimal linux-2.6.36/arch/m68k/kernel/ptrace.c linux-2.6.36-vs2.3.0.36.38/arch/m68k/kernel/ptrace.c
477 --- linux-2.6.36/arch/m68k/kernel/ptrace.c 2010-07-07 18:31:02.000000000 +0200
478 +++ linux-2.6.36-vs2.3.0.36.38/arch/m68k/kernel/ptrace.c 2010-10-21 13:09:36.000000000 +0200
480 #include <linux/ptrace.h>
481 #include <linux/user.h>
482 #include <linux/signal.h>
483 +#include <linux/vs_base.h>
485 #include <asm/uaccess.h>
486 #include <asm/page.h>
487 @@ -254,6 +255,8 @@ long arch_ptrace(struct task_struct *chi
488 ret = ptrace_request(child, request, addr, data);
491 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
496 diff -NurpP --minimal linux-2.6.36/arch/m68k/kernel/traps.c linux-2.6.36-vs2.3.0.36.38/arch/m68k/kernel/traps.c
497 --- linux-2.6.36/arch/m68k/kernel/traps.c 2010-08-02 16:52:04.000000000 +0200
498 +++ linux-2.6.36-vs2.3.0.36.38/arch/m68k/kernel/traps.c 2010-10-21 13:09:36.000000000 +0200
499 @@ -906,8 +906,8 @@ void show_registers(struct pt_regs *regs
500 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
501 regs->d4, regs->d5, regs->a0, regs->a1);
503 - printk("Process %s (pid: %d, task=%p)\n",
504 - current->comm, task_pid_nr(current), current);
505 + printk("Process %s (pid: %d[#%u], task=%p)\n",
506 + current->comm, task_pid_nr(current), current->xid, current);
507 addr = (unsigned long)&fp->un;
508 printk("Frame format=%X ", regs->format);
509 switch (regs->format) {
510 diff -NurpP --minimal linux-2.6.36/arch/m68knommu/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/m68knommu/Kconfig
511 --- linux-2.6.36/arch/m68knommu/Kconfig 2010-10-21 13:06:53.000000000 +0200
512 +++ linux-2.6.36-vs2.3.0.36.38/arch/m68knommu/Kconfig 2010-10-21 13:09:36.000000000 +0200
513 @@ -730,6 +730,8 @@ source "fs/Kconfig"
515 source "arch/m68knommu/Kconfig.debug"
517 +source "kernel/vserver/Kconfig"
519 source "security/Kconfig"
521 source "crypto/Kconfig"
522 diff -NurpP --minimal linux-2.6.36/arch/m68knommu/kernel/traps.c linux-2.6.36-vs2.3.0.36.38/arch/m68knommu/kernel/traps.c
523 --- linux-2.6.36/arch/m68knommu/kernel/traps.c 2009-09-10 15:25:23.000000000 +0200
524 +++ linux-2.6.36-vs2.3.0.36.38/arch/m68knommu/kernel/traps.c 2010-10-21 13:09:36.000000000 +0200
525 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
526 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
527 fp->d4, fp->d5, fp->a0, fp->a1);
529 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
530 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
531 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
532 + current->comm, task_pid_nr(current), current->xid,
533 + PAGE_SIZE+(unsigned long)current);
534 show_stack(NULL, (unsigned long *)(fp + 1));
535 add_taint(TAINT_DIE);
537 diff -NurpP --minimal linux-2.6.36/arch/mips/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/mips/Kconfig
538 --- linux-2.6.36/arch/mips/Kconfig 2010-10-21 13:06:53.000000000 +0200
539 +++ linux-2.6.36-vs2.3.0.36.38/arch/mips/Kconfig 2010-10-21 13:09:36.000000000 +0200
540 @@ -2298,6 +2298,8 @@ source "fs/Kconfig"
542 source "arch/mips/Kconfig.debug"
544 +source "kernel/vserver/Kconfig"
546 source "security/Kconfig"
548 source "crypto/Kconfig"
549 diff -NurpP --minimal linux-2.6.36/arch/mips/kernel/ptrace.c linux-2.6.36-vs2.3.0.36.38/arch/mips/kernel/ptrace.c
550 --- linux-2.6.36/arch/mips/kernel/ptrace.c 2010-10-21 13:06:54.000000000 +0200
551 +++ linux-2.6.36-vs2.3.0.36.38/arch/mips/kernel/ptrace.c 2010-10-21 13:09:36.000000000 +0200
553 #include <linux/security.h>
554 #include <linux/audit.h>
555 #include <linux/seccomp.h>
556 +#include <linux/vs_base.h>
558 #include <asm/byteorder.h>
560 @@ -259,6 +260,9 @@ long arch_ptrace(struct task_struct *chi
564 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
568 /* when I and D space are separate, these will need to be fixed. */
569 case PTRACE_PEEKTEXT: /* read word at location addr. */
570 diff -NurpP --minimal linux-2.6.36/arch/mips/kernel/scall32-o32.S linux-2.6.36-vs2.3.0.36.38/arch/mips/kernel/scall32-o32.S
571 --- linux-2.6.36/arch/mips/kernel/scall32-o32.S 2010-10-21 13:06:54.000000000 +0200
572 +++ linux-2.6.36-vs2.3.0.36.38/arch/mips/kernel/scall32-o32.S 2010-10-21 13:09:36.000000000 +0200
573 @@ -524,7 +524,7 @@ einval: li v0, -ENOSYS
574 sys sys_mq_timedreceive 5
575 sys sys_mq_notify 2 /* 4275 */
576 sys sys_mq_getsetattr 3
577 - sys sys_ni_syscall 0 /* sys_vserver */
580 sys sys_ni_syscall 0 /* available, was setaltroot */
581 sys sys_add_key 5 /* 4280 */
582 diff -NurpP --minimal linux-2.6.36/arch/mips/kernel/scall64-64.S linux-2.6.36-vs2.3.0.36.38/arch/mips/kernel/scall64-64.S
583 --- linux-2.6.36/arch/mips/kernel/scall64-64.S 2010-10-21 13:06:54.000000000 +0200
584 +++ linux-2.6.36-vs2.3.0.36.38/arch/mips/kernel/scall64-64.S 2010-10-21 13:09:36.000000000 +0200
585 @@ -363,7 +363,7 @@ sys_call_table:
586 PTR sys_mq_timedreceive
588 PTR sys_mq_getsetattr /* 5235 */
589 - PTR sys_ni_syscall /* sys_vserver */
592 PTR sys_ni_syscall /* available, was setaltroot */
594 diff -NurpP --minimal linux-2.6.36/arch/mips/kernel/scall64-n32.S linux-2.6.36-vs2.3.0.36.38/arch/mips/kernel/scall64-n32.S
595 --- linux-2.6.36/arch/mips/kernel/scall64-n32.S 2010-10-21 13:06:54.000000000 +0200
596 +++ linux-2.6.36-vs2.3.0.36.38/arch/mips/kernel/scall64-n32.S 2010-10-21 13:09:36.000000000 +0200
597 @@ -362,7 +362,7 @@ EXPORT(sysn32_call_table)
598 PTR compat_sys_mq_timedreceive
599 PTR compat_sys_mq_notify
600 PTR compat_sys_mq_getsetattr
601 - PTR sys_ni_syscall /* 6240, sys_vserver */
602 + PTR sys32_vserver /* 6240 */
603 PTR compat_sys_waitid
604 PTR sys_ni_syscall /* available, was setaltroot */
606 diff -NurpP --minimal linux-2.6.36/arch/mips/kernel/scall64-o32.S linux-2.6.36-vs2.3.0.36.38/arch/mips/kernel/scall64-o32.S
607 --- linux-2.6.36/arch/mips/kernel/scall64-o32.S 2010-10-21 13:06:54.000000000 +0200
608 +++ linux-2.6.36-vs2.3.0.36.38/arch/mips/kernel/scall64-o32.S 2010-10-21 13:09:36.000000000 +0200
609 @@ -481,7 +481,7 @@ sys_call_table:
610 PTR compat_sys_mq_timedreceive
611 PTR compat_sys_mq_notify /* 4275 */
612 PTR compat_sys_mq_getsetattr
613 - PTR sys_ni_syscall /* sys_vserver */
616 PTR sys_ni_syscall /* available, was setaltroot */
617 PTR sys_add_key /* 4280 */
618 diff -NurpP --minimal linux-2.6.36/arch/mips/kernel/traps.c linux-2.6.36-vs2.3.0.36.38/arch/mips/kernel/traps.c
619 --- linux-2.6.36/arch/mips/kernel/traps.c 2010-10-21 13:06:54.000000000 +0200
620 +++ linux-2.6.36-vs2.3.0.36.38/arch/mips/kernel/traps.c 2010-10-21 13:09:36.000000000 +0200
621 @@ -341,9 +341,10 @@ void show_registers(struct pt_regs *regs
625 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
626 - current->comm, current->pid, current_thread_info(), current,
627 - field, current_thread_info()->tp_value);
628 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
629 + current->comm, task_pid_nr(current), current->xid,
630 + current_thread_info(), current,
631 + field, current_thread_info()->tp_value);
632 if (cpu_has_userlocal) {
635 diff -NurpP --minimal linux-2.6.36/arch/parisc/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/parisc/Kconfig
636 --- linux-2.6.36/arch/parisc/Kconfig 2010-10-21 13:06:55.000000000 +0200
637 +++ linux-2.6.36-vs2.3.0.36.38/arch/parisc/Kconfig 2010-10-21 13:09:36.000000000 +0200
638 @@ -295,6 +295,8 @@ source "fs/Kconfig"
640 source "arch/parisc/Kconfig.debug"
642 +source "kernel/vserver/Kconfig"
644 source "security/Kconfig"
646 source "crypto/Kconfig"
647 diff -NurpP --minimal linux-2.6.36/arch/parisc/kernel/syscall_table.S linux-2.6.36-vs2.3.0.36.38/arch/parisc/kernel/syscall_table.S
648 --- linux-2.6.36/arch/parisc/kernel/syscall_table.S 2010-07-07 18:31:04.000000000 +0200
649 +++ linux-2.6.36-vs2.3.0.36.38/arch/parisc/kernel/syscall_table.S 2010-10-21 13:09:36.000000000 +0200
651 ENTRY_COMP(mbind) /* 260 */
652 ENTRY_COMP(get_mempolicy)
653 ENTRY_COMP(set_mempolicy)
654 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
655 + ENTRY_DIFF(vserver)
657 ENTRY_SAME(request_key) /* 265 */
659 diff -NurpP --minimal linux-2.6.36/arch/parisc/kernel/traps.c linux-2.6.36-vs2.3.0.36.38/arch/parisc/kernel/traps.c
660 --- linux-2.6.36/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
661 +++ linux-2.6.36-vs2.3.0.36.38/arch/parisc/kernel/traps.c 2010-10-21 13:09:36.000000000 +0200
662 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
666 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
667 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
668 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
669 + current->comm, task_pid_nr(current), current->xid,
670 + str, err, regs->iaoq[0]);
671 #ifdef PRINT_USER_FAULTS
672 /* XXX for debugging only */
674 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
675 pdc_console_restart();
678 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
679 - current->comm, task_pid_nr(current), str, err);
680 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
681 + current->comm, task_pid_nr(current), current->xid, str, err);
683 /* Wot's wrong wif bein' racy? */
684 if (current->thread.flags & PARISC_KERNEL_DEATH) {
685 diff -NurpP --minimal linux-2.6.36/arch/parisc/mm/fault.c linux-2.6.36-vs2.3.0.36.38/arch/parisc/mm/fault.c
686 --- linux-2.6.36/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
687 +++ linux-2.6.36-vs2.3.0.36.38/arch/parisc/mm/fault.c 2010-10-21 13:09:36.000000000 +0200
688 @@ -237,8 +237,9 @@ bad_area:
690 #ifdef PRINT_USER_FAULTS
691 printk(KERN_DEBUG "\n");
692 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
693 - task_pid_nr(tsk), tsk->comm, code, address);
694 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
695 + "command='%s' type=%lu address=0x%08lx\n",
696 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
698 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
699 vma->vm_start, vma->vm_end);
700 diff -NurpP --minimal linux-2.6.36/arch/powerpc/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/powerpc/Kconfig
701 --- linux-2.6.36/arch/powerpc/Kconfig 2010-10-21 13:06:55.000000000 +0200
702 +++ linux-2.6.36-vs2.3.0.36.38/arch/powerpc/Kconfig 2010-10-21 13:09:36.000000000 +0200
703 @@ -974,6 +974,8 @@ source "lib/Kconfig"
705 source "arch/powerpc/Kconfig.debug"
707 +source "kernel/vserver/Kconfig"
709 source "security/Kconfig"
712 diff -NurpP --minimal linux-2.6.36/arch/powerpc/include/asm/unistd.h linux-2.6.36-vs2.3.0.36.38/arch/powerpc/include/asm/unistd.h
713 --- linux-2.6.36/arch/powerpc/include/asm/unistd.h 2010-10-21 13:06:56.000000000 +0200
714 +++ linux-2.6.36-vs2.3.0.36.38/arch/powerpc/include/asm/unistd.h 2010-10-21 13:09:36.000000000 +0200
717 #define __NR_rtas 255
718 #define __NR_sys_debug_setcontext 256
719 -/* Number 257 is reserved for vserver */
720 +#define __NR_vserver 257
721 #define __NR_migrate_pages 258
722 #define __NR_mbind 259
723 #define __NR_get_mempolicy 260
724 diff -NurpP --minimal linux-2.6.36/arch/powerpc/kernel/process.c linux-2.6.36-vs2.3.0.36.38/arch/powerpc/kernel/process.c
725 --- linux-2.6.36/arch/powerpc/kernel/process.c 2010-10-21 13:06:56.000000000 +0200
726 +++ linux-2.6.36-vs2.3.0.36.38/arch/powerpc/kernel/process.c 2010-10-21 13:09:36.000000000 +0200
727 @@ -634,8 +634,9 @@ void show_regs(struct pt_regs * regs)
729 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
731 - printk("TASK = %p[%d] '%s' THREAD: %p",
732 - current, task_pid_nr(current), current->comm, task_thread_info(current));
733 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
734 + current, task_pid_nr(current), current->xid,
735 + current->comm, task_thread_info(current));
738 printk(" CPU: %d", raw_smp_processor_id());
739 diff -NurpP --minimal linux-2.6.36/arch/powerpc/kernel/traps.c linux-2.6.36-vs2.3.0.36.38/arch/powerpc/kernel/traps.c
740 --- linux-2.6.36/arch/powerpc/kernel/traps.c 2010-10-21 13:06:57.000000000 +0200
741 +++ linux-2.6.36-vs2.3.0.36.38/arch/powerpc/kernel/traps.c 2010-10-21 13:09:36.000000000 +0200
742 @@ -1048,8 +1048,9 @@ void nonrecoverable_exception(struct pt_
744 void trace_syscall(struct pt_regs *regs)
746 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
747 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
748 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
749 + current, task_pid_nr(current), current->xid,
750 + regs->nip, regs->link, regs->gpr[0],
751 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
754 diff -NurpP --minimal linux-2.6.36/arch/powerpc/kernel/vdso.c linux-2.6.36-vs2.3.0.36.38/arch/powerpc/kernel/vdso.c
755 --- linux-2.6.36/arch/powerpc/kernel/vdso.c 2010-08-02 16:52:07.000000000 +0200
756 +++ linux-2.6.36-vs2.3.0.36.38/arch/powerpc/kernel/vdso.c 2010-10-21 13:09:36.000000000 +0200
758 #include <linux/security.h>
759 #include <linux/bootmem.h>
760 #include <linux/memblock.h>
761 +#include <linux/vs_memory.h>
763 #include <asm/pgtable.h>
764 #include <asm/system.h>
765 diff -NurpP --minimal linux-2.6.36/arch/s390/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/s390/Kconfig
766 --- linux-2.6.36/arch/s390/Kconfig 2010-10-21 13:06:57.000000000 +0200
767 +++ linux-2.6.36-vs2.3.0.36.38/arch/s390/Kconfig 2010-10-21 13:09:36.000000000 +0200
768 @@ -620,6 +620,8 @@ source "fs/Kconfig"
770 source "arch/s390/Kconfig.debug"
772 +source "kernel/vserver/Kconfig"
774 source "security/Kconfig"
776 source "crypto/Kconfig"
777 diff -NurpP --minimal linux-2.6.36/arch/s390/include/asm/tlb.h linux-2.6.36-vs2.3.0.36.38/arch/s390/include/asm/tlb.h
778 --- linux-2.6.36/arch/s390/include/asm/tlb.h 2010-10-21 13:06:58.000000000 +0200
779 +++ linux-2.6.36-vs2.3.0.36.38/arch/s390/include/asm/tlb.h 2010-10-21 13:09:36.000000000 +0200
782 #include <linux/mm.h>
783 #include <linux/swap.h>
784 +#include <linux/vs_memory.h>
786 #include <asm/processor.h>
787 #include <asm/pgalloc.h>
789 diff -NurpP --minimal linux-2.6.36/arch/s390/include/asm/unistd.h linux-2.6.36-vs2.3.0.36.38/arch/s390/include/asm/unistd.h
790 --- linux-2.6.36/arch/s390/include/asm/unistd.h 2010-10-21 13:06:58.000000000 +0200
791 +++ linux-2.6.36-vs2.3.0.36.38/arch/s390/include/asm/unistd.h 2010-10-21 13:09:36.000000000 +0200
793 #define __NR_clock_gettime (__NR_timer_create+6)
794 #define __NR_clock_getres (__NR_timer_create+7)
795 #define __NR_clock_nanosleep (__NR_timer_create+8)
796 -/* Number 263 is reserved for vserver */
797 +#define __NR_vserver 263
798 #define __NR_statfs64 265
799 #define __NR_fstatfs64 266
800 #define __NR_remap_file_pages 267
801 diff -NurpP --minimal linux-2.6.36/arch/s390/kernel/ptrace.c linux-2.6.36-vs2.3.0.36.38/arch/s390/kernel/ptrace.c
802 --- linux-2.6.36/arch/s390/kernel/ptrace.c 2010-08-02 16:52:09.000000000 +0200
803 +++ linux-2.6.36-vs2.3.0.36.38/arch/s390/kernel/ptrace.c 2010-10-21 13:09:36.000000000 +0200
805 #include <linux/regset.h>
806 #include <linux/tracehook.h>
807 #include <linux/seccomp.h>
808 +#include <linux/vs_base.h>
809 #include <trace/syscall.h>
810 #include <asm/compat.h>
811 #include <asm/segment.h>
812 diff -NurpP --minimal linux-2.6.36/arch/s390/kernel/syscalls.S linux-2.6.36-vs2.3.0.36.38/arch/s390/kernel/syscalls.S
813 --- linux-2.6.36/arch/s390/kernel/syscalls.S 2010-10-21 13:06:58.000000000 +0200
814 +++ linux-2.6.36-vs2.3.0.36.38/arch/s390/kernel/syscalls.S 2010-10-21 13:09:36.000000000 +0200
815 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
816 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
817 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
818 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
819 -NI_SYSCALL /* reserved for vserver */
820 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
821 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
822 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
823 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
824 diff -NurpP --minimal linux-2.6.36/arch/sh/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/sh/Kconfig
825 --- linux-2.6.36/arch/sh/Kconfig 2010-10-21 13:06:58.000000000 +0200
826 +++ linux-2.6.36-vs2.3.0.36.38/arch/sh/Kconfig 2010-10-21 13:09:36.000000000 +0200
827 @@ -878,6 +878,8 @@ source "fs/Kconfig"
829 source "arch/sh/Kconfig.debug"
831 +source "kernel/vserver/Kconfig"
833 source "security/Kconfig"
835 source "crypto/Kconfig"
836 diff -NurpP --minimal linux-2.6.36/arch/sh/kernel/irq.c linux-2.6.36-vs2.3.0.36.38/arch/sh/kernel/irq.c
837 --- linux-2.6.36/arch/sh/kernel/irq.c 2010-08-02 16:52:10.000000000 +0200
838 +++ linux-2.6.36-vs2.3.0.36.38/arch/sh/kernel/irq.c 2010-10-21 13:09:36.000000000 +0200
840 #include <linux/seq_file.h>
841 #include <linux/ftrace.h>
842 #include <linux/delay.h>
843 +// #include <linux/vs_context.h>
844 #include <asm/processor.h>
845 #include <asm/machvec.h>
846 #include <asm/uaccess.h>
847 diff -NurpP --minimal linux-2.6.36/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.36-vs2.3.0.36.38/arch/sh/kernel/vsyscall/vsyscall.c
848 --- linux-2.6.36/arch/sh/kernel/vsyscall/vsyscall.c 2010-07-07 18:31:10.000000000 +0200
849 +++ linux-2.6.36-vs2.3.0.36.38/arch/sh/kernel/vsyscall/vsyscall.c 2010-10-21 13:09:36.000000000 +0200
851 #include <linux/elf.h>
852 #include <linux/sched.h>
853 #include <linux/err.h>
854 +#include <linux/vs_memory.h>
857 * Should the kernel map a VDSO page into processes and pass its
858 diff -NurpP --minimal linux-2.6.36/arch/sparc/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/sparc/Kconfig
859 --- linux-2.6.36/arch/sparc/Kconfig 2010-10-21 13:06:58.000000000 +0200
860 +++ linux-2.6.36-vs2.3.0.36.38/arch/sparc/Kconfig 2010-10-21 13:09:36.000000000 +0200
861 @@ -565,6 +565,8 @@ source "fs/Kconfig"
863 source "arch/sparc/Kconfig.debug"
865 +source "kernel/vserver/Kconfig"
867 source "security/Kconfig"
869 source "crypto/Kconfig"
870 diff -NurpP --minimal linux-2.6.36/arch/sparc/include/asm/tlb_64.h linux-2.6.36-vs2.3.0.36.38/arch/sparc/include/asm/tlb_64.h
871 --- linux-2.6.36/arch/sparc/include/asm/tlb_64.h 2009-09-10 15:25:45.000000000 +0200
872 +++ linux-2.6.36-vs2.3.0.36.38/arch/sparc/include/asm/tlb_64.h 2010-10-21 13:09:36.000000000 +0200
875 #include <linux/swap.h>
876 #include <linux/pagemap.h>
877 +#include <linux/vs_memory.h>
878 #include <asm/pgalloc.h>
879 #include <asm/tlbflush.h>
880 #include <asm/mmu_context.h>
881 diff -NurpP --minimal linux-2.6.36/arch/sparc/include/asm/unistd.h linux-2.6.36-vs2.3.0.36.38/arch/sparc/include/asm/unistd.h
882 --- linux-2.6.36/arch/sparc/include/asm/unistd.h 2010-10-21 13:06:58.000000000 +0200
883 +++ linux-2.6.36-vs2.3.0.36.38/arch/sparc/include/asm/unistd.h 2010-10-21 13:09:36.000000000 +0200
885 #define __NR_timer_getoverrun 264
886 #define __NR_timer_delete 265
887 #define __NR_timer_create 266
888 -/* #define __NR_vserver 267 Reserved for VSERVER */
889 +#define __NR_vserver 267
890 #define __NR_io_setup 268
891 #define __NR_io_destroy 269
892 #define __NR_io_submit 270
893 diff -NurpP --minimal linux-2.6.36/arch/sparc/kernel/systbls_32.S linux-2.6.36-vs2.3.0.36.38/arch/sparc/kernel/systbls_32.S
894 --- linux-2.6.36/arch/sparc/kernel/systbls_32.S 2010-10-21 13:06:59.000000000 +0200
895 +++ linux-2.6.36-vs2.3.0.36.38/arch/sparc/kernel/systbls_32.S 2010-10-21 13:09:36.000000000 +0200
896 @@ -70,7 +70,7 @@ sys_call_table:
897 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
898 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
899 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
900 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
901 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
902 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
903 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
904 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
905 diff -NurpP --minimal linux-2.6.36/arch/sparc/kernel/systbls_64.S linux-2.6.36-vs2.3.0.36.38/arch/sparc/kernel/systbls_64.S
906 --- linux-2.6.36/arch/sparc/kernel/systbls_64.S 2010-10-21 13:06:59.000000000 +0200
907 +++ linux-2.6.36-vs2.3.0.36.38/arch/sparc/kernel/systbls_64.S 2010-10-21 13:09:36.000000000 +0200
908 @@ -71,7 +71,7 @@ sys_call_table32:
909 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
910 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
911 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
912 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
913 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
914 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
915 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
916 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
917 @@ -147,7 +147,7 @@ sys_call_table:
918 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
919 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
920 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
921 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
922 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
923 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
924 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
925 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
926 diff -NurpP --minimal linux-2.6.36/arch/um/Kconfig.rest linux-2.6.36-vs2.3.0.36.38/arch/um/Kconfig.rest
927 --- linux-2.6.36/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
928 +++ linux-2.6.36-vs2.3.0.36.38/arch/um/Kconfig.rest 2010-10-21 13:09:36.000000000 +0200
929 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
933 +source "kernel/vserver/Kconfig"
935 source "security/Kconfig"
937 source "crypto/Kconfig"
938 diff -NurpP --minimal linux-2.6.36/arch/um/include/asm/tlb.h linux-2.6.36-vs2.3.0.36.38/arch/um/include/asm/tlb.h
939 --- linux-2.6.36/arch/um/include/asm/tlb.h 2009-09-10 15:25:46.000000000 +0200
940 +++ linux-2.6.36-vs2.3.0.36.38/arch/um/include/asm/tlb.h 2010-10-21 13:09:36.000000000 +0200
943 #include <linux/pagemap.h>
944 #include <linux/swap.h>
945 +#include <linux/vs_memory.h>
946 #include <asm/percpu.h>
947 #include <asm/pgalloc.h>
948 #include <asm/tlbflush.h>
949 diff -NurpP --minimal linux-2.6.36/arch/um/include/shared/kern_constants.h linux-2.6.36-vs2.3.0.36.38/arch/um/include/shared/kern_constants.h
950 --- linux-2.6.36/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
951 +++ linux-2.6.36-vs2.3.0.36.38/arch/um/include/shared/kern_constants.h 2010-10-21 13:09:36.000000000 +0200
953 +#include "../../../../include/generated/asm-offsets.h"
954 diff -NurpP --minimal linux-2.6.36/arch/um/include/shared/user_constants.h linux-2.6.36-vs2.3.0.36.38/arch/um/include/shared/user_constants.h
955 --- linux-2.6.36/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
956 +++ linux-2.6.36-vs2.3.0.36.38/arch/um/include/shared/user_constants.h 2010-10-21 13:09:36.000000000 +0200
961 + * This file was generated by arch/um/Makefile
965 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2) # */
966 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err) # */
967 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno) # */
968 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long) # */
969 +#define HOST_RBX 5 /* RBX # */
970 +#define HOST_RCX 11 /* RCX # */
971 +#define HOST_RDI 14 /* RDI # */
972 +#define HOST_RSI 13 /* RSI # */
973 +#define HOST_RDX 12 /* RDX # */
974 +#define HOST_RBP 4 /* RBP # */
975 +#define HOST_RAX 10 /* RAX # */
976 +#define HOST_R8 9 /* R8 # */
977 +#define HOST_R9 8 /* R9 # */
978 +#define HOST_R10 7 /* R10 # */
979 +#define HOST_R11 6 /* R11 # */
980 +#define HOST_R12 3 /* R12 # */
981 +#define HOST_R13 2 /* R13 # */
982 +#define HOST_R14 1 /* R14 # */
983 +#define HOST_R15 0 /* R15 # */
984 +#define HOST_ORIG_RAX 15 /* ORIG_RAX # */
985 +#define HOST_CS 17 /* CS # */
986 +#define HOST_SS 20 /* SS # */
987 +#define HOST_EFLAGS 18 /* EFLAGS # */
988 +#define HOST_IP 16 /* RIP # */
989 +#define HOST_SP 19 /* RSP # */
990 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct) # */
991 +#define UM_POLLIN 1 /* POLLIN # */
992 +#define UM_POLLPRI 2 /* POLLPRI # */
993 +#define UM_POLLOUT 4 /* POLLOUT # */
994 +#define UM_PROT_READ 1 /* PROT_READ # */
995 +#define UM_PROT_WRITE 2 /* PROT_WRITE # */
996 +#define UM_PROT_EXEC 4 /* PROT_EXEC # */
998 diff -NurpP --minimal linux-2.6.36/arch/x86/Kconfig linux-2.6.36-vs2.3.0.36.38/arch/x86/Kconfig
999 --- linux-2.6.36/arch/x86/Kconfig 2010-10-21 13:06:59.000000000 +0200
1000 +++ linux-2.6.36-vs2.3.0.36.38/arch/x86/Kconfig 2010-10-21 13:09:36.000000000 +0200
1001 @@ -2135,6 +2135,8 @@ source "fs/Kconfig"
1003 source "arch/x86/Kconfig.debug"
1005 +source "kernel/vserver/Kconfig"
1007 source "security/Kconfig"
1009 source "crypto/Kconfig"
1010 diff -NurpP --minimal linux-2.6.36/arch/x86/ia32/ia32entry.S linux-2.6.36-vs2.3.0.36.38/arch/x86/ia32/ia32entry.S
1011 --- linux-2.6.36/arch/x86/ia32/ia32entry.S 2010-10-21 13:06:59.000000000 +0200
1012 +++ linux-2.6.36-vs2.3.0.36.38/arch/x86/ia32/ia32entry.S 2010-10-21 13:09:36.000000000 +0200
1013 @@ -783,7 +783,7 @@ ia32_sys_call_table:
1014 .quad sys_tgkill /* 270 */
1015 .quad compat_sys_utimes
1016 .quad sys32_fadvise64_64
1017 - .quad quiet_ni_syscall /* sys_vserver */
1018 + .quad sys32_vserver
1020 .quad compat_sys_get_mempolicy /* 275 */
1021 .quad sys_set_mempolicy
1022 diff -NurpP --minimal linux-2.6.36/arch/x86/include/asm/unistd_64.h linux-2.6.36-vs2.3.0.36.38/arch/x86/include/asm/unistd_64.h
1023 --- linux-2.6.36/arch/x86/include/asm/unistd_64.h 2010-10-21 13:06:59.000000000 +0200
1024 +++ linux-2.6.36-vs2.3.0.36.38/arch/x86/include/asm/unistd_64.h 2010-10-21 13:09:36.000000000 +0200
1025 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
1026 #define __NR_utimes 235
1027 __SYSCALL(__NR_utimes, sys_utimes)
1028 #define __NR_vserver 236
1029 -__SYSCALL(__NR_vserver, sys_ni_syscall)
1030 +__SYSCALL(__NR_vserver, sys_vserver)
1031 #define __NR_mbind 237
1032 __SYSCALL(__NR_mbind, sys_mbind)
1033 #define __NR_set_mempolicy 238
1034 diff -NurpP --minimal linux-2.6.36/arch/x86/kernel/syscall_table_32.S linux-2.6.36-vs2.3.0.36.38/arch/x86/kernel/syscall_table_32.S
1035 --- linux-2.6.36/arch/x86/kernel/syscall_table_32.S 2010-10-21 13:07:00.000000000 +0200
1036 +++ linux-2.6.36-vs2.3.0.36.38/arch/x86/kernel/syscall_table_32.S 2010-10-21 13:09:36.000000000 +0200
1037 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
1038 .long sys_tgkill /* 270 */
1040 .long sys_fadvise64_64
1041 - .long sys_ni_syscall /* sys_vserver */
1044 .long sys_get_mempolicy
1045 .long sys_set_mempolicy
1046 diff -NurpP --minimal linux-2.6.36/drivers/block/Kconfig linux-2.6.36-vs2.3.0.36.38/drivers/block/Kconfig
1047 --- linux-2.6.36/drivers/block/Kconfig 2010-08-02 16:52:14.000000000 +0200
1048 +++ linux-2.6.36-vs2.3.0.36.38/drivers/block/Kconfig 2010-10-21 13:09:36.000000000 +0200
1049 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
1051 source "drivers/block/drbd/Kconfig"
1053 +config BLK_DEV_VROOT
1054 + tristate "Virtual Root device support"
1055 + depends on QUOTACTL
1057 + Saying Y here will allow you to use quota/fs ioctls on a shared
1058 + partition within a virtual server without compromising security.
1061 tristate "Network block device support"
1063 diff -NurpP --minimal linux-2.6.36/drivers/block/Makefile linux-2.6.36-vs2.3.0.36.38/drivers/block/Makefile
1064 --- linux-2.6.36/drivers/block/Makefile 2010-02-25 11:51:36.000000000 +0100
1065 +++ linux-2.6.36-vs2.3.0.36.38/drivers/block/Makefile 2010-10-21 13:09:36.000000000 +0200
1066 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1067 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1068 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1069 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1070 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1072 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1073 obj-$(CONFIG_BLK_DEV_DRBD) += drbd/
1074 diff -NurpP --minimal linux-2.6.36/drivers/block/loop.c linux-2.6.36-vs2.3.0.36.38/drivers/block/loop.c
1075 --- linux-2.6.36/drivers/block/loop.c 2010-10-21 13:07:02.000000000 +0200
1076 +++ linux-2.6.36-vs2.3.0.36.38/drivers/block/loop.c 2010-10-21 13:11:25.000000000 +0200
1078 #include <linux/highmem.h>
1079 #include <linux/kthread.h>
1080 #include <linux/splice.h>
1081 +#include <linux/vs_context.h>
1083 #include <asm/uaccess.h>
1085 @@ -814,6 +815,7 @@ static int loop_set_fd(struct loop_devic
1086 lo->lo_blocksize = lo_blocksize;
1087 lo->lo_device = bdev;
1088 lo->lo_flags = lo_flags;
1089 + lo->lo_xid = vx_current_xid();
1090 lo->lo_backing_file = file;
1091 lo->transfer = transfer_none;
1093 @@ -942,6 +944,7 @@ static int loop_clr_fd(struct loop_devic
1094 lo->lo_encrypt_key_size = 0;
1096 lo->lo_thread = NULL;
1098 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1099 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1100 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1101 @@ -979,7 +982,7 @@ loop_set_status(struct loop_device *lo,
1103 if (lo->lo_encrypt_key_size &&
1104 lo->lo_key_owner != uid &&
1105 - !capable(CAP_SYS_ADMIN))
1106 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1108 if (lo->lo_state != Lo_bound)
1110 @@ -1063,7 +1066,8 @@ loop_get_status(struct loop_device *lo,
1111 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1112 info->lo_encrypt_type =
1113 lo->lo_encryption ? lo->lo_encryption->number : 0;
1114 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1115 + if (lo->lo_encrypt_key_size &&
1116 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1117 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1118 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1119 lo->lo_encrypt_key_size);
1120 @@ -1409,6 +1413,9 @@ static int lo_open(struct block_device *
1122 struct loop_device *lo = bdev->bd_disk->private_data;
1124 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1128 mutex_lock(&lo->lo_ctl_mutex);
1130 diff -NurpP --minimal linux-2.6.36/drivers/block/vroot.c linux-2.6.36-vs2.3.0.36.38/drivers/block/vroot.c
1131 --- linux-2.6.36/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1132 +++ linux-2.6.36-vs2.3.0.36.38/drivers/block/vroot.c 2010-10-21 13:09:36.000000000 +0200
1135 + * linux/drivers/block/vroot.c
1137 + * written by Herbert Pötzl, 9/11/2002
1138 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1140 + * based on the loop.c code by Theodore Ts'o.
1142 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1143 + * Redistribution of this file is permitted under the
1144 + * GNU General Public License.
1148 +#include <linux/module.h>
1149 +#include <linux/moduleparam.h>
1150 +#include <linux/file.h>
1151 +#include <linux/major.h>
1152 +#include <linux/blkdev.h>
1153 +#include <linux/slab.h>
1155 +#include <linux/vroot.h>
1156 +#include <linux/vs_context.h>
1159 +static int max_vroot = 8;
1161 +static struct vroot_device *vroot_dev;
1162 +static struct gendisk **disks;
1165 +static int vroot_set_dev(
1166 + struct vroot_device *vr,
1167 + struct block_device *bdev,
1170 + struct block_device *real_bdev;
1171 + struct file *file;
1172 + struct inode *inode;
1176 + if (vr->vr_state != Vr_unbound)
1185 + inode = file->f_dentry->d_inode;
1188 + if (S_ISBLK(inode->i_mode)) {
1189 + real_bdev = inode->i_bdev;
1190 + vr->vr_device = real_bdev;
1191 + __iget(real_bdev->bd_inode);
1195 + vxdprintk(VXD_CBIT(misc, 0),
1196 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1197 + vr->vr_number, VXD_DEV(real_bdev));
1199 + vr->vr_state = Vr_bound;
1208 +static int vroot_clr_dev(
1209 + struct vroot_device *vr,
1210 + struct block_device *bdev)
1212 + struct block_device *real_bdev;
1214 + if (vr->vr_state != Vr_bound)
1216 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1219 + real_bdev = vr->vr_device;
1221 + vxdprintk(VXD_CBIT(misc, 0),
1222 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1223 + vr->vr_number, VXD_DEV(real_bdev));
1226 + vr->vr_state = Vr_unbound;
1227 + vr->vr_device = NULL;
1232 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1233 + unsigned int cmd, unsigned long arg)
1235 + struct vroot_device *vr = bdev->bd_disk->private_data;
1238 + down(&vr->vr_ctl_mutex);
1240 + case VROOT_SET_DEV:
1241 + err = vroot_set_dev(vr, bdev, arg);
1243 + case VROOT_CLR_DEV:
1244 + err = vroot_clr_dev(vr, bdev);
1250 + up(&vr->vr_ctl_mutex);
1254 +static int vr_open(struct block_device *bdev, fmode_t mode)
1256 + struct vroot_device *vr = bdev->bd_disk->private_data;
1258 + down(&vr->vr_ctl_mutex);
1260 + up(&vr->vr_ctl_mutex);
1264 +static int vr_release(struct gendisk *disk, fmode_t mode)
1266 + struct vroot_device *vr = disk->private_data;
1268 + down(&vr->vr_ctl_mutex);
1270 + up(&vr->vr_ctl_mutex);
1274 +static struct block_device_operations vr_fops = {
1275 + .owner = THIS_MODULE,
1277 + .release = vr_release,
1278 + .ioctl = vr_ioctl,
1281 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1283 + struct inode *inode = bdev->bd_inode;
1284 + struct vroot_device *vr;
1285 + struct block_device *real_bdev;
1286 + int minor = iminor(inode);
1288 + vr = &vroot_dev[minor];
1289 + real_bdev = vr->vr_device;
1291 + vxdprintk(VXD_CBIT(misc, 0),
1292 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1293 + vr->vr_number, VXD_DEV(real_bdev));
1295 + if (vr->vr_state != Vr_bound)
1296 + return ERR_PTR(-ENXIO);
1298 + __iget(real_bdev->bd_inode);
1303 + * And now the modules code and kernel interface.
1306 +module_param(max_vroot, int, 0);
1308 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1309 +MODULE_LICENSE("GPL");
1310 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1312 +MODULE_AUTHOR ("Herbert Pötzl");
1313 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1316 +int __init vroot_init(void)
1320 + if (max_vroot < 1 || max_vroot > 256) {
1321 + max_vroot = MAX_VROOT_DEFAULT;
1322 + printk(KERN_WARNING "vroot: invalid max_vroot "
1323 + "(must be between 1 and 256), "
1324 + "using default (%d)\n", max_vroot);
1327 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1331 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1334 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1336 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1340 + for (i = 0; i < max_vroot; i++) {
1341 + disks[i] = alloc_disk(1);
1344 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1345 + if (!disks[i]->queue)
1349 + for (i = 0; i < max_vroot; i++) {
1350 + struct vroot_device *vr = &vroot_dev[i];
1351 + struct gendisk *disk = disks[i];
1353 + memset(vr, 0, sizeof(*vr));
1354 + init_MUTEX(&vr->vr_ctl_mutex);
1355 + vr->vr_number = i;
1356 + disk->major = VROOT_MAJOR;
1357 + disk->first_minor = i;
1358 + disk->fops = &vr_fops;
1359 + sprintf(disk->disk_name, "vroot%d", i);
1360 + disk->private_data = vr;
1363 + err = register_vroot_grb(&__vroot_get_real_bdev);
1367 + for (i = 0; i < max_vroot; i++)
1368 + add_disk(disks[i]);
1369 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1374 + put_disk(disks[i]);
1379 + unregister_blkdev(VROOT_MAJOR, "vroot");
1380 + printk(KERN_ERR "vroot: ran out of memory\n");
1384 +void vroot_exit(void)
1388 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1389 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1391 + for (i = 0; i < max_vroot; i++) {
1392 + del_gendisk(disks[i]);
1393 + put_disk(disks[i]);
1395 + unregister_blkdev(VROOT_MAJOR, "vroot");
1401 +module_init(vroot_init);
1402 +module_exit(vroot_exit);
1406 +static int __init max_vroot_setup(char *str)
1408 + max_vroot = simple_strtol(str, NULL, 0);
1412 +__setup("max_vroot=", max_vroot_setup);
1416 diff -NurpP --minimal linux-2.6.36/drivers/char/sysrq.c linux-2.6.36-vs2.3.0.36.38/drivers/char/sysrq.c
1417 --- linux-2.6.36/drivers/char/sysrq.c 2010-10-21 13:07:02.000000000 +0200
1418 +++ linux-2.6.36-vs2.3.0.36.38/drivers/char/sysrq.c 2010-10-28 18:08:06.000000000 +0200
1420 #include <linux/oom.h>
1421 #include <linux/slab.h>
1422 #include <linux/input.h>
1423 +#include <linux/vserver/debug.h>
1425 #include <asm/ptrace.h>
1426 #include <asm/irq_regs.h>
1427 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
1428 .enable_mask = SYSRQ_ENABLE_RTNICE,
1432 +#ifdef CONFIG_VSERVER_DEBUG
1433 +static void sysrq_handle_vxinfo(int key)
1435 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1438 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1439 + .handler = sysrq_handle_vxinfo,
1440 + .help_msg = "conteXt",
1441 + .action_msg = "Show Context Info",
1442 + .enable_mask = SYSRQ_ENABLE_DUMP,
1446 /* Key Operations table and lock */
1447 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1449 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
1451 &sysrq_showstate_blocked_op, /* w */
1452 /* x: May be registered on ppc/powerpc for xmon */
1453 +#ifdef CONFIG_VSERVER_DEBUG
1454 + &sysrq_showvxinfo_op, /* x */
1458 /* y: May be registered on sparc64 for global register dump */
1460 &sysrq_ftrace_dump_op, /* z */
1461 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
1463 else if ((key >= 'a') && (key <= 'z'))
1464 retval = key + 10 - 'a';
1465 + else if ((key >= 'A') && (key <= 'Z'))
1466 + retval = key + 10 - 'A';
1470 diff -NurpP --minimal linux-2.6.36/drivers/char/tty_io.c linux-2.6.36-vs2.3.0.36.38/drivers/char/tty_io.c
1471 --- linux-2.6.36/drivers/char/tty_io.c 2010-10-21 13:07:02.000000000 +0200
1472 +++ linux-2.6.36-vs2.3.0.36.38/drivers/char/tty_io.c 2010-10-21 13:09:36.000000000 +0200
1475 #include <linux/kmod.h>
1476 #include <linux/nsproxy.h>
1477 +#include <linux/vs_pid.h>
1479 #undef TTY_DEBUG_HANGUP
1481 @@ -2038,7 +2039,8 @@ static int tiocsti(struct tty_struct *tt
1483 struct tty_ldisc *ld;
1485 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1486 + if (((current->signal->tty != tty) &&
1487 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1489 if (get_user(ch, p))
1491 @@ -2326,6 +2328,7 @@ static int tiocspgrp(struct tty_struct *
1493 if (get_user(pgrp_nr, p))
1495 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1499 diff -NurpP --minimal linux-2.6.36/drivers/gpu/drm/radeon/r100_reg_safe.h linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/r100_reg_safe.h
1500 --- linux-2.6.36/drivers/gpu/drm/radeon/r100_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1501 +++ linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/r100_reg_safe.h 2010-10-21 13:09:36.000000000 +0200
1503 +static const unsigned r100_reg_safe_bm[102] = {
1504 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1505 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1506 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1507 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1508 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1509 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1510 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1511 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1512 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1513 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1514 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1515 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1516 + 0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1517 + 0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1518 + 0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
1519 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1520 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
1521 + 0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
1522 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1523 + 0xFFFFFFFF, 0xFFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1524 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1525 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1526 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1527 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1528 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1529 + 0xFFFFFFFF, 0xFFFFFFEF,
1531 diff -NurpP --minimal linux-2.6.36/drivers/gpu/drm/radeon/r200_reg_safe.h linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/r200_reg_safe.h
1532 --- linux-2.6.36/drivers/gpu/drm/radeon/r200_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1533 +++ linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/r200_reg_safe.h 2010-10-21 13:09:36.000000000 +0200
1535 +static const unsigned r200_reg_safe_bm[102] = {
1536 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1537 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1538 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1539 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1540 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1541 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1542 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1543 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1544 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1545 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1546 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1547 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1548 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1549 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1550 + 0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
1551 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1552 + 0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
1553 + 0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
1554 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1555 + 0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1556 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1557 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1558 + 0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
1559 + 0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
1560 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1561 + 0xFFFFFE3F, 0xFFFFFFEF,
1563 diff -NurpP --minimal linux-2.6.36/drivers/gpu/drm/radeon/r300_reg_safe.h linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/r300_reg_safe.h
1564 --- linux-2.6.36/drivers/gpu/drm/radeon/r300_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1565 +++ linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/r300_reg_safe.h 2010-10-21 13:09:36.000000000 +0200
1567 +static const unsigned r300_reg_safe_bm[159] = {
1568 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1569 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1570 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1571 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1572 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1573 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1574 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1575 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1576 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1577 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1578 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1579 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1580 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1581 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1582 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1583 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1584 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1585 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1586 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1587 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1588 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1589 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1590 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1591 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1592 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1593 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1594 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1595 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1596 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1597 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1598 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1599 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1600 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1601 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1602 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1603 + 0x00000000, 0x0000C100, 0x00000000, 0x00000000,
1604 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1605 + 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
1606 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1607 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1609 diff -NurpP --minimal linux-2.6.36/drivers/gpu/drm/radeon/r420_reg_safe.h linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/r420_reg_safe.h
1610 --- linux-2.6.36/drivers/gpu/drm/radeon/r420_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1611 +++ linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/r420_reg_safe.h 2010-10-21 13:09:36.000000000 +0200
1613 +static const unsigned r420_reg_safe_bm[159] = {
1614 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1615 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1616 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1617 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1618 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1619 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1620 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1621 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1622 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1623 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1624 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1625 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1626 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1627 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1628 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1629 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1630 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1631 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1632 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1633 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1634 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1635 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1636 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1637 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1638 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1639 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1640 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1641 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1642 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1643 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1644 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1645 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1646 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1647 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1648 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1649 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1650 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1651 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1652 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1653 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1655 diff -NurpP --minimal linux-2.6.36/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/rn50_reg_safe.h
1656 --- linux-2.6.36/drivers/gpu/drm/radeon/rn50_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1657 +++ linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/rn50_reg_safe.h 2010-10-21 13:09:36.000000000 +0200
1659 +static const unsigned rn50_reg_safe_bm[102] = {
1660 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1661 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1662 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1663 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1664 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1665 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1666 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1667 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1668 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1669 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1670 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1671 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1672 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1673 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1674 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1675 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1676 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1677 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1678 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1679 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1680 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1681 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1682 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1683 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1684 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1685 + 0xFFFFFFFF, 0xFFFFFFFF,
1687 diff -NurpP --minimal linux-2.6.36/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/rs600_reg_safe.h
1688 --- linux-2.6.36/drivers/gpu/drm/radeon/rs600_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1689 +++ linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/rs600_reg_safe.h 2010-10-21 13:09:36.000000000 +0200
1691 +static const unsigned rs600_reg_safe_bm[219] = {
1692 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1693 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1694 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1695 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1696 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1697 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1698 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1699 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1700 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1701 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1702 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1703 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1704 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1705 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1706 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1707 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1708 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1709 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1710 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1711 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1712 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1713 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1714 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1715 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1716 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1717 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1718 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1719 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1720 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1721 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1722 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1723 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1724 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1725 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1726 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1727 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1728 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1729 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1730 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1731 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
1732 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1733 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1734 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1735 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1736 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1737 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1738 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1739 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1740 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1741 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1742 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1743 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1744 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1745 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1746 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1748 diff -NurpP --minimal linux-2.6.36/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/rv515_reg_safe.h
1749 --- linux-2.6.36/drivers/gpu/drm/radeon/rv515_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1750 +++ linux-2.6.36-vs2.3.0.36.38/drivers/gpu/drm/radeon/rv515_reg_safe.h 2010-10-21 13:09:36.000000000 +0200
1752 +static const unsigned rv515_reg_safe_bm[219] = {
1753 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1754 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1755 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1756 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1757 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1758 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1759 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1760 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1761 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1762 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1763 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1764 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1765 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1766 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1767 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1768 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1769 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1770 + 0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1771 + 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
1772 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1773 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1774 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1775 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1776 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1777 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1778 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1779 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1780 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1781 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1782 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1783 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1784 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1785 + 0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
1786 + 0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
1787 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1788 + 0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
1789 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1790 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
1791 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1792 + 0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
1793 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1794 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1795 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1796 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1797 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1798 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1799 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1800 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1801 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1802 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1803 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1804 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1805 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1806 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1807 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1809 diff -NurpP --minimal linux-2.6.36/drivers/infiniband/core/addr.c linux-2.6.36-vs2.3.0.36.38/drivers/infiniband/core/addr.c
1810 --- linux-2.6.36/drivers/infiniband/core/addr.c 2010-10-21 13:07:05.000000000 +0200
1811 +++ linux-2.6.36-vs2.3.0.36.38/drivers/infiniband/core/addr.c 2010-10-21 13:09:36.000000000 +0200
1812 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
1814 if (ipv6_addr_any(&fl.fl6_src)) {
1815 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1816 - &fl.fl6_dst, 0, &fl.fl6_src);
1817 + &fl.fl6_dst, 0, &fl.fl6_src, NULL);
1821 diff -NurpP --minimal linux-2.6.36/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.36-vs2.3.0.36.38/drivers/infiniband/hw/ipath/ipath_user_pages.c
1822 --- linux-2.6.36/drivers/infiniband/hw/ipath/ipath_user_pages.c 2010-07-07 18:31:19.000000000 +0200
1823 +++ linux-2.6.36-vs2.3.0.36.38/drivers/infiniband/hw/ipath/ipath_user_pages.c 2010-10-21 13:09:36.000000000 +0200
1825 #include <linux/device.h>
1826 #include <linux/slab.h>
1827 #include <linux/sched.h>
1828 +#include <linux/vs_memory.h>
1830 #include "ipath_kernel.h"
1832 diff -NurpP --minimal linux-2.6.36/drivers/md/dm-ioctl.c linux-2.6.36-vs2.3.0.36.38/drivers/md/dm-ioctl.c
1833 --- linux-2.6.36/drivers/md/dm-ioctl.c 2010-10-21 13:07:07.000000000 +0200
1834 +++ linux-2.6.36-vs2.3.0.36.38/drivers/md/dm-ioctl.c 2010-10-21 13:09:36.000000000 +0200
1836 #include <linux/dm-ioctl.h>
1837 #include <linux/hdreg.h>
1838 #include <linux/compat.h>
1839 +#include <linux/vs_context.h>
1841 #include <asm/uaccess.h>
1843 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1844 unsigned int h = hash_str(str);
1846 list_for_each_entry (hc, _name_buckets + h, name_list)
1847 - if (!strcmp(hc->name, str)) {
1848 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1849 + !strcmp(hc->name, str)) {
1853 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1854 unsigned int h = hash_str(str);
1856 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1857 - if (!strcmp(hc->uuid, str)) {
1858 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1859 + !strcmp(hc->uuid, str)) {
1863 @@ -377,6 +380,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1865 static int remove_all(struct dm_ioctl *param, size_t param_size)
1867 + if (!vx_check(0, VS_ADMIN))
1870 dm_hash_remove_all(1);
1871 param->data_size = 0;
1873 @@ -424,6 +430,8 @@ static int list_devices(struct dm_ioctl
1875 for (i = 0; i < NUM_BUCKETS; i++) {
1876 list_for_each_entry (hc, _name_buckets + i, name_list) {
1877 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1879 needed += sizeof(struct dm_name_list);
1880 needed += strlen(hc->name) + 1;
1881 needed += ALIGN_MASK;
1882 @@ -447,6 +455,8 @@ static int list_devices(struct dm_ioctl
1884 for (i = 0; i < NUM_BUCKETS; i++) {
1885 list_for_each_entry (hc, _name_buckets + i, name_list) {
1886 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1889 old_nl->next = (uint32_t) ((void *) nl -
1891 @@ -681,10 +691,11 @@ static struct hash_cell *__find_device_h
1895 - mdptr = dm_get_mdptr(md);
1896 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1897 + mdptr = dm_get_mdptr(md);
1905 @@ -1513,8 +1524,8 @@ static int ctl_ioctl(uint command, struc
1909 - /* only root can play with this */
1910 - if (!capable(CAP_SYS_ADMIN))
1911 + /* only root and certain contexts can play with this */
1912 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1915 if (_IOC_TYPE(command) != DM_IOCTL)
1916 diff -NurpP --minimal linux-2.6.36/drivers/md/dm.c linux-2.6.36-vs2.3.0.36.38/drivers/md/dm.c
1917 --- linux-2.6.36/drivers/md/dm.c 2010-10-21 13:07:07.000000000 +0200
1918 +++ linux-2.6.36-vs2.3.0.36.38/drivers/md/dm.c 2010-10-21 15:19:30.000000000 +0200
1920 #include <linux/idr.h>
1921 #include <linux/hdreg.h>
1922 #include <linux/delay.h>
1923 +#include <linux/vs_base.h>
1925 #include <trace/events/block.h>
1927 @@ -121,6 +122,7 @@ struct mapped_device {
1930 atomic_t open_count;
1933 unsigned long flags;
1935 @@ -343,6 +345,7 @@ int dm_deleting_md(struct mapped_device
1936 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1938 struct mapped_device *md;
1942 spin_lock(&_minor_lock);
1943 @@ -352,19 +355,20 @@ static int dm_blk_open(struct block_devi
1946 if (test_bit(DMF_FREEING, &md->flags) ||
1947 - dm_deleting_md(md)) {
1949 + dm_deleting_md(md))
1953 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1958 atomic_inc(&md->open_count);
1962 spin_unlock(&_minor_lock);
1965 - return md ? 0 : -ENXIO;
1969 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1970 @@ -586,6 +590,14 @@ int dm_set_geometry(struct mapped_device
1975 + * Get the xid associated with a dm device
1977 +xid_t dm_get_xid(struct mapped_device *md)
1982 /*-----------------------------------------------------------------
1984 * A more elegant soln is in the works that uses the queue
1985 @@ -1981,6 +1993,7 @@ static struct mapped_device *alloc_dev(i
1986 INIT_LIST_HEAD(&md->uevent_list);
1987 spin_lock_init(&md->uevent_lock);
1989 + md->xid = vx_current_xid();
1990 md->queue = blk_alloc_queue(GFP_KERNEL);
1993 diff -NurpP --minimal linux-2.6.36/drivers/md/dm.h linux-2.6.36-vs2.3.0.36.38/drivers/md/dm.h
1994 --- linux-2.6.36/drivers/md/dm.h 2010-10-21 13:07:07.000000000 +0200
1995 +++ linux-2.6.36-vs2.3.0.36.38/drivers/md/dm.h 2010-10-21 13:09:36.000000000 +0200
1996 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1998 struct dm_md_mempools;
2000 +xid_t dm_get_xid(struct mapped_device *md);
2002 /*-----------------------------------------------------------------
2003 * Internal table functions.
2004 *---------------------------------------------------------------*/
2005 diff -NurpP --minimal linux-2.6.36/drivers/net/tun.c linux-2.6.36-vs2.3.0.36.38/drivers/net/tun.c
2006 --- linux-2.6.36/drivers/net/tun.c 2010-10-21 13:07:15.000000000 +0200
2007 +++ linux-2.6.36-vs2.3.0.36.38/drivers/net/tun.c 2010-10-21 13:09:36.000000000 +0200
2009 #include <linux/nsproxy.h>
2010 #include <linux/virtio_net.h>
2011 #include <linux/rcupdate.h>
2012 +#include <linux/vs_network.h>
2013 #include <net/net_namespace.h>
2014 #include <net/netns/generic.h>
2015 #include <net/rtnetlink.h>
2016 @@ -103,6 +104,7 @@ struct tun_struct {
2022 struct net_device *dev;
2023 struct fasync_struct *fasync;
2024 @@ -853,6 +855,7 @@ static void tun_setup(struct net_device
2028 + tun->nid = current->nid;
2030 dev->ethtool_ops = &tun_ethtool_ops;
2031 dev->destructor = tun_free_netdev;
2032 @@ -1003,7 +1006,7 @@ static int tun_set_iff(struct net *net,
2034 if (((tun->owner != -1 && cred->euid != tun->owner) ||
2035 (tun->group != -1 && !in_egroup_p(tun->group))) &&
2036 - !capable(CAP_NET_ADMIN))
2037 + !cap_raised(current_cap(), CAP_NET_ADMIN))
2039 err = security_tun_dev_attach(tun->socket.sk);
2041 @@ -1017,7 +1020,7 @@ static int tun_set_iff(struct net *net,
2043 unsigned long flags = 0;
2045 - if (!capable(CAP_NET_ADMIN))
2046 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
2048 err = security_tun_dev_create();
2050 @@ -1087,6 +1090,9 @@ static int tun_set_iff(struct net *net,
2052 sk->sk_destruct = tun_sock_destruct;
2054 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
2057 err = tun_attach(tun, file);
2060 @@ -1278,6 +1284,16 @@ static long __tun_chr_ioctl(struct file
2061 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
2065 + if (!capable(CAP_CONTEXT))
2068 + /* Set nid owner of the device */
2069 + tun->nid = (nid_t) arg;
2071 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
2075 /* Only allow setting the type when the interface is down */
2076 if (tun->dev->flags & IFF_UP) {
2077 diff -NurpP --minimal linux-2.6.36/fs/attr.c linux-2.6.36-vs2.3.0.36.38/fs/attr.c
2078 --- linux-2.6.36/fs/attr.c 2010-10-21 13:07:47.000000000 +0200
2079 +++ linux-2.6.36-vs2.3.0.36.38/fs/attr.c 2010-10-21 14:04:40.000000000 +0200
2081 #include <linux/fsnotify.h>
2082 #include <linux/fcntl.h>
2083 #include <linux/security.h>
2084 +#include <linux/proc_fs.h>
2085 +#include <linux/devpts_fs.h>
2086 +#include <linux/vs_tag.h>
2089 * inode_change_ok - check if attribute changes to an inode are allowed
2090 @@ -73,6 +76,10 @@ int inode_change_ok(const struct inode *
2094 + /* check for inode tag permission */
2095 + if (dx_permission(inode, MAY_WRITE))
2100 EXPORT_SYMBOL(inode_change_ok);
2101 @@ -143,6 +150,8 @@ void setattr_copy(struct inode *inode, c
2102 inode->i_uid = attr->ia_uid;
2103 if (ia_valid & ATTR_GID)
2104 inode->i_gid = attr->ia_gid;
2105 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2106 + inode->i_tag = attr->ia_tag;
2107 if (ia_valid & ATTR_ATIME)
2108 inode->i_atime = timespec_trunc(attr->ia_atime,
2109 inode->i_sb->s_time_gran);
2110 @@ -170,7 +179,8 @@ int notify_change(struct dentry * dentry
2111 struct timespec now;
2112 unsigned int ia_valid = attr->ia_valid;
2114 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
2115 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
2116 + ATTR_TAG | ATTR_TIMES_SET)) {
2117 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
2120 diff -NurpP --minimal linux-2.6.36/fs/binfmt_aout.c linux-2.6.36-vs2.3.0.36.38/fs/binfmt_aout.c
2121 --- linux-2.6.36/fs/binfmt_aout.c 2010-10-21 13:07:47.000000000 +0200
2122 +++ linux-2.6.36-vs2.3.0.36.38/fs/binfmt_aout.c 2010-10-21 13:09:36.000000000 +0200
2124 #include <linux/init.h>
2125 #include <linux/coredump.h>
2126 #include <linux/slab.h>
2127 +#include <linux/vs_memory.h>
2129 #include <asm/system.h>
2130 #include <asm/uaccess.h>
2131 diff -NurpP --minimal linux-2.6.36/fs/binfmt_elf.c linux-2.6.36-vs2.3.0.36.38/fs/binfmt_elf.c
2132 --- linux-2.6.36/fs/binfmt_elf.c 2010-07-07 18:31:50.000000000 +0200
2133 +++ linux-2.6.36-vs2.3.0.36.38/fs/binfmt_elf.c 2010-10-21 13:09:36.000000000 +0200
2135 #include <linux/elf.h>
2136 #include <linux/utsname.h>
2137 #include <linux/coredump.h>
2138 +#include <linux/vs_memory.h>
2139 #include <asm/uaccess.h>
2140 #include <asm/param.h>
2141 #include <asm/page.h>
2142 diff -NurpP --minimal linux-2.6.36/fs/binfmt_flat.c linux-2.6.36-vs2.3.0.36.38/fs/binfmt_flat.c
2143 --- linux-2.6.36/fs/binfmt_flat.c 2010-08-02 16:52:47.000000000 +0200
2144 +++ linux-2.6.36-vs2.3.0.36.38/fs/binfmt_flat.c 2010-10-21 13:09:36.000000000 +0200
2146 #include <linux/init.h>
2147 #include <linux/flat.h>
2148 #include <linux/syscalls.h>
2149 +#include <linux/vs_memory.h>
2151 #include <asm/byteorder.h>
2152 #include <asm/system.h>
2153 diff -NurpP --minimal linux-2.6.36/fs/binfmt_som.c linux-2.6.36-vs2.3.0.36.38/fs/binfmt_som.c
2154 --- linux-2.6.36/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
2155 +++ linux-2.6.36-vs2.3.0.36.38/fs/binfmt_som.c 2010-10-21 13:09:36.000000000 +0200
2157 #include <linux/shm.h>
2158 #include <linux/personality.h>
2159 #include <linux/init.h>
2160 +#include <linux/vs_memory.h>
2162 #include <asm/uaccess.h>
2163 #include <asm/pgtable.h>
2164 diff -NurpP --minimal linux-2.6.36/fs/block_dev.c linux-2.6.36-vs2.3.0.36.38/fs/block_dev.c
2165 --- linux-2.6.36/fs/block_dev.c 2010-10-21 13:07:47.000000000 +0200
2166 +++ linux-2.6.36-vs2.3.0.36.38/fs/block_dev.c 2010-10-21 13:09:36.000000000 +0200
2168 #include <linux/namei.h>
2169 #include <linux/log2.h>
2170 #include <linux/kmemleak.h>
2171 +#include <linux/vs_device.h>
2172 #include <asm/uaccess.h>
2173 #include "internal.h"
2175 @@ -530,6 +531,7 @@ struct block_device *bdget(dev_t dev)
2176 bdev->bd_invalidated = 0;
2177 inode->i_mode = S_IFBLK;
2178 inode->i_rdev = dev;
2179 + inode->i_mdev = dev;
2180 inode->i_bdev = bdev;
2181 inode->i_data.a_ops = &def_blk_aops;
2182 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2183 @@ -576,6 +578,11 @@ EXPORT_SYMBOL(bdput);
2184 static struct block_device *bd_acquire(struct inode *inode)
2186 struct block_device *bdev;
2189 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2191 + inode->i_mdev = mdev;
2193 spin_lock(&bdev_lock);
2194 bdev = inode->i_bdev;
2195 @@ -586,7 +593,7 @@ static struct block_device *bd_acquire(s
2197 spin_unlock(&bdev_lock);
2199 - bdev = bdget(inode->i_rdev);
2200 + bdev = bdget(mdev);
2202 spin_lock(&bdev_lock);
2203 if (!inode->i_bdev) {
2204 diff -NurpP --minimal linux-2.6.36/fs/btrfs/ctree.h linux-2.6.36-vs2.3.0.36.38/fs/btrfs/ctree.h
2205 --- linux-2.6.36/fs/btrfs/ctree.h 2010-10-21 13:07:48.000000000 +0200
2206 +++ linux-2.6.36-vs2.3.0.36.38/fs/btrfs/ctree.h 2010-10-21 13:09:36.000000000 +0200
2207 @@ -551,11 +551,14 @@ struct btrfs_inode_item {
2208 /* modification sequence number for NFS */
2213 * a little future expansion, for more than this we can
2214 * just grow the inode item and version it
2216 - __le64 reserved[4];
2217 + __le16 reserved16;
2218 + __le32 reserved32;
2219 + __le64 reserved[3];
2220 struct btrfs_timespec atime;
2221 struct btrfs_timespec ctime;
2222 struct btrfs_timespec mtime;
2223 @@ -1193,6 +1196,8 @@ struct btrfs_root {
2224 #define BTRFS_MOUNT_DISCARD (1 << 10)
2225 #define BTRFS_MOUNT_FORCE_COMPRESS (1 << 11)
2227 +#define BTRFS_MOUNT_TAGGED (1 << 24)
2229 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
2230 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
2231 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
2232 @@ -1413,6 +1418,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
2233 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
2234 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
2235 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
2236 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
2237 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
2238 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
2239 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
2240 @@ -1474,6 +1480,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
2242 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
2244 +#define BTRFS_INODE_IXUNLINK (1 << 24)
2245 +#define BTRFS_INODE_BARRIER (1 << 25)
2246 +#define BTRFS_INODE_COW (1 << 26)
2249 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
2251 @@ -2432,6 +2442,7 @@ extern const struct dentry_operations bt
2252 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2253 void btrfs_update_iflags(struct inode *inode);
2254 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2255 +int btrfs_sync_flags(struct inode *inode, int, int);
2258 int btrfs_sync_file(struct file *file, int datasync);
2259 diff -NurpP --minimal linux-2.6.36/fs/btrfs/disk-io.c linux-2.6.36-vs2.3.0.36.38/fs/btrfs/disk-io.c
2260 --- linux-2.6.36/fs/btrfs/disk-io.c 2010-10-21 13:07:48.000000000 +0200
2261 +++ linux-2.6.36-vs2.3.0.36.38/fs/btrfs/disk-io.c 2010-10-21 13:09:36.000000000 +0200
2262 @@ -1707,6 +1707,9 @@ struct btrfs_root *open_ctree(struct sup
2266 + if (btrfs_test_opt(tree_root, TAGGED))
2267 + sb->s_flags |= MS_TAGGED;
2269 features = btrfs_super_incompat_flags(disk_super) &
2270 ~BTRFS_FEATURE_INCOMPAT_SUPP;
2272 diff -NurpP --minimal linux-2.6.36/fs/btrfs/inode.c linux-2.6.36-vs2.3.0.36.38/fs/btrfs/inode.c
2273 --- linux-2.6.36/fs/btrfs/inode.c 2010-10-21 13:07:48.000000000 +0200
2274 +++ linux-2.6.36-vs2.3.0.36.38/fs/btrfs/inode.c 2010-10-21 13:09:36.000000000 +0200
2276 #include <linux/posix_acl.h>
2277 #include <linux/falloc.h>
2278 #include <linux/slab.h>
2279 +#include <linux/vs_tag.h>
2283 #include "disk-io.h"
2284 @@ -2415,6 +2417,8 @@ static void btrfs_read_locked_inode(stru
2286 u64 alloc_group_block;
2292 path = btrfs_alloc_path();
2293 @@ -2431,8 +2435,13 @@ static void btrfs_read_locked_inode(stru
2295 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
2296 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
2297 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
2298 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
2300 + uid = btrfs_inode_uid(leaf, inode_item);
2301 + gid = btrfs_inode_gid(leaf, inode_item);
2302 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2303 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2304 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2305 + btrfs_inode_tag(leaf, inode_item));
2306 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
2308 tspec = btrfs_inode_atime(inode_item);
2309 @@ -2514,8 +2523,15 @@ static void fill_inode_item(struct btrfs
2310 struct btrfs_inode_item *item,
2311 struct inode *inode)
2313 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
2314 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
2315 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2316 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2318 + btrfs_set_inode_uid(leaf, item, uid);
2319 + btrfs_set_inode_gid(leaf, item, gid);
2320 +#ifdef CONFIG_TAGGING_INTERN
2321 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
2324 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
2325 btrfs_set_inode_mode(leaf, item, inode->i_mode);
2326 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
2327 @@ -6946,6 +6962,7 @@ static const struct inode_operations btr
2328 .listxattr = btrfs_listxattr,
2329 .removexattr = btrfs_removexattr,
2330 .permission = btrfs_permission,
2331 + .sync_flags = btrfs_sync_flags,
2333 static const struct inode_operations btrfs_dir_ro_inode_operations = {
2334 .lookup = btrfs_lookup,
2335 @@ -7021,6 +7038,7 @@ static const struct inode_operations btr
2336 .permission = btrfs_permission,
2337 .fallocate = btrfs_fallocate,
2338 .fiemap = btrfs_fiemap,
2339 + .sync_flags = btrfs_sync_flags,
2341 static const struct inode_operations btrfs_special_inode_operations = {
2342 .getattr = btrfs_getattr,
2343 diff -NurpP --minimal linux-2.6.36/fs/btrfs/ioctl.c linux-2.6.36-vs2.3.0.36.38/fs/btrfs/ioctl.c
2344 --- linux-2.6.36/fs/btrfs/ioctl.c 2010-08-02 16:52:47.000000000 +0200
2345 +++ linux-2.6.36-vs2.3.0.36.38/fs/btrfs/ioctl.c 2010-10-21 13:09:36.000000000 +0200
2346 @@ -68,10 +68,13 @@ static unsigned int btrfs_flags_to_ioctl
2348 unsigned int iflags = 0;
2350 - if (flags & BTRFS_INODE_SYNC)
2351 - iflags |= FS_SYNC_FL;
2352 if (flags & BTRFS_INODE_IMMUTABLE)
2353 iflags |= FS_IMMUTABLE_FL;
2354 + if (flags & BTRFS_INODE_IXUNLINK)
2355 + iflags |= FS_IXUNLINK_FL;
2357 + if (flags & BTRFS_INODE_SYNC)
2358 + iflags |= FS_SYNC_FL;
2359 if (flags & BTRFS_INODE_APPEND)
2360 iflags |= FS_APPEND_FL;
2361 if (flags & BTRFS_INODE_NODUMP)
2362 @@ -81,28 +84,78 @@ static unsigned int btrfs_flags_to_ioctl
2363 if (flags & BTRFS_INODE_DIRSYNC)
2364 iflags |= FS_DIRSYNC_FL;
2366 + if (flags & BTRFS_INODE_BARRIER)
2367 + iflags |= FS_BARRIER_FL;
2368 + if (flags & BTRFS_INODE_COW)
2369 + iflags |= FS_COW_FL;
2374 - * Update inode->i_flags based on the btrfs internal flags.
2375 + * Update inode->i_(v)flags based on the btrfs internal flags.
2377 void btrfs_update_iflags(struct inode *inode)
2379 struct btrfs_inode *ip = BTRFS_I(inode);
2381 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2382 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2383 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2385 - if (ip->flags & BTRFS_INODE_SYNC)
2386 - inode->i_flags |= S_SYNC;
2387 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2388 inode->i_flags |= S_IMMUTABLE;
2389 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2390 + inode->i_flags |= S_IXUNLINK;
2392 + if (ip->flags & BTRFS_INODE_SYNC)
2393 + inode->i_flags |= S_SYNC;
2394 if (ip->flags & BTRFS_INODE_APPEND)
2395 inode->i_flags |= S_APPEND;
2396 if (ip->flags & BTRFS_INODE_NOATIME)
2397 inode->i_flags |= S_NOATIME;
2398 if (ip->flags & BTRFS_INODE_DIRSYNC)
2399 inode->i_flags |= S_DIRSYNC;
2401 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2403 + if (ip->flags & BTRFS_INODE_BARRIER)
2404 + inode->i_vflags |= V_BARRIER;
2405 + if (ip->flags & BTRFS_INODE_COW)
2406 + inode->i_vflags |= V_COW;
2410 + * Update btrfs internal flags from inode->i_(v)flags.
2412 +void btrfs_update_flags(struct inode *inode)
2414 + struct btrfs_inode *ip = BTRFS_I(inode);
2416 + unsigned int flags = inode->i_flags;
2417 + unsigned int vflags = inode->i_vflags;
2419 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2420 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2421 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2422 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2424 + if (flags & S_IMMUTABLE)
2425 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2426 + if (flags & S_IXUNLINK)
2427 + ip->flags |= BTRFS_INODE_IXUNLINK;
2429 + if (flags & S_SYNC)
2430 + ip->flags |= BTRFS_INODE_SYNC;
2431 + if (flags & S_APPEND)
2432 + ip->flags |= BTRFS_INODE_APPEND;
2433 + if (flags & S_NOATIME)
2434 + ip->flags |= BTRFS_INODE_NOATIME;
2435 + if (flags & S_DIRSYNC)
2436 + ip->flags |= BTRFS_INODE_DIRSYNC;
2438 + if (vflags & V_BARRIER)
2439 + ip->flags |= BTRFS_INODE_BARRIER;
2440 + if (vflags & V_COW)
2441 + ip->flags |= BTRFS_INODE_COW;
2445 @@ -120,7 +173,7 @@ void btrfs_inherit_iflags(struct inode *
2446 flags = BTRFS_I(dir)->flags;
2448 if (S_ISREG(inode->i_mode))
2449 - flags &= ~BTRFS_INODE_DIRSYNC;
2450 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2451 else if (!S_ISDIR(inode->i_mode))
2452 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2454 @@ -128,6 +181,30 @@ void btrfs_inherit_iflags(struct inode *
2455 btrfs_update_iflags(inode);
2458 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2460 + struct btrfs_inode *ip = BTRFS_I(inode);
2461 + struct btrfs_root *root = ip->root;
2462 + struct btrfs_trans_handle *trans;
2465 + trans = btrfs_join_transaction(root, 1);
2468 + inode->i_flags = flags;
2469 + inode->i_vflags = vflags;
2470 + btrfs_update_flags(inode);
2472 + ret = btrfs_update_inode(trans, root, inode);
2475 + btrfs_update_iflags(inode);
2476 + inode->i_ctime = CURRENT_TIME;
2477 + btrfs_end_transaction(trans, root);
2482 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2484 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2485 @@ -150,6 +227,7 @@ static int btrfs_ioctl_setflags(struct f
2486 if (copy_from_user(&flags, arg, sizeof(flags)))
2489 + /* maybe add FS_IXUNLINK_FL ? */
2490 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
2491 FS_NOATIME_FL | FS_NODUMP_FL | \
2492 FS_SYNC_FL | FS_DIRSYNC_FL))
2493 @@ -162,7 +240,8 @@ static int btrfs_ioctl_setflags(struct f
2495 flags = btrfs_mask_flags(inode->i_mode, flags);
2496 oldflags = btrfs_flags_to_ioctl(ip->flags);
2497 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2498 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2499 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2500 if (!capable(CAP_LINUX_IMMUTABLE)) {
2503 @@ -173,14 +252,19 @@ static int btrfs_ioctl_setflags(struct f
2507 - if (flags & FS_SYNC_FL)
2508 - ip->flags |= BTRFS_INODE_SYNC;
2510 - ip->flags &= ~BTRFS_INODE_SYNC;
2511 if (flags & FS_IMMUTABLE_FL)
2512 ip->flags |= BTRFS_INODE_IMMUTABLE;
2514 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2515 + if (flags & FS_IXUNLINK_FL)
2516 + ip->flags |= BTRFS_INODE_IXUNLINK;
2518 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2520 + if (flags & FS_SYNC_FL)
2521 + ip->flags |= BTRFS_INODE_SYNC;
2523 + ip->flags &= ~BTRFS_INODE_SYNC;
2524 if (flags & FS_APPEND_FL)
2525 ip->flags |= BTRFS_INODE_APPEND;
2527 diff -NurpP --minimal linux-2.6.36/fs/btrfs/super.c linux-2.6.36-vs2.3.0.36.38/fs/btrfs/super.c
2528 --- linux-2.6.36/fs/btrfs/super.c 2010-10-21 13:07:48.000000000 +0200
2529 +++ linux-2.6.36-vs2.3.0.36.38/fs/btrfs/super.c 2010-10-21 13:09:36.000000000 +0200
2530 @@ -68,7 +68,7 @@ enum {
2531 Opt_nodatacow, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, Opt_ssd,
2532 Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress,
2533 Opt_compress_force, Opt_notreelog, Opt_ratio, Opt_flushoncommit,
2534 - Opt_discard, Opt_err,
2535 + Opt_tag, Opt_notag, Opt_tagid, Opt_discard, Opt_err,
2538 static match_table_t tokens = {
2539 @@ -92,6 +92,9 @@ static match_table_t tokens = {
2540 {Opt_flushoncommit, "flushoncommit"},
2541 {Opt_ratio, "metadata_ratio=%d"},
2542 {Opt_discard, "discard"},
2544 + {Opt_notag, "notag"},
2545 + {Opt_tagid, "tagid=%u"},
2549 @@ -235,6 +238,22 @@ int btrfs_parse_options(struct btrfs_roo
2551 btrfs_set_opt(info->mount_opt, DISCARD);
2553 +#ifndef CONFIG_TAGGING_NONE
2555 + printk(KERN_INFO "btrfs: use tagging\n");
2556 + btrfs_set_opt(info->mount_opt, TAGGED);
2559 + printk(KERN_INFO "btrfs: disabled tagging\n");
2560 + btrfs_clear_opt(info->mount_opt, TAGGED);
2563 +#ifdef CONFIG_PROPAGATE
2566 + btrfs_set_opt(info->mount_opt, TAGGED);
2570 printk(KERN_INFO "btrfs: unrecognized mount option "
2572 @@ -681,6 +700,12 @@ static int btrfs_remount(struct super_bl
2576 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2577 + printk("btrfs: %s: tagging not permitted on remount.\n",
2582 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2585 diff -NurpP --minimal linux-2.6.36/fs/char_dev.c linux-2.6.36-vs2.3.0.36.38/fs/char_dev.c
2586 --- linux-2.6.36/fs/char_dev.c 2010-10-21 13:07:48.000000000 +0200
2587 +++ linux-2.6.36-vs2.3.0.36.38/fs/char_dev.c 2010-10-21 13:09:36.000000000 +0200
2589 #include <linux/mutex.h>
2590 #include <linux/backing-dev.h>
2591 #include <linux/tty.h>
2592 +#include <linux/vs_context.h>
2593 +#include <linux/vs_device.h>
2595 #include "internal.h"
2597 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2599 struct cdev *new = NULL;
2603 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2605 + inode->i_mdev = mdev;
2607 spin_lock(&cdev_lock);
2610 struct kobject *kobj;
2613 spin_unlock(&cdev_lock);
2614 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2616 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2619 new = container_of(kobj, struct cdev, kobj);
2620 diff -NurpP --minimal linux-2.6.36/fs/dcache.c linux-2.6.36-vs2.3.0.36.38/fs/dcache.c
2621 --- linux-2.6.36/fs/dcache.c 2010-10-21 13:07:48.000000000 +0200
2622 +++ linux-2.6.36-vs2.3.0.36.38/fs/dcache.c 2010-10-21 13:09:36.000000000 +0200
2624 #include <linux/bootmem.h>
2625 #include <linux/fs_struct.h>
2626 #include <linux/hardirq.h>
2627 +#include <linux/vs_limit.h>
2628 #include "internal.h"
2630 int sysctl_vfs_cache_pressure __read_mostly = 100;
2631 @@ -230,6 +231,8 @@ repeat:
2635 + vx_dentry_dec(dentry);
2638 * AV: ->d_delete() is _NOT_ allowed to block now.
2640 @@ -323,6 +326,7 @@ static inline struct dentry * __dget_loc
2642 atomic_inc(&dentry->d_count);
2643 dentry_lru_del_init(dentry);
2644 + vx_dentry_inc(dentry);
2648 @@ -928,6 +932,9 @@ struct dentry *d_alloc(struct dentry * p
2649 struct dentry *dentry;
2652 + if (!vx_dentry_avail(1))
2655 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2658 @@ -973,6 +980,7 @@ struct dentry *d_alloc(struct dentry * p
2660 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
2661 dentry_stat.nr_dentry++;
2662 + vx_dentry_inc(dentry);
2663 spin_unlock(&dcache_lock);
2666 @@ -1432,6 +1440,7 @@ struct dentry * __d_lookup(struct dentry
2669 atomic_inc(&dentry->d_count);
2670 + vx_dentry_inc(dentry);
2672 spin_unlock(&dentry->d_lock);
2674 diff -NurpP --minimal linux-2.6.36/fs/devpts/inode.c linux-2.6.36-vs2.3.0.36.38/fs/devpts/inode.c
2675 --- linux-2.6.36/fs/devpts/inode.c 2010-08-02 16:52:48.000000000 +0200
2676 +++ linux-2.6.36-vs2.3.0.36.38/fs/devpts/inode.c 2010-10-21 22:25:15.000000000 +0200
2678 #include <linux/parser.h>
2679 #include <linux/fsnotify.h>
2680 #include <linux/seq_file.h>
2681 +#include <linux/vs_base.h>
2683 #define DEVPTS_DEFAULT_MODE 0600
2686 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2687 #define PTMX_MINOR 2
2689 +static int devpts_permission(struct inode *inode, int mask)
2691 + int ret = -EACCES;
2693 + /* devpts is xid tagged */
2694 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2695 + ret = generic_permission(inode, mask, NULL);
2699 +static struct inode_operations devpts_file_inode_operations = {
2700 + .permission = devpts_permission,
2703 extern int pty_limit; /* Config limit on Unix98 ptys */
2704 static DEFINE_MUTEX(allocated_ptys_lock);
2706 @@ -263,6 +278,25 @@ static int devpts_show_options(struct se
2710 +static int devpts_filter(struct dentry *de)
2712 + /* devpts is xid tagged */
2713 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
2716 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2718 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2721 +static struct file_operations devpts_dir_operations = {
2722 + .open = dcache_dir_open,
2723 + .release = dcache_dir_close,
2724 + .llseek = dcache_dir_lseek,
2725 + .read = generic_read_dir,
2726 + .readdir = devpts_readdir,
2729 static const struct super_operations devpts_sops = {
2730 .statfs = simple_statfs,
2731 .remount_fs = devpts_remount,
2732 @@ -302,12 +336,15 @@ devpts_fill_super(struct super_block *s,
2733 inode = new_inode(s);
2738 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2739 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2740 inode->i_op = &simple_dir_inode_operations;
2741 - inode->i_fop = &simple_dir_operations;
2742 + inode->i_fop = &devpts_dir_operations;
2744 + /* devpts is xid tagged */
2745 + inode->i_tag = (tag_t)vx_current_xid();
2747 s->s_root = d_alloc_root(inode);
2749 @@ -495,6 +532,9 @@ int devpts_pty_new(struct inode *ptmx_in
2750 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2751 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2752 init_special_inode(inode, S_IFCHR|opts->mode, device);
2753 + /* devpts is xid tagged */
2754 + inode->i_tag = (tag_t)vx_current_xid();
2755 + inode->i_op = &devpts_file_inode_operations;
2756 inode->i_private = tty;
2757 tty->driver_data = inode;
2759 diff -NurpP --minimal linux-2.6.36/fs/ext2/balloc.c linux-2.6.36-vs2.3.0.36.38/fs/ext2/balloc.c
2760 --- linux-2.6.36/fs/ext2/balloc.c 2010-10-21 13:07:48.000000000 +0200
2761 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext2/balloc.c 2010-10-21 13:09:36.000000000 +0200
2762 @@ -702,7 +702,6 @@ ext2_try_to_allocate(struct super_block
2764 end = EXT2_BLOCKS_PER_GROUP(sb);
2767 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2770 diff -NurpP --minimal linux-2.6.36/fs/ext2/ext2.h linux-2.6.36-vs2.3.0.36.38/fs/ext2/ext2.h
2771 --- linux-2.6.36/fs/ext2/ext2.h 2010-10-21 13:07:48.000000000 +0200
2772 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext2/ext2.h 2010-10-21 14:10:55.000000000 +0200
2773 @@ -127,6 +127,7 @@ extern void ext2_set_inode_flags(struct
2774 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2775 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2776 u64 start, u64 len);
2777 +extern int ext2_sync_flags(struct inode *, int, int);
2780 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2781 diff -NurpP --minimal linux-2.6.36/fs/ext2/file.c linux-2.6.36-vs2.3.0.36.38/fs/ext2/file.c
2782 --- linux-2.6.36/fs/ext2/file.c 2010-08-02 16:52:48.000000000 +0200
2783 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext2/file.c 2010-10-21 13:09:36.000000000 +0200
2784 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2785 .setattr = ext2_setattr,
2786 .check_acl = ext2_check_acl,
2787 .fiemap = ext2_fiemap,
2788 + .sync_flags = ext2_sync_flags,
2790 diff -NurpP --minimal linux-2.6.36/fs/ext2/ialloc.c linux-2.6.36-vs2.3.0.36.38/fs/ext2/ialloc.c
2791 --- linux-2.6.36/fs/ext2/ialloc.c 2010-10-21 13:07:48.000000000 +0200
2792 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext2/ialloc.c 2010-10-21 13:09:36.000000000 +0200
2794 #include <linux/backing-dev.h>
2795 #include <linux/buffer_head.h>
2796 #include <linux/random.h>
2797 +#include <linux/vs_tag.h>
2801 @@ -548,6 +549,7 @@ got:
2802 inode->i_mode = mode;
2803 inode->i_uid = current_fsuid();
2804 inode->i_gid = dir->i_gid;
2805 + inode->i_tag = dx_current_fstag(sb);
2807 inode_init_owner(inode, dir, mode);
2809 diff -NurpP --minimal linux-2.6.36/fs/ext2/inode.c linux-2.6.36-vs2.3.0.36.38/fs/ext2/inode.c
2810 --- linux-2.6.36/fs/ext2/inode.c 2010-10-21 13:07:48.000000000 +0200
2811 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext2/inode.c 2010-10-21 13:09:36.000000000 +0200
2813 #include <linux/mpage.h>
2814 #include <linux/fiemap.h>
2815 #include <linux/namei.h>
2816 +#include <linux/vs_tag.h>
2820 @@ -1169,7 +1170,7 @@ static void ext2_truncate_blocks(struct
2822 if (ext2_inode_is_fast_symlink(inode))
2824 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2825 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2827 __ext2_truncate_blocks(inode, offset);
2829 @@ -1258,36 +1259,61 @@ void ext2_set_inode_flags(struct inode *
2831 unsigned int flags = EXT2_I(inode)->i_flags;
2833 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2834 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2835 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2838 + if (flags & EXT2_IMMUTABLE_FL)
2839 + inode->i_flags |= S_IMMUTABLE;
2840 + if (flags & EXT2_IXUNLINK_FL)
2841 + inode->i_flags |= S_IXUNLINK;
2843 if (flags & EXT2_SYNC_FL)
2844 inode->i_flags |= S_SYNC;
2845 if (flags & EXT2_APPEND_FL)
2846 inode->i_flags |= S_APPEND;
2847 - if (flags & EXT2_IMMUTABLE_FL)
2848 - inode->i_flags |= S_IMMUTABLE;
2849 if (flags & EXT2_NOATIME_FL)
2850 inode->i_flags |= S_NOATIME;
2851 if (flags & EXT2_DIRSYNC_FL)
2852 inode->i_flags |= S_DIRSYNC;
2854 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2856 + if (flags & EXT2_BARRIER_FL)
2857 + inode->i_vflags |= V_BARRIER;
2858 + if (flags & EXT2_COW_FL)
2859 + inode->i_vflags |= V_COW;
2862 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2863 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2865 unsigned int flags = ei->vfs_inode.i_flags;
2866 + unsigned int vflags = ei->vfs_inode.i_vflags;
2868 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2869 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2870 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2871 + EXT2_BARRIER_FL | EXT2_COW_FL);
2873 + if (flags & S_IMMUTABLE)
2874 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2875 + if (flags & S_IXUNLINK)
2876 + ei->i_flags |= EXT2_IXUNLINK_FL;
2878 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2879 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2881 ei->i_flags |= EXT2_SYNC_FL;
2882 if (flags & S_APPEND)
2883 ei->i_flags |= EXT2_APPEND_FL;
2884 - if (flags & S_IMMUTABLE)
2885 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2886 if (flags & S_NOATIME)
2887 ei->i_flags |= EXT2_NOATIME_FL;
2888 if (flags & S_DIRSYNC)
2889 ei->i_flags |= EXT2_DIRSYNC_FL;
2891 + if (vflags & V_BARRIER)
2892 + ei->i_flags |= EXT2_BARRIER_FL;
2893 + if (vflags & V_COW)
2894 + ei->i_flags |= EXT2_COW_FL;
2897 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2898 @@ -1297,6 +1323,8 @@ struct inode *ext2_iget (struct super_bl
2899 struct ext2_inode *raw_inode;
2900 struct inode *inode;
2906 inode = iget_locked(sb, ino);
2907 @@ -1315,12 +1343,17 @@ struct inode *ext2_iget (struct super_bl
2910 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2911 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2912 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2913 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2914 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2915 if (!(test_opt (inode->i_sb, NO_UID32))) {
2916 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2917 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2918 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2919 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2921 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2922 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2923 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2924 + le16_to_cpu(raw_inode->i_raw_tag));
2926 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2927 inode->i_size = le32_to_cpu(raw_inode->i_size);
2928 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2929 @@ -1418,8 +1451,8 @@ static int __ext2_write_inode(struct ino
2930 struct ext2_inode_info *ei = EXT2_I(inode);
2931 struct super_block *sb = inode->i_sb;
2932 ino_t ino = inode->i_ino;
2933 - uid_t uid = inode->i_uid;
2934 - gid_t gid = inode->i_gid;
2935 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2936 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2937 struct buffer_head * bh;
2938 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2940 @@ -1455,6 +1488,9 @@ static int __ext2_write_inode(struct ino
2941 raw_inode->i_uid_high = 0;
2942 raw_inode->i_gid_high = 0;
2944 +#ifdef CONFIG_TAGGING_INTERN
2945 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2947 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2948 raw_inode->i_size = cpu_to_le32(inode->i_size);
2949 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2950 @@ -1544,7 +1580,8 @@ int ext2_setattr(struct dentry *dentry,
2951 if (is_quota_modification(inode, iattr))
2952 dquot_initialize(inode);
2953 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2954 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2955 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2956 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2957 error = dquot_transfer(inode, iattr);
2960 diff -NurpP --minimal linux-2.6.36/fs/ext2/ioctl.c linux-2.6.36-vs2.3.0.36.38/fs/ext2/ioctl.c
2961 --- linux-2.6.36/fs/ext2/ioctl.c 2009-09-10 15:26:21.000000000 +0200
2962 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext2/ioctl.c 2010-10-21 13:09:36.000000000 +0200
2964 #include <asm/uaccess.h>
2967 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2969 + inode->i_flags = flags;
2970 + inode->i_vflags = vflags;
2971 + ext2_get_inode_flags(EXT2_I(inode));
2972 + inode->i_ctime = CURRENT_TIME_SEC;
2973 + mark_inode_dirty(inode);
2977 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2979 struct inode *inode = filp->f_dentry->d_inode;
2980 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2982 flags = ext2_mask_flags(inode->i_mode, flags);
2984 + if (IS_BARRIER(inode)) {
2985 + vxwprintk_task(1, "messing with the barrier.");
2989 mutex_lock(&inode->i_mutex);
2990 /* Is it quota file? Do not allow user to mess with it */
2991 if (IS_NOQUOTA(inode)) {
2992 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2994 * This test looks nicer. Thanks to Pauline Middelink
2996 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2997 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2998 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2999 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
3000 if (!capable(CAP_LINUX_IMMUTABLE)) {
3001 mutex_unlock(&inode->i_mutex);
3003 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
3007 - flags = flags & EXT2_FL_USER_MODIFIABLE;
3008 + flags &= EXT2_FL_USER_MODIFIABLE;
3009 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
3010 ei->i_flags = flags;
3011 mutex_unlock(&inode->i_mutex);
3012 diff -NurpP --minimal linux-2.6.36/fs/ext2/namei.c linux-2.6.36-vs2.3.0.36.38/fs/ext2/namei.c
3013 --- linux-2.6.36/fs/ext2/namei.c 2010-07-07 18:31:51.000000000 +0200
3014 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext2/namei.c 2010-10-21 13:09:36.000000000 +0200
3017 #include <linux/pagemap.h>
3018 #include <linux/quotaops.h>
3019 +#include <linux/vs_tag.h>
3023 @@ -75,6 +76,7 @@ static struct dentry *ext2_lookup(struct
3024 return ERR_PTR(-EIO);
3026 return ERR_CAST(inode);
3027 + dx_propagate_tag(nd, inode);
3031 @@ -418,6 +420,7 @@ const struct inode_operations ext2_dir_i
3033 .setattr = ext2_setattr,
3034 .check_acl = ext2_check_acl,
3035 + .sync_flags = ext2_sync_flags,
3038 const struct inode_operations ext2_special_inode_operations = {
3039 diff -NurpP --minimal linux-2.6.36/fs/ext2/super.c linux-2.6.36-vs2.3.0.36.38/fs/ext2/super.c
3040 --- linux-2.6.36/fs/ext2/super.c 2010-10-21 13:07:48.000000000 +0200
3041 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext2/super.c 2010-10-21 13:09:36.000000000 +0200
3042 @@ -378,7 +378,8 @@ enum {
3043 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3044 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3045 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3046 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
3047 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
3048 + Opt_tag, Opt_notag, Opt_tagid
3051 static const match_table_t tokens = {
3052 @@ -406,6 +407,9 @@ static const match_table_t tokens = {
3054 {Opt_noacl, "noacl"},
3057 + {Opt_notag, "notag"},
3058 + {Opt_tagid, "tagid=%u"},
3059 {Opt_grpquota, "grpquota"},
3060 {Opt_ignore, "noquota"},
3061 {Opt_quota, "quota"},
3062 @@ -476,6 +480,20 @@ static int parse_options(char *options,
3064 set_opt (sbi->s_mount_opt, NO_UID32);
3066 +#ifndef CONFIG_TAGGING_NONE
3068 + set_opt (sbi->s_mount_opt, TAGGED);
3071 + clear_opt (sbi->s_mount_opt, TAGGED);
3074 +#ifdef CONFIG_PROPAGATE
3077 + set_opt (sbi->s_mount_opt, TAGGED);
3081 clear_opt (sbi->s_mount_opt, CHECK);
3083 @@ -833,6 +851,8 @@ static int ext2_fill_super(struct super_
3084 if (!parse_options((char *) data, sb))
3087 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3088 + sb->s_flags |= MS_TAGGED;
3089 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3090 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3092 @@ -1205,6 +1225,14 @@ static int ext2_remount (struct super_bl
3096 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3097 + !(sb->s_flags & MS_TAGGED)) {
3098 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3101 + goto restore_opts;
3104 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3105 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3107 diff -NurpP --minimal linux-2.6.36/fs/ext3/file.c linux-2.6.36-vs2.3.0.36.38/fs/ext3/file.c
3108 --- linux-2.6.36/fs/ext3/file.c 2010-07-07 18:31:51.000000000 +0200
3109 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext3/file.c 2010-10-21 13:09:36.000000000 +0200
3110 @@ -81,5 +81,6 @@ const struct inode_operations ext3_file_
3112 .check_acl = ext3_check_acl,
3113 .fiemap = ext3_fiemap,
3114 + .sync_flags = ext3_sync_flags,
3117 diff -NurpP --minimal linux-2.6.36/fs/ext3/ialloc.c linux-2.6.36-vs2.3.0.36.38/fs/ext3/ialloc.c
3118 --- linux-2.6.36/fs/ext3/ialloc.c 2010-10-21 13:07:48.000000000 +0200
3119 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext3/ialloc.c 2010-10-21 13:09:36.000000000 +0200
3121 #include <linux/buffer_head.h>
3122 #include <linux/random.h>
3123 #include <linux/bitops.h>
3124 +#include <linux/vs_tag.h>
3126 #include <asm/byteorder.h>
3128 @@ -531,6 +532,7 @@ got:
3129 inode->i_mode = mode;
3130 inode->i_uid = current_fsuid();
3131 inode->i_gid = dir->i_gid;
3132 + inode->i_tag = dx_current_fstag(sb);
3134 inode_init_owner(inode, dir, mode);
3136 diff -NurpP --minimal linux-2.6.36/fs/ext3/inode.c linux-2.6.36-vs2.3.0.36.38/fs/ext3/inode.c
3137 --- linux-2.6.36/fs/ext3/inode.c 2010-10-21 13:07:48.000000000 +0200
3138 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext3/inode.c 2010-10-21 13:09:36.000000000 +0200
3140 #include <linux/bio.h>
3141 #include <linux/fiemap.h>
3142 #include <linux/namei.h>
3143 +#include <linux/vs_tag.h>
3147 @@ -2387,7 +2388,7 @@ static void ext3_free_branches(handle_t
3149 int ext3_can_truncate(struct inode *inode)
3151 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3152 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3154 if (S_ISREG(inode->i_mode))
3156 @@ -2772,36 +2773,60 @@ void ext3_set_inode_flags(struct inode *
3158 unsigned int flags = EXT3_I(inode)->i_flags;
3160 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3161 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3162 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3164 + if (flags & EXT3_IMMUTABLE_FL)
3165 + inode->i_flags |= S_IMMUTABLE;
3166 + if (flags & EXT3_IXUNLINK_FL)
3167 + inode->i_flags |= S_IXUNLINK;
3169 if (flags & EXT3_SYNC_FL)
3170 inode->i_flags |= S_SYNC;
3171 if (flags & EXT3_APPEND_FL)
3172 inode->i_flags |= S_APPEND;
3173 - if (flags & EXT3_IMMUTABLE_FL)
3174 - inode->i_flags |= S_IMMUTABLE;
3175 if (flags & EXT3_NOATIME_FL)
3176 inode->i_flags |= S_NOATIME;
3177 if (flags & EXT3_DIRSYNC_FL)
3178 inode->i_flags |= S_DIRSYNC;
3180 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3182 + if (flags & EXT3_BARRIER_FL)
3183 + inode->i_vflags |= V_BARRIER;
3184 + if (flags & EXT3_COW_FL)
3185 + inode->i_vflags |= V_COW;
3188 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
3189 void ext3_get_inode_flags(struct ext3_inode_info *ei)
3191 unsigned int flags = ei->vfs_inode.i_flags;
3192 + unsigned int vflags = ei->vfs_inode.i_vflags;
3194 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
3195 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
3196 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
3197 + EXT3_BARRIER_FL | EXT3_COW_FL);
3199 + if (flags & S_IMMUTABLE)
3200 + ei->i_flags |= EXT3_IMMUTABLE_FL;
3201 + if (flags & S_IXUNLINK)
3202 + ei->i_flags |= EXT3_IXUNLINK_FL;
3204 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
3205 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
3207 ei->i_flags |= EXT3_SYNC_FL;
3208 if (flags & S_APPEND)
3209 ei->i_flags |= EXT3_APPEND_FL;
3210 - if (flags & S_IMMUTABLE)
3211 - ei->i_flags |= EXT3_IMMUTABLE_FL;
3212 if (flags & S_NOATIME)
3213 ei->i_flags |= EXT3_NOATIME_FL;
3214 if (flags & S_DIRSYNC)
3215 ei->i_flags |= EXT3_DIRSYNC_FL;
3217 + if (vflags & V_BARRIER)
3218 + ei->i_flags |= EXT3_BARRIER_FL;
3219 + if (vflags & V_COW)
3220 + ei->i_flags |= EXT3_COW_FL;
3223 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3224 @@ -2815,6 +2840,8 @@ struct inode *ext3_iget(struct super_blo
3225 transaction_t *transaction;
3231 inode = iget_locked(sb, ino);
3233 @@ -2831,12 +2858,17 @@ struct inode *ext3_iget(struct super_blo
3235 raw_inode = ext3_raw_inode(&iloc);
3236 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3237 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3238 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3239 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3240 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3241 if(!(test_opt (inode->i_sb, NO_UID32))) {
3242 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3243 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3244 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3245 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3247 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3248 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3249 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3250 + le16_to_cpu(raw_inode->i_raw_tag));
3252 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3253 inode->i_size = le32_to_cpu(raw_inode->i_size);
3254 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3255 @@ -2991,6 +3023,8 @@ static int ext3_do_update_inode(handle_t
3256 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3257 struct ext3_inode_info *ei = EXT3_I(inode);
3258 struct buffer_head *bh = iloc->bh;
3259 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3260 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3261 int err = 0, rc, block;
3264 @@ -3005,29 +3039,32 @@ again:
3265 ext3_get_inode_flags(ei);
3266 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3267 if(!(test_opt(inode->i_sb, NO_UID32))) {
3268 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3269 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3270 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3271 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3273 * Fix up interoperability with old kernels. Otherwise, old inodes get
3274 * re-used with the upper 16 bits of the uid/gid intact
3277 raw_inode->i_uid_high =
3278 - cpu_to_le16(high_16_bits(inode->i_uid));
3279 + cpu_to_le16(high_16_bits(uid));
3280 raw_inode->i_gid_high =
3281 - cpu_to_le16(high_16_bits(inode->i_gid));
3282 + cpu_to_le16(high_16_bits(gid));
3284 raw_inode->i_uid_high = 0;
3285 raw_inode->i_gid_high = 0;
3288 raw_inode->i_uid_low =
3289 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3290 + cpu_to_le16(fs_high2lowuid(uid));
3291 raw_inode->i_gid_low =
3292 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3293 + cpu_to_le16(fs_high2lowgid(gid));
3294 raw_inode->i_uid_high = 0;
3295 raw_inode->i_gid_high = 0;
3297 +#ifdef CONFIG_TAGGING_INTERN
3298 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3300 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3301 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3302 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3303 @@ -3187,7 +3224,8 @@ int ext3_setattr(struct dentry *dentry,
3304 if (is_quota_modification(inode, attr))
3305 dquot_initialize(inode);
3306 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3307 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3308 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3309 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3312 /* (user+group)*(old+new) structure, inode write (sb,
3313 @@ -3209,6 +3247,8 @@ int ext3_setattr(struct dentry *dentry,
3314 inode->i_uid = attr->ia_uid;
3315 if (attr->ia_valid & ATTR_GID)
3316 inode->i_gid = attr->ia_gid;
3317 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3318 + inode->i_tag = attr->ia_tag;
3319 error = ext3_mark_inode_dirty(handle, inode);
3320 ext3_journal_stop(handle);
3322 diff -NurpP --minimal linux-2.6.36/fs/ext3/ioctl.c linux-2.6.36-vs2.3.0.36.38/fs/ext3/ioctl.c
3323 --- linux-2.6.36/fs/ext3/ioctl.c 2009-06-11 17:13:03.000000000 +0200
3324 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext3/ioctl.c 2010-10-21 13:09:36.000000000 +0200
3328 #include <linux/fs.h>
3329 +#include <linux/mount.h>
3330 #include <linux/jbd.h>
3331 #include <linux/capability.h>
3332 #include <linux/ext3_fs.h>
3334 #include <linux/compat.h>
3335 #include <asm/uaccess.h>
3338 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
3340 + handle_t *handle = NULL;
3341 + struct ext3_iloc iloc;
3344 + handle = ext3_journal_start(inode, 1);
3345 + if (IS_ERR(handle))
3346 + return PTR_ERR(handle);
3348 + if (IS_SYNC(inode))
3349 + handle->h_sync = 1;
3350 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3354 + inode->i_flags = flags;
3355 + inode->i_vflags = vflags;
3356 + ext3_get_inode_flags(EXT3_I(inode));
3357 + inode->i_ctime = CURRENT_TIME_SEC;
3359 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3361 + ext3_journal_stop(handle);
3365 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3367 struct inode *inode = filp->f_dentry->d_inode;
3368 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
3370 flags = ext3_mask_flags(inode->i_mode, flags);
3372 + if (IS_BARRIER(inode)) {
3373 + vxwprintk_task(1, "messing with the barrier.");
3377 mutex_lock(&inode->i_mutex);
3379 /* Is it quota file? Do not allow user to mess with it */
3380 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3382 * This test looks nicer. Thanks to Pauline Middelink
3384 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3385 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3386 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3387 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3388 if (!capable(CAP_LINUX_IMMUTABLE))
3391 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3395 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3396 + flags &= EXT3_FL_USER_MODIFIABLE;
3397 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3398 ei->i_flags = flags;
3400 diff -NurpP --minimal linux-2.6.36/fs/ext3/namei.c linux-2.6.36-vs2.3.0.36.38/fs/ext3/namei.c
3401 --- linux-2.6.36/fs/ext3/namei.c 2010-10-21 13:07:48.000000000 +0200
3402 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext3/namei.c 2010-10-21 13:09:36.000000000 +0200
3404 #include <linux/quotaops.h>
3405 #include <linux/buffer_head.h>
3406 #include <linux/bio.h>
3407 +#include <linux/vs_tag.h>
3411 @@ -912,6 +913,7 @@ restart:
3413 ll_rw_block(READ_META, 1, &bh);
3415 + dx_propagate_tag(nd, inode);
3417 if ((bh = bh_use[ra_ptr++]) == NULL)
3419 @@ -2465,6 +2467,7 @@ const struct inode_operations ext3_dir_i
3420 .removexattr = generic_removexattr,
3422 .check_acl = ext3_check_acl,
3423 + .sync_flags = ext3_sync_flags,
3426 const struct inode_operations ext3_special_inode_operations = {
3427 diff -NurpP --minimal linux-2.6.36/fs/ext3/super.c linux-2.6.36-vs2.3.0.36.38/fs/ext3/super.c
3428 --- linux-2.6.36/fs/ext3/super.c 2010-10-21 13:07:48.000000000 +0200
3429 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext3/super.c 2010-10-21 13:09:36.000000000 +0200
3430 @@ -802,7 +802,8 @@ enum {
3431 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3432 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
3433 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
3434 - Opt_resize, Opt_usrquota, Opt_grpquota
3435 + Opt_resize, Opt_usrquota, Opt_grpquota,
3436 + Opt_tag, Opt_notag, Opt_tagid
3439 static const match_table_t tokens = {
3440 @@ -859,6 +860,9 @@ static const match_table_t tokens = {
3441 {Opt_barrier, "barrier"},
3442 {Opt_nobarrier, "nobarrier"},
3443 {Opt_resize, "resize"},
3445 + {Opt_notag, "notag"},
3446 + {Opt_tagid, "tagid=%u"},
3450 @@ -1011,6 +1015,20 @@ static int parse_options (char *options,
3452 set_opt (sbi->s_mount_opt, NO_UID32);
3454 +#ifndef CONFIG_TAGGING_NONE
3456 + set_opt (sbi->s_mount_opt, TAGGED);
3459 + clear_opt (sbi->s_mount_opt, TAGGED);
3462 +#ifdef CONFIG_PROPAGATE
3465 + set_opt (sbi->s_mount_opt, TAGGED);
3469 clear_opt (sbi->s_mount_opt, CHECK);
3471 @@ -1699,6 +1717,9 @@ static int ext3_fill_super (struct super
3475 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3476 + sb->s_flags |= MS_TAGGED;
3478 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3479 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3481 @@ -2564,6 +2585,14 @@ static int ext3_remount (struct super_bl
3482 if (test_opt(sb, ABORT))
3483 ext3_abort(sb, __func__, "Abort forced by user");
3485 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3486 + !(sb->s_flags & MS_TAGGED)) {
3487 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3490 + goto restore_opts;
3493 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3494 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3496 diff -NurpP --minimal linux-2.6.36/fs/ext4/ext4.h linux-2.6.36-vs2.3.0.36.38/fs/ext4/ext4.h
3497 --- linux-2.6.36/fs/ext4/ext4.h 2010-10-21 13:07:48.000000000 +0200
3498 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext4/ext4.h 2010-10-21 13:09:36.000000000 +0200
3499 @@ -323,8 +323,12 @@ struct flex_groups {
3500 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3501 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
3502 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
3503 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3504 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3506 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3507 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3509 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3510 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3512 @@ -593,7 +597,8 @@ struct ext4_inode {
3513 __le16 l_i_file_acl_high;
3514 __le16 l_i_uid_high; /* these 2 fields */
3515 __le16 l_i_gid_high; /* were reserved2[0] */
3516 - __u32 l_i_reserved2;
3517 + __le16 l_i_tag; /* Context Tag */
3518 + __u16 l_i_reserved2;
3521 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3522 @@ -707,6 +712,7 @@ do { \
3523 #define i_gid_low i_gid
3524 #define i_uid_high osd2.linux2.l_i_uid_high
3525 #define i_gid_high osd2.linux2.l_i_gid_high
3526 +#define i_raw_tag osd2.linux2.l_i_tag
3527 #define i_reserved2 osd2.linux2.l_i_reserved2
3529 #elif defined(__GNU__)
3530 @@ -885,6 +891,7 @@ struct ext4_inode_info {
3531 #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
3532 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
3533 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
3534 +#define EXT4_MOUNT_TAGGED 0x4000000 /* Enable Context Tags */
3535 #define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */
3536 #define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000 /* Abort on file data write */
3537 #define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000 /* Block validity checking */
3538 @@ -1997,6 +2004,7 @@ extern int ext4_map_blocks(handle_t *han
3539 struct ext4_map_blocks *map, int flags);
3540 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3541 __u64 start, __u64 len);
3542 +extern int ext4_sync_flags(struct inode *, int, int);
3544 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3545 __u64 start_orig, __u64 start_donor,
3546 diff -NurpP --minimal linux-2.6.36/fs/ext4/file.c linux-2.6.36-vs2.3.0.36.38/fs/ext4/file.c
3547 --- linux-2.6.36/fs/ext4/file.c 2010-10-21 13:07:48.000000000 +0200
3548 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext4/file.c 2010-10-21 13:09:36.000000000 +0200
3549 @@ -161,5 +161,6 @@ const struct inode_operations ext4_file_
3550 .check_acl = ext4_check_acl,
3551 .fallocate = ext4_fallocate,
3552 .fiemap = ext4_fiemap,
3553 + .sync_flags = ext4_sync_flags,
3556 diff -NurpP --minimal linux-2.6.36/fs/ext4/ialloc.c linux-2.6.36-vs2.3.0.36.38/fs/ext4/ialloc.c
3557 --- linux-2.6.36/fs/ext4/ialloc.c 2010-10-21 13:07:48.000000000 +0200
3558 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext4/ialloc.c 2010-10-21 13:09:36.000000000 +0200
3560 #include <linux/random.h>
3561 #include <linux/bitops.h>
3562 #include <linux/blkdev.h>
3563 +#include <linux/vs_tag.h>
3564 #include <asm/byteorder.h>
3567 @@ -976,6 +977,7 @@ got:
3568 inode->i_mode = mode;
3569 inode->i_uid = current_fsuid();
3570 inode->i_gid = dir->i_gid;
3571 + inode->i_tag = dx_current_fstag(sb);
3573 inode_init_owner(inode, dir, mode);
3575 diff -NurpP --minimal linux-2.6.36/fs/ext4/inode.c linux-2.6.36-vs2.3.0.36.38/fs/ext4/inode.c
3576 --- linux-2.6.36/fs/ext4/inode.c 2010-10-21 13:07:48.000000000 +0200
3577 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext4/inode.c 2010-10-21 13:09:36.000000000 +0200
3579 #include <linux/workqueue.h>
3580 #include <linux/kernel.h>
3581 #include <linux/slab.h>
3582 +#include <linux/vs_tag.h>
3584 #include "ext4_jbd2.h"
3586 @@ -4596,7 +4597,7 @@ static void ext4_free_branches(handle_t
3588 int ext4_can_truncate(struct inode *inode)
3590 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3591 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3593 if (S_ISREG(inode->i_mode))
3595 @@ -4947,41 +4948,64 @@ void ext4_set_inode_flags(struct inode *
3597 unsigned int flags = EXT4_I(inode)->i_flags;
3599 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3600 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3601 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3603 + if (flags & EXT4_IMMUTABLE_FL)
3604 + inode->i_flags |= S_IMMUTABLE;
3605 + if (flags & EXT4_IXUNLINK_FL)
3606 + inode->i_flags |= S_IXUNLINK;
3608 if (flags & EXT4_SYNC_FL)
3609 inode->i_flags |= S_SYNC;
3610 if (flags & EXT4_APPEND_FL)
3611 inode->i_flags |= S_APPEND;
3612 - if (flags & EXT4_IMMUTABLE_FL)
3613 - inode->i_flags |= S_IMMUTABLE;
3614 if (flags & EXT4_NOATIME_FL)
3615 inode->i_flags |= S_NOATIME;
3616 if (flags & EXT4_DIRSYNC_FL)
3617 inode->i_flags |= S_DIRSYNC;
3619 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3621 + if (flags & EXT4_BARRIER_FL)
3622 + inode->i_vflags |= V_BARRIER;
3623 + if (flags & EXT4_COW_FL)
3624 + inode->i_vflags |= V_COW;
3627 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3628 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3630 - unsigned int vfs_fl;
3631 + unsigned int vfs_fl, vfs_vf;
3632 unsigned long old_fl, new_fl;
3635 vfs_fl = ei->vfs_inode.i_flags;
3636 + vfs_vf = ei->vfs_inode.i_vflags;
3637 old_fl = ei->i_flags;
3638 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3639 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3641 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3644 + if (vfs_fl & S_IMMUTABLE)
3645 + new_fl |= EXT4_IMMUTABLE_FL;
3646 + if (vfs_fl & S_IXUNLINK)
3647 + new_fl |= EXT4_IXUNLINK_FL;
3649 if (vfs_fl & S_SYNC)
3650 new_fl |= EXT4_SYNC_FL;
3651 if (vfs_fl & S_APPEND)
3652 new_fl |= EXT4_APPEND_FL;
3653 - if (vfs_fl & S_IMMUTABLE)
3654 - new_fl |= EXT4_IMMUTABLE_FL;
3655 if (vfs_fl & S_NOATIME)
3656 new_fl |= EXT4_NOATIME_FL;
3657 if (vfs_fl & S_DIRSYNC)
3658 new_fl |= EXT4_DIRSYNC_FL;
3660 + if (vfs_vf & V_BARRIER)
3661 + new_fl |= EXT4_BARRIER_FL;
3662 + if (vfs_vf & V_COW)
3663 + new_fl |= EXT4_COW_FL;
3664 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3667 @@ -5017,6 +5041,8 @@ struct inode *ext4_iget(struct super_blo
3668 journal_t *journal = EXT4_SB(sb)->s_journal;
3674 inode = iget_locked(sb, ino);
3676 @@ -5032,12 +5058,16 @@ struct inode *ext4_iget(struct super_blo
3678 raw_inode = ext4_raw_inode(&iloc);
3679 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3680 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3681 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3682 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3683 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3684 if (!(test_opt(inode->i_sb, NO_UID32))) {
3685 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3686 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3687 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3688 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3690 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3691 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3692 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3693 + le16_to_cpu(raw_inode->i_raw_tag));
3694 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3696 ei->i_state_flags = 0;
3697 @@ -5256,6 +5286,8 @@ static int ext4_do_update_inode(handle_t
3698 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3699 struct ext4_inode_info *ei = EXT4_I(inode);
3700 struct buffer_head *bh = iloc->bh;
3701 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3702 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3703 int err = 0, rc, block;
3705 /* For fields not not tracking in the in-memory inode,
3706 @@ -5266,29 +5298,32 @@ static int ext4_do_update_inode(handle_t
3707 ext4_get_inode_flags(ei);
3708 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3709 if (!(test_opt(inode->i_sb, NO_UID32))) {
3710 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3711 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3712 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3713 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3715 * Fix up interoperability with old kernels. Otherwise, old inodes get
3716 * re-used with the upper 16 bits of the uid/gid intact
3719 raw_inode->i_uid_high =
3720 - cpu_to_le16(high_16_bits(inode->i_uid));
3721 + cpu_to_le16(high_16_bits(uid));
3722 raw_inode->i_gid_high =
3723 - cpu_to_le16(high_16_bits(inode->i_gid));
3724 + cpu_to_le16(high_16_bits(gid));
3726 raw_inode->i_uid_high = 0;
3727 raw_inode->i_gid_high = 0;
3730 raw_inode->i_uid_low =
3731 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3732 + cpu_to_le16(fs_high2lowuid(uid));
3733 raw_inode->i_gid_low =
3734 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3735 + cpu_to_le16(fs_high2lowgid(gid));
3736 raw_inode->i_uid_high = 0;
3737 raw_inode->i_gid_high = 0;
3739 +#ifdef CONFIG_TAGGING_INTERN
3740 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3742 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3744 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3745 @@ -5473,7 +5508,8 @@ int ext4_setattr(struct dentry *dentry,
3746 if (is_quota_modification(inode, attr))
3747 dquot_initialize(inode);
3748 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3749 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3750 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3751 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3754 /* (user+group)*(old+new) structure, inode write (sb,
3755 @@ -5495,6 +5531,8 @@ int ext4_setattr(struct dentry *dentry,
3756 inode->i_uid = attr->ia_uid;
3757 if (attr->ia_valid & ATTR_GID)
3758 inode->i_gid = attr->ia_gid;
3759 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3760 + inode->i_tag = attr->ia_tag;
3761 error = ext4_mark_inode_dirty(handle, inode);
3762 ext4_journal_stop(handle);
3764 diff -NurpP --minimal linux-2.6.36/fs/ext4/ioctl.c linux-2.6.36-vs2.3.0.36.38/fs/ext4/ioctl.c
3765 --- linux-2.6.36/fs/ext4/ioctl.c 2010-08-02 16:52:48.000000000 +0200
3766 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext4/ioctl.c 2010-10-21 13:09:36.000000000 +0200
3768 #include <linux/compat.h>
3769 #include <linux/mount.h>
3770 #include <linux/file.h>
3771 +#include <linux/vs_tag.h>
3772 #include <asm/uaccess.h>
3773 #include "ext4_jbd2.h"
3777 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3779 + handle_t *handle = NULL;
3780 + struct ext4_iloc iloc;
3783 + handle = ext4_journal_start(inode, 1);
3784 + if (IS_ERR(handle))
3785 + return PTR_ERR(handle);
3787 + if (IS_SYNC(inode))
3788 + ext4_handle_sync(handle);
3789 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3793 + inode->i_flags = flags;
3794 + inode->i_vflags = vflags;
3795 + ext4_get_inode_flags(EXT4_I(inode));
3796 + inode->i_ctime = ext4_current_time(inode);
3798 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3800 + ext4_journal_stop(handle);
3804 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3806 struct inode *inode = filp->f_dentry->d_inode;
3807 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3809 flags = ext4_mask_flags(inode->i_mode, flags);
3811 + if (IS_BARRIER(inode)) {
3812 + vxwprintk_task(1, "messing with the barrier.");
3817 mutex_lock(&inode->i_mutex);
3818 /* Is it quota file? Do not allow user to mess with it */
3819 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3821 * This test looks nicer. Thanks to Pauline Middelink
3823 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3824 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3825 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3826 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3827 if (!capable(CAP_LINUX_IMMUTABLE))
3830 diff -NurpP --minimal linux-2.6.36/fs/ext4/namei.c linux-2.6.36-vs2.3.0.36.38/fs/ext4/namei.c
3831 --- linux-2.6.36/fs/ext4/namei.c 2010-10-21 13:07:48.000000000 +0200
3832 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext4/namei.c 2010-10-21 13:09:36.000000000 +0200
3834 #include <linux/quotaops.h>
3835 #include <linux/buffer_head.h>
3836 #include <linux/bio.h>
3837 +#include <linux/vs_tag.h>
3839 #include "ext4_jbd2.h"
3841 @@ -912,6 +913,7 @@ restart:
3843 ll_rw_block(READ_META, 1, &bh);
3845 + dx_propagate_tag(nd, inode);
3847 if ((bh = bh_use[ra_ptr++]) == NULL)
3849 @@ -2522,6 +2524,7 @@ const struct inode_operations ext4_dir_i
3851 .check_acl = ext4_check_acl,
3852 .fiemap = ext4_fiemap,
3853 + .sync_flags = ext4_sync_flags,
3856 const struct inode_operations ext4_special_inode_operations = {
3857 diff -NurpP --minimal linux-2.6.36/fs/ext4/super.c linux-2.6.36-vs2.3.0.36.38/fs/ext4/super.c
3858 --- linux-2.6.36/fs/ext4/super.c 2010-10-21 13:07:48.000000000 +0200
3859 +++ linux-2.6.36-vs2.3.0.36.38/fs/ext4/super.c 2010-10-21 13:09:36.000000000 +0200
3860 @@ -1219,6 +1219,7 @@ enum {
3861 Opt_inode_readahead_blks, Opt_journal_ioprio,
3862 Opt_dioread_nolock, Opt_dioread_lock,
3863 Opt_discard, Opt_nodiscard,
3864 + Opt_tag, Opt_notag, Opt_tagid
3867 static const match_table_t tokens = {
3868 @@ -1289,6 +1290,9 @@ static const match_table_t tokens = {
3869 {Opt_dioread_lock, "dioread_lock"},
3870 {Opt_discard, "discard"},
3871 {Opt_nodiscard, "nodiscard"},
3873 + {Opt_notag, "notag"},
3874 + {Opt_tagid, "tagid=%u"},
3878 @@ -1457,6 +1461,20 @@ static int parse_options(char *options,
3880 set_opt(sbi->s_mount_opt, NO_UID32);
3882 +#ifndef CONFIG_TAGGING_NONE
3884 + set_opt (sbi->s_mount_opt, TAGGED);
3887 + clear_opt (sbi->s_mount_opt, TAGGED);
3890 +#ifdef CONFIG_PROPAGATE
3893 + set_opt (sbi->s_mount_opt, TAGGED);
3897 set_opt(sbi->s_mount_opt, DEBUG);
3899 @@ -2691,6 +2709,9 @@ static int ext4_fill_super(struct super_
3900 &journal_ioprio, NULL, 0))
3903 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3904 + sb->s_flags |= MS_TAGGED;
3906 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3907 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3909 @@ -3753,6 +3774,14 @@ static int ext4_remount(struct super_blo
3910 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3911 ext4_abort(sb, "Abort forced by user");
3913 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3914 + !(sb->s_flags & MS_TAGGED)) {
3915 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3918 + goto restore_opts;
3921 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3922 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3924 diff -NurpP --minimal linux-2.6.36/fs/fcntl.c linux-2.6.36-vs2.3.0.36.38/fs/fcntl.c
3925 --- linux-2.6.36/fs/fcntl.c 2010-10-21 13:07:48.000000000 +0200
3926 +++ linux-2.6.36-vs2.3.0.36.38/fs/fcntl.c 2010-10-21 13:09:36.000000000 +0200
3928 #include <linux/signal.h>
3929 #include <linux/rcupdate.h>
3930 #include <linux/pid_namespace.h>
3931 +#include <linux/vs_limit.h>
3933 #include <asm/poll.h>
3934 #include <asm/siginfo.h>
3935 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3938 filp_close(tofree, files);
3940 + vx_openfd_inc(newfd); /* fd was unused */
3944 @@ -434,6 +437,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3948 + if (!vx_files_avail(1))
3951 err = security_file_fcntl(filp, cmd, arg);
3953 diff -NurpP --minimal linux-2.6.36/fs/file.c linux-2.6.36-vs2.3.0.36.38/fs/file.c
3954 --- linux-2.6.36/fs/file.c 2010-10-21 13:07:48.000000000 +0200
3955 +++ linux-2.6.36-vs2.3.0.36.38/fs/file.c 2010-10-21 13:09:36.000000000 +0200
3957 #include <linux/spinlock.h>
3958 #include <linux/rcupdate.h>
3959 #include <linux/workqueue.h>
3960 +#include <linux/vs_limit.h>
3962 struct fdtable_defer {
3964 @@ -355,6 +356,8 @@ struct files_struct *dup_fd(struct files
3965 struct file *f = *old_fds++;
3968 + /* TODO: sum it first for check and performance */
3969 + vx_openfd_inc(open_files - i);
3972 * The fd may be claimed in the fd bitmap but not yet
3973 @@ -462,6 +465,7 @@ repeat:
3975 FD_CLR(fd, fdt->close_on_exec);
3977 + vx_openfd_inc(fd);
3980 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3981 diff -NurpP --minimal linux-2.6.36/fs/file_table.c linux-2.6.36-vs2.3.0.36.38/fs/file_table.c
3982 --- linux-2.6.36/fs/file_table.c 2010-10-21 13:07:48.000000000 +0200
3983 +++ linux-2.6.36-vs2.3.0.36.38/fs/file_table.c 2010-10-21 14:10:28.000000000 +0200
3985 #include <linux/percpu_counter.h>
3986 #include <linux/percpu.h>
3987 #include <linux/ima.h>
3988 +#include <linux/vs_limit.h>
3989 +#include <linux/vs_context.h>
3991 #include <asm/atomic.h>
3993 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
3994 spin_lock_init(&f->f_lock);
3995 eventpoll_init_file(f);
3996 /* f->f_version: 0 */
3997 + f->f_xid = vx_current_xid();
4002 @@ -251,6 +255,8 @@ static void __fput(struct file *file)
4003 cdev_put(inode->i_cdev);
4004 fops_put(file->f_op);
4005 put_pid(file->f_owner.pid);
4006 + vx_files_dec(file);
4008 file_sb_list_del(file);
4009 if (file->f_mode & FMODE_WRITE)
4010 drop_file_write_access(file);
4011 @@ -334,6 +340,8 @@ void put_filp(struct file *file)
4013 if (atomic_long_dec_and_test(&file->f_count)) {
4014 security_file_free(file);
4015 + vx_files_dec(file);
4017 file_sb_list_del(file);
4020 diff -NurpP --minimal linux-2.6.36/fs/fs_struct.c linux-2.6.36-vs2.3.0.36.38/fs/fs_struct.c
4021 --- linux-2.6.36/fs/fs_struct.c 2010-10-21 13:07:48.000000000 +0200
4022 +++ linux-2.6.36-vs2.3.0.36.38/fs/fs_struct.c 2010-10-21 13:56:13.000000000 +0200
4024 #include <linux/path.h>
4025 #include <linux/slab.h>
4026 #include <linux/fs_struct.h>
4027 +#include <linux/vserver/global.h>
4030 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
4031 @@ -77,6 +78,7 @@ void free_fs_struct(struct fs_struct *fs
4033 path_put(&fs->root);
4035 + atomic_dec(&vs_global_fs);
4036 kmem_cache_free(fs_cachep, fs);
4039 @@ -107,6 +109,7 @@ struct fs_struct *copy_fs_struct(struct
4040 spin_lock_init(&fs->lock);
4041 fs->umask = old->umask;
4042 get_fs_root_and_pwd(old, &fs->root, &fs->pwd);
4043 + atomic_inc(&vs_global_fs);
4047 diff -NurpP --minimal linux-2.6.36/fs/gfs2/file.c linux-2.6.36-vs2.3.0.36.38/fs/gfs2/file.c
4048 --- linux-2.6.36/fs/gfs2/file.c 2010-10-21 13:07:49.000000000 +0200
4049 +++ linux-2.6.36-vs2.3.0.36.38/fs/gfs2/file.c 2010-10-21 13:09:36.000000000 +0200
4050 @@ -132,6 +132,9 @@ static const u32 fsflags_to_gfs2[32] = {
4051 [7] = GFS2_DIF_NOATIME,
4052 [12] = GFS2_DIF_EXHASH,
4053 [14] = GFS2_DIF_INHERIT_JDATA,
4054 + [27] = GFS2_DIF_IXUNLINK,
4055 + [26] = GFS2_DIF_BARRIER,
4056 + [29] = GFS2_DIF_COW,
4059 static const u32 gfs2_to_fsflags[32] = {
4060 @@ -141,6 +144,9 @@ static const u32 gfs2_to_fsflags[32] = {
4061 [gfs2fl_NoAtime] = FS_NOATIME_FL,
4062 [gfs2fl_ExHash] = FS_INDEX_FL,
4063 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
4064 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
4065 + [gfs2fl_Barrier] = FS_BARRIER_FL,
4066 + [gfs2fl_Cow] = FS_COW_FL,
4069 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
4070 @@ -171,10 +177,16 @@ void gfs2_set_inode_flags(struct inode *
4072 struct gfs2_inode *ip = GFS2_I(inode);
4073 unsigned int flags = inode->i_flags;
4074 + unsigned int vflags = inode->i_vflags;
4076 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4077 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4079 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4080 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
4081 flags |= S_IMMUTABLE;
4082 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
4083 + flags |= S_IXUNLINK;
4085 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
4087 if (ip->i_diskflags & GFS2_DIF_NOATIME)
4088 @@ -182,6 +194,43 @@ void gfs2_set_inode_flags(struct inode *
4089 if (ip->i_diskflags & GFS2_DIF_SYNC)
4091 inode->i_flags = flags;
4093 + vflags &= ~(V_BARRIER | V_COW);
4095 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
4096 + vflags |= V_BARRIER;
4097 + if (ip->i_diskflags & GFS2_DIF_COW)
4099 + inode->i_vflags = vflags;
4102 +void gfs2_get_inode_flags(struct inode *inode)
4104 + struct gfs2_inode *ip = GFS2_I(inode);
4105 + unsigned int flags = inode->i_flags;
4106 + unsigned int vflags = inode->i_vflags;
4108 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
4109 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
4110 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
4111 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
4113 + if (flags & S_IMMUTABLE)
4114 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
4115 + if (flags & S_IXUNLINK)
4116 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
4118 + if (flags & S_APPEND)
4119 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
4120 + if (flags & S_NOATIME)
4121 + ip->i_diskflags |= GFS2_DIF_NOATIME;
4122 + if (flags & S_SYNC)
4123 + ip->i_diskflags |= GFS2_DIF_SYNC;
4125 + if (vflags & V_BARRIER)
4126 + ip->i_diskflags |= GFS2_DIF_BARRIER;
4127 + if (vflags & V_COW)
4128 + ip->i_diskflags |= GFS2_DIF_COW;
4131 /* Flags that can be set by user space */
4132 @@ -293,6 +342,37 @@ static int gfs2_set_flags(struct file *f
4133 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
4136 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
4138 + struct gfs2_inode *ip = GFS2_I(inode);
4139 + struct gfs2_sbd *sdp = GFS2_SB(inode);
4140 + struct buffer_head *bh;
4141 + struct gfs2_holder gh;
4144 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
4147 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
4150 + error = gfs2_meta_inode_buffer(ip, &bh);
4152 + goto out_trans_end;
4153 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
4154 + inode->i_flags = flags;
4155 + inode->i_vflags = vflags;
4156 + gfs2_get_inode_flags(inode);
4157 + gfs2_dinode_out(ip, bh->b_data);
4159 + gfs2_set_aops(inode);
4161 + gfs2_trans_end(sdp);
4163 + gfs2_glock_dq_uninit(&gh);
4167 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4170 diff -NurpP --minimal linux-2.6.36/fs/gfs2/inode.h linux-2.6.36-vs2.3.0.36.38/fs/gfs2/inode.h
4171 --- linux-2.6.36/fs/gfs2/inode.h 2010-08-02 16:52:49.000000000 +0200
4172 +++ linux-2.6.36-vs2.3.0.36.38/fs/gfs2/inode.h 2010-10-21 13:09:36.000000000 +0200
4173 @@ -109,6 +109,7 @@ extern const struct file_operations gfs2
4174 extern const struct file_operations gfs2_dir_fops_nolock;
4176 extern void gfs2_set_inode_flags(struct inode *inode);
4177 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
4179 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
4180 extern const struct file_operations gfs2_file_fops;
4181 diff -NurpP --minimal linux-2.6.36/fs/gfs2/ops_inode.c linux-2.6.36-vs2.3.0.36.38/fs/gfs2/ops_inode.c
4182 --- linux-2.6.36/fs/gfs2/ops_inode.c 2010-10-21 13:07:49.000000000 +0200
4183 +++ linux-2.6.36-vs2.3.0.36.38/fs/gfs2/ops_inode.c 2010-10-21 13:09:36.000000000 +0200
4184 @@ -1352,6 +1352,7 @@ const struct inode_operations gfs2_file_
4185 .listxattr = gfs2_listxattr,
4186 .removexattr = gfs2_removexattr,
4187 .fiemap = gfs2_fiemap,
4188 + .sync_flags = gfs2_sync_flags,
4191 const struct inode_operations gfs2_dir_iops = {
4192 @@ -1372,6 +1373,7 @@ const struct inode_operations gfs2_dir_i
4193 .listxattr = gfs2_listxattr,
4194 .removexattr = gfs2_removexattr,
4195 .fiemap = gfs2_fiemap,
4196 + .sync_flags = gfs2_sync_flags,
4199 const struct inode_operations gfs2_symlink_iops = {
4200 diff -NurpP --minimal linux-2.6.36/fs/hfsplus/ioctl.c linux-2.6.36-vs2.3.0.36.38/fs/hfsplus/ioctl.c
4201 --- linux-2.6.36/fs/hfsplus/ioctl.c 2010-08-02 16:52:49.000000000 +0200
4202 +++ linux-2.6.36-vs2.3.0.36.38/fs/hfsplus/ioctl.c 2010-10-21 13:09:36.000000000 +0200
4204 #include <linux/sched.h>
4205 #include <linux/xattr.h>
4206 #include <linux/smp_lock.h>
4207 +// #include <linux/mount.h>
4208 #include <asm/uaccess.h>
4209 #include "hfsplus_fs.h"
4211 diff -NurpP --minimal linux-2.6.36/fs/inode.c linux-2.6.36-vs2.3.0.36.38/fs/inode.c
4212 --- linux-2.6.36/fs/inode.c 2010-10-21 13:07:49.000000000 +0200
4213 +++ linux-2.6.36-vs2.3.0.36.38/fs/inode.c 2010-10-21 13:09:36.000000000 +0200
4215 #include <linux/mount.h>
4216 #include <linux/async.h>
4217 #include <linux/posix_acl.h>
4218 +#include <linux/vs_tag.h>
4221 * This is needed for the following functions:
4222 @@ -130,6 +131,9 @@ int inode_init_always(struct super_block
4223 struct address_space *const mapping = &inode->i_data;
4227 + /* essential because of inode slab reuse */
4229 inode->i_blkbits = sb->s_blocksize_bits;
4231 atomic_set(&inode->i_count, 1);
4232 @@ -150,6 +154,7 @@ int inode_init_always(struct super_block
4233 inode->i_bdev = NULL;
4234 inode->i_cdev = NULL;
4236 + inode->i_mdev = 0;
4237 inode->dirtied_when = 0;
4239 if (security_inode_alloc(inode))
4240 @@ -393,6 +398,8 @@ static int invalidate_list(struct list_h
4244 +EXPORT_SYMBOL_GPL(__iget);
4247 * invalidate_inodes - discard the inodes on a device
4249 @@ -1528,9 +1535,11 @@ void init_special_inode(struct inode *in
4250 if (S_ISCHR(mode)) {
4251 inode->i_fop = &def_chr_fops;
4252 inode->i_rdev = rdev;
4253 + inode->i_mdev = rdev;
4254 } else if (S_ISBLK(mode)) {
4255 inode->i_fop = &def_blk_fops;
4256 inode->i_rdev = rdev;
4257 + inode->i_mdev = rdev;
4258 } else if (S_ISFIFO(mode))
4259 inode->i_fop = &def_fifo_fops;
4260 else if (S_ISSOCK(mode))
4261 @@ -1559,5 +1568,6 @@ void inode_init_owner(struct inode *inod
4263 inode->i_gid = current_fsgid();
4264 inode->i_mode = mode;
4265 + inode->i_tag = dx_current_fstag(inode->i_sb);
4267 EXPORT_SYMBOL(inode_init_owner);
4268 diff -NurpP --minimal linux-2.6.36/fs/ioctl.c linux-2.6.36-vs2.3.0.36.38/fs/ioctl.c
4269 --- linux-2.6.36/fs/ioctl.c 2010-10-21 13:07:49.000000000 +0200
4270 +++ linux-2.6.36-vs2.3.0.36.38/fs/ioctl.c 2010-10-21 13:09:36.000000000 +0200
4272 #include <linux/writeback.h>
4273 #include <linux/buffer_head.h>
4274 #include <linux/falloc.h>
4275 +#include <linux/proc_fs.h>
4276 +#include <linux/vserver/inode.h>
4277 +#include <linux/vs_tag.h>
4279 #include <asm/ioctls.h>
4281 diff -NurpP --minimal linux-2.6.36/fs/ioprio.c linux-2.6.36-vs2.3.0.36.38/fs/ioprio.c
4282 --- linux-2.6.36/fs/ioprio.c 2010-07-07 18:31:52.000000000 +0200
4283 +++ linux-2.6.36-vs2.3.0.36.38/fs/ioprio.c 2010-10-21 13:09:36.000000000 +0200
4285 #include <linux/syscalls.h>
4286 #include <linux/security.h>
4287 #include <linux/pid_namespace.h>
4288 +#include <linux/vs_base.h>
4290 int set_task_ioprio(struct task_struct *task, int ioprio)
4292 @@ -124,6 +125,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4294 pgrp = find_vpid(who);
4295 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4296 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4298 ret = set_task_ioprio(p, ioprio);
4301 @@ -213,6 +216,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
4303 pgrp = find_vpid(who);
4304 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4305 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4307 tmpio = get_task_ioprio(p);
4310 diff -NurpP --minimal linux-2.6.36/fs/jfs/file.c linux-2.6.36-vs2.3.0.36.38/fs/jfs/file.c
4311 --- linux-2.6.36/fs/jfs/file.c 2010-10-21 13:07:50.000000000 +0200
4312 +++ linux-2.6.36-vs2.3.0.36.38/fs/jfs/file.c 2010-10-21 13:09:36.000000000 +0200
4313 @@ -102,7 +102,8 @@ int jfs_setattr(struct dentry *dentry, s
4314 if (is_quota_modification(inode, iattr))
4315 dquot_initialize(inode);
4316 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4317 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4318 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4319 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4320 rc = dquot_transfer(inode, iattr);
4323 @@ -133,6 +134,7 @@ const struct inode_operations jfs_file_i
4324 #ifdef CONFIG_JFS_POSIX_ACL
4325 .check_acl = jfs_check_acl,
4327 + .sync_flags = jfs_sync_flags,
4330 const struct file_operations jfs_file_operations = {
4331 diff -NurpP --minimal linux-2.6.36/fs/jfs/ioctl.c linux-2.6.36-vs2.3.0.36.38/fs/jfs/ioctl.c
4332 --- linux-2.6.36/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4333 +++ linux-2.6.36-vs2.3.0.36.38/fs/jfs/ioctl.c 2010-10-21 13:09:36.000000000 +0200
4335 #include <linux/mount.h>
4336 #include <linux/time.h>
4337 #include <linux/sched.h>
4338 +#include <linux/mount.h>
4339 #include <asm/current.h>
4340 #include <asm/uaccess.h>
4342 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
4346 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
4348 + inode->i_flags = flags;
4349 + inode->i_vflags = vflags;
4350 + jfs_get_inode_flags(JFS_IP(inode));
4351 + inode->i_ctime = CURRENT_TIME_SEC;
4352 + mark_inode_dirty(inode);
4356 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4358 struct inode *inode = filp->f_dentry->d_inode;
4359 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
4360 if (!S_ISDIR(inode->i_mode))
4361 flags &= ~JFS_DIRSYNC_FL;
4363 + if (IS_BARRIER(inode)) {
4364 + vxwprintk_task(1, "messing with the barrier.");
4368 /* Is it quota file? Do not allow user to mess with it */
4369 if (IS_NOQUOTA(inode)) {
4371 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
4372 * the relevant capability.
4374 if ((oldflags & JFS_IMMUTABLE_FL) ||
4375 - ((flags ^ oldflags) &
4376 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4377 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4378 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4379 if (!capable(CAP_LINUX_IMMUTABLE)) {
4380 mutex_unlock(&inode->i_mutex);
4382 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
4386 - flags = flags & JFS_FL_USER_MODIFIABLE;
4387 + flags &= JFS_FL_USER_MODIFIABLE;
4388 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
4389 jfs_inode->mode2 = flags;
4391 diff -NurpP --minimal linux-2.6.36/fs/jfs/jfs_dinode.h linux-2.6.36-vs2.3.0.36.38/fs/jfs/jfs_dinode.h
4392 --- linux-2.6.36/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
4393 +++ linux-2.6.36-vs2.3.0.36.38/fs/jfs/jfs_dinode.h 2010-10-21 13:09:36.000000000 +0200
4394 @@ -161,9 +161,13 @@ struct dinode {
4396 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4397 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4398 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4400 -#define JFS_FL_USER_VISIBLE 0x03F80000
4401 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4402 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4403 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4405 +#define JFS_FL_USER_VISIBLE 0x07F80000
4406 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4407 #define JFS_FL_INHERIT 0x03C80000
4409 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4410 diff -NurpP --minimal linux-2.6.36/fs/jfs/jfs_filsys.h linux-2.6.36-vs2.3.0.36.38/fs/jfs/jfs_filsys.h
4411 --- linux-2.6.36/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4412 +++ linux-2.6.36-vs2.3.0.36.38/fs/jfs/jfs_filsys.h 2010-10-21 13:09:36.000000000 +0200
4414 #define JFS_NAME_MAX 255
4415 #define JFS_PATH_MAX BPSIZE
4417 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4420 * file system state (superblock state)
4421 diff -NurpP --minimal linux-2.6.36/fs/jfs/jfs_imap.c linux-2.6.36-vs2.3.0.36.38/fs/jfs/jfs_imap.c
4422 --- linux-2.6.36/fs/jfs/jfs_imap.c 2010-07-07 18:31:52.000000000 +0200
4423 +++ linux-2.6.36-vs2.3.0.36.38/fs/jfs/jfs_imap.c 2010-10-21 13:09:36.000000000 +0200
4425 #include <linux/pagemap.h>
4426 #include <linux/quotaops.h>
4427 #include <linux/slab.h>
4428 +#include <linux/vs_tag.h>
4430 #include "jfs_incore.h"
4431 #include "jfs_inode.h"
4432 @@ -3060,6 +3061,8 @@ static int copy_from_dinode(struct dinod
4434 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4435 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4439 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4440 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4441 @@ -3080,14 +3083,18 @@ static int copy_from_dinode(struct dinod
4443 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4445 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4446 + uid = le32_to_cpu(dip->di_uid);
4447 + gid = le32_to_cpu(dip->di_gid);
4448 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4450 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4452 ip->i_uid = jfs_ip->saved_uid;
4454 ip->i_uid = sbi->uid;
4457 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4458 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4460 ip->i_gid = jfs_ip->saved_gid;
4462 @@ -3152,14 +3159,12 @@ static void copy_to_dinode(struct dinode
4463 dip->di_size = cpu_to_le64(ip->i_size);
4464 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4465 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4466 - if (sbi->uid == -1)
4467 - dip->di_uid = cpu_to_le32(ip->i_uid);
4469 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4470 - if (sbi->gid == -1)
4471 - dip->di_gid = cpu_to_le32(ip->i_gid);
4473 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4475 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4476 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4477 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4478 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4480 jfs_get_inode_flags(jfs_ip);
4482 * mode2 is only needed for storing the higher order bits.
4483 diff -NurpP --minimal linux-2.6.36/fs/jfs/jfs_inode.c linux-2.6.36-vs2.3.0.36.38/fs/jfs/jfs_inode.c
4484 --- linux-2.6.36/fs/jfs/jfs_inode.c 2010-08-02 16:52:49.000000000 +0200
4485 +++ linux-2.6.36-vs2.3.0.36.38/fs/jfs/jfs_inode.c 2010-10-21 13:09:36.000000000 +0200
4488 #include <linux/fs.h>
4489 #include <linux/quotaops.h>
4490 +#include <linux/vs_tag.h>
4491 #include "jfs_incore.h"
4492 #include "jfs_inode.h"
4493 #include "jfs_filsys.h"
4494 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4496 unsigned int flags = JFS_IP(inode)->mode2;
4498 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4499 - S_NOATIME | S_DIRSYNC | S_SYNC);
4500 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4501 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4503 if (flags & JFS_IMMUTABLE_FL)
4504 inode->i_flags |= S_IMMUTABLE;
4505 + if (flags & JFS_IXUNLINK_FL)
4506 + inode->i_flags |= S_IXUNLINK;
4508 + if (flags & JFS_SYNC_FL)
4509 + inode->i_flags |= S_SYNC;
4510 if (flags & JFS_APPEND_FL)
4511 inode->i_flags |= S_APPEND;
4512 if (flags & JFS_NOATIME_FL)
4513 inode->i_flags |= S_NOATIME;
4514 if (flags & JFS_DIRSYNC_FL)
4515 inode->i_flags |= S_DIRSYNC;
4516 - if (flags & JFS_SYNC_FL)
4517 - inode->i_flags |= S_SYNC;
4519 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4521 + if (flags & JFS_BARRIER_FL)
4522 + inode->i_vflags |= V_BARRIER;
4523 + if (flags & JFS_COW_FL)
4524 + inode->i_vflags |= V_COW;
4527 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4529 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4530 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4532 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4533 + JFS_APPEND_FL | JFS_NOATIME_FL |
4534 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4535 + JFS_BARRIER_FL | JFS_COW_FL);
4537 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4538 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4539 if (flags & S_IMMUTABLE)
4540 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4541 + if (flags & S_IXUNLINK)
4542 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4544 if (flags & S_APPEND)
4545 jfs_ip->mode2 |= JFS_APPEND_FL;
4546 if (flags & S_NOATIME)
4547 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4548 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4550 jfs_ip->mode2 |= JFS_SYNC_FL;
4552 + if (vflags & V_BARRIER)
4553 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4554 + if (vflags & V_COW)
4555 + jfs_ip->mode2 |= JFS_COW_FL;
4559 diff -NurpP --minimal linux-2.6.36/fs/jfs/jfs_inode.h linux-2.6.36-vs2.3.0.36.38/fs/jfs/jfs_inode.h
4560 --- linux-2.6.36/fs/jfs/jfs_inode.h 2010-10-21 13:07:50.000000000 +0200
4561 +++ linux-2.6.36-vs2.3.0.36.38/fs/jfs/jfs_inode.h 2010-10-21 13:09:36.000000000 +0200
4562 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4563 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4564 int fh_len, int fh_type);
4565 extern void jfs_set_inode_flags(struct inode *);
4566 +extern int jfs_sync_flags(struct inode *, int, int);
4567 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4568 extern int jfs_setattr(struct dentry *, struct iattr *);
4570 diff -NurpP --minimal linux-2.6.36/fs/jfs/namei.c linux-2.6.36-vs2.3.0.36.38/fs/jfs/namei.c
4571 --- linux-2.6.36/fs/jfs/namei.c 2010-07-07 18:31:52.000000000 +0200
4572 +++ linux-2.6.36-vs2.3.0.36.38/fs/jfs/namei.c 2010-10-21 13:09:36.000000000 +0200
4574 #include <linux/ctype.h>
4575 #include <linux/quotaops.h>
4576 #include <linux/exportfs.h>
4577 +#include <linux/vs_tag.h>
4578 #include "jfs_incore.h"
4579 #include "jfs_superblock.h"
4580 #include "jfs_inode.h"
4581 @@ -1491,6 +1492,7 @@ static struct dentry *jfs_lookup(struct
4582 return ERR_CAST(ip);
4585 + dx_propagate_tag(nd, ip);
4586 dentry = d_splice_alias(ip, dentry);
4588 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4589 @@ -1560,6 +1562,7 @@ const struct inode_operations jfs_dir_in
4590 #ifdef CONFIG_JFS_POSIX_ACL
4591 .check_acl = jfs_check_acl,
4593 + .sync_flags = jfs_sync_flags,
4596 const struct file_operations jfs_dir_operations = {
4597 diff -NurpP --minimal linux-2.6.36/fs/jfs/super.c linux-2.6.36-vs2.3.0.36.38/fs/jfs/super.c
4598 --- linux-2.6.36/fs/jfs/super.c 2010-10-21 13:07:50.000000000 +0200
4599 +++ linux-2.6.36-vs2.3.0.36.38/fs/jfs/super.c 2010-10-21 13:09:36.000000000 +0200
4600 @@ -195,7 +195,8 @@ static void jfs_put_super(struct super_b
4602 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4603 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4604 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4605 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4606 + Opt_tag, Opt_notag, Opt_tagid
4609 static const match_table_t tokens = {
4610 @@ -205,6 +206,10 @@ static const match_table_t tokens = {
4611 {Opt_resize, "resize=%u"},
4612 {Opt_resize_nosize, "resize"},
4613 {Opt_errors, "errors=%s"},
4615 + {Opt_notag, "notag"},
4616 + {Opt_tagid, "tagid=%u"},
4617 + {Opt_tag, "tagxid"},
4618 {Opt_ignore, "noquota"},
4619 {Opt_ignore, "quota"},
4620 {Opt_usrquota, "usrquota"},
4621 @@ -339,6 +344,20 @@ static int parse_options(char *options,
4625 +#ifndef CONFIG_TAGGING_NONE
4627 + *flag |= JFS_TAGGED;
4630 + *flag &= JFS_TAGGED;
4633 +#ifdef CONFIG_PROPAGATE
4636 + *flag |= JFS_TAGGED;
4640 printk("jfs: Unrecognized mount option \"%s\" "
4641 " or missing value\n", p);
4642 @@ -369,6 +388,12 @@ static int jfs_remount(struct super_bloc
4643 if (!parse_options(data, sb, &newLVSize, &flag)) {
4646 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4647 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4654 if (sb->s_flags & MS_RDONLY) {
4655 @@ -460,6 +485,9 @@ static int jfs_fill_super(struct super_b
4656 #ifdef CONFIG_JFS_POSIX_ACL
4657 sb->s_flags |= MS_POSIXACL;
4659 + /* map mount option tagxid */
4660 + if (sbi->flag & JFS_TAGGED)
4661 + sb->s_flags |= MS_TAGGED;
4664 printk(KERN_ERR "resize option for remount only\n");
4665 diff -NurpP --minimal linux-2.6.36/fs/libfs.c linux-2.6.36-vs2.3.0.36.38/fs/libfs.c
4666 --- linux-2.6.36/fs/libfs.c 2010-10-21 13:07:50.000000000 +0200
4667 +++ linux-2.6.36-vs2.3.0.36.38/fs/libfs.c 2010-10-21 13:09:36.000000000 +0200
4668 @@ -124,7 +124,8 @@ static inline unsigned char dt_type(stru
4669 * both impossible due to the lock on directory.
4672 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4673 +static inline int do_dcache_readdir_filter(struct file *filp,
4674 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4676 struct dentry *dentry = filp->f_path.dentry;
4677 struct dentry *cursor = filp->private_data;
4678 @@ -157,6 +158,8 @@ int dcache_readdir(struct file * filp, v
4679 next = list_entry(p, struct dentry, d_u.d_child);
4680 if (d_unhashed(next) || !next->d_inode)
4682 + if (filter && !filter(next))
4685 spin_unlock(&dcache_lock);
4686 if (filldir(dirent, next->d_name.name,
4687 @@ -175,6 +178,18 @@ int dcache_readdir(struct file * filp, v
4691 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4693 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4696 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4697 + int (*filter)(struct dentry *))
4699 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4703 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4706 @@ -925,6 +940,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4707 EXPORT_SYMBOL(dcache_dir_lseek);
4708 EXPORT_SYMBOL(dcache_dir_open);
4709 EXPORT_SYMBOL(dcache_readdir);
4710 +EXPORT_SYMBOL(dcache_readdir_filter);
4711 EXPORT_SYMBOL(generic_read_dir);
4712 EXPORT_SYMBOL(get_sb_pseudo);
4713 EXPORT_SYMBOL(simple_write_begin);
4714 diff -NurpP --minimal linux-2.6.36/fs/locks.c linux-2.6.36-vs2.3.0.36.38/fs/locks.c
4715 --- linux-2.6.36/fs/locks.c 2010-07-07 18:31:52.000000000 +0200
4716 +++ linux-2.6.36-vs2.3.0.36.38/fs/locks.c 2010-10-21 13:09:36.000000000 +0200
4718 #include <linux/time.h>
4719 #include <linux/rcupdate.h>
4720 #include <linux/pid_namespace.h>
4721 +#include <linux/vs_base.h>
4722 +#include <linux/vs_limit.h>
4724 #include <asm/uaccess.h>
4726 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
4727 /* Allocate an empty lock structure. */
4728 static struct file_lock *locks_alloc_lock(void)
4730 + if (!vx_locks_avail(1))
4732 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4735 @@ -174,6 +178,7 @@ static void locks_free_lock(struct file_
4736 BUG_ON(!list_empty(&fl->fl_block));
4737 BUG_ON(!list_empty(&fl->fl_link));
4740 locks_release_private(fl);
4741 kmem_cache_free(filelock_cache, fl);
4743 @@ -194,6 +199,7 @@ void locks_init_lock(struct file_lock *f
4744 fl->fl_start = fl->fl_end = 0;
4746 fl->fl_lmops = NULL;
4750 EXPORT_SYMBOL(locks_init_lock);
4751 @@ -248,6 +254,7 @@ void locks_copy_lock(struct file_lock *n
4752 new->fl_file = fl->fl_file;
4753 new->fl_ops = fl->fl_ops;
4754 new->fl_lmops = fl->fl_lmops;
4755 + new->fl_xid = fl->fl_xid;
4757 locks_copy_private(new, fl);
4759 @@ -286,6 +293,11 @@ static int flock_make_lock(struct file *
4760 fl->fl_flags = FL_FLOCK;
4762 fl->fl_end = OFFSET_MAX;
4764 + vxd_assert(filp->f_xid == vx_current_xid(),
4765 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4766 + fl->fl_xid = filp->f_xid;
4771 @@ -451,6 +463,7 @@ static int lease_init(struct file *filp,
4773 fl->fl_owner = current->files;
4774 fl->fl_pid = current->tgid;
4775 + fl->fl_xid = vx_current_xid();
4778 fl->fl_flags = FL_LEASE;
4779 @@ -470,6 +483,11 @@ static struct file_lock *lease_alloc(str
4781 return ERR_PTR(error);
4783 + fl->fl_xid = vx_current_xid();
4785 + vxd_assert(filp->f_xid == fl->fl_xid,
4786 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4788 error = lease_init(filp, type, fl);
4790 locks_free_lock(fl);
4791 @@ -770,6 +788,7 @@ static int flock_lock_file(struct file *
4795 + new_fl->fl_xid = -1;
4797 for_each_lock(inode, before) {
4798 struct file_lock *fl = *before;
4799 @@ -790,6 +809,7 @@ find_conflict:
4801 locks_copy_lock(new_fl, request);
4802 locks_insert_lock(before, new_fl);
4803 + vx_locks_inc(new_fl);
4807 @@ -800,7 +820,8 @@ out:
4811 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4812 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4813 + struct file_lock *conflock, xid_t xid)
4815 struct file_lock *fl;
4816 struct file_lock *new_fl = NULL;
4817 @@ -810,6 +831,8 @@ static int __posix_lock_file(struct inod
4818 struct file_lock **before;
4819 int error, added = 0;
4821 + vxd_assert(xid == vx_current_xid(),
4822 + "xid(%d) == current(%d)", xid, vx_current_xid());
4824 * We may need two file_lock structures for this operation,
4825 * so we get them in advance to avoid races.
4826 @@ -820,7 +843,11 @@ static int __posix_lock_file(struct inod
4827 (request->fl_type != F_UNLCK ||
4828 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4829 new_fl = locks_alloc_lock();
4830 + new_fl->fl_xid = xid;
4831 + vx_locks_inc(new_fl);
4832 new_fl2 = locks_alloc_lock();
4833 + new_fl2->fl_xid = xid;
4834 + vx_locks_inc(new_fl2);
4838 @@ -1019,7 +1046,8 @@ static int __posix_lock_file(struct inod
4839 int posix_lock_file(struct file *filp, struct file_lock *fl,
4840 struct file_lock *conflock)
4842 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4843 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4844 + fl, conflock, filp->f_xid);
4846 EXPORT_SYMBOL(posix_lock_file);
4848 @@ -1109,7 +1137,7 @@ int locks_mandatory_area(int read_write,
4849 fl.fl_end = offset + count - 1;
4852 - error = __posix_lock_file(inode, &fl, NULL);
4853 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4854 if (error != FILE_LOCK_DEFERRED)
4856 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4857 @@ -1425,6 +1453,7 @@ int generic_setlease(struct file *filp,
4859 locks_copy_lock(new_fl, lease);
4860 locks_insert_lock(before, new_fl);
4861 + vx_locks_inc(new_fl);
4865 @@ -1780,6 +1809,11 @@ int fcntl_setlk(unsigned int fd, struct
4866 if (file_lock == NULL)
4869 + vxd_assert(filp->f_xid == vx_current_xid(),
4870 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4871 + file_lock->fl_xid = filp->f_xid;
4872 + vx_locks_inc(file_lock);
4875 * This might block, so we do it before checking the inode.
4877 @@ -1898,6 +1932,11 @@ int fcntl_setlk64(unsigned int fd, struc
4878 if (file_lock == NULL)
4881 + vxd_assert(filp->f_xid == vx_current_xid(),
4882 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4883 + file_lock->fl_xid = filp->f_xid;
4884 + vx_locks_inc(file_lock);
4887 * This might block, so we do it before checking the inode.
4889 @@ -2163,8 +2202,11 @@ static int locks_show(struct seq_file *f
4891 lock_get_status(f, fl, (long)f->private, "");
4893 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4894 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4895 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4897 lock_get_status(f, bfl, (long)f->private, " ->");
4902 diff -NurpP --minimal linux-2.6.36/fs/namei.c linux-2.6.36-vs2.3.0.36.38/fs/namei.c
4903 --- linux-2.6.36/fs/namei.c 2010-10-21 13:07:50.000000000 +0200
4904 +++ linux-2.6.36-vs2.3.0.36.38/fs/namei.c 2010-10-21 22:29:08.000000000 +0200
4906 #include <linux/fcntl.h>
4907 #include <linux/device_cgroup.h>
4908 #include <linux/fs_struct.h>
4909 +#include <linux/proc_fs.h>
4910 +#include <linux/vserver/inode.h>
4911 +#include <linux/vs_base.h>
4912 +#include <linux/vs_tag.h>
4913 +#include <linux/vs_cowbl.h>
4914 +#include <linux/vs_device.h>
4915 +#include <linux/vs_context.h>
4916 +#include <linux/pid_namespace.h>
4917 #include <asm/uaccess.h>
4919 #include "internal.h"
4920 @@ -166,6 +174,84 @@ void putname(const char *name)
4921 EXPORT_SYMBOL(putname);
4924 +static inline int dx_barrier(const struct inode *inode)
4926 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4927 + vxwprintk_task(1, "did hit the barrier.");
4933 +static int __dx_permission(const struct inode *inode, int mask)
4935 + if (dx_barrier(inode))
4938 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4939 + /* devpts is xid tagged */
4940 + if (S_ISDIR(inode->i_mode) ||
4941 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4944 + /* just pretend we didn't find anything */
4947 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4948 + struct proc_dir_entry *de = PDE(inode);
4950 + if (de && !vx_hide_check(0, de->vx_flags))
4953 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4955 + struct task_struct *tsk;
4957 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4958 + vx_flags(VXF_STATE_SETUP, 0))
4961 + pid = PROC_I(inode)->pid;
4965 + tsk = pid_task(pid, PIDTYPE_PID);
4966 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4967 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4968 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
4972 + /* FIXME: Should we block some entries here? */
4977 + if (dx_notagcheck(inode->i_sb) ||
4978 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4987 +int dx_permission(const struct inode *inode, int mask)
4989 + int ret = __dx_permission(inode, mask);
4990 + if (unlikely(ret)) {
4991 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4992 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4995 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4996 + mask, inode->i_sb->s_id, inode, inode->i_tag,
5003 * This does basic POSIX ACL permission checking
5005 @@ -266,10 +352,14 @@ int inode_permission(struct inode *inode
5007 * Nobody gets write access to an immutable file.
5009 - if (IS_IMMUTABLE(inode))
5010 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
5014 + retval = dx_permission(inode, mask);
5018 if (inode->i_op->permission)
5019 retval = inode->i_op->permission(inode, mask);
5021 @@ -463,6 +553,9 @@ static int exec_permission(struct inode
5025 + if (dx_barrier(inode))
5028 if (inode->i_op->permission) {
5029 ret = inode->i_op->permission(inode, MAY_EXEC);
5031 @@ -672,7 +765,8 @@ static __always_inline void follow_dotdo
5033 if (nd->path.dentry == nd->root.dentry &&
5034 nd->path.mnt == nd->root.mnt) {
5036 + /* for sane '/' avoid follow_mount() */
5039 if (nd->path.dentry != nd->path.mnt->mnt_root) {
5040 /* rare case of legitimate dget_parent()... */
5041 @@ -725,7 +819,7 @@ static int do_lookup(struct nameidata *n
5043 struct vfsmount *mnt = nd->path.mnt;
5044 struct dentry *dentry, *parent;
5045 - struct inode *dir;
5046 + struct inode *dir, *inode;
5048 * See if the low-level filesystem might want
5049 * to use its own hash..
5050 @@ -747,12 +841,31 @@ static int do_lookup(struct nameidata *n
5052 if (dentry->d_op && dentry->d_op->d_revalidate)
5053 goto need_revalidate;
5055 + inode = dentry->d_inode;
5059 + if (__dx_permission(inode, MAY_ACCESS))
5063 path->dentry = dentry;
5064 __follow_mount(path);
5068 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
5069 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
5072 + "did lookup hidden %s:%p[#%d,%lu] " VS_Q("%s/%.*s") ".",
5073 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
5074 + vxd_path(&nd->path), name->len, name->name);
5080 parent = nd->path.dentry;
5081 dir = parent->d_inode;
5082 @@ -1307,7 +1420,7 @@ static int may_delete(struct inode *dir,
5085 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5086 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5087 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5090 if (!S_ISDIR(victim->d_inode->i_mode))
5091 @@ -1430,6 +1543,14 @@ int may_open(struct path *path, int acc_
5095 +#ifdef CONFIG_VSERVER_COWBL
5096 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5097 + if (IS_COW_LINK(inode))
5099 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5100 + mark_inode_dirty(inode);
5103 error = inode_permission(inode, acc_mode);
5106 @@ -1538,7 +1659,8 @@ static int open_will_truncate(int flag,
5109 static struct file *finish_open(struct nameidata *nd,
5110 - int open_flag, int acc_mode)
5111 + int open_flag, int acc_mode,
5112 + const char *pathname)
5116 @@ -1551,6 +1673,23 @@ static struct file *finish_open(struct n
5119 error = may_open(&nd->path, acc_mode, open_flag);
5120 +#ifdef CONFIG_VSERVER_COWBL
5121 + if (error == -EMLINK) {
5122 + struct dentry *dentry;
5123 + dentry = cow_break_link(pathname);
5124 + if (IS_ERR(dentry)) {
5125 + error = PTR_ERR(dentry);
5129 + if (will_truncate)
5130 + mnt_drop_write(nd->path.mnt);
5131 + release_open_intent(nd);
5132 + path_put(&nd->path);
5133 + return ERR_PTR(-EMLINK);
5139 mnt_drop_write(nd->path.mnt);
5140 @@ -1719,7 +1858,7 @@ static struct file *do_last(struct namei
5141 if (S_ISDIR(path->dentry->d_inode->i_mode))
5144 - filp = finish_open(nd, open_flag, acc_mode);
5145 + filp = finish_open(nd, open_flag, acc_mode, pathname);
5149 @@ -1748,7 +1887,11 @@ struct file *do_filp_open(int dfd, const
5151 int flag = open_to_namei_flags(open_flag);
5152 int force_reval = 0;
5154 +#ifdef CONFIG_VSERVER_COWBL
5159 if (!(open_flag & O_CREAT))
5162 @@ -1814,6 +1957,13 @@ reval:
5163 if (!(open_flag & O_NOFOLLOW))
5164 nd.flags |= LOOKUP_FOLLOW;
5165 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
5166 +#ifdef CONFIG_VSERVER_COWBL
5167 + if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
5173 while (unlikely(!filp)) { /* trailing symlink */
5175 struct inode *inode = path.dentry->d_inode;
5176 @@ -1852,6 +2002,13 @@ reval:
5178 nd.flags &= ~LOOKUP_PARENT;
5179 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
5180 +#ifdef CONFIG_VSERVER_COWBL
5181 + if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
5187 if (inode->i_op->put_link)
5188 inode->i_op->put_link(holder.dentry, &nd, cookie);
5190 @@ -1952,9 +2109,17 @@ int vfs_mknod(struct inode *dir, struct
5194 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5195 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5198 + if (!capable(CAP_MKNOD))
5201 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5203 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5206 if (!dir->i_op->mknod)
5209 @@ -2419,7 +2584,7 @@ int vfs_link(struct dentry *old_dentry,
5211 * A link to an append-only or immutable file cannot be created.
5213 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5214 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5216 if (!dir->i_op->link)
5218 @@ -2791,6 +2956,222 @@ int vfs_follow_link(struct nameidata *nd
5219 return __vfs_follow_link(nd, link);
5223 +#ifdef CONFIG_VSERVER_COWBL
5225 +#include <linux/file.h>
5228 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5232 + return do_splice_direct(in, &ppos, out, len, 0);
5235 +struct dentry *cow_break_link(const char *pathname)
5237 + int ret, mode, pathlen, redo = 0;
5238 + struct nameidata old_nd, dir_nd;
5239 + struct path old_path, new_path;
5240 + struct dentry *dir, *res = NULL;
5241 + struct file *old_file;
5242 + struct file *new_file;
5243 + char *to, *path, pad='\251';
5246 + vxdprintk(VXD_CBIT(misc, 1),
5247 + "cow_break_link(" VS_Q("%s") ")", pathname);
5248 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5253 + /* old_nd will have refs to dentry and mnt */
5254 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5255 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5257 + goto out_free_path;
5259 + old_path = old_nd.path;
5260 + mode = old_path.dentry->d_inode->i_mode;
5262 + to = d_path(&old_path, path, PATH_MAX-2);
5263 + pathlen = strlen(to);
5264 + vxdprintk(VXD_CBIT(misc, 2),
5265 + "old path " VS_Q("%s") " [" VS_Q("%.*s") ":%d]", to,
5266 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5267 + old_path.dentry->d_name.len);
5269 + to[pathlen + 1] = 0;
5271 + to[pathlen] = pad--;
5273 + if (pad <= '\240')
5276 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
5277 + /* dir_nd will have refs to dentry and mnt */
5278 + ret = path_lookup(to,
5279 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5280 + vxdprintk(VXD_CBIT(misc, 2),
5281 + "path_lookup(new): %d", ret);
5285 + /* this puppy downs the inode mutex */
5286 + new_path.dentry = lookup_create(&dir_nd, 0);
5287 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5288 + vxdprintk(VXD_CBIT(misc, 2),
5289 + "lookup_create(new): %p", new_path.dentry);
5290 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5291 + path_put(&dir_nd.path);
5294 + vxdprintk(VXD_CBIT(misc, 2),
5295 + "lookup_create(new): %p [" VS_Q("%.*s") ":%d]",
5297 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5298 + new_path.dentry->d_name.len);
5299 + dir = dir_nd.path.dentry;
5301 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5302 + vxdprintk(VXD_CBIT(misc, 2),
5303 + "vfs_create(new): %d", ret);
5304 + if (ret == -EEXIST) {
5305 + mutex_unlock(&dir->d_inode->i_mutex);
5306 + dput(new_path.dentry);
5307 + path_put(&dir_nd.path);
5311 + goto out_unlock_new;
5313 + /* drop out early, ret passes ENOENT */
5315 + if ((redo = d_unhashed(old_path.dentry)))
5316 + goto out_unlock_new;
5318 + new_path.mnt = dir_nd.path.mnt;
5319 + dget(old_path.dentry);
5320 + mntget(old_path.mnt);
5321 + /* this one cleans up the dentry/mnt in case of failure */
5322 + old_file = dentry_open(old_path.dentry, old_path.mnt,
5323 + O_RDONLY, current_cred());
5324 + vxdprintk(VXD_CBIT(misc, 2),
5325 + "dentry_open(old): %p", old_file);
5326 + if (!old_file || IS_ERR(old_file)) {
5327 + res = IS_ERR(old_file) ? (void *) old_file : res;
5328 + goto out_unlock_new;
5331 + dget(new_path.dentry);
5332 + mntget(new_path.mnt);
5333 + /* this one cleans up the dentry/mnt in case of failure */
5334 + new_file = dentry_open(new_path.dentry, new_path.mnt,
5335 + O_WRONLY, current_cred());
5336 + vxdprintk(VXD_CBIT(misc, 2),
5337 + "dentry_open(new): %p", new_file);
5339 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5340 + if (!new_file || IS_ERR(new_file))
5341 + goto out_fput_old;
5343 + size = i_size_read(old_file->f_dentry->d_inode);
5344 + ret = do_cow_splice(old_file, new_file, size);
5345 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5347 + goto out_fput_both;
5348 + } else if (ret < size) {
5350 + goto out_fput_both;
5352 + struct inode *old_inode = old_path.dentry->d_inode;
5353 + struct inode *new_inode = new_path.dentry->d_inode;
5354 + struct iattr attr = {
5355 + .ia_uid = old_inode->i_uid,
5356 + .ia_gid = old_inode->i_gid,
5357 + .ia_valid = ATTR_UID | ATTR_GID
5360 + setattr_copy(new_inode, &attr);
5361 + mark_inode_dirty(new_inode);
5364 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5366 + /* drop out late */
5368 + if ((redo = d_unhashed(old_path.dentry)))
5371 + vxdprintk(VXD_CBIT(misc, 2),
5372 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
5373 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5374 + new_path.dentry->d_name.len,
5375 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5376 + old_path.dentry->d_name.len);
5377 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5378 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5379 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5380 + res = new_path.dentry;
5383 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5386 + vxdprintk(VXD_CBIT(misc, 3),
5387 + "fput(new_file=%p[#%ld])", new_file,
5388 + atomic_long_read(&new_file->f_count));
5392 + vxdprintk(VXD_CBIT(misc, 3),
5393 + "fput(old_file=%p[#%ld])", old_file,
5394 + atomic_long_read(&old_file->f_count));
5398 + mutex_unlock(&dir->d_inode->i_mutex);
5402 + /* error path cleanup */
5403 + vfs_unlink(dir->d_inode, new_path.dentry);
5404 + dput(new_path.dentry);
5408 + goto out_rel_both;
5409 + /* lookup dentry once again */
5410 + path_put(&old_nd.path);
5411 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5413 + goto out_rel_both;
5415 + new_path.dentry = old_nd.path.dentry;
5416 + vxdprintk(VXD_CBIT(misc, 2),
5417 + "path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
5419 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5420 + new_path.dentry->d_name.len);
5421 + dget(new_path.dentry);
5422 + res = new_path.dentry;
5425 + path_put(&dir_nd.path);
5427 + path_put(&old_nd.path);
5432 + res = ERR_PTR(ret);
5438 /* get the link contents into pagecache */
5439 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5441 diff -NurpP --minimal linux-2.6.36/fs/namespace.c linux-2.6.36-vs2.3.0.36.38/fs/namespace.c
5442 --- linux-2.6.36/fs/namespace.c 2010-10-21 13:07:50.000000000 +0200
5443 +++ linux-2.6.36-vs2.3.0.36.38/fs/namespace.c 2010-10-21 15:11:02.000000000 +0200
5445 #include <linux/idr.h>
5446 #include <linux/fs_struct.h>
5447 #include <linux/fsnotify.h>
5448 +#include <linux/vs_base.h>
5449 +#include <linux/vs_context.h>
5450 +#include <linux/vs_tag.h>
5451 +#include <linux/vserver/space.h>
5452 +#include <linux/vserver/global.h>
5453 #include <asm/uaccess.h>
5454 #include <asm/unistd.h>
5456 @@ -601,6 +606,7 @@ static struct vfsmount *clone_mnt(struct
5457 mnt->mnt_root = dget(root);
5458 mnt->mnt_mountpoint = mnt->mnt_root;
5459 mnt->mnt_parent = mnt;
5460 + mnt->mnt_tag = old->mnt_tag;
5462 if (flag & CL_SLAVE) {
5463 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5464 @@ -699,6 +705,31 @@ static inline void mangle(struct seq_fil
5465 seq_escape(m, s, " \t\n\\");
5468 +static int mnt_is_reachable(struct vfsmount *mnt)
5471 + struct dentry *point;
5474 + if (mnt == mnt->mnt_ns->root)
5477 + br_read_lock(vfsmount_lock);
5478 + root = current->fs->root;
5479 + point = root.dentry;
5481 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5482 + point = mnt->mnt_mountpoint;
5483 + mnt = mnt->mnt_parent;
5486 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5488 + br_read_unlock(vfsmount_lock);
5494 * Simple .show_options callback for filesystems which don't want to
5495 * implement more complex mount option showing.
5496 @@ -801,6 +832,8 @@ static int show_sb_opts(struct seq_file
5497 { MS_SYNCHRONOUS, ",sync" },
5498 { MS_DIRSYNC, ",dirsync" },
5499 { MS_MANDLOCK, ",mand" },
5500 + { MS_TAGGED, ",tag" },
5501 + { MS_NOTAGCHECK, ",notagcheck" },
5504 const struct proc_fs_info *fs_infop;
5505 @@ -847,10 +880,20 @@ static int show_vfsmnt(struct seq_file *
5507 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5509 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5511 - seq_path(m, &mnt_path, " \t\n\\");
5513 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5515 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5518 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5519 + mnt == current->fs->root.mnt) {
5520 + seq_puts(m, "/dev/root / ");
5522 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5524 + seq_path(m, &mnt_path, " \t\n\\");
5527 show_type(m, mnt->mnt_sb);
5528 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5529 err = show_sb_opts(m, mnt->mnt_sb);
5530 @@ -880,6 +923,11 @@ static int show_mountinfo(struct seq_fil
5531 struct path root = p->root;
5534 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5536 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5539 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5540 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5541 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5542 @@ -938,17 +986,27 @@ static int show_vfsstat(struct seq_file
5543 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5547 - if (mnt->mnt_devname) {
5548 - seq_puts(m, "device ");
5549 - mangle(m, mnt->mnt_devname);
5551 - seq_puts(m, "no device");
5552 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5554 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5558 - seq_puts(m, " mounted on ");
5559 - seq_path(m, &mnt_path, " \t\n\\");
5561 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5562 + mnt == current->fs->root.mnt) {
5563 + seq_puts(m, "device /dev/root mounted on / ");
5566 + if (mnt->mnt_devname) {
5567 + seq_puts(m, "device ");
5568 + mangle(m, mnt->mnt_devname);
5570 + seq_puts(m, "no device");
5573 + seq_puts(m, " mounted on ");
5574 + seq_path(m, &mnt_path, " \t\n\\");
5578 /* file system type */
5579 seq_puts(m, "with fstype ");
5580 @@ -1194,7 +1252,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5584 - if (!capable(CAP_SYS_ADMIN))
5585 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5588 retval = do_umount(path.mnt, flags);
5589 @@ -1220,7 +1278,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5591 static int mount_is_safe(struct path *path)
5593 - if (capable(CAP_SYS_ADMIN))
5594 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5598 @@ -1510,7 +1568,7 @@ static int do_change_type(struct path *p
5602 - if (!capable(CAP_SYS_ADMIN))
5603 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5606 if (path->dentry != path->mnt->mnt_root)
5607 @@ -1541,11 +1599,13 @@ static int do_change_type(struct path *p
5608 * do loopback mount.
5610 static int do_loopback(struct path *path, char *old_name,
5612 + tag_t tag, unsigned long flags, int mnt_flags)
5614 struct path old_path;
5615 struct vfsmount *mnt = NULL;
5616 int err = mount_is_safe(path);
5617 + int recurse = flags & MS_REC;
5621 if (!old_name || !*old_name)
5622 @@ -1580,6 +1640,7 @@ static int do_loopback(struct path *path
5623 br_write_unlock(vfsmount_lock);
5624 release_mounts(&umount_list);
5626 + mnt->mnt_flags = mnt_flags;
5629 up_write(&namespace_sem);
5630 @@ -1610,12 +1671,12 @@ static int change_mount_flags(struct vfs
5631 * on it - tough luck.
5633 static int do_remount(struct path *path, int flags, int mnt_flags,
5635 + void *data, xid_t xid)
5638 struct super_block *sb = path->mnt->mnt_sb;
5640 - if (!capable(CAP_SYS_ADMIN))
5641 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5644 if (!check_mnt(path->mnt))
5645 @@ -1659,7 +1720,7 @@ static int do_move_mount(struct path *pa
5646 struct path old_path, parent_path;
5649 - if (!capable(CAP_SYS_ADMIN))
5650 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5652 if (!old_name || !*old_name)
5654 @@ -1741,7 +1802,7 @@ static int do_new_mount(struct path *pat
5657 /* we need capabilities... */
5658 - if (!capable(CAP_SYS_ADMIN))
5659 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5663 @@ -2009,6 +2070,7 @@ long do_mount(char *dev_name, char *dir_
5670 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5671 @@ -2036,6 +2098,12 @@ long do_mount(char *dev_name, char *dir_
5672 if (!(flags & MS_NOATIME))
5673 mnt_flags |= MNT_RELATIME;
5675 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5676 + /* FIXME: bind and re-mounts get the tag flag? */
5677 + if (flags & (MS_BIND|MS_REMOUNT))
5678 + flags |= MS_TAGID;
5681 /* Separate the per-mountpoint flags */
5682 if (flags & MS_NOSUID)
5683 mnt_flags |= MNT_NOSUID;
5684 @@ -2052,15 +2120,17 @@ long do_mount(char *dev_name, char *dir_
5685 if (flags & MS_RDONLY)
5686 mnt_flags |= MNT_READONLY;
5688 + if (!capable(CAP_SYS_ADMIN))
5689 + mnt_flags |= MNT_NODEV;
5690 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5691 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5694 if (flags & MS_REMOUNT)
5695 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5698 else if (flags & MS_BIND)
5699 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5700 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5701 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5702 retval = do_change_type(&path, flags);
5703 else if (flags & MS_MOVE)
5704 @@ -2139,6 +2209,7 @@ static struct mnt_namespace *dup_mnt_ns(
5705 q = next_mnt(q, new_ns->root);
5707 up_write(&namespace_sem);
5708 + atomic_inc(&vs_global_mnt_ns);
5712 @@ -2280,9 +2351,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5713 down_write(&namespace_sem);
5714 mutex_lock(&old.dentry->d_inode->i_mutex);
5716 - if (IS_MNT_SHARED(old.mnt) ||
5717 + if ((IS_MNT_SHARED(old.mnt) ||
5718 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5719 - IS_MNT_SHARED(root.mnt->mnt_parent))
5720 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5721 + !vx_flags(VXF_STATE_SETUP, 0))
5723 if (!check_mnt(root.mnt))
5725 @@ -2415,6 +2487,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5726 br_write_unlock(vfsmount_lock);
5727 up_write(&namespace_sem);
5728 release_mounts(&umount_list);
5729 + atomic_dec(&vs_global_mnt_ns);
5732 EXPORT_SYMBOL(put_mnt_ns);
5733 diff -NurpP --minimal linux-2.6.36/fs/nfs/client.c linux-2.6.36-vs2.3.0.36.38/fs/nfs/client.c
5734 --- linux-2.6.36/fs/nfs/client.c 2010-10-21 13:07:50.000000000 +0200
5735 +++ linux-2.6.36-vs2.3.0.36.38/fs/nfs/client.c 2010-10-21 13:09:36.000000000 +0200
5736 @@ -740,6 +740,9 @@ static int nfs_init_server_rpcclient(str
5737 if (server->flags & NFS_MOUNT_SOFT)
5738 server->client->cl_softrtry = 1;
5740 + server->client->cl_tag = 0;
5741 + if (server->flags & NFS_MOUNT_TAGGED)
5742 + server->client->cl_tag = 1;
5746 @@ -911,6 +914,10 @@ static void nfs_server_set_fsinfo(struct
5747 server->acdirmin = server->acdirmax = 0;
5750 + /* FIXME: needs fsinfo
5751 + if (server->flags & NFS_MOUNT_TAGGED)
5752 + sb->s_flags |= MS_TAGGED; */
5754 server->maxfilesize = fsinfo->maxfilesize;
5756 /* We're airborne Set socket buffersize */
5757 diff -NurpP --minimal linux-2.6.36/fs/nfs/dir.c linux-2.6.36-vs2.3.0.36.38/fs/nfs/dir.c
5758 --- linux-2.6.36/fs/nfs/dir.c 2010-10-21 13:07:50.000000000 +0200
5759 +++ linux-2.6.36-vs2.3.0.36.38/fs/nfs/dir.c 2010-10-21 13:09:36.000000000 +0200
5761 #include <linux/namei.h>
5762 #include <linux/mount.h>
5763 #include <linux/sched.h>
5764 +#include <linux/vs_tag.h>
5766 #include "nfs4_fs.h"
5767 #include "delegation.h"
5768 @@ -986,6 +987,7 @@ static struct dentry *nfs_lookup(struct
5770 goto out_unblock_sillyrename;
5772 + dx_propagate_tag(nd, inode);
5774 res = d_materialise_unique(dentry, inode);
5776 diff -NurpP --minimal linux-2.6.36/fs/nfs/inode.c linux-2.6.36-vs2.3.0.36.38/fs/nfs/inode.c
5777 --- linux-2.6.36/fs/nfs/inode.c 2010-10-21 13:07:50.000000000 +0200
5778 +++ linux-2.6.36-vs2.3.0.36.38/fs/nfs/inode.c 2010-10-21 13:09:36.000000000 +0200
5780 #include <linux/inet.h>
5781 #include <linux/nfs_xdr.h>
5782 #include <linux/slab.h>
5783 +#include <linux/vs_tag.h>
5785 #include <asm/system.h>
5786 #include <asm/uaccess.h>
5787 @@ -267,6 +268,8 @@ nfs_fhget(struct super_block *sb, struct
5788 if (inode->i_state & I_NEW) {
5789 struct nfs_inode *nfsi = NFS_I(inode);
5790 unsigned long now = jiffies;
5794 /* We set i_ino for the few things that still rely on it,
5795 * such as stat(2) */
5796 @@ -315,8 +318,8 @@ nfs_fhget(struct super_block *sb, struct
5797 nfsi->change_attr = 0;
5800 - inode->i_uid = -2;
5801 - inode->i_gid = -2;
5804 inode->i_blocks = 0;
5805 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5807 @@ -353,13 +356,13 @@ nfs_fhget(struct super_block *sb, struct
5808 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5809 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5810 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5811 - inode->i_uid = fattr->uid;
5813 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5814 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5815 | NFS_INO_INVALID_ACCESS
5816 | NFS_INO_INVALID_ACL;
5817 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5818 - inode->i_gid = fattr->gid;
5820 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5821 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5822 | NFS_INO_INVALID_ACCESS
5823 @@ -372,6 +375,11 @@ nfs_fhget(struct super_block *sb, struct
5825 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5827 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5828 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5829 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5830 + /* maybe fattr->xid someday */
5832 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5833 nfsi->attrtimeo_timestamp = now;
5834 nfsi->access_cache = RB_ROOT;
5835 @@ -488,6 +496,8 @@ void nfs_setattr_update_inode(struct ino
5836 inode->i_uid = attr->ia_uid;
5837 if ((attr->ia_valid & ATTR_GID) != 0)
5838 inode->i_gid = attr->ia_gid;
5839 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5840 + inode->i_tag = attr->ia_tag;
5841 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5842 spin_unlock(&inode->i_lock);
5844 @@ -923,6 +933,9 @@ static int nfs_check_inode_attributes(st
5845 struct nfs_inode *nfsi = NFS_I(inode);
5846 loff_t cur_size, new_isize;
5847 unsigned long invalid = 0;
5853 /* Has the inode gone and changed behind our back? */
5854 @@ -946,13 +959,18 @@ static int nfs_check_inode_attributes(st
5855 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5858 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5859 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5860 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5862 /* Have any file permissions changed? */
5863 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5864 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5865 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5866 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5867 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5868 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5869 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5870 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5871 + /* maybe check for tag too? */
5873 /* Has the link count changed? */
5874 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5875 @@ -1187,6 +1205,9 @@ static int nfs_update_inode(struct inode
5876 unsigned long invalid = 0;
5877 unsigned long now = jiffies;
5878 unsigned long save_cache_validity;
5883 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5884 __func__, inode->i_sb->s_id, inode->i_ino,
5885 @@ -1289,6 +1310,9 @@ static int nfs_update_inode(struct inode
5886 | NFS_INO_REVAL_PAGECACHE
5887 | NFS_INO_REVAL_FORCED);
5889 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5890 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5891 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5893 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5894 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5895 @@ -1310,9 +1334,9 @@ static int nfs_update_inode(struct inode
5896 | NFS_INO_REVAL_FORCED);
5898 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5899 - if (inode->i_uid != fattr->uid) {
5900 + if (uid != fattr->uid) {
5901 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5902 - inode->i_uid = fattr->uid;
5905 } else if (server->caps & NFS_CAP_OWNER)
5906 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5907 @@ -1321,9 +1345,9 @@ static int nfs_update_inode(struct inode
5908 | NFS_INO_REVAL_FORCED);
5910 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5911 - if (inode->i_gid != fattr->gid) {
5912 + if (gid != fattr->gid) {
5913 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5914 - inode->i_gid = fattr->gid;
5917 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5918 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5919 @@ -1331,6 +1355,10 @@ static int nfs_update_inode(struct inode
5920 | NFS_INO_INVALID_ACL
5921 | NFS_INO_REVAL_FORCED);
5923 + inode->i_uid = uid;
5924 + inode->i_gid = gid;
5925 + inode->i_tag = tag;
5927 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5928 if (inode->i_nlink != fattr->nlink) {
5929 invalid |= NFS_INO_INVALID_ATTR;
5930 diff -NurpP --minimal linux-2.6.36/fs/nfs/nfs3xdr.c linux-2.6.36-vs2.3.0.36.38/fs/nfs/nfs3xdr.c
5931 --- linux-2.6.36/fs/nfs/nfs3xdr.c 2010-10-21 13:07:50.000000000 +0200
5932 +++ linux-2.6.36-vs2.3.0.36.38/fs/nfs/nfs3xdr.c 2010-10-21 13:09:36.000000000 +0200
5934 #include <linux/nfs3.h>
5935 #include <linux/nfs_fs.h>
5936 #include <linux/nfsacl.h>
5937 +#include <linux/vs_tag.h>
5938 #include "internal.h"
5940 #define NFSDBG_FACILITY NFSDBG_XDR
5941 @@ -175,7 +176,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5944 static inline __be32 *
5945 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5946 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5948 if (attr->ia_valid & ATTR_MODE) {
5950 @@ -183,15 +184,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5954 - if (attr->ia_valid & ATTR_UID) {
5955 + if (attr->ia_valid & ATTR_UID ||
5956 + (tag && (attr->ia_valid & ATTR_TAG))) {
5958 - *p++ = htonl(attr->ia_uid);
5959 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5963 - if (attr->ia_valid & ATTR_GID) {
5964 + if (attr->ia_valid & ATTR_GID ||
5965 + (tag && (attr->ia_valid & ATTR_TAG))) {
5967 - *p++ = htonl(attr->ia_gid);
5968 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
5972 @@ -278,7 +281,8 @@ static int
5973 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
5975 p = xdr_encode_fhandle(p, args->fh);
5976 - p = xdr_encode_sattr(p, args->sattr);
5977 + p = xdr_encode_sattr(p, args->sattr,
5978 + req->rq_task->tk_client->cl_tag);
5979 *p++ = htonl(args->guard);
5981 p = xdr_encode_time3(p, &args->guardtime);
5982 @@ -383,7 +387,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
5983 *p++ = args->verifier[0];
5984 *p++ = args->verifier[1];
5986 - p = xdr_encode_sattr(p, args->sattr);
5987 + p = xdr_encode_sattr(p, args->sattr,
5988 + req->rq_task->tk_client->cl_tag);
5990 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5992 @@ -397,7 +402,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
5994 p = xdr_encode_fhandle(p, args->fh);
5995 p = xdr_encode_array(p, args->name, args->len);
5996 - p = xdr_encode_sattr(p, args->sattr);
5997 + p = xdr_encode_sattr(p, args->sattr,
5998 + req->rq_task->tk_client->cl_tag);
5999 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6002 @@ -410,7 +416,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
6004 p = xdr_encode_fhandle(p, args->fromfh);
6005 p = xdr_encode_array(p, args->fromname, args->fromlen);
6006 - p = xdr_encode_sattr(p, args->sattr);
6007 + p = xdr_encode_sattr(p, args->sattr,
6008 + req->rq_task->tk_client->cl_tag);
6009 *p++ = htonl(args->pathlen);
6010 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6012 @@ -428,7 +435,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
6013 p = xdr_encode_fhandle(p, args->fh);
6014 p = xdr_encode_array(p, args->name, args->len);
6015 *p++ = htonl(args->type);
6016 - p = xdr_encode_sattr(p, args->sattr);
6017 + p = xdr_encode_sattr(p, args->sattr,
6018 + req->rq_task->tk_client->cl_tag);
6019 if (args->type == NF3CHR || args->type == NF3BLK) {
6020 *p++ = htonl(MAJOR(args->rdev));
6021 *p++ = htonl(MINOR(args->rdev));
6022 diff -NurpP --minimal linux-2.6.36/fs/nfs/nfsroot.c linux-2.6.36-vs2.3.0.36.38/fs/nfs/nfsroot.c
6023 --- linux-2.6.36/fs/nfs/nfsroot.c 2010-08-02 16:52:50.000000000 +0200
6024 +++ linux-2.6.36-vs2.3.0.36.38/fs/nfs/nfsroot.c 2010-10-21 13:09:36.000000000 +0200
6025 @@ -122,12 +122,12 @@ static int mount_port __initdata = 0; /
6027 /* Options that take integer arguments */
6028 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
6029 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
6030 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
6031 /* Options that take no arguments */
6032 Opt_soft, Opt_hard, Opt_intr,
6033 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
6034 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
6035 - Opt_acl, Opt_noacl,
6036 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
6040 @@ -164,6 +164,9 @@ static const match_table_t tokens __init
6043 {Opt_noacl, "noacl"},
6045 + {Opt_notag, "notag"},
6046 + {Opt_tagid, "tagid=%u"},
6050 @@ -275,6 +278,20 @@ static int __init root_nfs_parse(char *n
6052 nfs_data.flags |= NFS_MOUNT_NOACL;
6054 +#ifndef CONFIG_TAGGING_NONE
6056 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6059 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
6062 +#ifdef CONFIG_PROPAGATE
6065 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6069 printk(KERN_WARNING "Root-NFS: unknown "
6071 diff -NurpP --minimal linux-2.6.36/fs/nfs/super.c linux-2.6.36-vs2.3.0.36.38/fs/nfs/super.c
6072 --- linux-2.6.36/fs/nfs/super.c 2010-10-21 13:07:50.000000000 +0200
6073 +++ linux-2.6.36-vs2.3.0.36.38/fs/nfs/super.c 2010-10-21 13:09:36.000000000 +0200
6075 #include <linux/nfs_xdr.h>
6076 #include <linux/magic.h>
6077 #include <linux/parser.h>
6078 +#include <linux/vs_tag.h>
6080 #include <asm/system.h>
6081 #include <asm/uaccess.h>
6082 @@ -617,6 +618,7 @@ static void nfs_show_mount_options(struc
6083 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
6084 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
6085 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
6086 + { NFS_MOUNT_TAGGED, ",tag", "" },
6089 const struct proc_nfs_info *nfs_infop;
6090 diff -NurpP --minimal linux-2.6.36/fs/nfsd/auth.c linux-2.6.36-vs2.3.0.36.38/fs/nfsd/auth.c
6091 --- linux-2.6.36/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
6092 +++ linux-2.6.36-vs2.3.0.36.38/fs/nfsd/auth.c 2010-10-21 13:09:36.000000000 +0200
6094 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
6096 #include <linux/sched.h>
6097 +#include <linux/vs_tag.h>
6101 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6103 new->fsuid = rqstp->rq_cred.cr_uid;
6104 new->fsgid = rqstp->rq_cred.cr_gid;
6105 + /* FIXME: this desperately needs a tag :)
6106 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6109 rqgi = rqstp->rq_cred.cr_group_info;
6111 diff -NurpP --minimal linux-2.6.36/fs/nfsd/nfs3xdr.c linux-2.6.36-vs2.3.0.36.38/fs/nfsd/nfs3xdr.c
6112 --- linux-2.6.36/fs/nfsd/nfs3xdr.c 2010-02-25 11:52:05.000000000 +0100
6113 +++ linux-2.6.36-vs2.3.0.36.38/fs/nfsd/nfs3xdr.c 2010-10-21 13:09:36.000000000 +0200
6117 #include <linux/namei.h>
6118 +#include <linux/vs_tag.h>
6122 @@ -95,6 +96,8 @@ static __be32 *
6123 decode_sattr3(__be32 *p, struct iattr *iap)
6131 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6134 iap->ia_valid |= ATTR_UID;
6135 - iap->ia_uid = ntohl(*p++);
6136 + uid = ntohl(*p++);
6139 iap->ia_valid |= ATTR_GID;
6140 - iap->ia_gid = ntohl(*p++);
6141 + gid = ntohl(*p++);
6143 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6144 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6145 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6149 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6150 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6151 *p++ = htonl((u32) stat->mode);
6152 *p++ = htonl((u32) stat->nlink);
6153 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6154 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6155 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6156 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6157 + stat->uid, stat->tag)));
6158 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6159 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6160 + stat->gid, stat->tag)));
6161 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6162 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6164 diff -NurpP --minimal linux-2.6.36/fs/nfsd/nfs4xdr.c linux-2.6.36-vs2.3.0.36.38/fs/nfsd/nfs4xdr.c
6165 --- linux-2.6.36/fs/nfsd/nfs4xdr.c 2010-10-21 13:07:50.000000000 +0200
6166 +++ linux-2.6.36-vs2.3.0.36.38/fs/nfsd/nfs4xdr.c 2010-10-21 13:09:36.000000000 +0200
6168 #include <linux/nfsd_idmap.h>
6169 #include <linux/nfs4_acl.h>
6170 #include <linux/sunrpc/svcauth_gss.h>
6171 +#include <linux/vs_tag.h>
6175 @@ -2057,14 +2058,18 @@ out_acl:
6176 WRITE32(stat.nlink);
6178 if (bmval1 & FATTR4_WORD1_OWNER) {
6179 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6180 + status = nfsd4_encode_user(rqstp,
6181 + TAGINO_UID(DX_TAG(dentry->d_inode),
6182 + stat.uid, stat.tag), &p, &buflen);
6183 if (status == nfserr_resource)
6188 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6189 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6190 + status = nfsd4_encode_group(rqstp,
6191 + TAGINO_GID(DX_TAG(dentry->d_inode),
6192 + stat.gid, stat.tag), &p, &buflen);
6193 if (status == nfserr_resource)
6196 diff -NurpP --minimal linux-2.6.36/fs/nfsd/nfsxdr.c linux-2.6.36-vs2.3.0.36.38/fs/nfsd/nfsxdr.c
6197 --- linux-2.6.36/fs/nfsd/nfsxdr.c 2010-02-25 11:52:05.000000000 +0100
6198 +++ linux-2.6.36-vs2.3.0.36.38/fs/nfsd/nfsxdr.c 2010-10-21 13:09:36.000000000 +0200
6203 +#include <linux/vs_tag.h>
6205 #define NFSDDBG_FACILITY NFSDDBG_XDR
6207 @@ -88,6 +89,8 @@ static __be32 *
6208 decode_sattr(__be32 *p, struct iattr *iap)
6216 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6218 if ((tmp = ntohl(*p++)) != (u32)-1) {
6219 iap->ia_valid |= ATTR_UID;
6220 - iap->ia_uid = tmp;
6223 if ((tmp = ntohl(*p++)) != (u32)-1) {
6224 iap->ia_valid |= ATTR_GID;
6225 - iap->ia_gid = tmp;
6228 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6229 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6230 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6231 if ((tmp = ntohl(*p++)) != (u32)-1) {
6232 iap->ia_valid |= ATTR_SIZE;
6234 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6235 *p++ = htonl(nfs_ftypes[type >> 12]);
6236 *p++ = htonl((u32) stat->mode);
6237 *p++ = htonl((u32) stat->nlink);
6238 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6239 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6240 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6241 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6242 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6243 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6245 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6246 *p++ = htonl(NFS_MAXPATHLEN);
6247 diff -NurpP --minimal linux-2.6.36/fs/ocfs2/dlmglue.c linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/dlmglue.c
6248 --- linux-2.6.36/fs/ocfs2/dlmglue.c 2010-10-21 13:07:50.000000000 +0200
6249 +++ linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/dlmglue.c 2010-10-21 13:09:36.000000000 +0200
6250 @@ -2114,6 +2114,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6251 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6252 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6253 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6254 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6255 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6256 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6257 lvb->lvb_iatime_packed =
6258 @@ -2168,6 +2169,7 @@ static void ocfs2_refresh_inode_from_lvb
6260 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6261 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6262 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6263 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6264 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6265 ocfs2_unpack_timespec(&inode->i_atime,
6266 diff -NurpP --minimal linux-2.6.36/fs/ocfs2/dlmglue.h linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/dlmglue.h
6267 --- linux-2.6.36/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
6268 +++ linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/dlmglue.h 2010-10-21 13:09:36.000000000 +0200
6269 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6272 __be32 lvb_igeneration;
6273 - __be32 lvb_reserved2;
6275 + __be16 lvb_reserved2;
6278 #define OCFS2_QINFO_LVB_VERSION 1
6279 diff -NurpP --minimal linux-2.6.36/fs/ocfs2/file.c linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/file.c
6280 --- linux-2.6.36/fs/ocfs2/file.c 2010-10-21 13:07:50.000000000 +0200
6281 +++ linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/file.c 2010-10-21 13:09:36.000000000 +0200
6282 @@ -1138,13 +1138,15 @@ int ocfs2_setattr(struct dentry *dentry,
6283 mlog(0, "uid change: %d\n", attr->ia_uid);
6284 if (attr->ia_valid & ATTR_GID)
6285 mlog(0, "gid change: %d\n", attr->ia_gid);
6286 + if (attr->ia_valid & ATTR_TAG)
6287 + mlog(0, "tag change: %d\n", attr->ia_tag);
6288 if (attr->ia_valid & ATTR_SIZE)
6289 mlog(0, "size change...\n");
6290 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6291 mlog(0, "time change...\n");
6293 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6294 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6295 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6296 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6297 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6299 diff -NurpP --minimal linux-2.6.36/fs/ocfs2/inode.c linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/inode.c
6300 --- linux-2.6.36/fs/ocfs2/inode.c 2010-10-21 13:07:50.000000000 +0200
6301 +++ linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/inode.c 2010-10-21 13:09:36.000000000 +0200
6303 #include <linux/highmem.h>
6304 #include <linux/pagemap.h>
6305 #include <linux/quotaops.h>
6306 +#include <linux/vs_tag.h>
6308 #include <asm/byteorder.h>
6310 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
6312 unsigned int flags = OCFS2_I(inode)->ip_attr;
6314 - inode->i_flags &= ~(S_IMMUTABLE |
6315 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6316 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6318 if (flags & OCFS2_IMMUTABLE_FL)
6319 inode->i_flags |= S_IMMUTABLE;
6320 + if (flags & OCFS2_IXUNLINK_FL)
6321 + inode->i_flags |= S_IXUNLINK;
6323 if (flags & OCFS2_SYNC_FL)
6324 inode->i_flags |= S_SYNC;
6325 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
6326 inode->i_flags |= S_NOATIME;
6327 if (flags & OCFS2_DIRSYNC_FL)
6328 inode->i_flags |= S_DIRSYNC;
6330 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6332 + if (flags & OCFS2_BARRIER_FL)
6333 + inode->i_vflags |= V_BARRIER;
6334 + if (flags & OCFS2_COW_FL)
6335 + inode->i_vflags |= V_COW;
6338 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6339 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6341 unsigned int flags = oi->vfs_inode.i_flags;
6342 + unsigned int vflags = oi->vfs_inode.i_vflags;
6344 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6345 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6346 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6347 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6349 + if (flags & S_IMMUTABLE)
6350 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6351 + if (flags & S_IXUNLINK)
6352 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6354 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6355 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6357 oi->ip_attr |= OCFS2_SYNC_FL;
6358 if (flags & S_APPEND)
6359 oi->ip_attr |= OCFS2_APPEND_FL;
6360 - if (flags & S_IMMUTABLE)
6361 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6362 if (flags & S_NOATIME)
6363 oi->ip_attr |= OCFS2_NOATIME_FL;
6364 if (flags & S_DIRSYNC)
6365 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6367 + if (vflags & V_BARRIER)
6368 + oi->ip_attr |= OCFS2_BARRIER_FL;
6369 + if (vflags & V_COW)
6370 + oi->ip_attr |= OCFS2_COW_FL;
6373 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
6374 @@ -245,6 +267,8 @@ void ocfs2_populate_inode(struct inode *
6375 struct super_block *sb;
6376 struct ocfs2_super *osb;
6381 mlog_entry("(0x%p, size:%llu)\n", inode,
6382 (unsigned long long)le64_to_cpu(fe->i_size));
6383 @@ -276,8 +300,12 @@ void ocfs2_populate_inode(struct inode *
6384 inode->i_generation = le32_to_cpu(fe->i_generation);
6385 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6386 inode->i_mode = le16_to_cpu(fe->i_mode);
6387 - inode->i_uid = le32_to_cpu(fe->i_uid);
6388 - inode->i_gid = le32_to_cpu(fe->i_gid);
6389 + uid = le32_to_cpu(fe->i_uid);
6390 + gid = le32_to_cpu(fe->i_gid);
6391 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6392 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6393 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6394 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6396 /* Fast symlinks will have i_size but no allocated clusters. */
6397 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6398 diff -NurpP --minimal linux-2.6.36/fs/ocfs2/inode.h linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/inode.h
6399 --- linux-2.6.36/fs/ocfs2/inode.h 2010-10-21 13:07:50.000000000 +0200
6400 +++ linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/inode.h 2010-10-21 13:09:36.000000000 +0200
6401 @@ -153,6 +153,7 @@ struct buffer_head *ocfs2_bread(struct i
6403 void ocfs2_set_inode_flags(struct inode *inode);
6404 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6405 +int ocfs2_sync_flags(struct inode *inode, int, int);
6407 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6409 diff -NurpP --minimal linux-2.6.36/fs/ocfs2/ioctl.c linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/ioctl.c
6410 --- linux-2.6.36/fs/ocfs2/ioctl.c 2010-02-25 11:52:06.000000000 +0100
6411 +++ linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/ioctl.c 2010-10-21 13:09:36.000000000 +0200
6412 @@ -43,7 +43,41 @@ static int ocfs2_get_inode_attr(struct i
6416 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6417 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6419 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6420 + struct buffer_head *bh = NULL;
6421 + handle_t *handle = NULL;
6424 + status = ocfs2_inode_lock(inode, &bh, 1);
6426 + mlog_errno(status);
6429 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6430 + if (IS_ERR(handle)) {
6431 + status = PTR_ERR(handle);
6432 + mlog_errno(status);
6436 + inode->i_flags = flags;
6437 + inode->i_vflags = vflags;
6438 + ocfs2_get_inode_flags(OCFS2_I(inode));
6440 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6442 + mlog_errno(status);
6444 + ocfs2_commit_trans(osb, handle);
6446 + ocfs2_inode_unlock(inode, 1);
6451 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6454 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6455 @@ -68,6 +102,11 @@ static int ocfs2_set_inode_attr(struct i
6456 if (!S_ISDIR(inode->i_mode))
6457 flags &= ~OCFS2_DIRSYNC_FL;
6459 + if (IS_BARRIER(inode)) {
6460 + vxwprintk_task(1, "messing with the barrier.");
6464 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6465 if (IS_ERR(handle)) {
6466 status = PTR_ERR(handle);
6467 @@ -109,6 +148,7 @@ bail:
6472 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6474 struct inode *inode = filp->f_path.dentry->d_inode;
6475 diff -NurpP --minimal linux-2.6.36/fs/ocfs2/namei.c linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/namei.c
6476 --- linux-2.6.36/fs/ocfs2/namei.c 2010-10-21 13:07:50.000000000 +0200
6477 +++ linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/namei.c 2010-10-21 13:09:36.000000000 +0200
6479 #include <linux/slab.h>
6480 #include <linux/highmem.h>
6481 #include <linux/quotaops.h>
6482 +#include <linux/vs_tag.h>
6484 #define MLOG_MASK_PREFIX ML_NAMEI
6485 #include <cluster/masklog.h>
6486 @@ -486,6 +487,7 @@ static int __ocfs2_mknod_locked(struct i
6487 struct ocfs2_dinode *fe = NULL;
6488 struct ocfs2_extent_list *fel;
6494 @@ -523,8 +525,11 @@ static int __ocfs2_mknod_locked(struct i
6495 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
6496 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6497 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6498 - fe->i_uid = cpu_to_le32(inode->i_uid);
6499 - fe->i_gid = cpu_to_le32(inode->i_gid);
6501 + tag = dx_current_fstag(osb->sb);
6502 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6503 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6504 + inode->i_tag = tag;
6505 fe->i_mode = cpu_to_le16(inode->i_mode);
6506 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6507 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6508 diff -NurpP --minimal linux-2.6.36/fs/ocfs2/ocfs2.h linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/ocfs2.h
6509 --- linux-2.6.36/fs/ocfs2/ocfs2.h 2010-08-02 16:52:51.000000000 +0200
6510 +++ linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/ocfs2.h 2010-10-21 13:09:36.000000000 +0200
6511 @@ -256,6 +256,7 @@ enum ocfs2_mount_options
6513 OCFS2_MOUNT_USRQUOTA = 1 << 10, /* We support user quotas */
6514 OCFS2_MOUNT_GRPQUOTA = 1 << 11, /* We support group quotas */
6515 + OCFS2_MOUNT_TAGGED = 1 << 12, /* use tagging */
6518 #define OCFS2_OSB_SOFT_RO 0x0001
6519 diff -NurpP --minimal linux-2.6.36/fs/ocfs2/ocfs2_fs.h linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/ocfs2_fs.h
6520 --- linux-2.6.36/fs/ocfs2/ocfs2_fs.h 2010-10-21 13:07:51.000000000 +0200
6521 +++ linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/ocfs2_fs.h 2010-10-21 14:00:41.000000000 +0200
6522 @@ -258,6 +258,11 @@
6523 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
6524 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
6526 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6528 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6529 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6531 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
6532 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
6534 diff -NurpP --minimal linux-2.6.36/fs/ocfs2/super.c linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/super.c
6535 --- linux-2.6.36/fs/ocfs2/super.c 2010-10-21 13:07:51.000000000 +0200
6536 +++ linux-2.6.36-vs2.3.0.36.38/fs/ocfs2/super.c 2010-10-21 13:09:36.000000000 +0200
6537 @@ -179,6 +179,7 @@ enum {
6541 + Opt_tag, Opt_notag, Opt_tagid,
6545 @@ -207,6 +208,9 @@ static const match_table_t tokens = {
6546 {Opt_grpquota, "grpquota"},
6547 {Opt_resv_level, "resv_level=%u"},
6548 {Opt_dir_resv_level, "dir_resv_level=%u"},
6550 + {Opt_notag, "notag"},
6551 + {Opt_tagid, "tagid=%u"},
6555 @@ -617,6 +621,13 @@ static int ocfs2_remount(struct super_bl
6559 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6560 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6562 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6566 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6567 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6569 @@ -1153,6 +1164,9 @@ static int ocfs2_fill_super(struct super
6571 ocfs2_complete_mount_recovery(osb);
6573 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6574 + sb->s_flags |= MS_TAGGED;
6576 if (ocfs2_mount_local(osb))
6577 snprintf(nodestr, sizeof(nodestr), "local");
6579 @@ -1468,6 +1482,20 @@ static int ocfs2_parse_options(struct su
6580 option < OCFS2_MAX_RESV_LEVEL)
6581 mopt->dir_resv_level = option;
6583 +#ifndef CONFIG_TAGGING_NONE
6585 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6588 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6591 +#ifdef CONFIG_PROPAGATE
6594 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6599 "Unrecognized mount option \"%s\" "
6600 diff -NurpP --minimal linux-2.6.36/fs/open.c linux-2.6.36-vs2.3.0.36.38/fs/open.c
6601 --- linux-2.6.36/fs/open.c 2010-10-21 13:07:51.000000000 +0200
6602 +++ linux-2.6.36-vs2.3.0.36.38/fs/open.c 2010-10-21 13:55:41.000000000 +0200
6604 #include <linux/fs_struct.h>
6605 #include <linux/ima.h>
6606 #include <linux/dnotify.h>
6607 +#include <linux/vs_base.h>
6608 +#include <linux/vs_limit.h>
6609 +#include <linux/vs_tag.h>
6610 +#include <linux/vs_cowbl.h>
6611 +#include <linux/vserver/dlimit.h>
6613 #include "internal.h"
6615 @@ -481,6 +486,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6616 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6620 +#ifdef CONFIG_VSERVER_COWBL
6621 + error = cow_check_and_break(&path);
6623 + goto dput_and_out;
6625 inode = path.dentry->d_inode;
6627 error = mnt_want_write(path.mnt);
6628 @@ -518,11 +529,11 @@ static int chown_common(struct path *pat
6629 newattrs.ia_valid = ATTR_CTIME;
6630 if (user != (uid_t) -1) {
6631 newattrs.ia_valid |= ATTR_UID;
6632 - newattrs.ia_uid = user;
6633 + newattrs.ia_uid = dx_map_uid(user);
6635 if (group != (gid_t) -1) {
6636 newattrs.ia_valid |= ATTR_GID;
6637 - newattrs.ia_gid = group;
6638 + newattrs.ia_gid = dx_map_gid(group);
6640 if (!S_ISDIR(inode->i_mode))
6641 newattrs.ia_valid |=
6642 @@ -547,6 +558,10 @@ SYSCALL_DEFINE3(chown, const char __user
6643 error = mnt_want_write(path.mnt);
6646 +#ifdef CONFIG_VSERVER_COWBL
6647 + error = cow_check_and_break(&path);
6650 error = chown_common(&path, user, group);
6651 mnt_drop_write(path.mnt);
6653 @@ -572,6 +587,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6654 error = mnt_want_write(path.mnt);
6657 +#ifdef CONFIG_VSERVER_COWBL
6658 + error = cow_check_and_break(&path);
6661 error = chown_common(&path, user, group);
6662 mnt_drop_write(path.mnt);
6664 @@ -591,6 +610,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6665 error = mnt_want_write(path.mnt);
6668 +#ifdef CONFIG_VSERVER_COWBL
6669 + error = cow_check_and_break(&path);
6672 error = chown_common(&path, user, group);
6673 mnt_drop_write(path.mnt);
6675 @@ -837,6 +860,7 @@ static void __put_unused_fd(struct files
6676 __FD_CLR(fd, fdt->open_fds);
6677 if (fd < files->next_fd)
6678 files->next_fd = fd;
6679 + vx_openfd_dec(fd);
6682 void put_unused_fd(unsigned int fd)
6683 diff -NurpP --minimal linux-2.6.36/fs/proc/array.c linux-2.6.36-vs2.3.0.36.38/fs/proc/array.c
6684 --- linux-2.6.36/fs/proc/array.c 2010-08-02 16:52:51.000000000 +0200
6685 +++ linux-2.6.36-vs2.3.0.36.38/fs/proc/array.c 2010-10-21 13:09:36.000000000 +0200
6687 #include <linux/pid_namespace.h>
6688 #include <linux/ptrace.h>
6689 #include <linux/tracehook.h>
6690 +#include <linux/vs_context.h>
6691 +#include <linux/vs_network.h>
6693 #include <asm/pgtable.h>
6694 #include <asm/processor.h>
6695 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
6697 ppid = pid_alive(p) ?
6698 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6699 + if (unlikely(vx_current_initpid(p->pid)))
6704 struct task_struct *tracer = tracehook_tracer_task(p);
6705 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6708 static void render_cap_t(struct seq_file *m, const char *header,
6710 + struct vx_info *vxi, kernel_cap_t *a)
6714 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6715 cap_bset = cred->cap_bset;
6718 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6719 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6720 - render_cap_t(m, "CapEff:\t", &cap_effective);
6721 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6722 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6723 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6724 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6725 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6726 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6729 static inline void task_context_switch_counts(struct seq_file *m,
6730 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6731 seq_printf(m, "\n");
6734 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6735 + struct pid *pid, struct task_struct *task)
6737 + seq_printf(m, "Proxy:\t%p(%c)\n"
6745 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6746 + atomic_read(&task->nsproxy->count),
6747 + task->nsproxy->uts_ns,
6748 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6749 + task->nsproxy->ipc_ns,
6750 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6751 + task->nsproxy->mnt_ns,
6752 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6753 + task->nsproxy->pid_ns,
6754 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6755 + task->nsproxy->net_ns,
6756 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6760 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6762 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6765 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6766 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6770 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6771 struct pid *pid, struct task_struct *task)
6773 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6775 task_cpus_allowed(m, task);
6776 cpuset_task_status_allowed(m, task);
6777 + task_vs_id(m, task);
6778 #if defined(CONFIG_S390)
6779 task_show_regs(m, task);
6781 @@ -465,6 +508,17 @@ static int do_task_stat(struct seq_file
6782 /* convert nsec -> ticks */
6783 start_time = nsec_to_clock_t(start_time);
6785 + /* fixup start time for virt uptime */
6786 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6787 + unsigned long long bias =
6788 + current->vx_info->cvirt.bias_clock;
6790 + if (start_time > bias)
6791 + start_time -= bias;
6796 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6797 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6798 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6799 diff -NurpP --minimal linux-2.6.36/fs/proc/base.c linux-2.6.36-vs2.3.0.36.38/fs/proc/base.c
6800 --- linux-2.6.36/fs/proc/base.c 2010-10-21 13:07:51.000000000 +0200
6801 +++ linux-2.6.36-vs2.3.0.36.38/fs/proc/base.c 2010-10-21 13:58:32.000000000 +0200
6803 #include <linux/pid_namespace.h>
6804 #include <linux/fs_struct.h>
6805 #include <linux/slab.h>
6806 +#include <linux/vs_context.h>
6807 +#include <linux/vs_network.h>
6808 #include "internal.h"
6811 @@ -1041,12 +1043,17 @@ static ssize_t oom_adjust_write(struct f
6815 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6816 + if (oom_adjust < task->signal->oom_adj &&
6817 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6818 unlock_task_sighand(task, &flags);
6819 put_task_struct(task);
6823 + /* prevent guest processes from circumventing the oom killer */
6824 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6825 + oom_adjust = OOM_ADJUST_MIN;
6828 * Warn that /proc/pid/oom_adj is deprecated, see
6829 * Documentation/feature-removal-schedule.txt.
6830 @@ -1179,7 +1186,7 @@ static ssize_t proc_loginuid_write(struc
6834 - if (!capable(CAP_AUDIT_CONTROL))
6835 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6839 @@ -1617,6 +1624,8 @@ static struct inode *proc_pid_make_inode
6840 inode->i_gid = cred->egid;
6843 + /* procfs is xid tagged */
6844 + inode->i_tag = (tag_t)vx_task_xid(task);
6845 security_task_to_inode(task, inode);
6848 @@ -2167,6 +2176,13 @@ static struct dentry *proc_pident_lookup
6852 + /* TODO: maybe we can come up with a generic approach? */
6853 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6854 + (dentry->d_name.len == 5) &&
6855 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6856 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6860 * Yes, it does not scale. And it should not. Don't add
6861 * new entries into /proc/<tgid>/ without very good reasons.
6862 @@ -2574,7 +2590,7 @@ out_iput:
6863 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6865 struct dentry *error;
6866 - struct task_struct *task = get_proc_task(dir);
6867 + struct task_struct *task = get_proc_task_real(dir);
6868 const struct pid_entry *p, *last;
6870 error = ERR_PTR(-ENOENT);
6871 @@ -2664,6 +2680,9 @@ static int proc_pid_personality(struct s
6872 static const struct file_operations proc_task_operations;
6873 static const struct inode_operations proc_task_inode_operations;
6875 +extern int proc_pid_vx_info(struct task_struct *, char *);
6876 +extern int proc_pid_nx_info(struct task_struct *, char *);
6878 static const struct pid_entry tgid_base_stuff[] = {
6879 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6880 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6881 @@ -2723,6 +2742,8 @@ static const struct pid_entry tgid_base_
6882 #ifdef CONFIG_CGROUPS
6883 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6885 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6886 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6887 INF("oom_score", S_IRUGO, proc_oom_score),
6888 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6889 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6890 @@ -2739,6 +2760,7 @@ static const struct pid_entry tgid_base_
6891 #ifdef CONFIG_TASK_IO_ACCOUNTING
6892 INF("io", S_IRUGO, proc_tgid_io_accounting),
6894 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6897 static int proc_tgid_base_readdir(struct file * filp,
6898 @@ -2930,7 +2952,7 @@ retry:
6900 pid = find_ge_pid(iter.tgid, ns);
6902 - iter.tgid = pid_nr_ns(pid, ns);
6903 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6904 iter.task = pid_task(pid, PIDTYPE_PID);
6905 /* What we to know is if the pid we have find is the
6906 * pid of a thread_group_leader. Testing for task
6907 @@ -2960,7 +2982,7 @@ static int proc_pid_fill_cache(struct fi
6908 struct tgid_iter iter)
6910 char name[PROC_NUMBUF];
6911 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6912 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6913 return proc_fill_cache(filp, dirent, filldir, name, len,
6914 proc_pid_instantiate, iter.task, NULL);
6916 @@ -2969,7 +2991,7 @@ static int proc_pid_fill_cache(struct fi
6917 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
6919 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6920 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
6921 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6922 struct tgid_iter iter;
6923 struct pid_namespace *ns;
6925 @@ -2989,6 +3011,8 @@ int proc_pid_readdir(struct file * filp,
6927 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6928 filp->f_pos = iter.tgid + TGID_OFFSET;
6929 + if (!vx_proc_task_visible(iter.task))
6931 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6932 put_task_struct(iter.task);
6934 @@ -3137,6 +3161,8 @@ static struct dentry *proc_task_lookup(s
6935 tid = name_to_int(dentry);
6938 + if (vx_current_initpid(tid))
6941 ns = dentry->d_sb->s_fs_info;
6943 diff -NurpP --minimal linux-2.6.36/fs/proc/generic.c linux-2.6.36-vs2.3.0.36.38/fs/proc/generic.c
6944 --- linux-2.6.36/fs/proc/generic.c 2010-10-21 13:07:51.000000000 +0200
6945 +++ linux-2.6.36-vs2.3.0.36.38/fs/proc/generic.c 2010-10-21 21:43:28.000000000 +0200
6947 #include <linux/bitops.h>
6948 #include <linux/spinlock.h>
6949 #include <linux/completion.h>
6950 +#include <linux/vserver/inode.h>
6951 #include <asm/uaccess.h>
6953 #include "internal.h"
6954 @@ -424,6 +425,8 @@ struct dentry *proc_lookup_de(struct pro
6955 for (de = de->subdir; de ; de = de->next) {
6956 if (de->namelen != dentry->d_name.len)
6958 + if (!vx_hide_check(0, de->vx_flags))
6960 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6963 @@ -432,6 +435,8 @@ struct dentry *proc_lookup_de(struct pro
6964 spin_unlock(&proc_subdir_lock);
6966 inode = proc_get_inode(dir->i_sb, ino, de);
6967 + /* generic proc entries belong to the host */
6972 @@ -509,6 +514,8 @@ int proc_readdir_de(struct proc_dir_entr
6974 /* filldir passes info to user space */
6976 + if (!vx_hide_check(0, de->vx_flags))
6978 spin_unlock(&proc_subdir_lock);
6979 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6980 de->low_ino, de->mode >> 12) < 0) {
6981 @@ -516,6 +523,7 @@ int proc_readdir_de(struct proc_dir_entr
6984 spin_lock(&proc_subdir_lock);
6989 @@ -630,6 +638,7 @@ static struct proc_dir_entry *__proc_cre
6991 atomic_set(&ent->count, 1);
6993 + ent->vx_flags = IATTR_PROC_DEFAULT;
6994 spin_lock_init(&ent->pde_unload_lock);
6995 ent->pde_unload_completion = NULL;
6996 INIT_LIST_HEAD(&ent->pde_openers);
6997 @@ -653,7 +662,8 @@ struct proc_dir_entry *proc_symlink(cons
7003 + ent->vx_flags = IATTR_PROC_SYMLINK;
7007 diff -NurpP --minimal linux-2.6.36/fs/proc/inode.c linux-2.6.36-vs2.3.0.36.38/fs/proc/inode.c
7008 --- linux-2.6.36/fs/proc/inode.c 2010-10-21 13:07:51.000000000 +0200
7009 +++ linux-2.6.36-vs2.3.0.36.38/fs/proc/inode.c 2010-10-21 13:09:36.000000000 +0200
7010 @@ -428,6 +428,8 @@ struct inode *proc_get_inode(struct supe
7011 inode->i_uid = de->uid;
7012 inode->i_gid = de->gid;
7015 + PROC_I(inode)->vx_flags = de->vx_flags;
7017 inode->i_size = de->size;
7019 diff -NurpP --minimal linux-2.6.36/fs/proc/internal.h linux-2.6.36-vs2.3.0.36.38/fs/proc/internal.h
7020 --- linux-2.6.36/fs/proc/internal.h 2010-02-25 11:52:06.000000000 +0100
7021 +++ linux-2.6.36-vs2.3.0.36.38/fs/proc/internal.h 2010-10-21 13:09:36.000000000 +0200
7025 #include <linux/proc_fs.h>
7026 +#include <linux/vs_pid.h>
7028 extern struct proc_dir_entry proc_root;
7029 #ifdef CONFIG_PROC_SYSCTL
7030 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
7031 struct pid *pid, struct task_struct *task);
7032 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7033 struct pid *pid, struct task_struct *task);
7034 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7035 + struct pid *pid, struct task_struct *task);
7037 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7039 extern const struct file_operations proc_maps_operations;
7040 @@ -68,11 +72,16 @@ static inline struct pid *proc_pid(struc
7041 return PROC_I(inode)->pid;
7044 -static inline struct task_struct *get_proc_task(struct inode *inode)
7045 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7047 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7050 +static inline struct task_struct *get_proc_task(struct inode *inode)
7052 + return vx_get_proc_task(inode, proc_pid(inode));
7055 static inline int proc_fd(struct inode *inode)
7057 return PROC_I(inode)->fd;
7058 diff -NurpP --minimal linux-2.6.36/fs/proc/loadavg.c linux-2.6.36-vs2.3.0.36.38/fs/proc/loadavg.c
7059 --- linux-2.6.36/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
7060 +++ linux-2.6.36-vs2.3.0.36.38/fs/proc/loadavg.c 2010-10-21 13:09:36.000000000 +0200
7063 static int loadavg_proc_show(struct seq_file *m, void *v)
7065 + unsigned long running;
7066 + unsigned int threads;
7067 unsigned long avnrun[3];
7069 get_avenrun(avnrun, FIXED_1/200, 0);
7071 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7072 + struct vx_info *vxi = current_vx_info();
7074 + running = atomic_read(&vxi->cvirt.nr_running);
7075 + threads = atomic_read(&vxi->cvirt.nr_threads);
7077 + running = nr_running();
7078 + threads = nr_threads;
7081 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
7082 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
7083 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
7084 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
7085 - nr_running(), nr_threads,
7087 task_active_pid_ns(current)->last_pid);
7090 diff -NurpP --minimal linux-2.6.36/fs/proc/meminfo.c linux-2.6.36-vs2.3.0.36.38/fs/proc/meminfo.c
7091 --- linux-2.6.36/fs/proc/meminfo.c 2009-12-03 20:02:53.000000000 +0100
7092 +++ linux-2.6.36-vs2.3.0.36.38/fs/proc/meminfo.c 2010-10-21 13:09:36.000000000 +0200
7093 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
7094 allowed = ((totalram_pages - hugetlb_total_pages())
7095 * sysctl_overcommit_ratio / 100) + total_swap_pages;
7097 - cached = global_page_state(NR_FILE_PAGES) -
7098 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
7099 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
7100 total_swapcache_pages - i.bufferram;
7103 diff -NurpP --minimal linux-2.6.36/fs/proc/root.c linux-2.6.36-vs2.3.0.36.38/fs/proc/root.c
7104 --- linux-2.6.36/fs/proc/root.c 2010-08-02 16:52:51.000000000 +0200
7105 +++ linux-2.6.36-vs2.3.0.36.38/fs/proc/root.c 2010-10-21 13:09:36.000000000 +0200
7107 #include <linux/bitops.h>
7108 #include <linux/mount.h>
7109 #include <linux/pid_namespace.h>
7110 +#include <linux/vserver/inode.h>
7112 #include "internal.h"
7114 +struct proc_dir_entry *proc_virtual;
7116 +extern void proc_vx_init(void);
7118 static int proc_test_super(struct super_block *sb, void *data)
7120 return sb->s_fs_info == data;
7121 @@ -135,6 +140,7 @@ void __init proc_root_init(void)
7123 proc_mkdir("bus", NULL);
7128 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7129 @@ -202,6 +208,7 @@ struct proc_dir_entry proc_root = {
7130 .proc_iops = &proc_root_inode_operations,
7131 .proc_fops = &proc_root_operations,
7132 .parent = &proc_root,
7133 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7136 int pid_ns_prepare_proc(struct pid_namespace *ns)
7137 diff -NurpP --minimal linux-2.6.36/fs/proc/uptime.c linux-2.6.36-vs2.3.0.36.38/fs/proc/uptime.c
7138 --- linux-2.6.36/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
7139 +++ linux-2.6.36-vs2.3.0.36.38/fs/proc/uptime.c 2010-10-21 13:09:36.000000000 +0200
7141 #include <linux/sched.h>
7142 #include <linux/seq_file.h>
7143 #include <linux/time.h>
7144 -#include <linux/kernel_stat.h>
7145 +#include <linux/vserver/cvirt.h>
7146 #include <asm/cputime.h>
7148 static int uptime_proc_show(struct seq_file *m, void *v)
7150 struct timespec uptime;
7151 struct timespec idle;
7153 - cputime_t idletime = cputime_zero;
7155 - for_each_possible_cpu(i)
7156 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
7157 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
7159 do_posix_clock_monotonic_gettime(&uptime);
7160 monotonic_to_bootbased(&uptime);
7161 cputime_to_timespec(idletime, &idle);
7163 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7164 + vx_vsi_uptime(&uptime, &idle);
7166 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
7167 (unsigned long) uptime.tv_sec,
7168 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7169 diff -NurpP --minimal linux-2.6.36/fs/quota/dquot.c linux-2.6.36-vs2.3.0.36.38/fs/quota/dquot.c
7170 --- linux-2.6.36/fs/quota/dquot.c 2010-10-21 13:07:51.000000000 +0200
7171 +++ linux-2.6.36-vs2.3.0.36.38/fs/quota/dquot.c 2010-10-21 13:09:36.000000000 +0200
7172 @@ -1538,6 +1538,9 @@ int __dquot_alloc_space(struct inode *in
7173 int reserve = flags & DQUOT_SPACE_RESERVE;
7174 int nofail = flags & DQUOT_SPACE_NOFAIL;
7176 + if ((ret = dl_alloc_space(inode, number)))
7180 * First test before acquiring mutex - solves deadlocks when we
7181 * re-enter the quota code and are already holding the mutex
7182 @@ -1592,6 +1595,9 @@ int dquot_alloc_inode(const struct inode
7184 char warntype[MAXQUOTAS];
7186 + if ((ret = dl_alloc_inode(inode)))
7189 /* First test before acquiring mutex - solves deadlocks when we
7190 * re-enter the quota code and are already holding the mutex */
7191 if (!dquot_active(inode))
7192 @@ -1662,6 +1668,8 @@ void __dquot_free_space(struct inode *in
7193 char warntype[MAXQUOTAS];
7194 int reserve = flags & DQUOT_SPACE_RESERVE;
7196 + dl_free_space(inode, number);
7198 /* First test before acquiring mutex - solves deadlocks when we
7199 * re-enter the quota code and are already holding the mutex */
7200 if (!dquot_active(inode)) {
7201 @@ -1700,6 +1708,8 @@ void dquot_free_inode(const struct inode
7203 char warntype[MAXQUOTAS];
7205 + dl_free_inode(inode);
7207 /* First test before acquiring mutex - solves deadlocks when we
7208 * re-enter the quota code and are already holding the mutex */
7209 if (!dquot_active(inode))
7210 diff -NurpP --minimal linux-2.6.36/fs/quota/quota.c linux-2.6.36-vs2.3.0.36.38/fs/quota/quota.c
7211 --- linux-2.6.36/fs/quota/quota.c 2010-08-02 16:52:51.000000000 +0200
7212 +++ linux-2.6.36-vs2.3.0.36.38/fs/quota/quota.c 2010-10-21 13:09:36.000000000 +0200
7214 #include <linux/fs.h>
7215 #include <linux/namei.h>
7216 #include <linux/slab.h>
7217 +#include <linux/vs_context.h>
7218 #include <asm/current.h>
7219 #include <asm/uaccess.h>
7220 #include <linux/kernel.h>
7221 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
7225 - if (!capable(CAP_SYS_ADMIN))
7226 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7230 @@ -296,6 +297,46 @@ static int do_quotactl(struct super_bloc
7234 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7236 +#include <linux/vroot.h>
7237 +#include <linux/major.h>
7238 +#include <linux/module.h>
7239 +#include <linux/kallsyms.h>
7240 +#include <linux/vserver/debug.h>
7242 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7244 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7246 +int register_vroot_grb(vroot_grb_func *func) {
7249 + spin_lock(&vroot_grb_lock);
7250 + if (!vroot_get_real_bdev) {
7251 + vroot_get_real_bdev = func;
7254 + spin_unlock(&vroot_grb_lock);
7257 +EXPORT_SYMBOL(register_vroot_grb);
7259 +int unregister_vroot_grb(vroot_grb_func *func) {
7260 + int ret = -EINVAL;
7262 + spin_lock(&vroot_grb_lock);
7263 + if (vroot_get_real_bdev) {
7264 + vroot_get_real_bdev = NULL;
7267 + spin_unlock(&vroot_grb_lock);
7270 +EXPORT_SYMBOL(unregister_vroot_grb);
7275 * look up a superblock on which quota ops will be performed
7276 * - use the name of a block device to find the superblock thereon
7277 @@ -313,6 +354,22 @@ static struct super_block *quotactl_bloc
7280 return ERR_CAST(bdev);
7281 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7282 + if (bdev && bdev->bd_inode &&
7283 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7284 + struct block_device *bdnew = (void *)-EINVAL;
7286 + if (vroot_get_real_bdev)
7287 + bdnew = vroot_get_real_bdev(bdev);
7289 + vxdprintk(VXD_CBIT(misc, 0),
7290 + "vroot_get_real_bdev not set");
7292 + if (IS_ERR(bdnew))
7293 + return ERR_PTR(PTR_ERR(bdnew));
7297 sb = get_super(bdev);
7300 diff -NurpP --minimal linux-2.6.36/fs/reiserfs/file.c linux-2.6.36-vs2.3.0.36.38/fs/reiserfs/file.c
7301 --- linux-2.6.36/fs/reiserfs/file.c 2010-10-21 13:07:51.000000000 +0200
7302 +++ linux-2.6.36-vs2.3.0.36.38/fs/reiserfs/file.c 2010-10-21 13:09:36.000000000 +0200
7303 @@ -313,4 +313,5 @@ const struct inode_operations reiserfs_f
7304 .listxattr = reiserfs_listxattr,
7305 .removexattr = reiserfs_removexattr,
7306 .permission = reiserfs_permission,
7307 + .sync_flags = reiserfs_sync_flags,
7309 diff -NurpP --minimal linux-2.6.36/fs/reiserfs/inode.c linux-2.6.36-vs2.3.0.36.38/fs/reiserfs/inode.c
7310 --- linux-2.6.36/fs/reiserfs/inode.c 2010-10-21 13:07:51.000000000 +0200
7311 +++ linux-2.6.36-vs2.3.0.36.38/fs/reiserfs/inode.c 2010-10-21 13:59:16.000000000 +0200
7313 #include <linux/writeback.h>
7314 #include <linux/quotaops.h>
7315 #include <linux/swap.h>
7316 +#include <linux/vs_tag.h>
7318 int reiserfs_commit_write(struct file *f, struct page *page,
7319 unsigned from, unsigned to);
7320 @@ -1133,6 +1134,8 @@ static void init_inode(struct inode *ino
7321 struct buffer_head *bh;
7322 struct item_head *ih;
7326 //int version = ITEM_VERSION_1;
7328 bh = PATH_PLAST_BUFFER(path);
7329 @@ -1153,12 +1156,13 @@ static void init_inode(struct inode *ino
7330 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7331 unsigned long blocks;
7333 + uid = sd_v1_uid(sd);
7334 + gid = sd_v1_gid(sd);
7336 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7337 set_inode_sd_version(inode, STAT_DATA_V1);
7338 inode->i_mode = sd_v1_mode(sd);
7339 inode->i_nlink = sd_v1_nlink(sd);
7340 - inode->i_uid = sd_v1_uid(sd);
7341 - inode->i_gid = sd_v1_gid(sd);
7342 inode->i_size = sd_v1_size(sd);
7343 inode->i_atime.tv_sec = sd_v1_atime(sd);
7344 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7345 @@ -1200,11 +1204,12 @@ static void init_inode(struct inode *ino
7346 // (directories and symlinks)
7347 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7349 + uid = sd_v2_uid(sd);
7350 + gid = sd_v2_gid(sd);
7352 inode->i_mode = sd_v2_mode(sd);
7353 inode->i_nlink = sd_v2_nlink(sd);
7354 - inode->i_uid = sd_v2_uid(sd);
7355 inode->i_size = sd_v2_size(sd);
7356 - inode->i_gid = sd_v2_gid(sd);
7357 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7358 inode->i_atime.tv_sec = sd_v2_atime(sd);
7359 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7360 @@ -1234,6 +1239,10 @@ static void init_inode(struct inode *ino
7361 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7364 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7365 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7366 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7369 if (S_ISREG(inode->i_mode)) {
7370 inode->i_op = &reiserfs_file_inode_operations;
7371 @@ -1256,13 +1265,15 @@ static void init_inode(struct inode *ino
7372 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7374 struct stat_data *sd_v2 = (struct stat_data *)sd;
7375 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7376 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7379 + set_sd_v2_uid(sd_v2, uid);
7380 + set_sd_v2_gid(sd_v2, gid);
7381 set_sd_v2_mode(sd_v2, inode->i_mode);
7382 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7383 - set_sd_v2_uid(sd_v2, inode->i_uid);
7384 set_sd_v2_size(sd_v2, size);
7385 - set_sd_v2_gid(sd_v2, inode->i_gid);
7386 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7387 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7388 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7389 @@ -2861,14 +2872,19 @@ int reiserfs_commit_write(struct file *f
7390 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7392 if (reiserfs_attrs(inode->i_sb)) {
7393 - if (sd_attrs & REISERFS_SYNC_FL)
7394 - inode->i_flags |= S_SYNC;
7396 - inode->i_flags &= ~S_SYNC;
7397 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7398 inode->i_flags |= S_IMMUTABLE;
7400 inode->i_flags &= ~S_IMMUTABLE;
7401 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7402 + inode->i_flags |= S_IXUNLINK;
7404 + inode->i_flags &= ~S_IXUNLINK;
7406 + if (sd_attrs & REISERFS_SYNC_FL)
7407 + inode->i_flags |= S_SYNC;
7409 + inode->i_flags &= ~S_SYNC;
7410 if (sd_attrs & REISERFS_APPEND_FL)
7411 inode->i_flags |= S_APPEND;
7413 @@ -2881,6 +2897,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7414 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7416 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7418 + if (sd_attrs & REISERFS_BARRIER_FL)
7419 + inode->i_vflags |= V_BARRIER;
7421 + inode->i_vflags &= ~V_BARRIER;
7422 + if (sd_attrs & REISERFS_COW_FL)
7423 + inode->i_vflags |= V_COW;
7425 + inode->i_vflags &= ~V_COW;
7429 @@ -2891,6 +2916,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7430 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7432 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7433 + if (inode->i_flags & S_IXUNLINK)
7434 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7436 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7438 if (inode->i_flags & S_SYNC)
7439 *sd_attrs |= REISERFS_SYNC_FL;
7441 @@ -2903,6 +2933,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7442 *sd_attrs |= REISERFS_NOTAIL_FL;
7444 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7446 + if (inode->i_vflags & V_BARRIER)
7447 + *sd_attrs |= REISERFS_BARRIER_FL;
7449 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7450 + if (inode->i_vflags & V_COW)
7451 + *sd_attrs |= REISERFS_COW_FL;
7453 + *sd_attrs &= ~REISERFS_COW_FL;
7457 @@ -3146,7 +3185,8 @@ int reiserfs_setattr(struct dentry *dent
7460 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7461 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7462 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7463 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7464 struct reiserfs_transaction_handle th;
7467 @@ -3175,6 +3215,9 @@ int reiserfs_setattr(struct dentry *dent
7468 inode->i_uid = attr->ia_uid;
7469 if (attr->ia_valid & ATTR_GID)
7470 inode->i_gid = attr->ia_gid;
7471 + if ((attr->ia_valid & ATTR_TAG) &&
7473 + inode->i_tag = attr->ia_tag;
7474 mark_inode_dirty(inode);
7475 error = journal_end(&th, inode->i_sb, jbegin_count);
7477 diff -NurpP --minimal linux-2.6.36/fs/reiserfs/ioctl.c linux-2.6.36-vs2.3.0.36.38/fs/reiserfs/ioctl.c
7478 --- linux-2.6.36/fs/reiserfs/ioctl.c 2010-10-21 13:07:51.000000000 +0200
7479 +++ linux-2.6.36-vs2.3.0.36.38/fs/reiserfs/ioctl.c 2010-10-21 13:09:36.000000000 +0200
7481 #include <linux/mount.h>
7482 #include <linux/reiserfs_fs.h>
7483 #include <linux/time.h>
7484 +#include <linux/mount.h>
7485 #include <asm/uaccess.h>
7486 #include <linux/pagemap.h>
7487 #include <linux/smp_lock.h>
7488 #include <linux/compat.h>
7491 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7493 + __u16 sd_attrs = 0;
7495 + inode->i_flags = flags;
7496 + inode->i_vflags = vflags;
7498 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7499 + REISERFS_I(inode)->i_attrs = sd_attrs;
7500 + inode->i_ctime = CURRENT_TIME_SEC;
7501 + mark_inode_dirty(inode);
7506 * reiserfs_ioctl - handler for ioctl for inode
7507 * supported commands:
7509 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7511 struct inode *inode = filp->f_path.dentry->d_inode;
7512 - unsigned int flags;
7513 + unsigned int flags, oldflags;
7516 reiserfs_write_lock(inode->i_sb);
7517 @@ -48,6 +64,7 @@ long reiserfs_ioctl(struct file *filp, u
7519 flags = REISERFS_I(inode)->i_attrs;
7520 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7521 + flags &= REISERFS_FL_USER_VISIBLE;
7522 err = put_user(flags, (int __user *)arg);
7524 case REISERFS_IOC_SETFLAGS:{
7525 @@ -68,6 +85,10 @@ long reiserfs_ioctl(struct file *filp, u
7529 + if (IS_BARRIER(inode)) {
7530 + vxwprintk_task(1, "messing with the barrier.");
7534 * Is it quota file? Do not allow user to mess with it
7536 @@ -92,6 +113,10 @@ long reiserfs_ioctl(struct file *filp, u
7541 + oldflags = REISERFS_I(inode)->i_attrs;
7542 + flags &= REISERFS_FL_USER_MODIFIABLE;
7543 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7544 sd_attrs_to_i_attrs(flags, inode);
7545 REISERFS_I(inode)->i_attrs = flags;
7546 inode->i_ctime = CURRENT_TIME_SEC;
7547 diff -NurpP --minimal linux-2.6.36/fs/reiserfs/namei.c linux-2.6.36-vs2.3.0.36.38/fs/reiserfs/namei.c
7548 --- linux-2.6.36/fs/reiserfs/namei.c 2010-08-02 16:52:52.000000000 +0200
7549 +++ linux-2.6.36-vs2.3.0.36.38/fs/reiserfs/namei.c 2010-10-21 13:09:36.000000000 +0200
7551 #include <linux/reiserfs_acl.h>
7552 #include <linux/reiserfs_xattr.h>
7553 #include <linux/quotaops.h>
7554 +#include <linux/vs_tag.h>
7556 #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; }
7557 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7558 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7559 if (retval == IO_ERROR) {
7560 return ERR_PTR(-EIO);
7562 + dx_propagate_tag(nd, inode);
7564 return d_splice_alias(inode, dentry);
7566 @@ -1532,6 +1534,7 @@ const struct inode_operations reiserfs_d
7567 .listxattr = reiserfs_listxattr,
7568 .removexattr = reiserfs_removexattr,
7569 .permission = reiserfs_permission,
7570 + .sync_flags = reiserfs_sync_flags,
7574 diff -NurpP --minimal linux-2.6.36/fs/reiserfs/super.c linux-2.6.36-vs2.3.0.36.38/fs/reiserfs/super.c
7575 --- linux-2.6.36/fs/reiserfs/super.c 2010-10-21 13:07:51.000000000 +0200
7576 +++ linux-2.6.36-vs2.3.0.36.38/fs/reiserfs/super.c 2010-10-21 13:09:36.000000000 +0200
7577 @@ -893,6 +893,14 @@ static int reiserfs_parse_options(struct
7578 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7579 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7581 +#ifndef CONFIG_TAGGING_NONE
7582 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7583 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7584 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7586 +#ifdef CONFIG_PROPAGATE
7587 + {"tag",.arg_required = 'T',.values = NULL},
7589 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7590 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7591 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7592 @@ -1202,6 +1210,14 @@ static int reiserfs_remount(struct super
7593 handle_quota_files(s, qf_names, &qfmt);
7596 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7597 + !(s->s_flags & MS_TAGGED)) {
7598 + reiserfs_warning(s, "super-vs01",
7599 + "reiserfs: tagging not permitted on remount.");
7606 /* Add options that are safe here */
7607 @@ -1684,6 +1700,10 @@ static int reiserfs_fill_super(struct su
7611 + /* map mount option tagxid */
7612 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7613 + s->s_flags |= MS_TAGGED;
7615 rs = SB_DISK_SUPER_BLOCK(s);
7616 /* Let's do basic sanity check to verify that underlying device is not
7617 smaller than the filesystem. If the check fails then abort and scream,
7618 diff -NurpP --minimal linux-2.6.36/fs/reiserfs/xattr.c linux-2.6.36-vs2.3.0.36.38/fs/reiserfs/xattr.c
7619 --- linux-2.6.36/fs/reiserfs/xattr.c 2010-08-02 16:52:52.000000000 +0200
7620 +++ linux-2.6.36-vs2.3.0.36.38/fs/reiserfs/xattr.c 2010-10-21 13:09:36.000000000 +0200
7622 #include <linux/errno.h>
7623 #include <linux/gfp.h>
7624 #include <linux/fs.h>
7625 +#include <linux/mount.h>
7626 #include <linux/file.h>
7627 #include <linux/pagemap.h>
7628 #include <linux/xattr.h>
7629 diff -NurpP --minimal linux-2.6.36/fs/stat.c linux-2.6.36-vs2.3.0.36.38/fs/stat.c
7630 --- linux-2.6.36/fs/stat.c 2010-10-21 13:07:51.000000000 +0200
7631 +++ linux-2.6.36-vs2.3.0.36.38/fs/stat.c 2010-10-21 13:09:36.000000000 +0200
7632 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7633 stat->nlink = inode->i_nlink;
7634 stat->uid = inode->i_uid;
7635 stat->gid = inode->i_gid;
7636 + stat->tag = inode->i_tag;
7637 stat->rdev = inode->i_rdev;
7638 stat->atime = inode->i_atime;
7639 stat->mtime = inode->i_mtime;
7640 diff -NurpP --minimal linux-2.6.36/fs/statfs.c linux-2.6.36-vs2.3.0.36.38/fs/statfs.c
7641 --- linux-2.6.36/fs/statfs.c 2010-10-21 13:07:51.000000000 +0200
7642 +++ linux-2.6.36-vs2.3.0.36.38/fs/statfs.c 2010-10-21 14:07:35.000000000 +0200
7644 #include <linux/statfs.h>
7645 #include <linux/security.h>
7646 #include <linux/uaccess.h>
7647 +#include <linux/vs_base.h>
7648 +#include <linux/vs_dlimit.h>
7650 static int flags_by_mnt(int mnt_flags)
7652 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
7653 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7654 if (retval == 0 && buf->f_frsize == 0)
7655 buf->f_frsize = buf->f_bsize;
7656 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7657 + vx_vsi_statfs(dentry->d_sb, buf);
7661 diff -NurpP --minimal linux-2.6.36/fs/super.c linux-2.6.36-vs2.3.0.36.38/fs/super.c
7662 --- linux-2.6.36/fs/super.c 2010-10-21 13:07:51.000000000 +0200
7663 +++ linux-2.6.36-vs2.3.0.36.38/fs/super.c 2010-10-21 13:09:36.000000000 +0200
7665 #include <linux/idr.h>
7666 #include <linux/mutex.h>
7667 #include <linux/backing-dev.h>
7668 +#include <linux/devpts_fs.h>
7669 +#include <linux/proc_fs.h>
7670 +#include <linux/vs_context.h>
7671 #include "internal.h"
7674 @@ -918,12 +921,18 @@ struct vfsmount *
7675 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
7677 struct vfsmount *mnt;
7678 + struct super_block *sb;
7679 char *secdata = NULL;
7683 return ERR_PTR(-ENODEV);
7686 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
7687 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
7691 mnt = alloc_vfsmnt(name);
7693 @@ -945,11 +954,19 @@ vfs_kern_mount(struct file_system_type *
7694 error = type->get_sb(type, flags, name, data, mnt);
7696 goto out_free_secdata;
7697 - BUG_ON(!mnt->mnt_sb);
7698 - WARN_ON(!mnt->mnt_sb->s_bdi);
7702 + WARN_ON(!sb->s_bdi);
7703 mnt->mnt_sb->s_flags |= MS_BORN;
7705 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
7707 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
7708 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7709 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7712 + error = security_sb_kern_mount(sb, flags, secdata);
7716 diff -NurpP --minimal linux-2.6.36/fs/sysfs/mount.c linux-2.6.36-vs2.3.0.36.38/fs/sysfs/mount.c
7717 --- linux-2.6.36/fs/sysfs/mount.c 2010-10-21 13:07:51.000000000 +0200
7718 +++ linux-2.6.36-vs2.3.0.36.38/fs/sysfs/mount.c 2010-10-21 13:09:36.000000000 +0200
7719 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7721 sb->s_blocksize = PAGE_CACHE_SIZE;
7722 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7723 - sb->s_magic = SYSFS_MAGIC;
7724 + sb->s_magic = SYSFS_SUPER_MAGIC;
7725 sb->s_op = &sysfs_ops;
7726 sb->s_time_gran = 1;
7728 diff -NurpP --minimal linux-2.6.36/fs/utimes.c linux-2.6.36-vs2.3.0.36.38/fs/utimes.c
7729 --- linux-2.6.36/fs/utimes.c 2010-10-21 13:07:51.000000000 +0200
7730 +++ linux-2.6.36-vs2.3.0.36.38/fs/utimes.c 2010-10-21 13:09:36.000000000 +0200
7732 #include <linux/stat.h>
7733 #include <linux/utime.h>
7734 #include <linux/syscalls.h>
7735 +#include <linux/mount.h>
7736 +#include <linux/vs_cowbl.h>
7737 #include <asm/uaccess.h>
7738 #include <asm/unistd.h>
7740 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7743 struct iattr newattrs;
7744 - struct inode *inode = path->dentry->d_inode;
7745 + struct inode *inode;
7747 error = mnt_want_write(path->mnt);
7751 + error = cow_check_and_break(path);
7753 + goto mnt_drop_write_and_out;
7755 + inode = path->dentry->d_inode;
7757 if (times && times[0].tv_nsec == UTIME_NOW &&
7758 times[1].tv_nsec == UTIME_NOW)
7760 diff -NurpP --minimal linux-2.6.36/fs/xattr.c linux-2.6.36-vs2.3.0.36.38/fs/xattr.c
7761 --- linux-2.6.36/fs/xattr.c 2010-08-02 16:52:52.000000000 +0200
7762 +++ linux-2.6.36-vs2.3.0.36.38/fs/xattr.c 2010-10-21 13:09:36.000000000 +0200
7764 #include <linux/module.h>
7765 #include <linux/fsnotify.h>
7766 #include <linux/audit.h>
7767 +#include <linux/mount.h>
7768 #include <asm/uaccess.h>
7771 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
7772 * The trusted.* namespace can only be accessed by a privileged user.
7774 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
7775 - return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
7776 + return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
7778 /* In user.* namespace, only regular files and directories can have
7779 * extended attributes. For sticky directories, only the owner and
7780 diff -NurpP --minimal linux-2.6.36/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.36-vs2.3.0.36.38/fs/xfs/linux-2.6/xfs_ioctl.c
7781 --- linux-2.6.36/fs/xfs/linux-2.6/xfs_ioctl.c 2010-10-21 13:07:51.000000000 +0200
7782 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/linux-2.6/xfs_ioctl.c 2010-10-21 14:02:37.000000000 +0200
7784 #include "xfs_bmap_btree.h"
7785 #include "xfs_dinode.h"
7786 #include "xfs_inode.h"
7787 -#include "xfs_ioctl.h"
7788 +// #include "xfs_ioctl.h"
7789 #include "xfs_rtalloc.h"
7790 #include "xfs_itable.h"
7791 #include "xfs_error.h"
7792 @@ -738,6 +738,10 @@ xfs_merge_ioc_xflags(
7793 xflags |= XFS_XFLAG_IMMUTABLE;
7795 xflags &= ~XFS_XFLAG_IMMUTABLE;
7796 + if (flags & FS_IXUNLINK_FL)
7797 + xflags |= XFS_XFLAG_IXUNLINK;
7799 + xflags &= ~XFS_XFLAG_IXUNLINK;
7800 if (flags & FS_APPEND_FL)
7801 xflags |= XFS_XFLAG_APPEND;
7803 @@ -766,6 +770,8 @@ xfs_di2lxflags(
7805 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7806 flags |= FS_IMMUTABLE_FL;
7807 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7808 + flags |= FS_IXUNLINK_FL;
7809 if (di_flags & XFS_DIFLAG_APPEND)
7810 flags |= FS_APPEND_FL;
7811 if (di_flags & XFS_DIFLAG_SYNC)
7812 @@ -826,6 +832,8 @@ xfs_set_diflags(
7813 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7814 if (xflags & XFS_XFLAG_IMMUTABLE)
7815 di_flags |= XFS_DIFLAG_IMMUTABLE;
7816 + if (xflags & XFS_XFLAG_IXUNLINK)
7817 + di_flags |= XFS_DIFLAG_IXUNLINK;
7818 if (xflags & XFS_XFLAG_APPEND)
7819 di_flags |= XFS_DIFLAG_APPEND;
7820 if (xflags & XFS_XFLAG_SYNC)
7821 @@ -868,6 +876,10 @@ xfs_diflags_to_linux(
7822 inode->i_flags |= S_IMMUTABLE;
7824 inode->i_flags &= ~S_IMMUTABLE;
7825 + if (xflags & XFS_XFLAG_IXUNLINK)
7826 + inode->i_flags |= S_IXUNLINK;
7828 + inode->i_flags &= ~S_IXUNLINK;
7829 if (xflags & XFS_XFLAG_APPEND)
7830 inode->i_flags |= S_APPEND;
7832 @@ -1341,10 +1353,18 @@ xfs_file_ioctl(
7833 case XFS_IOC_FSGETXATTRA:
7834 return xfs_ioc_fsgetxattr(ip, 1, arg);
7835 case XFS_IOC_FSSETXATTR:
7836 + if (IS_BARRIER(inode)) {
7837 + vxwprintk_task(1, "messing with the barrier.");
7838 + return -XFS_ERROR(EACCES);
7840 return xfs_ioc_fssetxattr(ip, filp, arg);
7841 case XFS_IOC_GETXFLAGS:
7842 return xfs_ioc_getxflags(ip, arg);
7843 case XFS_IOC_SETXFLAGS:
7844 + if (IS_BARRIER(inode)) {
7845 + vxwprintk_task(1, "messing with the barrier.");
7846 + return -XFS_ERROR(EACCES);
7848 return xfs_ioc_setxflags(ip, filp, arg);
7850 case XFS_IOC_FSSETDM: {
7851 diff -NurpP --minimal linux-2.6.36/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.36-vs2.3.0.36.38/fs/xfs/linux-2.6/xfs_ioctl.h
7852 --- linux-2.6.36/fs/xfs/linux-2.6/xfs_ioctl.h 2010-07-07 18:31:54.000000000 +0200
7853 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/linux-2.6/xfs_ioctl.h 2010-10-21 13:09:36.000000000 +0200
7854 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7855 void __user *uhandle,
7860 + struct inode *inode,
7867 diff -NurpP --minimal linux-2.6.36/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.36-vs2.3.0.36.38/fs/xfs/linux-2.6/xfs_iops.c
7868 --- linux-2.6.36/fs/xfs/linux-2.6/xfs_iops.c 2010-10-21 13:07:51.000000000 +0200
7869 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/linux-2.6/xfs_iops.c 2010-10-21 13:09:36.000000000 +0200
7871 #include "xfs_bmap_btree.h"
7872 #include "xfs_dinode.h"
7873 #include "xfs_inode.h"
7874 +#include "xfs_ioctl.h"
7875 #include "xfs_bmap.h"
7876 #include "xfs_rtalloc.h"
7877 #include "xfs_error.h"
7879 #include <linux/falloc.h>
7880 #include <linux/fiemap.h>
7881 #include <linux/slab.h>
7882 +#include <linux/vs_tag.h>
7885 * Bring the timestamps in the XFS inode uptodate.
7886 @@ -499,6 +501,7 @@ xfs_vn_getattr(
7887 stat->nlink = ip->i_d.di_nlink;
7888 stat->uid = ip->i_d.di_uid;
7889 stat->gid = ip->i_d.di_gid;
7890 + stat->tag = ip->i_d.di_tag;
7891 stat->ino = ip->i_ino;
7892 stat->atime = inode->i_atime;
7893 stat->mtime = inode->i_mtime;
7894 @@ -687,6 +690,7 @@ static const struct inode_operations xfs
7895 .listxattr = xfs_vn_listxattr,
7896 .fallocate = xfs_vn_fallocate,
7897 .fiemap = xfs_vn_fiemap,
7898 + .sync_flags = xfs_sync_flags,
7901 static const struct inode_operations xfs_dir_inode_operations = {
7902 @@ -712,6 +716,7 @@ static const struct inode_operations xfs
7903 .getxattr = generic_getxattr,
7904 .removexattr = generic_removexattr,
7905 .listxattr = xfs_vn_listxattr,
7906 + .sync_flags = xfs_sync_flags,
7909 static const struct inode_operations xfs_dir_ci_inode_operations = {
7910 @@ -761,6 +766,10 @@ xfs_diflags_to_iflags(
7911 inode->i_flags |= S_IMMUTABLE;
7913 inode->i_flags &= ~S_IMMUTABLE;
7914 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7915 + inode->i_flags |= S_IXUNLINK;
7917 + inode->i_flags &= ~S_IXUNLINK;
7918 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7919 inode->i_flags |= S_APPEND;
7921 @@ -773,6 +782,15 @@ xfs_diflags_to_iflags(
7922 inode->i_flags |= S_NOATIME;
7924 inode->i_flags &= ~S_NOATIME;
7926 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7927 + inode->i_vflags |= V_BARRIER;
7929 + inode->i_vflags &= ~V_BARRIER;
7930 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7931 + inode->i_vflags |= V_COW;
7933 + inode->i_vflags &= ~V_COW;
7937 @@ -801,6 +819,7 @@ xfs_setup_inode(
7938 inode->i_nlink = ip->i_d.di_nlink;
7939 inode->i_uid = ip->i_d.di_uid;
7940 inode->i_gid = ip->i_d.di_gid;
7941 + inode->i_tag = ip->i_d.di_tag;
7943 switch (inode->i_mode & S_IFMT) {
7945 diff -NurpP --minimal linux-2.6.36/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.36-vs2.3.0.36.38/fs/xfs/linux-2.6/xfs_linux.h
7946 --- linux-2.6.36/fs/xfs/linux-2.6/xfs_linux.h 2010-10-21 13:07:51.000000000 +0200
7947 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/linux-2.6/xfs_linux.h 2010-10-21 13:09:36.000000000 +0200
7950 #define current_cpu() (raw_smp_processor_id())
7951 #define current_pid() (current->pid)
7952 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
7953 #define current_test_flags(f) (current->flags & (f))
7954 #define current_set_flags_nested(sp, f) \
7955 (*(sp) = current->flags, current->flags |= (f))
7956 diff -NurpP --minimal linux-2.6.36/fs/xfs/linux-2.6/xfs_super.c linux-2.6.36-vs2.3.0.36.38/fs/xfs/linux-2.6/xfs_super.c
7957 --- linux-2.6.36/fs/xfs/linux-2.6/xfs_super.c 2010-10-21 13:07:51.000000000 +0200
7958 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/linux-2.6/xfs_super.c 2010-10-21 13:09:36.000000000 +0200
7959 @@ -113,6 +113,9 @@ mempool_t *xfs_ioend_pool;
7960 #define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */
7961 #define MNTOPT_DELAYLOG "delaylog" /* Delayed loging enabled */
7962 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed loging disabled */
7963 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7964 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7965 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7968 * Table driven mount option parser.
7969 @@ -121,10 +124,14 @@ mempool_t *xfs_ioend_pool;
7970 * in the future, too.
7973 + Opt_tag, Opt_notag,
7974 Opt_barrier, Opt_nobarrier, Opt_err
7977 static const match_table_t tokens = {
7978 + {Opt_tag, "tagxid"},
7980 + {Opt_notag, "notag"},
7981 {Opt_barrier, "barrier"},
7982 {Opt_nobarrier, "nobarrier"},
7984 @@ -371,6 +378,19 @@ xfs_parseargs(
7985 } else if (!strcmp(this_char, "irixsgid")) {
7987 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
7988 +#ifndef CONFIG_TAGGING_NONE
7989 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7990 + mp->m_flags |= XFS_MOUNT_TAGGED;
7991 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7992 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7993 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7994 + mp->m_flags |= XFS_MOUNT_TAGGED;
7996 +#ifdef CONFIG_PROPAGATE
7997 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7999 + mp->m_flags |= XFS_MOUNT_TAGGED;
8003 "XFS: unknown mount option [%s].", this_char);
8004 @@ -1320,6 +1340,16 @@ xfs_fs_remount(
8006 mp->m_flags &= ~XFS_MOUNT_BARRIER;
8009 + if (!(sb->s_flags & MS_TAGGED)) {
8011 + "XFS: %s: tagging not permitted on remount.\n",
8020 * Logically we would return an error here to prevent
8021 @@ -1547,6 +1577,9 @@ xfs_fs_fill_super(
8023 goto out_filestream_unmount;
8025 + if (mp->m_flags & XFS_MOUNT_TAGGED)
8026 + sb->s_flags |= MS_TAGGED;
8028 sb->s_magic = XFS_SB_MAGIC;
8029 sb->s_blocksize = mp->m_sb.sb_blocksize;
8030 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
8031 diff -NurpP --minimal linux-2.6.36/fs/xfs/xfs_dinode.h linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_dinode.h
8032 --- linux-2.6.36/fs/xfs/xfs_dinode.h 2009-06-11 17:13:09.000000000 +0200
8033 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_dinode.h 2010-10-21 13:09:36.000000000 +0200
8034 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
8035 __be32 di_gid; /* owner's group id */
8036 __be32 di_nlink; /* number of links to file */
8037 __be16 di_projid; /* owner's project id */
8038 - __u8 di_pad[8]; /* unused, zeroed space */
8039 + __be16 di_tag; /* context tagging */
8040 + __be16 di_vflags; /* vserver specific flags */
8041 + __u8 di_pad[4]; /* unused, zeroed space */
8042 __be16 di_flushiter; /* incremented on flush */
8043 xfs_timestamp_t di_atime; /* time last accessed */
8044 xfs_timestamp_t di_mtime; /* time last modified */
8045 @@ -183,6 +185,8 @@ static inline void xfs_dinode_put_rdev(s
8046 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
8047 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
8048 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
8049 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
8051 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
8052 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
8053 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
8054 @@ -198,6 +202,7 @@ static inline void xfs_dinode_put_rdev(s
8055 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8056 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8057 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8058 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8060 #ifdef CONFIG_XFS_RT
8061 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8062 @@ -210,6 +215,10 @@ static inline void xfs_dinode_put_rdev(s
8063 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8064 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8065 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8066 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8067 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8068 + XFS_DIFLAG_IXUNLINK)
8070 +#define XFS_DIVFLAG_BARRIER 0x01
8071 +#define XFS_DIVFLAG_COW 0x02
8073 #endif /* __XFS_DINODE_H__ */
8074 diff -NurpP --minimal linux-2.6.36/fs/xfs/xfs_fs.h linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_fs.h
8075 --- linux-2.6.36/fs/xfs/xfs_fs.h 2010-10-21 13:07:52.000000000 +0200
8076 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_fs.h 2010-10-21 13:09:36.000000000 +0200
8077 @@ -67,6 +67,9 @@ struct fsxattr {
8078 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8079 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8080 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8081 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8082 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8083 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8084 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8087 @@ -295,7 +298,8 @@ typedef struct xfs_bstat {
8088 __u32 bs_gen; /* generation count */
8089 __u16 bs_projid; /* project id */
8090 __u16 bs_forkoff; /* inode fork offset in bytes */
8091 - unsigned char bs_pad[12]; /* pad space, unused */
8092 + __u16 bs_tag; /* context tagging */
8093 + unsigned char bs_pad[10]; /* pad space, unused */
8094 __u32 bs_dmevmask; /* DMIG event mask */
8095 __u16 bs_dmstate; /* DMIG state info */
8096 __u16 bs_aextents; /* attribute number of extents */
8097 diff -NurpP --minimal linux-2.6.36/fs/xfs/xfs_ialloc.c linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_ialloc.c
8098 --- linux-2.6.36/fs/xfs/xfs_ialloc.c 2010-10-21 13:07:52.000000000 +0200
8099 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_ialloc.c 2010-10-21 13:09:36.000000000 +0200
8101 #include "xfs_error.h"
8102 #include "xfs_bmap.h"
8106 * Allocation group level functions.
8108 diff -NurpP --minimal linux-2.6.36/fs/xfs/xfs_inode.c linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_inode.c
8109 --- linux-2.6.36/fs/xfs/xfs_inode.c 2010-10-21 13:07:52.000000000 +0200
8110 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_inode.c 2010-10-21 13:09:36.000000000 +0200
8111 @@ -245,6 +245,7 @@ xfs_inotobp(
8115 +#include <linux/vs_tag.h>
8118 * This routine is called to map an inode to the buffer containing
8119 @@ -650,15 +651,25 @@ xfs_iformat_btree(
8121 xfs_dinode_from_disk(
8123 - xfs_dinode_t *from)
8124 + xfs_dinode_t *from,
8127 + uint32_t uid, gid, tag;
8129 to->di_magic = be16_to_cpu(from->di_magic);
8130 to->di_mode = be16_to_cpu(from->di_mode);
8131 to->di_version = from ->di_version;
8132 to->di_format = from->di_format;
8133 to->di_onlink = be16_to_cpu(from->di_onlink);
8134 - to->di_uid = be32_to_cpu(from->di_uid);
8135 - to->di_gid = be32_to_cpu(from->di_gid);
8137 + uid = be32_to_cpu(from->di_uid);
8138 + gid = be32_to_cpu(from->di_gid);
8139 + tag = be16_to_cpu(from->di_tag);
8141 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8142 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8143 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8145 to->di_nlink = be32_to_cpu(from->di_nlink);
8146 to->di_projid = be16_to_cpu(from->di_projid);
8147 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8148 @@ -679,21 +690,26 @@ xfs_dinode_from_disk(
8149 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8150 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8151 to->di_flags = be16_to_cpu(from->di_flags);
8152 + to->di_vflags = be16_to_cpu(from->di_vflags);
8153 to->di_gen = be32_to_cpu(from->di_gen);
8159 - xfs_icdinode_t *from)
8160 + xfs_icdinode_t *from,
8163 to->di_magic = cpu_to_be16(from->di_magic);
8164 to->di_mode = cpu_to_be16(from->di_mode);
8165 to->di_version = from ->di_version;
8166 to->di_format = from->di_format;
8167 to->di_onlink = cpu_to_be16(from->di_onlink);
8168 - to->di_uid = cpu_to_be32(from->di_uid);
8169 - to->di_gid = cpu_to_be32(from->di_gid);
8171 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8172 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8173 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8175 to->di_nlink = cpu_to_be32(from->di_nlink);
8176 to->di_projid = cpu_to_be16(from->di_projid);
8177 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8178 @@ -714,12 +730,14 @@ xfs_dinode_to_disk(
8179 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8180 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8181 to->di_flags = cpu_to_be16(from->di_flags);
8182 + to->di_vflags = cpu_to_be16(from->di_vflags);
8183 to->di_gen = cpu_to_be32(from->di_gen);
8188 - __uint16_t di_flags)
8189 + __uint16_t di_flags,
8190 + __uint16_t di_vflags)
8194 @@ -730,6 +748,8 @@ _xfs_dic2xflags(
8195 flags |= XFS_XFLAG_PREALLOC;
8196 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8197 flags |= XFS_XFLAG_IMMUTABLE;
8198 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8199 + flags |= XFS_XFLAG_IXUNLINK;
8200 if (di_flags & XFS_DIFLAG_APPEND)
8201 flags |= XFS_XFLAG_APPEND;
8202 if (di_flags & XFS_DIFLAG_SYNC)
8203 @@ -754,6 +774,10 @@ _xfs_dic2xflags(
8204 flags |= XFS_XFLAG_FILESTREAM;
8207 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8208 + flags |= FS_BARRIER_FL;
8209 + if (di_vflags & XFS_DIVFLAG_COW)
8210 + flags |= FS_COW_FL;
8214 @@ -763,7 +787,7 @@ xfs_ip2xflags(
8216 xfs_icdinode_t *dic = &ip->i_d;
8218 - return _xfs_dic2xflags(dic->di_flags) |
8219 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8220 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8223 @@ -771,7 +795,8 @@ uint
8227 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8228 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8229 + be16_to_cpu(dip->di_vflags)) |
8230 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8233 @@ -804,7 +829,6 @@ xfs_iread(
8236 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8239 * If we got something that isn't an inode it means someone
8240 * (nfs or dmi) has a stale handle.
8241 @@ -829,7 +853,8 @@ xfs_iread(
8242 * Otherwise, just get the truly permanent information.
8245 - xfs_dinode_from_disk(&ip->i_d, dip);
8246 + xfs_dinode_from_disk(&ip->i_d, dip,
8247 + mp->m_flags & XFS_MOUNT_TAGGED);
8248 error = xfs_iformat(ip, dip);
8251 @@ -1027,6 +1052,7 @@ xfs_ialloc(
8252 ASSERT(ip->i_d.di_nlink == nlink);
8253 ip->i_d.di_uid = current_fsuid();
8254 ip->i_d.di_gid = current_fsgid();
8255 + ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
8256 ip->i_d.di_projid = prid;
8257 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8259 @@ -1087,6 +1113,7 @@ xfs_ialloc(
8260 ip->i_d.di_dmevmask = 0;
8261 ip->i_d.di_dmstate = 0;
8262 ip->i_d.di_flags = 0;
8263 + ip->i_d.di_vflags = 0;
8264 flags = XFS_ILOG_CORE;
8265 switch (mode & S_IFMT) {
8267 @@ -2105,6 +2132,7 @@ xfs_ifree(
8269 ip->i_d.di_mode = 0; /* mark incore inode as free */
8270 ip->i_d.di_flags = 0;
8271 + ip->i_d.di_vflags = 0;
8272 ip->i_d.di_dmevmask = 0;
8273 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8274 ip->i_df.if_ext_max =
8275 @@ -2975,7 +3003,8 @@ xfs_iflush_int(
8276 * because if the inode is dirty at all the core must
8279 - xfs_dinode_to_disk(dip, &ip->i_d);
8280 + xfs_dinode_to_disk(dip, &ip->i_d,
8281 + mp->m_flags & XFS_MOUNT_TAGGED);
8283 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8284 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8285 diff -NurpP --minimal linux-2.6.36/fs/xfs/xfs_inode.h linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_inode.h
8286 --- linux-2.6.36/fs/xfs/xfs_inode.h 2010-10-21 13:07:52.000000000 +0200
8287 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_inode.h 2010-10-21 13:09:36.000000000 +0200
8288 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
8289 __uint32_t di_gid; /* owner's group id */
8290 __uint32_t di_nlink; /* number of links to file */
8291 __uint16_t di_projid; /* owner's project id */
8292 - __uint8_t di_pad[8]; /* unused, zeroed space */
8293 + __uint16_t di_tag; /* context tagging */
8294 + __uint16_t di_vflags; /* vserver specific flags */
8295 + __uint8_t di_pad[4]; /* unused, zeroed space */
8296 __uint16_t di_flushiter; /* incremented on flush */
8297 xfs_ictimestamp_t di_atime; /* time last accessed */
8298 xfs_ictimestamp_t di_mtime; /* time last modified */
8299 @@ -509,7 +511,7 @@ int xfs_itobp(struct xfs_mount *, struc
8300 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8301 struct xfs_inode *, uint);
8302 void xfs_dinode_to_disk(struct xfs_dinode *,
8303 - struct xfs_icdinode *);
8304 + struct xfs_icdinode *, int);
8305 void xfs_idestroy_fork(struct xfs_inode *, int);
8306 void xfs_idata_realloc(struct xfs_inode *, int, int);
8307 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8308 diff -NurpP --minimal linux-2.6.36/fs/xfs/xfs_itable.c linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_itable.c
8309 --- linux-2.6.36/fs/xfs/xfs_itable.c 2010-10-21 13:07:52.000000000 +0200
8310 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_itable.c 2010-10-21 13:09:36.000000000 +0200
8311 @@ -97,6 +97,7 @@ xfs_bulkstat_one_int(
8312 buf->bs_mode = dic->di_mode;
8313 buf->bs_uid = dic->di_uid;
8314 buf->bs_gid = dic->di_gid;
8315 + buf->bs_tag = dic->di_tag;
8316 buf->bs_size = dic->di_size;
8319 diff -NurpP --minimal linux-2.6.36/fs/xfs/xfs_log_recover.c linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_log_recover.c
8320 --- linux-2.6.36/fs/xfs/xfs_log_recover.c 2010-10-21 13:07:52.000000000 +0200
8321 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_log_recover.c 2010-10-21 14:02:02.000000000 +0200
8322 @@ -2450,7 +2450,8 @@ xlog_recover_do_inode_trans(
8325 /* The core is in in-core format */
8326 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
8327 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
8328 + mp->m_flags & XFS_MOUNT_TAGGED);
8330 /* the rest is in on-disk format */
8331 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8332 diff -NurpP --minimal linux-2.6.36/fs/xfs/xfs_mount.h linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_mount.h
8333 --- linux-2.6.36/fs/xfs/xfs_mount.h 2010-10-21 13:07:52.000000000 +0200
8334 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_mount.h 2010-10-21 13:09:36.000000000 +0200
8335 @@ -238,6 +238,7 @@ typedef struct xfs_mount {
8337 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8339 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8342 * Default minimum read and write sizes.
8343 diff -NurpP --minimal linux-2.6.36/fs/xfs/xfs_vnodeops.c linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_vnodeops.c
8344 --- linux-2.6.36/fs/xfs/xfs_vnodeops.c 2010-10-21 13:07:52.000000000 +0200
8345 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_vnodeops.c 2010-10-21 15:17:26.000000000 +0200
8347 #include "xfs_vnodeops.h"
8348 #include "xfs_trace.h"
8352 +xfs_get_inode_flags(
8355 + struct inode *inode = VFS_I(ip);
8356 + unsigned int flags = inode->i_flags;
8357 + unsigned int vflags = inode->i_vflags;
8359 + if (flags & S_IMMUTABLE)
8360 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8362 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8363 + if (flags & S_IXUNLINK)
8364 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8366 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8368 + if (vflags & V_BARRIER)
8369 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8371 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8372 + if (vflags & V_COW)
8373 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8375 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8380 + struct inode *inode,
8384 + struct xfs_inode *ip = XFS_I(inode);
8385 + struct xfs_mount *mp = ip->i_mount;
8386 + struct xfs_trans *tp;
8387 + unsigned int lock_flags = 0;
8390 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8391 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8395 + xfs_ilock(ip, XFS_ILOCK_EXCL);
8397 + xfs_trans_ijoin(tp, ip);
8399 + inode->i_flags = flags;
8400 + inode->i_vflags = vflags;
8401 + xfs_get_inode_flags(ip);
8403 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8404 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
8406 + XFS_STATS_INC(xs_ig_attrchg);
8408 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8409 + xfs_trans_set_sync(tp);
8410 + code = xfs_trans_commit(tp, 0);
8411 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8415 + xfs_trans_cancel(tp, 0);
8417 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8424 struct xfs_inode *ip,
8425 @@ -65,6 +137,7 @@ xfs_setattr(
8426 uint commit_flags=0;
8427 uid_t uid=0, iuid=0;
8428 gid_t gid=0, igid=0;
8429 + tag_t tag=0, itag=0;
8430 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8431 int need_iolock = 1;
8433 @@ -147,7 +220,7 @@ xfs_setattr(
8435 * Change file ownership. Must be the owner or privileged.
8437 - if (mask & (ATTR_UID|ATTR_GID)) {
8438 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8440 * These IDs could have changed since we last looked at them.
8441 * But, we're assured that if the ownership did change
8442 @@ -156,8 +229,10 @@ xfs_setattr(
8444 iuid = ip->i_d.di_uid;
8445 igid = ip->i_d.di_gid;
8446 + itag = ip->i_d.di_tag;
8447 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8448 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8449 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8452 * Do a quota reservation only if uid/gid is actually
8453 @@ -165,7 +240,8 @@ xfs_setattr(
8455 if (XFS_IS_QUOTA_RUNNING(mp) &&
8456 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8457 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
8458 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8459 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
8461 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
8462 capable(CAP_FOWNER) ?
8463 @@ -326,7 +402,7 @@ xfs_setattr(
8465 * Change file ownership. Must be the owner or privileged.
8467 - if (mask & (ATTR_UID|ATTR_GID)) {
8468 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8470 * CAP_FSETID overrides the following restrictions:
8472 @@ -342,6 +418,10 @@ xfs_setattr(
8473 * Change the ownerships and register quota modifications
8474 * in the transaction.
8476 + if (itag != tag) {
8477 + ip->i_d.di_tag = tag;
8478 + inode->i_tag = tag;
8481 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
8482 ASSERT(mask & ATTR_UID);
8483 diff -NurpP --minimal linux-2.6.36/fs/xfs/xfs_vnodeops.h linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_vnodeops.h
8484 --- linux-2.6.36/fs/xfs/xfs_vnodeops.h 2010-07-07 18:31:54.000000000 +0200
8485 +++ linux-2.6.36-vs2.3.0.36.38/fs/xfs/xfs_vnodeops.h 2010-10-21 13:09:36.000000000 +0200
8486 @@ -14,6 +14,7 @@ struct xfs_inode;
8490 +int xfs_sync_xflags(struct xfs_inode *ip);
8491 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8492 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8493 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8494 diff -NurpP --minimal linux-2.6.36/include/asm-generic/tlb.h linux-2.6.36-vs2.3.0.36.38/include/asm-generic/tlb.h
8495 --- linux-2.6.36/include/asm-generic/tlb.h 2009-09-10 15:26:24.000000000 +0200
8496 +++ linux-2.6.36-vs2.3.0.36.38/include/asm-generic/tlb.h 2010-10-21 13:09:36.000000000 +0200
8498 #define _ASM_GENERIC__TLB_H
8500 #include <linux/swap.h>
8501 +#include <linux/vs_memory.h>
8502 #include <asm/pgalloc.h>
8503 #include <asm/tlbflush.h>
8505 diff -NurpP --minimal linux-2.6.36/include/linux/Kbuild linux-2.6.36-vs2.3.0.36.38/include/linux/Kbuild
8506 --- linux-2.6.36/include/linux/Kbuild 2010-10-21 13:07:52.000000000 +0200
8507 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/Kbuild 2010-10-21 14:12:01.000000000 +0200
8508 @@ -15,6 +15,7 @@ header-y += netfilter_bridge/
8509 header-y += netfilter_ipv4/
8510 header-y += netfilter_ipv6/
8512 +header-y += vserver/
8515 objhdr-y += version.h
8516 diff -NurpP --minimal linux-2.6.36/include/linux/capability.h linux-2.6.36-vs2.3.0.36.38/include/linux/capability.h
8517 --- linux-2.6.36/include/linux/capability.h 2010-10-21 13:07:52.000000000 +0200
8518 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/capability.h 2010-10-21 13:09:36.000000000 +0200
8519 @@ -280,6 +280,7 @@ struct cpu_vfs_cap_data {
8520 arbitrary SCSI commands */
8521 /* Allow setting encryption key on loopback filesystem */
8522 /* Allow setting zone reclaim policy */
8523 +/* Allow the selection of a security context */
8525 #define CAP_SYS_ADMIN 21
8527 @@ -352,7 +353,13 @@ struct cpu_vfs_cap_data {
8529 #define CAP_MAC_ADMIN 33
8531 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8532 +/* Allow context manipulations */
8533 +/* Allow changing context info on files */
8535 +#define CAP_CONTEXT 34
8538 +#define CAP_LAST_CAP CAP_CONTEXT
8540 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8542 diff -NurpP --minimal linux-2.6.36/include/linux/devpts_fs.h linux-2.6.36-vs2.3.0.36.38/include/linux/devpts_fs.h
8543 --- linux-2.6.36/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8544 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/devpts_fs.h 2010-10-21 13:09:36.000000000 +0200
8545 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8550 #endif /* _LINUX_DEVPTS_FS_H */
8551 diff -NurpP --minimal linux-2.6.36/include/linux/ext2_fs.h linux-2.6.36-vs2.3.0.36.38/include/linux/ext2_fs.h
8552 --- linux-2.6.36/include/linux/ext2_fs.h 2010-02-25 11:52:07.000000000 +0100
8553 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/ext2_fs.h 2010-10-21 13:09:36.000000000 +0200
8554 @@ -189,8 +189,12 @@ struct ext2_group_desc
8555 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8556 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8557 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8558 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8559 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8561 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8562 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8564 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8565 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8567 @@ -274,7 +278,8 @@ struct ext2_inode {
8569 __le16 l_i_uid_high; /* these 2 fields */
8570 __le16 l_i_gid_high; /* were reserved2[0] */
8571 - __u32 l_i_reserved2;
8572 + __le16 l_i_tag; /* Context Tag */
8573 + __u16 l_i_reserved2;
8576 __u8 h_i_frag; /* Fragment number */
8577 @@ -303,6 +308,7 @@ struct ext2_inode {
8578 #define i_gid_low i_gid
8579 #define i_uid_high osd2.linux2.l_i_uid_high
8580 #define i_gid_high osd2.linux2.l_i_gid_high
8581 +#define i_raw_tag osd2.linux2.l_i_tag
8582 #define i_reserved2 osd2.linux2.l_i_reserved2
8585 @@ -347,6 +353,7 @@ struct ext2_inode {
8586 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8587 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8588 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8589 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8592 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8593 diff -NurpP --minimal linux-2.6.36/include/linux/ext3_fs.h linux-2.6.36-vs2.3.0.36.38/include/linux/ext3_fs.h
8594 --- linux-2.6.36/include/linux/ext3_fs.h 2010-10-21 13:07:53.000000000 +0200
8595 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/ext3_fs.h 2010-10-21 13:09:36.000000000 +0200
8596 @@ -173,10 +173,14 @@ struct ext3_group_desc
8597 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8598 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8599 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8600 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8601 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8603 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8604 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8605 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8606 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8608 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8609 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8611 /* Flags that should be inherited by new inodes from their parent. */
8612 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8613 @@ -312,7 +316,8 @@ struct ext3_inode {
8615 __le16 l_i_uid_high; /* these 2 fields */
8616 __le16 l_i_gid_high; /* were reserved2[0] */
8617 - __u32 l_i_reserved2;
8618 + __le16 l_i_tag; /* Context Tag */
8619 + __u16 l_i_reserved2;
8622 __u8 h_i_frag; /* Fragment number */
8623 @@ -343,6 +348,7 @@ struct ext3_inode {
8624 #define i_gid_low i_gid
8625 #define i_uid_high osd2.linux2.l_i_uid_high
8626 #define i_gid_high osd2.linux2.l_i_gid_high
8627 +#define i_raw_tag osd2.linux2.l_i_tag
8628 #define i_reserved2 osd2.linux2.l_i_reserved2
8630 #elif defined(__GNU__)
8631 @@ -405,6 +411,7 @@ struct ext3_inode {
8632 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8633 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8634 * error in ordered mode */
8635 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8637 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8638 #ifndef _LINUX_EXT2_FS_H
8639 @@ -908,6 +915,7 @@ extern void ext3_get_inode_flags(struct
8640 extern void ext3_set_aops(struct inode *inode);
8641 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8642 u64 start, u64 len);
8643 +extern int ext3_sync_flags(struct inode *, int, int);
8646 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8647 diff -NurpP --minimal linux-2.6.36/include/linux/fs.h linux-2.6.36-vs2.3.0.36.38/include/linux/fs.h
8648 --- linux-2.6.36/include/linux/fs.h 2010-10-21 13:07:53.000000000 +0200
8649 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/fs.h 2010-10-21 13:09:36.000000000 +0200
8650 @@ -208,6 +208,9 @@ struct inodes_stat_t {
8651 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8652 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8653 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8654 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8655 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8656 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8657 #define MS_BORN (1<<29)
8658 #define MS_ACTIVE (1<<30)
8659 #define MS_NOUSER (1<<31)
8660 @@ -235,6 +238,14 @@ struct inodes_stat_t {
8661 #define S_NOCMTIME 128 /* Do not update file c/mtime */
8662 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
8663 #define S_PRIVATE 512 /* Inode is fs-internal */
8664 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
8666 +/* Linux-VServer related Inode flags */
8670 +#define V_BARRIER 4 /* Barrier for chroot() */
8671 +#define V_COW 8 /* Copy on Write */
8674 * Note that nosuid etc flags are inode-specific: setting some file-system
8675 @@ -257,12 +268,15 @@ struct inodes_stat_t {
8676 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8677 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8678 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8679 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8680 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8681 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8682 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8683 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8685 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8686 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8687 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8688 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8689 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8690 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8692 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8693 @@ -270,6 +284,16 @@ struct inodes_stat_t {
8694 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
8695 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
8697 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8699 +#ifdef CONFIG_VSERVER_COWBL
8700 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8701 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8703 +# define IS_COW(inode) (0)
8704 +# define IS_COW_LINK(inode) (0)
8707 /* the read-only stuff doesn't really belong here, but any other place is
8708 probably as bad and I don't want to create yet another include file. */
8710 @@ -353,11 +377,14 @@ struct inodes_stat_t {
8711 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8712 #define FS_EXTENT_FL 0x00080000 /* Extents */
8713 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8714 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8715 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8717 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8718 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8719 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8720 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8722 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8723 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8725 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8726 #define SYNC_FILE_RANGE_WRITE 2
8727 @@ -437,6 +464,7 @@ typedef void (dio_iodone_t)(struct kiocb
8728 #define ATTR_KILL_PRIV (1 << 14)
8729 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8730 #define ATTR_TIMES_SET (1 << 16)
8731 +#define ATTR_TAG (1 << 17)
8734 * This is the Inode Attributes structure, used for notify_change(). It
8735 @@ -452,6 +480,7 @@ struct iattr {
8741 struct timespec ia_atime;
8742 struct timespec ia_mtime;
8743 @@ -465,6 +494,9 @@ struct iattr {
8744 struct file *ia_file;
8747 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8748 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8751 * Includes for diskquotas.
8753 @@ -732,7 +764,9 @@ struct inode {
8754 unsigned int i_nlink;
8760 unsigned int i_blkbits;
8763 @@ -774,7 +808,8 @@ struct inode {
8764 unsigned long i_state;
8765 unsigned long dirtied_when; /* jiffies of first dirtying */
8767 - unsigned int i_flags;
8768 + unsigned short i_flags;
8769 + unsigned short i_vflags;
8771 atomic_t i_writecount;
8772 #ifdef CONFIG_SECURITY
8773 @@ -862,12 +897,12 @@ static inline void i_size_write(struct i
8775 static inline unsigned iminor(const struct inode *inode)
8777 - return MINOR(inode->i_rdev);
8778 + return MINOR(inode->i_mdev);
8781 static inline unsigned imajor(const struct inode *inode)
8783 - return MAJOR(inode->i_rdev);
8784 + return MAJOR(inode->i_mdev);
8787 extern struct block_device *I_BDEV(struct inode *inode);
8788 @@ -929,6 +964,7 @@ struct file {
8790 struct fown_struct f_owner;
8791 const struct cred *f_cred;
8793 struct file_ra_state f_ra;
8796 @@ -1068,6 +1104,7 @@ struct file_lock {
8797 struct file *fl_file;
8802 struct fasync_struct * fl_fasync; /* for lease break notifications */
8803 unsigned long fl_break_time; /* for nonblocking lease breaks */
8804 @@ -1536,6 +1573,7 @@ struct inode_operations {
8805 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8806 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8807 int (*removexattr) (struct dentry *, const char *);
8808 + int (*sync_flags) (struct inode *, int, int);
8809 void (*truncate_range)(struct inode *, loff_t, loff_t);
8810 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
8812 @@ -1556,6 +1594,7 @@ extern ssize_t vfs_readv(struct file *,
8813 unsigned long, loff_t *);
8814 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8815 unsigned long, loff_t *);
8816 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8818 struct super_operations {
8819 struct inode *(*alloc_inode)(struct super_block *sb);
8820 @@ -2344,6 +2383,7 @@ extern int dcache_dir_open(struct inode
8821 extern int dcache_dir_close(struct inode *, struct file *);
8822 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8823 extern int dcache_readdir(struct file *, void *, filldir_t);
8824 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8825 extern int simple_setattr(struct dentry *, struct iattr *);
8826 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8827 extern int simple_statfs(struct dentry *, struct kstatfs *);
8828 diff -NurpP --minimal linux-2.6.36/include/linux/gfs2_ondisk.h linux-2.6.36-vs2.3.0.36.38/include/linux/gfs2_ondisk.h
8829 --- linux-2.6.36/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
8830 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/gfs2_ondisk.h 2010-10-21 13:09:36.000000000 +0200
8831 @@ -211,6 +211,9 @@ enum {
8835 + gfs2fl_IXUnlink = 16,
8836 + gfs2fl_Barrier = 17,
8838 gfs2fl_TruncInProg = 29,
8839 gfs2fl_InheritDirectio = 30,
8840 gfs2fl_InheritJdata = 31,
8841 @@ -227,6 +230,9 @@ enum {
8842 #define GFS2_DIF_NOATIME 0x00000080
8843 #define GFS2_DIF_SYNC 0x00000100
8844 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8845 +#define GFS2_DIF_IXUNLINK 0x00010000
8846 +#define GFS2_DIF_BARRIER 0x00020000
8847 +#define GFS2_DIF_COW 0x00040000
8848 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8849 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8850 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8851 diff -NurpP --minimal linux-2.6.36/include/linux/if_tun.h linux-2.6.36-vs2.3.0.36.38/include/linux/if_tun.h
8852 --- linux-2.6.36/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8853 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/if_tun.h 2010-10-21 13:09:36.000000000 +0200
8855 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8856 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8857 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8858 +#define TUNSETNID _IOW('T', 217, int)
8860 /* TUNSETIFF ifr flags */
8861 #define IFF_TUN 0x0001
8862 diff -NurpP --minimal linux-2.6.36/include/linux/init_task.h linux-2.6.36-vs2.3.0.36.38/include/linux/init_task.h
8863 --- linux-2.6.36/include/linux/init_task.h 2010-08-02 16:52:54.000000000 +0200
8864 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/init_task.h 2010-10-21 13:09:36.000000000 +0200
8865 @@ -172,6 +172,10 @@ extern struct cred init_cred;
8867 INIT_TRACE_RECURSION \
8868 INIT_TASK_RCU_PREEMPT(tsk) \
8870 + .vx_info = NULL, \
8872 + .nx_info = NULL, \
8876 diff -NurpP --minimal linux-2.6.36/include/linux/ipc.h linux-2.6.36-vs2.3.0.36.38/include/linux/ipc.h
8877 --- linux-2.6.36/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8878 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/ipc.h 2010-10-21 13:09:36.000000000 +0200
8879 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8887 diff -NurpP --minimal linux-2.6.36/include/linux/loop.h linux-2.6.36-vs2.3.0.36.38/include/linux/loop.h
8888 --- linux-2.6.36/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
8889 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/loop.h 2010-10-21 13:09:36.000000000 +0200
8890 @@ -45,6 +45,7 @@ struct loop_device {
8891 struct loop_func_table *lo_encryption;
8893 uid_t lo_key_owner; /* Who set the key */
8895 int (*ioctl)(struct loop_device *, int cmd,
8898 diff -NurpP --minimal linux-2.6.36/include/linux/magic.h linux-2.6.36-vs2.3.0.36.38/include/linux/magic.h
8899 --- linux-2.6.36/include/linux/magic.h 2010-07-07 18:31:55.000000000 +0200
8900 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/magic.h 2010-10-21 13:09:36.000000000 +0200
8903 #define ADFS_SUPER_MAGIC 0xadf5
8904 #define AFFS_SUPER_MAGIC 0xadff
8905 -#define AFS_SUPER_MAGIC 0x5346414F
8906 +#define AFS_SUPER_MAGIC 0x5346414F
8907 #define AUTOFS_SUPER_MAGIC 0x0187
8908 #define CODA_SUPER_MAGIC 0x73757245
8909 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8911 #define NFS_SUPER_MAGIC 0x6969
8912 #define OPENPROM_SUPER_MAGIC 0x9fa1
8913 #define PROC_SUPER_MAGIC 0x9fa0
8914 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8915 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8917 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8918 diff -NurpP --minimal linux-2.6.36/include/linux/major.h linux-2.6.36-vs2.3.0.36.38/include/linux/major.h
8919 --- linux-2.6.36/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8920 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/major.h 2010-10-21 13:09:36.000000000 +0200
8922 #define HD_MAJOR IDE0_MAJOR
8923 #define PTY_SLAVE_MAJOR 3
8925 +#define VROOT_MAJOR 4
8926 #define TTYAUX_MAJOR 5
8929 diff -NurpP --minimal linux-2.6.36/include/linux/memcontrol.h linux-2.6.36-vs2.3.0.36.38/include/linux/memcontrol.h
8930 --- linux-2.6.36/include/linux/memcontrol.h 2010-10-21 13:07:53.000000000 +0200
8931 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/memcontrol.h 2010-10-28 19:36:06.000000000 +0200
8932 @@ -77,6 +77,13 @@ int task_in_mem_cgroup(struct task_struc
8933 extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
8934 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8936 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8937 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8939 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8940 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8941 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8944 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8946 diff -NurpP --minimal linux-2.6.36/include/linux/mm_types.h linux-2.6.36-vs2.3.0.36.38/include/linux/mm_types.h
8947 --- linux-2.6.36/include/linux/mm_types.h 2010-10-21 13:07:53.000000000 +0200
8948 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/mm_types.h 2010-10-21 13:09:36.000000000 +0200
8949 @@ -269,6 +269,7 @@ struct mm_struct {
8951 /* Architecture-specific MM context */
8952 mm_context_t context;
8953 + struct vx_info *mm_vx_info;
8955 /* Swap token stuff */
8957 diff -NurpP --minimal linux-2.6.36/include/linux/mount.h linux-2.6.36-vs2.3.0.36.38/include/linux/mount.h
8958 --- linux-2.6.36/include/linux/mount.h 2010-10-21 13:07:53.000000000 +0200
8959 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/mount.h 2010-10-21 13:09:36.000000000 +0200
8960 @@ -46,6 +46,9 @@ struct mnt_namespace;
8962 #define MNT_INTERNAL 0x4000
8964 +#define MNT_TAGID 0x10000
8965 +#define MNT_NOTAG 0x20000
8968 struct list_head mnt_hash;
8969 struct vfsmount *mnt_parent; /* fs we are mounted on */
8970 @@ -84,6 +87,7 @@ struct vfsmount {
8974 + tag_t mnt_tag; /* tagging used for vfsmount */
8977 static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
8978 diff -NurpP --minimal linux-2.6.36/include/linux/net.h linux-2.6.36-vs2.3.0.36.38/include/linux/net.h
8979 --- linux-2.6.36/include/linux/net.h 2010-08-02 16:52:55.000000000 +0200
8980 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/net.h 2010-10-21 13:09:36.000000000 +0200
8981 @@ -71,6 +71,7 @@ struct net;
8982 #define SOCK_NOSPACE 2
8983 #define SOCK_PASSCRED 3
8984 #define SOCK_PASSSEC 4
8985 +#define SOCK_USER_SOCKET 5
8987 #ifndef ARCH_HAS_SOCKET_TYPES
8989 diff -NurpP --minimal linux-2.6.36/include/linux/nfs_mount.h linux-2.6.36-vs2.3.0.36.38/include/linux/nfs_mount.h
8990 --- linux-2.6.36/include/linux/nfs_mount.h 2010-10-21 13:07:54.000000000 +0200
8991 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/nfs_mount.h 2010-10-21 13:09:36.000000000 +0200
8992 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8993 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8994 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8995 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8996 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8997 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8998 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
9000 /* The following are for internal use only */
9001 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
9002 diff -NurpP --minimal linux-2.6.36/include/linux/nsproxy.h linux-2.6.36-vs2.3.0.36.38/include/linux/nsproxy.h
9003 --- linux-2.6.36/include/linux/nsproxy.h 2009-06-11 17:13:17.000000000 +0200
9004 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/nsproxy.h 2010-10-21 13:09:36.000000000 +0200
9007 #include <linux/spinlock.h>
9008 #include <linux/sched.h>
9009 +#include <linux/vserver/debug.h>
9011 struct mnt_namespace;
9012 struct uts_namespace;
9013 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
9016 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
9017 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
9018 void exit_task_namespaces(struct task_struct *tsk);
9019 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
9020 void free_nsproxy(struct nsproxy *ns);
9021 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
9022 struct fs_struct *);
9024 -static inline void put_nsproxy(struct nsproxy *ns)
9025 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
9027 +static inline void __get_nsproxy(struct nsproxy *ns,
9028 + const char *_file, int _line)
9030 - if (atomic_dec_and_test(&ns->count)) {
9033 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
9034 + ns, atomic_read(&ns->count), _file, _line);
9035 + atomic_inc(&ns->count);
9038 -static inline void get_nsproxy(struct nsproxy *ns)
9039 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
9041 +static inline void __put_nsproxy(struct nsproxy *ns,
9042 + const char *_file, int _line)
9044 - atomic_inc(&ns->count);
9045 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
9046 + ns, atomic_read(&ns->count), _file, _line);
9047 + if (atomic_dec_and_test(&ns->count)) {
9052 #ifdef CONFIG_CGROUP_NS
9053 diff -NurpP --minimal linux-2.6.36/include/linux/pid.h linux-2.6.36-vs2.3.0.36.38/include/linux/pid.h
9054 --- linux-2.6.36/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
9055 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/pid.h 2010-10-21 13:09:36.000000000 +0200
9056 @@ -8,7 +8,8 @@ enum pid_type
9066 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
9069 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9070 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9071 pid_t pid_vnr(struct pid *pid);
9073 #define do_each_pid_task(pid, type, task) \
9074 diff -NurpP --minimal linux-2.6.36/include/linux/proc_fs.h linux-2.6.36-vs2.3.0.36.38/include/linux/proc_fs.h
9075 --- linux-2.6.36/include/linux/proc_fs.h 2009-12-03 20:02:56.000000000 +0100
9076 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/proc_fs.h 2010-10-21 13:09:36.000000000 +0200
9077 @@ -56,6 +56,7 @@ struct proc_dir_entry {
9083 const struct inode_operations *proc_iops;
9085 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void
9086 extern void kclist_add(struct kcore_list *, void *, size_t, int type);
9093 int (*proc_get_link)(struct inode *, struct path *);
9094 int (*proc_read)(struct task_struct *task, char *page);
9095 int (*proc_show)(struct seq_file *m,
9096 struct pid_namespace *ns, struct pid *pid,
9097 struct task_struct *task);
9098 + int (*proc_vs_read)(char *page);
9099 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9100 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9103 struct ctl_table_header;
9104 @@ -263,6 +270,7 @@ struct ctl_table;
9111 struct proc_dir_entry *pde;
9112 diff -NurpP --minimal linux-2.6.36/include/linux/quotaops.h linux-2.6.36-vs2.3.0.36.38/include/linux/quotaops.h
9113 --- linux-2.6.36/include/linux/quotaops.h 2010-10-21 13:07:54.000000000 +0200
9114 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/quotaops.h 2010-10-21 13:09:36.000000000 +0200
9116 #define _LINUX_QUOTAOPS_
9118 #include <linux/fs.h>
9119 +#include <linux/vs_dlimit.h>
9121 #define DQUOT_SPACE_WARN 0x1
9122 #define DQUOT_SPACE_RESERVE 0x2
9123 @@ -205,11 +206,12 @@ static inline void dquot_drop(struct ino
9125 static inline int dquot_alloc_inode(const struct inode *inode)
9128 + return dl_alloc_inode(inode);
9131 static inline void dquot_free_inode(const struct inode *inode)
9133 + dl_free_inode(inode);
9136 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
9137 @@ -220,6 +222,10 @@ static inline int dquot_transfer(struct
9138 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
9143 + if ((ret = dl_alloc_space(inode, number)))
9145 if (!(flags & DQUOT_SPACE_RESERVE))
9146 inode_add_bytes(inode, number);
9148 @@ -230,6 +236,7 @@ static inline void __dquot_free_space(st
9150 if (!(flags & DQUOT_SPACE_RESERVE))
9151 inode_sub_bytes(inode, number);
9152 + dl_free_space(inode, number);
9155 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
9156 diff -NurpP --minimal linux-2.6.36/include/linux/reboot.h linux-2.6.36-vs2.3.0.36.38/include/linux/reboot.h
9157 --- linux-2.6.36/include/linux/reboot.h 2010-07-07 18:31:56.000000000 +0200
9158 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/reboot.h 2010-10-21 13:09:36.000000000 +0200
9160 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
9161 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
9162 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
9163 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
9167 diff -NurpP --minimal linux-2.6.36/include/linux/reiserfs_fs.h linux-2.6.36-vs2.3.0.36.38/include/linux/reiserfs_fs.h
9168 --- linux-2.6.36/include/linux/reiserfs_fs.h 2010-10-21 13:07:54.000000000 +0200
9169 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/reiserfs_fs.h 2010-10-21 13:09:36.000000000 +0200
9170 @@ -977,6 +977,11 @@ struct stat_data_v1 {
9171 #define REISERFS_COMPR_FL FS_COMPR_FL
9172 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9174 +/* unfortunately reiserfs sdattr is only 16 bit */
9175 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9176 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9177 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9179 /* persistent flags that file inherits from the parent directory */
9180 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9181 REISERFS_SYNC_FL | \
9182 @@ -986,6 +991,9 @@ struct stat_data_v1 {
9183 REISERFS_COMPR_FL | \
9184 REISERFS_NOTAIL_FL )
9186 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9187 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9189 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9192 @@ -2071,6 +2079,7 @@ static inline void reiserfs_update_sd(st
9193 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9194 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9195 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9196 +int reiserfs_sync_flags(struct inode *inode, int, int);
9199 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
9200 diff -NurpP --minimal linux-2.6.36/include/linux/reiserfs_fs_sb.h linux-2.6.36-vs2.3.0.36.38/include/linux/reiserfs_fs_sb.h
9201 --- linux-2.6.36/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
9202 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/reiserfs_fs_sb.h 2010-10-21 13:09:36.000000000 +0200
9203 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
9204 REISERFS_EXPOSE_PRIVROOT,
9205 REISERFS_BARRIER_NONE,
9206 REISERFS_BARRIER_FLUSH,
9209 /* Actions on error */
9210 REISERFS_ERROR_PANIC,
9211 diff -NurpP --minimal linux-2.6.36/include/linux/sched.h linux-2.6.36-vs2.3.0.36.38/include/linux/sched.h
9212 --- linux-2.6.36/include/linux/sched.h 2010-10-21 13:07:54.000000000 +0200
9213 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/sched.h 2010-10-21 13:09:36.000000000 +0200
9214 @@ -1339,6 +1339,14 @@ struct task_struct {
9218 +/* vserver context data */
9219 + struct vx_info *vx_info;
9220 + struct nx_info *nx_info;
9226 /* Thread group tracking */
9229 @@ -1573,6 +1581,11 @@ struct pid_namespace;
9230 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9231 struct pid_namespace *ns);
9233 +#include <linux/vserver/base.h>
9234 +#include <linux/vserver/context.h>
9235 +#include <linux/vserver/debug.h>
9236 +#include <linux/vserver/pid.h>
9238 static inline pid_t task_pid_nr(struct task_struct *tsk)
9241 @@ -1586,7 +1599,8 @@ static inline pid_t task_pid_nr_ns(struc
9243 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9245 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9246 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9247 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
9251 @@ -1599,7 +1613,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9253 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9255 - return pid_vnr(task_tgid(tsk));
9256 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9260 diff -NurpP --minimal linux-2.6.36/include/linux/shmem_fs.h linux-2.6.36-vs2.3.0.36.38/include/linux/shmem_fs.h
9261 --- linux-2.6.36/include/linux/shmem_fs.h 2010-10-21 13:07:55.000000000 +0200
9262 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/shmem_fs.h 2010-10-21 13:09:36.000000000 +0200
9265 #define SHMEM_NR_DIRECT 16
9267 +#define TMPFS_SUPER_MAGIC 0x01021994
9270 struct shmem_inode_info {
9272 unsigned long flags;
9273 diff -NurpP --minimal linux-2.6.36/include/linux/stat.h linux-2.6.36-vs2.3.0.36.38/include/linux/stat.h
9274 --- linux-2.6.36/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9275 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/stat.h 2010-10-21 13:09:36.000000000 +0200
9276 @@ -66,6 +66,7 @@ struct kstat {
9283 struct timespec atime;
9284 diff -NurpP --minimal linux-2.6.36/include/linux/sunrpc/auth.h linux-2.6.36-vs2.3.0.36.38/include/linux/sunrpc/auth.h
9285 --- linux-2.6.36/include/linux/sunrpc/auth.h 2010-10-21 13:07:55.000000000 +0200
9286 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/sunrpc/auth.h 2010-10-21 13:09:36.000000000 +0200
9292 struct group_info *group_info;
9293 unsigned char machine_cred : 1;
9295 diff -NurpP --minimal linux-2.6.36/include/linux/sunrpc/clnt.h linux-2.6.36-vs2.3.0.36.38/include/linux/sunrpc/clnt.h
9296 --- linux-2.6.36/include/linux/sunrpc/clnt.h 2010-10-21 13:07:55.000000000 +0200
9297 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/sunrpc/clnt.h 2010-10-21 13:09:36.000000000 +0200
9298 @@ -49,7 +49,8 @@ struct rpc_clnt {
9299 unsigned int cl_softrtry : 1,/* soft timeouts */
9300 cl_discrtry : 1,/* disconnect before retry */
9301 cl_autobind : 1,/* use getport() */
9302 - cl_chatty : 1;/* be verbose */
9303 + cl_chatty : 1,/* be verbose */
9304 + cl_tag : 1;/* context tagging */
9306 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9307 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9308 diff -NurpP --minimal linux-2.6.36/include/linux/syscalls.h linux-2.6.36-vs2.3.0.36.38/include/linux/syscalls.h
9309 --- linux-2.6.36/include/linux/syscalls.h 2010-10-21 13:07:55.000000000 +0200
9310 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/syscalls.h 2010-10-21 13:09:36.000000000 +0200
9311 @@ -478,6 +478,8 @@ asmlinkage long sys_symlink(const char _
9312 asmlinkage long sys_unlink(const char __user *pathname);
9313 asmlinkage long sys_rename(const char __user *oldname,
9314 const char __user *newname);
9315 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9317 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9318 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9320 diff -NurpP --minimal linux-2.6.36/include/linux/sysctl.h linux-2.6.36-vs2.3.0.36.38/include/linux/sysctl.h
9321 --- linux-2.6.36/include/linux/sysctl.h 2010-08-02 16:52:56.000000000 +0200
9322 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/sysctl.h 2010-10-21 13:09:36.000000000 +0200
9323 @@ -60,6 +60,7 @@ enum
9324 CTL_ABI=9, /* Binary emulation */
9325 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9326 CTL_ARLAN=254, /* arlan wireless driver */
9327 + CTL_VSERVER=4242, /* Linux-VServer debug */
9328 CTL_S390DBF=5677, /* s390 debug */
9329 CTL_SUNRPC=7249, /* sunrpc debug */
9330 CTL_PM=9899, /* frv power management */
9331 @@ -94,6 +95,7 @@ enum
9333 KERN_PANIC=15, /* int: panic timeout */
9334 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9335 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9337 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9338 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9339 diff -NurpP --minimal linux-2.6.36/include/linux/sysfs.h linux-2.6.36-vs2.3.0.36.38/include/linux/sysfs.h
9340 --- linux-2.6.36/include/linux/sysfs.h 2010-10-21 13:07:55.000000000 +0200
9341 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/sysfs.h 2010-10-21 13:09:36.000000000 +0200
9343 #include <linux/kobject_ns.h>
9344 #include <asm/atomic.h>
9346 +#define SYSFS_SUPER_MAGIC 0x62656572
9351 diff -NurpP --minimal linux-2.6.36/include/linux/time.h linux-2.6.36-vs2.3.0.36.38/include/linux/time.h
9352 --- linux-2.6.36/include/linux/time.h 2010-10-21 13:07:55.000000000 +0200
9353 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/time.h 2010-10-21 13:09:36.000000000 +0200
9354 @@ -252,6 +252,9 @@ static __always_inline void timespec_add
9355 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9359 +#include <linux/vs_time.h>
9361 #endif /* __KERNEL__ */
9363 #define NFDBITS __NFDBITS
9364 diff -NurpP --minimal linux-2.6.36/include/linux/types.h linux-2.6.36-vs2.3.0.36.38/include/linux/types.h
9365 --- linux-2.6.36/include/linux/types.h 2010-10-21 13:07:55.000000000 +0200
9366 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/types.h 2010-10-21 13:09:36.000000000 +0200
9367 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
9368 typedef __kernel_gid32_t gid_t;
9369 typedef __kernel_uid16_t uid16_t;
9370 typedef __kernel_gid16_t gid16_t;
9371 +typedef unsigned int xid_t;
9372 +typedef unsigned int nid_t;
9373 +typedef unsigned int tag_t;
9375 typedef unsigned long uintptr_t;
9377 diff -NurpP --minimal linux-2.6.36/include/linux/vroot.h linux-2.6.36-vs2.3.0.36.38/include/linux/vroot.h
9378 --- linux-2.6.36/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9379 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vroot.h 2010-10-21 13:09:36.000000000 +0200
9383 + * include/linux/vroot.h
9385 + * written by Herbert Pötzl, 9/11/2002
9386 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9388 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9389 + * Redistribution of this file is permitted under the
9390 + * GNU General Public License.
9393 +#ifndef _LINUX_VROOT_H
9394 +#define _LINUX_VROOT_H
9399 +/* Possible states of device */
9405 +struct vroot_device {
9409 + struct semaphore vr_ctl_mutex;
9410 + struct block_device *vr_device;
9415 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9417 +extern int register_vroot_grb(vroot_grb_func *);
9418 +extern int unregister_vroot_grb(vroot_grb_func *);
9420 +#endif /* __KERNEL__ */
9422 +#define MAX_VROOT_DEFAULT 8
9425 + * IOCTL commands --- we will commandeer 0x56 ('V')
9428 +#define VROOT_SET_DEV 0x5600
9429 +#define VROOT_CLR_DEV 0x5601
9431 +#endif /* _LINUX_VROOT_H */
9432 diff -NurpP --minimal linux-2.6.36/include/linux/vs_base.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_base.h
9433 --- linux-2.6.36/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9434 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_base.h 2010-10-21 13:09:36.000000000 +0200
9439 +#include "vserver/base.h"
9440 +#include "vserver/check.h"
9441 +#include "vserver/debug.h"
9444 +#warning duplicate inclusion
9446 diff -NurpP --minimal linux-2.6.36/include/linux/vs_context.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_context.h
9447 --- linux-2.6.36/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9448 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_context.h 2010-10-21 13:09:36.000000000 +0200
9450 +#ifndef _VS_CONTEXT_H
9451 +#define _VS_CONTEXT_H
9453 +#include "vserver/base.h"
9454 +#include "vserver/check.h"
9455 +#include "vserver/context.h"
9456 +#include "vserver/history.h"
9457 +#include "vserver/debug.h"
9459 +#include <linux/sched.h>
9462 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9464 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9465 + const char *_file, int _line, void *_here)
9470 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9471 + vxi, vxi ? vxi->vx_id : 0,
9472 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9474 + __vxh_get_vx_info(vxi, _here);
9476 + atomic_inc(&vxi->vx_usecnt);
9481 +extern void free_vx_info(struct vx_info *);
9483 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9485 +static inline void __put_vx_info(struct vx_info *vxi,
9486 + const char *_file, int _line, void *_here)
9491 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9492 + vxi, vxi ? vxi->vx_id : 0,
9493 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9495 + __vxh_put_vx_info(vxi, _here);
9497 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9498 + free_vx_info(vxi);
9502 +#define init_vx_info(p, i) \
9503 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9505 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9506 + const char *_file, int _line, void *_here)
9509 + vxlprintk(VXD_CBIT(xid, 3),
9510 + "init_vx_info(%p[#%d.%d])",
9511 + vxi, vxi ? vxi->vx_id : 0,
9512 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9514 + __vxh_init_vx_info(vxi, vxp, _here);
9516 + atomic_inc(&vxi->vx_usecnt);
9522 +#define set_vx_info(p, i) \
9523 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9525 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9526 + const char *_file, int _line, void *_here)
9528 + struct vx_info *vxo;
9533 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9534 + vxi, vxi ? vxi->vx_id : 0,
9535 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9537 + __vxh_set_vx_info(vxi, vxp, _here);
9539 + atomic_inc(&vxi->vx_usecnt);
9540 + vxo = xchg(vxp, vxi);
9545 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9547 +static inline void __clr_vx_info(struct vx_info **vxp,
9548 + const char *_file, int _line, void *_here)
9550 + struct vx_info *vxo;
9552 + vxo = xchg(vxp, NULL);
9556 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9557 + vxo, vxo ? vxo->vx_id : 0,
9558 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9560 + __vxh_clr_vx_info(vxo, vxp, _here);
9562 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9563 + free_vx_info(vxo);
9567 +#define claim_vx_info(v, p) \
9568 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9570 +static inline void __claim_vx_info(struct vx_info *vxi,
9571 + struct task_struct *task,
9572 + const char *_file, int _line, void *_here)
9574 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9575 + vxi, vxi ? vxi->vx_id : 0,
9576 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9577 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9578 + task, _file, _line);
9579 + __vxh_claim_vx_info(vxi, task, _here);
9581 + atomic_inc(&vxi->vx_tasks);
9585 +extern void unhash_vx_info(struct vx_info *);
9587 +#define release_vx_info(v, p) \
9588 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9590 +static inline void __release_vx_info(struct vx_info *vxi,
9591 + struct task_struct *task,
9592 + const char *_file, int _line, void *_here)
9594 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9595 + vxi, vxi ? vxi->vx_id : 0,
9596 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9597 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9598 + task, _file, _line);
9599 + __vxh_release_vx_info(vxi, task, _here);
9603 + if (atomic_dec_and_test(&vxi->vx_tasks))
9604 + unhash_vx_info(vxi);
9608 +#define task_get_vx_info(p) \
9609 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9611 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9612 + const char *_file, int _line, void *_here)
9614 + struct vx_info *vxi;
9617 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9619 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9625 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9627 + if (waitqueue_active(&vxi->vx_wait))
9628 + wake_up_interruptible(&vxi->vx_wait);
9632 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9634 +static inline void __enter_vx_info(struct vx_info *vxi,
9635 + struct vx_info_save *vxis, const char *_file, int _line)
9637 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9638 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9639 + current->xid, current->vx_info, _file, _line);
9640 + vxis->vxi = xchg(¤t->vx_info, vxi);
9641 + vxis->xid = current->xid;
9642 + current->xid = vxi ? vxi->vx_id : 0;
9645 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9647 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9648 + const char *_file, int _line)
9650 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9651 + vxis, vxis->xid, vxis->vxi, current,
9652 + current->xid, current->vx_info, _file, _line);
9653 + (void)xchg(¤t->vx_info, vxis->vxi);
9654 + current->xid = vxis->xid;
9658 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9660 + vxis->vxi = xchg(¤t->vx_info, NULL);
9661 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9664 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9666 + (void)xchg(¤t->xid, vxis->xid);
9667 + (void)xchg(¤t->vx_info, vxis->vxi);
9670 +#define task_is_init(p) \
9671 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9673 +static inline int __task_is_init(struct task_struct *p,
9674 + const char *_file, int _line, void *_here)
9676 + int is_init = is_global_init(p);
9680 + is_init = p->vx_info->vx_initpid == p->pid;
9685 +extern void exit_vx_info(struct task_struct *, int);
9686 +extern void exit_vx_info_early(struct task_struct *, int);
9690 +#warning duplicate inclusion
9692 diff -NurpP --minimal linux-2.6.36/include/linux/vs_cowbl.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_cowbl.h
9693 --- linux-2.6.36/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9694 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_cowbl.h 2010-10-21 13:09:36.000000000 +0200
9696 +#ifndef _VS_COWBL_H
9697 +#define _VS_COWBL_H
9699 +#include <linux/fs.h>
9700 +#include <linux/dcache.h>
9701 +#include <linux/namei.h>
9702 +#include <linux/slab.h>
9704 +extern struct dentry *cow_break_link(const char *pathname);
9706 +static inline int cow_check_and_break(struct path *path)
9708 + struct inode *inode = path->dentry->d_inode;
9711 + /* do we need this check? */
9712 + if (IS_RDONLY(inode))
9715 + if (IS_COW(inode)) {
9716 + if (IS_COW_LINK(inode)) {
9717 + struct dentry *new_dentry, *old_dentry = path->dentry;
9720 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9724 + pp = d_path(path, buf, PATH_MAX);
9725 + new_dentry = cow_break_link(pp);
9727 + if (!IS_ERR(new_dentry)) {
9728 + path->dentry = new_dentry;
9731 + error = PTR_ERR(new_dentry);
9733 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9734 + inode->i_ctime = CURRENT_TIME;
9735 + mark_inode_dirty(inode);
9742 +#warning duplicate inclusion
9744 diff -NurpP --minimal linux-2.6.36/include/linux/vs_cvirt.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_cvirt.h
9745 --- linux-2.6.36/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9746 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_cvirt.h 2010-10-21 13:09:36.000000000 +0200
9748 +#ifndef _VS_CVIRT_H
9749 +#define _VS_CVIRT_H
9751 +#include "vserver/cvirt.h"
9752 +#include "vserver/context.h"
9753 +#include "vserver/base.h"
9754 +#include "vserver/check.h"
9755 +#include "vserver/debug.h"
9758 +static inline void vx_activate_task(struct task_struct *p)
9760 + struct vx_info *vxi;
9762 + if ((vxi = p->vx_info)) {
9763 + vx_update_load(vxi);
9764 + atomic_inc(&vxi->cvirt.nr_running);
9768 +static inline void vx_deactivate_task(struct task_struct *p)
9770 + struct vx_info *vxi;
9772 + if ((vxi = p->vx_info)) {
9773 + vx_update_load(vxi);
9774 + atomic_dec(&vxi->cvirt.nr_running);
9778 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9780 + struct vx_info *vxi;
9782 + if ((vxi = p->vx_info))
9783 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9786 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9788 + struct vx_info *vxi;
9790 + if ((vxi = p->vx_info))
9791 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9796 +#warning duplicate inclusion
9798 diff -NurpP --minimal linux-2.6.36/include/linux/vs_device.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_device.h
9799 --- linux-2.6.36/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9800 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_device.h 2010-10-21 13:09:36.000000000 +0200
9802 +#ifndef _VS_DEVICE_H
9803 +#define _VS_DEVICE_H
9805 +#include "vserver/base.h"
9806 +#include "vserver/device.h"
9807 +#include "vserver/debug.h"
9810 +#ifdef CONFIG_VSERVER_DEVICE
9812 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9814 +#define vs_device_perm(v, d, m, p) \
9815 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9820 +int vs_map_device(struct vx_info *vxi,
9821 + dev_t device, dev_t *target, umode_t mode)
9828 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9833 +#define vs_map_chrdev(d, t, p) \
9834 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9835 +#define vs_map_blkdev(d, t, p) \
9836 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9838 +#define vs_chrdev_perm(d, p) \
9839 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9840 +#define vs_blkdev_perm(d, p) \
9841 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9845 +#warning duplicate inclusion
9847 diff -NurpP --minimal linux-2.6.36/include/linux/vs_dlimit.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_dlimit.h
9848 --- linux-2.6.36/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9849 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_dlimit.h 2010-10-21 13:09:36.000000000 +0200
9851 +#ifndef _VS_DLIMIT_H
9852 +#define _VS_DLIMIT_H
9854 +#include <linux/fs.h>
9856 +#include "vserver/dlimit.h"
9857 +#include "vserver/base.h"
9858 +#include "vserver/debug.h"
9861 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9863 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9864 + const char *_file, int _line)
9868 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9869 + dli, dli ? dli->dl_tag : 0,
9870 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9872 + atomic_inc(&dli->dl_usecnt);
9877 +#define free_dl_info(i) \
9878 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9880 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9882 +static inline void __put_dl_info(struct dl_info *dli,
9883 + const char *_file, int _line)
9887 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9888 + dli, dli ? dli->dl_tag : 0,
9889 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9891 + if (atomic_dec_and_test(&dli->dl_usecnt))
9892 + free_dl_info(dli);
9896 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9898 +static inline int __dl_alloc_space(struct super_block *sb,
9899 + tag_t tag, dlsize_t nr, const char *file, int line)
9901 + struct dl_info *dli = NULL;
9906 + dli = locate_dl_info(sb, tag);
9910 + spin_lock(&dli->dl_lock);
9911 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9913 + dli->dl_space_used += nr;
9914 + spin_unlock(&dli->dl_lock);
9917 + vxlprintk(VXD_CBIT(dlim, 1),
9918 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9919 + sb, tag, __dlimit_char(dli), (long long)nr,
9921 + return ret ? -ENOSPC : 0;
9924 +static inline void __dl_free_space(struct super_block *sb,
9925 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9927 + struct dl_info *dli = NULL;
9931 + dli = locate_dl_info(sb, tag);
9935 + spin_lock(&dli->dl_lock);
9936 + if (dli->dl_space_used > nr)
9937 + dli->dl_space_used -= nr;
9939 + dli->dl_space_used = 0;
9940 + spin_unlock(&dli->dl_lock);
9943 + vxlprintk(VXD_CBIT(dlim, 1),
9944 + "FREE (%p,#%d)%c %lld bytes",
9945 + sb, tag, __dlimit_char(dli), (long long)nr,
9949 +static inline int __dl_alloc_inode(struct super_block *sb,
9950 + tag_t tag, const char *_file, int _line)
9952 + struct dl_info *dli;
9955 + dli = locate_dl_info(sb, tag);
9959 + spin_lock(&dli->dl_lock);
9960 + dli->dl_inodes_used++;
9961 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9962 + spin_unlock(&dli->dl_lock);
9965 + vxlprintk(VXD_CBIT(dlim, 0),
9966 + "ALLOC (%p,#%d)%c inode (%d)",
9967 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9968 + return ret ? -ENOSPC : 0;
9971 +static inline void __dl_free_inode(struct super_block *sb,
9972 + tag_t tag, const char *_file, int _line)
9974 + struct dl_info *dli;
9976 + dli = locate_dl_info(sb, tag);
9980 + spin_lock(&dli->dl_lock);
9981 + if (dli->dl_inodes_used > 1)
9982 + dli->dl_inodes_used--;
9984 + dli->dl_inodes_used = 0;
9985 + spin_unlock(&dli->dl_lock);
9988 + vxlprintk(VXD_CBIT(dlim, 0),
9989 + "FREE (%p,#%d)%c inode",
9990 + sb, tag, __dlimit_char(dli), _file, _line);
9993 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
9994 + unsigned long long *free_blocks, unsigned long long *root_blocks,
9995 + const char *_file, int _line)
9997 + struct dl_info *dli;
9998 + uint64_t broot, bfree;
10000 + dli = locate_dl_info(sb, tag);
10004 + spin_lock(&dli->dl_lock);
10005 + broot = (dli->dl_space_total -
10006 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10007 + >> sb->s_blocksize_bits;
10008 + bfree = (dli->dl_space_total - dli->dl_space_used)
10009 + >> sb->s_blocksize_bits;
10010 + spin_unlock(&dli->dl_lock);
10012 + vxlprintk(VXD_CBIT(dlim, 2),
10013 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10014 + (long long)bfree, (long long)broot,
10015 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10017 + if (free_blocks) {
10018 + if (*free_blocks > bfree)
10019 + *free_blocks = bfree;
10021 + if (root_blocks) {
10022 + if (*root_blocks > broot)
10023 + *root_blocks = broot;
10025 + put_dl_info(dli);
10028 +#define dl_prealloc_space(in, bytes) \
10029 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10030 + __FILE__, __LINE__ )
10032 +#define dl_alloc_space(in, bytes) \
10033 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10034 + __FILE__, __LINE__ )
10036 +#define dl_reserve_space(in, bytes) \
10037 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10038 + __FILE__, __LINE__ )
10040 +#define dl_claim_space(in, bytes) (0)
10042 +#define dl_release_space(in, bytes) \
10043 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10044 + __FILE__, __LINE__ )
10046 +#define dl_free_space(in, bytes) \
10047 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10048 + __FILE__, __LINE__ )
10052 +#define dl_alloc_inode(in) \
10053 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10055 +#define dl_free_inode(in) \
10056 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10059 +#define dl_adjust_block(sb, tag, fb, rb) \
10060 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10064 +#warning duplicate inclusion
10066 diff -NurpP --minimal linux-2.6.36/include/linux/vs_inet.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_inet.h
10067 --- linux-2.6.36/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
10068 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_inet.h 2010-10-21 17:41:35.000000000 +0200
10070 +#ifndef _VS_INET_H
10071 +#define _VS_INET_H
10073 +#include "vserver/base.h"
10074 +#include "vserver/network.h"
10075 +#include "vserver/debug.h"
10077 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
10079 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
10080 + NIPQUAD((a)->mask), (a)->type
10081 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
10083 +#define NIPQUAD(addr) \
10084 + ((unsigned char *)&addr)[0], \
10085 + ((unsigned char *)&addr)[1], \
10086 + ((unsigned char *)&addr)[2], \
10087 + ((unsigned char *)&addr)[3]
10089 +#define NIPQUAD_FMT "%u.%u.%u.%u"
10093 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
10095 + __be32 ip = nxa->ip[0].s_addr;
10096 + __be32 mask = nxa->mask.s_addr;
10097 + __be32 bcast = ip | ~mask;
10100 + switch (nxa->type & tmask) {
10101 + case NXA_TYPE_MASK:
10102 + ret = (ip == (addr & mask));
10104 + case NXA_TYPE_ADDR:
10108 + /* fall through to broadcast */
10109 + case NXA_MOD_BCAST:
10110 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
10112 + case NXA_TYPE_RANGE:
10113 + ret = ((nxa->ip[0].s_addr <= addr) &&
10114 + (nxa->ip[1].s_addr > addr));
10116 + case NXA_TYPE_ANY:
10121 + vxdprintk(VXD_CBIT(net, 0),
10122 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
10123 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
10128 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
10130 + struct nx_addr_v4 *nxa;
10137 + /* allow 127.0.0.1 when remapping lback */
10138 + if ((tmask & NXA_LOOPBACK) &&
10139 + (addr == IPI_LOOPBACK) &&
10140 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10143 + /* check for lback address */
10144 + if ((tmask & NXA_MOD_LBACK) &&
10145 + (nxi->v4_lback.s_addr == addr))
10148 + /* check for broadcast address */
10149 + if ((tmask & NXA_MOD_BCAST) &&
10150 + (nxi->v4_bcast.s_addr == addr))
10153 + /* check for v4 addresses */
10154 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
10155 + if (v4_addr_match(nxa, addr, tmask))
10159 + vxdprintk(VXD_CBIT(net, 0),
10160 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
10161 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
10166 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
10168 + /* FIXME: needs full range checks */
10169 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
10173 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
10175 + struct nx_addr_v4 *ptr;
10177 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
10178 + if (v4_nx_addr_match(ptr, nxa, mask))
10183 +#include <net/inet_sock.h>
10186 + * Check if a given address matches for a socket
10188 + * nxi: the socket's nx_info if any
10189 + * addr: to be verified address
10192 +int v4_sock_addr_match (
10193 + struct nx_info *nxi,
10194 + struct inet_sock *inet,
10197 + __be32 saddr = inet->inet_rcv_saddr;
10198 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
10200 + if (addr && (saddr == addr || bcast == addr))
10203 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
10208 +/* inet related checks and helpers */
10212 +struct net_device;
10215 +#ifdef CONFIG_INET
10217 +#include <linux/netdevice.h>
10218 +#include <linux/inetdevice.h>
10219 +#include <net/inet_sock.h>
10220 +#include <net/inet_timewait_sock.h>
10223 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10224 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
10225 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
10229 + * check if address is covered by socket
10231 + * sk: the socket to check against
10232 + * addr: the address in question (must be != 0)
10236 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
10238 + struct nx_info *nxi = sk->sk_nx_info;
10239 + __be32 saddr = inet_rcv_saddr(sk);
10241 + vxdprintk(VXD_CBIT(net, 5),
10242 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
10243 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
10244 + (sk->sk_socket?sk->sk_socket->flags:0));
10246 + if (saddr) { /* direct address match */
10247 + return v4_addr_match(nxa, saddr, -1);
10248 + } else if (nxi) { /* match against nx_info */
10249 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
10250 + } else { /* unrestricted any socket */
10258 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
10260 + vxdprintk(VXD_CBIT(net, 1),
10261 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
10262 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
10263 + nxi ? dev_in_nx_info(dev, nxi) : 0);
10265 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10267 + if (dev_in_nx_info(dev, nxi))
10274 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
10280 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
10284 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
10286 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
10287 + nxi, nxi ? nxi->nx_id : 0, ifa,
10288 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
10290 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10292 + if (v4_ifa_in_nx_info(ifa, nxi))
10298 +struct nx_v4_sock_addr {
10299 + __be32 saddr; /* Address used for validation */
10300 + __be32 baddr; /* Address used for socket bind */
10304 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
10305 + struct nx_v4_sock_addr *nsa)
10307 + struct sock *sk = &inet->sk;
10308 + struct nx_info *nxi = sk->sk_nx_info;
10309 + __be32 saddr = addr->sin_addr.s_addr;
10310 + __be32 baddr = saddr;
10312 + vxdprintk(VXD_CBIT(net, 3),
10313 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
10314 + sk, sk->sk_nx_info, sk->sk_socket,
10315 + (sk->sk_socket ? sk->sk_socket->flags : 0),
10319 + if (saddr == INADDR_ANY) {
10320 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
10321 + baddr = nxi->v4.ip[0].s_addr;
10322 + } else if (saddr == IPI_LOOPBACK) {
10323 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10324 + baddr = nxi->v4_lback.s_addr;
10325 + } else { /* normal address bind */
10326 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
10327 + return -EADDRNOTAVAIL;
10331 + vxdprintk(VXD_CBIT(net, 3),
10332 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
10333 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
10335 + nsa->saddr = saddr;
10336 + nsa->baddr = baddr;
10341 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
10343 + inet->inet_saddr = nsa->baddr;
10344 + inet->inet_rcv_saddr = nsa->baddr;
10349 + * helper to simplify inet_lookup_listener
10351 + * nxi: the socket's nx_info if any
10352 + * addr: to be verified address
10353 + * saddr: socket address
10355 +static inline int v4_inet_addr_match (
10356 + struct nx_info *nxi,
10360 + if (addr && (saddr == addr))
10363 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
10367 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
10369 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
10370 + (addr == nxi->v4_lback.s_addr))
10371 + return IPI_LOOPBACK;
10376 +int nx_info_has_v4(struct nx_info *nxi)
10380 + if (NX_IPV4(nxi))
10382 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10387 +#else /* CONFIG_INET */
10390 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
10396 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10402 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10408 +int nx_info_has_v4(struct nx_info *nxi)
10413 +#endif /* CONFIG_INET */
10415 +#define current_nx_info_has_v4() \
10416 + nx_info_has_v4(current_nx_info())
10419 +// #warning duplicate inclusion
10421 diff -NurpP --minimal linux-2.6.36/include/linux/vs_inet6.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_inet6.h
10422 --- linux-2.6.36/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
10423 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_inet6.h 2010-10-21 13:09:36.000000000 +0200
10425 +#ifndef _VS_INET6_H
10426 +#define _VS_INET6_H
10428 +#include "vserver/base.h"
10429 +#include "vserver/network.h"
10430 +#include "vserver/debug.h"
10432 +#include <net/ipv6.h>
10434 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
10435 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
10438 +#ifdef CONFIG_IPV6
10441 +int v6_addr_match(struct nx_addr_v6 *nxa,
10442 + const struct in6_addr *addr, uint16_t mask)
10446 + switch (nxa->type & mask) {
10447 + case NXA_TYPE_MASK:
10448 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
10450 + case NXA_TYPE_ADDR:
10451 + ret = ipv6_addr_equal(&nxa->ip, addr);
10453 + case NXA_TYPE_ANY:
10457 + vxdprintk(VXD_CBIT(net, 0),
10458 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
10459 + nxa, NXAV6(nxa), addr, mask, ret);
10464 +int v6_addr_in_nx_info(struct nx_info *nxi,
10465 + const struct in6_addr *addr, uint16_t mask)
10467 + struct nx_addr_v6 *nxa;
10472 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
10473 + if (v6_addr_match(nxa, addr, mask))
10477 + vxdprintk(VXD_CBIT(net, 0),
10478 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
10479 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
10484 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
10486 + /* FIXME: needs full range checks */
10487 + return v6_addr_match(nxa, &addr->ip, mask);
10491 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
10493 + struct nx_addr_v6 *ptr;
10495 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
10496 + if (v6_nx_addr_match(ptr, nxa, mask))
10503 + * Check if a given address matches for a socket
10505 + * nxi: the socket's nx_info if any
10506 + * addr: to be verified address
10509 +int v6_sock_addr_match (
10510 + struct nx_info *nxi,
10511 + struct inet_sock *inet,
10512 + struct in6_addr *addr)
10514 + struct sock *sk = &inet->sk;
10515 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10517 + if (!ipv6_addr_any(addr) &&
10518 + ipv6_addr_equal(saddr, addr))
10520 + if (ipv6_addr_any(saddr))
10521 + return v6_addr_in_nx_info(nxi, addr, -1);
10526 + * check if address is covered by socket
10528 + * sk: the socket to check against
10529 + * addr: the address in question (must be != 0)
10533 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
10535 + struct nx_info *nxi = sk->sk_nx_info;
10536 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10538 + vxdprintk(VXD_CBIT(net, 5),
10539 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
10540 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
10541 + (sk->sk_socket?sk->sk_socket->flags:0));
10543 + if (!ipv6_addr_any(saddr)) { /* direct address match */
10544 + return v6_addr_match(nxa, saddr, -1);
10545 + } else if (nxi) { /* match against nx_info */
10546 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
10547 + } else { /* unrestricted any socket */
10553 +/* inet related checks and helpers */
10557 +struct net_device;
10561 +#include <linux/netdevice.h>
10562 +#include <linux/inetdevice.h>
10563 +#include <net/inet_timewait_sock.h>
10566 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10567 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
10568 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
10573 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
10579 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
10583 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
10585 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
10586 + nxi, nxi ? nxi->nx_id : 0, ifa,
10587 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
10589 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10591 + if (v6_ifa_in_nx_info(ifa, nxi))
10597 +struct nx_v6_sock_addr {
10598 + struct in6_addr saddr; /* Address used for validation */
10599 + struct in6_addr baddr; /* Address used for socket bind */
10603 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
10604 + struct nx_v6_sock_addr *nsa)
10606 + // struct sock *sk = &inet->sk;
10607 + // struct nx_info *nxi = sk->sk_nx_info;
10608 + struct in6_addr saddr = addr->sin6_addr;
10609 + struct in6_addr baddr = saddr;
10611 + nsa->saddr = saddr;
10612 + nsa->baddr = baddr;
10617 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10619 + // struct sock *sk = &inet->sk;
10620 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10622 + // *saddr = nsa->baddr;
10623 + // inet->inet_saddr = nsa->baddr;
10627 +int nx_info_has_v6(struct nx_info *nxi)
10631 + if (NX_IPV6(nxi))
10636 +#else /* CONFIG_IPV6 */
10639 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10646 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10652 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10658 +int nx_info_has_v6(struct nx_info *nxi)
10663 +#endif /* CONFIG_IPV6 */
10665 +#define current_nx_info_has_v6() \
10666 + nx_info_has_v6(current_nx_info())
10669 +#warning duplicate inclusion
10671 diff -NurpP --minimal linux-2.6.36/include/linux/vs_limit.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_limit.h
10672 --- linux-2.6.36/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
10673 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_limit.h 2010-10-21 13:09:36.000000000 +0200
10675 +#ifndef _VS_LIMIT_H
10676 +#define _VS_LIMIT_H
10678 +#include "vserver/limit.h"
10679 +#include "vserver/base.h"
10680 +#include "vserver/context.h"
10681 +#include "vserver/debug.h"
10682 +#include "vserver/context.h"
10683 +#include "vserver/limit_int.h"
10686 +#define vx_acc_cres(v, d, p, r) \
10687 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10689 +#define vx_acc_cres_cond(x, d, p, r) \
10690 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10691 + r, d, p, __FILE__, __LINE__)
10694 +#define vx_add_cres(v, a, p, r) \
10695 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10696 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10698 +#define vx_add_cres_cond(x, a, p, r) \
10699 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10700 + r, a, p, __FILE__, __LINE__)
10701 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10704 +/* process and file limits */
10706 +#define vx_nproc_inc(p) \
10707 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10709 +#define vx_nproc_dec(p) \
10710 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10712 +#define vx_files_inc(f) \
10713 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10715 +#define vx_files_dec(f) \
10716 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10718 +#define vx_locks_inc(l) \
10719 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10721 +#define vx_locks_dec(l) \
10722 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10724 +#define vx_openfd_inc(f) \
10725 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10727 +#define vx_openfd_dec(f) \
10728 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10731 +#define vx_cres_avail(v, n, r) \
10732 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10735 +#define vx_nproc_avail(n) \
10736 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10738 +#define vx_files_avail(n) \
10739 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10741 +#define vx_locks_avail(n) \
10742 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10744 +#define vx_openfd_avail(n) \
10745 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10748 +/* dentry limits */
10750 +#define vx_dentry_inc(d) do { \
10751 + if (atomic_read(&d->d_count) == 1) \
10752 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10755 +#define vx_dentry_dec(d) do { \
10756 + if (atomic_read(&d->d_count) == 0) \
10757 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10760 +#define vx_dentry_avail(n) \
10761 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10764 +/* socket limits */
10766 +#define vx_sock_inc(s) \
10767 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10769 +#define vx_sock_dec(s) \
10770 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10772 +#define vx_sock_avail(n) \
10773 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10776 +/* ipc resource limits */
10778 +#define vx_ipcmsg_add(v, u, a) \
10779 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10781 +#define vx_ipcmsg_sub(v, u, a) \
10782 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10784 +#define vx_ipcmsg_avail(v, a) \
10785 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10788 +#define vx_ipcshm_add(v, k, a) \
10789 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10791 +#define vx_ipcshm_sub(v, k, a) \
10792 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10794 +#define vx_ipcshm_avail(v, a) \
10795 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10798 +#define vx_semary_inc(a) \
10799 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10801 +#define vx_semary_dec(a) \
10802 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10805 +#define vx_nsems_add(a,n) \
10806 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10808 +#define vx_nsems_sub(a,n) \
10809 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10813 +#warning duplicate inclusion
10815 diff -NurpP --minimal linux-2.6.36/include/linux/vs_memory.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_memory.h
10816 --- linux-2.6.36/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
10817 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_memory.h 2010-10-21 13:09:36.000000000 +0200
10819 +#ifndef _VS_MEMORY_H
10820 +#define _VS_MEMORY_H
10822 +#include "vserver/limit.h"
10823 +#include "vserver/base.h"
10824 +#include "vserver/context.h"
10825 +#include "vserver/debug.h"
10826 +#include "vserver/context.h"
10827 +#include "vserver/limit_int.h"
10830 + VXPT_UNKNOWN = 0,
10839 +#define vx_page_fault(mm, vma, type, ret)
10843 +void __vx_page_fault(struct mm_struct *mm,
10844 + struct vm_area_struct *vma, int type, int ret)
10846 + struct vx_info *vxi = mm->mm_vx_info;
10849 + static char *page_type[6] =
10850 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
10851 + static char *page_what[4] =
10852 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
10858 + what = (ret & 0x3);
10860 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
10861 + type, what, ret, page_type[type], page_what[what]);
10863 + if (ret & VM_FAULT_WRITE)
10865 + atomic_inc(&vxi->cacct.page[type][what]);
10868 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
10872 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
10875 +#warning duplicate inclusion
10877 diff -NurpP --minimal linux-2.6.36/include/linux/vs_network.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_network.h
10878 --- linux-2.6.36/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
10879 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_network.h 2010-10-21 13:09:36.000000000 +0200
10881 +#ifndef _NX_VS_NETWORK_H
10882 +#define _NX_VS_NETWORK_H
10884 +#include "vserver/context.h"
10885 +#include "vserver/network.h"
10886 +#include "vserver/base.h"
10887 +#include "vserver/check.h"
10888 +#include "vserver/debug.h"
10890 +#include <linux/sched.h>
10893 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
10895 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
10896 + const char *_file, int _line)
10901 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
10902 + nxi, nxi ? nxi->nx_id : 0,
10903 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10906 + atomic_inc(&nxi->nx_usecnt);
10911 +extern void free_nx_info(struct nx_info *);
10913 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
10915 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
10920 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
10921 + nxi, nxi ? nxi->nx_id : 0,
10922 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10925 + if (atomic_dec_and_test(&nxi->nx_usecnt))
10926 + free_nx_info(nxi);
10930 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
10932 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10933 + const char *_file, int _line)
10936 + vxlprintk(VXD_CBIT(nid, 3),
10937 + "init_nx_info(%p[#%d.%d])",
10938 + nxi, nxi ? nxi->nx_id : 0,
10939 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10942 + atomic_inc(&nxi->nx_usecnt);
10948 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
10950 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10951 + const char *_file, int _line)
10953 + struct nx_info *nxo;
10958 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
10959 + nxi, nxi ? nxi->nx_id : 0,
10960 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10963 + atomic_inc(&nxi->nx_usecnt);
10964 + nxo = xchg(nxp, nxi);
10968 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
10970 +static inline void __clr_nx_info(struct nx_info **nxp,
10971 + const char *_file, int _line)
10973 + struct nx_info *nxo;
10975 + nxo = xchg(nxp, NULL);
10979 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
10980 + nxo, nxo ? nxo->nx_id : 0,
10981 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
10984 + if (atomic_dec_and_test(&nxo->nx_usecnt))
10985 + free_nx_info(nxo);
10989 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
10991 +static inline void __claim_nx_info(struct nx_info *nxi,
10992 + struct task_struct *task, const char *_file, int _line)
10994 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
10995 + nxi, nxi ? nxi->nx_id : 0,
10996 + nxi?atomic_read(&nxi->nx_usecnt):0,
10997 + nxi?atomic_read(&nxi->nx_tasks):0,
10998 + task, _file, _line);
11000 + atomic_inc(&nxi->nx_tasks);
11004 +extern void unhash_nx_info(struct nx_info *);
11006 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
11008 +static inline void __release_nx_info(struct nx_info *nxi,
11009 + struct task_struct *task, const char *_file, int _line)
11011 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
11012 + nxi, nxi ? nxi->nx_id : 0,
11013 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11014 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
11015 + task, _file, _line);
11019 + if (atomic_dec_and_test(&nxi->nx_tasks))
11020 + unhash_nx_info(nxi);
11024 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
11026 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
11027 + const char *_file, int _line)
11029 + struct nx_info *nxi;
11032 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
11033 + p, _file, _line);
11034 + nxi = __get_nx_info(p->nx_info, _file, _line);
11040 +static inline void exit_nx_info(struct task_struct *p)
11043 + release_nx_info(p->nx_info, p);
11048 +#warning duplicate inclusion
11050 diff -NurpP --minimal linux-2.6.36/include/linux/vs_pid.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_pid.h
11051 --- linux-2.6.36/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
11052 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_pid.h 2010-10-21 13:09:36.000000000 +0200
11057 +#include "vserver/base.h"
11058 +#include "vserver/check.h"
11059 +#include "vserver/context.h"
11060 +#include "vserver/debug.h"
11061 +#include "vserver/pid.h"
11062 +#include <linux/pid_namespace.h>
11065 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
11068 +int vx_proc_task_visible(struct task_struct *task)
11070 + if ((task->pid == 1) &&
11071 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
11072 + /* show a blend through init */
11074 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
11081 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
11086 +struct task_struct *vx_find_proc_task_by_pid(int pid)
11088 + struct task_struct *task = find_task_by_real_pid(pid);
11090 + if (task && !vx_proc_task_visible(task)) {
11091 + vxdprintk(VXD_CBIT(misc, 6),
11092 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
11093 + task, task->xid, task->pid,
11094 + current, current->xid, current->pid);
11103 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
11105 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
11107 + if (task && !vx_proc_task_visible(task)) {
11108 + vxdprintk(VXD_CBIT(misc, 6),
11109 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
11110 + task, task->xid, task->pid,
11111 + current, current->xid, current->pid);
11112 + put_task_struct(task);
11121 +struct task_struct *vx_child_reaper(struct task_struct *p)
11123 + struct vx_info *vxi = p->vx_info;
11124 + struct task_struct *reaper = child_reaper(p);
11129 + BUG_ON(!p->vx_info->vx_reaper);
11131 + /* child reaper for the guest reaper */
11132 + if (vxi->vx_reaper == p)
11135 + reaper = vxi->vx_reaper;
11137 + vxdprintk(VXD_CBIT(xid, 7),
11138 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
11139 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
11147 +#warning duplicate inclusion
11149 diff -NurpP --minimal linux-2.6.36/include/linux/vs_sched.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_sched.h
11150 --- linux-2.6.36/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
11151 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_sched.h 2010-10-24 15:13:57.000000000 +0200
11153 +#ifndef _VS_SCHED_H
11154 +#define _VS_SCHED_H
11156 +#include "vserver/base.h"
11157 +#include "vserver/context.h"
11158 +#include "vserver/sched.h"
11161 +#define MAX_PRIO_BIAS 20
11162 +#define MIN_PRIO_BIAS -20
11165 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
11167 + struct vx_info *vxi = p->vx_info;
11170 + prio += vx_cpu(vxi, sched_pc).prio_bias;
11174 +static inline void vx_account_user(struct vx_info *vxi,
11175 + cputime_t cputime, int nice)
11179 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
11182 +static inline void vx_account_system(struct vx_info *vxi,
11183 + cputime_t cputime, int idle)
11187 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
11191 +#warning duplicate inclusion
11193 diff -NurpP --minimal linux-2.6.36/include/linux/vs_socket.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_socket.h
11194 --- linux-2.6.36/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
11195 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_socket.h 2010-10-21 13:09:36.000000000 +0200
11197 +#ifndef _VS_SOCKET_H
11198 +#define _VS_SOCKET_H
11200 +#include "vserver/debug.h"
11201 +#include "vserver/base.h"
11202 +#include "vserver/cacct.h"
11203 +#include "vserver/context.h"
11204 +#include "vserver/tag.h"
11207 +/* socket accounting */
11209 +#include <linux/socket.h>
11211 +static inline int vx_sock_type(int family)
11213 + switch (family) {
11215 + return VXA_SOCK_UNSPEC;
11217 + return VXA_SOCK_UNIX;
11219 + return VXA_SOCK_INET;
11221 + return VXA_SOCK_INET6;
11223 + return VXA_SOCK_PACKET;
11225 + return VXA_SOCK_OTHER;
11229 +#define vx_acc_sock(v, f, p, s) \
11230 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
11232 +static inline void __vx_acc_sock(struct vx_info *vxi,
11233 + int family, int pos, int size, char *file, int line)
11236 + int type = vx_sock_type(family);
11238 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
11239 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
11243 +#define vx_sock_recv(sk, s) \
11244 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
11245 +#define vx_sock_send(sk, s) \
11246 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
11247 +#define vx_sock_fail(sk, s) \
11248 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
11251 +#define sock_vx_init(s) do { \
11252 + (s)->sk_xid = 0; \
11253 + (s)->sk_vx_info = NULL; \
11256 +#define sock_nx_init(s) do { \
11257 + (s)->sk_nid = 0; \
11258 + (s)->sk_nx_info = NULL; \
11262 +#warning duplicate inclusion
11264 diff -NurpP --minimal linux-2.6.36/include/linux/vs_tag.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_tag.h
11265 --- linux-2.6.36/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
11266 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_tag.h 2010-10-21 13:09:36.000000000 +0200
11271 +#include <linux/vserver/tag.h>
11273 +/* check conditions */
11275 +#define DX_ADMIN 0x0001
11276 +#define DX_WATCH 0x0002
11277 +#define DX_HOSTID 0x0008
11279 +#define DX_IDENT 0x0010
11281 +#define DX_ARG_MASK 0x0010
11284 +#define dx_task_tag(t) ((t)->tag)
11286 +#define dx_current_tag() dx_task_tag(current)
11288 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
11290 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
11294 + * check current context for ADMIN/WATCH and
11295 + * optionally against supplied argument
11297 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
11299 + if (mode & DX_ARG_MASK) {
11300 + if ((mode & DX_IDENT) && (id == cid))
11303 + return (((mode & DX_ADMIN) && (cid == 0)) ||
11304 + ((mode & DX_WATCH) && (cid == 1)) ||
11305 + ((mode & DX_HOSTID) && (id == 0)));
11309 +int dx_permission(const struct inode *inode, int mask);
11313 +#warning duplicate inclusion
11315 diff -NurpP --minimal linux-2.6.36/include/linux/vs_time.h linux-2.6.36-vs2.3.0.36.38/include/linux/vs_time.h
11316 --- linux-2.6.36/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
11317 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vs_time.h 2010-10-21 14:25:37.000000000 +0200
11319 +#ifndef _VS_TIME_H
11320 +#define _VS_TIME_H
11323 +/* time faking stuff */
11325 +#ifdef CONFIG_VSERVER_VTIME
11327 +extern void vx_adjust_timespec(struct timespec *ts);
11328 +extern int vx_settimeofday(struct timespec *ts);
11331 +#define vx_adjust_timespec(t) do { } while (0)
11332 +#define vx_settimeofday(t) do_settimeofday(t)
11336 +#warning duplicate inclusion
11338 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/Kbuild linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/Kbuild
11339 --- linux-2.6.36/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11340 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/Kbuild 2010-10-21 13:09:36.000000000 +0200
11343 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11344 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11345 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11346 + debug_cmd.h device_cmd.h
11348 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11350 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/base.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/base.h
11351 --- linux-2.6.36/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
11352 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/base.h 2010-10-21 13:09:36.000000000 +0200
11354 +#ifndef _VX_BASE_H
11355 +#define _VX_BASE_H
11358 +/* context state changes */
11370 +#define vx_task_xid(t) ((t)->xid)
11372 +#define vx_current_xid() vx_task_xid(current)
11374 +#define current_vx_info() (current->vx_info)
11377 +#define nx_task_nid(t) ((t)->nid)
11379 +#define nx_current_nid() nx_task_nid(current)
11381 +#define current_nx_info() (current->nx_info)
11384 +/* generic flag merging */
11386 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
11388 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11390 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
11392 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
11395 +/* context flags */
11397 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
11399 +#define vx_current_flags() __vx_flags(current_vx_info())
11401 +#define vx_info_flags(v, m, f) \
11402 + vs_check_flags(__vx_flags(v), m, f)
11404 +#define task_vx_flags(t, m, f) \
11405 + ((t) && vx_info_flags((t)->vx_info, m, f))
11407 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11410 +/* context caps */
11412 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
11414 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
11416 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
11418 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
11422 +/* network flags */
11424 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
11426 +#define nx_current_flags() __nx_flags(current_nx_info())
11428 +#define nx_info_flags(n, m, f) \
11429 + vs_check_flags(__nx_flags(n), m, f)
11431 +#define task_nx_flags(t, m, f) \
11432 + ((t) && nx_info_flags((t)->nx_info, m, f))
11434 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11437 +/* network caps */
11439 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
11441 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
11443 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
11445 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
11448 +/* context mask capabilities */
11450 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11452 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
11454 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
11457 +/* context bcap mask */
11459 +#define __vx_bcaps(v) ((v)->vx_bcaps)
11461 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
11464 +/* mask given bcaps */
11466 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11468 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
11471 +/* masked cap_bset */
11473 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
11475 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
11478 +#define vx_info_mbcap(v, b) \
11479 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11480 + vx_info_bcaps(v, b) : (b))
11482 +#define task_vx_mbcap(t, b) \
11483 + vx_info_mbcap((t)->vx_info, (t)->b)
11485 +#define vx_mbcap(b) task_vx_mbcap(current, b)
11488 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11490 +#define vx_capable(b, c) (capable(b) || \
11491 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
11493 +#define nx_capable(b, c) (capable(b) || \
11494 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
11496 +#define vx_task_initpid(t, n) \
11497 + ((t)->vx_info && \
11498 + ((t)->vx_info->vx_initpid == (n)))
11500 +#define vx_current_initpid(n) vx_task_initpid(current, n)
11503 +/* context unshare mask */
11505 +#define __vx_umask(v) ((v)->vx_umask)
11507 +#define vx_current_umask() __vx_umask(current_vx_info())
11509 +#define vx_can_unshare(b, f) (capable(b) || \
11510 + (cap_raised(current_cap(), b) && \
11511 + !((f) & ~vx_current_umask())))
11514 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
11516 +#define vx_info_state(v, m) (__vx_state(v) & (m))
11519 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
11521 +#define nx_info_state(n, m) (__nx_state(n) & (m))
11524 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/cacct.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cacct.h
11525 --- linux-2.6.36/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
11526 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cacct.h 2010-10-21 13:09:36.000000000 +0200
11528 +#ifndef _VX_CACCT_H
11529 +#define _VX_CACCT_H
11532 +enum sock_acc_field {
11533 + VXA_SOCK_UNSPEC = 0,
11539 + VXA_SOCK_SIZE /* array size */
11542 +#endif /* _VX_CACCT_H */
11543 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/cacct_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cacct_cmd.h
11544 --- linux-2.6.36/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
11545 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cacct_cmd.h 2010-10-21 13:09:36.000000000 +0200
11547 +#ifndef _VX_CACCT_CMD_H
11548 +#define _VX_CACCT_CMD_H
11551 +/* virtual host info name commands */
11553 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
11555 +struct vcmd_sock_stat_v0 {
11557 + uint32_t count[3];
11558 + uint64_t total[3];
11564 +#include <linux/compiler.h>
11566 +extern int vc_sock_stat(struct vx_info *, void __user *);
11568 +#endif /* __KERNEL__ */
11569 +#endif /* _VX_CACCT_CMD_H */
11570 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/cacct_def.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cacct_def.h
11571 --- linux-2.6.36/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
11572 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cacct_def.h 2010-10-21 13:09:36.000000000 +0200
11574 +#ifndef _VX_CACCT_DEF_H
11575 +#define _VX_CACCT_DEF_H
11577 +#include <asm/atomic.h>
11578 +#include <linux/vserver/cacct.h>
11581 +struct _vx_sock_acc {
11582 + atomic_long_t count;
11583 + atomic_long_t total;
11586 +/* context sub struct */
11588 +struct _vx_cacct {
11589 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11590 + atomic_t slab[8];
11591 + atomic_t page[6][8];
11594 +#ifdef CONFIG_VSERVER_DEBUG
11596 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11600 + printk("\t_vx_cacct:");
11601 + for (i = 0; i < 6; i++) {
11602 + struct _vx_sock_acc *ptr = cacct->sock[i];
11604 + printk("\t [%d] =", i);
11605 + for (j = 0; j < 3; j++) {
11606 + printk(" [%d] = %8lu, %8lu", j,
11607 + atomic_long_read(&ptr[j].count),
11608 + atomic_long_read(&ptr[j].total));
11616 +#endif /* _VX_CACCT_DEF_H */
11617 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/cacct_int.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cacct_int.h
11618 --- linux-2.6.36/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
11619 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cacct_int.h 2010-10-21 13:09:36.000000000 +0200
11621 +#ifndef _VX_CACCT_INT_H
11622 +#define _VX_CACCT_INT_H
11628 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11630 + return atomic_long_read(&cacct->sock[type][pos].count);
11635 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11637 + return atomic_long_read(&cacct->sock[type][pos].total);
11640 +#endif /* __KERNEL__ */
11641 +#endif /* _VX_CACCT_INT_H */
11642 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/check.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/check.h
11643 --- linux-2.6.36/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
11644 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/check.h 2010-10-21 13:09:36.000000000 +0200
11646 +#ifndef _VS_CHECK_H
11647 +#define _VS_CHECK_H
11650 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
11652 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11653 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
11655 +#define MIN_D_CONTEXT 65536
11658 +/* check conditions */
11660 +#define VS_ADMIN 0x0001
11661 +#define VS_WATCH 0x0002
11662 +#define VS_HIDE 0x0004
11663 +#define VS_HOSTID 0x0008
11665 +#define VS_IDENT 0x0010
11666 +#define VS_EQUIV 0x0020
11667 +#define VS_PARENT 0x0040
11668 +#define VS_CHILD 0x0080
11670 +#define VS_ARG_MASK 0x00F0
11672 +#define VS_DYNAMIC 0x0100
11673 +#define VS_STATIC 0x0200
11675 +#define VS_ATR_MASK 0x0F00
11677 +#ifdef CONFIG_VSERVER_PRIVACY
11678 +#define VS_ADMIN_P (0)
11679 +#define VS_WATCH_P (0)
11681 +#define VS_ADMIN_P VS_ADMIN
11682 +#define VS_WATCH_P VS_WATCH
11685 +#define VS_HARDIRQ 0x1000
11686 +#define VS_SOFTIRQ 0x2000
11687 +#define VS_IRQ 0x4000
11689 +#define VS_IRQ_MASK 0xF000
11691 +#include <linux/hardirq.h>
11694 + * check current context for ADMIN/WATCH and
11695 + * optionally against supplied argument
11697 +static inline int __vs_check(int cid, int id, unsigned int mode)
11699 + if (mode & VS_ARG_MASK) {
11700 + if ((mode & VS_IDENT) && (id == cid))
11703 + if (mode & VS_ATR_MASK) {
11704 + if ((mode & VS_DYNAMIC) &&
11705 + (id >= MIN_D_CONTEXT) &&
11706 + (id <= MAX_S_CONTEXT))
11708 + if ((mode & VS_STATIC) &&
11709 + (id > 1) && (id < MIN_D_CONTEXT))
11712 + if (mode & VS_IRQ_MASK) {
11713 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11715 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11717 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11720 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11721 + ((mode & VS_WATCH) && (cid == 1)) ||
11722 + ((mode & VS_HOSTID) && (id == 0)));
11725 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11727 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11730 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11732 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11735 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/context.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/context.h
11736 --- linux-2.6.36/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
11737 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/context.h 2010-10-21 13:09:36.000000000 +0200
11739 +#ifndef _VX_CONTEXT_H
11740 +#define _VX_CONTEXT_H
11742 +#include <linux/types.h>
11743 +#include <linux/capability.h>
11746 +/* context flags */
11748 +#define VXF_INFO_SCHED 0x00000002
11749 +#define VXF_INFO_NPROC 0x00000004
11750 +#define VXF_INFO_PRIVATE 0x00000008
11752 +#define VXF_INFO_INIT 0x00000010
11753 +#define VXF_INFO_HIDE 0x00000020
11754 +#define VXF_INFO_ULIMIT 0x00000040
11755 +#define VXF_INFO_NSPACE 0x00000080
11757 +#define VXF_SCHED_HARD 0x00000100
11758 +#define VXF_SCHED_PRIO 0x00000200
11759 +#define VXF_SCHED_PAUSE 0x00000400
11761 +#define VXF_VIRT_MEM 0x00010000
11762 +#define VXF_VIRT_UPTIME 0x00020000
11763 +#define VXF_VIRT_CPU 0x00040000
11764 +#define VXF_VIRT_LOAD 0x00080000
11765 +#define VXF_VIRT_TIME 0x00100000
11767 +#define VXF_HIDE_MOUNT 0x01000000
11768 +/* was VXF_HIDE_NETIF 0x02000000 */
11769 +#define VXF_HIDE_VINFO 0x04000000
11771 +#define VXF_STATE_SETUP (1ULL << 32)
11772 +#define VXF_STATE_INIT (1ULL << 33)
11773 +#define VXF_STATE_ADMIN (1ULL << 34)
11775 +#define VXF_SC_HELPER (1ULL << 36)
11776 +#define VXF_REBOOT_KILL (1ULL << 37)
11777 +#define VXF_PERSISTENT (1ULL << 38)
11779 +#define VXF_FORK_RSS (1ULL << 48)
11780 +#define VXF_PROLIFIC (1ULL << 49)
11782 +#define VXF_IGNEG_NICE (1ULL << 52)
11784 +#define VXF_ONE_TIME (0x0007ULL << 32)
11786 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11789 +/* context migration */
11791 +#define VXM_SET_INIT 0x00000001
11792 +#define VXM_SET_REAPER 0x00000002
11794 +/* context caps */
11796 +#define VXC_CAP_MASK 0x00000000
11798 +#define VXC_SET_UTSNAME 0x00000001
11799 +#define VXC_SET_RLIMIT 0x00000002
11800 +#define VXC_FS_SECURITY 0x00000004
11801 +#define VXC_FS_TRUSTED 0x00000008
11802 +#define VXC_TIOCSTI 0x00000010
11804 +/* was VXC_RAW_ICMP 0x00000100 */
11805 +#define VXC_SYSLOG 0x00001000
11806 +#define VXC_OOM_ADJUST 0x00002000
11807 +#define VXC_AUDIT_CONTROL 0x00004000
11809 +#define VXC_SECURE_MOUNT 0x00010000
11810 +#define VXC_SECURE_REMOUNT 0x00020000
11811 +#define VXC_BINARY_MOUNT 0x00040000
11813 +#define VXC_QUOTA_CTL 0x00100000
11814 +#define VXC_ADMIN_MAPPER 0x00200000
11815 +#define VXC_ADMIN_CLOOP 0x00400000
11817 +#define VXC_KTHREAD 0x01000000
11818 +#define VXC_NAMESPACE 0x02000000
11823 +#include <linux/list.h>
11824 +#include <linux/spinlock.h>
11825 +#include <linux/rcupdate.h>
11827 +#include "limit_def.h"
11828 +#include "sched_def.h"
11829 +#include "cvirt_def.h"
11830 +#include "cacct_def.h"
11831 +#include "device_def.h"
11833 +#define VX_SPACES 2
11835 +struct _vx_info_pc {
11836 + struct _vx_sched_pc sched_pc;
11837 + struct _vx_cvirt_pc cvirt_pc;
11841 + struct hlist_node vx_hlist; /* linked list of contexts */
11842 + xid_t vx_id; /* context id */
11843 + atomic_t vx_usecnt; /* usage count */
11844 + atomic_t vx_tasks; /* tasks count */
11845 + struct vx_info *vx_parent; /* parent context */
11846 + int vx_state; /* context state */
11848 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
11849 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
11850 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
11852 + uint64_t vx_flags; /* context flags */
11853 + uint64_t vx_ccaps; /* context caps (vserver) */
11854 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11855 + unsigned long vx_umask; /* unshare mask (guest) */
11857 + struct task_struct *vx_reaper; /* guest reaper process */
11858 + pid_t vx_initpid; /* PID of guest init */
11859 + int64_t vx_badness_bias; /* OOM points bias */
11861 + struct _vx_limit limit; /* vserver limits */
11862 + struct _vx_sched sched; /* vserver scheduler */
11863 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11864 + struct _vx_cacct cacct; /* context accounting */
11866 + struct _vx_device dmap; /* default device map targets */
11868 +#ifndef CONFIG_SMP
11869 + struct _vx_info_pc info_pc; /* per cpu data */
11871 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11874 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11875 + int reboot_cmd; /* last sys_reboot() cmd */
11876 + int exit_code; /* last process exit code */
11878 + char vx_name[65]; /* vserver name */
11881 +#ifndef CONFIG_SMP
11882 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11883 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11885 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11886 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11889 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11892 +struct vx_info_save {
11893 + struct vx_info *vxi;
11898 +/* status flags */
11900 +#define VXS_HASHED 0x0001
11901 +#define VXS_PAUSED 0x0010
11902 +#define VXS_SHUTDOWN 0x0100
11903 +#define VXS_HELPER 0x1000
11904 +#define VXS_RELEASED 0x8000
11907 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11908 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11910 +extern struct vx_info *lookup_vx_info(int);
11911 +extern struct vx_info *lookup_or_create_vx_info(int);
11913 +extern int get_xid_list(int, unsigned int *, int);
11914 +extern int xid_is_hashed(xid_t);
11916 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11918 +extern long vs_state_change(struct vx_info *, unsigned int);
11921 +#endif /* __KERNEL__ */
11922 +#endif /* _VX_CONTEXT_H */
11923 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/context_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/context_cmd.h
11924 --- linux-2.6.36/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
11925 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/context_cmd.h 2010-10-21 13:09:36.000000000 +0200
11927 +#ifndef _VX_CONTEXT_CMD_H
11928 +#define _VX_CONTEXT_CMD_H
11931 +/* vinfo commands */
11933 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
11936 +extern int vc_task_xid(uint32_t);
11938 +#endif /* __KERNEL__ */
11940 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
11942 +struct vcmd_vx_info_v0 {
11944 + uint32_t initpid;
11945 + /* more to come */
11949 +extern int vc_vx_info(struct vx_info *, void __user *);
11951 +#endif /* __KERNEL__ */
11953 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
11955 +struct vcmd_ctx_stat_v0 {
11958 + /* more to come */
11962 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11964 +#endif /* __KERNEL__ */
11966 +/* context commands */
11968 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
11969 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
11971 +struct vcmd_ctx_create {
11972 + uint64_t flagword;
11975 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
11976 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
11978 +struct vcmd_ctx_migrate {
11979 + uint64_t flagword;
11983 +extern int vc_ctx_create(uint32_t, void __user *);
11984 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11986 +#endif /* __KERNEL__ */
11989 +/* flag commands */
11991 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
11992 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
11994 +struct vcmd_ctx_flags_v0 {
11995 + uint64_t flagword;
12000 +extern int vc_get_cflags(struct vx_info *, void __user *);
12001 +extern int vc_set_cflags(struct vx_info *, void __user *);
12003 +#endif /* __KERNEL__ */
12006 +/* context caps commands */
12008 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
12009 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
12011 +struct vcmd_ctx_caps_v1 {
12017 +extern int vc_get_ccaps(struct vx_info *, void __user *);
12018 +extern int vc_set_ccaps(struct vx_info *, void __user *);
12020 +#endif /* __KERNEL__ */
12023 +/* bcaps commands */
12025 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
12026 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
12028 +struct vcmd_bcaps {
12034 +extern int vc_get_bcaps(struct vx_info *, void __user *);
12035 +extern int vc_set_bcaps(struct vx_info *, void __user *);
12037 +#endif /* __KERNEL__ */
12040 +/* umask commands */
12042 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
12043 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
12045 +struct vcmd_umask {
12051 +extern int vc_get_umask(struct vx_info *, void __user *);
12052 +extern int vc_set_umask(struct vx_info *, void __user *);
12054 +#endif /* __KERNEL__ */
12059 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
12060 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
12062 +struct vcmd_badness_v0 {
12067 +extern int vc_get_badness(struct vx_info *, void __user *);
12068 +extern int vc_set_badness(struct vx_info *, void __user *);
12070 +#endif /* __KERNEL__ */
12071 +#endif /* _VX_CONTEXT_CMD_H */
12072 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/cvirt.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cvirt.h
12073 --- linux-2.6.36/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
12074 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cvirt.h 2010-10-21 13:09:36.000000000 +0200
12076 +#ifndef _VX_CVIRT_H
12077 +#define _VX_CVIRT_H
12084 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12089 +void vx_update_load(struct vx_info *);
12092 +int vx_do_syslog(int, char __user *, int);
12094 +#endif /* __KERNEL__ */
12095 +#endif /* _VX_CVIRT_H */
12096 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/cvirt_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cvirt_cmd.h
12097 --- linux-2.6.36/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
12098 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cvirt_cmd.h 2010-10-21 13:09:36.000000000 +0200
12100 +#ifndef _VX_CVIRT_CMD_H
12101 +#define _VX_CVIRT_CMD_H
12104 +/* virtual host info name commands */
12106 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
12107 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
12109 +struct vcmd_vhi_name_v0 {
12115 +enum vhi_name_field {
12116 + VHIN_CONTEXT = 0,
12128 +#include <linux/compiler.h>
12130 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
12131 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
12133 +#endif /* __KERNEL__ */
12135 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
12137 +struct vcmd_virt_stat_v0 {
12140 + uint32_t nr_threads;
12141 + uint32_t nr_running;
12142 + uint32_t nr_uninterruptible;
12143 + uint32_t nr_onhold;
12144 + uint32_t nr_forks;
12145 + uint32_t load[3];
12149 +extern int vc_virt_stat(struct vx_info *, void __user *);
12151 +#endif /* __KERNEL__ */
12152 +#endif /* _VX_CVIRT_CMD_H */
12153 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/cvirt_def.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cvirt_def.h
12154 --- linux-2.6.36/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
12155 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/cvirt_def.h 2010-10-21 14:26:47.000000000 +0200
12157 +#ifndef _VX_CVIRT_DEF_H
12158 +#define _VX_CVIRT_DEF_H
12160 +#include <linux/jiffies.h>
12161 +#include <linux/spinlock.h>
12162 +#include <linux/wait.h>
12163 +#include <linux/time.h>
12164 +#include <asm/atomic.h>
12167 +struct _vx_usage_stat {
12171 + uint64_t softirq;
12177 +struct _vx_syslog {
12178 + wait_queue_head_t log_wait;
12179 + spinlock_t logbuf_lock; /* lock for the log buffer */
12181 + unsigned long log_start; /* next char to be read by syslog() */
12182 + unsigned long con_start; /* next char to be sent to consoles */
12183 + unsigned long log_end; /* most-recently-written-char + 1 */
12184 + unsigned long logged_chars; /* #chars since last read+clear operation */
12186 + char log_buf[1024];
12190 +/* context sub struct */
12192 +struct _vx_cvirt {
12193 + atomic_t nr_threads; /* number of current threads */
12194 + atomic_t nr_running; /* number of running threads */
12195 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
12197 + atomic_t nr_onhold; /* processes on hold */
12198 + uint32_t onhold_last; /* jiffies when put on hold */
12200 + struct timespec bias_ts; /* time offset to the host */
12201 + struct timespec bias_idle;
12202 + struct timespec bias_uptime; /* context creation point */
12203 + uint64_t bias_clock; /* offset in clock_t */
12205 + spinlock_t load_lock; /* lock for the load averages */
12206 + atomic_t load_updates; /* nr of load updates done so far */
12207 + uint32_t load_last; /* last time load was calculated */
12208 + uint32_t load[3]; /* load averages 1,5,15 */
12210 + atomic_t total_forks; /* number of forks so far */
12212 + struct _vx_syslog syslog;
12215 +struct _vx_cvirt_pc {
12216 + struct _vx_usage_stat cpustat;
12220 +#ifdef CONFIG_VSERVER_DEBUG
12222 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
12224 + printk("\t_vx_cvirt:\n");
12225 + printk("\t threads: %4d, %4d, %4d, %4d\n",
12226 + atomic_read(&cvirt->nr_threads),
12227 + atomic_read(&cvirt->nr_running),
12228 + atomic_read(&cvirt->nr_uninterruptible),
12229 + atomic_read(&cvirt->nr_onhold));
12230 + /* add rest here */
12231 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
12236 +#endif /* _VX_CVIRT_DEF_H */
12237 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/debug.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/debug.h
12238 --- linux-2.6.36/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
12239 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/debug.h 2010-10-21 18:35:25.000000000 +0200
12241 +#ifndef _VX_DEBUG_H
12242 +#define _VX_DEBUG_H
12245 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
12246 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
12247 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
12249 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
12250 + imajor((d)->bd_inode), iminor((d)->bd_inode)
12251 +#define VXF_DEV "%p[%lu,%d:%d]"
12253 +#if defined(CONFIG_QUOTES_UTF8)
12254 +#define VS_Q_LQM "\xc2\xbb"
12255 +#define VS_Q_RQM "\xc2\xab"
12256 +#elif defined(CONFIG_QUOTES_ASCII)
12257 +#define VS_Q_LQM "\x27"
12258 +#define VS_Q_RQM "\x27"
12260 +#define VS_Q_LQM "\xbb"
12261 +#define VS_Q_RQM "\xab"
12264 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
12267 +#define vxd_path(p) \
12268 + ({ static char _buffer[PATH_MAX]; \
12269 + d_path(p, _buffer, sizeof(_buffer)); })
12271 +#define vxd_cond_path(n) \
12272 + ((n) ? vxd_path(&(n)->path) : "<null>" )
12275 +#ifdef CONFIG_VSERVER_DEBUG
12277 +extern unsigned int vx_debug_switch;
12278 +extern unsigned int vx_debug_xid;
12279 +extern unsigned int vx_debug_nid;
12280 +extern unsigned int vx_debug_tag;
12281 +extern unsigned int vx_debug_net;
12282 +extern unsigned int vx_debug_limit;
12283 +extern unsigned int vx_debug_cres;
12284 +extern unsigned int vx_debug_dlim;
12285 +extern unsigned int vx_debug_quota;
12286 +extern unsigned int vx_debug_cvirt;
12287 +extern unsigned int vx_debug_space;
12288 +extern unsigned int vx_debug_misc;
12291 +#define VX_LOGLEVEL "vxD: "
12292 +#define VX_PROC_FMT "%p: "
12293 +#define VX_PROCESS current
12295 +#define vxdprintk(c, f, x...) \
12298 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
12299 + VX_PROCESS , ##x); \
12302 +#define vxlprintk(c, f, x...) \
12305 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
12308 +#define vxfprintk(c, f, x...) \
12311 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
12317 +void dump_vx_info(struct vx_info *, int);
12318 +void dump_vx_info_inactive(int);
12320 +#else /* CONFIG_VSERVER_DEBUG */
12322 +#define vx_debug_switch 0
12323 +#define vx_debug_xid 0
12324 +#define vx_debug_nid 0
12325 +#define vx_debug_tag 0
12326 +#define vx_debug_net 0
12327 +#define vx_debug_limit 0
12328 +#define vx_debug_cres 0
12329 +#define vx_debug_dlim 0
12330 +#define vx_debug_cvirt 0
12332 +#define vxdprintk(x...) do { } while (0)
12333 +#define vxlprintk(x...) do { } while (0)
12334 +#define vxfprintk(x...) do { } while (0)
12336 +#endif /* CONFIG_VSERVER_DEBUG */
12339 +#ifdef CONFIG_VSERVER_WARN
12341 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
12342 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
12343 +#define VX_WARN_XID "[xid #%u] "
12344 +#define VX_WARN_NID "[nid #%u] "
12345 +#define VX_WARN_TAG "[tag #%u] "
12347 +#define vxwprintk(c, f, x...) \
12350 + printk(VX_WARNLEVEL f "\n", ##x); \
12353 +#else /* CONFIG_VSERVER_WARN */
12355 +#define vxwprintk(x...) do { } while (0)
12357 +#endif /* CONFIG_VSERVER_WARN */
12359 +#define vxwprintk_task(c, f, x...) \
12360 + vxwprintk(c, VX_WARN_TASK f, \
12361 + current->comm, current->pid, \
12362 + current->xid, current->nid, current->tag, ##x)
12363 +#define vxwprintk_xid(c, f, x...) \
12364 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
12365 +#define vxwprintk_nid(c, f, x...) \
12366 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
12367 +#define vxwprintk_tag(c, f, x...) \
12368 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12370 +#ifdef CONFIG_VSERVER_DEBUG
12371 +#define vxd_assert_lock(l) assert_spin_locked(l)
12372 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12373 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12375 +#define vxd_assert_lock(l) do { } while (0)
12376 +#define vxd_assert(c, f, x...) do { } while (0)
12380 +#endif /* _VX_DEBUG_H */
12381 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/debug_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/debug_cmd.h
12382 --- linux-2.6.36/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
12383 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/debug_cmd.h 2010-10-21 13:09:36.000000000 +0200
12385 +#ifndef _VX_DEBUG_CMD_H
12386 +#define _VX_DEBUG_CMD_H
12389 +/* debug commands */
12391 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
12393 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
12394 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
12396 +struct vcmd_read_history_v0 {
12399 + char __user *data;
12402 +struct vcmd_read_monitor_v0 {
12405 + char __user *data;
12411 +#ifdef CONFIG_COMPAT
12413 +#include <asm/compat.h>
12415 +struct vcmd_read_history_v0_x32 {
12418 + compat_uptr_t data_ptr;
12421 +struct vcmd_read_monitor_v0_x32 {
12424 + compat_uptr_t data_ptr;
12427 +#endif /* CONFIG_COMPAT */
12429 +extern int vc_dump_history(uint32_t);
12431 +extern int vc_read_history(uint32_t, void __user *);
12432 +extern int vc_read_monitor(uint32_t, void __user *);
12434 +#ifdef CONFIG_COMPAT
12436 +extern int vc_read_history_x32(uint32_t, void __user *);
12437 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12439 +#endif /* CONFIG_COMPAT */
12441 +#endif /* __KERNEL__ */
12442 +#endif /* _VX_DEBUG_CMD_H */
12443 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/device.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/device.h
12444 --- linux-2.6.36/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
12445 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/device.h 2010-10-21 13:09:36.000000000 +0200
12447 +#ifndef _VX_DEVICE_H
12448 +#define _VX_DEVICE_H
12451 +#define DATTR_CREATE 0x00000001
12452 +#define DATTR_OPEN 0x00000002
12454 +#define DATTR_REMAP 0x00000010
12456 +#define DATTR_MASK 0x00000013
12459 +#else /* _VX_DEVICE_H */
12460 +#warning duplicate inclusion
12461 +#endif /* _VX_DEVICE_H */
12462 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/device_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/device_cmd.h
12463 --- linux-2.6.36/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
12464 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/device_cmd.h 2010-10-21 13:09:36.000000000 +0200
12466 +#ifndef _VX_DEVICE_CMD_H
12467 +#define _VX_DEVICE_CMD_H
12470 +/* device vserver commands */
12472 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
12473 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
12475 +struct vcmd_set_mapping_v0 {
12476 + const char __user *device;
12477 + const char __user *target;
12484 +#ifdef CONFIG_COMPAT
12486 +#include <asm/compat.h>
12488 +struct vcmd_set_mapping_v0_x32 {
12489 + compat_uptr_t device_ptr;
12490 + compat_uptr_t target_ptr;
12494 +#endif /* CONFIG_COMPAT */
12496 +#include <linux/compiler.h>
12498 +extern int vc_set_mapping(struct vx_info *, void __user *);
12499 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12501 +#ifdef CONFIG_COMPAT
12503 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12504 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12506 +#endif /* CONFIG_COMPAT */
12508 +#endif /* __KERNEL__ */
12509 +#endif /* _VX_DEVICE_CMD_H */
12510 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/device_def.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/device_def.h
12511 --- linux-2.6.36/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
12512 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/device_def.h 2010-10-21 13:09:36.000000000 +0200
12514 +#ifndef _VX_DEVICE_DEF_H
12515 +#define _VX_DEVICE_DEF_H
12517 +#include <linux/types.h>
12519 +struct vx_dmap_target {
12524 +struct _vx_device {
12525 +#ifdef CONFIG_VSERVER_DEVICE
12526 + struct vx_dmap_target targets[2];
12530 +#endif /* _VX_DEVICE_DEF_H */
12531 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/dlimit.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/dlimit.h
12532 --- linux-2.6.36/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
12533 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/dlimit.h 2010-10-21 13:09:36.000000000 +0200
12535 +#ifndef _VX_DLIMIT_H
12536 +#define _VX_DLIMIT_H
12538 +#include "switch.h"
12543 +/* keep in sync with CDLIM_INFINITY */
12545 +#define DLIM_INFINITY (~0ULL)
12547 +#include <linux/spinlock.h>
12548 +#include <linux/rcupdate.h>
12550 +struct super_block;
12553 + struct hlist_node dl_hlist; /* linked list of contexts */
12554 + struct rcu_head dl_rcu; /* the rcu head */
12555 + tag_t dl_tag; /* context tag */
12556 + atomic_t dl_usecnt; /* usage count */
12557 + atomic_t dl_refcnt; /* reference count */
12559 + struct super_block *dl_sb; /* associated superblock */
12561 + spinlock_t dl_lock; /* protect the values */
12563 + unsigned long long dl_space_used; /* used space in bytes */
12564 + unsigned long long dl_space_total; /* maximum space in bytes */
12565 + unsigned long dl_inodes_used; /* used inodes */
12566 + unsigned long dl_inodes_total; /* maximum inodes */
12568 + unsigned int dl_nrlmult; /* non root limit mult */
12573 +extern void rcu_free_dl_info(struct rcu_head *);
12574 +extern void unhash_dl_info(struct dl_info *);
12576 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12581 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12583 +typedef uint64_t dlsize_t;
12585 +#endif /* __KERNEL__ */
12586 +#else /* _VX_DLIMIT_H */
12587 +#warning duplicate inclusion
12588 +#endif /* _VX_DLIMIT_H */
12589 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/dlimit_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/dlimit_cmd.h
12590 --- linux-2.6.36/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12591 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/dlimit_cmd.h 2010-10-21 13:09:36.000000000 +0200
12593 +#ifndef _VX_DLIMIT_CMD_H
12594 +#define _VX_DLIMIT_CMD_H
12597 +/* dlimit vserver commands */
12599 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12600 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12602 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12603 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12605 +struct vcmd_ctx_dlimit_base_v0 {
12606 + const char __user *name;
12610 +struct vcmd_ctx_dlimit_v0 {
12611 + const char __user *name;
12612 + uint32_t space_used; /* used space in kbytes */
12613 + uint32_t space_total; /* maximum space in kbytes */
12614 + uint32_t inodes_used; /* used inodes */
12615 + uint32_t inodes_total; /* maximum inodes */
12616 + uint32_t reserved; /* reserved for root in % */
12620 +#define CDLIM_UNSET ((uint32_t)0UL)
12621 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12622 +#define CDLIM_KEEP ((uint32_t)~1UL)
12624 +#define DLIME_UNIT 0
12625 +#define DLIME_KILO 1
12626 +#define DLIME_MEGA 2
12627 +#define DLIME_GIGA 3
12629 +#define DLIMF_SHIFT 0x10
12631 +#define DLIMS_USED 0
12632 +#define DLIMS_TOTAL 2
12635 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12637 + int exp = (flags & DLIMF_SHIFT) ?
12638 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12639 + return ((uint64_t)val) << (10 * exp);
12643 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12647 + if (*flags & DLIMF_SHIFT) {
12648 + while (val > (1LL << 32) && (exp < 3)) {
12652 + *flags &= ~(DLIME_GIGA << shift);
12653 + *flags |= exp << shift;
12661 +#ifdef CONFIG_COMPAT
12663 +#include <asm/compat.h>
12665 +struct vcmd_ctx_dlimit_base_v0_x32 {
12666 + compat_uptr_t name_ptr;
12670 +struct vcmd_ctx_dlimit_v0_x32 {
12671 + compat_uptr_t name_ptr;
12672 + uint32_t space_used; /* used space in kbytes */
12673 + uint32_t space_total; /* maximum space in kbytes */
12674 + uint32_t inodes_used; /* used inodes */
12675 + uint32_t inodes_total; /* maximum inodes */
12676 + uint32_t reserved; /* reserved for root in % */
12680 +#endif /* CONFIG_COMPAT */
12682 +#include <linux/compiler.h>
12684 +extern int vc_add_dlimit(uint32_t, void __user *);
12685 +extern int vc_rem_dlimit(uint32_t, void __user *);
12687 +extern int vc_set_dlimit(uint32_t, void __user *);
12688 +extern int vc_get_dlimit(uint32_t, void __user *);
12690 +#ifdef CONFIG_COMPAT
12692 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12693 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12695 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12696 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12698 +#endif /* CONFIG_COMPAT */
12700 +#endif /* __KERNEL__ */
12701 +#endif /* _VX_DLIMIT_CMD_H */
12702 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/global.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/global.h
12703 --- linux-2.6.36/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12704 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/global.h 2010-10-21 13:09:36.000000000 +0200
12706 +#ifndef _VX_GLOBAL_H
12707 +#define _VX_GLOBAL_H
12710 +extern atomic_t vx_global_ctotal;
12711 +extern atomic_t vx_global_cactive;
12713 +extern atomic_t nx_global_ctotal;
12714 +extern atomic_t nx_global_cactive;
12716 +extern atomic_t vs_global_nsproxy;
12717 +extern atomic_t vs_global_fs;
12718 +extern atomic_t vs_global_mnt_ns;
12719 +extern atomic_t vs_global_uts_ns;
12720 +extern atomic_t vs_global_user_ns;
12721 +extern atomic_t vs_global_pid_ns;
12724 +#endif /* _VX_GLOBAL_H */
12725 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/history.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/history.h
12726 --- linux-2.6.36/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12727 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/history.h 2010-10-21 13:09:36.000000000 +0200
12729 +#ifndef _VX_HISTORY_H
12730 +#define _VX_HISTORY_H
12735 + VXH_THROW_OOPS = 1,
12739 + VXH_INIT_VX_INFO,
12742 + VXH_CLAIM_VX_INFO,
12743 + VXH_RELEASE_VX_INFO,
12744 + VXH_ALLOC_VX_INFO,
12745 + VXH_DEALLOC_VX_INFO,
12746 + VXH_HASH_VX_INFO,
12747 + VXH_UNHASH_VX_INFO,
12749 + VXH_LOOKUP_VX_INFO,
12750 + VXH_CREATE_VX_INFO,
12753 +struct _vxhe_vxi {
12754 + struct vx_info *ptr;
12760 +struct _vxhe_set_clr {
12764 +struct _vxhe_loc_lookup {
12768 +struct _vx_hist_entry {
12770 + unsigned short seq;
12771 + unsigned short type;
12772 + struct _vxhe_vxi vxi;
12774 + struct _vxhe_set_clr sc;
12775 + struct _vxhe_loc_lookup ll;
12779 +#ifdef CONFIG_VSERVER_HISTORY
12781 +extern unsigned volatile int vxh_active;
12783 +struct _vx_hist_entry *vxh_advance(void *loc);
12787 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12789 + entry->vxi.ptr = vxi;
12791 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12792 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12793 + entry->vxi.xid = vxi->vx_id;
12798 +#define __HERE__ current_text_addr()
12800 +#define __VXH_BODY(__type, __data, __here) \
12801 + struct _vx_hist_entry *entry; \
12803 + preempt_disable(); \
12804 + entry = vxh_advance(__here); \
12806 + entry->type = __type; \
12807 + preempt_enable();
12810 + /* pass vxi only */
12812 +#define __VXH_SMPL \
12813 + __vxh_copy_vxi(entry, vxi)
12816 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12818 + __VXH_BODY(__type, __VXH_SMPL, __here)
12821 + /* pass vxi and data (void *) */
12823 +#define __VXH_DATA \
12824 + __vxh_copy_vxi(entry, vxi); \
12825 + entry->sc.data = data
12828 +void __vxh_data(struct vx_info *vxi, void *data,
12829 + int __type, void *__here)
12831 + __VXH_BODY(__type, __VXH_DATA, __here)
12834 + /* pass vxi and arg (long) */
12836 +#define __VXH_LONG \
12837 + __vxh_copy_vxi(entry, vxi); \
12838 + entry->ll.arg = arg
12841 +void __vxh_long(struct vx_info *vxi, long arg,
12842 + int __type, void *__here)
12844 + __VXH_BODY(__type, __VXH_LONG, __here)
12849 +void __vxh_throw_oops(void *__here)
12851 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12852 + /* prevent further acquisition */
12857 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
12859 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
12860 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
12862 +#define __vxh_init_vx_info(v, d, h) \
12863 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
12864 +#define __vxh_set_vx_info(v, d, h) \
12865 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
12866 +#define __vxh_clr_vx_info(v, d, h) \
12867 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12869 +#define __vxh_claim_vx_info(v, d, h) \
12870 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12871 +#define __vxh_release_vx_info(v, d, h) \
12872 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12874 +#define vxh_alloc_vx_info(v) \
12875 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12876 +#define vxh_dealloc_vx_info(v) \
12877 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12879 +#define vxh_hash_vx_info(v) \
12880 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12881 +#define vxh_unhash_vx_info(v) \
12882 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12884 +#define vxh_loc_vx_info(v, l) \
12885 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
12886 +#define vxh_lookup_vx_info(v, l) \
12887 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
12888 +#define vxh_create_vx_info(v, l) \
12889 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
12891 +extern void vxh_dump_history(void);
12894 +#else /* CONFIG_VSERVER_HISTORY */
12896 +#define __HERE__ 0
12898 +#define vxh_throw_oops() do { } while (0)
12900 +#define __vxh_get_vx_info(v, h) do { } while (0)
12901 +#define __vxh_put_vx_info(v, h) do { } while (0)
12903 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
12904 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
12905 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
12907 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
12908 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
12910 +#define vxh_alloc_vx_info(v) do { } while (0)
12911 +#define vxh_dealloc_vx_info(v) do { } while (0)
12913 +#define vxh_hash_vx_info(v) do { } while (0)
12914 +#define vxh_unhash_vx_info(v) do { } while (0)
12916 +#define vxh_loc_vx_info(v, l) do { } while (0)
12917 +#define vxh_lookup_vx_info(v, l) do { } while (0)
12918 +#define vxh_create_vx_info(v, l) do { } while (0)
12920 +#define vxh_dump_history() do { } while (0)
12923 +#endif /* CONFIG_VSERVER_HISTORY */
12925 +#endif /* _VX_HISTORY_H */
12926 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/inode.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/inode.h
12927 --- linux-2.6.36/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
12928 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/inode.h 2010-10-21 13:09:36.000000000 +0200
12930 +#ifndef _VX_INODE_H
12931 +#define _VX_INODE_H
12934 +#define IATTR_TAG 0x01000000
12936 +#define IATTR_ADMIN 0x00000001
12937 +#define IATTR_WATCH 0x00000002
12938 +#define IATTR_HIDE 0x00000004
12939 +#define IATTR_FLAGS 0x00000007
12941 +#define IATTR_BARRIER 0x00010000
12942 +#define IATTR_IXUNLINK 0x00020000
12943 +#define IATTR_IMMUTABLE 0x00040000
12944 +#define IATTR_COW 0x00080000
12949 +#ifdef CONFIG_VSERVER_PROC_SECURE
12950 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12951 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12953 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12954 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12957 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12959 +#endif /* __KERNEL__ */
12961 +/* inode ioctls */
12963 +#define FIOC_GETXFLG _IOR('x', 5, long)
12964 +#define FIOC_SETXFLG _IOW('x', 6, long)
12966 +#else /* _VX_INODE_H */
12967 +#warning duplicate inclusion
12968 +#endif /* _VX_INODE_H */
12969 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/inode_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/inode_cmd.h
12970 --- linux-2.6.36/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
12971 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/inode_cmd.h 2010-10-21 13:09:36.000000000 +0200
12973 +#ifndef _VX_INODE_CMD_H
12974 +#define _VX_INODE_CMD_H
12977 +/* inode vserver commands */
12979 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
12980 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
12982 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
12983 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
12985 +struct vcmd_ctx_iattr_v1 {
12986 + const char __user *name;
12992 +struct vcmd_ctx_fiattr_v0 {
13002 +#ifdef CONFIG_COMPAT
13004 +#include <asm/compat.h>
13006 +struct vcmd_ctx_iattr_v1_x32 {
13007 + compat_uptr_t name_ptr;
13013 +#endif /* CONFIG_COMPAT */
13015 +#include <linux/compiler.h>
13017 +extern int vc_get_iattr(void __user *);
13018 +extern int vc_set_iattr(void __user *);
13020 +extern int vc_fget_iattr(uint32_t, void __user *);
13021 +extern int vc_fset_iattr(uint32_t, void __user *);
13023 +#ifdef CONFIG_COMPAT
13025 +extern int vc_get_iattr_x32(void __user *);
13026 +extern int vc_set_iattr_x32(void __user *);
13028 +#endif /* CONFIG_COMPAT */
13030 +#endif /* __KERNEL__ */
13031 +#endif /* _VX_INODE_CMD_H */
13032 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/limit.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/limit.h
13033 --- linux-2.6.36/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
13034 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/limit.h 2010-10-21 13:09:36.000000000 +0200
13036 +#ifndef _VX_LIMIT_H
13037 +#define _VX_LIMIT_H
13039 +#define VLIMIT_NSOCK 16
13040 +#define VLIMIT_OPENFD 17
13041 +#define VLIMIT_ANON 18
13042 +#define VLIMIT_SHMEM 19
13043 +#define VLIMIT_SEMARY 20
13044 +#define VLIMIT_NSEMS 21
13045 +#define VLIMIT_DENTRY 22
13046 +#define VLIMIT_MAPPED 23
13051 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
13053 +/* keep in sync with CRLIM_INFINITY */
13055 +#define VLIM_INFINITY (~0ULL)
13057 +#include <asm/atomic.h>
13058 +#include <asm/resource.h>
13060 +#ifndef RLIM_INFINITY
13061 +#warning RLIM_INFINITY is undefined
13064 +#define __rlim_val(l, r, v) ((l)->res[r].v)
13066 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
13067 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
13069 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
13070 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
13071 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
13073 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
13074 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
13076 +typedef atomic_long_t rlim_atomic_t;
13077 +typedef unsigned long rlim_t;
13079 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
13080 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
13081 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
13082 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
13083 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
13084 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
13087 +#if (RLIM_INFINITY == VLIM_INFINITY)
13088 +#define VX_VLIM(r) ((long long)(long)(r))
13089 +#define VX_RLIM(v) ((rlim_t)(v))
13091 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
13092 + ? VLIM_INFINITY : (long long)(r))
13093 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
13094 + ? RLIM_INFINITY : (rlim_t)(v))
13099 +void vx_vsi_meminfo(struct sysinfo *);
13100 +void vx_vsi_swapinfo(struct sysinfo *);
13101 +long vx_vsi_cached(struct sysinfo *);
13103 +#define NUM_LIMITS 24
13105 +#endif /* __KERNEL__ */
13106 +#endif /* _VX_LIMIT_H */
13107 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/limit_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/limit_cmd.h
13108 --- linux-2.6.36/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
13109 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/limit_cmd.h 2010-10-21 13:09:36.000000000 +0200
13111 +#ifndef _VX_LIMIT_CMD_H
13112 +#define _VX_LIMIT_CMD_H
13115 +/* rlimit vserver commands */
13117 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
13118 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
13119 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
13120 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
13121 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
13123 +struct vcmd_ctx_rlimit_v0 {
13125 + uint64_t minimum;
13126 + uint64_t softlimit;
13127 + uint64_t maximum;
13130 +struct vcmd_ctx_rlimit_mask_v0 {
13131 + uint32_t minimum;
13132 + uint32_t softlimit;
13133 + uint32_t maximum;
13136 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
13138 +struct vcmd_rlimit_stat_v0 {
13142 + uint64_t minimum;
13143 + uint64_t maximum;
13146 +#define CRLIM_UNSET (0ULL)
13147 +#define CRLIM_INFINITY (~0ULL)
13148 +#define CRLIM_KEEP (~1ULL)
13152 +#ifdef CONFIG_IA32_EMULATION
13154 +struct vcmd_ctx_rlimit_v0_x32 {
13156 + uint64_t minimum;
13157 + uint64_t softlimit;
13158 + uint64_t maximum;
13159 +} __attribute__ ((packed));
13161 +#endif /* CONFIG_IA32_EMULATION */
13163 +#include <linux/compiler.h>
13165 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
13166 +extern int vc_get_rlimit(struct vx_info *, void __user *);
13167 +extern int vc_set_rlimit(struct vx_info *, void __user *);
13168 +extern int vc_reset_hits(struct vx_info *, void __user *);
13169 +extern int vc_reset_minmax(struct vx_info *, void __user *);
13171 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
13173 +#ifdef CONFIG_IA32_EMULATION
13175 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
13176 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
13178 +#endif /* CONFIG_IA32_EMULATION */
13180 +#endif /* __KERNEL__ */
13181 +#endif /* _VX_LIMIT_CMD_H */
13182 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/limit_def.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/limit_def.h
13183 --- linux-2.6.36/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
13184 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/limit_def.h 2010-10-21 13:09:36.000000000 +0200
13186 +#ifndef _VX_LIMIT_DEF_H
13187 +#define _VX_LIMIT_DEF_H
13189 +#include <asm/atomic.h>
13190 +#include <asm/resource.h>
13192 +#include "limit.h"
13195 +struct _vx_res_limit {
13196 + rlim_t soft; /* Context soft limit */
13197 + rlim_t hard; /* Context hard limit */
13199 + rlim_atomic_t rcur; /* Current value */
13200 + rlim_t rmin; /* Context minimum */
13201 + rlim_t rmax; /* Context maximum */
13203 + atomic_t lhit; /* Limit hits */
13206 +/* context sub struct */
13208 +struct _vx_limit {
13209 + struct _vx_res_limit res[NUM_LIMITS];
13212 +#ifdef CONFIG_VSERVER_DEBUG
13214 +static inline void __dump_vx_limit(struct _vx_limit *limit)
13218 + printk("\t_vx_limit:");
13219 + for (i = 0; i < NUM_LIMITS; i++) {
13220 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
13221 + i, (unsigned long)__rlim_get(limit, i),
13222 + (unsigned long)__rlim_rmin(limit, i),
13223 + (unsigned long)__rlim_rmax(limit, i),
13224 + (long)__rlim_soft(limit, i),
13225 + (long)__rlim_hard(limit, i),
13226 + atomic_read(&__rlim_lhit(limit, i)));
13232 +#endif /* _VX_LIMIT_DEF_H */
13233 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/limit_int.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/limit_int.h
13234 --- linux-2.6.36/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
13235 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/limit_int.h 2010-10-21 13:09:36.000000000 +0200
13237 +#ifndef _VX_LIMIT_INT_H
13238 +#define _VX_LIMIT_INT_H
13240 +#include "context.h"
13244 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
13245 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
13247 +extern const char *vlimit_name[NUM_LIMITS];
13249 +static inline void __vx_acc_cres(struct vx_info *vxi,
13250 + int res, int dir, void *_data, char *_file, int _line)
13252 + if (VXD_RCRES_COND(res))
13253 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
13254 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13255 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13256 + (dir > 0) ? "++" : "--", _data, _file, _line);
13261 + __rlim_inc(&vxi->limit, res);
13263 + __rlim_dec(&vxi->limit, res);
13266 +static inline void __vx_add_cres(struct vx_info *vxi,
13267 + int res, int amount, void *_data, char *_file, int _line)
13269 + if (VXD_RCRES_COND(res))
13270 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
13271 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13272 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13273 + amount, _data, _file, _line);
13278 + __rlim_add(&vxi->limit, res, amount);
13282 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
13284 + int cond = (value > __rlim_rmax(limit, res));
13287 + __rlim_rmax(limit, res) = value;
13292 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13294 + int cond = (value < __rlim_rmin(limit, res));
13297 + __rlim_rmin(limit, res) = value;
13302 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13304 + if (!__vx_cres_adjust_max(limit, res, value))
13305 + __vx_cres_adjust_min(limit, res, value);
13310 + +1 ... no limit hit
13311 + -1 ... over soft limit
13312 + 0 ... over hard limit */
13314 +static inline int __vx_cres_avail(struct vx_info *vxi,
13315 + int res, int num, char *_file, int _line)
13317 + struct _vx_limit *limit;
13320 + if (VXD_RLIMIT_COND(res))
13321 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13322 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13323 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13324 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13325 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13326 + num, _file, _line);
13330 + limit = &vxi->limit;
13331 + value = __rlim_get(limit, res);
13333 + if (!__vx_cres_adjust_max(limit, res, value))
13334 + __vx_cres_adjust_min(limit, res, value);
13339 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
13341 + if (value + num <= __rlim_soft(limit, res))
13344 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
13346 + if (value + num <= __rlim_hard(limit, res))
13349 + __rlim_hit(limit, res);
13354 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13357 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13359 + rlim_t value, sum = 0;
13362 + while ((res = *array++)) {
13363 + value = __rlim_get(limit, res);
13364 + __vx_cres_fixup(limit, res, value);
13371 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13373 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
13374 + int res = *array;
13376 + if (value == __rlim_get(limit, res))
13379 + __rlim_set(limit, res, value);
13380 + /* now adjust min/max */
13381 + if (!__vx_cres_adjust_max(limit, res, value))
13382 + __vx_cres_adjust_min(limit, res, value);
13387 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13388 + const int *array, int num, char *_file, int _line)
13390 + struct _vx_limit *limit;
13391 + rlim_t value = 0;
13399 + limit = &vxi->limit;
13401 + value = __vx_cres_array_sum(limit, array + 1);
13403 + __rlim_set(limit, res, value);
13404 + __vx_cres_fixup(limit, res, value);
13406 + return __vx_cres_avail(vxi, res, num, _file, _line);
13410 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13415 + /* complex resources first */
13416 + if ((id < 0) || (id == RLIMIT_RSS))
13417 + __vx_cres_array_fixup(limit, VLA_RSS);
13419 + for (res = 0; res < NUM_LIMITS; res++) {
13420 + if ((id > 0) && (res != id))
13423 + value = __rlim_get(limit, res);
13424 + __vx_cres_fixup(limit, res, value);
13426 + /* not supposed to happen, maybe warn? */
13427 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13428 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13433 +#endif /* __KERNEL__ */
13434 +#endif /* _VX_LIMIT_INT_H */
13435 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/monitor.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/monitor.h
13436 --- linux-2.6.36/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
13437 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/monitor.h 2010-10-21 13:09:36.000000000 +0200
13439 +#ifndef _VX_MONITOR_H
13440 +#define _VX_MONITOR_H
13442 +#include <linux/types.h>
13449 + VXM_UPDATE = 0x20,
13453 + VXM_RQINFO_1 = 0x24,
13456 + VXM_ACTIVATE = 0x40,
13463 + VXM_MIGRATE = 0x48,
13466 + /* all other bits are flags */
13467 + VXM_SCHED = 0x80,
13470 +struct _vxm_update_1 {
13471 + uint32_t tokens_max;
13472 + uint32_t fill_rate;
13473 + uint32_t interval;
13476 +struct _vxm_update_2 {
13477 + uint32_t tokens_min;
13478 + uint32_t fill_rate;
13479 + uint32_t interval;
13482 +struct _vxm_rqinfo_1 {
13483 + uint16_t running;
13487 + uint32_t idle_tokens;
13490 +struct _vxm_rqinfo_2 {
13491 + uint32_t norm_time;
13492 + uint32_t idle_time;
13493 + uint32_t idle_skip;
13496 +struct _vxm_sched {
13498 + uint32_t norm_time;
13499 + uint32_t idle_time;
13502 +struct _vxm_task {
13507 +struct _vxm_event {
13516 + struct _vxm_task tsk;
13520 +struct _vx_mon_entry {
13524 + struct _vxm_event ev;
13525 + struct _vxm_sched sd;
13526 + struct _vxm_update_1 u1;
13527 + struct _vxm_update_2 u2;
13528 + struct _vxm_rqinfo_1 q1;
13529 + struct _vxm_rqinfo_2 q2;
13534 +#endif /* _VX_MONITOR_H */
13535 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/network.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/network.h
13536 --- linux-2.6.36/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
13537 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/network.h 2010-10-21 13:09:36.000000000 +0200
13539 +#ifndef _VX_NETWORK_H
13540 +#define _VX_NETWORK_H
13542 +#include <linux/types.h>
13545 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13548 +/* network flags */
13550 +#define NXF_INFO_PRIVATE 0x00000008
13552 +#define NXF_SINGLE_IP 0x00000100
13553 +#define NXF_LBACK_REMAP 0x00000200
13554 +#define NXF_LBACK_ALLOW 0x00000400
13556 +#define NXF_HIDE_NETIF 0x02000000
13557 +#define NXF_HIDE_LBACK 0x04000000
13559 +#define NXF_STATE_SETUP (1ULL << 32)
13560 +#define NXF_STATE_ADMIN (1ULL << 34)
13562 +#define NXF_SC_HELPER (1ULL << 36)
13563 +#define NXF_PERSISTENT (1ULL << 38)
13565 +#define NXF_ONE_TIME (0x0005ULL << 32)
13568 +#define NXF_INIT_SET (__nxf_init_set())
13570 +static inline uint64_t __nxf_init_set(void) {
13571 + return NXF_STATE_ADMIN
13572 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13573 + | NXF_LBACK_REMAP
13576 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13579 + | NXF_HIDE_NETIF;
13583 +/* network caps */
13585 +#define NXC_TUN_CREATE 0x00000001
13587 +#define NXC_RAW_ICMP 0x00000100
13590 +/* address types */
13592 +#define NXA_TYPE_IPV4 0x0001
13593 +#define NXA_TYPE_IPV6 0x0002
13595 +#define NXA_TYPE_NONE 0x0000
13596 +#define NXA_TYPE_ANY 0x00FF
13598 +#define NXA_TYPE_ADDR 0x0010
13599 +#define NXA_TYPE_MASK 0x0020
13600 +#define NXA_TYPE_RANGE 0x0040
13602 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13604 +#define NXA_MOD_BCAST 0x0100
13605 +#define NXA_MOD_LBACK 0x0200
13607 +#define NXA_LOOPBACK 0x1000
13609 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13610 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13614 +#include <linux/list.h>
13615 +#include <linux/spinlock.h>
13616 +#include <linux/rcupdate.h>
13617 +#include <linux/in.h>
13618 +#include <linux/in6.h>
13619 +#include <asm/atomic.h>
13621 +struct nx_addr_v4 {
13622 + struct nx_addr_v4 *next;
13623 + struct in_addr ip[2];
13624 + struct in_addr mask;
13629 +struct nx_addr_v6 {
13630 + struct nx_addr_v6 *next;
13631 + struct in6_addr ip;
13632 + struct in6_addr mask;
13639 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13640 + nid_t nx_id; /* vnet id */
13641 + atomic_t nx_usecnt; /* usage count */
13642 + atomic_t nx_tasks; /* tasks count */
13643 + int nx_state; /* context state */
13645 + uint64_t nx_flags; /* network flag word */
13646 + uint64_t nx_ncaps; /* network capabilities */
13648 + struct in_addr v4_lback; /* Loopback address */
13649 + struct in_addr v4_bcast; /* Broadcast address */
13650 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13651 +#ifdef CONFIG_IPV6
13652 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13654 + char nx_name[65]; /* network context name */
13658 +/* status flags */
13660 +#define NXS_HASHED 0x0001
13661 +#define NXS_SHUTDOWN 0x0100
13662 +#define NXS_RELEASED 0x8000
13664 +extern struct nx_info *lookup_nx_info(int);
13666 +extern int get_nid_list(int, unsigned int *, int);
13667 +extern int nid_is_hashed(nid_t);
13669 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13671 +extern long vs_net_change(struct nx_info *, unsigned int);
13676 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13677 +#ifdef CONFIG_IPV6
13678 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13680 +#define NX_IPV6(n) (0)
13683 +#endif /* __KERNEL__ */
13684 +#endif /* _VX_NETWORK_H */
13685 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/network_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/network_cmd.h
13686 --- linux-2.6.36/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13687 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/network_cmd.h 2010-10-21 13:09:36.000000000 +0200
13689 +#ifndef _VX_NETWORK_CMD_H
13690 +#define _VX_NETWORK_CMD_H
13693 +/* vinfo commands */
13695 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13698 +extern int vc_task_nid(uint32_t);
13700 +#endif /* __KERNEL__ */
13702 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13704 +struct vcmd_nx_info_v0 {
13706 + /* more to come */
13710 +extern int vc_nx_info(struct nx_info *, void __user *);
13712 +#endif /* __KERNEL__ */
13714 +#include <linux/in.h>
13715 +#include <linux/in6.h>
13717 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13718 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13720 +struct vcmd_net_create {
13721 + uint64_t flagword;
13724 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13726 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13727 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13729 +struct vcmd_net_addr_v0 {
13732 + struct in_addr ip[4];
13733 + struct in_addr mask[4];
13736 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
13737 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
13739 +struct vcmd_net_addr_ipv4_v1 {
13742 + struct in_addr ip;
13743 + struct in_addr mask;
13746 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13747 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13749 +struct vcmd_net_addr_ipv6_v1 {
13753 + struct in6_addr ip;
13754 + struct in6_addr mask;
13757 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13758 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13760 +struct vcmd_match_ipv4_v0 {
13765 + struct in_addr ip;
13766 + struct in_addr ip2;
13767 + struct in_addr mask;
13770 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13771 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13773 +struct vcmd_match_ipv6_v0 {
13778 + struct in6_addr ip;
13779 + struct in6_addr ip2;
13780 + struct in6_addr mask;
13785 +extern int vc_net_create(uint32_t, void __user *);
13786 +extern int vc_net_migrate(struct nx_info *, void __user *);
13788 +extern int vc_net_add(struct nx_info *, void __user *);
13789 +extern int vc_net_remove(struct nx_info *, void __user *);
13791 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13792 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
13794 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13795 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13797 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13798 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13800 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13801 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13803 +#endif /* __KERNEL__ */
13806 +/* flag commands */
13808 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13809 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13811 +struct vcmd_net_flags_v0 {
13812 + uint64_t flagword;
13817 +extern int vc_get_nflags(struct nx_info *, void __user *);
13818 +extern int vc_set_nflags(struct nx_info *, void __user *);
13820 +#endif /* __KERNEL__ */
13823 +/* network caps commands */
13825 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13826 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13828 +struct vcmd_net_caps_v0 {
13834 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13835 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13837 +#endif /* __KERNEL__ */
13838 +#endif /* _VX_CONTEXT_CMD_H */
13839 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/percpu.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/percpu.h
13840 --- linux-2.6.36/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13841 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/percpu.h 2010-10-21 13:09:36.000000000 +0200
13843 +#ifndef _VX_PERCPU_H
13844 +#define _VX_PERCPU_H
13846 +#include "cvirt_def.h"
13847 +#include "sched_def.h"
13849 +struct _vx_percpu {
13850 + struct _vx_cvirt_pc cvirt;
13851 + struct _vx_sched_pc sched;
13854 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13856 +#endif /* _VX_PERCPU_H */
13857 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/pid.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/pid.h
13858 --- linux-2.6.36/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
13859 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/pid.h 2010-10-21 13:09:36.000000000 +0200
13861 +#ifndef _VSERVER_PID_H
13862 +#define _VSERVER_PID_H
13864 +/* pid faking stuff */
13866 +#define vx_info_map_pid(v, p) \
13867 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13868 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13869 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13870 +#define vx_map_tgid(p) vx_map_pid(p)
13872 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13873 + const char *func, const char *file, int line)
13875 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13876 + vxfprintk(VXD_CBIT(cvirt, 2),
13877 + "vx_map_tgid: %p/%llx: %d -> %d",
13878 + vxi, (long long)vxi->vx_flags, pid,
13879 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13880 + func, file, line);
13883 + if (pid == vxi->vx_initpid)
13889 +#define vx_info_rmap_pid(v, p) \
13890 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
13891 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
13892 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13894 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13895 + const char *func, const char *file, int line)
13897 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13898 + vxfprintk(VXD_CBIT(cvirt, 2),
13899 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13900 + vxi, (long long)vxi->vx_flags, pid,
13901 + (pid == 1) ? vxi->vx_initpid : pid,
13902 + func, file, line);
13903 + if ((pid == 1) && vxi->vx_initpid)
13904 + return vxi->vx_initpid;
13905 + if (pid == vxi->vx_initpid)
13912 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/sched.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/sched.h
13913 --- linux-2.6.36/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13914 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/sched.h 2010-10-28 18:16:35.000000000 +0200
13916 +#ifndef _VX_SCHED_H
13917 +#define _VX_SCHED_H
13924 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13929 +void vx_update_load(struct vx_info *);
13932 +void vx_update_sched_param(struct _vx_sched *sched,
13933 + struct _vx_sched_pc *sched_pc);
13935 +#endif /* __KERNEL__ */
13936 +#else /* _VX_SCHED_H */
13937 +#warning duplicate inclusion
13938 +#endif /* _VX_SCHED_H */
13939 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/sched_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/sched_cmd.h
13940 --- linux-2.6.36/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
13941 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/sched_cmd.h 2010-10-28 19:02:11.000000000 +0200
13943 +#ifndef _VX_SCHED_CMD_H
13944 +#define _VX_SCHED_CMD_H
13947 +struct vcmd_prio_bias {
13949 + int32_t prio_bias;
13952 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13953 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13957 +#include <linux/compiler.h>
13959 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
13960 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
13962 +#endif /* __KERNEL__ */
13963 +#endif /* _VX_SCHED_CMD_H */
13964 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/sched_def.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/sched_def.h
13965 --- linux-2.6.36/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
13966 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/sched_def.h 2010-10-28 18:13:49.000000000 +0200
13968 +#ifndef _VX_SCHED_DEF_H
13969 +#define _VX_SCHED_DEF_H
13971 +#include <linux/spinlock.h>
13972 +#include <linux/jiffies.h>
13973 +#include <linux/cpumask.h>
13974 +#include <asm/atomic.h>
13975 +#include <asm/param.h>
13978 +/* context sub struct */
13980 +struct _vx_sched {
13981 + int prio_bias; /* bias offset for priority */
13983 + cpumask_t update; /* CPUs which should update */
13986 +struct _vx_sched_pc {
13987 + int prio_bias; /* bias offset for priority */
13989 + uint64_t user_ticks; /* token tick events */
13990 + uint64_t sys_ticks; /* token tick events */
13991 + uint64_t hold_ticks; /* token ticks paused */
13995 +#ifdef CONFIG_VSERVER_DEBUG
13997 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13999 + printk("\t_vx_sched:\n");
14000 + printk("\t priority = %4d\n", sched->prio_bias);
14005 +#endif /* _VX_SCHED_DEF_H */
14006 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/signal.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/signal.h
14007 --- linux-2.6.36/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
14008 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/signal.h 2010-10-21 13:09:36.000000000 +0200
14010 +#ifndef _VX_SIGNAL_H
14011 +#define _VX_SIGNAL_H
14018 +int vx_info_kill(struct vx_info *, int, int);
14020 +#endif /* __KERNEL__ */
14021 +#else /* _VX_SIGNAL_H */
14022 +#warning duplicate inclusion
14023 +#endif /* _VX_SIGNAL_H */
14024 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/signal_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/signal_cmd.h
14025 --- linux-2.6.36/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
14026 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/signal_cmd.h 2010-10-21 13:09:36.000000000 +0200
14028 +#ifndef _VX_SIGNAL_CMD_H
14029 +#define _VX_SIGNAL_CMD_H
14032 +/* signalling vserver commands */
14034 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
14035 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
14037 +struct vcmd_ctx_kill_v0 {
14042 +struct vcmd_wait_exit_v0 {
14043 + int32_t reboot_cmd;
14044 + int32_t exit_code;
14049 +extern int vc_ctx_kill(struct vx_info *, void __user *);
14050 +extern int vc_wait_exit(struct vx_info *, void __user *);
14052 +#endif /* __KERNEL__ */
14054 +/* process alteration commands */
14056 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
14057 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
14059 +struct vcmd_pflags_v0 {
14060 + uint32_t flagword;
14066 +extern int vc_get_pflags(uint32_t pid, void __user *);
14067 +extern int vc_set_pflags(uint32_t pid, void __user *);
14069 +#endif /* __KERNEL__ */
14070 +#endif /* _VX_SIGNAL_CMD_H */
14071 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/space.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/space.h
14072 --- linux-2.6.36/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
14073 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/space.h 2010-10-21 13:09:36.000000000 +0200
14075 +#ifndef _VX_SPACE_H
14076 +#define _VX_SPACE_H
14078 +#include <linux/types.h>
14082 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
14084 +#else /* _VX_SPACE_H */
14085 +#warning duplicate inclusion
14086 +#endif /* _VX_SPACE_H */
14087 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/space_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/space_cmd.h
14088 --- linux-2.6.36/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
14089 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/space_cmd.h 2010-10-21 13:09:36.000000000 +0200
14091 +#ifndef _VX_SPACE_CMD_H
14092 +#define _VX_SPACE_CMD_H
14095 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
14096 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
14097 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
14099 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
14100 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
14101 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
14103 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
14105 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
14106 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
14109 +struct vcmd_space_mask_v1 {
14113 +struct vcmd_space_mask_v2 {
14121 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
14122 +extern int vc_set_space_v1(struct vx_info *, void __user *);
14123 +extern int vc_enter_space(struct vx_info *, void __user *);
14124 +extern int vc_set_space(struct vx_info *, void __user *);
14125 +extern int vc_get_space_mask(void __user *, int);
14127 +#endif /* __KERNEL__ */
14128 +#endif /* _VX_SPACE_CMD_H */
14129 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/switch.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/switch.h
14130 --- linux-2.6.36/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
14131 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/switch.h 2010-10-21 13:09:36.000000000 +0200
14133 +#ifndef _VX_SWITCH_H
14134 +#define _VX_SWITCH_H
14136 +#include <linux/types.h>
14139 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
14140 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
14141 +#define VC_VERSION(c) ((c) & 0xFFF)
14143 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
14144 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
14148 + Syscall Matrix V2.8
14150 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
14151 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
14152 + |INFO |SETUP | |MOVE | | | | | |
14153 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14154 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
14155 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
14156 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14157 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
14158 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
14159 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14160 + MEMORY | | | | |MEMCTRL| | |SWAP | |
14161 + | 16| 17| 18| 19| 20| 21| | 22| 23|
14162 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14163 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
14164 + | 24| 25| 26| 27| 28| 29| | 30| 31|
14165 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14166 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
14167 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
14168 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14169 + OTHER |VSTAT | | | | | | |VINFO | |
14170 + | 40| 41| 42| 43| 44| 45| | 46| 47|
14171 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
14172 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
14173 + | 48| 49| 50| 51| 52| 53| | 54| 55|
14174 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14175 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
14176 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
14177 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14181 +#define VC_CAT_VERSION 0
14183 +#define VC_CAT_VSETUP 1
14184 +#define VC_CAT_VHOST 2
14186 +#define VC_CAT_DEVICE 6
14188 +#define VC_CAT_VPROC 9
14189 +#define VC_CAT_PROCALT 10
14190 +#define VC_CAT_PROCMIG 11
14191 +#define VC_CAT_PROCTRL 12
14193 +#define VC_CAT_SCHED 14
14194 +#define VC_CAT_MEMCTRL 20
14196 +#define VC_CAT_VNET 25
14197 +#define VC_CAT_NETALT 26
14198 +#define VC_CAT_NETMIG 27
14199 +#define VC_CAT_NETCTRL 28
14201 +#define VC_CAT_TAGMIG 35
14202 +#define VC_CAT_DLIMIT 36
14203 +#define VC_CAT_INODE 38
14205 +#define VC_CAT_VSTAT 40
14206 +#define VC_CAT_VINFO 46
14207 +#define VC_CAT_EVENT 48
14209 +#define VC_CAT_FLAGS 52
14210 +#define VC_CAT_VSPACE 54
14211 +#define VC_CAT_DEBUG 56
14212 +#define VC_CAT_RLIMIT 60
14214 +#define VC_CAT_SYSTEST 61
14215 +#define VC_CAT_COMPAT 63
14217 +/* query version */
14219 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
14220 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
14225 +#include <linux/errno.h>
14227 +#endif /* __KERNEL__ */
14229 +#endif /* _VX_SWITCH_H */
14231 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/tag.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/tag.h
14232 --- linux-2.6.36/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
14233 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/tag.h 2010-10-21 13:09:36.000000000 +0200
14238 +#include <linux/types.h>
14241 +#define DX_TAG(in) (IS_TAGGED(in))
14244 +#ifdef CONFIG_TAG_NFSD
14245 +#define DX_TAG_NFSD 1
14247 +#define DX_TAG_NFSD 0
14251 +#ifdef CONFIG_TAGGING_NONE
14253 +#define MAX_UID 0xFFFFFFFF
14254 +#define MAX_GID 0xFFFFFFFF
14256 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
14258 +#define TAGINO_UID(cond, uid, tag) (uid)
14259 +#define TAGINO_GID(cond, gid, tag) (gid)
14264 +#ifdef CONFIG_TAGGING_GID16
14266 +#define MAX_UID 0xFFFFFFFF
14267 +#define MAX_GID 0x0000FFFF
14269 +#define INOTAG_TAG(cond, uid, gid, tag) \
14270 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
14272 +#define TAGINO_UID(cond, uid, tag) (uid)
14273 +#define TAGINO_GID(cond, gid, tag) \
14274 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14279 +#ifdef CONFIG_TAGGING_ID24
14281 +#define MAX_UID 0x00FFFFFF
14282 +#define MAX_GID 0x00FFFFFF
14284 +#define INOTAG_TAG(cond, uid, gid, tag) \
14285 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14287 +#define TAGINO_UID(cond, uid, tag) \
14288 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14289 +#define TAGINO_GID(cond, gid, tag) \
14290 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14295 +#ifdef CONFIG_TAGGING_UID16
14297 +#define MAX_UID 0x0000FFFF
14298 +#define MAX_GID 0xFFFFFFFF
14300 +#define INOTAG_TAG(cond, uid, gid, tag) \
14301 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14303 +#define TAGINO_UID(cond, uid, tag) \
14304 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14305 +#define TAGINO_GID(cond, gid, tag) (gid)
14310 +#ifdef CONFIG_TAGGING_INTERN
14312 +#define MAX_UID 0xFFFFFFFF
14313 +#define MAX_GID 0xFFFFFFFF
14315 +#define INOTAG_TAG(cond, uid, gid, tag) \
14316 + ((cond) ? (tag) : 0)
14318 +#define TAGINO_UID(cond, uid, tag) (uid)
14319 +#define TAGINO_GID(cond, gid, tag) (gid)
14324 +#ifndef CONFIG_TAGGING_NONE
14325 +#define dx_current_fstag(sb) \
14326 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14328 +#define dx_current_fstag(sb) (0)
14331 +#ifndef CONFIG_TAGGING_INTERN
14332 +#define TAGINO_TAG(cond, tag) (0)
14334 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
14337 +#define INOTAG_UID(cond, uid, gid) \
14338 + ((cond) ? ((uid) & MAX_UID) : (uid))
14339 +#define INOTAG_GID(cond, uid, gid) \
14340 + ((cond) ? ((gid) & MAX_GID) : (gid))
14343 +static inline uid_t dx_map_uid(uid_t uid)
14345 + if ((uid > MAX_UID) && (uid != -1))
14347 + return (uid & MAX_UID);
14350 +static inline gid_t dx_map_gid(gid_t gid)
14352 + if ((gid > MAX_GID) && (gid != -1))
14354 + return (gid & MAX_GID);
14362 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14364 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14365 + unsigned long *flags);
14367 +#ifdef CONFIG_PROPAGATE
14369 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14371 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14374 +#define dx_propagate_tag(n, i) do { } while (0)
14377 +#endif /* _DX_TAG_H */
14378 diff -NurpP --minimal linux-2.6.36/include/linux/vserver/tag_cmd.h linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/tag_cmd.h
14379 --- linux-2.6.36/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
14380 +++ linux-2.6.36-vs2.3.0.36.38/include/linux/vserver/tag_cmd.h 2010-10-21 13:09:36.000000000 +0200
14382 +#ifndef _VX_TAG_CMD_H
14383 +#define _VX_TAG_CMD_H
14386 +/* vinfo commands */
14388 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
14391 +extern int vc_task_tag(uint32_t);
14393 +#endif /* __KERNEL__ */
14395 +/* context commands */
14397 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
14400 +extern int vc_tag_migrate(uint32_t);
14402 +#endif /* __KERNEL__ */
14403 +#endif /* _VX_TAG_CMD_H */
14404 diff -NurpP --minimal linux-2.6.36/include/net/addrconf.h linux-2.6.36-vs2.3.0.36.38/include/net/addrconf.h
14405 --- linux-2.6.36/include/net/addrconf.h 2010-10-21 13:07:56.000000000 +0200
14406 +++ linux-2.6.36-vs2.3.0.36.38/include/net/addrconf.h 2010-10-21 13:09:36.000000000 +0200
14407 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14408 struct net_device *dev,
14409 const struct in6_addr *daddr,
14410 unsigned int srcprefs,
14411 - struct in6_addr *saddr);
14412 + struct in6_addr *saddr,
14413 + struct nx_info *nxi);
14414 extern int ipv6_get_lladdr(struct net_device *dev,
14415 struct in6_addr *addr,
14416 unsigned char banned_flags);
14417 diff -NurpP --minimal linux-2.6.36/include/net/af_unix.h linux-2.6.36-vs2.3.0.36.38/include/net/af_unix.h
14418 --- linux-2.6.36/include/net/af_unix.h 2010-10-21 13:07:56.000000000 +0200
14419 +++ linux-2.6.36-vs2.3.0.36.38/include/net/af_unix.h 2010-10-21 13:09:36.000000000 +0200
14421 #include <linux/socket.h>
14422 #include <linux/un.h>
14423 #include <linux/mutex.h>
14424 +#include <linux/vs_base.h>
14425 #include <net/sock.h>
14427 extern void unix_inflight(struct file *fp);
14428 diff -NurpP --minimal linux-2.6.36/include/net/inet_timewait_sock.h linux-2.6.36-vs2.3.0.36.38/include/net/inet_timewait_sock.h
14429 --- linux-2.6.36/include/net/inet_timewait_sock.h 2010-08-02 16:52:56.000000000 +0200
14430 +++ linux-2.6.36-vs2.3.0.36.38/include/net/inet_timewait_sock.h 2010-10-21 13:09:36.000000000 +0200
14431 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
14432 #define tw_hash __tw_common.skc_hash
14433 #define tw_prot __tw_common.skc_prot
14434 #define tw_net __tw_common.skc_net
14435 +#define tw_xid __tw_common.skc_xid
14436 +#define tw_vx_info __tw_common.skc_vx_info
14437 +#define tw_nid __tw_common.skc_nid
14438 +#define tw_nx_info __tw_common.skc_nx_info
14440 volatile unsigned char tw_substate;
14441 /* 3 bits hole, try to pack */
14442 diff -NurpP --minimal linux-2.6.36/include/net/route.h linux-2.6.36-vs2.3.0.36.38/include/net/route.h
14443 --- linux-2.6.36/include/net/route.h 2010-10-21 13:07:56.000000000 +0200
14444 +++ linux-2.6.36-vs2.3.0.36.38/include/net/route.h 2010-10-21 13:09:36.000000000 +0200
14445 @@ -145,6 +145,9 @@ static inline void ip_rt_put(struct rtab
14446 dst_release(&rt->dst);
14449 +#include <linux/vs_base.h>
14450 +#include <linux/vs_inet.h>
14452 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14454 extern const __u8 ip_tos2prio[16];
14455 @@ -154,6 +157,9 @@ static inline char rt_tos2priority(u8 to
14456 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14459 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14460 + struct rtable **, struct flowi *);
14462 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14463 __be32 src, u32 tos, int oif, u8 protocol,
14464 __be16 sport, __be16 dport, struct sock *sk,
14465 @@ -171,11 +177,24 @@ static inline int ip_route_connect(struc
14468 struct net *net = sock_net(sk);
14469 + struct nx_info *nx_info = current_nx_info();
14471 if (inet_sk(sk)->transparent)
14472 fl.flags |= FLOWI_FLAG_ANYSRC;
14474 - if (!dst || !src) {
14476 + nx_info = sk->sk_nx_info;
14478 + vxdprintk(VXD_CBIT(net, 4),
14479 + "ip_route_connect(%p) %p,%p;%lx",
14480 + sk, nx_info, sk->sk_socket,
14481 + (sk->sk_socket?sk->sk_socket->flags:0));
14483 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14487 + if (!fl.fl4_dst || !fl.fl4_src) {
14488 err = __ip_route_output_key(net, rp, &fl);
14491 diff -NurpP --minimal linux-2.6.36/include/net/sock.h linux-2.6.36-vs2.3.0.36.38/include/net/sock.h
14492 --- linux-2.6.36/include/net/sock.h 2010-10-21 13:07:56.000000000 +0200
14493 +++ linux-2.6.36-vs2.3.0.36.38/include/net/sock.h 2010-10-21 13:09:36.000000000 +0200
14494 @@ -150,6 +150,10 @@ struct sock_common {
14495 #ifdef CONFIG_NET_NS
14496 struct net *skc_net;
14499 + struct vx_info *skc_vx_info;
14501 + struct nx_info *skc_nx_info;
14505 @@ -241,6 +245,10 @@ struct sock {
14506 #define sk_bind_node __sk_common.skc_bind_node
14507 #define sk_prot __sk_common.skc_prot
14508 #define sk_net __sk_common.skc_net
14509 +#define sk_xid __sk_common.skc_xid
14510 +#define sk_vx_info __sk_common.skc_vx_info
14511 +#define sk_nid __sk_common.skc_nid
14512 +#define sk_nx_info __sk_common.skc_nx_info
14513 kmemcheck_bitfield_begin(flags);
14514 unsigned int sk_shutdown : 2,
14516 diff -NurpP --minimal linux-2.6.36/init/Kconfig linux-2.6.36-vs2.3.0.36.38/init/Kconfig
14517 --- linux-2.6.36/init/Kconfig 2010-10-21 13:07:56.000000000 +0200
14518 +++ linux-2.6.36-vs2.3.0.36.38/init/Kconfig 2010-10-21 13:09:36.000000000 +0200
14519 @@ -476,6 +476,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
14521 boolean "Control Group support"
14525 This option adds support for grouping sets of processes together, for
14526 use with process control subsystems such as Cpusets, CFS, memory
14527 @@ -503,6 +504,7 @@ config CGROUP_DEBUG
14529 bool "Namespace cgroup subsystem"
14533 Provides a simple namespace cgroup subsystem to
14534 provide hierarchical naming of sets of namespaces,
14535 diff -NurpP --minimal linux-2.6.36/init/main.c linux-2.6.36-vs2.3.0.36.38/init/main.c
14536 --- linux-2.6.36/init/main.c 2010-10-21 13:07:56.000000000 +0200
14537 +++ linux-2.6.36-vs2.3.0.36.38/init/main.c 2010-10-21 13:10:12.000000000 +0200
14539 #include <linux/sfi.h>
14540 #include <linux/shmem_fs.h>
14541 #include <linux/slab.h>
14542 +#include <linux/vserver/percpu.h>
14544 #include <asm/io.h>
14545 #include <asm/bugs.h>
14546 diff -NurpP --minimal linux-2.6.36/ipc/mqueue.c linux-2.6.36-vs2.3.0.36.38/ipc/mqueue.c
14547 --- linux-2.6.36/ipc/mqueue.c 2010-10-21 13:07:56.000000000 +0200
14548 +++ linux-2.6.36-vs2.3.0.36.38/ipc/mqueue.c 2010-10-21 13:28:42.000000000 +0200
14550 #include <linux/pid.h>
14551 #include <linux/ipc_namespace.h>
14552 #include <linux/slab.h>
14553 +#include <linux/vs_context.h>
14554 +#include <linux/vs_limit.h>
14556 #include <net/sock.h>
14558 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14559 struct sigevent notify;
14560 struct pid* notify_owner;
14561 struct user_struct *user; /* user who created, for accounting */
14562 + struct vx_info *vxi;
14563 struct sock *notify_sock;
14564 struct sk_buff *notify_cookie;
14566 @@ -125,6 +128,7 @@ static struct inode *mqueue_get_inode(st
14567 if (S_ISREG(mode)) {
14568 struct mqueue_inode_info *info;
14569 struct task_struct *p = current;
14570 + struct vx_info *vxi = p->vx_info;
14571 unsigned long mq_bytes, mq_msg_tblsz;
14573 inode->i_fop = &mqueue_file_operations;
14574 @@ -138,6 +142,7 @@ static struct inode *mqueue_get_inode(st
14575 info->notify_owner = NULL;
14577 info->user = NULL; /* set when all is ok */
14578 + info->vxi = NULL;
14579 memset(&info->attr, 0, sizeof(info->attr));
14580 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14581 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14582 @@ -156,16 +161,19 @@ static struct inode *mqueue_get_inode(st
14583 spin_lock(&mq_lock);
14584 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14585 u->mq_bytes + mq_bytes >
14586 - task_rlimit(p, RLIMIT_MSGQUEUE)) {
14587 + task_rlimit(p, RLIMIT_MSGQUEUE) ||
14588 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14589 spin_unlock(&mq_lock);
14590 /* mqueue_evict_inode() releases info->messages */
14593 u->mq_bytes += mq_bytes;
14594 + vx_ipcmsg_add(vxi, u, mq_bytes);
14595 spin_unlock(&mq_lock);
14598 info->user = get_uid(u);
14599 + info->vxi = get_vx_info(vxi);
14600 } else if (S_ISDIR(mode)) {
14602 /* Some things misbehave if size == 0 on a directory */
14603 @@ -267,8 +275,11 @@ static void mqueue_evict_inode(struct in
14604 + info->attr.mq_msgsize);
14607 + struct vx_info *vxi = info->vxi;
14609 spin_lock(&mq_lock);
14610 user->mq_bytes -= mq_bytes;
14611 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14613 * get_ns_from_inode() ensures that the
14614 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14615 @@ -278,6 +289,7 @@ static void mqueue_evict_inode(struct in
14617 ipc_ns->mq_queues_count--;
14618 spin_unlock(&mq_lock);
14619 + put_vx_info(vxi);
14623 diff -NurpP --minimal linux-2.6.36/ipc/msg.c linux-2.6.36-vs2.3.0.36.38/ipc/msg.c
14624 --- linux-2.6.36/ipc/msg.c 2010-08-02 16:52:57.000000000 +0200
14625 +++ linux-2.6.36-vs2.3.0.36.38/ipc/msg.c 2010-10-21 13:09:36.000000000 +0200
14627 #include <linux/rwsem.h>
14628 #include <linux/nsproxy.h>
14629 #include <linux/ipc_namespace.h>
14630 +#include <linux/vs_base.h>
14632 #include <asm/current.h>
14633 #include <asm/uaccess.h>
14634 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14636 msq->q_perm.mode = msgflg & S_IRWXUGO;
14637 msq->q_perm.key = key;
14638 + msq->q_perm.xid = vx_current_xid();
14640 msq->q_perm.security = NULL;
14641 retval = security_msg_queue_alloc(msq);
14642 diff -NurpP --minimal linux-2.6.36/ipc/namespace.c linux-2.6.36-vs2.3.0.36.38/ipc/namespace.c
14643 --- linux-2.6.36/ipc/namespace.c 2009-09-10 15:26:27.000000000 +0200
14644 +++ linux-2.6.36-vs2.3.0.36.38/ipc/namespace.c 2010-10-21 13:09:36.000000000 +0200
14646 #include <linux/slab.h>
14647 #include <linux/fs.h>
14648 #include <linux/mount.h>
14649 +#include <linux/vs_base.h>
14650 +#include <linux/vserver/global.h>
14654 diff -NurpP --minimal linux-2.6.36/ipc/sem.c linux-2.6.36-vs2.3.0.36.38/ipc/sem.c
14655 --- linux-2.6.36/ipc/sem.c 2010-10-21 13:07:56.000000000 +0200
14656 +++ linux-2.6.36-vs2.3.0.36.38/ipc/sem.c 2010-10-21 13:09:36.000000000 +0200
14658 #include <linux/rwsem.h>
14659 #include <linux/nsproxy.h>
14660 #include <linux/ipc_namespace.h>
14661 +#include <linux/vs_base.h>
14662 +#include <linux/vs_limit.h>
14664 #include <asm/uaccess.h>
14666 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
14668 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14669 sma->sem_perm.key = key;
14670 + sma->sem_perm.xid = vx_current_xid();
14672 sma->sem_perm.security = NULL;
14673 retval = security_sem_alloc(sma);
14674 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
14677 ns->used_sems += nsems;
14678 + /* FIXME: obsoleted? */
14679 + vx_semary_inc(sma);
14680 + vx_nsems_add(sma, nsems);
14682 sma->sem_base = (struct sem *) &sma[1];
14684 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
14686 wake_up_sem_queue_do(&tasks);
14687 ns->used_sems -= sma->sem_nsems;
14688 + /* FIXME: obsoleted? */
14689 + vx_nsems_sub(sma, sma->sem_nsems);
14690 + vx_semary_dec(sma);
14691 security_sem_free(sma);
14692 ipc_rcu_putref(sma);
14694 diff -NurpP --minimal linux-2.6.36/ipc/shm.c linux-2.6.36-vs2.3.0.36.38/ipc/shm.c
14695 --- linux-2.6.36/ipc/shm.c 2010-08-02 16:52:57.000000000 +0200
14696 +++ linux-2.6.36-vs2.3.0.36.38/ipc/shm.c 2010-10-21 13:09:36.000000000 +0200
14698 #include <linux/nsproxy.h>
14699 #include <linux/mount.h>
14700 #include <linux/ipc_namespace.h>
14701 +#include <linux/vs_context.h>
14702 +#include <linux/vs_limit.h>
14704 #include <asm/uaccess.h>
14706 @@ -169,7 +171,12 @@ static void shm_open(struct vm_area_stru
14708 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14710 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14711 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14712 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14714 + vx_ipcshm_sub(vxi, shp, numpages);
14715 + ns->shm_tot -= numpages;
14719 if (!is_file_hugepages(shp->shm_file))
14720 @@ -179,6 +186,7 @@ static void shm_destroy(struct ipc_names
14722 fput (shp->shm_file);
14723 security_shm_free(shp);
14724 + put_vx_info(vxi);
14725 ipc_rcu_putref(shp);
14728 @@ -349,11 +357,15 @@ static int newseg(struct ipc_namespace *
14729 if (ns->shm_tot + numpages > ns->shm_ctlall)
14732 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14735 shp = ipc_rcu_alloc(sizeof(*shp));
14739 shp->shm_perm.key = key;
14740 + shp->shm_perm.xid = vx_current_xid();
14741 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14742 shp->mlock_user = NULL;
14744 @@ -407,6 +419,7 @@ static int newseg(struct ipc_namespace *
14745 ns->shm_tot += numpages;
14746 error = shp->shm_perm.id;
14748 + vx_ipcshm_add(current_vx_info(), key, numpages);
14752 diff -NurpP --minimal linux-2.6.36/kernel/Makefile linux-2.6.36-vs2.3.0.36.38/kernel/Makefile
14753 --- linux-2.6.36/kernel/Makefile 2010-10-21 13:07:56.000000000 +0200
14754 +++ linux-2.6.36-vs2.3.0.36.38/kernel/Makefile 2010-10-21 13:09:36.000000000 +0200
14755 @@ -25,6 +25,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
14756 CFLAGS_REMOVE_perf_event.o = -pg
14760 obj-$(CONFIG_FREEZER) += freezer.o
14761 obj-$(CONFIG_PROFILING) += profile.o
14762 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
14763 diff -NurpP --minimal linux-2.6.36/kernel/capability.c linux-2.6.36-vs2.3.0.36.38/kernel/capability.c
14764 --- linux-2.6.36/kernel/capability.c 2010-08-02 16:52:57.000000000 +0200
14765 +++ linux-2.6.36-vs2.3.0.36.38/kernel/capability.c 2010-10-21 13:09:36.000000000 +0200
14767 #include <linux/security.h>
14768 #include <linux/syscalls.h>
14769 #include <linux/pid_namespace.h>
14770 +#include <linux/vs_context.h>
14771 #include <asm/uaccess.h>
14774 @@ -119,6 +120,7 @@ static int cap_validate_magic(cap_user_h
14780 * The only thing that can change the capabilities of the current
14781 * process is the current process. As such, we can't be in this code
14782 @@ -289,6 +291,8 @@ error:
14786 +#include <linux/vserver/base.h>
14789 * capable - Determine if the current task has a superior capability in effect
14790 * @cap: The capability to be tested for
14791 @@ -301,6 +305,9 @@ error:
14793 int capable(int cap)
14795 + /* here for now so we don't require task locking */
14796 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
14798 if (unlikely(!cap_valid(cap))) {
14799 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
14801 diff -NurpP --minimal linux-2.6.36/kernel/compat.c linux-2.6.36-vs2.3.0.36.38/kernel/compat.c
14802 --- linux-2.6.36/kernel/compat.c 2010-10-21 13:07:56.000000000 +0200
14803 +++ linux-2.6.36-vs2.3.0.36.38/kernel/compat.c 2010-10-21 14:22:43.000000000 +0200
14804 @@ -914,7 +914,7 @@ asmlinkage long compat_sys_stime(compat_
14808 - do_settimeofday(&tv);
14809 + vx_settimeofday(&tv);
14813 diff -NurpP --minimal linux-2.6.36/kernel/exit.c linux-2.6.36-vs2.3.0.36.38/kernel/exit.c
14814 --- linux-2.6.36/kernel/exit.c 2010-10-21 13:07:56.000000000 +0200
14815 +++ linux-2.6.36-vs2.3.0.36.38/kernel/exit.c 2010-10-21 13:09:36.000000000 +0200
14817 #include <linux/fs_struct.h>
14818 #include <linux/init_task.h>
14819 #include <linux/perf_event.h>
14820 +#include <linux/vs_limit.h>
14821 +#include <linux/vs_context.h>
14822 +#include <linux/vs_network.h>
14823 +#include <linux/vs_pid.h>
14824 #include <trace/events/sched.h>
14825 #include <linux/hw_breakpoint.h>
14827 @@ -487,9 +491,11 @@ static void close_files(struct files_str
14828 filp_close(file, files);
14831 + vx_openfd_dec(i);
14839 @@ -1023,11 +1029,16 @@ NORET_TYPE void do_exit(long code)
14841 validate_creds_for_do_exit(tsk);
14843 + /* needs to stay after exit_notify() */
14844 + exit_vx_info(tsk, code);
14845 + exit_nx_info(tsk);
14849 /* causes final put_task_struct in finish_task_switch(). */
14850 tsk->state = TASK_DEAD;
14852 + printk("bad task: %p [%lx]\n", current, current->state);
14854 /* Avoid "noreturn function does return". */
14856 diff -NurpP --minimal linux-2.6.36/kernel/fork.c linux-2.6.36-vs2.3.0.36.38/kernel/fork.c
14857 --- linux-2.6.36/kernel/fork.c 2010-10-21 13:07:56.000000000 +0200
14858 +++ linux-2.6.36-vs2.3.0.36.38/kernel/fork.c 2010-10-21 13:09:36.000000000 +0200
14860 #include <linux/perf_event.h>
14861 #include <linux/posix-timers.h>
14862 #include <linux/user-return-notifier.h>
14863 +#include <linux/vs_context.h>
14864 +#include <linux/vs_network.h>
14865 +#include <linux/vs_limit.h>
14866 +#include <linux/vs_memory.h>
14868 #include <asm/pgtable.h>
14869 #include <asm/pgalloc.h>
14870 @@ -160,6 +164,8 @@ void free_task(struct task_struct *tsk)
14871 account_kernel_stack(tsk->stack, -1);
14872 free_thread_info(tsk->stack);
14873 rt_mutex_debug_task_free(tsk);
14874 + clr_vx_info(&tsk->vx_info);
14875 + clr_nx_info(&tsk->nx_info);
14876 ftrace_graph_exit_task(tsk);
14877 free_task_struct(tsk);
14879 @@ -492,6 +498,7 @@ static struct mm_struct * mm_init(struct
14880 if (likely(!mm_alloc_pgd(mm))) {
14882 mmu_notifier_mm_init(mm);
14883 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14887 @@ -525,6 +532,7 @@ void __mmdrop(struct mm_struct *mm)
14889 destroy_context(mm);
14890 mmu_notifier_mm_destroy(mm);
14891 + clr_vx_info(&mm->mm_vx_info);
14894 EXPORT_SYMBOL_GPL(__mmdrop);
14895 @@ -660,6 +668,7 @@ struct mm_struct *dup_mm(struct task_str
14898 memcpy(mm, oldmm, sizeof(*mm));
14899 + mm->mm_vx_info = NULL;
14901 /* Initializing for Swap token stuff */
14902 mm->token_priority = 0;
14903 @@ -698,6 +707,7 @@ fail_nocontext:
14904 * If init_new_context() failed, we cannot use mmput() to free the mm
14905 * because it calls destroy_context()
14907 + clr_vx_info(&mm->mm_vx_info);
14911 @@ -973,6 +983,8 @@ static struct task_struct *copy_process(
14913 struct task_struct *p;
14914 int cgroup_callbacks_done = 0;
14915 + struct vx_info *vxi;
14916 + struct nx_info *nxi;
14918 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14919 return ERR_PTR(-EINVAL);
14920 @@ -1019,7 +1031,12 @@ static struct task_struct *copy_process(
14921 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14922 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14924 + init_vx_info(&p->vx_info, current_vx_info());
14925 + init_nx_info(&p->nx_info, current_nx_info());
14928 + if (!vx_nproc_avail(1))
14929 + goto bad_fork_free;
14930 if (atomic_read(&p->real_cred->user->processes) >=
14931 task_rlimit(p, RLIMIT_NPROC)) {
14932 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14933 @@ -1284,6 +1301,18 @@ static struct task_struct *copy_process(
14936 spin_unlock(¤t->sighand->siglock);
14938 + /* p is copy of current */
14939 + vxi = p->vx_info;
14941 + claim_vx_info(vxi, p);
14942 + atomic_inc(&vxi->cvirt.nr_threads);
14943 + atomic_inc(&vxi->cvirt.total_forks);
14946 + nxi = p->nx_info;
14948 + claim_nx_info(nxi, p);
14949 write_unlock_irq(&tasklist_lock);
14950 proc_fork_connector(p);
14951 cgroup_post_fork(p);
14952 diff -NurpP --minimal linux-2.6.36/kernel/kthread.c linux-2.6.36-vs2.3.0.36.38/kernel/kthread.c
14953 --- linux-2.6.36/kernel/kthread.c 2010-10-21 13:07:57.000000000 +0200
14954 +++ linux-2.6.36-vs2.3.0.36.38/kernel/kthread.c 2010-10-21 13:42:40.000000000 +0200
14956 #include <linux/mutex.h>
14957 #include <linux/slab.h>
14958 #include <linux/freezer.h>
14959 +#include <linux/vs_pid.h>
14960 #include <trace/events/sched.h>
14962 static DEFINE_SPINLOCK(kthread_create_lock);
14963 diff -NurpP --minimal linux-2.6.36/kernel/nsproxy.c linux-2.6.36-vs2.3.0.36.38/kernel/nsproxy.c
14964 --- linux-2.6.36/kernel/nsproxy.c 2010-07-07 18:31:57.000000000 +0200
14965 +++ linux-2.6.36-vs2.3.0.36.38/kernel/nsproxy.c 2010-10-21 13:09:36.000000000 +0200
14967 #include <linux/mnt_namespace.h>
14968 #include <linux/utsname.h>
14969 #include <linux/pid_namespace.h>
14970 +#include <linux/vserver/global.h>
14971 +#include <linux/vserver/debug.h>
14972 #include <net/net_namespace.h>
14973 #include <linux/ipc_namespace.h>
14975 @@ -43,8 +45,11 @@ static inline struct nsproxy *create_nsp
14976 struct nsproxy *nsproxy;
14978 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14981 atomic_set(&nsproxy->count, 1);
14982 + atomic_inc(&vs_global_nsproxy);
14984 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14988 @@ -53,41 +58,52 @@ static inline struct nsproxy *create_nsp
14989 * Return the newly created nsproxy. Do not attach this to the task,
14990 * leave it to the caller to do proper locking and attach it to task.
14992 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14993 - struct task_struct *tsk, struct fs_struct *new_fs)
14994 +static struct nsproxy *unshare_namespaces(unsigned long flags,
14995 + struct nsproxy *orig, struct fs_struct *new_fs)
14997 struct nsproxy *new_nsp;
15000 + vxdprintk(VXD_CBIT(space, 4),
15001 + "unshare_namespaces(0x%08lx,%p,%p)",
15002 + flags, orig, new_fs);
15004 new_nsp = create_nsproxy();
15006 return ERR_PTR(-ENOMEM);
15008 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15009 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15010 if (IS_ERR(new_nsp->mnt_ns)) {
15011 err = PTR_ERR(new_nsp->mnt_ns);
15015 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15016 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15017 if (IS_ERR(new_nsp->uts_ns)) {
15018 err = PTR_ERR(new_nsp->uts_ns);
15022 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15023 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15024 if (IS_ERR(new_nsp->ipc_ns)) {
15025 err = PTR_ERR(new_nsp->ipc_ns);
15029 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15030 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15031 if (IS_ERR(new_nsp->pid_ns)) {
15032 err = PTR_ERR(new_nsp->pid_ns);
15036 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15038 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15039 + if (IS_ERR(new_nsp->user_ns)) {
15040 + err = PTR_ERR(new_nsp->user_ns);
15044 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15045 if (IS_ERR(new_nsp->net_ns)) {
15046 err = PTR_ERR(new_nsp->net_ns);
15048 @@ -112,6 +128,38 @@ out_ns:
15049 return ERR_PTR(err);
15052 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15053 + struct fs_struct *new_fs)
15055 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15059 + * copies the nsproxy, setting refcount to 1, and grabbing a
15060 + * reference to all contained namespaces.
15062 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15064 + struct nsproxy *ns = create_nsproxy();
15067 + memcpy(ns, orig, sizeof(struct nsproxy));
15068 + atomic_set(&ns->count, 1);
15071 + get_mnt_ns(ns->mnt_ns);
15073 + get_uts_ns(ns->uts_ns);
15075 + get_ipc_ns(ns->ipc_ns);
15077 + get_pid_ns(ns->pid_ns);
15079 + get_net(ns->net_ns);
15085 * called from clone. This now handles copy for nsproxy and all
15086 * namespaces therein.
15087 @@ -119,9 +167,12 @@ out_ns:
15088 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15090 struct nsproxy *old_ns = tsk->nsproxy;
15091 - struct nsproxy *new_ns;
15092 + struct nsproxy *new_ns = NULL;
15095 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15096 + flags, tsk, old_ns);
15101 @@ -131,7 +182,7 @@ int copy_namespaces(unsigned long flags,
15102 CLONE_NEWPID | CLONE_NEWNET)))
15105 - if (!capable(CAP_SYS_ADMIN)) {
15106 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
15110 @@ -158,6 +209,9 @@ int copy_namespaces(unsigned long flags,
15113 put_nsproxy(old_ns);
15114 + vxdprintk(VXD_CBIT(space, 3),
15115 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15116 + flags, tsk, old_ns, err, new_ns);
15120 @@ -171,7 +225,9 @@ void free_nsproxy(struct nsproxy *ns)
15121 put_ipc_ns(ns->ipc_ns);
15123 put_pid_ns(ns->pid_ns);
15124 - put_net(ns->net_ns);
15126 + put_net(ns->net_ns);
15127 + atomic_dec(&vs_global_nsproxy);
15128 kmem_cache_free(nsproxy_cachep, ns);
15131 @@ -184,11 +240,15 @@ int unshare_nsproxy_namespaces(unsigned
15135 + vxdprintk(VXD_CBIT(space, 4),
15136 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15137 + unshare_flags, current->nsproxy);
15139 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15143 - if (!capable(CAP_SYS_ADMIN))
15144 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
15147 *new_nsp = create_new_namespaces(unshare_flags, current,
15148 diff -NurpP --minimal linux-2.6.36/kernel/pid.c linux-2.6.36-vs2.3.0.36.38/kernel/pid.c
15149 --- linux-2.6.36/kernel/pid.c 2010-10-21 13:07:57.000000000 +0200
15150 +++ linux-2.6.36-vs2.3.0.36.38/kernel/pid.c 2010-10-21 13:09:36.000000000 +0200
15152 #include <linux/pid_namespace.h>
15153 #include <linux/init_task.h>
15154 #include <linux/syscalls.h>
15155 +#include <linux/vs_pid.h>
15157 #define pid_hashfn(nr, ns) \
15158 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15159 @@ -339,7 +340,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15161 struct pid *find_vpid(int nr)
15163 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15164 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15166 EXPORT_SYMBOL_GPL(find_vpid);
15168 @@ -399,6 +400,9 @@ void transfer_pid(struct task_struct *ol
15169 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15171 struct task_struct *result = NULL;
15173 + if (type == PIDTYPE_REALPID)
15174 + type = PIDTYPE_PID;
15176 struct hlist_node *first;
15177 first = rcu_dereference_check(pid->tasks[type].first,
15178 @@ -416,7 +420,7 @@ EXPORT_SYMBOL(pid_task);
15180 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15182 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15183 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15186 struct task_struct *find_task_by_vpid(pid_t vnr)
15187 @@ -458,7 +462,7 @@ struct pid *find_get_pid(pid_t nr)
15189 EXPORT_SYMBOL_GPL(find_get_pid);
15191 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15192 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15196 @@ -471,6 +475,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15200 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15202 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15205 pid_t pid_vnr(struct pid *pid)
15207 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15208 diff -NurpP --minimal linux-2.6.36/kernel/pid_namespace.c linux-2.6.36-vs2.3.0.36.38/kernel/pid_namespace.c
15209 --- linux-2.6.36/kernel/pid_namespace.c 2010-07-07 18:31:57.000000000 +0200
15210 +++ linux-2.6.36-vs2.3.0.36.38/kernel/pid_namespace.c 2010-10-21 13:09:36.000000000 +0200
15212 #include <linux/err.h>
15213 #include <linux/acct.h>
15214 #include <linux/slab.h>
15215 +#include <linux/vserver/global.h>
15217 #define BITS_PER_PAGE (PAGE_SIZE*8)
15219 @@ -87,6 +88,7 @@ static struct pid_namespace *create_pid_
15222 kref_init(&ns->kref);
15223 + atomic_inc(&vs_global_pid_ns);
15225 ns->parent = get_pid_ns(parent_pid_ns);
15227 @@ -112,6 +114,7 @@ static void destroy_pid_namespace(struct
15229 for (i = 0; i < PIDMAP_ENTRIES; i++)
15230 kfree(ns->pidmap[i].page);
15231 + atomic_dec(&vs_global_pid_ns);
15232 kmem_cache_free(pid_ns_cachep, ns);
15235 diff -NurpP --minimal linux-2.6.36/kernel/posix-timers.c linux-2.6.36-vs2.3.0.36.38/kernel/posix-timers.c
15236 --- linux-2.6.36/kernel/posix-timers.c 2010-10-21 13:07:57.000000000 +0200
15237 +++ linux-2.6.36-vs2.3.0.36.38/kernel/posix-timers.c 2010-10-21 13:09:36.000000000 +0200
15239 #include <linux/wait.h>
15240 #include <linux/workqueue.h>
15241 #include <linux/module.h>
15242 +#include <linux/vs_context.h>
15245 * Management arrays for POSIX timers. Timers are kept in slab memory
15246 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
15248 struct task_struct *task;
15249 int shared, ret = -1;
15252 * FIXME: if ->sigq is queued we can race with
15253 * dequeue_signal()->do_schedule_next_timer().
15254 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
15256 task = pid_task(timr->it_pid, PIDTYPE_PID);
15258 + struct vx_info_save vxis;
15259 + struct vx_info *vxi;
15261 + vxi = get_vx_info(task->vx_info);
15262 + enter_vx_info(vxi, &vxis);
15263 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15264 ret = send_sigqueue(timr->sigq, task, shared);
15265 + leave_vx_info(&vxis);
15266 + put_vx_info(vxi);
15270 /* If we failed to send the signal the timer stops. */
15273 diff -NurpP --minimal linux-2.6.36/kernel/printk.c linux-2.6.36-vs2.3.0.36.38/kernel/printk.c
15274 --- linux-2.6.36/kernel/printk.c 2010-10-21 13:07:57.000000000 +0200
15275 +++ linux-2.6.36-vs2.3.0.36.38/kernel/printk.c 2010-10-21 13:43:06.000000000 +0200
15277 #include <linux/syslog.h>
15278 #include <linux/cpu.h>
15279 #include <linux/notifier.h>
15280 +#include <linux/vs_cvirt.h>
15282 #include <asm/uaccess.h>
15284 @@ -266,18 +267,15 @@ int do_syslog(int type, char __user *buf
15285 unsigned i, j, limit, count;
15291 error = security_syslog(type, from_file);
15296 - case SYSLOG_ACTION_CLOSE: /* Close log */
15298 - case SYSLOG_ACTION_OPEN: /* Open log */
15300 - case SYSLOG_ACTION_READ: /* Read from log */
15301 + if ((type == SYSLOG_ACTION_READ) ||
15302 + (type == SYSLOG_ACTION_READ_ALL) ||
15303 + (type == SYSLOG_ACTION_READ_CLEAR)) {
15305 if (!buf || len < 0)
15307 @@ -288,6 +286,16 @@ int do_syslog(int type, char __user *buf
15312 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15313 + return vx_do_syslog(type, buf, len);
15316 + case SYSLOG_ACTION_CLOSE: /* Close log */
15318 + case SYSLOG_ACTION_OPEN: /* Open log */
15320 + case SYSLOG_ACTION_READ: /* Read from log */
15321 error = wait_event_interruptible(log_wait,
15322 (log_start - log_end));
15324 @@ -314,16 +322,6 @@ int do_syslog(int type, char __user *buf
15326 /* Read last kernel messages */
15327 case SYSLOG_ACTION_READ_ALL:
15329 - if (!buf || len < 0)
15334 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15339 if (count > log_buf_len)
15340 count = log_buf_len;
15341 diff -NurpP --minimal linux-2.6.36/kernel/ptrace.c linux-2.6.36-vs2.3.0.36.38/kernel/ptrace.c
15342 --- linux-2.6.36/kernel/ptrace.c 2010-10-21 13:07:57.000000000 +0200
15343 +++ linux-2.6.36-vs2.3.0.36.38/kernel/ptrace.c 2010-10-21 13:09:36.000000000 +0200
15345 #include <linux/syscalls.h>
15346 #include <linux/uaccess.h>
15347 #include <linux/regset.h>
15348 +#include <linux/vs_context.h>
15352 @@ -150,6 +151,11 @@ int __ptrace_may_access(struct task_stru
15353 dumpable = get_dumpable(task->mm);
15354 if (!dumpable && !capable(CAP_SYS_PTRACE))
15356 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
15358 + if (!vx_check(task->xid, VS_IDENT) &&
15359 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15362 return security_ptrace_access_check(task, mode);
15364 @@ -709,6 +715,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
15369 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
15370 + goto out_put_task_struct;
15372 if (request == PTRACE_ATTACH) {
15373 ret = ptrace_attach(child);
15375 diff -NurpP --minimal linux-2.6.36/kernel/sched.c linux-2.6.36-vs2.3.0.36.38/kernel/sched.c
15376 --- linux-2.6.36/kernel/sched.c 2010-10-21 13:07:57.000000000 +0200
15377 +++ linux-2.6.36-vs2.3.0.36.38/kernel/sched.c 2010-10-21 13:09:36.000000000 +0200
15379 #include <linux/ctype.h>
15380 #include <linux/ftrace.h>
15381 #include <linux/slab.h>
15382 +#include <linux/vs_sched.h>
15383 +#include <linux/vs_cvirt.h>
15385 #include <asm/tlb.h>
15386 #include <asm/irq_regs.h>
15387 @@ -3024,9 +3026,17 @@ static inline long calc_load_fold_idle(v
15389 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
15391 - loads[0] = (avenrun[0] + offset) << shift;
15392 - loads[1] = (avenrun[1] + offset) << shift;
15393 - loads[2] = (avenrun[2] + offset) << shift;
15394 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
15395 + struct vx_info *vxi = current_vx_info();
15397 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
15398 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
15399 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
15401 + loads[0] = (avenrun[0] + offset) << shift;
15402 + loads[1] = (avenrun[1] + offset) << shift;
15403 + loads[2] = (avenrun[2] + offset) << shift;
15407 static unsigned long
15408 @@ -3321,16 +3331,19 @@ void account_user_time(struct task_struc
15409 cputime_t cputime_scaled)
15411 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15412 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15414 + int nice = (TASK_NICE(p) > 0);
15416 /* Add user time to process. */
15417 p->utime = cputime_add(p->utime, cputime);
15418 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15419 + vx_account_user(vxi, cputime, nice);
15420 account_group_user_time(p, cputime);
15422 /* Add user time to cpustat. */
15423 tmp = cputime_to_cputime64(cputime);
15424 - if (TASK_NICE(p) > 0)
15426 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15428 cpustat->user = cputime64_add(cpustat->user, tmp);
15429 @@ -3381,6 +3394,7 @@ void account_system_time(struct task_str
15430 cputime_t cputime, cputime_t cputime_scaled)
15432 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15433 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15436 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
15437 @@ -3391,6 +3405,7 @@ void account_system_time(struct task_str
15438 /* Add system time to process. */
15439 p->stime = cputime_add(p->stime, cputime);
15440 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15441 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15442 account_group_system_time(p, cputime);
15444 /* Add system time to cpustat. */
15445 @@ -4477,7 +4492,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15448 if (increment < 0 && !can_nice(current, nice))
15450 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15452 retval = security_task_setnice(current, nice);
15454 diff -NurpP --minimal linux-2.6.36/kernel/sched_fair.c linux-2.6.36-vs2.3.0.36.38/kernel/sched_fair.c
15455 --- linux-2.6.36/kernel/sched_fair.c 2010-10-21 13:07:57.000000000 +0200
15456 +++ linux-2.6.36-vs2.3.0.36.38/kernel/sched_fair.c 2010-10-21 13:09:36.000000000 +0200
15457 @@ -782,6 +782,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15458 check_spread(cfs_rq, se);
15459 if (se != cfs_rq->curr)
15460 __enqueue_entity(cfs_rq, se);
15462 + if (entity_is_task(se))
15463 + vx_activate_task(task_of(se));
15466 static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
15467 @@ -825,6 +828,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15469 if (se != cfs_rq->curr)
15470 __dequeue_entity(cfs_rq, se);
15471 + if (entity_is_task(se))
15472 + vx_deactivate_task(task_of(se));
15473 account_entity_dequeue(cfs_rq, se);
15474 update_min_vruntime(cfs_rq);
15476 diff -NurpP --minimal linux-2.6.36/kernel/signal.c linux-2.6.36-vs2.3.0.36.38/kernel/signal.c
15477 --- linux-2.6.36/kernel/signal.c 2010-10-21 13:07:57.000000000 +0200
15478 +++ linux-2.6.36-vs2.3.0.36.38/kernel/signal.c 2010-10-21 13:09:36.000000000 +0200
15480 #include <linux/freezer.h>
15481 #include <linux/pid_namespace.h>
15482 #include <linux/nsproxy.h>
15483 +#include <linux/vs_context.h>
15484 +#include <linux/vs_pid.h>
15485 #define CREATE_TRACE_POINTS
15486 #include <trace/events/signal.h>
15488 @@ -646,9 +648,18 @@ static int check_kill_permission(int sig
15492 + vxdprintk(VXD_CBIT(misc, 7),
15493 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15494 + sig, info, t, vx_task_xid(t), t->pid);
15496 if (!valid_signal(sig))
15499 +/* FIXME: needed? if so, why?
15500 + if ((info != SEND_SIG_NOINFO) &&
15501 + (is_si_special(info) || !si_fromuser(info)))
15504 if (!si_fromuser(info))
15507 @@ -678,6 +689,20 @@ static int check_kill_permission(int sig
15512 + if (t->pid == 1 && current->xid)
15516 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15517 + loops, maybe ENOENT or EACCES? */
15518 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15519 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15520 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15521 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15525 return security_task_kill(t, info, sig, 0);
15528 @@ -1170,7 +1195,7 @@ int kill_pid_info(int sig, struct siginf
15531 p = pid_task(pid, PIDTYPE_PID);
15533 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15534 error = group_send_sig_info(sig, info, p);
15535 if (unlikely(error == -ESRCH))
15537 @@ -1210,7 +1235,7 @@ int kill_pid_info_as_uid(int sig, struct
15540 p = pid_task(pid, PIDTYPE_PID);
15542 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15546 @@ -1265,8 +1290,10 @@ static int kill_something_info(int sig,
15547 struct task_struct * p;
15549 for_each_process(p) {
15550 - if (task_pid_vnr(p) > 1 &&
15551 - !same_thread_group(p, current)) {
15552 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15553 + task_pid_vnr(p) > 1 &&
15554 + !same_thread_group(p, current) &&
15555 + !vx_current_initpid(p->pid)) {
15556 int err = group_send_sig_info(sig, info, p);
15559 @@ -1933,6 +1960,11 @@ relock:
15560 !sig_kernel_only(signr))
15563 + /* virtual init is protected against user signals */
15564 + if ((info->si_code == SI_USER) &&
15565 + vx_current_initpid(current->pid))
15568 if (sig_kernel_stop(signr)) {
15570 * The default action is to stop all threads in
15571 diff -NurpP --minimal linux-2.6.36/kernel/softirq.c linux-2.6.36-vs2.3.0.36.38/kernel/softirq.c
15572 --- linux-2.6.36/kernel/softirq.c 2010-08-02 16:52:57.000000000 +0200
15573 +++ linux-2.6.36-vs2.3.0.36.38/kernel/softirq.c 2010-10-21 13:09:36.000000000 +0200
15575 #include <linux/ftrace.h>
15576 #include <linux/smp.h>
15577 #include <linux/tick.h>
15578 +#include <linux/vs_context.h>
15580 #define CREATE_TRACE_POINTS
15581 #include <trace/events/irq.h>
15582 diff -NurpP --minimal linux-2.6.36/kernel/sys.c linux-2.6.36-vs2.3.0.36.38/kernel/sys.c
15583 --- linux-2.6.36/kernel/sys.c 2010-10-21 13:07:57.000000000 +0200
15584 +++ linux-2.6.36-vs2.3.0.36.38/kernel/sys.c 2010-10-21 13:45:48.000000000 +0200
15586 #include <linux/syscalls.h>
15587 #include <linux/kprobes.h>
15588 #include <linux/user_namespace.h>
15589 +#include <linux/vs_pid.h>
15591 #include <asm/uaccess.h>
15592 #include <asm/io.h>
15593 @@ -131,7 +132,10 @@ static int set_one_prio(struct task_stru
15596 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15598 + if (vx_flags(VXF_IGNEG_NICE, 0))
15604 no_nice = security_task_setnice(p, niceval);
15605 @@ -181,6 +185,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15607 pgrp = task_pgrp(current);
15608 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15609 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15611 error = set_one_prio(p, niceval, error);
15612 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15614 @@ -244,6 +250,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15616 pgrp = task_pgrp(current);
15617 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15618 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15620 niceval = 20 - task_nice(p);
15621 if (niceval > retval)
15623 @@ -357,6 +365,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15625 static DEFINE_MUTEX(reboot_mutex);
15627 +long vs_reboot(unsigned int, void __user *);
15630 * Reboot system call: for obvious reasons only root may call it,
15631 * and even root needs to set up some magic numbers in the registers
15632 @@ -389,6 +399,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15633 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15634 cmd = LINUX_REBOOT_CMD_HALT;
15636 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15637 + return vs_reboot(cmd, arg);
15639 mutex_lock(&reboot_mutex);
15641 case LINUX_REBOOT_CMD_RESTART:
15642 @@ -1169,7 +1182,7 @@ SYSCALL_DEFINE2(sethostname, char __user
15644 char tmp[__NEW_UTS_LEN];
15646 - if (!capable(CAP_SYS_ADMIN))
15647 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15649 if (len < 0 || len > __NEW_UTS_LEN)
15651 @@ -1218,7 +1231,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
15653 char tmp[__NEW_UTS_LEN];
15655 - if (!capable(CAP_SYS_ADMIN))
15656 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15658 if (len < 0 || len > __NEW_UTS_LEN)
15660 @@ -1334,7 +1347,7 @@ int do_prlimit(struct task_struct *tsk,
15661 task_lock(tsk->group_leader);
15663 if (new_rlim->rlim_max > rlim->rlim_max &&
15664 - !capable(CAP_SYS_RESOURCE))
15665 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15668 retval = security_task_setrlimit(tsk->group_leader,
15669 @@ -1383,7 +1396,7 @@ static int check_prlimit_permission(stru
15670 cred->gid != tcred->egid ||
15671 cred->gid != tcred->sgid ||
15672 cred->gid != tcred->gid) &&
15673 - !capable(CAP_SYS_RESOURCE)) {
15674 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT)) {
15678 diff -NurpP --minimal linux-2.6.36/kernel/sysctl.c linux-2.6.36-vs2.3.0.36.38/kernel/sysctl.c
15679 --- linux-2.6.36/kernel/sysctl.c 2010-10-21 13:07:57.000000000 +0200
15680 +++ linux-2.6.36-vs2.3.0.36.38/kernel/sysctl.c 2010-10-21 13:09:36.000000000 +0200
15682 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15683 #include <linux/lockdep.h>
15685 +extern char vshelper_path[];
15686 #ifdef CONFIG_CHR_DEV_SG
15687 #include <scsi/sg.h>
15689 @@ -573,6 +574,13 @@ static struct ctl_table kern_table[] = {
15690 .proc_handler = proc_dostring,
15694 + .procname = "vshelper",
15695 + .data = &vshelper_path,
15698 + .proc_handler = &proc_dostring,
15700 #ifdef CONFIG_CHR_DEV_SG
15702 .procname = "sg-big-buff",
15703 diff -NurpP --minimal linux-2.6.36/kernel/sysctl_binary.c linux-2.6.36-vs2.3.0.36.38/kernel/sysctl_binary.c
15704 --- linux-2.6.36/kernel/sysctl_binary.c 2010-08-02 16:52:57.000000000 +0200
15705 +++ linux-2.6.36-vs2.3.0.36.38/kernel/sysctl_binary.c 2010-10-21 13:09:36.000000000 +0200
15706 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15708 { CTL_INT, KERN_PANIC, "panic" },
15709 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15710 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15712 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15713 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15714 diff -NurpP --minimal linux-2.6.36/kernel/time/timekeeping.c linux-2.6.36-vs2.3.0.36.38/kernel/time/timekeeping.c
15715 --- linux-2.6.36/kernel/time/timekeeping.c 2010-10-21 13:07:57.000000000 +0200
15716 +++ linux-2.6.36-vs2.3.0.36.38/kernel/time/timekeeping.c 2010-10-21 14:17:59.000000000 +0200
15717 @@ -229,6 +229,7 @@ void getnstimeofday(struct timespec *ts)
15718 } while (read_seqretry(&xtime_lock, seq));
15720 timespec_add_ns(ts, nsecs);
15721 + vx_adjust_timespec(ts);
15724 EXPORT_SYMBOL(getnstimeofday);
15725 diff -NurpP --minimal linux-2.6.36/kernel/time.c linux-2.6.36-vs2.3.0.36.38/kernel/time.c
15726 --- linux-2.6.36/kernel/time.c 2010-10-21 13:07:57.000000000 +0200
15727 +++ linux-2.6.36-vs2.3.0.36.38/kernel/time.c 2010-10-21 14:22:43.000000000 +0200
15728 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15732 - do_settimeofday(&tv);
15733 + vx_settimeofday(&tv);
15737 @@ -177,7 +177,7 @@ int do_sys_settimeofday(struct timespec
15738 /* SMP safe, again the code in arch/foo/time.c should
15739 * globally block out interrupts when it runs.
15741 - return do_settimeofday(tv);
15742 + return vx_settimeofday(tv);
15746 diff -NurpP --minimal linux-2.6.36/kernel/timer.c linux-2.6.36-vs2.3.0.36.38/kernel/timer.c
15747 --- linux-2.6.36/kernel/timer.c 2010-10-21 13:07:57.000000000 +0200
15748 +++ linux-2.6.36-vs2.3.0.36.38/kernel/timer.c 2010-10-21 13:09:36.000000000 +0200
15750 #include <linux/perf_event.h>
15751 #include <linux/sched.h>
15752 #include <linux/slab.h>
15753 +#include <linux/vs_base.h>
15754 +#include <linux/vs_cvirt.h>
15755 +#include <linux/vs_pid.h>
15756 +#include <linux/vserver/sched.h>
15758 #include <asm/uaccess.h>
15759 #include <asm/unistd.h>
15760 @@ -1332,12 +1336,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15767 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15768 - * should be moved into arch/i386 instead?
15772 * sys_getpid - return the thread group id of the current process
15773 @@ -1366,10 +1364,23 @@ SYSCALL_DEFINE0(getppid)
15775 pid = task_tgid_vnr(current->real_parent);
15777 + return vx_map_pid(pid);
15784 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15787 +asmlinkage long do_getxpid(long *ppid)
15789 + *ppid = sys_getppid();
15790 + return sys_getpid();
15793 +#else /* _alpha_ */
15795 SYSCALL_DEFINE0(getuid)
15797 /* Only we change this so SMP safe */
15798 diff -NurpP --minimal linux-2.6.36/kernel/user_namespace.c linux-2.6.36-vs2.3.0.36.38/kernel/user_namespace.c
15799 --- linux-2.6.36/kernel/user_namespace.c 2010-10-21 13:07:57.000000000 +0200
15800 +++ linux-2.6.36-vs2.3.0.36.38/kernel/user_namespace.c 2010-10-21 13:09:36.000000000 +0200
15802 #include <linux/user_namespace.h>
15803 #include <linux/highuid.h>
15804 #include <linux/cred.h>
15805 +#include <linux/vserver/global.h>
15808 * Create a new user namespace, deriving the creator from the user in the
15809 @@ -31,6 +32,7 @@ int create_user_ns(struct cred *new)
15812 kref_init(&ns->kref);
15813 + atomic_inc(&vs_global_user_ns);
15815 for (n = 0; n < UIDHASH_SZ; ++n)
15816 INIT_HLIST_HEAD(ns->uidhash_table + n);
15817 @@ -79,6 +81,8 @@ void free_user_ns(struct kref *kref)
15818 struct user_namespace *ns =
15819 container_of(kref, struct user_namespace, kref);
15821 + /* FIXME: maybe move into destroyer? */
15822 + atomic_dec(&vs_global_user_ns);
15823 INIT_WORK(&ns->destroyer, free_user_ns_work);
15824 schedule_work(&ns->destroyer);
15826 diff -NurpP --minimal linux-2.6.36/kernel/utsname.c linux-2.6.36-vs2.3.0.36.38/kernel/utsname.c
15827 --- linux-2.6.36/kernel/utsname.c 2009-09-10 15:26:28.000000000 +0200
15828 +++ linux-2.6.36-vs2.3.0.36.38/kernel/utsname.c 2010-10-21 13:09:36.000000000 +0200
15829 @@ -14,14 +14,17 @@
15830 #include <linux/utsname.h>
15831 #include <linux/err.h>
15832 #include <linux/slab.h>
15833 +#include <linux/vserver/global.h>
15835 static struct uts_namespace *create_uts_ns(void)
15837 struct uts_namespace *uts_ns;
15839 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15842 kref_init(&uts_ns->kref);
15843 + atomic_inc(&vs_global_uts_ns);
15848 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
15849 struct uts_namespace *ns;
15851 ns = container_of(kref, struct uts_namespace, kref);
15852 + atomic_dec(&vs_global_uts_ns);
15855 diff -NurpP --minimal linux-2.6.36/kernel/vserver/Kconfig linux-2.6.36-vs2.3.0.36.38/kernel/vserver/Kconfig
15856 --- linux-2.6.36/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
15857 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/Kconfig 2010-10-21 21:49:28.000000000 +0200
15860 +# Linux VServer configuration
15863 +menu "Linux VServer"
15865 +config VSERVER_AUTO_LBACK
15866 + bool "Automatically Assign Loopback IP"
15869 + Automatically assign a guest specific loopback
15870 + IP and add it to the kernel network stack on
15873 +config VSERVER_AUTO_SINGLE
15874 + bool "Automatic Single IP Special Casing"
15875 + depends on EXPERIMENTAL
15878 + This allows network contexts with a single IP to
15879 + automatically remap 0.0.0.0 bindings to that IP,
15880 + avoiding further network checks and improving
15883 + (note: such guests do not allow to change the ip
15884 + on the fly and do not show loopback addresses)
15886 +config VSERVER_COWBL
15887 + bool "Enable COW Immutable Link Breaking"
15890 + This enables the COW (Copy-On-Write) link break code.
15891 + It allows you to treat unified files like normal files
15892 + when writing to them (which will implicitely break the
15893 + link and create a copy of the unified file)
15895 +config VSERVER_VTIME
15896 + bool "Enable Virtualized Guest Time"
15897 + depends on EXPERIMENTAL
15900 + This enables per guest time offsets to allow for
15901 + adjusting the system clock individually per guest.
15902 + this adds some overhead to the time functions and
15903 + therefore should not be enabled without good reason.
15905 +config VSERVER_DEVICE
15906 + bool "Enable Guest Device Mapping"
15907 + depends on EXPERIMENTAL
15910 + This enables generic device remapping.
15912 +config VSERVER_PROC_SECURE
15913 + bool "Enable Proc Security"
15914 + depends on PROC_FS
15917 + This configures ProcFS security to initially hide
15918 + non-process entries for all contexts except the main and
15919 + spectator context (i.e. for all guests), which is a secure
15922 + (note: on 1.2x the entries were visible by default)
15924 +config VSERVER_HARDCPU
15925 + bool "Enable Hard CPU Limits"
15928 + Activate the Hard CPU Limits
15930 + This will compile in code that allows the Token Bucket
15931 + Scheduler to put processes on hold when a context's
15932 + tokens are depleted (provided that its per-context
15933 + sched_hard flag is set).
15935 + Processes belonging to that context will not be able
15936 + to consume CPU resources again until a per-context
15937 + configured minimum of tokens has been reached.
15939 +config VSERVER_IDLETIME
15940 + bool "Avoid idle CPUs by skipping Time"
15941 + depends on VSERVER_HARDCPU
15944 + This option allows the scheduler to artificially
15945 + advance time (per cpu) when otherwise the idle
15946 + task would be scheduled, thus keeping the cpu
15947 + busy and sharing the available resources among
15948 + certain contexts.
15950 +config VSERVER_IDLELIMIT
15951 + bool "Limit the IDLE task"
15952 + depends on VSERVER_HARDCPU
15955 + Limit the idle slices, so the the next context
15956 + will be scheduled as soon as possible.
15958 + This might improve interactivity and latency, but
15959 + will also marginally increase scheduling overhead.
15962 + prompt "Persistent Inode Tagging"
15963 + default TAGGING_ID24
15965 + This adds persistent context information to filesystems
15966 + mounted with the tagxid option. Tagging is a requirement
15967 + for per-context disk limits and per-context quota.
15970 +config TAGGING_NONE
15973 + do not store per-context information in inodes.
15975 +config TAGGING_UID16
15976 + bool "UID16/GID32"
15978 + reduces UID to 16 bit, but leaves GID at 32 bit.
15980 +config TAGGING_GID16
15981 + bool "UID32/GID16"
15983 + reduces GID to 16 bit, but leaves UID at 32 bit.
15985 +config TAGGING_ID24
15986 + bool "UID24/GID24"
15988 + uses the upper 8bit from UID and GID for XID tagging
15989 + which leaves 24bit for UID/GID each, which should be
15990 + more than sufficient for normal use.
15992 +config TAGGING_INTERN
15993 + bool "UID32/GID32"
15995 + this uses otherwise reserved inode fields in the on
15996 + disk representation, which limits the use to a few
15997 + filesystems (currently ext2 and ext3)
16002 + bool "Tag NFSD User Auth and Files"
16005 + Enable this if you do want the in-kernel NFS
16006 + Server to use the tagging specified above.
16007 + (will require patched clients too)
16009 +config VSERVER_PRIVACY
16010 + bool "Honor Privacy Aspects of Guests"
16013 + When enabled, most context checks will disallow
16014 + access to structures assigned to a specific context,
16015 + like ptys or loop devices.
16017 +config VSERVER_CONTEXTS
16018 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
16020 + default "768" if 64BIT
16023 + This setting will optimize certain data structures
16024 + and memory allocations according to the expected
16027 + note: this is not a strict upper limit.
16029 +config VSERVER_WARN
16030 + bool "VServer Warnings"
16033 + This enables various runtime warnings, which will
16034 + notify about potential manipulation attempts or
16035 + resource shortage. It is generally considered to
16036 + be a good idea to have that enabled.
16038 +config VSERVER_WARN_DEVPTS
16039 + bool "VServer DevPTS Warnings"
16040 + depends on VSERVER_WARN
16043 + This enables DevPTS related warnings, issued when a
16044 + process inside a context tries to lookup or access
16045 + a dynamic pts from the host or a different context.
16047 +config VSERVER_DEBUG
16048 + bool "VServer Debugging Code"
16051 + Set this to yes if you want to be able to activate
16052 + debugging output at runtime. It adds a very small
16053 + overhead to all vserver related functions and
16054 + increases the kernel size by about 20k.
16056 +config VSERVER_HISTORY
16057 + bool "VServer History Tracing"
16058 + depends on VSERVER_DEBUG
16061 + Set this to yes if you want to record the history of
16062 + linux-vserver activities, so they can be replayed in
16063 + the event of a kernel panic or oops.
16065 +config VSERVER_HISTORY_SIZE
16066 + int "Per-CPU History Size (32-65536)"
16067 + depends on VSERVER_HISTORY
16071 + This allows you to specify the number of entries in
16072 + the per-CPU history buffer.
16074 +config VSERVER_LEGACY_MEM
16075 + bool "Legacy Memory Limits"
16078 + This provides fake memory limits to keep
16079 + older tools happy in the face of memory
16083 + prompt "Quotes used in debug and warn messages"
16084 + default QUOTES_ISO8859
16086 +config QUOTES_ISO8859
16087 + bool "Extended ASCII (ISO 8859) angle quotes"
16089 + This uses the extended ASCII characters \xbb
16090 + and \xab for quoting file and process names.
16092 +config QUOTES_UTF8
16093 + bool "UTF-8 angle quotes"
16095 + This uses the the UTF-8 sequences for angle
16096 + quotes to quote file and process names.
16098 +config QUOTES_ASCII
16099 + bool "ASCII single quotes"
16101 + This uses the ASCII single quote character
16102 + (\x27) to quote file and process names.
16112 + select NAMESPACES
16118 +config VSERVER_SECURITY
16120 + depends on SECURITY
16122 + select SECURITY_CAPABILITIES
16124 diff -NurpP --minimal linux-2.6.36/kernel/vserver/Makefile linux-2.6.36-vs2.3.0.36.38/kernel/vserver/Makefile
16125 --- linux-2.6.36/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
16126 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/Makefile 2010-10-21 13:09:36.000000000 +0200
16129 +# Makefile for the Linux vserver routines.
16133 +obj-y += vserver.o
16135 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
16136 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
16139 +vserver-$(CONFIG_INET) += inet.o
16140 +vserver-$(CONFIG_PROC_FS) += proc.o
16141 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
16142 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
16143 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
16144 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
16146 diff -NurpP --minimal linux-2.6.36/kernel/vserver/cacct.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/cacct.c
16147 --- linux-2.6.36/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
16148 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/cacct.c 2010-10-21 13:09:36.000000000 +0200
16151 + * linux/kernel/vserver/cacct.c
16153 + * Virtual Server: Context Accounting
16155 + * Copyright (C) 2006-2007 Herbert Pötzl
16157 + * V0.01 added accounting stats
16161 +#include <linux/types.h>
16162 +#include <linux/vs_context.h>
16163 +#include <linux/vserver/cacct_cmd.h>
16164 +#include <linux/vserver/cacct_int.h>
16166 +#include <asm/errno.h>
16167 +#include <asm/uaccess.h>
16170 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
16172 + struct vcmd_sock_stat_v0 vc_data;
16175 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16178 + field = vc_data.field;
16179 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
16182 + for (j = 0; j < 3; j++) {
16183 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
16184 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
16187 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16192 diff -NurpP --minimal linux-2.6.36/kernel/vserver/cacct_init.h linux-2.6.36-vs2.3.0.36.38/kernel/vserver/cacct_init.h
16193 --- linux-2.6.36/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16194 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/cacct_init.h 2010-10-21 13:09:36.000000000 +0200
16198 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16203 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16204 + for (j = 0; j < 3; j++) {
16205 + atomic_long_set(&cacct->sock[i][j].count, 0);
16206 + atomic_long_set(&cacct->sock[i][j].total, 0);
16209 + for (i = 0; i < 8; i++)
16210 + atomic_set(&cacct->slab[i], 0);
16211 + for (i = 0; i < 5; i++)
16212 + for (j = 0; j < 4; j++)
16213 + atomic_set(&cacct->page[i][j], 0);
16216 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16221 diff -NurpP --minimal linux-2.6.36/kernel/vserver/cacct_proc.h linux-2.6.36-vs2.3.0.36.38/kernel/vserver/cacct_proc.h
16222 --- linux-2.6.36/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
16223 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/cacct_proc.h 2010-10-21 13:09:36.000000000 +0200
16225 +#ifndef _VX_CACCT_PROC_H
16226 +#define _VX_CACCT_PROC_H
16228 +#include <linux/vserver/cacct_int.h>
16231 +#define VX_SOCKA_TOP \
16232 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
16234 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
16236 + int i, j, length = 0;
16237 + static char *type[VXA_SOCK_SIZE] = {
16238 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
16241 + length += sprintf(buffer + length, VX_SOCKA_TOP);
16242 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16243 + length += sprintf(buffer + length, "%s:", type[i]);
16244 + for (j = 0; j < 3; j++) {
16245 + length += sprintf(buffer + length,
16246 + "\t%10lu/%-10lu",
16247 + vx_sock_count(cacct, i, j),
16248 + vx_sock_total(cacct, i, j));
16250 + buffer[length++] = '\n';
16253 + length += sprintf(buffer + length, "\n");
16254 + length += sprintf(buffer + length,
16255 + "slab:\t %8u %8u %8u %8u\n",
16256 + atomic_read(&cacct->slab[1]),
16257 + atomic_read(&cacct->slab[4]),
16258 + atomic_read(&cacct->slab[0]),
16259 + atomic_read(&cacct->slab[2]));
16261 + length += sprintf(buffer + length, "\n");
16262 + for (i = 0; i < 5; i++) {
16263 + length += sprintf(buffer + length,
16264 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
16265 + atomic_read(&cacct->page[i][0]),
16266 + atomic_read(&cacct->page[i][1]),
16267 + atomic_read(&cacct->page[i][2]),
16268 + atomic_read(&cacct->page[i][3]),
16269 + atomic_read(&cacct->page[i][4]),
16270 + atomic_read(&cacct->page[i][5]),
16271 + atomic_read(&cacct->page[i][6]),
16272 + atomic_read(&cacct->page[i][7]));
16277 +#endif /* _VX_CACCT_PROC_H */
16278 diff -NurpP --minimal linux-2.6.36/kernel/vserver/context.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/context.c
16279 --- linux-2.6.36/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
16280 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/context.c 2010-10-21 14:39:59.000000000 +0200
16283 + * linux/kernel/vserver/context.c
16285 + * Virtual Server: Context Support
16287 + * Copyright (C) 2003-2007 Herbert Pötzl
16289 + * V0.01 context helper
16290 + * V0.02 vx_ctx_kill syscall command
16291 + * V0.03 replaced context_info calls
16292 + * V0.04 redesign of struct (de)alloc
16293 + * V0.05 rlimit basic implementation
16294 + * V0.06 task_xid and info commands
16295 + * V0.07 context flags and caps
16296 + * V0.08 switch to RCU based hash
16297 + * V0.09 revert to non RCU for now
16298 + * V0.10 and back to working RCU hash
16299 + * V0.11 and back to locking again
16300 + * V0.12 referenced context store
16301 + * V0.13 separate per cpu data
16302 + * V0.14 changed vcmds to vxi arg
16303 + * V0.15 added context stat
16304 + * V0.16 have __create claim() the vxi
16305 + * V0.17 removed older and legacy stuff
16309 +#include <linux/slab.h>
16310 +#include <linux/types.h>
16311 +#include <linux/security.h>
16312 +#include <linux/pid_namespace.h>
16314 +#include <linux/vserver/context.h>
16315 +#include <linux/vserver/network.h>
16316 +#include <linux/vserver/debug.h>
16317 +#include <linux/vserver/limit.h>
16318 +#include <linux/vserver/limit_int.h>
16319 +#include <linux/vserver/space.h>
16320 +#include <linux/init_task.h>
16321 +#include <linux/fs_struct.h>
16323 +#include <linux/vs_context.h>
16324 +#include <linux/vs_limit.h>
16325 +#include <linux/vs_pid.h>
16326 +#include <linux/vserver/context_cmd.h>
16328 +#include "cvirt_init.h"
16329 +#include "cacct_init.h"
16330 +#include "limit_init.h"
16331 +#include "sched_init.h"
16334 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
16335 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
16338 +/* now inactive context structures */
16340 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
16342 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
16345 +/* __alloc_vx_info()
16347 + * allocate an initialized vx_info struct
16348 + * doesn't make it visible (hash) */
16350 +static struct vx_info *__alloc_vx_info(xid_t xid)
16352 + struct vx_info *new = NULL;
16355 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
16357 + /* would this benefit from a slab cache? */
16358 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
16362 + memset(new, 0, sizeof(struct vx_info));
16364 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
16365 + if (!new->ptr_pc)
16368 + new->vx_id = xid;
16369 + INIT_HLIST_NODE(&new->vx_hlist);
16370 + atomic_set(&new->vx_usecnt, 0);
16371 + atomic_set(&new->vx_tasks, 0);
16372 + new->vx_parent = NULL;
16373 + new->vx_state = 0;
16374 + init_waitqueue_head(&new->vx_wait);
16376 + /* prepare reaper */
16377 + get_task_struct(init_pid_ns.child_reaper);
16378 + new->vx_reaper = init_pid_ns.child_reaper;
16379 + new->vx_badness_bias = 0;
16381 + /* rest of init goes here */
16382 + vx_info_init_limit(&new->limit);
16383 + vx_info_init_sched(&new->sched);
16384 + vx_info_init_cvirt(&new->cvirt);
16385 + vx_info_init_cacct(&new->cacct);
16387 + /* per cpu data structures */
16388 + for_each_possible_cpu(cpu) {
16389 + vx_info_init_sched_pc(
16390 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16391 + vx_info_init_cvirt_pc(
16392 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16395 + new->vx_flags = VXF_INIT_SET;
16396 + cap_set_init_eff(new->vx_bcaps);
16397 + new->vx_ccaps = 0;
16398 + new->vx_umask = 0;
16400 + new->reboot_cmd = 0;
16401 + new->exit_code = 0;
16403 + // preconfig fs entries
16404 + for (index = 0; index < VX_SPACES; index++) {
16405 + spin_lock(&init_fs.lock);
16407 + spin_unlock(&init_fs.lock);
16408 + new->vx_fs[index] = &init_fs;
16411 + vxdprintk(VXD_CBIT(xid, 0),
16412 + "alloc_vx_info(%d) = %p", xid, new);
16413 + vxh_alloc_vx_info(new);
16414 + atomic_inc(&vx_global_ctotal);
16423 +/* __dealloc_vx_info()
16425 + * final disposal of vx_info */
16427 +static void __dealloc_vx_info(struct vx_info *vxi)
16429 +#ifdef CONFIG_VSERVER_WARN
16430 + struct vx_info_save vxis;
16433 + vxdprintk(VXD_CBIT(xid, 0),
16434 + "dealloc_vx_info(%p)", vxi);
16435 + vxh_dealloc_vx_info(vxi);
16437 +#ifdef CONFIG_VSERVER_WARN
16438 + enter_vx_info(vxi, &vxis);
16439 + vx_info_exit_limit(&vxi->limit);
16440 + vx_info_exit_sched(&vxi->sched);
16441 + vx_info_exit_cvirt(&vxi->cvirt);
16442 + vx_info_exit_cacct(&vxi->cacct);
16444 + for_each_possible_cpu(cpu) {
16445 + vx_info_exit_sched_pc(
16446 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16447 + vx_info_exit_cvirt_pc(
16448 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16450 + leave_vx_info(&vxis);
16454 + vxi->vx_state |= VXS_RELEASED;
16457 + free_percpu(vxi->ptr_pc);
16460 + atomic_dec(&vx_global_ctotal);
16463 +static void __shutdown_vx_info(struct vx_info *vxi)
16465 + struct nsproxy *nsproxy;
16466 + struct fs_struct *fs;
16471 + vxi->vx_state |= VXS_SHUTDOWN;
16472 + vs_state_change(vxi, VSC_SHUTDOWN);
16474 + for (index = 0; index < VX_SPACES; index++) {
16475 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
16477 + put_nsproxy(nsproxy);
16479 + fs = xchg(&vxi->vx_fs[index], NULL);
16480 + spin_lock(&fs->lock);
16481 + kill = !--fs->users;
16482 + spin_unlock(&fs->lock);
16484 + free_fs_struct(fs);
16488 +/* exported stuff */
16490 +void free_vx_info(struct vx_info *vxi)
16492 + unsigned long flags;
16495 + /* check for reference counts first */
16496 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16497 + BUG_ON(atomic_read(&vxi->vx_tasks));
16499 + /* context must not be hashed */
16500 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16502 + /* context shutdown is mandatory */
16503 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16505 + /* nsproxy and fs check */
16506 + for (index = 0; index < VX_SPACES; index++) {
16507 + BUG_ON(vxi->vx_nsproxy[index]);
16508 + BUG_ON(vxi->vx_fs[index]);
16511 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16512 + hlist_del(&vxi->vx_hlist);
16513 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16515 + __dealloc_vx_info(vxi);
16519 +/* hash table for vx_info hash */
16521 +#define VX_HASH_SIZE 13
16523 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16524 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16526 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
16529 +static inline unsigned int __hashval(xid_t xid)
16531 + return (xid % VX_HASH_SIZE);
16536 +/* __hash_vx_info()
16538 + * add the vxi to the global hash table
16539 + * requires the hash_lock to be held */
16541 +static inline void __hash_vx_info(struct vx_info *vxi)
16543 + struct hlist_head *head;
16545 + vxd_assert_lock(&vx_info_hash_lock);
16546 + vxdprintk(VXD_CBIT(xid, 4),
16547 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16548 + vxh_hash_vx_info(vxi);
16550 + /* context must not be hashed */
16551 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16553 + vxi->vx_state |= VXS_HASHED;
16554 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16555 + hlist_add_head(&vxi->vx_hlist, head);
16556 + atomic_inc(&vx_global_cactive);
16559 +/* __unhash_vx_info()
16561 + * remove the vxi from the global hash table
16562 + * requires the hash_lock to be held */
16564 +static inline void __unhash_vx_info(struct vx_info *vxi)
16566 + unsigned long flags;
16568 + vxd_assert_lock(&vx_info_hash_lock);
16569 + vxdprintk(VXD_CBIT(xid, 4),
16570 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16571 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16572 + vxh_unhash_vx_info(vxi);
16574 + /* context must be hashed */
16575 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16576 + /* but without tasks */
16577 + BUG_ON(atomic_read(&vxi->vx_tasks));
16579 + vxi->vx_state &= ~VXS_HASHED;
16580 + hlist_del_init(&vxi->vx_hlist);
16581 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16582 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16583 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16584 + atomic_dec(&vx_global_cactive);
16588 +/* __lookup_vx_info()
16590 + * requires the hash_lock to be held
16591 + * doesn't increment the vx_refcnt */
16593 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16595 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16596 + struct hlist_node *pos;
16597 + struct vx_info *vxi;
16599 + vxd_assert_lock(&vx_info_hash_lock);
16600 + hlist_for_each(pos, head) {
16601 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16603 + if (vxi->vx_id == xid)
16608 + vxdprintk(VXD_CBIT(xid, 0),
16609 + "__lookup_vx_info(#%u): %p[#%u]",
16610 + xid, vxi, vxi ? vxi->vx_id : 0);
16611 + vxh_lookup_vx_info(vxi, xid);
16616 +/* __create_vx_info()
16618 + * create the requested context
16619 + * get(), claim() and hash it */
16621 +static struct vx_info *__create_vx_info(int id)
16623 + struct vx_info *new, *vxi = NULL;
16625 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16627 + if (!(new = __alloc_vx_info(id)))
16628 + return ERR_PTR(-ENOMEM);
16630 + /* required to make dynamic xids unique */
16631 + spin_lock(&vx_info_hash_lock);
16633 + /* static context requested */
16634 + if ((vxi = __lookup_vx_info(id))) {
16635 + vxdprintk(VXD_CBIT(xid, 0),
16636 + "create_vx_info(%d) = %p (already there)", id, vxi);
16637 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16638 + vxi = ERR_PTR(-EBUSY);
16640 + vxi = ERR_PTR(-EEXIST);
16643 + /* new context */
16644 + vxdprintk(VXD_CBIT(xid, 0),
16645 + "create_vx_info(%d) = %p (new)", id, new);
16646 + claim_vx_info(new, NULL);
16647 + __hash_vx_info(get_vx_info(new));
16648 + vxi = new, new = NULL;
16651 + spin_unlock(&vx_info_hash_lock);
16652 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16654 + __dealloc_vx_info(new);
16659 +/* exported stuff */
16662 +void unhash_vx_info(struct vx_info *vxi)
16664 + __shutdown_vx_info(vxi);
16665 + spin_lock(&vx_info_hash_lock);
16666 + __unhash_vx_info(vxi);
16667 + spin_unlock(&vx_info_hash_lock);
16668 + __wakeup_vx_info(vxi);
16672 +/* lookup_vx_info()
16674 + * search for a vx_info and get() it
16675 + * negative id means current */
16677 +struct vx_info *lookup_vx_info(int id)
16679 + struct vx_info *vxi = NULL;
16682 + vxi = get_vx_info(current_vx_info());
16683 + } else if (id > 1) {
16684 + spin_lock(&vx_info_hash_lock);
16685 + vxi = get_vx_info(__lookup_vx_info(id));
16686 + spin_unlock(&vx_info_hash_lock);
16691 +/* xid_is_hashed()
16693 + * verify that xid is still hashed */
16695 +int xid_is_hashed(xid_t xid)
16699 + spin_lock(&vx_info_hash_lock);
16700 + hashed = (__lookup_vx_info(xid) != NULL);
16701 + spin_unlock(&vx_info_hash_lock);
16705 +#ifdef CONFIG_PROC_FS
16709 + * get a subset of hashed xids for proc
16710 + * assumes size is at least one */
16712 +int get_xid_list(int index, unsigned int *xids, int size)
16714 + int hindex, nr_xids = 0;
16716 + /* only show current and children */
16717 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16720 + xids[nr_xids] = vx_current_xid();
16724 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16725 + struct hlist_head *head = &vx_info_hash[hindex];
16726 + struct hlist_node *pos;
16728 + spin_lock(&vx_info_hash_lock);
16729 + hlist_for_each(pos, head) {
16730 + struct vx_info *vxi;
16735 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16736 + xids[nr_xids] = vxi->vx_id;
16737 + if (++nr_xids >= size) {
16738 + spin_unlock(&vx_info_hash_lock);
16742 + /* keep the lock time short */
16743 + spin_unlock(&vx_info_hash_lock);
16750 +#ifdef CONFIG_VSERVER_DEBUG
16752 +void dump_vx_info_inactive(int level)
16754 + struct hlist_node *entry, *next;
16756 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16757 + struct vx_info *vxi =
16758 + list_entry(entry, struct vx_info, vx_hlist);
16760 + dump_vx_info(vxi, level);
16767 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16769 + struct user_struct *new_user, *old_user;
16774 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16777 + new_user = alloc_uid(vxi->vx_id, p->uid);
16781 + old_user = p->user;
16782 + if (new_user != old_user) {
16783 + atomic_inc(&new_user->processes);
16784 + atomic_dec(&old_user->processes);
16785 + p->user = new_user;
16787 + free_uid(old_user);
16793 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16795 + // p->cap_effective &= vxi->vx_cap_bset;
16796 + p->cap_effective =
16797 + cap_intersect(p->cap_effective, vxi->cap_bset);
16798 + // p->cap_inheritable &= vxi->vx_cap_bset;
16799 + p->cap_inheritable =
16800 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16801 + // p->cap_permitted &= vxi->vx_cap_bset;
16802 + p->cap_permitted =
16803 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16808 +#include <linux/file.h>
16809 +#include <linux/fdtable.h>
16811 +static int vx_openfd_task(struct task_struct *tsk)
16813 + struct files_struct *files = tsk->files;
16814 + struct fdtable *fdt;
16815 + const unsigned long *bptr;
16816 + int count, total;
16818 + /* no rcu_read_lock() because of spin_lock() */
16819 + spin_lock(&files->file_lock);
16820 + fdt = files_fdtable(files);
16821 + bptr = fdt->open_fds->fds_bits;
16822 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16823 + for (total = 0; count > 0; count--) {
16825 + total += hweight_long(*bptr);
16828 + spin_unlock(&files->file_lock);
16833 +/* for *space compatibility */
16835 +asmlinkage long sys_unshare(unsigned long);
16838 + * migrate task to new context
16839 + * gets vxi, puts old_vxi on change
16840 + * optionally unshares namespaces (hack)
16843 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16845 + struct vx_info *old_vxi;
16851 + vxdprintk(VXD_CBIT(xid, 5),
16852 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16853 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16855 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16856 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16859 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16862 + old_vxi = task_get_vx_info(p);
16863 + if (old_vxi == vxi)
16866 +// if (!(ret = vx_migrate_user(p, vxi))) {
16871 + openfd = vx_openfd_task(p);
16874 + atomic_dec(&old_vxi->cvirt.nr_threads);
16875 + atomic_dec(&old_vxi->cvirt.nr_running);
16876 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16877 + /* FIXME: what about the struct files here? */
16878 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16879 + /* account for the executable */
16880 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16882 + atomic_inc(&vxi->cvirt.nr_threads);
16883 + atomic_inc(&vxi->cvirt.nr_running);
16884 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16885 + /* FIXME: what about the struct files here? */
16886 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16887 + /* account for the executable */
16888 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16891 + release_vx_info(old_vxi, p);
16892 + clr_vx_info(&p->vx_info);
16894 + claim_vx_info(vxi, p);
16895 + set_vx_info(&p->vx_info, vxi);
16896 + p->xid = vxi->vx_id;
16898 + vxdprintk(VXD_CBIT(xid, 5),
16899 + "moved task %p into vxi:%p[#%d]",
16900 + p, vxi, vxi->vx_id);
16902 + // vx_mask_cap_bset(vxi, p);
16905 + /* hack for *spaces to provide compatibility */
16907 + struct nsproxy *old_nsp, *new_nsp;
16909 + ret = unshare_nsproxy_namespaces(
16910 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16915 + old_nsp = xchg(&p->nsproxy, new_nsp);
16916 + vx_set_space(vxi,
16917 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16918 + put_nsproxy(old_nsp);
16922 + put_vx_info(old_vxi);
16926 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16928 + struct task_struct *old_reaper;
16933 + vxdprintk(VXD_CBIT(xid, 6),
16934 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16935 + vxi, vxi->vx_id, p, p->xid, p->pid);
16937 + old_reaper = vxi->vx_reaper;
16938 + if (old_reaper == p)
16941 + /* set new child reaper */
16942 + get_task_struct(p);
16943 + vxi->vx_reaper = p;
16944 + put_task_struct(old_reaper);
16948 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16953 + vxdprintk(VXD_CBIT(xid, 6),
16954 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16955 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16957 + vxi->vx_flags &= ~VXF_STATE_INIT;
16958 + // vxi->vx_initpid = p->tgid;
16959 + vxi->vx_initpid = p->pid;
16963 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16965 + vxdprintk(VXD_CBIT(xid, 6),
16966 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16967 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16969 + vxi->exit_code = code;
16970 + vxi->vx_initpid = 0;
16974 +void vx_set_persistent(struct vx_info *vxi)
16976 + vxdprintk(VXD_CBIT(xid, 6),
16977 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16979 + get_vx_info(vxi);
16980 + claim_vx_info(vxi, NULL);
16983 +void vx_clear_persistent(struct vx_info *vxi)
16985 + vxdprintk(VXD_CBIT(xid, 6),
16986 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16988 + release_vx_info(vxi, NULL);
16989 + put_vx_info(vxi);
16992 +void vx_update_persistent(struct vx_info *vxi)
16994 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16995 + vx_set_persistent(vxi);
16997 + vx_clear_persistent(vxi);
17001 +/* task must be current or locked */
17003 +void exit_vx_info(struct task_struct *p, int code)
17005 + struct vx_info *vxi = p->vx_info;
17008 + atomic_dec(&vxi->cvirt.nr_threads);
17011 + vxi->exit_code = code;
17012 + release_vx_info(vxi, p);
17016 +void exit_vx_info_early(struct task_struct *p, int code)
17018 + struct vx_info *vxi = p->vx_info;
17021 + if (vxi->vx_initpid == p->pid)
17022 + vx_exit_init(vxi, p, code);
17023 + if (vxi->vx_reaper == p)
17024 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
17029 +/* vserver syscall commands below here */
17031 +/* taks xid and vx_info functions */
17033 +#include <asm/uaccess.h>
17036 +int vc_task_xid(uint32_t id)
17041 + struct task_struct *tsk;
17043 + read_lock(&tasklist_lock);
17044 + tsk = find_task_by_real_pid(id);
17045 + xid = (tsk) ? tsk->xid : -ESRCH;
17046 + read_unlock(&tasklist_lock);
17048 + xid = vx_current_xid();
17053 +int vc_vx_info(struct vx_info *vxi, void __user *data)
17055 + struct vcmd_vx_info_v0 vc_data;
17057 + vc_data.xid = vxi->vx_id;
17058 + vc_data.initpid = vxi->vx_initpid;
17060 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17066 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
17068 + struct vcmd_ctx_stat_v0 vc_data;
17070 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
17071 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
17073 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17079 +/* context functions */
17081 +int vc_ctx_create(uint32_t xid, void __user *data)
17083 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
17084 + struct vx_info *new_vxi;
17087 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17090 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
17093 + new_vxi = __create_vx_info(xid);
17094 + if (IS_ERR(new_vxi))
17095 + return PTR_ERR(new_vxi);
17097 + /* initial flags */
17098 + new_vxi->vx_flags = vc_data.flagword;
17101 + if (vs_state_change(new_vxi, VSC_STARTUP))
17104 + ret = vx_migrate_task(current, new_vxi, (!data));
17108 + /* return context id on success */
17109 + ret = new_vxi->vx_id;
17111 + /* get a reference for persistent contexts */
17112 + if ((vc_data.flagword & VXF_PERSISTENT))
17113 + vx_set_persistent(new_vxi);
17115 + release_vx_info(new_vxi, NULL);
17116 + put_vx_info(new_vxi);
17121 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
17123 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
17126 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17129 + ret = vx_migrate_task(current, vxi, 0);
17132 + if (vc_data.flagword & VXM_SET_INIT)
17133 + ret = vx_set_init(vxi, current);
17136 + if (vc_data.flagword & VXM_SET_REAPER)
17137 + ret = vx_set_reaper(vxi, current);
17142 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
17144 + struct vcmd_ctx_flags_v0 vc_data;
17146 + vc_data.flagword = vxi->vx_flags;
17148 + /* special STATE flag handling */
17149 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
17151 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17156 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
17158 + struct vcmd_ctx_flags_v0 vc_data;
17159 + uint64_t mask, trigger;
17161 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17164 + /* special STATE flag handling */
17165 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
17166 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
17168 + if (vxi == current_vx_info()) {
17169 + /* if (trigger & VXF_STATE_SETUP)
17170 + vx_mask_cap_bset(vxi, current); */
17171 + if (trigger & VXF_STATE_INIT) {
17174 + ret = vx_set_init(vxi, current);
17177 + ret = vx_set_reaper(vxi, current);
17183 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17184 + vc_data.flagword, mask);
17185 + if (trigger & VXF_PERSISTENT)
17186 + vx_update_persistent(vxi);
17192 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17194 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17196 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17200 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17202 + kernel_cap_t c = __cap_empty_set;
17204 + c.cap[0] = v & 0xFFFFFFFF;
17205 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17207 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17212 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17215 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17217 + *ccaps = vxi->vx_ccaps;
17222 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17224 + struct vcmd_ctx_caps_v1 vc_data;
17227 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17230 + vc_data.cmask = ~0ULL;
17232 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17237 +static int do_set_caps(struct vx_info *vxi,
17238 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
17240 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
17243 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
17244 + bcaps, bmask, ccaps, cmask);
17246 + vxi->vx_bcaps = cap_t_from_caps(
17247 + vs_mask_flags(bcold, bcaps, bmask));
17248 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
17253 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
17255 + struct vcmd_ctx_caps_v1 vc_data;
17257 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17260 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
17263 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
17265 + struct vcmd_bcaps vc_data;
17268 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
17271 + vc_data.bmask = ~0ULL;
17273 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17278 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
17280 + struct vcmd_bcaps vc_data;
17282 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17285 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
17289 +int vc_get_umask(struct vx_info *vxi, void __user *data)
17291 + struct vcmd_umask vc_data;
17293 + vc_data.umask = vxi->vx_umask;
17294 + vc_data.mask = ~0ULL;
17296 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17301 +int vc_set_umask(struct vx_info *vxi, void __user *data)
17303 + struct vcmd_umask vc_data;
17305 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17308 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
17309 + vc_data.umask, vc_data.mask);
17314 +int vc_get_badness(struct vx_info *vxi, void __user *data)
17316 + struct vcmd_badness_v0 vc_data;
17318 + vc_data.bias = vxi->vx_badness_bias;
17320 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17325 +int vc_set_badness(struct vx_info *vxi, void __user *data)
17327 + struct vcmd_badness_v0 vc_data;
17329 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17332 + vxi->vx_badness_bias = vc_data.bias;
17336 +#include <linux/module.h>
17338 +EXPORT_SYMBOL_GPL(free_vx_info);
17340 diff -NurpP --minimal linux-2.6.36/kernel/vserver/cvirt.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/cvirt.c
17341 --- linux-2.6.36/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
17342 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/cvirt.c 2010-10-24 12:39:42.000000000 +0200
17345 + * linux/kernel/vserver/cvirt.c
17347 + * Virtual Server: Context Virtualization
17349 + * Copyright (C) 2004-2007 Herbert Pötzl
17351 + * V0.01 broken out from limit.c
17352 + * V0.02 added utsname stuff
17353 + * V0.03 changed vcmds to vxi arg
17357 +#include <linux/types.h>
17358 +#include <linux/utsname.h>
17359 +#include <linux/vs_cvirt.h>
17360 +#include <linux/vserver/switch.h>
17361 +#include <linux/vserver/cvirt_cmd.h>
17363 +#include <asm/uaccess.h>
17366 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17368 + struct vx_info *vxi = current_vx_info();
17370 + set_normalized_timespec(uptime,
17371 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17372 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17375 + set_normalized_timespec(idle,
17376 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17377 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17381 +uint64_t vx_idle_jiffies(void)
17383 + return init_task.utime + init_task.stime;
17388 +static inline uint32_t __update_loadavg(uint32_t load,
17389 + int wsize, int delta, int n)
17391 + unsigned long long calc, prev;
17393 + /* just set it to n */
17394 + if (unlikely(delta >= wsize))
17395 + return (n << FSHIFT);
17397 + calc = delta * n;
17399 + prev = (wsize - delta);
17402 + do_div(calc, wsize);
17407 +void vx_update_load(struct vx_info *vxi)
17409 + uint32_t now, last, delta;
17410 + unsigned int nr_running, nr_uninterruptible;
17411 + unsigned int total;
17412 + unsigned long flags;
17414 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17417 + last = vxi->cvirt.load_last;
17418 + delta = now - last;
17420 + if (delta < 5*HZ)
17423 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17424 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17425 + total = nr_running + nr_uninterruptible;
17427 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17428 + 60*HZ, delta, total);
17429 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17430 + 5*60*HZ, delta, total);
17431 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17432 + 15*60*HZ, delta, total);
17434 + vxi->cvirt.load_last = now;
17436 + atomic_inc(&vxi->cvirt.load_updates);
17437 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17442 + * Commands to do_syslog:
17444 + * 0 -- Close the log. Currently a NOP.
17445 + * 1 -- Open the log. Currently a NOP.
17446 + * 2 -- Read from the log.
17447 + * 3 -- Read all messages remaining in the ring buffer.
17448 + * 4 -- Read and clear all messages remaining in the ring buffer
17449 + * 5 -- Clear ring buffer.
17450 + * 6 -- Disable printk's to console
17451 + * 7 -- Enable printk's to console
17452 + * 8 -- Set level of messages printed to console
17453 + * 9 -- Return number of unread characters in the log buffer
17454 + * 10 -- Return size of the log buffer
17456 +int vx_do_syslog(int type, char __user *buf, int len)
17459 + int do_clear = 0;
17460 + struct vx_info *vxi = current_vx_info();
17461 + struct _vx_syslog *log;
17465 + log = &vxi->cvirt.syslog;
17468 + case 0: /* Close log */
17469 + case 1: /* Open log */
17471 + case 2: /* Read from log */
17472 + error = wait_event_interruptible(log->log_wait,
17473 + (log->log_start - log->log_end));
17476 + spin_lock_irq(&log->logbuf_lock);
17477 + spin_unlock_irq(&log->logbuf_lock);
17479 + case 4: /* Read/clear last kernel messages */
17481 + /* fall through */
17482 + case 3: /* Read last kernel messages */
17485 + case 5: /* Clear ring buffer */
17488 + case 6: /* Disable logging to console */
17489 + case 7: /* Enable logging to console */
17490 + case 8: /* Set level of messages printed to console */
17493 + case 9: /* Number of chars in the log buffer */
17495 + case 10: /* Size of the log buffer */
17505 +/* virtual host info names */
17507 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17509 + struct nsproxy *nsproxy;
17510 + struct uts_namespace *uts;
17512 + if (id == VHIN_CONTEXT)
17513 + return vxi->vx_name;
17515 + nsproxy = vxi->vx_nsproxy[0];
17519 + uts = nsproxy->uts_ns;
17524 + case VHIN_SYSNAME:
17525 + return uts->name.sysname;
17526 + case VHIN_NODENAME:
17527 + return uts->name.nodename;
17528 + case VHIN_RELEASE:
17529 + return uts->name.release;
17530 + case VHIN_VERSION:
17531 + return uts->name.version;
17532 + case VHIN_MACHINE:
17533 + return uts->name.machine;
17534 + case VHIN_DOMAINNAME:
17535 + return uts->name.domainname;
17542 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17544 + struct vcmd_vhi_name_v0 vc_data;
17547 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17550 + name = vx_vhi_name(vxi, vc_data.field);
17554 + memcpy(name, vc_data.name, 65);
17558 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17560 + struct vcmd_vhi_name_v0 vc_data;
17563 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17566 + name = vx_vhi_name(vxi, vc_data.field);
17570 + memcpy(vc_data.name, name, 65);
17571 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17577 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17579 + struct vcmd_virt_stat_v0 vc_data;
17580 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17581 + struct timespec uptime;
17583 + do_posix_clock_monotonic_gettime(&uptime);
17584 + set_normalized_timespec(&uptime,
17585 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17586 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17588 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17589 + vc_data.uptime = timespec_to_ns(&uptime);
17590 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17591 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17592 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17593 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17594 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17595 + vc_data.load[0] = cvirt->load[0];
17596 + vc_data.load[1] = cvirt->load[1];
17597 + vc_data.load[2] = cvirt->load[2];
17599 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17605 +#ifdef CONFIG_VSERVER_VTIME
17607 +/* virtualized time base */
17609 +void vx_adjust_timespec(struct timespec *ts)
17611 + struct vx_info *vxi;
17613 + if (!vx_flags(VXF_VIRT_TIME, 0))
17616 + vxi = current_vx_info();
17617 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17618 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17620 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17622 + ts->tv_nsec -= NSEC_PER_SEC;
17623 + } else if (ts->tv_nsec < 0) {
17625 + ts->tv_nsec += NSEC_PER_SEC;
17629 +int vx_settimeofday(struct timespec *ts)
17631 + struct timespec ats, delta;
17632 + struct vx_info *vxi;
17634 + if (!vx_flags(VXF_VIRT_TIME, 0))
17635 + return do_settimeofday(ts);
17637 + getnstimeofday(&ats);
17638 + delta = timespec_sub(*ts, ats);
17640 + vxi = current_vx_info();
17641 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17647 diff -NurpP --minimal linux-2.6.36/kernel/vserver/cvirt_init.h linux-2.6.36-vs2.3.0.36.38/kernel/vserver/cvirt_init.h
17648 --- linux-2.6.36/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17649 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/cvirt_init.h 2010-10-21 14:40:17.000000000 +0200
17653 +extern uint64_t vx_idle_jiffies(void);
17655 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17657 + uint64_t idle_jiffies = vx_idle_jiffies();
17658 + uint64_t nsuptime;
17660 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17661 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17662 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17663 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17664 + cvirt->bias_ts.tv_sec = 0;
17665 + cvirt->bias_ts.tv_nsec = 0;
17667 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17668 + atomic_set(&cvirt->nr_threads, 0);
17669 + atomic_set(&cvirt->nr_running, 0);
17670 + atomic_set(&cvirt->nr_uninterruptible, 0);
17671 + atomic_set(&cvirt->nr_onhold, 0);
17673 + spin_lock_init(&cvirt->load_lock);
17674 + cvirt->load_last = jiffies;
17675 + atomic_set(&cvirt->load_updates, 0);
17676 + cvirt->load[0] = 0;
17677 + cvirt->load[1] = 0;
17678 + cvirt->load[2] = 0;
17679 + atomic_set(&cvirt->total_forks, 0);
17681 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17682 + init_waitqueue_head(&cvirt->syslog.log_wait);
17683 + cvirt->syslog.log_start = 0;
17684 + cvirt->syslog.log_end = 0;
17685 + cvirt->syslog.con_start = 0;
17686 + cvirt->syslog.logged_chars = 0;
17690 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17692 + // cvirt_pc->cpustat = { 0 };
17695 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17699 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17700 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17702 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17703 + "!!! cvirt: %p[nr_running] = %d on exit.",
17705 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17706 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17708 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17709 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17715 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17720 diff -NurpP --minimal linux-2.6.36/kernel/vserver/cvirt_proc.h linux-2.6.36-vs2.3.0.36.38/kernel/vserver/cvirt_proc.h
17721 --- linux-2.6.36/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17722 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/cvirt_proc.h 2010-10-21 13:09:36.000000000 +0200
17724 +#ifndef _VX_CVIRT_PROC_H
17725 +#define _VX_CVIRT_PROC_H
17727 +#include <linux/nsproxy.h>
17728 +#include <linux/mnt_namespace.h>
17729 +#include <linux/ipc_namespace.h>
17730 +#include <linux/utsname.h>
17731 +#include <linux/ipc.h>
17735 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17737 + struct mnt_namespace *ns;
17738 + struct uts_namespace *uts;
17739 + struct ipc_namespace *ipc;
17740 + struct path path;
17741 + char *pstr, *root;
17747 + length += sprintf(buffer + length,
17748 + "NSProxy:\t%p [%p,%p,%p]\n",
17749 + nsproxy, nsproxy->mnt_ns,
17750 + nsproxy->uts_ns, nsproxy->ipc_ns);
17752 + ns = nsproxy->mnt_ns;
17756 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17760 + path.mnt = ns->root;
17761 + path.dentry = ns->root->mnt_root;
17762 + root = d_path(&path, pstr, PATH_MAX - 2);
17763 + length += sprintf(buffer + length,
17764 + "Namespace:\t%p [#%u]\n"
17765 + "RootPath:\t%s\n",
17766 + ns, atomic_read(&ns->count),
17771 + uts = nsproxy->uts_ns;
17775 + length += sprintf(buffer + length,
17776 + "SysName:\t%.*s\n"
17777 + "NodeName:\t%.*s\n"
17778 + "Release:\t%.*s\n"
17779 + "Version:\t%.*s\n"
17780 + "Machine:\t%.*s\n"
17781 + "DomainName:\t%.*s\n",
17782 + __NEW_UTS_LEN, uts->name.sysname,
17783 + __NEW_UTS_LEN, uts->name.nodename,
17784 + __NEW_UTS_LEN, uts->name.release,
17785 + __NEW_UTS_LEN, uts->name.version,
17786 + __NEW_UTS_LEN, uts->name.machine,
17787 + __NEW_UTS_LEN, uts->name.domainname);
17790 + ipc = nsproxy->ipc_ns;
17794 + length += sprintf(buffer + length,
17795 + "SEMS:\t\t%d %d %d %d %d\n"
17796 + "MSG:\t\t%d %d %d\n"
17797 + "SHM:\t\t%lu %lu %d %d\n",
17798 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17799 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17801 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17802 + (unsigned long)ipc->shm_ctlmax,
17803 + (unsigned long)ipc->shm_ctlall,
17804 + ipc->shm_ctlmni, ipc->shm_tot);
17811 +#include <linux/sched.h>
17813 +#define LOAD_INT(x) ((x) >> FSHIFT)
17814 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17817 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17822 + length += sprintf(buffer + length,
17823 + "BiasUptime:\t%lu.%02lu\n",
17824 + (unsigned long)cvirt->bias_uptime.tv_sec,
17825 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17827 + a = cvirt->load[0] + (FIXED_1 / 200);
17828 + b = cvirt->load[1] + (FIXED_1 / 200);
17829 + c = cvirt->load[2] + (FIXED_1 / 200);
17830 + length += sprintf(buffer + length,
17831 + "nr_threads:\t%d\n"
17832 + "nr_running:\t%d\n"
17833 + "nr_unintr:\t%d\n"
17834 + "nr_onhold:\t%d\n"
17835 + "load_updates:\t%d\n"
17836 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17837 + "total_forks:\t%d\n",
17838 + atomic_read(&cvirt->nr_threads),
17839 + atomic_read(&cvirt->nr_running),
17840 + atomic_read(&cvirt->nr_uninterruptible),
17841 + atomic_read(&cvirt->nr_onhold),
17842 + atomic_read(&cvirt->load_updates),
17843 + LOAD_INT(a), LOAD_FRAC(a),
17844 + LOAD_INT(b), LOAD_FRAC(b),
17845 + LOAD_INT(c), LOAD_FRAC(c),
17846 + atomic_read(&cvirt->total_forks));
17851 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17852 + char *buffer, int cpu)
17858 +#endif /* _VX_CVIRT_PROC_H */
17859 diff -NurpP --minimal linux-2.6.36/kernel/vserver/debug.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/debug.c
17860 --- linux-2.6.36/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17861 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/debug.c 2010-10-21 13:09:36.000000000 +0200
17864 + * kernel/vserver/debug.c
17866 + * Copyright (C) 2005-2007 Herbert Pötzl
17868 + * V0.01 vx_info dump support
17872 +#include <linux/module.h>
17874 +#include <linux/vserver/context.h>
17877 +void dump_vx_info(struct vx_info *vxi, int level)
17879 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17880 + atomic_read(&vxi->vx_usecnt),
17881 + atomic_read(&vxi->vx_tasks),
17884 + __dump_vx_limit(&vxi->limit);
17885 + __dump_vx_sched(&vxi->sched);
17886 + __dump_vx_cvirt(&vxi->cvirt);
17887 + __dump_vx_cacct(&vxi->cacct);
17893 +EXPORT_SYMBOL_GPL(dump_vx_info);
17895 diff -NurpP --minimal linux-2.6.36/kernel/vserver/device.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/device.c
17896 --- linux-2.6.36/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17897 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/device.c 2010-10-21 13:09:36.000000000 +0200
17900 + * linux/kernel/vserver/device.c
17902 + * Linux-VServer: Device Support
17904 + * Copyright (C) 2006 Herbert Pötzl
17905 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17907 + * V0.01 device mapping basics
17908 + * V0.02 added defaults
17912 +#include <linux/slab.h>
17913 +#include <linux/rcupdate.h>
17914 +#include <linux/fs.h>
17915 +#include <linux/namei.h>
17916 +#include <linux/hash.h>
17918 +#include <asm/errno.h>
17919 +#include <asm/uaccess.h>
17920 +#include <linux/vserver/base.h>
17921 +#include <linux/vserver/debug.h>
17922 +#include <linux/vserver/context.h>
17923 +#include <linux/vserver/device.h>
17924 +#include <linux/vserver/device_cmd.h>
17927 +#define DMAP_HASH_BITS 4
17930 +struct vs_mapping {
17932 + struct hlist_node hlist;
17933 + struct list_head list;
17935 +#define dm_hlist u.hlist
17936 +#define dm_list u.list
17939 + struct vx_dmap_target target;
17943 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17945 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
17947 +static struct vx_dmap_target dmap_defaults[2] = {
17948 + { .flags = DATTR_OPEN },
17949 + { .flags = DATTR_OPEN },
17953 +struct kmem_cache *dmap_cachep __read_mostly;
17955 +int __init dmap_cache_init(void)
17957 + dmap_cachep = kmem_cache_create("dmap_cache",
17958 + sizeof(struct vs_mapping), 0,
17959 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17963 +__initcall(dmap_cache_init);
17966 +static inline unsigned int __hashval(dev_t dev, int bits)
17968 + return hash_long((unsigned long)dev, bits);
17972 +/* __hash_mapping()
17973 + * add the mapping to the hash table
17975 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17977 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17978 + struct hlist_head *head, *hash = dmap_main_hash;
17979 + int device = vdm->device;
17981 + spin_lock(hash_lock);
17982 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17983 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17985 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17986 + hlist_add_head(&vdm->dm_hlist, head);
17987 + spin_unlock(hash_lock);
17991 +static inline int __mode_to_default(umode_t mode)
18004 +/* __set_default()
18007 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
18008 + struct vx_dmap_target *vdmt)
18010 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18011 + spin_lock(hash_lock);
18014 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
18016 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
18019 + spin_unlock(hash_lock);
18021 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
18022 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
18026 +/* __remove_default()
18027 + * remove a default
18029 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
18031 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18032 + spin_lock(hash_lock);
18035 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
18036 + else /* remove == reset */
18037 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
18039 + spin_unlock(hash_lock);
18044 +/* __find_mapping()
18045 + * find a mapping in the hash table
18047 + * caller must hold hash_lock
18049 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
18050 + struct vs_mapping **local, struct vs_mapping **global)
18052 + struct hlist_head *hash = dmap_main_hash;
18053 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
18054 + struct hlist_node *pos;
18055 + struct vs_mapping *vdm;
18061 + hlist_for_each(pos, head) {
18062 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
18064 + if ((vdm->device == device) &&
18065 + !((vdm->target.flags ^ mode) & S_IFMT)) {
18066 + if (vdm->xid == xid) {
18069 + } else if (global && vdm->xid == 0)
18074 + if (global && *global)
18081 +/* __lookup_mapping()
18082 + * find a mapping and store the result in target and flags
18084 +static inline int __lookup_mapping(struct vx_info *vxi,
18085 + dev_t device, dev_t *target, int *flags, umode_t mode)
18087 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18088 + struct vs_mapping *vdm, *global;
18089 + struct vx_dmap_target *vdmt;
18091 + xid_t xid = vxi->vx_id;
18094 + spin_lock(hash_lock);
18095 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
18097 + vdmt = &vdm->target;
18101 + index = __mode_to_default(mode);
18102 + if (vxi && vxi->dmap.targets[index].flags) {
18104 + vdmt = &vxi->dmap.targets[index];
18105 + } else if (global) {
18107 + vdmt = &global->target;
18111 + vdmt = &dmap_defaults[index];
18115 + if (target && (vdmt->flags & DATTR_REMAP))
18116 + *target = vdmt->target;
18118 + *target = device;
18120 + *flags = vdmt->flags;
18122 + spin_unlock(hash_lock);
18128 +/* __remove_mapping()
18129 + * remove a mapping from the hash table
18131 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
18134 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18135 + struct vs_mapping *vdm = NULL;
18138 + spin_lock(hash_lock);
18140 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
18142 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18143 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18146 + hlist_del(&vdm->dm_hlist);
18149 + spin_unlock(hash_lock);
18151 + kmem_cache_free(dmap_cachep, vdm);
18157 +int vs_map_device(struct vx_info *vxi,
18158 + dev_t device, dev_t *target, umode_t mode)
18160 + int ret, flags = DATTR_MASK;
18164 + *target = device;
18167 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18168 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18169 + device, target ? *target : 0, flags, mode, ret);
18171 + return (flags & DATTR_MASK);
18176 +static int do_set_mapping(struct vx_info *vxi,
18177 + dev_t device, dev_t target, int flags, umode_t mode)
18180 + struct vs_mapping *new;
18182 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18186 + INIT_HLIST_NODE(&new->dm_hlist);
18187 + new->device = device;
18188 + new->target.target = target;
18189 + new->target.flags = flags | mode;
18190 + new->xid = (vxi ? vxi->vx_id : 0);
18192 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18193 + __hash_mapping(vxi, new);
18195 + struct vx_dmap_target new = {
18196 + .target = target,
18197 + .flags = flags | mode,
18199 + __set_default(vxi, mode, &new);
18205 +static int do_unset_mapping(struct vx_info *vxi,
18206 + dev_t device, dev_t target, int flags, umode_t mode)
18208 + int ret = -EINVAL;
18211 + ret = __remove_mapping(vxi, device, mode);
18215 + ret = __remove_default(vxi, mode);
18225 +static inline int __user_device(const char __user *name, dev_t *dev,
18228 + struct nameidata nd;
18235 + ret = user_lpath(name, &nd.path);
18238 + if (nd.path.dentry->d_inode) {
18239 + *dev = nd.path.dentry->d_inode->i_rdev;
18240 + *mode = nd.path.dentry->d_inode->i_mode;
18242 + path_put(&nd.path);
18246 +static inline int __mapping_mode(dev_t device, dev_t target,
18247 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18250 + *mode = device_mode & S_IFMT;
18252 + *mode = target_mode & S_IFMT;
18256 + /* if both given, device and target mode have to match */
18257 + if (device && target &&
18258 + ((device_mode ^ target_mode) & S_IFMT))
18264 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18265 + const char __user *target_path, int flags, int set)
18267 + dev_t device = ~0, target = ~0;
18268 + umode_t device_mode = 0, target_mode = 0, mode;
18271 + ret = __user_device(device_path, &device, &device_mode);
18274 + ret = __user_device(target_path, &target, &target_mode);
18278 + ret = __mapping_mode(device, target,
18279 + device_mode, target_mode, &mode);
18284 + return do_set_mapping(vxi, device, target,
18287 + return do_unset_mapping(vxi, device, target,
18292 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
18294 + struct vcmd_set_mapping_v0 vc_data;
18296 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18299 + return do_mapping(vxi, vc_data.device, vc_data.target,
18300 + vc_data.flags, 1);
18303 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
18305 + struct vcmd_set_mapping_v0 vc_data;
18307 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18310 + return do_mapping(vxi, vc_data.device, vc_data.target,
18311 + vc_data.flags, 0);
18315 +#ifdef CONFIG_COMPAT
18317 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
18319 + struct vcmd_set_mapping_v0_x32 vc_data;
18321 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18324 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18325 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
18328 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18330 + struct vcmd_set_mapping_v0_x32 vc_data;
18332 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18335 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18336 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18339 +#endif /* CONFIG_COMPAT */
18342 diff -NurpP --minimal linux-2.6.36/kernel/vserver/dlimit.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/dlimit.c
18343 --- linux-2.6.36/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
18344 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/dlimit.c 2010-10-21 13:09:36.000000000 +0200
18347 + * linux/kernel/vserver/dlimit.c
18349 + * Virtual Server: Context Disk Limits
18351 + * Copyright (C) 2004-2009 Herbert Pötzl
18353 + * V0.01 initial version
18354 + * V0.02 compat32 splitup
18355 + * V0.03 extended interface
18359 +#include <linux/statfs.h>
18360 +#include <linux/sched.h>
18361 +#include <linux/namei.h>
18362 +#include <linux/vs_tag.h>
18363 +#include <linux/vs_dlimit.h>
18364 +#include <linux/vserver/dlimit_cmd.h>
18365 +#include <linux/slab.h>
18366 +// #include <linux/gfp.h>
18368 +#include <asm/uaccess.h>
18370 +/* __alloc_dl_info()
18372 + * allocate an initialized dl_info struct
18373 + * doesn't make it visible (hash) */
18375 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18377 + struct dl_info *new = NULL;
18379 + vxdprintk(VXD_CBIT(dlim, 5),
18380 + "alloc_dl_info(%p,%d)*", sb, tag);
18382 + /* would this benefit from a slab cache? */
18383 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18387 + memset(new, 0, sizeof(struct dl_info));
18388 + new->dl_tag = tag;
18390 + INIT_RCU_HEAD(&new->dl_rcu);
18391 + INIT_HLIST_NODE(&new->dl_hlist);
18392 + spin_lock_init(&new->dl_lock);
18393 + atomic_set(&new->dl_refcnt, 0);
18394 + atomic_set(&new->dl_usecnt, 0);
18396 + /* rest of init goes here */
18398 + vxdprintk(VXD_CBIT(dlim, 4),
18399 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18403 +/* __dealloc_dl_info()
18405 + * final disposal of dl_info */
18407 +static void __dealloc_dl_info(struct dl_info *dli)
18409 + vxdprintk(VXD_CBIT(dlim, 4),
18410 + "dealloc_dl_info(%p)", dli);
18412 + dli->dl_hlist.next = LIST_POISON1;
18413 + dli->dl_tag = -1;
18416 + BUG_ON(atomic_read(&dli->dl_usecnt));
18417 + BUG_ON(atomic_read(&dli->dl_refcnt));
18423 +/* hash table for dl_info hash */
18425 +#define DL_HASH_SIZE 13
18427 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18429 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
18432 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18434 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18439 +/* __hash_dl_info()
18441 + * add the dli to the global hash table
18442 + * requires the hash_lock to be held */
18444 +static inline void __hash_dl_info(struct dl_info *dli)
18446 + struct hlist_head *head;
18448 + vxdprintk(VXD_CBIT(dlim, 6),
18449 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18450 + get_dl_info(dli);
18451 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18452 + hlist_add_head_rcu(&dli->dl_hlist, head);
18455 +/* __unhash_dl_info()
18457 + * remove the dli from the global hash table
18458 + * requires the hash_lock to be held */
18460 +static inline void __unhash_dl_info(struct dl_info *dli)
18462 + vxdprintk(VXD_CBIT(dlim, 6),
18463 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18464 + hlist_del_rcu(&dli->dl_hlist);
18465 + put_dl_info(dli);
18469 +/* __lookup_dl_info()
18471 + * requires the rcu_read_lock()
18472 + * doesn't increment the dl_refcnt */
18474 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18476 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18477 + struct hlist_node *pos;
18478 + struct dl_info *dli;
18480 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18482 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18490 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18492 + struct dl_info *dli;
18495 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18496 + vxdprintk(VXD_CBIT(dlim, 7),
18497 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18498 + rcu_read_unlock();
18502 +void rcu_free_dl_info(struct rcu_head *head)
18504 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18505 + int usecnt, refcnt;
18507 + BUG_ON(!dli || !head);
18509 + usecnt = atomic_read(&dli->dl_usecnt);
18510 + BUG_ON(usecnt < 0);
18512 + refcnt = atomic_read(&dli->dl_refcnt);
18513 + BUG_ON(refcnt < 0);
18515 + vxdprintk(VXD_CBIT(dlim, 3),
18516 + "rcu_free_dl_info(%p)", dli);
18518 + __dealloc_dl_info(dli);
18520 + printk("!!! rcu didn't free\n");
18526 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18527 + uint32_t flags, int add)
18529 + struct path path;
18532 + ret = user_lpath(name, &path);
18534 + struct super_block *sb;
18535 + struct dl_info *dli;
18538 + if (!path.dentry->d_inode)
18539 + goto out_release;
18540 + if (!(sb = path.dentry->d_inode->i_sb))
18541 + goto out_release;
18544 + dli = __alloc_dl_info(sb, id);
18545 + spin_lock(&dl_info_hash_lock);
18548 + if (__lookup_dl_info(sb, id))
18550 + __hash_dl_info(dli);
18553 + spin_lock(&dl_info_hash_lock);
18554 + dli = __lookup_dl_info(sb, id);
18559 + __unhash_dl_info(dli);
18563 + spin_unlock(&dl_info_hash_lock);
18565 + __dealloc_dl_info(dli);
18572 +int vc_add_dlimit(uint32_t id, void __user *data)
18574 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18576 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18579 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18582 +int vc_rem_dlimit(uint32_t id, void __user *data)
18584 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18586 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18589 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18592 +#ifdef CONFIG_COMPAT
18594 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18596 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18598 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18601 + return do_addrem_dlimit(id,
18602 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18605 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18607 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18609 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18612 + return do_addrem_dlimit(id,
18613 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18616 +#endif /* CONFIG_COMPAT */
18620 +int do_set_dlimit(uint32_t id, const char __user *name,
18621 + uint32_t space_used, uint32_t space_total,
18622 + uint32_t inodes_used, uint32_t inodes_total,
18623 + uint32_t reserved, uint32_t flags)
18625 + struct path path;
18628 + ret = user_lpath(name, &path);
18630 + struct super_block *sb;
18631 + struct dl_info *dli;
18634 + if (!path.dentry->d_inode)
18635 + goto out_release;
18636 + if (!(sb = path.dentry->d_inode->i_sb))
18637 + goto out_release;
18639 + /* sanity checks */
18640 + if ((reserved != CDLIM_KEEP &&
18641 + reserved > 100) ||
18642 + (inodes_used != CDLIM_KEEP &&
18643 + inodes_used > inodes_total) ||
18644 + (space_used != CDLIM_KEEP &&
18645 + space_used > space_total))
18646 + goto out_release;
18649 + dli = locate_dl_info(sb, id);
18651 + goto out_release;
18653 + spin_lock(&dli->dl_lock);
18655 + if (inodes_used != CDLIM_KEEP)
18656 + dli->dl_inodes_used = inodes_used;
18657 + if (inodes_total != CDLIM_KEEP)
18658 + dli->dl_inodes_total = inodes_total;
18659 + if (space_used != CDLIM_KEEP)
18660 + dli->dl_space_used = dlimit_space_32to64(
18661 + space_used, flags, DLIMS_USED);
18663 + if (space_total == CDLIM_INFINITY)
18664 + dli->dl_space_total = DLIM_INFINITY;
18665 + else if (space_total != CDLIM_KEEP)
18666 + dli->dl_space_total = dlimit_space_32to64(
18667 + space_total, flags, DLIMS_TOTAL);
18669 + if (reserved != CDLIM_KEEP)
18670 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18672 + spin_unlock(&dli->dl_lock);
18674 + put_dl_info(dli);
18683 +int vc_set_dlimit(uint32_t id, void __user *data)
18685 + struct vcmd_ctx_dlimit_v0 vc_data;
18687 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18690 + return do_set_dlimit(id, vc_data.name,
18691 + vc_data.space_used, vc_data.space_total,
18692 + vc_data.inodes_used, vc_data.inodes_total,
18693 + vc_data.reserved, vc_data.flags);
18696 +#ifdef CONFIG_COMPAT
18698 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18700 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18702 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18705 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18706 + vc_data.space_used, vc_data.space_total,
18707 + vc_data.inodes_used, vc_data.inodes_total,
18708 + vc_data.reserved, vc_data.flags);
18711 +#endif /* CONFIG_COMPAT */
18715 +int do_get_dlimit(uint32_t id, const char __user *name,
18716 + uint32_t *space_used, uint32_t *space_total,
18717 + uint32_t *inodes_used, uint32_t *inodes_total,
18718 + uint32_t *reserved, uint32_t *flags)
18720 + struct path path;
18723 + ret = user_lpath(name, &path);
18725 + struct super_block *sb;
18726 + struct dl_info *dli;
18729 + if (!path.dentry->d_inode)
18730 + goto out_release;
18731 + if (!(sb = path.dentry->d_inode->i_sb))
18732 + goto out_release;
18735 + dli = locate_dl_info(sb, id);
18737 + goto out_release;
18739 + spin_lock(&dli->dl_lock);
18740 + *inodes_used = dli->dl_inodes_used;
18741 + *inodes_total = dli->dl_inodes_total;
18743 + *space_used = dlimit_space_64to32(
18744 + dli->dl_space_used, flags, DLIMS_USED);
18746 + if (dli->dl_space_total == DLIM_INFINITY)
18747 + *space_total = CDLIM_INFINITY;
18749 + *space_total = dlimit_space_64to32(
18750 + dli->dl_space_total, flags, DLIMS_TOTAL);
18752 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18753 + spin_unlock(&dli->dl_lock);
18755 + put_dl_info(dli);
18766 +int vc_get_dlimit(uint32_t id, void __user *data)
18768 + struct vcmd_ctx_dlimit_v0 vc_data;
18771 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18774 + ret = do_get_dlimit(id, vc_data.name,
18775 + &vc_data.space_used, &vc_data.space_total,
18776 + &vc_data.inodes_used, &vc_data.inodes_total,
18777 + &vc_data.reserved, &vc_data.flags);
18781 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18786 +#ifdef CONFIG_COMPAT
18788 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18790 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18793 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18796 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18797 + &vc_data.space_used, &vc_data.space_total,
18798 + &vc_data.inodes_used, &vc_data.inodes_total,
18799 + &vc_data.reserved, &vc_data.flags);
18803 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18808 +#endif /* CONFIG_COMPAT */
18811 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18813 + struct dl_info *dli;
18814 + __u64 blimit, bfree, bavail;
18817 + dli = locate_dl_info(sb, dx_current_tag());
18821 + spin_lock(&dli->dl_lock);
18822 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18825 + /* reduce max inodes available to limit */
18826 + if (buf->f_files > dli->dl_inodes_total)
18827 + buf->f_files = dli->dl_inodes_total;
18829 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18830 + /* reduce free inodes to min */
18831 + if (ifree < buf->f_ffree)
18832 + buf->f_ffree = ifree;
18835 + if (dli->dl_space_total == DLIM_INFINITY)
18838 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18840 + if (dli->dl_space_total < dli->dl_space_used)
18843 + bfree = (dli->dl_space_total - dli->dl_space_used)
18844 + >> sb->s_blocksize_bits;
18846 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18847 + if (bavail < dli->dl_space_used)
18850 + bavail = (bavail - dli->dl_space_used)
18851 + >> sb->s_blocksize_bits;
18853 + /* reduce max space available to limit */
18854 + if (buf->f_blocks > blimit)
18855 + buf->f_blocks = blimit;
18857 + /* reduce free space to min */
18858 + if (bfree < buf->f_bfree)
18859 + buf->f_bfree = bfree;
18861 + /* reduce avail space to min */
18862 + if (bavail < buf->f_bavail)
18863 + buf->f_bavail = bavail;
18866 + spin_unlock(&dli->dl_lock);
18867 + put_dl_info(dli);
18872 +#include <linux/module.h>
18874 +EXPORT_SYMBOL_GPL(locate_dl_info);
18875 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18877 diff -NurpP --minimal linux-2.6.36/kernel/vserver/helper.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/helper.c
18878 --- linux-2.6.36/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18879 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/helper.c 2010-10-21 13:09:36.000000000 +0200
18882 + * linux/kernel/vserver/helper.c
18884 + * Virtual Context Support
18886 + * Copyright (C) 2004-2007 Herbert Pötzl
18888 + * V0.01 basic helper
18892 +#include <linux/kmod.h>
18893 +#include <linux/reboot.h>
18894 +#include <linux/vs_context.h>
18895 +#include <linux/vs_network.h>
18896 +#include <linux/vserver/signal.h>
18899 +char vshelper_path[255] = "/sbin/vshelper";
18902 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18906 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
18907 + printk( KERN_WARNING
18908 + "%s: (%s %s) returned %s with %d\n",
18909 + name, argv[1], argv[2],
18910 + sync ? "sync" : "async", ret);
18912 + vxdprintk(VXD_CBIT(switch, 4),
18913 + "%s: (%s %s) returned %s with %d",
18914 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18919 + * vshelper path is set via /proc/sys
18920 + * invoked by vserver sys_reboot(), with
18921 + * the following arguments
18923 + * argv [0] = vshelper_path;
18924 + * argv [1] = action: "restart", "halt", "poweroff", ...
18925 + * argv [2] = context identifier
18927 + * envp [*] = type-specific parameters
18930 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18932 + char id_buf[8], cmd_buf[16];
18933 + char uid_buf[16], pid_buf[16];
18936 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18937 + char *envp[] = {"HOME=/", "TERM=linux",
18938 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18939 + uid_buf, pid_buf, cmd_buf, 0};
18941 + if (vx_info_state(vxi, VXS_HELPER))
18943 + vxi->vx_state |= VXS_HELPER;
18945 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18947 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18948 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
18949 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
18952 + case LINUX_REBOOT_CMD_RESTART:
18953 + argv[1] = "restart";
18956 + case LINUX_REBOOT_CMD_HALT:
18957 + argv[1] = "halt";
18960 + case LINUX_REBOOT_CMD_POWER_OFF:
18961 + argv[1] = "poweroff";
18964 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18965 + argv[1] = "swsusp";
18968 + case LINUX_REBOOT_CMD_OOM:
18973 + vxi->vx_state &= ~VXS_HELPER;
18977 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18978 + vxi->vx_state &= ~VXS_HELPER;
18979 + __wakeup_vx_info(vxi);
18980 + return (ret) ? -EPERM : 0;
18984 +long vs_reboot(unsigned int cmd, void __user *arg)
18986 + struct vx_info *vxi = current_vx_info();
18989 + vxdprintk(VXD_CBIT(misc, 5),
18990 + "vs_reboot(%p[#%d],%u)",
18991 + vxi, vxi ? vxi->vx_id : 0, cmd);
18993 + ret = vs_reboot_helper(vxi, cmd, arg);
18997 + vxi->reboot_cmd = cmd;
18998 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19000 + case LINUX_REBOOT_CMD_RESTART:
19001 + case LINUX_REBOOT_CMD_HALT:
19002 + case LINUX_REBOOT_CMD_POWER_OFF:
19003 + vx_info_kill(vxi, 0, SIGKILL);
19004 + vx_info_kill(vxi, 1, SIGKILL);
19012 +long vs_oom_action(unsigned int cmd)
19014 + struct vx_info *vxi = current_vx_info();
19017 + vxdprintk(VXD_CBIT(misc, 5),
19018 + "vs_oom_action(%p[#%d],%u)",
19019 + vxi, vxi ? vxi->vx_id : 0, cmd);
19021 + ret = vs_reboot_helper(vxi, cmd, NULL);
19025 + vxi->reboot_cmd = cmd;
19026 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19027 + vx_info_kill(vxi, 0, SIGKILL);
19028 + vx_info_kill(vxi, 1, SIGKILL);
19034 + * argv [0] = vshelper_path;
19035 + * argv [1] = action: "startup", "shutdown"
19036 + * argv [2] = context identifier
19038 + * envp [*] = type-specific parameters
19041 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
19043 + char id_buf[8], cmd_buf[16];
19044 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19045 + char *envp[] = {"HOME=/", "TERM=linux",
19046 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19048 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
19051 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19052 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19055 + case VSC_STARTUP:
19056 + argv[1] = "startup";
19058 + case VSC_SHUTDOWN:
19059 + argv[1] = "shutdown";
19065 + return do_vshelper(vshelper_path, argv, envp, 1);
19070 + * argv [0] = vshelper_path;
19071 + * argv [1] = action: "netup", "netdown"
19072 + * argv [2] = context identifier
19074 + * envp [*] = type-specific parameters
19077 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
19079 + char id_buf[8], cmd_buf[16];
19080 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19081 + char *envp[] = {"HOME=/", "TERM=linux",
19082 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19084 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
19087 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
19088 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19092 + argv[1] = "netup";
19094 + case VSC_NETDOWN:
19095 + argv[1] = "netdown";
19101 + return do_vshelper(vshelper_path, argv, envp, 1);
19104 diff -NurpP --minimal linux-2.6.36/kernel/vserver/history.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/history.c
19105 --- linux-2.6.36/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
19106 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/history.c 2010-10-21 13:09:36.000000000 +0200
19109 + * kernel/vserver/history.c
19111 + * Virtual Context History Backtrace
19113 + * Copyright (C) 2004-2007 Herbert Pötzl
19115 + * V0.01 basic structure
19116 + * V0.02 hash/unhash and trace
19117 + * V0.03 preemption fixes
19121 +#include <linux/module.h>
19122 +#include <asm/uaccess.h>
19124 +#include <linux/vserver/context.h>
19125 +#include <linux/vserver/debug.h>
19126 +#include <linux/vserver/debug_cmd.h>
19127 +#include <linux/vserver/history.h>
19130 +#ifdef CONFIG_VSERVER_HISTORY
19131 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
19133 +#define VXH_SIZE 64
19136 +struct _vx_history {
19137 + unsigned int counter;
19139 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19143 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19145 +unsigned volatile int vxh_active = 1;
19147 +static atomic_t sequence = ATOMIC_INIT(0);
19152 + * requires disabled preemption */
19154 +struct _vx_hist_entry *vxh_advance(void *loc)
19156 + unsigned int cpu = smp_processor_id();
19157 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19158 + struct _vx_hist_entry *entry;
19159 + unsigned int index;
19161 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19162 + entry = &hist->entry[index];
19164 + entry->seq = atomic_inc_return(&sequence);
19165 + entry->loc = loc;
19169 +EXPORT_SYMBOL_GPL(vxh_advance);
19172 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19174 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19177 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19179 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19180 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19181 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19182 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19184 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19186 + switch (e->type) {
19187 + case VXH_THROW_OOPS:
19188 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19191 + case VXH_GET_VX_INFO:
19192 + case VXH_PUT_VX_INFO:
19193 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19195 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19196 + VXH_VXI_ARGS(e));
19199 + case VXH_INIT_VX_INFO:
19200 + case VXH_SET_VX_INFO:
19201 + case VXH_CLR_VX_INFO:
19202 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19204 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19205 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19206 + VXH_VXI_ARGS(e), e->sc.data);
19209 + case VXH_CLAIM_VX_INFO:
19210 + case VXH_RELEASE_VX_INFO:
19211 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19213 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19214 + VXH_VXI_ARGS(e), e->sc.data);
19217 + case VXH_ALLOC_VX_INFO:
19218 + case VXH_DEALLOC_VX_INFO:
19219 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19221 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19222 + VXH_VXI_ARGS(e));
19225 + case VXH_HASH_VX_INFO:
19226 + case VXH_UNHASH_VX_INFO:
19227 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19229 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19230 + VXH_VXI_ARGS(e));
19233 + case VXH_LOC_VX_INFO:
19234 + case VXH_LOOKUP_VX_INFO:
19235 + case VXH_CREATE_VX_INFO:
19236 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19238 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19239 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19240 + e->ll.arg, VXH_VXI_ARGS(e));
19245 +static void __vxh_dump_history(void)
19247 + unsigned int i, cpu;
19249 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19250 + atomic_read(&sequence), NR_CPUS);
19252 + for (i = 0; i < VXH_SIZE; i++) {
19253 + for_each_online_cpu(cpu) {
19254 + struct _vx_history *hist =
19255 + &per_cpu(vx_history_buffer, cpu);
19256 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19257 + struct _vx_hist_entry *entry = &hist->entry[index];
19259 + vxh_dump_entry(entry, cpu);
19264 +void vxh_dump_history(void)
19268 + local_irq_enable();
19270 + local_irq_disable();
19272 + __vxh_dump_history();
19276 +/* vserver syscall commands below here */
19279 +int vc_dump_history(uint32_t id)
19282 + __vxh_dump_history();
19289 +int do_read_history(struct __user _vx_hist_entry *data,
19290 + int cpu, uint32_t *index, uint32_t *count)
19292 + int pos, ret = 0;
19293 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19294 + int end = hist->counter;
19295 + int start = end - VXH_SIZE + 2;
19296 + int idx = *index;
19298 + /* special case: get current pos */
19304 + /* have we lost some data? */
19308 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
19309 + struct _vx_hist_entry *entry =
19310 + &hist->entry[idx % VXH_SIZE];
19312 + /* send entry to userspace */
19313 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
19317 + /* save new index and count */
19320 + return ret ? ret : (*index < end);
19323 +int vc_read_history(uint32_t id, void __user *data)
19325 + struct vcmd_read_history_v0 vc_data;
19328 + if (id >= NR_CPUS)
19331 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19334 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19335 + id, &vc_data.index, &vc_data.count);
19337 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19342 +#ifdef CONFIG_COMPAT
19344 +int vc_read_history_x32(uint32_t id, void __user *data)
19346 + struct vcmd_read_history_v0_x32 vc_data;
19349 + if (id >= NR_CPUS)
19352 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19355 + ret = do_read_history((struct __user _vx_hist_entry *)
19356 + compat_ptr(vc_data.data_ptr),
19357 + id, &vc_data.index, &vc_data.count);
19359 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19364 +#endif /* CONFIG_COMPAT */
19366 diff -NurpP --minimal linux-2.6.36/kernel/vserver/inet.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/inet.c
19367 --- linux-2.6.36/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19368 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/inet.c 2010-10-21 13:09:36.000000000 +0200
19371 +#include <linux/in.h>
19372 +#include <linux/inetdevice.h>
19373 +#include <linux/vs_inet.h>
19374 +#include <linux/vs_inet6.h>
19375 +#include <linux/vserver/debug.h>
19376 +#include <net/route.h>
19377 +#include <net/addrconf.h>
19380 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19384 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19387 + struct nx_addr_v4 *ptr;
19389 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19390 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19397 + vxdprintk(VXD_CBIT(net, 2),
19398 + "nx_v4_addr_conflict(%p,%p): %d",
19399 + nxi1, nxi2, ret);
19405 +#ifdef CONFIG_IPV6
19407 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19411 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19414 + struct nx_addr_v6 *ptr;
19416 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19417 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19424 + vxdprintk(VXD_CBIT(net, 2),
19425 + "nx_v6_addr_conflict(%p,%p): %d",
19426 + nxi1, nxi2, ret);
19433 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19435 + struct in_device *in_dev;
19436 + struct in_ifaddr **ifap;
19437 + struct in_ifaddr *ifa;
19442 + in_dev = in_dev_get(dev);
19446 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19447 + ifap = &ifa->ifa_next) {
19448 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19453 + in_dev_put(in_dev);
19459 +#ifdef CONFIG_IPV6
19461 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19463 + struct inet6_dev *in_dev;
19464 + struct inet6_ifaddr *ifa;
19469 + in_dev = in6_dev_get(dev);
19473 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19474 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19475 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19480 + in6_dev_put(in_dev);
19487 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19493 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19495 +#ifdef CONFIG_IPV6
19497 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19502 + vxdprintk(VXD_CBIT(net, 3),
19503 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19504 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19508 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
19509 + struct rtable **rp, struct flowi *fl)
19514 + /* FIXME: handle lback only case */
19515 + if (!NX_IPV4(nxi))
19518 + vxdprintk(VXD_CBIT(net, 4),
19519 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19520 + nxi, nxi ? nxi->nx_id : 0,
19521 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
19523 + /* single IP is unconditional */
19524 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19525 + (fl->fl4_src == INADDR_ANY))
19526 + fl->fl4_src = nxi->v4.ip[0].s_addr;
19528 + if (fl->fl4_src == INADDR_ANY) {
19529 + struct nx_addr_v4 *ptr;
19530 + __be32 found = 0;
19533 + err = __ip_route_output_key(net, rp, fl);
19535 + found = (*rp)->rt_src;
19537 + vxdprintk(VXD_CBIT(net, 4),
19538 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19539 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
19540 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19544 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19545 + __be32 primary = ptr->ip[0].s_addr;
19546 + __be32 mask = ptr->mask.s_addr;
19547 + __be32 neta = primary & mask;
19549 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19550 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19551 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19552 + NIPQUAD(mask), NIPQUAD(neta));
19553 + if ((found & mask) != neta)
19556 + fl->fl4_src = primary;
19557 + err = __ip_route_output_key(net, rp, fl);
19558 + vxdprintk(VXD_CBIT(net, 4),
19559 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19560 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
19562 + found = (*rp)->rt_src;
19564 + if (found == primary)
19568 + /* still no source ip? */
19569 + found = ipv4_is_loopback(fl->fl4_dst)
19570 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19572 + /* assign src ip to flow */
19573 + fl->fl4_src = found;
19576 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
19580 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19581 + if (ipv4_is_loopback(fl->fl4_dst))
19582 + fl->fl4_dst = nxi->v4_lback.s_addr;
19583 + if (ipv4_is_loopback(fl->fl4_src))
19584 + fl->fl4_src = nxi->v4_lback.s_addr;
19585 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
19586 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19592 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19594 diff -NurpP --minimal linux-2.6.36/kernel/vserver/init.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/init.c
19595 --- linux-2.6.36/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19596 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/init.c 2010-10-21 13:09:36.000000000 +0200
19599 + * linux/kernel/init.c
19601 + * Virtual Server Init
19603 + * Copyright (C) 2004-2007 Herbert Pötzl
19605 + * V0.01 basic structure
19609 +#include <linux/init.h>
19611 +int vserver_register_sysctl(void);
19612 +void vserver_unregister_sysctl(void);
19615 +static int __init init_vserver(void)
19619 +#ifdef CONFIG_VSERVER_DEBUG
19620 + vserver_register_sysctl();
19626 +static void __exit exit_vserver(void)
19629 +#ifdef CONFIG_VSERVER_DEBUG
19630 + vserver_unregister_sysctl();
19635 +/* FIXME: GFP_ZONETYPES gone
19636 +long vx_slab[GFP_ZONETYPES]; */
19640 +module_init(init_vserver);
19641 +module_exit(exit_vserver);
19643 diff -NurpP --minimal linux-2.6.36/kernel/vserver/inode.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/inode.c
19644 --- linux-2.6.36/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19645 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/inode.c 2010-10-21 17:40:44.000000000 +0200
19648 + * linux/kernel/vserver/inode.c
19650 + * Virtual Server: File System Support
19652 + * Copyright (C) 2004-2007 Herbert Pötzl
19654 + * V0.01 separated from vcontext V0.05
19655 + * V0.02 moved to tag (instead of xid)
19659 +#include <linux/tty.h>
19660 +#include <linux/proc_fs.h>
19661 +#include <linux/devpts_fs.h>
19662 +#include <linux/fs.h>
19663 +#include <linux/file.h>
19664 +#include <linux/mount.h>
19665 +#include <linux/parser.h>
19666 +#include <linux/namei.h>
19667 +#include <linux/vserver/inode.h>
19668 +#include <linux/vserver/inode_cmd.h>
19669 +#include <linux/vs_base.h>
19670 +#include <linux/vs_tag.h>
19672 +#include <asm/uaccess.h>
19675 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19677 + struct proc_dir_entry *entry;
19679 + if (!in || !in->i_sb)
19682 + *flags = IATTR_TAG
19683 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19684 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19685 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19686 + | (IS_COW(in) ? IATTR_COW : 0);
19687 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19689 + if (S_ISDIR(in->i_mode))
19690 + *mask |= IATTR_BARRIER;
19692 + if (IS_TAGGED(in)) {
19693 + *tag = in->i_tag;
19694 + *mask |= IATTR_TAG;
19697 + switch (in->i_sb->s_magic) {
19698 + case PROC_SUPER_MAGIC:
19699 + entry = PROC_I(in)->pde;
19701 + /* check for specific inodes? */
19703 + *mask |= IATTR_FLAGS;
19705 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19707 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19710 + case DEVPTS_SUPER_MAGIC:
19711 + *tag = in->i_tag;
19712 + *mask |= IATTR_TAG;
19721 +int vc_get_iattr(void __user *data)
19723 + struct path path;
19724 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19727 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19730 + ret = user_lpath(vc_data.name, &path);
19732 + ret = __vc_get_iattr(path.dentry->d_inode,
19733 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19739 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19744 +#ifdef CONFIG_COMPAT
19746 +int vc_get_iattr_x32(void __user *data)
19748 + struct path path;
19749 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19752 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19755 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19757 + ret = __vc_get_iattr(path.dentry->d_inode,
19758 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19764 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19769 +#endif /* CONFIG_COMPAT */
19772 +int vc_fget_iattr(uint32_t fd, void __user *data)
19774 + struct file *filp;
19775 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19778 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19782 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19785 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19786 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19790 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19796 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19798 + struct inode *in = de->d_inode;
19799 + int error = 0, is_proc = 0, has_tag = 0;
19800 + struct iattr attr = { 0 };
19802 + if (!in || !in->i_sb)
19805 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19806 + if ((*mask & IATTR_FLAGS) && !is_proc)
19809 + has_tag = IS_TAGGED(in) ||
19810 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19811 + if ((*mask & IATTR_TAG) && !has_tag)
19814 + mutex_lock(&in->i_mutex);
19815 + if (*mask & IATTR_TAG) {
19816 + attr.ia_tag = *tag;
19817 + attr.ia_valid |= ATTR_TAG;
19820 + if (*mask & IATTR_FLAGS) {
19821 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19822 + unsigned int iflags = PROC_I(in)->vx_flags;
19824 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19825 + | (*flags & IATTR_FLAGS);
19826 + PROC_I(in)->vx_flags = iflags;
19828 + entry->vx_flags = iflags;
19831 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19832 + IATTR_BARRIER | IATTR_COW)) {
19833 + int iflags = in->i_flags;
19834 + int vflags = in->i_vflags;
19836 + if (*mask & IATTR_IMMUTABLE) {
19837 + if (*flags & IATTR_IMMUTABLE)
19838 + iflags |= S_IMMUTABLE;
19840 + iflags &= ~S_IMMUTABLE;
19842 + if (*mask & IATTR_IXUNLINK) {
19843 + if (*flags & IATTR_IXUNLINK)
19844 + iflags |= S_IXUNLINK;
19846 + iflags &= ~S_IXUNLINK;
19848 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19849 + if (*flags & IATTR_BARRIER)
19850 + vflags |= V_BARRIER;
19852 + vflags &= ~V_BARRIER;
19854 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19855 + if (*flags & IATTR_COW)
19858 + vflags &= ~V_COW;
19860 + if (in->i_op && in->i_op->sync_flags) {
19861 + error = in->i_op->sync_flags(in, iflags, vflags);
19867 + if (attr.ia_valid) {
19868 + if (in->i_op && in->i_op->setattr)
19869 + error = in->i_op->setattr(de, &attr);
19871 + error = inode_change_ok(in, &attr);
19873 + setattr_copy(in, &attr);
19874 + mark_inode_dirty(in);
19880 + mutex_unlock(&in->i_mutex);
19884 +int vc_set_iattr(void __user *data)
19886 + struct path path;
19887 + struct vcmd_ctx_iattr_v1 vc_data;
19890 + if (!capable(CAP_LINUX_IMMUTABLE))
19892 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19895 + ret = user_lpath(vc_data.name, &path);
19897 + ret = __vc_set_iattr(path.dentry,
19898 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19902 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19907 +#ifdef CONFIG_COMPAT
19909 +int vc_set_iattr_x32(void __user *data)
19911 + struct path path;
19912 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19915 + if (!capable(CAP_LINUX_IMMUTABLE))
19917 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19920 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19922 + ret = __vc_set_iattr(path.dentry,
19923 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19927 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19932 +#endif /* CONFIG_COMPAT */
19934 +int vc_fset_iattr(uint32_t fd, void __user *data)
19936 + struct file *filp;
19937 + struct vcmd_ctx_fiattr_v0 vc_data;
19940 + if (!capable(CAP_LINUX_IMMUTABLE))
19942 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19946 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19949 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19950 + &vc_data.flags, &vc_data.mask);
19954 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19960 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19962 +static match_table_t tokens = {
19963 + {Opt_notagcheck, "notagcheck"},
19964 +#ifdef CONFIG_PROPAGATE
19965 + {Opt_notag, "notag"},
19966 + {Opt_tag, "tag"},
19967 + {Opt_tagid, "tagid=%u"},
19973 +static void __dx_parse_remove(char *string, char *opt)
19975 + char *p = strstr(string, opt);
19979 + while (*q != '\0' && *q != ',')
19988 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19989 + unsigned long *flags)
19992 + substring_t args[MAX_OPT_ARGS];
19993 + int token, option = 0;
19994 + char *s, *p, *opts;
19998 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
20003 + while ((p = strsep(&opts, ",")) != NULL) {
20004 + token = match_token(p, tokens, args);
20006 + vxdprintk(VXD_CBIT(tag, 7),
20007 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
20008 + p, token, option);
20011 +#ifdef CONFIG_PROPAGATE
20016 + __dx_parse_remove(s, "tag");
20017 + *mnt_flags |= MNT_TAGID;
20018 + set |= MNT_TAGID;
20022 + __dx_parse_remove(s, "notag");
20023 + *mnt_flags |= MNT_NOTAG;
20024 + set |= MNT_NOTAG;
20027 + if (tag && !match_int(args, &option))
20030 + __dx_parse_remove(s, "tagid");
20031 + *mnt_flags |= MNT_TAGID;
20032 + set |= MNT_TAGID;
20035 + case Opt_notagcheck:
20037 + __dx_parse_remove(s, "notagcheck");
20038 + *flags |= MS_NOTAGCHECK;
20039 + set |= MS_NOTAGCHECK;
20044 + strcpy(string, s);
20049 +#ifdef CONFIG_PROPAGATE
20051 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
20053 + tag_t new_tag = 0;
20054 + struct vfsmount *mnt;
20059 + mnt = nd->path.mnt;
20063 + propagate = (mnt->mnt_flags & MNT_TAGID);
20065 + new_tag = mnt->mnt_tag;
20067 + vxdprintk(VXD_CBIT(tag, 7),
20068 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
20069 + inode, inode->i_ino, inode->i_tag,
20070 + new_tag, (propagate) ? 1 : 0);
20073 + inode->i_tag = new_tag;
20076 +#include <linux/module.h>
20078 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
20080 +#endif /* CONFIG_PROPAGATE */
20082 diff -NurpP --minimal linux-2.6.36/kernel/vserver/limit.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/limit.c
20083 --- linux-2.6.36/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
20084 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/limit.c 2010-10-21 13:09:36.000000000 +0200
20087 + * linux/kernel/vserver/limit.c
20089 + * Virtual Server: Context Limits
20091 + * Copyright (C) 2004-2010 Herbert Pötzl
20093 + * V0.01 broken out from vcontext V0.05
20094 + * V0.02 changed vcmds to vxi arg
20095 + * V0.03 added memory cgroup support
20099 +#include <linux/sched.h>
20100 +#include <linux/module.h>
20101 +#include <linux/memcontrol.h>
20102 +#include <linux/res_counter.h>
20103 +#include <linux/vs_limit.h>
20104 +#include <linux/vserver/limit.h>
20105 +#include <linux/vserver/limit_cmd.h>
20107 +#include <asm/uaccess.h>
20110 +const char *vlimit_name[NUM_LIMITS] = {
20111 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20112 + [RLIMIT_RSS] = "RSS",
20113 + [RLIMIT_AS] = "VM",
20114 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20115 + [RLIMIT_CPU] = "CPU",
20116 + [RLIMIT_NPROC] = "NPROC",
20117 + [RLIMIT_NOFILE] = "NOFILE",
20118 + [RLIMIT_LOCKS] = "LOCKS",
20119 + [RLIMIT_SIGPENDING] = "SIGP",
20120 + [RLIMIT_MSGQUEUE] = "MSGQ",
20122 + [VLIMIT_NSOCK] = "NSOCK",
20123 + [VLIMIT_OPENFD] = "OPENFD",
20124 + [VLIMIT_SHMEM] = "SHMEM",
20125 + [VLIMIT_DENTRY] = "DENTRY",
20128 +EXPORT_SYMBOL_GPL(vlimit_name);
20130 +#define MASK_ENTRY(x) (1 << (x))
20132 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
20135 + , /* softlimit */
20136 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20137 + MASK_ENTRY( RLIMIT_RSS ) |
20138 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20141 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20142 + MASK_ENTRY( RLIMIT_RSS ) |
20143 + MASK_ENTRY( RLIMIT_AS ) |
20144 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20145 + MASK_ENTRY( RLIMIT_NPROC ) |
20146 + MASK_ENTRY( RLIMIT_NOFILE ) |
20147 + MASK_ENTRY( RLIMIT_LOCKS ) |
20148 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
20150 + MASK_ENTRY( VLIMIT_NSOCK ) |
20151 + MASK_ENTRY( VLIMIT_OPENFD ) |
20152 + MASK_ENTRY( VLIMIT_SHMEM ) |
20153 + MASK_ENTRY( VLIMIT_DENTRY ) |
20156 + /* accounting only */
20157 +uint32_t account_mask =
20158 + MASK_ENTRY( VLIMIT_SEMARY ) |
20159 + MASK_ENTRY( VLIMIT_NSEMS ) |
20160 + MASK_ENTRY( VLIMIT_MAPPED ) |
20164 +static int is_valid_vlimit(int id)
20166 + uint32_t mask = vlimit_mask.minimum |
20167 + vlimit_mask.softlimit | vlimit_mask.maximum;
20168 + return mask & (1 << id);
20171 +static int is_accounted_vlimit(int id)
20173 + if (is_valid_vlimit(id))
20175 + return account_mask & (1 << id);
20179 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
20181 + rlim_t limit = __rlim_soft(&vxi->limit, id);
20182 + return VX_VLIM(limit);
20185 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
20187 + rlim_t limit = __rlim_hard(&vxi->limit, id);
20188 + return VX_VLIM(limit);
20191 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
20192 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
20194 + if (!is_valid_vlimit(id))
20198 + *minimum = CRLIM_UNSET;
20200 + *softlimit = vc_get_soft(vxi, id);
20202 + *maximum = vc_get_hard(vxi, id);
20206 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
20208 + struct vcmd_ctx_rlimit_v0 vc_data;
20211 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20214 + ret = do_get_rlimit(vxi, vc_data.id,
20215 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20219 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20224 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
20225 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
20227 + if (!is_valid_vlimit(id))
20230 + if (maximum != CRLIM_KEEP)
20231 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
20232 + if (softlimit != CRLIM_KEEP)
20233 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
20235 + /* clamp soft limit */
20236 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
20237 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
20242 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
20244 + struct vcmd_ctx_rlimit_v0 vc_data;
20246 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20249 + return do_set_rlimit(vxi, vc_data.id,
20250 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20253 +#ifdef CONFIG_IA32_EMULATION
20255 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
20257 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20259 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20262 + return do_set_rlimit(vxi, vc_data.id,
20263 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20266 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
20268 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20271 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20274 + ret = do_get_rlimit(vxi, vc_data.id,
20275 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20279 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20284 +#endif /* CONFIG_IA32_EMULATION */
20287 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
20289 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
20295 +static inline void vx_reset_hits(struct _vx_limit *limit)
20299 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20300 + atomic_set(&__rlim_lhit(limit, lim), 0);
20304 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
20306 + vx_reset_hits(&vxi->limit);
20310 +static inline void vx_reset_minmax(struct _vx_limit *limit)
20315 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20316 + value = __rlim_get(limit, lim);
20317 + __rlim_rmax(limit, lim) = value;
20318 + __rlim_rmin(limit, lim) = value;
20322 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
20324 + vx_reset_minmax(&vxi->limit);
20329 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20331 + struct vcmd_rlimit_stat_v0 vc_data;
20332 + struct _vx_limit *limit = &vxi->limit;
20335 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20339 + if (!is_accounted_vlimit(id))
20342 + vx_limit_fixup(limit, id);
20343 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20344 + vc_data.value = __rlim_get(limit, id);
20345 + vc_data.minimum = __rlim_rmin(limit, id);
20346 + vc_data.maximum = __rlim_rmax(limit, id);
20348 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20354 +void vx_vsi_meminfo(struct sysinfo *val)
20356 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20357 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20358 + u64 res_limit, res_usage;
20363 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20364 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20366 + if (res_limit != RESOURCE_MAX)
20367 + val->totalram = (res_limit >> PAGE_SHIFT);
20368 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
20369 + val->bufferram = 0;
20370 + val->totalhigh = 0;
20371 + val->freehigh = 0;
20372 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20376 +void vx_vsi_swapinfo(struct sysinfo *val)
20378 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20379 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20380 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20381 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20382 + s64 swap_limit, swap_usage;
20387 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20388 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20389 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20390 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20392 + if (res_limit == RESOURCE_MAX)
20395 + swap_limit = memsw_limit - res_limit;
20396 + if (memsw_limit != RESOURCE_MAX)
20397 + val->totalswap = swap_limit >> PAGE_SHIFT;
20399 + swap_usage = memsw_usage - res_usage;
20400 + val->freeswap = (swap_usage < swap_limit) ?
20401 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20402 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20403 + val->totalswap = 0;
20404 + val->freeswap = 0;
20405 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20406 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20410 +long vx_vsi_cached(struct sysinfo *val)
20412 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20413 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20415 + return mem_cgroup_stat_read_cache(mcg);
20422 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
20424 + struct vx_info *vxi = mm->mm_vx_info;
20425 + unsigned long points;
20431 + points = vxi->vx_badness_bias;
20433 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20434 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20435 + points += (v > w) ? (v - w) : 0;
20440 diff -NurpP --minimal linux-2.6.36/kernel/vserver/limit_init.h linux-2.6.36-vs2.3.0.36.38/kernel/vserver/limit_init.h
20441 --- linux-2.6.36/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20442 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/limit_init.h 2010-10-21 13:09:36.000000000 +0200
20446 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20450 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20451 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20452 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20453 + __rlim_set(limit, lim, 0);
20454 + atomic_set(&__rlim_lhit(limit, lim), 0);
20455 + __rlim_rmin(limit, lim) = 0;
20456 + __rlim_rmax(limit, lim) = 0;
20460 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20465 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20466 + if ((1 << lim) & VLIM_NOCHECK)
20468 + value = __rlim_get(limit, lim);
20469 + vxwprintk_xid(value,
20470 + "!!! limit: %p[%s,%d] = %ld on exit.",
20471 + limit, vlimit_name[lim], lim, (long)value);
20475 diff -NurpP --minimal linux-2.6.36/kernel/vserver/limit_proc.h linux-2.6.36-vs2.3.0.36.38/kernel/vserver/limit_proc.h
20476 --- linux-2.6.36/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20477 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/limit_proc.h 2010-10-21 13:09:36.000000000 +0200
20479 +#ifndef _VX_LIMIT_PROC_H
20480 +#define _VX_LIMIT_PROC_H
20482 +#include <linux/vserver/limit_int.h>
20485 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20486 +#define VX_LIMIT_TOP \
20487 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20489 +#define VX_LIMIT_ARG(r) \
20490 + (unsigned long)__rlim_get(limit, r), \
20491 + (unsigned long)__rlim_rmin(limit, r), \
20492 + (unsigned long)__rlim_rmax(limit, r), \
20493 + VX_VLIM(__rlim_soft(limit, r)), \
20494 + VX_VLIM(__rlim_hard(limit, r)), \
20495 + atomic_read(&__rlim_lhit(limit, r))
20497 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20499 + vx_limit_fixup(limit, -1);
20500 + return sprintf(buffer, VX_LIMIT_TOP
20501 + "PROC" VX_LIMIT_FMT
20502 + "VM" VX_LIMIT_FMT
20503 + "VML" VX_LIMIT_FMT
20504 + "RSS" VX_LIMIT_FMT
20505 + "ANON" VX_LIMIT_FMT
20506 + "RMAP" VX_LIMIT_FMT
20507 + "FILES" VX_LIMIT_FMT
20508 + "OFD" VX_LIMIT_FMT
20509 + "LOCKS" VX_LIMIT_FMT
20510 + "SOCK" VX_LIMIT_FMT
20511 + "MSGQ" VX_LIMIT_FMT
20512 + "SHM" VX_LIMIT_FMT
20513 + "SEMA" VX_LIMIT_FMT
20514 + "SEMS" VX_LIMIT_FMT
20515 + "DENT" VX_LIMIT_FMT,
20516 + VX_LIMIT_ARG(RLIMIT_NPROC),
20517 + VX_LIMIT_ARG(RLIMIT_AS),
20518 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20519 + VX_LIMIT_ARG(RLIMIT_RSS),
20520 + VX_LIMIT_ARG(VLIMIT_ANON),
20521 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20522 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20523 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20524 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20525 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20526 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20527 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20528 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20529 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20530 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20533 +#endif /* _VX_LIMIT_PROC_H */
20536 diff -NurpP --minimal linux-2.6.36/kernel/vserver/network.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/network.c
20537 --- linux-2.6.36/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20538 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/network.c 2010-10-21 13:09:36.000000000 +0200
20541 + * linux/kernel/vserver/network.c
20543 + * Virtual Server: Network Support
20545 + * Copyright (C) 2003-2007 Herbert Pötzl
20547 + * V0.01 broken out from vcontext V0.05
20548 + * V0.02 cleaned up implementation
20549 + * V0.03 added equiv nx commands
20550 + * V0.04 switch to RCU based hash
20551 + * V0.05 and back to locking again
20552 + * V0.06 changed vcmds to nxi arg
20553 + * V0.07 have __create claim() the nxi
20557 +#include <linux/err.h>
20558 +#include <linux/slab.h>
20559 +#include <linux/rcupdate.h>
20561 +#include <linux/vs_network.h>
20562 +#include <linux/vs_pid.h>
20563 +#include <linux/vserver/network_cmd.h>
20566 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20567 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20569 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20570 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20573 +static int __init init_network(void)
20575 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20576 + sizeof(struct nx_addr_v4), 0,
20577 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20578 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20579 + sizeof(struct nx_addr_v6), 0,
20580 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20585 +/* __alloc_nx_addr_v4() */
20587 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20589 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20590 + nx_addr_v4_cachep, GFP_KERNEL);
20592 + if (!IS_ERR(nxa))
20593 + memset(nxa, 0, sizeof(*nxa));
20597 +/* __dealloc_nx_addr_v4() */
20599 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20601 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20604 +/* __dealloc_nx_addr_v4_all() */
20606 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20609 + struct nx_addr_v4 *next = nxa->next;
20611 + __dealloc_nx_addr_v4(nxa);
20617 +#ifdef CONFIG_IPV6
20619 +/* __alloc_nx_addr_v6() */
20621 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20623 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20624 + nx_addr_v6_cachep, GFP_KERNEL);
20626 + if (!IS_ERR(nxa))
20627 + memset(nxa, 0, sizeof(*nxa));
20631 +/* __dealloc_nx_addr_v6() */
20633 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20635 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20638 +/* __dealloc_nx_addr_v6_all() */
20640 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20643 + struct nx_addr_v6 *next = nxa->next;
20645 + __dealloc_nx_addr_v6(nxa);
20650 +#endif /* CONFIG_IPV6 */
20652 +/* __alloc_nx_info()
20654 + * allocate an initialized nx_info struct
20655 + * doesn't make it visible (hash) */
20657 +static struct nx_info *__alloc_nx_info(nid_t nid)
20659 + struct nx_info *new = NULL;
20661 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20663 + /* would this benefit from a slab cache? */
20664 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20668 + memset(new, 0, sizeof(struct nx_info));
20669 + new->nx_id = nid;
20670 + INIT_HLIST_NODE(&new->nx_hlist);
20671 + atomic_set(&new->nx_usecnt, 0);
20672 + atomic_set(&new->nx_tasks, 0);
20673 + new->nx_state = 0;
20675 + new->nx_flags = NXF_INIT_SET;
20677 + /* rest of init goes here */
20679 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20680 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20682 + vxdprintk(VXD_CBIT(nid, 0),
20683 + "alloc_nx_info(%d) = %p", nid, new);
20684 + atomic_inc(&nx_global_ctotal);
20688 +/* __dealloc_nx_info()
20690 + * final disposal of nx_info */
20692 +static void __dealloc_nx_info(struct nx_info *nxi)
20694 + vxdprintk(VXD_CBIT(nid, 0),
20695 + "dealloc_nx_info(%p)", nxi);
20697 + nxi->nx_hlist.next = LIST_POISON1;
20700 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20701 + BUG_ON(atomic_read(&nxi->nx_tasks));
20703 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20705 + nxi->nx_state |= NXS_RELEASED;
20707 + atomic_dec(&nx_global_ctotal);
20710 +static void __shutdown_nx_info(struct nx_info *nxi)
20712 + nxi->nx_state |= NXS_SHUTDOWN;
20713 + vs_net_change(nxi, VSC_NETDOWN);
20716 +/* exported stuff */
20718 +void free_nx_info(struct nx_info *nxi)
20720 + /* context shutdown is mandatory */
20721 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20723 + /* context must not be hashed */
20724 + BUG_ON(nxi->nx_state & NXS_HASHED);
20726 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20727 + BUG_ON(atomic_read(&nxi->nx_tasks));
20729 + __dealloc_nx_info(nxi);
20733 +void __nx_set_lback(struct nx_info *nxi)
20735 + int nid = nxi->nx_id;
20736 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20738 + nxi->v4_lback.s_addr = lback;
20741 +extern int __nx_inet_add_lback(__be32 addr);
20742 +extern int __nx_inet_del_lback(__be32 addr);
20745 +/* hash table for nx_info hash */
20747 +#define NX_HASH_SIZE 13
20749 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20751 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
20754 +static inline unsigned int __hashval(nid_t nid)
20756 + return (nid % NX_HASH_SIZE);
20761 +/* __hash_nx_info()
20763 + * add the nxi to the global hash table
20764 + * requires the hash_lock to be held */
20766 +static inline void __hash_nx_info(struct nx_info *nxi)
20768 + struct hlist_head *head;
20770 + vxd_assert_lock(&nx_info_hash_lock);
20771 + vxdprintk(VXD_CBIT(nid, 4),
20772 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20774 + /* context must not be hashed */
20775 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20777 + nxi->nx_state |= NXS_HASHED;
20778 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20779 + hlist_add_head(&nxi->nx_hlist, head);
20780 + atomic_inc(&nx_global_cactive);
20783 +/* __unhash_nx_info()
20785 + * remove the nxi from the global hash table
20786 + * requires the hash_lock to be held */
20788 +static inline void __unhash_nx_info(struct nx_info *nxi)
20790 + vxd_assert_lock(&nx_info_hash_lock);
20791 + vxdprintk(VXD_CBIT(nid, 4),
20792 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20793 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20795 + /* context must be hashed */
20796 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20797 + /* but without tasks */
20798 + BUG_ON(atomic_read(&nxi->nx_tasks));
20800 + nxi->nx_state &= ~NXS_HASHED;
20801 + hlist_del(&nxi->nx_hlist);
20802 + atomic_dec(&nx_global_cactive);
20806 +/* __lookup_nx_info()
20808 + * requires the hash_lock to be held
20809 + * doesn't increment the nx_refcnt */
20811 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20813 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20814 + struct hlist_node *pos;
20815 + struct nx_info *nxi;
20817 + vxd_assert_lock(&nx_info_hash_lock);
20818 + hlist_for_each(pos, head) {
20819 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20821 + if (nxi->nx_id == nid)
20826 + vxdprintk(VXD_CBIT(nid, 0),
20827 + "__lookup_nx_info(#%u): %p[#%u]",
20828 + nid, nxi, nxi ? nxi->nx_id : 0);
20833 +/* __create_nx_info()
20835 + * create the requested context
20836 + * get(), claim() and hash it */
20838 +static struct nx_info *__create_nx_info(int id)
20840 + struct nx_info *new, *nxi = NULL;
20842 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20844 + if (!(new = __alloc_nx_info(id)))
20845 + return ERR_PTR(-ENOMEM);
20847 + /* required to make dynamic xids unique */
20848 + spin_lock(&nx_info_hash_lock);
20850 + /* static context requested */
20851 + if ((nxi = __lookup_nx_info(id))) {
20852 + vxdprintk(VXD_CBIT(nid, 0),
20853 + "create_nx_info(%d) = %p (already there)", id, nxi);
20854 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20855 + nxi = ERR_PTR(-EBUSY);
20857 + nxi = ERR_PTR(-EEXIST);
20860 + /* new context */
20861 + vxdprintk(VXD_CBIT(nid, 0),
20862 + "create_nx_info(%d) = %p (new)", id, new);
20863 + claim_nx_info(new, NULL);
20864 + __nx_set_lback(new);
20865 + __hash_nx_info(get_nx_info(new));
20866 + nxi = new, new = NULL;
20869 + spin_unlock(&nx_info_hash_lock);
20871 + __dealloc_nx_info(new);
20877 +/* exported stuff */
20880 +void unhash_nx_info(struct nx_info *nxi)
20882 + __shutdown_nx_info(nxi);
20883 + spin_lock(&nx_info_hash_lock);
20884 + __unhash_nx_info(nxi);
20885 + spin_unlock(&nx_info_hash_lock);
20888 +/* lookup_nx_info()
20890 + * search for a nx_info and get() it
20891 + * negative id means current */
20893 +struct nx_info *lookup_nx_info(int id)
20895 + struct nx_info *nxi = NULL;
20898 + nxi = get_nx_info(current_nx_info());
20899 + } else if (id > 1) {
20900 + spin_lock(&nx_info_hash_lock);
20901 + nxi = get_nx_info(__lookup_nx_info(id));
20902 + spin_unlock(&nx_info_hash_lock);
20907 +/* nid_is_hashed()
20909 + * verify that nid is still hashed */
20911 +int nid_is_hashed(nid_t nid)
20915 + spin_lock(&nx_info_hash_lock);
20916 + hashed = (__lookup_nx_info(nid) != NULL);
20917 + spin_unlock(&nx_info_hash_lock);
20922 +#ifdef CONFIG_PROC_FS
20926 + * get a subset of hashed nids for proc
20927 + * assumes size is at least one */
20929 +int get_nid_list(int index, unsigned int *nids, int size)
20931 + int hindex, nr_nids = 0;
20933 + /* only show current and children */
20934 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20937 + nids[nr_nids] = nx_current_nid();
20941 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20942 + struct hlist_head *head = &nx_info_hash[hindex];
20943 + struct hlist_node *pos;
20945 + spin_lock(&nx_info_hash_lock);
20946 + hlist_for_each(pos, head) {
20947 + struct nx_info *nxi;
20952 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20953 + nids[nr_nids] = nxi->nx_id;
20954 + if (++nr_nids >= size) {
20955 + spin_unlock(&nx_info_hash_lock);
20959 + /* keep the lock time short */
20960 + spin_unlock(&nx_info_hash_lock);
20969 + * migrate task to new network
20970 + * gets nxi, puts old_nxi on change
20973 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20975 + struct nx_info *old_nxi;
20981 + vxdprintk(VXD_CBIT(nid, 5),
20982 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20983 + p, nxi, nxi->nx_id,
20984 + atomic_read(&nxi->nx_usecnt),
20985 + atomic_read(&nxi->nx_tasks));
20987 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20988 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20991 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20994 + /* maybe disallow this completely? */
20995 + old_nxi = task_get_nx_info(p);
20996 + if (old_nxi == nxi)
21001 + clr_nx_info(&p->nx_info);
21002 + claim_nx_info(nxi, p);
21003 + set_nx_info(&p->nx_info, nxi);
21004 + p->nid = nxi->nx_id;
21007 + vxdprintk(VXD_CBIT(nid, 5),
21008 + "moved task %p into nxi:%p[#%d]",
21009 + p, nxi, nxi->nx_id);
21012 + release_nx_info(old_nxi, p);
21015 + put_nx_info(old_nxi);
21020 +void nx_set_persistent(struct nx_info *nxi)
21022 + vxdprintk(VXD_CBIT(nid, 6),
21023 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
21025 + get_nx_info(nxi);
21026 + claim_nx_info(nxi, NULL);
21029 +void nx_clear_persistent(struct nx_info *nxi)
21031 + vxdprintk(VXD_CBIT(nid, 6),
21032 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
21034 + release_nx_info(nxi, NULL);
21035 + put_nx_info(nxi);
21038 +void nx_update_persistent(struct nx_info *nxi)
21040 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
21041 + nx_set_persistent(nxi);
21043 + nx_clear_persistent(nxi);
21046 +/* vserver syscall commands below here */
21048 +/* taks nid and nx_info functions */
21050 +#include <asm/uaccess.h>
21053 +int vc_task_nid(uint32_t id)
21058 + struct task_struct *tsk;
21060 + read_lock(&tasklist_lock);
21061 + tsk = find_task_by_real_pid(id);
21062 + nid = (tsk) ? tsk->nid : -ESRCH;
21063 + read_unlock(&tasklist_lock);
21065 + nid = nx_current_nid();
21070 +int vc_nx_info(struct nx_info *nxi, void __user *data)
21072 + struct vcmd_nx_info_v0 vc_data;
21074 + vc_data.nid = nxi->nx_id;
21076 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21082 +/* network functions */
21084 +int vc_net_create(uint32_t nid, void __user *data)
21086 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
21087 + struct nx_info *new_nxi;
21090 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21093 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
21096 + new_nxi = __create_nx_info(nid);
21097 + if (IS_ERR(new_nxi))
21098 + return PTR_ERR(new_nxi);
21100 + /* initial flags */
21101 + new_nxi->nx_flags = vc_data.flagword;
21104 + if (vs_net_change(new_nxi, VSC_NETUP))
21107 + ret = nx_migrate_task(current, new_nxi);
21111 + /* return context id on success */
21112 + ret = new_nxi->nx_id;
21114 + /* get a reference for persistent contexts */
21115 + if ((vc_data.flagword & NXF_PERSISTENT))
21116 + nx_set_persistent(new_nxi);
21118 + release_nx_info(new_nxi, NULL);
21119 + put_nx_info(new_nxi);
21124 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
21126 + return nx_migrate_task(current, nxi);
21131 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21132 + uint16_t type, uint16_t flags)
21134 + struct nx_addr_v4 *nxa = &nxi->v4;
21136 + if (NX_IPV4(nxi)) {
21137 + /* locate last entry */
21138 + for (; nxa->next; nxa = nxa->next);
21139 + nxa->next = __alloc_nx_addr_v4();
21143 + return PTR_ERR(nxa);
21146 + if (nxi->v4.next)
21147 + /* remove single ip for ip list */
21148 + nxi->nx_flags &= ~NXF_SINGLE_IP;
21150 + nxa->ip[0].s_addr = ip;
21151 + nxa->ip[1].s_addr = ip2;
21152 + nxa->mask.s_addr = mask;
21153 + nxa->type = type;
21154 + nxa->flags = flags;
21159 +int vc_net_add(struct nx_info *nxi, void __user *data)
21161 + struct vcmd_net_addr_v0 vc_data;
21162 + int index, ret = 0;
21164 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21167 + switch (vc_data.type) {
21168 + case NXA_TYPE_IPV4:
21169 + if ((vc_data.count < 1) || (vc_data.count > 4))
21173 + while (index < vc_data.count) {
21174 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
21175 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
21183 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
21184 + nxi->v4_bcast = vc_data.ip[0];
21188 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
21189 + nxi->v4_lback = vc_data.ip[0];
21200 +int vc_net_remove(struct nx_info *nxi, void __user *data)
21202 + struct vcmd_net_addr_v0 vc_data;
21204 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21207 + switch (vc_data.type) {
21208 + case NXA_TYPE_ANY:
21209 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21210 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21220 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
21222 + struct vcmd_net_addr_ipv4_v1 vc_data;
21224 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21227 + switch (vc_data.type) {
21228 + case NXA_TYPE_ADDR:
21229 + case NXA_TYPE_RANGE:
21230 + case NXA_TYPE_MASK:
21231 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
21232 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21234 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21235 + nxi->v4_bcast = vc_data.ip;
21238 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21239 + nxi->v4_lback = vc_data.ip;
21248 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
21250 + struct vcmd_net_addr_ipv4_v1 vc_data;
21252 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21255 + switch (vc_data.type) {
21256 +/* case NXA_TYPE_ADDR:
21259 + case NXA_TYPE_ANY:
21260 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21261 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21271 +#ifdef CONFIG_IPV6
21273 +int do_add_v6_addr(struct nx_info *nxi,
21274 + struct in6_addr *ip, struct in6_addr *mask,
21275 + uint32_t prefix, uint16_t type, uint16_t flags)
21277 + struct nx_addr_v6 *nxa = &nxi->v6;
21279 + if (NX_IPV6(nxi)) {
21280 + /* locate last entry */
21281 + for (; nxa->next; nxa = nxa->next);
21282 + nxa->next = __alloc_nx_addr_v6();
21286 + return PTR_ERR(nxa);
21290 + nxa->mask = *mask;
21291 + nxa->prefix = prefix;
21292 + nxa->type = type;
21293 + nxa->flags = flags;
21298 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21300 + struct vcmd_net_addr_ipv6_v1 vc_data;
21302 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21305 + switch (vc_data.type) {
21306 + case NXA_TYPE_ADDR:
21307 + case NXA_TYPE_MASK:
21308 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21309 + vc_data.prefix, vc_data.type, vc_data.flags);
21316 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21318 + struct vcmd_net_addr_ipv6_v1 vc_data;
21320 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21323 + switch (vc_data.type) {
21324 + case NXA_TYPE_ANY:
21325 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21326 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21335 +#endif /* CONFIG_IPV6 */
21338 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21340 + struct vcmd_net_flags_v0 vc_data;
21342 + vc_data.flagword = nxi->nx_flags;
21344 + /* special STATE flag handling */
21345 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21347 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21352 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21354 + struct vcmd_net_flags_v0 vc_data;
21355 + uint64_t mask, trigger;
21357 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21360 + /* special STATE flag handling */
21361 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21362 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21364 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21365 + vc_data.flagword, mask);
21366 + if (trigger & NXF_PERSISTENT)
21367 + nx_update_persistent(nxi);
21372 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21374 + struct vcmd_net_caps_v0 vc_data;
21376 + vc_data.ncaps = nxi->nx_ncaps;
21377 + vc_data.cmask = ~0ULL;
21379 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21384 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21386 + struct vcmd_net_caps_v0 vc_data;
21388 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21391 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21392 + vc_data.ncaps, vc_data.cmask);
21397 +#include <linux/module.h>
21399 +module_init(init_network);
21401 +EXPORT_SYMBOL_GPL(free_nx_info);
21402 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21404 diff -NurpP --minimal linux-2.6.36/kernel/vserver/proc.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/proc.c
21405 --- linux-2.6.36/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21406 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/proc.c 2010-10-21 13:09:36.000000000 +0200
21409 + * linux/kernel/vserver/proc.c
21411 + * Virtual Context Support
21413 + * Copyright (C) 2003-2007 Herbert Pötzl
21415 + * V0.01 basic structure
21416 + * V0.02 adaptation vs1.3.0
21417 + * V0.03 proc permissions
21418 + * V0.04 locking/generic
21419 + * V0.05 next generation procfs
21420 + * V0.06 inode validation
21421 + * V0.07 generic rewrite vid
21422 + * V0.08 remove inode type
21426 +#include <linux/proc_fs.h>
21427 +#include <linux/fs_struct.h>
21428 +#include <linux/mount.h>
21429 +#include <asm/unistd.h>
21431 +#include <linux/vs_context.h>
21432 +#include <linux/vs_network.h>
21433 +#include <linux/vs_cvirt.h>
21435 +#include <linux/in.h>
21436 +#include <linux/inetdevice.h>
21437 +#include <linux/vs_inet.h>
21438 +#include <linux/vs_inet6.h>
21440 +#include <linux/vserver/global.h>
21442 +#include "cvirt_proc.h"
21443 +#include "cacct_proc.h"
21444 +#include "limit_proc.h"
21445 +#include "sched_proc.h"
21446 +#include "vci_config.h"
21449 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21453 + CAP_FOR_EACH_U32(__capi) {
21454 + buffer += sprintf(buffer, "%08x",
21455 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21461 +static struct proc_dir_entry *proc_virtual;
21463 +static struct proc_dir_entry *proc_virtnet;
21466 +/* first the actual feeds */
21469 +static int proc_vci(char *buffer)
21471 + return sprintf(buffer,
21472 + "VCIVersion:\t%04x:%04x\n"
21473 + "VCISyscall:\t%d\n"
21474 + "VCIKernel:\t%08x\n",
21475 + VCI_VERSION >> 16,
21476 + VCI_VERSION & 0xFFFF,
21478 + vci_kernel_config());
21481 +static int proc_virtual_info(char *buffer)
21483 + return proc_vci(buffer);
21486 +static int proc_virtual_status(char *buffer)
21488 + return sprintf(buffer,
21490 + "#CActive:\t%d\n"
21491 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21492 + "#InitTask:\t%d\t%d %d\n",
21493 + atomic_read(&vx_global_ctotal),
21494 + atomic_read(&vx_global_cactive),
21495 + atomic_read(&vs_global_nsproxy),
21496 + atomic_read(&vs_global_fs),
21497 + atomic_read(&vs_global_mnt_ns),
21498 + atomic_read(&vs_global_uts_ns),
21499 + atomic_read(&nr_ipc_ns),
21500 + atomic_read(&vs_global_user_ns),
21501 + atomic_read(&vs_global_pid_ns),
21502 + atomic_read(&init_task.usage),
21503 + atomic_read(&init_task.nsproxy->count),
21504 + init_task.fs->users);
21508 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21512 + length = sprintf(buffer,
21520 + vxi->vx_badness_bias);
21524 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21526 + char *orig = buffer;
21528 + buffer += sprintf(buffer,
21531 + "Flags:\t%016llx\n",
21532 + atomic_read(&vxi->vx_usecnt),
21533 + atomic_read(&vxi->vx_tasks),
21534 + (unsigned long long)vxi->vx_flags);
21536 + buffer += sprintf(buffer, "BCaps:\t");
21537 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21538 + buffer += sprintf(buffer, "\n");
21540 + buffer += sprintf(buffer,
21541 + "CCaps:\t%016llx\n"
21542 + "Spaces:\t%08lx %08lx\n",
21543 + (unsigned long long)vxi->vx_ccaps,
21544 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
21545 + return buffer - orig;
21548 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21550 + return vx_info_proc_limit(&vxi->limit, buffer);
21553 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21557 + length = vx_info_proc_sched(&vxi->sched, buffer);
21558 + for_each_online_cpu(cpu) {
21559 + length += vx_info_proc_sched_pc(
21560 + &vx_per_cpu(vxi, sched_pc, cpu),
21561 + buffer + length, cpu);
21566 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21568 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
21571 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21573 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
21576 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21580 + vx_update_load(vxi);
21581 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21582 + for_each_online_cpu(cpu) {
21583 + length += vx_info_proc_cvirt_pc(
21584 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21585 + buffer + length, cpu);
21590 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21592 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21596 +static int proc_virtnet_info(char *buffer)
21598 + return proc_vci(buffer);
21601 +static int proc_virtnet_status(char *buffer)
21603 + return sprintf(buffer,
21605 + "#CActive:\t%d\n",
21606 + atomic_read(&nx_global_ctotal),
21607 + atomic_read(&nx_global_cactive));
21610 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21612 + struct nx_addr_v4 *v4a;
21613 +#ifdef CONFIG_IPV6
21614 + struct nx_addr_v6 *v6a;
21618 + length = sprintf(buffer,
21621 + "Bcast:\t" NIPQUAD_FMT "\n"
21622 + "Lback:\t" NIPQUAD_FMT "\n",
21625 + NIPQUAD(nxi->v4_bcast.s_addr),
21626 + NIPQUAD(nxi->v4_lback.s_addr));
21628 + if (!NX_IPV4(nxi))
21630 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21631 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21634 +#ifdef CONFIG_IPV6
21635 + if (!NX_IPV6(nxi))
21637 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21638 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21645 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21649 + length = sprintf(buffer,
21652 + "Flags:\t%016llx\n"
21653 + "NCaps:\t%016llx\n",
21654 + atomic_read(&nxi->nx_usecnt),
21655 + atomic_read(&nxi->nx_tasks),
21656 + (unsigned long long)nxi->nx_flags,
21657 + (unsigned long long)nxi->nx_ncaps);
21663 +/* here the inode helpers */
21669 + struct inode_operations *iop;
21670 + struct file_operations *fop;
21671 + union proc_op op;
21674 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21676 + struct inode *inode = new_inode(sb);
21681 + inode->i_mode = p->mode;
21683 + inode->i_op = p->iop;
21685 + inode->i_fop = p->fop;
21687 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
21688 + inode->i_flags |= S_IMMUTABLE;
21690 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21692 + inode->i_uid = 0;
21693 + inode->i_gid = 0;
21694 + inode->i_tag = 0;
21699 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21700 + struct dentry *dentry, int id, void *ptr)
21702 + struct vs_entry *p = ptr;
21703 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21704 + struct dentry *error = ERR_PTR(-EINVAL);
21709 + PROC_I(inode)->op = p->op;
21710 + PROC_I(inode)->fd = id;
21711 + d_add(dentry, inode);
21719 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21722 + * Fill a directory entry.
21724 + * If possible create the dcache entry and derive our inode number and
21725 + * file type from dcache entry.
21727 + * Since all of the proc inode numbers are dynamically generated, the inode
21728 + * numbers do not exist until the inode is cache. This means creating the
21729 + * the dcache entry in readdir is necessary to keep the inode numbers
21730 + * reported by readdir in sync with the inode numbers reported
21733 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21734 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21736 + struct dentry *child, *dir = filp->f_dentry;
21737 + struct inode *inode;
21738 + struct qstr qname;
21740 + unsigned type = DT_UNKNOWN;
21742 + qname.name = name;
21744 + qname.hash = full_name_hash(name, len);
21746 + child = d_lookup(dir, &qname);
21748 + struct dentry *new;
21749 + new = d_alloc(dir, &qname);
21751 + child = instantiate(dir->d_inode, new, id, ptr);
21758 + if (!child || IS_ERR(child) || !child->d_inode)
21759 + goto end_instantiate;
21760 + inode = child->d_inode;
21762 + ino = inode->i_ino;
21763 + type = inode->i_mode >> 12;
21768 + ino = find_inode_number(dir, &qname);
21771 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21776 +/* get and revalidate vx_info/xid */
21779 +struct vx_info *get_proc_vx_info(struct inode *inode)
21781 + return lookup_vx_info(PROC_I(inode)->fd);
21784 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
21786 + struct inode *inode = dentry->d_inode;
21787 + xid_t xid = PROC_I(inode)->fd;
21789 + if (!xid || xid_is_hashed(xid))
21796 +/* get and revalidate nx_info/nid */
21798 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
21800 + struct inode *inode = dentry->d_inode;
21801 + nid_t nid = PROC_I(inode)->fd;
21803 + if (!nid || nid_is_hashed(nid))
21811 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21813 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21814 + size_t count, loff_t *ppos)
21816 + struct inode *inode = file->f_dentry->d_inode;
21817 + unsigned long page;
21818 + ssize_t length = 0;
21820 + if (count > PROC_BLOCK_SIZE)
21821 + count = PROC_BLOCK_SIZE;
21823 + /* fade that out as soon as stable */
21824 + WARN_ON(PROC_I(inode)->fd);
21826 + if (!(page = __get_free_page(GFP_KERNEL)))
21829 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21830 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21833 + length = simple_read_from_buffer(buf, count, ppos,
21834 + (char *)page, length);
21840 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21841 + size_t count, loff_t *ppos)
21843 + struct inode *inode = file->f_dentry->d_inode;
21844 + struct vx_info *vxi = NULL;
21845 + xid_t xid = PROC_I(inode)->fd;
21846 + unsigned long page;
21847 + ssize_t length = 0;
21849 + if (count > PROC_BLOCK_SIZE)
21850 + count = PROC_BLOCK_SIZE;
21852 + /* fade that out as soon as stable */
21854 + vxi = lookup_vx_info(xid);
21858 + length = -ENOMEM;
21859 + if (!(page = __get_free_page(GFP_KERNEL)))
21862 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21863 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21866 + length = simple_read_from_buffer(buf, count, ppos,
21867 + (char *)page, length);
21871 + put_vx_info(vxi);
21876 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21877 + size_t count, loff_t *ppos)
21879 + struct inode *inode = file->f_dentry->d_inode;
21880 + struct nx_info *nxi = NULL;
21881 + nid_t nid = PROC_I(inode)->fd;
21882 + unsigned long page;
21883 + ssize_t length = 0;
21885 + if (count > PROC_BLOCK_SIZE)
21886 + count = PROC_BLOCK_SIZE;
21888 + /* fade that out as soon as stable */
21890 + nxi = lookup_nx_info(nid);
21894 + length = -ENOMEM;
21895 + if (!(page = __get_free_page(GFP_KERNEL)))
21898 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21899 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21902 + length = simple_read_from_buffer(buf, count, ppos,
21903 + (char *)page, length);
21907 + put_nx_info(nxi);
21914 +/* here comes the lower level */
21917 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21918 + .len = sizeof(NAME) - 1, \
21919 + .name = (NAME), \
21927 +#define DIR(NAME, MODE, OTYPE) \
21928 + NOD(NAME, (S_IFDIR | (MODE)), \
21929 + &proc_ ## OTYPE ## _inode_operations, \
21930 + &proc_ ## OTYPE ## _file_operations, { } )
21932 +#define INF(NAME, MODE, OTYPE) \
21933 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21934 + &proc_vs_info_file_operations, \
21935 + { .proc_vs_read = &proc_##OTYPE } )
21937 +#define VINF(NAME, MODE, OTYPE) \
21938 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21939 + &proc_vx_info_file_operations, \
21940 + { .proc_vxi_read = &proc_##OTYPE } )
21942 +#define NINF(NAME, MODE, OTYPE) \
21943 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21944 + &proc_nx_info_file_operations, \
21945 + { .proc_nxi_read = &proc_##OTYPE } )
21948 +static struct file_operations proc_vs_info_file_operations = {
21949 + .read = proc_vs_info_read,
21952 +static struct file_operations proc_vx_info_file_operations = {
21953 + .read = proc_vx_info_read,
21956 +static struct dentry_operations proc_xid_dentry_operations = {
21957 + .d_revalidate = proc_xid_revalidate,
21960 +static struct vs_entry vx_base_stuff[] = {
21961 + VINF("info", S_IRUGO, vxi_info),
21962 + VINF("status", S_IRUGO, vxi_status),
21963 + VINF("limit", S_IRUGO, vxi_limit),
21964 + VINF("sched", S_IRUGO, vxi_sched),
21965 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21966 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21967 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21968 + VINF("cacct", S_IRUGO, vxi_cacct),
21975 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21976 + struct dentry *dentry, int id, void *ptr)
21978 + dentry->d_op = &proc_xid_dentry_operations;
21979 + return vs_proc_instantiate(dir, dentry, id, ptr);
21982 +static struct dentry *proc_xid_lookup(struct inode *dir,
21983 + struct dentry *dentry, struct nameidata *nd)
21985 + struct vs_entry *p = vx_base_stuff;
21986 + struct dentry *error = ERR_PTR(-ENOENT);
21988 + for (; p->name; p++) {
21989 + if (p->len != dentry->d_name.len)
21991 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21997 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22002 +static int proc_xid_readdir(struct file *filp,
22003 + void *dirent, filldir_t filldir)
22005 + struct dentry *dentry = filp->f_dentry;
22006 + struct inode *inode = dentry->d_inode;
22007 + struct vs_entry *p = vx_base_stuff;
22008 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
22012 + pos = filp->f_pos;
22015 + ino = inode->i_ino;
22016 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22019 + /* fall through */
22021 + ino = parent_ino(dentry);
22022 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22025 + /* fall through */
22028 + if (index >= size)
22030 + for (p += index; p->name; p++) {
22031 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22032 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22038 + filp->f_pos = pos;
22044 +static struct file_operations proc_nx_info_file_operations = {
22045 + .read = proc_nx_info_read,
22048 +static struct dentry_operations proc_nid_dentry_operations = {
22049 + .d_revalidate = proc_nid_revalidate,
22052 +static struct vs_entry nx_base_stuff[] = {
22053 + NINF("info", S_IRUGO, nxi_info),
22054 + NINF("status", S_IRUGO, nxi_status),
22059 +static struct dentry *proc_nid_instantiate(struct inode *dir,
22060 + struct dentry *dentry, int id, void *ptr)
22062 + dentry->d_op = &proc_nid_dentry_operations;
22063 + return vs_proc_instantiate(dir, dentry, id, ptr);
22066 +static struct dentry *proc_nid_lookup(struct inode *dir,
22067 + struct dentry *dentry, struct nameidata *nd)
22069 + struct vs_entry *p = nx_base_stuff;
22070 + struct dentry *error = ERR_PTR(-ENOENT);
22072 + for (; p->name; p++) {
22073 + if (p->len != dentry->d_name.len)
22075 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22081 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22086 +static int proc_nid_readdir(struct file *filp,
22087 + void *dirent, filldir_t filldir)
22089 + struct dentry *dentry = filp->f_dentry;
22090 + struct inode *inode = dentry->d_inode;
22091 + struct vs_entry *p = nx_base_stuff;
22092 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
22096 + pos = filp->f_pos;
22099 + ino = inode->i_ino;
22100 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22103 + /* fall through */
22105 + ino = parent_ino(dentry);
22106 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22109 + /* fall through */
22112 + if (index >= size)
22114 + for (p += index; p->name; p++) {
22115 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22116 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22122 + filp->f_pos = pos;
22127 +#define MAX_MULBY10 ((~0U - 9) / 10)
22129 +static inline int atovid(const char *str, int len)
22134 + while (len-- > 0) {
22139 + if (vid >= MAX_MULBY10)
22149 +/* now the upper level (virtual) */
22152 +static struct file_operations proc_xid_file_operations = {
22153 + .read = generic_read_dir,
22154 + .readdir = proc_xid_readdir,
22157 +static struct inode_operations proc_xid_inode_operations = {
22158 + .lookup = proc_xid_lookup,
22161 +static struct vs_entry vx_virtual_stuff[] = {
22162 + INF("info", S_IRUGO, virtual_info),
22163 + INF("status", S_IRUGO, virtual_status),
22164 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
22168 +static struct dentry *proc_virtual_lookup(struct inode *dir,
22169 + struct dentry *dentry, struct nameidata *nd)
22171 + struct vs_entry *p = vx_virtual_stuff;
22172 + struct dentry *error = ERR_PTR(-ENOENT);
22175 + for (; p->name; p++) {
22176 + if (p->len != dentry->d_name.len)
22178 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22182 + goto instantiate;
22184 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22185 + if ((id < 0) || !xid_is_hashed(id))
22189 + error = proc_xid_instantiate(dir, dentry, id, p);
22194 +static struct file_operations proc_nid_file_operations = {
22195 + .read = generic_read_dir,
22196 + .readdir = proc_nid_readdir,
22199 +static struct inode_operations proc_nid_inode_operations = {
22200 + .lookup = proc_nid_lookup,
22203 +static struct vs_entry nx_virtnet_stuff[] = {
22204 + INF("info", S_IRUGO, virtnet_info),
22205 + INF("status", S_IRUGO, virtnet_status),
22206 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
22210 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
22211 + struct dentry *dentry, struct nameidata *nd)
22213 + struct vs_entry *p = nx_virtnet_stuff;
22214 + struct dentry *error = ERR_PTR(-ENOENT);
22217 + for (; p->name; p++) {
22218 + if (p->len != dentry->d_name.len)
22220 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22224 + goto instantiate;
22226 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22227 + if ((id < 0) || !nid_is_hashed(id))
22231 + error = proc_nid_instantiate(dir, dentry, id, p);
22237 +#define PROC_MAXVIDS 32
22239 +int proc_virtual_readdir(struct file *filp,
22240 + void *dirent, filldir_t filldir)
22242 + struct dentry *dentry = filp->f_dentry;
22243 + struct inode *inode = dentry->d_inode;
22244 + struct vs_entry *p = vx_virtual_stuff;
22245 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
22247 + unsigned int xid_array[PROC_MAXVIDS];
22248 + char buf[PROC_NUMBUF];
22249 + unsigned int nr_xids, i;
22252 + pos = filp->f_pos;
22255 + ino = inode->i_ino;
22256 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22259 + /* fall through */
22261 + ino = parent_ino(dentry);
22262 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22265 + /* fall through */
22268 + if (index >= size)
22270 + for (p += index; p->name; p++) {
22271 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22272 + vs_proc_instantiate, 0, p))
22277 + index = pos - size;
22278 + p = &vx_virtual_stuff[size - 1];
22279 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22280 + for (i = 0; i < nr_xids; i++) {
22281 + int n, xid = xid_array[i];
22282 + unsigned int j = PROC_NUMBUF;
22286 + buf[--j] = '0' + (n % 10);
22289 + if (proc_fill_cache(filp, dirent, filldir,
22290 + buf + j, PROC_NUMBUF - j,
22291 + vs_proc_instantiate, xid, p))
22297 + filp->f_pos = pos;
22301 +static int proc_virtual_getattr(struct vfsmount *mnt,
22302 + struct dentry *dentry, struct kstat *stat)
22304 + struct inode *inode = dentry->d_inode;
22306 + generic_fillattr(inode, stat);
22307 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22311 +static struct file_operations proc_virtual_dir_operations = {
22312 + .read = generic_read_dir,
22313 + .readdir = proc_virtual_readdir,
22316 +static struct inode_operations proc_virtual_dir_inode_operations = {
22317 + .getattr = proc_virtual_getattr,
22318 + .lookup = proc_virtual_lookup,
22325 +int proc_virtnet_readdir(struct file *filp,
22326 + void *dirent, filldir_t filldir)
22328 + struct dentry *dentry = filp->f_dentry;
22329 + struct inode *inode = dentry->d_inode;
22330 + struct vs_entry *p = nx_virtnet_stuff;
22331 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22333 + unsigned int nid_array[PROC_MAXVIDS];
22334 + char buf[PROC_NUMBUF];
22335 + unsigned int nr_nids, i;
22338 + pos = filp->f_pos;
22341 + ino = inode->i_ino;
22342 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22345 + /* fall through */
22347 + ino = parent_ino(dentry);
22348 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22351 + /* fall through */
22354 + if (index >= size)
22356 + for (p += index; p->name; p++) {
22357 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22358 + vs_proc_instantiate, 0, p))
22363 + index = pos - size;
22364 + p = &nx_virtnet_stuff[size - 1];
22365 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22366 + for (i = 0; i < nr_nids; i++) {
22367 + int n, nid = nid_array[i];
22368 + unsigned int j = PROC_NUMBUF;
22372 + buf[--j] = '0' + (n % 10);
22375 + if (proc_fill_cache(filp, dirent, filldir,
22376 + buf + j, PROC_NUMBUF - j,
22377 + vs_proc_instantiate, nid, p))
22383 + filp->f_pos = pos;
22387 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22388 + struct dentry *dentry, struct kstat *stat)
22390 + struct inode *inode = dentry->d_inode;
22392 + generic_fillattr(inode, stat);
22393 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22397 +static struct file_operations proc_virtnet_dir_operations = {
22398 + .read = generic_read_dir,
22399 + .readdir = proc_virtnet_readdir,
22402 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22403 + .getattr = proc_virtnet_getattr,
22404 + .lookup = proc_virtnet_lookup,
22409 +void proc_vx_init(void)
22411 + struct proc_dir_entry *ent;
22413 + ent = proc_mkdir("virtual", 0);
22415 + ent->proc_fops = &proc_virtual_dir_operations;
22416 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22418 + proc_virtual = ent;
22420 + ent = proc_mkdir("virtnet", 0);
22422 + ent->proc_fops = &proc_virtnet_dir_operations;
22423 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22425 + proc_virtnet = ent;
22431 +/* per pid info */
22434 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22436 + struct vx_info *vxi;
22437 + char *orig = buffer;
22439 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22441 + vxi = task_get_vx_info(p);
22445 + buffer += sprintf(buffer, "BCaps:\t");
22446 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22447 + buffer += sprintf(buffer, "\n");
22448 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22449 + (unsigned long long)vxi->vx_ccaps);
22450 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22451 + (unsigned long long)vxi->vx_flags);
22452 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22454 + put_vx_info(vxi);
22456 + return buffer - orig;
22460 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22462 + struct nx_info *nxi;
22463 + struct nx_addr_v4 *v4a;
22464 +#ifdef CONFIG_IPV6
22465 + struct nx_addr_v6 *v6a;
22467 + char *orig = buffer;
22470 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22472 + nxi = task_get_nx_info(p);
22476 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22477 + (unsigned long long)nxi->nx_ncaps);
22478 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22479 + (unsigned long long)nxi->nx_flags);
22481 + buffer += sprintf(buffer,
22482 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22483 + NIPQUAD(nxi->v4_bcast.s_addr));
22484 + buffer += sprintf (buffer,
22485 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22486 + NIPQUAD(nxi->v4_lback.s_addr));
22487 + if (!NX_IPV4(nxi))
22489 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22490 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22493 +#ifdef CONFIG_IPV6
22494 + if (!NX_IPV6(nxi))
22496 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22497 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22501 + put_nx_info(nxi);
22503 + return buffer - orig;
22506 diff -NurpP --minimal linux-2.6.36/kernel/vserver/sched.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/sched.c
22507 --- linux-2.6.36/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22508 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/sched.c 2010-10-28 19:13:19.000000000 +0200
22511 + * linux/kernel/vserver/sched.c
22513 + * Virtual Server: Scheduler Support
22515 + * Copyright (C) 2004-2010 Herbert Pötzl
22517 + * V0.01 adapted Sam Vilains version to 2.6.3
22518 + * V0.02 removed legacy interface
22519 + * V0.03 changed vcmds to vxi arg
22520 + * V0.04 removed older and legacy interfaces
22521 + * V0.05 removed scheduler code/commands
22525 +#include <linux/vs_context.h>
22526 +#include <linux/vs_sched.h>
22527 +#include <linux/vserver/sched_cmd.h>
22529 +#include <asm/uaccess.h>
22532 +void vx_update_sched_param(struct _vx_sched *sched,
22533 + struct _vx_sched_pc *sched_pc)
22535 + sched_pc->prio_bias = sched->prio_bias;
22538 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22542 + if (data->prio_bias > MAX_PRIO_BIAS)
22543 + data->prio_bias = MAX_PRIO_BIAS;
22544 + if (data->prio_bias < MIN_PRIO_BIAS)
22545 + data->prio_bias = MIN_PRIO_BIAS;
22547 + if (data->cpu_id != ~0) {
22548 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22549 + cpus_and(vxi->sched.update, cpu_online_map,
22550 + vxi->sched.update);
22552 + vxi->sched.update = cpu_online_map;
22554 + for_each_cpu_mask(cpu, vxi->sched.update)
22555 + vx_update_sched_param(&vxi->sched,
22556 + &vx_per_cpu(vxi, sched_pc, cpu));
22560 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22562 + struct vcmd_prio_bias vc_data;
22564 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22567 + return do_set_prio_bias(vxi, &vc_data);
22570 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22572 + struct vcmd_prio_bias vc_data;
22573 + struct _vx_sched_pc *pcd;
22576 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22579 + cpu = vc_data.cpu_id;
22581 + if (!cpu_possible(cpu))
22584 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22585 + vc_data.prio_bias = pcd->prio_bias;
22587 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22592 diff -NurpP --minimal linux-2.6.36/kernel/vserver/sched_init.h linux-2.6.36-vs2.3.0.36.38/kernel/vserver/sched_init.h
22593 --- linux-2.6.36/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22594 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/sched_init.h 2010-10-28 18:17:11.000000000 +0200
22597 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22599 + /* scheduling; hard code starting values as constants */
22600 + sched->prio_bias = 0;
22604 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22606 + sched_pc->prio_bias = 0;
22608 + sched_pc->user_ticks = 0;
22609 + sched_pc->sys_ticks = 0;
22610 + sched_pc->hold_ticks = 0;
22613 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22619 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22623 diff -NurpP --minimal linux-2.6.36/kernel/vserver/sched_proc.h linux-2.6.36-vs2.3.0.36.38/kernel/vserver/sched_proc.h
22624 --- linux-2.6.36/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22625 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/sched_proc.h 2010-10-28 18:15:30.000000000 +0200
22627 +#ifndef _VX_SCHED_PROC_H
22628 +#define _VX_SCHED_PROC_H
22632 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22636 + length += sprintf(buffer,
22637 + "PrioBias:\t%8d\n",
22638 + sched->prio_bias);
22643 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22644 + char *buffer, int cpu)
22648 + length += sprintf(buffer + length,
22649 + "cpu %d: %lld %lld %lld", cpu,
22650 + (unsigned long long)sched_pc->user_ticks,
22651 + (unsigned long long)sched_pc->sys_ticks,
22652 + (unsigned long long)sched_pc->hold_ticks);
22653 + length += sprintf(buffer + length,
22654 + " %d\n", sched_pc->prio_bias);
22658 +#endif /* _VX_SCHED_PROC_H */
22659 diff -NurpP --minimal linux-2.6.36/kernel/vserver/signal.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/signal.c
22660 --- linux-2.6.36/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22661 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/signal.c 2010-10-21 13:09:36.000000000 +0200
22664 + * linux/kernel/vserver/signal.c
22666 + * Virtual Server: Signal Support
22668 + * Copyright (C) 2003-2007 Herbert Pötzl
22670 + * V0.01 broken out from vcontext V0.05
22671 + * V0.02 changed vcmds to vxi arg
22672 + * V0.03 adjusted siginfo for kill
22676 +#include <asm/uaccess.h>
22678 +#include <linux/vs_context.h>
22679 +#include <linux/vs_pid.h>
22680 +#include <linux/vserver/signal_cmd.h>
22683 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22685 + int retval, count = 0;
22686 + struct task_struct *p;
22687 + struct siginfo *sip = SEND_SIG_PRIV;
22690 + vxdprintk(VXD_CBIT(misc, 4),
22691 + "vx_info_kill(%p[#%d],%d,%d)*",
22692 + vxi, vxi->vx_id, pid, sig);
22693 + read_lock(&tasklist_lock);
22697 + for_each_process(p) {
22700 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22701 + (pid && vxi->vx_initpid == p->pid))
22704 + err = group_send_sig_info(sig, sip, p);
22706 + if (err != -EPERM)
22712 + if (vxi->vx_initpid) {
22713 + pid = vxi->vx_initpid;
22714 + /* for now, only SIGINT to private init ... */
22715 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22716 + /* ... as long as there are tasks left */
22717 + (atomic_read(&vxi->vx_tasks) > 1))
22720 + /* fallthrough */
22722 + p = find_task_by_real_pid(pid);
22724 + if (vx_task_xid(p) == vxi->vx_id)
22725 + retval = group_send_sig_info(sig, sip, p);
22729 + read_unlock(&tasklist_lock);
22730 + vxdprintk(VXD_CBIT(misc, 4),
22731 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22732 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22736 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22738 + struct vcmd_ctx_kill_v0 vc_data;
22740 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22743 + /* special check to allow guest shutdown */
22744 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22745 + /* forbid killall pid=0 when init is present */
22746 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22747 + (vc_data.pid > 1)))
22750 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22754 +static int __wait_exit(struct vx_info *vxi)
22756 + DECLARE_WAITQUEUE(wait, current);
22759 + add_wait_queue(&vxi->vx_wait, &wait);
22760 + set_current_state(TASK_INTERRUPTIBLE);
22763 + if (vx_info_state(vxi,
22764 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22766 + if (signal_pending(current)) {
22767 + ret = -ERESTARTSYS;
22774 + set_current_state(TASK_RUNNING);
22775 + remove_wait_queue(&vxi->vx_wait, &wait);
22781 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22783 + struct vcmd_wait_exit_v0 vc_data;
22786 + ret = __wait_exit(vxi);
22787 + vc_data.reboot_cmd = vxi->reboot_cmd;
22788 + vc_data.exit_code = vxi->exit_code;
22790 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22795 diff -NurpP --minimal linux-2.6.36/kernel/vserver/space.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/space.c
22796 --- linux-2.6.36/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22797 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/space.c 2010-10-21 14:41:06.000000000 +0200
22800 + * linux/kernel/vserver/space.c
22802 + * Virtual Server: Context Space Support
22804 + * Copyright (C) 2003-2007 Herbert Pötzl
22806 + * V0.01 broken out from context.c 0.07
22807 + * V0.02 added task locking for namespace
22808 + * V0.03 broken out vx_enter_namespace
22809 + * V0.04 added *space support and commands
22813 +#include <linux/utsname.h>
22814 +#include <linux/nsproxy.h>
22815 +#include <linux/err.h>
22816 +#include <linux/fs_struct.h>
22817 +#include <asm/uaccess.h>
22819 +#include <linux/vs_context.h>
22820 +#include <linux/vserver/space.h>
22821 +#include <linux/vserver/space_cmd.h>
22823 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22824 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22825 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22826 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22827 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22828 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22831 +/* namespace functions */
22833 +#include <linux/mnt_namespace.h>
22834 +#include <linux/user_namespace.h>
22835 +#include <linux/pid_namespace.h>
22836 +#include <linux/ipc_namespace.h>
22837 +#include <net/net_namespace.h>
22840 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22841 + .mask = CLONE_FS |
22849 +static const struct vcmd_space_mask_v1 space_mask = {
22850 + .mask = CLONE_FS |
22855 +#ifdef CONFIG_PID_NS
22858 +#ifdef CONFIG_NET_NS
22864 +static const struct vcmd_space_mask_v1 default_space_mask = {
22865 + .mask = CLONE_FS |
22870 +#ifdef CONFIG_PID_NS
22877 + * build a new nsproxy mix
22878 + * assumes that both proxies are 'const'
22879 + * does not touch nsproxy refcounts
22880 + * will hold a reference on the result.
22883 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22884 + struct nsproxy *new_nsproxy, unsigned long mask)
22886 + struct mnt_namespace *old_ns;
22887 + struct uts_namespace *old_uts;
22888 + struct ipc_namespace *old_ipc;
22889 +#ifdef CONFIG_PID_NS
22890 + struct pid_namespace *old_pid;
22892 +#ifdef CONFIG_NET_NS
22893 + struct net *old_net;
22895 + struct nsproxy *nsproxy;
22897 + nsproxy = copy_nsproxy(old_nsproxy);
22901 + if (mask & CLONE_NEWNS) {
22902 + old_ns = nsproxy->mnt_ns;
22903 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22904 + if (nsproxy->mnt_ns)
22905 + get_mnt_ns(nsproxy->mnt_ns);
22909 + if (mask & CLONE_NEWUTS) {
22910 + old_uts = nsproxy->uts_ns;
22911 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22912 + if (nsproxy->uts_ns)
22913 + get_uts_ns(nsproxy->uts_ns);
22917 + if (mask & CLONE_NEWIPC) {
22918 + old_ipc = nsproxy->ipc_ns;
22919 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22920 + if (nsproxy->ipc_ns)
22921 + get_ipc_ns(nsproxy->ipc_ns);
22925 +#ifdef CONFIG_PID_NS
22926 + if (mask & CLONE_NEWPID) {
22927 + old_pid = nsproxy->pid_ns;
22928 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22929 + if (nsproxy->pid_ns)
22930 + get_pid_ns(nsproxy->pid_ns);
22934 +#ifdef CONFIG_NET_NS
22935 + if (mask & CLONE_NEWNET) {
22936 + old_net = nsproxy->net_ns;
22937 + nsproxy->net_ns = new_nsproxy->net_ns;
22938 + if (nsproxy->net_ns)
22939 + get_net(nsproxy->net_ns);
22944 + put_mnt_ns(old_ns);
22946 + put_uts_ns(old_uts);
22948 + put_ipc_ns(old_ipc);
22949 +#ifdef CONFIG_PID_NS
22951 + put_pid_ns(old_pid);
22953 +#ifdef CONFIG_NET_NS
22955 + put_net(old_net);
22963 + * merge two nsproxy structs into a new one.
22964 + * will hold a reference on the result.
22968 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22969 + struct nsproxy *proxy, unsigned long mask)
22971 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22977 + /* vs_mix_nsproxy returns with reference */
22978 + return vs_mix_nsproxy(old ? old : &null_proxy,
22981 + get_nsproxy(proxy);
22986 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22988 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22989 + struct fs_struct *fs_cur, *fs = NULL;
22990 + int ret, kill = 0;
22992 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22993 + vxi, vxi->vx_id, mask, index);
22995 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22999 + mask = vxi->vx_nsmask[index];
23001 + if ((mask & vxi->vx_nsmask[index]) != mask)
23004 + if (mask & CLONE_FS) {
23005 + fs = copy_fs_struct(vxi->vx_fs[index]);
23009 + proxy = vxi->vx_nsproxy[index];
23011 + vxdprintk(VXD_CBIT(space, 9),
23012 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
23013 + vxi, vxi->vx_id, mask, index, proxy, fs);
23015 + task_lock(current);
23016 + fs_cur = current->fs;
23018 + if (mask & CLONE_FS) {
23019 + spin_lock(&fs_cur->lock);
23020 + current->fs = fs;
23021 + kill = !--fs_cur->users;
23022 + spin_unlock(&fs_cur->lock);
23025 + proxy_cur = current->nsproxy;
23026 + get_nsproxy(proxy_cur);
23027 + task_unlock(current);
23030 + free_fs_struct(fs_cur);
23032 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
23033 + if (IS_ERR(proxy_new)) {
23034 + ret = PTR_ERR(proxy_new);
23038 + proxy_new = xchg(¤t->nsproxy, proxy_new);
23042 + put_nsproxy(proxy_new);
23045 + put_nsproxy(proxy_cur);
23050 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23052 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
23053 + struct fs_struct *fs_vxi, *fs;
23054 + int ret, kill = 0;
23056 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
23057 + vxi, vxi->vx_id, mask, index);
23060 + mask = default_space_mask.mask;
23062 + if ((mask & space_mask.mask) != mask)
23065 + proxy_vxi = vxi->vx_nsproxy[index];
23066 + fs_vxi = vxi->vx_fs[index];
23068 + if (mask & CLONE_FS) {
23069 + fs = copy_fs_struct(current->fs);
23074 + task_lock(current);
23076 + if (mask & CLONE_FS) {
23077 + spin_lock(&fs_vxi->lock);
23078 + vxi->vx_fs[index] = fs;
23079 + kill = !--fs_vxi->users;
23080 + spin_unlock(&fs_vxi->lock);
23083 + proxy_cur = current->nsproxy;
23084 + get_nsproxy(proxy_cur);
23085 + task_unlock(current);
23088 + free_fs_struct(fs_vxi);
23090 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
23091 + if (IS_ERR(proxy_new)) {
23092 + ret = PTR_ERR(proxy_new);
23096 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
23097 + vxi->vx_nsmask[index] |= mask;
23101 + put_nsproxy(proxy_new);
23104 + put_nsproxy(proxy_cur);
23109 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
23111 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23113 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23116 + return vx_enter_space(vxi, vc_data.mask, 0);
23119 +int vc_enter_space(struct vx_info *vxi, void __user *data)
23121 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23123 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23126 + if (vc_data.index >= VX_SPACES)
23129 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
23132 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
23134 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23136 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23139 + return vx_set_space(vxi, vc_data.mask, 0);
23142 +int vc_set_space(struct vx_info *vxi, void __user *data)
23144 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23146 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23149 + if (vc_data.index >= VX_SPACES)
23152 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
23155 +int vc_get_space_mask(void __user *data, int type)
23157 + const struct vcmd_space_mask_v1 *mask;
23160 + mask = &space_mask_v0;
23161 + else if (type == 1)
23162 + mask = &space_mask;
23164 + mask = &default_space_mask;
23166 + vxdprintk(VXD_CBIT(space, 10),
23167 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
23169 + if (copy_to_user(data, mask, sizeof(*mask)))
23174 diff -NurpP --minimal linux-2.6.36/kernel/vserver/switch.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/switch.c
23175 --- linux-2.6.36/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
23176 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/switch.c 2010-10-28 19:10:47.000000000 +0200
23179 + * linux/kernel/vserver/switch.c
23181 + * Virtual Server: Syscall Switch
23183 + * Copyright (C) 2003-2007 Herbert Pötzl
23185 + * V0.01 syscall switch
23186 + * V0.02 added signal to context
23187 + * V0.03 added rlimit functions
23188 + * V0.04 added iattr, task/xid functions
23189 + * V0.05 added debug/history stuff
23190 + * V0.06 added compat32 layer
23191 + * V0.07 vcmd args and perms
23192 + * V0.08 added status commands
23193 + * V0.09 added tag commands
23194 + * V0.10 added oom bias
23195 + * V0.11 added device commands
23199 +#include <linux/vs_context.h>
23200 +#include <linux/vs_network.h>
23201 +#include <linux/vserver/switch.h>
23203 +#include "vci_config.h"
23207 +int vc_get_version(uint32_t id)
23209 + return VCI_VERSION;
23213 +int vc_get_vci(uint32_t id)
23215 + return vci_kernel_config();
23218 +#include <linux/vserver/context_cmd.h>
23219 +#include <linux/vserver/cvirt_cmd.h>
23220 +#include <linux/vserver/cacct_cmd.h>
23221 +#include <linux/vserver/limit_cmd.h>
23222 +#include <linux/vserver/network_cmd.h>
23223 +#include <linux/vserver/sched_cmd.h>
23224 +#include <linux/vserver/debug_cmd.h>
23225 +#include <linux/vserver/inode_cmd.h>
23226 +#include <linux/vserver/dlimit_cmd.h>
23227 +#include <linux/vserver/signal_cmd.h>
23228 +#include <linux/vserver/space_cmd.h>
23229 +#include <linux/vserver/tag_cmd.h>
23230 +#include <linux/vserver/device_cmd.h>
23232 +#include <linux/vserver/inode.h>
23233 +#include <linux/vserver/dlimit.h>
23236 +#ifdef CONFIG_COMPAT
23237 +#define __COMPAT(name, id, data, compat) \
23238 + (compat) ? name ## _x32(id, data) : name(id, data)
23239 +#define __COMPAT_NO_ID(name, data, compat) \
23240 + (compat) ? name ## _x32(data) : name(data)
23242 +#define __COMPAT(name, id, data, compat) \
23244 +#define __COMPAT_NO_ID(name, data, compat) \
23250 +long do_vcmd(uint32_t cmd, uint32_t id,
23251 + struct vx_info *vxi, struct nx_info *nxi,
23252 + void __user *data, int compat)
23256 + case VCMD_get_version:
23257 + return vc_get_version(id);
23258 + case VCMD_get_vci:
23259 + return vc_get_vci(id);
23261 + case VCMD_task_xid:
23262 + return vc_task_xid(id);
23263 + case VCMD_vx_info:
23264 + return vc_vx_info(vxi, data);
23266 + case VCMD_task_nid:
23267 + return vc_task_nid(id);
23268 + case VCMD_nx_info:
23269 + return vc_nx_info(nxi, data);
23271 + case VCMD_task_tag:
23272 + return vc_task_tag(id);
23274 + case VCMD_set_space_v1:
23275 + return vc_set_space_v1(vxi, data);
23276 + /* this is version 2 */
23277 + case VCMD_set_space:
23278 + return vc_set_space(vxi, data);
23280 + case VCMD_get_space_mask_v0:
23281 + return vc_get_space_mask(data, 0);
23282 + /* this is version 1 */
23283 + case VCMD_get_space_mask:
23284 + return vc_get_space_mask(data, 1);
23286 + case VCMD_get_space_default:
23287 + return vc_get_space_mask(data, -1);
23289 +#ifdef CONFIG_IA32_EMULATION
23290 + case VCMD_get_rlimit:
23291 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23292 + case VCMD_set_rlimit:
23293 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23295 + case VCMD_get_rlimit:
23296 + return vc_get_rlimit(vxi, data);
23297 + case VCMD_set_rlimit:
23298 + return vc_set_rlimit(vxi, data);
23300 + case VCMD_get_rlimit_mask:
23301 + return vc_get_rlimit_mask(id, data);
23302 + case VCMD_reset_hits:
23303 + return vc_reset_hits(vxi, data);
23304 + case VCMD_reset_minmax:
23305 + return vc_reset_minmax(vxi, data);
23307 + case VCMD_get_vhi_name:
23308 + return vc_get_vhi_name(vxi, data);
23309 + case VCMD_set_vhi_name:
23310 + return vc_set_vhi_name(vxi, data);
23312 + case VCMD_ctx_stat:
23313 + return vc_ctx_stat(vxi, data);
23314 + case VCMD_virt_stat:
23315 + return vc_virt_stat(vxi, data);
23316 + case VCMD_sock_stat:
23317 + return vc_sock_stat(vxi, data);
23318 + case VCMD_rlimit_stat:
23319 + return vc_rlimit_stat(vxi, data);
23321 + case VCMD_set_cflags:
23322 + return vc_set_cflags(vxi, data);
23323 + case VCMD_get_cflags:
23324 + return vc_get_cflags(vxi, data);
23326 + /* this is version 1 */
23327 + case VCMD_set_ccaps:
23328 + return vc_set_ccaps(vxi, data);
23329 + /* this is version 1 */
23330 + case VCMD_get_ccaps:
23331 + return vc_get_ccaps(vxi, data);
23332 + case VCMD_set_bcaps:
23333 + return vc_set_bcaps(vxi, data);
23334 + case VCMD_get_bcaps:
23335 + return vc_get_bcaps(vxi, data);
23337 + case VCMD_set_badness:
23338 + return vc_set_badness(vxi, data);
23339 + case VCMD_get_badness:
23340 + return vc_get_badness(vxi, data);
23342 + case VCMD_set_nflags:
23343 + return vc_set_nflags(nxi, data);
23344 + case VCMD_get_nflags:
23345 + return vc_get_nflags(nxi, data);
23347 + case VCMD_set_ncaps:
23348 + return vc_set_ncaps(nxi, data);
23349 + case VCMD_get_ncaps:
23350 + return vc_get_ncaps(nxi, data);
23352 + case VCMD_set_prio_bias:
23353 + return vc_set_prio_bias(vxi, data);
23354 + case VCMD_get_prio_bias:
23355 + return vc_get_prio_bias(vxi, data);
23356 + case VCMD_add_dlimit:
23357 + return __COMPAT(vc_add_dlimit, id, data, compat);
23358 + case VCMD_rem_dlimit:
23359 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23360 + case VCMD_set_dlimit:
23361 + return __COMPAT(vc_set_dlimit, id, data, compat);
23362 + case VCMD_get_dlimit:
23363 + return __COMPAT(vc_get_dlimit, id, data, compat);
23365 + case VCMD_ctx_kill:
23366 + return vc_ctx_kill(vxi, data);
23368 + case VCMD_wait_exit:
23369 + return vc_wait_exit(vxi, data);
23371 + case VCMD_get_iattr:
23372 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23373 + case VCMD_set_iattr:
23374 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23376 + case VCMD_fget_iattr:
23377 + return vc_fget_iattr(id, data);
23378 + case VCMD_fset_iattr:
23379 + return vc_fset_iattr(id, data);
23381 + case VCMD_enter_space_v0:
23382 + return vc_enter_space_v1(vxi, NULL);
23383 + case VCMD_enter_space_v1:
23384 + return vc_enter_space_v1(vxi, data);
23385 + /* this is version 2 */
23386 + case VCMD_enter_space:
23387 + return vc_enter_space(vxi, data);
23389 + case VCMD_ctx_create_v0:
23390 + return vc_ctx_create(id, NULL);
23391 + case VCMD_ctx_create:
23392 + return vc_ctx_create(id, data);
23393 + case VCMD_ctx_migrate_v0:
23394 + return vc_ctx_migrate(vxi, NULL);
23395 + case VCMD_ctx_migrate:
23396 + return vc_ctx_migrate(vxi, data);
23398 + case VCMD_net_create_v0:
23399 + return vc_net_create(id, NULL);
23400 + case VCMD_net_create:
23401 + return vc_net_create(id, data);
23402 + case VCMD_net_migrate:
23403 + return vc_net_migrate(nxi, data);
23405 + case VCMD_tag_migrate:
23406 + return vc_tag_migrate(id);
23408 + case VCMD_net_add:
23409 + return vc_net_add(nxi, data);
23410 + case VCMD_net_remove:
23411 + return vc_net_remove(nxi, data);
23413 + case VCMD_net_add_ipv4:
23414 + return vc_net_add_ipv4(nxi, data);
23415 + case VCMD_net_remove_ipv4:
23416 + return vc_net_remove_ipv4(nxi, data);
23417 +#ifdef CONFIG_IPV6
23418 + case VCMD_net_add_ipv6:
23419 + return vc_net_add_ipv6(nxi, data);
23420 + case VCMD_net_remove_ipv6:
23421 + return vc_net_remove_ipv6(nxi, data);
23423 +/* case VCMD_add_match_ipv4:
23424 + return vc_add_match_ipv4(nxi, data);
23425 + case VCMD_get_match_ipv4:
23426 + return vc_get_match_ipv4(nxi, data);
23427 +#ifdef CONFIG_IPV6
23428 + case VCMD_add_match_ipv6:
23429 + return vc_add_match_ipv6(nxi, data);
23430 + case VCMD_get_match_ipv6:
23431 + return vc_get_match_ipv6(nxi, data);
23434 +#ifdef CONFIG_VSERVER_DEVICE
23435 + case VCMD_set_mapping:
23436 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23437 + case VCMD_unset_mapping:
23438 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23440 +#ifdef CONFIG_VSERVER_HISTORY
23441 + case VCMD_dump_history:
23442 + return vc_dump_history(id);
23443 + case VCMD_read_history:
23444 + return __COMPAT(vc_read_history, id, data, compat);
23447 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23448 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23454 +#define __VCMD(vcmd, _perm, _args, _flags) \
23455 + case VCMD_ ## vcmd: perm = _perm; \
23456 + args = _args; flags = _flags; break
23459 +#define VCA_NONE 0x00
23460 +#define VCA_VXI 0x01
23461 +#define VCA_NXI 0x02
23463 +#define VCF_NONE 0x00
23464 +#define VCF_INFO 0x01
23465 +#define VCF_ADMIN 0x02
23466 +#define VCF_ARES 0x06 /* includes admin */
23467 +#define VCF_SETUP 0x08
23469 +#define VCF_ZIDOK 0x10 /* zero id okay */
23473 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23476 + int permit = -1, state = 0;
23477 + int perm = -1, args = 0, flags = 0;
23478 + struct vx_info *vxi = NULL;
23479 + struct nx_info *nxi = NULL;
23482 + /* unpriviledged commands */
23483 + __VCMD(get_version, 0, VCA_NONE, 0);
23484 + __VCMD(get_vci, 0, VCA_NONE, 0);
23485 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23486 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23487 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23488 + __VCMD(get_space_default,0, VCA_NONE, 0);
23490 + /* info commands */
23491 + __VCMD(task_xid, 2, VCA_NONE, 0);
23492 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23493 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23494 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23495 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23496 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23497 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23498 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23499 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23500 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23502 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23503 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23504 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23505 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23507 + __VCMD(task_nid, 2, VCA_NONE, 0);
23508 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23509 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23510 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23512 + __VCMD(task_tag, 2, VCA_NONE, 0);
23514 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23515 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23516 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23517 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23519 + /* lower admin commands */
23520 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23521 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23522 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23523 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23524 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23525 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23526 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23527 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23529 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23530 + __VCMD(net_create, 5, VCA_NONE, 0);
23531 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23533 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23535 + /* higher admin commands */
23536 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23537 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23538 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23540 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23541 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23542 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23543 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23545 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23546 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23547 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23549 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23550 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23551 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23552 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23553 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23554 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23555 +#ifdef CONFIG_IPV6
23556 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23557 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23559 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23560 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23561 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23562 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23563 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23565 +#ifdef CONFIG_VSERVER_DEVICE
23566 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23567 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23569 + /* debug level admin commands */
23570 +#ifdef CONFIG_VSERVER_HISTORY
23571 + __VCMD(dump_history, 9, VCA_NONE, 0);
23572 + __VCMD(read_history, 9, VCA_NONE, 0);
23579 + vxdprintk(VXD_CBIT(switch, 0),
23580 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23581 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23582 + VC_VERSION(cmd), id, data, compat,
23583 + perm, args, flags);
23590 + if (!capable(CAP_CONTEXT))
23594 + /* moved here from the individual commands */
23596 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23600 + /* vcmd involves resource management */
23602 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23606 + /* various legacy exceptions */
23608 + /* will go away when spectator is a cap */
23609 + case VCMD_ctx_migrate_v0:
23610 + case VCMD_ctx_migrate:
23612 + current->xid = 1;
23618 + /* will go away when spectator is a cap */
23619 + case VCMD_net_migrate:
23621 + current->nid = 1;
23628 + /* vcmds are fine by default */
23631 + /* admin type vcmds require admin ... */
23632 + if (flags & VCF_ADMIN)
23633 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23635 + /* ... but setup type vcmds override that */
23636 + if (!permit && (flags & VCF_SETUP))
23637 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23645 + if (!id && (flags & VCF_ZIDOK))
23649 + if (args & VCA_VXI) {
23650 + vxi = lookup_vx_info(id);
23654 + if ((flags & VCF_ADMIN) &&
23655 + /* special case kill for shutdown */
23656 + (cmd != VCMD_ctx_kill) &&
23657 + /* can context be administrated? */
23658 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23664 + if (args & VCA_NXI) {
23665 + nxi = lookup_nx_info(id);
23669 + if ((flags & VCF_ADMIN) &&
23670 + /* can context be administrated? */
23671 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23678 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23681 + if ((args & VCA_NXI) && nxi)
23682 + put_nx_info(nxi);
23684 + if ((args & VCA_VXI) && vxi)
23685 + put_vx_info(vxi);
23687 + vxdprintk(VXD_CBIT(switch, 1),
23688 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23689 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23690 + VC_VERSION(cmd), ret, ret, state, permit);
23695 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23697 + return do_vserver(cmd, id, data, 0);
23700 +#ifdef CONFIG_COMPAT
23703 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23705 + return do_vserver(cmd, id, data, 1);
23708 +#endif /* CONFIG_COMPAT */
23709 diff -NurpP --minimal linux-2.6.36/kernel/vserver/sysctl.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/sysctl.c
23710 --- linux-2.6.36/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23711 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/sysctl.c 2010-10-21 13:09:36.000000000 +0200
23714 + * kernel/vserver/sysctl.c
23716 + * Virtual Context Support
23718 + * Copyright (C) 2004-2007 Herbert Pötzl
23720 + * V0.01 basic structure
23724 +#include <linux/module.h>
23725 +#include <linux/ctype.h>
23726 +#include <linux/sysctl.h>
23727 +#include <linux/parser.h>
23728 +#include <asm/uaccess.h>
23731 + CTL_DEBUG_ERROR = 0,
23732 + CTL_DEBUG_SWITCH = 1,
23747 +unsigned int vx_debug_switch = 0;
23748 +unsigned int vx_debug_xid = 0;
23749 +unsigned int vx_debug_nid = 0;
23750 +unsigned int vx_debug_tag = 0;
23751 +unsigned int vx_debug_net = 0;
23752 +unsigned int vx_debug_limit = 0;
23753 +unsigned int vx_debug_cres = 0;
23754 +unsigned int vx_debug_dlim = 0;
23755 +unsigned int vx_debug_quota = 0;
23756 +unsigned int vx_debug_cvirt = 0;
23757 +unsigned int vx_debug_space = 0;
23758 +unsigned int vx_debug_misc = 0;
23761 +static struct ctl_table_header *vserver_table_header;
23762 +static ctl_table vserver_root_table[];
23765 +void vserver_register_sysctl(void)
23767 + if (!vserver_table_header) {
23768 + vserver_table_header = register_sysctl_table(vserver_root_table);
23773 +void vserver_unregister_sysctl(void)
23775 + if (vserver_table_header) {
23776 + unregister_sysctl_table(vserver_table_header);
23777 + vserver_table_header = NULL;
23782 +static int proc_dodebug(ctl_table *table, int write,
23783 + void __user *buffer, size_t *lenp, loff_t *ppos)
23785 + char tmpbuf[20], *p, c;
23786 + unsigned int value;
23787 + size_t left, len;
23789 + if ((*ppos && !write) || !*lenp) {
23797 + if (!access_ok(VERIFY_READ, buffer, left))
23799 + p = (char *)buffer;
23800 + while (left && __get_user(c, p) >= 0 && isspace(c))
23805 + if (left > sizeof(tmpbuf) - 1)
23807 + if (copy_from_user(tmpbuf, p, left))
23809 + tmpbuf[left] = '\0';
23811 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23812 + value = 10 * value + (*p - '0');
23813 + if (*p && !isspace(*p))
23815 + while (left && isspace(*p))
23817 + *(unsigned int *)table->data = value;
23819 + if (!access_ok(VERIFY_WRITE, buffer, left))
23821 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23824 + if (__copy_to_user(buffer, tmpbuf, len))
23826 + if ((left -= len) > 0) {
23827 + if (put_user('\n', (char *)buffer + len))
23841 +#define CTL_ENTRY(ctl, name) \
23843 + .procname = #name, \
23844 + .data = &vx_ ## name, \
23845 + .maxlen = sizeof(int), \
23847 + .proc_handler = &proc_dodebug, \
23848 + .extra1 = &zero, \
23849 + .extra2 = &zero, \
23852 +static ctl_table vserver_debug_table[] = {
23853 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23854 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23855 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23856 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23857 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23858 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23859 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23860 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23861 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23862 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23863 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23864 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23868 +static ctl_table vserver_root_table[] = {
23870 + .procname = "vserver",
23872 + .child = vserver_debug_table
23878 +static match_table_t tokens = {
23879 + { CTL_DEBUG_SWITCH, "switch=%x" },
23880 + { CTL_DEBUG_XID, "xid=%x" },
23881 + { CTL_DEBUG_NID, "nid=%x" },
23882 + { CTL_DEBUG_TAG, "tag=%x" },
23883 + { CTL_DEBUG_NET, "net=%x" },
23884 + { CTL_DEBUG_LIMIT, "limit=%x" },
23885 + { CTL_DEBUG_CRES, "cres=%x" },
23886 + { CTL_DEBUG_DLIM, "dlim=%x" },
23887 + { CTL_DEBUG_QUOTA, "quota=%x" },
23888 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23889 + { CTL_DEBUG_SPACE, "space=%x" },
23890 + { CTL_DEBUG_MISC, "misc=%x" },
23891 + { CTL_DEBUG_ERROR, NULL }
23894 +#define HANDLE_CASE(id, name, val) \
23895 + case CTL_DEBUG_ ## id: \
23896 + vx_debug_ ## name = val; \
23897 + printk("vs_debug_" #name "=0x%x\n", val); \
23901 +static int __init vs_debug_setup(char *str)
23906 + printk("vs_debug_setup(%s)\n", str);
23907 + while ((p = strsep(&str, ",")) != NULL) {
23908 + substring_t args[MAX_OPT_ARGS];
23909 + unsigned int value;
23914 + token = match_token(p, tokens, args);
23915 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23918 + HANDLE_CASE(SWITCH, switch, value);
23919 + HANDLE_CASE(XID, xid, value);
23920 + HANDLE_CASE(NID, nid, value);
23921 + HANDLE_CASE(TAG, tag, value);
23922 + HANDLE_CASE(NET, net, value);
23923 + HANDLE_CASE(LIMIT, limit, value);
23924 + HANDLE_CASE(CRES, cres, value);
23925 + HANDLE_CASE(DLIM, dlim, value);
23926 + HANDLE_CASE(QUOTA, quota, value);
23927 + HANDLE_CASE(CVIRT, cvirt, value);
23928 + HANDLE_CASE(SPACE, space, value);
23929 + HANDLE_CASE(MISC, misc, value);
23938 +__setup("vsdebug=", vs_debug_setup);
23942 +EXPORT_SYMBOL_GPL(vx_debug_switch);
23943 +EXPORT_SYMBOL_GPL(vx_debug_xid);
23944 +EXPORT_SYMBOL_GPL(vx_debug_nid);
23945 +EXPORT_SYMBOL_GPL(vx_debug_net);
23946 +EXPORT_SYMBOL_GPL(vx_debug_limit);
23947 +EXPORT_SYMBOL_GPL(vx_debug_cres);
23948 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
23949 +EXPORT_SYMBOL_GPL(vx_debug_quota);
23950 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
23951 +EXPORT_SYMBOL_GPL(vx_debug_space);
23952 +EXPORT_SYMBOL_GPL(vx_debug_misc);
23954 diff -NurpP --minimal linux-2.6.36/kernel/vserver/tag.c linux-2.6.36-vs2.3.0.36.38/kernel/vserver/tag.c
23955 --- linux-2.6.36/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
23956 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/tag.c 2010-10-21 13:09:36.000000000 +0200
23959 + * linux/kernel/vserver/tag.c
23961 + * Virtual Server: Shallow Tag Space
23963 + * Copyright (C) 2007 Herbert Pötzl
23965 + * V0.01 basic implementation
23969 +#include <linux/sched.h>
23970 +#include <linux/vserver/debug.h>
23971 +#include <linux/vs_pid.h>
23972 +#include <linux/vs_tag.h>
23974 +#include <linux/vserver/tag_cmd.h>
23977 +int dx_migrate_task(struct task_struct *p, tag_t tag)
23982 + vxdprintk(VXD_CBIT(tag, 5),
23983 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
23989 + vxdprintk(VXD_CBIT(tag, 5),
23990 + "moved task %p into [#%d]", p, tag);
23994 +/* vserver syscall commands below here */
23996 +/* taks xid and vx_info functions */
23999 +int vc_task_tag(uint32_t id)
24004 + struct task_struct *tsk;
24005 + read_lock(&tasklist_lock);
24006 + tsk = find_task_by_real_pid(id);
24007 + tag = (tsk) ? tsk->tag : -ESRCH;
24008 + read_unlock(&tasklist_lock);
24010 + tag = dx_current_tag();
24015 +int vc_tag_migrate(uint32_t tag)
24017 + return dx_migrate_task(current, tag & 0xFFFF);
24021 diff -NurpP --minimal linux-2.6.36/kernel/vserver/vci_config.h linux-2.6.36-vs2.3.0.36.38/kernel/vserver/vci_config.h
24022 --- linux-2.6.36/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
24023 +++ linux-2.6.36-vs2.3.0.36.38/kernel/vserver/vci_config.h 2010-10-28 20:45:52.000000000 +0200
24026 +/* interface version */
24028 +#define VCI_VERSION 0x00020307
24032 + VCI_KCBIT_NO_DYNAMIC = 0,
24034 + VCI_KCBIT_PROC_SECURE = 4,
24035 + VCI_KCBIT_HARDCPU = 5,
24036 + VCI_KCBIT_IDLELIMIT = 6,
24037 + VCI_KCBIT_IDLETIME = 7,
24039 + VCI_KCBIT_COWBL = 8,
24040 + VCI_KCBIT_FULLCOWBL = 9,
24041 + VCI_KCBIT_SPACES = 10,
24042 + VCI_KCBIT_NETV2 = 11,
24043 + VCI_KCBIT_MEMCG = 12,
24045 + VCI_KCBIT_DEBUG = 16,
24046 + VCI_KCBIT_HISTORY = 20,
24047 + VCI_KCBIT_TAGGED = 24,
24048 + VCI_KCBIT_PPTAG = 28,
24050 + VCI_KCBIT_MORE = 31,
24054 +static inline uint32_t vci_kernel_config(void)
24057 + (1 << VCI_KCBIT_NO_DYNAMIC) |
24059 + /* configured features */
24060 +#ifdef CONFIG_VSERVER_PROC_SECURE
24061 + (1 << VCI_KCBIT_PROC_SECURE) |
24063 +#ifdef CONFIG_VSERVER_IDLELIMIT
24064 + (1 << VCI_KCBIT_IDLELIMIT) |
24066 +#ifdef CONFIG_VSERVER_IDLETIME
24067 + (1 << VCI_KCBIT_IDLETIME) |
24069 +#ifdef CONFIG_VSERVER_COWBL
24070 + (1 << VCI_KCBIT_COWBL) |
24071 + (1 << VCI_KCBIT_FULLCOWBL) |
24073 + (1 << VCI_KCBIT_SPACES) |
24074 + (1 << VCI_KCBIT_NETV2) |
24075 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
24076 + (1 << VCI_KCBIT_MEMCG) |
24079 + /* debug options */
24080 +#ifdef CONFIG_VSERVER_DEBUG
24081 + (1 << VCI_KCBIT_DEBUG) |
24083 +#ifdef CONFIG_VSERVER_HISTORY
24084 + (1 << VCI_KCBIT_HISTORY) |
24087 + /* inode context tagging */
24088 +#if defined(CONFIG_TAGGING_NONE)
24089 + (0 << VCI_KCBIT_TAGGED) |
24090 +#elif defined(CONFIG_TAGGING_UID16)
24091 + (1 << VCI_KCBIT_TAGGED) |
24092 +#elif defined(CONFIG_TAGGING_GID16)
24093 + (2 << VCI_KCBIT_TAGGED) |
24094 +#elif defined(CONFIG_TAGGING_ID24)
24095 + (3 << VCI_KCBIT_TAGGED) |
24096 +#elif defined(CONFIG_TAGGING_INTERN)
24097 + (4 << VCI_KCBIT_TAGGED) |
24098 +#elif defined(CONFIG_TAGGING_RUNTIME)
24099 + (5 << VCI_KCBIT_TAGGED) |
24101 + (7 << VCI_KCBIT_TAGGED) |
24103 + (1 << VCI_KCBIT_PPTAG) |
24107 diff -NurpP --minimal linux-2.6.36/mm/filemap_xip.c linux-2.6.36-vs2.3.0.36.38/mm/filemap_xip.c
24108 --- linux-2.6.36/mm/filemap_xip.c 2010-07-07 18:31:58.000000000 +0200
24109 +++ linux-2.6.36-vs2.3.0.36.38/mm/filemap_xip.c 2010-10-21 13:09:36.000000000 +0200
24111 #include <linux/seqlock.h>
24112 #include <linux/mutex.h>
24113 #include <linux/gfp.h>
24114 +#include <linux/vs_memory.h>
24115 #include <asm/tlbflush.h>
24116 #include <asm/io.h>
24118 diff -NurpP --minimal linux-2.6.36/mm/fremap.c linux-2.6.36-vs2.3.0.36.38/mm/fremap.c
24119 --- linux-2.6.36/mm/fremap.c 2010-10-21 13:07:57.000000000 +0200
24120 +++ linux-2.6.36-vs2.3.0.36.38/mm/fremap.c 2010-10-21 13:09:36.000000000 +0200
24122 #include <linux/module.h>
24123 #include <linux/syscalls.h>
24124 #include <linux/mmu_notifier.h>
24125 +#include <linux/vs_memory.h>
24127 #include <asm/mmu_context.h>
24128 #include <asm/cacheflush.h>
24129 diff -NurpP --minimal linux-2.6.36/mm/hugetlb.c linux-2.6.36-vs2.3.0.36.38/mm/hugetlb.c
24130 --- linux-2.6.36/mm/hugetlb.c 2010-10-21 13:07:57.000000000 +0200
24131 +++ linux-2.6.36-vs2.3.0.36.38/mm/hugetlb.c 2010-10-21 13:09:36.000000000 +0200
24134 #include <linux/hugetlb.h>
24135 #include <linux/node.h>
24136 +#include <linux/vs_memory.h>
24137 #include "internal.h"
24139 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
24140 diff -NurpP --minimal linux-2.6.36/mm/memcontrol.c linux-2.6.36-vs2.3.0.36.38/mm/memcontrol.c
24141 --- linux-2.6.36/mm/memcontrol.c 2010-10-21 13:07:57.000000000 +0200
24142 +++ linux-2.6.36-vs2.3.0.36.38/mm/memcontrol.c 2010-10-28 19:36:06.000000000 +0200
24143 @@ -638,6 +638,31 @@ struct mem_cgroup *mem_cgroup_from_task(
24144 struct mem_cgroup, css);
24147 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
24149 + return res_counter_read_u64(&mem->res, member);
24152 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
24154 + return res_counter_read_u64(&mem->memsw, member);
24157 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
24159 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
24162 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
24164 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
24167 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
24169 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
24172 static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
24174 struct mem_cgroup *mem = NULL;
24175 diff -NurpP --minimal linux-2.6.36/mm/memory.c linux-2.6.36-vs2.3.0.36.38/mm/memory.c
24176 --- linux-2.6.36/mm/memory.c 2010-10-21 13:07:57.000000000 +0200
24177 +++ linux-2.6.36-vs2.3.0.36.38/mm/memory.c 2010-10-21 13:09:36.000000000 +0200
24178 @@ -3145,6 +3145,7 @@ static inline int handle_pte_fault(struc
24182 + int ret = 0, type = VXPT_UNKNOWN;
24185 if (!pte_present(entry)) {
24186 @@ -3169,9 +3170,12 @@ static inline int handle_pte_fault(struc
24187 if (unlikely(!pte_same(*pte, entry)))
24189 if (flags & FAULT_FLAG_WRITE) {
24190 - if (!pte_write(entry))
24191 - return do_wp_page(mm, vma, address,
24192 + if (!pte_write(entry)) {
24193 + ret = do_wp_page(mm, vma, address,
24194 pte, pmd, ptl, entry);
24195 + type = VXPT_WRITE;
24198 entry = pte_mkdirty(entry);
24200 entry = pte_mkyoung(entry);
24201 @@ -3189,7 +3193,10 @@ static inline int handle_pte_fault(struc
24204 pte_unmap_unlock(pte, ptl);
24208 + vx_page_fault(mm, vma, type, ret);
24213 diff -NurpP --minimal linux-2.6.36/mm/mremap.c linux-2.6.36-vs2.3.0.36.38/mm/mremap.c
24214 --- linux-2.6.36/mm/mremap.c 2010-07-07 18:31:58.000000000 +0200
24215 +++ linux-2.6.36-vs2.3.0.36.38/mm/mremap.c 2010-10-21 13:09:36.000000000 +0200
24217 #include <linux/security.h>
24218 #include <linux/syscalls.h>
24219 #include <linux/mmu_notifier.h>
24220 +#include <linux/vs_memory.h>
24222 #include <asm/uaccess.h>
24223 #include <asm/cacheflush.h>
24224 diff -NurpP --minimal linux-2.6.36/mm/oom_kill.c linux-2.6.36-vs2.3.0.36.38/mm/oom_kill.c
24225 --- linux-2.6.36/mm/oom_kill.c 2010-10-21 13:07:57.000000000 +0200
24226 +++ linux-2.6.36-vs2.3.0.36.38/mm/oom_kill.c 2010-10-28 19:36:06.000000000 +0200
24228 #include <linux/memcontrol.h>
24229 #include <linux/mempolicy.h>
24230 #include <linux/security.h>
24231 +#include <linux/reboot.h>
24232 +#include <linux/vs_memory.h>
24233 +#include <linux/vs_context.h>
24235 int sysctl_panic_on_oom;
24236 int sysctl_oom_kill_allocating_task;
24237 @@ -124,11 +127,18 @@ struct task_struct *find_lock_task_mm(st
24238 static bool oom_unkillable_task(struct task_struct *p,
24239 const struct mem_cgroup *mem, const nodemask_t *nodemask)
24241 - if (is_global_init(p))
24242 + unsigned xid = vx_current_xid();
24244 + /* skip the init task, global and per guest */
24245 + if (task_is_init(p))
24247 if (p->flags & PF_KTHREAD)
24250 + /* skip other guest and host processes if oom in guest */
24251 + if (xid && vx_task_xid(p) != xid)
24254 /* When mem_cgroup_out_of_memory() and p is not member of the group */
24255 if (mem && !task_in_mem_cgroup(p, mem))
24257 @@ -209,6 +219,18 @@ unsigned int oom_badness(struct task_str
24258 points += p->signal->oom_score_adj;
24261 + * add points for context badness and
24262 + * reduce badness for processes belonging to
24263 + * a different context
24266 + points += vx_badness(p, p->mm);
24268 + if ((vx_current_xid() > 1) &&
24269 + vx_current_xid() != vx_task_xid(p))
24273 * Never return 0 for an eligible task that may be killed since it's
24274 * possible that no single user task uses more than 0.1% of memory and
24275 * no single admin tasks uses more than 3.0%.
24276 @@ -407,8 +429,8 @@ static int oom_kill_task(struct task_str
24280 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24281 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
24282 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24283 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
24284 K(get_mm_counter(p->mm, MM_ANONPAGES)),
24285 K(get_mm_counter(p->mm, MM_FILEPAGES)));
24287 @@ -452,8 +474,8 @@ static int oom_kill_process(struct task_
24291 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
24292 - message, task_pid_nr(p), p->comm, points);
24293 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
24294 + message, task_pid_nr(p), p->xid, p->comm, points);
24298 @@ -542,6 +564,8 @@ int unregister_oom_notifier(struct notif
24300 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
24302 +long vs_oom_action(unsigned int);
24305 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
24306 * if a parallel OOM killing is already taking place that includes a zone in
24307 @@ -701,7 +725,12 @@ retry:
24309 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
24310 read_unlock(&tasklist_lock);
24311 - panic("Out of memory and no killable processes...\n");
24313 + /* avoid panic for guest OOM */
24314 + if (current->xid)
24315 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
24317 + panic("Out of memory and no killable processes...\n");
24320 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
24321 diff -NurpP --minimal linux-2.6.36/mm/page_alloc.c linux-2.6.36-vs2.3.0.36.38/mm/page_alloc.c
24322 --- linux-2.6.36/mm/page_alloc.c 2010-10-21 13:07:57.000000000 +0200
24323 +++ linux-2.6.36-vs2.3.0.36.38/mm/page_alloc.c 2010-10-21 13:09:36.000000000 +0200
24325 #include <linux/compaction.h>
24326 #include <trace/events/kmem.h>
24327 #include <linux/ftrace_event.h>
24328 +#include <linux/vs_base.h>
24329 +#include <linux/vs_limit.h>
24331 #include <asm/tlbflush.h>
24332 #include <asm/div64.h>
24333 @@ -2329,6 +2331,9 @@ void si_meminfo(struct sysinfo *val)
24334 val->totalhigh = totalhigh_pages;
24335 val->freehigh = nr_free_highpages();
24336 val->mem_unit = PAGE_SIZE;
24338 + if (vx_flags(VXF_VIRT_MEM, 0))
24339 + vx_vsi_meminfo(val);
24342 EXPORT_SYMBOL(si_meminfo);
24343 @@ -2349,6 +2354,9 @@ void si_meminfo_node(struct sysinfo *val
24346 val->mem_unit = PAGE_SIZE;
24348 + if (vx_flags(VXF_VIRT_MEM, 0))
24349 + vx_vsi_meminfo(val);
24353 diff -NurpP --minimal linux-2.6.36/mm/rmap.c linux-2.6.36-vs2.3.0.36.38/mm/rmap.c
24354 --- linux-2.6.36/mm/rmap.c 2010-10-21 13:07:57.000000000 +0200
24355 +++ linux-2.6.36-vs2.3.0.36.38/mm/rmap.c 2010-10-21 13:19:11.000000000 +0200
24357 #include <linux/mmu_notifier.h>
24358 #include <linux/migrate.h>
24359 #include <linux/hugetlb.h>
24360 +#include <linux/vs_memory.h>
24362 #include <asm/tlbflush.h>
24364 diff -NurpP --minimal linux-2.6.36/mm/shmem.c linux-2.6.36-vs2.3.0.36.38/mm/shmem.c
24365 --- linux-2.6.36/mm/shmem.c 2010-10-21 13:07:57.000000000 +0200
24366 +++ linux-2.6.36-vs2.3.0.36.38/mm/shmem.c 2010-10-21 13:09:36.000000000 +0200
24367 @@ -1815,7 +1815,7 @@ static int shmem_statfs(struct dentry *d
24369 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24371 - buf->f_type = TMPFS_MAGIC;
24372 + buf->f_type = TMPFS_SUPER_MAGIC;
24373 buf->f_bsize = PAGE_CACHE_SIZE;
24374 buf->f_namelen = NAME_MAX;
24375 if (sbinfo->max_blocks) {
24376 @@ -2377,7 +2377,7 @@ int shmem_fill_super(struct super_block
24377 sb->s_maxbytes = SHMEM_MAX_BYTES;
24378 sb->s_blocksize = PAGE_CACHE_SIZE;
24379 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24380 - sb->s_magic = TMPFS_MAGIC;
24381 + sb->s_magic = TMPFS_SUPER_MAGIC;
24382 sb->s_op = &shmem_ops;
24383 sb->s_time_gran = 1;
24384 #ifdef CONFIG_TMPFS_POSIX_ACL
24385 diff -NurpP --minimal linux-2.6.36/mm/slab.c linux-2.6.36-vs2.3.0.36.38/mm/slab.c
24386 --- linux-2.6.36/mm/slab.c 2010-10-21 13:07:57.000000000 +0200
24387 +++ linux-2.6.36-vs2.3.0.36.38/mm/slab.c 2010-10-21 13:09:36.000000000 +0200
24388 @@ -407,6 +407,8 @@ static void kmem_list3_init(struct kmem_
24389 #define STATS_INC_FREEMISS(x) do { } while (0)
24392 +#include "slab_vs.h"
24397 @@ -3346,6 +3348,7 @@ retry:
24399 obj = slab_get_obj(cachep, slabp, nodeid);
24400 check_slabp(cachep, slabp);
24401 + vx_slab_alloc(cachep, flags);
24402 l3->free_objects--;
24403 /* move slabp to correct slabp list: */
24404 list_del(&slabp->list);
24405 @@ -3423,6 +3426,7 @@ __cache_alloc_node(struct kmem_cache *ca
24406 /* ___cache_alloc_node can fall back to other nodes */
24407 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24409 + vx_slab_alloc(cachep, flags);
24410 local_irq_restore(save_flags);
24411 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24412 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24413 @@ -3609,6 +3613,7 @@ static inline void __cache_free(struct k
24415 kmemleak_free_recursive(objp, cachep->flags);
24416 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
24417 + vx_slab_free(cachep);
24419 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24421 diff -NurpP --minimal linux-2.6.36/mm/slab_vs.h linux-2.6.36-vs2.3.0.36.38/mm/slab_vs.h
24422 --- linux-2.6.36/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24423 +++ linux-2.6.36-vs2.3.0.36.38/mm/slab_vs.h 2010-10-21 13:09:36.000000000 +0200
24426 +#include <linux/vserver/context.h>
24428 +#include <linux/vs_context.h>
24431 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24433 + int what = gfp_zone(cachep->gfpflags);
24434 + struct vx_info *vxi = current_vx_info();
24439 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24443 +void vx_slab_free(struct kmem_cache *cachep)
24445 + int what = gfp_zone(cachep->gfpflags);
24446 + struct vx_info *vxi = current_vx_info();
24451 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24454 diff -NurpP --minimal linux-2.6.36/mm/swapfile.c linux-2.6.36-vs2.3.0.36.38/mm/swapfile.c
24455 --- linux-2.6.36/mm/swapfile.c 2010-10-21 13:07:57.000000000 +0200
24456 +++ linux-2.6.36-vs2.3.0.36.38/mm/swapfile.c 2010-10-21 13:09:36.000000000 +0200
24458 #include <asm/tlbflush.h>
24459 #include <linux/swapops.h>
24460 #include <linux/page_cgroup.h>
24461 +#include <linux/vs_base.h>
24462 +#include <linux/vs_memory.h>
24464 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24466 @@ -1747,6 +1749,16 @@ static int swap_show(struct seq_file *sw
24468 if (si == SEQ_START_TOKEN) {
24469 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24470 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24471 + struct sysinfo si;
24473 + vx_vsi_swapinfo(&si);
24474 + if (si.totalswap < (1 << 10))
24476 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24477 + "hdv0", "partition", si.totalswap >> 10,
24478 + (si.totalswap - si.freeswap) >> 10, -1);
24483 @@ -2131,6 +2143,8 @@ void si_swapinfo(struct sysinfo *val)
24484 val->freeswap = nr_swap_pages + nr_to_be_unused;
24485 val->totalswap = total_swap_pages + nr_to_be_unused;
24486 spin_unlock(&swap_lock);
24487 + if (vx_flags(VXF_VIRT_MEM, 0))
24488 + vx_vsi_swapinfo(val);
24492 diff -NurpP --minimal linux-2.6.36/net/core/dev.c linux-2.6.36-vs2.3.0.36.38/net/core/dev.c
24493 --- linux-2.6.36/net/core/dev.c 2010-10-21 13:07:58.000000000 +0200
24494 +++ linux-2.6.36-vs2.3.0.36.38/net/core/dev.c 2010-10-21 14:12:56.000000000 +0200
24495 @@ -127,6 +127,7 @@
24496 #include <linux/in.h>
24497 #include <linux/jhash.h>
24498 #include <linux/random.h>
24499 +#include <linux/vs_inet.h>
24500 #include <trace/events/napi.h>
24501 #include <linux/pci.h>
24503 @@ -607,7 +608,8 @@ struct net_device *__dev_get_by_name(str
24504 struct hlist_head *head = dev_name_hash(net, name);
24506 hlist_for_each_entry(dev, p, head, name_hlist)
24507 - if (!strncmp(dev->name, name, IFNAMSIZ))
24508 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24509 + nx_dev_visible(current_nx_info(), dev))
24513 @@ -633,7 +635,8 @@ struct net_device *dev_get_by_name_rcu(s
24514 struct hlist_head *head = dev_name_hash(net, name);
24516 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24517 - if (!strncmp(dev->name, name, IFNAMSIZ))
24518 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24519 + nx_dev_visible(current_nx_info(), dev))
24523 @@ -684,7 +687,8 @@ struct net_device *__dev_get_by_index(st
24524 struct hlist_head *head = dev_index_hash(net, ifindex);
24526 hlist_for_each_entry(dev, p, head, index_hlist)
24527 - if (dev->ifindex == ifindex)
24528 + if ((dev->ifindex == ifindex) &&
24529 + nx_dev_visible(current_nx_info(), dev))
24533 @@ -709,7 +713,8 @@ struct net_device *dev_get_by_index_rcu(
24534 struct hlist_head *head = dev_index_hash(net, ifindex);
24536 hlist_for_each_entry_rcu(dev, p, head, index_hlist)
24537 - if (dev->ifindex == ifindex)
24538 + if ((dev->ifindex == ifindex) &&
24539 + nx_dev_visible(current_nx_info(), dev))
24543 @@ -762,10 +767,12 @@ struct net_device *dev_getbyhwaddr(struc
24547 - for_each_netdev(net, dev)
24548 + for_each_netdev(net, dev) {
24549 if (dev->type == type &&
24550 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24551 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24552 + nx_dev_visible(current_nx_info(), dev))
24558 @@ -776,9 +783,11 @@ struct net_device *__dev_getfirstbyhwtyp
24559 struct net_device *dev;
24562 - for_each_netdev(net, dev)
24563 - if (dev->type == type)
24564 + for_each_netdev(net, dev) {
24565 + if ((dev->type == type) &&
24566 + nx_dev_visible(current_nx_info(), dev))
24572 @@ -896,6 +905,8 @@ static int __dev_alloc_name(struct net *
24574 if (i < 0 || i >= max_netdevices)
24576 + if (!nx_dev_visible(current_nx_info(), d))
24579 /* avoid cases where sscanf is not exact inverse of printf */
24580 snprintf(buf, IFNAMSIZ, name, i);
24581 @@ -3658,6 +3669,8 @@ static int dev_ifconf(struct net *net, c
24584 for_each_netdev(net, dev) {
24585 + if (!nx_dev_visible(current_nx_info(), dev))
24587 for (i = 0; i < NPROTO; i++) {
24588 if (gifconf_list[i]) {
24590 @@ -3729,6 +3742,10 @@ static void dev_seq_printf_stats(struct
24591 struct rtnl_link_stats64 temp;
24592 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24594 + /* device visible inside network context? */
24595 + if (!nx_dev_visible(current_nx_info(), dev))
24598 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24599 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24600 dev->name, stats->rx_bytes, stats->rx_packets,
24601 diff -NurpP --minimal linux-2.6.36/net/core/rtnetlink.c linux-2.6.36-vs2.3.0.36.38/net/core/rtnetlink.c
24602 --- linux-2.6.36/net/core/rtnetlink.c 2010-10-21 13:07:58.000000000 +0200
24603 +++ linux-2.6.36-vs2.3.0.36.38/net/core/rtnetlink.c 2010-10-21 13:09:36.000000000 +0200
24604 @@ -927,6 +927,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24605 hlist_for_each_entry(dev, node, head, index_hlist) {
24608 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24610 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24611 NETLINK_CB(cb->skb).pid,
24612 cb->nlh->nlmsg_seq, 0,
24613 @@ -1643,6 +1645,9 @@ void rtmsg_ifinfo(int type, struct net_d
24614 struct sk_buff *skb;
24615 int err = -ENOBUFS;
24617 + if (!nx_dev_visible(current_nx_info(), dev))
24620 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
24623 diff -NurpP --minimal linux-2.6.36/net/core/sock.c linux-2.6.36-vs2.3.0.36.38/net/core/sock.c
24624 --- linux-2.6.36/net/core/sock.c 2010-10-21 13:07:58.000000000 +0200
24625 +++ linux-2.6.36-vs2.3.0.36.38/net/core/sock.c 2010-10-21 13:09:36.000000000 +0200
24626 @@ -127,6 +127,10 @@
24627 #include <net/cls_cgroup.h>
24629 #include <linux/filter.h>
24630 +#include <linux/vs_socket.h>
24631 +#include <linux/vs_limit.h>
24632 +#include <linux/vs_context.h>
24633 +#include <linux/vs_network.h>
24636 #include <net/tcp.h>
24637 @@ -1046,6 +1050,8 @@ static struct sock *sk_prot_alloc(struct
24639 sk_tx_queue_clear(sk);
24641 + sock_vx_init(sk);
24642 + sock_nx_init(sk);
24646 @@ -1142,6 +1148,11 @@ static void __sk_free(struct sock *sk)
24647 put_cred(sk->sk_peer_cred);
24648 put_pid(sk->sk_peer_pid);
24649 put_net(sock_net(sk));
24651 + clr_vx_info(&sk->sk_vx_info);
24653 + clr_nx_info(&sk->sk_nx_info);
24655 sk_prot_free(sk->sk_prot_creator, sk);
24658 @@ -1189,6 +1200,8 @@ struct sock *sk_clone(const struct sock
24661 get_net(sock_net(newsk));
24662 + sock_vx_init(newsk);
24663 + sock_nx_init(newsk);
24664 sk_node_init(&newsk->sk_node);
24665 sock_lock_init(newsk);
24666 bh_lock_sock(newsk);
24667 @@ -1244,6 +1257,12 @@ struct sock *sk_clone(const struct sock
24669 atomic_set(&newsk->sk_refcnt, 2);
24671 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24672 + newsk->sk_xid = sk->sk_xid;
24673 + vx_sock_inc(newsk);
24674 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24675 + newsk->sk_nid = sk->sk_nid;
24678 * Increment the counter in the same struct proto as the master
24679 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24680 @@ -1986,6 +2005,12 @@ void sock_init_data(struct socket *sock,
24682 sk->sk_stamp = ktime_set(-1L, 0);
24684 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24685 + sk->sk_xid = vx_current_xid();
24687 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24688 + sk->sk_nid = nx_current_nid();
24691 * Before updating sk_refcnt, we must commit prior changes to memory
24692 * (Documentation/RCU/rculist_nulls.txt for details)
24693 diff -NurpP --minimal linux-2.6.36/net/ipv4/af_inet.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/af_inet.c
24694 --- linux-2.6.36/net/ipv4/af_inet.c 2010-10-21 13:07:58.000000000 +0200
24695 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/af_inet.c 2010-10-21 13:09:36.000000000 +0200
24696 @@ -116,6 +116,7 @@
24697 #ifdef CONFIG_IP_MROUTE
24698 #include <linux/mroute.h>
24700 +#include <linux/vs_limit.h>
24703 /* The inetsw table contains everything that inet_create needs to
24704 @@ -327,9 +328,13 @@ lookup_protocol:
24708 + if ((protocol == IPPROTO_ICMP) &&
24709 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24712 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24713 goto out_rcu_unlock;
24716 err = -EAFNOSUPPORT;
24717 if (!inet_netns_ok(net, protocol))
24718 goto out_rcu_unlock;
24719 @@ -453,6 +458,7 @@ int inet_bind(struct socket *sock, struc
24720 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24721 struct sock *sk = sock->sk;
24722 struct inet_sock *inet = inet_sk(sk);
24723 + struct nx_v4_sock_addr nsa;
24724 unsigned short snum;
24727 @@ -466,7 +472,11 @@ int inet_bind(struct socket *sock, struc
24728 if (addr_len < sizeof(struct sockaddr_in))
24731 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24732 + err = v4_map_sock_addr(inet, addr, &nsa);
24736 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24738 /* Not specified by any standard per-se, however it breaks too
24739 * many applications when removed. It is unfortunate since
24740 @@ -478,7 +488,7 @@ int inet_bind(struct socket *sock, struc
24741 err = -EADDRNOTAVAIL;
24742 if (!sysctl_ip_nonlocal_bind &&
24743 !(inet->freebind || inet->transparent) &&
24744 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24745 + nsa.saddr != htonl(INADDR_ANY) &&
24746 chk_addr_ret != RTN_LOCAL &&
24747 chk_addr_ret != RTN_MULTICAST &&
24748 chk_addr_ret != RTN_BROADCAST)
24749 @@ -503,7 +513,7 @@ int inet_bind(struct socket *sock, struc
24750 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24751 goto out_release_sock;
24753 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24754 + v4_set_sock_addr(inet, &nsa);
24755 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24756 inet->inet_saddr = 0; /* Use device */
24758 @@ -705,11 +715,13 @@ int inet_getname(struct socket *sock, st
24761 sin->sin_port = inet->inet_dport;
24762 - sin->sin_addr.s_addr = inet->inet_daddr;
24763 + sin->sin_addr.s_addr =
24764 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24766 __be32 addr = inet->inet_rcv_saddr;
24768 addr = inet->inet_saddr;
24769 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24770 sin->sin_port = inet->inet_sport;
24771 sin->sin_addr.s_addr = addr;
24773 diff -NurpP --minimal linux-2.6.36/net/ipv4/devinet.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/devinet.c
24774 --- linux-2.6.36/net/ipv4/devinet.c 2010-10-21 13:07:58.000000000 +0200
24775 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/devinet.c 2010-10-21 13:09:36.000000000 +0200
24776 @@ -417,6 +417,7 @@ struct in_device *inetdev_by_index(struc
24778 EXPORT_SYMBOL(inetdev_by_index);
24781 /* Called only from RTNL semaphored context. No locks. */
24783 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24784 @@ -659,6 +660,8 @@ int devinet_ioctl(struct net *net, unsig
24786 in_dev = __in_dev_get_rtnl(dev);
24788 + struct nx_info *nxi = current_nx_info();
24790 if (tryaddrmatch) {
24791 /* Matthias Andree */
24792 /* compare label and address (4.4BSD style) */
24793 @@ -667,6 +670,8 @@ int devinet_ioctl(struct net *net, unsig
24794 This is checked above. */
24795 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24796 ifap = &ifa->ifa_next) {
24797 + if (!nx_v4_ifa_visible(nxi, ifa))
24799 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24800 sin_orig.sin_addr.s_addr ==
24801 ifa->ifa_address) {
24802 @@ -679,9 +684,12 @@ int devinet_ioctl(struct net *net, unsig
24803 comparing just the label */
24805 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24806 - ifap = &ifa->ifa_next)
24807 + ifap = &ifa->ifa_next) {
24808 + if (!nx_v4_ifa_visible(nxi, ifa))
24810 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24816 @@ -833,6 +841,8 @@ static int inet_gifconf(struct net_devic
24819 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24820 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24823 done += sizeof(ifr);
24825 @@ -1182,6 +1192,7 @@ static int inet_dump_ifaddr(struct sk_bu
24826 struct net_device *dev;
24827 struct in_device *in_dev;
24828 struct in_ifaddr *ifa;
24829 + struct sock *sk = skb->sk;
24830 struct hlist_head *head;
24831 struct hlist_node *node;
24833 @@ -1204,6 +1215,8 @@ static int inet_dump_ifaddr(struct sk_bu
24835 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24836 ifa = ifa->ifa_next, ip_idx++) {
24837 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24839 if (ip_idx < s_ip_idx)
24841 if (inet_fill_ifaddr(skb, ifa,
24842 diff -NurpP --minimal linux-2.6.36/net/ipv4/fib_hash.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/fib_hash.c
24843 --- linux-2.6.36/net/ipv4/fib_hash.c 2010-07-07 18:31:59.000000000 +0200
24844 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/fib_hash.c 2010-10-21 13:09:36.000000000 +0200
24845 @@ -1017,7 +1017,7 @@ static int fib_seq_show(struct seq_file
24846 prefix = f->fn_key;
24847 mask = FZ_MASK(iter->zone);
24848 flags = fib_flag_trans(fa->fa_type, mask, fi);
24850 + if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
24852 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
24853 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
24854 diff -NurpP --minimal linux-2.6.36/net/ipv4/inet_connection_sock.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/inet_connection_sock.c
24855 --- linux-2.6.36/net/ipv4/inet_connection_sock.c 2010-10-21 13:07:58.000000000 +0200
24856 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/inet_connection_sock.c 2010-10-21 13:09:36.000000000 +0200
24857 @@ -52,10 +52,40 @@ void inet_get_local_port_range(int *low,
24859 EXPORT_SYMBOL(inet_get_local_port_range);
24861 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24863 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
24864 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
24866 + if (inet_v6_ipv6only(sk2))
24869 + if (sk1_rcv_saddr &&
24871 + sk1_rcv_saddr == sk2_rcv_saddr)
24874 + if (sk1_rcv_saddr &&
24875 + !sk2_rcv_saddr &&
24876 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24879 + if (sk2_rcv_saddr &&
24880 + !sk1_rcv_saddr &&
24881 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24884 + if (!sk1_rcv_saddr &&
24885 + !sk2_rcv_saddr &&
24886 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24892 int inet_csk_bind_conflict(const struct sock *sk,
24893 const struct inet_bind_bucket *tb)
24895 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
24897 struct hlist_node *node;
24898 int reuse = sk->sk_reuse;
24899 @@ -75,9 +105,7 @@ int inet_csk_bind_conflict(const struct
24900 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
24901 if (!reuse || !sk2->sk_reuse ||
24902 sk2->sk_state == TCP_LISTEN) {
24903 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
24904 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
24905 - sk2_rcv_saddr == sk_rcv_saddr)
24906 + if (ipv4_rcv_saddr_equal(sk, sk2))
24910 diff -NurpP --minimal linux-2.6.36/net/ipv4/inet_diag.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/inet_diag.c
24911 --- linux-2.6.36/net/ipv4/inet_diag.c 2010-07-07 18:31:59.000000000 +0200
24912 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/inet_diag.c 2010-10-21 13:09:36.000000000 +0200
24914 #include <linux/stddef.h>
24916 #include <linux/inet_diag.h>
24917 +#include <linux/vs_network.h>
24918 +#include <linux/vs_inet.h>
24920 static const struct inet_diag_handler **inet_diag_table;
24922 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
24924 r->id.idiag_sport = inet->inet_sport;
24925 r->id.idiag_dport = inet->inet_dport;
24926 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
24927 - r->id.idiag_dst[0] = inet->inet_daddr;
24928 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
24929 + inet->inet_rcv_saddr);
24930 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
24931 + inet->inet_daddr);
24933 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
24934 if (r->idiag_family == AF_INET6) {
24935 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
24936 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
24937 r->id.idiag_sport = tw->tw_sport;
24938 r->id.idiag_dport = tw->tw_dport;
24939 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
24940 - r->id.idiag_dst[0] = tw->tw_daddr;
24941 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
24942 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
24943 r->idiag_state = tw->tw_substate;
24944 r->idiag_timer = 3;
24945 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
24946 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
24949 if (req->idiag_family == AF_INET) {
24950 + /* TODO: lback */
24951 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
24952 req->id.idiag_dport, req->id.idiag_src[0],
24953 req->id.idiag_sport, req->id.idiag_if);
24954 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
24958 + /* TODO: lback */
24959 entry.saddr = &inet->inet_rcv_saddr;
24960 entry.daddr = &inet->inet_daddr;
24962 @@ -541,6 +547,7 @@ static int inet_twsk_diag_dump(struct in
24966 + /* TODO: lback */
24967 entry.saddr = &tw->tw_rcv_saddr;
24968 entry.daddr = &tw->tw_daddr;
24970 @@ -587,8 +594,8 @@ static int inet_diag_fill_req(struct sk_
24972 r->id.idiag_sport = inet->inet_sport;
24973 r->id.idiag_dport = ireq->rmt_port;
24974 - r->id.idiag_src[0] = ireq->loc_addr;
24975 - r->id.idiag_dst[0] = ireq->rmt_addr;
24976 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
24977 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
24978 r->idiag_expires = jiffies_to_msecs(tmo);
24979 r->idiag_rqueue = 0;
24980 r->idiag_wqueue = 0;
24981 @@ -658,6 +665,7 @@ static int inet_diag_dump_reqs(struct sk
24985 + /* TODO: lback */
24987 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
24988 (entry.family == AF_INET6) ?
24989 @@ -728,6 +736,8 @@ static int inet_diag_dump(struct sk_buff
24990 sk_nulls_for_each(sk, node, &ilb->head) {
24991 struct inet_sock *inet = inet_sk(sk);
24993 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24998 @@ -794,6 +804,8 @@ skip_listen_ht:
24999 sk_nulls_for_each(sk, node, &head->chain) {
25000 struct inet_sock *inet = inet_sk(sk);
25002 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25006 if (!(r->idiag_states & (1 << sk->sk_state)))
25007 @@ -818,6 +830,8 @@ next_normal:
25008 inet_twsk_for_each(tw, node,
25011 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25015 if (r->id.idiag_sport != tw->tw_sport &&
25016 diff -NurpP --minimal linux-2.6.36/net/ipv4/inet_hashtables.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/inet_hashtables.c
25017 --- linux-2.6.36/net/ipv4/inet_hashtables.c 2010-10-21 13:07:58.000000000 +0200
25018 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/inet_hashtables.c 2010-10-21 13:09:36.000000000 +0200
25021 #include <net/inet_connection_sock.h>
25022 #include <net/inet_hashtables.h>
25023 +#include <net/route.h>
25024 #include <net/ip.h>
25027 @@ -132,6 +133,11 @@ static inline int compute_score(struct s
25028 if (rcv_saddr != daddr)
25032 + /* block non nx_info ips */
25033 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25034 + daddr, NXA_MASK_BIND))
25037 if (sk->sk_bound_dev_if) {
25038 if (sk->sk_bound_dev_if != dif)
25039 @@ -149,7 +155,6 @@ static inline int compute_score(struct s
25040 * wildcarded during the search since they can never be otherwise.
25044 struct sock *__inet_lookup_listener(struct net *net,
25045 struct inet_hashinfo *hashinfo,
25046 const __be32 daddr, const unsigned short hnum,
25047 @@ -172,6 +177,7 @@ begin:
25053 * if the nulls value we got at the end of this lookup is
25054 * not the expected one, we must restart lookup.
25055 diff -NurpP --minimal linux-2.6.36/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/netfilter/nf_nat_helper.c
25056 --- linux-2.6.36/net/ipv4/netfilter/nf_nat_helper.c 2010-07-07 18:31:59.000000000 +0200
25057 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/netfilter/nf_nat_helper.c 2010-10-21 13:09:36.000000000 +0200
25059 #include <net/route.h>
25061 #include <linux/netfilter_ipv4.h>
25062 +#include <net/route.h>
25063 #include <net/netfilter/nf_conntrack.h>
25064 #include <net/netfilter/nf_conntrack_helper.h>
25065 #include <net/netfilter/nf_conntrack_ecache.h>
25066 diff -NurpP --minimal linux-2.6.36/net/ipv4/netfilter.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/netfilter.c
25067 --- linux-2.6.36/net/ipv4/netfilter.c 2010-10-21 13:07:58.000000000 +0200
25068 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/netfilter.c 2010-10-21 13:09:36.000000000 +0200
25070 #include <linux/ip.h>
25071 #include <linux/skbuff.h>
25072 #include <linux/gfp.h>
25073 -#include <net/route.h>
25074 +// #include <net/route.h>
25075 #include <net/xfrm.h>
25076 #include <net/ip.h>
25077 #include <net/netfilter/nf_queue.h>
25078 diff -NurpP --minimal linux-2.6.36/net/ipv4/raw.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/raw.c
25079 --- linux-2.6.36/net/ipv4/raw.c 2010-10-21 13:07:58.000000000 +0200
25080 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/raw.c 2010-10-21 13:09:36.000000000 +0200
25081 @@ -116,7 +116,7 @@ static struct sock *__raw_v4_lookup(stru
25083 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
25084 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
25085 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
25086 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
25087 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
25088 goto found; /* gotcha */
25090 @@ -383,6 +383,12 @@ static int raw_send_hdrinc(struct sock *
25091 icmp_out_count(net, ((struct icmphdr *)
25092 skb_transport_header(skb))->type);
25095 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
25096 + sk->sk_nx_info &&
25097 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
25100 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
25101 rt->dst.dev, dst_output);
25103 @@ -563,6 +569,13 @@ static int raw_sendmsg(struct kiocb *ioc
25106 security_sk_classify_flow(sk, &fl);
25107 + if (sk->sk_nx_info) {
25108 + err = ip_v4_find_src(sock_net(sk),
25109 + sk->sk_nx_info, &rt, &fl);
25114 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
25117 @@ -635,17 +648,19 @@ static int raw_bind(struct sock *sk, str
25119 struct inet_sock *inet = inet_sk(sk);
25120 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
25121 + struct nx_v4_sock_addr nsa = { 0 };
25125 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
25127 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25128 + v4_map_sock_addr(inet, addr, &nsa);
25129 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25130 ret = -EADDRNOTAVAIL;
25131 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
25132 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
25133 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
25135 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
25136 + v4_set_sock_addr(inet, &nsa);
25137 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25138 inet->inet_saddr = 0; /* Use device */
25140 @@ -697,7 +712,8 @@ static int raw_recvmsg(struct kiocb *ioc
25141 /* Copy the address. */
25143 sin->sin_family = AF_INET;
25144 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25145 + sin->sin_addr.s_addr =
25146 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
25148 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
25150 @@ -875,7 +891,8 @@ static struct sock *raw_get_first(struct
25151 struct hlist_node *node;
25153 sk_for_each(sk, node, &state->h->ht[state->bucket])
25154 - if (sock_net(sk) == seq_file_net(seq))
25155 + if ((sock_net(sk) == seq_file_net(seq)) &&
25156 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25160 @@ -891,7 +908,8 @@ static struct sock *raw_get_next(struct
25164 - } while (sk && sock_net(sk) != seq_file_net(seq));
25165 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
25166 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25168 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
25169 sk = sk_head(&state->h->ht[state->bucket]);
25170 @@ -950,7 +968,10 @@ static void raw_sock_seq_show(struct seq
25172 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
25173 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
25174 - i, src, srcp, dest, destp, sp->sk_state,
25176 + nx_map_sock_lback(current_nx_info(), src), srcp,
25177 + nx_map_sock_lback(current_nx_info(), dest), destp,
25179 sk_wmem_alloc_get(sp),
25180 sk_rmem_alloc_get(sp),
25181 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
25182 diff -NurpP --minimal linux-2.6.36/net/ipv4/tcp.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/tcp.c
25183 --- linux-2.6.36/net/ipv4/tcp.c 2010-10-21 13:07:58.000000000 +0200
25184 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/tcp.c 2010-10-21 13:09:36.000000000 +0200
25185 @@ -266,6 +266,7 @@
25186 #include <linux/crypto.h>
25187 #include <linux/time.h>
25188 #include <linux/slab.h>
25189 +#include <linux/in.h>
25191 #include <net/icmp.h>
25192 #include <net/tcp.h>
25193 diff -NurpP --minimal linux-2.6.36/net/ipv4/tcp_ipv4.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/tcp_ipv4.c
25194 --- linux-2.6.36/net/ipv4/tcp_ipv4.c 2010-10-21 13:07:58.000000000 +0200
25195 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/tcp_ipv4.c 2010-10-21 13:09:36.000000000 +0200
25196 @@ -2016,6 +2016,12 @@ static void *listening_get_next(struct s
25197 req = req->dl_next;
25200 + vxdprintk(VXD_CBIT(net, 6),
25201 + "sk,req: %p [#%d] (from %d)", req->sk,
25202 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
25204 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
25206 if (req->rsk_ops->family == st->family) {
25209 @@ -2041,6 +2047,10 @@ get_req:
25212 sk_nulls_for_each_from(sk, node) {
25213 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
25214 + sk, sk->sk_nid, nx_current_nid());
25215 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25217 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
25220 @@ -2115,6 +2125,11 @@ static void *established_get_first(struc
25222 spin_lock_bh(lock);
25223 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
25224 + vxdprintk(VXD_CBIT(net, 6),
25225 + "sk,egf: %p [#%d] (from %d)",
25226 + sk, sk->sk_nid, nx_current_nid());
25227 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25229 if (sk->sk_family != st->family ||
25230 !net_eq(sock_net(sk), net)) {
25232 @@ -2125,6 +2140,11 @@ static void *established_get_first(struc
25233 st->state = TCP_SEQ_STATE_TIME_WAIT;
25234 inet_twsk_for_each(tw, node,
25235 &tcp_hashinfo.ehash[st->bucket].twchain) {
25236 + vxdprintk(VXD_CBIT(net, 6),
25237 + "tw: %p [#%d] (from %d)",
25238 + tw, tw->tw_nid, nx_current_nid());
25239 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25241 if (tw->tw_family != st->family ||
25242 !net_eq(twsk_net(tw), net)) {
25244 @@ -2154,7 +2174,9 @@ static void *established_get_next(struct
25248 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
25249 + while (tw && (tw->tw_family != st->family ||
25250 + !net_eq(twsk_net(tw), net) ||
25251 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
25255 @@ -2178,6 +2200,11 @@ get_tw:
25256 sk = sk_nulls_next(sk);
25258 sk_nulls_for_each_from(sk, node) {
25259 + vxdprintk(VXD_CBIT(net, 6),
25260 + "sk,egn: %p [#%d] (from %d)",
25261 + sk, sk->sk_nid, nx_current_nid());
25262 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25264 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
25267 @@ -2387,9 +2414,9 @@ static void get_openreq4(struct sock *sk
25268 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25269 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
25272 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
25273 ntohs(inet_sk(sk)->inet_sport),
25275 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
25276 ntohs(ireq->rmt_port),
25278 0, 0, /* could print option size, but that is af dependent. */
25279 @@ -2441,7 +2468,10 @@ static void get_tcp4_sock(struct sock *s
25281 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
25282 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
25283 - i, src, srcp, dest, destp, sk->sk_state,
25285 + nx_map_sock_lback(current_nx_info(), src), srcp,
25286 + nx_map_sock_lback(current_nx_info(), dest), destp,
25288 tp->write_seq - tp->snd_una,
25291 @@ -2476,7 +2506,10 @@ static void get_timewait4_sock(struct in
25293 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25294 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
25295 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
25297 + nx_map_sock_lback(current_nx_info(), src), srcp,
25298 + nx_map_sock_lback(current_nx_info(), dest), destp,
25299 + tw->tw_substate, 0, 0,
25300 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
25301 atomic_read(&tw->tw_refcnt), tw, len);
25303 diff -NurpP --minimal linux-2.6.36/net/ipv4/tcp_minisocks.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/tcp_minisocks.c
25304 --- linux-2.6.36/net/ipv4/tcp_minisocks.c 2010-10-21 13:07:58.000000000 +0200
25305 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/tcp_minisocks.c 2010-10-21 13:09:36.000000000 +0200
25307 #include <linux/slab.h>
25308 #include <linux/sysctl.h>
25309 #include <linux/workqueue.h>
25310 +#include <linux/vs_limit.h>
25311 +#include <linux/vs_socket.h>
25312 +#include <linux/vs_context.h>
25313 #include <net/tcp.h>
25314 #include <net/inet_common.h>
25315 #include <net/xfrm.h>
25316 @@ -290,6 +293,11 @@ void tcp_time_wait(struct sock *sk, int
25317 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25318 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25320 + tw->tw_xid = sk->sk_xid;
25321 + tw->tw_vx_info = NULL;
25322 + tw->tw_nid = sk->sk_nid;
25323 + tw->tw_nx_info = NULL;
25325 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
25326 if (tw->tw_family == PF_INET6) {
25327 struct ipv6_pinfo *np = inet6_sk(sk);
25328 diff -NurpP --minimal linux-2.6.36/net/ipv4/udp.c linux-2.6.36-vs2.3.0.36.38/net/ipv4/udp.c
25329 --- linux-2.6.36/net/ipv4/udp.c 2010-10-21 13:07:59.000000000 +0200
25330 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv4/udp.c 2010-10-21 13:09:36.000000000 +0200
25331 @@ -296,14 +296,7 @@ fail:
25333 EXPORT_SYMBOL(udp_lib_get_port);
25335 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25337 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25339 - return (!ipv6_only_sock(sk2) &&
25340 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25341 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25343 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25345 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25347 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
25348 if (inet->inet_rcv_saddr != daddr)
25352 + /* block non nx_info ips */
25353 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25354 + daddr, NXA_MASK_BIND))
25357 if (inet->inet_daddr) {
25358 if (inet->inet_daddr != saddr)
25359 @@ -441,6 +439,7 @@ exact_match:
25364 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25365 * harder than this. -DaveM
25367 @@ -486,6 +485,11 @@ begin:
25368 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25369 score = compute_score(sk, net, saddr, hnum, sport,
25370 daddr, dport, dif);
25371 + /* FIXME: disabled?
25372 + if (score == 9) {
25376 if (score > badness) {
25379 @@ -499,6 +503,7 @@ begin:
25380 if (get_nulls_value(node) != slot)
25385 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
25387 @@ -508,6 +513,7 @@ begin:
25395 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
25396 udp_sk(s)->udp_port_hash != hnum ||
25397 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25398 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25399 - (inet->inet_rcv_saddr &&
25400 - inet->inet_rcv_saddr != loc_addr) ||
25401 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25402 ipv6_only_sock(s) ||
25403 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25405 @@ -900,8 +905,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
25406 { .sport = inet->inet_sport,
25407 .dport = dport } } };
25408 struct net *net = sock_net(sk);
25409 + struct nx_info *nxi = sk->sk_nx_info;
25411 security_sk_classify_flow(sk, &fl);
25412 + err = ip_v4_find_src(net, nxi, &rt, &fl);
25416 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
25418 if (err == -ENETUNREACH)
25419 @@ -1183,7 +1193,8 @@ try_again:
25421 sin->sin_family = AF_INET;
25422 sin->sin_port = udp_hdr(skb)->source;
25423 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25424 + sin->sin_addr.s_addr = nx_map_sock_lback(
25425 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25426 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25428 if (inet->cmsg_flags)
25429 @@ -1923,6 +1934,8 @@ static struct sock *udp_get_first(struct
25430 sk_nulls_for_each(sk, node, &hslot->head) {
25431 if (!net_eq(sock_net(sk), net))
25433 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25435 if (sk->sk_family == state->family)
25438 @@ -1940,7 +1953,9 @@ static struct sock *udp_get_next(struct
25441 sk = sk_nulls_next(sk);
25442 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25443 + } while (sk && (!net_eq(sock_net(sk), net) ||
25444 + sk->sk_family != state->family ||
25445 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25448 if (state->bucket <= state->udp_table->mask)
25449 @@ -2047,7 +2062,10 @@ static void udp4_format_sock(struct sock
25451 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
25452 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
25453 - bucket, src, srcp, dest, destp, sp->sk_state,
25455 + nx_map_sock_lback(current_nx_info(), src), srcp,
25456 + nx_map_sock_lback(current_nx_info(), dest), destp,
25458 sk_wmem_alloc_get(sp),
25459 sk_rmem_alloc_get(sp),
25460 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
25461 diff -NurpP --minimal linux-2.6.36/net/ipv6/Kconfig linux-2.6.36-vs2.3.0.36.38/net/ipv6/Kconfig
25462 --- linux-2.6.36/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
25463 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv6/Kconfig 2010-10-21 13:09:36.000000000 +0200
25466 # IPv6 as module will cause a CRASH if you try to unload it
25468 - tristate "The IPv6 protocol"
25470 + bool "The IPv6 protocol"
25473 This is complemental support for the IP version 6.
25474 You will still be able to do traditional IPv4 networking as well.
25475 diff -NurpP --minimal linux-2.6.36/net/ipv6/addrconf.c linux-2.6.36-vs2.3.0.36.38/net/ipv6/addrconf.c
25476 --- linux-2.6.36/net/ipv6/addrconf.c 2010-10-21 13:07:59.000000000 +0200
25477 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv6/addrconf.c 2010-10-21 13:09:36.000000000 +0200
25480 #include <linux/proc_fs.h>
25481 #include <linux/seq_file.h>
25482 +#include <linux/vs_network.h>
25483 +#include <linux/vs_inet6.h>
25485 /* Set to 3 to get tracing... */
25486 #define ACONF_DEBUG 2
25487 @@ -1119,7 +1121,7 @@ out:
25489 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25490 const struct in6_addr *daddr, unsigned int prefs,
25491 - struct in6_addr *saddr)
25492 + struct in6_addr *saddr, struct nx_info *nxi)
25494 struct ipv6_saddr_score scores[2],
25495 *score = &scores[0], *hiscore = &scores[1];
25496 @@ -1191,6 +1193,8 @@ int ipv6_dev_get_saddr(struct net *net,
25500 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25504 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25505 @@ -3077,7 +3081,10 @@ static void if6_seq_stop(struct seq_file
25506 static int if6_seq_show(struct seq_file *seq, void *v)
25508 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25509 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25511 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25512 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25513 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25515 ifp->idev->dev->ifindex,
25517 @@ -3585,6 +3592,11 @@ static int in6_dump_addrs(struct inet6_d
25518 struct ifacaddr6 *ifaca;
25520 int ip_idx = *p_ip_idx;
25521 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25523 + /* disable ipv6 on non v6 guests */
25524 + if (nxi && !nx_info_has_v6(nxi))
25527 read_lock_bh(&idev->lock);
25529 @@ -3595,6 +3607,8 @@ static int in6_dump_addrs(struct inet6_d
25530 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25531 if (++ip_idx < s_ip_idx)
25533 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25535 err = inet6_fill_ifaddr(skb, ifa,
25536 NETLINK_CB(cb->skb).pid,
25537 cb->nlh->nlmsg_seq,
25538 @@ -3611,6 +3625,8 @@ static int in6_dump_addrs(struct inet6_d
25539 ifmca = ifmca->next, ip_idx++) {
25540 if (ip_idx < s_ip_idx)
25542 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25544 err = inet6_fill_ifmcaddr(skb, ifmca,
25545 NETLINK_CB(cb->skb).pid,
25546 cb->nlh->nlmsg_seq,
25547 @@ -3626,6 +3642,8 @@ static int in6_dump_addrs(struct inet6_d
25548 ifaca = ifaca->aca_next, ip_idx++) {
25549 if (ip_idx < s_ip_idx)
25551 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25553 err = inet6_fill_ifacaddr(skb, ifaca,
25554 NETLINK_CB(cb->skb).pid,
25555 cb->nlh->nlmsg_seq,
25556 @@ -3973,6 +3991,11 @@ static int inet6_dump_ifinfo(struct sk_b
25557 struct inet6_dev *idev;
25558 struct hlist_head *head;
25559 struct hlist_node *node;
25560 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25562 + /* FIXME: maybe disable ipv6 on non v6 guests?
25563 + if (skb->sk && skb->sk->sk_vx_info)
25564 + return skb->len; */
25567 s_idx = cb->args[1];
25568 @@ -3984,6 +4007,8 @@ static int inet6_dump_ifinfo(struct sk_b
25569 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25572 + if (!v6_dev_in_nx_info(dev, nxi))
25574 idev = __in6_dev_get(dev);
25577 diff -NurpP --minimal linux-2.6.36/net/ipv6/af_inet6.c linux-2.6.36-vs2.3.0.36.38/net/ipv6/af_inet6.c
25578 --- linux-2.6.36/net/ipv6/af_inet6.c 2010-10-21 13:07:59.000000000 +0200
25579 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv6/af_inet6.c 2010-10-21 13:09:36.000000000 +0200
25581 #include <linux/netdevice.h>
25582 #include <linux/icmpv6.h>
25583 #include <linux/netfilter_ipv6.h>
25584 +#include <linux/vs_inet.h>
25585 +#include <linux/vs_inet6.h>
25587 #include <net/ip.h>
25588 #include <net/ipv6.h>
25589 @@ -160,9 +162,12 @@ lookup_protocol:
25593 + if ((protocol == IPPROTO_ICMPV6) &&
25594 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25596 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25597 goto out_rcu_unlock;
25600 sock->ops = answer->ops;
25601 answer_prot = answer->prot;
25602 answer_no_check = answer->no_check;
25603 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25604 struct inet_sock *inet = inet_sk(sk);
25605 struct ipv6_pinfo *np = inet6_sk(sk);
25606 struct net *net = sock_net(sk);
25607 + struct nx_v6_sock_addr nsa;
25609 unsigned short snum;
25611 @@ -272,6 +278,11 @@ int inet6_bind(struct socket *sock, stru
25613 if (addr_len < SIN6_LEN_RFC2133)
25616 + err = v6_map_sock_addr(inet, addr, &nsa);
25620 addr_type = ipv6_addr_type(&addr->sin6_addr);
25621 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25623 @@ -303,6 +314,7 @@ int inet6_bind(struct socket *sock, stru
25624 /* Reproduce AF_INET checks to make the bindings consitant */
25625 v4addr = addr->sin6_addr.s6_addr32[3];
25626 chk_addr_ret = inet_addr_type(net, v4addr);
25628 if (!sysctl_ip_nonlocal_bind &&
25629 !(inet->freebind || inet->transparent) &&
25630 v4addr != htonl(INADDR_ANY) &&
25631 @@ -312,6 +324,10 @@ int inet6_bind(struct socket *sock, stru
25632 err = -EADDRNOTAVAIL;
25635 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25636 + err = -EADDRNOTAVAIL;
25640 if (addr_type != IPV6_ADDR_ANY) {
25641 struct net_device *dev = NULL;
25642 @@ -338,6 +354,11 @@ int inet6_bind(struct socket *sock, stru
25646 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25647 + err = -EADDRNOTAVAIL;
25651 /* ipv4 addr of the socket is invalid. Only the
25652 * unspecified and mapped address have a v4 equivalent.
25654 @@ -353,6 +374,9 @@ int inet6_bind(struct socket *sock, stru
25658 + /* what's that for? */
25659 + v6_set_sock_addr(inet, &nsa);
25661 inet->inet_rcv_saddr = v4addr;
25662 inet->inet_saddr = v4addr;
25664 @@ -454,9 +478,11 @@ int inet6_getname(struct socket *sock, s
25666 sin->sin6_port = inet->inet_dport;
25667 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
25668 + /* FIXME: remap lback? */
25670 sin->sin6_flowinfo = np->flow_label;
25672 + /* FIXME: remap lback? */
25673 if (ipv6_addr_any(&np->rcv_saddr))
25674 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
25676 diff -NurpP --minimal linux-2.6.36/net/ipv6/fib6_rules.c linux-2.6.36-vs2.3.0.36.38/net/ipv6/fib6_rules.c
25677 --- linux-2.6.36/net/ipv6/fib6_rules.c 2010-10-21 13:07:59.000000000 +0200
25678 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv6/fib6_rules.c 2010-10-21 13:09:36.000000000 +0200
25679 @@ -89,7 +89,7 @@ static int fib6_rule_action(struct fib_r
25680 ip6_dst_idev(&rt->dst)->dev,
25682 rt6_flags2srcprefs(flags),
25686 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25688 diff -NurpP --minimal linux-2.6.36/net/ipv6/inet6_hashtables.c linux-2.6.36-vs2.3.0.36.38/net/ipv6/inet6_hashtables.c
25689 --- linux-2.6.36/net/ipv6/inet6_hashtables.c 2010-02-25 11:52:10.000000000 +0100
25690 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv6/inet6_hashtables.c 2010-10-21 13:09:36.000000000 +0200
25693 #include <linux/module.h>
25694 #include <linux/random.h>
25695 +#include <linux/vs_inet6.h>
25697 #include <net/inet_connection_sock.h>
25698 #include <net/inet_hashtables.h>
25699 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
25700 unsigned int slot = hash & hashinfo->ehash_mask;
25701 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25706 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25707 @@ -94,7 +94,7 @@ begin:
25715 if (get_nulls_value(node) != slot)
25716 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
25717 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25721 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25724 if (sk->sk_bound_dev_if) {
25725 if (sk->sk_bound_dev_if != dif)
25726 diff -NurpP --minimal linux-2.6.36/net/ipv6/ip6_output.c linux-2.6.36-vs2.3.0.36.38/net/ipv6/ip6_output.c
25727 --- linux-2.6.36/net/ipv6/ip6_output.c 2010-10-21 13:07:59.000000000 +0200
25728 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv6/ip6_output.c 2010-10-21 13:09:36.000000000 +0200
25729 @@ -938,7 +938,7 @@ static int ip6_dst_lookup_tail(struct so
25730 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
25732 sk ? inet6_sk(sk)->srcprefs : 0,
25734 + &fl->fl6_src, sk->sk_nx_info);
25736 goto out_err_release;
25738 diff -NurpP --minimal linux-2.6.36/net/ipv6/ndisc.c linux-2.6.36-vs2.3.0.36.38/net/ipv6/ndisc.c
25739 --- linux-2.6.36/net/ipv6/ndisc.c 2010-10-21 13:07:59.000000000 +0200
25740 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv6/ndisc.c 2010-10-21 13:09:36.000000000 +0200
25741 @@ -591,7 +591,7 @@ static void ndisc_send_na(struct net_dev
25743 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25744 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25746 + &tmpaddr, NULL /* FIXME: ? */ ))
25748 src_addr = &tmpaddr;
25750 diff -NurpP --minimal linux-2.6.36/net/ipv6/raw.c linux-2.6.36-vs2.3.0.36.38/net/ipv6/raw.c
25751 --- linux-2.6.36/net/ipv6/raw.c 2010-10-21 13:07:59.000000000 +0200
25752 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv6/raw.c 2010-10-21 13:09:36.000000000 +0200
25754 #include <linux/icmpv6.h>
25755 #include <linux/netfilter.h>
25756 #include <linux/netfilter_ipv6.h>
25757 +#include <linux/vs_inet6.h>
25758 #include <linux/skbuff.h>
25759 #include <asm/uaccess.h>
25760 #include <asm/ioctls.h>
25761 @@ -283,6 +284,13 @@ static int rawv6_bind(struct sock *sk, s
25765 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25766 + err = -EADDRNOTAVAIL;
25772 /* ipv4 addr of the socket is invalid. Only the
25773 * unspecified and mapped address have a v4 equivalent.
25775 diff -NurpP --minimal linux-2.6.36/net/ipv6/route.c linux-2.6.36-vs2.3.0.36.38/net/ipv6/route.c
25776 --- linux-2.6.36/net/ipv6/route.c 2010-10-21 13:07:59.000000000 +0200
25777 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv6/route.c 2010-10-21 13:09:36.000000000 +0200
25778 @@ -2272,7 +2272,8 @@ static int rt6_fill_node(struct net *net
25779 struct inet6_dev *idev = ip6_dst_idev(&rt->dst);
25780 struct in6_addr saddr_buf;
25781 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25782 - dst, 0, &saddr_buf) == 0)
25783 + dst, 0, &saddr_buf,
25784 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
25785 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
25788 diff -NurpP --minimal linux-2.6.36/net/ipv6/tcp_ipv6.c linux-2.6.36-vs2.3.0.36.38/net/ipv6/tcp_ipv6.c
25789 --- linux-2.6.36/net/ipv6/tcp_ipv6.c 2010-10-21 13:07:59.000000000 +0200
25790 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv6/tcp_ipv6.c 2010-10-21 13:09:36.000000000 +0200
25793 #include <linux/crypto.h>
25794 #include <linux/scatterlist.h>
25795 +#include <linux/vs_inet6.h>
25797 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25798 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25799 @@ -160,8 +161,15 @@ static int tcp_v6_connect(struct sock *s
25800 * connect() to INADDR_ANY means loopback (BSD'ism).
25803 - if(ipv6_addr_any(&usin->sin6_addr))
25804 - usin->sin6_addr.s6_addr[15] = 0x1;
25805 + if(ipv6_addr_any(&usin->sin6_addr)) {
25806 + struct nx_info *nxi = sk->sk_nx_info;
25808 + if (nxi && nx_info_has_v6(nxi))
25809 + /* FIXME: remap lback? */
25810 + usin->sin6_addr = nxi->v6.ip;
25812 + usin->sin6_addr.s6_addr[15] = 0x1;
25815 addr_type = ipv6_addr_type(&usin->sin6_addr);
25817 diff -NurpP --minimal linux-2.6.36/net/ipv6/udp.c linux-2.6.36-vs2.3.0.36.38/net/ipv6/udp.c
25818 --- linux-2.6.36/net/ipv6/udp.c 2010-10-21 13:07:59.000000000 +0200
25819 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv6/udp.c 2010-10-21 13:09:36.000000000 +0200
25820 @@ -48,13 +48,14 @@
25822 #include <linux/proc_fs.h>
25823 #include <linux/seq_file.h>
25824 +#include <linux/vs_inet6.h>
25825 #include "udp_impl.h"
25827 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25829 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25830 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25831 - __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
25832 + __be32 sk_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
25833 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
25834 int sk_ipv6only = ipv6_only_sock(sk);
25835 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25836 @@ -62,24 +63,49 @@ int ipv6_rcv_saddr_equal(const struct so
25837 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25839 /* if both are mapped, treat as IPv4 */
25840 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25841 - return (!sk2_ipv6only &&
25842 - (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25843 - sk1_rcv_saddr == sk2_rcv_saddr));
25844 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25845 + if (!sk2_ipv6only &&
25846 + (!sk_rcv_saddr || !sk2_rcv_saddr ||
25847 + sk_rcv_saddr == sk2_rcv_saddr))
25853 if (addr_type2 == IPV6_ADDR_ANY &&
25854 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25858 if (addr_type == IPV6_ADDR_ANY &&
25859 !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25863 if (sk2_rcv_saddr6 &&
25864 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25871 + if (!sk_rcv_saddr && !sk2_rcv_saddr)
25872 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
25873 + if (!sk2_rcv_saddr)
25874 + return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
25875 + if (!sk_rcv_saddr)
25876 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
25879 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25880 + return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
25881 + else if (addr_type2 == IPV6_ADDR_ANY)
25882 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
25883 + else if (addr_type == IPV6_ADDR_ANY) {
25884 + if (addr_type2 == IPV6_ADDR_MAPPED)
25885 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
25887 + return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
25892 static unsigned int udp6_portaddr_hash(struct net *net,
25893 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
25894 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25898 + /* block non nx_info ips */
25899 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25902 if (!ipv6_addr_any(&np->daddr)) {
25903 if (!ipv6_addr_equal(&np->daddr, saddr))
25904 diff -NurpP --minimal linux-2.6.36/net/ipv6/xfrm6_policy.c linux-2.6.36-vs2.3.0.36.38/net/ipv6/xfrm6_policy.c
25905 --- linux-2.6.36/net/ipv6/xfrm6_policy.c 2010-08-02 16:53:00.000000000 +0200
25906 +++ linux-2.6.36-vs2.3.0.36.38/net/ipv6/xfrm6_policy.c 2010-10-21 13:09:36.000000000 +0200
25907 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
25908 dev = ip6_dst_idev(dst)->dev;
25909 ipv6_dev_get_saddr(dev_net(dev), dev,
25910 (struct in6_addr *)&daddr->a6, 0,
25911 - (struct in6_addr *)&saddr->a6);
25912 + (struct in6_addr *)&saddr->a6, NULL);
25916 diff -NurpP --minimal linux-2.6.36/net/netlink/af_netlink.c linux-2.6.36-vs2.3.0.36.38/net/netlink/af_netlink.c
25917 --- linux-2.6.36/net/netlink/af_netlink.c 2010-10-21 13:08:01.000000000 +0200
25918 +++ linux-2.6.36-vs2.3.0.36.38/net/netlink/af_netlink.c 2010-10-21 13:09:36.000000000 +0200
25920 #include <linux/types.h>
25921 #include <linux/audit.h>
25922 #include <linux/mutex.h>
25923 +#include <linux/vs_context.h>
25924 +#include <linux/vs_network.h>
25925 +#include <linux/vs_limit.h>
25927 #include <net/net_namespace.h>
25928 #include <net/sock.h>
25929 @@ -1928,6 +1931,8 @@ static struct sock *netlink_seq_socket_i
25930 sk_for_each(s, node, &hash->table[j]) {
25931 if (sock_net(s) != seq_file_net(seq))
25933 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25937 iter->hash_idx = j;
25938 @@ -1962,7 +1967,8 @@ static void *netlink_seq_next(struct seq
25942 - } while (s && sock_net(s) != seq_file_net(seq));
25943 + } while (s && (sock_net(s) != seq_file_net(seq) ||
25944 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
25948 @@ -1974,7 +1980,8 @@ static void *netlink_seq_next(struct seq
25950 for (; j <= hash->mask; j++) {
25951 s = sk_head(&hash->table[j]);
25952 - while (s && sock_net(s) != seq_file_net(seq))
25953 + while (s && (sock_net(s) != seq_file_net(seq) ||
25954 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
25958 diff -NurpP --minimal linux-2.6.36/net/sctp/ipv6.c linux-2.6.36-vs2.3.0.36.38/net/sctp/ipv6.c
25959 --- linux-2.6.36/net/sctp/ipv6.c 2010-08-02 16:53:01.000000000 +0200
25960 +++ linux-2.6.36-vs2.3.0.36.38/net/sctp/ipv6.c 2010-10-21 13:09:36.000000000 +0200
25961 @@ -304,7 +304,8 @@ static void sctp_v6_get_saddr(struct sct
25962 dst ? ip6_dst_idev(dst)->dev : NULL,
25963 &daddr->v6.sin6_addr,
25964 inet6_sk(&sk->inet.sk)->srcprefs,
25965 - &saddr->v6.sin6_addr);
25966 + &saddr->v6.sin6_addr,
25967 + asoc->base.sk->sk_nx_info);
25968 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
25969 &saddr->v6.sin6_addr);
25971 diff -NurpP --minimal linux-2.6.36/net/socket.c linux-2.6.36-vs2.3.0.36.38/net/socket.c
25972 --- linux-2.6.36/net/socket.c 2010-10-21 13:08:01.000000000 +0200
25973 +++ linux-2.6.36-vs2.3.0.36.38/net/socket.c 2010-10-21 13:09:36.000000000 +0200
25976 #include <net/sock.h>
25977 #include <linux/netfilter.h>
25978 +#include <linux/vs_base.h>
25979 +#include <linux/vs_socket.h>
25980 +#include <linux/vs_inet.h>
25981 +#include <linux/vs_inet6.h>
25983 #include <linux/if_tun.h>
25984 #include <linux/ipv6_route.h>
25985 @@ -551,7 +555,7 @@ static inline int __sock_sendmsg(struct
25986 struct msghdr *msg, size_t size)
25988 struct sock_iocb *si = kiocb_to_siocb(iocb);
25992 sock_update_classid(sock->sk);
25994 @@ -564,7 +568,22 @@ static inline int __sock_sendmsg(struct
25998 - return sock->ops->sendmsg(iocb, sock, msg, size);
25999 + len = sock->ops->sendmsg(iocb, sock, msg, size);
26002 + vx_sock_send(sock->sk, size);
26004 + vx_sock_fail(sock->sk, size);
26006 + vxdprintk(VXD_CBIT(net, 7),
26007 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26009 + (sock->sk)?sock->sk->sk_nx_info:0,
26010 + (sock->sk)?sock->sk->sk_vx_info:0,
26011 + (sock->sk)?sock->sk->sk_xid:0,
26012 + (sock->sk)?sock->sk->sk_nid:0,
26013 + (unsigned int)size, len);
26017 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
26018 @@ -681,6 +700,7 @@ static inline int __sock_recvmsg_nosec(s
26019 struct msghdr *msg, size_t size, int flags)
26021 struct sock_iocb *si = kiocb_to_siocb(iocb);
26024 sock_update_classid(sock->sk);
26026 @@ -690,7 +710,18 @@ static inline int __sock_recvmsg_nosec(s
26030 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
26031 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
26032 + if ((len >= 0) && sock->sk)
26033 + vx_sock_recv(sock->sk, len);
26034 + vxdprintk(VXD_CBIT(net, 7),
26035 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26037 + (sock->sk)?sock->sk->sk_nx_info:0,
26038 + (sock->sk)?sock->sk->sk_vx_info:0,
26039 + (sock->sk)?sock->sk->sk_xid:0,
26040 + (sock->sk)?sock->sk->sk_nid:0,
26041 + (unsigned int)size, len);
26045 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
26046 @@ -1159,6 +1190,13 @@ static int __sock_create(struct net *net
26047 if (type < 0 || type >= SOCK_MAX)
26050 + if (!nx_check(0, VS_ADMIN)) {
26051 + if (family == PF_INET && !current_nx_info_has_v4())
26052 + return -EAFNOSUPPORT;
26053 + if (family == PF_INET6 && !current_nx_info_has_v6())
26054 + return -EAFNOSUPPORT;
26059 This uglymoron is moved from INET layer to here to avoid
26060 @@ -1293,6 +1331,7 @@ SYSCALL_DEFINE3(socket, int, family, int
26064 + set_bit(SOCK_USER_SOCKET, &sock->flags);
26065 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
26068 @@ -1334,10 +1373,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
26069 err = sock_create(family, type, protocol, &sock1);
26072 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
26074 err = sock_create(family, type, protocol, &sock2);
26076 goto out_release_1;
26077 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
26079 err = sock1->ops->socketpair(sock1, sock2);
26081 diff -NurpP --minimal linux-2.6.36/net/sunrpc/auth.c linux-2.6.36-vs2.3.0.36.38/net/sunrpc/auth.c
26082 --- linux-2.6.36/net/sunrpc/auth.c 2010-10-21 13:08:01.000000000 +0200
26083 +++ linux-2.6.36-vs2.3.0.36.38/net/sunrpc/auth.c 2010-10-21 13:09:36.000000000 +0200
26085 #include <linux/hash.h>
26086 #include <linux/sunrpc/clnt.h>
26087 #include <linux/spinlock.h>
26088 +#include <linux/vs_tag.h>
26091 # define RPCDBG_FACILITY RPCDBG_AUTH
26092 @@ -425,6 +426,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
26093 memset(&acred, 0, sizeof(acred));
26094 acred.uid = cred->fsuid;
26095 acred.gid = cred->fsgid;
26096 + acred.tag = dx_current_tag();
26097 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
26099 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
26100 @@ -465,6 +467,7 @@ rpcauth_bind_root_cred(struct rpc_task *
26101 struct auth_cred acred = {
26104 + .tag = dx_current_tag(),
26107 dprintk("RPC: %5u looking up %s cred\n",
26108 diff -NurpP --minimal linux-2.6.36/net/sunrpc/auth_unix.c linux-2.6.36-vs2.3.0.36.38/net/sunrpc/auth_unix.c
26109 --- linux-2.6.36/net/sunrpc/auth_unix.c 2010-10-21 13:08:01.000000000 +0200
26110 +++ linux-2.6.36-vs2.3.0.36.38/net/sunrpc/auth_unix.c 2010-10-21 13:09:36.000000000 +0200
26111 @@ -12,12 +12,14 @@
26112 #include <linux/module.h>
26113 #include <linux/sunrpc/clnt.h>
26114 #include <linux/sunrpc/auth.h>
26115 +#include <linux/vs_tag.h>
26117 #define NFS_NGROUPS 16
26120 struct rpc_cred uc_base;
26123 gid_t uc_gids[NFS_NGROUPS];
26125 #define uc_uid uc_base.cr_uid
26126 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
26127 groups = NFS_NGROUPS;
26129 cred->uc_gid = acred->gid;
26130 + cred->uc_tag = acred->tag;
26131 for (i = 0; i < groups; i++)
26132 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
26133 if (i < NFS_NGROUPS)
26134 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
26138 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
26139 + if (cred->uc_uid != acred->uid ||
26140 + cred->uc_gid != acred->gid ||
26141 + cred->uc_tag != acred->tag)
26144 if (acred->group_info != NULL)
26145 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
26146 struct rpc_clnt *clnt = task->tk_client;
26147 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
26148 __be32 *base, *hold;
26152 *p++ = htonl(RPC_AUTH_UNIX);
26154 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
26155 * Copy the UTS nodename captured when the client was created.
26157 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
26158 + tag = task->tk_client->cl_tag;
26160 - *p++ = htonl((u32) cred->uc_uid);
26161 - *p++ = htonl((u32) cred->uc_gid);
26162 + *p++ = htonl((u32) TAGINO_UID(tag,
26163 + cred->uc_uid, cred->uc_tag));
26164 + *p++ = htonl((u32) TAGINO_GID(tag,
26165 + cred->uc_gid, cred->uc_tag));
26167 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
26168 *p++ = htonl((u32) cred->uc_gids[i]);
26169 diff -NurpP --minimal linux-2.6.36/net/sunrpc/clnt.c linux-2.6.36-vs2.3.0.36.38/net/sunrpc/clnt.c
26170 --- linux-2.6.36/net/sunrpc/clnt.c 2010-10-21 13:08:01.000000000 +0200
26171 +++ linux-2.6.36-vs2.3.0.36.38/net/sunrpc/clnt.c 2010-10-21 13:09:36.000000000 +0200
26173 #include <linux/utsname.h>
26174 #include <linux/workqueue.h>
26175 #include <linux/in6.h>
26176 +#include <linux/vs_cvirt.h>
26178 #include <linux/sunrpc/clnt.h>
26179 #include <linux/sunrpc/rpc_pipe_fs.h>
26180 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
26181 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
26182 clnt->cl_chatty = 1;
26184 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
26185 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
26186 + clnt->cl_tag = 1; */
26189 EXPORT_SYMBOL_GPL(rpc_create);
26190 diff -NurpP --minimal linux-2.6.36/net/unix/af_unix.c linux-2.6.36-vs2.3.0.36.38/net/unix/af_unix.c
26191 --- linux-2.6.36/net/unix/af_unix.c 2010-10-21 13:08:01.000000000 +0200
26192 +++ linux-2.6.36-vs2.3.0.36.38/net/unix/af_unix.c 2010-10-21 13:09:36.000000000 +0200
26193 @@ -114,6 +114,8 @@
26194 #include <linux/mount.h>
26195 #include <net/checksum.h>
26196 #include <linux/security.h>
26197 +#include <linux/vs_context.h>
26198 +#include <linux/vs_limit.h>
26200 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
26201 static DEFINE_SPINLOCK(unix_table_lock);
26202 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
26203 if (!net_eq(sock_net(s), net))
26206 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26208 if (u->addr->len == len &&
26209 !memcmp(u->addr->name, sunname, len))
26211 @@ -2148,6 +2152,8 @@ static struct sock *unix_seq_idx(struct
26212 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
26213 if (sock_net(s) != seq_file_net(seq))
26215 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26220 @@ -2172,7 +2178,8 @@ static void *unix_seq_next(struct seq_fi
26221 sk = first_unix_socket(&iter->i);
26223 sk = next_unix_socket(&iter->i, sk);
26224 - while (sk && (sock_net(sk) != seq_file_net(seq)))
26225 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
26226 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
26227 sk = next_unix_socket(&iter->i, sk);
26230 diff -NurpP --minimal linux-2.6.36/scripts/checksyscalls.sh linux-2.6.36-vs2.3.0.36.38/scripts/checksyscalls.sh
26231 --- linux-2.6.36/scripts/checksyscalls.sh 2010-10-21 13:08:01.000000000 +0200
26232 +++ linux-2.6.36-vs2.3.0.36.38/scripts/checksyscalls.sh 2010-10-21 13:09:36.000000000 +0200
26233 @@ -193,7 +193,6 @@ cat << EOF
26234 #define __IGNORE_afs_syscall
26235 #define __IGNORE_getpmsg
26236 #define __IGNORE_putpmsg
26237 -#define __IGNORE_vserver
26241 diff -NurpP --minimal linux-2.6.36/security/commoncap.c linux-2.6.36-vs2.3.0.36.38/security/commoncap.c
26242 --- linux-2.6.36/security/commoncap.c 2010-10-21 13:08:02.000000000 +0200
26243 +++ linux-2.6.36-vs2.3.0.36.38/security/commoncap.c 2010-10-21 13:09:36.000000000 +0200
26245 #include <linux/prctl.h>
26246 #include <linux/securebits.h>
26247 #include <linux/syslog.h>
26248 +#include <linux/vs_context.h>
26251 * If a non-root user executes a setuid-root binary in
26252 @@ -53,7 +54,7 @@ static void warn_setuid_and_fcaps_mixed(
26254 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
26256 - NETLINK_CB(skb).eff_cap = current_cap();
26257 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
26261 @@ -63,6 +64,7 @@ int cap_netlink_recv(struct sk_buff *skb
26266 EXPORT_SYMBOL(cap_netlink_recv);
26269 @@ -83,7 +85,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
26270 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
26273 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
26274 + struct vx_info *vxi = tsk->vx_info;
26277 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
26278 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
26279 + cap_raised(tsk->cap_effective, cap),
26280 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
26283 + /* special case SETUP */
26284 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26285 + /* FIXME: maybe use cred instead? */
26286 + cap_raised(tsk->cred->cap_effective, cap))
26289 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26293 @@ -571,7 +588,7 @@ int cap_inode_setxattr(struct dentry *de
26295 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26296 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26297 - !capable(CAP_SYS_ADMIN))
26298 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26302 @@ -597,7 +614,7 @@ int cap_inode_removexattr(struct dentry
26304 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26305 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26306 - !capable(CAP_SYS_ADMIN))
26307 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26311 @@ -899,7 +916,8 @@ int cap_syslog(int type, bool from_file)
26312 if (type != SYSLOG_ACTION_OPEN && from_file)
26314 if ((type != SYSLOG_ACTION_READ_ALL &&
26315 - type != SYSLOG_ACTION_SIZE_BUFFER) && !capable(CAP_SYS_ADMIN))
26316 + type != SYSLOG_ACTION_SIZE_BUFFER) &&
26317 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
26321 @@ -951,3 +969,4 @@ int cap_file_mmap(struct file *file, uns
26326 diff -NurpP --minimal linux-2.6.36/security/selinux/hooks.c linux-2.6.36-vs2.3.0.36.38/security/selinux/hooks.c
26327 --- linux-2.6.36/security/selinux/hooks.c 2010-10-21 13:08:02.000000000 +0200
26328 +++ linux-2.6.36-vs2.3.0.36.38/security/selinux/hooks.c 2010-10-21 13:09:36.000000000 +0200
26330 #include <linux/dccp.h>
26331 #include <linux/quota.h>
26332 #include <linux/un.h> /* for Unix socket types */
26333 -#include <net/af_unix.h> /* for Unix socket types */
26334 #include <linux/parser.h>
26335 #include <linux/nfs_mount.h>
26336 #include <net/ipv6.h>