1 diff -NurpP --minimal linux-3.0-rc5/Documentation/vserver/debug.txt linux-3.0-rc5-vs2.3.1-pre3/Documentation/vserver/debug.txt
2 --- linux-3.0-rc5/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-3.0-rc5-vs2.3.1-pre3/Documentation/vserver/debug.txt 2011-06-10 22:11:24.000000000 +0200
8 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
9 + "vx_rmap_tgid: %p/%llx: %d -> %d"
13 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
14 + "FREE (%p,#%d)%c inode"
15 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
16 + "FREE (%p,#%d)%c %lld bytes"
17 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
18 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
19 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
20 + "rcu_free_dl_info(%p)"
21 + 4 10 "alloc_dl_info(%p,%d) = %p"
22 + "dealloc_dl_info(%p)"
23 + "get_dl_info(%p[#%d.%d])"
24 + "put_dl_info(%p[#%d.%d])"
25 + 5 20 "alloc_dl_info(%p,%d)*"
26 + 6 40 "__hash_dl_info: %p[#%d]"
27 + "__unhash_dl_info: %p[#%d]"
28 + 7 80 "locate_dl_info(%p,#%d) = %p"
32 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
33 + "new_dqhash: %p [#0x%08x]"
34 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
35 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
36 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
37 + "vroot_get_real_bdev not set"
38 + 1 2 "cow_break_link(»%s«)"
40 + 2 4 "dentry_open(new): %p"
41 + "dentry_open(old): %p"
42 + "lookup_create(new): %p"
44 + "path_lookup(old): %d"
45 + "vfs_create(new): %d"
48 + 3 8 "fput(new_file=%p[#%d])"
49 + "fput(old_file=%p[#%d])"
50 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
51 + "vx_info_kill(%p[#%d],%d,%d)*"
52 + 5 20 "vs_reboot(%p[#%d],%d)"
53 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
57 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
58 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
59 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
60 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
61 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
62 + 6 40 "sk,egf: %p [#%d] (from %d)"
63 + "sk,egn: %p [#%d] (from %d)"
64 + "sk,req: %p [#%d] (from %d)"
65 + "sk: %p [#%d] (from %d)"
66 + "tw: %p [#%d] (from %d)"
67 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
68 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
72 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
73 + "alloc_nx_info(%d) = %p"
74 + "create_nx_info(%d) (dynamic rejected)"
75 + "create_nx_info(%d) = %p (already there)"
76 + "create_nx_info(%d) = %p (new)"
77 + "dealloc_nx_info(%p)"
78 + 1 2 "alloc_nx_info(%d)*"
79 + "create_nx_info(%d)*"
80 + 2 4 "get_nx_info(%p[#%d.%d])"
81 + "put_nx_info(%p[#%d.%d])"
82 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
83 + "clr_nx_info(%p[#%d.%d])"
84 + "init_nx_info(%p[#%d.%d])"
85 + "release_nx_info(%p[#%d.%d.%d]) %p"
86 + "set_nx_info(%p[#%d.%d])"
87 + 4 10 "__hash_nx_info: %p[#%d]"
88 + "__nx_dynamic_id: [#%d]"
89 + "__unhash_nx_info: %p[#%d.%d.%d]"
90 + 5 20 "moved task %p into nxi:%p[#%d]"
91 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
92 + "task_get_nx_info(%p)"
93 + 6 40 "nx_clear_persistent(%p[#%d])"
97 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
98 + 1 2 "quota_sync_dqh(%p,%d)"
99 + "sync_dquots(%p,%d)"
100 + "sync_dquots_dqh(%p,%d)"
101 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
105 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
106 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
107 + 4 10 "%s: (%s %s) returned %s with %d"
111 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
112 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
116 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
117 + "alloc_vx_info(%d) = %p"
118 + "alloc_vx_info(%d)*"
119 + "create_vx_info(%d) (dynamic rejected)"
120 + "create_vx_info(%d) = %p (already there)"
121 + "create_vx_info(%d) = %p (new)"
122 + "dealloc_vx_info(%p)"
123 + "loc_vx_info(%d) = %p (found)"
124 + "loc_vx_info(%d) = %p (new)"
125 + "loc_vx_info(%d) = %p (not available)"
126 + 1 2 "create_vx_info(%d)*"
128 + 2 4 "get_vx_info(%p[#%d.%d])"
129 + "put_vx_info(%p[#%d.%d])"
130 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
131 + "clr_vx_info(%p[#%d.%d])"
132 + "init_vx_info(%p[#%d.%d])"
133 + "release_vx_info(%p[#%d.%d.%d]) %p"
134 + "set_vx_info(%p[#%d.%d])"
135 + 4 10 "__hash_vx_info: %p[#%d]"
136 + "__unhash_vx_info: %p[#%d.%d.%d]"
137 + "__vx_dynamic_id: [#%d]"
138 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
139 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
140 + "moved task %p into vxi:%p[#%d]"
141 + "task_get_vx_info(%p)"
142 + "vx_migrate_task(%p,%p[#%d.%d])"
143 + 6 40 "vx_clear_persistent(%p[#%d])"
144 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
145 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
146 + "vx_set_persistent(%p[#%d])"
147 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
148 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
153 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
154 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
156 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
157 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
158 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
159 diff -NurpP --minimal linux-3.0-rc5/arch/alpha/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/alpha/Kconfig
160 --- linux-3.0-rc5/arch/alpha/Kconfig 2011-07-01 11:13:32.000000000 +0200
161 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/alpha/Kconfig 2011-06-10 22:11:24.000000000 +0200
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-3.0-rc5/arch/alpha/kernel/entry.S linux-3.0-rc5-vs2.3.1-pre3/arch/alpha/kernel/entry.S
172 --- linux-3.0-rc5/arch/alpha/kernel/entry.S 2010-10-21 13:06:45.000000000 +0200
173 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/alpha/kernel/entry.S 2011-06-10 22:11:24.000000000 +0200
174 @@ -860,24 +860,15 @@ sys_getxgid:
181 - ldq $2, TI_TASK($8)
183 - /* See linux/kernel/timer.c sys_getppid for discussion
184 - about this loop. */
185 - ldq $3, TASK_GROUP_LEADER($2)
186 - ldq $4, TASK_REAL_PARENT($3)
187 - ldl $0, TASK_TGID($2)
188 -1: ldl $1, TASK_TGID($4)
192 - ldq $3, TASK_GROUP_LEADER($2)
193 - ldq $4, TASK_REAL_PARENT($3)
199 + jsr $26, do_getxpid
206 diff -NurpP --minimal linux-3.0-rc5/arch/alpha/kernel/ptrace.c linux-3.0-rc5-vs2.3.1-pre3/arch/alpha/kernel/ptrace.c
207 --- linux-3.0-rc5/arch/alpha/kernel/ptrace.c 2011-01-05 21:48:40.000000000 +0100
208 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/alpha/kernel/ptrace.c 2011-06-10 22:11:24.000000000 +0200
210 #include <linux/user.h>
211 #include <linux/security.h>
212 #include <linux/signal.h>
213 +#include <linux/vs_base.h>
215 #include <asm/uaccess.h>
216 #include <asm/pgtable.h>
217 diff -NurpP --minimal linux-3.0-rc5/arch/alpha/kernel/systbls.S linux-3.0-rc5-vs2.3.1-pre3/arch/alpha/kernel/systbls.S
218 --- linux-3.0-rc5/arch/alpha/kernel/systbls.S 2011-07-01 11:13:32.000000000 +0200
219 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/alpha/kernel/systbls.S 2011-06-10 22:11:24.000000000 +0200
220 @@ -446,7 +446,7 @@ sys_call_table:
221 .quad sys_stat64 /* 425 */
224 - .quad sys_ni_syscall /* sys_vserver */
225 + .quad sys_vserver /* sys_vserver */
226 .quad sys_ni_syscall /* sys_mbind */
227 .quad sys_ni_syscall /* sys_get_mempolicy */
228 .quad sys_ni_syscall /* sys_set_mempolicy */
229 diff -NurpP --minimal linux-3.0-rc5/arch/alpha/kernel/traps.c linux-3.0-rc5-vs2.3.1-pre3/arch/alpha/kernel/traps.c
230 --- linux-3.0-rc5/arch/alpha/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
231 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/alpha/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
232 @@ -183,7 +183,8 @@ die_if_kernel(char * str, struct pt_regs
234 printk("CPU %d ", hard_smp_processor_id());
236 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
237 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
238 + task_pid_nr(current), current->xid, str, err);
239 dik_show_regs(regs, r9_15);
240 add_taint(TAINT_DIE);
241 dik_show_trace((unsigned long *)(regs+1));
242 diff -NurpP --minimal linux-3.0-rc5/arch/arm/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/arm/Kconfig
243 --- linux-3.0-rc5/arch/arm/Kconfig 2011-07-01 11:13:32.000000000 +0200
244 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/arm/Kconfig 2011-06-10 22:11:24.000000000 +0200
245 @@ -2035,6 +2035,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-3.0-rc5/arch/arm/kernel/calls.S linux-3.0-rc5-vs2.3.1-pre3/arch/arm/kernel/calls.S
255 --- linux-3.0-rc5/arch/arm/kernel/calls.S 2011-07-01 11:13:32.000000000 +0200
256 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/arm/kernel/calls.S 2011-06-10 22:11:24.000000000 +0200
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-3.0-rc5/arch/arm/kernel/process.c linux-3.0-rc5-vs2.3.1-pre3/arch/arm/kernel/process.c
267 --- linux-3.0-rc5/arch/arm/kernel/process.c 2011-05-22 16:16:47.000000000 +0200
268 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/arm/kernel/process.c 2011-06-10 22:11:24.000000000 +0200
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-3.0-rc5/arch/arm/kernel/traps.c linux-3.0-rc5-vs2.3.1-pre3/arch/arm/kernel/traps.c
280 --- linux-3.0-rc5/arch/arm/kernel/traps.c 2011-07-01 11:13:32.000000000 +0200
281 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/arm/kernel/traps.c 2011-06-22 12:39:12.000000000 +0200
282 @@ -242,8 +242,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-3.0-rc5/arch/cris/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/cris/Kconfig
294 --- linux-3.0-rc5/arch/cris/Kconfig 2011-07-01 11:13:37.000000000 +0200
295 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/cris/Kconfig 2011-06-10 22:11:24.000000000 +0200
296 @@ -678,6 +678,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-3.0-rc5/arch/frv/kernel/kernel_thread.S linux-3.0-rc5-vs2.3.1-pre3/arch/frv/kernel/kernel_thread.S
306 --- linux-3.0-rc5/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
307 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/frv/kernel/kernel_thread.S 2011-06-10 22:11:24.000000000 +0200
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-3.0-rc5/arch/h8300/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/h8300/Kconfig
318 --- linux-3.0-rc5/arch/h8300/Kconfig 2011-07-01 11:13:37.000000000 +0200
319 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/h8300/Kconfig 2011-06-10 22:11:24.000000000 +0200
320 @@ -213,6 +213,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-3.0-rc5/arch/ia64/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/Kconfig
330 --- linux-3.0-rc5/arch/ia64/Kconfig 2011-07-01 11:13:37.000000000 +0200
331 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/Kconfig 2011-06-10 22:11:24.000000000 +0200
332 @@ -671,6 +671,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-3.0-rc5/arch/ia64/include/asm/tlb.h linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/include/asm/tlb.h
342 --- linux-3.0-rc5/arch/ia64/include/asm/tlb.h 2011-07-01 11:13:37.000000000 +0200
343 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/include/asm/tlb.h 2011-06-10 22:11:24.000000000 +0200
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-3.0-rc5/arch/ia64/kernel/entry.S linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/kernel/entry.S
353 --- linux-3.0-rc5/arch/ia64/kernel/entry.S 2011-07-01 11:13:38.000000000 +0200
354 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/kernel/entry.S 2011-06-10 22:11:24.000000000 +0200
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-3.0-rc5/arch/ia64/kernel/perfmon.c linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/kernel/perfmon.c
365 --- linux-3.0-rc5/arch/ia64/kernel/perfmon.c 2011-03-15 18:06:39.000000000 +0100
366 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/kernel/perfmon.c 2011-06-10 22:11:24.000000000 +0200
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-3.0-rc5/arch/ia64/kernel/process.c linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/kernel/process.c
376 --- linux-3.0-rc5/arch/ia64/kernel/process.c 2011-03-15 18:06:39.000000000 +0100
377 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/kernel/process.c 2011-06-10 22:11:24.000000000 +0200
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-3.0-rc5/arch/ia64/kernel/ptrace.c linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/kernel/ptrace.c
390 --- linux-3.0-rc5/arch/ia64/kernel/ptrace.c 2011-01-05 21:48:59.000000000 +0100
391 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/kernel/ptrace.c 2011-06-10 22:11:24.000000000 +0200
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-3.0-rc5/arch/ia64/kernel/traps.c linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/kernel/traps.c
401 --- linux-3.0-rc5/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
402 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
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-3.0-rc5/arch/ia64/mm/fault.c linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/mm/fault.c
428 --- linux-3.0-rc5/arch/ia64/mm/fault.c 2011-07-01 11:13:38.000000000 +0200
429 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/ia64/mm/fault.c 2011-06-10 22:28:23.000000000 +0200
431 #include <linux/kprobes.h>
432 #include <linux/kdebug.h>
433 #include <linux/prefetch.h>
434 +#include <linux/vs_memory.h>
436 #include <asm/pgtable.h>
437 #include <asm/processor.h>
438 diff -NurpP --minimal linux-3.0-rc5/arch/m32r/kernel/traps.c linux-3.0-rc5-vs2.3.1-pre3/arch/m32r/kernel/traps.c
439 --- linux-3.0-rc5/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
440 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/m32r/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
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-3.0-rc5/arch/m68k/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/m68k/Kconfig
454 --- linux-3.0-rc5/arch/m68k/Kconfig 2011-07-01 11:13:38.000000000 +0200
455 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/m68k/Kconfig 2011-06-10 22:11:24.000000000 +0200
456 @@ -241,6 +241,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-3.0-rc5/arch/mips/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/mips/Kconfig
466 --- linux-3.0-rc5/arch/mips/Kconfig 2011-07-01 11:13:38.000000000 +0200
467 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/mips/Kconfig 2011-06-10 22:11:24.000000000 +0200
468 @@ -2485,6 +2485,8 @@ source "fs/Kconfig"
470 source "arch/mips/Kconfig.debug"
472 +source "kernel/vserver/Kconfig"
474 source "security/Kconfig"
476 source "crypto/Kconfig"
477 diff -NurpP --minimal linux-3.0-rc5/arch/mips/kernel/ptrace.c linux-3.0-rc5-vs2.3.1-pre3/arch/mips/kernel/ptrace.c
478 --- linux-3.0-rc5/arch/mips/kernel/ptrace.c 2011-07-01 11:13:39.000000000 +0200
479 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/mips/kernel/ptrace.c 2011-06-10 22:11:24.000000000 +0200
481 #include <linux/security.h>
482 #include <linux/audit.h>
483 #include <linux/seccomp.h>
484 +#include <linux/vs_base.h>
486 #include <asm/byteorder.h>
488 @@ -263,6 +264,9 @@ long arch_ptrace(struct task_struct *chi
489 void __user *datavp = (void __user *) data;
490 unsigned long __user *datalp = (void __user *) data;
492 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
496 /* when I and D space are separate, these will need to be fixed. */
497 case PTRACE_PEEKTEXT: /* read word at location addr. */
498 diff -NurpP --minimal linux-3.0-rc5/arch/mips/kernel/scall32-o32.S linux-3.0-rc5-vs2.3.1-pre3/arch/mips/kernel/scall32-o32.S
499 --- linux-3.0-rc5/arch/mips/kernel/scall32-o32.S 2011-07-01 11:13:39.000000000 +0200
500 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/mips/kernel/scall32-o32.S 2011-06-10 22:11:24.000000000 +0200
501 @@ -523,7 +523,7 @@ einval: li v0, -ENOSYS
502 sys sys_mq_timedreceive 5
503 sys sys_mq_notify 2 /* 4275 */
504 sys sys_mq_getsetattr 3
505 - sys sys_ni_syscall 0 /* sys_vserver */
508 sys sys_ni_syscall 0 /* available, was setaltroot */
509 sys sys_add_key 5 /* 4280 */
510 diff -NurpP --minimal linux-3.0-rc5/arch/mips/kernel/scall64-64.S linux-3.0-rc5-vs2.3.1-pre3/arch/mips/kernel/scall64-64.S
511 --- linux-3.0-rc5/arch/mips/kernel/scall64-64.S 2011-07-01 11:13:39.000000000 +0200
512 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/mips/kernel/scall64-64.S 2011-06-10 22:11:24.000000000 +0200
513 @@ -362,7 +362,7 @@ sys_call_table:
514 PTR sys_mq_timedreceive
516 PTR sys_mq_getsetattr /* 5235 */
517 - PTR sys_ni_syscall /* sys_vserver */
520 PTR sys_ni_syscall /* available, was setaltroot */
522 diff -NurpP --minimal linux-3.0-rc5/arch/mips/kernel/scall64-n32.S linux-3.0-rc5-vs2.3.1-pre3/arch/mips/kernel/scall64-n32.S
523 --- linux-3.0-rc5/arch/mips/kernel/scall64-n32.S 2011-07-01 11:13:39.000000000 +0200
524 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/mips/kernel/scall64-n32.S 2011-06-10 22:11:24.000000000 +0200
525 @@ -361,7 +361,7 @@ EXPORT(sysn32_call_table)
526 PTR compat_sys_mq_timedreceive
527 PTR compat_sys_mq_notify
528 PTR compat_sys_mq_getsetattr
529 - PTR sys_ni_syscall /* 6240, sys_vserver */
530 + PTR sys32_vserver /* 6240 */
531 PTR compat_sys_waitid
532 PTR sys_ni_syscall /* available, was setaltroot */
534 diff -NurpP --minimal linux-3.0-rc5/arch/mips/kernel/scall64-o32.S linux-3.0-rc5-vs2.3.1-pre3/arch/mips/kernel/scall64-o32.S
535 --- linux-3.0-rc5/arch/mips/kernel/scall64-o32.S 2011-07-01 11:13:39.000000000 +0200
536 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/mips/kernel/scall64-o32.S 2011-06-10 22:11:24.000000000 +0200
537 @@ -480,7 +480,7 @@ sys_call_table:
538 PTR compat_sys_mq_timedreceive
539 PTR compat_sys_mq_notify /* 4275 */
540 PTR compat_sys_mq_getsetattr
541 - PTR sys_ni_syscall /* sys_vserver */
544 PTR sys_ni_syscall /* available, was setaltroot */
545 PTR sys_add_key /* 4280 */
546 diff -NurpP --minimal linux-3.0-rc5/arch/mips/kernel/traps.c linux-3.0-rc5-vs2.3.1-pre3/arch/mips/kernel/traps.c
547 --- linux-3.0-rc5/arch/mips/kernel/traps.c 2011-05-22 16:17:00.000000000 +0200
548 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/mips/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
549 @@ -343,9 +343,10 @@ void show_registers(struct pt_regs *regs
553 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
554 - current->comm, current->pid, current_thread_info(), current,
555 - field, current_thread_info()->tp_value);
556 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
557 + current->comm, task_pid_nr(current), current->xid,
558 + current_thread_info(), current,
559 + field, current_thread_info()->tp_value);
560 if (cpu_has_userlocal) {
563 diff -NurpP --minimal linux-3.0-rc5/arch/parisc/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/parisc/Kconfig
564 --- linux-3.0-rc5/arch/parisc/Kconfig 2011-07-01 11:13:42.000000000 +0200
565 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/parisc/Kconfig 2011-06-10 22:11:24.000000000 +0200
566 @@ -279,6 +279,8 @@ source "fs/Kconfig"
568 source "arch/parisc/Kconfig.debug"
570 +source "kernel/vserver/Kconfig"
572 source "security/Kconfig"
574 source "crypto/Kconfig"
575 diff -NurpP --minimal linux-3.0-rc5/arch/parisc/kernel/syscall_table.S linux-3.0-rc5-vs2.3.1-pre3/arch/parisc/kernel/syscall_table.S
576 --- linux-3.0-rc5/arch/parisc/kernel/syscall_table.S 2011-07-01 11:13:43.000000000 +0200
577 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/parisc/kernel/syscall_table.S 2011-06-10 22:11:24.000000000 +0200
579 ENTRY_COMP(mbind) /* 260 */
580 ENTRY_COMP(get_mempolicy)
581 ENTRY_COMP(set_mempolicy)
582 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
583 + ENTRY_DIFF(vserver)
585 ENTRY_SAME(request_key) /* 265 */
587 diff -NurpP --minimal linux-3.0-rc5/arch/parisc/kernel/traps.c linux-3.0-rc5-vs2.3.1-pre3/arch/parisc/kernel/traps.c
588 --- linux-3.0-rc5/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
589 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/parisc/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
590 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
594 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
595 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
596 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
597 + current->comm, task_pid_nr(current), current->xid,
598 + str, err, regs->iaoq[0]);
599 #ifdef PRINT_USER_FAULTS
600 /* XXX for debugging only */
602 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
603 pdc_console_restart();
606 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
607 - current->comm, task_pid_nr(current), str, err);
608 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
609 + current->comm, task_pid_nr(current), current->xid, str, err);
611 /* Wot's wrong wif bein' racy? */
612 if (current->thread.flags & PARISC_KERNEL_DEATH) {
613 diff -NurpP --minimal linux-3.0-rc5/arch/parisc/mm/fault.c linux-3.0-rc5-vs2.3.1-pre3/arch/parisc/mm/fault.c
614 --- linux-3.0-rc5/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
615 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/parisc/mm/fault.c 2011-06-10 22:11:24.000000000 +0200
616 @@ -237,8 +237,9 @@ bad_area:
618 #ifdef PRINT_USER_FAULTS
619 printk(KERN_DEBUG "\n");
620 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
621 - task_pid_nr(tsk), tsk->comm, code, address);
622 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
623 + "command='%s' type=%lu address=0x%08lx\n",
624 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
626 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
627 vma->vm_start, vma->vm_end);
628 diff -NurpP --minimal linux-3.0-rc5/arch/powerpc/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/powerpc/Kconfig
629 --- linux-3.0-rc5/arch/powerpc/Kconfig 2011-07-01 11:13:43.000000000 +0200
630 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/powerpc/Kconfig 2011-06-10 22:11:24.000000000 +0200
631 @@ -978,6 +978,8 @@ source "lib/Kconfig"
633 source "arch/powerpc/Kconfig.debug"
635 +source "kernel/vserver/Kconfig"
637 source "security/Kconfig"
640 diff -NurpP --minimal linux-3.0-rc5/arch/powerpc/include/asm/unistd.h linux-3.0-rc5-vs2.3.1-pre3/arch/powerpc/include/asm/unistd.h
641 --- linux-3.0-rc5/arch/powerpc/include/asm/unistd.h 2011-07-01 11:13:44.000000000 +0200
642 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/powerpc/include/asm/unistd.h 2011-06-10 22:11:24.000000000 +0200
645 #define __NR_rtas 255
646 #define __NR_sys_debug_setcontext 256
647 -/* Number 257 is reserved for vserver */
648 +#define __NR_vserver 257
649 #define __NR_migrate_pages 258
650 #define __NR_mbind 259
651 #define __NR_get_mempolicy 260
652 diff -NurpP --minimal linux-3.0-rc5/arch/powerpc/kernel/process.c linux-3.0-rc5-vs2.3.1-pre3/arch/powerpc/kernel/process.c
653 --- linux-3.0-rc5/arch/powerpc/kernel/process.c 2011-07-01 11:13:44.000000000 +0200
654 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/powerpc/kernel/process.c 2011-06-10 22:11:24.000000000 +0200
655 @@ -656,8 +656,9 @@ void show_regs(struct pt_regs * regs)
657 printk("DAR: "REG", DSISR: %08lx\n", regs->dar, regs->dsisr);
659 - printk("TASK = %p[%d] '%s' THREAD: %p",
660 - current, task_pid_nr(current), current->comm, task_thread_info(current));
661 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
662 + current, task_pid_nr(current), current->xid,
663 + current->comm, task_thread_info(current));
666 printk(" CPU: %d", raw_smp_processor_id());
667 diff -NurpP --minimal linux-3.0-rc5/arch/powerpc/kernel/traps.c linux-3.0-rc5-vs2.3.1-pre3/arch/powerpc/kernel/traps.c
668 --- linux-3.0-rc5/arch/powerpc/kernel/traps.c 2011-07-01 11:13:44.000000000 +0200
669 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/powerpc/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
670 @@ -1075,8 +1075,9 @@ void nonrecoverable_exception(struct pt_
672 void trace_syscall(struct pt_regs *regs)
674 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
675 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
676 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
677 + current, task_pid_nr(current), current->xid,
678 + regs->nip, regs->link, regs->gpr[0],
679 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
682 diff -NurpP --minimal linux-3.0-rc5/arch/powerpc/kernel/vdso.c linux-3.0-rc5-vs2.3.1-pre3/arch/powerpc/kernel/vdso.c
683 --- linux-3.0-rc5/arch/powerpc/kernel/vdso.c 2011-05-22 16:17:02.000000000 +0200
684 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/powerpc/kernel/vdso.c 2011-06-10 22:11:24.000000000 +0200
686 #include <linux/security.h>
687 #include <linux/bootmem.h>
688 #include <linux/memblock.h>
689 +#include <linux/vs_memory.h>
691 #include <asm/pgtable.h>
692 #include <asm/system.h>
693 diff -NurpP --minimal linux-3.0-rc5/arch/s390/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/s390/Kconfig
694 --- linux-3.0-rc5/arch/s390/Kconfig 2011-07-01 11:13:45.000000000 +0200
695 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/s390/Kconfig 2011-07-01 11:35:34.000000000 +0200
696 @@ -628,6 +628,8 @@ source "fs/Kconfig"
698 source "arch/s390/Kconfig.debug"
700 +source "kernel/vserver/Kconfig"
702 source "security/Kconfig"
704 source "crypto/Kconfig"
705 diff -NurpP --minimal linux-3.0-rc5/arch/s390/include/asm/tlb.h linux-3.0-rc5-vs2.3.1-pre3/arch/s390/include/asm/tlb.h
706 --- linux-3.0-rc5/arch/s390/include/asm/tlb.h 2011-07-01 11:13:45.000000000 +0200
707 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/s390/include/asm/tlb.h 2011-06-15 02:40:14.000000000 +0200
709 #include <linux/mm.h>
710 #include <linux/pagemap.h>
711 #include <linux/swap.h>
712 +#include <linux/vs_memory.h>
714 #include <asm/processor.h>
715 #include <asm/pgalloc.h>
716 #include <asm/tlbflush.h>
717 diff -NurpP --minimal linux-3.0-rc5/arch/s390/include/asm/unistd.h linux-3.0-rc5-vs2.3.1-pre3/arch/s390/include/asm/unistd.h
718 --- linux-3.0-rc5/arch/s390/include/asm/unistd.h 2011-07-01 11:13:45.000000000 +0200
719 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/s390/include/asm/unistd.h 2011-06-10 22:11:24.000000000 +0200
721 #define __NR_clock_gettime (__NR_timer_create+6)
722 #define __NR_clock_getres (__NR_timer_create+7)
723 #define __NR_clock_nanosleep (__NR_timer_create+8)
724 -/* Number 263 is reserved for vserver */
725 +#define __NR_vserver 263
726 #define __NR_statfs64 265
727 #define __NR_fstatfs64 266
728 #define __NR_remap_file_pages 267
729 diff -NurpP --minimal linux-3.0-rc5/arch/s390/kernel/ptrace.c linux-3.0-rc5-vs2.3.1-pre3/arch/s390/kernel/ptrace.c
730 --- linux-3.0-rc5/arch/s390/kernel/ptrace.c 2011-03-15 18:06:45.000000000 +0100
731 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/s390/kernel/ptrace.c 2011-06-10 22:11:24.000000000 +0200
733 #include <linux/regset.h>
734 #include <linux/tracehook.h>
735 #include <linux/seccomp.h>
736 +#include <linux/vs_base.h>
737 #include <trace/syscall.h>
738 #include <asm/compat.h>
739 #include <asm/segment.h>
740 diff -NurpP --minimal linux-3.0-rc5/arch/s390/kernel/syscalls.S linux-3.0-rc5-vs2.3.1-pre3/arch/s390/kernel/syscalls.S
741 --- linux-3.0-rc5/arch/s390/kernel/syscalls.S 2011-07-01 11:13:45.000000000 +0200
742 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/s390/kernel/syscalls.S 2011-06-10 22:11:24.000000000 +0200
743 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
744 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
745 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
746 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
747 -NI_SYSCALL /* reserved for vserver */
748 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
749 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
750 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
751 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
752 diff -NurpP --minimal linux-3.0-rc5/arch/sh/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/sh/Kconfig
753 --- linux-3.0-rc5/arch/sh/Kconfig 2011-07-01 11:13:45.000000000 +0200
754 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/sh/Kconfig 2011-06-10 22:11:24.000000000 +0200
755 @@ -888,6 +888,8 @@ source "fs/Kconfig"
757 source "arch/sh/Kconfig.debug"
759 +source "kernel/vserver/Kconfig"
761 source "security/Kconfig"
763 source "crypto/Kconfig"
764 diff -NurpP --minimal linux-3.0-rc5/arch/sh/kernel/irq.c linux-3.0-rc5-vs2.3.1-pre3/arch/sh/kernel/irq.c
765 --- linux-3.0-rc5/arch/sh/kernel/irq.c 2011-05-22 16:17:07.000000000 +0200
766 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/sh/kernel/irq.c 2011-06-10 22:11:24.000000000 +0200
768 #include <linux/seq_file.h>
769 #include <linux/ftrace.h>
770 #include <linux/delay.h>
771 +// #include <linux/vs_context.h>
772 #include <linux/ratelimit.h>
773 #include <asm/processor.h>
774 #include <asm/machvec.h>
775 diff -NurpP --minimal linux-3.0-rc5/arch/sh/kernel/vsyscall/vsyscall.c linux-3.0-rc5-vs2.3.1-pre3/arch/sh/kernel/vsyscall/vsyscall.c
776 --- linux-3.0-rc5/arch/sh/kernel/vsyscall/vsyscall.c 2011-05-22 16:17:07.000000000 +0200
777 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/sh/kernel/vsyscall/vsyscall.c 2011-06-10 22:11:24.000000000 +0200
779 #include <linux/elf.h>
780 #include <linux/sched.h>
781 #include <linux/err.h>
782 +#include <linux/vs_memory.h>
785 * Should the kernel map a VDSO page into processes and pass its
786 diff -NurpP --minimal linux-3.0-rc5/arch/sparc/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/sparc/Kconfig
787 --- linux-3.0-rc5/arch/sparc/Kconfig 2011-07-01 11:13:46.000000000 +0200
788 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/sparc/Kconfig 2011-06-15 02:40:14.000000000 +0200
789 @@ -601,6 +601,8 @@ source "fs/Kconfig"
791 source "arch/sparc/Kconfig.debug"
793 +source "kernel/vserver/Kconfig"
795 source "security/Kconfig"
797 source "crypto/Kconfig"
798 diff -NurpP --minimal linux-3.0-rc5/arch/sparc/include/asm/tlb_64.h linux-3.0-rc5-vs2.3.1-pre3/arch/sparc/include/asm/tlb_64.h
799 --- linux-3.0-rc5/arch/sparc/include/asm/tlb_64.h 2011-07-01 11:13:46.000000000 +0200
800 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/sparc/include/asm/tlb_64.h 2011-06-10 22:11:24.000000000 +0200
803 #include <linux/swap.h>
804 #include <linux/pagemap.h>
805 +#include <linux/vs_memory.h>
806 #include <asm/pgalloc.h>
807 #include <asm/tlbflush.h>
808 #include <asm/mmu_context.h>
809 diff -NurpP --minimal linux-3.0-rc5/arch/sparc/include/asm/unistd.h linux-3.0-rc5-vs2.3.1-pre3/arch/sparc/include/asm/unistd.h
810 --- linux-3.0-rc5/arch/sparc/include/asm/unistd.h 2011-07-01 11:13:46.000000000 +0200
811 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/sparc/include/asm/unistd.h 2011-06-10 22:11:24.000000000 +0200
813 #define __NR_timer_getoverrun 264
814 #define __NR_timer_delete 265
815 #define __NR_timer_create 266
816 -/* #define __NR_vserver 267 Reserved for VSERVER */
817 +#define __NR_vserver 267
818 #define __NR_io_setup 268
819 #define __NR_io_destroy 269
820 #define __NR_io_submit 270
821 diff -NurpP --minimal linux-3.0-rc5/arch/sparc/kernel/systbls_32.S linux-3.0-rc5-vs2.3.1-pre3/arch/sparc/kernel/systbls_32.S
822 --- linux-3.0-rc5/arch/sparc/kernel/systbls_32.S 2011-07-01 11:13:46.000000000 +0200
823 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/sparc/kernel/systbls_32.S 2011-06-10 22:11:24.000000000 +0200
824 @@ -70,7 +70,7 @@ sys_call_table:
825 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
826 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
827 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
828 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
829 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
830 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
831 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
832 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
833 diff -NurpP --minimal linux-3.0-rc5/arch/sparc/kernel/systbls_64.S linux-3.0-rc5-vs2.3.1-pre3/arch/sparc/kernel/systbls_64.S
834 --- linux-3.0-rc5/arch/sparc/kernel/systbls_64.S 2011-07-01 11:13:46.000000000 +0200
835 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/sparc/kernel/systbls_64.S 2011-06-10 22:11:24.000000000 +0200
836 @@ -71,7 +71,7 @@ sys_call_table32:
837 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
838 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
839 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
840 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
841 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
842 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
843 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
844 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
845 @@ -148,7 +148,7 @@ sys_call_table:
846 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
847 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
848 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
849 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
850 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
851 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
852 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
853 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
854 diff -NurpP --minimal linux-3.0-rc5/arch/um/Kconfig.rest linux-3.0-rc5-vs2.3.1-pre3/arch/um/Kconfig.rest
855 --- linux-3.0-rc5/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
856 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/um/Kconfig.rest 2011-06-10 22:11:24.000000000 +0200
857 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
861 +source "kernel/vserver/Kconfig"
863 source "security/Kconfig"
865 source "crypto/Kconfig"
866 diff -NurpP --minimal linux-3.0-rc5/arch/um/include/asm/tlb.h linux-3.0-rc5-vs2.3.1-pre3/arch/um/include/asm/tlb.h
867 --- linux-3.0-rc5/arch/um/include/asm/tlb.h 2011-07-01 11:13:46.000000000 +0200
868 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/um/include/asm/tlb.h 2011-06-10 22:11:24.000000000 +0200
871 #include <linux/pagemap.h>
872 #include <linux/swap.h>
873 +#include <linux/vs_memory.h>
874 #include <asm/percpu.h>
875 #include <asm/pgalloc.h>
876 #include <asm/tlbflush.h>
877 diff -NurpP --minimal linux-3.0-rc5/arch/um/include/shared/kern_constants.h linux-3.0-rc5-vs2.3.1-pre3/arch/um/include/shared/kern_constants.h
878 --- linux-3.0-rc5/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
879 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/um/include/shared/kern_constants.h 2011-06-10 22:11:24.000000000 +0200
881 +#include "../../../../include/generated/asm-offsets.h"
882 diff -NurpP --minimal linux-3.0-rc5/arch/um/include/shared/user_constants.h linux-3.0-rc5-vs2.3.1-pre3/arch/um/include/shared/user_constants.h
883 --- linux-3.0-rc5/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
884 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/um/include/shared/user_constants.h 2011-06-10 22:11:24.000000000 +0200
889 + * This file was generated by arch/um/Makefile
893 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2) # */
894 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err) # */
895 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno) # */
896 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long) # */
897 +#define HOST_RBX 5 /* RBX # */
898 +#define HOST_RCX 11 /* RCX # */
899 +#define HOST_RDI 14 /* RDI # */
900 +#define HOST_RSI 13 /* RSI # */
901 +#define HOST_RDX 12 /* RDX # */
902 +#define HOST_RBP 4 /* RBP # */
903 +#define HOST_RAX 10 /* RAX # */
904 +#define HOST_R8 9 /* R8 # */
905 +#define HOST_R9 8 /* R9 # */
906 +#define HOST_R10 7 /* R10 # */
907 +#define HOST_R11 6 /* R11 # */
908 +#define HOST_R12 3 /* R12 # */
909 +#define HOST_R13 2 /* R13 # */
910 +#define HOST_R14 1 /* R14 # */
911 +#define HOST_R15 0 /* R15 # */
912 +#define HOST_ORIG_RAX 15 /* ORIG_RAX # */
913 +#define HOST_CS 17 /* CS # */
914 +#define HOST_SS 20 /* SS # */
915 +#define HOST_EFLAGS 18 /* EFLAGS # */
916 +#define HOST_IP 16 /* RIP # */
917 +#define HOST_SP 19 /* RSP # */
918 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct) # */
919 +#define UM_POLLIN 1 /* POLLIN # */
920 +#define UM_POLLPRI 2 /* POLLPRI # */
921 +#define UM_POLLOUT 4 /* POLLOUT # */
922 +#define UM_PROT_READ 1 /* PROT_READ # */
923 +#define UM_PROT_WRITE 2 /* PROT_WRITE # */
924 +#define UM_PROT_EXEC 4 /* PROT_EXEC # */
926 diff -NurpP --minimal linux-3.0-rc5/arch/x86/Kconfig linux-3.0-rc5-vs2.3.1-pre3/arch/x86/Kconfig
927 --- linux-3.0-rc5/arch/x86/Kconfig 2011-07-01 11:13:47.000000000 +0200
928 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/x86/Kconfig 2011-06-10 22:11:24.000000000 +0200
929 @@ -2159,6 +2159,8 @@ source "fs/Kconfig"
931 source "arch/x86/Kconfig.debug"
933 +source "kernel/vserver/Kconfig"
935 source "security/Kconfig"
937 source "crypto/Kconfig"
938 diff -NurpP --minimal linux-3.0-rc5/arch/x86/ia32/ia32entry.S linux-3.0-rc5-vs2.3.1-pre3/arch/x86/ia32/ia32entry.S
939 --- linux-3.0-rc5/arch/x86/ia32/ia32entry.S 2011-07-01 11:13:47.000000000 +0200
940 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/x86/ia32/ia32entry.S 2011-06-10 22:11:24.000000000 +0200
941 @@ -776,7 +776,7 @@ ia32_sys_call_table:
942 .quad sys_tgkill /* 270 */
943 .quad compat_sys_utimes
944 .quad sys32_fadvise64_64
945 - .quad quiet_ni_syscall /* sys_vserver */
946 + .quad sys32_vserver
948 .quad compat_sys_get_mempolicy /* 275 */
949 .quad sys_set_mempolicy
950 diff -NurpP --minimal linux-3.0-rc5/arch/x86/include/asm/unistd_64.h linux-3.0-rc5-vs2.3.1-pre3/arch/x86/include/asm/unistd_64.h
951 --- linux-3.0-rc5/arch/x86/include/asm/unistd_64.h 2011-07-01 11:13:47.000000000 +0200
952 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/x86/include/asm/unistd_64.h 2011-06-10 22:11:24.000000000 +0200
953 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
954 #define __NR_utimes 235
955 __SYSCALL(__NR_utimes, sys_utimes)
956 #define __NR_vserver 236
957 -__SYSCALL(__NR_vserver, sys_ni_syscall)
958 +__SYSCALL(__NR_vserver, sys_vserver)
959 #define __NR_mbind 237
960 __SYSCALL(__NR_mbind, sys_mbind)
961 #define __NR_set_mempolicy 238
962 diff -NurpP --minimal linux-3.0-rc5/arch/x86/kernel/syscall_table_32.S linux-3.0-rc5-vs2.3.1-pre3/arch/x86/kernel/syscall_table_32.S
963 --- linux-3.0-rc5/arch/x86/kernel/syscall_table_32.S 2011-07-01 11:13:48.000000000 +0200
964 +++ linux-3.0-rc5-vs2.3.1-pre3/arch/x86/kernel/syscall_table_32.S 2011-06-10 22:11:24.000000000 +0200
965 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
966 .long sys_tgkill /* 270 */
968 .long sys_fadvise64_64
969 - .long sys_ni_syscall /* sys_vserver */
972 .long sys_get_mempolicy
973 .long sys_set_mempolicy
974 diff -NurpP --minimal linux-3.0-rc5/block/genhd.c linux-3.0-rc5-vs2.3.1-pre3/block/genhd.c
975 --- linux-3.0-rc5/block/genhd.c 2011-07-01 11:13:48.000000000 +0200
976 +++ linux-3.0-rc5-vs2.3.1-pre3/block/genhd.c 2011-07-01 11:35:34.000000000 +0200
977 @@ -1154,17 +1154,17 @@ static int diskstats_show(struct seq_fil
978 cpu = part_stat_lock();
979 part_round_stats(cpu, hd);
981 - seq_printf(seqf, "%4d %7d %s %lu %lu %llu "
982 - "%u %lu %lu %llu %u %u %u %u\n",
983 + seq_printf(seqf, "%4d %7d %s %lu %lu %lu "
984 + "%u %lu %lu %lu %u %u %u %u\n",
985 MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
986 disk_name(gp, hd->partno, buf),
987 part_stat_read(hd, ios[READ]),
988 part_stat_read(hd, merges[READ]),
989 - (unsigned long long)part_stat_read(hd, sectors[READ]),
990 + part_stat_read(hd, sectors[READ]),
991 jiffies_to_msecs(part_stat_read(hd, ticks[READ])),
992 part_stat_read(hd, ios[WRITE]),
993 part_stat_read(hd, merges[WRITE]),
994 - (unsigned long long)part_stat_read(hd, sectors[WRITE]),
995 + part_stat_read(hd, sectors[WRITE]),
996 jiffies_to_msecs(part_stat_read(hd, ticks[WRITE])),
998 jiffies_to_msecs(part_stat_read(hd, io_ticks)),
999 diff -NurpP --minimal linux-3.0-rc5/drivers/block/Kconfig linux-3.0-rc5-vs2.3.1-pre3/drivers/block/Kconfig
1000 --- linux-3.0-rc5/drivers/block/Kconfig 2011-07-01 11:13:50.000000000 +0200
1001 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/block/Kconfig 2011-06-10 22:11:24.000000000 +0200
1002 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
1004 source "drivers/block/drbd/Kconfig"
1006 +config BLK_DEV_VROOT
1007 + tristate "Virtual Root device support"
1008 + depends on QUOTACTL
1010 + Saying Y here will allow you to use quota/fs ioctls on a shared
1011 + partition within a virtual server without compromising security.
1014 tristate "Network block device support"
1016 diff -NurpP --minimal linux-3.0-rc5/drivers/block/Makefile linux-3.0-rc5-vs2.3.1-pre3/drivers/block/Makefile
1017 --- linux-3.0-rc5/drivers/block/Makefile 2011-07-01 11:13:50.000000000 +0200
1018 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/block/Makefile 2011-06-10 22:11:24.000000000 +0200
1019 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1020 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1021 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1022 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1023 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1025 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1026 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
1027 diff -NurpP --minimal linux-3.0-rc5/drivers/block/loop.c linux-3.0-rc5-vs2.3.1-pre3/drivers/block/loop.c
1028 --- linux-3.0-rc5/drivers/block/loop.c 2011-07-01 11:13:50.000000000 +0200
1029 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/block/loop.c 2011-06-10 22:11:24.000000000 +0200
1031 #include <linux/kthread.h>
1032 #include <linux/splice.h>
1033 #include <linux/sysfs.h>
1034 +#include <linux/vs_context.h>
1036 #include <asm/uaccess.h>
1038 @@ -891,6 +892,7 @@ static int loop_set_fd(struct loop_devic
1039 lo->lo_blocksize = lo_blocksize;
1040 lo->lo_device = bdev;
1041 lo->lo_flags = lo_flags;
1042 + lo->lo_xid = vx_current_xid();
1043 lo->lo_backing_file = file;
1044 lo->transfer = transfer_none;
1046 @@ -1019,6 +1021,7 @@ static int loop_clr_fd(struct loop_devic
1047 lo->lo_encrypt_key_size = 0;
1049 lo->lo_thread = NULL;
1051 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1052 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1053 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1054 @@ -1057,7 +1060,7 @@ loop_set_status(struct loop_device *lo,
1056 if (lo->lo_encrypt_key_size &&
1057 lo->lo_key_owner != uid &&
1058 - !capable(CAP_SYS_ADMIN))
1059 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1061 if (lo->lo_state != Lo_bound)
1063 @@ -1141,7 +1144,8 @@ loop_get_status(struct loop_device *lo,
1064 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1065 info->lo_encrypt_type =
1066 lo->lo_encryption ? lo->lo_encryption->number : 0;
1067 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1068 + if (lo->lo_encrypt_key_size &&
1069 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1070 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1071 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1072 lo->lo_encrypt_key_size);
1073 @@ -1487,6 +1491,9 @@ static int lo_open(struct block_device *
1075 struct loop_device *lo = bdev->bd_disk->private_data;
1077 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1080 mutex_lock(&lo->lo_ctl_mutex);
1082 mutex_unlock(&lo->lo_ctl_mutex);
1083 diff -NurpP --minimal linux-3.0-rc5/drivers/block/vroot.c linux-3.0-rc5-vs2.3.1-pre3/drivers/block/vroot.c
1084 --- linux-3.0-rc5/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1085 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/block/vroot.c 2011-06-10 22:11:24.000000000 +0200
1088 + * linux/drivers/block/vroot.c
1090 + * written by Herbert Pötzl, 9/11/2002
1091 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1093 + * based on the loop.c code by Theodore Ts'o.
1095 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1096 + * Redistribution of this file is permitted under the
1097 + * GNU General Public License.
1101 +#include <linux/module.h>
1102 +#include <linux/moduleparam.h>
1103 +#include <linux/file.h>
1104 +#include <linux/major.h>
1105 +#include <linux/blkdev.h>
1106 +#include <linux/slab.h>
1108 +#include <linux/vroot.h>
1109 +#include <linux/vs_context.h>
1112 +static int max_vroot = 8;
1114 +static struct vroot_device *vroot_dev;
1115 +static struct gendisk **disks;
1118 +static int vroot_set_dev(
1119 + struct vroot_device *vr,
1120 + struct block_device *bdev,
1123 + struct block_device *real_bdev;
1124 + struct file *file;
1125 + struct inode *inode;
1129 + if (vr->vr_state != Vr_unbound)
1138 + inode = file->f_dentry->d_inode;
1141 + if (S_ISBLK(inode->i_mode)) {
1142 + real_bdev = inode->i_bdev;
1143 + vr->vr_device = real_bdev;
1144 + __iget(real_bdev->bd_inode);
1148 + vxdprintk(VXD_CBIT(misc, 0),
1149 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1150 + vr->vr_number, VXD_DEV(real_bdev));
1152 + vr->vr_state = Vr_bound;
1161 +static int vroot_clr_dev(
1162 + struct vroot_device *vr,
1163 + struct block_device *bdev)
1165 + struct block_device *real_bdev;
1167 + if (vr->vr_state != Vr_bound)
1169 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1172 + real_bdev = vr->vr_device;
1174 + vxdprintk(VXD_CBIT(misc, 0),
1175 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1176 + vr->vr_number, VXD_DEV(real_bdev));
1179 + vr->vr_state = Vr_unbound;
1180 + vr->vr_device = NULL;
1185 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1186 + unsigned int cmd, unsigned long arg)
1188 + struct vroot_device *vr = bdev->bd_disk->private_data;
1191 + down(&vr->vr_ctl_mutex);
1193 + case VROOT_SET_DEV:
1194 + err = vroot_set_dev(vr, bdev, arg);
1196 + case VROOT_CLR_DEV:
1197 + err = vroot_clr_dev(vr, bdev);
1203 + up(&vr->vr_ctl_mutex);
1207 +static int vr_open(struct block_device *bdev, fmode_t mode)
1209 + struct vroot_device *vr = bdev->bd_disk->private_data;
1211 + down(&vr->vr_ctl_mutex);
1213 + up(&vr->vr_ctl_mutex);
1217 +static int vr_release(struct gendisk *disk, fmode_t mode)
1219 + struct vroot_device *vr = disk->private_data;
1221 + down(&vr->vr_ctl_mutex);
1223 + up(&vr->vr_ctl_mutex);
1227 +static struct block_device_operations vr_fops = {
1228 + .owner = THIS_MODULE,
1230 + .release = vr_release,
1231 + .ioctl = vr_ioctl,
1234 +static int vroot_make_request(struct request_queue *q, struct bio *bio)
1236 + printk("vroot_make_request %p, %p\n", q, bio);
1237 + bio_io_error(bio);
1241 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1243 + struct inode *inode = bdev->bd_inode;
1244 + struct vroot_device *vr;
1245 + struct block_device *real_bdev;
1246 + int minor = iminor(inode);
1248 + vr = &vroot_dev[minor];
1249 + real_bdev = vr->vr_device;
1251 + vxdprintk(VXD_CBIT(misc, 0),
1252 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1253 + vr->vr_number, VXD_DEV(real_bdev));
1255 + if (vr->vr_state != Vr_bound)
1256 + return ERR_PTR(-ENXIO);
1258 + __iget(real_bdev->bd_inode);
1265 + * And now the modules code and kernel interface.
1268 +module_param(max_vroot, int, 0);
1270 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1271 +MODULE_LICENSE("GPL");
1272 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1274 +MODULE_AUTHOR ("Herbert Pötzl");
1275 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1278 +int __init vroot_init(void)
1282 + if (max_vroot < 1 || max_vroot > 256) {
1283 + max_vroot = MAX_VROOT_DEFAULT;
1284 + printk(KERN_WARNING "vroot: invalid max_vroot "
1285 + "(must be between 1 and 256), "
1286 + "using default (%d)\n", max_vroot);
1289 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1293 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1296 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1298 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1302 + for (i = 0; i < max_vroot; i++) {
1303 + disks[i] = alloc_disk(1);
1306 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1307 + if (!disks[i]->queue)
1309 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1312 + for (i = 0; i < max_vroot; i++) {
1313 + struct vroot_device *vr = &vroot_dev[i];
1314 + struct gendisk *disk = disks[i];
1316 + memset(vr, 0, sizeof(*vr));
1317 + sema_init(&vr->vr_ctl_mutex, 1);
1318 + vr->vr_number = i;
1319 + disk->major = VROOT_MAJOR;
1320 + disk->first_minor = i;
1321 + disk->fops = &vr_fops;
1322 + sprintf(disk->disk_name, "vroot%d", i);
1323 + disk->private_data = vr;
1326 + err = register_vroot_grb(&__vroot_get_real_bdev);
1330 + for (i = 0; i < max_vroot; i++)
1331 + add_disk(disks[i]);
1332 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1337 + put_disk(disks[i]);
1342 + unregister_blkdev(VROOT_MAJOR, "vroot");
1343 + printk(KERN_ERR "vroot: ran out of memory\n");
1347 +void vroot_exit(void)
1351 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1352 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1354 + for (i = 0; i < max_vroot; i++) {
1355 + del_gendisk(disks[i]);
1356 + put_disk(disks[i]);
1358 + unregister_blkdev(VROOT_MAJOR, "vroot");
1364 +module_init(vroot_init);
1365 +module_exit(vroot_exit);
1369 +static int __init max_vroot_setup(char *str)
1371 + max_vroot = simple_strtol(str, NULL, 0);
1375 +__setup("max_vroot=", max_vroot_setup);
1379 diff -NurpP --minimal linux-3.0-rc5/drivers/gpu/drm/radeon/r100_reg_safe.h linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/r100_reg_safe.h
1380 --- linux-3.0-rc5/drivers/gpu/drm/radeon/r100_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1381 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/r100_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
1383 +static const unsigned r100_reg_safe_bm[102] = {
1384 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1385 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1386 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1387 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1388 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1389 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1390 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1391 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1392 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1393 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1394 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1395 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1396 + 0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1397 + 0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1398 + 0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
1399 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1400 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
1401 + 0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
1402 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1403 + 0xFFFFFFFF, 0xFFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1404 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1405 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1406 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1407 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1408 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1409 + 0xFFFFFFFF, 0xFFFFFFEF,
1411 diff -NurpP --minimal linux-3.0-rc5/drivers/gpu/drm/radeon/r200_reg_safe.h linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/r200_reg_safe.h
1412 --- linux-3.0-rc5/drivers/gpu/drm/radeon/r200_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1413 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/r200_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
1415 +static const unsigned r200_reg_safe_bm[102] = {
1416 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1417 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1418 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1419 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1420 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1421 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1422 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1423 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1424 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1425 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1426 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1427 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1428 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1429 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1430 + 0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
1431 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1432 + 0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
1433 + 0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
1434 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1435 + 0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1436 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1437 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1438 + 0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
1439 + 0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
1440 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1441 + 0xFFFFFE3F, 0xFFFFFFEF,
1443 diff -NurpP --minimal linux-3.0-rc5/drivers/gpu/drm/radeon/r300_reg_safe.h linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/r300_reg_safe.h
1444 --- linux-3.0-rc5/drivers/gpu/drm/radeon/r300_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1445 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/r300_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
1447 +static const unsigned r300_reg_safe_bm[159] = {
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 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1456 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1457 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1458 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1459 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1460 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1461 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1462 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1463 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1464 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1465 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1466 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1467 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1468 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1469 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1470 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1471 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1472 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1473 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1474 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1475 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1476 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1477 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1478 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1479 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1480 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1481 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1482 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1483 + 0x00000000, 0x0000C100, 0x00000000, 0x00000000,
1484 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1485 + 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
1486 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1487 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1489 diff -NurpP --minimal linux-3.0-rc5/drivers/gpu/drm/radeon/r420_reg_safe.h linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/r420_reg_safe.h
1490 --- linux-3.0-rc5/drivers/gpu/drm/radeon/r420_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1491 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/r420_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
1493 +static const unsigned r420_reg_safe_bm[159] = {
1494 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1495 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1496 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1497 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1498 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1499 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1500 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1501 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1502 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1503 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1504 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1505 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1506 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1507 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1508 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1509 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1510 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1511 + 0xF0000078, 0xFF000009, 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 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1520 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1521 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1522 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1523 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1524 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1525 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1526 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1527 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1528 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1529 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1530 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1531 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1532 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1533 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1535 diff -NurpP --minimal linux-3.0-rc5/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/rn50_reg_safe.h
1536 --- linux-3.0-rc5/drivers/gpu/drm/radeon/rn50_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1537 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/rn50_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
1539 +static const unsigned rn50_reg_safe_bm[102] = {
1540 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1541 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1542 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1543 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1544 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1545 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1546 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1547 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1548 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1549 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1550 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1551 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1552 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1553 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1554 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
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 + 0xFFFFFFFF, 0xFFFFFFFF,
1567 diff -NurpP --minimal linux-3.0-rc5/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/rs600_reg_safe.h
1568 --- linux-3.0-rc5/drivers/gpu/drm/radeon/rs600_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1569 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/rs600_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
1571 +static const unsigned rs600_reg_safe_bm[219] = {
1572 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1573 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1574 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1575 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1576 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1577 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1578 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1579 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1580 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1581 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1582 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1583 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1584 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1585 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1586 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1587 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1588 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1589 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1590 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1591 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1592 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1593 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1594 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1595 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1596 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1597 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1598 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1599 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1600 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1601 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1602 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1603 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1604 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1605 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1606 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1607 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1608 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1609 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1610 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1611 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
1612 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1613 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1614 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1615 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1616 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1617 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1618 + 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, 0xFFFFFFFF,
1628 diff -NurpP --minimal linux-3.0-rc5/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/rv515_reg_safe.h
1629 --- linux-3.0-rc5/drivers/gpu/drm/radeon/rv515_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1630 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/gpu/drm/radeon/rv515_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
1632 +static const unsigned rv515_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 + 0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1651 + 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 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 + 0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
1666 + 0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
1667 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1668 + 0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
1669 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1670 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
1671 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1672 + 0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
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-3.0-rc5/drivers/infiniband/core/addr.c linux-3.0-rc5-vs2.3.1-pre3/drivers/infiniband/core/addr.c
1690 --- linux-3.0-rc5/drivers/infiniband/core/addr.c 2011-07-01 11:13:52.000000000 +0200
1691 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/infiniband/core/addr.c 2011-06-16 14:16:51.000000000 +0200
1692 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
1694 if (ipv6_addr_any(&fl6.saddr)) {
1695 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1696 - &fl6.daddr, 0, &fl6.saddr);
1697 + &fl6.daddr, 0, &fl6.saddr, NULL);
1701 diff -NurpP --minimal linux-3.0-rc5/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-3.0-rc5-vs2.3.1-pre3/drivers/infiniband/hw/ipath/ipath_user_pages.c
1702 --- linux-3.0-rc5/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-05-22 16:17:16.000000000 +0200
1703 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-06-10 22:11:24.000000000 +0200
1705 #include <linux/device.h>
1706 #include <linux/slab.h>
1707 #include <linux/sched.h>
1708 +#include <linux/vs_memory.h>
1710 #include "ipath_kernel.h"
1712 diff -NurpP --minimal linux-3.0-rc5/drivers/md/dm-ioctl.c linux-3.0-rc5-vs2.3.1-pre3/drivers/md/dm-ioctl.c
1713 --- linux-3.0-rc5/drivers/md/dm-ioctl.c 2011-05-22 16:17:18.000000000 +0200
1714 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/md/dm-ioctl.c 2011-06-10 22:11:24.000000000 +0200
1716 #include <linux/dm-ioctl.h>
1717 #include <linux/hdreg.h>
1718 #include <linux/compat.h>
1719 +#include <linux/vs_context.h>
1721 #include <asm/uaccess.h>
1723 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1724 unsigned int h = hash_str(str);
1726 list_for_each_entry (hc, _name_buckets + h, name_list)
1727 - if (!strcmp(hc->name, str)) {
1728 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1729 + !strcmp(hc->name, str)) {
1733 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1734 unsigned int h = hash_str(str);
1736 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1737 - if (!strcmp(hc->uuid, str)) {
1738 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1739 + !strcmp(hc->uuid, str)) {
1743 @@ -427,6 +430,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1745 static int remove_all(struct dm_ioctl *param, size_t param_size)
1747 + if (!vx_check(0, VS_ADMIN))
1750 dm_hash_remove_all(1);
1751 param->data_size = 0;
1753 @@ -474,6 +480,8 @@ static int list_devices(struct dm_ioctl
1755 for (i = 0; i < NUM_BUCKETS; i++) {
1756 list_for_each_entry (hc, _name_buckets + i, name_list) {
1757 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1759 needed += sizeof(struct dm_name_list);
1760 needed += strlen(hc->name) + 1;
1761 needed += ALIGN_MASK;
1762 @@ -497,6 +505,8 @@ static int list_devices(struct dm_ioctl
1764 for (i = 0; i < NUM_BUCKETS; i++) {
1765 list_for_each_entry (hc, _name_buckets + i, name_list) {
1766 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1769 old_nl->next = (uint32_t) ((void *) nl -
1771 @@ -731,10 +741,11 @@ static struct hash_cell *__find_device_h
1775 - mdptr = dm_get_mdptr(md);
1776 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1777 + mdptr = dm_get_mdptr(md);
1785 @@ -1577,8 +1588,8 @@ static int ctl_ioctl(uint command, struc
1787 size_t input_param_size;
1789 - /* only root can play with this */
1790 - if (!capable(CAP_SYS_ADMIN))
1791 + /* only root and certain contexts can play with this */
1792 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1795 if (_IOC_TYPE(command) != DM_IOCTL)
1796 diff -NurpP --minimal linux-3.0-rc5/drivers/md/dm.c linux-3.0-rc5-vs2.3.1-pre3/drivers/md/dm.c
1797 --- linux-3.0-rc5/drivers/md/dm.c 2011-05-22 16:17:18.000000000 +0200
1798 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/md/dm.c 2011-06-10 22:11:24.000000000 +0200
1800 #include <linux/idr.h>
1801 #include <linux/hdreg.h>
1802 #include <linux/delay.h>
1803 +#include <linux/vs_base.h>
1805 #include <trace/events/block.h>
1807 @@ -119,6 +120,7 @@ struct mapped_device {
1810 atomic_t open_count;
1813 unsigned long flags;
1815 @@ -326,6 +328,7 @@ int dm_deleting_md(struct mapped_device
1816 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1818 struct mapped_device *md;
1821 spin_lock(&_minor_lock);
1823 @@ -334,18 +337,19 @@ static int dm_blk_open(struct block_devi
1826 if (test_bit(DMF_FREEING, &md->flags) ||
1827 - dm_deleting_md(md)) {
1829 + dm_deleting_md(md))
1833 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1838 atomic_inc(&md->open_count);
1842 spin_unlock(&_minor_lock);
1844 - return md ? 0 : -ENXIO;
1848 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1849 @@ -566,6 +570,14 @@ int dm_set_geometry(struct mapped_device
1854 + * Get the xid associated with a dm device
1856 +xid_t dm_get_xid(struct mapped_device *md)
1861 /*-----------------------------------------------------------------
1863 * A more elegant soln is in the works that uses the queue
1864 @@ -1841,6 +1853,7 @@ static struct mapped_device *alloc_dev(i
1865 INIT_LIST_HEAD(&md->uevent_list);
1866 spin_lock_init(&md->uevent_lock);
1868 + md->xid = vx_current_xid();
1869 md->queue = blk_alloc_queue(GFP_KERNEL);
1872 diff -NurpP --minimal linux-3.0-rc5/drivers/md/dm.h linux-3.0-rc5-vs2.3.1-pre3/drivers/md/dm.h
1873 --- linux-3.0-rc5/drivers/md/dm.h 2011-05-22 16:17:18.000000000 +0200
1874 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/md/dm.h 2011-06-10 22:11:24.000000000 +0200
1875 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1877 struct dm_md_mempools;
1879 +xid_t dm_get_xid(struct mapped_device *md);
1881 /*-----------------------------------------------------------------
1882 * Internal table functions.
1883 *---------------------------------------------------------------*/
1884 diff -NurpP --minimal linux-3.0-rc5/drivers/net/tun.c linux-3.0-rc5-vs2.3.1-pre3/drivers/net/tun.c
1885 --- linux-3.0-rc5/drivers/net/tun.c 2011-07-01 11:14:01.000000000 +0200
1886 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/net/tun.c 2011-06-22 12:39:14.000000000 +0200
1888 #include <linux/nsproxy.h>
1889 #include <linux/virtio_net.h>
1890 #include <linux/rcupdate.h>
1891 +#include <linux/vs_network.h>
1892 #include <net/net_namespace.h>
1893 #include <net/netns/generic.h>
1894 #include <net/rtnetlink.h>
1895 @@ -121,6 +122,7 @@ struct tun_struct {
1901 struct net_device *dev;
1903 @@ -904,6 +906,7 @@ static void tun_setup(struct net_device
1907 + tun->nid = current->nid;
1909 dev->ethtool_ops = &tun_ethtool_ops;
1910 dev->destructor = tun_free_netdev;
1911 @@ -1054,7 +1057,7 @@ static int tun_set_iff(struct net *net,
1913 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1914 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1915 - !capable(CAP_NET_ADMIN))
1916 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1918 err = security_tun_dev_attach(tun->socket.sk);
1920 @@ -1068,7 +1071,7 @@ static int tun_set_iff(struct net *net,
1922 unsigned long flags = 0;
1924 - if (!capable(CAP_NET_ADMIN))
1925 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1927 err = security_tun_dev_create();
1929 @@ -1136,6 +1139,9 @@ static int tun_set_iff(struct net *net,
1931 sk->sk_destruct = tun_sock_destruct;
1933 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1936 err = tun_attach(tun, file);
1939 @@ -1317,6 +1323,16 @@ static long __tun_chr_ioctl(struct file
1940 tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
1944 + if (!capable(CAP_CONTEXT))
1947 + /* Set nid owner of the device */
1948 + tun->nid = (nid_t) arg;
1950 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
1954 /* Only allow setting the type when the interface is down */
1955 if (tun->dev->flags & IFF_UP) {
1956 diff -NurpP --minimal linux-3.0-rc5/drivers/tty/sysrq.c linux-3.0-rc5-vs2.3.1-pre3/drivers/tty/sysrq.c
1957 --- linux-3.0-rc5/drivers/tty/sysrq.c 2011-05-22 16:17:44.000000000 +0200
1958 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/tty/sysrq.c 2011-06-10 22:11:24.000000000 +0200
1960 #include <linux/oom.h>
1961 #include <linux/slab.h>
1962 #include <linux/input.h>
1963 +#include <linux/vserver/debug.h>
1965 #include <asm/ptrace.h>
1966 #include <asm/irq_regs.h>
1967 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
1968 .enable_mask = SYSRQ_ENABLE_RTNICE,
1972 +#ifdef CONFIG_VSERVER_DEBUG
1973 +static void sysrq_handle_vxinfo(int key)
1975 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1978 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1979 + .handler = sysrq_handle_vxinfo,
1980 + .help_msg = "conteXt",
1981 + .action_msg = "Show Context Info",
1982 + .enable_mask = SYSRQ_ENABLE_DUMP,
1986 /* Key Operations table and lock */
1987 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1989 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
1991 &sysrq_showstate_blocked_op, /* w */
1992 /* x: May be registered on ppc/powerpc for xmon */
1993 +#ifdef CONFIG_VSERVER_DEBUG
1994 + &sysrq_showvxinfo_op, /* x */
1998 /* y: May be registered on sparc64 for global register dump */
2000 &sysrq_ftrace_dump_op, /* z */
2001 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
2003 else if ((key >= 'a') && (key <= 'z'))
2004 retval = key + 10 - 'a';
2005 + else if ((key >= 'A') && (key <= 'Z'))
2006 + retval = key + 10 - 'A';
2010 diff -NurpP --minimal linux-3.0-rc5/drivers/tty/tty_io.c linux-3.0-rc5-vs2.3.1-pre3/drivers/tty/tty_io.c
2011 --- linux-3.0-rc5/drivers/tty/tty_io.c 2011-07-01 11:14:14.000000000 +0200
2012 +++ linux-3.0-rc5-vs2.3.1-pre3/drivers/tty/tty_io.c 2011-06-10 22:11:24.000000000 +0200
2015 #include <linux/kmod.h>
2016 #include <linux/nsproxy.h>
2017 +#include <linux/vs_pid.h>
2019 #undef TTY_DEBUG_HANGUP
2021 @@ -2057,7 +2058,8 @@ static int tiocsti(struct tty_struct *tt
2023 struct tty_ldisc *ld;
2025 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
2026 + if (((current->signal->tty != tty) &&
2027 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
2029 if (get_user(ch, p))
2031 @@ -2345,6 +2347,7 @@ static int tiocspgrp(struct tty_struct *
2033 if (get_user(pgrp_nr, p))
2035 + pgrp_nr = vx_rmap_pid(pgrp_nr);
2039 diff -NurpP --minimal linux-3.0-rc5/fs/attr.c linux-3.0-rc5-vs2.3.1-pre3/fs/attr.c
2040 --- linux-3.0-rc5/fs/attr.c 2011-07-01 11:14:16.000000000 +0200
2041 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/attr.c 2011-06-10 22:11:24.000000000 +0200
2043 #include <linux/fsnotify.h>
2044 #include <linux/fcntl.h>
2045 #include <linux/security.h>
2046 +#include <linux/proc_fs.h>
2047 +#include <linux/devpts_fs.h>
2048 +#include <linux/vs_tag.h>
2051 * inode_change_ok - check if attribute changes to an inode are allowed
2052 @@ -73,6 +76,10 @@ int inode_change_ok(const struct inode *
2056 + /* check for inode tag permission */
2057 + if (dx_permission(inode, MAY_WRITE))
2062 EXPORT_SYMBOL(inode_change_ok);
2063 @@ -143,6 +150,8 @@ void setattr_copy(struct inode *inode, c
2064 inode->i_uid = attr->ia_uid;
2065 if (ia_valid & ATTR_GID)
2066 inode->i_gid = attr->ia_gid;
2067 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2068 + inode->i_tag = attr->ia_tag;
2069 if (ia_valid & ATTR_ATIME)
2070 inode->i_atime = timespec_trunc(attr->ia_atime,
2071 inode->i_sb->s_time_gran);
2072 @@ -170,7 +179,8 @@ int notify_change(struct dentry * dentry
2073 struct timespec now;
2074 unsigned int ia_valid = attr->ia_valid;
2076 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
2077 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
2078 + ATTR_TAG | ATTR_TIMES_SET)) {
2079 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
2082 diff -NurpP --minimal linux-3.0-rc5/fs/binfmt_aout.c linux-3.0-rc5-vs2.3.1-pre3/fs/binfmt_aout.c
2083 --- linux-3.0-rc5/fs/binfmt_aout.c 2010-10-21 13:07:47.000000000 +0200
2084 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/binfmt_aout.c 2011-06-10 22:11:24.000000000 +0200
2086 #include <linux/init.h>
2087 #include <linux/coredump.h>
2088 #include <linux/slab.h>
2089 +#include <linux/vs_memory.h>
2091 #include <asm/system.h>
2092 #include <asm/uaccess.h>
2093 diff -NurpP --minimal linux-3.0-rc5/fs/binfmt_elf.c linux-3.0-rc5-vs2.3.1-pre3/fs/binfmt_elf.c
2094 --- linux-3.0-rc5/fs/binfmt_elf.c 2011-05-22 16:17:48.000000000 +0200
2095 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/binfmt_elf.c 2011-06-10 22:11:24.000000000 +0200
2097 #include <linux/elf.h>
2098 #include <linux/utsname.h>
2099 #include <linux/coredump.h>
2100 +#include <linux/vs_memory.h>
2101 #include <asm/uaccess.h>
2102 #include <asm/param.h>
2103 #include <asm/page.h>
2104 diff -NurpP --minimal linux-3.0-rc5/fs/binfmt_flat.c linux-3.0-rc5-vs2.3.1-pre3/fs/binfmt_flat.c
2105 --- linux-3.0-rc5/fs/binfmt_flat.c 2011-07-01 11:14:16.000000000 +0200
2106 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/binfmt_flat.c 2011-06-10 22:11:24.000000000 +0200
2108 #include <linux/init.h>
2109 #include <linux/flat.h>
2110 #include <linux/syscalls.h>
2111 +#include <linux/vs_memory.h>
2113 #include <asm/byteorder.h>
2114 #include <asm/system.h>
2115 diff -NurpP --minimal linux-3.0-rc5/fs/binfmt_som.c linux-3.0-rc5-vs2.3.1-pre3/fs/binfmt_som.c
2116 --- linux-3.0-rc5/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
2117 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/binfmt_som.c 2011-06-10 22:11:24.000000000 +0200
2119 #include <linux/shm.h>
2120 #include <linux/personality.h>
2121 #include <linux/init.h>
2122 +#include <linux/vs_memory.h>
2124 #include <asm/uaccess.h>
2125 #include <asm/pgtable.h>
2126 diff -NurpP --minimal linux-3.0-rc5/fs/block_dev.c linux-3.0-rc5-vs2.3.1-pre3/fs/block_dev.c
2127 --- linux-3.0-rc5/fs/block_dev.c 2011-07-01 11:14:16.000000000 +0200
2128 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/block_dev.c 2011-07-01 11:35:34.000000000 +0200
2130 #include <linux/namei.h>
2131 #include <linux/log2.h>
2132 #include <linux/kmemleak.h>
2133 +#include <linux/vs_device.h>
2134 #include <asm/uaccess.h>
2135 #include "internal.h"
2137 @@ -553,6 +554,7 @@ struct block_device *bdget(dev_t dev)
2138 bdev->bd_invalidated = 0;
2139 inode->i_mode = S_IFBLK;
2140 inode->i_rdev = dev;
2141 + inode->i_mdev = dev;
2142 inode->i_bdev = bdev;
2143 inode->i_data.a_ops = &def_blk_aops;
2144 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2145 @@ -599,6 +601,11 @@ EXPORT_SYMBOL(bdput);
2146 static struct block_device *bd_acquire(struct inode *inode)
2148 struct block_device *bdev;
2151 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2153 + inode->i_mdev = mdev;
2155 spin_lock(&bdev_lock);
2156 bdev = inode->i_bdev;
2157 @@ -609,7 +616,7 @@ static struct block_device *bd_acquire(s
2159 spin_unlock(&bdev_lock);
2161 - bdev = bdget(inode->i_rdev);
2162 + bdev = bdget(mdev);
2164 spin_lock(&bdev_lock);
2165 if (!inode->i_bdev) {
2166 diff -NurpP --minimal linux-3.0-rc5/fs/btrfs/ctree.h linux-3.0-rc5-vs2.3.1-pre3/fs/btrfs/ctree.h
2167 --- linux-3.0-rc5/fs/btrfs/ctree.h 2011-07-01 11:14:16.000000000 +0200
2168 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/btrfs/ctree.h 2011-07-01 11:35:34.000000000 +0200
2169 @@ -600,11 +600,14 @@ struct btrfs_inode_item {
2170 /* modification sequence number for NFS */
2175 * a little future expansion, for more than this we can
2176 * just grow the inode item and version it
2178 - __le64 reserved[4];
2179 + __le16 reserved16;
2180 + __le32 reserved32;
2181 + __le64 reserved[3];
2182 struct btrfs_timespec atime;
2183 struct btrfs_timespec ctime;
2184 struct btrfs_timespec mtime;
2185 @@ -1354,6 +1357,8 @@ struct btrfs_ioctl_defrag_range_args {
2186 #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16)
2187 #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17)
2189 +#define BTRFS_MOUNT_TAGGED (1 << 24)
2191 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
2192 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
2193 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
2194 @@ -1563,6 +1568,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
2195 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
2196 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
2197 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
2198 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
2199 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
2200 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
2201 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
2202 @@ -1616,6 +1622,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
2204 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
2206 +#define BTRFS_INODE_IXUNLINK (1 << 24)
2207 +#define BTRFS_INODE_BARRIER (1 << 25)
2208 +#define BTRFS_INODE_COW (1 << 26)
2211 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
2213 @@ -2590,6 +2600,7 @@ extern const struct dentry_operations bt
2214 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2215 void btrfs_update_iflags(struct inode *inode);
2216 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2217 +int btrfs_sync_flags(struct inode *inode, int, int);
2218 int btrfs_defrag_file(struct inode *inode, struct file *file,
2219 struct btrfs_ioctl_defrag_range_args *range,
2220 u64 newer_than, unsigned long max_pages);
2221 diff -NurpP --minimal linux-3.0-rc5/fs/btrfs/disk-io.c linux-3.0-rc5-vs2.3.1-pre3/fs/btrfs/disk-io.c
2222 --- linux-3.0-rc5/fs/btrfs/disk-io.c 2011-07-01 11:14:16.000000000 +0200
2223 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/btrfs/disk-io.c 2011-06-22 12:39:15.000000000 +0200
2224 @@ -1765,6 +1765,9 @@ struct btrfs_root *open_ctree(struct sup
2228 + if (btrfs_test_opt(tree_root, TAGGED))
2229 + sb->s_flags |= MS_TAGGED;
2231 features = btrfs_super_incompat_flags(disk_super) &
2232 ~BTRFS_FEATURE_INCOMPAT_SUPP;
2234 diff -NurpP --minimal linux-3.0-rc5/fs/btrfs/inode.c linux-3.0-rc5-vs2.3.1-pre3/fs/btrfs/inode.c
2235 --- linux-3.0-rc5/fs/btrfs/inode.c 2011-07-01 11:14:17.000000000 +0200
2236 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/btrfs/inode.c 2011-07-01 11:35:34.000000000 +0200
2238 #include <linux/falloc.h>
2239 #include <linux/slab.h>
2240 #include <linux/ratelimit.h>
2241 +#include <linux/vs_tag.h>
2244 #include "disk-io.h"
2245 @@ -2508,6 +2509,8 @@ static void btrfs_read_locked_inode(stru
2246 struct btrfs_key location;
2252 bool filled = false;
2254 @@ -2540,8 +2543,13 @@ static void btrfs_read_locked_inode(stru
2256 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
2257 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
2258 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
2259 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
2261 + uid = btrfs_inode_uid(leaf, inode_item);
2262 + gid = btrfs_inode_gid(leaf, inode_item);
2263 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2264 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2265 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2266 + btrfs_inode_tag(leaf, inode_item));
2267 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
2269 tspec = btrfs_inode_atime(inode_item);
2270 @@ -2624,6 +2632,9 @@ static void fill_inode_item(struct btrfs
2271 struct btrfs_inode_item *item,
2272 struct inode *inode)
2274 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2275 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2277 if (!leaf->map_token)
2278 map_private_extent_buffer(leaf, (unsigned long)item,
2279 sizeof(struct btrfs_inode_item),
2280 @@ -2631,8 +2642,11 @@ static void fill_inode_item(struct btrfs
2281 &leaf->map_start, &leaf->map_len,
2284 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
2285 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
2286 + btrfs_set_inode_uid(leaf, item, uid);
2287 + btrfs_set_inode_gid(leaf, item, gid);
2288 +#ifdef CONFIG_TAGGING_INTERN
2289 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
2291 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
2292 btrfs_set_inode_mode(leaf, item, inode->i_mode);
2293 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
2294 @@ -7357,6 +7371,7 @@ static const struct inode_operations btr
2295 .listxattr = btrfs_listxattr,
2296 .removexattr = btrfs_removexattr,
2297 .permission = btrfs_permission,
2298 + .sync_flags = btrfs_sync_flags,
2300 static const struct inode_operations btrfs_dir_ro_inode_operations = {
2301 .lookup = btrfs_lookup,
2302 @@ -7429,6 +7444,7 @@ static const struct inode_operations btr
2303 .removexattr = btrfs_removexattr,
2304 .permission = btrfs_permission,
2305 .fiemap = btrfs_fiemap,
2306 + .sync_flags = btrfs_sync_flags,
2308 static const struct inode_operations btrfs_special_inode_operations = {
2309 .getattr = btrfs_getattr,
2310 diff -NurpP --minimal linux-3.0-rc5/fs/btrfs/ioctl.c linux-3.0-rc5-vs2.3.1-pre3/fs/btrfs/ioctl.c
2311 --- linux-3.0-rc5/fs/btrfs/ioctl.c 2011-07-01 11:14:17.000000000 +0200
2312 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/btrfs/ioctl.c 2011-06-22 12:39:15.000000000 +0200
2313 @@ -70,10 +70,13 @@ static unsigned int btrfs_flags_to_ioctl
2315 unsigned int iflags = 0;
2317 - if (flags & BTRFS_INODE_SYNC)
2318 - iflags |= FS_SYNC_FL;
2319 if (flags & BTRFS_INODE_IMMUTABLE)
2320 iflags |= FS_IMMUTABLE_FL;
2321 + if (flags & BTRFS_INODE_IXUNLINK)
2322 + iflags |= FS_IXUNLINK_FL;
2324 + if (flags & BTRFS_INODE_SYNC)
2325 + iflags |= FS_SYNC_FL;
2326 if (flags & BTRFS_INODE_APPEND)
2327 iflags |= FS_APPEND_FL;
2328 if (flags & BTRFS_INODE_NODUMP)
2329 @@ -90,28 +93,78 @@ static unsigned int btrfs_flags_to_ioctl
2330 else if (flags & BTRFS_INODE_NOCOMPRESS)
2331 iflags |= FS_NOCOMP_FL;
2333 + if (flags & BTRFS_INODE_BARRIER)
2334 + iflags |= FS_BARRIER_FL;
2335 + if (flags & BTRFS_INODE_COW)
2336 + iflags |= FS_COW_FL;
2341 - * Update inode->i_flags based on the btrfs internal flags.
2342 + * Update inode->i_(v)flags based on the btrfs internal flags.
2344 void btrfs_update_iflags(struct inode *inode)
2346 struct btrfs_inode *ip = BTRFS_I(inode);
2348 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2349 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2350 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2352 - if (ip->flags & BTRFS_INODE_SYNC)
2353 - inode->i_flags |= S_SYNC;
2354 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2355 inode->i_flags |= S_IMMUTABLE;
2356 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2357 + inode->i_flags |= S_IXUNLINK;
2359 + if (ip->flags & BTRFS_INODE_SYNC)
2360 + inode->i_flags |= S_SYNC;
2361 if (ip->flags & BTRFS_INODE_APPEND)
2362 inode->i_flags |= S_APPEND;
2363 if (ip->flags & BTRFS_INODE_NOATIME)
2364 inode->i_flags |= S_NOATIME;
2365 if (ip->flags & BTRFS_INODE_DIRSYNC)
2366 inode->i_flags |= S_DIRSYNC;
2368 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2370 + if (ip->flags & BTRFS_INODE_BARRIER)
2371 + inode->i_vflags |= V_BARRIER;
2372 + if (ip->flags & BTRFS_INODE_COW)
2373 + inode->i_vflags |= V_COW;
2377 + * Update btrfs internal flags from inode->i_(v)flags.
2379 +void btrfs_update_flags(struct inode *inode)
2381 + struct btrfs_inode *ip = BTRFS_I(inode);
2383 + unsigned int flags = inode->i_flags;
2384 + unsigned int vflags = inode->i_vflags;
2386 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2387 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2388 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2389 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2391 + if (flags & S_IMMUTABLE)
2392 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2393 + if (flags & S_IXUNLINK)
2394 + ip->flags |= BTRFS_INODE_IXUNLINK;
2396 + if (flags & S_SYNC)
2397 + ip->flags |= BTRFS_INODE_SYNC;
2398 + if (flags & S_APPEND)
2399 + ip->flags |= BTRFS_INODE_APPEND;
2400 + if (flags & S_NOATIME)
2401 + ip->flags |= BTRFS_INODE_NOATIME;
2402 + if (flags & S_DIRSYNC)
2403 + ip->flags |= BTRFS_INODE_DIRSYNC;
2405 + if (vflags & V_BARRIER)
2406 + ip->flags |= BTRFS_INODE_BARRIER;
2407 + if (vflags & V_COW)
2408 + ip->flags |= BTRFS_INODE_COW;
2412 @@ -129,7 +182,7 @@ void btrfs_inherit_iflags(struct inode *
2413 flags = BTRFS_I(dir)->flags;
2415 if (S_ISREG(inode->i_mode))
2416 - flags &= ~BTRFS_INODE_DIRSYNC;
2417 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2418 else if (!S_ISDIR(inode->i_mode))
2419 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2421 @@ -137,6 +190,30 @@ void btrfs_inherit_iflags(struct inode *
2422 btrfs_update_iflags(inode);
2425 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2427 + struct btrfs_inode *ip = BTRFS_I(inode);
2428 + struct btrfs_root *root = ip->root;
2429 + struct btrfs_trans_handle *trans;
2432 + trans = btrfs_join_transaction(root);
2435 + inode->i_flags = flags;
2436 + inode->i_vflags = vflags;
2437 + btrfs_update_flags(inode);
2439 + ret = btrfs_update_inode(trans, root, inode);
2442 + btrfs_update_iflags(inode);
2443 + inode->i_ctime = CURRENT_TIME;
2444 + btrfs_end_transaction(trans, root);
2449 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2451 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2452 @@ -188,7 +265,8 @@ static int btrfs_ioctl_setflags(struct f
2454 flags = btrfs_mask_flags(inode->i_mode, flags);
2455 oldflags = btrfs_flags_to_ioctl(ip->flags);
2456 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2457 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2458 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2459 if (!capable(CAP_LINUX_IMMUTABLE)) {
2462 @@ -199,14 +277,19 @@ static int btrfs_ioctl_setflags(struct f
2466 - if (flags & FS_SYNC_FL)
2467 - ip->flags |= BTRFS_INODE_SYNC;
2469 - ip->flags &= ~BTRFS_INODE_SYNC;
2470 if (flags & FS_IMMUTABLE_FL)
2471 ip->flags |= BTRFS_INODE_IMMUTABLE;
2473 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2474 + if (flags & FS_IXUNLINK_FL)
2475 + ip->flags |= BTRFS_INODE_IXUNLINK;
2477 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2479 + if (flags & FS_SYNC_FL)
2480 + ip->flags |= BTRFS_INODE_SYNC;
2482 + ip->flags &= ~BTRFS_INODE_SYNC;
2483 if (flags & FS_APPEND_FL)
2484 ip->flags |= BTRFS_INODE_APPEND;
2486 diff -NurpP --minimal linux-3.0-rc5/fs/btrfs/super.c linux-3.0-rc5-vs2.3.1-pre3/fs/btrfs/super.c
2487 --- linux-3.0-rc5/fs/btrfs/super.c 2011-07-01 11:14:17.000000000 +0200
2488 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/btrfs/super.c 2011-06-15 02:40:14.000000000 +0200
2489 @@ -162,7 +162,7 @@ enum {
2490 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
2491 Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
2492 Opt_enospc_debug, Opt_subvolrootid, Opt_defrag,
2493 - Opt_inode_cache, Opt_err,
2494 + Opt_inode_cache, Opt_tag, Opt_notag, Opt_tagid, Opt_err,
2497 static match_table_t tokens = {
2498 @@ -195,6 +195,9 @@ static match_table_t tokens = {
2499 {Opt_subvolrootid, "subvolrootid=%d"},
2500 {Opt_defrag, "autodefrag"},
2501 {Opt_inode_cache, "inode_cache"},
2503 + {Opt_notag, "notag"},
2504 + {Opt_tagid, "tagid=%u"},
2508 @@ -381,6 +384,22 @@ int btrfs_parse_options(struct btrfs_roo
2509 printk(KERN_INFO "btrfs: enabling auto defrag");
2510 btrfs_set_opt(info->mount_opt, AUTO_DEFRAG);
2512 +#ifndef CONFIG_TAGGING_NONE
2514 + printk(KERN_INFO "btrfs: use tagging\n");
2515 + btrfs_set_opt(info->mount_opt, TAGGED);
2518 + printk(KERN_INFO "btrfs: disabled tagging\n");
2519 + btrfs_clear_opt(info->mount_opt, TAGGED);
2522 +#ifdef CONFIG_PROPAGATE
2525 + btrfs_set_opt(info->mount_opt, TAGGED);
2529 printk(KERN_INFO "btrfs: unrecognized mount option "
2531 @@ -901,6 +920,12 @@ static int btrfs_remount(struct super_bl
2535 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2536 + printk("btrfs: %s: tagging not permitted on remount.\n",
2541 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2544 diff -NurpP --minimal linux-3.0-rc5/fs/char_dev.c linux-3.0-rc5-vs2.3.1-pre3/fs/char_dev.c
2545 --- linux-3.0-rc5/fs/char_dev.c 2011-03-15 18:07:31.000000000 +0100
2546 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/char_dev.c 2011-06-10 22:11:24.000000000 +0200
2548 #include <linux/mutex.h>
2549 #include <linux/backing-dev.h>
2550 #include <linux/tty.h>
2551 +#include <linux/vs_context.h>
2552 +#include <linux/vs_device.h>
2554 #include "internal.h"
2556 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2558 struct cdev *new = NULL;
2562 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2564 + inode->i_mdev = mdev;
2566 spin_lock(&cdev_lock);
2569 struct kobject *kobj;
2572 spin_unlock(&cdev_lock);
2573 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2575 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2578 new = container_of(kobj, struct cdev, kobj);
2579 diff -NurpP --minimal linux-3.0-rc5/fs/dcache.c linux-3.0-rc5-vs2.3.1-pre3/fs/dcache.c
2580 --- linux-3.0-rc5/fs/dcache.c 2011-07-01 11:14:17.000000000 +0200
2581 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/dcache.c 2011-06-10 22:35:26.000000000 +0200
2583 #include <linux/bit_spinlock.h>
2584 #include <linux/rculist_bl.h>
2585 #include <linux/prefetch.h>
2586 +#include <linux/vs_limit.h>
2587 #include "internal.h"
2590 @@ -479,6 +480,8 @@ int d_invalidate(struct dentry * dentry)
2591 spin_lock(&dentry->d_lock);
2594 + vx_dentry_dec(dentry);
2597 * Somebody else still using it?
2599 @@ -506,6 +509,7 @@ EXPORT_SYMBOL(d_invalidate);
2600 static inline void __dget_dlock(struct dentry *dentry)
2603 + vx_dentry_inc(dentry);
2606 static inline void __dget(struct dentry *dentry)
2607 @@ -1266,6 +1270,9 @@ struct dentry *d_alloc(struct dentry * p
2608 struct dentry *dentry;
2611 + if (!vx_dentry_avail(1))
2614 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2617 @@ -1288,6 +1295,7 @@ struct dentry *d_alloc(struct dentry * p
2619 dentry->d_count = 1;
2620 dentry->d_flags = 0;
2621 + vx_dentry_inc(dentry);
2622 spin_lock_init(&dentry->d_lock);
2623 seqcount_init(&dentry->d_seq);
2624 dentry->d_inode = NULL;
2625 @@ -1947,6 +1955,7 @@ struct dentry *__d_lookup(struct dentry
2629 + vx_dentry_inc(dentry);
2631 spin_unlock(&dentry->d_lock);
2633 diff -NurpP --minimal linux-3.0-rc5/fs/devpts/inode.c linux-3.0-rc5-vs2.3.1-pre3/fs/devpts/inode.c
2634 --- linux-3.0-rc5/fs/devpts/inode.c 2011-05-22 16:17:50.000000000 +0200
2635 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/devpts/inode.c 2011-06-10 22:11:24.000000000 +0200
2637 #include <linux/parser.h>
2638 #include <linux/fsnotify.h>
2639 #include <linux/seq_file.h>
2640 +#include <linux/vs_base.h>
2642 #define DEVPTS_DEFAULT_MODE 0600
2645 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2646 #define PTMX_MINOR 2
2648 +static int devpts_permission(struct inode *inode, int mask, unsigned int flags)
2650 + int ret = -EACCES;
2652 + /* devpts is xid tagged */
2653 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2654 + ret = generic_permission(inode, mask, flags, NULL);
2658 +static struct inode_operations devpts_file_inode_operations = {
2659 + .permission = devpts_permission,
2662 extern int pty_limit; /* Config limit on Unix98 ptys */
2663 static DEFINE_MUTEX(allocated_ptys_lock);
2665 @@ -263,6 +278,34 @@ static int devpts_show_options(struct se
2669 +static int devpts_filter(struct dentry *de)
2673 + /* devpts is xid tagged */
2674 + if (de && de->d_inode)
2675 + xid = (xid_t)de->d_inode->i_tag;
2676 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2678 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2679 + de->d_name.len, de->d_name.name);
2681 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2684 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2686 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2689 +static struct file_operations devpts_dir_operations = {
2690 + .open = dcache_dir_open,
2691 + .release = dcache_dir_close,
2692 + .llseek = dcache_dir_lseek,
2693 + .read = generic_read_dir,
2694 + .readdir = devpts_readdir,
2697 static const struct super_operations devpts_sops = {
2698 .statfs = simple_statfs,
2699 .remount_fs = devpts_remount,
2700 @@ -302,12 +345,15 @@ devpts_fill_super(struct super_block *s,
2701 inode = new_inode(s);
2706 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2707 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2708 inode->i_op = &simple_dir_inode_operations;
2709 - inode->i_fop = &simple_dir_operations;
2710 + inode->i_fop = &devpts_dir_operations;
2712 + /* devpts is xid tagged */
2713 + inode->i_tag = (tag_t)vx_current_xid();
2715 s->s_root = d_alloc_root(inode);
2717 @@ -494,6 +540,9 @@ int devpts_pty_new(struct inode *ptmx_in
2718 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2719 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2720 init_special_inode(inode, S_IFCHR|opts->mode, device);
2721 + /* devpts is xid tagged */
2722 + inode->i_tag = (tag_t)vx_current_xid();
2723 + inode->i_op = &devpts_file_inode_operations;
2724 inode->i_private = tty;
2725 tty->driver_data = inode;
2727 diff -NurpP --minimal linux-3.0-rc5/fs/ext2/balloc.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/balloc.c
2728 --- linux-3.0-rc5/fs/ext2/balloc.c 2011-05-22 16:17:51.000000000 +0200
2729 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/balloc.c 2011-06-10 22:11:24.000000000 +0200
2730 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2732 end = EXT2_BLOCKS_PER_GROUP(sb);
2735 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2738 diff -NurpP --minimal linux-3.0-rc5/fs/ext2/ext2.h linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/ext2.h
2739 --- linux-3.0-rc5/fs/ext2/ext2.h 2011-05-22 16:17:51.000000000 +0200
2740 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/ext2.h 2011-06-10 22:11:24.000000000 +0200
2741 @@ -126,6 +126,7 @@ extern void ext2_set_inode_flags(struct
2742 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2743 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2744 u64 start, u64 len);
2745 +extern int ext2_sync_flags(struct inode *, int, int);
2748 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2749 diff -NurpP --minimal linux-3.0-rc5/fs/ext2/file.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/file.c
2750 --- linux-3.0-rc5/fs/ext2/file.c 2010-08-02 16:52:48.000000000 +0200
2751 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/file.c 2011-06-10 22:11:24.000000000 +0200
2752 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2753 .setattr = ext2_setattr,
2754 .check_acl = ext2_check_acl,
2755 .fiemap = ext2_fiemap,
2756 + .sync_flags = ext2_sync_flags,
2758 diff -NurpP --minimal linux-3.0-rc5/fs/ext2/ialloc.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/ialloc.c
2759 --- linux-3.0-rc5/fs/ext2/ialloc.c 2011-05-22 16:17:51.000000000 +0200
2760 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/ialloc.c 2011-06-10 22:11:24.000000000 +0200
2762 #include <linux/backing-dev.h>
2763 #include <linux/buffer_head.h>
2764 #include <linux/random.h>
2765 +#include <linux/vs_tag.h>
2769 @@ -549,6 +550,7 @@ got:
2770 inode->i_mode = mode;
2771 inode->i_uid = current_fsuid();
2772 inode->i_gid = dir->i_gid;
2773 + inode->i_tag = dx_current_fstag(sb);
2775 inode_init_owner(inode, dir, mode);
2777 diff -NurpP --minimal linux-3.0-rc5/fs/ext2/inode.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/inode.c
2778 --- linux-3.0-rc5/fs/ext2/inode.c 2011-05-22 16:17:51.000000000 +0200
2779 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/inode.c 2011-06-10 22:11:24.000000000 +0200
2781 #include <linux/mpage.h>
2782 #include <linux/fiemap.h>
2783 #include <linux/namei.h>
2784 +#include <linux/vs_tag.h>
2788 @@ -1167,7 +1168,7 @@ static void ext2_truncate_blocks(struct
2790 if (ext2_inode_is_fast_symlink(inode))
2792 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2793 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2795 __ext2_truncate_blocks(inode, offset);
2797 @@ -1256,36 +1257,61 @@ void ext2_set_inode_flags(struct inode *
2799 unsigned int flags = EXT2_I(inode)->i_flags;
2801 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2802 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2803 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2806 + if (flags & EXT2_IMMUTABLE_FL)
2807 + inode->i_flags |= S_IMMUTABLE;
2808 + if (flags & EXT2_IXUNLINK_FL)
2809 + inode->i_flags |= S_IXUNLINK;
2811 if (flags & EXT2_SYNC_FL)
2812 inode->i_flags |= S_SYNC;
2813 if (flags & EXT2_APPEND_FL)
2814 inode->i_flags |= S_APPEND;
2815 - if (flags & EXT2_IMMUTABLE_FL)
2816 - inode->i_flags |= S_IMMUTABLE;
2817 if (flags & EXT2_NOATIME_FL)
2818 inode->i_flags |= S_NOATIME;
2819 if (flags & EXT2_DIRSYNC_FL)
2820 inode->i_flags |= S_DIRSYNC;
2822 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2824 + if (flags & EXT2_BARRIER_FL)
2825 + inode->i_vflags |= V_BARRIER;
2826 + if (flags & EXT2_COW_FL)
2827 + inode->i_vflags |= V_COW;
2830 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2831 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2833 unsigned int flags = ei->vfs_inode.i_flags;
2834 + unsigned int vflags = ei->vfs_inode.i_vflags;
2836 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2837 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2838 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2839 + EXT2_BARRIER_FL | EXT2_COW_FL);
2841 + if (flags & S_IMMUTABLE)
2842 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2843 + if (flags & S_IXUNLINK)
2844 + ei->i_flags |= EXT2_IXUNLINK_FL;
2846 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2847 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2849 ei->i_flags |= EXT2_SYNC_FL;
2850 if (flags & S_APPEND)
2851 ei->i_flags |= EXT2_APPEND_FL;
2852 - if (flags & S_IMMUTABLE)
2853 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2854 if (flags & S_NOATIME)
2855 ei->i_flags |= EXT2_NOATIME_FL;
2856 if (flags & S_DIRSYNC)
2857 ei->i_flags |= EXT2_DIRSYNC_FL;
2859 + if (vflags & V_BARRIER)
2860 + ei->i_flags |= EXT2_BARRIER_FL;
2861 + if (vflags & V_COW)
2862 + ei->i_flags |= EXT2_COW_FL;
2865 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2866 @@ -1295,6 +1321,8 @@ struct inode *ext2_iget (struct super_bl
2867 struct ext2_inode *raw_inode;
2868 struct inode *inode;
2874 inode = iget_locked(sb, ino);
2875 @@ -1313,12 +1341,17 @@ struct inode *ext2_iget (struct super_bl
2878 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2879 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2880 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2881 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2882 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2883 if (!(test_opt (inode->i_sb, NO_UID32))) {
2884 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2885 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2886 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2887 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2889 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2890 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2891 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2892 + le16_to_cpu(raw_inode->i_raw_tag));
2894 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2895 inode->i_size = le32_to_cpu(raw_inode->i_size);
2896 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2897 @@ -1416,8 +1449,8 @@ static int __ext2_write_inode(struct ino
2898 struct ext2_inode_info *ei = EXT2_I(inode);
2899 struct super_block *sb = inode->i_sb;
2900 ino_t ino = inode->i_ino;
2901 - uid_t uid = inode->i_uid;
2902 - gid_t gid = inode->i_gid;
2903 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2904 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2905 struct buffer_head * bh;
2906 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2908 @@ -1453,6 +1486,9 @@ static int __ext2_write_inode(struct ino
2909 raw_inode->i_uid_high = 0;
2910 raw_inode->i_gid_high = 0;
2912 +#ifdef CONFIG_TAGGING_INTERN
2913 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2915 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2916 raw_inode->i_size = cpu_to_le32(inode->i_size);
2917 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2918 @@ -1533,7 +1569,8 @@ int ext2_setattr(struct dentry *dentry,
2919 if (is_quota_modification(inode, iattr))
2920 dquot_initialize(inode);
2921 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2922 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2923 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2924 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2925 error = dquot_transfer(inode, iattr);
2928 diff -NurpP --minimal linux-3.0-rc5/fs/ext2/ioctl.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/ioctl.c
2929 --- linux-3.0-rc5/fs/ext2/ioctl.c 2011-05-22 16:17:51.000000000 +0200
2930 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/ioctl.c 2011-06-10 22:11:24.000000000 +0200
2932 #include <asm/uaccess.h>
2935 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2937 + inode->i_flags = flags;
2938 + inode->i_vflags = vflags;
2939 + ext2_get_inode_flags(EXT2_I(inode));
2940 + inode->i_ctime = CURRENT_TIME_SEC;
2941 + mark_inode_dirty(inode);
2945 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2947 struct inode *inode = filp->f_dentry->d_inode;
2948 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2950 flags = ext2_mask_flags(inode->i_mode, flags);
2952 + if (IS_BARRIER(inode)) {
2953 + vxwprintk_task(1, "messing with the barrier.");
2957 mutex_lock(&inode->i_mutex);
2958 /* Is it quota file? Do not allow user to mess with it */
2959 if (IS_NOQUOTA(inode)) {
2960 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2962 * This test looks nicer. Thanks to Pauline Middelink
2964 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2965 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2966 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2967 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2968 if (!capable(CAP_LINUX_IMMUTABLE)) {
2969 mutex_unlock(&inode->i_mutex);
2971 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2975 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2976 + flags &= EXT2_FL_USER_MODIFIABLE;
2977 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2978 ei->i_flags = flags;
2979 mutex_unlock(&inode->i_mutex);
2980 diff -NurpP --minimal linux-3.0-rc5/fs/ext2/namei.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/namei.c
2981 --- linux-3.0-rc5/fs/ext2/namei.c 2011-05-22 16:17:51.000000000 +0200
2982 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/namei.c 2011-06-10 22:11:24.000000000 +0200
2985 #include <linux/pagemap.h>
2986 #include <linux/quotaops.h>
2987 +#include <linux/vs_tag.h>
2991 @@ -75,6 +76,7 @@ static struct dentry *ext2_lookup(struct
2992 return ERR_PTR(-EIO);
2994 return ERR_CAST(inode);
2995 + dx_propagate_tag(nd, inode);
2999 @@ -413,6 +415,7 @@ const struct inode_operations ext2_dir_i
3001 .setattr = ext2_setattr,
3002 .check_acl = ext2_check_acl,
3003 + .sync_flags = ext2_sync_flags,
3006 const struct inode_operations ext2_special_inode_operations = {
3007 diff -NurpP --minimal linux-3.0-rc5/fs/ext2/super.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/super.c
3008 --- linux-3.0-rc5/fs/ext2/super.c 2011-07-01 11:14:18.000000000 +0200
3009 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext2/super.c 2011-06-10 22:11:24.000000000 +0200
3010 @@ -394,7 +394,8 @@ enum {
3011 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3012 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3013 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3014 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
3015 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
3016 + Opt_tag, Opt_notag, Opt_tagid
3019 static const match_table_t tokens = {
3020 @@ -422,6 +423,9 @@ static const match_table_t tokens = {
3022 {Opt_noacl, "noacl"},
3025 + {Opt_notag, "notag"},
3026 + {Opt_tagid, "tagid=%u"},
3027 {Opt_grpquota, "grpquota"},
3028 {Opt_ignore, "noquota"},
3029 {Opt_quota, "quota"},
3030 @@ -492,6 +496,20 @@ static int parse_options(char *options,
3032 set_opt (sbi->s_mount_opt, NO_UID32);
3034 +#ifndef CONFIG_TAGGING_NONE
3036 + set_opt (sbi->s_mount_opt, TAGGED);
3039 + clear_opt (sbi->s_mount_opt, TAGGED);
3042 +#ifdef CONFIG_PROPAGATE
3045 + set_opt (sbi->s_mount_opt, TAGGED);
3049 clear_opt (sbi->s_mount_opt, CHECK);
3051 @@ -850,6 +868,8 @@ static int ext2_fill_super(struct super_
3052 if (!parse_options((char *) data, sb))
3055 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3056 + sb->s_flags |= MS_TAGGED;
3057 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3058 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3060 @@ -1224,6 +1244,14 @@ static int ext2_remount (struct super_bl
3064 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3065 + !(sb->s_flags & MS_TAGGED)) {
3066 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3069 + goto restore_opts;
3072 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3073 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3075 diff -NurpP --minimal linux-3.0-rc5/fs/ext3/file.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext3/file.c
3076 --- linux-3.0-rc5/fs/ext3/file.c 2010-07-07 18:31:51.000000000 +0200
3077 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext3/file.c 2011-06-10 22:11:24.000000000 +0200
3078 @@ -81,5 +81,6 @@ const struct inode_operations ext3_file_
3080 .check_acl = ext3_check_acl,
3081 .fiemap = ext3_fiemap,
3082 + .sync_flags = ext3_sync_flags,
3085 diff -NurpP --minimal linux-3.0-rc5/fs/ext3/ialloc.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext3/ialloc.c
3086 --- linux-3.0-rc5/fs/ext3/ialloc.c 2011-05-22 16:17:52.000000000 +0200
3087 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext3/ialloc.c 2011-06-10 22:11:24.000000000 +0200
3089 #include <linux/buffer_head.h>
3090 #include <linux/random.h>
3091 #include <linux/bitops.h>
3092 +#include <linux/vs_tag.h>
3094 #include <asm/byteorder.h>
3096 @@ -532,6 +533,7 @@ got:
3097 inode->i_mode = mode;
3098 inode->i_uid = current_fsuid();
3099 inode->i_gid = dir->i_gid;
3100 + inode->i_tag = dx_current_fstag(sb);
3102 inode_init_owner(inode, dir, mode);
3104 diff -NurpP --minimal linux-3.0-rc5/fs/ext3/inode.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext3/inode.c
3105 --- linux-3.0-rc5/fs/ext3/inode.c 2011-07-01 11:14:18.000000000 +0200
3106 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext3/inode.c 2011-06-10 22:11:24.000000000 +0200
3108 #include <linux/bio.h>
3109 #include <linux/fiemap.h>
3110 #include <linux/namei.h>
3111 +#include <linux/vs_tag.h>
3115 @@ -2391,7 +2392,7 @@ static void ext3_free_branches(handle_t
3117 int ext3_can_truncate(struct inode *inode)
3119 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3120 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3122 if (S_ISREG(inode->i_mode))
3124 @@ -2775,36 +2776,60 @@ void ext3_set_inode_flags(struct inode *
3126 unsigned int flags = EXT3_I(inode)->i_flags;
3128 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3129 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3130 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3132 + if (flags & EXT3_IMMUTABLE_FL)
3133 + inode->i_flags |= S_IMMUTABLE;
3134 + if (flags & EXT3_IXUNLINK_FL)
3135 + inode->i_flags |= S_IXUNLINK;
3137 if (flags & EXT3_SYNC_FL)
3138 inode->i_flags |= S_SYNC;
3139 if (flags & EXT3_APPEND_FL)
3140 inode->i_flags |= S_APPEND;
3141 - if (flags & EXT3_IMMUTABLE_FL)
3142 - inode->i_flags |= S_IMMUTABLE;
3143 if (flags & EXT3_NOATIME_FL)
3144 inode->i_flags |= S_NOATIME;
3145 if (flags & EXT3_DIRSYNC_FL)
3146 inode->i_flags |= S_DIRSYNC;
3148 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3150 + if (flags & EXT3_BARRIER_FL)
3151 + inode->i_vflags |= V_BARRIER;
3152 + if (flags & EXT3_COW_FL)
3153 + inode->i_vflags |= V_COW;
3156 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
3157 void ext3_get_inode_flags(struct ext3_inode_info *ei)
3159 unsigned int flags = ei->vfs_inode.i_flags;
3160 + unsigned int vflags = ei->vfs_inode.i_vflags;
3162 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
3163 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
3164 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
3165 + EXT3_BARRIER_FL | EXT3_COW_FL);
3167 + if (flags & S_IMMUTABLE)
3168 + ei->i_flags |= EXT3_IMMUTABLE_FL;
3169 + if (flags & S_IXUNLINK)
3170 + ei->i_flags |= EXT3_IXUNLINK_FL;
3172 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
3173 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
3175 ei->i_flags |= EXT3_SYNC_FL;
3176 if (flags & S_APPEND)
3177 ei->i_flags |= EXT3_APPEND_FL;
3178 - if (flags & S_IMMUTABLE)
3179 - ei->i_flags |= EXT3_IMMUTABLE_FL;
3180 if (flags & S_NOATIME)
3181 ei->i_flags |= EXT3_NOATIME_FL;
3182 if (flags & S_DIRSYNC)
3183 ei->i_flags |= EXT3_DIRSYNC_FL;
3185 + if (vflags & V_BARRIER)
3186 + ei->i_flags |= EXT3_BARRIER_FL;
3187 + if (vflags & V_COW)
3188 + ei->i_flags |= EXT3_COW_FL;
3191 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3192 @@ -2818,6 +2843,8 @@ struct inode *ext3_iget(struct super_blo
3193 transaction_t *transaction;
3199 inode = iget_locked(sb, ino);
3201 @@ -2834,12 +2861,17 @@ struct inode *ext3_iget(struct super_blo
3203 raw_inode = ext3_raw_inode(&iloc);
3204 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3205 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3206 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3207 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3208 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3209 if(!(test_opt (inode->i_sb, NO_UID32))) {
3210 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3211 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3212 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3213 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3215 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3216 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3217 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3218 + le16_to_cpu(raw_inode->i_raw_tag));
3220 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3221 inode->i_size = le32_to_cpu(raw_inode->i_size);
3222 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3223 @@ -2994,6 +3026,8 @@ static int ext3_do_update_inode(handle_t
3224 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3225 struct ext3_inode_info *ei = EXT3_I(inode);
3226 struct buffer_head *bh = iloc->bh;
3227 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3228 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3229 int err = 0, rc, block;
3232 @@ -3008,29 +3042,32 @@ again:
3233 ext3_get_inode_flags(ei);
3234 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3235 if(!(test_opt(inode->i_sb, NO_UID32))) {
3236 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3237 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3238 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3239 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3241 * Fix up interoperability with old kernels. Otherwise, old inodes get
3242 * re-used with the upper 16 bits of the uid/gid intact
3245 raw_inode->i_uid_high =
3246 - cpu_to_le16(high_16_bits(inode->i_uid));
3247 + cpu_to_le16(high_16_bits(uid));
3248 raw_inode->i_gid_high =
3249 - cpu_to_le16(high_16_bits(inode->i_gid));
3250 + cpu_to_le16(high_16_bits(gid));
3252 raw_inode->i_uid_high = 0;
3253 raw_inode->i_gid_high = 0;
3256 raw_inode->i_uid_low =
3257 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3258 + cpu_to_le16(fs_high2lowuid(uid));
3259 raw_inode->i_gid_low =
3260 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3261 + cpu_to_le16(fs_high2lowgid(gid));
3262 raw_inode->i_uid_high = 0;
3263 raw_inode->i_gid_high = 0;
3265 +#ifdef CONFIG_TAGGING_INTERN
3266 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3268 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3269 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3270 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3271 @@ -3190,7 +3227,8 @@ int ext3_setattr(struct dentry *dentry,
3272 if (is_quota_modification(inode, attr))
3273 dquot_initialize(inode);
3274 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3275 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3276 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3277 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3280 /* (user+group)*(old+new) structure, inode write (sb,
3281 @@ -3212,6 +3250,8 @@ int ext3_setattr(struct dentry *dentry,
3282 inode->i_uid = attr->ia_uid;
3283 if (attr->ia_valid & ATTR_GID)
3284 inode->i_gid = attr->ia_gid;
3285 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3286 + inode->i_tag = attr->ia_tag;
3287 error = ext3_mark_inode_dirty(handle, inode);
3288 ext3_journal_stop(handle);
3290 diff -NurpP --minimal linux-3.0-rc5/fs/ext3/ioctl.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext3/ioctl.c
3291 --- linux-3.0-rc5/fs/ext3/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3292 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext3/ioctl.c 2011-06-10 22:11:24.000000000 +0200
3296 #include <linux/fs.h>
3297 +#include <linux/mount.h>
3298 #include <linux/jbd.h>
3299 #include <linux/capability.h>
3300 #include <linux/ext3_fs.h>
3302 #include <linux/compat.h>
3303 #include <asm/uaccess.h>
3306 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
3308 + handle_t *handle = NULL;
3309 + struct ext3_iloc iloc;
3312 + handle = ext3_journal_start(inode, 1);
3313 + if (IS_ERR(handle))
3314 + return PTR_ERR(handle);
3316 + if (IS_SYNC(inode))
3317 + handle->h_sync = 1;
3318 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3322 + inode->i_flags = flags;
3323 + inode->i_vflags = vflags;
3324 + ext3_get_inode_flags(EXT3_I(inode));
3325 + inode->i_ctime = CURRENT_TIME_SEC;
3327 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3329 + ext3_journal_stop(handle);
3333 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3335 struct inode *inode = filp->f_dentry->d_inode;
3336 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
3338 flags = ext3_mask_flags(inode->i_mode, flags);
3340 + if (IS_BARRIER(inode)) {
3341 + vxwprintk_task(1, "messing with the barrier.");
3345 mutex_lock(&inode->i_mutex);
3347 /* Is it quota file? Do not allow user to mess with it */
3348 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3350 * This test looks nicer. Thanks to Pauline Middelink
3352 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3353 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3354 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3355 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3356 if (!capable(CAP_LINUX_IMMUTABLE))
3359 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3363 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3364 + flags &= EXT3_FL_USER_MODIFIABLE;
3365 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3366 ei->i_flags = flags;
3368 diff -NurpP --minimal linux-3.0-rc5/fs/ext3/namei.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext3/namei.c
3369 --- linux-3.0-rc5/fs/ext3/namei.c 2011-07-01 11:14:18.000000000 +0200
3370 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext3/namei.c 2011-06-10 22:11:24.000000000 +0200
3372 #include <linux/quotaops.h>
3373 #include <linux/buffer_head.h>
3374 #include <linux/bio.h>
3375 +#include <linux/vs_tag.h>
3379 @@ -923,6 +924,7 @@ restart:
3381 ll_rw_block(READ_META, 1, &bh);
3383 + dx_propagate_tag(nd, inode);
3385 if ((bh = bh_use[ra_ptr++]) == NULL)
3387 @@ -2534,6 +2536,7 @@ const struct inode_operations ext3_dir_i
3388 .removexattr = generic_removexattr,
3390 .check_acl = ext3_check_acl,
3391 + .sync_flags = ext3_sync_flags,
3394 const struct inode_operations ext3_special_inode_operations = {
3395 diff -NurpP --minimal linux-3.0-rc5/fs/ext3/super.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext3/super.c
3396 --- linux-3.0-rc5/fs/ext3/super.c 2011-07-01 11:14:18.000000000 +0200
3397 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext3/super.c 2011-06-10 22:11:24.000000000 +0200
3398 @@ -821,7 +821,8 @@ enum {
3399 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3400 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
3401 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
3402 - Opt_resize, Opt_usrquota, Opt_grpquota
3403 + Opt_resize, Opt_usrquota, Opt_grpquota,
3404 + Opt_tag, Opt_notag, Opt_tagid
3407 static const match_table_t tokens = {
3408 @@ -878,6 +879,9 @@ static const match_table_t tokens = {
3409 {Opt_barrier, "barrier"},
3410 {Opt_nobarrier, "nobarrier"},
3411 {Opt_resize, "resize"},
3413 + {Opt_notag, "notag"},
3414 + {Opt_tagid, "tagid=%u"},
3418 @@ -1030,6 +1034,20 @@ static int parse_options (char *options,
3420 set_opt (sbi->s_mount_opt, NO_UID32);
3422 +#ifndef CONFIG_TAGGING_NONE
3424 + set_opt (sbi->s_mount_opt, TAGGED);
3427 + clear_opt (sbi->s_mount_opt, TAGGED);
3430 +#ifdef CONFIG_PROPAGATE
3433 + set_opt (sbi->s_mount_opt, TAGGED);
3437 clear_opt (sbi->s_mount_opt, CHECK);
3439 @@ -1724,6 +1742,9 @@ static int ext3_fill_super (struct super
3443 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3444 + sb->s_flags |= MS_TAGGED;
3446 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3447 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3449 @@ -2604,6 +2625,14 @@ static int ext3_remount (struct super_bl
3450 if (test_opt(sb, ABORT))
3451 ext3_abort(sb, __func__, "Abort forced by user");
3453 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3454 + !(sb->s_flags & MS_TAGGED)) {
3455 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3458 + goto restore_opts;
3461 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3462 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3464 diff -NurpP --minimal linux-3.0-rc5/fs/ext4/ext4.h linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/ext4.h
3465 --- linux-3.0-rc5/fs/ext4/ext4.h 2011-07-01 11:14:18.000000000 +0200
3466 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/ext4.h 2011-06-10 22:11:24.000000000 +0200
3467 @@ -350,8 +350,12 @@ struct flex_groups {
3468 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3469 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
3470 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
3471 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3472 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3474 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3475 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3477 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3478 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3480 @@ -608,7 +612,8 @@ struct ext4_inode {
3481 __le16 l_i_file_acl_high;
3482 __le16 l_i_uid_high; /* these 2 fields */
3483 __le16 l_i_gid_high; /* were reserved2[0] */
3484 - __u32 l_i_reserved2;
3485 + __le16 l_i_tag; /* Context Tag */
3486 + __u16 l_i_reserved2;
3489 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3490 @@ -726,6 +731,7 @@ do { \
3491 #define i_gid_low i_gid
3492 #define i_uid_high osd2.linux2.l_i_uid_high
3493 #define i_gid_high osd2.linux2.l_i_gid_high
3494 +#define i_raw_tag osd2.linux2.l_i_tag
3495 #define i_reserved2 osd2.linux2.l_i_reserved2
3497 #elif defined(__GNU__)
3498 @@ -902,6 +908,7 @@ struct ext4_inode_info {
3499 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3500 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3501 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3502 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3503 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3504 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3505 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3506 @@ -2172,6 +2179,7 @@ extern int ext4_map_blocks(handle_t *han
3507 struct ext4_map_blocks *map, int flags);
3508 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3509 __u64 start, __u64 len);
3510 +extern int ext4_sync_flags(struct inode *, int, int);
3512 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3513 __u64 start_orig, __u64 start_donor,
3514 diff -NurpP --minimal linux-3.0-rc5/fs/ext4/file.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/file.c
3515 --- linux-3.0-rc5/fs/ext4/file.c 2011-07-01 11:14:18.000000000 +0200
3516 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/file.c 2011-06-10 22:11:24.000000000 +0200
3517 @@ -282,5 +282,6 @@ const struct inode_operations ext4_file_
3519 .check_acl = ext4_check_acl,
3520 .fiemap = ext4_fiemap,
3521 + .sync_flags = ext4_sync_flags,
3524 diff -NurpP --minimal linux-3.0-rc5/fs/ext4/ialloc.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/ialloc.c
3525 --- linux-3.0-rc5/fs/ext4/ialloc.c 2011-05-22 16:17:52.000000000 +0200
3526 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/ialloc.c 2011-06-10 22:11:24.000000000 +0200
3528 #include <linux/random.h>
3529 #include <linux/bitops.h>
3530 #include <linux/blkdev.h>
3531 +#include <linux/vs_tag.h>
3532 #include <asm/byteorder.h>
3535 @@ -992,6 +993,7 @@ got:
3536 inode->i_mode = mode;
3537 inode->i_uid = current_fsuid();
3538 inode->i_gid = dir->i_gid;
3539 + inode->i_tag = dx_current_fstag(sb);
3541 inode_init_owner(inode, dir, mode);
3543 diff -NurpP --minimal linux-3.0-rc5/fs/ext4/inode.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/inode.c
3544 --- linux-3.0-rc5/fs/ext4/inode.c 2011-07-01 11:14:18.000000000 +0200
3545 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/inode.c 2011-07-01 11:35:34.000000000 +0200
3547 #include <linux/printk.h>
3548 #include <linux/slab.h>
3549 #include <linux/ratelimit.h>
3550 +#include <linux/vs_tag.h>
3552 #include "ext4_jbd2.h"
3554 @@ -4797,41 +4798,64 @@ void ext4_set_inode_flags(struct inode *
3556 unsigned int flags = EXT4_I(inode)->i_flags;
3558 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3559 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3560 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3562 + if (flags & EXT4_IMMUTABLE_FL)
3563 + inode->i_flags |= S_IMMUTABLE;
3564 + if (flags & EXT4_IXUNLINK_FL)
3565 + inode->i_flags |= S_IXUNLINK;
3567 if (flags & EXT4_SYNC_FL)
3568 inode->i_flags |= S_SYNC;
3569 if (flags & EXT4_APPEND_FL)
3570 inode->i_flags |= S_APPEND;
3571 - if (flags & EXT4_IMMUTABLE_FL)
3572 - inode->i_flags |= S_IMMUTABLE;
3573 if (flags & EXT4_NOATIME_FL)
3574 inode->i_flags |= S_NOATIME;
3575 if (flags & EXT4_DIRSYNC_FL)
3576 inode->i_flags |= S_DIRSYNC;
3578 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3580 + if (flags & EXT4_BARRIER_FL)
3581 + inode->i_vflags |= V_BARRIER;
3582 + if (flags & EXT4_COW_FL)
3583 + inode->i_vflags |= V_COW;
3586 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3587 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3589 - unsigned int vfs_fl;
3590 + unsigned int vfs_fl, vfs_vf;
3591 unsigned long old_fl, new_fl;
3594 vfs_fl = ei->vfs_inode.i_flags;
3595 + vfs_vf = ei->vfs_inode.i_vflags;
3596 old_fl = ei->i_flags;
3597 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3598 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3600 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3603 + if (vfs_fl & S_IMMUTABLE)
3604 + new_fl |= EXT4_IMMUTABLE_FL;
3605 + if (vfs_fl & S_IXUNLINK)
3606 + new_fl |= EXT4_IXUNLINK_FL;
3608 if (vfs_fl & S_SYNC)
3609 new_fl |= EXT4_SYNC_FL;
3610 if (vfs_fl & S_APPEND)
3611 new_fl |= EXT4_APPEND_FL;
3612 - if (vfs_fl & S_IMMUTABLE)
3613 - new_fl |= EXT4_IMMUTABLE_FL;
3614 if (vfs_fl & S_NOATIME)
3615 new_fl |= EXT4_NOATIME_FL;
3616 if (vfs_fl & S_DIRSYNC)
3617 new_fl |= EXT4_DIRSYNC_FL;
3619 + if (vfs_vf & V_BARRIER)
3620 + new_fl |= EXT4_BARRIER_FL;
3621 + if (vfs_vf & V_COW)
3622 + new_fl |= EXT4_COW_FL;
3623 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3626 @@ -4867,6 +4891,8 @@ struct inode *ext4_iget(struct super_blo
3627 journal_t *journal = EXT4_SB(sb)->s_journal;
3633 inode = iget_locked(sb, ino);
3635 @@ -4882,12 +4908,16 @@ struct inode *ext4_iget(struct super_blo
3637 raw_inode = ext4_raw_inode(&iloc);
3638 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3639 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3640 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3641 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3642 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3643 if (!(test_opt(inode->i_sb, NO_UID32))) {
3644 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3645 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3646 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3647 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3649 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3650 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3651 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3652 + le16_to_cpu(raw_inode->i_raw_tag));
3653 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3655 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3656 @@ -5106,6 +5136,8 @@ static int ext4_do_update_inode(handle_t
3657 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3658 struct ext4_inode_info *ei = EXT4_I(inode);
3659 struct buffer_head *bh = iloc->bh;
3660 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3661 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3662 int err = 0, rc, block;
3664 /* For fields not not tracking in the in-memory inode,
3665 @@ -5116,29 +5148,32 @@ static int ext4_do_update_inode(handle_t
3666 ext4_get_inode_flags(ei);
3667 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3668 if (!(test_opt(inode->i_sb, NO_UID32))) {
3669 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3670 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3671 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3672 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3674 * Fix up interoperability with old kernels. Otherwise, old inodes get
3675 * re-used with the upper 16 bits of the uid/gid intact
3678 raw_inode->i_uid_high =
3679 - cpu_to_le16(high_16_bits(inode->i_uid));
3680 + cpu_to_le16(high_16_bits(uid));
3681 raw_inode->i_gid_high =
3682 - cpu_to_le16(high_16_bits(inode->i_gid));
3683 + cpu_to_le16(high_16_bits(gid));
3685 raw_inode->i_uid_high = 0;
3686 raw_inode->i_gid_high = 0;
3689 raw_inode->i_uid_low =
3690 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3691 + cpu_to_le16(fs_high2lowuid(uid));
3692 raw_inode->i_gid_low =
3693 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3694 + cpu_to_le16(fs_high2lowgid(gid));
3695 raw_inode->i_uid_high = 0;
3696 raw_inode->i_gid_high = 0;
3698 +#ifdef CONFIG_TAGGING_INTERN
3699 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3701 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3703 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3704 @@ -5324,7 +5359,8 @@ int ext4_setattr(struct dentry *dentry,
3705 if (is_quota_modification(inode, attr))
3706 dquot_initialize(inode);
3707 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3708 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3709 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3710 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3713 /* (user+group)*(old+new) structure, inode write (sb,
3714 @@ -5346,6 +5382,8 @@ int ext4_setattr(struct dentry *dentry,
3715 inode->i_uid = attr->ia_uid;
3716 if (attr->ia_valid & ATTR_GID)
3717 inode->i_gid = attr->ia_gid;
3718 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3719 + inode->i_tag = attr->ia_tag;
3720 error = ext4_mark_inode_dirty(handle, inode);
3721 ext4_journal_stop(handle);
3723 diff -NurpP --minimal linux-3.0-rc5/fs/ext4/ioctl.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/ioctl.c
3724 --- linux-3.0-rc5/fs/ext4/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3725 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/ioctl.c 2011-06-10 22:11:24.000000000 +0200
3727 #include <linux/compat.h>
3728 #include <linux/mount.h>
3729 #include <linux/file.h>
3730 +#include <linux/vs_tag.h>
3731 #include <asm/uaccess.h>
3732 #include "ext4_jbd2.h"
3736 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3738 + handle_t *handle = NULL;
3739 + struct ext4_iloc iloc;
3742 + handle = ext4_journal_start(inode, 1);
3743 + if (IS_ERR(handle))
3744 + return PTR_ERR(handle);
3746 + if (IS_SYNC(inode))
3747 + ext4_handle_sync(handle);
3748 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3752 + inode->i_flags = flags;
3753 + inode->i_vflags = vflags;
3754 + ext4_get_inode_flags(EXT4_I(inode));
3755 + inode->i_ctime = ext4_current_time(inode);
3757 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3759 + ext4_journal_stop(handle);
3763 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3765 struct inode *inode = filp->f_dentry->d_inode;
3766 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3768 flags = ext4_mask_flags(inode->i_mode, flags);
3770 + if (IS_BARRIER(inode)) {
3771 + vxwprintk_task(1, "messing with the barrier.");
3776 mutex_lock(&inode->i_mutex);
3777 /* Is it quota file? Do not allow user to mess with it */
3778 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3780 * This test looks nicer. Thanks to Pauline Middelink
3782 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3783 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3784 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3785 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3786 if (!capable(CAP_LINUX_IMMUTABLE))
3789 diff -NurpP --minimal linux-3.0-rc5/fs/ext4/namei.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/namei.c
3790 --- linux-3.0-rc5/fs/ext4/namei.c 2011-07-01 11:14:18.000000000 +0200
3791 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/namei.c 2011-06-10 22:11:24.000000000 +0200
3793 #include <linux/quotaops.h>
3794 #include <linux/buffer_head.h>
3795 #include <linux/bio.h>
3796 +#include <linux/vs_tag.h>
3798 #include "ext4_jbd2.h"
3800 @@ -924,6 +925,7 @@ restart:
3802 ll_rw_block(READ_META, 1, &bh);
3804 + dx_propagate_tag(nd, inode);
3806 if ((bh = bh_use[ra_ptr++]) == NULL)
3808 @@ -2596,6 +2598,7 @@ const struct inode_operations ext4_dir_i
3810 .check_acl = ext4_check_acl,
3811 .fiemap = ext4_fiemap,
3812 + .sync_flags = ext4_sync_flags,
3815 const struct inode_operations ext4_special_inode_operations = {
3816 diff -NurpP --minimal linux-3.0-rc5/fs/ext4/super.c linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/super.c
3817 --- linux-3.0-rc5/fs/ext4/super.c 2011-07-01 11:14:18.000000000 +0200
3818 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ext4/super.c 2011-07-01 11:35:34.000000000 +0200
3819 @@ -1294,6 +1294,7 @@ enum {
3820 Opt_dioread_nolock, Opt_dioread_lock,
3821 Opt_discard, Opt_nodiscard,
3822 Opt_init_inode_table, Opt_noinit_inode_table,
3823 + Opt_tag, Opt_notag, Opt_tagid
3826 static const match_table_t tokens = {
3827 @@ -1369,6 +1370,9 @@ static const match_table_t tokens = {
3828 {Opt_init_inode_table, "init_itable=%u"},
3829 {Opt_init_inode_table, "init_itable"},
3830 {Opt_noinit_inode_table, "noinit_itable"},
3832 + {Opt_notag, "notag"},
3833 + {Opt_tagid, "tagid=%u"},
3837 @@ -1537,6 +1541,20 @@ static int parse_options(char *options,
3839 set_opt(sb, NO_UID32);
3841 +#ifndef CONFIG_TAGGING_NONE
3843 + set_opt(sb, TAGGED);
3846 + clear_opt(sb, TAGGED);
3849 +#ifdef CONFIG_PROPAGATE
3852 + set_opt(sb, TAGGED);
3858 @@ -3194,6 +3212,9 @@ static int ext4_fill_super(struct super_
3859 &journal_ioprio, NULL, 0))
3862 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3863 + sb->s_flags |= MS_TAGGED;
3865 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3866 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3868 @@ -4324,6 +4345,14 @@ static int ext4_remount(struct super_blo
3869 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3870 ext4_abort(sb, "Abort forced by user");
3872 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3873 + !(sb->s_flags & MS_TAGGED)) {
3874 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3877 + goto restore_opts;
3880 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3881 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3883 diff -NurpP --minimal linux-3.0-rc5/fs/fcntl.c linux-3.0-rc5-vs2.3.1-pre3/fs/fcntl.c
3884 --- linux-3.0-rc5/fs/fcntl.c 2011-05-22 16:17:52.000000000 +0200
3885 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/fcntl.c 2011-06-10 22:11:24.000000000 +0200
3887 #include <linux/signal.h>
3888 #include <linux/rcupdate.h>
3889 #include <linux/pid_namespace.h>
3890 +#include <linux/vs_limit.h>
3892 #include <asm/poll.h>
3893 #include <asm/siginfo.h>
3894 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3897 filp_close(tofree, files);
3899 + vx_openfd_inc(newfd); /* fd was unused */
3903 @@ -447,6 +450,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3904 filp = fget_raw(fd);
3907 + if (!vx_files_avail(1))
3910 if (unlikely(filp->f_mode & FMODE_PATH)) {
3911 if (!check_fcntl_cmd(cmd)) {
3912 diff -NurpP --minimal linux-3.0-rc5/fs/file.c linux-3.0-rc5-vs2.3.1-pre3/fs/file.c
3913 --- linux-3.0-rc5/fs/file.c 2011-05-22 16:17:52.000000000 +0200
3914 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/file.c 2011-06-10 22:11:24.000000000 +0200
3916 #include <linux/spinlock.h>
3917 #include <linux/rcupdate.h>
3918 #include <linux/workqueue.h>
3919 +#include <linux/vs_limit.h>
3921 struct fdtable_defer {
3923 @@ -359,6 +360,8 @@ struct files_struct *dup_fd(struct files
3924 struct file *f = *old_fds++;
3927 + /* TODO: sum it first for check and performance */
3928 + vx_openfd_inc(open_files - i);
3931 * The fd may be claimed in the fd bitmap but not yet
3932 @@ -466,6 +469,7 @@ repeat:
3934 FD_CLR(fd, fdt->close_on_exec);
3936 + vx_openfd_inc(fd);
3939 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3940 diff -NurpP --minimal linux-3.0-rc5/fs/file_table.c linux-3.0-rc5-vs2.3.1-pre3/fs/file_table.c
3941 --- linux-3.0-rc5/fs/file_table.c 2011-05-22 16:17:52.000000000 +0200
3942 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/file_table.c 2011-06-10 22:11:24.000000000 +0200
3944 #include <linux/percpu_counter.h>
3945 #include <linux/percpu.h>
3946 #include <linux/ima.h>
3947 +#include <linux/vs_limit.h>
3948 +#include <linux/vs_context.h>
3950 #include <asm/atomic.h>
3952 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
3953 spin_lock_init(&f->f_lock);
3954 eventpoll_init_file(f);
3955 /* f->f_version: 0 */
3956 + f->f_xid = vx_current_xid();
3961 @@ -253,6 +257,8 @@ static void __fput(struct file *file)
3963 fops_put(file->f_op);
3964 put_pid(file->f_owner.pid);
3965 + vx_files_dec(file);
3967 file_sb_list_del(file);
3968 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
3969 i_readcount_dec(inode);
3970 @@ -383,6 +389,8 @@ void put_filp(struct file *file)
3972 if (atomic_long_dec_and_test(&file->f_count)) {
3973 security_file_free(file);
3974 + vx_files_dec(file);
3976 file_sb_list_del(file);
3979 diff -NurpP --minimal linux-3.0-rc5/fs/fs_struct.c linux-3.0-rc5-vs2.3.1-pre3/fs/fs_struct.c
3980 --- linux-3.0-rc5/fs/fs_struct.c 2011-03-15 18:07:31.000000000 +0100
3981 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/fs_struct.c 2011-06-10 22:11:24.000000000 +0200
3983 #include <linux/path.h>
3984 #include <linux/slab.h>
3985 #include <linux/fs_struct.h>
3986 +#include <linux/vserver/global.h>
3987 #include "internal.h"
3989 static inline void path_get_longterm(struct path *path)
3990 @@ -96,6 +97,7 @@ void free_fs_struct(struct fs_struct *fs
3992 path_put_longterm(&fs->root);
3993 path_put_longterm(&fs->pwd);
3994 + atomic_dec(&vs_global_fs);
3995 kmem_cache_free(fs_cachep, fs);
3998 @@ -135,6 +137,7 @@ struct fs_struct *copy_fs_struct(struct
4000 path_get_longterm(&fs->pwd);
4001 spin_unlock(&old->lock);
4002 + atomic_inc(&vs_global_fs);
4006 diff -NurpP --minimal linux-3.0-rc5/fs/gfs2/file.c linux-3.0-rc5-vs2.3.1-pre3/fs/gfs2/file.c
4007 --- linux-3.0-rc5/fs/gfs2/file.c 2011-07-01 11:14:18.000000000 +0200
4008 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/gfs2/file.c 2011-06-10 22:11:24.000000000 +0200
4009 @@ -134,6 +134,9 @@ static const u32 fsflags_to_gfs2[32] = {
4010 [7] = GFS2_DIF_NOATIME,
4011 [12] = GFS2_DIF_EXHASH,
4012 [14] = GFS2_DIF_INHERIT_JDATA,
4013 + [27] = GFS2_DIF_IXUNLINK,
4014 + [26] = GFS2_DIF_BARRIER,
4015 + [29] = GFS2_DIF_COW,
4018 static const u32 gfs2_to_fsflags[32] = {
4019 @@ -143,6 +146,9 @@ static const u32 gfs2_to_fsflags[32] = {
4020 [gfs2fl_NoAtime] = FS_NOATIME_FL,
4021 [gfs2fl_ExHash] = FS_INDEX_FL,
4022 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
4023 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
4024 + [gfs2fl_Barrier] = FS_BARRIER_FL,
4025 + [gfs2fl_Cow] = FS_COW_FL,
4028 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
4029 @@ -173,10 +179,16 @@ void gfs2_set_inode_flags(struct inode *
4031 struct gfs2_inode *ip = GFS2_I(inode);
4032 unsigned int flags = inode->i_flags;
4033 + unsigned int vflags = inode->i_vflags;
4035 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4036 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4038 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4039 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
4040 flags |= S_IMMUTABLE;
4041 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
4042 + flags |= S_IXUNLINK;
4044 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
4046 if (ip->i_diskflags & GFS2_DIF_NOATIME)
4047 @@ -184,6 +196,43 @@ void gfs2_set_inode_flags(struct inode *
4048 if (ip->i_diskflags & GFS2_DIF_SYNC)
4050 inode->i_flags = flags;
4052 + vflags &= ~(V_BARRIER | V_COW);
4054 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
4055 + vflags |= V_BARRIER;
4056 + if (ip->i_diskflags & GFS2_DIF_COW)
4058 + inode->i_vflags = vflags;
4061 +void gfs2_get_inode_flags(struct inode *inode)
4063 + struct gfs2_inode *ip = GFS2_I(inode);
4064 + unsigned int flags = inode->i_flags;
4065 + unsigned int vflags = inode->i_vflags;
4067 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
4068 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
4069 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
4070 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
4072 + if (flags & S_IMMUTABLE)
4073 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
4074 + if (flags & S_IXUNLINK)
4075 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
4077 + if (flags & S_APPEND)
4078 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
4079 + if (flags & S_NOATIME)
4080 + ip->i_diskflags |= GFS2_DIF_NOATIME;
4081 + if (flags & S_SYNC)
4082 + ip->i_diskflags |= GFS2_DIF_SYNC;
4084 + if (vflags & V_BARRIER)
4085 + ip->i_diskflags |= GFS2_DIF_BARRIER;
4086 + if (vflags & V_COW)
4087 + ip->i_diskflags |= GFS2_DIF_COW;
4090 /* Flags that can be set by user space */
4091 @@ -295,6 +344,37 @@ static int gfs2_set_flags(struct file *f
4092 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
4095 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
4097 + struct gfs2_inode *ip = GFS2_I(inode);
4098 + struct gfs2_sbd *sdp = GFS2_SB(inode);
4099 + struct buffer_head *bh;
4100 + struct gfs2_holder gh;
4103 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
4106 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
4109 + error = gfs2_meta_inode_buffer(ip, &bh);
4111 + goto out_trans_end;
4112 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
4113 + inode->i_flags = flags;
4114 + inode->i_vflags = vflags;
4115 + gfs2_get_inode_flags(inode);
4116 + gfs2_dinode_out(ip, bh->b_data);
4118 + gfs2_set_aops(inode);
4120 + gfs2_trans_end(sdp);
4122 + gfs2_glock_dq_uninit(&gh);
4126 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4129 diff -NurpP --minimal linux-3.0-rc5/fs/gfs2/inode.h linux-3.0-rc5-vs2.3.1-pre3/fs/gfs2/inode.h
4130 --- linux-3.0-rc5/fs/gfs2/inode.h 2011-07-01 11:14:18.000000000 +0200
4131 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/gfs2/inode.h 2011-06-10 22:11:24.000000000 +0200
4132 @@ -120,6 +120,7 @@ extern const struct file_operations gfs2
4133 extern const struct file_operations gfs2_dir_fops_nolock;
4135 extern void gfs2_set_inode_flags(struct inode *inode);
4136 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
4138 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
4139 extern const struct file_operations gfs2_file_fops;
4140 diff -NurpP --minimal linux-3.0-rc5/fs/inode.c linux-3.0-rc5-vs2.3.1-pre3/fs/inode.c
4141 --- linux-3.0-rc5/fs/inode.c 2011-07-01 11:14:18.000000000 +0200
4142 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/inode.c 2011-07-01 11:35:34.000000000 +0200
4144 #include <linux/ima.h>
4145 #include <linux/cred.h>
4146 #include <linux/buffer_head.h> /* for inode_has_buffers */
4147 +#include <linux/vs_tag.h>
4148 #include "internal.h"
4151 @@ -146,6 +147,9 @@ int inode_init_always(struct super_block
4152 struct address_space *const mapping = &inode->i_data;
4156 + /* essential because of inode slab reuse */
4158 inode->i_blkbits = sb->s_blocksize_bits;
4160 atomic_set(&inode->i_count, 1);
4161 @@ -166,6 +170,7 @@ int inode_init_always(struct super_block
4162 inode->i_bdev = NULL;
4163 inode->i_cdev = NULL;
4165 + inode->i_mdev = 0;
4166 inode->dirtied_when = 0;
4168 if (security_inode_alloc(inode))
4169 @@ -404,6 +409,8 @@ void __insert_inode_hash(struct inode *i
4171 EXPORT_SYMBOL(__insert_inode_hash);
4173 +EXPORT_SYMBOL_GPL(__iget);
4176 * remove_inode_hash - remove an inode from the hash
4177 * @inode: inode to unhash
4178 @@ -1643,9 +1650,11 @@ void init_special_inode(struct inode *in
4179 if (S_ISCHR(mode)) {
4180 inode->i_fop = &def_chr_fops;
4181 inode->i_rdev = rdev;
4182 + inode->i_mdev = rdev;
4183 } else if (S_ISBLK(mode)) {
4184 inode->i_fop = &def_blk_fops;
4185 inode->i_rdev = rdev;
4186 + inode->i_mdev = rdev;
4187 } else if (S_ISFIFO(mode))
4188 inode->i_fop = &def_fifo_fops;
4189 else if (S_ISSOCK(mode))
4190 @@ -1674,6 +1683,7 @@ void inode_init_owner(struct inode *inod
4192 inode->i_gid = current_fsgid();
4193 inode->i_mode = mode;
4194 + inode->i_tag = dx_current_fstag(inode->i_sb);
4196 EXPORT_SYMBOL(inode_init_owner);
4198 diff -NurpP --minimal linux-3.0-rc5/fs/ioctl.c linux-3.0-rc5-vs2.3.1-pre3/fs/ioctl.c
4199 --- linux-3.0-rc5/fs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
4200 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ioctl.c 2011-06-10 22:11:24.000000000 +0200
4202 #include <linux/writeback.h>
4203 #include <linux/buffer_head.h>
4204 #include <linux/falloc.h>
4205 +#include <linux/proc_fs.h>
4206 +#include <linux/vserver/inode.h>
4207 +#include <linux/vs_tag.h>
4209 #include <asm/ioctls.h>
4211 diff -NurpP --minimal linux-3.0-rc5/fs/ioprio.c linux-3.0-rc5-vs2.3.1-pre3/fs/ioprio.c
4212 --- linux-3.0-rc5/fs/ioprio.c 2011-01-05 21:50:24.000000000 +0100
4213 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ioprio.c 2011-06-10 22:11:24.000000000 +0200
4215 #include <linux/syscalls.h>
4216 #include <linux/security.h>
4217 #include <linux/pid_namespace.h>
4218 +#include <linux/vs_base.h>
4220 int set_task_ioprio(struct task_struct *task, int ioprio)
4222 @@ -119,6 +120,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4224 pgrp = find_vpid(who);
4225 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4226 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4228 ret = set_task_ioprio(p, ioprio);
4231 @@ -208,6 +211,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
4233 pgrp = find_vpid(who);
4234 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4235 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4237 tmpio = get_task_ioprio(p);
4240 diff -NurpP --minimal linux-3.0-rc5/fs/jfs/file.c linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/file.c
4241 --- linux-3.0-rc5/fs/jfs/file.c 2011-07-01 11:14:18.000000000 +0200
4242 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/file.c 2011-07-01 11:35:34.000000000 +0200
4243 @@ -102,7 +102,8 @@ int jfs_setattr(struct dentry *dentry, s
4244 if (is_quota_modification(inode, iattr))
4245 dquot_initialize(inode);
4246 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4247 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4248 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4249 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4250 rc = dquot_transfer(inode, iattr);
4253 @@ -133,6 +134,7 @@ const struct inode_operations jfs_file_i
4254 #ifdef CONFIG_JFS_POSIX_ACL
4255 .check_acl = jfs_check_acl,
4257 + .sync_flags = jfs_sync_flags,
4260 const struct file_operations jfs_file_operations = {
4261 diff -NurpP --minimal linux-3.0-rc5/fs/jfs/ioctl.c linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/ioctl.c
4262 --- linux-3.0-rc5/fs/jfs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
4263 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/ioctl.c 2011-06-10 22:11:24.000000000 +0200
4265 #include <linux/mount.h>
4266 #include <linux/time.h>
4267 #include <linux/sched.h>
4268 +#include <linux/mount.h>
4269 #include <asm/current.h>
4270 #include <asm/uaccess.h>
4272 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
4276 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
4278 + inode->i_flags = flags;
4279 + inode->i_vflags = vflags;
4280 + jfs_get_inode_flags(JFS_IP(inode));
4281 + inode->i_ctime = CURRENT_TIME_SEC;
4282 + mark_inode_dirty(inode);
4286 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4288 struct inode *inode = filp->f_dentry->d_inode;
4289 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
4290 if (!S_ISDIR(inode->i_mode))
4291 flags &= ~JFS_DIRSYNC_FL;
4293 + if (IS_BARRIER(inode)) {
4294 + vxwprintk_task(1, "messing with the barrier.");
4298 /* Is it quota file? Do not allow user to mess with it */
4299 if (IS_NOQUOTA(inode)) {
4301 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
4302 * the relevant capability.
4304 if ((oldflags & JFS_IMMUTABLE_FL) ||
4305 - ((flags ^ oldflags) &
4306 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4307 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4308 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4309 if (!capable(CAP_LINUX_IMMUTABLE)) {
4310 mutex_unlock(&inode->i_mutex);
4312 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
4316 - flags = flags & JFS_FL_USER_MODIFIABLE;
4317 + flags &= JFS_FL_USER_MODIFIABLE;
4318 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
4319 jfs_inode->mode2 = flags;
4321 diff -NurpP --minimal linux-3.0-rc5/fs/jfs/jfs_dinode.h linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/jfs_dinode.h
4322 --- linux-3.0-rc5/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
4323 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/jfs_dinode.h 2011-06-10 22:11:24.000000000 +0200
4324 @@ -161,9 +161,13 @@ struct dinode {
4326 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4327 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4328 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4330 -#define JFS_FL_USER_VISIBLE 0x03F80000
4331 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4332 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4333 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4335 +#define JFS_FL_USER_VISIBLE 0x07F80000
4336 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4337 #define JFS_FL_INHERIT 0x03C80000
4339 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4340 diff -NurpP --minimal linux-3.0-rc5/fs/jfs/jfs_filsys.h linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/jfs_filsys.h
4341 --- linux-3.0-rc5/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4342 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/jfs_filsys.h 2011-06-10 22:11:24.000000000 +0200
4344 #define JFS_NAME_MAX 255
4345 #define JFS_PATH_MAX BPSIZE
4347 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4350 * file system state (superblock state)
4351 diff -NurpP --minimal linux-3.0-rc5/fs/jfs/jfs_imap.c linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/jfs_imap.c
4352 --- linux-3.0-rc5/fs/jfs/jfs_imap.c 2011-07-01 11:14:18.000000000 +0200
4353 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/jfs_imap.c 2011-07-01 11:35:34.000000000 +0200
4355 #include <linux/pagemap.h>
4356 #include <linux/quotaops.h>
4357 #include <linux/slab.h>
4358 +#include <linux/vs_tag.h>
4360 #include "jfs_incore.h"
4361 #include "jfs_inode.h"
4362 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
4364 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4365 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4369 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4370 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4371 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
4373 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4375 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4376 + uid = le32_to_cpu(dip->di_uid);
4377 + gid = le32_to_cpu(dip->di_gid);
4378 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4380 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4382 ip->i_uid = jfs_ip->saved_uid;
4384 ip->i_uid = sbi->uid;
4387 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4388 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4390 ip->i_gid = jfs_ip->saved_gid;
4392 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
4393 dip->di_size = cpu_to_le64(ip->i_size);
4394 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4395 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4396 - if (sbi->uid == -1)
4397 - dip->di_uid = cpu_to_le32(ip->i_uid);
4399 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4400 - if (sbi->gid == -1)
4401 - dip->di_gid = cpu_to_le32(ip->i_gid);
4403 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4405 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4406 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4407 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4408 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4410 jfs_get_inode_flags(jfs_ip);
4412 * mode2 is only needed for storing the higher order bits.
4413 diff -NurpP --minimal linux-3.0-rc5/fs/jfs/jfs_inode.c linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/jfs_inode.c
4414 --- linux-3.0-rc5/fs/jfs/jfs_inode.c 2010-08-02 16:52:49.000000000 +0200
4415 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/jfs_inode.c 2011-06-10 22:11:24.000000000 +0200
4418 #include <linux/fs.h>
4419 #include <linux/quotaops.h>
4420 +#include <linux/vs_tag.h>
4421 #include "jfs_incore.h"
4422 #include "jfs_inode.h"
4423 #include "jfs_filsys.h"
4424 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4426 unsigned int flags = JFS_IP(inode)->mode2;
4428 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4429 - S_NOATIME | S_DIRSYNC | S_SYNC);
4430 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4431 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4433 if (flags & JFS_IMMUTABLE_FL)
4434 inode->i_flags |= S_IMMUTABLE;
4435 + if (flags & JFS_IXUNLINK_FL)
4436 + inode->i_flags |= S_IXUNLINK;
4438 + if (flags & JFS_SYNC_FL)
4439 + inode->i_flags |= S_SYNC;
4440 if (flags & JFS_APPEND_FL)
4441 inode->i_flags |= S_APPEND;
4442 if (flags & JFS_NOATIME_FL)
4443 inode->i_flags |= S_NOATIME;
4444 if (flags & JFS_DIRSYNC_FL)
4445 inode->i_flags |= S_DIRSYNC;
4446 - if (flags & JFS_SYNC_FL)
4447 - inode->i_flags |= S_SYNC;
4449 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4451 + if (flags & JFS_BARRIER_FL)
4452 + inode->i_vflags |= V_BARRIER;
4453 + if (flags & JFS_COW_FL)
4454 + inode->i_vflags |= V_COW;
4457 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4459 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4460 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4462 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4463 + JFS_APPEND_FL | JFS_NOATIME_FL |
4464 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4465 + JFS_BARRIER_FL | JFS_COW_FL);
4467 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4468 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4469 if (flags & S_IMMUTABLE)
4470 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4471 + if (flags & S_IXUNLINK)
4472 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4474 if (flags & S_APPEND)
4475 jfs_ip->mode2 |= JFS_APPEND_FL;
4476 if (flags & S_NOATIME)
4477 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4478 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4480 jfs_ip->mode2 |= JFS_SYNC_FL;
4482 + if (vflags & V_BARRIER)
4483 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4484 + if (vflags & V_COW)
4485 + jfs_ip->mode2 |= JFS_COW_FL;
4489 diff -NurpP --minimal linux-3.0-rc5/fs/jfs/jfs_inode.h linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/jfs_inode.h
4490 --- linux-3.0-rc5/fs/jfs/jfs_inode.h 2011-07-01 11:14:18.000000000 +0200
4491 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/jfs_inode.h 2011-06-10 22:11:24.000000000 +0200
4492 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4493 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4494 int fh_len, int fh_type);
4495 extern void jfs_set_inode_flags(struct inode *);
4496 +extern int jfs_sync_flags(struct inode *, int, int);
4497 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4498 extern int jfs_setattr(struct dentry *, struct iattr *);
4500 diff -NurpP --minimal linux-3.0-rc5/fs/jfs/namei.c linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/namei.c
4501 --- linux-3.0-rc5/fs/jfs/namei.c 2011-05-22 16:17:53.000000000 +0200
4502 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/namei.c 2011-06-10 22:11:24.000000000 +0200
4504 #include <linux/ctype.h>
4505 #include <linux/quotaops.h>
4506 #include <linux/exportfs.h>
4507 +#include <linux/vs_tag.h>
4508 #include "jfs_incore.h"
4509 #include "jfs_superblock.h"
4510 #include "jfs_inode.h"
4511 @@ -1486,6 +1487,7 @@ static struct dentry *jfs_lookup(struct
4512 return ERR_CAST(ip);
4515 + dx_propagate_tag(nd, ip);
4516 return d_splice_alias(ip, dentry);
4519 @@ -1550,6 +1552,7 @@ const struct inode_operations jfs_dir_in
4520 #ifdef CONFIG_JFS_POSIX_ACL
4521 .check_acl = jfs_check_acl,
4523 + .sync_flags = jfs_sync_flags,
4526 const struct file_operations jfs_dir_operations = {
4527 diff -NurpP --minimal linux-3.0-rc5/fs/jfs/super.c linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/super.c
4528 --- linux-3.0-rc5/fs/jfs/super.c 2011-05-22 16:17:53.000000000 +0200
4529 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/jfs/super.c 2011-06-10 22:11:24.000000000 +0200
4530 @@ -198,7 +198,8 @@ static void jfs_put_super(struct super_b
4532 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4533 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4534 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4535 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4536 + Opt_tag, Opt_notag, Opt_tagid
4539 static const match_table_t tokens = {
4540 @@ -208,6 +209,10 @@ static const match_table_t tokens = {
4541 {Opt_resize, "resize=%u"},
4542 {Opt_resize_nosize, "resize"},
4543 {Opt_errors, "errors=%s"},
4545 + {Opt_notag, "notag"},
4546 + {Opt_tagid, "tagid=%u"},
4547 + {Opt_tag, "tagxid"},
4548 {Opt_ignore, "noquota"},
4549 {Opt_ignore, "quota"},
4550 {Opt_usrquota, "usrquota"},
4551 @@ -342,6 +347,20 @@ static int parse_options(char *options,
4555 +#ifndef CONFIG_TAGGING_NONE
4557 + *flag |= JFS_TAGGED;
4560 + *flag &= JFS_TAGGED;
4563 +#ifdef CONFIG_PROPAGATE
4566 + *flag |= JFS_TAGGED;
4570 printk("jfs: Unrecognized mount option \"%s\" "
4571 " or missing value\n", p);
4572 @@ -373,6 +392,12 @@ static int jfs_remount(struct super_bloc
4576 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4577 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4583 if (sb->s_flags & MS_RDONLY) {
4585 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
4586 #ifdef CONFIG_JFS_POSIX_ACL
4587 sb->s_flags |= MS_POSIXACL;
4589 + /* map mount option tagxid */
4590 + if (sbi->flag & JFS_TAGGED)
4591 + sb->s_flags |= MS_TAGGED;
4594 printk(KERN_ERR "resize option for remount only\n");
4595 diff -NurpP --minimal linux-3.0-rc5/fs/libfs.c linux-3.0-rc5-vs2.3.1-pre3/fs/libfs.c
4596 --- linux-3.0-rc5/fs/libfs.c 2011-03-15 18:07:32.000000000 +0100
4597 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/libfs.c 2011-06-10 22:11:24.000000000 +0200
4598 @@ -133,7 +133,8 @@ static inline unsigned char dt_type(stru
4599 * both impossible due to the lock on directory.
4602 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4603 +static inline int do_dcache_readdir_filter(struct file *filp,
4604 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4606 struct dentry *dentry = filp->f_path.dentry;
4607 struct dentry *cursor = filp->private_data;
4608 @@ -164,6 +165,8 @@ int dcache_readdir(struct file * filp, v
4609 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4610 struct dentry *next;
4611 next = list_entry(p, struct dentry, d_u.d_child);
4612 + if (filter && !filter(next))
4614 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4615 if (!simple_positive(next)) {
4616 spin_unlock(&next->d_lock);
4617 @@ -190,6 +193,17 @@ int dcache_readdir(struct file * filp, v
4621 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4623 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4626 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4627 + int (*filter)(struct dentry *))
4629 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4632 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4635 @@ -965,6 +979,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4636 EXPORT_SYMBOL(dcache_dir_lseek);
4637 EXPORT_SYMBOL(dcache_dir_open);
4638 EXPORT_SYMBOL(dcache_readdir);
4639 +EXPORT_SYMBOL(dcache_readdir_filter);
4640 EXPORT_SYMBOL(generic_read_dir);
4641 EXPORT_SYMBOL(mount_pseudo);
4642 EXPORT_SYMBOL(simple_write_begin);
4643 diff -NurpP --minimal linux-3.0-rc5/fs/locks.c linux-3.0-rc5-vs2.3.1-pre3/fs/locks.c
4644 --- linux-3.0-rc5/fs/locks.c 2011-05-22 16:17:53.000000000 +0200
4645 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/locks.c 2011-06-10 22:11:24.000000000 +0200
4647 #include <linux/time.h>
4648 #include <linux/rcupdate.h>
4649 #include <linux/pid_namespace.h>
4650 +#include <linux/vs_base.h>
4651 +#include <linux/vs_limit.h>
4653 #include <asm/uaccess.h>
4655 @@ -163,6 +168,7 @@ static void locks_init_lock_always(struc
4658 fl->fl_start = fl->fl_end = 0;
4662 /* Allocate an empty lock structure. */
4663 @@ -173,7 +175,12 @@ static struct kmem_cache *filelock_cache
4664 /* Allocate an empty lock structure. */
4665 struct file_lock *locks_alloc_lock(void)
4667 - struct file_lock *fl = kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4668 + struct file_lock *fl;
4670 + if (!vx_locks_avail(1))
4673 + fl = kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4676 locks_init_lock_always(fl);
4677 @@ -190,6 +194,7 @@ void locks_free_lock(struct file_lock *f
4678 BUG_ON(!list_empty(&fl->fl_block));
4679 BUG_ON(!list_empty(&fl->fl_link));
4682 locks_release_private(fl);
4683 kmem_cache_free(filelock_cache, fl);
4685 @@ -262,6 +268,7 @@ void locks_copy_lock(struct file_lock *n
4686 new->fl_file = fl->fl_file;
4687 new->fl_ops = fl->fl_ops;
4688 new->fl_lmops = fl->fl_lmops;
4689 + new->fl_xid = fl->fl_xid;
4691 locks_copy_private(new, fl);
4693 @@ -300,6 +307,11 @@ static int flock_make_lock(struct file *
4694 fl->fl_flags = FL_FLOCK;
4696 fl->fl_end = OFFSET_MAX;
4698 + vxd_assert(filp->f_xid == vx_current_xid(),
4699 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4700 + fl->fl_xid = filp->f_xid;
4705 @@ -449,6 +461,7 @@ static int lease_init(struct file *filp,
4707 fl->fl_owner = current->files;
4708 fl->fl_pid = current->tgid;
4709 + fl->fl_xid = vx_current_xid();
4712 fl->fl_flags = FL_LEASE;
4713 @@ -468,6 +481,11 @@ static struct file_lock *lease_alloc(str
4715 return ERR_PTR(error);
4717 + fl->fl_xid = vx_current_xid();
4719 + vxd_assert(filp->f_xid == fl->fl_xid,
4720 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4722 error = lease_init(filp, type, fl);
4724 locks_free_lock(fl);
4725 @@ -769,6 +787,7 @@ static int flock_lock_file(struct file *
4729 + new_fl->fl_xid = -1;
4731 for_each_lock(inode, before) {
4732 struct file_lock *fl = *before;
4733 @@ -789,6 +808,7 @@ find_conflict:
4735 locks_copy_lock(new_fl, request);
4736 locks_insert_lock(before, new_fl);
4737 + vx_locks_inc(new_fl);
4741 @@ -799,7 +819,8 @@ out:
4745 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4746 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4747 + struct file_lock *conflock, xid_t xid)
4749 struct file_lock *fl;
4750 struct file_lock *new_fl = NULL;
4751 @@ -809,6 +830,8 @@ static int __posix_lock_file(struct inod
4752 struct file_lock **before;
4753 int error, added = 0;
4755 + vxd_assert(xid == vx_current_xid(),
4756 + "xid(%d) == current(%d)", xid, vx_current_xid());
4758 * We may need two file_lock structures for this operation,
4759 * so we get them in advance to avoid races.
4760 @@ -819,7 +842,11 @@ static int __posix_lock_file(struct inod
4761 (request->fl_type != F_UNLCK ||
4762 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4763 new_fl = locks_alloc_lock();
4764 + new_fl->fl_xid = xid;
4765 + vx_locks_inc(new_fl);
4766 new_fl2 = locks_alloc_lock();
4767 + new_fl2->fl_xid = xid;
4768 + vx_locks_inc(new_fl2);
4772 @@ -1018,7 +1045,8 @@ static int __posix_lock_file(struct inod
4773 int posix_lock_file(struct file *filp, struct file_lock *fl,
4774 struct file_lock *conflock)
4776 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4777 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4778 + fl, conflock, filp->f_xid);
4780 EXPORT_SYMBOL(posix_lock_file);
4782 @@ -1108,7 +1136,7 @@ int locks_mandatory_area(int read_write,
4783 fl.fl_end = offset + count - 1;
4786 - error = __posix_lock_file(inode, &fl, NULL);
4787 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4788 if (error != FILE_LOCK_DEFERRED)
4790 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4791 @@ -1421,6 +1449,7 @@ int generic_setlease(struct file *filp,
4794 locks_insert_lock(before, lease);
4795 + vx_locks_inc(lease);
4799 @@ -1805,6 +1834,11 @@ int fcntl_setlk(unsigned int fd, struct
4800 if (file_lock == NULL)
4803 + vxd_assert(filp->f_xid == vx_current_xid(),
4804 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4805 + file_lock->fl_xid = filp->f_xid;
4806 + vx_locks_inc(file_lock);
4809 * This might block, so we do it before checking the inode.
4811 @@ -1923,6 +1957,11 @@ int fcntl_setlk64(unsigned int fd, struc
4812 if (file_lock == NULL)
4815 + vxd_assert(filp->f_xid == vx_current_xid(),
4816 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4817 + file_lock->fl_xid = filp->f_xid;
4818 + vx_locks_inc(file_lock);
4821 * This might block, so we do it before checking the inode.
4823 @@ -2188,8 +2227,11 @@ static int locks_show(struct seq_file *f
4825 lock_get_status(f, fl, *((loff_t *)f->private), "");
4827 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4828 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4829 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4831 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4836 diff -NurpP --minimal linux-3.0-rc5/fs/namei.c linux-3.0-rc5-vs2.3.1-pre3/fs/namei.c
4837 --- linux-3.0-rc5/fs/namei.c 2011-07-01 11:14:19.000000000 +0200
4838 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/namei.c 2011-06-22 12:39:15.000000000 +0200
4840 #include <linux/fcntl.h>
4841 #include <linux/device_cgroup.h>
4842 #include <linux/fs_struct.h>
4843 +#include <linux/proc_fs.h>
4844 +#include <linux/vserver/inode.h>
4845 +#include <linux/vs_base.h>
4846 +#include <linux/vs_tag.h>
4847 +#include <linux/vs_cowbl.h>
4848 +#include <linux/vs_device.h>
4849 +#include <linux/vs_context.h>
4850 +#include <linux/pid_namespace.h>
4851 #include <asm/uaccess.h>
4853 #include "internal.h"
4854 @@ -173,6 +181,84 @@ void putname(const char *name)
4855 EXPORT_SYMBOL(putname);
4858 +static inline int dx_barrier(const struct inode *inode)
4860 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4861 + vxwprintk_task(1, "did hit the barrier.");
4867 +static int __dx_permission(const struct inode *inode, int mask)
4869 + if (dx_barrier(inode))
4872 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4873 + /* devpts is xid tagged */
4874 + if (S_ISDIR(inode->i_mode) ||
4875 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4878 + /* just pretend we didn't find anything */
4881 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4882 + struct proc_dir_entry *de = PDE(inode);
4884 + if (de && !vx_hide_check(0, de->vx_flags))
4887 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4889 + struct task_struct *tsk;
4891 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4892 + vx_flags(VXF_STATE_SETUP, 0))
4895 + pid = PROC_I(inode)->pid;
4899 + tsk = pid_task(pid, PIDTYPE_PID);
4900 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4901 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4902 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
4906 + /* FIXME: Should we block some entries here? */
4911 + if (dx_notagcheck(inode->i_sb) ||
4912 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4921 +int dx_permission(const struct inode *inode, int mask)
4923 + int ret = __dx_permission(inode, mask);
4924 + if (unlikely(ret)) {
4925 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4926 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4929 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4930 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4937 * This does basic POSIX ACL permission checking
4939 @@ -283,10 +369,14 @@ int inode_permission(struct inode *inode
4941 * Nobody gets write access to an immutable file.
4943 - if (IS_IMMUTABLE(inode))
4944 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4948 + retval = dx_permission(inode, mask);
4952 if (inode->i_op->permission)
4953 retval = inode->i_op->permission(inode, mask, 0);
4955 @@ -580,6 +670,9 @@ static inline int exec_permission(struct
4957 struct user_namespace *ns = inode_userns(inode);
4959 + if (dx_barrier(inode))
4962 if (inode->i_op->permission) {
4963 ret = inode->i_op->permission(inode, MAY_EXEC, flags);
4965 @@ -1082,7 +1175,8 @@ static void follow_dotdot(struct nameida
4967 if (nd->path.dentry == nd->root.dentry &&
4968 nd->path.mnt == nd->root.mnt) {
4970 + /* for sane '/' avoid follow_mount() */
4973 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4974 /* rare case of legitimate dget_parent()... */
4975 @@ -1832,7 +1926,7 @@ static int may_delete(struct inode *dir,
4978 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4979 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4980 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4983 if (!S_ISDIR(victim->d_inode->i_mode))
4984 @@ -1959,6 +2053,15 @@ static int may_open(struct path *path, i
4988 +#ifdef CONFIG_VSERVER_COWBL
4989 + if (IS_COW(inode) &&
4990 + ((flag & O_ACCMODE) != O_RDONLY)) {
4991 + if (IS_COW_LINK(inode))
4993 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4994 + mark_inode_dirty(inode);
4997 error = inode_permission(inode, acc_mode);
5000 @@ -2852,7 +2955,7 @@ int vfs_link(struct dentry *old_dentry,
5002 * A link to an append-only or immutable file cannot be created.
5004 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5005 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5007 if (!dir->i_op->link)
5009 @@ -3238,6 +3341,222 @@ int vfs_follow_link(struct nameidata *nd
5010 return __vfs_follow_link(nd, link);
5014 +#ifdef CONFIG_VSERVER_COWBL
5016 +#include <linux/file.h>
5019 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5023 + return do_splice_direct(in, &ppos, out, len, 0);
5026 +struct dentry *cow_break_link(const char *pathname)
5028 + int ret, mode, pathlen, redo = 0;
5029 + struct nameidata old_nd, dir_nd;
5030 + struct path old_path, new_path;
5031 + struct dentry *dir, *res = NULL;
5032 + struct file *old_file;
5033 + struct file *new_file;
5034 + char *to, *path, pad='\251';
5037 + vxdprintk(VXD_CBIT(misc, 1),
5038 + "cow_break_link(" VS_Q("%s") ")", pathname);
5039 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5044 + /* old_nd will have refs to dentry and mnt */
5045 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
5046 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(old): %d", ret);
5048 + goto out_free_path;
5050 + old_path = old_nd.path;
5051 + mode = old_path.dentry->d_inode->i_mode;
5053 + to = d_path(&old_path, path, PATH_MAX-2);
5054 + pathlen = strlen(to);
5055 + vxdprintk(VXD_CBIT(misc, 2),
5056 + "old path " VS_Q("%s") " [" VS_Q("%.*s") ":%d]", to,
5057 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5058 + old_path.dentry->d_name.len);
5060 + to[pathlen + 1] = 0;
5062 + to[pathlen] = pad--;
5064 + if (pad <= '\240')
5067 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
5068 + /* dir_nd will have refs to dentry and mnt */
5069 + ret = do_path_lookup(AT_FDCWD, to,
5070 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5071 + vxdprintk(VXD_CBIT(misc, 2),
5072 + "do_path_lookup(new): %d", ret);
5076 + /* this puppy downs the inode mutex */
5077 + new_path.dentry = lookup_create(&dir_nd, 0);
5078 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5079 + vxdprintk(VXD_CBIT(misc, 2),
5080 + "lookup_create(new): %p", new_path.dentry);
5081 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5082 + path_put(&dir_nd.path);
5085 + vxdprintk(VXD_CBIT(misc, 2),
5086 + "lookup_create(new): %p [" VS_Q("%.*s") ":%d]",
5088 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5089 + new_path.dentry->d_name.len);
5090 + dir = dir_nd.path.dentry;
5092 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5093 + vxdprintk(VXD_CBIT(misc, 2),
5094 + "vfs_create(new): %d", ret);
5095 + if (ret == -EEXIST) {
5096 + mutex_unlock(&dir->d_inode->i_mutex);
5097 + dput(new_path.dentry);
5098 + path_put(&dir_nd.path);
5102 + goto out_unlock_new;
5104 + /* drop out early, ret passes ENOENT */
5106 + if ((redo = d_unhashed(old_path.dentry)))
5107 + goto out_unlock_new;
5109 + new_path.mnt = dir_nd.path.mnt;
5110 + dget(old_path.dentry);
5111 + mntget(old_path.mnt);
5112 + /* this one cleans up the dentry/mnt in case of failure */
5113 + old_file = dentry_open(old_path.dentry, old_path.mnt,
5114 + O_RDONLY, current_cred());
5115 + vxdprintk(VXD_CBIT(misc, 2),
5116 + "dentry_open(old): %p", old_file);
5117 + if (!old_file || IS_ERR(old_file)) {
5118 + res = IS_ERR(old_file) ? (void *) old_file : res;
5119 + goto out_unlock_new;
5122 + dget(new_path.dentry);
5123 + mntget(new_path.mnt);
5124 + /* this one cleans up the dentry/mnt in case of failure */
5125 + new_file = dentry_open(new_path.dentry, new_path.mnt,
5126 + O_WRONLY, current_cred());
5127 + vxdprintk(VXD_CBIT(misc, 2),
5128 + "dentry_open(new): %p", new_file);
5130 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5131 + if (!new_file || IS_ERR(new_file))
5132 + goto out_fput_old;
5134 + size = i_size_read(old_file->f_dentry->d_inode);
5135 + ret = do_cow_splice(old_file, new_file, size);
5136 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5138 + goto out_fput_both;
5139 + } else if (ret < size) {
5141 + goto out_fput_both;
5143 + struct inode *old_inode = old_path.dentry->d_inode;
5144 + struct inode *new_inode = new_path.dentry->d_inode;
5145 + struct iattr attr = {
5146 + .ia_uid = old_inode->i_uid,
5147 + .ia_gid = old_inode->i_gid,
5148 + .ia_valid = ATTR_UID | ATTR_GID
5151 + setattr_copy(new_inode, &attr);
5152 + mark_inode_dirty(new_inode);
5155 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5157 + /* drop out late */
5159 + if ((redo = d_unhashed(old_path.dentry)))
5162 + vxdprintk(VXD_CBIT(misc, 2),
5163 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
5164 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5165 + new_path.dentry->d_name.len,
5166 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5167 + old_path.dentry->d_name.len);
5168 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5169 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5170 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5171 + res = new_path.dentry;
5174 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5177 + vxdprintk(VXD_CBIT(misc, 3),
5178 + "fput(new_file=%p[#%ld])", new_file,
5179 + atomic_long_read(&new_file->f_count));
5183 + vxdprintk(VXD_CBIT(misc, 3),
5184 + "fput(old_file=%p[#%ld])", old_file,
5185 + atomic_long_read(&old_file->f_count));
5189 + mutex_unlock(&dir->d_inode->i_mutex);
5193 + /* error path cleanup */
5194 + vfs_unlink(dir->d_inode, new_path.dentry);
5195 + dput(new_path.dentry);
5199 + goto out_rel_both;
5200 + /* lookup dentry once again */
5201 + path_put(&old_nd.path);
5202 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
5204 + goto out_rel_both;
5206 + new_path.dentry = old_nd.path.dentry;
5207 + vxdprintk(VXD_CBIT(misc, 2),
5208 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
5210 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5211 + new_path.dentry->d_name.len);
5212 + dget(new_path.dentry);
5213 + res = new_path.dentry;
5216 + path_put(&dir_nd.path);
5218 + path_put(&old_nd.path);
5223 + res = ERR_PTR(ret);
5229 /* get the link contents into pagecache */
5230 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5232 diff -NurpP --minimal linux-3.0-rc5/fs/namespace.c linux-3.0-rc5-vs2.3.1-pre3/fs/namespace.c
5233 --- linux-3.0-rc5/fs/namespace.c 2011-07-01 11:14:19.000000000 +0200
5234 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/namespace.c 2011-06-13 18:26:48.000000000 +0200
5236 #include <linux/idr.h>
5237 #include <linux/fs_struct.h>
5238 #include <linux/fsnotify.h>
5239 +#include <linux/vs_base.h>
5240 +#include <linux/vs_context.h>
5241 +#include <linux/vs_tag.h>
5242 +#include <linux/vserver/space.h>
5243 +#include <linux/vserver/global.h>
5244 #include <asm/uaccess.h>
5245 #include <asm/unistd.h>
5247 @@ -724,6 +729,7 @@ static struct vfsmount *clone_mnt(struct
5248 mnt->mnt_root = dget(root);
5249 mnt->mnt_mountpoint = mnt->mnt_root;
5250 mnt->mnt_parent = mnt;
5251 + mnt->mnt_tag = old->mnt_tag;
5253 if (flag & CL_SLAVE) {
5254 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5255 @@ -852,6 +858,31 @@ static inline void mangle(struct seq_fil
5256 seq_escape(m, s, " \t\n\\");
5259 +static int mnt_is_reachable(struct vfsmount *mnt)
5262 + struct dentry *point;
5265 + if (mnt == mnt->mnt_ns->root)
5268 + br_read_lock(vfsmount_lock);
5269 + root = current->fs->root;
5270 + point = root.dentry;
5272 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5273 + point = mnt->mnt_mountpoint;
5274 + mnt = mnt->mnt_parent;
5277 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5279 + br_read_unlock(vfsmount_lock);
5285 * Simple .show_options callback for filesystems which don't want to
5286 * implement more complex mount option showing.
5287 @@ -954,6 +985,8 @@ static int show_sb_opts(struct seq_file
5288 { MS_SYNCHRONOUS, ",sync" },
5289 { MS_DIRSYNC, ",dirsync" },
5290 { MS_MANDLOCK, ",mand" },
5291 + { MS_TAGGED, ",tag" },
5292 + { MS_NOTAGCHECK, ",notagcheck" },
5295 const struct proc_fs_info *fs_infop;
5296 @@ -1000,16 +1033,26 @@ static int show_vfsmnt(struct seq_file *
5298 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5300 - if (mnt->mnt_sb->s_op->show_devname) {
5301 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5304 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5306 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5309 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5310 + mnt == current->fs->root.mnt) {
5311 + seq_puts(m, "/dev/root / ");
5313 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5314 + if (mnt->mnt_sb->s_op->show_devname) {
5315 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5319 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5322 + seq_path(m, &mnt_path, " \t\n\\");
5326 - seq_path(m, &mnt_path, " \t\n\\");
5328 show_type(m, mnt->mnt_sb);
5329 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5330 err = show_sb_opts(m, mnt->mnt_sb);
5331 @@ -1039,6 +1082,11 @@ static int show_mountinfo(struct seq_fil
5332 struct path root = p->root;
5335 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5337 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5340 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5341 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5342 if (sb->s_op->show_path)
5343 @@ -1107,21 +1155,31 @@ static int show_vfsstat(struct seq_file
5344 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5348 - if (mnt->mnt_sb->s_op->show_devname) {
5349 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5350 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5352 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5355 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5356 + mnt == current->fs->root.mnt) {
5357 + seq_puts(m, "device /dev/root mounted on / ");
5359 - if (mnt->mnt_devname) {
5360 - seq_puts(m, "device ");
5361 - mangle(m, mnt->mnt_devname);
5363 - seq_puts(m, "no device");
5366 + if (mnt->mnt_sb->s_op->show_devname) {
5367 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5369 + if (mnt->mnt_devname) {
5370 + seq_puts(m, "device ");
5371 + mangle(m, mnt->mnt_devname);
5373 + seq_puts(m, "no device");
5377 - seq_puts(m, " mounted on ");
5378 - seq_path(m, &mnt_path, " \t\n\\");
5381 + seq_puts(m, " mounted on ");
5382 + seq_path(m, &mnt_path, " \t\n\\");
5386 /* file system type */
5387 seq_puts(m, "with fstype ");
5388 @@ -1380,7 +1438,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5392 - if (!capable(CAP_SYS_ADMIN))
5393 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5396 retval = do_umount(path.mnt, flags);
5397 @@ -1406,7 +1464,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5399 static int mount_is_safe(struct path *path)
5401 - if (capable(CAP_SYS_ADMIN))
5402 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5406 @@ -1716,7 +1774,7 @@ static int do_change_type(struct path *p
5410 - if (!capable(CAP_SYS_ADMIN))
5411 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5414 if (path->dentry != path->mnt->mnt_root)
5415 @@ -1732,6 +1790,7 @@ static int do_change_type(struct path *p
5419 + // mnt->mnt_flags = mnt_flags;
5421 br_write_lock(vfsmount_lock);
5422 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
5423 @@ -1747,12 +1806,14 @@ static int do_change_type(struct path *p
5424 * do loopback mount.
5426 static int do_loopback(struct path *path, char *old_name,
5428 + tag_t tag, unsigned long flags, int mnt_flags)
5430 LIST_HEAD(umount_list);
5431 struct path old_path;
5432 struct vfsmount *mnt = NULL;
5433 int err = mount_is_safe(path);
5434 + int recurse = flags & MS_REC;
5438 if (!old_name || !*old_name)
5439 @@ -1818,12 +1879,12 @@ static int change_mount_flags(struct vfs
5440 * on it - tough luck.
5442 static int do_remount(struct path *path, int flags, int mnt_flags,
5444 + void *data, xid_t xid)
5447 struct super_block *sb = path->mnt->mnt_sb;
5449 - if (!capable(CAP_SYS_ADMIN))
5450 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5453 if (!check_mnt(path->mnt))
5454 @@ -1871,7 +1932,7 @@ static int do_move_mount(struct path *pa
5455 struct path old_path, parent_path;
5458 - if (!capable(CAP_SYS_ADMIN))
5459 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5461 if (!old_name || !*old_name)
5463 @@ -2022,7 +2083,7 @@ static int do_new_mount(struct path *pat
5466 /* we need capabilities... */
5467 - if (!capable(CAP_SYS_ADMIN))
5468 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5471 mnt = do_kern_mount(type, flags, name, data);
5472 @@ -2291,6 +2352,7 @@ long do_mount(char *dev_name, char *dir_
5479 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5480 @@ -2318,6 +2380,12 @@ long do_mount(char *dev_name, char *dir_
5481 if (!(flags & MS_NOATIME))
5482 mnt_flags |= MNT_RELATIME;
5484 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5485 + /* FIXME: bind and re-mounts get the tag flag? */
5486 + if (flags & (MS_BIND|MS_REMOUNT))
5487 + flags |= MS_TAGID;
5490 /* Separate the per-mountpoint flags */
5491 if (flags & MS_NOSUID)
5492 mnt_flags |= MNT_NOSUID;
5493 @@ -2334,15 +2402,17 @@ long do_mount(char *dev_name, char *dir_
5494 if (flags & MS_RDONLY)
5495 mnt_flags |= MNT_READONLY;
5497 + if (!capable(CAP_SYS_ADMIN))
5498 + mnt_flags |= MNT_NODEV;
5499 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5500 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5503 if (flags & MS_REMOUNT)
5504 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5507 else if (flags & MS_BIND)
5508 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5509 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5510 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5511 retval = do_change_type(&path, flags);
5512 else if (flags & MS_MOVE)
5513 @@ -2442,6 +2512,7 @@ static struct mnt_namespace *dup_mnt_ns(
5514 q = next_mnt(q, new_ns->root);
5516 up_write(&namespace_sem);
5517 + atomic_inc(&vs_global_mnt_ns);
5521 @@ -2581,9 +2652,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5525 - if (IS_MNT_SHARED(old.mnt) ||
5526 - IS_MNT_SHARED(new.mnt->mnt_parent) ||
5527 - IS_MNT_SHARED(root.mnt->mnt_parent))
5528 + if ((IS_MNT_SHARED(old.mnt) ||
5529 + IS_MNT_SHARED(new.mnt->mnt_parent) ||
5530 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5531 + !vx_flags(VXF_STATE_SETUP, 0))
5533 if (!check_mnt(root.mnt) || !check_mnt(new.mnt))
5535 @@ -2715,6 +2787,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5536 br_write_unlock(vfsmount_lock);
5537 up_write(&namespace_sem);
5538 release_mounts(&umount_list);
5539 + atomic_dec(&vs_global_mnt_ns);
5542 EXPORT_SYMBOL(put_mnt_ns);
5543 diff -NurpP --minimal linux-3.0-rc5/fs/nfs/client.c linux-3.0-rc5-vs2.3.1-pre3/fs/nfs/client.c
5544 --- linux-3.0-rc5/fs/nfs/client.c 2011-07-01 11:14:19.000000000 +0200
5545 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/nfs/client.c 2011-06-10 22:11:24.000000000 +0200
5546 @@ -780,6 +780,9 @@ static int nfs_init_server_rpcclient(str
5547 if (server->flags & NFS_MOUNT_SOFT)
5548 server->client->cl_softrtry = 1;
5550 + server->client->cl_tag = 0;
5551 + if (server->flags & NFS_MOUNT_TAGGED)
5552 + server->client->cl_tag = 1;
5556 @@ -951,6 +954,10 @@ static void nfs_server_set_fsinfo(struct
5557 server->acdirmin = server->acdirmax = 0;
5560 + /* FIXME: needs fsinfo
5561 + if (server->flags & NFS_MOUNT_TAGGED)
5562 + sb->s_flags |= MS_TAGGED; */
5564 server->maxfilesize = fsinfo->maxfilesize;
5566 server->time_delta = fsinfo->time_delta;
5567 diff -NurpP --minimal linux-3.0-rc5/fs/nfs/dir.c linux-3.0-rc5-vs2.3.1-pre3/fs/nfs/dir.c
5568 --- linux-3.0-rc5/fs/nfs/dir.c 2011-07-01 11:14:19.000000000 +0200
5569 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/nfs/dir.c 2011-06-10 22:11:24.000000000 +0200
5571 #include <linux/sched.h>
5572 #include <linux/kmemleak.h>
5573 #include <linux/xattr.h>
5574 +#include <linux/vs_tag.h>
5576 #include "delegation.h"
5578 @@ -1298,6 +1299,7 @@ static struct dentry *nfs_lookup(struct
5580 goto out_unblock_sillyrename;
5582 + dx_propagate_tag(nd, inode);
5584 res = d_materialise_unique(dentry, inode);
5586 diff -NurpP --minimal linux-3.0-rc5/fs/nfs/inode.c linux-3.0-rc5-vs2.3.1-pre3/fs/nfs/inode.c
5587 --- linux-3.0-rc5/fs/nfs/inode.c 2011-07-01 11:14:19.000000000 +0200
5588 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/nfs/inode.c 2011-07-01 11:35:34.000000000 +0200
5590 #include <linux/nfs_xdr.h>
5591 #include <linux/slab.h>
5592 #include <linux/compat.h>
5593 +#include <linux/vs_tag.h>
5595 #include <asm/system.h>
5596 #include <asm/uaccess.h>
5597 @@ -273,6 +274,8 @@ nfs_fhget(struct super_block *sb, struct
5598 if (inode->i_state & I_NEW) {
5599 struct nfs_inode *nfsi = NFS_I(inode);
5600 unsigned long now = jiffies;
5604 /* We set i_ino for the few things that still rely on it,
5605 * such as stat(2) */
5606 @@ -321,8 +324,8 @@ nfs_fhget(struct super_block *sb, struct
5607 nfsi->change_attr = 0;
5610 - inode->i_uid = -2;
5611 - inode->i_gid = -2;
5614 inode->i_blocks = 0;
5615 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5617 @@ -359,13 +362,13 @@ nfs_fhget(struct super_block *sb, struct
5618 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5619 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5620 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5621 - inode->i_uid = fattr->uid;
5623 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5624 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5625 | NFS_INO_INVALID_ACCESS
5626 | NFS_INO_INVALID_ACL;
5627 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5628 - inode->i_gid = fattr->gid;
5630 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5631 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5632 | NFS_INO_INVALID_ACCESS
5633 @@ -378,6 +381,11 @@ nfs_fhget(struct super_block *sb, struct
5635 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5637 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5638 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5639 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5640 + /* maybe fattr->xid someday */
5642 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5643 nfsi->attrtimeo_timestamp = now;
5644 nfsi->access_cache = RB_ROOT;
5645 @@ -494,6 +502,8 @@ void nfs_setattr_update_inode(struct ino
5646 inode->i_uid = attr->ia_uid;
5647 if ((attr->ia_valid & ATTR_GID) != 0)
5648 inode->i_gid = attr->ia_gid;
5649 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5650 + inode->i_tag = attr->ia_tag;
5651 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5652 spin_unlock(&inode->i_lock);
5654 @@ -941,6 +951,9 @@ static int nfs_check_inode_attributes(st
5655 struct nfs_inode *nfsi = NFS_I(inode);
5656 loff_t cur_size, new_isize;
5657 unsigned long invalid = 0;
5663 /* Has the inode gone and changed behind our back? */
5664 @@ -964,13 +977,18 @@ static int nfs_check_inode_attributes(st
5665 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5668 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5669 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5670 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5672 /* Have any file permissions changed? */
5673 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5674 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5675 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5676 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5677 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5678 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5679 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5680 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5681 + /* maybe check for tag too? */
5683 /* Has the link count changed? */
5684 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5685 @@ -1205,6 +1223,9 @@ static int nfs_update_inode(struct inode
5686 unsigned long invalid = 0;
5687 unsigned long now = jiffies;
5688 unsigned long save_cache_validity;
5693 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5694 __func__, inode->i_sb->s_id, inode->i_ino,
5695 @@ -1312,6 +1333,9 @@ static int nfs_update_inode(struct inode
5696 | NFS_INO_REVAL_PAGECACHE
5697 | NFS_INO_REVAL_FORCED);
5699 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5700 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5701 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5703 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5704 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5705 @@ -1333,9 +1357,9 @@ static int nfs_update_inode(struct inode
5706 | NFS_INO_REVAL_FORCED);
5708 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5709 - if (inode->i_uid != fattr->uid) {
5710 + if (uid != fattr->uid) {
5711 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5712 - inode->i_uid = fattr->uid;
5715 } else if (server->caps & NFS_CAP_OWNER)
5716 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5717 @@ -1344,9 +1368,9 @@ static int nfs_update_inode(struct inode
5718 | NFS_INO_REVAL_FORCED);
5720 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5721 - if (inode->i_gid != fattr->gid) {
5722 + if (gid != fattr->gid) {
5723 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5724 - inode->i_gid = fattr->gid;
5727 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5728 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5729 @@ -1354,6 +1378,10 @@ static int nfs_update_inode(struct inode
5730 | NFS_INO_INVALID_ACL
5731 | NFS_INO_REVAL_FORCED);
5733 + inode->i_uid = uid;
5734 + inode->i_gid = gid;
5735 + inode->i_tag = tag;
5737 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5738 if (inode->i_nlink != fattr->nlink) {
5739 invalid |= NFS_INO_INVALID_ATTR;
5740 diff -NurpP --minimal linux-3.0-rc5/fs/nfs/nfs3xdr.c linux-3.0-rc5-vs2.3.1-pre3/fs/nfs/nfs3xdr.c
5741 --- linux-3.0-rc5/fs/nfs/nfs3xdr.c 2011-03-15 18:07:32.000000000 +0100
5742 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/nfs/nfs3xdr.c 2011-06-10 22:11:24.000000000 +0200
5744 #include <linux/nfs3.h>
5745 #include <linux/nfs_fs.h>
5746 #include <linux/nfsacl.h>
5747 +#include <linux/vs_tag.h>
5748 #include "internal.h"
5750 #define NFSDBG_FACILITY NFSDBG_XDR
5751 @@ -562,7 +563,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5755 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5756 +static void encode_sattr3(struct xdr_stream *xdr,
5757 + const struct iattr *attr, int tag)
5761 @@ -594,15 +596,19 @@ static void encode_sattr3(struct xdr_str
5765 - if (attr->ia_valid & ATTR_UID) {
5766 + if (attr->ia_valid & ATTR_UID ||
5767 + (tag && (attr->ia_valid & ATTR_TAG))) {
5769 - *p++ = cpu_to_be32(attr->ia_uid);
5770 + *p++ = cpu_to_be32(TAGINO_UID(tag,
5771 + attr->ia_uid, attr->ia_tag));
5775 - if (attr->ia_valid & ATTR_GID) {
5776 + if (attr->ia_valid & ATTR_GID ||
5777 + (tag && (attr->ia_valid & ATTR_TAG))) {
5779 - *p++ = cpu_to_be32(attr->ia_gid);
5780 + *p++ = cpu_to_be32(TAGINO_GID(tag,
5781 + attr->ia_gid, attr->ia_tag));
5785 @@ -878,7 +884,7 @@ static void nfs3_xdr_enc_setattr3args(st
5786 const struct nfs3_sattrargs *args)
5788 encode_nfs_fh3(xdr, args->fh);
5789 - encode_sattr3(xdr, args->sattr);
5790 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5791 encode_sattrguard3(xdr, args);
5794 @@ -1028,13 +1034,13 @@ static void nfs3_xdr_enc_write3args(stru
5797 static void encode_createhow3(struct xdr_stream *xdr,
5798 - const struct nfs3_createargs *args)
5799 + const struct nfs3_createargs *args, int tag)
5801 encode_uint32(xdr, args->createmode);
5802 switch (args->createmode) {
5803 case NFS3_CREATE_UNCHECKED:
5804 case NFS3_CREATE_GUARDED:
5805 - encode_sattr3(xdr, args->sattr);
5806 + encode_sattr3(xdr, args->sattr, tag);
5808 case NFS3_CREATE_EXCLUSIVE:
5809 encode_createverf3(xdr, args->verifier);
5810 @@ -1049,7 +1055,7 @@ static void nfs3_xdr_enc_create3args(str
5811 const struct nfs3_createargs *args)
5813 encode_diropargs3(xdr, args->fh, args->name, args->len);
5814 - encode_createhow3(xdr, args);
5815 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5819 @@ -1065,7 +1071,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5820 const struct nfs3_mkdirargs *args)
5822 encode_diropargs3(xdr, args->fh, args->name, args->len);
5823 - encode_sattr3(xdr, args->sattr);
5824 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5828 @@ -1082,9 +1088,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5831 static void encode_symlinkdata3(struct xdr_stream *xdr,
5832 - const struct nfs3_symlinkargs *args)
5833 + const struct nfs3_symlinkargs *args, int tag)
5835 - encode_sattr3(xdr, args->sattr);
5836 + encode_sattr3(xdr, args->sattr, tag);
5837 encode_nfspath3(xdr, args->pages, args->pathlen);
5840 @@ -1093,7 +1099,7 @@ static void nfs3_xdr_enc_symlink3args(st
5841 const struct nfs3_symlinkargs *args)
5843 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5844 - encode_symlinkdata3(xdr, args);
5845 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5849 @@ -1121,24 +1127,24 @@ static void nfs3_xdr_enc_symlink3args(st
5852 static void encode_devicedata3(struct xdr_stream *xdr,
5853 - const struct nfs3_mknodargs *args)
5854 + const struct nfs3_mknodargs *args, int tag)
5856 - encode_sattr3(xdr, args->sattr);
5857 + encode_sattr3(xdr, args->sattr, tag);
5858 encode_specdata3(xdr, args->rdev);
5861 static void encode_mknoddata3(struct xdr_stream *xdr,
5862 - const struct nfs3_mknodargs *args)
5863 + const struct nfs3_mknodargs *args, int tag)
5865 encode_ftype3(xdr, args->type);
5866 switch (args->type) {
5869 - encode_devicedata3(xdr, args);
5870 + encode_devicedata3(xdr, args, tag);
5874 - encode_sattr3(xdr, args->sattr);
5875 + encode_sattr3(xdr, args->sattr, tag);
5879 @@ -1153,7 +1159,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5880 const struct nfs3_mknodargs *args)
5882 encode_diropargs3(xdr, args->fh, args->name, args->len);
5883 - encode_mknoddata3(xdr, args);
5884 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5888 diff -NurpP --minimal linux-3.0-rc5/fs/nfs/super.c linux-3.0-rc5-vs2.3.1-pre3/fs/nfs/super.c
5889 --- linux-3.0-rc5/fs/nfs/super.c 2011-07-01 11:14:19.000000000 +0200
5890 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/nfs/super.c 2011-06-10 22:11:24.000000000 +0200
5892 #include <linux/nfs_xdr.h>
5893 #include <linux/magic.h>
5894 #include <linux/parser.h>
5895 +#include <linux/vs_tag.h>
5897 #include <asm/system.h>
5898 #include <asm/uaccess.h>
5899 @@ -87,6 +88,7 @@ enum {
5900 Opt_sharecache, Opt_nosharecache,
5901 Opt_resvport, Opt_noresvport,
5902 Opt_fscache, Opt_nofscache,
5903 + Opt_tag, Opt_notag,
5905 /* Mount options that take integer arguments */
5907 @@ -100,6 +102,7 @@ enum {
5913 /* Mount options that take string arguments */
5914 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
5915 @@ -180,6 +183,10 @@ static const match_table_t nfs_mount_opt
5916 { Opt_fscache_uniq, "fsc=%s" },
5917 { Opt_local_lock, "local_lock=%s" },
5919 + { Opt_tag, "tag" },
5920 + { Opt_notag, "notag" },
5921 + { Opt_tagid, "tagid=%u" },
5926 @@ -650,6 +657,7 @@ static void nfs_show_mount_options(struc
5927 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5928 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5929 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5930 + { NFS_MOUNT_TAGGED, ",tag", "" },
5933 const struct proc_nfs_info *nfs_infop;
5934 @@ -1198,6 +1206,14 @@ static int nfs_parse_mount_options(char
5935 kfree(mnt->fscache_uniq);
5936 mnt->fscache_uniq = NULL;
5938 +#ifndef CONFIG_TAGGING_NONE
5940 + mnt->flags |= NFS_MOUNT_TAGGED;
5943 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5948 * options that take numeric values
5949 @@ -1304,6 +1320,12 @@ static int nfs_parse_mount_options(char
5950 goto out_invalid_value;
5951 mnt->minorversion = option;
5953 +#ifdef CONFIG_PROPAGATE
5956 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5961 * options that take text values
5962 diff -NurpP --minimal linux-3.0-rc5/fs/nfsd/auth.c linux-3.0-rc5-vs2.3.1-pre3/fs/nfsd/auth.c
5963 --- linux-3.0-rc5/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
5964 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/nfsd/auth.c 2011-06-10 22:11:24.000000000 +0200
5966 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
5968 #include <linux/sched.h>
5969 +#include <linux/vs_tag.h>
5973 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5975 new->fsuid = rqstp->rq_cred.cr_uid;
5976 new->fsgid = rqstp->rq_cred.cr_gid;
5977 + /* FIXME: this desperately needs a tag :)
5978 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5981 rqgi = rqstp->rq_cred.cr_group_info;
5983 diff -NurpP --minimal linux-3.0-rc5/fs/nfsd/nfs3xdr.c linux-3.0-rc5-vs2.3.1-pre3/fs/nfsd/nfs3xdr.c
5984 --- linux-3.0-rc5/fs/nfsd/nfs3xdr.c 2011-07-01 11:14:19.000000000 +0200
5985 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/nfsd/nfs3xdr.c 2011-06-10 22:11:24.000000000 +0200
5989 #include <linux/namei.h>
5990 +#include <linux/vs_tag.h>
5994 @@ -95,6 +96,8 @@ static __be32 *
5995 decode_sattr3(__be32 *p, struct iattr *iap)
6003 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6006 iap->ia_valid |= ATTR_UID;
6007 - iap->ia_uid = ntohl(*p++);
6008 + uid = ntohl(*p++);
6011 iap->ia_valid |= ATTR_GID;
6012 - iap->ia_gid = ntohl(*p++);
6013 + gid = ntohl(*p++);
6015 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6016 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6017 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6021 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6022 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6023 *p++ = htonl((u32) stat->mode);
6024 *p++ = htonl((u32) stat->nlink);
6025 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6026 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6027 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6028 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6029 + stat->uid, stat->tag)));
6030 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6031 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6032 + stat->gid, stat->tag)));
6033 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6034 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6036 diff -NurpP --minimal linux-3.0-rc5/fs/nfsd/nfs4xdr.c linux-3.0-rc5-vs2.3.1-pre3/fs/nfsd/nfs4xdr.c
6037 --- linux-3.0-rc5/fs/nfsd/nfs4xdr.c 2011-07-01 11:14:19.000000000 +0200
6038 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/nfsd/nfs4xdr.c 2011-06-10 22:11:24.000000000 +0200
6040 #include <linux/statfs.h>
6041 #include <linux/utsname.h>
6042 #include <linux/sunrpc/svcauth_gss.h>
6043 +#include <linux/vs_tag.h>
6047 @@ -2090,14 +2091,18 @@ out_acl:
6048 WRITE32(stat.nlink);
6050 if (bmval1 & FATTR4_WORD1_OWNER) {
6051 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6052 + status = nfsd4_encode_user(rqstp,
6053 + TAGINO_UID(DX_TAG(dentry->d_inode),
6054 + stat.uid, stat.tag), &p, &buflen);
6055 if (status == nfserr_resource)
6060 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6061 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6062 + status = nfsd4_encode_group(rqstp,
6063 + TAGINO_GID(DX_TAG(dentry->d_inode),
6064 + stat.gid, stat.tag), &p, &buflen);
6065 if (status == nfserr_resource)
6068 diff -NurpP --minimal linux-3.0-rc5/fs/nfsd/nfsxdr.c linux-3.0-rc5-vs2.3.1-pre3/fs/nfsd/nfsxdr.c
6069 --- linux-3.0-rc5/fs/nfsd/nfsxdr.c 2011-05-22 16:17:53.000000000 +0200
6070 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/nfsd/nfsxdr.c 2011-06-10 22:11:24.000000000 +0200
6075 +#include <linux/vs_tag.h>
6077 #define NFSDDBG_FACILITY NFSDDBG_XDR
6079 @@ -88,6 +89,8 @@ static __be32 *
6080 decode_sattr(__be32 *p, struct iattr *iap)
6088 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6090 if ((tmp = ntohl(*p++)) != (u32)-1) {
6091 iap->ia_valid |= ATTR_UID;
6092 - iap->ia_uid = tmp;
6095 if ((tmp = ntohl(*p++)) != (u32)-1) {
6096 iap->ia_valid |= ATTR_GID;
6097 - iap->ia_gid = tmp;
6100 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6101 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6102 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6103 if ((tmp = ntohl(*p++)) != (u32)-1) {
6104 iap->ia_valid |= ATTR_SIZE;
6106 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6107 *p++ = htonl(nfs_ftypes[type >> 12]);
6108 *p++ = htonl((u32) stat->mode);
6109 *p++ = htonl((u32) stat->nlink);
6110 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6111 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6112 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6113 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6114 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6115 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6117 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6118 *p++ = htonl(NFS_MAXPATHLEN);
6119 diff -NurpP --minimal linux-3.0-rc5/fs/ocfs2/dlmglue.c linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/dlmglue.c
6120 --- linux-3.0-rc5/fs/ocfs2/dlmglue.c 2011-05-22 16:17:53.000000000 +0200
6121 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/dlmglue.c 2011-06-10 22:11:24.000000000 +0200
6122 @@ -2041,6 +2041,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6123 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6124 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6125 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6126 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6127 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6128 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6129 lvb->lvb_iatime_packed =
6130 @@ -2091,6 +2092,7 @@ static void ocfs2_refresh_inode_from_lvb
6132 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6133 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6134 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6135 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6136 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6137 ocfs2_unpack_timespec(&inode->i_atime,
6138 diff -NurpP --minimal linux-3.0-rc5/fs/ocfs2/dlmglue.h linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/dlmglue.h
6139 --- linux-3.0-rc5/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
6140 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/dlmglue.h 2011-06-10 22:11:24.000000000 +0200
6141 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6144 __be32 lvb_igeneration;
6145 - __be32 lvb_reserved2;
6147 + __be16 lvb_reserved2;
6150 #define OCFS2_QINFO_LVB_VERSION 1
6151 diff -NurpP --minimal linux-3.0-rc5/fs/ocfs2/file.c linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/file.c
6152 --- linux-3.0-rc5/fs/ocfs2/file.c 2011-07-01 11:14:20.000000000 +0200
6153 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/file.c 2011-06-10 22:43:33.000000000 +0200
6154 @@ -1111,7 +1111,7 @@ int ocfs2_setattr(struct dentry *dentry,
6155 attr->ia_valid &= ~ATTR_SIZE;
6157 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6158 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6159 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6160 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
6163 diff -NurpP --minimal linux-3.0-rc5/fs/ocfs2/inode.c linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/inode.c
6164 --- linux-3.0-rc5/fs/ocfs2/inode.c 2011-05-22 16:17:53.000000000 +0200
6165 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/inode.c 2011-06-10 22:11:24.000000000 +0200
6167 #include <linux/highmem.h>
6168 #include <linux/pagemap.h>
6169 #include <linux/quotaops.h>
6170 +#include <linux/vs_tag.h>
6172 #include <asm/byteorder.h>
6174 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
6176 unsigned int flags = OCFS2_I(inode)->ip_attr;
6178 - inode->i_flags &= ~(S_IMMUTABLE |
6179 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6180 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6182 if (flags & OCFS2_IMMUTABLE_FL)
6183 inode->i_flags |= S_IMMUTABLE;
6184 + if (flags & OCFS2_IXUNLINK_FL)
6185 + inode->i_flags |= S_IXUNLINK;
6187 if (flags & OCFS2_SYNC_FL)
6188 inode->i_flags |= S_SYNC;
6189 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
6190 inode->i_flags |= S_NOATIME;
6191 if (flags & OCFS2_DIRSYNC_FL)
6192 inode->i_flags |= S_DIRSYNC;
6194 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6196 + if (flags & OCFS2_BARRIER_FL)
6197 + inode->i_vflags |= V_BARRIER;
6198 + if (flags & OCFS2_COW_FL)
6199 + inode->i_vflags |= V_COW;
6202 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6203 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6205 unsigned int flags = oi->vfs_inode.i_flags;
6206 + unsigned int vflags = oi->vfs_inode.i_vflags;
6208 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6209 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6210 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6211 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6213 + if (flags & S_IMMUTABLE)
6214 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6215 + if (flags & S_IXUNLINK)
6216 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6218 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6219 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6221 oi->ip_attr |= OCFS2_SYNC_FL;
6222 if (flags & S_APPEND)
6223 oi->ip_attr |= OCFS2_APPEND_FL;
6224 - if (flags & S_IMMUTABLE)
6225 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6226 if (flags & S_NOATIME)
6227 oi->ip_attr |= OCFS2_NOATIME_FL;
6228 if (flags & S_DIRSYNC)
6229 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6231 + if (vflags & V_BARRIER)
6232 + oi->ip_attr |= OCFS2_BARRIER_FL;
6233 + if (vflags & V_COW)
6234 + oi->ip_attr |= OCFS2_COW_FL;
6237 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
6238 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
6239 struct super_block *sb;
6240 struct ocfs2_super *osb;
6247 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
6248 inode->i_generation = le32_to_cpu(fe->i_generation);
6249 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6250 inode->i_mode = le16_to_cpu(fe->i_mode);
6251 - inode->i_uid = le32_to_cpu(fe->i_uid);
6252 - inode->i_gid = le32_to_cpu(fe->i_gid);
6253 + uid = le32_to_cpu(fe->i_uid);
6254 + gid = le32_to_cpu(fe->i_gid);
6255 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6256 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6257 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6258 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6260 /* Fast symlinks will have i_size but no allocated clusters. */
6261 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6262 diff -NurpP --minimal linux-3.0-rc5/fs/ocfs2/inode.h linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/inode.h
6263 --- linux-3.0-rc5/fs/ocfs2/inode.h 2011-01-05 21:50:26.000000000 +0100
6264 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/inode.h 2011-06-10 22:11:24.000000000 +0200
6265 @@ -151,6 +151,7 @@ struct buffer_head *ocfs2_bread(struct i
6267 void ocfs2_set_inode_flags(struct inode *inode);
6268 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6269 +int ocfs2_sync_flags(struct inode *inode, int, int);
6271 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6273 diff -NurpP --minimal linux-3.0-rc5/fs/ocfs2/ioctl.c linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/ioctl.c
6274 --- linux-3.0-rc5/fs/ocfs2/ioctl.c 2011-07-01 11:14:20.000000000 +0200
6275 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/ioctl.c 2011-06-10 22:11:24.000000000 +0200
6276 @@ -78,7 +78,41 @@ static int ocfs2_get_inode_attr(struct i
6280 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6281 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6283 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6284 + struct buffer_head *bh = NULL;
6285 + handle_t *handle = NULL;
6288 + status = ocfs2_inode_lock(inode, &bh, 1);
6290 + mlog_errno(status);
6293 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6294 + if (IS_ERR(handle)) {
6295 + status = PTR_ERR(handle);
6296 + mlog_errno(status);
6300 + inode->i_flags = flags;
6301 + inode->i_vflags = vflags;
6302 + ocfs2_get_inode_flags(OCFS2_I(inode));
6304 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6306 + mlog_errno(status);
6308 + ocfs2_commit_trans(osb, handle);
6310 + ocfs2_inode_unlock(inode, 1);
6315 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6318 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6319 @@ -103,6 +137,11 @@ static int ocfs2_set_inode_attr(struct i
6320 if (!S_ISDIR(inode->i_mode))
6321 flags &= ~OCFS2_DIRSYNC_FL;
6323 + if (IS_BARRIER(inode)) {
6324 + vxwprintk_task(1, "messing with the barrier.");
6328 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6329 if (IS_ERR(handle)) {
6330 status = PTR_ERR(handle);
6331 @@ -880,6 +919,7 @@ bail:
6336 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6338 struct inode *inode = filp->f_path.dentry->d_inode;
6339 diff -NurpP --minimal linux-3.0-rc5/fs/ocfs2/namei.c linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/namei.c
6340 --- linux-3.0-rc5/fs/ocfs2/namei.c 2011-05-22 16:17:53.000000000 +0200
6341 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/namei.c 2011-06-10 22:11:24.000000000 +0200
6343 #include <linux/slab.h>
6344 #include <linux/highmem.h>
6345 #include <linux/quotaops.h>
6346 +#include <linux/vs_tag.h>
6348 #include <cluster/masklog.h>
6350 @@ -477,6 +478,7 @@ static int __ocfs2_mknod_locked(struct i
6351 struct ocfs2_dinode *fe = NULL;
6352 struct ocfs2_extent_list *fel;
6358 @@ -514,8 +516,11 @@ static int __ocfs2_mknod_locked(struct i
6359 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
6360 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6361 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6362 - fe->i_uid = cpu_to_le32(inode->i_uid);
6363 - fe->i_gid = cpu_to_le32(inode->i_gid);
6365 + tag = dx_current_fstag(osb->sb);
6366 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6367 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6368 + inode->i_tag = tag;
6369 fe->i_mode = cpu_to_le16(inode->i_mode);
6370 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6371 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6372 diff -NurpP --minimal linux-3.0-rc5/fs/ocfs2/ocfs2.h linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/ocfs2.h
6373 --- linux-3.0-rc5/fs/ocfs2/ocfs2.h 2011-05-22 16:17:53.000000000 +0200
6374 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/ocfs2.h 2011-06-10 22:11:24.000000000 +0200
6375 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
6377 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
6378 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
6379 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
6382 #define OCFS2_OSB_SOFT_RO 0x0001
6383 diff -NurpP --minimal linux-3.0-rc5/fs/ocfs2/ocfs2_fs.h linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/ocfs2_fs.h
6384 --- linux-3.0-rc5/fs/ocfs2/ocfs2_fs.h 2011-05-22 16:17:53.000000000 +0200
6385 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/ocfs2_fs.h 2011-06-10 22:11:24.000000000 +0200
6386 @@ -266,6 +266,11 @@
6387 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
6388 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
6390 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6392 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6393 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6395 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
6396 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
6398 diff -NurpP --minimal linux-3.0-rc5/fs/ocfs2/super.c linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/super.c
6399 --- linux-3.0-rc5/fs/ocfs2/super.c 2011-07-01 11:14:20.000000000 +0200
6400 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/ocfs2/super.c 2011-06-15 02:40:14.000000000 +0200
6401 @@ -184,6 +184,7 @@ enum {
6405 + Opt_tag, Opt_notag, Opt_tagid,
6409 @@ -215,6 +216,9 @@ static const match_table_t tokens = {
6410 {Opt_coherency_full, "coherency=full"},
6411 {Opt_resv_level, "resv_level=%u"},
6412 {Opt_dir_resv_level, "dir_resv_level=%u"},
6414 + {Opt_notag, "notag"},
6415 + {Opt_tagid, "tagid=%u"},
6419 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
6423 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6424 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6426 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6430 /* We're going to/from readonly mode. */
6431 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
6432 /* Disable quota accounting before remounting RO */
6433 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
6435 ocfs2_complete_mount_recovery(osb);
6437 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6438 + sb->s_flags |= MS_TAGGED;
6440 if (ocfs2_mount_local(osb))
6441 snprintf(nodestr, sizeof(nodestr), "local");
6443 @@ -1506,6 +1520,20 @@ static int ocfs2_parse_options(struct su
6444 option < OCFS2_MAX_RESV_LEVEL)
6445 mopt->dir_resv_level = option;
6447 +#ifndef CONFIG_TAGGING_NONE
6449 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6452 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6455 +#ifdef CONFIG_PROPAGATE
6458 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6463 "Unrecognized mount option \"%s\" "
6464 diff -NurpP --minimal linux-3.0-rc5/fs/open.c linux-3.0-rc5-vs2.3.1-pre3/fs/open.c
6465 --- linux-3.0-rc5/fs/open.c 2011-05-22 16:17:53.000000000 +0200
6466 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/open.c 2011-06-10 22:11:24.000000000 +0200
6468 #include <linux/fs_struct.h>
6469 #include <linux/ima.h>
6470 #include <linux/dnotify.h>
6471 +#include <linux/vs_base.h>
6472 +#include <linux/vs_limit.h>
6473 +#include <linux/vs_tag.h>
6474 +#include <linux/vs_cowbl.h>
6475 +#include <linux/vserver/dlimit.h>
6477 #include "internal.h"
6479 @@ -494,6 +499,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6480 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6484 +#ifdef CONFIG_VSERVER_COWBL
6485 + error = cow_check_and_break(&path);
6487 + goto dput_and_out;
6489 inode = path.dentry->d_inode;
6491 error = mnt_want_write(path.mnt);
6492 @@ -531,11 +542,11 @@ static int chown_common(struct path *pat
6493 newattrs.ia_valid = ATTR_CTIME;
6494 if (user != (uid_t) -1) {
6495 newattrs.ia_valid |= ATTR_UID;
6496 - newattrs.ia_uid = user;
6497 + newattrs.ia_uid = dx_map_uid(user);
6499 if (group != (gid_t) -1) {
6500 newattrs.ia_valid |= ATTR_GID;
6501 - newattrs.ia_gid = group;
6502 + newattrs.ia_gid = dx_map_gid(group);
6504 if (!S_ISDIR(inode->i_mode))
6505 newattrs.ia_valid |=
6506 @@ -560,6 +571,10 @@ SYSCALL_DEFINE3(chown, const char __user
6507 error = mnt_want_write(path.mnt);
6510 +#ifdef CONFIG_VSERVER_COWBL
6511 + error = cow_check_and_break(&path);
6514 error = chown_common(&path, user, group);
6515 mnt_drop_write(path.mnt);
6517 @@ -587,6 +602,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6518 error = mnt_want_write(path.mnt);
6521 +#ifdef CONFIG_VSERVER_COWBL
6522 + error = cow_check_and_break(&path);
6525 error = chown_common(&path, user, group);
6526 mnt_drop_write(path.mnt);
6528 @@ -606,6 +625,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6529 error = mnt_want_write(path.mnt);
6532 +#ifdef CONFIG_VSERVER_COWBL
6533 + error = cow_check_and_break(&path);
6536 error = chown_common(&path, user, group);
6537 mnt_drop_write(path.mnt);
6539 @@ -857,6 +880,7 @@ static void __put_unused_fd(struct files
6540 __FD_CLR(fd, fdt->open_fds);
6541 if (fd < files->next_fd)
6542 files->next_fd = fd;
6543 + vx_openfd_dec(fd);
6546 void put_unused_fd(unsigned int fd)
6547 diff -NurpP --minimal linux-3.0-rc5/fs/proc/array.c linux-3.0-rc5-vs2.3.1-pre3/fs/proc/array.c
6548 --- linux-3.0-rc5/fs/proc/array.c 2011-07-01 11:14:20.000000000 +0200
6549 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/proc/array.c 2011-06-10 22:11:24.000000000 +0200
6551 #include <linux/pid_namespace.h>
6552 #include <linux/ptrace.h>
6553 #include <linux/tracehook.h>
6554 +#include <linux/vs_context.h>
6555 +#include <linux/vs_network.h>
6557 #include <asm/pgtable.h>
6558 #include <asm/processor.h>
6559 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
6561 ppid = pid_alive(p) ?
6562 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6563 + if (unlikely(vx_current_initpid(p->pid)))
6568 struct task_struct *tracer = tracehook_tracer_task(p);
6569 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6572 static void render_cap_t(struct seq_file *m, const char *header,
6574 + struct vx_info *vxi, kernel_cap_t *a)
6578 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6579 cap_bset = cred->cap_bset;
6582 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6583 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6584 - render_cap_t(m, "CapEff:\t", &cap_effective);
6585 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6586 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6587 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6588 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6589 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6590 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6593 static inline void task_context_switch_counts(struct seq_file *m,
6594 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6598 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6599 + struct pid *pid, struct task_struct *task)
6601 + seq_printf(m, "Proxy:\t%p(%c)\n"
6609 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6610 + atomic_read(&task->nsproxy->count),
6611 + task->nsproxy->uts_ns,
6612 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6613 + task->nsproxy->ipc_ns,
6614 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6615 + task->nsproxy->mnt_ns,
6616 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6617 + task->nsproxy->pid_ns,
6618 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6619 + task->nsproxy->net_ns,
6620 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6624 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6626 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6629 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6630 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6634 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6635 struct pid *pid, struct task_struct *task)
6637 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6639 task_cpus_allowed(m, task);
6640 cpuset_task_status_allowed(m, task);
6641 + task_vs_id(m, task);
6642 task_context_switch_counts(m, task);
6645 @@ -462,6 +505,17 @@ static int do_task_stat(struct seq_file
6646 /* convert nsec -> ticks */
6647 start_time = nsec_to_clock_t(start_time);
6649 + /* fixup start time for virt uptime */
6650 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6651 + unsigned long long bias =
6652 + current->vx_info->cvirt.bias_clock;
6654 + if (start_time > bias)
6655 + start_time -= bias;
6660 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6661 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6662 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6663 diff -NurpP --minimal linux-3.0-rc5/fs/proc/base.c linux-3.0-rc5-vs2.3.1-pre3/fs/proc/base.c
6664 --- linux-3.0-rc5/fs/proc/base.c 2011-07-01 11:14:20.000000000 +0200
6665 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/proc/base.c 2011-06-22 12:39:15.000000000 +0200
6667 #include <linux/pid_namespace.h>
6668 #include <linux/fs_struct.h>
6669 #include <linux/slab.h>
6670 +#include <linux/vs_context.h>
6671 +#include <linux/vs_network.h>
6672 #ifdef CONFIG_HARDWALL
6673 #include <asm/hardwall.h>
6675 @@ -1102,11 +1104,16 @@ static ssize_t oom_adjust_write(struct f
6679 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6680 + if (oom_adjust < task->signal->oom_adj &&
6681 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6686 + /* prevent guest processes from circumventing the oom killer */
6687 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6688 + oom_adjust = OOM_ADJUST_MIN;
6690 if (oom_adjust != task->signal->oom_adj) {
6691 if (oom_adjust == OOM_DISABLE)
6692 atomic_inc(&task->mm->oom_disable_count);
6693 @@ -1275,7 +1282,7 @@ static ssize_t proc_loginuid_write(struc
6697 - if (!capable(CAP_AUDIT_CONTROL))
6698 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6702 @@ -1722,6 +1729,8 @@ struct inode *proc_pid_make_inode(struct
6703 inode->i_gid = cred->egid;
6706 + /* procfs is xid tagged */
6707 + inode->i_tag = (tag_t)vx_task_xid(task);
6708 security_task_to_inode(task, inode);
6711 @@ -1758,6 +1767,8 @@ int pid_getattr(struct vfsmount *mnt, st
6715 +static unsigned name_to_int(struct dentry *dentry);
6718 * Exceptional case: normally we are not allowed to unhash a busy
6719 * directory. In this case, however, we can do it - no aliasing problems
6720 @@ -1786,6 +1797,12 @@ int pid_revalidate(struct dentry *dentry
6721 task = get_proc_task(inode);
6724 + unsigned pid = name_to_int(dentry);
6726 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6727 + put_task_struct(task);
6730 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6731 task_dumpable(task)) {
6733 @@ -1802,6 +1819,7 @@ int pid_revalidate(struct dentry *dentry
6734 put_task_struct(task);
6741 @@ -2283,6 +2301,13 @@ static struct dentry *proc_pident_lookup
6745 + /* TODO: maybe we can come up with a generic approach? */
6746 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6747 + (dentry->d_name.len == 5) &&
6748 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6749 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6753 * Yes, it does not scale. And it should not. Don't add
6754 * new entries into /proc/<tgid>/ without very good reasons.
6755 @@ -2668,7 +2693,7 @@ out_iput:
6756 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6758 struct dentry *error;
6759 - struct task_struct *task = get_proc_task(dir);
6760 + struct task_struct *task = get_proc_task_real(dir);
6761 const struct pid_entry *p, *last;
6763 error = ERR_PTR(-ENOENT);
6764 @@ -2762,6 +2787,9 @@ static int proc_pid_personality(struct s
6765 static const struct file_operations proc_task_operations;
6766 static const struct inode_operations proc_task_inode_operations;
6768 +extern int proc_pid_vx_info(struct task_struct *, char *);
6769 +extern int proc_pid_nx_info(struct task_struct *, char *);
6771 static const struct pid_entry tgid_base_stuff[] = {
6772 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6773 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6774 @@ -2825,6 +2853,8 @@ static const struct pid_entry tgid_base_
6775 #ifdef CONFIG_CGROUPS
6776 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6778 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6779 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6780 INF("oom_score", S_IRUGO, proc_oom_score),
6781 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6782 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6783 @@ -2844,6 +2874,7 @@ static const struct pid_entry tgid_base_
6784 #ifdef CONFIG_HARDWALL
6785 INF("hardwall", S_IRUGO, proc_pid_hardwall),
6787 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6790 static int proc_tgid_base_readdir(struct file * filp,
6791 @@ -3036,7 +3067,7 @@ retry:
6793 pid = find_ge_pid(iter.tgid, ns);
6795 - iter.tgid = pid_nr_ns(pid, ns);
6796 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6797 iter.task = pid_task(pid, PIDTYPE_PID);
6798 /* What we to know is if the pid we have find is the
6799 * pid of a thread_group_leader. Testing for task
6800 @@ -3066,7 +3097,7 @@ static int proc_pid_fill_cache(struct fi
6801 struct tgid_iter iter)
6803 char name[PROC_NUMBUF];
6804 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6805 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6806 return proc_fill_cache(filp, dirent, filldir, name, len,
6807 proc_pid_instantiate, iter.task, NULL);
6809 @@ -3083,7 +3114,7 @@ int proc_pid_readdir(struct file * filp,
6811 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6813 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
6814 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6818 @@ -3100,6 +3131,8 @@ int proc_pid_readdir(struct file * filp,
6820 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6821 filp->f_pos = iter.tgid + TGID_OFFSET;
6822 + if (!vx_proc_task_visible(iter.task))
6824 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6825 put_task_struct(iter.task);
6827 @@ -3253,6 +3286,8 @@ static struct dentry *proc_task_lookup(s
6828 tid = name_to_int(dentry);
6831 + if (vx_current_initpid(tid))
6834 ns = dentry->d_sb->s_fs_info;
6836 diff -NurpP --minimal linux-3.0-rc5/fs/proc/generic.c linux-3.0-rc5-vs2.3.1-pre3/fs/proc/generic.c
6837 --- linux-3.0-rc5/fs/proc/generic.c 2011-07-01 11:14:20.000000000 +0200
6838 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/proc/generic.c 2011-06-10 22:11:24.000000000 +0200
6840 #include <linux/bitops.h>
6841 #include <linux/spinlock.h>
6842 #include <linux/completion.h>
6843 +#include <linux/vserver/inode.h>
6844 #include <asm/uaccess.h>
6846 #include "internal.h"
6847 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
6848 for (de = de->subdir; de ; de = de->next) {
6849 if (de->namelen != dentry->d_name.len)
6851 + if (!vx_hide_check(0, de->vx_flags))
6853 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6855 spin_unlock(&proc_subdir_lock);
6857 inode = proc_get_inode(dir->i_sb, de);
6858 + /* generic proc entries belong to the host */
6863 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
6865 /* filldir passes info to user space */
6867 + if (!vx_hide_check(0, de->vx_flags))
6869 spin_unlock(&proc_subdir_lock);
6870 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6871 de->low_ino, de->mode >> 12) < 0) {
6872 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
6875 spin_lock(&proc_subdir_lock);
6880 @@ -627,6 +635,7 @@ static struct proc_dir_entry *__proc_cre
6882 atomic_set(&ent->count, 1);
6884 + ent->vx_flags = IATTR_PROC_DEFAULT;
6885 spin_lock_init(&ent->pde_unload_lock);
6886 ent->pde_unload_completion = NULL;
6887 INIT_LIST_HEAD(&ent->pde_openers);
6888 @@ -650,7 +659,8 @@ struct proc_dir_entry *proc_symlink(cons
6894 + ent->vx_flags = IATTR_PROC_SYMLINK;
6898 diff -NurpP --minimal linux-3.0-rc5/fs/proc/inode.c linux-3.0-rc5-vs2.3.1-pre3/fs/proc/inode.c
6899 --- linux-3.0-rc5/fs/proc/inode.c 2011-07-01 11:14:20.000000000 +0200
6900 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/proc/inode.c 2011-06-10 22:11:24.000000000 +0200
6901 @@ -442,6 +442,8 @@ struct inode *proc_get_inode(struct supe
6902 inode->i_uid = de->uid;
6903 inode->i_gid = de->gid;
6906 + PROC_I(inode)->vx_flags = de->vx_flags;
6908 inode->i_size = de->size;
6910 diff -NurpP --minimal linux-3.0-rc5/fs/proc/internal.h linux-3.0-rc5-vs2.3.1-pre3/fs/proc/internal.h
6911 --- linux-3.0-rc5/fs/proc/internal.h 2011-07-01 11:14:20.000000000 +0200
6912 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/proc/internal.h 2011-06-10 22:11:24.000000000 +0200
6916 #include <linux/proc_fs.h>
6917 +#include <linux/vs_pid.h>
6919 extern struct proc_dir_entry proc_root;
6920 #ifdef CONFIG_PROC_SYSCTL
6921 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
6922 struct pid *pid, struct task_struct *task);
6923 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6924 struct pid *pid, struct task_struct *task);
6925 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6926 + struct pid *pid, struct task_struct *task);
6928 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6930 extern const struct file_operations proc_maps_operations;
6931 @@ -76,11 +80,16 @@ static inline struct pid *proc_pid(struc
6932 return PROC_I(inode)->pid;
6935 -static inline struct task_struct *get_proc_task(struct inode *inode)
6936 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6938 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6941 +static inline struct task_struct *get_proc_task(struct inode *inode)
6943 + return vx_get_proc_task(inode, proc_pid(inode));
6946 static inline int proc_fd(struct inode *inode)
6948 return PROC_I(inode)->fd;
6949 diff -NurpP --minimal linux-3.0-rc5/fs/proc/loadavg.c linux-3.0-rc5-vs2.3.1-pre3/fs/proc/loadavg.c
6950 --- linux-3.0-rc5/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
6951 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/proc/loadavg.c 2011-06-10 22:11:24.000000000 +0200
6954 static int loadavg_proc_show(struct seq_file *m, void *v)
6956 + unsigned long running;
6957 + unsigned int threads;
6958 unsigned long avnrun[3];
6960 get_avenrun(avnrun, FIXED_1/200, 0);
6962 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6963 + struct vx_info *vxi = current_vx_info();
6965 + running = atomic_read(&vxi->cvirt.nr_running);
6966 + threads = atomic_read(&vxi->cvirt.nr_threads);
6968 + running = nr_running();
6969 + threads = nr_threads;
6972 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6973 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6974 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6975 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6976 - nr_running(), nr_threads,
6978 task_active_pid_ns(current)->last_pid);
6981 diff -NurpP --minimal linux-3.0-rc5/fs/proc/meminfo.c linux-3.0-rc5-vs2.3.1-pre3/fs/proc/meminfo.c
6982 --- linux-3.0-rc5/fs/proc/meminfo.c 2011-03-15 18:07:33.000000000 +0100
6983 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/proc/meminfo.c 2011-06-10 22:11:24.000000000 +0200
6984 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
6985 allowed = ((totalram_pages - hugetlb_total_pages())
6986 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6988 - cached = global_page_state(NR_FILE_PAGES) -
6989 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6990 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6991 total_swapcache_pages - i.bufferram;
6994 diff -NurpP --minimal linux-3.0-rc5/fs/proc/root.c linux-3.0-rc5-vs2.3.1-pre3/fs/proc/root.c
6995 --- linux-3.0-rc5/fs/proc/root.c 2011-07-01 11:14:20.000000000 +0200
6996 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/proc/root.c 2011-06-22 12:39:15.000000000 +0200
6998 #include <linux/bitops.h>
6999 #include <linux/mount.h>
7000 #include <linux/pid_namespace.h>
7001 +#include <linux/vserver/inode.h>
7003 #include "internal.h"
7005 +struct proc_dir_entry *proc_virtual;
7007 +extern void proc_vx_init(void);
7009 static int proc_test_super(struct super_block *sb, void *data)
7011 return sb->s_fs_info == data;
7012 @@ -125,6 +130,7 @@ void __init proc_root_init(void)
7014 proc_mkdir("bus", NULL);
7019 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7020 @@ -193,6 +199,7 @@ struct proc_dir_entry proc_root = {
7021 .proc_iops = &proc_root_inode_operations,
7022 .proc_fops = &proc_root_operations,
7023 .parent = &proc_root,
7024 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7027 int pid_ns_prepare_proc(struct pid_namespace *ns)
7028 diff -NurpP --minimal linux-3.0-rc5/fs/proc/uptime.c linux-3.0-rc5-vs2.3.1-pre3/fs/proc/uptime.c
7029 --- linux-3.0-rc5/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
7030 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/proc/uptime.c 2011-06-10 22:11:24.000000000 +0200
7032 #include <linux/sched.h>
7033 #include <linux/seq_file.h>
7034 #include <linux/time.h>
7035 -#include <linux/kernel_stat.h>
7036 +#include <linux/vserver/cvirt.h>
7037 #include <asm/cputime.h>
7039 static int uptime_proc_show(struct seq_file *m, void *v)
7041 struct timespec uptime;
7042 struct timespec idle;
7044 - cputime_t idletime = cputime_zero;
7046 - for_each_possible_cpu(i)
7047 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
7048 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
7050 do_posix_clock_monotonic_gettime(&uptime);
7051 monotonic_to_bootbased(&uptime);
7052 cputime_to_timespec(idletime, &idle);
7054 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7055 + vx_vsi_uptime(&uptime, &idle);
7057 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
7058 (unsigned long) uptime.tv_sec,
7059 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7060 diff -NurpP --minimal linux-3.0-rc5/fs/quota/dquot.c linux-3.0-rc5-vs2.3.1-pre3/fs/quota/dquot.c
7061 --- linux-3.0-rc5/fs/quota/dquot.c 2011-07-01 11:14:20.000000000 +0200
7062 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/quota/dquot.c 2011-06-10 22:11:24.000000000 +0200
7063 @@ -1548,6 +1548,9 @@ int __dquot_alloc_space(struct inode *in
7064 int reserve = flags & DQUOT_SPACE_RESERVE;
7065 int nofail = flags & DQUOT_SPACE_NOFAIL;
7067 + if ((ret = dl_alloc_space(inode, number)))
7071 * First test before acquiring mutex - solves deadlocks when we
7072 * re-enter the quota code and are already holding the mutex
7073 @@ -1602,6 +1605,9 @@ int dquot_alloc_inode(const struct inode
7075 char warntype[MAXQUOTAS];
7077 + if ((ret = dl_alloc_inode(inode)))
7080 /* First test before acquiring mutex - solves deadlocks when we
7081 * re-enter the quota code and are already holding the mutex */
7082 if (!dquot_active(inode))
7083 @@ -1672,6 +1678,8 @@ void __dquot_free_space(struct inode *in
7084 char warntype[MAXQUOTAS];
7085 int reserve = flags & DQUOT_SPACE_RESERVE;
7087 + dl_free_space(inode, number);
7089 /* First test before acquiring mutex - solves deadlocks when we
7090 * re-enter the quota code and are already holding the mutex */
7091 if (!dquot_active(inode)) {
7092 @@ -1710,6 +1718,8 @@ void dquot_free_inode(const struct inode
7094 char warntype[MAXQUOTAS];
7096 + dl_free_inode(inode);
7098 /* First test before acquiring mutex - solves deadlocks when we
7099 * re-enter the quota code and are already holding the mutex */
7100 if (!dquot_active(inode))
7101 diff -NurpP --minimal linux-3.0-rc5/fs/quota/quota.c linux-3.0-rc5-vs2.3.1-pre3/fs/quota/quota.c
7102 --- linux-3.0-rc5/fs/quota/quota.c 2011-03-15 18:07:34.000000000 +0100
7103 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/quota/quota.c 2011-06-13 18:19:47.000000000 +0200
7105 #include <linux/fs.h>
7106 #include <linux/namei.h>
7107 #include <linux/slab.h>
7108 +#include <linux/vs_context.h>
7109 #include <asm/current.h>
7110 #include <asm/uaccess.h>
7111 #include <linux/kernel.h>
7112 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
7116 - if (!capable(CAP_SYS_ADMIN))
7117 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7121 @@ -293,6 +294,46 @@ static int do_quotactl(struct super_bloc
7125 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7127 +#include <linux/vroot.h>
7128 +#include <linux/major.h>
7129 +#include <linux/module.h>
7130 +#include <linux/kallsyms.h>
7131 +#include <linux/vserver/debug.h>
7133 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7135 +static DEFINE_SPINLOCK(vroot_grb_lock);
7137 +int register_vroot_grb(vroot_grb_func *func) {
7140 + spin_lock(&vroot_grb_lock);
7141 + if (!vroot_get_real_bdev) {
7142 + vroot_get_real_bdev = func;
7145 + spin_unlock(&vroot_grb_lock);
7148 +EXPORT_SYMBOL(register_vroot_grb);
7150 +int unregister_vroot_grb(vroot_grb_func *func) {
7151 + int ret = -EINVAL;
7153 + spin_lock(&vroot_grb_lock);
7154 + if (vroot_get_real_bdev) {
7155 + vroot_get_real_bdev = NULL;
7158 + spin_unlock(&vroot_grb_lock);
7161 +EXPORT_SYMBOL(unregister_vroot_grb);
7166 * look up a superblock on which quota ops will be performed
7167 * - use the name of a block device to find the superblock thereon
7168 @@ -310,6 +351,22 @@ static struct super_block *quotactl_bloc
7171 return ERR_CAST(bdev);
7172 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7173 + if (bdev && bdev->bd_inode &&
7174 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7175 + struct block_device *bdnew = (void *)-EINVAL;
7177 + if (vroot_get_real_bdev)
7178 + bdnew = vroot_get_real_bdev(bdev);
7180 + vxdprintk(VXD_CBIT(misc, 0),
7181 + "vroot_get_real_bdev not set");
7183 + if (IS_ERR(bdnew))
7184 + return ERR_PTR(PTR_ERR(bdnew));
7188 sb = get_super(bdev);
7191 diff -NurpP --minimal linux-3.0-rc5/fs/reiserfs/file.c linux-3.0-rc5-vs2.3.1-pre3/fs/reiserfs/file.c
7192 --- linux-3.0-rc5/fs/reiserfs/file.c 2011-01-05 21:50:26.000000000 +0100
7193 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/reiserfs/file.c 2011-06-10 22:11:24.000000000 +0200
7194 @@ -312,4 +312,5 @@ const struct inode_operations reiserfs_f
7195 .listxattr = reiserfs_listxattr,
7196 .removexattr = reiserfs_removexattr,
7197 .permission = reiserfs_permission,
7198 + .sync_flags = reiserfs_sync_flags,
7200 diff -NurpP --minimal linux-3.0-rc5/fs/reiserfs/inode.c linux-3.0-rc5-vs2.3.1-pre3/fs/reiserfs/inode.c
7201 --- linux-3.0-rc5/fs/reiserfs/inode.c 2011-05-22 16:17:53.000000000 +0200
7202 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/reiserfs/inode.c 2011-06-10 22:11:24.000000000 +0200
7204 #include <linux/writeback.h>
7205 #include <linux/quotaops.h>
7206 #include <linux/swap.h>
7207 +#include <linux/vs_tag.h>
7209 int reiserfs_commit_write(struct file *f, struct page *page,
7210 unsigned from, unsigned to);
7211 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
7212 struct buffer_head *bh;
7213 struct item_head *ih;
7217 //int version = ITEM_VERSION_1;
7219 bh = PATH_PLAST_BUFFER(path);
7220 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
7221 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7222 unsigned long blocks;
7224 + uid = sd_v1_uid(sd);
7225 + gid = sd_v1_gid(sd);
7227 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7228 set_inode_sd_version(inode, STAT_DATA_V1);
7229 inode->i_mode = sd_v1_mode(sd);
7230 inode->i_nlink = sd_v1_nlink(sd);
7231 - inode->i_uid = sd_v1_uid(sd);
7232 - inode->i_gid = sd_v1_gid(sd);
7233 inode->i_size = sd_v1_size(sd);
7234 inode->i_atime.tv_sec = sd_v1_atime(sd);
7235 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7236 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
7237 // (directories and symlinks)
7238 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7240 + uid = sd_v2_uid(sd);
7241 + gid = sd_v2_gid(sd);
7243 inode->i_mode = sd_v2_mode(sd);
7244 inode->i_nlink = sd_v2_nlink(sd);
7245 - inode->i_uid = sd_v2_uid(sd);
7246 inode->i_size = sd_v2_size(sd);
7247 - inode->i_gid = sd_v2_gid(sd);
7248 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7249 inode->i_atime.tv_sec = sd_v2_atime(sd);
7250 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7251 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
7252 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7255 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7256 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7257 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7260 if (S_ISREG(inode->i_mode)) {
7261 inode->i_op = &reiserfs_file_inode_operations;
7262 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
7263 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7265 struct stat_data *sd_v2 = (struct stat_data *)sd;
7266 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7267 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7270 + set_sd_v2_uid(sd_v2, uid);
7271 + set_sd_v2_gid(sd_v2, gid);
7272 set_sd_v2_mode(sd_v2, inode->i_mode);
7273 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7274 - set_sd_v2_uid(sd_v2, inode->i_uid);
7275 set_sd_v2_size(sd_v2, size);
7276 - set_sd_v2_gid(sd_v2, inode->i_gid);
7277 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7278 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7279 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7280 @@ -2863,14 +2874,19 @@ int reiserfs_commit_write(struct file *f
7281 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7283 if (reiserfs_attrs(inode->i_sb)) {
7284 - if (sd_attrs & REISERFS_SYNC_FL)
7285 - inode->i_flags |= S_SYNC;
7287 - inode->i_flags &= ~S_SYNC;
7288 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7289 inode->i_flags |= S_IMMUTABLE;
7291 inode->i_flags &= ~S_IMMUTABLE;
7292 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7293 + inode->i_flags |= S_IXUNLINK;
7295 + inode->i_flags &= ~S_IXUNLINK;
7297 + if (sd_attrs & REISERFS_SYNC_FL)
7298 + inode->i_flags |= S_SYNC;
7300 + inode->i_flags &= ~S_SYNC;
7301 if (sd_attrs & REISERFS_APPEND_FL)
7302 inode->i_flags |= S_APPEND;
7304 @@ -2883,6 +2899,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7305 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7307 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7309 + if (sd_attrs & REISERFS_BARRIER_FL)
7310 + inode->i_vflags |= V_BARRIER;
7312 + inode->i_vflags &= ~V_BARRIER;
7313 + if (sd_attrs & REISERFS_COW_FL)
7314 + inode->i_vflags |= V_COW;
7316 + inode->i_vflags &= ~V_COW;
7320 @@ -2893,6 +2918,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7321 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7323 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7324 + if (inode->i_flags & S_IXUNLINK)
7325 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7327 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7329 if (inode->i_flags & S_SYNC)
7330 *sd_attrs |= REISERFS_SYNC_FL;
7332 @@ -2905,6 +2935,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7333 *sd_attrs |= REISERFS_NOTAIL_FL;
7335 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7337 + if (inode->i_vflags & V_BARRIER)
7338 + *sd_attrs |= REISERFS_BARRIER_FL;
7340 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7341 + if (inode->i_vflags & V_COW)
7342 + *sd_attrs |= REISERFS_COW_FL;
7344 + *sd_attrs &= ~REISERFS_COW_FL;
7348 @@ -3148,7 +3187,8 @@ int reiserfs_setattr(struct dentry *dent
7351 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7352 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7353 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7354 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7355 struct reiserfs_transaction_handle th;
7358 @@ -3177,6 +3217,9 @@ int reiserfs_setattr(struct dentry *dent
7359 inode->i_uid = attr->ia_uid;
7360 if (attr->ia_valid & ATTR_GID)
7361 inode->i_gid = attr->ia_gid;
7362 + if ((attr->ia_valid & ATTR_TAG) &&
7364 + inode->i_tag = attr->ia_tag;
7365 mark_inode_dirty(inode);
7366 error = journal_end(&th, inode->i_sb, jbegin_count);
7368 diff -NurpP --minimal linux-3.0-rc5/fs/reiserfs/ioctl.c linux-3.0-rc5-vs2.3.1-pre3/fs/reiserfs/ioctl.c
7369 --- linux-3.0-rc5/fs/reiserfs/ioctl.c 2011-05-22 16:17:53.000000000 +0200
7370 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/reiserfs/ioctl.c 2011-06-10 22:11:24.000000000 +0200
7372 #include <linux/pagemap.h>
7373 #include <linux/compat.h>
7376 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7378 + __u16 sd_attrs = 0;
7380 + inode->i_flags = flags;
7381 + inode->i_vflags = vflags;
7383 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7384 + REISERFS_I(inode)->i_attrs = sd_attrs;
7385 + inode->i_ctime = CURRENT_TIME_SEC;
7386 + mark_inode_dirty(inode);
7391 * reiserfs_ioctl - handler for ioctl for inode
7392 * supported commands:
7394 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7396 struct inode *inode = filp->f_path.dentry->d_inode;
7397 - unsigned int flags;
7398 + unsigned int flags, oldflags;
7401 reiserfs_write_lock(inode->i_sb);
7402 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7404 flags = REISERFS_I(inode)->i_attrs;
7405 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7406 + flags &= REISERFS_FL_USER_VISIBLE;
7407 err = put_user(flags, (int __user *)arg);
7409 case REISERFS_IOC_SETFLAGS:{
7410 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7414 + if (IS_BARRIER(inode)) {
7415 + vxwprintk_task(1, "messing with the barrier.");
7419 * Is it quota file? Do not allow user to mess with it
7421 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7426 + oldflags = REISERFS_I(inode)->i_attrs;
7427 + flags &= REISERFS_FL_USER_MODIFIABLE;
7428 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7429 sd_attrs_to_i_attrs(flags, inode);
7430 REISERFS_I(inode)->i_attrs = flags;
7431 inode->i_ctime = CURRENT_TIME_SEC;
7432 diff -NurpP --minimal linux-3.0-rc5/fs/reiserfs/namei.c linux-3.0-rc5-vs2.3.1-pre3/fs/reiserfs/namei.c
7433 --- linux-3.0-rc5/fs/reiserfs/namei.c 2011-05-22 16:17:53.000000000 +0200
7434 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/reiserfs/namei.c 2011-06-10 22:11:24.000000000 +0200
7436 #include <linux/reiserfs_acl.h>
7437 #include <linux/reiserfs_xattr.h>
7438 #include <linux/quotaops.h>
7439 +#include <linux/vs_tag.h>
7441 #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; }
7442 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7443 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7444 if (retval == IO_ERROR) {
7445 return ERR_PTR(-EIO);
7447 + dx_propagate_tag(nd, inode);
7449 return d_splice_alias(inode, dentry);
7451 @@ -1529,6 +1531,7 @@ const struct inode_operations reiserfs_d
7452 .listxattr = reiserfs_listxattr,
7453 .removexattr = reiserfs_removexattr,
7454 .permission = reiserfs_permission,
7455 + .sync_flags = reiserfs_sync_flags,
7459 diff -NurpP --minimal linux-3.0-rc5/fs/reiserfs/super.c linux-3.0-rc5-vs2.3.1-pre3/fs/reiserfs/super.c
7460 --- linux-3.0-rc5/fs/reiserfs/super.c 2011-07-01 11:14:20.000000000 +0200
7461 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/reiserfs/super.c 2011-06-10 22:11:24.000000000 +0200
7462 @@ -899,6 +899,14 @@ static int reiserfs_parse_options(struct
7463 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7464 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7466 +#ifndef CONFIG_TAGGING_NONE
7467 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7468 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7469 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7471 +#ifdef CONFIG_PROPAGATE
7472 + {"tag",.arg_required = 'T',.values = NULL},
7474 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7475 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7476 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7477 @@ -1208,6 +1216,14 @@ static int reiserfs_remount(struct super
7478 handle_quota_files(s, qf_names, &qfmt);
7481 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7482 + !(s->s_flags & MS_TAGGED)) {
7483 + reiserfs_warning(s, "super-vs01",
7484 + "reiserfs: tagging not permitted on remount.");
7491 /* Add options that are safe here */
7492 @@ -1690,6 +1706,10 @@ static int reiserfs_fill_super(struct su
7496 + /* map mount option tagxid */
7497 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7498 + s->s_flags |= MS_TAGGED;
7500 rs = SB_DISK_SUPER_BLOCK(s);
7501 /* Let's do basic sanity check to verify that underlying device is not
7502 smaller than the filesystem. If the check fails then abort and scream,
7503 diff -NurpP --minimal linux-3.0-rc5/fs/reiserfs/xattr.c linux-3.0-rc5-vs2.3.1-pre3/fs/reiserfs/xattr.c
7504 --- linux-3.0-rc5/fs/reiserfs/xattr.c 2011-07-01 11:14:20.000000000 +0200
7505 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/reiserfs/xattr.c 2011-06-22 12:39:15.000000000 +0200
7507 #include <linux/errno.h>
7508 #include <linux/gfp.h>
7509 #include <linux/fs.h>
7510 +#include <linux/mount.h>
7511 #include <linux/file.h>
7512 #include <linux/pagemap.h>
7513 #include <linux/xattr.h>
7514 diff -NurpP --minimal linux-3.0-rc5/fs/stat.c linux-3.0-rc5-vs2.3.1-pre3/fs/stat.c
7515 --- linux-3.0-rc5/fs/stat.c 2011-05-22 16:17:54.000000000 +0200
7516 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/stat.c 2011-06-10 22:11:24.000000000 +0200
7517 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7518 stat->nlink = inode->i_nlink;
7519 stat->uid = inode->i_uid;
7520 stat->gid = inode->i_gid;
7521 + stat->tag = inode->i_tag;
7522 stat->rdev = inode->i_rdev;
7523 stat->atime = inode->i_atime;
7524 stat->mtime = inode->i_mtime;
7525 diff -NurpP --minimal linux-3.0-rc5/fs/statfs.c linux-3.0-rc5-vs2.3.1-pre3/fs/statfs.c
7526 --- linux-3.0-rc5/fs/statfs.c 2011-05-22 16:17:54.000000000 +0200
7527 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/statfs.c 2011-06-10 22:11:24.000000000 +0200
7529 #include <linux/statfs.h>
7530 #include <linux/security.h>
7531 #include <linux/uaccess.h>
7532 +#include <linux/vs_base.h>
7533 +#include <linux/vs_dlimit.h>
7535 static int flags_by_mnt(int mnt_flags)
7537 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
7538 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7539 if (retval == 0 && buf->f_frsize == 0)
7540 buf->f_frsize = buf->f_bsize;
7541 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7542 + vx_vsi_statfs(dentry->d_sb, buf);
7546 diff -NurpP --minimal linux-3.0-rc5/fs/sysfs/mount.c linux-3.0-rc5-vs2.3.1-pre3/fs/sysfs/mount.c
7547 --- linux-3.0-rc5/fs/sysfs/mount.c 2011-07-01 11:14:20.000000000 +0200
7548 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/sysfs/mount.c 2011-06-22 12:39:15.000000000 +0200
7549 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7551 sb->s_blocksize = PAGE_CACHE_SIZE;
7552 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7553 - sb->s_magic = SYSFS_MAGIC;
7554 + sb->s_magic = SYSFS_SUPER_MAGIC;
7555 sb->s_op = &sysfs_ops;
7556 sb->s_time_gran = 1;
7558 diff -NurpP --minimal linux-3.0-rc5/fs/utimes.c linux-3.0-rc5-vs2.3.1-pre3/fs/utimes.c
7559 --- linux-3.0-rc5/fs/utimes.c 2011-05-22 16:17:54.000000000 +0200
7560 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/utimes.c 2011-06-10 22:11:24.000000000 +0200
7562 #include <linux/stat.h>
7563 #include <linux/utime.h>
7564 #include <linux/syscalls.h>
7565 +#include <linux/mount.h>
7566 +#include <linux/vs_cowbl.h>
7567 #include <asm/uaccess.h>
7568 #include <asm/unistd.h>
7570 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7573 struct iattr newattrs;
7574 - struct inode *inode = path->dentry->d_inode;
7575 + struct inode *inode;
7577 error = mnt_want_write(path->mnt);
7581 + error = cow_check_and_break(path);
7583 + goto mnt_drop_write_and_out;
7585 + inode = path->dentry->d_inode;
7587 if (times && times[0].tv_nsec == UTIME_NOW &&
7588 times[1].tv_nsec == UTIME_NOW)
7590 diff -NurpP --minimal linux-3.0-rc5/fs/xattr.c linux-3.0-rc5-vs2.3.1-pre3/fs/xattr.c
7591 --- linux-3.0-rc5/fs/xattr.c 2011-07-01 11:14:20.000000000 +0200
7592 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xattr.c 2011-06-10 23:10:19.000000000 +0200
7594 #include <linux/module.h>
7595 #include <linux/fsnotify.h>
7596 #include <linux/audit.h>
7597 +#include <linux/mount.h>
7598 #include <asm/uaccess.h>
7601 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
7602 * The trusted.* namespace can only be accessed by privileged users.
7604 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
7605 - if (!capable(CAP_SYS_ADMIN))
7606 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
7607 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
7610 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/linux-2.6/xfs_ioctl.c linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/linux-2.6/xfs_ioctl.c
7611 --- linux-3.0-rc5/fs/xfs/linux-2.6/xfs_ioctl.c 2011-05-22 16:17:54.000000000 +0200
7612 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/linux-2.6/xfs_ioctl.c 2011-06-10 22:11:24.000000000 +0200
7614 #include "xfs_bmap_btree.h"
7615 #include "xfs_dinode.h"
7616 #include "xfs_inode.h"
7617 -#include "xfs_ioctl.h"
7618 +// #include "xfs_ioctl.h"
7619 #include "xfs_rtalloc.h"
7620 #include "xfs_itable.h"
7621 #include "xfs_error.h"
7622 @@ -748,6 +748,10 @@ xfs_merge_ioc_xflags(
7623 xflags |= XFS_XFLAG_IMMUTABLE;
7625 xflags &= ~XFS_XFLAG_IMMUTABLE;
7626 + if (flags & FS_IXUNLINK_FL)
7627 + xflags |= XFS_XFLAG_IXUNLINK;
7629 + xflags &= ~XFS_XFLAG_IXUNLINK;
7630 if (flags & FS_APPEND_FL)
7631 xflags |= XFS_XFLAG_APPEND;
7633 @@ -776,6 +780,8 @@ xfs_di2lxflags(
7635 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7636 flags |= FS_IMMUTABLE_FL;
7637 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7638 + flags |= FS_IXUNLINK_FL;
7639 if (di_flags & XFS_DIFLAG_APPEND)
7640 flags |= FS_APPEND_FL;
7641 if (di_flags & XFS_DIFLAG_SYNC)
7642 @@ -836,6 +842,8 @@ xfs_set_diflags(
7643 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7644 if (xflags & XFS_XFLAG_IMMUTABLE)
7645 di_flags |= XFS_DIFLAG_IMMUTABLE;
7646 + if (xflags & XFS_XFLAG_IXUNLINK)
7647 + di_flags |= XFS_DIFLAG_IXUNLINK;
7648 if (xflags & XFS_XFLAG_APPEND)
7649 di_flags |= XFS_DIFLAG_APPEND;
7650 if (xflags & XFS_XFLAG_SYNC)
7651 @@ -878,6 +886,10 @@ xfs_diflags_to_linux(
7652 inode->i_flags |= S_IMMUTABLE;
7654 inode->i_flags &= ~S_IMMUTABLE;
7655 + if (xflags & XFS_XFLAG_IXUNLINK)
7656 + inode->i_flags |= S_IXUNLINK;
7658 + inode->i_flags &= ~S_IXUNLINK;
7659 if (xflags & XFS_XFLAG_APPEND)
7660 inode->i_flags |= S_APPEND;
7662 @@ -1370,10 +1382,18 @@ xfs_file_ioctl(
7663 case XFS_IOC_FSGETXATTRA:
7664 return xfs_ioc_fsgetxattr(ip, 1, arg);
7665 case XFS_IOC_FSSETXATTR:
7666 + if (IS_BARRIER(inode)) {
7667 + vxwprintk_task(1, "messing with the barrier.");
7668 + return -XFS_ERROR(EACCES);
7670 return xfs_ioc_fssetxattr(ip, filp, arg);
7671 case XFS_IOC_GETXFLAGS:
7672 return xfs_ioc_getxflags(ip, arg);
7673 case XFS_IOC_SETXFLAGS:
7674 + if (IS_BARRIER(inode)) {
7675 + vxwprintk_task(1, "messing with the barrier.");
7676 + return -XFS_ERROR(EACCES);
7678 return xfs_ioc_setxflags(ip, filp, arg);
7680 case XFS_IOC_FSSETDM: {
7681 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/linux-2.6/xfs_ioctl.h linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/linux-2.6/xfs_ioctl.h
7682 --- linux-3.0-rc5/fs/xfs/linux-2.6/xfs_ioctl.h 2010-07-07 18:31:54.000000000 +0200
7683 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/linux-2.6/xfs_ioctl.h 2011-06-10 22:11:24.000000000 +0200
7684 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7685 void __user *uhandle,
7690 + struct inode *inode,
7697 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/linux-2.6/xfs_iops.c linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/linux-2.6/xfs_iops.c
7698 --- linux-3.0-rc5/fs/xfs/linux-2.6/xfs_iops.c 2011-07-01 11:14:20.000000000 +0200
7699 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/linux-2.6/xfs_iops.c 2011-06-22 12:39:15.000000000 +0200
7701 #include "xfs_bmap_btree.h"
7702 #include "xfs_dinode.h"
7703 #include "xfs_inode.h"
7704 +#include "xfs_ioctl.h"
7705 #include "xfs_bmap.h"
7706 #include "xfs_rtalloc.h"
7707 #include "xfs_error.h"
7709 #include <linux/security.h>
7710 #include <linux/fiemap.h>
7711 #include <linux/slab.h>
7712 +#include <linux/vs_tag.h>
7715 * Bring the timestamps in the XFS inode uptodate.
7716 @@ -464,6 +466,7 @@ xfs_vn_getattr(
7717 stat->nlink = ip->i_d.di_nlink;
7718 stat->uid = ip->i_d.di_uid;
7719 stat->gid = ip->i_d.di_gid;
7720 + stat->tag = ip->i_d.di_tag;
7721 stat->ino = ip->i_ino;
7722 stat->atime = inode->i_atime;
7723 stat->mtime = inode->i_mtime;
7724 @@ -599,6 +602,7 @@ static const struct inode_operations xfs
7725 .removexattr = generic_removexattr,
7726 .listxattr = xfs_vn_listxattr,
7727 .fiemap = xfs_vn_fiemap,
7728 + .sync_flags = xfs_sync_flags,
7731 static const struct inode_operations xfs_dir_inode_operations = {
7732 @@ -624,6 +628,7 @@ static const struct inode_operations xfs
7733 .getxattr = generic_getxattr,
7734 .removexattr = generic_removexattr,
7735 .listxattr = xfs_vn_listxattr,
7736 + .sync_flags = xfs_sync_flags,
7739 static const struct inode_operations xfs_dir_ci_inode_operations = {
7740 @@ -673,6 +678,10 @@ xfs_diflags_to_iflags(
7741 inode->i_flags |= S_IMMUTABLE;
7743 inode->i_flags &= ~S_IMMUTABLE;
7744 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7745 + inode->i_flags |= S_IXUNLINK;
7747 + inode->i_flags &= ~S_IXUNLINK;
7748 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7749 inode->i_flags |= S_APPEND;
7751 @@ -685,6 +694,15 @@ xfs_diflags_to_iflags(
7752 inode->i_flags |= S_NOATIME;
7754 inode->i_flags &= ~S_NOATIME;
7756 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7757 + inode->i_vflags |= V_BARRIER;
7759 + inode->i_vflags &= ~V_BARRIER;
7760 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7761 + inode->i_vflags |= V_COW;
7763 + inode->i_vflags &= ~V_COW;
7767 @@ -716,6 +734,7 @@ xfs_setup_inode(
7768 inode->i_nlink = ip->i_d.di_nlink;
7769 inode->i_uid = ip->i_d.di_uid;
7770 inode->i_gid = ip->i_d.di_gid;
7771 + inode->i_tag = ip->i_d.di_tag;
7773 switch (inode->i_mode & S_IFMT) {
7775 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/linux-2.6/xfs_linux.h linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/linux-2.6/xfs_linux.h
7776 --- linux-3.0-rc5/fs/xfs/linux-2.6/xfs_linux.h 2011-07-01 11:14:20.000000000 +0200
7777 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/linux-2.6/xfs_linux.h 2011-06-10 22:11:24.000000000 +0200
7780 #define current_cpu() (raw_smp_processor_id())
7781 #define current_pid() (current->pid)
7782 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7783 #define current_test_flags(f) (current->flags & (f))
7784 #define current_set_flags_nested(sp, f) \
7785 (*(sp) = current->flags, current->flags |= (f))
7786 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/linux-2.6/xfs_super.c linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/linux-2.6/xfs_super.c
7787 --- linux-3.0-rc5/fs/xfs/linux-2.6/xfs_super.c 2011-07-01 11:14:20.000000000 +0200
7788 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/linux-2.6/xfs_super.c 2011-06-22 12:39:15.000000000 +0200
7789 @@ -114,6 +114,9 @@ mempool_t *xfs_ioend_pool;
7790 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7791 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7792 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7793 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7794 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7795 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7798 * Table driven mount option parser.
7799 @@ -122,10 +125,14 @@ mempool_t *xfs_ioend_pool;
7800 * in the future, too.
7803 + Opt_tag, Opt_notag,
7804 Opt_barrier, Opt_nobarrier, Opt_err
7807 static const match_table_t tokens = {
7808 + {Opt_tag, "tagxid"},
7810 + {Opt_notag, "notag"},
7811 {Opt_barrier, "barrier"},
7812 {Opt_nobarrier, "nobarrier"},
7814 @@ -373,6 +380,19 @@ xfs_parseargs(
7815 } else if (!strcmp(this_char, "irixsgid")) {
7817 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7818 +#ifndef CONFIG_TAGGING_NONE
7819 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7820 + mp->m_flags |= XFS_MOUNT_TAGGED;
7821 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7822 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7823 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7824 + mp->m_flags |= XFS_MOUNT_TAGGED;
7826 +#ifdef CONFIG_PROPAGATE
7827 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7829 + mp->m_flags |= XFS_MOUNT_TAGGED;
7832 xfs_warn(mp, "unknown mount option [%s].", this_char);
7834 @@ -1182,6 +1202,16 @@ xfs_fs_remount(
7836 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7839 + if (!(sb->s_flags & MS_TAGGED)) {
7841 + "XFS: %s: tagging not permitted on remount.\n",
7850 * Logically we would return an error here to prevent
7851 @@ -1397,6 +1427,9 @@ xfs_fs_fill_super(
7855 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7856 + sb->s_flags |= MS_TAGGED;
7859 * we must configure the block size in the superblock before we run the
7860 * full mount process as the mount process can lookup and cache inodes.
7861 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/xfs_dinode.h linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_dinode.h
7862 --- linux-3.0-rc5/fs/xfs/xfs_dinode.h 2011-01-05 21:50:28.000000000 +0100
7863 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_dinode.h 2011-06-10 22:11:24.000000000 +0200
7864 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
7865 __be32 di_nlink; /* number of links to file */
7866 __be16 di_projid_lo; /* lower part of owner's project id */
7867 __be16 di_projid_hi; /* higher part owner's project id */
7868 - __u8 di_pad[6]; /* unused, zeroed space */
7869 + __u8 di_pad[2]; /* unused, zeroed space */
7870 + __be16 di_tag; /* context tagging */
7871 + __be16 di_vflags; /* vserver specific flags */
7872 __be16 di_flushiter; /* incremented on flush */
7873 xfs_timestamp_t di_atime; /* time last accessed */
7874 xfs_timestamp_t di_mtime; /* time last modified */
7875 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
7876 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7877 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7878 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7879 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7881 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7882 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7883 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7884 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
7885 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7886 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7887 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7888 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7890 #ifdef CONFIG_XFS_RT
7891 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
7892 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
7893 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
7894 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
7895 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
7896 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
7897 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
7898 + XFS_DIFLAG_IXUNLINK)
7900 +#define XFS_DIVFLAG_BARRIER 0x01
7901 +#define XFS_DIVFLAG_COW 0x02
7903 #endif /* __XFS_DINODE_H__ */
7904 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/xfs_fs.h linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_fs.h
7905 --- linux-3.0-rc5/fs/xfs/xfs_fs.h 2011-01-05 21:50:28.000000000 +0100
7906 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_fs.h 2011-06-10 22:11:24.000000000 +0200
7907 @@ -67,6 +67,9 @@ struct fsxattr {
7908 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
7909 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
7910 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
7911 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
7912 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
7913 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
7914 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
7917 @@ -297,7 +300,8 @@ typedef struct xfs_bstat {
7918 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
7919 __u16 bs_forkoff; /* inode fork offset in bytes */
7920 __u16 bs_projid_hi; /* higher part of project id */
7921 - unsigned char bs_pad[10]; /* pad space, unused */
7922 + unsigned char bs_pad[8]; /* pad space, unused */
7923 + __u16 bs_tag; /* context tagging */
7924 __u32 bs_dmevmask; /* DMIG event mask */
7925 __u16 bs_dmstate; /* DMIG state info */
7926 __u16 bs_aextents; /* attribute number of extents */
7927 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/xfs_ialloc.c linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_ialloc.c
7928 --- linux-3.0-rc5/fs/xfs/xfs_ialloc.c 2011-05-22 16:17:54.000000000 +0200
7929 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_ialloc.c 2011-06-10 22:11:24.000000000 +0200
7931 #include "xfs_error.h"
7932 #include "xfs_bmap.h"
7936 * Allocation group level functions.
7938 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/xfs_inode.c linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_inode.c
7939 --- linux-3.0-rc5/fs/xfs/xfs_inode.c 2011-07-01 11:14:20.000000000 +0200
7940 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_inode.c 2011-06-10 22:11:24.000000000 +0200
7941 @@ -243,6 +243,7 @@ xfs_inotobp(
7945 +#include <linux/vs_tag.h>
7948 * This routine is called to map an inode to the buffer containing
7949 @@ -641,15 +642,25 @@ xfs_iformat_btree(
7951 xfs_dinode_from_disk(
7953 - xfs_dinode_t *from)
7954 + xfs_dinode_t *from,
7957 + uint32_t uid, gid, tag;
7959 to->di_magic = be16_to_cpu(from->di_magic);
7960 to->di_mode = be16_to_cpu(from->di_mode);
7961 to->di_version = from ->di_version;
7962 to->di_format = from->di_format;
7963 to->di_onlink = be16_to_cpu(from->di_onlink);
7964 - to->di_uid = be32_to_cpu(from->di_uid);
7965 - to->di_gid = be32_to_cpu(from->di_gid);
7967 + uid = be32_to_cpu(from->di_uid);
7968 + gid = be32_to_cpu(from->di_gid);
7969 + tag = be16_to_cpu(from->di_tag);
7971 + to->di_uid = INOTAG_UID(tagged, uid, gid);
7972 + to->di_gid = INOTAG_GID(tagged, uid, gid);
7973 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
7975 to->di_nlink = be32_to_cpu(from->di_nlink);
7976 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
7977 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
7978 @@ -671,21 +682,26 @@ xfs_dinode_from_disk(
7979 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
7980 to->di_dmstate = be16_to_cpu(from->di_dmstate);
7981 to->di_flags = be16_to_cpu(from->di_flags);
7982 + to->di_vflags = be16_to_cpu(from->di_vflags);
7983 to->di_gen = be32_to_cpu(from->di_gen);
7989 - xfs_icdinode_t *from)
7990 + xfs_icdinode_t *from,
7993 to->di_magic = cpu_to_be16(from->di_magic);
7994 to->di_mode = cpu_to_be16(from->di_mode);
7995 to->di_version = from ->di_version;
7996 to->di_format = from->di_format;
7997 to->di_onlink = cpu_to_be16(from->di_onlink);
7998 - to->di_uid = cpu_to_be32(from->di_uid);
7999 - to->di_gid = cpu_to_be32(from->di_gid);
8001 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8002 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8003 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8005 to->di_nlink = cpu_to_be32(from->di_nlink);
8006 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
8007 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
8008 @@ -707,12 +723,14 @@ xfs_dinode_to_disk(
8009 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8010 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8011 to->di_flags = cpu_to_be16(from->di_flags);
8012 + to->di_vflags = cpu_to_be16(from->di_vflags);
8013 to->di_gen = cpu_to_be32(from->di_gen);
8018 - __uint16_t di_flags)
8019 + __uint16_t di_flags,
8020 + __uint16_t di_vflags)
8024 @@ -723,6 +741,8 @@ _xfs_dic2xflags(
8025 flags |= XFS_XFLAG_PREALLOC;
8026 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8027 flags |= XFS_XFLAG_IMMUTABLE;
8028 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8029 + flags |= XFS_XFLAG_IXUNLINK;
8030 if (di_flags & XFS_DIFLAG_APPEND)
8031 flags |= XFS_XFLAG_APPEND;
8032 if (di_flags & XFS_DIFLAG_SYNC)
8033 @@ -747,6 +767,10 @@ _xfs_dic2xflags(
8034 flags |= XFS_XFLAG_FILESTREAM;
8037 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8038 + flags |= FS_BARRIER_FL;
8039 + if (di_vflags & XFS_DIVFLAG_COW)
8040 + flags |= FS_COW_FL;
8044 @@ -756,7 +780,7 @@ xfs_ip2xflags(
8046 xfs_icdinode_t *dic = &ip->i_d;
8048 - return _xfs_dic2xflags(dic->di_flags) |
8049 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8050 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8053 @@ -764,7 +788,8 @@ uint
8057 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8058 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8059 + be16_to_cpu(dip->di_vflags)) |
8060 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8063 @@ -797,7 +822,6 @@ xfs_iread(
8066 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8069 * If we got something that isn't an inode it means someone
8070 * (nfs or dmi) has a stale handle.
8071 @@ -820,7 +844,8 @@ xfs_iread(
8072 * Otherwise, just get the truly permanent information.
8075 - xfs_dinode_from_disk(&ip->i_d, dip);
8076 + xfs_dinode_from_disk(&ip->i_d, dip,
8077 + mp->m_flags & XFS_MOUNT_TAGGED);
8078 error = xfs_iformat(ip, dip);
8081 @@ -1015,6 +1040,7 @@ xfs_ialloc(
8082 ASSERT(ip->i_d.di_nlink == nlink);
8083 ip->i_d.di_uid = current_fsuid();
8084 ip->i_d.di_gid = current_fsgid();
8085 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
8086 xfs_set_projid(ip, prid);
8087 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8089 @@ -1075,6 +1101,7 @@ xfs_ialloc(
8090 ip->i_d.di_dmevmask = 0;
8091 ip->i_d.di_dmstate = 0;
8092 ip->i_d.di_flags = 0;
8093 + ip->i_d.di_vflags = 0;
8094 flags = XFS_ILOG_CORE;
8095 switch (mode & S_IFMT) {
8097 @@ -2108,6 +2135,7 @@ xfs_ifree(
8099 ip->i_d.di_mode = 0; /* mark incore inode as free */
8100 ip->i_d.di_flags = 0;
8101 + ip->i_d.di_vflags = 0;
8102 ip->i_d.di_dmevmask = 0;
8103 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8104 ip->i_df.if_ext_max =
8105 @@ -2987,7 +3015,8 @@ xfs_iflush_int(
8106 * because if the inode is dirty at all the core must
8109 - xfs_dinode_to_disk(dip, &ip->i_d);
8110 + xfs_dinode_to_disk(dip, &ip->i_d,
8111 + mp->m_flags & XFS_MOUNT_TAGGED);
8113 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8114 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8115 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/xfs_inode.h linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_inode.h
8116 --- linux-3.0-rc5/fs/xfs/xfs_inode.h 2011-07-01 11:14:20.000000000 +0200
8117 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_inode.h 2011-07-01 11:35:35.000000000 +0200
8118 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
8119 __uint32_t di_nlink; /* number of links to file */
8120 __uint16_t di_projid_lo; /* lower part of owner's project id */
8121 __uint16_t di_projid_hi; /* higher part of owner's project id */
8122 - __uint8_t di_pad[6]; /* unused, zeroed space */
8123 + __uint8_t di_pad[2]; /* unused, zeroed space */
8124 + __uint16_t di_tag; /* context tagging */
8125 + __uint16_t di_vflags; /* vserver specific flags */
8126 __uint16_t di_flushiter; /* incremented on flush */
8127 xfs_ictimestamp_t di_atime; /* time last accessed */
8128 xfs_ictimestamp_t di_mtime; /* time last modified */
8129 @@ -546,7 +548,7 @@ int xfs_itobp(struct xfs_mount *, struc
8130 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8131 struct xfs_inode *, uint);
8132 void xfs_dinode_to_disk(struct xfs_dinode *,
8133 - struct xfs_icdinode *);
8134 + struct xfs_icdinode *, int);
8135 void xfs_idestroy_fork(struct xfs_inode *, int);
8136 void xfs_idata_realloc(struct xfs_inode *, int, int);
8137 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8138 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/xfs_itable.c linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_itable.c
8139 --- linux-3.0-rc5/fs/xfs/xfs_itable.c 2011-05-22 16:17:54.000000000 +0200
8140 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_itable.c 2011-06-10 22:11:24.000000000 +0200
8141 @@ -98,6 +98,7 @@ xfs_bulkstat_one_int(
8142 buf->bs_mode = dic->di_mode;
8143 buf->bs_uid = dic->di_uid;
8144 buf->bs_gid = dic->di_gid;
8145 + buf->bs_tag = dic->di_tag;
8146 buf->bs_size = dic->di_size;
8149 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/xfs_log_recover.c linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_log_recover.c
8150 --- linux-3.0-rc5/fs/xfs/xfs_log_recover.c 2011-07-01 11:14:20.000000000 +0200
8151 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_log_recover.c 2011-06-10 22:11:24.000000000 +0200
8152 @@ -2343,7 +2343,8 @@ xlog_recover_inode_pass2(
8155 /* The core is in in-core format */
8156 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
8157 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
8158 + mp->m_flags & XFS_MOUNT_TAGGED);
8160 /* the rest is in on-disk format */
8161 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8162 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/xfs_mount.h linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_mount.h
8163 --- linux-3.0-rc5/fs/xfs/xfs_mount.h 2011-07-01 11:14:20.000000000 +0200
8164 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_mount.h 2011-06-10 22:11:24.000000000 +0200
8165 @@ -249,6 +249,7 @@ typedef struct xfs_mount {
8167 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8169 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8172 * Default minimum read and write sizes.
8173 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/xfs_vnodeops.c linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_vnodeops.c
8174 --- linux-3.0-rc5/fs/xfs/xfs_vnodeops.c 2011-07-01 11:14:20.000000000 +0200
8175 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_vnodeops.c 2011-07-01 11:35:35.000000000 +0200
8177 #include "xfs_vnodeops.h"
8178 #include "xfs_trace.h"
8182 +xfs_get_inode_flags(
8185 + struct inode *inode = VFS_I(ip);
8186 + unsigned int flags = inode->i_flags;
8187 + unsigned int vflags = inode->i_vflags;
8189 + if (flags & S_IMMUTABLE)
8190 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8192 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8193 + if (flags & S_IXUNLINK)
8194 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8196 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8198 + if (vflags & V_BARRIER)
8199 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8201 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8202 + if (vflags & V_COW)
8203 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8205 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8210 + struct inode *inode,
8214 + struct xfs_inode *ip = XFS_I(inode);
8215 + struct xfs_mount *mp = ip->i_mount;
8216 + struct xfs_trans *tp;
8217 + unsigned int lock_flags = 0;
8220 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8221 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8225 + xfs_ilock(ip, XFS_ILOCK_EXCL);
8227 + xfs_trans_ijoin(tp, ip);
8229 + inode->i_flags = flags;
8230 + inode->i_vflags = vflags;
8231 + xfs_get_inode_flags(ip);
8233 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8234 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
8236 + XFS_STATS_INC(xs_ig_attrchg);
8238 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8239 + xfs_trans_set_sync(tp);
8240 + code = xfs_trans_commit(tp, 0);
8241 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8245 + xfs_trans_cancel(tp, 0);
8247 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8254 struct xfs_inode *ip,
8255 @@ -65,6 +137,7 @@ xfs_setattr(
8256 uint commit_flags=0;
8257 uid_t uid=0, iuid=0;
8258 gid_t gid=0, igid=0;
8259 + tag_t tag=0, itag=0;
8260 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8261 int need_iolock = 1;
8263 @@ -147,7 +220,7 @@ xfs_setattr(
8265 * Change file ownership. Must be the owner or privileged.
8267 - if (mask & (ATTR_UID|ATTR_GID)) {
8268 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8270 * These IDs could have changed since we last looked at them.
8271 * But, we're assured that if the ownership did change
8272 @@ -156,8 +229,10 @@ xfs_setattr(
8274 iuid = ip->i_d.di_uid;
8275 igid = ip->i_d.di_gid;
8276 + itag = ip->i_d.di_tag;
8277 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8278 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8279 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8282 * Do a quota reservation only if uid/gid is actually
8283 @@ -165,7 +240,8 @@ xfs_setattr(
8285 if (XFS_IS_QUOTA_RUNNING(mp) &&
8286 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8287 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
8288 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8289 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
8291 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
8292 capable(CAP_FOWNER) ?
8293 @@ -329,7 +405,7 @@ xfs_setattr(
8295 * Change file ownership. Must be the owner or privileged.
8297 - if (mask & (ATTR_UID|ATTR_GID)) {
8298 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8300 * CAP_FSETID overrides the following restrictions:
8302 @@ -345,6 +421,10 @@ xfs_setattr(
8303 * Change the ownerships and register quota modifications
8304 * in the transaction.
8306 + if (itag != tag) {
8307 + ip->i_d.di_tag = tag;
8308 + inode->i_tag = tag;
8311 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
8312 ASSERT(mask & ATTR_UID);
8313 diff -NurpP --minimal linux-3.0-rc5/fs/xfs/xfs_vnodeops.h linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_vnodeops.h
8314 --- linux-3.0-rc5/fs/xfs/xfs_vnodeops.h 2011-05-22 16:17:54.000000000 +0200
8315 +++ linux-3.0-rc5-vs2.3.1-pre3/fs/xfs/xfs_vnodeops.h 2011-06-10 22:11:24.000000000 +0200
8316 @@ -13,6 +13,7 @@ struct xfs_inode;
8320 +int xfs_sync_xflags(struct xfs_inode *ip);
8321 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8322 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8323 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8324 diff -NurpP --minimal linux-3.0-rc5/include/asm-generic/tlb.h linux-3.0-rc5-vs2.3.1-pre3/include/asm-generic/tlb.h
8325 --- linux-3.0-rc5/include/asm-generic/tlb.h 2011-07-01 11:14:20.000000000 +0200
8326 +++ linux-3.0-rc5-vs2.3.1-pre3/include/asm-generic/tlb.h 2011-06-10 22:11:24.000000000 +0200
8328 #define _ASM_GENERIC__TLB_H
8330 #include <linux/swap.h>
8331 +#include <linux/vs_memory.h>
8332 #include <asm/pgalloc.h>
8333 #include <asm/tlbflush.h>
8335 diff -NurpP --minimal linux-3.0-rc5/include/linux/Kbuild linux-3.0-rc5-vs2.3.1-pre3/include/linux/Kbuild
8336 --- linux-3.0-rc5/include/linux/Kbuild 2011-07-01 11:14:20.000000000 +0200
8337 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/Kbuild 2011-06-10 22:11:24.000000000 +0200
8338 @@ -17,6 +17,7 @@ header-y += netfilter_bridge/
8339 header-y += netfilter_ipv4/
8340 header-y += netfilter_ipv6/
8342 +header-y += vserver/
8345 objhdr-y += version.h
8346 diff -NurpP --minimal linux-3.0-rc5/include/linux/capability.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/capability.h
8347 --- linux-3.0-rc5/include/linux/capability.h 2011-07-01 11:14:21.000000000 +0200
8348 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/capability.h 2011-06-10 22:11:24.000000000 +0200
8349 @@ -279,6 +279,7 @@ struct cpu_vfs_cap_data {
8350 arbitrary SCSI commands */
8351 /* Allow setting encryption key on loopback filesystem */
8352 /* Allow setting zone reclaim policy */
8353 +/* Allow the selection of a security context */
8355 #define CAP_SYS_ADMIN 21
8357 @@ -362,7 +363,12 @@ struct cpu_vfs_cap_data {
8359 #define CAP_LAST_CAP CAP_WAKE_ALARM
8361 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8362 +/* Allow context manipulations */
8363 +/* Allow changing context info on files */
8365 +#define CAP_CONTEXT 63
8367 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
8370 * Bit location of each capability (used by user-space library and kernel)
8371 diff -NurpP --minimal linux-3.0-rc5/include/linux/cred.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/cred.h
8372 --- linux-3.0-rc5/include/linux/cred.h 2011-07-01 11:14:21.000000000 +0200
8373 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/cred.h 2011-06-10 22:11:24.000000000 +0200
8374 @@ -156,6 +156,7 @@ extern void exit_creds(struct task_struc
8375 extern int copy_creds(struct task_struct *, unsigned long);
8376 extern const struct cred *get_task_cred(struct task_struct *);
8377 extern struct cred *cred_alloc_blank(void);
8378 +extern struct cred *__prepare_creds(const struct cred *);
8379 extern struct cred *prepare_creds(void);
8380 extern struct cred *prepare_exec_creds(void);
8381 extern int commit_creds(struct cred *);
8382 @@ -209,6 +210,31 @@ static inline void validate_process_cred
8386 +static inline void set_cred_subscribers(struct cred *cred, int n)
8388 +#ifdef CONFIG_DEBUG_CREDENTIALS
8389 + atomic_set(&cred->subscribers, n);
8393 +static inline int read_cred_subscribers(const struct cred *cred)
8395 +#ifdef CONFIG_DEBUG_CREDENTIALS
8396 + return atomic_read(&cred->subscribers);
8402 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
8404 +#ifdef CONFIG_DEBUG_CREDENTIALS
8405 + struct cred *cred = (struct cred *) _cred;
8407 + atomic_add(n, &cred->subscribers);
8412 * get_new_cred - Get a reference on a new set of credentials
8413 * @cred: The new credentials to reference
8414 diff -NurpP --minimal linux-3.0-rc5/include/linux/devpts_fs.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/devpts_fs.h
8415 --- linux-3.0-rc5/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8416 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/devpts_fs.h 2011-06-10 22:11:24.000000000 +0200
8417 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8422 #endif /* _LINUX_DEVPTS_FS_H */
8423 diff -NurpP --minimal linux-3.0-rc5/include/linux/ext2_fs.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/ext2_fs.h
8424 --- linux-3.0-rc5/include/linux/ext2_fs.h 2010-02-25 11:52:07.000000000 +0100
8425 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/ext2_fs.h 2011-06-10 22:11:24.000000000 +0200
8426 @@ -189,8 +189,12 @@ struct ext2_group_desc
8427 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8428 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8429 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8430 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8431 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8433 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8434 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8436 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8437 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8439 @@ -274,7 +278,8 @@ struct ext2_inode {
8441 __le16 l_i_uid_high; /* these 2 fields */
8442 __le16 l_i_gid_high; /* were reserved2[0] */
8443 - __u32 l_i_reserved2;
8444 + __le16 l_i_tag; /* Context Tag */
8445 + __u16 l_i_reserved2;
8448 __u8 h_i_frag; /* Fragment number */
8449 @@ -303,6 +308,7 @@ struct ext2_inode {
8450 #define i_gid_low i_gid
8451 #define i_uid_high osd2.linux2.l_i_uid_high
8452 #define i_gid_high osd2.linux2.l_i_gid_high
8453 +#define i_raw_tag osd2.linux2.l_i_tag
8454 #define i_reserved2 osd2.linux2.l_i_reserved2
8457 @@ -347,6 +353,7 @@ struct ext2_inode {
8458 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8459 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8460 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8461 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8464 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8465 diff -NurpP --minimal linux-3.0-rc5/include/linux/ext3_fs.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/ext3_fs.h
8466 --- linux-3.0-rc5/include/linux/ext3_fs.h 2011-07-01 11:14:21.000000000 +0200
8467 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/ext3_fs.h 2011-06-10 22:11:24.000000000 +0200
8468 @@ -173,10 +173,14 @@ struct ext3_group_desc
8469 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8470 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8471 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8472 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8473 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8475 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8476 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8477 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8478 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8480 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8481 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8483 /* Flags that should be inherited by new inodes from their parent. */
8484 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8485 @@ -312,7 +316,8 @@ struct ext3_inode {
8487 __le16 l_i_uid_high; /* these 2 fields */
8488 __le16 l_i_gid_high; /* were reserved2[0] */
8489 - __u32 l_i_reserved2;
8490 + __le16 l_i_tag; /* Context Tag */
8491 + __u16 l_i_reserved2;
8494 __u8 h_i_frag; /* Fragment number */
8495 @@ -343,6 +348,7 @@ struct ext3_inode {
8496 #define i_gid_low i_gid
8497 #define i_uid_high osd2.linux2.l_i_uid_high
8498 #define i_gid_high osd2.linux2.l_i_gid_high
8499 +#define i_raw_tag osd2.linux2.l_i_tag
8500 #define i_reserved2 osd2.linux2.l_i_reserved2
8502 #elif defined(__GNU__)
8503 @@ -405,6 +411,7 @@ struct ext3_inode {
8504 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8505 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8506 * error in ordered mode */
8507 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8509 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8510 #ifndef _LINUX_EXT2_FS_H
8511 @@ -919,6 +926,7 @@ extern void ext3_get_inode_flags(struct
8512 extern void ext3_set_aops(struct inode *inode);
8513 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8514 u64 start, u64 len);
8515 +extern int ext3_sync_flags(struct inode *, int, int);
8518 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8519 diff -NurpP --minimal linux-3.0-rc5/include/linux/fs.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/fs.h
8520 --- linux-3.0-rc5/include/linux/fs.h 2011-07-01 11:14:21.000000000 +0200
8521 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/fs.h 2011-07-01 11:35:35.000000000 +0200
8522 @@ -208,6 +208,9 @@ struct inodes_stat_t {
8523 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8524 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8525 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8526 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8527 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8528 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8529 #define MS_NOSEC (1<<28)
8530 #define MS_BORN (1<<29)
8531 #define MS_ACTIVE (1<<30)
8532 @@ -239,6 +242,14 @@ struct inodes_stat_t {
8533 #define S_IMA 1024 /* Inode has an associated IMA struct */
8534 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
8535 #define S_NOSEC 4096 /* no suid or xattr security attributes */
8536 +#define S_IXUNLINK 16384 /* Immutable Invert on unlink */
8538 +/* Linux-VServer related Inode flags */
8542 +#define V_BARRIER 4 /* Barrier for chroot() */
8543 +#define V_COW 8 /* Copy on Write */
8546 * Note that nosuid etc flags are inode-specific: setting some file-system
8547 @@ -261,12 +272,15 @@ struct inodes_stat_t {
8548 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8549 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8550 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8551 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8552 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8553 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8554 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8555 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8557 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8558 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8559 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8560 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8561 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8562 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8564 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8565 @@ -277,6 +291,16 @@ struct inodes_stat_t {
8566 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
8567 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
8569 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8571 +#ifdef CONFIG_VSERVER_COWBL
8572 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8573 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8575 +# define IS_COW(inode) (0)
8576 +# define IS_COW_LINK(inode) (0)
8579 /* the read-only stuff doesn't really belong here, but any other place is
8580 probably as bad and I don't want to create yet another include file. */
8582 @@ -362,11 +386,14 @@ struct inodes_stat_t {
8583 #define FS_EXTENT_FL 0x00080000 /* Extents */
8584 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8585 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
8586 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8587 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8589 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8590 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8592 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8593 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8595 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8596 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8598 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8599 #define SYNC_FILE_RANGE_WRITE 2
8600 @@ -447,6 +474,7 @@ typedef void (dio_iodone_t)(struct kiocb
8601 #define ATTR_KILL_PRIV (1 << 14)
8602 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8603 #define ATTR_TIMES_SET (1 << 16)
8604 +#define ATTR_TAG (1 << 17)
8607 * This is the Inode Attributes structure, used for notify_change(). It
8608 @@ -462,6 +490,7 @@ struct iattr {
8614 struct timespec ia_atime;
8615 struct timespec ia_mtime;
8616 @@ -475,6 +504,9 @@ struct iattr {
8617 struct file *ia_file;
8620 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8621 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8624 * Includes for diskquotas.
8626 @@ -740,11 +772,13 @@ struct inode {
8631 const struct inode_operations *i_op;
8632 struct super_block *i_sb;
8634 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
8635 - unsigned int i_flags;
8636 + unsigned short i_flags;
8637 + unsigned short i_vflags;
8638 unsigned long i_state;
8639 #ifdef CONFIG_SECURITY
8641 @@ -766,6 +800,7 @@ struct inode {
8643 unsigned int i_nlink;
8646 unsigned int i_blkbits;
8649 @@ -890,12 +925,12 @@ static inline void i_size_write(struct i
8651 static inline unsigned iminor(const struct inode *inode)
8653 - return MINOR(inode->i_rdev);
8654 + return MINOR(inode->i_mdev);
8657 static inline unsigned imajor(const struct inode *inode)
8659 - return MAJOR(inode->i_rdev);
8660 + return MAJOR(inode->i_mdev);
8663 extern struct block_device *I_BDEV(struct inode *inode);
8664 @@ -957,6 +992,7 @@ struct file {
8666 struct fown_struct f_owner;
8667 const struct cred *f_cred;
8669 struct file_ra_state f_ra;
8672 @@ -1101,6 +1137,7 @@ struct file_lock {
8673 struct file *fl_file;
8678 struct fasync_struct * fl_fasync; /* for lease break notifications */
8679 unsigned long fl_break_time; /* for nonblocking lease breaks */
8680 @@ -1600,6 +1637,7 @@ struct inode_operations {
8681 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8682 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8683 int (*removexattr) (struct dentry *, const char *);
8684 + int (*sync_flags) (struct inode *, int, int);
8685 void (*truncate_range)(struct inode *, loff_t, loff_t);
8686 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8688 @@ -1618,6 +1656,7 @@ extern ssize_t vfs_readv(struct file *,
8689 unsigned long, loff_t *);
8690 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8691 unsigned long, loff_t *);
8692 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8694 struct super_operations {
8695 struct inode *(*alloc_inode)(struct super_block *sb);
8696 @@ -2437,6 +2476,7 @@ extern int dcache_dir_open(struct inode
8697 extern int dcache_dir_close(struct inode *, struct file *);
8698 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8699 extern int dcache_readdir(struct file *, void *, filldir_t);
8700 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8701 extern int simple_setattr(struct dentry *, struct iattr *);
8702 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8703 extern int simple_statfs(struct dentry *, struct kstatfs *);
8704 diff -NurpP --minimal linux-3.0-rc5/include/linux/gfs2_ondisk.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/gfs2_ondisk.h
8705 --- linux-3.0-rc5/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
8706 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/gfs2_ondisk.h 2011-06-10 22:11:24.000000000 +0200
8707 @@ -211,6 +211,9 @@ enum {
8711 + gfs2fl_IXUnlink = 16,
8712 + gfs2fl_Barrier = 17,
8714 gfs2fl_TruncInProg = 29,
8715 gfs2fl_InheritDirectio = 30,
8716 gfs2fl_InheritJdata = 31,
8717 @@ -227,6 +230,9 @@ enum {
8718 #define GFS2_DIF_NOATIME 0x00000080
8719 #define GFS2_DIF_SYNC 0x00000100
8720 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8721 +#define GFS2_DIF_IXUNLINK 0x00010000
8722 +#define GFS2_DIF_BARRIER 0x00020000
8723 +#define GFS2_DIF_COW 0x00040000
8724 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8725 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8726 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8727 diff -NurpP --minimal linux-3.0-rc5/include/linux/if_tun.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/if_tun.h
8728 --- linux-3.0-rc5/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8729 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/if_tun.h 2011-06-10 22:11:24.000000000 +0200
8731 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8732 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8733 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8734 +#define TUNSETNID _IOW('T', 217, int)
8736 /* TUNSETIFF ifr flags */
8737 #define IFF_TUN 0x0001
8738 diff -NurpP --minimal linux-3.0-rc5/include/linux/init_task.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/init_task.h
8739 --- linux-3.0-rc5/include/linux/init_task.h 2011-07-01 11:14:21.000000000 +0200
8740 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/init_task.h 2011-06-10 22:11:24.000000000 +0200
8741 @@ -193,6 +193,10 @@ extern struct cred init_cred;
8743 INIT_TRACE_RECURSION \
8744 INIT_TASK_RCU_PREEMPT(tsk) \
8746 + .vx_info = NULL, \
8748 + .nx_info = NULL, \
8752 diff -NurpP --minimal linux-3.0-rc5/include/linux/ipc.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/ipc.h
8753 --- linux-3.0-rc5/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8754 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/ipc.h 2011-06-10 22:11:24.000000000 +0200
8755 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8763 diff -NurpP --minimal linux-3.0-rc5/include/linux/ipc_namespace.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/ipc_namespace.h
8764 --- linux-3.0-rc5/include/linux/ipc_namespace.h 2011-05-22 16:17:55.000000000 +0200
8765 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/ipc_namespace.h 2011-06-13 14:09:44.000000000 +0200
8766 @@ -94,7 +94,8 @@ static inline int mq_init_ns(struct ipc_
8768 #if defined(CONFIG_IPC_NS)
8769 extern struct ipc_namespace *copy_ipcs(unsigned long flags,
8770 - struct task_struct *tsk);
8771 + struct ipc_namespace *old_ns,
8772 + struct user_namespace *user_ns);
8773 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8776 @@ -105,12 +106,13 @@ static inline struct ipc_namespace *get_
8777 extern void put_ipc_ns(struct ipc_namespace *ns);
8779 static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
8780 - struct task_struct *tsk)
8781 + struct ipc_namespace *old_ns,
8782 + struct user_namespace *user_ns)
8784 if (flags & CLONE_NEWIPC)
8785 return ERR_PTR(-EINVAL);
8787 - return tsk->nsproxy->ipc_ns;
8791 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8792 diff -NurpP --minimal linux-3.0-rc5/include/linux/loop.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/loop.h
8793 --- linux-3.0-rc5/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
8794 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/loop.h 2011-06-10 22:11:24.000000000 +0200
8795 @@ -45,6 +45,7 @@ struct loop_device {
8796 struct loop_func_table *lo_encryption;
8798 uid_t lo_key_owner; /* Who set the key */
8800 int (*ioctl)(struct loop_device *, int cmd,
8803 diff -NurpP --minimal linux-3.0-rc5/include/linux/magic.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/magic.h
8804 --- linux-3.0-rc5/include/linux/magic.h 2011-05-22 16:17:55.000000000 +0200
8805 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/magic.h 2011-06-10 22:11:24.000000000 +0200
8808 #define ADFS_SUPER_MAGIC 0xadf5
8809 #define AFFS_SUPER_MAGIC 0xadff
8810 -#define AFS_SUPER_MAGIC 0x5346414F
8811 +#define AFS_SUPER_MAGIC 0x5346414F
8812 #define AUTOFS_SUPER_MAGIC 0x0187
8813 #define CODA_SUPER_MAGIC 0x73757245
8814 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8816 #define NFS_SUPER_MAGIC 0x6969
8817 #define OPENPROM_SUPER_MAGIC 0x9fa1
8818 #define PROC_SUPER_MAGIC 0x9fa0
8819 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8820 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8822 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8823 diff -NurpP --minimal linux-3.0-rc5/include/linux/major.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/major.h
8824 --- linux-3.0-rc5/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8825 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/major.h 2011-06-10 22:11:24.000000000 +0200
8827 #define HD_MAJOR IDE0_MAJOR
8828 #define PTY_SLAVE_MAJOR 3
8830 +#define VROOT_MAJOR 4
8831 #define TTYAUX_MAJOR 5
8834 diff -NurpP --minimal linux-3.0-rc5/include/linux/memcontrol.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/memcontrol.h
8835 --- linux-3.0-rc5/include/linux/memcontrol.h 2011-07-01 11:14:21.000000000 +0200
8836 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/memcontrol.h 2011-06-22 12:39:15.000000000 +0200
8837 @@ -86,6 +86,13 @@ extern struct mem_cgroup *try_get_mem_cg
8838 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8839 extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
8841 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8842 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8844 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8845 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8846 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8849 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8851 diff -NurpP --minimal linux-3.0-rc5/include/linux/mm_types.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/mm_types.h
8852 --- linux-3.0-rc5/include/linux/mm_types.h 2011-07-01 11:14:21.000000000 +0200
8853 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/mm_types.h 2011-06-10 22:11:24.000000000 +0200
8854 @@ -268,6 +268,7 @@ struct mm_struct {
8856 /* Architecture-specific MM context */
8857 mm_context_t context;
8858 + struct vx_info *mm_vx_info;
8860 /* Swap token stuff */
8862 diff -NurpP --minimal linux-3.0-rc5/include/linux/mmzone.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/mmzone.h
8863 --- linux-3.0-rc5/include/linux/mmzone.h 2011-07-01 11:14:21.000000000 +0200
8864 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/mmzone.h 2011-07-01 11:35:35.000000000 +0200
8865 @@ -654,6 +654,13 @@ typedef struct pglist_data {
8866 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8869 +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
8871 +#define node_end_pfn(nid) ({\
8872 + pg_data_t *__pgdat = NODE_DATA(nid);\
8873 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8876 #include <linux/memory_hotplug.h>
8878 extern struct mutex zonelists_mutex;
8879 diff -NurpP --minimal linux-3.0-rc5/include/linux/mount.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/mount.h
8880 --- linux-3.0-rc5/include/linux/mount.h 2011-03-15 18:07:39.000000000 +0100
8881 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/mount.h 2011-06-10 22:11:24.000000000 +0200
8882 @@ -52,6 +52,9 @@ struct mnt_pcp {
8886 +#define MNT_TAGID 0x10000
8887 +#define MNT_NOTAG 0x20000
8890 struct list_head mnt_hash;
8891 struct vfsmount *mnt_parent; /* fs we are mounted on */
8892 @@ -86,6 +89,7 @@ struct vfsmount {
8893 int mnt_expiry_mark; /* true if marked for expiry */
8896 + tag_t mnt_tag; /* tagging used for vfsmount */
8899 struct file; /* forward dec */
8900 diff -NurpP --minimal linux-3.0-rc5/include/linux/net.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/net.h
8901 --- linux-3.0-rc5/include/linux/net.h 2011-07-01 11:14:21.000000000 +0200
8902 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/net.h 2011-06-10 22:11:24.000000000 +0200
8903 @@ -72,6 +72,7 @@ struct net;
8904 #define SOCK_NOSPACE 2
8905 #define SOCK_PASSCRED 3
8906 #define SOCK_PASSSEC 4
8907 +#define SOCK_USER_SOCKET 5
8909 #ifndef ARCH_HAS_SOCKET_TYPES
8911 diff -NurpP --minimal linux-3.0-rc5/include/linux/nfs_mount.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/nfs_mount.h
8912 --- linux-3.0-rc5/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
8913 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/nfs_mount.h 2011-06-10 22:11:24.000000000 +0200
8914 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8915 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8916 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8917 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8918 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8919 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8920 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8922 /* The following are for internal use only */
8923 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8924 diff -NurpP --minimal linux-3.0-rc5/include/linux/nsproxy.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/nsproxy.h
8925 --- linux-3.0-rc5/include/linux/nsproxy.h 2011-07-01 11:14:21.000000000 +0200
8926 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/nsproxy.h 2011-06-10 22:11:24.000000000 +0200
8929 #include <linux/spinlock.h>
8930 #include <linux/sched.h>
8931 +#include <linux/vserver/debug.h>
8933 struct mnt_namespace;
8934 struct uts_namespace;
8935 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
8938 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8939 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8940 void exit_task_namespaces(struct task_struct *tsk);
8941 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8942 void free_nsproxy(struct nsproxy *ns);
8943 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
8944 struct fs_struct *);
8946 -static inline void put_nsproxy(struct nsproxy *ns)
8947 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8949 +static inline void __get_nsproxy(struct nsproxy *ns,
8950 + const char *_file, int _line)
8952 - if (atomic_dec_and_test(&ns->count)) {
8955 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8956 + ns, atomic_read(&ns->count), _file, _line);
8957 + atomic_inc(&ns->count);
8960 -static inline void get_nsproxy(struct nsproxy *ns)
8961 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8963 +static inline void __put_nsproxy(struct nsproxy *ns,
8964 + const char *_file, int _line)
8966 - atomic_inc(&ns->count);
8967 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8968 + ns, atomic_read(&ns->count), _file, _line);
8969 + if (atomic_dec_and_test(&ns->count)) {
8975 diff -NurpP --minimal linux-3.0-rc5/include/linux/pid.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/pid.h
8976 --- linux-3.0-rc5/include/linux/pid.h 2011-07-01 11:14:21.000000000 +0200
8977 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/pid.h 2011-06-10 22:11:24.000000000 +0200
8978 @@ -8,7 +8,8 @@ enum pid_type
8988 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
8991 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8992 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8993 pid_t pid_vnr(struct pid *pid);
8995 #define do_each_pid_task(pid, type, task) \
8996 diff -NurpP --minimal linux-3.0-rc5/include/linux/proc_fs.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/proc_fs.h
8997 --- linux-3.0-rc5/include/linux/proc_fs.h 2011-07-01 11:14:21.000000000 +0200
8998 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/proc_fs.h 2011-06-10 22:11:24.000000000 +0200
8999 @@ -56,6 +56,7 @@ struct proc_dir_entry {
9005 const struct inode_operations *proc_iops;
9007 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
9008 extern const struct proc_ns_operations utsns_operations;
9009 extern const struct proc_ns_operations ipcns_operations;
9015 int (*proc_get_link)(struct inode *, struct path *);
9016 int (*proc_read)(struct task_struct *task, char *page);
9017 int (*proc_show)(struct seq_file *m,
9018 struct pid_namespace *ns, struct pid *pid,
9019 struct task_struct *task);
9020 + int (*proc_vs_read)(char *page);
9021 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9022 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9025 struct ctl_table_header;
9026 @@ -265,6 +272,7 @@ struct ctl_table;
9033 struct proc_dir_entry *pde;
9034 diff -NurpP --minimal linux-3.0-rc5/include/linux/quotaops.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/quotaops.h
9035 --- linux-3.0-rc5/include/linux/quotaops.h 2011-05-22 16:17:57.000000000 +0200
9036 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/quotaops.h 2011-06-10 22:11:24.000000000 +0200
9038 #define _LINUX_QUOTAOPS_
9040 #include <linux/fs.h>
9041 +#include <linux/vs_dlimit.h>
9043 #define DQUOT_SPACE_WARN 0x1
9044 #define DQUOT_SPACE_RESERVE 0x2
9045 @@ -204,11 +205,12 @@ static inline void dquot_drop(struct ino
9047 static inline int dquot_alloc_inode(const struct inode *inode)
9050 + return dl_alloc_inode(inode);
9053 static inline void dquot_free_inode(const struct inode *inode)
9055 + dl_free_inode(inode);
9058 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
9059 @@ -219,6 +221,10 @@ static inline int dquot_transfer(struct
9060 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
9065 + if ((ret = dl_alloc_space(inode, number)))
9067 if (!(flags & DQUOT_SPACE_RESERVE))
9068 inode_add_bytes(inode, number);
9070 @@ -229,6 +235,7 @@ static inline void __dquot_free_space(st
9072 if (!(flags & DQUOT_SPACE_RESERVE))
9073 inode_sub_bytes(inode, number);
9074 + dl_free_space(inode, number);
9077 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
9078 diff -NurpP --minimal linux-3.0-rc5/include/linux/reboot.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/reboot.h
9079 --- linux-3.0-rc5/include/linux/reboot.h 2010-07-07 18:31:56.000000000 +0200
9080 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/reboot.h 2011-06-10 22:11:24.000000000 +0200
9082 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
9083 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
9084 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
9085 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
9089 diff -NurpP --minimal linux-3.0-rc5/include/linux/reiserfs_fs.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/reiserfs_fs.h
9090 --- linux-3.0-rc5/include/linux/reiserfs_fs.h 2011-05-22 16:17:58.000000000 +0200
9091 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/reiserfs_fs.h 2011-06-10 22:11:24.000000000 +0200
9092 @@ -976,6 +976,11 @@ struct stat_data_v1 {
9093 #define REISERFS_COMPR_FL FS_COMPR_FL
9094 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9096 +/* unfortunately reiserfs sdattr is only 16 bit */
9097 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9098 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9099 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9101 /* persistent flags that file inherits from the parent directory */
9102 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9103 REISERFS_SYNC_FL | \
9104 @@ -985,6 +990,9 @@ struct stat_data_v1 {
9105 REISERFS_COMPR_FL | \
9106 REISERFS_NOTAIL_FL )
9108 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9109 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9111 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9114 @@ -2073,6 +2081,7 @@ static inline void reiserfs_update_sd(st
9115 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9116 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9117 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9118 +int reiserfs_sync_flags(struct inode *inode, int, int);
9120 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
9122 diff -NurpP --minimal linux-3.0-rc5/include/linux/reiserfs_fs_sb.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/reiserfs_fs_sb.h
9123 --- linux-3.0-rc5/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
9124 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/reiserfs_fs_sb.h 2011-06-10 22:11:24.000000000 +0200
9125 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
9126 REISERFS_EXPOSE_PRIVROOT,
9127 REISERFS_BARRIER_NONE,
9128 REISERFS_BARRIER_FLUSH,
9131 /* Actions on error */
9132 REISERFS_ERROR_PANIC,
9133 diff -NurpP --minimal linux-3.0-rc5/include/linux/sched.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/sched.h
9134 --- linux-3.0-rc5/include/linux/sched.h 2011-07-01 11:14:21.000000000 +0200
9135 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/sched.h 2011-06-15 02:40:14.000000000 +0200
9136 @@ -1397,6 +1397,14 @@ struct task_struct {
9140 +/* vserver context data */
9141 + struct vx_info *vx_info;
9142 + struct nx_info *nx_info;
9148 /* Thread group tracking */
9151 @@ -1640,6 +1648,11 @@ struct pid_namespace;
9152 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9153 struct pid_namespace *ns);
9155 +#include <linux/vserver/base.h>
9156 +#include <linux/vserver/context.h>
9157 +#include <linux/vserver/debug.h>
9158 +#include <linux/vserver/pid.h>
9160 static inline pid_t task_pid_nr(struct task_struct *tsk)
9163 @@ -1653,7 +1666,8 @@ static inline pid_t task_pid_nr_ns(struc
9165 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9167 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9168 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9169 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
9173 @@ -1666,7 +1680,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9175 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9177 - return pid_vnr(task_tgid(tsk));
9178 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9182 diff -NurpP --minimal linux-3.0-rc5/include/linux/shmem_fs.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/shmem_fs.h
9183 --- linux-3.0-rc5/include/linux/shmem_fs.h 2011-07-01 11:14:21.000000000 +0200
9184 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/shmem_fs.h 2011-07-01 11:35:35.000000000 +0200
9187 #define SHMEM_SYMLINK_INLINE_LEN (SHMEM_NR_DIRECT * sizeof(swp_entry_t))
9189 +#define TMPFS_SUPER_MAGIC 0x01021994
9192 struct shmem_inode_info {
9194 unsigned long flags;
9195 diff -NurpP --minimal linux-3.0-rc5/include/linux/stat.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/stat.h
9196 --- linux-3.0-rc5/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9197 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/stat.h 2011-06-10 22:11:24.000000000 +0200
9198 @@ -66,6 +66,7 @@ struct kstat {
9205 struct timespec atime;
9206 diff -NurpP --minimal linux-3.0-rc5/include/linux/sunrpc/auth.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/sunrpc/auth.h
9207 --- linux-3.0-rc5/include/linux/sunrpc/auth.h 2011-03-15 18:07:39.000000000 +0100
9208 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/sunrpc/auth.h 2011-06-10 22:11:24.000000000 +0200
9214 struct group_info *group_info;
9215 unsigned char machine_cred : 1;
9217 diff -NurpP --minimal linux-3.0-rc5/include/linux/sunrpc/clnt.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/sunrpc/clnt.h
9218 --- linux-3.0-rc5/include/linux/sunrpc/clnt.h 2011-05-22 16:17:58.000000000 +0200
9219 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/sunrpc/clnt.h 2011-06-10 22:11:24.000000000 +0200
9220 @@ -49,7 +49,8 @@ struct rpc_clnt {
9221 unsigned int cl_softrtry : 1,/* soft timeouts */
9222 cl_discrtry : 1,/* disconnect before retry */
9223 cl_autobind : 1,/* use getport() */
9224 - cl_chatty : 1;/* be verbose */
9225 + cl_chatty : 1,/* be verbose */
9226 + cl_tag : 1;/* context tagging */
9228 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9229 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9230 diff -NurpP --minimal linux-3.0-rc5/include/linux/syscalls.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/syscalls.h
9231 --- linux-3.0-rc5/include/linux/syscalls.h 2011-07-01 11:14:22.000000000 +0200
9232 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/syscalls.h 2011-06-10 22:11:24.000000000 +0200
9233 @@ -483,6 +483,8 @@ asmlinkage long sys_symlink(const char _
9234 asmlinkage long sys_unlink(const char __user *pathname);
9235 asmlinkage long sys_rename(const char __user *oldname,
9236 const char __user *newname);
9237 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9239 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9240 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9242 diff -NurpP --minimal linux-3.0-rc5/include/linux/sysctl.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/sysctl.h
9243 --- linux-3.0-rc5/include/linux/sysctl.h 2011-03-15 18:07:40.000000000 +0100
9244 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/sysctl.h 2011-06-10 22:11:24.000000000 +0200
9245 @@ -60,6 +60,7 @@ enum
9246 CTL_ABI=9, /* Binary emulation */
9247 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9248 CTL_ARLAN=254, /* arlan wireless driver */
9249 + CTL_VSERVER=4242, /* Linux-VServer debug */
9250 CTL_S390DBF=5677, /* s390 debug */
9251 CTL_SUNRPC=7249, /* sunrpc debug */
9252 CTL_PM=9899, /* frv power management */
9253 @@ -94,6 +95,7 @@ enum
9255 KERN_PANIC=15, /* int: panic timeout */
9256 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9257 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9259 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9260 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9261 diff -NurpP --minimal linux-3.0-rc5/include/linux/sysfs.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/sysfs.h
9262 --- linux-3.0-rc5/include/linux/sysfs.h 2011-07-01 11:14:22.000000000 +0200
9263 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/sysfs.h 2011-06-22 12:39:15.000000000 +0200
9265 #include <linux/kobject_ns.h>
9266 #include <asm/atomic.h>
9268 +#define SYSFS_SUPER_MAGIC 0x62656572
9273 diff -NurpP --minimal linux-3.0-rc5/include/linux/time.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/time.h
9274 --- linux-3.0-rc5/include/linux/time.h 2011-07-01 11:14:22.000000000 +0200
9275 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/time.h 2011-06-10 22:11:24.000000000 +0200
9276 @@ -256,6 +256,9 @@ static __always_inline void timespec_add
9277 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9281 +#include <linux/vs_time.h>
9283 #endif /* __KERNEL__ */
9285 #define NFDBITS __NFDBITS
9286 diff -NurpP --minimal linux-3.0-rc5/include/linux/types.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/types.h
9287 --- linux-3.0-rc5/include/linux/types.h 2011-05-22 16:17:58.000000000 +0200
9288 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/types.h 2011-06-10 22:11:24.000000000 +0200
9289 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
9290 typedef __kernel_gid32_t gid_t;
9291 typedef __kernel_uid16_t uid16_t;
9292 typedef __kernel_gid16_t gid16_t;
9293 +typedef unsigned int xid_t;
9294 +typedef unsigned int nid_t;
9295 +typedef unsigned int tag_t;
9297 typedef unsigned long uintptr_t;
9299 diff -NurpP --minimal linux-3.0-rc5/include/linux/utsname.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/utsname.h
9300 --- linux-3.0-rc5/include/linux/utsname.h 2011-05-22 16:17:58.000000000 +0200
9301 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/utsname.h 2011-06-13 14:36:48.000000000 +0200
9302 @@ -54,7 +54,8 @@ static inline void get_uts_ns(struct uts
9305 extern struct uts_namespace *copy_utsname(unsigned long flags,
9306 - struct task_struct *tsk);
9307 + struct uts_namespace *old_ns,
9308 + struct user_namespace *user_ns);
9309 extern void free_uts_ns(struct kref *kref);
9311 static inline void put_uts_ns(struct uts_namespace *ns)
9312 @@ -71,12 +72,13 @@ static inline void put_uts_ns(struct uts
9315 static inline struct uts_namespace *copy_utsname(unsigned long flags,
9316 - struct task_struct *tsk)
9317 + struct uts_namespace *old_ns,
9318 + struct user_namespace *user_ns)
9320 if (flags & CLONE_NEWUTS)
9321 return ERR_PTR(-EINVAL);
9323 - return tsk->nsproxy->uts_ns;
9328 diff -NurpP --minimal linux-3.0-rc5/include/linux/vroot.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vroot.h
9329 --- linux-3.0-rc5/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9330 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vroot.h 2011-06-10 22:11:24.000000000 +0200
9334 + * include/linux/vroot.h
9336 + * written by Herbert Pötzl, 9/11/2002
9337 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9339 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9340 + * Redistribution of this file is permitted under the
9341 + * GNU General Public License.
9344 +#ifndef _LINUX_VROOT_H
9345 +#define _LINUX_VROOT_H
9350 +/* Possible states of device */
9356 +struct vroot_device {
9360 + struct semaphore vr_ctl_mutex;
9361 + struct block_device *vr_device;
9366 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9368 +extern int register_vroot_grb(vroot_grb_func *);
9369 +extern int unregister_vroot_grb(vroot_grb_func *);
9371 +#endif /* __KERNEL__ */
9373 +#define MAX_VROOT_DEFAULT 8
9376 + * IOCTL commands --- we will commandeer 0x56 ('V')
9379 +#define VROOT_SET_DEV 0x5600
9380 +#define VROOT_CLR_DEV 0x5601
9382 +#endif /* _LINUX_VROOT_H */
9383 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_base.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_base.h
9384 --- linux-3.0-rc5/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9385 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_base.h 2011-06-10 22:11:24.000000000 +0200
9390 +#include "vserver/base.h"
9391 +#include "vserver/check.h"
9392 +#include "vserver/debug.h"
9395 +#warning duplicate inclusion
9397 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_context.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_context.h
9398 --- linux-3.0-rc5/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9399 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_context.h 2011-06-10 22:11:24.000000000 +0200
9401 +#ifndef _VS_CONTEXT_H
9402 +#define _VS_CONTEXT_H
9404 +#include "vserver/base.h"
9405 +#include "vserver/check.h"
9406 +#include "vserver/context.h"
9407 +#include "vserver/history.h"
9408 +#include "vserver/debug.h"
9410 +#include <linux/sched.h>
9413 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9415 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9416 + const char *_file, int _line, void *_here)
9421 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9422 + vxi, vxi ? vxi->vx_id : 0,
9423 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9425 + __vxh_get_vx_info(vxi, _here);
9427 + atomic_inc(&vxi->vx_usecnt);
9432 +extern void free_vx_info(struct vx_info *);
9434 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9436 +static inline void __put_vx_info(struct vx_info *vxi,
9437 + const char *_file, int _line, void *_here)
9442 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9443 + vxi, vxi ? vxi->vx_id : 0,
9444 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9446 + __vxh_put_vx_info(vxi, _here);
9448 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9449 + free_vx_info(vxi);
9453 +#define init_vx_info(p, i) \
9454 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9456 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9457 + const char *_file, int _line, void *_here)
9460 + vxlprintk(VXD_CBIT(xid, 3),
9461 + "init_vx_info(%p[#%d.%d])",
9462 + vxi, vxi ? vxi->vx_id : 0,
9463 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9465 + __vxh_init_vx_info(vxi, vxp, _here);
9467 + atomic_inc(&vxi->vx_usecnt);
9473 +#define set_vx_info(p, i) \
9474 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9476 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9477 + const char *_file, int _line, void *_here)
9479 + struct vx_info *vxo;
9484 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9485 + vxi, vxi ? vxi->vx_id : 0,
9486 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9488 + __vxh_set_vx_info(vxi, vxp, _here);
9490 + atomic_inc(&vxi->vx_usecnt);
9491 + vxo = xchg(vxp, vxi);
9496 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9498 +static inline void __clr_vx_info(struct vx_info **vxp,
9499 + const char *_file, int _line, void *_here)
9501 + struct vx_info *vxo;
9503 + vxo = xchg(vxp, NULL);
9507 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9508 + vxo, vxo ? vxo->vx_id : 0,
9509 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9511 + __vxh_clr_vx_info(vxo, vxp, _here);
9513 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9514 + free_vx_info(vxo);
9518 +#define claim_vx_info(v, p) \
9519 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9521 +static inline void __claim_vx_info(struct vx_info *vxi,
9522 + struct task_struct *task,
9523 + const char *_file, int _line, void *_here)
9525 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9526 + vxi, vxi ? vxi->vx_id : 0,
9527 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9528 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9529 + task, _file, _line);
9530 + __vxh_claim_vx_info(vxi, task, _here);
9532 + atomic_inc(&vxi->vx_tasks);
9536 +extern void unhash_vx_info(struct vx_info *);
9538 +#define release_vx_info(v, p) \
9539 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9541 +static inline void __release_vx_info(struct vx_info *vxi,
9542 + struct task_struct *task,
9543 + const char *_file, int _line, void *_here)
9545 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9546 + vxi, vxi ? vxi->vx_id : 0,
9547 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9548 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9549 + task, _file, _line);
9550 + __vxh_release_vx_info(vxi, task, _here);
9554 + if (atomic_dec_and_test(&vxi->vx_tasks))
9555 + unhash_vx_info(vxi);
9559 +#define task_get_vx_info(p) \
9560 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9562 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9563 + const char *_file, int _line, void *_here)
9565 + struct vx_info *vxi;
9568 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9570 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9576 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9578 + if (waitqueue_active(&vxi->vx_wait))
9579 + wake_up_interruptible(&vxi->vx_wait);
9583 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9585 +static inline void __enter_vx_info(struct vx_info *vxi,
9586 + struct vx_info_save *vxis, const char *_file, int _line)
9588 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9589 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9590 + current->xid, current->vx_info, _file, _line);
9591 + vxis->vxi = xchg(¤t->vx_info, vxi);
9592 + vxis->xid = current->xid;
9593 + current->xid = vxi ? vxi->vx_id : 0;
9596 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9598 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9599 + const char *_file, int _line)
9601 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9602 + vxis, vxis->xid, vxis->vxi, current,
9603 + current->xid, current->vx_info, _file, _line);
9604 + (void)xchg(¤t->vx_info, vxis->vxi);
9605 + current->xid = vxis->xid;
9609 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9611 + vxis->vxi = xchg(¤t->vx_info, NULL);
9612 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9615 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9617 + (void)xchg(¤t->xid, vxis->xid);
9618 + (void)xchg(¤t->vx_info, vxis->vxi);
9621 +#define task_is_init(p) \
9622 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9624 +static inline int __task_is_init(struct task_struct *p,
9625 + const char *_file, int _line, void *_here)
9627 + int is_init = is_global_init(p);
9631 + is_init = p->vx_info->vx_initpid == p->pid;
9636 +extern void exit_vx_info(struct task_struct *, int);
9637 +extern void exit_vx_info_early(struct task_struct *, int);
9641 +#warning duplicate inclusion
9643 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_cowbl.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_cowbl.h
9644 --- linux-3.0-rc5/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9645 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_cowbl.h 2011-06-10 22:11:24.000000000 +0200
9647 +#ifndef _VS_COWBL_H
9648 +#define _VS_COWBL_H
9650 +#include <linux/fs.h>
9651 +#include <linux/dcache.h>
9652 +#include <linux/namei.h>
9653 +#include <linux/slab.h>
9655 +extern struct dentry *cow_break_link(const char *pathname);
9657 +static inline int cow_check_and_break(struct path *path)
9659 + struct inode *inode = path->dentry->d_inode;
9662 + /* do we need this check? */
9663 + if (IS_RDONLY(inode))
9666 + if (IS_COW(inode)) {
9667 + if (IS_COW_LINK(inode)) {
9668 + struct dentry *new_dentry, *old_dentry = path->dentry;
9671 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9675 + pp = d_path(path, buf, PATH_MAX);
9676 + new_dentry = cow_break_link(pp);
9678 + if (!IS_ERR(new_dentry)) {
9679 + path->dentry = new_dentry;
9682 + error = PTR_ERR(new_dentry);
9684 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9685 + inode->i_ctime = CURRENT_TIME;
9686 + mark_inode_dirty(inode);
9693 +#warning duplicate inclusion
9695 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_cvirt.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_cvirt.h
9696 --- linux-3.0-rc5/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9697 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_cvirt.h 2011-06-10 22:11:24.000000000 +0200
9699 +#ifndef _VS_CVIRT_H
9700 +#define _VS_CVIRT_H
9702 +#include "vserver/cvirt.h"
9703 +#include "vserver/context.h"
9704 +#include "vserver/base.h"
9705 +#include "vserver/check.h"
9706 +#include "vserver/debug.h"
9709 +static inline void vx_activate_task(struct task_struct *p)
9711 + struct vx_info *vxi;
9713 + if ((vxi = p->vx_info)) {
9714 + vx_update_load(vxi);
9715 + atomic_inc(&vxi->cvirt.nr_running);
9719 +static inline void vx_deactivate_task(struct task_struct *p)
9721 + struct vx_info *vxi;
9723 + if ((vxi = p->vx_info)) {
9724 + vx_update_load(vxi);
9725 + atomic_dec(&vxi->cvirt.nr_running);
9729 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9731 + struct vx_info *vxi;
9733 + if ((vxi = p->vx_info))
9734 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9737 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9739 + struct vx_info *vxi;
9741 + if ((vxi = p->vx_info))
9742 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9747 +#warning duplicate inclusion
9749 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_device.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_device.h
9750 --- linux-3.0-rc5/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9751 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_device.h 2011-06-10 22:11:24.000000000 +0200
9753 +#ifndef _VS_DEVICE_H
9754 +#define _VS_DEVICE_H
9756 +#include "vserver/base.h"
9757 +#include "vserver/device.h"
9758 +#include "vserver/debug.h"
9761 +#ifdef CONFIG_VSERVER_DEVICE
9763 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9765 +#define vs_device_perm(v, d, m, p) \
9766 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9771 +int vs_map_device(struct vx_info *vxi,
9772 + dev_t device, dev_t *target, umode_t mode)
9779 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9784 +#define vs_map_chrdev(d, t, p) \
9785 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9786 +#define vs_map_blkdev(d, t, p) \
9787 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9789 +#define vs_chrdev_perm(d, p) \
9790 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9791 +#define vs_blkdev_perm(d, p) \
9792 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9796 +#warning duplicate inclusion
9798 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_dlimit.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_dlimit.h
9799 --- linux-3.0-rc5/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9800 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_dlimit.h 2011-06-10 22:11:24.000000000 +0200
9802 +#ifndef _VS_DLIMIT_H
9803 +#define _VS_DLIMIT_H
9805 +#include <linux/fs.h>
9807 +#include "vserver/dlimit.h"
9808 +#include "vserver/base.h"
9809 +#include "vserver/debug.h"
9812 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9814 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9815 + const char *_file, int _line)
9819 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9820 + dli, dli ? dli->dl_tag : 0,
9821 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9823 + atomic_inc(&dli->dl_usecnt);
9828 +#define free_dl_info(i) \
9829 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9831 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9833 +static inline void __put_dl_info(struct dl_info *dli,
9834 + const char *_file, int _line)
9838 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9839 + dli, dli ? dli->dl_tag : 0,
9840 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9842 + if (atomic_dec_and_test(&dli->dl_usecnt))
9843 + free_dl_info(dli);
9847 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9849 +static inline int __dl_alloc_space(struct super_block *sb,
9850 + tag_t tag, dlsize_t nr, const char *file, int line)
9852 + struct dl_info *dli = NULL;
9857 + dli = locate_dl_info(sb, tag);
9861 + spin_lock(&dli->dl_lock);
9862 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9864 + dli->dl_space_used += nr;
9865 + spin_unlock(&dli->dl_lock);
9868 + vxlprintk(VXD_CBIT(dlim, 1),
9869 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9870 + sb, tag, __dlimit_char(dli), (long long)nr,
9872 + return ret ? -ENOSPC : 0;
9875 +static inline void __dl_free_space(struct super_block *sb,
9876 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9878 + struct dl_info *dli = NULL;
9882 + dli = locate_dl_info(sb, tag);
9886 + spin_lock(&dli->dl_lock);
9887 + if (dli->dl_space_used > nr)
9888 + dli->dl_space_used -= nr;
9890 + dli->dl_space_used = 0;
9891 + spin_unlock(&dli->dl_lock);
9894 + vxlprintk(VXD_CBIT(dlim, 1),
9895 + "FREE (%p,#%d)%c %lld bytes",
9896 + sb, tag, __dlimit_char(dli), (long long)nr,
9900 +static inline int __dl_alloc_inode(struct super_block *sb,
9901 + tag_t tag, const char *_file, int _line)
9903 + struct dl_info *dli;
9906 + dli = locate_dl_info(sb, tag);
9910 + spin_lock(&dli->dl_lock);
9911 + dli->dl_inodes_used++;
9912 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9913 + spin_unlock(&dli->dl_lock);
9916 + vxlprintk(VXD_CBIT(dlim, 0),
9917 + "ALLOC (%p,#%d)%c inode (%d)",
9918 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9919 + return ret ? -ENOSPC : 0;
9922 +static inline void __dl_free_inode(struct super_block *sb,
9923 + tag_t tag, const char *_file, int _line)
9925 + struct dl_info *dli;
9927 + dli = locate_dl_info(sb, tag);
9931 + spin_lock(&dli->dl_lock);
9932 + if (dli->dl_inodes_used > 1)
9933 + dli->dl_inodes_used--;
9935 + dli->dl_inodes_used = 0;
9936 + spin_unlock(&dli->dl_lock);
9939 + vxlprintk(VXD_CBIT(dlim, 0),
9940 + "FREE (%p,#%d)%c inode",
9941 + sb, tag, __dlimit_char(dli), _file, _line);
9944 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
9945 + unsigned long long *free_blocks, unsigned long long *root_blocks,
9946 + const char *_file, int _line)
9948 + struct dl_info *dli;
9949 + uint64_t broot, bfree;
9951 + dli = locate_dl_info(sb, tag);
9955 + spin_lock(&dli->dl_lock);
9956 + broot = (dli->dl_space_total -
9957 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
9958 + >> sb->s_blocksize_bits;
9959 + bfree = (dli->dl_space_total - dli->dl_space_used)
9960 + >> sb->s_blocksize_bits;
9961 + spin_unlock(&dli->dl_lock);
9963 + vxlprintk(VXD_CBIT(dlim, 2),
9964 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
9965 + (long long)bfree, (long long)broot,
9966 + *free_blocks, *root_blocks, dli->dl_nrlmult,
9968 + if (free_blocks) {
9969 + if (*free_blocks > bfree)
9970 + *free_blocks = bfree;
9972 + if (root_blocks) {
9973 + if (*root_blocks > broot)
9974 + *root_blocks = broot;
9979 +#define dl_prealloc_space(in, bytes) \
9980 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9981 + __FILE__, __LINE__ )
9983 +#define dl_alloc_space(in, bytes) \
9984 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9985 + __FILE__, __LINE__ )
9987 +#define dl_reserve_space(in, bytes) \
9988 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9989 + __FILE__, __LINE__ )
9991 +#define dl_claim_space(in, bytes) (0)
9993 +#define dl_release_space(in, bytes) \
9994 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9995 + __FILE__, __LINE__ )
9997 +#define dl_free_space(in, bytes) \
9998 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9999 + __FILE__, __LINE__ )
10003 +#define dl_alloc_inode(in) \
10004 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10006 +#define dl_free_inode(in) \
10007 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10010 +#define dl_adjust_block(sb, tag, fb, rb) \
10011 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10015 +#warning duplicate inclusion
10017 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_inet.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_inet.h
10018 --- linux-3.0-rc5/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
10019 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_inet.h 2011-06-10 22:11:24.000000000 +0200
10021 +#ifndef _VS_INET_H
10022 +#define _VS_INET_H
10024 +#include "vserver/base.h"
10025 +#include "vserver/network.h"
10026 +#include "vserver/debug.h"
10028 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
10030 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
10031 + NIPQUAD((a)->mask), (a)->type
10032 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
10034 +#define NIPQUAD(addr) \
10035 + ((unsigned char *)&addr)[0], \
10036 + ((unsigned char *)&addr)[1], \
10037 + ((unsigned char *)&addr)[2], \
10038 + ((unsigned char *)&addr)[3]
10040 +#define NIPQUAD_FMT "%u.%u.%u.%u"
10044 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
10046 + __be32 ip = nxa->ip[0].s_addr;
10047 + __be32 mask = nxa->mask.s_addr;
10048 + __be32 bcast = ip | ~mask;
10051 + switch (nxa->type & tmask) {
10052 + case NXA_TYPE_MASK:
10053 + ret = (ip == (addr & mask));
10055 + case NXA_TYPE_ADDR:
10059 + /* fall through to broadcast */
10060 + case NXA_MOD_BCAST:
10061 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
10063 + case NXA_TYPE_RANGE:
10064 + ret = ((nxa->ip[0].s_addr <= addr) &&
10065 + (nxa->ip[1].s_addr > addr));
10067 + case NXA_TYPE_ANY:
10072 + vxdprintk(VXD_CBIT(net, 0),
10073 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
10074 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
10079 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
10081 + struct nx_addr_v4 *nxa;
10088 + /* allow 127.0.0.1 when remapping lback */
10089 + if ((tmask & NXA_LOOPBACK) &&
10090 + (addr == IPI_LOOPBACK) &&
10091 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10094 + /* check for lback address */
10095 + if ((tmask & NXA_MOD_LBACK) &&
10096 + (nxi->v4_lback.s_addr == addr))
10099 + /* check for broadcast address */
10100 + if ((tmask & NXA_MOD_BCAST) &&
10101 + (nxi->v4_bcast.s_addr == addr))
10104 + /* check for v4 addresses */
10105 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
10106 + if (v4_addr_match(nxa, addr, tmask))
10110 + vxdprintk(VXD_CBIT(net, 0),
10111 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
10112 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
10117 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
10119 + /* FIXME: needs full range checks */
10120 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
10124 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
10126 + struct nx_addr_v4 *ptr;
10128 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
10129 + if (v4_nx_addr_match(ptr, nxa, mask))
10134 +#include <net/inet_sock.h>
10137 + * Check if a given address matches for a socket
10139 + * nxi: the socket's nx_info if any
10140 + * addr: to be verified address
10143 +int v4_sock_addr_match (
10144 + struct nx_info *nxi,
10145 + struct inet_sock *inet,
10148 + __be32 saddr = inet->inet_rcv_saddr;
10149 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
10151 + if (addr && (saddr == addr || bcast == addr))
10154 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
10159 +/* inet related checks and helpers */
10163 +struct net_device;
10166 +#ifdef CONFIG_INET
10168 +#include <linux/netdevice.h>
10169 +#include <linux/inetdevice.h>
10170 +#include <net/inet_sock.h>
10171 +#include <net/inet_timewait_sock.h>
10174 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10175 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
10176 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
10180 + * check if address is covered by socket
10182 + * sk: the socket to check against
10183 + * addr: the address in question (must be != 0)
10187 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
10189 + struct nx_info *nxi = sk->sk_nx_info;
10190 + __be32 saddr = sk_rcv_saddr(sk);
10192 + vxdprintk(VXD_CBIT(net, 5),
10193 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
10194 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
10195 + (sk->sk_socket?sk->sk_socket->flags:0));
10197 + if (saddr) { /* direct address match */
10198 + return v4_addr_match(nxa, saddr, -1);
10199 + } else if (nxi) { /* match against nx_info */
10200 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
10201 + } else { /* unrestricted any socket */
10209 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
10211 + vxdprintk(VXD_CBIT(net, 1),
10212 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
10213 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
10214 + nxi ? dev_in_nx_info(dev, nxi) : 0);
10216 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10218 + if (dev_in_nx_info(dev, nxi))
10225 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
10231 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
10235 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
10237 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
10238 + nxi, nxi ? nxi->nx_id : 0, ifa,
10239 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
10241 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10243 + if (v4_ifa_in_nx_info(ifa, nxi))
10249 +struct nx_v4_sock_addr {
10250 + __be32 saddr; /* Address used for validation */
10251 + __be32 baddr; /* Address used for socket bind */
10255 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
10256 + struct nx_v4_sock_addr *nsa)
10258 + struct sock *sk = &inet->sk;
10259 + struct nx_info *nxi = sk->sk_nx_info;
10260 + __be32 saddr = addr->sin_addr.s_addr;
10261 + __be32 baddr = saddr;
10263 + vxdprintk(VXD_CBIT(net, 3),
10264 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
10265 + sk, sk->sk_nx_info, sk->sk_socket,
10266 + (sk->sk_socket ? sk->sk_socket->flags : 0),
10270 + if (saddr == INADDR_ANY) {
10271 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
10272 + baddr = nxi->v4.ip[0].s_addr;
10273 + } else if (saddr == IPI_LOOPBACK) {
10274 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10275 + baddr = nxi->v4_lback.s_addr;
10276 + } else { /* normal address bind */
10277 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
10278 + return -EADDRNOTAVAIL;
10282 + vxdprintk(VXD_CBIT(net, 3),
10283 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
10284 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
10286 + nsa->saddr = saddr;
10287 + nsa->baddr = baddr;
10292 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
10294 + inet->inet_saddr = nsa->baddr;
10295 + inet->inet_rcv_saddr = nsa->baddr;
10300 + * helper to simplify inet_lookup_listener
10302 + * nxi: the socket's nx_info if any
10303 + * addr: to be verified address
10304 + * saddr: socket address
10306 +static inline int v4_inet_addr_match (
10307 + struct nx_info *nxi,
10311 + if (addr && (saddr == addr))
10314 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
10318 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
10320 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
10321 + (addr == nxi->v4_lback.s_addr))
10322 + return IPI_LOOPBACK;
10327 +int nx_info_has_v4(struct nx_info *nxi)
10331 + if (NX_IPV4(nxi))
10333 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10338 +#else /* CONFIG_INET */
10341 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
10347 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10353 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10359 +int nx_info_has_v4(struct nx_info *nxi)
10364 +#endif /* CONFIG_INET */
10366 +#define current_nx_info_has_v4() \
10367 + nx_info_has_v4(current_nx_info())
10370 +// #warning duplicate inclusion
10372 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_inet6.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_inet6.h
10373 --- linux-3.0-rc5/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
10374 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_inet6.h 2011-06-10 22:11:24.000000000 +0200
10376 +#ifndef _VS_INET6_H
10377 +#define _VS_INET6_H
10379 +#include "vserver/base.h"
10380 +#include "vserver/network.h"
10381 +#include "vserver/debug.h"
10383 +#include <net/ipv6.h>
10385 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
10386 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
10389 +#ifdef CONFIG_IPV6
10392 +int v6_addr_match(struct nx_addr_v6 *nxa,
10393 + const struct in6_addr *addr, uint16_t mask)
10397 + switch (nxa->type & mask) {
10398 + case NXA_TYPE_MASK:
10399 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
10401 + case NXA_TYPE_ADDR:
10402 + ret = ipv6_addr_equal(&nxa->ip, addr);
10404 + case NXA_TYPE_ANY:
10408 + vxdprintk(VXD_CBIT(net, 0),
10409 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
10410 + nxa, NXAV6(nxa), addr, mask, ret);
10415 +int v6_addr_in_nx_info(struct nx_info *nxi,
10416 + const struct in6_addr *addr, uint16_t mask)
10418 + struct nx_addr_v6 *nxa;
10423 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
10424 + if (v6_addr_match(nxa, addr, mask))
10428 + vxdprintk(VXD_CBIT(net, 0),
10429 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
10430 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
10435 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
10437 + /* FIXME: needs full range checks */
10438 + return v6_addr_match(nxa, &addr->ip, mask);
10442 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
10444 + struct nx_addr_v6 *ptr;
10446 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
10447 + if (v6_nx_addr_match(ptr, nxa, mask))
10454 + * Check if a given address matches for a socket
10456 + * nxi: the socket's nx_info if any
10457 + * addr: to be verified address
10460 +int v6_sock_addr_match (
10461 + struct nx_info *nxi,
10462 + struct inet_sock *inet,
10463 + struct in6_addr *addr)
10465 + struct sock *sk = &inet->sk;
10466 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10468 + if (!ipv6_addr_any(addr) &&
10469 + ipv6_addr_equal(saddr, addr))
10471 + if (ipv6_addr_any(saddr))
10472 + return v6_addr_in_nx_info(nxi, addr, -1);
10477 + * check if address is covered by socket
10479 + * sk: the socket to check against
10480 + * addr: the address in question (must be != 0)
10484 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
10486 + struct nx_info *nxi = sk->sk_nx_info;
10487 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10489 + vxdprintk(VXD_CBIT(net, 5),
10490 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
10491 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
10492 + (sk->sk_socket?sk->sk_socket->flags:0));
10494 + if (!ipv6_addr_any(saddr)) { /* direct address match */
10495 + return v6_addr_match(nxa, saddr, -1);
10496 + } else if (nxi) { /* match against nx_info */
10497 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
10498 + } else { /* unrestricted any socket */
10504 +/* inet related checks and helpers */
10508 +struct net_device;
10512 +#include <linux/netdevice.h>
10513 +#include <linux/inetdevice.h>
10514 +#include <net/inet_timewait_sock.h>
10517 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10518 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
10519 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
10524 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
10530 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
10534 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
10536 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
10537 + nxi, nxi ? nxi->nx_id : 0, ifa,
10538 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
10540 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10542 + if (v6_ifa_in_nx_info(ifa, nxi))
10548 +struct nx_v6_sock_addr {
10549 + struct in6_addr saddr; /* Address used for validation */
10550 + struct in6_addr baddr; /* Address used for socket bind */
10554 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
10555 + struct nx_v6_sock_addr *nsa)
10557 + // struct sock *sk = &inet->sk;
10558 + // struct nx_info *nxi = sk->sk_nx_info;
10559 + struct in6_addr saddr = addr->sin6_addr;
10560 + struct in6_addr baddr = saddr;
10562 + nsa->saddr = saddr;
10563 + nsa->baddr = baddr;
10568 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10570 + // struct sock *sk = &inet->sk;
10571 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10573 + // *saddr = nsa->baddr;
10574 + // inet->inet_saddr = nsa->baddr;
10578 +int nx_info_has_v6(struct nx_info *nxi)
10582 + if (NX_IPV6(nxi))
10587 +#else /* CONFIG_IPV6 */
10590 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10597 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10603 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10609 +int nx_info_has_v6(struct nx_info *nxi)
10614 +#endif /* CONFIG_IPV6 */
10616 +#define current_nx_info_has_v6() \
10617 + nx_info_has_v6(current_nx_info())
10620 +#warning duplicate inclusion
10622 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_limit.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_limit.h
10623 --- linux-3.0-rc5/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
10624 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_limit.h 2011-06-10 22:11:24.000000000 +0200
10626 +#ifndef _VS_LIMIT_H
10627 +#define _VS_LIMIT_H
10629 +#include "vserver/limit.h"
10630 +#include "vserver/base.h"
10631 +#include "vserver/context.h"
10632 +#include "vserver/debug.h"
10633 +#include "vserver/context.h"
10634 +#include "vserver/limit_int.h"
10637 +#define vx_acc_cres(v, d, p, r) \
10638 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10640 +#define vx_acc_cres_cond(x, d, p, r) \
10641 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10642 + r, d, p, __FILE__, __LINE__)
10645 +#define vx_add_cres(v, a, p, r) \
10646 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10647 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10649 +#define vx_add_cres_cond(x, a, p, r) \
10650 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10651 + r, a, p, __FILE__, __LINE__)
10652 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10655 +/* process and file limits */
10657 +#define vx_nproc_inc(p) \
10658 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10660 +#define vx_nproc_dec(p) \
10661 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10663 +#define vx_files_inc(f) \
10664 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10666 +#define vx_files_dec(f) \
10667 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10669 +#define vx_locks_inc(l) \
10670 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10672 +#define vx_locks_dec(l) \
10673 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10675 +#define vx_openfd_inc(f) \
10676 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10678 +#define vx_openfd_dec(f) \
10679 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10682 +#define vx_cres_avail(v, n, r) \
10683 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10686 +#define vx_nproc_avail(n) \
10687 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10689 +#define vx_files_avail(n) \
10690 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10692 +#define vx_locks_avail(n) \
10693 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10695 +#define vx_openfd_avail(n) \
10696 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10699 +/* dentry limits */
10701 +#define vx_dentry_inc(d) do { \
10702 + if ((d)->d_count == 1) \
10703 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10706 +#define vx_dentry_dec(d) do { \
10707 + if ((d)->d_count == 0) \
10708 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10711 +#define vx_dentry_avail(n) \
10712 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10715 +/* socket limits */
10717 +#define vx_sock_inc(s) \
10718 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10720 +#define vx_sock_dec(s) \
10721 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10723 +#define vx_sock_avail(n) \
10724 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10727 +/* ipc resource limits */
10729 +#define vx_ipcmsg_add(v, u, a) \
10730 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10732 +#define vx_ipcmsg_sub(v, u, a) \
10733 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10735 +#define vx_ipcmsg_avail(v, a) \
10736 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10739 +#define vx_ipcshm_add(v, k, a) \
10740 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10742 +#define vx_ipcshm_sub(v, k, a) \
10743 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10745 +#define vx_ipcshm_avail(v, a) \
10746 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10749 +#define vx_semary_inc(a) \
10750 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10752 +#define vx_semary_dec(a) \
10753 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10756 +#define vx_nsems_add(a,n) \
10757 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10759 +#define vx_nsems_sub(a,n) \
10760 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10764 +#warning duplicate inclusion
10766 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_memory.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_memory.h
10767 --- linux-3.0-rc5/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
10768 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_memory.h 2011-06-10 22:11:24.000000000 +0200
10770 +#ifndef _VS_MEMORY_H
10771 +#define _VS_MEMORY_H
10773 +#include "vserver/limit.h"
10774 +#include "vserver/base.h"
10775 +#include "vserver/context.h"
10776 +#include "vserver/debug.h"
10777 +#include "vserver/context.h"
10778 +#include "vserver/limit_int.h"
10781 + VXPT_UNKNOWN = 0,
10790 +#define vx_page_fault(mm, vma, type, ret)
10794 +void __vx_page_fault(struct mm_struct *mm,
10795 + struct vm_area_struct *vma, int type, int ret)
10797 + struct vx_info *vxi = mm->mm_vx_info;
10800 + static char *page_type[6] =
10801 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
10802 + static char *page_what[4] =
10803 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
10809 + what = (ret & 0x3);
10811 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
10812 + type, what, ret, page_type[type], page_what[what]);
10814 + if (ret & VM_FAULT_WRITE)
10816 + atomic_inc(&vxi->cacct.page[type][what]);
10819 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
10823 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
10826 +#warning duplicate inclusion
10828 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_network.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_network.h
10829 --- linux-3.0-rc5/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
10830 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_network.h 2011-06-10 22:11:24.000000000 +0200
10832 +#ifndef _NX_VS_NETWORK_H
10833 +#define _NX_VS_NETWORK_H
10835 +#include "vserver/context.h"
10836 +#include "vserver/network.h"
10837 +#include "vserver/base.h"
10838 +#include "vserver/check.h"
10839 +#include "vserver/debug.h"
10841 +#include <linux/sched.h>
10844 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
10846 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
10847 + const char *_file, int _line)
10852 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
10853 + nxi, nxi ? nxi->nx_id : 0,
10854 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10857 + atomic_inc(&nxi->nx_usecnt);
10862 +extern void free_nx_info(struct nx_info *);
10864 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
10866 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
10871 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
10872 + nxi, nxi ? nxi->nx_id : 0,
10873 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10876 + if (atomic_dec_and_test(&nxi->nx_usecnt))
10877 + free_nx_info(nxi);
10881 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
10883 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10884 + const char *_file, int _line)
10887 + vxlprintk(VXD_CBIT(nid, 3),
10888 + "init_nx_info(%p[#%d.%d])",
10889 + nxi, nxi ? nxi->nx_id : 0,
10890 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10893 + atomic_inc(&nxi->nx_usecnt);
10899 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
10901 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10902 + const char *_file, int _line)
10904 + struct nx_info *nxo;
10909 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
10910 + nxi, nxi ? nxi->nx_id : 0,
10911 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10914 + atomic_inc(&nxi->nx_usecnt);
10915 + nxo = xchg(nxp, nxi);
10919 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
10921 +static inline void __clr_nx_info(struct nx_info **nxp,
10922 + const char *_file, int _line)
10924 + struct nx_info *nxo;
10926 + nxo = xchg(nxp, NULL);
10930 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
10931 + nxo, nxo ? nxo->nx_id : 0,
10932 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
10935 + if (atomic_dec_and_test(&nxo->nx_usecnt))
10936 + free_nx_info(nxo);
10940 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
10942 +static inline void __claim_nx_info(struct nx_info *nxi,
10943 + struct task_struct *task, const char *_file, int _line)
10945 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
10946 + nxi, nxi ? nxi->nx_id : 0,
10947 + nxi?atomic_read(&nxi->nx_usecnt):0,
10948 + nxi?atomic_read(&nxi->nx_tasks):0,
10949 + task, _file, _line);
10951 + atomic_inc(&nxi->nx_tasks);
10955 +extern void unhash_nx_info(struct nx_info *);
10957 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
10959 +static inline void __release_nx_info(struct nx_info *nxi,
10960 + struct task_struct *task, const char *_file, int _line)
10962 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
10963 + nxi, nxi ? nxi->nx_id : 0,
10964 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10965 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
10966 + task, _file, _line);
10970 + if (atomic_dec_and_test(&nxi->nx_tasks))
10971 + unhash_nx_info(nxi);
10975 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
10977 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
10978 + const char *_file, int _line)
10980 + struct nx_info *nxi;
10983 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
10984 + p, _file, _line);
10985 + nxi = __get_nx_info(p->nx_info, _file, _line);
10991 +static inline void exit_nx_info(struct task_struct *p)
10994 + release_nx_info(p->nx_info, p);
10999 +#warning duplicate inclusion
11001 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_pid.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_pid.h
11002 --- linux-3.0-rc5/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
11003 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_pid.h 2011-06-10 22:11:24.000000000 +0200
11008 +#include "vserver/base.h"
11009 +#include "vserver/check.h"
11010 +#include "vserver/context.h"
11011 +#include "vserver/debug.h"
11012 +#include "vserver/pid.h"
11013 +#include <linux/pid_namespace.h>
11016 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
11019 +int vx_proc_task_visible(struct task_struct *task)
11021 + if ((task->pid == 1) &&
11022 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
11023 + /* show a blend through init */
11025 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
11032 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
11036 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
11038 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
11040 + if (task && !vx_proc_task_visible(task)) {
11041 + vxdprintk(VXD_CBIT(misc, 6),
11042 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
11043 + task, task->xid, task->pid,
11044 + current, current->xid, current->pid);
11045 + put_task_struct(task);
11053 +#warning duplicate inclusion
11055 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_sched.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_sched.h
11056 --- linux-3.0-rc5/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
11057 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_sched.h 2011-06-10 22:11:24.000000000 +0200
11059 +#ifndef _VS_SCHED_H
11060 +#define _VS_SCHED_H
11062 +#include "vserver/base.h"
11063 +#include "vserver/context.h"
11064 +#include "vserver/sched.h"
11067 +#define MAX_PRIO_BIAS 20
11068 +#define MIN_PRIO_BIAS -20
11071 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
11073 + struct vx_info *vxi = p->vx_info;
11076 + prio += vx_cpu(vxi, sched_pc).prio_bias;
11080 +static inline void vx_account_user(struct vx_info *vxi,
11081 + cputime_t cputime, int nice)
11085 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
11088 +static inline void vx_account_system(struct vx_info *vxi,
11089 + cputime_t cputime, int idle)
11093 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
11097 +#warning duplicate inclusion
11099 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_socket.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_socket.h
11100 --- linux-3.0-rc5/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
11101 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_socket.h 2011-06-10 22:11:24.000000000 +0200
11103 +#ifndef _VS_SOCKET_H
11104 +#define _VS_SOCKET_H
11106 +#include "vserver/debug.h"
11107 +#include "vserver/base.h"
11108 +#include "vserver/cacct.h"
11109 +#include "vserver/context.h"
11110 +#include "vserver/tag.h"
11113 +/* socket accounting */
11115 +#include <linux/socket.h>
11117 +static inline int vx_sock_type(int family)
11119 + switch (family) {
11121 + return VXA_SOCK_UNSPEC;
11123 + return VXA_SOCK_UNIX;
11125 + return VXA_SOCK_INET;
11127 + return VXA_SOCK_INET6;
11129 + return VXA_SOCK_PACKET;
11131 + return VXA_SOCK_OTHER;
11135 +#define vx_acc_sock(v, f, p, s) \
11136 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
11138 +static inline void __vx_acc_sock(struct vx_info *vxi,
11139 + int family, int pos, int size, char *file, int line)
11142 + int type = vx_sock_type(family);
11144 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
11145 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
11149 +#define vx_sock_recv(sk, s) \
11150 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
11151 +#define vx_sock_send(sk, s) \
11152 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
11153 +#define vx_sock_fail(sk, s) \
11154 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
11157 +#define sock_vx_init(s) do { \
11158 + (s)->sk_xid = 0; \
11159 + (s)->sk_vx_info = NULL; \
11162 +#define sock_nx_init(s) do { \
11163 + (s)->sk_nid = 0; \
11164 + (s)->sk_nx_info = NULL; \
11168 +#warning duplicate inclusion
11170 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_tag.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_tag.h
11171 --- linux-3.0-rc5/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
11172 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_tag.h 2011-06-10 22:11:24.000000000 +0200
11177 +#include <linux/vserver/tag.h>
11179 +/* check conditions */
11181 +#define DX_ADMIN 0x0001
11182 +#define DX_WATCH 0x0002
11183 +#define DX_HOSTID 0x0008
11185 +#define DX_IDENT 0x0010
11187 +#define DX_ARG_MASK 0x0010
11190 +#define dx_task_tag(t) ((t)->tag)
11192 +#define dx_current_tag() dx_task_tag(current)
11194 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
11196 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
11200 + * check current context for ADMIN/WATCH and
11201 + * optionally against supplied argument
11203 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
11205 + if (mode & DX_ARG_MASK) {
11206 + if ((mode & DX_IDENT) && (id == cid))
11209 + return (((mode & DX_ADMIN) && (cid == 0)) ||
11210 + ((mode & DX_WATCH) && (cid == 1)) ||
11211 + ((mode & DX_HOSTID) && (id == 0)));
11215 +int dx_permission(const struct inode *inode, int mask);
11219 +#warning duplicate inclusion
11221 diff -NurpP --minimal linux-3.0-rc5/include/linux/vs_time.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_time.h
11222 --- linux-3.0-rc5/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
11223 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vs_time.h 2011-06-13 14:57:45.000000000 +0200
11225 +#ifndef _VS_TIME_H
11226 +#define _VS_TIME_H
11229 +/* time faking stuff */
11231 +#ifdef CONFIG_VSERVER_VTIME
11233 +extern void vx_adjust_timespec(struct timespec *ts);
11234 +extern int vx_settimeofday(const struct timespec *ts);
11237 +#define vx_adjust_timespec(t) do { } while (0)
11238 +#define vx_settimeofday(t) do_settimeofday(t)
11242 +#warning duplicate inclusion
11244 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/Kbuild linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/Kbuild
11245 --- linux-3.0-rc5/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11246 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/Kbuild 2011-06-10 22:11:24.000000000 +0200
11249 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11250 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11251 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11252 + debug_cmd.h device_cmd.h
11254 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11256 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/base.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/base.h
11257 --- linux-3.0-rc5/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
11258 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/base.h 2011-06-13 14:09:44.000000000 +0200
11260 +#ifndef _VX_BASE_H
11261 +#define _VX_BASE_H
11264 +/* context state changes */
11276 +#define vx_task_xid(t) ((t)->xid)
11278 +#define vx_current_xid() vx_task_xid(current)
11280 +#define current_vx_info() (current->vx_info)
11283 +#define nx_task_nid(t) ((t)->nid)
11285 +#define nx_current_nid() nx_task_nid(current)
11287 +#define current_nx_info() (current->nx_info)
11290 +/* generic flag merging */
11292 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
11294 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11296 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
11298 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
11301 +/* context flags */
11303 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
11305 +#define vx_current_flags() __vx_flags(current_vx_info())
11307 +#define vx_info_flags(v, m, f) \
11308 + vs_check_flags(__vx_flags(v), m, f)
11310 +#define task_vx_flags(t, m, f) \
11311 + ((t) && vx_info_flags((t)->vx_info, m, f))
11313 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11316 +/* context caps */
11318 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
11320 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
11322 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
11324 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
11328 +/* network flags */
11330 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
11332 +#define nx_current_flags() __nx_flags(current_nx_info())
11334 +#define nx_info_flags(n, m, f) \
11335 + vs_check_flags(__nx_flags(n), m, f)
11337 +#define task_nx_flags(t, m, f) \
11338 + ((t) && nx_info_flags((t)->nx_info, m, f))
11340 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11343 +/* network caps */
11345 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
11347 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
11349 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
11351 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
11354 +/* context mask capabilities */
11356 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11358 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
11360 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
11363 +/* context bcap mask */
11365 +#define __vx_bcaps(v) ((v)->vx_bcaps)
11367 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
11370 +/* mask given bcaps */
11372 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11374 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
11377 +/* masked cap_bset */
11379 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
11381 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
11384 +#define vx_info_mbcap(v, b) \
11385 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11386 + vx_info_bcaps(v, b) : (b))
11388 +#define task_vx_mbcap(t, b) \
11389 + vx_info_mbcap((t)->vx_info, (t)->b)
11391 +#define vx_mbcap(b) task_vx_mbcap(current, b)
11394 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11396 +#define vx_capable(b, c) (capable(b) || \
11397 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
11399 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
11400 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
11402 +#define nx_capable(b, c) (capable(b) || \
11403 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
11405 +#define vx_task_initpid(t, n) \
11406 + ((t)->vx_info && \
11407 + ((t)->vx_info->vx_initpid == (n)))
11409 +#define vx_current_initpid(n) vx_task_initpid(current, n)
11412 +/* context unshare mask */
11414 +#define __vx_umask(v) ((v)->vx_umask)
11416 +#define vx_current_umask() __vx_umask(current_vx_info())
11418 +#define vx_can_unshare(b, f) (capable(b) || \
11419 + (cap_raised(current_cap(), b) && \
11420 + !((f) & ~vx_current_umask())))
11423 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
11425 +#define vx_info_state(v, m) (__vx_state(v) & (m))
11428 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
11430 +#define nx_info_state(n, m) (__nx_state(n) & (m))
11433 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/cacct.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cacct.h
11434 --- linux-3.0-rc5/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
11435 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cacct.h 2011-06-10 22:11:24.000000000 +0200
11437 +#ifndef _VX_CACCT_H
11438 +#define _VX_CACCT_H
11441 +enum sock_acc_field {
11442 + VXA_SOCK_UNSPEC = 0,
11448 + VXA_SOCK_SIZE /* array size */
11451 +#endif /* _VX_CACCT_H */
11452 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/cacct_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cacct_cmd.h
11453 --- linux-3.0-rc5/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
11454 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cacct_cmd.h 2011-06-10 22:11:24.000000000 +0200
11456 +#ifndef _VX_CACCT_CMD_H
11457 +#define _VX_CACCT_CMD_H
11460 +/* virtual host info name commands */
11462 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
11464 +struct vcmd_sock_stat_v0 {
11466 + uint32_t count[3];
11467 + uint64_t total[3];
11473 +#include <linux/compiler.h>
11475 +extern int vc_sock_stat(struct vx_info *, void __user *);
11477 +#endif /* __KERNEL__ */
11478 +#endif /* _VX_CACCT_CMD_H */
11479 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/cacct_def.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cacct_def.h
11480 --- linux-3.0-rc5/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
11481 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cacct_def.h 2011-06-10 22:11:24.000000000 +0200
11483 +#ifndef _VX_CACCT_DEF_H
11484 +#define _VX_CACCT_DEF_H
11486 +#include <asm/atomic.h>
11487 +#include <linux/vserver/cacct.h>
11490 +struct _vx_sock_acc {
11491 + atomic_long_t count;
11492 + atomic_long_t total;
11495 +/* context sub struct */
11497 +struct _vx_cacct {
11498 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11499 + atomic_t slab[8];
11500 + atomic_t page[6][8];
11503 +#ifdef CONFIG_VSERVER_DEBUG
11505 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11509 + printk("\t_vx_cacct:");
11510 + for (i = 0; i < 6; i++) {
11511 + struct _vx_sock_acc *ptr = cacct->sock[i];
11513 + printk("\t [%d] =", i);
11514 + for (j = 0; j < 3; j++) {
11515 + printk(" [%d] = %8lu, %8lu", j,
11516 + atomic_long_read(&ptr[j].count),
11517 + atomic_long_read(&ptr[j].total));
11525 +#endif /* _VX_CACCT_DEF_H */
11526 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/cacct_int.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cacct_int.h
11527 --- linux-3.0-rc5/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
11528 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cacct_int.h 2011-06-10 22:11:24.000000000 +0200
11530 +#ifndef _VX_CACCT_INT_H
11531 +#define _VX_CACCT_INT_H
11537 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11539 + return atomic_long_read(&cacct->sock[type][pos].count);
11544 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11546 + return atomic_long_read(&cacct->sock[type][pos].total);
11549 +#endif /* __KERNEL__ */
11550 +#endif /* _VX_CACCT_INT_H */
11551 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/check.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/check.h
11552 --- linux-3.0-rc5/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
11553 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/check.h 2011-06-10 22:11:24.000000000 +0200
11555 +#ifndef _VS_CHECK_H
11556 +#define _VS_CHECK_H
11559 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
11561 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11562 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
11564 +#define MIN_D_CONTEXT 65536
11567 +/* check conditions */
11569 +#define VS_ADMIN 0x0001
11570 +#define VS_WATCH 0x0002
11571 +#define VS_HIDE 0x0004
11572 +#define VS_HOSTID 0x0008
11574 +#define VS_IDENT 0x0010
11575 +#define VS_EQUIV 0x0020
11576 +#define VS_PARENT 0x0040
11577 +#define VS_CHILD 0x0080
11579 +#define VS_ARG_MASK 0x00F0
11581 +#define VS_DYNAMIC 0x0100
11582 +#define VS_STATIC 0x0200
11584 +#define VS_ATR_MASK 0x0F00
11586 +#ifdef CONFIG_VSERVER_PRIVACY
11587 +#define VS_ADMIN_P (0)
11588 +#define VS_WATCH_P (0)
11590 +#define VS_ADMIN_P VS_ADMIN
11591 +#define VS_WATCH_P VS_WATCH
11594 +#define VS_HARDIRQ 0x1000
11595 +#define VS_SOFTIRQ 0x2000
11596 +#define VS_IRQ 0x4000
11598 +#define VS_IRQ_MASK 0xF000
11600 +#include <linux/hardirq.h>
11603 + * check current context for ADMIN/WATCH and
11604 + * optionally against supplied argument
11606 +static inline int __vs_check(int cid, int id, unsigned int mode)
11608 + if (mode & VS_ARG_MASK) {
11609 + if ((mode & VS_IDENT) && (id == cid))
11612 + if (mode & VS_ATR_MASK) {
11613 + if ((mode & VS_DYNAMIC) &&
11614 + (id >= MIN_D_CONTEXT) &&
11615 + (id <= MAX_S_CONTEXT))
11617 + if ((mode & VS_STATIC) &&
11618 + (id > 1) && (id < MIN_D_CONTEXT))
11621 + if (mode & VS_IRQ_MASK) {
11622 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11624 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11626 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11629 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11630 + ((mode & VS_WATCH) && (cid == 1)) ||
11631 + ((mode & VS_HOSTID) && (id == 0)));
11634 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11636 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11639 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11641 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11644 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/context.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/context.h
11645 --- linux-3.0-rc5/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
11646 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/context.h 2011-06-10 22:11:24.000000000 +0200
11648 +#ifndef _VX_CONTEXT_H
11649 +#define _VX_CONTEXT_H
11651 +#include <linux/types.h>
11652 +#include <linux/capability.h>
11655 +/* context flags */
11657 +#define VXF_INFO_SCHED 0x00000002
11658 +#define VXF_INFO_NPROC 0x00000004
11659 +#define VXF_INFO_PRIVATE 0x00000008
11661 +#define VXF_INFO_INIT 0x00000010
11662 +#define VXF_INFO_HIDE 0x00000020
11663 +#define VXF_INFO_ULIMIT 0x00000040
11664 +#define VXF_INFO_NSPACE 0x00000080
11666 +#define VXF_SCHED_HARD 0x00000100
11667 +#define VXF_SCHED_PRIO 0x00000200
11668 +#define VXF_SCHED_PAUSE 0x00000400
11670 +#define VXF_VIRT_MEM 0x00010000
11671 +#define VXF_VIRT_UPTIME 0x00020000
11672 +#define VXF_VIRT_CPU 0x00040000
11673 +#define VXF_VIRT_LOAD 0x00080000
11674 +#define VXF_VIRT_TIME 0x00100000
11676 +#define VXF_HIDE_MOUNT 0x01000000
11677 +/* was VXF_HIDE_NETIF 0x02000000 */
11678 +#define VXF_HIDE_VINFO 0x04000000
11680 +#define VXF_STATE_SETUP (1ULL << 32)
11681 +#define VXF_STATE_INIT (1ULL << 33)
11682 +#define VXF_STATE_ADMIN (1ULL << 34)
11684 +#define VXF_SC_HELPER (1ULL << 36)
11685 +#define VXF_REBOOT_KILL (1ULL << 37)
11686 +#define VXF_PERSISTENT (1ULL << 38)
11688 +#define VXF_FORK_RSS (1ULL << 48)
11689 +#define VXF_PROLIFIC (1ULL << 49)
11691 +#define VXF_IGNEG_NICE (1ULL << 52)
11693 +#define VXF_ONE_TIME (0x0007ULL << 32)
11695 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11698 +/* context migration */
11700 +#define VXM_SET_INIT 0x00000001
11701 +#define VXM_SET_REAPER 0x00000002
11703 +/* context caps */
11705 +#define VXC_CAP_MASK 0x00000000
11707 +#define VXC_SET_UTSNAME 0x00000001
11708 +#define VXC_SET_RLIMIT 0x00000002
11709 +#define VXC_FS_SECURITY 0x00000004
11710 +#define VXC_FS_TRUSTED 0x00000008
11711 +#define VXC_TIOCSTI 0x00000010
11713 +/* was VXC_RAW_ICMP 0x00000100 */
11714 +#define VXC_SYSLOG 0x00001000
11715 +#define VXC_OOM_ADJUST 0x00002000
11716 +#define VXC_AUDIT_CONTROL 0x00004000
11718 +#define VXC_SECURE_MOUNT 0x00010000
11719 +#define VXC_SECURE_REMOUNT 0x00020000
11720 +#define VXC_BINARY_MOUNT 0x00040000
11722 +#define VXC_QUOTA_CTL 0x00100000
11723 +#define VXC_ADMIN_MAPPER 0x00200000
11724 +#define VXC_ADMIN_CLOOP 0x00400000
11726 +#define VXC_KTHREAD 0x01000000
11727 +#define VXC_NAMESPACE 0x02000000
11732 +#include <linux/list.h>
11733 +#include <linux/spinlock.h>
11734 +#include <linux/rcupdate.h>
11736 +#include "limit_def.h"
11737 +#include "sched_def.h"
11738 +#include "cvirt_def.h"
11739 +#include "cacct_def.h"
11740 +#include "device_def.h"
11742 +#define VX_SPACES 2
11744 +struct _vx_info_pc {
11745 + struct _vx_sched_pc sched_pc;
11746 + struct _vx_cvirt_pc cvirt_pc;
11749 +struct _vx_space {
11750 + unsigned long vx_nsmask; /* assignment mask */
11751 + struct nsproxy *vx_nsproxy; /* private namespaces */
11752 + struct fs_struct *vx_fs; /* private namespace fs */
11753 + const struct cred *vx_cred; /* task credentials */
11757 + struct hlist_node vx_hlist; /* linked list of contexts */
11758 + xid_t vx_id; /* context id */
11759 + atomic_t vx_usecnt; /* usage count */
11760 + atomic_t vx_tasks; /* tasks count */
11761 + struct vx_info *vx_parent; /* parent context */
11762 + int vx_state; /* context state */
11764 + struct _vx_space space[VX_SPACES]; /* namespace store */
11766 + uint64_t vx_flags; /* context flags */
11767 + uint64_t vx_ccaps; /* context caps (vserver) */
11768 + uint64_t vx_umask; /* unshare mask (guest) */
11769 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11771 + struct task_struct *vx_reaper; /* guest reaper process */
11772 + pid_t vx_initpid; /* PID of guest init */
11773 + int64_t vx_badness_bias; /* OOM points bias */
11775 + struct _vx_limit limit; /* vserver limits */
11776 + struct _vx_sched sched; /* vserver scheduler */
11777 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11778 + struct _vx_cacct cacct; /* context accounting */
11780 + struct _vx_device dmap; /* default device map targets */
11782 +#ifndef CONFIG_SMP
11783 + struct _vx_info_pc info_pc; /* per cpu data */
11785 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11788 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11789 + int reboot_cmd; /* last sys_reboot() cmd */
11790 + int exit_code; /* last process exit code */
11792 + char vx_name[65]; /* vserver name */
11795 +#ifndef CONFIG_SMP
11796 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11797 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11799 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11800 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11803 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11806 +struct vx_info_save {
11807 + struct vx_info *vxi;
11812 +/* status flags */
11814 +#define VXS_HASHED 0x0001
11815 +#define VXS_PAUSED 0x0010
11816 +#define VXS_SHUTDOWN 0x0100
11817 +#define VXS_HELPER 0x1000
11818 +#define VXS_RELEASED 0x8000
11821 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11822 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11824 +extern struct vx_info *lookup_vx_info(int);
11825 +extern struct vx_info *lookup_or_create_vx_info(int);
11827 +extern int get_xid_list(int, unsigned int *, int);
11828 +extern int xid_is_hashed(xid_t);
11830 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11832 +extern long vs_state_change(struct vx_info *, unsigned int);
11835 +#endif /* __KERNEL__ */
11836 +#endif /* _VX_CONTEXT_H */
11837 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/context_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/context_cmd.h
11838 --- linux-3.0-rc5/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
11839 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/context_cmd.h 2011-06-10 22:11:24.000000000 +0200
11841 +#ifndef _VX_CONTEXT_CMD_H
11842 +#define _VX_CONTEXT_CMD_H
11845 +/* vinfo commands */
11847 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
11850 +extern int vc_task_xid(uint32_t);
11852 +#endif /* __KERNEL__ */
11854 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
11856 +struct vcmd_vx_info_v0 {
11858 + uint32_t initpid;
11859 + /* more to come */
11863 +extern int vc_vx_info(struct vx_info *, void __user *);
11865 +#endif /* __KERNEL__ */
11867 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
11869 +struct vcmd_ctx_stat_v0 {
11872 + /* more to come */
11876 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11878 +#endif /* __KERNEL__ */
11880 +/* context commands */
11882 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
11883 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
11885 +struct vcmd_ctx_create {
11886 + uint64_t flagword;
11889 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
11890 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
11892 +struct vcmd_ctx_migrate {
11893 + uint64_t flagword;
11897 +extern int vc_ctx_create(uint32_t, void __user *);
11898 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11900 +#endif /* __KERNEL__ */
11903 +/* flag commands */
11905 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
11906 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
11908 +struct vcmd_ctx_flags_v0 {
11909 + uint64_t flagword;
11914 +extern int vc_get_cflags(struct vx_info *, void __user *);
11915 +extern int vc_set_cflags(struct vx_info *, void __user *);
11917 +#endif /* __KERNEL__ */
11920 +/* context caps commands */
11922 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
11923 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
11925 +struct vcmd_ctx_caps_v1 {
11931 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11932 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11934 +#endif /* __KERNEL__ */
11937 +/* bcaps commands */
11939 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
11940 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
11942 +struct vcmd_bcaps {
11948 +extern int vc_get_bcaps(struct vx_info *, void __user *);
11949 +extern int vc_set_bcaps(struct vx_info *, void __user *);
11951 +#endif /* __KERNEL__ */
11954 +/* umask commands */
11956 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
11957 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
11959 +struct vcmd_umask {
11965 +extern int vc_get_umask(struct vx_info *, void __user *);
11966 +extern int vc_set_umask(struct vx_info *, void __user *);
11968 +#endif /* __KERNEL__ */
11973 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
11974 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
11976 +struct vcmd_badness_v0 {
11981 +extern int vc_get_badness(struct vx_info *, void __user *);
11982 +extern int vc_set_badness(struct vx_info *, void __user *);
11984 +#endif /* __KERNEL__ */
11985 +#endif /* _VX_CONTEXT_CMD_H */
11986 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/cvirt.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cvirt.h
11987 --- linux-3.0-rc5/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11988 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cvirt.h 2011-06-10 22:11:24.000000000 +0200
11990 +#ifndef _VX_CVIRT_H
11991 +#define _VX_CVIRT_H
11998 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12003 +void vx_update_load(struct vx_info *);
12006 +int vx_do_syslog(int, char __user *, int);
12008 +#endif /* __KERNEL__ */
12009 +#endif /* _VX_CVIRT_H */
12010 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/cvirt_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cvirt_cmd.h
12011 --- linux-3.0-rc5/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
12012 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cvirt_cmd.h 2011-06-10 22:11:24.000000000 +0200
12014 +#ifndef _VX_CVIRT_CMD_H
12015 +#define _VX_CVIRT_CMD_H
12018 +/* virtual host info name commands */
12020 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
12021 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
12023 +struct vcmd_vhi_name_v0 {
12029 +enum vhi_name_field {
12030 + VHIN_CONTEXT = 0,
12042 +#include <linux/compiler.h>
12044 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
12045 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
12047 +#endif /* __KERNEL__ */
12049 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
12051 +struct vcmd_virt_stat_v0 {
12054 + uint32_t nr_threads;
12055 + uint32_t nr_running;
12056 + uint32_t nr_uninterruptible;
12057 + uint32_t nr_onhold;
12058 + uint32_t nr_forks;
12059 + uint32_t load[3];
12063 +extern int vc_virt_stat(struct vx_info *, void __user *);
12065 +#endif /* __KERNEL__ */
12066 +#endif /* _VX_CVIRT_CMD_H */
12067 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/cvirt_def.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cvirt_def.h
12068 --- linux-3.0-rc5/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
12069 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/cvirt_def.h 2011-06-10 22:11:24.000000000 +0200
12071 +#ifndef _VX_CVIRT_DEF_H
12072 +#define _VX_CVIRT_DEF_H
12074 +#include <linux/jiffies.h>
12075 +#include <linux/spinlock.h>
12076 +#include <linux/wait.h>
12077 +#include <linux/time.h>
12078 +#include <asm/atomic.h>
12081 +struct _vx_usage_stat {
12085 + uint64_t softirq;
12091 +struct _vx_syslog {
12092 + wait_queue_head_t log_wait;
12093 + spinlock_t logbuf_lock; /* lock for the log buffer */
12095 + unsigned long log_start; /* next char to be read by syslog() */
12096 + unsigned long con_start; /* next char to be sent to consoles */
12097 + unsigned long log_end; /* most-recently-written-char + 1 */
12098 + unsigned long logged_chars; /* #chars since last read+clear operation */
12100 + char log_buf[1024];
12104 +/* context sub struct */
12106 +struct _vx_cvirt {
12107 + atomic_t nr_threads; /* number of current threads */
12108 + atomic_t nr_running; /* number of running threads */
12109 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
12111 + atomic_t nr_onhold; /* processes on hold */
12112 + uint32_t onhold_last; /* jiffies when put on hold */
12114 + struct timespec bias_ts; /* time offset to the host */
12115 + struct timespec bias_idle;
12116 + struct timespec bias_uptime; /* context creation point */
12117 + uint64_t bias_clock; /* offset in clock_t */
12119 + spinlock_t load_lock; /* lock for the load averages */
12120 + atomic_t load_updates; /* nr of load updates done so far */
12121 + uint32_t load_last; /* last time load was calculated */
12122 + uint32_t load[3]; /* load averages 1,5,15 */
12124 + atomic_t total_forks; /* number of forks so far */
12126 + struct _vx_syslog syslog;
12129 +struct _vx_cvirt_pc {
12130 + struct _vx_usage_stat cpustat;
12134 +#ifdef CONFIG_VSERVER_DEBUG
12136 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
12138 + printk("\t_vx_cvirt:\n");
12139 + printk("\t threads: %4d, %4d, %4d, %4d\n",
12140 + atomic_read(&cvirt->nr_threads),
12141 + atomic_read(&cvirt->nr_running),
12142 + atomic_read(&cvirt->nr_uninterruptible),
12143 + atomic_read(&cvirt->nr_onhold));
12144 + /* add rest here */
12145 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
12150 +#endif /* _VX_CVIRT_DEF_H */
12151 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/debug.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/debug.h
12152 --- linux-3.0-rc5/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
12153 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/debug.h 2011-06-10 22:11:24.000000000 +0200
12155 +#ifndef _VX_DEBUG_H
12156 +#define _VX_DEBUG_H
12159 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
12160 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
12161 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
12163 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
12164 + imajor((d)->bd_inode), iminor((d)->bd_inode)
12165 +#define VXF_DEV "%p[%lu,%d:%d]"
12167 +#if defined(CONFIG_QUOTES_UTF8)
12168 +#define VS_Q_LQM "\xc2\xbb"
12169 +#define VS_Q_RQM "\xc2\xab"
12170 +#elif defined(CONFIG_QUOTES_ASCII)
12171 +#define VS_Q_LQM "\x27"
12172 +#define VS_Q_RQM "\x27"
12174 +#define VS_Q_LQM "\xbb"
12175 +#define VS_Q_RQM "\xab"
12178 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
12181 +#define vxd_path(p) \
12182 + ({ static char _buffer[PATH_MAX]; \
12183 + d_path(p, _buffer, sizeof(_buffer)); })
12185 +#define vxd_cond_path(n) \
12186 + ((n) ? vxd_path(&(n)->path) : "<null>" )
12189 +#ifdef CONFIG_VSERVER_DEBUG
12191 +extern unsigned int vx_debug_switch;
12192 +extern unsigned int vx_debug_xid;
12193 +extern unsigned int vx_debug_nid;
12194 +extern unsigned int vx_debug_tag;
12195 +extern unsigned int vx_debug_net;
12196 +extern unsigned int vx_debug_limit;
12197 +extern unsigned int vx_debug_cres;
12198 +extern unsigned int vx_debug_dlim;
12199 +extern unsigned int vx_debug_quota;
12200 +extern unsigned int vx_debug_cvirt;
12201 +extern unsigned int vx_debug_space;
12202 +extern unsigned int vx_debug_misc;
12205 +#define VX_LOGLEVEL "vxD: "
12206 +#define VX_PROC_FMT "%p: "
12207 +#define VX_PROCESS current
12209 +#define vxdprintk(c, f, x...) \
12212 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
12213 + VX_PROCESS , ##x); \
12216 +#define vxlprintk(c, f, x...) \
12219 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
12222 +#define vxfprintk(c, f, x...) \
12225 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
12231 +void dump_vx_info(struct vx_info *, int);
12232 +void dump_vx_info_inactive(int);
12234 +#else /* CONFIG_VSERVER_DEBUG */
12236 +#define vx_debug_switch 0
12237 +#define vx_debug_xid 0
12238 +#define vx_debug_nid 0
12239 +#define vx_debug_tag 0
12240 +#define vx_debug_net 0
12241 +#define vx_debug_limit 0
12242 +#define vx_debug_cres 0
12243 +#define vx_debug_dlim 0
12244 +#define vx_debug_cvirt 0
12246 +#define vxdprintk(x...) do { } while (0)
12247 +#define vxlprintk(x...) do { } while (0)
12248 +#define vxfprintk(x...) do { } while (0)
12250 +#endif /* CONFIG_VSERVER_DEBUG */
12253 +#ifdef CONFIG_VSERVER_WARN
12255 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
12256 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
12257 +#define VX_WARN_XID "[xid #%u] "
12258 +#define VX_WARN_NID "[nid #%u] "
12259 +#define VX_WARN_TAG "[tag #%u] "
12261 +#define vxwprintk(c, f, x...) \
12264 + printk(VX_WARNLEVEL f "\n", ##x); \
12267 +#else /* CONFIG_VSERVER_WARN */
12269 +#define vxwprintk(x...) do { } while (0)
12271 +#endif /* CONFIG_VSERVER_WARN */
12273 +#define vxwprintk_task(c, f, x...) \
12274 + vxwprintk(c, VX_WARN_TASK f, \
12275 + current->comm, current->pid, \
12276 + current->xid, current->nid, current->tag, ##x)
12277 +#define vxwprintk_xid(c, f, x...) \
12278 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
12279 +#define vxwprintk_nid(c, f, x...) \
12280 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
12281 +#define vxwprintk_tag(c, f, x...) \
12282 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12284 +#ifdef CONFIG_VSERVER_DEBUG
12285 +#define vxd_assert_lock(l) assert_spin_locked(l)
12286 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12287 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12289 +#define vxd_assert_lock(l) do { } while (0)
12290 +#define vxd_assert(c, f, x...) do { } while (0)
12294 +#endif /* _VX_DEBUG_H */
12295 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/debug_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/debug_cmd.h
12296 --- linux-3.0-rc5/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
12297 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/debug_cmd.h 2011-06-10 22:11:24.000000000 +0200
12299 +#ifndef _VX_DEBUG_CMD_H
12300 +#define _VX_DEBUG_CMD_H
12303 +/* debug commands */
12305 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
12307 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
12308 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
12310 +struct vcmd_read_history_v0 {
12313 + char __user *data;
12316 +struct vcmd_read_monitor_v0 {
12319 + char __user *data;
12325 +#ifdef CONFIG_COMPAT
12327 +#include <asm/compat.h>
12329 +struct vcmd_read_history_v0_x32 {
12332 + compat_uptr_t data_ptr;
12335 +struct vcmd_read_monitor_v0_x32 {
12338 + compat_uptr_t data_ptr;
12341 +#endif /* CONFIG_COMPAT */
12343 +extern int vc_dump_history(uint32_t);
12345 +extern int vc_read_history(uint32_t, void __user *);
12346 +extern int vc_read_monitor(uint32_t, void __user *);
12348 +#ifdef CONFIG_COMPAT
12350 +extern int vc_read_history_x32(uint32_t, void __user *);
12351 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12353 +#endif /* CONFIG_COMPAT */
12355 +#endif /* __KERNEL__ */
12356 +#endif /* _VX_DEBUG_CMD_H */
12357 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/device.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/device.h
12358 --- linux-3.0-rc5/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
12359 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/device.h 2011-06-10 22:11:24.000000000 +0200
12361 +#ifndef _VX_DEVICE_H
12362 +#define _VX_DEVICE_H
12365 +#define DATTR_CREATE 0x00000001
12366 +#define DATTR_OPEN 0x00000002
12368 +#define DATTR_REMAP 0x00000010
12370 +#define DATTR_MASK 0x00000013
12373 +#else /* _VX_DEVICE_H */
12374 +#warning duplicate inclusion
12375 +#endif /* _VX_DEVICE_H */
12376 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/device_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/device_cmd.h
12377 --- linux-3.0-rc5/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
12378 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/device_cmd.h 2011-06-10 22:11:24.000000000 +0200
12380 +#ifndef _VX_DEVICE_CMD_H
12381 +#define _VX_DEVICE_CMD_H
12384 +/* device vserver commands */
12386 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
12387 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
12389 +struct vcmd_set_mapping_v0 {
12390 + const char __user *device;
12391 + const char __user *target;
12398 +#ifdef CONFIG_COMPAT
12400 +#include <asm/compat.h>
12402 +struct vcmd_set_mapping_v0_x32 {
12403 + compat_uptr_t device_ptr;
12404 + compat_uptr_t target_ptr;
12408 +#endif /* CONFIG_COMPAT */
12410 +#include <linux/compiler.h>
12412 +extern int vc_set_mapping(struct vx_info *, void __user *);
12413 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12415 +#ifdef CONFIG_COMPAT
12417 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12418 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12420 +#endif /* CONFIG_COMPAT */
12422 +#endif /* __KERNEL__ */
12423 +#endif /* _VX_DEVICE_CMD_H */
12424 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/device_def.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/device_def.h
12425 --- linux-3.0-rc5/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
12426 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/device_def.h 2011-06-10 22:11:24.000000000 +0200
12428 +#ifndef _VX_DEVICE_DEF_H
12429 +#define _VX_DEVICE_DEF_H
12431 +#include <linux/types.h>
12433 +struct vx_dmap_target {
12438 +struct _vx_device {
12439 +#ifdef CONFIG_VSERVER_DEVICE
12440 + struct vx_dmap_target targets[2];
12444 +#endif /* _VX_DEVICE_DEF_H */
12445 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/dlimit.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/dlimit.h
12446 --- linux-3.0-rc5/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
12447 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/dlimit.h 2011-06-10 22:11:24.000000000 +0200
12449 +#ifndef _VX_DLIMIT_H
12450 +#define _VX_DLIMIT_H
12452 +#include "switch.h"
12457 +/* keep in sync with CDLIM_INFINITY */
12459 +#define DLIM_INFINITY (~0ULL)
12461 +#include <linux/spinlock.h>
12462 +#include <linux/rcupdate.h>
12464 +struct super_block;
12467 + struct hlist_node dl_hlist; /* linked list of contexts */
12468 + struct rcu_head dl_rcu; /* the rcu head */
12469 + tag_t dl_tag; /* context tag */
12470 + atomic_t dl_usecnt; /* usage count */
12471 + atomic_t dl_refcnt; /* reference count */
12473 + struct super_block *dl_sb; /* associated superblock */
12475 + spinlock_t dl_lock; /* protect the values */
12477 + unsigned long long dl_space_used; /* used space in bytes */
12478 + unsigned long long dl_space_total; /* maximum space in bytes */
12479 + unsigned long dl_inodes_used; /* used inodes */
12480 + unsigned long dl_inodes_total; /* maximum inodes */
12482 + unsigned int dl_nrlmult; /* non root limit mult */
12487 +extern void rcu_free_dl_info(struct rcu_head *);
12488 +extern void unhash_dl_info(struct dl_info *);
12490 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12495 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12497 +typedef uint64_t dlsize_t;
12499 +#endif /* __KERNEL__ */
12500 +#else /* _VX_DLIMIT_H */
12501 +#warning duplicate inclusion
12502 +#endif /* _VX_DLIMIT_H */
12503 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/dlimit_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/dlimit_cmd.h
12504 --- linux-3.0-rc5/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12505 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/dlimit_cmd.h 2011-06-10 22:11:24.000000000 +0200
12507 +#ifndef _VX_DLIMIT_CMD_H
12508 +#define _VX_DLIMIT_CMD_H
12511 +/* dlimit vserver commands */
12513 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12514 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12516 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12517 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12519 +struct vcmd_ctx_dlimit_base_v0 {
12520 + const char __user *name;
12524 +struct vcmd_ctx_dlimit_v0 {
12525 + const char __user *name;
12526 + uint32_t space_used; /* used space in kbytes */
12527 + uint32_t space_total; /* maximum space in kbytes */
12528 + uint32_t inodes_used; /* used inodes */
12529 + uint32_t inodes_total; /* maximum inodes */
12530 + uint32_t reserved; /* reserved for root in % */
12534 +#define CDLIM_UNSET ((uint32_t)0UL)
12535 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12536 +#define CDLIM_KEEP ((uint32_t)~1UL)
12538 +#define DLIME_UNIT 0
12539 +#define DLIME_KILO 1
12540 +#define DLIME_MEGA 2
12541 +#define DLIME_GIGA 3
12543 +#define DLIMF_SHIFT 0x10
12545 +#define DLIMS_USED 0
12546 +#define DLIMS_TOTAL 2
12549 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12551 + int exp = (flags & DLIMF_SHIFT) ?
12552 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12553 + return ((uint64_t)val) << (10 * exp);
12557 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12561 + if (*flags & DLIMF_SHIFT) {
12562 + while (val > (1LL << 32) && (exp < 3)) {
12566 + *flags &= ~(DLIME_GIGA << shift);
12567 + *flags |= exp << shift;
12575 +#ifdef CONFIG_COMPAT
12577 +#include <asm/compat.h>
12579 +struct vcmd_ctx_dlimit_base_v0_x32 {
12580 + compat_uptr_t name_ptr;
12584 +struct vcmd_ctx_dlimit_v0_x32 {
12585 + compat_uptr_t name_ptr;
12586 + uint32_t space_used; /* used space in kbytes */
12587 + uint32_t space_total; /* maximum space in kbytes */
12588 + uint32_t inodes_used; /* used inodes */
12589 + uint32_t inodes_total; /* maximum inodes */
12590 + uint32_t reserved; /* reserved for root in % */
12594 +#endif /* CONFIG_COMPAT */
12596 +#include <linux/compiler.h>
12598 +extern int vc_add_dlimit(uint32_t, void __user *);
12599 +extern int vc_rem_dlimit(uint32_t, void __user *);
12601 +extern int vc_set_dlimit(uint32_t, void __user *);
12602 +extern int vc_get_dlimit(uint32_t, void __user *);
12604 +#ifdef CONFIG_COMPAT
12606 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12607 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12609 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12610 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12612 +#endif /* CONFIG_COMPAT */
12614 +#endif /* __KERNEL__ */
12615 +#endif /* _VX_DLIMIT_CMD_H */
12616 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/global.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/global.h
12617 --- linux-3.0-rc5/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12618 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/global.h 2011-06-10 22:11:24.000000000 +0200
12620 +#ifndef _VX_GLOBAL_H
12621 +#define _VX_GLOBAL_H
12624 +extern atomic_t vx_global_ctotal;
12625 +extern atomic_t vx_global_cactive;
12627 +extern atomic_t nx_global_ctotal;
12628 +extern atomic_t nx_global_cactive;
12630 +extern atomic_t vs_global_nsproxy;
12631 +extern atomic_t vs_global_fs;
12632 +extern atomic_t vs_global_mnt_ns;
12633 +extern atomic_t vs_global_uts_ns;
12634 +extern atomic_t vs_global_user_ns;
12635 +extern atomic_t vs_global_pid_ns;
12638 +#endif /* _VX_GLOBAL_H */
12639 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/history.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/history.h
12640 --- linux-3.0-rc5/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12641 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/history.h 2011-06-10 22:11:24.000000000 +0200
12643 +#ifndef _VX_HISTORY_H
12644 +#define _VX_HISTORY_H
12649 + VXH_THROW_OOPS = 1,
12653 + VXH_INIT_VX_INFO,
12656 + VXH_CLAIM_VX_INFO,
12657 + VXH_RELEASE_VX_INFO,
12658 + VXH_ALLOC_VX_INFO,
12659 + VXH_DEALLOC_VX_INFO,
12660 + VXH_HASH_VX_INFO,
12661 + VXH_UNHASH_VX_INFO,
12663 + VXH_LOOKUP_VX_INFO,
12664 + VXH_CREATE_VX_INFO,
12667 +struct _vxhe_vxi {
12668 + struct vx_info *ptr;
12674 +struct _vxhe_set_clr {
12678 +struct _vxhe_loc_lookup {
12682 +struct _vx_hist_entry {
12684 + unsigned short seq;
12685 + unsigned short type;
12686 + struct _vxhe_vxi vxi;
12688 + struct _vxhe_set_clr sc;
12689 + struct _vxhe_loc_lookup ll;
12693 +#ifdef CONFIG_VSERVER_HISTORY
12695 +extern unsigned volatile int vxh_active;
12697 +struct _vx_hist_entry *vxh_advance(void *loc);
12701 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12703 + entry->vxi.ptr = vxi;
12705 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12706 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12707 + entry->vxi.xid = vxi->vx_id;
12712 +#define __HERE__ current_text_addr()
12714 +#define __VXH_BODY(__type, __data, __here) \
12715 + struct _vx_hist_entry *entry; \
12717 + preempt_disable(); \
12718 + entry = vxh_advance(__here); \
12720 + entry->type = __type; \
12721 + preempt_enable();
12724 + /* pass vxi only */
12726 +#define __VXH_SMPL \
12727 + __vxh_copy_vxi(entry, vxi)
12730 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12732 + __VXH_BODY(__type, __VXH_SMPL, __here)
12735 + /* pass vxi and data (void *) */
12737 +#define __VXH_DATA \
12738 + __vxh_copy_vxi(entry, vxi); \
12739 + entry->sc.data = data
12742 +void __vxh_data(struct vx_info *vxi, void *data,
12743 + int __type, void *__here)
12745 + __VXH_BODY(__type, __VXH_DATA, __here)
12748 + /* pass vxi and arg (long) */
12750 +#define __VXH_LONG \
12751 + __vxh_copy_vxi(entry, vxi); \
12752 + entry->ll.arg = arg
12755 +void __vxh_long(struct vx_info *vxi, long arg,
12756 + int __type, void *__here)
12758 + __VXH_BODY(__type, __VXH_LONG, __here)
12763 +void __vxh_throw_oops(void *__here)
12765 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12766 + /* prevent further acquisition */
12771 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
12773 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
12774 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
12776 +#define __vxh_init_vx_info(v, d, h) \
12777 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
12778 +#define __vxh_set_vx_info(v, d, h) \
12779 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
12780 +#define __vxh_clr_vx_info(v, d, h) \
12781 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12783 +#define __vxh_claim_vx_info(v, d, h) \
12784 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12785 +#define __vxh_release_vx_info(v, d, h) \
12786 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12788 +#define vxh_alloc_vx_info(v) \
12789 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12790 +#define vxh_dealloc_vx_info(v) \
12791 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12793 +#define vxh_hash_vx_info(v) \
12794 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12795 +#define vxh_unhash_vx_info(v) \
12796 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12798 +#define vxh_loc_vx_info(v, l) \
12799 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
12800 +#define vxh_lookup_vx_info(v, l) \
12801 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
12802 +#define vxh_create_vx_info(v, l) \
12803 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
12805 +extern void vxh_dump_history(void);
12808 +#else /* CONFIG_VSERVER_HISTORY */
12810 +#define __HERE__ 0
12812 +#define vxh_throw_oops() do { } while (0)
12814 +#define __vxh_get_vx_info(v, h) do { } while (0)
12815 +#define __vxh_put_vx_info(v, h) do { } while (0)
12817 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
12818 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
12819 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
12821 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
12822 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
12824 +#define vxh_alloc_vx_info(v) do { } while (0)
12825 +#define vxh_dealloc_vx_info(v) do { } while (0)
12827 +#define vxh_hash_vx_info(v) do { } while (0)
12828 +#define vxh_unhash_vx_info(v) do { } while (0)
12830 +#define vxh_loc_vx_info(v, l) do { } while (0)
12831 +#define vxh_lookup_vx_info(v, l) do { } while (0)
12832 +#define vxh_create_vx_info(v, l) do { } while (0)
12834 +#define vxh_dump_history() do { } while (0)
12837 +#endif /* CONFIG_VSERVER_HISTORY */
12839 +#endif /* _VX_HISTORY_H */
12840 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/inode.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/inode.h
12841 --- linux-3.0-rc5/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
12842 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/inode.h 2011-06-10 22:11:24.000000000 +0200
12844 +#ifndef _VX_INODE_H
12845 +#define _VX_INODE_H
12848 +#define IATTR_TAG 0x01000000
12850 +#define IATTR_ADMIN 0x00000001
12851 +#define IATTR_WATCH 0x00000002
12852 +#define IATTR_HIDE 0x00000004
12853 +#define IATTR_FLAGS 0x00000007
12855 +#define IATTR_BARRIER 0x00010000
12856 +#define IATTR_IXUNLINK 0x00020000
12857 +#define IATTR_IMMUTABLE 0x00040000
12858 +#define IATTR_COW 0x00080000
12863 +#ifdef CONFIG_VSERVER_PROC_SECURE
12864 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12865 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12867 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12868 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12871 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12873 +#endif /* __KERNEL__ */
12875 +/* inode ioctls */
12877 +#define FIOC_GETXFLG _IOR('x', 5, long)
12878 +#define FIOC_SETXFLG _IOW('x', 6, long)
12880 +#else /* _VX_INODE_H */
12881 +#warning duplicate inclusion
12882 +#endif /* _VX_INODE_H */
12883 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/inode_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/inode_cmd.h
12884 --- linux-3.0-rc5/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
12885 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/inode_cmd.h 2011-06-10 22:11:24.000000000 +0200
12887 +#ifndef _VX_INODE_CMD_H
12888 +#define _VX_INODE_CMD_H
12891 +/* inode vserver commands */
12893 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
12894 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
12896 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
12897 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
12899 +struct vcmd_ctx_iattr_v1 {
12900 + const char __user *name;
12906 +struct vcmd_ctx_fiattr_v0 {
12916 +#ifdef CONFIG_COMPAT
12918 +#include <asm/compat.h>
12920 +struct vcmd_ctx_iattr_v1_x32 {
12921 + compat_uptr_t name_ptr;
12927 +#endif /* CONFIG_COMPAT */
12929 +#include <linux/compiler.h>
12931 +extern int vc_get_iattr(void __user *);
12932 +extern int vc_set_iattr(void __user *);
12934 +extern int vc_fget_iattr(uint32_t, void __user *);
12935 +extern int vc_fset_iattr(uint32_t, void __user *);
12937 +#ifdef CONFIG_COMPAT
12939 +extern int vc_get_iattr_x32(void __user *);
12940 +extern int vc_set_iattr_x32(void __user *);
12942 +#endif /* CONFIG_COMPAT */
12944 +#endif /* __KERNEL__ */
12945 +#endif /* _VX_INODE_CMD_H */
12946 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/limit.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/limit.h
12947 --- linux-3.0-rc5/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12948 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/limit.h 2011-06-10 22:11:24.000000000 +0200
12950 +#ifndef _VX_LIMIT_H
12951 +#define _VX_LIMIT_H
12953 +#define VLIMIT_NSOCK 16
12954 +#define VLIMIT_OPENFD 17
12955 +#define VLIMIT_ANON 18
12956 +#define VLIMIT_SHMEM 19
12957 +#define VLIMIT_SEMARY 20
12958 +#define VLIMIT_NSEMS 21
12959 +#define VLIMIT_DENTRY 22
12960 +#define VLIMIT_MAPPED 23
12965 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12967 +/* keep in sync with CRLIM_INFINITY */
12969 +#define VLIM_INFINITY (~0ULL)
12971 +#include <asm/atomic.h>
12972 +#include <asm/resource.h>
12974 +#ifndef RLIM_INFINITY
12975 +#warning RLIM_INFINITY is undefined
12978 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12980 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12981 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12983 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12984 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12985 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12987 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12988 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12990 +typedef atomic_long_t rlim_atomic_t;
12991 +typedef unsigned long rlim_t;
12993 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12994 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12995 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12996 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12997 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12998 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
13001 +#if (RLIM_INFINITY == VLIM_INFINITY)
13002 +#define VX_VLIM(r) ((long long)(long)(r))
13003 +#define VX_RLIM(v) ((rlim_t)(v))
13005 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
13006 + ? VLIM_INFINITY : (long long)(r))
13007 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
13008 + ? RLIM_INFINITY : (rlim_t)(v))
13013 +void vx_vsi_meminfo(struct sysinfo *);
13014 +void vx_vsi_swapinfo(struct sysinfo *);
13015 +long vx_vsi_cached(struct sysinfo *);
13017 +#define NUM_LIMITS 24
13019 +#endif /* __KERNEL__ */
13020 +#endif /* _VX_LIMIT_H */
13021 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/limit_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/limit_cmd.h
13022 --- linux-3.0-rc5/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
13023 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/limit_cmd.h 2011-06-10 22:11:24.000000000 +0200
13025 +#ifndef _VX_LIMIT_CMD_H
13026 +#define _VX_LIMIT_CMD_H
13029 +/* rlimit vserver commands */
13031 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
13032 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
13033 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
13034 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
13035 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
13037 +struct vcmd_ctx_rlimit_v0 {
13039 + uint64_t minimum;
13040 + uint64_t softlimit;
13041 + uint64_t maximum;
13044 +struct vcmd_ctx_rlimit_mask_v0 {
13045 + uint32_t minimum;
13046 + uint32_t softlimit;
13047 + uint32_t maximum;
13050 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
13052 +struct vcmd_rlimit_stat_v0 {
13056 + uint64_t minimum;
13057 + uint64_t maximum;
13060 +#define CRLIM_UNSET (0ULL)
13061 +#define CRLIM_INFINITY (~0ULL)
13062 +#define CRLIM_KEEP (~1ULL)
13066 +#ifdef CONFIG_IA32_EMULATION
13068 +struct vcmd_ctx_rlimit_v0_x32 {
13070 + uint64_t minimum;
13071 + uint64_t softlimit;
13072 + uint64_t maximum;
13073 +} __attribute__ ((packed));
13075 +#endif /* CONFIG_IA32_EMULATION */
13077 +#include <linux/compiler.h>
13079 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
13080 +extern int vc_get_rlimit(struct vx_info *, void __user *);
13081 +extern int vc_set_rlimit(struct vx_info *, void __user *);
13082 +extern int vc_reset_hits(struct vx_info *, void __user *);
13083 +extern int vc_reset_minmax(struct vx_info *, void __user *);
13085 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
13087 +#ifdef CONFIG_IA32_EMULATION
13089 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
13090 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
13092 +#endif /* CONFIG_IA32_EMULATION */
13094 +#endif /* __KERNEL__ */
13095 +#endif /* _VX_LIMIT_CMD_H */
13096 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/limit_def.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/limit_def.h
13097 --- linux-3.0-rc5/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
13098 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/limit_def.h 2011-06-10 22:11:24.000000000 +0200
13100 +#ifndef _VX_LIMIT_DEF_H
13101 +#define _VX_LIMIT_DEF_H
13103 +#include <asm/atomic.h>
13104 +#include <asm/resource.h>
13106 +#include "limit.h"
13109 +struct _vx_res_limit {
13110 + rlim_t soft; /* Context soft limit */
13111 + rlim_t hard; /* Context hard limit */
13113 + rlim_atomic_t rcur; /* Current value */
13114 + rlim_t rmin; /* Context minimum */
13115 + rlim_t rmax; /* Context maximum */
13117 + atomic_t lhit; /* Limit hits */
13120 +/* context sub struct */
13122 +struct _vx_limit {
13123 + struct _vx_res_limit res[NUM_LIMITS];
13126 +#ifdef CONFIG_VSERVER_DEBUG
13128 +static inline void __dump_vx_limit(struct _vx_limit *limit)
13132 + printk("\t_vx_limit:");
13133 + for (i = 0; i < NUM_LIMITS; i++) {
13134 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
13135 + i, (unsigned long)__rlim_get(limit, i),
13136 + (unsigned long)__rlim_rmin(limit, i),
13137 + (unsigned long)__rlim_rmax(limit, i),
13138 + (long)__rlim_soft(limit, i),
13139 + (long)__rlim_hard(limit, i),
13140 + atomic_read(&__rlim_lhit(limit, i)));
13146 +#endif /* _VX_LIMIT_DEF_H */
13147 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/limit_int.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/limit_int.h
13148 --- linux-3.0-rc5/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
13149 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/limit_int.h 2011-06-10 22:11:24.000000000 +0200
13151 +#ifndef _VX_LIMIT_INT_H
13152 +#define _VX_LIMIT_INT_H
13154 +#include "context.h"
13158 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
13159 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
13161 +extern const char *vlimit_name[NUM_LIMITS];
13163 +static inline void __vx_acc_cres(struct vx_info *vxi,
13164 + int res, int dir, void *_data, char *_file, int _line)
13166 + if (VXD_RCRES_COND(res))
13167 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
13168 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13169 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13170 + (dir > 0) ? "++" : "--", _data, _file, _line);
13175 + __rlim_inc(&vxi->limit, res);
13177 + __rlim_dec(&vxi->limit, res);
13180 +static inline void __vx_add_cres(struct vx_info *vxi,
13181 + int res, int amount, void *_data, char *_file, int _line)
13183 + if (VXD_RCRES_COND(res))
13184 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
13185 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13186 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13187 + amount, _data, _file, _line);
13192 + __rlim_add(&vxi->limit, res, amount);
13196 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
13198 + int cond = (value > __rlim_rmax(limit, res));
13201 + __rlim_rmax(limit, res) = value;
13206 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13208 + int cond = (value < __rlim_rmin(limit, res));
13211 + __rlim_rmin(limit, res) = value;
13216 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13218 + if (!__vx_cres_adjust_max(limit, res, value))
13219 + __vx_cres_adjust_min(limit, res, value);
13224 + +1 ... no limit hit
13225 + -1 ... over soft limit
13226 + 0 ... over hard limit */
13228 +static inline int __vx_cres_avail(struct vx_info *vxi,
13229 + int res, int num, char *_file, int _line)
13231 + struct _vx_limit *limit;
13234 + if (VXD_RLIMIT_COND(res))
13235 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13236 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13237 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13238 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13239 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13240 + num, _file, _line);
13244 + limit = &vxi->limit;
13245 + value = __rlim_get(limit, res);
13247 + if (!__vx_cres_adjust_max(limit, res, value))
13248 + __vx_cres_adjust_min(limit, res, value);
13253 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
13255 + if (value + num <= __rlim_soft(limit, res))
13258 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
13260 + if (value + num <= __rlim_hard(limit, res))
13263 + __rlim_hit(limit, res);
13268 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13271 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13273 + rlim_t value, sum = 0;
13276 + while ((res = *array++)) {
13277 + value = __rlim_get(limit, res);
13278 + __vx_cres_fixup(limit, res, value);
13285 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13287 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
13288 + int res = *array;
13290 + if (value == __rlim_get(limit, res))
13293 + __rlim_set(limit, res, value);
13294 + /* now adjust min/max */
13295 + if (!__vx_cres_adjust_max(limit, res, value))
13296 + __vx_cres_adjust_min(limit, res, value);
13301 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13302 + const int *array, int num, char *_file, int _line)
13304 + struct _vx_limit *limit;
13305 + rlim_t value = 0;
13313 + limit = &vxi->limit;
13315 + value = __vx_cres_array_sum(limit, array + 1);
13317 + __rlim_set(limit, res, value);
13318 + __vx_cres_fixup(limit, res, value);
13320 + return __vx_cres_avail(vxi, res, num, _file, _line);
13324 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13329 + /* complex resources first */
13330 + if ((id < 0) || (id == RLIMIT_RSS))
13331 + __vx_cres_array_fixup(limit, VLA_RSS);
13333 + for (res = 0; res < NUM_LIMITS; res++) {
13334 + if ((id > 0) && (res != id))
13337 + value = __rlim_get(limit, res);
13338 + __vx_cres_fixup(limit, res, value);
13340 + /* not supposed to happen, maybe warn? */
13341 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13342 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13347 +#endif /* __KERNEL__ */
13348 +#endif /* _VX_LIMIT_INT_H */
13349 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/monitor.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/monitor.h
13350 --- linux-3.0-rc5/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
13351 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/monitor.h 2011-06-10 22:11:24.000000000 +0200
13353 +#ifndef _VX_MONITOR_H
13354 +#define _VX_MONITOR_H
13356 +#include <linux/types.h>
13363 + VXM_UPDATE = 0x20,
13367 + VXM_RQINFO_1 = 0x24,
13370 + VXM_ACTIVATE = 0x40,
13377 + VXM_MIGRATE = 0x48,
13380 + /* all other bits are flags */
13381 + VXM_SCHED = 0x80,
13384 +struct _vxm_update_1 {
13385 + uint32_t tokens_max;
13386 + uint32_t fill_rate;
13387 + uint32_t interval;
13390 +struct _vxm_update_2 {
13391 + uint32_t tokens_min;
13392 + uint32_t fill_rate;
13393 + uint32_t interval;
13396 +struct _vxm_rqinfo_1 {
13397 + uint16_t running;
13401 + uint32_t idle_tokens;
13404 +struct _vxm_rqinfo_2 {
13405 + uint32_t norm_time;
13406 + uint32_t idle_time;
13407 + uint32_t idle_skip;
13410 +struct _vxm_sched {
13412 + uint32_t norm_time;
13413 + uint32_t idle_time;
13416 +struct _vxm_task {
13421 +struct _vxm_event {
13430 + struct _vxm_task tsk;
13434 +struct _vx_mon_entry {
13438 + struct _vxm_event ev;
13439 + struct _vxm_sched sd;
13440 + struct _vxm_update_1 u1;
13441 + struct _vxm_update_2 u2;
13442 + struct _vxm_rqinfo_1 q1;
13443 + struct _vxm_rqinfo_2 q2;
13448 +#endif /* _VX_MONITOR_H */
13449 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/network.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/network.h
13450 --- linux-3.0-rc5/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
13451 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/network.h 2011-06-10 22:11:24.000000000 +0200
13453 +#ifndef _VX_NETWORK_H
13454 +#define _VX_NETWORK_H
13456 +#include <linux/types.h>
13459 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13462 +/* network flags */
13464 +#define NXF_INFO_PRIVATE 0x00000008
13466 +#define NXF_SINGLE_IP 0x00000100
13467 +#define NXF_LBACK_REMAP 0x00000200
13468 +#define NXF_LBACK_ALLOW 0x00000400
13470 +#define NXF_HIDE_NETIF 0x02000000
13471 +#define NXF_HIDE_LBACK 0x04000000
13473 +#define NXF_STATE_SETUP (1ULL << 32)
13474 +#define NXF_STATE_ADMIN (1ULL << 34)
13476 +#define NXF_SC_HELPER (1ULL << 36)
13477 +#define NXF_PERSISTENT (1ULL << 38)
13479 +#define NXF_ONE_TIME (0x0005ULL << 32)
13482 +#define NXF_INIT_SET (__nxf_init_set())
13484 +static inline uint64_t __nxf_init_set(void) {
13485 + return NXF_STATE_ADMIN
13486 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13487 + | NXF_LBACK_REMAP
13490 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13493 + | NXF_HIDE_NETIF;
13497 +/* network caps */
13499 +#define NXC_TUN_CREATE 0x00000001
13501 +#define NXC_RAW_ICMP 0x00000100
13504 +/* address types */
13506 +#define NXA_TYPE_IPV4 0x0001
13507 +#define NXA_TYPE_IPV6 0x0002
13509 +#define NXA_TYPE_NONE 0x0000
13510 +#define NXA_TYPE_ANY 0x00FF
13512 +#define NXA_TYPE_ADDR 0x0010
13513 +#define NXA_TYPE_MASK 0x0020
13514 +#define NXA_TYPE_RANGE 0x0040
13516 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13518 +#define NXA_MOD_BCAST 0x0100
13519 +#define NXA_MOD_LBACK 0x0200
13521 +#define NXA_LOOPBACK 0x1000
13523 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13524 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13528 +#include <linux/list.h>
13529 +#include <linux/spinlock.h>
13530 +#include <linux/rcupdate.h>
13531 +#include <linux/in.h>
13532 +#include <linux/in6.h>
13533 +#include <asm/atomic.h>
13535 +struct nx_addr_v4 {
13536 + struct nx_addr_v4 *next;
13537 + struct in_addr ip[2];
13538 + struct in_addr mask;
13543 +struct nx_addr_v6 {
13544 + struct nx_addr_v6 *next;
13545 + struct in6_addr ip;
13546 + struct in6_addr mask;
13553 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13554 + nid_t nx_id; /* vnet id */
13555 + atomic_t nx_usecnt; /* usage count */
13556 + atomic_t nx_tasks; /* tasks count */
13557 + int nx_state; /* context state */
13559 + uint64_t nx_flags; /* network flag word */
13560 + uint64_t nx_ncaps; /* network capabilities */
13562 + struct in_addr v4_lback; /* Loopback address */
13563 + struct in_addr v4_bcast; /* Broadcast address */
13564 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13565 +#ifdef CONFIG_IPV6
13566 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13568 + char nx_name[65]; /* network context name */
13572 +/* status flags */
13574 +#define NXS_HASHED 0x0001
13575 +#define NXS_SHUTDOWN 0x0100
13576 +#define NXS_RELEASED 0x8000
13578 +extern struct nx_info *lookup_nx_info(int);
13580 +extern int get_nid_list(int, unsigned int *, int);
13581 +extern int nid_is_hashed(nid_t);
13583 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13585 +extern long vs_net_change(struct nx_info *, unsigned int);
13590 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13591 +#ifdef CONFIG_IPV6
13592 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13594 +#define NX_IPV6(n) (0)
13597 +#endif /* __KERNEL__ */
13598 +#endif /* _VX_NETWORK_H */
13599 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/network_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/network_cmd.h
13600 --- linux-3.0-rc5/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13601 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/network_cmd.h 2011-06-10 22:11:24.000000000 +0200
13603 +#ifndef _VX_NETWORK_CMD_H
13604 +#define _VX_NETWORK_CMD_H
13607 +/* vinfo commands */
13609 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13612 +extern int vc_task_nid(uint32_t);
13614 +#endif /* __KERNEL__ */
13616 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13618 +struct vcmd_nx_info_v0 {
13620 + /* more to come */
13624 +extern int vc_nx_info(struct nx_info *, void __user *);
13626 +#endif /* __KERNEL__ */
13628 +#include <linux/in.h>
13629 +#include <linux/in6.h>
13631 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13632 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13634 +struct vcmd_net_create {
13635 + uint64_t flagword;
13638 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13640 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13641 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13643 +struct vcmd_net_addr_v0 {
13646 + struct in_addr ip[4];
13647 + struct in_addr mask[4];
13650 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13651 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13653 +struct vcmd_net_addr_ipv4_v1 {
13656 + struct in_addr ip;
13657 + struct in_addr mask;
13660 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13661 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13663 +struct vcmd_net_addr_ipv4_v2 {
13666 + struct in_addr ip;
13667 + struct in_addr ip2;
13668 + struct in_addr mask;
13671 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13672 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13674 +struct vcmd_net_addr_ipv6_v1 {
13678 + struct in6_addr ip;
13679 + struct in6_addr mask;
13682 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13683 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13685 +struct vcmd_match_ipv4_v0 {
13690 + struct in_addr ip;
13691 + struct in_addr ip2;
13692 + struct in_addr mask;
13695 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13696 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13698 +struct vcmd_match_ipv6_v0 {
13703 + struct in6_addr ip;
13704 + struct in6_addr ip2;
13705 + struct in6_addr mask;
13710 +extern int vc_net_create(uint32_t, void __user *);
13711 +extern int vc_net_migrate(struct nx_info *, void __user *);
13713 +extern int vc_net_add(struct nx_info *, void __user *);
13714 +extern int vc_net_remove(struct nx_info *, void __user *);
13716 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
13717 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13719 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
13720 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
13722 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13723 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13725 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13726 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13728 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13729 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13731 +#endif /* __KERNEL__ */
13734 +/* flag commands */
13736 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13737 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13739 +struct vcmd_net_flags_v0 {
13740 + uint64_t flagword;
13745 +extern int vc_get_nflags(struct nx_info *, void __user *);
13746 +extern int vc_set_nflags(struct nx_info *, void __user *);
13748 +#endif /* __KERNEL__ */
13751 +/* network caps commands */
13753 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13754 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13756 +struct vcmd_net_caps_v0 {
13762 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13763 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13765 +#endif /* __KERNEL__ */
13766 +#endif /* _VX_CONTEXT_CMD_H */
13767 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/percpu.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/percpu.h
13768 --- linux-3.0-rc5/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13769 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/percpu.h 2011-06-10 22:11:24.000000000 +0200
13771 +#ifndef _VX_PERCPU_H
13772 +#define _VX_PERCPU_H
13774 +#include "cvirt_def.h"
13775 +#include "sched_def.h"
13777 +struct _vx_percpu {
13778 + struct _vx_cvirt_pc cvirt;
13779 + struct _vx_sched_pc sched;
13782 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13784 +#endif /* _VX_PERCPU_H */
13785 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/pid.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/pid.h
13786 --- linux-3.0-rc5/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
13787 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/pid.h 2011-06-10 22:11:24.000000000 +0200
13789 +#ifndef _VSERVER_PID_H
13790 +#define _VSERVER_PID_H
13792 +/* pid faking stuff */
13794 +#define vx_info_map_pid(v, p) \
13795 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13796 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13797 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13798 +#define vx_map_tgid(p) vx_map_pid(p)
13800 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13801 + const char *func, const char *file, int line)
13803 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13804 + vxfprintk(VXD_CBIT(cvirt, 2),
13805 + "vx_map_tgid: %p/%llx: %d -> %d",
13806 + vxi, (long long)vxi->vx_flags, pid,
13807 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13808 + func, file, line);
13811 + if (pid == vxi->vx_initpid)
13817 +#define vx_info_rmap_pid(v, p) \
13818 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
13819 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
13820 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13822 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13823 + const char *func, const char *file, int line)
13825 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13826 + vxfprintk(VXD_CBIT(cvirt, 2),
13827 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13828 + vxi, (long long)vxi->vx_flags, pid,
13829 + (pid == 1) ? vxi->vx_initpid : pid,
13830 + func, file, line);
13831 + if ((pid == 1) && vxi->vx_initpid)
13832 + return vxi->vx_initpid;
13833 + if (pid == vxi->vx_initpid)
13840 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/sched.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/sched.h
13841 --- linux-3.0-rc5/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13842 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/sched.h 2011-06-10 22:11:24.000000000 +0200
13844 +#ifndef _VX_SCHED_H
13845 +#define _VX_SCHED_H
13852 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13857 +void vx_update_load(struct vx_info *);
13860 +void vx_update_sched_param(struct _vx_sched *sched,
13861 + struct _vx_sched_pc *sched_pc);
13863 +#endif /* __KERNEL__ */
13864 +#else /* _VX_SCHED_H */
13865 +#warning duplicate inclusion
13866 +#endif /* _VX_SCHED_H */
13867 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/sched_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/sched_cmd.h
13868 --- linux-3.0-rc5/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
13869 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/sched_cmd.h 2011-06-10 22:11:24.000000000 +0200
13871 +#ifndef _VX_SCHED_CMD_H
13872 +#define _VX_SCHED_CMD_H
13875 +struct vcmd_prio_bias {
13877 + int32_t prio_bias;
13880 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13881 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13885 +#include <linux/compiler.h>
13887 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
13888 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
13890 +#endif /* __KERNEL__ */
13891 +#endif /* _VX_SCHED_CMD_H */
13892 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/sched_def.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/sched_def.h
13893 --- linux-3.0-rc5/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
13894 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/sched_def.h 2011-06-10 22:11:24.000000000 +0200
13896 +#ifndef _VX_SCHED_DEF_H
13897 +#define _VX_SCHED_DEF_H
13899 +#include <linux/spinlock.h>
13900 +#include <linux/jiffies.h>
13901 +#include <linux/cpumask.h>
13902 +#include <asm/atomic.h>
13903 +#include <asm/param.h>
13906 +/* context sub struct */
13908 +struct _vx_sched {
13909 + int prio_bias; /* bias offset for priority */
13911 + cpumask_t update; /* CPUs which should update */
13914 +struct _vx_sched_pc {
13915 + int prio_bias; /* bias offset for priority */
13917 + uint64_t user_ticks; /* token tick events */
13918 + uint64_t sys_ticks; /* token tick events */
13919 + uint64_t hold_ticks; /* token ticks paused */
13923 +#ifdef CONFIG_VSERVER_DEBUG
13925 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13927 + printk("\t_vx_sched:\n");
13928 + printk("\t priority = %4d\n", sched->prio_bias);
13933 +#endif /* _VX_SCHED_DEF_H */
13934 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/signal.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/signal.h
13935 --- linux-3.0-rc5/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13936 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/signal.h 2011-06-10 22:11:24.000000000 +0200
13938 +#ifndef _VX_SIGNAL_H
13939 +#define _VX_SIGNAL_H
13946 +int vx_info_kill(struct vx_info *, int, int);
13948 +#endif /* __KERNEL__ */
13949 +#else /* _VX_SIGNAL_H */
13950 +#warning duplicate inclusion
13951 +#endif /* _VX_SIGNAL_H */
13952 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/signal_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/signal_cmd.h
13953 --- linux-3.0-rc5/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13954 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/signal_cmd.h 2011-06-10 22:11:24.000000000 +0200
13956 +#ifndef _VX_SIGNAL_CMD_H
13957 +#define _VX_SIGNAL_CMD_H
13960 +/* signalling vserver commands */
13962 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13963 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13965 +struct vcmd_ctx_kill_v0 {
13970 +struct vcmd_wait_exit_v0 {
13971 + int32_t reboot_cmd;
13972 + int32_t exit_code;
13977 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13978 +extern int vc_wait_exit(struct vx_info *, void __user *);
13980 +#endif /* __KERNEL__ */
13982 +/* process alteration commands */
13984 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13985 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13987 +struct vcmd_pflags_v0 {
13988 + uint32_t flagword;
13994 +extern int vc_get_pflags(uint32_t pid, void __user *);
13995 +extern int vc_set_pflags(uint32_t pid, void __user *);
13997 +#endif /* __KERNEL__ */
13998 +#endif /* _VX_SIGNAL_CMD_H */
13999 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/space.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/space.h
14000 --- linux-3.0-rc5/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
14001 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/space.h 2011-06-10 22:11:24.000000000 +0200
14003 +#ifndef _VX_SPACE_H
14004 +#define _VX_SPACE_H
14006 +#include <linux/types.h>
14010 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
14012 +#else /* _VX_SPACE_H */
14013 +#warning duplicate inclusion
14014 +#endif /* _VX_SPACE_H */
14015 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/space_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/space_cmd.h
14016 --- linux-3.0-rc5/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
14017 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/space_cmd.h 2011-06-10 22:11:24.000000000 +0200
14019 +#ifndef _VX_SPACE_CMD_H
14020 +#define _VX_SPACE_CMD_H
14023 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
14024 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
14025 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
14027 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
14028 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
14029 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
14031 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
14033 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
14034 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
14037 +struct vcmd_space_mask_v1 {
14041 +struct vcmd_space_mask_v2 {
14049 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
14050 +extern int vc_set_space_v1(struct vx_info *, void __user *);
14051 +extern int vc_enter_space(struct vx_info *, void __user *);
14052 +extern int vc_set_space(struct vx_info *, void __user *);
14053 +extern int vc_get_space_mask(void __user *, int);
14055 +#endif /* __KERNEL__ */
14056 +#endif /* _VX_SPACE_CMD_H */
14057 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/switch.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/switch.h
14058 --- linux-3.0-rc5/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
14059 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/switch.h 2011-06-10 22:11:24.000000000 +0200
14061 +#ifndef _VX_SWITCH_H
14062 +#define _VX_SWITCH_H
14064 +#include <linux/types.h>
14067 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
14068 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
14069 +#define VC_VERSION(c) ((c) & 0xFFF)
14071 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
14072 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
14076 + Syscall Matrix V2.8
14078 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
14079 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
14080 + |INFO |SETUP | |MOVE | | | | | |
14081 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14082 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
14083 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
14084 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14085 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
14086 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
14087 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14088 + MEMORY | | | | |MEMCTRL| | |SWAP | |
14089 + | 16| 17| 18| 19| 20| 21| | 22| 23|
14090 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14091 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
14092 + | 24| 25| 26| 27| 28| 29| | 30| 31|
14093 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14094 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
14095 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
14096 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14097 + OTHER |VSTAT | | | | | | |VINFO | |
14098 + | 40| 41| 42| 43| 44| 45| | 46| 47|
14099 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
14100 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
14101 + | 48| 49| 50| 51| 52| 53| | 54| 55|
14102 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14103 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
14104 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
14105 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14109 +#define VC_CAT_VERSION 0
14111 +#define VC_CAT_VSETUP 1
14112 +#define VC_CAT_VHOST 2
14114 +#define VC_CAT_DEVICE 6
14116 +#define VC_CAT_VPROC 9
14117 +#define VC_CAT_PROCALT 10
14118 +#define VC_CAT_PROCMIG 11
14119 +#define VC_CAT_PROCTRL 12
14121 +#define VC_CAT_SCHED 14
14122 +#define VC_CAT_MEMCTRL 20
14124 +#define VC_CAT_VNET 25
14125 +#define VC_CAT_NETALT 26
14126 +#define VC_CAT_NETMIG 27
14127 +#define VC_CAT_NETCTRL 28
14129 +#define VC_CAT_TAGMIG 35
14130 +#define VC_CAT_DLIMIT 36
14131 +#define VC_CAT_INODE 38
14133 +#define VC_CAT_VSTAT 40
14134 +#define VC_CAT_VINFO 46
14135 +#define VC_CAT_EVENT 48
14137 +#define VC_CAT_FLAGS 52
14138 +#define VC_CAT_VSPACE 54
14139 +#define VC_CAT_DEBUG 56
14140 +#define VC_CAT_RLIMIT 60
14142 +#define VC_CAT_SYSTEST 61
14143 +#define VC_CAT_COMPAT 63
14145 +/* query version */
14147 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
14148 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
14153 +#include <linux/errno.h>
14155 +#endif /* __KERNEL__ */
14157 +#endif /* _VX_SWITCH_H */
14159 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/tag.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/tag.h
14160 --- linux-3.0-rc5/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
14161 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/tag.h 2011-06-10 22:11:24.000000000 +0200
14166 +#include <linux/types.h>
14169 +#define DX_TAG(in) (IS_TAGGED(in))
14172 +#ifdef CONFIG_TAG_NFSD
14173 +#define DX_TAG_NFSD 1
14175 +#define DX_TAG_NFSD 0
14179 +#ifdef CONFIG_TAGGING_NONE
14181 +#define MAX_UID 0xFFFFFFFF
14182 +#define MAX_GID 0xFFFFFFFF
14184 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
14186 +#define TAGINO_UID(cond, uid, tag) (uid)
14187 +#define TAGINO_GID(cond, gid, tag) (gid)
14192 +#ifdef CONFIG_TAGGING_GID16
14194 +#define MAX_UID 0xFFFFFFFF
14195 +#define MAX_GID 0x0000FFFF
14197 +#define INOTAG_TAG(cond, uid, gid, tag) \
14198 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
14200 +#define TAGINO_UID(cond, uid, tag) (uid)
14201 +#define TAGINO_GID(cond, gid, tag) \
14202 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14207 +#ifdef CONFIG_TAGGING_ID24
14209 +#define MAX_UID 0x00FFFFFF
14210 +#define MAX_GID 0x00FFFFFF
14212 +#define INOTAG_TAG(cond, uid, gid, tag) \
14213 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14215 +#define TAGINO_UID(cond, uid, tag) \
14216 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14217 +#define TAGINO_GID(cond, gid, tag) \
14218 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14223 +#ifdef CONFIG_TAGGING_UID16
14225 +#define MAX_UID 0x0000FFFF
14226 +#define MAX_GID 0xFFFFFFFF
14228 +#define INOTAG_TAG(cond, uid, gid, tag) \
14229 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14231 +#define TAGINO_UID(cond, uid, tag) \
14232 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14233 +#define TAGINO_GID(cond, gid, tag) (gid)
14238 +#ifdef CONFIG_TAGGING_INTERN
14240 +#define MAX_UID 0xFFFFFFFF
14241 +#define MAX_GID 0xFFFFFFFF
14243 +#define INOTAG_TAG(cond, uid, gid, tag) \
14244 + ((cond) ? (tag) : 0)
14246 +#define TAGINO_UID(cond, uid, tag) (uid)
14247 +#define TAGINO_GID(cond, gid, tag) (gid)
14252 +#ifndef CONFIG_TAGGING_NONE
14253 +#define dx_current_fstag(sb) \
14254 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14256 +#define dx_current_fstag(sb) (0)
14259 +#ifndef CONFIG_TAGGING_INTERN
14260 +#define TAGINO_TAG(cond, tag) (0)
14262 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
14265 +#define INOTAG_UID(cond, uid, gid) \
14266 + ((cond) ? ((uid) & MAX_UID) : (uid))
14267 +#define INOTAG_GID(cond, uid, gid) \
14268 + ((cond) ? ((gid) & MAX_GID) : (gid))
14271 +static inline uid_t dx_map_uid(uid_t uid)
14273 + if ((uid > MAX_UID) && (uid != -1))
14275 + return (uid & MAX_UID);
14278 +static inline gid_t dx_map_gid(gid_t gid)
14280 + if ((gid > MAX_GID) && (gid != -1))
14282 + return (gid & MAX_GID);
14290 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14292 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14293 + unsigned long *flags);
14295 +#ifdef CONFIG_PROPAGATE
14297 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14299 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14302 +#define dx_propagate_tag(n, i) do { } while (0)
14305 +#endif /* _DX_TAG_H */
14306 diff -NurpP --minimal linux-3.0-rc5/include/linux/vserver/tag_cmd.h linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/tag_cmd.h
14307 --- linux-3.0-rc5/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
14308 +++ linux-3.0-rc5-vs2.3.1-pre3/include/linux/vserver/tag_cmd.h 2011-06-10 22:11:24.000000000 +0200
14310 +#ifndef _VX_TAG_CMD_H
14311 +#define _VX_TAG_CMD_H
14314 +/* vinfo commands */
14316 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
14319 +extern int vc_task_tag(uint32_t);
14321 +#endif /* __KERNEL__ */
14323 +/* context commands */
14325 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
14328 +extern int vc_tag_migrate(uint32_t);
14330 +#endif /* __KERNEL__ */
14331 +#endif /* _VX_TAG_CMD_H */
14332 diff -NurpP --minimal linux-3.0-rc5/include/net/addrconf.h linux-3.0-rc5-vs2.3.1-pre3/include/net/addrconf.h
14333 --- linux-3.0-rc5/include/net/addrconf.h 2011-07-01 11:14:22.000000000 +0200
14334 +++ linux-3.0-rc5-vs2.3.1-pre3/include/net/addrconf.h 2011-06-10 22:11:24.000000000 +0200
14335 @@ -80,7 +80,8 @@ extern int ipv6_dev_get_saddr(struct n
14336 struct net_device *dev,
14337 const struct in6_addr *daddr,
14338 unsigned int srcprefs,
14339 - struct in6_addr *saddr);
14340 + struct in6_addr *saddr,
14341 + struct nx_info *nxi);
14342 extern int ipv6_get_lladdr(struct net_device *dev,
14343 struct in6_addr *addr,
14344 unsigned char banned_flags);
14345 diff -NurpP --minimal linux-3.0-rc5/include/net/af_unix.h linux-3.0-rc5-vs2.3.1-pre3/include/net/af_unix.h
14346 --- linux-3.0-rc5/include/net/af_unix.h 2011-07-01 11:14:22.000000000 +0200
14347 +++ linux-3.0-rc5-vs2.3.1-pre3/include/net/af_unix.h 2011-06-10 22:11:24.000000000 +0200
14349 #include <linux/socket.h>
14350 #include <linux/un.h>
14351 #include <linux/mutex.h>
14352 +#include <linux/vs_base.h>
14353 #include <net/sock.h>
14355 extern void unix_inflight(struct file *fp);
14356 diff -NurpP --minimal linux-3.0-rc5/include/net/inet_timewait_sock.h linux-3.0-rc5-vs2.3.1-pre3/include/net/inet_timewait_sock.h
14357 --- linux-3.0-rc5/include/net/inet_timewait_sock.h 2011-03-15 18:07:40.000000000 +0100
14358 +++ linux-3.0-rc5-vs2.3.1-pre3/include/net/inet_timewait_sock.h 2011-06-10 22:11:24.000000000 +0200
14359 @@ -113,6 +113,10 @@ struct inet_timewait_sock {
14360 #define tw_net __tw_common.skc_net
14361 #define tw_daddr __tw_common.skc_daddr
14362 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
14363 +#define tw_xid __tw_common.skc_xid
14364 +#define tw_vx_info __tw_common.skc_vx_info
14365 +#define tw_nid __tw_common.skc_nid
14366 +#define tw_nx_info __tw_common.skc_nx_info
14368 volatile unsigned char tw_substate;
14369 unsigned char tw_rcv_wscale;
14370 diff -NurpP --minimal linux-3.0-rc5/include/net/ip6_route.h linux-3.0-rc5-vs2.3.1-pre3/include/net/ip6_route.h
14371 --- linux-3.0-rc5/include/net/ip6_route.h 2011-07-01 11:14:22.000000000 +0200
14372 +++ linux-3.0-rc5-vs2.3.1-pre3/include/net/ip6_route.h 2011-06-16 14:16:51.000000000 +0200
14373 @@ -86,7 +86,8 @@ extern int ip6_route_get_saddr(struct
14374 struct rt6_info *rt,
14375 const struct in6_addr *daddr,
14376 unsigned int prefs,
14377 - struct in6_addr *saddr);
14378 + struct in6_addr *saddr,
14379 + struct nx_info *nxi);
14381 extern struct rt6_info *rt6_lookup(struct net *net,
14382 const struct in6_addr *daddr,
14383 diff -NurpP --minimal linux-3.0-rc5/include/net/route.h linux-3.0-rc5-vs2.3.1-pre3/include/net/route.h
14384 --- linux-3.0-rc5/include/net/route.h 2011-07-01 11:14:22.000000000 +0200
14385 +++ linux-3.0-rc5-vs2.3.1-pre3/include/net/route.h 2011-06-13 18:20:44.000000000 +0200
14386 @@ -202,6 +202,9 @@ static inline void ip_rt_put(struct rtab
14387 dst_release(&rt->dst);
14390 +#include <linux/vs_base.h>
14391 +#include <linux/vs_inet.h>
14393 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14395 extern const __u8 ip_tos2prio[16];
14396 @@ -253,6 +256,9 @@ static inline void ip_route_connect_init
14397 protocol, flow_flags, dst, src, dport, sport);
14400 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
14401 + struct flowi4 *);
14403 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
14404 __be32 dst, __be32 src, u32 tos,
14405 int oif, u8 protocol,
14406 @@ -261,11 +267,24 @@ static inline struct rtable *ip_route_co
14408 struct net *net = sock_net(sk);
14410 + struct nx_info *nx_info = current_nx_info();
14412 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
14413 sport, dport, sk, can_sleep);
14415 - if (!dst || !src) {
14417 + nx_info = sk->sk_nx_info;
14419 + vxdprintk(VXD_CBIT(net, 4),
14420 + "ip_route_connect(%p) %p,%p;%lx",
14421 + sk, nx_info, sk->sk_socket,
14422 + (sk->sk_socket?sk->sk_socket->flags:0));
14424 + rt = ip_v4_find_src(net, nx_info, fl4);
14428 + if (!fl4->daddr || !fl4->saddr) {
14429 rt = __ip_route_output_key(net, fl4);
14432 diff -NurpP --minimal linux-3.0-rc5/include/net/sock.h linux-3.0-rc5-vs2.3.1-pre3/include/net/sock.h
14433 --- linux-3.0-rc5/include/net/sock.h 2011-07-01 11:14:22.000000000 +0200
14434 +++ linux-3.0-rc5-vs2.3.1-pre3/include/net/sock.h 2011-07-01 11:35:35.000000000 +0200
14435 @@ -149,6 +149,10 @@ struct sock_common {
14436 #ifdef CONFIG_NET_NS
14437 struct net *skc_net;
14440 + struct vx_info *skc_vx_info;
14442 + struct nx_info *skc_nx_info;
14444 * fields between dontcopy_begin/dontcopy_end
14445 * are not copied in sock_copy()
14446 @@ -256,6 +260,10 @@ struct sock {
14447 #define sk_bind_node __sk_common.skc_bind_node
14448 #define sk_prot __sk_common.skc_prot
14449 #define sk_net __sk_common.skc_net
14450 +#define sk_xid __sk_common.skc_xid
14451 +#define sk_vx_info __sk_common.skc_vx_info
14452 +#define sk_nid __sk_common.skc_nid
14453 +#define sk_nx_info __sk_common.skc_nx_info
14454 socket_lock_t sk_lock;
14455 struct sk_buff_head sk_receive_queue;
14457 diff -NurpP --minimal linux-3.0-rc5/init/Kconfig linux-3.0-rc5-vs2.3.1-pre3/init/Kconfig
14458 --- linux-3.0-rc5/init/Kconfig 2011-07-01 11:14:22.000000000 +0200
14459 +++ linux-3.0-rc5-vs2.3.1-pre3/init/Kconfig 2011-06-22 12:39:15.000000000 +0200
14460 @@ -574,6 +574,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
14462 boolean "Control Group support"
14466 This option adds support for grouping sets of processes together, for
14467 use with process control subsystems such as Cpusets, CFS, memory
14468 diff -NurpP --minimal linux-3.0-rc5/init/main.c linux-3.0-rc5-vs2.3.1-pre3/init/main.c
14469 --- linux-3.0-rc5/init/main.c 2011-07-01 11:14:22.000000000 +0200
14470 +++ linux-3.0-rc5-vs2.3.1-pre3/init/main.c 2011-06-22 12:39:15.000000000 +0200
14472 #include <linux/shmem_fs.h>
14473 #include <linux/slab.h>
14474 #include <linux/perf_event.h>
14475 +#include <linux/vserver/percpu.h>
14477 #include <asm/io.h>
14478 #include <asm/bugs.h>
14479 diff -NurpP --minimal linux-3.0-rc5/ipc/mqueue.c linux-3.0-rc5-vs2.3.1-pre3/ipc/mqueue.c
14480 --- linux-3.0-rc5/ipc/mqueue.c 2011-03-15 18:07:41.000000000 +0100
14481 +++ linux-3.0-rc5-vs2.3.1-pre3/ipc/mqueue.c 2011-06-10 22:11:24.000000000 +0200
14483 #include <linux/pid.h>
14484 #include <linux/ipc_namespace.h>
14485 #include <linux/slab.h>
14486 +#include <linux/vs_context.h>
14487 +#include <linux/vs_limit.h>
14489 #include <net/sock.h>
14491 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14492 struct sigevent notify;
14493 struct pid* notify_owner;
14494 struct user_struct *user; /* user who created, for accounting */
14495 + struct vx_info *vxi;
14496 struct sock *notify_sock;
14497 struct sk_buff *notify_cookie;
14499 @@ -126,6 +129,7 @@ static struct inode *mqueue_get_inode(st
14500 if (S_ISREG(mode)) {
14501 struct mqueue_inode_info *info;
14502 struct task_struct *p = current;
14503 + struct vx_info *vxi = p->vx_info;
14504 unsigned long mq_bytes, mq_msg_tblsz;
14506 inode->i_fop = &mqueue_file_operations;
14507 @@ -139,6 +143,7 @@ static struct inode *mqueue_get_inode(st
14508 info->notify_owner = NULL;
14510 info->user = NULL; /* set when all is ok */
14511 + info->vxi = NULL;
14512 memset(&info->attr, 0, sizeof(info->attr));
14513 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14514 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14515 @@ -157,16 +162,19 @@ static struct inode *mqueue_get_inode(st
14516 spin_lock(&mq_lock);
14517 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14518 u->mq_bytes + mq_bytes >
14519 - task_rlimit(p, RLIMIT_MSGQUEUE)) {
14520 + task_rlimit(p, RLIMIT_MSGQUEUE) ||
14521 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14522 spin_unlock(&mq_lock);
14523 /* mqueue_evict_inode() releases info->messages */
14526 u->mq_bytes += mq_bytes;
14527 + vx_ipcmsg_add(vxi, u, mq_bytes);
14528 spin_unlock(&mq_lock);
14531 info->user = get_uid(u);
14532 + info->vxi = get_vx_info(vxi);
14533 } else if (S_ISDIR(mode)) {
14535 /* Some things misbehave if size == 0 on a directory */
14536 @@ -275,8 +283,11 @@ static void mqueue_evict_inode(struct in
14537 + info->attr.mq_msgsize);
14540 + struct vx_info *vxi = info->vxi;
14542 spin_lock(&mq_lock);
14543 user->mq_bytes -= mq_bytes;
14544 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14546 * get_ns_from_inode() ensures that the
14547 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14548 @@ -286,6 +297,7 @@ static void mqueue_evict_inode(struct in
14550 ipc_ns->mq_queues_count--;
14551 spin_unlock(&mq_lock);
14552 + put_vx_info(vxi);
14556 diff -NurpP --minimal linux-3.0-rc5/ipc/msg.c linux-3.0-rc5-vs2.3.1-pre3/ipc/msg.c
14557 --- linux-3.0-rc5/ipc/msg.c 2011-05-22 16:17:59.000000000 +0200
14558 +++ linux-3.0-rc5-vs2.3.1-pre3/ipc/msg.c 2011-06-10 22:11:24.000000000 +0200
14560 #include <linux/rwsem.h>
14561 #include <linux/nsproxy.h>
14562 #include <linux/ipc_namespace.h>
14563 +#include <linux/vs_base.h>
14565 #include <asm/current.h>
14566 #include <asm/uaccess.h>
14567 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14569 msq->q_perm.mode = msgflg & S_IRWXUGO;
14570 msq->q_perm.key = key;
14571 + msq->q_perm.xid = vx_current_xid();
14573 msq->q_perm.security = NULL;
14574 retval = security_msg_queue_alloc(msq);
14575 diff -NurpP --minimal linux-3.0-rc5/ipc/namespace.c linux-3.0-rc5-vs2.3.1-pre3/ipc/namespace.c
14576 --- linux-3.0-rc5/ipc/namespace.c 2011-07-01 11:14:22.000000000 +0200
14577 +++ linux-3.0-rc5-vs2.3.1-pre3/ipc/namespace.c 2011-06-13 14:09:44.000000000 +0200
14578 @@ -13,11 +13,12 @@
14579 #include <linux/mount.h>
14580 #include <linux/user_namespace.h>
14581 #include <linux/proc_fs.h>
14582 +#include <linux/vs_base.h>
14583 +#include <linux/vserver/global.h>
14587 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
14588 - struct ipc_namespace *old_ns)
14589 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
14591 struct ipc_namespace *ns;
14593 @@ -46,19 +47,18 @@ static struct ipc_namespace *create_ipc_
14594 ipcns_notify(IPCNS_CREATED);
14595 register_ipcns_notifier(ns);
14597 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
14598 + ns->user_ns = get_user_ns(user_ns);
14603 struct ipc_namespace *copy_ipcs(unsigned long flags,
14604 - struct task_struct *tsk)
14605 + struct ipc_namespace *old_ns,
14606 + struct user_namespace *user_ns)
14608 - struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
14610 if (!(flags & CLONE_NEWIPC))
14611 - return get_ipc_ns(ns);
14612 - return create_ipc_ns(tsk, ns);
14613 + return get_ipc_ns(old_ns);
14614 + return create_ipc_ns(user_ns);
14618 diff -NurpP --minimal linux-3.0-rc5/ipc/sem.c linux-3.0-rc5-vs2.3.1-pre3/ipc/sem.c
14619 --- linux-3.0-rc5/ipc/sem.c 2011-05-22 16:17:59.000000000 +0200
14620 +++ linux-3.0-rc5-vs2.3.1-pre3/ipc/sem.c 2011-06-10 22:11:24.000000000 +0200
14622 #include <linux/rwsem.h>
14623 #include <linux/nsproxy.h>
14624 #include <linux/ipc_namespace.h>
14625 +#include <linux/vs_base.h>
14626 +#include <linux/vs_limit.h>
14628 #include <asm/uaccess.h>
14630 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
14632 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14633 sma->sem_perm.key = key;
14634 + sma->sem_perm.xid = vx_current_xid();
14636 sma->sem_perm.security = NULL;
14637 retval = security_sem_alloc(sma);
14638 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
14641 ns->used_sems += nsems;
14642 + /* FIXME: obsoleted? */
14643 + vx_semary_inc(sma);
14644 + vx_nsems_add(sma, nsems);
14646 sma->sem_base = (struct sem *) &sma[1];
14648 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
14650 wake_up_sem_queue_do(&tasks);
14651 ns->used_sems -= sma->sem_nsems;
14652 + /* FIXME: obsoleted? */
14653 + vx_nsems_sub(sma, sma->sem_nsems);
14654 + vx_semary_dec(sma);
14655 security_sem_free(sma);
14656 ipc_rcu_putref(sma);
14658 diff -NurpP --minimal linux-3.0-rc5/ipc/shm.c linux-3.0-rc5-vs2.3.1-pre3/ipc/shm.c
14659 --- linux-3.0-rc5/ipc/shm.c 2011-07-01 11:14:22.000000000 +0200
14660 +++ linux-3.0-rc5-vs2.3.1-pre3/ipc/shm.c 2011-06-10 22:11:24.000000000 +0200
14662 #include <linux/nsproxy.h>
14663 #include <linux/mount.h>
14664 #include <linux/ipc_namespace.h>
14665 +#include <linux/vs_context.h>
14666 +#include <linux/vs_limit.h>
14668 #include <asm/uaccess.h>
14670 @@ -173,7 +175,12 @@ static void shm_open(struct vm_area_stru
14672 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14674 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14675 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14676 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14678 + vx_ipcshm_sub(vxi, shp, numpages);
14679 + ns->shm_tot -= numpages;
14683 if (!is_file_hugepages(shp->shm_file))
14684 @@ -183,6 +190,7 @@ static void shm_destroy(struct ipc_names
14686 fput (shp->shm_file);
14687 security_shm_free(shp);
14688 + put_vx_info(vxi);
14689 ipc_rcu_putref(shp);
14692 @@ -355,11 +363,15 @@ static int newseg(struct ipc_namespace *
14693 if (ns->shm_tot + numpages > ns->shm_ctlall)
14696 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14699 shp = ipc_rcu_alloc(sizeof(*shp));
14703 shp->shm_perm.key = key;
14704 + shp->shm_perm.xid = vx_current_xid();
14705 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14706 shp->mlock_user = NULL;
14708 @@ -413,6 +425,7 @@ static int newseg(struct ipc_namespace *
14709 ns->shm_tot += numpages;
14710 error = shp->shm_perm.id;
14712 + vx_ipcshm_add(current_vx_info(), key, numpages);
14716 diff -NurpP --minimal linux-3.0-rc5/kernel/Makefile linux-3.0-rc5-vs2.3.1-pre3/kernel/Makefile
14717 --- linux-3.0-rc5/kernel/Makefile 2011-07-01 11:14:22.000000000 +0200
14718 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/Makefile 2011-06-10 22:11:24.000000000 +0200
14719 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
14720 CFLAGS_REMOVE_irq_work.o = -pg
14724 obj-$(CONFIG_FREEZER) += freezer.o
14725 obj-$(CONFIG_PROFILING) += profile.o
14726 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
14727 diff -NurpP --minimal linux-3.0-rc5/kernel/capability.c linux-3.0-rc5-vs2.3.1-pre3/kernel/capability.c
14728 --- linux-3.0-rc5/kernel/capability.c 2011-07-01 11:14:22.000000000 +0200
14729 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/capability.c 2011-06-10 22:21:49.000000000 +0200
14731 #include <linux/syscalls.h>
14732 #include <linux/pid_namespace.h>
14733 #include <linux/user_namespace.h>
14734 +#include <linux/vs_context.h>
14735 #include <asm/uaccess.h>
14738 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
14744 * The only thing that can change the capabilities of the current
14745 * process is the current process. As such, we can't be in this code
14746 @@ -340,6 +342,8 @@ bool has_capability_noaudit(struct task_
14750 +#include <linux/vserver/base.h>
14753 * capable - Determine if the current task has a superior capability in effect
14754 * @cap: The capability to be tested for
14755 @@ -369,6 +373,9 @@ EXPORT_SYMBOL(capable);
14757 bool ns_capable(struct user_namespace *ns, int cap)
14759 + /* here for now so we don't require task locking */
14760 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
14762 if (unlikely(!cap_valid(cap))) {
14763 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
14765 diff -NurpP --minimal linux-3.0-rc5/kernel/compat.c linux-3.0-rc5-vs2.3.1-pre3/kernel/compat.c
14766 --- linux-3.0-rc5/kernel/compat.c 2011-07-01 11:14:22.000000000 +0200
14767 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/compat.c 2011-06-10 22:11:24.000000000 +0200
14768 @@ -970,7 +970,7 @@ asmlinkage long compat_sys_stime(compat_
14772 - do_settimeofday(&tv);
14773 + vx_settimeofday(&tv);
14777 diff -NurpP --minimal linux-3.0-rc5/kernel/cred.c linux-3.0-rc5-vs2.3.1-pre3/kernel/cred.c
14778 --- linux-3.0-rc5/kernel/cred.c 2011-07-01 11:14:22.000000000 +0200
14779 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/cred.c 2011-06-10 22:11:24.000000000 +0200
14780 @@ -61,31 +61,6 @@ struct cred init_cred = {
14784 -static inline void set_cred_subscribers(struct cred *cred, int n)
14786 -#ifdef CONFIG_DEBUG_CREDENTIALS
14787 - atomic_set(&cred->subscribers, n);
14791 -static inline int read_cred_subscribers(const struct cred *cred)
14793 -#ifdef CONFIG_DEBUG_CREDENTIALS
14794 - return atomic_read(&cred->subscribers);
14800 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14802 -#ifdef CONFIG_DEBUG_CREDENTIALS
14803 - struct cred *cred = (struct cred *) _cred;
14805 - atomic_add(n, &cred->subscribers);
14810 * Dispose of the shared task group credentials
14812 @@ -281,21 +256,16 @@ error:
14814 * Call commit_creds() or abort_creds() to clean up.
14816 -struct cred *prepare_creds(void)
14817 +struct cred *__prepare_creds(const struct cred *old)
14819 - struct task_struct *task = current;
14820 - const struct cred *old;
14823 - validate_process_creds();
14825 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14829 kdebug("prepare_creds() alloc %p", new);
14831 - old = task->cred;
14832 memcpy(new, old, sizeof(struct cred));
14834 atomic_set(&new->usage, 1);
14835 @@ -322,6 +292,13 @@ error:
14840 +struct cred *prepare_creds(void)
14842 + validate_process_creds();
14844 + return __prepare_creds(current->cred);
14846 EXPORT_SYMBOL(prepare_creds);
14849 diff -NurpP --minimal linux-3.0-rc5/kernel/exit.c linux-3.0-rc5-vs2.3.1-pre3/kernel/exit.c
14850 --- linux-3.0-rc5/kernel/exit.c 2011-07-01 11:14:22.000000000 +0200
14851 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/exit.c 2011-06-22 12:39:15.000000000 +0200
14853 #include <linux/fs_struct.h>
14854 #include <linux/init_task.h>
14855 #include <linux/perf_event.h>
14856 +#include <linux/vs_limit.h>
14857 +#include <linux/vs_context.h>
14858 +#include <linux/vs_network.h>
14859 +#include <linux/vs_pid.h>
14860 #include <trace/events/sched.h>
14861 #include <linux/hw_breakpoint.h>
14862 #include <linux/oom.h>
14863 @@ -494,9 +498,11 @@ static void close_files(struct files_str
14864 filp_close(file, files);
14867 + vx_openfd_dec(i);
14875 @@ -1047,11 +1053,16 @@ NORET_TYPE void do_exit(long code)
14877 validate_creds_for_do_exit(tsk);
14879 + /* needs to stay after exit_notify() */
14880 + exit_vx_info(tsk, code);
14881 + exit_nx_info(tsk);
14885 /* causes final put_task_struct in finish_task_switch(). */
14886 tsk->state = TASK_DEAD;
14888 + printk("bad task: %p [%lx]\n", current, current->state);
14890 /* Avoid "noreturn function does return". */
14892 diff -NurpP --minimal linux-3.0-rc5/kernel/fork.c linux-3.0-rc5-vs2.3.1-pre3/kernel/fork.c
14893 --- linux-3.0-rc5/kernel/fork.c 2011-07-01 11:14:22.000000000 +0200
14894 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/fork.c 2011-06-10 22:21:02.000000000 +0200
14896 #include <linux/user-return-notifier.h>
14897 #include <linux/oom.h>
14898 #include <linux/khugepaged.h>
14899 +#include <linux/vs_context.h>
14900 +#include <linux/vs_network.h>
14901 +#include <linux/vs_limit.h>
14902 +#include <linux/vs_memory.h>
14904 #include <asm/pgtable.h>
14905 #include <asm/pgalloc.h>
14906 @@ -167,6 +171,8 @@ void free_task(struct task_struct *tsk)
14907 account_kernel_stack(tsk->stack, -1);
14908 free_thread_info(tsk->stack);
14909 rt_mutex_debug_task_free(tsk);
14910 + clr_vx_info(&tsk->vx_info);
14911 + clr_nx_info(&tsk->nx_info);
14912 ftrace_graph_exit_task(tsk);
14913 free_task_struct(tsk);
14915 @@ -505,6 +511,7 @@ static struct mm_struct * mm_init(struct
14916 if (likely(!mm_alloc_pgd(mm))) {
14918 mmu_notifier_mm_init(mm);
14919 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14923 @@ -542,6 +549,7 @@ void __mmdrop(struct mm_struct *mm)
14924 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14925 VM_BUG_ON(mm->pmd_huge_pte);
14927 + clr_vx_info(&mm->mm_vx_info);
14930 EXPORT_SYMBOL_GPL(__mmdrop);
14931 @@ -729,6 +737,7 @@ struct mm_struct *dup_mm(struct task_str
14934 memcpy(mm, oldmm, sizeof(*mm));
14935 + mm->mm_vx_info = NULL;
14936 mm_init_cpumask(mm);
14938 /* Initializing for Swap token stuff */
14939 @@ -772,6 +781,7 @@ fail_nocontext:
14940 * If init_new_context() failed, we cannot use mmput() to free the mm
14941 * because it calls destroy_context()
14943 + clr_vx_info(&mm->mm_vx_info);
14947 @@ -1057,6 +1067,8 @@ static struct task_struct *copy_process(
14949 struct task_struct *p;
14950 int cgroup_callbacks_done = 0;
14951 + struct vx_info *vxi;
14952 + struct nx_info *nxi;
14954 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14955 return ERR_PTR(-EINVAL);
14956 @@ -1103,7 +1115,12 @@ static struct task_struct *copy_process(
14957 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14958 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14960 + init_vx_info(&p->vx_info, current_vx_info());
14961 + init_nx_info(&p->nx_info, current_nx_info());
14964 + if (!vx_nproc_avail(1))
14965 + goto bad_fork_free;
14966 if (atomic_read(&p->real_cred->user->processes) >=
14967 task_rlimit(p, RLIMIT_NPROC)) {
14968 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14969 @@ -1360,6 +1377,18 @@ static struct task_struct *copy_process(
14972 spin_unlock(¤t->sighand->siglock);
14974 + /* p is copy of current */
14975 + vxi = p->vx_info;
14977 + claim_vx_info(vxi, p);
14978 + atomic_inc(&vxi->cvirt.nr_threads);
14979 + atomic_inc(&vxi->cvirt.total_forks);
14982 + nxi = p->nx_info;
14984 + claim_nx_info(nxi, p);
14985 write_unlock_irq(&tasklist_lock);
14986 proc_fork_connector(p);
14987 cgroup_post_fork(p);
14988 diff -NurpP --minimal linux-3.0-rc5/kernel/kthread.c linux-3.0-rc5-vs2.3.1-pre3/kernel/kthread.c
14989 --- linux-3.0-rc5/kernel/kthread.c 2011-07-01 11:14:22.000000000 +0200
14990 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/kthread.c 2011-06-10 22:11:24.000000000 +0200
14992 #include <linux/mutex.h>
14993 #include <linux/slab.h>
14994 #include <linux/freezer.h>
14995 +#include <linux/vs_pid.h>
14996 #include <trace/events/sched.h>
14998 static DEFINE_SPINLOCK(kthread_create_lock);
14999 diff -NurpP --minimal linux-3.0-rc5/kernel/nsproxy.c linux-3.0-rc5-vs2.3.1-pre3/kernel/nsproxy.c
15000 --- linux-3.0-rc5/kernel/nsproxy.c 2011-07-01 11:14:23.000000000 +0200
15001 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/nsproxy.c 2011-06-13 14:09:44.000000000 +0200
15003 #include <linux/mnt_namespace.h>
15004 #include <linux/utsname.h>
15005 #include <linux/pid_namespace.h>
15006 +#include <linux/vserver/global.h>
15007 +#include <linux/vserver/debug.h>
15008 #include <net/net_namespace.h>
15009 #include <linux/ipc_namespace.h>
15010 #include <linux/proc_fs.h>
15011 @@ -46,8 +48,11 @@ static inline struct nsproxy *create_nsp
15012 struct nsproxy *nsproxy;
15014 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
15017 atomic_set(&nsproxy->count, 1);
15018 + atomic_inc(&vs_global_nsproxy);
15020 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
15024 @@ -56,8 +61,11 @@ static inline struct nsproxy *create_nsp
15025 * Return the newly created nsproxy. Do not attach this to the task,
15026 * leave it to the caller to do proper locking and attach it to task.
15028 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15029 - struct task_struct *tsk, struct fs_struct *new_fs)
15030 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15031 + struct nsproxy *orig,
15032 + struct fs_struct *new_fs,
15033 + struct user_namespace *new_user,
15034 + struct pid_namespace *new_pid)
15036 struct nsproxy *new_nsp;
15038 @@ -66,31 +74,31 @@ static struct nsproxy *create_new_namesp
15040 return ERR_PTR(-ENOMEM);
15042 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15043 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15044 if (IS_ERR(new_nsp->mnt_ns)) {
15045 err = PTR_ERR(new_nsp->mnt_ns);
15049 - new_nsp->uts_ns = copy_utsname(flags, tsk);
15050 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
15051 if (IS_ERR(new_nsp->uts_ns)) {
15052 err = PTR_ERR(new_nsp->uts_ns);
15056 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
15057 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
15058 if (IS_ERR(new_nsp->ipc_ns)) {
15059 err = PTR_ERR(new_nsp->ipc_ns);
15063 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15064 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
15065 if (IS_ERR(new_nsp->pid_ns)) {
15066 err = PTR_ERR(new_nsp->pid_ns);
15070 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15071 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15072 if (IS_ERR(new_nsp->net_ns)) {
15073 err = PTR_ERR(new_nsp->net_ns);
15075 @@ -115,6 +123,40 @@ out_ns:
15076 return ERR_PTR(err);
15079 +static struct nsproxy *create_new_namespaces(unsigned long flags,
15080 + struct task_struct *tsk, struct fs_struct *new_fs)
15082 + return unshare_namespaces(flags, tsk->nsproxy,
15083 + new_fs, task_cred_xxx(tsk, user)->user_ns,
15084 + task_active_pid_ns(tsk));
15088 + * copies the nsproxy, setting refcount to 1, and grabbing a
15089 + * reference to all contained namespaces.
15091 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15093 + struct nsproxy *ns = create_nsproxy();
15096 + memcpy(ns, orig, sizeof(struct nsproxy));
15097 + atomic_set(&ns->count, 1);
15100 + get_mnt_ns(ns->mnt_ns);
15102 + get_uts_ns(ns->uts_ns);
15104 + get_ipc_ns(ns->ipc_ns);
15106 + get_pid_ns(ns->pid_ns);
15108 + get_net(ns->net_ns);
15114 * called from clone. This now handles copy for nsproxy and all
15115 * namespaces therein.
15116 @@ -122,9 +164,12 @@ out_ns:
15117 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15119 struct nsproxy *old_ns = tsk->nsproxy;
15120 - struct nsproxy *new_ns;
15121 + struct nsproxy *new_ns = NULL;
15124 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15125 + flags, tsk, old_ns);
15130 @@ -134,7 +179,7 @@ int copy_namespaces(unsigned long flags,
15131 CLONE_NEWPID | CLONE_NEWNET)))
15134 - if (!capable(CAP_SYS_ADMIN)) {
15135 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
15139 @@ -161,6 +206,9 @@ int copy_namespaces(unsigned long flags,
15142 put_nsproxy(old_ns);
15143 + vxdprintk(VXD_CBIT(space, 3),
15144 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15145 + flags, tsk, old_ns, err, new_ns);
15149 @@ -174,7 +222,9 @@ void free_nsproxy(struct nsproxy *ns)
15150 put_ipc_ns(ns->ipc_ns);
15152 put_pid_ns(ns->pid_ns);
15153 - put_net(ns->net_ns);
15155 + put_net(ns->net_ns);
15156 + atomic_dec(&vs_global_nsproxy);
15157 kmem_cache_free(nsproxy_cachep, ns);
15160 @@ -187,11 +237,15 @@ int unshare_nsproxy_namespaces(unsigned
15164 + vxdprintk(VXD_CBIT(space, 4),
15165 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15166 + unshare_flags, current->nsproxy);
15168 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15172 - if (!capable(CAP_SYS_ADMIN))
15173 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
15176 *new_nsp = create_new_namespaces(unshare_flags, current,
15177 diff -NurpP --minimal linux-3.0-rc5/kernel/pid.c linux-3.0-rc5-vs2.3.1-pre3/kernel/pid.c
15178 --- linux-3.0-rc5/kernel/pid.c 2011-05-22 16:17:59.000000000 +0200
15179 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/pid.c 2011-06-10 22:11:24.000000000 +0200
15181 #include <linux/pid_namespace.h>
15182 #include <linux/init_task.h>
15183 #include <linux/syscalls.h>
15184 +#include <linux/vs_pid.h>
15186 #define pid_hashfn(nr, ns) \
15187 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15188 @@ -342,7 +343,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15190 struct pid *find_vpid(int nr)
15192 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15193 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15195 EXPORT_SYMBOL_GPL(find_vpid);
15197 @@ -402,6 +403,9 @@ void transfer_pid(struct task_struct *ol
15198 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15200 struct task_struct *result = NULL;
15202 + if (type == PIDTYPE_REALPID)
15203 + type = PIDTYPE_PID;
15205 struct hlist_node *first;
15206 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
15207 @@ -420,7 +424,7 @@ EXPORT_SYMBOL(pid_task);
15208 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15210 rcu_lockdep_assert(rcu_read_lock_held());
15211 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15212 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15215 struct task_struct *find_task_by_vpid(pid_t vnr)
15216 @@ -464,7 +468,7 @@ struct pid *find_get_pid(pid_t nr)
15218 EXPORT_SYMBOL_GPL(find_get_pid);
15220 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15221 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15225 @@ -477,6 +481,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15229 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15231 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15234 pid_t pid_vnr(struct pid *pid)
15236 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15237 diff -NurpP --minimal linux-3.0-rc5/kernel/pid_namespace.c linux-3.0-rc5-vs2.3.1-pre3/kernel/pid_namespace.c
15238 --- linux-3.0-rc5/kernel/pid_namespace.c 2011-05-22 16:17:59.000000000 +0200
15239 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/pid_namespace.c 2011-06-10 22:17:45.000000000 +0200
15241 #include <linux/acct.h>
15242 #include <linux/slab.h>
15243 #include <linux/proc_fs.h>
15244 +#include <linux/vserver/global.h>
15246 #define BITS_PER_PAGE (PAGE_SIZE*8)
15248 @@ -88,6 +89,7 @@ static struct pid_namespace *create_pid_
15251 kref_init(&ns->kref);
15252 + atomic_inc(&vs_global_pid_ns);
15254 ns->parent = get_pid_ns(parent_pid_ns);
15256 @@ -119,6 +121,7 @@ static void destroy_pid_namespace(struct
15258 for (i = 0; i < PIDMAP_ENTRIES; i++)
15259 kfree(ns->pidmap[i].page);
15260 + atomic_dec(&vs_global_pid_ns);
15261 kmem_cache_free(pid_ns_cachep, ns);
15264 diff -NurpP --minimal linux-3.0-rc5/kernel/posix-timers.c linux-3.0-rc5-vs2.3.1-pre3/kernel/posix-timers.c
15265 --- linux-3.0-rc5/kernel/posix-timers.c 2011-07-01 11:14:23.000000000 +0200
15266 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/posix-timers.c 2011-06-10 22:11:24.000000000 +0200
15268 #include <linux/wait.h>
15269 #include <linux/workqueue.h>
15270 #include <linux/module.h>
15271 +#include <linux/vs_context.h>
15274 * Management arrays for POSIX timers. Timers are kept in slab memory
15275 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
15277 struct task_struct *task;
15278 int shared, ret = -1;
15281 * FIXME: if ->sigq is queued we can race with
15282 * dequeue_signal()->do_schedule_next_timer().
15283 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
15285 task = pid_task(timr->it_pid, PIDTYPE_PID);
15287 + struct vx_info_save vxis;
15288 + struct vx_info *vxi;
15290 + vxi = get_vx_info(task->vx_info);
15291 + enter_vx_info(vxi, &vxis);
15292 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15293 ret = send_sigqueue(timr->sigq, task, shared);
15294 + leave_vx_info(&vxis);
15295 + put_vx_info(vxi);
15299 /* If we failed to send the signal the timer stops. */
15302 diff -NurpP --minimal linux-3.0-rc5/kernel/printk.c linux-3.0-rc5-vs2.3.1-pre3/kernel/printk.c
15303 --- linux-3.0-rc5/kernel/printk.c 2011-07-01 11:14:23.000000000 +0200
15304 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/printk.c 2011-06-10 22:11:24.000000000 +0200
15306 #include <linux/cpu.h>
15307 #include <linux/notifier.h>
15308 #include <linux/rculist.h>
15309 +#include <linux/vs_cvirt.h>
15311 #include <asm/uaccess.h>
15313 @@ -314,7 +315,7 @@ static int check_syslog_permissions(int
15316 if (syslog_action_restricted(type)) {
15317 - if (capable(CAP_SYSLOG))
15318 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
15320 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
15321 if (capable(CAP_SYS_ADMIN)) {
15322 @@ -342,12 +343,9 @@ int do_syslog(int type, char __user *buf
15327 - case SYSLOG_ACTION_CLOSE: /* Close log */
15329 - case SYSLOG_ACTION_OPEN: /* Open log */
15331 - case SYSLOG_ACTION_READ: /* Read from log */
15332 + if ((type == SYSLOG_ACTION_READ) ||
15333 + (type == SYSLOG_ACTION_READ_ALL) ||
15334 + (type == SYSLOG_ACTION_READ_CLEAR)) {
15336 if (!buf || len < 0)
15338 @@ -358,6 +356,16 @@ int do_syslog(int type, char __user *buf
15343 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15344 + return vx_do_syslog(type, buf, len);
15347 + case SYSLOG_ACTION_CLOSE: /* Close log */
15349 + case SYSLOG_ACTION_OPEN: /* Open log */
15351 + case SYSLOG_ACTION_READ: /* Read from log */
15352 error = wait_event_interruptible(log_wait,
15353 (log_start - log_end));
15355 @@ -384,16 +392,6 @@ int do_syslog(int type, char __user *buf
15357 /* Read last kernel messages */
15358 case SYSLOG_ACTION_READ_ALL:
15360 - if (!buf || len < 0)
15365 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15370 if (count > log_buf_len)
15371 count = log_buf_len;
15372 diff -NurpP --minimal linux-3.0-rc5/kernel/ptrace.c linux-3.0-rc5-vs2.3.1-pre3/kernel/ptrace.c
15373 --- linux-3.0-rc5/kernel/ptrace.c 2011-07-01 11:14:23.000000000 +0200
15374 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/ptrace.c 2011-06-10 22:11:24.000000000 +0200
15376 #include <linux/syscalls.h>
15377 #include <linux/uaccess.h>
15378 #include <linux/regset.h>
15379 +#include <linux/vs_context.h>
15380 #include <linux/hw_breakpoint.h>
15383 @@ -169,6 +170,11 @@ ok:
15384 dumpable = get_dumpable(task->mm);
15385 if (!dumpable && !task_ns_capable(task, CAP_SYS_PTRACE))
15387 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
15389 + if (!vx_check(task->xid, VS_IDENT) &&
15390 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15393 return security_ptrace_access_check(task, mode);
15395 diff -NurpP --minimal linux-3.0-rc5/kernel/sched.c linux-3.0-rc5-vs2.3.1-pre3/kernel/sched.c
15396 --- linux-3.0-rc5/kernel/sched.c 2011-07-01 11:14:23.000000000 +0200
15397 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/sched.c 2011-06-15 02:40:14.000000000 +0200
15399 #include <linux/ctype.h>
15400 #include <linux/ftrace.h>
15401 #include <linux/slab.h>
15402 +#include <linux/vs_sched.h>
15403 +#include <linux/vs_cvirt.h>
15405 #include <asm/tlb.h>
15406 #include <asm/irq_regs.h>
15407 @@ -3429,9 +3431,17 @@ static void calc_global_nohz(unsigned lo
15409 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
15411 - loads[0] = (avenrun[0] + offset) << shift;
15412 - loads[1] = (avenrun[1] + offset) << shift;
15413 - loads[2] = (avenrun[2] + offset) << shift;
15414 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
15415 + struct vx_info *vxi = current_vx_info();
15417 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
15418 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
15419 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
15421 + loads[0] = (avenrun[0] + offset) << shift;
15422 + loads[1] = (avenrun[1] + offset) << shift;
15423 + loads[2] = (avenrun[2] + offset) << shift;
15428 @@ -3714,16 +3724,19 @@ void account_user_time(struct task_struc
15429 cputime_t cputime_scaled)
15431 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15432 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15434 + int nice = (TASK_NICE(p) > 0);
15436 /* Add user time to process. */
15437 p->utime = cputime_add(p->utime, cputime);
15438 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15439 + vx_account_user(vxi, cputime, nice);
15440 account_group_user_time(p, cputime);
15442 /* Add user time to cpustat. */
15443 tmp = cputime_to_cputime64(cputime);
15444 - if (TASK_NICE(p) > 0)
15446 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15448 cpustat->user = cputime64_add(cpustat->user, tmp);
15449 @@ -3775,10 +3788,12 @@ void __account_system_time(struct task_s
15450 cputime_t cputime_scaled, cputime64_t *target_cputime64)
15452 cputime64_t tmp = cputime_to_cputime64(cputime);
15453 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15455 /* Add system time to process. */
15456 p->stime = cputime_add(p->stime, cputime);
15457 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15458 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15459 account_group_system_time(p, cputime);
15461 /* Add system time to cpustat. */
15462 @@ -4936,7 +4951,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15465 if (increment < 0 && !can_nice(current, nice))
15467 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15469 retval = security_task_setnice(current, nice);
15471 diff -NurpP --minimal linux-3.0-rc5/kernel/sched_fair.c linux-3.0-rc5-vs2.3.1-pre3/kernel/sched_fair.c
15472 --- linux-3.0-rc5/kernel/sched_fair.c 2011-07-01 11:14:23.000000000 +0200
15473 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/sched_fair.c 2011-06-10 22:11:24.000000000 +0200
15474 @@ -998,6 +998,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15475 __enqueue_entity(cfs_rq, se);
15478 + if (entity_is_task(se))
15479 + vx_activate_task(task_of(se));
15480 if (cfs_rq->nr_running == 1)
15481 list_add_leaf_cfs_rq(cfs_rq);
15483 @@ -1074,6 +1076,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15484 if (se != cfs_rq->curr)
15485 __dequeue_entity(cfs_rq, se);
15487 + if (entity_is_task(se))
15488 + vx_deactivate_task(task_of(se));
15489 update_cfs_load(cfs_rq, 0);
15490 account_entity_dequeue(cfs_rq, se);
15492 diff -NurpP --minimal linux-3.0-rc5/kernel/signal.c linux-3.0-rc5-vs2.3.1-pre3/kernel/signal.c
15493 --- linux-3.0-rc5/kernel/signal.c 2011-07-01 11:14:23.000000000 +0200
15494 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/signal.c 2011-06-22 12:39:16.000000000 +0200
15496 #include <linux/freezer.h>
15497 #include <linux/pid_namespace.h>
15498 #include <linux/nsproxy.h>
15499 +#include <linux/vs_context.h>
15500 +#include <linux/vs_pid.h>
15501 #define CREATE_TRACE_POINTS
15502 #include <trace/events/signal.h>
15504 @@ -744,9 +746,18 @@ static int check_kill_permission(int sig
15508 + vxdprintk(VXD_CBIT(misc, 7),
15509 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15510 + sig, info, t, vx_task_xid(t), t->pid);
15512 if (!valid_signal(sig))
15515 +/* FIXME: needed? if so, why?
15516 + if ((info != SEND_SIG_NOINFO) &&
15517 + (is_si_special(info) || !si_fromuser(info)))
15520 if (!si_fromuser(info))
15523 @@ -770,6 +781,20 @@ static int check_kill_permission(int sig
15528 + if (t->pid == 1 && current->xid)
15532 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15533 + loops, maybe ENOENT or EACCES? */
15534 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15535 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15536 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15537 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15541 return security_task_kill(t, info, sig, 0);
15544 @@ -1239,7 +1264,7 @@ int kill_pid_info(int sig, struct siginf
15547 p = pid_task(pid, PIDTYPE_PID);
15549 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15550 error = group_send_sig_info(sig, info, p);
15551 if (unlikely(error == -ESRCH))
15553 @@ -1278,7 +1303,7 @@ int kill_pid_info_as_uid(int sig, struct
15556 p = pid_task(pid, PIDTYPE_PID);
15558 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15562 @@ -1333,8 +1358,10 @@ static int kill_something_info(int sig,
15563 struct task_struct * p;
15565 for_each_process(p) {
15566 - if (task_pid_vnr(p) > 1 &&
15567 - !same_thread_group(p, current)) {
15568 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15569 + task_pid_vnr(p) > 1 &&
15570 + !same_thread_group(p, current) &&
15571 + !vx_current_initpid(p->pid)) {
15572 int err = group_send_sig_info(sig, info, p);
15575 @@ -2133,6 +2160,11 @@ relock:
15576 !sig_kernel_only(signr))
15579 + /* virtual init is protected against user signals */
15580 + if ((info->si_code == SI_USER) &&
15581 + vx_current_initpid(current->pid))
15584 if (sig_kernel_stop(signr)) {
15586 * The default action is to stop all threads in
15587 diff -NurpP --minimal linux-3.0-rc5/kernel/softirq.c linux-3.0-rc5-vs2.3.1-pre3/kernel/softirq.c
15588 --- linux-3.0-rc5/kernel/softirq.c 2011-07-01 11:14:23.000000000 +0200
15589 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/softirq.c 2011-06-22 12:39:16.000000000 +0200
15591 #include <linux/ftrace.h>
15592 #include <linux/smp.h>
15593 #include <linux/tick.h>
15594 +#include <linux/vs_context.h>
15596 #define CREATE_TRACE_POINTS
15597 #include <trace/events/irq.h>
15598 diff -NurpP --minimal linux-3.0-rc5/kernel/sys.c linux-3.0-rc5-vs2.3.1-pre3/kernel/sys.c
15599 --- linux-3.0-rc5/kernel/sys.c 2011-07-01 11:14:23.000000000 +0200
15600 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/sys.c 2011-06-10 22:11:24.000000000 +0200
15602 #include <linux/syscalls.h>
15603 #include <linux/kprobes.h>
15604 #include <linux/user_namespace.h>
15605 +#include <linux/vs_pid.h>
15607 #include <linux/kmsg_dump.h>
15609 @@ -151,7 +152,10 @@ static int set_one_prio(struct task_stru
15612 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15614 + if (vx_flags(VXF_IGNEG_NICE, 0))
15620 no_nice = security_task_setnice(p, niceval);
15621 @@ -201,6 +205,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15623 pgrp = task_pgrp(current);
15624 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15625 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15627 error = set_one_prio(p, niceval, error);
15628 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15630 @@ -264,6 +270,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15632 pgrp = task_pgrp(current);
15633 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15634 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15636 niceval = 20 - task_nice(p);
15637 if (niceval > retval)
15639 @@ -383,6 +391,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15641 static DEFINE_MUTEX(reboot_mutex);
15643 +long vs_reboot(unsigned int, void __user *);
15646 * Reboot system call: for obvious reasons only root may call it,
15647 * and even root needs to set up some magic numbers in the registers
15648 @@ -415,6 +425,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15649 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15650 cmd = LINUX_REBOOT_CMD_HALT;
15652 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15653 + return vs_reboot(cmd, arg);
15655 mutex_lock(&reboot_mutex);
15657 case LINUX_REBOOT_CMD_RESTART:
15658 @@ -1365,7 +1378,7 @@ int do_prlimit(struct task_struct *tsk,
15659 /* Keep the capable check against init_user_ns until
15660 cgroups can contain all limits */
15661 if (new_rlim->rlim_max > rlim->rlim_max &&
15662 - !capable(CAP_SYS_RESOURCE))
15663 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15666 retval = security_task_setrlimit(tsk->group_leader,
15667 diff -NurpP --minimal linux-3.0-rc5/kernel/sysctl.c linux-3.0-rc5-vs2.3.1-pre3/kernel/sysctl.c
15668 --- linux-3.0-rc5/kernel/sysctl.c 2011-07-01 11:14:23.000000000 +0200
15669 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/sysctl.c 2011-06-15 02:40:14.000000000 +0200
15671 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15672 #include <linux/lockdep.h>
15674 +extern char vshelper_path[];
15675 #ifdef CONFIG_CHR_DEV_SG
15676 #include <scsi/sg.h>
15678 @@ -568,6 +569,13 @@ static struct ctl_table kern_table[] = {
15679 .proc_handler = proc_dostring,
15683 + .procname = "vshelper",
15684 + .data = &vshelper_path,
15687 + .proc_handler = &proc_dostring,
15689 #ifdef CONFIG_CHR_DEV_SG
15691 .procname = "sg-big-buff",
15692 diff -NurpP --minimal linux-3.0-rc5/kernel/sysctl_binary.c linux-3.0-rc5-vs2.3.1-pre3/kernel/sysctl_binary.c
15693 --- linux-3.0-rc5/kernel/sysctl_binary.c 2011-05-22 16:17:59.000000000 +0200
15694 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/sysctl_binary.c 2011-06-10 22:11:24.000000000 +0200
15695 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15697 { CTL_INT, KERN_PANIC, "panic" },
15698 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15699 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15701 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15702 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15703 diff -NurpP --minimal linux-3.0-rc5/kernel/time/timekeeping.c linux-3.0-rc5-vs2.3.1-pre3/kernel/time/timekeeping.c
15704 --- linux-3.0-rc5/kernel/time/timekeeping.c 2011-07-01 11:14:23.000000000 +0200
15705 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/time/timekeeping.c 2011-06-10 22:11:24.000000000 +0200
15706 @@ -233,6 +233,7 @@ void getnstimeofday(struct timespec *ts)
15707 } while (read_seqretry(&xtime_lock, seq));
15709 timespec_add_ns(ts, nsecs);
15710 + vx_adjust_timespec(ts);
15713 EXPORT_SYMBOL(getnstimeofday);
15714 diff -NurpP --minimal linux-3.0-rc5/kernel/time.c linux-3.0-rc5-vs2.3.1-pre3/kernel/time.c
15715 --- linux-3.0-rc5/kernel/time.c 2011-05-22 16:17:59.000000000 +0200
15716 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/time.c 2011-06-10 22:11:24.000000000 +0200
15717 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15721 - do_settimeofday(&tv);
15722 + vx_settimeofday(&tv);
15726 @@ -177,7 +177,7 @@ int do_sys_settimeofday(const struct tim
15727 /* SMP safe, again the code in arch/foo/time.c should
15728 * globally block out interrupts when it runs.
15730 - return do_settimeofday(tv);
15731 + return vx_settimeofday(tv);
15735 diff -NurpP --minimal linux-3.0-rc5/kernel/timer.c linux-3.0-rc5-vs2.3.1-pre3/kernel/timer.c
15736 --- linux-3.0-rc5/kernel/timer.c 2011-07-01 11:14:23.000000000 +0200
15737 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/timer.c 2011-06-15 02:40:14.000000000 +0200
15739 #include <linux/irq_work.h>
15740 #include <linux/sched.h>
15741 #include <linux/slab.h>
15742 +#include <linux/vs_base.h>
15743 +#include <linux/vs_cvirt.h>
15744 +#include <linux/vs_pid.h>
15745 +#include <linux/vserver/sched.h>
15747 #include <asm/uaccess.h>
15748 #include <asm/unistd.h>
15749 @@ -1336,12 +1340,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15756 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15757 - * should be moved into arch/i386 instead?
15761 * sys_getpid - return the thread group id of the current process
15762 @@ -1370,10 +1368,23 @@ SYSCALL_DEFINE0(getppid)
15764 pid = task_tgid_vnr(current->real_parent);
15766 + return vx_map_pid(pid);
15773 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15776 +asmlinkage long do_getxpid(long *ppid)
15778 + *ppid = sys_getppid();
15779 + return sys_getpid();
15782 +#else /* _alpha_ */
15784 SYSCALL_DEFINE0(getuid)
15786 /* Only we change this so SMP safe */
15787 diff -NurpP --minimal linux-3.0-rc5/kernel/user_namespace.c linux-3.0-rc5-vs2.3.1-pre3/kernel/user_namespace.c
15788 --- linux-3.0-rc5/kernel/user_namespace.c 2011-03-15 18:07:42.000000000 +0100
15789 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/user_namespace.c 2011-06-10 22:11:24.000000000 +0200
15791 #include <linux/user_namespace.h>
15792 #include <linux/highuid.h>
15793 #include <linux/cred.h>
15794 +#include <linux/vserver/global.h>
15796 static struct kmem_cache *user_ns_cachep __read_mostly;
15798 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
15801 kref_init(&ns->kref);
15802 + atomic_inc(&vs_global_user_ns);
15804 for (n = 0; n < UIDHASH_SZ; ++n)
15805 INIT_HLIST_HEAD(ns->uidhash_table + n);
15806 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
15807 struct user_namespace *ns =
15808 container_of(kref, struct user_namespace, kref);
15810 + /* FIXME: maybe move into destroyer? */
15811 + atomic_dec(&vs_global_user_ns);
15812 INIT_WORK(&ns->destroyer, free_user_ns_work);
15813 schedule_work(&ns->destroyer);
15815 diff -NurpP --minimal linux-3.0-rc5/kernel/utsname.c linux-3.0-rc5-vs2.3.1-pre3/kernel/utsname.c
15816 --- linux-3.0-rc5/kernel/utsname.c 2011-07-01 11:14:23.000000000 +0200
15817 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/utsname.c 2011-06-13 14:09:44.000000000 +0200
15818 @@ -16,14 +16,17 @@
15819 #include <linux/slab.h>
15820 #include <linux/user_namespace.h>
15821 #include <linux/proc_fs.h>
15822 +#include <linux/vserver/global.h>
15824 static struct uts_namespace *create_uts_ns(void)
15826 struct uts_namespace *uts_ns;
15828 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15831 kref_init(&uts_ns->kref);
15832 + atomic_inc(&vs_global_uts_ns);
15837 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
15838 * @old_ns: namespace to clone
15839 * Return NULL on error (failure to kmalloc), new ns otherwise
15841 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
15842 - struct uts_namespace *old_ns)
15843 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
15844 + struct user_namespace *old_user)
15846 struct uts_namespace *ns;
15848 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
15850 down_read(&uts_sem);
15851 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
15852 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
15853 + ns->user_ns = get_user_ns(old_user);
15857 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
15860 struct uts_namespace *copy_utsname(unsigned long flags,
15861 - struct task_struct *tsk)
15862 + struct uts_namespace *old_ns,
15863 + struct user_namespace *user_ns)
15865 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
15866 struct uts_namespace *new_ns;
15869 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
15870 if (!(flags & CLONE_NEWUTS))
15873 - new_ns = clone_uts_ns(tsk, old_ns);
15874 + new_ns = clone_uts_ns(old_ns, user_ns);
15876 put_uts_ns(old_ns);
15878 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
15880 ns = container_of(kref, struct uts_namespace, kref);
15881 put_user_ns(ns->user_ns);
15882 + atomic_dec(&vs_global_uts_ns);
15886 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/Kconfig linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/Kconfig
15887 --- linux-3.0-rc5/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
15888 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/Kconfig 2011-06-10 22:11:24.000000000 +0200
15891 +# Linux VServer configuration
15894 +menu "Linux VServer"
15896 +config VSERVER_AUTO_LBACK
15897 + bool "Automatically Assign Loopback IP"
15900 + Automatically assign a guest specific loopback
15901 + IP and add it to the kernel network stack on
15904 +config VSERVER_AUTO_SINGLE
15905 + bool "Automatic Single IP Special Casing"
15906 + depends on EXPERIMENTAL
15909 + This allows network contexts with a single IP to
15910 + automatically remap 0.0.0.0 bindings to that IP,
15911 + avoiding further network checks and improving
15914 + (note: such guests do not allow to change the ip
15915 + on the fly and do not show loopback addresses)
15917 +config VSERVER_COWBL
15918 + bool "Enable COW Immutable Link Breaking"
15921 + This enables the COW (Copy-On-Write) link break code.
15922 + It allows you to treat unified files like normal files
15923 + when writing to them (which will implicitely break the
15924 + link and create a copy of the unified file)
15926 +config VSERVER_VTIME
15927 + bool "Enable Virtualized Guest Time"
15928 + depends on EXPERIMENTAL
15931 + This enables per guest time offsets to allow for
15932 + adjusting the system clock individually per guest.
15933 + this adds some overhead to the time functions and
15934 + therefore should not be enabled without good reason.
15936 +config VSERVER_DEVICE
15937 + bool "Enable Guest Device Mapping"
15938 + depends on EXPERIMENTAL
15941 + This enables generic device remapping.
15943 +config VSERVER_PROC_SECURE
15944 + bool "Enable Proc Security"
15945 + depends on PROC_FS
15948 + This configures ProcFS security to initially hide
15949 + non-process entries for all contexts except the main and
15950 + spectator context (i.e. for all guests), which is a secure
15953 + (note: on 1.2x the entries were visible by default)
15956 + prompt "Persistent Inode Tagging"
15957 + default TAGGING_ID24
15959 + This adds persistent context information to filesystems
15960 + mounted with the tagxid option. Tagging is a requirement
15961 + for per-context disk limits and per-context quota.
15964 +config TAGGING_NONE
15967 + do not store per-context information in inodes.
15969 +config TAGGING_UID16
15970 + bool "UID16/GID32"
15972 + reduces UID to 16 bit, but leaves GID at 32 bit.
15974 +config TAGGING_GID16
15975 + bool "UID32/GID16"
15977 + reduces GID to 16 bit, but leaves UID at 32 bit.
15979 +config TAGGING_ID24
15980 + bool "UID24/GID24"
15982 + uses the upper 8bit from UID and GID for XID tagging
15983 + which leaves 24bit for UID/GID each, which should be
15984 + more than sufficient for normal use.
15986 +config TAGGING_INTERN
15987 + bool "UID32/GID32"
15989 + this uses otherwise reserved inode fields in the on
15990 + disk representation, which limits the use to a few
15991 + filesystems (currently ext2 and ext3)
15996 + bool "Tag NFSD User Auth and Files"
15999 + Enable this if you do want the in-kernel NFS
16000 + Server to use the tagging specified above.
16001 + (will require patched clients too)
16003 +config VSERVER_PRIVACY
16004 + bool "Honor Privacy Aspects of Guests"
16007 + When enabled, most context checks will disallow
16008 + access to structures assigned to a specific context,
16009 + like ptys or loop devices.
16011 +config VSERVER_CONTEXTS
16012 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
16014 + default "768" if 64BIT
16017 + This setting will optimize certain data structures
16018 + and memory allocations according to the expected
16021 + note: this is not a strict upper limit.
16023 +config VSERVER_WARN
16024 + bool "VServer Warnings"
16027 + This enables various runtime warnings, which will
16028 + notify about potential manipulation attempts or
16029 + resource shortage. It is generally considered to
16030 + be a good idea to have that enabled.
16032 +config VSERVER_WARN_DEVPTS
16033 + bool "VServer DevPTS Warnings"
16034 + depends on VSERVER_WARN
16037 + This enables DevPTS related warnings, issued when a
16038 + process inside a context tries to lookup or access
16039 + a dynamic pts from the host or a different context.
16041 +config VSERVER_DEBUG
16042 + bool "VServer Debugging Code"
16045 + Set this to yes if you want to be able to activate
16046 + debugging output at runtime. It adds a very small
16047 + overhead to all vserver related functions and
16048 + increases the kernel size by about 20k.
16050 +config VSERVER_HISTORY
16051 + bool "VServer History Tracing"
16052 + depends on VSERVER_DEBUG
16055 + Set this to yes if you want to record the history of
16056 + linux-vserver activities, so they can be replayed in
16057 + the event of a kernel panic or oops.
16059 +config VSERVER_HISTORY_SIZE
16060 + int "Per-CPU History Size (32-65536)"
16061 + depends on VSERVER_HISTORY
16065 + This allows you to specify the number of entries in
16066 + the per-CPU history buffer.
16068 +config VSERVER_LEGACY_MEM
16069 + bool "Legacy Memory Limits"
16072 + This provides fake memory limits to keep
16073 + older tools happy in the face of memory
16077 + prompt "Quotes used in debug and warn messages"
16078 + default QUOTES_ISO8859
16080 +config QUOTES_ISO8859
16081 + bool "Extended ASCII (ISO 8859) angle quotes"
16083 + This uses the extended ASCII characters \xbb
16084 + and \xab for quoting file and process names.
16086 +config QUOTES_UTF8
16087 + bool "UTF-8 angle quotes"
16089 + This uses the the UTF-8 sequences for angle
16090 + quotes to quote file and process names.
16092 +config QUOTES_ASCII
16093 + bool "ASCII single quotes"
16095 + This uses the ASCII single quote character
16096 + (\x27) to quote file and process names.
16106 + select NAMESPACES
16112 +config VSERVER_SECURITY
16114 + depends on SECURITY
16116 + select SECURITY_CAPABILITIES
16118 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/Makefile linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/Makefile
16119 --- linux-3.0-rc5/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
16120 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/Makefile 2011-06-10 22:11:24.000000000 +0200
16123 +# Makefile for the Linux vserver routines.
16127 +obj-y += vserver.o
16129 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
16130 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
16133 +vserver-$(CONFIG_INET) += inet.o
16134 +vserver-$(CONFIG_PROC_FS) += proc.o
16135 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
16136 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
16137 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
16138 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
16140 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/cacct.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/cacct.c
16141 --- linux-3.0-rc5/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
16142 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/cacct.c 2011-06-10 22:11:24.000000000 +0200
16145 + * linux/kernel/vserver/cacct.c
16147 + * Virtual Server: Context Accounting
16149 + * Copyright (C) 2006-2007 Herbert Pötzl
16151 + * V0.01 added accounting stats
16155 +#include <linux/types.h>
16156 +#include <linux/vs_context.h>
16157 +#include <linux/vserver/cacct_cmd.h>
16158 +#include <linux/vserver/cacct_int.h>
16160 +#include <asm/errno.h>
16161 +#include <asm/uaccess.h>
16164 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
16166 + struct vcmd_sock_stat_v0 vc_data;
16169 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16172 + field = vc_data.field;
16173 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
16176 + for (j = 0; j < 3; j++) {
16177 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
16178 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
16181 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16186 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/cacct_init.h linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/cacct_init.h
16187 --- linux-3.0-rc5/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16188 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/cacct_init.h 2011-06-10 22:11:24.000000000 +0200
16192 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16197 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16198 + for (j = 0; j < 3; j++) {
16199 + atomic_long_set(&cacct->sock[i][j].count, 0);
16200 + atomic_long_set(&cacct->sock[i][j].total, 0);
16203 + for (i = 0; i < 8; i++)
16204 + atomic_set(&cacct->slab[i], 0);
16205 + for (i = 0; i < 5; i++)
16206 + for (j = 0; j < 4; j++)
16207 + atomic_set(&cacct->page[i][j], 0);
16210 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16215 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/cacct_proc.h linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/cacct_proc.h
16216 --- linux-3.0-rc5/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
16217 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/cacct_proc.h 2011-06-10 22:11:24.000000000 +0200
16219 +#ifndef _VX_CACCT_PROC_H
16220 +#define _VX_CACCT_PROC_H
16222 +#include <linux/vserver/cacct_int.h>
16225 +#define VX_SOCKA_TOP \
16226 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
16228 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
16230 + int i, j, length = 0;
16231 + static char *type[VXA_SOCK_SIZE] = {
16232 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
16235 + length += sprintf(buffer + length, VX_SOCKA_TOP);
16236 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16237 + length += sprintf(buffer + length, "%s:", type[i]);
16238 + for (j = 0; j < 3; j++) {
16239 + length += sprintf(buffer + length,
16240 + "\t%10lu/%-10lu",
16241 + vx_sock_count(cacct, i, j),
16242 + vx_sock_total(cacct, i, j));
16244 + buffer[length++] = '\n';
16247 + length += sprintf(buffer + length, "\n");
16248 + length += sprintf(buffer + length,
16249 + "slab:\t %8u %8u %8u %8u\n",
16250 + atomic_read(&cacct->slab[1]),
16251 + atomic_read(&cacct->slab[4]),
16252 + atomic_read(&cacct->slab[0]),
16253 + atomic_read(&cacct->slab[2]));
16255 + length += sprintf(buffer + length, "\n");
16256 + for (i = 0; i < 5; i++) {
16257 + length += sprintf(buffer + length,
16258 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
16259 + atomic_read(&cacct->page[i][0]),
16260 + atomic_read(&cacct->page[i][1]),
16261 + atomic_read(&cacct->page[i][2]),
16262 + atomic_read(&cacct->page[i][3]),
16263 + atomic_read(&cacct->page[i][4]),
16264 + atomic_read(&cacct->page[i][5]),
16265 + atomic_read(&cacct->page[i][6]),
16266 + atomic_read(&cacct->page[i][7]));
16271 +#endif /* _VX_CACCT_PROC_H */
16272 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/context.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/context.c
16273 --- linux-3.0-rc5/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
16274 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/context.c 2011-06-16 14:16:51.000000000 +0200
16277 + * linux/kernel/vserver/context.c
16279 + * Virtual Server: Context Support
16281 + * Copyright (C) 2003-2010 Herbert Pötzl
16283 + * V0.01 context helper
16284 + * V0.02 vx_ctx_kill syscall command
16285 + * V0.03 replaced context_info calls
16286 + * V0.04 redesign of struct (de)alloc
16287 + * V0.05 rlimit basic implementation
16288 + * V0.06 task_xid and info commands
16289 + * V0.07 context flags and caps
16290 + * V0.08 switch to RCU based hash
16291 + * V0.09 revert to non RCU for now
16292 + * V0.10 and back to working RCU hash
16293 + * V0.11 and back to locking again
16294 + * V0.12 referenced context store
16295 + * V0.13 separate per cpu data
16296 + * V0.14 changed vcmds to vxi arg
16297 + * V0.15 added context stat
16298 + * V0.16 have __create claim() the vxi
16299 + * V0.17 removed older and legacy stuff
16300 + * V0.18 added user credentials
16304 +#include <linux/slab.h>
16305 +#include <linux/types.h>
16306 +#include <linux/security.h>
16307 +#include <linux/pid_namespace.h>
16308 +#include <linux/capability.h>
16310 +#include <linux/vserver/context.h>
16311 +#include <linux/vserver/network.h>
16312 +#include <linux/vserver/debug.h>
16313 +#include <linux/vserver/limit.h>
16314 +#include <linux/vserver/limit_int.h>
16315 +#include <linux/vserver/space.h>
16316 +#include <linux/init_task.h>
16317 +#include <linux/fs_struct.h>
16318 +#include <linux/cred.h>
16320 +#include <linux/vs_context.h>
16321 +#include <linux/vs_limit.h>
16322 +#include <linux/vs_pid.h>
16323 +#include <linux/vserver/context_cmd.h>
16325 +#include "cvirt_init.h"
16326 +#include "cacct_init.h"
16327 +#include "limit_init.h"
16328 +#include "sched_init.h"
16331 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
16332 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
16335 +/* now inactive context structures */
16337 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
16339 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
16342 +/* __alloc_vx_info()
16344 + * allocate an initialized vx_info struct
16345 + * doesn't make it visible (hash) */
16347 +static struct vx_info *__alloc_vx_info(xid_t xid)
16349 + struct vx_info *new = NULL;
16352 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
16354 + /* would this benefit from a slab cache? */
16355 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
16359 + memset(new, 0, sizeof(struct vx_info));
16361 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
16362 + if (!new->ptr_pc)
16365 + new->vx_id = xid;
16366 + INIT_HLIST_NODE(&new->vx_hlist);
16367 + atomic_set(&new->vx_usecnt, 0);
16368 + atomic_set(&new->vx_tasks, 0);
16369 + new->vx_parent = NULL;
16370 + new->vx_state = 0;
16371 + init_waitqueue_head(&new->vx_wait);
16373 + /* prepare reaper */
16374 + get_task_struct(init_pid_ns.child_reaper);
16375 + new->vx_reaper = init_pid_ns.child_reaper;
16376 + new->vx_badness_bias = 0;
16378 + /* rest of init goes here */
16379 + vx_info_init_limit(&new->limit);
16380 + vx_info_init_sched(&new->sched);
16381 + vx_info_init_cvirt(&new->cvirt);
16382 + vx_info_init_cacct(&new->cacct);
16384 + /* per cpu data structures */
16385 + for_each_possible_cpu(cpu) {
16386 + vx_info_init_sched_pc(
16387 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16388 + vx_info_init_cvirt_pc(
16389 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16392 + new->vx_flags = VXF_INIT_SET;
16393 + new->vx_bcaps = CAP_FULL_SET;
16394 + new->vx_ccaps = 0;
16395 + new->vx_umask = 0;
16397 + new->reboot_cmd = 0;
16398 + new->exit_code = 0;
16400 + // preconfig spaces
16401 + for (index = 0; index < VX_SPACES; index++) {
16402 + struct _vx_space *space = &new->space[index];
16405 + spin_lock(&init_fs.lock);
16407 + spin_unlock(&init_fs.lock);
16408 + space->vx_fs = &init_fs;
16410 + /* FIXME: do we want defaults? */
16411 + // space->vx_real_cred = 0;
16412 + // space->vx_cred = 0;
16416 + vxdprintk(VXD_CBIT(xid, 0),
16417 + "alloc_vx_info(%d) = %p", xid, new);
16418 + vxh_alloc_vx_info(new);
16419 + atomic_inc(&vx_global_ctotal);
16428 +/* __dealloc_vx_info()
16430 + * final disposal of vx_info */
16432 +static void __dealloc_vx_info(struct vx_info *vxi)
16434 +#ifdef CONFIG_VSERVER_WARN
16435 + struct vx_info_save vxis;
16438 + vxdprintk(VXD_CBIT(xid, 0),
16439 + "dealloc_vx_info(%p)", vxi);
16440 + vxh_dealloc_vx_info(vxi);
16442 +#ifdef CONFIG_VSERVER_WARN
16443 + enter_vx_info(vxi, &vxis);
16444 + vx_info_exit_limit(&vxi->limit);
16445 + vx_info_exit_sched(&vxi->sched);
16446 + vx_info_exit_cvirt(&vxi->cvirt);
16447 + vx_info_exit_cacct(&vxi->cacct);
16449 + for_each_possible_cpu(cpu) {
16450 + vx_info_exit_sched_pc(
16451 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16452 + vx_info_exit_cvirt_pc(
16453 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16455 + leave_vx_info(&vxis);
16459 + vxi->vx_state |= VXS_RELEASED;
16462 + free_percpu(vxi->ptr_pc);
16465 + atomic_dec(&vx_global_ctotal);
16468 +static void __shutdown_vx_info(struct vx_info *vxi)
16470 + struct nsproxy *nsproxy;
16471 + struct fs_struct *fs;
16472 + struct cred *cred;
16477 + vxi->vx_state |= VXS_SHUTDOWN;
16478 + vs_state_change(vxi, VSC_SHUTDOWN);
16480 + for (index = 0; index < VX_SPACES; index++) {
16481 + struct _vx_space *space = &vxi->space[index];
16483 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16485 + put_nsproxy(nsproxy);
16487 + fs = xchg(&space->vx_fs, NULL);
16488 + spin_lock(&fs->lock);
16489 + kill = !--fs->users;
16490 + spin_unlock(&fs->lock);
16492 + free_fs_struct(fs);
16494 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
16496 + abort_creds(cred);
16500 +/* exported stuff */
16502 +void free_vx_info(struct vx_info *vxi)
16504 + unsigned long flags;
16507 + /* check for reference counts first */
16508 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16509 + BUG_ON(atomic_read(&vxi->vx_tasks));
16511 + /* context must not be hashed */
16512 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16514 + /* context shutdown is mandatory */
16515 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16517 + /* spaces check */
16518 + for (index = 0; index < VX_SPACES; index++) {
16519 + struct _vx_space *space = &vxi->space[index];
16521 + BUG_ON(space->vx_nsproxy);
16522 + BUG_ON(space->vx_fs);
16523 + // BUG_ON(space->vx_real_cred);
16524 + // BUG_ON(space->vx_cred);
16527 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16528 + hlist_del(&vxi->vx_hlist);
16529 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16531 + __dealloc_vx_info(vxi);
16535 +/* hash table for vx_info hash */
16537 +#define VX_HASH_SIZE 13
16539 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16540 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16542 +static DEFINE_SPINLOCK(vx_info_hash_lock);
16545 +static inline unsigned int __hashval(xid_t xid)
16547 + return (xid % VX_HASH_SIZE);
16552 +/* __hash_vx_info()
16554 + * add the vxi to the global hash table
16555 + * requires the hash_lock to be held */
16557 +static inline void __hash_vx_info(struct vx_info *vxi)
16559 + struct hlist_head *head;
16561 + vxd_assert_lock(&vx_info_hash_lock);
16562 + vxdprintk(VXD_CBIT(xid, 4),
16563 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16564 + vxh_hash_vx_info(vxi);
16566 + /* context must not be hashed */
16567 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16569 + vxi->vx_state |= VXS_HASHED;
16570 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16571 + hlist_add_head(&vxi->vx_hlist, head);
16572 + atomic_inc(&vx_global_cactive);
16575 +/* __unhash_vx_info()
16577 + * remove the vxi from the global hash table
16578 + * requires the hash_lock to be held */
16580 +static inline void __unhash_vx_info(struct vx_info *vxi)
16582 + unsigned long flags;
16584 + vxd_assert_lock(&vx_info_hash_lock);
16585 + vxdprintk(VXD_CBIT(xid, 4),
16586 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16587 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16588 + vxh_unhash_vx_info(vxi);
16590 + /* context must be hashed */
16591 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16592 + /* but without tasks */
16593 + BUG_ON(atomic_read(&vxi->vx_tasks));
16595 + vxi->vx_state &= ~VXS_HASHED;
16596 + hlist_del_init(&vxi->vx_hlist);
16597 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16598 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16599 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16600 + atomic_dec(&vx_global_cactive);
16604 +/* __lookup_vx_info()
16606 + * requires the hash_lock to be held
16607 + * doesn't increment the vx_refcnt */
16609 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16611 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16612 + struct hlist_node *pos;
16613 + struct vx_info *vxi;
16615 + vxd_assert_lock(&vx_info_hash_lock);
16616 + hlist_for_each(pos, head) {
16617 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16619 + if (vxi->vx_id == xid)
16624 + vxdprintk(VXD_CBIT(xid, 0),
16625 + "__lookup_vx_info(#%u): %p[#%u]",
16626 + xid, vxi, vxi ? vxi->vx_id : 0);
16627 + vxh_lookup_vx_info(vxi, xid);
16632 +/* __create_vx_info()
16634 + * create the requested context
16635 + * get(), claim() and hash it */
16637 +static struct vx_info *__create_vx_info(int id)
16639 + struct vx_info *new, *vxi = NULL;
16641 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16643 + if (!(new = __alloc_vx_info(id)))
16644 + return ERR_PTR(-ENOMEM);
16646 + /* required to make dynamic xids unique */
16647 + spin_lock(&vx_info_hash_lock);
16649 + /* static context requested */
16650 + if ((vxi = __lookup_vx_info(id))) {
16651 + vxdprintk(VXD_CBIT(xid, 0),
16652 + "create_vx_info(%d) = %p (already there)", id, vxi);
16653 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16654 + vxi = ERR_PTR(-EBUSY);
16656 + vxi = ERR_PTR(-EEXIST);
16659 + /* new context */
16660 + vxdprintk(VXD_CBIT(xid, 0),
16661 + "create_vx_info(%d) = %p (new)", id, new);
16662 + claim_vx_info(new, NULL);
16663 + __hash_vx_info(get_vx_info(new));
16664 + vxi = new, new = NULL;
16667 + spin_unlock(&vx_info_hash_lock);
16668 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16670 + __dealloc_vx_info(new);
16675 +/* exported stuff */
16678 +void unhash_vx_info(struct vx_info *vxi)
16680 + spin_lock(&vx_info_hash_lock);
16681 + __unhash_vx_info(vxi);
16682 + spin_unlock(&vx_info_hash_lock);
16683 + __shutdown_vx_info(vxi);
16684 + __wakeup_vx_info(vxi);
16688 +/* lookup_vx_info()
16690 + * search for a vx_info and get() it
16691 + * negative id means current */
16693 +struct vx_info *lookup_vx_info(int id)
16695 + struct vx_info *vxi = NULL;
16698 + vxi = get_vx_info(current_vx_info());
16699 + } else if (id > 1) {
16700 + spin_lock(&vx_info_hash_lock);
16701 + vxi = get_vx_info(__lookup_vx_info(id));
16702 + spin_unlock(&vx_info_hash_lock);
16707 +/* xid_is_hashed()
16709 + * verify that xid is still hashed */
16711 +int xid_is_hashed(xid_t xid)
16715 + spin_lock(&vx_info_hash_lock);
16716 + hashed = (__lookup_vx_info(xid) != NULL);
16717 + spin_unlock(&vx_info_hash_lock);
16721 +#ifdef CONFIG_PROC_FS
16725 + * get a subset of hashed xids for proc
16726 + * assumes size is at least one */
16728 +int get_xid_list(int index, unsigned int *xids, int size)
16730 + int hindex, nr_xids = 0;
16732 + /* only show current and children */
16733 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16736 + xids[nr_xids] = vx_current_xid();
16740 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16741 + struct hlist_head *head = &vx_info_hash[hindex];
16742 + struct hlist_node *pos;
16744 + spin_lock(&vx_info_hash_lock);
16745 + hlist_for_each(pos, head) {
16746 + struct vx_info *vxi;
16751 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16752 + xids[nr_xids] = vxi->vx_id;
16753 + if (++nr_xids >= size) {
16754 + spin_unlock(&vx_info_hash_lock);
16758 + /* keep the lock time short */
16759 + spin_unlock(&vx_info_hash_lock);
16766 +#ifdef CONFIG_VSERVER_DEBUG
16768 +void dump_vx_info_inactive(int level)
16770 + struct hlist_node *entry, *next;
16772 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16773 + struct vx_info *vxi =
16774 + list_entry(entry, struct vx_info, vx_hlist);
16776 + dump_vx_info(vxi, level);
16783 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16785 + struct user_struct *new_user, *old_user;
16790 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16793 + new_user = alloc_uid(vxi->vx_id, p->uid);
16797 + old_user = p->user;
16798 + if (new_user != old_user) {
16799 + atomic_inc(&new_user->processes);
16800 + atomic_dec(&old_user->processes);
16801 + p->user = new_user;
16803 + free_uid(old_user);
16809 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16811 + // p->cap_effective &= vxi->vx_cap_bset;
16812 + p->cap_effective =
16813 + cap_intersect(p->cap_effective, vxi->cap_bset);
16814 + // p->cap_inheritable &= vxi->vx_cap_bset;
16815 + p->cap_inheritable =
16816 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16817 + // p->cap_permitted &= vxi->vx_cap_bset;
16818 + p->cap_permitted =
16819 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16824 +#include <linux/file.h>
16825 +#include <linux/fdtable.h>
16827 +static int vx_openfd_task(struct task_struct *tsk)
16829 + struct files_struct *files = tsk->files;
16830 + struct fdtable *fdt;
16831 + const unsigned long *bptr;
16832 + int count, total;
16834 + /* no rcu_read_lock() because of spin_lock() */
16835 + spin_lock(&files->file_lock);
16836 + fdt = files_fdtable(files);
16837 + bptr = fdt->open_fds->fds_bits;
16838 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16839 + for (total = 0; count > 0; count--) {
16841 + total += hweight_long(*bptr);
16844 + spin_unlock(&files->file_lock);
16849 +/* for *space compatibility */
16851 +asmlinkage long sys_unshare(unsigned long);
16854 + * migrate task to new context
16855 + * gets vxi, puts old_vxi on change
16856 + * optionally unshares namespaces (hack)
16859 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16861 + struct vx_info *old_vxi;
16867 + vxdprintk(VXD_CBIT(xid, 5),
16868 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16869 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16871 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16872 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16875 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16878 + old_vxi = task_get_vx_info(p);
16879 + if (old_vxi == vxi)
16882 +// if (!(ret = vx_migrate_user(p, vxi))) {
16887 + openfd = vx_openfd_task(p);
16890 + atomic_dec(&old_vxi->cvirt.nr_threads);
16891 + atomic_dec(&old_vxi->cvirt.nr_running);
16892 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16893 + /* FIXME: what about the struct files here? */
16894 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16895 + /* account for the executable */
16896 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16898 + atomic_inc(&vxi->cvirt.nr_threads);
16899 + atomic_inc(&vxi->cvirt.nr_running);
16900 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16901 + /* FIXME: what about the struct files here? */
16902 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16903 + /* account for the executable */
16904 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16907 + release_vx_info(old_vxi, p);
16908 + clr_vx_info(&p->vx_info);
16910 + claim_vx_info(vxi, p);
16911 + set_vx_info(&p->vx_info, vxi);
16912 + p->xid = vxi->vx_id;
16914 + vxdprintk(VXD_CBIT(xid, 5),
16915 + "moved task %p into vxi:%p[#%d]",
16916 + p, vxi, vxi->vx_id);
16918 + // vx_mask_cap_bset(vxi, p);
16921 + /* hack for *spaces to provide compatibility */
16923 + struct nsproxy *old_nsp, *new_nsp;
16925 + ret = unshare_nsproxy_namespaces(
16926 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16931 + old_nsp = xchg(&p->nsproxy, new_nsp);
16932 + vx_set_space(vxi,
16933 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16934 + put_nsproxy(old_nsp);
16938 + put_vx_info(old_vxi);
16942 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16944 + struct task_struct *old_reaper;
16949 + vxdprintk(VXD_CBIT(xid, 6),
16950 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16951 + vxi, vxi->vx_id, p, p->xid, p->pid);
16953 + old_reaper = vxi->vx_reaper;
16954 + if (old_reaper == p)
16957 + /* set new child reaper */
16958 + get_task_struct(p);
16959 + vxi->vx_reaper = p;
16960 + put_task_struct(old_reaper);
16964 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16969 + vxdprintk(VXD_CBIT(xid, 6),
16970 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16971 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16973 + vxi->vx_flags &= ~VXF_STATE_INIT;
16974 + // vxi->vx_initpid = p->tgid;
16975 + vxi->vx_initpid = p->pid;
16979 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16981 + vxdprintk(VXD_CBIT(xid, 6),
16982 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16983 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16985 + vxi->exit_code = code;
16986 + vxi->vx_initpid = 0;
16990 +void vx_set_persistent(struct vx_info *vxi)
16992 + vxdprintk(VXD_CBIT(xid, 6),
16993 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16995 + get_vx_info(vxi);
16996 + claim_vx_info(vxi, NULL);
16999 +void vx_clear_persistent(struct vx_info *vxi)
17001 + vxdprintk(VXD_CBIT(xid, 6),
17002 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
17004 + release_vx_info(vxi, NULL);
17005 + put_vx_info(vxi);
17008 +void vx_update_persistent(struct vx_info *vxi)
17010 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
17011 + vx_set_persistent(vxi);
17013 + vx_clear_persistent(vxi);
17017 +/* task must be current or locked */
17019 +void exit_vx_info(struct task_struct *p, int code)
17021 + struct vx_info *vxi = p->vx_info;
17024 + atomic_dec(&vxi->cvirt.nr_threads);
17027 + vxi->exit_code = code;
17028 + release_vx_info(vxi, p);
17032 +void exit_vx_info_early(struct task_struct *p, int code)
17034 + struct vx_info *vxi = p->vx_info;
17037 + if (vxi->vx_initpid == p->pid)
17038 + vx_exit_init(vxi, p, code);
17039 + if (vxi->vx_reaper == p)
17040 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
17045 +/* vserver syscall commands below here */
17047 +/* taks xid and vx_info functions */
17049 +#include <asm/uaccess.h>
17052 +int vc_task_xid(uint32_t id)
17057 + struct task_struct *tsk;
17060 + tsk = find_task_by_real_pid(id);
17061 + xid = (tsk) ? tsk->xid : -ESRCH;
17062 + rcu_read_unlock();
17064 + xid = vx_current_xid();
17069 +int vc_vx_info(struct vx_info *vxi, void __user *data)
17071 + struct vcmd_vx_info_v0 vc_data;
17073 + vc_data.xid = vxi->vx_id;
17074 + vc_data.initpid = vxi->vx_initpid;
17076 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17082 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
17084 + struct vcmd_ctx_stat_v0 vc_data;
17086 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
17087 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
17089 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17095 +/* context functions */
17097 +int vc_ctx_create(uint32_t xid, void __user *data)
17099 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
17100 + struct vx_info *new_vxi;
17103 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17106 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
17109 + new_vxi = __create_vx_info(xid);
17110 + if (IS_ERR(new_vxi))
17111 + return PTR_ERR(new_vxi);
17113 + /* initial flags */
17114 + new_vxi->vx_flags = vc_data.flagword;
17117 + if (vs_state_change(new_vxi, VSC_STARTUP))
17120 + ret = vx_migrate_task(current, new_vxi, (!data));
17124 + /* return context id on success */
17125 + ret = new_vxi->vx_id;
17127 + /* get a reference for persistent contexts */
17128 + if ((vc_data.flagword & VXF_PERSISTENT))
17129 + vx_set_persistent(new_vxi);
17131 + release_vx_info(new_vxi, NULL);
17132 + put_vx_info(new_vxi);
17137 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
17139 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
17142 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17145 + ret = vx_migrate_task(current, vxi, 0);
17148 + if (vc_data.flagword & VXM_SET_INIT)
17149 + ret = vx_set_init(vxi, current);
17152 + if (vc_data.flagword & VXM_SET_REAPER)
17153 + ret = vx_set_reaper(vxi, current);
17158 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
17160 + struct vcmd_ctx_flags_v0 vc_data;
17162 + vc_data.flagword = vxi->vx_flags;
17164 + /* special STATE flag handling */
17165 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
17167 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17172 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
17174 + struct vcmd_ctx_flags_v0 vc_data;
17175 + uint64_t mask, trigger;
17177 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17180 + /* special STATE flag handling */
17181 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
17182 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
17184 + if (vxi == current_vx_info()) {
17185 + /* if (trigger & VXF_STATE_SETUP)
17186 + vx_mask_cap_bset(vxi, current); */
17187 + if (trigger & VXF_STATE_INIT) {
17190 + ret = vx_set_init(vxi, current);
17193 + ret = vx_set_reaper(vxi, current);
17199 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17200 + vc_data.flagword, mask);
17201 + if (trigger & VXF_PERSISTENT)
17202 + vx_update_persistent(vxi);
17208 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17210 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17212 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17216 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17218 + kernel_cap_t c = __cap_empty_set;
17220 + c.cap[0] = v & 0xFFFFFFFF;
17221 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17223 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17228 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17231 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17233 + *ccaps = vxi->vx_ccaps;
17238 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17240 + struct vcmd_ctx_caps_v1 vc_data;
17243 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17246 + vc_data.cmask = ~0ULL;
17248 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17253 +static int do_set_caps(struct vx_info *vxi,
17254 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
17256 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
17259 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
17260 + bcaps, bmask, ccaps, cmask);
17262 + vxi->vx_bcaps = cap_t_from_caps(
17263 + vs_mask_flags(bcold, bcaps, bmask));
17264 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
17269 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
17271 + struct vcmd_ctx_caps_v1 vc_data;
17273 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17276 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
17279 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
17281 + struct vcmd_bcaps vc_data;
17284 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
17287 + vc_data.bmask = ~0ULL;
17289 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17294 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
17296 + struct vcmd_bcaps vc_data;
17298 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17301 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
17305 +int vc_get_umask(struct vx_info *vxi, void __user *data)
17307 + struct vcmd_umask vc_data;
17309 + vc_data.umask = vxi->vx_umask;
17310 + vc_data.mask = ~0ULL;
17312 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17317 +int vc_set_umask(struct vx_info *vxi, void __user *data)
17319 + struct vcmd_umask vc_data;
17321 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17324 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
17325 + vc_data.umask, vc_data.mask);
17330 +int vc_get_badness(struct vx_info *vxi, void __user *data)
17332 + struct vcmd_badness_v0 vc_data;
17334 + vc_data.bias = vxi->vx_badness_bias;
17336 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17341 +int vc_set_badness(struct vx_info *vxi, void __user *data)
17343 + struct vcmd_badness_v0 vc_data;
17345 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17348 + vxi->vx_badness_bias = vc_data.bias;
17352 +#include <linux/module.h>
17354 +EXPORT_SYMBOL_GPL(free_vx_info);
17356 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/cvirt.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/cvirt.c
17357 --- linux-3.0-rc5/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
17358 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/cvirt.c 2011-06-13 14:57:26.000000000 +0200
17361 + * linux/kernel/vserver/cvirt.c
17363 + * Virtual Server: Context Virtualization
17365 + * Copyright (C) 2004-2007 Herbert Pötzl
17367 + * V0.01 broken out from limit.c
17368 + * V0.02 added utsname stuff
17369 + * V0.03 changed vcmds to vxi arg
17373 +#include <linux/types.h>
17374 +#include <linux/utsname.h>
17375 +#include <linux/vs_cvirt.h>
17376 +#include <linux/vserver/switch.h>
17377 +#include <linux/vserver/cvirt_cmd.h>
17379 +#include <asm/uaccess.h>
17382 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17384 + struct vx_info *vxi = current_vx_info();
17386 + set_normalized_timespec(uptime,
17387 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17388 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17391 + set_normalized_timespec(idle,
17392 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17393 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17397 +uint64_t vx_idle_jiffies(void)
17399 + return init_task.utime + init_task.stime;
17404 +static inline uint32_t __update_loadavg(uint32_t load,
17405 + int wsize, int delta, int n)
17407 + unsigned long long calc, prev;
17409 + /* just set it to n */
17410 + if (unlikely(delta >= wsize))
17411 + return (n << FSHIFT);
17413 + calc = delta * n;
17415 + prev = (wsize - delta);
17418 + do_div(calc, wsize);
17423 +void vx_update_load(struct vx_info *vxi)
17425 + uint32_t now, last, delta;
17426 + unsigned int nr_running, nr_uninterruptible;
17427 + unsigned int total;
17428 + unsigned long flags;
17430 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17433 + last = vxi->cvirt.load_last;
17434 + delta = now - last;
17436 + if (delta < 5*HZ)
17439 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17440 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17441 + total = nr_running + nr_uninterruptible;
17443 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17444 + 60*HZ, delta, total);
17445 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17446 + 5*60*HZ, delta, total);
17447 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17448 + 15*60*HZ, delta, total);
17450 + vxi->cvirt.load_last = now;
17452 + atomic_inc(&vxi->cvirt.load_updates);
17453 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17458 + * Commands to do_syslog:
17460 + * 0 -- Close the log. Currently a NOP.
17461 + * 1 -- Open the log. Currently a NOP.
17462 + * 2 -- Read from the log.
17463 + * 3 -- Read all messages remaining in the ring buffer.
17464 + * 4 -- Read and clear all messages remaining in the ring buffer
17465 + * 5 -- Clear ring buffer.
17466 + * 6 -- Disable printk's to console
17467 + * 7 -- Enable printk's to console
17468 + * 8 -- Set level of messages printed to console
17469 + * 9 -- Return number of unread characters in the log buffer
17470 + * 10 -- Return size of the log buffer
17472 +int vx_do_syslog(int type, char __user *buf, int len)
17475 + int do_clear = 0;
17476 + struct vx_info *vxi = current_vx_info();
17477 + struct _vx_syslog *log;
17481 + log = &vxi->cvirt.syslog;
17484 + case 0: /* Close log */
17485 + case 1: /* Open log */
17487 + case 2: /* Read from log */
17488 + error = wait_event_interruptible(log->log_wait,
17489 + (log->log_start - log->log_end));
17492 + spin_lock_irq(&log->logbuf_lock);
17493 + spin_unlock_irq(&log->logbuf_lock);
17495 + case 4: /* Read/clear last kernel messages */
17497 + /* fall through */
17498 + case 3: /* Read last kernel messages */
17501 + case 5: /* Clear ring buffer */
17504 + case 6: /* Disable logging to console */
17505 + case 7: /* Enable logging to console */
17506 + case 8: /* Set level of messages printed to console */
17509 + case 9: /* Number of chars in the log buffer */
17511 + case 10: /* Size of the log buffer */
17521 +/* virtual host info names */
17523 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17525 + struct nsproxy *nsproxy;
17526 + struct uts_namespace *uts;
17528 + if (id == VHIN_CONTEXT)
17529 + return vxi->vx_name;
17531 + nsproxy = vxi->space[0].vx_nsproxy;
17535 + uts = nsproxy->uts_ns;
17540 + case VHIN_SYSNAME:
17541 + return uts->name.sysname;
17542 + case VHIN_NODENAME:
17543 + return uts->name.nodename;
17544 + case VHIN_RELEASE:
17545 + return uts->name.release;
17546 + case VHIN_VERSION:
17547 + return uts->name.version;
17548 + case VHIN_MACHINE:
17549 + return uts->name.machine;
17550 + case VHIN_DOMAINNAME:
17551 + return uts->name.domainname;
17558 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17560 + struct vcmd_vhi_name_v0 vc_data;
17563 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17566 + name = vx_vhi_name(vxi, vc_data.field);
17570 + memcpy(name, vc_data.name, 65);
17574 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17576 + struct vcmd_vhi_name_v0 vc_data;
17579 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17582 + name = vx_vhi_name(vxi, vc_data.field);
17586 + memcpy(vc_data.name, name, 65);
17587 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17593 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17595 + struct vcmd_virt_stat_v0 vc_data;
17596 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17597 + struct timespec uptime;
17599 + do_posix_clock_monotonic_gettime(&uptime);
17600 + set_normalized_timespec(&uptime,
17601 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17602 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17604 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17605 + vc_data.uptime = timespec_to_ns(&uptime);
17606 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17607 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17608 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17609 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17610 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17611 + vc_data.load[0] = cvirt->load[0];
17612 + vc_data.load[1] = cvirt->load[1];
17613 + vc_data.load[2] = cvirt->load[2];
17615 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17621 +#ifdef CONFIG_VSERVER_VTIME
17623 +/* virtualized time base */
17625 +void vx_adjust_timespec(struct timespec *ts)
17627 + struct vx_info *vxi;
17629 + if (!vx_flags(VXF_VIRT_TIME, 0))
17632 + vxi = current_vx_info();
17633 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17634 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17636 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17638 + ts->tv_nsec -= NSEC_PER_SEC;
17639 + } else if (ts->tv_nsec < 0) {
17641 + ts->tv_nsec += NSEC_PER_SEC;
17645 +int vx_settimeofday(const struct timespec *ts)
17647 + struct timespec ats, delta;
17648 + struct vx_info *vxi;
17650 + if (!vx_flags(VXF_VIRT_TIME, 0))
17651 + return do_settimeofday(ts);
17653 + getnstimeofday(&ats);
17654 + delta = timespec_sub(*ts, ats);
17656 + vxi = current_vx_info();
17657 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17663 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/cvirt_init.h linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/cvirt_init.h
17664 --- linux-3.0-rc5/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17665 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/cvirt_init.h 2011-06-10 22:11:24.000000000 +0200
17669 +extern uint64_t vx_idle_jiffies(void);
17671 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17673 + uint64_t idle_jiffies = vx_idle_jiffies();
17674 + uint64_t nsuptime;
17676 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17677 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17678 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17679 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17680 + cvirt->bias_ts.tv_sec = 0;
17681 + cvirt->bias_ts.tv_nsec = 0;
17683 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17684 + atomic_set(&cvirt->nr_threads, 0);
17685 + atomic_set(&cvirt->nr_running, 0);
17686 + atomic_set(&cvirt->nr_uninterruptible, 0);
17687 + atomic_set(&cvirt->nr_onhold, 0);
17689 + spin_lock_init(&cvirt->load_lock);
17690 + cvirt->load_last = jiffies;
17691 + atomic_set(&cvirt->load_updates, 0);
17692 + cvirt->load[0] = 0;
17693 + cvirt->load[1] = 0;
17694 + cvirt->load[2] = 0;
17695 + atomic_set(&cvirt->total_forks, 0);
17697 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17698 + init_waitqueue_head(&cvirt->syslog.log_wait);
17699 + cvirt->syslog.log_start = 0;
17700 + cvirt->syslog.log_end = 0;
17701 + cvirt->syslog.con_start = 0;
17702 + cvirt->syslog.logged_chars = 0;
17706 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17708 + // cvirt_pc->cpustat = { 0 };
17711 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17713 +#ifdef CONFIG_VSERVER_WARN
17716 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17717 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17719 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17720 + "!!! cvirt: %p[nr_running] = %d on exit.",
17722 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17723 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17725 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17726 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17732 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17737 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/cvirt_proc.h linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/cvirt_proc.h
17738 --- linux-3.0-rc5/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17739 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/cvirt_proc.h 2011-06-10 22:11:24.000000000 +0200
17741 +#ifndef _VX_CVIRT_PROC_H
17742 +#define _VX_CVIRT_PROC_H
17744 +#include <linux/nsproxy.h>
17745 +#include <linux/mnt_namespace.h>
17746 +#include <linux/ipc_namespace.h>
17747 +#include <linux/utsname.h>
17748 +#include <linux/ipc.h>
17752 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17754 + struct mnt_namespace *ns;
17755 + struct uts_namespace *uts;
17756 + struct ipc_namespace *ipc;
17757 + struct path path;
17758 + char *pstr, *root;
17764 + length += sprintf(buffer + length,
17765 + "NSProxy:\t%p [%p,%p,%p]\n",
17766 + nsproxy, nsproxy->mnt_ns,
17767 + nsproxy->uts_ns, nsproxy->ipc_ns);
17769 + ns = nsproxy->mnt_ns;
17773 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17777 + path.mnt = ns->root;
17778 + path.dentry = ns->root->mnt_root;
17779 + root = d_path(&path, pstr, PATH_MAX - 2);
17780 + length += sprintf(buffer + length,
17781 + "Namespace:\t%p [#%u]\n"
17782 + "RootPath:\t%s\n",
17783 + ns, atomic_read(&ns->count),
17788 + uts = nsproxy->uts_ns;
17792 + length += sprintf(buffer + length,
17793 + "SysName:\t%.*s\n"
17794 + "NodeName:\t%.*s\n"
17795 + "Release:\t%.*s\n"
17796 + "Version:\t%.*s\n"
17797 + "Machine:\t%.*s\n"
17798 + "DomainName:\t%.*s\n",
17799 + __NEW_UTS_LEN, uts->name.sysname,
17800 + __NEW_UTS_LEN, uts->name.nodename,
17801 + __NEW_UTS_LEN, uts->name.release,
17802 + __NEW_UTS_LEN, uts->name.version,
17803 + __NEW_UTS_LEN, uts->name.machine,
17804 + __NEW_UTS_LEN, uts->name.domainname);
17807 + ipc = nsproxy->ipc_ns;
17811 + length += sprintf(buffer + length,
17812 + "SEMS:\t\t%d %d %d %d %d\n"
17813 + "MSG:\t\t%d %d %d\n"
17814 + "SHM:\t\t%lu %lu %d %d\n",
17815 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17816 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17818 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17819 + (unsigned long)ipc->shm_ctlmax,
17820 + (unsigned long)ipc->shm_ctlall,
17821 + ipc->shm_ctlmni, ipc->shm_tot);
17828 +#include <linux/sched.h>
17830 +#define LOAD_INT(x) ((x) >> FSHIFT)
17831 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17834 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17839 + length += sprintf(buffer + length,
17840 + "BiasUptime:\t%lu.%02lu\n",
17841 + (unsigned long)cvirt->bias_uptime.tv_sec,
17842 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17844 + a = cvirt->load[0] + (FIXED_1 / 200);
17845 + b = cvirt->load[1] + (FIXED_1 / 200);
17846 + c = cvirt->load[2] + (FIXED_1 / 200);
17847 + length += sprintf(buffer + length,
17848 + "nr_threads:\t%d\n"
17849 + "nr_running:\t%d\n"
17850 + "nr_unintr:\t%d\n"
17851 + "nr_onhold:\t%d\n"
17852 + "load_updates:\t%d\n"
17853 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17854 + "total_forks:\t%d\n",
17855 + atomic_read(&cvirt->nr_threads),
17856 + atomic_read(&cvirt->nr_running),
17857 + atomic_read(&cvirt->nr_uninterruptible),
17858 + atomic_read(&cvirt->nr_onhold),
17859 + atomic_read(&cvirt->load_updates),
17860 + LOAD_INT(a), LOAD_FRAC(a),
17861 + LOAD_INT(b), LOAD_FRAC(b),
17862 + LOAD_INT(c), LOAD_FRAC(c),
17863 + atomic_read(&cvirt->total_forks));
17868 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17869 + char *buffer, int cpu)
17875 +#endif /* _VX_CVIRT_PROC_H */
17876 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/debug.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/debug.c
17877 --- linux-3.0-rc5/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17878 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/debug.c 2011-06-10 22:11:24.000000000 +0200
17881 + * kernel/vserver/debug.c
17883 + * Copyright (C) 2005-2007 Herbert Pötzl
17885 + * V0.01 vx_info dump support
17889 +#include <linux/module.h>
17891 +#include <linux/vserver/context.h>
17894 +void dump_vx_info(struct vx_info *vxi, int level)
17896 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17897 + atomic_read(&vxi->vx_usecnt),
17898 + atomic_read(&vxi->vx_tasks),
17901 + __dump_vx_limit(&vxi->limit);
17902 + __dump_vx_sched(&vxi->sched);
17903 + __dump_vx_cvirt(&vxi->cvirt);
17904 + __dump_vx_cacct(&vxi->cacct);
17910 +EXPORT_SYMBOL_GPL(dump_vx_info);
17912 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/device.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/device.c
17913 --- linux-3.0-rc5/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17914 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/device.c 2011-06-10 23:20:56.000000000 +0200
17917 + * linux/kernel/vserver/device.c
17919 + * Linux-VServer: Device Support
17921 + * Copyright (C) 2006 Herbert Pötzl
17922 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17924 + * V0.01 device mapping basics
17925 + * V0.02 added defaults
17929 +#include <linux/slab.h>
17930 +#include <linux/rcupdate.h>
17931 +#include <linux/fs.h>
17932 +#include <linux/namei.h>
17933 +#include <linux/hash.h>
17935 +#include <asm/errno.h>
17936 +#include <asm/uaccess.h>
17937 +#include <linux/vserver/base.h>
17938 +#include <linux/vserver/debug.h>
17939 +#include <linux/vserver/context.h>
17940 +#include <linux/vserver/device.h>
17941 +#include <linux/vserver/device_cmd.h>
17944 +#define DMAP_HASH_BITS 4
17947 +struct vs_mapping {
17949 + struct hlist_node hlist;
17950 + struct list_head list;
17952 +#define dm_hlist u.hlist
17953 +#define dm_list u.list
17956 + struct vx_dmap_target target;
17960 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17962 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17964 +static struct vx_dmap_target dmap_defaults[2] = {
17965 + { .flags = DATTR_OPEN },
17966 + { .flags = DATTR_OPEN },
17970 +struct kmem_cache *dmap_cachep __read_mostly;
17972 +int __init dmap_cache_init(void)
17974 + dmap_cachep = kmem_cache_create("dmap_cache",
17975 + sizeof(struct vs_mapping), 0,
17976 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17980 +__initcall(dmap_cache_init);
17983 +static inline unsigned int __hashval(dev_t dev, int bits)
17985 + return hash_long((unsigned long)dev, bits);
17989 +/* __hash_mapping()
17990 + * add the mapping to the hash table
17992 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17994 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17995 + struct hlist_head *head, *hash = dmap_main_hash;
17996 + int device = vdm->device;
17998 + spin_lock(hash_lock);
17999 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
18000 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
18002 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
18003 + hlist_add_head(&vdm->dm_hlist, head);
18004 + spin_unlock(hash_lock);
18008 +static inline int __mode_to_default(umode_t mode)
18021 +/* __set_default()
18024 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
18025 + struct vx_dmap_target *vdmt)
18027 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18028 + spin_lock(hash_lock);
18031 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
18033 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
18036 + spin_unlock(hash_lock);
18038 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
18039 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
18043 +/* __remove_default()
18044 + * remove a default
18046 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
18048 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18049 + spin_lock(hash_lock);
18052 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
18053 + else /* remove == reset */
18054 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
18056 + spin_unlock(hash_lock);
18061 +/* __find_mapping()
18062 + * find a mapping in the hash table
18064 + * caller must hold hash_lock
18066 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
18067 + struct vs_mapping **local, struct vs_mapping **global)
18069 + struct hlist_head *hash = dmap_main_hash;
18070 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
18071 + struct hlist_node *pos;
18072 + struct vs_mapping *vdm;
18078 + hlist_for_each(pos, head) {
18079 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
18081 + if ((vdm->device == device) &&
18082 + !((vdm->target.flags ^ mode) & S_IFMT)) {
18083 + if (vdm->xid == xid) {
18086 + } else if (global && vdm->xid == 0)
18091 + if (global && *global)
18098 +/* __lookup_mapping()
18099 + * find a mapping and store the result in target and flags
18101 +static inline int __lookup_mapping(struct vx_info *vxi,
18102 + dev_t device, dev_t *target, int *flags, umode_t mode)
18104 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18105 + struct vs_mapping *vdm, *global;
18106 + struct vx_dmap_target *vdmt;
18108 + xid_t xid = vxi->vx_id;
18111 + spin_lock(hash_lock);
18112 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
18114 + vdmt = &vdm->target;
18118 + index = __mode_to_default(mode);
18119 + if (vxi && vxi->dmap.targets[index].flags) {
18121 + vdmt = &vxi->dmap.targets[index];
18122 + } else if (global) {
18124 + vdmt = &global->target;
18128 + vdmt = &dmap_defaults[index];
18132 + if (target && (vdmt->flags & DATTR_REMAP))
18133 + *target = vdmt->target;
18135 + *target = device;
18137 + *flags = vdmt->flags;
18139 + spin_unlock(hash_lock);
18145 +/* __remove_mapping()
18146 + * remove a mapping from the hash table
18148 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
18151 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18152 + struct vs_mapping *vdm = NULL;
18155 + spin_lock(hash_lock);
18157 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
18159 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18160 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18163 + hlist_del(&vdm->dm_hlist);
18166 + spin_unlock(hash_lock);
18168 + kmem_cache_free(dmap_cachep, vdm);
18174 +int vs_map_device(struct vx_info *vxi,
18175 + dev_t device, dev_t *target, umode_t mode)
18177 + int ret, flags = DATTR_MASK;
18181 + *target = device;
18184 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18185 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18186 + device, target ? *target : 0, flags, mode, ret);
18188 + return (flags & DATTR_MASK);
18193 +static int do_set_mapping(struct vx_info *vxi,
18194 + dev_t device, dev_t target, int flags, umode_t mode)
18197 + struct vs_mapping *new;
18199 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18203 + INIT_HLIST_NODE(&new->dm_hlist);
18204 + new->device = device;
18205 + new->target.target = target;
18206 + new->target.flags = flags | mode;
18207 + new->xid = (vxi ? vxi->vx_id : 0);
18209 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18210 + __hash_mapping(vxi, new);
18212 + struct vx_dmap_target new = {
18213 + .target = target,
18214 + .flags = flags | mode,
18216 + __set_default(vxi, mode, &new);
18222 +static int do_unset_mapping(struct vx_info *vxi,
18223 + dev_t device, dev_t target, int flags, umode_t mode)
18225 + int ret = -EINVAL;
18228 + ret = __remove_mapping(vxi, device, mode);
18232 + ret = __remove_default(vxi, mode);
18242 +static inline int __user_device(const char __user *name, dev_t *dev,
18245 + struct nameidata nd;
18252 + ret = user_lpath(name, &nd.path);
18255 + if (nd.path.dentry->d_inode) {
18256 + *dev = nd.path.dentry->d_inode->i_rdev;
18257 + *mode = nd.path.dentry->d_inode->i_mode;
18259 + path_put(&nd.path);
18263 +static inline int __mapping_mode(dev_t device, dev_t target,
18264 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18267 + *mode = device_mode & S_IFMT;
18269 + *mode = target_mode & S_IFMT;
18273 + /* if both given, device and target mode have to match */
18274 + if (device && target &&
18275 + ((device_mode ^ target_mode) & S_IFMT))
18281 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18282 + const char __user *target_path, int flags, int set)
18284 + dev_t device = ~0, target = ~0;
18285 + umode_t device_mode = 0, target_mode = 0, mode;
18288 + ret = __user_device(device_path, &device, &device_mode);
18291 + ret = __user_device(target_path, &target, &target_mode);
18295 + ret = __mapping_mode(device, target,
18296 + device_mode, target_mode, &mode);
18301 + return do_set_mapping(vxi, device, target,
18304 + return do_unset_mapping(vxi, device, target,
18309 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
18311 + struct vcmd_set_mapping_v0 vc_data;
18313 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18316 + return do_mapping(vxi, vc_data.device, vc_data.target,
18317 + vc_data.flags, 1);
18320 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
18322 + struct vcmd_set_mapping_v0 vc_data;
18324 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18327 + return do_mapping(vxi, vc_data.device, vc_data.target,
18328 + vc_data.flags, 0);
18332 +#ifdef CONFIG_COMPAT
18334 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
18336 + struct vcmd_set_mapping_v0_x32 vc_data;
18338 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18341 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18342 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
18345 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18347 + struct vcmd_set_mapping_v0_x32 vc_data;
18349 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18352 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18353 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18356 +#endif /* CONFIG_COMPAT */
18359 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/dlimit.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/dlimit.c
18360 --- linux-3.0-rc5/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
18361 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/dlimit.c 2011-06-10 23:20:56.000000000 +0200
18364 + * linux/kernel/vserver/dlimit.c
18366 + * Virtual Server: Context Disk Limits
18368 + * Copyright (C) 2004-2009 Herbert Pötzl
18370 + * V0.01 initial version
18371 + * V0.02 compat32 splitup
18372 + * V0.03 extended interface
18376 +#include <linux/statfs.h>
18377 +#include <linux/sched.h>
18378 +#include <linux/namei.h>
18379 +#include <linux/vs_tag.h>
18380 +#include <linux/vs_dlimit.h>
18381 +#include <linux/vserver/dlimit_cmd.h>
18382 +#include <linux/slab.h>
18383 +// #include <linux/gfp.h>
18385 +#include <asm/uaccess.h>
18387 +/* __alloc_dl_info()
18389 + * allocate an initialized dl_info struct
18390 + * doesn't make it visible (hash) */
18392 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18394 + struct dl_info *new = NULL;
18396 + vxdprintk(VXD_CBIT(dlim, 5),
18397 + "alloc_dl_info(%p,%d)*", sb, tag);
18399 + /* would this benefit from a slab cache? */
18400 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18404 + memset(new, 0, sizeof(struct dl_info));
18405 + new->dl_tag = tag;
18407 + // INIT_RCU_HEAD(&new->dl_rcu);
18408 + INIT_HLIST_NODE(&new->dl_hlist);
18409 + spin_lock_init(&new->dl_lock);
18410 + atomic_set(&new->dl_refcnt, 0);
18411 + atomic_set(&new->dl_usecnt, 0);
18413 + /* rest of init goes here */
18415 + vxdprintk(VXD_CBIT(dlim, 4),
18416 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18420 +/* __dealloc_dl_info()
18422 + * final disposal of dl_info */
18424 +static void __dealloc_dl_info(struct dl_info *dli)
18426 + vxdprintk(VXD_CBIT(dlim, 4),
18427 + "dealloc_dl_info(%p)", dli);
18429 + dli->dl_hlist.next = LIST_POISON1;
18430 + dli->dl_tag = -1;
18433 + BUG_ON(atomic_read(&dli->dl_usecnt));
18434 + BUG_ON(atomic_read(&dli->dl_refcnt));
18440 +/* hash table for dl_info hash */
18442 +#define DL_HASH_SIZE 13
18444 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18446 +static DEFINE_SPINLOCK(dl_info_hash_lock);
18449 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18451 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18456 +/* __hash_dl_info()
18458 + * add the dli to the global hash table
18459 + * requires the hash_lock to be held */
18461 +static inline void __hash_dl_info(struct dl_info *dli)
18463 + struct hlist_head *head;
18465 + vxdprintk(VXD_CBIT(dlim, 6),
18466 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18467 + get_dl_info(dli);
18468 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18469 + hlist_add_head_rcu(&dli->dl_hlist, head);
18472 +/* __unhash_dl_info()
18474 + * remove the dli from the global hash table
18475 + * requires the hash_lock to be held */
18477 +static inline void __unhash_dl_info(struct dl_info *dli)
18479 + vxdprintk(VXD_CBIT(dlim, 6),
18480 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18481 + hlist_del_rcu(&dli->dl_hlist);
18482 + put_dl_info(dli);
18486 +/* __lookup_dl_info()
18488 + * requires the rcu_read_lock()
18489 + * doesn't increment the dl_refcnt */
18491 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18493 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18494 + struct hlist_node *pos;
18495 + struct dl_info *dli;
18497 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18499 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18507 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18509 + struct dl_info *dli;
18512 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18513 + vxdprintk(VXD_CBIT(dlim, 7),
18514 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18515 + rcu_read_unlock();
18519 +void rcu_free_dl_info(struct rcu_head *head)
18521 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18522 + int usecnt, refcnt;
18524 + BUG_ON(!dli || !head);
18526 + usecnt = atomic_read(&dli->dl_usecnt);
18527 + BUG_ON(usecnt < 0);
18529 + refcnt = atomic_read(&dli->dl_refcnt);
18530 + BUG_ON(refcnt < 0);
18532 + vxdprintk(VXD_CBIT(dlim, 3),
18533 + "rcu_free_dl_info(%p)", dli);
18535 + __dealloc_dl_info(dli);
18537 + printk("!!! rcu didn't free\n");
18543 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18544 + uint32_t flags, int add)
18546 + struct path path;
18549 + ret = user_lpath(name, &path);
18551 + struct super_block *sb;
18552 + struct dl_info *dli;
18555 + if (!path.dentry->d_inode)
18556 + goto out_release;
18557 + if (!(sb = path.dentry->d_inode->i_sb))
18558 + goto out_release;
18561 + dli = __alloc_dl_info(sb, id);
18562 + spin_lock(&dl_info_hash_lock);
18565 + if (__lookup_dl_info(sb, id))
18567 + __hash_dl_info(dli);
18570 + spin_lock(&dl_info_hash_lock);
18571 + dli = __lookup_dl_info(sb, id);
18576 + __unhash_dl_info(dli);
18580 + spin_unlock(&dl_info_hash_lock);
18582 + __dealloc_dl_info(dli);
18589 +int vc_add_dlimit(uint32_t id, void __user *data)
18591 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18593 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18596 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18599 +int vc_rem_dlimit(uint32_t id, void __user *data)
18601 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18603 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18606 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18609 +#ifdef CONFIG_COMPAT
18611 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18613 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18615 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18618 + return do_addrem_dlimit(id,
18619 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18622 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18624 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18626 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18629 + return do_addrem_dlimit(id,
18630 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18633 +#endif /* CONFIG_COMPAT */
18637 +int do_set_dlimit(uint32_t id, const char __user *name,
18638 + uint32_t space_used, uint32_t space_total,
18639 + uint32_t inodes_used, uint32_t inodes_total,
18640 + uint32_t reserved, uint32_t flags)
18642 + struct path path;
18645 + ret = user_lpath(name, &path);
18647 + struct super_block *sb;
18648 + struct dl_info *dli;
18651 + if (!path.dentry->d_inode)
18652 + goto out_release;
18653 + if (!(sb = path.dentry->d_inode->i_sb))
18654 + goto out_release;
18656 + /* sanity checks */
18657 + if ((reserved != CDLIM_KEEP &&
18658 + reserved > 100) ||
18659 + (inodes_used != CDLIM_KEEP &&
18660 + inodes_used > inodes_total) ||
18661 + (space_used != CDLIM_KEEP &&
18662 + space_used > space_total))
18663 + goto out_release;
18666 + dli = locate_dl_info(sb, id);
18668 + goto out_release;
18670 + spin_lock(&dli->dl_lock);
18672 + if (inodes_used != CDLIM_KEEP)
18673 + dli->dl_inodes_used = inodes_used;
18674 + if (inodes_total != CDLIM_KEEP)
18675 + dli->dl_inodes_total = inodes_total;
18676 + if (space_used != CDLIM_KEEP)
18677 + dli->dl_space_used = dlimit_space_32to64(
18678 + space_used, flags, DLIMS_USED);
18680 + if (space_total == CDLIM_INFINITY)
18681 + dli->dl_space_total = DLIM_INFINITY;
18682 + else if (space_total != CDLIM_KEEP)
18683 + dli->dl_space_total = dlimit_space_32to64(
18684 + space_total, flags, DLIMS_TOTAL);
18686 + if (reserved != CDLIM_KEEP)
18687 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18689 + spin_unlock(&dli->dl_lock);
18691 + put_dl_info(dli);
18700 +int vc_set_dlimit(uint32_t id, void __user *data)
18702 + struct vcmd_ctx_dlimit_v0 vc_data;
18704 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18707 + return do_set_dlimit(id, vc_data.name,
18708 + vc_data.space_used, vc_data.space_total,
18709 + vc_data.inodes_used, vc_data.inodes_total,
18710 + vc_data.reserved, vc_data.flags);
18713 +#ifdef CONFIG_COMPAT
18715 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18717 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18719 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18722 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18723 + vc_data.space_used, vc_data.space_total,
18724 + vc_data.inodes_used, vc_data.inodes_total,
18725 + vc_data.reserved, vc_data.flags);
18728 +#endif /* CONFIG_COMPAT */
18732 +int do_get_dlimit(uint32_t id, const char __user *name,
18733 + uint32_t *space_used, uint32_t *space_total,
18734 + uint32_t *inodes_used, uint32_t *inodes_total,
18735 + uint32_t *reserved, uint32_t *flags)
18737 + struct path path;
18740 + ret = user_lpath(name, &path);
18742 + struct super_block *sb;
18743 + struct dl_info *dli;
18746 + if (!path.dentry->d_inode)
18747 + goto out_release;
18748 + if (!(sb = path.dentry->d_inode->i_sb))
18749 + goto out_release;
18752 + dli = locate_dl_info(sb, id);
18754 + goto out_release;
18756 + spin_lock(&dli->dl_lock);
18757 + *inodes_used = dli->dl_inodes_used;
18758 + *inodes_total = dli->dl_inodes_total;
18760 + *space_used = dlimit_space_64to32(
18761 + dli->dl_space_used, flags, DLIMS_USED);
18763 + if (dli->dl_space_total == DLIM_INFINITY)
18764 + *space_total = CDLIM_INFINITY;
18766 + *space_total = dlimit_space_64to32(
18767 + dli->dl_space_total, flags, DLIMS_TOTAL);
18769 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18770 + spin_unlock(&dli->dl_lock);
18772 + put_dl_info(dli);
18783 +int vc_get_dlimit(uint32_t id, void __user *data)
18785 + struct vcmd_ctx_dlimit_v0 vc_data;
18788 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18791 + ret = do_get_dlimit(id, vc_data.name,
18792 + &vc_data.space_used, &vc_data.space_total,
18793 + &vc_data.inodes_used, &vc_data.inodes_total,
18794 + &vc_data.reserved, &vc_data.flags);
18798 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18803 +#ifdef CONFIG_COMPAT
18805 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18807 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18810 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18813 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18814 + &vc_data.space_used, &vc_data.space_total,
18815 + &vc_data.inodes_used, &vc_data.inodes_total,
18816 + &vc_data.reserved, &vc_data.flags);
18820 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18825 +#endif /* CONFIG_COMPAT */
18828 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18830 + struct dl_info *dli;
18831 + __u64 blimit, bfree, bavail;
18834 + dli = locate_dl_info(sb, dx_current_tag());
18838 + spin_lock(&dli->dl_lock);
18839 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18842 + /* reduce max inodes available to limit */
18843 + if (buf->f_files > dli->dl_inodes_total)
18844 + buf->f_files = dli->dl_inodes_total;
18846 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18847 + /* reduce free inodes to min */
18848 + if (ifree < buf->f_ffree)
18849 + buf->f_ffree = ifree;
18852 + if (dli->dl_space_total == DLIM_INFINITY)
18855 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18857 + if (dli->dl_space_total < dli->dl_space_used)
18860 + bfree = (dli->dl_space_total - dli->dl_space_used)
18861 + >> sb->s_blocksize_bits;
18863 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18864 + if (bavail < dli->dl_space_used)
18867 + bavail = (bavail - dli->dl_space_used)
18868 + >> sb->s_blocksize_bits;
18870 + /* reduce max space available to limit */
18871 + if (buf->f_blocks > blimit)
18872 + buf->f_blocks = blimit;
18874 + /* reduce free space to min */
18875 + if (bfree < buf->f_bfree)
18876 + buf->f_bfree = bfree;
18878 + /* reduce avail space to min */
18879 + if (bavail < buf->f_bavail)
18880 + buf->f_bavail = bavail;
18883 + spin_unlock(&dli->dl_lock);
18884 + put_dl_info(dli);
18889 +#include <linux/module.h>
18891 +EXPORT_SYMBOL_GPL(locate_dl_info);
18892 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18894 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/helper.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/helper.c
18895 --- linux-3.0-rc5/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18896 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/helper.c 2011-06-10 22:11:24.000000000 +0200
18899 + * linux/kernel/vserver/helper.c
18901 + * Virtual Context Support
18903 + * Copyright (C) 2004-2007 Herbert Pötzl
18905 + * V0.01 basic helper
18909 +#include <linux/kmod.h>
18910 +#include <linux/reboot.h>
18911 +#include <linux/vs_context.h>
18912 +#include <linux/vs_network.h>
18913 +#include <linux/vserver/signal.h>
18916 +char vshelper_path[255] = "/sbin/vshelper";
18919 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18923 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
18924 + printk( KERN_WARNING
18925 + "%s: (%s %s) returned %s with %d\n",
18926 + name, argv[1], argv[2],
18927 + sync ? "sync" : "async", ret);
18929 + vxdprintk(VXD_CBIT(switch, 4),
18930 + "%s: (%s %s) returned %s with %d",
18931 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18936 + * vshelper path is set via /proc/sys
18937 + * invoked by vserver sys_reboot(), with
18938 + * the following arguments
18940 + * argv [0] = vshelper_path;
18941 + * argv [1] = action: "restart", "halt", "poweroff", ...
18942 + * argv [2] = context identifier
18944 + * envp [*] = type-specific parameters
18947 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18949 + char id_buf[8], cmd_buf[16];
18950 + char uid_buf[16], pid_buf[16];
18953 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18954 + char *envp[] = {"HOME=/", "TERM=linux",
18955 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18956 + uid_buf, pid_buf, cmd_buf, 0};
18958 + if (vx_info_state(vxi, VXS_HELPER))
18960 + vxi->vx_state |= VXS_HELPER;
18962 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18964 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18965 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
18966 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
18969 + case LINUX_REBOOT_CMD_RESTART:
18970 + argv[1] = "restart";
18973 + case LINUX_REBOOT_CMD_HALT:
18974 + argv[1] = "halt";
18977 + case LINUX_REBOOT_CMD_POWER_OFF:
18978 + argv[1] = "poweroff";
18981 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18982 + argv[1] = "swsusp";
18985 + case LINUX_REBOOT_CMD_OOM:
18990 + vxi->vx_state &= ~VXS_HELPER;
18994 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18995 + vxi->vx_state &= ~VXS_HELPER;
18996 + __wakeup_vx_info(vxi);
18997 + return (ret) ? -EPERM : 0;
19001 +long vs_reboot(unsigned int cmd, void __user *arg)
19003 + struct vx_info *vxi = current_vx_info();
19006 + vxdprintk(VXD_CBIT(misc, 5),
19007 + "vs_reboot(%p[#%d],%u)",
19008 + vxi, vxi ? vxi->vx_id : 0, cmd);
19010 + ret = vs_reboot_helper(vxi, cmd, arg);
19014 + vxi->reboot_cmd = cmd;
19015 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19017 + case LINUX_REBOOT_CMD_RESTART:
19018 + case LINUX_REBOOT_CMD_HALT:
19019 + case LINUX_REBOOT_CMD_POWER_OFF:
19020 + vx_info_kill(vxi, 0, SIGKILL);
19021 + vx_info_kill(vxi, 1, SIGKILL);
19029 +long vs_oom_action(unsigned int cmd)
19031 + struct vx_info *vxi = current_vx_info();
19034 + vxdprintk(VXD_CBIT(misc, 5),
19035 + "vs_oom_action(%p[#%d],%u)",
19036 + vxi, vxi ? vxi->vx_id : 0, cmd);
19038 + ret = vs_reboot_helper(vxi, cmd, NULL);
19042 + vxi->reboot_cmd = cmd;
19043 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19044 + vx_info_kill(vxi, 0, SIGKILL);
19045 + vx_info_kill(vxi, 1, SIGKILL);
19051 + * argv [0] = vshelper_path;
19052 + * argv [1] = action: "startup", "shutdown"
19053 + * argv [2] = context identifier
19055 + * envp [*] = type-specific parameters
19058 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
19060 + char id_buf[8], cmd_buf[16];
19061 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19062 + char *envp[] = {"HOME=/", "TERM=linux",
19063 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19065 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
19068 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19069 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19072 + case VSC_STARTUP:
19073 + argv[1] = "startup";
19075 + case VSC_SHUTDOWN:
19076 + argv[1] = "shutdown";
19082 + return do_vshelper(vshelper_path, argv, envp, 1);
19087 + * argv [0] = vshelper_path;
19088 + * argv [1] = action: "netup", "netdown"
19089 + * argv [2] = context identifier
19091 + * envp [*] = type-specific parameters
19094 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
19096 + char id_buf[8], cmd_buf[16];
19097 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19098 + char *envp[] = {"HOME=/", "TERM=linux",
19099 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19101 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
19104 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
19105 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19109 + argv[1] = "netup";
19111 + case VSC_NETDOWN:
19112 + argv[1] = "netdown";
19118 + return do_vshelper(vshelper_path, argv, envp, 1);
19121 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/history.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/history.c
19122 --- linux-3.0-rc5/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
19123 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/history.c 2011-06-10 22:11:24.000000000 +0200
19126 + * kernel/vserver/history.c
19128 + * Virtual Context History Backtrace
19130 + * Copyright (C) 2004-2007 Herbert Pötzl
19132 + * V0.01 basic structure
19133 + * V0.02 hash/unhash and trace
19134 + * V0.03 preemption fixes
19138 +#include <linux/module.h>
19139 +#include <asm/uaccess.h>
19141 +#include <linux/vserver/context.h>
19142 +#include <linux/vserver/debug.h>
19143 +#include <linux/vserver/debug_cmd.h>
19144 +#include <linux/vserver/history.h>
19147 +#ifdef CONFIG_VSERVER_HISTORY
19148 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
19150 +#define VXH_SIZE 64
19153 +struct _vx_history {
19154 + unsigned int counter;
19156 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19160 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19162 +unsigned volatile int vxh_active = 1;
19164 +static atomic_t sequence = ATOMIC_INIT(0);
19169 + * requires disabled preemption */
19171 +struct _vx_hist_entry *vxh_advance(void *loc)
19173 + unsigned int cpu = smp_processor_id();
19174 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19175 + struct _vx_hist_entry *entry;
19176 + unsigned int index;
19178 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19179 + entry = &hist->entry[index];
19181 + entry->seq = atomic_inc_return(&sequence);
19182 + entry->loc = loc;
19186 +EXPORT_SYMBOL_GPL(vxh_advance);
19189 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19191 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19194 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19196 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19197 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19198 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19199 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19201 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19203 + switch (e->type) {
19204 + case VXH_THROW_OOPS:
19205 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19208 + case VXH_GET_VX_INFO:
19209 + case VXH_PUT_VX_INFO:
19210 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19212 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19213 + VXH_VXI_ARGS(e));
19216 + case VXH_INIT_VX_INFO:
19217 + case VXH_SET_VX_INFO:
19218 + case VXH_CLR_VX_INFO:
19219 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19221 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19222 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19223 + VXH_VXI_ARGS(e), e->sc.data);
19226 + case VXH_CLAIM_VX_INFO:
19227 + case VXH_RELEASE_VX_INFO:
19228 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19230 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19231 + VXH_VXI_ARGS(e), e->sc.data);
19234 + case VXH_ALLOC_VX_INFO:
19235 + case VXH_DEALLOC_VX_INFO:
19236 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19238 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19239 + VXH_VXI_ARGS(e));
19242 + case VXH_HASH_VX_INFO:
19243 + case VXH_UNHASH_VX_INFO:
19244 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19246 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19247 + VXH_VXI_ARGS(e));
19250 + case VXH_LOC_VX_INFO:
19251 + case VXH_LOOKUP_VX_INFO:
19252 + case VXH_CREATE_VX_INFO:
19253 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19255 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19256 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19257 + e->ll.arg, VXH_VXI_ARGS(e));
19262 +static void __vxh_dump_history(void)
19264 + unsigned int i, cpu;
19266 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19267 + atomic_read(&sequence), NR_CPUS);
19269 + for (i = 0; i < VXH_SIZE; i++) {
19270 + for_each_online_cpu(cpu) {
19271 + struct _vx_history *hist =
19272 + &per_cpu(vx_history_buffer, cpu);
19273 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19274 + struct _vx_hist_entry *entry = &hist->entry[index];
19276 + vxh_dump_entry(entry, cpu);
19281 +void vxh_dump_history(void)
19285 + local_irq_enable();
19287 + local_irq_disable();
19289 + __vxh_dump_history();
19293 +/* vserver syscall commands below here */
19296 +int vc_dump_history(uint32_t id)
19299 + __vxh_dump_history();
19306 +int do_read_history(struct __user _vx_hist_entry *data,
19307 + int cpu, uint32_t *index, uint32_t *count)
19309 + int pos, ret = 0;
19310 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19311 + int end = hist->counter;
19312 + int start = end - VXH_SIZE + 2;
19313 + int idx = *index;
19315 + /* special case: get current pos */
19321 + /* have we lost some data? */
19325 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
19326 + struct _vx_hist_entry *entry =
19327 + &hist->entry[idx % VXH_SIZE];
19329 + /* send entry to userspace */
19330 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
19334 + /* save new index and count */
19337 + return ret ? ret : (*index < end);
19340 +int vc_read_history(uint32_t id, void __user *data)
19342 + struct vcmd_read_history_v0 vc_data;
19345 + if (id >= NR_CPUS)
19348 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19351 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19352 + id, &vc_data.index, &vc_data.count);
19354 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19359 +#ifdef CONFIG_COMPAT
19361 +int vc_read_history_x32(uint32_t id, void __user *data)
19363 + struct vcmd_read_history_v0_x32 vc_data;
19366 + if (id >= NR_CPUS)
19369 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19372 + ret = do_read_history((struct __user _vx_hist_entry *)
19373 + compat_ptr(vc_data.data_ptr),
19374 + id, &vc_data.index, &vc_data.count);
19376 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19381 +#endif /* CONFIG_COMPAT */
19383 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/inet.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/inet.c
19384 --- linux-3.0-rc5/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19385 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/inet.c 2011-06-13 18:20:44.000000000 +0200
19388 +#include <linux/in.h>
19389 +#include <linux/inetdevice.h>
19390 +#include <linux/vs_inet.h>
19391 +#include <linux/vs_inet6.h>
19392 +#include <linux/vserver/debug.h>
19393 +#include <net/route.h>
19394 +#include <net/addrconf.h>
19397 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19401 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19404 + struct nx_addr_v4 *ptr;
19406 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19407 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19414 + vxdprintk(VXD_CBIT(net, 2),
19415 + "nx_v4_addr_conflict(%p,%p): %d",
19416 + nxi1, nxi2, ret);
19422 +#ifdef CONFIG_IPV6
19424 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19428 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19431 + struct nx_addr_v6 *ptr;
19433 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19434 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19441 + vxdprintk(VXD_CBIT(net, 2),
19442 + "nx_v6_addr_conflict(%p,%p): %d",
19443 + nxi1, nxi2, ret);
19450 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19452 + struct in_device *in_dev;
19453 + struct in_ifaddr **ifap;
19454 + struct in_ifaddr *ifa;
19459 + in_dev = in_dev_get(dev);
19463 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19464 + ifap = &ifa->ifa_next) {
19465 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19470 + in_dev_put(in_dev);
19476 +#ifdef CONFIG_IPV6
19478 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19480 + struct inet6_dev *in_dev;
19481 + struct inet6_ifaddr *ifa;
19486 + in_dev = in6_dev_get(dev);
19490 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19491 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19492 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19497 + in6_dev_put(in_dev);
19504 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19510 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19512 +#ifdef CONFIG_IPV6
19514 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19519 + vxdprintk(VXD_CBIT(net, 3),
19520 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19521 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19525 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
19526 + struct flowi4 *fl4)
19528 + struct rtable *rt;
19533 + /* FIXME: handle lback only case */
19534 + if (!NX_IPV4(nxi))
19535 + return ERR_PTR(EPERM);
19537 + vxdprintk(VXD_CBIT(net, 4),
19538 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19539 + nxi, nxi ? nxi->nx_id : 0,
19540 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
19542 + /* single IP is unconditional */
19543 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19544 + (fl4->saddr == INADDR_ANY))
19545 + fl4->saddr = nxi->v4.ip[0].s_addr;
19547 + if (fl4->saddr == INADDR_ANY) {
19548 + struct nx_addr_v4 *ptr;
19549 + __be32 found = 0;
19551 + rt = __ip_route_output_key(net, fl4);
19552 + if (!IS_ERR(rt)) {
19553 + found = fl4->saddr;
19555 + vxdprintk(VXD_CBIT(net, 4),
19556 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19557 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
19558 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19562 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19563 + __be32 primary = ptr->ip[0].s_addr;
19564 + __be32 mask = ptr->mask.s_addr;
19565 + __be32 neta = primary & mask;
19567 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19568 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19569 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19570 + NIPQUAD(mask), NIPQUAD(neta));
19571 + if ((found & mask) != neta)
19574 + fl4->saddr = primary;
19575 + rt = __ip_route_output_key(net, fl4);
19576 + vxdprintk(VXD_CBIT(net, 4),
19577 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19578 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
19579 + if (!IS_ERR(rt)) {
19580 + found = fl4->saddr;
19582 + if (found == primary)
19586 + /* still no source ip? */
19587 + found = ipv4_is_loopback(fl4->daddr)
19588 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19590 + /* assign src ip to flow */
19591 + fl4->saddr = found;
19594 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
19595 + return ERR_PTR(EPERM);
19598 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19599 + if (ipv4_is_loopback(fl4->daddr))
19600 + fl4->daddr = nxi->v4_lback.s_addr;
19601 + if (ipv4_is_loopback(fl4->saddr))
19602 + fl4->saddr = nxi->v4_lback.s_addr;
19603 + } else if (ipv4_is_loopback(fl4->daddr) &&
19604 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19605 + return ERR_PTR(EPERM);
19610 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19612 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/init.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/init.c
19613 --- linux-3.0-rc5/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19614 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/init.c 2011-06-10 22:11:24.000000000 +0200
19617 + * linux/kernel/init.c
19619 + * Virtual Server Init
19621 + * Copyright (C) 2004-2007 Herbert Pötzl
19623 + * V0.01 basic structure
19627 +#include <linux/init.h>
19629 +int vserver_register_sysctl(void);
19630 +void vserver_unregister_sysctl(void);
19633 +static int __init init_vserver(void)
19637 +#ifdef CONFIG_VSERVER_DEBUG
19638 + vserver_register_sysctl();
19644 +static void __exit exit_vserver(void)
19647 +#ifdef CONFIG_VSERVER_DEBUG
19648 + vserver_unregister_sysctl();
19653 +/* FIXME: GFP_ZONETYPES gone
19654 +long vx_slab[GFP_ZONETYPES]; */
19658 +module_init(init_vserver);
19659 +module_exit(exit_vserver);
19661 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/inode.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/inode.c
19662 --- linux-3.0-rc5/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19663 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/inode.c 2011-06-10 22:11:24.000000000 +0200
19666 + * linux/kernel/vserver/inode.c
19668 + * Virtual Server: File System Support
19670 + * Copyright (C) 2004-2007 Herbert Pötzl
19672 + * V0.01 separated from vcontext V0.05
19673 + * V0.02 moved to tag (instead of xid)
19677 +#include <linux/tty.h>
19678 +#include <linux/proc_fs.h>
19679 +#include <linux/devpts_fs.h>
19680 +#include <linux/fs.h>
19681 +#include <linux/file.h>
19682 +#include <linux/mount.h>
19683 +#include <linux/parser.h>
19684 +#include <linux/namei.h>
19685 +#include <linux/vserver/inode.h>
19686 +#include <linux/vserver/inode_cmd.h>
19687 +#include <linux/vs_base.h>
19688 +#include <linux/vs_tag.h>
19690 +#include <asm/uaccess.h>
19693 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19695 + struct proc_dir_entry *entry;
19697 + if (!in || !in->i_sb)
19700 + *flags = IATTR_TAG
19701 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19702 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19703 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19704 + | (IS_COW(in) ? IATTR_COW : 0);
19705 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19707 + if (S_ISDIR(in->i_mode))
19708 + *mask |= IATTR_BARRIER;
19710 + if (IS_TAGGED(in)) {
19711 + *tag = in->i_tag;
19712 + *mask |= IATTR_TAG;
19715 + switch (in->i_sb->s_magic) {
19716 + case PROC_SUPER_MAGIC:
19717 + entry = PROC_I(in)->pde;
19719 + /* check for specific inodes? */
19721 + *mask |= IATTR_FLAGS;
19723 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19725 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19728 + case DEVPTS_SUPER_MAGIC:
19729 + *tag = in->i_tag;
19730 + *mask |= IATTR_TAG;
19739 +int vc_get_iattr(void __user *data)
19741 + struct path path;
19742 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19745 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19748 + ret = user_lpath(vc_data.name, &path);
19750 + ret = __vc_get_iattr(path.dentry->d_inode,
19751 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19757 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19762 +#ifdef CONFIG_COMPAT
19764 +int vc_get_iattr_x32(void __user *data)
19766 + struct path path;
19767 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19770 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19773 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19775 + ret = __vc_get_iattr(path.dentry->d_inode,
19776 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19782 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19787 +#endif /* CONFIG_COMPAT */
19790 +int vc_fget_iattr(uint32_t fd, void __user *data)
19792 + struct file *filp;
19793 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19796 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19800 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19803 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19804 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19808 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19814 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19816 + struct inode *in = de->d_inode;
19817 + int error = 0, is_proc = 0, has_tag = 0;
19818 + struct iattr attr = { 0 };
19820 + if (!in || !in->i_sb)
19823 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19824 + if ((*mask & IATTR_FLAGS) && !is_proc)
19827 + has_tag = IS_TAGGED(in) ||
19828 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19829 + if ((*mask & IATTR_TAG) && !has_tag)
19832 + mutex_lock(&in->i_mutex);
19833 + if (*mask & IATTR_TAG) {
19834 + attr.ia_tag = *tag;
19835 + attr.ia_valid |= ATTR_TAG;
19838 + if (*mask & IATTR_FLAGS) {
19839 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19840 + unsigned int iflags = PROC_I(in)->vx_flags;
19842 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19843 + | (*flags & IATTR_FLAGS);
19844 + PROC_I(in)->vx_flags = iflags;
19846 + entry->vx_flags = iflags;
19849 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19850 + IATTR_BARRIER | IATTR_COW)) {
19851 + int iflags = in->i_flags;
19852 + int vflags = in->i_vflags;
19854 + if (*mask & IATTR_IMMUTABLE) {
19855 + if (*flags & IATTR_IMMUTABLE)
19856 + iflags |= S_IMMUTABLE;
19858 + iflags &= ~S_IMMUTABLE;
19860 + if (*mask & IATTR_IXUNLINK) {
19861 + if (*flags & IATTR_IXUNLINK)
19862 + iflags |= S_IXUNLINK;
19864 + iflags &= ~S_IXUNLINK;
19866 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19867 + if (*flags & IATTR_BARRIER)
19868 + vflags |= V_BARRIER;
19870 + vflags &= ~V_BARRIER;
19872 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19873 + if (*flags & IATTR_COW)
19876 + vflags &= ~V_COW;
19878 + if (in->i_op && in->i_op->sync_flags) {
19879 + error = in->i_op->sync_flags(in, iflags, vflags);
19885 + if (attr.ia_valid) {
19886 + if (in->i_op && in->i_op->setattr)
19887 + error = in->i_op->setattr(de, &attr);
19889 + error = inode_change_ok(in, &attr);
19891 + setattr_copy(in, &attr);
19892 + mark_inode_dirty(in);
19898 + mutex_unlock(&in->i_mutex);
19902 +int vc_set_iattr(void __user *data)
19904 + struct path path;
19905 + struct vcmd_ctx_iattr_v1 vc_data;
19908 + if (!capable(CAP_LINUX_IMMUTABLE))
19910 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19913 + ret = user_lpath(vc_data.name, &path);
19915 + ret = __vc_set_iattr(path.dentry,
19916 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19920 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19925 +#ifdef CONFIG_COMPAT
19927 +int vc_set_iattr_x32(void __user *data)
19929 + struct path path;
19930 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19933 + if (!capable(CAP_LINUX_IMMUTABLE))
19935 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19938 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19940 + ret = __vc_set_iattr(path.dentry,
19941 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19945 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19950 +#endif /* CONFIG_COMPAT */
19952 +int vc_fset_iattr(uint32_t fd, void __user *data)
19954 + struct file *filp;
19955 + struct vcmd_ctx_fiattr_v0 vc_data;
19958 + if (!capable(CAP_LINUX_IMMUTABLE))
19960 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19964 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19967 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19968 + &vc_data.flags, &vc_data.mask);
19972 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19978 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19980 +static match_table_t tokens = {
19981 + {Opt_notagcheck, "notagcheck"},
19982 +#ifdef CONFIG_PROPAGATE
19983 + {Opt_notag, "notag"},
19984 + {Opt_tag, "tag"},
19985 + {Opt_tagid, "tagid=%u"},
19991 +static void __dx_parse_remove(char *string, char *opt)
19993 + char *p = strstr(string, opt);
19997 + while (*q != '\0' && *q != ',')
20006 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
20007 + unsigned long *flags)
20010 + substring_t args[MAX_OPT_ARGS];
20012 + char *s, *p, *opts;
20013 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_WARN)
20019 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
20024 + while ((p = strsep(&opts, ",")) != NULL) {
20025 + token = match_token(p, tokens, args);
20028 +#ifdef CONFIG_PROPAGATE
20033 + __dx_parse_remove(s, "tag");
20034 + *mnt_flags |= MNT_TAGID;
20035 + set |= MNT_TAGID;
20039 + __dx_parse_remove(s, "notag");
20040 + *mnt_flags |= MNT_NOTAG;
20041 + set |= MNT_NOTAG;
20044 + if (tag && !match_int(args, &option))
20047 + __dx_parse_remove(s, "tagid");
20048 + *mnt_flags |= MNT_TAGID;
20049 + set |= MNT_TAGID;
20052 + case Opt_notagcheck:
20054 + __dx_parse_remove(s, "notagcheck");
20055 + *flags |= MS_NOTAGCHECK;
20056 + set |= MS_NOTAGCHECK;
20059 + vxdprintk(VXD_CBIT(tag, 7),
20060 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
20061 + p, token, option);
20064 + strcpy(string, s);
20069 +#ifdef CONFIG_PROPAGATE
20071 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
20073 + tag_t new_tag = 0;
20074 + struct vfsmount *mnt;
20079 + mnt = nd->path.mnt;
20083 + propagate = (mnt->mnt_flags & MNT_TAGID);
20085 + new_tag = mnt->mnt_tag;
20087 + vxdprintk(VXD_CBIT(tag, 7),
20088 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
20089 + inode, inode->i_ino, inode->i_tag,
20090 + new_tag, (propagate) ? 1 : 0);
20093 + inode->i_tag = new_tag;
20096 +#include <linux/module.h>
20098 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
20100 +#endif /* CONFIG_PROPAGATE */
20102 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/limit.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/limit.c
20103 --- linux-3.0-rc5/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
20104 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/limit.c 2011-06-10 22:11:24.000000000 +0200
20107 + * linux/kernel/vserver/limit.c
20109 + * Virtual Server: Context Limits
20111 + * Copyright (C) 2004-2010 Herbert Pötzl
20113 + * V0.01 broken out from vcontext V0.05
20114 + * V0.02 changed vcmds to vxi arg
20115 + * V0.03 added memory cgroup support
20119 +#include <linux/sched.h>
20120 +#include <linux/module.h>
20121 +#include <linux/memcontrol.h>
20122 +#include <linux/res_counter.h>
20123 +#include <linux/vs_limit.h>
20124 +#include <linux/vserver/limit.h>
20125 +#include <linux/vserver/limit_cmd.h>
20127 +#include <asm/uaccess.h>
20130 +const char *vlimit_name[NUM_LIMITS] = {
20131 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20132 + [RLIMIT_RSS] = "RSS",
20133 + [RLIMIT_AS] = "VM",
20134 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20135 + [RLIMIT_CPU] = "CPU",
20136 + [RLIMIT_NPROC] = "NPROC",
20137 + [RLIMIT_NOFILE] = "NOFILE",
20138 + [RLIMIT_LOCKS] = "LOCKS",
20139 + [RLIMIT_SIGPENDING] = "SIGP",
20140 + [RLIMIT_MSGQUEUE] = "MSGQ",
20142 + [VLIMIT_NSOCK] = "NSOCK",
20143 + [VLIMIT_OPENFD] = "OPENFD",
20144 + [VLIMIT_SHMEM] = "SHMEM",
20145 + [VLIMIT_DENTRY] = "DENTRY",
20148 +EXPORT_SYMBOL_GPL(vlimit_name);
20150 +#define MASK_ENTRY(x) (1 << (x))
20152 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
20155 + , /* softlimit */
20156 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20157 + MASK_ENTRY( RLIMIT_RSS ) |
20158 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20161 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20162 + MASK_ENTRY( RLIMIT_RSS ) |
20163 + MASK_ENTRY( RLIMIT_AS ) |
20164 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20165 + MASK_ENTRY( RLIMIT_NPROC ) |
20166 + MASK_ENTRY( RLIMIT_NOFILE ) |
20167 + MASK_ENTRY( RLIMIT_LOCKS ) |
20168 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
20170 + MASK_ENTRY( VLIMIT_NSOCK ) |
20171 + MASK_ENTRY( VLIMIT_OPENFD ) |
20172 + MASK_ENTRY( VLIMIT_SHMEM ) |
20173 + MASK_ENTRY( VLIMIT_DENTRY ) |
20176 + /* accounting only */
20177 +uint32_t account_mask =
20178 + MASK_ENTRY( VLIMIT_SEMARY ) |
20179 + MASK_ENTRY( VLIMIT_NSEMS ) |
20180 + MASK_ENTRY( VLIMIT_MAPPED ) |
20184 +static int is_valid_vlimit(int id)
20186 + uint32_t mask = vlimit_mask.minimum |
20187 + vlimit_mask.softlimit | vlimit_mask.maximum;
20188 + return mask & (1 << id);
20191 +static int is_accounted_vlimit(int id)
20193 + if (is_valid_vlimit(id))
20195 + return account_mask & (1 << id);
20199 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
20201 + rlim_t limit = __rlim_soft(&vxi->limit, id);
20202 + return VX_VLIM(limit);
20205 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
20207 + rlim_t limit = __rlim_hard(&vxi->limit, id);
20208 + return VX_VLIM(limit);
20211 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
20212 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
20214 + if (!is_valid_vlimit(id))
20218 + *minimum = CRLIM_UNSET;
20220 + *softlimit = vc_get_soft(vxi, id);
20222 + *maximum = vc_get_hard(vxi, id);
20226 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
20228 + struct vcmd_ctx_rlimit_v0 vc_data;
20231 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20234 + ret = do_get_rlimit(vxi, vc_data.id,
20235 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20239 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20244 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
20245 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
20247 + if (!is_valid_vlimit(id))
20250 + if (maximum != CRLIM_KEEP)
20251 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
20252 + if (softlimit != CRLIM_KEEP)
20253 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
20255 + /* clamp soft limit */
20256 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
20257 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
20262 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
20264 + struct vcmd_ctx_rlimit_v0 vc_data;
20266 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20269 + return do_set_rlimit(vxi, vc_data.id,
20270 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20273 +#ifdef CONFIG_IA32_EMULATION
20275 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
20277 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20279 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20282 + return do_set_rlimit(vxi, vc_data.id,
20283 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20286 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
20288 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20291 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20294 + ret = do_get_rlimit(vxi, vc_data.id,
20295 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20299 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20304 +#endif /* CONFIG_IA32_EMULATION */
20307 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
20309 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
20315 +static inline void vx_reset_hits(struct _vx_limit *limit)
20319 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20320 + atomic_set(&__rlim_lhit(limit, lim), 0);
20324 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
20326 + vx_reset_hits(&vxi->limit);
20330 +static inline void vx_reset_minmax(struct _vx_limit *limit)
20335 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20336 + value = __rlim_get(limit, lim);
20337 + __rlim_rmax(limit, lim) = value;
20338 + __rlim_rmin(limit, lim) = value;
20342 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
20344 + vx_reset_minmax(&vxi->limit);
20349 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20351 + struct vcmd_rlimit_stat_v0 vc_data;
20352 + struct _vx_limit *limit = &vxi->limit;
20355 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20359 + if (!is_accounted_vlimit(id))
20362 + vx_limit_fixup(limit, id);
20363 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20364 + vc_data.value = __rlim_get(limit, id);
20365 + vc_data.minimum = __rlim_rmin(limit, id);
20366 + vc_data.maximum = __rlim_rmax(limit, id);
20368 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20374 +void vx_vsi_meminfo(struct sysinfo *val)
20376 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20377 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20378 + u64 res_limit, res_usage;
20383 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20384 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20386 + if (res_limit != RESOURCE_MAX)
20387 + val->totalram = (res_limit >> PAGE_SHIFT);
20388 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
20389 + val->bufferram = 0;
20390 + val->totalhigh = 0;
20391 + val->freehigh = 0;
20392 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20396 +void vx_vsi_swapinfo(struct sysinfo *val)
20398 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20399 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20400 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20401 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20402 + s64 swap_limit, swap_usage;
20407 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20408 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20409 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20410 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20412 + if (res_limit == RESOURCE_MAX)
20415 + swap_limit = memsw_limit - res_limit;
20416 + if (memsw_limit != RESOURCE_MAX)
20417 + val->totalswap = swap_limit >> PAGE_SHIFT;
20419 + swap_usage = memsw_usage - res_usage;
20420 + val->freeswap = (swap_usage < swap_limit) ?
20421 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20422 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20423 + val->totalswap = 0;
20424 + val->freeswap = 0;
20425 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20426 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20430 +long vx_vsi_cached(struct sysinfo *val)
20432 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20433 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20435 + return mem_cgroup_stat_read_cache(mcg);
20442 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
20444 + struct vx_info *vxi = mm->mm_vx_info;
20445 + unsigned long points;
20451 + points = vxi->vx_badness_bias;
20453 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20454 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20455 + points += (v > w) ? (v - w) : 0;
20460 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/limit_init.h linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/limit_init.h
20461 --- linux-3.0-rc5/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20462 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/limit_init.h 2011-06-10 22:11:24.000000000 +0200
20466 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20470 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20471 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20472 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20473 + __rlim_set(limit, lim, 0);
20474 + atomic_set(&__rlim_lhit(limit, lim), 0);
20475 + __rlim_rmin(limit, lim) = 0;
20476 + __rlim_rmax(limit, lim) = 0;
20480 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20485 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20486 + if ((1 << lim) & VLIM_NOCHECK)
20488 + value = __rlim_get(limit, lim);
20489 + vxwprintk_xid(value,
20490 + "!!! limit: %p[%s,%d] = %ld on exit.",
20491 + limit, vlimit_name[lim], lim, (long)value);
20495 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/limit_proc.h linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/limit_proc.h
20496 --- linux-3.0-rc5/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20497 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/limit_proc.h 2011-06-10 22:11:24.000000000 +0200
20499 +#ifndef _VX_LIMIT_PROC_H
20500 +#define _VX_LIMIT_PROC_H
20502 +#include <linux/vserver/limit_int.h>
20505 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20506 +#define VX_LIMIT_TOP \
20507 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20509 +#define VX_LIMIT_ARG(r) \
20510 + (unsigned long)__rlim_get(limit, r), \
20511 + (unsigned long)__rlim_rmin(limit, r), \
20512 + (unsigned long)__rlim_rmax(limit, r), \
20513 + VX_VLIM(__rlim_soft(limit, r)), \
20514 + VX_VLIM(__rlim_hard(limit, r)), \
20515 + atomic_read(&__rlim_lhit(limit, r))
20517 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20519 + vx_limit_fixup(limit, -1);
20520 + return sprintf(buffer, VX_LIMIT_TOP
20521 + "PROC" VX_LIMIT_FMT
20522 + "VM" VX_LIMIT_FMT
20523 + "VML" VX_LIMIT_FMT
20524 + "RSS" VX_LIMIT_FMT
20525 + "ANON" VX_LIMIT_FMT
20526 + "RMAP" VX_LIMIT_FMT
20527 + "FILES" VX_LIMIT_FMT
20528 + "OFD" VX_LIMIT_FMT
20529 + "LOCKS" VX_LIMIT_FMT
20530 + "SOCK" VX_LIMIT_FMT
20531 + "MSGQ" VX_LIMIT_FMT
20532 + "SHM" VX_LIMIT_FMT
20533 + "SEMA" VX_LIMIT_FMT
20534 + "SEMS" VX_LIMIT_FMT
20535 + "DENT" VX_LIMIT_FMT,
20536 + VX_LIMIT_ARG(RLIMIT_NPROC),
20537 + VX_LIMIT_ARG(RLIMIT_AS),
20538 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20539 + VX_LIMIT_ARG(RLIMIT_RSS),
20540 + VX_LIMIT_ARG(VLIMIT_ANON),
20541 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20542 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20543 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20544 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20545 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20546 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20547 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20548 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20549 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20550 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20553 +#endif /* _VX_LIMIT_PROC_H */
20556 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/network.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/network.c
20557 --- linux-3.0-rc5/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20558 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/network.c 2011-06-10 23:20:56.000000000 +0200
20561 + * linux/kernel/vserver/network.c
20563 + * Virtual Server: Network Support
20565 + * Copyright (C) 2003-2007 Herbert Pötzl
20567 + * V0.01 broken out from vcontext V0.05
20568 + * V0.02 cleaned up implementation
20569 + * V0.03 added equiv nx commands
20570 + * V0.04 switch to RCU based hash
20571 + * V0.05 and back to locking again
20572 + * V0.06 changed vcmds to nxi arg
20573 + * V0.07 have __create claim() the nxi
20577 +#include <linux/err.h>
20578 +#include <linux/slab.h>
20579 +#include <linux/rcupdate.h>
20581 +#include <linux/vs_network.h>
20582 +#include <linux/vs_pid.h>
20583 +#include <linux/vserver/network_cmd.h>
20586 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20587 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20589 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20590 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20593 +static int __init init_network(void)
20595 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20596 + sizeof(struct nx_addr_v4), 0,
20597 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20598 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20599 + sizeof(struct nx_addr_v6), 0,
20600 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20605 +/* __alloc_nx_addr_v4() */
20607 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20609 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20610 + nx_addr_v4_cachep, GFP_KERNEL);
20612 + if (!IS_ERR(nxa))
20613 + memset(nxa, 0, sizeof(*nxa));
20617 +/* __dealloc_nx_addr_v4() */
20619 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20621 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20624 +/* __dealloc_nx_addr_v4_all() */
20626 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20629 + struct nx_addr_v4 *next = nxa->next;
20631 + __dealloc_nx_addr_v4(nxa);
20637 +#ifdef CONFIG_IPV6
20639 +/* __alloc_nx_addr_v6() */
20641 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20643 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20644 + nx_addr_v6_cachep, GFP_KERNEL);
20646 + if (!IS_ERR(nxa))
20647 + memset(nxa, 0, sizeof(*nxa));
20651 +/* __dealloc_nx_addr_v6() */
20653 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20655 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20658 +/* __dealloc_nx_addr_v6_all() */
20660 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20663 + struct nx_addr_v6 *next = nxa->next;
20665 + __dealloc_nx_addr_v6(nxa);
20670 +#endif /* CONFIG_IPV6 */
20672 +/* __alloc_nx_info()
20674 + * allocate an initialized nx_info struct
20675 + * doesn't make it visible (hash) */
20677 +static struct nx_info *__alloc_nx_info(nid_t nid)
20679 + struct nx_info *new = NULL;
20681 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20683 + /* would this benefit from a slab cache? */
20684 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20688 + memset(new, 0, sizeof(struct nx_info));
20689 + new->nx_id = nid;
20690 + INIT_HLIST_NODE(&new->nx_hlist);
20691 + atomic_set(&new->nx_usecnt, 0);
20692 + atomic_set(&new->nx_tasks, 0);
20693 + new->nx_state = 0;
20695 + new->nx_flags = NXF_INIT_SET;
20697 + /* rest of init goes here */
20699 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20700 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20702 + vxdprintk(VXD_CBIT(nid, 0),
20703 + "alloc_nx_info(%d) = %p", nid, new);
20704 + atomic_inc(&nx_global_ctotal);
20708 +/* __dealloc_nx_info()
20710 + * final disposal of nx_info */
20712 +static void __dealloc_nx_info(struct nx_info *nxi)
20714 + vxdprintk(VXD_CBIT(nid, 0),
20715 + "dealloc_nx_info(%p)", nxi);
20717 + nxi->nx_hlist.next = LIST_POISON1;
20720 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20721 + BUG_ON(atomic_read(&nxi->nx_tasks));
20723 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20725 + nxi->nx_state |= NXS_RELEASED;
20727 + atomic_dec(&nx_global_ctotal);
20730 +static void __shutdown_nx_info(struct nx_info *nxi)
20732 + nxi->nx_state |= NXS_SHUTDOWN;
20733 + vs_net_change(nxi, VSC_NETDOWN);
20736 +/* exported stuff */
20738 +void free_nx_info(struct nx_info *nxi)
20740 + /* context shutdown is mandatory */
20741 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20743 + /* context must not be hashed */
20744 + BUG_ON(nxi->nx_state & NXS_HASHED);
20746 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20747 + BUG_ON(atomic_read(&nxi->nx_tasks));
20749 + __dealloc_nx_info(nxi);
20753 +void __nx_set_lback(struct nx_info *nxi)
20755 + int nid = nxi->nx_id;
20756 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20758 + nxi->v4_lback.s_addr = lback;
20761 +extern int __nx_inet_add_lback(__be32 addr);
20762 +extern int __nx_inet_del_lback(__be32 addr);
20765 +/* hash table for nx_info hash */
20767 +#define NX_HASH_SIZE 13
20769 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20771 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20774 +static inline unsigned int __hashval(nid_t nid)
20776 + return (nid % NX_HASH_SIZE);
20781 +/* __hash_nx_info()
20783 + * add the nxi to the global hash table
20784 + * requires the hash_lock to be held */
20786 +static inline void __hash_nx_info(struct nx_info *nxi)
20788 + struct hlist_head *head;
20790 + vxd_assert_lock(&nx_info_hash_lock);
20791 + vxdprintk(VXD_CBIT(nid, 4),
20792 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20794 + /* context must not be hashed */
20795 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20797 + nxi->nx_state |= NXS_HASHED;
20798 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20799 + hlist_add_head(&nxi->nx_hlist, head);
20800 + atomic_inc(&nx_global_cactive);
20803 +/* __unhash_nx_info()
20805 + * remove the nxi from the global hash table
20806 + * requires the hash_lock to be held */
20808 +static inline void __unhash_nx_info(struct nx_info *nxi)
20810 + vxd_assert_lock(&nx_info_hash_lock);
20811 + vxdprintk(VXD_CBIT(nid, 4),
20812 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20813 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20815 + /* context must be hashed */
20816 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20817 + /* but without tasks */
20818 + BUG_ON(atomic_read(&nxi->nx_tasks));
20820 + nxi->nx_state &= ~NXS_HASHED;
20821 + hlist_del(&nxi->nx_hlist);
20822 + atomic_dec(&nx_global_cactive);
20826 +/* __lookup_nx_info()
20828 + * requires the hash_lock to be held
20829 + * doesn't increment the nx_refcnt */
20831 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20833 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20834 + struct hlist_node *pos;
20835 + struct nx_info *nxi;
20837 + vxd_assert_lock(&nx_info_hash_lock);
20838 + hlist_for_each(pos, head) {
20839 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20841 + if (nxi->nx_id == nid)
20846 + vxdprintk(VXD_CBIT(nid, 0),
20847 + "__lookup_nx_info(#%u): %p[#%u]",
20848 + nid, nxi, nxi ? nxi->nx_id : 0);
20853 +/* __create_nx_info()
20855 + * create the requested context
20856 + * get(), claim() and hash it */
20858 +static struct nx_info *__create_nx_info(int id)
20860 + struct nx_info *new, *nxi = NULL;
20862 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20864 + if (!(new = __alloc_nx_info(id)))
20865 + return ERR_PTR(-ENOMEM);
20867 + /* required to make dynamic xids unique */
20868 + spin_lock(&nx_info_hash_lock);
20870 + /* static context requested */
20871 + if ((nxi = __lookup_nx_info(id))) {
20872 + vxdprintk(VXD_CBIT(nid, 0),
20873 + "create_nx_info(%d) = %p (already there)", id, nxi);
20874 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20875 + nxi = ERR_PTR(-EBUSY);
20877 + nxi = ERR_PTR(-EEXIST);
20880 + /* new context */
20881 + vxdprintk(VXD_CBIT(nid, 0),
20882 + "create_nx_info(%d) = %p (new)", id, new);
20883 + claim_nx_info(new, NULL);
20884 + __nx_set_lback(new);
20885 + __hash_nx_info(get_nx_info(new));
20886 + nxi = new, new = NULL;
20889 + spin_unlock(&nx_info_hash_lock);
20891 + __dealloc_nx_info(new);
20897 +/* exported stuff */
20900 +void unhash_nx_info(struct nx_info *nxi)
20902 + __shutdown_nx_info(nxi);
20903 + spin_lock(&nx_info_hash_lock);
20904 + __unhash_nx_info(nxi);
20905 + spin_unlock(&nx_info_hash_lock);
20908 +/* lookup_nx_info()
20910 + * search for a nx_info and get() it
20911 + * negative id means current */
20913 +struct nx_info *lookup_nx_info(int id)
20915 + struct nx_info *nxi = NULL;
20918 + nxi = get_nx_info(current_nx_info());
20919 + } else if (id > 1) {
20920 + spin_lock(&nx_info_hash_lock);
20921 + nxi = get_nx_info(__lookup_nx_info(id));
20922 + spin_unlock(&nx_info_hash_lock);
20927 +/* nid_is_hashed()
20929 + * verify that nid is still hashed */
20931 +int nid_is_hashed(nid_t nid)
20935 + spin_lock(&nx_info_hash_lock);
20936 + hashed = (__lookup_nx_info(nid) != NULL);
20937 + spin_unlock(&nx_info_hash_lock);
20942 +#ifdef CONFIG_PROC_FS
20946 + * get a subset of hashed nids for proc
20947 + * assumes size is at least one */
20949 +int get_nid_list(int index, unsigned int *nids, int size)
20951 + int hindex, nr_nids = 0;
20953 + /* only show current and children */
20954 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20957 + nids[nr_nids] = nx_current_nid();
20961 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20962 + struct hlist_head *head = &nx_info_hash[hindex];
20963 + struct hlist_node *pos;
20965 + spin_lock(&nx_info_hash_lock);
20966 + hlist_for_each(pos, head) {
20967 + struct nx_info *nxi;
20972 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20973 + nids[nr_nids] = nxi->nx_id;
20974 + if (++nr_nids >= size) {
20975 + spin_unlock(&nx_info_hash_lock);
20979 + /* keep the lock time short */
20980 + spin_unlock(&nx_info_hash_lock);
20989 + * migrate task to new network
20990 + * gets nxi, puts old_nxi on change
20993 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20995 + struct nx_info *old_nxi;
21001 + vxdprintk(VXD_CBIT(nid, 5),
21002 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
21003 + p, nxi, nxi->nx_id,
21004 + atomic_read(&nxi->nx_usecnt),
21005 + atomic_read(&nxi->nx_tasks));
21007 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
21008 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21011 + if (nx_info_state(nxi, NXS_SHUTDOWN))
21014 + /* maybe disallow this completely? */
21015 + old_nxi = task_get_nx_info(p);
21016 + if (old_nxi == nxi)
21021 + clr_nx_info(&p->nx_info);
21022 + claim_nx_info(nxi, p);
21023 + set_nx_info(&p->nx_info, nxi);
21024 + p->nid = nxi->nx_id;
21027 + vxdprintk(VXD_CBIT(nid, 5),
21028 + "moved task %p into nxi:%p[#%d]",
21029 + p, nxi, nxi->nx_id);
21032 + release_nx_info(old_nxi, p);
21035 + put_nx_info(old_nxi);
21040 +void nx_set_persistent(struct nx_info *nxi)
21042 + vxdprintk(VXD_CBIT(nid, 6),
21043 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
21045 + get_nx_info(nxi);
21046 + claim_nx_info(nxi, NULL);
21049 +void nx_clear_persistent(struct nx_info *nxi)
21051 + vxdprintk(VXD_CBIT(nid, 6),
21052 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
21054 + release_nx_info(nxi, NULL);
21055 + put_nx_info(nxi);
21058 +void nx_update_persistent(struct nx_info *nxi)
21060 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
21061 + nx_set_persistent(nxi);
21063 + nx_clear_persistent(nxi);
21066 +/* vserver syscall commands below here */
21068 +/* taks nid and nx_info functions */
21070 +#include <asm/uaccess.h>
21073 +int vc_task_nid(uint32_t id)
21078 + struct task_struct *tsk;
21081 + tsk = find_task_by_real_pid(id);
21082 + nid = (tsk) ? tsk->nid : -ESRCH;
21083 + rcu_read_unlock();
21085 + nid = nx_current_nid();
21090 +int vc_nx_info(struct nx_info *nxi, void __user *data)
21092 + struct vcmd_nx_info_v0 vc_data;
21094 + vc_data.nid = nxi->nx_id;
21096 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21102 +/* network functions */
21104 +int vc_net_create(uint32_t nid, void __user *data)
21106 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
21107 + struct nx_info *new_nxi;
21110 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21113 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
21116 + new_nxi = __create_nx_info(nid);
21117 + if (IS_ERR(new_nxi))
21118 + return PTR_ERR(new_nxi);
21120 + /* initial flags */
21121 + new_nxi->nx_flags = vc_data.flagword;
21124 + if (vs_net_change(new_nxi, VSC_NETUP))
21127 + ret = nx_migrate_task(current, new_nxi);
21131 + /* return context id on success */
21132 + ret = new_nxi->nx_id;
21134 + /* get a reference for persistent contexts */
21135 + if ((vc_data.flagword & NXF_PERSISTENT))
21136 + nx_set_persistent(new_nxi);
21138 + release_nx_info(new_nxi, NULL);
21139 + put_nx_info(new_nxi);
21144 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
21146 + return nx_migrate_task(current, nxi);
21151 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21152 + uint16_t type, uint16_t flags)
21154 + struct nx_addr_v4 *nxa = &nxi->v4;
21156 + if (NX_IPV4(nxi)) {
21157 + /* locate last entry */
21158 + for (; nxa->next; nxa = nxa->next);
21159 + nxa->next = __alloc_nx_addr_v4();
21163 + return PTR_ERR(nxa);
21166 + if (nxi->v4.next)
21167 + /* remove single ip for ip list */
21168 + nxi->nx_flags &= ~NXF_SINGLE_IP;
21170 + nxa->ip[0].s_addr = ip;
21171 + nxa->ip[1].s_addr = ip2;
21172 + nxa->mask.s_addr = mask;
21173 + nxa->type = type;
21174 + nxa->flags = flags;
21178 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21179 + uint16_t type, uint16_t flags)
21181 + struct nx_addr_v4 *nxa = &nxi->v4;
21184 +/* case NXA_TYPE_ADDR:
21187 + case NXA_TYPE_ANY:
21188 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
21189 + memset(nxa, 0, sizeof(*nxa));
21199 +int vc_net_add(struct nx_info *nxi, void __user *data)
21201 + struct vcmd_net_addr_v0 vc_data;
21202 + int index, ret = 0;
21204 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21207 + switch (vc_data.type) {
21208 + case NXA_TYPE_IPV4:
21209 + if ((vc_data.count < 1) || (vc_data.count > 4))
21213 + while (index < vc_data.count) {
21214 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
21215 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
21223 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
21224 + nxi->v4_bcast = vc_data.ip[0];
21228 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
21229 + nxi->v4_lback = vc_data.ip[0];
21240 +int vc_net_remove(struct nx_info *nxi, void __user *data)
21242 + struct vcmd_net_addr_v0 vc_data;
21244 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21247 + switch (vc_data.type) {
21248 + case NXA_TYPE_ANY:
21249 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21250 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21260 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
21262 + struct vcmd_net_addr_ipv4_v1 vc_data;
21264 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21267 + switch (vc_data.type) {
21268 + case NXA_TYPE_ADDR:
21269 + case NXA_TYPE_MASK:
21270 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
21271 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21273 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21274 + nxi->v4_bcast = vc_data.ip;
21277 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21278 + nxi->v4_lback = vc_data.ip;
21287 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
21289 + struct vcmd_net_addr_ipv4_v2 vc_data;
21291 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21294 + switch (vc_data.type) {
21295 + case NXA_TYPE_ADDR:
21296 + case NXA_TYPE_MASK:
21297 + case NXA_TYPE_RANGE:
21298 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
21299 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21301 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21302 + nxi->v4_bcast = vc_data.ip;
21305 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21306 + nxi->v4_lback = vc_data.ip;
21315 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
21317 + struct vcmd_net_addr_ipv4_v1 vc_data;
21319 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21322 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
21323 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21326 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
21328 + struct vcmd_net_addr_ipv4_v2 vc_data;
21330 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21333 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
21334 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21337 +#ifdef CONFIG_IPV6
21339 +int do_add_v6_addr(struct nx_info *nxi,
21340 + struct in6_addr *ip, struct in6_addr *mask,
21341 + uint32_t prefix, uint16_t type, uint16_t flags)
21343 + struct nx_addr_v6 *nxa = &nxi->v6;
21345 + if (NX_IPV6(nxi)) {
21346 + /* locate last entry */
21347 + for (; nxa->next; nxa = nxa->next);
21348 + nxa->next = __alloc_nx_addr_v6();
21352 + return PTR_ERR(nxa);
21356 + nxa->mask = *mask;
21357 + nxa->prefix = prefix;
21358 + nxa->type = type;
21359 + nxa->flags = flags;
21364 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21366 + struct vcmd_net_addr_ipv6_v1 vc_data;
21368 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21371 + switch (vc_data.type) {
21372 + case NXA_TYPE_ADDR:
21373 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
21374 + /* fallthrough */
21375 + case NXA_TYPE_MASK:
21376 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21377 + vc_data.prefix, vc_data.type, vc_data.flags);
21384 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21386 + struct vcmd_net_addr_ipv6_v1 vc_data;
21388 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21391 + switch (vc_data.type) {
21392 + case NXA_TYPE_ANY:
21393 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21394 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21403 +#endif /* CONFIG_IPV6 */
21406 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21408 + struct vcmd_net_flags_v0 vc_data;
21410 + vc_data.flagword = nxi->nx_flags;
21412 + /* special STATE flag handling */
21413 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21415 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21420 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21422 + struct vcmd_net_flags_v0 vc_data;
21423 + uint64_t mask, trigger;
21425 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21428 + /* special STATE flag handling */
21429 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21430 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21432 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21433 + vc_data.flagword, mask);
21434 + if (trigger & NXF_PERSISTENT)
21435 + nx_update_persistent(nxi);
21440 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21442 + struct vcmd_net_caps_v0 vc_data;
21444 + vc_data.ncaps = nxi->nx_ncaps;
21445 + vc_data.cmask = ~0ULL;
21447 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21452 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21454 + struct vcmd_net_caps_v0 vc_data;
21456 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21459 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21460 + vc_data.ncaps, vc_data.cmask);
21465 +#include <linux/module.h>
21467 +module_init(init_network);
21469 +EXPORT_SYMBOL_GPL(free_nx_info);
21470 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21472 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/proc.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/proc.c
21473 --- linux-3.0-rc5/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21474 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/proc.c 2011-06-10 22:11:24.000000000 +0200
21477 + * linux/kernel/vserver/proc.c
21479 + * Virtual Context Support
21481 + * Copyright (C) 2003-2007 Herbert Pötzl
21483 + * V0.01 basic structure
21484 + * V0.02 adaptation vs1.3.0
21485 + * V0.03 proc permissions
21486 + * V0.04 locking/generic
21487 + * V0.05 next generation procfs
21488 + * V0.06 inode validation
21489 + * V0.07 generic rewrite vid
21490 + * V0.08 remove inode type
21494 +#include <linux/proc_fs.h>
21495 +#include <linux/fs_struct.h>
21496 +#include <linux/mount.h>
21497 +#include <asm/unistd.h>
21499 +#include <linux/vs_context.h>
21500 +#include <linux/vs_network.h>
21501 +#include <linux/vs_cvirt.h>
21503 +#include <linux/in.h>
21504 +#include <linux/inetdevice.h>
21505 +#include <linux/vs_inet.h>
21506 +#include <linux/vs_inet6.h>
21508 +#include <linux/vserver/global.h>
21510 +#include "cvirt_proc.h"
21511 +#include "cacct_proc.h"
21512 +#include "limit_proc.h"
21513 +#include "sched_proc.h"
21514 +#include "vci_config.h"
21517 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21521 + CAP_FOR_EACH_U32(__capi) {
21522 + buffer += sprintf(buffer, "%08x",
21523 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21529 +static struct proc_dir_entry *proc_virtual;
21531 +static struct proc_dir_entry *proc_virtnet;
21534 +/* first the actual feeds */
21537 +static int proc_vci(char *buffer)
21539 + return sprintf(buffer,
21540 + "VCIVersion:\t%04x:%04x\n"
21541 + "VCISyscall:\t%d\n"
21542 + "VCIKernel:\t%08x\n",
21543 + VCI_VERSION >> 16,
21544 + VCI_VERSION & 0xFFFF,
21546 + vci_kernel_config());
21549 +static int proc_virtual_info(char *buffer)
21551 + return proc_vci(buffer);
21554 +static int proc_virtual_status(char *buffer)
21556 + return sprintf(buffer,
21558 + "#CActive:\t%d\n"
21559 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21560 + "#InitTask:\t%d\t%d %d\n",
21561 + atomic_read(&vx_global_ctotal),
21562 + atomic_read(&vx_global_cactive),
21563 + atomic_read(&vs_global_nsproxy),
21564 + atomic_read(&vs_global_fs),
21565 + atomic_read(&vs_global_mnt_ns),
21566 + atomic_read(&vs_global_uts_ns),
21567 + atomic_read(&nr_ipc_ns),
21568 + atomic_read(&vs_global_user_ns),
21569 + atomic_read(&vs_global_pid_ns),
21570 + atomic_read(&init_task.usage),
21571 + atomic_read(&init_task.nsproxy->count),
21572 + init_task.fs->users);
21576 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21580 + length = sprintf(buffer,
21588 + vxi->vx_badness_bias);
21592 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21594 + char *orig = buffer;
21596 + buffer += sprintf(buffer,
21599 + "Flags:\t%016llx\n",
21600 + atomic_read(&vxi->vx_usecnt),
21601 + atomic_read(&vxi->vx_tasks),
21602 + (unsigned long long)vxi->vx_flags);
21604 + buffer += sprintf(buffer, "BCaps:\t");
21605 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21606 + buffer += sprintf(buffer, "\n");
21608 + buffer += sprintf(buffer,
21609 + "CCaps:\t%016llx\n"
21610 + "Umask:\t%16llx\n"
21611 + "Spaces:\t%08lx %08lx\n",
21612 + (unsigned long long)vxi->vx_ccaps,
21613 + (unsigned long long)vxi->vx_umask,
21614 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21615 + return buffer - orig;
21618 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21620 + return vx_info_proc_limit(&vxi->limit, buffer);
21623 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21627 + length = vx_info_proc_sched(&vxi->sched, buffer);
21628 + for_each_online_cpu(cpu) {
21629 + length += vx_info_proc_sched_pc(
21630 + &vx_per_cpu(vxi, sched_pc, cpu),
21631 + buffer + length, cpu);
21636 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21638 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21641 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21643 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21646 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21650 + vx_update_load(vxi);
21651 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21652 + for_each_online_cpu(cpu) {
21653 + length += vx_info_proc_cvirt_pc(
21654 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21655 + buffer + length, cpu);
21660 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21662 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21666 +static int proc_virtnet_info(char *buffer)
21668 + return proc_vci(buffer);
21671 +static int proc_virtnet_status(char *buffer)
21673 + return sprintf(buffer,
21675 + "#CActive:\t%d\n",
21676 + atomic_read(&nx_global_ctotal),
21677 + atomic_read(&nx_global_cactive));
21680 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21682 + struct nx_addr_v4 *v4a;
21683 +#ifdef CONFIG_IPV6
21684 + struct nx_addr_v6 *v6a;
21688 + length = sprintf(buffer,
21691 + "Bcast:\t" NIPQUAD_FMT "\n"
21692 + "Lback:\t" NIPQUAD_FMT "\n",
21695 + NIPQUAD(nxi->v4_bcast.s_addr),
21696 + NIPQUAD(nxi->v4_lback.s_addr));
21698 + if (!NX_IPV4(nxi))
21700 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21701 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21704 +#ifdef CONFIG_IPV6
21705 + if (!NX_IPV6(nxi))
21707 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21708 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21715 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21719 + length = sprintf(buffer,
21722 + "Flags:\t%016llx\n"
21723 + "NCaps:\t%016llx\n",
21724 + atomic_read(&nxi->nx_usecnt),
21725 + atomic_read(&nxi->nx_tasks),
21726 + (unsigned long long)nxi->nx_flags,
21727 + (unsigned long long)nxi->nx_ncaps);
21733 +/* here the inode helpers */
21739 + struct inode_operations *iop;
21740 + struct file_operations *fop;
21741 + union proc_op op;
21744 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21746 + struct inode *inode = new_inode(sb);
21751 + inode->i_mode = p->mode;
21753 + inode->i_op = p->iop;
21755 + inode->i_fop = p->fop;
21757 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
21758 + inode->i_flags |= S_IMMUTABLE;
21760 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21762 + inode->i_uid = 0;
21763 + inode->i_gid = 0;
21764 + inode->i_tag = 0;
21769 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21770 + struct dentry *dentry, int id, void *ptr)
21772 + struct vs_entry *p = ptr;
21773 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21774 + struct dentry *error = ERR_PTR(-EINVAL);
21779 + PROC_I(inode)->op = p->op;
21780 + PROC_I(inode)->fd = id;
21781 + d_add(dentry, inode);
21789 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21792 + * Fill a directory entry.
21794 + * If possible create the dcache entry and derive our inode number and
21795 + * file type from dcache entry.
21797 + * Since all of the proc inode numbers are dynamically generated, the inode
21798 + * numbers do not exist until the inode is cache. This means creating the
21799 + * the dcache entry in readdir is necessary to keep the inode numbers
21800 + * reported by readdir in sync with the inode numbers reported
21803 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21804 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21806 + struct dentry *child, *dir = filp->f_dentry;
21807 + struct inode *inode;
21808 + struct qstr qname;
21810 + unsigned type = DT_UNKNOWN;
21812 + qname.name = name;
21814 + qname.hash = full_name_hash(name, len);
21816 + child = d_lookup(dir, &qname);
21818 + struct dentry *new;
21819 + new = d_alloc(dir, &qname);
21821 + child = instantiate(dir->d_inode, new, id, ptr);
21828 + if (!child || IS_ERR(child) || !child->d_inode)
21829 + goto end_instantiate;
21830 + inode = child->d_inode;
21832 + ino = inode->i_ino;
21833 + type = inode->i_mode >> 12;
21838 + ino = find_inode_number(dir, &qname);
21841 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21846 +/* get and revalidate vx_info/xid */
21849 +struct vx_info *get_proc_vx_info(struct inode *inode)
21851 + return lookup_vx_info(PROC_I(inode)->fd);
21854 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
21856 + struct inode *inode = dentry->d_inode;
21857 + xid_t xid = PROC_I(inode)->fd;
21859 + if (!xid || xid_is_hashed(xid))
21866 +/* get and revalidate nx_info/nid */
21868 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
21870 + struct inode *inode = dentry->d_inode;
21871 + nid_t nid = PROC_I(inode)->fd;
21873 + if (!nid || nid_is_hashed(nid))
21881 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21883 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21884 + size_t count, loff_t *ppos)
21886 + struct inode *inode = file->f_dentry->d_inode;
21887 + unsigned long page;
21888 + ssize_t length = 0;
21890 + if (count > PROC_BLOCK_SIZE)
21891 + count = PROC_BLOCK_SIZE;
21893 + /* fade that out as soon as stable */
21894 + WARN_ON(PROC_I(inode)->fd);
21896 + if (!(page = __get_free_page(GFP_KERNEL)))
21899 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21900 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21903 + length = simple_read_from_buffer(buf, count, ppos,
21904 + (char *)page, length);
21910 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21911 + size_t count, loff_t *ppos)
21913 + struct inode *inode = file->f_dentry->d_inode;
21914 + struct vx_info *vxi = NULL;
21915 + xid_t xid = PROC_I(inode)->fd;
21916 + unsigned long page;
21917 + ssize_t length = 0;
21919 + if (count > PROC_BLOCK_SIZE)
21920 + count = PROC_BLOCK_SIZE;
21922 + /* fade that out as soon as stable */
21924 + vxi = lookup_vx_info(xid);
21928 + length = -ENOMEM;
21929 + if (!(page = __get_free_page(GFP_KERNEL)))
21932 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21933 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21936 + length = simple_read_from_buffer(buf, count, ppos,
21937 + (char *)page, length);
21941 + put_vx_info(vxi);
21946 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21947 + size_t count, loff_t *ppos)
21949 + struct inode *inode = file->f_dentry->d_inode;
21950 + struct nx_info *nxi = NULL;
21951 + nid_t nid = PROC_I(inode)->fd;
21952 + unsigned long page;
21953 + ssize_t length = 0;
21955 + if (count > PROC_BLOCK_SIZE)
21956 + count = PROC_BLOCK_SIZE;
21958 + /* fade that out as soon as stable */
21960 + nxi = lookup_nx_info(nid);
21964 + length = -ENOMEM;
21965 + if (!(page = __get_free_page(GFP_KERNEL)))
21968 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21969 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21972 + length = simple_read_from_buffer(buf, count, ppos,
21973 + (char *)page, length);
21977 + put_nx_info(nxi);
21984 +/* here comes the lower level */
21987 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21988 + .len = sizeof(NAME) - 1, \
21989 + .name = (NAME), \
21997 +#define DIR(NAME, MODE, OTYPE) \
21998 + NOD(NAME, (S_IFDIR | (MODE)), \
21999 + &proc_ ## OTYPE ## _inode_operations, \
22000 + &proc_ ## OTYPE ## _file_operations, { } )
22002 +#define INF(NAME, MODE, OTYPE) \
22003 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22004 + &proc_vs_info_file_operations, \
22005 + { .proc_vs_read = &proc_##OTYPE } )
22007 +#define VINF(NAME, MODE, OTYPE) \
22008 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22009 + &proc_vx_info_file_operations, \
22010 + { .proc_vxi_read = &proc_##OTYPE } )
22012 +#define NINF(NAME, MODE, OTYPE) \
22013 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22014 + &proc_nx_info_file_operations, \
22015 + { .proc_nxi_read = &proc_##OTYPE } )
22018 +static struct file_operations proc_vs_info_file_operations = {
22019 + .read = proc_vs_info_read,
22022 +static struct file_operations proc_vx_info_file_operations = {
22023 + .read = proc_vx_info_read,
22026 +static struct dentry_operations proc_xid_dentry_operations = {
22027 + .d_revalidate = proc_xid_revalidate,
22030 +static struct vs_entry vx_base_stuff[] = {
22031 + VINF("info", S_IRUGO, vxi_info),
22032 + VINF("status", S_IRUGO, vxi_status),
22033 + VINF("limit", S_IRUGO, vxi_limit),
22034 + VINF("sched", S_IRUGO, vxi_sched),
22035 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
22036 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
22037 + VINF("cvirt", S_IRUGO, vxi_cvirt),
22038 + VINF("cacct", S_IRUGO, vxi_cacct),
22045 +static struct dentry *proc_xid_instantiate(struct inode *dir,
22046 + struct dentry *dentry, int id, void *ptr)
22048 + dentry->d_op = &proc_xid_dentry_operations;
22049 + return vs_proc_instantiate(dir, dentry, id, ptr);
22052 +static struct dentry *proc_xid_lookup(struct inode *dir,
22053 + struct dentry *dentry, struct nameidata *nd)
22055 + struct vs_entry *p = vx_base_stuff;
22056 + struct dentry *error = ERR_PTR(-ENOENT);
22058 + for (; p->name; p++) {
22059 + if (p->len != dentry->d_name.len)
22061 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22067 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22072 +static int proc_xid_readdir(struct file *filp,
22073 + void *dirent, filldir_t filldir)
22075 + struct dentry *dentry = filp->f_dentry;
22076 + struct inode *inode = dentry->d_inode;
22077 + struct vs_entry *p = vx_base_stuff;
22078 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
22082 + pos = filp->f_pos;
22085 + ino = inode->i_ino;
22086 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22089 + /* fall through */
22091 + ino = parent_ino(dentry);
22092 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22095 + /* fall through */
22098 + if (index >= size)
22100 + for (p += index; p->name; p++) {
22101 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22102 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22108 + filp->f_pos = pos;
22114 +static struct file_operations proc_nx_info_file_operations = {
22115 + .read = proc_nx_info_read,
22118 +static struct dentry_operations proc_nid_dentry_operations = {
22119 + .d_revalidate = proc_nid_revalidate,
22122 +static struct vs_entry nx_base_stuff[] = {
22123 + NINF("info", S_IRUGO, nxi_info),
22124 + NINF("status", S_IRUGO, nxi_status),
22129 +static struct dentry *proc_nid_instantiate(struct inode *dir,
22130 + struct dentry *dentry, int id, void *ptr)
22132 + dentry->d_op = &proc_nid_dentry_operations;
22133 + return vs_proc_instantiate(dir, dentry, id, ptr);
22136 +static struct dentry *proc_nid_lookup(struct inode *dir,
22137 + struct dentry *dentry, struct nameidata *nd)
22139 + struct vs_entry *p = nx_base_stuff;
22140 + struct dentry *error = ERR_PTR(-ENOENT);
22142 + for (; p->name; p++) {
22143 + if (p->len != dentry->d_name.len)
22145 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22151 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22156 +static int proc_nid_readdir(struct file *filp,
22157 + void *dirent, filldir_t filldir)
22159 + struct dentry *dentry = filp->f_dentry;
22160 + struct inode *inode = dentry->d_inode;
22161 + struct vs_entry *p = nx_base_stuff;
22162 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
22166 + pos = filp->f_pos;
22169 + ino = inode->i_ino;
22170 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22173 + /* fall through */
22175 + ino = parent_ino(dentry);
22176 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22179 + /* fall through */
22182 + if (index >= size)
22184 + for (p += index; p->name; p++) {
22185 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22186 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22192 + filp->f_pos = pos;
22197 +#define MAX_MULBY10 ((~0U - 9) / 10)
22199 +static inline int atovid(const char *str, int len)
22204 + while (len-- > 0) {
22209 + if (vid >= MAX_MULBY10)
22219 +/* now the upper level (virtual) */
22222 +static struct file_operations proc_xid_file_operations = {
22223 + .read = generic_read_dir,
22224 + .readdir = proc_xid_readdir,
22227 +static struct inode_operations proc_xid_inode_operations = {
22228 + .lookup = proc_xid_lookup,
22231 +static struct vs_entry vx_virtual_stuff[] = {
22232 + INF("info", S_IRUGO, virtual_info),
22233 + INF("status", S_IRUGO, virtual_status),
22234 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
22238 +static struct dentry *proc_virtual_lookup(struct inode *dir,
22239 + struct dentry *dentry, struct nameidata *nd)
22241 + struct vs_entry *p = vx_virtual_stuff;
22242 + struct dentry *error = ERR_PTR(-ENOENT);
22245 + for (; p->name; p++) {
22246 + if (p->len != dentry->d_name.len)
22248 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22252 + goto instantiate;
22254 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22255 + if ((id < 0) || !xid_is_hashed(id))
22259 + error = proc_xid_instantiate(dir, dentry, id, p);
22264 +static struct file_operations proc_nid_file_operations = {
22265 + .read = generic_read_dir,
22266 + .readdir = proc_nid_readdir,
22269 +static struct inode_operations proc_nid_inode_operations = {
22270 + .lookup = proc_nid_lookup,
22273 +static struct vs_entry nx_virtnet_stuff[] = {
22274 + INF("info", S_IRUGO, virtnet_info),
22275 + INF("status", S_IRUGO, virtnet_status),
22276 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
22280 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
22281 + struct dentry *dentry, struct nameidata *nd)
22283 + struct vs_entry *p = nx_virtnet_stuff;
22284 + struct dentry *error = ERR_PTR(-ENOENT);
22287 + for (; p->name; p++) {
22288 + if (p->len != dentry->d_name.len)
22290 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22294 + goto instantiate;
22296 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22297 + if ((id < 0) || !nid_is_hashed(id))
22301 + error = proc_nid_instantiate(dir, dentry, id, p);
22307 +#define PROC_MAXVIDS 32
22309 +int proc_virtual_readdir(struct file *filp,
22310 + void *dirent, filldir_t filldir)
22312 + struct dentry *dentry = filp->f_dentry;
22313 + struct inode *inode = dentry->d_inode;
22314 + struct vs_entry *p = vx_virtual_stuff;
22315 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
22317 + unsigned int xid_array[PROC_MAXVIDS];
22318 + char buf[PROC_NUMBUF];
22319 + unsigned int nr_xids, i;
22322 + pos = filp->f_pos;
22325 + ino = inode->i_ino;
22326 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22329 + /* fall through */
22331 + ino = parent_ino(dentry);
22332 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22335 + /* fall through */
22338 + if (index >= size)
22340 + for (p += index; p->name; p++) {
22341 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22342 + vs_proc_instantiate, 0, p))
22347 + index = pos - size;
22348 + p = &vx_virtual_stuff[size - 1];
22349 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22350 + for (i = 0; i < nr_xids; i++) {
22351 + int n, xid = xid_array[i];
22352 + unsigned int j = PROC_NUMBUF;
22356 + buf[--j] = '0' + (n % 10);
22359 + if (proc_fill_cache(filp, dirent, filldir,
22360 + buf + j, PROC_NUMBUF - j,
22361 + vs_proc_instantiate, xid, p))
22367 + filp->f_pos = pos;
22371 +static int proc_virtual_getattr(struct vfsmount *mnt,
22372 + struct dentry *dentry, struct kstat *stat)
22374 + struct inode *inode = dentry->d_inode;
22376 + generic_fillattr(inode, stat);
22377 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22381 +static struct file_operations proc_virtual_dir_operations = {
22382 + .read = generic_read_dir,
22383 + .readdir = proc_virtual_readdir,
22386 +static struct inode_operations proc_virtual_dir_inode_operations = {
22387 + .getattr = proc_virtual_getattr,
22388 + .lookup = proc_virtual_lookup,
22395 +int proc_virtnet_readdir(struct file *filp,
22396 + void *dirent, filldir_t filldir)
22398 + struct dentry *dentry = filp->f_dentry;
22399 + struct inode *inode = dentry->d_inode;
22400 + struct vs_entry *p = nx_virtnet_stuff;
22401 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22403 + unsigned int nid_array[PROC_MAXVIDS];
22404 + char buf[PROC_NUMBUF];
22405 + unsigned int nr_nids, i;
22408 + pos = filp->f_pos;
22411 + ino = inode->i_ino;
22412 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22415 + /* fall through */
22417 + ino = parent_ino(dentry);
22418 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22421 + /* fall through */
22424 + if (index >= size)
22426 + for (p += index; p->name; p++) {
22427 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22428 + vs_proc_instantiate, 0, p))
22433 + index = pos - size;
22434 + p = &nx_virtnet_stuff[size - 1];
22435 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22436 + for (i = 0; i < nr_nids; i++) {
22437 + int n, nid = nid_array[i];
22438 + unsigned int j = PROC_NUMBUF;
22442 + buf[--j] = '0' + (n % 10);
22445 + if (proc_fill_cache(filp, dirent, filldir,
22446 + buf + j, PROC_NUMBUF - j,
22447 + vs_proc_instantiate, nid, p))
22453 + filp->f_pos = pos;
22457 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22458 + struct dentry *dentry, struct kstat *stat)
22460 + struct inode *inode = dentry->d_inode;
22462 + generic_fillattr(inode, stat);
22463 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22467 +static struct file_operations proc_virtnet_dir_operations = {
22468 + .read = generic_read_dir,
22469 + .readdir = proc_virtnet_readdir,
22472 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22473 + .getattr = proc_virtnet_getattr,
22474 + .lookup = proc_virtnet_lookup,
22479 +void proc_vx_init(void)
22481 + struct proc_dir_entry *ent;
22483 + ent = proc_mkdir("virtual", 0);
22485 + ent->proc_fops = &proc_virtual_dir_operations;
22486 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22488 + proc_virtual = ent;
22490 + ent = proc_mkdir("virtnet", 0);
22492 + ent->proc_fops = &proc_virtnet_dir_operations;
22493 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22495 + proc_virtnet = ent;
22501 +/* per pid info */
22504 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22506 + struct vx_info *vxi;
22507 + char *orig = buffer;
22509 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22511 + vxi = task_get_vx_info(p);
22515 + buffer += sprintf(buffer, "BCaps:\t");
22516 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22517 + buffer += sprintf(buffer, "\n");
22518 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22519 + (unsigned long long)vxi->vx_ccaps);
22520 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22521 + (unsigned long long)vxi->vx_flags);
22522 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22524 + put_vx_info(vxi);
22526 + return buffer - orig;
22530 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22532 + struct nx_info *nxi;
22533 + struct nx_addr_v4 *v4a;
22534 +#ifdef CONFIG_IPV6
22535 + struct nx_addr_v6 *v6a;
22537 + char *orig = buffer;
22540 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22542 + nxi = task_get_nx_info(p);
22546 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22547 + (unsigned long long)nxi->nx_ncaps);
22548 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22549 + (unsigned long long)nxi->nx_flags);
22551 + buffer += sprintf(buffer,
22552 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22553 + NIPQUAD(nxi->v4_bcast.s_addr));
22554 + buffer += sprintf (buffer,
22555 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22556 + NIPQUAD(nxi->v4_lback.s_addr));
22557 + if (!NX_IPV4(nxi))
22559 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22560 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22563 +#ifdef CONFIG_IPV6
22564 + if (!NX_IPV6(nxi))
22566 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22567 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22571 + put_nx_info(nxi);
22573 + return buffer - orig;
22576 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/sched.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/sched.c
22577 --- linux-3.0-rc5/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22578 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/sched.c 2011-06-10 22:11:24.000000000 +0200
22581 + * linux/kernel/vserver/sched.c
22583 + * Virtual Server: Scheduler Support
22585 + * Copyright (C) 2004-2010 Herbert Pötzl
22587 + * V0.01 adapted Sam Vilains version to 2.6.3
22588 + * V0.02 removed legacy interface
22589 + * V0.03 changed vcmds to vxi arg
22590 + * V0.04 removed older and legacy interfaces
22591 + * V0.05 removed scheduler code/commands
22595 +#include <linux/vs_context.h>
22596 +#include <linux/vs_sched.h>
22597 +#include <linux/vserver/sched_cmd.h>
22599 +#include <asm/uaccess.h>
22602 +void vx_update_sched_param(struct _vx_sched *sched,
22603 + struct _vx_sched_pc *sched_pc)
22605 + sched_pc->prio_bias = sched->prio_bias;
22608 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22612 + if (data->prio_bias > MAX_PRIO_BIAS)
22613 + data->prio_bias = MAX_PRIO_BIAS;
22614 + if (data->prio_bias < MIN_PRIO_BIAS)
22615 + data->prio_bias = MIN_PRIO_BIAS;
22617 + if (data->cpu_id != ~0) {
22618 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22619 + cpus_and(vxi->sched.update, cpu_online_map,
22620 + vxi->sched.update);
22622 + vxi->sched.update = cpu_online_map;
22624 + for_each_cpu_mask(cpu, vxi->sched.update)
22625 + vx_update_sched_param(&vxi->sched,
22626 + &vx_per_cpu(vxi, sched_pc, cpu));
22630 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22632 + struct vcmd_prio_bias vc_data;
22634 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22637 + return do_set_prio_bias(vxi, &vc_data);
22640 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22642 + struct vcmd_prio_bias vc_data;
22643 + struct _vx_sched_pc *pcd;
22646 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22649 + cpu = vc_data.cpu_id;
22651 + if (!cpu_possible(cpu))
22654 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22655 + vc_data.prio_bias = pcd->prio_bias;
22657 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22662 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/sched_init.h linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/sched_init.h
22663 --- linux-3.0-rc5/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22664 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/sched_init.h 2011-06-10 22:11:24.000000000 +0200
22667 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22669 + /* scheduling; hard code starting values as constants */
22670 + sched->prio_bias = 0;
22674 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22676 + sched_pc->prio_bias = 0;
22678 + sched_pc->user_ticks = 0;
22679 + sched_pc->sys_ticks = 0;
22680 + sched_pc->hold_ticks = 0;
22683 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22689 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22693 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/sched_proc.h linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/sched_proc.h
22694 --- linux-3.0-rc5/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22695 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/sched_proc.h 2011-06-10 22:11:24.000000000 +0200
22697 +#ifndef _VX_SCHED_PROC_H
22698 +#define _VX_SCHED_PROC_H
22702 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22706 + length += sprintf(buffer,
22707 + "PrioBias:\t%8d\n",
22708 + sched->prio_bias);
22713 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22714 + char *buffer, int cpu)
22718 + length += sprintf(buffer + length,
22719 + "cpu %d: %lld %lld %lld", cpu,
22720 + (unsigned long long)sched_pc->user_ticks,
22721 + (unsigned long long)sched_pc->sys_ticks,
22722 + (unsigned long long)sched_pc->hold_ticks);
22723 + length += sprintf(buffer + length,
22724 + " %d\n", sched_pc->prio_bias);
22728 +#endif /* _VX_SCHED_PROC_H */
22729 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/signal.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/signal.c
22730 --- linux-3.0-rc5/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22731 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/signal.c 2011-06-10 22:11:24.000000000 +0200
22734 + * linux/kernel/vserver/signal.c
22736 + * Virtual Server: Signal Support
22738 + * Copyright (C) 2003-2007 Herbert Pötzl
22740 + * V0.01 broken out from vcontext V0.05
22741 + * V0.02 changed vcmds to vxi arg
22742 + * V0.03 adjusted siginfo for kill
22746 +#include <asm/uaccess.h>
22748 +#include <linux/vs_context.h>
22749 +#include <linux/vs_pid.h>
22750 +#include <linux/vserver/signal_cmd.h>
22753 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22755 + int retval, count = 0;
22756 + struct task_struct *p;
22757 + struct siginfo *sip = SEND_SIG_PRIV;
22760 + vxdprintk(VXD_CBIT(misc, 4),
22761 + "vx_info_kill(%p[#%d],%d,%d)*",
22762 + vxi, vxi->vx_id, pid, sig);
22763 + read_lock(&tasklist_lock);
22767 + for_each_process(p) {
22770 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22771 + (pid && vxi->vx_initpid == p->pid))
22774 + err = group_send_sig_info(sig, sip, p);
22776 + if (err != -EPERM)
22782 + if (vxi->vx_initpid) {
22783 + pid = vxi->vx_initpid;
22784 + /* for now, only SIGINT to private init ... */
22785 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22786 + /* ... as long as there are tasks left */
22787 + (atomic_read(&vxi->vx_tasks) > 1))
22790 + /* fallthrough */
22793 + p = find_task_by_real_pid(pid);
22794 + rcu_read_unlock();
22796 + if (vx_task_xid(p) == vxi->vx_id)
22797 + retval = group_send_sig_info(sig, sip, p);
22801 + read_unlock(&tasklist_lock);
22802 + vxdprintk(VXD_CBIT(misc, 4),
22803 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22804 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22808 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22810 + struct vcmd_ctx_kill_v0 vc_data;
22812 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22815 + /* special check to allow guest shutdown */
22816 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22817 + /* forbid killall pid=0 when init is present */
22818 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22819 + (vc_data.pid > 1)))
22822 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22826 +static int __wait_exit(struct vx_info *vxi)
22828 + DECLARE_WAITQUEUE(wait, current);
22831 + add_wait_queue(&vxi->vx_wait, &wait);
22832 + set_current_state(TASK_INTERRUPTIBLE);
22835 + if (vx_info_state(vxi,
22836 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22838 + if (signal_pending(current)) {
22839 + ret = -ERESTARTSYS;
22846 + set_current_state(TASK_RUNNING);
22847 + remove_wait_queue(&vxi->vx_wait, &wait);
22853 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22855 + struct vcmd_wait_exit_v0 vc_data;
22858 + ret = __wait_exit(vxi);
22859 + vc_data.reboot_cmd = vxi->reboot_cmd;
22860 + vc_data.exit_code = vxi->exit_code;
22862 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22867 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/space.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/space.c
22868 --- linux-3.0-rc5/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22869 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/space.c 2011-06-10 22:11:24.000000000 +0200
22872 + * linux/kernel/vserver/space.c
22874 + * Virtual Server: Context Space Support
22876 + * Copyright (C) 2003-2010 Herbert Pötzl
22878 + * V0.01 broken out from context.c 0.07
22879 + * V0.02 added task locking for namespace
22880 + * V0.03 broken out vx_enter_namespace
22881 + * V0.04 added *space support and commands
22882 + * V0.05 added credential support
22886 +#include <linux/utsname.h>
22887 +#include <linux/nsproxy.h>
22888 +#include <linux/err.h>
22889 +#include <linux/fs_struct.h>
22890 +#include <linux/cred.h>
22891 +#include <asm/uaccess.h>
22893 +#include <linux/vs_context.h>
22894 +#include <linux/vserver/space.h>
22895 +#include <linux/vserver/space_cmd.h>
22897 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22898 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22899 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22900 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22901 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22902 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22905 +/* namespace functions */
22907 +#include <linux/mnt_namespace.h>
22908 +#include <linux/user_namespace.h>
22909 +#include <linux/pid_namespace.h>
22910 +#include <linux/ipc_namespace.h>
22911 +#include <net/net_namespace.h>
22914 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22915 + .mask = CLONE_FS |
22923 +static const struct vcmd_space_mask_v1 space_mask = {
22924 + .mask = CLONE_FS |
22929 +#ifdef CONFIG_PID_NS
22932 +#ifdef CONFIG_NET_NS
22938 +static const struct vcmd_space_mask_v1 default_space_mask = {
22939 + .mask = CLONE_FS |
22944 +#ifdef CONFIG_PID_NS
22951 + * build a new nsproxy mix
22952 + * assumes that both proxies are 'const'
22953 + * does not touch nsproxy refcounts
22954 + * will hold a reference on the result.
22957 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22958 + struct nsproxy *new_nsproxy, unsigned long mask)
22960 + struct mnt_namespace *old_ns;
22961 + struct uts_namespace *old_uts;
22962 + struct ipc_namespace *old_ipc;
22963 +#ifdef CONFIG_PID_NS
22964 + struct pid_namespace *old_pid;
22966 +#ifdef CONFIG_NET_NS
22967 + struct net *old_net;
22969 + struct nsproxy *nsproxy;
22971 + nsproxy = copy_nsproxy(old_nsproxy);
22975 + if (mask & CLONE_NEWNS) {
22976 + old_ns = nsproxy->mnt_ns;
22977 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22978 + if (nsproxy->mnt_ns)
22979 + get_mnt_ns(nsproxy->mnt_ns);
22983 + if (mask & CLONE_NEWUTS) {
22984 + old_uts = nsproxy->uts_ns;
22985 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22986 + if (nsproxy->uts_ns)
22987 + get_uts_ns(nsproxy->uts_ns);
22991 + if (mask & CLONE_NEWIPC) {
22992 + old_ipc = nsproxy->ipc_ns;
22993 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22994 + if (nsproxy->ipc_ns)
22995 + get_ipc_ns(nsproxy->ipc_ns);
22999 +#ifdef CONFIG_PID_NS
23000 + if (mask & CLONE_NEWPID) {
23001 + old_pid = nsproxy->pid_ns;
23002 + nsproxy->pid_ns = new_nsproxy->pid_ns;
23003 + if (nsproxy->pid_ns)
23004 + get_pid_ns(nsproxy->pid_ns);
23008 +#ifdef CONFIG_NET_NS
23009 + if (mask & CLONE_NEWNET) {
23010 + old_net = nsproxy->net_ns;
23011 + nsproxy->net_ns = new_nsproxy->net_ns;
23012 + if (nsproxy->net_ns)
23013 + get_net(nsproxy->net_ns);
23018 + put_mnt_ns(old_ns);
23020 + put_uts_ns(old_uts);
23022 + put_ipc_ns(old_ipc);
23023 +#ifdef CONFIG_PID_NS
23025 + put_pid_ns(old_pid);
23027 +#ifdef CONFIG_NET_NS
23029 + put_net(old_net);
23037 + * merge two nsproxy structs into a new one.
23038 + * will hold a reference on the result.
23042 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
23043 + struct nsproxy *proxy, unsigned long mask)
23045 + struct nsproxy null_proxy = { .mnt_ns = NULL };
23051 + /* vs_mix_nsproxy returns with reference */
23052 + return vs_mix_nsproxy(old ? old : &null_proxy,
23055 + get_nsproxy(proxy);
23060 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23062 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
23063 + struct fs_struct *fs_cur, *fs = NULL;
23064 + struct _vx_space *space;
23065 + int ret, kill = 0;
23067 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
23068 + vxi, vxi->vx_id, mask, index);
23070 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
23073 + if (index >= VX_SPACES)
23076 + space = &vxi->space[index];
23079 + mask = space->vx_nsmask;
23081 + if ((mask & space->vx_nsmask) != mask)
23084 + if (mask & CLONE_FS) {
23085 + fs = copy_fs_struct(space->vx_fs);
23089 + proxy = space->vx_nsproxy;
23091 + vxdprintk(VXD_CBIT(space, 9),
23092 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
23093 + vxi, vxi->vx_id, mask, index, proxy, fs);
23095 + task_lock(current);
23096 + fs_cur = current->fs;
23098 + if (mask & CLONE_FS) {
23099 + spin_lock(&fs_cur->lock);
23100 + current->fs = fs;
23101 + kill = !--fs_cur->users;
23102 + spin_unlock(&fs_cur->lock);
23105 + proxy_cur = current->nsproxy;
23106 + get_nsproxy(proxy_cur);
23107 + task_unlock(current);
23110 + free_fs_struct(fs_cur);
23112 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
23113 + if (IS_ERR(proxy_new)) {
23114 + ret = PTR_ERR(proxy_new);
23118 + proxy_new = xchg(¤t->nsproxy, proxy_new);
23120 + if (mask & CLONE_NEWUSER) {
23121 + struct cred *cred;
23123 + vxdprintk(VXD_CBIT(space, 10),
23124 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
23125 + vxi, vxi->vx_id, space->vx_cred,
23126 + current->real_cred, current->cred);
23128 + if (space->vx_cred) {
23129 + cred = __prepare_creds(space->vx_cred);
23131 + commit_creds(cred);
23138 + put_nsproxy(proxy_new);
23141 + put_nsproxy(proxy_cur);
23146 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23148 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
23149 + struct fs_struct *fs_vxi, *fs;
23150 + struct _vx_space *space;
23151 + int ret, kill = 0;
23153 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
23154 + vxi, vxi->vx_id, mask, index);
23156 + if ((mask & space_mask.mask) != mask)
23159 + if (index >= VX_SPACES)
23162 + space = &vxi->space[index];
23164 + proxy_vxi = space->vx_nsproxy;
23165 + fs_vxi = space->vx_fs;
23167 + if (mask & CLONE_FS) {
23168 + fs = copy_fs_struct(current->fs);
23173 + task_lock(current);
23175 + if (mask & CLONE_FS) {
23176 + spin_lock(&fs_vxi->lock);
23177 + space->vx_fs = fs;
23178 + kill = !--fs_vxi->users;
23179 + spin_unlock(&fs_vxi->lock);
23182 + proxy_cur = current->nsproxy;
23183 + get_nsproxy(proxy_cur);
23184 + task_unlock(current);
23187 + free_fs_struct(fs_vxi);
23189 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
23190 + if (IS_ERR(proxy_new)) {
23191 + ret = PTR_ERR(proxy_new);
23195 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
23196 + space->vx_nsmask |= mask;
23198 + if (mask & CLONE_NEWUSER) {
23199 + struct cred *cred;
23201 + vxdprintk(VXD_CBIT(space, 10),
23202 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
23203 + vxi, vxi->vx_id, space->vx_cred,
23204 + current->real_cred, current->cred);
23206 + cred = prepare_creds();
23207 + cred = (struct cred *)xchg(&space->vx_cred, cred);
23209 + abort_creds(cred);
23215 + put_nsproxy(proxy_new);
23218 + put_nsproxy(proxy_cur);
23223 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
23225 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23227 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23230 + return vx_enter_space(vxi, vc_data.mask, 0);
23233 +int vc_enter_space(struct vx_info *vxi, void __user *data)
23235 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23237 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23240 + if (vc_data.index >= VX_SPACES)
23243 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
23246 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
23248 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23250 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23253 + return vx_set_space(vxi, vc_data.mask, 0);
23256 +int vc_set_space(struct vx_info *vxi, void __user *data)
23258 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23260 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23263 + if (vc_data.index >= VX_SPACES)
23266 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
23269 +int vc_get_space_mask(void __user *data, int type)
23271 + const struct vcmd_space_mask_v1 *mask;
23274 + mask = &space_mask_v0;
23275 + else if (type == 1)
23276 + mask = &space_mask;
23278 + mask = &default_space_mask;
23280 + vxdprintk(VXD_CBIT(space, 10),
23281 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
23283 + if (copy_to_user(data, mask, sizeof(*mask)))
23288 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/switch.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/switch.c
23289 --- linux-3.0-rc5/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
23290 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/switch.c 2011-06-10 22:11:24.000000000 +0200
23293 + * linux/kernel/vserver/switch.c
23295 + * Virtual Server: Syscall Switch
23297 + * Copyright (C) 2003-2007 Herbert Pötzl
23299 + * V0.01 syscall switch
23300 + * V0.02 added signal to context
23301 + * V0.03 added rlimit functions
23302 + * V0.04 added iattr, task/xid functions
23303 + * V0.05 added debug/history stuff
23304 + * V0.06 added compat32 layer
23305 + * V0.07 vcmd args and perms
23306 + * V0.08 added status commands
23307 + * V0.09 added tag commands
23308 + * V0.10 added oom bias
23309 + * V0.11 added device commands
23313 +#include <linux/vs_context.h>
23314 +#include <linux/vs_network.h>
23315 +#include <linux/vserver/switch.h>
23317 +#include "vci_config.h"
23321 +int vc_get_version(uint32_t id)
23323 + return VCI_VERSION;
23327 +int vc_get_vci(uint32_t id)
23329 + return vci_kernel_config();
23332 +#include <linux/vserver/context_cmd.h>
23333 +#include <linux/vserver/cvirt_cmd.h>
23334 +#include <linux/vserver/cacct_cmd.h>
23335 +#include <linux/vserver/limit_cmd.h>
23336 +#include <linux/vserver/network_cmd.h>
23337 +#include <linux/vserver/sched_cmd.h>
23338 +#include <linux/vserver/debug_cmd.h>
23339 +#include <linux/vserver/inode_cmd.h>
23340 +#include <linux/vserver/dlimit_cmd.h>
23341 +#include <linux/vserver/signal_cmd.h>
23342 +#include <linux/vserver/space_cmd.h>
23343 +#include <linux/vserver/tag_cmd.h>
23344 +#include <linux/vserver/device_cmd.h>
23346 +#include <linux/vserver/inode.h>
23347 +#include <linux/vserver/dlimit.h>
23350 +#ifdef CONFIG_COMPAT
23351 +#define __COMPAT(name, id, data, compat) \
23352 + (compat) ? name ## _x32(id, data) : name(id, data)
23353 +#define __COMPAT_NO_ID(name, data, compat) \
23354 + (compat) ? name ## _x32(data) : name(data)
23356 +#define __COMPAT(name, id, data, compat) \
23358 +#define __COMPAT_NO_ID(name, data, compat) \
23364 +long do_vcmd(uint32_t cmd, uint32_t id,
23365 + struct vx_info *vxi, struct nx_info *nxi,
23366 + void __user *data, int compat)
23370 + case VCMD_get_version:
23371 + return vc_get_version(id);
23372 + case VCMD_get_vci:
23373 + return vc_get_vci(id);
23375 + case VCMD_task_xid:
23376 + return vc_task_xid(id);
23377 + case VCMD_vx_info:
23378 + return vc_vx_info(vxi, data);
23380 + case VCMD_task_nid:
23381 + return vc_task_nid(id);
23382 + case VCMD_nx_info:
23383 + return vc_nx_info(nxi, data);
23385 + case VCMD_task_tag:
23386 + return vc_task_tag(id);
23388 + case VCMD_set_space_v1:
23389 + return vc_set_space_v1(vxi, data);
23390 + /* this is version 2 */
23391 + case VCMD_set_space:
23392 + return vc_set_space(vxi, data);
23394 + case VCMD_get_space_mask_v0:
23395 + return vc_get_space_mask(data, 0);
23396 + /* this is version 1 */
23397 + case VCMD_get_space_mask:
23398 + return vc_get_space_mask(data, 1);
23400 + case VCMD_get_space_default:
23401 + return vc_get_space_mask(data, -1);
23403 + case VCMD_set_umask:
23404 + return vc_set_umask(vxi, data);
23406 + case VCMD_get_umask:
23407 + return vc_get_umask(vxi, data);
23409 +#ifdef CONFIG_IA32_EMULATION
23410 + case VCMD_get_rlimit:
23411 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23412 + case VCMD_set_rlimit:
23413 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23415 + case VCMD_get_rlimit:
23416 + return vc_get_rlimit(vxi, data);
23417 + case VCMD_set_rlimit:
23418 + return vc_set_rlimit(vxi, data);
23420 + case VCMD_get_rlimit_mask:
23421 + return vc_get_rlimit_mask(id, data);
23422 + case VCMD_reset_hits:
23423 + return vc_reset_hits(vxi, data);
23424 + case VCMD_reset_minmax:
23425 + return vc_reset_minmax(vxi, data);
23427 + case VCMD_get_vhi_name:
23428 + return vc_get_vhi_name(vxi, data);
23429 + case VCMD_set_vhi_name:
23430 + return vc_set_vhi_name(vxi, data);
23432 + case VCMD_ctx_stat:
23433 + return vc_ctx_stat(vxi, data);
23434 + case VCMD_virt_stat:
23435 + return vc_virt_stat(vxi, data);
23436 + case VCMD_sock_stat:
23437 + return vc_sock_stat(vxi, data);
23438 + case VCMD_rlimit_stat:
23439 + return vc_rlimit_stat(vxi, data);
23441 + case VCMD_set_cflags:
23442 + return vc_set_cflags(vxi, data);
23443 + case VCMD_get_cflags:
23444 + return vc_get_cflags(vxi, data);
23446 + /* this is version 1 */
23447 + case VCMD_set_ccaps:
23448 + return vc_set_ccaps(vxi, data);
23449 + /* this is version 1 */
23450 + case VCMD_get_ccaps:
23451 + return vc_get_ccaps(vxi, data);
23452 + case VCMD_set_bcaps:
23453 + return vc_set_bcaps(vxi, data);
23454 + case VCMD_get_bcaps:
23455 + return vc_get_bcaps(vxi, data);
23457 + case VCMD_set_badness:
23458 + return vc_set_badness(vxi, data);
23459 + case VCMD_get_badness:
23460 + return vc_get_badness(vxi, data);
23462 + case VCMD_set_nflags:
23463 + return vc_set_nflags(nxi, data);
23464 + case VCMD_get_nflags:
23465 + return vc_get_nflags(nxi, data);
23467 + case VCMD_set_ncaps:
23468 + return vc_set_ncaps(nxi, data);
23469 + case VCMD_get_ncaps:
23470 + return vc_get_ncaps(nxi, data);
23472 + case VCMD_set_prio_bias:
23473 + return vc_set_prio_bias(vxi, data);
23474 + case VCMD_get_prio_bias:
23475 + return vc_get_prio_bias(vxi, data);
23476 + case VCMD_add_dlimit:
23477 + return __COMPAT(vc_add_dlimit, id, data, compat);
23478 + case VCMD_rem_dlimit:
23479 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23480 + case VCMD_set_dlimit:
23481 + return __COMPAT(vc_set_dlimit, id, data, compat);
23482 + case VCMD_get_dlimit:
23483 + return __COMPAT(vc_get_dlimit, id, data, compat);
23485 + case VCMD_ctx_kill:
23486 + return vc_ctx_kill(vxi, data);
23488 + case VCMD_wait_exit:
23489 + return vc_wait_exit(vxi, data);
23491 + case VCMD_get_iattr:
23492 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23493 + case VCMD_set_iattr:
23494 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23496 + case VCMD_fget_iattr:
23497 + return vc_fget_iattr(id, data);
23498 + case VCMD_fset_iattr:
23499 + return vc_fset_iattr(id, data);
23501 + case VCMD_enter_space_v0:
23502 + return vc_enter_space_v1(vxi, NULL);
23503 + case VCMD_enter_space_v1:
23504 + return vc_enter_space_v1(vxi, data);
23505 + /* this is version 2 */
23506 + case VCMD_enter_space:
23507 + return vc_enter_space(vxi, data);
23509 + case VCMD_ctx_create_v0:
23510 + return vc_ctx_create(id, NULL);
23511 + case VCMD_ctx_create:
23512 + return vc_ctx_create(id, data);
23513 + case VCMD_ctx_migrate_v0:
23514 + return vc_ctx_migrate(vxi, NULL);
23515 + case VCMD_ctx_migrate:
23516 + return vc_ctx_migrate(vxi, data);
23518 + case VCMD_net_create_v0:
23519 + return vc_net_create(id, NULL);
23520 + case VCMD_net_create:
23521 + return vc_net_create(id, data);
23522 + case VCMD_net_migrate:
23523 + return vc_net_migrate(nxi, data);
23525 + case VCMD_tag_migrate:
23526 + return vc_tag_migrate(id);
23528 + case VCMD_net_add:
23529 + return vc_net_add(nxi, data);
23530 + case VCMD_net_remove:
23531 + return vc_net_remove(nxi, data);
23533 + case VCMD_net_add_ipv4_v1:
23534 + return vc_net_add_ipv4_v1(nxi, data);
23535 + /* this is version 2 */
23536 + case VCMD_net_add_ipv4:
23537 + return vc_net_add_ipv4(nxi, data);
23539 + case VCMD_net_rem_ipv4_v1:
23540 + return vc_net_rem_ipv4_v1(nxi, data);
23541 + /* this is version 2 */
23542 + case VCMD_net_rem_ipv4:
23543 + return vc_net_rem_ipv4(nxi, data);
23544 +#ifdef CONFIG_IPV6
23545 + case VCMD_net_add_ipv6:
23546 + return vc_net_add_ipv6(nxi, data);
23547 + case VCMD_net_remove_ipv6:
23548 + return vc_net_remove_ipv6(nxi, data);
23550 +/* case VCMD_add_match_ipv4:
23551 + return vc_add_match_ipv4(nxi, data);
23552 + case VCMD_get_match_ipv4:
23553 + return vc_get_match_ipv4(nxi, data);
23554 +#ifdef CONFIG_IPV6
23555 + case VCMD_add_match_ipv6:
23556 + return vc_add_match_ipv6(nxi, data);
23557 + case VCMD_get_match_ipv6:
23558 + return vc_get_match_ipv6(nxi, data);
23561 +#ifdef CONFIG_VSERVER_DEVICE
23562 + case VCMD_set_mapping:
23563 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23564 + case VCMD_unset_mapping:
23565 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23567 +#ifdef CONFIG_VSERVER_HISTORY
23568 + case VCMD_dump_history:
23569 + return vc_dump_history(id);
23570 + case VCMD_read_history:
23571 + return __COMPAT(vc_read_history, id, data, compat);
23574 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23575 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23581 +#define __VCMD(vcmd, _perm, _args, _flags) \
23582 + case VCMD_ ## vcmd: perm = _perm; \
23583 + args = _args; flags = _flags; break
23586 +#define VCA_NONE 0x00
23587 +#define VCA_VXI 0x01
23588 +#define VCA_NXI 0x02
23590 +#define VCF_NONE 0x00
23591 +#define VCF_INFO 0x01
23592 +#define VCF_ADMIN 0x02
23593 +#define VCF_ARES 0x06 /* includes admin */
23594 +#define VCF_SETUP 0x08
23596 +#define VCF_ZIDOK 0x10 /* zero id okay */
23600 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23603 + int permit = -1, state = 0;
23604 + int perm = -1, args = 0, flags = 0;
23605 + struct vx_info *vxi = NULL;
23606 + struct nx_info *nxi = NULL;
23609 + /* unpriviledged commands */
23610 + __VCMD(get_version, 0, VCA_NONE, 0);
23611 + __VCMD(get_vci, 0, VCA_NONE, 0);
23612 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23613 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23614 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23615 + __VCMD(get_space_default,0, VCA_NONE, 0);
23617 + /* info commands */
23618 + __VCMD(task_xid, 2, VCA_NONE, 0);
23619 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23620 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23621 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23622 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23623 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23624 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23625 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23626 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23627 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23628 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23630 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23631 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23632 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23633 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23635 + __VCMD(task_nid, 2, VCA_NONE, 0);
23636 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23637 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23638 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23640 + __VCMD(task_tag, 2, VCA_NONE, 0);
23642 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23643 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23644 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23645 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23647 + /* lower admin commands */
23648 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23649 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23650 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23651 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23652 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23653 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23654 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23655 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23657 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23658 + __VCMD(net_create, 5, VCA_NONE, 0);
23659 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23661 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23663 + /* higher admin commands */
23664 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23665 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23666 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23668 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23669 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23670 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23671 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23672 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23674 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23675 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23676 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23678 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23679 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23680 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23681 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23682 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23683 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23684 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23685 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23686 +#ifdef CONFIG_IPV6
23687 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23688 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23690 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23691 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23692 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23693 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23694 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23696 +#ifdef CONFIG_VSERVER_DEVICE
23697 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23698 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23700 + /* debug level admin commands */
23701 +#ifdef CONFIG_VSERVER_HISTORY
23702 + __VCMD(dump_history, 9, VCA_NONE, 0);
23703 + __VCMD(read_history, 9, VCA_NONE, 0);
23710 + vxdprintk(VXD_CBIT(switch, 0),
23711 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23712 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23713 + VC_VERSION(cmd), id, data, compat,
23714 + perm, args, flags);
23721 + if (!capable(CAP_CONTEXT))
23725 + /* moved here from the individual commands */
23727 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23731 + /* vcmd involves resource management */
23733 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23737 + /* various legacy exceptions */
23739 + /* will go away when spectator is a cap */
23740 + case VCMD_ctx_migrate_v0:
23741 + case VCMD_ctx_migrate:
23743 + current->xid = 1;
23749 + /* will go away when spectator is a cap */
23750 + case VCMD_net_migrate:
23752 + current->nid = 1;
23759 + /* vcmds are fine by default */
23762 + /* admin type vcmds require admin ... */
23763 + if (flags & VCF_ADMIN)
23764 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23766 + /* ... but setup type vcmds override that */
23767 + if (!permit && (flags & VCF_SETUP))
23768 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23776 + if (!id && (flags & VCF_ZIDOK))
23780 + if (args & VCA_VXI) {
23781 + vxi = lookup_vx_info(id);
23785 + if ((flags & VCF_ADMIN) &&
23786 + /* special case kill for shutdown */
23787 + (cmd != VCMD_ctx_kill) &&
23788 + /* can context be administrated? */
23789 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23795 + if (args & VCA_NXI) {
23796 + nxi = lookup_nx_info(id);
23800 + if ((flags & VCF_ADMIN) &&
23801 + /* can context be administrated? */
23802 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23809 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23812 + if ((args & VCA_NXI) && nxi)
23813 + put_nx_info(nxi);
23815 + if ((args & VCA_VXI) && vxi)
23816 + put_vx_info(vxi);
23818 + vxdprintk(VXD_CBIT(switch, 1),
23819 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23820 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23821 + VC_VERSION(cmd), ret, ret, state, permit);
23826 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23828 + return do_vserver(cmd, id, data, 0);
23831 +#ifdef CONFIG_COMPAT
23834 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23836 + return do_vserver(cmd, id, data, 1);
23839 +#endif /* CONFIG_COMPAT */
23840 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/sysctl.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/sysctl.c
23841 --- linux-3.0-rc5/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23842 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/sysctl.c 2011-06-10 22:11:24.000000000 +0200
23845 + * kernel/vserver/sysctl.c
23847 + * Virtual Context Support
23849 + * Copyright (C) 2004-2007 Herbert Pötzl
23851 + * V0.01 basic structure
23855 +#include <linux/module.h>
23856 +#include <linux/ctype.h>
23857 +#include <linux/sysctl.h>
23858 +#include <linux/parser.h>
23859 +#include <asm/uaccess.h>
23862 + CTL_DEBUG_ERROR = 0,
23863 + CTL_DEBUG_SWITCH = 1,
23878 +unsigned int vx_debug_switch = 0;
23879 +unsigned int vx_debug_xid = 0;
23880 +unsigned int vx_debug_nid = 0;
23881 +unsigned int vx_debug_tag = 0;
23882 +unsigned int vx_debug_net = 0;
23883 +unsigned int vx_debug_limit = 0;
23884 +unsigned int vx_debug_cres = 0;
23885 +unsigned int vx_debug_dlim = 0;
23886 +unsigned int vx_debug_quota = 0;
23887 +unsigned int vx_debug_cvirt = 0;
23888 +unsigned int vx_debug_space = 0;
23889 +unsigned int vx_debug_misc = 0;
23892 +static struct ctl_table_header *vserver_table_header;
23893 +static ctl_table vserver_root_table[];
23896 +void vserver_register_sysctl(void)
23898 + if (!vserver_table_header) {
23899 + vserver_table_header = register_sysctl_table(vserver_root_table);
23904 +void vserver_unregister_sysctl(void)
23906 + if (vserver_table_header) {
23907 + unregister_sysctl_table(vserver_table_header);
23908 + vserver_table_header = NULL;
23913 +static int proc_dodebug(ctl_table *table, int write,
23914 + void __user *buffer, size_t *lenp, loff_t *ppos)
23916 + char tmpbuf[20], *p, c;
23917 + unsigned int value;
23918 + size_t left, len;
23920 + if ((*ppos && !write) || !*lenp) {
23928 + if (!access_ok(VERIFY_READ, buffer, left))
23930 + p = (char *)buffer;
23931 + while (left && __get_user(c, p) >= 0 && isspace(c))
23936 + if (left > sizeof(tmpbuf) - 1)
23938 + if (copy_from_user(tmpbuf, p, left))
23940 + tmpbuf[left] = '\0';
23942 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23943 + value = 10 * value + (*p - '0');
23944 + if (*p && !isspace(*p))
23946 + while (left && isspace(*p))
23948 + *(unsigned int *)table->data = value;
23950 + if (!access_ok(VERIFY_WRITE, buffer, left))
23952 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23955 + if (__copy_to_user(buffer, tmpbuf, len))
23957 + if ((left -= len) > 0) {
23958 + if (put_user('\n', (char *)buffer + len))
23972 +#define CTL_ENTRY(ctl, name) \
23974 + .procname = #name, \
23975 + .data = &vx_ ## name, \
23976 + .maxlen = sizeof(int), \
23978 + .proc_handler = &proc_dodebug, \
23979 + .extra1 = &zero, \
23980 + .extra2 = &zero, \
23983 +static ctl_table vserver_debug_table[] = {
23984 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23985 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23986 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23987 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23988 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23989 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23990 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23991 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23992 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23993 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23994 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23995 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23999 +static ctl_table vserver_root_table[] = {
24001 + .procname = "vserver",
24003 + .child = vserver_debug_table
24009 +static match_table_t tokens = {
24010 + { CTL_DEBUG_SWITCH, "switch=%x" },
24011 + { CTL_DEBUG_XID, "xid=%x" },
24012 + { CTL_DEBUG_NID, "nid=%x" },
24013 + { CTL_DEBUG_TAG, "tag=%x" },
24014 + { CTL_DEBUG_NET, "net=%x" },
24015 + { CTL_DEBUG_LIMIT, "limit=%x" },
24016 + { CTL_DEBUG_CRES, "cres=%x" },
24017 + { CTL_DEBUG_DLIM, "dlim=%x" },
24018 + { CTL_DEBUG_QUOTA, "quota=%x" },
24019 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
24020 + { CTL_DEBUG_SPACE, "space=%x" },
24021 + { CTL_DEBUG_MISC, "misc=%x" },
24022 + { CTL_DEBUG_ERROR, NULL }
24025 +#define HANDLE_CASE(id, name, val) \
24026 + case CTL_DEBUG_ ## id: \
24027 + vx_debug_ ## name = val; \
24028 + printk("vs_debug_" #name "=0x%x\n", val); \
24032 +static int __init vs_debug_setup(char *str)
24037 + printk("vs_debug_setup(%s)\n", str);
24038 + while ((p = strsep(&str, ",")) != NULL) {
24039 + substring_t args[MAX_OPT_ARGS];
24040 + unsigned int value;
24045 + token = match_token(p, tokens, args);
24046 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
24049 + HANDLE_CASE(SWITCH, switch, value);
24050 + HANDLE_CASE(XID, xid, value);
24051 + HANDLE_CASE(NID, nid, value);
24052 + HANDLE_CASE(TAG, tag, value);
24053 + HANDLE_CASE(NET, net, value);
24054 + HANDLE_CASE(LIMIT, limit, value);
24055 + HANDLE_CASE(CRES, cres, value);
24056 + HANDLE_CASE(DLIM, dlim, value);
24057 + HANDLE_CASE(QUOTA, quota, value);
24058 + HANDLE_CASE(CVIRT, cvirt, value);
24059 + HANDLE_CASE(SPACE, space, value);
24060 + HANDLE_CASE(MISC, misc, value);
24069 +__setup("vsdebug=", vs_debug_setup);
24073 +EXPORT_SYMBOL_GPL(vx_debug_switch);
24074 +EXPORT_SYMBOL_GPL(vx_debug_xid);
24075 +EXPORT_SYMBOL_GPL(vx_debug_nid);
24076 +EXPORT_SYMBOL_GPL(vx_debug_net);
24077 +EXPORT_SYMBOL_GPL(vx_debug_limit);
24078 +EXPORT_SYMBOL_GPL(vx_debug_cres);
24079 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
24080 +EXPORT_SYMBOL_GPL(vx_debug_quota);
24081 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
24082 +EXPORT_SYMBOL_GPL(vx_debug_space);
24083 +EXPORT_SYMBOL_GPL(vx_debug_misc);
24085 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/tag.c linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/tag.c
24086 --- linux-3.0-rc5/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
24087 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/tag.c 2011-06-10 22:11:24.000000000 +0200
24090 + * linux/kernel/vserver/tag.c
24092 + * Virtual Server: Shallow Tag Space
24094 + * Copyright (C) 2007 Herbert Pötzl
24096 + * V0.01 basic implementation
24100 +#include <linux/sched.h>
24101 +#include <linux/vserver/debug.h>
24102 +#include <linux/vs_pid.h>
24103 +#include <linux/vs_tag.h>
24105 +#include <linux/vserver/tag_cmd.h>
24108 +int dx_migrate_task(struct task_struct *p, tag_t tag)
24113 + vxdprintk(VXD_CBIT(tag, 5),
24114 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
24120 + vxdprintk(VXD_CBIT(tag, 5),
24121 + "moved task %p into [#%d]", p, tag);
24125 +/* vserver syscall commands below here */
24127 +/* taks xid and vx_info functions */
24130 +int vc_task_tag(uint32_t id)
24135 + struct task_struct *tsk;
24137 + tsk = find_task_by_real_pid(id);
24138 + tag = (tsk) ? tsk->tag : -ESRCH;
24139 + rcu_read_unlock();
24141 + tag = dx_current_tag();
24146 +int vc_tag_migrate(uint32_t tag)
24148 + return dx_migrate_task(current, tag & 0xFFFF);
24152 diff -NurpP --minimal linux-3.0-rc5/kernel/vserver/vci_config.h linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/vci_config.h
24153 --- linux-3.0-rc5/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
24154 +++ linux-3.0-rc5-vs2.3.1-pre3/kernel/vserver/vci_config.h 2011-06-10 22:11:24.000000000 +0200
24157 +/* interface version */
24159 +#define VCI_VERSION 0x00020308
24163 + VCI_KCBIT_NO_DYNAMIC = 0,
24165 + VCI_KCBIT_PROC_SECURE = 4,
24166 + /* VCI_KCBIT_HARDCPU = 5, */
24167 + /* VCI_KCBIT_IDLELIMIT = 6, */
24168 + /* VCI_KCBIT_IDLETIME = 7, */
24170 + VCI_KCBIT_COWBL = 8,
24171 + VCI_KCBIT_FULLCOWBL = 9,
24172 + VCI_KCBIT_SPACES = 10,
24173 + VCI_KCBIT_NETV2 = 11,
24174 + VCI_KCBIT_MEMCG = 12,
24176 + VCI_KCBIT_DEBUG = 16,
24177 + VCI_KCBIT_HISTORY = 20,
24178 + VCI_KCBIT_TAGGED = 24,
24179 + VCI_KCBIT_PPTAG = 28,
24181 + VCI_KCBIT_MORE = 31,
24185 +static inline uint32_t vci_kernel_config(void)
24188 + (1 << VCI_KCBIT_NO_DYNAMIC) |
24190 + /* configured features */
24191 +#ifdef CONFIG_VSERVER_PROC_SECURE
24192 + (1 << VCI_KCBIT_PROC_SECURE) |
24194 +#ifdef CONFIG_VSERVER_COWBL
24195 + (1 << VCI_KCBIT_COWBL) |
24196 + (1 << VCI_KCBIT_FULLCOWBL) |
24198 + (1 << VCI_KCBIT_SPACES) |
24199 + (1 << VCI_KCBIT_NETV2) |
24200 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
24201 + (1 << VCI_KCBIT_MEMCG) |
24204 + /* debug options */
24205 +#ifdef CONFIG_VSERVER_DEBUG
24206 + (1 << VCI_KCBIT_DEBUG) |
24208 +#ifdef CONFIG_VSERVER_HISTORY
24209 + (1 << VCI_KCBIT_HISTORY) |
24212 + /* inode context tagging */
24213 +#if defined(CONFIG_TAGGING_NONE)
24214 + (0 << VCI_KCBIT_TAGGED) |
24215 +#elif defined(CONFIG_TAGGING_UID16)
24216 + (1 << VCI_KCBIT_TAGGED) |
24217 +#elif defined(CONFIG_TAGGING_GID16)
24218 + (2 << VCI_KCBIT_TAGGED) |
24219 +#elif defined(CONFIG_TAGGING_ID24)
24220 + (3 << VCI_KCBIT_TAGGED) |
24221 +#elif defined(CONFIG_TAGGING_INTERN)
24222 + (4 << VCI_KCBIT_TAGGED) |
24223 +#elif defined(CONFIG_TAGGING_RUNTIME)
24224 + (5 << VCI_KCBIT_TAGGED) |
24226 + (7 << VCI_KCBIT_TAGGED) |
24228 + (1 << VCI_KCBIT_PPTAG) |
24232 diff -NurpP --minimal linux-3.0-rc5/mm/filemap_xip.c linux-3.0-rc5-vs2.3.1-pre3/mm/filemap_xip.c
24233 --- linux-3.0-rc5/mm/filemap_xip.c 2011-07-01 11:14:23.000000000 +0200
24234 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/filemap_xip.c 2011-06-10 22:11:24.000000000 +0200
24236 #include <linux/seqlock.h>
24237 #include <linux/mutex.h>
24238 #include <linux/gfp.h>
24239 +#include <linux/vs_memory.h>
24240 #include <asm/tlbflush.h>
24241 #include <asm/io.h>
24243 diff -NurpP --minimal linux-3.0-rc5/mm/fremap.c linux-3.0-rc5-vs2.3.1-pre3/mm/fremap.c
24244 --- linux-3.0-rc5/mm/fremap.c 2011-07-01 11:14:23.000000000 +0200
24245 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/fremap.c 2011-06-10 22:11:24.000000000 +0200
24247 #include <linux/module.h>
24248 #include <linux/syscalls.h>
24249 #include <linux/mmu_notifier.h>
24250 +#include <linux/vs_memory.h>
24252 #include <asm/mmu_context.h>
24253 #include <asm/cacheflush.h>
24254 diff -NurpP --minimal linux-3.0-rc5/mm/hugetlb.c linux-3.0-rc5-vs2.3.1-pre3/mm/hugetlb.c
24255 --- linux-3.0-rc5/mm/hugetlb.c 2011-07-01 11:14:23.000000000 +0200
24256 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/hugetlb.c 2011-06-22 12:39:16.000000000 +0200
24259 #include <linux/hugetlb.h>
24260 #include <linux/node.h>
24261 +#include <linux/vs_memory.h>
24262 #include "internal.h"
24264 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
24265 diff -NurpP --minimal linux-3.0-rc5/mm/memcontrol.c linux-3.0-rc5-vs2.3.1-pre3/mm/memcontrol.c
24266 --- linux-3.0-rc5/mm/memcontrol.c 2011-07-01 11:14:23.000000000 +0200
24267 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/memcontrol.c 2011-07-01 11:35:35.000000000 +0200
24268 @@ -736,6 +736,31 @@ struct mem_cgroup *mem_cgroup_from_task(
24269 struct mem_cgroup, css);
24272 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
24274 + return res_counter_read_u64(&mem->res, member);
24277 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
24279 + return res_counter_read_u64(&mem->memsw, member);
24282 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
24284 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
24287 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
24289 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
24292 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
24294 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
24297 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
24299 struct mem_cgroup *mem = NULL;
24300 diff -NurpP --minimal linux-3.0-rc5/mm/memory.c linux-3.0-rc5-vs2.3.1-pre3/mm/memory.c
24301 --- linux-3.0-rc5/mm/memory.c 2011-07-01 11:14:23.000000000 +0200
24302 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/memory.c 2011-07-01 11:35:35.000000000 +0200
24303 @@ -3331,6 +3331,7 @@ int handle_pte_fault(struct mm_struct *m
24307 + int ret = 0, type = VXPT_UNKNOWN;
24310 if (!pte_present(entry)) {
24311 @@ -3355,9 +3356,12 @@ int handle_pte_fault(struct mm_struct *m
24312 if (unlikely(!pte_same(*pte, entry)))
24314 if (flags & FAULT_FLAG_WRITE) {
24315 - if (!pte_write(entry))
24316 - return do_wp_page(mm, vma, address,
24317 + if (!pte_write(entry)) {
24318 + ret = do_wp_page(mm, vma, address,
24319 pte, pmd, ptl, entry);
24320 + type = VXPT_WRITE;
24323 entry = pte_mkdirty(entry);
24325 entry = pte_mkyoung(entry);
24326 @@ -3375,7 +3379,10 @@ int handle_pte_fault(struct mm_struct *m
24329 pte_unmap_unlock(pte, ptl);
24333 + vx_page_fault(mm, vma, type, ret);
24338 diff -NurpP --minimal linux-3.0-rc5/mm/mremap.c linux-3.0-rc5-vs2.3.1-pre3/mm/mremap.c
24339 --- linux-3.0-rc5/mm/mremap.c 2011-07-01 11:14:23.000000000 +0200
24340 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/mremap.c 2011-06-10 22:11:24.000000000 +0200
24342 #include <linux/security.h>
24343 #include <linux/syscalls.h>
24344 #include <linux/mmu_notifier.h>
24345 +#include <linux/vs_memory.h>
24347 #include <asm/uaccess.h>
24348 #include <asm/cacheflush.h>
24349 diff -NurpP --minimal linux-3.0-rc5/mm/oom_kill.c linux-3.0-rc5-vs2.3.1-pre3/mm/oom_kill.c
24350 --- linux-3.0-rc5/mm/oom_kill.c 2011-07-01 11:14:23.000000000 +0200
24351 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/oom_kill.c 2011-06-10 22:11:24.000000000 +0200
24353 #include <linux/mempolicy.h>
24354 #include <linux/security.h>
24355 #include <linux/ptrace.h>
24356 +#include <linux/reboot.h>
24357 +#include <linux/vs_memory.h>
24358 +#include <linux/vs_context.h>
24360 int sysctl_panic_on_oom;
24361 int sysctl_oom_kill_allocating_task;
24362 @@ -134,11 +137,18 @@ struct task_struct *find_lock_task_mm(st
24363 static bool oom_unkillable_task(struct task_struct *p,
24364 const struct mem_cgroup *mem, const nodemask_t *nodemask)
24366 - if (is_global_init(p))
24367 + unsigned xid = vx_current_xid();
24369 + /* skip the init task, global and per guest */
24370 + if (task_is_init(p))
24372 if (p->flags & PF_KTHREAD)
24375 + /* skip other guest and host processes if oom in guest */
24376 + if (xid && vx_task_xid(p) != xid)
24379 /* When mem_cgroup_out_of_memory() and p is not member of the group */
24380 if (mem && !task_in_mem_cgroup(p, mem))
24382 @@ -214,6 +224,18 @@ unsigned int oom_badness(struct task_str
24383 points += p->signal->oom_score_adj;
24386 + * add points for context badness and
24387 + * reduce badness for processes belonging to
24388 + * a different context
24391 + points += vx_badness(p, p->mm);
24393 + if ((vx_current_xid() > 1) &&
24394 + vx_current_xid() != vx_task_xid(p))
24398 * Never return 0 for an eligible task that may be killed since it's
24399 * possible that no single user task uses more than 0.1% of memory and
24400 * no single admin tasks uses more than 3.0%.
24401 @@ -427,8 +449,8 @@ static int oom_kill_task(struct task_str
24402 /* mm cannot be safely dereferenced after task_unlock(p) */
24405 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24406 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
24407 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24408 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
24409 K(get_mm_counter(p->mm, MM_ANONPAGES)),
24410 K(get_mm_counter(p->mm, MM_FILEPAGES)));
24412 @@ -482,8 +504,8 @@ static int oom_kill_process(struct task_
24416 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
24417 - message, task_pid_nr(p), p->comm, points);
24418 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
24419 + message, task_pid_nr(p), p->xid, p->comm, points);
24423 @@ -584,6 +606,8 @@ int unregister_oom_notifier(struct notif
24425 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
24427 +long vs_oom_action(unsigned int);
24430 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
24431 * if a parallel OOM killing is already taking place that includes a zone in
24432 @@ -742,7 +766,12 @@ retry:
24434 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
24435 read_unlock(&tasklist_lock);
24436 - panic("Out of memory and no killable processes...\n");
24438 + /* avoid panic for guest OOM */
24439 + if (current->xid)
24440 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
24442 + panic("Out of memory and no killable processes...\n");
24445 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
24446 diff -NurpP --minimal linux-3.0-rc5/mm/page_alloc.c linux-3.0-rc5-vs2.3.1-pre3/mm/page_alloc.c
24447 --- linux-3.0-rc5/mm/page_alloc.c 2011-07-01 11:14:23.000000000 +0200
24448 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/page_alloc.c 2011-06-10 22:24:12.000000000 +0200
24450 #include <linux/ftrace_event.h>
24451 #include <linux/memcontrol.h>
24452 #include <linux/prefetch.h>
24453 +#include <linux/vs_base.h>
24454 +#include <linux/vs_limit.h>
24456 #include <asm/tlbflush.h>
24457 #include <asm/div64.h>
24458 @@ -2470,6 +2472,9 @@ void si_meminfo(struct sysinfo *val)
24459 val->totalhigh = totalhigh_pages;
24460 val->freehigh = nr_free_highpages();
24461 val->mem_unit = PAGE_SIZE;
24463 + if (vx_flags(VXF_VIRT_MEM, 0))
24464 + vx_vsi_meminfo(val);
24467 EXPORT_SYMBOL(si_meminfo);
24468 @@ -2490,6 +2495,9 @@ void si_meminfo_node(struct sysinfo *val
24471 val->mem_unit = PAGE_SIZE;
24473 + if (vx_flags(VXF_VIRT_MEM, 0))
24474 + vx_vsi_meminfo(val);
24478 diff -NurpP --minimal linux-3.0-rc5/mm/pgtable-generic.c linux-3.0-rc5-vs2.3.1-pre3/mm/pgtable-generic.c
24479 --- linux-3.0-rc5/mm/pgtable-generic.c 2011-03-15 18:07:42.000000000 +0100
24480 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/pgtable-generic.c 2011-06-10 22:11:24.000000000 +0200
24482 * Copyright (C) 2010 Linus Torvalds
24485 +#include <linux/mm.h>
24487 #include <linux/pagemap.h>
24488 #include <asm/tlb.h>
24489 #include <asm-generic/pgtable.h>
24490 diff -NurpP --minimal linux-3.0-rc5/mm/rmap.c linux-3.0-rc5-vs2.3.1-pre3/mm/rmap.c
24491 --- linux-3.0-rc5/mm/rmap.c 2011-07-01 11:14:23.000000000 +0200
24492 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/rmap.c 2011-07-01 11:35:35.000000000 +0200
24494 #include <linux/mmu_notifier.h>
24495 #include <linux/migrate.h>
24496 #include <linux/hugetlb.h>
24497 +#include <linux/vs_memory.h>
24499 #include <asm/tlbflush.h>
24501 diff -NurpP --minimal linux-3.0-rc5/mm/shmem.c linux-3.0-rc5-vs2.3.1-pre3/mm/shmem.c
24502 --- linux-3.0-rc5/mm/shmem.c 2011-07-01 11:14:23.000000000 +0200
24503 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/shmem.c 2011-07-01 11:35:35.000000000 +0200
24504 @@ -1850,7 +1850,7 @@ static int shmem_statfs(struct dentry *d
24506 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24508 - buf->f_type = TMPFS_MAGIC;
24509 + buf->f_type = TMPFS_SUPER_MAGIC;
24510 buf->f_bsize = PAGE_CACHE_SIZE;
24511 buf->f_namelen = NAME_MAX;
24512 if (sbinfo->max_blocks) {
24513 @@ -2605,7 +2605,7 @@ int shmem_fill_super(struct super_block
24514 sb->s_maxbytes = SHMEM_MAX_BYTES;
24515 sb->s_blocksize = PAGE_CACHE_SIZE;
24516 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24517 - sb->s_magic = TMPFS_MAGIC;
24518 + sb->s_magic = TMPFS_SUPER_MAGIC;
24519 sb->s_op = &shmem_ops;
24520 sb->s_time_gran = 1;
24521 #ifdef CONFIG_TMPFS_XATTR
24522 diff -NurpP --minimal linux-3.0-rc5/mm/slab.c linux-3.0-rc5-vs2.3.1-pre3/mm/slab.c
24523 --- linux-3.0-rc5/mm/slab.c 2011-07-01 11:14:23.000000000 +0200
24524 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/slab.c 2011-06-15 02:41:23.000000000 +0200
24525 @@ -411,6 +411,8 @@ static void kmem_list3_init(struct kmem_
24526 #define STATS_INC_FREEMISS(x) do { } while (0)
24529 +#include "slab_vs.h"
24534 @@ -3348,6 +3350,7 @@ retry:
24536 obj = slab_get_obj(cachep, slabp, nodeid);
24537 check_slabp(cachep, slabp);
24538 + vx_slab_alloc(cachep, flags);
24539 l3->free_objects--;
24540 /* move slabp to correct slabp list: */
24541 list_del(&slabp->list);
24542 @@ -3425,6 +3428,7 @@ __cache_alloc_node(struct kmem_cache *ca
24543 /* ___cache_alloc_node can fall back to other nodes */
24544 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24546 + vx_slab_alloc(cachep, flags);
24547 local_irq_restore(save_flags);
24548 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24549 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24550 @@ -3612,6 +3616,7 @@ static inline void __cache_free(struct k
24552 kmemleak_free_recursive(objp, cachep->flags);
24553 objp = cache_free_debugcheck(cachep, objp, caller);
24554 + vx_slab_free(cachep);
24556 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24558 diff -NurpP --minimal linux-3.0-rc5/mm/slab_vs.h linux-3.0-rc5-vs2.3.1-pre3/mm/slab_vs.h
24559 --- linux-3.0-rc5/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24560 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/slab_vs.h 2011-06-10 22:11:24.000000000 +0200
24563 +#include <linux/vserver/context.h>
24565 +#include <linux/vs_context.h>
24568 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24570 + int what = gfp_zone(cachep->gfpflags);
24571 + struct vx_info *vxi = current_vx_info();
24576 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24580 +void vx_slab_free(struct kmem_cache *cachep)
24582 + int what = gfp_zone(cachep->gfpflags);
24583 + struct vx_info *vxi = current_vx_info();
24588 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24591 diff -NurpP --minimal linux-3.0-rc5/mm/swapfile.c linux-3.0-rc5-vs2.3.1-pre3/mm/swapfile.c
24592 --- linux-3.0-rc5/mm/swapfile.c 2011-07-01 11:14:23.000000000 +0200
24593 +++ linux-3.0-rc5-vs2.3.1-pre3/mm/swapfile.c 2011-07-01 11:35:35.000000000 +0200
24595 #include <asm/tlbflush.h>
24596 #include <linux/swapops.h>
24597 #include <linux/page_cgroup.h>
24598 +#include <linux/vs_base.h>
24599 +#include <linux/vs_memory.h>
24601 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24603 @@ -1759,6 +1761,16 @@ static int swap_show(struct seq_file *sw
24605 if (si == SEQ_START_TOKEN) {
24606 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24607 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24608 + struct sysinfo si;
24610 + vx_vsi_swapinfo(&si);
24611 + if (si.totalswap < (1 << 10))
24613 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24614 + "hdv0", "partition", si.totalswap >> 10,
24615 + (si.totalswap - si.freeswap) >> 10, -1);
24620 @@ -2186,6 +2198,8 @@ void si_swapinfo(struct sysinfo *val)
24621 val->freeswap = nr_swap_pages + nr_to_be_unused;
24622 val->totalswap = total_swap_pages + nr_to_be_unused;
24623 spin_unlock(&swap_lock);
24624 + if (vx_flags(VXF_VIRT_MEM, 0))
24625 + vx_vsi_swapinfo(val);
24629 diff -NurpP --minimal linux-3.0-rc5/net/bridge/br_multicast.c linux-3.0-rc5-vs2.3.1-pre3/net/bridge/br_multicast.c
24630 --- linux-3.0-rc5/net/bridge/br_multicast.c 2011-07-01 11:14:26.000000000 +0200
24631 +++ linux-3.0-rc5-vs2.3.1-pre3/net/bridge/br_multicast.c 2011-06-22 12:39:16.000000000 +0200
24632 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
24633 ip6h->hop_limit = 1;
24634 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24635 ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24637 + &ip6h->saddr, NULL);
24638 ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
24640 hopopt = (u8 *)(ip6h + 1);
24641 diff -NurpP --minimal linux-3.0-rc5/net/core/dev.c linux-3.0-rc5-vs2.3.1-pre3/net/core/dev.c
24642 --- linux-3.0-rc5/net/core/dev.c 2011-07-01 11:14:26.000000000 +0200
24643 +++ linux-3.0-rc5-vs2.3.1-pre3/net/core/dev.c 2011-06-15 02:40:14.000000000 +0200
24644 @@ -127,6 +127,7 @@
24645 #include <linux/in.h>
24646 #include <linux/jhash.h>
24647 #include <linux/random.h>
24648 +#include <linux/vs_inet.h>
24649 #include <trace/events/napi.h>
24650 #include <trace/events/net.h>
24651 #include <trace/events/skb.h>
24652 @@ -609,7 +610,8 @@ struct net_device *__dev_get_by_name(str
24653 struct hlist_head *head = dev_name_hash(net, name);
24655 hlist_for_each_entry(dev, p, head, name_hlist)
24656 - if (!strncmp(dev->name, name, IFNAMSIZ))
24657 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24658 + nx_dev_visible(current_nx_info(), dev))
24662 @@ -635,7 +637,8 @@ struct net_device *dev_get_by_name_rcu(s
24663 struct hlist_head *head = dev_name_hash(net, name);
24665 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24666 - if (!strncmp(dev->name, name, IFNAMSIZ))
24667 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24668 + nx_dev_visible(current_nx_info(), dev))
24672 @@ -686,7 +689,8 @@ struct net_device *__dev_get_by_index(st
24673 struct hlist_head *head = dev_index_hash(net, ifindex);
24675 hlist_for_each_entry(dev, p, head, index_hlist)
24676 - if (dev->ifindex == ifindex)
24677 + if ((dev->ifindex == ifindex) &&
24678 + nx_dev_visible(current_nx_info(), dev))
24682 @@ -711,7 +715,8 @@ struct net_device *dev_get_by_index_rcu(
24683 struct hlist_head *head = dev_index_hash(net, ifindex);
24685 hlist_for_each_entry_rcu(dev, p, head, index_hlist)
24686 - if (dev->ifindex == ifindex)
24687 + if ((dev->ifindex == ifindex) &&
24688 + nx_dev_visible(current_nx_info(), dev))
24692 @@ -764,7 +769,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24694 for_each_netdev_rcu(net, dev)
24695 if (dev->type == type &&
24696 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24697 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24698 + nx_dev_visible(current_nx_info(), dev))
24702 @@ -776,9 +782,11 @@ struct net_device *__dev_getfirstbyhwtyp
24703 struct net_device *dev;
24706 - for_each_netdev(net, dev)
24707 - if (dev->type == type)
24708 + for_each_netdev(net, dev) {
24709 + if ((dev->type == type) &&
24710 + nx_dev_visible(current_nx_info(), dev))
24716 @@ -896,6 +904,8 @@ static int __dev_alloc_name(struct net *
24718 if (i < 0 || i >= max_netdevices)
24720 + if (!nx_dev_visible(current_nx_info(), d))
24723 /* avoid cases where sscanf is not exact inverse of printf */
24724 snprintf(buf, IFNAMSIZ, name, i);
24725 @@ -3937,6 +3947,8 @@ static int dev_ifconf(struct net *net, c
24728 for_each_netdev(net, dev) {
24729 + if (!nx_dev_visible(current_nx_info(), dev))
24731 for (i = 0; i < NPROTO; i++) {
24732 if (gifconf_list[i]) {
24734 @@ -4011,6 +4023,10 @@ static void dev_seq_printf_stats(struct
24735 struct rtnl_link_stats64 temp;
24736 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24738 + /* device visible inside network context? */
24739 + if (!nx_dev_visible(current_nx_info(), dev))
24742 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24743 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24744 dev->name, stats->rx_bytes, stats->rx_packets,
24745 diff -NurpP --minimal linux-3.0-rc5/net/core/rtnetlink.c linux-3.0-rc5-vs2.3.1-pre3/net/core/rtnetlink.c
24746 --- linux-3.0-rc5/net/core/rtnetlink.c 2011-07-01 11:14:26.000000000 +0200
24747 +++ linux-3.0-rc5-vs2.3.1-pre3/net/core/rtnetlink.c 2011-06-10 22:11:24.000000000 +0200
24748 @@ -1015,6 +1015,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24749 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
24752 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24754 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24755 NETLINK_CB(cb->skb).pid,
24756 cb->nlh->nlmsg_seq, 0,
24757 @@ -1848,6 +1850,9 @@ void rtmsg_ifinfo(int type, struct net_d
24758 struct sk_buff *skb;
24759 int err = -ENOBUFS;
24761 + if (!nx_dev_visible(current_nx_info(), dev))
24764 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
24767 diff -NurpP --minimal linux-3.0-rc5/net/core/sock.c linux-3.0-rc5-vs2.3.1-pre3/net/core/sock.c
24768 --- linux-3.0-rc5/net/core/sock.c 2011-05-22 16:18:00.000000000 +0200
24769 +++ linux-3.0-rc5-vs2.3.1-pre3/net/core/sock.c 2011-06-10 22:11:24.000000000 +0200
24770 @@ -127,6 +127,10 @@
24771 #include <net/cls_cgroup.h>
24773 #include <linux/filter.h>
24774 +#include <linux/vs_socket.h>
24775 +#include <linux/vs_limit.h>
24776 +#include <linux/vs_context.h>
24777 +#include <linux/vs_network.h>
24780 #include <net/tcp.h>
24781 @@ -1070,6 +1074,8 @@ static struct sock *sk_prot_alloc(struct
24783 sk_tx_queue_clear(sk);
24785 + sock_vx_init(sk);
24786 + sock_nx_init(sk);
24790 @@ -1169,6 +1175,11 @@ static void __sk_free(struct sock *sk)
24791 put_cred(sk->sk_peer_cred);
24792 put_pid(sk->sk_peer_pid);
24793 put_net(sock_net(sk));
24795 + clr_vx_info(&sk->sk_vx_info);
24797 + clr_nx_info(&sk->sk_nx_info);
24799 sk_prot_free(sk->sk_prot_creator, sk);
24802 @@ -1216,6 +1227,8 @@ struct sock *sk_clone(const struct sock
24805 get_net(sock_net(newsk));
24806 + sock_vx_init(newsk);
24807 + sock_nx_init(newsk);
24808 sk_node_init(&newsk->sk_node);
24809 sock_lock_init(newsk);
24810 bh_lock_sock(newsk);
24811 @@ -1271,6 +1284,12 @@ struct sock *sk_clone(const struct sock
24813 atomic_set(&newsk->sk_refcnt, 2);
24815 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24816 + newsk->sk_xid = sk->sk_xid;
24817 + vx_sock_inc(newsk);
24818 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24819 + newsk->sk_nid = sk->sk_nid;
24822 * Increment the counter in the same struct proto as the master
24823 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24824 @@ -2017,6 +2036,12 @@ void sock_init_data(struct socket *sock,
24826 sk->sk_stamp = ktime_set(-1L, 0);
24828 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24829 + sk->sk_xid = vx_current_xid();
24831 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24832 + sk->sk_nid = nx_current_nid();
24835 * Before updating sk_refcnt, we must commit prior changes to memory
24836 * (Documentation/RCU/rculist_nulls.txt for details)
24837 diff -NurpP --minimal linux-3.0-rc5/net/ipv4/af_inet.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/af_inet.c
24838 --- linux-3.0-rc5/net/ipv4/af_inet.c 2011-07-01 11:14:26.000000000 +0200
24839 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/af_inet.c 2011-06-22 12:39:16.000000000 +0200
24840 @@ -117,6 +117,7 @@
24841 #ifdef CONFIG_IP_MROUTE
24842 #include <linux/mroute.h>
24844 +#include <linux/vs_limit.h>
24847 /* The inetsw table contains everything that inet_create needs to
24848 @@ -326,9 +327,13 @@ lookup_protocol:
24852 + if ((protocol == IPPROTO_ICMP) &&
24853 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24856 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24857 goto out_rcu_unlock;
24860 err = -EAFNOSUPPORT;
24861 if (!inet_netns_ok(net, protocol))
24862 goto out_rcu_unlock;
24863 @@ -452,6 +457,7 @@ int inet_bind(struct socket *sock, struc
24864 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24865 struct sock *sk = sock->sk;
24866 struct inet_sock *inet = inet_sk(sk);
24867 + struct nx_v4_sock_addr nsa;
24868 unsigned short snum;
24871 @@ -468,7 +474,11 @@ int inet_bind(struct socket *sock, struc
24872 if (addr->sin_family != AF_INET)
24875 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24876 + err = v4_map_sock_addr(inet, addr, &nsa);
24880 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24882 /* Not specified by any standard per-se, however it breaks too
24883 * many applications when removed. It is unfortunate since
24884 @@ -480,7 +490,7 @@ int inet_bind(struct socket *sock, struc
24885 err = -EADDRNOTAVAIL;
24886 if (!sysctl_ip_nonlocal_bind &&
24887 !(inet->freebind || inet->transparent) &&
24888 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24889 + nsa.saddr != htonl(INADDR_ANY) &&
24890 chk_addr_ret != RTN_LOCAL &&
24891 chk_addr_ret != RTN_MULTICAST &&
24892 chk_addr_ret != RTN_BROADCAST)
24893 @@ -505,7 +515,7 @@ int inet_bind(struct socket *sock, struc
24894 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24895 goto out_release_sock;
24897 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24898 + v4_set_sock_addr(inet, &nsa);
24899 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24900 inet->inet_saddr = 0; /* Use device */
24902 @@ -708,11 +718,13 @@ int inet_getname(struct socket *sock, st
24905 sin->sin_port = inet->inet_dport;
24906 - sin->sin_addr.s_addr = inet->inet_daddr;
24907 + sin->sin_addr.s_addr =
24908 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24910 __be32 addr = inet->inet_rcv_saddr;
24912 addr = inet->inet_saddr;
24913 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24914 sin->sin_port = inet->inet_sport;
24915 sin->sin_addr.s_addr = addr;
24917 diff -NurpP --minimal linux-3.0-rc5/net/ipv4/devinet.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/devinet.c
24918 --- linux-3.0-rc5/net/ipv4/devinet.c 2011-07-01 11:14:26.000000000 +0200
24919 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/devinet.c 2011-06-10 22:11:24.000000000 +0200
24920 @@ -518,6 +518,7 @@ struct in_device *inetdev_by_index(struc
24922 EXPORT_SYMBOL(inetdev_by_index);
24925 /* Called only from RTNL semaphored context. No locks. */
24927 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24928 @@ -759,6 +760,8 @@ int devinet_ioctl(struct net *net, unsig
24930 in_dev = __in_dev_get_rtnl(dev);
24932 + struct nx_info *nxi = current_nx_info();
24934 if (tryaddrmatch) {
24935 /* Matthias Andree */
24936 /* compare label and address (4.4BSD style) */
24937 @@ -767,6 +770,8 @@ int devinet_ioctl(struct net *net, unsig
24938 This is checked above. */
24939 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24940 ifap = &ifa->ifa_next) {
24941 + if (!nx_v4_ifa_visible(nxi, ifa))
24943 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24944 sin_orig.sin_addr.s_addr ==
24946 @@ -779,9 +784,12 @@ int devinet_ioctl(struct net *net, unsig
24947 comparing just the label */
24949 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24950 - ifap = &ifa->ifa_next)
24951 + ifap = &ifa->ifa_next) {
24952 + if (!nx_v4_ifa_visible(nxi, ifa))
24954 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24960 @@ -934,6 +942,8 @@ static int inet_gifconf(struct net_devic
24963 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24964 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24967 done += sizeof(ifr);
24969 @@ -1294,6 +1304,7 @@ static int inet_dump_ifaddr(struct sk_bu
24970 struct net_device *dev;
24971 struct in_device *in_dev;
24972 struct in_ifaddr *ifa;
24973 + struct sock *sk = skb->sk;
24974 struct hlist_head *head;
24975 struct hlist_node *node;
24977 @@ -1316,6 +1327,8 @@ static int inet_dump_ifaddr(struct sk_bu
24979 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24980 ifa = ifa->ifa_next, ip_idx++) {
24981 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24983 if (ip_idx < s_ip_idx)
24985 if (inet_fill_ifaddr(skb, ifa,
24986 diff -NurpP --minimal linux-3.0-rc5/net/ipv4/inet_connection_sock.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/inet_connection_sock.c
24987 --- linux-3.0-rc5/net/ipv4/inet_connection_sock.c 2011-07-01 11:14:26.000000000 +0200
24988 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/inet_connection_sock.c 2011-06-10 22:11:24.000000000 +0200
24989 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
24991 EXPORT_SYMBOL(inet_get_local_port_range);
24993 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24995 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24996 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24998 + if (inet_v6_ipv6only(sk2))
25001 + if (sk1_rcv_saddr &&
25003 + sk1_rcv_saddr == sk2_rcv_saddr)
25006 + if (sk1_rcv_saddr &&
25007 + !sk2_rcv_saddr &&
25008 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
25011 + if (sk2_rcv_saddr &&
25012 + !sk1_rcv_saddr &&
25013 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
25016 + if (!sk1_rcv_saddr &&
25017 + !sk2_rcv_saddr &&
25018 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
25024 int inet_csk_bind_conflict(const struct sock *sk,
25025 const struct inet_bind_bucket *tb)
25027 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct
25028 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
25029 if (!reuse || !sk2->sk_reuse ||
25030 sk2->sk_state == TCP_LISTEN) {
25031 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25032 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
25033 - sk2_rcv_saddr == sk_rcv_saddr(sk))
25034 + if (ipv4_rcv_saddr_equal(sk, sk2))
25038 diff -NurpP --minimal linux-3.0-rc5/net/ipv4/inet_diag.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/inet_diag.c
25039 --- linux-3.0-rc5/net/ipv4/inet_diag.c 2011-07-01 11:14:26.000000000 +0200
25040 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/inet_diag.c 2011-06-22 12:39:16.000000000 +0200
25042 #include <linux/stddef.h>
25044 #include <linux/inet_diag.h>
25045 +#include <linux/vs_network.h>
25046 +#include <linux/vs_inet.h>
25048 static const struct inet_diag_handler **inet_diag_table;
25050 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
25052 r->id.idiag_sport = inet->inet_sport;
25053 r->id.idiag_dport = inet->inet_dport;
25054 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
25055 - r->id.idiag_dst[0] = inet->inet_daddr;
25056 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
25057 + inet->inet_rcv_saddr);
25058 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
25059 + inet->inet_daddr);
25061 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25062 if (r->idiag_family == AF_INET6) {
25063 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
25064 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
25065 r->id.idiag_sport = tw->tw_sport;
25066 r->id.idiag_dport = tw->tw_dport;
25067 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
25068 - r->id.idiag_dst[0] = tw->tw_daddr;
25069 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
25070 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
25071 r->idiag_state = tw->tw_substate;
25072 r->idiag_timer = 3;
25073 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
25074 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
25077 if (req->idiag_family == AF_INET) {
25078 + /* TODO: lback */
25079 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
25080 req->id.idiag_dport, req->id.idiag_src[0],
25081 req->id.idiag_sport, req->id.idiag_if);
25082 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
25086 + /* TODO: lback */
25087 entry.saddr = &inet->inet_rcv_saddr;
25088 entry.daddr = &inet->inet_daddr;
25090 @@ -543,6 +549,7 @@ static int inet_twsk_diag_dump(struct in
25094 + /* TODO: lback */
25095 entry.saddr = &tw->tw_rcv_saddr;
25096 entry.daddr = &tw->tw_daddr;
25098 @@ -589,8 +596,8 @@ static int inet_diag_fill_req(struct sk_
25100 r->id.idiag_sport = inet->inet_sport;
25101 r->id.idiag_dport = ireq->rmt_port;
25102 - r->id.idiag_src[0] = ireq->loc_addr;
25103 - r->id.idiag_dst[0] = ireq->rmt_addr;
25104 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
25105 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
25106 r->idiag_expires = jiffies_to_msecs(tmo);
25107 r->idiag_rqueue = 0;
25108 r->idiag_wqueue = 0;
25109 @@ -661,6 +668,7 @@ static int inet_diag_dump_reqs(struct sk
25113 + /* TODO: lback */
25115 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25116 (entry.family == AF_INET6) ?
25117 @@ -731,6 +739,8 @@ static int inet_diag_dump(struct sk_buff
25118 sk_nulls_for_each(sk, node, &ilb->head) {
25119 struct inet_sock *inet = inet_sk(sk);
25121 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25126 @@ -797,6 +807,8 @@ skip_listen_ht:
25127 sk_nulls_for_each(sk, node, &head->chain) {
25128 struct inet_sock *inet = inet_sk(sk);
25130 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25134 if (!(r->idiag_states & (1 << sk->sk_state)))
25135 @@ -821,6 +833,8 @@ next_normal:
25136 inet_twsk_for_each(tw, node,
25139 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25143 if (r->id.idiag_sport != tw->tw_sport &&
25144 diff -NurpP --minimal linux-3.0-rc5/net/ipv4/inet_hashtables.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/inet_hashtables.c
25145 --- linux-3.0-rc5/net/ipv4/inet_hashtables.c 2011-01-05 21:50:42.000000000 +0100
25146 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/inet_hashtables.c 2011-06-10 22:11:24.000000000 +0200
25149 #include <net/inet_connection_sock.h>
25150 #include <net/inet_hashtables.h>
25151 +#include <net/route.h>
25152 #include <net/ip.h>
25155 @@ -155,6 +156,11 @@ static inline int compute_score(struct s
25156 if (rcv_saddr != daddr)
25160 + /* block non nx_info ips */
25161 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25162 + daddr, NXA_MASK_BIND))
25165 if (sk->sk_bound_dev_if) {
25166 if (sk->sk_bound_dev_if != dif)
25167 @@ -172,7 +178,6 @@ static inline int compute_score(struct s
25168 * wildcarded during the search since they can never be otherwise.
25172 struct sock *__inet_lookup_listener(struct net *net,
25173 struct inet_hashinfo *hashinfo,
25174 const __be32 daddr, const unsigned short hnum,
25175 @@ -195,6 +200,7 @@ begin:
25181 * if the nulls value we got at the end of this lookup is
25182 * not the expected one, we must restart lookup.
25183 diff -NurpP --minimal linux-3.0-rc5/net/ipv4/netfilter/nf_nat_helper.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/netfilter/nf_nat_helper.c
25184 --- linux-3.0-rc5/net/ipv4/netfilter/nf_nat_helper.c 2011-07-01 11:14:26.000000000 +0200
25185 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/netfilter/nf_nat_helper.c 2011-06-15 02:40:14.000000000 +0200
25187 #include <net/route.h>
25189 #include <linux/netfilter_ipv4.h>
25190 +#include <net/route.h>
25191 #include <net/netfilter/nf_conntrack.h>
25192 #include <net/netfilter/nf_conntrack_helper.h>
25193 #include <net/netfilter/nf_conntrack_ecache.h>
25194 diff -NurpP --minimal linux-3.0-rc5/net/ipv4/netfilter.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/netfilter.c
25195 --- linux-3.0-rc5/net/ipv4/netfilter.c 2011-05-22 16:18:00.000000000 +0200
25196 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/netfilter.c 2011-06-10 22:11:24.000000000 +0200
25198 #include <linux/ip.h>
25199 #include <linux/skbuff.h>
25200 #include <linux/gfp.h>
25201 -#include <net/route.h>
25202 +// #include <net/route.h>
25203 #include <net/xfrm.h>
25204 #include <net/ip.h>
25205 #include <net/netfilter/nf_queue.h>
25206 diff -NurpP --minimal linux-3.0-rc5/net/ipv4/raw.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/raw.c
25207 --- linux-3.0-rc5/net/ipv4/raw.c 2011-07-01 11:14:26.000000000 +0200
25208 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/raw.c 2011-06-10 22:11:24.000000000 +0200
25209 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
25211 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
25212 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
25213 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
25214 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
25215 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
25216 goto found; /* gotcha */
25218 @@ -385,6 +385,12 @@ static int raw_send_hdrinc(struct sock *
25219 icmp_out_count(net, ((struct icmphdr *)
25220 skb_transport_header(skb))->type);
25223 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
25224 + sk->sk_nx_info &&
25225 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
25228 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
25229 rt->dst.dev, dst_output);
25231 @@ -647,17 +653,19 @@ static int raw_bind(struct sock *sk, str
25233 struct inet_sock *inet = inet_sk(sk);
25234 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
25235 + struct nx_v4_sock_addr nsa = { 0 };
25239 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
25241 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25242 + v4_map_sock_addr(inet, addr, &nsa);
25243 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25244 ret = -EADDRNOTAVAIL;
25245 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
25246 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
25247 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
25249 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
25250 + v4_set_sock_addr(inet, &nsa);
25251 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25252 inet->inet_saddr = 0; /* Use device */
25254 @@ -709,7 +717,8 @@ static int raw_recvmsg(struct kiocb *ioc
25255 /* Copy the address. */
25257 sin->sin_family = AF_INET;
25258 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25259 + sin->sin_addr.s_addr =
25260 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
25262 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
25264 @@ -905,7 +914,8 @@ static struct sock *raw_get_first(struct
25265 struct hlist_node *node;
25267 sk_for_each(sk, node, &state->h->ht[state->bucket])
25268 - if (sock_net(sk) == seq_file_net(seq))
25269 + if ((sock_net(sk) == seq_file_net(seq)) &&
25270 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25274 @@ -921,7 +931,8 @@ static struct sock *raw_get_next(struct
25278 - } while (sk && sock_net(sk) != seq_file_net(seq));
25279 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
25280 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25282 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
25283 sk = sk_head(&state->h->ht[state->bucket]);
25284 diff -NurpP --minimal linux-3.0-rc5/net/ipv4/tcp.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/tcp.c
25285 --- linux-3.0-rc5/net/ipv4/tcp.c 2011-07-01 11:14:26.000000000 +0200
25286 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/tcp.c 2011-06-10 22:11:24.000000000 +0200
25287 @@ -266,6 +266,7 @@
25288 #include <linux/crypto.h>
25289 #include <linux/time.h>
25290 #include <linux/slab.h>
25291 +#include <linux/in.h>
25293 #include <net/icmp.h>
25294 #include <net/tcp.h>
25295 diff -NurpP --minimal linux-3.0-rc5/net/ipv4/tcp_ipv4.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/tcp_ipv4.c
25296 --- linux-3.0-rc5/net/ipv4/tcp_ipv4.c 2011-07-01 11:14:26.000000000 +0200
25297 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/tcp_ipv4.c 2011-06-22 12:39:16.000000000 +0200
25298 @@ -2002,6 +2002,12 @@ static void *listening_get_next(struct s
25299 req = req->dl_next;
25302 + vxdprintk(VXD_CBIT(net, 6),
25303 + "sk,req: %p [#%d] (from %d)", req->sk,
25304 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
25306 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
25308 if (req->rsk_ops->family == st->family) {
25311 @@ -2026,6 +2032,10 @@ get_req:
25314 sk_nulls_for_each_from(sk, node) {
25315 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
25316 + sk, sk->sk_nid, nx_current_nid());
25317 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25319 if (!net_eq(sock_net(sk), net))
25321 if (sk->sk_family == st->family) {
25322 @@ -2102,6 +2112,11 @@ static void *established_get_first(struc
25324 spin_lock_bh(lock);
25325 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
25326 + vxdprintk(VXD_CBIT(net, 6),
25327 + "sk,egf: %p [#%d] (from %d)",
25328 + sk, sk->sk_nid, nx_current_nid());
25329 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25331 if (sk->sk_family != st->family ||
25332 !net_eq(sock_net(sk), net)) {
25334 @@ -2112,6 +2127,11 @@ static void *established_get_first(struc
25335 st->state = TCP_SEQ_STATE_TIME_WAIT;
25336 inet_twsk_for_each(tw, node,
25337 &tcp_hashinfo.ehash[st->bucket].twchain) {
25338 + vxdprintk(VXD_CBIT(net, 6),
25339 + "tw: %p [#%d] (from %d)",
25340 + tw, tw->tw_nid, nx_current_nid());
25341 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25343 if (tw->tw_family != st->family ||
25344 !net_eq(twsk_net(tw), net)) {
25346 @@ -2141,7 +2161,9 @@ static void *established_get_next(struct
25350 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
25351 + while (tw && (tw->tw_family != st->family ||
25352 + !net_eq(twsk_net(tw), net) ||
25353 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
25357 @@ -2165,6 +2187,11 @@ get_tw:
25358 sk = sk_nulls_next(sk);
25360 sk_nulls_for_each_from(sk, node) {
25361 + vxdprintk(VXD_CBIT(net, 6),
25362 + "sk,egn: %p [#%d] (from %d)",
25363 + sk, sk->sk_nid, nx_current_nid());
25364 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25366 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
25369 @@ -2374,9 +2401,9 @@ static void get_openreq4(struct sock *sk
25370 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25371 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
25374 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
25375 ntohs(inet_sk(sk)->inet_sport),
25377 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
25378 ntohs(ireq->rmt_port),
25380 0, 0, /* could print option size, but that is af dependent. */
25381 diff -NurpP --minimal linux-3.0-rc5/net/ipv4/tcp_minisocks.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/tcp_minisocks.c
25382 --- linux-3.0-rc5/net/ipv4/tcp_minisocks.c 2011-03-15 18:07:45.000000000 +0100
25383 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/tcp_minisocks.c 2011-06-10 22:11:24.000000000 +0200
25385 #include <linux/slab.h>
25386 #include <linux/sysctl.h>
25387 #include <linux/workqueue.h>
25388 +#include <linux/vs_limit.h>
25389 +#include <linux/vs_socket.h>
25390 +#include <linux/vs_context.h>
25391 #include <net/tcp.h>
25392 #include <net/inet_common.h>
25393 #include <net/xfrm.h>
25394 @@ -335,6 +338,11 @@ void tcp_time_wait(struct sock *sk, int
25395 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25396 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25398 + tw->tw_xid = sk->sk_xid;
25399 + tw->tw_vx_info = NULL;
25400 + tw->tw_nid = sk->sk_nid;
25401 + tw->tw_nx_info = NULL;
25403 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
25404 if (tw->tw_family == PF_INET6) {
25405 struct ipv6_pinfo *np = inet6_sk(sk);
25406 diff -NurpP --minimal linux-3.0-rc5/net/ipv4/udp.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/udp.c
25407 --- linux-3.0-rc5/net/ipv4/udp.c 2011-07-01 11:14:26.000000000 +0200
25408 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv4/udp.c 2011-06-10 22:11:24.000000000 +0200
25409 @@ -296,14 +296,7 @@ fail:
25411 EXPORT_SYMBOL(udp_lib_get_port);
25413 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25415 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25417 - return (!ipv6_only_sock(sk2) &&
25418 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25419 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25421 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25423 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25425 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
25426 if (inet->inet_rcv_saddr != daddr)
25430 + /* block non nx_info ips */
25431 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25432 + daddr, NXA_MASK_BIND))
25435 if (inet->inet_daddr) {
25436 if (inet->inet_daddr != saddr)
25437 @@ -441,6 +439,7 @@ exact_match:
25442 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25443 * harder than this. -DaveM
25445 @@ -486,6 +485,11 @@ begin:
25446 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25447 score = compute_score(sk, net, saddr, hnum, sport,
25448 daddr, dport, dif);
25449 + /* FIXME: disabled?
25450 + if (score == 9) {
25454 if (score > badness) {
25457 @@ -499,6 +503,7 @@ begin:
25458 if (get_nulls_value(node) != slot)
25463 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
25465 @@ -508,6 +513,7 @@ begin:
25473 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
25474 udp_sk(s)->udp_port_hash != hnum ||
25475 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25476 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25477 - (inet->inet_rcv_saddr &&
25478 - inet->inet_rcv_saddr != loc_addr) ||
25479 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25480 ipv6_only_sock(s) ||
25481 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25483 @@ -1226,7 +1231,8 @@ try_again:
25485 sin->sin_family = AF_INET;
25486 sin->sin_port = udp_hdr(skb)->source;
25487 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25488 + sin->sin_addr.s_addr = nx_map_sock_lback(
25489 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25490 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25492 if (inet->cmsg_flags)
25493 @@ -1967,6 +1973,8 @@ static struct sock *udp_get_first(struct
25494 sk_nulls_for_each(sk, node, &hslot->head) {
25495 if (!net_eq(sock_net(sk), net))
25497 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25499 if (sk->sk_family == state->family)
25502 @@ -1984,7 +1992,9 @@ static struct sock *udp_get_next(struct
25505 sk = sk_nulls_next(sk);
25506 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25507 + } while (sk && (!net_eq(sock_net(sk), net) ||
25508 + sk->sk_family != state->family ||
25509 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25512 if (state->bucket <= state->udp_table->mask)
25513 diff -NurpP --minimal linux-3.0-rc5/net/ipv6/Kconfig linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/Kconfig
25514 --- linux-3.0-rc5/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
25515 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/Kconfig 2011-06-10 22:11:24.000000000 +0200
25518 # IPv6 as module will cause a CRASH if you try to unload it
25520 - tristate "The IPv6 protocol"
25522 + bool "The IPv6 protocol"
25525 This is complemental support for the IP version 6.
25526 You will still be able to do traditional IPv4 networking as well.
25527 diff -NurpP --minimal linux-3.0-rc5/net/ipv6/addrconf.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/addrconf.c
25528 --- linux-3.0-rc5/net/ipv6/addrconf.c 2011-07-01 11:14:26.000000000 +0200
25529 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/addrconf.c 2011-06-10 22:11:24.000000000 +0200
25532 #include <linux/proc_fs.h>
25533 #include <linux/seq_file.h>
25534 +#include <linux/vs_network.h>
25535 +#include <linux/vs_inet6.h>
25537 /* Set to 3 to get tracing... */
25538 #define ACONF_DEBUG 2
25539 @@ -1108,7 +1110,7 @@ out:
25541 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25542 const struct in6_addr *daddr, unsigned int prefs,
25543 - struct in6_addr *saddr)
25544 + struct in6_addr *saddr, struct nx_info *nxi)
25546 struct ipv6_saddr_score scores[2],
25547 *score = &scores[0], *hiscore = &scores[1];
25548 @@ -1180,6 +1182,8 @@ int ipv6_dev_get_saddr(struct net *net,
25552 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25556 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25557 @@ -3048,7 +3052,10 @@ static void if6_seq_stop(struct seq_file
25558 static int if6_seq_show(struct seq_file *seq, void *v)
25560 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25561 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25563 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25564 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25565 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25567 ifp->idev->dev->ifindex,
25569 @@ -3554,6 +3561,11 @@ static int in6_dump_addrs(struct inet6_d
25570 struct ifacaddr6 *ifaca;
25572 int ip_idx = *p_ip_idx;
25573 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25575 + /* disable ipv6 on non v6 guests */
25576 + if (nxi && !nx_info_has_v6(nxi))
25579 read_lock_bh(&idev->lock);
25581 @@ -3564,6 +3576,8 @@ static int in6_dump_addrs(struct inet6_d
25582 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25583 if (++ip_idx < s_ip_idx)
25585 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25587 err = inet6_fill_ifaddr(skb, ifa,
25588 NETLINK_CB(cb->skb).pid,
25589 cb->nlh->nlmsg_seq,
25590 @@ -3580,6 +3594,8 @@ static int in6_dump_addrs(struct inet6_d
25591 ifmca = ifmca->next, ip_idx++) {
25592 if (ip_idx < s_ip_idx)
25594 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25596 err = inet6_fill_ifmcaddr(skb, ifmca,
25597 NETLINK_CB(cb->skb).pid,
25598 cb->nlh->nlmsg_seq,
25599 @@ -3595,6 +3611,8 @@ static int in6_dump_addrs(struct inet6_d
25600 ifaca = ifaca->aca_next, ip_idx++) {
25601 if (ip_idx < s_ip_idx)
25603 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25605 err = inet6_fill_ifacaddr(skb, ifaca,
25606 NETLINK_CB(cb->skb).pid,
25607 cb->nlh->nlmsg_seq,
25608 @@ -3980,6 +3998,11 @@ static int inet6_dump_ifinfo(struct sk_b
25609 struct inet6_dev *idev;
25610 struct hlist_head *head;
25611 struct hlist_node *node;
25612 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25614 + /* FIXME: maybe disable ipv6 on non v6 guests?
25615 + if (skb->sk && skb->sk->sk_vx_info)
25616 + return skb->len; */
25619 s_idx = cb->args[1];
25620 @@ -3991,6 +4014,8 @@ static int inet6_dump_ifinfo(struct sk_b
25621 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25624 + if (!v6_dev_in_nx_info(dev, nxi))
25626 idev = __in6_dev_get(dev);
25629 diff -NurpP --minimal linux-3.0-rc5/net/ipv6/af_inet6.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/af_inet6.c
25630 --- linux-3.0-rc5/net/ipv6/af_inet6.c 2011-07-01 11:14:26.000000000 +0200
25631 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/af_inet6.c 2011-06-15 02:44:10.000000000 +0200
25633 #include <linux/netdevice.h>
25634 #include <linux/icmpv6.h>
25635 #include <linux/netfilter_ipv6.h>
25636 +#include <linux/vs_inet.h>
25637 +#include <linux/vs_inet6.h>
25639 #include <net/ip.h>
25640 #include <net/ipv6.h>
25641 @@ -160,9 +162,12 @@ lookup_protocol:
25645 + if ((protocol == IPPROTO_ICMPV6) &&
25646 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25648 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25649 goto out_rcu_unlock;
25652 sock->ops = answer->ops;
25653 answer_prot = answer->prot;
25654 answer_no_check = answer->no_check;
25655 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25656 struct inet_sock *inet = inet_sk(sk);
25657 struct ipv6_pinfo *np = inet6_sk(sk);
25658 struct net *net = sock_net(sk);
25659 + struct nx_v6_sock_addr nsa;
25661 unsigned short snum;
25663 @@ -276,6 +282,10 @@ int inet6_bind(struct socket *sock, stru
25664 if (addr->sin6_family != AF_INET6)
25667 + err = v6_map_sock_addr(inet, addr, &nsa);
25671 addr_type = ipv6_addr_type(&addr->sin6_addr);
25672 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25674 @@ -307,6 +317,7 @@ int inet6_bind(struct socket *sock, stru
25675 /* Reproduce AF_INET checks to make the bindings consistent */
25676 v4addr = addr->sin6_addr.s6_addr32[3];
25677 chk_addr_ret = inet_addr_type(net, v4addr);
25679 if (!sysctl_ip_nonlocal_bind &&
25680 !(inet->freebind || inet->transparent) &&
25681 v4addr != htonl(INADDR_ANY) &&
25682 @@ -316,6 +327,10 @@ int inet6_bind(struct socket *sock, stru
25683 err = -EADDRNOTAVAIL;
25686 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25687 + err = -EADDRNOTAVAIL;
25691 if (addr_type != IPV6_ADDR_ANY) {
25692 struct net_device *dev = NULL;
25693 @@ -342,6 +357,11 @@ int inet6_bind(struct socket *sock, stru
25697 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25698 + err = -EADDRNOTAVAIL;
25702 /* ipv4 addr of the socket is invalid. Only the
25703 * unspecified and mapped address have a v4 equivalent.
25705 @@ -358,6 +378,9 @@ int inet6_bind(struct socket *sock, stru
25709 + /* what's that for? */
25710 + v6_set_sock_addr(inet, &nsa);
25712 inet->inet_rcv_saddr = v4addr;
25713 inet->inet_saddr = v4addr;
25715 @@ -459,9 +482,11 @@ int inet6_getname(struct socket *sock, s
25717 sin->sin6_port = inet->inet_dport;
25718 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
25719 + /* FIXME: remap lback? */
25721 sin->sin6_flowinfo = np->flow_label;
25723 + /* FIXME: remap lback? */
25724 if (ipv6_addr_any(&np->rcv_saddr))
25725 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
25727 diff -NurpP --minimal linux-3.0-rc5/net/ipv6/fib6_rules.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/fib6_rules.c
25728 --- linux-3.0-rc5/net/ipv6/fib6_rules.c 2011-05-22 16:18:00.000000000 +0200
25729 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/fib6_rules.c 2011-06-10 22:11:24.000000000 +0200
25730 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
25731 ip6_dst_idev(&rt->dst)->dev,
25733 rt6_flags2srcprefs(flags),
25737 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25739 diff -NurpP --minimal linux-3.0-rc5/net/ipv6/inet6_hashtables.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/inet6_hashtables.c
25740 --- linux-3.0-rc5/net/ipv6/inet6_hashtables.c 2011-05-22 16:18:00.000000000 +0200
25741 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/inet6_hashtables.c 2011-06-10 22:11:24.000000000 +0200
25744 #include <linux/module.h>
25745 #include <linux/random.h>
25746 +#include <linux/vs_inet6.h>
25748 #include <net/inet_connection_sock.h>
25749 #include <net/inet_hashtables.h>
25750 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
25751 unsigned int slot = hash & hashinfo->ehash_mask;
25752 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25757 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25758 @@ -94,7 +94,7 @@ begin:
25766 if (get_nulls_value(node) != slot)
25767 @@ -140,6 +140,9 @@ static inline int compute_score(struct s
25768 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25772 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25775 if (sk->sk_bound_dev_if) {
25776 if (sk->sk_bound_dev_if != dif)
25777 diff -NurpP --minimal linux-3.0-rc5/net/ipv6/ip6_output.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/ip6_output.c
25778 --- linux-3.0-rc5/net/ipv6/ip6_output.c 2011-07-01 11:14:26.000000000 +0200
25779 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/ip6_output.c 2011-06-16 14:16:51.000000000 +0200
25780 @@ -933,7 +933,8 @@ static int ip6_dst_lookup_tail(struct so
25781 struct rt6_info *rt = (struct rt6_info *) *dst;
25782 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25783 sk ? inet6_sk(sk)->srcprefs : 0,
25786 + sk ? sk->sk_nx_info : NULL);
25788 goto out_err_release;
25790 diff -NurpP --minimal linux-3.0-rc5/net/ipv6/ndisc.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/ndisc.c
25791 --- linux-3.0-rc5/net/ipv6/ndisc.c 2011-07-01 11:14:26.000000000 +0200
25792 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/ndisc.c 2011-06-10 22:11:24.000000000 +0200
25793 @@ -597,7 +597,7 @@ static void ndisc_send_na(struct net_dev
25795 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25796 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25800 src_addr = &tmpaddr;
25802 diff -NurpP --minimal linux-3.0-rc5/net/ipv6/raw.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/raw.c
25803 --- linux-3.0-rc5/net/ipv6/raw.c 2011-07-01 11:14:26.000000000 +0200
25804 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/raw.c 2011-06-10 22:11:24.000000000 +0200
25806 #include <linux/icmpv6.h>
25807 #include <linux/netfilter.h>
25808 #include <linux/netfilter_ipv6.h>
25809 +#include <linux/vs_inet6.h>
25810 #include <linux/skbuff.h>
25811 #include <linux/compat.h>
25812 #include <asm/uaccess.h>
25813 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
25817 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25818 + err = -EADDRNOTAVAIL;
25824 /* ipv4 addr of the socket is invalid. Only the
25825 * unspecified and mapped address have a v4 equivalent.
25827 diff -NurpP --minimal linux-3.0-rc5/net/ipv6/route.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/route.c
25828 --- linux-3.0-rc5/net/ipv6/route.c 2011-07-01 11:14:26.000000000 +0200
25829 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/route.c 2011-06-16 14:16:51.000000000 +0200
25831 #include <net/xfrm.h>
25832 #include <net/netevent.h>
25833 #include <net/netlink.h>
25834 +#include <linux/vs_inet6.h>
25836 #include <asm/uaccess.h>
25838 @@ -2057,15 +2058,17 @@ int ip6_route_get_saddr(struct net *net,
25839 struct rt6_info *rt,
25840 const struct in6_addr *daddr,
25841 unsigned int prefs,
25842 - struct in6_addr *saddr)
25843 + struct in6_addr *saddr,
25844 + struct nx_info *nxi)
25846 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25848 - if (rt->rt6i_prefsrc.plen)
25849 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25850 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25851 ipv6_addr_copy(saddr, &rt->rt6i_prefsrc.addr);
25853 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25854 - daddr, prefs, saddr);
25855 + daddr, prefs, saddr, nxi);
25859 @@ -2394,7 +2397,8 @@ static int rt6_fill_node(struct net *net
25860 NLA_PUT_U32(skb, RTA_IIF, iif);
25862 struct in6_addr saddr_buf;
25863 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0)
25864 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25865 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
25866 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
25869 diff -NurpP --minimal linux-3.0-rc5/net/ipv6/tcp_ipv6.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/tcp_ipv6.c
25870 --- linux-3.0-rc5/net/ipv6/tcp_ipv6.c 2011-07-01 11:14:26.000000000 +0200
25871 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/tcp_ipv6.c 2011-06-22 12:39:16.000000000 +0200
25874 #include <linux/crypto.h>
25875 #include <linux/scatterlist.h>
25876 +#include <linux/vs_inet6.h>
25878 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25879 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25880 @@ -161,8 +162,15 @@ static int tcp_v6_connect(struct sock *s
25881 * connect() to INADDR_ANY means loopback (BSD'ism).
25884 - if(ipv6_addr_any(&usin->sin6_addr))
25885 - usin->sin6_addr.s6_addr[15] = 0x1;
25886 + if(ipv6_addr_any(&usin->sin6_addr)) {
25887 + struct nx_info *nxi = sk->sk_nx_info;
25889 + if (nxi && nx_info_has_v6(nxi))
25890 + /* FIXME: remap lback? */
25891 + usin->sin6_addr = nxi->v6.ip;
25893 + usin->sin6_addr.s6_addr[15] = 0x1;
25896 addr_type = ipv6_addr_type(&usin->sin6_addr);
25898 diff -NurpP --minimal linux-3.0-rc5/net/ipv6/udp.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/udp.c
25899 --- linux-3.0-rc5/net/ipv6/udp.c 2011-07-01 11:14:26.000000000 +0200
25900 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/udp.c 2011-06-10 22:11:24.000000000 +0200
25901 @@ -45,41 +45,67 @@
25902 #include <net/tcp_states.h>
25903 #include <net/ip6_checksum.h>
25904 #include <net/xfrm.h>
25905 +#include <linux/vs_inet6.h>
25907 #include <linux/proc_fs.h>
25908 #include <linux/seq_file.h>
25909 #include "udp_impl.h"
25911 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25912 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25914 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25915 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25916 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25917 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25918 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25919 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25920 - int sk_ipv6only = ipv6_only_sock(sk);
25921 + int sk1_ipv6only = ipv6_only_sock(sk1);
25922 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25923 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25924 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25925 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25927 /* if both are mapped, treat as IPv4 */
25928 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25929 - return (!sk2_ipv6only &&
25930 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25931 + if (!sk2_ipv6only &&
25932 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25933 - sk1_rcv_saddr == sk2_rcv_saddr));
25934 + sk1_rcv_saddr == sk2_rcv_saddr))
25940 if (addr_type2 == IPV6_ADDR_ANY &&
25941 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25945 if (addr_type == IPV6_ADDR_ANY &&
25946 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25948 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25951 if (sk2_rcv_saddr6 &&
25952 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25954 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
25960 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
25961 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25962 + if (!sk2_rcv_saddr)
25963 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
25964 + if (!sk1_rcv_saddr)
25965 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
25968 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25969 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25970 + else if (addr_type2 == IPV6_ADDR_ANY)
25971 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
25972 + else if (addr_type == IPV6_ADDR_ANY) {
25973 + if (addr_type2 == IPV6_ADDR_MAPPED)
25974 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25976 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
25981 static unsigned int udp6_portaddr_hash(struct net *net,
25982 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
25983 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25987 + /* block non nx_info ips */
25988 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25991 if (!ipv6_addr_any(&np->daddr)) {
25992 if (!ipv6_addr_equal(&np->daddr, saddr))
25993 diff -NurpP --minimal linux-3.0-rc5/net/ipv6/xfrm6_policy.c linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/xfrm6_policy.c
25994 --- linux-3.0-rc5/net/ipv6/xfrm6_policy.c 2011-07-01 11:14:26.000000000 +0200
25995 +++ linux-3.0-rc5-vs2.3.1-pre3/net/ipv6/xfrm6_policy.c 2011-06-10 22:11:24.000000000 +0200
25996 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
25997 dev = ip6_dst_idev(dst)->dev;
25998 ipv6_dev_get_saddr(dev_net(dev), dev,
25999 (struct in6_addr *)&daddr->a6, 0,
26000 - (struct in6_addr *)&saddr->a6);
26001 + (struct in6_addr *)&saddr->a6, NULL);
26005 diff -NurpP --minimal linux-3.0-rc5/netfilter/ipvs/ip_vs_xmit.c linux-3.0-rc5-vs2.3.1-pre3/net/netfilter/ipvs/ip_vs_xmit.c
26006 --- linux-3.0-rc5/net/netfilter/ipvs/ip_vs_xmit.c
26007 +++ linux-3.0-rc5-vs2.3.1-pre3/net/netfilter/ipvs/ip_vs_xmit.c
26008 @@ -213,7 +213,7 @@ __ip_vs_route_output_v6(struct net *net,
26010 if (ipv6_addr_any(&fl6.saddr) &&
26011 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
26012 - &fl6.daddr, 0, &fl6.saddr) < 0)
26013 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
26016 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
26017 diff -NurpP --minimal linux-3.0-rc5/net/netlink/af_netlink.c linux-3.0-rc5-vs2.3.1-pre3/net/netlink/af_netlink.c
26018 --- linux-3.0-rc5/net/netlink/af_netlink.c 2011-07-01 11:14:27.000000000 +0200
26019 +++ linux-3.0-rc5-vs2.3.1-pre3/net/netlink/af_netlink.c 2011-06-10 22:11:24.000000000 +0200
26021 #include <linux/types.h>
26022 #include <linux/audit.h>
26023 #include <linux/mutex.h>
26024 +#include <linux/vs_context.h>
26025 +#include <linux/vs_network.h>
26026 +#include <linux/vs_limit.h>
26028 #include <net/net_namespace.h>
26029 #include <net/sock.h>
26030 @@ -1907,6 +1910,8 @@ static struct sock *netlink_seq_socket_i
26031 sk_for_each(s, node, &hash->table[j]) {
26032 if (sock_net(s) != seq_file_net(seq))
26034 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26038 iter->hash_idx = j;
26039 @@ -1941,7 +1946,8 @@ static void *netlink_seq_next(struct seq
26043 - } while (s && sock_net(s) != seq_file_net(seq));
26044 + } while (s && (sock_net(s) != seq_file_net(seq) ||
26045 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
26049 @@ -1953,7 +1959,8 @@ static void *netlink_seq_next(struct seq
26051 for (; j <= hash->mask; j++) {
26052 s = sk_head(&hash->table[j]);
26053 - while (s && sock_net(s) != seq_file_net(seq))
26054 + while (s && (sock_net(s) != seq_file_net(seq) ||
26055 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
26059 diff -NurpP --minimal linux-3.0-rc5/net/socket.c linux-3.0-rc5-vs2.3.1-pre3/net/socket.c
26060 --- linux-3.0-rc5/net/socket.c 2011-07-01 11:14:27.000000000 +0200
26061 +++ linux-3.0-rc5-vs2.3.1-pre3/net/socket.c 2011-06-16 14:16:51.000000000 +0200
26064 #include <net/sock.h>
26065 #include <linux/netfilter.h>
26066 +#include <linux/vs_base.h>
26067 +#include <linux/vs_socket.h>
26068 +#include <linux/vs_inet.h>
26069 +#include <linux/vs_inet6.h>
26071 #include <linux/if_tun.h>
26072 #include <linux/ipv6_route.h>
26073 @@ -546,6 +550,7 @@ static inline int __sock_sendmsg_nosec(s
26074 struct msghdr *msg, size_t size)
26076 struct sock_iocb *si = kiocb_to_siocb(iocb);
26079 sock_update_classid(sock->sk);
26081 @@ -554,7 +559,22 @@ static inline int __sock_sendmsg_nosec(s
26085 - return sock->ops->sendmsg(iocb, sock, msg, size);
26086 + len = sock->ops->sendmsg(iocb, sock, msg, size);
26089 + vx_sock_send(sock->sk, size);
26091 + vx_sock_fail(sock->sk, size);
26093 + vxdprintk(VXD_CBIT(net, 7),
26094 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26096 + (sock->sk)?sock->sk->sk_nx_info:0,
26097 + (sock->sk)?sock->sk->sk_vx_info:0,
26098 + (sock->sk)?sock->sk->sk_xid:0,
26099 + (sock->sk)?sock->sk->sk_nid:0,
26100 + (unsigned int)size, len);
26104 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
26105 @@ -694,6 +714,7 @@ static inline int __sock_recvmsg_nosec(s
26106 struct msghdr *msg, size_t size, int flags)
26108 struct sock_iocb *si = kiocb_to_siocb(iocb);
26111 sock_update_classid(sock->sk);
26113 @@ -703,7 +724,18 @@ static inline int __sock_recvmsg_nosec(s
26117 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
26118 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
26119 + if ((len >= 0) && sock->sk)
26120 + vx_sock_recv(sock->sk, len);
26121 + vxdprintk(VXD_CBIT(net, 7),
26122 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26124 + (sock->sk)?sock->sk->sk_nx_info:0,
26125 + (sock->sk)?sock->sk->sk_vx_info:0,
26126 + (sock->sk)?sock->sk->sk_xid:0,
26127 + (sock->sk)?sock->sk->sk_nid:0,
26128 + (unsigned int)size, len);
26132 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
26133 @@ -1188,6 +1220,13 @@ int __sock_create(struct net *net, int f
26134 if (type < 0 || type >= SOCK_MAX)
26137 + if (!nx_check(0, VS_ADMIN)) {
26138 + if (family == PF_INET && !current_nx_info_has_v4())
26139 + return -EAFNOSUPPORT;
26140 + if (family == PF_INET6 && !current_nx_info_has_v6())
26141 + return -EAFNOSUPPORT;
26146 This uglymoron is moved from INET layer to here to avoid
26147 @@ -1323,6 +1362,7 @@ SYSCALL_DEFINE3(socket, int, family, int
26151 + set_bit(SOCK_USER_SOCKET, &sock->flags);
26152 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
26155 @@ -1364,10 +1404,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
26156 err = sock_create(family, type, protocol, &sock1);
26159 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
26161 err = sock_create(family, type, protocol, &sock2);
26163 goto out_release_1;
26164 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
26166 err = sock1->ops->socketpair(sock1, sock2);
26168 diff -NurpP --minimal linux-3.0-rc5/net/sunrpc/auth.c linux-3.0-rc5-vs2.3.1-pre3/net/sunrpc/auth.c
26169 --- linux-3.0-rc5/net/sunrpc/auth.c 2011-07-01 11:14:27.000000000 +0200
26170 +++ linux-3.0-rc5-vs2.3.1-pre3/net/sunrpc/auth.c 2011-06-10 22:11:24.000000000 +0200
26172 #include <linux/hash.h>
26173 #include <linux/sunrpc/clnt.h>
26174 #include <linux/spinlock.h>
26175 +#include <linux/vs_tag.h>
26178 # define RPCDBG_FACILITY RPCDBG_AUTH
26179 @@ -427,6 +428,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
26180 memset(&acred, 0, sizeof(acred));
26181 acred.uid = cred->fsuid;
26182 acred.gid = cred->fsgid;
26183 + acred.tag = dx_current_tag();
26184 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
26186 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
26187 @@ -467,6 +469,7 @@ rpcauth_bind_root_cred(struct rpc_task *
26188 struct auth_cred acred = {
26191 + .tag = dx_current_tag(),
26194 dprintk("RPC: %5u looking up %s cred\n",
26195 diff -NurpP --minimal linux-3.0-rc5/net/sunrpc/auth_unix.c linux-3.0-rc5-vs2.3.1-pre3/net/sunrpc/auth_unix.c
26196 --- linux-3.0-rc5/net/sunrpc/auth_unix.c 2010-10-21 13:08:01.000000000 +0200
26197 +++ linux-3.0-rc5-vs2.3.1-pre3/net/sunrpc/auth_unix.c 2011-06-10 22:11:24.000000000 +0200
26198 @@ -12,12 +12,14 @@
26199 #include <linux/module.h>
26200 #include <linux/sunrpc/clnt.h>
26201 #include <linux/sunrpc/auth.h>
26202 +#include <linux/vs_tag.h>
26204 #define NFS_NGROUPS 16
26207 struct rpc_cred uc_base;
26210 gid_t uc_gids[NFS_NGROUPS];
26212 #define uc_uid uc_base.cr_uid
26213 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
26214 groups = NFS_NGROUPS;
26216 cred->uc_gid = acred->gid;
26217 + cred->uc_tag = acred->tag;
26218 for (i = 0; i < groups; i++)
26219 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
26220 if (i < NFS_NGROUPS)
26221 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
26225 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
26226 + if (cred->uc_uid != acred->uid ||
26227 + cred->uc_gid != acred->gid ||
26228 + cred->uc_tag != acred->tag)
26231 if (acred->group_info != NULL)
26232 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
26233 struct rpc_clnt *clnt = task->tk_client;
26234 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
26235 __be32 *base, *hold;
26239 *p++ = htonl(RPC_AUTH_UNIX);
26241 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
26242 * Copy the UTS nodename captured when the client was created.
26244 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
26245 + tag = task->tk_client->cl_tag;
26247 - *p++ = htonl((u32) cred->uc_uid);
26248 - *p++ = htonl((u32) cred->uc_gid);
26249 + *p++ = htonl((u32) TAGINO_UID(tag,
26250 + cred->uc_uid, cred->uc_tag));
26251 + *p++ = htonl((u32) TAGINO_GID(tag,
26252 + cred->uc_gid, cred->uc_tag));
26254 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
26255 *p++ = htonl((u32) cred->uc_gids[i]);
26256 diff -NurpP --minimal linux-3.0-rc5/net/sunrpc/clnt.c linux-3.0-rc5-vs2.3.1-pre3/net/sunrpc/clnt.c
26257 --- linux-3.0-rc5/net/sunrpc/clnt.c 2011-07-01 11:14:27.000000000 +0200
26258 +++ linux-3.0-rc5-vs2.3.1-pre3/net/sunrpc/clnt.c 2011-07-01 11:35:35.000000000 +0200
26260 #include <linux/in.h>
26261 #include <linux/in6.h>
26262 #include <linux/un.h>
26263 +#include <linux/vs_cvirt.h>
26265 #include <linux/sunrpc/clnt.h>
26266 #include <linux/sunrpc/rpc_pipe_fs.h>
26267 @@ -362,6 +363,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
26268 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
26269 clnt->cl_chatty = 1;
26271 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
26272 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
26273 + clnt->cl_tag = 1; */
26276 EXPORT_SYMBOL_GPL(rpc_create);
26277 diff -NurpP --minimal linux-3.0-rc5/net/unix/af_unix.c linux-3.0-rc5-vs2.3.1-pre3/net/unix/af_unix.c
26278 --- linux-3.0-rc5/net/unix/af_unix.c 2011-07-01 11:14:27.000000000 +0200
26279 +++ linux-3.0-rc5-vs2.3.1-pre3/net/unix/af_unix.c 2011-06-10 22:11:24.000000000 +0200
26280 @@ -114,6 +114,8 @@
26281 #include <linux/mount.h>
26282 #include <net/checksum.h>
26283 #include <linux/security.h>
26284 +#include <linux/vs_context.h>
26285 +#include <linux/vs_limit.h>
26287 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
26288 static DEFINE_SPINLOCK(unix_table_lock);
26289 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
26290 if (!net_eq(sock_net(s), net))
26293 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26295 if (u->addr->len == len &&
26296 !memcmp(u->addr->name, sunname, len))
26298 @@ -2208,6 +2212,8 @@ static struct sock *unix_seq_idx(struct
26299 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
26300 if (sock_net(s) != seq_file_net(seq))
26302 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26307 @@ -2232,7 +2238,8 @@ static void *unix_seq_next(struct seq_fi
26308 sk = first_unix_socket(&iter->i);
26310 sk = next_unix_socket(&iter->i, sk);
26311 - while (sk && (sock_net(sk) != seq_file_net(seq)))
26312 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
26313 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
26314 sk = next_unix_socket(&iter->i, sk);
26317 diff -NurpP --minimal linux-3.0-rc5/scripts/checksyscalls.sh linux-3.0-rc5-vs2.3.1-pre3/scripts/checksyscalls.sh
26318 --- linux-3.0-rc5/scripts/checksyscalls.sh 2011-03-15 18:07:46.000000000 +0100
26319 +++ linux-3.0-rc5-vs2.3.1-pre3/scripts/checksyscalls.sh 2011-06-10 22:11:24.000000000 +0200
26320 @@ -193,7 +193,6 @@ cat << EOF
26321 #define __IGNORE_afs_syscall
26322 #define __IGNORE_getpmsg
26323 #define __IGNORE_putpmsg
26324 -#define __IGNORE_vserver
26328 diff -NurpP --minimal linux-3.0-rc5/security/commoncap.c linux-3.0-rc5-vs2.3.1-pre3/security/commoncap.c
26329 --- linux-3.0-rc5/security/commoncap.c 2011-07-01 11:14:27.000000000 +0200
26330 +++ linux-3.0-rc5-vs2.3.1-pre3/security/commoncap.c 2011-06-16 14:16:51.000000000 +0200
26331 @@ -62,6 +62,7 @@ int cap_netlink_recv(struct sk_buff *skb
26336 EXPORT_SYMBOL(cap_netlink_recv);
26339 @@ -83,14 +84,20 @@ EXPORT_SYMBOL(cap_netlink_recv);
26340 int cap_capable(struct task_struct *tsk, const struct cred *cred,
26341 struct user_namespace *targ_ns, int cap, int audit)
26343 + struct vx_info *vxi = tsk->vx_info;
26346 /* The creator of the user namespace has all caps. */
26347 if (targ_ns != &init_user_ns && targ_ns->creator == cred->user)
26350 /* Do we have the necessary capabilities? */
26351 - if (targ_ns == cred->user->user_ns)
26352 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
26353 + if (targ_ns == cred->user->user_ns) {
26354 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26355 + cap_raised(cred->cap_effective, cap))
26357 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26360 /* Have we tried all of the parent namespaces? */
26361 if (targ_ns == &init_user_ns)
26362 @@ -611,7 +618,7 @@ int cap_inode_setxattr(struct dentry *de
26364 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26365 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26366 - !capable(CAP_SYS_ADMIN))
26367 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26371 @@ -637,7 +644,7 @@ int cap_inode_removexattr(struct dentry
26373 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26374 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26375 - !capable(CAP_SYS_ADMIN))
26376 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26380 @@ -971,3 +978,4 @@ int cap_file_mmap(struct file *file, uns
26385 diff -NurpP --minimal linux-3.0-rc5/security/selinux/hooks.c linux-3.0-rc5-vs2.3.1-pre3/security/selinux/hooks.c
26386 --- linux-3.0-rc5/security/selinux/hooks.c 2011-07-01 11:14:28.000000000 +0200
26387 +++ linux-3.0-rc5-vs2.3.1-pre3/security/selinux/hooks.c 2011-06-15 02:40:14.000000000 +0200
26389 #include <linux/dccp.h>
26390 #include <linux/quota.h>
26391 #include <linux/un.h> /* for Unix socket types */
26392 -#include <net/af_unix.h> /* for Unix socket types */
26393 #include <linux/parser.h>
26394 #include <linux/nfs_mount.h>
26395 #include <net/ipv6.h>