1 diff -NurpP --minimal linux-2.6.38.1/Documentation/vserver/debug.txt linux-2.6.38.1-vs2.3.0.37-rc9/Documentation/vserver/debug.txt
2 --- linux-2.6.38.1/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.38.1-vs2.3.0.37-rc9/Documentation/vserver/debug.txt 2011-01-29 02:01:07.000000000 +0100
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.38.1/arch/alpha/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/alpha/Kconfig
160 --- linux-2.6.38.1/arch/alpha/Kconfig 2011-03-15 18:06:23.000000000 +0100
161 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/alpha/Kconfig 2011-03-10 17:21:19.000000000 +0100
162 @@ -668,6 +668,8 @@ config DUMMY_CONSOLE
166 +source "kernel/vserver/Kconfig"
168 source "security/Kconfig"
170 source "crypto/Kconfig"
171 diff -NurpP --minimal linux-2.6.38.1/arch/alpha/kernel/entry.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/alpha/kernel/entry.S
172 --- linux-2.6.38.1/arch/alpha/kernel/entry.S 2010-10-21 13:06:45.000000000 +0200
173 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/alpha/kernel/entry.S 2011-01-29 02:01:07.000000000 +0100
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.38.1/arch/alpha/kernel/ptrace.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/alpha/kernel/ptrace.c
207 --- linux-2.6.38.1/arch/alpha/kernel/ptrace.c 2011-01-05 21:48:40.000000000 +0100
208 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/alpha/kernel/ptrace.c 2011-01-29 02:01:07.000000000 +0100
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.38.1/arch/alpha/kernel/systbls.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/alpha/kernel/systbls.S
218 --- linux-2.6.38.1/arch/alpha/kernel/systbls.S 2010-10-21 13:06:46.000000000 +0200
219 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/alpha/kernel/systbls.S 2011-01-29 02:01:07.000000000 +0100
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.38.1/arch/alpha/kernel/traps.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/alpha/kernel/traps.c
230 --- linux-2.6.38.1/arch/alpha/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
231 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/alpha/kernel/traps.c 2011-01-29 02:01:07.000000000 +0100
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.38.1/arch/arm/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/arm/Kconfig
243 --- linux-2.6.38.1/arch/arm/Kconfig 2011-03-15 18:06:23.000000000 +0100
244 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/arm/Kconfig 2011-03-07 16:53:25.000000000 +0100
245 @@ -1934,6 +1934,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.38.1/arch/arm/kernel/calls.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/arm/kernel/calls.S
255 --- linux-2.6.38.1/arch/arm/kernel/calls.S 2010-10-21 13:06:46.000000000 +0200
256 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/arm/kernel/calls.S 2011-01-29 02:01:07.000000000 +0100
258 /* 310 */ CALL(sys_request_key)
260 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
261 -/* vserver */ CALL(sys_ni_syscall)
264 /* 315 */ CALL(sys_ioprio_get)
265 CALL(sys_inotify_init)
266 diff -NurpP --minimal linux-2.6.38.1/arch/arm/kernel/process.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/arm/kernel/process.c
267 --- linux-2.6.38.1/arch/arm/kernel/process.c 2011-03-15 18:06:25.000000000 +0100
268 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/arm/kernel/process.c 2011-01-29 02:01:07.000000000 +0100
269 @@ -315,7 +315,8 @@ void __show_regs(struct pt_regs *regs)
270 void show_regs(struct pt_regs * regs)
273 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
274 + printk("Pid: %d[#%u], comm: %20s\n",
275 + task_pid_nr(current), current->xid, current->comm);
279 diff -NurpP --minimal linux-2.6.38.1/arch/arm/kernel/traps.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/arm/kernel/traps.c
280 --- linux-2.6.38.1/arch/arm/kernel/traps.c 2011-03-15 18:06:25.000000000 +0100
281 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/arm/kernel/traps.c 2011-01-29 02:01:07.000000000 +0100
282 @@ -243,8 +243,8 @@ static int __die(const char *str, int er
286 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
287 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
288 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
289 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
291 if (!user_mode(regs) || in_interrupt()) {
292 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
293 diff -NurpP --minimal linux-2.6.38.1/arch/cris/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/cris/Kconfig
294 --- linux-2.6.38.1/arch/cris/Kconfig 2011-03-15 18:06:38.000000000 +0100
295 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/cris/Kconfig 2011-01-29 02:01:07.000000000 +0100
296 @@ -685,6 +685,8 @@ source "drivers/staging/Kconfig"
298 source "arch/cris/Kconfig.debug"
300 +source "kernel/vserver/Kconfig"
302 source "security/Kconfig"
304 source "crypto/Kconfig"
305 diff -NurpP --minimal linux-2.6.38.1/arch/frv/kernel/kernel_thread.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/frv/kernel/kernel_thread.S
306 --- linux-2.6.38.1/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
307 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/frv/kernel/kernel_thread.S 2011-01-29 02:01:07.000000000 +0100
308 @@ -37,7 +37,7 @@ kernel_thread:
310 # start by forking the current process, but with shared VM
311 setlos.p #__NR_clone,gr7 ; syscall number
312 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
313 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
314 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
316 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
317 diff -NurpP --minimal linux-2.6.38.1/arch/h8300/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/h8300/Kconfig
318 --- linux-2.6.38.1/arch/h8300/Kconfig 2011-03-15 18:06:38.000000000 +0100
319 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/h8300/Kconfig 2011-01-29 02:01:07.000000000 +0100
320 @@ -217,6 +217,8 @@ source "fs/Kconfig"
322 source "arch/h8300/Kconfig.debug"
324 +source "kernel/vserver/Kconfig"
326 source "security/Kconfig"
328 source "crypto/Kconfig"
329 diff -NurpP --minimal linux-2.6.38.1/arch/ia64/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/Kconfig
330 --- linux-2.6.38.1/arch/ia64/Kconfig 2011-03-15 18:06:38.000000000 +0100
331 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/Kconfig 2011-01-29 02:01:07.000000000 +0100
332 @@ -674,6 +674,8 @@ source "fs/Kconfig"
334 source "arch/ia64/Kconfig.debug"
336 +source "kernel/vserver/Kconfig"
338 source "security/Kconfig"
340 source "crypto/Kconfig"
341 diff -NurpP --minimal linux-2.6.38.1/arch/ia64/include/asm/tlb.h linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/include/asm/tlb.h
342 --- linux-2.6.38.1/arch/ia64/include/asm/tlb.h 2010-02-25 11:51:26.000000000 +0100
343 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/include/asm/tlb.h 2011-01-29 02:01:07.000000000 +0100
345 #include <linux/mm.h>
346 #include <linux/pagemap.h>
347 #include <linux/swap.h>
348 +#include <linux/vs_memory.h>
350 #include <asm/pgalloc.h>
351 #include <asm/processor.h>
352 diff -NurpP --minimal linux-2.6.38.1/arch/ia64/kernel/entry.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/kernel/entry.S
353 --- linux-2.6.38.1/arch/ia64/kernel/entry.S 2010-10-21 13:06:52.000000000 +0200
354 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/kernel/entry.S 2011-01-29 02:01:07.000000000 +0100
355 @@ -1714,7 +1714,7 @@ sys_call_table:
357 data8 sys_mq_getsetattr
359 - data8 sys_ni_syscall // reserved for vserver
361 data8 sys_waitid // 1270
363 data8 sys_request_key
364 diff -NurpP --minimal linux-2.6.38.1/arch/ia64/kernel/perfmon.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/kernel/perfmon.c
365 --- linux-2.6.38.1/arch/ia64/kernel/perfmon.c 2011-03-15 18:06:39.000000000 +0100
366 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/kernel/perfmon.c 2011-01-29 02:01:07.000000000 +0100
368 #include <linux/completion.h>
369 #include <linux/tracehook.h>
370 #include <linux/slab.h>
371 +#include <linux/vs_memory.h>
373 #include <asm/errno.h>
374 #include <asm/intrinsics.h>
375 diff -NurpP --minimal linux-2.6.38.1/arch/ia64/kernel/process.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/kernel/process.c
376 --- linux-2.6.38.1/arch/ia64/kernel/process.c 2011-03-15 18:06:39.000000000 +0100
377 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/kernel/process.c 2011-01-29 02:01:07.000000000 +0100
378 @@ -109,8 +109,8 @@ show_regs (struct pt_regs *regs)
379 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
382 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
383 - smp_processor_id(), current->comm);
384 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
385 + current->xid, smp_processor_id(), current->comm);
386 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
387 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
388 init_utsname()->release);
389 diff -NurpP --minimal linux-2.6.38.1/arch/ia64/kernel/ptrace.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/kernel/ptrace.c
390 --- linux-2.6.38.1/arch/ia64/kernel/ptrace.c 2011-01-05 21:48:59.000000000 +0100
391 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/kernel/ptrace.c 2011-01-29 02:01:07.000000000 +0100
393 #include <linux/regset.h>
394 #include <linux/elf.h>
395 #include <linux/tracehook.h>
396 +#include <linux/vs_base.h>
398 #include <asm/pgtable.h>
399 #include <asm/processor.h>
400 diff -NurpP --minimal linux-2.6.38.1/arch/ia64/kernel/traps.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/kernel/traps.c
401 --- linux-2.6.38.1/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
402 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/kernel/traps.c 2011-01-29 02:01:07.000000000 +0100
403 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
406 if (++die.lock_owner_depth < 3) {
407 - printk("%s[%d]: %s %ld [%d]\n",
408 - current->comm, task_pid_nr(current), str, err, ++die_counter);
409 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
410 + current->comm, task_pid_nr(current), current->xid,
411 + str, err, ++die_counter);
412 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
415 @@ -323,8 +324,9 @@ handle_fpu_swa (int fp_fault, struct pt_
416 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
417 last.time = current_jiffies + 5 * HZ;
419 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
420 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
421 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
422 + current->comm, task_pid_nr(current), current->xid,
423 + regs->cr_iip + ia64_psr(regs)->ri, isr);
427 diff -NurpP --minimal linux-2.6.38.1/arch/ia64/mm/fault.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/mm/fault.c
428 --- linux-2.6.38.1/arch/ia64/mm/fault.c 2010-08-02 16:52:04.000000000 +0200
429 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/ia64/mm/fault.c 2011-01-29 02:01:07.000000000 +0100
431 #include <linux/interrupt.h>
432 #include <linux/kprobes.h>
433 #include <linux/kdebug.h>
434 +#include <linux/vs_memory.h>
436 #include <asm/pgtable.h>
437 #include <asm/processor.h>
438 diff -NurpP --minimal linux-2.6.38.1/arch/m32r/kernel/traps.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/m32r/kernel/traps.c
439 --- linux-2.6.38.1/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
440 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/m32r/kernel/traps.c 2011-01-29 02:01:07.000000000 +0100
441 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
443 printk("SPI: %08lx\n", sp);
445 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
446 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
447 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
448 + current->comm, task_pid_nr(current), current->xid,
449 + 0xffff & i, 4096+(unsigned long)current);
452 * When in-kernel, we also print out the stack and code at the
453 diff -NurpP --minimal linux-2.6.38.1/arch/m68k/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/m68k/Kconfig
454 --- linux-2.6.38.1/arch/m68k/Kconfig 2011-01-05 21:49:00.000000000 +0100
455 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/m68k/Kconfig 2011-01-29 02:01:07.000000000 +0100
456 @@ -610,6 +610,8 @@ source "fs/Kconfig"
458 source "arch/m68k/Kconfig.debug"
460 +source "kernel/vserver/Kconfig"
462 source "security/Kconfig"
464 source "crypto/Kconfig"
465 diff -NurpP --minimal linux-2.6.38.1/arch/m68k/kernel/ptrace.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/m68k/kernel/ptrace.c
466 --- linux-2.6.38.1/arch/m68k/kernel/ptrace.c 2011-01-05 21:49:01.000000000 +0100
467 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/m68k/kernel/ptrace.c 2011-01-29 02:01:07.000000000 +0100
469 #include <linux/ptrace.h>
470 #include <linux/user.h>
471 #include <linux/signal.h>
472 +#include <linux/vs_base.h>
474 #include <asm/uaccess.h>
475 #include <asm/page.h>
476 @@ -255,6 +256,8 @@ long arch_ptrace(struct task_struct *chi
477 ret = ptrace_request(child, request, addr, data);
480 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
485 diff -NurpP --minimal linux-2.6.38.1/arch/m68k/kernel/traps.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/m68k/kernel/traps.c
486 --- linux-2.6.38.1/arch/m68k/kernel/traps.c 2010-08-02 16:52:04.000000000 +0200
487 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/m68k/kernel/traps.c 2011-01-29 02:01:07.000000000 +0100
488 @@ -906,8 +906,8 @@ void show_registers(struct pt_regs *regs
489 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
490 regs->d4, regs->d5, regs->a0, regs->a1);
492 - printk("Process %s (pid: %d, task=%p)\n",
493 - current->comm, task_pid_nr(current), current);
494 + printk("Process %s (pid: %d[#%u], task=%p)\n",
495 + current->comm, task_pid_nr(current), current->xid, current);
496 addr = (unsigned long)&fp->un;
497 printk("Frame format=%X ", regs->format);
498 switch (regs->format) {
499 diff -NurpP --minimal linux-2.6.38.1/arch/m68knommu/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/m68knommu/Kconfig
500 --- linux-2.6.38.1/arch/m68knommu/Kconfig 2011-03-15 18:06:41.000000000 +0100
501 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/m68knommu/Kconfig 2011-01-29 02:01:07.000000000 +0100
502 @@ -801,6 +801,8 @@ source "fs/Kconfig"
504 source "arch/m68knommu/Kconfig.debug"
506 +source "kernel/vserver/Kconfig"
508 source "security/Kconfig"
510 source "crypto/Kconfig"
511 diff -NurpP --minimal linux-2.6.38.1/arch/m68knommu/kernel/traps.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/m68knommu/kernel/traps.c
512 --- linux-2.6.38.1/arch/m68knommu/kernel/traps.c 2011-01-05 21:49:01.000000000 +0100
513 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/m68knommu/kernel/traps.c 2011-01-29 02:01:07.000000000 +0100
514 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
515 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
516 fp->d4, fp->d5, fp->a0, fp->a1);
518 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
519 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
520 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
521 + current->comm, task_pid_nr(current), current->xid,
522 + PAGE_SIZE+(unsigned long)current);
523 show_stack(NULL, (unsigned long *)(fp + 1));
524 add_taint(TAINT_DIE);
526 diff -NurpP --minimal linux-2.6.38.1/arch/mips/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/Kconfig
527 --- linux-2.6.38.1/arch/mips/Kconfig 2011-03-15 18:06:42.000000000 +0100
528 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/Kconfig 2011-03-15 18:15:06.000000000 +0100
529 @@ -2418,6 +2418,8 @@ source "fs/Kconfig"
531 source "arch/mips/Kconfig.debug"
533 +source "kernel/vserver/Kconfig"
535 source "security/Kconfig"
537 source "crypto/Kconfig"
538 diff -NurpP --minimal linux-2.6.38.1/arch/mips/kernel/ptrace.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/kernel/ptrace.c
539 --- linux-2.6.38.1/arch/mips/kernel/ptrace.c 2011-01-05 21:49:06.000000000 +0100
540 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/kernel/ptrace.c 2011-01-29 02:01:07.000000000 +0100
542 #include <linux/security.h>
543 #include <linux/audit.h>
544 #include <linux/seccomp.h>
545 +#include <linux/vs_base.h>
547 #include <asm/byteorder.h>
549 @@ -263,6 +264,9 @@ long arch_ptrace(struct task_struct *chi
550 void __user *datavp = (void __user *) data;
551 unsigned long __user *datalp = (void __user *) data;
553 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
557 /* when I and D space are separate, these will need to be fixed. */
558 case PTRACE_PEEKTEXT: /* read word at location addr. */
559 diff -NurpP --minimal linux-2.6.38.1/arch/mips/kernel/scall32-o32.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/kernel/scall32-o32.S
560 --- linux-2.6.38.1/arch/mips/kernel/scall32-o32.S 2010-10-21 13:06:54.000000000 +0200
561 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/kernel/scall32-o32.S 2011-01-29 02:01:07.000000000 +0100
562 @@ -524,7 +524,7 @@ einval: li v0, -ENOSYS
563 sys sys_mq_timedreceive 5
564 sys sys_mq_notify 2 /* 4275 */
565 sys sys_mq_getsetattr 3
566 - sys sys_ni_syscall 0 /* sys_vserver */
569 sys sys_ni_syscall 0 /* available, was setaltroot */
570 sys sys_add_key 5 /* 4280 */
571 diff -NurpP --minimal linux-2.6.38.1/arch/mips/kernel/scall64-64.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/kernel/scall64-64.S
572 --- linux-2.6.38.1/arch/mips/kernel/scall64-64.S 2010-10-21 13:06:54.000000000 +0200
573 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/kernel/scall64-64.S 2011-01-29 02:01:07.000000000 +0100
574 @@ -363,7 +363,7 @@ sys_call_table:
575 PTR sys_mq_timedreceive
577 PTR sys_mq_getsetattr /* 5235 */
578 - PTR sys_ni_syscall /* sys_vserver */
581 PTR sys_ni_syscall /* available, was setaltroot */
583 diff -NurpP --minimal linux-2.6.38.1/arch/mips/kernel/scall64-n32.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/kernel/scall64-n32.S
584 --- linux-2.6.38.1/arch/mips/kernel/scall64-n32.S 2010-10-21 13:06:54.000000000 +0200
585 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/kernel/scall64-n32.S 2011-01-29 02:01:07.000000000 +0100
586 @@ -362,7 +362,7 @@ EXPORT(sysn32_call_table)
587 PTR compat_sys_mq_timedreceive
588 PTR compat_sys_mq_notify
589 PTR compat_sys_mq_getsetattr
590 - PTR sys_ni_syscall /* 6240, sys_vserver */
591 + PTR sys32_vserver /* 6240 */
592 PTR compat_sys_waitid
593 PTR sys_ni_syscall /* available, was setaltroot */
595 diff -NurpP --minimal linux-2.6.38.1/arch/mips/kernel/scall64-o32.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/kernel/scall64-o32.S
596 --- linux-2.6.38.1/arch/mips/kernel/scall64-o32.S 2010-10-21 13:06:54.000000000 +0200
597 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/kernel/scall64-o32.S 2011-01-29 02:01:07.000000000 +0100
598 @@ -481,7 +481,7 @@ sys_call_table:
599 PTR compat_sys_mq_timedreceive
600 PTR compat_sys_mq_notify /* 4275 */
601 PTR compat_sys_mq_getsetattr
602 - PTR sys_ni_syscall /* sys_vserver */
605 PTR sys_ni_syscall /* available, was setaltroot */
606 PTR sys_add_key /* 4280 */
607 diff -NurpP --minimal linux-2.6.38.1/arch/mips/kernel/traps.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/kernel/traps.c
608 --- linux-2.6.38.1/arch/mips/kernel/traps.c 2011-03-15 18:06:42.000000000 +0100
609 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/mips/kernel/traps.c 2011-01-29 02:01:07.000000000 +0100
610 @@ -343,9 +343,10 @@ void show_registers(struct pt_regs *regs
614 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
615 - current->comm, current->pid, current_thread_info(), current,
616 - field, current_thread_info()->tp_value);
617 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
618 + current->comm, task_pid_nr(current), current->xid,
619 + current_thread_info(), current,
620 + field, current_thread_info()->tp_value);
621 if (cpu_has_userlocal) {
624 diff -NurpP --minimal linux-2.6.38.1/arch/parisc/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/parisc/Kconfig
625 --- linux-2.6.38.1/arch/parisc/Kconfig 2011-03-15 18:06:43.000000000 +0100
626 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/parisc/Kconfig 2011-01-29 02:01:07.000000000 +0100
627 @@ -283,6 +283,8 @@ source "fs/Kconfig"
629 source "arch/parisc/Kconfig.debug"
631 +source "kernel/vserver/Kconfig"
633 source "security/Kconfig"
635 source "crypto/Kconfig"
636 diff -NurpP --minimal linux-2.6.38.1/arch/parisc/kernel/syscall_table.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/parisc/kernel/syscall_table.S
637 --- linux-2.6.38.1/arch/parisc/kernel/syscall_table.S 2011-01-05 21:49:09.000000000 +0100
638 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/parisc/kernel/syscall_table.S 2011-01-29 02:01:07.000000000 +0100
640 ENTRY_COMP(mbind) /* 260 */
641 ENTRY_COMP(get_mempolicy)
642 ENTRY_COMP(set_mempolicy)
643 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
644 + ENTRY_DIFF(vserver)
646 ENTRY_SAME(request_key) /* 265 */
648 diff -NurpP --minimal linux-2.6.38.1/arch/parisc/kernel/traps.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/parisc/kernel/traps.c
649 --- linux-2.6.38.1/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
650 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/parisc/kernel/traps.c 2011-01-29 02:01:07.000000000 +0100
651 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
655 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
656 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
657 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
658 + current->comm, task_pid_nr(current), current->xid,
659 + str, err, regs->iaoq[0]);
660 #ifdef PRINT_USER_FAULTS
661 /* XXX for debugging only */
663 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
664 pdc_console_restart();
667 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
668 - current->comm, task_pid_nr(current), str, err);
669 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
670 + current->comm, task_pid_nr(current), current->xid, str, err);
672 /* Wot's wrong wif bein' racy? */
673 if (current->thread.flags & PARISC_KERNEL_DEATH) {
674 diff -NurpP --minimal linux-2.6.38.1/arch/parisc/mm/fault.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/parisc/mm/fault.c
675 --- linux-2.6.38.1/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
676 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/parisc/mm/fault.c 2011-01-29 02:01:07.000000000 +0100
677 @@ -237,8 +237,9 @@ bad_area:
679 #ifdef PRINT_USER_FAULTS
680 printk(KERN_DEBUG "\n");
681 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
682 - task_pid_nr(tsk), tsk->comm, code, address);
683 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
684 + "command='%s' type=%lu address=0x%08lx\n",
685 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
687 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
688 vma->vm_start, vma->vm_end);
689 diff -NurpP --minimal linux-2.6.38.1/arch/powerpc/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/powerpc/Kconfig
690 --- linux-2.6.38.1/arch/powerpc/Kconfig 2011-03-15 18:06:43.000000000 +0100
691 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/powerpc/Kconfig 2011-01-29 02:01:07.000000000 +0100
692 @@ -964,6 +964,8 @@ source "lib/Kconfig"
694 source "arch/powerpc/Kconfig.debug"
696 +source "kernel/vserver/Kconfig"
698 source "security/Kconfig"
701 diff -NurpP --minimal linux-2.6.38.1/arch/powerpc/include/asm/unistd.h linux-2.6.38.1-vs2.3.0.37-rc9/arch/powerpc/include/asm/unistd.h
702 --- linux-2.6.38.1/arch/powerpc/include/asm/unistd.h 2011-01-05 21:49:10.000000000 +0100
703 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/powerpc/include/asm/unistd.h 2011-01-29 02:01:07.000000000 +0100
706 #define __NR_rtas 255
707 #define __NR_sys_debug_setcontext 256
708 -/* Number 257 is reserved for vserver */
709 +#define __NR_vserver 257
710 #define __NR_migrate_pages 258
711 #define __NR_mbind 259
712 #define __NR_get_mempolicy 260
713 diff -NurpP --minimal linux-2.6.38.1/arch/powerpc/kernel/process.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/powerpc/kernel/process.c
714 --- linux-2.6.38.1/arch/powerpc/kernel/process.c 2011-03-15 18:06:44.000000000 +0100
715 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/powerpc/kernel/process.c 2011-03-10 17:21:19.000000000 +0100
716 @@ -635,8 +635,9 @@ void show_regs(struct pt_regs * regs)
718 printk("DAR: "REG", DSISR: %08lx\n", regs->dar, regs->dsisr);
720 - printk("TASK = %p[%d] '%s' THREAD: %p",
721 - current, task_pid_nr(current), current->comm, task_thread_info(current));
722 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
723 + current, task_pid_nr(current), current->xid,
724 + current->comm, task_thread_info(current));
727 printk(" CPU: %d", raw_smp_processor_id());
728 diff -NurpP --minimal linux-2.6.38.1/arch/powerpc/kernel/traps.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/powerpc/kernel/traps.c
729 --- linux-2.6.38.1/arch/powerpc/kernel/traps.c 2011-03-15 18:06:44.000000000 +0100
730 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/powerpc/kernel/traps.c 2011-01-29 02:01:07.000000000 +0100
731 @@ -1043,8 +1043,9 @@ void nonrecoverable_exception(struct pt_
733 void trace_syscall(struct pt_regs *regs)
735 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
736 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
737 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
738 + current, task_pid_nr(current), current->xid,
739 + regs->nip, regs->link, regs->gpr[0],
740 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
743 diff -NurpP --minimal linux-2.6.38.1/arch/powerpc/kernel/vdso.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/powerpc/kernel/vdso.c
744 --- linux-2.6.38.1/arch/powerpc/kernel/vdso.c 2011-01-05 21:49:11.000000000 +0100
745 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/powerpc/kernel/vdso.c 2011-01-29 02:01:07.000000000 +0100
747 #include <linux/security.h>
748 #include <linux/bootmem.h>
749 #include <linux/memblock.h>
750 +#include <linux/vs_memory.h>
752 #include <asm/pgtable.h>
753 #include <asm/system.h>
754 diff -NurpP --minimal linux-2.6.38.1/arch/s390/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/s390/Kconfig
755 --- linux-2.6.38.1/arch/s390/Kconfig 2011-03-15 18:06:45.000000000 +0100
756 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/s390/Kconfig 2011-02-17 02:17:45.000000000 +0100
757 @@ -645,6 +645,8 @@ source "fs/Kconfig"
759 source "arch/s390/Kconfig.debug"
761 +source "kernel/vserver/Kconfig"
763 source "security/Kconfig"
765 source "crypto/Kconfig"
766 diff -NurpP --minimal linux-2.6.38.1/arch/s390/include/asm/tlb.h linux-2.6.38.1-vs2.3.0.37-rc9/arch/s390/include/asm/tlb.h
767 --- linux-2.6.38.1/arch/s390/include/asm/tlb.h 2011-03-15 18:06:45.000000000 +0100
768 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/s390/include/asm/tlb.h 2011-02-17 02:17:45.000000000 +0100
770 #include <linux/mm.h>
771 #include <linux/pagemap.h>
772 #include <linux/swap.h>
773 +#include <linux/vs_memory.h>
775 #include <asm/processor.h>
776 #include <asm/pgalloc.h>
778 diff -NurpP --minimal linux-2.6.38.1/arch/s390/include/asm/unistd.h linux-2.6.38.1-vs2.3.0.37-rc9/arch/s390/include/asm/unistd.h
779 --- linux-2.6.38.1/arch/s390/include/asm/unistd.h 2010-10-21 13:06:58.000000000 +0200
780 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/s390/include/asm/unistd.h 2011-01-29 02:01:07.000000000 +0100
782 #define __NR_clock_gettime (__NR_timer_create+6)
783 #define __NR_clock_getres (__NR_timer_create+7)
784 #define __NR_clock_nanosleep (__NR_timer_create+8)
785 -/* Number 263 is reserved for vserver */
786 +#define __NR_vserver 263
787 #define __NR_statfs64 265
788 #define __NR_fstatfs64 266
789 #define __NR_remap_file_pages 267
790 diff -NurpP --minimal linux-2.6.38.1/arch/s390/kernel/ptrace.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/s390/kernel/ptrace.c
791 --- linux-2.6.38.1/arch/s390/kernel/ptrace.c 2011-03-15 18:06:45.000000000 +0100
792 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/s390/kernel/ptrace.c 2011-01-29 02:01:07.000000000 +0100
794 #include <linux/regset.h>
795 #include <linux/tracehook.h>
796 #include <linux/seccomp.h>
797 +#include <linux/vs_base.h>
798 #include <trace/syscall.h>
799 #include <asm/compat.h>
800 #include <asm/segment.h>
801 diff -NurpP --minimal linux-2.6.38.1/arch/s390/kernel/syscalls.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/s390/kernel/syscalls.S
802 --- linux-2.6.38.1/arch/s390/kernel/syscalls.S 2010-10-21 13:06:58.000000000 +0200
803 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/s390/kernel/syscalls.S 2011-01-29 02:01:07.000000000 +0100
804 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
805 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
806 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
807 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
808 -NI_SYSCALL /* reserved for vserver */
809 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
810 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
811 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
812 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
813 diff -NurpP --minimal linux-2.6.38.1/arch/sh/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/sh/Kconfig
814 --- linux-2.6.38.1/arch/sh/Kconfig 2011-03-15 18:06:46.000000000 +0100
815 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/sh/Kconfig 2011-02-02 22:20:22.000000000 +0100
816 @@ -889,6 +889,8 @@ source "fs/Kconfig"
818 source "arch/sh/Kconfig.debug"
820 +source "kernel/vserver/Kconfig"
822 source "security/Kconfig"
824 source "crypto/Kconfig"
825 diff -NurpP --minimal linux-2.6.38.1/arch/sh/kernel/irq.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/sh/kernel/irq.c
826 --- linux-2.6.38.1/arch/sh/kernel/irq.c 2011-01-05 21:49:16.000000000 +0100
827 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/sh/kernel/irq.c 2011-01-29 02:01:07.000000000 +0100
829 #include <linux/seq_file.h>
830 #include <linux/ftrace.h>
831 #include <linux/delay.h>
832 +// #include <linux/vs_context.h>
833 #include <asm/processor.h>
834 #include <asm/machvec.h>
835 #include <asm/uaccess.h>
836 diff -NurpP --minimal linux-2.6.38.1/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.38.1-vs2.3.0.37-rc9/arch/sh/kernel/vsyscall/vsyscall.c
837 --- linux-2.6.38.1/arch/sh/kernel/vsyscall/vsyscall.c 2010-07-07 18:31:10.000000000 +0200
838 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/sh/kernel/vsyscall/vsyscall.c 2011-01-29 02:01:07.000000000 +0100
840 #include <linux/elf.h>
841 #include <linux/sched.h>
842 #include <linux/err.h>
843 +#include <linux/vs_memory.h>
846 * Should the kernel map a VDSO page into processes and pass its
847 diff -NurpP --minimal linux-2.6.38.1/arch/sparc/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/sparc/Kconfig
848 --- linux-2.6.38.1/arch/sparc/Kconfig 2011-03-15 18:06:47.000000000 +0100
849 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/sparc/Kconfig 2011-01-29 02:01:07.000000000 +0100
850 @@ -553,6 +553,8 @@ source "fs/Kconfig"
852 source "arch/sparc/Kconfig.debug"
854 +source "kernel/vserver/Kconfig"
856 source "security/Kconfig"
858 source "crypto/Kconfig"
859 diff -NurpP --minimal linux-2.6.38.1/arch/sparc/include/asm/tlb_64.h linux-2.6.38.1-vs2.3.0.37-rc9/arch/sparc/include/asm/tlb_64.h
860 --- linux-2.6.38.1/arch/sparc/include/asm/tlb_64.h 2009-09-10 15:25:45.000000000 +0200
861 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/sparc/include/asm/tlb_64.h 2011-01-29 02:01:07.000000000 +0100
864 #include <linux/swap.h>
865 #include <linux/pagemap.h>
866 +#include <linux/vs_memory.h>
867 #include <asm/pgalloc.h>
868 #include <asm/tlbflush.h>
869 #include <asm/mmu_context.h>
870 diff -NurpP --minimal linux-2.6.38.1/arch/sparc/include/asm/unistd.h linux-2.6.38.1-vs2.3.0.37-rc9/arch/sparc/include/asm/unistd.h
871 --- linux-2.6.38.1/arch/sparc/include/asm/unistd.h 2010-10-21 13:06:58.000000000 +0200
872 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/sparc/include/asm/unistd.h 2011-01-29 02:01:07.000000000 +0100
874 #define __NR_timer_getoverrun 264
875 #define __NR_timer_delete 265
876 #define __NR_timer_create 266
877 -/* #define __NR_vserver 267 Reserved for VSERVER */
878 +#define __NR_vserver 267
879 #define __NR_io_setup 268
880 #define __NR_io_destroy 269
881 #define __NR_io_submit 270
882 diff -NurpP --minimal linux-2.6.38.1/arch/sparc/kernel/systbls_32.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/sparc/kernel/systbls_32.S
883 --- linux-2.6.38.1/arch/sparc/kernel/systbls_32.S 2010-10-21 13:06:59.000000000 +0200
884 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/sparc/kernel/systbls_32.S 2011-01-29 02:01:07.000000000 +0100
885 @@ -70,7 +70,7 @@ sys_call_table:
886 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
887 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
888 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
889 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
890 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
891 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
892 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
893 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
894 diff -NurpP --minimal linux-2.6.38.1/arch/sparc/kernel/systbls_64.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/sparc/kernel/systbls_64.S
895 --- linux-2.6.38.1/arch/sparc/kernel/systbls_64.S 2010-10-21 13:06:59.000000000 +0200
896 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/sparc/kernel/systbls_64.S 2011-01-29 02:01:07.000000000 +0100
897 @@ -71,7 +71,7 @@ sys_call_table32:
898 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
899 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
900 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
901 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
902 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
903 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
904 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
905 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
906 @@ -147,7 +147,7 @@ sys_call_table:
907 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
908 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
909 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
910 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
911 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
912 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
913 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
914 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
915 diff -NurpP --minimal linux-2.6.38.1/arch/um/Kconfig.rest linux-2.6.38.1-vs2.3.0.37-rc9/arch/um/Kconfig.rest
916 --- linux-2.6.38.1/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
917 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/um/Kconfig.rest 2011-01-29 02:01:07.000000000 +0100
918 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
922 +source "kernel/vserver/Kconfig"
924 source "security/Kconfig"
926 source "crypto/Kconfig"
927 diff -NurpP --minimal linux-2.6.38.1/arch/um/include/asm/tlb.h linux-2.6.38.1-vs2.3.0.37-rc9/arch/um/include/asm/tlb.h
928 --- linux-2.6.38.1/arch/um/include/asm/tlb.h 2009-09-10 15:25:46.000000000 +0200
929 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/um/include/asm/tlb.h 2011-01-29 02:01:07.000000000 +0100
932 #include <linux/pagemap.h>
933 #include <linux/swap.h>
934 +#include <linux/vs_memory.h>
935 #include <asm/percpu.h>
936 #include <asm/pgalloc.h>
937 #include <asm/tlbflush.h>
938 diff -NurpP --minimal linux-2.6.38.1/arch/um/include/shared/kern_constants.h linux-2.6.38.1-vs2.3.0.37-rc9/arch/um/include/shared/kern_constants.h
939 --- linux-2.6.38.1/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
940 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/um/include/shared/kern_constants.h 2011-01-29 02:01:07.000000000 +0100
942 +#include "../../../../include/generated/asm-offsets.h"
943 diff -NurpP --minimal linux-2.6.38.1/arch/um/include/shared/user_constants.h linux-2.6.38.1-vs2.3.0.37-rc9/arch/um/include/shared/user_constants.h
944 --- linux-2.6.38.1/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
945 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/um/include/shared/user_constants.h 2011-01-29 02:01:07.000000000 +0100
950 + * This file was generated by arch/um/Makefile
954 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2) # */
955 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err) # */
956 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno) # */
957 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long) # */
958 +#define HOST_RBX 5 /* RBX # */
959 +#define HOST_RCX 11 /* RCX # */
960 +#define HOST_RDI 14 /* RDI # */
961 +#define HOST_RSI 13 /* RSI # */
962 +#define HOST_RDX 12 /* RDX # */
963 +#define HOST_RBP 4 /* RBP # */
964 +#define HOST_RAX 10 /* RAX # */
965 +#define HOST_R8 9 /* R8 # */
966 +#define HOST_R9 8 /* R9 # */
967 +#define HOST_R10 7 /* R10 # */
968 +#define HOST_R11 6 /* R11 # */
969 +#define HOST_R12 3 /* R12 # */
970 +#define HOST_R13 2 /* R13 # */
971 +#define HOST_R14 1 /* R14 # */
972 +#define HOST_R15 0 /* R15 # */
973 +#define HOST_ORIG_RAX 15 /* ORIG_RAX # */
974 +#define HOST_CS 17 /* CS # */
975 +#define HOST_SS 20 /* SS # */
976 +#define HOST_EFLAGS 18 /* EFLAGS # */
977 +#define HOST_IP 16 /* RIP # */
978 +#define HOST_SP 19 /* RSP # */
979 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct) # */
980 +#define UM_POLLIN 1 /* POLLIN # */
981 +#define UM_POLLPRI 2 /* POLLPRI # */
982 +#define UM_POLLOUT 4 /* POLLOUT # */
983 +#define UM_PROT_READ 1 /* PROT_READ # */
984 +#define UM_PROT_WRITE 2 /* PROT_WRITE # */
985 +#define UM_PROT_EXEC 4 /* PROT_EXEC # */
987 diff -NurpP --minimal linux-2.6.38.1/arch/x86/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/arch/x86/Kconfig
988 --- linux-2.6.38.1/arch/x86/Kconfig 2011-03-15 18:06:48.000000000 +0100
989 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/x86/Kconfig 2011-01-29 02:01:07.000000000 +0100
990 @@ -2159,6 +2159,8 @@ source "fs/Kconfig"
992 source "arch/x86/Kconfig.debug"
994 +source "kernel/vserver/Kconfig"
996 source "security/Kconfig"
998 source "crypto/Kconfig"
999 diff -NurpP --minimal linux-2.6.38.1/arch/x86/ia32/ia32entry.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/x86/ia32/ia32entry.S
1000 --- linux-2.6.38.1/arch/x86/ia32/ia32entry.S 2010-10-21 13:06:59.000000000 +0200
1001 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/x86/ia32/ia32entry.S 2011-01-29 02:01:07.000000000 +0100
1002 @@ -783,7 +783,7 @@ ia32_sys_call_table:
1003 .quad sys_tgkill /* 270 */
1004 .quad compat_sys_utimes
1005 .quad sys32_fadvise64_64
1006 - .quad quiet_ni_syscall /* sys_vserver */
1007 + .quad sys32_vserver
1009 .quad compat_sys_get_mempolicy /* 275 */
1010 .quad sys_set_mempolicy
1011 diff -NurpP --minimal linux-2.6.38.1/arch/x86/include/asm/unistd_64.h linux-2.6.38.1-vs2.3.0.37-rc9/arch/x86/include/asm/unistd_64.h
1012 --- linux-2.6.38.1/arch/x86/include/asm/unistd_64.h 2010-10-21 13:06:59.000000000 +0200
1013 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/x86/include/asm/unistd_64.h 2011-01-29 02:01:07.000000000 +0100
1014 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
1015 #define __NR_utimes 235
1016 __SYSCALL(__NR_utimes, sys_utimes)
1017 #define __NR_vserver 236
1018 -__SYSCALL(__NR_vserver, sys_ni_syscall)
1019 +__SYSCALL(__NR_vserver, sys_vserver)
1020 #define __NR_mbind 237
1021 __SYSCALL(__NR_mbind, sys_mbind)
1022 #define __NR_set_mempolicy 238
1023 diff -NurpP --minimal linux-2.6.38.1/arch/x86/kernel/syscall_table_32.S linux-2.6.38.1-vs2.3.0.37-rc9/arch/x86/kernel/syscall_table_32.S
1024 --- linux-2.6.38.1/arch/x86/kernel/syscall_table_32.S 2010-10-21 13:07:00.000000000 +0200
1025 +++ linux-2.6.38.1-vs2.3.0.37-rc9/arch/x86/kernel/syscall_table_32.S 2011-01-29 02:01:07.000000000 +0100
1026 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
1027 .long sys_tgkill /* 270 */
1029 .long sys_fadvise64_64
1030 - .long sys_ni_syscall /* sys_vserver */
1033 .long sys_get_mempolicy
1034 .long sys_set_mempolicy
1035 diff -NurpP --minimal linux-2.6.38.1/drivers/block/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/drivers/block/Kconfig
1036 --- linux-2.6.38.1/drivers/block/Kconfig 2011-03-15 18:06:54.000000000 +0100
1037 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/block/Kconfig 2011-01-29 02:01:07.000000000 +0100
1038 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
1040 source "drivers/block/drbd/Kconfig"
1042 +config BLK_DEV_VROOT
1043 + tristate "Virtual Root device support"
1044 + depends on QUOTACTL
1046 + Saying Y here will allow you to use quota/fs ioctls on a shared
1047 + partition within a virtual server without compromising security.
1050 tristate "Network block device support"
1052 diff -NurpP --minimal linux-2.6.38.1/drivers/block/Makefile linux-2.6.38.1-vs2.3.0.37-rc9/drivers/block/Makefile
1053 --- linux-2.6.38.1/drivers/block/Makefile 2011-03-15 18:06:54.000000000 +0100
1054 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/block/Makefile 2011-02-17 02:17:45.000000000 +0100
1055 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1056 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1057 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1058 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1059 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1061 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1062 obj-$(CONFIG_BLK_DEV_DRBD) += drbd/
1063 diff -NurpP --minimal linux-2.6.38.1/drivers/block/loop.c linux-2.6.38.1-vs2.3.0.37-rc9/drivers/block/loop.c
1064 --- linux-2.6.38.1/drivers/block/loop.c 2011-03-15 18:06:54.000000000 +0100
1065 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/block/loop.c 2011-03-10 17:21:19.000000000 +0100
1067 #include <linux/kthread.h>
1068 #include <linux/splice.h>
1069 #include <linux/sysfs.h>
1070 +#include <linux/vs_context.h>
1072 #include <asm/uaccess.h>
1074 @@ -902,6 +903,7 @@ static int loop_set_fd(struct loop_devic
1075 lo->lo_blocksize = lo_blocksize;
1076 lo->lo_device = bdev;
1077 lo->lo_flags = lo_flags;
1078 + lo->lo_xid = vx_current_xid();
1079 lo->lo_backing_file = file;
1080 lo->transfer = transfer_none;
1082 @@ -1032,6 +1034,7 @@ static int loop_clr_fd(struct loop_devic
1083 lo->lo_encrypt_key_size = 0;
1085 lo->lo_thread = NULL;
1087 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1088 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1089 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1090 @@ -1070,7 +1073,7 @@ loop_set_status(struct loop_device *lo,
1092 if (lo->lo_encrypt_key_size &&
1093 lo->lo_key_owner != uid &&
1094 - !capable(CAP_SYS_ADMIN))
1095 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1097 if (lo->lo_state != Lo_bound)
1099 @@ -1154,7 +1157,8 @@ loop_get_status(struct loop_device *lo,
1100 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1101 info->lo_encrypt_type =
1102 lo->lo_encryption ? lo->lo_encryption->number : 0;
1103 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1104 + if (lo->lo_encrypt_key_size &&
1105 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1106 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1107 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1108 lo->lo_encrypt_key_size);
1109 @@ -1500,6 +1504,9 @@ static int lo_open(struct block_device *
1111 struct loop_device *lo = bdev->bd_disk->private_data;
1113 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1116 mutex_lock(&lo->lo_ctl_mutex);
1118 mutex_unlock(&lo->lo_ctl_mutex);
1119 diff -NurpP --minimal linux-2.6.38.1/drivers/block/vroot.c linux-2.6.38.1-vs2.3.0.37-rc9/drivers/block/vroot.c
1120 --- linux-2.6.38.1/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1121 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/block/vroot.c 2011-03-17 18:14:05.000000000 +0100
1124 + * linux/drivers/block/vroot.c
1126 + * written by Herbert Pötzl, 9/11/2002
1127 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1129 + * based on the loop.c code by Theodore Ts'o.
1131 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1132 + * Redistribution of this file is permitted under the
1133 + * GNU General Public License.
1137 +#include <linux/module.h>
1138 +#include <linux/moduleparam.h>
1139 +#include <linux/file.h>
1140 +#include <linux/major.h>
1141 +#include <linux/blkdev.h>
1142 +#include <linux/slab.h>
1144 +#include <linux/vroot.h>
1145 +#include <linux/vs_context.h>
1148 +static int max_vroot = 8;
1150 +static struct vroot_device *vroot_dev;
1151 +static struct gendisk **disks;
1154 +static int vroot_set_dev(
1155 + struct vroot_device *vr,
1156 + struct block_device *bdev,
1159 + struct block_device *real_bdev;
1160 + struct file *file;
1161 + struct inode *inode;
1165 + if (vr->vr_state != Vr_unbound)
1174 + inode = file->f_dentry->d_inode;
1177 + if (S_ISBLK(inode->i_mode)) {
1178 + real_bdev = inode->i_bdev;
1179 + vr->vr_device = real_bdev;
1180 + __iget(real_bdev->bd_inode);
1184 + vxdprintk(VXD_CBIT(misc, 0),
1185 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1186 + vr->vr_number, VXD_DEV(real_bdev));
1188 + vr->vr_state = Vr_bound;
1197 +static int vroot_clr_dev(
1198 + struct vroot_device *vr,
1199 + struct block_device *bdev)
1201 + struct block_device *real_bdev;
1203 + if (vr->vr_state != Vr_bound)
1205 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1208 + real_bdev = vr->vr_device;
1210 + vxdprintk(VXD_CBIT(misc, 0),
1211 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1212 + vr->vr_number, VXD_DEV(real_bdev));
1215 + vr->vr_state = Vr_unbound;
1216 + vr->vr_device = NULL;
1221 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1222 + unsigned int cmd, unsigned long arg)
1224 + struct vroot_device *vr = bdev->bd_disk->private_data;
1227 + down(&vr->vr_ctl_mutex);
1229 + case VROOT_SET_DEV:
1230 + err = vroot_set_dev(vr, bdev, arg);
1232 + case VROOT_CLR_DEV:
1233 + err = vroot_clr_dev(vr, bdev);
1239 + up(&vr->vr_ctl_mutex);
1243 +static int vr_open(struct block_device *bdev, fmode_t mode)
1245 + struct vroot_device *vr = bdev->bd_disk->private_data;
1247 + down(&vr->vr_ctl_mutex);
1249 + up(&vr->vr_ctl_mutex);
1253 +static int vr_release(struct gendisk *disk, fmode_t mode)
1255 + struct vroot_device *vr = disk->private_data;
1257 + down(&vr->vr_ctl_mutex);
1259 + up(&vr->vr_ctl_mutex);
1263 +static struct block_device_operations vr_fops = {
1264 + .owner = THIS_MODULE,
1266 + .release = vr_release,
1267 + .ioctl = vr_ioctl,
1270 +static int vroot_make_request(struct request_queue *q, struct bio *bio)
1272 + printk("vroot_make_request %p, %p\n", q, bio);
1273 + bio_io_error(bio);
1277 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1279 + struct inode *inode = bdev->bd_inode;
1280 + struct vroot_device *vr;
1281 + struct block_device *real_bdev;
1282 + int minor = iminor(inode);
1284 + vr = &vroot_dev[minor];
1285 + real_bdev = vr->vr_device;
1287 + vxdprintk(VXD_CBIT(misc, 0),
1288 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1289 + vr->vr_number, VXD_DEV(real_bdev));
1291 + if (vr->vr_state != Vr_bound)
1292 + return ERR_PTR(-ENXIO);
1294 + __iget(real_bdev->bd_inode);
1301 + * And now the modules code and kernel interface.
1304 +module_param(max_vroot, int, 0);
1306 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1307 +MODULE_LICENSE("GPL");
1308 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1310 +MODULE_AUTHOR ("Herbert Pötzl");
1311 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1314 +int __init vroot_init(void)
1318 + if (max_vroot < 1 || max_vroot > 256) {
1319 + max_vroot = MAX_VROOT_DEFAULT;
1320 + printk(KERN_WARNING "vroot: invalid max_vroot "
1321 + "(must be between 1 and 256), "
1322 + "using default (%d)\n", max_vroot);
1325 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1329 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1332 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1334 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1338 + for (i = 0; i < max_vroot; i++) {
1339 + disks[i] = alloc_disk(1);
1342 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1343 + if (!disks[i]->queue)
1345 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1348 + for (i = 0; i < max_vroot; i++) {
1349 + struct vroot_device *vr = &vroot_dev[i];
1350 + struct gendisk *disk = disks[i];
1352 + memset(vr, 0, sizeof(*vr));
1353 + sema_init(&vr->vr_ctl_mutex, 1);
1354 + vr->vr_number = i;
1355 + disk->major = VROOT_MAJOR;
1356 + disk->first_minor = i;
1357 + disk->fops = &vr_fops;
1358 + sprintf(disk->disk_name, "vroot%d", i);
1359 + disk->private_data = vr;
1362 + err = register_vroot_grb(&__vroot_get_real_bdev);
1366 + for (i = 0; i < max_vroot; i++)
1367 + add_disk(disks[i]);
1368 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1373 + put_disk(disks[i]);
1378 + unregister_blkdev(VROOT_MAJOR, "vroot");
1379 + printk(KERN_ERR "vroot: ran out of memory\n");
1383 +void vroot_exit(void)
1387 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1388 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1390 + for (i = 0; i < max_vroot; i++) {
1391 + del_gendisk(disks[i]);
1392 + put_disk(disks[i]);
1394 + unregister_blkdev(VROOT_MAJOR, "vroot");
1400 +module_init(vroot_init);
1401 +module_exit(vroot_exit);
1405 +static int __init max_vroot_setup(char *str)
1407 + max_vroot = simple_strtol(str, NULL, 0);
1411 +__setup("max_vroot=", max_vroot_setup);
1415 diff -NurpP --minimal linux-2.6.38.1/drivers/gpu/drm/radeon/r100_reg_safe.h linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/r100_reg_safe.h
1416 --- linux-2.6.38.1/drivers/gpu/drm/radeon/r100_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1417 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/r100_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1419 +static const unsigned r100_reg_safe_bm[102] = {
1420 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1421 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1422 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1423 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1424 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1425 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1426 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1427 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1428 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1429 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1430 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1431 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1432 + 0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1433 + 0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1434 + 0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
1435 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1436 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
1437 + 0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
1438 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1439 + 0xFFFFFFFF, 0xFFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1440 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1441 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1442 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1443 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1444 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1445 + 0xFFFFFFFF, 0xFFFFFFEF,
1447 diff -NurpP --minimal linux-2.6.38.1/drivers/gpu/drm/radeon/r200_reg_safe.h linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/r200_reg_safe.h
1448 --- linux-2.6.38.1/drivers/gpu/drm/radeon/r200_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1449 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/r200_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1451 +static const unsigned r200_reg_safe_bm[102] = {
1452 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1453 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1454 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1455 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1456 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1457 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1458 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1459 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1460 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1461 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1462 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1463 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1464 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1465 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1466 + 0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
1467 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1468 + 0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
1469 + 0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
1470 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1471 + 0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1472 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1473 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1474 + 0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
1475 + 0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
1476 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1477 + 0xFFFFFE3F, 0xFFFFFFEF,
1479 diff -NurpP --minimal linux-2.6.38.1/drivers/gpu/drm/radeon/r300_reg_safe.h linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/r300_reg_safe.h
1480 --- linux-2.6.38.1/drivers/gpu/drm/radeon/r300_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1481 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/r300_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1483 +static const unsigned r300_reg_safe_bm[159] = {
1484 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1485 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1486 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1487 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1488 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1489 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1490 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1491 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1492 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1493 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1494 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1495 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1496 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1497 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1498 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1499 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1500 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1501 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1502 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1503 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
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 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1511 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1512 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1513 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1514 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1515 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1516 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1517 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1518 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1519 + 0x00000000, 0x0000C100, 0x00000000, 0x00000000,
1520 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1521 + 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
1522 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1523 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1525 diff -NurpP --minimal linux-2.6.38.1/drivers/gpu/drm/radeon/r420_reg_safe.h linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/r420_reg_safe.h
1526 --- linux-2.6.38.1/drivers/gpu/drm/radeon/r420_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1527 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/r420_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1529 +static const unsigned r420_reg_safe_bm[159] = {
1530 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1531 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1532 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1533 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1534 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1535 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1536 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1537 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1538 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1539 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1540 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1541 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1542 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1543 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1544 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1545 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1546 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1547 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1548 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1549 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1550 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1551 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1552 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1553 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1554 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1555 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1556 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1557 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1558 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1559 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1560 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1561 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1562 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1563 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1564 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1565 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1566 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1567 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1568 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1569 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1571 diff -NurpP --minimal linux-2.6.38.1/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/rn50_reg_safe.h
1572 --- linux-2.6.38.1/drivers/gpu/drm/radeon/rn50_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1573 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/rn50_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1575 +static const unsigned rn50_reg_safe_bm[102] = {
1576 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1577 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1578 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1579 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1580 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1581 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1582 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1583 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1584 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1585 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1586 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1587 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 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 + 0xFFFFFFFF, 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 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1601 + 0xFFFFFFFF, 0xFFFFFFFF,
1603 diff -NurpP --minimal linux-2.6.38.1/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/rs600_reg_safe.h
1604 --- linux-2.6.38.1/drivers/gpu/drm/radeon/rs600_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1605 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/rs600_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1607 +static const unsigned rs600_reg_safe_bm[219] = {
1608 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1609 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1610 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1611 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1612 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1613 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1614 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1615 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1616 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1617 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1618 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1619 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1620 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1621 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1622 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1623 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1624 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1625 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1626 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1627 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1628 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1629 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1630 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1631 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1632 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1633 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1634 + 0xFFFFF7FF, 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 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1641 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1642 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1643 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1644 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1645 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1646 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1647 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
1648 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1649 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1650 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1651 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1652 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1653 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1654 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1655 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1656 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1657 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1658 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1659 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1660 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1661 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1662 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1664 diff -NurpP --minimal linux-2.6.38.1/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/rv515_reg_safe.h
1665 --- linux-2.6.38.1/drivers/gpu/drm/radeon/rv515_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1666 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/gpu/drm/radeon/rv515_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1668 +static const unsigned rv515_reg_safe_bm[219] = {
1669 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1670 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1671 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 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 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1680 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1681 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1682 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1683 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1684 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1685 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1686 + 0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1687 + 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
1688 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1689 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1690 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1691 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1692 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1693 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1694 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1695 + 0xFFFFF7FF, 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 + 0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
1702 + 0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
1703 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1704 + 0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
1705 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1706 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
1707 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1708 + 0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
1709 + 0xFFFFFFFF, 0xFFFFFFFF, 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 + 0xFFFFFFFF, 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,
1725 diff -NurpP --minimal linux-2.6.38.1/drivers/infiniband/core/addr.c linux-2.6.38.1-vs2.3.0.37-rc9/drivers/infiniband/core/addr.c
1726 --- linux-2.6.38.1/drivers/infiniband/core/addr.c 2011-03-15 18:06:57.000000000 +0100
1727 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/infiniband/core/addr.c 2011-01-29 02:01:07.000000000 +0100
1728 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
1730 if (ipv6_addr_any(&fl.fl6_src)) {
1731 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1732 - &fl.fl6_dst, 0, &fl.fl6_src);
1733 + &fl.fl6_dst, 0, &fl.fl6_src, NULL);
1737 diff -NurpP --minimal linux-2.6.38.1/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.38.1-vs2.3.0.37-rc9/drivers/infiniband/hw/ipath/ipath_user_pages.c
1738 --- linux-2.6.38.1/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-03-15 18:06:58.000000000 +0100
1739 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-01-29 02:01:07.000000000 +0100
1741 #include <linux/device.h>
1742 #include <linux/slab.h>
1743 #include <linux/sched.h>
1744 +#include <linux/vs_memory.h>
1746 #include "ipath_kernel.h"
1748 diff -NurpP --minimal linux-2.6.38.1/drivers/md/dm-ioctl.c linux-2.6.38.1-vs2.3.0.37-rc9/drivers/md/dm-ioctl.c
1749 --- linux-2.6.38.1/drivers/md/dm-ioctl.c 2011-03-15 18:07:02.000000000 +0100
1750 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/md/dm-ioctl.c 2011-01-29 02:01:07.000000000 +0100
1752 #include <linux/dm-ioctl.h>
1753 #include <linux/hdreg.h>
1754 #include <linux/compat.h>
1755 +#include <linux/vs_context.h>
1757 #include <asm/uaccess.h>
1759 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1760 unsigned int h = hash_str(str);
1762 list_for_each_entry (hc, _name_buckets + h, name_list)
1763 - if (!strcmp(hc->name, str)) {
1764 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1765 + !strcmp(hc->name, str)) {
1769 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1770 unsigned int h = hash_str(str);
1772 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1773 - if (!strcmp(hc->uuid, str)) {
1774 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1775 + !strcmp(hc->uuid, str)) {
1779 @@ -427,6 +430,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1781 static int remove_all(struct dm_ioctl *param, size_t param_size)
1783 + if (!vx_check(0, VS_ADMIN))
1786 dm_hash_remove_all(1);
1787 param->data_size = 0;
1789 @@ -474,6 +480,8 @@ static int list_devices(struct dm_ioctl
1791 for (i = 0; i < NUM_BUCKETS; i++) {
1792 list_for_each_entry (hc, _name_buckets + i, name_list) {
1793 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1795 needed += sizeof(struct dm_name_list);
1796 needed += strlen(hc->name) + 1;
1797 needed += ALIGN_MASK;
1798 @@ -497,6 +505,8 @@ static int list_devices(struct dm_ioctl
1800 for (i = 0; i < NUM_BUCKETS; i++) {
1801 list_for_each_entry (hc, _name_buckets + i, name_list) {
1802 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1805 old_nl->next = (uint32_t) ((void *) nl -
1807 @@ -731,10 +741,11 @@ static struct hash_cell *__find_device_h
1811 - mdptr = dm_get_mdptr(md);
1812 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1813 + mdptr = dm_get_mdptr(md);
1821 @@ -1566,8 +1577,8 @@ static int ctl_ioctl(uint command, struc
1825 - /* only root can play with this */
1826 - if (!capable(CAP_SYS_ADMIN))
1827 + /* only root and certain contexts can play with this */
1828 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1831 if (_IOC_TYPE(command) != DM_IOCTL)
1832 diff -NurpP --minimal linux-2.6.38.1/drivers/md/dm.c linux-2.6.38.1-vs2.3.0.37-rc9/drivers/md/dm.c
1833 --- linux-2.6.38.1/drivers/md/dm.c 2011-03-15 18:07:02.000000000 +0100
1834 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/md/dm.c 2011-01-29 03:26:19.000000000 +0100
1836 #include <linux/idr.h>
1837 #include <linux/hdreg.h>
1838 #include <linux/delay.h>
1839 +#include <linux/vs_base.h>
1841 #include <trace/events/block.h>
1843 @@ -119,6 +120,7 @@ struct mapped_device {
1846 atomic_t open_count;
1849 unsigned long flags;
1851 @@ -326,6 +328,7 @@ int dm_deleting_md(struct mapped_device
1852 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1854 struct mapped_device *md;
1857 spin_lock(&_minor_lock);
1859 @@ -334,18 +337,19 @@ static int dm_blk_open(struct block_devi
1862 if (test_bit(DMF_FREEING, &md->flags) ||
1863 - dm_deleting_md(md)) {
1865 + dm_deleting_md(md))
1869 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1874 atomic_inc(&md->open_count);
1878 spin_unlock(&_minor_lock);
1880 - return md ? 0 : -ENXIO;
1884 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1885 @@ -565,6 +569,14 @@ int dm_set_geometry(struct mapped_device
1890 + * Get the xid associated with a dm device
1892 +xid_t dm_get_xid(struct mapped_device *md)
1897 /*-----------------------------------------------------------------
1899 * A more elegant soln is in the works that uses the queue
1900 @@ -1860,6 +1872,7 @@ static struct mapped_device *alloc_dev(i
1901 INIT_LIST_HEAD(&md->uevent_list);
1902 spin_lock_init(&md->uevent_lock);
1904 + md->xid = vx_current_xid();
1905 md->queue = blk_alloc_queue(GFP_KERNEL);
1908 diff -NurpP --minimal linux-2.6.38.1/drivers/md/dm.h linux-2.6.38.1-vs2.3.0.37-rc9/drivers/md/dm.h
1909 --- linux-2.6.38.1/drivers/md/dm.h 2010-10-21 13:07:07.000000000 +0200
1910 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/md/dm.h 2011-01-29 02:01:07.000000000 +0100
1911 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1913 struct dm_md_mempools;
1915 +xid_t dm_get_xid(struct mapped_device *md);
1917 /*-----------------------------------------------------------------
1918 * Internal table functions.
1919 *---------------------------------------------------------------*/
1920 diff -NurpP --minimal linux-2.6.38.1/drivers/net/tun.c linux-2.6.38.1-vs2.3.0.37-rc9/drivers/net/tun.c
1921 --- linux-2.6.38.1/drivers/net/tun.c 2011-03-15 18:07:12.000000000 +0100
1922 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/net/tun.c 2011-01-29 02:01:07.000000000 +0100
1924 #include <linux/nsproxy.h>
1925 #include <linux/virtio_net.h>
1926 #include <linux/rcupdate.h>
1927 +#include <linux/vs_network.h>
1928 #include <net/net_namespace.h>
1929 #include <net/netns/generic.h>
1930 #include <net/rtnetlink.h>
1931 @@ -103,6 +104,7 @@ struct tun_struct {
1937 struct net_device *dev;
1938 struct fasync_struct *fasync;
1939 @@ -853,6 +855,7 @@ static void tun_setup(struct net_device
1943 + tun->nid = current->nid;
1945 dev->ethtool_ops = &tun_ethtool_ops;
1946 dev->destructor = tun_free_netdev;
1947 @@ -1003,7 +1006,7 @@ static int tun_set_iff(struct net *net,
1949 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1950 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1951 - !capable(CAP_NET_ADMIN))
1952 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1954 err = security_tun_dev_attach(tun->socket.sk);
1956 @@ -1017,7 +1020,7 @@ static int tun_set_iff(struct net *net,
1958 unsigned long flags = 0;
1960 - if (!capable(CAP_NET_ADMIN))
1961 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1963 err = security_tun_dev_create();
1965 @@ -1087,6 +1090,9 @@ static int tun_set_iff(struct net *net,
1967 sk->sk_destruct = tun_sock_destruct;
1969 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1972 err = tun_attach(tun, file);
1975 @@ -1278,6 +1284,16 @@ static long __tun_chr_ioctl(struct file
1976 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
1980 + if (!capable(CAP_CONTEXT))
1983 + /* Set nid owner of the device */
1984 + tun->nid = (nid_t) arg;
1986 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
1990 /* Only allow setting the type when the interface is down */
1991 if (tun->dev->flags & IFF_UP) {
1992 diff -NurpP --minimal linux-2.6.38.1/drivers/tty/sysrq.c linux-2.6.38.1-vs2.3.0.37-rc9/drivers/tty/sysrq.c
1993 --- linux-2.6.38.1/drivers/tty/sysrq.c 2011-03-15 18:07:26.000000000 +0100
1994 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/tty/sysrq.c 2011-02-17 02:17:49.000000000 +0100
1996 #include <linux/oom.h>
1997 #include <linux/slab.h>
1998 #include <linux/input.h>
1999 +#include <linux/vserver/debug.h>
2001 #include <asm/ptrace.h>
2002 #include <asm/irq_regs.h>
2003 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
2004 .enable_mask = SYSRQ_ENABLE_RTNICE,
2008 +#ifdef CONFIG_VSERVER_DEBUG
2009 +static void sysrq_handle_vxinfo(int key)
2011 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
2014 +static struct sysrq_key_op sysrq_showvxinfo_op = {
2015 + .handler = sysrq_handle_vxinfo,
2016 + .help_msg = "conteXt",
2017 + .action_msg = "Show Context Info",
2018 + .enable_mask = SYSRQ_ENABLE_DUMP,
2022 /* Key Operations table and lock */
2023 static DEFINE_SPINLOCK(sysrq_key_table_lock);
2025 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
2027 &sysrq_showstate_blocked_op, /* w */
2028 /* x: May be registered on ppc/powerpc for xmon */
2029 +#ifdef CONFIG_VSERVER_DEBUG
2030 + &sysrq_showvxinfo_op, /* x */
2034 /* y: May be registered on sparc64 for global register dump */
2036 &sysrq_ftrace_dump_op, /* z */
2037 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
2039 else if ((key >= 'a') && (key <= 'z'))
2040 retval = key + 10 - 'a';
2041 + else if ((key >= 'A') && (key <= 'Z'))
2042 + retval = key + 10 - 'A';
2046 diff -NurpP --minimal linux-2.6.38.1/drivers/tty/tty_io.c linux-2.6.38.1-vs2.3.0.37-rc9/drivers/tty/tty_io.c
2047 --- linux-2.6.38.1/drivers/tty/tty_io.c 2011-03-15 18:07:26.000000000 +0100
2048 +++ linux-2.6.38.1-vs2.3.0.37-rc9/drivers/tty/tty_io.c 2011-02-02 22:20:24.000000000 +0100
2051 #include <linux/kmod.h>
2052 #include <linux/nsproxy.h>
2053 +#include <linux/vs_pid.h>
2055 #undef TTY_DEBUG_HANGUP
2057 @@ -2057,7 +2058,8 @@ static int tiocsti(struct tty_struct *tt
2059 struct tty_ldisc *ld;
2061 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
2062 + if (((current->signal->tty != tty) &&
2063 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
2065 if (get_user(ch, p))
2067 @@ -2345,6 +2347,7 @@ static int tiocspgrp(struct tty_struct *
2069 if (get_user(pgrp_nr, p))
2071 + pgrp_nr = vx_rmap_pid(pgrp_nr);
2075 diff -NurpP --minimal linux-2.6.38.1/fs/attr.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/attr.c
2076 --- linux-2.6.38.1/fs/attr.c 2010-10-21 13:07:47.000000000 +0200
2077 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/attr.c 2011-01-29 02:01:07.000000000 +0100
2079 #include <linux/fsnotify.h>
2080 #include <linux/fcntl.h>
2081 #include <linux/security.h>
2082 +#include <linux/proc_fs.h>
2083 +#include <linux/devpts_fs.h>
2084 +#include <linux/vs_tag.h>
2087 * inode_change_ok - check if attribute changes to an inode are allowed
2088 @@ -73,6 +76,10 @@ int inode_change_ok(const struct inode *
2092 + /* check for inode tag permission */
2093 + if (dx_permission(inode, MAY_WRITE))
2098 EXPORT_SYMBOL(inode_change_ok);
2099 @@ -143,6 +150,8 @@ void setattr_copy(struct inode *inode, c
2100 inode->i_uid = attr->ia_uid;
2101 if (ia_valid & ATTR_GID)
2102 inode->i_gid = attr->ia_gid;
2103 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2104 + inode->i_tag = attr->ia_tag;
2105 if (ia_valid & ATTR_ATIME)
2106 inode->i_atime = timespec_trunc(attr->ia_atime,
2107 inode->i_sb->s_time_gran);
2108 @@ -170,7 +179,8 @@ int notify_change(struct dentry * dentry
2109 struct timespec now;
2110 unsigned int ia_valid = attr->ia_valid;
2112 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
2113 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
2114 + ATTR_TAG | ATTR_TIMES_SET)) {
2115 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
2118 diff -NurpP --minimal linux-2.6.38.1/fs/binfmt_aout.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/binfmt_aout.c
2119 --- linux-2.6.38.1/fs/binfmt_aout.c 2010-10-21 13:07:47.000000000 +0200
2120 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/binfmt_aout.c 2011-01-29 02:01:07.000000000 +0100
2122 #include <linux/init.h>
2123 #include <linux/coredump.h>
2124 #include <linux/slab.h>
2125 +#include <linux/vs_memory.h>
2127 #include <asm/system.h>
2128 #include <asm/uaccess.h>
2129 diff -NurpP --minimal linux-2.6.38.1/fs/binfmt_elf.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/binfmt_elf.c
2130 --- linux-2.6.38.1/fs/binfmt_elf.c 2011-03-15 18:07:31.000000000 +0100
2131 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/binfmt_elf.c 2011-01-29 02:01:07.000000000 +0100
2133 #include <linux/elf.h>
2134 #include <linux/utsname.h>
2135 #include <linux/coredump.h>
2136 +#include <linux/vs_memory.h>
2137 #include <asm/uaccess.h>
2138 #include <asm/param.h>
2139 #include <asm/page.h>
2140 diff -NurpP --minimal linux-2.6.38.1/fs/binfmt_flat.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/binfmt_flat.c
2141 --- linux-2.6.38.1/fs/binfmt_flat.c 2010-08-02 16:52:47.000000000 +0200
2142 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/binfmt_flat.c 2011-01-29 02:01:07.000000000 +0100
2144 #include <linux/init.h>
2145 #include <linux/flat.h>
2146 #include <linux/syscalls.h>
2147 +#include <linux/vs_memory.h>
2149 #include <asm/byteorder.h>
2150 #include <asm/system.h>
2151 diff -NurpP --minimal linux-2.6.38.1/fs/binfmt_som.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/binfmt_som.c
2152 --- linux-2.6.38.1/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
2153 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/binfmt_som.c 2011-01-29 02:01:07.000000000 +0100
2155 #include <linux/shm.h>
2156 #include <linux/personality.h>
2157 #include <linux/init.h>
2158 +#include <linux/vs_memory.h>
2160 #include <asm/uaccess.h>
2161 #include <asm/pgtable.h>
2162 diff -NurpP --minimal linux-2.6.38.1/fs/block_dev.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/block_dev.c
2163 --- linux-2.6.38.1/fs/block_dev.c 2011-03-15 18:07:31.000000000 +0100
2164 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/block_dev.c 2011-03-07 16:53:27.000000000 +0100
2166 #include <linux/namei.h>
2167 #include <linux/log2.h>
2168 #include <linux/kmemleak.h>
2169 +#include <linux/vs_device.h>
2170 #include <asm/uaccess.h>
2171 #include "internal.h"
2173 @@ -551,6 +552,7 @@ struct block_device *bdget(dev_t dev)
2174 bdev->bd_invalidated = 0;
2175 inode->i_mode = S_IFBLK;
2176 inode->i_rdev = dev;
2177 + inode->i_mdev = dev;
2178 inode->i_bdev = bdev;
2179 inode->i_data.a_ops = &def_blk_aops;
2180 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2181 @@ -597,6 +599,11 @@ EXPORT_SYMBOL(bdput);
2182 static struct block_device *bd_acquire(struct inode *inode)
2184 struct block_device *bdev;
2187 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2189 + inode->i_mdev = mdev;
2191 spin_lock(&bdev_lock);
2192 bdev = inode->i_bdev;
2193 @@ -607,7 +614,7 @@ static struct block_device *bd_acquire(s
2195 spin_unlock(&bdev_lock);
2197 - bdev = bdget(inode->i_rdev);
2198 + bdev = bdget(mdev);
2200 spin_lock(&bdev_lock);
2201 if (!inode->i_bdev) {
2202 diff -NurpP --minimal linux-2.6.38.1/fs/btrfs/ctree.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/btrfs/ctree.h
2203 --- linux-2.6.38.1/fs/btrfs/ctree.h 2011-03-15 18:07:31.000000000 +0100
2204 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/btrfs/ctree.h 2011-03-15 18:15:06.000000000 +0100
2205 @@ -587,11 +587,14 @@ struct btrfs_inode_item {
2206 /* modification sequence number for NFS */
2211 * a little future expansion, for more than this we can
2212 * just grow the inode item and version it
2214 - __le64 reserved[4];
2215 + __le16 reserved16;
2216 + __le32 reserved32;
2217 + __le64 reserved[3];
2218 struct btrfs_timespec atime;
2219 struct btrfs_timespec ctime;
2220 struct btrfs_timespec mtime;
2221 @@ -1265,6 +1268,8 @@ struct btrfs_root {
2222 #define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14)
2223 #define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15)
2225 +#define BTRFS_MOUNT_TAGGED (1 << 24)
2227 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
2228 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
2229 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
2230 @@ -1485,6 +1490,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
2231 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
2232 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
2233 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
2234 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
2235 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
2236 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
2237 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
2238 @@ -1546,6 +1552,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
2240 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
2242 +#define BTRFS_INODE_IXUNLINK (1 << 24)
2243 +#define BTRFS_INODE_BARRIER (1 << 25)
2244 +#define BTRFS_INODE_COW (1 << 26)
2247 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
2249 @@ -2553,6 +2563,7 @@ extern const struct dentry_operations bt
2250 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2251 void btrfs_update_iflags(struct inode *inode);
2252 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2253 +int btrfs_sync_flags(struct inode *inode, int, int);
2256 int btrfs_sync_file(struct file *file, int datasync);
2257 diff -NurpP --minimal linux-2.6.38.1/fs/btrfs/disk-io.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/btrfs/disk-io.c
2258 --- linux-2.6.38.1/fs/btrfs/disk-io.c 2011-03-15 18:07:31.000000000 +0100
2259 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/btrfs/disk-io.c 2011-02-17 02:17:50.000000000 +0100
2260 @@ -1768,6 +1768,9 @@ struct btrfs_root *open_ctree(struct sup
2264 + if (btrfs_test_opt(tree_root, TAGGED))
2265 + sb->s_flags |= MS_TAGGED;
2267 features = btrfs_super_incompat_flags(disk_super) &
2268 ~BTRFS_FEATURE_INCOMPAT_SUPP;
2270 diff -NurpP --minimal linux-2.6.38.1/fs/btrfs/inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/btrfs/inode.c
2271 --- linux-2.6.38.1/fs/btrfs/inode.c 2011-03-15 18:07:31.000000000 +0100
2272 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/btrfs/inode.c 2011-03-15 18:15:06.000000000 +0100
2274 #include <linux/posix_acl.h>
2275 #include <linux/falloc.h>
2276 #include <linux/slab.h>
2277 +#include <linux/vs_tag.h>
2281 #include "disk-io.h"
2282 @@ -2463,6 +2465,8 @@ static void btrfs_read_locked_inode(stru
2284 u64 alloc_group_block;
2290 path = btrfs_alloc_path();
2291 @@ -2479,8 +2483,13 @@ static void btrfs_read_locked_inode(stru
2293 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
2294 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
2295 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
2296 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
2298 + uid = btrfs_inode_uid(leaf, inode_item);
2299 + gid = btrfs_inode_gid(leaf, inode_item);
2300 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2301 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2302 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2303 + btrfs_inode_tag(leaf, inode_item));
2304 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
2306 tspec = btrfs_inode_atime(inode_item);
2307 @@ -2562,8 +2571,15 @@ static void fill_inode_item(struct btrfs
2308 struct btrfs_inode_item *item,
2309 struct inode *inode)
2311 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
2312 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
2313 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2314 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2316 + btrfs_set_inode_uid(leaf, item, uid);
2317 + btrfs_set_inode_gid(leaf, item, gid);
2318 +#ifdef CONFIG_TAGGING_INTERN
2319 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
2322 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
2323 btrfs_set_inode_mode(leaf, item, inode->i_mode);
2324 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
2325 @@ -7293,6 +7309,7 @@ static const struct inode_operations btr
2326 .listxattr = btrfs_listxattr,
2327 .removexattr = btrfs_removexattr,
2328 .permission = btrfs_permission,
2329 + .sync_flags = btrfs_sync_flags,
2331 static const struct inode_operations btrfs_dir_ro_inode_operations = {
2332 .lookup = btrfs_lookup,
2333 @@ -7367,6 +7384,7 @@ static const struct inode_operations btr
2334 .removexattr = btrfs_removexattr,
2335 .permission = btrfs_permission,
2336 .fiemap = btrfs_fiemap,
2337 + .sync_flags = btrfs_sync_flags,
2339 static const struct inode_operations btrfs_special_inode_operations = {
2340 .getattr = btrfs_getattr,
2341 diff -NurpP --minimal linux-2.6.38.1/fs/btrfs/ioctl.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/btrfs/ioctl.c
2342 --- linux-2.6.38.1/fs/btrfs/ioctl.c 2011-03-15 18:07:31.000000000 +0100
2343 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/btrfs/ioctl.c 2011-03-07 16:53:27.000000000 +0100
2344 @@ -68,10 +68,13 @@ static unsigned int btrfs_flags_to_ioctl
2346 unsigned int iflags = 0;
2348 - if (flags & BTRFS_INODE_SYNC)
2349 - iflags |= FS_SYNC_FL;
2350 if (flags & BTRFS_INODE_IMMUTABLE)
2351 iflags |= FS_IMMUTABLE_FL;
2352 + if (flags & BTRFS_INODE_IXUNLINK)
2353 + iflags |= FS_IXUNLINK_FL;
2355 + if (flags & BTRFS_INODE_SYNC)
2356 + iflags |= FS_SYNC_FL;
2357 if (flags & BTRFS_INODE_APPEND)
2358 iflags |= FS_APPEND_FL;
2359 if (flags & BTRFS_INODE_NODUMP)
2360 @@ -81,28 +84,78 @@ static unsigned int btrfs_flags_to_ioctl
2361 if (flags & BTRFS_INODE_DIRSYNC)
2362 iflags |= FS_DIRSYNC_FL;
2364 + if (flags & BTRFS_INODE_BARRIER)
2365 + iflags |= FS_BARRIER_FL;
2366 + if (flags & BTRFS_INODE_COW)
2367 + iflags |= FS_COW_FL;
2372 - * Update inode->i_flags based on the btrfs internal flags.
2373 + * Update inode->i_(v)flags based on the btrfs internal flags.
2375 void btrfs_update_iflags(struct inode *inode)
2377 struct btrfs_inode *ip = BTRFS_I(inode);
2379 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2380 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2381 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2383 - if (ip->flags & BTRFS_INODE_SYNC)
2384 - inode->i_flags |= S_SYNC;
2385 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2386 inode->i_flags |= S_IMMUTABLE;
2387 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2388 + inode->i_flags |= S_IXUNLINK;
2390 + if (ip->flags & BTRFS_INODE_SYNC)
2391 + inode->i_flags |= S_SYNC;
2392 if (ip->flags & BTRFS_INODE_APPEND)
2393 inode->i_flags |= S_APPEND;
2394 if (ip->flags & BTRFS_INODE_NOATIME)
2395 inode->i_flags |= S_NOATIME;
2396 if (ip->flags & BTRFS_INODE_DIRSYNC)
2397 inode->i_flags |= S_DIRSYNC;
2399 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2401 + if (ip->flags & BTRFS_INODE_BARRIER)
2402 + inode->i_vflags |= V_BARRIER;
2403 + if (ip->flags & BTRFS_INODE_COW)
2404 + inode->i_vflags |= V_COW;
2408 + * Update btrfs internal flags from inode->i_(v)flags.
2410 +void btrfs_update_flags(struct inode *inode)
2412 + struct btrfs_inode *ip = BTRFS_I(inode);
2414 + unsigned int flags = inode->i_flags;
2415 + unsigned int vflags = inode->i_vflags;
2417 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2418 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2419 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2420 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2422 + if (flags & S_IMMUTABLE)
2423 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2424 + if (flags & S_IXUNLINK)
2425 + ip->flags |= BTRFS_INODE_IXUNLINK;
2427 + if (flags & S_SYNC)
2428 + ip->flags |= BTRFS_INODE_SYNC;
2429 + if (flags & S_APPEND)
2430 + ip->flags |= BTRFS_INODE_APPEND;
2431 + if (flags & S_NOATIME)
2432 + ip->flags |= BTRFS_INODE_NOATIME;
2433 + if (flags & S_DIRSYNC)
2434 + ip->flags |= BTRFS_INODE_DIRSYNC;
2436 + if (vflags & V_BARRIER)
2437 + ip->flags |= BTRFS_INODE_BARRIER;
2438 + if (vflags & V_COW)
2439 + ip->flags |= BTRFS_INODE_COW;
2443 @@ -120,7 +173,7 @@ void btrfs_inherit_iflags(struct inode *
2444 flags = BTRFS_I(dir)->flags;
2446 if (S_ISREG(inode->i_mode))
2447 - flags &= ~BTRFS_INODE_DIRSYNC;
2448 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2449 else if (!S_ISDIR(inode->i_mode))
2450 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2452 @@ -128,6 +181,30 @@ void btrfs_inherit_iflags(struct inode *
2453 btrfs_update_iflags(inode);
2456 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2458 + struct btrfs_inode *ip = BTRFS_I(inode);
2459 + struct btrfs_root *root = ip->root;
2460 + struct btrfs_trans_handle *trans;
2463 + trans = btrfs_join_transaction(root, 1);
2466 + inode->i_flags = flags;
2467 + inode->i_vflags = vflags;
2468 + btrfs_update_flags(inode);
2470 + ret = btrfs_update_inode(trans, root, inode);
2473 + btrfs_update_iflags(inode);
2474 + inode->i_ctime = CURRENT_TIME;
2475 + btrfs_end_transaction(trans, root);
2480 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2482 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2483 @@ -153,6 +230,7 @@ static int btrfs_ioctl_setflags(struct f
2484 if (copy_from_user(&flags, arg, sizeof(flags)))
2487 + /* maybe add FS_IXUNLINK_FL ? */
2488 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
2489 FS_NOATIME_FL | FS_NODUMP_FL | \
2490 FS_SYNC_FL | FS_DIRSYNC_FL))
2491 @@ -165,7 +243,8 @@ static int btrfs_ioctl_setflags(struct f
2493 flags = btrfs_mask_flags(inode->i_mode, flags);
2494 oldflags = btrfs_flags_to_ioctl(ip->flags);
2495 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2496 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2497 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2498 if (!capable(CAP_LINUX_IMMUTABLE)) {
2501 @@ -176,14 +255,19 @@ static int btrfs_ioctl_setflags(struct f
2505 - if (flags & FS_SYNC_FL)
2506 - ip->flags |= BTRFS_INODE_SYNC;
2508 - ip->flags &= ~BTRFS_INODE_SYNC;
2509 if (flags & FS_IMMUTABLE_FL)
2510 ip->flags |= BTRFS_INODE_IMMUTABLE;
2512 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2513 + if (flags & FS_IXUNLINK_FL)
2514 + ip->flags |= BTRFS_INODE_IXUNLINK;
2516 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2518 + if (flags & FS_SYNC_FL)
2519 + ip->flags |= BTRFS_INODE_SYNC;
2521 + ip->flags &= ~BTRFS_INODE_SYNC;
2522 if (flags & FS_APPEND_FL)
2523 ip->flags |= BTRFS_INODE_APPEND;
2525 diff -NurpP --minimal linux-2.6.38.1/fs/btrfs/super.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/btrfs/super.c
2526 --- linux-2.6.38.1/fs/btrfs/super.c 2011-03-15 18:07:31.000000000 +0100
2527 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/btrfs/super.c 2011-03-07 17:04:18.000000000 +0100
2528 @@ -155,8 +155,8 @@ enum {
2529 Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress,
2530 Opt_compress_type, Opt_compress_force, Opt_compress_force_type,
2531 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
2532 - Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
2533 - Opt_enospc_debug, Opt_err,
2534 + Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
2535 + Opt_enospc_debug, Opt_tag, Opt_notag, Opt_tagid, Opt_err,
2538 static match_table_t tokens = {
2539 @@ -186,6 +186,9 @@ static match_table_t tokens = {
2540 {Opt_clear_cache, "clear_cache"},
2541 {Opt_user_subvol_rm_allowed, "user_subvol_rm_allowed"},
2542 {Opt_enospc_debug, "enospc_debug"},
2544 + {Opt_notag, "notag"},
2545 + {Opt_tagid, "tagid=%u"},
2549 @@ -363,6 +366,22 @@ int btrfs_parse_options(struct btrfs_roo
2550 case Opt_enospc_debug:
2551 btrfs_set_opt(info->mount_opt, ENOSPC_DEBUG);
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 @@ -841,6 +860,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.38.1/fs/char_dev.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/char_dev.c
2586 --- linux-2.6.38.1/fs/char_dev.c 2011-03-15 18:07:31.000000000 +0100
2587 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/char_dev.c 2011-01-29 02:01:07.000000000 +0100
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.38.1/fs/dcache.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/dcache.c
2621 --- linux-2.6.38.1/fs/dcache.c 2011-03-26 01:10:17.000000000 +0100
2622 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/dcache.c 2011-03-25 22:52:15.000000000 +0100
2624 #include <linux/hardirq.h>
2625 #include <linux/bit_spinlock.h>
2626 #include <linux/rculist_bl.h>
2627 +#include <linux/vs_limit.h>
2628 #include "internal.h"
2631 @@ -500,6 +501,8 @@ int d_invalidate(struct dentry * dentry)
2632 spin_lock(&dentry->d_lock);
2635 + vx_dentry_dec(dentry);
2638 * Somebody else still using it?
2640 @@ -527,6 +530,7 @@ EXPORT_SYMBOL(d_invalidate);
2641 static inline void __dget_dlock(struct dentry *dentry)
2644 + vx_dentry_inc(dentry);
2647 static inline void __dget(struct dentry *dentry)
2648 @@ -1283,6 +1287,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 @@ -1304,6 +1311,7 @@ struct dentry *d_alloc(struct dentry * p
2659 dname[name->len] = 0;
2661 dentry->d_count = 1;
2662 + vx_dentry_inc(dentry);
2663 dentry->d_flags = DCACHE_UNHASHED;
2664 spin_lock_init(&dentry->d_lock);
2665 seqcount_init(&dentry->d_seq);
2666 @@ -1962,6 +1970,7 @@ struct dentry *__d_lookup(struct dentry
2670 + vx_dentry_inc(dentry);
2672 spin_unlock(&dentry->d_lock);
2674 diff -NurpP --minimal linux-2.6.38.1/fs/devpts/inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/devpts/inode.c
2675 --- linux-2.6.38.1/fs/devpts/inode.c 2011-01-05 21:50:22.000000000 +0100
2676 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/devpts/inode.c 2011-03-17 02:17:19.000000000 +0100
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, unsigned int flags)
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, flags, 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,34 @@ static int devpts_show_options(struct se
2710 +static int devpts_filter(struct dentry *de)
2714 + /* devpts is xid tagged */
2715 + if (de && de->d_inode)
2716 + xid = (xid_t)de->d_inode->i_tag;
2717 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2719 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2720 + de->d_name.len, de->d_name.name);
2722 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2725 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2727 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2730 +static struct file_operations devpts_dir_operations = {
2731 + .open = dcache_dir_open,
2732 + .release = dcache_dir_close,
2733 + .llseek = dcache_dir_lseek,
2734 + .read = generic_read_dir,
2735 + .readdir = devpts_readdir,
2738 static const struct super_operations devpts_sops = {
2739 .statfs = simple_statfs,
2740 .remount_fs = devpts_remount,
2741 @@ -302,12 +345,15 @@ devpts_fill_super(struct super_block *s,
2742 inode = new_inode(s);
2747 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2748 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2749 inode->i_op = &simple_dir_inode_operations;
2750 - inode->i_fop = &simple_dir_operations;
2751 + inode->i_fop = &devpts_dir_operations;
2753 + /* devpts is xid tagged */
2754 + inode->i_tag = (tag_t)vx_current_xid();
2756 s->s_root = d_alloc_root(inode);
2758 @@ -493,6 +539,9 @@ int devpts_pty_new(struct inode *ptmx_in
2759 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2760 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2761 init_special_inode(inode, S_IFCHR|opts->mode, device);
2762 + /* devpts is xid tagged */
2763 + inode->i_tag = (tag_t)vx_current_xid();
2764 + inode->i_op = &devpts_file_inode_operations;
2765 inode->i_private = tty;
2766 tty->driver_data = inode;
2768 diff -NurpP --minimal linux-2.6.38.1/fs/ext2/balloc.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/balloc.c
2769 --- linux-2.6.38.1/fs/ext2/balloc.c 2011-01-05 21:50:22.000000000 +0100
2770 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/balloc.c 2011-01-29 02:01:07.000000000 +0100
2771 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2773 end = EXT2_BLOCKS_PER_GROUP(sb);
2776 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2779 diff -NurpP --minimal linux-2.6.38.1/fs/ext2/ext2.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/ext2.h
2780 --- linux-2.6.38.1/fs/ext2/ext2.h 2011-01-05 21:50:22.000000000 +0100
2781 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/ext2.h 2011-01-29 02:01:07.000000000 +0100
2782 @@ -126,6 +126,7 @@ extern void ext2_set_inode_flags(struct
2783 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2784 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2785 u64 start, u64 len);
2786 +extern int ext2_sync_flags(struct inode *, int, int);
2789 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2790 diff -NurpP --minimal linux-2.6.38.1/fs/ext2/file.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/file.c
2791 --- linux-2.6.38.1/fs/ext2/file.c 2010-08-02 16:52:48.000000000 +0200
2792 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/file.c 2011-01-29 02:01:07.000000000 +0100
2793 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2794 .setattr = ext2_setattr,
2795 .check_acl = ext2_check_acl,
2796 .fiemap = ext2_fiemap,
2797 + .sync_flags = ext2_sync_flags,
2799 diff -NurpP --minimal linux-2.6.38.1/fs/ext2/ialloc.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/ialloc.c
2800 --- linux-2.6.38.1/fs/ext2/ialloc.c 2010-10-21 13:07:48.000000000 +0200
2801 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/ialloc.c 2011-01-29 02:01:07.000000000 +0100
2803 #include <linux/backing-dev.h>
2804 #include <linux/buffer_head.h>
2805 #include <linux/random.h>
2806 +#include <linux/vs_tag.h>
2810 @@ -548,6 +549,7 @@ got:
2811 inode->i_mode = mode;
2812 inode->i_uid = current_fsuid();
2813 inode->i_gid = dir->i_gid;
2814 + inode->i_tag = dx_current_fstag(sb);
2816 inode_init_owner(inode, dir, mode);
2818 diff -NurpP --minimal linux-2.6.38.1/fs/ext2/inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/inode.c
2819 --- linux-2.6.38.1/fs/ext2/inode.c 2011-01-05 21:50:22.000000000 +0100
2820 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/inode.c 2011-01-29 02:01:07.000000000 +0100
2822 #include <linux/mpage.h>
2823 #include <linux/fiemap.h>
2824 #include <linux/namei.h>
2825 +#include <linux/vs_tag.h>
2829 @@ -1169,7 +1170,7 @@ static void ext2_truncate_blocks(struct
2831 if (ext2_inode_is_fast_symlink(inode))
2833 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2834 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2836 __ext2_truncate_blocks(inode, offset);
2838 @@ -1258,36 +1259,61 @@ void ext2_set_inode_flags(struct inode *
2840 unsigned int flags = EXT2_I(inode)->i_flags;
2842 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2843 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2844 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2847 + if (flags & EXT2_IMMUTABLE_FL)
2848 + inode->i_flags |= S_IMMUTABLE;
2849 + if (flags & EXT2_IXUNLINK_FL)
2850 + inode->i_flags |= S_IXUNLINK;
2852 if (flags & EXT2_SYNC_FL)
2853 inode->i_flags |= S_SYNC;
2854 if (flags & EXT2_APPEND_FL)
2855 inode->i_flags |= S_APPEND;
2856 - if (flags & EXT2_IMMUTABLE_FL)
2857 - inode->i_flags |= S_IMMUTABLE;
2858 if (flags & EXT2_NOATIME_FL)
2859 inode->i_flags |= S_NOATIME;
2860 if (flags & EXT2_DIRSYNC_FL)
2861 inode->i_flags |= S_DIRSYNC;
2863 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2865 + if (flags & EXT2_BARRIER_FL)
2866 + inode->i_vflags |= V_BARRIER;
2867 + if (flags & EXT2_COW_FL)
2868 + inode->i_vflags |= V_COW;
2871 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2872 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2874 unsigned int flags = ei->vfs_inode.i_flags;
2875 + unsigned int vflags = ei->vfs_inode.i_vflags;
2877 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2878 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2879 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2880 + EXT2_BARRIER_FL | EXT2_COW_FL);
2882 + if (flags & S_IMMUTABLE)
2883 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2884 + if (flags & S_IXUNLINK)
2885 + ei->i_flags |= EXT2_IXUNLINK_FL;
2887 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2888 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2890 ei->i_flags |= EXT2_SYNC_FL;
2891 if (flags & S_APPEND)
2892 ei->i_flags |= EXT2_APPEND_FL;
2893 - if (flags & S_IMMUTABLE)
2894 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2895 if (flags & S_NOATIME)
2896 ei->i_flags |= EXT2_NOATIME_FL;
2897 if (flags & S_DIRSYNC)
2898 ei->i_flags |= EXT2_DIRSYNC_FL;
2900 + if (vflags & V_BARRIER)
2901 + ei->i_flags |= EXT2_BARRIER_FL;
2902 + if (vflags & V_COW)
2903 + ei->i_flags |= EXT2_COW_FL;
2906 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2907 @@ -1297,6 +1323,8 @@ struct inode *ext2_iget (struct super_bl
2908 struct ext2_inode *raw_inode;
2909 struct inode *inode;
2915 inode = iget_locked(sb, ino);
2916 @@ -1315,12 +1343,17 @@ struct inode *ext2_iget (struct super_bl
2919 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2920 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2921 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2922 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2923 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2924 if (!(test_opt (inode->i_sb, NO_UID32))) {
2925 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2926 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2927 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2928 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2930 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2931 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2932 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2933 + le16_to_cpu(raw_inode->i_raw_tag));
2935 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2936 inode->i_size = le32_to_cpu(raw_inode->i_size);
2937 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2938 @@ -1418,8 +1451,8 @@ static int __ext2_write_inode(struct ino
2939 struct ext2_inode_info *ei = EXT2_I(inode);
2940 struct super_block *sb = inode->i_sb;
2941 ino_t ino = inode->i_ino;
2942 - uid_t uid = inode->i_uid;
2943 - gid_t gid = inode->i_gid;
2944 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2945 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2946 struct buffer_head * bh;
2947 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2949 @@ -1455,6 +1488,9 @@ static int __ext2_write_inode(struct ino
2950 raw_inode->i_uid_high = 0;
2951 raw_inode->i_gid_high = 0;
2953 +#ifdef CONFIG_TAGGING_INTERN
2954 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2956 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2957 raw_inode->i_size = cpu_to_le32(inode->i_size);
2958 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2959 @@ -1535,7 +1571,8 @@ int ext2_setattr(struct dentry *dentry,
2960 if (is_quota_modification(inode, iattr))
2961 dquot_initialize(inode);
2962 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2963 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2964 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2965 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2966 error = dquot_transfer(inode, iattr);
2969 diff -NurpP --minimal linux-2.6.38.1/fs/ext2/ioctl.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/ioctl.c
2970 --- linux-2.6.38.1/fs/ext2/ioctl.c 2009-09-10 15:26:21.000000000 +0200
2971 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/ioctl.c 2011-01-29 02:01:07.000000000 +0100
2973 #include <asm/uaccess.h>
2976 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2978 + inode->i_flags = flags;
2979 + inode->i_vflags = vflags;
2980 + ext2_get_inode_flags(EXT2_I(inode));
2981 + inode->i_ctime = CURRENT_TIME_SEC;
2982 + mark_inode_dirty(inode);
2986 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2988 struct inode *inode = filp->f_dentry->d_inode;
2989 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2991 flags = ext2_mask_flags(inode->i_mode, flags);
2993 + if (IS_BARRIER(inode)) {
2994 + vxwprintk_task(1, "messing with the barrier.");
2998 mutex_lock(&inode->i_mutex);
2999 /* Is it quota file? Do not allow user to mess with it */
3000 if (IS_NOQUOTA(inode)) {
3001 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
3003 * This test looks nicer. Thanks to Pauline Middelink
3005 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
3006 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
3007 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
3008 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
3009 if (!capable(CAP_LINUX_IMMUTABLE)) {
3010 mutex_unlock(&inode->i_mutex);
3012 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
3016 - flags = flags & EXT2_FL_USER_MODIFIABLE;
3017 + flags &= EXT2_FL_USER_MODIFIABLE;
3018 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
3019 ei->i_flags = flags;
3020 mutex_unlock(&inode->i_mutex);
3021 diff -NurpP --minimal linux-2.6.38.1/fs/ext2/namei.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/namei.c
3022 --- linux-2.6.38.1/fs/ext2/namei.c 2011-03-15 18:07:31.000000000 +0100
3023 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/namei.c 2011-03-10 17:21:19.000000000 +0100
3026 #include <linux/pagemap.h>
3027 #include <linux/quotaops.h>
3028 +#include <linux/vs_tag.h>
3032 @@ -75,6 +76,7 @@ static struct dentry *ext2_lookup(struct
3033 return ERR_PTR(-EIO);
3035 return ERR_CAST(inode);
3036 + dx_propagate_tag(nd, inode);
3040 @@ -413,6 +415,7 @@ const struct inode_operations ext2_dir_i
3042 .setattr = ext2_setattr,
3043 .check_acl = ext2_check_acl,
3044 + .sync_flags = ext2_sync_flags,
3047 const struct inode_operations ext2_special_inode_operations = {
3048 diff -NurpP --minimal linux-2.6.38.1/fs/ext2/super.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/super.c
3049 --- linux-2.6.38.1/fs/ext2/super.c 2011-03-15 18:07:31.000000000 +0100
3050 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext2/super.c 2011-01-29 02:01:07.000000000 +0100
3051 @@ -394,7 +394,8 @@ enum {
3052 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3053 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3054 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3055 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
3056 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
3057 + Opt_tag, Opt_notag, Opt_tagid
3060 static const match_table_t tokens = {
3061 @@ -422,6 +423,9 @@ static const match_table_t tokens = {
3063 {Opt_noacl, "noacl"},
3066 + {Opt_notag, "notag"},
3067 + {Opt_tagid, "tagid=%u"},
3068 {Opt_grpquota, "grpquota"},
3069 {Opt_ignore, "noquota"},
3070 {Opt_quota, "quota"},
3071 @@ -492,6 +496,20 @@ static int parse_options(char *options,
3073 set_opt (sbi->s_mount_opt, NO_UID32);
3075 +#ifndef CONFIG_TAGGING_NONE
3077 + set_opt (sbi->s_mount_opt, TAGGED);
3080 + clear_opt (sbi->s_mount_opt, TAGGED);
3083 +#ifdef CONFIG_PROPAGATE
3086 + set_opt (sbi->s_mount_opt, TAGGED);
3090 clear_opt (sbi->s_mount_opt, CHECK);
3092 @@ -850,6 +868,8 @@ static int ext2_fill_super(struct super_
3093 if (!parse_options((char *) data, sb))
3096 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3097 + sb->s_flags |= MS_TAGGED;
3098 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3099 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3101 @@ -1223,6 +1243,14 @@ static int ext2_remount (struct super_bl
3105 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3106 + !(sb->s_flags & MS_TAGGED)) {
3107 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3110 + goto restore_opts;
3113 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3114 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3116 diff -NurpP --minimal linux-2.6.38.1/fs/ext3/file.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext3/file.c
3117 --- linux-2.6.38.1/fs/ext3/file.c 2010-07-07 18:31:51.000000000 +0200
3118 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext3/file.c 2011-01-29 02:01:07.000000000 +0100
3119 @@ -81,5 +81,6 @@ const struct inode_operations ext3_file_
3121 .check_acl = ext3_check_acl,
3122 .fiemap = ext3_fiemap,
3123 + .sync_flags = ext3_sync_flags,
3126 diff -NurpP --minimal linux-2.6.38.1/fs/ext3/ialloc.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext3/ialloc.c
3127 --- linux-2.6.38.1/fs/ext3/ialloc.c 2011-01-05 21:50:22.000000000 +0100
3128 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext3/ialloc.c 2011-01-29 02:01:07.000000000 +0100
3130 #include <linux/buffer_head.h>
3131 #include <linux/random.h>
3132 #include <linux/bitops.h>
3133 +#include <linux/vs_tag.h>
3135 #include <asm/byteorder.h>
3137 @@ -531,6 +532,7 @@ got:
3138 inode->i_mode = mode;
3139 inode->i_uid = current_fsuid();
3140 inode->i_gid = dir->i_gid;
3141 + inode->i_tag = dx_current_fstag(sb);
3143 inode_init_owner(inode, dir, mode);
3145 diff -NurpP --minimal linux-2.6.38.1/fs/ext3/inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext3/inode.c
3146 --- linux-2.6.38.1/fs/ext3/inode.c 2011-03-15 18:07:31.000000000 +0100
3147 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext3/inode.c 2011-01-29 02:01:07.000000000 +0100
3149 #include <linux/bio.h>
3150 #include <linux/fiemap.h>
3151 #include <linux/namei.h>
3152 +#include <linux/vs_tag.h>
3156 @@ -2394,7 +2395,7 @@ static void ext3_free_branches(handle_t
3158 int ext3_can_truncate(struct inode *inode)
3160 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3161 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3163 if (S_ISREG(inode->i_mode))
3165 @@ -2778,36 +2779,60 @@ void ext3_set_inode_flags(struct inode *
3167 unsigned int flags = EXT3_I(inode)->i_flags;
3169 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3170 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3171 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3173 + if (flags & EXT3_IMMUTABLE_FL)
3174 + inode->i_flags |= S_IMMUTABLE;
3175 + if (flags & EXT3_IXUNLINK_FL)
3176 + inode->i_flags |= S_IXUNLINK;
3178 if (flags & EXT3_SYNC_FL)
3179 inode->i_flags |= S_SYNC;
3180 if (flags & EXT3_APPEND_FL)
3181 inode->i_flags |= S_APPEND;
3182 - if (flags & EXT3_IMMUTABLE_FL)
3183 - inode->i_flags |= S_IMMUTABLE;
3184 if (flags & EXT3_NOATIME_FL)
3185 inode->i_flags |= S_NOATIME;
3186 if (flags & EXT3_DIRSYNC_FL)
3187 inode->i_flags |= S_DIRSYNC;
3189 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3191 + if (flags & EXT3_BARRIER_FL)
3192 + inode->i_vflags |= V_BARRIER;
3193 + if (flags & EXT3_COW_FL)
3194 + inode->i_vflags |= V_COW;
3197 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
3198 void ext3_get_inode_flags(struct ext3_inode_info *ei)
3200 unsigned int flags = ei->vfs_inode.i_flags;
3201 + unsigned int vflags = ei->vfs_inode.i_vflags;
3203 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
3204 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
3205 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
3206 + EXT3_BARRIER_FL | EXT3_COW_FL);
3208 + if (flags & S_IMMUTABLE)
3209 + ei->i_flags |= EXT3_IMMUTABLE_FL;
3210 + if (flags & S_IXUNLINK)
3211 + ei->i_flags |= EXT3_IXUNLINK_FL;
3213 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
3214 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
3216 ei->i_flags |= EXT3_SYNC_FL;
3217 if (flags & S_APPEND)
3218 ei->i_flags |= EXT3_APPEND_FL;
3219 - if (flags & S_IMMUTABLE)
3220 - ei->i_flags |= EXT3_IMMUTABLE_FL;
3221 if (flags & S_NOATIME)
3222 ei->i_flags |= EXT3_NOATIME_FL;
3223 if (flags & S_DIRSYNC)
3224 ei->i_flags |= EXT3_DIRSYNC_FL;
3226 + if (vflags & V_BARRIER)
3227 + ei->i_flags |= EXT3_BARRIER_FL;
3228 + if (vflags & V_COW)
3229 + ei->i_flags |= EXT3_COW_FL;
3232 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3233 @@ -2821,6 +2846,8 @@ struct inode *ext3_iget(struct super_blo
3234 transaction_t *transaction;
3240 inode = iget_locked(sb, ino);
3242 @@ -2837,12 +2864,17 @@ struct inode *ext3_iget(struct super_blo
3244 raw_inode = ext3_raw_inode(&iloc);
3245 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3246 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3247 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3248 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3249 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3250 if(!(test_opt (inode->i_sb, NO_UID32))) {
3251 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3252 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3253 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3254 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3256 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3257 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3258 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3259 + le16_to_cpu(raw_inode->i_raw_tag));
3261 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3262 inode->i_size = le32_to_cpu(raw_inode->i_size);
3263 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3264 @@ -2997,6 +3029,8 @@ static int ext3_do_update_inode(handle_t
3265 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3266 struct ext3_inode_info *ei = EXT3_I(inode);
3267 struct buffer_head *bh = iloc->bh;
3268 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3269 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3270 int err = 0, rc, block;
3273 @@ -3011,29 +3045,32 @@ again:
3274 ext3_get_inode_flags(ei);
3275 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3276 if(!(test_opt(inode->i_sb, NO_UID32))) {
3277 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3278 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3279 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3280 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3282 * Fix up interoperability with old kernels. Otherwise, old inodes get
3283 * re-used with the upper 16 bits of the uid/gid intact
3286 raw_inode->i_uid_high =
3287 - cpu_to_le16(high_16_bits(inode->i_uid));
3288 + cpu_to_le16(high_16_bits(uid));
3289 raw_inode->i_gid_high =
3290 - cpu_to_le16(high_16_bits(inode->i_gid));
3291 + cpu_to_le16(high_16_bits(gid));
3293 raw_inode->i_uid_high = 0;
3294 raw_inode->i_gid_high = 0;
3297 raw_inode->i_uid_low =
3298 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3299 + cpu_to_le16(fs_high2lowuid(uid));
3300 raw_inode->i_gid_low =
3301 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3302 + cpu_to_le16(fs_high2lowgid(gid));
3303 raw_inode->i_uid_high = 0;
3304 raw_inode->i_gid_high = 0;
3306 +#ifdef CONFIG_TAGGING_INTERN
3307 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3309 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3310 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3311 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3312 @@ -3193,7 +3230,8 @@ int ext3_setattr(struct dentry *dentry,
3313 if (is_quota_modification(inode, attr))
3314 dquot_initialize(inode);
3315 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3316 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3317 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3318 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3321 /* (user+group)*(old+new) structure, inode write (sb,
3322 @@ -3215,6 +3253,8 @@ int ext3_setattr(struct dentry *dentry,
3323 inode->i_uid = attr->ia_uid;
3324 if (attr->ia_valid & ATTR_GID)
3325 inode->i_gid = attr->ia_gid;
3326 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3327 + inode->i_tag = attr->ia_tag;
3328 error = ext3_mark_inode_dirty(handle, inode);
3329 ext3_journal_stop(handle);
3331 diff -NurpP --minimal linux-2.6.38.1/fs/ext3/ioctl.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext3/ioctl.c
3332 --- linux-2.6.38.1/fs/ext3/ioctl.c 2011-03-15 18:07:31.000000000 +0100
3333 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext3/ioctl.c 2011-01-29 02:01:07.000000000 +0100
3337 #include <linux/fs.h>
3338 +#include <linux/mount.h>
3339 #include <linux/jbd.h>
3340 #include <linux/capability.h>
3341 #include <linux/ext3_fs.h>
3343 #include <linux/compat.h>
3344 #include <asm/uaccess.h>
3347 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
3349 + handle_t *handle = NULL;
3350 + struct ext3_iloc iloc;
3353 + handle = ext3_journal_start(inode, 1);
3354 + if (IS_ERR(handle))
3355 + return PTR_ERR(handle);
3357 + if (IS_SYNC(inode))
3358 + handle->h_sync = 1;
3359 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3363 + inode->i_flags = flags;
3364 + inode->i_vflags = vflags;
3365 + ext3_get_inode_flags(EXT3_I(inode));
3366 + inode->i_ctime = CURRENT_TIME_SEC;
3368 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3370 + ext3_journal_stop(handle);
3374 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3376 struct inode *inode = filp->f_dentry->d_inode;
3377 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
3379 flags = ext3_mask_flags(inode->i_mode, flags);
3381 + if (IS_BARRIER(inode)) {
3382 + vxwprintk_task(1, "messing with the barrier.");
3386 mutex_lock(&inode->i_mutex);
3388 /* Is it quota file? Do not allow user to mess with it */
3389 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3391 * This test looks nicer. Thanks to Pauline Middelink
3393 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3394 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3395 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3396 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3397 if (!capable(CAP_LINUX_IMMUTABLE))
3400 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3404 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3405 + flags &= EXT3_FL_USER_MODIFIABLE;
3406 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3407 ei->i_flags = flags;
3409 diff -NurpP --minimal linux-2.6.38.1/fs/ext3/namei.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext3/namei.c
3410 --- linux-2.6.38.1/fs/ext3/namei.c 2011-03-26 01:10:17.000000000 +0100
3411 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext3/namei.c 2011-03-25 22:52:15.000000000 +0100
3413 #include <linux/quotaops.h>
3414 #include <linux/buffer_head.h>
3415 #include <linux/bio.h>
3416 +#include <linux/vs_tag.h>
3420 @@ -923,6 +924,7 @@ restart:
3422 ll_rw_block(READ_META, 1, &bh);
3424 + dx_propagate_tag(nd, inode);
3426 if ((bh = bh_use[ra_ptr++]) == NULL)
3428 @@ -2487,6 +2489,7 @@ const struct inode_operations ext3_dir_i
3429 .removexattr = generic_removexattr,
3431 .check_acl = ext3_check_acl,
3432 + .sync_flags = ext3_sync_flags,
3435 const struct inode_operations ext3_special_inode_operations = {
3436 diff -NurpP --minimal linux-2.6.38.1/fs/ext3/super.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext3/super.c
3437 --- linux-2.6.38.1/fs/ext3/super.c 2011-03-15 18:07:31.000000000 +0100
3438 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext3/super.c 2011-01-29 02:01:07.000000000 +0100
3439 @@ -820,7 +820,8 @@ enum {
3440 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3441 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
3442 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
3443 - Opt_resize, Opt_usrquota, Opt_grpquota
3444 + Opt_resize, Opt_usrquota, Opt_grpquota,
3445 + Opt_tag, Opt_notag, Opt_tagid
3448 static const match_table_t tokens = {
3449 @@ -877,6 +878,9 @@ static const match_table_t tokens = {
3450 {Opt_barrier, "barrier"},
3451 {Opt_nobarrier, "nobarrier"},
3452 {Opt_resize, "resize"},
3454 + {Opt_notag, "notag"},
3455 + {Opt_tagid, "tagid=%u"},
3459 @@ -1029,6 +1033,20 @@ static int parse_options (char *options,
3461 set_opt (sbi->s_mount_opt, NO_UID32);
3463 +#ifndef CONFIG_TAGGING_NONE
3465 + set_opt (sbi->s_mount_opt, TAGGED);
3468 + clear_opt (sbi->s_mount_opt, TAGGED);
3471 +#ifdef CONFIG_PROPAGATE
3474 + set_opt (sbi->s_mount_opt, TAGGED);
3478 clear_opt (sbi->s_mount_opt, CHECK);
3480 @@ -1715,6 +1733,9 @@ static int ext3_fill_super (struct super
3484 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3485 + sb->s_flags |= MS_TAGGED;
3487 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3488 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3490 @@ -2594,6 +2615,14 @@ static int ext3_remount (struct super_bl
3491 if (test_opt(sb, ABORT))
3492 ext3_abort(sb, __func__, "Abort forced by user");
3494 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3495 + !(sb->s_flags & MS_TAGGED)) {
3496 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3499 + goto restore_opts;
3502 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3503 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3505 diff -NurpP --minimal linux-2.6.38.1/fs/ext4/ext4.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/ext4.h
3506 --- linux-2.6.38.1/fs/ext4/ext4.h 2011-03-15 18:07:31.000000000 +0100
3507 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/ext4.h 2011-02-17 02:17:50.000000000 +0100
3508 @@ -347,8 +347,12 @@ struct flex_groups {
3509 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3510 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
3511 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
3512 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3513 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3515 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3516 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3518 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3519 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3521 @@ -601,7 +605,8 @@ struct ext4_inode {
3522 __le16 l_i_file_acl_high;
3523 __le16 l_i_uid_high; /* these 2 fields */
3524 __le16 l_i_gid_high; /* were reserved2[0] */
3525 - __u32 l_i_reserved2;
3526 + __le16 l_i_tag; /* Context Tag */
3527 + __u16 l_i_reserved2;
3530 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3531 @@ -719,6 +724,7 @@ do { \
3532 #define i_gid_low i_gid
3533 #define i_uid_high osd2.linux2.l_i_uid_high
3534 #define i_gid_high osd2.linux2.l_i_gid_high
3535 +#define i_raw_tag osd2.linux2.l_i_tag
3536 #define i_reserved2 osd2.linux2.l_i_reserved2
3538 #elif defined(__GNU__)
3539 @@ -895,6 +901,7 @@ struct ext4_inode_info {
3540 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3541 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3542 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3543 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3544 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3545 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3546 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3547 @@ -2074,6 +2081,7 @@ extern int ext4_map_blocks(handle_t *han
3548 struct ext4_map_blocks *map, int flags);
3549 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3550 __u64 start, __u64 len);
3551 +extern int ext4_sync_flags(struct inode *, int, int);
3553 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3554 __u64 start_orig, __u64 start_donor,
3555 diff -NurpP --minimal linux-2.6.38.1/fs/ext4/file.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/file.c
3556 --- linux-2.6.38.1/fs/ext4/file.c 2011-03-15 18:07:31.000000000 +0100
3557 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/file.c 2011-02-17 02:17:50.000000000 +0100
3558 @@ -283,5 +283,6 @@ const struct inode_operations ext4_file_
3560 .check_acl = ext4_check_acl,
3561 .fiemap = ext4_fiemap,
3562 + .sync_flags = ext4_sync_flags,
3565 diff -NurpP --minimal linux-2.6.38.1/fs/ext4/ialloc.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/ialloc.c
3566 --- linux-2.6.38.1/fs/ext4/ialloc.c 2011-03-15 18:07:31.000000000 +0100
3567 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/ialloc.c 2011-01-29 02:01:07.000000000 +0100
3569 #include <linux/random.h>
3570 #include <linux/bitops.h>
3571 #include <linux/blkdev.h>
3572 +#include <linux/vs_tag.h>
3573 #include <asm/byteorder.h>
3576 @@ -991,6 +992,7 @@ got:
3577 inode->i_mode = mode;
3578 inode->i_uid = current_fsuid();
3579 inode->i_gid = dir->i_gid;
3580 + inode->i_tag = dx_current_fstag(sb);
3582 inode_init_owner(inode, dir, mode);
3584 diff -NurpP --minimal linux-2.6.38.1/fs/ext4/inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/inode.c
3585 --- linux-2.6.38.1/fs/ext4/inode.c 2011-03-15 18:07:31.000000000 +0100
3586 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/inode.c 2011-01-29 02:27:03.000000000 +0100
3588 #include <linux/printk.h>
3589 #include <linux/slab.h>
3590 #include <linux/ratelimit.h>
3591 +#include <linux/vs_tag.h>
3593 #include "ext4_jbd2.h"
3595 @@ -4446,7 +4447,7 @@ static void ext4_free_branches(handle_t
3597 int ext4_can_truncate(struct inode *inode)
3599 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3600 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3602 if (S_ISREG(inode->i_mode))
3604 @@ -4797,41 +4798,64 @@ void ext4_set_inode_flags(struct inode *
3606 unsigned int flags = EXT4_I(inode)->i_flags;
3608 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3609 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3610 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3612 + if (flags & EXT4_IMMUTABLE_FL)
3613 + inode->i_flags |= S_IMMUTABLE;
3614 + if (flags & EXT4_IXUNLINK_FL)
3615 + inode->i_flags |= S_IXUNLINK;
3617 if (flags & EXT4_SYNC_FL)
3618 inode->i_flags |= S_SYNC;
3619 if (flags & EXT4_APPEND_FL)
3620 inode->i_flags |= S_APPEND;
3621 - if (flags & EXT4_IMMUTABLE_FL)
3622 - inode->i_flags |= S_IMMUTABLE;
3623 if (flags & EXT4_NOATIME_FL)
3624 inode->i_flags |= S_NOATIME;
3625 if (flags & EXT4_DIRSYNC_FL)
3626 inode->i_flags |= S_DIRSYNC;
3628 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3630 + if (flags & EXT4_BARRIER_FL)
3631 + inode->i_vflags |= V_BARRIER;
3632 + if (flags & EXT4_COW_FL)
3633 + inode->i_vflags |= V_COW;
3636 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3637 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3639 - unsigned int vfs_fl;
3640 + unsigned int vfs_fl, vfs_vf;
3641 unsigned long old_fl, new_fl;
3644 vfs_fl = ei->vfs_inode.i_flags;
3645 + vfs_vf = ei->vfs_inode.i_vflags;
3646 old_fl = ei->i_flags;
3647 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3648 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3650 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3653 + if (vfs_fl & S_IMMUTABLE)
3654 + new_fl |= EXT4_IMMUTABLE_FL;
3655 + if (vfs_fl & S_IXUNLINK)
3656 + new_fl |= EXT4_IXUNLINK_FL;
3658 if (vfs_fl & S_SYNC)
3659 new_fl |= EXT4_SYNC_FL;
3660 if (vfs_fl & S_APPEND)
3661 new_fl |= EXT4_APPEND_FL;
3662 - if (vfs_fl & S_IMMUTABLE)
3663 - new_fl |= EXT4_IMMUTABLE_FL;
3664 if (vfs_fl & S_NOATIME)
3665 new_fl |= EXT4_NOATIME_FL;
3666 if (vfs_fl & S_DIRSYNC)
3667 new_fl |= EXT4_DIRSYNC_FL;
3669 + if (vfs_vf & V_BARRIER)
3670 + new_fl |= EXT4_BARRIER_FL;
3671 + if (vfs_vf & V_COW)
3672 + new_fl |= EXT4_COW_FL;
3673 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3676 @@ -4867,6 +4891,8 @@ struct inode *ext4_iget(struct super_blo
3677 journal_t *journal = EXT4_SB(sb)->s_journal;
3683 inode = iget_locked(sb, ino);
3685 @@ -4882,12 +4908,16 @@ struct inode *ext4_iget(struct super_blo
3687 raw_inode = ext4_raw_inode(&iloc);
3688 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3689 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3690 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3691 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3692 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3693 if (!(test_opt(inode->i_sb, NO_UID32))) {
3694 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3695 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3696 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3697 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3699 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3700 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3701 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3702 + le16_to_cpu(raw_inode->i_raw_tag));
3703 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3705 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3706 @@ -5106,6 +5136,8 @@ static int ext4_do_update_inode(handle_t
3707 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3708 struct ext4_inode_info *ei = EXT4_I(inode);
3709 struct buffer_head *bh = iloc->bh;
3710 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3711 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3712 int err = 0, rc, block;
3714 /* For fields not not tracking in the in-memory inode,
3715 @@ -5116,29 +5148,32 @@ static int ext4_do_update_inode(handle_t
3716 ext4_get_inode_flags(ei);
3717 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3718 if (!(test_opt(inode->i_sb, NO_UID32))) {
3719 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3720 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3721 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3722 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3724 * Fix up interoperability with old kernels. Otherwise, old inodes get
3725 * re-used with the upper 16 bits of the uid/gid intact
3728 raw_inode->i_uid_high =
3729 - cpu_to_le16(high_16_bits(inode->i_uid));
3730 + cpu_to_le16(high_16_bits(uid));
3731 raw_inode->i_gid_high =
3732 - cpu_to_le16(high_16_bits(inode->i_gid));
3733 + cpu_to_le16(high_16_bits(gid));
3735 raw_inode->i_uid_high = 0;
3736 raw_inode->i_gid_high = 0;
3739 raw_inode->i_uid_low =
3740 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3741 + cpu_to_le16(fs_high2lowuid(uid));
3742 raw_inode->i_gid_low =
3743 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3744 + cpu_to_le16(fs_high2lowgid(gid));
3745 raw_inode->i_uid_high = 0;
3746 raw_inode->i_gid_high = 0;
3748 +#ifdef CONFIG_TAGGING_INTERN
3749 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3751 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3753 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3754 @@ -5324,7 +5359,8 @@ int ext4_setattr(struct dentry *dentry,
3755 if (is_quota_modification(inode, attr))
3756 dquot_initialize(inode);
3757 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3758 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3759 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3760 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3763 /* (user+group)*(old+new) structure, inode write (sb,
3764 @@ -5346,6 +5382,8 @@ int ext4_setattr(struct dentry *dentry,
3765 inode->i_uid = attr->ia_uid;
3766 if (attr->ia_valid & ATTR_GID)
3767 inode->i_gid = attr->ia_gid;
3768 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3769 + inode->i_tag = attr->ia_tag;
3770 error = ext4_mark_inode_dirty(handle, inode);
3771 ext4_journal_stop(handle);
3773 diff -NurpP --minimal linux-2.6.38.1/fs/ext4/ioctl.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/ioctl.c
3774 --- linux-2.6.38.1/fs/ext4/ioctl.c 2011-01-05 21:50:23.000000000 +0100
3775 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/ioctl.c 2011-01-29 02:01:07.000000000 +0100
3777 #include <linux/compat.h>
3778 #include <linux/mount.h>
3779 #include <linux/file.h>
3780 +#include <linux/vs_tag.h>
3781 #include <asm/uaccess.h>
3782 #include "ext4_jbd2.h"
3786 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3788 + handle_t *handle = NULL;
3789 + struct ext4_iloc iloc;
3792 + handle = ext4_journal_start(inode, 1);
3793 + if (IS_ERR(handle))
3794 + return PTR_ERR(handle);
3796 + if (IS_SYNC(inode))
3797 + ext4_handle_sync(handle);
3798 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3802 + inode->i_flags = flags;
3803 + inode->i_vflags = vflags;
3804 + ext4_get_inode_flags(EXT4_I(inode));
3805 + inode->i_ctime = ext4_current_time(inode);
3807 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3809 + ext4_journal_stop(handle);
3813 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3815 struct inode *inode = filp->f_dentry->d_inode;
3816 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3818 flags = ext4_mask_flags(inode->i_mode, flags);
3820 + if (IS_BARRIER(inode)) {
3821 + vxwprintk_task(1, "messing with the barrier.");
3826 mutex_lock(&inode->i_mutex);
3827 /* Is it quota file? Do not allow user to mess with it */
3828 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3830 * This test looks nicer. Thanks to Pauline Middelink
3832 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3833 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3834 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3835 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3836 if (!capable(CAP_LINUX_IMMUTABLE))
3839 diff -NurpP --minimal linux-2.6.38.1/fs/ext4/namei.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/namei.c
3840 --- linux-2.6.38.1/fs/ext4/namei.c 2011-03-15 18:07:31.000000000 +0100
3841 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/namei.c 2011-01-29 02:01:07.000000000 +0100
3843 #include <linux/quotaops.h>
3844 #include <linux/buffer_head.h>
3845 #include <linux/bio.h>
3846 +#include <linux/vs_tag.h>
3848 #include "ext4_jbd2.h"
3850 @@ -923,6 +924,7 @@ restart:
3852 ll_rw_block(READ_META, 1, &bh);
3854 + dx_propagate_tag(nd, inode);
3856 if ((bh = bh_use[ra_ptr++]) == NULL)
3858 @@ -2540,6 +2542,7 @@ const struct inode_operations ext4_dir_i
3860 .check_acl = ext4_check_acl,
3861 .fiemap = ext4_fiemap,
3862 + .sync_flags = ext4_sync_flags,
3865 const struct inode_operations ext4_special_inode_operations = {
3866 diff -NurpP --minimal linux-2.6.38.1/fs/ext4/super.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/super.c
3867 --- linux-2.6.38.1/fs/ext4/super.c 2011-03-15 18:07:31.000000000 +0100
3868 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ext4/super.c 2011-02-17 02:17:50.000000000 +0100
3869 @@ -1262,6 +1262,7 @@ enum {
3870 Opt_dioread_nolock, Opt_dioread_lock,
3871 Opt_discard, Opt_nodiscard,
3872 Opt_init_inode_table, Opt_noinit_inode_table,
3873 + Opt_tag, Opt_notag, Opt_tagid
3876 static const match_table_t tokens = {
3877 @@ -1337,6 +1338,9 @@ static const match_table_t tokens = {
3878 {Opt_init_inode_table, "init_itable=%u"},
3879 {Opt_init_inode_table, "init_itable"},
3880 {Opt_noinit_inode_table, "noinit_itable"},
3882 + {Opt_notag, "notag"},
3883 + {Opt_tagid, "tagid=%u"},
3887 @@ -1505,6 +1509,20 @@ static int parse_options(char *options,
3889 set_opt(sb, NO_UID32);
3891 +#ifndef CONFIG_TAGGING_NONE
3893 + set_opt(sb, TAGGED);
3896 + clear_opt(sb, TAGGED);
3899 +#ifdef CONFIG_PROPAGATE
3902 + set_opt(sb, TAGGED);
3908 @@ -3148,6 +3166,9 @@ static int ext4_fill_super(struct super_
3909 &journal_ioprio, NULL, 0))
3912 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3913 + sb->s_flags |= MS_TAGGED;
3915 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3916 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3918 @@ -4235,6 +4256,14 @@ static int ext4_remount(struct super_blo
3919 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3920 ext4_abort(sb, "Abort forced by user");
3922 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3923 + !(sb->s_flags & MS_TAGGED)) {
3924 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3927 + goto restore_opts;
3930 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3931 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3933 diff -NurpP --minimal linux-2.6.38.1/fs/fcntl.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/fcntl.c
3934 --- linux-2.6.38.1/fs/fcntl.c 2011-03-15 18:07:31.000000000 +0100
3935 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/fcntl.c 2011-02-17 02:17:50.000000000 +0100
3937 #include <linux/signal.h>
3938 #include <linux/rcupdate.h>
3939 #include <linux/pid_namespace.h>
3940 +#include <linux/vs_limit.h>
3942 #include <asm/poll.h>
3943 #include <asm/siginfo.h>
3944 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3947 filp_close(tofree, files);
3949 + vx_openfd_inc(newfd); /* fd was unused */
3953 @@ -434,6 +437,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3957 + if (!vx_files_avail(1))
3960 err = security_file_fcntl(filp, cmd, arg);
3962 diff -NurpP --minimal linux-2.6.38.1/fs/file.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/file.c
3963 --- linux-2.6.38.1/fs/file.c 2010-10-21 13:07:48.000000000 +0200
3964 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/file.c 2011-01-29 02:01:07.000000000 +0100
3966 #include <linux/spinlock.h>
3967 #include <linux/rcupdate.h>
3968 #include <linux/workqueue.h>
3969 +#include <linux/vs_limit.h>
3971 struct fdtable_defer {
3973 @@ -355,6 +356,8 @@ struct files_struct *dup_fd(struct files
3974 struct file *f = *old_fds++;
3977 + /* TODO: sum it first for check and performance */
3978 + vx_openfd_inc(open_files - i);
3981 * The fd may be claimed in the fd bitmap but not yet
3982 @@ -462,6 +465,7 @@ repeat:
3984 FD_CLR(fd, fdt->close_on_exec);
3986 + vx_openfd_inc(fd);
3989 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3990 diff -NurpP --minimal linux-2.6.38.1/fs/file_table.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/file_table.c
3991 --- linux-2.6.38.1/fs/file_table.c 2011-03-15 18:07:31.000000000 +0100
3992 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/file_table.c 2011-02-17 02:17:50.000000000 +0100
3994 #include <linux/percpu_counter.h>
3995 #include <linux/percpu.h>
3996 #include <linux/ima.h>
3997 +#include <linux/vs_limit.h>
3998 +#include <linux/vs_context.h>
4000 #include <asm/atomic.h>
4002 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
4003 spin_lock_init(&f->f_lock);
4004 eventpoll_init_file(f);
4005 /* f->f_version: 0 */
4006 + f->f_xid = vx_current_xid();
4011 @@ -250,6 +254,8 @@ static void __fput(struct file *file)
4012 cdev_put(inode->i_cdev);
4013 fops_put(file->f_op);
4014 put_pid(file->f_owner.pid);
4015 + vx_files_dec(file);
4017 file_sb_list_del(file);
4018 if (file->f_mode & FMODE_WRITE)
4019 drop_file_write_access(file);
4020 @@ -333,6 +339,8 @@ void put_filp(struct file *file)
4022 if (atomic_long_dec_and_test(&file->f_count)) {
4023 security_file_free(file);
4024 + vx_files_dec(file);
4026 file_sb_list_del(file);
4029 diff -NurpP --minimal linux-2.6.38.1/fs/fs_struct.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/fs_struct.c
4030 --- linux-2.6.38.1/fs/fs_struct.c 2011-03-15 18:07:31.000000000 +0100
4031 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/fs_struct.c 2011-01-29 02:35:02.000000000 +0100
4033 #include <linux/path.h>
4034 #include <linux/slab.h>
4035 #include <linux/fs_struct.h>
4036 +#include <linux/vserver/global.h>
4037 #include "internal.h"
4039 static inline void path_get_longterm(struct path *path)
4040 @@ -96,6 +97,7 @@ void free_fs_struct(struct fs_struct *fs
4042 path_put_longterm(&fs->root);
4043 path_put_longterm(&fs->pwd);
4044 + atomic_dec(&vs_global_fs);
4045 kmem_cache_free(fs_cachep, fs);
4048 @@ -135,6 +137,7 @@ struct fs_struct *copy_fs_struct(struct
4050 path_get_longterm(&fs->pwd);
4051 spin_unlock(&old->lock);
4052 + atomic_inc(&vs_global_fs);
4056 diff -NurpP --minimal linux-2.6.38.1/fs/gfs2/file.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/gfs2/file.c
4057 --- linux-2.6.38.1/fs/gfs2/file.c 2011-03-15 18:07:32.000000000 +0100
4058 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/gfs2/file.c 2011-01-29 02:01:07.000000000 +0100
4059 @@ -134,6 +134,9 @@ static const u32 fsflags_to_gfs2[32] = {
4060 [7] = GFS2_DIF_NOATIME,
4061 [12] = GFS2_DIF_EXHASH,
4062 [14] = GFS2_DIF_INHERIT_JDATA,
4063 + [27] = GFS2_DIF_IXUNLINK,
4064 + [26] = GFS2_DIF_BARRIER,
4065 + [29] = GFS2_DIF_COW,
4068 static const u32 gfs2_to_fsflags[32] = {
4069 @@ -143,6 +146,9 @@ static const u32 gfs2_to_fsflags[32] = {
4070 [gfs2fl_NoAtime] = FS_NOATIME_FL,
4071 [gfs2fl_ExHash] = FS_INDEX_FL,
4072 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
4073 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
4074 + [gfs2fl_Barrier] = FS_BARRIER_FL,
4075 + [gfs2fl_Cow] = FS_COW_FL,
4078 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
4079 @@ -173,10 +179,16 @@ void gfs2_set_inode_flags(struct inode *
4081 struct gfs2_inode *ip = GFS2_I(inode);
4082 unsigned int flags = inode->i_flags;
4083 + unsigned int vflags = inode->i_vflags;
4085 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4086 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4088 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4089 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
4090 flags |= S_IMMUTABLE;
4091 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
4092 + flags |= S_IXUNLINK;
4094 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
4096 if (ip->i_diskflags & GFS2_DIF_NOATIME)
4097 @@ -184,6 +196,43 @@ void gfs2_set_inode_flags(struct inode *
4098 if (ip->i_diskflags & GFS2_DIF_SYNC)
4100 inode->i_flags = flags;
4102 + vflags &= ~(V_BARRIER | V_COW);
4104 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
4105 + vflags |= V_BARRIER;
4106 + if (ip->i_diskflags & GFS2_DIF_COW)
4108 + inode->i_vflags = vflags;
4111 +void gfs2_get_inode_flags(struct inode *inode)
4113 + struct gfs2_inode *ip = GFS2_I(inode);
4114 + unsigned int flags = inode->i_flags;
4115 + unsigned int vflags = inode->i_vflags;
4117 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
4118 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
4119 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
4120 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
4122 + if (flags & S_IMMUTABLE)
4123 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
4124 + if (flags & S_IXUNLINK)
4125 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
4127 + if (flags & S_APPEND)
4128 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
4129 + if (flags & S_NOATIME)
4130 + ip->i_diskflags |= GFS2_DIF_NOATIME;
4131 + if (flags & S_SYNC)
4132 + ip->i_diskflags |= GFS2_DIF_SYNC;
4134 + if (vflags & V_BARRIER)
4135 + ip->i_diskflags |= GFS2_DIF_BARRIER;
4136 + if (vflags & V_COW)
4137 + ip->i_diskflags |= GFS2_DIF_COW;
4140 /* Flags that can be set by user space */
4141 @@ -295,6 +344,37 @@ static int gfs2_set_flags(struct file *f
4142 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
4145 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
4147 + struct gfs2_inode *ip = GFS2_I(inode);
4148 + struct gfs2_sbd *sdp = GFS2_SB(inode);
4149 + struct buffer_head *bh;
4150 + struct gfs2_holder gh;
4153 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
4156 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
4159 + error = gfs2_meta_inode_buffer(ip, &bh);
4161 + goto out_trans_end;
4162 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
4163 + inode->i_flags = flags;
4164 + inode->i_vflags = vflags;
4165 + gfs2_get_inode_flags(inode);
4166 + gfs2_dinode_out(ip, bh->b_data);
4168 + gfs2_set_aops(inode);
4170 + gfs2_trans_end(sdp);
4172 + gfs2_glock_dq_uninit(&gh);
4176 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4179 diff -NurpP --minimal linux-2.6.38.1/fs/gfs2/inode.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/gfs2/inode.h
4180 --- linux-2.6.38.1/fs/gfs2/inode.h 2011-03-15 18:07:32.000000000 +0100
4181 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/gfs2/inode.h 2011-01-29 02:01:07.000000000 +0100
4182 @@ -125,6 +125,7 @@ extern const struct file_operations gfs2
4183 extern const struct file_operations gfs2_dir_fops_nolock;
4185 extern void gfs2_set_inode_flags(struct inode *inode);
4186 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
4188 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
4189 extern const struct file_operations gfs2_file_fops;
4190 diff -NurpP --minimal linux-2.6.38.1/fs/gfs2/ops_inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/gfs2/ops_inode.c
4191 --- linux-2.6.38.1/fs/gfs2/ops_inode.c 2011-03-15 18:07:32.000000000 +0100
4192 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/gfs2/ops_inode.c 2011-01-29 02:01:07.000000000 +0100
4193 @@ -1326,6 +1326,8 @@ const struct inode_operations gfs2_dir_i
4194 .listxattr = gfs2_listxattr,
4195 .removexattr = gfs2_removexattr,
4196 .fiemap = gfs2_fiemap,
4197 + .sync_flags = gfs2_sync_flags,
4198 + .sync_flags = gfs2_sync_flags,
4201 const struct inode_operations gfs2_symlink_iops = {
4202 diff -NurpP --minimal linux-2.6.38.1/fs/inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/inode.c
4203 --- linux-2.6.38.1/fs/inode.c 2011-03-15 18:07:32.000000000 +0100
4204 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/inode.c 2011-03-07 16:53:27.000000000 +0100
4206 #include <linux/async.h>
4207 #include <linux/posix_acl.h>
4208 #include <linux/ima.h>
4209 +#include <linux/vs_tag.h>
4212 * This is needed for the following functions:
4213 @@ -164,6 +165,9 @@ int inode_init_always(struct super_block
4214 struct address_space *const mapping = &inode->i_data;
4218 + /* essential because of inode slab reuse */
4220 inode->i_blkbits = sb->s_blocksize_bits;
4222 atomic_set(&inode->i_count, 1);
4223 @@ -184,6 +188,7 @@ int inode_init_always(struct super_block
4224 inode->i_bdev = NULL;
4225 inode->i_cdev = NULL;
4227 + inode->i_mdev = 0;
4228 inode->dirtied_when = 0;
4230 if (security_inode_alloc(inode))
4231 @@ -431,6 +436,8 @@ static void __remove_inode_hash(struct i
4232 hlist_del_init(&inode->i_hash);
4235 +EXPORT_SYMBOL_GPL(__iget);
4238 * remove_inode_hash - remove an inode from the hash
4239 * @inode: inode to unhash
4240 @@ -1704,9 +1711,11 @@ void init_special_inode(struct inode *in
4241 if (S_ISCHR(mode)) {
4242 inode->i_fop = &def_chr_fops;
4243 inode->i_rdev = rdev;
4244 + inode->i_mdev = rdev;
4245 } else if (S_ISBLK(mode)) {
4246 inode->i_fop = &def_blk_fops;
4247 inode->i_rdev = rdev;
4248 + inode->i_mdev = rdev;
4249 } else if (S_ISFIFO(mode))
4250 inode->i_fop = &def_fifo_fops;
4251 else if (S_ISSOCK(mode))
4252 @@ -1735,5 +1744,6 @@ void inode_init_owner(struct inode *inod
4254 inode->i_gid = current_fsgid();
4255 inode->i_mode = mode;
4256 + inode->i_tag = dx_current_fstag(inode->i_sb);
4258 EXPORT_SYMBOL(inode_init_owner);
4259 diff -NurpP --minimal linux-2.6.38.1/fs/ioctl.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ioctl.c
4260 --- linux-2.6.38.1/fs/ioctl.c 2011-03-15 18:07:32.000000000 +0100
4261 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ioctl.c 2011-02-17 02:17:50.000000000 +0100
4263 #include <linux/writeback.h>
4264 #include <linux/buffer_head.h>
4265 #include <linux/falloc.h>
4266 +#include <linux/proc_fs.h>
4267 +#include <linux/vserver/inode.h>
4268 +#include <linux/vs_tag.h>
4270 #include <asm/ioctls.h>
4272 diff -NurpP --minimal linux-2.6.38.1/fs/ioprio.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ioprio.c
4273 --- linux-2.6.38.1/fs/ioprio.c 2011-01-05 21:50:24.000000000 +0100
4274 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ioprio.c 2011-01-29 02:01:07.000000000 +0100
4276 #include <linux/syscalls.h>
4277 #include <linux/security.h>
4278 #include <linux/pid_namespace.h>
4279 +#include <linux/vs_base.h>
4281 int set_task_ioprio(struct task_struct *task, int ioprio)
4283 @@ -119,6 +120,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4285 pgrp = find_vpid(who);
4286 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4287 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4289 ret = set_task_ioprio(p, ioprio);
4292 @@ -208,6 +211,8 @@ SYSCALL_DEFINE2(ioprio_get, 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 tmpio = get_task_ioprio(p);
4301 diff -NurpP --minimal linux-2.6.38.1/fs/jfs/file.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/file.c
4302 --- linux-2.6.38.1/fs/jfs/file.c 2010-10-21 13:07:50.000000000 +0200
4303 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/file.c 2011-01-29 02:01:07.000000000 +0100
4304 @@ -102,7 +102,8 @@ int jfs_setattr(struct dentry *dentry, s
4305 if (is_quota_modification(inode, iattr))
4306 dquot_initialize(inode);
4307 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4308 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4309 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4310 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4311 rc = dquot_transfer(inode, iattr);
4314 @@ -133,6 +134,7 @@ const struct inode_operations jfs_file_i
4315 #ifdef CONFIG_JFS_POSIX_ACL
4316 .check_acl = jfs_check_acl,
4318 + .sync_flags = jfs_sync_flags,
4321 const struct file_operations jfs_file_operations = {
4322 diff -NurpP --minimal linux-2.6.38.1/fs/jfs/ioctl.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/ioctl.c
4323 --- linux-2.6.38.1/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4324 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/ioctl.c 2011-01-29 02:01:07.000000000 +0100
4326 #include <linux/mount.h>
4327 #include <linux/time.h>
4328 #include <linux/sched.h>
4329 +#include <linux/mount.h>
4330 #include <asm/current.h>
4331 #include <asm/uaccess.h>
4333 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
4337 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
4339 + inode->i_flags = flags;
4340 + inode->i_vflags = vflags;
4341 + jfs_get_inode_flags(JFS_IP(inode));
4342 + inode->i_ctime = CURRENT_TIME_SEC;
4343 + mark_inode_dirty(inode);
4347 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4349 struct inode *inode = filp->f_dentry->d_inode;
4350 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
4351 if (!S_ISDIR(inode->i_mode))
4352 flags &= ~JFS_DIRSYNC_FL;
4354 + if (IS_BARRIER(inode)) {
4355 + vxwprintk_task(1, "messing with the barrier.");
4359 /* Is it quota file? Do not allow user to mess with it */
4360 if (IS_NOQUOTA(inode)) {
4362 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
4363 * the relevant capability.
4365 if ((oldflags & JFS_IMMUTABLE_FL) ||
4366 - ((flags ^ oldflags) &
4367 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4368 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4369 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4370 if (!capable(CAP_LINUX_IMMUTABLE)) {
4371 mutex_unlock(&inode->i_mutex);
4373 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
4377 - flags = flags & JFS_FL_USER_MODIFIABLE;
4378 + flags &= JFS_FL_USER_MODIFIABLE;
4379 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
4380 jfs_inode->mode2 = flags;
4382 diff -NurpP --minimal linux-2.6.38.1/fs/jfs/jfs_dinode.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/jfs_dinode.h
4383 --- linux-2.6.38.1/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
4384 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/jfs_dinode.h 2011-01-29 02:01:07.000000000 +0100
4385 @@ -161,9 +161,13 @@ struct dinode {
4387 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4388 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4389 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4391 -#define JFS_FL_USER_VISIBLE 0x03F80000
4392 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4393 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4394 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4396 +#define JFS_FL_USER_VISIBLE 0x07F80000
4397 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4398 #define JFS_FL_INHERIT 0x03C80000
4400 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4401 diff -NurpP --minimal linux-2.6.38.1/fs/jfs/jfs_filsys.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/jfs_filsys.h
4402 --- linux-2.6.38.1/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4403 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/jfs_filsys.h 2011-01-29 02:01:07.000000000 +0100
4405 #define JFS_NAME_MAX 255
4406 #define JFS_PATH_MAX BPSIZE
4408 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4411 * file system state (superblock state)
4412 diff -NurpP --minimal linux-2.6.38.1/fs/jfs/jfs_imap.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/jfs_imap.c
4413 --- linux-2.6.38.1/fs/jfs/jfs_imap.c 2011-01-05 21:50:24.000000000 +0100
4414 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/jfs_imap.c 2011-01-29 02:01:07.000000000 +0100
4416 #include <linux/pagemap.h>
4417 #include <linux/quotaops.h>
4418 #include <linux/slab.h>
4419 +#include <linux/vs_tag.h>
4421 #include "jfs_incore.h"
4422 #include "jfs_inode.h"
4423 @@ -3060,6 +3061,8 @@ static int copy_from_dinode(struct dinod
4425 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4426 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4430 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4431 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4432 @@ -3080,14 +3083,18 @@ static int copy_from_dinode(struct dinod
4434 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4436 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4437 + uid = le32_to_cpu(dip->di_uid);
4438 + gid = le32_to_cpu(dip->di_gid);
4439 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4441 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4443 ip->i_uid = jfs_ip->saved_uid;
4445 ip->i_uid = sbi->uid;
4448 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4449 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4451 ip->i_gid = jfs_ip->saved_gid;
4453 @@ -3152,14 +3159,12 @@ static void copy_to_dinode(struct dinode
4454 dip->di_size = cpu_to_le64(ip->i_size);
4455 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4456 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4457 - if (sbi->uid == -1)
4458 - dip->di_uid = cpu_to_le32(ip->i_uid);
4460 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4461 - if (sbi->gid == -1)
4462 - dip->di_gid = cpu_to_le32(ip->i_gid);
4464 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4466 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4467 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4468 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4469 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4471 jfs_get_inode_flags(jfs_ip);
4473 * mode2 is only needed for storing the higher order bits.
4474 diff -NurpP --minimal linux-2.6.38.1/fs/jfs/jfs_inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/jfs_inode.c
4475 --- linux-2.6.38.1/fs/jfs/jfs_inode.c 2010-08-02 16:52:49.000000000 +0200
4476 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/jfs_inode.c 2011-01-29 02:01:07.000000000 +0100
4479 #include <linux/fs.h>
4480 #include <linux/quotaops.h>
4481 +#include <linux/vs_tag.h>
4482 #include "jfs_incore.h"
4483 #include "jfs_inode.h"
4484 #include "jfs_filsys.h"
4485 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4487 unsigned int flags = JFS_IP(inode)->mode2;
4489 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4490 - S_NOATIME | S_DIRSYNC | S_SYNC);
4491 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4492 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4494 if (flags & JFS_IMMUTABLE_FL)
4495 inode->i_flags |= S_IMMUTABLE;
4496 + if (flags & JFS_IXUNLINK_FL)
4497 + inode->i_flags |= S_IXUNLINK;
4499 + if (flags & JFS_SYNC_FL)
4500 + inode->i_flags |= S_SYNC;
4501 if (flags & JFS_APPEND_FL)
4502 inode->i_flags |= S_APPEND;
4503 if (flags & JFS_NOATIME_FL)
4504 inode->i_flags |= S_NOATIME;
4505 if (flags & JFS_DIRSYNC_FL)
4506 inode->i_flags |= S_DIRSYNC;
4507 - if (flags & JFS_SYNC_FL)
4508 - inode->i_flags |= S_SYNC;
4510 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4512 + if (flags & JFS_BARRIER_FL)
4513 + inode->i_vflags |= V_BARRIER;
4514 + if (flags & JFS_COW_FL)
4515 + inode->i_vflags |= V_COW;
4518 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4520 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4521 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4523 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4524 + JFS_APPEND_FL | JFS_NOATIME_FL |
4525 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4526 + JFS_BARRIER_FL | JFS_COW_FL);
4528 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4529 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4530 if (flags & S_IMMUTABLE)
4531 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4532 + if (flags & S_IXUNLINK)
4533 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4535 if (flags & S_APPEND)
4536 jfs_ip->mode2 |= JFS_APPEND_FL;
4537 if (flags & S_NOATIME)
4538 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4539 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4541 jfs_ip->mode2 |= JFS_SYNC_FL;
4543 + if (vflags & V_BARRIER)
4544 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4545 + if (vflags & V_COW)
4546 + jfs_ip->mode2 |= JFS_COW_FL;
4550 diff -NurpP --minimal linux-2.6.38.1/fs/jfs/jfs_inode.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/jfs_inode.h
4551 --- linux-2.6.38.1/fs/jfs/jfs_inode.h 2010-10-21 13:07:50.000000000 +0200
4552 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/jfs_inode.h 2011-01-29 02:01:07.000000000 +0100
4553 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4554 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4555 int fh_len, int fh_type);
4556 extern void jfs_set_inode_flags(struct inode *);
4557 +extern int jfs_sync_flags(struct inode *, int, int);
4558 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4559 extern int jfs_setattr(struct dentry *, struct iattr *);
4561 diff -NurpP --minimal linux-2.6.38.1/fs/jfs/namei.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/namei.c
4562 --- linux-2.6.38.1/fs/jfs/namei.c 2011-03-15 18:07:32.000000000 +0100
4563 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/namei.c 2011-03-15 18:15:06.000000000 +0100
4565 #include <linux/ctype.h>
4566 #include <linux/quotaops.h>
4567 #include <linux/exportfs.h>
4568 +#include <linux/vs_tag.h>
4569 #include "jfs_incore.h"
4570 #include "jfs_superblock.h"
4571 #include "jfs_inode.h"
4572 @@ -1489,6 +1490,7 @@ static struct dentry *jfs_lookup(struct
4573 return ERR_CAST(ip);
4576 + dx_propagate_tag(nd, ip);
4577 return d_splice_alias(ip, dentry);
4580 @@ -1553,6 +1555,7 @@ const struct inode_operations jfs_dir_in
4581 #ifdef CONFIG_JFS_POSIX_ACL
4582 .check_acl = jfs_check_acl,
4584 + .sync_flags = jfs_sync_flags,
4587 const struct file_operations jfs_dir_operations = {
4588 diff -NurpP --minimal linux-2.6.38.1/fs/jfs/super.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/super.c
4589 --- linux-2.6.38.1/fs/jfs/super.c 2011-03-15 18:07:32.000000000 +0100
4590 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/jfs/super.c 2011-01-29 02:01:07.000000000 +0100
4591 @@ -198,7 +198,8 @@ static void jfs_put_super(struct super_b
4593 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4594 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4595 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4596 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4597 + Opt_tag, Opt_notag, Opt_tagid
4600 static const match_table_t tokens = {
4601 @@ -208,6 +209,10 @@ static const match_table_t tokens = {
4602 {Opt_resize, "resize=%u"},
4603 {Opt_resize_nosize, "resize"},
4604 {Opt_errors, "errors=%s"},
4606 + {Opt_notag, "notag"},
4607 + {Opt_tagid, "tagid=%u"},
4608 + {Opt_tag, "tagxid"},
4609 {Opt_ignore, "noquota"},
4610 {Opt_ignore, "quota"},
4611 {Opt_usrquota, "usrquota"},
4612 @@ -342,6 +347,20 @@ static int parse_options(char *options,
4616 +#ifndef CONFIG_TAGGING_NONE
4618 + *flag |= JFS_TAGGED;
4621 + *flag &= JFS_TAGGED;
4624 +#ifdef CONFIG_PROPAGATE
4627 + *flag |= JFS_TAGGED;
4631 printk("jfs: Unrecognized mount option \"%s\" "
4632 " or missing value\n", p);
4633 @@ -373,6 +392,12 @@ static int jfs_remount(struct super_bloc
4637 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4638 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4644 if (sb->s_flags & MS_RDONLY) {
4646 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
4647 #ifdef CONFIG_JFS_POSIX_ACL
4648 sb->s_flags |= MS_POSIXACL;
4650 + /* map mount option tagxid */
4651 + if (sbi->flag & JFS_TAGGED)
4652 + sb->s_flags |= MS_TAGGED;
4655 printk(KERN_ERR "resize option for remount only\n");
4656 diff -NurpP --minimal linux-2.6.38.1/fs/libfs.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/libfs.c
4657 --- linux-2.6.38.1/fs/libfs.c 2011-03-15 18:07:32.000000000 +0100
4658 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/libfs.c 2011-01-29 05:03:51.000000000 +0100
4659 @@ -133,7 +133,8 @@ static inline unsigned char dt_type(stru
4660 * both impossible due to the lock on directory.
4663 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4664 +static inline int do_dcache_readdir_filter(struct file *filp,
4665 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4667 struct dentry *dentry = filp->f_path.dentry;
4668 struct dentry *cursor = filp->private_data;
4669 @@ -164,6 +165,8 @@ int dcache_readdir(struct file * filp, v
4670 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4671 struct dentry *next;
4672 next = list_entry(p, struct dentry, d_u.d_child);
4673 + if (filter && !filter(next))
4675 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4676 if (!simple_positive(next)) {
4677 spin_unlock(&next->d_lock);
4678 @@ -190,6 +193,17 @@ int dcache_readdir(struct file * filp, v
4682 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4684 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4687 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4688 + int (*filter)(struct dentry *))
4690 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4693 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4696 @@ -965,6 +979,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4697 EXPORT_SYMBOL(dcache_dir_lseek);
4698 EXPORT_SYMBOL(dcache_dir_open);
4699 EXPORT_SYMBOL(dcache_readdir);
4700 +EXPORT_SYMBOL(dcache_readdir_filter);
4701 EXPORT_SYMBOL(generic_read_dir);
4702 EXPORT_SYMBOL(mount_pseudo);
4703 EXPORT_SYMBOL(simple_write_begin);
4704 diff -NurpP --minimal linux-2.6.38.1/fs/locks.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/locks.c
4705 --- linux-2.6.38.1/fs/locks.c 2011-03-15 18:07:32.000000000 +0100
4706 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/locks.c 2011-01-29 02:01:07.000000000 +0100
4708 #include <linux/time.h>
4709 #include <linux/rcupdate.h>
4710 #include <linux/pid_namespace.h>
4711 +#include <linux/vs_base.h>
4712 +#include <linux/vs_limit.h>
4714 #include <asm/uaccess.h>
4716 @@ -164,6 +166,8 @@ static struct kmem_cache *filelock_cache
4717 /* Allocate an empty lock structure. */
4718 struct file_lock *locks_alloc_lock(void)
4720 + if (!vx_locks_avail(1))
4722 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4724 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4725 @@ -191,6 +195,7 @@ void locks_free_lock(struct file_lock *f
4726 BUG_ON(!list_empty(&fl->fl_block));
4727 BUG_ON(!list_empty(&fl->fl_link));
4730 locks_release_private(fl);
4731 kmem_cache_free(filelock_cache, fl);
4733 @@ -212,6 +217,7 @@ void locks_init_lock(struct file_lock *f
4734 fl->fl_start = fl->fl_end = 0;
4736 fl->fl_lmops = NULL;
4740 EXPORT_SYMBOL(locks_init_lock);
4741 @@ -263,6 +269,7 @@ void locks_copy_lock(struct file_lock *n
4742 new->fl_file = fl->fl_file;
4743 new->fl_ops = fl->fl_ops;
4744 new->fl_lmops = fl->fl_lmops;
4745 + new->fl_xid = fl->fl_xid;
4747 locks_copy_private(new, fl);
4749 @@ -301,6 +308,11 @@ static int flock_make_lock(struct file *
4750 fl->fl_flags = FL_FLOCK;
4752 fl->fl_end = OFFSET_MAX;
4754 + vxd_assert(filp->f_xid == vx_current_xid(),
4755 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4756 + fl->fl_xid = filp->f_xid;
4761 @@ -460,6 +472,7 @@ static int lease_init(struct file *filp,
4763 fl->fl_owner = current->files;
4764 fl->fl_pid = current->tgid;
4765 + fl->fl_xid = vx_current_xid();
4768 fl->fl_flags = FL_LEASE;
4769 @@ -479,6 +492,11 @@ static struct file_lock *lease_alloc(str
4771 return ERR_PTR(error);
4773 + fl->fl_xid = vx_current_xid();
4775 + vxd_assert(filp->f_xid == fl->fl_xid,
4776 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4778 error = lease_init(filp, type, fl);
4780 locks_free_lock(fl);
4781 @@ -780,6 +798,7 @@ static int flock_lock_file(struct file *
4785 + new_fl->fl_xid = -1;
4787 for_each_lock(inode, before) {
4788 struct file_lock *fl = *before;
4789 @@ -800,6 +819,7 @@ find_conflict:
4791 locks_copy_lock(new_fl, request);
4792 locks_insert_lock(before, new_fl);
4793 + vx_locks_inc(new_fl);
4797 @@ -810,7 +830,8 @@ out:
4801 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4802 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4803 + struct file_lock *conflock, xid_t xid)
4805 struct file_lock *fl;
4806 struct file_lock *new_fl = NULL;
4807 @@ -820,6 +841,8 @@ static int __posix_lock_file(struct inod
4808 struct file_lock **before;
4809 int error, added = 0;
4811 + vxd_assert(xid == vx_current_xid(),
4812 + "xid(%d) == current(%d)", xid, vx_current_xid());
4814 * We may need two file_lock structures for this operation,
4815 * so we get them in advance to avoid races.
4816 @@ -830,7 +853,11 @@ static int __posix_lock_file(struct inod
4817 (request->fl_type != F_UNLCK ||
4818 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4819 new_fl = locks_alloc_lock();
4820 + new_fl->fl_xid = xid;
4821 + vx_locks_inc(new_fl);
4822 new_fl2 = locks_alloc_lock();
4823 + new_fl2->fl_xid = xid;
4824 + vx_locks_inc(new_fl2);
4828 @@ -1029,7 +1056,8 @@ static int __posix_lock_file(struct inod
4829 int posix_lock_file(struct file *filp, struct file_lock *fl,
4830 struct file_lock *conflock)
4832 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4833 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4834 + fl, conflock, filp->f_xid);
4836 EXPORT_SYMBOL(posix_lock_file);
4838 @@ -1119,7 +1147,7 @@ int locks_mandatory_area(int read_write,
4839 fl.fl_end = offset + count - 1;
4842 - error = __posix_lock_file(inode, &fl, NULL);
4843 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4844 if (error != FILE_LOCK_DEFERRED)
4846 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4847 @@ -1432,6 +1460,7 @@ int generic_setlease(struct file *filp,
4850 locks_insert_lock(before, lease);
4851 + vx_locks_inc(lease);
4855 @@ -1816,6 +1845,11 @@ int fcntl_setlk(unsigned int fd, struct
4856 if (file_lock == NULL)
4859 + vxd_assert(filp->f_xid == vx_current_xid(),
4860 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4861 + file_lock->fl_xid = filp->f_xid;
4862 + vx_locks_inc(file_lock);
4865 * This might block, so we do it before checking the inode.
4867 @@ -1934,6 +1968,11 @@ int fcntl_setlk64(unsigned int fd, struc
4868 if (file_lock == NULL)
4871 + vxd_assert(filp->f_xid == vx_current_xid(),
4872 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4873 + file_lock->fl_xid = filp->f_xid;
4874 + vx_locks_inc(file_lock);
4877 * This might block, so we do it before checking the inode.
4879 @@ -2199,8 +2238,11 @@ static int locks_show(struct seq_file *f
4881 lock_get_status(f, fl, *((loff_t *)f->private), "");
4883 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4884 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4885 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4887 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4892 diff -NurpP --minimal linux-2.6.38.1/fs/namei.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/namei.c
4893 --- linux-2.6.38.1/fs/namei.c 2011-03-15 18:07:32.000000000 +0100
4894 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/namei.c 2011-03-15 18:17:37.000000000 +0100
4896 #include <linux/fcntl.h>
4897 #include <linux/device_cgroup.h>
4898 #include <linux/fs_struct.h>
4899 +#include <linux/proc_fs.h>
4900 +#include <linux/vserver/inode.h>
4901 +#include <linux/vs_base.h>
4902 +#include <linux/vs_tag.h>
4903 +#include <linux/vs_cowbl.h>
4904 +#include <linux/vs_device.h>
4905 +#include <linux/vs_context.h>
4906 +#include <linux/pid_namespace.h>
4907 #include <asm/uaccess.h>
4909 #include "internal.h"
4910 @@ -166,6 +174,84 @@ void putname(const char *name)
4911 EXPORT_SYMBOL(putname);
4914 +static inline int dx_barrier(const struct inode *inode)
4916 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4917 + vxwprintk_task(1, "did hit the barrier.");
4923 +static int __dx_permission(const struct inode *inode, int mask)
4925 + if (dx_barrier(inode))
4928 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4929 + /* devpts is xid tagged */
4930 + if (S_ISDIR(inode->i_mode) ||
4931 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4934 + /* just pretend we didn't find anything */
4937 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4938 + struct proc_dir_entry *de = PDE(inode);
4940 + if (de && !vx_hide_check(0, de->vx_flags))
4943 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4945 + struct task_struct *tsk;
4947 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4948 + vx_flags(VXF_STATE_SETUP, 0))
4951 + pid = PROC_I(inode)->pid;
4955 + tsk = pid_task(pid, PIDTYPE_PID);
4956 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4957 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4958 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
4962 + /* FIXME: Should we block some entries here? */
4967 + if (dx_notagcheck(inode->i_sb) ||
4968 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4977 +int dx_permission(const struct inode *inode, int mask)
4979 + int ret = __dx_permission(inode, mask);
4980 + if (unlikely(ret)) {
4981 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4982 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4985 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4986 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4993 * This does basic POSIX ACL permission checking
4995 @@ -271,10 +357,14 @@ int inode_permission(struct inode *inode
4997 * Nobody gets write access to an immutable file.
4999 - if (IS_IMMUTABLE(inode))
5000 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
5004 + retval = dx_permission(inode, mask);
5008 if (inode->i_op->permission)
5009 retval = inode->i_op->permission(inode, mask, 0);
5011 @@ -676,6 +766,9 @@ static inline int exec_permission(struct
5015 + if (dx_barrier(inode))
5018 if (inode->i_op->permission) {
5019 ret = inode->i_op->permission(inode, MAY_EXEC, flags);
5021 @@ -1162,7 +1255,8 @@ static void follow_dotdot(struct nameida
5023 if (nd->path.dentry == nd->root.dentry &&
5024 nd->path.mnt == nd->root.mnt) {
5026 + /* for sane '/' avoid follow_mount() */
5029 if (nd->path.dentry != nd->path.mnt->mnt_root) {
5030 /* rare case of legitimate dget_parent()... */
5031 @@ -1216,7 +1310,7 @@ static int do_lookup(struct nameidata *n
5033 struct vfsmount *mnt = nd->path.mnt;
5034 struct dentry *dentry, *parent = nd->path.dentry;
5035 - struct inode *dir;
5036 + struct inode *dir, *d_inode;
5040 @@ -1277,6 +1371,13 @@ found:
5045 + d_inode = dentry->d_inode;
5049 + if (__dx_permission(d_inode, MAY_ACCESS))
5053 path->dentry = dentry;
5054 @@ -1288,6 +1389,18 @@ done:
5055 *inode = path->dentry->d_inode;
5059 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
5060 + if (d_inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
5063 + "did lookup hidden %s:%p[#%d,%lu] " VS_Q("%s/%.*s") ".",
5064 + d_inode->i_sb->s_id, d_inode, d_inode->i_tag, d_inode->i_ino,
5065 + vxd_path(&nd->path), name->len, name->name);
5071 dir = parent->d_inode;
5072 BUG_ON(nd->inode != dir);
5073 @@ -1982,7 +2095,7 @@ static int may_delete(struct inode *dir,
5076 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5077 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5078 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5081 if (!S_ISDIR(victim->d_inode->i_mode))
5082 @@ -2105,6 +2218,14 @@ int may_open(struct path *path, int acc_
5086 +#ifdef CONFIG_VSERVER_COWBL
5087 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5088 + if (IS_COW_LINK(inode))
5090 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5091 + mark_inode_dirty(inode);
5094 error = inode_permission(inode, acc_mode);
5097 @@ -2215,7 +2336,8 @@ static int open_will_truncate(int flag,
5100 static struct file *finish_open(struct nameidata *nd,
5101 - int open_flag, int acc_mode)
5102 + int open_flag, int acc_mode,
5103 + const char *pathname)
5107 @@ -2228,6 +2350,23 @@ static struct file *finish_open(struct n
5110 error = may_open(&nd->path, acc_mode, open_flag);
5111 +#ifdef CONFIG_VSERVER_COWBL
5112 + if (error == -EMLINK) {
5113 + struct dentry *dentry;
5114 + dentry = cow_break_link(pathname);
5115 + if (IS_ERR(dentry)) {
5116 + error = PTR_ERR(dentry);
5120 + if (will_truncate)
5121 + mnt_drop_write(nd->path.mnt);
5122 + release_open_intent(nd);
5123 + path_put(&nd->path);
5124 + return ERR_PTR(-EMLINK);
5130 mnt_drop_write(nd->path.mnt);
5131 @@ -2375,7 +2514,7 @@ static struct file *do_last(struct namei
5132 if (S_ISDIR(nd->inode->i_mode))
5135 - filp = finish_open(nd, open_flag, acc_mode);
5136 + filp = finish_open(nd, open_flag, acc_mode, pathname);
5140 @@ -2402,7 +2541,12 @@ struct file *do_filp_open(int dfd, const
5142 int flag = open_to_namei_flags(open_flag);
5144 +#ifdef CONFIG_VSERVER_COWBL
5150 if (!(open_flag & O_CREAT))
5153 @@ -2468,7 +2612,7 @@ struct file *do_filp_open(int dfd, const
5156 audit_inode(pathname, nd.path.dentry);
5157 - filp = finish_open(&nd, open_flag, acc_mode);
5158 + filp = finish_open(&nd, open_flag, acc_mode, pathname);
5160 release_open_intent(&nd);
5162 @@ -2510,6 +2654,13 @@ reval:
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 */
5174 struct path link = path;
5175 struct inode *linki = link.dentry->d_inode;
5176 @@ -2544,6 +2695,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 (linki->i_op->put_link)
5188 linki->i_op->put_link(link.dentry, &nd, cookie);
5190 @@ -2642,9 +2800,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 @@ -3107,7 +3273,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 @@ -3479,6 +3645,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.38.1/fs/namespace.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/namespace.c
5442 --- linux-2.6.38.1/fs/namespace.c 2011-03-15 18:07:32.000000000 +0100
5443 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/namespace.c 2011-03-07 16:53:27.000000000 +0100
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 @@ -702,6 +707,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 @@ -830,6 +836,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 @@ -932,6 +963,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 @@ -978,10 +1011,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 @@ -1011,6 +1054,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 @@ -1069,17 +1117,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 @@ -1337,7 +1395,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 @@ -1363,7 +1421,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 @@ -1653,7 +1711,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 @@ -1684,11 +1742,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 @@ -1723,6 +1783,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 @@ -1753,12 +1814,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 @@ -1802,7 +1863,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 @@ -1888,7 +1949,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))
5662 mnt = do_kern_mount(type, flags, name, data);
5663 @@ -2194,6 +2255,7 @@ long do_mount(char *dev_name, char *dir_
5670 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5671 @@ -2221,6 +2283,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 @@ -2237,15 +2305,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 @@ -2345,6 +2415,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 @@ -2487,9 +2558,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 @@ -2624,6 +2696,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.38.1/fs/nfs/client.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfs/client.c
5734 --- linux-2.6.38.1/fs/nfs/client.c 2011-03-15 18:07:32.000000000 +0100
5735 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfs/client.c 2011-02-02 22:20:25.000000000 +0100
5736 @@ -761,6 +761,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 @@ -934,6 +937,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 server->time_delta = fsinfo->time_delta;
5757 diff -NurpP --minimal linux-2.6.38.1/fs/nfs/dir.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfs/dir.c
5758 --- linux-2.6.38.1/fs/nfs/dir.c 2011-03-15 18:07:32.000000000 +0100
5759 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfs/dir.c 2011-01-29 02:49:21.000000000 +0100
5761 #include <linux/sched.h>
5762 #include <linux/kmemleak.h>
5763 #include <linux/xattr.h>
5764 +#include <linux/vs_tag.h>
5766 #include "delegation.h"
5768 @@ -1224,6 +1225,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.38.1/fs/nfs/inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfs/inode.c
5777 --- linux-2.6.38.1/fs/nfs/inode.c 2011-03-15 18:07:32.000000000 +0100
5778 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfs/inode.c 2011-03-15 18:17:58.000000000 +0100
5780 #include <linux/nfs_xdr.h>
5781 #include <linux/slab.h>
5782 #include <linux/compat.h>
5783 +#include <linux/vs_tag.h>
5785 #include <asm/system.h>
5786 #include <asm/uaccess.h>
5787 @@ -270,6 +271,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 @@ -318,8 +321,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 @@ -356,13 +359,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 @@ -375,6 +378,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 @@ -491,6 +499,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 @@ -939,6 +949,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 @@ -962,13 +975,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 @@ -1203,6 +1221,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 @@ -1305,6 +1326,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 @@ -1326,9 +1350,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 @@ -1337,9 +1361,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 @@ -1347,6 +1371,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.38.1/fs/nfs/nfs3xdr.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfs/nfs3xdr.c
5931 --- linux-2.6.38.1/fs/nfs/nfs3xdr.c 2011-03-15 18:07:32.000000000 +0100
5932 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfs/nfs3xdr.c 2011-02-02 22:20:25.000000000 +0100
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 @@ -562,7 +563,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5945 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5946 +static void encode_sattr3(struct xdr_stream *xdr,
5947 + const struct iattr *attr, int tag)
5951 @@ -594,15 +596,19 @@ static void encode_sattr3(struct xdr_str
5955 - if (attr->ia_valid & ATTR_UID) {
5956 + if (attr->ia_valid & ATTR_UID ||
5957 + (tag && (attr->ia_valid & ATTR_TAG))) {
5959 - *p++ = cpu_to_be32(attr->ia_uid);
5960 + *p++ = cpu_to_be32(TAGINO_UID(tag,
5961 + attr->ia_uid, attr->ia_tag));
5965 - if (attr->ia_valid & ATTR_GID) {
5966 + if (attr->ia_valid & ATTR_GID ||
5967 + (tag && (attr->ia_valid & ATTR_TAG))) {
5969 - *p++ = cpu_to_be32(attr->ia_gid);
5970 + *p++ = cpu_to_be32(TAGINO_GID(tag,
5971 + attr->ia_gid, attr->ia_tag));
5975 @@ -878,7 +884,7 @@ static void nfs3_xdr_enc_setattr3args(st
5976 const struct nfs3_sattrargs *args)
5978 encode_nfs_fh3(xdr, args->fh);
5979 - encode_sattr3(xdr, args->sattr);
5980 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5981 encode_sattrguard3(xdr, args);
5984 @@ -1028,13 +1034,13 @@ static void nfs3_xdr_enc_write3args(stru
5987 static void encode_createhow3(struct xdr_stream *xdr,
5988 - const struct nfs3_createargs *args)
5989 + const struct nfs3_createargs *args, int tag)
5991 encode_uint32(xdr, args->createmode);
5992 switch (args->createmode) {
5993 case NFS3_CREATE_UNCHECKED:
5994 case NFS3_CREATE_GUARDED:
5995 - encode_sattr3(xdr, args->sattr);
5996 + encode_sattr3(xdr, args->sattr, tag);
5998 case NFS3_CREATE_EXCLUSIVE:
5999 encode_createverf3(xdr, args->verifier);
6000 @@ -1049,7 +1055,7 @@ static void nfs3_xdr_enc_create3args(str
6001 const struct nfs3_createargs *args)
6003 encode_diropargs3(xdr, args->fh, args->name, args->len);
6004 - encode_createhow3(xdr, args);
6005 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
6009 @@ -1065,7 +1071,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
6010 const struct nfs3_mkdirargs *args)
6012 encode_diropargs3(xdr, args->fh, args->name, args->len);
6013 - encode_sattr3(xdr, args->sattr);
6014 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
6018 @@ -1082,9 +1088,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
6021 static void encode_symlinkdata3(struct xdr_stream *xdr,
6022 - const struct nfs3_symlinkargs *args)
6023 + const struct nfs3_symlinkargs *args, int tag)
6025 - encode_sattr3(xdr, args->sattr);
6026 + encode_sattr3(xdr, args->sattr, tag);
6027 encode_nfspath3(xdr, args->pages, args->pathlen);
6030 @@ -1093,7 +1099,7 @@ static void nfs3_xdr_enc_symlink3args(st
6031 const struct nfs3_symlinkargs *args)
6033 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
6034 - encode_symlinkdata3(xdr, args);
6035 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
6039 @@ -1121,24 +1127,24 @@ static void nfs3_xdr_enc_symlink3args(st
6042 static void encode_devicedata3(struct xdr_stream *xdr,
6043 - const struct nfs3_mknodargs *args)
6044 + const struct nfs3_mknodargs *args, int tag)
6046 - encode_sattr3(xdr, args->sattr);
6047 + encode_sattr3(xdr, args->sattr, tag);
6048 encode_specdata3(xdr, args->rdev);
6051 static void encode_mknoddata3(struct xdr_stream *xdr,
6052 - const struct nfs3_mknodargs *args)
6053 + const struct nfs3_mknodargs *args, int tag)
6055 encode_ftype3(xdr, args->type);
6056 switch (args->type) {
6059 - encode_devicedata3(xdr, args);
6060 + encode_devicedata3(xdr, args, tag);
6064 - encode_sattr3(xdr, args->sattr);
6065 + encode_sattr3(xdr, args->sattr, tag);
6069 @@ -1153,7 +1159,7 @@ static void nfs3_xdr_enc_mknod3args(stru
6070 const struct nfs3_mknodargs *args)
6072 encode_diropargs3(xdr, args->fh, args->name, args->len);
6073 - encode_mknoddata3(xdr, args);
6074 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
6078 diff -NurpP --minimal linux-2.6.38.1/fs/nfs/super.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfs/super.c
6079 --- linux-2.6.38.1/fs/nfs/super.c 2011-03-15 18:07:32.000000000 +0100
6080 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfs/super.c 2011-01-29 02:01:07.000000000 +0100
6082 #include <linux/nfs_xdr.h>
6083 #include <linux/magic.h>
6084 #include <linux/parser.h>
6085 +#include <linux/vs_tag.h>
6087 #include <asm/system.h>
6088 #include <asm/uaccess.h>
6089 @@ -86,6 +87,7 @@ enum {
6090 Opt_sharecache, Opt_nosharecache,
6091 Opt_resvport, Opt_noresvport,
6092 Opt_fscache, Opt_nofscache,
6093 + Opt_tag, Opt_notag,
6095 /* Mount options that take integer arguments */
6097 @@ -99,6 +101,7 @@ enum {
6103 /* Mount options that take string arguments */
6104 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
6105 @@ -179,6 +182,10 @@ static const match_table_t nfs_mount_opt
6106 { Opt_fscache_uniq, "fsc=%s" },
6107 { Opt_local_lock, "local_lock=%s" },
6109 + { Opt_tag, "tag" },
6110 + { Opt_notag, "notag" },
6111 + { Opt_tagid, "tagid=%u" },
6116 @@ -642,6 +649,7 @@ static void nfs_show_mount_options(struc
6117 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
6118 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
6119 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
6120 + { NFS_MOUNT_TAGGED, ",tag", "" },
6123 const struct proc_nfs_info *nfs_infop;
6124 @@ -1122,6 +1130,14 @@ static int nfs_parse_mount_options(char
6125 kfree(mnt->fscache_uniq);
6126 mnt->fscache_uniq = NULL;
6128 +#ifndef CONFIG_TAGGING_NONE
6130 + mnt->flags |= NFS_MOUNT_TAGGED;
6133 + mnt->flags &= ~NFS_MOUNT_TAGGED;
6138 * options that take numeric values
6139 @@ -1306,6 +1322,12 @@ static int nfs_parse_mount_options(char
6140 goto out_invalid_value;
6141 mnt->minorversion = option;
6143 +#ifdef CONFIG_PROPAGATE
6146 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6151 * options that take text values
6152 diff -NurpP --minimal linux-2.6.38.1/fs/nfsd/auth.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfsd/auth.c
6153 --- linux-2.6.38.1/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
6154 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfsd/auth.c 2011-01-29 02:01:07.000000000 +0100
6156 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
6158 #include <linux/sched.h>
6159 +#include <linux/vs_tag.h>
6163 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6165 new->fsuid = rqstp->rq_cred.cr_uid;
6166 new->fsgid = rqstp->rq_cred.cr_gid;
6167 + /* FIXME: this desperately needs a tag :)
6168 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6171 rqgi = rqstp->rq_cred.cr_group_info;
6173 diff -NurpP --minimal linux-2.6.38.1/fs/nfsd/nfs3xdr.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfsd/nfs3xdr.c
6174 --- linux-2.6.38.1/fs/nfsd/nfs3xdr.c 2011-01-05 21:50:25.000000000 +0100
6175 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfsd/nfs3xdr.c 2011-01-29 02:01:07.000000000 +0100
6179 #include <linux/namei.h>
6180 +#include <linux/vs_tag.h>
6184 @@ -95,6 +96,8 @@ static __be32 *
6185 decode_sattr3(__be32 *p, struct iattr *iap)
6193 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6196 iap->ia_valid |= ATTR_UID;
6197 - iap->ia_uid = ntohl(*p++);
6198 + uid = ntohl(*p++);
6201 iap->ia_valid |= ATTR_GID;
6202 - iap->ia_gid = ntohl(*p++);
6203 + gid = ntohl(*p++);
6205 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6206 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6207 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6211 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6212 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6213 *p++ = htonl((u32) stat->mode);
6214 *p++ = htonl((u32) stat->nlink);
6215 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6216 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6217 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6218 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6219 + stat->uid, stat->tag)));
6220 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6221 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6222 + stat->gid, stat->tag)));
6223 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6224 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6226 diff -NurpP --minimal linux-2.6.38.1/fs/nfsd/nfs4xdr.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfsd/nfs4xdr.c
6227 --- linux-2.6.38.1/fs/nfsd/nfs4xdr.c 2011-03-15 18:07:32.000000000 +0100
6228 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfsd/nfs4xdr.c 2011-03-15 18:15:06.000000000 +0100
6230 #include <linux/statfs.h>
6231 #include <linux/utsname.h>
6232 #include <linux/sunrpc/svcauth_gss.h>
6233 +#include <linux/vs_tag.h>
6237 @@ -2098,14 +2099,18 @@ out_acl:
6238 WRITE32(stat.nlink);
6240 if (bmval1 & FATTR4_WORD1_OWNER) {
6241 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6242 + status = nfsd4_encode_user(rqstp,
6243 + TAGINO_UID(DX_TAG(dentry->d_inode),
6244 + stat.uid, stat.tag), &p, &buflen);
6245 if (status == nfserr_resource)
6250 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6251 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6252 + status = nfsd4_encode_group(rqstp,
6253 + TAGINO_GID(DX_TAG(dentry->d_inode),
6254 + stat.gid, stat.tag), &p, &buflen);
6255 if (status == nfserr_resource)
6258 diff -NurpP --minimal linux-2.6.38.1/fs/nfsd/nfsxdr.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfsd/nfsxdr.c
6259 --- linux-2.6.38.1/fs/nfsd/nfsxdr.c 2010-02-25 11:52:05.000000000 +0100
6260 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/nfsd/nfsxdr.c 2011-01-29 02:01:07.000000000 +0100
6265 +#include <linux/vs_tag.h>
6267 #define NFSDDBG_FACILITY NFSDDBG_XDR
6269 @@ -88,6 +89,8 @@ static __be32 *
6270 decode_sattr(__be32 *p, struct iattr *iap)
6278 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6280 if ((tmp = ntohl(*p++)) != (u32)-1) {
6281 iap->ia_valid |= ATTR_UID;
6282 - iap->ia_uid = tmp;
6285 if ((tmp = ntohl(*p++)) != (u32)-1) {
6286 iap->ia_valid |= ATTR_GID;
6287 - iap->ia_gid = tmp;
6290 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6291 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6292 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6293 if ((tmp = ntohl(*p++)) != (u32)-1) {
6294 iap->ia_valid |= ATTR_SIZE;
6296 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6297 *p++ = htonl(nfs_ftypes[type >> 12]);
6298 *p++ = htonl((u32) stat->mode);
6299 *p++ = htonl((u32) stat->nlink);
6300 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6301 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6302 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6303 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6304 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6305 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6307 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6308 *p++ = htonl(NFS_MAXPATHLEN);
6309 diff -NurpP --minimal linux-2.6.38.1/fs/ocfs2/dlmglue.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/dlmglue.c
6310 --- linux-2.6.38.1/fs/ocfs2/dlmglue.c 2011-01-05 21:50:26.000000000 +0100
6311 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/dlmglue.c 2011-01-29 02:01:07.000000000 +0100
6312 @@ -2114,6 +2114,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6313 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6314 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6315 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6316 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6317 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6318 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6319 lvb->lvb_iatime_packed =
6320 @@ -2168,6 +2169,7 @@ static void ocfs2_refresh_inode_from_lvb
6322 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6323 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6324 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6325 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6326 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6327 ocfs2_unpack_timespec(&inode->i_atime,
6328 diff -NurpP --minimal linux-2.6.38.1/fs/ocfs2/dlmglue.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/dlmglue.h
6329 --- linux-2.6.38.1/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
6330 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/dlmglue.h 2011-01-29 02:01:07.000000000 +0100
6331 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6334 __be32 lvb_igeneration;
6335 - __be32 lvb_reserved2;
6337 + __be16 lvb_reserved2;
6340 #define OCFS2_QINFO_LVB_VERSION 1
6341 diff -NurpP --minimal linux-2.6.38.1/fs/ocfs2/file.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/file.c
6342 --- linux-2.6.38.1/fs/ocfs2/file.c 2011-03-15 18:07:33.000000000 +0100
6343 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/file.c 2011-01-29 02:01:07.000000000 +0100
6344 @@ -1126,13 +1126,15 @@ int ocfs2_setattr(struct dentry *dentry,
6345 mlog(0, "uid change: %d\n", attr->ia_uid);
6346 if (attr->ia_valid & ATTR_GID)
6347 mlog(0, "gid change: %d\n", attr->ia_gid);
6348 + if (attr->ia_valid & ATTR_TAG)
6349 + mlog(0, "tag change: %d\n", attr->ia_tag);
6350 if (attr->ia_valid & ATTR_SIZE)
6351 mlog(0, "size change...\n");
6352 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6353 mlog(0, "time change...\n");
6355 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6356 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6357 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6358 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6359 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6361 diff -NurpP --minimal linux-2.6.38.1/fs/ocfs2/inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/inode.c
6362 --- linux-2.6.38.1/fs/ocfs2/inode.c 2011-03-15 18:07:33.000000000 +0100
6363 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/inode.c 2011-01-29 02:01:07.000000000 +0100
6365 #include <linux/highmem.h>
6366 #include <linux/pagemap.h>
6367 #include <linux/quotaops.h>
6368 +#include <linux/vs_tag.h>
6370 #include <asm/byteorder.h>
6372 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
6374 unsigned int flags = OCFS2_I(inode)->ip_attr;
6376 - inode->i_flags &= ~(S_IMMUTABLE |
6377 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6378 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6380 if (flags & OCFS2_IMMUTABLE_FL)
6381 inode->i_flags |= S_IMMUTABLE;
6382 + if (flags & OCFS2_IXUNLINK_FL)
6383 + inode->i_flags |= S_IXUNLINK;
6385 if (flags & OCFS2_SYNC_FL)
6386 inode->i_flags |= S_SYNC;
6387 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
6388 inode->i_flags |= S_NOATIME;
6389 if (flags & OCFS2_DIRSYNC_FL)
6390 inode->i_flags |= S_DIRSYNC;
6392 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6394 + if (flags & OCFS2_BARRIER_FL)
6395 + inode->i_vflags |= V_BARRIER;
6396 + if (flags & OCFS2_COW_FL)
6397 + inode->i_vflags |= V_COW;
6400 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6401 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6403 unsigned int flags = oi->vfs_inode.i_flags;
6404 + unsigned int vflags = oi->vfs_inode.i_vflags;
6406 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6407 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6408 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6409 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6411 + if (flags & S_IMMUTABLE)
6412 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6413 + if (flags & S_IXUNLINK)
6414 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6416 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6417 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6419 oi->ip_attr |= OCFS2_SYNC_FL;
6420 if (flags & S_APPEND)
6421 oi->ip_attr |= OCFS2_APPEND_FL;
6422 - if (flags & S_IMMUTABLE)
6423 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6424 if (flags & S_NOATIME)
6425 oi->ip_attr |= OCFS2_NOATIME_FL;
6426 if (flags & S_DIRSYNC)
6427 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6429 + if (vflags & V_BARRIER)
6430 + oi->ip_attr |= OCFS2_BARRIER_FL;
6431 + if (vflags & V_COW)
6432 + oi->ip_attr |= OCFS2_COW_FL;
6435 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
6436 @@ -245,6 +267,8 @@ void ocfs2_populate_inode(struct inode *
6437 struct super_block *sb;
6438 struct ocfs2_super *osb;
6443 mlog_entry("(0x%p, size:%llu)\n", inode,
6444 (unsigned long long)le64_to_cpu(fe->i_size));
6445 @@ -276,8 +300,12 @@ void ocfs2_populate_inode(struct inode *
6446 inode->i_generation = le32_to_cpu(fe->i_generation);
6447 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6448 inode->i_mode = le16_to_cpu(fe->i_mode);
6449 - inode->i_uid = le32_to_cpu(fe->i_uid);
6450 - inode->i_gid = le32_to_cpu(fe->i_gid);
6451 + uid = le32_to_cpu(fe->i_uid);
6452 + gid = le32_to_cpu(fe->i_gid);
6453 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6454 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6455 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6456 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6458 /* Fast symlinks will have i_size but no allocated clusters. */
6459 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6460 diff -NurpP --minimal linux-2.6.38.1/fs/ocfs2/inode.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/inode.h
6461 --- linux-2.6.38.1/fs/ocfs2/inode.h 2011-01-05 21:50:26.000000000 +0100
6462 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/inode.h 2011-01-29 02:01:07.000000000 +0100
6463 @@ -151,6 +151,7 @@ struct buffer_head *ocfs2_bread(struct i
6465 void ocfs2_set_inode_flags(struct inode *inode);
6466 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6467 +int ocfs2_sync_flags(struct inode *inode, int, int);
6469 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6471 diff -NurpP --minimal linux-2.6.38.1/fs/ocfs2/ioctl.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/ioctl.c
6472 --- linux-2.6.38.1/fs/ocfs2/ioctl.c 2011-01-05 21:50:26.000000000 +0100
6473 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/ioctl.c 2011-01-29 02:01:07.000000000 +0100
6474 @@ -63,7 +63,41 @@ static int ocfs2_get_inode_attr(struct i
6478 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6479 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6481 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6482 + struct buffer_head *bh = NULL;
6483 + handle_t *handle = NULL;
6486 + status = ocfs2_inode_lock(inode, &bh, 1);
6488 + mlog_errno(status);
6491 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6492 + if (IS_ERR(handle)) {
6493 + status = PTR_ERR(handle);
6494 + mlog_errno(status);
6498 + inode->i_flags = flags;
6499 + inode->i_vflags = vflags;
6500 + ocfs2_get_inode_flags(OCFS2_I(inode));
6502 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6504 + mlog_errno(status);
6506 + ocfs2_commit_trans(osb, handle);
6508 + ocfs2_inode_unlock(inode, 1);
6513 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6516 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6517 @@ -88,6 +122,11 @@ static int ocfs2_set_inode_attr(struct i
6518 if (!S_ISDIR(inode->i_mode))
6519 flags &= ~OCFS2_DIRSYNC_FL;
6521 + if (IS_BARRIER(inode)) {
6522 + vxwprintk_task(1, "messing with the barrier.");
6526 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6527 if (IS_ERR(handle)) {
6528 status = PTR_ERR(handle);
6529 @@ -451,6 +490,7 @@ bail:
6534 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6536 struct inode *inode = filp->f_path.dentry->d_inode;
6537 diff -NurpP --minimal linux-2.6.38.1/fs/ocfs2/namei.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/namei.c
6538 --- linux-2.6.38.1/fs/ocfs2/namei.c 2011-03-15 18:07:33.000000000 +0100
6539 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/namei.c 2011-01-29 02:01:07.000000000 +0100
6541 #include <linux/slab.h>
6542 #include <linux/highmem.h>
6543 #include <linux/quotaops.h>
6544 +#include <linux/vs_tag.h>
6546 #define MLOG_MASK_PREFIX ML_NAMEI
6547 #include <cluster/masklog.h>
6548 @@ -485,6 +486,7 @@ static int __ocfs2_mknod_locked(struct i
6549 struct ocfs2_dinode *fe = NULL;
6550 struct ocfs2_extent_list *fel;
6556 @@ -522,8 +524,11 @@ static int __ocfs2_mknod_locked(struct i
6557 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
6558 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6559 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6560 - fe->i_uid = cpu_to_le32(inode->i_uid);
6561 - fe->i_gid = cpu_to_le32(inode->i_gid);
6563 + tag = dx_current_fstag(osb->sb);
6564 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6565 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6566 + inode->i_tag = tag;
6567 fe->i_mode = cpu_to_le16(inode->i_mode);
6568 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6569 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6570 diff -NurpP --minimal linux-2.6.38.1/fs/ocfs2/ocfs2.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/ocfs2.h
6571 --- linux-2.6.38.1/fs/ocfs2/ocfs2.h 2011-03-15 18:07:33.000000000 +0100
6572 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/ocfs2.h 2011-01-29 02:01:07.000000000 +0100
6573 @@ -267,6 +267,7 @@ enum ocfs2_mount_options
6575 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
6576 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
6577 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
6580 #define OCFS2_OSB_SOFT_RO 0x0001
6581 diff -NurpP --minimal linux-2.6.38.1/fs/ocfs2/ocfs2_fs.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/ocfs2_fs.h
6582 --- linux-2.6.38.1/fs/ocfs2/ocfs2_fs.h 2011-01-05 21:50:26.000000000 +0100
6583 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/ocfs2_fs.h 2011-01-29 02:01:07.000000000 +0100
6584 @@ -266,6 +266,11 @@
6585 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
6586 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
6588 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6590 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6591 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6593 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
6594 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
6596 diff -NurpP --minimal linux-2.6.38.1/fs/ocfs2/super.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/super.c
6597 --- linux-2.6.38.1/fs/ocfs2/super.c 2011-03-15 18:07:33.000000000 +0100
6598 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/ocfs2/super.c 2011-03-07 16:53:27.000000000 +0100
6599 @@ -181,6 +181,7 @@ enum {
6603 + Opt_tag, Opt_notag, Opt_tagid,
6607 @@ -212,6 +213,9 @@ static const match_table_t tokens = {
6608 {Opt_coherency_full, "coherency=full"},
6609 {Opt_resv_level, "resv_level=%u"},
6610 {Opt_dir_resv_level, "dir_resv_level=%u"},
6612 + {Opt_notag, "notag"},
6613 + {Opt_tagid, "tagid=%u"},
6617 @@ -666,6 +670,13 @@ static int ocfs2_remount(struct super_bl
6621 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6622 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6624 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6628 /* We're going to/from readonly mode. */
6629 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
6630 /* Disable quota accounting before remounting RO */
6631 @@ -1183,6 +1194,9 @@ static int ocfs2_fill_super(struct super
6633 ocfs2_complete_mount_recovery(osb);
6635 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6636 + sb->s_flags |= MS_TAGGED;
6638 if (ocfs2_mount_local(osb))
6639 snprintf(nodestr, sizeof(nodestr), "local");
6641 @@ -1514,6 +1528,20 @@ static int ocfs2_parse_options(struct su
6642 option < OCFS2_MAX_RESV_LEVEL)
6643 mopt->dir_resv_level = option;
6645 +#ifndef CONFIG_TAGGING_NONE
6647 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6650 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6653 +#ifdef CONFIG_PROPAGATE
6656 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6661 "Unrecognized mount option \"%s\" "
6662 diff -NurpP --minimal linux-2.6.38.1/fs/open.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/open.c
6663 --- linux-2.6.38.1/fs/open.c 2011-03-15 18:07:33.000000000 +0100
6664 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/open.c 2011-03-15 18:15:06.000000000 +0100
6666 #include <linux/fs_struct.h>
6667 #include <linux/ima.h>
6668 #include <linux/dnotify.h>
6669 +#include <linux/vs_base.h>
6670 +#include <linux/vs_limit.h>
6671 +#include <linux/vs_tag.h>
6672 +#include <linux/vs_cowbl.h>
6673 +#include <linux/vserver/dlimit.h>
6675 #include "internal.h"
6677 @@ -494,6 +499,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6678 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6682 +#ifdef CONFIG_VSERVER_COWBL
6683 + error = cow_check_and_break(&path);
6685 + goto dput_and_out;
6687 inode = path.dentry->d_inode;
6689 error = mnt_want_write(path.mnt);
6690 @@ -531,11 +542,11 @@ static int chown_common(struct path *pat
6691 newattrs.ia_valid = ATTR_CTIME;
6692 if (user != (uid_t) -1) {
6693 newattrs.ia_valid |= ATTR_UID;
6694 - newattrs.ia_uid = user;
6695 + newattrs.ia_uid = dx_map_uid(user);
6697 if (group != (gid_t) -1) {
6698 newattrs.ia_valid |= ATTR_GID;
6699 - newattrs.ia_gid = group;
6700 + newattrs.ia_gid = dx_map_gid(group);
6702 if (!S_ISDIR(inode->i_mode))
6703 newattrs.ia_valid |=
6704 @@ -560,6 +571,10 @@ SYSCALL_DEFINE3(chown, const char __user
6705 error = mnt_want_write(path.mnt);
6708 +#ifdef CONFIG_VSERVER_COWBL
6709 + error = cow_check_and_break(&path);
6712 error = chown_common(&path, user, group);
6713 mnt_drop_write(path.mnt);
6715 @@ -585,6 +600,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6716 error = mnt_want_write(path.mnt);
6719 +#ifdef CONFIG_VSERVER_COWBL
6720 + error = cow_check_and_break(&path);
6723 error = chown_common(&path, user, group);
6724 mnt_drop_write(path.mnt);
6726 @@ -604,6 +623,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6727 error = mnt_want_write(path.mnt);
6730 +#ifdef CONFIG_VSERVER_COWBL
6731 + error = cow_check_and_break(&path);
6734 error = chown_common(&path, user, group);
6735 mnt_drop_write(path.mnt);
6737 @@ -852,6 +875,7 @@ static void __put_unused_fd(struct files
6738 __FD_CLR(fd, fdt->open_fds);
6739 if (fd < files->next_fd)
6740 files->next_fd = fd;
6741 + vx_openfd_dec(fd);
6744 void put_unused_fd(unsigned int fd)
6745 diff -NurpP --minimal linux-2.6.38.1/fs/proc/array.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/array.c
6746 --- linux-2.6.38.1/fs/proc/array.c 2011-03-15 18:07:33.000000000 +0100
6747 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/array.c 2011-02-17 02:23:41.000000000 +0100
6749 #include <linux/pid_namespace.h>
6750 #include <linux/ptrace.h>
6751 #include <linux/tracehook.h>
6752 +#include <linux/vs_context.h>
6753 +#include <linux/vs_network.h>
6755 #include <asm/pgtable.h>
6756 #include <asm/processor.h>
6757 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
6759 ppid = pid_alive(p) ?
6760 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6761 + if (unlikely(vx_current_initpid(p->pid)))
6766 struct task_struct *tracer = tracehook_tracer_task(p);
6767 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6770 static void render_cap_t(struct seq_file *m, const char *header,
6772 + struct vx_info *vxi, kernel_cap_t *a)
6776 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6777 cap_bset = cred->cap_bset;
6780 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6781 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6782 - render_cap_t(m, "CapEff:\t", &cap_effective);
6783 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6784 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6785 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6786 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6787 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6788 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6791 static inline void task_context_switch_counts(struct seq_file *m,
6792 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6796 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6797 + struct pid *pid, struct task_struct *task)
6799 + seq_printf(m, "Proxy:\t%p(%c)\n"
6807 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6808 + atomic_read(&task->nsproxy->count),
6809 + task->nsproxy->uts_ns,
6810 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6811 + task->nsproxy->ipc_ns,
6812 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6813 + task->nsproxy->mnt_ns,
6814 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6815 + task->nsproxy->pid_ns,
6816 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6817 + task->nsproxy->net_ns,
6818 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6822 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6824 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6827 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6828 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6832 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6833 struct pid *pid, struct task_struct *task)
6835 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6837 task_cpus_allowed(m, task);
6838 cpuset_task_status_allowed(m, task);
6839 + task_vs_id(m, task);
6840 task_context_switch_counts(m, task);
6843 @@ -462,6 +505,17 @@ static int do_task_stat(struct seq_file
6844 /* convert nsec -> ticks */
6845 start_time = nsec_to_clock_t(start_time);
6847 + /* fixup start time for virt uptime */
6848 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6849 + unsigned long long bias =
6850 + current->vx_info->cvirt.bias_clock;
6852 + if (start_time > bias)
6853 + start_time -= bias;
6858 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6859 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6860 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6861 diff -NurpP --minimal linux-2.6.38.1/fs/proc/base.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/base.c
6862 --- linux-2.6.38.1/fs/proc/base.c 2011-03-15 18:07:33.000000000 +0100
6863 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/base.c 2011-03-15 18:15:06.000000000 +0100
6865 #include <linux/pid_namespace.h>
6866 #include <linux/fs_struct.h>
6867 #include <linux/slab.h>
6868 +#include <linux/vs_context.h>
6869 +#include <linux/vs_network.h>
6870 #include "internal.h"
6873 @@ -1043,11 +1045,16 @@ static ssize_t oom_adjust_write(struct f
6877 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6878 + if (oom_adjust < task->signal->oom_adj &&
6879 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6884 + /* prevent guest processes from circumventing the oom killer */
6885 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6886 + oom_adjust = OOM_ADJUST_MIN;
6888 if (oom_adjust != task->signal->oom_adj) {
6889 if (oom_adjust == OOM_DISABLE)
6890 atomic_inc(&task->mm->oom_disable_count);
6891 @@ -1216,7 +1223,7 @@ static ssize_t proc_loginuid_write(struc
6895 - if (!capable(CAP_AUDIT_CONTROL))
6896 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6900 @@ -1715,6 +1722,8 @@ static struct inode *proc_pid_make_inode
6901 inode->i_gid = cred->egid;
6904 + /* procfs is xid tagged */
6905 + inode->i_tag = (tag_t)vx_task_xid(task);
6906 security_task_to_inode(task, inode);
6909 @@ -1751,6 +1760,8 @@ static int pid_getattr(struct vfsmount *
6913 +static unsigned name_to_int(struct dentry *dentry);
6916 * Exceptional case: normally we are not allowed to unhash a busy
6917 * directory. In this case, however, we can do it - no aliasing problems
6918 @@ -1779,6 +1790,12 @@ static int pid_revalidate(struct dentry
6919 task = get_proc_task(inode);
6922 + unsigned pid = name_to_int(dentry);
6924 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6925 + put_task_struct(task);
6928 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6929 task_dumpable(task)) {
6931 @@ -1795,6 +1812,7 @@ static int pid_revalidate(struct dentry
6932 put_task_struct(task);
6939 @@ -2283,6 +2301,13 @@ static struct dentry *proc_pident_lookup
6943 + /* TODO: maybe we can come up with a generic approach? */
6944 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6945 + (dentry->d_name.len == 5) &&
6946 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6947 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6951 * Yes, it does not scale. And it should not. Don't add
6952 * new entries into /proc/<tgid>/ without very good reasons.
6953 @@ -2668,7 +2693,7 @@ out_iput:
6954 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6956 struct dentry *error;
6957 - struct task_struct *task = get_proc_task(dir);
6958 + struct task_struct *task = get_proc_task_real(dir);
6959 const struct pid_entry *p, *last;
6961 error = ERR_PTR(-ENOENT);
6962 @@ -2758,6 +2783,9 @@ static int proc_pid_personality(struct s
6963 static const struct file_operations proc_task_operations;
6964 static const struct inode_operations proc_task_inode_operations;
6966 +extern int proc_pid_vx_info(struct task_struct *, char *);
6967 +extern int proc_pid_nx_info(struct task_struct *, char *);
6969 static const struct pid_entry tgid_base_stuff[] = {
6970 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6971 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6972 @@ -2820,6 +2848,8 @@ static const struct pid_entry tgid_base_
6973 #ifdef CONFIG_CGROUPS
6974 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6976 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6977 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6978 INF("oom_score", S_IRUGO, proc_oom_score),
6979 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6980 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6981 @@ -2836,6 +2866,7 @@ static const struct pid_entry tgid_base_
6982 #ifdef CONFIG_TASK_IO_ACCOUNTING
6983 INF("io", S_IRUGO, proc_tgid_io_accounting),
6985 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6988 static int proc_tgid_base_readdir(struct file * filp,
6989 @@ -3028,7 +3059,7 @@ retry:
6991 pid = find_ge_pid(iter.tgid, ns);
6993 - iter.tgid = pid_nr_ns(pid, ns);
6994 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6995 iter.task = pid_task(pid, PIDTYPE_PID);
6996 /* What we to know is if the pid we have find is the
6997 * pid of a thread_group_leader. Testing for task
6998 @@ -3058,7 +3089,7 @@ static int proc_pid_fill_cache(struct fi
6999 struct tgid_iter iter)
7001 char name[PROC_NUMBUF];
7002 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
7003 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
7004 return proc_fill_cache(filp, dirent, filldir, name, len,
7005 proc_pid_instantiate, iter.task, NULL);
7007 @@ -3067,7 +3098,7 @@ static int proc_pid_fill_cache(struct fi
7008 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
7010 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
7011 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
7012 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
7013 struct tgid_iter iter;
7014 struct pid_namespace *ns;
7016 @@ -3087,6 +3118,8 @@ int proc_pid_readdir(struct file * filp,
7018 iter.tgid += 1, iter = next_tgid(ns, iter)) {
7019 filp->f_pos = iter.tgid + TGID_OFFSET;
7020 + if (!vx_proc_task_visible(iter.task))
7022 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
7023 put_task_struct(iter.task);
7025 @@ -3236,6 +3269,8 @@ static struct dentry *proc_task_lookup(s
7026 tid = name_to_int(dentry);
7029 + if (vx_current_initpid(tid))
7032 ns = dentry->d_sb->s_fs_info;
7034 diff -NurpP --minimal linux-2.6.38.1/fs/proc/generic.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/generic.c
7035 --- linux-2.6.38.1/fs/proc/generic.c 2011-03-15 18:07:33.000000000 +0100
7036 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/generic.c 2011-01-29 02:29:09.000000000 +0100
7038 #include <linux/bitops.h>
7039 #include <linux/spinlock.h>
7040 #include <linux/completion.h>
7041 +#include <linux/vserver/inode.h>
7042 #include <asm/uaccess.h>
7044 #include "internal.h"
7045 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
7046 for (de = de->subdir; de ; de = de->next) {
7047 if (de->namelen != dentry->d_name.len)
7049 + if (!vx_hide_check(0, de->vx_flags))
7051 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
7053 spin_unlock(&proc_subdir_lock);
7055 inode = proc_get_inode(dir->i_sb, de);
7056 + /* generic proc entries belong to the host */
7061 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
7063 /* filldir passes info to user space */
7065 + if (!vx_hide_check(0, de->vx_flags))
7067 spin_unlock(&proc_subdir_lock);
7068 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
7069 de->low_ino, de->mode >> 12) < 0) {
7070 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
7073 spin_lock(&proc_subdir_lock);
7078 @@ -627,6 +635,7 @@ static struct proc_dir_entry *__proc_cre
7080 atomic_set(&ent->count, 1);
7082 + ent->vx_flags = IATTR_PROC_DEFAULT;
7083 spin_lock_init(&ent->pde_unload_lock);
7084 ent->pde_unload_completion = NULL;
7085 INIT_LIST_HEAD(&ent->pde_openers);
7086 @@ -650,7 +659,8 @@ struct proc_dir_entry *proc_symlink(cons
7092 + ent->vx_flags = IATTR_PROC_SYMLINK;
7096 diff -NurpP --minimal linux-2.6.38.1/fs/proc/inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/inode.c
7097 --- linux-2.6.38.1/fs/proc/inode.c 2011-03-15 18:07:33.000000000 +0100
7098 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/inode.c 2011-03-15 18:15:06.000000000 +0100
7099 @@ -437,6 +437,8 @@ struct inode *proc_get_inode(struct supe
7100 inode->i_uid = de->uid;
7101 inode->i_gid = de->gid;
7104 + PROC_I(inode)->vx_flags = de->vx_flags;
7106 inode->i_size = de->size;
7108 diff -NurpP --minimal linux-2.6.38.1/fs/proc/internal.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/internal.h
7109 --- linux-2.6.38.1/fs/proc/internal.h 2011-03-15 18:07:33.000000000 +0100
7110 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/internal.h 2011-01-29 02:01:07.000000000 +0100
7114 #include <linux/proc_fs.h>
7115 +#include <linux/vs_pid.h>
7117 extern struct proc_dir_entry proc_root;
7118 #ifdef CONFIG_PROC_SYSCTL
7119 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
7120 struct pid *pid, struct task_struct *task);
7121 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7122 struct pid *pid, struct task_struct *task);
7123 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7124 + struct pid *pid, struct task_struct *task);
7126 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7128 extern const struct file_operations proc_maps_operations;
7129 @@ -68,11 +72,16 @@ static inline struct pid *proc_pid(struc
7130 return PROC_I(inode)->pid;
7133 -static inline struct task_struct *get_proc_task(struct inode *inode)
7134 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7136 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7139 +static inline struct task_struct *get_proc_task(struct inode *inode)
7141 + return vx_get_proc_task(inode, proc_pid(inode));
7144 static inline int proc_fd(struct inode *inode)
7146 return PROC_I(inode)->fd;
7147 diff -NurpP --minimal linux-2.6.38.1/fs/proc/loadavg.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/loadavg.c
7148 --- linux-2.6.38.1/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
7149 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/loadavg.c 2011-01-29 02:01:07.000000000 +0100
7152 static int loadavg_proc_show(struct seq_file *m, void *v)
7154 + unsigned long running;
7155 + unsigned int threads;
7156 unsigned long avnrun[3];
7158 get_avenrun(avnrun, FIXED_1/200, 0);
7160 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7161 + struct vx_info *vxi = current_vx_info();
7163 + running = atomic_read(&vxi->cvirt.nr_running);
7164 + threads = atomic_read(&vxi->cvirt.nr_threads);
7166 + running = nr_running();
7167 + threads = nr_threads;
7170 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
7171 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
7172 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
7173 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
7174 - nr_running(), nr_threads,
7176 task_active_pid_ns(current)->last_pid);
7179 diff -NurpP --minimal linux-2.6.38.1/fs/proc/meminfo.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/meminfo.c
7180 --- linux-2.6.38.1/fs/proc/meminfo.c 2011-03-15 18:07:33.000000000 +0100
7181 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/meminfo.c 2011-01-29 02:01:07.000000000 +0100
7182 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
7183 allowed = ((totalram_pages - hugetlb_total_pages())
7184 * sysctl_overcommit_ratio / 100) + total_swap_pages;
7186 - cached = global_page_state(NR_FILE_PAGES) -
7187 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
7188 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
7189 total_swapcache_pages - i.bufferram;
7192 diff -NurpP --minimal linux-2.6.38.1/fs/proc/root.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/root.c
7193 --- linux-2.6.38.1/fs/proc/root.c 2011-01-05 21:50:26.000000000 +0100
7194 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/root.c 2011-01-29 02:01:07.000000000 +0100
7196 #include <linux/bitops.h>
7197 #include <linux/mount.h>
7198 #include <linux/pid_namespace.h>
7199 +#include <linux/vserver/inode.h>
7201 #include "internal.h"
7203 +struct proc_dir_entry *proc_virtual;
7205 +extern void proc_vx_init(void);
7207 static int proc_test_super(struct super_block *sb, void *data)
7209 return sb->s_fs_info == data;
7210 @@ -134,6 +139,7 @@ void __init proc_root_init(void)
7212 proc_mkdir("bus", NULL);
7217 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7218 @@ -202,6 +208,7 @@ struct proc_dir_entry proc_root = {
7219 .proc_iops = &proc_root_inode_operations,
7220 .proc_fops = &proc_root_operations,
7221 .parent = &proc_root,
7222 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7225 int pid_ns_prepare_proc(struct pid_namespace *ns)
7226 diff -NurpP --minimal linux-2.6.38.1/fs/proc/uptime.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/uptime.c
7227 --- linux-2.6.38.1/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
7228 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/proc/uptime.c 2011-01-29 02:01:07.000000000 +0100
7230 #include <linux/sched.h>
7231 #include <linux/seq_file.h>
7232 #include <linux/time.h>
7233 -#include <linux/kernel_stat.h>
7234 +#include <linux/vserver/cvirt.h>
7235 #include <asm/cputime.h>
7237 static int uptime_proc_show(struct seq_file *m, void *v)
7239 struct timespec uptime;
7240 struct timespec idle;
7242 - cputime_t idletime = cputime_zero;
7244 - for_each_possible_cpu(i)
7245 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
7246 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
7248 do_posix_clock_monotonic_gettime(&uptime);
7249 monotonic_to_bootbased(&uptime);
7250 cputime_to_timespec(idletime, &idle);
7252 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7253 + vx_vsi_uptime(&uptime, &idle);
7255 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
7256 (unsigned long) uptime.tv_sec,
7257 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7258 diff -NurpP --minimal linux-2.6.38.1/fs/quota/dquot.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/quota/dquot.c
7259 --- linux-2.6.38.1/fs/quota/dquot.c 2011-03-15 18:07:33.000000000 +0100
7260 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/quota/dquot.c 2011-01-29 02:01:07.000000000 +0100
7261 @@ -1545,6 +1545,9 @@ int __dquot_alloc_space(struct inode *in
7262 int reserve = flags & DQUOT_SPACE_RESERVE;
7263 int nofail = flags & DQUOT_SPACE_NOFAIL;
7265 + if ((ret = dl_alloc_space(inode, number)))
7269 * First test before acquiring mutex - solves deadlocks when we
7270 * re-enter the quota code and are already holding the mutex
7271 @@ -1599,6 +1602,9 @@ int dquot_alloc_inode(const struct inode
7273 char warntype[MAXQUOTAS];
7275 + if ((ret = dl_alloc_inode(inode)))
7278 /* First test before acquiring mutex - solves deadlocks when we
7279 * re-enter the quota code and are already holding the mutex */
7280 if (!dquot_active(inode))
7281 @@ -1669,6 +1675,8 @@ void __dquot_free_space(struct inode *in
7282 char warntype[MAXQUOTAS];
7283 int reserve = flags & DQUOT_SPACE_RESERVE;
7285 + dl_free_space(inode, number);
7287 /* First test before acquiring mutex - solves deadlocks when we
7288 * re-enter the quota code and are already holding the mutex */
7289 if (!dquot_active(inode)) {
7290 @@ -1707,6 +1715,8 @@ void dquot_free_inode(const struct inode
7292 char warntype[MAXQUOTAS];
7294 + dl_free_inode(inode);
7296 /* First test before acquiring mutex - solves deadlocks when we
7297 * re-enter the quota code and are already holding the mutex */
7298 if (!dquot_active(inode))
7299 diff -NurpP --minimal linux-2.6.38.1/fs/quota/quota.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/quota/quota.c
7300 --- linux-2.6.38.1/fs/quota/quota.c 2011-03-15 18:07:34.000000000 +0100
7301 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/quota/quota.c 2011-01-29 02:01:07.000000000 +0100
7303 #include <linux/fs.h>
7304 #include <linux/namei.h>
7305 #include <linux/slab.h>
7306 +#include <linux/vs_context.h>
7307 #include <asm/current.h>
7308 #include <asm/uaccess.h>
7309 #include <linux/kernel.h>
7310 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
7314 - if (!capable(CAP_SYS_ADMIN))
7315 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7319 @@ -293,6 +294,46 @@ static int do_quotactl(struct super_bloc
7323 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7325 +#include <linux/vroot.h>
7326 +#include <linux/major.h>
7327 +#include <linux/module.h>
7328 +#include <linux/kallsyms.h>
7329 +#include <linux/vserver/debug.h>
7331 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7333 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7335 +int register_vroot_grb(vroot_grb_func *func) {
7338 + spin_lock(&vroot_grb_lock);
7339 + if (!vroot_get_real_bdev) {
7340 + vroot_get_real_bdev = func;
7343 + spin_unlock(&vroot_grb_lock);
7346 +EXPORT_SYMBOL(register_vroot_grb);
7348 +int unregister_vroot_grb(vroot_grb_func *func) {
7349 + int ret = -EINVAL;
7351 + spin_lock(&vroot_grb_lock);
7352 + if (vroot_get_real_bdev) {
7353 + vroot_get_real_bdev = NULL;
7356 + spin_unlock(&vroot_grb_lock);
7359 +EXPORT_SYMBOL(unregister_vroot_grb);
7364 * look up a superblock on which quota ops will be performed
7365 * - use the name of a block device to find the superblock thereon
7366 @@ -310,6 +351,22 @@ static struct super_block *quotactl_bloc
7369 return ERR_CAST(bdev);
7370 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7371 + if (bdev && bdev->bd_inode &&
7372 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7373 + struct block_device *bdnew = (void *)-EINVAL;
7375 + if (vroot_get_real_bdev)
7376 + bdnew = vroot_get_real_bdev(bdev);
7378 + vxdprintk(VXD_CBIT(misc, 0),
7379 + "vroot_get_real_bdev not set");
7381 + if (IS_ERR(bdnew))
7382 + return ERR_PTR(PTR_ERR(bdnew));
7386 sb = get_super(bdev);
7389 diff -NurpP --minimal linux-2.6.38.1/fs/reiserfs/file.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/reiserfs/file.c
7390 --- linux-2.6.38.1/fs/reiserfs/file.c 2011-01-05 21:50:26.000000000 +0100
7391 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/reiserfs/file.c 2011-01-29 02:01:07.000000000 +0100
7392 @@ -312,4 +312,5 @@ const struct inode_operations reiserfs_f
7393 .listxattr = reiserfs_listxattr,
7394 .removexattr = reiserfs_removexattr,
7395 .permission = reiserfs_permission,
7396 + .sync_flags = reiserfs_sync_flags,
7398 diff -NurpP --minimal linux-2.6.38.1/fs/reiserfs/inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/reiserfs/inode.c
7399 --- linux-2.6.38.1/fs/reiserfs/inode.c 2011-01-05 21:50:26.000000000 +0100
7400 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/reiserfs/inode.c 2011-01-29 02:01:07.000000000 +0100
7402 #include <linux/writeback.h>
7403 #include <linux/quotaops.h>
7404 #include <linux/swap.h>
7405 +#include <linux/vs_tag.h>
7407 int reiserfs_commit_write(struct file *f, struct page *page,
7408 unsigned from, unsigned to);
7409 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
7410 struct buffer_head *bh;
7411 struct item_head *ih;
7415 //int version = ITEM_VERSION_1;
7417 bh = PATH_PLAST_BUFFER(path);
7418 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
7419 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7420 unsigned long blocks;
7422 + uid = sd_v1_uid(sd);
7423 + gid = sd_v1_gid(sd);
7425 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7426 set_inode_sd_version(inode, STAT_DATA_V1);
7427 inode->i_mode = sd_v1_mode(sd);
7428 inode->i_nlink = sd_v1_nlink(sd);
7429 - inode->i_uid = sd_v1_uid(sd);
7430 - inode->i_gid = sd_v1_gid(sd);
7431 inode->i_size = sd_v1_size(sd);
7432 inode->i_atime.tv_sec = sd_v1_atime(sd);
7433 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7434 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
7435 // (directories and symlinks)
7436 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7438 + uid = sd_v2_uid(sd);
7439 + gid = sd_v2_gid(sd);
7441 inode->i_mode = sd_v2_mode(sd);
7442 inode->i_nlink = sd_v2_nlink(sd);
7443 - inode->i_uid = sd_v2_uid(sd);
7444 inode->i_size = sd_v2_size(sd);
7445 - inode->i_gid = sd_v2_gid(sd);
7446 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7447 inode->i_atime.tv_sec = sd_v2_atime(sd);
7448 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7449 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
7450 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7453 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7454 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7455 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7458 if (S_ISREG(inode->i_mode)) {
7459 inode->i_op = &reiserfs_file_inode_operations;
7460 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
7461 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7463 struct stat_data *sd_v2 = (struct stat_data *)sd;
7464 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7465 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7468 + set_sd_v2_uid(sd_v2, uid);
7469 + set_sd_v2_gid(sd_v2, gid);
7470 set_sd_v2_mode(sd_v2, inode->i_mode);
7471 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7472 - set_sd_v2_uid(sd_v2, inode->i_uid);
7473 set_sd_v2_size(sd_v2, size);
7474 - set_sd_v2_gid(sd_v2, inode->i_gid);
7475 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7476 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7477 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7478 @@ -2858,14 +2869,19 @@ int reiserfs_commit_write(struct file *f
7479 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7481 if (reiserfs_attrs(inode->i_sb)) {
7482 - if (sd_attrs & REISERFS_SYNC_FL)
7483 - inode->i_flags |= S_SYNC;
7485 - inode->i_flags &= ~S_SYNC;
7486 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7487 inode->i_flags |= S_IMMUTABLE;
7489 inode->i_flags &= ~S_IMMUTABLE;
7490 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7491 + inode->i_flags |= S_IXUNLINK;
7493 + inode->i_flags &= ~S_IXUNLINK;
7495 + if (sd_attrs & REISERFS_SYNC_FL)
7496 + inode->i_flags |= S_SYNC;
7498 + inode->i_flags &= ~S_SYNC;
7499 if (sd_attrs & REISERFS_APPEND_FL)
7500 inode->i_flags |= S_APPEND;
7502 @@ -2878,6 +2894,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7503 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7505 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7507 + if (sd_attrs & REISERFS_BARRIER_FL)
7508 + inode->i_vflags |= V_BARRIER;
7510 + inode->i_vflags &= ~V_BARRIER;
7511 + if (sd_attrs & REISERFS_COW_FL)
7512 + inode->i_vflags |= V_COW;
7514 + inode->i_vflags &= ~V_COW;
7518 @@ -2888,6 +2913,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7519 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7521 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7522 + if (inode->i_flags & S_IXUNLINK)
7523 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7525 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7527 if (inode->i_flags & S_SYNC)
7528 *sd_attrs |= REISERFS_SYNC_FL;
7530 @@ -2900,6 +2930,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7531 *sd_attrs |= REISERFS_NOTAIL_FL;
7533 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7535 + if (inode->i_vflags & V_BARRIER)
7536 + *sd_attrs |= REISERFS_BARRIER_FL;
7538 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7539 + if (inode->i_vflags & V_COW)
7540 + *sd_attrs |= REISERFS_COW_FL;
7542 + *sd_attrs &= ~REISERFS_COW_FL;
7546 @@ -3143,7 +3182,8 @@ int reiserfs_setattr(struct dentry *dent
7549 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7550 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7551 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7552 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7553 struct reiserfs_transaction_handle th;
7556 @@ -3172,6 +3212,9 @@ int reiserfs_setattr(struct dentry *dent
7557 inode->i_uid = attr->ia_uid;
7558 if (attr->ia_valid & ATTR_GID)
7559 inode->i_gid = attr->ia_gid;
7560 + if ((attr->ia_valid & ATTR_TAG) &&
7562 + inode->i_tag = attr->ia_tag;
7563 mark_inode_dirty(inode);
7564 error = journal_end(&th, inode->i_sb, jbegin_count);
7566 diff -NurpP --minimal linux-2.6.38.1/fs/reiserfs/ioctl.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/reiserfs/ioctl.c
7567 --- linux-2.6.38.1/fs/reiserfs/ioctl.c 2011-01-05 21:50:26.000000000 +0100
7568 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/reiserfs/ioctl.c 2011-01-29 02:01:07.000000000 +0100
7570 #include <linux/pagemap.h>
7571 #include <linux/compat.h>
7574 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7576 + __u16 sd_attrs = 0;
7578 + inode->i_flags = flags;
7579 + inode->i_vflags = vflags;
7581 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7582 + REISERFS_I(inode)->i_attrs = sd_attrs;
7583 + inode->i_ctime = CURRENT_TIME_SEC;
7584 + mark_inode_dirty(inode);
7589 * reiserfs_ioctl - handler for ioctl for inode
7590 * supported commands:
7592 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7594 struct inode *inode = filp->f_path.dentry->d_inode;
7595 - unsigned int flags;
7596 + unsigned int flags, oldflags;
7599 reiserfs_write_lock(inode->i_sb);
7600 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7602 flags = REISERFS_I(inode)->i_attrs;
7603 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7604 + flags &= REISERFS_FL_USER_VISIBLE;
7605 err = put_user(flags, (int __user *)arg);
7607 case REISERFS_IOC_SETFLAGS:{
7608 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7612 + if (IS_BARRIER(inode)) {
7613 + vxwprintk_task(1, "messing with the barrier.");
7617 * Is it quota file? Do not allow user to mess with it
7619 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7624 + oldflags = REISERFS_I(inode)->i_attrs;
7625 + flags &= REISERFS_FL_USER_MODIFIABLE;
7626 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7627 sd_attrs_to_i_attrs(flags, inode);
7628 REISERFS_I(inode)->i_attrs = flags;
7629 inode->i_ctime = CURRENT_TIME_SEC;
7630 diff -NurpP --minimal linux-2.6.38.1/fs/reiserfs/namei.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/reiserfs/namei.c
7631 --- linux-2.6.38.1/fs/reiserfs/namei.c 2011-03-15 18:07:34.000000000 +0100
7632 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/reiserfs/namei.c 2011-03-10 17:21:19.000000000 +0100
7634 #include <linux/reiserfs_acl.h>
7635 #include <linux/reiserfs_xattr.h>
7636 #include <linux/quotaops.h>
7637 +#include <linux/vs_tag.h>
7639 #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; }
7640 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7641 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7642 if (retval == IO_ERROR) {
7643 return ERR_PTR(-EIO);
7645 + dx_propagate_tag(nd, inode);
7647 return d_splice_alias(inode, dentry);
7649 @@ -1532,6 +1534,7 @@ const struct inode_operations reiserfs_d
7650 .listxattr = reiserfs_listxattr,
7651 .removexattr = reiserfs_removexattr,
7652 .permission = reiserfs_permission,
7653 + .sync_flags = reiserfs_sync_flags,
7657 diff -NurpP --minimal linux-2.6.38.1/fs/reiserfs/super.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/reiserfs/super.c
7658 --- linux-2.6.38.1/fs/reiserfs/super.c 2011-03-15 18:07:34.000000000 +0100
7659 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/reiserfs/super.c 2011-01-29 02:01:07.000000000 +0100
7660 @@ -899,6 +899,14 @@ static int reiserfs_parse_options(struct
7661 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7662 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7664 +#ifndef CONFIG_TAGGING_NONE
7665 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7666 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7667 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7669 +#ifdef CONFIG_PROPAGATE
7670 + {"tag",.arg_required = 'T',.values = NULL},
7672 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7673 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7674 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7675 @@ -1208,6 +1216,14 @@ static int reiserfs_remount(struct super
7676 handle_quota_files(s, qf_names, &qfmt);
7679 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7680 + !(s->s_flags & MS_TAGGED)) {
7681 + reiserfs_warning(s, "super-vs01",
7682 + "reiserfs: tagging not permitted on remount.");
7689 /* Add options that are safe here */
7690 @@ -1690,6 +1706,10 @@ static int reiserfs_fill_super(struct su
7694 + /* map mount option tagxid */
7695 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7696 + s->s_flags |= MS_TAGGED;
7698 rs = SB_DISK_SUPER_BLOCK(s);
7699 /* Let's do basic sanity check to verify that underlying device is not
7700 smaller than the filesystem. If the check fails then abort and scream,
7701 diff -NurpP --minimal linux-2.6.38.1/fs/reiserfs/xattr.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/reiserfs/xattr.c
7702 --- linux-2.6.38.1/fs/reiserfs/xattr.c 2011-03-15 18:07:34.000000000 +0100
7703 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/reiserfs/xattr.c 2011-03-15 18:15:06.000000000 +0100
7705 #include <linux/errno.h>
7706 #include <linux/gfp.h>
7707 #include <linux/fs.h>
7708 +#include <linux/mount.h>
7709 #include <linux/file.h>
7710 #include <linux/pagemap.h>
7711 #include <linux/xattr.h>
7712 diff -NurpP --minimal linux-2.6.38.1/fs/stat.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/stat.c
7713 --- linux-2.6.38.1/fs/stat.c 2011-03-15 18:07:34.000000000 +0100
7714 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/stat.c 2011-01-29 02:01:07.000000000 +0100
7715 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7716 stat->nlink = inode->i_nlink;
7717 stat->uid = inode->i_uid;
7718 stat->gid = inode->i_gid;
7719 + stat->tag = inode->i_tag;
7720 stat->rdev = inode->i_rdev;
7721 stat->atime = inode->i_atime;
7722 stat->mtime = inode->i_mtime;
7723 diff -NurpP --minimal linux-2.6.38.1/fs/statfs.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/statfs.c
7724 --- linux-2.6.38.1/fs/statfs.c 2010-10-21 13:07:51.000000000 +0200
7725 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/statfs.c 2011-01-29 02:01:07.000000000 +0100
7727 #include <linux/statfs.h>
7728 #include <linux/security.h>
7729 #include <linux/uaccess.h>
7730 +#include <linux/vs_base.h>
7731 +#include <linux/vs_dlimit.h>
7733 static int flags_by_mnt(int mnt_flags)
7735 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
7736 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7737 if (retval == 0 && buf->f_frsize == 0)
7738 buf->f_frsize = buf->f_bsize;
7739 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7740 + vx_vsi_statfs(dentry->d_sb, buf);
7744 diff -NurpP --minimal linux-2.6.38.1/fs/super.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/super.c
7745 --- linux-2.6.38.1/fs/super.c 2011-03-15 18:07:34.000000000 +0100
7746 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/super.c 2011-02-17 02:17:50.000000000 +0100
7748 #include <linux/mutex.h>
7749 #include <linux/backing-dev.h>
7750 #include <linux/rculist_bl.h>
7751 +#include <linux/devpts_fs.h>
7752 +#include <linux/proc_fs.h>
7753 +#include <linux/vs_context.h>
7754 #include "internal.h"
7757 @@ -963,6 +966,7 @@ struct vfsmount *
7758 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
7760 struct vfsmount *mnt;
7761 + struct super_block *sb;
7762 struct dentry *root;
7763 char *secdata = NULL;
7765 @@ -970,6 +974,11 @@ vfs_kern_mount(struct file_system_type *
7767 return ERR_PTR(-ENODEV);
7770 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
7771 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
7775 mnt = alloc_vfsmnt(name);
7777 @@ -1001,11 +1010,19 @@ vfs_kern_mount(struct file_system_type *
7779 goto out_free_secdata;
7781 - BUG_ON(!mnt->mnt_sb);
7782 - WARN_ON(!mnt->mnt_sb->s_bdi);
7786 + WARN_ON(!sb->s_bdi);
7787 mnt->mnt_sb->s_flags |= MS_BORN;
7789 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
7791 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
7792 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7793 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7796 + error = security_sb_kern_mount(sb, flags, secdata);
7800 diff -NurpP --minimal linux-2.6.38.1/fs/sysfs/mount.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/sysfs/mount.c
7801 --- linux-2.6.38.1/fs/sysfs/mount.c 2011-01-05 21:50:27.000000000 +0100
7802 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/sysfs/mount.c 2011-01-29 02:01:07.000000000 +0100
7803 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7805 sb->s_blocksize = PAGE_CACHE_SIZE;
7806 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7807 - sb->s_magic = SYSFS_MAGIC;
7808 + sb->s_magic = SYSFS_SUPER_MAGIC;
7809 sb->s_op = &sysfs_ops;
7810 sb->s_time_gran = 1;
7812 diff -NurpP --minimal linux-2.6.38.1/fs/utimes.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/utimes.c
7813 --- linux-2.6.38.1/fs/utimes.c 2010-10-21 13:07:51.000000000 +0200
7814 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/utimes.c 2011-01-29 02:01:07.000000000 +0100
7816 #include <linux/stat.h>
7817 #include <linux/utime.h>
7818 #include <linux/syscalls.h>
7819 +#include <linux/mount.h>
7820 +#include <linux/vs_cowbl.h>
7821 #include <asm/uaccess.h>
7822 #include <asm/unistd.h>
7824 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7827 struct iattr newattrs;
7828 - struct inode *inode = path->dentry->d_inode;
7829 + struct inode *inode;
7831 error = mnt_want_write(path->mnt);
7835 + error = cow_check_and_break(path);
7837 + goto mnt_drop_write_and_out;
7839 + inode = path->dentry->d_inode;
7841 if (times && times[0].tv_nsec == UTIME_NOW &&
7842 times[1].tv_nsec == UTIME_NOW)
7844 diff -NurpP --minimal linux-2.6.38.1/fs/xattr.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/xattr.c
7845 --- linux-2.6.38.1/fs/xattr.c 2010-08-02 16:52:52.000000000 +0200
7846 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xattr.c 2011-01-29 02:01:07.000000000 +0100
7848 #include <linux/module.h>
7849 #include <linux/fsnotify.h>
7850 #include <linux/audit.h>
7851 +#include <linux/mount.h>
7852 #include <asm/uaccess.h>
7855 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
7856 * The trusted.* namespace can only be accessed by a privileged user.
7858 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
7859 - return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
7860 + return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
7862 /* In user.* namespace, only regular files and directories can have
7863 * extended attributes. For sticky directories, only the owner and
7864 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/linux-2.6/xfs_ioctl.c
7865 --- linux-2.6.38.1/fs/xfs/linux-2.6/xfs_ioctl.c 2011-03-15 18:07:34.000000000 +0100
7866 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/linux-2.6/xfs_ioctl.c 2011-03-10 17:21:19.000000000 +0100
7868 #include "xfs_bmap_btree.h"
7869 #include "xfs_dinode.h"
7870 #include "xfs_inode.h"
7871 -#include "xfs_ioctl.h"
7872 +// #include "xfs_ioctl.h"
7873 #include "xfs_rtalloc.h"
7874 #include "xfs_itable.h"
7875 #include "xfs_error.h"
7876 @@ -744,6 +744,10 @@ xfs_merge_ioc_xflags(
7877 xflags |= XFS_XFLAG_IMMUTABLE;
7879 xflags &= ~XFS_XFLAG_IMMUTABLE;
7880 + if (flags & FS_IXUNLINK_FL)
7881 + xflags |= XFS_XFLAG_IXUNLINK;
7883 + xflags &= ~XFS_XFLAG_IXUNLINK;
7884 if (flags & FS_APPEND_FL)
7885 xflags |= XFS_XFLAG_APPEND;
7887 @@ -772,6 +776,8 @@ xfs_di2lxflags(
7889 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7890 flags |= FS_IMMUTABLE_FL;
7891 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7892 + flags |= FS_IXUNLINK_FL;
7893 if (di_flags & XFS_DIFLAG_APPEND)
7894 flags |= FS_APPEND_FL;
7895 if (di_flags & XFS_DIFLAG_SYNC)
7896 @@ -832,6 +838,8 @@ xfs_set_diflags(
7897 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7898 if (xflags & XFS_XFLAG_IMMUTABLE)
7899 di_flags |= XFS_DIFLAG_IMMUTABLE;
7900 + if (xflags & XFS_XFLAG_IXUNLINK)
7901 + di_flags |= XFS_DIFLAG_IXUNLINK;
7902 if (xflags & XFS_XFLAG_APPEND)
7903 di_flags |= XFS_DIFLAG_APPEND;
7904 if (xflags & XFS_XFLAG_SYNC)
7905 @@ -874,6 +882,10 @@ xfs_diflags_to_linux(
7906 inode->i_flags |= S_IMMUTABLE;
7908 inode->i_flags &= ~S_IMMUTABLE;
7909 + if (xflags & XFS_XFLAG_IXUNLINK)
7910 + inode->i_flags |= S_IXUNLINK;
7912 + inode->i_flags &= ~S_IXUNLINK;
7913 if (xflags & XFS_XFLAG_APPEND)
7914 inode->i_flags |= S_APPEND;
7916 @@ -1366,10 +1378,18 @@ xfs_file_ioctl(
7917 case XFS_IOC_FSGETXATTRA:
7918 return xfs_ioc_fsgetxattr(ip, 1, arg);
7919 case XFS_IOC_FSSETXATTR:
7920 + if (IS_BARRIER(inode)) {
7921 + vxwprintk_task(1, "messing with the barrier.");
7922 + return -XFS_ERROR(EACCES);
7924 return xfs_ioc_fssetxattr(ip, filp, arg);
7925 case XFS_IOC_GETXFLAGS:
7926 return xfs_ioc_getxflags(ip, arg);
7927 case XFS_IOC_SETXFLAGS:
7928 + if (IS_BARRIER(inode)) {
7929 + vxwprintk_task(1, "messing with the barrier.");
7930 + return -XFS_ERROR(EACCES);
7932 return xfs_ioc_setxflags(ip, filp, arg);
7934 case XFS_IOC_FSSETDM: {
7935 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/linux-2.6/xfs_ioctl.h
7936 --- linux-2.6.38.1/fs/xfs/linux-2.6/xfs_ioctl.h 2010-07-07 18:31:54.000000000 +0200
7937 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/linux-2.6/xfs_ioctl.h 2011-01-29 02:01:07.000000000 +0100
7938 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7939 void __user *uhandle,
7944 + struct inode *inode,
7951 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/linux-2.6/xfs_iops.c
7952 --- linux-2.6.38.1/fs/xfs/linux-2.6/xfs_iops.c 2011-03-15 18:07:34.000000000 +0100
7953 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/linux-2.6/xfs_iops.c 2011-01-29 02:01:07.000000000 +0100
7955 #include "xfs_bmap_btree.h"
7956 #include "xfs_dinode.h"
7957 #include "xfs_inode.h"
7958 +#include "xfs_ioctl.h"
7959 #include "xfs_bmap.h"
7960 #include "xfs_rtalloc.h"
7961 #include "xfs_error.h"
7963 #include <linux/security.h>
7964 #include <linux/fiemap.h>
7965 #include <linux/slab.h>
7966 +#include <linux/vs_tag.h>
7969 * Bring the timestamps in the XFS inode uptodate.
7970 @@ -463,6 +465,7 @@ xfs_vn_getattr(
7971 stat->nlink = ip->i_d.di_nlink;
7972 stat->uid = ip->i_d.di_uid;
7973 stat->gid = ip->i_d.di_gid;
7974 + stat->tag = ip->i_d.di_tag;
7975 stat->ino = ip->i_ino;
7976 stat->atime = inode->i_atime;
7977 stat->mtime = inode->i_mtime;
7978 @@ -598,6 +601,7 @@ static const struct inode_operations xfs
7979 .removexattr = generic_removexattr,
7980 .listxattr = xfs_vn_listxattr,
7981 .fiemap = xfs_vn_fiemap,
7982 + .sync_flags = xfs_sync_flags,
7985 static const struct inode_operations xfs_dir_inode_operations = {
7986 @@ -623,6 +627,7 @@ static const struct inode_operations xfs
7987 .getxattr = generic_getxattr,
7988 .removexattr = generic_removexattr,
7989 .listxattr = xfs_vn_listxattr,
7990 + .sync_flags = xfs_sync_flags,
7993 static const struct inode_operations xfs_dir_ci_inode_operations = {
7994 @@ -672,6 +677,10 @@ xfs_diflags_to_iflags(
7995 inode->i_flags |= S_IMMUTABLE;
7997 inode->i_flags &= ~S_IMMUTABLE;
7998 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7999 + inode->i_flags |= S_IXUNLINK;
8001 + inode->i_flags &= ~S_IXUNLINK;
8002 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
8003 inode->i_flags |= S_APPEND;
8005 @@ -684,6 +693,15 @@ xfs_diflags_to_iflags(
8006 inode->i_flags |= S_NOATIME;
8008 inode->i_flags &= ~S_NOATIME;
8010 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
8011 + inode->i_vflags |= V_BARRIER;
8013 + inode->i_vflags &= ~V_BARRIER;
8014 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
8015 + inode->i_vflags |= V_COW;
8017 + inode->i_vflags &= ~V_COW;
8021 @@ -715,6 +733,7 @@ xfs_setup_inode(
8022 inode->i_nlink = ip->i_d.di_nlink;
8023 inode->i_uid = ip->i_d.di_uid;
8024 inode->i_gid = ip->i_d.di_gid;
8025 + inode->i_tag = ip->i_d.di_tag;
8027 switch (inode->i_mode & S_IFMT) {
8029 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/linux-2.6/xfs_linux.h
8030 --- linux-2.6.38.1/fs/xfs/linux-2.6/xfs_linux.h 2011-03-15 18:07:34.000000000 +0100
8031 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/linux-2.6/xfs_linux.h 2011-01-29 02:01:07.000000000 +0100
8034 #define current_cpu() (raw_smp_processor_id())
8035 #define current_pid() (current->pid)
8036 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
8037 #define current_test_flags(f) (current->flags & (f))
8038 #define current_set_flags_nested(sp, f) \
8039 (*(sp) = current->flags, current->flags |= (f))
8040 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/linux-2.6/xfs_super.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/linux-2.6/xfs_super.c
8041 --- linux-2.6.38.1/fs/xfs/linux-2.6/xfs_super.c 2011-03-15 18:07:34.000000000 +0100
8042 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/linux-2.6/xfs_super.c 2011-01-29 02:01:07.000000000 +0100
8043 @@ -112,6 +112,9 @@ mempool_t *xfs_ioend_pool;
8044 #define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */
8045 #define MNTOPT_DELAYLOG "delaylog" /* Delayed loging enabled */
8046 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed loging disabled */
8047 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
8048 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
8049 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
8052 * Table driven mount option parser.
8053 @@ -120,10 +123,14 @@ mempool_t *xfs_ioend_pool;
8054 * in the future, too.
8057 + Opt_tag, Opt_notag,
8058 Opt_barrier, Opt_nobarrier, Opt_err
8061 static const match_table_t tokens = {
8062 + {Opt_tag, "tagxid"},
8064 + {Opt_notag, "notag"},
8065 {Opt_barrier, "barrier"},
8066 {Opt_nobarrier, "nobarrier"},
8068 @@ -367,6 +374,19 @@ xfs_parseargs(
8069 } else if (!strcmp(this_char, "irixsgid")) {
8071 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
8072 +#ifndef CONFIG_TAGGING_NONE
8073 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8074 + mp->m_flags |= XFS_MOUNT_TAGGED;
8075 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
8076 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
8077 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
8078 + mp->m_flags |= XFS_MOUNT_TAGGED;
8080 +#ifdef CONFIG_PROPAGATE
8081 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8083 + mp->m_flags |= XFS_MOUNT_TAGGED;
8087 "XFS: unknown mount option [%s].", this_char);
8088 @@ -1327,6 +1347,16 @@ xfs_fs_remount(
8090 mp->m_flags &= ~XFS_MOUNT_BARRIER;
8093 + if (!(sb->s_flags & MS_TAGGED)) {
8095 + "XFS: %s: tagging not permitted on remount.\n",
8104 * Logically we would return an error here to prevent
8105 @@ -1555,6 +1585,9 @@ xfs_fs_fill_super(
8107 goto out_filestream_unmount;
8109 + if (mp->m_flags & XFS_MOUNT_TAGGED)
8110 + sb->s_flags |= MS_TAGGED;
8112 sb->s_magic = XFS_SB_MAGIC;
8113 sb->s_blocksize = mp->m_sb.sb_blocksize;
8114 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
8115 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/xfs_dinode.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_dinode.h
8116 --- linux-2.6.38.1/fs/xfs/xfs_dinode.h 2011-01-05 21:50:28.000000000 +0100
8117 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_dinode.h 2011-01-29 02:01:07.000000000 +0100
8118 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
8119 __be32 di_nlink; /* number of links to file */
8120 __be16 di_projid_lo; /* lower part of owner's project id */
8121 __be16 di_projid_hi; /* higher part owner's project id */
8122 - __u8 di_pad[6]; /* unused, zeroed space */
8123 + __u8 di_pad[2]; /* unused, zeroed space */
8124 + __be16 di_tag; /* context tagging */
8125 + __be16 di_vflags; /* vserver specific flags */
8126 __be16 di_flushiter; /* incremented on flush */
8127 xfs_timestamp_t di_atime; /* time last accessed */
8128 xfs_timestamp_t di_mtime; /* time last modified */
8129 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
8130 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
8131 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
8132 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
8133 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
8135 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
8136 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
8137 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
8138 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
8139 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8140 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8141 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8142 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8144 #ifdef CONFIG_XFS_RT
8145 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8146 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
8147 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8148 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8149 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8150 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8151 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8152 + XFS_DIFLAG_IXUNLINK)
8154 +#define XFS_DIVFLAG_BARRIER 0x01
8155 +#define XFS_DIVFLAG_COW 0x02
8157 #endif /* __XFS_DINODE_H__ */
8158 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/xfs_fs.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_fs.h
8159 --- linux-2.6.38.1/fs/xfs/xfs_fs.h 2011-01-05 21:50:28.000000000 +0100
8160 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_fs.h 2011-01-29 02:01:07.000000000 +0100
8161 @@ -67,6 +67,9 @@ struct fsxattr {
8162 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8163 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8164 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8165 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8166 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8167 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8168 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8171 @@ -297,7 +300,8 @@ typedef struct xfs_bstat {
8172 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
8173 __u16 bs_forkoff; /* inode fork offset in bytes */
8174 __u16 bs_projid_hi; /* higher part of project id */
8175 - unsigned char bs_pad[10]; /* pad space, unused */
8176 + unsigned char bs_pad[8]; /* pad space, unused */
8177 + __u16 bs_tag; /* context tagging */
8178 __u32 bs_dmevmask; /* DMIG event mask */
8179 __u16 bs_dmstate; /* DMIG state info */
8180 __u16 bs_aextents; /* attribute number of extents */
8181 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/xfs_ialloc.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_ialloc.c
8182 --- linux-2.6.38.1/fs/xfs/xfs_ialloc.c 2011-01-05 21:50:28.000000000 +0100
8183 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_ialloc.c 2011-01-29 02:01:07.000000000 +0100
8185 #include "xfs_error.h"
8186 #include "xfs_bmap.h"
8190 * Allocation group level functions.
8192 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/xfs_inode.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_inode.c
8193 --- linux-2.6.38.1/fs/xfs/xfs_inode.c 2011-03-15 18:07:34.000000000 +0100
8194 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_inode.c 2011-01-29 02:01:07.000000000 +0100
8195 @@ -245,6 +245,7 @@ xfs_inotobp(
8199 +#include <linux/vs_tag.h>
8202 * This routine is called to map an inode to the buffer containing
8203 @@ -650,15 +651,25 @@ xfs_iformat_btree(
8205 xfs_dinode_from_disk(
8207 - xfs_dinode_t *from)
8208 + xfs_dinode_t *from,
8211 + uint32_t uid, gid, tag;
8213 to->di_magic = be16_to_cpu(from->di_magic);
8214 to->di_mode = be16_to_cpu(from->di_mode);
8215 to->di_version = from ->di_version;
8216 to->di_format = from->di_format;
8217 to->di_onlink = be16_to_cpu(from->di_onlink);
8218 - to->di_uid = be32_to_cpu(from->di_uid);
8219 - to->di_gid = be32_to_cpu(from->di_gid);
8221 + uid = be32_to_cpu(from->di_uid);
8222 + gid = be32_to_cpu(from->di_gid);
8223 + tag = be16_to_cpu(from->di_tag);
8225 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8226 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8227 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8229 to->di_nlink = be32_to_cpu(from->di_nlink);
8230 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
8231 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
8232 @@ -680,21 +691,26 @@ xfs_dinode_from_disk(
8233 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8234 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8235 to->di_flags = be16_to_cpu(from->di_flags);
8236 + to->di_vflags = be16_to_cpu(from->di_vflags);
8237 to->di_gen = be32_to_cpu(from->di_gen);
8243 - xfs_icdinode_t *from)
8244 + xfs_icdinode_t *from,
8247 to->di_magic = cpu_to_be16(from->di_magic);
8248 to->di_mode = cpu_to_be16(from->di_mode);
8249 to->di_version = from ->di_version;
8250 to->di_format = from->di_format;
8251 to->di_onlink = cpu_to_be16(from->di_onlink);
8252 - to->di_uid = cpu_to_be32(from->di_uid);
8253 - to->di_gid = cpu_to_be32(from->di_gid);
8255 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8256 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8257 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8259 to->di_nlink = cpu_to_be32(from->di_nlink);
8260 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
8261 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
8262 @@ -716,12 +732,14 @@ xfs_dinode_to_disk(
8263 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8264 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8265 to->di_flags = cpu_to_be16(from->di_flags);
8266 + to->di_vflags = cpu_to_be16(from->di_vflags);
8267 to->di_gen = cpu_to_be32(from->di_gen);
8272 - __uint16_t di_flags)
8273 + __uint16_t di_flags,
8274 + __uint16_t di_vflags)
8278 @@ -732,6 +750,8 @@ _xfs_dic2xflags(
8279 flags |= XFS_XFLAG_PREALLOC;
8280 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8281 flags |= XFS_XFLAG_IMMUTABLE;
8282 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8283 + flags |= XFS_XFLAG_IXUNLINK;
8284 if (di_flags & XFS_DIFLAG_APPEND)
8285 flags |= XFS_XFLAG_APPEND;
8286 if (di_flags & XFS_DIFLAG_SYNC)
8287 @@ -756,6 +776,10 @@ _xfs_dic2xflags(
8288 flags |= XFS_XFLAG_FILESTREAM;
8291 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8292 + flags |= FS_BARRIER_FL;
8293 + if (di_vflags & XFS_DIVFLAG_COW)
8294 + flags |= FS_COW_FL;
8298 @@ -765,7 +789,7 @@ xfs_ip2xflags(
8300 xfs_icdinode_t *dic = &ip->i_d;
8302 - return _xfs_dic2xflags(dic->di_flags) |
8303 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8304 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8307 @@ -773,7 +797,8 @@ uint
8311 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8312 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8313 + be16_to_cpu(dip->di_vflags)) |
8314 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8317 @@ -806,7 +831,6 @@ xfs_iread(
8320 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8323 * If we got something that isn't an inode it means someone
8324 * (nfs or dmi) has a stale handle.
8325 @@ -831,7 +855,8 @@ xfs_iread(
8326 * Otherwise, just get the truly permanent information.
8329 - xfs_dinode_from_disk(&ip->i_d, dip);
8330 + xfs_dinode_from_disk(&ip->i_d, dip,
8331 + mp->m_flags & XFS_MOUNT_TAGGED);
8332 error = xfs_iformat(ip, dip);
8335 @@ -1028,6 +1053,7 @@ xfs_ialloc(
8336 ASSERT(ip->i_d.di_nlink == nlink);
8337 ip->i_d.di_uid = current_fsuid();
8338 ip->i_d.di_gid = current_fsgid();
8339 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
8340 xfs_set_projid(ip, prid);
8341 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8343 @@ -1088,6 +1114,7 @@ xfs_ialloc(
8344 ip->i_d.di_dmevmask = 0;
8345 ip->i_d.di_dmstate = 0;
8346 ip->i_d.di_flags = 0;
8347 + ip->i_d.di_vflags = 0;
8348 flags = XFS_ILOG_CORE;
8349 switch (mode & S_IFMT) {
8351 @@ -2122,6 +2149,7 @@ xfs_ifree(
8353 ip->i_d.di_mode = 0; /* mark incore inode as free */
8354 ip->i_d.di_flags = 0;
8355 + ip->i_d.di_vflags = 0;
8356 ip->i_d.di_dmevmask = 0;
8357 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8358 ip->i_df.if_ext_max =
8359 @@ -3004,7 +3032,8 @@ xfs_iflush_int(
8360 * because if the inode is dirty at all the core must
8363 - xfs_dinode_to_disk(dip, &ip->i_d);
8364 + xfs_dinode_to_disk(dip, &ip->i_d,
8365 + mp->m_flags & XFS_MOUNT_TAGGED);
8367 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8368 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8369 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/xfs_inode.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_inode.h
8370 --- linux-2.6.38.1/fs/xfs/xfs_inode.h 2011-03-15 18:07:34.000000000 +0100
8371 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_inode.h 2011-01-29 02:01:07.000000000 +0100
8372 @@ -136,7 +136,9 @@ typedef struct xfs_icdinode {
8373 __uint32_t di_nlink; /* number of links to file */
8374 __uint16_t di_projid_lo; /* lower part of owner's project id */
8375 __uint16_t di_projid_hi; /* higher part of owner's project id */
8376 - __uint8_t di_pad[6]; /* unused, zeroed space */
8377 + __uint8_t di_pad[2]; /* unused, zeroed space */
8378 + __uint16_t di_tag; /* context tagging */
8379 + __uint16_t di_vflags; /* vserver specific flags */
8380 __uint16_t di_flushiter; /* incremented on flush */
8381 xfs_ictimestamp_t di_atime; /* time last accessed */
8382 xfs_ictimestamp_t di_mtime; /* time last modified */
8383 @@ -530,7 +532,7 @@ int xfs_itobp(struct xfs_mount *, struc
8384 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8385 struct xfs_inode *, uint);
8386 void xfs_dinode_to_disk(struct xfs_dinode *,
8387 - struct xfs_icdinode *);
8388 + struct xfs_icdinode *, int);
8389 void xfs_idestroy_fork(struct xfs_inode *, int);
8390 void xfs_idata_realloc(struct xfs_inode *, int, int);
8391 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8392 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/xfs_itable.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_itable.c
8393 --- linux-2.6.38.1/fs/xfs/xfs_itable.c 2011-01-05 21:50:28.000000000 +0100
8394 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_itable.c 2011-01-29 02:01:07.000000000 +0100
8395 @@ -98,6 +98,7 @@ xfs_bulkstat_one_int(
8396 buf->bs_mode = dic->di_mode;
8397 buf->bs_uid = dic->di_uid;
8398 buf->bs_gid = dic->di_gid;
8399 + buf->bs_tag = dic->di_tag;
8400 buf->bs_size = dic->di_size;
8403 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/xfs_log_recover.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_log_recover.c
8404 --- linux-2.6.38.1/fs/xfs/xfs_log_recover.c 2011-03-15 18:07:34.000000000 +0100
8405 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_log_recover.c 2011-01-29 02:01:07.000000000 +0100
8406 @@ -2317,7 +2317,8 @@ xlog_recover_inode_pass2(
8409 /* The core is in in-core format */
8410 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
8411 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
8412 + mp->m_flags & XFS_MOUNT_TAGGED);
8414 /* the rest is in on-disk format */
8415 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8416 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/xfs_mount.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_mount.h
8417 --- linux-2.6.38.1/fs/xfs/xfs_mount.h 2011-03-15 18:07:34.000000000 +0100
8418 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_mount.h 2011-01-29 02:01:07.000000000 +0100
8419 @@ -251,6 +251,7 @@ typedef struct xfs_mount {
8421 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8423 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8426 * Default minimum read and write sizes.
8427 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/xfs_vnodeops.c linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_vnodeops.c
8428 --- linux-2.6.38.1/fs/xfs/xfs_vnodeops.c 2011-03-15 18:07:34.000000000 +0100
8429 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_vnodeops.c 2011-01-29 02:01:07.000000000 +0100
8431 #include "xfs_vnodeops.h"
8432 #include "xfs_trace.h"
8436 +xfs_get_inode_flags(
8439 + struct inode *inode = VFS_I(ip);
8440 + unsigned int flags = inode->i_flags;
8441 + unsigned int vflags = inode->i_vflags;
8443 + if (flags & S_IMMUTABLE)
8444 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8446 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8447 + if (flags & S_IXUNLINK)
8448 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8450 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8452 + if (vflags & V_BARRIER)
8453 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8455 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8456 + if (vflags & V_COW)
8457 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8459 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8464 + struct inode *inode,
8468 + struct xfs_inode *ip = XFS_I(inode);
8469 + struct xfs_mount *mp = ip->i_mount;
8470 + struct xfs_trans *tp;
8471 + unsigned int lock_flags = 0;
8474 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8475 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8479 + xfs_ilock(ip, XFS_ILOCK_EXCL);
8481 + xfs_trans_ijoin(tp, ip);
8483 + inode->i_flags = flags;
8484 + inode->i_vflags = vflags;
8485 + xfs_get_inode_flags(ip);
8487 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8488 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
8490 + XFS_STATS_INC(xs_ig_attrchg);
8492 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8493 + xfs_trans_set_sync(tp);
8494 + code = xfs_trans_commit(tp, 0);
8495 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8499 + xfs_trans_cancel(tp, 0);
8501 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8508 struct xfs_inode *ip,
8509 @@ -65,6 +137,7 @@ xfs_setattr(
8510 uint commit_flags=0;
8511 uid_t uid=0, iuid=0;
8512 gid_t gid=0, igid=0;
8513 + tag_t tag=0, itag=0;
8514 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8515 int need_iolock = 1;
8517 @@ -147,7 +220,7 @@ xfs_setattr(
8519 * Change file ownership. Must be the owner or privileged.
8521 - if (mask & (ATTR_UID|ATTR_GID)) {
8522 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8524 * These IDs could have changed since we last looked at them.
8525 * But, we're assured that if the ownership did change
8526 @@ -156,8 +229,10 @@ xfs_setattr(
8528 iuid = ip->i_d.di_uid;
8529 igid = ip->i_d.di_gid;
8530 + itag = ip->i_d.di_tag;
8531 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8532 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8533 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8536 * Do a quota reservation only if uid/gid is actually
8537 @@ -165,7 +240,8 @@ xfs_setattr(
8539 if (XFS_IS_QUOTA_RUNNING(mp) &&
8540 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8541 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
8542 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8543 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
8545 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
8546 capable(CAP_FOWNER) ?
8547 @@ -329,7 +405,7 @@ xfs_setattr(
8549 * Change file ownership. Must be the owner or privileged.
8551 - if (mask & (ATTR_UID|ATTR_GID)) {
8552 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8554 * CAP_FSETID overrides the following restrictions:
8556 @@ -345,6 +421,10 @@ xfs_setattr(
8557 * Change the ownerships and register quota modifications
8558 * in the transaction.
8560 + if (itag != tag) {
8561 + ip->i_d.di_tag = tag;
8562 + inode->i_tag = tag;
8565 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
8566 ASSERT(mask & ATTR_UID);
8567 diff -NurpP --minimal linux-2.6.38.1/fs/xfs/xfs_vnodeops.h linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_vnodeops.h
8568 --- linux-2.6.38.1/fs/xfs/xfs_vnodeops.h 2011-01-05 21:50:28.000000000 +0100
8569 +++ linux-2.6.38.1-vs2.3.0.37-rc9/fs/xfs/xfs_vnodeops.h 2011-01-29 02:01:07.000000000 +0100
8570 @@ -13,6 +13,7 @@ struct xfs_inode;
8574 +int xfs_sync_xflags(struct xfs_inode *ip);
8575 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8576 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8577 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8578 diff -NurpP --minimal linux-2.6.38.1/include/asm-generic/tlb.h linux-2.6.38.1-vs2.3.0.37-rc9/include/asm-generic/tlb.h
8579 --- linux-2.6.38.1/include/asm-generic/tlb.h 2009-09-10 15:26:24.000000000 +0200
8580 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/asm-generic/tlb.h 2011-01-29 02:01:07.000000000 +0100
8582 #define _ASM_GENERIC__TLB_H
8584 #include <linux/swap.h>
8585 +#include <linux/vs_memory.h>
8586 #include <asm/pgalloc.h>
8587 #include <asm/tlbflush.h>
8589 diff -NurpP --minimal linux-2.6.38.1/include/linux/Kbuild linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/Kbuild
8590 --- linux-2.6.38.1/include/linux/Kbuild 2011-03-15 18:07:37.000000000 +0100
8591 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/Kbuild 2011-02-17 02:17:51.000000000 +0100
8592 @@ -16,6 +16,7 @@ header-y += netfilter_bridge/
8593 header-y += netfilter_ipv4/
8594 header-y += netfilter_ipv6/
8596 +header-y += vserver/
8599 objhdr-y += version.h
8600 diff -NurpP --minimal linux-2.6.38.1/include/linux/capability.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/capability.h
8601 --- linux-2.6.38.1/include/linux/capability.h 2011-03-15 18:07:37.000000000 +0100
8602 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/capability.h 2011-01-29 02:01:07.000000000 +0100
8603 @@ -279,6 +279,7 @@ struct cpu_vfs_cap_data {
8604 arbitrary SCSI commands */
8605 /* Allow setting encryption key on loopback filesystem */
8606 /* Allow setting zone reclaim policy */
8607 +/* Allow the selection of a security context */
8609 #define CAP_SYS_ADMIN 21
8611 @@ -357,7 +358,12 @@ struct cpu_vfs_cap_data {
8613 #define CAP_LAST_CAP CAP_SYSLOG
8615 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8616 +/* Allow context manipulations */
8617 +/* Allow changing context info on files */
8619 +#define CAP_CONTEXT 63
8621 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
8624 * Bit location of each capability (used by user-space library and kernel)
8625 diff -NurpP --minimal linux-2.6.38.1/include/linux/cred.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/cred.h
8626 --- linux-2.6.38.1/include/linux/cred.h 2011-01-05 21:50:29.000000000 +0100
8627 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/cred.h 2011-01-31 12:03:07.000000000 +0100
8628 @@ -155,6 +155,7 @@ extern void exit_creds(struct task_struc
8629 extern int copy_creds(struct task_struct *, unsigned long);
8630 extern const struct cred *get_task_cred(struct task_struct *);
8631 extern struct cred *cred_alloc_blank(void);
8632 +extern struct cred *__prepare_creds(const struct cred *);
8633 extern struct cred *prepare_creds(void);
8634 extern struct cred *prepare_exec_creds(void);
8635 extern int commit_creds(struct cred *);
8636 @@ -208,6 +209,31 @@ static inline void validate_process_cred
8640 +static inline void set_cred_subscribers(struct cred *cred, int n)
8642 +#ifdef CONFIG_DEBUG_CREDENTIALS
8643 + atomic_set(&cred->subscribers, n);
8647 +static inline int read_cred_subscribers(const struct cred *cred)
8649 +#ifdef CONFIG_DEBUG_CREDENTIALS
8650 + return atomic_read(&cred->subscribers);
8656 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
8658 +#ifdef CONFIG_DEBUG_CREDENTIALS
8659 + struct cred *cred = (struct cred *) _cred;
8661 + atomic_add(n, &cred->subscribers);
8666 * get_new_cred - Get a reference on a new set of credentials
8667 * @cred: The new credentials to reference
8668 diff -NurpP --minimal linux-2.6.38.1/include/linux/devpts_fs.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/devpts_fs.h
8669 --- linux-2.6.38.1/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8670 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/devpts_fs.h 2011-01-29 02:01:07.000000000 +0100
8671 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8676 #endif /* _LINUX_DEVPTS_FS_H */
8677 diff -NurpP --minimal linux-2.6.38.1/include/linux/ext2_fs.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/ext2_fs.h
8678 --- linux-2.6.38.1/include/linux/ext2_fs.h 2010-02-25 11:52:07.000000000 +0100
8679 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/ext2_fs.h 2011-01-29 02:01:07.000000000 +0100
8680 @@ -189,8 +189,12 @@ struct ext2_group_desc
8681 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8682 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8683 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8684 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8685 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8687 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8688 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8690 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8691 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8693 @@ -274,7 +278,8 @@ struct ext2_inode {
8695 __le16 l_i_uid_high; /* these 2 fields */
8696 __le16 l_i_gid_high; /* were reserved2[0] */
8697 - __u32 l_i_reserved2;
8698 + __le16 l_i_tag; /* Context Tag */
8699 + __u16 l_i_reserved2;
8702 __u8 h_i_frag; /* Fragment number */
8703 @@ -303,6 +308,7 @@ struct ext2_inode {
8704 #define i_gid_low i_gid
8705 #define i_uid_high osd2.linux2.l_i_uid_high
8706 #define i_gid_high osd2.linux2.l_i_gid_high
8707 +#define i_raw_tag osd2.linux2.l_i_tag
8708 #define i_reserved2 osd2.linux2.l_i_reserved2
8711 @@ -347,6 +353,7 @@ struct ext2_inode {
8712 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8713 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8714 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8715 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8718 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8719 diff -NurpP --minimal linux-2.6.38.1/include/linux/ext3_fs.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/ext3_fs.h
8720 --- linux-2.6.38.1/include/linux/ext3_fs.h 2011-03-15 18:07:38.000000000 +0100
8721 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/ext3_fs.h 2011-01-29 02:01:07.000000000 +0100
8722 @@ -173,10 +173,14 @@ struct ext3_group_desc
8723 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8724 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8725 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8726 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8727 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8729 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8730 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8731 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8732 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8734 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8735 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8737 /* Flags that should be inherited by new inodes from their parent. */
8738 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8739 @@ -312,7 +316,8 @@ struct ext3_inode {
8741 __le16 l_i_uid_high; /* these 2 fields */
8742 __le16 l_i_gid_high; /* were reserved2[0] */
8743 - __u32 l_i_reserved2;
8744 + __le16 l_i_tag; /* Context Tag */
8745 + __u16 l_i_reserved2;
8748 __u8 h_i_frag; /* Fragment number */
8749 @@ -343,6 +348,7 @@ struct ext3_inode {
8750 #define i_gid_low i_gid
8751 #define i_uid_high osd2.linux2.l_i_uid_high
8752 #define i_gid_high osd2.linux2.l_i_gid_high
8753 +#define i_raw_tag osd2.linux2.l_i_tag
8754 #define i_reserved2 osd2.linux2.l_i_reserved2
8756 #elif defined(__GNU__)
8757 @@ -405,6 +411,7 @@ struct ext3_inode {
8758 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8759 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8760 * error in ordered mode */
8761 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8763 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8764 #ifndef _LINUX_EXT2_FS_H
8765 @@ -918,6 +925,7 @@ extern void ext3_get_inode_flags(struct
8766 extern void ext3_set_aops(struct inode *inode);
8767 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8768 u64 start, u64 len);
8769 +extern int ext3_sync_flags(struct inode *, int, int);
8772 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8773 diff -NurpP --minimal linux-2.6.38.1/include/linux/fs.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/fs.h
8774 --- linux-2.6.38.1/include/linux/fs.h 2011-03-15 18:07:38.000000000 +0100
8775 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/fs.h 2011-03-07 16:53:28.000000000 +0100
8776 @@ -214,6 +214,9 @@ struct inodes_stat_t {
8777 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8778 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8779 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8780 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8781 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8782 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8783 #define MS_BORN (1<<29)
8784 #define MS_ACTIVE (1<<30)
8785 #define MS_NOUSER (1<<31)
8786 @@ -243,6 +246,14 @@ struct inodes_stat_t {
8787 #define S_PRIVATE 512 /* Inode is fs-internal */
8788 #define S_IMA 1024 /* Inode has an associated IMA struct */
8789 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
8790 +#define S_IXUNLINK 4096 /* Immutable Invert on unlink */
8792 +/* Linux-VServer related Inode flags */
8796 +#define V_BARRIER 4 /* Barrier for chroot() */
8797 +#define V_COW 8 /* Copy on Write */
8800 * Note that nosuid etc flags are inode-specific: setting some file-system
8801 @@ -265,12 +276,15 @@ struct inodes_stat_t {
8802 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8803 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8804 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8805 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8806 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8807 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8808 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8809 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8811 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8812 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8813 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8814 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8815 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8816 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8818 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8819 @@ -280,6 +294,16 @@ struct inodes_stat_t {
8820 #define IS_IMA(inode) ((inode)->i_flags & S_IMA)
8821 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
8823 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8825 +#ifdef CONFIG_VSERVER_COWBL
8826 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8827 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8829 +# define IS_COW(inode) (0)
8830 +# define IS_COW_LINK(inode) (0)
8833 /* the read-only stuff doesn't really belong here, but any other place is
8834 probably as bad and I don't want to create yet another include file. */
8836 @@ -364,11 +388,14 @@ struct inodes_stat_t {
8837 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8838 #define FS_EXTENT_FL 0x00080000 /* Extents */
8839 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8840 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8841 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8843 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8844 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8845 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8846 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8848 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8849 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8851 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8852 #define SYNC_FILE_RANGE_WRITE 2
8853 @@ -449,6 +476,7 @@ typedef void (dio_iodone_t)(struct kiocb
8854 #define ATTR_KILL_PRIV (1 << 14)
8855 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8856 #define ATTR_TIMES_SET (1 << 16)
8857 +#define ATTR_TAG (1 << 17)
8860 * This is the Inode Attributes structure, used for notify_change(). It
8861 @@ -464,6 +492,7 @@ struct iattr {
8867 struct timespec ia_atime;
8868 struct timespec ia_mtime;
8869 @@ -477,6 +506,9 @@ struct iattr {
8870 struct file *ia_file;
8873 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8874 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8877 * Includes for diskquotas.
8879 @@ -742,11 +774,13 @@ struct inode {
8884 const struct inode_operations *i_op;
8885 struct super_block *i_sb;
8887 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
8888 - unsigned int i_flags;
8889 + unsigned short i_flags;
8890 + unsigned short i_vflags;
8891 struct mutex i_mutex;
8893 unsigned long i_state;
8894 @@ -764,6 +798,7 @@ struct inode {
8896 unsigned int i_nlink;
8899 unsigned int i_blkbits;
8902 @@ -892,12 +927,12 @@ static inline void i_size_write(struct i
8904 static inline unsigned iminor(const struct inode *inode)
8906 - return MINOR(inode->i_rdev);
8907 + return MINOR(inode->i_mdev);
8910 static inline unsigned imajor(const struct inode *inode)
8912 - return MAJOR(inode->i_rdev);
8913 + return MAJOR(inode->i_mdev);
8916 extern struct block_device *I_BDEV(struct inode *inode);
8917 @@ -959,6 +994,7 @@ struct file {
8919 struct fown_struct f_owner;
8920 const struct cred *f_cred;
8922 struct file_ra_state f_ra;
8925 @@ -1096,6 +1132,7 @@ struct file_lock {
8926 struct file *fl_file;
8931 struct fasync_struct * fl_fasync; /* for lease break notifications */
8932 unsigned long fl_break_time; /* for nonblocking lease breaks */
8933 @@ -1584,6 +1621,7 @@ struct inode_operations {
8934 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8935 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8936 int (*removexattr) (struct dentry *, const char *);
8937 + int (*sync_flags) (struct inode *, int, int);
8938 void (*truncate_range)(struct inode *, loff_t, loff_t);
8939 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8941 @@ -1602,6 +1640,7 @@ extern ssize_t vfs_readv(struct file *,
8942 unsigned long, loff_t *);
8943 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8944 unsigned long, loff_t *);
8945 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8947 struct super_operations {
8948 struct inode *(*alloc_inode)(struct super_block *sb);
8949 @@ -2414,6 +2453,7 @@ extern int dcache_dir_open(struct inode
8950 extern int dcache_dir_close(struct inode *, struct file *);
8951 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8952 extern int dcache_readdir(struct file *, void *, filldir_t);
8953 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8954 extern int simple_setattr(struct dentry *, struct iattr *);
8955 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8956 extern int simple_statfs(struct dentry *, struct kstatfs *);
8957 diff -NurpP --minimal linux-2.6.38.1/include/linux/gfs2_ondisk.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/gfs2_ondisk.h
8958 --- linux-2.6.38.1/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
8959 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/gfs2_ondisk.h 2011-01-29 02:01:07.000000000 +0100
8960 @@ -211,6 +211,9 @@ enum {
8964 + gfs2fl_IXUnlink = 16,
8965 + gfs2fl_Barrier = 17,
8967 gfs2fl_TruncInProg = 29,
8968 gfs2fl_InheritDirectio = 30,
8969 gfs2fl_InheritJdata = 31,
8970 @@ -227,6 +230,9 @@ enum {
8971 #define GFS2_DIF_NOATIME 0x00000080
8972 #define GFS2_DIF_SYNC 0x00000100
8973 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8974 +#define GFS2_DIF_IXUNLINK 0x00010000
8975 +#define GFS2_DIF_BARRIER 0x00020000
8976 +#define GFS2_DIF_COW 0x00040000
8977 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8978 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8979 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8980 diff -NurpP --minimal linux-2.6.38.1/include/linux/if_tun.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/if_tun.h
8981 --- linux-2.6.38.1/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8982 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/if_tun.h 2011-01-29 02:01:07.000000000 +0100
8984 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8985 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8986 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8987 +#define TUNSETNID _IOW('T', 217, int)
8989 /* TUNSETIFF ifr flags */
8990 #define IFF_TUN 0x0001
8991 diff -NurpP --minimal linux-2.6.38.1/include/linux/init_task.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/init_task.h
8992 --- linux-2.6.38.1/include/linux/init_task.h 2011-03-15 18:07:38.000000000 +0100
8993 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/init_task.h 2011-01-29 02:01:07.000000000 +0100
8994 @@ -192,6 +192,10 @@ extern struct cred init_cred;
8996 INIT_TRACE_RECURSION \
8997 INIT_TASK_RCU_PREEMPT(tsk) \
8999 + .vx_info = NULL, \
9001 + .nx_info = NULL, \
9005 diff -NurpP --minimal linux-2.6.38.1/include/linux/ipc.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/ipc.h
9006 --- linux-2.6.38.1/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
9007 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/ipc.h 2011-01-29 02:01:07.000000000 +0100
9008 @@ -91,6 +91,7 @@ struct kern_ipc_perm
9016 diff -NurpP --minimal linux-2.6.38.1/include/linux/loop.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/loop.h
9017 --- linux-2.6.38.1/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
9018 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/loop.h 2011-01-29 02:01:07.000000000 +0100
9019 @@ -45,6 +45,7 @@ struct loop_device {
9020 struct loop_func_table *lo_encryption;
9022 uid_t lo_key_owner; /* Who set the key */
9024 int (*ioctl)(struct loop_device *, int cmd,
9027 diff -NurpP --minimal linux-2.6.38.1/include/linux/magic.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/magic.h
9028 --- linux-2.6.38.1/include/linux/magic.h 2011-03-15 18:07:39.000000000 +0100
9029 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/magic.h 2011-01-29 02:01:07.000000000 +0100
9032 #define ADFS_SUPER_MAGIC 0xadf5
9033 #define AFFS_SUPER_MAGIC 0xadff
9034 -#define AFS_SUPER_MAGIC 0x5346414F
9035 +#define AFS_SUPER_MAGIC 0x5346414F
9036 #define AUTOFS_SUPER_MAGIC 0x0187
9037 #define CODA_SUPER_MAGIC 0x73757245
9038 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
9040 #define NFS_SUPER_MAGIC 0x6969
9041 #define OPENPROM_SUPER_MAGIC 0x9fa1
9042 #define PROC_SUPER_MAGIC 0x9fa0
9043 +#define DEVPTS_SUPER_MAGIC 0x1cd1
9044 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
9046 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
9047 diff -NurpP --minimal linux-2.6.38.1/include/linux/major.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/major.h
9048 --- linux-2.6.38.1/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
9049 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/major.h 2011-01-29 02:01:07.000000000 +0100
9051 #define HD_MAJOR IDE0_MAJOR
9052 #define PTY_SLAVE_MAJOR 3
9054 +#define VROOT_MAJOR 4
9055 #define TTYAUX_MAJOR 5
9058 diff -NurpP --minimal linux-2.6.38.1/include/linux/memcontrol.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/memcontrol.h
9059 --- linux-2.6.38.1/include/linux/memcontrol.h 2011-03-15 18:07:39.000000000 +0100
9060 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/memcontrol.h 2011-01-29 02:01:07.000000000 +0100
9061 @@ -82,6 +82,13 @@ int task_in_mem_cgroup(struct task_struc
9062 extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
9063 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
9065 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
9066 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
9068 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
9069 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
9070 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
9073 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
9075 diff -NurpP --minimal linux-2.6.38.1/include/linux/mm_types.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/mm_types.h
9076 --- linux-2.6.38.1/include/linux/mm_types.h 2011-03-15 18:07:39.000000000 +0100
9077 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/mm_types.h 2011-01-29 02:01:07.000000000 +0100
9078 @@ -269,6 +269,7 @@ struct mm_struct {
9080 /* Architecture-specific MM context */
9081 mm_context_t context;
9082 + struct vx_info *mm_vx_info;
9084 /* Swap token stuff */
9086 diff -NurpP --minimal linux-2.6.38.1/include/linux/mount.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/mount.h
9087 --- linux-2.6.38.1/include/linux/mount.h 2011-03-15 18:07:39.000000000 +0100
9088 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/mount.h 2011-01-29 03:11:27.000000000 +0100
9089 @@ -52,6 +52,9 @@ struct mnt_pcp {
9093 +#define MNT_TAGID 0x10000
9094 +#define MNT_NOTAG 0x20000
9097 struct list_head mnt_hash;
9098 struct vfsmount *mnt_parent; /* fs we are mounted on */
9099 @@ -86,6 +89,7 @@ struct vfsmount {
9100 int mnt_expiry_mark; /* true if marked for expiry */
9103 + tag_t mnt_tag; /* tagging used for vfsmount */
9106 struct file; /* forward dec */
9107 diff -NurpP --minimal linux-2.6.38.1/include/linux/net.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/net.h
9108 --- linux-2.6.38.1/include/linux/net.h 2011-01-05 21:50:31.000000000 +0100
9109 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/net.h 2011-01-29 02:01:07.000000000 +0100
9110 @@ -71,6 +71,7 @@ struct net;
9111 #define SOCK_NOSPACE 2
9112 #define SOCK_PASSCRED 3
9113 #define SOCK_PASSSEC 4
9114 +#define SOCK_USER_SOCKET 5
9116 #ifndef ARCH_HAS_SOCKET_TYPES
9118 diff -NurpP --minimal linux-2.6.38.1/include/linux/nfs_mount.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/nfs_mount.h
9119 --- linux-2.6.38.1/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
9120 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/nfs_mount.h 2011-01-29 02:01:07.000000000 +0100
9121 @@ -63,7 +63,8 @@ struct nfs_mount_data {
9122 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
9123 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
9124 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
9125 -#define NFS_MOUNT_FLAGMASK 0xFFFF
9126 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
9127 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
9129 /* The following are for internal use only */
9130 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
9131 diff -NurpP --minimal linux-2.6.38.1/include/linux/nsproxy.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/nsproxy.h
9132 --- linux-2.6.38.1/include/linux/nsproxy.h 2009-06-11 17:13:17.000000000 +0200
9133 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/nsproxy.h 2011-01-29 02:01:07.000000000 +0100
9136 #include <linux/spinlock.h>
9137 #include <linux/sched.h>
9138 +#include <linux/vserver/debug.h>
9140 struct mnt_namespace;
9141 struct uts_namespace;
9142 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
9145 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
9146 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
9147 void exit_task_namespaces(struct task_struct *tsk);
9148 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
9149 void free_nsproxy(struct nsproxy *ns);
9150 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
9151 struct fs_struct *);
9153 -static inline void put_nsproxy(struct nsproxy *ns)
9154 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
9156 +static inline void __get_nsproxy(struct nsproxy *ns,
9157 + const char *_file, int _line)
9159 - if (atomic_dec_and_test(&ns->count)) {
9162 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
9163 + ns, atomic_read(&ns->count), _file, _line);
9164 + atomic_inc(&ns->count);
9167 -static inline void get_nsproxy(struct nsproxy *ns)
9168 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
9170 +static inline void __put_nsproxy(struct nsproxy *ns,
9171 + const char *_file, int _line)
9173 - atomic_inc(&ns->count);
9174 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
9175 + ns, atomic_read(&ns->count), _file, _line);
9176 + if (atomic_dec_and_test(&ns->count)) {
9181 #ifdef CONFIG_CGROUP_NS
9182 diff -NurpP --minimal linux-2.6.38.1/include/linux/pid.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/pid.h
9183 --- linux-2.6.38.1/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
9184 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/pid.h 2011-01-29 02:01:07.000000000 +0100
9185 @@ -8,7 +8,8 @@ enum pid_type
9195 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
9198 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9199 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9200 pid_t pid_vnr(struct pid *pid);
9202 #define do_each_pid_task(pid, type, task) \
9203 diff -NurpP --minimal linux-2.6.38.1/include/linux/proc_fs.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/proc_fs.h
9204 --- linux-2.6.38.1/include/linux/proc_fs.h 2009-12-03 20:02:56.000000000 +0100
9205 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/proc_fs.h 2011-01-29 02:01:07.000000000 +0100
9206 @@ -56,6 +56,7 @@ struct proc_dir_entry {
9212 const struct inode_operations *proc_iops;
9214 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void
9215 extern void kclist_add(struct kcore_list *, void *, size_t, int type);
9222 int (*proc_get_link)(struct inode *, struct path *);
9223 int (*proc_read)(struct task_struct *task, char *page);
9224 int (*proc_show)(struct seq_file *m,
9225 struct pid_namespace *ns, struct pid *pid,
9226 struct task_struct *task);
9227 + int (*proc_vs_read)(char *page);
9228 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9229 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9232 struct ctl_table_header;
9233 @@ -263,6 +270,7 @@ struct ctl_table;
9240 struct proc_dir_entry *pde;
9241 diff -NurpP --minimal linux-2.6.38.1/include/linux/quotaops.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/quotaops.h
9242 --- linux-2.6.38.1/include/linux/quotaops.h 2011-03-15 18:07:39.000000000 +0100
9243 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/quotaops.h 2011-01-29 02:01:07.000000000 +0100
9245 #define _LINUX_QUOTAOPS_
9247 #include <linux/fs.h>
9248 +#include <linux/vs_dlimit.h>
9250 #define DQUOT_SPACE_WARN 0x1
9251 #define DQUOT_SPACE_RESERVE 0x2
9252 @@ -204,11 +205,12 @@ static inline void dquot_drop(struct ino
9254 static inline int dquot_alloc_inode(const struct inode *inode)
9257 + return dl_alloc_inode(inode);
9260 static inline void dquot_free_inode(const struct inode *inode)
9262 + dl_free_inode(inode);
9265 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
9266 @@ -219,6 +221,10 @@ static inline int dquot_transfer(struct
9267 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
9272 + if ((ret = dl_alloc_space(inode, number)))
9274 if (!(flags & DQUOT_SPACE_RESERVE))
9275 inode_add_bytes(inode, number);
9277 @@ -229,6 +235,7 @@ static inline void __dquot_free_space(st
9279 if (!(flags & DQUOT_SPACE_RESERVE))
9280 inode_sub_bytes(inode, number);
9281 + dl_free_space(inode, number);
9284 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
9285 diff -NurpP --minimal linux-2.6.38.1/include/linux/reboot.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/reboot.h
9286 --- linux-2.6.38.1/include/linux/reboot.h 2010-07-07 18:31:56.000000000 +0200
9287 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/reboot.h 2011-01-29 02:01:07.000000000 +0100
9289 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
9290 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
9291 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
9292 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
9296 diff -NurpP --minimal linux-2.6.38.1/include/linux/reiserfs_fs.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/reiserfs_fs.h
9297 --- linux-2.6.38.1/include/linux/reiserfs_fs.h 2011-01-05 21:50:32.000000000 +0100
9298 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/reiserfs_fs.h 2011-01-29 02:01:07.000000000 +0100
9299 @@ -976,6 +976,11 @@ struct stat_data_v1 {
9300 #define REISERFS_COMPR_FL FS_COMPR_FL
9301 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9303 +/* unfortunately reiserfs sdattr is only 16 bit */
9304 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9305 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9306 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9308 /* persistent flags that file inherits from the parent directory */
9309 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9310 REISERFS_SYNC_FL | \
9311 @@ -985,6 +990,9 @@ struct stat_data_v1 {
9312 REISERFS_COMPR_FL | \
9313 REISERFS_NOTAIL_FL )
9315 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9316 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9318 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9321 @@ -2070,6 +2078,7 @@ static inline void reiserfs_update_sd(st
9322 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9323 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9324 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9325 +int reiserfs_sync_flags(struct inode *inode, int, int);
9327 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
9329 diff -NurpP --minimal linux-2.6.38.1/include/linux/reiserfs_fs_sb.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/reiserfs_fs_sb.h
9330 --- linux-2.6.38.1/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
9331 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/reiserfs_fs_sb.h 2011-01-29 02:01:07.000000000 +0100
9332 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
9333 REISERFS_EXPOSE_PRIVROOT,
9334 REISERFS_BARRIER_NONE,
9335 REISERFS_BARRIER_FLUSH,
9338 /* Actions on error */
9339 REISERFS_ERROR_PANIC,
9340 diff -NurpP --minimal linux-2.6.38.1/include/linux/sched.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/sched.h
9341 --- linux-2.6.38.1/include/linux/sched.h 2011-03-15 18:07:39.000000000 +0100
9342 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/sched.h 2011-03-07 16:53:28.000000000 +0100
9343 @@ -1373,6 +1373,14 @@ struct task_struct {
9347 +/* vserver context data */
9348 + struct vx_info *vx_info;
9349 + struct nx_info *nx_info;
9355 /* Thread group tracking */
9358 @@ -1607,6 +1615,11 @@ struct pid_namespace;
9359 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9360 struct pid_namespace *ns);
9362 +#include <linux/vserver/base.h>
9363 +#include <linux/vserver/context.h>
9364 +#include <linux/vserver/debug.h>
9365 +#include <linux/vserver/pid.h>
9367 static inline pid_t task_pid_nr(struct task_struct *tsk)
9370 @@ -1620,7 +1633,8 @@ static inline pid_t task_pid_nr_ns(struc
9372 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9374 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9375 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9376 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
9380 @@ -1633,7 +1647,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9382 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9384 - return pid_vnr(task_tgid(tsk));
9385 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9389 diff -NurpP --minimal linux-2.6.38.1/include/linux/shmem_fs.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/shmem_fs.h
9390 --- linux-2.6.38.1/include/linux/shmem_fs.h 2010-10-21 13:07:55.000000000 +0200
9391 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/shmem_fs.h 2011-01-29 02:01:07.000000000 +0100
9394 #define SHMEM_NR_DIRECT 16
9396 +#define TMPFS_SUPER_MAGIC 0x01021994
9399 struct shmem_inode_info {
9401 unsigned long flags;
9402 diff -NurpP --minimal linux-2.6.38.1/include/linux/stat.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/stat.h
9403 --- linux-2.6.38.1/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9404 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/stat.h 2011-01-29 02:01:07.000000000 +0100
9405 @@ -66,6 +66,7 @@ struct kstat {
9412 struct timespec atime;
9413 diff -NurpP --minimal linux-2.6.38.1/include/linux/sunrpc/auth.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/sunrpc/auth.h
9414 --- linux-2.6.38.1/include/linux/sunrpc/auth.h 2011-03-15 18:07:39.000000000 +0100
9415 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/sunrpc/auth.h 2011-01-29 02:01:07.000000000 +0100
9421 struct group_info *group_info;
9422 unsigned char machine_cred : 1;
9424 diff -NurpP --minimal linux-2.6.38.1/include/linux/sunrpc/clnt.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/sunrpc/clnt.h
9425 --- linux-2.6.38.1/include/linux/sunrpc/clnt.h 2011-03-15 18:07:39.000000000 +0100
9426 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/sunrpc/clnt.h 2011-01-29 02:01:07.000000000 +0100
9427 @@ -49,7 +49,8 @@ struct rpc_clnt {
9428 unsigned int cl_softrtry : 1,/* soft timeouts */
9429 cl_discrtry : 1,/* disconnect before retry */
9430 cl_autobind : 1,/* use getport() */
9431 - cl_chatty : 1;/* be verbose */
9432 + cl_chatty : 1,/* be verbose */
9433 + cl_tag : 1;/* context tagging */
9435 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9436 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9437 diff -NurpP --minimal linux-2.6.38.1/include/linux/syscalls.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/syscalls.h
9438 --- linux-2.6.38.1/include/linux/syscalls.h 2011-03-15 18:07:39.000000000 +0100
9439 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/syscalls.h 2011-02-17 02:17:51.000000000 +0100
9440 @@ -478,6 +478,8 @@ asmlinkage long sys_symlink(const char _
9441 asmlinkage long sys_unlink(const char __user *pathname);
9442 asmlinkage long sys_rename(const char __user *oldname,
9443 const char __user *newname);
9444 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9446 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9447 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9449 diff -NurpP --minimal linux-2.6.38.1/include/linux/sysctl.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/sysctl.h
9450 --- linux-2.6.38.1/include/linux/sysctl.h 2011-03-15 18:07:40.000000000 +0100
9451 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/sysctl.h 2011-03-15 18:15:06.000000000 +0100
9452 @@ -60,6 +60,7 @@ enum
9453 CTL_ABI=9, /* Binary emulation */
9454 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9455 CTL_ARLAN=254, /* arlan wireless driver */
9456 + CTL_VSERVER=4242, /* Linux-VServer debug */
9457 CTL_S390DBF=5677, /* s390 debug */
9458 CTL_SUNRPC=7249, /* sunrpc debug */
9459 CTL_PM=9899, /* frv power management */
9460 @@ -94,6 +95,7 @@ enum
9462 KERN_PANIC=15, /* int: panic timeout */
9463 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9464 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9466 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9467 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9468 diff -NurpP --minimal linux-2.6.38.1/include/linux/sysfs.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/sysfs.h
9469 --- linux-2.6.38.1/include/linux/sysfs.h 2011-01-05 21:50:34.000000000 +0100
9470 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/sysfs.h 2011-01-29 02:01:07.000000000 +0100
9472 #include <linux/kobject_ns.h>
9473 #include <asm/atomic.h>
9475 +#define SYSFS_SUPER_MAGIC 0x62656572
9480 diff -NurpP --minimal linux-2.6.38.1/include/linux/time.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/time.h
9481 --- linux-2.6.38.1/include/linux/time.h 2011-03-15 18:07:40.000000000 +0100
9482 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/time.h 2011-01-29 02:01:07.000000000 +0100
9483 @@ -254,6 +254,9 @@ static __always_inline void timespec_add
9484 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9488 +#include <linux/vs_time.h>
9490 #endif /* __KERNEL__ */
9492 #define NFDBITS __NFDBITS
9493 diff -NurpP --minimal linux-2.6.38.1/include/linux/types.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/types.h
9494 --- linux-2.6.38.1/include/linux/types.h 2011-01-05 21:50:34.000000000 +0100
9495 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/types.h 2011-01-29 02:01:07.000000000 +0100
9496 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
9497 typedef __kernel_gid32_t gid_t;
9498 typedef __kernel_uid16_t uid16_t;
9499 typedef __kernel_gid16_t gid16_t;
9500 +typedef unsigned int xid_t;
9501 +typedef unsigned int nid_t;
9502 +typedef unsigned int tag_t;
9504 typedef unsigned long uintptr_t;
9506 diff -NurpP --minimal linux-2.6.38.1/include/linux/vroot.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vroot.h
9507 --- linux-2.6.38.1/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9508 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vroot.h 2011-01-29 02:01:07.000000000 +0100
9512 + * include/linux/vroot.h
9514 + * written by Herbert Pötzl, 9/11/2002
9515 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9517 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9518 + * Redistribution of this file is permitted under the
9519 + * GNU General Public License.
9522 +#ifndef _LINUX_VROOT_H
9523 +#define _LINUX_VROOT_H
9528 +/* Possible states of device */
9534 +struct vroot_device {
9538 + struct semaphore vr_ctl_mutex;
9539 + struct block_device *vr_device;
9544 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9546 +extern int register_vroot_grb(vroot_grb_func *);
9547 +extern int unregister_vroot_grb(vroot_grb_func *);
9549 +#endif /* __KERNEL__ */
9551 +#define MAX_VROOT_DEFAULT 8
9554 + * IOCTL commands --- we will commandeer 0x56 ('V')
9557 +#define VROOT_SET_DEV 0x5600
9558 +#define VROOT_CLR_DEV 0x5601
9560 +#endif /* _LINUX_VROOT_H */
9561 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_base.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_base.h
9562 --- linux-2.6.38.1/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9563 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_base.h 2011-01-29 02:01:07.000000000 +0100
9568 +#include "vserver/base.h"
9569 +#include "vserver/check.h"
9570 +#include "vserver/debug.h"
9573 +#warning duplicate inclusion
9575 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_context.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_context.h
9576 --- linux-2.6.38.1/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9577 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_context.h 2011-01-29 02:01:07.000000000 +0100
9579 +#ifndef _VS_CONTEXT_H
9580 +#define _VS_CONTEXT_H
9582 +#include "vserver/base.h"
9583 +#include "vserver/check.h"
9584 +#include "vserver/context.h"
9585 +#include "vserver/history.h"
9586 +#include "vserver/debug.h"
9588 +#include <linux/sched.h>
9591 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9593 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9594 + const char *_file, int _line, void *_here)
9599 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9600 + vxi, vxi ? vxi->vx_id : 0,
9601 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9603 + __vxh_get_vx_info(vxi, _here);
9605 + atomic_inc(&vxi->vx_usecnt);
9610 +extern void free_vx_info(struct vx_info *);
9612 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9614 +static inline void __put_vx_info(struct vx_info *vxi,
9615 + const char *_file, int _line, void *_here)
9620 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9621 + vxi, vxi ? vxi->vx_id : 0,
9622 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9624 + __vxh_put_vx_info(vxi, _here);
9626 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9627 + free_vx_info(vxi);
9631 +#define init_vx_info(p, i) \
9632 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9634 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9635 + const char *_file, int _line, void *_here)
9638 + vxlprintk(VXD_CBIT(xid, 3),
9639 + "init_vx_info(%p[#%d.%d])",
9640 + vxi, vxi ? vxi->vx_id : 0,
9641 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9643 + __vxh_init_vx_info(vxi, vxp, _here);
9645 + atomic_inc(&vxi->vx_usecnt);
9651 +#define set_vx_info(p, i) \
9652 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9654 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9655 + const char *_file, int _line, void *_here)
9657 + struct vx_info *vxo;
9662 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9663 + vxi, vxi ? vxi->vx_id : 0,
9664 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9666 + __vxh_set_vx_info(vxi, vxp, _here);
9668 + atomic_inc(&vxi->vx_usecnt);
9669 + vxo = xchg(vxp, vxi);
9674 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9676 +static inline void __clr_vx_info(struct vx_info **vxp,
9677 + const char *_file, int _line, void *_here)
9679 + struct vx_info *vxo;
9681 + vxo = xchg(vxp, NULL);
9685 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9686 + vxo, vxo ? vxo->vx_id : 0,
9687 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9689 + __vxh_clr_vx_info(vxo, vxp, _here);
9691 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9692 + free_vx_info(vxo);
9696 +#define claim_vx_info(v, p) \
9697 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9699 +static inline void __claim_vx_info(struct vx_info *vxi,
9700 + struct task_struct *task,
9701 + const char *_file, int _line, void *_here)
9703 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9704 + vxi, vxi ? vxi->vx_id : 0,
9705 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9706 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9707 + task, _file, _line);
9708 + __vxh_claim_vx_info(vxi, task, _here);
9710 + atomic_inc(&vxi->vx_tasks);
9714 +extern void unhash_vx_info(struct vx_info *);
9716 +#define release_vx_info(v, p) \
9717 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9719 +static inline void __release_vx_info(struct vx_info *vxi,
9720 + struct task_struct *task,
9721 + const char *_file, int _line, void *_here)
9723 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9724 + vxi, vxi ? vxi->vx_id : 0,
9725 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9726 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9727 + task, _file, _line);
9728 + __vxh_release_vx_info(vxi, task, _here);
9732 + if (atomic_dec_and_test(&vxi->vx_tasks))
9733 + unhash_vx_info(vxi);
9737 +#define task_get_vx_info(p) \
9738 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9740 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9741 + const char *_file, int _line, void *_here)
9743 + struct vx_info *vxi;
9746 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9748 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9754 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9756 + if (waitqueue_active(&vxi->vx_wait))
9757 + wake_up_interruptible(&vxi->vx_wait);
9761 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9763 +static inline void __enter_vx_info(struct vx_info *vxi,
9764 + struct vx_info_save *vxis, const char *_file, int _line)
9766 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9767 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9768 + current->xid, current->vx_info, _file, _line);
9769 + vxis->vxi = xchg(¤t->vx_info, vxi);
9770 + vxis->xid = current->xid;
9771 + current->xid = vxi ? vxi->vx_id : 0;
9774 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9776 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9777 + const char *_file, int _line)
9779 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9780 + vxis, vxis->xid, vxis->vxi, current,
9781 + current->xid, current->vx_info, _file, _line);
9782 + (void)xchg(¤t->vx_info, vxis->vxi);
9783 + current->xid = vxis->xid;
9787 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9789 + vxis->vxi = xchg(¤t->vx_info, NULL);
9790 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9793 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9795 + (void)xchg(¤t->xid, vxis->xid);
9796 + (void)xchg(¤t->vx_info, vxis->vxi);
9799 +#define task_is_init(p) \
9800 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9802 +static inline int __task_is_init(struct task_struct *p,
9803 + const char *_file, int _line, void *_here)
9805 + int is_init = is_global_init(p);
9809 + is_init = p->vx_info->vx_initpid == p->pid;
9814 +extern void exit_vx_info(struct task_struct *, int);
9815 +extern void exit_vx_info_early(struct task_struct *, int);
9819 +#warning duplicate inclusion
9821 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_cowbl.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_cowbl.h
9822 --- linux-2.6.38.1/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9823 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_cowbl.h 2011-01-29 02:01:07.000000000 +0100
9825 +#ifndef _VS_COWBL_H
9826 +#define _VS_COWBL_H
9828 +#include <linux/fs.h>
9829 +#include <linux/dcache.h>
9830 +#include <linux/namei.h>
9831 +#include <linux/slab.h>
9833 +extern struct dentry *cow_break_link(const char *pathname);
9835 +static inline int cow_check_and_break(struct path *path)
9837 + struct inode *inode = path->dentry->d_inode;
9840 + /* do we need this check? */
9841 + if (IS_RDONLY(inode))
9844 + if (IS_COW(inode)) {
9845 + if (IS_COW_LINK(inode)) {
9846 + struct dentry *new_dentry, *old_dentry = path->dentry;
9849 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9853 + pp = d_path(path, buf, PATH_MAX);
9854 + new_dentry = cow_break_link(pp);
9856 + if (!IS_ERR(new_dentry)) {
9857 + path->dentry = new_dentry;
9860 + error = PTR_ERR(new_dentry);
9862 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9863 + inode->i_ctime = CURRENT_TIME;
9864 + mark_inode_dirty(inode);
9871 +#warning duplicate inclusion
9873 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_cvirt.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_cvirt.h
9874 --- linux-2.6.38.1/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9875 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_cvirt.h 2011-01-29 02:01:07.000000000 +0100
9877 +#ifndef _VS_CVIRT_H
9878 +#define _VS_CVIRT_H
9880 +#include "vserver/cvirt.h"
9881 +#include "vserver/context.h"
9882 +#include "vserver/base.h"
9883 +#include "vserver/check.h"
9884 +#include "vserver/debug.h"
9887 +static inline void vx_activate_task(struct task_struct *p)
9889 + struct vx_info *vxi;
9891 + if ((vxi = p->vx_info)) {
9892 + vx_update_load(vxi);
9893 + atomic_inc(&vxi->cvirt.nr_running);
9897 +static inline void vx_deactivate_task(struct task_struct *p)
9899 + struct vx_info *vxi;
9901 + if ((vxi = p->vx_info)) {
9902 + vx_update_load(vxi);
9903 + atomic_dec(&vxi->cvirt.nr_running);
9907 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9909 + struct vx_info *vxi;
9911 + if ((vxi = p->vx_info))
9912 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9915 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9917 + struct vx_info *vxi;
9919 + if ((vxi = p->vx_info))
9920 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9925 +#warning duplicate inclusion
9927 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_device.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_device.h
9928 --- linux-2.6.38.1/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9929 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_device.h 2011-01-29 02:01:07.000000000 +0100
9931 +#ifndef _VS_DEVICE_H
9932 +#define _VS_DEVICE_H
9934 +#include "vserver/base.h"
9935 +#include "vserver/device.h"
9936 +#include "vserver/debug.h"
9939 +#ifdef CONFIG_VSERVER_DEVICE
9941 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9943 +#define vs_device_perm(v, d, m, p) \
9944 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9949 +int vs_map_device(struct vx_info *vxi,
9950 + dev_t device, dev_t *target, umode_t mode)
9957 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9962 +#define vs_map_chrdev(d, t, p) \
9963 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9964 +#define vs_map_blkdev(d, t, p) \
9965 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9967 +#define vs_chrdev_perm(d, p) \
9968 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9969 +#define vs_blkdev_perm(d, p) \
9970 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9974 +#warning duplicate inclusion
9976 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_dlimit.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_dlimit.h
9977 --- linux-2.6.38.1/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9978 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_dlimit.h 2011-01-29 02:01:07.000000000 +0100
9980 +#ifndef _VS_DLIMIT_H
9981 +#define _VS_DLIMIT_H
9983 +#include <linux/fs.h>
9985 +#include "vserver/dlimit.h"
9986 +#include "vserver/base.h"
9987 +#include "vserver/debug.h"
9990 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9992 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9993 + const char *_file, int _line)
9997 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9998 + dli, dli ? dli->dl_tag : 0,
9999 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10001 + atomic_inc(&dli->dl_usecnt);
10006 +#define free_dl_info(i) \
10007 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
10009 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
10011 +static inline void __put_dl_info(struct dl_info *dli,
10012 + const char *_file, int _line)
10016 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
10017 + dli, dli ? dli->dl_tag : 0,
10018 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10020 + if (atomic_dec_and_test(&dli->dl_usecnt))
10021 + free_dl_info(dli);
10025 +#define __dlimit_char(d) ((d) ? '*' : ' ')
10027 +static inline int __dl_alloc_space(struct super_block *sb,
10028 + tag_t tag, dlsize_t nr, const char *file, int line)
10030 + struct dl_info *dli = NULL;
10035 + dli = locate_dl_info(sb, tag);
10039 + spin_lock(&dli->dl_lock);
10040 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
10042 + dli->dl_space_used += nr;
10043 + spin_unlock(&dli->dl_lock);
10044 + put_dl_info(dli);
10046 + vxlprintk(VXD_CBIT(dlim, 1),
10047 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
10048 + sb, tag, __dlimit_char(dli), (long long)nr,
10049 + ret, file, line);
10050 + return ret ? -ENOSPC : 0;
10053 +static inline void __dl_free_space(struct super_block *sb,
10054 + tag_t tag, dlsize_t nr, const char *_file, int _line)
10056 + struct dl_info *dli = NULL;
10060 + dli = locate_dl_info(sb, tag);
10064 + spin_lock(&dli->dl_lock);
10065 + if (dli->dl_space_used > nr)
10066 + dli->dl_space_used -= nr;
10068 + dli->dl_space_used = 0;
10069 + spin_unlock(&dli->dl_lock);
10070 + put_dl_info(dli);
10072 + vxlprintk(VXD_CBIT(dlim, 1),
10073 + "FREE (%p,#%d)%c %lld bytes",
10074 + sb, tag, __dlimit_char(dli), (long long)nr,
10078 +static inline int __dl_alloc_inode(struct super_block *sb,
10079 + tag_t tag, const char *_file, int _line)
10081 + struct dl_info *dli;
10084 + dli = locate_dl_info(sb, tag);
10088 + spin_lock(&dli->dl_lock);
10089 + dli->dl_inodes_used++;
10090 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
10091 + spin_unlock(&dli->dl_lock);
10092 + put_dl_info(dli);
10094 + vxlprintk(VXD_CBIT(dlim, 0),
10095 + "ALLOC (%p,#%d)%c inode (%d)",
10096 + sb, tag, __dlimit_char(dli), ret, _file, _line);
10097 + return ret ? -ENOSPC : 0;
10100 +static inline void __dl_free_inode(struct super_block *sb,
10101 + tag_t tag, const char *_file, int _line)
10103 + struct dl_info *dli;
10105 + dli = locate_dl_info(sb, tag);
10109 + spin_lock(&dli->dl_lock);
10110 + if (dli->dl_inodes_used > 1)
10111 + dli->dl_inodes_used--;
10113 + dli->dl_inodes_used = 0;
10114 + spin_unlock(&dli->dl_lock);
10115 + put_dl_info(dli);
10117 + vxlprintk(VXD_CBIT(dlim, 0),
10118 + "FREE (%p,#%d)%c inode",
10119 + sb, tag, __dlimit_char(dli), _file, _line);
10122 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10123 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10124 + const char *_file, int _line)
10126 + struct dl_info *dli;
10127 + uint64_t broot, bfree;
10129 + dli = locate_dl_info(sb, tag);
10133 + spin_lock(&dli->dl_lock);
10134 + broot = (dli->dl_space_total -
10135 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10136 + >> sb->s_blocksize_bits;
10137 + bfree = (dli->dl_space_total - dli->dl_space_used)
10138 + >> sb->s_blocksize_bits;
10139 + spin_unlock(&dli->dl_lock);
10141 + vxlprintk(VXD_CBIT(dlim, 2),
10142 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10143 + (long long)bfree, (long long)broot,
10144 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10146 + if (free_blocks) {
10147 + if (*free_blocks > bfree)
10148 + *free_blocks = bfree;
10150 + if (root_blocks) {
10151 + if (*root_blocks > broot)
10152 + *root_blocks = broot;
10154 + put_dl_info(dli);
10157 +#define dl_prealloc_space(in, bytes) \
10158 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10159 + __FILE__, __LINE__ )
10161 +#define dl_alloc_space(in, bytes) \
10162 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10163 + __FILE__, __LINE__ )
10165 +#define dl_reserve_space(in, bytes) \
10166 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10167 + __FILE__, __LINE__ )
10169 +#define dl_claim_space(in, bytes) (0)
10171 +#define dl_release_space(in, bytes) \
10172 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10173 + __FILE__, __LINE__ )
10175 +#define dl_free_space(in, bytes) \
10176 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10177 + __FILE__, __LINE__ )
10181 +#define dl_alloc_inode(in) \
10182 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10184 +#define dl_free_inode(in) \
10185 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10188 +#define dl_adjust_block(sb, tag, fb, rb) \
10189 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10193 +#warning duplicate inclusion
10195 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_inet.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_inet.h
10196 --- linux-2.6.38.1/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
10197 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_inet.h 2011-01-29 04:45:50.000000000 +0100
10199 +#ifndef _VS_INET_H
10200 +#define _VS_INET_H
10202 +#include "vserver/base.h"
10203 +#include "vserver/network.h"
10204 +#include "vserver/debug.h"
10206 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
10208 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
10209 + NIPQUAD((a)->mask), (a)->type
10210 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
10212 +#define NIPQUAD(addr) \
10213 + ((unsigned char *)&addr)[0], \
10214 + ((unsigned char *)&addr)[1], \
10215 + ((unsigned char *)&addr)[2], \
10216 + ((unsigned char *)&addr)[3]
10218 +#define NIPQUAD_FMT "%u.%u.%u.%u"
10222 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
10224 + __be32 ip = nxa->ip[0].s_addr;
10225 + __be32 mask = nxa->mask.s_addr;
10226 + __be32 bcast = ip | ~mask;
10229 + switch (nxa->type & tmask) {
10230 + case NXA_TYPE_MASK:
10231 + ret = (ip == (addr & mask));
10233 + case NXA_TYPE_ADDR:
10237 + /* fall through to broadcast */
10238 + case NXA_MOD_BCAST:
10239 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
10241 + case NXA_TYPE_RANGE:
10242 + ret = ((nxa->ip[0].s_addr <= addr) &&
10243 + (nxa->ip[1].s_addr > addr));
10245 + case NXA_TYPE_ANY:
10250 + vxdprintk(VXD_CBIT(net, 0),
10251 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
10252 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
10257 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
10259 + struct nx_addr_v4 *nxa;
10266 + /* allow 127.0.0.1 when remapping lback */
10267 + if ((tmask & NXA_LOOPBACK) &&
10268 + (addr == IPI_LOOPBACK) &&
10269 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10272 + /* check for lback address */
10273 + if ((tmask & NXA_MOD_LBACK) &&
10274 + (nxi->v4_lback.s_addr == addr))
10277 + /* check for broadcast address */
10278 + if ((tmask & NXA_MOD_BCAST) &&
10279 + (nxi->v4_bcast.s_addr == addr))
10282 + /* check for v4 addresses */
10283 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
10284 + if (v4_addr_match(nxa, addr, tmask))
10288 + vxdprintk(VXD_CBIT(net, 0),
10289 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
10290 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
10295 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
10297 + /* FIXME: needs full range checks */
10298 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
10302 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
10304 + struct nx_addr_v4 *ptr;
10306 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
10307 + if (v4_nx_addr_match(ptr, nxa, mask))
10312 +#include <net/inet_sock.h>
10315 + * Check if a given address matches for a socket
10317 + * nxi: the socket's nx_info if any
10318 + * addr: to be verified address
10321 +int v4_sock_addr_match (
10322 + struct nx_info *nxi,
10323 + struct inet_sock *inet,
10326 + __be32 saddr = inet->inet_rcv_saddr;
10327 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
10329 + if (addr && (saddr == addr || bcast == addr))
10332 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
10337 +/* inet related checks and helpers */
10341 +struct net_device;
10344 +#ifdef CONFIG_INET
10346 +#include <linux/netdevice.h>
10347 +#include <linux/inetdevice.h>
10348 +#include <net/inet_sock.h>
10349 +#include <net/inet_timewait_sock.h>
10352 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10353 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
10354 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
10358 + * check if address is covered by socket
10360 + * sk: the socket to check against
10361 + * addr: the address in question (must be != 0)
10365 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
10367 + struct nx_info *nxi = sk->sk_nx_info;
10368 + __be32 saddr = sk_rcv_saddr(sk);
10370 + vxdprintk(VXD_CBIT(net, 5),
10371 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
10372 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
10373 + (sk->sk_socket?sk->sk_socket->flags:0));
10375 + if (saddr) { /* direct address match */
10376 + return v4_addr_match(nxa, saddr, -1);
10377 + } else if (nxi) { /* match against nx_info */
10378 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
10379 + } else { /* unrestricted any socket */
10387 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
10389 + vxdprintk(VXD_CBIT(net, 1),
10390 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
10391 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
10392 + nxi ? dev_in_nx_info(dev, nxi) : 0);
10394 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10396 + if (dev_in_nx_info(dev, nxi))
10403 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
10409 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
10413 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
10415 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
10416 + nxi, nxi ? nxi->nx_id : 0, ifa,
10417 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
10419 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10421 + if (v4_ifa_in_nx_info(ifa, nxi))
10427 +struct nx_v4_sock_addr {
10428 + __be32 saddr; /* Address used for validation */
10429 + __be32 baddr; /* Address used for socket bind */
10433 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
10434 + struct nx_v4_sock_addr *nsa)
10436 + struct sock *sk = &inet->sk;
10437 + struct nx_info *nxi = sk->sk_nx_info;
10438 + __be32 saddr = addr->sin_addr.s_addr;
10439 + __be32 baddr = saddr;
10441 + vxdprintk(VXD_CBIT(net, 3),
10442 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
10443 + sk, sk->sk_nx_info, sk->sk_socket,
10444 + (sk->sk_socket ? sk->sk_socket->flags : 0),
10448 + if (saddr == INADDR_ANY) {
10449 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
10450 + baddr = nxi->v4.ip[0].s_addr;
10451 + } else if (saddr == IPI_LOOPBACK) {
10452 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10453 + baddr = nxi->v4_lback.s_addr;
10454 + } else { /* normal address bind */
10455 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
10456 + return -EADDRNOTAVAIL;
10460 + vxdprintk(VXD_CBIT(net, 3),
10461 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
10462 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
10464 + nsa->saddr = saddr;
10465 + nsa->baddr = baddr;
10470 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
10472 + inet->inet_saddr = nsa->baddr;
10473 + inet->inet_rcv_saddr = nsa->baddr;
10478 + * helper to simplify inet_lookup_listener
10480 + * nxi: the socket's nx_info if any
10481 + * addr: to be verified address
10482 + * saddr: socket address
10484 +static inline int v4_inet_addr_match (
10485 + struct nx_info *nxi,
10489 + if (addr && (saddr == addr))
10492 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
10496 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
10498 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
10499 + (addr == nxi->v4_lback.s_addr))
10500 + return IPI_LOOPBACK;
10505 +int nx_info_has_v4(struct nx_info *nxi)
10509 + if (NX_IPV4(nxi))
10511 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10516 +#else /* CONFIG_INET */
10519 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
10525 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10531 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10537 +int nx_info_has_v4(struct nx_info *nxi)
10542 +#endif /* CONFIG_INET */
10544 +#define current_nx_info_has_v4() \
10545 + nx_info_has_v4(current_nx_info())
10548 +// #warning duplicate inclusion
10550 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_inet6.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_inet6.h
10551 --- linux-2.6.38.1/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
10552 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_inet6.h 2011-01-29 02:01:07.000000000 +0100
10554 +#ifndef _VS_INET6_H
10555 +#define _VS_INET6_H
10557 +#include "vserver/base.h"
10558 +#include "vserver/network.h"
10559 +#include "vserver/debug.h"
10561 +#include <net/ipv6.h>
10563 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
10564 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
10567 +#ifdef CONFIG_IPV6
10570 +int v6_addr_match(struct nx_addr_v6 *nxa,
10571 + const struct in6_addr *addr, uint16_t mask)
10575 + switch (nxa->type & mask) {
10576 + case NXA_TYPE_MASK:
10577 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
10579 + case NXA_TYPE_ADDR:
10580 + ret = ipv6_addr_equal(&nxa->ip, addr);
10582 + case NXA_TYPE_ANY:
10586 + vxdprintk(VXD_CBIT(net, 0),
10587 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
10588 + nxa, NXAV6(nxa), addr, mask, ret);
10593 +int v6_addr_in_nx_info(struct nx_info *nxi,
10594 + const struct in6_addr *addr, uint16_t mask)
10596 + struct nx_addr_v6 *nxa;
10601 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
10602 + if (v6_addr_match(nxa, addr, mask))
10606 + vxdprintk(VXD_CBIT(net, 0),
10607 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
10608 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
10613 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
10615 + /* FIXME: needs full range checks */
10616 + return v6_addr_match(nxa, &addr->ip, mask);
10620 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
10622 + struct nx_addr_v6 *ptr;
10624 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
10625 + if (v6_nx_addr_match(ptr, nxa, mask))
10632 + * Check if a given address matches for a socket
10634 + * nxi: the socket's nx_info if any
10635 + * addr: to be verified address
10638 +int v6_sock_addr_match (
10639 + struct nx_info *nxi,
10640 + struct inet_sock *inet,
10641 + struct in6_addr *addr)
10643 + struct sock *sk = &inet->sk;
10644 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10646 + if (!ipv6_addr_any(addr) &&
10647 + ipv6_addr_equal(saddr, addr))
10649 + if (ipv6_addr_any(saddr))
10650 + return v6_addr_in_nx_info(nxi, addr, -1);
10655 + * check if address is covered by socket
10657 + * sk: the socket to check against
10658 + * addr: the address in question (must be != 0)
10662 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
10664 + struct nx_info *nxi = sk->sk_nx_info;
10665 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10667 + vxdprintk(VXD_CBIT(net, 5),
10668 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
10669 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
10670 + (sk->sk_socket?sk->sk_socket->flags:0));
10672 + if (!ipv6_addr_any(saddr)) { /* direct address match */
10673 + return v6_addr_match(nxa, saddr, -1);
10674 + } else if (nxi) { /* match against nx_info */
10675 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
10676 + } else { /* unrestricted any socket */
10682 +/* inet related checks and helpers */
10686 +struct net_device;
10690 +#include <linux/netdevice.h>
10691 +#include <linux/inetdevice.h>
10692 +#include <net/inet_timewait_sock.h>
10695 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10696 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
10697 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
10702 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
10708 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
10712 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
10714 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
10715 + nxi, nxi ? nxi->nx_id : 0, ifa,
10716 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
10718 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10720 + if (v6_ifa_in_nx_info(ifa, nxi))
10726 +struct nx_v6_sock_addr {
10727 + struct in6_addr saddr; /* Address used for validation */
10728 + struct in6_addr baddr; /* Address used for socket bind */
10732 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
10733 + struct nx_v6_sock_addr *nsa)
10735 + // struct sock *sk = &inet->sk;
10736 + // struct nx_info *nxi = sk->sk_nx_info;
10737 + struct in6_addr saddr = addr->sin6_addr;
10738 + struct in6_addr baddr = saddr;
10740 + nsa->saddr = saddr;
10741 + nsa->baddr = baddr;
10746 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10748 + // struct sock *sk = &inet->sk;
10749 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10751 + // *saddr = nsa->baddr;
10752 + // inet->inet_saddr = nsa->baddr;
10756 +int nx_info_has_v6(struct nx_info *nxi)
10760 + if (NX_IPV6(nxi))
10765 +#else /* CONFIG_IPV6 */
10768 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10775 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10781 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10787 +int nx_info_has_v6(struct nx_info *nxi)
10792 +#endif /* CONFIG_IPV6 */
10794 +#define current_nx_info_has_v6() \
10795 + nx_info_has_v6(current_nx_info())
10798 +#warning duplicate inclusion
10800 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_limit.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_limit.h
10801 --- linux-2.6.38.1/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
10802 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_limit.h 2011-01-29 04:59:22.000000000 +0100
10804 +#ifndef _VS_LIMIT_H
10805 +#define _VS_LIMIT_H
10807 +#include "vserver/limit.h"
10808 +#include "vserver/base.h"
10809 +#include "vserver/context.h"
10810 +#include "vserver/debug.h"
10811 +#include "vserver/context.h"
10812 +#include "vserver/limit_int.h"
10815 +#define vx_acc_cres(v, d, p, r) \
10816 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10818 +#define vx_acc_cres_cond(x, d, p, r) \
10819 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10820 + r, d, p, __FILE__, __LINE__)
10823 +#define vx_add_cres(v, a, p, r) \
10824 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10825 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10827 +#define vx_add_cres_cond(x, a, p, r) \
10828 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10829 + r, a, p, __FILE__, __LINE__)
10830 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10833 +/* process and file limits */
10835 +#define vx_nproc_inc(p) \
10836 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10838 +#define vx_nproc_dec(p) \
10839 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10841 +#define vx_files_inc(f) \
10842 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10844 +#define vx_files_dec(f) \
10845 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10847 +#define vx_locks_inc(l) \
10848 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10850 +#define vx_locks_dec(l) \
10851 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10853 +#define vx_openfd_inc(f) \
10854 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10856 +#define vx_openfd_dec(f) \
10857 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10860 +#define vx_cres_avail(v, n, r) \
10861 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10864 +#define vx_nproc_avail(n) \
10865 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10867 +#define vx_files_avail(n) \
10868 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10870 +#define vx_locks_avail(n) \
10871 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10873 +#define vx_openfd_avail(n) \
10874 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10877 +/* dentry limits */
10879 +#define vx_dentry_inc(d) do { \
10880 + if ((d)->d_count == 1) \
10881 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10884 +#define vx_dentry_dec(d) do { \
10885 + if ((d)->d_count == 0) \
10886 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10889 +#define vx_dentry_avail(n) \
10890 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10893 +/* socket limits */
10895 +#define vx_sock_inc(s) \
10896 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10898 +#define vx_sock_dec(s) \
10899 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10901 +#define vx_sock_avail(n) \
10902 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10905 +/* ipc resource limits */
10907 +#define vx_ipcmsg_add(v, u, a) \
10908 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10910 +#define vx_ipcmsg_sub(v, u, a) \
10911 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10913 +#define vx_ipcmsg_avail(v, a) \
10914 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10917 +#define vx_ipcshm_add(v, k, a) \
10918 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10920 +#define vx_ipcshm_sub(v, k, a) \
10921 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10923 +#define vx_ipcshm_avail(v, a) \
10924 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10927 +#define vx_semary_inc(a) \
10928 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10930 +#define vx_semary_dec(a) \
10931 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10934 +#define vx_nsems_add(a,n) \
10935 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10937 +#define vx_nsems_sub(a,n) \
10938 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10942 +#warning duplicate inclusion
10944 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_memory.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_memory.h
10945 --- linux-2.6.38.1/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
10946 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_memory.h 2011-01-29 02:01:07.000000000 +0100
10948 +#ifndef _VS_MEMORY_H
10949 +#define _VS_MEMORY_H
10951 +#include "vserver/limit.h"
10952 +#include "vserver/base.h"
10953 +#include "vserver/context.h"
10954 +#include "vserver/debug.h"
10955 +#include "vserver/context.h"
10956 +#include "vserver/limit_int.h"
10959 + VXPT_UNKNOWN = 0,
10968 +#define vx_page_fault(mm, vma, type, ret)
10972 +void __vx_page_fault(struct mm_struct *mm,
10973 + struct vm_area_struct *vma, int type, int ret)
10975 + struct vx_info *vxi = mm->mm_vx_info;
10978 + static char *page_type[6] =
10979 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
10980 + static char *page_what[4] =
10981 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
10987 + what = (ret & 0x3);
10989 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
10990 + type, what, ret, page_type[type], page_what[what]);
10992 + if (ret & VM_FAULT_WRITE)
10994 + atomic_inc(&vxi->cacct.page[type][what]);
10997 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
11001 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
11004 +#warning duplicate inclusion
11006 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_network.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_network.h
11007 --- linux-2.6.38.1/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
11008 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_network.h 2011-01-29 02:01:07.000000000 +0100
11010 +#ifndef _NX_VS_NETWORK_H
11011 +#define _NX_VS_NETWORK_H
11013 +#include "vserver/context.h"
11014 +#include "vserver/network.h"
11015 +#include "vserver/base.h"
11016 +#include "vserver/check.h"
11017 +#include "vserver/debug.h"
11019 +#include <linux/sched.h>
11022 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
11024 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
11025 + const char *_file, int _line)
11030 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
11031 + nxi, nxi ? nxi->nx_id : 0,
11032 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11035 + atomic_inc(&nxi->nx_usecnt);
11040 +extern void free_nx_info(struct nx_info *);
11042 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
11044 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
11049 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
11050 + nxi, nxi ? nxi->nx_id : 0,
11051 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11054 + if (atomic_dec_and_test(&nxi->nx_usecnt))
11055 + free_nx_info(nxi);
11059 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
11061 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
11062 + const char *_file, int _line)
11065 + vxlprintk(VXD_CBIT(nid, 3),
11066 + "init_nx_info(%p[#%d.%d])",
11067 + nxi, nxi ? nxi->nx_id : 0,
11068 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11071 + atomic_inc(&nxi->nx_usecnt);
11077 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
11079 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
11080 + const char *_file, int _line)
11082 + struct nx_info *nxo;
11087 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
11088 + nxi, nxi ? nxi->nx_id : 0,
11089 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11092 + atomic_inc(&nxi->nx_usecnt);
11093 + nxo = xchg(nxp, nxi);
11097 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
11099 +static inline void __clr_nx_info(struct nx_info **nxp,
11100 + const char *_file, int _line)
11102 + struct nx_info *nxo;
11104 + nxo = xchg(nxp, NULL);
11108 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
11109 + nxo, nxo ? nxo->nx_id : 0,
11110 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
11113 + if (atomic_dec_and_test(&nxo->nx_usecnt))
11114 + free_nx_info(nxo);
11118 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
11120 +static inline void __claim_nx_info(struct nx_info *nxi,
11121 + struct task_struct *task, const char *_file, int _line)
11123 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
11124 + nxi, nxi ? nxi->nx_id : 0,
11125 + nxi?atomic_read(&nxi->nx_usecnt):0,
11126 + nxi?atomic_read(&nxi->nx_tasks):0,
11127 + task, _file, _line);
11129 + atomic_inc(&nxi->nx_tasks);
11133 +extern void unhash_nx_info(struct nx_info *);
11135 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
11137 +static inline void __release_nx_info(struct nx_info *nxi,
11138 + struct task_struct *task, const char *_file, int _line)
11140 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
11141 + nxi, nxi ? nxi->nx_id : 0,
11142 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11143 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
11144 + task, _file, _line);
11148 + if (atomic_dec_and_test(&nxi->nx_tasks))
11149 + unhash_nx_info(nxi);
11153 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
11155 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
11156 + const char *_file, int _line)
11158 + struct nx_info *nxi;
11161 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
11162 + p, _file, _line);
11163 + nxi = __get_nx_info(p->nx_info, _file, _line);
11169 +static inline void exit_nx_info(struct task_struct *p)
11172 + release_nx_info(p->nx_info, p);
11177 +#warning duplicate inclusion
11179 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_pid.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_pid.h
11180 --- linux-2.6.38.1/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
11181 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_pid.h 2011-03-22 17:43:53.000000000 +0100
11186 +#include "vserver/base.h"
11187 +#include "vserver/check.h"
11188 +#include "vserver/context.h"
11189 +#include "vserver/debug.h"
11190 +#include "vserver/pid.h"
11191 +#include <linux/pid_namespace.h>
11194 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
11197 +int vx_proc_task_visible(struct task_struct *task)
11199 + if ((task->pid == 1) &&
11200 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
11201 + /* show a blend through init */
11203 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
11210 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
11214 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
11216 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
11218 + if (task && !vx_proc_task_visible(task)) {
11219 + vxdprintk(VXD_CBIT(misc, 6),
11220 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
11221 + task, task->xid, task->pid,
11222 + current, current->xid, current->pid);
11223 + put_task_struct(task);
11231 +#warning duplicate inclusion
11233 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_sched.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_sched.h
11234 --- linux-2.6.38.1/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
11235 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_sched.h 2011-01-29 02:01:07.000000000 +0100
11237 +#ifndef _VS_SCHED_H
11238 +#define _VS_SCHED_H
11240 +#include "vserver/base.h"
11241 +#include "vserver/context.h"
11242 +#include "vserver/sched.h"
11245 +#define MAX_PRIO_BIAS 20
11246 +#define MIN_PRIO_BIAS -20
11249 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
11251 + struct vx_info *vxi = p->vx_info;
11254 + prio += vx_cpu(vxi, sched_pc).prio_bias;
11258 +static inline void vx_account_user(struct vx_info *vxi,
11259 + cputime_t cputime, int nice)
11263 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
11266 +static inline void vx_account_system(struct vx_info *vxi,
11267 + cputime_t cputime, int idle)
11271 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
11275 +#warning duplicate inclusion
11277 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_socket.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_socket.h
11278 --- linux-2.6.38.1/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
11279 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_socket.h 2011-01-29 02:01:07.000000000 +0100
11281 +#ifndef _VS_SOCKET_H
11282 +#define _VS_SOCKET_H
11284 +#include "vserver/debug.h"
11285 +#include "vserver/base.h"
11286 +#include "vserver/cacct.h"
11287 +#include "vserver/context.h"
11288 +#include "vserver/tag.h"
11291 +/* socket accounting */
11293 +#include <linux/socket.h>
11295 +static inline int vx_sock_type(int family)
11297 + switch (family) {
11299 + return VXA_SOCK_UNSPEC;
11301 + return VXA_SOCK_UNIX;
11303 + return VXA_SOCK_INET;
11305 + return VXA_SOCK_INET6;
11307 + return VXA_SOCK_PACKET;
11309 + return VXA_SOCK_OTHER;
11313 +#define vx_acc_sock(v, f, p, s) \
11314 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
11316 +static inline void __vx_acc_sock(struct vx_info *vxi,
11317 + int family, int pos, int size, char *file, int line)
11320 + int type = vx_sock_type(family);
11322 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
11323 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
11327 +#define vx_sock_recv(sk, s) \
11328 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
11329 +#define vx_sock_send(sk, s) \
11330 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
11331 +#define vx_sock_fail(sk, s) \
11332 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
11335 +#define sock_vx_init(s) do { \
11336 + (s)->sk_xid = 0; \
11337 + (s)->sk_vx_info = NULL; \
11340 +#define sock_nx_init(s) do { \
11341 + (s)->sk_nid = 0; \
11342 + (s)->sk_nx_info = NULL; \
11346 +#warning duplicate inclusion
11348 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_tag.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_tag.h
11349 --- linux-2.6.38.1/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
11350 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_tag.h 2011-01-29 02:01:07.000000000 +0100
11355 +#include <linux/vserver/tag.h>
11357 +/* check conditions */
11359 +#define DX_ADMIN 0x0001
11360 +#define DX_WATCH 0x0002
11361 +#define DX_HOSTID 0x0008
11363 +#define DX_IDENT 0x0010
11365 +#define DX_ARG_MASK 0x0010
11368 +#define dx_task_tag(t) ((t)->tag)
11370 +#define dx_current_tag() dx_task_tag(current)
11372 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
11374 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
11378 + * check current context for ADMIN/WATCH and
11379 + * optionally against supplied argument
11381 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
11383 + if (mode & DX_ARG_MASK) {
11384 + if ((mode & DX_IDENT) && (id == cid))
11387 + return (((mode & DX_ADMIN) && (cid == 0)) ||
11388 + ((mode & DX_WATCH) && (cid == 1)) ||
11389 + ((mode & DX_HOSTID) && (id == 0)));
11393 +int dx_permission(const struct inode *inode, int mask);
11397 +#warning duplicate inclusion
11399 diff -NurpP --minimal linux-2.6.38.1/include/linux/vs_time.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_time.h
11400 --- linux-2.6.38.1/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
11401 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vs_time.h 2011-01-29 02:01:07.000000000 +0100
11403 +#ifndef _VS_TIME_H
11404 +#define _VS_TIME_H
11407 +/* time faking stuff */
11409 +#ifdef CONFIG_VSERVER_VTIME
11411 +extern void vx_adjust_timespec(struct timespec *ts);
11412 +extern int vx_settimeofday(struct timespec *ts);
11415 +#define vx_adjust_timespec(t) do { } while (0)
11416 +#define vx_settimeofday(t) do_settimeofday(t)
11420 +#warning duplicate inclusion
11422 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/Kbuild linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/Kbuild
11423 --- linux-2.6.38.1/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11424 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/Kbuild 2011-01-29 02:01:07.000000000 +0100
11427 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11428 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11429 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11430 + debug_cmd.h device_cmd.h
11432 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11434 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/base.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/base.h
11435 --- linux-2.6.38.1/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
11436 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/base.h 2011-01-29 02:01:07.000000000 +0100
11438 +#ifndef _VX_BASE_H
11439 +#define _VX_BASE_H
11442 +/* context state changes */
11454 +#define vx_task_xid(t) ((t)->xid)
11456 +#define vx_current_xid() vx_task_xid(current)
11458 +#define current_vx_info() (current->vx_info)
11461 +#define nx_task_nid(t) ((t)->nid)
11463 +#define nx_current_nid() nx_task_nid(current)
11465 +#define current_nx_info() (current->nx_info)
11468 +/* generic flag merging */
11470 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
11472 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11474 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
11476 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
11479 +/* context flags */
11481 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
11483 +#define vx_current_flags() __vx_flags(current_vx_info())
11485 +#define vx_info_flags(v, m, f) \
11486 + vs_check_flags(__vx_flags(v), m, f)
11488 +#define task_vx_flags(t, m, f) \
11489 + ((t) && vx_info_flags((t)->vx_info, m, f))
11491 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11494 +/* context caps */
11496 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
11498 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
11500 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
11502 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
11506 +/* network flags */
11508 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
11510 +#define nx_current_flags() __nx_flags(current_nx_info())
11512 +#define nx_info_flags(n, m, f) \
11513 + vs_check_flags(__nx_flags(n), m, f)
11515 +#define task_nx_flags(t, m, f) \
11516 + ((t) && nx_info_flags((t)->nx_info, m, f))
11518 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11521 +/* network caps */
11523 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
11525 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
11527 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
11529 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
11532 +/* context mask capabilities */
11534 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11536 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
11538 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
11541 +/* context bcap mask */
11543 +#define __vx_bcaps(v) ((v)->vx_bcaps)
11545 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
11548 +/* mask given bcaps */
11550 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11552 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
11555 +/* masked cap_bset */
11557 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
11559 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
11562 +#define vx_info_mbcap(v, b) \
11563 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11564 + vx_info_bcaps(v, b) : (b))
11566 +#define task_vx_mbcap(t, b) \
11567 + vx_info_mbcap((t)->vx_info, (t)->b)
11569 +#define vx_mbcap(b) task_vx_mbcap(current, b)
11572 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11574 +#define vx_capable(b, c) (capable(b) || \
11575 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
11577 +#define nx_capable(b, c) (capable(b) || \
11578 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
11580 +#define vx_task_initpid(t, n) \
11581 + ((t)->vx_info && \
11582 + ((t)->vx_info->vx_initpid == (n)))
11584 +#define vx_current_initpid(n) vx_task_initpid(current, n)
11587 +/* context unshare mask */
11589 +#define __vx_umask(v) ((v)->vx_umask)
11591 +#define vx_current_umask() __vx_umask(current_vx_info())
11593 +#define vx_can_unshare(b, f) (capable(b) || \
11594 + (cap_raised(current_cap(), b) && \
11595 + !((f) & ~vx_current_umask())))
11598 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
11600 +#define vx_info_state(v, m) (__vx_state(v) & (m))
11603 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
11605 +#define nx_info_state(n, m) (__nx_state(n) & (m))
11608 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/cacct.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cacct.h
11609 --- linux-2.6.38.1/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
11610 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cacct.h 2011-01-29 02:01:07.000000000 +0100
11612 +#ifndef _VX_CACCT_H
11613 +#define _VX_CACCT_H
11616 +enum sock_acc_field {
11617 + VXA_SOCK_UNSPEC = 0,
11623 + VXA_SOCK_SIZE /* array size */
11626 +#endif /* _VX_CACCT_H */
11627 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/cacct_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cacct_cmd.h
11628 --- linux-2.6.38.1/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
11629 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cacct_cmd.h 2011-01-29 02:01:07.000000000 +0100
11631 +#ifndef _VX_CACCT_CMD_H
11632 +#define _VX_CACCT_CMD_H
11635 +/* virtual host info name commands */
11637 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
11639 +struct vcmd_sock_stat_v0 {
11641 + uint32_t count[3];
11642 + uint64_t total[3];
11648 +#include <linux/compiler.h>
11650 +extern int vc_sock_stat(struct vx_info *, void __user *);
11652 +#endif /* __KERNEL__ */
11653 +#endif /* _VX_CACCT_CMD_H */
11654 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/cacct_def.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cacct_def.h
11655 --- linux-2.6.38.1/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
11656 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cacct_def.h 2011-01-29 02:01:07.000000000 +0100
11658 +#ifndef _VX_CACCT_DEF_H
11659 +#define _VX_CACCT_DEF_H
11661 +#include <asm/atomic.h>
11662 +#include <linux/vserver/cacct.h>
11665 +struct _vx_sock_acc {
11666 + atomic_long_t count;
11667 + atomic_long_t total;
11670 +/* context sub struct */
11672 +struct _vx_cacct {
11673 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11674 + atomic_t slab[8];
11675 + atomic_t page[6][8];
11678 +#ifdef CONFIG_VSERVER_DEBUG
11680 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11684 + printk("\t_vx_cacct:");
11685 + for (i = 0; i < 6; i++) {
11686 + struct _vx_sock_acc *ptr = cacct->sock[i];
11688 + printk("\t [%d] =", i);
11689 + for (j = 0; j < 3; j++) {
11690 + printk(" [%d] = %8lu, %8lu", j,
11691 + atomic_long_read(&ptr[j].count),
11692 + atomic_long_read(&ptr[j].total));
11700 +#endif /* _VX_CACCT_DEF_H */
11701 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/cacct_int.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cacct_int.h
11702 --- linux-2.6.38.1/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
11703 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cacct_int.h 2011-01-29 02:01:07.000000000 +0100
11705 +#ifndef _VX_CACCT_INT_H
11706 +#define _VX_CACCT_INT_H
11712 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11714 + return atomic_long_read(&cacct->sock[type][pos].count);
11719 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11721 + return atomic_long_read(&cacct->sock[type][pos].total);
11724 +#endif /* __KERNEL__ */
11725 +#endif /* _VX_CACCT_INT_H */
11726 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/check.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/check.h
11727 --- linux-2.6.38.1/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
11728 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/check.h 2011-01-29 02:01:07.000000000 +0100
11730 +#ifndef _VS_CHECK_H
11731 +#define _VS_CHECK_H
11734 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
11736 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11737 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
11739 +#define MIN_D_CONTEXT 65536
11742 +/* check conditions */
11744 +#define VS_ADMIN 0x0001
11745 +#define VS_WATCH 0x0002
11746 +#define VS_HIDE 0x0004
11747 +#define VS_HOSTID 0x0008
11749 +#define VS_IDENT 0x0010
11750 +#define VS_EQUIV 0x0020
11751 +#define VS_PARENT 0x0040
11752 +#define VS_CHILD 0x0080
11754 +#define VS_ARG_MASK 0x00F0
11756 +#define VS_DYNAMIC 0x0100
11757 +#define VS_STATIC 0x0200
11759 +#define VS_ATR_MASK 0x0F00
11761 +#ifdef CONFIG_VSERVER_PRIVACY
11762 +#define VS_ADMIN_P (0)
11763 +#define VS_WATCH_P (0)
11765 +#define VS_ADMIN_P VS_ADMIN
11766 +#define VS_WATCH_P VS_WATCH
11769 +#define VS_HARDIRQ 0x1000
11770 +#define VS_SOFTIRQ 0x2000
11771 +#define VS_IRQ 0x4000
11773 +#define VS_IRQ_MASK 0xF000
11775 +#include <linux/hardirq.h>
11778 + * check current context for ADMIN/WATCH and
11779 + * optionally against supplied argument
11781 +static inline int __vs_check(int cid, int id, unsigned int mode)
11783 + if (mode & VS_ARG_MASK) {
11784 + if ((mode & VS_IDENT) && (id == cid))
11787 + if (mode & VS_ATR_MASK) {
11788 + if ((mode & VS_DYNAMIC) &&
11789 + (id >= MIN_D_CONTEXT) &&
11790 + (id <= MAX_S_CONTEXT))
11792 + if ((mode & VS_STATIC) &&
11793 + (id > 1) && (id < MIN_D_CONTEXT))
11796 + if (mode & VS_IRQ_MASK) {
11797 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11799 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11801 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11804 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11805 + ((mode & VS_WATCH) && (cid == 1)) ||
11806 + ((mode & VS_HOSTID) && (id == 0)));
11809 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11811 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11814 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11816 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11819 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/context.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/context.h
11820 --- linux-2.6.38.1/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
11821 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/context.h 2011-01-31 22:46:21.000000000 +0100
11823 +#ifndef _VX_CONTEXT_H
11824 +#define _VX_CONTEXT_H
11826 +#include <linux/types.h>
11827 +#include <linux/capability.h>
11830 +/* context flags */
11832 +#define VXF_INFO_SCHED 0x00000002
11833 +#define VXF_INFO_NPROC 0x00000004
11834 +#define VXF_INFO_PRIVATE 0x00000008
11836 +#define VXF_INFO_INIT 0x00000010
11837 +#define VXF_INFO_HIDE 0x00000020
11838 +#define VXF_INFO_ULIMIT 0x00000040
11839 +#define VXF_INFO_NSPACE 0x00000080
11841 +#define VXF_SCHED_HARD 0x00000100
11842 +#define VXF_SCHED_PRIO 0x00000200
11843 +#define VXF_SCHED_PAUSE 0x00000400
11845 +#define VXF_VIRT_MEM 0x00010000
11846 +#define VXF_VIRT_UPTIME 0x00020000
11847 +#define VXF_VIRT_CPU 0x00040000
11848 +#define VXF_VIRT_LOAD 0x00080000
11849 +#define VXF_VIRT_TIME 0x00100000
11851 +#define VXF_HIDE_MOUNT 0x01000000
11852 +/* was VXF_HIDE_NETIF 0x02000000 */
11853 +#define VXF_HIDE_VINFO 0x04000000
11855 +#define VXF_STATE_SETUP (1ULL << 32)
11856 +#define VXF_STATE_INIT (1ULL << 33)
11857 +#define VXF_STATE_ADMIN (1ULL << 34)
11859 +#define VXF_SC_HELPER (1ULL << 36)
11860 +#define VXF_REBOOT_KILL (1ULL << 37)
11861 +#define VXF_PERSISTENT (1ULL << 38)
11863 +#define VXF_FORK_RSS (1ULL << 48)
11864 +#define VXF_PROLIFIC (1ULL << 49)
11866 +#define VXF_IGNEG_NICE (1ULL << 52)
11868 +#define VXF_ONE_TIME (0x0007ULL << 32)
11870 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11873 +/* context migration */
11875 +#define VXM_SET_INIT 0x00000001
11876 +#define VXM_SET_REAPER 0x00000002
11878 +/* context caps */
11880 +#define VXC_CAP_MASK 0x00000000
11882 +#define VXC_SET_UTSNAME 0x00000001
11883 +#define VXC_SET_RLIMIT 0x00000002
11884 +#define VXC_FS_SECURITY 0x00000004
11885 +#define VXC_FS_TRUSTED 0x00000008
11886 +#define VXC_TIOCSTI 0x00000010
11888 +/* was VXC_RAW_ICMP 0x00000100 */
11889 +#define VXC_SYSLOG 0x00001000
11890 +#define VXC_OOM_ADJUST 0x00002000
11891 +#define VXC_AUDIT_CONTROL 0x00004000
11893 +#define VXC_SECURE_MOUNT 0x00010000
11894 +#define VXC_SECURE_REMOUNT 0x00020000
11895 +#define VXC_BINARY_MOUNT 0x00040000
11897 +#define VXC_QUOTA_CTL 0x00100000
11898 +#define VXC_ADMIN_MAPPER 0x00200000
11899 +#define VXC_ADMIN_CLOOP 0x00400000
11901 +#define VXC_KTHREAD 0x01000000
11902 +#define VXC_NAMESPACE 0x02000000
11907 +#include <linux/list.h>
11908 +#include <linux/spinlock.h>
11909 +#include <linux/rcupdate.h>
11911 +#include "limit_def.h"
11912 +#include "sched_def.h"
11913 +#include "cvirt_def.h"
11914 +#include "cacct_def.h"
11915 +#include "device_def.h"
11917 +#define VX_SPACES 2
11919 +struct _vx_info_pc {
11920 + struct _vx_sched_pc sched_pc;
11921 + struct _vx_cvirt_pc cvirt_pc;
11924 +struct _vx_space {
11925 + unsigned long vx_nsmask; /* assignment mask */
11926 + struct nsproxy *vx_nsproxy; /* private namespaces */
11927 + struct fs_struct *vx_fs; /* private namespace fs */
11928 + const struct cred *vx_cred; /* task credentials */
11932 + struct hlist_node vx_hlist; /* linked list of contexts */
11933 + xid_t vx_id; /* context id */
11934 + atomic_t vx_usecnt; /* usage count */
11935 + atomic_t vx_tasks; /* tasks count */
11936 + struct vx_info *vx_parent; /* parent context */
11937 + int vx_state; /* context state */
11939 + struct _vx_space space[VX_SPACES]; /* namespace store */
11941 + uint64_t vx_flags; /* context flags */
11942 + uint64_t vx_ccaps; /* context caps (vserver) */
11943 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11944 + unsigned long vx_umask; /* unshare mask (guest) */
11946 + struct task_struct *vx_reaper; /* guest reaper process */
11947 + pid_t vx_initpid; /* PID of guest init */
11948 + int64_t vx_badness_bias; /* OOM points bias */
11950 + struct _vx_limit limit; /* vserver limits */
11951 + struct _vx_sched sched; /* vserver scheduler */
11952 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11953 + struct _vx_cacct cacct; /* context accounting */
11955 + struct _vx_device dmap; /* default device map targets */
11957 +#ifndef CONFIG_SMP
11958 + struct _vx_info_pc info_pc; /* per cpu data */
11960 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11963 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11964 + int reboot_cmd; /* last sys_reboot() cmd */
11965 + int exit_code; /* last process exit code */
11967 + char vx_name[65]; /* vserver name */
11970 +#ifndef CONFIG_SMP
11971 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11972 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11974 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11975 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11978 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11981 +struct vx_info_save {
11982 + struct vx_info *vxi;
11987 +/* status flags */
11989 +#define VXS_HASHED 0x0001
11990 +#define VXS_PAUSED 0x0010
11991 +#define VXS_SHUTDOWN 0x0100
11992 +#define VXS_HELPER 0x1000
11993 +#define VXS_RELEASED 0x8000
11996 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11997 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11999 +extern struct vx_info *lookup_vx_info(int);
12000 +extern struct vx_info *lookup_or_create_vx_info(int);
12002 +extern int get_xid_list(int, unsigned int *, int);
12003 +extern int xid_is_hashed(xid_t);
12005 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
12007 +extern long vs_state_change(struct vx_info *, unsigned int);
12010 +#endif /* __KERNEL__ */
12011 +#endif /* _VX_CONTEXT_H */
12012 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/context_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/context_cmd.h
12013 --- linux-2.6.38.1/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
12014 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/context_cmd.h 2011-01-29 02:01:07.000000000 +0100
12016 +#ifndef _VX_CONTEXT_CMD_H
12017 +#define _VX_CONTEXT_CMD_H
12020 +/* vinfo commands */
12022 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
12025 +extern int vc_task_xid(uint32_t);
12027 +#endif /* __KERNEL__ */
12029 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
12031 +struct vcmd_vx_info_v0 {
12033 + uint32_t initpid;
12034 + /* more to come */
12038 +extern int vc_vx_info(struct vx_info *, void __user *);
12040 +#endif /* __KERNEL__ */
12042 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
12044 +struct vcmd_ctx_stat_v0 {
12047 + /* more to come */
12051 +extern int vc_ctx_stat(struct vx_info *, void __user *);
12053 +#endif /* __KERNEL__ */
12055 +/* context commands */
12057 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
12058 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
12060 +struct vcmd_ctx_create {
12061 + uint64_t flagword;
12064 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
12065 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
12067 +struct vcmd_ctx_migrate {
12068 + uint64_t flagword;
12072 +extern int vc_ctx_create(uint32_t, void __user *);
12073 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
12075 +#endif /* __KERNEL__ */
12078 +/* flag commands */
12080 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
12081 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
12083 +struct vcmd_ctx_flags_v0 {
12084 + uint64_t flagword;
12089 +extern int vc_get_cflags(struct vx_info *, void __user *);
12090 +extern int vc_set_cflags(struct vx_info *, void __user *);
12092 +#endif /* __KERNEL__ */
12095 +/* context caps commands */
12097 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
12098 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
12100 +struct vcmd_ctx_caps_v1 {
12106 +extern int vc_get_ccaps(struct vx_info *, void __user *);
12107 +extern int vc_set_ccaps(struct vx_info *, void __user *);
12109 +#endif /* __KERNEL__ */
12112 +/* bcaps commands */
12114 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
12115 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
12117 +struct vcmd_bcaps {
12123 +extern int vc_get_bcaps(struct vx_info *, void __user *);
12124 +extern int vc_set_bcaps(struct vx_info *, void __user *);
12126 +#endif /* __KERNEL__ */
12129 +/* umask commands */
12131 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
12132 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
12134 +struct vcmd_umask {
12140 +extern int vc_get_umask(struct vx_info *, void __user *);
12141 +extern int vc_set_umask(struct vx_info *, void __user *);
12143 +#endif /* __KERNEL__ */
12148 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
12149 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
12151 +struct vcmd_badness_v0 {
12156 +extern int vc_get_badness(struct vx_info *, void __user *);
12157 +extern int vc_set_badness(struct vx_info *, void __user *);
12159 +#endif /* __KERNEL__ */
12160 +#endif /* _VX_CONTEXT_CMD_H */
12161 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/cvirt.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cvirt.h
12162 --- linux-2.6.38.1/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
12163 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cvirt.h 2011-01-29 02:01:07.000000000 +0100
12165 +#ifndef _VX_CVIRT_H
12166 +#define _VX_CVIRT_H
12173 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12178 +void vx_update_load(struct vx_info *);
12181 +int vx_do_syslog(int, char __user *, int);
12183 +#endif /* __KERNEL__ */
12184 +#endif /* _VX_CVIRT_H */
12185 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/cvirt_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cvirt_cmd.h
12186 --- linux-2.6.38.1/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
12187 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cvirt_cmd.h 2011-01-29 02:01:07.000000000 +0100
12189 +#ifndef _VX_CVIRT_CMD_H
12190 +#define _VX_CVIRT_CMD_H
12193 +/* virtual host info name commands */
12195 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
12196 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
12198 +struct vcmd_vhi_name_v0 {
12204 +enum vhi_name_field {
12205 + VHIN_CONTEXT = 0,
12217 +#include <linux/compiler.h>
12219 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
12220 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
12222 +#endif /* __KERNEL__ */
12224 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
12226 +struct vcmd_virt_stat_v0 {
12229 + uint32_t nr_threads;
12230 + uint32_t nr_running;
12231 + uint32_t nr_uninterruptible;
12232 + uint32_t nr_onhold;
12233 + uint32_t nr_forks;
12234 + uint32_t load[3];
12238 +extern int vc_virt_stat(struct vx_info *, void __user *);
12240 +#endif /* __KERNEL__ */
12241 +#endif /* _VX_CVIRT_CMD_H */
12242 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/cvirt_def.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cvirt_def.h
12243 --- linux-2.6.38.1/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
12244 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/cvirt_def.h 2011-01-29 02:01:07.000000000 +0100
12246 +#ifndef _VX_CVIRT_DEF_H
12247 +#define _VX_CVIRT_DEF_H
12249 +#include <linux/jiffies.h>
12250 +#include <linux/spinlock.h>
12251 +#include <linux/wait.h>
12252 +#include <linux/time.h>
12253 +#include <asm/atomic.h>
12256 +struct _vx_usage_stat {
12260 + uint64_t softirq;
12266 +struct _vx_syslog {
12267 + wait_queue_head_t log_wait;
12268 + spinlock_t logbuf_lock; /* lock for the log buffer */
12270 + unsigned long log_start; /* next char to be read by syslog() */
12271 + unsigned long con_start; /* next char to be sent to consoles */
12272 + unsigned long log_end; /* most-recently-written-char + 1 */
12273 + unsigned long logged_chars; /* #chars since last read+clear operation */
12275 + char log_buf[1024];
12279 +/* context sub struct */
12281 +struct _vx_cvirt {
12282 + atomic_t nr_threads; /* number of current threads */
12283 + atomic_t nr_running; /* number of running threads */
12284 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
12286 + atomic_t nr_onhold; /* processes on hold */
12287 + uint32_t onhold_last; /* jiffies when put on hold */
12289 + struct timespec bias_ts; /* time offset to the host */
12290 + struct timespec bias_idle;
12291 + struct timespec bias_uptime; /* context creation point */
12292 + uint64_t bias_clock; /* offset in clock_t */
12294 + spinlock_t load_lock; /* lock for the load averages */
12295 + atomic_t load_updates; /* nr of load updates done so far */
12296 + uint32_t load_last; /* last time load was calculated */
12297 + uint32_t load[3]; /* load averages 1,5,15 */
12299 + atomic_t total_forks; /* number of forks so far */
12301 + struct _vx_syslog syslog;
12304 +struct _vx_cvirt_pc {
12305 + struct _vx_usage_stat cpustat;
12309 +#ifdef CONFIG_VSERVER_DEBUG
12311 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
12313 + printk("\t_vx_cvirt:\n");
12314 + printk("\t threads: %4d, %4d, %4d, %4d\n",
12315 + atomic_read(&cvirt->nr_threads),
12316 + atomic_read(&cvirt->nr_running),
12317 + atomic_read(&cvirt->nr_uninterruptible),
12318 + atomic_read(&cvirt->nr_onhold));
12319 + /* add rest here */
12320 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
12325 +#endif /* _VX_CVIRT_DEF_H */
12326 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/debug.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/debug.h
12327 --- linux-2.6.38.1/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
12328 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/debug.h 2011-01-29 02:01:07.000000000 +0100
12330 +#ifndef _VX_DEBUG_H
12331 +#define _VX_DEBUG_H
12334 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
12335 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
12336 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
12338 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
12339 + imajor((d)->bd_inode), iminor((d)->bd_inode)
12340 +#define VXF_DEV "%p[%lu,%d:%d]"
12342 +#if defined(CONFIG_QUOTES_UTF8)
12343 +#define VS_Q_LQM "\xc2\xbb"
12344 +#define VS_Q_RQM "\xc2\xab"
12345 +#elif defined(CONFIG_QUOTES_ASCII)
12346 +#define VS_Q_LQM "\x27"
12347 +#define VS_Q_RQM "\x27"
12349 +#define VS_Q_LQM "\xbb"
12350 +#define VS_Q_RQM "\xab"
12353 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
12356 +#define vxd_path(p) \
12357 + ({ static char _buffer[PATH_MAX]; \
12358 + d_path(p, _buffer, sizeof(_buffer)); })
12360 +#define vxd_cond_path(n) \
12361 + ((n) ? vxd_path(&(n)->path) : "<null>" )
12364 +#ifdef CONFIG_VSERVER_DEBUG
12366 +extern unsigned int vx_debug_switch;
12367 +extern unsigned int vx_debug_xid;
12368 +extern unsigned int vx_debug_nid;
12369 +extern unsigned int vx_debug_tag;
12370 +extern unsigned int vx_debug_net;
12371 +extern unsigned int vx_debug_limit;
12372 +extern unsigned int vx_debug_cres;
12373 +extern unsigned int vx_debug_dlim;
12374 +extern unsigned int vx_debug_quota;
12375 +extern unsigned int vx_debug_cvirt;
12376 +extern unsigned int vx_debug_space;
12377 +extern unsigned int vx_debug_misc;
12380 +#define VX_LOGLEVEL "vxD: "
12381 +#define VX_PROC_FMT "%p: "
12382 +#define VX_PROCESS current
12384 +#define vxdprintk(c, f, x...) \
12387 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
12388 + VX_PROCESS , ##x); \
12391 +#define vxlprintk(c, f, x...) \
12394 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
12397 +#define vxfprintk(c, f, x...) \
12400 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
12406 +void dump_vx_info(struct vx_info *, int);
12407 +void dump_vx_info_inactive(int);
12409 +#else /* CONFIG_VSERVER_DEBUG */
12411 +#define vx_debug_switch 0
12412 +#define vx_debug_xid 0
12413 +#define vx_debug_nid 0
12414 +#define vx_debug_tag 0
12415 +#define vx_debug_net 0
12416 +#define vx_debug_limit 0
12417 +#define vx_debug_cres 0
12418 +#define vx_debug_dlim 0
12419 +#define vx_debug_cvirt 0
12421 +#define vxdprintk(x...) do { } while (0)
12422 +#define vxlprintk(x...) do { } while (0)
12423 +#define vxfprintk(x...) do { } while (0)
12425 +#endif /* CONFIG_VSERVER_DEBUG */
12428 +#ifdef CONFIG_VSERVER_WARN
12430 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
12431 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
12432 +#define VX_WARN_XID "[xid #%u] "
12433 +#define VX_WARN_NID "[nid #%u] "
12434 +#define VX_WARN_TAG "[tag #%u] "
12436 +#define vxwprintk(c, f, x...) \
12439 + printk(VX_WARNLEVEL f "\n", ##x); \
12442 +#else /* CONFIG_VSERVER_WARN */
12444 +#define vxwprintk(x...) do { } while (0)
12446 +#endif /* CONFIG_VSERVER_WARN */
12448 +#define vxwprintk_task(c, f, x...) \
12449 + vxwprintk(c, VX_WARN_TASK f, \
12450 + current->comm, current->pid, \
12451 + current->xid, current->nid, current->tag, ##x)
12452 +#define vxwprintk_xid(c, f, x...) \
12453 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
12454 +#define vxwprintk_nid(c, f, x...) \
12455 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
12456 +#define vxwprintk_tag(c, f, x...) \
12457 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12459 +#ifdef CONFIG_VSERVER_DEBUG
12460 +#define vxd_assert_lock(l) assert_spin_locked(l)
12461 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12462 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12464 +#define vxd_assert_lock(l) do { } while (0)
12465 +#define vxd_assert(c, f, x...) do { } while (0)
12469 +#endif /* _VX_DEBUG_H */
12470 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/debug_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/debug_cmd.h
12471 --- linux-2.6.38.1/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
12472 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/debug_cmd.h 2011-01-29 02:01:07.000000000 +0100
12474 +#ifndef _VX_DEBUG_CMD_H
12475 +#define _VX_DEBUG_CMD_H
12478 +/* debug commands */
12480 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
12482 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
12483 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
12485 +struct vcmd_read_history_v0 {
12488 + char __user *data;
12491 +struct vcmd_read_monitor_v0 {
12494 + char __user *data;
12500 +#ifdef CONFIG_COMPAT
12502 +#include <asm/compat.h>
12504 +struct vcmd_read_history_v0_x32 {
12507 + compat_uptr_t data_ptr;
12510 +struct vcmd_read_monitor_v0_x32 {
12513 + compat_uptr_t data_ptr;
12516 +#endif /* CONFIG_COMPAT */
12518 +extern int vc_dump_history(uint32_t);
12520 +extern int vc_read_history(uint32_t, void __user *);
12521 +extern int vc_read_monitor(uint32_t, void __user *);
12523 +#ifdef CONFIG_COMPAT
12525 +extern int vc_read_history_x32(uint32_t, void __user *);
12526 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12528 +#endif /* CONFIG_COMPAT */
12530 +#endif /* __KERNEL__ */
12531 +#endif /* _VX_DEBUG_CMD_H */
12532 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/device.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/device.h
12533 --- linux-2.6.38.1/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
12534 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/device.h 2011-01-29 02:01:07.000000000 +0100
12536 +#ifndef _VX_DEVICE_H
12537 +#define _VX_DEVICE_H
12540 +#define DATTR_CREATE 0x00000001
12541 +#define DATTR_OPEN 0x00000002
12543 +#define DATTR_REMAP 0x00000010
12545 +#define DATTR_MASK 0x00000013
12548 +#else /* _VX_DEVICE_H */
12549 +#warning duplicate inclusion
12550 +#endif /* _VX_DEVICE_H */
12551 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/device_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/device_cmd.h
12552 --- linux-2.6.38.1/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
12553 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/device_cmd.h 2011-01-29 02:01:07.000000000 +0100
12555 +#ifndef _VX_DEVICE_CMD_H
12556 +#define _VX_DEVICE_CMD_H
12559 +/* device vserver commands */
12561 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
12562 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
12564 +struct vcmd_set_mapping_v0 {
12565 + const char __user *device;
12566 + const char __user *target;
12573 +#ifdef CONFIG_COMPAT
12575 +#include <asm/compat.h>
12577 +struct vcmd_set_mapping_v0_x32 {
12578 + compat_uptr_t device_ptr;
12579 + compat_uptr_t target_ptr;
12583 +#endif /* CONFIG_COMPAT */
12585 +#include <linux/compiler.h>
12587 +extern int vc_set_mapping(struct vx_info *, void __user *);
12588 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12590 +#ifdef CONFIG_COMPAT
12592 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12593 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12595 +#endif /* CONFIG_COMPAT */
12597 +#endif /* __KERNEL__ */
12598 +#endif /* _VX_DEVICE_CMD_H */
12599 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/device_def.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/device_def.h
12600 --- linux-2.6.38.1/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
12601 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/device_def.h 2011-01-29 02:01:07.000000000 +0100
12603 +#ifndef _VX_DEVICE_DEF_H
12604 +#define _VX_DEVICE_DEF_H
12606 +#include <linux/types.h>
12608 +struct vx_dmap_target {
12613 +struct _vx_device {
12614 +#ifdef CONFIG_VSERVER_DEVICE
12615 + struct vx_dmap_target targets[2];
12619 +#endif /* _VX_DEVICE_DEF_H */
12620 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/dlimit.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/dlimit.h
12621 --- linux-2.6.38.1/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
12622 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/dlimit.h 2011-01-29 02:01:07.000000000 +0100
12624 +#ifndef _VX_DLIMIT_H
12625 +#define _VX_DLIMIT_H
12627 +#include "switch.h"
12632 +/* keep in sync with CDLIM_INFINITY */
12634 +#define DLIM_INFINITY (~0ULL)
12636 +#include <linux/spinlock.h>
12637 +#include <linux/rcupdate.h>
12639 +struct super_block;
12642 + struct hlist_node dl_hlist; /* linked list of contexts */
12643 + struct rcu_head dl_rcu; /* the rcu head */
12644 + tag_t dl_tag; /* context tag */
12645 + atomic_t dl_usecnt; /* usage count */
12646 + atomic_t dl_refcnt; /* reference count */
12648 + struct super_block *dl_sb; /* associated superblock */
12650 + spinlock_t dl_lock; /* protect the values */
12652 + unsigned long long dl_space_used; /* used space in bytes */
12653 + unsigned long long dl_space_total; /* maximum space in bytes */
12654 + unsigned long dl_inodes_used; /* used inodes */
12655 + unsigned long dl_inodes_total; /* maximum inodes */
12657 + unsigned int dl_nrlmult; /* non root limit mult */
12662 +extern void rcu_free_dl_info(struct rcu_head *);
12663 +extern void unhash_dl_info(struct dl_info *);
12665 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12670 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12672 +typedef uint64_t dlsize_t;
12674 +#endif /* __KERNEL__ */
12675 +#else /* _VX_DLIMIT_H */
12676 +#warning duplicate inclusion
12677 +#endif /* _VX_DLIMIT_H */
12678 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/dlimit_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/dlimit_cmd.h
12679 --- linux-2.6.38.1/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12680 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/dlimit_cmd.h 2011-01-29 02:01:07.000000000 +0100
12682 +#ifndef _VX_DLIMIT_CMD_H
12683 +#define _VX_DLIMIT_CMD_H
12686 +/* dlimit vserver commands */
12688 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12689 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12691 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12692 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12694 +struct vcmd_ctx_dlimit_base_v0 {
12695 + const char __user *name;
12699 +struct vcmd_ctx_dlimit_v0 {
12700 + const char __user *name;
12701 + uint32_t space_used; /* used space in kbytes */
12702 + uint32_t space_total; /* maximum space in kbytes */
12703 + uint32_t inodes_used; /* used inodes */
12704 + uint32_t inodes_total; /* maximum inodes */
12705 + uint32_t reserved; /* reserved for root in % */
12709 +#define CDLIM_UNSET ((uint32_t)0UL)
12710 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12711 +#define CDLIM_KEEP ((uint32_t)~1UL)
12713 +#define DLIME_UNIT 0
12714 +#define DLIME_KILO 1
12715 +#define DLIME_MEGA 2
12716 +#define DLIME_GIGA 3
12718 +#define DLIMF_SHIFT 0x10
12720 +#define DLIMS_USED 0
12721 +#define DLIMS_TOTAL 2
12724 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12726 + int exp = (flags & DLIMF_SHIFT) ?
12727 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12728 + return ((uint64_t)val) << (10 * exp);
12732 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12736 + if (*flags & DLIMF_SHIFT) {
12737 + while (val > (1LL << 32) && (exp < 3)) {
12741 + *flags &= ~(DLIME_GIGA << shift);
12742 + *flags |= exp << shift;
12750 +#ifdef CONFIG_COMPAT
12752 +#include <asm/compat.h>
12754 +struct vcmd_ctx_dlimit_base_v0_x32 {
12755 + compat_uptr_t name_ptr;
12759 +struct vcmd_ctx_dlimit_v0_x32 {
12760 + compat_uptr_t name_ptr;
12761 + uint32_t space_used; /* used space in kbytes */
12762 + uint32_t space_total; /* maximum space in kbytes */
12763 + uint32_t inodes_used; /* used inodes */
12764 + uint32_t inodes_total; /* maximum inodes */
12765 + uint32_t reserved; /* reserved for root in % */
12769 +#endif /* CONFIG_COMPAT */
12771 +#include <linux/compiler.h>
12773 +extern int vc_add_dlimit(uint32_t, void __user *);
12774 +extern int vc_rem_dlimit(uint32_t, void __user *);
12776 +extern int vc_set_dlimit(uint32_t, void __user *);
12777 +extern int vc_get_dlimit(uint32_t, void __user *);
12779 +#ifdef CONFIG_COMPAT
12781 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12782 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12784 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12785 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12787 +#endif /* CONFIG_COMPAT */
12789 +#endif /* __KERNEL__ */
12790 +#endif /* _VX_DLIMIT_CMD_H */
12791 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/global.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/global.h
12792 --- linux-2.6.38.1/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12793 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/global.h 2011-01-29 02:01:07.000000000 +0100
12795 +#ifndef _VX_GLOBAL_H
12796 +#define _VX_GLOBAL_H
12799 +extern atomic_t vx_global_ctotal;
12800 +extern atomic_t vx_global_cactive;
12802 +extern atomic_t nx_global_ctotal;
12803 +extern atomic_t nx_global_cactive;
12805 +extern atomic_t vs_global_nsproxy;
12806 +extern atomic_t vs_global_fs;
12807 +extern atomic_t vs_global_mnt_ns;
12808 +extern atomic_t vs_global_uts_ns;
12809 +extern atomic_t vs_global_user_ns;
12810 +extern atomic_t vs_global_pid_ns;
12813 +#endif /* _VX_GLOBAL_H */
12814 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/history.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/history.h
12815 --- linux-2.6.38.1/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12816 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/history.h 2011-01-29 02:01:07.000000000 +0100
12818 +#ifndef _VX_HISTORY_H
12819 +#define _VX_HISTORY_H
12824 + VXH_THROW_OOPS = 1,
12828 + VXH_INIT_VX_INFO,
12831 + VXH_CLAIM_VX_INFO,
12832 + VXH_RELEASE_VX_INFO,
12833 + VXH_ALLOC_VX_INFO,
12834 + VXH_DEALLOC_VX_INFO,
12835 + VXH_HASH_VX_INFO,
12836 + VXH_UNHASH_VX_INFO,
12838 + VXH_LOOKUP_VX_INFO,
12839 + VXH_CREATE_VX_INFO,
12842 +struct _vxhe_vxi {
12843 + struct vx_info *ptr;
12849 +struct _vxhe_set_clr {
12853 +struct _vxhe_loc_lookup {
12857 +struct _vx_hist_entry {
12859 + unsigned short seq;
12860 + unsigned short type;
12861 + struct _vxhe_vxi vxi;
12863 + struct _vxhe_set_clr sc;
12864 + struct _vxhe_loc_lookup ll;
12868 +#ifdef CONFIG_VSERVER_HISTORY
12870 +extern unsigned volatile int vxh_active;
12872 +struct _vx_hist_entry *vxh_advance(void *loc);
12876 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12878 + entry->vxi.ptr = vxi;
12880 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12881 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12882 + entry->vxi.xid = vxi->vx_id;
12887 +#define __HERE__ current_text_addr()
12889 +#define __VXH_BODY(__type, __data, __here) \
12890 + struct _vx_hist_entry *entry; \
12892 + preempt_disable(); \
12893 + entry = vxh_advance(__here); \
12895 + entry->type = __type; \
12896 + preempt_enable();
12899 + /* pass vxi only */
12901 +#define __VXH_SMPL \
12902 + __vxh_copy_vxi(entry, vxi)
12905 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12907 + __VXH_BODY(__type, __VXH_SMPL, __here)
12910 + /* pass vxi and data (void *) */
12912 +#define __VXH_DATA \
12913 + __vxh_copy_vxi(entry, vxi); \
12914 + entry->sc.data = data
12917 +void __vxh_data(struct vx_info *vxi, void *data,
12918 + int __type, void *__here)
12920 + __VXH_BODY(__type, __VXH_DATA, __here)
12923 + /* pass vxi and arg (long) */
12925 +#define __VXH_LONG \
12926 + __vxh_copy_vxi(entry, vxi); \
12927 + entry->ll.arg = arg
12930 +void __vxh_long(struct vx_info *vxi, long arg,
12931 + int __type, void *__here)
12933 + __VXH_BODY(__type, __VXH_LONG, __here)
12938 +void __vxh_throw_oops(void *__here)
12940 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12941 + /* prevent further acquisition */
12946 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
12948 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
12949 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
12951 +#define __vxh_init_vx_info(v, d, h) \
12952 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
12953 +#define __vxh_set_vx_info(v, d, h) \
12954 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
12955 +#define __vxh_clr_vx_info(v, d, h) \
12956 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12958 +#define __vxh_claim_vx_info(v, d, h) \
12959 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12960 +#define __vxh_release_vx_info(v, d, h) \
12961 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12963 +#define vxh_alloc_vx_info(v) \
12964 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12965 +#define vxh_dealloc_vx_info(v) \
12966 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12968 +#define vxh_hash_vx_info(v) \
12969 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12970 +#define vxh_unhash_vx_info(v) \
12971 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12973 +#define vxh_loc_vx_info(v, l) \
12974 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
12975 +#define vxh_lookup_vx_info(v, l) \
12976 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
12977 +#define vxh_create_vx_info(v, l) \
12978 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
12980 +extern void vxh_dump_history(void);
12983 +#else /* CONFIG_VSERVER_HISTORY */
12985 +#define __HERE__ 0
12987 +#define vxh_throw_oops() do { } while (0)
12989 +#define __vxh_get_vx_info(v, h) do { } while (0)
12990 +#define __vxh_put_vx_info(v, h) do { } while (0)
12992 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
12993 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
12994 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
12996 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
12997 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
12999 +#define vxh_alloc_vx_info(v) do { } while (0)
13000 +#define vxh_dealloc_vx_info(v) do { } while (0)
13002 +#define vxh_hash_vx_info(v) do { } while (0)
13003 +#define vxh_unhash_vx_info(v) do { } while (0)
13005 +#define vxh_loc_vx_info(v, l) do { } while (0)
13006 +#define vxh_lookup_vx_info(v, l) do { } while (0)
13007 +#define vxh_create_vx_info(v, l) do { } while (0)
13009 +#define vxh_dump_history() do { } while (0)
13012 +#endif /* CONFIG_VSERVER_HISTORY */
13014 +#endif /* _VX_HISTORY_H */
13015 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/inode.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/inode.h
13016 --- linux-2.6.38.1/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
13017 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/inode.h 2011-01-29 02:01:07.000000000 +0100
13019 +#ifndef _VX_INODE_H
13020 +#define _VX_INODE_H
13023 +#define IATTR_TAG 0x01000000
13025 +#define IATTR_ADMIN 0x00000001
13026 +#define IATTR_WATCH 0x00000002
13027 +#define IATTR_HIDE 0x00000004
13028 +#define IATTR_FLAGS 0x00000007
13030 +#define IATTR_BARRIER 0x00010000
13031 +#define IATTR_IXUNLINK 0x00020000
13032 +#define IATTR_IMMUTABLE 0x00040000
13033 +#define IATTR_COW 0x00080000
13038 +#ifdef CONFIG_VSERVER_PROC_SECURE
13039 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
13040 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
13042 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
13043 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
13046 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
13048 +#endif /* __KERNEL__ */
13050 +/* inode ioctls */
13052 +#define FIOC_GETXFLG _IOR('x', 5, long)
13053 +#define FIOC_SETXFLG _IOW('x', 6, long)
13055 +#else /* _VX_INODE_H */
13056 +#warning duplicate inclusion
13057 +#endif /* _VX_INODE_H */
13058 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/inode_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/inode_cmd.h
13059 --- linux-2.6.38.1/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
13060 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/inode_cmd.h 2011-01-29 02:01:07.000000000 +0100
13062 +#ifndef _VX_INODE_CMD_H
13063 +#define _VX_INODE_CMD_H
13066 +/* inode vserver commands */
13068 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
13069 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
13071 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
13072 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
13074 +struct vcmd_ctx_iattr_v1 {
13075 + const char __user *name;
13081 +struct vcmd_ctx_fiattr_v0 {
13091 +#ifdef CONFIG_COMPAT
13093 +#include <asm/compat.h>
13095 +struct vcmd_ctx_iattr_v1_x32 {
13096 + compat_uptr_t name_ptr;
13102 +#endif /* CONFIG_COMPAT */
13104 +#include <linux/compiler.h>
13106 +extern int vc_get_iattr(void __user *);
13107 +extern int vc_set_iattr(void __user *);
13109 +extern int vc_fget_iattr(uint32_t, void __user *);
13110 +extern int vc_fset_iattr(uint32_t, void __user *);
13112 +#ifdef CONFIG_COMPAT
13114 +extern int vc_get_iattr_x32(void __user *);
13115 +extern int vc_set_iattr_x32(void __user *);
13117 +#endif /* CONFIG_COMPAT */
13119 +#endif /* __KERNEL__ */
13120 +#endif /* _VX_INODE_CMD_H */
13121 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/limit.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/limit.h
13122 --- linux-2.6.38.1/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
13123 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/limit.h 2011-01-29 02:01:07.000000000 +0100
13125 +#ifndef _VX_LIMIT_H
13126 +#define _VX_LIMIT_H
13128 +#define VLIMIT_NSOCK 16
13129 +#define VLIMIT_OPENFD 17
13130 +#define VLIMIT_ANON 18
13131 +#define VLIMIT_SHMEM 19
13132 +#define VLIMIT_SEMARY 20
13133 +#define VLIMIT_NSEMS 21
13134 +#define VLIMIT_DENTRY 22
13135 +#define VLIMIT_MAPPED 23
13140 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
13142 +/* keep in sync with CRLIM_INFINITY */
13144 +#define VLIM_INFINITY (~0ULL)
13146 +#include <asm/atomic.h>
13147 +#include <asm/resource.h>
13149 +#ifndef RLIM_INFINITY
13150 +#warning RLIM_INFINITY is undefined
13153 +#define __rlim_val(l, r, v) ((l)->res[r].v)
13155 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
13156 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
13158 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
13159 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
13160 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
13162 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
13163 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
13165 +typedef atomic_long_t rlim_atomic_t;
13166 +typedef unsigned long rlim_t;
13168 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
13169 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
13170 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
13171 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
13172 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
13173 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
13176 +#if (RLIM_INFINITY == VLIM_INFINITY)
13177 +#define VX_VLIM(r) ((long long)(long)(r))
13178 +#define VX_RLIM(v) ((rlim_t)(v))
13180 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
13181 + ? VLIM_INFINITY : (long long)(r))
13182 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
13183 + ? RLIM_INFINITY : (rlim_t)(v))
13188 +void vx_vsi_meminfo(struct sysinfo *);
13189 +void vx_vsi_swapinfo(struct sysinfo *);
13190 +long vx_vsi_cached(struct sysinfo *);
13192 +#define NUM_LIMITS 24
13194 +#endif /* __KERNEL__ */
13195 +#endif /* _VX_LIMIT_H */
13196 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/limit_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/limit_cmd.h
13197 --- linux-2.6.38.1/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
13198 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/limit_cmd.h 2011-01-29 02:01:07.000000000 +0100
13200 +#ifndef _VX_LIMIT_CMD_H
13201 +#define _VX_LIMIT_CMD_H
13204 +/* rlimit vserver commands */
13206 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
13207 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
13208 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
13209 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
13210 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
13212 +struct vcmd_ctx_rlimit_v0 {
13214 + uint64_t minimum;
13215 + uint64_t softlimit;
13216 + uint64_t maximum;
13219 +struct vcmd_ctx_rlimit_mask_v0 {
13220 + uint32_t minimum;
13221 + uint32_t softlimit;
13222 + uint32_t maximum;
13225 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
13227 +struct vcmd_rlimit_stat_v0 {
13231 + uint64_t minimum;
13232 + uint64_t maximum;
13235 +#define CRLIM_UNSET (0ULL)
13236 +#define CRLIM_INFINITY (~0ULL)
13237 +#define CRLIM_KEEP (~1ULL)
13241 +#ifdef CONFIG_IA32_EMULATION
13243 +struct vcmd_ctx_rlimit_v0_x32 {
13245 + uint64_t minimum;
13246 + uint64_t softlimit;
13247 + uint64_t maximum;
13248 +} __attribute__ ((packed));
13250 +#endif /* CONFIG_IA32_EMULATION */
13252 +#include <linux/compiler.h>
13254 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
13255 +extern int vc_get_rlimit(struct vx_info *, void __user *);
13256 +extern int vc_set_rlimit(struct vx_info *, void __user *);
13257 +extern int vc_reset_hits(struct vx_info *, void __user *);
13258 +extern int vc_reset_minmax(struct vx_info *, void __user *);
13260 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
13262 +#ifdef CONFIG_IA32_EMULATION
13264 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
13265 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
13267 +#endif /* CONFIG_IA32_EMULATION */
13269 +#endif /* __KERNEL__ */
13270 +#endif /* _VX_LIMIT_CMD_H */
13271 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/limit_def.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/limit_def.h
13272 --- linux-2.6.38.1/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
13273 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/limit_def.h 2011-01-29 02:01:07.000000000 +0100
13275 +#ifndef _VX_LIMIT_DEF_H
13276 +#define _VX_LIMIT_DEF_H
13278 +#include <asm/atomic.h>
13279 +#include <asm/resource.h>
13281 +#include "limit.h"
13284 +struct _vx_res_limit {
13285 + rlim_t soft; /* Context soft limit */
13286 + rlim_t hard; /* Context hard limit */
13288 + rlim_atomic_t rcur; /* Current value */
13289 + rlim_t rmin; /* Context minimum */
13290 + rlim_t rmax; /* Context maximum */
13292 + atomic_t lhit; /* Limit hits */
13295 +/* context sub struct */
13297 +struct _vx_limit {
13298 + struct _vx_res_limit res[NUM_LIMITS];
13301 +#ifdef CONFIG_VSERVER_DEBUG
13303 +static inline void __dump_vx_limit(struct _vx_limit *limit)
13307 + printk("\t_vx_limit:");
13308 + for (i = 0; i < NUM_LIMITS; i++) {
13309 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
13310 + i, (unsigned long)__rlim_get(limit, i),
13311 + (unsigned long)__rlim_rmin(limit, i),
13312 + (unsigned long)__rlim_rmax(limit, i),
13313 + (long)__rlim_soft(limit, i),
13314 + (long)__rlim_hard(limit, i),
13315 + atomic_read(&__rlim_lhit(limit, i)));
13321 +#endif /* _VX_LIMIT_DEF_H */
13322 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/limit_int.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/limit_int.h
13323 --- linux-2.6.38.1/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
13324 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/limit_int.h 2011-01-29 02:01:07.000000000 +0100
13326 +#ifndef _VX_LIMIT_INT_H
13327 +#define _VX_LIMIT_INT_H
13329 +#include "context.h"
13333 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
13334 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
13336 +extern const char *vlimit_name[NUM_LIMITS];
13338 +static inline void __vx_acc_cres(struct vx_info *vxi,
13339 + int res, int dir, void *_data, char *_file, int _line)
13341 + if (VXD_RCRES_COND(res))
13342 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
13343 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13344 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13345 + (dir > 0) ? "++" : "--", _data, _file, _line);
13350 + __rlim_inc(&vxi->limit, res);
13352 + __rlim_dec(&vxi->limit, res);
13355 +static inline void __vx_add_cres(struct vx_info *vxi,
13356 + int res, int amount, void *_data, char *_file, int _line)
13358 + if (VXD_RCRES_COND(res))
13359 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
13360 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13361 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13362 + amount, _data, _file, _line);
13367 + __rlim_add(&vxi->limit, res, amount);
13371 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
13373 + int cond = (value > __rlim_rmax(limit, res));
13376 + __rlim_rmax(limit, res) = value;
13381 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13383 + int cond = (value < __rlim_rmin(limit, res));
13386 + __rlim_rmin(limit, res) = value;
13391 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13393 + if (!__vx_cres_adjust_max(limit, res, value))
13394 + __vx_cres_adjust_min(limit, res, value);
13399 + +1 ... no limit hit
13400 + -1 ... over soft limit
13401 + 0 ... over hard limit */
13403 +static inline int __vx_cres_avail(struct vx_info *vxi,
13404 + int res, int num, char *_file, int _line)
13406 + struct _vx_limit *limit;
13409 + if (VXD_RLIMIT_COND(res))
13410 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13411 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13412 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13413 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13414 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13415 + num, _file, _line);
13419 + limit = &vxi->limit;
13420 + value = __rlim_get(limit, res);
13422 + if (!__vx_cres_adjust_max(limit, res, value))
13423 + __vx_cres_adjust_min(limit, res, value);
13428 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
13430 + if (value + num <= __rlim_soft(limit, res))
13433 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
13435 + if (value + num <= __rlim_hard(limit, res))
13438 + __rlim_hit(limit, res);
13443 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13446 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13448 + rlim_t value, sum = 0;
13451 + while ((res = *array++)) {
13452 + value = __rlim_get(limit, res);
13453 + __vx_cres_fixup(limit, res, value);
13460 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13462 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
13463 + int res = *array;
13465 + if (value == __rlim_get(limit, res))
13468 + __rlim_set(limit, res, value);
13469 + /* now adjust min/max */
13470 + if (!__vx_cres_adjust_max(limit, res, value))
13471 + __vx_cres_adjust_min(limit, res, value);
13476 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13477 + const int *array, int num, char *_file, int _line)
13479 + struct _vx_limit *limit;
13480 + rlim_t value = 0;
13488 + limit = &vxi->limit;
13490 + value = __vx_cres_array_sum(limit, array + 1);
13492 + __rlim_set(limit, res, value);
13493 + __vx_cres_fixup(limit, res, value);
13495 + return __vx_cres_avail(vxi, res, num, _file, _line);
13499 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13504 + /* complex resources first */
13505 + if ((id < 0) || (id == RLIMIT_RSS))
13506 + __vx_cres_array_fixup(limit, VLA_RSS);
13508 + for (res = 0; res < NUM_LIMITS; res++) {
13509 + if ((id > 0) && (res != id))
13512 + value = __rlim_get(limit, res);
13513 + __vx_cres_fixup(limit, res, value);
13515 + /* not supposed to happen, maybe warn? */
13516 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13517 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13522 +#endif /* __KERNEL__ */
13523 +#endif /* _VX_LIMIT_INT_H */
13524 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/monitor.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/monitor.h
13525 --- linux-2.6.38.1/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
13526 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/monitor.h 2011-01-29 02:01:07.000000000 +0100
13528 +#ifndef _VX_MONITOR_H
13529 +#define _VX_MONITOR_H
13531 +#include <linux/types.h>
13538 + VXM_UPDATE = 0x20,
13542 + VXM_RQINFO_1 = 0x24,
13545 + VXM_ACTIVATE = 0x40,
13552 + VXM_MIGRATE = 0x48,
13555 + /* all other bits are flags */
13556 + VXM_SCHED = 0x80,
13559 +struct _vxm_update_1 {
13560 + uint32_t tokens_max;
13561 + uint32_t fill_rate;
13562 + uint32_t interval;
13565 +struct _vxm_update_2 {
13566 + uint32_t tokens_min;
13567 + uint32_t fill_rate;
13568 + uint32_t interval;
13571 +struct _vxm_rqinfo_1 {
13572 + uint16_t running;
13576 + uint32_t idle_tokens;
13579 +struct _vxm_rqinfo_2 {
13580 + uint32_t norm_time;
13581 + uint32_t idle_time;
13582 + uint32_t idle_skip;
13585 +struct _vxm_sched {
13587 + uint32_t norm_time;
13588 + uint32_t idle_time;
13591 +struct _vxm_task {
13596 +struct _vxm_event {
13605 + struct _vxm_task tsk;
13609 +struct _vx_mon_entry {
13613 + struct _vxm_event ev;
13614 + struct _vxm_sched sd;
13615 + struct _vxm_update_1 u1;
13616 + struct _vxm_update_2 u2;
13617 + struct _vxm_rqinfo_1 q1;
13618 + struct _vxm_rqinfo_2 q2;
13623 +#endif /* _VX_MONITOR_H */
13624 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/network.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/network.h
13625 --- linux-2.6.38.1/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
13626 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/network.h 2011-01-29 02:01:07.000000000 +0100
13628 +#ifndef _VX_NETWORK_H
13629 +#define _VX_NETWORK_H
13631 +#include <linux/types.h>
13634 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13637 +/* network flags */
13639 +#define NXF_INFO_PRIVATE 0x00000008
13641 +#define NXF_SINGLE_IP 0x00000100
13642 +#define NXF_LBACK_REMAP 0x00000200
13643 +#define NXF_LBACK_ALLOW 0x00000400
13645 +#define NXF_HIDE_NETIF 0x02000000
13646 +#define NXF_HIDE_LBACK 0x04000000
13648 +#define NXF_STATE_SETUP (1ULL << 32)
13649 +#define NXF_STATE_ADMIN (1ULL << 34)
13651 +#define NXF_SC_HELPER (1ULL << 36)
13652 +#define NXF_PERSISTENT (1ULL << 38)
13654 +#define NXF_ONE_TIME (0x0005ULL << 32)
13657 +#define NXF_INIT_SET (__nxf_init_set())
13659 +static inline uint64_t __nxf_init_set(void) {
13660 + return NXF_STATE_ADMIN
13661 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13662 + | NXF_LBACK_REMAP
13665 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13668 + | NXF_HIDE_NETIF;
13672 +/* network caps */
13674 +#define NXC_TUN_CREATE 0x00000001
13676 +#define NXC_RAW_ICMP 0x00000100
13679 +/* address types */
13681 +#define NXA_TYPE_IPV4 0x0001
13682 +#define NXA_TYPE_IPV6 0x0002
13684 +#define NXA_TYPE_NONE 0x0000
13685 +#define NXA_TYPE_ANY 0x00FF
13687 +#define NXA_TYPE_ADDR 0x0010
13688 +#define NXA_TYPE_MASK 0x0020
13689 +#define NXA_TYPE_RANGE 0x0040
13691 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13693 +#define NXA_MOD_BCAST 0x0100
13694 +#define NXA_MOD_LBACK 0x0200
13696 +#define NXA_LOOPBACK 0x1000
13698 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13699 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13703 +#include <linux/list.h>
13704 +#include <linux/spinlock.h>
13705 +#include <linux/rcupdate.h>
13706 +#include <linux/in.h>
13707 +#include <linux/in6.h>
13708 +#include <asm/atomic.h>
13710 +struct nx_addr_v4 {
13711 + struct nx_addr_v4 *next;
13712 + struct in_addr ip[2];
13713 + struct in_addr mask;
13718 +struct nx_addr_v6 {
13719 + struct nx_addr_v6 *next;
13720 + struct in6_addr ip;
13721 + struct in6_addr mask;
13728 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13729 + nid_t nx_id; /* vnet id */
13730 + atomic_t nx_usecnt; /* usage count */
13731 + atomic_t nx_tasks; /* tasks count */
13732 + int nx_state; /* context state */
13734 + uint64_t nx_flags; /* network flag word */
13735 + uint64_t nx_ncaps; /* network capabilities */
13737 + struct in_addr v4_lback; /* Loopback address */
13738 + struct in_addr v4_bcast; /* Broadcast address */
13739 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13740 +#ifdef CONFIG_IPV6
13741 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13743 + char nx_name[65]; /* network context name */
13747 +/* status flags */
13749 +#define NXS_HASHED 0x0001
13750 +#define NXS_SHUTDOWN 0x0100
13751 +#define NXS_RELEASED 0x8000
13753 +extern struct nx_info *lookup_nx_info(int);
13755 +extern int get_nid_list(int, unsigned int *, int);
13756 +extern int nid_is_hashed(nid_t);
13758 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13760 +extern long vs_net_change(struct nx_info *, unsigned int);
13765 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13766 +#ifdef CONFIG_IPV6
13767 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13769 +#define NX_IPV6(n) (0)
13772 +#endif /* __KERNEL__ */
13773 +#endif /* _VX_NETWORK_H */
13774 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/network_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/network_cmd.h
13775 --- linux-2.6.38.1/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13776 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/network_cmd.h 2011-01-29 02:01:07.000000000 +0100
13778 +#ifndef _VX_NETWORK_CMD_H
13779 +#define _VX_NETWORK_CMD_H
13782 +/* vinfo commands */
13784 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13787 +extern int vc_task_nid(uint32_t);
13789 +#endif /* __KERNEL__ */
13791 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13793 +struct vcmd_nx_info_v0 {
13795 + /* more to come */
13799 +extern int vc_nx_info(struct nx_info *, void __user *);
13801 +#endif /* __KERNEL__ */
13803 +#include <linux/in.h>
13804 +#include <linux/in6.h>
13806 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13807 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13809 +struct vcmd_net_create {
13810 + uint64_t flagword;
13813 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13815 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13816 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13818 +struct vcmd_net_addr_v0 {
13821 + struct in_addr ip[4];
13822 + struct in_addr mask[4];
13825 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
13826 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
13828 +struct vcmd_net_addr_ipv4_v1 {
13831 + struct in_addr ip;
13832 + struct in_addr mask;
13835 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13836 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13838 +struct vcmd_net_addr_ipv6_v1 {
13842 + struct in6_addr ip;
13843 + struct in6_addr mask;
13846 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13847 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13849 +struct vcmd_match_ipv4_v0 {
13854 + struct in_addr ip;
13855 + struct in_addr ip2;
13856 + struct in_addr mask;
13859 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13860 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13862 +struct vcmd_match_ipv6_v0 {
13867 + struct in6_addr ip;
13868 + struct in6_addr ip2;
13869 + struct in6_addr mask;
13874 +extern int vc_net_create(uint32_t, void __user *);
13875 +extern int vc_net_migrate(struct nx_info *, void __user *);
13877 +extern int vc_net_add(struct nx_info *, void __user *);
13878 +extern int vc_net_remove(struct nx_info *, void __user *);
13880 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13881 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
13883 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13884 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13886 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13887 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13889 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13890 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13892 +#endif /* __KERNEL__ */
13895 +/* flag commands */
13897 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13898 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13900 +struct vcmd_net_flags_v0 {
13901 + uint64_t flagword;
13906 +extern int vc_get_nflags(struct nx_info *, void __user *);
13907 +extern int vc_set_nflags(struct nx_info *, void __user *);
13909 +#endif /* __KERNEL__ */
13912 +/* network caps commands */
13914 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13915 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13917 +struct vcmd_net_caps_v0 {
13923 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13924 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13926 +#endif /* __KERNEL__ */
13927 +#endif /* _VX_CONTEXT_CMD_H */
13928 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/percpu.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/percpu.h
13929 --- linux-2.6.38.1/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13930 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/percpu.h 2011-01-29 02:01:07.000000000 +0100
13932 +#ifndef _VX_PERCPU_H
13933 +#define _VX_PERCPU_H
13935 +#include "cvirt_def.h"
13936 +#include "sched_def.h"
13938 +struct _vx_percpu {
13939 + struct _vx_cvirt_pc cvirt;
13940 + struct _vx_sched_pc sched;
13943 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13945 +#endif /* _VX_PERCPU_H */
13946 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/pid.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/pid.h
13947 --- linux-2.6.38.1/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
13948 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/pid.h 2011-01-29 02:01:07.000000000 +0100
13950 +#ifndef _VSERVER_PID_H
13951 +#define _VSERVER_PID_H
13953 +/* pid faking stuff */
13955 +#define vx_info_map_pid(v, p) \
13956 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13957 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13958 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13959 +#define vx_map_tgid(p) vx_map_pid(p)
13961 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13962 + const char *func, const char *file, int line)
13964 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13965 + vxfprintk(VXD_CBIT(cvirt, 2),
13966 + "vx_map_tgid: %p/%llx: %d -> %d",
13967 + vxi, (long long)vxi->vx_flags, pid,
13968 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13969 + func, file, line);
13972 + if (pid == vxi->vx_initpid)
13978 +#define vx_info_rmap_pid(v, p) \
13979 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
13980 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
13981 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13983 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13984 + const char *func, const char *file, int line)
13986 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13987 + vxfprintk(VXD_CBIT(cvirt, 2),
13988 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13989 + vxi, (long long)vxi->vx_flags, pid,
13990 + (pid == 1) ? vxi->vx_initpid : pid,
13991 + func, file, line);
13992 + if ((pid == 1) && vxi->vx_initpid)
13993 + return vxi->vx_initpid;
13994 + if (pid == vxi->vx_initpid)
14001 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/sched.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/sched.h
14002 --- linux-2.6.38.1/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
14003 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/sched.h 2011-01-29 02:01:07.000000000 +0100
14005 +#ifndef _VX_SCHED_H
14006 +#define _VX_SCHED_H
14013 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14018 +void vx_update_load(struct vx_info *);
14021 +void vx_update_sched_param(struct _vx_sched *sched,
14022 + struct _vx_sched_pc *sched_pc);
14024 +#endif /* __KERNEL__ */
14025 +#else /* _VX_SCHED_H */
14026 +#warning duplicate inclusion
14027 +#endif /* _VX_SCHED_H */
14028 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/sched_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/sched_cmd.h
14029 --- linux-2.6.38.1/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
14030 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/sched_cmd.h 2011-01-29 02:01:07.000000000 +0100
14032 +#ifndef _VX_SCHED_CMD_H
14033 +#define _VX_SCHED_CMD_H
14036 +struct vcmd_prio_bias {
14038 + int32_t prio_bias;
14041 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
14042 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
14046 +#include <linux/compiler.h>
14048 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
14049 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
14051 +#endif /* __KERNEL__ */
14052 +#endif /* _VX_SCHED_CMD_H */
14053 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/sched_def.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/sched_def.h
14054 --- linux-2.6.38.1/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
14055 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/sched_def.h 2011-01-29 02:01:07.000000000 +0100
14057 +#ifndef _VX_SCHED_DEF_H
14058 +#define _VX_SCHED_DEF_H
14060 +#include <linux/spinlock.h>
14061 +#include <linux/jiffies.h>
14062 +#include <linux/cpumask.h>
14063 +#include <asm/atomic.h>
14064 +#include <asm/param.h>
14067 +/* context sub struct */
14069 +struct _vx_sched {
14070 + int prio_bias; /* bias offset for priority */
14072 + cpumask_t update; /* CPUs which should update */
14075 +struct _vx_sched_pc {
14076 + int prio_bias; /* bias offset for priority */
14078 + uint64_t user_ticks; /* token tick events */
14079 + uint64_t sys_ticks; /* token tick events */
14080 + uint64_t hold_ticks; /* token ticks paused */
14084 +#ifdef CONFIG_VSERVER_DEBUG
14086 +static inline void __dump_vx_sched(struct _vx_sched *sched)
14088 + printk("\t_vx_sched:\n");
14089 + printk("\t priority = %4d\n", sched->prio_bias);
14094 +#endif /* _VX_SCHED_DEF_H */
14095 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/signal.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/signal.h
14096 --- linux-2.6.38.1/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
14097 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/signal.h 2011-01-29 02:01:07.000000000 +0100
14099 +#ifndef _VX_SIGNAL_H
14100 +#define _VX_SIGNAL_H
14107 +int vx_info_kill(struct vx_info *, int, int);
14109 +#endif /* __KERNEL__ */
14110 +#else /* _VX_SIGNAL_H */
14111 +#warning duplicate inclusion
14112 +#endif /* _VX_SIGNAL_H */
14113 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/signal_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/signal_cmd.h
14114 --- linux-2.6.38.1/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
14115 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/signal_cmd.h 2011-01-29 02:01:07.000000000 +0100
14117 +#ifndef _VX_SIGNAL_CMD_H
14118 +#define _VX_SIGNAL_CMD_H
14121 +/* signalling vserver commands */
14123 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
14124 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
14126 +struct vcmd_ctx_kill_v0 {
14131 +struct vcmd_wait_exit_v0 {
14132 + int32_t reboot_cmd;
14133 + int32_t exit_code;
14138 +extern int vc_ctx_kill(struct vx_info *, void __user *);
14139 +extern int vc_wait_exit(struct vx_info *, void __user *);
14141 +#endif /* __KERNEL__ */
14143 +/* process alteration commands */
14145 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
14146 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
14148 +struct vcmd_pflags_v0 {
14149 + uint32_t flagword;
14155 +extern int vc_get_pflags(uint32_t pid, void __user *);
14156 +extern int vc_set_pflags(uint32_t pid, void __user *);
14158 +#endif /* __KERNEL__ */
14159 +#endif /* _VX_SIGNAL_CMD_H */
14160 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/space.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/space.h
14161 --- linux-2.6.38.1/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
14162 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/space.h 2011-01-29 02:01:07.000000000 +0100
14164 +#ifndef _VX_SPACE_H
14165 +#define _VX_SPACE_H
14167 +#include <linux/types.h>
14171 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
14173 +#else /* _VX_SPACE_H */
14174 +#warning duplicate inclusion
14175 +#endif /* _VX_SPACE_H */
14176 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/space_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/space_cmd.h
14177 --- linux-2.6.38.1/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
14178 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/space_cmd.h 2011-01-29 02:01:07.000000000 +0100
14180 +#ifndef _VX_SPACE_CMD_H
14181 +#define _VX_SPACE_CMD_H
14184 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
14185 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
14186 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
14188 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
14189 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
14190 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
14192 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
14194 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
14195 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
14198 +struct vcmd_space_mask_v1 {
14202 +struct vcmd_space_mask_v2 {
14210 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
14211 +extern int vc_set_space_v1(struct vx_info *, void __user *);
14212 +extern int vc_enter_space(struct vx_info *, void __user *);
14213 +extern int vc_set_space(struct vx_info *, void __user *);
14214 +extern int vc_get_space_mask(void __user *, int);
14216 +#endif /* __KERNEL__ */
14217 +#endif /* _VX_SPACE_CMD_H */
14218 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/switch.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/switch.h
14219 --- linux-2.6.38.1/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
14220 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/switch.h 2011-01-29 02:01:07.000000000 +0100
14222 +#ifndef _VX_SWITCH_H
14223 +#define _VX_SWITCH_H
14225 +#include <linux/types.h>
14228 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
14229 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
14230 +#define VC_VERSION(c) ((c) & 0xFFF)
14232 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
14233 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
14237 + Syscall Matrix V2.8
14239 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
14240 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
14241 + |INFO |SETUP | |MOVE | | | | | |
14242 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14243 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
14244 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
14245 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14246 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
14247 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
14248 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14249 + MEMORY | | | | |MEMCTRL| | |SWAP | |
14250 + | 16| 17| 18| 19| 20| 21| | 22| 23|
14251 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14252 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
14253 + | 24| 25| 26| 27| 28| 29| | 30| 31|
14254 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14255 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
14256 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
14257 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14258 + OTHER |VSTAT | | | | | | |VINFO | |
14259 + | 40| 41| 42| 43| 44| 45| | 46| 47|
14260 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
14261 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
14262 + | 48| 49| 50| 51| 52| 53| | 54| 55|
14263 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14264 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
14265 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
14266 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14270 +#define VC_CAT_VERSION 0
14272 +#define VC_CAT_VSETUP 1
14273 +#define VC_CAT_VHOST 2
14275 +#define VC_CAT_DEVICE 6
14277 +#define VC_CAT_VPROC 9
14278 +#define VC_CAT_PROCALT 10
14279 +#define VC_CAT_PROCMIG 11
14280 +#define VC_CAT_PROCTRL 12
14282 +#define VC_CAT_SCHED 14
14283 +#define VC_CAT_MEMCTRL 20
14285 +#define VC_CAT_VNET 25
14286 +#define VC_CAT_NETALT 26
14287 +#define VC_CAT_NETMIG 27
14288 +#define VC_CAT_NETCTRL 28
14290 +#define VC_CAT_TAGMIG 35
14291 +#define VC_CAT_DLIMIT 36
14292 +#define VC_CAT_INODE 38
14294 +#define VC_CAT_VSTAT 40
14295 +#define VC_CAT_VINFO 46
14296 +#define VC_CAT_EVENT 48
14298 +#define VC_CAT_FLAGS 52
14299 +#define VC_CAT_VSPACE 54
14300 +#define VC_CAT_DEBUG 56
14301 +#define VC_CAT_RLIMIT 60
14303 +#define VC_CAT_SYSTEST 61
14304 +#define VC_CAT_COMPAT 63
14306 +/* query version */
14308 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
14309 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
14314 +#include <linux/errno.h>
14316 +#endif /* __KERNEL__ */
14318 +#endif /* _VX_SWITCH_H */
14320 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/tag.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/tag.h
14321 --- linux-2.6.38.1/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
14322 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/tag.h 2011-01-29 02:01:07.000000000 +0100
14327 +#include <linux/types.h>
14330 +#define DX_TAG(in) (IS_TAGGED(in))
14333 +#ifdef CONFIG_TAG_NFSD
14334 +#define DX_TAG_NFSD 1
14336 +#define DX_TAG_NFSD 0
14340 +#ifdef CONFIG_TAGGING_NONE
14342 +#define MAX_UID 0xFFFFFFFF
14343 +#define MAX_GID 0xFFFFFFFF
14345 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
14347 +#define TAGINO_UID(cond, uid, tag) (uid)
14348 +#define TAGINO_GID(cond, gid, tag) (gid)
14353 +#ifdef CONFIG_TAGGING_GID16
14355 +#define MAX_UID 0xFFFFFFFF
14356 +#define MAX_GID 0x0000FFFF
14358 +#define INOTAG_TAG(cond, uid, gid, tag) \
14359 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
14361 +#define TAGINO_UID(cond, uid, tag) (uid)
14362 +#define TAGINO_GID(cond, gid, tag) \
14363 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14368 +#ifdef CONFIG_TAGGING_ID24
14370 +#define MAX_UID 0x00FFFFFF
14371 +#define MAX_GID 0x00FFFFFF
14373 +#define INOTAG_TAG(cond, uid, gid, tag) \
14374 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14376 +#define TAGINO_UID(cond, uid, tag) \
14377 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14378 +#define TAGINO_GID(cond, gid, tag) \
14379 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14384 +#ifdef CONFIG_TAGGING_UID16
14386 +#define MAX_UID 0x0000FFFF
14387 +#define MAX_GID 0xFFFFFFFF
14389 +#define INOTAG_TAG(cond, uid, gid, tag) \
14390 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14392 +#define TAGINO_UID(cond, uid, tag) \
14393 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14394 +#define TAGINO_GID(cond, gid, tag) (gid)
14399 +#ifdef CONFIG_TAGGING_INTERN
14401 +#define MAX_UID 0xFFFFFFFF
14402 +#define MAX_GID 0xFFFFFFFF
14404 +#define INOTAG_TAG(cond, uid, gid, tag) \
14405 + ((cond) ? (tag) : 0)
14407 +#define TAGINO_UID(cond, uid, tag) (uid)
14408 +#define TAGINO_GID(cond, gid, tag) (gid)
14413 +#ifndef CONFIG_TAGGING_NONE
14414 +#define dx_current_fstag(sb) \
14415 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14417 +#define dx_current_fstag(sb) (0)
14420 +#ifndef CONFIG_TAGGING_INTERN
14421 +#define TAGINO_TAG(cond, tag) (0)
14423 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
14426 +#define INOTAG_UID(cond, uid, gid) \
14427 + ((cond) ? ((uid) & MAX_UID) : (uid))
14428 +#define INOTAG_GID(cond, uid, gid) \
14429 + ((cond) ? ((gid) & MAX_GID) : (gid))
14432 +static inline uid_t dx_map_uid(uid_t uid)
14434 + if ((uid > MAX_UID) && (uid != -1))
14436 + return (uid & MAX_UID);
14439 +static inline gid_t dx_map_gid(gid_t gid)
14441 + if ((gid > MAX_GID) && (gid != -1))
14443 + return (gid & MAX_GID);
14451 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14453 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14454 + unsigned long *flags);
14456 +#ifdef CONFIG_PROPAGATE
14458 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14460 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14463 +#define dx_propagate_tag(n, i) do { } while (0)
14466 +#endif /* _DX_TAG_H */
14467 diff -NurpP --minimal linux-2.6.38.1/include/linux/vserver/tag_cmd.h linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/tag_cmd.h
14468 --- linux-2.6.38.1/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
14469 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/linux/vserver/tag_cmd.h 2011-01-29 02:01:07.000000000 +0100
14471 +#ifndef _VX_TAG_CMD_H
14472 +#define _VX_TAG_CMD_H
14475 +/* vinfo commands */
14477 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
14480 +extern int vc_task_tag(uint32_t);
14482 +#endif /* __KERNEL__ */
14484 +/* context commands */
14486 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
14489 +extern int vc_tag_migrate(uint32_t);
14491 +#endif /* __KERNEL__ */
14492 +#endif /* _VX_TAG_CMD_H */
14493 diff -NurpP --minimal linux-2.6.38.1/include/net/addrconf.h linux-2.6.38.1-vs2.3.0.37-rc9/include/net/addrconf.h
14494 --- linux-2.6.38.1/include/net/addrconf.h 2011-03-15 18:07:40.000000000 +0100
14495 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/net/addrconf.h 2011-01-29 02:01:07.000000000 +0100
14496 @@ -82,7 +82,8 @@ extern int ipv6_dev_get_saddr(struct n
14497 struct net_device *dev,
14498 const struct in6_addr *daddr,
14499 unsigned int srcprefs,
14500 - struct in6_addr *saddr);
14501 + struct in6_addr *saddr,
14502 + struct nx_info *nxi);
14503 extern int ipv6_get_lladdr(struct net_device *dev,
14504 struct in6_addr *addr,
14505 unsigned char banned_flags);
14506 diff -NurpP --minimal linux-2.6.38.1/include/net/af_unix.h linux-2.6.38.1-vs2.3.0.37-rc9/include/net/af_unix.h
14507 --- linux-2.6.38.1/include/net/af_unix.h 2011-01-05 21:50:35.000000000 +0100
14508 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/net/af_unix.h 2011-01-29 02:01:07.000000000 +0100
14510 #include <linux/socket.h>
14511 #include <linux/un.h>
14512 #include <linux/mutex.h>
14513 +#include <linux/vs_base.h>
14514 #include <net/sock.h>
14516 extern void unix_inflight(struct file *fp);
14517 diff -NurpP --minimal linux-2.6.38.1/include/net/inet_timewait_sock.h linux-2.6.38.1-vs2.3.0.37-rc9/include/net/inet_timewait_sock.h
14518 --- linux-2.6.38.1/include/net/inet_timewait_sock.h 2011-03-15 18:07:40.000000000 +0100
14519 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/net/inet_timewait_sock.h 2011-01-29 03:12:58.000000000 +0100
14520 @@ -113,6 +113,10 @@ struct inet_timewait_sock {
14521 #define tw_net __tw_common.skc_net
14522 #define tw_daddr __tw_common.skc_daddr
14523 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
14524 +#define tw_xid __tw_common.skc_xid
14525 +#define tw_vx_info __tw_common.skc_vx_info
14526 +#define tw_nid __tw_common.skc_nid
14527 +#define tw_nx_info __tw_common.skc_nx_info
14529 volatile unsigned char tw_substate;
14530 unsigned char tw_rcv_wscale;
14531 diff -NurpP --minimal linux-2.6.38.1/include/net/route.h linux-2.6.38.1-vs2.3.0.37-rc9/include/net/route.h
14532 --- linux-2.6.38.1/include/net/route.h 2011-03-15 18:07:40.000000000 +0100
14533 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/net/route.h 2011-01-29 02:01:07.000000000 +0100
14534 @@ -153,6 +153,9 @@ static inline void ip_rt_put(struct rtab
14535 dst_release(&rt->dst);
14538 +#include <linux/vs_base.h>
14539 +#include <linux/vs_inet.h>
14541 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14543 extern const __u8 ip_tos2prio[16];
14544 @@ -162,6 +165,9 @@ static inline char rt_tos2priority(u8 to
14545 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14548 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14549 + struct rtable **, struct flowi *);
14551 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14552 __be32 src, u32 tos, int oif, u8 protocol,
14553 __be16 sport, __be16 dport, struct sock *sk,
14554 @@ -177,11 +183,24 @@ static inline int ip_route_connect(struc
14555 .fl_ip_dport = dport };
14557 struct net *net = sock_net(sk);
14558 + struct nx_info *nx_info = current_nx_info();
14560 if (inet_sk(sk)->transparent)
14561 fl.flags |= FLOWI_FLAG_ANYSRC;
14563 - if (!dst || !src) {
14565 + nx_info = sk->sk_nx_info;
14567 + vxdprintk(VXD_CBIT(net, 4),
14568 + "ip_route_connect(%p) %p,%p;%lx",
14569 + sk, nx_info, sk->sk_socket,
14570 + (sk->sk_socket?sk->sk_socket->flags:0));
14572 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14576 + if (!fl.fl4_dst || !fl.fl4_src) {
14577 err = __ip_route_output_key(net, rp, &fl);
14580 diff -NurpP --minimal linux-2.6.38.1/include/net/sock.h linux-2.6.38.1-vs2.3.0.37-rc9/include/net/sock.h
14581 --- linux-2.6.38.1/include/net/sock.h 2011-03-15 18:07:41.000000000 +0100
14582 +++ linux-2.6.38.1-vs2.3.0.37-rc9/include/net/sock.h 2011-02-17 02:17:51.000000000 +0100
14583 @@ -148,6 +148,10 @@ struct sock_common {
14584 #ifdef CONFIG_NET_NS
14585 struct net *skc_net;
14588 + struct vx_info *skc_vx_info;
14590 + struct nx_info *skc_nx_info;
14592 * fields between dontcopy_begin/dontcopy_end
14593 * are not copied in sock_copy()
14594 @@ -256,6 +260,10 @@ struct sock {
14595 #define sk_bind_node __sk_common.skc_bind_node
14596 #define sk_prot __sk_common.skc_prot
14597 #define sk_net __sk_common.skc_net
14598 +#define sk_xid __sk_common.skc_xid
14599 +#define sk_vx_info __sk_common.skc_vx_info
14600 +#define sk_nid __sk_common.skc_nid
14601 +#define sk_nx_info __sk_common.skc_nx_info
14602 socket_lock_t sk_lock;
14603 struct sk_buff_head sk_receive_queue;
14605 diff -NurpP --minimal linux-2.6.38.1/init/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/init/Kconfig
14606 --- linux-2.6.38.1/init/Kconfig 2011-03-15 18:07:41.000000000 +0100
14607 +++ linux-2.6.38.1-vs2.3.0.37-rc9/init/Kconfig 2011-01-29 02:01:07.000000000 +0100
14608 @@ -559,6 +559,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
14610 boolean "Control Group support"
14614 This option adds support for grouping sets of processes together, for
14615 use with process control subsystems such as Cpusets, CFS, memory
14616 @@ -584,6 +585,7 @@ config CGROUP_DEBUG
14619 bool "Namespace cgroup subsystem"
14622 Provides a simple namespace cgroup subsystem to
14623 provide hierarchical naming of sets of namespaces,
14624 diff -NurpP --minimal linux-2.6.38.1/init/main.c linux-2.6.38.1-vs2.3.0.37-rc9/init/main.c
14625 --- linux-2.6.38.1/init/main.c 2011-03-15 18:07:41.000000000 +0100
14626 +++ linux-2.6.38.1-vs2.3.0.37-rc9/init/main.c 2011-01-29 02:21:25.000000000 +0100
14628 #include <linux/shmem_fs.h>
14629 #include <linux/slab.h>
14630 #include <linux/perf_event.h>
14631 +#include <linux/vserver/percpu.h>
14633 #include <asm/io.h>
14634 #include <asm/bugs.h>
14635 diff -NurpP --minimal linux-2.6.38.1/ipc/mqueue.c linux-2.6.38.1-vs2.3.0.37-rc9/ipc/mqueue.c
14636 --- linux-2.6.38.1/ipc/mqueue.c 2011-03-15 18:07:41.000000000 +0100
14637 +++ linux-2.6.38.1-vs2.3.0.37-rc9/ipc/mqueue.c 2011-01-29 02:01:07.000000000 +0100
14639 #include <linux/pid.h>
14640 #include <linux/ipc_namespace.h>
14641 #include <linux/slab.h>
14642 +#include <linux/vs_context.h>
14643 +#include <linux/vs_limit.h>
14645 #include <net/sock.h>
14647 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14648 struct sigevent notify;
14649 struct pid* notify_owner;
14650 struct user_struct *user; /* user who created, for accounting */
14651 + struct vx_info *vxi;
14652 struct sock *notify_sock;
14653 struct sk_buff *notify_cookie;
14655 @@ -126,6 +129,7 @@ static struct inode *mqueue_get_inode(st
14656 if (S_ISREG(mode)) {
14657 struct mqueue_inode_info *info;
14658 struct task_struct *p = current;
14659 + struct vx_info *vxi = p->vx_info;
14660 unsigned long mq_bytes, mq_msg_tblsz;
14662 inode->i_fop = &mqueue_file_operations;
14663 @@ -139,6 +143,7 @@ static struct inode *mqueue_get_inode(st
14664 info->notify_owner = NULL;
14666 info->user = NULL; /* set when all is ok */
14667 + info->vxi = NULL;
14668 memset(&info->attr, 0, sizeof(info->attr));
14669 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14670 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14671 @@ -157,16 +162,19 @@ static struct inode *mqueue_get_inode(st
14672 spin_lock(&mq_lock);
14673 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14674 u->mq_bytes + mq_bytes >
14675 - task_rlimit(p, RLIMIT_MSGQUEUE)) {
14676 + task_rlimit(p, RLIMIT_MSGQUEUE) ||
14677 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14678 spin_unlock(&mq_lock);
14679 /* mqueue_evict_inode() releases info->messages */
14682 u->mq_bytes += mq_bytes;
14683 + vx_ipcmsg_add(vxi, u, mq_bytes);
14684 spin_unlock(&mq_lock);
14687 info->user = get_uid(u);
14688 + info->vxi = get_vx_info(vxi);
14689 } else if (S_ISDIR(mode)) {
14691 /* Some things misbehave if size == 0 on a directory */
14692 @@ -275,8 +283,11 @@ static void mqueue_evict_inode(struct in
14693 + info->attr.mq_msgsize);
14696 + struct vx_info *vxi = info->vxi;
14698 spin_lock(&mq_lock);
14699 user->mq_bytes -= mq_bytes;
14700 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14702 * get_ns_from_inode() ensures that the
14703 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14704 @@ -286,6 +297,7 @@ static void mqueue_evict_inode(struct in
14706 ipc_ns->mq_queues_count--;
14707 spin_unlock(&mq_lock);
14708 + put_vx_info(vxi);
14712 diff -NurpP --minimal linux-2.6.38.1/ipc/msg.c linux-2.6.38.1-vs2.3.0.37-rc9/ipc/msg.c
14713 --- linux-2.6.38.1/ipc/msg.c 2010-08-02 16:52:57.000000000 +0200
14714 +++ linux-2.6.38.1-vs2.3.0.37-rc9/ipc/msg.c 2011-01-29 02:01:07.000000000 +0100
14716 #include <linux/rwsem.h>
14717 #include <linux/nsproxy.h>
14718 #include <linux/ipc_namespace.h>
14719 +#include <linux/vs_base.h>
14721 #include <asm/current.h>
14722 #include <asm/uaccess.h>
14723 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14725 msq->q_perm.mode = msgflg & S_IRWXUGO;
14726 msq->q_perm.key = key;
14727 + msq->q_perm.xid = vx_current_xid();
14729 msq->q_perm.security = NULL;
14730 retval = security_msg_queue_alloc(msq);
14731 diff -NurpP --minimal linux-2.6.38.1/ipc/namespace.c linux-2.6.38.1-vs2.3.0.37-rc9/ipc/namespace.c
14732 --- linux-2.6.38.1/ipc/namespace.c 2009-09-10 15:26:27.000000000 +0200
14733 +++ linux-2.6.38.1-vs2.3.0.37-rc9/ipc/namespace.c 2011-01-29 02:01:07.000000000 +0100
14735 #include <linux/slab.h>
14736 #include <linux/fs.h>
14737 #include <linux/mount.h>
14738 +#include <linux/vs_base.h>
14739 +#include <linux/vserver/global.h>
14743 diff -NurpP --minimal linux-2.6.38.1/ipc/sem.c linux-2.6.38.1-vs2.3.0.37-rc9/ipc/sem.c
14744 --- linux-2.6.38.1/ipc/sem.c 2010-10-21 13:07:56.000000000 +0200
14745 +++ linux-2.6.38.1-vs2.3.0.37-rc9/ipc/sem.c 2011-01-29 02:01:07.000000000 +0100
14747 #include <linux/rwsem.h>
14748 #include <linux/nsproxy.h>
14749 #include <linux/ipc_namespace.h>
14750 +#include <linux/vs_base.h>
14751 +#include <linux/vs_limit.h>
14753 #include <asm/uaccess.h>
14755 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
14757 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14758 sma->sem_perm.key = key;
14759 + sma->sem_perm.xid = vx_current_xid();
14761 sma->sem_perm.security = NULL;
14762 retval = security_sem_alloc(sma);
14763 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
14766 ns->used_sems += nsems;
14767 + /* FIXME: obsoleted? */
14768 + vx_semary_inc(sma);
14769 + vx_nsems_add(sma, nsems);
14771 sma->sem_base = (struct sem *) &sma[1];
14773 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
14775 wake_up_sem_queue_do(&tasks);
14776 ns->used_sems -= sma->sem_nsems;
14777 + /* FIXME: obsoleted? */
14778 + vx_nsems_sub(sma, sma->sem_nsems);
14779 + vx_semary_dec(sma);
14780 security_sem_free(sma);
14781 ipc_rcu_putref(sma);
14783 diff -NurpP --minimal linux-2.6.38.1/ipc/shm.c linux-2.6.38.1-vs2.3.0.37-rc9/ipc/shm.c
14784 --- linux-2.6.38.1/ipc/shm.c 2011-01-05 21:50:37.000000000 +0100
14785 +++ linux-2.6.38.1-vs2.3.0.37-rc9/ipc/shm.c 2011-01-29 02:01:07.000000000 +0100
14787 #include <linux/nsproxy.h>
14788 #include <linux/mount.h>
14789 #include <linux/ipc_namespace.h>
14790 +#include <linux/vs_context.h>
14791 +#include <linux/vs_limit.h>
14793 #include <asm/uaccess.h>
14795 @@ -173,7 +175,12 @@ static void shm_open(struct vm_area_stru
14797 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14799 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14800 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14801 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14803 + vx_ipcshm_sub(vxi, shp, numpages);
14804 + ns->shm_tot -= numpages;
14808 if (!is_file_hugepages(shp->shm_file))
14809 @@ -183,6 +190,7 @@ static void shm_destroy(struct ipc_names
14811 fput (shp->shm_file);
14812 security_shm_free(shp);
14813 + put_vx_info(vxi);
14814 ipc_rcu_putref(shp);
14817 @@ -355,11 +363,15 @@ static int newseg(struct ipc_namespace *
14818 if (ns->shm_tot + numpages > ns->shm_ctlall)
14821 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14824 shp = ipc_rcu_alloc(sizeof(*shp));
14828 shp->shm_perm.key = key;
14829 + shp->shm_perm.xid = vx_current_xid();
14830 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14831 shp->mlock_user = NULL;
14833 @@ -413,6 +425,7 @@ static int newseg(struct ipc_namespace *
14834 ns->shm_tot += numpages;
14835 error = shp->shm_perm.id;
14837 + vx_ipcshm_add(current_vx_info(), key, numpages);
14841 diff -NurpP --minimal linux-2.6.38.1/kernel/Makefile linux-2.6.38.1-vs2.3.0.37-rc9/kernel/Makefile
14842 --- linux-2.6.38.1/kernel/Makefile 2011-03-15 18:07:41.000000000 +0100
14843 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/Makefile 2011-01-29 02:01:07.000000000 +0100
14844 @@ -25,6 +25,7 @@ CFLAGS_REMOVE_perf_event.o = -pg
14845 CFLAGS_REMOVE_irq_work.o = -pg
14849 obj-$(CONFIG_FREEZER) += freezer.o
14850 obj-$(CONFIG_PROFILING) += profile.o
14851 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
14852 diff -NurpP --minimal linux-2.6.38.1/kernel/capability.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/capability.c
14853 --- linux-2.6.38.1/kernel/capability.c 2011-03-15 18:07:41.000000000 +0100
14854 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/capability.c 2011-02-17 02:17:51.000000000 +0100
14856 #include <linux/security.h>
14857 #include <linux/syscalls.h>
14858 #include <linux/pid_namespace.h>
14859 +#include <linux/vs_context.h>
14860 #include <asm/uaccess.h>
14863 @@ -119,6 +120,7 @@ static int cap_validate_magic(cap_user_h
14869 * The only thing that can change the capabilities of the current
14870 * process is the current process. As such, we can't be in this code
14871 @@ -289,6 +291,8 @@ error:
14875 +#include <linux/vserver/base.h>
14878 * capable - Determine if the current task has a superior capability in effect
14879 * @cap: The capability to be tested for
14880 @@ -301,6 +305,9 @@ error:
14882 int capable(int cap)
14884 + /* here for now so we don't require task locking */
14885 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
14887 if (unlikely(!cap_valid(cap))) {
14888 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
14890 diff -NurpP --minimal linux-2.6.38.1/kernel/compat.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/compat.c
14891 --- linux-2.6.38.1/kernel/compat.c 2010-10-21 13:07:56.000000000 +0200
14892 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/compat.c 2011-01-29 02:01:07.000000000 +0100
14893 @@ -914,7 +914,7 @@ asmlinkage long compat_sys_stime(compat_
14897 - do_settimeofday(&tv);
14898 + vx_settimeofday(&tv);
14902 diff -NurpP --minimal linux-2.6.38.1/kernel/cred.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/cred.c
14903 --- linux-2.6.38.1/kernel/cred.c 2011-03-15 18:07:41.000000000 +0100
14904 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/cred.c 2011-02-17 02:17:51.000000000 +0100
14905 @@ -60,31 +60,6 @@ struct cred init_cred = {
14909 -static inline void set_cred_subscribers(struct cred *cred, int n)
14911 -#ifdef CONFIG_DEBUG_CREDENTIALS
14912 - atomic_set(&cred->subscribers, n);
14916 -static inline int read_cred_subscribers(const struct cred *cred)
14918 -#ifdef CONFIG_DEBUG_CREDENTIALS
14919 - return atomic_read(&cred->subscribers);
14925 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14927 -#ifdef CONFIG_DEBUG_CREDENTIALS
14928 - struct cred *cred = (struct cred *) _cred;
14930 - atomic_add(n, &cred->subscribers);
14935 * Dispose of the shared task group credentials
14937 @@ -280,21 +255,16 @@ error:
14939 * Call commit_creds() or abort_creds() to clean up.
14941 -struct cred *prepare_creds(void)
14942 +struct cred *__prepare_creds(const struct cred *old)
14944 - struct task_struct *task = current;
14945 - const struct cred *old;
14948 - validate_process_creds();
14950 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14954 kdebug("prepare_creds() alloc %p", new);
14956 - old = task->cred;
14957 memcpy(new, old, sizeof(struct cred));
14959 atomic_set(&new->usage, 1);
14960 @@ -321,6 +291,13 @@ error:
14965 +struct cred *prepare_creds(void)
14967 + validate_process_creds();
14969 + return __prepare_creds(current->cred);
14971 EXPORT_SYMBOL(prepare_creds);
14974 diff -NurpP --minimal linux-2.6.38.1/kernel/exit.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/exit.c
14975 --- linux-2.6.38.1/kernel/exit.c 2011-03-15 18:07:41.000000000 +0100
14976 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/exit.c 2011-01-29 02:01:07.000000000 +0100
14978 #include <linux/fs_struct.h>
14979 #include <linux/init_task.h>
14980 #include <linux/perf_event.h>
14981 +#include <linux/vs_limit.h>
14982 +#include <linux/vs_context.h>
14983 +#include <linux/vs_network.h>
14984 +#include <linux/vs_pid.h>
14985 #include <trace/events/sched.h>
14986 #include <linux/hw_breakpoint.h>
14987 #include <linux/oom.h>
14988 @@ -494,9 +498,11 @@ static void close_files(struct files_str
14989 filp_close(file, files);
14992 + vx_openfd_dec(i);
15000 @@ -1047,11 +1053,16 @@ NORET_TYPE void do_exit(long code)
15002 validate_creds_for_do_exit(tsk);
15004 + /* needs to stay after exit_notify() */
15005 + exit_vx_info(tsk, code);
15006 + exit_nx_info(tsk);
15010 /* causes final put_task_struct in finish_task_switch(). */
15011 tsk->state = TASK_DEAD;
15013 + printk("bad task: %p [%lx]\n", current, current->state);
15015 /* Avoid "noreturn function does return". */
15017 diff -NurpP --minimal linux-2.6.38.1/kernel/fork.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/fork.c
15018 --- linux-2.6.38.1/kernel/fork.c 2011-03-15 18:07:41.000000000 +0100
15019 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/fork.c 2011-01-29 03:19:29.000000000 +0100
15021 #include <linux/user-return-notifier.h>
15022 #include <linux/oom.h>
15023 #include <linux/khugepaged.h>
15024 +#include <linux/vs_context.h>
15025 +#include <linux/vs_network.h>
15026 +#include <linux/vs_limit.h>
15027 +#include <linux/vs_memory.h>
15029 #include <asm/pgtable.h>
15030 #include <asm/pgalloc.h>
15031 @@ -162,6 +166,8 @@ void free_task(struct task_struct *tsk)
15032 account_kernel_stack(tsk->stack, -1);
15033 free_thread_info(tsk->stack);
15034 rt_mutex_debug_task_free(tsk);
15035 + clr_vx_info(&tsk->vx_info);
15036 + clr_nx_info(&tsk->nx_info);
15037 ftrace_graph_exit_task(tsk);
15038 free_task_struct(tsk);
15040 @@ -500,6 +506,7 @@ static struct mm_struct * mm_init(struct
15041 if (likely(!mm_alloc_pgd(mm))) {
15043 mmu_notifier_mm_init(mm);
15044 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15048 @@ -536,6 +543,7 @@ void __mmdrop(struct mm_struct *mm)
15049 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
15050 VM_BUG_ON(mm->pmd_huge_pte);
15052 + clr_vx_info(&mm->mm_vx_info);
15055 EXPORT_SYMBOL_GPL(__mmdrop);
15056 @@ -672,6 +680,7 @@ struct mm_struct *dup_mm(struct task_str
15059 memcpy(mm, oldmm, sizeof(*mm));
15060 + mm->mm_vx_info = NULL;
15062 /* Initializing for Swap token stuff */
15063 mm->token_priority = 0;
15064 @@ -714,6 +723,7 @@ fail_nocontext:
15065 * If init_new_context() failed, we cannot use mmput() to free the mm
15066 * because it calls destroy_context()
15068 + clr_vx_info(&mm->mm_vx_info);
15072 @@ -995,6 +1005,8 @@ static struct task_struct *copy_process(
15074 struct task_struct *p;
15075 int cgroup_callbacks_done = 0;
15076 + struct vx_info *vxi;
15077 + struct nx_info *nxi;
15079 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15080 return ERR_PTR(-EINVAL);
15081 @@ -1041,7 +1053,12 @@ static struct task_struct *copy_process(
15082 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15083 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15085 + init_vx_info(&p->vx_info, current_vx_info());
15086 + init_nx_info(&p->nx_info, current_nx_info());
15089 + if (!vx_nproc_avail(1))
15090 + goto bad_fork_free;
15091 if (atomic_read(&p->real_cred->user->processes) >=
15092 task_rlimit(p, RLIMIT_NPROC)) {
15093 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15094 @@ -1306,6 +1323,18 @@ static struct task_struct *copy_process(
15097 spin_unlock(¤t->sighand->siglock);
15099 + /* p is copy of current */
15100 + vxi = p->vx_info;
15102 + claim_vx_info(vxi, p);
15103 + atomic_inc(&vxi->cvirt.nr_threads);
15104 + atomic_inc(&vxi->cvirt.total_forks);
15107 + nxi = p->nx_info;
15109 + claim_nx_info(nxi, p);
15110 write_unlock_irq(&tasklist_lock);
15111 proc_fork_connector(p);
15112 cgroup_post_fork(p);
15113 diff -NurpP --minimal linux-2.6.38.1/kernel/kthread.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/kthread.c
15114 --- linux-2.6.38.1/kernel/kthread.c 2011-03-15 18:07:41.000000000 +0100
15115 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/kthread.c 2011-01-29 02:01:07.000000000 +0100
15117 #include <linux/mutex.h>
15118 #include <linux/slab.h>
15119 #include <linux/freezer.h>
15120 +#include <linux/vs_pid.h>
15121 #include <trace/events/sched.h>
15123 static DEFINE_SPINLOCK(kthread_create_lock);
15124 diff -NurpP --minimal linux-2.6.38.1/kernel/nsproxy.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/nsproxy.c
15125 --- linux-2.6.38.1/kernel/nsproxy.c 2010-07-07 18:31:57.000000000 +0200
15126 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/nsproxy.c 2011-01-29 02:01:07.000000000 +0100
15128 #include <linux/mnt_namespace.h>
15129 #include <linux/utsname.h>
15130 #include <linux/pid_namespace.h>
15131 +#include <linux/vserver/global.h>
15132 +#include <linux/vserver/debug.h>
15133 #include <net/net_namespace.h>
15134 #include <linux/ipc_namespace.h>
15136 @@ -43,8 +45,11 @@ static inline struct nsproxy *create_nsp
15137 struct nsproxy *nsproxy;
15139 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
15142 atomic_set(&nsproxy->count, 1);
15143 + atomic_inc(&vs_global_nsproxy);
15145 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
15149 @@ -53,41 +58,52 @@ static inline struct nsproxy *create_nsp
15150 * Return the newly created nsproxy. Do not attach this to the task,
15151 * leave it to the caller to do proper locking and attach it to task.
15153 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15154 - struct task_struct *tsk, struct fs_struct *new_fs)
15155 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15156 + struct nsproxy *orig, struct fs_struct *new_fs)
15158 struct nsproxy *new_nsp;
15161 + vxdprintk(VXD_CBIT(space, 4),
15162 + "unshare_namespaces(0x%08lx,%p,%p)",
15163 + flags, orig, new_fs);
15165 new_nsp = create_nsproxy();
15167 return ERR_PTR(-ENOMEM);
15169 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15170 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15171 if (IS_ERR(new_nsp->mnt_ns)) {
15172 err = PTR_ERR(new_nsp->mnt_ns);
15176 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15177 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15178 if (IS_ERR(new_nsp->uts_ns)) {
15179 err = PTR_ERR(new_nsp->uts_ns);
15183 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15184 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15185 if (IS_ERR(new_nsp->ipc_ns)) {
15186 err = PTR_ERR(new_nsp->ipc_ns);
15190 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15191 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15192 if (IS_ERR(new_nsp->pid_ns)) {
15193 err = PTR_ERR(new_nsp->pid_ns);
15197 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15199 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15200 + if (IS_ERR(new_nsp->user_ns)) {
15201 + err = PTR_ERR(new_nsp->user_ns);
15205 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15206 if (IS_ERR(new_nsp->net_ns)) {
15207 err = PTR_ERR(new_nsp->net_ns);
15209 @@ -112,6 +128,38 @@ out_ns:
15210 return ERR_PTR(err);
15213 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15214 + struct fs_struct *new_fs)
15216 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15220 + * copies the nsproxy, setting refcount to 1, and grabbing a
15221 + * reference to all contained namespaces.
15223 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15225 + struct nsproxy *ns = create_nsproxy();
15228 + memcpy(ns, orig, sizeof(struct nsproxy));
15229 + atomic_set(&ns->count, 1);
15232 + get_mnt_ns(ns->mnt_ns);
15234 + get_uts_ns(ns->uts_ns);
15236 + get_ipc_ns(ns->ipc_ns);
15238 + get_pid_ns(ns->pid_ns);
15240 + get_net(ns->net_ns);
15246 * called from clone. This now handles copy for nsproxy and all
15247 * namespaces therein.
15248 @@ -119,9 +167,12 @@ out_ns:
15249 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15251 struct nsproxy *old_ns = tsk->nsproxy;
15252 - struct nsproxy *new_ns;
15253 + struct nsproxy *new_ns = NULL;
15256 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15257 + flags, tsk, old_ns);
15262 @@ -131,7 +182,7 @@ int copy_namespaces(unsigned long flags,
15263 CLONE_NEWPID | CLONE_NEWNET)))
15266 - if (!capable(CAP_SYS_ADMIN)) {
15267 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
15271 @@ -158,6 +209,9 @@ int copy_namespaces(unsigned long flags,
15274 put_nsproxy(old_ns);
15275 + vxdprintk(VXD_CBIT(space, 3),
15276 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15277 + flags, tsk, old_ns, err, new_ns);
15281 @@ -171,7 +225,9 @@ void free_nsproxy(struct nsproxy *ns)
15282 put_ipc_ns(ns->ipc_ns);
15284 put_pid_ns(ns->pid_ns);
15285 - put_net(ns->net_ns);
15287 + put_net(ns->net_ns);
15288 + atomic_dec(&vs_global_nsproxy);
15289 kmem_cache_free(nsproxy_cachep, ns);
15292 @@ -184,11 +240,15 @@ int unshare_nsproxy_namespaces(unsigned
15296 + vxdprintk(VXD_CBIT(space, 4),
15297 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15298 + unshare_flags, current->nsproxy);
15300 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15304 - if (!capable(CAP_SYS_ADMIN))
15305 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
15308 *new_nsp = create_new_namespaces(unshare_flags, current,
15309 diff -NurpP --minimal linux-2.6.38.1/kernel/pid.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/pid.c
15310 --- linux-2.6.38.1/kernel/pid.c 2011-01-05 21:50:38.000000000 +0100
15311 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/pid.c 2011-01-29 02:01:07.000000000 +0100
15313 #include <linux/pid_namespace.h>
15314 #include <linux/init_task.h>
15315 #include <linux/syscalls.h>
15316 +#include <linux/vs_pid.h>
15318 #define pid_hashfn(nr, ns) \
15319 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15320 @@ -339,7 +340,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15322 struct pid *find_vpid(int nr)
15324 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15325 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15327 EXPORT_SYMBOL_GPL(find_vpid);
15329 @@ -399,6 +400,9 @@ void transfer_pid(struct task_struct *ol
15330 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15332 struct task_struct *result = NULL;
15334 + if (type == PIDTYPE_REALPID)
15335 + type = PIDTYPE_PID;
15337 struct hlist_node *first;
15338 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
15339 @@ -417,7 +421,7 @@ EXPORT_SYMBOL(pid_task);
15340 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15342 rcu_lockdep_assert(rcu_read_lock_held());
15343 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15344 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15347 struct task_struct *find_task_by_vpid(pid_t vnr)
15348 @@ -459,7 +463,7 @@ struct pid *find_get_pid(pid_t nr)
15350 EXPORT_SYMBOL_GPL(find_get_pid);
15352 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15353 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15357 @@ -472,6 +476,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15361 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15363 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15366 pid_t pid_vnr(struct pid *pid)
15368 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15369 diff -NurpP --minimal linux-2.6.38.1/kernel/pid_namespace.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/pid_namespace.c
15370 --- linux-2.6.38.1/kernel/pid_namespace.c 2010-07-07 18:31:57.000000000 +0200
15371 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/pid_namespace.c 2011-01-29 02:01:07.000000000 +0100
15373 #include <linux/err.h>
15374 #include <linux/acct.h>
15375 #include <linux/slab.h>
15376 +#include <linux/vserver/global.h>
15378 #define BITS_PER_PAGE (PAGE_SIZE*8)
15380 @@ -87,6 +88,7 @@ static struct pid_namespace *create_pid_
15383 kref_init(&ns->kref);
15384 + atomic_inc(&vs_global_pid_ns);
15386 ns->parent = get_pid_ns(parent_pid_ns);
15388 @@ -112,6 +114,7 @@ static void destroy_pid_namespace(struct
15390 for (i = 0; i < PIDMAP_ENTRIES; i++)
15391 kfree(ns->pidmap[i].page);
15392 + atomic_dec(&vs_global_pid_ns);
15393 kmem_cache_free(pid_ns_cachep, ns);
15396 diff -NurpP --minimal linux-2.6.38.1/kernel/posix-timers.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/posix-timers.c
15397 --- linux-2.6.38.1/kernel/posix-timers.c 2011-03-15 18:07:42.000000000 +0100
15398 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/posix-timers.c 2011-01-29 02:01:07.000000000 +0100
15400 #include <linux/wait.h>
15401 #include <linux/workqueue.h>
15402 #include <linux/module.h>
15403 +#include <linux/vs_context.h>
15406 * Management arrays for POSIX timers. Timers are kept in slab memory
15407 @@ -369,6 +370,7 @@ int posix_timer_event(struct k_itimer *t
15409 struct task_struct *task;
15410 int shared, ret = -1;
15413 * FIXME: if ->sigq is queued we can race with
15414 * dequeue_signal()->do_schedule_next_timer().
15415 @@ -385,10 +387,18 @@ int posix_timer_event(struct k_itimer *t
15417 task = pid_task(timr->it_pid, PIDTYPE_PID);
15419 + struct vx_info_save vxis;
15420 + struct vx_info *vxi;
15422 + vxi = get_vx_info(task->vx_info);
15423 + enter_vx_info(vxi, &vxis);
15424 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15425 ret = send_sigqueue(timr->sigq, task, shared);
15426 + leave_vx_info(&vxis);
15427 + put_vx_info(vxi);
15431 /* If we failed to send the signal the timer stops. */
15434 diff -NurpP --minimal linux-2.6.38.1/kernel/printk.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/printk.c
15435 --- linux-2.6.38.1/kernel/printk.c 2011-03-15 18:07:42.000000000 +0100
15436 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/printk.c 2011-02-17 02:34:59.000000000 +0100
15438 #include <linux/cpu.h>
15439 #include <linux/notifier.h>
15440 #include <linux/rculist.h>
15441 +#include <linux/vs_cvirt.h>
15443 #include <asm/uaccess.h>
15445 @@ -280,7 +281,7 @@ static int check_syslog_permissions(int
15448 if (syslog_action_restricted(type)) {
15449 - if (capable(CAP_SYSLOG))
15450 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
15452 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
15453 if (capable(CAP_SYS_ADMIN)) {
15454 @@ -308,12 +309,9 @@ int do_syslog(int type, char __user *buf
15459 - case SYSLOG_ACTION_CLOSE: /* Close log */
15461 - case SYSLOG_ACTION_OPEN: /* Open log */
15463 - case SYSLOG_ACTION_READ: /* Read from log */
15464 + if ((type == SYSLOG_ACTION_READ) ||
15465 + (type == SYSLOG_ACTION_READ_ALL) ||
15466 + (type == SYSLOG_ACTION_READ_CLEAR)) {
15468 if (!buf || len < 0)
15470 @@ -324,6 +322,16 @@ int do_syslog(int type, char __user *buf
15475 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15476 + return vx_do_syslog(type, buf, len);
15479 + case SYSLOG_ACTION_CLOSE: /* Close log */
15481 + case SYSLOG_ACTION_OPEN: /* Open log */
15483 + case SYSLOG_ACTION_READ: /* Read from log */
15484 error = wait_event_interruptible(log_wait,
15485 (log_start - log_end));
15487 @@ -350,16 +358,6 @@ int do_syslog(int type, char __user *buf
15489 /* Read last kernel messages */
15490 case SYSLOG_ACTION_READ_ALL:
15492 - if (!buf || len < 0)
15497 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15502 if (count > log_buf_len)
15503 count = log_buf_len;
15504 diff -NurpP --minimal linux-2.6.38.1/kernel/ptrace.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/ptrace.c
15505 --- linux-2.6.38.1/kernel/ptrace.c 2011-03-15 18:07:42.000000000 +0100
15506 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/ptrace.c 2011-03-10 17:21:19.000000000 +0100
15508 #include <linux/syscalls.h>
15509 #include <linux/uaccess.h>
15510 #include <linux/regset.h>
15511 +#include <linux/vs_context.h>
15515 @@ -150,6 +151,11 @@ int __ptrace_may_access(struct task_stru
15516 dumpable = get_dumpable(task->mm);
15517 if (!dumpable && !capable(CAP_SYS_PTRACE))
15519 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
15521 + if (!vx_check(task->xid, VS_IDENT) &&
15522 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15525 return security_ptrace_access_check(task, mode);
15527 @@ -713,6 +719,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
15532 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
15533 + goto out_put_task_struct;
15535 if (request == PTRACE_ATTACH) {
15536 ret = ptrace_attach(child);
15538 diff -NurpP --minimal linux-2.6.38.1/kernel/sched.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/sched.c
15539 --- linux-2.6.38.1/kernel/sched.c 2011-03-26 01:10:17.000000000 +0100
15540 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/sched.c 2011-03-25 22:52:15.000000000 +0100
15542 #include <linux/ctype.h>
15543 #include <linux/ftrace.h>
15544 #include <linux/slab.h>
15545 +#include <linux/vs_sched.h>
15546 +#include <linux/vs_cvirt.h>
15548 #include <asm/tlb.h>
15549 #include <asm/irq_regs.h>
15550 @@ -3228,9 +3230,17 @@ static void calc_global_nohz(unsigned lo
15552 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
15554 - loads[0] = (avenrun[0] + offset) << shift;
15555 - loads[1] = (avenrun[1] + offset) << shift;
15556 - loads[2] = (avenrun[2] + offset) << shift;
15557 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
15558 + struct vx_info *vxi = current_vx_info();
15560 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
15561 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
15562 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
15564 + loads[0] = (avenrun[0] + offset) << shift;
15565 + loads[1] = (avenrun[1] + offset) << shift;
15566 + loads[2] = (avenrun[2] + offset) << shift;
15571 @@ -3518,16 +3528,19 @@ void account_user_time(struct task_struc
15572 cputime_t cputime_scaled)
15574 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15575 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15577 + int nice = (TASK_NICE(p) > 0);
15579 /* Add user time to process. */
15580 p->utime = cputime_add(p->utime, cputime);
15581 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15582 + vx_account_user(vxi, cputime, nice);
15583 account_group_user_time(p, cputime);
15585 /* Add user time to cpustat. */
15586 tmp = cputime_to_cputime64(cputime);
15587 - if (TASK_NICE(p) > 0)
15589 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15591 cpustat->user = cputime64_add(cpustat->user, tmp);
15592 @@ -3578,6 +3591,7 @@ void account_system_time(struct task_str
15593 cputime_t cputime, cputime_t cputime_scaled)
15595 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15596 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15599 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
15600 @@ -3588,6 +3602,7 @@ void account_system_time(struct task_str
15601 /* Add system time to process. */
15602 p->stime = cputime_add(p->stime, cputime);
15603 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15604 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15605 account_group_system_time(p, cputime);
15607 /* Add system time to cpustat. */
15608 @@ -4672,7 +4687,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15611 if (increment < 0 && !can_nice(current, nice))
15613 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15615 retval = security_task_setnice(current, nice);
15617 diff -NurpP --minimal linux-2.6.38.1/kernel/sched_fair.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/sched_fair.c
15618 --- linux-2.6.38.1/kernel/sched_fair.c 2011-03-15 18:07:42.000000000 +0100
15619 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/sched_fair.c 2011-02-02 22:20:27.000000000 +0100
15620 @@ -992,6 +992,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15621 __enqueue_entity(cfs_rq, se);
15624 + if (entity_is_task(se))
15625 + vx_activate_task(task_of(se));
15626 if (cfs_rq->nr_running == 1)
15627 list_add_leaf_cfs_rq(cfs_rq);
15629 @@ -1038,6 +1040,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15630 if (se != cfs_rq->curr)
15631 __dequeue_entity(cfs_rq, se);
15633 + if (entity_is_task(se))
15634 + vx_deactivate_task(task_of(se));
15635 update_cfs_load(cfs_rq, 0);
15636 account_entity_dequeue(cfs_rq, se);
15637 update_min_vruntime(cfs_rq);
15638 diff -NurpP --minimal linux-2.6.38.1/kernel/signal.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/signal.c
15639 --- linux-2.6.38.1/kernel/signal.c 2011-01-05 21:50:38.000000000 +0100
15640 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/signal.c 2011-01-29 02:01:07.000000000 +0100
15642 #include <linux/freezer.h>
15643 #include <linux/pid_namespace.h>
15644 #include <linux/nsproxy.h>
15645 +#include <linux/vs_context.h>
15646 +#include <linux/vs_pid.h>
15647 #define CREATE_TRACE_POINTS
15648 #include <trace/events/signal.h>
15650 @@ -646,9 +648,18 @@ static int check_kill_permission(int sig
15654 + vxdprintk(VXD_CBIT(misc, 7),
15655 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15656 + sig, info, t, vx_task_xid(t), t->pid);
15658 if (!valid_signal(sig))
15661 +/* FIXME: needed? if so, why?
15662 + if ((info != SEND_SIG_NOINFO) &&
15663 + (is_si_special(info) || !si_fromuser(info)))
15666 if (!si_fromuser(info))
15669 @@ -678,6 +689,20 @@ static int check_kill_permission(int sig
15674 + if (t->pid == 1 && current->xid)
15678 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15679 + loops, maybe ENOENT or EACCES? */
15680 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15681 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15682 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15683 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15687 return security_task_kill(t, info, sig, 0);
15690 @@ -1171,7 +1196,7 @@ int kill_pid_info(int sig, struct siginf
15693 p = pid_task(pid, PIDTYPE_PID);
15695 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15696 error = group_send_sig_info(sig, info, p);
15697 if (unlikely(error == -ESRCH))
15699 @@ -1211,7 +1236,7 @@ int kill_pid_info_as_uid(int sig, struct
15702 p = pid_task(pid, PIDTYPE_PID);
15704 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15708 @@ -1266,8 +1291,10 @@ static int kill_something_info(int sig,
15709 struct task_struct * p;
15711 for_each_process(p) {
15712 - if (task_pid_vnr(p) > 1 &&
15713 - !same_thread_group(p, current)) {
15714 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15715 + task_pid_vnr(p) > 1 &&
15716 + !same_thread_group(p, current) &&
15717 + !vx_current_initpid(p->pid)) {
15718 int err = group_send_sig_info(sig, info, p);
15721 @@ -1936,6 +1963,11 @@ relock:
15722 !sig_kernel_only(signr))
15725 + /* virtual init is protected against user signals */
15726 + if ((info->si_code == SI_USER) &&
15727 + vx_current_initpid(current->pid))
15730 if (sig_kernel_stop(signr)) {
15732 * The default action is to stop all threads in
15733 diff -NurpP --minimal linux-2.6.38.1/kernel/softirq.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/softirq.c
15734 --- linux-2.6.38.1/kernel/softirq.c 2011-03-15 18:07:42.000000000 +0100
15735 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/softirq.c 2011-01-29 02:01:07.000000000 +0100
15737 #include <linux/ftrace.h>
15738 #include <linux/smp.h>
15739 #include <linux/tick.h>
15740 +#include <linux/vs_context.h>
15742 #define CREATE_TRACE_POINTS
15743 #include <trace/events/irq.h>
15744 diff -NurpP --minimal linux-2.6.38.1/kernel/sys.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/sys.c
15745 --- linux-2.6.38.1/kernel/sys.c 2011-03-15 18:07:42.000000000 +0100
15746 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/sys.c 2011-02-02 22:20:27.000000000 +0100
15748 #include <linux/syscalls.h>
15749 #include <linux/kprobes.h>
15750 #include <linux/user_namespace.h>
15751 +#include <linux/vs_pid.h>
15753 #include <linux/kmsg_dump.h>
15755 @@ -133,7 +134,10 @@ static int set_one_prio(struct task_stru
15758 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15760 + if (vx_flags(VXF_IGNEG_NICE, 0))
15766 no_nice = security_task_setnice(p, niceval);
15767 @@ -183,6 +187,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15769 pgrp = task_pgrp(current);
15770 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15771 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15773 error = set_one_prio(p, niceval, error);
15774 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15776 @@ -246,6 +252,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15778 pgrp = task_pgrp(current);
15779 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15780 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15782 niceval = 20 - task_nice(p);
15783 if (niceval > retval)
15785 @@ -363,6 +371,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15787 static DEFINE_MUTEX(reboot_mutex);
15789 +long vs_reboot(unsigned int, void __user *);
15792 * Reboot system call: for obvious reasons only root may call it,
15793 * and even root needs to set up some magic numbers in the registers
15794 @@ -395,6 +405,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15795 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15796 cmd = LINUX_REBOOT_CMD_HALT;
15798 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15799 + return vs_reboot(cmd, arg);
15801 mutex_lock(&reboot_mutex);
15803 case LINUX_REBOOT_CMD_RESTART:
15804 @@ -1177,7 +1190,7 @@ SYSCALL_DEFINE2(sethostname, char __user
15806 char tmp[__NEW_UTS_LEN];
15808 - if (!capable(CAP_SYS_ADMIN))
15809 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15811 if (len < 0 || len > __NEW_UTS_LEN)
15813 @@ -1226,7 +1239,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
15815 char tmp[__NEW_UTS_LEN];
15817 - if (!capable(CAP_SYS_ADMIN))
15818 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15820 if (len < 0 || len > __NEW_UTS_LEN)
15822 @@ -1342,7 +1355,7 @@ int do_prlimit(struct task_struct *tsk,
15823 task_lock(tsk->group_leader);
15825 if (new_rlim->rlim_max > rlim->rlim_max &&
15826 - !capable(CAP_SYS_RESOURCE))
15827 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15830 retval = security_task_setrlimit(tsk->group_leader,
15831 @@ -1392,7 +1405,7 @@ static int check_prlimit_permission(stru
15832 cred->gid != tcred->egid ||
15833 cred->gid != tcred->sgid ||
15834 cred->gid != tcred->gid) &&
15835 - !capable(CAP_SYS_RESOURCE)) {
15836 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT)) {
15840 diff -NurpP --minimal linux-2.6.38.1/kernel/sysctl.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/sysctl.c
15841 --- linux-2.6.38.1/kernel/sysctl.c 2011-03-15 18:07:42.000000000 +0100
15842 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/sysctl.c 2011-03-15 18:15:06.000000000 +0100
15844 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15845 #include <linux/lockdep.h>
15847 +extern char vshelper_path[];
15848 #ifdef CONFIG_CHR_DEV_SG
15849 #include <scsi/sg.h>
15851 @@ -568,6 +569,13 @@ static struct ctl_table kern_table[] = {
15852 .proc_handler = proc_dostring,
15856 + .procname = "vshelper",
15857 + .data = &vshelper_path,
15860 + .proc_handler = &proc_dostring,
15862 #ifdef CONFIG_CHR_DEV_SG
15864 .procname = "sg-big-buff",
15865 diff -NurpP --minimal linux-2.6.38.1/kernel/sysctl_binary.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/sysctl_binary.c
15866 --- linux-2.6.38.1/kernel/sysctl_binary.c 2011-03-15 18:07:42.000000000 +0100
15867 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/sysctl_binary.c 2011-01-29 02:01:07.000000000 +0100
15868 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15870 { CTL_INT, KERN_PANIC, "panic" },
15871 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15872 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15874 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15875 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15876 diff -NurpP --minimal linux-2.6.38.1/kernel/time/timekeeping.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/time/timekeeping.c
15877 --- linux-2.6.38.1/kernel/time/timekeeping.c 2011-03-15 18:07:42.000000000 +0100
15878 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/time/timekeeping.c 2011-01-29 02:01:07.000000000 +0100
15879 @@ -233,6 +233,7 @@ void getnstimeofday(struct timespec *ts)
15880 } while (read_seqretry(&xtime_lock, seq));
15882 timespec_add_ns(ts, nsecs);
15883 + vx_adjust_timespec(ts);
15886 EXPORT_SYMBOL(getnstimeofday);
15887 diff -NurpP --minimal linux-2.6.38.1/kernel/time.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/time.c
15888 --- linux-2.6.38.1/kernel/time.c 2011-03-15 18:07:42.000000000 +0100
15889 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/time.c 2011-01-29 02:01:07.000000000 +0100
15890 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15894 - do_settimeofday(&tv);
15895 + vx_settimeofday(&tv);
15899 @@ -177,7 +177,7 @@ int do_sys_settimeofday(struct timespec
15900 /* SMP safe, again the code in arch/foo/time.c should
15901 * globally block out interrupts when it runs.
15903 - return do_settimeofday(tv);
15904 + return vx_settimeofday(tv);
15908 diff -NurpP --minimal linux-2.6.38.1/kernel/timer.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/timer.c
15909 --- linux-2.6.38.1/kernel/timer.c 2011-03-15 18:07:42.000000000 +0100
15910 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/timer.c 2011-02-17 02:17:51.000000000 +0100
15912 #include <linux/irq_work.h>
15913 #include <linux/sched.h>
15914 #include <linux/slab.h>
15915 +#include <linux/vs_base.h>
15916 +#include <linux/vs_cvirt.h>
15917 +#include <linux/vs_pid.h>
15918 +#include <linux/vserver/sched.h>
15920 #include <asm/uaccess.h>
15921 #include <asm/unistd.h>
15922 @@ -1321,12 +1325,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15929 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15930 - * should be moved into arch/i386 instead?
15934 * sys_getpid - return the thread group id of the current process
15935 @@ -1355,10 +1353,23 @@ SYSCALL_DEFINE0(getppid)
15937 pid = task_tgid_vnr(current->real_parent);
15939 + return vx_map_pid(pid);
15946 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15949 +asmlinkage long do_getxpid(long *ppid)
15951 + *ppid = sys_getppid();
15952 + return sys_getpid();
15955 +#else /* _alpha_ */
15957 SYSCALL_DEFINE0(getuid)
15959 /* Only we change this so SMP safe */
15960 diff -NurpP --minimal linux-2.6.38.1/kernel/user_namespace.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/user_namespace.c
15961 --- linux-2.6.38.1/kernel/user_namespace.c 2011-03-15 18:07:42.000000000 +0100
15962 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/user_namespace.c 2011-01-29 02:01:07.000000000 +0100
15964 #include <linux/user_namespace.h>
15965 #include <linux/highuid.h>
15966 #include <linux/cred.h>
15967 +#include <linux/vserver/global.h>
15969 static struct kmem_cache *user_ns_cachep __read_mostly;
15971 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
15974 kref_init(&ns->kref);
15975 + atomic_inc(&vs_global_user_ns);
15977 for (n = 0; n < UIDHASH_SZ; ++n)
15978 INIT_HLIST_HEAD(ns->uidhash_table + n);
15979 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
15980 struct user_namespace *ns =
15981 container_of(kref, struct user_namespace, kref);
15983 + /* FIXME: maybe move into destroyer? */
15984 + atomic_dec(&vs_global_user_ns);
15985 INIT_WORK(&ns->destroyer, free_user_ns_work);
15986 schedule_work(&ns->destroyer);
15988 diff -NurpP --minimal linux-2.6.38.1/kernel/utsname.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/utsname.c
15989 --- linux-2.6.38.1/kernel/utsname.c 2009-09-10 15:26:28.000000000 +0200
15990 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/utsname.c 2011-01-29 02:01:07.000000000 +0100
15991 @@ -14,14 +14,17 @@
15992 #include <linux/utsname.h>
15993 #include <linux/err.h>
15994 #include <linux/slab.h>
15995 +#include <linux/vserver/global.h>
15997 static struct uts_namespace *create_uts_ns(void)
15999 struct uts_namespace *uts_ns;
16001 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
16004 kref_init(&uts_ns->kref);
16005 + atomic_inc(&vs_global_uts_ns);
16010 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
16011 struct uts_namespace *ns;
16013 ns = container_of(kref, struct uts_namespace, kref);
16014 + atomic_dec(&vs_global_uts_ns);
16017 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/Kconfig
16018 --- linux-2.6.38.1/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
16019 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/Kconfig 2011-03-15 21:32:33.000000000 +0100
16022 +# Linux VServer configuration
16025 +menu "Linux VServer"
16027 +config VSERVER_AUTO_LBACK
16028 + bool "Automatically Assign Loopback IP"
16031 + Automatically assign a guest specific loopback
16032 + IP and add it to the kernel network stack on
16035 +config VSERVER_AUTO_SINGLE
16036 + bool "Automatic Single IP Special Casing"
16037 + depends on EXPERIMENTAL
16040 + This allows network contexts with a single IP to
16041 + automatically remap 0.0.0.0 bindings to that IP,
16042 + avoiding further network checks and improving
16045 + (note: such guests do not allow to change the ip
16046 + on the fly and do not show loopback addresses)
16048 +config VSERVER_COWBL
16049 + bool "Enable COW Immutable Link Breaking"
16052 + This enables the COW (Copy-On-Write) link break code.
16053 + It allows you to treat unified files like normal files
16054 + when writing to them (which will implicitely break the
16055 + link and create a copy of the unified file)
16057 +config VSERVER_VTIME
16058 + bool "Enable Virtualized Guest Time"
16059 + depends on EXPERIMENTAL
16062 + This enables per guest time offsets to allow for
16063 + adjusting the system clock individually per guest.
16064 + this adds some overhead to the time functions and
16065 + therefore should not be enabled without good reason.
16067 +config VSERVER_DEVICE
16068 + bool "Enable Guest Device Mapping"
16069 + depends on EXPERIMENTAL
16072 + This enables generic device remapping.
16074 +config VSERVER_PROC_SECURE
16075 + bool "Enable Proc Security"
16076 + depends on PROC_FS
16079 + This configures ProcFS security to initially hide
16080 + non-process entries for all contexts except the main and
16081 + spectator context (i.e. for all guests), which is a secure
16084 + (note: on 1.2x the entries were visible by default)
16087 + prompt "Persistent Inode Tagging"
16088 + default TAGGING_ID24
16090 + This adds persistent context information to filesystems
16091 + mounted with the tagxid option. Tagging is a requirement
16092 + for per-context disk limits and per-context quota.
16095 +config TAGGING_NONE
16098 + do not store per-context information in inodes.
16100 +config TAGGING_UID16
16101 + bool "UID16/GID32"
16103 + reduces UID to 16 bit, but leaves GID at 32 bit.
16105 +config TAGGING_GID16
16106 + bool "UID32/GID16"
16108 + reduces GID to 16 bit, but leaves UID at 32 bit.
16110 +config TAGGING_ID24
16111 + bool "UID24/GID24"
16113 + uses the upper 8bit from UID and GID for XID tagging
16114 + which leaves 24bit for UID/GID each, which should be
16115 + more than sufficient for normal use.
16117 +config TAGGING_INTERN
16118 + bool "UID32/GID32"
16120 + this uses otherwise reserved inode fields in the on
16121 + disk representation, which limits the use to a few
16122 + filesystems (currently ext2 and ext3)
16127 + bool "Tag NFSD User Auth and Files"
16130 + Enable this if you do want the in-kernel NFS
16131 + Server to use the tagging specified above.
16132 + (will require patched clients too)
16134 +config VSERVER_PRIVACY
16135 + bool "Honor Privacy Aspects of Guests"
16138 + When enabled, most context checks will disallow
16139 + access to structures assigned to a specific context,
16140 + like ptys or loop devices.
16142 +config VSERVER_CONTEXTS
16143 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
16145 + default "768" if 64BIT
16148 + This setting will optimize certain data structures
16149 + and memory allocations according to the expected
16152 + note: this is not a strict upper limit.
16154 +config VSERVER_WARN
16155 + bool "VServer Warnings"
16158 + This enables various runtime warnings, which will
16159 + notify about potential manipulation attempts or
16160 + resource shortage. It is generally considered to
16161 + be a good idea to have that enabled.
16163 +config VSERVER_WARN_DEVPTS
16164 + bool "VServer DevPTS Warnings"
16165 + depends on VSERVER_WARN
16168 + This enables DevPTS related warnings, issued when a
16169 + process inside a context tries to lookup or access
16170 + a dynamic pts from the host or a different context.
16172 +config VSERVER_DEBUG
16173 + bool "VServer Debugging Code"
16176 + Set this to yes if you want to be able to activate
16177 + debugging output at runtime. It adds a very small
16178 + overhead to all vserver related functions and
16179 + increases the kernel size by about 20k.
16181 +config VSERVER_HISTORY
16182 + bool "VServer History Tracing"
16183 + depends on VSERVER_DEBUG
16186 + Set this to yes if you want to record the history of
16187 + linux-vserver activities, so they can be replayed in
16188 + the event of a kernel panic or oops.
16190 +config VSERVER_HISTORY_SIZE
16191 + int "Per-CPU History Size (32-65536)"
16192 + depends on VSERVER_HISTORY
16196 + This allows you to specify the number of entries in
16197 + the per-CPU history buffer.
16199 +config VSERVER_LEGACY_MEM
16200 + bool "Legacy Memory Limits"
16203 + This provides fake memory limits to keep
16204 + older tools happy in the face of memory
16208 + prompt "Quotes used in debug and warn messages"
16209 + default QUOTES_ISO8859
16211 +config QUOTES_ISO8859
16212 + bool "Extended ASCII (ISO 8859) angle quotes"
16214 + This uses the extended ASCII characters \xbb
16215 + and \xab for quoting file and process names.
16217 +config QUOTES_UTF8
16218 + bool "UTF-8 angle quotes"
16220 + This uses the the UTF-8 sequences for angle
16221 + quotes to quote file and process names.
16223 +config QUOTES_ASCII
16224 + bool "ASCII single quotes"
16226 + This uses the ASCII single quote character
16227 + (\x27) to quote file and process names.
16237 + select NAMESPACES
16243 +config VSERVER_SECURITY
16245 + depends on SECURITY
16247 + select SECURITY_CAPABILITIES
16249 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/Makefile linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/Makefile
16250 --- linux-2.6.38.1/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
16251 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/Makefile 2011-01-29 02:01:07.000000000 +0100
16254 +# Makefile for the Linux vserver routines.
16258 +obj-y += vserver.o
16260 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
16261 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
16264 +vserver-$(CONFIG_INET) += inet.o
16265 +vserver-$(CONFIG_PROC_FS) += proc.o
16266 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
16267 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
16268 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
16269 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
16271 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/cacct.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/cacct.c
16272 --- linux-2.6.38.1/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
16273 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/cacct.c 2011-01-29 02:01:07.000000000 +0100
16276 + * linux/kernel/vserver/cacct.c
16278 + * Virtual Server: Context Accounting
16280 + * Copyright (C) 2006-2007 Herbert Pötzl
16282 + * V0.01 added accounting stats
16286 +#include <linux/types.h>
16287 +#include <linux/vs_context.h>
16288 +#include <linux/vserver/cacct_cmd.h>
16289 +#include <linux/vserver/cacct_int.h>
16291 +#include <asm/errno.h>
16292 +#include <asm/uaccess.h>
16295 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
16297 + struct vcmd_sock_stat_v0 vc_data;
16300 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16303 + field = vc_data.field;
16304 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
16307 + for (j = 0; j < 3; j++) {
16308 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
16309 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
16312 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16317 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/cacct_init.h linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/cacct_init.h
16318 --- linux-2.6.38.1/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16319 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/cacct_init.h 2011-01-29 02:01:07.000000000 +0100
16323 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16328 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16329 + for (j = 0; j < 3; j++) {
16330 + atomic_long_set(&cacct->sock[i][j].count, 0);
16331 + atomic_long_set(&cacct->sock[i][j].total, 0);
16334 + for (i = 0; i < 8; i++)
16335 + atomic_set(&cacct->slab[i], 0);
16336 + for (i = 0; i < 5; i++)
16337 + for (j = 0; j < 4; j++)
16338 + atomic_set(&cacct->page[i][j], 0);
16341 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16346 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/cacct_proc.h linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/cacct_proc.h
16347 --- linux-2.6.38.1/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
16348 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/cacct_proc.h 2011-01-29 02:01:07.000000000 +0100
16350 +#ifndef _VX_CACCT_PROC_H
16351 +#define _VX_CACCT_PROC_H
16353 +#include <linux/vserver/cacct_int.h>
16356 +#define VX_SOCKA_TOP \
16357 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
16359 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
16361 + int i, j, length = 0;
16362 + static char *type[VXA_SOCK_SIZE] = {
16363 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
16366 + length += sprintf(buffer + length, VX_SOCKA_TOP);
16367 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16368 + length += sprintf(buffer + length, "%s:", type[i]);
16369 + for (j = 0; j < 3; j++) {
16370 + length += sprintf(buffer + length,
16371 + "\t%10lu/%-10lu",
16372 + vx_sock_count(cacct, i, j),
16373 + vx_sock_total(cacct, i, j));
16375 + buffer[length++] = '\n';
16378 + length += sprintf(buffer + length, "\n");
16379 + length += sprintf(buffer + length,
16380 + "slab:\t %8u %8u %8u %8u\n",
16381 + atomic_read(&cacct->slab[1]),
16382 + atomic_read(&cacct->slab[4]),
16383 + atomic_read(&cacct->slab[0]),
16384 + atomic_read(&cacct->slab[2]));
16386 + length += sprintf(buffer + length, "\n");
16387 + for (i = 0; i < 5; i++) {
16388 + length += sprintf(buffer + length,
16389 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
16390 + atomic_read(&cacct->page[i][0]),
16391 + atomic_read(&cacct->page[i][1]),
16392 + atomic_read(&cacct->page[i][2]),
16393 + atomic_read(&cacct->page[i][3]),
16394 + atomic_read(&cacct->page[i][4]),
16395 + atomic_read(&cacct->page[i][5]),
16396 + atomic_read(&cacct->page[i][6]),
16397 + atomic_read(&cacct->page[i][7]));
16402 +#endif /* _VX_CACCT_PROC_H */
16403 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/context.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/context.c
16404 --- linux-2.6.38.1/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
16405 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/context.c 2011-03-22 17:35:46.000000000 +0100
16408 + * linux/kernel/vserver/context.c
16410 + * Virtual Server: Context Support
16412 + * Copyright (C) 2003-2010 Herbert Pötzl
16414 + * V0.01 context helper
16415 + * V0.02 vx_ctx_kill syscall command
16416 + * V0.03 replaced context_info calls
16417 + * V0.04 redesign of struct (de)alloc
16418 + * V0.05 rlimit basic implementation
16419 + * V0.06 task_xid and info commands
16420 + * V0.07 context flags and caps
16421 + * V0.08 switch to RCU based hash
16422 + * V0.09 revert to non RCU for now
16423 + * V0.10 and back to working RCU hash
16424 + * V0.11 and back to locking again
16425 + * V0.12 referenced context store
16426 + * V0.13 separate per cpu data
16427 + * V0.14 changed vcmds to vxi arg
16428 + * V0.15 added context stat
16429 + * V0.16 have __create claim() the vxi
16430 + * V0.17 removed older and legacy stuff
16431 + * V0.18 added user credentials
16435 +#include <linux/slab.h>
16436 +#include <linux/types.h>
16437 +#include <linux/security.h>
16438 +#include <linux/pid_namespace.h>
16440 +#include <linux/vserver/context.h>
16441 +#include <linux/vserver/network.h>
16442 +#include <linux/vserver/debug.h>
16443 +#include <linux/vserver/limit.h>
16444 +#include <linux/vserver/limit_int.h>
16445 +#include <linux/vserver/space.h>
16446 +#include <linux/init_task.h>
16447 +#include <linux/fs_struct.h>
16448 +#include <linux/cred.h>
16450 +#include <linux/vs_context.h>
16451 +#include <linux/vs_limit.h>
16452 +#include <linux/vs_pid.h>
16453 +#include <linux/vserver/context_cmd.h>
16455 +#include "cvirt_init.h"
16456 +#include "cacct_init.h"
16457 +#include "limit_init.h"
16458 +#include "sched_init.h"
16461 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
16462 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
16465 +/* now inactive context structures */
16467 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
16469 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
16472 +/* __alloc_vx_info()
16474 + * allocate an initialized vx_info struct
16475 + * doesn't make it visible (hash) */
16477 +static struct vx_info *__alloc_vx_info(xid_t xid)
16479 + struct vx_info *new = NULL;
16482 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
16484 + /* would this benefit from a slab cache? */
16485 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
16489 + memset(new, 0, sizeof(struct vx_info));
16491 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
16492 + if (!new->ptr_pc)
16495 + new->vx_id = xid;
16496 + INIT_HLIST_NODE(&new->vx_hlist);
16497 + atomic_set(&new->vx_usecnt, 0);
16498 + atomic_set(&new->vx_tasks, 0);
16499 + new->vx_parent = NULL;
16500 + new->vx_state = 0;
16501 + init_waitqueue_head(&new->vx_wait);
16503 + /* prepare reaper */
16504 + get_task_struct(init_pid_ns.child_reaper);
16505 + new->vx_reaper = init_pid_ns.child_reaper;
16506 + new->vx_badness_bias = 0;
16508 + /* rest of init goes here */
16509 + vx_info_init_limit(&new->limit);
16510 + vx_info_init_sched(&new->sched);
16511 + vx_info_init_cvirt(&new->cvirt);
16512 + vx_info_init_cacct(&new->cacct);
16514 + /* per cpu data structures */
16515 + for_each_possible_cpu(cpu) {
16516 + vx_info_init_sched_pc(
16517 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16518 + vx_info_init_cvirt_pc(
16519 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16522 + new->vx_flags = VXF_INIT_SET;
16523 + cap_set_init_eff(new->vx_bcaps);
16524 + new->vx_ccaps = 0;
16525 + new->vx_umask = 0;
16527 + new->reboot_cmd = 0;
16528 + new->exit_code = 0;
16530 + // preconfig spaces
16531 + for (index = 0; index < VX_SPACES; index++) {
16532 + struct _vx_space *space = &new->space[index];
16535 + spin_lock(&init_fs.lock);
16537 + spin_unlock(&init_fs.lock);
16538 + space->vx_fs = &init_fs;
16540 + /* FIXME: do we want defaults? */
16541 + // space->vx_real_cred = 0;
16542 + // space->vx_cred = 0;
16546 + vxdprintk(VXD_CBIT(xid, 0),
16547 + "alloc_vx_info(%d) = %p", xid, new);
16548 + vxh_alloc_vx_info(new);
16549 + atomic_inc(&vx_global_ctotal);
16558 +/* __dealloc_vx_info()
16560 + * final disposal of vx_info */
16562 +static void __dealloc_vx_info(struct vx_info *vxi)
16564 +#ifdef CONFIG_VSERVER_WARN
16565 + struct vx_info_save vxis;
16568 + vxdprintk(VXD_CBIT(xid, 0),
16569 + "dealloc_vx_info(%p)", vxi);
16570 + vxh_dealloc_vx_info(vxi);
16572 +#ifdef CONFIG_VSERVER_WARN
16573 + enter_vx_info(vxi, &vxis);
16574 + vx_info_exit_limit(&vxi->limit);
16575 + vx_info_exit_sched(&vxi->sched);
16576 + vx_info_exit_cvirt(&vxi->cvirt);
16577 + vx_info_exit_cacct(&vxi->cacct);
16579 + for_each_possible_cpu(cpu) {
16580 + vx_info_exit_sched_pc(
16581 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16582 + vx_info_exit_cvirt_pc(
16583 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16585 + leave_vx_info(&vxis);
16589 + vxi->vx_state |= VXS_RELEASED;
16592 + free_percpu(vxi->ptr_pc);
16595 + atomic_dec(&vx_global_ctotal);
16598 +static void __shutdown_vx_info(struct vx_info *vxi)
16600 + struct nsproxy *nsproxy;
16601 + struct fs_struct *fs;
16602 + struct cred *cred;
16607 + vxi->vx_state |= VXS_SHUTDOWN;
16608 + vs_state_change(vxi, VSC_SHUTDOWN);
16610 + for (index = 0; index < VX_SPACES; index++) {
16611 + struct _vx_space *space = &vxi->space[index];
16613 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16615 + put_nsproxy(nsproxy);
16617 + fs = xchg(&space->vx_fs, NULL);
16618 + spin_lock(&fs->lock);
16619 + kill = !--fs->users;
16620 + spin_unlock(&fs->lock);
16622 + free_fs_struct(fs);
16624 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
16626 + abort_creds(cred);
16630 +/* exported stuff */
16632 +void free_vx_info(struct vx_info *vxi)
16634 + unsigned long flags;
16637 + /* check for reference counts first */
16638 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16639 + BUG_ON(atomic_read(&vxi->vx_tasks));
16641 + /* context must not be hashed */
16642 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16644 + /* context shutdown is mandatory */
16645 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16647 + /* spaces check */
16648 + for (index = 0; index < VX_SPACES; index++) {
16649 + struct _vx_space *space = &vxi->space[index];
16651 + BUG_ON(space->vx_nsproxy);
16652 + BUG_ON(space->vx_fs);
16653 + // BUG_ON(space->vx_real_cred);
16654 + // BUG_ON(space->vx_cred);
16657 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16658 + hlist_del(&vxi->vx_hlist);
16659 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16661 + __dealloc_vx_info(vxi);
16665 +/* hash table for vx_info hash */
16667 +#define VX_HASH_SIZE 13
16669 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16670 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16672 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
16675 +static inline unsigned int __hashval(xid_t xid)
16677 + return (xid % VX_HASH_SIZE);
16682 +/* __hash_vx_info()
16684 + * add the vxi to the global hash table
16685 + * requires the hash_lock to be held */
16687 +static inline void __hash_vx_info(struct vx_info *vxi)
16689 + struct hlist_head *head;
16691 + vxd_assert_lock(&vx_info_hash_lock);
16692 + vxdprintk(VXD_CBIT(xid, 4),
16693 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16694 + vxh_hash_vx_info(vxi);
16696 + /* context must not be hashed */
16697 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16699 + vxi->vx_state |= VXS_HASHED;
16700 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16701 + hlist_add_head(&vxi->vx_hlist, head);
16702 + atomic_inc(&vx_global_cactive);
16705 +/* __unhash_vx_info()
16707 + * remove the vxi from the global hash table
16708 + * requires the hash_lock to be held */
16710 +static inline void __unhash_vx_info(struct vx_info *vxi)
16712 + unsigned long flags;
16714 + vxd_assert_lock(&vx_info_hash_lock);
16715 + vxdprintk(VXD_CBIT(xid, 4),
16716 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16717 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16718 + vxh_unhash_vx_info(vxi);
16720 + /* context must be hashed */
16721 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16722 + /* but without tasks */
16723 + BUG_ON(atomic_read(&vxi->vx_tasks));
16725 + vxi->vx_state &= ~VXS_HASHED;
16726 + hlist_del_init(&vxi->vx_hlist);
16727 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16728 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16729 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16730 + atomic_dec(&vx_global_cactive);
16734 +/* __lookup_vx_info()
16736 + * requires the hash_lock to be held
16737 + * doesn't increment the vx_refcnt */
16739 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16741 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16742 + struct hlist_node *pos;
16743 + struct vx_info *vxi;
16745 + vxd_assert_lock(&vx_info_hash_lock);
16746 + hlist_for_each(pos, head) {
16747 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16749 + if (vxi->vx_id == xid)
16754 + vxdprintk(VXD_CBIT(xid, 0),
16755 + "__lookup_vx_info(#%u): %p[#%u]",
16756 + xid, vxi, vxi ? vxi->vx_id : 0);
16757 + vxh_lookup_vx_info(vxi, xid);
16762 +/* __create_vx_info()
16764 + * create the requested context
16765 + * get(), claim() and hash it */
16767 +static struct vx_info *__create_vx_info(int id)
16769 + struct vx_info *new, *vxi = NULL;
16771 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16773 + if (!(new = __alloc_vx_info(id)))
16774 + return ERR_PTR(-ENOMEM);
16776 + /* required to make dynamic xids unique */
16777 + spin_lock(&vx_info_hash_lock);
16779 + /* static context requested */
16780 + if ((vxi = __lookup_vx_info(id))) {
16781 + vxdprintk(VXD_CBIT(xid, 0),
16782 + "create_vx_info(%d) = %p (already there)", id, vxi);
16783 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16784 + vxi = ERR_PTR(-EBUSY);
16786 + vxi = ERR_PTR(-EEXIST);
16789 + /* new context */
16790 + vxdprintk(VXD_CBIT(xid, 0),
16791 + "create_vx_info(%d) = %p (new)", id, new);
16792 + claim_vx_info(new, NULL);
16793 + __hash_vx_info(get_vx_info(new));
16794 + vxi = new, new = NULL;
16797 + spin_unlock(&vx_info_hash_lock);
16798 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16800 + __dealloc_vx_info(new);
16805 +/* exported stuff */
16808 +void unhash_vx_info(struct vx_info *vxi)
16810 + __shutdown_vx_info(vxi);
16811 + spin_lock(&vx_info_hash_lock);
16812 + __unhash_vx_info(vxi);
16813 + spin_unlock(&vx_info_hash_lock);
16814 + __wakeup_vx_info(vxi);
16818 +/* lookup_vx_info()
16820 + * search for a vx_info and get() it
16821 + * negative id means current */
16823 +struct vx_info *lookup_vx_info(int id)
16825 + struct vx_info *vxi = NULL;
16828 + vxi = get_vx_info(current_vx_info());
16829 + } else if (id > 1) {
16830 + spin_lock(&vx_info_hash_lock);
16831 + vxi = get_vx_info(__lookup_vx_info(id));
16832 + spin_unlock(&vx_info_hash_lock);
16837 +/* xid_is_hashed()
16839 + * verify that xid is still hashed */
16841 +int xid_is_hashed(xid_t xid)
16845 + spin_lock(&vx_info_hash_lock);
16846 + hashed = (__lookup_vx_info(xid) != NULL);
16847 + spin_unlock(&vx_info_hash_lock);
16851 +#ifdef CONFIG_PROC_FS
16855 + * get a subset of hashed xids for proc
16856 + * assumes size is at least one */
16858 +int get_xid_list(int index, unsigned int *xids, int size)
16860 + int hindex, nr_xids = 0;
16862 + /* only show current and children */
16863 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16866 + xids[nr_xids] = vx_current_xid();
16870 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16871 + struct hlist_head *head = &vx_info_hash[hindex];
16872 + struct hlist_node *pos;
16874 + spin_lock(&vx_info_hash_lock);
16875 + hlist_for_each(pos, head) {
16876 + struct vx_info *vxi;
16881 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16882 + xids[nr_xids] = vxi->vx_id;
16883 + if (++nr_xids >= size) {
16884 + spin_unlock(&vx_info_hash_lock);
16888 + /* keep the lock time short */
16889 + spin_unlock(&vx_info_hash_lock);
16896 +#ifdef CONFIG_VSERVER_DEBUG
16898 +void dump_vx_info_inactive(int level)
16900 + struct hlist_node *entry, *next;
16902 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16903 + struct vx_info *vxi =
16904 + list_entry(entry, struct vx_info, vx_hlist);
16906 + dump_vx_info(vxi, level);
16913 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16915 + struct user_struct *new_user, *old_user;
16920 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16923 + new_user = alloc_uid(vxi->vx_id, p->uid);
16927 + old_user = p->user;
16928 + if (new_user != old_user) {
16929 + atomic_inc(&new_user->processes);
16930 + atomic_dec(&old_user->processes);
16931 + p->user = new_user;
16933 + free_uid(old_user);
16939 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16941 + // p->cap_effective &= vxi->vx_cap_bset;
16942 + p->cap_effective =
16943 + cap_intersect(p->cap_effective, vxi->cap_bset);
16944 + // p->cap_inheritable &= vxi->vx_cap_bset;
16945 + p->cap_inheritable =
16946 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16947 + // p->cap_permitted &= vxi->vx_cap_bset;
16948 + p->cap_permitted =
16949 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16954 +#include <linux/file.h>
16955 +#include <linux/fdtable.h>
16957 +static int vx_openfd_task(struct task_struct *tsk)
16959 + struct files_struct *files = tsk->files;
16960 + struct fdtable *fdt;
16961 + const unsigned long *bptr;
16962 + int count, total;
16964 + /* no rcu_read_lock() because of spin_lock() */
16965 + spin_lock(&files->file_lock);
16966 + fdt = files_fdtable(files);
16967 + bptr = fdt->open_fds->fds_bits;
16968 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16969 + for (total = 0; count > 0; count--) {
16971 + total += hweight_long(*bptr);
16974 + spin_unlock(&files->file_lock);
16979 +/* for *space compatibility */
16981 +asmlinkage long sys_unshare(unsigned long);
16984 + * migrate task to new context
16985 + * gets vxi, puts old_vxi on change
16986 + * optionally unshares namespaces (hack)
16989 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16991 + struct vx_info *old_vxi;
16997 + vxdprintk(VXD_CBIT(xid, 5),
16998 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16999 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
17001 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
17002 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17005 + if (vx_info_state(vxi, VXS_SHUTDOWN))
17008 + old_vxi = task_get_vx_info(p);
17009 + if (old_vxi == vxi)
17012 +// if (!(ret = vx_migrate_user(p, vxi))) {
17017 + openfd = vx_openfd_task(p);
17020 + atomic_dec(&old_vxi->cvirt.nr_threads);
17021 + atomic_dec(&old_vxi->cvirt.nr_running);
17022 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
17023 + /* FIXME: what about the struct files here? */
17024 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
17025 + /* account for the executable */
17026 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
17028 + atomic_inc(&vxi->cvirt.nr_threads);
17029 + atomic_inc(&vxi->cvirt.nr_running);
17030 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
17031 + /* FIXME: what about the struct files here? */
17032 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
17033 + /* account for the executable */
17034 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
17037 + release_vx_info(old_vxi, p);
17038 + clr_vx_info(&p->vx_info);
17040 + claim_vx_info(vxi, p);
17041 + set_vx_info(&p->vx_info, vxi);
17042 + p->xid = vxi->vx_id;
17044 + vxdprintk(VXD_CBIT(xid, 5),
17045 + "moved task %p into vxi:%p[#%d]",
17046 + p, vxi, vxi->vx_id);
17048 + // vx_mask_cap_bset(vxi, p);
17051 + /* hack for *spaces to provide compatibility */
17053 + struct nsproxy *old_nsp, *new_nsp;
17055 + ret = unshare_nsproxy_namespaces(
17056 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
17061 + old_nsp = xchg(&p->nsproxy, new_nsp);
17062 + vx_set_space(vxi,
17063 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
17064 + put_nsproxy(old_nsp);
17068 + put_vx_info(old_vxi);
17072 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
17074 + struct task_struct *old_reaper;
17079 + vxdprintk(VXD_CBIT(xid, 6),
17080 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
17081 + vxi, vxi->vx_id, p, p->xid, p->pid);
17083 + old_reaper = vxi->vx_reaper;
17084 + if (old_reaper == p)
17087 + /* set new child reaper */
17088 + get_task_struct(p);
17089 + vxi->vx_reaper = p;
17090 + put_task_struct(old_reaper);
17094 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
17099 + vxdprintk(VXD_CBIT(xid, 6),
17100 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
17101 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17103 + vxi->vx_flags &= ~VXF_STATE_INIT;
17104 + // vxi->vx_initpid = p->tgid;
17105 + vxi->vx_initpid = p->pid;
17109 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
17111 + vxdprintk(VXD_CBIT(xid, 6),
17112 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
17113 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17115 + vxi->exit_code = code;
17116 + vxi->vx_initpid = 0;
17120 +void vx_set_persistent(struct vx_info *vxi)
17122 + vxdprintk(VXD_CBIT(xid, 6),
17123 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
17125 + get_vx_info(vxi);
17126 + claim_vx_info(vxi, NULL);
17129 +void vx_clear_persistent(struct vx_info *vxi)
17131 + vxdprintk(VXD_CBIT(xid, 6),
17132 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
17134 + release_vx_info(vxi, NULL);
17135 + put_vx_info(vxi);
17138 +void vx_update_persistent(struct vx_info *vxi)
17140 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
17141 + vx_set_persistent(vxi);
17143 + vx_clear_persistent(vxi);
17147 +/* task must be current or locked */
17149 +void exit_vx_info(struct task_struct *p, int code)
17151 + struct vx_info *vxi = p->vx_info;
17154 + atomic_dec(&vxi->cvirt.nr_threads);
17157 + vxi->exit_code = code;
17158 + release_vx_info(vxi, p);
17162 +void exit_vx_info_early(struct task_struct *p, int code)
17164 + struct vx_info *vxi = p->vx_info;
17167 + if (vxi->vx_initpid == p->pid)
17168 + vx_exit_init(vxi, p, code);
17169 + if (vxi->vx_reaper == p)
17170 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
17175 +/* vserver syscall commands below here */
17177 +/* taks xid and vx_info functions */
17179 +#include <asm/uaccess.h>
17182 +int vc_task_xid(uint32_t id)
17187 + struct task_struct *tsk;
17190 + tsk = find_task_by_real_pid(id);
17191 + xid = (tsk) ? tsk->xid : -ESRCH;
17192 + rcu_read_unlock();
17194 + xid = vx_current_xid();
17199 +int vc_vx_info(struct vx_info *vxi, void __user *data)
17201 + struct vcmd_vx_info_v0 vc_data;
17203 + vc_data.xid = vxi->vx_id;
17204 + vc_data.initpid = vxi->vx_initpid;
17206 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17212 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
17214 + struct vcmd_ctx_stat_v0 vc_data;
17216 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
17217 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
17219 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17225 +/* context functions */
17227 +int vc_ctx_create(uint32_t xid, void __user *data)
17229 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
17230 + struct vx_info *new_vxi;
17233 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17236 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
17239 + new_vxi = __create_vx_info(xid);
17240 + if (IS_ERR(new_vxi))
17241 + return PTR_ERR(new_vxi);
17243 + /* initial flags */
17244 + new_vxi->vx_flags = vc_data.flagword;
17247 + if (vs_state_change(new_vxi, VSC_STARTUP))
17250 + ret = vx_migrate_task(current, new_vxi, (!data));
17254 + /* return context id on success */
17255 + ret = new_vxi->vx_id;
17257 + /* get a reference for persistent contexts */
17258 + if ((vc_data.flagword & VXF_PERSISTENT))
17259 + vx_set_persistent(new_vxi);
17261 + release_vx_info(new_vxi, NULL);
17262 + put_vx_info(new_vxi);
17267 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
17269 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
17272 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17275 + ret = vx_migrate_task(current, vxi, 0);
17278 + if (vc_data.flagword & VXM_SET_INIT)
17279 + ret = vx_set_init(vxi, current);
17282 + if (vc_data.flagword & VXM_SET_REAPER)
17283 + ret = vx_set_reaper(vxi, current);
17288 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
17290 + struct vcmd_ctx_flags_v0 vc_data;
17292 + vc_data.flagword = vxi->vx_flags;
17294 + /* special STATE flag handling */
17295 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
17297 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17302 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
17304 + struct vcmd_ctx_flags_v0 vc_data;
17305 + uint64_t mask, trigger;
17307 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17310 + /* special STATE flag handling */
17311 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
17312 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
17314 + if (vxi == current_vx_info()) {
17315 + /* if (trigger & VXF_STATE_SETUP)
17316 + vx_mask_cap_bset(vxi, current); */
17317 + if (trigger & VXF_STATE_INIT) {
17320 + ret = vx_set_init(vxi, current);
17323 + ret = vx_set_reaper(vxi, current);
17329 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17330 + vc_data.flagword, mask);
17331 + if (trigger & VXF_PERSISTENT)
17332 + vx_update_persistent(vxi);
17338 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17340 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17342 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17346 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17348 + kernel_cap_t c = __cap_empty_set;
17350 + c.cap[0] = v & 0xFFFFFFFF;
17351 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17353 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17358 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17361 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17363 + *ccaps = vxi->vx_ccaps;
17368 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17370 + struct vcmd_ctx_caps_v1 vc_data;
17373 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17376 + vc_data.cmask = ~0ULL;
17378 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17383 +static int do_set_caps(struct vx_info *vxi,
17384 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
17386 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
17389 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
17390 + bcaps, bmask, ccaps, cmask);
17392 + vxi->vx_bcaps = cap_t_from_caps(
17393 + vs_mask_flags(bcold, bcaps, bmask));
17394 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
17399 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
17401 + struct vcmd_ctx_caps_v1 vc_data;
17403 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17406 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
17409 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
17411 + struct vcmd_bcaps vc_data;
17414 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
17417 + vc_data.bmask = ~0ULL;
17419 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17424 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
17426 + struct vcmd_bcaps vc_data;
17428 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17431 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
17435 +int vc_get_umask(struct vx_info *vxi, void __user *data)
17437 + struct vcmd_umask vc_data;
17439 + vc_data.umask = vxi->vx_umask;
17440 + vc_data.mask = ~0ULL;
17442 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17447 +int vc_set_umask(struct vx_info *vxi, void __user *data)
17449 + struct vcmd_umask vc_data;
17451 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17454 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
17455 + vc_data.umask, vc_data.mask);
17460 +int vc_get_badness(struct vx_info *vxi, void __user *data)
17462 + struct vcmd_badness_v0 vc_data;
17464 + vc_data.bias = vxi->vx_badness_bias;
17466 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17471 +int vc_set_badness(struct vx_info *vxi, void __user *data)
17473 + struct vcmd_badness_v0 vc_data;
17475 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17478 + vxi->vx_badness_bias = vc_data.bias;
17482 +#include <linux/module.h>
17484 +EXPORT_SYMBOL_GPL(free_vx_info);
17486 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/cvirt.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/cvirt.c
17487 --- linux-2.6.38.1/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
17488 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/cvirt.c 2011-01-29 02:01:07.000000000 +0100
17491 + * linux/kernel/vserver/cvirt.c
17493 + * Virtual Server: Context Virtualization
17495 + * Copyright (C) 2004-2007 Herbert Pötzl
17497 + * V0.01 broken out from limit.c
17498 + * V0.02 added utsname stuff
17499 + * V0.03 changed vcmds to vxi arg
17503 +#include <linux/types.h>
17504 +#include <linux/utsname.h>
17505 +#include <linux/vs_cvirt.h>
17506 +#include <linux/vserver/switch.h>
17507 +#include <linux/vserver/cvirt_cmd.h>
17509 +#include <asm/uaccess.h>
17512 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17514 + struct vx_info *vxi = current_vx_info();
17516 + set_normalized_timespec(uptime,
17517 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17518 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17521 + set_normalized_timespec(idle,
17522 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17523 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17527 +uint64_t vx_idle_jiffies(void)
17529 + return init_task.utime + init_task.stime;
17534 +static inline uint32_t __update_loadavg(uint32_t load,
17535 + int wsize, int delta, int n)
17537 + unsigned long long calc, prev;
17539 + /* just set it to n */
17540 + if (unlikely(delta >= wsize))
17541 + return (n << FSHIFT);
17543 + calc = delta * n;
17545 + prev = (wsize - delta);
17548 + do_div(calc, wsize);
17553 +void vx_update_load(struct vx_info *vxi)
17555 + uint32_t now, last, delta;
17556 + unsigned int nr_running, nr_uninterruptible;
17557 + unsigned int total;
17558 + unsigned long flags;
17560 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17563 + last = vxi->cvirt.load_last;
17564 + delta = now - last;
17566 + if (delta < 5*HZ)
17569 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17570 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17571 + total = nr_running + nr_uninterruptible;
17573 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17574 + 60*HZ, delta, total);
17575 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17576 + 5*60*HZ, delta, total);
17577 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17578 + 15*60*HZ, delta, total);
17580 + vxi->cvirt.load_last = now;
17582 + atomic_inc(&vxi->cvirt.load_updates);
17583 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17588 + * Commands to do_syslog:
17590 + * 0 -- Close the log. Currently a NOP.
17591 + * 1 -- Open the log. Currently a NOP.
17592 + * 2 -- Read from the log.
17593 + * 3 -- Read all messages remaining in the ring buffer.
17594 + * 4 -- Read and clear all messages remaining in the ring buffer
17595 + * 5 -- Clear ring buffer.
17596 + * 6 -- Disable printk's to console
17597 + * 7 -- Enable printk's to console
17598 + * 8 -- Set level of messages printed to console
17599 + * 9 -- Return number of unread characters in the log buffer
17600 + * 10 -- Return size of the log buffer
17602 +int vx_do_syslog(int type, char __user *buf, int len)
17605 + int do_clear = 0;
17606 + struct vx_info *vxi = current_vx_info();
17607 + struct _vx_syslog *log;
17611 + log = &vxi->cvirt.syslog;
17614 + case 0: /* Close log */
17615 + case 1: /* Open log */
17617 + case 2: /* Read from log */
17618 + error = wait_event_interruptible(log->log_wait,
17619 + (log->log_start - log->log_end));
17622 + spin_lock_irq(&log->logbuf_lock);
17623 + spin_unlock_irq(&log->logbuf_lock);
17625 + case 4: /* Read/clear last kernel messages */
17627 + /* fall through */
17628 + case 3: /* Read last kernel messages */
17631 + case 5: /* Clear ring buffer */
17634 + case 6: /* Disable logging to console */
17635 + case 7: /* Enable logging to console */
17636 + case 8: /* Set level of messages printed to console */
17639 + case 9: /* Number of chars in the log buffer */
17641 + case 10: /* Size of the log buffer */
17651 +/* virtual host info names */
17653 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17655 + struct nsproxy *nsproxy;
17656 + struct uts_namespace *uts;
17658 + if (id == VHIN_CONTEXT)
17659 + return vxi->vx_name;
17661 + nsproxy = vxi->space[0].vx_nsproxy;
17665 + uts = nsproxy->uts_ns;
17670 + case VHIN_SYSNAME:
17671 + return uts->name.sysname;
17672 + case VHIN_NODENAME:
17673 + return uts->name.nodename;
17674 + case VHIN_RELEASE:
17675 + return uts->name.release;
17676 + case VHIN_VERSION:
17677 + return uts->name.version;
17678 + case VHIN_MACHINE:
17679 + return uts->name.machine;
17680 + case VHIN_DOMAINNAME:
17681 + return uts->name.domainname;
17688 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17690 + struct vcmd_vhi_name_v0 vc_data;
17693 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17696 + name = vx_vhi_name(vxi, vc_data.field);
17700 + memcpy(name, vc_data.name, 65);
17704 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17706 + struct vcmd_vhi_name_v0 vc_data;
17709 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17712 + name = vx_vhi_name(vxi, vc_data.field);
17716 + memcpy(vc_data.name, name, 65);
17717 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17723 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17725 + struct vcmd_virt_stat_v0 vc_data;
17726 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17727 + struct timespec uptime;
17729 + do_posix_clock_monotonic_gettime(&uptime);
17730 + set_normalized_timespec(&uptime,
17731 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17732 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17734 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17735 + vc_data.uptime = timespec_to_ns(&uptime);
17736 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17737 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17738 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17739 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17740 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17741 + vc_data.load[0] = cvirt->load[0];
17742 + vc_data.load[1] = cvirt->load[1];
17743 + vc_data.load[2] = cvirt->load[2];
17745 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17751 +#ifdef CONFIG_VSERVER_VTIME
17753 +/* virtualized time base */
17755 +void vx_adjust_timespec(struct timespec *ts)
17757 + struct vx_info *vxi;
17759 + if (!vx_flags(VXF_VIRT_TIME, 0))
17762 + vxi = current_vx_info();
17763 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17764 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17766 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17768 + ts->tv_nsec -= NSEC_PER_SEC;
17769 + } else if (ts->tv_nsec < 0) {
17771 + ts->tv_nsec += NSEC_PER_SEC;
17775 +int vx_settimeofday(struct timespec *ts)
17777 + struct timespec ats, delta;
17778 + struct vx_info *vxi;
17780 + if (!vx_flags(VXF_VIRT_TIME, 0))
17781 + return do_settimeofday(ts);
17783 + getnstimeofday(&ats);
17784 + delta = timespec_sub(*ts, ats);
17786 + vxi = current_vx_info();
17787 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17793 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/cvirt_init.h linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/cvirt_init.h
17794 --- linux-2.6.38.1/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17795 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/cvirt_init.h 2011-03-21 07:21:38.000000000 +0100
17799 +extern uint64_t vx_idle_jiffies(void);
17801 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17803 + uint64_t idle_jiffies = vx_idle_jiffies();
17804 + uint64_t nsuptime;
17806 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17807 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17808 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17809 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17810 + cvirt->bias_ts.tv_sec = 0;
17811 + cvirt->bias_ts.tv_nsec = 0;
17813 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17814 + atomic_set(&cvirt->nr_threads, 0);
17815 + atomic_set(&cvirt->nr_running, 0);
17816 + atomic_set(&cvirt->nr_uninterruptible, 0);
17817 + atomic_set(&cvirt->nr_onhold, 0);
17819 + spin_lock_init(&cvirt->load_lock);
17820 + cvirt->load_last = jiffies;
17821 + atomic_set(&cvirt->load_updates, 0);
17822 + cvirt->load[0] = 0;
17823 + cvirt->load[1] = 0;
17824 + cvirt->load[2] = 0;
17825 + atomic_set(&cvirt->total_forks, 0);
17827 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17828 + init_waitqueue_head(&cvirt->syslog.log_wait);
17829 + cvirt->syslog.log_start = 0;
17830 + cvirt->syslog.log_end = 0;
17831 + cvirt->syslog.con_start = 0;
17832 + cvirt->syslog.logged_chars = 0;
17836 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17838 + // cvirt_pc->cpustat = { 0 };
17841 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17843 +#ifdef CONFIG_VSERVER_WARN
17846 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17847 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17849 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17850 + "!!! cvirt: %p[nr_running] = %d on exit.",
17852 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17853 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17855 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17856 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17862 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17867 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/cvirt_proc.h linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/cvirt_proc.h
17868 --- linux-2.6.38.1/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17869 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/cvirt_proc.h 2011-01-29 02:01:07.000000000 +0100
17871 +#ifndef _VX_CVIRT_PROC_H
17872 +#define _VX_CVIRT_PROC_H
17874 +#include <linux/nsproxy.h>
17875 +#include <linux/mnt_namespace.h>
17876 +#include <linux/ipc_namespace.h>
17877 +#include <linux/utsname.h>
17878 +#include <linux/ipc.h>
17882 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17884 + struct mnt_namespace *ns;
17885 + struct uts_namespace *uts;
17886 + struct ipc_namespace *ipc;
17887 + struct path path;
17888 + char *pstr, *root;
17894 + length += sprintf(buffer + length,
17895 + "NSProxy:\t%p [%p,%p,%p]\n",
17896 + nsproxy, nsproxy->mnt_ns,
17897 + nsproxy->uts_ns, nsproxy->ipc_ns);
17899 + ns = nsproxy->mnt_ns;
17903 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17907 + path.mnt = ns->root;
17908 + path.dentry = ns->root->mnt_root;
17909 + root = d_path(&path, pstr, PATH_MAX - 2);
17910 + length += sprintf(buffer + length,
17911 + "Namespace:\t%p [#%u]\n"
17912 + "RootPath:\t%s\n",
17913 + ns, atomic_read(&ns->count),
17918 + uts = nsproxy->uts_ns;
17922 + length += sprintf(buffer + length,
17923 + "SysName:\t%.*s\n"
17924 + "NodeName:\t%.*s\n"
17925 + "Release:\t%.*s\n"
17926 + "Version:\t%.*s\n"
17927 + "Machine:\t%.*s\n"
17928 + "DomainName:\t%.*s\n",
17929 + __NEW_UTS_LEN, uts->name.sysname,
17930 + __NEW_UTS_LEN, uts->name.nodename,
17931 + __NEW_UTS_LEN, uts->name.release,
17932 + __NEW_UTS_LEN, uts->name.version,
17933 + __NEW_UTS_LEN, uts->name.machine,
17934 + __NEW_UTS_LEN, uts->name.domainname);
17937 + ipc = nsproxy->ipc_ns;
17941 + length += sprintf(buffer + length,
17942 + "SEMS:\t\t%d %d %d %d %d\n"
17943 + "MSG:\t\t%d %d %d\n"
17944 + "SHM:\t\t%lu %lu %d %d\n",
17945 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17946 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17948 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17949 + (unsigned long)ipc->shm_ctlmax,
17950 + (unsigned long)ipc->shm_ctlall,
17951 + ipc->shm_ctlmni, ipc->shm_tot);
17958 +#include <linux/sched.h>
17960 +#define LOAD_INT(x) ((x) >> FSHIFT)
17961 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17964 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17969 + length += sprintf(buffer + length,
17970 + "BiasUptime:\t%lu.%02lu\n",
17971 + (unsigned long)cvirt->bias_uptime.tv_sec,
17972 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17974 + a = cvirt->load[0] + (FIXED_1 / 200);
17975 + b = cvirt->load[1] + (FIXED_1 / 200);
17976 + c = cvirt->load[2] + (FIXED_1 / 200);
17977 + length += sprintf(buffer + length,
17978 + "nr_threads:\t%d\n"
17979 + "nr_running:\t%d\n"
17980 + "nr_unintr:\t%d\n"
17981 + "nr_onhold:\t%d\n"
17982 + "load_updates:\t%d\n"
17983 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17984 + "total_forks:\t%d\n",
17985 + atomic_read(&cvirt->nr_threads),
17986 + atomic_read(&cvirt->nr_running),
17987 + atomic_read(&cvirt->nr_uninterruptible),
17988 + atomic_read(&cvirt->nr_onhold),
17989 + atomic_read(&cvirt->load_updates),
17990 + LOAD_INT(a), LOAD_FRAC(a),
17991 + LOAD_INT(b), LOAD_FRAC(b),
17992 + LOAD_INT(c), LOAD_FRAC(c),
17993 + atomic_read(&cvirt->total_forks));
17998 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17999 + char *buffer, int cpu)
18005 +#endif /* _VX_CVIRT_PROC_H */
18006 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/debug.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/debug.c
18007 --- linux-2.6.38.1/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
18008 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/debug.c 2011-01-29 02:01:07.000000000 +0100
18011 + * kernel/vserver/debug.c
18013 + * Copyright (C) 2005-2007 Herbert Pötzl
18015 + * V0.01 vx_info dump support
18019 +#include <linux/module.h>
18021 +#include <linux/vserver/context.h>
18024 +void dump_vx_info(struct vx_info *vxi, int level)
18026 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
18027 + atomic_read(&vxi->vx_usecnt),
18028 + atomic_read(&vxi->vx_tasks),
18031 + __dump_vx_limit(&vxi->limit);
18032 + __dump_vx_sched(&vxi->sched);
18033 + __dump_vx_cvirt(&vxi->cvirt);
18034 + __dump_vx_cacct(&vxi->cacct);
18040 +EXPORT_SYMBOL_GPL(dump_vx_info);
18042 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/device.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/device.c
18043 --- linux-2.6.38.1/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
18044 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/device.c 2011-01-29 02:01:07.000000000 +0100
18047 + * linux/kernel/vserver/device.c
18049 + * Linux-VServer: Device Support
18051 + * Copyright (C) 2006 Herbert Pötzl
18052 + * Copyright (C) 2007 Daniel Hokka Zakrisson
18054 + * V0.01 device mapping basics
18055 + * V0.02 added defaults
18059 +#include <linux/slab.h>
18060 +#include <linux/rcupdate.h>
18061 +#include <linux/fs.h>
18062 +#include <linux/namei.h>
18063 +#include <linux/hash.h>
18065 +#include <asm/errno.h>
18066 +#include <asm/uaccess.h>
18067 +#include <linux/vserver/base.h>
18068 +#include <linux/vserver/debug.h>
18069 +#include <linux/vserver/context.h>
18070 +#include <linux/vserver/device.h>
18071 +#include <linux/vserver/device_cmd.h>
18074 +#define DMAP_HASH_BITS 4
18077 +struct vs_mapping {
18079 + struct hlist_node hlist;
18080 + struct list_head list;
18082 +#define dm_hlist u.hlist
18083 +#define dm_list u.list
18086 + struct vx_dmap_target target;
18090 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
18092 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
18094 +static struct vx_dmap_target dmap_defaults[2] = {
18095 + { .flags = DATTR_OPEN },
18096 + { .flags = DATTR_OPEN },
18100 +struct kmem_cache *dmap_cachep __read_mostly;
18102 +int __init dmap_cache_init(void)
18104 + dmap_cachep = kmem_cache_create("dmap_cache",
18105 + sizeof(struct vs_mapping), 0,
18106 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
18110 +__initcall(dmap_cache_init);
18113 +static inline unsigned int __hashval(dev_t dev, int bits)
18115 + return hash_long((unsigned long)dev, bits);
18119 +/* __hash_mapping()
18120 + * add the mapping to the hash table
18122 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
18124 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18125 + struct hlist_head *head, *hash = dmap_main_hash;
18126 + int device = vdm->device;
18128 + spin_lock(hash_lock);
18129 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
18130 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
18132 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
18133 + hlist_add_head(&vdm->dm_hlist, head);
18134 + spin_unlock(hash_lock);
18138 +static inline int __mode_to_default(umode_t mode)
18151 +/* __set_default()
18154 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
18155 + struct vx_dmap_target *vdmt)
18157 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18158 + spin_lock(hash_lock);
18161 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
18163 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
18166 + spin_unlock(hash_lock);
18168 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
18169 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
18173 +/* __remove_default()
18174 + * remove a default
18176 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
18178 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18179 + spin_lock(hash_lock);
18182 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
18183 + else /* remove == reset */
18184 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
18186 + spin_unlock(hash_lock);
18191 +/* __find_mapping()
18192 + * find a mapping in the hash table
18194 + * caller must hold hash_lock
18196 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
18197 + struct vs_mapping **local, struct vs_mapping **global)
18199 + struct hlist_head *hash = dmap_main_hash;
18200 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
18201 + struct hlist_node *pos;
18202 + struct vs_mapping *vdm;
18208 + hlist_for_each(pos, head) {
18209 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
18211 + if ((vdm->device == device) &&
18212 + !((vdm->target.flags ^ mode) & S_IFMT)) {
18213 + if (vdm->xid == xid) {
18216 + } else if (global && vdm->xid == 0)
18221 + if (global && *global)
18228 +/* __lookup_mapping()
18229 + * find a mapping and store the result in target and flags
18231 +static inline int __lookup_mapping(struct vx_info *vxi,
18232 + dev_t device, dev_t *target, int *flags, umode_t mode)
18234 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18235 + struct vs_mapping *vdm, *global;
18236 + struct vx_dmap_target *vdmt;
18238 + xid_t xid = vxi->vx_id;
18241 + spin_lock(hash_lock);
18242 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
18244 + vdmt = &vdm->target;
18248 + index = __mode_to_default(mode);
18249 + if (vxi && vxi->dmap.targets[index].flags) {
18251 + vdmt = &vxi->dmap.targets[index];
18252 + } else if (global) {
18254 + vdmt = &global->target;
18258 + vdmt = &dmap_defaults[index];
18262 + if (target && (vdmt->flags & DATTR_REMAP))
18263 + *target = vdmt->target;
18265 + *target = device;
18267 + *flags = vdmt->flags;
18269 + spin_unlock(hash_lock);
18275 +/* __remove_mapping()
18276 + * remove a mapping from the hash table
18278 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
18281 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18282 + struct vs_mapping *vdm = NULL;
18285 + spin_lock(hash_lock);
18287 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
18289 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18290 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18293 + hlist_del(&vdm->dm_hlist);
18296 + spin_unlock(hash_lock);
18298 + kmem_cache_free(dmap_cachep, vdm);
18304 +int vs_map_device(struct vx_info *vxi,
18305 + dev_t device, dev_t *target, umode_t mode)
18307 + int ret, flags = DATTR_MASK;
18311 + *target = device;
18314 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18315 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18316 + device, target ? *target : 0, flags, mode, ret);
18318 + return (flags & DATTR_MASK);
18323 +static int do_set_mapping(struct vx_info *vxi,
18324 + dev_t device, dev_t target, int flags, umode_t mode)
18327 + struct vs_mapping *new;
18329 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18333 + INIT_HLIST_NODE(&new->dm_hlist);
18334 + new->device = device;
18335 + new->target.target = target;
18336 + new->target.flags = flags | mode;
18337 + new->xid = (vxi ? vxi->vx_id : 0);
18339 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18340 + __hash_mapping(vxi, new);
18342 + struct vx_dmap_target new = {
18343 + .target = target,
18344 + .flags = flags | mode,
18346 + __set_default(vxi, mode, &new);
18352 +static int do_unset_mapping(struct vx_info *vxi,
18353 + dev_t device, dev_t target, int flags, umode_t mode)
18355 + int ret = -EINVAL;
18358 + ret = __remove_mapping(vxi, device, mode);
18362 + ret = __remove_default(vxi, mode);
18372 +static inline int __user_device(const char __user *name, dev_t *dev,
18375 + struct nameidata nd;
18382 + ret = user_lpath(name, &nd.path);
18385 + if (nd.path.dentry->d_inode) {
18386 + *dev = nd.path.dentry->d_inode->i_rdev;
18387 + *mode = nd.path.dentry->d_inode->i_mode;
18389 + path_put(&nd.path);
18393 +static inline int __mapping_mode(dev_t device, dev_t target,
18394 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18397 + *mode = device_mode & S_IFMT;
18399 + *mode = target_mode & S_IFMT;
18403 + /* if both given, device and target mode have to match */
18404 + if (device && target &&
18405 + ((device_mode ^ target_mode) & S_IFMT))
18411 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18412 + const char __user *target_path, int flags, int set)
18414 + dev_t device = ~0, target = ~0;
18415 + umode_t device_mode = 0, target_mode = 0, mode;
18418 + ret = __user_device(device_path, &device, &device_mode);
18421 + ret = __user_device(target_path, &target, &target_mode);
18425 + ret = __mapping_mode(device, target,
18426 + device_mode, target_mode, &mode);
18431 + return do_set_mapping(vxi, device, target,
18434 + return do_unset_mapping(vxi, device, target,
18439 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
18441 + struct vcmd_set_mapping_v0 vc_data;
18443 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18446 + return do_mapping(vxi, vc_data.device, vc_data.target,
18447 + vc_data.flags, 1);
18450 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
18452 + struct vcmd_set_mapping_v0 vc_data;
18454 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18457 + return do_mapping(vxi, vc_data.device, vc_data.target,
18458 + vc_data.flags, 0);
18462 +#ifdef CONFIG_COMPAT
18464 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
18466 + struct vcmd_set_mapping_v0_x32 vc_data;
18468 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18471 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18472 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
18475 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18477 + struct vcmd_set_mapping_v0_x32 vc_data;
18479 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18482 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18483 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18486 +#endif /* CONFIG_COMPAT */
18489 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/dlimit.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/dlimit.c
18490 --- linux-2.6.38.1/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
18491 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/dlimit.c 2011-01-29 02:01:07.000000000 +0100
18494 + * linux/kernel/vserver/dlimit.c
18496 + * Virtual Server: Context Disk Limits
18498 + * Copyright (C) 2004-2009 Herbert Pötzl
18500 + * V0.01 initial version
18501 + * V0.02 compat32 splitup
18502 + * V0.03 extended interface
18506 +#include <linux/statfs.h>
18507 +#include <linux/sched.h>
18508 +#include <linux/namei.h>
18509 +#include <linux/vs_tag.h>
18510 +#include <linux/vs_dlimit.h>
18511 +#include <linux/vserver/dlimit_cmd.h>
18512 +#include <linux/slab.h>
18513 +// #include <linux/gfp.h>
18515 +#include <asm/uaccess.h>
18517 +/* __alloc_dl_info()
18519 + * allocate an initialized dl_info struct
18520 + * doesn't make it visible (hash) */
18522 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18524 + struct dl_info *new = NULL;
18526 + vxdprintk(VXD_CBIT(dlim, 5),
18527 + "alloc_dl_info(%p,%d)*", sb, tag);
18529 + /* would this benefit from a slab cache? */
18530 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18534 + memset(new, 0, sizeof(struct dl_info));
18535 + new->dl_tag = tag;
18537 + // INIT_RCU_HEAD(&new->dl_rcu);
18538 + INIT_HLIST_NODE(&new->dl_hlist);
18539 + spin_lock_init(&new->dl_lock);
18540 + atomic_set(&new->dl_refcnt, 0);
18541 + atomic_set(&new->dl_usecnt, 0);
18543 + /* rest of init goes here */
18545 + vxdprintk(VXD_CBIT(dlim, 4),
18546 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18550 +/* __dealloc_dl_info()
18552 + * final disposal of dl_info */
18554 +static void __dealloc_dl_info(struct dl_info *dli)
18556 + vxdprintk(VXD_CBIT(dlim, 4),
18557 + "dealloc_dl_info(%p)", dli);
18559 + dli->dl_hlist.next = LIST_POISON1;
18560 + dli->dl_tag = -1;
18563 + BUG_ON(atomic_read(&dli->dl_usecnt));
18564 + BUG_ON(atomic_read(&dli->dl_refcnt));
18570 +/* hash table for dl_info hash */
18572 +#define DL_HASH_SIZE 13
18574 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18576 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
18579 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18581 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18586 +/* __hash_dl_info()
18588 + * add the dli to the global hash table
18589 + * requires the hash_lock to be held */
18591 +static inline void __hash_dl_info(struct dl_info *dli)
18593 + struct hlist_head *head;
18595 + vxdprintk(VXD_CBIT(dlim, 6),
18596 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18597 + get_dl_info(dli);
18598 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18599 + hlist_add_head_rcu(&dli->dl_hlist, head);
18602 +/* __unhash_dl_info()
18604 + * remove the dli from the global hash table
18605 + * requires the hash_lock to be held */
18607 +static inline void __unhash_dl_info(struct dl_info *dli)
18609 + vxdprintk(VXD_CBIT(dlim, 6),
18610 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18611 + hlist_del_rcu(&dli->dl_hlist);
18612 + put_dl_info(dli);
18616 +/* __lookup_dl_info()
18618 + * requires the rcu_read_lock()
18619 + * doesn't increment the dl_refcnt */
18621 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18623 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18624 + struct hlist_node *pos;
18625 + struct dl_info *dli;
18627 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18629 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18637 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18639 + struct dl_info *dli;
18642 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18643 + vxdprintk(VXD_CBIT(dlim, 7),
18644 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18645 + rcu_read_unlock();
18649 +void rcu_free_dl_info(struct rcu_head *head)
18651 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18652 + int usecnt, refcnt;
18654 + BUG_ON(!dli || !head);
18656 + usecnt = atomic_read(&dli->dl_usecnt);
18657 + BUG_ON(usecnt < 0);
18659 + refcnt = atomic_read(&dli->dl_refcnt);
18660 + BUG_ON(refcnt < 0);
18662 + vxdprintk(VXD_CBIT(dlim, 3),
18663 + "rcu_free_dl_info(%p)", dli);
18665 + __dealloc_dl_info(dli);
18667 + printk("!!! rcu didn't free\n");
18673 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18674 + uint32_t flags, int add)
18676 + struct path path;
18679 + ret = user_lpath(name, &path);
18681 + struct super_block *sb;
18682 + struct dl_info *dli;
18685 + if (!path.dentry->d_inode)
18686 + goto out_release;
18687 + if (!(sb = path.dentry->d_inode->i_sb))
18688 + goto out_release;
18691 + dli = __alloc_dl_info(sb, id);
18692 + spin_lock(&dl_info_hash_lock);
18695 + if (__lookup_dl_info(sb, id))
18697 + __hash_dl_info(dli);
18700 + spin_lock(&dl_info_hash_lock);
18701 + dli = __lookup_dl_info(sb, id);
18706 + __unhash_dl_info(dli);
18710 + spin_unlock(&dl_info_hash_lock);
18712 + __dealloc_dl_info(dli);
18719 +int vc_add_dlimit(uint32_t id, void __user *data)
18721 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18723 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18726 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18729 +int vc_rem_dlimit(uint32_t id, void __user *data)
18731 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18733 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18736 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18739 +#ifdef CONFIG_COMPAT
18741 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18743 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18745 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18748 + return do_addrem_dlimit(id,
18749 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18752 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18754 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18756 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18759 + return do_addrem_dlimit(id,
18760 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18763 +#endif /* CONFIG_COMPAT */
18767 +int do_set_dlimit(uint32_t id, const char __user *name,
18768 + uint32_t space_used, uint32_t space_total,
18769 + uint32_t inodes_used, uint32_t inodes_total,
18770 + uint32_t reserved, uint32_t flags)
18772 + struct path path;
18775 + ret = user_lpath(name, &path);
18777 + struct super_block *sb;
18778 + struct dl_info *dli;
18781 + if (!path.dentry->d_inode)
18782 + goto out_release;
18783 + if (!(sb = path.dentry->d_inode->i_sb))
18784 + goto out_release;
18786 + /* sanity checks */
18787 + if ((reserved != CDLIM_KEEP &&
18788 + reserved > 100) ||
18789 + (inodes_used != CDLIM_KEEP &&
18790 + inodes_used > inodes_total) ||
18791 + (space_used != CDLIM_KEEP &&
18792 + space_used > space_total))
18793 + goto out_release;
18796 + dli = locate_dl_info(sb, id);
18798 + goto out_release;
18800 + spin_lock(&dli->dl_lock);
18802 + if (inodes_used != CDLIM_KEEP)
18803 + dli->dl_inodes_used = inodes_used;
18804 + if (inodes_total != CDLIM_KEEP)
18805 + dli->dl_inodes_total = inodes_total;
18806 + if (space_used != CDLIM_KEEP)
18807 + dli->dl_space_used = dlimit_space_32to64(
18808 + space_used, flags, DLIMS_USED);
18810 + if (space_total == CDLIM_INFINITY)
18811 + dli->dl_space_total = DLIM_INFINITY;
18812 + else if (space_total != CDLIM_KEEP)
18813 + dli->dl_space_total = dlimit_space_32to64(
18814 + space_total, flags, DLIMS_TOTAL);
18816 + if (reserved != CDLIM_KEEP)
18817 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18819 + spin_unlock(&dli->dl_lock);
18821 + put_dl_info(dli);
18830 +int vc_set_dlimit(uint32_t id, void __user *data)
18832 + struct vcmd_ctx_dlimit_v0 vc_data;
18834 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18837 + return do_set_dlimit(id, vc_data.name,
18838 + vc_data.space_used, vc_data.space_total,
18839 + vc_data.inodes_used, vc_data.inodes_total,
18840 + vc_data.reserved, vc_data.flags);
18843 +#ifdef CONFIG_COMPAT
18845 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18847 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18849 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18852 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18853 + vc_data.space_used, vc_data.space_total,
18854 + vc_data.inodes_used, vc_data.inodes_total,
18855 + vc_data.reserved, vc_data.flags);
18858 +#endif /* CONFIG_COMPAT */
18862 +int do_get_dlimit(uint32_t id, const char __user *name,
18863 + uint32_t *space_used, uint32_t *space_total,
18864 + uint32_t *inodes_used, uint32_t *inodes_total,
18865 + uint32_t *reserved, uint32_t *flags)
18867 + struct path path;
18870 + ret = user_lpath(name, &path);
18872 + struct super_block *sb;
18873 + struct dl_info *dli;
18876 + if (!path.dentry->d_inode)
18877 + goto out_release;
18878 + if (!(sb = path.dentry->d_inode->i_sb))
18879 + goto out_release;
18882 + dli = locate_dl_info(sb, id);
18884 + goto out_release;
18886 + spin_lock(&dli->dl_lock);
18887 + *inodes_used = dli->dl_inodes_used;
18888 + *inodes_total = dli->dl_inodes_total;
18890 + *space_used = dlimit_space_64to32(
18891 + dli->dl_space_used, flags, DLIMS_USED);
18893 + if (dli->dl_space_total == DLIM_INFINITY)
18894 + *space_total = CDLIM_INFINITY;
18896 + *space_total = dlimit_space_64to32(
18897 + dli->dl_space_total, flags, DLIMS_TOTAL);
18899 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18900 + spin_unlock(&dli->dl_lock);
18902 + put_dl_info(dli);
18913 +int vc_get_dlimit(uint32_t id, void __user *data)
18915 + struct vcmd_ctx_dlimit_v0 vc_data;
18918 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18921 + ret = do_get_dlimit(id, vc_data.name,
18922 + &vc_data.space_used, &vc_data.space_total,
18923 + &vc_data.inodes_used, &vc_data.inodes_total,
18924 + &vc_data.reserved, &vc_data.flags);
18928 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18933 +#ifdef CONFIG_COMPAT
18935 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18937 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18940 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18943 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18944 + &vc_data.space_used, &vc_data.space_total,
18945 + &vc_data.inodes_used, &vc_data.inodes_total,
18946 + &vc_data.reserved, &vc_data.flags);
18950 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18955 +#endif /* CONFIG_COMPAT */
18958 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18960 + struct dl_info *dli;
18961 + __u64 blimit, bfree, bavail;
18964 + dli = locate_dl_info(sb, dx_current_tag());
18968 + spin_lock(&dli->dl_lock);
18969 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18972 + /* reduce max inodes available to limit */
18973 + if (buf->f_files > dli->dl_inodes_total)
18974 + buf->f_files = dli->dl_inodes_total;
18976 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18977 + /* reduce free inodes to min */
18978 + if (ifree < buf->f_ffree)
18979 + buf->f_ffree = ifree;
18982 + if (dli->dl_space_total == DLIM_INFINITY)
18985 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18987 + if (dli->dl_space_total < dli->dl_space_used)
18990 + bfree = (dli->dl_space_total - dli->dl_space_used)
18991 + >> sb->s_blocksize_bits;
18993 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18994 + if (bavail < dli->dl_space_used)
18997 + bavail = (bavail - dli->dl_space_used)
18998 + >> sb->s_blocksize_bits;
19000 + /* reduce max space available to limit */
19001 + if (buf->f_blocks > blimit)
19002 + buf->f_blocks = blimit;
19004 + /* reduce free space to min */
19005 + if (bfree < buf->f_bfree)
19006 + buf->f_bfree = bfree;
19008 + /* reduce avail space to min */
19009 + if (bavail < buf->f_bavail)
19010 + buf->f_bavail = bavail;
19013 + spin_unlock(&dli->dl_lock);
19014 + put_dl_info(dli);
19019 +#include <linux/module.h>
19021 +EXPORT_SYMBOL_GPL(locate_dl_info);
19022 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
19024 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/helper.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/helper.c
19025 --- linux-2.6.38.1/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
19026 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/helper.c 2011-01-29 02:01:07.000000000 +0100
19029 + * linux/kernel/vserver/helper.c
19031 + * Virtual Context Support
19033 + * Copyright (C) 2004-2007 Herbert Pötzl
19035 + * V0.01 basic helper
19039 +#include <linux/kmod.h>
19040 +#include <linux/reboot.h>
19041 +#include <linux/vs_context.h>
19042 +#include <linux/vs_network.h>
19043 +#include <linux/vserver/signal.h>
19046 +char vshelper_path[255] = "/sbin/vshelper";
19049 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
19053 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
19054 + printk( KERN_WARNING
19055 + "%s: (%s %s) returned %s with %d\n",
19056 + name, argv[1], argv[2],
19057 + sync ? "sync" : "async", ret);
19059 + vxdprintk(VXD_CBIT(switch, 4),
19060 + "%s: (%s %s) returned %s with %d",
19061 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
19066 + * vshelper path is set via /proc/sys
19067 + * invoked by vserver sys_reboot(), with
19068 + * the following arguments
19070 + * argv [0] = vshelper_path;
19071 + * argv [1] = action: "restart", "halt", "poweroff", ...
19072 + * argv [2] = context identifier
19074 + * envp [*] = type-specific parameters
19077 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
19079 + char id_buf[8], cmd_buf[16];
19080 + char uid_buf[16], pid_buf[16];
19083 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19084 + char *envp[] = {"HOME=/", "TERM=linux",
19085 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
19086 + uid_buf, pid_buf, cmd_buf, 0};
19088 + if (vx_info_state(vxi, VXS_HELPER))
19090 + vxi->vx_state |= VXS_HELPER;
19092 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19094 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19095 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
19096 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
19099 + case LINUX_REBOOT_CMD_RESTART:
19100 + argv[1] = "restart";
19103 + case LINUX_REBOOT_CMD_HALT:
19104 + argv[1] = "halt";
19107 + case LINUX_REBOOT_CMD_POWER_OFF:
19108 + argv[1] = "poweroff";
19111 + case LINUX_REBOOT_CMD_SW_SUSPEND:
19112 + argv[1] = "swsusp";
19115 + case LINUX_REBOOT_CMD_OOM:
19120 + vxi->vx_state &= ~VXS_HELPER;
19124 + ret = do_vshelper(vshelper_path, argv, envp, 0);
19125 + vxi->vx_state &= ~VXS_HELPER;
19126 + __wakeup_vx_info(vxi);
19127 + return (ret) ? -EPERM : 0;
19131 +long vs_reboot(unsigned int cmd, void __user *arg)
19133 + struct vx_info *vxi = current_vx_info();
19136 + vxdprintk(VXD_CBIT(misc, 5),
19137 + "vs_reboot(%p[#%d],%u)",
19138 + vxi, vxi ? vxi->vx_id : 0, cmd);
19140 + ret = vs_reboot_helper(vxi, cmd, arg);
19144 + vxi->reboot_cmd = cmd;
19145 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19147 + case LINUX_REBOOT_CMD_RESTART:
19148 + case LINUX_REBOOT_CMD_HALT:
19149 + case LINUX_REBOOT_CMD_POWER_OFF:
19150 + vx_info_kill(vxi, 0, SIGKILL);
19151 + vx_info_kill(vxi, 1, SIGKILL);
19159 +long vs_oom_action(unsigned int cmd)
19161 + struct vx_info *vxi = current_vx_info();
19164 + vxdprintk(VXD_CBIT(misc, 5),
19165 + "vs_oom_action(%p[#%d],%u)",
19166 + vxi, vxi ? vxi->vx_id : 0, cmd);
19168 + ret = vs_reboot_helper(vxi, cmd, NULL);
19172 + vxi->reboot_cmd = cmd;
19173 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19174 + vx_info_kill(vxi, 0, SIGKILL);
19175 + vx_info_kill(vxi, 1, SIGKILL);
19181 + * argv [0] = vshelper_path;
19182 + * argv [1] = action: "startup", "shutdown"
19183 + * argv [2] = context identifier
19185 + * envp [*] = type-specific parameters
19188 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
19190 + char id_buf[8], cmd_buf[16];
19191 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19192 + char *envp[] = {"HOME=/", "TERM=linux",
19193 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19195 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
19198 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19199 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19202 + case VSC_STARTUP:
19203 + argv[1] = "startup";
19205 + case VSC_SHUTDOWN:
19206 + argv[1] = "shutdown";
19212 + return do_vshelper(vshelper_path, argv, envp, 1);
19217 + * argv [0] = vshelper_path;
19218 + * argv [1] = action: "netup", "netdown"
19219 + * argv [2] = context identifier
19221 + * envp [*] = type-specific parameters
19224 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
19226 + char id_buf[8], cmd_buf[16];
19227 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19228 + char *envp[] = {"HOME=/", "TERM=linux",
19229 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19231 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
19234 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
19235 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19239 + argv[1] = "netup";
19241 + case VSC_NETDOWN:
19242 + argv[1] = "netdown";
19248 + return do_vshelper(vshelper_path, argv, envp, 1);
19251 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/history.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/history.c
19252 --- linux-2.6.38.1/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
19253 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/history.c 2011-01-29 02:01:07.000000000 +0100
19256 + * kernel/vserver/history.c
19258 + * Virtual Context History Backtrace
19260 + * Copyright (C) 2004-2007 Herbert Pötzl
19262 + * V0.01 basic structure
19263 + * V0.02 hash/unhash and trace
19264 + * V0.03 preemption fixes
19268 +#include <linux/module.h>
19269 +#include <asm/uaccess.h>
19271 +#include <linux/vserver/context.h>
19272 +#include <linux/vserver/debug.h>
19273 +#include <linux/vserver/debug_cmd.h>
19274 +#include <linux/vserver/history.h>
19277 +#ifdef CONFIG_VSERVER_HISTORY
19278 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
19280 +#define VXH_SIZE 64
19283 +struct _vx_history {
19284 + unsigned int counter;
19286 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19290 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19292 +unsigned volatile int vxh_active = 1;
19294 +static atomic_t sequence = ATOMIC_INIT(0);
19299 + * requires disabled preemption */
19301 +struct _vx_hist_entry *vxh_advance(void *loc)
19303 + unsigned int cpu = smp_processor_id();
19304 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19305 + struct _vx_hist_entry *entry;
19306 + unsigned int index;
19308 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19309 + entry = &hist->entry[index];
19311 + entry->seq = atomic_inc_return(&sequence);
19312 + entry->loc = loc;
19316 +EXPORT_SYMBOL_GPL(vxh_advance);
19319 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19321 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19324 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19326 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19327 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19328 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19329 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19331 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19333 + switch (e->type) {
19334 + case VXH_THROW_OOPS:
19335 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19338 + case VXH_GET_VX_INFO:
19339 + case VXH_PUT_VX_INFO:
19340 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19342 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19343 + VXH_VXI_ARGS(e));
19346 + case VXH_INIT_VX_INFO:
19347 + case VXH_SET_VX_INFO:
19348 + case VXH_CLR_VX_INFO:
19349 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19351 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19352 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19353 + VXH_VXI_ARGS(e), e->sc.data);
19356 + case VXH_CLAIM_VX_INFO:
19357 + case VXH_RELEASE_VX_INFO:
19358 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19360 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19361 + VXH_VXI_ARGS(e), e->sc.data);
19364 + case VXH_ALLOC_VX_INFO:
19365 + case VXH_DEALLOC_VX_INFO:
19366 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19368 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19369 + VXH_VXI_ARGS(e));
19372 + case VXH_HASH_VX_INFO:
19373 + case VXH_UNHASH_VX_INFO:
19374 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19376 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19377 + VXH_VXI_ARGS(e));
19380 + case VXH_LOC_VX_INFO:
19381 + case VXH_LOOKUP_VX_INFO:
19382 + case VXH_CREATE_VX_INFO:
19383 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19385 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19386 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19387 + e->ll.arg, VXH_VXI_ARGS(e));
19392 +static void __vxh_dump_history(void)
19394 + unsigned int i, cpu;
19396 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19397 + atomic_read(&sequence), NR_CPUS);
19399 + for (i = 0; i < VXH_SIZE; i++) {
19400 + for_each_online_cpu(cpu) {
19401 + struct _vx_history *hist =
19402 + &per_cpu(vx_history_buffer, cpu);
19403 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19404 + struct _vx_hist_entry *entry = &hist->entry[index];
19406 + vxh_dump_entry(entry, cpu);
19411 +void vxh_dump_history(void)
19415 + local_irq_enable();
19417 + local_irq_disable();
19419 + __vxh_dump_history();
19423 +/* vserver syscall commands below here */
19426 +int vc_dump_history(uint32_t id)
19429 + __vxh_dump_history();
19436 +int do_read_history(struct __user _vx_hist_entry *data,
19437 + int cpu, uint32_t *index, uint32_t *count)
19439 + int pos, ret = 0;
19440 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19441 + int end = hist->counter;
19442 + int start = end - VXH_SIZE + 2;
19443 + int idx = *index;
19445 + /* special case: get current pos */
19451 + /* have we lost some data? */
19455 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
19456 + struct _vx_hist_entry *entry =
19457 + &hist->entry[idx % VXH_SIZE];
19459 + /* send entry to userspace */
19460 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
19464 + /* save new index and count */
19467 + return ret ? ret : (*index < end);
19470 +int vc_read_history(uint32_t id, void __user *data)
19472 + struct vcmd_read_history_v0 vc_data;
19475 + if (id >= NR_CPUS)
19478 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19481 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19482 + id, &vc_data.index, &vc_data.count);
19484 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19489 +#ifdef CONFIG_COMPAT
19491 +int vc_read_history_x32(uint32_t id, void __user *data)
19493 + struct vcmd_read_history_v0_x32 vc_data;
19496 + if (id >= NR_CPUS)
19499 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19502 + ret = do_read_history((struct __user _vx_hist_entry *)
19503 + compat_ptr(vc_data.data_ptr),
19504 + id, &vc_data.index, &vc_data.count);
19506 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19511 +#endif /* CONFIG_COMPAT */
19513 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/inet.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/inet.c
19514 --- linux-2.6.38.1/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19515 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/inet.c 2011-01-29 02:01:07.000000000 +0100
19518 +#include <linux/in.h>
19519 +#include <linux/inetdevice.h>
19520 +#include <linux/vs_inet.h>
19521 +#include <linux/vs_inet6.h>
19522 +#include <linux/vserver/debug.h>
19523 +#include <net/route.h>
19524 +#include <net/addrconf.h>
19527 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19531 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19534 + struct nx_addr_v4 *ptr;
19536 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19537 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19544 + vxdprintk(VXD_CBIT(net, 2),
19545 + "nx_v4_addr_conflict(%p,%p): %d",
19546 + nxi1, nxi2, ret);
19552 +#ifdef CONFIG_IPV6
19554 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19558 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19561 + struct nx_addr_v6 *ptr;
19563 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19564 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19571 + vxdprintk(VXD_CBIT(net, 2),
19572 + "nx_v6_addr_conflict(%p,%p): %d",
19573 + nxi1, nxi2, ret);
19580 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19582 + struct in_device *in_dev;
19583 + struct in_ifaddr **ifap;
19584 + struct in_ifaddr *ifa;
19589 + in_dev = in_dev_get(dev);
19593 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19594 + ifap = &ifa->ifa_next) {
19595 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19600 + in_dev_put(in_dev);
19606 +#ifdef CONFIG_IPV6
19608 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19610 + struct inet6_dev *in_dev;
19611 + struct inet6_ifaddr *ifa;
19616 + in_dev = in6_dev_get(dev);
19620 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19621 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19622 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19627 + in6_dev_put(in_dev);
19634 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19640 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19642 +#ifdef CONFIG_IPV6
19644 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19649 + vxdprintk(VXD_CBIT(net, 3),
19650 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19651 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19655 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
19656 + struct rtable **rp, struct flowi *fl)
19661 + /* FIXME: handle lback only case */
19662 + if (!NX_IPV4(nxi))
19665 + vxdprintk(VXD_CBIT(net, 4),
19666 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19667 + nxi, nxi ? nxi->nx_id : 0,
19668 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
19670 + /* single IP is unconditional */
19671 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19672 + (fl->fl4_src == INADDR_ANY))
19673 + fl->fl4_src = nxi->v4.ip[0].s_addr;
19675 + if (fl->fl4_src == INADDR_ANY) {
19676 + struct nx_addr_v4 *ptr;
19677 + __be32 found = 0;
19680 + err = __ip_route_output_key(net, rp, fl);
19682 + found = (*rp)->rt_src;
19684 + vxdprintk(VXD_CBIT(net, 4),
19685 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19686 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
19687 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19691 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19692 + __be32 primary = ptr->ip[0].s_addr;
19693 + __be32 mask = ptr->mask.s_addr;
19694 + __be32 neta = primary & mask;
19696 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19697 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19698 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19699 + NIPQUAD(mask), NIPQUAD(neta));
19700 + if ((found & mask) != neta)
19703 + fl->fl4_src = primary;
19704 + err = __ip_route_output_key(net, rp, fl);
19705 + vxdprintk(VXD_CBIT(net, 4),
19706 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19707 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
19709 + found = (*rp)->rt_src;
19711 + if (found == primary)
19715 + /* still no source ip? */
19716 + found = ipv4_is_loopback(fl->fl4_dst)
19717 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19719 + /* assign src ip to flow */
19720 + fl->fl4_src = found;
19723 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
19727 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19728 + if (ipv4_is_loopback(fl->fl4_dst))
19729 + fl->fl4_dst = nxi->v4_lback.s_addr;
19730 + if (ipv4_is_loopback(fl->fl4_src))
19731 + fl->fl4_src = nxi->v4_lback.s_addr;
19732 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
19733 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19739 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19741 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/init.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/init.c
19742 --- linux-2.6.38.1/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19743 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/init.c 2011-01-29 02:01:07.000000000 +0100
19746 + * linux/kernel/init.c
19748 + * Virtual Server Init
19750 + * Copyright (C) 2004-2007 Herbert Pötzl
19752 + * V0.01 basic structure
19756 +#include <linux/init.h>
19758 +int vserver_register_sysctl(void);
19759 +void vserver_unregister_sysctl(void);
19762 +static int __init init_vserver(void)
19766 +#ifdef CONFIG_VSERVER_DEBUG
19767 + vserver_register_sysctl();
19773 +static void __exit exit_vserver(void)
19776 +#ifdef CONFIG_VSERVER_DEBUG
19777 + vserver_unregister_sysctl();
19782 +/* FIXME: GFP_ZONETYPES gone
19783 +long vx_slab[GFP_ZONETYPES]; */
19787 +module_init(init_vserver);
19788 +module_exit(exit_vserver);
19790 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/inode.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/inode.c
19791 --- linux-2.6.38.1/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19792 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/inode.c 2011-03-21 07:25:53.000000000 +0100
19795 + * linux/kernel/vserver/inode.c
19797 + * Virtual Server: File System Support
19799 + * Copyright (C) 2004-2007 Herbert Pötzl
19801 + * V0.01 separated from vcontext V0.05
19802 + * V0.02 moved to tag (instead of xid)
19806 +#include <linux/tty.h>
19807 +#include <linux/proc_fs.h>
19808 +#include <linux/devpts_fs.h>
19809 +#include <linux/fs.h>
19810 +#include <linux/file.h>
19811 +#include <linux/mount.h>
19812 +#include <linux/parser.h>
19813 +#include <linux/namei.h>
19814 +#include <linux/vserver/inode.h>
19815 +#include <linux/vserver/inode_cmd.h>
19816 +#include <linux/vs_base.h>
19817 +#include <linux/vs_tag.h>
19819 +#include <asm/uaccess.h>
19822 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19824 + struct proc_dir_entry *entry;
19826 + if (!in || !in->i_sb)
19829 + *flags = IATTR_TAG
19830 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19831 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19832 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19833 + | (IS_COW(in) ? IATTR_COW : 0);
19834 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19836 + if (S_ISDIR(in->i_mode))
19837 + *mask |= IATTR_BARRIER;
19839 + if (IS_TAGGED(in)) {
19840 + *tag = in->i_tag;
19841 + *mask |= IATTR_TAG;
19844 + switch (in->i_sb->s_magic) {
19845 + case PROC_SUPER_MAGIC:
19846 + entry = PROC_I(in)->pde;
19848 + /* check for specific inodes? */
19850 + *mask |= IATTR_FLAGS;
19852 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19854 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19857 + case DEVPTS_SUPER_MAGIC:
19858 + *tag = in->i_tag;
19859 + *mask |= IATTR_TAG;
19868 +int vc_get_iattr(void __user *data)
19870 + struct path path;
19871 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19874 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19877 + ret = user_lpath(vc_data.name, &path);
19879 + ret = __vc_get_iattr(path.dentry->d_inode,
19880 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19886 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19891 +#ifdef CONFIG_COMPAT
19893 +int vc_get_iattr_x32(void __user *data)
19895 + struct path path;
19896 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19899 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19902 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19904 + ret = __vc_get_iattr(path.dentry->d_inode,
19905 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19911 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19916 +#endif /* CONFIG_COMPAT */
19919 +int vc_fget_iattr(uint32_t fd, void __user *data)
19921 + struct file *filp;
19922 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19925 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19929 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19932 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19933 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19937 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19943 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19945 + struct inode *in = de->d_inode;
19946 + int error = 0, is_proc = 0, has_tag = 0;
19947 + struct iattr attr = { 0 };
19949 + if (!in || !in->i_sb)
19952 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19953 + if ((*mask & IATTR_FLAGS) && !is_proc)
19956 + has_tag = IS_TAGGED(in) ||
19957 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19958 + if ((*mask & IATTR_TAG) && !has_tag)
19961 + mutex_lock(&in->i_mutex);
19962 + if (*mask & IATTR_TAG) {
19963 + attr.ia_tag = *tag;
19964 + attr.ia_valid |= ATTR_TAG;
19967 + if (*mask & IATTR_FLAGS) {
19968 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19969 + unsigned int iflags = PROC_I(in)->vx_flags;
19971 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19972 + | (*flags & IATTR_FLAGS);
19973 + PROC_I(in)->vx_flags = iflags;
19975 + entry->vx_flags = iflags;
19978 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19979 + IATTR_BARRIER | IATTR_COW)) {
19980 + int iflags = in->i_flags;
19981 + int vflags = in->i_vflags;
19983 + if (*mask & IATTR_IMMUTABLE) {
19984 + if (*flags & IATTR_IMMUTABLE)
19985 + iflags |= S_IMMUTABLE;
19987 + iflags &= ~S_IMMUTABLE;
19989 + if (*mask & IATTR_IXUNLINK) {
19990 + if (*flags & IATTR_IXUNLINK)
19991 + iflags |= S_IXUNLINK;
19993 + iflags &= ~S_IXUNLINK;
19995 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19996 + if (*flags & IATTR_BARRIER)
19997 + vflags |= V_BARRIER;
19999 + vflags &= ~V_BARRIER;
20001 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
20002 + if (*flags & IATTR_COW)
20005 + vflags &= ~V_COW;
20007 + if (in->i_op && in->i_op->sync_flags) {
20008 + error = in->i_op->sync_flags(in, iflags, vflags);
20014 + if (attr.ia_valid) {
20015 + if (in->i_op && in->i_op->setattr)
20016 + error = in->i_op->setattr(de, &attr);
20018 + error = inode_change_ok(in, &attr);
20020 + setattr_copy(in, &attr);
20021 + mark_inode_dirty(in);
20027 + mutex_unlock(&in->i_mutex);
20031 +int vc_set_iattr(void __user *data)
20033 + struct path path;
20034 + struct vcmd_ctx_iattr_v1 vc_data;
20037 + if (!capable(CAP_LINUX_IMMUTABLE))
20039 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20042 + ret = user_lpath(vc_data.name, &path);
20044 + ret = __vc_set_iattr(path.dentry,
20045 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20049 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20054 +#ifdef CONFIG_COMPAT
20056 +int vc_set_iattr_x32(void __user *data)
20058 + struct path path;
20059 + struct vcmd_ctx_iattr_v1_x32 vc_data;
20062 + if (!capable(CAP_LINUX_IMMUTABLE))
20064 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20067 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20069 + ret = __vc_set_iattr(path.dentry,
20070 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20074 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20079 +#endif /* CONFIG_COMPAT */
20081 +int vc_fset_iattr(uint32_t fd, void __user *data)
20083 + struct file *filp;
20084 + struct vcmd_ctx_fiattr_v0 vc_data;
20087 + if (!capable(CAP_LINUX_IMMUTABLE))
20089 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20093 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20096 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
20097 + &vc_data.flags, &vc_data.mask);
20101 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20107 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
20109 +static match_table_t tokens = {
20110 + {Opt_notagcheck, "notagcheck"},
20111 +#ifdef CONFIG_PROPAGATE
20112 + {Opt_notag, "notag"},
20113 + {Opt_tag, "tag"},
20114 + {Opt_tagid, "tagid=%u"},
20120 +static void __dx_parse_remove(char *string, char *opt)
20122 + char *p = strstr(string, opt);
20126 + while (*q != '\0' && *q != ',')
20135 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
20136 + unsigned long *flags)
20139 + substring_t args[MAX_OPT_ARGS];
20141 + char *s, *p, *opts;
20142 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_WARN)
20148 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
20153 + while ((p = strsep(&opts, ",")) != NULL) {
20154 + token = match_token(p, tokens, args);
20157 +#ifdef CONFIG_PROPAGATE
20162 + __dx_parse_remove(s, "tag");
20163 + *mnt_flags |= MNT_TAGID;
20164 + set |= MNT_TAGID;
20168 + __dx_parse_remove(s, "notag");
20169 + *mnt_flags |= MNT_NOTAG;
20170 + set |= MNT_NOTAG;
20173 + if (tag && !match_int(args, &option))
20176 + __dx_parse_remove(s, "tagid");
20177 + *mnt_flags |= MNT_TAGID;
20178 + set |= MNT_TAGID;
20181 + case Opt_notagcheck:
20183 + __dx_parse_remove(s, "notagcheck");
20184 + *flags |= MS_NOTAGCHECK;
20185 + set |= MS_NOTAGCHECK;
20188 + vxdprintk(VXD_CBIT(tag, 7),
20189 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
20190 + p, token, option);
20193 + strcpy(string, s);
20198 +#ifdef CONFIG_PROPAGATE
20200 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
20202 + tag_t new_tag = 0;
20203 + struct vfsmount *mnt;
20208 + mnt = nd->path.mnt;
20212 + propagate = (mnt->mnt_flags & MNT_TAGID);
20214 + new_tag = mnt->mnt_tag;
20216 + vxdprintk(VXD_CBIT(tag, 7),
20217 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
20218 + inode, inode->i_ino, inode->i_tag,
20219 + new_tag, (propagate) ? 1 : 0);
20222 + inode->i_tag = new_tag;
20225 +#include <linux/module.h>
20227 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
20229 +#endif /* CONFIG_PROPAGATE */
20231 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/limit.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/limit.c
20232 --- linux-2.6.38.1/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
20233 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/limit.c 2011-01-29 02:01:07.000000000 +0100
20236 + * linux/kernel/vserver/limit.c
20238 + * Virtual Server: Context Limits
20240 + * Copyright (C) 2004-2010 Herbert Pötzl
20242 + * V0.01 broken out from vcontext V0.05
20243 + * V0.02 changed vcmds to vxi arg
20244 + * V0.03 added memory cgroup support
20248 +#include <linux/sched.h>
20249 +#include <linux/module.h>
20250 +#include <linux/memcontrol.h>
20251 +#include <linux/res_counter.h>
20252 +#include <linux/vs_limit.h>
20253 +#include <linux/vserver/limit.h>
20254 +#include <linux/vserver/limit_cmd.h>
20256 +#include <asm/uaccess.h>
20259 +const char *vlimit_name[NUM_LIMITS] = {
20260 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20261 + [RLIMIT_RSS] = "RSS",
20262 + [RLIMIT_AS] = "VM",
20263 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20264 + [RLIMIT_CPU] = "CPU",
20265 + [RLIMIT_NPROC] = "NPROC",
20266 + [RLIMIT_NOFILE] = "NOFILE",
20267 + [RLIMIT_LOCKS] = "LOCKS",
20268 + [RLIMIT_SIGPENDING] = "SIGP",
20269 + [RLIMIT_MSGQUEUE] = "MSGQ",
20271 + [VLIMIT_NSOCK] = "NSOCK",
20272 + [VLIMIT_OPENFD] = "OPENFD",
20273 + [VLIMIT_SHMEM] = "SHMEM",
20274 + [VLIMIT_DENTRY] = "DENTRY",
20277 +EXPORT_SYMBOL_GPL(vlimit_name);
20279 +#define MASK_ENTRY(x) (1 << (x))
20281 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
20284 + , /* softlimit */
20285 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20286 + MASK_ENTRY( RLIMIT_RSS ) |
20287 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20290 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20291 + MASK_ENTRY( RLIMIT_RSS ) |
20292 + MASK_ENTRY( RLIMIT_AS ) |
20293 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20294 + MASK_ENTRY( RLIMIT_NPROC ) |
20295 + MASK_ENTRY( RLIMIT_NOFILE ) |
20296 + MASK_ENTRY( RLIMIT_LOCKS ) |
20297 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
20299 + MASK_ENTRY( VLIMIT_NSOCK ) |
20300 + MASK_ENTRY( VLIMIT_OPENFD ) |
20301 + MASK_ENTRY( VLIMIT_SHMEM ) |
20302 + MASK_ENTRY( VLIMIT_DENTRY ) |
20305 + /* accounting only */
20306 +uint32_t account_mask =
20307 + MASK_ENTRY( VLIMIT_SEMARY ) |
20308 + MASK_ENTRY( VLIMIT_NSEMS ) |
20309 + MASK_ENTRY( VLIMIT_MAPPED ) |
20313 +static int is_valid_vlimit(int id)
20315 + uint32_t mask = vlimit_mask.minimum |
20316 + vlimit_mask.softlimit | vlimit_mask.maximum;
20317 + return mask & (1 << id);
20320 +static int is_accounted_vlimit(int id)
20322 + if (is_valid_vlimit(id))
20324 + return account_mask & (1 << id);
20328 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
20330 + rlim_t limit = __rlim_soft(&vxi->limit, id);
20331 + return VX_VLIM(limit);
20334 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
20336 + rlim_t limit = __rlim_hard(&vxi->limit, id);
20337 + return VX_VLIM(limit);
20340 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
20341 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
20343 + if (!is_valid_vlimit(id))
20347 + *minimum = CRLIM_UNSET;
20349 + *softlimit = vc_get_soft(vxi, id);
20351 + *maximum = vc_get_hard(vxi, id);
20355 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
20357 + struct vcmd_ctx_rlimit_v0 vc_data;
20360 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20363 + ret = do_get_rlimit(vxi, vc_data.id,
20364 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20368 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20373 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
20374 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
20376 + if (!is_valid_vlimit(id))
20379 + if (maximum != CRLIM_KEEP)
20380 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
20381 + if (softlimit != CRLIM_KEEP)
20382 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
20384 + /* clamp soft limit */
20385 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
20386 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
20391 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
20393 + struct vcmd_ctx_rlimit_v0 vc_data;
20395 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20398 + return do_set_rlimit(vxi, vc_data.id,
20399 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20402 +#ifdef CONFIG_IA32_EMULATION
20404 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
20406 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20408 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20411 + return do_set_rlimit(vxi, vc_data.id,
20412 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20415 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
20417 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20420 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20423 + ret = do_get_rlimit(vxi, vc_data.id,
20424 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20428 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20433 +#endif /* CONFIG_IA32_EMULATION */
20436 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
20438 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
20444 +static inline void vx_reset_hits(struct _vx_limit *limit)
20448 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20449 + atomic_set(&__rlim_lhit(limit, lim), 0);
20453 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
20455 + vx_reset_hits(&vxi->limit);
20459 +static inline void vx_reset_minmax(struct _vx_limit *limit)
20464 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20465 + value = __rlim_get(limit, lim);
20466 + __rlim_rmax(limit, lim) = value;
20467 + __rlim_rmin(limit, lim) = value;
20471 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
20473 + vx_reset_minmax(&vxi->limit);
20478 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20480 + struct vcmd_rlimit_stat_v0 vc_data;
20481 + struct _vx_limit *limit = &vxi->limit;
20484 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20488 + if (!is_accounted_vlimit(id))
20491 + vx_limit_fixup(limit, id);
20492 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20493 + vc_data.value = __rlim_get(limit, id);
20494 + vc_data.minimum = __rlim_rmin(limit, id);
20495 + vc_data.maximum = __rlim_rmax(limit, id);
20497 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20503 +void vx_vsi_meminfo(struct sysinfo *val)
20505 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20506 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20507 + u64 res_limit, res_usage;
20512 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20513 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20515 + if (res_limit != RESOURCE_MAX)
20516 + val->totalram = (res_limit >> PAGE_SHIFT);
20517 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
20518 + val->bufferram = 0;
20519 + val->totalhigh = 0;
20520 + val->freehigh = 0;
20521 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20525 +void vx_vsi_swapinfo(struct sysinfo *val)
20527 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20528 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20529 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20530 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20531 + s64 swap_limit, swap_usage;
20536 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20537 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20538 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20539 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20541 + if (res_limit == RESOURCE_MAX)
20544 + swap_limit = memsw_limit - res_limit;
20545 + if (memsw_limit != RESOURCE_MAX)
20546 + val->totalswap = swap_limit >> PAGE_SHIFT;
20548 + swap_usage = memsw_usage - res_usage;
20549 + val->freeswap = (swap_usage < swap_limit) ?
20550 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20551 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20552 + val->totalswap = 0;
20553 + val->freeswap = 0;
20554 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20555 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20559 +long vx_vsi_cached(struct sysinfo *val)
20561 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20562 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20564 + return mem_cgroup_stat_read_cache(mcg);
20571 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
20573 + struct vx_info *vxi = mm->mm_vx_info;
20574 + unsigned long points;
20580 + points = vxi->vx_badness_bias;
20582 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20583 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20584 + points += (v > w) ? (v - w) : 0;
20589 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/limit_init.h linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/limit_init.h
20590 --- linux-2.6.38.1/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20591 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/limit_init.h 2011-01-29 02:01:07.000000000 +0100
20595 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20599 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20600 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20601 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20602 + __rlim_set(limit, lim, 0);
20603 + atomic_set(&__rlim_lhit(limit, lim), 0);
20604 + __rlim_rmin(limit, lim) = 0;
20605 + __rlim_rmax(limit, lim) = 0;
20609 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20614 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20615 + if ((1 << lim) & VLIM_NOCHECK)
20617 + value = __rlim_get(limit, lim);
20618 + vxwprintk_xid(value,
20619 + "!!! limit: %p[%s,%d] = %ld on exit.",
20620 + limit, vlimit_name[lim], lim, (long)value);
20624 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/limit_proc.h linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/limit_proc.h
20625 --- linux-2.6.38.1/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20626 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/limit_proc.h 2011-01-29 02:01:07.000000000 +0100
20628 +#ifndef _VX_LIMIT_PROC_H
20629 +#define _VX_LIMIT_PROC_H
20631 +#include <linux/vserver/limit_int.h>
20634 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20635 +#define VX_LIMIT_TOP \
20636 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20638 +#define VX_LIMIT_ARG(r) \
20639 + (unsigned long)__rlim_get(limit, r), \
20640 + (unsigned long)__rlim_rmin(limit, r), \
20641 + (unsigned long)__rlim_rmax(limit, r), \
20642 + VX_VLIM(__rlim_soft(limit, r)), \
20643 + VX_VLIM(__rlim_hard(limit, r)), \
20644 + atomic_read(&__rlim_lhit(limit, r))
20646 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20648 + vx_limit_fixup(limit, -1);
20649 + return sprintf(buffer, VX_LIMIT_TOP
20650 + "PROC" VX_LIMIT_FMT
20651 + "VM" VX_LIMIT_FMT
20652 + "VML" VX_LIMIT_FMT
20653 + "RSS" VX_LIMIT_FMT
20654 + "ANON" VX_LIMIT_FMT
20655 + "RMAP" VX_LIMIT_FMT
20656 + "FILES" VX_LIMIT_FMT
20657 + "OFD" VX_LIMIT_FMT
20658 + "LOCKS" VX_LIMIT_FMT
20659 + "SOCK" VX_LIMIT_FMT
20660 + "MSGQ" VX_LIMIT_FMT
20661 + "SHM" VX_LIMIT_FMT
20662 + "SEMA" VX_LIMIT_FMT
20663 + "SEMS" VX_LIMIT_FMT
20664 + "DENT" VX_LIMIT_FMT,
20665 + VX_LIMIT_ARG(RLIMIT_NPROC),
20666 + VX_LIMIT_ARG(RLIMIT_AS),
20667 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20668 + VX_LIMIT_ARG(RLIMIT_RSS),
20669 + VX_LIMIT_ARG(VLIMIT_ANON),
20670 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20671 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20672 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20673 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20674 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20675 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20676 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20677 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20678 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20679 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20682 +#endif /* _VX_LIMIT_PROC_H */
20685 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/network.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/network.c
20686 --- linux-2.6.38.1/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20687 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/network.c 2011-03-22 17:36:23.000000000 +0100
20690 + * linux/kernel/vserver/network.c
20692 + * Virtual Server: Network Support
20694 + * Copyright (C) 2003-2007 Herbert Pötzl
20696 + * V0.01 broken out from vcontext V0.05
20697 + * V0.02 cleaned up implementation
20698 + * V0.03 added equiv nx commands
20699 + * V0.04 switch to RCU based hash
20700 + * V0.05 and back to locking again
20701 + * V0.06 changed vcmds to nxi arg
20702 + * V0.07 have __create claim() the nxi
20706 +#include <linux/err.h>
20707 +#include <linux/slab.h>
20708 +#include <linux/rcupdate.h>
20710 +#include <linux/vs_network.h>
20711 +#include <linux/vs_pid.h>
20712 +#include <linux/vserver/network_cmd.h>
20715 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20716 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20718 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20719 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20722 +static int __init init_network(void)
20724 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20725 + sizeof(struct nx_addr_v4), 0,
20726 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20727 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20728 + sizeof(struct nx_addr_v6), 0,
20729 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20734 +/* __alloc_nx_addr_v4() */
20736 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20738 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20739 + nx_addr_v4_cachep, GFP_KERNEL);
20741 + if (!IS_ERR(nxa))
20742 + memset(nxa, 0, sizeof(*nxa));
20746 +/* __dealloc_nx_addr_v4() */
20748 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20750 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20753 +/* __dealloc_nx_addr_v4_all() */
20755 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20758 + struct nx_addr_v4 *next = nxa->next;
20760 + __dealloc_nx_addr_v4(nxa);
20766 +#ifdef CONFIG_IPV6
20768 +/* __alloc_nx_addr_v6() */
20770 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20772 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20773 + nx_addr_v6_cachep, GFP_KERNEL);
20775 + if (!IS_ERR(nxa))
20776 + memset(nxa, 0, sizeof(*nxa));
20780 +/* __dealloc_nx_addr_v6() */
20782 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20784 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20787 +/* __dealloc_nx_addr_v6_all() */
20789 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20792 + struct nx_addr_v6 *next = nxa->next;
20794 + __dealloc_nx_addr_v6(nxa);
20799 +#endif /* CONFIG_IPV6 */
20801 +/* __alloc_nx_info()
20803 + * allocate an initialized nx_info struct
20804 + * doesn't make it visible (hash) */
20806 +static struct nx_info *__alloc_nx_info(nid_t nid)
20808 + struct nx_info *new = NULL;
20810 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20812 + /* would this benefit from a slab cache? */
20813 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20817 + memset(new, 0, sizeof(struct nx_info));
20818 + new->nx_id = nid;
20819 + INIT_HLIST_NODE(&new->nx_hlist);
20820 + atomic_set(&new->nx_usecnt, 0);
20821 + atomic_set(&new->nx_tasks, 0);
20822 + new->nx_state = 0;
20824 + new->nx_flags = NXF_INIT_SET;
20826 + /* rest of init goes here */
20828 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20829 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20831 + vxdprintk(VXD_CBIT(nid, 0),
20832 + "alloc_nx_info(%d) = %p", nid, new);
20833 + atomic_inc(&nx_global_ctotal);
20837 +/* __dealloc_nx_info()
20839 + * final disposal of nx_info */
20841 +static void __dealloc_nx_info(struct nx_info *nxi)
20843 + vxdprintk(VXD_CBIT(nid, 0),
20844 + "dealloc_nx_info(%p)", nxi);
20846 + nxi->nx_hlist.next = LIST_POISON1;
20849 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20850 + BUG_ON(atomic_read(&nxi->nx_tasks));
20852 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20854 + nxi->nx_state |= NXS_RELEASED;
20856 + atomic_dec(&nx_global_ctotal);
20859 +static void __shutdown_nx_info(struct nx_info *nxi)
20861 + nxi->nx_state |= NXS_SHUTDOWN;
20862 + vs_net_change(nxi, VSC_NETDOWN);
20865 +/* exported stuff */
20867 +void free_nx_info(struct nx_info *nxi)
20869 + /* context shutdown is mandatory */
20870 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20872 + /* context must not be hashed */
20873 + BUG_ON(nxi->nx_state & NXS_HASHED);
20875 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20876 + BUG_ON(atomic_read(&nxi->nx_tasks));
20878 + __dealloc_nx_info(nxi);
20882 +void __nx_set_lback(struct nx_info *nxi)
20884 + int nid = nxi->nx_id;
20885 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20887 + nxi->v4_lback.s_addr = lback;
20890 +extern int __nx_inet_add_lback(__be32 addr);
20891 +extern int __nx_inet_del_lback(__be32 addr);
20894 +/* hash table for nx_info hash */
20896 +#define NX_HASH_SIZE 13
20898 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20900 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
20903 +static inline unsigned int __hashval(nid_t nid)
20905 + return (nid % NX_HASH_SIZE);
20910 +/* __hash_nx_info()
20912 + * add the nxi to the global hash table
20913 + * requires the hash_lock to be held */
20915 +static inline void __hash_nx_info(struct nx_info *nxi)
20917 + struct hlist_head *head;
20919 + vxd_assert_lock(&nx_info_hash_lock);
20920 + vxdprintk(VXD_CBIT(nid, 4),
20921 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20923 + /* context must not be hashed */
20924 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20926 + nxi->nx_state |= NXS_HASHED;
20927 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20928 + hlist_add_head(&nxi->nx_hlist, head);
20929 + atomic_inc(&nx_global_cactive);
20932 +/* __unhash_nx_info()
20934 + * remove the nxi from the global hash table
20935 + * requires the hash_lock to be held */
20937 +static inline void __unhash_nx_info(struct nx_info *nxi)
20939 + vxd_assert_lock(&nx_info_hash_lock);
20940 + vxdprintk(VXD_CBIT(nid, 4),
20941 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20942 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20944 + /* context must be hashed */
20945 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20946 + /* but without tasks */
20947 + BUG_ON(atomic_read(&nxi->nx_tasks));
20949 + nxi->nx_state &= ~NXS_HASHED;
20950 + hlist_del(&nxi->nx_hlist);
20951 + atomic_dec(&nx_global_cactive);
20955 +/* __lookup_nx_info()
20957 + * requires the hash_lock to be held
20958 + * doesn't increment the nx_refcnt */
20960 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20962 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20963 + struct hlist_node *pos;
20964 + struct nx_info *nxi;
20966 + vxd_assert_lock(&nx_info_hash_lock);
20967 + hlist_for_each(pos, head) {
20968 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20970 + if (nxi->nx_id == nid)
20975 + vxdprintk(VXD_CBIT(nid, 0),
20976 + "__lookup_nx_info(#%u): %p[#%u]",
20977 + nid, nxi, nxi ? nxi->nx_id : 0);
20982 +/* __create_nx_info()
20984 + * create the requested context
20985 + * get(), claim() and hash it */
20987 +static struct nx_info *__create_nx_info(int id)
20989 + struct nx_info *new, *nxi = NULL;
20991 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20993 + if (!(new = __alloc_nx_info(id)))
20994 + return ERR_PTR(-ENOMEM);
20996 + /* required to make dynamic xids unique */
20997 + spin_lock(&nx_info_hash_lock);
20999 + /* static context requested */
21000 + if ((nxi = __lookup_nx_info(id))) {
21001 + vxdprintk(VXD_CBIT(nid, 0),
21002 + "create_nx_info(%d) = %p (already there)", id, nxi);
21003 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21004 + nxi = ERR_PTR(-EBUSY);
21006 + nxi = ERR_PTR(-EEXIST);
21009 + /* new context */
21010 + vxdprintk(VXD_CBIT(nid, 0),
21011 + "create_nx_info(%d) = %p (new)", id, new);
21012 + claim_nx_info(new, NULL);
21013 + __nx_set_lback(new);
21014 + __hash_nx_info(get_nx_info(new));
21015 + nxi = new, new = NULL;
21018 + spin_unlock(&nx_info_hash_lock);
21020 + __dealloc_nx_info(new);
21026 +/* exported stuff */
21029 +void unhash_nx_info(struct nx_info *nxi)
21031 + __shutdown_nx_info(nxi);
21032 + spin_lock(&nx_info_hash_lock);
21033 + __unhash_nx_info(nxi);
21034 + spin_unlock(&nx_info_hash_lock);
21037 +/* lookup_nx_info()
21039 + * search for a nx_info and get() it
21040 + * negative id means current */
21042 +struct nx_info *lookup_nx_info(int id)
21044 + struct nx_info *nxi = NULL;
21047 + nxi = get_nx_info(current_nx_info());
21048 + } else if (id > 1) {
21049 + spin_lock(&nx_info_hash_lock);
21050 + nxi = get_nx_info(__lookup_nx_info(id));
21051 + spin_unlock(&nx_info_hash_lock);
21056 +/* nid_is_hashed()
21058 + * verify that nid is still hashed */
21060 +int nid_is_hashed(nid_t nid)
21064 + spin_lock(&nx_info_hash_lock);
21065 + hashed = (__lookup_nx_info(nid) != NULL);
21066 + spin_unlock(&nx_info_hash_lock);
21071 +#ifdef CONFIG_PROC_FS
21075 + * get a subset of hashed nids for proc
21076 + * assumes size is at least one */
21078 +int get_nid_list(int index, unsigned int *nids, int size)
21080 + int hindex, nr_nids = 0;
21082 + /* only show current and children */
21083 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
21086 + nids[nr_nids] = nx_current_nid();
21090 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
21091 + struct hlist_head *head = &nx_info_hash[hindex];
21092 + struct hlist_node *pos;
21094 + spin_lock(&nx_info_hash_lock);
21095 + hlist_for_each(pos, head) {
21096 + struct nx_info *nxi;
21101 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21102 + nids[nr_nids] = nxi->nx_id;
21103 + if (++nr_nids >= size) {
21104 + spin_unlock(&nx_info_hash_lock);
21108 + /* keep the lock time short */
21109 + spin_unlock(&nx_info_hash_lock);
21118 + * migrate task to new network
21119 + * gets nxi, puts old_nxi on change
21122 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
21124 + struct nx_info *old_nxi;
21130 + vxdprintk(VXD_CBIT(nid, 5),
21131 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
21132 + p, nxi, nxi->nx_id,
21133 + atomic_read(&nxi->nx_usecnt),
21134 + atomic_read(&nxi->nx_tasks));
21136 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
21137 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21140 + if (nx_info_state(nxi, NXS_SHUTDOWN))
21143 + /* maybe disallow this completely? */
21144 + old_nxi = task_get_nx_info(p);
21145 + if (old_nxi == nxi)
21150 + clr_nx_info(&p->nx_info);
21151 + claim_nx_info(nxi, p);
21152 + set_nx_info(&p->nx_info, nxi);
21153 + p->nid = nxi->nx_id;
21156 + vxdprintk(VXD_CBIT(nid, 5),
21157 + "moved task %p into nxi:%p[#%d]",
21158 + p, nxi, nxi->nx_id);
21161 + release_nx_info(old_nxi, p);
21164 + put_nx_info(old_nxi);
21169 +void nx_set_persistent(struct nx_info *nxi)
21171 + vxdprintk(VXD_CBIT(nid, 6),
21172 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
21174 + get_nx_info(nxi);
21175 + claim_nx_info(nxi, NULL);
21178 +void nx_clear_persistent(struct nx_info *nxi)
21180 + vxdprintk(VXD_CBIT(nid, 6),
21181 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
21183 + release_nx_info(nxi, NULL);
21184 + put_nx_info(nxi);
21187 +void nx_update_persistent(struct nx_info *nxi)
21189 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
21190 + nx_set_persistent(nxi);
21192 + nx_clear_persistent(nxi);
21195 +/* vserver syscall commands below here */
21197 +/* taks nid and nx_info functions */
21199 +#include <asm/uaccess.h>
21202 +int vc_task_nid(uint32_t id)
21207 + struct task_struct *tsk;
21210 + tsk = find_task_by_real_pid(id);
21211 + nid = (tsk) ? tsk->nid : -ESRCH;
21212 + rcu_read_unlock();
21214 + nid = nx_current_nid();
21219 +int vc_nx_info(struct nx_info *nxi, void __user *data)
21221 + struct vcmd_nx_info_v0 vc_data;
21223 + vc_data.nid = nxi->nx_id;
21225 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21231 +/* network functions */
21233 +int vc_net_create(uint32_t nid, void __user *data)
21235 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
21236 + struct nx_info *new_nxi;
21239 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21242 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
21245 + new_nxi = __create_nx_info(nid);
21246 + if (IS_ERR(new_nxi))
21247 + return PTR_ERR(new_nxi);
21249 + /* initial flags */
21250 + new_nxi->nx_flags = vc_data.flagword;
21253 + if (vs_net_change(new_nxi, VSC_NETUP))
21256 + ret = nx_migrate_task(current, new_nxi);
21260 + /* return context id on success */
21261 + ret = new_nxi->nx_id;
21263 + /* get a reference for persistent contexts */
21264 + if ((vc_data.flagword & NXF_PERSISTENT))
21265 + nx_set_persistent(new_nxi);
21267 + release_nx_info(new_nxi, NULL);
21268 + put_nx_info(new_nxi);
21273 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
21275 + return nx_migrate_task(current, nxi);
21280 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21281 + uint16_t type, uint16_t flags)
21283 + struct nx_addr_v4 *nxa = &nxi->v4;
21285 + if (NX_IPV4(nxi)) {
21286 + /* locate last entry */
21287 + for (; nxa->next; nxa = nxa->next);
21288 + nxa->next = __alloc_nx_addr_v4();
21292 + return PTR_ERR(nxa);
21295 + if (nxi->v4.next)
21296 + /* remove single ip for ip list */
21297 + nxi->nx_flags &= ~NXF_SINGLE_IP;
21299 + nxa->ip[0].s_addr = ip;
21300 + nxa->ip[1].s_addr = ip2;
21301 + nxa->mask.s_addr = mask;
21302 + nxa->type = type;
21303 + nxa->flags = flags;
21308 +int vc_net_add(struct nx_info *nxi, void __user *data)
21310 + struct vcmd_net_addr_v0 vc_data;
21311 + int index, ret = 0;
21313 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21316 + switch (vc_data.type) {
21317 + case NXA_TYPE_IPV4:
21318 + if ((vc_data.count < 1) || (vc_data.count > 4))
21322 + while (index < vc_data.count) {
21323 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
21324 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
21332 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
21333 + nxi->v4_bcast = vc_data.ip[0];
21337 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
21338 + nxi->v4_lback = vc_data.ip[0];
21349 +int vc_net_remove(struct nx_info *nxi, void __user *data)
21351 + struct vcmd_net_addr_v0 vc_data;
21353 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21356 + switch (vc_data.type) {
21357 + case NXA_TYPE_ANY:
21358 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21359 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21369 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
21371 + struct vcmd_net_addr_ipv4_v1 vc_data;
21373 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21376 + switch (vc_data.type) {
21377 + case NXA_TYPE_ADDR:
21378 + case NXA_TYPE_RANGE:
21379 + case NXA_TYPE_MASK:
21380 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
21381 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21383 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21384 + nxi->v4_bcast = vc_data.ip;
21387 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21388 + nxi->v4_lback = vc_data.ip;
21397 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
21399 + struct vcmd_net_addr_ipv4_v1 vc_data;
21401 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21404 + switch (vc_data.type) {
21405 +/* case NXA_TYPE_ADDR:
21408 + case NXA_TYPE_ANY:
21409 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21410 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21420 +#ifdef CONFIG_IPV6
21422 +int do_add_v6_addr(struct nx_info *nxi,
21423 + struct in6_addr *ip, struct in6_addr *mask,
21424 + uint32_t prefix, uint16_t type, uint16_t flags)
21426 + struct nx_addr_v6 *nxa = &nxi->v6;
21428 + if (NX_IPV6(nxi)) {
21429 + /* locate last entry */
21430 + for (; nxa->next; nxa = nxa->next);
21431 + nxa->next = __alloc_nx_addr_v6();
21435 + return PTR_ERR(nxa);
21439 + nxa->mask = *mask;
21440 + nxa->prefix = prefix;
21441 + nxa->type = type;
21442 + nxa->flags = flags;
21447 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21449 + struct vcmd_net_addr_ipv6_v1 vc_data;
21451 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21454 + switch (vc_data.type) {
21455 + case NXA_TYPE_ADDR:
21456 + case NXA_TYPE_MASK:
21457 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21458 + vc_data.prefix, vc_data.type, vc_data.flags);
21465 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21467 + struct vcmd_net_addr_ipv6_v1 vc_data;
21469 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21472 + switch (vc_data.type) {
21473 + case NXA_TYPE_ANY:
21474 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21475 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21484 +#endif /* CONFIG_IPV6 */
21487 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21489 + struct vcmd_net_flags_v0 vc_data;
21491 + vc_data.flagword = nxi->nx_flags;
21493 + /* special STATE flag handling */
21494 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21496 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21501 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21503 + struct vcmd_net_flags_v0 vc_data;
21504 + uint64_t mask, trigger;
21506 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21509 + /* special STATE flag handling */
21510 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21511 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21513 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21514 + vc_data.flagword, mask);
21515 + if (trigger & NXF_PERSISTENT)
21516 + nx_update_persistent(nxi);
21521 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21523 + struct vcmd_net_caps_v0 vc_data;
21525 + vc_data.ncaps = nxi->nx_ncaps;
21526 + vc_data.cmask = ~0ULL;
21528 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21533 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21535 + struct vcmd_net_caps_v0 vc_data;
21537 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21540 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21541 + vc_data.ncaps, vc_data.cmask);
21546 +#include <linux/module.h>
21548 +module_init(init_network);
21550 +EXPORT_SYMBOL_GPL(free_nx_info);
21551 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21553 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/proc.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/proc.c
21554 --- linux-2.6.38.1/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21555 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/proc.c 2011-01-29 02:01:07.000000000 +0100
21558 + * linux/kernel/vserver/proc.c
21560 + * Virtual Context Support
21562 + * Copyright (C) 2003-2007 Herbert Pötzl
21564 + * V0.01 basic structure
21565 + * V0.02 adaptation vs1.3.0
21566 + * V0.03 proc permissions
21567 + * V0.04 locking/generic
21568 + * V0.05 next generation procfs
21569 + * V0.06 inode validation
21570 + * V0.07 generic rewrite vid
21571 + * V0.08 remove inode type
21575 +#include <linux/proc_fs.h>
21576 +#include <linux/fs_struct.h>
21577 +#include <linux/mount.h>
21578 +#include <asm/unistd.h>
21580 +#include <linux/vs_context.h>
21581 +#include <linux/vs_network.h>
21582 +#include <linux/vs_cvirt.h>
21584 +#include <linux/in.h>
21585 +#include <linux/inetdevice.h>
21586 +#include <linux/vs_inet.h>
21587 +#include <linux/vs_inet6.h>
21589 +#include <linux/vserver/global.h>
21591 +#include "cvirt_proc.h"
21592 +#include "cacct_proc.h"
21593 +#include "limit_proc.h"
21594 +#include "sched_proc.h"
21595 +#include "vci_config.h"
21598 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21602 + CAP_FOR_EACH_U32(__capi) {
21603 + buffer += sprintf(buffer, "%08x",
21604 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21610 +static struct proc_dir_entry *proc_virtual;
21612 +static struct proc_dir_entry *proc_virtnet;
21615 +/* first the actual feeds */
21618 +static int proc_vci(char *buffer)
21620 + return sprintf(buffer,
21621 + "VCIVersion:\t%04x:%04x\n"
21622 + "VCISyscall:\t%d\n"
21623 + "VCIKernel:\t%08x\n",
21624 + VCI_VERSION >> 16,
21625 + VCI_VERSION & 0xFFFF,
21627 + vci_kernel_config());
21630 +static int proc_virtual_info(char *buffer)
21632 + return proc_vci(buffer);
21635 +static int proc_virtual_status(char *buffer)
21637 + return sprintf(buffer,
21639 + "#CActive:\t%d\n"
21640 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21641 + "#InitTask:\t%d\t%d %d\n",
21642 + atomic_read(&vx_global_ctotal),
21643 + atomic_read(&vx_global_cactive),
21644 + atomic_read(&vs_global_nsproxy),
21645 + atomic_read(&vs_global_fs),
21646 + atomic_read(&vs_global_mnt_ns),
21647 + atomic_read(&vs_global_uts_ns),
21648 + atomic_read(&nr_ipc_ns),
21649 + atomic_read(&vs_global_user_ns),
21650 + atomic_read(&vs_global_pid_ns),
21651 + atomic_read(&init_task.usage),
21652 + atomic_read(&init_task.nsproxy->count),
21653 + init_task.fs->users);
21657 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21661 + length = sprintf(buffer,
21669 + vxi->vx_badness_bias);
21673 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21675 + char *orig = buffer;
21677 + buffer += sprintf(buffer,
21680 + "Flags:\t%016llx\n",
21681 + atomic_read(&vxi->vx_usecnt),
21682 + atomic_read(&vxi->vx_tasks),
21683 + (unsigned long long)vxi->vx_flags);
21685 + buffer += sprintf(buffer, "BCaps:\t");
21686 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21687 + buffer += sprintf(buffer, "\n");
21689 + buffer += sprintf(buffer,
21690 + "CCaps:\t%016llx\n"
21691 + "Spaces:\t%08lx %08lx\n",
21692 + (unsigned long long)vxi->vx_ccaps,
21693 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21694 + return buffer - orig;
21697 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21699 + return vx_info_proc_limit(&vxi->limit, buffer);
21702 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21706 + length = vx_info_proc_sched(&vxi->sched, buffer);
21707 + for_each_online_cpu(cpu) {
21708 + length += vx_info_proc_sched_pc(
21709 + &vx_per_cpu(vxi, sched_pc, cpu),
21710 + buffer + length, cpu);
21715 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21717 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21720 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21722 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21725 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21729 + vx_update_load(vxi);
21730 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21731 + for_each_online_cpu(cpu) {
21732 + length += vx_info_proc_cvirt_pc(
21733 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21734 + buffer + length, cpu);
21739 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21741 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21745 +static int proc_virtnet_info(char *buffer)
21747 + return proc_vci(buffer);
21750 +static int proc_virtnet_status(char *buffer)
21752 + return sprintf(buffer,
21754 + "#CActive:\t%d\n",
21755 + atomic_read(&nx_global_ctotal),
21756 + atomic_read(&nx_global_cactive));
21759 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21761 + struct nx_addr_v4 *v4a;
21762 +#ifdef CONFIG_IPV6
21763 + struct nx_addr_v6 *v6a;
21767 + length = sprintf(buffer,
21770 + "Bcast:\t" NIPQUAD_FMT "\n"
21771 + "Lback:\t" NIPQUAD_FMT "\n",
21774 + NIPQUAD(nxi->v4_bcast.s_addr),
21775 + NIPQUAD(nxi->v4_lback.s_addr));
21777 + if (!NX_IPV4(nxi))
21779 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21780 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21783 +#ifdef CONFIG_IPV6
21784 + if (!NX_IPV6(nxi))
21786 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21787 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21794 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21798 + length = sprintf(buffer,
21801 + "Flags:\t%016llx\n"
21802 + "NCaps:\t%016llx\n",
21803 + atomic_read(&nxi->nx_usecnt),
21804 + atomic_read(&nxi->nx_tasks),
21805 + (unsigned long long)nxi->nx_flags,
21806 + (unsigned long long)nxi->nx_ncaps);
21812 +/* here the inode helpers */
21818 + struct inode_operations *iop;
21819 + struct file_operations *fop;
21820 + union proc_op op;
21823 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21825 + struct inode *inode = new_inode(sb);
21830 + inode->i_mode = p->mode;
21832 + inode->i_op = p->iop;
21834 + inode->i_fop = p->fop;
21836 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
21837 + inode->i_flags |= S_IMMUTABLE;
21839 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21841 + inode->i_uid = 0;
21842 + inode->i_gid = 0;
21843 + inode->i_tag = 0;
21848 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21849 + struct dentry *dentry, int id, void *ptr)
21851 + struct vs_entry *p = ptr;
21852 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21853 + struct dentry *error = ERR_PTR(-EINVAL);
21858 + PROC_I(inode)->op = p->op;
21859 + PROC_I(inode)->fd = id;
21860 + d_add(dentry, inode);
21868 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21871 + * Fill a directory entry.
21873 + * If possible create the dcache entry and derive our inode number and
21874 + * file type from dcache entry.
21876 + * Since all of the proc inode numbers are dynamically generated, the inode
21877 + * numbers do not exist until the inode is cache. This means creating the
21878 + * the dcache entry in readdir is necessary to keep the inode numbers
21879 + * reported by readdir in sync with the inode numbers reported
21882 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21883 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21885 + struct dentry *child, *dir = filp->f_dentry;
21886 + struct inode *inode;
21887 + struct qstr qname;
21889 + unsigned type = DT_UNKNOWN;
21891 + qname.name = name;
21893 + qname.hash = full_name_hash(name, len);
21895 + child = d_lookup(dir, &qname);
21897 + struct dentry *new;
21898 + new = d_alloc(dir, &qname);
21900 + child = instantiate(dir->d_inode, new, id, ptr);
21907 + if (!child || IS_ERR(child) || !child->d_inode)
21908 + goto end_instantiate;
21909 + inode = child->d_inode;
21911 + ino = inode->i_ino;
21912 + type = inode->i_mode >> 12;
21917 + ino = find_inode_number(dir, &qname);
21920 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21925 +/* get and revalidate vx_info/xid */
21928 +struct vx_info *get_proc_vx_info(struct inode *inode)
21930 + return lookup_vx_info(PROC_I(inode)->fd);
21933 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
21935 + struct inode *inode = dentry->d_inode;
21936 + xid_t xid = PROC_I(inode)->fd;
21938 + if (!xid || xid_is_hashed(xid))
21945 +/* get and revalidate nx_info/nid */
21947 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
21949 + struct inode *inode = dentry->d_inode;
21950 + nid_t nid = PROC_I(inode)->fd;
21952 + if (!nid || nid_is_hashed(nid))
21960 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21962 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21963 + size_t count, loff_t *ppos)
21965 + struct inode *inode = file->f_dentry->d_inode;
21966 + unsigned long page;
21967 + ssize_t length = 0;
21969 + if (count > PROC_BLOCK_SIZE)
21970 + count = PROC_BLOCK_SIZE;
21972 + /* fade that out as soon as stable */
21973 + WARN_ON(PROC_I(inode)->fd);
21975 + if (!(page = __get_free_page(GFP_KERNEL)))
21978 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21979 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21982 + length = simple_read_from_buffer(buf, count, ppos,
21983 + (char *)page, length);
21989 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21990 + size_t count, loff_t *ppos)
21992 + struct inode *inode = file->f_dentry->d_inode;
21993 + struct vx_info *vxi = NULL;
21994 + xid_t xid = PROC_I(inode)->fd;
21995 + unsigned long page;
21996 + ssize_t length = 0;
21998 + if (count > PROC_BLOCK_SIZE)
21999 + count = PROC_BLOCK_SIZE;
22001 + /* fade that out as soon as stable */
22003 + vxi = lookup_vx_info(xid);
22007 + length = -ENOMEM;
22008 + if (!(page = __get_free_page(GFP_KERNEL)))
22011 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
22012 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
22015 + length = simple_read_from_buffer(buf, count, ppos,
22016 + (char *)page, length);
22020 + put_vx_info(vxi);
22025 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
22026 + size_t count, loff_t *ppos)
22028 + struct inode *inode = file->f_dentry->d_inode;
22029 + struct nx_info *nxi = NULL;
22030 + nid_t nid = PROC_I(inode)->fd;
22031 + unsigned long page;
22032 + ssize_t length = 0;
22034 + if (count > PROC_BLOCK_SIZE)
22035 + count = PROC_BLOCK_SIZE;
22037 + /* fade that out as soon as stable */
22039 + nxi = lookup_nx_info(nid);
22043 + length = -ENOMEM;
22044 + if (!(page = __get_free_page(GFP_KERNEL)))
22047 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
22048 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
22051 + length = simple_read_from_buffer(buf, count, ppos,
22052 + (char *)page, length);
22056 + put_nx_info(nxi);
22063 +/* here comes the lower level */
22066 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
22067 + .len = sizeof(NAME) - 1, \
22068 + .name = (NAME), \
22076 +#define DIR(NAME, MODE, OTYPE) \
22077 + NOD(NAME, (S_IFDIR | (MODE)), \
22078 + &proc_ ## OTYPE ## _inode_operations, \
22079 + &proc_ ## OTYPE ## _file_operations, { } )
22081 +#define INF(NAME, MODE, OTYPE) \
22082 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22083 + &proc_vs_info_file_operations, \
22084 + { .proc_vs_read = &proc_##OTYPE } )
22086 +#define VINF(NAME, MODE, OTYPE) \
22087 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22088 + &proc_vx_info_file_operations, \
22089 + { .proc_vxi_read = &proc_##OTYPE } )
22091 +#define NINF(NAME, MODE, OTYPE) \
22092 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22093 + &proc_nx_info_file_operations, \
22094 + { .proc_nxi_read = &proc_##OTYPE } )
22097 +static struct file_operations proc_vs_info_file_operations = {
22098 + .read = proc_vs_info_read,
22101 +static struct file_operations proc_vx_info_file_operations = {
22102 + .read = proc_vx_info_read,
22105 +static struct dentry_operations proc_xid_dentry_operations = {
22106 + .d_revalidate = proc_xid_revalidate,
22109 +static struct vs_entry vx_base_stuff[] = {
22110 + VINF("info", S_IRUGO, vxi_info),
22111 + VINF("status", S_IRUGO, vxi_status),
22112 + VINF("limit", S_IRUGO, vxi_limit),
22113 + VINF("sched", S_IRUGO, vxi_sched),
22114 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
22115 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
22116 + VINF("cvirt", S_IRUGO, vxi_cvirt),
22117 + VINF("cacct", S_IRUGO, vxi_cacct),
22124 +static struct dentry *proc_xid_instantiate(struct inode *dir,
22125 + struct dentry *dentry, int id, void *ptr)
22127 + dentry->d_op = &proc_xid_dentry_operations;
22128 + return vs_proc_instantiate(dir, dentry, id, ptr);
22131 +static struct dentry *proc_xid_lookup(struct inode *dir,
22132 + struct dentry *dentry, struct nameidata *nd)
22134 + struct vs_entry *p = vx_base_stuff;
22135 + struct dentry *error = ERR_PTR(-ENOENT);
22137 + for (; p->name; p++) {
22138 + if (p->len != dentry->d_name.len)
22140 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22146 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22151 +static int proc_xid_readdir(struct file *filp,
22152 + void *dirent, filldir_t filldir)
22154 + struct dentry *dentry = filp->f_dentry;
22155 + struct inode *inode = dentry->d_inode;
22156 + struct vs_entry *p = vx_base_stuff;
22157 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
22161 + pos = filp->f_pos;
22164 + ino = inode->i_ino;
22165 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22168 + /* fall through */
22170 + ino = parent_ino(dentry);
22171 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22174 + /* fall through */
22177 + if (index >= size)
22179 + for (p += index; p->name; p++) {
22180 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22181 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22187 + filp->f_pos = pos;
22193 +static struct file_operations proc_nx_info_file_operations = {
22194 + .read = proc_nx_info_read,
22197 +static struct dentry_operations proc_nid_dentry_operations = {
22198 + .d_revalidate = proc_nid_revalidate,
22201 +static struct vs_entry nx_base_stuff[] = {
22202 + NINF("info", S_IRUGO, nxi_info),
22203 + NINF("status", S_IRUGO, nxi_status),
22208 +static struct dentry *proc_nid_instantiate(struct inode *dir,
22209 + struct dentry *dentry, int id, void *ptr)
22211 + dentry->d_op = &proc_nid_dentry_operations;
22212 + return vs_proc_instantiate(dir, dentry, id, ptr);
22215 +static struct dentry *proc_nid_lookup(struct inode *dir,
22216 + struct dentry *dentry, struct nameidata *nd)
22218 + struct vs_entry *p = nx_base_stuff;
22219 + struct dentry *error = ERR_PTR(-ENOENT);
22221 + for (; p->name; p++) {
22222 + if (p->len != dentry->d_name.len)
22224 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22230 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22235 +static int proc_nid_readdir(struct file *filp,
22236 + void *dirent, filldir_t filldir)
22238 + struct dentry *dentry = filp->f_dentry;
22239 + struct inode *inode = dentry->d_inode;
22240 + struct vs_entry *p = nx_base_stuff;
22241 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
22245 + pos = filp->f_pos;
22248 + ino = inode->i_ino;
22249 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22252 + /* fall through */
22254 + ino = parent_ino(dentry);
22255 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22258 + /* fall through */
22261 + if (index >= size)
22263 + for (p += index; p->name; p++) {
22264 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22265 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22271 + filp->f_pos = pos;
22276 +#define MAX_MULBY10 ((~0U - 9) / 10)
22278 +static inline int atovid(const char *str, int len)
22283 + while (len-- > 0) {
22288 + if (vid >= MAX_MULBY10)
22298 +/* now the upper level (virtual) */
22301 +static struct file_operations proc_xid_file_operations = {
22302 + .read = generic_read_dir,
22303 + .readdir = proc_xid_readdir,
22306 +static struct inode_operations proc_xid_inode_operations = {
22307 + .lookup = proc_xid_lookup,
22310 +static struct vs_entry vx_virtual_stuff[] = {
22311 + INF("info", S_IRUGO, virtual_info),
22312 + INF("status", S_IRUGO, virtual_status),
22313 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
22317 +static struct dentry *proc_virtual_lookup(struct inode *dir,
22318 + struct dentry *dentry, struct nameidata *nd)
22320 + struct vs_entry *p = vx_virtual_stuff;
22321 + struct dentry *error = ERR_PTR(-ENOENT);
22324 + for (; p->name; p++) {
22325 + if (p->len != dentry->d_name.len)
22327 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22331 + goto instantiate;
22333 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22334 + if ((id < 0) || !xid_is_hashed(id))
22338 + error = proc_xid_instantiate(dir, dentry, id, p);
22343 +static struct file_operations proc_nid_file_operations = {
22344 + .read = generic_read_dir,
22345 + .readdir = proc_nid_readdir,
22348 +static struct inode_operations proc_nid_inode_operations = {
22349 + .lookup = proc_nid_lookup,
22352 +static struct vs_entry nx_virtnet_stuff[] = {
22353 + INF("info", S_IRUGO, virtnet_info),
22354 + INF("status", S_IRUGO, virtnet_status),
22355 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
22359 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
22360 + struct dentry *dentry, struct nameidata *nd)
22362 + struct vs_entry *p = nx_virtnet_stuff;
22363 + struct dentry *error = ERR_PTR(-ENOENT);
22366 + for (; p->name; p++) {
22367 + if (p->len != dentry->d_name.len)
22369 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22373 + goto instantiate;
22375 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22376 + if ((id < 0) || !nid_is_hashed(id))
22380 + error = proc_nid_instantiate(dir, dentry, id, p);
22386 +#define PROC_MAXVIDS 32
22388 +int proc_virtual_readdir(struct file *filp,
22389 + void *dirent, filldir_t filldir)
22391 + struct dentry *dentry = filp->f_dentry;
22392 + struct inode *inode = dentry->d_inode;
22393 + struct vs_entry *p = vx_virtual_stuff;
22394 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
22396 + unsigned int xid_array[PROC_MAXVIDS];
22397 + char buf[PROC_NUMBUF];
22398 + unsigned int nr_xids, i;
22401 + pos = filp->f_pos;
22404 + ino = inode->i_ino;
22405 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22408 + /* fall through */
22410 + ino = parent_ino(dentry);
22411 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22414 + /* fall through */
22417 + if (index >= size)
22419 + for (p += index; p->name; p++) {
22420 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22421 + vs_proc_instantiate, 0, p))
22426 + index = pos - size;
22427 + p = &vx_virtual_stuff[size - 1];
22428 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22429 + for (i = 0; i < nr_xids; i++) {
22430 + int n, xid = xid_array[i];
22431 + unsigned int j = PROC_NUMBUF;
22435 + buf[--j] = '0' + (n % 10);
22438 + if (proc_fill_cache(filp, dirent, filldir,
22439 + buf + j, PROC_NUMBUF - j,
22440 + vs_proc_instantiate, xid, p))
22446 + filp->f_pos = pos;
22450 +static int proc_virtual_getattr(struct vfsmount *mnt,
22451 + struct dentry *dentry, struct kstat *stat)
22453 + struct inode *inode = dentry->d_inode;
22455 + generic_fillattr(inode, stat);
22456 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22460 +static struct file_operations proc_virtual_dir_operations = {
22461 + .read = generic_read_dir,
22462 + .readdir = proc_virtual_readdir,
22465 +static struct inode_operations proc_virtual_dir_inode_operations = {
22466 + .getattr = proc_virtual_getattr,
22467 + .lookup = proc_virtual_lookup,
22474 +int proc_virtnet_readdir(struct file *filp,
22475 + void *dirent, filldir_t filldir)
22477 + struct dentry *dentry = filp->f_dentry;
22478 + struct inode *inode = dentry->d_inode;
22479 + struct vs_entry *p = nx_virtnet_stuff;
22480 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22482 + unsigned int nid_array[PROC_MAXVIDS];
22483 + char buf[PROC_NUMBUF];
22484 + unsigned int nr_nids, i;
22487 + pos = filp->f_pos;
22490 + ino = inode->i_ino;
22491 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22494 + /* fall through */
22496 + ino = parent_ino(dentry);
22497 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22500 + /* fall through */
22503 + if (index >= size)
22505 + for (p += index; p->name; p++) {
22506 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22507 + vs_proc_instantiate, 0, p))
22512 + index = pos - size;
22513 + p = &nx_virtnet_stuff[size - 1];
22514 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22515 + for (i = 0; i < nr_nids; i++) {
22516 + int n, nid = nid_array[i];
22517 + unsigned int j = PROC_NUMBUF;
22521 + buf[--j] = '0' + (n % 10);
22524 + if (proc_fill_cache(filp, dirent, filldir,
22525 + buf + j, PROC_NUMBUF - j,
22526 + vs_proc_instantiate, nid, p))
22532 + filp->f_pos = pos;
22536 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22537 + struct dentry *dentry, struct kstat *stat)
22539 + struct inode *inode = dentry->d_inode;
22541 + generic_fillattr(inode, stat);
22542 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22546 +static struct file_operations proc_virtnet_dir_operations = {
22547 + .read = generic_read_dir,
22548 + .readdir = proc_virtnet_readdir,
22551 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22552 + .getattr = proc_virtnet_getattr,
22553 + .lookup = proc_virtnet_lookup,
22558 +void proc_vx_init(void)
22560 + struct proc_dir_entry *ent;
22562 + ent = proc_mkdir("virtual", 0);
22564 + ent->proc_fops = &proc_virtual_dir_operations;
22565 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22567 + proc_virtual = ent;
22569 + ent = proc_mkdir("virtnet", 0);
22571 + ent->proc_fops = &proc_virtnet_dir_operations;
22572 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22574 + proc_virtnet = ent;
22580 +/* per pid info */
22583 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22585 + struct vx_info *vxi;
22586 + char *orig = buffer;
22588 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22590 + vxi = task_get_vx_info(p);
22594 + buffer += sprintf(buffer, "BCaps:\t");
22595 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22596 + buffer += sprintf(buffer, "\n");
22597 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22598 + (unsigned long long)vxi->vx_ccaps);
22599 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22600 + (unsigned long long)vxi->vx_flags);
22601 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22603 + put_vx_info(vxi);
22605 + return buffer - orig;
22609 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22611 + struct nx_info *nxi;
22612 + struct nx_addr_v4 *v4a;
22613 +#ifdef CONFIG_IPV6
22614 + struct nx_addr_v6 *v6a;
22616 + char *orig = buffer;
22619 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22621 + nxi = task_get_nx_info(p);
22625 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22626 + (unsigned long long)nxi->nx_ncaps);
22627 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22628 + (unsigned long long)nxi->nx_flags);
22630 + buffer += sprintf(buffer,
22631 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22632 + NIPQUAD(nxi->v4_bcast.s_addr));
22633 + buffer += sprintf (buffer,
22634 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22635 + NIPQUAD(nxi->v4_lback.s_addr));
22636 + if (!NX_IPV4(nxi))
22638 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22639 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22642 +#ifdef CONFIG_IPV6
22643 + if (!NX_IPV6(nxi))
22645 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22646 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22650 + put_nx_info(nxi);
22652 + return buffer - orig;
22655 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/sched.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/sched.c
22656 --- linux-2.6.38.1/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22657 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/sched.c 2011-01-29 02:01:07.000000000 +0100
22660 + * linux/kernel/vserver/sched.c
22662 + * Virtual Server: Scheduler Support
22664 + * Copyright (C) 2004-2010 Herbert Pötzl
22666 + * V0.01 adapted Sam Vilains version to 2.6.3
22667 + * V0.02 removed legacy interface
22668 + * V0.03 changed vcmds to vxi arg
22669 + * V0.04 removed older and legacy interfaces
22670 + * V0.05 removed scheduler code/commands
22674 +#include <linux/vs_context.h>
22675 +#include <linux/vs_sched.h>
22676 +#include <linux/vserver/sched_cmd.h>
22678 +#include <asm/uaccess.h>
22681 +void vx_update_sched_param(struct _vx_sched *sched,
22682 + struct _vx_sched_pc *sched_pc)
22684 + sched_pc->prio_bias = sched->prio_bias;
22687 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22691 + if (data->prio_bias > MAX_PRIO_BIAS)
22692 + data->prio_bias = MAX_PRIO_BIAS;
22693 + if (data->prio_bias < MIN_PRIO_BIAS)
22694 + data->prio_bias = MIN_PRIO_BIAS;
22696 + if (data->cpu_id != ~0) {
22697 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22698 + cpus_and(vxi->sched.update, cpu_online_map,
22699 + vxi->sched.update);
22701 + vxi->sched.update = cpu_online_map;
22703 + for_each_cpu_mask(cpu, vxi->sched.update)
22704 + vx_update_sched_param(&vxi->sched,
22705 + &vx_per_cpu(vxi, sched_pc, cpu));
22709 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22711 + struct vcmd_prio_bias vc_data;
22713 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22716 + return do_set_prio_bias(vxi, &vc_data);
22719 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22721 + struct vcmd_prio_bias vc_data;
22722 + struct _vx_sched_pc *pcd;
22725 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22728 + cpu = vc_data.cpu_id;
22730 + if (!cpu_possible(cpu))
22733 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22734 + vc_data.prio_bias = pcd->prio_bias;
22736 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22741 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/sched_init.h linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/sched_init.h
22742 --- linux-2.6.38.1/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22743 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/sched_init.h 2011-01-29 02:01:07.000000000 +0100
22746 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22748 + /* scheduling; hard code starting values as constants */
22749 + sched->prio_bias = 0;
22753 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22755 + sched_pc->prio_bias = 0;
22757 + sched_pc->user_ticks = 0;
22758 + sched_pc->sys_ticks = 0;
22759 + sched_pc->hold_ticks = 0;
22762 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22768 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22772 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/sched_proc.h linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/sched_proc.h
22773 --- linux-2.6.38.1/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22774 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/sched_proc.h 2011-01-29 02:01:07.000000000 +0100
22776 +#ifndef _VX_SCHED_PROC_H
22777 +#define _VX_SCHED_PROC_H
22781 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22785 + length += sprintf(buffer,
22786 + "PrioBias:\t%8d\n",
22787 + sched->prio_bias);
22792 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22793 + char *buffer, int cpu)
22797 + length += sprintf(buffer + length,
22798 + "cpu %d: %lld %lld %lld", cpu,
22799 + (unsigned long long)sched_pc->user_ticks,
22800 + (unsigned long long)sched_pc->sys_ticks,
22801 + (unsigned long long)sched_pc->hold_ticks);
22802 + length += sprintf(buffer + length,
22803 + " %d\n", sched_pc->prio_bias);
22807 +#endif /* _VX_SCHED_PROC_H */
22808 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/signal.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/signal.c
22809 --- linux-2.6.38.1/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22810 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/signal.c 2011-03-22 17:37:59.000000000 +0100
22813 + * linux/kernel/vserver/signal.c
22815 + * Virtual Server: Signal Support
22817 + * Copyright (C) 2003-2007 Herbert Pötzl
22819 + * V0.01 broken out from vcontext V0.05
22820 + * V0.02 changed vcmds to vxi arg
22821 + * V0.03 adjusted siginfo for kill
22825 +#include <asm/uaccess.h>
22827 +#include <linux/vs_context.h>
22828 +#include <linux/vs_pid.h>
22829 +#include <linux/vserver/signal_cmd.h>
22832 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22834 + int retval, count = 0;
22835 + struct task_struct *p;
22836 + struct siginfo *sip = SEND_SIG_PRIV;
22839 + vxdprintk(VXD_CBIT(misc, 4),
22840 + "vx_info_kill(%p[#%d],%d,%d)*",
22841 + vxi, vxi->vx_id, pid, sig);
22842 + read_lock(&tasklist_lock);
22846 + for_each_process(p) {
22849 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22850 + (pid && vxi->vx_initpid == p->pid))
22853 + err = group_send_sig_info(sig, sip, p);
22855 + if (err != -EPERM)
22861 + if (vxi->vx_initpid) {
22862 + pid = vxi->vx_initpid;
22863 + /* for now, only SIGINT to private init ... */
22864 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22865 + /* ... as long as there are tasks left */
22866 + (atomic_read(&vxi->vx_tasks) > 1))
22869 + /* fallthrough */
22872 + p = find_task_by_real_pid(pid);
22873 + rcu_read_unlock();
22875 + if (vx_task_xid(p) == vxi->vx_id)
22876 + retval = group_send_sig_info(sig, sip, p);
22880 + read_unlock(&tasklist_lock);
22881 + vxdprintk(VXD_CBIT(misc, 4),
22882 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22883 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22887 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22889 + struct vcmd_ctx_kill_v0 vc_data;
22891 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22894 + /* special check to allow guest shutdown */
22895 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22896 + /* forbid killall pid=0 when init is present */
22897 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22898 + (vc_data.pid > 1)))
22901 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22905 +static int __wait_exit(struct vx_info *vxi)
22907 + DECLARE_WAITQUEUE(wait, current);
22910 + add_wait_queue(&vxi->vx_wait, &wait);
22911 + set_current_state(TASK_INTERRUPTIBLE);
22914 + if (vx_info_state(vxi,
22915 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22917 + if (signal_pending(current)) {
22918 + ret = -ERESTARTSYS;
22925 + set_current_state(TASK_RUNNING);
22926 + remove_wait_queue(&vxi->vx_wait, &wait);
22932 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22934 + struct vcmd_wait_exit_v0 vc_data;
22937 + ret = __wait_exit(vxi);
22938 + vc_data.reboot_cmd = vxi->reboot_cmd;
22939 + vc_data.exit_code = vxi->exit_code;
22941 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22946 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/space.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/space.c
22947 --- linux-2.6.38.1/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22948 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/space.c 2011-02-01 03:30:46.000000000 +0100
22951 + * linux/kernel/vserver/space.c
22953 + * Virtual Server: Context Space Support
22955 + * Copyright (C) 2003-2010 Herbert Pötzl
22957 + * V0.01 broken out from context.c 0.07
22958 + * V0.02 added task locking for namespace
22959 + * V0.03 broken out vx_enter_namespace
22960 + * V0.04 added *space support and commands
22961 + * V0.05 added credential support
22965 +#include <linux/utsname.h>
22966 +#include <linux/nsproxy.h>
22967 +#include <linux/err.h>
22968 +#include <linux/fs_struct.h>
22969 +#include <linux/cred.h>
22970 +#include <asm/uaccess.h>
22972 +#include <linux/vs_context.h>
22973 +#include <linux/vserver/space.h>
22974 +#include <linux/vserver/space_cmd.h>
22976 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22977 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22978 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22979 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22980 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22981 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22984 +/* namespace functions */
22986 +#include <linux/mnt_namespace.h>
22987 +#include <linux/user_namespace.h>
22988 +#include <linux/pid_namespace.h>
22989 +#include <linux/ipc_namespace.h>
22990 +#include <net/net_namespace.h>
22993 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22994 + .mask = CLONE_FS |
23002 +static const struct vcmd_space_mask_v1 space_mask = {
23003 + .mask = CLONE_FS |
23008 +#ifdef CONFIG_PID_NS
23011 +#ifdef CONFIG_NET_NS
23017 +static const struct vcmd_space_mask_v1 default_space_mask = {
23018 + .mask = CLONE_FS |
23023 +#ifdef CONFIG_PID_NS
23030 + * build a new nsproxy mix
23031 + * assumes that both proxies are 'const'
23032 + * does not touch nsproxy refcounts
23033 + * will hold a reference on the result.
23036 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
23037 + struct nsproxy *new_nsproxy, unsigned long mask)
23039 + struct mnt_namespace *old_ns;
23040 + struct uts_namespace *old_uts;
23041 + struct ipc_namespace *old_ipc;
23042 +#ifdef CONFIG_PID_NS
23043 + struct pid_namespace *old_pid;
23045 +#ifdef CONFIG_NET_NS
23046 + struct net *old_net;
23048 + struct nsproxy *nsproxy;
23050 + nsproxy = copy_nsproxy(old_nsproxy);
23054 + if (mask & CLONE_NEWNS) {
23055 + old_ns = nsproxy->mnt_ns;
23056 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
23057 + if (nsproxy->mnt_ns)
23058 + get_mnt_ns(nsproxy->mnt_ns);
23062 + if (mask & CLONE_NEWUTS) {
23063 + old_uts = nsproxy->uts_ns;
23064 + nsproxy->uts_ns = new_nsproxy->uts_ns;
23065 + if (nsproxy->uts_ns)
23066 + get_uts_ns(nsproxy->uts_ns);
23070 + if (mask & CLONE_NEWIPC) {
23071 + old_ipc = nsproxy->ipc_ns;
23072 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
23073 + if (nsproxy->ipc_ns)
23074 + get_ipc_ns(nsproxy->ipc_ns);
23078 +#ifdef CONFIG_PID_NS
23079 + if (mask & CLONE_NEWPID) {
23080 + old_pid = nsproxy->pid_ns;
23081 + nsproxy->pid_ns = new_nsproxy->pid_ns;
23082 + if (nsproxy->pid_ns)
23083 + get_pid_ns(nsproxy->pid_ns);
23087 +#ifdef CONFIG_NET_NS
23088 + if (mask & CLONE_NEWNET) {
23089 + old_net = nsproxy->net_ns;
23090 + nsproxy->net_ns = new_nsproxy->net_ns;
23091 + if (nsproxy->net_ns)
23092 + get_net(nsproxy->net_ns);
23097 + put_mnt_ns(old_ns);
23099 + put_uts_ns(old_uts);
23101 + put_ipc_ns(old_ipc);
23102 +#ifdef CONFIG_PID_NS
23104 + put_pid_ns(old_pid);
23106 +#ifdef CONFIG_NET_NS
23108 + put_net(old_net);
23116 + * merge two nsproxy structs into a new one.
23117 + * will hold a reference on the result.
23121 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
23122 + struct nsproxy *proxy, unsigned long mask)
23124 + struct nsproxy null_proxy = { .mnt_ns = NULL };
23130 + /* vs_mix_nsproxy returns with reference */
23131 + return vs_mix_nsproxy(old ? old : &null_proxy,
23134 + get_nsproxy(proxy);
23139 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23141 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
23142 + struct fs_struct *fs_cur, *fs = NULL;
23143 + struct _vx_space *space;
23144 + int ret, kill = 0;
23146 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
23147 + vxi, vxi->vx_id, mask, index);
23149 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
23152 + if (index >= VX_SPACES)
23155 + space = &vxi->space[index];
23158 + mask = space->vx_nsmask;
23160 + if ((mask & space->vx_nsmask) != mask)
23163 + if (mask & CLONE_FS) {
23164 + fs = copy_fs_struct(space->vx_fs);
23168 + proxy = space->vx_nsproxy;
23170 + vxdprintk(VXD_CBIT(space, 9),
23171 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
23172 + vxi, vxi->vx_id, mask, index, proxy, fs);
23174 + task_lock(current);
23175 + fs_cur = current->fs;
23177 + if (mask & CLONE_FS) {
23178 + spin_lock(&fs_cur->lock);
23179 + current->fs = fs;
23180 + kill = !--fs_cur->users;
23181 + spin_unlock(&fs_cur->lock);
23184 + proxy_cur = current->nsproxy;
23185 + get_nsproxy(proxy_cur);
23186 + task_unlock(current);
23189 + free_fs_struct(fs_cur);
23191 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
23192 + if (IS_ERR(proxy_new)) {
23193 + ret = PTR_ERR(proxy_new);
23197 + proxy_new = xchg(¤t->nsproxy, proxy_new);
23199 + if (mask & CLONE_NEWUSER) {
23200 + struct cred *cred;
23202 + vxdprintk(VXD_CBIT(space, 10),
23203 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
23204 + vxi, vxi->vx_id, space->vx_cred,
23205 + current->real_cred, current->cred);
23207 + if (space->vx_cred) {
23208 + cred = __prepare_creds(space->vx_cred);
23210 + commit_creds(cred);
23217 + put_nsproxy(proxy_new);
23220 + put_nsproxy(proxy_cur);
23225 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23227 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
23228 + struct fs_struct *fs_vxi, *fs;
23229 + struct _vx_space *space;
23230 + int ret, kill = 0;
23232 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
23233 + vxi, vxi->vx_id, mask, index);
23235 + if ((mask & space_mask.mask) != mask)
23238 + if (index >= VX_SPACES)
23241 + space = &vxi->space[index];
23243 + proxy_vxi = space->vx_nsproxy;
23244 + fs_vxi = space->vx_fs;
23246 + if (mask & CLONE_FS) {
23247 + fs = copy_fs_struct(current->fs);
23252 + task_lock(current);
23254 + if (mask & CLONE_FS) {
23255 + spin_lock(&fs_vxi->lock);
23256 + space->vx_fs = fs;
23257 + kill = !--fs_vxi->users;
23258 + spin_unlock(&fs_vxi->lock);
23261 + proxy_cur = current->nsproxy;
23262 + get_nsproxy(proxy_cur);
23263 + task_unlock(current);
23266 + free_fs_struct(fs_vxi);
23268 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
23269 + if (IS_ERR(proxy_new)) {
23270 + ret = PTR_ERR(proxy_new);
23274 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
23275 + space->vx_nsmask |= mask;
23277 + if (mask & CLONE_NEWUSER) {
23278 + struct cred *cred;
23280 + vxdprintk(VXD_CBIT(space, 10),
23281 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
23282 + vxi, vxi->vx_id, space->vx_cred,
23283 + current->real_cred, current->cred);
23285 + cred = prepare_creds();
23286 + cred = (struct cred *)xchg(&space->vx_cred, cred);
23288 + abort_creds(cred);
23294 + put_nsproxy(proxy_new);
23297 + put_nsproxy(proxy_cur);
23302 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
23304 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23306 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23309 + return vx_enter_space(vxi, vc_data.mask, 0);
23312 +int vc_enter_space(struct vx_info *vxi, void __user *data)
23314 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23316 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23319 + if (vc_data.index >= VX_SPACES)
23322 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
23325 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
23327 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23329 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23332 + return vx_set_space(vxi, vc_data.mask, 0);
23335 +int vc_set_space(struct vx_info *vxi, void __user *data)
23337 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23339 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23342 + if (vc_data.index >= VX_SPACES)
23345 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
23348 +int vc_get_space_mask(void __user *data, int type)
23350 + const struct vcmd_space_mask_v1 *mask;
23353 + mask = &space_mask_v0;
23354 + else if (type == 1)
23355 + mask = &space_mask;
23357 + mask = &default_space_mask;
23359 + vxdprintk(VXD_CBIT(space, 10),
23360 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
23362 + if (copy_to_user(data, mask, sizeof(*mask)))
23367 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/switch.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/switch.c
23368 --- linux-2.6.38.1/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
23369 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/switch.c 2011-01-29 02:01:07.000000000 +0100
23372 + * linux/kernel/vserver/switch.c
23374 + * Virtual Server: Syscall Switch
23376 + * Copyright (C) 2003-2007 Herbert Pötzl
23378 + * V0.01 syscall switch
23379 + * V0.02 added signal to context
23380 + * V0.03 added rlimit functions
23381 + * V0.04 added iattr, task/xid functions
23382 + * V0.05 added debug/history stuff
23383 + * V0.06 added compat32 layer
23384 + * V0.07 vcmd args and perms
23385 + * V0.08 added status commands
23386 + * V0.09 added tag commands
23387 + * V0.10 added oom bias
23388 + * V0.11 added device commands
23392 +#include <linux/vs_context.h>
23393 +#include <linux/vs_network.h>
23394 +#include <linux/vserver/switch.h>
23396 +#include "vci_config.h"
23400 +int vc_get_version(uint32_t id)
23402 + return VCI_VERSION;
23406 +int vc_get_vci(uint32_t id)
23408 + return vci_kernel_config();
23411 +#include <linux/vserver/context_cmd.h>
23412 +#include <linux/vserver/cvirt_cmd.h>
23413 +#include <linux/vserver/cacct_cmd.h>
23414 +#include <linux/vserver/limit_cmd.h>
23415 +#include <linux/vserver/network_cmd.h>
23416 +#include <linux/vserver/sched_cmd.h>
23417 +#include <linux/vserver/debug_cmd.h>
23418 +#include <linux/vserver/inode_cmd.h>
23419 +#include <linux/vserver/dlimit_cmd.h>
23420 +#include <linux/vserver/signal_cmd.h>
23421 +#include <linux/vserver/space_cmd.h>
23422 +#include <linux/vserver/tag_cmd.h>
23423 +#include <linux/vserver/device_cmd.h>
23425 +#include <linux/vserver/inode.h>
23426 +#include <linux/vserver/dlimit.h>
23429 +#ifdef CONFIG_COMPAT
23430 +#define __COMPAT(name, id, data, compat) \
23431 + (compat) ? name ## _x32(id, data) : name(id, data)
23432 +#define __COMPAT_NO_ID(name, data, compat) \
23433 + (compat) ? name ## _x32(data) : name(data)
23435 +#define __COMPAT(name, id, data, compat) \
23437 +#define __COMPAT_NO_ID(name, data, compat) \
23443 +long do_vcmd(uint32_t cmd, uint32_t id,
23444 + struct vx_info *vxi, struct nx_info *nxi,
23445 + void __user *data, int compat)
23449 + case VCMD_get_version:
23450 + return vc_get_version(id);
23451 + case VCMD_get_vci:
23452 + return vc_get_vci(id);
23454 + case VCMD_task_xid:
23455 + return vc_task_xid(id);
23456 + case VCMD_vx_info:
23457 + return vc_vx_info(vxi, data);
23459 + case VCMD_task_nid:
23460 + return vc_task_nid(id);
23461 + case VCMD_nx_info:
23462 + return vc_nx_info(nxi, data);
23464 + case VCMD_task_tag:
23465 + return vc_task_tag(id);
23467 + case VCMD_set_space_v1:
23468 + return vc_set_space_v1(vxi, data);
23469 + /* this is version 2 */
23470 + case VCMD_set_space:
23471 + return vc_set_space(vxi, data);
23473 + case VCMD_get_space_mask_v0:
23474 + return vc_get_space_mask(data, 0);
23475 + /* this is version 1 */
23476 + case VCMD_get_space_mask:
23477 + return vc_get_space_mask(data, 1);
23479 + case VCMD_get_space_default:
23480 + return vc_get_space_mask(data, -1);
23482 +#ifdef CONFIG_IA32_EMULATION
23483 + case VCMD_get_rlimit:
23484 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23485 + case VCMD_set_rlimit:
23486 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23488 + case VCMD_get_rlimit:
23489 + return vc_get_rlimit(vxi, data);
23490 + case VCMD_set_rlimit:
23491 + return vc_set_rlimit(vxi, data);
23493 + case VCMD_get_rlimit_mask:
23494 + return vc_get_rlimit_mask(id, data);
23495 + case VCMD_reset_hits:
23496 + return vc_reset_hits(vxi, data);
23497 + case VCMD_reset_minmax:
23498 + return vc_reset_minmax(vxi, data);
23500 + case VCMD_get_vhi_name:
23501 + return vc_get_vhi_name(vxi, data);
23502 + case VCMD_set_vhi_name:
23503 + return vc_set_vhi_name(vxi, data);
23505 + case VCMD_ctx_stat:
23506 + return vc_ctx_stat(vxi, data);
23507 + case VCMD_virt_stat:
23508 + return vc_virt_stat(vxi, data);
23509 + case VCMD_sock_stat:
23510 + return vc_sock_stat(vxi, data);
23511 + case VCMD_rlimit_stat:
23512 + return vc_rlimit_stat(vxi, data);
23514 + case VCMD_set_cflags:
23515 + return vc_set_cflags(vxi, data);
23516 + case VCMD_get_cflags:
23517 + return vc_get_cflags(vxi, data);
23519 + /* this is version 1 */
23520 + case VCMD_set_ccaps:
23521 + return vc_set_ccaps(vxi, data);
23522 + /* this is version 1 */
23523 + case VCMD_get_ccaps:
23524 + return vc_get_ccaps(vxi, data);
23525 + case VCMD_set_bcaps:
23526 + return vc_set_bcaps(vxi, data);
23527 + case VCMD_get_bcaps:
23528 + return vc_get_bcaps(vxi, data);
23530 + case VCMD_set_badness:
23531 + return vc_set_badness(vxi, data);
23532 + case VCMD_get_badness:
23533 + return vc_get_badness(vxi, data);
23535 + case VCMD_set_nflags:
23536 + return vc_set_nflags(nxi, data);
23537 + case VCMD_get_nflags:
23538 + return vc_get_nflags(nxi, data);
23540 + case VCMD_set_ncaps:
23541 + return vc_set_ncaps(nxi, data);
23542 + case VCMD_get_ncaps:
23543 + return vc_get_ncaps(nxi, data);
23545 + case VCMD_set_prio_bias:
23546 + return vc_set_prio_bias(vxi, data);
23547 + case VCMD_get_prio_bias:
23548 + return vc_get_prio_bias(vxi, data);
23549 + case VCMD_add_dlimit:
23550 + return __COMPAT(vc_add_dlimit, id, data, compat);
23551 + case VCMD_rem_dlimit:
23552 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23553 + case VCMD_set_dlimit:
23554 + return __COMPAT(vc_set_dlimit, id, data, compat);
23555 + case VCMD_get_dlimit:
23556 + return __COMPAT(vc_get_dlimit, id, data, compat);
23558 + case VCMD_ctx_kill:
23559 + return vc_ctx_kill(vxi, data);
23561 + case VCMD_wait_exit:
23562 + return vc_wait_exit(vxi, data);
23564 + case VCMD_get_iattr:
23565 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23566 + case VCMD_set_iattr:
23567 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23569 + case VCMD_fget_iattr:
23570 + return vc_fget_iattr(id, data);
23571 + case VCMD_fset_iattr:
23572 + return vc_fset_iattr(id, data);
23574 + case VCMD_enter_space_v0:
23575 + return vc_enter_space_v1(vxi, NULL);
23576 + case VCMD_enter_space_v1:
23577 + return vc_enter_space_v1(vxi, data);
23578 + /* this is version 2 */
23579 + case VCMD_enter_space:
23580 + return vc_enter_space(vxi, data);
23582 + case VCMD_ctx_create_v0:
23583 + return vc_ctx_create(id, NULL);
23584 + case VCMD_ctx_create:
23585 + return vc_ctx_create(id, data);
23586 + case VCMD_ctx_migrate_v0:
23587 + return vc_ctx_migrate(vxi, NULL);
23588 + case VCMD_ctx_migrate:
23589 + return vc_ctx_migrate(vxi, data);
23591 + case VCMD_net_create_v0:
23592 + return vc_net_create(id, NULL);
23593 + case VCMD_net_create:
23594 + return vc_net_create(id, data);
23595 + case VCMD_net_migrate:
23596 + return vc_net_migrate(nxi, data);
23598 + case VCMD_tag_migrate:
23599 + return vc_tag_migrate(id);
23601 + case VCMD_net_add:
23602 + return vc_net_add(nxi, data);
23603 + case VCMD_net_remove:
23604 + return vc_net_remove(nxi, data);
23606 + case VCMD_net_add_ipv4:
23607 + return vc_net_add_ipv4(nxi, data);
23608 + case VCMD_net_remove_ipv4:
23609 + return vc_net_remove_ipv4(nxi, data);
23610 +#ifdef CONFIG_IPV6
23611 + case VCMD_net_add_ipv6:
23612 + return vc_net_add_ipv6(nxi, data);
23613 + case VCMD_net_remove_ipv6:
23614 + return vc_net_remove_ipv6(nxi, data);
23616 +/* case VCMD_add_match_ipv4:
23617 + return vc_add_match_ipv4(nxi, data);
23618 + case VCMD_get_match_ipv4:
23619 + return vc_get_match_ipv4(nxi, data);
23620 +#ifdef CONFIG_IPV6
23621 + case VCMD_add_match_ipv6:
23622 + return vc_add_match_ipv6(nxi, data);
23623 + case VCMD_get_match_ipv6:
23624 + return vc_get_match_ipv6(nxi, data);
23627 +#ifdef CONFIG_VSERVER_DEVICE
23628 + case VCMD_set_mapping:
23629 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23630 + case VCMD_unset_mapping:
23631 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23633 +#ifdef CONFIG_VSERVER_HISTORY
23634 + case VCMD_dump_history:
23635 + return vc_dump_history(id);
23636 + case VCMD_read_history:
23637 + return __COMPAT(vc_read_history, id, data, compat);
23640 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23641 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23647 +#define __VCMD(vcmd, _perm, _args, _flags) \
23648 + case VCMD_ ## vcmd: perm = _perm; \
23649 + args = _args; flags = _flags; break
23652 +#define VCA_NONE 0x00
23653 +#define VCA_VXI 0x01
23654 +#define VCA_NXI 0x02
23656 +#define VCF_NONE 0x00
23657 +#define VCF_INFO 0x01
23658 +#define VCF_ADMIN 0x02
23659 +#define VCF_ARES 0x06 /* includes admin */
23660 +#define VCF_SETUP 0x08
23662 +#define VCF_ZIDOK 0x10 /* zero id okay */
23666 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23669 + int permit = -1, state = 0;
23670 + int perm = -1, args = 0, flags = 0;
23671 + struct vx_info *vxi = NULL;
23672 + struct nx_info *nxi = NULL;
23675 + /* unpriviledged commands */
23676 + __VCMD(get_version, 0, VCA_NONE, 0);
23677 + __VCMD(get_vci, 0, VCA_NONE, 0);
23678 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23679 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23680 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23681 + __VCMD(get_space_default,0, VCA_NONE, 0);
23683 + /* info commands */
23684 + __VCMD(task_xid, 2, VCA_NONE, 0);
23685 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23686 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23687 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23688 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23689 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23690 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23691 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23692 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23693 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23695 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23696 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23697 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23698 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23700 + __VCMD(task_nid, 2, VCA_NONE, 0);
23701 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23702 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23703 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23705 + __VCMD(task_tag, 2, VCA_NONE, 0);
23707 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23708 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23709 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23710 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23712 + /* lower admin commands */
23713 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23714 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23715 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23716 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23717 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23718 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23719 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23720 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23722 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23723 + __VCMD(net_create, 5, VCA_NONE, 0);
23724 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23726 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23728 + /* higher admin commands */
23729 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23730 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23731 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23733 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23734 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23735 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23736 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23738 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23739 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23740 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23742 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23743 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23744 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23745 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23746 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23747 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23748 +#ifdef CONFIG_IPV6
23749 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23750 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23752 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23753 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23754 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23755 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23756 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23758 +#ifdef CONFIG_VSERVER_DEVICE
23759 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23760 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23762 + /* debug level admin commands */
23763 +#ifdef CONFIG_VSERVER_HISTORY
23764 + __VCMD(dump_history, 9, VCA_NONE, 0);
23765 + __VCMD(read_history, 9, VCA_NONE, 0);
23772 + vxdprintk(VXD_CBIT(switch, 0),
23773 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23774 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23775 + VC_VERSION(cmd), id, data, compat,
23776 + perm, args, flags);
23783 + if (!capable(CAP_CONTEXT))
23787 + /* moved here from the individual commands */
23789 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23793 + /* vcmd involves resource management */
23795 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23799 + /* various legacy exceptions */
23801 + /* will go away when spectator is a cap */
23802 + case VCMD_ctx_migrate_v0:
23803 + case VCMD_ctx_migrate:
23805 + current->xid = 1;
23811 + /* will go away when spectator is a cap */
23812 + case VCMD_net_migrate:
23814 + current->nid = 1;
23821 + /* vcmds are fine by default */
23824 + /* admin type vcmds require admin ... */
23825 + if (flags & VCF_ADMIN)
23826 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23828 + /* ... but setup type vcmds override that */
23829 + if (!permit && (flags & VCF_SETUP))
23830 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23838 + if (!id && (flags & VCF_ZIDOK))
23842 + if (args & VCA_VXI) {
23843 + vxi = lookup_vx_info(id);
23847 + if ((flags & VCF_ADMIN) &&
23848 + /* special case kill for shutdown */
23849 + (cmd != VCMD_ctx_kill) &&
23850 + /* can context be administrated? */
23851 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23857 + if (args & VCA_NXI) {
23858 + nxi = lookup_nx_info(id);
23862 + if ((flags & VCF_ADMIN) &&
23863 + /* can context be administrated? */
23864 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23871 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23874 + if ((args & VCA_NXI) && nxi)
23875 + put_nx_info(nxi);
23877 + if ((args & VCA_VXI) && vxi)
23878 + put_vx_info(vxi);
23880 + vxdprintk(VXD_CBIT(switch, 1),
23881 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23882 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23883 + VC_VERSION(cmd), ret, ret, state, permit);
23888 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23890 + return do_vserver(cmd, id, data, 0);
23893 +#ifdef CONFIG_COMPAT
23896 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23898 + return do_vserver(cmd, id, data, 1);
23901 +#endif /* CONFIG_COMPAT */
23902 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/sysctl.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/sysctl.c
23903 --- linux-2.6.38.1/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23904 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/sysctl.c 2011-01-29 02:01:07.000000000 +0100
23907 + * kernel/vserver/sysctl.c
23909 + * Virtual Context Support
23911 + * Copyright (C) 2004-2007 Herbert Pötzl
23913 + * V0.01 basic structure
23917 +#include <linux/module.h>
23918 +#include <linux/ctype.h>
23919 +#include <linux/sysctl.h>
23920 +#include <linux/parser.h>
23921 +#include <asm/uaccess.h>
23924 + CTL_DEBUG_ERROR = 0,
23925 + CTL_DEBUG_SWITCH = 1,
23940 +unsigned int vx_debug_switch = 0;
23941 +unsigned int vx_debug_xid = 0;
23942 +unsigned int vx_debug_nid = 0;
23943 +unsigned int vx_debug_tag = 0;
23944 +unsigned int vx_debug_net = 0;
23945 +unsigned int vx_debug_limit = 0;
23946 +unsigned int vx_debug_cres = 0;
23947 +unsigned int vx_debug_dlim = 0;
23948 +unsigned int vx_debug_quota = 0;
23949 +unsigned int vx_debug_cvirt = 0;
23950 +unsigned int vx_debug_space = 0;
23951 +unsigned int vx_debug_misc = 0;
23954 +static struct ctl_table_header *vserver_table_header;
23955 +static ctl_table vserver_root_table[];
23958 +void vserver_register_sysctl(void)
23960 + if (!vserver_table_header) {
23961 + vserver_table_header = register_sysctl_table(vserver_root_table);
23966 +void vserver_unregister_sysctl(void)
23968 + if (vserver_table_header) {
23969 + unregister_sysctl_table(vserver_table_header);
23970 + vserver_table_header = NULL;
23975 +static int proc_dodebug(ctl_table *table, int write,
23976 + void __user *buffer, size_t *lenp, loff_t *ppos)
23978 + char tmpbuf[20], *p, c;
23979 + unsigned int value;
23980 + size_t left, len;
23982 + if ((*ppos && !write) || !*lenp) {
23990 + if (!access_ok(VERIFY_READ, buffer, left))
23992 + p = (char *)buffer;
23993 + while (left && __get_user(c, p) >= 0 && isspace(c))
23998 + if (left > sizeof(tmpbuf) - 1)
24000 + if (copy_from_user(tmpbuf, p, left))
24002 + tmpbuf[left] = '\0';
24004 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
24005 + value = 10 * value + (*p - '0');
24006 + if (*p && !isspace(*p))
24008 + while (left && isspace(*p))
24010 + *(unsigned int *)table->data = value;
24012 + if (!access_ok(VERIFY_WRITE, buffer, left))
24014 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
24017 + if (__copy_to_user(buffer, tmpbuf, len))
24019 + if ((left -= len) > 0) {
24020 + if (put_user('\n', (char *)buffer + len))
24034 +#define CTL_ENTRY(ctl, name) \
24036 + .procname = #name, \
24037 + .data = &vx_ ## name, \
24038 + .maxlen = sizeof(int), \
24040 + .proc_handler = &proc_dodebug, \
24041 + .extra1 = &zero, \
24042 + .extra2 = &zero, \
24045 +static ctl_table vserver_debug_table[] = {
24046 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
24047 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
24048 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
24049 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
24050 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
24051 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
24052 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
24053 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
24054 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
24055 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
24056 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
24057 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
24061 +static ctl_table vserver_root_table[] = {
24063 + .procname = "vserver",
24065 + .child = vserver_debug_table
24071 +static match_table_t tokens = {
24072 + { CTL_DEBUG_SWITCH, "switch=%x" },
24073 + { CTL_DEBUG_XID, "xid=%x" },
24074 + { CTL_DEBUG_NID, "nid=%x" },
24075 + { CTL_DEBUG_TAG, "tag=%x" },
24076 + { CTL_DEBUG_NET, "net=%x" },
24077 + { CTL_DEBUG_LIMIT, "limit=%x" },
24078 + { CTL_DEBUG_CRES, "cres=%x" },
24079 + { CTL_DEBUG_DLIM, "dlim=%x" },
24080 + { CTL_DEBUG_QUOTA, "quota=%x" },
24081 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
24082 + { CTL_DEBUG_SPACE, "space=%x" },
24083 + { CTL_DEBUG_MISC, "misc=%x" },
24084 + { CTL_DEBUG_ERROR, NULL }
24087 +#define HANDLE_CASE(id, name, val) \
24088 + case CTL_DEBUG_ ## id: \
24089 + vx_debug_ ## name = val; \
24090 + printk("vs_debug_" #name "=0x%x\n", val); \
24094 +static int __init vs_debug_setup(char *str)
24099 + printk("vs_debug_setup(%s)\n", str);
24100 + while ((p = strsep(&str, ",")) != NULL) {
24101 + substring_t args[MAX_OPT_ARGS];
24102 + unsigned int value;
24107 + token = match_token(p, tokens, args);
24108 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
24111 + HANDLE_CASE(SWITCH, switch, value);
24112 + HANDLE_CASE(XID, xid, value);
24113 + HANDLE_CASE(NID, nid, value);
24114 + HANDLE_CASE(TAG, tag, value);
24115 + HANDLE_CASE(NET, net, value);
24116 + HANDLE_CASE(LIMIT, limit, value);
24117 + HANDLE_CASE(CRES, cres, value);
24118 + HANDLE_CASE(DLIM, dlim, value);
24119 + HANDLE_CASE(QUOTA, quota, value);
24120 + HANDLE_CASE(CVIRT, cvirt, value);
24121 + HANDLE_CASE(SPACE, space, value);
24122 + HANDLE_CASE(MISC, misc, value);
24131 +__setup("vsdebug=", vs_debug_setup);
24135 +EXPORT_SYMBOL_GPL(vx_debug_switch);
24136 +EXPORT_SYMBOL_GPL(vx_debug_xid);
24137 +EXPORT_SYMBOL_GPL(vx_debug_nid);
24138 +EXPORT_SYMBOL_GPL(vx_debug_net);
24139 +EXPORT_SYMBOL_GPL(vx_debug_limit);
24140 +EXPORT_SYMBOL_GPL(vx_debug_cres);
24141 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
24142 +EXPORT_SYMBOL_GPL(vx_debug_quota);
24143 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
24144 +EXPORT_SYMBOL_GPL(vx_debug_space);
24145 +EXPORT_SYMBOL_GPL(vx_debug_misc);
24147 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/tag.c linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/tag.c
24148 --- linux-2.6.38.1/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
24149 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/tag.c 2011-03-22 17:43:07.000000000 +0100
24152 + * linux/kernel/vserver/tag.c
24154 + * Virtual Server: Shallow Tag Space
24156 + * Copyright (C) 2007 Herbert Pötzl
24158 + * V0.01 basic implementation
24162 +#include <linux/sched.h>
24163 +#include <linux/vserver/debug.h>
24164 +#include <linux/vs_pid.h>
24165 +#include <linux/vs_tag.h>
24167 +#include <linux/vserver/tag_cmd.h>
24170 +int dx_migrate_task(struct task_struct *p, tag_t tag)
24175 + vxdprintk(VXD_CBIT(tag, 5),
24176 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
24182 + vxdprintk(VXD_CBIT(tag, 5),
24183 + "moved task %p into [#%d]", p, tag);
24187 +/* vserver syscall commands below here */
24189 +/* taks xid and vx_info functions */
24192 +int vc_task_tag(uint32_t id)
24197 + struct task_struct *tsk;
24199 + tsk = find_task_by_real_pid(id);
24200 + tag = (tsk) ? tsk->tag : -ESRCH;
24201 + rcu_read_unlock();
24203 + tag = dx_current_tag();
24208 +int vc_tag_migrate(uint32_t tag)
24210 + return dx_migrate_task(current, tag & 0xFFFF);
24214 diff -NurpP --minimal linux-2.6.38.1/kernel/vserver/vci_config.h linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/vci_config.h
24215 --- linux-2.6.38.1/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
24216 +++ linux-2.6.38.1-vs2.3.0.37-rc9/kernel/vserver/vci_config.h 2011-03-15 21:34:31.000000000 +0100
24219 +/* interface version */
24221 +#define VCI_VERSION 0x00020307
24225 + VCI_KCBIT_NO_DYNAMIC = 0,
24227 + VCI_KCBIT_PROC_SECURE = 4,
24228 + /* VCI_KCBIT_HARDCPU = 5, */
24229 + /* VCI_KCBIT_IDLELIMIT = 6, */
24230 + /* VCI_KCBIT_IDLETIME = 7, */
24232 + VCI_KCBIT_COWBL = 8,
24233 + VCI_KCBIT_FULLCOWBL = 9,
24234 + VCI_KCBIT_SPACES = 10,
24235 + VCI_KCBIT_NETV2 = 11,
24236 + VCI_KCBIT_MEMCG = 12,
24238 + VCI_KCBIT_DEBUG = 16,
24239 + VCI_KCBIT_HISTORY = 20,
24240 + VCI_KCBIT_TAGGED = 24,
24241 + VCI_KCBIT_PPTAG = 28,
24243 + VCI_KCBIT_MORE = 31,
24247 +static inline uint32_t vci_kernel_config(void)
24250 + (1 << VCI_KCBIT_NO_DYNAMIC) |
24252 + /* configured features */
24253 +#ifdef CONFIG_VSERVER_PROC_SECURE
24254 + (1 << VCI_KCBIT_PROC_SECURE) |
24256 +#ifdef CONFIG_VSERVER_COWBL
24257 + (1 << VCI_KCBIT_COWBL) |
24258 + (1 << VCI_KCBIT_FULLCOWBL) |
24260 + (1 << VCI_KCBIT_SPACES) |
24261 + (1 << VCI_KCBIT_NETV2) |
24262 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
24263 + (1 << VCI_KCBIT_MEMCG) |
24266 + /* debug options */
24267 +#ifdef CONFIG_VSERVER_DEBUG
24268 + (1 << VCI_KCBIT_DEBUG) |
24270 +#ifdef CONFIG_VSERVER_HISTORY
24271 + (1 << VCI_KCBIT_HISTORY) |
24274 + /* inode context tagging */
24275 +#if defined(CONFIG_TAGGING_NONE)
24276 + (0 << VCI_KCBIT_TAGGED) |
24277 +#elif defined(CONFIG_TAGGING_UID16)
24278 + (1 << VCI_KCBIT_TAGGED) |
24279 +#elif defined(CONFIG_TAGGING_GID16)
24280 + (2 << VCI_KCBIT_TAGGED) |
24281 +#elif defined(CONFIG_TAGGING_ID24)
24282 + (3 << VCI_KCBIT_TAGGED) |
24283 +#elif defined(CONFIG_TAGGING_INTERN)
24284 + (4 << VCI_KCBIT_TAGGED) |
24285 +#elif defined(CONFIG_TAGGING_RUNTIME)
24286 + (5 << VCI_KCBIT_TAGGED) |
24288 + (7 << VCI_KCBIT_TAGGED) |
24290 + (1 << VCI_KCBIT_PPTAG) |
24294 diff -NurpP --minimal linux-2.6.38.1/mm/filemap_xip.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/filemap_xip.c
24295 --- linux-2.6.38.1/mm/filemap_xip.c 2010-07-07 18:31:58.000000000 +0200
24296 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/filemap_xip.c 2011-01-29 02:01:07.000000000 +0100
24298 #include <linux/seqlock.h>
24299 #include <linux/mutex.h>
24300 #include <linux/gfp.h>
24301 +#include <linux/vs_memory.h>
24302 #include <asm/tlbflush.h>
24303 #include <asm/io.h>
24305 diff -NurpP --minimal linux-2.6.38.1/mm/fremap.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/fremap.c
24306 --- linux-2.6.38.1/mm/fremap.c 2010-10-21 13:07:57.000000000 +0200
24307 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/fremap.c 2011-01-29 02:01:07.000000000 +0100
24309 #include <linux/module.h>
24310 #include <linux/syscalls.h>
24311 #include <linux/mmu_notifier.h>
24312 +#include <linux/vs_memory.h>
24314 #include <asm/mmu_context.h>
24315 #include <asm/cacheflush.h>
24316 diff -NurpP --minimal linux-2.6.38.1/mm/hugetlb.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/hugetlb.c
24317 --- linux-2.6.38.1/mm/hugetlb.c 2011-03-15 18:07:42.000000000 +0100
24318 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/hugetlb.c 2011-01-29 02:01:07.000000000 +0100
24321 #include <linux/hugetlb.h>
24322 #include <linux/node.h>
24323 +#include <linux/vs_memory.h>
24324 #include "internal.h"
24326 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
24327 diff -NurpP --minimal linux-2.6.38.1/mm/memcontrol.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/memcontrol.c
24328 --- linux-2.6.38.1/mm/memcontrol.c 2011-03-15 18:07:42.000000000 +0100
24329 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/memcontrol.c 2011-02-17 02:17:51.000000000 +0100
24330 @@ -681,6 +681,31 @@ struct mem_cgroup *mem_cgroup_from_task(
24331 struct mem_cgroup, css);
24334 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
24336 + return res_counter_read_u64(&mem->res, member);
24339 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
24341 + return res_counter_read_u64(&mem->memsw, member);
24344 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
24346 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
24349 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
24351 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
24354 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
24356 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
24359 static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
24361 struct mem_cgroup *mem = NULL;
24362 diff -NurpP --minimal linux-2.6.38.1/mm/memory.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/memory.c
24363 --- linux-2.6.38.1/mm/memory.c 2011-03-15 18:07:42.000000000 +0100
24364 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/memory.c 2011-03-07 16:53:28.000000000 +0100
24365 @@ -3225,6 +3225,7 @@ int handle_pte_fault(struct mm_struct *m
24369 + int ret = 0, type = VXPT_UNKNOWN;
24372 if (!pte_present(entry)) {
24373 @@ -3249,9 +3250,12 @@ int handle_pte_fault(struct mm_struct *m
24374 if (unlikely(!pte_same(*pte, entry)))
24376 if (flags & FAULT_FLAG_WRITE) {
24377 - if (!pte_write(entry))
24378 - return do_wp_page(mm, vma, address,
24379 + if (!pte_write(entry)) {
24380 + ret = do_wp_page(mm, vma, address,
24381 pte, pmd, ptl, entry);
24382 + type = VXPT_WRITE;
24385 entry = pte_mkdirty(entry);
24387 entry = pte_mkyoung(entry);
24388 @@ -3269,7 +3273,10 @@ int handle_pte_fault(struct mm_struct *m
24391 pte_unmap_unlock(pte, ptl);
24395 + vx_page_fault(mm, vma, type, ret);
24400 diff -NurpP --minimal linux-2.6.38.1/mm/mremap.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/mremap.c
24401 --- linux-2.6.38.1/mm/mremap.c 2011-03-15 18:07:42.000000000 +0100
24402 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/mremap.c 2011-03-07 16:53:28.000000000 +0100
24404 #include <linux/security.h>
24405 #include <linux/syscalls.h>
24406 #include <linux/mmu_notifier.h>
24407 +#include <linux/vs_memory.h>
24409 #include <asm/uaccess.h>
24410 #include <asm/cacheflush.h>
24411 diff -NurpP --minimal linux-2.6.38.1/mm/oom_kill.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/oom_kill.c
24412 --- linux-2.6.38.1/mm/oom_kill.c 2011-01-05 21:50:40.000000000 +0100
24413 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/oom_kill.c 2011-01-29 02:01:07.000000000 +0100
24415 #include <linux/memcontrol.h>
24416 #include <linux/mempolicy.h>
24417 #include <linux/security.h>
24418 +#include <linux/reboot.h>
24419 +#include <linux/vs_memory.h>
24420 +#include <linux/vs_context.h>
24422 int sysctl_panic_on_oom;
24423 int sysctl_oom_kill_allocating_task;
24424 @@ -124,11 +127,18 @@ struct task_struct *find_lock_task_mm(st
24425 static bool oom_unkillable_task(struct task_struct *p,
24426 const struct mem_cgroup *mem, const nodemask_t *nodemask)
24428 - if (is_global_init(p))
24429 + unsigned xid = vx_current_xid();
24431 + /* skip the init task, global and per guest */
24432 + if (task_is_init(p))
24434 if (p->flags & PF_KTHREAD)
24437 + /* skip other guest and host processes if oom in guest */
24438 + if (xid && vx_task_xid(p) != xid)
24441 /* When mem_cgroup_out_of_memory() and p is not member of the group */
24442 if (mem && !task_in_mem_cgroup(p, mem))
24444 @@ -210,6 +220,18 @@ unsigned int oom_badness(struct task_str
24445 points += p->signal->oom_score_adj;
24448 + * add points for context badness and
24449 + * reduce badness for processes belonging to
24450 + * a different context
24453 + points += vx_badness(p, p->mm);
24455 + if ((vx_current_xid() > 1) &&
24456 + vx_current_xid() != vx_task_xid(p))
24460 * Never return 0 for an eligible task that may be killed since it's
24461 * possible that no single user task uses more than 0.1% of memory and
24462 * no single admin tasks uses more than 3.0%.
24463 @@ -414,8 +436,8 @@ static int oom_kill_task(struct task_str
24464 /* mm cannot be safely dereferenced after task_unlock(p) */
24467 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24468 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
24469 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24470 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
24471 K(get_mm_counter(p->mm, MM_ANONPAGES)),
24472 K(get_mm_counter(p->mm, MM_FILEPAGES)));
24474 @@ -477,8 +499,8 @@ static int oom_kill_process(struct task_
24478 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
24479 - message, task_pid_nr(p), p->comm, points);
24480 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
24481 + message, task_pid_nr(p), p->xid, p->comm, points);
24485 @@ -567,6 +589,8 @@ int unregister_oom_notifier(struct notif
24487 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
24489 +long vs_oom_action(unsigned int);
24492 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
24493 * if a parallel OOM killing is already taking place that includes a zone in
24494 @@ -726,7 +750,12 @@ retry:
24496 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
24497 read_unlock(&tasklist_lock);
24498 - panic("Out of memory and no killable processes...\n");
24500 + /* avoid panic for guest OOM */
24501 + if (current->xid)
24502 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
24504 + panic("Out of memory and no killable processes...\n");
24507 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
24508 diff -NurpP --minimal linux-2.6.38.1/mm/page_alloc.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/page_alloc.c
24509 --- linux-2.6.38.1/mm/page_alloc.c 2011-03-15 18:07:42.000000000 +0100
24510 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/page_alloc.c 2011-03-07 16:53:28.000000000 +0100
24512 #include <linux/compaction.h>
24513 #include <trace/events/kmem.h>
24514 #include <linux/ftrace_event.h>
24515 +#include <linux/vs_base.h>
24516 +#include <linux/vs_limit.h>
24518 #include <asm/tlbflush.h>
24519 #include <asm/div64.h>
24520 @@ -2388,6 +2390,9 @@ void si_meminfo(struct sysinfo *val)
24521 val->totalhigh = totalhigh_pages;
24522 val->freehigh = nr_free_highpages();
24523 val->mem_unit = PAGE_SIZE;
24525 + if (vx_flags(VXF_VIRT_MEM, 0))
24526 + vx_vsi_meminfo(val);
24529 EXPORT_SYMBOL(si_meminfo);
24530 @@ -2408,6 +2413,9 @@ void si_meminfo_node(struct sysinfo *val
24533 val->mem_unit = PAGE_SIZE;
24535 + if (vx_flags(VXF_VIRT_MEM, 0))
24536 + vx_vsi_meminfo(val);
24540 diff -NurpP --minimal linux-2.6.38.1/mm/pgtable-generic.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/pgtable-generic.c
24541 --- linux-2.6.38.1/mm/pgtable-generic.c 2011-03-15 18:07:42.000000000 +0100
24542 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/pgtable-generic.c 2011-02-02 22:20:27.000000000 +0100
24544 * Copyright (C) 2010 Linus Torvalds
24547 +#include <linux/mm.h>
24549 #include <linux/pagemap.h>
24550 #include <asm/tlb.h>
24551 #include <asm-generic/pgtable.h>
24552 diff -NurpP --minimal linux-2.6.38.1/mm/rmap.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/rmap.c
24553 --- linux-2.6.38.1/mm/rmap.c 2011-03-15 18:07:42.000000000 +0100
24554 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/rmap.c 2011-03-15 18:15:06.000000000 +0100
24556 #include <linux/mmu_notifier.h>
24557 #include <linux/migrate.h>
24558 #include <linux/hugetlb.h>
24559 +#include <linux/vs_memory.h>
24561 #include <asm/tlbflush.h>
24563 diff -NurpP --minimal linux-2.6.38.1/mm/shmem.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/shmem.c
24564 --- linux-2.6.38.1/mm/shmem.c 2011-03-15 18:07:42.000000000 +0100
24565 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/shmem.c 2011-01-29 02:01:07.000000000 +0100
24566 @@ -1816,7 +1816,7 @@ static int shmem_statfs(struct dentry *d
24568 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24570 - buf->f_type = TMPFS_MAGIC;
24571 + buf->f_type = TMPFS_SUPER_MAGIC;
24572 buf->f_bsize = PAGE_CACHE_SIZE;
24573 buf->f_namelen = NAME_MAX;
24574 if (sbinfo->max_blocks) {
24575 @@ -2378,7 +2378,7 @@ int shmem_fill_super(struct super_block
24576 sb->s_maxbytes = SHMEM_MAX_BYTES;
24577 sb->s_blocksize = PAGE_CACHE_SIZE;
24578 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24579 - sb->s_magic = TMPFS_MAGIC;
24580 + sb->s_magic = TMPFS_SUPER_MAGIC;
24581 sb->s_op = &shmem_ops;
24582 sb->s_time_gran = 1;
24583 #ifdef CONFIG_TMPFS_POSIX_ACL
24584 diff -NurpP --minimal linux-2.6.38.1/mm/slab.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/slab.c
24585 --- linux-2.6.38.1/mm/slab.c 2011-03-15 18:07:42.000000000 +0100
24586 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/slab.c 2011-01-29 02:01:07.000000000 +0100
24587 @@ -407,6 +407,8 @@ static void kmem_list3_init(struct kmem_
24588 #define STATS_INC_FREEMISS(x) do { } while (0)
24591 +#include "slab_vs.h"
24596 @@ -3346,6 +3348,7 @@ retry:
24598 obj = slab_get_obj(cachep, slabp, nodeid);
24599 check_slabp(cachep, slabp);
24600 + vx_slab_alloc(cachep, flags);
24601 l3->free_objects--;
24602 /* move slabp to correct slabp list: */
24603 list_del(&slabp->list);
24604 @@ -3423,6 +3426,7 @@ __cache_alloc_node(struct kmem_cache *ca
24605 /* ___cache_alloc_node can fall back to other nodes */
24606 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24608 + vx_slab_alloc(cachep, flags);
24609 local_irq_restore(save_flags);
24610 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24611 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24612 @@ -3609,6 +3613,7 @@ static inline void __cache_free(struct k
24614 kmemleak_free_recursive(objp, cachep->flags);
24615 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
24616 + vx_slab_free(cachep);
24618 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24620 diff -NurpP --minimal linux-2.6.38.1/mm/slab_vs.h linux-2.6.38.1-vs2.3.0.37-rc9/mm/slab_vs.h
24621 --- linux-2.6.38.1/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24622 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/slab_vs.h 2011-01-29 02:01:07.000000000 +0100
24625 +#include <linux/vserver/context.h>
24627 +#include <linux/vs_context.h>
24630 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24632 + int what = gfp_zone(cachep->gfpflags);
24633 + struct vx_info *vxi = current_vx_info();
24638 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24642 +void vx_slab_free(struct kmem_cache *cachep)
24644 + int what = gfp_zone(cachep->gfpflags);
24645 + struct vx_info *vxi = current_vx_info();
24650 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24653 diff -NurpP --minimal linux-2.6.38.1/mm/swapfile.c linux-2.6.38.1-vs2.3.0.37-rc9/mm/swapfile.c
24654 --- linux-2.6.38.1/mm/swapfile.c 2011-03-15 18:07:42.000000000 +0100
24655 +++ linux-2.6.38.1-vs2.3.0.37-rc9/mm/swapfile.c 2011-03-07 16:53:28.000000000 +0100
24657 #include <asm/tlbflush.h>
24658 #include <linux/swapops.h>
24659 #include <linux/page_cgroup.h>
24660 +#include <linux/vs_base.h>
24661 +#include <linux/vs_memory.h>
24663 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24665 @@ -1775,6 +1777,16 @@ static int swap_show(struct seq_file *sw
24667 if (si == SEQ_START_TOKEN) {
24668 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24669 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24670 + struct sysinfo si;
24672 + vx_vsi_swapinfo(&si);
24673 + if (si.totalswap < (1 << 10))
24675 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24676 + "hdv0", "partition", si.totalswap >> 10,
24677 + (si.totalswap - si.freeswap) >> 10, -1);
24682 @@ -2181,6 +2193,8 @@ void si_swapinfo(struct sysinfo *val)
24683 val->freeswap = nr_swap_pages + nr_to_be_unused;
24684 val->totalswap = total_swap_pages + nr_to_be_unused;
24685 spin_unlock(&swap_lock);
24686 + if (vx_flags(VXF_VIRT_MEM, 0))
24687 + vx_vsi_swapinfo(val);
24691 diff -NurpP --minimal linux-2.6.38.1/net/bridge/br_multicast.c linux-2.6.38.1-vs2.3.0.37-rc9/net/bridge/br_multicast.c
24692 --- linux-2.6.38.1/net/bridge/br_multicast.c 2011-03-15 18:07:44.000000000 +0100
24693 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/bridge/br_multicast.c 2011-03-10 16:51:08.000000000 +0100
24694 @@ -446,7 +446,7 @@ static struct sk_buff *br_ip6_multicast_
24695 ip6h->nexthdr = IPPROTO_HOPOPTS;
24696 ip6h->hop_limit = 1;
24697 ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24699 + &ip6h->saddr, NULL);
24700 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24701 ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
24703 diff -NurpP --minimal linux-2.6.38.1/net/core/dev.c linux-2.6.38.1-vs2.3.0.37-rc9/net/core/dev.c
24704 --- linux-2.6.38.1/net/core/dev.c 2011-03-15 18:07:44.000000000 +0100
24705 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/core/dev.c 2011-03-15 18:15:06.000000000 +0100
24706 @@ -127,6 +127,7 @@
24707 #include <linux/in.h>
24708 #include <linux/jhash.h>
24709 #include <linux/random.h>
24710 +#include <linux/vs_inet.h>
24711 #include <trace/events/napi.h>
24712 #include <trace/events/net.h>
24713 #include <trace/events/skb.h>
24714 @@ -608,7 +609,8 @@ struct net_device *__dev_get_by_name(str
24715 struct hlist_head *head = dev_name_hash(net, name);
24717 hlist_for_each_entry(dev, p, head, name_hlist)
24718 - if (!strncmp(dev->name, name, IFNAMSIZ))
24719 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24720 + nx_dev_visible(current_nx_info(), dev))
24724 @@ -634,7 +636,8 @@ struct net_device *dev_get_by_name_rcu(s
24725 struct hlist_head *head = dev_name_hash(net, name);
24727 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24728 - if (!strncmp(dev->name, name, IFNAMSIZ))
24729 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24730 + nx_dev_visible(current_nx_info(), dev))
24734 @@ -685,7 +688,8 @@ struct net_device *__dev_get_by_index(st
24735 struct hlist_head *head = dev_index_hash(net, ifindex);
24737 hlist_for_each_entry(dev, p, head, index_hlist)
24738 - if (dev->ifindex == ifindex)
24739 + if ((dev->ifindex == ifindex) &&
24740 + nx_dev_visible(current_nx_info(), dev))
24744 @@ -710,7 +714,8 @@ struct net_device *dev_get_by_index_rcu(
24745 struct hlist_head *head = dev_index_hash(net, ifindex);
24747 hlist_for_each_entry_rcu(dev, p, head, index_hlist)
24748 - if (dev->ifindex == ifindex)
24749 + if ((dev->ifindex == ifindex) &&
24750 + nx_dev_visible(current_nx_info(), dev))
24754 @@ -763,7 +768,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24756 for_each_netdev_rcu(net, dev)
24757 if (dev->type == type &&
24758 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24759 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24760 + nx_dev_visible(current_nx_info(), dev))
24764 @@ -775,9 +781,11 @@ struct net_device *__dev_getfirstbyhwtyp
24765 struct net_device *dev;
24768 - for_each_netdev(net, dev)
24769 - if (dev->type == type)
24770 + for_each_netdev(net, dev) {
24771 + if ((dev->type == type) &&
24772 + nx_dev_visible(current_nx_info(), dev))
24778 @@ -895,6 +903,8 @@ static int __dev_alloc_name(struct net *
24780 if (i < 0 || i >= max_netdevices)
24782 + if (!nx_dev_visible(current_nx_info(), d))
24785 /* avoid cases where sscanf is not exact inverse of printf */
24786 snprintf(buf, IFNAMSIZ, name, i);
24787 @@ -3873,6 +3883,8 @@ static int dev_ifconf(struct net *net, c
24790 for_each_netdev(net, dev) {
24791 + if (!nx_dev_visible(current_nx_info(), dev))
24793 for (i = 0; i < NPROTO; i++) {
24794 if (gifconf_list[i]) {
24796 @@ -3944,6 +3956,10 @@ static void dev_seq_printf_stats(struct
24797 struct rtnl_link_stats64 temp;
24798 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24800 + /* device visible inside network context? */
24801 + if (!nx_dev_visible(current_nx_info(), dev))
24804 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24805 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24806 dev->name, stats->rx_bytes, stats->rx_packets,
24807 diff -NurpP --minimal linux-2.6.38.1/net/core/rtnetlink.c linux-2.6.38.1-vs2.3.0.37-rc9/net/core/rtnetlink.c
24808 --- linux-2.6.38.1/net/core/rtnetlink.c 2011-03-15 18:07:44.000000000 +0100
24809 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/core/rtnetlink.c 2011-02-17 02:17:52.000000000 +0100
24810 @@ -1012,6 +1012,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24811 hlist_for_each_entry(dev, node, head, index_hlist) {
24814 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24816 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24817 NETLINK_CB(cb->skb).pid,
24818 cb->nlh->nlmsg_seq, 0,
24819 @@ -1771,6 +1773,9 @@ void rtmsg_ifinfo(int type, struct net_d
24820 struct sk_buff *skb;
24821 int err = -ENOBUFS;
24823 + if (!nx_dev_visible(current_nx_info(), dev))
24826 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
24829 diff -NurpP --minimal linux-2.6.38.1/net/core/sock.c linux-2.6.38.1-vs2.3.0.37-rc9/net/core/sock.c
24830 --- linux-2.6.38.1/net/core/sock.c 2011-03-15 18:07:44.000000000 +0100
24831 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/core/sock.c 2011-01-29 02:01:07.000000000 +0100
24832 @@ -127,6 +127,10 @@
24833 #include <net/cls_cgroup.h>
24835 #include <linux/filter.h>
24836 +#include <linux/vs_socket.h>
24837 +#include <linux/vs_limit.h>
24838 +#include <linux/vs_context.h>
24839 +#include <linux/vs_network.h>
24842 #include <net/tcp.h>
24843 @@ -1070,6 +1074,8 @@ static struct sock *sk_prot_alloc(struct
24845 sk_tx_queue_clear(sk);
24847 + sock_vx_init(sk);
24848 + sock_nx_init(sk);
24852 @@ -1169,6 +1175,11 @@ static void __sk_free(struct sock *sk)
24853 put_cred(sk->sk_peer_cred);
24854 put_pid(sk->sk_peer_pid);
24855 put_net(sock_net(sk));
24857 + clr_vx_info(&sk->sk_vx_info);
24859 + clr_nx_info(&sk->sk_nx_info);
24861 sk_prot_free(sk->sk_prot_creator, sk);
24864 @@ -1216,6 +1227,8 @@ struct sock *sk_clone(const struct sock
24867 get_net(sock_net(newsk));
24868 + sock_vx_init(newsk);
24869 + sock_nx_init(newsk);
24870 sk_node_init(&newsk->sk_node);
24871 sock_lock_init(newsk);
24872 bh_lock_sock(newsk);
24873 @@ -1271,6 +1284,12 @@ struct sock *sk_clone(const struct sock
24875 atomic_set(&newsk->sk_refcnt, 2);
24877 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24878 + newsk->sk_xid = sk->sk_xid;
24879 + vx_sock_inc(newsk);
24880 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24881 + newsk->sk_nid = sk->sk_nid;
24884 * Increment the counter in the same struct proto as the master
24885 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24886 @@ -2017,6 +2036,12 @@ void sock_init_data(struct socket *sock,
24888 sk->sk_stamp = ktime_set(-1L, 0);
24890 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24891 + sk->sk_xid = vx_current_xid();
24893 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24894 + sk->sk_nid = nx_current_nid();
24897 * Before updating sk_refcnt, we must commit prior changes to memory
24898 * (Documentation/RCU/rculist_nulls.txt for details)
24899 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/af_inet.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/af_inet.c
24900 --- linux-2.6.38.1/net/ipv4/af_inet.c 2011-03-15 18:07:45.000000000 +0100
24901 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/af_inet.c 2011-02-17 02:17:52.000000000 +0100
24902 @@ -116,6 +116,7 @@
24903 #ifdef CONFIG_IP_MROUTE
24904 #include <linux/mroute.h>
24906 +#include <linux/vs_limit.h>
24909 /* The inetsw table contains everything that inet_create needs to
24910 @@ -325,9 +326,13 @@ lookup_protocol:
24914 + if ((protocol == IPPROTO_ICMP) &&
24915 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24918 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24919 goto out_rcu_unlock;
24922 err = -EAFNOSUPPORT;
24923 if (!inet_netns_ok(net, protocol))
24924 goto out_rcu_unlock;
24925 @@ -451,6 +456,7 @@ int inet_bind(struct socket *sock, struc
24926 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24927 struct sock *sk = sock->sk;
24928 struct inet_sock *inet = inet_sk(sk);
24929 + struct nx_v4_sock_addr nsa;
24930 unsigned short snum;
24933 @@ -464,7 +470,11 @@ int inet_bind(struct socket *sock, struc
24934 if (addr_len < sizeof(struct sockaddr_in))
24937 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24938 + err = v4_map_sock_addr(inet, addr, &nsa);
24942 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24944 /* Not specified by any standard per-se, however it breaks too
24945 * many applications when removed. It is unfortunate since
24946 @@ -476,7 +486,7 @@ int inet_bind(struct socket *sock, struc
24947 err = -EADDRNOTAVAIL;
24948 if (!sysctl_ip_nonlocal_bind &&
24949 !(inet->freebind || inet->transparent) &&
24950 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24951 + nsa.saddr != htonl(INADDR_ANY) &&
24952 chk_addr_ret != RTN_LOCAL &&
24953 chk_addr_ret != RTN_MULTICAST &&
24954 chk_addr_ret != RTN_BROADCAST)
24955 @@ -501,7 +511,7 @@ int inet_bind(struct socket *sock, struc
24956 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24957 goto out_release_sock;
24959 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24960 + v4_set_sock_addr(inet, &nsa);
24961 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24962 inet->inet_saddr = 0; /* Use device */
24964 @@ -703,11 +713,13 @@ int inet_getname(struct socket *sock, st
24967 sin->sin_port = inet->inet_dport;
24968 - sin->sin_addr.s_addr = inet->inet_daddr;
24969 + sin->sin_addr.s_addr =
24970 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24972 __be32 addr = inet->inet_rcv_saddr;
24974 addr = inet->inet_saddr;
24975 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24976 sin->sin_port = inet->inet_sport;
24977 sin->sin_addr.s_addr = addr;
24979 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/devinet.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/devinet.c
24980 --- linux-2.6.38.1/net/ipv4/devinet.c 2011-03-15 18:07:45.000000000 +0100
24981 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/devinet.c 2011-03-15 18:15:06.000000000 +0100
24982 @@ -420,6 +420,7 @@ struct in_device *inetdev_by_index(struc
24984 EXPORT_SYMBOL(inetdev_by_index);
24987 /* Called only from RTNL semaphored context. No locks. */
24989 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24990 @@ -660,6 +661,8 @@ int devinet_ioctl(struct net *net, unsig
24992 in_dev = __in_dev_get_rtnl(dev);
24994 + struct nx_info *nxi = current_nx_info();
24996 if (tryaddrmatch) {
24997 /* Matthias Andree */
24998 /* compare label and address (4.4BSD style) */
24999 @@ -668,6 +671,8 @@ int devinet_ioctl(struct net *net, unsig
25000 This is checked above. */
25001 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
25002 ifap = &ifa->ifa_next) {
25003 + if (!nx_v4_ifa_visible(nxi, ifa))
25005 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
25006 sin_orig.sin_addr.s_addr ==
25008 @@ -680,9 +685,12 @@ int devinet_ioctl(struct net *net, unsig
25009 comparing just the label */
25011 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
25012 - ifap = &ifa->ifa_next)
25013 + ifap = &ifa->ifa_next) {
25014 + if (!nx_v4_ifa_visible(nxi, ifa))
25016 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
25022 @@ -834,6 +842,8 @@ static int inet_gifconf(struct net_devic
25025 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
25026 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
25029 done += sizeof(ifr);
25031 @@ -1193,6 +1203,7 @@ static int inet_dump_ifaddr(struct sk_bu
25032 struct net_device *dev;
25033 struct in_device *in_dev;
25034 struct in_ifaddr *ifa;
25035 + struct sock *sk = skb->sk;
25036 struct hlist_head *head;
25037 struct hlist_node *node;
25039 @@ -1215,6 +1226,8 @@ static int inet_dump_ifaddr(struct sk_bu
25041 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
25042 ifa = ifa->ifa_next, ip_idx++) {
25043 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
25045 if (ip_idx < s_ip_idx)
25047 if (inet_fill_ifaddr(skb, ifa,
25048 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/fib_hash.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/fib_hash.c
25049 --- linux-2.6.38.1/net/ipv4/fib_hash.c 2011-01-05 21:50:41.000000000 +0100
25050 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/fib_hash.c 2011-01-29 02:01:07.000000000 +0100
25051 @@ -1080,7 +1080,7 @@ static int fib_seq_show(struct seq_file
25052 prefix = f->fn_key;
25053 mask = FZ_MASK(iter->zone);
25054 flags = fib_flag_trans(fa->fa_type, mask, fi);
25056 + if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
25058 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
25059 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
25060 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/inet_connection_sock.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/inet_connection_sock.c
25061 --- linux-2.6.38.1/net/ipv4/inet_connection_sock.c 2011-03-15 18:07:45.000000000 +0100
25062 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/inet_connection_sock.c 2011-01-29 05:17:31.000000000 +0100
25063 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
25065 EXPORT_SYMBOL(inet_get_local_port_range);
25067 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25069 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
25070 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
25072 + if (inet_v6_ipv6only(sk2))
25075 + if (sk1_rcv_saddr &&
25077 + sk1_rcv_saddr == sk2_rcv_saddr)
25080 + if (sk1_rcv_saddr &&
25081 + !sk2_rcv_saddr &&
25082 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
25085 + if (sk2_rcv_saddr &&
25086 + !sk1_rcv_saddr &&
25087 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
25090 + if (!sk1_rcv_saddr &&
25091 + !sk2_rcv_saddr &&
25092 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
25098 int inet_csk_bind_conflict(const struct sock *sk,
25099 const struct inet_bind_bucket *tb)
25101 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct
25102 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
25103 if (!reuse || !sk2->sk_reuse ||
25104 ((1 << sk2->sk_state) & (TCPF_LISTEN | TCPF_CLOSE))) {
25105 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25106 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
25107 - sk2_rcv_saddr == sk_rcv_saddr(sk))
25108 + if (ipv4_rcv_saddr_equal(sk, sk2))
25112 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/inet_diag.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/inet_diag.c
25113 --- linux-2.6.38.1/net/ipv4/inet_diag.c 2011-01-05 21:50:42.000000000 +0100
25114 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/inet_diag.c 2011-01-29 02:01:07.000000000 +0100
25116 #include <linux/stddef.h>
25118 #include <linux/inet_diag.h>
25119 +#include <linux/vs_network.h>
25120 +#include <linux/vs_inet.h>
25122 static const struct inet_diag_handler **inet_diag_table;
25124 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
25126 r->id.idiag_sport = inet->inet_sport;
25127 r->id.idiag_dport = inet->inet_dport;
25128 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
25129 - r->id.idiag_dst[0] = inet->inet_daddr;
25130 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
25131 + inet->inet_rcv_saddr);
25132 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
25133 + inet->inet_daddr);
25135 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25136 if (r->idiag_family == AF_INET6) {
25137 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
25138 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
25139 r->id.idiag_sport = tw->tw_sport;
25140 r->id.idiag_dport = tw->tw_dport;
25141 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
25142 - r->id.idiag_dst[0] = tw->tw_daddr;
25143 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
25144 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
25145 r->idiag_state = tw->tw_substate;
25146 r->idiag_timer = 3;
25147 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
25148 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
25151 if (req->idiag_family == AF_INET) {
25152 + /* TODO: lback */
25153 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
25154 req->id.idiag_dport, req->id.idiag_src[0],
25155 req->id.idiag_sport, req->id.idiag_if);
25156 @@ -507,6 +512,7 @@ static int inet_csk_diag_dump(struct soc
25160 + /* TODO: lback */
25161 entry.saddr = &inet->inet_rcv_saddr;
25162 entry.daddr = &inet->inet_daddr;
25164 @@ -545,6 +551,7 @@ static int inet_twsk_diag_dump(struct in
25168 + /* TODO: lback */
25169 entry.saddr = &tw->tw_rcv_saddr;
25170 entry.daddr = &tw->tw_daddr;
25172 @@ -591,8 +598,8 @@ static int inet_diag_fill_req(struct sk_
25174 r->id.idiag_sport = inet->inet_sport;
25175 r->id.idiag_dport = ireq->rmt_port;
25176 - r->id.idiag_src[0] = ireq->loc_addr;
25177 - r->id.idiag_dst[0] = ireq->rmt_addr;
25178 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
25179 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
25180 r->idiag_expires = jiffies_to_msecs(tmo);
25181 r->idiag_rqueue = 0;
25182 r->idiag_wqueue = 0;
25183 @@ -663,6 +670,7 @@ static int inet_diag_dump_reqs(struct sk
25187 + /* TODO: lback */
25189 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25190 (entry.family == AF_INET6) ?
25191 @@ -733,6 +741,8 @@ static int inet_diag_dump(struct sk_buff
25192 sk_nulls_for_each(sk, node, &ilb->head) {
25193 struct inet_sock *inet = inet_sk(sk);
25195 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25200 @@ -799,6 +809,8 @@ skip_listen_ht:
25201 sk_nulls_for_each(sk, node, &head->chain) {
25202 struct inet_sock *inet = inet_sk(sk);
25204 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25208 if (!(r->idiag_states & (1 << sk->sk_state)))
25209 @@ -823,6 +835,8 @@ next_normal:
25210 inet_twsk_for_each(tw, node,
25213 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25217 if (r->id.idiag_sport != tw->tw_sport &&
25218 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/inet_hashtables.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/inet_hashtables.c
25219 --- linux-2.6.38.1/net/ipv4/inet_hashtables.c 2011-01-05 21:50:42.000000000 +0100
25220 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/inet_hashtables.c 2011-01-29 02:01:07.000000000 +0100
25223 #include <net/inet_connection_sock.h>
25224 #include <net/inet_hashtables.h>
25225 +#include <net/route.h>
25226 #include <net/ip.h>
25229 @@ -155,6 +156,11 @@ static inline int compute_score(struct s
25230 if (rcv_saddr != daddr)
25234 + /* block non nx_info ips */
25235 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25236 + daddr, NXA_MASK_BIND))
25239 if (sk->sk_bound_dev_if) {
25240 if (sk->sk_bound_dev_if != dif)
25241 @@ -172,7 +178,6 @@ static inline int compute_score(struct s
25242 * wildcarded during the search since they can never be otherwise.
25246 struct sock *__inet_lookup_listener(struct net *net,
25247 struct inet_hashinfo *hashinfo,
25248 const __be32 daddr, const unsigned short hnum,
25249 @@ -195,6 +200,7 @@ begin:
25255 * if the nulls value we got at the end of this lookup is
25256 * not the expected one, we must restart lookup.
25257 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/netfilter/nf_nat_helper.c
25258 --- linux-2.6.38.1/net/ipv4/netfilter/nf_nat_helper.c 2011-01-05 21:50:42.000000000 +0100
25259 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/netfilter/nf_nat_helper.c 2011-01-29 02:01:07.000000000 +0100
25261 #include <net/route.h>
25263 #include <linux/netfilter_ipv4.h>
25264 +#include <net/route.h>
25265 #include <net/netfilter/nf_conntrack.h>
25266 #include <net/netfilter/nf_conntrack_helper.h>
25267 #include <net/netfilter/nf_conntrack_ecache.h>
25268 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/netfilter.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/netfilter.c
25269 --- linux-2.6.38.1/net/ipv4/netfilter.c 2011-03-15 18:07:45.000000000 +0100
25270 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/netfilter.c 2011-01-29 02:01:07.000000000 +0100
25272 #include <linux/ip.h>
25273 #include <linux/skbuff.h>
25274 #include <linux/gfp.h>
25275 -#include <net/route.h>
25276 +// #include <net/route.h>
25277 #include <net/xfrm.h>
25278 #include <net/ip.h>
25279 #include <net/netfilter/nf_queue.h>
25280 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/raw.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/raw.c
25281 --- linux-2.6.38.1/net/ipv4/raw.c 2011-03-15 18:07:45.000000000 +0100
25282 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/raw.c 2011-02-17 02:17:52.000000000 +0100
25283 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
25285 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
25286 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
25287 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
25288 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
25289 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
25290 goto found; /* gotcha */
25292 @@ -384,6 +384,12 @@ static int raw_send_hdrinc(struct sock *
25293 icmp_out_count(net, ((struct icmphdr *)
25294 skb_transport_header(skb))->type);
25297 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
25298 + sk->sk_nx_info &&
25299 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
25302 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
25303 rt->dst.dev, dst_output);
25305 @@ -563,6 +569,13 @@ static int raw_sendmsg(struct kiocb *ioc
25308 security_sk_classify_flow(sk, &fl);
25309 + if (sk->sk_nx_info) {
25310 + err = ip_v4_find_src(sock_net(sk),
25311 + sk->sk_nx_info, &rt, &fl);
25316 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
25319 @@ -635,17 +648,19 @@ static int raw_bind(struct sock *sk, str
25321 struct inet_sock *inet = inet_sk(sk);
25322 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
25323 + struct nx_v4_sock_addr nsa = { 0 };
25327 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
25329 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25330 + v4_map_sock_addr(inet, addr, &nsa);
25331 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25332 ret = -EADDRNOTAVAIL;
25333 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
25334 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
25335 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
25337 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
25338 + v4_set_sock_addr(inet, &nsa);
25339 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25340 inet->inet_saddr = 0; /* Use device */
25342 @@ -697,7 +712,8 @@ static int raw_recvmsg(struct kiocb *ioc
25343 /* Copy the address. */
25345 sin->sin_family = AF_INET;
25346 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25347 + sin->sin_addr.s_addr =
25348 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
25350 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
25352 @@ -893,7 +909,8 @@ static struct sock *raw_get_first(struct
25353 struct hlist_node *node;
25355 sk_for_each(sk, node, &state->h->ht[state->bucket])
25356 - if (sock_net(sk) == seq_file_net(seq))
25357 + if ((sock_net(sk) == seq_file_net(seq)) &&
25358 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25362 @@ -909,7 +926,8 @@ static struct sock *raw_get_next(struct
25366 - } while (sk && sock_net(sk) != seq_file_net(seq));
25367 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
25368 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25370 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
25371 sk = sk_head(&state->h->ht[state->bucket]);
25372 @@ -968,7 +986,10 @@ static void raw_sock_seq_show(struct seq
25374 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
25375 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
25376 - i, src, srcp, dest, destp, sp->sk_state,
25378 + nx_map_sock_lback(current_nx_info(), src), srcp,
25379 + nx_map_sock_lback(current_nx_info(), dest), destp,
25381 sk_wmem_alloc_get(sp),
25382 sk_rmem_alloc_get(sp),
25383 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
25384 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/tcp.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/tcp.c
25385 --- linux-2.6.38.1/net/ipv4/tcp.c 2011-03-15 18:07:45.000000000 +0100
25386 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/tcp.c 2011-01-29 02:01:07.000000000 +0100
25387 @@ -266,6 +266,7 @@
25388 #include <linux/crypto.h>
25389 #include <linux/time.h>
25390 #include <linux/slab.h>
25391 +#include <linux/in.h>
25393 #include <net/icmp.h>
25394 #include <net/tcp.h>
25395 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/tcp_ipv4.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/tcp_ipv4.c
25396 --- linux-2.6.38.1/net/ipv4/tcp_ipv4.c 2011-03-15 18:07:45.000000000 +0100
25397 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/tcp_ipv4.c 2011-02-02 22:20:27.000000000 +0100
25398 @@ -1988,6 +1988,12 @@ static void *listening_get_next(struct s
25399 req = req->dl_next;
25402 + vxdprintk(VXD_CBIT(net, 6),
25403 + "sk,req: %p [#%d] (from %d)", req->sk,
25404 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
25406 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
25408 if (req->rsk_ops->family == st->family) {
25411 @@ -2012,6 +2018,10 @@ get_req:
25414 sk_nulls_for_each_from(sk, node) {
25415 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
25416 + sk, sk->sk_nid, nx_current_nid());
25417 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25419 if (!net_eq(sock_net(sk), net))
25421 if (sk->sk_family == st->family) {
25422 @@ -2088,6 +2098,11 @@ static void *established_get_first(struc
25424 spin_lock_bh(lock);
25425 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
25426 + vxdprintk(VXD_CBIT(net, 6),
25427 + "sk,egf: %p [#%d] (from %d)",
25428 + sk, sk->sk_nid, nx_current_nid());
25429 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25431 if (sk->sk_family != st->family ||
25432 !net_eq(sock_net(sk), net)) {
25434 @@ -2098,6 +2113,11 @@ static void *established_get_first(struc
25435 st->state = TCP_SEQ_STATE_TIME_WAIT;
25436 inet_twsk_for_each(tw, node,
25437 &tcp_hashinfo.ehash[st->bucket].twchain) {
25438 + vxdprintk(VXD_CBIT(net, 6),
25439 + "tw: %p [#%d] (from %d)",
25440 + tw, tw->tw_nid, nx_current_nid());
25441 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25443 if (tw->tw_family != st->family ||
25444 !net_eq(twsk_net(tw), net)) {
25446 @@ -2127,7 +2147,9 @@ static void *established_get_next(struct
25450 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
25451 + while (tw && (tw->tw_family != st->family ||
25452 + !net_eq(twsk_net(tw), net) ||
25453 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
25457 @@ -2151,6 +2173,11 @@ get_tw:
25458 sk = sk_nulls_next(sk);
25460 sk_nulls_for_each_from(sk, node) {
25461 + vxdprintk(VXD_CBIT(net, 6),
25462 + "sk,egn: %p [#%d] (from %d)",
25463 + sk, sk->sk_nid, nx_current_nid());
25464 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25466 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
25469 @@ -2360,9 +2387,9 @@ static void get_openreq4(struct sock *sk
25470 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25471 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
25474 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
25475 ntohs(inet_sk(sk)->inet_sport),
25477 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
25478 ntohs(ireq->rmt_port),
25480 0, 0, /* could print option size, but that is af dependent. */
25481 @@ -2414,7 +2441,10 @@ static void get_tcp4_sock(struct sock *s
25483 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
25484 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
25485 - i, src, srcp, dest, destp, sk->sk_state,
25487 + nx_map_sock_lback(current_nx_info(), src), srcp,
25488 + nx_map_sock_lback(current_nx_info(), dest), destp,
25490 tp->write_seq - tp->snd_una,
25493 @@ -2449,7 +2479,10 @@ static void get_timewait4_sock(struct in
25495 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25496 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
25497 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
25499 + nx_map_sock_lback(current_nx_info(), src), srcp,
25500 + nx_map_sock_lback(current_nx_info(), dest), destp,
25501 + tw->tw_substate, 0, 0,
25502 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
25503 atomic_read(&tw->tw_refcnt), tw, len);
25505 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/tcp_minisocks.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/tcp_minisocks.c
25506 --- linux-2.6.38.1/net/ipv4/tcp_minisocks.c 2011-03-15 18:07:45.000000000 +0100
25507 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/tcp_minisocks.c 2011-01-29 02:01:07.000000000 +0100
25509 #include <linux/slab.h>
25510 #include <linux/sysctl.h>
25511 #include <linux/workqueue.h>
25512 +#include <linux/vs_limit.h>
25513 +#include <linux/vs_socket.h>
25514 +#include <linux/vs_context.h>
25515 #include <net/tcp.h>
25516 #include <net/inet_common.h>
25517 #include <net/xfrm.h>
25518 @@ -335,6 +338,11 @@ void tcp_time_wait(struct sock *sk, int
25519 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25520 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25522 + tw->tw_xid = sk->sk_xid;
25523 + tw->tw_vx_info = NULL;
25524 + tw->tw_nid = sk->sk_nid;
25525 + tw->tw_nx_info = NULL;
25527 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
25528 if (tw->tw_family == PF_INET6) {
25529 struct ipv6_pinfo *np = inet6_sk(sk);
25530 diff -NurpP --minimal linux-2.6.38.1/net/ipv4/udp.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/udp.c
25531 --- linux-2.6.38.1/net/ipv4/udp.c 2011-03-15 18:07:45.000000000 +0100
25532 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv4/udp.c 2011-01-29 02:01:07.000000000 +0100
25533 @@ -296,14 +296,7 @@ fail:
25535 EXPORT_SYMBOL(udp_lib_get_port);
25537 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25539 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25541 - return (!ipv6_only_sock(sk2) &&
25542 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25543 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25545 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25547 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25549 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
25550 if (inet->inet_rcv_saddr != daddr)
25554 + /* block non nx_info ips */
25555 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25556 + daddr, NXA_MASK_BIND))
25559 if (inet->inet_daddr) {
25560 if (inet->inet_daddr != saddr)
25561 @@ -441,6 +439,7 @@ exact_match:
25566 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25567 * harder than this. -DaveM
25569 @@ -486,6 +485,11 @@ begin:
25570 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25571 score = compute_score(sk, net, saddr, hnum, sport,
25572 daddr, dport, dif);
25573 + /* FIXME: disabled?
25574 + if (score == 9) {
25578 if (score > badness) {
25581 @@ -499,6 +503,7 @@ begin:
25582 if (get_nulls_value(node) != slot)
25587 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
25589 @@ -508,6 +513,7 @@ begin:
25597 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
25598 udp_sk(s)->udp_port_hash != hnum ||
25599 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25600 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25601 - (inet->inet_rcv_saddr &&
25602 - inet->inet_rcv_saddr != loc_addr) ||
25603 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25604 ipv6_only_sock(s) ||
25605 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25607 @@ -898,8 +903,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
25608 .fl_ip_sport = inet->inet_sport,
25609 .fl_ip_dport = dport };
25610 struct net *net = sock_net(sk);
25611 + struct nx_info *nxi = sk->sk_nx_info;
25613 security_sk_classify_flow(sk, &fl);
25614 + err = ip_v4_find_src(net, nxi, &rt, &fl);
25618 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
25620 if (err == -ENETUNREACH)
25621 @@ -1181,7 +1191,8 @@ try_again:
25623 sin->sin_family = AF_INET;
25624 sin->sin_port = udp_hdr(skb)->source;
25625 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25626 + sin->sin_addr.s_addr = nx_map_sock_lback(
25627 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25628 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25630 if (inet->cmsg_flags)
25631 @@ -1922,6 +1933,8 @@ static struct sock *udp_get_first(struct
25632 sk_nulls_for_each(sk, node, &hslot->head) {
25633 if (!net_eq(sock_net(sk), net))
25635 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25637 if (sk->sk_family == state->family)
25640 @@ -1939,7 +1952,9 @@ static struct sock *udp_get_next(struct
25643 sk = sk_nulls_next(sk);
25644 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25645 + } while (sk && (!net_eq(sock_net(sk), net) ||
25646 + sk->sk_family != state->family ||
25647 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25650 if (state->bucket <= state->udp_table->mask)
25651 @@ -2046,7 +2061,10 @@ static void udp4_format_sock(struct sock
25653 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
25654 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
25655 - bucket, src, srcp, dest, destp, sp->sk_state,
25657 + nx_map_sock_lback(current_nx_info(), src), srcp,
25658 + nx_map_sock_lback(current_nx_info(), dest), destp,
25660 sk_wmem_alloc_get(sp),
25661 sk_rmem_alloc_get(sp),
25662 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
25663 diff -NurpP --minimal linux-2.6.38.1/net/ipv6/Kconfig linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/Kconfig
25664 --- linux-2.6.38.1/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
25665 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/Kconfig 2011-01-29 02:01:07.000000000 +0100
25668 # IPv6 as module will cause a CRASH if you try to unload it
25670 - tristate "The IPv6 protocol"
25672 + bool "The IPv6 protocol"
25675 This is complemental support for the IP version 6.
25676 You will still be able to do traditional IPv4 networking as well.
25677 diff -NurpP --minimal linux-2.6.38.1/net/ipv6/addrconf.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/addrconf.c
25678 --- linux-2.6.38.1/net/ipv6/addrconf.c 2011-03-15 18:07:45.000000000 +0100
25679 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/addrconf.c 2011-02-02 22:20:27.000000000 +0100
25682 #include <linux/proc_fs.h>
25683 #include <linux/seq_file.h>
25684 +#include <linux/vs_network.h>
25685 +#include <linux/vs_inet6.h>
25687 /* Set to 3 to get tracing... */
25688 #define ACONF_DEBUG 2
25689 @@ -1121,7 +1123,7 @@ out:
25691 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25692 const struct in6_addr *daddr, unsigned int prefs,
25693 - struct in6_addr *saddr)
25694 + struct in6_addr *saddr, struct nx_info *nxi)
25696 struct ipv6_saddr_score scores[2],
25697 *score = &scores[0], *hiscore = &scores[1];
25698 @@ -1193,6 +1195,8 @@ int ipv6_dev_get_saddr(struct net *net,
25702 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25706 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25707 @@ -3061,7 +3065,10 @@ static void if6_seq_stop(struct seq_file
25708 static int if6_seq_show(struct seq_file *seq, void *v)
25710 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25711 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25713 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25714 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25715 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25717 ifp->idev->dev->ifindex,
25719 @@ -3567,6 +3574,11 @@ static int in6_dump_addrs(struct inet6_d
25720 struct ifacaddr6 *ifaca;
25722 int ip_idx = *p_ip_idx;
25723 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25725 + /* disable ipv6 on non v6 guests */
25726 + if (nxi && !nx_info_has_v6(nxi))
25729 read_lock_bh(&idev->lock);
25731 @@ -3577,6 +3589,8 @@ static int in6_dump_addrs(struct inet6_d
25732 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25733 if (++ip_idx < s_ip_idx)
25735 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25737 err = inet6_fill_ifaddr(skb, ifa,
25738 NETLINK_CB(cb->skb).pid,
25739 cb->nlh->nlmsg_seq,
25740 @@ -3593,6 +3607,8 @@ static int in6_dump_addrs(struct inet6_d
25741 ifmca = ifmca->next, ip_idx++) {
25742 if (ip_idx < s_ip_idx)
25744 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25746 err = inet6_fill_ifmcaddr(skb, ifmca,
25747 NETLINK_CB(cb->skb).pid,
25748 cb->nlh->nlmsg_seq,
25749 @@ -3608,6 +3624,8 @@ static int in6_dump_addrs(struct inet6_d
25750 ifaca = ifaca->aca_next, ip_idx++) {
25751 if (ip_idx < s_ip_idx)
25753 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25755 err = inet6_fill_ifacaddr(skb, ifaca,
25756 NETLINK_CB(cb->skb).pid,
25757 cb->nlh->nlmsg_seq,
25758 @@ -3993,6 +4011,11 @@ static int inet6_dump_ifinfo(struct sk_b
25759 struct inet6_dev *idev;
25760 struct hlist_head *head;
25761 struct hlist_node *node;
25762 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25764 + /* FIXME: maybe disable ipv6 on non v6 guests?
25765 + if (skb->sk && skb->sk->sk_vx_info)
25766 + return skb->len; */
25769 s_idx = cb->args[1];
25770 @@ -4004,6 +4027,8 @@ static int inet6_dump_ifinfo(struct sk_b
25771 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25774 + if (!v6_dev_in_nx_info(dev, nxi))
25776 idev = __in6_dev_get(dev);
25779 diff -NurpP --minimal linux-2.6.38.1/net/ipv6/af_inet6.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/af_inet6.c
25780 --- linux-2.6.38.1/net/ipv6/af_inet6.c 2011-03-15 18:07:45.000000000 +0100
25781 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/af_inet6.c 2011-01-29 02:01:07.000000000 +0100
25783 #include <linux/netdevice.h>
25784 #include <linux/icmpv6.h>
25785 #include <linux/netfilter_ipv6.h>
25786 +#include <linux/vs_inet.h>
25787 +#include <linux/vs_inet6.h>
25789 #include <net/ip.h>
25790 #include <net/ipv6.h>
25791 @@ -160,9 +162,12 @@ lookup_protocol:
25795 + if ((protocol == IPPROTO_ICMPV6) &&
25796 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25798 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25799 goto out_rcu_unlock;
25802 sock->ops = answer->ops;
25803 answer_prot = answer->prot;
25804 answer_no_check = answer->no_check;
25805 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25806 struct inet_sock *inet = inet_sk(sk);
25807 struct ipv6_pinfo *np = inet6_sk(sk);
25808 struct net *net = sock_net(sk);
25809 + struct nx_v6_sock_addr nsa;
25811 unsigned short snum;
25813 @@ -272,6 +278,11 @@ int inet6_bind(struct socket *sock, stru
25815 if (addr_len < SIN6_LEN_RFC2133)
25818 + err = v6_map_sock_addr(inet, addr, &nsa);
25822 addr_type = ipv6_addr_type(&addr->sin6_addr);
25823 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25825 @@ -303,6 +314,7 @@ int inet6_bind(struct socket *sock, stru
25826 /* Reproduce AF_INET checks to make the bindings consistent */
25827 v4addr = addr->sin6_addr.s6_addr32[3];
25828 chk_addr_ret = inet_addr_type(net, v4addr);
25830 if (!sysctl_ip_nonlocal_bind &&
25831 !(inet->freebind || inet->transparent) &&
25832 v4addr != htonl(INADDR_ANY) &&
25833 @@ -312,6 +324,10 @@ int inet6_bind(struct socket *sock, stru
25834 err = -EADDRNOTAVAIL;
25837 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25838 + err = -EADDRNOTAVAIL;
25842 if (addr_type != IPV6_ADDR_ANY) {
25843 struct net_device *dev = NULL;
25844 @@ -338,6 +354,11 @@ int inet6_bind(struct socket *sock, stru
25848 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25849 + err = -EADDRNOTAVAIL;
25853 /* ipv4 addr of the socket is invalid. Only the
25854 * unspecified and mapped address have a v4 equivalent.
25856 @@ -354,6 +375,9 @@ int inet6_bind(struct socket *sock, stru
25860 + /* what's that for? */
25861 + v6_set_sock_addr(inet, &nsa);
25863 inet->inet_rcv_saddr = v4addr;
25864 inet->inet_saddr = v4addr;
25866 @@ -455,9 +479,11 @@ int inet6_getname(struct socket *sock, s
25868 sin->sin6_port = inet->inet_dport;
25869 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
25870 + /* FIXME: remap lback? */
25872 sin->sin6_flowinfo = np->flow_label;
25874 + /* FIXME: remap lback? */
25875 if (ipv6_addr_any(&np->rcv_saddr))
25876 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
25878 diff -NurpP --minimal linux-2.6.38.1/net/ipv6/fib6_rules.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/fib6_rules.c
25879 --- linux-2.6.38.1/net/ipv6/fib6_rules.c 2011-01-05 21:50:42.000000000 +0100
25880 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/fib6_rules.c 2011-01-29 02:01:07.000000000 +0100
25881 @@ -88,7 +88,7 @@ static int fib6_rule_action(struct fib_r
25882 ip6_dst_idev(&rt->dst)->dev,
25884 rt6_flags2srcprefs(flags),
25888 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25890 diff -NurpP --minimal linux-2.6.38.1/net/ipv6/inet6_hashtables.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/inet6_hashtables.c
25891 --- linux-2.6.38.1/net/ipv6/inet6_hashtables.c 2010-02-25 11:52:10.000000000 +0100
25892 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/inet6_hashtables.c 2011-01-29 02:01:07.000000000 +0100
25895 #include <linux/module.h>
25896 #include <linux/random.h>
25897 +#include <linux/vs_inet6.h>
25899 #include <net/inet_connection_sock.h>
25900 #include <net/inet_hashtables.h>
25901 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
25902 unsigned int slot = hash & hashinfo->ehash_mask;
25903 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25908 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25909 @@ -94,7 +94,7 @@ begin:
25917 if (get_nulls_value(node) != slot)
25918 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
25919 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25923 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25926 if (sk->sk_bound_dev_if) {
25927 if (sk->sk_bound_dev_if != dif)
25928 diff -NurpP --minimal linux-2.6.38.1/net/ipv6/ip6_output.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/ip6_output.c
25929 --- linux-2.6.38.1/net/ipv6/ip6_output.c 2011-03-15 18:07:45.000000000 +0100
25930 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/ip6_output.c 2011-01-29 02:01:07.000000000 +0100
25931 @@ -933,7 +933,7 @@ static int ip6_dst_lookup_tail(struct so
25932 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
25934 sk ? inet6_sk(sk)->srcprefs : 0,
25936 + &fl->fl6_src, sk->sk_nx_info);
25938 goto out_err_release;
25940 diff -NurpP --minimal linux-2.6.38.1/net/ipv6/ndisc.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/ndisc.c
25941 --- linux-2.6.38.1/net/ipv6/ndisc.c 2011-03-15 18:07:45.000000000 +0100
25942 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/ndisc.c 2011-03-10 16:52:54.000000000 +0100
25943 @@ -595,7 +595,7 @@ static void ndisc_send_na(struct net_dev
25945 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25946 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25950 src_addr = &tmpaddr;
25952 diff -NurpP --minimal linux-2.6.38.1/net/ipv6/raw.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/raw.c
25953 --- linux-2.6.38.1/net/ipv6/raw.c 2011-03-15 18:07:45.000000000 +0100
25954 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/raw.c 2011-02-17 02:17:52.000000000 +0100
25956 #include <linux/icmpv6.h>
25957 #include <linux/netfilter.h>
25958 #include <linux/netfilter_ipv6.h>
25959 +#include <linux/vs_inet6.h>
25960 #include <linux/skbuff.h>
25961 #include <linux/compat.h>
25962 #include <asm/uaccess.h>
25963 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
25967 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25968 + err = -EADDRNOTAVAIL;
25974 /* ipv4 addr of the socket is invalid. Only the
25975 * unspecified and mapped address have a v4 equivalent.
25977 diff -NurpP --minimal linux-2.6.38.1/net/ipv6/route.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/route.c
25978 --- linux-2.6.38.1/net/ipv6/route.c 2011-03-15 18:07:45.000000000 +0100
25979 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/route.c 2011-03-15 18:15:06.000000000 +0100
25980 @@ -2291,7 +2291,8 @@ static int rt6_fill_node(struct net *net
25981 struct inet6_dev *idev = ip6_dst_idev(&rt->dst);
25982 struct in6_addr saddr_buf;
25983 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25984 - dst, 0, &saddr_buf) == 0)
25985 + dst, 0, &saddr_buf,
25986 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
25987 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
25990 diff -NurpP --minimal linux-2.6.38.1/net/ipv6/tcp_ipv6.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/tcp_ipv6.c
25991 --- linux-2.6.38.1/net/ipv6/tcp_ipv6.c 2011-03-15 18:07:45.000000000 +0100
25992 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/tcp_ipv6.c 2011-01-29 02:01:07.000000000 +0100
25995 #include <linux/crypto.h>
25996 #include <linux/scatterlist.h>
25997 +#include <linux/vs_inet6.h>
25999 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
26000 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
26001 @@ -161,8 +162,15 @@ static int tcp_v6_connect(struct sock *s
26002 * connect() to INADDR_ANY means loopback (BSD'ism).
26005 - if(ipv6_addr_any(&usin->sin6_addr))
26006 - usin->sin6_addr.s6_addr[15] = 0x1;
26007 + if(ipv6_addr_any(&usin->sin6_addr)) {
26008 + struct nx_info *nxi = sk->sk_nx_info;
26010 + if (nxi && nx_info_has_v6(nxi))
26011 + /* FIXME: remap lback? */
26012 + usin->sin6_addr = nxi->v6.ip;
26014 + usin->sin6_addr.s6_addr[15] = 0x1;
26017 addr_type = ipv6_addr_type(&usin->sin6_addr);
26019 diff -NurpP --minimal linux-2.6.38.1/net/ipv6/udp.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/udp.c
26020 --- linux-2.6.38.1/net/ipv6/udp.c 2011-03-15 18:07:45.000000000 +0100
26021 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/udp.c 2011-01-29 05:23:17.000000000 +0100
26022 @@ -45,41 +45,67 @@
26023 #include <net/tcp_states.h>
26024 #include <net/ip6_checksum.h>
26025 #include <net/xfrm.h>
26026 +#include <linux/vs_inet6.h>
26028 #include <linux/proc_fs.h>
26029 #include <linux/seq_file.h>
26030 #include "udp_impl.h"
26032 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
26033 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26035 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
26036 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
26037 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
26038 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
26039 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
26040 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
26041 - int sk_ipv6only = ipv6_only_sock(sk);
26042 + int sk1_ipv6only = ipv6_only_sock(sk1);
26043 int sk2_ipv6only = inet_v6_ipv6only(sk2);
26044 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
26045 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
26046 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
26048 /* if both are mapped, treat as IPv4 */
26049 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
26050 - return (!sk2_ipv6only &&
26051 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
26052 + if (!sk2_ipv6only &&
26053 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
26054 - sk1_rcv_saddr == sk2_rcv_saddr));
26055 + sk1_rcv_saddr == sk2_rcv_saddr))
26061 if (addr_type2 == IPV6_ADDR_ANY &&
26062 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
26066 if (addr_type == IPV6_ADDR_ANY &&
26067 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
26069 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
26072 if (sk2_rcv_saddr6 &&
26073 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
26075 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
26081 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
26082 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
26083 + if (!sk2_rcv_saddr)
26084 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
26085 + if (!sk1_rcv_saddr)
26086 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
26089 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
26090 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
26091 + else if (addr_type2 == IPV6_ADDR_ANY)
26092 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
26093 + else if (addr_type == IPV6_ADDR_ANY) {
26094 + if (addr_type2 == IPV6_ADDR_MAPPED)
26095 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
26097 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
26102 static unsigned int udp6_portaddr_hash(struct net *net,
26103 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
26104 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
26108 + /* block non nx_info ips */
26109 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
26112 if (!ipv6_addr_any(&np->daddr)) {
26113 if (!ipv6_addr_equal(&np->daddr, saddr))
26114 diff -NurpP --minimal linux-2.6.38.1/net/ipv6/xfrm6_policy.c linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/xfrm6_policy.c
26115 --- linux-2.6.38.1/net/ipv6/xfrm6_policy.c 2011-03-15 18:07:45.000000000 +0100
26116 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/ipv6/xfrm6_policy.c 2011-02-02 22:20:27.000000000 +0100
26117 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
26118 dev = ip6_dst_idev(dst)->dev;
26119 ipv6_dev_get_saddr(dev_net(dev), dev,
26120 (struct in6_addr *)&daddr->a6, 0,
26121 - (struct in6_addr *)&saddr->a6);
26122 + (struct in6_addr *)&saddr->a6, NULL);
26126 diff -NurpP --minimal linux-2.6.38.1/net/netfilter/ipvs/ip_vs_xmit.c linux-2.6.38.1-vs2.3.0.37-rc9/net/netfilter/ipvs/ip_vs_xmit.c
26127 --- linux-2.6.38.1/net/netfilter/ipvs/ip_vs_xmit.c 2011-03-15 18:07:46.000000000 +0100
26128 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/netfilter/ipvs/ip_vs_xmit.c 2011-01-29 02:01:07.000000000 +0100
26129 @@ -213,7 +213,7 @@ __ip_vs_route_output_v6(struct net *net,
26131 if (ipv6_addr_any(&fl.fl6_src) &&
26132 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
26133 - &fl.fl6_dst, 0, &fl.fl6_src) < 0)
26134 + &fl.fl6_dst, 0, &fl.fl6_src, NULL) < 0)
26136 if (do_xfrm && xfrm_lookup(net, &dst, &fl, NULL, 0) < 0)
26138 diff -NurpP --minimal linux-2.6.38.1/net/netlink/af_netlink.c linux-2.6.38.1-vs2.3.0.37-rc9/net/netlink/af_netlink.c
26139 --- linux-2.6.38.1/net/netlink/af_netlink.c 2011-03-15 18:07:46.000000000 +0100
26140 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/netlink/af_netlink.c 2011-03-10 17:21:19.000000000 +0100
26142 #include <linux/types.h>
26143 #include <linux/audit.h>
26144 #include <linux/mutex.h>
26145 +#include <linux/vs_context.h>
26146 +#include <linux/vs_network.h>
26147 +#include <linux/vs_limit.h>
26149 #include <net/net_namespace.h>
26150 #include <net/sock.h>
26151 @@ -1922,6 +1925,8 @@ static struct sock *netlink_seq_socket_i
26152 sk_for_each(s, node, &hash->table[j]) {
26153 if (sock_net(s) != seq_file_net(seq))
26155 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26159 iter->hash_idx = j;
26160 @@ -1956,7 +1961,8 @@ static void *netlink_seq_next(struct seq
26164 - } while (s && sock_net(s) != seq_file_net(seq));
26165 + } while (s && (sock_net(s) != seq_file_net(seq) ||
26166 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
26170 @@ -1968,7 +1974,8 @@ static void *netlink_seq_next(struct seq
26172 for (; j <= hash->mask; j++) {
26173 s = sk_head(&hash->table[j]);
26174 - while (s && sock_net(s) != seq_file_net(seq))
26175 + while (s && (sock_net(s) != seq_file_net(seq) ||
26176 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
26180 diff -NurpP --minimal linux-2.6.38.1/net/sctp/ipv6.c linux-2.6.38.1-vs2.3.0.37-rc9/net/sctp/ipv6.c
26181 --- linux-2.6.38.1/net/sctp/ipv6.c 2011-01-05 21:50:45.000000000 +0100
26182 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/sctp/ipv6.c 2011-01-29 02:01:07.000000000 +0100
26183 @@ -306,7 +306,8 @@ static void sctp_v6_get_saddr(struct sct
26184 dst ? ip6_dst_idev(dst)->dev : NULL,
26185 &daddr->v6.sin6_addr,
26186 inet6_sk(&sk->inet.sk)->srcprefs,
26187 - &saddr->v6.sin6_addr);
26188 + &saddr->v6.sin6_addr,
26189 + asoc->base.sk->sk_nx_info);
26190 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
26191 &saddr->v6.sin6_addr);
26193 diff -NurpP --minimal linux-2.6.38.1/net/socket.c linux-2.6.38.1-vs2.3.0.37-rc9/net/socket.c
26194 --- linux-2.6.38.1/net/socket.c 2011-03-15 18:07:46.000000000 +0100
26195 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/socket.c 2011-01-29 02:01:07.000000000 +0100
26198 #include <net/sock.h>
26199 #include <linux/netfilter.h>
26200 +#include <linux/vs_base.h>
26201 +#include <linux/vs_socket.h>
26202 +#include <linux/vs_inet.h>
26203 +#include <linux/vs_inet6.h>
26205 #include <linux/if_tun.h>
26206 #include <linux/ipv6_route.h>
26207 @@ -551,7 +555,7 @@ static inline int __sock_sendmsg(struct
26208 struct msghdr *msg, size_t size)
26210 struct sock_iocb *si = kiocb_to_siocb(iocb);
26214 sock_update_classid(sock->sk);
26216 @@ -564,7 +568,22 @@ static inline int __sock_sendmsg(struct
26220 - return sock->ops->sendmsg(iocb, sock, msg, size);
26221 + len = sock->ops->sendmsg(iocb, sock, msg, size);
26224 + vx_sock_send(sock->sk, size);
26226 + vx_sock_fail(sock->sk, size);
26228 + vxdprintk(VXD_CBIT(net, 7),
26229 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26231 + (sock->sk)?sock->sk->sk_nx_info:0,
26232 + (sock->sk)?sock->sk->sk_vx_info:0,
26233 + (sock->sk)?sock->sk->sk_xid:0,
26234 + (sock->sk)?sock->sk->sk_nid:0,
26235 + (unsigned int)size, len);
26239 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
26240 @@ -682,6 +701,7 @@ static inline int __sock_recvmsg_nosec(s
26241 struct msghdr *msg, size_t size, int flags)
26243 struct sock_iocb *si = kiocb_to_siocb(iocb);
26246 sock_update_classid(sock->sk);
26248 @@ -691,7 +711,18 @@ static inline int __sock_recvmsg_nosec(s
26252 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
26253 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
26254 + if ((len >= 0) && sock->sk)
26255 + vx_sock_recv(sock->sk, len);
26256 + vxdprintk(VXD_CBIT(net, 7),
26257 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26259 + (sock->sk)?sock->sk->sk_nx_info:0,
26260 + (sock->sk)?sock->sk->sk_vx_info:0,
26261 + (sock->sk)?sock->sk->sk_xid:0,
26262 + (sock->sk)?sock->sk->sk_nid:0,
26263 + (unsigned int)size, len);
26267 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
26268 @@ -1175,6 +1206,13 @@ int __sock_create(struct net *net, int f
26269 if (type < 0 || type >= SOCK_MAX)
26272 + if (!nx_check(0, VS_ADMIN)) {
26273 + if (family == PF_INET && !current_nx_info_has_v4())
26274 + return -EAFNOSUPPORT;
26275 + if (family == PF_INET6 && !current_nx_info_has_v6())
26276 + return -EAFNOSUPPORT;
26281 This uglymoron is moved from INET layer to here to avoid
26282 @@ -1310,6 +1348,7 @@ SYSCALL_DEFINE3(socket, int, family, int
26286 + set_bit(SOCK_USER_SOCKET, &sock->flags);
26287 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
26290 @@ -1351,10 +1390,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
26291 err = sock_create(family, type, protocol, &sock1);
26294 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
26296 err = sock_create(family, type, protocol, &sock2);
26298 goto out_release_1;
26299 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
26301 err = sock1->ops->socketpair(sock1, sock2);
26303 diff -NurpP --minimal linux-2.6.38.1/net/sunrpc/auth.c linux-2.6.38.1-vs2.3.0.37-rc9/net/sunrpc/auth.c
26304 --- linux-2.6.38.1/net/sunrpc/auth.c 2011-03-15 18:07:46.000000000 +0100
26305 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/sunrpc/auth.c 2011-01-29 02:01:07.000000000 +0100
26307 #include <linux/hash.h>
26308 #include <linux/sunrpc/clnt.h>
26309 #include <linux/spinlock.h>
26310 +#include <linux/vs_tag.h>
26313 # define RPCDBG_FACILITY RPCDBG_AUTH
26314 @@ -425,6 +426,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
26315 memset(&acred, 0, sizeof(acred));
26316 acred.uid = cred->fsuid;
26317 acred.gid = cred->fsgid;
26318 + acred.tag = dx_current_tag();
26319 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
26321 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
26322 @@ -465,6 +467,7 @@ rpcauth_bind_root_cred(struct rpc_task *
26323 struct auth_cred acred = {
26326 + .tag = dx_current_tag(),
26329 dprintk("RPC: %5u looking up %s cred\n",
26330 diff -NurpP --minimal linux-2.6.38.1/net/sunrpc/auth_unix.c linux-2.6.38.1-vs2.3.0.37-rc9/net/sunrpc/auth_unix.c
26331 --- linux-2.6.38.1/net/sunrpc/auth_unix.c 2010-10-21 13:08:01.000000000 +0200
26332 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/sunrpc/auth_unix.c 2011-01-29 02:01:07.000000000 +0100
26333 @@ -12,12 +12,14 @@
26334 #include <linux/module.h>
26335 #include <linux/sunrpc/clnt.h>
26336 #include <linux/sunrpc/auth.h>
26337 +#include <linux/vs_tag.h>
26339 #define NFS_NGROUPS 16
26342 struct rpc_cred uc_base;
26345 gid_t uc_gids[NFS_NGROUPS];
26347 #define uc_uid uc_base.cr_uid
26348 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
26349 groups = NFS_NGROUPS;
26351 cred->uc_gid = acred->gid;
26352 + cred->uc_tag = acred->tag;
26353 for (i = 0; i < groups; i++)
26354 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
26355 if (i < NFS_NGROUPS)
26356 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
26360 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
26361 + if (cred->uc_uid != acred->uid ||
26362 + cred->uc_gid != acred->gid ||
26363 + cred->uc_tag != acred->tag)
26366 if (acred->group_info != NULL)
26367 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
26368 struct rpc_clnt *clnt = task->tk_client;
26369 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
26370 __be32 *base, *hold;
26374 *p++ = htonl(RPC_AUTH_UNIX);
26376 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
26377 * Copy the UTS nodename captured when the client was created.
26379 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
26380 + tag = task->tk_client->cl_tag;
26382 - *p++ = htonl((u32) cred->uc_uid);
26383 - *p++ = htonl((u32) cred->uc_gid);
26384 + *p++ = htonl((u32) TAGINO_UID(tag,
26385 + cred->uc_uid, cred->uc_tag));
26386 + *p++ = htonl((u32) TAGINO_GID(tag,
26387 + cred->uc_gid, cred->uc_tag));
26389 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
26390 *p++ = htonl((u32) cred->uc_gids[i]);
26391 diff -NurpP --minimal linux-2.6.38.1/net/sunrpc/clnt.c linux-2.6.38.1-vs2.3.0.37-rc9/net/sunrpc/clnt.c
26392 --- linux-2.6.38.1/net/sunrpc/clnt.c 2011-03-26 01:10:17.000000000 +0100
26393 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/sunrpc/clnt.c 2011-03-25 22:52:15.000000000 +0100
26395 #include <linux/utsname.h>
26396 #include <linux/workqueue.h>
26397 #include <linux/in6.h>
26398 +#include <linux/vs_cvirt.h>
26400 #include <linux/sunrpc/clnt.h>
26401 #include <linux/sunrpc/rpc_pipe_fs.h>
26402 @@ -359,6 +360,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
26403 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
26404 clnt->cl_chatty = 1;
26406 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
26407 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
26408 + clnt->cl_tag = 1; */
26411 EXPORT_SYMBOL_GPL(rpc_create);
26412 diff -NurpP --minimal linux-2.6.38.1/net/unix/af_unix.c linux-2.6.38.1-vs2.3.0.37-rc9/net/unix/af_unix.c
26413 --- linux-2.6.38.1/net/unix/af_unix.c 2011-03-15 18:07:46.000000000 +0100
26414 +++ linux-2.6.38.1-vs2.3.0.37-rc9/net/unix/af_unix.c 2011-03-15 18:15:06.000000000 +0100
26415 @@ -114,6 +114,8 @@
26416 #include <linux/mount.h>
26417 #include <net/checksum.h>
26418 #include <linux/security.h>
26419 +#include <linux/vs_context.h>
26420 +#include <linux/vs_limit.h>
26422 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
26423 static DEFINE_SPINLOCK(unix_table_lock);
26424 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
26425 if (!net_eq(sock_net(s), net))
26428 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26430 if (u->addr->len == len &&
26431 !memcmp(u->addr->name, sunname, len))
26433 @@ -2188,6 +2192,8 @@ static struct sock *unix_seq_idx(struct
26434 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
26435 if (sock_net(s) != seq_file_net(seq))
26437 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26442 @@ -2212,7 +2218,8 @@ static void *unix_seq_next(struct seq_fi
26443 sk = first_unix_socket(&iter->i);
26445 sk = next_unix_socket(&iter->i, sk);
26446 - while (sk && (sock_net(sk) != seq_file_net(seq)))
26447 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
26448 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
26449 sk = next_unix_socket(&iter->i, sk);
26452 diff -NurpP --minimal linux-2.6.38.1/scripts/checksyscalls.sh linux-2.6.38.1-vs2.3.0.37-rc9/scripts/checksyscalls.sh
26453 --- linux-2.6.38.1/scripts/checksyscalls.sh 2011-03-15 18:07:46.000000000 +0100
26454 +++ linux-2.6.38.1-vs2.3.0.37-rc9/scripts/checksyscalls.sh 2011-01-29 02:01:07.000000000 +0100
26455 @@ -193,7 +193,6 @@ cat << EOF
26456 #define __IGNORE_afs_syscall
26457 #define __IGNORE_getpmsg
26458 #define __IGNORE_putpmsg
26459 -#define __IGNORE_vserver
26463 diff -NurpP --minimal linux-2.6.38.1/security/commoncap.c linux-2.6.38.1-vs2.3.0.37-rc9/security/commoncap.c
26464 --- linux-2.6.38.1/security/commoncap.c 2011-01-05 21:50:47.000000000 +0100
26465 +++ linux-2.6.38.1-vs2.3.0.37-rc9/security/commoncap.c 2011-01-29 02:01:07.000000000 +0100
26467 #include <linux/sched.h>
26468 #include <linux/prctl.h>
26469 #include <linux/securebits.h>
26470 +// #include <linux/vs_context.h>
26473 * If a non-root user executes a setuid-root binary in
26474 @@ -52,7 +53,7 @@ static void warn_setuid_and_fcaps_mixed(
26476 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
26478 - NETLINK_CB(skb).eff_cap = current_cap();
26479 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
26483 @@ -62,6 +63,7 @@ int cap_netlink_recv(struct sk_buff *skb
26488 EXPORT_SYMBOL(cap_netlink_recv);
26491 @@ -82,7 +84,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
26492 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
26495 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
26496 + struct vx_info *vxi = tsk->vx_info;
26499 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
26500 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
26501 + cap_raised(tsk->cap_effective, cap),
26502 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
26505 + /* special case SETUP */
26506 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26507 + /* FIXME: maybe use cred instead? */
26508 + cap_raised(tsk->cred->cap_effective, cap))
26511 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26515 @@ -570,7 +587,7 @@ int cap_inode_setxattr(struct dentry *de
26517 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26518 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26519 - !capable(CAP_SYS_ADMIN))
26520 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26524 @@ -596,7 +613,7 @@ int cap_inode_removexattr(struct dentry
26526 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26527 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26528 - !capable(CAP_SYS_ADMIN))
26529 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26533 @@ -929,3 +946,4 @@ int cap_file_mmap(struct file *file, uns
26538 diff -NurpP --minimal linux-2.6.38.1/security/selinux/hooks.c linux-2.6.38.1-vs2.3.0.37-rc9/security/selinux/hooks.c
26539 --- linux-2.6.38.1/security/selinux/hooks.c 2011-03-15 18:07:47.000000000 +0100
26540 +++ linux-2.6.38.1-vs2.3.0.37-rc9/security/selinux/hooks.c 2011-02-17 02:17:52.000000000 +0100
26542 #include <linux/dccp.h>
26543 #include <linux/quota.h>
26544 #include <linux/un.h> /* for Unix socket types */
26545 -#include <net/af_unix.h> /* for Unix socket types */
26546 #include <linux/parser.h>
26547 #include <linux/nfs_mount.h>
26548 #include <net/ipv6.h>