1 diff -NurpP --minimal linux-2.6.38.3/Documentation/vserver/debug.txt linux-2.6.38.3-vs2.3.0.37-rc14/Documentation/vserver/debug.txt
2 --- linux-2.6.38.3/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/alpha/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/alpha/Kconfig
160 --- linux-2.6.38.3/arch/alpha/Kconfig 2011-03-15 18:06:23.000000000 +0100
161 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/alpha/kernel/entry.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/alpha/kernel/entry.S
172 --- linux-2.6.38.3/arch/alpha/kernel/entry.S 2010-10-21 13:06:45.000000000 +0200
173 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/alpha/kernel/ptrace.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/alpha/kernel/ptrace.c
207 --- linux-2.6.38.3/arch/alpha/kernel/ptrace.c 2011-01-05 21:48:40.000000000 +0100
208 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/alpha/kernel/systbls.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/alpha/kernel/systbls.S
218 --- linux-2.6.38.3/arch/alpha/kernel/systbls.S 2010-10-21 13:06:46.000000000 +0200
219 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/alpha/kernel/traps.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/alpha/kernel/traps.c
230 --- linux-2.6.38.3/arch/alpha/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
231 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/arm/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/arm/Kconfig
243 --- linux-2.6.38.3/arch/arm/Kconfig 2011-03-15 18:06:23.000000000 +0100
244 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/arm/kernel/calls.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/arm/kernel/calls.S
255 --- linux-2.6.38.3/arch/arm/kernel/calls.S 2010-10-21 13:06:46.000000000 +0200
256 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/arm/kernel/process.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/arm/kernel/process.c
267 --- linux-2.6.38.3/arch/arm/kernel/process.c 2011-03-15 18:06:25.000000000 +0100
268 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/arm/kernel/traps.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/arm/kernel/traps.c
280 --- linux-2.6.38.3/arch/arm/kernel/traps.c 2011-03-15 18:06:25.000000000 +0100
281 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/cris/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/cris/Kconfig
294 --- linux-2.6.38.3/arch/cris/Kconfig 2011-03-15 18:06:38.000000000 +0100
295 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/frv/kernel/kernel_thread.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/frv/kernel/kernel_thread.S
306 --- linux-2.6.38.3/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
307 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/h8300/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/h8300/Kconfig
318 --- linux-2.6.38.3/arch/h8300/Kconfig 2011-03-15 18:06:38.000000000 +0100
319 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/ia64/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/ia64/Kconfig
330 --- linux-2.6.38.3/arch/ia64/Kconfig 2011-03-15 18:06:38.000000000 +0100
331 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/ia64/include/asm/tlb.h linux-2.6.38.3-vs2.3.0.37-rc14/arch/ia64/include/asm/tlb.h
342 --- linux-2.6.38.3/arch/ia64/include/asm/tlb.h 2010-02-25 11:51:26.000000000 +0100
343 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/ia64/kernel/entry.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/ia64/kernel/entry.S
353 --- linux-2.6.38.3/arch/ia64/kernel/entry.S 2010-10-21 13:06:52.000000000 +0200
354 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/ia64/kernel/perfmon.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/ia64/kernel/perfmon.c
365 --- linux-2.6.38.3/arch/ia64/kernel/perfmon.c 2011-03-15 18:06:39.000000000 +0100
366 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/ia64/kernel/process.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/ia64/kernel/process.c
376 --- linux-2.6.38.3/arch/ia64/kernel/process.c 2011-03-15 18:06:39.000000000 +0100
377 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/ia64/kernel/ptrace.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/ia64/kernel/ptrace.c
390 --- linux-2.6.38.3/arch/ia64/kernel/ptrace.c 2011-01-05 21:48:59.000000000 +0100
391 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/ia64/kernel/traps.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/ia64/kernel/traps.c
401 --- linux-2.6.38.3/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
402 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/ia64/mm/fault.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/ia64/mm/fault.c
428 --- linux-2.6.38.3/arch/ia64/mm/fault.c 2010-08-02 16:52:04.000000000 +0200
429 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/m32r/kernel/traps.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/m32r/kernel/traps.c
439 --- linux-2.6.38.3/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
440 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/m68k/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/m68k/Kconfig
454 --- linux-2.6.38.3/arch/m68k/Kconfig 2011-01-05 21:49:00.000000000 +0100
455 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/m68k/kernel/ptrace.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/m68k/kernel/ptrace.c
466 --- linux-2.6.38.3/arch/m68k/kernel/ptrace.c 2011-01-05 21:49:01.000000000 +0100
467 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/m68k/kernel/traps.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/m68k/kernel/traps.c
486 --- linux-2.6.38.3/arch/m68k/kernel/traps.c 2010-08-02 16:52:04.000000000 +0200
487 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/m68knommu/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/m68knommu/Kconfig
500 --- linux-2.6.38.3/arch/m68knommu/Kconfig 2011-03-15 18:06:41.000000000 +0100
501 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/m68knommu/kernel/traps.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/m68knommu/kernel/traps.c
512 --- linux-2.6.38.3/arch/m68knommu/kernel/traps.c 2011-01-05 21:49:01.000000000 +0100
513 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/mips/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/mips/Kconfig
527 --- linux-2.6.38.3/arch/mips/Kconfig 2011-03-15 18:06:42.000000000 +0100
528 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/mips/kernel/ptrace.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/mips/kernel/ptrace.c
539 --- linux-2.6.38.3/arch/mips/kernel/ptrace.c 2011-01-05 21:49:06.000000000 +0100
540 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/mips/kernel/scall32-o32.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/mips/kernel/scall32-o32.S
560 --- linux-2.6.38.3/arch/mips/kernel/scall32-o32.S 2010-10-21 13:06:54.000000000 +0200
561 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/mips/kernel/scall64-64.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/mips/kernel/scall64-64.S
572 --- linux-2.6.38.3/arch/mips/kernel/scall64-64.S 2010-10-21 13:06:54.000000000 +0200
573 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/mips/kernel/scall64-n32.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/mips/kernel/scall64-n32.S
584 --- linux-2.6.38.3/arch/mips/kernel/scall64-n32.S 2010-10-21 13:06:54.000000000 +0200
585 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/mips/kernel/scall64-o32.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/mips/kernel/scall64-o32.S
596 --- linux-2.6.38.3/arch/mips/kernel/scall64-o32.S 2010-10-21 13:06:54.000000000 +0200
597 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/mips/kernel/traps.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/mips/kernel/traps.c
608 --- linux-2.6.38.3/arch/mips/kernel/traps.c 2011-03-15 18:06:42.000000000 +0100
609 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/parisc/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/parisc/Kconfig
625 --- linux-2.6.38.3/arch/parisc/Kconfig 2011-03-15 18:06:43.000000000 +0100
626 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/parisc/kernel/syscall_table.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/parisc/kernel/syscall_table.S
637 --- linux-2.6.38.3/arch/parisc/kernel/syscall_table.S 2011-01-05 21:49:09.000000000 +0100
638 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/parisc/kernel/traps.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/parisc/kernel/traps.c
649 --- linux-2.6.38.3/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
650 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/parisc/mm/fault.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/parisc/mm/fault.c
675 --- linux-2.6.38.3/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
676 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/powerpc/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/powerpc/Kconfig
690 --- linux-2.6.38.3/arch/powerpc/Kconfig 2011-03-15 18:06:43.000000000 +0100
691 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/powerpc/include/asm/unistd.h linux-2.6.38.3-vs2.3.0.37-rc14/arch/powerpc/include/asm/unistd.h
702 --- linux-2.6.38.3/arch/powerpc/include/asm/unistd.h 2011-01-05 21:49:10.000000000 +0100
703 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/powerpc/kernel/process.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/powerpc/kernel/process.c
714 --- linux-2.6.38.3/arch/powerpc/kernel/process.c 2011-03-15 18:06:44.000000000 +0100
715 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/powerpc/kernel/traps.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/powerpc/kernel/traps.c
729 --- linux-2.6.38.3/arch/powerpc/kernel/traps.c 2011-03-15 18:06:44.000000000 +0100
730 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/powerpc/kernel/vdso.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/powerpc/kernel/vdso.c
744 --- linux-2.6.38.3/arch/powerpc/kernel/vdso.c 2011-01-05 21:49:11.000000000 +0100
745 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/s390/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/s390/Kconfig
755 --- linux-2.6.38.3/arch/s390/Kconfig 2011-03-15 18:06:45.000000000 +0100
756 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/s390/include/asm/tlb.h linux-2.6.38.3-vs2.3.0.37-rc14/arch/s390/include/asm/tlb.h
767 --- linux-2.6.38.3/arch/s390/include/asm/tlb.h 2011-03-15 18:06:45.000000000 +0100
768 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/s390/include/asm/unistd.h linux-2.6.38.3-vs2.3.0.37-rc14/arch/s390/include/asm/unistd.h
779 --- linux-2.6.38.3/arch/s390/include/asm/unistd.h 2010-10-21 13:06:58.000000000 +0200
780 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/s390/kernel/ptrace.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/s390/kernel/ptrace.c
791 --- linux-2.6.38.3/arch/s390/kernel/ptrace.c 2011-03-15 18:06:45.000000000 +0100
792 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/s390/kernel/syscalls.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/s390/kernel/syscalls.S
802 --- linux-2.6.38.3/arch/s390/kernel/syscalls.S 2010-10-21 13:06:58.000000000 +0200
803 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/sh/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/sh/Kconfig
814 --- linux-2.6.38.3/arch/sh/Kconfig 2011-03-15 18:06:46.000000000 +0100
815 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/sh/kernel/irq.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/sh/kernel/irq.c
826 --- linux-2.6.38.3/arch/sh/kernel/irq.c 2011-01-05 21:49:16.000000000 +0100
827 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.38.3-vs2.3.0.37-rc14/arch/sh/kernel/vsyscall/vsyscall.c
837 --- linux-2.6.38.3/arch/sh/kernel/vsyscall/vsyscall.c 2010-07-07 18:31:10.000000000 +0200
838 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/sparc/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/sparc/Kconfig
848 --- linux-2.6.38.3/arch/sparc/Kconfig 2011-03-15 18:06:47.000000000 +0100
849 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/sparc/include/asm/tlb_64.h linux-2.6.38.3-vs2.3.0.37-rc14/arch/sparc/include/asm/tlb_64.h
860 --- linux-2.6.38.3/arch/sparc/include/asm/tlb_64.h 2009-09-10 15:25:45.000000000 +0200
861 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/sparc/include/asm/unistd.h linux-2.6.38.3-vs2.3.0.37-rc14/arch/sparc/include/asm/unistd.h
871 --- linux-2.6.38.3/arch/sparc/include/asm/unistd.h 2010-10-21 13:06:58.000000000 +0200
872 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/sparc/kernel/systbls_32.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/sparc/kernel/systbls_32.S
883 --- linux-2.6.38.3/arch/sparc/kernel/systbls_32.S 2010-10-21 13:06:59.000000000 +0200
884 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/sparc/kernel/systbls_64.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/sparc/kernel/systbls_64.S
895 --- linux-2.6.38.3/arch/sparc/kernel/systbls_64.S 2010-10-21 13:06:59.000000000 +0200
896 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/um/Kconfig.rest linux-2.6.38.3-vs2.3.0.37-rc14/arch/um/Kconfig.rest
916 --- linux-2.6.38.3/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
917 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/um/include/asm/tlb.h linux-2.6.38.3-vs2.3.0.37-rc14/arch/um/include/asm/tlb.h
928 --- linux-2.6.38.3/arch/um/include/asm/tlb.h 2009-09-10 15:25:46.000000000 +0200
929 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/um/include/shared/kern_constants.h linux-2.6.38.3-vs2.3.0.37-rc14/arch/um/include/shared/kern_constants.h
939 --- linux-2.6.38.3/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
940 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/um/include/shared/user_constants.h linux-2.6.38.3-vs2.3.0.37-rc14/arch/um/include/shared/user_constants.h
944 --- linux-2.6.38.3/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
945 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/x86/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/arch/x86/Kconfig
988 --- linux-2.6.38.3/arch/x86/Kconfig 2011-03-15 18:06:48.000000000 +0100
989 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/x86/ia32/ia32entry.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/x86/ia32/ia32entry.S
1000 --- linux-2.6.38.3/arch/x86/ia32/ia32entry.S 2010-10-21 13:06:59.000000000 +0200
1001 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/x86/include/asm/unistd_64.h linux-2.6.38.3-vs2.3.0.37-rc14/arch/x86/include/asm/unistd_64.h
1012 --- linux-2.6.38.3/arch/x86/include/asm/unistd_64.h 2010-10-21 13:06:59.000000000 +0200
1013 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/arch/x86/kernel/syscall_table_32.S linux-2.6.38.3-vs2.3.0.37-rc14/arch/x86/kernel/syscall_table_32.S
1024 --- linux-2.6.38.3/arch/x86/kernel/syscall_table_32.S 2010-10-21 13:07:00.000000000 +0200
1025 +++ linux-2.6.38.3-vs2.3.0.37-rc14/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.3/block/genhd.c linux-2.6.38.3-vs2.3.0.37-rc14/block/genhd.c
1036 --- linux-2.6.38.3/block/genhd.c 2011-03-15 18:06:52.000000000 +0100
1037 +++ linux-2.6.38.3-vs2.3.0.37-rc14/block/genhd.c 2011-04-14 03:36:35.000000000 +0200
1038 @@ -1154,17 +1154,17 @@ static int diskstats_show(struct seq_fil
1039 cpu = part_stat_lock();
1040 part_round_stats(cpu, hd);
1042 - seq_printf(seqf, "%4d %7d %s %lu %lu %llu "
1043 - "%u %lu %lu %llu %u %u %u %u\n",
1044 + seq_printf(seqf, "%4d %7d %s %lu %lu %lu "
1045 + "%u %lu %lu %lu %u %u %u %u\n",
1046 MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
1047 disk_name(gp, hd->partno, buf),
1048 part_stat_read(hd, ios[0]),
1049 part_stat_read(hd, merges[0]),
1050 - (unsigned long long)part_stat_read(hd, sectors[0]),
1051 + part_stat_read(hd, sectors[0]),
1052 jiffies_to_msecs(part_stat_read(hd, ticks[0])),
1053 part_stat_read(hd, ios[1]),
1054 part_stat_read(hd, merges[1]),
1055 - (unsigned long long)part_stat_read(hd, sectors[1]),
1056 + part_stat_read(hd, sectors[1]),
1057 jiffies_to_msecs(part_stat_read(hd, ticks[1])),
1059 jiffies_to_msecs(part_stat_read(hd, io_ticks)),
1060 diff -NurpP --minimal linux-2.6.38.3/drivers/block/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/drivers/block/Kconfig
1061 --- linux-2.6.38.3/drivers/block/Kconfig 2011-03-15 18:06:54.000000000 +0100
1062 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/block/Kconfig 2011-01-29 02:01:07.000000000 +0100
1063 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
1065 source "drivers/block/drbd/Kconfig"
1067 +config BLK_DEV_VROOT
1068 + tristate "Virtual Root device support"
1069 + depends on QUOTACTL
1071 + Saying Y here will allow you to use quota/fs ioctls on a shared
1072 + partition within a virtual server without compromising security.
1075 tristate "Network block device support"
1077 diff -NurpP --minimal linux-2.6.38.3/drivers/block/Makefile linux-2.6.38.3-vs2.3.0.37-rc14/drivers/block/Makefile
1078 --- linux-2.6.38.3/drivers/block/Makefile 2011-03-15 18:06:54.000000000 +0100
1079 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/block/Makefile 2011-02-17 02:17:45.000000000 +0100
1080 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1081 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1082 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1083 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1084 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1086 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1087 obj-$(CONFIG_BLK_DEV_DRBD) += drbd/
1088 diff -NurpP --minimal linux-2.6.38.3/drivers/block/loop.c linux-2.6.38.3-vs2.3.0.37-rc14/drivers/block/loop.c
1089 --- linux-2.6.38.3/drivers/block/loop.c 2011-03-15 18:06:54.000000000 +0100
1090 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/block/loop.c 2011-03-10 17:21:19.000000000 +0100
1092 #include <linux/kthread.h>
1093 #include <linux/splice.h>
1094 #include <linux/sysfs.h>
1095 +#include <linux/vs_context.h>
1097 #include <asm/uaccess.h>
1099 @@ -902,6 +903,7 @@ static int loop_set_fd(struct loop_devic
1100 lo->lo_blocksize = lo_blocksize;
1101 lo->lo_device = bdev;
1102 lo->lo_flags = lo_flags;
1103 + lo->lo_xid = vx_current_xid();
1104 lo->lo_backing_file = file;
1105 lo->transfer = transfer_none;
1107 @@ -1032,6 +1034,7 @@ static int loop_clr_fd(struct loop_devic
1108 lo->lo_encrypt_key_size = 0;
1110 lo->lo_thread = NULL;
1112 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1113 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1114 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1115 @@ -1070,7 +1073,7 @@ loop_set_status(struct loop_device *lo,
1117 if (lo->lo_encrypt_key_size &&
1118 lo->lo_key_owner != uid &&
1119 - !capable(CAP_SYS_ADMIN))
1120 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1122 if (lo->lo_state != Lo_bound)
1124 @@ -1154,7 +1157,8 @@ loop_get_status(struct loop_device *lo,
1125 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1126 info->lo_encrypt_type =
1127 lo->lo_encryption ? lo->lo_encryption->number : 0;
1128 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1129 + if (lo->lo_encrypt_key_size &&
1130 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1131 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1132 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1133 lo->lo_encrypt_key_size);
1134 @@ -1500,6 +1504,9 @@ static int lo_open(struct block_device *
1136 struct loop_device *lo = bdev->bd_disk->private_data;
1138 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1141 mutex_lock(&lo->lo_ctl_mutex);
1143 mutex_unlock(&lo->lo_ctl_mutex);
1144 diff -NurpP --minimal linux-2.6.38.3/drivers/block/vroot.c linux-2.6.38.3-vs2.3.0.37-rc14/drivers/block/vroot.c
1145 --- linux-2.6.38.3/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1146 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/block/vroot.c 2011-03-17 18:14:05.000000000 +0100
1149 + * linux/drivers/block/vroot.c
1151 + * written by Herbert Pötzl, 9/11/2002
1152 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1154 + * based on the loop.c code by Theodore Ts'o.
1156 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1157 + * Redistribution of this file is permitted under the
1158 + * GNU General Public License.
1162 +#include <linux/module.h>
1163 +#include <linux/moduleparam.h>
1164 +#include <linux/file.h>
1165 +#include <linux/major.h>
1166 +#include <linux/blkdev.h>
1167 +#include <linux/slab.h>
1169 +#include <linux/vroot.h>
1170 +#include <linux/vs_context.h>
1173 +static int max_vroot = 8;
1175 +static struct vroot_device *vroot_dev;
1176 +static struct gendisk **disks;
1179 +static int vroot_set_dev(
1180 + struct vroot_device *vr,
1181 + struct block_device *bdev,
1184 + struct block_device *real_bdev;
1185 + struct file *file;
1186 + struct inode *inode;
1190 + if (vr->vr_state != Vr_unbound)
1199 + inode = file->f_dentry->d_inode;
1202 + if (S_ISBLK(inode->i_mode)) {
1203 + real_bdev = inode->i_bdev;
1204 + vr->vr_device = real_bdev;
1205 + __iget(real_bdev->bd_inode);
1209 + vxdprintk(VXD_CBIT(misc, 0),
1210 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1211 + vr->vr_number, VXD_DEV(real_bdev));
1213 + vr->vr_state = Vr_bound;
1222 +static int vroot_clr_dev(
1223 + struct vroot_device *vr,
1224 + struct block_device *bdev)
1226 + struct block_device *real_bdev;
1228 + if (vr->vr_state != Vr_bound)
1230 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1233 + real_bdev = vr->vr_device;
1235 + vxdprintk(VXD_CBIT(misc, 0),
1236 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1237 + vr->vr_number, VXD_DEV(real_bdev));
1240 + vr->vr_state = Vr_unbound;
1241 + vr->vr_device = NULL;
1246 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1247 + unsigned int cmd, unsigned long arg)
1249 + struct vroot_device *vr = bdev->bd_disk->private_data;
1252 + down(&vr->vr_ctl_mutex);
1254 + case VROOT_SET_DEV:
1255 + err = vroot_set_dev(vr, bdev, arg);
1257 + case VROOT_CLR_DEV:
1258 + err = vroot_clr_dev(vr, bdev);
1264 + up(&vr->vr_ctl_mutex);
1268 +static int vr_open(struct block_device *bdev, fmode_t mode)
1270 + struct vroot_device *vr = bdev->bd_disk->private_data;
1272 + down(&vr->vr_ctl_mutex);
1274 + up(&vr->vr_ctl_mutex);
1278 +static int vr_release(struct gendisk *disk, fmode_t mode)
1280 + struct vroot_device *vr = disk->private_data;
1282 + down(&vr->vr_ctl_mutex);
1284 + up(&vr->vr_ctl_mutex);
1288 +static struct block_device_operations vr_fops = {
1289 + .owner = THIS_MODULE,
1291 + .release = vr_release,
1292 + .ioctl = vr_ioctl,
1295 +static int vroot_make_request(struct request_queue *q, struct bio *bio)
1297 + printk("vroot_make_request %p, %p\n", q, bio);
1298 + bio_io_error(bio);
1302 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1304 + struct inode *inode = bdev->bd_inode;
1305 + struct vroot_device *vr;
1306 + struct block_device *real_bdev;
1307 + int minor = iminor(inode);
1309 + vr = &vroot_dev[minor];
1310 + real_bdev = vr->vr_device;
1312 + vxdprintk(VXD_CBIT(misc, 0),
1313 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1314 + vr->vr_number, VXD_DEV(real_bdev));
1316 + if (vr->vr_state != Vr_bound)
1317 + return ERR_PTR(-ENXIO);
1319 + __iget(real_bdev->bd_inode);
1326 + * And now the modules code and kernel interface.
1329 +module_param(max_vroot, int, 0);
1331 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1332 +MODULE_LICENSE("GPL");
1333 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1335 +MODULE_AUTHOR ("Herbert Pötzl");
1336 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1339 +int __init vroot_init(void)
1343 + if (max_vroot < 1 || max_vroot > 256) {
1344 + max_vroot = MAX_VROOT_DEFAULT;
1345 + printk(KERN_WARNING "vroot: invalid max_vroot "
1346 + "(must be between 1 and 256), "
1347 + "using default (%d)\n", max_vroot);
1350 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1354 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1357 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1359 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1363 + for (i = 0; i < max_vroot; i++) {
1364 + disks[i] = alloc_disk(1);
1367 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1368 + if (!disks[i]->queue)
1370 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1373 + for (i = 0; i < max_vroot; i++) {
1374 + struct vroot_device *vr = &vroot_dev[i];
1375 + struct gendisk *disk = disks[i];
1377 + memset(vr, 0, sizeof(*vr));
1378 + sema_init(&vr->vr_ctl_mutex, 1);
1379 + vr->vr_number = i;
1380 + disk->major = VROOT_MAJOR;
1381 + disk->first_minor = i;
1382 + disk->fops = &vr_fops;
1383 + sprintf(disk->disk_name, "vroot%d", i);
1384 + disk->private_data = vr;
1387 + err = register_vroot_grb(&__vroot_get_real_bdev);
1391 + for (i = 0; i < max_vroot; i++)
1392 + add_disk(disks[i]);
1393 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1398 + put_disk(disks[i]);
1403 + unregister_blkdev(VROOT_MAJOR, "vroot");
1404 + printk(KERN_ERR "vroot: ran out of memory\n");
1408 +void vroot_exit(void)
1412 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1413 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1415 + for (i = 0; i < max_vroot; i++) {
1416 + del_gendisk(disks[i]);
1417 + put_disk(disks[i]);
1419 + unregister_blkdev(VROOT_MAJOR, "vroot");
1425 +module_init(vroot_init);
1426 +module_exit(vroot_exit);
1430 +static int __init max_vroot_setup(char *str)
1432 + max_vroot = simple_strtol(str, NULL, 0);
1436 +__setup("max_vroot=", max_vroot_setup);
1440 diff -NurpP --minimal linux-2.6.38.3/drivers/gpu/drm/radeon/r100_reg_safe.h linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/r100_reg_safe.h
1441 --- linux-2.6.38.3/drivers/gpu/drm/radeon/r100_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1442 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/r100_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1444 +static const unsigned r100_reg_safe_bm[102] = {
1445 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1446 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1447 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1448 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1449 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1450 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1451 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1452 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1453 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1454 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1455 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1456 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1457 + 0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1458 + 0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1459 + 0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
1460 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1461 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
1462 + 0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
1463 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1464 + 0xFFFFFFFF, 0xFFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1465 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1466 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1467 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1468 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1469 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1470 + 0xFFFFFFFF, 0xFFFFFFEF,
1472 diff -NurpP --minimal linux-2.6.38.3/drivers/gpu/drm/radeon/r200_reg_safe.h linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/r200_reg_safe.h
1473 --- linux-2.6.38.3/drivers/gpu/drm/radeon/r200_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1474 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/r200_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1476 +static const unsigned r200_reg_safe_bm[102] = {
1477 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1478 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1479 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1480 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1481 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1482 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1483 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1484 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1485 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1486 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1487 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1488 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1489 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1490 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1491 + 0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
1492 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1493 + 0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
1494 + 0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
1495 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1496 + 0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1497 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1498 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1499 + 0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
1500 + 0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
1501 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1502 + 0xFFFFFE3F, 0xFFFFFFEF,
1504 diff -NurpP --minimal linux-2.6.38.3/drivers/gpu/drm/radeon/r300_reg_safe.h linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/r300_reg_safe.h
1505 --- linux-2.6.38.3/drivers/gpu/drm/radeon/r300_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1506 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/r300_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1508 +static const unsigned r300_reg_safe_bm[159] = {
1509 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1510 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1511 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1512 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1513 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1514 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1515 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1516 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1517 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1518 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1519 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1520 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1521 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1522 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1523 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1524 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1525 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1526 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1527 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1528 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1529 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
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 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1536 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1537 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1538 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1539 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1540 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1541 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1542 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1543 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1544 + 0x00000000, 0x0000C100, 0x00000000, 0x00000000,
1545 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1546 + 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
1547 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1548 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1550 diff -NurpP --minimal linux-2.6.38.3/drivers/gpu/drm/radeon/r420_reg_safe.h linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/r420_reg_safe.h
1551 --- linux-2.6.38.3/drivers/gpu/drm/radeon/r420_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1552 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/r420_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1554 +static const unsigned r420_reg_safe_bm[159] = {
1555 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1556 + 0xFFFFFFFF, 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 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1563 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1564 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1565 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1566 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1567 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1568 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1569 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1570 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1571 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1572 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1573 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1574 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1575 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1576 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1577 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1578 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1579 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1580 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1581 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1582 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1583 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1584 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1585 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1586 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1587 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1588 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1589 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1590 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1591 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1592 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1593 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1594 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1596 diff -NurpP --minimal linux-2.6.38.3/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/rn50_reg_safe.h
1597 --- linux-2.6.38.3/drivers/gpu/drm/radeon/rn50_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1598 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/rn50_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1600 +static const unsigned rn50_reg_safe_bm[102] = {
1601 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1602 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1603 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1604 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1605 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1606 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1607 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1608 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1609 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1610 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1611 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1612 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 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 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1619 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1620 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1621 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1622 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1623 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1624 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1625 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1626 + 0xFFFFFFFF, 0xFFFFFFFF,
1628 diff -NurpP --minimal linux-2.6.38.3/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/rs600_reg_safe.h
1629 --- linux-2.6.38.3/drivers/gpu/drm/radeon/rs600_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1630 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/rs600_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1632 +static const unsigned rs600_reg_safe_bm[219] = {
1633 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1634 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1635 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1636 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1637 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1638 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1639 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1640 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1641 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1642 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1643 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1644 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1645 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1646 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1647 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1648 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1649 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1650 + 0xF0000078, 0xFF000009, 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 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1660 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1661 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1662 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1663 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1664 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1665 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1666 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1667 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1668 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1669 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1670 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1671 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1672 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
1673 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1674 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1675 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1676 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1677 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1678 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1679 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1680 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1681 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1682 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1683 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1684 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1685 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1686 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1687 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1689 diff -NurpP --minimal linux-2.6.38.3/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/rv515_reg_safe.h
1690 --- linux-2.6.38.3/drivers/gpu/drm/radeon/rv515_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1691 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/gpu/drm/radeon/rv515_reg_safe.h 2011-01-29 02:01:07.000000000 +0100
1693 +static const unsigned rv515_reg_safe_bm[219] = {
1694 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1695 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1696 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1697 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1698 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1699 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1700 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1701 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1702 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1703 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1704 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1705 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1706 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1707 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1708 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1709 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1710 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1711 + 0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1712 + 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 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 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1721 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1722 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1723 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1724 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1725 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1726 + 0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
1727 + 0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
1728 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1729 + 0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
1730 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1731 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
1732 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1733 + 0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
1734 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1735 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1736 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1737 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1738 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1739 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1740 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1741 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1742 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1743 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1744 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1745 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1746 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1747 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1748 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1750 diff -NurpP --minimal linux-2.6.38.3/drivers/infiniband/core/addr.c linux-2.6.38.3-vs2.3.0.37-rc14/drivers/infiniband/core/addr.c
1751 --- linux-2.6.38.3/drivers/infiniband/core/addr.c 2011-03-15 18:06:57.000000000 +0100
1752 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/infiniband/core/addr.c 2011-01-29 02:01:07.000000000 +0100
1753 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
1755 if (ipv6_addr_any(&fl.fl6_src)) {
1756 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1757 - &fl.fl6_dst, 0, &fl.fl6_src);
1758 + &fl.fl6_dst, 0, &fl.fl6_src, NULL);
1762 diff -NurpP --minimal linux-2.6.38.3/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.38.3-vs2.3.0.37-rc14/drivers/infiniband/hw/ipath/ipath_user_pages.c
1763 --- linux-2.6.38.3/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-03-15 18:06:58.000000000 +0100
1764 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-01-29 02:01:07.000000000 +0100
1766 #include <linux/device.h>
1767 #include <linux/slab.h>
1768 #include <linux/sched.h>
1769 +#include <linux/vs_memory.h>
1771 #include "ipath_kernel.h"
1773 diff -NurpP --minimal linux-2.6.38.3/drivers/md/dm-ioctl.c linux-2.6.38.3-vs2.3.0.37-rc14/drivers/md/dm-ioctl.c
1774 --- linux-2.6.38.3/drivers/md/dm-ioctl.c 2011-03-15 18:07:02.000000000 +0100
1775 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/md/dm-ioctl.c 2011-01-29 02:01:07.000000000 +0100
1777 #include <linux/dm-ioctl.h>
1778 #include <linux/hdreg.h>
1779 #include <linux/compat.h>
1780 +#include <linux/vs_context.h>
1782 #include <asm/uaccess.h>
1784 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1785 unsigned int h = hash_str(str);
1787 list_for_each_entry (hc, _name_buckets + h, name_list)
1788 - if (!strcmp(hc->name, str)) {
1789 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1790 + !strcmp(hc->name, str)) {
1794 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1795 unsigned int h = hash_str(str);
1797 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1798 - if (!strcmp(hc->uuid, str)) {
1799 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1800 + !strcmp(hc->uuid, str)) {
1804 @@ -427,6 +430,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1806 static int remove_all(struct dm_ioctl *param, size_t param_size)
1808 + if (!vx_check(0, VS_ADMIN))
1811 dm_hash_remove_all(1);
1812 param->data_size = 0;
1814 @@ -474,6 +480,8 @@ static int list_devices(struct dm_ioctl
1816 for (i = 0; i < NUM_BUCKETS; i++) {
1817 list_for_each_entry (hc, _name_buckets + i, name_list) {
1818 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1820 needed += sizeof(struct dm_name_list);
1821 needed += strlen(hc->name) + 1;
1822 needed += ALIGN_MASK;
1823 @@ -497,6 +505,8 @@ static int list_devices(struct dm_ioctl
1825 for (i = 0; i < NUM_BUCKETS; i++) {
1826 list_for_each_entry (hc, _name_buckets + i, name_list) {
1827 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1830 old_nl->next = (uint32_t) ((void *) nl -
1832 @@ -731,10 +741,11 @@ static struct hash_cell *__find_device_h
1836 - mdptr = dm_get_mdptr(md);
1837 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1838 + mdptr = dm_get_mdptr(md);
1846 @@ -1566,8 +1577,8 @@ static int ctl_ioctl(uint command, struc
1850 - /* only root can play with this */
1851 - if (!capable(CAP_SYS_ADMIN))
1852 + /* only root and certain contexts can play with this */
1853 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1856 if (_IOC_TYPE(command) != DM_IOCTL)
1857 diff -NurpP --minimal linux-2.6.38.3/drivers/md/dm.c linux-2.6.38.3-vs2.3.0.37-rc14/drivers/md/dm.c
1858 --- linux-2.6.38.3/drivers/md/dm.c 2011-03-15 18:07:02.000000000 +0100
1859 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/md/dm.c 2011-01-29 03:26:19.000000000 +0100
1861 #include <linux/idr.h>
1862 #include <linux/hdreg.h>
1863 #include <linux/delay.h>
1864 +#include <linux/vs_base.h>
1866 #include <trace/events/block.h>
1868 @@ -119,6 +120,7 @@ struct mapped_device {
1871 atomic_t open_count;
1874 unsigned long flags;
1876 @@ -326,6 +328,7 @@ int dm_deleting_md(struct mapped_device
1877 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1879 struct mapped_device *md;
1882 spin_lock(&_minor_lock);
1884 @@ -334,18 +337,19 @@ static int dm_blk_open(struct block_devi
1887 if (test_bit(DMF_FREEING, &md->flags) ||
1888 - dm_deleting_md(md)) {
1890 + dm_deleting_md(md))
1894 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1899 atomic_inc(&md->open_count);
1903 spin_unlock(&_minor_lock);
1905 - return md ? 0 : -ENXIO;
1909 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1910 @@ -565,6 +569,14 @@ int dm_set_geometry(struct mapped_device
1915 + * Get the xid associated with a dm device
1917 +xid_t dm_get_xid(struct mapped_device *md)
1922 /*-----------------------------------------------------------------
1924 * A more elegant soln is in the works that uses the queue
1925 @@ -1860,6 +1872,7 @@ static struct mapped_device *alloc_dev(i
1926 INIT_LIST_HEAD(&md->uevent_list);
1927 spin_lock_init(&md->uevent_lock);
1929 + md->xid = vx_current_xid();
1930 md->queue = blk_alloc_queue(GFP_KERNEL);
1933 diff -NurpP --minimal linux-2.6.38.3/drivers/md/dm.h linux-2.6.38.3-vs2.3.0.37-rc14/drivers/md/dm.h
1934 --- linux-2.6.38.3/drivers/md/dm.h 2010-10-21 13:07:07.000000000 +0200
1935 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/md/dm.h 2011-01-29 02:01:07.000000000 +0100
1936 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1938 struct dm_md_mempools;
1940 +xid_t dm_get_xid(struct mapped_device *md);
1942 /*-----------------------------------------------------------------
1943 * Internal table functions.
1944 *---------------------------------------------------------------*/
1945 diff -NurpP --minimal linux-2.6.38.3/drivers/net/tun.c linux-2.6.38.3-vs2.3.0.37-rc14/drivers/net/tun.c
1946 --- linux-2.6.38.3/drivers/net/tun.c 2011-03-15 18:07:12.000000000 +0100
1947 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/net/tun.c 2011-01-29 02:01:07.000000000 +0100
1949 #include <linux/nsproxy.h>
1950 #include <linux/virtio_net.h>
1951 #include <linux/rcupdate.h>
1952 +#include <linux/vs_network.h>
1953 #include <net/net_namespace.h>
1954 #include <net/netns/generic.h>
1955 #include <net/rtnetlink.h>
1956 @@ -103,6 +104,7 @@ struct tun_struct {
1962 struct net_device *dev;
1963 struct fasync_struct *fasync;
1964 @@ -853,6 +855,7 @@ static void tun_setup(struct net_device
1968 + tun->nid = current->nid;
1970 dev->ethtool_ops = &tun_ethtool_ops;
1971 dev->destructor = tun_free_netdev;
1972 @@ -1003,7 +1006,7 @@ static int tun_set_iff(struct net *net,
1974 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1975 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1976 - !capable(CAP_NET_ADMIN))
1977 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1979 err = security_tun_dev_attach(tun->socket.sk);
1981 @@ -1017,7 +1020,7 @@ static int tun_set_iff(struct net *net,
1983 unsigned long flags = 0;
1985 - if (!capable(CAP_NET_ADMIN))
1986 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1988 err = security_tun_dev_create();
1990 @@ -1087,6 +1090,9 @@ static int tun_set_iff(struct net *net,
1992 sk->sk_destruct = tun_sock_destruct;
1994 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1997 err = tun_attach(tun, file);
2000 @@ -1278,6 +1284,16 @@ static long __tun_chr_ioctl(struct file
2001 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
2005 + if (!capable(CAP_CONTEXT))
2008 + /* Set nid owner of the device */
2009 + tun->nid = (nid_t) arg;
2011 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
2015 /* Only allow setting the type when the interface is down */
2016 if (tun->dev->flags & IFF_UP) {
2017 diff -NurpP --minimal linux-2.6.38.3/drivers/tty/sysrq.c linux-2.6.38.3-vs2.3.0.37-rc14/drivers/tty/sysrq.c
2018 --- linux-2.6.38.3/drivers/tty/sysrq.c 2011-03-15 18:07:26.000000000 +0100
2019 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/tty/sysrq.c 2011-02-17 02:17:49.000000000 +0100
2021 #include <linux/oom.h>
2022 #include <linux/slab.h>
2023 #include <linux/input.h>
2024 +#include <linux/vserver/debug.h>
2026 #include <asm/ptrace.h>
2027 #include <asm/irq_regs.h>
2028 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
2029 .enable_mask = SYSRQ_ENABLE_RTNICE,
2033 +#ifdef CONFIG_VSERVER_DEBUG
2034 +static void sysrq_handle_vxinfo(int key)
2036 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
2039 +static struct sysrq_key_op sysrq_showvxinfo_op = {
2040 + .handler = sysrq_handle_vxinfo,
2041 + .help_msg = "conteXt",
2042 + .action_msg = "Show Context Info",
2043 + .enable_mask = SYSRQ_ENABLE_DUMP,
2047 /* Key Operations table and lock */
2048 static DEFINE_SPINLOCK(sysrq_key_table_lock);
2050 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
2052 &sysrq_showstate_blocked_op, /* w */
2053 /* x: May be registered on ppc/powerpc for xmon */
2054 +#ifdef CONFIG_VSERVER_DEBUG
2055 + &sysrq_showvxinfo_op, /* x */
2059 /* y: May be registered on sparc64 for global register dump */
2061 &sysrq_ftrace_dump_op, /* z */
2062 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
2064 else if ((key >= 'a') && (key <= 'z'))
2065 retval = key + 10 - 'a';
2066 + else if ((key >= 'A') && (key <= 'Z'))
2067 + retval = key + 10 - 'A';
2071 diff -NurpP --minimal linux-2.6.38.3/drivers/tty/tty_io.c linux-2.6.38.3-vs2.3.0.37-rc14/drivers/tty/tty_io.c
2072 --- linux-2.6.38.3/drivers/tty/tty_io.c 2011-03-15 18:07:26.000000000 +0100
2073 +++ linux-2.6.38.3-vs2.3.0.37-rc14/drivers/tty/tty_io.c 2011-02-02 22:20:24.000000000 +0100
2076 #include <linux/kmod.h>
2077 #include <linux/nsproxy.h>
2078 +#include <linux/vs_pid.h>
2080 #undef TTY_DEBUG_HANGUP
2082 @@ -2057,7 +2058,8 @@ static int tiocsti(struct tty_struct *tt
2084 struct tty_ldisc *ld;
2086 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
2087 + if (((current->signal->tty != tty) &&
2088 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
2090 if (get_user(ch, p))
2092 @@ -2345,6 +2347,7 @@ static int tiocspgrp(struct tty_struct *
2094 if (get_user(pgrp_nr, p))
2096 + pgrp_nr = vx_rmap_pid(pgrp_nr);
2100 diff -NurpP --minimal linux-2.6.38.3/fs/attr.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/attr.c
2101 --- linux-2.6.38.3/fs/attr.c 2010-10-21 13:07:47.000000000 +0200
2102 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/attr.c 2011-01-29 02:01:07.000000000 +0100
2104 #include <linux/fsnotify.h>
2105 #include <linux/fcntl.h>
2106 #include <linux/security.h>
2107 +#include <linux/proc_fs.h>
2108 +#include <linux/devpts_fs.h>
2109 +#include <linux/vs_tag.h>
2112 * inode_change_ok - check if attribute changes to an inode are allowed
2113 @@ -73,6 +76,10 @@ int inode_change_ok(const struct inode *
2117 + /* check for inode tag permission */
2118 + if (dx_permission(inode, MAY_WRITE))
2123 EXPORT_SYMBOL(inode_change_ok);
2124 @@ -143,6 +150,8 @@ void setattr_copy(struct inode *inode, c
2125 inode->i_uid = attr->ia_uid;
2126 if (ia_valid & ATTR_GID)
2127 inode->i_gid = attr->ia_gid;
2128 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2129 + inode->i_tag = attr->ia_tag;
2130 if (ia_valid & ATTR_ATIME)
2131 inode->i_atime = timespec_trunc(attr->ia_atime,
2132 inode->i_sb->s_time_gran);
2133 @@ -170,7 +179,8 @@ int notify_change(struct dentry * dentry
2134 struct timespec now;
2135 unsigned int ia_valid = attr->ia_valid;
2137 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
2138 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
2139 + ATTR_TAG | ATTR_TIMES_SET)) {
2140 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
2143 diff -NurpP --minimal linux-2.6.38.3/fs/binfmt_aout.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/binfmt_aout.c
2144 --- linux-2.6.38.3/fs/binfmt_aout.c 2010-10-21 13:07:47.000000000 +0200
2145 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/binfmt_aout.c 2011-01-29 02:01:07.000000000 +0100
2147 #include <linux/init.h>
2148 #include <linux/coredump.h>
2149 #include <linux/slab.h>
2150 +#include <linux/vs_memory.h>
2152 #include <asm/system.h>
2153 #include <asm/uaccess.h>
2154 diff -NurpP --minimal linux-2.6.38.3/fs/binfmt_elf.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/binfmt_elf.c
2155 --- linux-2.6.38.3/fs/binfmt_elf.c 2011-03-15 18:07:31.000000000 +0100
2156 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/binfmt_elf.c 2011-01-29 02:01:07.000000000 +0100
2158 #include <linux/elf.h>
2159 #include <linux/utsname.h>
2160 #include <linux/coredump.h>
2161 +#include <linux/vs_memory.h>
2162 #include <asm/uaccess.h>
2163 #include <asm/param.h>
2164 #include <asm/page.h>
2165 diff -NurpP --minimal linux-2.6.38.3/fs/binfmt_flat.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/binfmt_flat.c
2166 --- linux-2.6.38.3/fs/binfmt_flat.c 2010-08-02 16:52:47.000000000 +0200
2167 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/binfmt_flat.c 2011-01-29 02:01:07.000000000 +0100
2169 #include <linux/init.h>
2170 #include <linux/flat.h>
2171 #include <linux/syscalls.h>
2172 +#include <linux/vs_memory.h>
2174 #include <asm/byteorder.h>
2175 #include <asm/system.h>
2176 diff -NurpP --minimal linux-2.6.38.3/fs/binfmt_som.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/binfmt_som.c
2177 --- linux-2.6.38.3/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
2178 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/binfmt_som.c 2011-01-29 02:01:07.000000000 +0100
2180 #include <linux/shm.h>
2181 #include <linux/personality.h>
2182 #include <linux/init.h>
2183 +#include <linux/vs_memory.h>
2185 #include <asm/uaccess.h>
2186 #include <asm/pgtable.h>
2187 diff -NurpP --minimal linux-2.6.38.3/fs/block_dev.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/block_dev.c
2188 --- linux-2.6.38.3/fs/block_dev.c 2011-03-15 18:07:31.000000000 +0100
2189 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/block_dev.c 2011-03-07 16:53:27.000000000 +0100
2191 #include <linux/namei.h>
2192 #include <linux/log2.h>
2193 #include <linux/kmemleak.h>
2194 +#include <linux/vs_device.h>
2195 #include <asm/uaccess.h>
2196 #include "internal.h"
2198 @@ -551,6 +552,7 @@ struct block_device *bdget(dev_t dev)
2199 bdev->bd_invalidated = 0;
2200 inode->i_mode = S_IFBLK;
2201 inode->i_rdev = dev;
2202 + inode->i_mdev = dev;
2203 inode->i_bdev = bdev;
2204 inode->i_data.a_ops = &def_blk_aops;
2205 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2206 @@ -597,6 +599,11 @@ EXPORT_SYMBOL(bdput);
2207 static struct block_device *bd_acquire(struct inode *inode)
2209 struct block_device *bdev;
2212 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2214 + inode->i_mdev = mdev;
2216 spin_lock(&bdev_lock);
2217 bdev = inode->i_bdev;
2218 @@ -607,7 +614,7 @@ static struct block_device *bd_acquire(s
2220 spin_unlock(&bdev_lock);
2222 - bdev = bdget(inode->i_rdev);
2223 + bdev = bdget(mdev);
2225 spin_lock(&bdev_lock);
2226 if (!inode->i_bdev) {
2227 diff -NurpP --minimal linux-2.6.38.3/fs/btrfs/ctree.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/btrfs/ctree.h
2228 --- linux-2.6.38.3/fs/btrfs/ctree.h 2011-04-15 10:30:30.000000000 +0200
2229 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/btrfs/ctree.h 2011-04-15 10:33:41.000000000 +0200
2230 @@ -587,11 +587,14 @@ struct btrfs_inode_item {
2231 /* modification sequence number for NFS */
2236 * a little future expansion, for more than this we can
2237 * just grow the inode item and version it
2239 - __le64 reserved[4];
2240 + __le16 reserved16;
2241 + __le32 reserved32;
2242 + __le64 reserved[3];
2243 struct btrfs_timespec atime;
2244 struct btrfs_timespec ctime;
2245 struct btrfs_timespec mtime;
2246 @@ -1265,6 +1268,8 @@ struct btrfs_root {
2247 #define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14)
2248 #define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15)
2250 +#define BTRFS_MOUNT_TAGGED (1 << 24)
2252 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
2253 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
2254 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
2255 @@ -1487,6 +1492,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
2256 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
2257 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
2258 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
2259 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
2260 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
2261 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
2262 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
2263 @@ -1548,6 +1554,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
2265 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
2267 +#define BTRFS_INODE_IXUNLINK (1 << 24)
2268 +#define BTRFS_INODE_BARRIER (1 << 25)
2269 +#define BTRFS_INODE_COW (1 << 26)
2272 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
2274 @@ -2557,6 +2567,7 @@ extern const struct dentry_operations bt
2275 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2276 void btrfs_update_iflags(struct inode *inode);
2277 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2278 +int btrfs_sync_flags(struct inode *inode, int, int);
2281 int btrfs_sync_file(struct file *file, int datasync);
2282 diff -NurpP --minimal linux-2.6.38.3/fs/btrfs/disk-io.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/btrfs/disk-io.c
2283 --- linux-2.6.38.3/fs/btrfs/disk-io.c 2011-04-15 10:30:30.000000000 +0200
2284 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/btrfs/disk-io.c 2011-04-15 10:33:41.000000000 +0200
2285 @@ -1770,6 +1770,9 @@ struct btrfs_root *open_ctree(struct sup
2289 + if (btrfs_test_opt(tree_root, TAGGED))
2290 + sb->s_flags |= MS_TAGGED;
2292 features = btrfs_super_incompat_flags(disk_super) &
2293 ~BTRFS_FEATURE_INCOMPAT_SUPP;
2295 diff -NurpP --minimal linux-2.6.38.3/fs/btrfs/inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/btrfs/inode.c
2296 --- linux-2.6.38.3/fs/btrfs/inode.c 2011-03-15 18:07:31.000000000 +0100
2297 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/btrfs/inode.c 2011-03-15 18:15:06.000000000 +0100
2299 #include <linux/posix_acl.h>
2300 #include <linux/falloc.h>
2301 #include <linux/slab.h>
2302 +#include <linux/vs_tag.h>
2306 #include "disk-io.h"
2307 @@ -2463,6 +2465,8 @@ static void btrfs_read_locked_inode(stru
2309 u64 alloc_group_block;
2315 path = btrfs_alloc_path();
2316 @@ -2479,8 +2483,13 @@ static void btrfs_read_locked_inode(stru
2318 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
2319 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
2320 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
2321 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
2323 + uid = btrfs_inode_uid(leaf, inode_item);
2324 + gid = btrfs_inode_gid(leaf, inode_item);
2325 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2326 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2327 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2328 + btrfs_inode_tag(leaf, inode_item));
2329 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
2331 tspec = btrfs_inode_atime(inode_item);
2332 @@ -2562,8 +2571,15 @@ static void fill_inode_item(struct btrfs
2333 struct btrfs_inode_item *item,
2334 struct inode *inode)
2336 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
2337 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
2338 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2339 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2341 + btrfs_set_inode_uid(leaf, item, uid);
2342 + btrfs_set_inode_gid(leaf, item, gid);
2343 +#ifdef CONFIG_TAGGING_INTERN
2344 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
2347 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
2348 btrfs_set_inode_mode(leaf, item, inode->i_mode);
2349 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
2350 @@ -7293,6 +7309,7 @@ static const struct inode_operations btr
2351 .listxattr = btrfs_listxattr,
2352 .removexattr = btrfs_removexattr,
2353 .permission = btrfs_permission,
2354 + .sync_flags = btrfs_sync_flags,
2356 static const struct inode_operations btrfs_dir_ro_inode_operations = {
2357 .lookup = btrfs_lookup,
2358 @@ -7367,6 +7384,7 @@ static const struct inode_operations btr
2359 .removexattr = btrfs_removexattr,
2360 .permission = btrfs_permission,
2361 .fiemap = btrfs_fiemap,
2362 + .sync_flags = btrfs_sync_flags,
2364 static const struct inode_operations btrfs_special_inode_operations = {
2365 .getattr = btrfs_getattr,
2366 diff -NurpP --minimal linux-2.6.38.3/fs/btrfs/ioctl.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/btrfs/ioctl.c
2367 --- linux-2.6.38.3/fs/btrfs/ioctl.c 2011-04-15 10:30:30.000000000 +0200
2368 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/btrfs/ioctl.c 2011-04-15 10:33:41.000000000 +0200
2369 @@ -68,10 +68,13 @@ static unsigned int btrfs_flags_to_ioctl
2371 unsigned int iflags = 0;
2373 - if (flags & BTRFS_INODE_SYNC)
2374 - iflags |= FS_SYNC_FL;
2375 if (flags & BTRFS_INODE_IMMUTABLE)
2376 iflags |= FS_IMMUTABLE_FL;
2377 + if (flags & BTRFS_INODE_IXUNLINK)
2378 + iflags |= FS_IXUNLINK_FL;
2380 + if (flags & BTRFS_INODE_SYNC)
2381 + iflags |= FS_SYNC_FL;
2382 if (flags & BTRFS_INODE_APPEND)
2383 iflags |= FS_APPEND_FL;
2384 if (flags & BTRFS_INODE_NODUMP)
2385 @@ -81,28 +84,78 @@ static unsigned int btrfs_flags_to_ioctl
2386 if (flags & BTRFS_INODE_DIRSYNC)
2387 iflags |= FS_DIRSYNC_FL;
2389 + if (flags & BTRFS_INODE_BARRIER)
2390 + iflags |= FS_BARRIER_FL;
2391 + if (flags & BTRFS_INODE_COW)
2392 + iflags |= FS_COW_FL;
2397 - * Update inode->i_flags based on the btrfs internal flags.
2398 + * Update inode->i_(v)flags based on the btrfs internal flags.
2400 void btrfs_update_iflags(struct inode *inode)
2402 struct btrfs_inode *ip = BTRFS_I(inode);
2404 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2405 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2406 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2408 - if (ip->flags & BTRFS_INODE_SYNC)
2409 - inode->i_flags |= S_SYNC;
2410 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2411 inode->i_flags |= S_IMMUTABLE;
2412 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2413 + inode->i_flags |= S_IXUNLINK;
2415 + if (ip->flags & BTRFS_INODE_SYNC)
2416 + inode->i_flags |= S_SYNC;
2417 if (ip->flags & BTRFS_INODE_APPEND)
2418 inode->i_flags |= S_APPEND;
2419 if (ip->flags & BTRFS_INODE_NOATIME)
2420 inode->i_flags |= S_NOATIME;
2421 if (ip->flags & BTRFS_INODE_DIRSYNC)
2422 inode->i_flags |= S_DIRSYNC;
2424 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2426 + if (ip->flags & BTRFS_INODE_BARRIER)
2427 + inode->i_vflags |= V_BARRIER;
2428 + if (ip->flags & BTRFS_INODE_COW)
2429 + inode->i_vflags |= V_COW;
2433 + * Update btrfs internal flags from inode->i_(v)flags.
2435 +void btrfs_update_flags(struct inode *inode)
2437 + struct btrfs_inode *ip = BTRFS_I(inode);
2439 + unsigned int flags = inode->i_flags;
2440 + unsigned int vflags = inode->i_vflags;
2442 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2443 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2444 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2445 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2447 + if (flags & S_IMMUTABLE)
2448 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2449 + if (flags & S_IXUNLINK)
2450 + ip->flags |= BTRFS_INODE_IXUNLINK;
2452 + if (flags & S_SYNC)
2453 + ip->flags |= BTRFS_INODE_SYNC;
2454 + if (flags & S_APPEND)
2455 + ip->flags |= BTRFS_INODE_APPEND;
2456 + if (flags & S_NOATIME)
2457 + ip->flags |= BTRFS_INODE_NOATIME;
2458 + if (flags & S_DIRSYNC)
2459 + ip->flags |= BTRFS_INODE_DIRSYNC;
2461 + if (vflags & V_BARRIER)
2462 + ip->flags |= BTRFS_INODE_BARRIER;
2463 + if (vflags & V_COW)
2464 + ip->flags |= BTRFS_INODE_COW;
2468 @@ -120,7 +173,7 @@ void btrfs_inherit_iflags(struct inode *
2469 flags = BTRFS_I(dir)->flags;
2471 if (S_ISREG(inode->i_mode))
2472 - flags &= ~BTRFS_INODE_DIRSYNC;
2473 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2474 else if (!S_ISDIR(inode->i_mode))
2475 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2477 @@ -128,6 +181,30 @@ void btrfs_inherit_iflags(struct inode *
2478 btrfs_update_iflags(inode);
2481 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2483 + struct btrfs_inode *ip = BTRFS_I(inode);
2484 + struct btrfs_root *root = ip->root;
2485 + struct btrfs_trans_handle *trans;
2488 + trans = btrfs_join_transaction(root, 1);
2491 + inode->i_flags = flags;
2492 + inode->i_vflags = vflags;
2493 + btrfs_update_flags(inode);
2495 + ret = btrfs_update_inode(trans, root, inode);
2498 + btrfs_update_iflags(inode);
2499 + inode->i_ctime = CURRENT_TIME;
2500 + btrfs_end_transaction(trans, root);
2505 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2507 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2508 @@ -153,6 +230,7 @@ static int btrfs_ioctl_setflags(struct f
2509 if (copy_from_user(&flags, arg, sizeof(flags)))
2512 + /* maybe add FS_IXUNLINK_FL ? */
2513 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
2514 FS_NOATIME_FL | FS_NODUMP_FL | \
2515 FS_SYNC_FL | FS_DIRSYNC_FL))
2516 @@ -165,7 +243,8 @@ static int btrfs_ioctl_setflags(struct f
2518 flags = btrfs_mask_flags(inode->i_mode, flags);
2519 oldflags = btrfs_flags_to_ioctl(ip->flags);
2520 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2521 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2522 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2523 if (!capable(CAP_LINUX_IMMUTABLE)) {
2526 @@ -176,14 +255,19 @@ static int btrfs_ioctl_setflags(struct f
2530 - if (flags & FS_SYNC_FL)
2531 - ip->flags |= BTRFS_INODE_SYNC;
2533 - ip->flags &= ~BTRFS_INODE_SYNC;
2534 if (flags & FS_IMMUTABLE_FL)
2535 ip->flags |= BTRFS_INODE_IMMUTABLE;
2537 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2538 + if (flags & FS_IXUNLINK_FL)
2539 + ip->flags |= BTRFS_INODE_IXUNLINK;
2541 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2543 + if (flags & FS_SYNC_FL)
2544 + ip->flags |= BTRFS_INODE_SYNC;
2546 + ip->flags &= ~BTRFS_INODE_SYNC;
2547 if (flags & FS_APPEND_FL)
2548 ip->flags |= BTRFS_INODE_APPEND;
2550 diff -NurpP --minimal linux-2.6.38.3/fs/btrfs/super.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/btrfs/super.c
2551 --- linux-2.6.38.3/fs/btrfs/super.c 2011-03-15 18:07:31.000000000 +0100
2552 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/btrfs/super.c 2011-03-07 17:04:18.000000000 +0100
2553 @@ -155,8 +155,8 @@ enum {
2554 Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress,
2555 Opt_compress_type, Opt_compress_force, Opt_compress_force_type,
2556 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
2557 - Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
2558 - Opt_enospc_debug, Opt_err,
2559 + Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
2560 + Opt_enospc_debug, Opt_tag, Opt_notag, Opt_tagid, Opt_err,
2563 static match_table_t tokens = {
2564 @@ -186,6 +186,9 @@ static match_table_t tokens = {
2565 {Opt_clear_cache, "clear_cache"},
2566 {Opt_user_subvol_rm_allowed, "user_subvol_rm_allowed"},
2567 {Opt_enospc_debug, "enospc_debug"},
2569 + {Opt_notag, "notag"},
2570 + {Opt_tagid, "tagid=%u"},
2574 @@ -363,6 +366,22 @@ int btrfs_parse_options(struct btrfs_roo
2575 case Opt_enospc_debug:
2576 btrfs_set_opt(info->mount_opt, ENOSPC_DEBUG);
2578 +#ifndef CONFIG_TAGGING_NONE
2580 + printk(KERN_INFO "btrfs: use tagging\n");
2581 + btrfs_set_opt(info->mount_opt, TAGGED);
2584 + printk(KERN_INFO "btrfs: disabled tagging\n");
2585 + btrfs_clear_opt(info->mount_opt, TAGGED);
2588 +#ifdef CONFIG_PROPAGATE
2591 + btrfs_set_opt(info->mount_opt, TAGGED);
2595 printk(KERN_INFO "btrfs: unrecognized mount option "
2597 @@ -841,6 +860,12 @@ static int btrfs_remount(struct super_bl
2601 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2602 + printk("btrfs: %s: tagging not permitted on remount.\n",
2607 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2610 diff -NurpP --minimal linux-2.6.38.3/fs/char_dev.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/char_dev.c
2611 --- linux-2.6.38.3/fs/char_dev.c 2011-03-15 18:07:31.000000000 +0100
2612 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/char_dev.c 2011-01-29 02:01:07.000000000 +0100
2614 #include <linux/mutex.h>
2615 #include <linux/backing-dev.h>
2616 #include <linux/tty.h>
2617 +#include <linux/vs_context.h>
2618 +#include <linux/vs_device.h>
2620 #include "internal.h"
2622 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2624 struct cdev *new = NULL;
2628 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2630 + inode->i_mdev = mdev;
2632 spin_lock(&cdev_lock);
2635 struct kobject *kobj;
2638 spin_unlock(&cdev_lock);
2639 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2641 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2644 new = container_of(kobj, struct cdev, kobj);
2645 diff -NurpP --minimal linux-2.6.38.3/fs/dcache.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/dcache.c
2646 --- linux-2.6.38.3/fs/dcache.c 2011-04-15 10:30:30.000000000 +0200
2647 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/dcache.c 2011-03-28 15:00:13.000000000 +0200
2649 #include <linux/hardirq.h>
2650 #include <linux/bit_spinlock.h>
2651 #include <linux/rculist_bl.h>
2652 +#include <linux/vs_limit.h>
2653 #include "internal.h"
2656 @@ -500,6 +501,8 @@ int d_invalidate(struct dentry * dentry)
2657 spin_lock(&dentry->d_lock);
2660 + vx_dentry_dec(dentry);
2663 * Somebody else still using it?
2665 @@ -527,6 +530,7 @@ EXPORT_SYMBOL(d_invalidate);
2666 static inline void __dget_dlock(struct dentry *dentry)
2669 + vx_dentry_inc(dentry);
2672 static inline void __dget(struct dentry *dentry)
2673 @@ -1283,6 +1287,9 @@ struct dentry *d_alloc(struct dentry * p
2674 struct dentry *dentry;
2677 + if (!vx_dentry_avail(1))
2680 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2683 @@ -1304,6 +1311,7 @@ struct dentry *d_alloc(struct dentry * p
2684 dname[name->len] = 0;
2686 dentry->d_count = 1;
2687 + vx_dentry_inc(dentry);
2688 dentry->d_flags = DCACHE_UNHASHED;
2689 spin_lock_init(&dentry->d_lock);
2690 seqcount_init(&dentry->d_seq);
2691 @@ -1965,6 +1973,7 @@ struct dentry *__d_lookup(struct dentry
2695 + vx_dentry_inc(dentry);
2697 spin_unlock(&dentry->d_lock);
2699 diff -NurpP --minimal linux-2.6.38.3/fs/devpts/inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/devpts/inode.c
2700 --- linux-2.6.38.3/fs/devpts/inode.c 2011-01-05 21:50:22.000000000 +0100
2701 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/devpts/inode.c 2011-03-17 02:17:19.000000000 +0100
2703 #include <linux/parser.h>
2704 #include <linux/fsnotify.h>
2705 #include <linux/seq_file.h>
2706 +#include <linux/vs_base.h>
2708 #define DEVPTS_DEFAULT_MODE 0600
2711 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2712 #define PTMX_MINOR 2
2714 +static int devpts_permission(struct inode *inode, int mask, unsigned int flags)
2716 + int ret = -EACCES;
2718 + /* devpts is xid tagged */
2719 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2720 + ret = generic_permission(inode, mask, flags, NULL);
2724 +static struct inode_operations devpts_file_inode_operations = {
2725 + .permission = devpts_permission,
2728 extern int pty_limit; /* Config limit on Unix98 ptys */
2729 static DEFINE_MUTEX(allocated_ptys_lock);
2731 @@ -263,6 +278,34 @@ static int devpts_show_options(struct se
2735 +static int devpts_filter(struct dentry *de)
2739 + /* devpts is xid tagged */
2740 + if (de && de->d_inode)
2741 + xid = (xid_t)de->d_inode->i_tag;
2742 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2744 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2745 + de->d_name.len, de->d_name.name);
2747 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2750 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2752 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2755 +static struct file_operations devpts_dir_operations = {
2756 + .open = dcache_dir_open,
2757 + .release = dcache_dir_close,
2758 + .llseek = dcache_dir_lseek,
2759 + .read = generic_read_dir,
2760 + .readdir = devpts_readdir,
2763 static const struct super_operations devpts_sops = {
2764 .statfs = simple_statfs,
2765 .remount_fs = devpts_remount,
2766 @@ -302,12 +345,15 @@ devpts_fill_super(struct super_block *s,
2767 inode = new_inode(s);
2772 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2773 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2774 inode->i_op = &simple_dir_inode_operations;
2775 - inode->i_fop = &simple_dir_operations;
2776 + inode->i_fop = &devpts_dir_operations;
2778 + /* devpts is xid tagged */
2779 + inode->i_tag = (tag_t)vx_current_xid();
2781 s->s_root = d_alloc_root(inode);
2783 @@ -493,6 +539,9 @@ int devpts_pty_new(struct inode *ptmx_in
2784 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2785 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2786 init_special_inode(inode, S_IFCHR|opts->mode, device);
2787 + /* devpts is xid tagged */
2788 + inode->i_tag = (tag_t)vx_current_xid();
2789 + inode->i_op = &devpts_file_inode_operations;
2790 inode->i_private = tty;
2791 tty->driver_data = inode;
2793 diff -NurpP --minimal linux-2.6.38.3/fs/ext2/balloc.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/balloc.c
2794 --- linux-2.6.38.3/fs/ext2/balloc.c 2011-01-05 21:50:22.000000000 +0100
2795 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/balloc.c 2011-01-29 02:01:07.000000000 +0100
2796 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2798 end = EXT2_BLOCKS_PER_GROUP(sb);
2801 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2804 diff -NurpP --minimal linux-2.6.38.3/fs/ext2/ext2.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/ext2.h
2805 --- linux-2.6.38.3/fs/ext2/ext2.h 2011-01-05 21:50:22.000000000 +0100
2806 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/ext2.h 2011-01-29 02:01:07.000000000 +0100
2807 @@ -126,6 +126,7 @@ extern void ext2_set_inode_flags(struct
2808 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2809 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2810 u64 start, u64 len);
2811 +extern int ext2_sync_flags(struct inode *, int, int);
2814 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2815 diff -NurpP --minimal linux-2.6.38.3/fs/ext2/file.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/file.c
2816 --- linux-2.6.38.3/fs/ext2/file.c 2010-08-02 16:52:48.000000000 +0200
2817 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/file.c 2011-01-29 02:01:07.000000000 +0100
2818 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2819 .setattr = ext2_setattr,
2820 .check_acl = ext2_check_acl,
2821 .fiemap = ext2_fiemap,
2822 + .sync_flags = ext2_sync_flags,
2824 diff -NurpP --minimal linux-2.6.38.3/fs/ext2/ialloc.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/ialloc.c
2825 --- linux-2.6.38.3/fs/ext2/ialloc.c 2010-10-21 13:07:48.000000000 +0200
2826 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/ialloc.c 2011-01-29 02:01:07.000000000 +0100
2828 #include <linux/backing-dev.h>
2829 #include <linux/buffer_head.h>
2830 #include <linux/random.h>
2831 +#include <linux/vs_tag.h>
2835 @@ -548,6 +549,7 @@ got:
2836 inode->i_mode = mode;
2837 inode->i_uid = current_fsuid();
2838 inode->i_gid = dir->i_gid;
2839 + inode->i_tag = dx_current_fstag(sb);
2841 inode_init_owner(inode, dir, mode);
2843 diff -NurpP --minimal linux-2.6.38.3/fs/ext2/inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/inode.c
2844 --- linux-2.6.38.3/fs/ext2/inode.c 2011-01-05 21:50:22.000000000 +0100
2845 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/inode.c 2011-01-29 02:01:07.000000000 +0100
2847 #include <linux/mpage.h>
2848 #include <linux/fiemap.h>
2849 #include <linux/namei.h>
2850 +#include <linux/vs_tag.h>
2854 @@ -1169,7 +1170,7 @@ static void ext2_truncate_blocks(struct
2856 if (ext2_inode_is_fast_symlink(inode))
2858 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2859 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2861 __ext2_truncate_blocks(inode, offset);
2863 @@ -1258,36 +1259,61 @@ void ext2_set_inode_flags(struct inode *
2865 unsigned int flags = EXT2_I(inode)->i_flags;
2867 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2868 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2869 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2872 + if (flags & EXT2_IMMUTABLE_FL)
2873 + inode->i_flags |= S_IMMUTABLE;
2874 + if (flags & EXT2_IXUNLINK_FL)
2875 + inode->i_flags |= S_IXUNLINK;
2877 if (flags & EXT2_SYNC_FL)
2878 inode->i_flags |= S_SYNC;
2879 if (flags & EXT2_APPEND_FL)
2880 inode->i_flags |= S_APPEND;
2881 - if (flags & EXT2_IMMUTABLE_FL)
2882 - inode->i_flags |= S_IMMUTABLE;
2883 if (flags & EXT2_NOATIME_FL)
2884 inode->i_flags |= S_NOATIME;
2885 if (flags & EXT2_DIRSYNC_FL)
2886 inode->i_flags |= S_DIRSYNC;
2888 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2890 + if (flags & EXT2_BARRIER_FL)
2891 + inode->i_vflags |= V_BARRIER;
2892 + if (flags & EXT2_COW_FL)
2893 + inode->i_vflags |= V_COW;
2896 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2897 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2899 unsigned int flags = ei->vfs_inode.i_flags;
2900 + unsigned int vflags = ei->vfs_inode.i_vflags;
2902 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2903 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2904 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2905 + EXT2_BARRIER_FL | EXT2_COW_FL);
2907 + if (flags & S_IMMUTABLE)
2908 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2909 + if (flags & S_IXUNLINK)
2910 + ei->i_flags |= EXT2_IXUNLINK_FL;
2912 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2913 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2915 ei->i_flags |= EXT2_SYNC_FL;
2916 if (flags & S_APPEND)
2917 ei->i_flags |= EXT2_APPEND_FL;
2918 - if (flags & S_IMMUTABLE)
2919 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2920 if (flags & S_NOATIME)
2921 ei->i_flags |= EXT2_NOATIME_FL;
2922 if (flags & S_DIRSYNC)
2923 ei->i_flags |= EXT2_DIRSYNC_FL;
2925 + if (vflags & V_BARRIER)
2926 + ei->i_flags |= EXT2_BARRIER_FL;
2927 + if (vflags & V_COW)
2928 + ei->i_flags |= EXT2_COW_FL;
2931 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2932 @@ -1297,6 +1323,8 @@ struct inode *ext2_iget (struct super_bl
2933 struct ext2_inode *raw_inode;
2934 struct inode *inode;
2940 inode = iget_locked(sb, ino);
2941 @@ -1315,12 +1343,17 @@ struct inode *ext2_iget (struct super_bl
2944 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2945 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2946 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2947 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2948 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2949 if (!(test_opt (inode->i_sb, NO_UID32))) {
2950 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2951 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2952 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2953 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2955 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2956 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2957 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2958 + le16_to_cpu(raw_inode->i_raw_tag));
2960 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2961 inode->i_size = le32_to_cpu(raw_inode->i_size);
2962 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2963 @@ -1418,8 +1451,8 @@ static int __ext2_write_inode(struct ino
2964 struct ext2_inode_info *ei = EXT2_I(inode);
2965 struct super_block *sb = inode->i_sb;
2966 ino_t ino = inode->i_ino;
2967 - uid_t uid = inode->i_uid;
2968 - gid_t gid = inode->i_gid;
2969 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2970 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2971 struct buffer_head * bh;
2972 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2974 @@ -1455,6 +1488,9 @@ static int __ext2_write_inode(struct ino
2975 raw_inode->i_uid_high = 0;
2976 raw_inode->i_gid_high = 0;
2978 +#ifdef CONFIG_TAGGING_INTERN
2979 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2981 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2982 raw_inode->i_size = cpu_to_le32(inode->i_size);
2983 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2984 @@ -1535,7 +1571,8 @@ int ext2_setattr(struct dentry *dentry,
2985 if (is_quota_modification(inode, iattr))
2986 dquot_initialize(inode);
2987 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2988 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2989 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2990 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2991 error = dquot_transfer(inode, iattr);
2994 diff -NurpP --minimal linux-2.6.38.3/fs/ext2/ioctl.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/ioctl.c
2995 --- linux-2.6.38.3/fs/ext2/ioctl.c 2009-09-10 15:26:21.000000000 +0200
2996 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/ioctl.c 2011-01-29 02:01:07.000000000 +0100
2998 #include <asm/uaccess.h>
3001 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
3003 + inode->i_flags = flags;
3004 + inode->i_vflags = vflags;
3005 + ext2_get_inode_flags(EXT2_I(inode));
3006 + inode->i_ctime = CURRENT_TIME_SEC;
3007 + mark_inode_dirty(inode);
3011 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3013 struct inode *inode = filp->f_dentry->d_inode;
3014 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
3016 flags = ext2_mask_flags(inode->i_mode, flags);
3018 + if (IS_BARRIER(inode)) {
3019 + vxwprintk_task(1, "messing with the barrier.");
3023 mutex_lock(&inode->i_mutex);
3024 /* Is it quota file? Do not allow user to mess with it */
3025 if (IS_NOQUOTA(inode)) {
3026 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
3028 * This test looks nicer. Thanks to Pauline Middelink
3030 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
3031 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
3032 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
3033 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
3034 if (!capable(CAP_LINUX_IMMUTABLE)) {
3035 mutex_unlock(&inode->i_mutex);
3037 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
3041 - flags = flags & EXT2_FL_USER_MODIFIABLE;
3042 + flags &= EXT2_FL_USER_MODIFIABLE;
3043 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
3044 ei->i_flags = flags;
3045 mutex_unlock(&inode->i_mutex);
3046 diff -NurpP --minimal linux-2.6.38.3/fs/ext2/namei.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/namei.c
3047 --- linux-2.6.38.3/fs/ext2/namei.c 2011-03-15 18:07:31.000000000 +0100
3048 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/namei.c 2011-03-10 17:21:19.000000000 +0100
3051 #include <linux/pagemap.h>
3052 #include <linux/quotaops.h>
3053 +#include <linux/vs_tag.h>
3057 @@ -75,6 +76,7 @@ static struct dentry *ext2_lookup(struct
3058 return ERR_PTR(-EIO);
3060 return ERR_CAST(inode);
3061 + dx_propagate_tag(nd, inode);
3065 @@ -413,6 +415,7 @@ const struct inode_operations ext2_dir_i
3067 .setattr = ext2_setattr,
3068 .check_acl = ext2_check_acl,
3069 + .sync_flags = ext2_sync_flags,
3072 const struct inode_operations ext2_special_inode_operations = {
3073 diff -NurpP --minimal linux-2.6.38.3/fs/ext2/super.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/super.c
3074 --- linux-2.6.38.3/fs/ext2/super.c 2011-03-15 18:07:31.000000000 +0100
3075 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext2/super.c 2011-01-29 02:01:07.000000000 +0100
3076 @@ -394,7 +394,8 @@ enum {
3077 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3078 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3079 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3080 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
3081 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
3082 + Opt_tag, Opt_notag, Opt_tagid
3085 static const match_table_t tokens = {
3086 @@ -422,6 +423,9 @@ static const match_table_t tokens = {
3088 {Opt_noacl, "noacl"},
3091 + {Opt_notag, "notag"},
3092 + {Opt_tagid, "tagid=%u"},
3093 {Opt_grpquota, "grpquota"},
3094 {Opt_ignore, "noquota"},
3095 {Opt_quota, "quota"},
3096 @@ -492,6 +496,20 @@ static int parse_options(char *options,
3098 set_opt (sbi->s_mount_opt, NO_UID32);
3100 +#ifndef CONFIG_TAGGING_NONE
3102 + set_opt (sbi->s_mount_opt, TAGGED);
3105 + clear_opt (sbi->s_mount_opt, TAGGED);
3108 +#ifdef CONFIG_PROPAGATE
3111 + set_opt (sbi->s_mount_opt, TAGGED);
3115 clear_opt (sbi->s_mount_opt, CHECK);
3117 @@ -850,6 +868,8 @@ static int ext2_fill_super(struct super_
3118 if (!parse_options((char *) data, sb))
3121 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3122 + sb->s_flags |= MS_TAGGED;
3123 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3124 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3126 @@ -1223,6 +1243,14 @@ static int ext2_remount (struct super_bl
3130 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3131 + !(sb->s_flags & MS_TAGGED)) {
3132 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3135 + goto restore_opts;
3138 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3139 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3141 diff -NurpP --minimal linux-2.6.38.3/fs/ext3/file.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext3/file.c
3142 --- linux-2.6.38.3/fs/ext3/file.c 2010-07-07 18:31:51.000000000 +0200
3143 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext3/file.c 2011-01-29 02:01:07.000000000 +0100
3144 @@ -81,5 +81,6 @@ const struct inode_operations ext3_file_
3146 .check_acl = ext3_check_acl,
3147 .fiemap = ext3_fiemap,
3148 + .sync_flags = ext3_sync_flags,
3151 diff -NurpP --minimal linux-2.6.38.3/fs/ext3/ialloc.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext3/ialloc.c
3152 --- linux-2.6.38.3/fs/ext3/ialloc.c 2011-01-05 21:50:22.000000000 +0100
3153 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext3/ialloc.c 2011-01-29 02:01:07.000000000 +0100
3155 #include <linux/buffer_head.h>
3156 #include <linux/random.h>
3157 #include <linux/bitops.h>
3158 +#include <linux/vs_tag.h>
3160 #include <asm/byteorder.h>
3162 @@ -531,6 +532,7 @@ got:
3163 inode->i_mode = mode;
3164 inode->i_uid = current_fsuid();
3165 inode->i_gid = dir->i_gid;
3166 + inode->i_tag = dx_current_fstag(sb);
3168 inode_init_owner(inode, dir, mode);
3170 diff -NurpP --minimal linux-2.6.38.3/fs/ext3/inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext3/inode.c
3171 --- linux-2.6.38.3/fs/ext3/inode.c 2011-03-15 18:07:31.000000000 +0100
3172 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext3/inode.c 2011-01-29 02:01:07.000000000 +0100
3174 #include <linux/bio.h>
3175 #include <linux/fiemap.h>
3176 #include <linux/namei.h>
3177 +#include <linux/vs_tag.h>
3181 @@ -2394,7 +2395,7 @@ static void ext3_free_branches(handle_t
3183 int ext3_can_truncate(struct inode *inode)
3185 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3186 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3188 if (S_ISREG(inode->i_mode))
3190 @@ -2778,36 +2779,60 @@ void ext3_set_inode_flags(struct inode *
3192 unsigned int flags = EXT3_I(inode)->i_flags;
3194 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3195 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3196 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3198 + if (flags & EXT3_IMMUTABLE_FL)
3199 + inode->i_flags |= S_IMMUTABLE;
3200 + if (flags & EXT3_IXUNLINK_FL)
3201 + inode->i_flags |= S_IXUNLINK;
3203 if (flags & EXT3_SYNC_FL)
3204 inode->i_flags |= S_SYNC;
3205 if (flags & EXT3_APPEND_FL)
3206 inode->i_flags |= S_APPEND;
3207 - if (flags & EXT3_IMMUTABLE_FL)
3208 - inode->i_flags |= S_IMMUTABLE;
3209 if (flags & EXT3_NOATIME_FL)
3210 inode->i_flags |= S_NOATIME;
3211 if (flags & EXT3_DIRSYNC_FL)
3212 inode->i_flags |= S_DIRSYNC;
3214 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3216 + if (flags & EXT3_BARRIER_FL)
3217 + inode->i_vflags |= V_BARRIER;
3218 + if (flags & EXT3_COW_FL)
3219 + inode->i_vflags |= V_COW;
3222 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
3223 void ext3_get_inode_flags(struct ext3_inode_info *ei)
3225 unsigned int flags = ei->vfs_inode.i_flags;
3226 + unsigned int vflags = ei->vfs_inode.i_vflags;
3228 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
3229 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
3230 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
3231 + EXT3_BARRIER_FL | EXT3_COW_FL);
3233 + if (flags & S_IMMUTABLE)
3234 + ei->i_flags |= EXT3_IMMUTABLE_FL;
3235 + if (flags & S_IXUNLINK)
3236 + ei->i_flags |= EXT3_IXUNLINK_FL;
3238 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
3239 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
3241 ei->i_flags |= EXT3_SYNC_FL;
3242 if (flags & S_APPEND)
3243 ei->i_flags |= EXT3_APPEND_FL;
3244 - if (flags & S_IMMUTABLE)
3245 - ei->i_flags |= EXT3_IMMUTABLE_FL;
3246 if (flags & S_NOATIME)
3247 ei->i_flags |= EXT3_NOATIME_FL;
3248 if (flags & S_DIRSYNC)
3249 ei->i_flags |= EXT3_DIRSYNC_FL;
3251 + if (vflags & V_BARRIER)
3252 + ei->i_flags |= EXT3_BARRIER_FL;
3253 + if (vflags & V_COW)
3254 + ei->i_flags |= EXT3_COW_FL;
3257 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3258 @@ -2821,6 +2846,8 @@ struct inode *ext3_iget(struct super_blo
3259 transaction_t *transaction;
3265 inode = iget_locked(sb, ino);
3267 @@ -2837,12 +2864,17 @@ struct inode *ext3_iget(struct super_blo
3269 raw_inode = ext3_raw_inode(&iloc);
3270 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3271 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3272 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3273 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3274 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3275 if(!(test_opt (inode->i_sb, NO_UID32))) {
3276 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3277 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3278 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3279 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3281 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3282 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3283 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3284 + le16_to_cpu(raw_inode->i_raw_tag));
3286 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3287 inode->i_size = le32_to_cpu(raw_inode->i_size);
3288 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3289 @@ -2997,6 +3029,8 @@ static int ext3_do_update_inode(handle_t
3290 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3291 struct ext3_inode_info *ei = EXT3_I(inode);
3292 struct buffer_head *bh = iloc->bh;
3293 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3294 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3295 int err = 0, rc, block;
3298 @@ -3011,29 +3045,32 @@ again:
3299 ext3_get_inode_flags(ei);
3300 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3301 if(!(test_opt(inode->i_sb, NO_UID32))) {
3302 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3303 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3304 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3305 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3307 * Fix up interoperability with old kernels. Otherwise, old inodes get
3308 * re-used with the upper 16 bits of the uid/gid intact
3311 raw_inode->i_uid_high =
3312 - cpu_to_le16(high_16_bits(inode->i_uid));
3313 + cpu_to_le16(high_16_bits(uid));
3314 raw_inode->i_gid_high =
3315 - cpu_to_le16(high_16_bits(inode->i_gid));
3316 + cpu_to_le16(high_16_bits(gid));
3318 raw_inode->i_uid_high = 0;
3319 raw_inode->i_gid_high = 0;
3322 raw_inode->i_uid_low =
3323 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3324 + cpu_to_le16(fs_high2lowuid(uid));
3325 raw_inode->i_gid_low =
3326 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3327 + cpu_to_le16(fs_high2lowgid(gid));
3328 raw_inode->i_uid_high = 0;
3329 raw_inode->i_gid_high = 0;
3331 +#ifdef CONFIG_TAGGING_INTERN
3332 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3334 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3335 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3336 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3337 @@ -3193,7 +3230,8 @@ int ext3_setattr(struct dentry *dentry,
3338 if (is_quota_modification(inode, attr))
3339 dquot_initialize(inode);
3340 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3341 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3342 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3343 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3346 /* (user+group)*(old+new) structure, inode write (sb,
3347 @@ -3215,6 +3253,8 @@ int ext3_setattr(struct dentry *dentry,
3348 inode->i_uid = attr->ia_uid;
3349 if (attr->ia_valid & ATTR_GID)
3350 inode->i_gid = attr->ia_gid;
3351 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3352 + inode->i_tag = attr->ia_tag;
3353 error = ext3_mark_inode_dirty(handle, inode);
3354 ext3_journal_stop(handle);
3356 diff -NurpP --minimal linux-2.6.38.3/fs/ext3/ioctl.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext3/ioctl.c
3357 --- linux-2.6.38.3/fs/ext3/ioctl.c 2011-03-15 18:07:31.000000000 +0100
3358 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext3/ioctl.c 2011-01-29 02:01:07.000000000 +0100
3362 #include <linux/fs.h>
3363 +#include <linux/mount.h>
3364 #include <linux/jbd.h>
3365 #include <linux/capability.h>
3366 #include <linux/ext3_fs.h>
3368 #include <linux/compat.h>
3369 #include <asm/uaccess.h>
3372 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
3374 + handle_t *handle = NULL;
3375 + struct ext3_iloc iloc;
3378 + handle = ext3_journal_start(inode, 1);
3379 + if (IS_ERR(handle))
3380 + return PTR_ERR(handle);
3382 + if (IS_SYNC(inode))
3383 + handle->h_sync = 1;
3384 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3388 + inode->i_flags = flags;
3389 + inode->i_vflags = vflags;
3390 + ext3_get_inode_flags(EXT3_I(inode));
3391 + inode->i_ctime = CURRENT_TIME_SEC;
3393 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3395 + ext3_journal_stop(handle);
3399 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3401 struct inode *inode = filp->f_dentry->d_inode;
3402 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
3404 flags = ext3_mask_flags(inode->i_mode, flags);
3406 + if (IS_BARRIER(inode)) {
3407 + vxwprintk_task(1, "messing with the barrier.");
3411 mutex_lock(&inode->i_mutex);
3413 /* Is it quota file? Do not allow user to mess with it */
3414 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3416 * This test looks nicer. Thanks to Pauline Middelink
3418 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3419 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3420 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3421 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3422 if (!capable(CAP_LINUX_IMMUTABLE))
3425 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3429 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3430 + flags &= EXT3_FL_USER_MODIFIABLE;
3431 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3432 ei->i_flags = flags;
3434 diff -NurpP --minimal linux-2.6.38.3/fs/ext3/namei.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext3/namei.c
3435 --- linux-2.6.38.3/fs/ext3/namei.c 2011-04-15 10:30:30.000000000 +0200
3436 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext3/namei.c 2011-03-25 22:52:15.000000000 +0100
3438 #include <linux/quotaops.h>
3439 #include <linux/buffer_head.h>
3440 #include <linux/bio.h>
3441 +#include <linux/vs_tag.h>
3445 @@ -923,6 +924,7 @@ restart:
3447 ll_rw_block(READ_META, 1, &bh);
3449 + dx_propagate_tag(nd, inode);
3451 if ((bh = bh_use[ra_ptr++]) == NULL)
3453 @@ -2487,6 +2489,7 @@ const struct inode_operations ext3_dir_i
3454 .removexattr = generic_removexattr,
3456 .check_acl = ext3_check_acl,
3457 + .sync_flags = ext3_sync_flags,
3460 const struct inode_operations ext3_special_inode_operations = {
3461 diff -NurpP --minimal linux-2.6.38.3/fs/ext3/super.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext3/super.c
3462 --- linux-2.6.38.3/fs/ext3/super.c 2011-04-15 10:30:30.000000000 +0200
3463 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext3/super.c 2011-03-28 15:00:13.000000000 +0200
3464 @@ -820,7 +820,8 @@ enum {
3465 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3466 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
3467 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
3468 - Opt_resize, Opt_usrquota, Opt_grpquota
3469 + Opt_resize, Opt_usrquota, Opt_grpquota,
3470 + Opt_tag, Opt_notag, Opt_tagid
3473 static const match_table_t tokens = {
3474 @@ -877,6 +878,9 @@ static const match_table_t tokens = {
3475 {Opt_barrier, "barrier"},
3476 {Opt_nobarrier, "nobarrier"},
3477 {Opt_resize, "resize"},
3479 + {Opt_notag, "notag"},
3480 + {Opt_tagid, "tagid=%u"},
3484 @@ -1029,6 +1033,20 @@ static int parse_options (char *options,
3486 set_opt (sbi->s_mount_opt, NO_UID32);
3488 +#ifndef CONFIG_TAGGING_NONE
3490 + set_opt (sbi->s_mount_opt, TAGGED);
3493 + clear_opt (sbi->s_mount_opt, TAGGED);
3496 +#ifdef CONFIG_PROPAGATE
3499 + set_opt (sbi->s_mount_opt, TAGGED);
3503 clear_opt (sbi->s_mount_opt, CHECK);
3505 @@ -1722,6 +1740,9 @@ static int ext3_fill_super (struct super
3509 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3510 + sb->s_flags |= MS_TAGGED;
3512 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3513 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3515 @@ -2601,6 +2622,14 @@ static int ext3_remount (struct super_bl
3516 if (test_opt(sb, ABORT))
3517 ext3_abort(sb, __func__, "Abort forced by user");
3519 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3520 + !(sb->s_flags & MS_TAGGED)) {
3521 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3524 + goto restore_opts;
3527 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3528 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3530 diff -NurpP --minimal linux-2.6.38.3/fs/ext4/ext4.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/ext4.h
3531 --- linux-2.6.38.3/fs/ext4/ext4.h 2011-03-15 18:07:31.000000000 +0100
3532 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/ext4.h 2011-02-17 02:17:50.000000000 +0100
3533 @@ -347,8 +347,12 @@ struct flex_groups {
3534 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3535 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
3536 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
3537 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3538 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3540 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3541 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3543 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3544 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3546 @@ -601,7 +605,8 @@ struct ext4_inode {
3547 __le16 l_i_file_acl_high;
3548 __le16 l_i_uid_high; /* these 2 fields */
3549 __le16 l_i_gid_high; /* were reserved2[0] */
3550 - __u32 l_i_reserved2;
3551 + __le16 l_i_tag; /* Context Tag */
3552 + __u16 l_i_reserved2;
3555 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3556 @@ -719,6 +724,7 @@ do { \
3557 #define i_gid_low i_gid
3558 #define i_uid_high osd2.linux2.l_i_uid_high
3559 #define i_gid_high osd2.linux2.l_i_gid_high
3560 +#define i_raw_tag osd2.linux2.l_i_tag
3561 #define i_reserved2 osd2.linux2.l_i_reserved2
3563 #elif defined(__GNU__)
3564 @@ -895,6 +901,7 @@ struct ext4_inode_info {
3565 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3566 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3567 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3568 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3569 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3570 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3571 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3572 @@ -2074,6 +2081,7 @@ extern int ext4_map_blocks(handle_t *han
3573 struct ext4_map_blocks *map, int flags);
3574 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3575 __u64 start, __u64 len);
3576 +extern int ext4_sync_flags(struct inode *, int, int);
3578 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3579 __u64 start_orig, __u64 start_donor,
3580 diff -NurpP --minimal linux-2.6.38.3/fs/ext4/file.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/file.c
3581 --- linux-2.6.38.3/fs/ext4/file.c 2011-03-15 18:07:31.000000000 +0100
3582 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/file.c 2011-02-17 02:17:50.000000000 +0100
3583 @@ -283,5 +283,6 @@ const struct inode_operations ext4_file_
3585 .check_acl = ext4_check_acl,
3586 .fiemap = ext4_fiemap,
3587 + .sync_flags = ext4_sync_flags,
3590 diff -NurpP --minimal linux-2.6.38.3/fs/ext4/ialloc.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/ialloc.c
3591 --- linux-2.6.38.3/fs/ext4/ialloc.c 2011-03-15 18:07:31.000000000 +0100
3592 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/ialloc.c 2011-01-29 02:01:07.000000000 +0100
3594 #include <linux/random.h>
3595 #include <linux/bitops.h>
3596 #include <linux/blkdev.h>
3597 +#include <linux/vs_tag.h>
3598 #include <asm/byteorder.h>
3601 @@ -991,6 +992,7 @@ got:
3602 inode->i_mode = mode;
3603 inode->i_uid = current_fsuid();
3604 inode->i_gid = dir->i_gid;
3605 + inode->i_tag = dx_current_fstag(sb);
3607 inode_init_owner(inode, dir, mode);
3609 diff -NurpP --minimal linux-2.6.38.3/fs/ext4/inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/inode.c
3610 --- linux-2.6.38.3/fs/ext4/inode.c 2011-04-15 10:30:30.000000000 +0200
3611 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/inode.c 2011-04-15 10:33:41.000000000 +0200
3613 #include <linux/printk.h>
3614 #include <linux/slab.h>
3615 #include <linux/ratelimit.h>
3616 +#include <linux/vs_tag.h>
3618 #include "ext4_jbd2.h"
3620 @@ -4446,7 +4447,7 @@ static void ext4_free_branches(handle_t
3622 int ext4_can_truncate(struct inode *inode)
3624 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3625 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3627 if (S_ISREG(inode->i_mode))
3629 @@ -4797,41 +4798,64 @@ void ext4_set_inode_flags(struct inode *
3631 unsigned int flags = EXT4_I(inode)->i_flags;
3633 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3634 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3635 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3637 + if (flags & EXT4_IMMUTABLE_FL)
3638 + inode->i_flags |= S_IMMUTABLE;
3639 + if (flags & EXT4_IXUNLINK_FL)
3640 + inode->i_flags |= S_IXUNLINK;
3642 if (flags & EXT4_SYNC_FL)
3643 inode->i_flags |= S_SYNC;
3644 if (flags & EXT4_APPEND_FL)
3645 inode->i_flags |= S_APPEND;
3646 - if (flags & EXT4_IMMUTABLE_FL)
3647 - inode->i_flags |= S_IMMUTABLE;
3648 if (flags & EXT4_NOATIME_FL)
3649 inode->i_flags |= S_NOATIME;
3650 if (flags & EXT4_DIRSYNC_FL)
3651 inode->i_flags |= S_DIRSYNC;
3653 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3655 + if (flags & EXT4_BARRIER_FL)
3656 + inode->i_vflags |= V_BARRIER;
3657 + if (flags & EXT4_COW_FL)
3658 + inode->i_vflags |= V_COW;
3661 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3662 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3664 - unsigned int vfs_fl;
3665 + unsigned int vfs_fl, vfs_vf;
3666 unsigned long old_fl, new_fl;
3669 vfs_fl = ei->vfs_inode.i_flags;
3670 + vfs_vf = ei->vfs_inode.i_vflags;
3671 old_fl = ei->i_flags;
3672 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3673 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3675 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3678 + if (vfs_fl & S_IMMUTABLE)
3679 + new_fl |= EXT4_IMMUTABLE_FL;
3680 + if (vfs_fl & S_IXUNLINK)
3681 + new_fl |= EXT4_IXUNLINK_FL;
3683 if (vfs_fl & S_SYNC)
3684 new_fl |= EXT4_SYNC_FL;
3685 if (vfs_fl & S_APPEND)
3686 new_fl |= EXT4_APPEND_FL;
3687 - if (vfs_fl & S_IMMUTABLE)
3688 - new_fl |= EXT4_IMMUTABLE_FL;
3689 if (vfs_fl & S_NOATIME)
3690 new_fl |= EXT4_NOATIME_FL;
3691 if (vfs_fl & S_DIRSYNC)
3692 new_fl |= EXT4_DIRSYNC_FL;
3694 + if (vfs_vf & V_BARRIER)
3695 + new_fl |= EXT4_BARRIER_FL;
3696 + if (vfs_vf & V_COW)
3697 + new_fl |= EXT4_COW_FL;
3698 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3701 @@ -4867,6 +4891,8 @@ struct inode *ext4_iget(struct super_blo
3702 journal_t *journal = EXT4_SB(sb)->s_journal;
3708 inode = iget_locked(sb, ino);
3710 @@ -4882,12 +4908,16 @@ struct inode *ext4_iget(struct super_blo
3712 raw_inode = ext4_raw_inode(&iloc);
3713 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3714 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3715 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3716 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3717 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3718 if (!(test_opt(inode->i_sb, NO_UID32))) {
3719 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3720 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3721 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3722 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3724 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3725 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3726 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3727 + le16_to_cpu(raw_inode->i_raw_tag));
3728 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3730 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3731 @@ -5106,6 +5136,8 @@ static int ext4_do_update_inode(handle_t
3732 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3733 struct ext4_inode_info *ei = EXT4_I(inode);
3734 struct buffer_head *bh = iloc->bh;
3735 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3736 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3737 int err = 0, rc, block;
3739 /* For fields not not tracking in the in-memory inode,
3740 @@ -5116,29 +5148,32 @@ static int ext4_do_update_inode(handle_t
3741 ext4_get_inode_flags(ei);
3742 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3743 if (!(test_opt(inode->i_sb, NO_UID32))) {
3744 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3745 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3746 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3747 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3749 * Fix up interoperability with old kernels. Otherwise, old inodes get
3750 * re-used with the upper 16 bits of the uid/gid intact
3753 raw_inode->i_uid_high =
3754 - cpu_to_le16(high_16_bits(inode->i_uid));
3755 + cpu_to_le16(high_16_bits(uid));
3756 raw_inode->i_gid_high =
3757 - cpu_to_le16(high_16_bits(inode->i_gid));
3758 + cpu_to_le16(high_16_bits(gid));
3760 raw_inode->i_uid_high = 0;
3761 raw_inode->i_gid_high = 0;
3764 raw_inode->i_uid_low =
3765 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3766 + cpu_to_le16(fs_high2lowuid(uid));
3767 raw_inode->i_gid_low =
3768 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3769 + cpu_to_le16(fs_high2lowgid(gid));
3770 raw_inode->i_uid_high = 0;
3771 raw_inode->i_gid_high = 0;
3773 +#ifdef CONFIG_TAGGING_INTERN
3774 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3776 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3778 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3779 @@ -5324,7 +5359,8 @@ int ext4_setattr(struct dentry *dentry,
3780 if (is_quota_modification(inode, attr))
3781 dquot_initialize(inode);
3782 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3783 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3784 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3785 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3788 /* (user+group)*(old+new) structure, inode write (sb,
3789 @@ -5346,6 +5382,8 @@ int ext4_setattr(struct dentry *dentry,
3790 inode->i_uid = attr->ia_uid;
3791 if (attr->ia_valid & ATTR_GID)
3792 inode->i_gid = attr->ia_gid;
3793 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3794 + inode->i_tag = attr->ia_tag;
3795 error = ext4_mark_inode_dirty(handle, inode);
3796 ext4_journal_stop(handle);
3798 diff -NurpP --minimal linux-2.6.38.3/fs/ext4/ioctl.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/ioctl.c
3799 --- linux-2.6.38.3/fs/ext4/ioctl.c 2011-01-05 21:50:23.000000000 +0100
3800 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/ioctl.c 2011-01-29 02:01:07.000000000 +0100
3802 #include <linux/compat.h>
3803 #include <linux/mount.h>
3804 #include <linux/file.h>
3805 +#include <linux/vs_tag.h>
3806 #include <asm/uaccess.h>
3807 #include "ext4_jbd2.h"
3811 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3813 + handle_t *handle = NULL;
3814 + struct ext4_iloc iloc;
3817 + handle = ext4_journal_start(inode, 1);
3818 + if (IS_ERR(handle))
3819 + return PTR_ERR(handle);
3821 + if (IS_SYNC(inode))
3822 + ext4_handle_sync(handle);
3823 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3827 + inode->i_flags = flags;
3828 + inode->i_vflags = vflags;
3829 + ext4_get_inode_flags(EXT4_I(inode));
3830 + inode->i_ctime = ext4_current_time(inode);
3832 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3834 + ext4_journal_stop(handle);
3838 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3840 struct inode *inode = filp->f_dentry->d_inode;
3841 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3843 flags = ext4_mask_flags(inode->i_mode, flags);
3845 + if (IS_BARRIER(inode)) {
3846 + vxwprintk_task(1, "messing with the barrier.");
3851 mutex_lock(&inode->i_mutex);
3852 /* Is it quota file? Do not allow user to mess with it */
3853 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3855 * This test looks nicer. Thanks to Pauline Middelink
3857 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3858 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3859 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3860 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3861 if (!capable(CAP_LINUX_IMMUTABLE))
3864 diff -NurpP --minimal linux-2.6.38.3/fs/ext4/namei.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/namei.c
3865 --- linux-2.6.38.3/fs/ext4/namei.c 2011-03-15 18:07:31.000000000 +0100
3866 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/namei.c 2011-01-29 02:01:07.000000000 +0100
3868 #include <linux/quotaops.h>
3869 #include <linux/buffer_head.h>
3870 #include <linux/bio.h>
3871 +#include <linux/vs_tag.h>
3873 #include "ext4_jbd2.h"
3875 @@ -923,6 +924,7 @@ restart:
3877 ll_rw_block(READ_META, 1, &bh);
3879 + dx_propagate_tag(nd, inode);
3881 if ((bh = bh_use[ra_ptr++]) == NULL)
3883 @@ -2540,6 +2542,7 @@ const struct inode_operations ext4_dir_i
3885 .check_acl = ext4_check_acl,
3886 .fiemap = ext4_fiemap,
3887 + .sync_flags = ext4_sync_flags,
3890 const struct inode_operations ext4_special_inode_operations = {
3891 diff -NurpP --minimal linux-2.6.38.3/fs/ext4/super.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/super.c
3892 --- linux-2.6.38.3/fs/ext4/super.c 2011-04-15 10:30:30.000000000 +0200
3893 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ext4/super.c 2011-04-15 10:33:41.000000000 +0200
3894 @@ -1263,6 +1263,7 @@ enum {
3895 Opt_dioread_nolock, Opt_dioread_lock,
3896 Opt_discard, Opt_nodiscard,
3897 Opt_init_inode_table, Opt_noinit_inode_table,
3898 + Opt_tag, Opt_notag, Opt_tagid
3901 static const match_table_t tokens = {
3902 @@ -1338,6 +1339,9 @@ static const match_table_t tokens = {
3903 {Opt_init_inode_table, "init_itable=%u"},
3904 {Opt_init_inode_table, "init_itable"},
3905 {Opt_noinit_inode_table, "noinit_itable"},
3907 + {Opt_notag, "notag"},
3908 + {Opt_tagid, "tagid=%u"},
3912 @@ -1506,6 +1510,20 @@ static int parse_options(char *options,
3914 set_opt(sb, NO_UID32);
3916 +#ifndef CONFIG_TAGGING_NONE
3918 + set_opt(sb, TAGGED);
3921 + clear_opt(sb, TAGGED);
3924 +#ifdef CONFIG_PROPAGATE
3927 + set_opt(sb, TAGGED);
3933 @@ -3162,6 +3180,9 @@ static int ext4_fill_super(struct super_
3934 &journal_ioprio, NULL, 0))
3937 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3938 + sb->s_flags |= MS_TAGGED;
3940 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3941 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3943 @@ -4249,6 +4270,14 @@ static int ext4_remount(struct super_blo
3944 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3945 ext4_abort(sb, "Abort forced by user");
3947 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3948 + !(sb->s_flags & MS_TAGGED)) {
3949 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3952 + goto restore_opts;
3955 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3956 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3958 diff -NurpP --minimal linux-2.6.38.3/fs/fcntl.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/fcntl.c
3959 --- linux-2.6.38.3/fs/fcntl.c 2011-03-15 18:07:31.000000000 +0100
3960 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/fcntl.c 2011-02-17 02:17:50.000000000 +0100
3962 #include <linux/signal.h>
3963 #include <linux/rcupdate.h>
3964 #include <linux/pid_namespace.h>
3965 +#include <linux/vs_limit.h>
3967 #include <asm/poll.h>
3968 #include <asm/siginfo.h>
3969 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3972 filp_close(tofree, files);
3974 + vx_openfd_inc(newfd); /* fd was unused */
3978 @@ -434,6 +437,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3982 + if (!vx_files_avail(1))
3985 err = security_file_fcntl(filp, cmd, arg);
3987 diff -NurpP --minimal linux-2.6.38.3/fs/file.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/file.c
3988 --- linux-2.6.38.3/fs/file.c 2010-10-21 13:07:48.000000000 +0200
3989 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/file.c 2011-01-29 02:01:07.000000000 +0100
3991 #include <linux/spinlock.h>
3992 #include <linux/rcupdate.h>
3993 #include <linux/workqueue.h>
3994 +#include <linux/vs_limit.h>
3996 struct fdtable_defer {
3998 @@ -355,6 +356,8 @@ struct files_struct *dup_fd(struct files
3999 struct file *f = *old_fds++;
4002 + /* TODO: sum it first for check and performance */
4003 + vx_openfd_inc(open_files - i);
4006 * The fd may be claimed in the fd bitmap but not yet
4007 @@ -462,6 +465,7 @@ repeat:
4009 FD_CLR(fd, fdt->close_on_exec);
4011 + vx_openfd_inc(fd);
4014 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
4015 diff -NurpP --minimal linux-2.6.38.3/fs/file_table.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/file_table.c
4016 --- linux-2.6.38.3/fs/file_table.c 2011-03-15 18:07:31.000000000 +0100
4017 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/file_table.c 2011-02-17 02:17:50.000000000 +0100
4019 #include <linux/percpu_counter.h>
4020 #include <linux/percpu.h>
4021 #include <linux/ima.h>
4022 +#include <linux/vs_limit.h>
4023 +#include <linux/vs_context.h>
4025 #include <asm/atomic.h>
4027 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
4028 spin_lock_init(&f->f_lock);
4029 eventpoll_init_file(f);
4030 /* f->f_version: 0 */
4031 + f->f_xid = vx_current_xid();
4036 @@ -250,6 +254,8 @@ static void __fput(struct file *file)
4037 cdev_put(inode->i_cdev);
4038 fops_put(file->f_op);
4039 put_pid(file->f_owner.pid);
4040 + vx_files_dec(file);
4042 file_sb_list_del(file);
4043 if (file->f_mode & FMODE_WRITE)
4044 drop_file_write_access(file);
4045 @@ -333,6 +339,8 @@ void put_filp(struct file *file)
4047 if (atomic_long_dec_and_test(&file->f_count)) {
4048 security_file_free(file);
4049 + vx_files_dec(file);
4051 file_sb_list_del(file);
4054 diff -NurpP --minimal linux-2.6.38.3/fs/fs_struct.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/fs_struct.c
4055 --- linux-2.6.38.3/fs/fs_struct.c 2011-03-15 18:07:31.000000000 +0100
4056 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/fs_struct.c 2011-01-29 02:35:02.000000000 +0100
4058 #include <linux/path.h>
4059 #include <linux/slab.h>
4060 #include <linux/fs_struct.h>
4061 +#include <linux/vserver/global.h>
4062 #include "internal.h"
4064 static inline void path_get_longterm(struct path *path)
4065 @@ -96,6 +97,7 @@ void free_fs_struct(struct fs_struct *fs
4067 path_put_longterm(&fs->root);
4068 path_put_longterm(&fs->pwd);
4069 + atomic_dec(&vs_global_fs);
4070 kmem_cache_free(fs_cachep, fs);
4073 @@ -135,6 +137,7 @@ struct fs_struct *copy_fs_struct(struct
4075 path_get_longterm(&fs->pwd);
4076 spin_unlock(&old->lock);
4077 + atomic_inc(&vs_global_fs);
4081 diff -NurpP --minimal linux-2.6.38.3/fs/gfs2/file.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/gfs2/file.c
4082 --- linux-2.6.38.3/fs/gfs2/file.c 2011-03-15 18:07:32.000000000 +0100
4083 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/gfs2/file.c 2011-01-29 02:01:07.000000000 +0100
4084 @@ -134,6 +134,9 @@ static const u32 fsflags_to_gfs2[32] = {
4085 [7] = GFS2_DIF_NOATIME,
4086 [12] = GFS2_DIF_EXHASH,
4087 [14] = GFS2_DIF_INHERIT_JDATA,
4088 + [27] = GFS2_DIF_IXUNLINK,
4089 + [26] = GFS2_DIF_BARRIER,
4090 + [29] = GFS2_DIF_COW,
4093 static const u32 gfs2_to_fsflags[32] = {
4094 @@ -143,6 +146,9 @@ static const u32 gfs2_to_fsflags[32] = {
4095 [gfs2fl_NoAtime] = FS_NOATIME_FL,
4096 [gfs2fl_ExHash] = FS_INDEX_FL,
4097 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
4098 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
4099 + [gfs2fl_Barrier] = FS_BARRIER_FL,
4100 + [gfs2fl_Cow] = FS_COW_FL,
4103 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
4104 @@ -173,10 +179,16 @@ void gfs2_set_inode_flags(struct inode *
4106 struct gfs2_inode *ip = GFS2_I(inode);
4107 unsigned int flags = inode->i_flags;
4108 + unsigned int vflags = inode->i_vflags;
4110 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4111 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4113 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4114 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
4115 flags |= S_IMMUTABLE;
4116 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
4117 + flags |= S_IXUNLINK;
4119 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
4121 if (ip->i_diskflags & GFS2_DIF_NOATIME)
4122 @@ -184,6 +196,43 @@ void gfs2_set_inode_flags(struct inode *
4123 if (ip->i_diskflags & GFS2_DIF_SYNC)
4125 inode->i_flags = flags;
4127 + vflags &= ~(V_BARRIER | V_COW);
4129 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
4130 + vflags |= V_BARRIER;
4131 + if (ip->i_diskflags & GFS2_DIF_COW)
4133 + inode->i_vflags = vflags;
4136 +void gfs2_get_inode_flags(struct inode *inode)
4138 + struct gfs2_inode *ip = GFS2_I(inode);
4139 + unsigned int flags = inode->i_flags;
4140 + unsigned int vflags = inode->i_vflags;
4142 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
4143 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
4144 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
4145 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
4147 + if (flags & S_IMMUTABLE)
4148 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
4149 + if (flags & S_IXUNLINK)
4150 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
4152 + if (flags & S_APPEND)
4153 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
4154 + if (flags & S_NOATIME)
4155 + ip->i_diskflags |= GFS2_DIF_NOATIME;
4156 + if (flags & S_SYNC)
4157 + ip->i_diskflags |= GFS2_DIF_SYNC;
4159 + if (vflags & V_BARRIER)
4160 + ip->i_diskflags |= GFS2_DIF_BARRIER;
4161 + if (vflags & V_COW)
4162 + ip->i_diskflags |= GFS2_DIF_COW;
4165 /* Flags that can be set by user space */
4166 @@ -295,6 +344,37 @@ static int gfs2_set_flags(struct file *f
4167 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
4170 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
4172 + struct gfs2_inode *ip = GFS2_I(inode);
4173 + struct gfs2_sbd *sdp = GFS2_SB(inode);
4174 + struct buffer_head *bh;
4175 + struct gfs2_holder gh;
4178 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
4181 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
4184 + error = gfs2_meta_inode_buffer(ip, &bh);
4186 + goto out_trans_end;
4187 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
4188 + inode->i_flags = flags;
4189 + inode->i_vflags = vflags;
4190 + gfs2_get_inode_flags(inode);
4191 + gfs2_dinode_out(ip, bh->b_data);
4193 + gfs2_set_aops(inode);
4195 + gfs2_trans_end(sdp);
4197 + gfs2_glock_dq_uninit(&gh);
4201 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4204 diff -NurpP --minimal linux-2.6.38.3/fs/gfs2/inode.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/gfs2/inode.h
4205 --- linux-2.6.38.3/fs/gfs2/inode.h 2011-03-15 18:07:32.000000000 +0100
4206 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/gfs2/inode.h 2011-01-29 02:01:07.000000000 +0100
4207 @@ -125,6 +125,7 @@ extern const struct file_operations gfs2
4208 extern const struct file_operations gfs2_dir_fops_nolock;
4210 extern void gfs2_set_inode_flags(struct inode *inode);
4211 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
4213 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
4214 extern const struct file_operations gfs2_file_fops;
4215 diff -NurpP --minimal linux-2.6.38.3/fs/gfs2/ops_inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/gfs2/ops_inode.c
4216 --- linux-2.6.38.3/fs/gfs2/ops_inode.c 2011-03-15 18:07:32.000000000 +0100
4217 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/gfs2/ops_inode.c 2011-01-29 02:01:07.000000000 +0100
4218 @@ -1326,6 +1326,8 @@ const struct inode_operations gfs2_dir_i
4219 .listxattr = gfs2_listxattr,
4220 .removexattr = gfs2_removexattr,
4221 .fiemap = gfs2_fiemap,
4222 + .sync_flags = gfs2_sync_flags,
4223 + .sync_flags = gfs2_sync_flags,
4226 const struct inode_operations gfs2_symlink_iops = {
4227 diff -NurpP --minimal linux-2.6.38.3/fs/inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/inode.c
4228 --- linux-2.6.38.3/fs/inode.c 2011-03-15 18:07:32.000000000 +0100
4229 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/inode.c 2011-03-07 16:53:27.000000000 +0100
4231 #include <linux/async.h>
4232 #include <linux/posix_acl.h>
4233 #include <linux/ima.h>
4234 +#include <linux/vs_tag.h>
4237 * This is needed for the following functions:
4238 @@ -164,6 +165,9 @@ int inode_init_always(struct super_block
4239 struct address_space *const mapping = &inode->i_data;
4243 + /* essential because of inode slab reuse */
4245 inode->i_blkbits = sb->s_blocksize_bits;
4247 atomic_set(&inode->i_count, 1);
4248 @@ -184,6 +188,7 @@ int inode_init_always(struct super_block
4249 inode->i_bdev = NULL;
4250 inode->i_cdev = NULL;
4252 + inode->i_mdev = 0;
4253 inode->dirtied_when = 0;
4255 if (security_inode_alloc(inode))
4256 @@ -431,6 +436,8 @@ static void __remove_inode_hash(struct i
4257 hlist_del_init(&inode->i_hash);
4260 +EXPORT_SYMBOL_GPL(__iget);
4263 * remove_inode_hash - remove an inode from the hash
4264 * @inode: inode to unhash
4265 @@ -1704,9 +1711,11 @@ void init_special_inode(struct inode *in
4266 if (S_ISCHR(mode)) {
4267 inode->i_fop = &def_chr_fops;
4268 inode->i_rdev = rdev;
4269 + inode->i_mdev = rdev;
4270 } else if (S_ISBLK(mode)) {
4271 inode->i_fop = &def_blk_fops;
4272 inode->i_rdev = rdev;
4273 + inode->i_mdev = rdev;
4274 } else if (S_ISFIFO(mode))
4275 inode->i_fop = &def_fifo_fops;
4276 else if (S_ISSOCK(mode))
4277 @@ -1735,5 +1744,6 @@ void inode_init_owner(struct inode *inod
4279 inode->i_gid = current_fsgid();
4280 inode->i_mode = mode;
4281 + inode->i_tag = dx_current_fstag(inode->i_sb);
4283 EXPORT_SYMBOL(inode_init_owner);
4284 diff -NurpP --minimal linux-2.6.38.3/fs/ioctl.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ioctl.c
4285 --- linux-2.6.38.3/fs/ioctl.c 2011-03-15 18:07:32.000000000 +0100
4286 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ioctl.c 2011-02-17 02:17:50.000000000 +0100
4288 #include <linux/writeback.h>
4289 #include <linux/buffer_head.h>
4290 #include <linux/falloc.h>
4291 +#include <linux/proc_fs.h>
4292 +#include <linux/vserver/inode.h>
4293 +#include <linux/vs_tag.h>
4295 #include <asm/ioctls.h>
4297 diff -NurpP --minimal linux-2.6.38.3/fs/ioprio.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ioprio.c
4298 --- linux-2.6.38.3/fs/ioprio.c 2011-01-05 21:50:24.000000000 +0100
4299 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ioprio.c 2011-01-29 02:01:07.000000000 +0100
4301 #include <linux/syscalls.h>
4302 #include <linux/security.h>
4303 #include <linux/pid_namespace.h>
4304 +#include <linux/vs_base.h>
4306 int set_task_ioprio(struct task_struct *task, int ioprio)
4308 @@ -119,6 +120,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4310 pgrp = find_vpid(who);
4311 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4312 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4314 ret = set_task_ioprio(p, ioprio);
4317 @@ -208,6 +211,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
4319 pgrp = find_vpid(who);
4320 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4321 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4323 tmpio = get_task_ioprio(p);
4326 diff -NurpP --minimal linux-2.6.38.3/fs/jfs/file.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/file.c
4327 --- linux-2.6.38.3/fs/jfs/file.c 2010-10-21 13:07:50.000000000 +0200
4328 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/file.c 2011-01-29 02:01:07.000000000 +0100
4329 @@ -102,7 +102,8 @@ int jfs_setattr(struct dentry *dentry, s
4330 if (is_quota_modification(inode, iattr))
4331 dquot_initialize(inode);
4332 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4333 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4334 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4335 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4336 rc = dquot_transfer(inode, iattr);
4339 @@ -133,6 +134,7 @@ const struct inode_operations jfs_file_i
4340 #ifdef CONFIG_JFS_POSIX_ACL
4341 .check_acl = jfs_check_acl,
4343 + .sync_flags = jfs_sync_flags,
4346 const struct file_operations jfs_file_operations = {
4347 diff -NurpP --minimal linux-2.6.38.3/fs/jfs/ioctl.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/ioctl.c
4348 --- linux-2.6.38.3/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4349 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/ioctl.c 2011-01-29 02:01:07.000000000 +0100
4351 #include <linux/mount.h>
4352 #include <linux/time.h>
4353 #include <linux/sched.h>
4354 +#include <linux/mount.h>
4355 #include <asm/current.h>
4356 #include <asm/uaccess.h>
4358 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
4362 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
4364 + inode->i_flags = flags;
4365 + inode->i_vflags = vflags;
4366 + jfs_get_inode_flags(JFS_IP(inode));
4367 + inode->i_ctime = CURRENT_TIME_SEC;
4368 + mark_inode_dirty(inode);
4372 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4374 struct inode *inode = filp->f_dentry->d_inode;
4375 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
4376 if (!S_ISDIR(inode->i_mode))
4377 flags &= ~JFS_DIRSYNC_FL;
4379 + if (IS_BARRIER(inode)) {
4380 + vxwprintk_task(1, "messing with the barrier.");
4384 /* Is it quota file? Do not allow user to mess with it */
4385 if (IS_NOQUOTA(inode)) {
4387 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
4388 * the relevant capability.
4390 if ((oldflags & JFS_IMMUTABLE_FL) ||
4391 - ((flags ^ oldflags) &
4392 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4393 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4394 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4395 if (!capable(CAP_LINUX_IMMUTABLE)) {
4396 mutex_unlock(&inode->i_mutex);
4398 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
4402 - flags = flags & JFS_FL_USER_MODIFIABLE;
4403 + flags &= JFS_FL_USER_MODIFIABLE;
4404 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
4405 jfs_inode->mode2 = flags;
4407 diff -NurpP --minimal linux-2.6.38.3/fs/jfs/jfs_dinode.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/jfs_dinode.h
4408 --- linux-2.6.38.3/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
4409 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/jfs_dinode.h 2011-01-29 02:01:07.000000000 +0100
4410 @@ -161,9 +161,13 @@ struct dinode {
4412 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4413 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4414 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4416 -#define JFS_FL_USER_VISIBLE 0x03F80000
4417 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4418 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4419 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4421 +#define JFS_FL_USER_VISIBLE 0x07F80000
4422 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4423 #define JFS_FL_INHERIT 0x03C80000
4425 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4426 diff -NurpP --minimal linux-2.6.38.3/fs/jfs/jfs_filsys.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/jfs_filsys.h
4427 --- linux-2.6.38.3/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4428 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/jfs_filsys.h 2011-01-29 02:01:07.000000000 +0100
4430 #define JFS_NAME_MAX 255
4431 #define JFS_PATH_MAX BPSIZE
4433 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4436 * file system state (superblock state)
4437 diff -NurpP --minimal linux-2.6.38.3/fs/jfs/jfs_imap.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/jfs_imap.c
4438 --- linux-2.6.38.3/fs/jfs/jfs_imap.c 2011-01-05 21:50:24.000000000 +0100
4439 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/jfs_imap.c 2011-01-29 02:01:07.000000000 +0100
4441 #include <linux/pagemap.h>
4442 #include <linux/quotaops.h>
4443 #include <linux/slab.h>
4444 +#include <linux/vs_tag.h>
4446 #include "jfs_incore.h"
4447 #include "jfs_inode.h"
4448 @@ -3060,6 +3061,8 @@ static int copy_from_dinode(struct dinod
4450 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4451 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4455 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4456 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4457 @@ -3080,14 +3083,18 @@ static int copy_from_dinode(struct dinod
4459 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4461 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4462 + uid = le32_to_cpu(dip->di_uid);
4463 + gid = le32_to_cpu(dip->di_gid);
4464 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4466 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4468 ip->i_uid = jfs_ip->saved_uid;
4470 ip->i_uid = sbi->uid;
4473 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4474 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4476 ip->i_gid = jfs_ip->saved_gid;
4478 @@ -3152,14 +3159,12 @@ static void copy_to_dinode(struct dinode
4479 dip->di_size = cpu_to_le64(ip->i_size);
4480 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4481 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4482 - if (sbi->uid == -1)
4483 - dip->di_uid = cpu_to_le32(ip->i_uid);
4485 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4486 - if (sbi->gid == -1)
4487 - dip->di_gid = cpu_to_le32(ip->i_gid);
4489 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4491 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4492 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4493 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4494 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4496 jfs_get_inode_flags(jfs_ip);
4498 * mode2 is only needed for storing the higher order bits.
4499 diff -NurpP --minimal linux-2.6.38.3/fs/jfs/jfs_inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/jfs_inode.c
4500 --- linux-2.6.38.3/fs/jfs/jfs_inode.c 2010-08-02 16:52:49.000000000 +0200
4501 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/jfs_inode.c 2011-01-29 02:01:07.000000000 +0100
4504 #include <linux/fs.h>
4505 #include <linux/quotaops.h>
4506 +#include <linux/vs_tag.h>
4507 #include "jfs_incore.h"
4508 #include "jfs_inode.h"
4509 #include "jfs_filsys.h"
4510 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4512 unsigned int flags = JFS_IP(inode)->mode2;
4514 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4515 - S_NOATIME | S_DIRSYNC | S_SYNC);
4516 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4517 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4519 if (flags & JFS_IMMUTABLE_FL)
4520 inode->i_flags |= S_IMMUTABLE;
4521 + if (flags & JFS_IXUNLINK_FL)
4522 + inode->i_flags |= S_IXUNLINK;
4524 + if (flags & JFS_SYNC_FL)
4525 + inode->i_flags |= S_SYNC;
4526 if (flags & JFS_APPEND_FL)
4527 inode->i_flags |= S_APPEND;
4528 if (flags & JFS_NOATIME_FL)
4529 inode->i_flags |= S_NOATIME;
4530 if (flags & JFS_DIRSYNC_FL)
4531 inode->i_flags |= S_DIRSYNC;
4532 - if (flags & JFS_SYNC_FL)
4533 - inode->i_flags |= S_SYNC;
4535 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4537 + if (flags & JFS_BARRIER_FL)
4538 + inode->i_vflags |= V_BARRIER;
4539 + if (flags & JFS_COW_FL)
4540 + inode->i_vflags |= V_COW;
4543 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4545 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4546 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4548 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4549 + JFS_APPEND_FL | JFS_NOATIME_FL |
4550 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4551 + JFS_BARRIER_FL | JFS_COW_FL);
4553 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4554 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4555 if (flags & S_IMMUTABLE)
4556 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4557 + if (flags & S_IXUNLINK)
4558 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4560 if (flags & S_APPEND)
4561 jfs_ip->mode2 |= JFS_APPEND_FL;
4562 if (flags & S_NOATIME)
4563 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4564 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4566 jfs_ip->mode2 |= JFS_SYNC_FL;
4568 + if (vflags & V_BARRIER)
4569 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4570 + if (vflags & V_COW)
4571 + jfs_ip->mode2 |= JFS_COW_FL;
4575 diff -NurpP --minimal linux-2.6.38.3/fs/jfs/jfs_inode.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/jfs_inode.h
4576 --- linux-2.6.38.3/fs/jfs/jfs_inode.h 2010-10-21 13:07:50.000000000 +0200
4577 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/jfs_inode.h 2011-01-29 02:01:07.000000000 +0100
4578 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4579 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4580 int fh_len, int fh_type);
4581 extern void jfs_set_inode_flags(struct inode *);
4582 +extern int jfs_sync_flags(struct inode *, int, int);
4583 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4584 extern int jfs_setattr(struct dentry *, struct iattr *);
4586 diff -NurpP --minimal linux-2.6.38.3/fs/jfs/namei.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/namei.c
4587 --- linux-2.6.38.3/fs/jfs/namei.c 2011-03-15 18:07:32.000000000 +0100
4588 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/namei.c 2011-03-15 18:15:06.000000000 +0100
4590 #include <linux/ctype.h>
4591 #include <linux/quotaops.h>
4592 #include <linux/exportfs.h>
4593 +#include <linux/vs_tag.h>
4594 #include "jfs_incore.h"
4595 #include "jfs_superblock.h"
4596 #include "jfs_inode.h"
4597 @@ -1489,6 +1490,7 @@ static struct dentry *jfs_lookup(struct
4598 return ERR_CAST(ip);
4601 + dx_propagate_tag(nd, ip);
4602 return d_splice_alias(ip, dentry);
4605 @@ -1553,6 +1555,7 @@ const struct inode_operations jfs_dir_in
4606 #ifdef CONFIG_JFS_POSIX_ACL
4607 .check_acl = jfs_check_acl,
4609 + .sync_flags = jfs_sync_flags,
4612 const struct file_operations jfs_dir_operations = {
4613 diff -NurpP --minimal linux-2.6.38.3/fs/jfs/super.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/super.c
4614 --- linux-2.6.38.3/fs/jfs/super.c 2011-03-15 18:07:32.000000000 +0100
4615 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/jfs/super.c 2011-01-29 02:01:07.000000000 +0100
4616 @@ -198,7 +198,8 @@ static void jfs_put_super(struct super_b
4618 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4619 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4620 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4621 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4622 + Opt_tag, Opt_notag, Opt_tagid
4625 static const match_table_t tokens = {
4626 @@ -208,6 +209,10 @@ static const match_table_t tokens = {
4627 {Opt_resize, "resize=%u"},
4628 {Opt_resize_nosize, "resize"},
4629 {Opt_errors, "errors=%s"},
4631 + {Opt_notag, "notag"},
4632 + {Opt_tagid, "tagid=%u"},
4633 + {Opt_tag, "tagxid"},
4634 {Opt_ignore, "noquota"},
4635 {Opt_ignore, "quota"},
4636 {Opt_usrquota, "usrquota"},
4637 @@ -342,6 +347,20 @@ static int parse_options(char *options,
4641 +#ifndef CONFIG_TAGGING_NONE
4643 + *flag |= JFS_TAGGED;
4646 + *flag &= JFS_TAGGED;
4649 +#ifdef CONFIG_PROPAGATE
4652 + *flag |= JFS_TAGGED;
4656 printk("jfs: Unrecognized mount option \"%s\" "
4657 " or missing value\n", p);
4658 @@ -373,6 +392,12 @@ static int jfs_remount(struct super_bloc
4662 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4663 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4669 if (sb->s_flags & MS_RDONLY) {
4671 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
4672 #ifdef CONFIG_JFS_POSIX_ACL
4673 sb->s_flags |= MS_POSIXACL;
4675 + /* map mount option tagxid */
4676 + if (sbi->flag & JFS_TAGGED)
4677 + sb->s_flags |= MS_TAGGED;
4680 printk(KERN_ERR "resize option for remount only\n");
4681 diff -NurpP --minimal linux-2.6.38.3/fs/libfs.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/libfs.c
4682 --- linux-2.6.38.3/fs/libfs.c 2011-03-15 18:07:32.000000000 +0100
4683 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/libfs.c 2011-01-29 05:03:51.000000000 +0100
4684 @@ -133,7 +133,8 @@ static inline unsigned char dt_type(stru
4685 * both impossible due to the lock on directory.
4688 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4689 +static inline int do_dcache_readdir_filter(struct file *filp,
4690 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4692 struct dentry *dentry = filp->f_path.dentry;
4693 struct dentry *cursor = filp->private_data;
4694 @@ -164,6 +165,8 @@ int dcache_readdir(struct file * filp, v
4695 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4696 struct dentry *next;
4697 next = list_entry(p, struct dentry, d_u.d_child);
4698 + if (filter && !filter(next))
4700 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4701 if (!simple_positive(next)) {
4702 spin_unlock(&next->d_lock);
4703 @@ -190,6 +193,17 @@ int dcache_readdir(struct file * filp, v
4707 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4709 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4712 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4713 + int (*filter)(struct dentry *))
4715 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4718 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4721 @@ -965,6 +979,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4722 EXPORT_SYMBOL(dcache_dir_lseek);
4723 EXPORT_SYMBOL(dcache_dir_open);
4724 EXPORT_SYMBOL(dcache_readdir);
4725 +EXPORT_SYMBOL(dcache_readdir_filter);
4726 EXPORT_SYMBOL(generic_read_dir);
4727 EXPORT_SYMBOL(mount_pseudo);
4728 EXPORT_SYMBOL(simple_write_begin);
4729 diff -NurpP --minimal linux-2.6.38.3/fs/locks.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/locks.c
4730 --- linux-2.6.38.3/fs/locks.c 2011-03-15 18:07:32.000000000 +0100
4731 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/locks.c 2011-01-29 02:01:07.000000000 +0100
4733 #include <linux/time.h>
4734 #include <linux/rcupdate.h>
4735 #include <linux/pid_namespace.h>
4736 +#include <linux/vs_base.h>
4737 +#include <linux/vs_limit.h>
4739 #include <asm/uaccess.h>
4741 @@ -164,6 +166,8 @@ static struct kmem_cache *filelock_cache
4742 /* Allocate an empty lock structure. */
4743 struct file_lock *locks_alloc_lock(void)
4745 + if (!vx_locks_avail(1))
4747 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4749 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4750 @@ -191,6 +195,7 @@ void locks_free_lock(struct file_lock *f
4751 BUG_ON(!list_empty(&fl->fl_block));
4752 BUG_ON(!list_empty(&fl->fl_link));
4755 locks_release_private(fl);
4756 kmem_cache_free(filelock_cache, fl);
4758 @@ -212,6 +217,7 @@ void locks_init_lock(struct file_lock *f
4759 fl->fl_start = fl->fl_end = 0;
4761 fl->fl_lmops = NULL;
4765 EXPORT_SYMBOL(locks_init_lock);
4766 @@ -263,6 +269,7 @@ void locks_copy_lock(struct file_lock *n
4767 new->fl_file = fl->fl_file;
4768 new->fl_ops = fl->fl_ops;
4769 new->fl_lmops = fl->fl_lmops;
4770 + new->fl_xid = fl->fl_xid;
4772 locks_copy_private(new, fl);
4774 @@ -301,6 +308,11 @@ static int flock_make_lock(struct file *
4775 fl->fl_flags = FL_FLOCK;
4777 fl->fl_end = OFFSET_MAX;
4779 + vxd_assert(filp->f_xid == vx_current_xid(),
4780 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4781 + fl->fl_xid = filp->f_xid;
4786 @@ -460,6 +472,7 @@ static int lease_init(struct file *filp,
4788 fl->fl_owner = current->files;
4789 fl->fl_pid = current->tgid;
4790 + fl->fl_xid = vx_current_xid();
4793 fl->fl_flags = FL_LEASE;
4794 @@ -479,6 +492,11 @@ static struct file_lock *lease_alloc(str
4796 return ERR_PTR(error);
4798 + fl->fl_xid = vx_current_xid();
4800 + vxd_assert(filp->f_xid == fl->fl_xid,
4801 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4803 error = lease_init(filp, type, fl);
4805 locks_free_lock(fl);
4806 @@ -780,6 +798,7 @@ static int flock_lock_file(struct file *
4810 + new_fl->fl_xid = -1;
4812 for_each_lock(inode, before) {
4813 struct file_lock *fl = *before;
4814 @@ -800,6 +819,7 @@ find_conflict:
4816 locks_copy_lock(new_fl, request);
4817 locks_insert_lock(before, new_fl);
4818 + vx_locks_inc(new_fl);
4822 @@ -810,7 +830,8 @@ out:
4826 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4827 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4828 + struct file_lock *conflock, xid_t xid)
4830 struct file_lock *fl;
4831 struct file_lock *new_fl = NULL;
4832 @@ -820,6 +841,8 @@ static int __posix_lock_file(struct inod
4833 struct file_lock **before;
4834 int error, added = 0;
4836 + vxd_assert(xid == vx_current_xid(),
4837 + "xid(%d) == current(%d)", xid, vx_current_xid());
4839 * We may need two file_lock structures for this operation,
4840 * so we get them in advance to avoid races.
4841 @@ -830,7 +853,11 @@ static int __posix_lock_file(struct inod
4842 (request->fl_type != F_UNLCK ||
4843 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4844 new_fl = locks_alloc_lock();
4845 + new_fl->fl_xid = xid;
4846 + vx_locks_inc(new_fl);
4847 new_fl2 = locks_alloc_lock();
4848 + new_fl2->fl_xid = xid;
4849 + vx_locks_inc(new_fl2);
4853 @@ -1029,7 +1056,8 @@ static int __posix_lock_file(struct inod
4854 int posix_lock_file(struct file *filp, struct file_lock *fl,
4855 struct file_lock *conflock)
4857 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4858 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4859 + fl, conflock, filp->f_xid);
4861 EXPORT_SYMBOL(posix_lock_file);
4863 @@ -1119,7 +1147,7 @@ int locks_mandatory_area(int read_write,
4864 fl.fl_end = offset + count - 1;
4867 - error = __posix_lock_file(inode, &fl, NULL);
4868 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4869 if (error != FILE_LOCK_DEFERRED)
4871 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4872 @@ -1432,6 +1460,7 @@ int generic_setlease(struct file *filp,
4875 locks_insert_lock(before, lease);
4876 + vx_locks_inc(lease);
4880 @@ -1816,6 +1845,11 @@ int fcntl_setlk(unsigned int fd, struct
4881 if (file_lock == NULL)
4884 + vxd_assert(filp->f_xid == vx_current_xid(),
4885 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4886 + file_lock->fl_xid = filp->f_xid;
4887 + vx_locks_inc(file_lock);
4890 * This might block, so we do it before checking the inode.
4892 @@ -1934,6 +1968,11 @@ int fcntl_setlk64(unsigned int fd, struc
4893 if (file_lock == NULL)
4896 + vxd_assert(filp->f_xid == vx_current_xid(),
4897 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4898 + file_lock->fl_xid = filp->f_xid;
4899 + vx_locks_inc(file_lock);
4902 * This might block, so we do it before checking the inode.
4904 @@ -2199,8 +2238,11 @@ static int locks_show(struct seq_file *f
4906 lock_get_status(f, fl, *((loff_t *)f->private), "");
4908 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4909 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4910 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4912 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4917 diff -NurpP --minimal linux-2.6.38.3/fs/namei.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/namei.c
4918 --- linux-2.6.38.3/fs/namei.c 2011-03-15 18:07:32.000000000 +0100
4919 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/namei.c 2011-03-15 18:17:37.000000000 +0100
4921 #include <linux/fcntl.h>
4922 #include <linux/device_cgroup.h>
4923 #include <linux/fs_struct.h>
4924 +#include <linux/proc_fs.h>
4925 +#include <linux/vserver/inode.h>
4926 +#include <linux/vs_base.h>
4927 +#include <linux/vs_tag.h>
4928 +#include <linux/vs_cowbl.h>
4929 +#include <linux/vs_device.h>
4930 +#include <linux/vs_context.h>
4931 +#include <linux/pid_namespace.h>
4932 #include <asm/uaccess.h>
4934 #include "internal.h"
4935 @@ -166,6 +174,84 @@ void putname(const char *name)
4936 EXPORT_SYMBOL(putname);
4939 +static inline int dx_barrier(const struct inode *inode)
4941 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4942 + vxwprintk_task(1, "did hit the barrier.");
4948 +static int __dx_permission(const struct inode *inode, int mask)
4950 + if (dx_barrier(inode))
4953 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4954 + /* devpts is xid tagged */
4955 + if (S_ISDIR(inode->i_mode) ||
4956 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4959 + /* just pretend we didn't find anything */
4962 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4963 + struct proc_dir_entry *de = PDE(inode);
4965 + if (de && !vx_hide_check(0, de->vx_flags))
4968 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4970 + struct task_struct *tsk;
4972 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4973 + vx_flags(VXF_STATE_SETUP, 0))
4976 + pid = PROC_I(inode)->pid;
4980 + tsk = pid_task(pid, PIDTYPE_PID);
4981 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4982 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4983 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
4987 + /* FIXME: Should we block some entries here? */
4992 + if (dx_notagcheck(inode->i_sb) ||
4993 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
5002 +int dx_permission(const struct inode *inode, int mask)
5004 + int ret = __dx_permission(inode, mask);
5005 + if (unlikely(ret)) {
5006 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
5007 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
5010 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
5011 + mask, inode->i_sb->s_id, inode, inode->i_tag,
5018 * This does basic POSIX ACL permission checking
5020 @@ -271,10 +357,14 @@ int inode_permission(struct inode *inode
5022 * Nobody gets write access to an immutable file.
5024 - if (IS_IMMUTABLE(inode))
5025 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
5029 + retval = dx_permission(inode, mask);
5033 if (inode->i_op->permission)
5034 retval = inode->i_op->permission(inode, mask, 0);
5036 @@ -676,6 +766,9 @@ static inline int exec_permission(struct
5040 + if (dx_barrier(inode))
5043 if (inode->i_op->permission) {
5044 ret = inode->i_op->permission(inode, MAY_EXEC, flags);
5046 @@ -1162,7 +1255,8 @@ static void follow_dotdot(struct nameida
5048 if (nd->path.dentry == nd->root.dentry &&
5049 nd->path.mnt == nd->root.mnt) {
5051 + /* for sane '/' avoid follow_mount() */
5054 if (nd->path.dentry != nd->path.mnt->mnt_root) {
5055 /* rare case of legitimate dget_parent()... */
5056 @@ -1216,7 +1310,7 @@ static int do_lookup(struct nameidata *n
5058 struct vfsmount *mnt = nd->path.mnt;
5059 struct dentry *dentry, *parent = nd->path.dentry;
5060 - struct inode *dir;
5061 + struct inode *dir, *d_inode;
5065 @@ -1277,6 +1371,13 @@ found:
5070 + d_inode = dentry->d_inode;
5074 + if (__dx_permission(d_inode, MAY_ACCESS))
5078 path->dentry = dentry;
5079 @@ -1288,6 +1389,18 @@ done:
5080 *inode = path->dentry->d_inode;
5084 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
5085 + if (d_inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
5088 + "did lookup hidden %s:%p[#%d,%lu] " VS_Q("%s/%.*s") ".",
5089 + d_inode->i_sb->s_id, d_inode, d_inode->i_tag, d_inode->i_ino,
5090 + vxd_path(&nd->path), name->len, name->name);
5096 dir = parent->d_inode;
5097 BUG_ON(nd->inode != dir);
5098 @@ -1982,7 +2095,7 @@ static int may_delete(struct inode *dir,
5101 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5102 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5103 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5106 if (!S_ISDIR(victim->d_inode->i_mode))
5107 @@ -2105,6 +2218,14 @@ int may_open(struct path *path, int acc_
5111 +#ifdef CONFIG_VSERVER_COWBL
5112 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5113 + if (IS_COW_LINK(inode))
5115 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5116 + mark_inode_dirty(inode);
5119 error = inode_permission(inode, acc_mode);
5122 @@ -2215,7 +2336,8 @@ static int open_will_truncate(int flag,
5125 static struct file *finish_open(struct nameidata *nd,
5126 - int open_flag, int acc_mode)
5127 + int open_flag, int acc_mode,
5128 + const char *pathname)
5132 @@ -2228,6 +2350,23 @@ static struct file *finish_open(struct n
5135 error = may_open(&nd->path, acc_mode, open_flag);
5136 +#ifdef CONFIG_VSERVER_COWBL
5137 + if (error == -EMLINK) {
5138 + struct dentry *dentry;
5139 + dentry = cow_break_link(pathname);
5140 + if (IS_ERR(dentry)) {
5141 + error = PTR_ERR(dentry);
5145 + if (will_truncate)
5146 + mnt_drop_write(nd->path.mnt);
5147 + release_open_intent(nd);
5148 + path_put(&nd->path);
5149 + return ERR_PTR(-EMLINK);
5155 mnt_drop_write(nd->path.mnt);
5156 @@ -2375,7 +2514,7 @@ static struct file *do_last(struct namei
5157 if (S_ISDIR(nd->inode->i_mode))
5160 - filp = finish_open(nd, open_flag, acc_mode);
5161 + filp = finish_open(nd, open_flag, acc_mode, pathname);
5165 @@ -2402,7 +2541,12 @@ struct file *do_filp_open(int dfd, const
5167 int flag = open_to_namei_flags(open_flag);
5169 +#ifdef CONFIG_VSERVER_COWBL
5175 if (!(open_flag & O_CREAT))
5178 @@ -2468,7 +2612,7 @@ struct file *do_filp_open(int dfd, const
5181 audit_inode(pathname, nd.path.dentry);
5182 - filp = finish_open(&nd, open_flag, acc_mode);
5183 + filp = finish_open(&nd, open_flag, acc_mode, pathname);
5185 release_open_intent(&nd);
5187 @@ -2510,6 +2654,13 @@ reval:
5190 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
5191 +#ifdef CONFIG_VSERVER_COWBL
5192 + if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
5198 while (unlikely(!filp)) { /* trailing symlink */
5199 struct path link = path;
5200 struct inode *linki = link.dentry->d_inode;
5201 @@ -2544,6 +2695,13 @@ reval:
5203 nd.flags &= ~LOOKUP_PARENT;
5204 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
5205 +#ifdef CONFIG_VSERVER_COWBL
5206 + if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
5212 if (linki->i_op->put_link)
5213 linki->i_op->put_link(link.dentry, &nd, cookie);
5215 @@ -2642,9 +2800,17 @@ int vfs_mknod(struct inode *dir, struct
5219 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5220 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5223 + if (!capable(CAP_MKNOD))
5226 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5228 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5231 if (!dir->i_op->mknod)
5234 @@ -3107,7 +3273,7 @@ int vfs_link(struct dentry *old_dentry,
5236 * A link to an append-only or immutable file cannot be created.
5238 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5239 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5241 if (!dir->i_op->link)
5243 @@ -3479,6 +3645,222 @@ int vfs_follow_link(struct nameidata *nd
5244 return __vfs_follow_link(nd, link);
5248 +#ifdef CONFIG_VSERVER_COWBL
5250 +#include <linux/file.h>
5253 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5257 + return do_splice_direct(in, &ppos, out, len, 0);
5260 +struct dentry *cow_break_link(const char *pathname)
5262 + int ret, mode, pathlen, redo = 0;
5263 + struct nameidata old_nd, dir_nd;
5264 + struct path old_path, new_path;
5265 + struct dentry *dir, *res = NULL;
5266 + struct file *old_file;
5267 + struct file *new_file;
5268 + char *to, *path, pad='\251';
5271 + vxdprintk(VXD_CBIT(misc, 1),
5272 + "cow_break_link(" VS_Q("%s") ")", pathname);
5273 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5278 + /* old_nd will have refs to dentry and mnt */
5279 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5280 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5282 + goto out_free_path;
5284 + old_path = old_nd.path;
5285 + mode = old_path.dentry->d_inode->i_mode;
5287 + to = d_path(&old_path, path, PATH_MAX-2);
5288 + pathlen = strlen(to);
5289 + vxdprintk(VXD_CBIT(misc, 2),
5290 + "old path " VS_Q("%s") " [" VS_Q("%.*s") ":%d]", to,
5291 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5292 + old_path.dentry->d_name.len);
5294 + to[pathlen + 1] = 0;
5296 + to[pathlen] = pad--;
5298 + if (pad <= '\240')
5301 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
5302 + /* dir_nd will have refs to dentry and mnt */
5303 + ret = path_lookup(to,
5304 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5305 + vxdprintk(VXD_CBIT(misc, 2),
5306 + "path_lookup(new): %d", ret);
5310 + /* this puppy downs the inode mutex */
5311 + new_path.dentry = lookup_create(&dir_nd, 0);
5312 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5313 + vxdprintk(VXD_CBIT(misc, 2),
5314 + "lookup_create(new): %p", new_path.dentry);
5315 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5316 + path_put(&dir_nd.path);
5319 + vxdprintk(VXD_CBIT(misc, 2),
5320 + "lookup_create(new): %p [" VS_Q("%.*s") ":%d]",
5322 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5323 + new_path.dentry->d_name.len);
5324 + dir = dir_nd.path.dentry;
5326 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5327 + vxdprintk(VXD_CBIT(misc, 2),
5328 + "vfs_create(new): %d", ret);
5329 + if (ret == -EEXIST) {
5330 + mutex_unlock(&dir->d_inode->i_mutex);
5331 + dput(new_path.dentry);
5332 + path_put(&dir_nd.path);
5336 + goto out_unlock_new;
5338 + /* drop out early, ret passes ENOENT */
5340 + if ((redo = d_unhashed(old_path.dentry)))
5341 + goto out_unlock_new;
5343 + new_path.mnt = dir_nd.path.mnt;
5344 + dget(old_path.dentry);
5345 + mntget(old_path.mnt);
5346 + /* this one cleans up the dentry/mnt in case of failure */
5347 + old_file = dentry_open(old_path.dentry, old_path.mnt,
5348 + O_RDONLY, current_cred());
5349 + vxdprintk(VXD_CBIT(misc, 2),
5350 + "dentry_open(old): %p", old_file);
5351 + if (!old_file || IS_ERR(old_file)) {
5352 + res = IS_ERR(old_file) ? (void *) old_file : res;
5353 + goto out_unlock_new;
5356 + dget(new_path.dentry);
5357 + mntget(new_path.mnt);
5358 + /* this one cleans up the dentry/mnt in case of failure */
5359 + new_file = dentry_open(new_path.dentry, new_path.mnt,
5360 + O_WRONLY, current_cred());
5361 + vxdprintk(VXD_CBIT(misc, 2),
5362 + "dentry_open(new): %p", new_file);
5364 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5365 + if (!new_file || IS_ERR(new_file))
5366 + goto out_fput_old;
5368 + size = i_size_read(old_file->f_dentry->d_inode);
5369 + ret = do_cow_splice(old_file, new_file, size);
5370 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5372 + goto out_fput_both;
5373 + } else if (ret < size) {
5375 + goto out_fput_both;
5377 + struct inode *old_inode = old_path.dentry->d_inode;
5378 + struct inode *new_inode = new_path.dentry->d_inode;
5379 + struct iattr attr = {
5380 + .ia_uid = old_inode->i_uid,
5381 + .ia_gid = old_inode->i_gid,
5382 + .ia_valid = ATTR_UID | ATTR_GID
5385 + setattr_copy(new_inode, &attr);
5386 + mark_inode_dirty(new_inode);
5389 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5391 + /* drop out late */
5393 + if ((redo = d_unhashed(old_path.dentry)))
5396 + vxdprintk(VXD_CBIT(misc, 2),
5397 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
5398 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5399 + new_path.dentry->d_name.len,
5400 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5401 + old_path.dentry->d_name.len);
5402 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5403 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5404 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5405 + res = new_path.dentry;
5408 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5411 + vxdprintk(VXD_CBIT(misc, 3),
5412 + "fput(new_file=%p[#%ld])", new_file,
5413 + atomic_long_read(&new_file->f_count));
5417 + vxdprintk(VXD_CBIT(misc, 3),
5418 + "fput(old_file=%p[#%ld])", old_file,
5419 + atomic_long_read(&old_file->f_count));
5423 + mutex_unlock(&dir->d_inode->i_mutex);
5427 + /* error path cleanup */
5428 + vfs_unlink(dir->d_inode, new_path.dentry);
5429 + dput(new_path.dentry);
5433 + goto out_rel_both;
5434 + /* lookup dentry once again */
5435 + path_put(&old_nd.path);
5436 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5438 + goto out_rel_both;
5440 + new_path.dentry = old_nd.path.dentry;
5441 + vxdprintk(VXD_CBIT(misc, 2),
5442 + "path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
5444 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5445 + new_path.dentry->d_name.len);
5446 + dget(new_path.dentry);
5447 + res = new_path.dentry;
5450 + path_put(&dir_nd.path);
5452 + path_put(&old_nd.path);
5457 + res = ERR_PTR(ret);
5463 /* get the link contents into pagecache */
5464 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5466 diff -NurpP --minimal linux-2.6.38.3/fs/namespace.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/namespace.c
5467 --- linux-2.6.38.3/fs/namespace.c 2011-04-15 10:30:30.000000000 +0200
5468 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/namespace.c 2011-03-28 15:00:13.000000000 +0200
5470 #include <linux/idr.h>
5471 #include <linux/fs_struct.h>
5472 #include <linux/fsnotify.h>
5473 +#include <linux/vs_base.h>
5474 +#include <linux/vs_context.h>
5475 +#include <linux/vs_tag.h>
5476 +#include <linux/vserver/space.h>
5477 +#include <linux/vserver/global.h>
5478 #include <asm/uaccess.h>
5479 #include <asm/unistd.h>
5481 @@ -702,6 +707,7 @@ static struct vfsmount *clone_mnt(struct
5482 mnt->mnt_root = dget(root);
5483 mnt->mnt_mountpoint = mnt->mnt_root;
5484 mnt->mnt_parent = mnt;
5485 + mnt->mnt_tag = old->mnt_tag;
5487 if (flag & CL_SLAVE) {
5488 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5489 @@ -830,6 +836,31 @@ static inline void mangle(struct seq_fil
5490 seq_escape(m, s, " \t\n\\");
5493 +static int mnt_is_reachable(struct vfsmount *mnt)
5496 + struct dentry *point;
5499 + if (mnt == mnt->mnt_ns->root)
5502 + br_read_lock(vfsmount_lock);
5503 + root = current->fs->root;
5504 + point = root.dentry;
5506 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5507 + point = mnt->mnt_mountpoint;
5508 + mnt = mnt->mnt_parent;
5511 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5513 + br_read_unlock(vfsmount_lock);
5519 * Simple .show_options callback for filesystems which don't want to
5520 * implement more complex mount option showing.
5521 @@ -932,6 +963,8 @@ static int show_sb_opts(struct seq_file
5522 { MS_SYNCHRONOUS, ",sync" },
5523 { MS_DIRSYNC, ",dirsync" },
5524 { MS_MANDLOCK, ",mand" },
5525 + { MS_TAGGED, ",tag" },
5526 + { MS_NOTAGCHECK, ",notagcheck" },
5529 const struct proc_fs_info *fs_infop;
5530 @@ -978,10 +1011,20 @@ static int show_vfsmnt(struct seq_file *
5532 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5534 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5536 - seq_path(m, &mnt_path, " \t\n\\");
5538 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5540 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5543 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5544 + mnt == current->fs->root.mnt) {
5545 + seq_puts(m, "/dev/root / ");
5547 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5549 + seq_path(m, &mnt_path, " \t\n\\");
5552 show_type(m, mnt->mnt_sb);
5553 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5554 err = show_sb_opts(m, mnt->mnt_sb);
5555 @@ -1011,6 +1054,11 @@ static int show_mountinfo(struct seq_fil
5556 struct path root = p->root;
5559 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5561 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5564 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5565 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5566 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5567 @@ -1069,17 +1117,27 @@ static int show_vfsstat(struct seq_file
5568 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5572 - if (mnt->mnt_devname) {
5573 - seq_puts(m, "device ");
5574 - mangle(m, mnt->mnt_devname);
5576 - seq_puts(m, "no device");
5577 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5579 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5583 - seq_puts(m, " mounted on ");
5584 - seq_path(m, &mnt_path, " \t\n\\");
5586 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5587 + mnt == current->fs->root.mnt) {
5588 + seq_puts(m, "device /dev/root mounted on / ");
5591 + if (mnt->mnt_devname) {
5592 + seq_puts(m, "device ");
5593 + mangle(m, mnt->mnt_devname);
5595 + seq_puts(m, "no device");
5598 + seq_puts(m, " mounted on ");
5599 + seq_path(m, &mnt_path, " \t\n\\");
5603 /* file system type */
5604 seq_puts(m, "with fstype ");
5605 @@ -1337,7 +1395,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5609 - if (!capable(CAP_SYS_ADMIN))
5610 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5613 retval = do_umount(path.mnt, flags);
5614 @@ -1363,7 +1421,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5616 static int mount_is_safe(struct path *path)
5618 - if (capable(CAP_SYS_ADMIN))
5619 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5623 @@ -1653,7 +1711,7 @@ static int do_change_type(struct path *p
5627 - if (!capable(CAP_SYS_ADMIN))
5628 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5631 if (path->dentry != path->mnt->mnt_root)
5632 @@ -1684,11 +1742,13 @@ static int do_change_type(struct path *p
5633 * do loopback mount.
5635 static int do_loopback(struct path *path, char *old_name,
5637 + tag_t tag, unsigned long flags, int mnt_flags)
5639 struct path old_path;
5640 struct vfsmount *mnt = NULL;
5641 int err = mount_is_safe(path);
5642 + int recurse = flags & MS_REC;
5646 if (!old_name || !*old_name)
5647 @@ -1723,6 +1783,7 @@ static int do_loopback(struct path *path
5648 br_write_unlock(vfsmount_lock);
5649 release_mounts(&umount_list);
5651 + mnt->mnt_flags = mnt_flags;
5654 up_write(&namespace_sem);
5655 @@ -1753,12 +1814,12 @@ static int change_mount_flags(struct vfs
5656 * on it - tough luck.
5658 static int do_remount(struct path *path, int flags, int mnt_flags,
5660 + void *data, xid_t xid)
5663 struct super_block *sb = path->mnt->mnt_sb;
5665 - if (!capable(CAP_SYS_ADMIN))
5666 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5669 if (!check_mnt(path->mnt))
5670 @@ -1802,7 +1863,7 @@ static int do_move_mount(struct path *pa
5671 struct path old_path, parent_path;
5674 - if (!capable(CAP_SYS_ADMIN))
5675 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5677 if (!old_name || !*old_name)
5679 @@ -1888,7 +1949,7 @@ static int do_new_mount(struct path *pat
5682 /* we need capabilities... */
5683 - if (!capable(CAP_SYS_ADMIN))
5684 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5687 mnt = do_kern_mount(type, flags, name, data);
5688 @@ -2194,6 +2255,7 @@ long do_mount(char *dev_name, char *dir_
5695 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5696 @@ -2221,6 +2283,12 @@ long do_mount(char *dev_name, char *dir_
5697 if (!(flags & MS_NOATIME))
5698 mnt_flags |= MNT_RELATIME;
5700 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5701 + /* FIXME: bind and re-mounts get the tag flag? */
5702 + if (flags & (MS_BIND|MS_REMOUNT))
5703 + flags |= MS_TAGID;
5706 /* Separate the per-mountpoint flags */
5707 if (flags & MS_NOSUID)
5708 mnt_flags |= MNT_NOSUID;
5709 @@ -2237,15 +2305,17 @@ long do_mount(char *dev_name, char *dir_
5710 if (flags & MS_RDONLY)
5711 mnt_flags |= MNT_READONLY;
5713 + if (!capable(CAP_SYS_ADMIN))
5714 + mnt_flags |= MNT_NODEV;
5715 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5716 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5719 if (flags & MS_REMOUNT)
5720 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5723 else if (flags & MS_BIND)
5724 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5725 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5726 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5727 retval = do_change_type(&path, flags);
5728 else if (flags & MS_MOVE)
5729 @@ -2345,6 +2415,7 @@ static struct mnt_namespace *dup_mnt_ns(
5730 q = next_mnt(q, new_ns->root);
5732 up_write(&namespace_sem);
5733 + atomic_inc(&vs_global_mnt_ns);
5737 @@ -2484,9 +2555,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5738 down_write(&namespace_sem);
5739 mutex_lock(&old.dentry->d_inode->i_mutex);
5741 - if (IS_MNT_SHARED(old.mnt) ||
5742 + if ((IS_MNT_SHARED(old.mnt) ||
5743 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5744 - IS_MNT_SHARED(root.mnt->mnt_parent))
5745 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5746 + !vx_flags(VXF_STATE_SETUP, 0))
5748 if (!check_mnt(root.mnt) || !check_mnt(new.mnt))
5750 @@ -2618,6 +2690,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5751 br_write_unlock(vfsmount_lock);
5752 up_write(&namespace_sem);
5753 release_mounts(&umount_list);
5754 + atomic_dec(&vs_global_mnt_ns);
5757 EXPORT_SYMBOL(put_mnt_ns);
5758 diff -NurpP --minimal linux-2.6.38.3/fs/nfs/client.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfs/client.c
5759 --- linux-2.6.38.3/fs/nfs/client.c 2011-03-15 18:07:32.000000000 +0100
5760 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfs/client.c 2011-02-02 22:20:25.000000000 +0100
5761 @@ -761,6 +761,9 @@ static int nfs_init_server_rpcclient(str
5762 if (server->flags & NFS_MOUNT_SOFT)
5763 server->client->cl_softrtry = 1;
5765 + server->client->cl_tag = 0;
5766 + if (server->flags & NFS_MOUNT_TAGGED)
5767 + server->client->cl_tag = 1;
5771 @@ -934,6 +937,10 @@ static void nfs_server_set_fsinfo(struct
5772 server->acdirmin = server->acdirmax = 0;
5775 + /* FIXME: needs fsinfo
5776 + if (server->flags & NFS_MOUNT_TAGGED)
5777 + sb->s_flags |= MS_TAGGED; */
5779 server->maxfilesize = fsinfo->maxfilesize;
5781 server->time_delta = fsinfo->time_delta;
5782 diff -NurpP --minimal linux-2.6.38.3/fs/nfs/dir.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfs/dir.c
5783 --- linux-2.6.38.3/fs/nfs/dir.c 2011-03-15 18:07:32.000000000 +0100
5784 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfs/dir.c 2011-01-29 02:49:21.000000000 +0100
5786 #include <linux/sched.h>
5787 #include <linux/kmemleak.h>
5788 #include <linux/xattr.h>
5789 +#include <linux/vs_tag.h>
5791 #include "delegation.h"
5793 @@ -1224,6 +1225,7 @@ static struct dentry *nfs_lookup(struct
5795 goto out_unblock_sillyrename;
5797 + dx_propagate_tag(nd, inode);
5799 res = d_materialise_unique(dentry, inode);
5801 diff -NurpP --minimal linux-2.6.38.3/fs/nfs/inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfs/inode.c
5802 --- linux-2.6.38.3/fs/nfs/inode.c 2011-03-15 18:07:32.000000000 +0100
5803 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfs/inode.c 2011-03-15 18:17:58.000000000 +0100
5805 #include <linux/nfs_xdr.h>
5806 #include <linux/slab.h>
5807 #include <linux/compat.h>
5808 +#include <linux/vs_tag.h>
5810 #include <asm/system.h>
5811 #include <asm/uaccess.h>
5812 @@ -270,6 +271,8 @@ nfs_fhget(struct super_block *sb, struct
5813 if (inode->i_state & I_NEW) {
5814 struct nfs_inode *nfsi = NFS_I(inode);
5815 unsigned long now = jiffies;
5819 /* We set i_ino for the few things that still rely on it,
5820 * such as stat(2) */
5821 @@ -318,8 +321,8 @@ nfs_fhget(struct super_block *sb, struct
5822 nfsi->change_attr = 0;
5825 - inode->i_uid = -2;
5826 - inode->i_gid = -2;
5829 inode->i_blocks = 0;
5830 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5832 @@ -356,13 +359,13 @@ nfs_fhget(struct super_block *sb, struct
5833 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5834 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5835 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5836 - inode->i_uid = fattr->uid;
5838 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5839 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5840 | NFS_INO_INVALID_ACCESS
5841 | NFS_INO_INVALID_ACL;
5842 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5843 - inode->i_gid = fattr->gid;
5845 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5846 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5847 | NFS_INO_INVALID_ACCESS
5848 @@ -375,6 +378,11 @@ nfs_fhget(struct super_block *sb, struct
5850 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5852 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5853 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5854 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5855 + /* maybe fattr->xid someday */
5857 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5858 nfsi->attrtimeo_timestamp = now;
5859 nfsi->access_cache = RB_ROOT;
5860 @@ -491,6 +499,8 @@ void nfs_setattr_update_inode(struct ino
5861 inode->i_uid = attr->ia_uid;
5862 if ((attr->ia_valid & ATTR_GID) != 0)
5863 inode->i_gid = attr->ia_gid;
5864 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5865 + inode->i_tag = attr->ia_tag;
5866 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5867 spin_unlock(&inode->i_lock);
5869 @@ -939,6 +949,9 @@ static int nfs_check_inode_attributes(st
5870 struct nfs_inode *nfsi = NFS_I(inode);
5871 loff_t cur_size, new_isize;
5872 unsigned long invalid = 0;
5878 /* Has the inode gone and changed behind our back? */
5879 @@ -962,13 +975,18 @@ static int nfs_check_inode_attributes(st
5880 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5883 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5884 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5885 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5887 /* Have any file permissions changed? */
5888 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5889 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5890 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5891 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5892 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5893 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5894 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5895 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5896 + /* maybe check for tag too? */
5898 /* Has the link count changed? */
5899 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5900 @@ -1203,6 +1221,9 @@ static int nfs_update_inode(struct inode
5901 unsigned long invalid = 0;
5902 unsigned long now = jiffies;
5903 unsigned long save_cache_validity;
5908 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5909 __func__, inode->i_sb->s_id, inode->i_ino,
5910 @@ -1305,6 +1326,9 @@ static int nfs_update_inode(struct inode
5911 | NFS_INO_REVAL_PAGECACHE
5912 | NFS_INO_REVAL_FORCED);
5914 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5915 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5916 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5918 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5919 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5920 @@ -1326,9 +1350,9 @@ static int nfs_update_inode(struct inode
5921 | NFS_INO_REVAL_FORCED);
5923 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5924 - if (inode->i_uid != fattr->uid) {
5925 + if (uid != fattr->uid) {
5926 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5927 - inode->i_uid = fattr->uid;
5930 } else if (server->caps & NFS_CAP_OWNER)
5931 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5932 @@ -1337,9 +1361,9 @@ static int nfs_update_inode(struct inode
5933 | NFS_INO_REVAL_FORCED);
5935 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5936 - if (inode->i_gid != fattr->gid) {
5937 + if (gid != fattr->gid) {
5938 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5939 - inode->i_gid = fattr->gid;
5942 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5943 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5944 @@ -1347,6 +1371,10 @@ static int nfs_update_inode(struct inode
5945 | NFS_INO_INVALID_ACL
5946 | NFS_INO_REVAL_FORCED);
5948 + inode->i_uid = uid;
5949 + inode->i_gid = gid;
5950 + inode->i_tag = tag;
5952 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5953 if (inode->i_nlink != fattr->nlink) {
5954 invalid |= NFS_INO_INVALID_ATTR;
5955 diff -NurpP --minimal linux-2.6.38.3/fs/nfs/nfs3xdr.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfs/nfs3xdr.c
5956 --- linux-2.6.38.3/fs/nfs/nfs3xdr.c 2011-03-15 18:07:32.000000000 +0100
5957 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfs/nfs3xdr.c 2011-02-02 22:20:25.000000000 +0100
5959 #include <linux/nfs3.h>
5960 #include <linux/nfs_fs.h>
5961 #include <linux/nfsacl.h>
5962 +#include <linux/vs_tag.h>
5963 #include "internal.h"
5965 #define NFSDBG_FACILITY NFSDBG_XDR
5966 @@ -562,7 +563,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5970 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5971 +static void encode_sattr3(struct xdr_stream *xdr,
5972 + const struct iattr *attr, int tag)
5976 @@ -594,15 +596,19 @@ static void encode_sattr3(struct xdr_str
5980 - if (attr->ia_valid & ATTR_UID) {
5981 + if (attr->ia_valid & ATTR_UID ||
5982 + (tag && (attr->ia_valid & ATTR_TAG))) {
5984 - *p++ = cpu_to_be32(attr->ia_uid);
5985 + *p++ = cpu_to_be32(TAGINO_UID(tag,
5986 + attr->ia_uid, attr->ia_tag));
5990 - if (attr->ia_valid & ATTR_GID) {
5991 + if (attr->ia_valid & ATTR_GID ||
5992 + (tag && (attr->ia_valid & ATTR_TAG))) {
5994 - *p++ = cpu_to_be32(attr->ia_gid);
5995 + *p++ = cpu_to_be32(TAGINO_GID(tag,
5996 + attr->ia_gid, attr->ia_tag));
6000 @@ -878,7 +884,7 @@ static void nfs3_xdr_enc_setattr3args(st
6001 const struct nfs3_sattrargs *args)
6003 encode_nfs_fh3(xdr, args->fh);
6004 - encode_sattr3(xdr, args->sattr);
6005 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
6006 encode_sattrguard3(xdr, args);
6009 @@ -1028,13 +1034,13 @@ static void nfs3_xdr_enc_write3args(stru
6012 static void encode_createhow3(struct xdr_stream *xdr,
6013 - const struct nfs3_createargs *args)
6014 + const struct nfs3_createargs *args, int tag)
6016 encode_uint32(xdr, args->createmode);
6017 switch (args->createmode) {
6018 case NFS3_CREATE_UNCHECKED:
6019 case NFS3_CREATE_GUARDED:
6020 - encode_sattr3(xdr, args->sattr);
6021 + encode_sattr3(xdr, args->sattr, tag);
6023 case NFS3_CREATE_EXCLUSIVE:
6024 encode_createverf3(xdr, args->verifier);
6025 @@ -1049,7 +1055,7 @@ static void nfs3_xdr_enc_create3args(str
6026 const struct nfs3_createargs *args)
6028 encode_diropargs3(xdr, args->fh, args->name, args->len);
6029 - encode_createhow3(xdr, args);
6030 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
6034 @@ -1065,7 +1071,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
6035 const struct nfs3_mkdirargs *args)
6037 encode_diropargs3(xdr, args->fh, args->name, args->len);
6038 - encode_sattr3(xdr, args->sattr);
6039 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
6043 @@ -1082,9 +1088,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
6046 static void encode_symlinkdata3(struct xdr_stream *xdr,
6047 - const struct nfs3_symlinkargs *args)
6048 + const struct nfs3_symlinkargs *args, int tag)
6050 - encode_sattr3(xdr, args->sattr);
6051 + encode_sattr3(xdr, args->sattr, tag);
6052 encode_nfspath3(xdr, args->pages, args->pathlen);
6055 @@ -1093,7 +1099,7 @@ static void nfs3_xdr_enc_symlink3args(st
6056 const struct nfs3_symlinkargs *args)
6058 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
6059 - encode_symlinkdata3(xdr, args);
6060 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
6064 @@ -1121,24 +1127,24 @@ static void nfs3_xdr_enc_symlink3args(st
6067 static void encode_devicedata3(struct xdr_stream *xdr,
6068 - const struct nfs3_mknodargs *args)
6069 + const struct nfs3_mknodargs *args, int tag)
6071 - encode_sattr3(xdr, args->sattr);
6072 + encode_sattr3(xdr, args->sattr, tag);
6073 encode_specdata3(xdr, args->rdev);
6076 static void encode_mknoddata3(struct xdr_stream *xdr,
6077 - const struct nfs3_mknodargs *args)
6078 + const struct nfs3_mknodargs *args, int tag)
6080 encode_ftype3(xdr, args->type);
6081 switch (args->type) {
6084 - encode_devicedata3(xdr, args);
6085 + encode_devicedata3(xdr, args, tag);
6089 - encode_sattr3(xdr, args->sattr);
6090 + encode_sattr3(xdr, args->sattr, tag);
6094 @@ -1153,7 +1159,7 @@ static void nfs3_xdr_enc_mknod3args(stru
6095 const struct nfs3_mknodargs *args)
6097 encode_diropargs3(xdr, args->fh, args->name, args->len);
6098 - encode_mknoddata3(xdr, args);
6099 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
6103 diff -NurpP --minimal linux-2.6.38.3/fs/nfs/super.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfs/super.c
6104 --- linux-2.6.38.3/fs/nfs/super.c 2011-03-15 18:07:32.000000000 +0100
6105 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfs/super.c 2011-01-29 02:01:07.000000000 +0100
6107 #include <linux/nfs_xdr.h>
6108 #include <linux/magic.h>
6109 #include <linux/parser.h>
6110 +#include <linux/vs_tag.h>
6112 #include <asm/system.h>
6113 #include <asm/uaccess.h>
6114 @@ -86,6 +87,7 @@ enum {
6115 Opt_sharecache, Opt_nosharecache,
6116 Opt_resvport, Opt_noresvport,
6117 Opt_fscache, Opt_nofscache,
6118 + Opt_tag, Opt_notag,
6120 /* Mount options that take integer arguments */
6122 @@ -99,6 +101,7 @@ enum {
6128 /* Mount options that take string arguments */
6129 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
6130 @@ -179,6 +182,10 @@ static const match_table_t nfs_mount_opt
6131 { Opt_fscache_uniq, "fsc=%s" },
6132 { Opt_local_lock, "local_lock=%s" },
6134 + { Opt_tag, "tag" },
6135 + { Opt_notag, "notag" },
6136 + { Opt_tagid, "tagid=%u" },
6141 @@ -642,6 +649,7 @@ static void nfs_show_mount_options(struc
6142 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
6143 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
6144 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
6145 + { NFS_MOUNT_TAGGED, ",tag", "" },
6148 const struct proc_nfs_info *nfs_infop;
6149 @@ -1122,6 +1130,14 @@ static int nfs_parse_mount_options(char
6150 kfree(mnt->fscache_uniq);
6151 mnt->fscache_uniq = NULL;
6153 +#ifndef CONFIG_TAGGING_NONE
6155 + mnt->flags |= NFS_MOUNT_TAGGED;
6158 + mnt->flags &= ~NFS_MOUNT_TAGGED;
6163 * options that take numeric values
6164 @@ -1306,6 +1322,12 @@ static int nfs_parse_mount_options(char
6165 goto out_invalid_value;
6166 mnt->minorversion = option;
6168 +#ifdef CONFIG_PROPAGATE
6171 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6176 * options that take text values
6177 diff -NurpP --minimal linux-2.6.38.3/fs/nfsd/auth.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfsd/auth.c
6178 --- linux-2.6.38.3/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
6179 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfsd/auth.c 2011-01-29 02:01:07.000000000 +0100
6181 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
6183 #include <linux/sched.h>
6184 +#include <linux/vs_tag.h>
6188 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6190 new->fsuid = rqstp->rq_cred.cr_uid;
6191 new->fsgid = rqstp->rq_cred.cr_gid;
6192 + /* FIXME: this desperately needs a tag :)
6193 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6196 rqgi = rqstp->rq_cred.cr_group_info;
6198 diff -NurpP --minimal linux-2.6.38.3/fs/nfsd/nfs3xdr.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfsd/nfs3xdr.c
6199 --- linux-2.6.38.3/fs/nfsd/nfs3xdr.c 2011-01-05 21:50:25.000000000 +0100
6200 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfsd/nfs3xdr.c 2011-01-29 02:01:07.000000000 +0100
6204 #include <linux/namei.h>
6205 +#include <linux/vs_tag.h>
6209 @@ -95,6 +96,8 @@ static __be32 *
6210 decode_sattr3(__be32 *p, struct iattr *iap)
6218 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6221 iap->ia_valid |= ATTR_UID;
6222 - iap->ia_uid = ntohl(*p++);
6223 + uid = ntohl(*p++);
6226 iap->ia_valid |= ATTR_GID;
6227 - iap->ia_gid = ntohl(*p++);
6228 + gid = ntohl(*p++);
6230 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6231 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6232 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6236 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6237 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6238 *p++ = htonl((u32) stat->mode);
6239 *p++ = htonl((u32) stat->nlink);
6240 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6241 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6242 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6243 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6244 + stat->uid, stat->tag)));
6245 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6246 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6247 + stat->gid, stat->tag)));
6248 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6249 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6251 diff -NurpP --minimal linux-2.6.38.3/fs/nfsd/nfs4xdr.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfsd/nfs4xdr.c
6252 --- linux-2.6.38.3/fs/nfsd/nfs4xdr.c 2011-04-15 10:30:30.000000000 +0200
6253 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfsd/nfs4xdr.c 2011-03-28 15:00:13.000000000 +0200
6255 #include <linux/statfs.h>
6256 #include <linux/utsname.h>
6257 #include <linux/sunrpc/svcauth_gss.h>
6258 +#include <linux/vs_tag.h>
6262 @@ -2095,14 +2096,18 @@ out_acl:
6263 WRITE32(stat.nlink);
6265 if (bmval1 & FATTR4_WORD1_OWNER) {
6266 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6267 + status = nfsd4_encode_user(rqstp,
6268 + TAGINO_UID(DX_TAG(dentry->d_inode),
6269 + stat.uid, stat.tag), &p, &buflen);
6270 if (status == nfserr_resource)
6275 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6276 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6277 + status = nfsd4_encode_group(rqstp,
6278 + TAGINO_GID(DX_TAG(dentry->d_inode),
6279 + stat.gid, stat.tag), &p, &buflen);
6280 if (status == nfserr_resource)
6283 diff -NurpP --minimal linux-2.6.38.3/fs/nfsd/nfsxdr.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfsd/nfsxdr.c
6284 --- linux-2.6.38.3/fs/nfsd/nfsxdr.c 2010-02-25 11:52:05.000000000 +0100
6285 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/nfsd/nfsxdr.c 2011-01-29 02:01:07.000000000 +0100
6290 +#include <linux/vs_tag.h>
6292 #define NFSDDBG_FACILITY NFSDDBG_XDR
6294 @@ -88,6 +89,8 @@ static __be32 *
6295 decode_sattr(__be32 *p, struct iattr *iap)
6303 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6305 if ((tmp = ntohl(*p++)) != (u32)-1) {
6306 iap->ia_valid |= ATTR_UID;
6307 - iap->ia_uid = tmp;
6310 if ((tmp = ntohl(*p++)) != (u32)-1) {
6311 iap->ia_valid |= ATTR_GID;
6312 - iap->ia_gid = tmp;
6315 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6316 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6317 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6318 if ((tmp = ntohl(*p++)) != (u32)-1) {
6319 iap->ia_valid |= ATTR_SIZE;
6321 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6322 *p++ = htonl(nfs_ftypes[type >> 12]);
6323 *p++ = htonl((u32) stat->mode);
6324 *p++ = htonl((u32) stat->nlink);
6325 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6326 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6327 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6328 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6329 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6330 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6332 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6333 *p++ = htonl(NFS_MAXPATHLEN);
6334 diff -NurpP --minimal linux-2.6.38.3/fs/ocfs2/dlmglue.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/dlmglue.c
6335 --- linux-2.6.38.3/fs/ocfs2/dlmglue.c 2011-01-05 21:50:26.000000000 +0100
6336 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/dlmglue.c 2011-01-29 02:01:07.000000000 +0100
6337 @@ -2114,6 +2114,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6338 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6339 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6340 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6341 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6342 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6343 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6344 lvb->lvb_iatime_packed =
6345 @@ -2168,6 +2169,7 @@ static void ocfs2_refresh_inode_from_lvb
6347 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6348 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6349 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6350 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6351 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6352 ocfs2_unpack_timespec(&inode->i_atime,
6353 diff -NurpP --minimal linux-2.6.38.3/fs/ocfs2/dlmglue.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/dlmglue.h
6354 --- linux-2.6.38.3/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
6355 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/dlmglue.h 2011-01-29 02:01:07.000000000 +0100
6356 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6359 __be32 lvb_igeneration;
6360 - __be32 lvb_reserved2;
6362 + __be16 lvb_reserved2;
6365 #define OCFS2_QINFO_LVB_VERSION 1
6366 diff -NurpP --minimal linux-2.6.38.3/fs/ocfs2/file.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/file.c
6367 --- linux-2.6.38.3/fs/ocfs2/file.c 2011-03-15 18:07:33.000000000 +0100
6368 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/file.c 2011-01-29 02:01:07.000000000 +0100
6369 @@ -1126,13 +1126,15 @@ int ocfs2_setattr(struct dentry *dentry,
6370 mlog(0, "uid change: %d\n", attr->ia_uid);
6371 if (attr->ia_valid & ATTR_GID)
6372 mlog(0, "gid change: %d\n", attr->ia_gid);
6373 + if (attr->ia_valid & ATTR_TAG)
6374 + mlog(0, "tag change: %d\n", attr->ia_tag);
6375 if (attr->ia_valid & ATTR_SIZE)
6376 mlog(0, "size change...\n");
6377 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6378 mlog(0, "time change...\n");
6380 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6381 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6382 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6383 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6384 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6386 diff -NurpP --minimal linux-2.6.38.3/fs/ocfs2/inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/inode.c
6387 --- linux-2.6.38.3/fs/ocfs2/inode.c 2011-03-15 18:07:33.000000000 +0100
6388 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/inode.c 2011-01-29 02:01:07.000000000 +0100
6390 #include <linux/highmem.h>
6391 #include <linux/pagemap.h>
6392 #include <linux/quotaops.h>
6393 +#include <linux/vs_tag.h>
6395 #include <asm/byteorder.h>
6397 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
6399 unsigned int flags = OCFS2_I(inode)->ip_attr;
6401 - inode->i_flags &= ~(S_IMMUTABLE |
6402 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6403 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6405 if (flags & OCFS2_IMMUTABLE_FL)
6406 inode->i_flags |= S_IMMUTABLE;
6407 + if (flags & OCFS2_IXUNLINK_FL)
6408 + inode->i_flags |= S_IXUNLINK;
6410 if (flags & OCFS2_SYNC_FL)
6411 inode->i_flags |= S_SYNC;
6412 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
6413 inode->i_flags |= S_NOATIME;
6414 if (flags & OCFS2_DIRSYNC_FL)
6415 inode->i_flags |= S_DIRSYNC;
6417 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6419 + if (flags & OCFS2_BARRIER_FL)
6420 + inode->i_vflags |= V_BARRIER;
6421 + if (flags & OCFS2_COW_FL)
6422 + inode->i_vflags |= V_COW;
6425 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6426 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6428 unsigned int flags = oi->vfs_inode.i_flags;
6429 + unsigned int vflags = oi->vfs_inode.i_vflags;
6431 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6432 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6433 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6434 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6436 + if (flags & S_IMMUTABLE)
6437 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6438 + if (flags & S_IXUNLINK)
6439 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6441 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6442 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6444 oi->ip_attr |= OCFS2_SYNC_FL;
6445 if (flags & S_APPEND)
6446 oi->ip_attr |= OCFS2_APPEND_FL;
6447 - if (flags & S_IMMUTABLE)
6448 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6449 if (flags & S_NOATIME)
6450 oi->ip_attr |= OCFS2_NOATIME_FL;
6451 if (flags & S_DIRSYNC)
6452 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6454 + if (vflags & V_BARRIER)
6455 + oi->ip_attr |= OCFS2_BARRIER_FL;
6456 + if (vflags & V_COW)
6457 + oi->ip_attr |= OCFS2_COW_FL;
6460 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
6461 @@ -245,6 +267,8 @@ void ocfs2_populate_inode(struct inode *
6462 struct super_block *sb;
6463 struct ocfs2_super *osb;
6468 mlog_entry("(0x%p, size:%llu)\n", inode,
6469 (unsigned long long)le64_to_cpu(fe->i_size));
6470 @@ -276,8 +300,12 @@ void ocfs2_populate_inode(struct inode *
6471 inode->i_generation = le32_to_cpu(fe->i_generation);
6472 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6473 inode->i_mode = le16_to_cpu(fe->i_mode);
6474 - inode->i_uid = le32_to_cpu(fe->i_uid);
6475 - inode->i_gid = le32_to_cpu(fe->i_gid);
6476 + uid = le32_to_cpu(fe->i_uid);
6477 + gid = le32_to_cpu(fe->i_gid);
6478 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6479 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6480 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6481 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6483 /* Fast symlinks will have i_size but no allocated clusters. */
6484 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6485 diff -NurpP --minimal linux-2.6.38.3/fs/ocfs2/inode.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/inode.h
6486 --- linux-2.6.38.3/fs/ocfs2/inode.h 2011-01-05 21:50:26.000000000 +0100
6487 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/inode.h 2011-01-29 02:01:07.000000000 +0100
6488 @@ -151,6 +151,7 @@ struct buffer_head *ocfs2_bread(struct i
6490 void ocfs2_set_inode_flags(struct inode *inode);
6491 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6492 +int ocfs2_sync_flags(struct inode *inode, int, int);
6494 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6496 diff -NurpP --minimal linux-2.6.38.3/fs/ocfs2/ioctl.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/ioctl.c
6497 --- linux-2.6.38.3/fs/ocfs2/ioctl.c 2011-01-05 21:50:26.000000000 +0100
6498 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/ioctl.c 2011-01-29 02:01:07.000000000 +0100
6499 @@ -63,7 +63,41 @@ static int ocfs2_get_inode_attr(struct i
6503 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6504 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6506 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6507 + struct buffer_head *bh = NULL;
6508 + handle_t *handle = NULL;
6511 + status = ocfs2_inode_lock(inode, &bh, 1);
6513 + mlog_errno(status);
6516 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6517 + if (IS_ERR(handle)) {
6518 + status = PTR_ERR(handle);
6519 + mlog_errno(status);
6523 + inode->i_flags = flags;
6524 + inode->i_vflags = vflags;
6525 + ocfs2_get_inode_flags(OCFS2_I(inode));
6527 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6529 + mlog_errno(status);
6531 + ocfs2_commit_trans(osb, handle);
6533 + ocfs2_inode_unlock(inode, 1);
6538 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6541 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6542 @@ -88,6 +122,11 @@ static int ocfs2_set_inode_attr(struct i
6543 if (!S_ISDIR(inode->i_mode))
6544 flags &= ~OCFS2_DIRSYNC_FL;
6546 + if (IS_BARRIER(inode)) {
6547 + vxwprintk_task(1, "messing with the barrier.");
6551 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6552 if (IS_ERR(handle)) {
6553 status = PTR_ERR(handle);
6554 @@ -451,6 +490,7 @@ bail:
6559 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6561 struct inode *inode = filp->f_path.dentry->d_inode;
6562 diff -NurpP --minimal linux-2.6.38.3/fs/ocfs2/namei.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/namei.c
6563 --- linux-2.6.38.3/fs/ocfs2/namei.c 2011-03-15 18:07:33.000000000 +0100
6564 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/namei.c 2011-01-29 02:01:07.000000000 +0100
6566 #include <linux/slab.h>
6567 #include <linux/highmem.h>
6568 #include <linux/quotaops.h>
6569 +#include <linux/vs_tag.h>
6571 #define MLOG_MASK_PREFIX ML_NAMEI
6572 #include <cluster/masklog.h>
6573 @@ -485,6 +486,7 @@ static int __ocfs2_mknod_locked(struct i
6574 struct ocfs2_dinode *fe = NULL;
6575 struct ocfs2_extent_list *fel;
6581 @@ -522,8 +524,11 @@ static int __ocfs2_mknod_locked(struct i
6582 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
6583 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6584 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6585 - fe->i_uid = cpu_to_le32(inode->i_uid);
6586 - fe->i_gid = cpu_to_le32(inode->i_gid);
6588 + tag = dx_current_fstag(osb->sb);
6589 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6590 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6591 + inode->i_tag = tag;
6592 fe->i_mode = cpu_to_le16(inode->i_mode);
6593 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6594 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6595 diff -NurpP --minimal linux-2.6.38.3/fs/ocfs2/ocfs2.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/ocfs2.h
6596 --- linux-2.6.38.3/fs/ocfs2/ocfs2.h 2011-03-15 18:07:33.000000000 +0100
6597 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/ocfs2.h 2011-01-29 02:01:07.000000000 +0100
6598 @@ -267,6 +267,7 @@ enum ocfs2_mount_options
6600 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
6601 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
6602 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
6605 #define OCFS2_OSB_SOFT_RO 0x0001
6606 diff -NurpP --minimal linux-2.6.38.3/fs/ocfs2/ocfs2_fs.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/ocfs2_fs.h
6607 --- linux-2.6.38.3/fs/ocfs2/ocfs2_fs.h 2011-01-05 21:50:26.000000000 +0100
6608 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/ocfs2_fs.h 2011-01-29 02:01:07.000000000 +0100
6609 @@ -266,6 +266,11 @@
6610 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
6611 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
6613 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6615 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6616 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6618 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
6619 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
6621 diff -NurpP --minimal linux-2.6.38.3/fs/ocfs2/super.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/super.c
6622 --- linux-2.6.38.3/fs/ocfs2/super.c 2011-03-15 18:07:33.000000000 +0100
6623 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/ocfs2/super.c 2011-03-07 16:53:27.000000000 +0100
6624 @@ -181,6 +181,7 @@ enum {
6628 + Opt_tag, Opt_notag, Opt_tagid,
6632 @@ -212,6 +213,9 @@ static const match_table_t tokens = {
6633 {Opt_coherency_full, "coherency=full"},
6634 {Opt_resv_level, "resv_level=%u"},
6635 {Opt_dir_resv_level, "dir_resv_level=%u"},
6637 + {Opt_notag, "notag"},
6638 + {Opt_tagid, "tagid=%u"},
6642 @@ -666,6 +670,13 @@ static int ocfs2_remount(struct super_bl
6646 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6647 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6649 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6653 /* We're going to/from readonly mode. */
6654 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
6655 /* Disable quota accounting before remounting RO */
6656 @@ -1183,6 +1194,9 @@ static int ocfs2_fill_super(struct super
6658 ocfs2_complete_mount_recovery(osb);
6660 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6661 + sb->s_flags |= MS_TAGGED;
6663 if (ocfs2_mount_local(osb))
6664 snprintf(nodestr, sizeof(nodestr), "local");
6666 @@ -1514,6 +1528,20 @@ static int ocfs2_parse_options(struct su
6667 option < OCFS2_MAX_RESV_LEVEL)
6668 mopt->dir_resv_level = option;
6670 +#ifndef CONFIG_TAGGING_NONE
6672 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6675 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6678 +#ifdef CONFIG_PROPAGATE
6681 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6686 "Unrecognized mount option \"%s\" "
6687 diff -NurpP --minimal linux-2.6.38.3/fs/open.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/open.c
6688 --- linux-2.6.38.3/fs/open.c 2011-03-15 18:07:33.000000000 +0100
6689 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/open.c 2011-03-15 18:15:06.000000000 +0100
6691 #include <linux/fs_struct.h>
6692 #include <linux/ima.h>
6693 #include <linux/dnotify.h>
6694 +#include <linux/vs_base.h>
6695 +#include <linux/vs_limit.h>
6696 +#include <linux/vs_tag.h>
6697 +#include <linux/vs_cowbl.h>
6698 +#include <linux/vserver/dlimit.h>
6700 #include "internal.h"
6702 @@ -494,6 +499,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6703 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6707 +#ifdef CONFIG_VSERVER_COWBL
6708 + error = cow_check_and_break(&path);
6710 + goto dput_and_out;
6712 inode = path.dentry->d_inode;
6714 error = mnt_want_write(path.mnt);
6715 @@ -531,11 +542,11 @@ static int chown_common(struct path *pat
6716 newattrs.ia_valid = ATTR_CTIME;
6717 if (user != (uid_t) -1) {
6718 newattrs.ia_valid |= ATTR_UID;
6719 - newattrs.ia_uid = user;
6720 + newattrs.ia_uid = dx_map_uid(user);
6722 if (group != (gid_t) -1) {
6723 newattrs.ia_valid |= ATTR_GID;
6724 - newattrs.ia_gid = group;
6725 + newattrs.ia_gid = dx_map_gid(group);
6727 if (!S_ISDIR(inode->i_mode))
6728 newattrs.ia_valid |=
6729 @@ -560,6 +571,10 @@ SYSCALL_DEFINE3(chown, const char __user
6730 error = mnt_want_write(path.mnt);
6733 +#ifdef CONFIG_VSERVER_COWBL
6734 + error = cow_check_and_break(&path);
6737 error = chown_common(&path, user, group);
6738 mnt_drop_write(path.mnt);
6740 @@ -585,6 +600,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6741 error = mnt_want_write(path.mnt);
6744 +#ifdef CONFIG_VSERVER_COWBL
6745 + error = cow_check_and_break(&path);
6748 error = chown_common(&path, user, group);
6749 mnt_drop_write(path.mnt);
6751 @@ -604,6 +623,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6752 error = mnt_want_write(path.mnt);
6755 +#ifdef CONFIG_VSERVER_COWBL
6756 + error = cow_check_and_break(&path);
6759 error = chown_common(&path, user, group);
6760 mnt_drop_write(path.mnt);
6762 @@ -852,6 +875,7 @@ static void __put_unused_fd(struct files
6763 __FD_CLR(fd, fdt->open_fds);
6764 if (fd < files->next_fd)
6765 files->next_fd = fd;
6766 + vx_openfd_dec(fd);
6769 void put_unused_fd(unsigned int fd)
6770 diff -NurpP --minimal linux-2.6.38.3/fs/proc/array.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/array.c
6771 --- linux-2.6.38.3/fs/proc/array.c 2011-04-15 10:30:30.000000000 +0200
6772 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/array.c 2011-03-28 15:00:13.000000000 +0200
6774 #include <linux/pid_namespace.h>
6775 #include <linux/ptrace.h>
6776 #include <linux/tracehook.h>
6777 +#include <linux/vs_context.h>
6778 +#include <linux/vs_network.h>
6780 #include <asm/pgtable.h>
6781 #include <asm/processor.h>
6782 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
6784 ppid = pid_alive(p) ?
6785 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6786 + if (unlikely(vx_current_initpid(p->pid)))
6791 struct task_struct *tracer = tracehook_tracer_task(p);
6792 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6795 static void render_cap_t(struct seq_file *m, const char *header,
6797 + struct vx_info *vxi, kernel_cap_t *a)
6801 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6802 cap_bset = cred->cap_bset;
6805 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6806 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6807 - render_cap_t(m, "CapEff:\t", &cap_effective);
6808 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6809 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6810 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6811 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6812 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6813 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6816 static inline void task_context_switch_counts(struct seq_file *m,
6817 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6821 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6822 + struct pid *pid, struct task_struct *task)
6824 + seq_printf(m, "Proxy:\t%p(%c)\n"
6832 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6833 + atomic_read(&task->nsproxy->count),
6834 + task->nsproxy->uts_ns,
6835 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6836 + task->nsproxy->ipc_ns,
6837 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6838 + task->nsproxy->mnt_ns,
6839 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6840 + task->nsproxy->pid_ns,
6841 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6842 + task->nsproxy->net_ns,
6843 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6847 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6849 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6852 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6853 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6857 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6858 struct pid *pid, struct task_struct *task)
6860 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6862 task_cpus_allowed(m, task);
6863 cpuset_task_status_allowed(m, task);
6864 + task_vs_id(m, task);
6865 task_context_switch_counts(m, task);
6868 @@ -462,6 +505,17 @@ static int do_task_stat(struct seq_file
6869 /* convert nsec -> ticks */
6870 start_time = nsec_to_clock_t(start_time);
6872 + /* fixup start time for virt uptime */
6873 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6874 + unsigned long long bias =
6875 + current->vx_info->cvirt.bias_clock;
6877 + if (start_time > bias)
6878 + start_time -= bias;
6883 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6884 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6885 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6886 diff -NurpP --minimal linux-2.6.38.3/fs/proc/base.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/base.c
6887 --- linux-2.6.38.3/fs/proc/base.c 2011-03-15 18:07:33.000000000 +0100
6888 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/base.c 2011-03-15 18:15:06.000000000 +0100
6890 #include <linux/pid_namespace.h>
6891 #include <linux/fs_struct.h>
6892 #include <linux/slab.h>
6893 +#include <linux/vs_context.h>
6894 +#include <linux/vs_network.h>
6895 #include "internal.h"
6898 @@ -1043,11 +1045,16 @@ static ssize_t oom_adjust_write(struct f
6902 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6903 + if (oom_adjust < task->signal->oom_adj &&
6904 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6909 + /* prevent guest processes from circumventing the oom killer */
6910 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6911 + oom_adjust = OOM_ADJUST_MIN;
6913 if (oom_adjust != task->signal->oom_adj) {
6914 if (oom_adjust == OOM_DISABLE)
6915 atomic_inc(&task->mm->oom_disable_count);
6916 @@ -1216,7 +1223,7 @@ static ssize_t proc_loginuid_write(struc
6920 - if (!capable(CAP_AUDIT_CONTROL))
6921 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6925 @@ -1715,6 +1722,8 @@ static struct inode *proc_pid_make_inode
6926 inode->i_gid = cred->egid;
6929 + /* procfs is xid tagged */
6930 + inode->i_tag = (tag_t)vx_task_xid(task);
6931 security_task_to_inode(task, inode);
6934 @@ -1751,6 +1760,8 @@ static int pid_getattr(struct vfsmount *
6938 +static unsigned name_to_int(struct dentry *dentry);
6941 * Exceptional case: normally we are not allowed to unhash a busy
6942 * directory. In this case, however, we can do it - no aliasing problems
6943 @@ -1779,6 +1790,12 @@ static int pid_revalidate(struct dentry
6944 task = get_proc_task(inode);
6947 + unsigned pid = name_to_int(dentry);
6949 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6950 + put_task_struct(task);
6953 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6954 task_dumpable(task)) {
6956 @@ -1795,6 +1812,7 @@ static int pid_revalidate(struct dentry
6957 put_task_struct(task);
6964 @@ -2283,6 +2301,13 @@ static struct dentry *proc_pident_lookup
6968 + /* TODO: maybe we can come up with a generic approach? */
6969 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6970 + (dentry->d_name.len == 5) &&
6971 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6972 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6976 * Yes, it does not scale. And it should not. Don't add
6977 * new entries into /proc/<tgid>/ without very good reasons.
6978 @@ -2668,7 +2693,7 @@ out_iput:
6979 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6981 struct dentry *error;
6982 - struct task_struct *task = get_proc_task(dir);
6983 + struct task_struct *task = get_proc_task_real(dir);
6984 const struct pid_entry *p, *last;
6986 error = ERR_PTR(-ENOENT);
6987 @@ -2758,6 +2783,9 @@ static int proc_pid_personality(struct s
6988 static const struct file_operations proc_task_operations;
6989 static const struct inode_operations proc_task_inode_operations;
6991 +extern int proc_pid_vx_info(struct task_struct *, char *);
6992 +extern int proc_pid_nx_info(struct task_struct *, char *);
6994 static const struct pid_entry tgid_base_stuff[] = {
6995 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6996 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6997 @@ -2820,6 +2848,8 @@ static const struct pid_entry tgid_base_
6998 #ifdef CONFIG_CGROUPS
6999 REG("cgroup", S_IRUGO, proc_cgroup_operations),
7001 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
7002 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
7003 INF("oom_score", S_IRUGO, proc_oom_score),
7004 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
7005 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
7006 @@ -2836,6 +2866,7 @@ static const struct pid_entry tgid_base_
7007 #ifdef CONFIG_TASK_IO_ACCOUNTING
7008 INF("io", S_IRUGO, proc_tgid_io_accounting),
7010 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
7013 static int proc_tgid_base_readdir(struct file * filp,
7014 @@ -3028,7 +3059,7 @@ retry:
7016 pid = find_ge_pid(iter.tgid, ns);
7018 - iter.tgid = pid_nr_ns(pid, ns);
7019 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
7020 iter.task = pid_task(pid, PIDTYPE_PID);
7021 /* What we to know is if the pid we have find is the
7022 * pid of a thread_group_leader. Testing for task
7023 @@ -3058,7 +3089,7 @@ static int proc_pid_fill_cache(struct fi
7024 struct tgid_iter iter)
7026 char name[PROC_NUMBUF];
7027 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
7028 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
7029 return proc_fill_cache(filp, dirent, filldir, name, len,
7030 proc_pid_instantiate, iter.task, NULL);
7032 @@ -3067,7 +3098,7 @@ static int proc_pid_fill_cache(struct fi
7033 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
7035 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
7036 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
7037 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
7038 struct tgid_iter iter;
7039 struct pid_namespace *ns;
7041 @@ -3087,6 +3118,8 @@ int proc_pid_readdir(struct file * filp,
7043 iter.tgid += 1, iter = next_tgid(ns, iter)) {
7044 filp->f_pos = iter.tgid + TGID_OFFSET;
7045 + if (!vx_proc_task_visible(iter.task))
7047 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
7048 put_task_struct(iter.task);
7050 @@ -3236,6 +3269,8 @@ static struct dentry *proc_task_lookup(s
7051 tid = name_to_int(dentry);
7054 + if (vx_current_initpid(tid))
7057 ns = dentry->d_sb->s_fs_info;
7059 diff -NurpP --minimal linux-2.6.38.3/fs/proc/generic.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/generic.c
7060 --- linux-2.6.38.3/fs/proc/generic.c 2011-03-15 18:07:33.000000000 +0100
7061 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/generic.c 2011-01-29 02:29:09.000000000 +0100
7063 #include <linux/bitops.h>
7064 #include <linux/spinlock.h>
7065 #include <linux/completion.h>
7066 +#include <linux/vserver/inode.h>
7067 #include <asm/uaccess.h>
7069 #include "internal.h"
7070 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
7071 for (de = de->subdir; de ; de = de->next) {
7072 if (de->namelen != dentry->d_name.len)
7074 + if (!vx_hide_check(0, de->vx_flags))
7076 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
7078 spin_unlock(&proc_subdir_lock);
7080 inode = proc_get_inode(dir->i_sb, de);
7081 + /* generic proc entries belong to the host */
7086 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
7088 /* filldir passes info to user space */
7090 + if (!vx_hide_check(0, de->vx_flags))
7092 spin_unlock(&proc_subdir_lock);
7093 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
7094 de->low_ino, de->mode >> 12) < 0) {
7095 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
7098 spin_lock(&proc_subdir_lock);
7103 @@ -627,6 +635,7 @@ static struct proc_dir_entry *__proc_cre
7105 atomic_set(&ent->count, 1);
7107 + ent->vx_flags = IATTR_PROC_DEFAULT;
7108 spin_lock_init(&ent->pde_unload_lock);
7109 ent->pde_unload_completion = NULL;
7110 INIT_LIST_HEAD(&ent->pde_openers);
7111 @@ -650,7 +659,8 @@ struct proc_dir_entry *proc_symlink(cons
7117 + ent->vx_flags = IATTR_PROC_SYMLINK;
7121 diff -NurpP --minimal linux-2.6.38.3/fs/proc/inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/inode.c
7122 --- linux-2.6.38.3/fs/proc/inode.c 2011-03-15 18:07:33.000000000 +0100
7123 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/inode.c 2011-03-15 18:15:06.000000000 +0100
7124 @@ -437,6 +437,8 @@ struct inode *proc_get_inode(struct supe
7125 inode->i_uid = de->uid;
7126 inode->i_gid = de->gid;
7129 + PROC_I(inode)->vx_flags = de->vx_flags;
7131 inode->i_size = de->size;
7133 diff -NurpP --minimal linux-2.6.38.3/fs/proc/internal.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/internal.h
7134 --- linux-2.6.38.3/fs/proc/internal.h 2011-03-15 18:07:33.000000000 +0100
7135 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/internal.h 2011-01-29 02:01:07.000000000 +0100
7139 #include <linux/proc_fs.h>
7140 +#include <linux/vs_pid.h>
7142 extern struct proc_dir_entry proc_root;
7143 #ifdef CONFIG_PROC_SYSCTL
7144 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
7145 struct pid *pid, struct task_struct *task);
7146 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7147 struct pid *pid, struct task_struct *task);
7148 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7149 + struct pid *pid, struct task_struct *task);
7151 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7153 extern const struct file_operations proc_maps_operations;
7154 @@ -68,11 +72,16 @@ static inline struct pid *proc_pid(struc
7155 return PROC_I(inode)->pid;
7158 -static inline struct task_struct *get_proc_task(struct inode *inode)
7159 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7161 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7164 +static inline struct task_struct *get_proc_task(struct inode *inode)
7166 + return vx_get_proc_task(inode, proc_pid(inode));
7169 static inline int proc_fd(struct inode *inode)
7171 return PROC_I(inode)->fd;
7172 diff -NurpP --minimal linux-2.6.38.3/fs/proc/loadavg.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/loadavg.c
7173 --- linux-2.6.38.3/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
7174 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/loadavg.c 2011-01-29 02:01:07.000000000 +0100
7177 static int loadavg_proc_show(struct seq_file *m, void *v)
7179 + unsigned long running;
7180 + unsigned int threads;
7181 unsigned long avnrun[3];
7183 get_avenrun(avnrun, FIXED_1/200, 0);
7185 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7186 + struct vx_info *vxi = current_vx_info();
7188 + running = atomic_read(&vxi->cvirt.nr_running);
7189 + threads = atomic_read(&vxi->cvirt.nr_threads);
7191 + running = nr_running();
7192 + threads = nr_threads;
7195 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
7196 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
7197 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
7198 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
7199 - nr_running(), nr_threads,
7201 task_active_pid_ns(current)->last_pid);
7204 diff -NurpP --minimal linux-2.6.38.3/fs/proc/meminfo.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/meminfo.c
7205 --- linux-2.6.38.3/fs/proc/meminfo.c 2011-03-15 18:07:33.000000000 +0100
7206 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/meminfo.c 2011-01-29 02:01:07.000000000 +0100
7207 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
7208 allowed = ((totalram_pages - hugetlb_total_pages())
7209 * sysctl_overcommit_ratio / 100) + total_swap_pages;
7211 - cached = global_page_state(NR_FILE_PAGES) -
7212 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
7213 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
7214 total_swapcache_pages - i.bufferram;
7217 diff -NurpP --minimal linux-2.6.38.3/fs/proc/root.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/root.c
7218 --- linux-2.6.38.3/fs/proc/root.c 2011-01-05 21:50:26.000000000 +0100
7219 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/root.c 2011-01-29 02:01:07.000000000 +0100
7221 #include <linux/bitops.h>
7222 #include <linux/mount.h>
7223 #include <linux/pid_namespace.h>
7224 +#include <linux/vserver/inode.h>
7226 #include "internal.h"
7228 +struct proc_dir_entry *proc_virtual;
7230 +extern void proc_vx_init(void);
7232 static int proc_test_super(struct super_block *sb, void *data)
7234 return sb->s_fs_info == data;
7235 @@ -134,6 +139,7 @@ void __init proc_root_init(void)
7237 proc_mkdir("bus", NULL);
7242 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7243 @@ -202,6 +208,7 @@ struct proc_dir_entry proc_root = {
7244 .proc_iops = &proc_root_inode_operations,
7245 .proc_fops = &proc_root_operations,
7246 .parent = &proc_root,
7247 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7250 int pid_ns_prepare_proc(struct pid_namespace *ns)
7251 diff -NurpP --minimal linux-2.6.38.3/fs/proc/uptime.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/uptime.c
7252 --- linux-2.6.38.3/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
7253 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/proc/uptime.c 2011-01-29 02:01:07.000000000 +0100
7255 #include <linux/sched.h>
7256 #include <linux/seq_file.h>
7257 #include <linux/time.h>
7258 -#include <linux/kernel_stat.h>
7259 +#include <linux/vserver/cvirt.h>
7260 #include <asm/cputime.h>
7262 static int uptime_proc_show(struct seq_file *m, void *v)
7264 struct timespec uptime;
7265 struct timespec idle;
7267 - cputime_t idletime = cputime_zero;
7269 - for_each_possible_cpu(i)
7270 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
7271 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
7273 do_posix_clock_monotonic_gettime(&uptime);
7274 monotonic_to_bootbased(&uptime);
7275 cputime_to_timespec(idletime, &idle);
7277 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7278 + vx_vsi_uptime(&uptime, &idle);
7280 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
7281 (unsigned long) uptime.tv_sec,
7282 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7283 diff -NurpP --minimal linux-2.6.38.3/fs/quota/dquot.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/quota/dquot.c
7284 --- linux-2.6.38.3/fs/quota/dquot.c 2011-04-15 10:30:30.000000000 +0200
7285 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/quota/dquot.c 2011-04-15 10:33:41.000000000 +0200
7286 @@ -1540,6 +1540,9 @@ int __dquot_alloc_space(struct inode *in
7287 int reserve = flags & DQUOT_SPACE_RESERVE;
7288 int nofail = flags & DQUOT_SPACE_NOFAIL;
7290 + if ((ret = dl_alloc_space(inode, number)))
7294 * First test before acquiring mutex - solves deadlocks when we
7295 * re-enter the quota code and are already holding the mutex
7296 @@ -1594,6 +1597,9 @@ int dquot_alloc_inode(const struct inode
7298 char warntype[MAXQUOTAS];
7300 + if ((ret = dl_alloc_inode(inode)))
7303 /* First test before acquiring mutex - solves deadlocks when we
7304 * re-enter the quota code and are already holding the mutex */
7305 if (!dquot_active(inode))
7306 @@ -1664,6 +1670,8 @@ void __dquot_free_space(struct inode *in
7307 char warntype[MAXQUOTAS];
7308 int reserve = flags & DQUOT_SPACE_RESERVE;
7310 + dl_free_space(inode, number);
7312 /* First test before acquiring mutex - solves deadlocks when we
7313 * re-enter the quota code and are already holding the mutex */
7314 if (!dquot_active(inode)) {
7315 @@ -1702,6 +1710,8 @@ void dquot_free_inode(const struct inode
7317 char warntype[MAXQUOTAS];
7319 + dl_free_inode(inode);
7321 /* First test before acquiring mutex - solves deadlocks when we
7322 * re-enter the quota code and are already holding the mutex */
7323 if (!dquot_active(inode))
7324 diff -NurpP --minimal linux-2.6.38.3/fs/quota/quota.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/quota/quota.c
7325 --- linux-2.6.38.3/fs/quota/quota.c 2011-03-15 18:07:34.000000000 +0100
7326 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/quota/quota.c 2011-01-29 02:01:07.000000000 +0100
7328 #include <linux/fs.h>
7329 #include <linux/namei.h>
7330 #include <linux/slab.h>
7331 +#include <linux/vs_context.h>
7332 #include <asm/current.h>
7333 #include <asm/uaccess.h>
7334 #include <linux/kernel.h>
7335 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
7339 - if (!capable(CAP_SYS_ADMIN))
7340 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7344 @@ -293,6 +294,46 @@ static int do_quotactl(struct super_bloc
7348 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7350 +#include <linux/vroot.h>
7351 +#include <linux/major.h>
7352 +#include <linux/module.h>
7353 +#include <linux/kallsyms.h>
7354 +#include <linux/vserver/debug.h>
7356 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7358 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7360 +int register_vroot_grb(vroot_grb_func *func) {
7363 + spin_lock(&vroot_grb_lock);
7364 + if (!vroot_get_real_bdev) {
7365 + vroot_get_real_bdev = func;
7368 + spin_unlock(&vroot_grb_lock);
7371 +EXPORT_SYMBOL(register_vroot_grb);
7373 +int unregister_vroot_grb(vroot_grb_func *func) {
7374 + int ret = -EINVAL;
7376 + spin_lock(&vroot_grb_lock);
7377 + if (vroot_get_real_bdev) {
7378 + vroot_get_real_bdev = NULL;
7381 + spin_unlock(&vroot_grb_lock);
7384 +EXPORT_SYMBOL(unregister_vroot_grb);
7389 * look up a superblock on which quota ops will be performed
7390 * - use the name of a block device to find the superblock thereon
7391 @@ -310,6 +351,22 @@ static struct super_block *quotactl_bloc
7394 return ERR_CAST(bdev);
7395 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7396 + if (bdev && bdev->bd_inode &&
7397 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7398 + struct block_device *bdnew = (void *)-EINVAL;
7400 + if (vroot_get_real_bdev)
7401 + bdnew = vroot_get_real_bdev(bdev);
7403 + vxdprintk(VXD_CBIT(misc, 0),
7404 + "vroot_get_real_bdev not set");
7406 + if (IS_ERR(bdnew))
7407 + return ERR_PTR(PTR_ERR(bdnew));
7411 sb = get_super(bdev);
7414 diff -NurpP --minimal linux-2.6.38.3/fs/reiserfs/file.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/reiserfs/file.c
7415 --- linux-2.6.38.3/fs/reiserfs/file.c 2011-01-05 21:50:26.000000000 +0100
7416 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/reiserfs/file.c 2011-01-29 02:01:07.000000000 +0100
7417 @@ -312,4 +312,5 @@ const struct inode_operations reiserfs_f
7418 .listxattr = reiserfs_listxattr,
7419 .removexattr = reiserfs_removexattr,
7420 .permission = reiserfs_permission,
7421 + .sync_flags = reiserfs_sync_flags,
7423 diff -NurpP --minimal linux-2.6.38.3/fs/reiserfs/inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/reiserfs/inode.c
7424 --- linux-2.6.38.3/fs/reiserfs/inode.c 2011-01-05 21:50:26.000000000 +0100
7425 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/reiserfs/inode.c 2011-01-29 02:01:07.000000000 +0100
7427 #include <linux/writeback.h>
7428 #include <linux/quotaops.h>
7429 #include <linux/swap.h>
7430 +#include <linux/vs_tag.h>
7432 int reiserfs_commit_write(struct file *f, struct page *page,
7433 unsigned from, unsigned to);
7434 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
7435 struct buffer_head *bh;
7436 struct item_head *ih;
7440 //int version = ITEM_VERSION_1;
7442 bh = PATH_PLAST_BUFFER(path);
7443 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
7444 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7445 unsigned long blocks;
7447 + uid = sd_v1_uid(sd);
7448 + gid = sd_v1_gid(sd);
7450 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7451 set_inode_sd_version(inode, STAT_DATA_V1);
7452 inode->i_mode = sd_v1_mode(sd);
7453 inode->i_nlink = sd_v1_nlink(sd);
7454 - inode->i_uid = sd_v1_uid(sd);
7455 - inode->i_gid = sd_v1_gid(sd);
7456 inode->i_size = sd_v1_size(sd);
7457 inode->i_atime.tv_sec = sd_v1_atime(sd);
7458 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7459 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
7460 // (directories and symlinks)
7461 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7463 + uid = sd_v2_uid(sd);
7464 + gid = sd_v2_gid(sd);
7466 inode->i_mode = sd_v2_mode(sd);
7467 inode->i_nlink = sd_v2_nlink(sd);
7468 - inode->i_uid = sd_v2_uid(sd);
7469 inode->i_size = sd_v2_size(sd);
7470 - inode->i_gid = sd_v2_gid(sd);
7471 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7472 inode->i_atime.tv_sec = sd_v2_atime(sd);
7473 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7474 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
7475 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7478 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7479 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7480 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7483 if (S_ISREG(inode->i_mode)) {
7484 inode->i_op = &reiserfs_file_inode_operations;
7485 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
7486 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7488 struct stat_data *sd_v2 = (struct stat_data *)sd;
7489 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7490 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7493 + set_sd_v2_uid(sd_v2, uid);
7494 + set_sd_v2_gid(sd_v2, gid);
7495 set_sd_v2_mode(sd_v2, inode->i_mode);
7496 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7497 - set_sd_v2_uid(sd_v2, inode->i_uid);
7498 set_sd_v2_size(sd_v2, size);
7499 - set_sd_v2_gid(sd_v2, inode->i_gid);
7500 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7501 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7502 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7503 @@ -2858,14 +2869,19 @@ int reiserfs_commit_write(struct file *f
7504 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7506 if (reiserfs_attrs(inode->i_sb)) {
7507 - if (sd_attrs & REISERFS_SYNC_FL)
7508 - inode->i_flags |= S_SYNC;
7510 - inode->i_flags &= ~S_SYNC;
7511 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7512 inode->i_flags |= S_IMMUTABLE;
7514 inode->i_flags &= ~S_IMMUTABLE;
7515 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7516 + inode->i_flags |= S_IXUNLINK;
7518 + inode->i_flags &= ~S_IXUNLINK;
7520 + if (sd_attrs & REISERFS_SYNC_FL)
7521 + inode->i_flags |= S_SYNC;
7523 + inode->i_flags &= ~S_SYNC;
7524 if (sd_attrs & REISERFS_APPEND_FL)
7525 inode->i_flags |= S_APPEND;
7527 @@ -2878,6 +2894,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7528 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7530 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7532 + if (sd_attrs & REISERFS_BARRIER_FL)
7533 + inode->i_vflags |= V_BARRIER;
7535 + inode->i_vflags &= ~V_BARRIER;
7536 + if (sd_attrs & REISERFS_COW_FL)
7537 + inode->i_vflags |= V_COW;
7539 + inode->i_vflags &= ~V_COW;
7543 @@ -2888,6 +2913,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7544 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7546 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7547 + if (inode->i_flags & S_IXUNLINK)
7548 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7550 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7552 if (inode->i_flags & S_SYNC)
7553 *sd_attrs |= REISERFS_SYNC_FL;
7555 @@ -2900,6 +2930,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7556 *sd_attrs |= REISERFS_NOTAIL_FL;
7558 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7560 + if (inode->i_vflags & V_BARRIER)
7561 + *sd_attrs |= REISERFS_BARRIER_FL;
7563 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7564 + if (inode->i_vflags & V_COW)
7565 + *sd_attrs |= REISERFS_COW_FL;
7567 + *sd_attrs &= ~REISERFS_COW_FL;
7571 @@ -3143,7 +3182,8 @@ int reiserfs_setattr(struct dentry *dent
7574 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7575 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7576 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7577 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7578 struct reiserfs_transaction_handle th;
7581 @@ -3172,6 +3212,9 @@ int reiserfs_setattr(struct dentry *dent
7582 inode->i_uid = attr->ia_uid;
7583 if (attr->ia_valid & ATTR_GID)
7584 inode->i_gid = attr->ia_gid;
7585 + if ((attr->ia_valid & ATTR_TAG) &&
7587 + inode->i_tag = attr->ia_tag;
7588 mark_inode_dirty(inode);
7589 error = journal_end(&th, inode->i_sb, jbegin_count);
7591 diff -NurpP --minimal linux-2.6.38.3/fs/reiserfs/ioctl.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/reiserfs/ioctl.c
7592 --- linux-2.6.38.3/fs/reiserfs/ioctl.c 2011-01-05 21:50:26.000000000 +0100
7593 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/reiserfs/ioctl.c 2011-01-29 02:01:07.000000000 +0100
7595 #include <linux/pagemap.h>
7596 #include <linux/compat.h>
7599 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7601 + __u16 sd_attrs = 0;
7603 + inode->i_flags = flags;
7604 + inode->i_vflags = vflags;
7606 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7607 + REISERFS_I(inode)->i_attrs = sd_attrs;
7608 + inode->i_ctime = CURRENT_TIME_SEC;
7609 + mark_inode_dirty(inode);
7614 * reiserfs_ioctl - handler for ioctl for inode
7615 * supported commands:
7617 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7619 struct inode *inode = filp->f_path.dentry->d_inode;
7620 - unsigned int flags;
7621 + unsigned int flags, oldflags;
7624 reiserfs_write_lock(inode->i_sb);
7625 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7627 flags = REISERFS_I(inode)->i_attrs;
7628 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7629 + flags &= REISERFS_FL_USER_VISIBLE;
7630 err = put_user(flags, (int __user *)arg);
7632 case REISERFS_IOC_SETFLAGS:{
7633 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7637 + if (IS_BARRIER(inode)) {
7638 + vxwprintk_task(1, "messing with the barrier.");
7642 * Is it quota file? Do not allow user to mess with it
7644 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7649 + oldflags = REISERFS_I(inode)->i_attrs;
7650 + flags &= REISERFS_FL_USER_MODIFIABLE;
7651 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7652 sd_attrs_to_i_attrs(flags, inode);
7653 REISERFS_I(inode)->i_attrs = flags;
7654 inode->i_ctime = CURRENT_TIME_SEC;
7655 diff -NurpP --minimal linux-2.6.38.3/fs/reiserfs/namei.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/reiserfs/namei.c
7656 --- linux-2.6.38.3/fs/reiserfs/namei.c 2011-03-15 18:07:34.000000000 +0100
7657 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/reiserfs/namei.c 2011-03-10 17:21:19.000000000 +0100
7659 #include <linux/reiserfs_acl.h>
7660 #include <linux/reiserfs_xattr.h>
7661 #include <linux/quotaops.h>
7662 +#include <linux/vs_tag.h>
7664 #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; }
7665 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7666 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7667 if (retval == IO_ERROR) {
7668 return ERR_PTR(-EIO);
7670 + dx_propagate_tag(nd, inode);
7672 return d_splice_alias(inode, dentry);
7674 @@ -1532,6 +1534,7 @@ const struct inode_operations reiserfs_d
7675 .listxattr = reiserfs_listxattr,
7676 .removexattr = reiserfs_removexattr,
7677 .permission = reiserfs_permission,
7678 + .sync_flags = reiserfs_sync_flags,
7682 diff -NurpP --minimal linux-2.6.38.3/fs/reiserfs/super.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/reiserfs/super.c
7683 --- linux-2.6.38.3/fs/reiserfs/super.c 2011-03-15 18:07:34.000000000 +0100
7684 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/reiserfs/super.c 2011-01-29 02:01:07.000000000 +0100
7685 @@ -899,6 +899,14 @@ static int reiserfs_parse_options(struct
7686 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7687 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7689 +#ifndef CONFIG_TAGGING_NONE
7690 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7691 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7692 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7694 +#ifdef CONFIG_PROPAGATE
7695 + {"tag",.arg_required = 'T',.values = NULL},
7697 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7698 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7699 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7700 @@ -1208,6 +1216,14 @@ static int reiserfs_remount(struct super
7701 handle_quota_files(s, qf_names, &qfmt);
7704 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7705 + !(s->s_flags & MS_TAGGED)) {
7706 + reiserfs_warning(s, "super-vs01",
7707 + "reiserfs: tagging not permitted on remount.");
7714 /* Add options that are safe here */
7715 @@ -1690,6 +1706,10 @@ static int reiserfs_fill_super(struct su
7719 + /* map mount option tagxid */
7720 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7721 + s->s_flags |= MS_TAGGED;
7723 rs = SB_DISK_SUPER_BLOCK(s);
7724 /* Let's do basic sanity check to verify that underlying device is not
7725 smaller than the filesystem. If the check fails then abort and scream,
7726 diff -NurpP --minimal linux-2.6.38.3/fs/reiserfs/xattr.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/reiserfs/xattr.c
7727 --- linux-2.6.38.3/fs/reiserfs/xattr.c 2011-03-15 18:07:34.000000000 +0100
7728 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/reiserfs/xattr.c 2011-03-15 18:15:06.000000000 +0100
7730 #include <linux/errno.h>
7731 #include <linux/gfp.h>
7732 #include <linux/fs.h>
7733 +#include <linux/mount.h>
7734 #include <linux/file.h>
7735 #include <linux/pagemap.h>
7736 #include <linux/xattr.h>
7737 diff -NurpP --minimal linux-2.6.38.3/fs/stat.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/stat.c
7738 --- linux-2.6.38.3/fs/stat.c 2011-03-15 18:07:34.000000000 +0100
7739 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/stat.c 2011-01-29 02:01:07.000000000 +0100
7740 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7741 stat->nlink = inode->i_nlink;
7742 stat->uid = inode->i_uid;
7743 stat->gid = inode->i_gid;
7744 + stat->tag = inode->i_tag;
7745 stat->rdev = inode->i_rdev;
7746 stat->atime = inode->i_atime;
7747 stat->mtime = inode->i_mtime;
7748 diff -NurpP --minimal linux-2.6.38.3/fs/statfs.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/statfs.c
7749 --- linux-2.6.38.3/fs/statfs.c 2010-10-21 13:07:51.000000000 +0200
7750 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/statfs.c 2011-01-29 02:01:07.000000000 +0100
7752 #include <linux/statfs.h>
7753 #include <linux/security.h>
7754 #include <linux/uaccess.h>
7755 +#include <linux/vs_base.h>
7756 +#include <linux/vs_dlimit.h>
7758 static int flags_by_mnt(int mnt_flags)
7760 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
7761 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7762 if (retval == 0 && buf->f_frsize == 0)
7763 buf->f_frsize = buf->f_bsize;
7764 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7765 + vx_vsi_statfs(dentry->d_sb, buf);
7769 diff -NurpP --minimal linux-2.6.38.3/fs/super.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/super.c
7770 --- linux-2.6.38.3/fs/super.c 2011-04-15 10:30:30.000000000 +0200
7771 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/super.c 2011-03-28 15:01:33.000000000 +0200
7773 #include <linux/mutex.h>
7774 #include <linux/backing-dev.h>
7775 #include <linux/rculist_bl.h>
7776 +#include <linux/devpts_fs.h>
7777 +#include <linux/proc_fs.h>
7778 +#include <linux/vs_context.h>
7779 #include "internal.h"
7782 @@ -964,6 +967,7 @@ struct vfsmount *
7783 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
7785 struct vfsmount *mnt;
7786 + struct super_block *sb;
7787 struct dentry *root;
7788 char *secdata = NULL;
7790 @@ -971,6 +975,11 @@ vfs_kern_mount(struct file_system_type *
7792 return ERR_PTR(-ENODEV);
7795 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
7796 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
7800 mnt = alloc_vfsmnt(name);
7802 @@ -1002,12 +1011,20 @@ vfs_kern_mount(struct file_system_type *
7804 goto out_free_secdata;
7806 - BUG_ON(!mnt->mnt_sb);
7807 - WARN_ON(!mnt->mnt_sb->s_bdi);
7811 + WARN_ON(!sb->s_bdi);
7812 WARN_ON(mnt->mnt_sb->s_bdi == &default_backing_dev_info);
7813 mnt->mnt_sb->s_flags |= MS_BORN;
7815 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
7817 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
7818 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7819 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7822 + error = security_sb_kern_mount(sb, flags, secdata);
7826 diff -NurpP --minimal linux-2.6.38.3/fs/sysfs/mount.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/sysfs/mount.c
7827 --- linux-2.6.38.3/fs/sysfs/mount.c 2011-01-05 21:50:27.000000000 +0100
7828 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/sysfs/mount.c 2011-01-29 02:01:07.000000000 +0100
7829 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7831 sb->s_blocksize = PAGE_CACHE_SIZE;
7832 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7833 - sb->s_magic = SYSFS_MAGIC;
7834 + sb->s_magic = SYSFS_SUPER_MAGIC;
7835 sb->s_op = &sysfs_ops;
7836 sb->s_time_gran = 1;
7838 diff -NurpP --minimal linux-2.6.38.3/fs/utimes.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/utimes.c
7839 --- linux-2.6.38.3/fs/utimes.c 2010-10-21 13:07:51.000000000 +0200
7840 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/utimes.c 2011-01-29 02:01:07.000000000 +0100
7842 #include <linux/stat.h>
7843 #include <linux/utime.h>
7844 #include <linux/syscalls.h>
7845 +#include <linux/mount.h>
7846 +#include <linux/vs_cowbl.h>
7847 #include <asm/uaccess.h>
7848 #include <asm/unistd.h>
7850 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7853 struct iattr newattrs;
7854 - struct inode *inode = path->dentry->d_inode;
7855 + struct inode *inode;
7857 error = mnt_want_write(path->mnt);
7861 + error = cow_check_and_break(path);
7863 + goto mnt_drop_write_and_out;
7865 + inode = path->dentry->d_inode;
7867 if (times && times[0].tv_nsec == UTIME_NOW &&
7868 times[1].tv_nsec == UTIME_NOW)
7870 diff -NurpP --minimal linux-2.6.38.3/fs/xattr.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/xattr.c
7871 --- linux-2.6.38.3/fs/xattr.c 2010-08-02 16:52:52.000000000 +0200
7872 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xattr.c 2011-01-29 02:01:07.000000000 +0100
7874 #include <linux/module.h>
7875 #include <linux/fsnotify.h>
7876 #include <linux/audit.h>
7877 +#include <linux/mount.h>
7878 #include <asm/uaccess.h>
7881 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
7882 * The trusted.* namespace can only be accessed by a privileged user.
7884 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
7885 - return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
7886 + return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
7888 /* In user.* namespace, only regular files and directories can have
7889 * extended attributes. For sticky directories, only the owner and
7890 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/linux-2.6/xfs_ioctl.c
7891 --- linux-2.6.38.3/fs/xfs/linux-2.6/xfs_ioctl.c 2011-03-15 18:07:34.000000000 +0100
7892 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/linux-2.6/xfs_ioctl.c 2011-03-10 17:21:19.000000000 +0100
7894 #include "xfs_bmap_btree.h"
7895 #include "xfs_dinode.h"
7896 #include "xfs_inode.h"
7897 -#include "xfs_ioctl.h"
7898 +// #include "xfs_ioctl.h"
7899 #include "xfs_rtalloc.h"
7900 #include "xfs_itable.h"
7901 #include "xfs_error.h"
7902 @@ -744,6 +744,10 @@ xfs_merge_ioc_xflags(
7903 xflags |= XFS_XFLAG_IMMUTABLE;
7905 xflags &= ~XFS_XFLAG_IMMUTABLE;
7906 + if (flags & FS_IXUNLINK_FL)
7907 + xflags |= XFS_XFLAG_IXUNLINK;
7909 + xflags &= ~XFS_XFLAG_IXUNLINK;
7910 if (flags & FS_APPEND_FL)
7911 xflags |= XFS_XFLAG_APPEND;
7913 @@ -772,6 +776,8 @@ xfs_di2lxflags(
7915 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7916 flags |= FS_IMMUTABLE_FL;
7917 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7918 + flags |= FS_IXUNLINK_FL;
7919 if (di_flags & XFS_DIFLAG_APPEND)
7920 flags |= FS_APPEND_FL;
7921 if (di_flags & XFS_DIFLAG_SYNC)
7922 @@ -832,6 +838,8 @@ xfs_set_diflags(
7923 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7924 if (xflags & XFS_XFLAG_IMMUTABLE)
7925 di_flags |= XFS_DIFLAG_IMMUTABLE;
7926 + if (xflags & XFS_XFLAG_IXUNLINK)
7927 + di_flags |= XFS_DIFLAG_IXUNLINK;
7928 if (xflags & XFS_XFLAG_APPEND)
7929 di_flags |= XFS_DIFLAG_APPEND;
7930 if (xflags & XFS_XFLAG_SYNC)
7931 @@ -874,6 +882,10 @@ xfs_diflags_to_linux(
7932 inode->i_flags |= S_IMMUTABLE;
7934 inode->i_flags &= ~S_IMMUTABLE;
7935 + if (xflags & XFS_XFLAG_IXUNLINK)
7936 + inode->i_flags |= S_IXUNLINK;
7938 + inode->i_flags &= ~S_IXUNLINK;
7939 if (xflags & XFS_XFLAG_APPEND)
7940 inode->i_flags |= S_APPEND;
7942 @@ -1366,10 +1378,18 @@ xfs_file_ioctl(
7943 case XFS_IOC_FSGETXATTRA:
7944 return xfs_ioc_fsgetxattr(ip, 1, arg);
7945 case XFS_IOC_FSSETXATTR:
7946 + if (IS_BARRIER(inode)) {
7947 + vxwprintk_task(1, "messing with the barrier.");
7948 + return -XFS_ERROR(EACCES);
7950 return xfs_ioc_fssetxattr(ip, filp, arg);
7951 case XFS_IOC_GETXFLAGS:
7952 return xfs_ioc_getxflags(ip, arg);
7953 case XFS_IOC_SETXFLAGS:
7954 + if (IS_BARRIER(inode)) {
7955 + vxwprintk_task(1, "messing with the barrier.");
7956 + return -XFS_ERROR(EACCES);
7958 return xfs_ioc_setxflags(ip, filp, arg);
7960 case XFS_IOC_FSSETDM: {
7961 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/linux-2.6/xfs_ioctl.h
7962 --- linux-2.6.38.3/fs/xfs/linux-2.6/xfs_ioctl.h 2010-07-07 18:31:54.000000000 +0200
7963 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/linux-2.6/xfs_ioctl.h 2011-01-29 02:01:07.000000000 +0100
7964 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7965 void __user *uhandle,
7970 + struct inode *inode,
7977 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/linux-2.6/xfs_iops.c
7978 --- linux-2.6.38.3/fs/xfs/linux-2.6/xfs_iops.c 2011-03-15 18:07:34.000000000 +0100
7979 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/linux-2.6/xfs_iops.c 2011-01-29 02:01:07.000000000 +0100
7981 #include "xfs_bmap_btree.h"
7982 #include "xfs_dinode.h"
7983 #include "xfs_inode.h"
7984 +#include "xfs_ioctl.h"
7985 #include "xfs_bmap.h"
7986 #include "xfs_rtalloc.h"
7987 #include "xfs_error.h"
7989 #include <linux/security.h>
7990 #include <linux/fiemap.h>
7991 #include <linux/slab.h>
7992 +#include <linux/vs_tag.h>
7995 * Bring the timestamps in the XFS inode uptodate.
7996 @@ -463,6 +465,7 @@ xfs_vn_getattr(
7997 stat->nlink = ip->i_d.di_nlink;
7998 stat->uid = ip->i_d.di_uid;
7999 stat->gid = ip->i_d.di_gid;
8000 + stat->tag = ip->i_d.di_tag;
8001 stat->ino = ip->i_ino;
8002 stat->atime = inode->i_atime;
8003 stat->mtime = inode->i_mtime;
8004 @@ -598,6 +601,7 @@ static const struct inode_operations xfs
8005 .removexattr = generic_removexattr,
8006 .listxattr = xfs_vn_listxattr,
8007 .fiemap = xfs_vn_fiemap,
8008 + .sync_flags = xfs_sync_flags,
8011 static const struct inode_operations xfs_dir_inode_operations = {
8012 @@ -623,6 +627,7 @@ static const struct inode_operations xfs
8013 .getxattr = generic_getxattr,
8014 .removexattr = generic_removexattr,
8015 .listxattr = xfs_vn_listxattr,
8016 + .sync_flags = xfs_sync_flags,
8019 static const struct inode_operations xfs_dir_ci_inode_operations = {
8020 @@ -672,6 +677,10 @@ xfs_diflags_to_iflags(
8021 inode->i_flags |= S_IMMUTABLE;
8023 inode->i_flags &= ~S_IMMUTABLE;
8024 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
8025 + inode->i_flags |= S_IXUNLINK;
8027 + inode->i_flags &= ~S_IXUNLINK;
8028 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
8029 inode->i_flags |= S_APPEND;
8031 @@ -684,6 +693,15 @@ xfs_diflags_to_iflags(
8032 inode->i_flags |= S_NOATIME;
8034 inode->i_flags &= ~S_NOATIME;
8036 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
8037 + inode->i_vflags |= V_BARRIER;
8039 + inode->i_vflags &= ~V_BARRIER;
8040 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
8041 + inode->i_vflags |= V_COW;
8043 + inode->i_vflags &= ~V_COW;
8047 @@ -715,6 +733,7 @@ xfs_setup_inode(
8048 inode->i_nlink = ip->i_d.di_nlink;
8049 inode->i_uid = ip->i_d.di_uid;
8050 inode->i_gid = ip->i_d.di_gid;
8051 + inode->i_tag = ip->i_d.di_tag;
8053 switch (inode->i_mode & S_IFMT) {
8055 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/linux-2.6/xfs_linux.h
8056 --- linux-2.6.38.3/fs/xfs/linux-2.6/xfs_linux.h 2011-03-15 18:07:34.000000000 +0100
8057 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/linux-2.6/xfs_linux.h 2011-01-29 02:01:07.000000000 +0100
8060 #define current_cpu() (raw_smp_processor_id())
8061 #define current_pid() (current->pid)
8062 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
8063 #define current_test_flags(f) (current->flags & (f))
8064 #define current_set_flags_nested(sp, f) \
8065 (*(sp) = current->flags, current->flags |= (f))
8066 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/linux-2.6/xfs_super.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/linux-2.6/xfs_super.c
8067 --- linux-2.6.38.3/fs/xfs/linux-2.6/xfs_super.c 2011-04-15 10:30:30.000000000 +0200
8068 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/linux-2.6/xfs_super.c 2011-04-15 10:35:15.000000000 +0200
8069 @@ -112,6 +112,9 @@ mempool_t *xfs_ioend_pool;
8070 #define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */
8071 #define MNTOPT_DELAYLOG "delaylog" /* Delayed loging enabled */
8072 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed loging disabled */
8073 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
8074 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
8075 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
8078 * Table driven mount option parser.
8079 @@ -120,10 +123,14 @@ mempool_t *xfs_ioend_pool;
8080 * in the future, too.
8083 + Opt_tag, Opt_notag,
8084 Opt_barrier, Opt_nobarrier, Opt_err
8087 static const match_table_t tokens = {
8088 + {Opt_tag, "tagxid"},
8090 + {Opt_notag, "notag"},
8091 {Opt_barrier, "barrier"},
8092 {Opt_nobarrier, "nobarrier"},
8094 @@ -367,6 +374,19 @@ xfs_parseargs(
8095 } else if (!strcmp(this_char, "irixsgid")) {
8097 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
8098 +#ifndef CONFIG_TAGGING_NONE
8099 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8100 + mp->m_flags |= XFS_MOUNT_TAGGED;
8101 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
8102 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
8103 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
8104 + mp->m_flags |= XFS_MOUNT_TAGGED;
8106 +#ifdef CONFIG_PROPAGATE
8107 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8109 + mp->m_flags |= XFS_MOUNT_TAGGED;
8113 "XFS: unknown mount option [%s].", this_char);
8114 @@ -1327,6 +1347,16 @@ xfs_fs_remount(
8116 mp->m_flags &= ~XFS_MOUNT_BARRIER;
8119 + if (!(sb->s_flags & MS_TAGGED)) {
8121 + "XFS: %s: tagging not permitted on remount.\n",
8130 * Logically we would return an error here to prevent
8131 @@ -1551,6 +1581,9 @@ xfs_fs_fill_super(
8135 + if (mp->m_flags & XFS_MOUNT_TAGGED)
8136 + sb->s_flags |= MS_TAGGED;
8139 * we must configure the block size in the superblock before we run the
8140 * full mount process as the mount process can lookup and cache inodes.
8141 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/xfs_dinode.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_dinode.h
8142 --- linux-2.6.38.3/fs/xfs/xfs_dinode.h 2011-01-05 21:50:28.000000000 +0100
8143 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_dinode.h 2011-01-29 02:01:07.000000000 +0100
8144 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
8145 __be32 di_nlink; /* number of links to file */
8146 __be16 di_projid_lo; /* lower part of owner's project id */
8147 __be16 di_projid_hi; /* higher part owner's project id */
8148 - __u8 di_pad[6]; /* unused, zeroed space */
8149 + __u8 di_pad[2]; /* unused, zeroed space */
8150 + __be16 di_tag; /* context tagging */
8151 + __be16 di_vflags; /* vserver specific flags */
8152 __be16 di_flushiter; /* incremented on flush */
8153 xfs_timestamp_t di_atime; /* time last accessed */
8154 xfs_timestamp_t di_mtime; /* time last modified */
8155 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
8156 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
8157 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
8158 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
8159 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
8161 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
8162 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
8163 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
8164 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
8165 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8166 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8167 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8168 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8170 #ifdef CONFIG_XFS_RT
8171 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8172 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
8173 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8174 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8175 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8176 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8177 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8178 + XFS_DIFLAG_IXUNLINK)
8180 +#define XFS_DIVFLAG_BARRIER 0x01
8181 +#define XFS_DIVFLAG_COW 0x02
8183 #endif /* __XFS_DINODE_H__ */
8184 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/xfs_fs.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_fs.h
8185 --- linux-2.6.38.3/fs/xfs/xfs_fs.h 2011-01-05 21:50:28.000000000 +0100
8186 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_fs.h 2011-01-29 02:01:07.000000000 +0100
8187 @@ -67,6 +67,9 @@ struct fsxattr {
8188 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8189 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8190 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8191 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8192 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8193 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8194 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8197 @@ -297,7 +300,8 @@ typedef struct xfs_bstat {
8198 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
8199 __u16 bs_forkoff; /* inode fork offset in bytes */
8200 __u16 bs_projid_hi; /* higher part of project id */
8201 - unsigned char bs_pad[10]; /* pad space, unused */
8202 + unsigned char bs_pad[8]; /* pad space, unused */
8203 + __u16 bs_tag; /* context tagging */
8204 __u32 bs_dmevmask; /* DMIG event mask */
8205 __u16 bs_dmstate; /* DMIG state info */
8206 __u16 bs_aextents; /* attribute number of extents */
8207 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/xfs_ialloc.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_ialloc.c
8208 --- linux-2.6.38.3/fs/xfs/xfs_ialloc.c 2011-01-05 21:50:28.000000000 +0100
8209 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_ialloc.c 2011-01-29 02:01:07.000000000 +0100
8211 #include "xfs_error.h"
8212 #include "xfs_bmap.h"
8216 * Allocation group level functions.
8218 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/xfs_inode.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_inode.c
8219 --- linux-2.6.38.3/fs/xfs/xfs_inode.c 2011-03-15 18:07:34.000000000 +0100
8220 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_inode.c 2011-01-29 02:01:07.000000000 +0100
8221 @@ -245,6 +245,7 @@ xfs_inotobp(
8225 +#include <linux/vs_tag.h>
8228 * This routine is called to map an inode to the buffer containing
8229 @@ -650,15 +651,25 @@ xfs_iformat_btree(
8231 xfs_dinode_from_disk(
8233 - xfs_dinode_t *from)
8234 + xfs_dinode_t *from,
8237 + uint32_t uid, gid, tag;
8239 to->di_magic = be16_to_cpu(from->di_magic);
8240 to->di_mode = be16_to_cpu(from->di_mode);
8241 to->di_version = from ->di_version;
8242 to->di_format = from->di_format;
8243 to->di_onlink = be16_to_cpu(from->di_onlink);
8244 - to->di_uid = be32_to_cpu(from->di_uid);
8245 - to->di_gid = be32_to_cpu(from->di_gid);
8247 + uid = be32_to_cpu(from->di_uid);
8248 + gid = be32_to_cpu(from->di_gid);
8249 + tag = be16_to_cpu(from->di_tag);
8251 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8252 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8253 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8255 to->di_nlink = be32_to_cpu(from->di_nlink);
8256 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
8257 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
8258 @@ -680,21 +691,26 @@ xfs_dinode_from_disk(
8259 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8260 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8261 to->di_flags = be16_to_cpu(from->di_flags);
8262 + to->di_vflags = be16_to_cpu(from->di_vflags);
8263 to->di_gen = be32_to_cpu(from->di_gen);
8269 - xfs_icdinode_t *from)
8270 + xfs_icdinode_t *from,
8273 to->di_magic = cpu_to_be16(from->di_magic);
8274 to->di_mode = cpu_to_be16(from->di_mode);
8275 to->di_version = from ->di_version;
8276 to->di_format = from->di_format;
8277 to->di_onlink = cpu_to_be16(from->di_onlink);
8278 - to->di_uid = cpu_to_be32(from->di_uid);
8279 - to->di_gid = cpu_to_be32(from->di_gid);
8281 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8282 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8283 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8285 to->di_nlink = cpu_to_be32(from->di_nlink);
8286 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
8287 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
8288 @@ -716,12 +732,14 @@ xfs_dinode_to_disk(
8289 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8290 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8291 to->di_flags = cpu_to_be16(from->di_flags);
8292 + to->di_vflags = cpu_to_be16(from->di_vflags);
8293 to->di_gen = cpu_to_be32(from->di_gen);
8298 - __uint16_t di_flags)
8299 + __uint16_t di_flags,
8300 + __uint16_t di_vflags)
8304 @@ -732,6 +750,8 @@ _xfs_dic2xflags(
8305 flags |= XFS_XFLAG_PREALLOC;
8306 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8307 flags |= XFS_XFLAG_IMMUTABLE;
8308 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8309 + flags |= XFS_XFLAG_IXUNLINK;
8310 if (di_flags & XFS_DIFLAG_APPEND)
8311 flags |= XFS_XFLAG_APPEND;
8312 if (di_flags & XFS_DIFLAG_SYNC)
8313 @@ -756,6 +776,10 @@ _xfs_dic2xflags(
8314 flags |= XFS_XFLAG_FILESTREAM;
8317 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8318 + flags |= FS_BARRIER_FL;
8319 + if (di_vflags & XFS_DIVFLAG_COW)
8320 + flags |= FS_COW_FL;
8324 @@ -765,7 +789,7 @@ xfs_ip2xflags(
8326 xfs_icdinode_t *dic = &ip->i_d;
8328 - return _xfs_dic2xflags(dic->di_flags) |
8329 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8330 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8333 @@ -773,7 +797,8 @@ uint
8337 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8338 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8339 + be16_to_cpu(dip->di_vflags)) |
8340 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8343 @@ -806,7 +831,6 @@ xfs_iread(
8346 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8349 * If we got something that isn't an inode it means someone
8350 * (nfs or dmi) has a stale handle.
8351 @@ -831,7 +855,8 @@ xfs_iread(
8352 * Otherwise, just get the truly permanent information.
8355 - xfs_dinode_from_disk(&ip->i_d, dip);
8356 + xfs_dinode_from_disk(&ip->i_d, dip,
8357 + mp->m_flags & XFS_MOUNT_TAGGED);
8358 error = xfs_iformat(ip, dip);
8361 @@ -1028,6 +1053,7 @@ xfs_ialloc(
8362 ASSERT(ip->i_d.di_nlink == nlink);
8363 ip->i_d.di_uid = current_fsuid();
8364 ip->i_d.di_gid = current_fsgid();
8365 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
8366 xfs_set_projid(ip, prid);
8367 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8369 @@ -1088,6 +1114,7 @@ xfs_ialloc(
8370 ip->i_d.di_dmevmask = 0;
8371 ip->i_d.di_dmstate = 0;
8372 ip->i_d.di_flags = 0;
8373 + ip->i_d.di_vflags = 0;
8374 flags = XFS_ILOG_CORE;
8375 switch (mode & S_IFMT) {
8377 @@ -2122,6 +2149,7 @@ xfs_ifree(
8379 ip->i_d.di_mode = 0; /* mark incore inode as free */
8380 ip->i_d.di_flags = 0;
8381 + ip->i_d.di_vflags = 0;
8382 ip->i_d.di_dmevmask = 0;
8383 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8384 ip->i_df.if_ext_max =
8385 @@ -3004,7 +3032,8 @@ xfs_iflush_int(
8386 * because if the inode is dirty at all the core must
8389 - xfs_dinode_to_disk(dip, &ip->i_d);
8390 + xfs_dinode_to_disk(dip, &ip->i_d,
8391 + mp->m_flags & XFS_MOUNT_TAGGED);
8393 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8394 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8395 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/xfs_inode.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_inode.h
8396 --- linux-2.6.38.3/fs/xfs/xfs_inode.h 2011-03-15 18:07:34.000000000 +0100
8397 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_inode.h 2011-01-29 02:01:07.000000000 +0100
8398 @@ -136,7 +136,9 @@ typedef struct xfs_icdinode {
8399 __uint32_t di_nlink; /* number of links to file */
8400 __uint16_t di_projid_lo; /* lower part of owner's project id */
8401 __uint16_t di_projid_hi; /* higher part of owner's project id */
8402 - __uint8_t di_pad[6]; /* unused, zeroed space */
8403 + __uint8_t di_pad[2]; /* unused, zeroed space */
8404 + __uint16_t di_tag; /* context tagging */
8405 + __uint16_t di_vflags; /* vserver specific flags */
8406 __uint16_t di_flushiter; /* incremented on flush */
8407 xfs_ictimestamp_t di_atime; /* time last accessed */
8408 xfs_ictimestamp_t di_mtime; /* time last modified */
8409 @@ -530,7 +532,7 @@ int xfs_itobp(struct xfs_mount *, struc
8410 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8411 struct xfs_inode *, uint);
8412 void xfs_dinode_to_disk(struct xfs_dinode *,
8413 - struct xfs_icdinode *);
8414 + struct xfs_icdinode *, int);
8415 void xfs_idestroy_fork(struct xfs_inode *, int);
8416 void xfs_idata_realloc(struct xfs_inode *, int, int);
8417 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8418 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/xfs_itable.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_itable.c
8419 --- linux-2.6.38.3/fs/xfs/xfs_itable.c 2011-01-05 21:50:28.000000000 +0100
8420 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_itable.c 2011-01-29 02:01:07.000000000 +0100
8421 @@ -98,6 +98,7 @@ xfs_bulkstat_one_int(
8422 buf->bs_mode = dic->di_mode;
8423 buf->bs_uid = dic->di_uid;
8424 buf->bs_gid = dic->di_gid;
8425 + buf->bs_tag = dic->di_tag;
8426 buf->bs_size = dic->di_size;
8429 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/xfs_log_recover.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_log_recover.c
8430 --- linux-2.6.38.3/fs/xfs/xfs_log_recover.c 2011-03-15 18:07:34.000000000 +0100
8431 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_log_recover.c 2011-01-29 02:01:07.000000000 +0100
8432 @@ -2317,7 +2317,8 @@ xlog_recover_inode_pass2(
8435 /* The core is in in-core format */
8436 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
8437 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
8438 + mp->m_flags & XFS_MOUNT_TAGGED);
8440 /* the rest is in on-disk format */
8441 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8442 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/xfs_mount.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_mount.h
8443 --- linux-2.6.38.3/fs/xfs/xfs_mount.h 2011-03-15 18:07:34.000000000 +0100
8444 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_mount.h 2011-01-29 02:01:07.000000000 +0100
8445 @@ -251,6 +251,7 @@ typedef struct xfs_mount {
8447 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8449 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8452 * Default minimum read and write sizes.
8453 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/xfs_vnodeops.c linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_vnodeops.c
8454 --- linux-2.6.38.3/fs/xfs/xfs_vnodeops.c 2011-03-15 18:07:34.000000000 +0100
8455 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_vnodeops.c 2011-01-29 02:01:07.000000000 +0100
8457 #include "xfs_vnodeops.h"
8458 #include "xfs_trace.h"
8462 +xfs_get_inode_flags(
8465 + struct inode *inode = VFS_I(ip);
8466 + unsigned int flags = inode->i_flags;
8467 + unsigned int vflags = inode->i_vflags;
8469 + if (flags & S_IMMUTABLE)
8470 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8472 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8473 + if (flags & S_IXUNLINK)
8474 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8476 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8478 + if (vflags & V_BARRIER)
8479 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8481 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8482 + if (vflags & V_COW)
8483 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8485 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8490 + struct inode *inode,
8494 + struct xfs_inode *ip = XFS_I(inode);
8495 + struct xfs_mount *mp = ip->i_mount;
8496 + struct xfs_trans *tp;
8497 + unsigned int lock_flags = 0;
8500 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8501 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8505 + xfs_ilock(ip, XFS_ILOCK_EXCL);
8507 + xfs_trans_ijoin(tp, ip);
8509 + inode->i_flags = flags;
8510 + inode->i_vflags = vflags;
8511 + xfs_get_inode_flags(ip);
8513 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8514 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
8516 + XFS_STATS_INC(xs_ig_attrchg);
8518 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8519 + xfs_trans_set_sync(tp);
8520 + code = xfs_trans_commit(tp, 0);
8521 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8525 + xfs_trans_cancel(tp, 0);
8527 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8534 struct xfs_inode *ip,
8535 @@ -65,6 +137,7 @@ xfs_setattr(
8536 uint commit_flags=0;
8537 uid_t uid=0, iuid=0;
8538 gid_t gid=0, igid=0;
8539 + tag_t tag=0, itag=0;
8540 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8541 int need_iolock = 1;
8543 @@ -147,7 +220,7 @@ xfs_setattr(
8545 * Change file ownership. Must be the owner or privileged.
8547 - if (mask & (ATTR_UID|ATTR_GID)) {
8548 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8550 * These IDs could have changed since we last looked at them.
8551 * But, we're assured that if the ownership did change
8552 @@ -156,8 +229,10 @@ xfs_setattr(
8554 iuid = ip->i_d.di_uid;
8555 igid = ip->i_d.di_gid;
8556 + itag = ip->i_d.di_tag;
8557 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8558 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8559 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8562 * Do a quota reservation only if uid/gid is actually
8563 @@ -165,7 +240,8 @@ xfs_setattr(
8565 if (XFS_IS_QUOTA_RUNNING(mp) &&
8566 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8567 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
8568 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8569 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
8571 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
8572 capable(CAP_FOWNER) ?
8573 @@ -329,7 +405,7 @@ xfs_setattr(
8575 * Change file ownership. Must be the owner or privileged.
8577 - if (mask & (ATTR_UID|ATTR_GID)) {
8578 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8580 * CAP_FSETID overrides the following restrictions:
8582 @@ -345,6 +421,10 @@ xfs_setattr(
8583 * Change the ownerships and register quota modifications
8584 * in the transaction.
8586 + if (itag != tag) {
8587 + ip->i_d.di_tag = tag;
8588 + inode->i_tag = tag;
8591 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
8592 ASSERT(mask & ATTR_UID);
8593 diff -NurpP --minimal linux-2.6.38.3/fs/xfs/xfs_vnodeops.h linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_vnodeops.h
8594 --- linux-2.6.38.3/fs/xfs/xfs_vnodeops.h 2011-01-05 21:50:28.000000000 +0100
8595 +++ linux-2.6.38.3-vs2.3.0.37-rc14/fs/xfs/xfs_vnodeops.h 2011-01-29 02:01:07.000000000 +0100
8596 @@ -13,6 +13,7 @@ struct xfs_inode;
8600 +int xfs_sync_xflags(struct xfs_inode *ip);
8601 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8602 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8603 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8604 diff -NurpP --minimal linux-2.6.38.3/include/asm-generic/tlb.h linux-2.6.38.3-vs2.3.0.37-rc14/include/asm-generic/tlb.h
8605 --- linux-2.6.38.3/include/asm-generic/tlb.h 2009-09-10 15:26:24.000000000 +0200
8606 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/asm-generic/tlb.h 2011-01-29 02:01:07.000000000 +0100
8608 #define _ASM_GENERIC__TLB_H
8610 #include <linux/swap.h>
8611 +#include <linux/vs_memory.h>
8612 #include <asm/pgalloc.h>
8613 #include <asm/tlbflush.h>
8615 diff -NurpP --minimal linux-2.6.38.3/include/linux/Kbuild linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/Kbuild
8616 --- linux-2.6.38.3/include/linux/Kbuild 2011-03-15 18:07:37.000000000 +0100
8617 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/Kbuild 2011-02-17 02:17:51.000000000 +0100
8618 @@ -16,6 +16,7 @@ header-y += netfilter_bridge/
8619 header-y += netfilter_ipv4/
8620 header-y += netfilter_ipv6/
8622 +header-y += vserver/
8625 objhdr-y += version.h
8626 diff -NurpP --minimal linux-2.6.38.3/include/linux/capability.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/capability.h
8627 --- linux-2.6.38.3/include/linux/capability.h 2011-03-15 18:07:37.000000000 +0100
8628 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/capability.h 2011-01-29 02:01:07.000000000 +0100
8629 @@ -279,6 +279,7 @@ struct cpu_vfs_cap_data {
8630 arbitrary SCSI commands */
8631 /* Allow setting encryption key on loopback filesystem */
8632 /* Allow setting zone reclaim policy */
8633 +/* Allow the selection of a security context */
8635 #define CAP_SYS_ADMIN 21
8637 @@ -357,7 +358,12 @@ struct cpu_vfs_cap_data {
8639 #define CAP_LAST_CAP CAP_SYSLOG
8641 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8642 +/* Allow context manipulations */
8643 +/* Allow changing context info on files */
8645 +#define CAP_CONTEXT 63
8647 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
8650 * Bit location of each capability (used by user-space library and kernel)
8651 diff -NurpP --minimal linux-2.6.38.3/include/linux/cred.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/cred.h
8652 --- linux-2.6.38.3/include/linux/cred.h 2011-01-05 21:50:29.000000000 +0100
8653 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/cred.h 2011-01-31 12:03:07.000000000 +0100
8654 @@ -155,6 +155,7 @@ extern void exit_creds(struct task_struc
8655 extern int copy_creds(struct task_struct *, unsigned long);
8656 extern const struct cred *get_task_cred(struct task_struct *);
8657 extern struct cred *cred_alloc_blank(void);
8658 +extern struct cred *__prepare_creds(const struct cred *);
8659 extern struct cred *prepare_creds(void);
8660 extern struct cred *prepare_exec_creds(void);
8661 extern int commit_creds(struct cred *);
8662 @@ -208,6 +209,31 @@ static inline void validate_process_cred
8666 +static inline void set_cred_subscribers(struct cred *cred, int n)
8668 +#ifdef CONFIG_DEBUG_CREDENTIALS
8669 + atomic_set(&cred->subscribers, n);
8673 +static inline int read_cred_subscribers(const struct cred *cred)
8675 +#ifdef CONFIG_DEBUG_CREDENTIALS
8676 + return atomic_read(&cred->subscribers);
8682 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
8684 +#ifdef CONFIG_DEBUG_CREDENTIALS
8685 + struct cred *cred = (struct cred *) _cred;
8687 + atomic_add(n, &cred->subscribers);
8692 * get_new_cred - Get a reference on a new set of credentials
8693 * @cred: The new credentials to reference
8694 diff -NurpP --minimal linux-2.6.38.3/include/linux/devpts_fs.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/devpts_fs.h
8695 --- linux-2.6.38.3/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8696 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/devpts_fs.h 2011-01-29 02:01:07.000000000 +0100
8697 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8702 #endif /* _LINUX_DEVPTS_FS_H */
8703 diff -NurpP --minimal linux-2.6.38.3/include/linux/ext2_fs.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/ext2_fs.h
8704 --- linux-2.6.38.3/include/linux/ext2_fs.h 2010-02-25 11:52:07.000000000 +0100
8705 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/ext2_fs.h 2011-01-29 02:01:07.000000000 +0100
8706 @@ -189,8 +189,12 @@ struct ext2_group_desc
8707 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8708 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8709 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8710 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8711 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8713 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8714 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8716 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8717 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8719 @@ -274,7 +278,8 @@ struct ext2_inode {
8721 __le16 l_i_uid_high; /* these 2 fields */
8722 __le16 l_i_gid_high; /* were reserved2[0] */
8723 - __u32 l_i_reserved2;
8724 + __le16 l_i_tag; /* Context Tag */
8725 + __u16 l_i_reserved2;
8728 __u8 h_i_frag; /* Fragment number */
8729 @@ -303,6 +308,7 @@ struct ext2_inode {
8730 #define i_gid_low i_gid
8731 #define i_uid_high osd2.linux2.l_i_uid_high
8732 #define i_gid_high osd2.linux2.l_i_gid_high
8733 +#define i_raw_tag osd2.linux2.l_i_tag
8734 #define i_reserved2 osd2.linux2.l_i_reserved2
8737 @@ -347,6 +353,7 @@ struct ext2_inode {
8738 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8739 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8740 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8741 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8744 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8745 diff -NurpP --minimal linux-2.6.38.3/include/linux/ext3_fs.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/ext3_fs.h
8746 --- linux-2.6.38.3/include/linux/ext3_fs.h 2011-03-15 18:07:38.000000000 +0100
8747 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/ext3_fs.h 2011-01-29 02:01:07.000000000 +0100
8748 @@ -173,10 +173,14 @@ struct ext3_group_desc
8749 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8750 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8751 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8752 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8753 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8755 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8756 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8757 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8758 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8760 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8761 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8763 /* Flags that should be inherited by new inodes from their parent. */
8764 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8765 @@ -312,7 +316,8 @@ struct ext3_inode {
8767 __le16 l_i_uid_high; /* these 2 fields */
8768 __le16 l_i_gid_high; /* were reserved2[0] */
8769 - __u32 l_i_reserved2;
8770 + __le16 l_i_tag; /* Context Tag */
8771 + __u16 l_i_reserved2;
8774 __u8 h_i_frag; /* Fragment number */
8775 @@ -343,6 +348,7 @@ struct ext3_inode {
8776 #define i_gid_low i_gid
8777 #define i_uid_high osd2.linux2.l_i_uid_high
8778 #define i_gid_high osd2.linux2.l_i_gid_high
8779 +#define i_raw_tag osd2.linux2.l_i_tag
8780 #define i_reserved2 osd2.linux2.l_i_reserved2
8782 #elif defined(__GNU__)
8783 @@ -405,6 +411,7 @@ struct ext3_inode {
8784 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8785 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8786 * error in ordered mode */
8787 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8789 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8790 #ifndef _LINUX_EXT2_FS_H
8791 @@ -918,6 +925,7 @@ extern void ext3_get_inode_flags(struct
8792 extern void ext3_set_aops(struct inode *inode);
8793 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8794 u64 start, u64 len);
8795 +extern int ext3_sync_flags(struct inode *, int, int);
8798 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8799 diff -NurpP --minimal linux-2.6.38.3/include/linux/fs.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/fs.h
8800 --- linux-2.6.38.3/include/linux/fs.h 2011-03-15 18:07:38.000000000 +0100
8801 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/fs.h 2011-03-07 16:53:28.000000000 +0100
8802 @@ -214,6 +214,9 @@ struct inodes_stat_t {
8803 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8804 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8805 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8806 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8807 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8808 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8809 #define MS_BORN (1<<29)
8810 #define MS_ACTIVE (1<<30)
8811 #define MS_NOUSER (1<<31)
8812 @@ -243,6 +246,14 @@ struct inodes_stat_t {
8813 #define S_PRIVATE 512 /* Inode is fs-internal */
8814 #define S_IMA 1024 /* Inode has an associated IMA struct */
8815 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
8816 +#define S_IXUNLINK 4096 /* Immutable Invert on unlink */
8818 +/* Linux-VServer related Inode flags */
8822 +#define V_BARRIER 4 /* Barrier for chroot() */
8823 +#define V_COW 8 /* Copy on Write */
8826 * Note that nosuid etc flags are inode-specific: setting some file-system
8827 @@ -265,12 +276,15 @@ struct inodes_stat_t {
8828 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8829 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8830 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8831 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8832 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8833 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8834 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8835 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8837 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8838 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8839 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8840 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8841 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8842 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8844 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8845 @@ -280,6 +294,16 @@ struct inodes_stat_t {
8846 #define IS_IMA(inode) ((inode)->i_flags & S_IMA)
8847 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
8849 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8851 +#ifdef CONFIG_VSERVER_COWBL
8852 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8853 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8855 +# define IS_COW(inode) (0)
8856 +# define IS_COW_LINK(inode) (0)
8859 /* the read-only stuff doesn't really belong here, but any other place is
8860 probably as bad and I don't want to create yet another include file. */
8862 @@ -364,11 +388,14 @@ struct inodes_stat_t {
8863 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8864 #define FS_EXTENT_FL 0x00080000 /* Extents */
8865 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8866 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8867 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8869 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8870 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8871 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8872 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8874 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8875 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8877 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8878 #define SYNC_FILE_RANGE_WRITE 2
8879 @@ -449,6 +476,7 @@ typedef void (dio_iodone_t)(struct kiocb
8880 #define ATTR_KILL_PRIV (1 << 14)
8881 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8882 #define ATTR_TIMES_SET (1 << 16)
8883 +#define ATTR_TAG (1 << 17)
8886 * This is the Inode Attributes structure, used for notify_change(). It
8887 @@ -464,6 +492,7 @@ struct iattr {
8893 struct timespec ia_atime;
8894 struct timespec ia_mtime;
8895 @@ -477,6 +506,9 @@ struct iattr {
8896 struct file *ia_file;
8899 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8900 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8903 * Includes for diskquotas.
8905 @@ -742,11 +774,13 @@ struct inode {
8910 const struct inode_operations *i_op;
8911 struct super_block *i_sb;
8913 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
8914 - unsigned int i_flags;
8915 + unsigned short i_flags;
8916 + unsigned short i_vflags;
8917 struct mutex i_mutex;
8919 unsigned long i_state;
8920 @@ -764,6 +798,7 @@ struct inode {
8922 unsigned int i_nlink;
8925 unsigned int i_blkbits;
8928 @@ -892,12 +927,12 @@ static inline void i_size_write(struct i
8930 static inline unsigned iminor(const struct inode *inode)
8932 - return MINOR(inode->i_rdev);
8933 + return MINOR(inode->i_mdev);
8936 static inline unsigned imajor(const struct inode *inode)
8938 - return MAJOR(inode->i_rdev);
8939 + return MAJOR(inode->i_mdev);
8942 extern struct block_device *I_BDEV(struct inode *inode);
8943 @@ -959,6 +994,7 @@ struct file {
8945 struct fown_struct f_owner;
8946 const struct cred *f_cred;
8948 struct file_ra_state f_ra;
8951 @@ -1096,6 +1132,7 @@ struct file_lock {
8952 struct file *fl_file;
8957 struct fasync_struct * fl_fasync; /* for lease break notifications */
8958 unsigned long fl_break_time; /* for nonblocking lease breaks */
8959 @@ -1584,6 +1621,7 @@ struct inode_operations {
8960 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8961 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8962 int (*removexattr) (struct dentry *, const char *);
8963 + int (*sync_flags) (struct inode *, int, int);
8964 void (*truncate_range)(struct inode *, loff_t, loff_t);
8965 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8967 @@ -1602,6 +1640,7 @@ extern ssize_t vfs_readv(struct file *,
8968 unsigned long, loff_t *);
8969 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8970 unsigned long, loff_t *);
8971 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8973 struct super_operations {
8974 struct inode *(*alloc_inode)(struct super_block *sb);
8975 @@ -2414,6 +2453,7 @@ extern int dcache_dir_open(struct inode
8976 extern int dcache_dir_close(struct inode *, struct file *);
8977 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8978 extern int dcache_readdir(struct file *, void *, filldir_t);
8979 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8980 extern int simple_setattr(struct dentry *, struct iattr *);
8981 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8982 extern int simple_statfs(struct dentry *, struct kstatfs *);
8983 diff -NurpP --minimal linux-2.6.38.3/include/linux/gfs2_ondisk.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/gfs2_ondisk.h
8984 --- linux-2.6.38.3/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
8985 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/gfs2_ondisk.h 2011-01-29 02:01:07.000000000 +0100
8986 @@ -211,6 +211,9 @@ enum {
8990 + gfs2fl_IXUnlink = 16,
8991 + gfs2fl_Barrier = 17,
8993 gfs2fl_TruncInProg = 29,
8994 gfs2fl_InheritDirectio = 30,
8995 gfs2fl_InheritJdata = 31,
8996 @@ -227,6 +230,9 @@ enum {
8997 #define GFS2_DIF_NOATIME 0x00000080
8998 #define GFS2_DIF_SYNC 0x00000100
8999 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
9000 +#define GFS2_DIF_IXUNLINK 0x00010000
9001 +#define GFS2_DIF_BARRIER 0x00020000
9002 +#define GFS2_DIF_COW 0x00040000
9003 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
9004 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
9005 #define GFS2_DIF_INHERIT_JDATA 0x80000000
9006 diff -NurpP --minimal linux-2.6.38.3/include/linux/if_tun.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/if_tun.h
9007 --- linux-2.6.38.3/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
9008 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/if_tun.h 2011-01-29 02:01:07.000000000 +0100
9010 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
9011 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
9012 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
9013 +#define TUNSETNID _IOW('T', 217, int)
9015 /* TUNSETIFF ifr flags */
9016 #define IFF_TUN 0x0001
9017 diff -NurpP --minimal linux-2.6.38.3/include/linux/init_task.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/init_task.h
9018 --- linux-2.6.38.3/include/linux/init_task.h 2011-03-15 18:07:38.000000000 +0100
9019 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/init_task.h 2011-01-29 02:01:07.000000000 +0100
9020 @@ -192,6 +192,10 @@ extern struct cred init_cred;
9022 INIT_TRACE_RECURSION \
9023 INIT_TASK_RCU_PREEMPT(tsk) \
9025 + .vx_info = NULL, \
9027 + .nx_info = NULL, \
9031 diff -NurpP --minimal linux-2.6.38.3/include/linux/ipc.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/ipc.h
9032 --- linux-2.6.38.3/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
9033 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/ipc.h 2011-01-29 02:01:07.000000000 +0100
9034 @@ -91,6 +91,7 @@ struct kern_ipc_perm
9042 diff -NurpP --minimal linux-2.6.38.3/include/linux/loop.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/loop.h
9043 --- linux-2.6.38.3/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
9044 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/loop.h 2011-01-29 02:01:07.000000000 +0100
9045 @@ -45,6 +45,7 @@ struct loop_device {
9046 struct loop_func_table *lo_encryption;
9048 uid_t lo_key_owner; /* Who set the key */
9050 int (*ioctl)(struct loop_device *, int cmd,
9053 diff -NurpP --minimal linux-2.6.38.3/include/linux/magic.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/magic.h
9054 --- linux-2.6.38.3/include/linux/magic.h 2011-03-15 18:07:39.000000000 +0100
9055 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/magic.h 2011-01-29 02:01:07.000000000 +0100
9058 #define ADFS_SUPER_MAGIC 0xadf5
9059 #define AFFS_SUPER_MAGIC 0xadff
9060 -#define AFS_SUPER_MAGIC 0x5346414F
9061 +#define AFS_SUPER_MAGIC 0x5346414F
9062 #define AUTOFS_SUPER_MAGIC 0x0187
9063 #define CODA_SUPER_MAGIC 0x73757245
9064 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
9066 #define NFS_SUPER_MAGIC 0x6969
9067 #define OPENPROM_SUPER_MAGIC 0x9fa1
9068 #define PROC_SUPER_MAGIC 0x9fa0
9069 +#define DEVPTS_SUPER_MAGIC 0x1cd1
9070 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
9072 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
9073 diff -NurpP --minimal linux-2.6.38.3/include/linux/major.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/major.h
9074 --- linux-2.6.38.3/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
9075 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/major.h 2011-01-29 02:01:07.000000000 +0100
9077 #define HD_MAJOR IDE0_MAJOR
9078 #define PTY_SLAVE_MAJOR 3
9080 +#define VROOT_MAJOR 4
9081 #define TTYAUX_MAJOR 5
9084 diff -NurpP --minimal linux-2.6.38.3/include/linux/memcontrol.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/memcontrol.h
9085 --- linux-2.6.38.3/include/linux/memcontrol.h 2011-03-15 18:07:39.000000000 +0100
9086 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/memcontrol.h 2011-01-29 02:01:07.000000000 +0100
9087 @@ -82,6 +82,13 @@ int task_in_mem_cgroup(struct task_struc
9088 extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
9089 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
9091 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
9092 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
9094 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
9095 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
9096 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
9099 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
9101 diff -NurpP --minimal linux-2.6.38.3/include/linux/mm_types.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/mm_types.h
9102 --- linux-2.6.38.3/include/linux/mm_types.h 2011-03-15 18:07:39.000000000 +0100
9103 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/mm_types.h 2011-01-29 02:01:07.000000000 +0100
9104 @@ -269,6 +269,7 @@ struct mm_struct {
9106 /* Architecture-specific MM context */
9107 mm_context_t context;
9108 + struct vx_info *mm_vx_info;
9110 /* Swap token stuff */
9112 diff -NurpP --minimal linux-2.6.38.3/include/linux/mount.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/mount.h
9113 --- linux-2.6.38.3/include/linux/mount.h 2011-03-15 18:07:39.000000000 +0100
9114 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/mount.h 2011-01-29 03:11:27.000000000 +0100
9115 @@ -52,6 +52,9 @@ struct mnt_pcp {
9119 +#define MNT_TAGID 0x10000
9120 +#define MNT_NOTAG 0x20000
9123 struct list_head mnt_hash;
9124 struct vfsmount *mnt_parent; /* fs we are mounted on */
9125 @@ -86,6 +89,7 @@ struct vfsmount {
9126 int mnt_expiry_mark; /* true if marked for expiry */
9129 + tag_t mnt_tag; /* tagging used for vfsmount */
9132 struct file; /* forward dec */
9133 diff -NurpP --minimal linux-2.6.38.3/include/linux/net.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/net.h
9134 --- linux-2.6.38.3/include/linux/net.h 2011-01-05 21:50:31.000000000 +0100
9135 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/net.h 2011-01-29 02:01:07.000000000 +0100
9136 @@ -71,6 +71,7 @@ struct net;
9137 #define SOCK_NOSPACE 2
9138 #define SOCK_PASSCRED 3
9139 #define SOCK_PASSSEC 4
9140 +#define SOCK_USER_SOCKET 5
9142 #ifndef ARCH_HAS_SOCKET_TYPES
9144 diff -NurpP --minimal linux-2.6.38.3/include/linux/nfs_mount.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/nfs_mount.h
9145 --- linux-2.6.38.3/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
9146 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/nfs_mount.h 2011-01-29 02:01:07.000000000 +0100
9147 @@ -63,7 +63,8 @@ struct nfs_mount_data {
9148 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
9149 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
9150 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
9151 -#define NFS_MOUNT_FLAGMASK 0xFFFF
9152 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
9153 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
9155 /* The following are for internal use only */
9156 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
9157 diff -NurpP --minimal linux-2.6.38.3/include/linux/nsproxy.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/nsproxy.h
9158 --- linux-2.6.38.3/include/linux/nsproxy.h 2009-06-11 17:13:17.000000000 +0200
9159 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/nsproxy.h 2011-01-29 02:01:07.000000000 +0100
9162 #include <linux/spinlock.h>
9163 #include <linux/sched.h>
9164 +#include <linux/vserver/debug.h>
9166 struct mnt_namespace;
9167 struct uts_namespace;
9168 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
9171 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
9172 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
9173 void exit_task_namespaces(struct task_struct *tsk);
9174 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
9175 void free_nsproxy(struct nsproxy *ns);
9176 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
9177 struct fs_struct *);
9179 -static inline void put_nsproxy(struct nsproxy *ns)
9180 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
9182 +static inline void __get_nsproxy(struct nsproxy *ns,
9183 + const char *_file, int _line)
9185 - if (atomic_dec_and_test(&ns->count)) {
9188 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
9189 + ns, atomic_read(&ns->count), _file, _line);
9190 + atomic_inc(&ns->count);
9193 -static inline void get_nsproxy(struct nsproxy *ns)
9194 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
9196 +static inline void __put_nsproxy(struct nsproxy *ns,
9197 + const char *_file, int _line)
9199 - atomic_inc(&ns->count);
9200 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
9201 + ns, atomic_read(&ns->count), _file, _line);
9202 + if (atomic_dec_and_test(&ns->count)) {
9207 #ifdef CONFIG_CGROUP_NS
9208 diff -NurpP --minimal linux-2.6.38.3/include/linux/pid.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/pid.h
9209 --- linux-2.6.38.3/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
9210 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/pid.h 2011-01-29 02:01:07.000000000 +0100
9211 @@ -8,7 +8,8 @@ enum pid_type
9221 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
9224 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9225 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9226 pid_t pid_vnr(struct pid *pid);
9228 #define do_each_pid_task(pid, type, task) \
9229 diff -NurpP --minimal linux-2.6.38.3/include/linux/proc_fs.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/proc_fs.h
9230 --- linux-2.6.38.3/include/linux/proc_fs.h 2009-12-03 20:02:56.000000000 +0100
9231 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/proc_fs.h 2011-01-29 02:01:07.000000000 +0100
9232 @@ -56,6 +56,7 @@ struct proc_dir_entry {
9238 const struct inode_operations *proc_iops;
9240 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void
9241 extern void kclist_add(struct kcore_list *, void *, size_t, int type);
9248 int (*proc_get_link)(struct inode *, struct path *);
9249 int (*proc_read)(struct task_struct *task, char *page);
9250 int (*proc_show)(struct seq_file *m,
9251 struct pid_namespace *ns, struct pid *pid,
9252 struct task_struct *task);
9253 + int (*proc_vs_read)(char *page);
9254 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9255 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9258 struct ctl_table_header;
9259 @@ -263,6 +270,7 @@ struct ctl_table;
9266 struct proc_dir_entry *pde;
9267 diff -NurpP --minimal linux-2.6.38.3/include/linux/quotaops.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/quotaops.h
9268 --- linux-2.6.38.3/include/linux/quotaops.h 2011-03-15 18:07:39.000000000 +0100
9269 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/quotaops.h 2011-01-29 02:01:07.000000000 +0100
9271 #define _LINUX_QUOTAOPS_
9273 #include <linux/fs.h>
9274 +#include <linux/vs_dlimit.h>
9276 #define DQUOT_SPACE_WARN 0x1
9277 #define DQUOT_SPACE_RESERVE 0x2
9278 @@ -204,11 +205,12 @@ static inline void dquot_drop(struct ino
9280 static inline int dquot_alloc_inode(const struct inode *inode)
9283 + return dl_alloc_inode(inode);
9286 static inline void dquot_free_inode(const struct inode *inode)
9288 + dl_free_inode(inode);
9291 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
9292 @@ -219,6 +221,10 @@ static inline int dquot_transfer(struct
9293 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
9298 + if ((ret = dl_alloc_space(inode, number)))
9300 if (!(flags & DQUOT_SPACE_RESERVE))
9301 inode_add_bytes(inode, number);
9303 @@ -229,6 +235,7 @@ static inline void __dquot_free_space(st
9305 if (!(flags & DQUOT_SPACE_RESERVE))
9306 inode_sub_bytes(inode, number);
9307 + dl_free_space(inode, number);
9310 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
9311 diff -NurpP --minimal linux-2.6.38.3/include/linux/reboot.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/reboot.h
9312 --- linux-2.6.38.3/include/linux/reboot.h 2010-07-07 18:31:56.000000000 +0200
9313 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/reboot.h 2011-01-29 02:01:07.000000000 +0100
9315 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
9316 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
9317 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
9318 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
9322 diff -NurpP --minimal linux-2.6.38.3/include/linux/reiserfs_fs.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/reiserfs_fs.h
9323 --- linux-2.6.38.3/include/linux/reiserfs_fs.h 2011-01-05 21:50:32.000000000 +0100
9324 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/reiserfs_fs.h 2011-01-29 02:01:07.000000000 +0100
9325 @@ -976,6 +976,11 @@ struct stat_data_v1 {
9326 #define REISERFS_COMPR_FL FS_COMPR_FL
9327 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9329 +/* unfortunately reiserfs sdattr is only 16 bit */
9330 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9331 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9332 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9334 /* persistent flags that file inherits from the parent directory */
9335 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9336 REISERFS_SYNC_FL | \
9337 @@ -985,6 +990,9 @@ struct stat_data_v1 {
9338 REISERFS_COMPR_FL | \
9339 REISERFS_NOTAIL_FL )
9341 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9342 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9344 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9347 @@ -2070,6 +2078,7 @@ static inline void reiserfs_update_sd(st
9348 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9349 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9350 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9351 +int reiserfs_sync_flags(struct inode *inode, int, int);
9353 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
9355 diff -NurpP --minimal linux-2.6.38.3/include/linux/reiserfs_fs_sb.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/reiserfs_fs_sb.h
9356 --- linux-2.6.38.3/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
9357 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/reiserfs_fs_sb.h 2011-01-29 02:01:07.000000000 +0100
9358 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
9359 REISERFS_EXPOSE_PRIVROOT,
9360 REISERFS_BARRIER_NONE,
9361 REISERFS_BARRIER_FLUSH,
9364 /* Actions on error */
9365 REISERFS_ERROR_PANIC,
9366 diff -NurpP --minimal linux-2.6.38.3/include/linux/sched.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/sched.h
9367 --- linux-2.6.38.3/include/linux/sched.h 2011-03-15 18:07:39.000000000 +0100
9368 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/sched.h 2011-03-07 16:53:28.000000000 +0100
9369 @@ -1373,6 +1373,14 @@ struct task_struct {
9373 +/* vserver context data */
9374 + struct vx_info *vx_info;
9375 + struct nx_info *nx_info;
9381 /* Thread group tracking */
9384 @@ -1607,6 +1615,11 @@ struct pid_namespace;
9385 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9386 struct pid_namespace *ns);
9388 +#include <linux/vserver/base.h>
9389 +#include <linux/vserver/context.h>
9390 +#include <linux/vserver/debug.h>
9391 +#include <linux/vserver/pid.h>
9393 static inline pid_t task_pid_nr(struct task_struct *tsk)
9396 @@ -1620,7 +1633,8 @@ static inline pid_t task_pid_nr_ns(struc
9398 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9400 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9401 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9402 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
9406 @@ -1633,7 +1647,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9408 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9410 - return pid_vnr(task_tgid(tsk));
9411 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9415 diff -NurpP --minimal linux-2.6.38.3/include/linux/shmem_fs.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/shmem_fs.h
9416 --- linux-2.6.38.3/include/linux/shmem_fs.h 2010-10-21 13:07:55.000000000 +0200
9417 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/shmem_fs.h 2011-01-29 02:01:07.000000000 +0100
9420 #define SHMEM_NR_DIRECT 16
9422 +#define TMPFS_SUPER_MAGIC 0x01021994
9425 struct shmem_inode_info {
9427 unsigned long flags;
9428 diff -NurpP --minimal linux-2.6.38.3/include/linux/stat.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/stat.h
9429 --- linux-2.6.38.3/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9430 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/stat.h 2011-01-29 02:01:07.000000000 +0100
9431 @@ -66,6 +66,7 @@ struct kstat {
9438 struct timespec atime;
9439 diff -NurpP --minimal linux-2.6.38.3/include/linux/sunrpc/auth.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/sunrpc/auth.h
9440 --- linux-2.6.38.3/include/linux/sunrpc/auth.h 2011-03-15 18:07:39.000000000 +0100
9441 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/sunrpc/auth.h 2011-01-29 02:01:07.000000000 +0100
9447 struct group_info *group_info;
9448 unsigned char machine_cred : 1;
9450 diff -NurpP --minimal linux-2.6.38.3/include/linux/sunrpc/clnt.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/sunrpc/clnt.h
9451 --- linux-2.6.38.3/include/linux/sunrpc/clnt.h 2011-03-15 18:07:39.000000000 +0100
9452 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/sunrpc/clnt.h 2011-01-29 02:01:07.000000000 +0100
9453 @@ -49,7 +49,8 @@ struct rpc_clnt {
9454 unsigned int cl_softrtry : 1,/* soft timeouts */
9455 cl_discrtry : 1,/* disconnect before retry */
9456 cl_autobind : 1,/* use getport() */
9457 - cl_chatty : 1;/* be verbose */
9458 + cl_chatty : 1,/* be verbose */
9459 + cl_tag : 1;/* context tagging */
9461 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9462 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9463 diff -NurpP --minimal linux-2.6.38.3/include/linux/syscalls.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/syscalls.h
9464 --- linux-2.6.38.3/include/linux/syscalls.h 2011-03-15 18:07:39.000000000 +0100
9465 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/syscalls.h 2011-02-17 02:17:51.000000000 +0100
9466 @@ -478,6 +478,8 @@ asmlinkage long sys_symlink(const char _
9467 asmlinkage long sys_unlink(const char __user *pathname);
9468 asmlinkage long sys_rename(const char __user *oldname,
9469 const char __user *newname);
9470 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9472 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9473 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9475 diff -NurpP --minimal linux-2.6.38.3/include/linux/sysctl.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/sysctl.h
9476 --- linux-2.6.38.3/include/linux/sysctl.h 2011-03-15 18:07:40.000000000 +0100
9477 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/sysctl.h 2011-03-15 18:15:06.000000000 +0100
9478 @@ -60,6 +60,7 @@ enum
9479 CTL_ABI=9, /* Binary emulation */
9480 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9481 CTL_ARLAN=254, /* arlan wireless driver */
9482 + CTL_VSERVER=4242, /* Linux-VServer debug */
9483 CTL_S390DBF=5677, /* s390 debug */
9484 CTL_SUNRPC=7249, /* sunrpc debug */
9485 CTL_PM=9899, /* frv power management */
9486 @@ -94,6 +95,7 @@ enum
9488 KERN_PANIC=15, /* int: panic timeout */
9489 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9490 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9492 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9493 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9494 diff -NurpP --minimal linux-2.6.38.3/include/linux/sysfs.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/sysfs.h
9495 --- linux-2.6.38.3/include/linux/sysfs.h 2011-01-05 21:50:34.000000000 +0100
9496 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/sysfs.h 2011-01-29 02:01:07.000000000 +0100
9498 #include <linux/kobject_ns.h>
9499 #include <asm/atomic.h>
9501 +#define SYSFS_SUPER_MAGIC 0x62656572
9506 diff -NurpP --minimal linux-2.6.38.3/include/linux/time.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/time.h
9507 --- linux-2.6.38.3/include/linux/time.h 2011-03-15 18:07:40.000000000 +0100
9508 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/time.h 2011-01-29 02:01:07.000000000 +0100
9509 @@ -254,6 +254,9 @@ static __always_inline void timespec_add
9510 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9514 +#include <linux/vs_time.h>
9516 #endif /* __KERNEL__ */
9518 #define NFDBITS __NFDBITS
9519 diff -NurpP --minimal linux-2.6.38.3/include/linux/types.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/types.h
9520 --- linux-2.6.38.3/include/linux/types.h 2011-01-05 21:50:34.000000000 +0100
9521 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/types.h 2011-01-29 02:01:07.000000000 +0100
9522 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
9523 typedef __kernel_gid32_t gid_t;
9524 typedef __kernel_uid16_t uid16_t;
9525 typedef __kernel_gid16_t gid16_t;
9526 +typedef unsigned int xid_t;
9527 +typedef unsigned int nid_t;
9528 +typedef unsigned int tag_t;
9530 typedef unsigned long uintptr_t;
9532 diff -NurpP --minimal linux-2.6.38.3/include/linux/vroot.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vroot.h
9533 --- linux-2.6.38.3/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9534 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vroot.h 2011-01-29 02:01:07.000000000 +0100
9538 + * include/linux/vroot.h
9540 + * written by Herbert Pötzl, 9/11/2002
9541 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9543 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9544 + * Redistribution of this file is permitted under the
9545 + * GNU General Public License.
9548 +#ifndef _LINUX_VROOT_H
9549 +#define _LINUX_VROOT_H
9554 +/* Possible states of device */
9560 +struct vroot_device {
9564 + struct semaphore vr_ctl_mutex;
9565 + struct block_device *vr_device;
9570 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9572 +extern int register_vroot_grb(vroot_grb_func *);
9573 +extern int unregister_vroot_grb(vroot_grb_func *);
9575 +#endif /* __KERNEL__ */
9577 +#define MAX_VROOT_DEFAULT 8
9580 + * IOCTL commands --- we will commandeer 0x56 ('V')
9583 +#define VROOT_SET_DEV 0x5600
9584 +#define VROOT_CLR_DEV 0x5601
9586 +#endif /* _LINUX_VROOT_H */
9587 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_base.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_base.h
9588 --- linux-2.6.38.3/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9589 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_base.h 2011-01-29 02:01:07.000000000 +0100
9594 +#include "vserver/base.h"
9595 +#include "vserver/check.h"
9596 +#include "vserver/debug.h"
9599 +#warning duplicate inclusion
9601 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_context.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_context.h
9602 --- linux-2.6.38.3/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9603 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_context.h 2011-01-29 02:01:07.000000000 +0100
9605 +#ifndef _VS_CONTEXT_H
9606 +#define _VS_CONTEXT_H
9608 +#include "vserver/base.h"
9609 +#include "vserver/check.h"
9610 +#include "vserver/context.h"
9611 +#include "vserver/history.h"
9612 +#include "vserver/debug.h"
9614 +#include <linux/sched.h>
9617 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9619 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9620 + const char *_file, int _line, void *_here)
9625 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9626 + vxi, vxi ? vxi->vx_id : 0,
9627 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9629 + __vxh_get_vx_info(vxi, _here);
9631 + atomic_inc(&vxi->vx_usecnt);
9636 +extern void free_vx_info(struct vx_info *);
9638 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9640 +static inline void __put_vx_info(struct vx_info *vxi,
9641 + const char *_file, int _line, void *_here)
9646 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9647 + vxi, vxi ? vxi->vx_id : 0,
9648 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9650 + __vxh_put_vx_info(vxi, _here);
9652 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9653 + free_vx_info(vxi);
9657 +#define init_vx_info(p, i) \
9658 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9660 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9661 + const char *_file, int _line, void *_here)
9664 + vxlprintk(VXD_CBIT(xid, 3),
9665 + "init_vx_info(%p[#%d.%d])",
9666 + vxi, vxi ? vxi->vx_id : 0,
9667 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9669 + __vxh_init_vx_info(vxi, vxp, _here);
9671 + atomic_inc(&vxi->vx_usecnt);
9677 +#define set_vx_info(p, i) \
9678 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9680 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9681 + const char *_file, int _line, void *_here)
9683 + struct vx_info *vxo;
9688 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9689 + vxi, vxi ? vxi->vx_id : 0,
9690 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9692 + __vxh_set_vx_info(vxi, vxp, _here);
9694 + atomic_inc(&vxi->vx_usecnt);
9695 + vxo = xchg(vxp, vxi);
9700 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9702 +static inline void __clr_vx_info(struct vx_info **vxp,
9703 + const char *_file, int _line, void *_here)
9705 + struct vx_info *vxo;
9707 + vxo = xchg(vxp, NULL);
9711 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9712 + vxo, vxo ? vxo->vx_id : 0,
9713 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9715 + __vxh_clr_vx_info(vxo, vxp, _here);
9717 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9718 + free_vx_info(vxo);
9722 +#define claim_vx_info(v, p) \
9723 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9725 +static inline void __claim_vx_info(struct vx_info *vxi,
9726 + struct task_struct *task,
9727 + const char *_file, int _line, void *_here)
9729 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9730 + vxi, vxi ? vxi->vx_id : 0,
9731 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9732 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9733 + task, _file, _line);
9734 + __vxh_claim_vx_info(vxi, task, _here);
9736 + atomic_inc(&vxi->vx_tasks);
9740 +extern void unhash_vx_info(struct vx_info *);
9742 +#define release_vx_info(v, p) \
9743 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9745 +static inline void __release_vx_info(struct vx_info *vxi,
9746 + struct task_struct *task,
9747 + const char *_file, int _line, void *_here)
9749 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9750 + vxi, vxi ? vxi->vx_id : 0,
9751 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9752 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9753 + task, _file, _line);
9754 + __vxh_release_vx_info(vxi, task, _here);
9758 + if (atomic_dec_and_test(&vxi->vx_tasks))
9759 + unhash_vx_info(vxi);
9763 +#define task_get_vx_info(p) \
9764 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9766 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9767 + const char *_file, int _line, void *_here)
9769 + struct vx_info *vxi;
9772 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9774 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9780 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9782 + if (waitqueue_active(&vxi->vx_wait))
9783 + wake_up_interruptible(&vxi->vx_wait);
9787 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9789 +static inline void __enter_vx_info(struct vx_info *vxi,
9790 + struct vx_info_save *vxis, const char *_file, int _line)
9792 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9793 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9794 + current->xid, current->vx_info, _file, _line);
9795 + vxis->vxi = xchg(¤t->vx_info, vxi);
9796 + vxis->xid = current->xid;
9797 + current->xid = vxi ? vxi->vx_id : 0;
9800 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9802 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9803 + const char *_file, int _line)
9805 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9806 + vxis, vxis->xid, vxis->vxi, current,
9807 + current->xid, current->vx_info, _file, _line);
9808 + (void)xchg(¤t->vx_info, vxis->vxi);
9809 + current->xid = vxis->xid;
9813 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9815 + vxis->vxi = xchg(¤t->vx_info, NULL);
9816 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9819 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9821 + (void)xchg(¤t->xid, vxis->xid);
9822 + (void)xchg(¤t->vx_info, vxis->vxi);
9825 +#define task_is_init(p) \
9826 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9828 +static inline int __task_is_init(struct task_struct *p,
9829 + const char *_file, int _line, void *_here)
9831 + int is_init = is_global_init(p);
9835 + is_init = p->vx_info->vx_initpid == p->pid;
9840 +extern void exit_vx_info(struct task_struct *, int);
9841 +extern void exit_vx_info_early(struct task_struct *, int);
9845 +#warning duplicate inclusion
9847 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_cowbl.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_cowbl.h
9848 --- linux-2.6.38.3/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9849 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_cowbl.h 2011-01-29 02:01:07.000000000 +0100
9851 +#ifndef _VS_COWBL_H
9852 +#define _VS_COWBL_H
9854 +#include <linux/fs.h>
9855 +#include <linux/dcache.h>
9856 +#include <linux/namei.h>
9857 +#include <linux/slab.h>
9859 +extern struct dentry *cow_break_link(const char *pathname);
9861 +static inline int cow_check_and_break(struct path *path)
9863 + struct inode *inode = path->dentry->d_inode;
9866 + /* do we need this check? */
9867 + if (IS_RDONLY(inode))
9870 + if (IS_COW(inode)) {
9871 + if (IS_COW_LINK(inode)) {
9872 + struct dentry *new_dentry, *old_dentry = path->dentry;
9875 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9879 + pp = d_path(path, buf, PATH_MAX);
9880 + new_dentry = cow_break_link(pp);
9882 + if (!IS_ERR(new_dentry)) {
9883 + path->dentry = new_dentry;
9886 + error = PTR_ERR(new_dentry);
9888 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9889 + inode->i_ctime = CURRENT_TIME;
9890 + mark_inode_dirty(inode);
9897 +#warning duplicate inclusion
9899 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_cvirt.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_cvirt.h
9900 --- linux-2.6.38.3/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9901 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_cvirt.h 2011-01-29 02:01:07.000000000 +0100
9903 +#ifndef _VS_CVIRT_H
9904 +#define _VS_CVIRT_H
9906 +#include "vserver/cvirt.h"
9907 +#include "vserver/context.h"
9908 +#include "vserver/base.h"
9909 +#include "vserver/check.h"
9910 +#include "vserver/debug.h"
9913 +static inline void vx_activate_task(struct task_struct *p)
9915 + struct vx_info *vxi;
9917 + if ((vxi = p->vx_info)) {
9918 + vx_update_load(vxi);
9919 + atomic_inc(&vxi->cvirt.nr_running);
9923 +static inline void vx_deactivate_task(struct task_struct *p)
9925 + struct vx_info *vxi;
9927 + if ((vxi = p->vx_info)) {
9928 + vx_update_load(vxi);
9929 + atomic_dec(&vxi->cvirt.nr_running);
9933 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9935 + struct vx_info *vxi;
9937 + if ((vxi = p->vx_info))
9938 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9941 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9943 + struct vx_info *vxi;
9945 + if ((vxi = p->vx_info))
9946 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9951 +#warning duplicate inclusion
9953 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_device.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_device.h
9954 --- linux-2.6.38.3/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9955 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_device.h 2011-01-29 02:01:07.000000000 +0100
9957 +#ifndef _VS_DEVICE_H
9958 +#define _VS_DEVICE_H
9960 +#include "vserver/base.h"
9961 +#include "vserver/device.h"
9962 +#include "vserver/debug.h"
9965 +#ifdef CONFIG_VSERVER_DEVICE
9967 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9969 +#define vs_device_perm(v, d, m, p) \
9970 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9975 +int vs_map_device(struct vx_info *vxi,
9976 + dev_t device, dev_t *target, umode_t mode)
9983 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9988 +#define vs_map_chrdev(d, t, p) \
9989 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9990 +#define vs_map_blkdev(d, t, p) \
9991 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9993 +#define vs_chrdev_perm(d, p) \
9994 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9995 +#define vs_blkdev_perm(d, p) \
9996 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
10000 +#warning duplicate inclusion
10002 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_dlimit.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_dlimit.h
10003 --- linux-2.6.38.3/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
10004 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_dlimit.h 2011-01-29 02:01:07.000000000 +0100
10006 +#ifndef _VS_DLIMIT_H
10007 +#define _VS_DLIMIT_H
10009 +#include <linux/fs.h>
10011 +#include "vserver/dlimit.h"
10012 +#include "vserver/base.h"
10013 +#include "vserver/debug.h"
10016 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
10018 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
10019 + const char *_file, int _line)
10023 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
10024 + dli, dli ? dli->dl_tag : 0,
10025 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10027 + atomic_inc(&dli->dl_usecnt);
10032 +#define free_dl_info(i) \
10033 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
10035 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
10037 +static inline void __put_dl_info(struct dl_info *dli,
10038 + const char *_file, int _line)
10042 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
10043 + dli, dli ? dli->dl_tag : 0,
10044 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10046 + if (atomic_dec_and_test(&dli->dl_usecnt))
10047 + free_dl_info(dli);
10051 +#define __dlimit_char(d) ((d) ? '*' : ' ')
10053 +static inline int __dl_alloc_space(struct super_block *sb,
10054 + tag_t tag, dlsize_t nr, const char *file, int line)
10056 + struct dl_info *dli = NULL;
10061 + dli = locate_dl_info(sb, tag);
10065 + spin_lock(&dli->dl_lock);
10066 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
10068 + dli->dl_space_used += nr;
10069 + spin_unlock(&dli->dl_lock);
10070 + put_dl_info(dli);
10072 + vxlprintk(VXD_CBIT(dlim, 1),
10073 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
10074 + sb, tag, __dlimit_char(dli), (long long)nr,
10075 + ret, file, line);
10076 + return ret ? -ENOSPC : 0;
10079 +static inline void __dl_free_space(struct super_block *sb,
10080 + tag_t tag, dlsize_t nr, const char *_file, int _line)
10082 + struct dl_info *dli = NULL;
10086 + dli = locate_dl_info(sb, tag);
10090 + spin_lock(&dli->dl_lock);
10091 + if (dli->dl_space_used > nr)
10092 + dli->dl_space_used -= nr;
10094 + dli->dl_space_used = 0;
10095 + spin_unlock(&dli->dl_lock);
10096 + put_dl_info(dli);
10098 + vxlprintk(VXD_CBIT(dlim, 1),
10099 + "FREE (%p,#%d)%c %lld bytes",
10100 + sb, tag, __dlimit_char(dli), (long long)nr,
10104 +static inline int __dl_alloc_inode(struct super_block *sb,
10105 + tag_t tag, const char *_file, int _line)
10107 + struct dl_info *dli;
10110 + dli = locate_dl_info(sb, tag);
10114 + spin_lock(&dli->dl_lock);
10115 + dli->dl_inodes_used++;
10116 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
10117 + spin_unlock(&dli->dl_lock);
10118 + put_dl_info(dli);
10120 + vxlprintk(VXD_CBIT(dlim, 0),
10121 + "ALLOC (%p,#%d)%c inode (%d)",
10122 + sb, tag, __dlimit_char(dli), ret, _file, _line);
10123 + return ret ? -ENOSPC : 0;
10126 +static inline void __dl_free_inode(struct super_block *sb,
10127 + tag_t tag, const char *_file, int _line)
10129 + struct dl_info *dli;
10131 + dli = locate_dl_info(sb, tag);
10135 + spin_lock(&dli->dl_lock);
10136 + if (dli->dl_inodes_used > 1)
10137 + dli->dl_inodes_used--;
10139 + dli->dl_inodes_used = 0;
10140 + spin_unlock(&dli->dl_lock);
10141 + put_dl_info(dli);
10143 + vxlprintk(VXD_CBIT(dlim, 0),
10144 + "FREE (%p,#%d)%c inode",
10145 + sb, tag, __dlimit_char(dli), _file, _line);
10148 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10149 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10150 + const char *_file, int _line)
10152 + struct dl_info *dli;
10153 + uint64_t broot, bfree;
10155 + dli = locate_dl_info(sb, tag);
10159 + spin_lock(&dli->dl_lock);
10160 + broot = (dli->dl_space_total -
10161 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10162 + >> sb->s_blocksize_bits;
10163 + bfree = (dli->dl_space_total - dli->dl_space_used)
10164 + >> sb->s_blocksize_bits;
10165 + spin_unlock(&dli->dl_lock);
10167 + vxlprintk(VXD_CBIT(dlim, 2),
10168 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10169 + (long long)bfree, (long long)broot,
10170 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10172 + if (free_blocks) {
10173 + if (*free_blocks > bfree)
10174 + *free_blocks = bfree;
10176 + if (root_blocks) {
10177 + if (*root_blocks > broot)
10178 + *root_blocks = broot;
10180 + put_dl_info(dli);
10183 +#define dl_prealloc_space(in, bytes) \
10184 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10185 + __FILE__, __LINE__ )
10187 +#define dl_alloc_space(in, bytes) \
10188 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10189 + __FILE__, __LINE__ )
10191 +#define dl_reserve_space(in, bytes) \
10192 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10193 + __FILE__, __LINE__ )
10195 +#define dl_claim_space(in, bytes) (0)
10197 +#define dl_release_space(in, bytes) \
10198 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10199 + __FILE__, __LINE__ )
10201 +#define dl_free_space(in, bytes) \
10202 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10203 + __FILE__, __LINE__ )
10207 +#define dl_alloc_inode(in) \
10208 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10210 +#define dl_free_inode(in) \
10211 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10214 +#define dl_adjust_block(sb, tag, fb, rb) \
10215 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10219 +#warning duplicate inclusion
10221 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_inet.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_inet.h
10222 --- linux-2.6.38.3/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
10223 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_inet.h 2011-01-29 04:45:50.000000000 +0100
10225 +#ifndef _VS_INET_H
10226 +#define _VS_INET_H
10228 +#include "vserver/base.h"
10229 +#include "vserver/network.h"
10230 +#include "vserver/debug.h"
10232 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
10234 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
10235 + NIPQUAD((a)->mask), (a)->type
10236 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
10238 +#define NIPQUAD(addr) \
10239 + ((unsigned char *)&addr)[0], \
10240 + ((unsigned char *)&addr)[1], \
10241 + ((unsigned char *)&addr)[2], \
10242 + ((unsigned char *)&addr)[3]
10244 +#define NIPQUAD_FMT "%u.%u.%u.%u"
10248 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
10250 + __be32 ip = nxa->ip[0].s_addr;
10251 + __be32 mask = nxa->mask.s_addr;
10252 + __be32 bcast = ip | ~mask;
10255 + switch (nxa->type & tmask) {
10256 + case NXA_TYPE_MASK:
10257 + ret = (ip == (addr & mask));
10259 + case NXA_TYPE_ADDR:
10263 + /* fall through to broadcast */
10264 + case NXA_MOD_BCAST:
10265 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
10267 + case NXA_TYPE_RANGE:
10268 + ret = ((nxa->ip[0].s_addr <= addr) &&
10269 + (nxa->ip[1].s_addr > addr));
10271 + case NXA_TYPE_ANY:
10276 + vxdprintk(VXD_CBIT(net, 0),
10277 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
10278 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
10283 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
10285 + struct nx_addr_v4 *nxa;
10292 + /* allow 127.0.0.1 when remapping lback */
10293 + if ((tmask & NXA_LOOPBACK) &&
10294 + (addr == IPI_LOOPBACK) &&
10295 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10298 + /* check for lback address */
10299 + if ((tmask & NXA_MOD_LBACK) &&
10300 + (nxi->v4_lback.s_addr == addr))
10303 + /* check for broadcast address */
10304 + if ((tmask & NXA_MOD_BCAST) &&
10305 + (nxi->v4_bcast.s_addr == addr))
10308 + /* check for v4 addresses */
10309 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
10310 + if (v4_addr_match(nxa, addr, tmask))
10314 + vxdprintk(VXD_CBIT(net, 0),
10315 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
10316 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
10321 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
10323 + /* FIXME: needs full range checks */
10324 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
10328 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
10330 + struct nx_addr_v4 *ptr;
10332 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
10333 + if (v4_nx_addr_match(ptr, nxa, mask))
10338 +#include <net/inet_sock.h>
10341 + * Check if a given address matches for a socket
10343 + * nxi: the socket's nx_info if any
10344 + * addr: to be verified address
10347 +int v4_sock_addr_match (
10348 + struct nx_info *nxi,
10349 + struct inet_sock *inet,
10352 + __be32 saddr = inet->inet_rcv_saddr;
10353 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
10355 + if (addr && (saddr == addr || bcast == addr))
10358 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
10363 +/* inet related checks and helpers */
10367 +struct net_device;
10370 +#ifdef CONFIG_INET
10372 +#include <linux/netdevice.h>
10373 +#include <linux/inetdevice.h>
10374 +#include <net/inet_sock.h>
10375 +#include <net/inet_timewait_sock.h>
10378 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10379 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
10380 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
10384 + * check if address is covered by socket
10386 + * sk: the socket to check against
10387 + * addr: the address in question (must be != 0)
10391 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
10393 + struct nx_info *nxi = sk->sk_nx_info;
10394 + __be32 saddr = sk_rcv_saddr(sk);
10396 + vxdprintk(VXD_CBIT(net, 5),
10397 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
10398 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
10399 + (sk->sk_socket?sk->sk_socket->flags:0));
10401 + if (saddr) { /* direct address match */
10402 + return v4_addr_match(nxa, saddr, -1);
10403 + } else if (nxi) { /* match against nx_info */
10404 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
10405 + } else { /* unrestricted any socket */
10413 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
10415 + vxdprintk(VXD_CBIT(net, 1),
10416 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
10417 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
10418 + nxi ? dev_in_nx_info(dev, nxi) : 0);
10420 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10422 + if (dev_in_nx_info(dev, nxi))
10429 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
10435 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
10439 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
10441 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
10442 + nxi, nxi ? nxi->nx_id : 0, ifa,
10443 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
10445 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10447 + if (v4_ifa_in_nx_info(ifa, nxi))
10453 +struct nx_v4_sock_addr {
10454 + __be32 saddr; /* Address used for validation */
10455 + __be32 baddr; /* Address used for socket bind */
10459 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
10460 + struct nx_v4_sock_addr *nsa)
10462 + struct sock *sk = &inet->sk;
10463 + struct nx_info *nxi = sk->sk_nx_info;
10464 + __be32 saddr = addr->sin_addr.s_addr;
10465 + __be32 baddr = saddr;
10467 + vxdprintk(VXD_CBIT(net, 3),
10468 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
10469 + sk, sk->sk_nx_info, sk->sk_socket,
10470 + (sk->sk_socket ? sk->sk_socket->flags : 0),
10474 + if (saddr == INADDR_ANY) {
10475 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
10476 + baddr = nxi->v4.ip[0].s_addr;
10477 + } else if (saddr == IPI_LOOPBACK) {
10478 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10479 + baddr = nxi->v4_lback.s_addr;
10480 + } else { /* normal address bind */
10481 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
10482 + return -EADDRNOTAVAIL;
10486 + vxdprintk(VXD_CBIT(net, 3),
10487 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
10488 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
10490 + nsa->saddr = saddr;
10491 + nsa->baddr = baddr;
10496 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
10498 + inet->inet_saddr = nsa->baddr;
10499 + inet->inet_rcv_saddr = nsa->baddr;
10504 + * helper to simplify inet_lookup_listener
10506 + * nxi: the socket's nx_info if any
10507 + * addr: to be verified address
10508 + * saddr: socket address
10510 +static inline int v4_inet_addr_match (
10511 + struct nx_info *nxi,
10515 + if (addr && (saddr == addr))
10518 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
10522 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
10524 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
10525 + (addr == nxi->v4_lback.s_addr))
10526 + return IPI_LOOPBACK;
10531 +int nx_info_has_v4(struct nx_info *nxi)
10535 + if (NX_IPV4(nxi))
10537 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10542 +#else /* CONFIG_INET */
10545 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
10551 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10557 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10563 +int nx_info_has_v4(struct nx_info *nxi)
10568 +#endif /* CONFIG_INET */
10570 +#define current_nx_info_has_v4() \
10571 + nx_info_has_v4(current_nx_info())
10574 +// #warning duplicate inclusion
10576 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_inet6.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_inet6.h
10577 --- linux-2.6.38.3/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
10578 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_inet6.h 2011-01-29 02:01:07.000000000 +0100
10580 +#ifndef _VS_INET6_H
10581 +#define _VS_INET6_H
10583 +#include "vserver/base.h"
10584 +#include "vserver/network.h"
10585 +#include "vserver/debug.h"
10587 +#include <net/ipv6.h>
10589 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
10590 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
10593 +#ifdef CONFIG_IPV6
10596 +int v6_addr_match(struct nx_addr_v6 *nxa,
10597 + const struct in6_addr *addr, uint16_t mask)
10601 + switch (nxa->type & mask) {
10602 + case NXA_TYPE_MASK:
10603 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
10605 + case NXA_TYPE_ADDR:
10606 + ret = ipv6_addr_equal(&nxa->ip, addr);
10608 + case NXA_TYPE_ANY:
10612 + vxdprintk(VXD_CBIT(net, 0),
10613 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
10614 + nxa, NXAV6(nxa), addr, mask, ret);
10619 +int v6_addr_in_nx_info(struct nx_info *nxi,
10620 + const struct in6_addr *addr, uint16_t mask)
10622 + struct nx_addr_v6 *nxa;
10627 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
10628 + if (v6_addr_match(nxa, addr, mask))
10632 + vxdprintk(VXD_CBIT(net, 0),
10633 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
10634 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
10639 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
10641 + /* FIXME: needs full range checks */
10642 + return v6_addr_match(nxa, &addr->ip, mask);
10646 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
10648 + struct nx_addr_v6 *ptr;
10650 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
10651 + if (v6_nx_addr_match(ptr, nxa, mask))
10658 + * Check if a given address matches for a socket
10660 + * nxi: the socket's nx_info if any
10661 + * addr: to be verified address
10664 +int v6_sock_addr_match (
10665 + struct nx_info *nxi,
10666 + struct inet_sock *inet,
10667 + struct in6_addr *addr)
10669 + struct sock *sk = &inet->sk;
10670 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10672 + if (!ipv6_addr_any(addr) &&
10673 + ipv6_addr_equal(saddr, addr))
10675 + if (ipv6_addr_any(saddr))
10676 + return v6_addr_in_nx_info(nxi, addr, -1);
10681 + * check if address is covered by socket
10683 + * sk: the socket to check against
10684 + * addr: the address in question (must be != 0)
10688 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
10690 + struct nx_info *nxi = sk->sk_nx_info;
10691 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10693 + vxdprintk(VXD_CBIT(net, 5),
10694 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
10695 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
10696 + (sk->sk_socket?sk->sk_socket->flags:0));
10698 + if (!ipv6_addr_any(saddr)) { /* direct address match */
10699 + return v6_addr_match(nxa, saddr, -1);
10700 + } else if (nxi) { /* match against nx_info */
10701 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
10702 + } else { /* unrestricted any socket */
10708 +/* inet related checks and helpers */
10712 +struct net_device;
10716 +#include <linux/netdevice.h>
10717 +#include <linux/inetdevice.h>
10718 +#include <net/inet_timewait_sock.h>
10721 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10722 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
10723 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
10728 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
10734 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
10738 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
10740 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
10741 + nxi, nxi ? nxi->nx_id : 0, ifa,
10742 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
10744 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10746 + if (v6_ifa_in_nx_info(ifa, nxi))
10752 +struct nx_v6_sock_addr {
10753 + struct in6_addr saddr; /* Address used for validation */
10754 + struct in6_addr baddr; /* Address used for socket bind */
10758 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
10759 + struct nx_v6_sock_addr *nsa)
10761 + // struct sock *sk = &inet->sk;
10762 + // struct nx_info *nxi = sk->sk_nx_info;
10763 + struct in6_addr saddr = addr->sin6_addr;
10764 + struct in6_addr baddr = saddr;
10766 + nsa->saddr = saddr;
10767 + nsa->baddr = baddr;
10772 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10774 + // struct sock *sk = &inet->sk;
10775 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10777 + // *saddr = nsa->baddr;
10778 + // inet->inet_saddr = nsa->baddr;
10782 +int nx_info_has_v6(struct nx_info *nxi)
10786 + if (NX_IPV6(nxi))
10791 +#else /* CONFIG_IPV6 */
10794 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10801 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10807 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10813 +int nx_info_has_v6(struct nx_info *nxi)
10818 +#endif /* CONFIG_IPV6 */
10820 +#define current_nx_info_has_v6() \
10821 + nx_info_has_v6(current_nx_info())
10824 +#warning duplicate inclusion
10826 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_limit.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_limit.h
10827 --- linux-2.6.38.3/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
10828 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_limit.h 2011-01-29 04:59:22.000000000 +0100
10830 +#ifndef _VS_LIMIT_H
10831 +#define _VS_LIMIT_H
10833 +#include "vserver/limit.h"
10834 +#include "vserver/base.h"
10835 +#include "vserver/context.h"
10836 +#include "vserver/debug.h"
10837 +#include "vserver/context.h"
10838 +#include "vserver/limit_int.h"
10841 +#define vx_acc_cres(v, d, p, r) \
10842 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10844 +#define vx_acc_cres_cond(x, d, p, r) \
10845 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10846 + r, d, p, __FILE__, __LINE__)
10849 +#define vx_add_cres(v, a, p, r) \
10850 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10851 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10853 +#define vx_add_cres_cond(x, a, p, r) \
10854 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10855 + r, a, p, __FILE__, __LINE__)
10856 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10859 +/* process and file limits */
10861 +#define vx_nproc_inc(p) \
10862 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10864 +#define vx_nproc_dec(p) \
10865 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10867 +#define vx_files_inc(f) \
10868 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10870 +#define vx_files_dec(f) \
10871 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10873 +#define vx_locks_inc(l) \
10874 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10876 +#define vx_locks_dec(l) \
10877 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10879 +#define vx_openfd_inc(f) \
10880 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10882 +#define vx_openfd_dec(f) \
10883 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10886 +#define vx_cres_avail(v, n, r) \
10887 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10890 +#define vx_nproc_avail(n) \
10891 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10893 +#define vx_files_avail(n) \
10894 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10896 +#define vx_locks_avail(n) \
10897 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10899 +#define vx_openfd_avail(n) \
10900 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10903 +/* dentry limits */
10905 +#define vx_dentry_inc(d) do { \
10906 + if ((d)->d_count == 1) \
10907 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10910 +#define vx_dentry_dec(d) do { \
10911 + if ((d)->d_count == 0) \
10912 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10915 +#define vx_dentry_avail(n) \
10916 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10919 +/* socket limits */
10921 +#define vx_sock_inc(s) \
10922 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10924 +#define vx_sock_dec(s) \
10925 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10927 +#define vx_sock_avail(n) \
10928 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10931 +/* ipc resource limits */
10933 +#define vx_ipcmsg_add(v, u, a) \
10934 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10936 +#define vx_ipcmsg_sub(v, u, a) \
10937 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10939 +#define vx_ipcmsg_avail(v, a) \
10940 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10943 +#define vx_ipcshm_add(v, k, a) \
10944 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10946 +#define vx_ipcshm_sub(v, k, a) \
10947 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10949 +#define vx_ipcshm_avail(v, a) \
10950 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10953 +#define vx_semary_inc(a) \
10954 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10956 +#define vx_semary_dec(a) \
10957 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10960 +#define vx_nsems_add(a,n) \
10961 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10963 +#define vx_nsems_sub(a,n) \
10964 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10968 +#warning duplicate inclusion
10970 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_memory.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_memory.h
10971 --- linux-2.6.38.3/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
10972 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_memory.h 2011-01-29 02:01:07.000000000 +0100
10974 +#ifndef _VS_MEMORY_H
10975 +#define _VS_MEMORY_H
10977 +#include "vserver/limit.h"
10978 +#include "vserver/base.h"
10979 +#include "vserver/context.h"
10980 +#include "vserver/debug.h"
10981 +#include "vserver/context.h"
10982 +#include "vserver/limit_int.h"
10985 + VXPT_UNKNOWN = 0,
10994 +#define vx_page_fault(mm, vma, type, ret)
10998 +void __vx_page_fault(struct mm_struct *mm,
10999 + struct vm_area_struct *vma, int type, int ret)
11001 + struct vx_info *vxi = mm->mm_vx_info;
11004 + static char *page_type[6] =
11005 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
11006 + static char *page_what[4] =
11007 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
11013 + what = (ret & 0x3);
11015 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
11016 + type, what, ret, page_type[type], page_what[what]);
11018 + if (ret & VM_FAULT_WRITE)
11020 + atomic_inc(&vxi->cacct.page[type][what]);
11023 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
11027 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
11030 +#warning duplicate inclusion
11032 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_network.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_network.h
11033 --- linux-2.6.38.3/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
11034 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_network.h 2011-01-29 02:01:07.000000000 +0100
11036 +#ifndef _NX_VS_NETWORK_H
11037 +#define _NX_VS_NETWORK_H
11039 +#include "vserver/context.h"
11040 +#include "vserver/network.h"
11041 +#include "vserver/base.h"
11042 +#include "vserver/check.h"
11043 +#include "vserver/debug.h"
11045 +#include <linux/sched.h>
11048 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
11050 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
11051 + const char *_file, int _line)
11056 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
11057 + nxi, nxi ? nxi->nx_id : 0,
11058 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11061 + atomic_inc(&nxi->nx_usecnt);
11066 +extern void free_nx_info(struct nx_info *);
11068 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
11070 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
11075 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
11076 + nxi, nxi ? nxi->nx_id : 0,
11077 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11080 + if (atomic_dec_and_test(&nxi->nx_usecnt))
11081 + free_nx_info(nxi);
11085 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
11087 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
11088 + const char *_file, int _line)
11091 + vxlprintk(VXD_CBIT(nid, 3),
11092 + "init_nx_info(%p[#%d.%d])",
11093 + nxi, nxi ? nxi->nx_id : 0,
11094 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11097 + atomic_inc(&nxi->nx_usecnt);
11103 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
11105 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
11106 + const char *_file, int _line)
11108 + struct nx_info *nxo;
11113 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
11114 + nxi, nxi ? nxi->nx_id : 0,
11115 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11118 + atomic_inc(&nxi->nx_usecnt);
11119 + nxo = xchg(nxp, nxi);
11123 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
11125 +static inline void __clr_nx_info(struct nx_info **nxp,
11126 + const char *_file, int _line)
11128 + struct nx_info *nxo;
11130 + nxo = xchg(nxp, NULL);
11134 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
11135 + nxo, nxo ? nxo->nx_id : 0,
11136 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
11139 + if (atomic_dec_and_test(&nxo->nx_usecnt))
11140 + free_nx_info(nxo);
11144 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
11146 +static inline void __claim_nx_info(struct nx_info *nxi,
11147 + struct task_struct *task, const char *_file, int _line)
11149 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
11150 + nxi, nxi ? nxi->nx_id : 0,
11151 + nxi?atomic_read(&nxi->nx_usecnt):0,
11152 + nxi?atomic_read(&nxi->nx_tasks):0,
11153 + task, _file, _line);
11155 + atomic_inc(&nxi->nx_tasks);
11159 +extern void unhash_nx_info(struct nx_info *);
11161 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
11163 +static inline void __release_nx_info(struct nx_info *nxi,
11164 + struct task_struct *task, const char *_file, int _line)
11166 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
11167 + nxi, nxi ? nxi->nx_id : 0,
11168 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11169 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
11170 + task, _file, _line);
11174 + if (atomic_dec_and_test(&nxi->nx_tasks))
11175 + unhash_nx_info(nxi);
11179 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
11181 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
11182 + const char *_file, int _line)
11184 + struct nx_info *nxi;
11187 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
11188 + p, _file, _line);
11189 + nxi = __get_nx_info(p->nx_info, _file, _line);
11195 +static inline void exit_nx_info(struct task_struct *p)
11198 + release_nx_info(p->nx_info, p);
11203 +#warning duplicate inclusion
11205 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_pid.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_pid.h
11206 --- linux-2.6.38.3/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
11207 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_pid.h 2011-03-22 17:43:53.000000000 +0100
11212 +#include "vserver/base.h"
11213 +#include "vserver/check.h"
11214 +#include "vserver/context.h"
11215 +#include "vserver/debug.h"
11216 +#include "vserver/pid.h"
11217 +#include <linux/pid_namespace.h>
11220 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
11223 +int vx_proc_task_visible(struct task_struct *task)
11225 + if ((task->pid == 1) &&
11226 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
11227 + /* show a blend through init */
11229 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
11236 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
11240 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
11242 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
11244 + if (task && !vx_proc_task_visible(task)) {
11245 + vxdprintk(VXD_CBIT(misc, 6),
11246 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
11247 + task, task->xid, task->pid,
11248 + current, current->xid, current->pid);
11249 + put_task_struct(task);
11257 +#warning duplicate inclusion
11259 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_sched.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_sched.h
11260 --- linux-2.6.38.3/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
11261 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_sched.h 2011-01-29 02:01:07.000000000 +0100
11263 +#ifndef _VS_SCHED_H
11264 +#define _VS_SCHED_H
11266 +#include "vserver/base.h"
11267 +#include "vserver/context.h"
11268 +#include "vserver/sched.h"
11271 +#define MAX_PRIO_BIAS 20
11272 +#define MIN_PRIO_BIAS -20
11275 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
11277 + struct vx_info *vxi = p->vx_info;
11280 + prio += vx_cpu(vxi, sched_pc).prio_bias;
11284 +static inline void vx_account_user(struct vx_info *vxi,
11285 + cputime_t cputime, int nice)
11289 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
11292 +static inline void vx_account_system(struct vx_info *vxi,
11293 + cputime_t cputime, int idle)
11297 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
11301 +#warning duplicate inclusion
11303 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_socket.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_socket.h
11304 --- linux-2.6.38.3/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
11305 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_socket.h 2011-01-29 02:01:07.000000000 +0100
11307 +#ifndef _VS_SOCKET_H
11308 +#define _VS_SOCKET_H
11310 +#include "vserver/debug.h"
11311 +#include "vserver/base.h"
11312 +#include "vserver/cacct.h"
11313 +#include "vserver/context.h"
11314 +#include "vserver/tag.h"
11317 +/* socket accounting */
11319 +#include <linux/socket.h>
11321 +static inline int vx_sock_type(int family)
11323 + switch (family) {
11325 + return VXA_SOCK_UNSPEC;
11327 + return VXA_SOCK_UNIX;
11329 + return VXA_SOCK_INET;
11331 + return VXA_SOCK_INET6;
11333 + return VXA_SOCK_PACKET;
11335 + return VXA_SOCK_OTHER;
11339 +#define vx_acc_sock(v, f, p, s) \
11340 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
11342 +static inline void __vx_acc_sock(struct vx_info *vxi,
11343 + int family, int pos, int size, char *file, int line)
11346 + int type = vx_sock_type(family);
11348 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
11349 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
11353 +#define vx_sock_recv(sk, s) \
11354 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
11355 +#define vx_sock_send(sk, s) \
11356 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
11357 +#define vx_sock_fail(sk, s) \
11358 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
11361 +#define sock_vx_init(s) do { \
11362 + (s)->sk_xid = 0; \
11363 + (s)->sk_vx_info = NULL; \
11366 +#define sock_nx_init(s) do { \
11367 + (s)->sk_nid = 0; \
11368 + (s)->sk_nx_info = NULL; \
11372 +#warning duplicate inclusion
11374 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_tag.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_tag.h
11375 --- linux-2.6.38.3/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
11376 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_tag.h 2011-01-29 02:01:07.000000000 +0100
11381 +#include <linux/vserver/tag.h>
11383 +/* check conditions */
11385 +#define DX_ADMIN 0x0001
11386 +#define DX_WATCH 0x0002
11387 +#define DX_HOSTID 0x0008
11389 +#define DX_IDENT 0x0010
11391 +#define DX_ARG_MASK 0x0010
11394 +#define dx_task_tag(t) ((t)->tag)
11396 +#define dx_current_tag() dx_task_tag(current)
11398 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
11400 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
11404 + * check current context for ADMIN/WATCH and
11405 + * optionally against supplied argument
11407 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
11409 + if (mode & DX_ARG_MASK) {
11410 + if ((mode & DX_IDENT) && (id == cid))
11413 + return (((mode & DX_ADMIN) && (cid == 0)) ||
11414 + ((mode & DX_WATCH) && (cid == 1)) ||
11415 + ((mode & DX_HOSTID) && (id == 0)));
11419 +int dx_permission(const struct inode *inode, int mask);
11423 +#warning duplicate inclusion
11425 diff -NurpP --minimal linux-2.6.38.3/include/linux/vs_time.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_time.h
11426 --- linux-2.6.38.3/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
11427 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vs_time.h 2011-01-29 02:01:07.000000000 +0100
11429 +#ifndef _VS_TIME_H
11430 +#define _VS_TIME_H
11433 +/* time faking stuff */
11435 +#ifdef CONFIG_VSERVER_VTIME
11437 +extern void vx_adjust_timespec(struct timespec *ts);
11438 +extern int vx_settimeofday(struct timespec *ts);
11441 +#define vx_adjust_timespec(t) do { } while (0)
11442 +#define vx_settimeofday(t) do_settimeofday(t)
11446 +#warning duplicate inclusion
11448 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/Kbuild linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/Kbuild
11449 --- linux-2.6.38.3/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11450 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/Kbuild 2011-01-29 02:01:07.000000000 +0100
11453 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11454 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11455 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11456 + debug_cmd.h device_cmd.h
11458 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11460 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/base.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/base.h
11461 --- linux-2.6.38.3/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
11462 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/base.h 2011-01-29 02:01:07.000000000 +0100
11464 +#ifndef _VX_BASE_H
11465 +#define _VX_BASE_H
11468 +/* context state changes */
11480 +#define vx_task_xid(t) ((t)->xid)
11482 +#define vx_current_xid() vx_task_xid(current)
11484 +#define current_vx_info() (current->vx_info)
11487 +#define nx_task_nid(t) ((t)->nid)
11489 +#define nx_current_nid() nx_task_nid(current)
11491 +#define current_nx_info() (current->nx_info)
11494 +/* generic flag merging */
11496 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
11498 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11500 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
11502 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
11505 +/* context flags */
11507 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
11509 +#define vx_current_flags() __vx_flags(current_vx_info())
11511 +#define vx_info_flags(v, m, f) \
11512 + vs_check_flags(__vx_flags(v), m, f)
11514 +#define task_vx_flags(t, m, f) \
11515 + ((t) && vx_info_flags((t)->vx_info, m, f))
11517 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11520 +/* context caps */
11522 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
11524 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
11526 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
11528 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
11532 +/* network flags */
11534 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
11536 +#define nx_current_flags() __nx_flags(current_nx_info())
11538 +#define nx_info_flags(n, m, f) \
11539 + vs_check_flags(__nx_flags(n), m, f)
11541 +#define task_nx_flags(t, m, f) \
11542 + ((t) && nx_info_flags((t)->nx_info, m, f))
11544 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11547 +/* network caps */
11549 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
11551 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
11553 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
11555 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
11558 +/* context mask capabilities */
11560 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11562 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
11564 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
11567 +/* context bcap mask */
11569 +#define __vx_bcaps(v) ((v)->vx_bcaps)
11571 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
11574 +/* mask given bcaps */
11576 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11578 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
11581 +/* masked cap_bset */
11583 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
11585 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
11588 +#define vx_info_mbcap(v, b) \
11589 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11590 + vx_info_bcaps(v, b) : (b))
11592 +#define task_vx_mbcap(t, b) \
11593 + vx_info_mbcap((t)->vx_info, (t)->b)
11595 +#define vx_mbcap(b) task_vx_mbcap(current, b)
11598 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11600 +#define vx_capable(b, c) (capable(b) || \
11601 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
11603 +#define nx_capable(b, c) (capable(b) || \
11604 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
11606 +#define vx_task_initpid(t, n) \
11607 + ((t)->vx_info && \
11608 + ((t)->vx_info->vx_initpid == (n)))
11610 +#define vx_current_initpid(n) vx_task_initpid(current, n)
11613 +/* context unshare mask */
11615 +#define __vx_umask(v) ((v)->vx_umask)
11617 +#define vx_current_umask() __vx_umask(current_vx_info())
11619 +#define vx_can_unshare(b, f) (capable(b) || \
11620 + (cap_raised(current_cap(), b) && \
11621 + !((f) & ~vx_current_umask())))
11624 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
11626 +#define vx_info_state(v, m) (__vx_state(v) & (m))
11629 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
11631 +#define nx_info_state(n, m) (__nx_state(n) & (m))
11634 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/cacct.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cacct.h
11635 --- linux-2.6.38.3/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
11636 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cacct.h 2011-01-29 02:01:07.000000000 +0100
11638 +#ifndef _VX_CACCT_H
11639 +#define _VX_CACCT_H
11642 +enum sock_acc_field {
11643 + VXA_SOCK_UNSPEC = 0,
11649 + VXA_SOCK_SIZE /* array size */
11652 +#endif /* _VX_CACCT_H */
11653 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/cacct_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cacct_cmd.h
11654 --- linux-2.6.38.3/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
11655 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cacct_cmd.h 2011-01-29 02:01:07.000000000 +0100
11657 +#ifndef _VX_CACCT_CMD_H
11658 +#define _VX_CACCT_CMD_H
11661 +/* virtual host info name commands */
11663 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
11665 +struct vcmd_sock_stat_v0 {
11667 + uint32_t count[3];
11668 + uint64_t total[3];
11674 +#include <linux/compiler.h>
11676 +extern int vc_sock_stat(struct vx_info *, void __user *);
11678 +#endif /* __KERNEL__ */
11679 +#endif /* _VX_CACCT_CMD_H */
11680 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/cacct_def.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cacct_def.h
11681 --- linux-2.6.38.3/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
11682 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cacct_def.h 2011-01-29 02:01:07.000000000 +0100
11684 +#ifndef _VX_CACCT_DEF_H
11685 +#define _VX_CACCT_DEF_H
11687 +#include <asm/atomic.h>
11688 +#include <linux/vserver/cacct.h>
11691 +struct _vx_sock_acc {
11692 + atomic_long_t count;
11693 + atomic_long_t total;
11696 +/* context sub struct */
11698 +struct _vx_cacct {
11699 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11700 + atomic_t slab[8];
11701 + atomic_t page[6][8];
11704 +#ifdef CONFIG_VSERVER_DEBUG
11706 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11710 + printk("\t_vx_cacct:");
11711 + for (i = 0; i < 6; i++) {
11712 + struct _vx_sock_acc *ptr = cacct->sock[i];
11714 + printk("\t [%d] =", i);
11715 + for (j = 0; j < 3; j++) {
11716 + printk(" [%d] = %8lu, %8lu", j,
11717 + atomic_long_read(&ptr[j].count),
11718 + atomic_long_read(&ptr[j].total));
11726 +#endif /* _VX_CACCT_DEF_H */
11727 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/cacct_int.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cacct_int.h
11728 --- linux-2.6.38.3/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
11729 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cacct_int.h 2011-01-29 02:01:07.000000000 +0100
11731 +#ifndef _VX_CACCT_INT_H
11732 +#define _VX_CACCT_INT_H
11738 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11740 + return atomic_long_read(&cacct->sock[type][pos].count);
11745 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11747 + return atomic_long_read(&cacct->sock[type][pos].total);
11750 +#endif /* __KERNEL__ */
11751 +#endif /* _VX_CACCT_INT_H */
11752 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/check.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/check.h
11753 --- linux-2.6.38.3/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
11754 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/check.h 2011-01-29 02:01:07.000000000 +0100
11756 +#ifndef _VS_CHECK_H
11757 +#define _VS_CHECK_H
11760 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
11762 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11763 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
11765 +#define MIN_D_CONTEXT 65536
11768 +/* check conditions */
11770 +#define VS_ADMIN 0x0001
11771 +#define VS_WATCH 0x0002
11772 +#define VS_HIDE 0x0004
11773 +#define VS_HOSTID 0x0008
11775 +#define VS_IDENT 0x0010
11776 +#define VS_EQUIV 0x0020
11777 +#define VS_PARENT 0x0040
11778 +#define VS_CHILD 0x0080
11780 +#define VS_ARG_MASK 0x00F0
11782 +#define VS_DYNAMIC 0x0100
11783 +#define VS_STATIC 0x0200
11785 +#define VS_ATR_MASK 0x0F00
11787 +#ifdef CONFIG_VSERVER_PRIVACY
11788 +#define VS_ADMIN_P (0)
11789 +#define VS_WATCH_P (0)
11791 +#define VS_ADMIN_P VS_ADMIN
11792 +#define VS_WATCH_P VS_WATCH
11795 +#define VS_HARDIRQ 0x1000
11796 +#define VS_SOFTIRQ 0x2000
11797 +#define VS_IRQ 0x4000
11799 +#define VS_IRQ_MASK 0xF000
11801 +#include <linux/hardirq.h>
11804 + * check current context for ADMIN/WATCH and
11805 + * optionally against supplied argument
11807 +static inline int __vs_check(int cid, int id, unsigned int mode)
11809 + if (mode & VS_ARG_MASK) {
11810 + if ((mode & VS_IDENT) && (id == cid))
11813 + if (mode & VS_ATR_MASK) {
11814 + if ((mode & VS_DYNAMIC) &&
11815 + (id >= MIN_D_CONTEXT) &&
11816 + (id <= MAX_S_CONTEXT))
11818 + if ((mode & VS_STATIC) &&
11819 + (id > 1) && (id < MIN_D_CONTEXT))
11822 + if (mode & VS_IRQ_MASK) {
11823 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11825 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11827 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11830 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11831 + ((mode & VS_WATCH) && (cid == 1)) ||
11832 + ((mode & VS_HOSTID) && (id == 0)));
11835 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11837 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11840 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11842 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11845 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/context.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/context.h
11846 --- linux-2.6.38.3/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
11847 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/context.h 2011-01-31 22:46:21.000000000 +0100
11849 +#ifndef _VX_CONTEXT_H
11850 +#define _VX_CONTEXT_H
11852 +#include <linux/types.h>
11853 +#include <linux/capability.h>
11856 +/* context flags */
11858 +#define VXF_INFO_SCHED 0x00000002
11859 +#define VXF_INFO_NPROC 0x00000004
11860 +#define VXF_INFO_PRIVATE 0x00000008
11862 +#define VXF_INFO_INIT 0x00000010
11863 +#define VXF_INFO_HIDE 0x00000020
11864 +#define VXF_INFO_ULIMIT 0x00000040
11865 +#define VXF_INFO_NSPACE 0x00000080
11867 +#define VXF_SCHED_HARD 0x00000100
11868 +#define VXF_SCHED_PRIO 0x00000200
11869 +#define VXF_SCHED_PAUSE 0x00000400
11871 +#define VXF_VIRT_MEM 0x00010000
11872 +#define VXF_VIRT_UPTIME 0x00020000
11873 +#define VXF_VIRT_CPU 0x00040000
11874 +#define VXF_VIRT_LOAD 0x00080000
11875 +#define VXF_VIRT_TIME 0x00100000
11877 +#define VXF_HIDE_MOUNT 0x01000000
11878 +/* was VXF_HIDE_NETIF 0x02000000 */
11879 +#define VXF_HIDE_VINFO 0x04000000
11881 +#define VXF_STATE_SETUP (1ULL << 32)
11882 +#define VXF_STATE_INIT (1ULL << 33)
11883 +#define VXF_STATE_ADMIN (1ULL << 34)
11885 +#define VXF_SC_HELPER (1ULL << 36)
11886 +#define VXF_REBOOT_KILL (1ULL << 37)
11887 +#define VXF_PERSISTENT (1ULL << 38)
11889 +#define VXF_FORK_RSS (1ULL << 48)
11890 +#define VXF_PROLIFIC (1ULL << 49)
11892 +#define VXF_IGNEG_NICE (1ULL << 52)
11894 +#define VXF_ONE_TIME (0x0007ULL << 32)
11896 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11899 +/* context migration */
11901 +#define VXM_SET_INIT 0x00000001
11902 +#define VXM_SET_REAPER 0x00000002
11904 +/* context caps */
11906 +#define VXC_CAP_MASK 0x00000000
11908 +#define VXC_SET_UTSNAME 0x00000001
11909 +#define VXC_SET_RLIMIT 0x00000002
11910 +#define VXC_FS_SECURITY 0x00000004
11911 +#define VXC_FS_TRUSTED 0x00000008
11912 +#define VXC_TIOCSTI 0x00000010
11914 +/* was VXC_RAW_ICMP 0x00000100 */
11915 +#define VXC_SYSLOG 0x00001000
11916 +#define VXC_OOM_ADJUST 0x00002000
11917 +#define VXC_AUDIT_CONTROL 0x00004000
11919 +#define VXC_SECURE_MOUNT 0x00010000
11920 +#define VXC_SECURE_REMOUNT 0x00020000
11921 +#define VXC_BINARY_MOUNT 0x00040000
11923 +#define VXC_QUOTA_CTL 0x00100000
11924 +#define VXC_ADMIN_MAPPER 0x00200000
11925 +#define VXC_ADMIN_CLOOP 0x00400000
11927 +#define VXC_KTHREAD 0x01000000
11928 +#define VXC_NAMESPACE 0x02000000
11933 +#include <linux/list.h>
11934 +#include <linux/spinlock.h>
11935 +#include <linux/rcupdate.h>
11937 +#include "limit_def.h"
11938 +#include "sched_def.h"
11939 +#include "cvirt_def.h"
11940 +#include "cacct_def.h"
11941 +#include "device_def.h"
11943 +#define VX_SPACES 2
11945 +struct _vx_info_pc {
11946 + struct _vx_sched_pc sched_pc;
11947 + struct _vx_cvirt_pc cvirt_pc;
11950 +struct _vx_space {
11951 + unsigned long vx_nsmask; /* assignment mask */
11952 + struct nsproxy *vx_nsproxy; /* private namespaces */
11953 + struct fs_struct *vx_fs; /* private namespace fs */
11954 + const struct cred *vx_cred; /* task credentials */
11958 + struct hlist_node vx_hlist; /* linked list of contexts */
11959 + xid_t vx_id; /* context id */
11960 + atomic_t vx_usecnt; /* usage count */
11961 + atomic_t vx_tasks; /* tasks count */
11962 + struct vx_info *vx_parent; /* parent context */
11963 + int vx_state; /* context state */
11965 + struct _vx_space space[VX_SPACES]; /* namespace store */
11967 + uint64_t vx_flags; /* context flags */
11968 + uint64_t vx_ccaps; /* context caps (vserver) */
11969 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11970 + unsigned long vx_umask; /* unshare mask (guest) */
11972 + struct task_struct *vx_reaper; /* guest reaper process */
11973 + pid_t vx_initpid; /* PID of guest init */
11974 + int64_t vx_badness_bias; /* OOM points bias */
11976 + struct _vx_limit limit; /* vserver limits */
11977 + struct _vx_sched sched; /* vserver scheduler */
11978 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11979 + struct _vx_cacct cacct; /* context accounting */
11981 + struct _vx_device dmap; /* default device map targets */
11983 +#ifndef CONFIG_SMP
11984 + struct _vx_info_pc info_pc; /* per cpu data */
11986 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11989 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11990 + int reboot_cmd; /* last sys_reboot() cmd */
11991 + int exit_code; /* last process exit code */
11993 + char vx_name[65]; /* vserver name */
11996 +#ifndef CONFIG_SMP
11997 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11998 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
12000 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
12001 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
12004 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
12007 +struct vx_info_save {
12008 + struct vx_info *vxi;
12013 +/* status flags */
12015 +#define VXS_HASHED 0x0001
12016 +#define VXS_PAUSED 0x0010
12017 +#define VXS_SHUTDOWN 0x0100
12018 +#define VXS_HELPER 0x1000
12019 +#define VXS_RELEASED 0x8000
12022 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
12023 +extern void release_vx_info(struct vx_info *, struct task_struct *);
12025 +extern struct vx_info *lookup_vx_info(int);
12026 +extern struct vx_info *lookup_or_create_vx_info(int);
12028 +extern int get_xid_list(int, unsigned int *, int);
12029 +extern int xid_is_hashed(xid_t);
12031 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
12033 +extern long vs_state_change(struct vx_info *, unsigned int);
12036 +#endif /* __KERNEL__ */
12037 +#endif /* _VX_CONTEXT_H */
12038 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/context_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/context_cmd.h
12039 --- linux-2.6.38.3/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
12040 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/context_cmd.h 2011-01-29 02:01:07.000000000 +0100
12042 +#ifndef _VX_CONTEXT_CMD_H
12043 +#define _VX_CONTEXT_CMD_H
12046 +/* vinfo commands */
12048 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
12051 +extern int vc_task_xid(uint32_t);
12053 +#endif /* __KERNEL__ */
12055 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
12057 +struct vcmd_vx_info_v0 {
12059 + uint32_t initpid;
12060 + /* more to come */
12064 +extern int vc_vx_info(struct vx_info *, void __user *);
12066 +#endif /* __KERNEL__ */
12068 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
12070 +struct vcmd_ctx_stat_v0 {
12073 + /* more to come */
12077 +extern int vc_ctx_stat(struct vx_info *, void __user *);
12079 +#endif /* __KERNEL__ */
12081 +/* context commands */
12083 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
12084 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
12086 +struct vcmd_ctx_create {
12087 + uint64_t flagword;
12090 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
12091 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
12093 +struct vcmd_ctx_migrate {
12094 + uint64_t flagword;
12098 +extern int vc_ctx_create(uint32_t, void __user *);
12099 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
12101 +#endif /* __KERNEL__ */
12104 +/* flag commands */
12106 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
12107 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
12109 +struct vcmd_ctx_flags_v0 {
12110 + uint64_t flagword;
12115 +extern int vc_get_cflags(struct vx_info *, void __user *);
12116 +extern int vc_set_cflags(struct vx_info *, void __user *);
12118 +#endif /* __KERNEL__ */
12121 +/* context caps commands */
12123 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
12124 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
12126 +struct vcmd_ctx_caps_v1 {
12132 +extern int vc_get_ccaps(struct vx_info *, void __user *);
12133 +extern int vc_set_ccaps(struct vx_info *, void __user *);
12135 +#endif /* __KERNEL__ */
12138 +/* bcaps commands */
12140 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
12141 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
12143 +struct vcmd_bcaps {
12149 +extern int vc_get_bcaps(struct vx_info *, void __user *);
12150 +extern int vc_set_bcaps(struct vx_info *, void __user *);
12152 +#endif /* __KERNEL__ */
12155 +/* umask commands */
12157 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
12158 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
12160 +struct vcmd_umask {
12166 +extern int vc_get_umask(struct vx_info *, void __user *);
12167 +extern int vc_set_umask(struct vx_info *, void __user *);
12169 +#endif /* __KERNEL__ */
12174 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
12175 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
12177 +struct vcmd_badness_v0 {
12182 +extern int vc_get_badness(struct vx_info *, void __user *);
12183 +extern int vc_set_badness(struct vx_info *, void __user *);
12185 +#endif /* __KERNEL__ */
12186 +#endif /* _VX_CONTEXT_CMD_H */
12187 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/cvirt.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cvirt.h
12188 --- linux-2.6.38.3/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
12189 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cvirt.h 2011-01-29 02:01:07.000000000 +0100
12191 +#ifndef _VX_CVIRT_H
12192 +#define _VX_CVIRT_H
12199 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12204 +void vx_update_load(struct vx_info *);
12207 +int vx_do_syslog(int, char __user *, int);
12209 +#endif /* __KERNEL__ */
12210 +#endif /* _VX_CVIRT_H */
12211 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/cvirt_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cvirt_cmd.h
12212 --- linux-2.6.38.3/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
12213 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cvirt_cmd.h 2011-01-29 02:01:07.000000000 +0100
12215 +#ifndef _VX_CVIRT_CMD_H
12216 +#define _VX_CVIRT_CMD_H
12219 +/* virtual host info name commands */
12221 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
12222 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
12224 +struct vcmd_vhi_name_v0 {
12230 +enum vhi_name_field {
12231 + VHIN_CONTEXT = 0,
12243 +#include <linux/compiler.h>
12245 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
12246 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
12248 +#endif /* __KERNEL__ */
12250 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
12252 +struct vcmd_virt_stat_v0 {
12255 + uint32_t nr_threads;
12256 + uint32_t nr_running;
12257 + uint32_t nr_uninterruptible;
12258 + uint32_t nr_onhold;
12259 + uint32_t nr_forks;
12260 + uint32_t load[3];
12264 +extern int vc_virt_stat(struct vx_info *, void __user *);
12266 +#endif /* __KERNEL__ */
12267 +#endif /* _VX_CVIRT_CMD_H */
12268 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/cvirt_def.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cvirt_def.h
12269 --- linux-2.6.38.3/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
12270 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/cvirt_def.h 2011-01-29 02:01:07.000000000 +0100
12272 +#ifndef _VX_CVIRT_DEF_H
12273 +#define _VX_CVIRT_DEF_H
12275 +#include <linux/jiffies.h>
12276 +#include <linux/spinlock.h>
12277 +#include <linux/wait.h>
12278 +#include <linux/time.h>
12279 +#include <asm/atomic.h>
12282 +struct _vx_usage_stat {
12286 + uint64_t softirq;
12292 +struct _vx_syslog {
12293 + wait_queue_head_t log_wait;
12294 + spinlock_t logbuf_lock; /* lock for the log buffer */
12296 + unsigned long log_start; /* next char to be read by syslog() */
12297 + unsigned long con_start; /* next char to be sent to consoles */
12298 + unsigned long log_end; /* most-recently-written-char + 1 */
12299 + unsigned long logged_chars; /* #chars since last read+clear operation */
12301 + char log_buf[1024];
12305 +/* context sub struct */
12307 +struct _vx_cvirt {
12308 + atomic_t nr_threads; /* number of current threads */
12309 + atomic_t nr_running; /* number of running threads */
12310 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
12312 + atomic_t nr_onhold; /* processes on hold */
12313 + uint32_t onhold_last; /* jiffies when put on hold */
12315 + struct timespec bias_ts; /* time offset to the host */
12316 + struct timespec bias_idle;
12317 + struct timespec bias_uptime; /* context creation point */
12318 + uint64_t bias_clock; /* offset in clock_t */
12320 + spinlock_t load_lock; /* lock for the load averages */
12321 + atomic_t load_updates; /* nr of load updates done so far */
12322 + uint32_t load_last; /* last time load was calculated */
12323 + uint32_t load[3]; /* load averages 1,5,15 */
12325 + atomic_t total_forks; /* number of forks so far */
12327 + struct _vx_syslog syslog;
12330 +struct _vx_cvirt_pc {
12331 + struct _vx_usage_stat cpustat;
12335 +#ifdef CONFIG_VSERVER_DEBUG
12337 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
12339 + printk("\t_vx_cvirt:\n");
12340 + printk("\t threads: %4d, %4d, %4d, %4d\n",
12341 + atomic_read(&cvirt->nr_threads),
12342 + atomic_read(&cvirt->nr_running),
12343 + atomic_read(&cvirt->nr_uninterruptible),
12344 + atomic_read(&cvirt->nr_onhold));
12345 + /* add rest here */
12346 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
12351 +#endif /* _VX_CVIRT_DEF_H */
12352 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/debug.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/debug.h
12353 --- linux-2.6.38.3/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
12354 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/debug.h 2011-01-29 02:01:07.000000000 +0100
12356 +#ifndef _VX_DEBUG_H
12357 +#define _VX_DEBUG_H
12360 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
12361 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
12362 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
12364 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
12365 + imajor((d)->bd_inode), iminor((d)->bd_inode)
12366 +#define VXF_DEV "%p[%lu,%d:%d]"
12368 +#if defined(CONFIG_QUOTES_UTF8)
12369 +#define VS_Q_LQM "\xc2\xbb"
12370 +#define VS_Q_RQM "\xc2\xab"
12371 +#elif defined(CONFIG_QUOTES_ASCII)
12372 +#define VS_Q_LQM "\x27"
12373 +#define VS_Q_RQM "\x27"
12375 +#define VS_Q_LQM "\xbb"
12376 +#define VS_Q_RQM "\xab"
12379 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
12382 +#define vxd_path(p) \
12383 + ({ static char _buffer[PATH_MAX]; \
12384 + d_path(p, _buffer, sizeof(_buffer)); })
12386 +#define vxd_cond_path(n) \
12387 + ((n) ? vxd_path(&(n)->path) : "<null>" )
12390 +#ifdef CONFIG_VSERVER_DEBUG
12392 +extern unsigned int vx_debug_switch;
12393 +extern unsigned int vx_debug_xid;
12394 +extern unsigned int vx_debug_nid;
12395 +extern unsigned int vx_debug_tag;
12396 +extern unsigned int vx_debug_net;
12397 +extern unsigned int vx_debug_limit;
12398 +extern unsigned int vx_debug_cres;
12399 +extern unsigned int vx_debug_dlim;
12400 +extern unsigned int vx_debug_quota;
12401 +extern unsigned int vx_debug_cvirt;
12402 +extern unsigned int vx_debug_space;
12403 +extern unsigned int vx_debug_misc;
12406 +#define VX_LOGLEVEL "vxD: "
12407 +#define VX_PROC_FMT "%p: "
12408 +#define VX_PROCESS current
12410 +#define vxdprintk(c, f, x...) \
12413 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
12414 + VX_PROCESS , ##x); \
12417 +#define vxlprintk(c, f, x...) \
12420 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
12423 +#define vxfprintk(c, f, x...) \
12426 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
12432 +void dump_vx_info(struct vx_info *, int);
12433 +void dump_vx_info_inactive(int);
12435 +#else /* CONFIG_VSERVER_DEBUG */
12437 +#define vx_debug_switch 0
12438 +#define vx_debug_xid 0
12439 +#define vx_debug_nid 0
12440 +#define vx_debug_tag 0
12441 +#define vx_debug_net 0
12442 +#define vx_debug_limit 0
12443 +#define vx_debug_cres 0
12444 +#define vx_debug_dlim 0
12445 +#define vx_debug_cvirt 0
12447 +#define vxdprintk(x...) do { } while (0)
12448 +#define vxlprintk(x...) do { } while (0)
12449 +#define vxfprintk(x...) do { } while (0)
12451 +#endif /* CONFIG_VSERVER_DEBUG */
12454 +#ifdef CONFIG_VSERVER_WARN
12456 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
12457 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
12458 +#define VX_WARN_XID "[xid #%u] "
12459 +#define VX_WARN_NID "[nid #%u] "
12460 +#define VX_WARN_TAG "[tag #%u] "
12462 +#define vxwprintk(c, f, x...) \
12465 + printk(VX_WARNLEVEL f "\n", ##x); \
12468 +#else /* CONFIG_VSERVER_WARN */
12470 +#define vxwprintk(x...) do { } while (0)
12472 +#endif /* CONFIG_VSERVER_WARN */
12474 +#define vxwprintk_task(c, f, x...) \
12475 + vxwprintk(c, VX_WARN_TASK f, \
12476 + current->comm, current->pid, \
12477 + current->xid, current->nid, current->tag, ##x)
12478 +#define vxwprintk_xid(c, f, x...) \
12479 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
12480 +#define vxwprintk_nid(c, f, x...) \
12481 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
12482 +#define vxwprintk_tag(c, f, x...) \
12483 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12485 +#ifdef CONFIG_VSERVER_DEBUG
12486 +#define vxd_assert_lock(l) assert_spin_locked(l)
12487 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12488 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12490 +#define vxd_assert_lock(l) do { } while (0)
12491 +#define vxd_assert(c, f, x...) do { } while (0)
12495 +#endif /* _VX_DEBUG_H */
12496 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/debug_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/debug_cmd.h
12497 --- linux-2.6.38.3/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
12498 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/debug_cmd.h 2011-01-29 02:01:07.000000000 +0100
12500 +#ifndef _VX_DEBUG_CMD_H
12501 +#define _VX_DEBUG_CMD_H
12504 +/* debug commands */
12506 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
12508 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
12509 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
12511 +struct vcmd_read_history_v0 {
12514 + char __user *data;
12517 +struct vcmd_read_monitor_v0 {
12520 + char __user *data;
12526 +#ifdef CONFIG_COMPAT
12528 +#include <asm/compat.h>
12530 +struct vcmd_read_history_v0_x32 {
12533 + compat_uptr_t data_ptr;
12536 +struct vcmd_read_monitor_v0_x32 {
12539 + compat_uptr_t data_ptr;
12542 +#endif /* CONFIG_COMPAT */
12544 +extern int vc_dump_history(uint32_t);
12546 +extern int vc_read_history(uint32_t, void __user *);
12547 +extern int vc_read_monitor(uint32_t, void __user *);
12549 +#ifdef CONFIG_COMPAT
12551 +extern int vc_read_history_x32(uint32_t, void __user *);
12552 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12554 +#endif /* CONFIG_COMPAT */
12556 +#endif /* __KERNEL__ */
12557 +#endif /* _VX_DEBUG_CMD_H */
12558 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/device.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/device.h
12559 --- linux-2.6.38.3/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
12560 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/device.h 2011-01-29 02:01:07.000000000 +0100
12562 +#ifndef _VX_DEVICE_H
12563 +#define _VX_DEVICE_H
12566 +#define DATTR_CREATE 0x00000001
12567 +#define DATTR_OPEN 0x00000002
12569 +#define DATTR_REMAP 0x00000010
12571 +#define DATTR_MASK 0x00000013
12574 +#else /* _VX_DEVICE_H */
12575 +#warning duplicate inclusion
12576 +#endif /* _VX_DEVICE_H */
12577 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/device_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/device_cmd.h
12578 --- linux-2.6.38.3/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
12579 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/device_cmd.h 2011-01-29 02:01:07.000000000 +0100
12581 +#ifndef _VX_DEVICE_CMD_H
12582 +#define _VX_DEVICE_CMD_H
12585 +/* device vserver commands */
12587 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
12588 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
12590 +struct vcmd_set_mapping_v0 {
12591 + const char __user *device;
12592 + const char __user *target;
12599 +#ifdef CONFIG_COMPAT
12601 +#include <asm/compat.h>
12603 +struct vcmd_set_mapping_v0_x32 {
12604 + compat_uptr_t device_ptr;
12605 + compat_uptr_t target_ptr;
12609 +#endif /* CONFIG_COMPAT */
12611 +#include <linux/compiler.h>
12613 +extern int vc_set_mapping(struct vx_info *, void __user *);
12614 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12616 +#ifdef CONFIG_COMPAT
12618 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12619 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12621 +#endif /* CONFIG_COMPAT */
12623 +#endif /* __KERNEL__ */
12624 +#endif /* _VX_DEVICE_CMD_H */
12625 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/device_def.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/device_def.h
12626 --- linux-2.6.38.3/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
12627 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/device_def.h 2011-01-29 02:01:07.000000000 +0100
12629 +#ifndef _VX_DEVICE_DEF_H
12630 +#define _VX_DEVICE_DEF_H
12632 +#include <linux/types.h>
12634 +struct vx_dmap_target {
12639 +struct _vx_device {
12640 +#ifdef CONFIG_VSERVER_DEVICE
12641 + struct vx_dmap_target targets[2];
12645 +#endif /* _VX_DEVICE_DEF_H */
12646 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/dlimit.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/dlimit.h
12647 --- linux-2.6.38.3/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
12648 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/dlimit.h 2011-01-29 02:01:07.000000000 +0100
12650 +#ifndef _VX_DLIMIT_H
12651 +#define _VX_DLIMIT_H
12653 +#include "switch.h"
12658 +/* keep in sync with CDLIM_INFINITY */
12660 +#define DLIM_INFINITY (~0ULL)
12662 +#include <linux/spinlock.h>
12663 +#include <linux/rcupdate.h>
12665 +struct super_block;
12668 + struct hlist_node dl_hlist; /* linked list of contexts */
12669 + struct rcu_head dl_rcu; /* the rcu head */
12670 + tag_t dl_tag; /* context tag */
12671 + atomic_t dl_usecnt; /* usage count */
12672 + atomic_t dl_refcnt; /* reference count */
12674 + struct super_block *dl_sb; /* associated superblock */
12676 + spinlock_t dl_lock; /* protect the values */
12678 + unsigned long long dl_space_used; /* used space in bytes */
12679 + unsigned long long dl_space_total; /* maximum space in bytes */
12680 + unsigned long dl_inodes_used; /* used inodes */
12681 + unsigned long dl_inodes_total; /* maximum inodes */
12683 + unsigned int dl_nrlmult; /* non root limit mult */
12688 +extern void rcu_free_dl_info(struct rcu_head *);
12689 +extern void unhash_dl_info(struct dl_info *);
12691 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12696 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12698 +typedef uint64_t dlsize_t;
12700 +#endif /* __KERNEL__ */
12701 +#else /* _VX_DLIMIT_H */
12702 +#warning duplicate inclusion
12703 +#endif /* _VX_DLIMIT_H */
12704 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/dlimit_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/dlimit_cmd.h
12705 --- linux-2.6.38.3/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12706 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/dlimit_cmd.h 2011-01-29 02:01:07.000000000 +0100
12708 +#ifndef _VX_DLIMIT_CMD_H
12709 +#define _VX_DLIMIT_CMD_H
12712 +/* dlimit vserver commands */
12714 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12715 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12717 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12718 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12720 +struct vcmd_ctx_dlimit_base_v0 {
12721 + const char __user *name;
12725 +struct vcmd_ctx_dlimit_v0 {
12726 + const char __user *name;
12727 + uint32_t space_used; /* used space in kbytes */
12728 + uint32_t space_total; /* maximum space in kbytes */
12729 + uint32_t inodes_used; /* used inodes */
12730 + uint32_t inodes_total; /* maximum inodes */
12731 + uint32_t reserved; /* reserved for root in % */
12735 +#define CDLIM_UNSET ((uint32_t)0UL)
12736 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12737 +#define CDLIM_KEEP ((uint32_t)~1UL)
12739 +#define DLIME_UNIT 0
12740 +#define DLIME_KILO 1
12741 +#define DLIME_MEGA 2
12742 +#define DLIME_GIGA 3
12744 +#define DLIMF_SHIFT 0x10
12746 +#define DLIMS_USED 0
12747 +#define DLIMS_TOTAL 2
12750 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12752 + int exp = (flags & DLIMF_SHIFT) ?
12753 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12754 + return ((uint64_t)val) << (10 * exp);
12758 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12762 + if (*flags & DLIMF_SHIFT) {
12763 + while (val > (1LL << 32) && (exp < 3)) {
12767 + *flags &= ~(DLIME_GIGA << shift);
12768 + *flags |= exp << shift;
12776 +#ifdef CONFIG_COMPAT
12778 +#include <asm/compat.h>
12780 +struct vcmd_ctx_dlimit_base_v0_x32 {
12781 + compat_uptr_t name_ptr;
12785 +struct vcmd_ctx_dlimit_v0_x32 {
12786 + compat_uptr_t name_ptr;
12787 + uint32_t space_used; /* used space in kbytes */
12788 + uint32_t space_total; /* maximum space in kbytes */
12789 + uint32_t inodes_used; /* used inodes */
12790 + uint32_t inodes_total; /* maximum inodes */
12791 + uint32_t reserved; /* reserved for root in % */
12795 +#endif /* CONFIG_COMPAT */
12797 +#include <linux/compiler.h>
12799 +extern int vc_add_dlimit(uint32_t, void __user *);
12800 +extern int vc_rem_dlimit(uint32_t, void __user *);
12802 +extern int vc_set_dlimit(uint32_t, void __user *);
12803 +extern int vc_get_dlimit(uint32_t, void __user *);
12805 +#ifdef CONFIG_COMPAT
12807 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12808 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12810 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12811 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12813 +#endif /* CONFIG_COMPAT */
12815 +#endif /* __KERNEL__ */
12816 +#endif /* _VX_DLIMIT_CMD_H */
12817 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/global.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/global.h
12818 --- linux-2.6.38.3/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12819 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/global.h 2011-01-29 02:01:07.000000000 +0100
12821 +#ifndef _VX_GLOBAL_H
12822 +#define _VX_GLOBAL_H
12825 +extern atomic_t vx_global_ctotal;
12826 +extern atomic_t vx_global_cactive;
12828 +extern atomic_t nx_global_ctotal;
12829 +extern atomic_t nx_global_cactive;
12831 +extern atomic_t vs_global_nsproxy;
12832 +extern atomic_t vs_global_fs;
12833 +extern atomic_t vs_global_mnt_ns;
12834 +extern atomic_t vs_global_uts_ns;
12835 +extern atomic_t vs_global_user_ns;
12836 +extern atomic_t vs_global_pid_ns;
12839 +#endif /* _VX_GLOBAL_H */
12840 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/history.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/history.h
12841 --- linux-2.6.38.3/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12842 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/history.h 2011-01-29 02:01:07.000000000 +0100
12844 +#ifndef _VX_HISTORY_H
12845 +#define _VX_HISTORY_H
12850 + VXH_THROW_OOPS = 1,
12854 + VXH_INIT_VX_INFO,
12857 + VXH_CLAIM_VX_INFO,
12858 + VXH_RELEASE_VX_INFO,
12859 + VXH_ALLOC_VX_INFO,
12860 + VXH_DEALLOC_VX_INFO,
12861 + VXH_HASH_VX_INFO,
12862 + VXH_UNHASH_VX_INFO,
12864 + VXH_LOOKUP_VX_INFO,
12865 + VXH_CREATE_VX_INFO,
12868 +struct _vxhe_vxi {
12869 + struct vx_info *ptr;
12875 +struct _vxhe_set_clr {
12879 +struct _vxhe_loc_lookup {
12883 +struct _vx_hist_entry {
12885 + unsigned short seq;
12886 + unsigned short type;
12887 + struct _vxhe_vxi vxi;
12889 + struct _vxhe_set_clr sc;
12890 + struct _vxhe_loc_lookup ll;
12894 +#ifdef CONFIG_VSERVER_HISTORY
12896 +extern unsigned volatile int vxh_active;
12898 +struct _vx_hist_entry *vxh_advance(void *loc);
12902 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12904 + entry->vxi.ptr = vxi;
12906 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12907 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12908 + entry->vxi.xid = vxi->vx_id;
12913 +#define __HERE__ current_text_addr()
12915 +#define __VXH_BODY(__type, __data, __here) \
12916 + struct _vx_hist_entry *entry; \
12918 + preempt_disable(); \
12919 + entry = vxh_advance(__here); \
12921 + entry->type = __type; \
12922 + preempt_enable();
12925 + /* pass vxi only */
12927 +#define __VXH_SMPL \
12928 + __vxh_copy_vxi(entry, vxi)
12931 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12933 + __VXH_BODY(__type, __VXH_SMPL, __here)
12936 + /* pass vxi and data (void *) */
12938 +#define __VXH_DATA \
12939 + __vxh_copy_vxi(entry, vxi); \
12940 + entry->sc.data = data
12943 +void __vxh_data(struct vx_info *vxi, void *data,
12944 + int __type, void *__here)
12946 + __VXH_BODY(__type, __VXH_DATA, __here)
12949 + /* pass vxi and arg (long) */
12951 +#define __VXH_LONG \
12952 + __vxh_copy_vxi(entry, vxi); \
12953 + entry->ll.arg = arg
12956 +void __vxh_long(struct vx_info *vxi, long arg,
12957 + int __type, void *__here)
12959 + __VXH_BODY(__type, __VXH_LONG, __here)
12964 +void __vxh_throw_oops(void *__here)
12966 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12967 + /* prevent further acquisition */
12972 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
12974 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
12975 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
12977 +#define __vxh_init_vx_info(v, d, h) \
12978 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
12979 +#define __vxh_set_vx_info(v, d, h) \
12980 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
12981 +#define __vxh_clr_vx_info(v, d, h) \
12982 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12984 +#define __vxh_claim_vx_info(v, d, h) \
12985 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12986 +#define __vxh_release_vx_info(v, d, h) \
12987 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12989 +#define vxh_alloc_vx_info(v) \
12990 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12991 +#define vxh_dealloc_vx_info(v) \
12992 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12994 +#define vxh_hash_vx_info(v) \
12995 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12996 +#define vxh_unhash_vx_info(v) \
12997 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12999 +#define vxh_loc_vx_info(v, l) \
13000 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
13001 +#define vxh_lookup_vx_info(v, l) \
13002 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
13003 +#define vxh_create_vx_info(v, l) \
13004 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
13006 +extern void vxh_dump_history(void);
13009 +#else /* CONFIG_VSERVER_HISTORY */
13011 +#define __HERE__ 0
13013 +#define vxh_throw_oops() do { } while (0)
13015 +#define __vxh_get_vx_info(v, h) do { } while (0)
13016 +#define __vxh_put_vx_info(v, h) do { } while (0)
13018 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
13019 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
13020 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
13022 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
13023 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
13025 +#define vxh_alloc_vx_info(v) do { } while (0)
13026 +#define vxh_dealloc_vx_info(v) do { } while (0)
13028 +#define vxh_hash_vx_info(v) do { } while (0)
13029 +#define vxh_unhash_vx_info(v) do { } while (0)
13031 +#define vxh_loc_vx_info(v, l) do { } while (0)
13032 +#define vxh_lookup_vx_info(v, l) do { } while (0)
13033 +#define vxh_create_vx_info(v, l) do { } while (0)
13035 +#define vxh_dump_history() do { } while (0)
13038 +#endif /* CONFIG_VSERVER_HISTORY */
13040 +#endif /* _VX_HISTORY_H */
13041 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/inode.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/inode.h
13042 --- linux-2.6.38.3/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
13043 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/inode.h 2011-01-29 02:01:07.000000000 +0100
13045 +#ifndef _VX_INODE_H
13046 +#define _VX_INODE_H
13049 +#define IATTR_TAG 0x01000000
13051 +#define IATTR_ADMIN 0x00000001
13052 +#define IATTR_WATCH 0x00000002
13053 +#define IATTR_HIDE 0x00000004
13054 +#define IATTR_FLAGS 0x00000007
13056 +#define IATTR_BARRIER 0x00010000
13057 +#define IATTR_IXUNLINK 0x00020000
13058 +#define IATTR_IMMUTABLE 0x00040000
13059 +#define IATTR_COW 0x00080000
13064 +#ifdef CONFIG_VSERVER_PROC_SECURE
13065 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
13066 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
13068 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
13069 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
13072 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
13074 +#endif /* __KERNEL__ */
13076 +/* inode ioctls */
13078 +#define FIOC_GETXFLG _IOR('x', 5, long)
13079 +#define FIOC_SETXFLG _IOW('x', 6, long)
13081 +#else /* _VX_INODE_H */
13082 +#warning duplicate inclusion
13083 +#endif /* _VX_INODE_H */
13084 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/inode_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/inode_cmd.h
13085 --- linux-2.6.38.3/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
13086 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/inode_cmd.h 2011-01-29 02:01:07.000000000 +0100
13088 +#ifndef _VX_INODE_CMD_H
13089 +#define _VX_INODE_CMD_H
13092 +/* inode vserver commands */
13094 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
13095 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
13097 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
13098 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
13100 +struct vcmd_ctx_iattr_v1 {
13101 + const char __user *name;
13107 +struct vcmd_ctx_fiattr_v0 {
13117 +#ifdef CONFIG_COMPAT
13119 +#include <asm/compat.h>
13121 +struct vcmd_ctx_iattr_v1_x32 {
13122 + compat_uptr_t name_ptr;
13128 +#endif /* CONFIG_COMPAT */
13130 +#include <linux/compiler.h>
13132 +extern int vc_get_iattr(void __user *);
13133 +extern int vc_set_iattr(void __user *);
13135 +extern int vc_fget_iattr(uint32_t, void __user *);
13136 +extern int vc_fset_iattr(uint32_t, void __user *);
13138 +#ifdef CONFIG_COMPAT
13140 +extern int vc_get_iattr_x32(void __user *);
13141 +extern int vc_set_iattr_x32(void __user *);
13143 +#endif /* CONFIG_COMPAT */
13145 +#endif /* __KERNEL__ */
13146 +#endif /* _VX_INODE_CMD_H */
13147 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/limit.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/limit.h
13148 --- linux-2.6.38.3/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
13149 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/limit.h 2011-01-29 02:01:07.000000000 +0100
13151 +#ifndef _VX_LIMIT_H
13152 +#define _VX_LIMIT_H
13154 +#define VLIMIT_NSOCK 16
13155 +#define VLIMIT_OPENFD 17
13156 +#define VLIMIT_ANON 18
13157 +#define VLIMIT_SHMEM 19
13158 +#define VLIMIT_SEMARY 20
13159 +#define VLIMIT_NSEMS 21
13160 +#define VLIMIT_DENTRY 22
13161 +#define VLIMIT_MAPPED 23
13166 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
13168 +/* keep in sync with CRLIM_INFINITY */
13170 +#define VLIM_INFINITY (~0ULL)
13172 +#include <asm/atomic.h>
13173 +#include <asm/resource.h>
13175 +#ifndef RLIM_INFINITY
13176 +#warning RLIM_INFINITY is undefined
13179 +#define __rlim_val(l, r, v) ((l)->res[r].v)
13181 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
13182 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
13184 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
13185 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
13186 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
13188 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
13189 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
13191 +typedef atomic_long_t rlim_atomic_t;
13192 +typedef unsigned long rlim_t;
13194 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
13195 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
13196 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
13197 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
13198 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
13199 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
13202 +#if (RLIM_INFINITY == VLIM_INFINITY)
13203 +#define VX_VLIM(r) ((long long)(long)(r))
13204 +#define VX_RLIM(v) ((rlim_t)(v))
13206 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
13207 + ? VLIM_INFINITY : (long long)(r))
13208 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
13209 + ? RLIM_INFINITY : (rlim_t)(v))
13214 +void vx_vsi_meminfo(struct sysinfo *);
13215 +void vx_vsi_swapinfo(struct sysinfo *);
13216 +long vx_vsi_cached(struct sysinfo *);
13218 +#define NUM_LIMITS 24
13220 +#endif /* __KERNEL__ */
13221 +#endif /* _VX_LIMIT_H */
13222 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/limit_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/limit_cmd.h
13223 --- linux-2.6.38.3/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
13224 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/limit_cmd.h 2011-01-29 02:01:07.000000000 +0100
13226 +#ifndef _VX_LIMIT_CMD_H
13227 +#define _VX_LIMIT_CMD_H
13230 +/* rlimit vserver commands */
13232 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
13233 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
13234 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
13235 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
13236 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
13238 +struct vcmd_ctx_rlimit_v0 {
13240 + uint64_t minimum;
13241 + uint64_t softlimit;
13242 + uint64_t maximum;
13245 +struct vcmd_ctx_rlimit_mask_v0 {
13246 + uint32_t minimum;
13247 + uint32_t softlimit;
13248 + uint32_t maximum;
13251 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
13253 +struct vcmd_rlimit_stat_v0 {
13257 + uint64_t minimum;
13258 + uint64_t maximum;
13261 +#define CRLIM_UNSET (0ULL)
13262 +#define CRLIM_INFINITY (~0ULL)
13263 +#define CRLIM_KEEP (~1ULL)
13267 +#ifdef CONFIG_IA32_EMULATION
13269 +struct vcmd_ctx_rlimit_v0_x32 {
13271 + uint64_t minimum;
13272 + uint64_t softlimit;
13273 + uint64_t maximum;
13274 +} __attribute__ ((packed));
13276 +#endif /* CONFIG_IA32_EMULATION */
13278 +#include <linux/compiler.h>
13280 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
13281 +extern int vc_get_rlimit(struct vx_info *, void __user *);
13282 +extern int vc_set_rlimit(struct vx_info *, void __user *);
13283 +extern int vc_reset_hits(struct vx_info *, void __user *);
13284 +extern int vc_reset_minmax(struct vx_info *, void __user *);
13286 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
13288 +#ifdef CONFIG_IA32_EMULATION
13290 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
13291 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
13293 +#endif /* CONFIG_IA32_EMULATION */
13295 +#endif /* __KERNEL__ */
13296 +#endif /* _VX_LIMIT_CMD_H */
13297 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/limit_def.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/limit_def.h
13298 --- linux-2.6.38.3/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
13299 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/limit_def.h 2011-01-29 02:01:07.000000000 +0100
13301 +#ifndef _VX_LIMIT_DEF_H
13302 +#define _VX_LIMIT_DEF_H
13304 +#include <asm/atomic.h>
13305 +#include <asm/resource.h>
13307 +#include "limit.h"
13310 +struct _vx_res_limit {
13311 + rlim_t soft; /* Context soft limit */
13312 + rlim_t hard; /* Context hard limit */
13314 + rlim_atomic_t rcur; /* Current value */
13315 + rlim_t rmin; /* Context minimum */
13316 + rlim_t rmax; /* Context maximum */
13318 + atomic_t lhit; /* Limit hits */
13321 +/* context sub struct */
13323 +struct _vx_limit {
13324 + struct _vx_res_limit res[NUM_LIMITS];
13327 +#ifdef CONFIG_VSERVER_DEBUG
13329 +static inline void __dump_vx_limit(struct _vx_limit *limit)
13333 + printk("\t_vx_limit:");
13334 + for (i = 0; i < NUM_LIMITS; i++) {
13335 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
13336 + i, (unsigned long)__rlim_get(limit, i),
13337 + (unsigned long)__rlim_rmin(limit, i),
13338 + (unsigned long)__rlim_rmax(limit, i),
13339 + (long)__rlim_soft(limit, i),
13340 + (long)__rlim_hard(limit, i),
13341 + atomic_read(&__rlim_lhit(limit, i)));
13347 +#endif /* _VX_LIMIT_DEF_H */
13348 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/limit_int.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/limit_int.h
13349 --- linux-2.6.38.3/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
13350 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/limit_int.h 2011-01-29 02:01:07.000000000 +0100
13352 +#ifndef _VX_LIMIT_INT_H
13353 +#define _VX_LIMIT_INT_H
13355 +#include "context.h"
13359 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
13360 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
13362 +extern const char *vlimit_name[NUM_LIMITS];
13364 +static inline void __vx_acc_cres(struct vx_info *vxi,
13365 + int res, int dir, void *_data, char *_file, int _line)
13367 + if (VXD_RCRES_COND(res))
13368 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
13369 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13370 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13371 + (dir > 0) ? "++" : "--", _data, _file, _line);
13376 + __rlim_inc(&vxi->limit, res);
13378 + __rlim_dec(&vxi->limit, res);
13381 +static inline void __vx_add_cres(struct vx_info *vxi,
13382 + int res, int amount, void *_data, char *_file, int _line)
13384 + if (VXD_RCRES_COND(res))
13385 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
13386 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13387 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13388 + amount, _data, _file, _line);
13393 + __rlim_add(&vxi->limit, res, amount);
13397 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
13399 + int cond = (value > __rlim_rmax(limit, res));
13402 + __rlim_rmax(limit, res) = value;
13407 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13409 + int cond = (value < __rlim_rmin(limit, res));
13412 + __rlim_rmin(limit, res) = value;
13417 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13419 + if (!__vx_cres_adjust_max(limit, res, value))
13420 + __vx_cres_adjust_min(limit, res, value);
13425 + +1 ... no limit hit
13426 + -1 ... over soft limit
13427 + 0 ... over hard limit */
13429 +static inline int __vx_cres_avail(struct vx_info *vxi,
13430 + int res, int num, char *_file, int _line)
13432 + struct _vx_limit *limit;
13435 + if (VXD_RLIMIT_COND(res))
13436 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13437 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13438 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13439 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13440 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13441 + num, _file, _line);
13445 + limit = &vxi->limit;
13446 + value = __rlim_get(limit, res);
13448 + if (!__vx_cres_adjust_max(limit, res, value))
13449 + __vx_cres_adjust_min(limit, res, value);
13454 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
13456 + if (value + num <= __rlim_soft(limit, res))
13459 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
13461 + if (value + num <= __rlim_hard(limit, res))
13464 + __rlim_hit(limit, res);
13469 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13472 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13474 + rlim_t value, sum = 0;
13477 + while ((res = *array++)) {
13478 + value = __rlim_get(limit, res);
13479 + __vx_cres_fixup(limit, res, value);
13486 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13488 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
13489 + int res = *array;
13491 + if (value == __rlim_get(limit, res))
13494 + __rlim_set(limit, res, value);
13495 + /* now adjust min/max */
13496 + if (!__vx_cres_adjust_max(limit, res, value))
13497 + __vx_cres_adjust_min(limit, res, value);
13502 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13503 + const int *array, int num, char *_file, int _line)
13505 + struct _vx_limit *limit;
13506 + rlim_t value = 0;
13514 + limit = &vxi->limit;
13516 + value = __vx_cres_array_sum(limit, array + 1);
13518 + __rlim_set(limit, res, value);
13519 + __vx_cres_fixup(limit, res, value);
13521 + return __vx_cres_avail(vxi, res, num, _file, _line);
13525 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13530 + /* complex resources first */
13531 + if ((id < 0) || (id == RLIMIT_RSS))
13532 + __vx_cres_array_fixup(limit, VLA_RSS);
13534 + for (res = 0; res < NUM_LIMITS; res++) {
13535 + if ((id > 0) && (res != id))
13538 + value = __rlim_get(limit, res);
13539 + __vx_cres_fixup(limit, res, value);
13541 + /* not supposed to happen, maybe warn? */
13542 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13543 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13548 +#endif /* __KERNEL__ */
13549 +#endif /* _VX_LIMIT_INT_H */
13550 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/monitor.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/monitor.h
13551 --- linux-2.6.38.3/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
13552 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/monitor.h 2011-01-29 02:01:07.000000000 +0100
13554 +#ifndef _VX_MONITOR_H
13555 +#define _VX_MONITOR_H
13557 +#include <linux/types.h>
13564 + VXM_UPDATE = 0x20,
13568 + VXM_RQINFO_1 = 0x24,
13571 + VXM_ACTIVATE = 0x40,
13578 + VXM_MIGRATE = 0x48,
13581 + /* all other bits are flags */
13582 + VXM_SCHED = 0x80,
13585 +struct _vxm_update_1 {
13586 + uint32_t tokens_max;
13587 + uint32_t fill_rate;
13588 + uint32_t interval;
13591 +struct _vxm_update_2 {
13592 + uint32_t tokens_min;
13593 + uint32_t fill_rate;
13594 + uint32_t interval;
13597 +struct _vxm_rqinfo_1 {
13598 + uint16_t running;
13602 + uint32_t idle_tokens;
13605 +struct _vxm_rqinfo_2 {
13606 + uint32_t norm_time;
13607 + uint32_t idle_time;
13608 + uint32_t idle_skip;
13611 +struct _vxm_sched {
13613 + uint32_t norm_time;
13614 + uint32_t idle_time;
13617 +struct _vxm_task {
13622 +struct _vxm_event {
13631 + struct _vxm_task tsk;
13635 +struct _vx_mon_entry {
13639 + struct _vxm_event ev;
13640 + struct _vxm_sched sd;
13641 + struct _vxm_update_1 u1;
13642 + struct _vxm_update_2 u2;
13643 + struct _vxm_rqinfo_1 q1;
13644 + struct _vxm_rqinfo_2 q2;
13649 +#endif /* _VX_MONITOR_H */
13650 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/network.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/network.h
13651 --- linux-2.6.38.3/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
13652 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/network.h 2011-01-29 02:01:07.000000000 +0100
13654 +#ifndef _VX_NETWORK_H
13655 +#define _VX_NETWORK_H
13657 +#include <linux/types.h>
13660 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13663 +/* network flags */
13665 +#define NXF_INFO_PRIVATE 0x00000008
13667 +#define NXF_SINGLE_IP 0x00000100
13668 +#define NXF_LBACK_REMAP 0x00000200
13669 +#define NXF_LBACK_ALLOW 0x00000400
13671 +#define NXF_HIDE_NETIF 0x02000000
13672 +#define NXF_HIDE_LBACK 0x04000000
13674 +#define NXF_STATE_SETUP (1ULL << 32)
13675 +#define NXF_STATE_ADMIN (1ULL << 34)
13677 +#define NXF_SC_HELPER (1ULL << 36)
13678 +#define NXF_PERSISTENT (1ULL << 38)
13680 +#define NXF_ONE_TIME (0x0005ULL << 32)
13683 +#define NXF_INIT_SET (__nxf_init_set())
13685 +static inline uint64_t __nxf_init_set(void) {
13686 + return NXF_STATE_ADMIN
13687 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13688 + | NXF_LBACK_REMAP
13691 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13694 + | NXF_HIDE_NETIF;
13698 +/* network caps */
13700 +#define NXC_TUN_CREATE 0x00000001
13702 +#define NXC_RAW_ICMP 0x00000100
13705 +/* address types */
13707 +#define NXA_TYPE_IPV4 0x0001
13708 +#define NXA_TYPE_IPV6 0x0002
13710 +#define NXA_TYPE_NONE 0x0000
13711 +#define NXA_TYPE_ANY 0x00FF
13713 +#define NXA_TYPE_ADDR 0x0010
13714 +#define NXA_TYPE_MASK 0x0020
13715 +#define NXA_TYPE_RANGE 0x0040
13717 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13719 +#define NXA_MOD_BCAST 0x0100
13720 +#define NXA_MOD_LBACK 0x0200
13722 +#define NXA_LOOPBACK 0x1000
13724 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13725 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13729 +#include <linux/list.h>
13730 +#include <linux/spinlock.h>
13731 +#include <linux/rcupdate.h>
13732 +#include <linux/in.h>
13733 +#include <linux/in6.h>
13734 +#include <asm/atomic.h>
13736 +struct nx_addr_v4 {
13737 + struct nx_addr_v4 *next;
13738 + struct in_addr ip[2];
13739 + struct in_addr mask;
13744 +struct nx_addr_v6 {
13745 + struct nx_addr_v6 *next;
13746 + struct in6_addr ip;
13747 + struct in6_addr mask;
13754 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13755 + nid_t nx_id; /* vnet id */
13756 + atomic_t nx_usecnt; /* usage count */
13757 + atomic_t nx_tasks; /* tasks count */
13758 + int nx_state; /* context state */
13760 + uint64_t nx_flags; /* network flag word */
13761 + uint64_t nx_ncaps; /* network capabilities */
13763 + struct in_addr v4_lback; /* Loopback address */
13764 + struct in_addr v4_bcast; /* Broadcast address */
13765 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13766 +#ifdef CONFIG_IPV6
13767 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13769 + char nx_name[65]; /* network context name */
13773 +/* status flags */
13775 +#define NXS_HASHED 0x0001
13776 +#define NXS_SHUTDOWN 0x0100
13777 +#define NXS_RELEASED 0x8000
13779 +extern struct nx_info *lookup_nx_info(int);
13781 +extern int get_nid_list(int, unsigned int *, int);
13782 +extern int nid_is_hashed(nid_t);
13784 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13786 +extern long vs_net_change(struct nx_info *, unsigned int);
13791 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13792 +#ifdef CONFIG_IPV6
13793 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13795 +#define NX_IPV6(n) (0)
13798 +#endif /* __KERNEL__ */
13799 +#endif /* _VX_NETWORK_H */
13800 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/network_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/network_cmd.h
13801 --- linux-2.6.38.3/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13802 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/network_cmd.h 2011-04-15 16:09:57.000000000 +0200
13804 +#ifndef _VX_NETWORK_CMD_H
13805 +#define _VX_NETWORK_CMD_H
13808 +/* vinfo commands */
13810 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13813 +extern int vc_task_nid(uint32_t);
13815 +#endif /* __KERNEL__ */
13817 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13819 +struct vcmd_nx_info_v0 {
13821 + /* more to come */
13825 +extern int vc_nx_info(struct nx_info *, void __user *);
13827 +#endif /* __KERNEL__ */
13829 +#include <linux/in.h>
13830 +#include <linux/in6.h>
13832 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13833 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13835 +struct vcmd_net_create {
13836 + uint64_t flagword;
13839 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13841 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13842 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13844 +struct vcmd_net_addr_v0 {
13847 + struct in_addr ip[4];
13848 + struct in_addr mask[4];
13851 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13852 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13854 +struct vcmd_net_addr_ipv4_v1 {
13857 + struct in_addr ip;
13858 + struct in_addr mask;
13861 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13862 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13864 +struct vcmd_net_addr_ipv4_v2 {
13867 + struct in_addr ip;
13868 + struct in_addr ip2;
13869 + struct in_addr mask;
13872 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13873 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13875 +struct vcmd_net_addr_ipv6_v1 {
13879 + struct in6_addr ip;
13880 + struct in6_addr mask;
13883 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13884 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13886 +struct vcmd_match_ipv4_v0 {
13891 + struct in_addr ip;
13892 + struct in_addr ip2;
13893 + struct in_addr mask;
13896 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13897 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13899 +struct vcmd_match_ipv6_v0 {
13904 + struct in6_addr ip;
13905 + struct in6_addr ip2;
13906 + struct in6_addr mask;
13911 +extern int vc_net_create(uint32_t, void __user *);
13912 +extern int vc_net_migrate(struct nx_info *, void __user *);
13914 +extern int vc_net_add(struct nx_info *, void __user *);
13915 +extern int vc_net_remove(struct nx_info *, void __user *);
13917 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
13918 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13920 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
13921 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
13923 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13924 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13926 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13927 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13929 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13930 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13932 +#endif /* __KERNEL__ */
13935 +/* flag commands */
13937 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13938 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13940 +struct vcmd_net_flags_v0 {
13941 + uint64_t flagword;
13946 +extern int vc_get_nflags(struct nx_info *, void __user *);
13947 +extern int vc_set_nflags(struct nx_info *, void __user *);
13949 +#endif /* __KERNEL__ */
13952 +/* network caps commands */
13954 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13955 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13957 +struct vcmd_net_caps_v0 {
13963 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13964 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13966 +#endif /* __KERNEL__ */
13967 +#endif /* _VX_CONTEXT_CMD_H */
13968 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/percpu.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/percpu.h
13969 --- linux-2.6.38.3/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13970 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/percpu.h 2011-01-29 02:01:07.000000000 +0100
13972 +#ifndef _VX_PERCPU_H
13973 +#define _VX_PERCPU_H
13975 +#include "cvirt_def.h"
13976 +#include "sched_def.h"
13978 +struct _vx_percpu {
13979 + struct _vx_cvirt_pc cvirt;
13980 + struct _vx_sched_pc sched;
13983 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13985 +#endif /* _VX_PERCPU_H */
13986 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/pid.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/pid.h
13987 --- linux-2.6.38.3/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
13988 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/pid.h 2011-01-29 02:01:07.000000000 +0100
13990 +#ifndef _VSERVER_PID_H
13991 +#define _VSERVER_PID_H
13993 +/* pid faking stuff */
13995 +#define vx_info_map_pid(v, p) \
13996 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13997 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13998 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13999 +#define vx_map_tgid(p) vx_map_pid(p)
14001 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
14002 + const char *func, const char *file, int line)
14004 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14005 + vxfprintk(VXD_CBIT(cvirt, 2),
14006 + "vx_map_tgid: %p/%llx: %d -> %d",
14007 + vxi, (long long)vxi->vx_flags, pid,
14008 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
14009 + func, file, line);
14012 + if (pid == vxi->vx_initpid)
14018 +#define vx_info_rmap_pid(v, p) \
14019 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
14020 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
14021 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
14023 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
14024 + const char *func, const char *file, int line)
14026 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14027 + vxfprintk(VXD_CBIT(cvirt, 2),
14028 + "vx_rmap_tgid: %p/%llx: %d -> %d",
14029 + vxi, (long long)vxi->vx_flags, pid,
14030 + (pid == 1) ? vxi->vx_initpid : pid,
14031 + func, file, line);
14032 + if ((pid == 1) && vxi->vx_initpid)
14033 + return vxi->vx_initpid;
14034 + if (pid == vxi->vx_initpid)
14041 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/sched.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/sched.h
14042 --- linux-2.6.38.3/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
14043 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/sched.h 2011-01-29 02:01:07.000000000 +0100
14045 +#ifndef _VX_SCHED_H
14046 +#define _VX_SCHED_H
14053 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14058 +void vx_update_load(struct vx_info *);
14061 +void vx_update_sched_param(struct _vx_sched *sched,
14062 + struct _vx_sched_pc *sched_pc);
14064 +#endif /* __KERNEL__ */
14065 +#else /* _VX_SCHED_H */
14066 +#warning duplicate inclusion
14067 +#endif /* _VX_SCHED_H */
14068 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/sched_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/sched_cmd.h
14069 --- linux-2.6.38.3/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
14070 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/sched_cmd.h 2011-01-29 02:01:07.000000000 +0100
14072 +#ifndef _VX_SCHED_CMD_H
14073 +#define _VX_SCHED_CMD_H
14076 +struct vcmd_prio_bias {
14078 + int32_t prio_bias;
14081 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
14082 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
14086 +#include <linux/compiler.h>
14088 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
14089 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
14091 +#endif /* __KERNEL__ */
14092 +#endif /* _VX_SCHED_CMD_H */
14093 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/sched_def.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/sched_def.h
14094 --- linux-2.6.38.3/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
14095 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/sched_def.h 2011-01-29 02:01:07.000000000 +0100
14097 +#ifndef _VX_SCHED_DEF_H
14098 +#define _VX_SCHED_DEF_H
14100 +#include <linux/spinlock.h>
14101 +#include <linux/jiffies.h>
14102 +#include <linux/cpumask.h>
14103 +#include <asm/atomic.h>
14104 +#include <asm/param.h>
14107 +/* context sub struct */
14109 +struct _vx_sched {
14110 + int prio_bias; /* bias offset for priority */
14112 + cpumask_t update; /* CPUs which should update */
14115 +struct _vx_sched_pc {
14116 + int prio_bias; /* bias offset for priority */
14118 + uint64_t user_ticks; /* token tick events */
14119 + uint64_t sys_ticks; /* token tick events */
14120 + uint64_t hold_ticks; /* token ticks paused */
14124 +#ifdef CONFIG_VSERVER_DEBUG
14126 +static inline void __dump_vx_sched(struct _vx_sched *sched)
14128 + printk("\t_vx_sched:\n");
14129 + printk("\t priority = %4d\n", sched->prio_bias);
14134 +#endif /* _VX_SCHED_DEF_H */
14135 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/signal.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/signal.h
14136 --- linux-2.6.38.3/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
14137 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/signal.h 2011-01-29 02:01:07.000000000 +0100
14139 +#ifndef _VX_SIGNAL_H
14140 +#define _VX_SIGNAL_H
14147 +int vx_info_kill(struct vx_info *, int, int);
14149 +#endif /* __KERNEL__ */
14150 +#else /* _VX_SIGNAL_H */
14151 +#warning duplicate inclusion
14152 +#endif /* _VX_SIGNAL_H */
14153 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/signal_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/signal_cmd.h
14154 --- linux-2.6.38.3/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
14155 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/signal_cmd.h 2011-01-29 02:01:07.000000000 +0100
14157 +#ifndef _VX_SIGNAL_CMD_H
14158 +#define _VX_SIGNAL_CMD_H
14161 +/* signalling vserver commands */
14163 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
14164 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
14166 +struct vcmd_ctx_kill_v0 {
14171 +struct vcmd_wait_exit_v0 {
14172 + int32_t reboot_cmd;
14173 + int32_t exit_code;
14178 +extern int vc_ctx_kill(struct vx_info *, void __user *);
14179 +extern int vc_wait_exit(struct vx_info *, void __user *);
14181 +#endif /* __KERNEL__ */
14183 +/* process alteration commands */
14185 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
14186 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
14188 +struct vcmd_pflags_v0 {
14189 + uint32_t flagword;
14195 +extern int vc_get_pflags(uint32_t pid, void __user *);
14196 +extern int vc_set_pflags(uint32_t pid, void __user *);
14198 +#endif /* __KERNEL__ */
14199 +#endif /* _VX_SIGNAL_CMD_H */
14200 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/space.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/space.h
14201 --- linux-2.6.38.3/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
14202 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/space.h 2011-01-29 02:01:07.000000000 +0100
14204 +#ifndef _VX_SPACE_H
14205 +#define _VX_SPACE_H
14207 +#include <linux/types.h>
14211 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
14213 +#else /* _VX_SPACE_H */
14214 +#warning duplicate inclusion
14215 +#endif /* _VX_SPACE_H */
14216 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/space_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/space_cmd.h
14217 --- linux-2.6.38.3/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
14218 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/space_cmd.h 2011-01-29 02:01:07.000000000 +0100
14220 +#ifndef _VX_SPACE_CMD_H
14221 +#define _VX_SPACE_CMD_H
14224 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
14225 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
14226 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
14228 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
14229 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
14230 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
14232 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
14234 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
14235 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
14238 +struct vcmd_space_mask_v1 {
14242 +struct vcmd_space_mask_v2 {
14250 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
14251 +extern int vc_set_space_v1(struct vx_info *, void __user *);
14252 +extern int vc_enter_space(struct vx_info *, void __user *);
14253 +extern int vc_set_space(struct vx_info *, void __user *);
14254 +extern int vc_get_space_mask(void __user *, int);
14256 +#endif /* __KERNEL__ */
14257 +#endif /* _VX_SPACE_CMD_H */
14258 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/switch.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/switch.h
14259 --- linux-2.6.38.3/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
14260 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/switch.h 2011-01-29 02:01:07.000000000 +0100
14262 +#ifndef _VX_SWITCH_H
14263 +#define _VX_SWITCH_H
14265 +#include <linux/types.h>
14268 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
14269 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
14270 +#define VC_VERSION(c) ((c) & 0xFFF)
14272 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
14273 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
14277 + Syscall Matrix V2.8
14279 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
14280 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
14281 + |INFO |SETUP | |MOVE | | | | | |
14282 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14283 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
14284 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
14285 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14286 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
14287 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
14288 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14289 + MEMORY | | | | |MEMCTRL| | |SWAP | |
14290 + | 16| 17| 18| 19| 20| 21| | 22| 23|
14291 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14292 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
14293 + | 24| 25| 26| 27| 28| 29| | 30| 31|
14294 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14295 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
14296 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
14297 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14298 + OTHER |VSTAT | | | | | | |VINFO | |
14299 + | 40| 41| 42| 43| 44| 45| | 46| 47|
14300 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
14301 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
14302 + | 48| 49| 50| 51| 52| 53| | 54| 55|
14303 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14304 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
14305 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
14306 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14310 +#define VC_CAT_VERSION 0
14312 +#define VC_CAT_VSETUP 1
14313 +#define VC_CAT_VHOST 2
14315 +#define VC_CAT_DEVICE 6
14317 +#define VC_CAT_VPROC 9
14318 +#define VC_CAT_PROCALT 10
14319 +#define VC_CAT_PROCMIG 11
14320 +#define VC_CAT_PROCTRL 12
14322 +#define VC_CAT_SCHED 14
14323 +#define VC_CAT_MEMCTRL 20
14325 +#define VC_CAT_VNET 25
14326 +#define VC_CAT_NETALT 26
14327 +#define VC_CAT_NETMIG 27
14328 +#define VC_CAT_NETCTRL 28
14330 +#define VC_CAT_TAGMIG 35
14331 +#define VC_CAT_DLIMIT 36
14332 +#define VC_CAT_INODE 38
14334 +#define VC_CAT_VSTAT 40
14335 +#define VC_CAT_VINFO 46
14336 +#define VC_CAT_EVENT 48
14338 +#define VC_CAT_FLAGS 52
14339 +#define VC_CAT_VSPACE 54
14340 +#define VC_CAT_DEBUG 56
14341 +#define VC_CAT_RLIMIT 60
14343 +#define VC_CAT_SYSTEST 61
14344 +#define VC_CAT_COMPAT 63
14346 +/* query version */
14348 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
14349 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
14354 +#include <linux/errno.h>
14356 +#endif /* __KERNEL__ */
14358 +#endif /* _VX_SWITCH_H */
14360 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/tag.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/tag.h
14361 --- linux-2.6.38.3/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
14362 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/tag.h 2011-01-29 02:01:07.000000000 +0100
14367 +#include <linux/types.h>
14370 +#define DX_TAG(in) (IS_TAGGED(in))
14373 +#ifdef CONFIG_TAG_NFSD
14374 +#define DX_TAG_NFSD 1
14376 +#define DX_TAG_NFSD 0
14380 +#ifdef CONFIG_TAGGING_NONE
14382 +#define MAX_UID 0xFFFFFFFF
14383 +#define MAX_GID 0xFFFFFFFF
14385 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
14387 +#define TAGINO_UID(cond, uid, tag) (uid)
14388 +#define TAGINO_GID(cond, gid, tag) (gid)
14393 +#ifdef CONFIG_TAGGING_GID16
14395 +#define MAX_UID 0xFFFFFFFF
14396 +#define MAX_GID 0x0000FFFF
14398 +#define INOTAG_TAG(cond, uid, gid, tag) \
14399 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
14401 +#define TAGINO_UID(cond, uid, tag) (uid)
14402 +#define TAGINO_GID(cond, gid, tag) \
14403 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14408 +#ifdef CONFIG_TAGGING_ID24
14410 +#define MAX_UID 0x00FFFFFF
14411 +#define MAX_GID 0x00FFFFFF
14413 +#define INOTAG_TAG(cond, uid, gid, tag) \
14414 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14416 +#define TAGINO_UID(cond, uid, tag) \
14417 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14418 +#define TAGINO_GID(cond, gid, tag) \
14419 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14424 +#ifdef CONFIG_TAGGING_UID16
14426 +#define MAX_UID 0x0000FFFF
14427 +#define MAX_GID 0xFFFFFFFF
14429 +#define INOTAG_TAG(cond, uid, gid, tag) \
14430 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14432 +#define TAGINO_UID(cond, uid, tag) \
14433 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14434 +#define TAGINO_GID(cond, gid, tag) (gid)
14439 +#ifdef CONFIG_TAGGING_INTERN
14441 +#define MAX_UID 0xFFFFFFFF
14442 +#define MAX_GID 0xFFFFFFFF
14444 +#define INOTAG_TAG(cond, uid, gid, tag) \
14445 + ((cond) ? (tag) : 0)
14447 +#define TAGINO_UID(cond, uid, tag) (uid)
14448 +#define TAGINO_GID(cond, gid, tag) (gid)
14453 +#ifndef CONFIG_TAGGING_NONE
14454 +#define dx_current_fstag(sb) \
14455 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14457 +#define dx_current_fstag(sb) (0)
14460 +#ifndef CONFIG_TAGGING_INTERN
14461 +#define TAGINO_TAG(cond, tag) (0)
14463 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
14466 +#define INOTAG_UID(cond, uid, gid) \
14467 + ((cond) ? ((uid) & MAX_UID) : (uid))
14468 +#define INOTAG_GID(cond, uid, gid) \
14469 + ((cond) ? ((gid) & MAX_GID) : (gid))
14472 +static inline uid_t dx_map_uid(uid_t uid)
14474 + if ((uid > MAX_UID) && (uid != -1))
14476 + return (uid & MAX_UID);
14479 +static inline gid_t dx_map_gid(gid_t gid)
14481 + if ((gid > MAX_GID) && (gid != -1))
14483 + return (gid & MAX_GID);
14491 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14493 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14494 + unsigned long *flags);
14496 +#ifdef CONFIG_PROPAGATE
14498 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14500 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14503 +#define dx_propagate_tag(n, i) do { } while (0)
14506 +#endif /* _DX_TAG_H */
14507 diff -NurpP --minimal linux-2.6.38.3/include/linux/vserver/tag_cmd.h linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/tag_cmd.h
14508 --- linux-2.6.38.3/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
14509 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/linux/vserver/tag_cmd.h 2011-01-29 02:01:07.000000000 +0100
14511 +#ifndef _VX_TAG_CMD_H
14512 +#define _VX_TAG_CMD_H
14515 +/* vinfo commands */
14517 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
14520 +extern int vc_task_tag(uint32_t);
14522 +#endif /* __KERNEL__ */
14524 +/* context commands */
14526 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
14529 +extern int vc_tag_migrate(uint32_t);
14531 +#endif /* __KERNEL__ */
14532 +#endif /* _VX_TAG_CMD_H */
14533 diff -NurpP --minimal linux-2.6.38.3/include/net/addrconf.h linux-2.6.38.3-vs2.3.0.37-rc14/include/net/addrconf.h
14534 --- linux-2.6.38.3/include/net/addrconf.h 2011-03-15 18:07:40.000000000 +0100
14535 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/net/addrconf.h 2011-01-29 02:01:07.000000000 +0100
14536 @@ -82,7 +82,8 @@ extern int ipv6_dev_get_saddr(struct n
14537 struct net_device *dev,
14538 const struct in6_addr *daddr,
14539 unsigned int srcprefs,
14540 - struct in6_addr *saddr);
14541 + struct in6_addr *saddr,
14542 + struct nx_info *nxi);
14543 extern int ipv6_get_lladdr(struct net_device *dev,
14544 struct in6_addr *addr,
14545 unsigned char banned_flags);
14546 diff -NurpP --minimal linux-2.6.38.3/include/net/af_unix.h linux-2.6.38.3-vs2.3.0.37-rc14/include/net/af_unix.h
14547 --- linux-2.6.38.3/include/net/af_unix.h 2011-01-05 21:50:35.000000000 +0100
14548 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/net/af_unix.h 2011-01-29 02:01:07.000000000 +0100
14550 #include <linux/socket.h>
14551 #include <linux/un.h>
14552 #include <linux/mutex.h>
14553 +#include <linux/vs_base.h>
14554 #include <net/sock.h>
14556 extern void unix_inflight(struct file *fp);
14557 diff -NurpP --minimal linux-2.6.38.3/include/net/inet_timewait_sock.h linux-2.6.38.3-vs2.3.0.37-rc14/include/net/inet_timewait_sock.h
14558 --- linux-2.6.38.3/include/net/inet_timewait_sock.h 2011-03-15 18:07:40.000000000 +0100
14559 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/net/inet_timewait_sock.h 2011-01-29 03:12:58.000000000 +0100
14560 @@ -113,6 +113,10 @@ struct inet_timewait_sock {
14561 #define tw_net __tw_common.skc_net
14562 #define tw_daddr __tw_common.skc_daddr
14563 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
14564 +#define tw_xid __tw_common.skc_xid
14565 +#define tw_vx_info __tw_common.skc_vx_info
14566 +#define tw_nid __tw_common.skc_nid
14567 +#define tw_nx_info __tw_common.skc_nx_info
14569 volatile unsigned char tw_substate;
14570 unsigned char tw_rcv_wscale;
14571 diff -NurpP --minimal linux-2.6.38.3/include/net/route.h linux-2.6.38.3-vs2.3.0.37-rc14/include/net/route.h
14572 --- linux-2.6.38.3/include/net/route.h 2011-03-15 18:07:40.000000000 +0100
14573 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/net/route.h 2011-01-29 02:01:07.000000000 +0100
14574 @@ -153,6 +153,9 @@ static inline void ip_rt_put(struct rtab
14575 dst_release(&rt->dst);
14578 +#include <linux/vs_base.h>
14579 +#include <linux/vs_inet.h>
14581 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14583 extern const __u8 ip_tos2prio[16];
14584 @@ -162,6 +165,9 @@ static inline char rt_tos2priority(u8 to
14585 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14588 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14589 + struct rtable **, struct flowi *);
14591 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14592 __be32 src, u32 tos, int oif, u8 protocol,
14593 __be16 sport, __be16 dport, struct sock *sk,
14594 @@ -177,11 +183,24 @@ static inline int ip_route_connect(struc
14595 .fl_ip_dport = dport };
14597 struct net *net = sock_net(sk);
14598 + struct nx_info *nx_info = current_nx_info();
14600 if (inet_sk(sk)->transparent)
14601 fl.flags |= FLOWI_FLAG_ANYSRC;
14603 - if (!dst || !src) {
14605 + nx_info = sk->sk_nx_info;
14607 + vxdprintk(VXD_CBIT(net, 4),
14608 + "ip_route_connect(%p) %p,%p;%lx",
14609 + sk, nx_info, sk->sk_socket,
14610 + (sk->sk_socket?sk->sk_socket->flags:0));
14612 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14616 + if (!fl.fl4_dst || !fl.fl4_src) {
14617 err = __ip_route_output_key(net, rp, &fl);
14620 diff -NurpP --minimal linux-2.6.38.3/include/net/sock.h linux-2.6.38.3-vs2.3.0.37-rc14/include/net/sock.h
14621 --- linux-2.6.38.3/include/net/sock.h 2011-03-15 18:07:41.000000000 +0100
14622 +++ linux-2.6.38.3-vs2.3.0.37-rc14/include/net/sock.h 2011-02-17 02:17:51.000000000 +0100
14623 @@ -148,6 +148,10 @@ struct sock_common {
14624 #ifdef CONFIG_NET_NS
14625 struct net *skc_net;
14628 + struct vx_info *skc_vx_info;
14630 + struct nx_info *skc_nx_info;
14632 * fields between dontcopy_begin/dontcopy_end
14633 * are not copied in sock_copy()
14634 @@ -256,6 +260,10 @@ struct sock {
14635 #define sk_bind_node __sk_common.skc_bind_node
14636 #define sk_prot __sk_common.skc_prot
14637 #define sk_net __sk_common.skc_net
14638 +#define sk_xid __sk_common.skc_xid
14639 +#define sk_vx_info __sk_common.skc_vx_info
14640 +#define sk_nid __sk_common.skc_nid
14641 +#define sk_nx_info __sk_common.skc_nx_info
14642 socket_lock_t sk_lock;
14643 struct sk_buff_head sk_receive_queue;
14645 diff -NurpP --minimal linux-2.6.38.3/init/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/init/Kconfig
14646 --- linux-2.6.38.3/init/Kconfig 2011-03-15 18:07:41.000000000 +0100
14647 +++ linux-2.6.38.3-vs2.3.0.37-rc14/init/Kconfig 2011-01-29 02:01:07.000000000 +0100
14648 @@ -559,6 +559,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
14650 boolean "Control Group support"
14654 This option adds support for grouping sets of processes together, for
14655 use with process control subsystems such as Cpusets, CFS, memory
14656 @@ -584,6 +585,7 @@ config CGROUP_DEBUG
14659 bool "Namespace cgroup subsystem"
14662 Provides a simple namespace cgroup subsystem to
14663 provide hierarchical naming of sets of namespaces,
14664 diff -NurpP --minimal linux-2.6.38.3/init/main.c linux-2.6.38.3-vs2.3.0.37-rc14/init/main.c
14665 --- linux-2.6.38.3/init/main.c 2011-03-15 18:07:41.000000000 +0100
14666 +++ linux-2.6.38.3-vs2.3.0.37-rc14/init/main.c 2011-01-29 02:21:25.000000000 +0100
14668 #include <linux/shmem_fs.h>
14669 #include <linux/slab.h>
14670 #include <linux/perf_event.h>
14671 +#include <linux/vserver/percpu.h>
14673 #include <asm/io.h>
14674 #include <asm/bugs.h>
14675 diff -NurpP --minimal linux-2.6.38.3/ipc/mqueue.c linux-2.6.38.3-vs2.3.0.37-rc14/ipc/mqueue.c
14676 --- linux-2.6.38.3/ipc/mqueue.c 2011-03-15 18:07:41.000000000 +0100
14677 +++ linux-2.6.38.3-vs2.3.0.37-rc14/ipc/mqueue.c 2011-01-29 02:01:07.000000000 +0100
14679 #include <linux/pid.h>
14680 #include <linux/ipc_namespace.h>
14681 #include <linux/slab.h>
14682 +#include <linux/vs_context.h>
14683 +#include <linux/vs_limit.h>
14685 #include <net/sock.h>
14687 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14688 struct sigevent notify;
14689 struct pid* notify_owner;
14690 struct user_struct *user; /* user who created, for accounting */
14691 + struct vx_info *vxi;
14692 struct sock *notify_sock;
14693 struct sk_buff *notify_cookie;
14695 @@ -126,6 +129,7 @@ static struct inode *mqueue_get_inode(st
14696 if (S_ISREG(mode)) {
14697 struct mqueue_inode_info *info;
14698 struct task_struct *p = current;
14699 + struct vx_info *vxi = p->vx_info;
14700 unsigned long mq_bytes, mq_msg_tblsz;
14702 inode->i_fop = &mqueue_file_operations;
14703 @@ -139,6 +143,7 @@ static struct inode *mqueue_get_inode(st
14704 info->notify_owner = NULL;
14706 info->user = NULL; /* set when all is ok */
14707 + info->vxi = NULL;
14708 memset(&info->attr, 0, sizeof(info->attr));
14709 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14710 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14711 @@ -157,16 +162,19 @@ static struct inode *mqueue_get_inode(st
14712 spin_lock(&mq_lock);
14713 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14714 u->mq_bytes + mq_bytes >
14715 - task_rlimit(p, RLIMIT_MSGQUEUE)) {
14716 + task_rlimit(p, RLIMIT_MSGQUEUE) ||
14717 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14718 spin_unlock(&mq_lock);
14719 /* mqueue_evict_inode() releases info->messages */
14722 u->mq_bytes += mq_bytes;
14723 + vx_ipcmsg_add(vxi, u, mq_bytes);
14724 spin_unlock(&mq_lock);
14727 info->user = get_uid(u);
14728 + info->vxi = get_vx_info(vxi);
14729 } else if (S_ISDIR(mode)) {
14731 /* Some things misbehave if size == 0 on a directory */
14732 @@ -275,8 +283,11 @@ static void mqueue_evict_inode(struct in
14733 + info->attr.mq_msgsize);
14736 + struct vx_info *vxi = info->vxi;
14738 spin_lock(&mq_lock);
14739 user->mq_bytes -= mq_bytes;
14740 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14742 * get_ns_from_inode() ensures that the
14743 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14744 @@ -286,6 +297,7 @@ static void mqueue_evict_inode(struct in
14746 ipc_ns->mq_queues_count--;
14747 spin_unlock(&mq_lock);
14748 + put_vx_info(vxi);
14752 diff -NurpP --minimal linux-2.6.38.3/ipc/msg.c linux-2.6.38.3-vs2.3.0.37-rc14/ipc/msg.c
14753 --- linux-2.6.38.3/ipc/msg.c 2010-08-02 16:52:57.000000000 +0200
14754 +++ linux-2.6.38.3-vs2.3.0.37-rc14/ipc/msg.c 2011-01-29 02:01:07.000000000 +0100
14756 #include <linux/rwsem.h>
14757 #include <linux/nsproxy.h>
14758 #include <linux/ipc_namespace.h>
14759 +#include <linux/vs_base.h>
14761 #include <asm/current.h>
14762 #include <asm/uaccess.h>
14763 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14765 msq->q_perm.mode = msgflg & S_IRWXUGO;
14766 msq->q_perm.key = key;
14767 + msq->q_perm.xid = vx_current_xid();
14769 msq->q_perm.security = NULL;
14770 retval = security_msg_queue_alloc(msq);
14771 diff -NurpP --minimal linux-2.6.38.3/ipc/namespace.c linux-2.6.38.3-vs2.3.0.37-rc14/ipc/namespace.c
14772 --- linux-2.6.38.3/ipc/namespace.c 2009-09-10 15:26:27.000000000 +0200
14773 +++ linux-2.6.38.3-vs2.3.0.37-rc14/ipc/namespace.c 2011-01-29 02:01:07.000000000 +0100
14775 #include <linux/slab.h>
14776 #include <linux/fs.h>
14777 #include <linux/mount.h>
14778 +#include <linux/vs_base.h>
14779 +#include <linux/vserver/global.h>
14783 diff -NurpP --minimal linux-2.6.38.3/ipc/sem.c linux-2.6.38.3-vs2.3.0.37-rc14/ipc/sem.c
14784 --- linux-2.6.38.3/ipc/sem.c 2010-10-21 13:07:56.000000000 +0200
14785 +++ linux-2.6.38.3-vs2.3.0.37-rc14/ipc/sem.c 2011-01-29 02:01:07.000000000 +0100
14787 #include <linux/rwsem.h>
14788 #include <linux/nsproxy.h>
14789 #include <linux/ipc_namespace.h>
14790 +#include <linux/vs_base.h>
14791 +#include <linux/vs_limit.h>
14793 #include <asm/uaccess.h>
14795 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
14797 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14798 sma->sem_perm.key = key;
14799 + sma->sem_perm.xid = vx_current_xid();
14801 sma->sem_perm.security = NULL;
14802 retval = security_sem_alloc(sma);
14803 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
14806 ns->used_sems += nsems;
14807 + /* FIXME: obsoleted? */
14808 + vx_semary_inc(sma);
14809 + vx_nsems_add(sma, nsems);
14811 sma->sem_base = (struct sem *) &sma[1];
14813 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
14815 wake_up_sem_queue_do(&tasks);
14816 ns->used_sems -= sma->sem_nsems;
14817 + /* FIXME: obsoleted? */
14818 + vx_nsems_sub(sma, sma->sem_nsems);
14819 + vx_semary_dec(sma);
14820 security_sem_free(sma);
14821 ipc_rcu_putref(sma);
14823 diff -NurpP --minimal linux-2.6.38.3/ipc/shm.c linux-2.6.38.3-vs2.3.0.37-rc14/ipc/shm.c
14824 --- linux-2.6.38.3/ipc/shm.c 2011-01-05 21:50:37.000000000 +0100
14825 +++ linux-2.6.38.3-vs2.3.0.37-rc14/ipc/shm.c 2011-01-29 02:01:07.000000000 +0100
14827 #include <linux/nsproxy.h>
14828 #include <linux/mount.h>
14829 #include <linux/ipc_namespace.h>
14830 +#include <linux/vs_context.h>
14831 +#include <linux/vs_limit.h>
14833 #include <asm/uaccess.h>
14835 @@ -173,7 +175,12 @@ static void shm_open(struct vm_area_stru
14837 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14839 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14840 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14841 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14843 + vx_ipcshm_sub(vxi, shp, numpages);
14844 + ns->shm_tot -= numpages;
14848 if (!is_file_hugepages(shp->shm_file))
14849 @@ -183,6 +190,7 @@ static void shm_destroy(struct ipc_names
14851 fput (shp->shm_file);
14852 security_shm_free(shp);
14853 + put_vx_info(vxi);
14854 ipc_rcu_putref(shp);
14857 @@ -355,11 +363,15 @@ static int newseg(struct ipc_namespace *
14858 if (ns->shm_tot + numpages > ns->shm_ctlall)
14861 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14864 shp = ipc_rcu_alloc(sizeof(*shp));
14868 shp->shm_perm.key = key;
14869 + shp->shm_perm.xid = vx_current_xid();
14870 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14871 shp->mlock_user = NULL;
14873 @@ -413,6 +425,7 @@ static int newseg(struct ipc_namespace *
14874 ns->shm_tot += numpages;
14875 error = shp->shm_perm.id;
14877 + vx_ipcshm_add(current_vx_info(), key, numpages);
14881 diff -NurpP --minimal linux-2.6.38.3/kernel/Makefile linux-2.6.38.3-vs2.3.0.37-rc14/kernel/Makefile
14882 --- linux-2.6.38.3/kernel/Makefile 2011-03-15 18:07:41.000000000 +0100
14883 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/Makefile 2011-01-29 02:01:07.000000000 +0100
14884 @@ -25,6 +25,7 @@ CFLAGS_REMOVE_perf_event.o = -pg
14885 CFLAGS_REMOVE_irq_work.o = -pg
14889 obj-$(CONFIG_FREEZER) += freezer.o
14890 obj-$(CONFIG_PROFILING) += profile.o
14891 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
14892 diff -NurpP --minimal linux-2.6.38.3/kernel/capability.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/capability.c
14893 --- linux-2.6.38.3/kernel/capability.c 2011-03-15 18:07:41.000000000 +0100
14894 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/capability.c 2011-02-17 02:17:51.000000000 +0100
14896 #include <linux/security.h>
14897 #include <linux/syscalls.h>
14898 #include <linux/pid_namespace.h>
14899 +#include <linux/vs_context.h>
14900 #include <asm/uaccess.h>
14903 @@ -119,6 +120,7 @@ static int cap_validate_magic(cap_user_h
14909 * The only thing that can change the capabilities of the current
14910 * process is the current process. As such, we can't be in this code
14911 @@ -289,6 +291,8 @@ error:
14915 +#include <linux/vserver/base.h>
14918 * capable - Determine if the current task has a superior capability in effect
14919 * @cap: The capability to be tested for
14920 @@ -301,6 +305,9 @@ error:
14922 int capable(int cap)
14924 + /* here for now so we don't require task locking */
14925 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
14927 if (unlikely(!cap_valid(cap))) {
14928 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
14930 diff -NurpP --minimal linux-2.6.38.3/kernel/compat.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/compat.c
14931 --- linux-2.6.38.3/kernel/compat.c 2010-10-21 13:07:56.000000000 +0200
14932 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/compat.c 2011-01-29 02:01:07.000000000 +0100
14933 @@ -914,7 +914,7 @@ asmlinkage long compat_sys_stime(compat_
14937 - do_settimeofday(&tv);
14938 + vx_settimeofday(&tv);
14942 diff -NurpP --minimal linux-2.6.38.3/kernel/cred.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/cred.c
14943 --- linux-2.6.38.3/kernel/cred.c 2011-03-15 18:07:41.000000000 +0100
14944 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/cred.c 2011-02-17 02:17:51.000000000 +0100
14945 @@ -60,31 +60,6 @@ struct cred init_cred = {
14949 -static inline void set_cred_subscribers(struct cred *cred, int n)
14951 -#ifdef CONFIG_DEBUG_CREDENTIALS
14952 - atomic_set(&cred->subscribers, n);
14956 -static inline int read_cred_subscribers(const struct cred *cred)
14958 -#ifdef CONFIG_DEBUG_CREDENTIALS
14959 - return atomic_read(&cred->subscribers);
14965 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14967 -#ifdef CONFIG_DEBUG_CREDENTIALS
14968 - struct cred *cred = (struct cred *) _cred;
14970 - atomic_add(n, &cred->subscribers);
14975 * Dispose of the shared task group credentials
14977 @@ -280,21 +255,16 @@ error:
14979 * Call commit_creds() or abort_creds() to clean up.
14981 -struct cred *prepare_creds(void)
14982 +struct cred *__prepare_creds(const struct cred *old)
14984 - struct task_struct *task = current;
14985 - const struct cred *old;
14988 - validate_process_creds();
14990 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14994 kdebug("prepare_creds() alloc %p", new);
14996 - old = task->cred;
14997 memcpy(new, old, sizeof(struct cred));
14999 atomic_set(&new->usage, 1);
15000 @@ -321,6 +291,13 @@ error:
15005 +struct cred *prepare_creds(void)
15007 + validate_process_creds();
15009 + return __prepare_creds(current->cred);
15011 EXPORT_SYMBOL(prepare_creds);
15014 diff -NurpP --minimal linux-2.6.38.3/kernel/exit.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/exit.c
15015 --- linux-2.6.38.3/kernel/exit.c 2011-03-15 18:07:41.000000000 +0100
15016 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/exit.c 2011-01-29 02:01:07.000000000 +0100
15018 #include <linux/fs_struct.h>
15019 #include <linux/init_task.h>
15020 #include <linux/perf_event.h>
15021 +#include <linux/vs_limit.h>
15022 +#include <linux/vs_context.h>
15023 +#include <linux/vs_network.h>
15024 +#include <linux/vs_pid.h>
15025 #include <trace/events/sched.h>
15026 #include <linux/hw_breakpoint.h>
15027 #include <linux/oom.h>
15028 @@ -494,9 +498,11 @@ static void close_files(struct files_str
15029 filp_close(file, files);
15032 + vx_openfd_dec(i);
15040 @@ -1047,11 +1053,16 @@ NORET_TYPE void do_exit(long code)
15042 validate_creds_for_do_exit(tsk);
15044 + /* needs to stay after exit_notify() */
15045 + exit_vx_info(tsk, code);
15046 + exit_nx_info(tsk);
15050 /* causes final put_task_struct in finish_task_switch(). */
15051 tsk->state = TASK_DEAD;
15053 + printk("bad task: %p [%lx]\n", current, current->state);
15055 /* Avoid "noreturn function does return". */
15057 diff -NurpP --minimal linux-2.6.38.3/kernel/fork.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/fork.c
15058 --- linux-2.6.38.3/kernel/fork.c 2011-03-15 18:07:41.000000000 +0100
15059 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/fork.c 2011-01-29 03:19:29.000000000 +0100
15061 #include <linux/user-return-notifier.h>
15062 #include <linux/oom.h>
15063 #include <linux/khugepaged.h>
15064 +#include <linux/vs_context.h>
15065 +#include <linux/vs_network.h>
15066 +#include <linux/vs_limit.h>
15067 +#include <linux/vs_memory.h>
15069 #include <asm/pgtable.h>
15070 #include <asm/pgalloc.h>
15071 @@ -162,6 +166,8 @@ void free_task(struct task_struct *tsk)
15072 account_kernel_stack(tsk->stack, -1);
15073 free_thread_info(tsk->stack);
15074 rt_mutex_debug_task_free(tsk);
15075 + clr_vx_info(&tsk->vx_info);
15076 + clr_nx_info(&tsk->nx_info);
15077 ftrace_graph_exit_task(tsk);
15078 free_task_struct(tsk);
15080 @@ -500,6 +506,7 @@ static struct mm_struct * mm_init(struct
15081 if (likely(!mm_alloc_pgd(mm))) {
15083 mmu_notifier_mm_init(mm);
15084 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15088 @@ -536,6 +543,7 @@ void __mmdrop(struct mm_struct *mm)
15089 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
15090 VM_BUG_ON(mm->pmd_huge_pte);
15092 + clr_vx_info(&mm->mm_vx_info);
15095 EXPORT_SYMBOL_GPL(__mmdrop);
15096 @@ -672,6 +680,7 @@ struct mm_struct *dup_mm(struct task_str
15099 memcpy(mm, oldmm, sizeof(*mm));
15100 + mm->mm_vx_info = NULL;
15102 /* Initializing for Swap token stuff */
15103 mm->token_priority = 0;
15104 @@ -714,6 +723,7 @@ fail_nocontext:
15105 * If init_new_context() failed, we cannot use mmput() to free the mm
15106 * because it calls destroy_context()
15108 + clr_vx_info(&mm->mm_vx_info);
15112 @@ -995,6 +1005,8 @@ static struct task_struct *copy_process(
15114 struct task_struct *p;
15115 int cgroup_callbacks_done = 0;
15116 + struct vx_info *vxi;
15117 + struct nx_info *nxi;
15119 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15120 return ERR_PTR(-EINVAL);
15121 @@ -1041,7 +1053,12 @@ static struct task_struct *copy_process(
15122 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15123 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15125 + init_vx_info(&p->vx_info, current_vx_info());
15126 + init_nx_info(&p->nx_info, current_nx_info());
15129 + if (!vx_nproc_avail(1))
15130 + goto bad_fork_free;
15131 if (atomic_read(&p->real_cred->user->processes) >=
15132 task_rlimit(p, RLIMIT_NPROC)) {
15133 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15134 @@ -1306,6 +1323,18 @@ static struct task_struct *copy_process(
15137 spin_unlock(¤t->sighand->siglock);
15139 + /* p is copy of current */
15140 + vxi = p->vx_info;
15142 + claim_vx_info(vxi, p);
15143 + atomic_inc(&vxi->cvirt.nr_threads);
15144 + atomic_inc(&vxi->cvirt.total_forks);
15147 + nxi = p->nx_info;
15149 + claim_nx_info(nxi, p);
15150 write_unlock_irq(&tasklist_lock);
15151 proc_fork_connector(p);
15152 cgroup_post_fork(p);
15153 diff -NurpP --minimal linux-2.6.38.3/kernel/kthread.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/kthread.c
15154 --- linux-2.6.38.3/kernel/kthread.c 2011-03-15 18:07:41.000000000 +0100
15155 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/kthread.c 2011-01-29 02:01:07.000000000 +0100
15157 #include <linux/mutex.h>
15158 #include <linux/slab.h>
15159 #include <linux/freezer.h>
15160 +#include <linux/vs_pid.h>
15161 #include <trace/events/sched.h>
15163 static DEFINE_SPINLOCK(kthread_create_lock);
15164 diff -NurpP --minimal linux-2.6.38.3/kernel/nsproxy.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/nsproxy.c
15165 --- linux-2.6.38.3/kernel/nsproxy.c 2010-07-07 18:31:57.000000000 +0200
15166 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/nsproxy.c 2011-01-29 02:01:07.000000000 +0100
15168 #include <linux/mnt_namespace.h>
15169 #include <linux/utsname.h>
15170 #include <linux/pid_namespace.h>
15171 +#include <linux/vserver/global.h>
15172 +#include <linux/vserver/debug.h>
15173 #include <net/net_namespace.h>
15174 #include <linux/ipc_namespace.h>
15176 @@ -43,8 +45,11 @@ static inline struct nsproxy *create_nsp
15177 struct nsproxy *nsproxy;
15179 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
15182 atomic_set(&nsproxy->count, 1);
15183 + atomic_inc(&vs_global_nsproxy);
15185 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
15189 @@ -53,41 +58,52 @@ static inline struct nsproxy *create_nsp
15190 * Return the newly created nsproxy. Do not attach this to the task,
15191 * leave it to the caller to do proper locking and attach it to task.
15193 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15194 - struct task_struct *tsk, struct fs_struct *new_fs)
15195 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15196 + struct nsproxy *orig, struct fs_struct *new_fs)
15198 struct nsproxy *new_nsp;
15201 + vxdprintk(VXD_CBIT(space, 4),
15202 + "unshare_namespaces(0x%08lx,%p,%p)",
15203 + flags, orig, new_fs);
15205 new_nsp = create_nsproxy();
15207 return ERR_PTR(-ENOMEM);
15209 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15210 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15211 if (IS_ERR(new_nsp->mnt_ns)) {
15212 err = PTR_ERR(new_nsp->mnt_ns);
15216 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15217 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15218 if (IS_ERR(new_nsp->uts_ns)) {
15219 err = PTR_ERR(new_nsp->uts_ns);
15223 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15224 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15225 if (IS_ERR(new_nsp->ipc_ns)) {
15226 err = PTR_ERR(new_nsp->ipc_ns);
15230 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15231 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15232 if (IS_ERR(new_nsp->pid_ns)) {
15233 err = PTR_ERR(new_nsp->pid_ns);
15237 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15239 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15240 + if (IS_ERR(new_nsp->user_ns)) {
15241 + err = PTR_ERR(new_nsp->user_ns);
15245 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15246 if (IS_ERR(new_nsp->net_ns)) {
15247 err = PTR_ERR(new_nsp->net_ns);
15249 @@ -112,6 +128,38 @@ out_ns:
15250 return ERR_PTR(err);
15253 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15254 + struct fs_struct *new_fs)
15256 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15260 + * copies the nsproxy, setting refcount to 1, and grabbing a
15261 + * reference to all contained namespaces.
15263 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15265 + struct nsproxy *ns = create_nsproxy();
15268 + memcpy(ns, orig, sizeof(struct nsproxy));
15269 + atomic_set(&ns->count, 1);
15272 + get_mnt_ns(ns->mnt_ns);
15274 + get_uts_ns(ns->uts_ns);
15276 + get_ipc_ns(ns->ipc_ns);
15278 + get_pid_ns(ns->pid_ns);
15280 + get_net(ns->net_ns);
15286 * called from clone. This now handles copy for nsproxy and all
15287 * namespaces therein.
15288 @@ -119,9 +167,12 @@ out_ns:
15289 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15291 struct nsproxy *old_ns = tsk->nsproxy;
15292 - struct nsproxy *new_ns;
15293 + struct nsproxy *new_ns = NULL;
15296 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15297 + flags, tsk, old_ns);
15302 @@ -131,7 +182,7 @@ int copy_namespaces(unsigned long flags,
15303 CLONE_NEWPID | CLONE_NEWNET)))
15306 - if (!capable(CAP_SYS_ADMIN)) {
15307 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
15311 @@ -158,6 +209,9 @@ int copy_namespaces(unsigned long flags,
15314 put_nsproxy(old_ns);
15315 + vxdprintk(VXD_CBIT(space, 3),
15316 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15317 + flags, tsk, old_ns, err, new_ns);
15321 @@ -171,7 +225,9 @@ void free_nsproxy(struct nsproxy *ns)
15322 put_ipc_ns(ns->ipc_ns);
15324 put_pid_ns(ns->pid_ns);
15325 - put_net(ns->net_ns);
15327 + put_net(ns->net_ns);
15328 + atomic_dec(&vs_global_nsproxy);
15329 kmem_cache_free(nsproxy_cachep, ns);
15332 @@ -184,11 +240,15 @@ int unshare_nsproxy_namespaces(unsigned
15336 + vxdprintk(VXD_CBIT(space, 4),
15337 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15338 + unshare_flags, current->nsproxy);
15340 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15344 - if (!capable(CAP_SYS_ADMIN))
15345 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
15348 *new_nsp = create_new_namespaces(unshare_flags, current,
15349 diff -NurpP --minimal linux-2.6.38.3/kernel/pid.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/pid.c
15350 --- linux-2.6.38.3/kernel/pid.c 2011-01-05 21:50:38.000000000 +0100
15351 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/pid.c 2011-01-29 02:01:07.000000000 +0100
15353 #include <linux/pid_namespace.h>
15354 #include <linux/init_task.h>
15355 #include <linux/syscalls.h>
15356 +#include <linux/vs_pid.h>
15358 #define pid_hashfn(nr, ns) \
15359 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15360 @@ -339,7 +340,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15362 struct pid *find_vpid(int nr)
15364 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15365 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15367 EXPORT_SYMBOL_GPL(find_vpid);
15369 @@ -399,6 +400,9 @@ void transfer_pid(struct task_struct *ol
15370 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15372 struct task_struct *result = NULL;
15374 + if (type == PIDTYPE_REALPID)
15375 + type = PIDTYPE_PID;
15377 struct hlist_node *first;
15378 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
15379 @@ -417,7 +421,7 @@ EXPORT_SYMBOL(pid_task);
15380 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15382 rcu_lockdep_assert(rcu_read_lock_held());
15383 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15384 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15387 struct task_struct *find_task_by_vpid(pid_t vnr)
15388 @@ -459,7 +463,7 @@ struct pid *find_get_pid(pid_t nr)
15390 EXPORT_SYMBOL_GPL(find_get_pid);
15392 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15393 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15397 @@ -472,6 +476,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15401 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15403 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15406 pid_t pid_vnr(struct pid *pid)
15408 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15409 diff -NurpP --minimal linux-2.6.38.3/kernel/pid_namespace.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/pid_namespace.c
15410 --- linux-2.6.38.3/kernel/pid_namespace.c 2010-07-07 18:31:57.000000000 +0200
15411 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/pid_namespace.c 2011-01-29 02:01:07.000000000 +0100
15413 #include <linux/err.h>
15414 #include <linux/acct.h>
15415 #include <linux/slab.h>
15416 +#include <linux/vserver/global.h>
15418 #define BITS_PER_PAGE (PAGE_SIZE*8)
15420 @@ -87,6 +88,7 @@ static struct pid_namespace *create_pid_
15423 kref_init(&ns->kref);
15424 + atomic_inc(&vs_global_pid_ns);
15426 ns->parent = get_pid_ns(parent_pid_ns);
15428 @@ -112,6 +114,7 @@ static void destroy_pid_namespace(struct
15430 for (i = 0; i < PIDMAP_ENTRIES; i++)
15431 kfree(ns->pidmap[i].page);
15432 + atomic_dec(&vs_global_pid_ns);
15433 kmem_cache_free(pid_ns_cachep, ns);
15436 diff -NurpP --minimal linux-2.6.38.3/kernel/posix-timers.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/posix-timers.c
15437 --- linux-2.6.38.3/kernel/posix-timers.c 2011-03-15 18:07:42.000000000 +0100
15438 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/posix-timers.c 2011-01-29 02:01:07.000000000 +0100
15440 #include <linux/wait.h>
15441 #include <linux/workqueue.h>
15442 #include <linux/module.h>
15443 +#include <linux/vs_context.h>
15446 * Management arrays for POSIX timers. Timers are kept in slab memory
15447 @@ -369,6 +370,7 @@ int posix_timer_event(struct k_itimer *t
15449 struct task_struct *task;
15450 int shared, ret = -1;
15453 * FIXME: if ->sigq is queued we can race with
15454 * dequeue_signal()->do_schedule_next_timer().
15455 @@ -385,10 +387,18 @@ int posix_timer_event(struct k_itimer *t
15457 task = pid_task(timr->it_pid, PIDTYPE_PID);
15459 + struct vx_info_save vxis;
15460 + struct vx_info *vxi;
15462 + vxi = get_vx_info(task->vx_info);
15463 + enter_vx_info(vxi, &vxis);
15464 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15465 ret = send_sigqueue(timr->sigq, task, shared);
15466 + leave_vx_info(&vxis);
15467 + put_vx_info(vxi);
15471 /* If we failed to send the signal the timer stops. */
15474 diff -NurpP --minimal linux-2.6.38.3/kernel/printk.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/printk.c
15475 --- linux-2.6.38.3/kernel/printk.c 2011-03-15 18:07:42.000000000 +0100
15476 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/printk.c 2011-02-17 02:34:59.000000000 +0100
15478 #include <linux/cpu.h>
15479 #include <linux/notifier.h>
15480 #include <linux/rculist.h>
15481 +#include <linux/vs_cvirt.h>
15483 #include <asm/uaccess.h>
15485 @@ -280,7 +281,7 @@ static int check_syslog_permissions(int
15488 if (syslog_action_restricted(type)) {
15489 - if (capable(CAP_SYSLOG))
15490 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
15492 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
15493 if (capable(CAP_SYS_ADMIN)) {
15494 @@ -308,12 +309,9 @@ int do_syslog(int type, char __user *buf
15499 - case SYSLOG_ACTION_CLOSE: /* Close log */
15501 - case SYSLOG_ACTION_OPEN: /* Open log */
15503 - case SYSLOG_ACTION_READ: /* Read from log */
15504 + if ((type == SYSLOG_ACTION_READ) ||
15505 + (type == SYSLOG_ACTION_READ_ALL) ||
15506 + (type == SYSLOG_ACTION_READ_CLEAR)) {
15508 if (!buf || len < 0)
15510 @@ -324,6 +322,16 @@ int do_syslog(int type, char __user *buf
15515 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15516 + return vx_do_syslog(type, buf, len);
15519 + case SYSLOG_ACTION_CLOSE: /* Close log */
15521 + case SYSLOG_ACTION_OPEN: /* Open log */
15523 + case SYSLOG_ACTION_READ: /* Read from log */
15524 error = wait_event_interruptible(log_wait,
15525 (log_start - log_end));
15527 @@ -350,16 +358,6 @@ int do_syslog(int type, char __user *buf
15529 /* Read last kernel messages */
15530 case SYSLOG_ACTION_READ_ALL:
15532 - if (!buf || len < 0)
15537 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15542 if (count > log_buf_len)
15543 count = log_buf_len;
15544 diff -NurpP --minimal linux-2.6.38.3/kernel/ptrace.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/ptrace.c
15545 --- linux-2.6.38.3/kernel/ptrace.c 2011-03-15 18:07:42.000000000 +0100
15546 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/ptrace.c 2011-03-31 19:40:13.000000000 +0200
15548 #include <linux/syscalls.h>
15549 #include <linux/uaccess.h>
15550 #include <linux/regset.h>
15551 +#include <linux/vs_context.h>
15555 @@ -150,6 +151,11 @@ int __ptrace_may_access(struct task_stru
15556 dumpable = get_dumpable(task->mm);
15557 if (!dumpable && !capable(CAP_SYS_PTRACE))
15559 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
15561 + if (!vx_check(task->xid, VS_IDENT) &&
15562 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15565 return security_ptrace_access_check(task, mode);
15567 diff -NurpP --minimal linux-2.6.38.3/kernel/sched.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/sched.c
15568 --- linux-2.6.38.3/kernel/sched.c 2011-04-15 10:30:30.000000000 +0200
15569 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/sched.c 2011-03-25 22:52:15.000000000 +0100
15571 #include <linux/ctype.h>
15572 #include <linux/ftrace.h>
15573 #include <linux/slab.h>
15574 +#include <linux/vs_sched.h>
15575 +#include <linux/vs_cvirt.h>
15577 #include <asm/tlb.h>
15578 #include <asm/irq_regs.h>
15579 @@ -3228,9 +3230,17 @@ static void calc_global_nohz(unsigned lo
15581 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
15583 - loads[0] = (avenrun[0] + offset) << shift;
15584 - loads[1] = (avenrun[1] + offset) << shift;
15585 - loads[2] = (avenrun[2] + offset) << shift;
15586 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
15587 + struct vx_info *vxi = current_vx_info();
15589 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
15590 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
15591 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
15593 + loads[0] = (avenrun[0] + offset) << shift;
15594 + loads[1] = (avenrun[1] + offset) << shift;
15595 + loads[2] = (avenrun[2] + offset) << shift;
15600 @@ -3518,16 +3528,19 @@ void account_user_time(struct task_struc
15601 cputime_t cputime_scaled)
15603 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15604 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15606 + int nice = (TASK_NICE(p) > 0);
15608 /* Add user time to process. */
15609 p->utime = cputime_add(p->utime, cputime);
15610 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15611 + vx_account_user(vxi, cputime, nice);
15612 account_group_user_time(p, cputime);
15614 /* Add user time to cpustat. */
15615 tmp = cputime_to_cputime64(cputime);
15616 - if (TASK_NICE(p) > 0)
15618 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15620 cpustat->user = cputime64_add(cpustat->user, tmp);
15621 @@ -3578,6 +3591,7 @@ void account_system_time(struct task_str
15622 cputime_t cputime, cputime_t cputime_scaled)
15624 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15625 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15628 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
15629 @@ -3588,6 +3602,7 @@ void account_system_time(struct task_str
15630 /* Add system time to process. */
15631 p->stime = cputime_add(p->stime, cputime);
15632 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15633 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15634 account_group_system_time(p, cputime);
15636 /* Add system time to cpustat. */
15637 @@ -4672,7 +4687,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15640 if (increment < 0 && !can_nice(current, nice))
15642 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15644 retval = security_task_setnice(current, nice);
15646 diff -NurpP --minimal linux-2.6.38.3/kernel/sched_fair.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/sched_fair.c
15647 --- linux-2.6.38.3/kernel/sched_fair.c 2011-03-15 18:07:42.000000000 +0100
15648 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/sched_fair.c 2011-02-02 22:20:27.000000000 +0100
15649 @@ -992,6 +992,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15650 __enqueue_entity(cfs_rq, se);
15653 + if (entity_is_task(se))
15654 + vx_activate_task(task_of(se));
15655 if (cfs_rq->nr_running == 1)
15656 list_add_leaf_cfs_rq(cfs_rq);
15658 @@ -1038,6 +1040,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15659 if (se != cfs_rq->curr)
15660 __dequeue_entity(cfs_rq, se);
15662 + if (entity_is_task(se))
15663 + vx_deactivate_task(task_of(se));
15664 update_cfs_load(cfs_rq, 0);
15665 account_entity_dequeue(cfs_rq, se);
15666 update_min_vruntime(cfs_rq);
15667 diff -NurpP --minimal linux-2.6.38.3/kernel/signal.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/signal.c
15668 --- linux-2.6.38.3/kernel/signal.c 2011-04-15 10:30:30.000000000 +0200
15669 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/signal.c 2011-04-15 10:33:41.000000000 +0200
15671 #include <linux/freezer.h>
15672 #include <linux/pid_namespace.h>
15673 #include <linux/nsproxy.h>
15674 +#include <linux/vs_context.h>
15675 +#include <linux/vs_pid.h>
15676 #define CREATE_TRACE_POINTS
15677 #include <trace/events/signal.h>
15679 @@ -646,9 +648,18 @@ static int check_kill_permission(int sig
15683 + vxdprintk(VXD_CBIT(misc, 7),
15684 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15685 + sig, info, t, vx_task_xid(t), t->pid);
15687 if (!valid_signal(sig))
15690 +/* FIXME: needed? if so, why?
15691 + if ((info != SEND_SIG_NOINFO) &&
15692 + (is_si_special(info) || !si_fromuser(info)))
15695 if (!si_fromuser(info))
15698 @@ -678,6 +689,20 @@ static int check_kill_permission(int sig
15703 + if (t->pid == 1 && current->xid)
15707 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15708 + loops, maybe ENOENT or EACCES? */
15709 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15710 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15711 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15712 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15716 return security_task_kill(t, info, sig, 0);
15719 @@ -1171,7 +1196,7 @@ int kill_pid_info(int sig, struct siginf
15722 p = pid_task(pid, PIDTYPE_PID);
15724 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15725 error = group_send_sig_info(sig, info, p);
15726 if (unlikely(error == -ESRCH))
15728 @@ -1211,7 +1236,7 @@ int kill_pid_info_as_uid(int sig, struct
15731 p = pid_task(pid, PIDTYPE_PID);
15733 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15737 @@ -1266,8 +1291,10 @@ static int kill_something_info(int sig,
15738 struct task_struct * p;
15740 for_each_process(p) {
15741 - if (task_pid_vnr(p) > 1 &&
15742 - !same_thread_group(p, current)) {
15743 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15744 + task_pid_vnr(p) > 1 &&
15745 + !same_thread_group(p, current) &&
15746 + !vx_current_initpid(p->pid)) {
15747 int err = group_send_sig_info(sig, info, p);
15750 @@ -1936,6 +1963,11 @@ relock:
15751 !sig_kernel_only(signr))
15754 + /* virtual init is protected against user signals */
15755 + if ((info->si_code == SI_USER) &&
15756 + vx_current_initpid(current->pid))
15759 if (sig_kernel_stop(signr)) {
15761 * The default action is to stop all threads in
15762 diff -NurpP --minimal linux-2.6.38.3/kernel/softirq.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/softirq.c
15763 --- linux-2.6.38.3/kernel/softirq.c 2011-03-15 18:07:42.000000000 +0100
15764 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/softirq.c 2011-01-29 02:01:07.000000000 +0100
15766 #include <linux/ftrace.h>
15767 #include <linux/smp.h>
15768 #include <linux/tick.h>
15769 +#include <linux/vs_context.h>
15771 #define CREATE_TRACE_POINTS
15772 #include <trace/events/irq.h>
15773 diff -NurpP --minimal linux-2.6.38.3/kernel/sys.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/sys.c
15774 --- linux-2.6.38.3/kernel/sys.c 2011-03-15 18:07:42.000000000 +0100
15775 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/sys.c 2011-02-02 22:20:27.000000000 +0100
15777 #include <linux/syscalls.h>
15778 #include <linux/kprobes.h>
15779 #include <linux/user_namespace.h>
15780 +#include <linux/vs_pid.h>
15782 #include <linux/kmsg_dump.h>
15784 @@ -133,7 +134,10 @@ static int set_one_prio(struct task_stru
15787 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15789 + if (vx_flags(VXF_IGNEG_NICE, 0))
15795 no_nice = security_task_setnice(p, niceval);
15796 @@ -183,6 +187,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15798 pgrp = task_pgrp(current);
15799 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15800 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15802 error = set_one_prio(p, niceval, error);
15803 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15805 @@ -246,6 +252,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15807 pgrp = task_pgrp(current);
15808 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15809 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15811 niceval = 20 - task_nice(p);
15812 if (niceval > retval)
15814 @@ -363,6 +371,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15816 static DEFINE_MUTEX(reboot_mutex);
15818 +long vs_reboot(unsigned int, void __user *);
15821 * Reboot system call: for obvious reasons only root may call it,
15822 * and even root needs to set up some magic numbers in the registers
15823 @@ -395,6 +405,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15824 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15825 cmd = LINUX_REBOOT_CMD_HALT;
15827 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15828 + return vs_reboot(cmd, arg);
15830 mutex_lock(&reboot_mutex);
15832 case LINUX_REBOOT_CMD_RESTART:
15833 @@ -1177,7 +1190,7 @@ SYSCALL_DEFINE2(sethostname, char __user
15835 char tmp[__NEW_UTS_LEN];
15837 - if (!capable(CAP_SYS_ADMIN))
15838 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15840 if (len < 0 || len > __NEW_UTS_LEN)
15842 @@ -1226,7 +1239,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
15844 char tmp[__NEW_UTS_LEN];
15846 - if (!capable(CAP_SYS_ADMIN))
15847 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15849 if (len < 0 || len > __NEW_UTS_LEN)
15851 @@ -1342,7 +1355,7 @@ int do_prlimit(struct task_struct *tsk,
15852 task_lock(tsk->group_leader);
15854 if (new_rlim->rlim_max > rlim->rlim_max &&
15855 - !capable(CAP_SYS_RESOURCE))
15856 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15859 retval = security_task_setrlimit(tsk->group_leader,
15860 @@ -1392,7 +1405,7 @@ static int check_prlimit_permission(stru
15861 cred->gid != tcred->egid ||
15862 cred->gid != tcred->sgid ||
15863 cred->gid != tcred->gid) &&
15864 - !capable(CAP_SYS_RESOURCE)) {
15865 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT)) {
15869 diff -NurpP --minimal linux-2.6.38.3/kernel/sysctl.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/sysctl.c
15870 --- linux-2.6.38.3/kernel/sysctl.c 2011-04-15 10:30:30.000000000 +0200
15871 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/sysctl.c 2011-03-28 15:00:14.000000000 +0200
15873 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15874 #include <linux/lockdep.h>
15876 +extern char vshelper_path[];
15877 #ifdef CONFIG_CHR_DEV_SG
15878 #include <scsi/sg.h>
15880 @@ -573,6 +574,13 @@ static struct ctl_table kern_table[] = {
15881 .proc_handler = proc_dostring,
15885 + .procname = "vshelper",
15886 + .data = &vshelper_path,
15889 + .proc_handler = &proc_dostring,
15891 #ifdef CONFIG_CHR_DEV_SG
15893 .procname = "sg-big-buff",
15894 diff -NurpP --minimal linux-2.6.38.3/kernel/sysctl_binary.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/sysctl_binary.c
15895 --- linux-2.6.38.3/kernel/sysctl_binary.c 2011-03-15 18:07:42.000000000 +0100
15896 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/sysctl_binary.c 2011-01-29 02:01:07.000000000 +0100
15897 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15899 { CTL_INT, KERN_PANIC, "panic" },
15900 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15901 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15903 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15904 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15905 diff -NurpP --minimal linux-2.6.38.3/kernel/time/timekeeping.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/time/timekeeping.c
15906 --- linux-2.6.38.3/kernel/time/timekeeping.c 2011-03-15 18:07:42.000000000 +0100
15907 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/time/timekeeping.c 2011-01-29 02:01:07.000000000 +0100
15908 @@ -233,6 +233,7 @@ void getnstimeofday(struct timespec *ts)
15909 } while (read_seqretry(&xtime_lock, seq));
15911 timespec_add_ns(ts, nsecs);
15912 + vx_adjust_timespec(ts);
15915 EXPORT_SYMBOL(getnstimeofday);
15916 diff -NurpP --minimal linux-2.6.38.3/kernel/time.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/time.c
15917 --- linux-2.6.38.3/kernel/time.c 2011-03-15 18:07:42.000000000 +0100
15918 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/time.c 2011-01-29 02:01:07.000000000 +0100
15919 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15923 - do_settimeofday(&tv);
15924 + vx_settimeofday(&tv);
15928 @@ -177,7 +177,7 @@ int do_sys_settimeofday(struct timespec
15929 /* SMP safe, again the code in arch/foo/time.c should
15930 * globally block out interrupts when it runs.
15932 - return do_settimeofday(tv);
15933 + return vx_settimeofday(tv);
15937 diff -NurpP --minimal linux-2.6.38.3/kernel/timer.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/timer.c
15938 --- linux-2.6.38.3/kernel/timer.c 2011-03-15 18:07:42.000000000 +0100
15939 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/timer.c 2011-02-17 02:17:51.000000000 +0100
15941 #include <linux/irq_work.h>
15942 #include <linux/sched.h>
15943 #include <linux/slab.h>
15944 +#include <linux/vs_base.h>
15945 +#include <linux/vs_cvirt.h>
15946 +#include <linux/vs_pid.h>
15947 +#include <linux/vserver/sched.h>
15949 #include <asm/uaccess.h>
15950 #include <asm/unistd.h>
15951 @@ -1321,12 +1325,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15958 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15959 - * should be moved into arch/i386 instead?
15963 * sys_getpid - return the thread group id of the current process
15964 @@ -1355,10 +1353,23 @@ SYSCALL_DEFINE0(getppid)
15966 pid = task_tgid_vnr(current->real_parent);
15968 + return vx_map_pid(pid);
15975 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15978 +asmlinkage long do_getxpid(long *ppid)
15980 + *ppid = sys_getppid();
15981 + return sys_getpid();
15984 +#else /* _alpha_ */
15986 SYSCALL_DEFINE0(getuid)
15988 /* Only we change this so SMP safe */
15989 diff -NurpP --minimal linux-2.6.38.3/kernel/user_namespace.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/user_namespace.c
15990 --- linux-2.6.38.3/kernel/user_namespace.c 2011-03-15 18:07:42.000000000 +0100
15991 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/user_namespace.c 2011-01-29 02:01:07.000000000 +0100
15993 #include <linux/user_namespace.h>
15994 #include <linux/highuid.h>
15995 #include <linux/cred.h>
15996 +#include <linux/vserver/global.h>
15998 static struct kmem_cache *user_ns_cachep __read_mostly;
16000 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
16003 kref_init(&ns->kref);
16004 + atomic_inc(&vs_global_user_ns);
16006 for (n = 0; n < UIDHASH_SZ; ++n)
16007 INIT_HLIST_HEAD(ns->uidhash_table + n);
16008 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
16009 struct user_namespace *ns =
16010 container_of(kref, struct user_namespace, kref);
16012 + /* FIXME: maybe move into destroyer? */
16013 + atomic_dec(&vs_global_user_ns);
16014 INIT_WORK(&ns->destroyer, free_user_ns_work);
16015 schedule_work(&ns->destroyer);
16017 diff -NurpP --minimal linux-2.6.38.3/kernel/utsname.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/utsname.c
16018 --- linux-2.6.38.3/kernel/utsname.c 2009-09-10 15:26:28.000000000 +0200
16019 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/utsname.c 2011-01-29 02:01:07.000000000 +0100
16020 @@ -14,14 +14,17 @@
16021 #include <linux/utsname.h>
16022 #include <linux/err.h>
16023 #include <linux/slab.h>
16024 +#include <linux/vserver/global.h>
16026 static struct uts_namespace *create_uts_ns(void)
16028 struct uts_namespace *uts_ns;
16030 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
16033 kref_init(&uts_ns->kref);
16034 + atomic_inc(&vs_global_uts_ns);
16039 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
16040 struct uts_namespace *ns;
16042 ns = container_of(kref, struct uts_namespace, kref);
16043 + atomic_dec(&vs_global_uts_ns);
16046 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/Kconfig
16047 --- linux-2.6.38.3/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
16048 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/Kconfig 2011-03-15 21:32:33.000000000 +0100
16051 +# Linux VServer configuration
16054 +menu "Linux VServer"
16056 +config VSERVER_AUTO_LBACK
16057 + bool "Automatically Assign Loopback IP"
16060 + Automatically assign a guest specific loopback
16061 + IP and add it to the kernel network stack on
16064 +config VSERVER_AUTO_SINGLE
16065 + bool "Automatic Single IP Special Casing"
16066 + depends on EXPERIMENTAL
16069 + This allows network contexts with a single IP to
16070 + automatically remap 0.0.0.0 bindings to that IP,
16071 + avoiding further network checks and improving
16074 + (note: such guests do not allow to change the ip
16075 + on the fly and do not show loopback addresses)
16077 +config VSERVER_COWBL
16078 + bool "Enable COW Immutable Link Breaking"
16081 + This enables the COW (Copy-On-Write) link break code.
16082 + It allows you to treat unified files like normal files
16083 + when writing to them (which will implicitely break the
16084 + link and create a copy of the unified file)
16086 +config VSERVER_VTIME
16087 + bool "Enable Virtualized Guest Time"
16088 + depends on EXPERIMENTAL
16091 + This enables per guest time offsets to allow for
16092 + adjusting the system clock individually per guest.
16093 + this adds some overhead to the time functions and
16094 + therefore should not be enabled without good reason.
16096 +config VSERVER_DEVICE
16097 + bool "Enable Guest Device Mapping"
16098 + depends on EXPERIMENTAL
16101 + This enables generic device remapping.
16103 +config VSERVER_PROC_SECURE
16104 + bool "Enable Proc Security"
16105 + depends on PROC_FS
16108 + This configures ProcFS security to initially hide
16109 + non-process entries for all contexts except the main and
16110 + spectator context (i.e. for all guests), which is a secure
16113 + (note: on 1.2x the entries were visible by default)
16116 + prompt "Persistent Inode Tagging"
16117 + default TAGGING_ID24
16119 + This adds persistent context information to filesystems
16120 + mounted with the tagxid option. Tagging is a requirement
16121 + for per-context disk limits and per-context quota.
16124 +config TAGGING_NONE
16127 + do not store per-context information in inodes.
16129 +config TAGGING_UID16
16130 + bool "UID16/GID32"
16132 + reduces UID to 16 bit, but leaves GID at 32 bit.
16134 +config TAGGING_GID16
16135 + bool "UID32/GID16"
16137 + reduces GID to 16 bit, but leaves UID at 32 bit.
16139 +config TAGGING_ID24
16140 + bool "UID24/GID24"
16142 + uses the upper 8bit from UID and GID for XID tagging
16143 + which leaves 24bit for UID/GID each, which should be
16144 + more than sufficient for normal use.
16146 +config TAGGING_INTERN
16147 + bool "UID32/GID32"
16149 + this uses otherwise reserved inode fields in the on
16150 + disk representation, which limits the use to a few
16151 + filesystems (currently ext2 and ext3)
16156 + bool "Tag NFSD User Auth and Files"
16159 + Enable this if you do want the in-kernel NFS
16160 + Server to use the tagging specified above.
16161 + (will require patched clients too)
16163 +config VSERVER_PRIVACY
16164 + bool "Honor Privacy Aspects of Guests"
16167 + When enabled, most context checks will disallow
16168 + access to structures assigned to a specific context,
16169 + like ptys or loop devices.
16171 +config VSERVER_CONTEXTS
16172 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
16174 + default "768" if 64BIT
16177 + This setting will optimize certain data structures
16178 + and memory allocations according to the expected
16181 + note: this is not a strict upper limit.
16183 +config VSERVER_WARN
16184 + bool "VServer Warnings"
16187 + This enables various runtime warnings, which will
16188 + notify about potential manipulation attempts or
16189 + resource shortage. It is generally considered to
16190 + be a good idea to have that enabled.
16192 +config VSERVER_WARN_DEVPTS
16193 + bool "VServer DevPTS Warnings"
16194 + depends on VSERVER_WARN
16197 + This enables DevPTS related warnings, issued when a
16198 + process inside a context tries to lookup or access
16199 + a dynamic pts from the host or a different context.
16201 +config VSERVER_DEBUG
16202 + bool "VServer Debugging Code"
16205 + Set this to yes if you want to be able to activate
16206 + debugging output at runtime. It adds a very small
16207 + overhead to all vserver related functions and
16208 + increases the kernel size by about 20k.
16210 +config VSERVER_HISTORY
16211 + bool "VServer History Tracing"
16212 + depends on VSERVER_DEBUG
16215 + Set this to yes if you want to record the history of
16216 + linux-vserver activities, so they can be replayed in
16217 + the event of a kernel panic or oops.
16219 +config VSERVER_HISTORY_SIZE
16220 + int "Per-CPU History Size (32-65536)"
16221 + depends on VSERVER_HISTORY
16225 + This allows you to specify the number of entries in
16226 + the per-CPU history buffer.
16228 +config VSERVER_LEGACY_MEM
16229 + bool "Legacy Memory Limits"
16232 + This provides fake memory limits to keep
16233 + older tools happy in the face of memory
16237 + prompt "Quotes used in debug and warn messages"
16238 + default QUOTES_ISO8859
16240 +config QUOTES_ISO8859
16241 + bool "Extended ASCII (ISO 8859) angle quotes"
16243 + This uses the extended ASCII characters \xbb
16244 + and \xab for quoting file and process names.
16246 +config QUOTES_UTF8
16247 + bool "UTF-8 angle quotes"
16249 + This uses the the UTF-8 sequences for angle
16250 + quotes to quote file and process names.
16252 +config QUOTES_ASCII
16253 + bool "ASCII single quotes"
16255 + This uses the ASCII single quote character
16256 + (\x27) to quote file and process names.
16266 + select NAMESPACES
16272 +config VSERVER_SECURITY
16274 + depends on SECURITY
16276 + select SECURITY_CAPABILITIES
16278 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/Makefile linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/Makefile
16279 --- linux-2.6.38.3/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
16280 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/Makefile 2011-01-29 02:01:07.000000000 +0100
16283 +# Makefile for the Linux vserver routines.
16287 +obj-y += vserver.o
16289 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
16290 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
16293 +vserver-$(CONFIG_INET) += inet.o
16294 +vserver-$(CONFIG_PROC_FS) += proc.o
16295 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
16296 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
16297 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
16298 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
16300 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/cacct.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/cacct.c
16301 --- linux-2.6.38.3/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
16302 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/cacct.c 2011-01-29 02:01:07.000000000 +0100
16305 + * linux/kernel/vserver/cacct.c
16307 + * Virtual Server: Context Accounting
16309 + * Copyright (C) 2006-2007 Herbert Pötzl
16311 + * V0.01 added accounting stats
16315 +#include <linux/types.h>
16316 +#include <linux/vs_context.h>
16317 +#include <linux/vserver/cacct_cmd.h>
16318 +#include <linux/vserver/cacct_int.h>
16320 +#include <asm/errno.h>
16321 +#include <asm/uaccess.h>
16324 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
16326 + struct vcmd_sock_stat_v0 vc_data;
16329 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16332 + field = vc_data.field;
16333 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
16336 + for (j = 0; j < 3; j++) {
16337 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
16338 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
16341 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16346 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/cacct_init.h linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/cacct_init.h
16347 --- linux-2.6.38.3/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16348 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/cacct_init.h 2011-01-29 02:01:07.000000000 +0100
16352 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16357 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16358 + for (j = 0; j < 3; j++) {
16359 + atomic_long_set(&cacct->sock[i][j].count, 0);
16360 + atomic_long_set(&cacct->sock[i][j].total, 0);
16363 + for (i = 0; i < 8; i++)
16364 + atomic_set(&cacct->slab[i], 0);
16365 + for (i = 0; i < 5; i++)
16366 + for (j = 0; j < 4; j++)
16367 + atomic_set(&cacct->page[i][j], 0);
16370 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16375 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/cacct_proc.h linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/cacct_proc.h
16376 --- linux-2.6.38.3/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
16377 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/cacct_proc.h 2011-01-29 02:01:07.000000000 +0100
16379 +#ifndef _VX_CACCT_PROC_H
16380 +#define _VX_CACCT_PROC_H
16382 +#include <linux/vserver/cacct_int.h>
16385 +#define VX_SOCKA_TOP \
16386 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
16388 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
16390 + int i, j, length = 0;
16391 + static char *type[VXA_SOCK_SIZE] = {
16392 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
16395 + length += sprintf(buffer + length, VX_SOCKA_TOP);
16396 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16397 + length += sprintf(buffer + length, "%s:", type[i]);
16398 + for (j = 0; j < 3; j++) {
16399 + length += sprintf(buffer + length,
16400 + "\t%10lu/%-10lu",
16401 + vx_sock_count(cacct, i, j),
16402 + vx_sock_total(cacct, i, j));
16404 + buffer[length++] = '\n';
16407 + length += sprintf(buffer + length, "\n");
16408 + length += sprintf(buffer + length,
16409 + "slab:\t %8u %8u %8u %8u\n",
16410 + atomic_read(&cacct->slab[1]),
16411 + atomic_read(&cacct->slab[4]),
16412 + atomic_read(&cacct->slab[0]),
16413 + atomic_read(&cacct->slab[2]));
16415 + length += sprintf(buffer + length, "\n");
16416 + for (i = 0; i < 5; i++) {
16417 + length += sprintf(buffer + length,
16418 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
16419 + atomic_read(&cacct->page[i][0]),
16420 + atomic_read(&cacct->page[i][1]),
16421 + atomic_read(&cacct->page[i][2]),
16422 + atomic_read(&cacct->page[i][3]),
16423 + atomic_read(&cacct->page[i][4]),
16424 + atomic_read(&cacct->page[i][5]),
16425 + atomic_read(&cacct->page[i][6]),
16426 + atomic_read(&cacct->page[i][7]));
16431 +#endif /* _VX_CACCT_PROC_H */
16432 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/context.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/context.c
16433 --- linux-2.6.38.3/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
16434 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/context.c 2011-03-22 17:35:46.000000000 +0100
16437 + * linux/kernel/vserver/context.c
16439 + * Virtual Server: Context Support
16441 + * Copyright (C) 2003-2010 Herbert Pötzl
16443 + * V0.01 context helper
16444 + * V0.02 vx_ctx_kill syscall command
16445 + * V0.03 replaced context_info calls
16446 + * V0.04 redesign of struct (de)alloc
16447 + * V0.05 rlimit basic implementation
16448 + * V0.06 task_xid and info commands
16449 + * V0.07 context flags and caps
16450 + * V0.08 switch to RCU based hash
16451 + * V0.09 revert to non RCU for now
16452 + * V0.10 and back to working RCU hash
16453 + * V0.11 and back to locking again
16454 + * V0.12 referenced context store
16455 + * V0.13 separate per cpu data
16456 + * V0.14 changed vcmds to vxi arg
16457 + * V0.15 added context stat
16458 + * V0.16 have __create claim() the vxi
16459 + * V0.17 removed older and legacy stuff
16460 + * V0.18 added user credentials
16464 +#include <linux/slab.h>
16465 +#include <linux/types.h>
16466 +#include <linux/security.h>
16467 +#include <linux/pid_namespace.h>
16469 +#include <linux/vserver/context.h>
16470 +#include <linux/vserver/network.h>
16471 +#include <linux/vserver/debug.h>
16472 +#include <linux/vserver/limit.h>
16473 +#include <linux/vserver/limit_int.h>
16474 +#include <linux/vserver/space.h>
16475 +#include <linux/init_task.h>
16476 +#include <linux/fs_struct.h>
16477 +#include <linux/cred.h>
16479 +#include <linux/vs_context.h>
16480 +#include <linux/vs_limit.h>
16481 +#include <linux/vs_pid.h>
16482 +#include <linux/vserver/context_cmd.h>
16484 +#include "cvirt_init.h"
16485 +#include "cacct_init.h"
16486 +#include "limit_init.h"
16487 +#include "sched_init.h"
16490 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
16491 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
16494 +/* now inactive context structures */
16496 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
16498 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
16501 +/* __alloc_vx_info()
16503 + * allocate an initialized vx_info struct
16504 + * doesn't make it visible (hash) */
16506 +static struct vx_info *__alloc_vx_info(xid_t xid)
16508 + struct vx_info *new = NULL;
16511 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
16513 + /* would this benefit from a slab cache? */
16514 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
16518 + memset(new, 0, sizeof(struct vx_info));
16520 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
16521 + if (!new->ptr_pc)
16524 + new->vx_id = xid;
16525 + INIT_HLIST_NODE(&new->vx_hlist);
16526 + atomic_set(&new->vx_usecnt, 0);
16527 + atomic_set(&new->vx_tasks, 0);
16528 + new->vx_parent = NULL;
16529 + new->vx_state = 0;
16530 + init_waitqueue_head(&new->vx_wait);
16532 + /* prepare reaper */
16533 + get_task_struct(init_pid_ns.child_reaper);
16534 + new->vx_reaper = init_pid_ns.child_reaper;
16535 + new->vx_badness_bias = 0;
16537 + /* rest of init goes here */
16538 + vx_info_init_limit(&new->limit);
16539 + vx_info_init_sched(&new->sched);
16540 + vx_info_init_cvirt(&new->cvirt);
16541 + vx_info_init_cacct(&new->cacct);
16543 + /* per cpu data structures */
16544 + for_each_possible_cpu(cpu) {
16545 + vx_info_init_sched_pc(
16546 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16547 + vx_info_init_cvirt_pc(
16548 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16551 + new->vx_flags = VXF_INIT_SET;
16552 + cap_set_init_eff(new->vx_bcaps);
16553 + new->vx_ccaps = 0;
16554 + new->vx_umask = 0;
16556 + new->reboot_cmd = 0;
16557 + new->exit_code = 0;
16559 + // preconfig spaces
16560 + for (index = 0; index < VX_SPACES; index++) {
16561 + struct _vx_space *space = &new->space[index];
16564 + spin_lock(&init_fs.lock);
16566 + spin_unlock(&init_fs.lock);
16567 + space->vx_fs = &init_fs;
16569 + /* FIXME: do we want defaults? */
16570 + // space->vx_real_cred = 0;
16571 + // space->vx_cred = 0;
16575 + vxdprintk(VXD_CBIT(xid, 0),
16576 + "alloc_vx_info(%d) = %p", xid, new);
16577 + vxh_alloc_vx_info(new);
16578 + atomic_inc(&vx_global_ctotal);
16587 +/* __dealloc_vx_info()
16589 + * final disposal of vx_info */
16591 +static void __dealloc_vx_info(struct vx_info *vxi)
16593 +#ifdef CONFIG_VSERVER_WARN
16594 + struct vx_info_save vxis;
16597 + vxdprintk(VXD_CBIT(xid, 0),
16598 + "dealloc_vx_info(%p)", vxi);
16599 + vxh_dealloc_vx_info(vxi);
16601 +#ifdef CONFIG_VSERVER_WARN
16602 + enter_vx_info(vxi, &vxis);
16603 + vx_info_exit_limit(&vxi->limit);
16604 + vx_info_exit_sched(&vxi->sched);
16605 + vx_info_exit_cvirt(&vxi->cvirt);
16606 + vx_info_exit_cacct(&vxi->cacct);
16608 + for_each_possible_cpu(cpu) {
16609 + vx_info_exit_sched_pc(
16610 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16611 + vx_info_exit_cvirt_pc(
16612 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16614 + leave_vx_info(&vxis);
16618 + vxi->vx_state |= VXS_RELEASED;
16621 + free_percpu(vxi->ptr_pc);
16624 + atomic_dec(&vx_global_ctotal);
16627 +static void __shutdown_vx_info(struct vx_info *vxi)
16629 + struct nsproxy *nsproxy;
16630 + struct fs_struct *fs;
16631 + struct cred *cred;
16636 + vxi->vx_state |= VXS_SHUTDOWN;
16637 + vs_state_change(vxi, VSC_SHUTDOWN);
16639 + for (index = 0; index < VX_SPACES; index++) {
16640 + struct _vx_space *space = &vxi->space[index];
16642 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16644 + put_nsproxy(nsproxy);
16646 + fs = xchg(&space->vx_fs, NULL);
16647 + spin_lock(&fs->lock);
16648 + kill = !--fs->users;
16649 + spin_unlock(&fs->lock);
16651 + free_fs_struct(fs);
16653 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
16655 + abort_creds(cred);
16659 +/* exported stuff */
16661 +void free_vx_info(struct vx_info *vxi)
16663 + unsigned long flags;
16666 + /* check for reference counts first */
16667 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16668 + BUG_ON(atomic_read(&vxi->vx_tasks));
16670 + /* context must not be hashed */
16671 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16673 + /* context shutdown is mandatory */
16674 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16676 + /* spaces check */
16677 + for (index = 0; index < VX_SPACES; index++) {
16678 + struct _vx_space *space = &vxi->space[index];
16680 + BUG_ON(space->vx_nsproxy);
16681 + BUG_ON(space->vx_fs);
16682 + // BUG_ON(space->vx_real_cred);
16683 + // BUG_ON(space->vx_cred);
16686 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16687 + hlist_del(&vxi->vx_hlist);
16688 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16690 + __dealloc_vx_info(vxi);
16694 +/* hash table for vx_info hash */
16696 +#define VX_HASH_SIZE 13
16698 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16699 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16701 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
16704 +static inline unsigned int __hashval(xid_t xid)
16706 + return (xid % VX_HASH_SIZE);
16711 +/* __hash_vx_info()
16713 + * add the vxi to the global hash table
16714 + * requires the hash_lock to be held */
16716 +static inline void __hash_vx_info(struct vx_info *vxi)
16718 + struct hlist_head *head;
16720 + vxd_assert_lock(&vx_info_hash_lock);
16721 + vxdprintk(VXD_CBIT(xid, 4),
16722 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16723 + vxh_hash_vx_info(vxi);
16725 + /* context must not be hashed */
16726 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16728 + vxi->vx_state |= VXS_HASHED;
16729 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16730 + hlist_add_head(&vxi->vx_hlist, head);
16731 + atomic_inc(&vx_global_cactive);
16734 +/* __unhash_vx_info()
16736 + * remove the vxi from the global hash table
16737 + * requires the hash_lock to be held */
16739 +static inline void __unhash_vx_info(struct vx_info *vxi)
16741 + unsigned long flags;
16743 + vxd_assert_lock(&vx_info_hash_lock);
16744 + vxdprintk(VXD_CBIT(xid, 4),
16745 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16746 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16747 + vxh_unhash_vx_info(vxi);
16749 + /* context must be hashed */
16750 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16751 + /* but without tasks */
16752 + BUG_ON(atomic_read(&vxi->vx_tasks));
16754 + vxi->vx_state &= ~VXS_HASHED;
16755 + hlist_del_init(&vxi->vx_hlist);
16756 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16757 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16758 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16759 + atomic_dec(&vx_global_cactive);
16763 +/* __lookup_vx_info()
16765 + * requires the hash_lock to be held
16766 + * doesn't increment the vx_refcnt */
16768 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16770 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16771 + struct hlist_node *pos;
16772 + struct vx_info *vxi;
16774 + vxd_assert_lock(&vx_info_hash_lock);
16775 + hlist_for_each(pos, head) {
16776 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16778 + if (vxi->vx_id == xid)
16783 + vxdprintk(VXD_CBIT(xid, 0),
16784 + "__lookup_vx_info(#%u): %p[#%u]",
16785 + xid, vxi, vxi ? vxi->vx_id : 0);
16786 + vxh_lookup_vx_info(vxi, xid);
16791 +/* __create_vx_info()
16793 + * create the requested context
16794 + * get(), claim() and hash it */
16796 +static struct vx_info *__create_vx_info(int id)
16798 + struct vx_info *new, *vxi = NULL;
16800 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16802 + if (!(new = __alloc_vx_info(id)))
16803 + return ERR_PTR(-ENOMEM);
16805 + /* required to make dynamic xids unique */
16806 + spin_lock(&vx_info_hash_lock);
16808 + /* static context requested */
16809 + if ((vxi = __lookup_vx_info(id))) {
16810 + vxdprintk(VXD_CBIT(xid, 0),
16811 + "create_vx_info(%d) = %p (already there)", id, vxi);
16812 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16813 + vxi = ERR_PTR(-EBUSY);
16815 + vxi = ERR_PTR(-EEXIST);
16818 + /* new context */
16819 + vxdprintk(VXD_CBIT(xid, 0),
16820 + "create_vx_info(%d) = %p (new)", id, new);
16821 + claim_vx_info(new, NULL);
16822 + __hash_vx_info(get_vx_info(new));
16823 + vxi = new, new = NULL;
16826 + spin_unlock(&vx_info_hash_lock);
16827 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16829 + __dealloc_vx_info(new);
16834 +/* exported stuff */
16837 +void unhash_vx_info(struct vx_info *vxi)
16839 + __shutdown_vx_info(vxi);
16840 + spin_lock(&vx_info_hash_lock);
16841 + __unhash_vx_info(vxi);
16842 + spin_unlock(&vx_info_hash_lock);
16843 + __wakeup_vx_info(vxi);
16847 +/* lookup_vx_info()
16849 + * search for a vx_info and get() it
16850 + * negative id means current */
16852 +struct vx_info *lookup_vx_info(int id)
16854 + struct vx_info *vxi = NULL;
16857 + vxi = get_vx_info(current_vx_info());
16858 + } else if (id > 1) {
16859 + spin_lock(&vx_info_hash_lock);
16860 + vxi = get_vx_info(__lookup_vx_info(id));
16861 + spin_unlock(&vx_info_hash_lock);
16866 +/* xid_is_hashed()
16868 + * verify that xid is still hashed */
16870 +int xid_is_hashed(xid_t xid)
16874 + spin_lock(&vx_info_hash_lock);
16875 + hashed = (__lookup_vx_info(xid) != NULL);
16876 + spin_unlock(&vx_info_hash_lock);
16880 +#ifdef CONFIG_PROC_FS
16884 + * get a subset of hashed xids for proc
16885 + * assumes size is at least one */
16887 +int get_xid_list(int index, unsigned int *xids, int size)
16889 + int hindex, nr_xids = 0;
16891 + /* only show current and children */
16892 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16895 + xids[nr_xids] = vx_current_xid();
16899 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16900 + struct hlist_head *head = &vx_info_hash[hindex];
16901 + struct hlist_node *pos;
16903 + spin_lock(&vx_info_hash_lock);
16904 + hlist_for_each(pos, head) {
16905 + struct vx_info *vxi;
16910 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16911 + xids[nr_xids] = vxi->vx_id;
16912 + if (++nr_xids >= size) {
16913 + spin_unlock(&vx_info_hash_lock);
16917 + /* keep the lock time short */
16918 + spin_unlock(&vx_info_hash_lock);
16925 +#ifdef CONFIG_VSERVER_DEBUG
16927 +void dump_vx_info_inactive(int level)
16929 + struct hlist_node *entry, *next;
16931 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16932 + struct vx_info *vxi =
16933 + list_entry(entry, struct vx_info, vx_hlist);
16935 + dump_vx_info(vxi, level);
16942 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16944 + struct user_struct *new_user, *old_user;
16949 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16952 + new_user = alloc_uid(vxi->vx_id, p->uid);
16956 + old_user = p->user;
16957 + if (new_user != old_user) {
16958 + atomic_inc(&new_user->processes);
16959 + atomic_dec(&old_user->processes);
16960 + p->user = new_user;
16962 + free_uid(old_user);
16968 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16970 + // p->cap_effective &= vxi->vx_cap_bset;
16971 + p->cap_effective =
16972 + cap_intersect(p->cap_effective, vxi->cap_bset);
16973 + // p->cap_inheritable &= vxi->vx_cap_bset;
16974 + p->cap_inheritable =
16975 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16976 + // p->cap_permitted &= vxi->vx_cap_bset;
16977 + p->cap_permitted =
16978 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16983 +#include <linux/file.h>
16984 +#include <linux/fdtable.h>
16986 +static int vx_openfd_task(struct task_struct *tsk)
16988 + struct files_struct *files = tsk->files;
16989 + struct fdtable *fdt;
16990 + const unsigned long *bptr;
16991 + int count, total;
16993 + /* no rcu_read_lock() because of spin_lock() */
16994 + spin_lock(&files->file_lock);
16995 + fdt = files_fdtable(files);
16996 + bptr = fdt->open_fds->fds_bits;
16997 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16998 + for (total = 0; count > 0; count--) {
17000 + total += hweight_long(*bptr);
17003 + spin_unlock(&files->file_lock);
17008 +/* for *space compatibility */
17010 +asmlinkage long sys_unshare(unsigned long);
17013 + * migrate task to new context
17014 + * gets vxi, puts old_vxi on change
17015 + * optionally unshares namespaces (hack)
17018 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
17020 + struct vx_info *old_vxi;
17026 + vxdprintk(VXD_CBIT(xid, 5),
17027 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
17028 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
17030 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
17031 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17034 + if (vx_info_state(vxi, VXS_SHUTDOWN))
17037 + old_vxi = task_get_vx_info(p);
17038 + if (old_vxi == vxi)
17041 +// if (!(ret = vx_migrate_user(p, vxi))) {
17046 + openfd = vx_openfd_task(p);
17049 + atomic_dec(&old_vxi->cvirt.nr_threads);
17050 + atomic_dec(&old_vxi->cvirt.nr_running);
17051 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
17052 + /* FIXME: what about the struct files here? */
17053 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
17054 + /* account for the executable */
17055 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
17057 + atomic_inc(&vxi->cvirt.nr_threads);
17058 + atomic_inc(&vxi->cvirt.nr_running);
17059 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
17060 + /* FIXME: what about the struct files here? */
17061 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
17062 + /* account for the executable */
17063 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
17066 + release_vx_info(old_vxi, p);
17067 + clr_vx_info(&p->vx_info);
17069 + claim_vx_info(vxi, p);
17070 + set_vx_info(&p->vx_info, vxi);
17071 + p->xid = vxi->vx_id;
17073 + vxdprintk(VXD_CBIT(xid, 5),
17074 + "moved task %p into vxi:%p[#%d]",
17075 + p, vxi, vxi->vx_id);
17077 + // vx_mask_cap_bset(vxi, p);
17080 + /* hack for *spaces to provide compatibility */
17082 + struct nsproxy *old_nsp, *new_nsp;
17084 + ret = unshare_nsproxy_namespaces(
17085 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
17090 + old_nsp = xchg(&p->nsproxy, new_nsp);
17091 + vx_set_space(vxi,
17092 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
17093 + put_nsproxy(old_nsp);
17097 + put_vx_info(old_vxi);
17101 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
17103 + struct task_struct *old_reaper;
17108 + vxdprintk(VXD_CBIT(xid, 6),
17109 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
17110 + vxi, vxi->vx_id, p, p->xid, p->pid);
17112 + old_reaper = vxi->vx_reaper;
17113 + if (old_reaper == p)
17116 + /* set new child reaper */
17117 + get_task_struct(p);
17118 + vxi->vx_reaper = p;
17119 + put_task_struct(old_reaper);
17123 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
17128 + vxdprintk(VXD_CBIT(xid, 6),
17129 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
17130 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17132 + vxi->vx_flags &= ~VXF_STATE_INIT;
17133 + // vxi->vx_initpid = p->tgid;
17134 + vxi->vx_initpid = p->pid;
17138 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
17140 + vxdprintk(VXD_CBIT(xid, 6),
17141 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
17142 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17144 + vxi->exit_code = code;
17145 + vxi->vx_initpid = 0;
17149 +void vx_set_persistent(struct vx_info *vxi)
17151 + vxdprintk(VXD_CBIT(xid, 6),
17152 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
17154 + get_vx_info(vxi);
17155 + claim_vx_info(vxi, NULL);
17158 +void vx_clear_persistent(struct vx_info *vxi)
17160 + vxdprintk(VXD_CBIT(xid, 6),
17161 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
17163 + release_vx_info(vxi, NULL);
17164 + put_vx_info(vxi);
17167 +void vx_update_persistent(struct vx_info *vxi)
17169 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
17170 + vx_set_persistent(vxi);
17172 + vx_clear_persistent(vxi);
17176 +/* task must be current or locked */
17178 +void exit_vx_info(struct task_struct *p, int code)
17180 + struct vx_info *vxi = p->vx_info;
17183 + atomic_dec(&vxi->cvirt.nr_threads);
17186 + vxi->exit_code = code;
17187 + release_vx_info(vxi, p);
17191 +void exit_vx_info_early(struct task_struct *p, int code)
17193 + struct vx_info *vxi = p->vx_info;
17196 + if (vxi->vx_initpid == p->pid)
17197 + vx_exit_init(vxi, p, code);
17198 + if (vxi->vx_reaper == p)
17199 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
17204 +/* vserver syscall commands below here */
17206 +/* taks xid and vx_info functions */
17208 +#include <asm/uaccess.h>
17211 +int vc_task_xid(uint32_t id)
17216 + struct task_struct *tsk;
17219 + tsk = find_task_by_real_pid(id);
17220 + xid = (tsk) ? tsk->xid : -ESRCH;
17221 + rcu_read_unlock();
17223 + xid = vx_current_xid();
17228 +int vc_vx_info(struct vx_info *vxi, void __user *data)
17230 + struct vcmd_vx_info_v0 vc_data;
17232 + vc_data.xid = vxi->vx_id;
17233 + vc_data.initpid = vxi->vx_initpid;
17235 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17241 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
17243 + struct vcmd_ctx_stat_v0 vc_data;
17245 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
17246 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
17248 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17254 +/* context functions */
17256 +int vc_ctx_create(uint32_t xid, void __user *data)
17258 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
17259 + struct vx_info *new_vxi;
17262 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17265 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
17268 + new_vxi = __create_vx_info(xid);
17269 + if (IS_ERR(new_vxi))
17270 + return PTR_ERR(new_vxi);
17272 + /* initial flags */
17273 + new_vxi->vx_flags = vc_data.flagword;
17276 + if (vs_state_change(new_vxi, VSC_STARTUP))
17279 + ret = vx_migrate_task(current, new_vxi, (!data));
17283 + /* return context id on success */
17284 + ret = new_vxi->vx_id;
17286 + /* get a reference for persistent contexts */
17287 + if ((vc_data.flagword & VXF_PERSISTENT))
17288 + vx_set_persistent(new_vxi);
17290 + release_vx_info(new_vxi, NULL);
17291 + put_vx_info(new_vxi);
17296 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
17298 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
17301 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17304 + ret = vx_migrate_task(current, vxi, 0);
17307 + if (vc_data.flagword & VXM_SET_INIT)
17308 + ret = vx_set_init(vxi, current);
17311 + if (vc_data.flagword & VXM_SET_REAPER)
17312 + ret = vx_set_reaper(vxi, current);
17317 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
17319 + struct vcmd_ctx_flags_v0 vc_data;
17321 + vc_data.flagword = vxi->vx_flags;
17323 + /* special STATE flag handling */
17324 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
17326 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17331 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
17333 + struct vcmd_ctx_flags_v0 vc_data;
17334 + uint64_t mask, trigger;
17336 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17339 + /* special STATE flag handling */
17340 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
17341 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
17343 + if (vxi == current_vx_info()) {
17344 + /* if (trigger & VXF_STATE_SETUP)
17345 + vx_mask_cap_bset(vxi, current); */
17346 + if (trigger & VXF_STATE_INIT) {
17349 + ret = vx_set_init(vxi, current);
17352 + ret = vx_set_reaper(vxi, current);
17358 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17359 + vc_data.flagword, mask);
17360 + if (trigger & VXF_PERSISTENT)
17361 + vx_update_persistent(vxi);
17367 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17369 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17371 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17375 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17377 + kernel_cap_t c = __cap_empty_set;
17379 + c.cap[0] = v & 0xFFFFFFFF;
17380 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17382 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17387 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17390 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17392 + *ccaps = vxi->vx_ccaps;
17397 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17399 + struct vcmd_ctx_caps_v1 vc_data;
17402 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17405 + vc_data.cmask = ~0ULL;
17407 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17412 +static int do_set_caps(struct vx_info *vxi,
17413 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
17415 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
17418 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
17419 + bcaps, bmask, ccaps, cmask);
17421 + vxi->vx_bcaps = cap_t_from_caps(
17422 + vs_mask_flags(bcold, bcaps, bmask));
17423 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
17428 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
17430 + struct vcmd_ctx_caps_v1 vc_data;
17432 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17435 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
17438 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
17440 + struct vcmd_bcaps vc_data;
17443 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
17446 + vc_data.bmask = ~0ULL;
17448 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17453 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
17455 + struct vcmd_bcaps vc_data;
17457 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17460 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
17464 +int vc_get_umask(struct vx_info *vxi, void __user *data)
17466 + struct vcmd_umask vc_data;
17468 + vc_data.umask = vxi->vx_umask;
17469 + vc_data.mask = ~0ULL;
17471 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17476 +int vc_set_umask(struct vx_info *vxi, void __user *data)
17478 + struct vcmd_umask vc_data;
17480 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17483 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
17484 + vc_data.umask, vc_data.mask);
17489 +int vc_get_badness(struct vx_info *vxi, void __user *data)
17491 + struct vcmd_badness_v0 vc_data;
17493 + vc_data.bias = vxi->vx_badness_bias;
17495 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17500 +int vc_set_badness(struct vx_info *vxi, void __user *data)
17502 + struct vcmd_badness_v0 vc_data;
17504 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17507 + vxi->vx_badness_bias = vc_data.bias;
17511 +#include <linux/module.h>
17513 +EXPORT_SYMBOL_GPL(free_vx_info);
17515 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/cvirt.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/cvirt.c
17516 --- linux-2.6.38.3/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
17517 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/cvirt.c 2011-01-29 02:01:07.000000000 +0100
17520 + * linux/kernel/vserver/cvirt.c
17522 + * Virtual Server: Context Virtualization
17524 + * Copyright (C) 2004-2007 Herbert Pötzl
17526 + * V0.01 broken out from limit.c
17527 + * V0.02 added utsname stuff
17528 + * V0.03 changed vcmds to vxi arg
17532 +#include <linux/types.h>
17533 +#include <linux/utsname.h>
17534 +#include <linux/vs_cvirt.h>
17535 +#include <linux/vserver/switch.h>
17536 +#include <linux/vserver/cvirt_cmd.h>
17538 +#include <asm/uaccess.h>
17541 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17543 + struct vx_info *vxi = current_vx_info();
17545 + set_normalized_timespec(uptime,
17546 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17547 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17550 + set_normalized_timespec(idle,
17551 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17552 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17556 +uint64_t vx_idle_jiffies(void)
17558 + return init_task.utime + init_task.stime;
17563 +static inline uint32_t __update_loadavg(uint32_t load,
17564 + int wsize, int delta, int n)
17566 + unsigned long long calc, prev;
17568 + /* just set it to n */
17569 + if (unlikely(delta >= wsize))
17570 + return (n << FSHIFT);
17572 + calc = delta * n;
17574 + prev = (wsize - delta);
17577 + do_div(calc, wsize);
17582 +void vx_update_load(struct vx_info *vxi)
17584 + uint32_t now, last, delta;
17585 + unsigned int nr_running, nr_uninterruptible;
17586 + unsigned int total;
17587 + unsigned long flags;
17589 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17592 + last = vxi->cvirt.load_last;
17593 + delta = now - last;
17595 + if (delta < 5*HZ)
17598 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17599 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17600 + total = nr_running + nr_uninterruptible;
17602 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17603 + 60*HZ, delta, total);
17604 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17605 + 5*60*HZ, delta, total);
17606 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17607 + 15*60*HZ, delta, total);
17609 + vxi->cvirt.load_last = now;
17611 + atomic_inc(&vxi->cvirt.load_updates);
17612 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17617 + * Commands to do_syslog:
17619 + * 0 -- Close the log. Currently a NOP.
17620 + * 1 -- Open the log. Currently a NOP.
17621 + * 2 -- Read from the log.
17622 + * 3 -- Read all messages remaining in the ring buffer.
17623 + * 4 -- Read and clear all messages remaining in the ring buffer
17624 + * 5 -- Clear ring buffer.
17625 + * 6 -- Disable printk's to console
17626 + * 7 -- Enable printk's to console
17627 + * 8 -- Set level of messages printed to console
17628 + * 9 -- Return number of unread characters in the log buffer
17629 + * 10 -- Return size of the log buffer
17631 +int vx_do_syslog(int type, char __user *buf, int len)
17634 + int do_clear = 0;
17635 + struct vx_info *vxi = current_vx_info();
17636 + struct _vx_syslog *log;
17640 + log = &vxi->cvirt.syslog;
17643 + case 0: /* Close log */
17644 + case 1: /* Open log */
17646 + case 2: /* Read from log */
17647 + error = wait_event_interruptible(log->log_wait,
17648 + (log->log_start - log->log_end));
17651 + spin_lock_irq(&log->logbuf_lock);
17652 + spin_unlock_irq(&log->logbuf_lock);
17654 + case 4: /* Read/clear last kernel messages */
17656 + /* fall through */
17657 + case 3: /* Read last kernel messages */
17660 + case 5: /* Clear ring buffer */
17663 + case 6: /* Disable logging to console */
17664 + case 7: /* Enable logging to console */
17665 + case 8: /* Set level of messages printed to console */
17668 + case 9: /* Number of chars in the log buffer */
17670 + case 10: /* Size of the log buffer */
17680 +/* virtual host info names */
17682 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17684 + struct nsproxy *nsproxy;
17685 + struct uts_namespace *uts;
17687 + if (id == VHIN_CONTEXT)
17688 + return vxi->vx_name;
17690 + nsproxy = vxi->space[0].vx_nsproxy;
17694 + uts = nsproxy->uts_ns;
17699 + case VHIN_SYSNAME:
17700 + return uts->name.sysname;
17701 + case VHIN_NODENAME:
17702 + return uts->name.nodename;
17703 + case VHIN_RELEASE:
17704 + return uts->name.release;
17705 + case VHIN_VERSION:
17706 + return uts->name.version;
17707 + case VHIN_MACHINE:
17708 + return uts->name.machine;
17709 + case VHIN_DOMAINNAME:
17710 + return uts->name.domainname;
17717 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17719 + struct vcmd_vhi_name_v0 vc_data;
17722 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17725 + name = vx_vhi_name(vxi, vc_data.field);
17729 + memcpy(name, vc_data.name, 65);
17733 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17735 + struct vcmd_vhi_name_v0 vc_data;
17738 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17741 + name = vx_vhi_name(vxi, vc_data.field);
17745 + memcpy(vc_data.name, name, 65);
17746 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17752 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17754 + struct vcmd_virt_stat_v0 vc_data;
17755 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17756 + struct timespec uptime;
17758 + do_posix_clock_monotonic_gettime(&uptime);
17759 + set_normalized_timespec(&uptime,
17760 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17761 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17763 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17764 + vc_data.uptime = timespec_to_ns(&uptime);
17765 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17766 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17767 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17768 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17769 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17770 + vc_data.load[0] = cvirt->load[0];
17771 + vc_data.load[1] = cvirt->load[1];
17772 + vc_data.load[2] = cvirt->load[2];
17774 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17780 +#ifdef CONFIG_VSERVER_VTIME
17782 +/* virtualized time base */
17784 +void vx_adjust_timespec(struct timespec *ts)
17786 + struct vx_info *vxi;
17788 + if (!vx_flags(VXF_VIRT_TIME, 0))
17791 + vxi = current_vx_info();
17792 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17793 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17795 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17797 + ts->tv_nsec -= NSEC_PER_SEC;
17798 + } else if (ts->tv_nsec < 0) {
17800 + ts->tv_nsec += NSEC_PER_SEC;
17804 +int vx_settimeofday(struct timespec *ts)
17806 + struct timespec ats, delta;
17807 + struct vx_info *vxi;
17809 + if (!vx_flags(VXF_VIRT_TIME, 0))
17810 + return do_settimeofday(ts);
17812 + getnstimeofday(&ats);
17813 + delta = timespec_sub(*ts, ats);
17815 + vxi = current_vx_info();
17816 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17822 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/cvirt_init.h linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/cvirt_init.h
17823 --- linux-2.6.38.3/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17824 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/cvirt_init.h 2011-03-21 07:21:38.000000000 +0100
17828 +extern uint64_t vx_idle_jiffies(void);
17830 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17832 + uint64_t idle_jiffies = vx_idle_jiffies();
17833 + uint64_t nsuptime;
17835 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17836 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17837 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17838 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17839 + cvirt->bias_ts.tv_sec = 0;
17840 + cvirt->bias_ts.tv_nsec = 0;
17842 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17843 + atomic_set(&cvirt->nr_threads, 0);
17844 + atomic_set(&cvirt->nr_running, 0);
17845 + atomic_set(&cvirt->nr_uninterruptible, 0);
17846 + atomic_set(&cvirt->nr_onhold, 0);
17848 + spin_lock_init(&cvirt->load_lock);
17849 + cvirt->load_last = jiffies;
17850 + atomic_set(&cvirt->load_updates, 0);
17851 + cvirt->load[0] = 0;
17852 + cvirt->load[1] = 0;
17853 + cvirt->load[2] = 0;
17854 + atomic_set(&cvirt->total_forks, 0);
17856 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17857 + init_waitqueue_head(&cvirt->syslog.log_wait);
17858 + cvirt->syslog.log_start = 0;
17859 + cvirt->syslog.log_end = 0;
17860 + cvirt->syslog.con_start = 0;
17861 + cvirt->syslog.logged_chars = 0;
17865 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17867 + // cvirt_pc->cpustat = { 0 };
17870 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17872 +#ifdef CONFIG_VSERVER_WARN
17875 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17876 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17878 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17879 + "!!! cvirt: %p[nr_running] = %d on exit.",
17881 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17882 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17884 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17885 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17891 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17896 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/cvirt_proc.h linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/cvirt_proc.h
17897 --- linux-2.6.38.3/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17898 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/cvirt_proc.h 2011-01-29 02:01:07.000000000 +0100
17900 +#ifndef _VX_CVIRT_PROC_H
17901 +#define _VX_CVIRT_PROC_H
17903 +#include <linux/nsproxy.h>
17904 +#include <linux/mnt_namespace.h>
17905 +#include <linux/ipc_namespace.h>
17906 +#include <linux/utsname.h>
17907 +#include <linux/ipc.h>
17911 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17913 + struct mnt_namespace *ns;
17914 + struct uts_namespace *uts;
17915 + struct ipc_namespace *ipc;
17916 + struct path path;
17917 + char *pstr, *root;
17923 + length += sprintf(buffer + length,
17924 + "NSProxy:\t%p [%p,%p,%p]\n",
17925 + nsproxy, nsproxy->mnt_ns,
17926 + nsproxy->uts_ns, nsproxy->ipc_ns);
17928 + ns = nsproxy->mnt_ns;
17932 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17936 + path.mnt = ns->root;
17937 + path.dentry = ns->root->mnt_root;
17938 + root = d_path(&path, pstr, PATH_MAX - 2);
17939 + length += sprintf(buffer + length,
17940 + "Namespace:\t%p [#%u]\n"
17941 + "RootPath:\t%s\n",
17942 + ns, atomic_read(&ns->count),
17947 + uts = nsproxy->uts_ns;
17951 + length += sprintf(buffer + length,
17952 + "SysName:\t%.*s\n"
17953 + "NodeName:\t%.*s\n"
17954 + "Release:\t%.*s\n"
17955 + "Version:\t%.*s\n"
17956 + "Machine:\t%.*s\n"
17957 + "DomainName:\t%.*s\n",
17958 + __NEW_UTS_LEN, uts->name.sysname,
17959 + __NEW_UTS_LEN, uts->name.nodename,
17960 + __NEW_UTS_LEN, uts->name.release,
17961 + __NEW_UTS_LEN, uts->name.version,
17962 + __NEW_UTS_LEN, uts->name.machine,
17963 + __NEW_UTS_LEN, uts->name.domainname);
17966 + ipc = nsproxy->ipc_ns;
17970 + length += sprintf(buffer + length,
17971 + "SEMS:\t\t%d %d %d %d %d\n"
17972 + "MSG:\t\t%d %d %d\n"
17973 + "SHM:\t\t%lu %lu %d %d\n",
17974 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17975 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17977 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17978 + (unsigned long)ipc->shm_ctlmax,
17979 + (unsigned long)ipc->shm_ctlall,
17980 + ipc->shm_ctlmni, ipc->shm_tot);
17987 +#include <linux/sched.h>
17989 +#define LOAD_INT(x) ((x) >> FSHIFT)
17990 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17993 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17998 + length += sprintf(buffer + length,
17999 + "BiasUptime:\t%lu.%02lu\n",
18000 + (unsigned long)cvirt->bias_uptime.tv_sec,
18001 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
18003 + a = cvirt->load[0] + (FIXED_1 / 200);
18004 + b = cvirt->load[1] + (FIXED_1 / 200);
18005 + c = cvirt->load[2] + (FIXED_1 / 200);
18006 + length += sprintf(buffer + length,
18007 + "nr_threads:\t%d\n"
18008 + "nr_running:\t%d\n"
18009 + "nr_unintr:\t%d\n"
18010 + "nr_onhold:\t%d\n"
18011 + "load_updates:\t%d\n"
18012 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
18013 + "total_forks:\t%d\n",
18014 + atomic_read(&cvirt->nr_threads),
18015 + atomic_read(&cvirt->nr_running),
18016 + atomic_read(&cvirt->nr_uninterruptible),
18017 + atomic_read(&cvirt->nr_onhold),
18018 + atomic_read(&cvirt->load_updates),
18019 + LOAD_INT(a), LOAD_FRAC(a),
18020 + LOAD_INT(b), LOAD_FRAC(b),
18021 + LOAD_INT(c), LOAD_FRAC(c),
18022 + atomic_read(&cvirt->total_forks));
18027 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
18028 + char *buffer, int cpu)
18034 +#endif /* _VX_CVIRT_PROC_H */
18035 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/debug.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/debug.c
18036 --- linux-2.6.38.3/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
18037 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/debug.c 2011-01-29 02:01:07.000000000 +0100
18040 + * kernel/vserver/debug.c
18042 + * Copyright (C) 2005-2007 Herbert Pötzl
18044 + * V0.01 vx_info dump support
18048 +#include <linux/module.h>
18050 +#include <linux/vserver/context.h>
18053 +void dump_vx_info(struct vx_info *vxi, int level)
18055 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
18056 + atomic_read(&vxi->vx_usecnt),
18057 + atomic_read(&vxi->vx_tasks),
18060 + __dump_vx_limit(&vxi->limit);
18061 + __dump_vx_sched(&vxi->sched);
18062 + __dump_vx_cvirt(&vxi->cvirt);
18063 + __dump_vx_cacct(&vxi->cacct);
18069 +EXPORT_SYMBOL_GPL(dump_vx_info);
18071 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/device.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/device.c
18072 --- linux-2.6.38.3/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
18073 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/device.c 2011-01-29 02:01:07.000000000 +0100
18076 + * linux/kernel/vserver/device.c
18078 + * Linux-VServer: Device Support
18080 + * Copyright (C) 2006 Herbert Pötzl
18081 + * Copyright (C) 2007 Daniel Hokka Zakrisson
18083 + * V0.01 device mapping basics
18084 + * V0.02 added defaults
18088 +#include <linux/slab.h>
18089 +#include <linux/rcupdate.h>
18090 +#include <linux/fs.h>
18091 +#include <linux/namei.h>
18092 +#include <linux/hash.h>
18094 +#include <asm/errno.h>
18095 +#include <asm/uaccess.h>
18096 +#include <linux/vserver/base.h>
18097 +#include <linux/vserver/debug.h>
18098 +#include <linux/vserver/context.h>
18099 +#include <linux/vserver/device.h>
18100 +#include <linux/vserver/device_cmd.h>
18103 +#define DMAP_HASH_BITS 4
18106 +struct vs_mapping {
18108 + struct hlist_node hlist;
18109 + struct list_head list;
18111 +#define dm_hlist u.hlist
18112 +#define dm_list u.list
18115 + struct vx_dmap_target target;
18119 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
18121 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
18123 +static struct vx_dmap_target dmap_defaults[2] = {
18124 + { .flags = DATTR_OPEN },
18125 + { .flags = DATTR_OPEN },
18129 +struct kmem_cache *dmap_cachep __read_mostly;
18131 +int __init dmap_cache_init(void)
18133 + dmap_cachep = kmem_cache_create("dmap_cache",
18134 + sizeof(struct vs_mapping), 0,
18135 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
18139 +__initcall(dmap_cache_init);
18142 +static inline unsigned int __hashval(dev_t dev, int bits)
18144 + return hash_long((unsigned long)dev, bits);
18148 +/* __hash_mapping()
18149 + * add the mapping to the hash table
18151 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
18153 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18154 + struct hlist_head *head, *hash = dmap_main_hash;
18155 + int device = vdm->device;
18157 + spin_lock(hash_lock);
18158 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
18159 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
18161 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
18162 + hlist_add_head(&vdm->dm_hlist, head);
18163 + spin_unlock(hash_lock);
18167 +static inline int __mode_to_default(umode_t mode)
18180 +/* __set_default()
18183 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
18184 + struct vx_dmap_target *vdmt)
18186 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18187 + spin_lock(hash_lock);
18190 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
18192 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
18195 + spin_unlock(hash_lock);
18197 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
18198 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
18202 +/* __remove_default()
18203 + * remove a default
18205 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
18207 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18208 + spin_lock(hash_lock);
18211 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
18212 + else /* remove == reset */
18213 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
18215 + spin_unlock(hash_lock);
18220 +/* __find_mapping()
18221 + * find a mapping in the hash table
18223 + * caller must hold hash_lock
18225 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
18226 + struct vs_mapping **local, struct vs_mapping **global)
18228 + struct hlist_head *hash = dmap_main_hash;
18229 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
18230 + struct hlist_node *pos;
18231 + struct vs_mapping *vdm;
18237 + hlist_for_each(pos, head) {
18238 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
18240 + if ((vdm->device == device) &&
18241 + !((vdm->target.flags ^ mode) & S_IFMT)) {
18242 + if (vdm->xid == xid) {
18245 + } else if (global && vdm->xid == 0)
18250 + if (global && *global)
18257 +/* __lookup_mapping()
18258 + * find a mapping and store the result in target and flags
18260 +static inline int __lookup_mapping(struct vx_info *vxi,
18261 + dev_t device, dev_t *target, int *flags, umode_t mode)
18263 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18264 + struct vs_mapping *vdm, *global;
18265 + struct vx_dmap_target *vdmt;
18267 + xid_t xid = vxi->vx_id;
18270 + spin_lock(hash_lock);
18271 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
18273 + vdmt = &vdm->target;
18277 + index = __mode_to_default(mode);
18278 + if (vxi && vxi->dmap.targets[index].flags) {
18280 + vdmt = &vxi->dmap.targets[index];
18281 + } else if (global) {
18283 + vdmt = &global->target;
18287 + vdmt = &dmap_defaults[index];
18291 + if (target && (vdmt->flags & DATTR_REMAP))
18292 + *target = vdmt->target;
18294 + *target = device;
18296 + *flags = vdmt->flags;
18298 + spin_unlock(hash_lock);
18304 +/* __remove_mapping()
18305 + * remove a mapping from the hash table
18307 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
18310 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18311 + struct vs_mapping *vdm = NULL;
18314 + spin_lock(hash_lock);
18316 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
18318 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18319 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18322 + hlist_del(&vdm->dm_hlist);
18325 + spin_unlock(hash_lock);
18327 + kmem_cache_free(dmap_cachep, vdm);
18333 +int vs_map_device(struct vx_info *vxi,
18334 + dev_t device, dev_t *target, umode_t mode)
18336 + int ret, flags = DATTR_MASK;
18340 + *target = device;
18343 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18344 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18345 + device, target ? *target : 0, flags, mode, ret);
18347 + return (flags & DATTR_MASK);
18352 +static int do_set_mapping(struct vx_info *vxi,
18353 + dev_t device, dev_t target, int flags, umode_t mode)
18356 + struct vs_mapping *new;
18358 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18362 + INIT_HLIST_NODE(&new->dm_hlist);
18363 + new->device = device;
18364 + new->target.target = target;
18365 + new->target.flags = flags | mode;
18366 + new->xid = (vxi ? vxi->vx_id : 0);
18368 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18369 + __hash_mapping(vxi, new);
18371 + struct vx_dmap_target new = {
18372 + .target = target,
18373 + .flags = flags | mode,
18375 + __set_default(vxi, mode, &new);
18381 +static int do_unset_mapping(struct vx_info *vxi,
18382 + dev_t device, dev_t target, int flags, umode_t mode)
18384 + int ret = -EINVAL;
18387 + ret = __remove_mapping(vxi, device, mode);
18391 + ret = __remove_default(vxi, mode);
18401 +static inline int __user_device(const char __user *name, dev_t *dev,
18404 + struct nameidata nd;
18411 + ret = user_lpath(name, &nd.path);
18414 + if (nd.path.dentry->d_inode) {
18415 + *dev = nd.path.dentry->d_inode->i_rdev;
18416 + *mode = nd.path.dentry->d_inode->i_mode;
18418 + path_put(&nd.path);
18422 +static inline int __mapping_mode(dev_t device, dev_t target,
18423 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18426 + *mode = device_mode & S_IFMT;
18428 + *mode = target_mode & S_IFMT;
18432 + /* if both given, device and target mode have to match */
18433 + if (device && target &&
18434 + ((device_mode ^ target_mode) & S_IFMT))
18440 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18441 + const char __user *target_path, int flags, int set)
18443 + dev_t device = ~0, target = ~0;
18444 + umode_t device_mode = 0, target_mode = 0, mode;
18447 + ret = __user_device(device_path, &device, &device_mode);
18450 + ret = __user_device(target_path, &target, &target_mode);
18454 + ret = __mapping_mode(device, target,
18455 + device_mode, target_mode, &mode);
18460 + return do_set_mapping(vxi, device, target,
18463 + return do_unset_mapping(vxi, device, target,
18468 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
18470 + struct vcmd_set_mapping_v0 vc_data;
18472 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18475 + return do_mapping(vxi, vc_data.device, vc_data.target,
18476 + vc_data.flags, 1);
18479 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
18481 + struct vcmd_set_mapping_v0 vc_data;
18483 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18486 + return do_mapping(vxi, vc_data.device, vc_data.target,
18487 + vc_data.flags, 0);
18491 +#ifdef CONFIG_COMPAT
18493 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
18495 + struct vcmd_set_mapping_v0_x32 vc_data;
18497 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18500 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18501 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
18504 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18506 + struct vcmd_set_mapping_v0_x32 vc_data;
18508 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18511 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18512 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18515 +#endif /* CONFIG_COMPAT */
18518 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/dlimit.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/dlimit.c
18519 --- linux-2.6.38.3/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
18520 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/dlimit.c 2011-01-29 02:01:07.000000000 +0100
18523 + * linux/kernel/vserver/dlimit.c
18525 + * Virtual Server: Context Disk Limits
18527 + * Copyright (C) 2004-2009 Herbert Pötzl
18529 + * V0.01 initial version
18530 + * V0.02 compat32 splitup
18531 + * V0.03 extended interface
18535 +#include <linux/statfs.h>
18536 +#include <linux/sched.h>
18537 +#include <linux/namei.h>
18538 +#include <linux/vs_tag.h>
18539 +#include <linux/vs_dlimit.h>
18540 +#include <linux/vserver/dlimit_cmd.h>
18541 +#include <linux/slab.h>
18542 +// #include <linux/gfp.h>
18544 +#include <asm/uaccess.h>
18546 +/* __alloc_dl_info()
18548 + * allocate an initialized dl_info struct
18549 + * doesn't make it visible (hash) */
18551 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18553 + struct dl_info *new = NULL;
18555 + vxdprintk(VXD_CBIT(dlim, 5),
18556 + "alloc_dl_info(%p,%d)*", sb, tag);
18558 + /* would this benefit from a slab cache? */
18559 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18563 + memset(new, 0, sizeof(struct dl_info));
18564 + new->dl_tag = tag;
18566 + // INIT_RCU_HEAD(&new->dl_rcu);
18567 + INIT_HLIST_NODE(&new->dl_hlist);
18568 + spin_lock_init(&new->dl_lock);
18569 + atomic_set(&new->dl_refcnt, 0);
18570 + atomic_set(&new->dl_usecnt, 0);
18572 + /* rest of init goes here */
18574 + vxdprintk(VXD_CBIT(dlim, 4),
18575 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18579 +/* __dealloc_dl_info()
18581 + * final disposal of dl_info */
18583 +static void __dealloc_dl_info(struct dl_info *dli)
18585 + vxdprintk(VXD_CBIT(dlim, 4),
18586 + "dealloc_dl_info(%p)", dli);
18588 + dli->dl_hlist.next = LIST_POISON1;
18589 + dli->dl_tag = -1;
18592 + BUG_ON(atomic_read(&dli->dl_usecnt));
18593 + BUG_ON(atomic_read(&dli->dl_refcnt));
18599 +/* hash table for dl_info hash */
18601 +#define DL_HASH_SIZE 13
18603 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18605 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
18608 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18610 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18615 +/* __hash_dl_info()
18617 + * add the dli to the global hash table
18618 + * requires the hash_lock to be held */
18620 +static inline void __hash_dl_info(struct dl_info *dli)
18622 + struct hlist_head *head;
18624 + vxdprintk(VXD_CBIT(dlim, 6),
18625 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18626 + get_dl_info(dli);
18627 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18628 + hlist_add_head_rcu(&dli->dl_hlist, head);
18631 +/* __unhash_dl_info()
18633 + * remove the dli from the global hash table
18634 + * requires the hash_lock to be held */
18636 +static inline void __unhash_dl_info(struct dl_info *dli)
18638 + vxdprintk(VXD_CBIT(dlim, 6),
18639 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18640 + hlist_del_rcu(&dli->dl_hlist);
18641 + put_dl_info(dli);
18645 +/* __lookup_dl_info()
18647 + * requires the rcu_read_lock()
18648 + * doesn't increment the dl_refcnt */
18650 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18652 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18653 + struct hlist_node *pos;
18654 + struct dl_info *dli;
18656 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18658 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18666 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18668 + struct dl_info *dli;
18671 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18672 + vxdprintk(VXD_CBIT(dlim, 7),
18673 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18674 + rcu_read_unlock();
18678 +void rcu_free_dl_info(struct rcu_head *head)
18680 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18681 + int usecnt, refcnt;
18683 + BUG_ON(!dli || !head);
18685 + usecnt = atomic_read(&dli->dl_usecnt);
18686 + BUG_ON(usecnt < 0);
18688 + refcnt = atomic_read(&dli->dl_refcnt);
18689 + BUG_ON(refcnt < 0);
18691 + vxdprintk(VXD_CBIT(dlim, 3),
18692 + "rcu_free_dl_info(%p)", dli);
18694 + __dealloc_dl_info(dli);
18696 + printk("!!! rcu didn't free\n");
18702 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18703 + uint32_t flags, int add)
18705 + struct path path;
18708 + ret = user_lpath(name, &path);
18710 + struct super_block *sb;
18711 + struct dl_info *dli;
18714 + if (!path.dentry->d_inode)
18715 + goto out_release;
18716 + if (!(sb = path.dentry->d_inode->i_sb))
18717 + goto out_release;
18720 + dli = __alloc_dl_info(sb, id);
18721 + spin_lock(&dl_info_hash_lock);
18724 + if (__lookup_dl_info(sb, id))
18726 + __hash_dl_info(dli);
18729 + spin_lock(&dl_info_hash_lock);
18730 + dli = __lookup_dl_info(sb, id);
18735 + __unhash_dl_info(dli);
18739 + spin_unlock(&dl_info_hash_lock);
18741 + __dealloc_dl_info(dli);
18748 +int vc_add_dlimit(uint32_t id, void __user *data)
18750 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18752 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18755 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18758 +int vc_rem_dlimit(uint32_t id, void __user *data)
18760 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18762 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18765 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18768 +#ifdef CONFIG_COMPAT
18770 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18772 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18774 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18777 + return do_addrem_dlimit(id,
18778 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18781 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18783 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18785 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18788 + return do_addrem_dlimit(id,
18789 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18792 +#endif /* CONFIG_COMPAT */
18796 +int do_set_dlimit(uint32_t id, const char __user *name,
18797 + uint32_t space_used, uint32_t space_total,
18798 + uint32_t inodes_used, uint32_t inodes_total,
18799 + uint32_t reserved, uint32_t flags)
18801 + struct path path;
18804 + ret = user_lpath(name, &path);
18806 + struct super_block *sb;
18807 + struct dl_info *dli;
18810 + if (!path.dentry->d_inode)
18811 + goto out_release;
18812 + if (!(sb = path.dentry->d_inode->i_sb))
18813 + goto out_release;
18815 + /* sanity checks */
18816 + if ((reserved != CDLIM_KEEP &&
18817 + reserved > 100) ||
18818 + (inodes_used != CDLIM_KEEP &&
18819 + inodes_used > inodes_total) ||
18820 + (space_used != CDLIM_KEEP &&
18821 + space_used > space_total))
18822 + goto out_release;
18825 + dli = locate_dl_info(sb, id);
18827 + goto out_release;
18829 + spin_lock(&dli->dl_lock);
18831 + if (inodes_used != CDLIM_KEEP)
18832 + dli->dl_inodes_used = inodes_used;
18833 + if (inodes_total != CDLIM_KEEP)
18834 + dli->dl_inodes_total = inodes_total;
18835 + if (space_used != CDLIM_KEEP)
18836 + dli->dl_space_used = dlimit_space_32to64(
18837 + space_used, flags, DLIMS_USED);
18839 + if (space_total == CDLIM_INFINITY)
18840 + dli->dl_space_total = DLIM_INFINITY;
18841 + else if (space_total != CDLIM_KEEP)
18842 + dli->dl_space_total = dlimit_space_32to64(
18843 + space_total, flags, DLIMS_TOTAL);
18845 + if (reserved != CDLIM_KEEP)
18846 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18848 + spin_unlock(&dli->dl_lock);
18850 + put_dl_info(dli);
18859 +int vc_set_dlimit(uint32_t id, void __user *data)
18861 + struct vcmd_ctx_dlimit_v0 vc_data;
18863 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18866 + return do_set_dlimit(id, vc_data.name,
18867 + vc_data.space_used, vc_data.space_total,
18868 + vc_data.inodes_used, vc_data.inodes_total,
18869 + vc_data.reserved, vc_data.flags);
18872 +#ifdef CONFIG_COMPAT
18874 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18876 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18878 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18881 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18882 + vc_data.space_used, vc_data.space_total,
18883 + vc_data.inodes_used, vc_data.inodes_total,
18884 + vc_data.reserved, vc_data.flags);
18887 +#endif /* CONFIG_COMPAT */
18891 +int do_get_dlimit(uint32_t id, const char __user *name,
18892 + uint32_t *space_used, uint32_t *space_total,
18893 + uint32_t *inodes_used, uint32_t *inodes_total,
18894 + uint32_t *reserved, uint32_t *flags)
18896 + struct path path;
18899 + ret = user_lpath(name, &path);
18901 + struct super_block *sb;
18902 + struct dl_info *dli;
18905 + if (!path.dentry->d_inode)
18906 + goto out_release;
18907 + if (!(sb = path.dentry->d_inode->i_sb))
18908 + goto out_release;
18911 + dli = locate_dl_info(sb, id);
18913 + goto out_release;
18915 + spin_lock(&dli->dl_lock);
18916 + *inodes_used = dli->dl_inodes_used;
18917 + *inodes_total = dli->dl_inodes_total;
18919 + *space_used = dlimit_space_64to32(
18920 + dli->dl_space_used, flags, DLIMS_USED);
18922 + if (dli->dl_space_total == DLIM_INFINITY)
18923 + *space_total = CDLIM_INFINITY;
18925 + *space_total = dlimit_space_64to32(
18926 + dli->dl_space_total, flags, DLIMS_TOTAL);
18928 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18929 + spin_unlock(&dli->dl_lock);
18931 + put_dl_info(dli);
18942 +int vc_get_dlimit(uint32_t id, void __user *data)
18944 + struct vcmd_ctx_dlimit_v0 vc_data;
18947 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18950 + ret = do_get_dlimit(id, vc_data.name,
18951 + &vc_data.space_used, &vc_data.space_total,
18952 + &vc_data.inodes_used, &vc_data.inodes_total,
18953 + &vc_data.reserved, &vc_data.flags);
18957 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18962 +#ifdef CONFIG_COMPAT
18964 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18966 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18969 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18972 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18973 + &vc_data.space_used, &vc_data.space_total,
18974 + &vc_data.inodes_used, &vc_data.inodes_total,
18975 + &vc_data.reserved, &vc_data.flags);
18979 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18984 +#endif /* CONFIG_COMPAT */
18987 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18989 + struct dl_info *dli;
18990 + __u64 blimit, bfree, bavail;
18993 + dli = locate_dl_info(sb, dx_current_tag());
18997 + spin_lock(&dli->dl_lock);
18998 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
19001 + /* reduce max inodes available to limit */
19002 + if (buf->f_files > dli->dl_inodes_total)
19003 + buf->f_files = dli->dl_inodes_total;
19005 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
19006 + /* reduce free inodes to min */
19007 + if (ifree < buf->f_ffree)
19008 + buf->f_ffree = ifree;
19011 + if (dli->dl_space_total == DLIM_INFINITY)
19014 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
19016 + if (dli->dl_space_total < dli->dl_space_used)
19019 + bfree = (dli->dl_space_total - dli->dl_space_used)
19020 + >> sb->s_blocksize_bits;
19022 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
19023 + if (bavail < dli->dl_space_used)
19026 + bavail = (bavail - dli->dl_space_used)
19027 + >> sb->s_blocksize_bits;
19029 + /* reduce max space available to limit */
19030 + if (buf->f_blocks > blimit)
19031 + buf->f_blocks = blimit;
19033 + /* reduce free space to min */
19034 + if (bfree < buf->f_bfree)
19035 + buf->f_bfree = bfree;
19037 + /* reduce avail space to min */
19038 + if (bavail < buf->f_bavail)
19039 + buf->f_bavail = bavail;
19042 + spin_unlock(&dli->dl_lock);
19043 + put_dl_info(dli);
19048 +#include <linux/module.h>
19050 +EXPORT_SYMBOL_GPL(locate_dl_info);
19051 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
19053 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/helper.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/helper.c
19054 --- linux-2.6.38.3/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
19055 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/helper.c 2011-01-29 02:01:07.000000000 +0100
19058 + * linux/kernel/vserver/helper.c
19060 + * Virtual Context Support
19062 + * Copyright (C) 2004-2007 Herbert Pötzl
19064 + * V0.01 basic helper
19068 +#include <linux/kmod.h>
19069 +#include <linux/reboot.h>
19070 +#include <linux/vs_context.h>
19071 +#include <linux/vs_network.h>
19072 +#include <linux/vserver/signal.h>
19075 +char vshelper_path[255] = "/sbin/vshelper";
19078 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
19082 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
19083 + printk( KERN_WARNING
19084 + "%s: (%s %s) returned %s with %d\n",
19085 + name, argv[1], argv[2],
19086 + sync ? "sync" : "async", ret);
19088 + vxdprintk(VXD_CBIT(switch, 4),
19089 + "%s: (%s %s) returned %s with %d",
19090 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
19095 + * vshelper path is set via /proc/sys
19096 + * invoked by vserver sys_reboot(), with
19097 + * the following arguments
19099 + * argv [0] = vshelper_path;
19100 + * argv [1] = action: "restart", "halt", "poweroff", ...
19101 + * argv [2] = context identifier
19103 + * envp [*] = type-specific parameters
19106 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
19108 + char id_buf[8], cmd_buf[16];
19109 + char uid_buf[16], pid_buf[16];
19112 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19113 + char *envp[] = {"HOME=/", "TERM=linux",
19114 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
19115 + uid_buf, pid_buf, cmd_buf, 0};
19117 + if (vx_info_state(vxi, VXS_HELPER))
19119 + vxi->vx_state |= VXS_HELPER;
19121 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19123 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19124 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
19125 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
19128 + case LINUX_REBOOT_CMD_RESTART:
19129 + argv[1] = "restart";
19132 + case LINUX_REBOOT_CMD_HALT:
19133 + argv[1] = "halt";
19136 + case LINUX_REBOOT_CMD_POWER_OFF:
19137 + argv[1] = "poweroff";
19140 + case LINUX_REBOOT_CMD_SW_SUSPEND:
19141 + argv[1] = "swsusp";
19144 + case LINUX_REBOOT_CMD_OOM:
19149 + vxi->vx_state &= ~VXS_HELPER;
19153 + ret = do_vshelper(vshelper_path, argv, envp, 0);
19154 + vxi->vx_state &= ~VXS_HELPER;
19155 + __wakeup_vx_info(vxi);
19156 + return (ret) ? -EPERM : 0;
19160 +long vs_reboot(unsigned int cmd, void __user *arg)
19162 + struct vx_info *vxi = current_vx_info();
19165 + vxdprintk(VXD_CBIT(misc, 5),
19166 + "vs_reboot(%p[#%d],%u)",
19167 + vxi, vxi ? vxi->vx_id : 0, cmd);
19169 + ret = vs_reboot_helper(vxi, cmd, arg);
19173 + vxi->reboot_cmd = cmd;
19174 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19176 + case LINUX_REBOOT_CMD_RESTART:
19177 + case LINUX_REBOOT_CMD_HALT:
19178 + case LINUX_REBOOT_CMD_POWER_OFF:
19179 + vx_info_kill(vxi, 0, SIGKILL);
19180 + vx_info_kill(vxi, 1, SIGKILL);
19188 +long vs_oom_action(unsigned int cmd)
19190 + struct vx_info *vxi = current_vx_info();
19193 + vxdprintk(VXD_CBIT(misc, 5),
19194 + "vs_oom_action(%p[#%d],%u)",
19195 + vxi, vxi ? vxi->vx_id : 0, cmd);
19197 + ret = vs_reboot_helper(vxi, cmd, NULL);
19201 + vxi->reboot_cmd = cmd;
19202 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19203 + vx_info_kill(vxi, 0, SIGKILL);
19204 + vx_info_kill(vxi, 1, SIGKILL);
19210 + * argv [0] = vshelper_path;
19211 + * argv [1] = action: "startup", "shutdown"
19212 + * argv [2] = context identifier
19214 + * envp [*] = type-specific parameters
19217 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
19219 + char id_buf[8], cmd_buf[16];
19220 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19221 + char *envp[] = {"HOME=/", "TERM=linux",
19222 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19224 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
19227 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19228 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19231 + case VSC_STARTUP:
19232 + argv[1] = "startup";
19234 + case VSC_SHUTDOWN:
19235 + argv[1] = "shutdown";
19241 + return do_vshelper(vshelper_path, argv, envp, 1);
19246 + * argv [0] = vshelper_path;
19247 + * argv [1] = action: "netup", "netdown"
19248 + * argv [2] = context identifier
19250 + * envp [*] = type-specific parameters
19253 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
19255 + char id_buf[8], cmd_buf[16];
19256 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19257 + char *envp[] = {"HOME=/", "TERM=linux",
19258 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19260 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
19263 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
19264 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19268 + argv[1] = "netup";
19270 + case VSC_NETDOWN:
19271 + argv[1] = "netdown";
19277 + return do_vshelper(vshelper_path, argv, envp, 1);
19280 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/history.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/history.c
19281 --- linux-2.6.38.3/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
19282 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/history.c 2011-01-29 02:01:07.000000000 +0100
19285 + * kernel/vserver/history.c
19287 + * Virtual Context History Backtrace
19289 + * Copyright (C) 2004-2007 Herbert Pötzl
19291 + * V0.01 basic structure
19292 + * V0.02 hash/unhash and trace
19293 + * V0.03 preemption fixes
19297 +#include <linux/module.h>
19298 +#include <asm/uaccess.h>
19300 +#include <linux/vserver/context.h>
19301 +#include <linux/vserver/debug.h>
19302 +#include <linux/vserver/debug_cmd.h>
19303 +#include <linux/vserver/history.h>
19306 +#ifdef CONFIG_VSERVER_HISTORY
19307 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
19309 +#define VXH_SIZE 64
19312 +struct _vx_history {
19313 + unsigned int counter;
19315 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19319 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19321 +unsigned volatile int vxh_active = 1;
19323 +static atomic_t sequence = ATOMIC_INIT(0);
19328 + * requires disabled preemption */
19330 +struct _vx_hist_entry *vxh_advance(void *loc)
19332 + unsigned int cpu = smp_processor_id();
19333 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19334 + struct _vx_hist_entry *entry;
19335 + unsigned int index;
19337 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19338 + entry = &hist->entry[index];
19340 + entry->seq = atomic_inc_return(&sequence);
19341 + entry->loc = loc;
19345 +EXPORT_SYMBOL_GPL(vxh_advance);
19348 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19350 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19353 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19355 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19356 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19357 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19358 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19360 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19362 + switch (e->type) {
19363 + case VXH_THROW_OOPS:
19364 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19367 + case VXH_GET_VX_INFO:
19368 + case VXH_PUT_VX_INFO:
19369 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19371 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19372 + VXH_VXI_ARGS(e));
19375 + case VXH_INIT_VX_INFO:
19376 + case VXH_SET_VX_INFO:
19377 + case VXH_CLR_VX_INFO:
19378 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19380 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19381 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19382 + VXH_VXI_ARGS(e), e->sc.data);
19385 + case VXH_CLAIM_VX_INFO:
19386 + case VXH_RELEASE_VX_INFO:
19387 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19389 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19390 + VXH_VXI_ARGS(e), e->sc.data);
19393 + case VXH_ALLOC_VX_INFO:
19394 + case VXH_DEALLOC_VX_INFO:
19395 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19397 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19398 + VXH_VXI_ARGS(e));
19401 + case VXH_HASH_VX_INFO:
19402 + case VXH_UNHASH_VX_INFO:
19403 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19405 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19406 + VXH_VXI_ARGS(e));
19409 + case VXH_LOC_VX_INFO:
19410 + case VXH_LOOKUP_VX_INFO:
19411 + case VXH_CREATE_VX_INFO:
19412 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19414 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19415 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19416 + e->ll.arg, VXH_VXI_ARGS(e));
19421 +static void __vxh_dump_history(void)
19423 + unsigned int i, cpu;
19425 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19426 + atomic_read(&sequence), NR_CPUS);
19428 + for (i = 0; i < VXH_SIZE; i++) {
19429 + for_each_online_cpu(cpu) {
19430 + struct _vx_history *hist =
19431 + &per_cpu(vx_history_buffer, cpu);
19432 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19433 + struct _vx_hist_entry *entry = &hist->entry[index];
19435 + vxh_dump_entry(entry, cpu);
19440 +void vxh_dump_history(void)
19444 + local_irq_enable();
19446 + local_irq_disable();
19448 + __vxh_dump_history();
19452 +/* vserver syscall commands below here */
19455 +int vc_dump_history(uint32_t id)
19458 + __vxh_dump_history();
19465 +int do_read_history(struct __user _vx_hist_entry *data,
19466 + int cpu, uint32_t *index, uint32_t *count)
19468 + int pos, ret = 0;
19469 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19470 + int end = hist->counter;
19471 + int start = end - VXH_SIZE + 2;
19472 + int idx = *index;
19474 + /* special case: get current pos */
19480 + /* have we lost some data? */
19484 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
19485 + struct _vx_hist_entry *entry =
19486 + &hist->entry[idx % VXH_SIZE];
19488 + /* send entry to userspace */
19489 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
19493 + /* save new index and count */
19496 + return ret ? ret : (*index < end);
19499 +int vc_read_history(uint32_t id, void __user *data)
19501 + struct vcmd_read_history_v0 vc_data;
19504 + if (id >= NR_CPUS)
19507 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19510 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19511 + id, &vc_data.index, &vc_data.count);
19513 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19518 +#ifdef CONFIG_COMPAT
19520 +int vc_read_history_x32(uint32_t id, void __user *data)
19522 + struct vcmd_read_history_v0_x32 vc_data;
19525 + if (id >= NR_CPUS)
19528 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19531 + ret = do_read_history((struct __user _vx_hist_entry *)
19532 + compat_ptr(vc_data.data_ptr),
19533 + id, &vc_data.index, &vc_data.count);
19535 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19540 +#endif /* CONFIG_COMPAT */
19542 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/inet.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/inet.c
19543 --- linux-2.6.38.3/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19544 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/inet.c 2011-01-29 02:01:07.000000000 +0100
19547 +#include <linux/in.h>
19548 +#include <linux/inetdevice.h>
19549 +#include <linux/vs_inet.h>
19550 +#include <linux/vs_inet6.h>
19551 +#include <linux/vserver/debug.h>
19552 +#include <net/route.h>
19553 +#include <net/addrconf.h>
19556 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19560 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19563 + struct nx_addr_v4 *ptr;
19565 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19566 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19573 + vxdprintk(VXD_CBIT(net, 2),
19574 + "nx_v4_addr_conflict(%p,%p): %d",
19575 + nxi1, nxi2, ret);
19581 +#ifdef CONFIG_IPV6
19583 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19587 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19590 + struct nx_addr_v6 *ptr;
19592 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19593 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19600 + vxdprintk(VXD_CBIT(net, 2),
19601 + "nx_v6_addr_conflict(%p,%p): %d",
19602 + nxi1, nxi2, ret);
19609 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19611 + struct in_device *in_dev;
19612 + struct in_ifaddr **ifap;
19613 + struct in_ifaddr *ifa;
19618 + in_dev = in_dev_get(dev);
19622 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19623 + ifap = &ifa->ifa_next) {
19624 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19629 + in_dev_put(in_dev);
19635 +#ifdef CONFIG_IPV6
19637 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19639 + struct inet6_dev *in_dev;
19640 + struct inet6_ifaddr *ifa;
19645 + in_dev = in6_dev_get(dev);
19649 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19650 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19651 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19656 + in6_dev_put(in_dev);
19663 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19669 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19671 +#ifdef CONFIG_IPV6
19673 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19678 + vxdprintk(VXD_CBIT(net, 3),
19679 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19680 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19684 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
19685 + struct rtable **rp, struct flowi *fl)
19690 + /* FIXME: handle lback only case */
19691 + if (!NX_IPV4(nxi))
19694 + vxdprintk(VXD_CBIT(net, 4),
19695 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19696 + nxi, nxi ? nxi->nx_id : 0,
19697 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
19699 + /* single IP is unconditional */
19700 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19701 + (fl->fl4_src == INADDR_ANY))
19702 + fl->fl4_src = nxi->v4.ip[0].s_addr;
19704 + if (fl->fl4_src == INADDR_ANY) {
19705 + struct nx_addr_v4 *ptr;
19706 + __be32 found = 0;
19709 + err = __ip_route_output_key(net, rp, fl);
19711 + found = (*rp)->rt_src;
19713 + vxdprintk(VXD_CBIT(net, 4),
19714 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19715 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
19716 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19720 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19721 + __be32 primary = ptr->ip[0].s_addr;
19722 + __be32 mask = ptr->mask.s_addr;
19723 + __be32 neta = primary & mask;
19725 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19726 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19727 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19728 + NIPQUAD(mask), NIPQUAD(neta));
19729 + if ((found & mask) != neta)
19732 + fl->fl4_src = primary;
19733 + err = __ip_route_output_key(net, rp, fl);
19734 + vxdprintk(VXD_CBIT(net, 4),
19735 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19736 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
19738 + found = (*rp)->rt_src;
19740 + if (found == primary)
19744 + /* still no source ip? */
19745 + found = ipv4_is_loopback(fl->fl4_dst)
19746 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19748 + /* assign src ip to flow */
19749 + fl->fl4_src = found;
19752 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
19756 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19757 + if (ipv4_is_loopback(fl->fl4_dst))
19758 + fl->fl4_dst = nxi->v4_lback.s_addr;
19759 + if (ipv4_is_loopback(fl->fl4_src))
19760 + fl->fl4_src = nxi->v4_lback.s_addr;
19761 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
19762 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19768 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19770 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/init.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/init.c
19771 --- linux-2.6.38.3/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19772 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/init.c 2011-01-29 02:01:07.000000000 +0100
19775 + * linux/kernel/init.c
19777 + * Virtual Server Init
19779 + * Copyright (C) 2004-2007 Herbert Pötzl
19781 + * V0.01 basic structure
19785 +#include <linux/init.h>
19787 +int vserver_register_sysctl(void);
19788 +void vserver_unregister_sysctl(void);
19791 +static int __init init_vserver(void)
19795 +#ifdef CONFIG_VSERVER_DEBUG
19796 + vserver_register_sysctl();
19802 +static void __exit exit_vserver(void)
19805 +#ifdef CONFIG_VSERVER_DEBUG
19806 + vserver_unregister_sysctl();
19811 +/* FIXME: GFP_ZONETYPES gone
19812 +long vx_slab[GFP_ZONETYPES]; */
19816 +module_init(init_vserver);
19817 +module_exit(exit_vserver);
19819 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/inode.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/inode.c
19820 --- linux-2.6.38.3/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19821 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/inode.c 2011-03-21 07:25:53.000000000 +0100
19824 + * linux/kernel/vserver/inode.c
19826 + * Virtual Server: File System Support
19828 + * Copyright (C) 2004-2007 Herbert Pötzl
19830 + * V0.01 separated from vcontext V0.05
19831 + * V0.02 moved to tag (instead of xid)
19835 +#include <linux/tty.h>
19836 +#include <linux/proc_fs.h>
19837 +#include <linux/devpts_fs.h>
19838 +#include <linux/fs.h>
19839 +#include <linux/file.h>
19840 +#include <linux/mount.h>
19841 +#include <linux/parser.h>
19842 +#include <linux/namei.h>
19843 +#include <linux/vserver/inode.h>
19844 +#include <linux/vserver/inode_cmd.h>
19845 +#include <linux/vs_base.h>
19846 +#include <linux/vs_tag.h>
19848 +#include <asm/uaccess.h>
19851 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19853 + struct proc_dir_entry *entry;
19855 + if (!in || !in->i_sb)
19858 + *flags = IATTR_TAG
19859 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19860 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19861 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19862 + | (IS_COW(in) ? IATTR_COW : 0);
19863 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19865 + if (S_ISDIR(in->i_mode))
19866 + *mask |= IATTR_BARRIER;
19868 + if (IS_TAGGED(in)) {
19869 + *tag = in->i_tag;
19870 + *mask |= IATTR_TAG;
19873 + switch (in->i_sb->s_magic) {
19874 + case PROC_SUPER_MAGIC:
19875 + entry = PROC_I(in)->pde;
19877 + /* check for specific inodes? */
19879 + *mask |= IATTR_FLAGS;
19881 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19883 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19886 + case DEVPTS_SUPER_MAGIC:
19887 + *tag = in->i_tag;
19888 + *mask |= IATTR_TAG;
19897 +int vc_get_iattr(void __user *data)
19899 + struct path path;
19900 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19903 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19906 + ret = user_lpath(vc_data.name, &path);
19908 + ret = __vc_get_iattr(path.dentry->d_inode,
19909 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19915 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19920 +#ifdef CONFIG_COMPAT
19922 +int vc_get_iattr_x32(void __user *data)
19924 + struct path path;
19925 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19928 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19931 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19933 + ret = __vc_get_iattr(path.dentry->d_inode,
19934 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19940 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19945 +#endif /* CONFIG_COMPAT */
19948 +int vc_fget_iattr(uint32_t fd, void __user *data)
19950 + struct file *filp;
19951 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19954 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19958 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19961 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19962 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19966 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19972 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19974 + struct inode *in = de->d_inode;
19975 + int error = 0, is_proc = 0, has_tag = 0;
19976 + struct iattr attr = { 0 };
19978 + if (!in || !in->i_sb)
19981 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19982 + if ((*mask & IATTR_FLAGS) && !is_proc)
19985 + has_tag = IS_TAGGED(in) ||
19986 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19987 + if ((*mask & IATTR_TAG) && !has_tag)
19990 + mutex_lock(&in->i_mutex);
19991 + if (*mask & IATTR_TAG) {
19992 + attr.ia_tag = *tag;
19993 + attr.ia_valid |= ATTR_TAG;
19996 + if (*mask & IATTR_FLAGS) {
19997 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19998 + unsigned int iflags = PROC_I(in)->vx_flags;
20000 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
20001 + | (*flags & IATTR_FLAGS);
20002 + PROC_I(in)->vx_flags = iflags;
20004 + entry->vx_flags = iflags;
20007 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
20008 + IATTR_BARRIER | IATTR_COW)) {
20009 + int iflags = in->i_flags;
20010 + int vflags = in->i_vflags;
20012 + if (*mask & IATTR_IMMUTABLE) {
20013 + if (*flags & IATTR_IMMUTABLE)
20014 + iflags |= S_IMMUTABLE;
20016 + iflags &= ~S_IMMUTABLE;
20018 + if (*mask & IATTR_IXUNLINK) {
20019 + if (*flags & IATTR_IXUNLINK)
20020 + iflags |= S_IXUNLINK;
20022 + iflags &= ~S_IXUNLINK;
20024 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
20025 + if (*flags & IATTR_BARRIER)
20026 + vflags |= V_BARRIER;
20028 + vflags &= ~V_BARRIER;
20030 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
20031 + if (*flags & IATTR_COW)
20034 + vflags &= ~V_COW;
20036 + if (in->i_op && in->i_op->sync_flags) {
20037 + error = in->i_op->sync_flags(in, iflags, vflags);
20043 + if (attr.ia_valid) {
20044 + if (in->i_op && in->i_op->setattr)
20045 + error = in->i_op->setattr(de, &attr);
20047 + error = inode_change_ok(in, &attr);
20049 + setattr_copy(in, &attr);
20050 + mark_inode_dirty(in);
20056 + mutex_unlock(&in->i_mutex);
20060 +int vc_set_iattr(void __user *data)
20062 + struct path path;
20063 + struct vcmd_ctx_iattr_v1 vc_data;
20066 + if (!capable(CAP_LINUX_IMMUTABLE))
20068 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20071 + ret = user_lpath(vc_data.name, &path);
20073 + ret = __vc_set_iattr(path.dentry,
20074 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20078 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20083 +#ifdef CONFIG_COMPAT
20085 +int vc_set_iattr_x32(void __user *data)
20087 + struct path path;
20088 + struct vcmd_ctx_iattr_v1_x32 vc_data;
20091 + if (!capable(CAP_LINUX_IMMUTABLE))
20093 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20096 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20098 + ret = __vc_set_iattr(path.dentry,
20099 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20103 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20108 +#endif /* CONFIG_COMPAT */
20110 +int vc_fset_iattr(uint32_t fd, void __user *data)
20112 + struct file *filp;
20113 + struct vcmd_ctx_fiattr_v0 vc_data;
20116 + if (!capable(CAP_LINUX_IMMUTABLE))
20118 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20122 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20125 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
20126 + &vc_data.flags, &vc_data.mask);
20130 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20136 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
20138 +static match_table_t tokens = {
20139 + {Opt_notagcheck, "notagcheck"},
20140 +#ifdef CONFIG_PROPAGATE
20141 + {Opt_notag, "notag"},
20142 + {Opt_tag, "tag"},
20143 + {Opt_tagid, "tagid=%u"},
20149 +static void __dx_parse_remove(char *string, char *opt)
20151 + char *p = strstr(string, opt);
20155 + while (*q != '\0' && *q != ',')
20164 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
20165 + unsigned long *flags)
20168 + substring_t args[MAX_OPT_ARGS];
20170 + char *s, *p, *opts;
20171 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_WARN)
20177 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
20182 + while ((p = strsep(&opts, ",")) != NULL) {
20183 + token = match_token(p, tokens, args);
20186 +#ifdef CONFIG_PROPAGATE
20191 + __dx_parse_remove(s, "tag");
20192 + *mnt_flags |= MNT_TAGID;
20193 + set |= MNT_TAGID;
20197 + __dx_parse_remove(s, "notag");
20198 + *mnt_flags |= MNT_NOTAG;
20199 + set |= MNT_NOTAG;
20202 + if (tag && !match_int(args, &option))
20205 + __dx_parse_remove(s, "tagid");
20206 + *mnt_flags |= MNT_TAGID;
20207 + set |= MNT_TAGID;
20210 + case Opt_notagcheck:
20212 + __dx_parse_remove(s, "notagcheck");
20213 + *flags |= MS_NOTAGCHECK;
20214 + set |= MS_NOTAGCHECK;
20217 + vxdprintk(VXD_CBIT(tag, 7),
20218 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
20219 + p, token, option);
20222 + strcpy(string, s);
20227 +#ifdef CONFIG_PROPAGATE
20229 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
20231 + tag_t new_tag = 0;
20232 + struct vfsmount *mnt;
20237 + mnt = nd->path.mnt;
20241 + propagate = (mnt->mnt_flags & MNT_TAGID);
20243 + new_tag = mnt->mnt_tag;
20245 + vxdprintk(VXD_CBIT(tag, 7),
20246 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
20247 + inode, inode->i_ino, inode->i_tag,
20248 + new_tag, (propagate) ? 1 : 0);
20251 + inode->i_tag = new_tag;
20254 +#include <linux/module.h>
20256 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
20258 +#endif /* CONFIG_PROPAGATE */
20260 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/limit.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/limit.c
20261 --- linux-2.6.38.3/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
20262 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/limit.c 2011-01-29 02:01:07.000000000 +0100
20265 + * linux/kernel/vserver/limit.c
20267 + * Virtual Server: Context Limits
20269 + * Copyright (C) 2004-2010 Herbert Pötzl
20271 + * V0.01 broken out from vcontext V0.05
20272 + * V0.02 changed vcmds to vxi arg
20273 + * V0.03 added memory cgroup support
20277 +#include <linux/sched.h>
20278 +#include <linux/module.h>
20279 +#include <linux/memcontrol.h>
20280 +#include <linux/res_counter.h>
20281 +#include <linux/vs_limit.h>
20282 +#include <linux/vserver/limit.h>
20283 +#include <linux/vserver/limit_cmd.h>
20285 +#include <asm/uaccess.h>
20288 +const char *vlimit_name[NUM_LIMITS] = {
20289 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20290 + [RLIMIT_RSS] = "RSS",
20291 + [RLIMIT_AS] = "VM",
20292 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20293 + [RLIMIT_CPU] = "CPU",
20294 + [RLIMIT_NPROC] = "NPROC",
20295 + [RLIMIT_NOFILE] = "NOFILE",
20296 + [RLIMIT_LOCKS] = "LOCKS",
20297 + [RLIMIT_SIGPENDING] = "SIGP",
20298 + [RLIMIT_MSGQUEUE] = "MSGQ",
20300 + [VLIMIT_NSOCK] = "NSOCK",
20301 + [VLIMIT_OPENFD] = "OPENFD",
20302 + [VLIMIT_SHMEM] = "SHMEM",
20303 + [VLIMIT_DENTRY] = "DENTRY",
20306 +EXPORT_SYMBOL_GPL(vlimit_name);
20308 +#define MASK_ENTRY(x) (1 << (x))
20310 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
20313 + , /* softlimit */
20314 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20315 + MASK_ENTRY( RLIMIT_RSS ) |
20316 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20319 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20320 + MASK_ENTRY( RLIMIT_RSS ) |
20321 + MASK_ENTRY( RLIMIT_AS ) |
20322 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20323 + MASK_ENTRY( RLIMIT_NPROC ) |
20324 + MASK_ENTRY( RLIMIT_NOFILE ) |
20325 + MASK_ENTRY( RLIMIT_LOCKS ) |
20326 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
20328 + MASK_ENTRY( VLIMIT_NSOCK ) |
20329 + MASK_ENTRY( VLIMIT_OPENFD ) |
20330 + MASK_ENTRY( VLIMIT_SHMEM ) |
20331 + MASK_ENTRY( VLIMIT_DENTRY ) |
20334 + /* accounting only */
20335 +uint32_t account_mask =
20336 + MASK_ENTRY( VLIMIT_SEMARY ) |
20337 + MASK_ENTRY( VLIMIT_NSEMS ) |
20338 + MASK_ENTRY( VLIMIT_MAPPED ) |
20342 +static int is_valid_vlimit(int id)
20344 + uint32_t mask = vlimit_mask.minimum |
20345 + vlimit_mask.softlimit | vlimit_mask.maximum;
20346 + return mask & (1 << id);
20349 +static int is_accounted_vlimit(int id)
20351 + if (is_valid_vlimit(id))
20353 + return account_mask & (1 << id);
20357 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
20359 + rlim_t limit = __rlim_soft(&vxi->limit, id);
20360 + return VX_VLIM(limit);
20363 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
20365 + rlim_t limit = __rlim_hard(&vxi->limit, id);
20366 + return VX_VLIM(limit);
20369 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
20370 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
20372 + if (!is_valid_vlimit(id))
20376 + *minimum = CRLIM_UNSET;
20378 + *softlimit = vc_get_soft(vxi, id);
20380 + *maximum = vc_get_hard(vxi, id);
20384 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
20386 + struct vcmd_ctx_rlimit_v0 vc_data;
20389 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20392 + ret = do_get_rlimit(vxi, vc_data.id,
20393 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20397 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20402 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
20403 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
20405 + if (!is_valid_vlimit(id))
20408 + if (maximum != CRLIM_KEEP)
20409 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
20410 + if (softlimit != CRLIM_KEEP)
20411 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
20413 + /* clamp soft limit */
20414 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
20415 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
20420 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
20422 + struct vcmd_ctx_rlimit_v0 vc_data;
20424 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20427 + return do_set_rlimit(vxi, vc_data.id,
20428 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20431 +#ifdef CONFIG_IA32_EMULATION
20433 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
20435 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20437 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20440 + return do_set_rlimit(vxi, vc_data.id,
20441 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20444 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
20446 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20449 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20452 + ret = do_get_rlimit(vxi, vc_data.id,
20453 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20457 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20462 +#endif /* CONFIG_IA32_EMULATION */
20465 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
20467 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
20473 +static inline void vx_reset_hits(struct _vx_limit *limit)
20477 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20478 + atomic_set(&__rlim_lhit(limit, lim), 0);
20482 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
20484 + vx_reset_hits(&vxi->limit);
20488 +static inline void vx_reset_minmax(struct _vx_limit *limit)
20493 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20494 + value = __rlim_get(limit, lim);
20495 + __rlim_rmax(limit, lim) = value;
20496 + __rlim_rmin(limit, lim) = value;
20500 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
20502 + vx_reset_minmax(&vxi->limit);
20507 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20509 + struct vcmd_rlimit_stat_v0 vc_data;
20510 + struct _vx_limit *limit = &vxi->limit;
20513 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20517 + if (!is_accounted_vlimit(id))
20520 + vx_limit_fixup(limit, id);
20521 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20522 + vc_data.value = __rlim_get(limit, id);
20523 + vc_data.minimum = __rlim_rmin(limit, id);
20524 + vc_data.maximum = __rlim_rmax(limit, id);
20526 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20532 +void vx_vsi_meminfo(struct sysinfo *val)
20534 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20535 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20536 + u64 res_limit, res_usage;
20541 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20542 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20544 + if (res_limit != RESOURCE_MAX)
20545 + val->totalram = (res_limit >> PAGE_SHIFT);
20546 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
20547 + val->bufferram = 0;
20548 + val->totalhigh = 0;
20549 + val->freehigh = 0;
20550 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20554 +void vx_vsi_swapinfo(struct sysinfo *val)
20556 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20557 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20558 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20559 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20560 + s64 swap_limit, swap_usage;
20565 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20566 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20567 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20568 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20570 + if (res_limit == RESOURCE_MAX)
20573 + swap_limit = memsw_limit - res_limit;
20574 + if (memsw_limit != RESOURCE_MAX)
20575 + val->totalswap = swap_limit >> PAGE_SHIFT;
20577 + swap_usage = memsw_usage - res_usage;
20578 + val->freeswap = (swap_usage < swap_limit) ?
20579 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20580 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20581 + val->totalswap = 0;
20582 + val->freeswap = 0;
20583 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20584 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20588 +long vx_vsi_cached(struct sysinfo *val)
20590 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20591 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20593 + return mem_cgroup_stat_read_cache(mcg);
20600 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
20602 + struct vx_info *vxi = mm->mm_vx_info;
20603 + unsigned long points;
20609 + points = vxi->vx_badness_bias;
20611 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20612 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20613 + points += (v > w) ? (v - w) : 0;
20618 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/limit_init.h linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/limit_init.h
20619 --- linux-2.6.38.3/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20620 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/limit_init.h 2011-01-29 02:01:07.000000000 +0100
20624 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20628 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20629 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20630 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20631 + __rlim_set(limit, lim, 0);
20632 + atomic_set(&__rlim_lhit(limit, lim), 0);
20633 + __rlim_rmin(limit, lim) = 0;
20634 + __rlim_rmax(limit, lim) = 0;
20638 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20643 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20644 + if ((1 << lim) & VLIM_NOCHECK)
20646 + value = __rlim_get(limit, lim);
20647 + vxwprintk_xid(value,
20648 + "!!! limit: %p[%s,%d] = %ld on exit.",
20649 + limit, vlimit_name[lim], lim, (long)value);
20653 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/limit_proc.h linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/limit_proc.h
20654 --- linux-2.6.38.3/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20655 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/limit_proc.h 2011-01-29 02:01:07.000000000 +0100
20657 +#ifndef _VX_LIMIT_PROC_H
20658 +#define _VX_LIMIT_PROC_H
20660 +#include <linux/vserver/limit_int.h>
20663 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20664 +#define VX_LIMIT_TOP \
20665 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20667 +#define VX_LIMIT_ARG(r) \
20668 + (unsigned long)__rlim_get(limit, r), \
20669 + (unsigned long)__rlim_rmin(limit, r), \
20670 + (unsigned long)__rlim_rmax(limit, r), \
20671 + VX_VLIM(__rlim_soft(limit, r)), \
20672 + VX_VLIM(__rlim_hard(limit, r)), \
20673 + atomic_read(&__rlim_lhit(limit, r))
20675 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20677 + vx_limit_fixup(limit, -1);
20678 + return sprintf(buffer, VX_LIMIT_TOP
20679 + "PROC" VX_LIMIT_FMT
20680 + "VM" VX_LIMIT_FMT
20681 + "VML" VX_LIMIT_FMT
20682 + "RSS" VX_LIMIT_FMT
20683 + "ANON" VX_LIMIT_FMT
20684 + "RMAP" VX_LIMIT_FMT
20685 + "FILES" VX_LIMIT_FMT
20686 + "OFD" VX_LIMIT_FMT
20687 + "LOCKS" VX_LIMIT_FMT
20688 + "SOCK" VX_LIMIT_FMT
20689 + "MSGQ" VX_LIMIT_FMT
20690 + "SHM" VX_LIMIT_FMT
20691 + "SEMA" VX_LIMIT_FMT
20692 + "SEMS" VX_LIMIT_FMT
20693 + "DENT" VX_LIMIT_FMT,
20694 + VX_LIMIT_ARG(RLIMIT_NPROC),
20695 + VX_LIMIT_ARG(RLIMIT_AS),
20696 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20697 + VX_LIMIT_ARG(RLIMIT_RSS),
20698 + VX_LIMIT_ARG(VLIMIT_ANON),
20699 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20700 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20701 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20702 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20703 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20704 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20705 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20706 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20707 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20708 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20711 +#endif /* _VX_LIMIT_PROC_H */
20714 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/network.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/network.c
20715 --- linux-2.6.38.3/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20716 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/network.c 2011-04-15 16:07:48.000000000 +0200
20719 + * linux/kernel/vserver/network.c
20721 + * Virtual Server: Network Support
20723 + * Copyright (C) 2003-2007 Herbert Pötzl
20725 + * V0.01 broken out from vcontext V0.05
20726 + * V0.02 cleaned up implementation
20727 + * V0.03 added equiv nx commands
20728 + * V0.04 switch to RCU based hash
20729 + * V0.05 and back to locking again
20730 + * V0.06 changed vcmds to nxi arg
20731 + * V0.07 have __create claim() the nxi
20735 +#include <linux/err.h>
20736 +#include <linux/slab.h>
20737 +#include <linux/rcupdate.h>
20739 +#include <linux/vs_network.h>
20740 +#include <linux/vs_pid.h>
20741 +#include <linux/vserver/network_cmd.h>
20744 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20745 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20747 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20748 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20751 +static int __init init_network(void)
20753 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20754 + sizeof(struct nx_addr_v4), 0,
20755 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20756 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20757 + sizeof(struct nx_addr_v6), 0,
20758 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20763 +/* __alloc_nx_addr_v4() */
20765 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20767 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20768 + nx_addr_v4_cachep, GFP_KERNEL);
20770 + if (!IS_ERR(nxa))
20771 + memset(nxa, 0, sizeof(*nxa));
20775 +/* __dealloc_nx_addr_v4() */
20777 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20779 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20782 +/* __dealloc_nx_addr_v4_all() */
20784 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20787 + struct nx_addr_v4 *next = nxa->next;
20789 + __dealloc_nx_addr_v4(nxa);
20795 +#ifdef CONFIG_IPV6
20797 +/* __alloc_nx_addr_v6() */
20799 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20801 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20802 + nx_addr_v6_cachep, GFP_KERNEL);
20804 + if (!IS_ERR(nxa))
20805 + memset(nxa, 0, sizeof(*nxa));
20809 +/* __dealloc_nx_addr_v6() */
20811 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20813 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20816 +/* __dealloc_nx_addr_v6_all() */
20818 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20821 + struct nx_addr_v6 *next = nxa->next;
20823 + __dealloc_nx_addr_v6(nxa);
20828 +#endif /* CONFIG_IPV6 */
20830 +/* __alloc_nx_info()
20832 + * allocate an initialized nx_info struct
20833 + * doesn't make it visible (hash) */
20835 +static struct nx_info *__alloc_nx_info(nid_t nid)
20837 + struct nx_info *new = NULL;
20839 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20841 + /* would this benefit from a slab cache? */
20842 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20846 + memset(new, 0, sizeof(struct nx_info));
20847 + new->nx_id = nid;
20848 + INIT_HLIST_NODE(&new->nx_hlist);
20849 + atomic_set(&new->nx_usecnt, 0);
20850 + atomic_set(&new->nx_tasks, 0);
20851 + new->nx_state = 0;
20853 + new->nx_flags = NXF_INIT_SET;
20855 + /* rest of init goes here */
20857 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20858 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20860 + vxdprintk(VXD_CBIT(nid, 0),
20861 + "alloc_nx_info(%d) = %p", nid, new);
20862 + atomic_inc(&nx_global_ctotal);
20866 +/* __dealloc_nx_info()
20868 + * final disposal of nx_info */
20870 +static void __dealloc_nx_info(struct nx_info *nxi)
20872 + vxdprintk(VXD_CBIT(nid, 0),
20873 + "dealloc_nx_info(%p)", nxi);
20875 + nxi->nx_hlist.next = LIST_POISON1;
20878 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20879 + BUG_ON(atomic_read(&nxi->nx_tasks));
20881 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20883 + nxi->nx_state |= NXS_RELEASED;
20885 + atomic_dec(&nx_global_ctotal);
20888 +static void __shutdown_nx_info(struct nx_info *nxi)
20890 + nxi->nx_state |= NXS_SHUTDOWN;
20891 + vs_net_change(nxi, VSC_NETDOWN);
20894 +/* exported stuff */
20896 +void free_nx_info(struct nx_info *nxi)
20898 + /* context shutdown is mandatory */
20899 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20901 + /* context must not be hashed */
20902 + BUG_ON(nxi->nx_state & NXS_HASHED);
20904 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20905 + BUG_ON(atomic_read(&nxi->nx_tasks));
20907 + __dealloc_nx_info(nxi);
20911 +void __nx_set_lback(struct nx_info *nxi)
20913 + int nid = nxi->nx_id;
20914 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20916 + nxi->v4_lback.s_addr = lback;
20919 +extern int __nx_inet_add_lback(__be32 addr);
20920 +extern int __nx_inet_del_lback(__be32 addr);
20923 +/* hash table for nx_info hash */
20925 +#define NX_HASH_SIZE 13
20927 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20929 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
20932 +static inline unsigned int __hashval(nid_t nid)
20934 + return (nid % NX_HASH_SIZE);
20939 +/* __hash_nx_info()
20941 + * add the nxi to the global hash table
20942 + * requires the hash_lock to be held */
20944 +static inline void __hash_nx_info(struct nx_info *nxi)
20946 + struct hlist_head *head;
20948 + vxd_assert_lock(&nx_info_hash_lock);
20949 + vxdprintk(VXD_CBIT(nid, 4),
20950 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20952 + /* context must not be hashed */
20953 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20955 + nxi->nx_state |= NXS_HASHED;
20956 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20957 + hlist_add_head(&nxi->nx_hlist, head);
20958 + atomic_inc(&nx_global_cactive);
20961 +/* __unhash_nx_info()
20963 + * remove the nxi from the global hash table
20964 + * requires the hash_lock to be held */
20966 +static inline void __unhash_nx_info(struct nx_info *nxi)
20968 + vxd_assert_lock(&nx_info_hash_lock);
20969 + vxdprintk(VXD_CBIT(nid, 4),
20970 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20971 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20973 + /* context must be hashed */
20974 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20975 + /* but without tasks */
20976 + BUG_ON(atomic_read(&nxi->nx_tasks));
20978 + nxi->nx_state &= ~NXS_HASHED;
20979 + hlist_del(&nxi->nx_hlist);
20980 + atomic_dec(&nx_global_cactive);
20984 +/* __lookup_nx_info()
20986 + * requires the hash_lock to be held
20987 + * doesn't increment the nx_refcnt */
20989 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20991 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20992 + struct hlist_node *pos;
20993 + struct nx_info *nxi;
20995 + vxd_assert_lock(&nx_info_hash_lock);
20996 + hlist_for_each(pos, head) {
20997 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20999 + if (nxi->nx_id == nid)
21004 + vxdprintk(VXD_CBIT(nid, 0),
21005 + "__lookup_nx_info(#%u): %p[#%u]",
21006 + nid, nxi, nxi ? nxi->nx_id : 0);
21011 +/* __create_nx_info()
21013 + * create the requested context
21014 + * get(), claim() and hash it */
21016 +static struct nx_info *__create_nx_info(int id)
21018 + struct nx_info *new, *nxi = NULL;
21020 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
21022 + if (!(new = __alloc_nx_info(id)))
21023 + return ERR_PTR(-ENOMEM);
21025 + /* required to make dynamic xids unique */
21026 + spin_lock(&nx_info_hash_lock);
21028 + /* static context requested */
21029 + if ((nxi = __lookup_nx_info(id))) {
21030 + vxdprintk(VXD_CBIT(nid, 0),
21031 + "create_nx_info(%d) = %p (already there)", id, nxi);
21032 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21033 + nxi = ERR_PTR(-EBUSY);
21035 + nxi = ERR_PTR(-EEXIST);
21038 + /* new context */
21039 + vxdprintk(VXD_CBIT(nid, 0),
21040 + "create_nx_info(%d) = %p (new)", id, new);
21041 + claim_nx_info(new, NULL);
21042 + __nx_set_lback(new);
21043 + __hash_nx_info(get_nx_info(new));
21044 + nxi = new, new = NULL;
21047 + spin_unlock(&nx_info_hash_lock);
21049 + __dealloc_nx_info(new);
21055 +/* exported stuff */
21058 +void unhash_nx_info(struct nx_info *nxi)
21060 + __shutdown_nx_info(nxi);
21061 + spin_lock(&nx_info_hash_lock);
21062 + __unhash_nx_info(nxi);
21063 + spin_unlock(&nx_info_hash_lock);
21066 +/* lookup_nx_info()
21068 + * search for a nx_info and get() it
21069 + * negative id means current */
21071 +struct nx_info *lookup_nx_info(int id)
21073 + struct nx_info *nxi = NULL;
21076 + nxi = get_nx_info(current_nx_info());
21077 + } else if (id > 1) {
21078 + spin_lock(&nx_info_hash_lock);
21079 + nxi = get_nx_info(__lookup_nx_info(id));
21080 + spin_unlock(&nx_info_hash_lock);
21085 +/* nid_is_hashed()
21087 + * verify that nid is still hashed */
21089 +int nid_is_hashed(nid_t nid)
21093 + spin_lock(&nx_info_hash_lock);
21094 + hashed = (__lookup_nx_info(nid) != NULL);
21095 + spin_unlock(&nx_info_hash_lock);
21100 +#ifdef CONFIG_PROC_FS
21104 + * get a subset of hashed nids for proc
21105 + * assumes size is at least one */
21107 +int get_nid_list(int index, unsigned int *nids, int size)
21109 + int hindex, nr_nids = 0;
21111 + /* only show current and children */
21112 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
21115 + nids[nr_nids] = nx_current_nid();
21119 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
21120 + struct hlist_head *head = &nx_info_hash[hindex];
21121 + struct hlist_node *pos;
21123 + spin_lock(&nx_info_hash_lock);
21124 + hlist_for_each(pos, head) {
21125 + struct nx_info *nxi;
21130 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21131 + nids[nr_nids] = nxi->nx_id;
21132 + if (++nr_nids >= size) {
21133 + spin_unlock(&nx_info_hash_lock);
21137 + /* keep the lock time short */
21138 + spin_unlock(&nx_info_hash_lock);
21147 + * migrate task to new network
21148 + * gets nxi, puts old_nxi on change
21151 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
21153 + struct nx_info *old_nxi;
21159 + vxdprintk(VXD_CBIT(nid, 5),
21160 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
21161 + p, nxi, nxi->nx_id,
21162 + atomic_read(&nxi->nx_usecnt),
21163 + atomic_read(&nxi->nx_tasks));
21165 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
21166 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21169 + if (nx_info_state(nxi, NXS_SHUTDOWN))
21172 + /* maybe disallow this completely? */
21173 + old_nxi = task_get_nx_info(p);
21174 + if (old_nxi == nxi)
21179 + clr_nx_info(&p->nx_info);
21180 + claim_nx_info(nxi, p);
21181 + set_nx_info(&p->nx_info, nxi);
21182 + p->nid = nxi->nx_id;
21185 + vxdprintk(VXD_CBIT(nid, 5),
21186 + "moved task %p into nxi:%p[#%d]",
21187 + p, nxi, nxi->nx_id);
21190 + release_nx_info(old_nxi, p);
21193 + put_nx_info(old_nxi);
21198 +void nx_set_persistent(struct nx_info *nxi)
21200 + vxdprintk(VXD_CBIT(nid, 6),
21201 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
21203 + get_nx_info(nxi);
21204 + claim_nx_info(nxi, NULL);
21207 +void nx_clear_persistent(struct nx_info *nxi)
21209 + vxdprintk(VXD_CBIT(nid, 6),
21210 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
21212 + release_nx_info(nxi, NULL);
21213 + put_nx_info(nxi);
21216 +void nx_update_persistent(struct nx_info *nxi)
21218 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
21219 + nx_set_persistent(nxi);
21221 + nx_clear_persistent(nxi);
21224 +/* vserver syscall commands below here */
21226 +/* taks nid and nx_info functions */
21228 +#include <asm/uaccess.h>
21231 +int vc_task_nid(uint32_t id)
21236 + struct task_struct *tsk;
21239 + tsk = find_task_by_real_pid(id);
21240 + nid = (tsk) ? tsk->nid : -ESRCH;
21241 + rcu_read_unlock();
21243 + nid = nx_current_nid();
21248 +int vc_nx_info(struct nx_info *nxi, void __user *data)
21250 + struct vcmd_nx_info_v0 vc_data;
21252 + vc_data.nid = nxi->nx_id;
21254 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21260 +/* network functions */
21262 +int vc_net_create(uint32_t nid, void __user *data)
21264 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
21265 + struct nx_info *new_nxi;
21268 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21271 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
21274 + new_nxi = __create_nx_info(nid);
21275 + if (IS_ERR(new_nxi))
21276 + return PTR_ERR(new_nxi);
21278 + /* initial flags */
21279 + new_nxi->nx_flags = vc_data.flagword;
21282 + if (vs_net_change(new_nxi, VSC_NETUP))
21285 + ret = nx_migrate_task(current, new_nxi);
21289 + /* return context id on success */
21290 + ret = new_nxi->nx_id;
21292 + /* get a reference for persistent contexts */
21293 + if ((vc_data.flagword & NXF_PERSISTENT))
21294 + nx_set_persistent(new_nxi);
21296 + release_nx_info(new_nxi, NULL);
21297 + put_nx_info(new_nxi);
21302 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
21304 + return nx_migrate_task(current, nxi);
21309 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21310 + uint16_t type, uint16_t flags)
21312 + struct nx_addr_v4 *nxa = &nxi->v4;
21314 + if (NX_IPV4(nxi)) {
21315 + /* locate last entry */
21316 + for (; nxa->next; nxa = nxa->next);
21317 + nxa->next = __alloc_nx_addr_v4();
21321 + return PTR_ERR(nxa);
21324 + if (nxi->v4.next)
21325 + /* remove single ip for ip list */
21326 + nxi->nx_flags &= ~NXF_SINGLE_IP;
21328 + nxa->ip[0].s_addr = ip;
21329 + nxa->ip[1].s_addr = ip2;
21330 + nxa->mask.s_addr = mask;
21331 + nxa->type = type;
21332 + nxa->flags = flags;
21336 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21337 + uint16_t type, uint16_t flags)
21339 + struct nx_addr_v4 *nxa = &nxi->v4;
21342 +/* case NXA_TYPE_ADDR:
21345 + case NXA_TYPE_ANY:
21346 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
21347 + memset(nxa, 0, sizeof(*nxa));
21357 +int vc_net_add(struct nx_info *nxi, void __user *data)
21359 + struct vcmd_net_addr_v0 vc_data;
21360 + int index, ret = 0;
21362 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21365 + switch (vc_data.type) {
21366 + case NXA_TYPE_IPV4:
21367 + if ((vc_data.count < 1) || (vc_data.count > 4))
21371 + while (index < vc_data.count) {
21372 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
21373 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
21381 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
21382 + nxi->v4_bcast = vc_data.ip[0];
21386 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
21387 + nxi->v4_lback = vc_data.ip[0];
21398 +int vc_net_remove(struct nx_info *nxi, void __user *data)
21400 + struct vcmd_net_addr_v0 vc_data;
21402 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21405 + switch (vc_data.type) {
21406 + case NXA_TYPE_ANY:
21407 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21408 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21418 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
21420 + struct vcmd_net_addr_ipv4_v1 vc_data;
21422 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21425 + switch (vc_data.type) {
21426 + case NXA_TYPE_ADDR:
21427 + vc_data.mask.s_addr = ~0;
21428 + /* fallthrough */
21429 + case NXA_TYPE_MASK:
21430 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
21431 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21433 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21434 + nxi->v4_bcast = vc_data.ip;
21437 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21438 + nxi->v4_lback = vc_data.ip;
21447 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
21449 + struct vcmd_net_addr_ipv4_v2 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 + case NXA_TYPE_RANGE:
21458 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
21459 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21461 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21462 + nxi->v4_bcast = vc_data.ip;
21465 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21466 + nxi->v4_lback = vc_data.ip;
21475 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
21477 + struct vcmd_net_addr_ipv4_v1 vc_data;
21479 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21482 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
21483 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21486 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
21488 + struct vcmd_net_addr_ipv4_v2 vc_data;
21490 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21493 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
21494 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21497 +#ifdef CONFIG_IPV6
21499 +int do_add_v6_addr(struct nx_info *nxi,
21500 + struct in6_addr *ip, struct in6_addr *mask,
21501 + uint32_t prefix, uint16_t type, uint16_t flags)
21503 + struct nx_addr_v6 *nxa = &nxi->v6;
21505 + if (NX_IPV6(nxi)) {
21506 + /* locate last entry */
21507 + for (; nxa->next; nxa = nxa->next);
21508 + nxa->next = __alloc_nx_addr_v6();
21512 + return PTR_ERR(nxa);
21516 + nxa->mask = *mask;
21517 + nxa->prefix = prefix;
21518 + nxa->type = type;
21519 + nxa->flags = flags;
21524 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21526 + struct vcmd_net_addr_ipv6_v1 vc_data;
21528 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21531 + switch (vc_data.type) {
21532 + case NXA_TYPE_ADDR:
21533 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
21534 + /* fallthrough */
21535 + case NXA_TYPE_MASK:
21536 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21537 + vc_data.prefix, vc_data.type, vc_data.flags);
21544 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21546 + struct vcmd_net_addr_ipv6_v1 vc_data;
21548 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21551 + switch (vc_data.type) {
21552 + case NXA_TYPE_ANY:
21553 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21554 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21563 +#endif /* CONFIG_IPV6 */
21566 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21568 + struct vcmd_net_flags_v0 vc_data;
21570 + vc_data.flagword = nxi->nx_flags;
21572 + /* special STATE flag handling */
21573 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21575 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21580 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21582 + struct vcmd_net_flags_v0 vc_data;
21583 + uint64_t mask, trigger;
21585 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21588 + /* special STATE flag handling */
21589 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21590 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21592 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21593 + vc_data.flagword, mask);
21594 + if (trigger & NXF_PERSISTENT)
21595 + nx_update_persistent(nxi);
21600 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21602 + struct vcmd_net_caps_v0 vc_data;
21604 + vc_data.ncaps = nxi->nx_ncaps;
21605 + vc_data.cmask = ~0ULL;
21607 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21612 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21614 + struct vcmd_net_caps_v0 vc_data;
21616 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21619 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21620 + vc_data.ncaps, vc_data.cmask);
21625 +#include <linux/module.h>
21627 +module_init(init_network);
21629 +EXPORT_SYMBOL_GPL(free_nx_info);
21630 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21632 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/proc.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/proc.c
21633 --- linux-2.6.38.3/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21634 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/proc.c 2011-01-29 02:01:07.000000000 +0100
21637 + * linux/kernel/vserver/proc.c
21639 + * Virtual Context Support
21641 + * Copyright (C) 2003-2007 Herbert Pötzl
21643 + * V0.01 basic structure
21644 + * V0.02 adaptation vs1.3.0
21645 + * V0.03 proc permissions
21646 + * V0.04 locking/generic
21647 + * V0.05 next generation procfs
21648 + * V0.06 inode validation
21649 + * V0.07 generic rewrite vid
21650 + * V0.08 remove inode type
21654 +#include <linux/proc_fs.h>
21655 +#include <linux/fs_struct.h>
21656 +#include <linux/mount.h>
21657 +#include <asm/unistd.h>
21659 +#include <linux/vs_context.h>
21660 +#include <linux/vs_network.h>
21661 +#include <linux/vs_cvirt.h>
21663 +#include <linux/in.h>
21664 +#include <linux/inetdevice.h>
21665 +#include <linux/vs_inet.h>
21666 +#include <linux/vs_inet6.h>
21668 +#include <linux/vserver/global.h>
21670 +#include "cvirt_proc.h"
21671 +#include "cacct_proc.h"
21672 +#include "limit_proc.h"
21673 +#include "sched_proc.h"
21674 +#include "vci_config.h"
21677 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21681 + CAP_FOR_EACH_U32(__capi) {
21682 + buffer += sprintf(buffer, "%08x",
21683 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21689 +static struct proc_dir_entry *proc_virtual;
21691 +static struct proc_dir_entry *proc_virtnet;
21694 +/* first the actual feeds */
21697 +static int proc_vci(char *buffer)
21699 + return sprintf(buffer,
21700 + "VCIVersion:\t%04x:%04x\n"
21701 + "VCISyscall:\t%d\n"
21702 + "VCIKernel:\t%08x\n",
21703 + VCI_VERSION >> 16,
21704 + VCI_VERSION & 0xFFFF,
21706 + vci_kernel_config());
21709 +static int proc_virtual_info(char *buffer)
21711 + return proc_vci(buffer);
21714 +static int proc_virtual_status(char *buffer)
21716 + return sprintf(buffer,
21718 + "#CActive:\t%d\n"
21719 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21720 + "#InitTask:\t%d\t%d %d\n",
21721 + atomic_read(&vx_global_ctotal),
21722 + atomic_read(&vx_global_cactive),
21723 + atomic_read(&vs_global_nsproxy),
21724 + atomic_read(&vs_global_fs),
21725 + atomic_read(&vs_global_mnt_ns),
21726 + atomic_read(&vs_global_uts_ns),
21727 + atomic_read(&nr_ipc_ns),
21728 + atomic_read(&vs_global_user_ns),
21729 + atomic_read(&vs_global_pid_ns),
21730 + atomic_read(&init_task.usage),
21731 + atomic_read(&init_task.nsproxy->count),
21732 + init_task.fs->users);
21736 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21740 + length = sprintf(buffer,
21748 + vxi->vx_badness_bias);
21752 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21754 + char *orig = buffer;
21756 + buffer += sprintf(buffer,
21759 + "Flags:\t%016llx\n",
21760 + atomic_read(&vxi->vx_usecnt),
21761 + atomic_read(&vxi->vx_tasks),
21762 + (unsigned long long)vxi->vx_flags);
21764 + buffer += sprintf(buffer, "BCaps:\t");
21765 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21766 + buffer += sprintf(buffer, "\n");
21768 + buffer += sprintf(buffer,
21769 + "CCaps:\t%016llx\n"
21770 + "Spaces:\t%08lx %08lx\n",
21771 + (unsigned long long)vxi->vx_ccaps,
21772 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21773 + return buffer - orig;
21776 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21778 + return vx_info_proc_limit(&vxi->limit, buffer);
21781 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21785 + length = vx_info_proc_sched(&vxi->sched, buffer);
21786 + for_each_online_cpu(cpu) {
21787 + length += vx_info_proc_sched_pc(
21788 + &vx_per_cpu(vxi, sched_pc, cpu),
21789 + buffer + length, cpu);
21794 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21796 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21799 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21801 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21804 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21808 + vx_update_load(vxi);
21809 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21810 + for_each_online_cpu(cpu) {
21811 + length += vx_info_proc_cvirt_pc(
21812 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21813 + buffer + length, cpu);
21818 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21820 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21824 +static int proc_virtnet_info(char *buffer)
21826 + return proc_vci(buffer);
21829 +static int proc_virtnet_status(char *buffer)
21831 + return sprintf(buffer,
21833 + "#CActive:\t%d\n",
21834 + atomic_read(&nx_global_ctotal),
21835 + atomic_read(&nx_global_cactive));
21838 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21840 + struct nx_addr_v4 *v4a;
21841 +#ifdef CONFIG_IPV6
21842 + struct nx_addr_v6 *v6a;
21846 + length = sprintf(buffer,
21849 + "Bcast:\t" NIPQUAD_FMT "\n"
21850 + "Lback:\t" NIPQUAD_FMT "\n",
21853 + NIPQUAD(nxi->v4_bcast.s_addr),
21854 + NIPQUAD(nxi->v4_lback.s_addr));
21856 + if (!NX_IPV4(nxi))
21858 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21859 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21862 +#ifdef CONFIG_IPV6
21863 + if (!NX_IPV6(nxi))
21865 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21866 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21873 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21877 + length = sprintf(buffer,
21880 + "Flags:\t%016llx\n"
21881 + "NCaps:\t%016llx\n",
21882 + atomic_read(&nxi->nx_usecnt),
21883 + atomic_read(&nxi->nx_tasks),
21884 + (unsigned long long)nxi->nx_flags,
21885 + (unsigned long long)nxi->nx_ncaps);
21891 +/* here the inode helpers */
21897 + struct inode_operations *iop;
21898 + struct file_operations *fop;
21899 + union proc_op op;
21902 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21904 + struct inode *inode = new_inode(sb);
21909 + inode->i_mode = p->mode;
21911 + inode->i_op = p->iop;
21913 + inode->i_fop = p->fop;
21915 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
21916 + inode->i_flags |= S_IMMUTABLE;
21918 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21920 + inode->i_uid = 0;
21921 + inode->i_gid = 0;
21922 + inode->i_tag = 0;
21927 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21928 + struct dentry *dentry, int id, void *ptr)
21930 + struct vs_entry *p = ptr;
21931 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21932 + struct dentry *error = ERR_PTR(-EINVAL);
21937 + PROC_I(inode)->op = p->op;
21938 + PROC_I(inode)->fd = id;
21939 + d_add(dentry, inode);
21947 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21950 + * Fill a directory entry.
21952 + * If possible create the dcache entry and derive our inode number and
21953 + * file type from dcache entry.
21955 + * Since all of the proc inode numbers are dynamically generated, the inode
21956 + * numbers do not exist until the inode is cache. This means creating the
21957 + * the dcache entry in readdir is necessary to keep the inode numbers
21958 + * reported by readdir in sync with the inode numbers reported
21961 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21962 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21964 + struct dentry *child, *dir = filp->f_dentry;
21965 + struct inode *inode;
21966 + struct qstr qname;
21968 + unsigned type = DT_UNKNOWN;
21970 + qname.name = name;
21972 + qname.hash = full_name_hash(name, len);
21974 + child = d_lookup(dir, &qname);
21976 + struct dentry *new;
21977 + new = d_alloc(dir, &qname);
21979 + child = instantiate(dir->d_inode, new, id, ptr);
21986 + if (!child || IS_ERR(child) || !child->d_inode)
21987 + goto end_instantiate;
21988 + inode = child->d_inode;
21990 + ino = inode->i_ino;
21991 + type = inode->i_mode >> 12;
21996 + ino = find_inode_number(dir, &qname);
21999 + return filldir(dirent, name, len, filp->f_pos, ino, type);
22004 +/* get and revalidate vx_info/xid */
22007 +struct vx_info *get_proc_vx_info(struct inode *inode)
22009 + return lookup_vx_info(PROC_I(inode)->fd);
22012 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
22014 + struct inode *inode = dentry->d_inode;
22015 + xid_t xid = PROC_I(inode)->fd;
22017 + if (!xid || xid_is_hashed(xid))
22024 +/* get and revalidate nx_info/nid */
22026 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
22028 + struct inode *inode = dentry->d_inode;
22029 + nid_t nid = PROC_I(inode)->fd;
22031 + if (!nid || nid_is_hashed(nid))
22039 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
22041 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
22042 + size_t count, loff_t *ppos)
22044 + struct inode *inode = file->f_dentry->d_inode;
22045 + unsigned long page;
22046 + ssize_t length = 0;
22048 + if (count > PROC_BLOCK_SIZE)
22049 + count = PROC_BLOCK_SIZE;
22051 + /* fade that out as soon as stable */
22052 + WARN_ON(PROC_I(inode)->fd);
22054 + if (!(page = __get_free_page(GFP_KERNEL)))
22057 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
22058 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
22061 + length = simple_read_from_buffer(buf, count, ppos,
22062 + (char *)page, length);
22068 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
22069 + size_t count, loff_t *ppos)
22071 + struct inode *inode = file->f_dentry->d_inode;
22072 + struct vx_info *vxi = NULL;
22073 + xid_t xid = PROC_I(inode)->fd;
22074 + unsigned long page;
22075 + ssize_t length = 0;
22077 + if (count > PROC_BLOCK_SIZE)
22078 + count = PROC_BLOCK_SIZE;
22080 + /* fade that out as soon as stable */
22082 + vxi = lookup_vx_info(xid);
22086 + length = -ENOMEM;
22087 + if (!(page = __get_free_page(GFP_KERNEL)))
22090 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
22091 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
22094 + length = simple_read_from_buffer(buf, count, ppos,
22095 + (char *)page, length);
22099 + put_vx_info(vxi);
22104 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
22105 + size_t count, loff_t *ppos)
22107 + struct inode *inode = file->f_dentry->d_inode;
22108 + struct nx_info *nxi = NULL;
22109 + nid_t nid = PROC_I(inode)->fd;
22110 + unsigned long page;
22111 + ssize_t length = 0;
22113 + if (count > PROC_BLOCK_SIZE)
22114 + count = PROC_BLOCK_SIZE;
22116 + /* fade that out as soon as stable */
22118 + nxi = lookup_nx_info(nid);
22122 + length = -ENOMEM;
22123 + if (!(page = __get_free_page(GFP_KERNEL)))
22126 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
22127 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
22130 + length = simple_read_from_buffer(buf, count, ppos,
22131 + (char *)page, length);
22135 + put_nx_info(nxi);
22142 +/* here comes the lower level */
22145 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
22146 + .len = sizeof(NAME) - 1, \
22147 + .name = (NAME), \
22155 +#define DIR(NAME, MODE, OTYPE) \
22156 + NOD(NAME, (S_IFDIR | (MODE)), \
22157 + &proc_ ## OTYPE ## _inode_operations, \
22158 + &proc_ ## OTYPE ## _file_operations, { } )
22160 +#define INF(NAME, MODE, OTYPE) \
22161 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22162 + &proc_vs_info_file_operations, \
22163 + { .proc_vs_read = &proc_##OTYPE } )
22165 +#define VINF(NAME, MODE, OTYPE) \
22166 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22167 + &proc_vx_info_file_operations, \
22168 + { .proc_vxi_read = &proc_##OTYPE } )
22170 +#define NINF(NAME, MODE, OTYPE) \
22171 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22172 + &proc_nx_info_file_operations, \
22173 + { .proc_nxi_read = &proc_##OTYPE } )
22176 +static struct file_operations proc_vs_info_file_operations = {
22177 + .read = proc_vs_info_read,
22180 +static struct file_operations proc_vx_info_file_operations = {
22181 + .read = proc_vx_info_read,
22184 +static struct dentry_operations proc_xid_dentry_operations = {
22185 + .d_revalidate = proc_xid_revalidate,
22188 +static struct vs_entry vx_base_stuff[] = {
22189 + VINF("info", S_IRUGO, vxi_info),
22190 + VINF("status", S_IRUGO, vxi_status),
22191 + VINF("limit", S_IRUGO, vxi_limit),
22192 + VINF("sched", S_IRUGO, vxi_sched),
22193 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
22194 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
22195 + VINF("cvirt", S_IRUGO, vxi_cvirt),
22196 + VINF("cacct", S_IRUGO, vxi_cacct),
22203 +static struct dentry *proc_xid_instantiate(struct inode *dir,
22204 + struct dentry *dentry, int id, void *ptr)
22206 + dentry->d_op = &proc_xid_dentry_operations;
22207 + return vs_proc_instantiate(dir, dentry, id, ptr);
22210 +static struct dentry *proc_xid_lookup(struct inode *dir,
22211 + struct dentry *dentry, struct nameidata *nd)
22213 + struct vs_entry *p = vx_base_stuff;
22214 + struct dentry *error = ERR_PTR(-ENOENT);
22216 + for (; p->name; p++) {
22217 + if (p->len != dentry->d_name.len)
22219 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22225 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22230 +static int proc_xid_readdir(struct file *filp,
22231 + void *dirent, filldir_t filldir)
22233 + struct dentry *dentry = filp->f_dentry;
22234 + struct inode *inode = dentry->d_inode;
22235 + struct vs_entry *p = vx_base_stuff;
22236 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
22240 + pos = filp->f_pos;
22243 + ino = inode->i_ino;
22244 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22247 + /* fall through */
22249 + ino = parent_ino(dentry);
22250 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22253 + /* fall through */
22256 + if (index >= size)
22258 + for (p += index; p->name; p++) {
22259 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22260 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22266 + filp->f_pos = pos;
22272 +static struct file_operations proc_nx_info_file_operations = {
22273 + .read = proc_nx_info_read,
22276 +static struct dentry_operations proc_nid_dentry_operations = {
22277 + .d_revalidate = proc_nid_revalidate,
22280 +static struct vs_entry nx_base_stuff[] = {
22281 + NINF("info", S_IRUGO, nxi_info),
22282 + NINF("status", S_IRUGO, nxi_status),
22287 +static struct dentry *proc_nid_instantiate(struct inode *dir,
22288 + struct dentry *dentry, int id, void *ptr)
22290 + dentry->d_op = &proc_nid_dentry_operations;
22291 + return vs_proc_instantiate(dir, dentry, id, ptr);
22294 +static struct dentry *proc_nid_lookup(struct inode *dir,
22295 + struct dentry *dentry, struct nameidata *nd)
22297 + struct vs_entry *p = nx_base_stuff;
22298 + struct dentry *error = ERR_PTR(-ENOENT);
22300 + for (; p->name; p++) {
22301 + if (p->len != dentry->d_name.len)
22303 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22309 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22314 +static int proc_nid_readdir(struct file *filp,
22315 + void *dirent, filldir_t filldir)
22317 + struct dentry *dentry = filp->f_dentry;
22318 + struct inode *inode = dentry->d_inode;
22319 + struct vs_entry *p = nx_base_stuff;
22320 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
22324 + pos = filp->f_pos;
22327 + ino = inode->i_ino;
22328 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22331 + /* fall through */
22333 + ino = parent_ino(dentry);
22334 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22337 + /* fall through */
22340 + if (index >= size)
22342 + for (p += index; p->name; p++) {
22343 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22344 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22350 + filp->f_pos = pos;
22355 +#define MAX_MULBY10 ((~0U - 9) / 10)
22357 +static inline int atovid(const char *str, int len)
22362 + while (len-- > 0) {
22367 + if (vid >= MAX_MULBY10)
22377 +/* now the upper level (virtual) */
22380 +static struct file_operations proc_xid_file_operations = {
22381 + .read = generic_read_dir,
22382 + .readdir = proc_xid_readdir,
22385 +static struct inode_operations proc_xid_inode_operations = {
22386 + .lookup = proc_xid_lookup,
22389 +static struct vs_entry vx_virtual_stuff[] = {
22390 + INF("info", S_IRUGO, virtual_info),
22391 + INF("status", S_IRUGO, virtual_status),
22392 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
22396 +static struct dentry *proc_virtual_lookup(struct inode *dir,
22397 + struct dentry *dentry, struct nameidata *nd)
22399 + struct vs_entry *p = vx_virtual_stuff;
22400 + struct dentry *error = ERR_PTR(-ENOENT);
22403 + for (; p->name; p++) {
22404 + if (p->len != dentry->d_name.len)
22406 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22410 + goto instantiate;
22412 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22413 + if ((id < 0) || !xid_is_hashed(id))
22417 + error = proc_xid_instantiate(dir, dentry, id, p);
22422 +static struct file_operations proc_nid_file_operations = {
22423 + .read = generic_read_dir,
22424 + .readdir = proc_nid_readdir,
22427 +static struct inode_operations proc_nid_inode_operations = {
22428 + .lookup = proc_nid_lookup,
22431 +static struct vs_entry nx_virtnet_stuff[] = {
22432 + INF("info", S_IRUGO, virtnet_info),
22433 + INF("status", S_IRUGO, virtnet_status),
22434 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
22438 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
22439 + struct dentry *dentry, struct nameidata *nd)
22441 + struct vs_entry *p = nx_virtnet_stuff;
22442 + struct dentry *error = ERR_PTR(-ENOENT);
22445 + for (; p->name; p++) {
22446 + if (p->len != dentry->d_name.len)
22448 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22452 + goto instantiate;
22454 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22455 + if ((id < 0) || !nid_is_hashed(id))
22459 + error = proc_nid_instantiate(dir, dentry, id, p);
22465 +#define PROC_MAXVIDS 32
22467 +int proc_virtual_readdir(struct file *filp,
22468 + void *dirent, filldir_t filldir)
22470 + struct dentry *dentry = filp->f_dentry;
22471 + struct inode *inode = dentry->d_inode;
22472 + struct vs_entry *p = vx_virtual_stuff;
22473 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
22475 + unsigned int xid_array[PROC_MAXVIDS];
22476 + char buf[PROC_NUMBUF];
22477 + unsigned int nr_xids, i;
22480 + pos = filp->f_pos;
22483 + ino = inode->i_ino;
22484 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22487 + /* fall through */
22489 + ino = parent_ino(dentry);
22490 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22493 + /* fall through */
22496 + if (index >= size)
22498 + for (p += index; p->name; p++) {
22499 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22500 + vs_proc_instantiate, 0, p))
22505 + index = pos - size;
22506 + p = &vx_virtual_stuff[size - 1];
22507 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22508 + for (i = 0; i < nr_xids; i++) {
22509 + int n, xid = xid_array[i];
22510 + unsigned int j = PROC_NUMBUF;
22514 + buf[--j] = '0' + (n % 10);
22517 + if (proc_fill_cache(filp, dirent, filldir,
22518 + buf + j, PROC_NUMBUF - j,
22519 + vs_proc_instantiate, xid, p))
22525 + filp->f_pos = pos;
22529 +static int proc_virtual_getattr(struct vfsmount *mnt,
22530 + struct dentry *dentry, struct kstat *stat)
22532 + struct inode *inode = dentry->d_inode;
22534 + generic_fillattr(inode, stat);
22535 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22539 +static struct file_operations proc_virtual_dir_operations = {
22540 + .read = generic_read_dir,
22541 + .readdir = proc_virtual_readdir,
22544 +static struct inode_operations proc_virtual_dir_inode_operations = {
22545 + .getattr = proc_virtual_getattr,
22546 + .lookup = proc_virtual_lookup,
22553 +int proc_virtnet_readdir(struct file *filp,
22554 + void *dirent, filldir_t filldir)
22556 + struct dentry *dentry = filp->f_dentry;
22557 + struct inode *inode = dentry->d_inode;
22558 + struct vs_entry *p = nx_virtnet_stuff;
22559 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22561 + unsigned int nid_array[PROC_MAXVIDS];
22562 + char buf[PROC_NUMBUF];
22563 + unsigned int nr_nids, i;
22566 + pos = filp->f_pos;
22569 + ino = inode->i_ino;
22570 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22573 + /* fall through */
22575 + ino = parent_ino(dentry);
22576 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22579 + /* fall through */
22582 + if (index >= size)
22584 + for (p += index; p->name; p++) {
22585 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22586 + vs_proc_instantiate, 0, p))
22591 + index = pos - size;
22592 + p = &nx_virtnet_stuff[size - 1];
22593 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22594 + for (i = 0; i < nr_nids; i++) {
22595 + int n, nid = nid_array[i];
22596 + unsigned int j = PROC_NUMBUF;
22600 + buf[--j] = '0' + (n % 10);
22603 + if (proc_fill_cache(filp, dirent, filldir,
22604 + buf + j, PROC_NUMBUF - j,
22605 + vs_proc_instantiate, nid, p))
22611 + filp->f_pos = pos;
22615 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22616 + struct dentry *dentry, struct kstat *stat)
22618 + struct inode *inode = dentry->d_inode;
22620 + generic_fillattr(inode, stat);
22621 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22625 +static struct file_operations proc_virtnet_dir_operations = {
22626 + .read = generic_read_dir,
22627 + .readdir = proc_virtnet_readdir,
22630 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22631 + .getattr = proc_virtnet_getattr,
22632 + .lookup = proc_virtnet_lookup,
22637 +void proc_vx_init(void)
22639 + struct proc_dir_entry *ent;
22641 + ent = proc_mkdir("virtual", 0);
22643 + ent->proc_fops = &proc_virtual_dir_operations;
22644 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22646 + proc_virtual = ent;
22648 + ent = proc_mkdir("virtnet", 0);
22650 + ent->proc_fops = &proc_virtnet_dir_operations;
22651 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22653 + proc_virtnet = ent;
22659 +/* per pid info */
22662 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22664 + struct vx_info *vxi;
22665 + char *orig = buffer;
22667 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22669 + vxi = task_get_vx_info(p);
22673 + buffer += sprintf(buffer, "BCaps:\t");
22674 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22675 + buffer += sprintf(buffer, "\n");
22676 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22677 + (unsigned long long)vxi->vx_ccaps);
22678 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22679 + (unsigned long long)vxi->vx_flags);
22680 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22682 + put_vx_info(vxi);
22684 + return buffer - orig;
22688 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22690 + struct nx_info *nxi;
22691 + struct nx_addr_v4 *v4a;
22692 +#ifdef CONFIG_IPV6
22693 + struct nx_addr_v6 *v6a;
22695 + char *orig = buffer;
22698 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22700 + nxi = task_get_nx_info(p);
22704 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22705 + (unsigned long long)nxi->nx_ncaps);
22706 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22707 + (unsigned long long)nxi->nx_flags);
22709 + buffer += sprintf(buffer,
22710 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22711 + NIPQUAD(nxi->v4_bcast.s_addr));
22712 + buffer += sprintf (buffer,
22713 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22714 + NIPQUAD(nxi->v4_lback.s_addr));
22715 + if (!NX_IPV4(nxi))
22717 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22718 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22721 +#ifdef CONFIG_IPV6
22722 + if (!NX_IPV6(nxi))
22724 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22725 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22729 + put_nx_info(nxi);
22731 + return buffer - orig;
22734 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/sched.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/sched.c
22735 --- linux-2.6.38.3/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22736 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/sched.c 2011-01-29 02:01:07.000000000 +0100
22739 + * linux/kernel/vserver/sched.c
22741 + * Virtual Server: Scheduler Support
22743 + * Copyright (C) 2004-2010 Herbert Pötzl
22745 + * V0.01 adapted Sam Vilains version to 2.6.3
22746 + * V0.02 removed legacy interface
22747 + * V0.03 changed vcmds to vxi arg
22748 + * V0.04 removed older and legacy interfaces
22749 + * V0.05 removed scheduler code/commands
22753 +#include <linux/vs_context.h>
22754 +#include <linux/vs_sched.h>
22755 +#include <linux/vserver/sched_cmd.h>
22757 +#include <asm/uaccess.h>
22760 +void vx_update_sched_param(struct _vx_sched *sched,
22761 + struct _vx_sched_pc *sched_pc)
22763 + sched_pc->prio_bias = sched->prio_bias;
22766 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22770 + if (data->prio_bias > MAX_PRIO_BIAS)
22771 + data->prio_bias = MAX_PRIO_BIAS;
22772 + if (data->prio_bias < MIN_PRIO_BIAS)
22773 + data->prio_bias = MIN_PRIO_BIAS;
22775 + if (data->cpu_id != ~0) {
22776 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22777 + cpus_and(vxi->sched.update, cpu_online_map,
22778 + vxi->sched.update);
22780 + vxi->sched.update = cpu_online_map;
22782 + for_each_cpu_mask(cpu, vxi->sched.update)
22783 + vx_update_sched_param(&vxi->sched,
22784 + &vx_per_cpu(vxi, sched_pc, cpu));
22788 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22790 + struct vcmd_prio_bias vc_data;
22792 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22795 + return do_set_prio_bias(vxi, &vc_data);
22798 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22800 + struct vcmd_prio_bias vc_data;
22801 + struct _vx_sched_pc *pcd;
22804 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22807 + cpu = vc_data.cpu_id;
22809 + if (!cpu_possible(cpu))
22812 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22813 + vc_data.prio_bias = pcd->prio_bias;
22815 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22820 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/sched_init.h linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/sched_init.h
22821 --- linux-2.6.38.3/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22822 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/sched_init.h 2011-01-29 02:01:07.000000000 +0100
22825 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22827 + /* scheduling; hard code starting values as constants */
22828 + sched->prio_bias = 0;
22832 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22834 + sched_pc->prio_bias = 0;
22836 + sched_pc->user_ticks = 0;
22837 + sched_pc->sys_ticks = 0;
22838 + sched_pc->hold_ticks = 0;
22841 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22847 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22851 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/sched_proc.h linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/sched_proc.h
22852 --- linux-2.6.38.3/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22853 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/sched_proc.h 2011-01-29 02:01:07.000000000 +0100
22855 +#ifndef _VX_SCHED_PROC_H
22856 +#define _VX_SCHED_PROC_H
22860 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22864 + length += sprintf(buffer,
22865 + "PrioBias:\t%8d\n",
22866 + sched->prio_bias);
22871 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22872 + char *buffer, int cpu)
22876 + length += sprintf(buffer + length,
22877 + "cpu %d: %lld %lld %lld", cpu,
22878 + (unsigned long long)sched_pc->user_ticks,
22879 + (unsigned long long)sched_pc->sys_ticks,
22880 + (unsigned long long)sched_pc->hold_ticks);
22881 + length += sprintf(buffer + length,
22882 + " %d\n", sched_pc->prio_bias);
22886 +#endif /* _VX_SCHED_PROC_H */
22887 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/signal.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/signal.c
22888 --- linux-2.6.38.3/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22889 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/signal.c 2011-03-22 17:37:59.000000000 +0100
22892 + * linux/kernel/vserver/signal.c
22894 + * Virtual Server: Signal Support
22896 + * Copyright (C) 2003-2007 Herbert Pötzl
22898 + * V0.01 broken out from vcontext V0.05
22899 + * V0.02 changed vcmds to vxi arg
22900 + * V0.03 adjusted siginfo for kill
22904 +#include <asm/uaccess.h>
22906 +#include <linux/vs_context.h>
22907 +#include <linux/vs_pid.h>
22908 +#include <linux/vserver/signal_cmd.h>
22911 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22913 + int retval, count = 0;
22914 + struct task_struct *p;
22915 + struct siginfo *sip = SEND_SIG_PRIV;
22918 + vxdprintk(VXD_CBIT(misc, 4),
22919 + "vx_info_kill(%p[#%d],%d,%d)*",
22920 + vxi, vxi->vx_id, pid, sig);
22921 + read_lock(&tasklist_lock);
22925 + for_each_process(p) {
22928 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22929 + (pid && vxi->vx_initpid == p->pid))
22932 + err = group_send_sig_info(sig, sip, p);
22934 + if (err != -EPERM)
22940 + if (vxi->vx_initpid) {
22941 + pid = vxi->vx_initpid;
22942 + /* for now, only SIGINT to private init ... */
22943 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22944 + /* ... as long as there are tasks left */
22945 + (atomic_read(&vxi->vx_tasks) > 1))
22948 + /* fallthrough */
22951 + p = find_task_by_real_pid(pid);
22952 + rcu_read_unlock();
22954 + if (vx_task_xid(p) == vxi->vx_id)
22955 + retval = group_send_sig_info(sig, sip, p);
22959 + read_unlock(&tasklist_lock);
22960 + vxdprintk(VXD_CBIT(misc, 4),
22961 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22962 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22966 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22968 + struct vcmd_ctx_kill_v0 vc_data;
22970 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22973 + /* special check to allow guest shutdown */
22974 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22975 + /* forbid killall pid=0 when init is present */
22976 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22977 + (vc_data.pid > 1)))
22980 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22984 +static int __wait_exit(struct vx_info *vxi)
22986 + DECLARE_WAITQUEUE(wait, current);
22989 + add_wait_queue(&vxi->vx_wait, &wait);
22990 + set_current_state(TASK_INTERRUPTIBLE);
22993 + if (vx_info_state(vxi,
22994 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22996 + if (signal_pending(current)) {
22997 + ret = -ERESTARTSYS;
23004 + set_current_state(TASK_RUNNING);
23005 + remove_wait_queue(&vxi->vx_wait, &wait);
23011 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
23013 + struct vcmd_wait_exit_v0 vc_data;
23016 + ret = __wait_exit(vxi);
23017 + vc_data.reboot_cmd = vxi->reboot_cmd;
23018 + vc_data.exit_code = vxi->exit_code;
23020 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23025 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/space.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/space.c
23026 --- linux-2.6.38.3/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
23027 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/space.c 2011-02-01 03:30:46.000000000 +0100
23030 + * linux/kernel/vserver/space.c
23032 + * Virtual Server: Context Space Support
23034 + * Copyright (C) 2003-2010 Herbert Pötzl
23036 + * V0.01 broken out from context.c 0.07
23037 + * V0.02 added task locking for namespace
23038 + * V0.03 broken out vx_enter_namespace
23039 + * V0.04 added *space support and commands
23040 + * V0.05 added credential support
23044 +#include <linux/utsname.h>
23045 +#include <linux/nsproxy.h>
23046 +#include <linux/err.h>
23047 +#include <linux/fs_struct.h>
23048 +#include <linux/cred.h>
23049 +#include <asm/uaccess.h>
23051 +#include <linux/vs_context.h>
23052 +#include <linux/vserver/space.h>
23053 +#include <linux/vserver/space_cmd.h>
23055 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
23056 +atomic_t vs_global_fs = ATOMIC_INIT(0);
23057 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
23058 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
23059 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
23060 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
23063 +/* namespace functions */
23065 +#include <linux/mnt_namespace.h>
23066 +#include <linux/user_namespace.h>
23067 +#include <linux/pid_namespace.h>
23068 +#include <linux/ipc_namespace.h>
23069 +#include <net/net_namespace.h>
23072 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
23073 + .mask = CLONE_FS |
23081 +static const struct vcmd_space_mask_v1 space_mask = {
23082 + .mask = CLONE_FS |
23087 +#ifdef CONFIG_PID_NS
23090 +#ifdef CONFIG_NET_NS
23096 +static const struct vcmd_space_mask_v1 default_space_mask = {
23097 + .mask = CLONE_FS |
23102 +#ifdef CONFIG_PID_NS
23109 + * build a new nsproxy mix
23110 + * assumes that both proxies are 'const'
23111 + * does not touch nsproxy refcounts
23112 + * will hold a reference on the result.
23115 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
23116 + struct nsproxy *new_nsproxy, unsigned long mask)
23118 + struct mnt_namespace *old_ns;
23119 + struct uts_namespace *old_uts;
23120 + struct ipc_namespace *old_ipc;
23121 +#ifdef CONFIG_PID_NS
23122 + struct pid_namespace *old_pid;
23124 +#ifdef CONFIG_NET_NS
23125 + struct net *old_net;
23127 + struct nsproxy *nsproxy;
23129 + nsproxy = copy_nsproxy(old_nsproxy);
23133 + if (mask & CLONE_NEWNS) {
23134 + old_ns = nsproxy->mnt_ns;
23135 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
23136 + if (nsproxy->mnt_ns)
23137 + get_mnt_ns(nsproxy->mnt_ns);
23141 + if (mask & CLONE_NEWUTS) {
23142 + old_uts = nsproxy->uts_ns;
23143 + nsproxy->uts_ns = new_nsproxy->uts_ns;
23144 + if (nsproxy->uts_ns)
23145 + get_uts_ns(nsproxy->uts_ns);
23149 + if (mask & CLONE_NEWIPC) {
23150 + old_ipc = nsproxy->ipc_ns;
23151 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
23152 + if (nsproxy->ipc_ns)
23153 + get_ipc_ns(nsproxy->ipc_ns);
23157 +#ifdef CONFIG_PID_NS
23158 + if (mask & CLONE_NEWPID) {
23159 + old_pid = nsproxy->pid_ns;
23160 + nsproxy->pid_ns = new_nsproxy->pid_ns;
23161 + if (nsproxy->pid_ns)
23162 + get_pid_ns(nsproxy->pid_ns);
23166 +#ifdef CONFIG_NET_NS
23167 + if (mask & CLONE_NEWNET) {
23168 + old_net = nsproxy->net_ns;
23169 + nsproxy->net_ns = new_nsproxy->net_ns;
23170 + if (nsproxy->net_ns)
23171 + get_net(nsproxy->net_ns);
23176 + put_mnt_ns(old_ns);
23178 + put_uts_ns(old_uts);
23180 + put_ipc_ns(old_ipc);
23181 +#ifdef CONFIG_PID_NS
23183 + put_pid_ns(old_pid);
23185 +#ifdef CONFIG_NET_NS
23187 + put_net(old_net);
23195 + * merge two nsproxy structs into a new one.
23196 + * will hold a reference on the result.
23200 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
23201 + struct nsproxy *proxy, unsigned long mask)
23203 + struct nsproxy null_proxy = { .mnt_ns = NULL };
23209 + /* vs_mix_nsproxy returns with reference */
23210 + return vs_mix_nsproxy(old ? old : &null_proxy,
23213 + get_nsproxy(proxy);
23218 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23220 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
23221 + struct fs_struct *fs_cur, *fs = NULL;
23222 + struct _vx_space *space;
23223 + int ret, kill = 0;
23225 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
23226 + vxi, vxi->vx_id, mask, index);
23228 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
23231 + if (index >= VX_SPACES)
23234 + space = &vxi->space[index];
23237 + mask = space->vx_nsmask;
23239 + if ((mask & space->vx_nsmask) != mask)
23242 + if (mask & CLONE_FS) {
23243 + fs = copy_fs_struct(space->vx_fs);
23247 + proxy = space->vx_nsproxy;
23249 + vxdprintk(VXD_CBIT(space, 9),
23250 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
23251 + vxi, vxi->vx_id, mask, index, proxy, fs);
23253 + task_lock(current);
23254 + fs_cur = current->fs;
23256 + if (mask & CLONE_FS) {
23257 + spin_lock(&fs_cur->lock);
23258 + current->fs = fs;
23259 + kill = !--fs_cur->users;
23260 + spin_unlock(&fs_cur->lock);
23263 + proxy_cur = current->nsproxy;
23264 + get_nsproxy(proxy_cur);
23265 + task_unlock(current);
23268 + free_fs_struct(fs_cur);
23270 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
23271 + if (IS_ERR(proxy_new)) {
23272 + ret = PTR_ERR(proxy_new);
23276 + proxy_new = xchg(¤t->nsproxy, proxy_new);
23278 + if (mask & CLONE_NEWUSER) {
23279 + struct cred *cred;
23281 + vxdprintk(VXD_CBIT(space, 10),
23282 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
23283 + vxi, vxi->vx_id, space->vx_cred,
23284 + current->real_cred, current->cred);
23286 + if (space->vx_cred) {
23287 + cred = __prepare_creds(space->vx_cred);
23289 + commit_creds(cred);
23296 + put_nsproxy(proxy_new);
23299 + put_nsproxy(proxy_cur);
23304 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23306 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
23307 + struct fs_struct *fs_vxi, *fs;
23308 + struct _vx_space *space;
23309 + int ret, kill = 0;
23311 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
23312 + vxi, vxi->vx_id, mask, index);
23314 + if ((mask & space_mask.mask) != mask)
23317 + if (index >= VX_SPACES)
23320 + space = &vxi->space[index];
23322 + proxy_vxi = space->vx_nsproxy;
23323 + fs_vxi = space->vx_fs;
23325 + if (mask & CLONE_FS) {
23326 + fs = copy_fs_struct(current->fs);
23331 + task_lock(current);
23333 + if (mask & CLONE_FS) {
23334 + spin_lock(&fs_vxi->lock);
23335 + space->vx_fs = fs;
23336 + kill = !--fs_vxi->users;
23337 + spin_unlock(&fs_vxi->lock);
23340 + proxy_cur = current->nsproxy;
23341 + get_nsproxy(proxy_cur);
23342 + task_unlock(current);
23345 + free_fs_struct(fs_vxi);
23347 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
23348 + if (IS_ERR(proxy_new)) {
23349 + ret = PTR_ERR(proxy_new);
23353 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
23354 + space->vx_nsmask |= mask;
23356 + if (mask & CLONE_NEWUSER) {
23357 + struct cred *cred;
23359 + vxdprintk(VXD_CBIT(space, 10),
23360 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
23361 + vxi, vxi->vx_id, space->vx_cred,
23362 + current->real_cred, current->cred);
23364 + cred = prepare_creds();
23365 + cred = (struct cred *)xchg(&space->vx_cred, cred);
23367 + abort_creds(cred);
23373 + put_nsproxy(proxy_new);
23376 + put_nsproxy(proxy_cur);
23381 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
23383 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23385 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23388 + return vx_enter_space(vxi, vc_data.mask, 0);
23391 +int vc_enter_space(struct vx_info *vxi, void __user *data)
23393 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23395 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23398 + if (vc_data.index >= VX_SPACES)
23401 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
23404 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
23406 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23408 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23411 + return vx_set_space(vxi, vc_data.mask, 0);
23414 +int vc_set_space(struct vx_info *vxi, void __user *data)
23416 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23418 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23421 + if (vc_data.index >= VX_SPACES)
23424 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
23427 +int vc_get_space_mask(void __user *data, int type)
23429 + const struct vcmd_space_mask_v1 *mask;
23432 + mask = &space_mask_v0;
23433 + else if (type == 1)
23434 + mask = &space_mask;
23436 + mask = &default_space_mask;
23438 + vxdprintk(VXD_CBIT(space, 10),
23439 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
23441 + if (copy_to_user(data, mask, sizeof(*mask)))
23446 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/switch.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/switch.c
23447 --- linux-2.6.38.3/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
23448 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/switch.c 2011-04-15 16:09:19.000000000 +0200
23451 + * linux/kernel/vserver/switch.c
23453 + * Virtual Server: Syscall Switch
23455 + * Copyright (C) 2003-2007 Herbert Pötzl
23457 + * V0.01 syscall switch
23458 + * V0.02 added signal to context
23459 + * V0.03 added rlimit functions
23460 + * V0.04 added iattr, task/xid functions
23461 + * V0.05 added debug/history stuff
23462 + * V0.06 added compat32 layer
23463 + * V0.07 vcmd args and perms
23464 + * V0.08 added status commands
23465 + * V0.09 added tag commands
23466 + * V0.10 added oom bias
23467 + * V0.11 added device commands
23471 +#include <linux/vs_context.h>
23472 +#include <linux/vs_network.h>
23473 +#include <linux/vserver/switch.h>
23475 +#include "vci_config.h"
23479 +int vc_get_version(uint32_t id)
23481 + return VCI_VERSION;
23485 +int vc_get_vci(uint32_t id)
23487 + return vci_kernel_config();
23490 +#include <linux/vserver/context_cmd.h>
23491 +#include <linux/vserver/cvirt_cmd.h>
23492 +#include <linux/vserver/cacct_cmd.h>
23493 +#include <linux/vserver/limit_cmd.h>
23494 +#include <linux/vserver/network_cmd.h>
23495 +#include <linux/vserver/sched_cmd.h>
23496 +#include <linux/vserver/debug_cmd.h>
23497 +#include <linux/vserver/inode_cmd.h>
23498 +#include <linux/vserver/dlimit_cmd.h>
23499 +#include <linux/vserver/signal_cmd.h>
23500 +#include <linux/vserver/space_cmd.h>
23501 +#include <linux/vserver/tag_cmd.h>
23502 +#include <linux/vserver/device_cmd.h>
23504 +#include <linux/vserver/inode.h>
23505 +#include <linux/vserver/dlimit.h>
23508 +#ifdef CONFIG_COMPAT
23509 +#define __COMPAT(name, id, data, compat) \
23510 + (compat) ? name ## _x32(id, data) : name(id, data)
23511 +#define __COMPAT_NO_ID(name, data, compat) \
23512 + (compat) ? name ## _x32(data) : name(data)
23514 +#define __COMPAT(name, id, data, compat) \
23516 +#define __COMPAT_NO_ID(name, data, compat) \
23522 +long do_vcmd(uint32_t cmd, uint32_t id,
23523 + struct vx_info *vxi, struct nx_info *nxi,
23524 + void __user *data, int compat)
23528 + case VCMD_get_version:
23529 + return vc_get_version(id);
23530 + case VCMD_get_vci:
23531 + return vc_get_vci(id);
23533 + case VCMD_task_xid:
23534 + return vc_task_xid(id);
23535 + case VCMD_vx_info:
23536 + return vc_vx_info(vxi, data);
23538 + case VCMD_task_nid:
23539 + return vc_task_nid(id);
23540 + case VCMD_nx_info:
23541 + return vc_nx_info(nxi, data);
23543 + case VCMD_task_tag:
23544 + return vc_task_tag(id);
23546 + case VCMD_set_space_v1:
23547 + return vc_set_space_v1(vxi, data);
23548 + /* this is version 2 */
23549 + case VCMD_set_space:
23550 + return vc_set_space(vxi, data);
23552 + case VCMD_get_space_mask_v0:
23553 + return vc_get_space_mask(data, 0);
23554 + /* this is version 1 */
23555 + case VCMD_get_space_mask:
23556 + return vc_get_space_mask(data, 1);
23558 + case VCMD_get_space_default:
23559 + return vc_get_space_mask(data, -1);
23561 +#ifdef CONFIG_IA32_EMULATION
23562 + case VCMD_get_rlimit:
23563 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23564 + case VCMD_set_rlimit:
23565 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23567 + case VCMD_get_rlimit:
23568 + return vc_get_rlimit(vxi, data);
23569 + case VCMD_set_rlimit:
23570 + return vc_set_rlimit(vxi, data);
23572 + case VCMD_get_rlimit_mask:
23573 + return vc_get_rlimit_mask(id, data);
23574 + case VCMD_reset_hits:
23575 + return vc_reset_hits(vxi, data);
23576 + case VCMD_reset_minmax:
23577 + return vc_reset_minmax(vxi, data);
23579 + case VCMD_get_vhi_name:
23580 + return vc_get_vhi_name(vxi, data);
23581 + case VCMD_set_vhi_name:
23582 + return vc_set_vhi_name(vxi, data);
23584 + case VCMD_ctx_stat:
23585 + return vc_ctx_stat(vxi, data);
23586 + case VCMD_virt_stat:
23587 + return vc_virt_stat(vxi, data);
23588 + case VCMD_sock_stat:
23589 + return vc_sock_stat(vxi, data);
23590 + case VCMD_rlimit_stat:
23591 + return vc_rlimit_stat(vxi, data);
23593 + case VCMD_set_cflags:
23594 + return vc_set_cflags(vxi, data);
23595 + case VCMD_get_cflags:
23596 + return vc_get_cflags(vxi, data);
23598 + /* this is version 1 */
23599 + case VCMD_set_ccaps:
23600 + return vc_set_ccaps(vxi, data);
23601 + /* this is version 1 */
23602 + case VCMD_get_ccaps:
23603 + return vc_get_ccaps(vxi, data);
23604 + case VCMD_set_bcaps:
23605 + return vc_set_bcaps(vxi, data);
23606 + case VCMD_get_bcaps:
23607 + return vc_get_bcaps(vxi, data);
23609 + case VCMD_set_badness:
23610 + return vc_set_badness(vxi, data);
23611 + case VCMD_get_badness:
23612 + return vc_get_badness(vxi, data);
23614 + case VCMD_set_nflags:
23615 + return vc_set_nflags(nxi, data);
23616 + case VCMD_get_nflags:
23617 + return vc_get_nflags(nxi, data);
23619 + case VCMD_set_ncaps:
23620 + return vc_set_ncaps(nxi, data);
23621 + case VCMD_get_ncaps:
23622 + return vc_get_ncaps(nxi, data);
23624 + case VCMD_set_prio_bias:
23625 + return vc_set_prio_bias(vxi, data);
23626 + case VCMD_get_prio_bias:
23627 + return vc_get_prio_bias(vxi, data);
23628 + case VCMD_add_dlimit:
23629 + return __COMPAT(vc_add_dlimit, id, data, compat);
23630 + case VCMD_rem_dlimit:
23631 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23632 + case VCMD_set_dlimit:
23633 + return __COMPAT(vc_set_dlimit, id, data, compat);
23634 + case VCMD_get_dlimit:
23635 + return __COMPAT(vc_get_dlimit, id, data, compat);
23637 + case VCMD_ctx_kill:
23638 + return vc_ctx_kill(vxi, data);
23640 + case VCMD_wait_exit:
23641 + return vc_wait_exit(vxi, data);
23643 + case VCMD_get_iattr:
23644 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23645 + case VCMD_set_iattr:
23646 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23648 + case VCMD_fget_iattr:
23649 + return vc_fget_iattr(id, data);
23650 + case VCMD_fset_iattr:
23651 + return vc_fset_iattr(id, data);
23653 + case VCMD_enter_space_v0:
23654 + return vc_enter_space_v1(vxi, NULL);
23655 + case VCMD_enter_space_v1:
23656 + return vc_enter_space_v1(vxi, data);
23657 + /* this is version 2 */
23658 + case VCMD_enter_space:
23659 + return vc_enter_space(vxi, data);
23661 + case VCMD_ctx_create_v0:
23662 + return vc_ctx_create(id, NULL);
23663 + case VCMD_ctx_create:
23664 + return vc_ctx_create(id, data);
23665 + case VCMD_ctx_migrate_v0:
23666 + return vc_ctx_migrate(vxi, NULL);
23667 + case VCMD_ctx_migrate:
23668 + return vc_ctx_migrate(vxi, data);
23670 + case VCMD_net_create_v0:
23671 + return vc_net_create(id, NULL);
23672 + case VCMD_net_create:
23673 + return vc_net_create(id, data);
23674 + case VCMD_net_migrate:
23675 + return vc_net_migrate(nxi, data);
23677 + case VCMD_tag_migrate:
23678 + return vc_tag_migrate(id);
23680 + case VCMD_net_add:
23681 + return vc_net_add(nxi, data);
23682 + case VCMD_net_remove:
23683 + return vc_net_remove(nxi, data);
23685 + case VCMD_net_add_ipv4_v1:
23686 + return vc_net_add_ipv4_v1(nxi, data);
23687 + /* this is version 2 */
23688 + case VCMD_net_add_ipv4:
23689 + return vc_net_add_ipv4(nxi, data);
23691 + case VCMD_net_rem_ipv4_v1:
23692 + return vc_net_rem_ipv4_v1(nxi, data);
23693 + /* this is version 2 */
23694 + case VCMD_net_rem_ipv4:
23695 + return vc_net_rem_ipv4(nxi, data);
23696 +#ifdef CONFIG_IPV6
23697 + case VCMD_net_add_ipv6:
23698 + return vc_net_add_ipv6(nxi, data);
23699 + case VCMD_net_remove_ipv6:
23700 + return vc_net_remove_ipv6(nxi, data);
23702 +/* case VCMD_add_match_ipv4:
23703 + return vc_add_match_ipv4(nxi, data);
23704 + case VCMD_get_match_ipv4:
23705 + return vc_get_match_ipv4(nxi, data);
23706 +#ifdef CONFIG_IPV6
23707 + case VCMD_add_match_ipv6:
23708 + return vc_add_match_ipv6(nxi, data);
23709 + case VCMD_get_match_ipv6:
23710 + return vc_get_match_ipv6(nxi, data);
23713 +#ifdef CONFIG_VSERVER_DEVICE
23714 + case VCMD_set_mapping:
23715 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23716 + case VCMD_unset_mapping:
23717 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23719 +#ifdef CONFIG_VSERVER_HISTORY
23720 + case VCMD_dump_history:
23721 + return vc_dump_history(id);
23722 + case VCMD_read_history:
23723 + return __COMPAT(vc_read_history, id, data, compat);
23726 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23727 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23733 +#define __VCMD(vcmd, _perm, _args, _flags) \
23734 + case VCMD_ ## vcmd: perm = _perm; \
23735 + args = _args; flags = _flags; break
23738 +#define VCA_NONE 0x00
23739 +#define VCA_VXI 0x01
23740 +#define VCA_NXI 0x02
23742 +#define VCF_NONE 0x00
23743 +#define VCF_INFO 0x01
23744 +#define VCF_ADMIN 0x02
23745 +#define VCF_ARES 0x06 /* includes admin */
23746 +#define VCF_SETUP 0x08
23748 +#define VCF_ZIDOK 0x10 /* zero id okay */
23752 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23755 + int permit = -1, state = 0;
23756 + int perm = -1, args = 0, flags = 0;
23757 + struct vx_info *vxi = NULL;
23758 + struct nx_info *nxi = NULL;
23761 + /* unpriviledged commands */
23762 + __VCMD(get_version, 0, VCA_NONE, 0);
23763 + __VCMD(get_vci, 0, VCA_NONE, 0);
23764 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23765 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23766 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23767 + __VCMD(get_space_default,0, VCA_NONE, 0);
23769 + /* info commands */
23770 + __VCMD(task_xid, 2, VCA_NONE, 0);
23771 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23772 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23773 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23774 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23775 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23776 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23777 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23778 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23779 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23781 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23782 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23783 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23784 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23786 + __VCMD(task_nid, 2, VCA_NONE, 0);
23787 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23788 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23789 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23791 + __VCMD(task_tag, 2, VCA_NONE, 0);
23793 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23794 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23795 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23796 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23798 + /* lower admin commands */
23799 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23800 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23801 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23802 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23803 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23804 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23805 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23806 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23808 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23809 + __VCMD(net_create, 5, VCA_NONE, 0);
23810 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23812 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23814 + /* higher admin commands */
23815 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23816 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23817 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23819 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23820 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23821 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23822 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23824 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23825 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23826 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23828 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23829 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23830 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23831 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23832 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23833 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23834 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23835 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23836 +#ifdef CONFIG_IPV6
23837 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23838 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23840 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23841 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23842 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23843 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23844 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23846 +#ifdef CONFIG_VSERVER_DEVICE
23847 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23848 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23850 + /* debug level admin commands */
23851 +#ifdef CONFIG_VSERVER_HISTORY
23852 + __VCMD(dump_history, 9, VCA_NONE, 0);
23853 + __VCMD(read_history, 9, VCA_NONE, 0);
23860 + vxdprintk(VXD_CBIT(switch, 0),
23861 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23862 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23863 + VC_VERSION(cmd), id, data, compat,
23864 + perm, args, flags);
23871 + if (!capable(CAP_CONTEXT))
23875 + /* moved here from the individual commands */
23877 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23881 + /* vcmd involves resource management */
23883 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23887 + /* various legacy exceptions */
23889 + /* will go away when spectator is a cap */
23890 + case VCMD_ctx_migrate_v0:
23891 + case VCMD_ctx_migrate:
23893 + current->xid = 1;
23899 + /* will go away when spectator is a cap */
23900 + case VCMD_net_migrate:
23902 + current->nid = 1;
23909 + /* vcmds are fine by default */
23912 + /* admin type vcmds require admin ... */
23913 + if (flags & VCF_ADMIN)
23914 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23916 + /* ... but setup type vcmds override that */
23917 + if (!permit && (flags & VCF_SETUP))
23918 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23926 + if (!id && (flags & VCF_ZIDOK))
23930 + if (args & VCA_VXI) {
23931 + vxi = lookup_vx_info(id);
23935 + if ((flags & VCF_ADMIN) &&
23936 + /* special case kill for shutdown */
23937 + (cmd != VCMD_ctx_kill) &&
23938 + /* can context be administrated? */
23939 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23945 + if (args & VCA_NXI) {
23946 + nxi = lookup_nx_info(id);
23950 + if ((flags & VCF_ADMIN) &&
23951 + /* can context be administrated? */
23952 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23959 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23962 + if ((args & VCA_NXI) && nxi)
23963 + put_nx_info(nxi);
23965 + if ((args & VCA_VXI) && vxi)
23966 + put_vx_info(vxi);
23968 + vxdprintk(VXD_CBIT(switch, 1),
23969 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23970 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23971 + VC_VERSION(cmd), ret, ret, state, permit);
23976 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23978 + return do_vserver(cmd, id, data, 0);
23981 +#ifdef CONFIG_COMPAT
23984 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23986 + return do_vserver(cmd, id, data, 1);
23989 +#endif /* CONFIG_COMPAT */
23990 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/sysctl.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/sysctl.c
23991 --- linux-2.6.38.3/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23992 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/sysctl.c 2011-01-29 02:01:07.000000000 +0100
23995 + * kernel/vserver/sysctl.c
23997 + * Virtual Context Support
23999 + * Copyright (C) 2004-2007 Herbert Pötzl
24001 + * V0.01 basic structure
24005 +#include <linux/module.h>
24006 +#include <linux/ctype.h>
24007 +#include <linux/sysctl.h>
24008 +#include <linux/parser.h>
24009 +#include <asm/uaccess.h>
24012 + CTL_DEBUG_ERROR = 0,
24013 + CTL_DEBUG_SWITCH = 1,
24028 +unsigned int vx_debug_switch = 0;
24029 +unsigned int vx_debug_xid = 0;
24030 +unsigned int vx_debug_nid = 0;
24031 +unsigned int vx_debug_tag = 0;
24032 +unsigned int vx_debug_net = 0;
24033 +unsigned int vx_debug_limit = 0;
24034 +unsigned int vx_debug_cres = 0;
24035 +unsigned int vx_debug_dlim = 0;
24036 +unsigned int vx_debug_quota = 0;
24037 +unsigned int vx_debug_cvirt = 0;
24038 +unsigned int vx_debug_space = 0;
24039 +unsigned int vx_debug_misc = 0;
24042 +static struct ctl_table_header *vserver_table_header;
24043 +static ctl_table vserver_root_table[];
24046 +void vserver_register_sysctl(void)
24048 + if (!vserver_table_header) {
24049 + vserver_table_header = register_sysctl_table(vserver_root_table);
24054 +void vserver_unregister_sysctl(void)
24056 + if (vserver_table_header) {
24057 + unregister_sysctl_table(vserver_table_header);
24058 + vserver_table_header = NULL;
24063 +static int proc_dodebug(ctl_table *table, int write,
24064 + void __user *buffer, size_t *lenp, loff_t *ppos)
24066 + char tmpbuf[20], *p, c;
24067 + unsigned int value;
24068 + size_t left, len;
24070 + if ((*ppos && !write) || !*lenp) {
24078 + if (!access_ok(VERIFY_READ, buffer, left))
24080 + p = (char *)buffer;
24081 + while (left && __get_user(c, p) >= 0 && isspace(c))
24086 + if (left > sizeof(tmpbuf) - 1)
24088 + if (copy_from_user(tmpbuf, p, left))
24090 + tmpbuf[left] = '\0';
24092 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
24093 + value = 10 * value + (*p - '0');
24094 + if (*p && !isspace(*p))
24096 + while (left && isspace(*p))
24098 + *(unsigned int *)table->data = value;
24100 + if (!access_ok(VERIFY_WRITE, buffer, left))
24102 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
24105 + if (__copy_to_user(buffer, tmpbuf, len))
24107 + if ((left -= len) > 0) {
24108 + if (put_user('\n', (char *)buffer + len))
24122 +#define CTL_ENTRY(ctl, name) \
24124 + .procname = #name, \
24125 + .data = &vx_ ## name, \
24126 + .maxlen = sizeof(int), \
24128 + .proc_handler = &proc_dodebug, \
24129 + .extra1 = &zero, \
24130 + .extra2 = &zero, \
24133 +static ctl_table vserver_debug_table[] = {
24134 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
24135 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
24136 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
24137 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
24138 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
24139 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
24140 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
24141 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
24142 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
24143 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
24144 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
24145 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
24149 +static ctl_table vserver_root_table[] = {
24151 + .procname = "vserver",
24153 + .child = vserver_debug_table
24159 +static match_table_t tokens = {
24160 + { CTL_DEBUG_SWITCH, "switch=%x" },
24161 + { CTL_DEBUG_XID, "xid=%x" },
24162 + { CTL_DEBUG_NID, "nid=%x" },
24163 + { CTL_DEBUG_TAG, "tag=%x" },
24164 + { CTL_DEBUG_NET, "net=%x" },
24165 + { CTL_DEBUG_LIMIT, "limit=%x" },
24166 + { CTL_DEBUG_CRES, "cres=%x" },
24167 + { CTL_DEBUG_DLIM, "dlim=%x" },
24168 + { CTL_DEBUG_QUOTA, "quota=%x" },
24169 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
24170 + { CTL_DEBUG_SPACE, "space=%x" },
24171 + { CTL_DEBUG_MISC, "misc=%x" },
24172 + { CTL_DEBUG_ERROR, NULL }
24175 +#define HANDLE_CASE(id, name, val) \
24176 + case CTL_DEBUG_ ## id: \
24177 + vx_debug_ ## name = val; \
24178 + printk("vs_debug_" #name "=0x%x\n", val); \
24182 +static int __init vs_debug_setup(char *str)
24187 + printk("vs_debug_setup(%s)\n", str);
24188 + while ((p = strsep(&str, ",")) != NULL) {
24189 + substring_t args[MAX_OPT_ARGS];
24190 + unsigned int value;
24195 + token = match_token(p, tokens, args);
24196 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
24199 + HANDLE_CASE(SWITCH, switch, value);
24200 + HANDLE_CASE(XID, xid, value);
24201 + HANDLE_CASE(NID, nid, value);
24202 + HANDLE_CASE(TAG, tag, value);
24203 + HANDLE_CASE(NET, net, value);
24204 + HANDLE_CASE(LIMIT, limit, value);
24205 + HANDLE_CASE(CRES, cres, value);
24206 + HANDLE_CASE(DLIM, dlim, value);
24207 + HANDLE_CASE(QUOTA, quota, value);
24208 + HANDLE_CASE(CVIRT, cvirt, value);
24209 + HANDLE_CASE(SPACE, space, value);
24210 + HANDLE_CASE(MISC, misc, value);
24219 +__setup("vsdebug=", vs_debug_setup);
24223 +EXPORT_SYMBOL_GPL(vx_debug_switch);
24224 +EXPORT_SYMBOL_GPL(vx_debug_xid);
24225 +EXPORT_SYMBOL_GPL(vx_debug_nid);
24226 +EXPORT_SYMBOL_GPL(vx_debug_net);
24227 +EXPORT_SYMBOL_GPL(vx_debug_limit);
24228 +EXPORT_SYMBOL_GPL(vx_debug_cres);
24229 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
24230 +EXPORT_SYMBOL_GPL(vx_debug_quota);
24231 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
24232 +EXPORT_SYMBOL_GPL(vx_debug_space);
24233 +EXPORT_SYMBOL_GPL(vx_debug_misc);
24235 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/tag.c linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/tag.c
24236 --- linux-2.6.38.3/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
24237 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/tag.c 2011-03-22 17:43:07.000000000 +0100
24240 + * linux/kernel/vserver/tag.c
24242 + * Virtual Server: Shallow Tag Space
24244 + * Copyright (C) 2007 Herbert Pötzl
24246 + * V0.01 basic implementation
24250 +#include <linux/sched.h>
24251 +#include <linux/vserver/debug.h>
24252 +#include <linux/vs_pid.h>
24253 +#include <linux/vs_tag.h>
24255 +#include <linux/vserver/tag_cmd.h>
24258 +int dx_migrate_task(struct task_struct *p, tag_t tag)
24263 + vxdprintk(VXD_CBIT(tag, 5),
24264 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
24270 + vxdprintk(VXD_CBIT(tag, 5),
24271 + "moved task %p into [#%d]", p, tag);
24275 +/* vserver syscall commands below here */
24277 +/* taks xid and vx_info functions */
24280 +int vc_task_tag(uint32_t id)
24285 + struct task_struct *tsk;
24287 + tsk = find_task_by_real_pid(id);
24288 + tag = (tsk) ? tsk->tag : -ESRCH;
24289 + rcu_read_unlock();
24291 + tag = dx_current_tag();
24296 +int vc_tag_migrate(uint32_t tag)
24298 + return dx_migrate_task(current, tag & 0xFFFF);
24302 diff -NurpP --minimal linux-2.6.38.3/kernel/vserver/vci_config.h linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/vci_config.h
24303 --- linux-2.6.38.3/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
24304 +++ linux-2.6.38.3-vs2.3.0.37-rc14/kernel/vserver/vci_config.h 2011-04-15 16:25:52.000000000 +0200
24307 +/* interface version */
24309 +#define VCI_VERSION 0x00020308
24313 + VCI_KCBIT_NO_DYNAMIC = 0,
24315 + VCI_KCBIT_PROC_SECURE = 4,
24316 + /* VCI_KCBIT_HARDCPU = 5, */
24317 + /* VCI_KCBIT_IDLELIMIT = 6, */
24318 + /* VCI_KCBIT_IDLETIME = 7, */
24320 + VCI_KCBIT_COWBL = 8,
24321 + VCI_KCBIT_FULLCOWBL = 9,
24322 + VCI_KCBIT_SPACES = 10,
24323 + VCI_KCBIT_NETV2 = 11,
24324 + VCI_KCBIT_MEMCG = 12,
24326 + VCI_KCBIT_DEBUG = 16,
24327 + VCI_KCBIT_HISTORY = 20,
24328 + VCI_KCBIT_TAGGED = 24,
24329 + VCI_KCBIT_PPTAG = 28,
24331 + VCI_KCBIT_MORE = 31,
24335 +static inline uint32_t vci_kernel_config(void)
24338 + (1 << VCI_KCBIT_NO_DYNAMIC) |
24340 + /* configured features */
24341 +#ifdef CONFIG_VSERVER_PROC_SECURE
24342 + (1 << VCI_KCBIT_PROC_SECURE) |
24344 +#ifdef CONFIG_VSERVER_COWBL
24345 + (1 << VCI_KCBIT_COWBL) |
24346 + (1 << VCI_KCBIT_FULLCOWBL) |
24348 + (1 << VCI_KCBIT_SPACES) |
24349 + (1 << VCI_KCBIT_NETV2) |
24350 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
24351 + (1 << VCI_KCBIT_MEMCG) |
24354 + /* debug options */
24355 +#ifdef CONFIG_VSERVER_DEBUG
24356 + (1 << VCI_KCBIT_DEBUG) |
24358 +#ifdef CONFIG_VSERVER_HISTORY
24359 + (1 << VCI_KCBIT_HISTORY) |
24362 + /* inode context tagging */
24363 +#if defined(CONFIG_TAGGING_NONE)
24364 + (0 << VCI_KCBIT_TAGGED) |
24365 +#elif defined(CONFIG_TAGGING_UID16)
24366 + (1 << VCI_KCBIT_TAGGED) |
24367 +#elif defined(CONFIG_TAGGING_GID16)
24368 + (2 << VCI_KCBIT_TAGGED) |
24369 +#elif defined(CONFIG_TAGGING_ID24)
24370 + (3 << VCI_KCBIT_TAGGED) |
24371 +#elif defined(CONFIG_TAGGING_INTERN)
24372 + (4 << VCI_KCBIT_TAGGED) |
24373 +#elif defined(CONFIG_TAGGING_RUNTIME)
24374 + (5 << VCI_KCBIT_TAGGED) |
24376 + (7 << VCI_KCBIT_TAGGED) |
24378 + (1 << VCI_KCBIT_PPTAG) |
24382 diff -NurpP --minimal linux-2.6.38.3/mm/filemap_xip.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/filemap_xip.c
24383 --- linux-2.6.38.3/mm/filemap_xip.c 2010-07-07 18:31:58.000000000 +0200
24384 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/filemap_xip.c 2011-01-29 02:01:07.000000000 +0100
24386 #include <linux/seqlock.h>
24387 #include <linux/mutex.h>
24388 #include <linux/gfp.h>
24389 +#include <linux/vs_memory.h>
24390 #include <asm/tlbflush.h>
24391 #include <asm/io.h>
24393 diff -NurpP --minimal linux-2.6.38.3/mm/fremap.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/fremap.c
24394 --- linux-2.6.38.3/mm/fremap.c 2010-10-21 13:07:57.000000000 +0200
24395 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/fremap.c 2011-01-29 02:01:07.000000000 +0100
24397 #include <linux/module.h>
24398 #include <linux/syscalls.h>
24399 #include <linux/mmu_notifier.h>
24400 +#include <linux/vs_memory.h>
24402 #include <asm/mmu_context.h>
24403 #include <asm/cacheflush.h>
24404 diff -NurpP --minimal linux-2.6.38.3/mm/hugetlb.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/hugetlb.c
24405 --- linux-2.6.38.3/mm/hugetlb.c 2011-03-15 18:07:42.000000000 +0100
24406 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/hugetlb.c 2011-01-29 02:01:07.000000000 +0100
24409 #include <linux/hugetlb.h>
24410 #include <linux/node.h>
24411 +#include <linux/vs_memory.h>
24412 #include "internal.h"
24414 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
24415 diff -NurpP --minimal linux-2.6.38.3/mm/memcontrol.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/memcontrol.c
24416 --- linux-2.6.38.3/mm/memcontrol.c 2011-03-15 18:07:42.000000000 +0100
24417 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/memcontrol.c 2011-02-17 02:17:51.000000000 +0100
24418 @@ -681,6 +681,31 @@ struct mem_cgroup *mem_cgroup_from_task(
24419 struct mem_cgroup, css);
24422 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
24424 + return res_counter_read_u64(&mem->res, member);
24427 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
24429 + return res_counter_read_u64(&mem->memsw, member);
24432 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
24434 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
24437 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
24439 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
24442 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
24444 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
24447 static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
24449 struct mem_cgroup *mem = NULL;
24450 diff -NurpP --minimal linux-2.6.38.3/mm/memory.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/memory.c
24451 --- linux-2.6.38.3/mm/memory.c 2011-03-15 18:07:42.000000000 +0100
24452 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/memory.c 2011-03-07 16:53:28.000000000 +0100
24453 @@ -3225,6 +3225,7 @@ int handle_pte_fault(struct mm_struct *m
24457 + int ret = 0, type = VXPT_UNKNOWN;
24460 if (!pte_present(entry)) {
24461 @@ -3249,9 +3250,12 @@ int handle_pte_fault(struct mm_struct *m
24462 if (unlikely(!pte_same(*pte, entry)))
24464 if (flags & FAULT_FLAG_WRITE) {
24465 - if (!pte_write(entry))
24466 - return do_wp_page(mm, vma, address,
24467 + if (!pte_write(entry)) {
24468 + ret = do_wp_page(mm, vma, address,
24469 pte, pmd, ptl, entry);
24470 + type = VXPT_WRITE;
24473 entry = pte_mkdirty(entry);
24475 entry = pte_mkyoung(entry);
24476 @@ -3269,7 +3273,10 @@ int handle_pte_fault(struct mm_struct *m
24479 pte_unmap_unlock(pte, ptl);
24483 + vx_page_fault(mm, vma, type, ret);
24488 diff -NurpP --minimal linux-2.6.38.3/mm/mremap.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/mremap.c
24489 --- linux-2.6.38.3/mm/mremap.c 2011-04-15 10:30:30.000000000 +0200
24490 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/mremap.c 2011-04-15 10:33:41.000000000 +0200
24492 #include <linux/security.h>
24493 #include <linux/syscalls.h>
24494 #include <linux/mmu_notifier.h>
24495 +#include <linux/vs_memory.h>
24497 #include <asm/uaccess.h>
24498 #include <asm/cacheflush.h>
24499 diff -NurpP --minimal linux-2.6.38.3/mm/oom_kill.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/oom_kill.c
24500 --- linux-2.6.38.3/mm/oom_kill.c 2011-04-15 10:30:30.000000000 +0200
24501 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/oom_kill.c 2011-03-28 15:00:55.000000000 +0200
24503 #include <linux/mempolicy.h>
24504 #include <linux/security.h>
24505 #include <linux/ptrace.h>
24506 +#include <linux/reboot.h>
24507 +#include <linux/vs_memory.h>
24508 +#include <linux/vs_context.h>
24510 int sysctl_panic_on_oom;
24511 int sysctl_oom_kill_allocating_task;
24512 @@ -125,11 +128,18 @@ struct task_struct *find_lock_task_mm(st
24513 static bool oom_unkillable_task(struct task_struct *p,
24514 const struct mem_cgroup *mem, const nodemask_t *nodemask)
24516 - if (is_global_init(p))
24517 + unsigned xid = vx_current_xid();
24519 + /* skip the init task, global and per guest */
24520 + if (task_is_init(p))
24522 if (p->flags & PF_KTHREAD)
24525 + /* skip other guest and host processes if oom in guest */
24526 + if (xid && vx_task_xid(p) != xid)
24529 /* When mem_cgroup_out_of_memory() and p is not member of the group */
24530 if (mem && !task_in_mem_cgroup(p, mem))
24532 @@ -211,6 +221,18 @@ unsigned int oom_badness(struct task_str
24533 points += p->signal->oom_score_adj;
24536 + * add points for context badness and
24537 + * reduce badness for processes belonging to
24538 + * a different context
24541 + points += vx_badness(p, p->mm);
24543 + if ((vx_current_xid() > 1) &&
24544 + vx_current_xid() != vx_task_xid(p))
24548 * Never return 0 for an eligible task that may be killed since it's
24549 * possible that no single user task uses more than 0.1% of memory and
24550 * no single admin tasks uses more than 3.0%.
24551 @@ -424,8 +446,8 @@ static int oom_kill_task(struct task_str
24552 /* mm cannot be safely dereferenced after task_unlock(p) */
24555 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24556 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
24557 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24558 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
24559 K(get_mm_counter(p->mm, MM_ANONPAGES)),
24560 K(get_mm_counter(p->mm, MM_FILEPAGES)));
24562 @@ -487,8 +509,8 @@ static int oom_kill_process(struct task_
24566 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
24567 - message, task_pid_nr(p), p->comm, points);
24568 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
24569 + message, task_pid_nr(p), p->xid, p->comm, points);
24573 @@ -579,6 +601,8 @@ int unregister_oom_notifier(struct notif
24575 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
24577 +long vs_oom_action(unsigned int);
24580 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
24581 * if a parallel OOM killing is already taking place that includes a zone in
24582 @@ -738,7 +762,12 @@ retry:
24584 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
24585 read_unlock(&tasklist_lock);
24586 - panic("Out of memory and no killable processes...\n");
24588 + /* avoid panic for guest OOM */
24589 + if (current->xid)
24590 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
24592 + panic("Out of memory and no killable processes...\n");
24595 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
24596 diff -NurpP --minimal linux-2.6.38.3/mm/page_alloc.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/page_alloc.c
24597 --- linux-2.6.38.3/mm/page_alloc.c 2011-04-15 10:30:30.000000000 +0200
24598 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/page_alloc.c 2011-03-28 15:00:14.000000000 +0200
24600 #include <linux/compaction.h>
24601 #include <trace/events/kmem.h>
24602 #include <linux/ftrace_event.h>
24603 +#include <linux/vs_base.h>
24604 +#include <linux/vs_limit.h>
24606 #include <asm/tlbflush.h>
24607 #include <asm/div64.h>
24608 @@ -2388,6 +2390,9 @@ void si_meminfo(struct sysinfo *val)
24609 val->totalhigh = totalhigh_pages;
24610 val->freehigh = nr_free_highpages();
24611 val->mem_unit = PAGE_SIZE;
24613 + if (vx_flags(VXF_VIRT_MEM, 0))
24614 + vx_vsi_meminfo(val);
24617 EXPORT_SYMBOL(si_meminfo);
24618 @@ -2408,6 +2413,9 @@ void si_meminfo_node(struct sysinfo *val
24621 val->mem_unit = PAGE_SIZE;
24623 + if (vx_flags(VXF_VIRT_MEM, 0))
24624 + vx_vsi_meminfo(val);
24628 diff -NurpP --minimal linux-2.6.38.3/mm/pgtable-generic.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/pgtable-generic.c
24629 --- linux-2.6.38.3/mm/pgtable-generic.c 2011-03-15 18:07:42.000000000 +0100
24630 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/pgtable-generic.c 2011-02-02 22:20:27.000000000 +0100
24632 * Copyright (C) 2010 Linus Torvalds
24635 +#include <linux/mm.h>
24637 #include <linux/pagemap.h>
24638 #include <asm/tlb.h>
24639 #include <asm-generic/pgtable.h>
24640 diff -NurpP --minimal linux-2.6.38.3/mm/rmap.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/rmap.c
24641 --- linux-2.6.38.3/mm/rmap.c 2011-03-15 18:07:42.000000000 +0100
24642 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/rmap.c 2011-03-15 18:15:06.000000000 +0100
24644 #include <linux/mmu_notifier.h>
24645 #include <linux/migrate.h>
24646 #include <linux/hugetlb.h>
24647 +#include <linux/vs_memory.h>
24649 #include <asm/tlbflush.h>
24651 diff -NurpP --minimal linux-2.6.38.3/mm/shmem.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/shmem.c
24652 --- linux-2.6.38.3/mm/shmem.c 2011-04-15 10:30:30.000000000 +0200
24653 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/shmem.c 2011-03-28 15:00:14.000000000 +0200
24654 @@ -1816,7 +1816,7 @@ static int shmem_statfs(struct dentry *d
24656 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24658 - buf->f_type = TMPFS_MAGIC;
24659 + buf->f_type = TMPFS_SUPER_MAGIC;
24660 buf->f_bsize = PAGE_CACHE_SIZE;
24661 buf->f_namelen = NAME_MAX;
24662 if (sbinfo->max_blocks) {
24663 @@ -2378,7 +2378,7 @@ int shmem_fill_super(struct super_block
24664 sb->s_maxbytes = SHMEM_MAX_BYTES;
24665 sb->s_blocksize = PAGE_CACHE_SIZE;
24666 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24667 - sb->s_magic = TMPFS_MAGIC;
24668 + sb->s_magic = TMPFS_SUPER_MAGIC;
24669 sb->s_op = &shmem_ops;
24670 sb->s_time_gran = 1;
24671 #ifdef CONFIG_TMPFS_POSIX_ACL
24672 diff -NurpP --minimal linux-2.6.38.3/mm/slab.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/slab.c
24673 --- linux-2.6.38.3/mm/slab.c 2011-04-15 10:30:30.000000000 +0200
24674 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/slab.c 2011-03-28 15:00:14.000000000 +0200
24675 @@ -407,6 +407,8 @@ static void kmem_list3_init(struct kmem_
24676 #define STATS_INC_FREEMISS(x) do { } while (0)
24679 +#include "slab_vs.h"
24684 @@ -3346,6 +3348,7 @@ retry:
24686 obj = slab_get_obj(cachep, slabp, nodeid);
24687 check_slabp(cachep, slabp);
24688 + vx_slab_alloc(cachep, flags);
24689 l3->free_objects--;
24690 /* move slabp to correct slabp list: */
24691 list_del(&slabp->list);
24692 @@ -3423,6 +3426,7 @@ __cache_alloc_node(struct kmem_cache *ca
24693 /* ___cache_alloc_node can fall back to other nodes */
24694 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24696 + vx_slab_alloc(cachep, flags);
24697 local_irq_restore(save_flags);
24698 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24699 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24700 @@ -3609,6 +3613,7 @@ static inline void __cache_free(struct k
24702 kmemleak_free_recursive(objp, cachep->flags);
24703 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
24704 + vx_slab_free(cachep);
24706 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24708 diff -NurpP --minimal linux-2.6.38.3/mm/slab_vs.h linux-2.6.38.3-vs2.3.0.37-rc14/mm/slab_vs.h
24709 --- linux-2.6.38.3/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24710 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/slab_vs.h 2011-01-29 02:01:07.000000000 +0100
24713 +#include <linux/vserver/context.h>
24715 +#include <linux/vs_context.h>
24718 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24720 + int what = gfp_zone(cachep->gfpflags);
24721 + struct vx_info *vxi = current_vx_info();
24726 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24730 +void vx_slab_free(struct kmem_cache *cachep)
24732 + int what = gfp_zone(cachep->gfpflags);
24733 + struct vx_info *vxi = current_vx_info();
24738 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24741 diff -NurpP --minimal linux-2.6.38.3/mm/swapfile.c linux-2.6.38.3-vs2.3.0.37-rc14/mm/swapfile.c
24742 --- linux-2.6.38.3/mm/swapfile.c 2011-04-15 10:30:30.000000000 +0200
24743 +++ linux-2.6.38.3-vs2.3.0.37-rc14/mm/swapfile.c 2011-03-28 15:00:14.000000000 +0200
24745 #include <asm/tlbflush.h>
24746 #include <linux/swapops.h>
24747 #include <linux/page_cgroup.h>
24748 +#include <linux/vs_base.h>
24749 +#include <linux/vs_memory.h>
24751 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24753 @@ -1775,6 +1777,16 @@ static int swap_show(struct seq_file *sw
24755 if (si == SEQ_START_TOKEN) {
24756 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24757 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24758 + struct sysinfo si;
24760 + vx_vsi_swapinfo(&si);
24761 + if (si.totalswap < (1 << 10))
24763 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24764 + "hdv0", "partition", si.totalswap >> 10,
24765 + (si.totalswap - si.freeswap) >> 10, -1);
24770 @@ -2186,6 +2198,8 @@ void si_swapinfo(struct sysinfo *val)
24771 val->freeswap = nr_swap_pages + nr_to_be_unused;
24772 val->totalswap = total_swap_pages + nr_to_be_unused;
24773 spin_unlock(&swap_lock);
24774 + if (vx_flags(VXF_VIRT_MEM, 0))
24775 + vx_vsi_swapinfo(val);
24779 diff -NurpP --minimal linux-2.6.38.3/net/bridge/br_multicast.c linux-2.6.38.3-vs2.3.0.37-rc14/net/bridge/br_multicast.c
24780 --- linux-2.6.38.3/net/bridge/br_multicast.c 2011-03-15 18:07:44.000000000 +0100
24781 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/bridge/br_multicast.c 2011-03-10 16:51:08.000000000 +0100
24782 @@ -446,7 +446,7 @@ static struct sk_buff *br_ip6_multicast_
24783 ip6h->nexthdr = IPPROTO_HOPOPTS;
24784 ip6h->hop_limit = 1;
24785 ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24787 + &ip6h->saddr, NULL);
24788 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24789 ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
24791 diff -NurpP --minimal linux-2.6.38.3/net/core/dev.c linux-2.6.38.3-vs2.3.0.37-rc14/net/core/dev.c
24792 --- linux-2.6.38.3/net/core/dev.c 2011-03-15 18:07:44.000000000 +0100
24793 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/core/dev.c 2011-03-15 18:15:06.000000000 +0100
24794 @@ -127,6 +127,7 @@
24795 #include <linux/in.h>
24796 #include <linux/jhash.h>
24797 #include <linux/random.h>
24798 +#include <linux/vs_inet.h>
24799 #include <trace/events/napi.h>
24800 #include <trace/events/net.h>
24801 #include <trace/events/skb.h>
24802 @@ -608,7 +609,8 @@ struct net_device *__dev_get_by_name(str
24803 struct hlist_head *head = dev_name_hash(net, name);
24805 hlist_for_each_entry(dev, p, head, name_hlist)
24806 - if (!strncmp(dev->name, name, IFNAMSIZ))
24807 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24808 + nx_dev_visible(current_nx_info(), dev))
24812 @@ -634,7 +636,8 @@ struct net_device *dev_get_by_name_rcu(s
24813 struct hlist_head *head = dev_name_hash(net, name);
24815 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24816 - if (!strncmp(dev->name, name, IFNAMSIZ))
24817 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24818 + nx_dev_visible(current_nx_info(), dev))
24822 @@ -685,7 +688,8 @@ struct net_device *__dev_get_by_index(st
24823 struct hlist_head *head = dev_index_hash(net, ifindex);
24825 hlist_for_each_entry(dev, p, head, index_hlist)
24826 - if (dev->ifindex == ifindex)
24827 + if ((dev->ifindex == ifindex) &&
24828 + nx_dev_visible(current_nx_info(), dev))
24832 @@ -710,7 +714,8 @@ struct net_device *dev_get_by_index_rcu(
24833 struct hlist_head *head = dev_index_hash(net, ifindex);
24835 hlist_for_each_entry_rcu(dev, p, head, index_hlist)
24836 - if (dev->ifindex == ifindex)
24837 + if ((dev->ifindex == ifindex) &&
24838 + nx_dev_visible(current_nx_info(), dev))
24842 @@ -763,7 +768,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24844 for_each_netdev_rcu(net, dev)
24845 if (dev->type == type &&
24846 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24847 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24848 + nx_dev_visible(current_nx_info(), dev))
24852 @@ -775,9 +781,11 @@ struct net_device *__dev_getfirstbyhwtyp
24853 struct net_device *dev;
24856 - for_each_netdev(net, dev)
24857 - if (dev->type == type)
24858 + for_each_netdev(net, dev) {
24859 + if ((dev->type == type) &&
24860 + nx_dev_visible(current_nx_info(), dev))
24866 @@ -895,6 +903,8 @@ static int __dev_alloc_name(struct net *
24868 if (i < 0 || i >= max_netdevices)
24870 + if (!nx_dev_visible(current_nx_info(), d))
24873 /* avoid cases where sscanf is not exact inverse of printf */
24874 snprintf(buf, IFNAMSIZ, name, i);
24875 @@ -3873,6 +3883,8 @@ static int dev_ifconf(struct net *net, c
24878 for_each_netdev(net, dev) {
24879 + if (!nx_dev_visible(current_nx_info(), dev))
24881 for (i = 0; i < NPROTO; i++) {
24882 if (gifconf_list[i]) {
24884 @@ -3944,6 +3956,10 @@ static void dev_seq_printf_stats(struct
24885 struct rtnl_link_stats64 temp;
24886 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24888 + /* device visible inside network context? */
24889 + if (!nx_dev_visible(current_nx_info(), dev))
24892 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24893 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24894 dev->name, stats->rx_bytes, stats->rx_packets,
24895 diff -NurpP --minimal linux-2.6.38.3/net/core/rtnetlink.c linux-2.6.38.3-vs2.3.0.37-rc14/net/core/rtnetlink.c
24896 --- linux-2.6.38.3/net/core/rtnetlink.c 2011-03-15 18:07:44.000000000 +0100
24897 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/core/rtnetlink.c 2011-02-17 02:17:52.000000000 +0100
24898 @@ -1012,6 +1012,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24899 hlist_for_each_entry(dev, node, head, index_hlist) {
24902 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24904 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24905 NETLINK_CB(cb->skb).pid,
24906 cb->nlh->nlmsg_seq, 0,
24907 @@ -1771,6 +1773,9 @@ void rtmsg_ifinfo(int type, struct net_d
24908 struct sk_buff *skb;
24909 int err = -ENOBUFS;
24911 + if (!nx_dev_visible(current_nx_info(), dev))
24914 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
24917 diff -NurpP --minimal linux-2.6.38.3/net/core/sock.c linux-2.6.38.3-vs2.3.0.37-rc14/net/core/sock.c
24918 --- linux-2.6.38.3/net/core/sock.c 2011-03-15 18:07:44.000000000 +0100
24919 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/core/sock.c 2011-01-29 02:01:07.000000000 +0100
24920 @@ -127,6 +127,10 @@
24921 #include <net/cls_cgroup.h>
24923 #include <linux/filter.h>
24924 +#include <linux/vs_socket.h>
24925 +#include <linux/vs_limit.h>
24926 +#include <linux/vs_context.h>
24927 +#include <linux/vs_network.h>
24930 #include <net/tcp.h>
24931 @@ -1070,6 +1074,8 @@ static struct sock *sk_prot_alloc(struct
24933 sk_tx_queue_clear(sk);
24935 + sock_vx_init(sk);
24936 + sock_nx_init(sk);
24940 @@ -1169,6 +1175,11 @@ static void __sk_free(struct sock *sk)
24941 put_cred(sk->sk_peer_cred);
24942 put_pid(sk->sk_peer_pid);
24943 put_net(sock_net(sk));
24945 + clr_vx_info(&sk->sk_vx_info);
24947 + clr_nx_info(&sk->sk_nx_info);
24949 sk_prot_free(sk->sk_prot_creator, sk);
24952 @@ -1216,6 +1227,8 @@ struct sock *sk_clone(const struct sock
24955 get_net(sock_net(newsk));
24956 + sock_vx_init(newsk);
24957 + sock_nx_init(newsk);
24958 sk_node_init(&newsk->sk_node);
24959 sock_lock_init(newsk);
24960 bh_lock_sock(newsk);
24961 @@ -1271,6 +1284,12 @@ struct sock *sk_clone(const struct sock
24963 atomic_set(&newsk->sk_refcnt, 2);
24965 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24966 + newsk->sk_xid = sk->sk_xid;
24967 + vx_sock_inc(newsk);
24968 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24969 + newsk->sk_nid = sk->sk_nid;
24972 * Increment the counter in the same struct proto as the master
24973 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24974 @@ -2017,6 +2036,12 @@ void sock_init_data(struct socket *sock,
24976 sk->sk_stamp = ktime_set(-1L, 0);
24978 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24979 + sk->sk_xid = vx_current_xid();
24981 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24982 + sk->sk_nid = nx_current_nid();
24985 * Before updating sk_refcnt, we must commit prior changes to memory
24986 * (Documentation/RCU/rculist_nulls.txt for details)
24987 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/af_inet.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/af_inet.c
24988 --- linux-2.6.38.3/net/ipv4/af_inet.c 2011-03-15 18:07:45.000000000 +0100
24989 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/af_inet.c 2011-02-17 02:17:52.000000000 +0100
24990 @@ -116,6 +116,7 @@
24991 #ifdef CONFIG_IP_MROUTE
24992 #include <linux/mroute.h>
24994 +#include <linux/vs_limit.h>
24997 /* The inetsw table contains everything that inet_create needs to
24998 @@ -325,9 +326,13 @@ lookup_protocol:
25002 + if ((protocol == IPPROTO_ICMP) &&
25003 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25006 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25007 goto out_rcu_unlock;
25010 err = -EAFNOSUPPORT;
25011 if (!inet_netns_ok(net, protocol))
25012 goto out_rcu_unlock;
25013 @@ -451,6 +456,7 @@ int inet_bind(struct socket *sock, struc
25014 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
25015 struct sock *sk = sock->sk;
25016 struct inet_sock *inet = inet_sk(sk);
25017 + struct nx_v4_sock_addr nsa;
25018 unsigned short snum;
25021 @@ -464,7 +470,11 @@ int inet_bind(struct socket *sock, struc
25022 if (addr_len < sizeof(struct sockaddr_in))
25025 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25026 + err = v4_map_sock_addr(inet, addr, &nsa);
25030 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25032 /* Not specified by any standard per-se, however it breaks too
25033 * many applications when removed. It is unfortunate since
25034 @@ -476,7 +486,7 @@ int inet_bind(struct socket *sock, struc
25035 err = -EADDRNOTAVAIL;
25036 if (!sysctl_ip_nonlocal_bind &&
25037 !(inet->freebind || inet->transparent) &&
25038 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
25039 + nsa.saddr != htonl(INADDR_ANY) &&
25040 chk_addr_ret != RTN_LOCAL &&
25041 chk_addr_ret != RTN_MULTICAST &&
25042 chk_addr_ret != RTN_BROADCAST)
25043 @@ -501,7 +511,7 @@ int inet_bind(struct socket *sock, struc
25044 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
25045 goto out_release_sock;
25047 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
25048 + v4_set_sock_addr(inet, &nsa);
25049 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25050 inet->inet_saddr = 0; /* Use device */
25052 @@ -703,11 +713,13 @@ int inet_getname(struct socket *sock, st
25055 sin->sin_port = inet->inet_dport;
25056 - sin->sin_addr.s_addr = inet->inet_daddr;
25057 + sin->sin_addr.s_addr =
25058 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
25060 __be32 addr = inet->inet_rcv_saddr;
25062 addr = inet->inet_saddr;
25063 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
25064 sin->sin_port = inet->inet_sport;
25065 sin->sin_addr.s_addr = addr;
25067 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/devinet.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/devinet.c
25068 --- linux-2.6.38.3/net/ipv4/devinet.c 2011-03-15 18:07:45.000000000 +0100
25069 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/devinet.c 2011-03-15 18:15:06.000000000 +0100
25070 @@ -420,6 +420,7 @@ struct in_device *inetdev_by_index(struc
25072 EXPORT_SYMBOL(inetdev_by_index);
25075 /* Called only from RTNL semaphored context. No locks. */
25077 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
25078 @@ -660,6 +661,8 @@ int devinet_ioctl(struct net *net, unsig
25080 in_dev = __in_dev_get_rtnl(dev);
25082 + struct nx_info *nxi = current_nx_info();
25084 if (tryaddrmatch) {
25085 /* Matthias Andree */
25086 /* compare label and address (4.4BSD style) */
25087 @@ -668,6 +671,8 @@ int devinet_ioctl(struct net *net, unsig
25088 This is checked above. */
25089 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
25090 ifap = &ifa->ifa_next) {
25091 + if (!nx_v4_ifa_visible(nxi, ifa))
25093 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
25094 sin_orig.sin_addr.s_addr ==
25096 @@ -680,9 +685,12 @@ int devinet_ioctl(struct net *net, unsig
25097 comparing just the label */
25099 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
25100 - ifap = &ifa->ifa_next)
25101 + ifap = &ifa->ifa_next) {
25102 + if (!nx_v4_ifa_visible(nxi, ifa))
25104 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
25110 @@ -834,6 +842,8 @@ static int inet_gifconf(struct net_devic
25113 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
25114 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
25117 done += sizeof(ifr);
25119 @@ -1193,6 +1203,7 @@ static int inet_dump_ifaddr(struct sk_bu
25120 struct net_device *dev;
25121 struct in_device *in_dev;
25122 struct in_ifaddr *ifa;
25123 + struct sock *sk = skb->sk;
25124 struct hlist_head *head;
25125 struct hlist_node *node;
25127 @@ -1215,6 +1226,8 @@ static int inet_dump_ifaddr(struct sk_bu
25129 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
25130 ifa = ifa->ifa_next, ip_idx++) {
25131 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
25133 if (ip_idx < s_ip_idx)
25135 if (inet_fill_ifaddr(skb, ifa,
25136 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/fib_hash.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/fib_hash.c
25137 --- linux-2.6.38.3/net/ipv4/fib_hash.c 2011-01-05 21:50:41.000000000 +0100
25138 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/fib_hash.c 2011-01-29 02:01:07.000000000 +0100
25139 @@ -1080,7 +1080,7 @@ static int fib_seq_show(struct seq_file
25140 prefix = f->fn_key;
25141 mask = FZ_MASK(iter->zone);
25142 flags = fib_flag_trans(fa->fa_type, mask, fi);
25144 + if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
25146 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
25147 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
25148 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/inet_connection_sock.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/inet_connection_sock.c
25149 --- linux-2.6.38.3/net/ipv4/inet_connection_sock.c 2011-03-15 18:07:45.000000000 +0100
25150 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/inet_connection_sock.c 2011-01-29 05:17:31.000000000 +0100
25151 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
25153 EXPORT_SYMBOL(inet_get_local_port_range);
25155 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25157 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
25158 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
25160 + if (inet_v6_ipv6only(sk2))
25163 + if (sk1_rcv_saddr &&
25165 + sk1_rcv_saddr == sk2_rcv_saddr)
25168 + if (sk1_rcv_saddr &&
25169 + !sk2_rcv_saddr &&
25170 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
25173 + if (sk2_rcv_saddr &&
25174 + !sk1_rcv_saddr &&
25175 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
25178 + if (!sk1_rcv_saddr &&
25179 + !sk2_rcv_saddr &&
25180 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
25186 int inet_csk_bind_conflict(const struct sock *sk,
25187 const struct inet_bind_bucket *tb)
25189 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct
25190 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
25191 if (!reuse || !sk2->sk_reuse ||
25192 ((1 << sk2->sk_state) & (TCPF_LISTEN | TCPF_CLOSE))) {
25193 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25194 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
25195 - sk2_rcv_saddr == sk_rcv_saddr(sk))
25196 + if (ipv4_rcv_saddr_equal(sk, sk2))
25200 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/inet_diag.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/inet_diag.c
25201 --- linux-2.6.38.3/net/ipv4/inet_diag.c 2011-01-05 21:50:42.000000000 +0100
25202 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/inet_diag.c 2011-01-29 02:01:07.000000000 +0100
25204 #include <linux/stddef.h>
25206 #include <linux/inet_diag.h>
25207 +#include <linux/vs_network.h>
25208 +#include <linux/vs_inet.h>
25210 static const struct inet_diag_handler **inet_diag_table;
25212 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
25214 r->id.idiag_sport = inet->inet_sport;
25215 r->id.idiag_dport = inet->inet_dport;
25216 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
25217 - r->id.idiag_dst[0] = inet->inet_daddr;
25218 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
25219 + inet->inet_rcv_saddr);
25220 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
25221 + inet->inet_daddr);
25223 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25224 if (r->idiag_family == AF_INET6) {
25225 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
25226 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
25227 r->id.idiag_sport = tw->tw_sport;
25228 r->id.idiag_dport = tw->tw_dport;
25229 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
25230 - r->id.idiag_dst[0] = tw->tw_daddr;
25231 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
25232 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
25233 r->idiag_state = tw->tw_substate;
25234 r->idiag_timer = 3;
25235 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
25236 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
25239 if (req->idiag_family == AF_INET) {
25240 + /* TODO: lback */
25241 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
25242 req->id.idiag_dport, req->id.idiag_src[0],
25243 req->id.idiag_sport, req->id.idiag_if);
25244 @@ -507,6 +512,7 @@ static int inet_csk_diag_dump(struct soc
25248 + /* TODO: lback */
25249 entry.saddr = &inet->inet_rcv_saddr;
25250 entry.daddr = &inet->inet_daddr;
25252 @@ -545,6 +551,7 @@ static int inet_twsk_diag_dump(struct in
25256 + /* TODO: lback */
25257 entry.saddr = &tw->tw_rcv_saddr;
25258 entry.daddr = &tw->tw_daddr;
25260 @@ -591,8 +598,8 @@ static int inet_diag_fill_req(struct sk_
25262 r->id.idiag_sport = inet->inet_sport;
25263 r->id.idiag_dport = ireq->rmt_port;
25264 - r->id.idiag_src[0] = ireq->loc_addr;
25265 - r->id.idiag_dst[0] = ireq->rmt_addr;
25266 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
25267 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
25268 r->idiag_expires = jiffies_to_msecs(tmo);
25269 r->idiag_rqueue = 0;
25270 r->idiag_wqueue = 0;
25271 @@ -663,6 +670,7 @@ static int inet_diag_dump_reqs(struct sk
25275 + /* TODO: lback */
25277 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25278 (entry.family == AF_INET6) ?
25279 @@ -733,6 +741,8 @@ static int inet_diag_dump(struct sk_buff
25280 sk_nulls_for_each(sk, node, &ilb->head) {
25281 struct inet_sock *inet = inet_sk(sk);
25283 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25288 @@ -799,6 +809,8 @@ skip_listen_ht:
25289 sk_nulls_for_each(sk, node, &head->chain) {
25290 struct inet_sock *inet = inet_sk(sk);
25292 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25296 if (!(r->idiag_states & (1 << sk->sk_state)))
25297 @@ -823,6 +835,8 @@ next_normal:
25298 inet_twsk_for_each(tw, node,
25301 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25305 if (r->id.idiag_sport != tw->tw_sport &&
25306 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/inet_hashtables.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/inet_hashtables.c
25307 --- linux-2.6.38.3/net/ipv4/inet_hashtables.c 2011-01-05 21:50:42.000000000 +0100
25308 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/inet_hashtables.c 2011-01-29 02:01:07.000000000 +0100
25311 #include <net/inet_connection_sock.h>
25312 #include <net/inet_hashtables.h>
25313 +#include <net/route.h>
25314 #include <net/ip.h>
25317 @@ -155,6 +156,11 @@ static inline int compute_score(struct s
25318 if (rcv_saddr != daddr)
25322 + /* block non nx_info ips */
25323 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25324 + daddr, NXA_MASK_BIND))
25327 if (sk->sk_bound_dev_if) {
25328 if (sk->sk_bound_dev_if != dif)
25329 @@ -172,7 +178,6 @@ static inline int compute_score(struct s
25330 * wildcarded during the search since they can never be otherwise.
25334 struct sock *__inet_lookup_listener(struct net *net,
25335 struct inet_hashinfo *hashinfo,
25336 const __be32 daddr, const unsigned short hnum,
25337 @@ -195,6 +200,7 @@ begin:
25343 * if the nulls value we got at the end of this lookup is
25344 * not the expected one, we must restart lookup.
25345 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/netfilter/nf_nat_helper.c
25346 --- linux-2.6.38.3/net/ipv4/netfilter/nf_nat_helper.c 2011-01-05 21:50:42.000000000 +0100
25347 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/netfilter/nf_nat_helper.c 2011-01-29 02:01:07.000000000 +0100
25349 #include <net/route.h>
25351 #include <linux/netfilter_ipv4.h>
25352 +#include <net/route.h>
25353 #include <net/netfilter/nf_conntrack.h>
25354 #include <net/netfilter/nf_conntrack_helper.h>
25355 #include <net/netfilter/nf_conntrack_ecache.h>
25356 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/netfilter.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/netfilter.c
25357 --- linux-2.6.38.3/net/ipv4/netfilter.c 2011-03-15 18:07:45.000000000 +0100
25358 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/netfilter.c 2011-01-29 02:01:07.000000000 +0100
25360 #include <linux/ip.h>
25361 #include <linux/skbuff.h>
25362 #include <linux/gfp.h>
25363 -#include <net/route.h>
25364 +// #include <net/route.h>
25365 #include <net/xfrm.h>
25366 #include <net/ip.h>
25367 #include <net/netfilter/nf_queue.h>
25368 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/raw.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/raw.c
25369 --- linux-2.6.38.3/net/ipv4/raw.c 2011-03-15 18:07:45.000000000 +0100
25370 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/raw.c 2011-02-17 02:17:52.000000000 +0100
25371 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
25373 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
25374 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
25375 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
25376 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
25377 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
25378 goto found; /* gotcha */
25380 @@ -384,6 +384,12 @@ static int raw_send_hdrinc(struct sock *
25381 icmp_out_count(net, ((struct icmphdr *)
25382 skb_transport_header(skb))->type);
25385 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
25386 + sk->sk_nx_info &&
25387 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
25390 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
25391 rt->dst.dev, dst_output);
25393 @@ -563,6 +569,13 @@ static int raw_sendmsg(struct kiocb *ioc
25396 security_sk_classify_flow(sk, &fl);
25397 + if (sk->sk_nx_info) {
25398 + err = ip_v4_find_src(sock_net(sk),
25399 + sk->sk_nx_info, &rt, &fl);
25404 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
25407 @@ -635,17 +648,19 @@ static int raw_bind(struct sock *sk, str
25409 struct inet_sock *inet = inet_sk(sk);
25410 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
25411 + struct nx_v4_sock_addr nsa = { 0 };
25415 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
25417 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25418 + v4_map_sock_addr(inet, addr, &nsa);
25419 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25420 ret = -EADDRNOTAVAIL;
25421 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
25422 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
25423 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
25425 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
25426 + v4_set_sock_addr(inet, &nsa);
25427 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25428 inet->inet_saddr = 0; /* Use device */
25430 @@ -697,7 +712,8 @@ static int raw_recvmsg(struct kiocb *ioc
25431 /* Copy the address. */
25433 sin->sin_family = AF_INET;
25434 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25435 + sin->sin_addr.s_addr =
25436 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
25438 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
25440 @@ -893,7 +909,8 @@ static struct sock *raw_get_first(struct
25441 struct hlist_node *node;
25443 sk_for_each(sk, node, &state->h->ht[state->bucket])
25444 - if (sock_net(sk) == seq_file_net(seq))
25445 + if ((sock_net(sk) == seq_file_net(seq)) &&
25446 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25450 @@ -909,7 +926,8 @@ static struct sock *raw_get_next(struct
25454 - } while (sk && sock_net(sk) != seq_file_net(seq));
25455 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
25456 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25458 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
25459 sk = sk_head(&state->h->ht[state->bucket]);
25460 @@ -968,7 +986,10 @@ static void raw_sock_seq_show(struct seq
25462 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
25463 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
25464 - i, src, srcp, dest, destp, sp->sk_state,
25466 + nx_map_sock_lback(current_nx_info(), src), srcp,
25467 + nx_map_sock_lback(current_nx_info(), dest), destp,
25469 sk_wmem_alloc_get(sp),
25470 sk_rmem_alloc_get(sp),
25471 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
25472 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/tcp.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/tcp.c
25473 --- linux-2.6.38.3/net/ipv4/tcp.c 2011-03-15 18:07:45.000000000 +0100
25474 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/tcp.c 2011-01-29 02:01:07.000000000 +0100
25475 @@ -266,6 +266,7 @@
25476 #include <linux/crypto.h>
25477 #include <linux/time.h>
25478 #include <linux/slab.h>
25479 +#include <linux/in.h>
25481 #include <net/icmp.h>
25482 #include <net/tcp.h>
25483 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/tcp_ipv4.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/tcp_ipv4.c
25484 --- linux-2.6.38.3/net/ipv4/tcp_ipv4.c 2011-03-15 18:07:45.000000000 +0100
25485 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/tcp_ipv4.c 2011-02-02 22:20:27.000000000 +0100
25486 @@ -1988,6 +1988,12 @@ static void *listening_get_next(struct s
25487 req = req->dl_next;
25490 + vxdprintk(VXD_CBIT(net, 6),
25491 + "sk,req: %p [#%d] (from %d)", req->sk,
25492 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
25494 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
25496 if (req->rsk_ops->family == st->family) {
25499 @@ -2012,6 +2018,10 @@ get_req:
25502 sk_nulls_for_each_from(sk, node) {
25503 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
25504 + sk, sk->sk_nid, nx_current_nid());
25505 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25507 if (!net_eq(sock_net(sk), net))
25509 if (sk->sk_family == st->family) {
25510 @@ -2088,6 +2098,11 @@ static void *established_get_first(struc
25512 spin_lock_bh(lock);
25513 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
25514 + vxdprintk(VXD_CBIT(net, 6),
25515 + "sk,egf: %p [#%d] (from %d)",
25516 + sk, sk->sk_nid, nx_current_nid());
25517 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25519 if (sk->sk_family != st->family ||
25520 !net_eq(sock_net(sk), net)) {
25522 @@ -2098,6 +2113,11 @@ static void *established_get_first(struc
25523 st->state = TCP_SEQ_STATE_TIME_WAIT;
25524 inet_twsk_for_each(tw, node,
25525 &tcp_hashinfo.ehash[st->bucket].twchain) {
25526 + vxdprintk(VXD_CBIT(net, 6),
25527 + "tw: %p [#%d] (from %d)",
25528 + tw, tw->tw_nid, nx_current_nid());
25529 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25531 if (tw->tw_family != st->family ||
25532 !net_eq(twsk_net(tw), net)) {
25534 @@ -2127,7 +2147,9 @@ static void *established_get_next(struct
25538 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
25539 + while (tw && (tw->tw_family != st->family ||
25540 + !net_eq(twsk_net(tw), net) ||
25541 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
25545 @@ -2151,6 +2173,11 @@ get_tw:
25546 sk = sk_nulls_next(sk);
25548 sk_nulls_for_each_from(sk, node) {
25549 + vxdprintk(VXD_CBIT(net, 6),
25550 + "sk,egn: %p [#%d] (from %d)",
25551 + sk, sk->sk_nid, nx_current_nid());
25552 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25554 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
25557 @@ -2360,9 +2387,9 @@ static void get_openreq4(struct sock *sk
25558 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25559 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
25562 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
25563 ntohs(inet_sk(sk)->inet_sport),
25565 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
25566 ntohs(ireq->rmt_port),
25568 0, 0, /* could print option size, but that is af dependent. */
25569 @@ -2414,7 +2441,10 @@ static void get_tcp4_sock(struct sock *s
25571 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
25572 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
25573 - i, src, srcp, dest, destp, sk->sk_state,
25575 + nx_map_sock_lback(current_nx_info(), src), srcp,
25576 + nx_map_sock_lback(current_nx_info(), dest), destp,
25578 tp->write_seq - tp->snd_una,
25581 @@ -2449,7 +2479,10 @@ static void get_timewait4_sock(struct in
25583 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25584 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
25585 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
25587 + nx_map_sock_lback(current_nx_info(), src), srcp,
25588 + nx_map_sock_lback(current_nx_info(), dest), destp,
25589 + tw->tw_substate, 0, 0,
25590 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
25591 atomic_read(&tw->tw_refcnt), tw, len);
25593 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/tcp_minisocks.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/tcp_minisocks.c
25594 --- linux-2.6.38.3/net/ipv4/tcp_minisocks.c 2011-03-15 18:07:45.000000000 +0100
25595 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/tcp_minisocks.c 2011-01-29 02:01:07.000000000 +0100
25597 #include <linux/slab.h>
25598 #include <linux/sysctl.h>
25599 #include <linux/workqueue.h>
25600 +#include <linux/vs_limit.h>
25601 +#include <linux/vs_socket.h>
25602 +#include <linux/vs_context.h>
25603 #include <net/tcp.h>
25604 #include <net/inet_common.h>
25605 #include <net/xfrm.h>
25606 @@ -335,6 +338,11 @@ void tcp_time_wait(struct sock *sk, int
25607 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25608 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25610 + tw->tw_xid = sk->sk_xid;
25611 + tw->tw_vx_info = NULL;
25612 + tw->tw_nid = sk->sk_nid;
25613 + tw->tw_nx_info = NULL;
25615 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
25616 if (tw->tw_family == PF_INET6) {
25617 struct ipv6_pinfo *np = inet6_sk(sk);
25618 diff -NurpP --minimal linux-2.6.38.3/net/ipv4/udp.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/udp.c
25619 --- linux-2.6.38.3/net/ipv4/udp.c 2011-03-15 18:07:45.000000000 +0100
25620 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv4/udp.c 2011-01-29 02:01:07.000000000 +0100
25621 @@ -296,14 +296,7 @@ fail:
25623 EXPORT_SYMBOL(udp_lib_get_port);
25625 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25627 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25629 - return (!ipv6_only_sock(sk2) &&
25630 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25631 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25633 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25635 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25637 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
25638 if (inet->inet_rcv_saddr != daddr)
25642 + /* block non nx_info ips */
25643 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25644 + daddr, NXA_MASK_BIND))
25647 if (inet->inet_daddr) {
25648 if (inet->inet_daddr != saddr)
25649 @@ -441,6 +439,7 @@ exact_match:
25654 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25655 * harder than this. -DaveM
25657 @@ -486,6 +485,11 @@ begin:
25658 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25659 score = compute_score(sk, net, saddr, hnum, sport,
25660 daddr, dport, dif);
25661 + /* FIXME: disabled?
25662 + if (score == 9) {
25666 if (score > badness) {
25669 @@ -499,6 +503,7 @@ begin:
25670 if (get_nulls_value(node) != slot)
25675 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
25677 @@ -508,6 +513,7 @@ begin:
25685 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
25686 udp_sk(s)->udp_port_hash != hnum ||
25687 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25688 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25689 - (inet->inet_rcv_saddr &&
25690 - inet->inet_rcv_saddr != loc_addr) ||
25691 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25692 ipv6_only_sock(s) ||
25693 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25695 @@ -898,8 +903,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
25696 .fl_ip_sport = inet->inet_sport,
25697 .fl_ip_dport = dport };
25698 struct net *net = sock_net(sk);
25699 + struct nx_info *nxi = sk->sk_nx_info;
25701 security_sk_classify_flow(sk, &fl);
25702 + err = ip_v4_find_src(net, nxi, &rt, &fl);
25706 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
25708 if (err == -ENETUNREACH)
25709 @@ -1181,7 +1191,8 @@ try_again:
25711 sin->sin_family = AF_INET;
25712 sin->sin_port = udp_hdr(skb)->source;
25713 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25714 + sin->sin_addr.s_addr = nx_map_sock_lback(
25715 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25716 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25718 if (inet->cmsg_flags)
25719 @@ -1922,6 +1933,8 @@ static struct sock *udp_get_first(struct
25720 sk_nulls_for_each(sk, node, &hslot->head) {
25721 if (!net_eq(sock_net(sk), net))
25723 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25725 if (sk->sk_family == state->family)
25728 @@ -1939,7 +1952,9 @@ static struct sock *udp_get_next(struct
25731 sk = sk_nulls_next(sk);
25732 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25733 + } while (sk && (!net_eq(sock_net(sk), net) ||
25734 + sk->sk_family != state->family ||
25735 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25738 if (state->bucket <= state->udp_table->mask)
25739 @@ -2046,7 +2061,10 @@ static void udp4_format_sock(struct sock
25741 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
25742 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
25743 - bucket, src, srcp, dest, destp, sp->sk_state,
25745 + nx_map_sock_lback(current_nx_info(), src), srcp,
25746 + nx_map_sock_lback(current_nx_info(), dest), destp,
25748 sk_wmem_alloc_get(sp),
25749 sk_rmem_alloc_get(sp),
25750 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
25751 diff -NurpP --minimal linux-2.6.38.3/net/ipv6/Kconfig linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/Kconfig
25752 --- linux-2.6.38.3/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
25753 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/Kconfig 2011-01-29 02:01:07.000000000 +0100
25756 # IPv6 as module will cause a CRASH if you try to unload it
25758 - tristate "The IPv6 protocol"
25760 + bool "The IPv6 protocol"
25763 This is complemental support for the IP version 6.
25764 You will still be able to do traditional IPv4 networking as well.
25765 diff -NurpP --minimal linux-2.6.38.3/net/ipv6/addrconf.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/addrconf.c
25766 --- linux-2.6.38.3/net/ipv6/addrconf.c 2011-03-15 18:07:45.000000000 +0100
25767 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/addrconf.c 2011-02-02 22:20:27.000000000 +0100
25770 #include <linux/proc_fs.h>
25771 #include <linux/seq_file.h>
25772 +#include <linux/vs_network.h>
25773 +#include <linux/vs_inet6.h>
25775 /* Set to 3 to get tracing... */
25776 #define ACONF_DEBUG 2
25777 @@ -1121,7 +1123,7 @@ out:
25779 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25780 const struct in6_addr *daddr, unsigned int prefs,
25781 - struct in6_addr *saddr)
25782 + struct in6_addr *saddr, struct nx_info *nxi)
25784 struct ipv6_saddr_score scores[2],
25785 *score = &scores[0], *hiscore = &scores[1];
25786 @@ -1193,6 +1195,8 @@ int ipv6_dev_get_saddr(struct net *net,
25790 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25794 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25795 @@ -3061,7 +3065,10 @@ static void if6_seq_stop(struct seq_file
25796 static int if6_seq_show(struct seq_file *seq, void *v)
25798 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25799 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25801 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25802 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25803 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25805 ifp->idev->dev->ifindex,
25807 @@ -3567,6 +3574,11 @@ static int in6_dump_addrs(struct inet6_d
25808 struct ifacaddr6 *ifaca;
25810 int ip_idx = *p_ip_idx;
25811 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25813 + /* disable ipv6 on non v6 guests */
25814 + if (nxi && !nx_info_has_v6(nxi))
25817 read_lock_bh(&idev->lock);
25819 @@ -3577,6 +3589,8 @@ static int in6_dump_addrs(struct inet6_d
25820 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25821 if (++ip_idx < s_ip_idx)
25823 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25825 err = inet6_fill_ifaddr(skb, ifa,
25826 NETLINK_CB(cb->skb).pid,
25827 cb->nlh->nlmsg_seq,
25828 @@ -3593,6 +3607,8 @@ static int in6_dump_addrs(struct inet6_d
25829 ifmca = ifmca->next, ip_idx++) {
25830 if (ip_idx < s_ip_idx)
25832 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25834 err = inet6_fill_ifmcaddr(skb, ifmca,
25835 NETLINK_CB(cb->skb).pid,
25836 cb->nlh->nlmsg_seq,
25837 @@ -3608,6 +3624,8 @@ static int in6_dump_addrs(struct inet6_d
25838 ifaca = ifaca->aca_next, ip_idx++) {
25839 if (ip_idx < s_ip_idx)
25841 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25843 err = inet6_fill_ifacaddr(skb, ifaca,
25844 NETLINK_CB(cb->skb).pid,
25845 cb->nlh->nlmsg_seq,
25846 @@ -3993,6 +4011,11 @@ static int inet6_dump_ifinfo(struct sk_b
25847 struct inet6_dev *idev;
25848 struct hlist_head *head;
25849 struct hlist_node *node;
25850 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25852 + /* FIXME: maybe disable ipv6 on non v6 guests?
25853 + if (skb->sk && skb->sk->sk_vx_info)
25854 + return skb->len; */
25857 s_idx = cb->args[1];
25858 @@ -4004,6 +4027,8 @@ static int inet6_dump_ifinfo(struct sk_b
25859 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25862 + if (!v6_dev_in_nx_info(dev, nxi))
25864 idev = __in6_dev_get(dev);
25867 diff -NurpP --minimal linux-2.6.38.3/net/ipv6/af_inet6.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/af_inet6.c
25868 --- linux-2.6.38.3/net/ipv6/af_inet6.c 2011-03-15 18:07:45.000000000 +0100
25869 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/af_inet6.c 2011-01-29 02:01:07.000000000 +0100
25871 #include <linux/netdevice.h>
25872 #include <linux/icmpv6.h>
25873 #include <linux/netfilter_ipv6.h>
25874 +#include <linux/vs_inet.h>
25875 +#include <linux/vs_inet6.h>
25877 #include <net/ip.h>
25878 #include <net/ipv6.h>
25879 @@ -160,9 +162,12 @@ lookup_protocol:
25883 + if ((protocol == IPPROTO_ICMPV6) &&
25884 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25886 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25887 goto out_rcu_unlock;
25890 sock->ops = answer->ops;
25891 answer_prot = answer->prot;
25892 answer_no_check = answer->no_check;
25893 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25894 struct inet_sock *inet = inet_sk(sk);
25895 struct ipv6_pinfo *np = inet6_sk(sk);
25896 struct net *net = sock_net(sk);
25897 + struct nx_v6_sock_addr nsa;
25899 unsigned short snum;
25901 @@ -272,6 +278,11 @@ int inet6_bind(struct socket *sock, stru
25903 if (addr_len < SIN6_LEN_RFC2133)
25906 + err = v6_map_sock_addr(inet, addr, &nsa);
25910 addr_type = ipv6_addr_type(&addr->sin6_addr);
25911 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25913 @@ -303,6 +314,7 @@ int inet6_bind(struct socket *sock, stru
25914 /* Reproduce AF_INET checks to make the bindings consistent */
25915 v4addr = addr->sin6_addr.s6_addr32[3];
25916 chk_addr_ret = inet_addr_type(net, v4addr);
25918 if (!sysctl_ip_nonlocal_bind &&
25919 !(inet->freebind || inet->transparent) &&
25920 v4addr != htonl(INADDR_ANY) &&
25921 @@ -312,6 +324,10 @@ int inet6_bind(struct socket *sock, stru
25922 err = -EADDRNOTAVAIL;
25925 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25926 + err = -EADDRNOTAVAIL;
25930 if (addr_type != IPV6_ADDR_ANY) {
25931 struct net_device *dev = NULL;
25932 @@ -338,6 +354,11 @@ int inet6_bind(struct socket *sock, stru
25936 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25937 + err = -EADDRNOTAVAIL;
25941 /* ipv4 addr of the socket is invalid. Only the
25942 * unspecified and mapped address have a v4 equivalent.
25944 @@ -354,6 +375,9 @@ int inet6_bind(struct socket *sock, stru
25948 + /* what's that for? */
25949 + v6_set_sock_addr(inet, &nsa);
25951 inet->inet_rcv_saddr = v4addr;
25952 inet->inet_saddr = v4addr;
25954 @@ -455,9 +479,11 @@ int inet6_getname(struct socket *sock, s
25956 sin->sin6_port = inet->inet_dport;
25957 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
25958 + /* FIXME: remap lback? */
25960 sin->sin6_flowinfo = np->flow_label;
25962 + /* FIXME: remap lback? */
25963 if (ipv6_addr_any(&np->rcv_saddr))
25964 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
25966 diff -NurpP --minimal linux-2.6.38.3/net/ipv6/fib6_rules.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/fib6_rules.c
25967 --- linux-2.6.38.3/net/ipv6/fib6_rules.c 2011-01-05 21:50:42.000000000 +0100
25968 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/fib6_rules.c 2011-01-29 02:01:07.000000000 +0100
25969 @@ -88,7 +88,7 @@ static int fib6_rule_action(struct fib_r
25970 ip6_dst_idev(&rt->dst)->dev,
25972 rt6_flags2srcprefs(flags),
25976 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25978 diff -NurpP --minimal linux-2.6.38.3/net/ipv6/inet6_hashtables.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/inet6_hashtables.c
25979 --- linux-2.6.38.3/net/ipv6/inet6_hashtables.c 2010-02-25 11:52:10.000000000 +0100
25980 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/inet6_hashtables.c 2011-01-29 02:01:07.000000000 +0100
25983 #include <linux/module.h>
25984 #include <linux/random.h>
25985 +#include <linux/vs_inet6.h>
25987 #include <net/inet_connection_sock.h>
25988 #include <net/inet_hashtables.h>
25989 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
25990 unsigned int slot = hash & hashinfo->ehash_mask;
25991 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25996 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25997 @@ -94,7 +94,7 @@ begin:
26005 if (get_nulls_value(node) != slot)
26006 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
26007 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
26011 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
26014 if (sk->sk_bound_dev_if) {
26015 if (sk->sk_bound_dev_if != dif)
26016 diff -NurpP --minimal linux-2.6.38.3/net/ipv6/ip6_output.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/ip6_output.c
26017 --- linux-2.6.38.3/net/ipv6/ip6_output.c 2011-03-15 18:07:45.000000000 +0100
26018 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/ip6_output.c 2011-01-29 02:01:07.000000000 +0100
26019 @@ -933,7 +933,7 @@ static int ip6_dst_lookup_tail(struct so
26020 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
26022 sk ? inet6_sk(sk)->srcprefs : 0,
26024 + &fl->fl6_src, sk->sk_nx_info);
26026 goto out_err_release;
26028 diff -NurpP --minimal linux-2.6.38.3/net/ipv6/ndisc.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/ndisc.c
26029 --- linux-2.6.38.3/net/ipv6/ndisc.c 2011-03-15 18:07:45.000000000 +0100
26030 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/ndisc.c 2011-03-10 16:52:54.000000000 +0100
26031 @@ -595,7 +595,7 @@ static void ndisc_send_na(struct net_dev
26033 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
26034 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
26038 src_addr = &tmpaddr;
26040 diff -NurpP --minimal linux-2.6.38.3/net/ipv6/raw.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/raw.c
26041 --- linux-2.6.38.3/net/ipv6/raw.c 2011-03-15 18:07:45.000000000 +0100
26042 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/raw.c 2011-02-17 02:17:52.000000000 +0100
26044 #include <linux/icmpv6.h>
26045 #include <linux/netfilter.h>
26046 #include <linux/netfilter_ipv6.h>
26047 +#include <linux/vs_inet6.h>
26048 #include <linux/skbuff.h>
26049 #include <linux/compat.h>
26050 #include <asm/uaccess.h>
26051 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
26055 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
26056 + err = -EADDRNOTAVAIL;
26062 /* ipv4 addr of the socket is invalid. Only the
26063 * unspecified and mapped address have a v4 equivalent.
26065 diff -NurpP --minimal linux-2.6.38.3/net/ipv6/route.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/route.c
26066 --- linux-2.6.38.3/net/ipv6/route.c 2011-03-15 18:07:45.000000000 +0100
26067 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/route.c 2011-03-15 18:15:06.000000000 +0100
26068 @@ -2291,7 +2291,8 @@ static int rt6_fill_node(struct net *net
26069 struct inet6_dev *idev = ip6_dst_idev(&rt->dst);
26070 struct in6_addr saddr_buf;
26071 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
26072 - dst, 0, &saddr_buf) == 0)
26073 + dst, 0, &saddr_buf,
26074 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
26075 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
26078 diff -NurpP --minimal linux-2.6.38.3/net/ipv6/tcp_ipv6.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/tcp_ipv6.c
26079 --- linux-2.6.38.3/net/ipv6/tcp_ipv6.c 2011-03-15 18:07:45.000000000 +0100
26080 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/tcp_ipv6.c 2011-01-29 02:01:07.000000000 +0100
26083 #include <linux/crypto.h>
26084 #include <linux/scatterlist.h>
26085 +#include <linux/vs_inet6.h>
26087 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
26088 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
26089 @@ -161,8 +162,15 @@ static int tcp_v6_connect(struct sock *s
26090 * connect() to INADDR_ANY means loopback (BSD'ism).
26093 - if(ipv6_addr_any(&usin->sin6_addr))
26094 - usin->sin6_addr.s6_addr[15] = 0x1;
26095 + if(ipv6_addr_any(&usin->sin6_addr)) {
26096 + struct nx_info *nxi = sk->sk_nx_info;
26098 + if (nxi && nx_info_has_v6(nxi))
26099 + /* FIXME: remap lback? */
26100 + usin->sin6_addr = nxi->v6.ip;
26102 + usin->sin6_addr.s6_addr[15] = 0x1;
26105 addr_type = ipv6_addr_type(&usin->sin6_addr);
26107 diff -NurpP --minimal linux-2.6.38.3/net/ipv6/udp.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/udp.c
26108 --- linux-2.6.38.3/net/ipv6/udp.c 2011-03-15 18:07:45.000000000 +0100
26109 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/udp.c 2011-01-29 05:23:17.000000000 +0100
26110 @@ -45,41 +45,67 @@
26111 #include <net/tcp_states.h>
26112 #include <net/ip6_checksum.h>
26113 #include <net/xfrm.h>
26114 +#include <linux/vs_inet6.h>
26116 #include <linux/proc_fs.h>
26117 #include <linux/seq_file.h>
26118 #include "udp_impl.h"
26120 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
26121 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26123 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
26124 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
26125 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
26126 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
26127 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
26128 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
26129 - int sk_ipv6only = ipv6_only_sock(sk);
26130 + int sk1_ipv6only = ipv6_only_sock(sk1);
26131 int sk2_ipv6only = inet_v6_ipv6only(sk2);
26132 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
26133 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
26134 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
26136 /* if both are mapped, treat as IPv4 */
26137 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
26138 - return (!sk2_ipv6only &&
26139 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
26140 + if (!sk2_ipv6only &&
26141 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
26142 - sk1_rcv_saddr == sk2_rcv_saddr));
26143 + sk1_rcv_saddr == sk2_rcv_saddr))
26149 if (addr_type2 == IPV6_ADDR_ANY &&
26150 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
26154 if (addr_type == IPV6_ADDR_ANY &&
26155 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
26157 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
26160 if (sk2_rcv_saddr6 &&
26161 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
26163 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
26169 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
26170 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
26171 + if (!sk2_rcv_saddr)
26172 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
26173 + if (!sk1_rcv_saddr)
26174 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
26177 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
26178 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
26179 + else if (addr_type2 == IPV6_ADDR_ANY)
26180 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
26181 + else if (addr_type == IPV6_ADDR_ANY) {
26182 + if (addr_type2 == IPV6_ADDR_MAPPED)
26183 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
26185 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
26190 static unsigned int udp6_portaddr_hash(struct net *net,
26191 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
26192 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
26196 + /* block non nx_info ips */
26197 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
26200 if (!ipv6_addr_any(&np->daddr)) {
26201 if (!ipv6_addr_equal(&np->daddr, saddr))
26202 diff -NurpP --minimal linux-2.6.38.3/net/ipv6/xfrm6_policy.c linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/xfrm6_policy.c
26203 --- linux-2.6.38.3/net/ipv6/xfrm6_policy.c 2011-03-15 18:07:45.000000000 +0100
26204 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/ipv6/xfrm6_policy.c 2011-02-02 22:20:27.000000000 +0100
26205 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
26206 dev = ip6_dst_idev(dst)->dev;
26207 ipv6_dev_get_saddr(dev_net(dev), dev,
26208 (struct in6_addr *)&daddr->a6, 0,
26209 - (struct in6_addr *)&saddr->a6);
26210 + (struct in6_addr *)&saddr->a6, NULL);
26214 diff -NurpP --minimal linux-2.6.38.3/net/netfilter/ipvs/ip_vs_xmit.c linux-2.6.38.3-vs2.3.0.37-rc14/net/netfilter/ipvs/ip_vs_xmit.c
26215 --- linux-2.6.38.3/net/netfilter/ipvs/ip_vs_xmit.c 2011-03-15 18:07:46.000000000 +0100
26216 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/netfilter/ipvs/ip_vs_xmit.c 2011-01-29 02:01:07.000000000 +0100
26217 @@ -213,7 +213,7 @@ __ip_vs_route_output_v6(struct net *net,
26219 if (ipv6_addr_any(&fl.fl6_src) &&
26220 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
26221 - &fl.fl6_dst, 0, &fl.fl6_src) < 0)
26222 + &fl.fl6_dst, 0, &fl.fl6_src, NULL) < 0)
26224 if (do_xfrm && xfrm_lookup(net, &dst, &fl, NULL, 0) < 0)
26226 diff -NurpP --minimal linux-2.6.38.3/net/netlink/af_netlink.c linux-2.6.38.3-vs2.3.0.37-rc14/net/netlink/af_netlink.c
26227 --- linux-2.6.38.3/net/netlink/af_netlink.c 2011-03-15 18:07:46.000000000 +0100
26228 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/netlink/af_netlink.c 2011-03-10 17:21:19.000000000 +0100
26230 #include <linux/types.h>
26231 #include <linux/audit.h>
26232 #include <linux/mutex.h>
26233 +#include <linux/vs_context.h>
26234 +#include <linux/vs_network.h>
26235 +#include <linux/vs_limit.h>
26237 #include <net/net_namespace.h>
26238 #include <net/sock.h>
26239 @@ -1922,6 +1925,8 @@ static struct sock *netlink_seq_socket_i
26240 sk_for_each(s, node, &hash->table[j]) {
26241 if (sock_net(s) != seq_file_net(seq))
26243 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26247 iter->hash_idx = j;
26248 @@ -1956,7 +1961,8 @@ static void *netlink_seq_next(struct seq
26252 - } while (s && sock_net(s) != seq_file_net(seq));
26253 + } while (s && (sock_net(s) != seq_file_net(seq) ||
26254 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
26258 @@ -1968,7 +1974,8 @@ static void *netlink_seq_next(struct seq
26260 for (; j <= hash->mask; j++) {
26261 s = sk_head(&hash->table[j]);
26262 - while (s && sock_net(s) != seq_file_net(seq))
26263 + while (s && (sock_net(s) != seq_file_net(seq) ||
26264 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
26268 diff -NurpP --minimal linux-2.6.38.3/net/sctp/ipv6.c linux-2.6.38.3-vs2.3.0.37-rc14/net/sctp/ipv6.c
26269 --- linux-2.6.38.3/net/sctp/ipv6.c 2011-01-05 21:50:45.000000000 +0100
26270 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/sctp/ipv6.c 2011-01-29 02:01:07.000000000 +0100
26271 @@ -306,7 +306,8 @@ static void sctp_v6_get_saddr(struct sct
26272 dst ? ip6_dst_idev(dst)->dev : NULL,
26273 &daddr->v6.sin6_addr,
26274 inet6_sk(&sk->inet.sk)->srcprefs,
26275 - &saddr->v6.sin6_addr);
26276 + &saddr->v6.sin6_addr,
26277 + asoc->base.sk->sk_nx_info);
26278 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
26279 &saddr->v6.sin6_addr);
26281 diff -NurpP --minimal linux-2.6.38.3/net/socket.c linux-2.6.38.3-vs2.3.0.37-rc14/net/socket.c
26282 --- linux-2.6.38.3/net/socket.c 2011-04-15 10:30:30.000000000 +0200
26283 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/socket.c 2011-03-28 15:00:14.000000000 +0200
26286 #include <net/sock.h>
26287 #include <linux/netfilter.h>
26288 +#include <linux/vs_base.h>
26289 +#include <linux/vs_socket.h>
26290 +#include <linux/vs_inet.h>
26291 +#include <linux/vs_inet6.h>
26293 #include <linux/if_tun.h>
26294 #include <linux/ipv6_route.h>
26295 @@ -551,7 +555,7 @@ static inline int __sock_sendmsg(struct
26296 struct msghdr *msg, size_t size)
26298 struct sock_iocb *si = kiocb_to_siocb(iocb);
26302 sock_update_classid(sock->sk);
26304 @@ -564,7 +568,22 @@ static inline int __sock_sendmsg(struct
26308 - return sock->ops->sendmsg(iocb, sock, msg, size);
26309 + len = sock->ops->sendmsg(iocb, sock, msg, size);
26312 + vx_sock_send(sock->sk, size);
26314 + vx_sock_fail(sock->sk, size);
26316 + vxdprintk(VXD_CBIT(net, 7),
26317 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26319 + (sock->sk)?sock->sk->sk_nx_info:0,
26320 + (sock->sk)?sock->sk->sk_vx_info:0,
26321 + (sock->sk)?sock->sk->sk_xid:0,
26322 + (sock->sk)?sock->sk->sk_nid:0,
26323 + (unsigned int)size, len);
26327 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
26328 @@ -682,6 +701,7 @@ static inline int __sock_recvmsg_nosec(s
26329 struct msghdr *msg, size_t size, int flags)
26331 struct sock_iocb *si = kiocb_to_siocb(iocb);
26334 sock_update_classid(sock->sk);
26336 @@ -691,7 +711,18 @@ static inline int __sock_recvmsg_nosec(s
26340 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
26341 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
26342 + if ((len >= 0) && sock->sk)
26343 + vx_sock_recv(sock->sk, len);
26344 + vxdprintk(VXD_CBIT(net, 7),
26345 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26347 + (sock->sk)?sock->sk->sk_nx_info:0,
26348 + (sock->sk)?sock->sk->sk_vx_info:0,
26349 + (sock->sk)?sock->sk->sk_xid:0,
26350 + (sock->sk)?sock->sk->sk_nid:0,
26351 + (unsigned int)size, len);
26355 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
26356 @@ -1175,6 +1206,13 @@ int __sock_create(struct net *net, int f
26357 if (type < 0 || type >= SOCK_MAX)
26360 + if (!nx_check(0, VS_ADMIN)) {
26361 + if (family == PF_INET && !current_nx_info_has_v4())
26362 + return -EAFNOSUPPORT;
26363 + if (family == PF_INET6 && !current_nx_info_has_v6())
26364 + return -EAFNOSUPPORT;
26369 This uglymoron is moved from INET layer to here to avoid
26370 @@ -1310,6 +1348,7 @@ SYSCALL_DEFINE3(socket, int, family, int
26374 + set_bit(SOCK_USER_SOCKET, &sock->flags);
26375 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
26378 @@ -1351,10 +1390,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
26379 err = sock_create(family, type, protocol, &sock1);
26382 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
26384 err = sock_create(family, type, protocol, &sock2);
26386 goto out_release_1;
26387 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
26389 err = sock1->ops->socketpair(sock1, sock2);
26391 diff -NurpP --minimal linux-2.6.38.3/net/sunrpc/auth.c linux-2.6.38.3-vs2.3.0.37-rc14/net/sunrpc/auth.c
26392 --- linux-2.6.38.3/net/sunrpc/auth.c 2011-03-15 18:07:46.000000000 +0100
26393 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/sunrpc/auth.c 2011-01-29 02:01:07.000000000 +0100
26395 #include <linux/hash.h>
26396 #include <linux/sunrpc/clnt.h>
26397 #include <linux/spinlock.h>
26398 +#include <linux/vs_tag.h>
26401 # define RPCDBG_FACILITY RPCDBG_AUTH
26402 @@ -425,6 +426,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
26403 memset(&acred, 0, sizeof(acred));
26404 acred.uid = cred->fsuid;
26405 acred.gid = cred->fsgid;
26406 + acred.tag = dx_current_tag();
26407 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
26409 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
26410 @@ -465,6 +467,7 @@ rpcauth_bind_root_cred(struct rpc_task *
26411 struct auth_cred acred = {
26414 + .tag = dx_current_tag(),
26417 dprintk("RPC: %5u looking up %s cred\n",
26418 diff -NurpP --minimal linux-2.6.38.3/net/sunrpc/auth_unix.c linux-2.6.38.3-vs2.3.0.37-rc14/net/sunrpc/auth_unix.c
26419 --- linux-2.6.38.3/net/sunrpc/auth_unix.c 2010-10-21 13:08:01.000000000 +0200
26420 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/sunrpc/auth_unix.c 2011-01-29 02:01:07.000000000 +0100
26421 @@ -12,12 +12,14 @@
26422 #include <linux/module.h>
26423 #include <linux/sunrpc/clnt.h>
26424 #include <linux/sunrpc/auth.h>
26425 +#include <linux/vs_tag.h>
26427 #define NFS_NGROUPS 16
26430 struct rpc_cred uc_base;
26433 gid_t uc_gids[NFS_NGROUPS];
26435 #define uc_uid uc_base.cr_uid
26436 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
26437 groups = NFS_NGROUPS;
26439 cred->uc_gid = acred->gid;
26440 + cred->uc_tag = acred->tag;
26441 for (i = 0; i < groups; i++)
26442 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
26443 if (i < NFS_NGROUPS)
26444 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
26448 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
26449 + if (cred->uc_uid != acred->uid ||
26450 + cred->uc_gid != acred->gid ||
26451 + cred->uc_tag != acred->tag)
26454 if (acred->group_info != NULL)
26455 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
26456 struct rpc_clnt *clnt = task->tk_client;
26457 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
26458 __be32 *base, *hold;
26462 *p++ = htonl(RPC_AUTH_UNIX);
26464 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
26465 * Copy the UTS nodename captured when the client was created.
26467 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
26468 + tag = task->tk_client->cl_tag;
26470 - *p++ = htonl((u32) cred->uc_uid);
26471 - *p++ = htonl((u32) cred->uc_gid);
26472 + *p++ = htonl((u32) TAGINO_UID(tag,
26473 + cred->uc_uid, cred->uc_tag));
26474 + *p++ = htonl((u32) TAGINO_GID(tag,
26475 + cred->uc_gid, cred->uc_tag));
26477 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
26478 *p++ = htonl((u32) cred->uc_gids[i]);
26479 diff -NurpP --minimal linux-2.6.38.3/net/sunrpc/clnt.c linux-2.6.38.3-vs2.3.0.37-rc14/net/sunrpc/clnt.c
26480 --- linux-2.6.38.3/net/sunrpc/clnt.c 2011-04-15 10:30:30.000000000 +0200
26481 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/sunrpc/clnt.c 2011-03-25 22:52:15.000000000 +0100
26483 #include <linux/utsname.h>
26484 #include <linux/workqueue.h>
26485 #include <linux/in6.h>
26486 +#include <linux/vs_cvirt.h>
26488 #include <linux/sunrpc/clnt.h>
26489 #include <linux/sunrpc/rpc_pipe_fs.h>
26490 @@ -359,6 +360,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
26491 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
26492 clnt->cl_chatty = 1;
26494 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
26495 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
26496 + clnt->cl_tag = 1; */
26499 EXPORT_SYMBOL_GPL(rpc_create);
26500 diff -NurpP --minimal linux-2.6.38.3/net/unix/af_unix.c linux-2.6.38.3-vs2.3.0.37-rc14/net/unix/af_unix.c
26501 --- linux-2.6.38.3/net/unix/af_unix.c 2011-03-15 18:07:46.000000000 +0100
26502 +++ linux-2.6.38.3-vs2.3.0.37-rc14/net/unix/af_unix.c 2011-03-15 18:15:06.000000000 +0100
26503 @@ -114,6 +114,8 @@
26504 #include <linux/mount.h>
26505 #include <net/checksum.h>
26506 #include <linux/security.h>
26507 +#include <linux/vs_context.h>
26508 +#include <linux/vs_limit.h>
26510 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
26511 static DEFINE_SPINLOCK(unix_table_lock);
26512 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
26513 if (!net_eq(sock_net(s), net))
26516 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26518 if (u->addr->len == len &&
26519 !memcmp(u->addr->name, sunname, len))
26521 @@ -2188,6 +2192,8 @@ static struct sock *unix_seq_idx(struct
26522 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
26523 if (sock_net(s) != seq_file_net(seq))
26525 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26530 @@ -2212,7 +2218,8 @@ static void *unix_seq_next(struct seq_fi
26531 sk = first_unix_socket(&iter->i);
26533 sk = next_unix_socket(&iter->i, sk);
26534 - while (sk && (sock_net(sk) != seq_file_net(seq)))
26535 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
26536 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
26537 sk = next_unix_socket(&iter->i, sk);
26540 diff -NurpP --minimal linux-2.6.38.3/scripts/checksyscalls.sh linux-2.6.38.3-vs2.3.0.37-rc14/scripts/checksyscalls.sh
26541 --- linux-2.6.38.3/scripts/checksyscalls.sh 2011-03-15 18:07:46.000000000 +0100
26542 +++ linux-2.6.38.3-vs2.3.0.37-rc14/scripts/checksyscalls.sh 2011-01-29 02:01:07.000000000 +0100
26543 @@ -193,7 +193,6 @@ cat << EOF
26544 #define __IGNORE_afs_syscall
26545 #define __IGNORE_getpmsg
26546 #define __IGNORE_putpmsg
26547 -#define __IGNORE_vserver
26551 diff -NurpP --minimal linux-2.6.38.3/security/commoncap.c linux-2.6.38.3-vs2.3.0.37-rc14/security/commoncap.c
26552 --- linux-2.6.38.3/security/commoncap.c 2011-01-05 21:50:47.000000000 +0100
26553 +++ linux-2.6.38.3-vs2.3.0.37-rc14/security/commoncap.c 2011-01-29 02:01:07.000000000 +0100
26555 #include <linux/sched.h>
26556 #include <linux/prctl.h>
26557 #include <linux/securebits.h>
26558 +// #include <linux/vs_context.h>
26561 * If a non-root user executes a setuid-root binary in
26562 @@ -52,7 +53,7 @@ static void warn_setuid_and_fcaps_mixed(
26564 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
26566 - NETLINK_CB(skb).eff_cap = current_cap();
26567 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
26571 @@ -62,6 +63,7 @@ int cap_netlink_recv(struct sk_buff *skb
26576 EXPORT_SYMBOL(cap_netlink_recv);
26579 @@ -82,7 +84,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
26580 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
26583 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
26584 + struct vx_info *vxi = tsk->vx_info;
26587 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
26588 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
26589 + cap_raised(tsk->cap_effective, cap),
26590 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
26593 + /* special case SETUP */
26594 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26595 + /* FIXME: maybe use cred instead? */
26596 + cap_raised(tsk->cred->cap_effective, cap))
26599 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26603 @@ -570,7 +587,7 @@ int cap_inode_setxattr(struct dentry *de
26605 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26606 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26607 - !capable(CAP_SYS_ADMIN))
26608 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26612 @@ -596,7 +613,7 @@ int cap_inode_removexattr(struct dentry
26614 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26615 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26616 - !capable(CAP_SYS_ADMIN))
26617 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26621 @@ -929,3 +946,4 @@ int cap_file_mmap(struct file *file, uns
26626 diff -NurpP --minimal linux-2.6.38.3/security/selinux/hooks.c linux-2.6.38.3-vs2.3.0.37-rc14/security/selinux/hooks.c
26627 --- linux-2.6.38.3/security/selinux/hooks.c 2011-03-15 18:07:47.000000000 +0100
26628 +++ linux-2.6.38.3-vs2.3.0.37-rc14/security/selinux/hooks.c 2011-02-17 02:17:52.000000000 +0100
26630 #include <linux/dccp.h>
26631 #include <linux/quota.h>
26632 #include <linux/un.h> /* for Unix socket types */
26633 -#include <net/af_unix.h> /* for Unix socket types */
26634 #include <linux/parser.h>
26635 #include <linux/nfs_mount.h>
26636 #include <net/ipv6.h>