1 diff -NurpP --minimal linux-3.6/Documentation/vserver/debug.txt linux-3.6-vs2.3.4.3-noxfs-nocow/Documentation/vserver/debug.txt
2 --- linux-3.6/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/Documentation/vserver/debug.txt 2012-10-04 18:46:59.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.6/arch/alpha/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/alpha/Kconfig
160 --- linux-3.6/arch/alpha/Kconfig 2012-10-04 15:26:43.000000000 +0200
161 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/alpha/Kconfig 2012-10-04 18:46:59.000000000 +0200
162 @@ -664,6 +664,8 @@ config DUMMY_CONSOLE
166 +source "kernel/vserver/Kconfig"
168 source "security/Kconfig"
170 source "crypto/Kconfig"
171 diff -NurpP --minimal linux-3.6/arch/alpha/kernel/ptrace.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/alpha/kernel/ptrace.c
172 --- linux-3.6/arch/alpha/kernel/ptrace.c 2012-05-21 18:06:12.000000000 +0200
173 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/alpha/kernel/ptrace.c 2012-10-04 18:46:59.000000000 +0200
175 #include <linux/user.h>
176 #include <linux/security.h>
177 #include <linux/signal.h>
178 +#include <linux/vs_base.h>
180 #include <asm/uaccess.h>
181 #include <asm/pgtable.h>
182 diff -NurpP --minimal linux-3.6/arch/alpha/kernel/systbls.S linux-3.6-vs2.3.4.3-noxfs-nocow/arch/alpha/kernel/systbls.S
183 --- linux-3.6/arch/alpha/kernel/systbls.S 2012-10-04 15:26:43.000000000 +0200
184 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/alpha/kernel/systbls.S 2012-10-04 18:46:59.000000000 +0200
185 @@ -446,7 +446,7 @@ sys_call_table:
186 .quad sys_stat64 /* 425 */
189 - .quad sys_ni_syscall /* sys_vserver */
190 + .quad sys_vserver /* sys_vserver */
191 .quad sys_ni_syscall /* sys_mbind */
192 .quad sys_ni_syscall /* sys_get_mempolicy */
193 .quad sys_ni_syscall /* sys_set_mempolicy */
194 diff -NurpP --minimal linux-3.6/arch/alpha/kernel/traps.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/alpha/kernel/traps.c
195 --- linux-3.6/arch/alpha/kernel/traps.c 2012-05-21 18:06:12.000000000 +0200
196 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/alpha/kernel/traps.c 2012-10-04 18:46:59.000000000 +0200
197 @@ -184,7 +184,8 @@ die_if_kernel(char * str, struct pt_regs
199 printk("CPU %d ", hard_smp_processor_id());
201 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
202 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
203 + task_pid_nr(current), current->xid, str, err);
204 dik_show_regs(regs, r9_15);
205 add_taint(TAINT_DIE);
206 dik_show_trace((unsigned long *)(regs+1));
207 diff -NurpP --minimal linux-3.6/arch/arm/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/arm/Kconfig
208 --- linux-3.6/arch/arm/Kconfig 2012-10-04 15:26:43.000000000 +0200
209 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/arm/Kconfig 2012-10-04 18:46:59.000000000 +0200
210 @@ -2331,6 +2331,8 @@ source "fs/Kconfig"
212 source "arch/arm/Kconfig.debug"
214 +source "kernel/vserver/Kconfig"
216 source "security/Kconfig"
218 source "crypto/Kconfig"
219 diff -NurpP --minimal linux-3.6/arch/arm/kernel/calls.S linux-3.6-vs2.3.4.3-noxfs-nocow/arch/arm/kernel/calls.S
220 --- linux-3.6/arch/arm/kernel/calls.S 2012-10-04 15:26:43.000000000 +0200
221 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/arm/kernel/calls.S 2012-10-04 18:46:59.000000000 +0200
223 /* 310 */ CALL(sys_request_key)
225 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
226 -/* vserver */ CALL(sys_ni_syscall)
229 /* 315 */ CALL(sys_ioprio_get)
230 CALL(sys_inotify_init)
231 diff -NurpP --minimal linux-3.6/arch/arm/kernel/process.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/arm/kernel/process.c
232 --- linux-3.6/arch/arm/kernel/process.c 2012-10-04 15:26:43.000000000 +0200
233 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/arm/kernel/process.c 2012-10-04 18:46:59.000000000 +0200
234 @@ -337,7 +337,8 @@ void __show_regs(struct pt_regs *regs)
235 void show_regs(struct pt_regs * regs)
238 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
239 + printk("Pid: %d[#%u], comm: %20s\n",
240 + task_pid_nr(current), current->xid, current->comm);
244 diff -NurpP --minimal linux-3.6/arch/arm/kernel/traps.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/arm/kernel/traps.c
245 --- linux-3.6/arch/arm/kernel/traps.c 2012-10-04 15:26:44.000000000 +0200
246 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/arm/kernel/traps.c 2012-10-04 19:03:56.000000000 +0200
247 @@ -249,8 +249,8 @@ static int __die(const char *str, int er
251 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
252 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), end_of_stack(tsk));
253 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
254 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, end_of_stack(tsk));
256 if (!user_mode(regs) || in_interrupt()) {
257 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
258 diff -NurpP --minimal linux-3.6/arch/cris/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/cris/Kconfig
259 --- linux-3.6/arch/cris/Kconfig 2012-10-04 15:26:51.000000000 +0200
260 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/cris/Kconfig 2012-10-04 18:46:59.000000000 +0200
261 @@ -673,6 +673,8 @@ source "drivers/staging/Kconfig"
263 source "arch/cris/Kconfig.debug"
265 +source "kernel/vserver/Kconfig"
267 source "security/Kconfig"
269 source "crypto/Kconfig"
270 diff -NurpP --minimal linux-3.6/arch/frv/kernel/kernel_thread.S linux-3.6-vs2.3.4.3-noxfs-nocow/arch/frv/kernel/kernel_thread.S
271 --- linux-3.6/arch/frv/kernel/kernel_thread.S 2012-10-04 15:26:51.000000000 +0200
272 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/frv/kernel/kernel_thread.S 2012-10-04 18:46:59.000000000 +0200
273 @@ -37,7 +37,7 @@ kernel_thread:
275 # start by forking the current process, but with shared VM
276 setlos.p #__NR_clone,gr7 ; syscall number
277 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
278 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
279 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
281 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
282 diff -NurpP --minimal linux-3.6/arch/h8300/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/h8300/Kconfig
283 --- linux-3.6/arch/h8300/Kconfig 2012-10-04 15:26:51.000000000 +0200
284 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/h8300/Kconfig 2012-10-04 18:46:59.000000000 +0200
285 @@ -215,6 +215,8 @@ source "fs/Kconfig"
287 source "arch/h8300/Kconfig.debug"
289 +source "kernel/vserver/Kconfig"
291 source "security/Kconfig"
293 source "crypto/Kconfig"
294 diff -NurpP --minimal linux-3.6/arch/ia64/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/ia64/Kconfig
295 --- linux-3.6/arch/ia64/Kconfig 2012-10-04 15:26:51.000000000 +0200
296 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/ia64/Kconfig 2012-10-04 18:46:59.000000000 +0200
297 @@ -652,6 +652,8 @@ source "fs/Kconfig"
299 source "arch/ia64/Kconfig.debug"
301 +source "kernel/vserver/Kconfig"
303 source "security/Kconfig"
305 source "crypto/Kconfig"
306 diff -NurpP --minimal linux-3.6/arch/ia64/kernel/entry.S linux-3.6-vs2.3.4.3-noxfs-nocow/arch/ia64/kernel/entry.S
307 --- linux-3.6/arch/ia64/kernel/entry.S 2012-03-19 19:46:40.000000000 +0100
308 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/ia64/kernel/entry.S 2012-10-04 18:46:59.000000000 +0200
309 @@ -1714,7 +1714,7 @@ sys_call_table:
311 data8 sys_mq_getsetattr
313 - data8 sys_ni_syscall // reserved for vserver
315 data8 sys_waitid // 1270
317 data8 sys_request_key
318 diff -NurpP --minimal linux-3.6/arch/ia64/kernel/process.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/ia64/kernel/process.c
319 --- linux-3.6/arch/ia64/kernel/process.c 2012-07-22 23:38:51.000000000 +0200
320 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/ia64/kernel/process.c 2012-10-04 18:46:59.000000000 +0200
321 @@ -110,8 +110,8 @@ show_regs (struct pt_regs *regs)
322 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
325 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
326 - smp_processor_id(), current->comm);
327 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
328 + current->xid, smp_processor_id(), current->comm);
329 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
330 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
331 init_utsname()->release);
332 diff -NurpP --minimal linux-3.6/arch/ia64/kernel/ptrace.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/ia64/kernel/ptrace.c
333 --- linux-3.6/arch/ia64/kernel/ptrace.c 2012-05-21 18:06:26.000000000 +0200
334 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/ia64/kernel/ptrace.c 2012-10-04 18:46:59.000000000 +0200
336 #include <linux/regset.h>
337 #include <linux/elf.h>
338 #include <linux/tracehook.h>
339 +#include <linux/vs_base.h>
341 #include <asm/pgtable.h>
342 #include <asm/processor.h>
343 diff -NurpP --minimal linux-3.6/arch/ia64/kernel/traps.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/ia64/kernel/traps.c
344 --- linux-3.6/arch/ia64/kernel/traps.c 2012-05-21 18:06:26.000000000 +0200
345 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/ia64/kernel/traps.c 2012-10-04 18:47:00.000000000 +0200
346 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
349 if (++die.lock_owner_depth < 3) {
350 - printk("%s[%d]: %s %ld [%d]\n",
351 - current->comm, task_pid_nr(current), str, err, ++die_counter);
352 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
353 + current->comm, task_pid_nr(current), current->xid,
354 + str, err, ++die_counter);
355 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
358 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
359 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
360 last.time = current_jiffies + 5 * HZ;
362 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
363 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
364 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
365 + current->comm, task_pid_nr(current), current->xid,
366 + regs->cr_iip + ia64_psr(regs)->ri, isr);
370 diff -NurpP --minimal linux-3.6/arch/m32r/kernel/traps.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/m32r/kernel/traps.c
371 --- linux-3.6/arch/m32r/kernel/traps.c 2012-05-21 18:06:26.000000000 +0200
372 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/m32r/kernel/traps.c 2012-10-04 18:47:00.000000000 +0200
373 @@ -195,8 +195,9 @@ static void show_registers(struct pt_reg
375 printk("SPI: %08lx\n", sp);
377 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
378 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
379 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
380 + current->comm, task_pid_nr(current), current->xid,
381 + 0xffff & i, 4096+(unsigned long)current);
384 * When in-kernel, we also print out the stack and code at the
385 diff -NurpP --minimal linux-3.6/arch/m68k/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/m68k/Kconfig
386 --- linux-3.6/arch/m68k/Kconfig 2012-10-04 15:26:51.000000000 +0200
387 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/m68k/Kconfig 2012-10-04 18:47:00.000000000 +0200
388 @@ -129,6 +129,8 @@ source "fs/Kconfig"
390 source "arch/m68k/Kconfig.debug"
392 +source "kernel/vserver/Kconfig"
394 source "security/Kconfig"
396 source "crypto/Kconfig"
397 diff -NurpP --minimal linux-3.6/arch/mips/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/Kconfig
398 --- linux-3.6/arch/mips/Kconfig 2012-10-04 15:26:52.000000000 +0200
399 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/Kconfig 2012-10-04 18:47:00.000000000 +0200
400 @@ -2554,6 +2554,8 @@ source "fs/Kconfig"
402 source "arch/mips/Kconfig.debug"
404 +source "kernel/vserver/Kconfig"
406 source "security/Kconfig"
408 source "crypto/Kconfig"
409 diff -NurpP --minimal linux-3.6/arch/mips/kernel/ptrace.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/kernel/ptrace.c
410 --- linux-3.6/arch/mips/kernel/ptrace.c 2012-07-22 23:38:52.000000000 +0200
411 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/kernel/ptrace.c 2012-10-04 18:47:00.000000000 +0200
413 #include <linux/security.h>
414 #include <linux/audit.h>
415 #include <linux/seccomp.h>
416 +#include <linux/vs_base.h>
418 #include <asm/byteorder.h>
420 @@ -262,6 +263,9 @@ long arch_ptrace(struct task_struct *chi
421 void __user *datavp = (void __user *) data;
422 unsigned long __user *datalp = (void __user *) data;
424 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
428 /* when I and D space are separate, these will need to be fixed. */
429 case PTRACE_PEEKTEXT: /* read word at location addr. */
430 diff -NurpP --minimal linux-3.6/arch/mips/kernel/scall32-o32.S linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/kernel/scall32-o32.S
431 --- linux-3.6/arch/mips/kernel/scall32-o32.S 2012-01-09 16:14:05.000000000 +0100
432 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/kernel/scall32-o32.S 2012-10-04 18:47:00.000000000 +0200
433 @@ -523,7 +523,7 @@ einval: li v0, -ENOSYS
434 sys sys_mq_timedreceive 5
435 sys sys_mq_notify 2 /* 4275 */
436 sys sys_mq_getsetattr 3
437 - sys sys_ni_syscall 0 /* sys_vserver */
440 sys sys_ni_syscall 0 /* available, was setaltroot */
441 sys sys_add_key 5 /* 4280 */
442 diff -NurpP --minimal linux-3.6/arch/mips/kernel/scall64-64.S linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/kernel/scall64-64.S
443 --- linux-3.6/arch/mips/kernel/scall64-64.S 2012-01-09 16:14:05.000000000 +0100
444 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/kernel/scall64-64.S 2012-10-04 18:47:00.000000000 +0200
445 @@ -362,7 +362,7 @@ sys_call_table:
446 PTR sys_mq_timedreceive
448 PTR sys_mq_getsetattr /* 5235 */
449 - PTR sys_ni_syscall /* sys_vserver */
452 PTR sys_ni_syscall /* available, was setaltroot */
454 diff -NurpP --minimal linux-3.6/arch/mips/kernel/scall64-n32.S linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/kernel/scall64-n32.S
455 --- linux-3.6/arch/mips/kernel/scall64-n32.S 2012-01-09 16:14:05.000000000 +0100
456 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/kernel/scall64-n32.S 2012-10-04 18:47:00.000000000 +0200
457 @@ -361,7 +361,7 @@ EXPORT(sysn32_call_table)
458 PTR compat_sys_mq_timedreceive
459 PTR compat_sys_mq_notify
460 PTR compat_sys_mq_getsetattr
461 - PTR sys_ni_syscall /* 6240, sys_vserver */
462 + PTR sys32_vserver /* 6240 */
463 PTR compat_sys_waitid
464 PTR sys_ni_syscall /* available, was setaltroot */
466 diff -NurpP --minimal linux-3.6/arch/mips/kernel/scall64-o32.S linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/kernel/scall64-o32.S
467 --- linux-3.6/arch/mips/kernel/scall64-o32.S 2012-01-09 16:14:05.000000000 +0100
468 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/kernel/scall64-o32.S 2012-10-04 18:47:00.000000000 +0200
469 @@ -480,7 +480,7 @@ sys_call_table:
470 PTR compat_sys_mq_timedreceive
471 PTR compat_sys_mq_notify /* 4275 */
472 PTR compat_sys_mq_getsetattr
473 - PTR sys_ni_syscall /* sys_vserver */
476 PTR sys_ni_syscall /* available, was setaltroot */
477 PTR sys_add_key /* 4280 */
478 diff -NurpP --minimal linux-3.6/arch/mips/kernel/traps.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/kernel/traps.c
479 --- linux-3.6/arch/mips/kernel/traps.c 2012-10-04 15:26:53.000000000 +0200
480 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/mips/kernel/traps.c 2012-10-04 18:47:00.000000000 +0200
481 @@ -347,9 +347,10 @@ void show_registers(struct pt_regs *regs
485 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
486 - current->comm, current->pid, current_thread_info(), current,
487 - field, current_thread_info()->tp_value);
488 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
489 + current->comm, task_pid_nr(current), current->xid,
490 + current_thread_info(), current,
491 + field, current_thread_info()->tp_value);
492 if (cpu_has_userlocal) {
495 diff -NurpP --minimal linux-3.6/arch/parisc/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/parisc/Kconfig
496 --- linux-3.6/arch/parisc/Kconfig 2012-07-22 23:38:52.000000000 +0200
497 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/parisc/Kconfig 2012-10-04 18:47:00.000000000 +0200
498 @@ -281,6 +281,8 @@ source "fs/Kconfig"
500 source "arch/parisc/Kconfig.debug"
502 +source "kernel/vserver/Kconfig"
504 source "security/Kconfig"
506 source "crypto/Kconfig"
507 diff -NurpP --minimal linux-3.6/arch/parisc/kernel/syscall_table.S linux-3.6-vs2.3.4.3-noxfs-nocow/arch/parisc/kernel/syscall_table.S
508 --- linux-3.6/arch/parisc/kernel/syscall_table.S 2011-10-24 18:45:00.000000000 +0200
509 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/parisc/kernel/syscall_table.S 2012-10-04 18:47:00.000000000 +0200
511 ENTRY_COMP(mbind) /* 260 */
512 ENTRY_COMP(get_mempolicy)
513 ENTRY_COMP(set_mempolicy)
514 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
515 + ENTRY_DIFF(vserver)
517 ENTRY_SAME(request_key) /* 265 */
519 diff -NurpP --minimal linux-3.6/arch/parisc/kernel/traps.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/parisc/kernel/traps.c
520 --- linux-3.6/arch/parisc/kernel/traps.c 2012-05-21 18:06:28.000000000 +0200
521 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/parisc/kernel/traps.c 2012-10-04 18:47:00.000000000 +0200
522 @@ -235,8 +235,9 @@ void die_if_kernel(char *str, struct pt_
526 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
527 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
528 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
529 + current->comm, task_pid_nr(current), current->xid,
530 + str, err, regs->iaoq[0]);
531 #ifdef PRINT_USER_FAULTS
532 /* XXX for debugging only */
534 @@ -269,8 +270,8 @@ void die_if_kernel(char *str, struct pt_
535 pdc_console_restart();
538 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
539 - current->comm, task_pid_nr(current), str, err);
540 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
541 + current->comm, task_pid_nr(current), current->xid, str, err);
543 /* Wot's wrong wif bein' racy? */
544 if (current->thread.flags & PARISC_KERNEL_DEATH) {
545 diff -NurpP --minimal linux-3.6/arch/parisc/mm/fault.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/parisc/mm/fault.c
546 --- linux-3.6/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
547 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/parisc/mm/fault.c 2012-10-04 18:47:00.000000000 +0200
548 @@ -237,8 +237,9 @@ bad_area:
550 #ifdef PRINT_USER_FAULTS
551 printk(KERN_DEBUG "\n");
552 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
553 - task_pid_nr(tsk), tsk->comm, code, address);
554 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
555 + "command='%s' type=%lu address=0x%08lx\n",
556 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
558 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
559 vma->vm_start, vma->vm_end);
560 diff -NurpP --minimal linux-3.6/arch/powerpc/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/powerpc/Kconfig
561 --- linux-3.6/arch/powerpc/Kconfig 2012-10-04 15:26:53.000000000 +0200
562 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/powerpc/Kconfig 2012-10-04 18:47:00.000000000 +0200
563 @@ -996,6 +996,8 @@ source "lib/Kconfig"
565 source "arch/powerpc/Kconfig.debug"
567 +source "kernel/vserver/Kconfig"
569 source "security/Kconfig"
572 diff -NurpP --minimal linux-3.6/arch/powerpc/include/asm/unistd.h linux-3.6-vs2.3.4.3-noxfs-nocow/arch/powerpc/include/asm/unistd.h
573 --- linux-3.6/arch/powerpc/include/asm/unistd.h 2012-10-04 15:26:53.000000000 +0200
574 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/powerpc/include/asm/unistd.h 2012-10-04 18:47:00.000000000 +0200
577 #define __NR_rtas 255
578 #define __NR_sys_debug_setcontext 256
579 -/* Number 257 is reserved for vserver */
580 +#define __NR_vserver 257
581 #define __NR_migrate_pages 258
582 #define __NR_mbind 259
583 #define __NR_get_mempolicy 260
584 diff -NurpP --minimal linux-3.6/arch/powerpc/kernel/process.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/powerpc/kernel/process.c
585 --- linux-3.6/arch/powerpc/kernel/process.c 2012-10-04 15:26:54.000000000 +0200
586 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/powerpc/kernel/process.c 2012-10-04 18:47:00.000000000 +0200
587 @@ -661,8 +661,9 @@ void show_regs(struct pt_regs * regs)
589 printk("DAR: "REG", DSISR: %08lx\n", regs->dar, regs->dsisr);
591 - printk("TASK = %p[%d] '%s' THREAD: %p",
592 - current, task_pid_nr(current), current->comm, task_thread_info(current));
593 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
594 + current, task_pid_nr(current), current->xid,
595 + current->comm, task_thread_info(current));
598 printk(" CPU: %d", raw_smp_processor_id());
599 diff -NurpP --minimal linux-3.6/arch/powerpc/kernel/traps.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/powerpc/kernel/traps.c
600 --- linux-3.6/arch/powerpc/kernel/traps.c 2012-10-04 15:26:54.000000000 +0200
601 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/powerpc/kernel/traps.c 2012-10-04 18:47:00.000000000 +0200
602 @@ -1119,8 +1119,9 @@ void nonrecoverable_exception(struct pt_
604 void trace_syscall(struct pt_regs *regs)
606 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
607 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
608 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
609 + current, task_pid_nr(current), current->xid,
610 + regs->nip, regs->link, regs->gpr[0],
611 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
614 diff -NurpP --minimal linux-3.6/arch/s390/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/s390/Kconfig
615 --- linux-3.6/arch/s390/Kconfig 2012-10-04 15:26:54.000000000 +0200
616 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/s390/Kconfig 2012-10-04 18:47:00.000000000 +0200
617 @@ -634,6 +634,8 @@ source "fs/Kconfig"
619 source "arch/s390/Kconfig.debug"
621 +source "kernel/vserver/Kconfig"
623 source "security/Kconfig"
625 source "crypto/Kconfig"
626 diff -NurpP --minimal linux-3.6/arch/s390/include/asm/tlb.h linux-3.6-vs2.3.4.3-noxfs-nocow/arch/s390/include/asm/tlb.h
627 --- linux-3.6/arch/s390/include/asm/tlb.h 2012-07-22 23:38:59.000000000 +0200
628 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/s390/include/asm/tlb.h 2012-10-04 18:47:00.000000000 +0200
630 #include <linux/mm.h>
631 #include <linux/pagemap.h>
632 #include <linux/swap.h>
634 #include <asm/processor.h>
635 #include <asm/pgalloc.h>
636 #include <asm/tlbflush.h>
637 diff -NurpP --minimal linux-3.6/arch/s390/include/asm/unistd.h linux-3.6-vs2.3.4.3-noxfs-nocow/arch/s390/include/asm/unistd.h
638 --- linux-3.6/arch/s390/include/asm/unistd.h 2012-10-04 15:26:55.000000000 +0200
639 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/s390/include/asm/unistd.h 2012-10-04 18:47:00.000000000 +0200
641 #define __NR_clock_gettime (__NR_timer_create+6)
642 #define __NR_clock_getres (__NR_timer_create+7)
643 #define __NR_clock_nanosleep (__NR_timer_create+8)
644 -/* Number 263 is reserved for vserver */
645 +#define __NR_vserver 263
646 #define __NR_statfs64 265
647 #define __NR_fstatfs64 266
648 #define __NR_remap_file_pages 267
649 diff -NurpP --minimal linux-3.6/arch/s390/kernel/ptrace.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/s390/kernel/ptrace.c
650 --- linux-3.6/arch/s390/kernel/ptrace.c 2012-10-04 15:26:55.000000000 +0200
651 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/s390/kernel/ptrace.c 2012-10-04 18:47:00.000000000 +0200
653 #include <linux/tracehook.h>
654 #include <linux/seccomp.h>
655 #include <linux/compat.h>
656 +#include <linux/vs_base.h>
657 #include <trace/syscall.h>
658 #include <asm/segment.h>
659 #include <asm/page.h>
660 diff -NurpP --minimal linux-3.6/arch/s390/kernel/syscalls.S linux-3.6-vs2.3.4.3-noxfs-nocow/arch/s390/kernel/syscalls.S
661 --- linux-3.6/arch/s390/kernel/syscalls.S 2012-01-09 16:14:06.000000000 +0100
662 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/s390/kernel/syscalls.S 2012-10-04 18:47:00.000000000 +0200
663 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
664 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
665 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
666 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
667 -NI_SYSCALL /* reserved for vserver */
668 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
669 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
670 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
671 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
672 diff -NurpP --minimal linux-3.6/arch/sh/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/sh/Kconfig
673 --- linux-3.6/arch/sh/Kconfig 2012-10-04 15:26:55.000000000 +0200
674 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/sh/Kconfig 2012-10-04 18:47:00.000000000 +0200
675 @@ -940,6 +940,8 @@ source "fs/Kconfig"
677 source "arch/sh/Kconfig.debug"
679 +source "kernel/vserver/Kconfig"
681 source "security/Kconfig"
683 source "crypto/Kconfig"
684 diff -NurpP --minimal linux-3.6/arch/sh/kernel/irq.c linux-3.6-vs2.3.4.3-noxfs-nocow/arch/sh/kernel/irq.c
685 --- linux-3.6/arch/sh/kernel/irq.c 2012-10-04 15:26:56.000000000 +0200
686 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/sh/kernel/irq.c 2012-10-04 18:47:00.000000000 +0200
688 #include <linux/ftrace.h>
689 #include <linux/delay.h>
690 #include <linux/ratelimit.h>
691 +// #include <linux/vs_context.h>
692 #include <asm/processor.h>
693 #include <asm/machvec.h>
694 #include <asm/uaccess.h>
695 diff -NurpP --minimal linux-3.6/arch/sparc/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/sparc/Kconfig
696 --- linux-3.6/arch/sparc/Kconfig 2012-10-04 15:26:58.000000000 +0200
697 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/sparc/Kconfig 2012-10-04 18:47:00.000000000 +0200
698 @@ -593,6 +593,8 @@ source "fs/Kconfig"
700 source "arch/sparc/Kconfig.debug"
702 +source "kernel/vserver/Kconfig"
704 source "security/Kconfig"
706 source "crypto/Kconfig"
707 diff -NurpP --minimal linux-3.6/arch/sparc/include/asm/unistd.h linux-3.6-vs2.3.4.3-noxfs-nocow/arch/sparc/include/asm/unistd.h
708 --- linux-3.6/arch/sparc/include/asm/unistd.h 2012-10-04 15:26:59.000000000 +0200
709 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/sparc/include/asm/unistd.h 2012-10-04 18:47:00.000000000 +0200
711 #define __NR_timer_getoverrun 264
712 #define __NR_timer_delete 265
713 #define __NR_timer_create 266
714 -/* #define __NR_vserver 267 Reserved for VSERVER */
715 +#define __NR_vserver 267
716 #define __NR_io_setup 268
717 #define __NR_io_destroy 269
718 #define __NR_io_submit 270
719 diff -NurpP --minimal linux-3.6/arch/sparc/kernel/systbls_32.S linux-3.6-vs2.3.4.3-noxfs-nocow/arch/sparc/kernel/systbls_32.S
720 --- linux-3.6/arch/sparc/kernel/systbls_32.S 2012-01-09 16:14:09.000000000 +0100
721 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/sparc/kernel/systbls_32.S 2012-10-04 18:47:00.000000000 +0200
722 @@ -70,7 +70,7 @@ sys_call_table:
723 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_ni_syscall
724 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
725 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
726 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
727 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
728 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
729 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
730 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
731 diff -NurpP --minimal linux-3.6/arch/sparc/kernel/systbls_64.S linux-3.6-vs2.3.4.3-noxfs-nocow/arch/sparc/kernel/systbls_64.S
732 --- linux-3.6/arch/sparc/kernel/systbls_64.S 2012-07-22 23:39:00.000000000 +0200
733 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/sparc/kernel/systbls_64.S 2012-10-04 18:47:00.000000000 +0200
734 @@ -71,7 +71,7 @@ sys_call_table32:
735 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys_nis_syscall
736 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
737 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
738 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
739 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
740 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
741 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
742 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, compat_sys_keyctl, compat_sys_openat
743 @@ -148,7 +148,7 @@ sys_call_table:
744 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nis_syscall
745 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
746 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
747 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
748 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
749 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
750 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
751 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
752 diff -NurpP --minimal linux-3.6/arch/um/Kconfig.rest linux-3.6-vs2.3.4.3-noxfs-nocow/arch/um/Kconfig.rest
753 --- linux-3.6/arch/um/Kconfig.rest 2012-01-09 16:14:09.000000000 +0100
754 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/um/Kconfig.rest 2012-10-04 18:47:00.000000000 +0200
755 @@ -12,6 +12,8 @@ source "arch/um/Kconfig.net"
759 +source "kernel/vserver/Kconfig"
761 source "security/Kconfig"
763 source "crypto/Kconfig"
764 diff -NurpP --minimal linux-3.6/arch/um/include/shared/kern_constants.h linux-3.6-vs2.3.4.3-noxfs-nocow/arch/um/include/shared/kern_constants.h
765 --- linux-3.6/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
766 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/um/include/shared/kern_constants.h 2012-10-04 18:47:00.000000000 +0200
768 +#include "../../../../include/generated/asm-offsets.h"
769 diff -NurpP --minimal linux-3.6/arch/um/include/shared/user_constants.h linux-3.6-vs2.3.4.3-noxfs-nocow/arch/um/include/shared/user_constants.h
770 --- linux-3.6/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
771 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/um/include/shared/user_constants.h 2012-10-04 18:47:00.000000000 +0200
776 + * This file was generated by arch/um/Makefile
780 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2) # */
781 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err) # */
782 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno) # */
783 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long) # */
784 +#define HOST_RBX 5 /* RBX # */
785 +#define HOST_RCX 11 /* RCX # */
786 +#define HOST_RDI 14 /* RDI # */
787 +#define HOST_RSI 13 /* RSI # */
788 +#define HOST_RDX 12 /* RDX # */
789 +#define HOST_RBP 4 /* RBP # */
790 +#define HOST_RAX 10 /* RAX # */
791 +#define HOST_R8 9 /* R8 # */
792 +#define HOST_R9 8 /* R9 # */
793 +#define HOST_R10 7 /* R10 # */
794 +#define HOST_R11 6 /* R11 # */
795 +#define HOST_R12 3 /* R12 # */
796 +#define HOST_R13 2 /* R13 # */
797 +#define HOST_R14 1 /* R14 # */
798 +#define HOST_R15 0 /* R15 # */
799 +#define HOST_ORIG_RAX 15 /* ORIG_RAX # */
800 +#define HOST_CS 17 /* CS # */
801 +#define HOST_SS 20 /* SS # */
802 +#define HOST_EFLAGS 18 /* EFLAGS # */
803 +#define HOST_IP 16 /* RIP # */
804 +#define HOST_SP 19 /* RSP # */
805 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct) # */
806 +#define UM_POLLIN 1 /* POLLIN # */
807 +#define UM_POLLPRI 2 /* POLLPRI # */
808 +#define UM_POLLOUT 4 /* POLLOUT # */
809 +#define UM_PROT_READ 1 /* PROT_READ # */
810 +#define UM_PROT_WRITE 2 /* PROT_WRITE # */
811 +#define UM_PROT_EXEC 4 /* PROT_EXEC # */
813 diff -NurpP --minimal linux-3.6/arch/x86/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/arch/x86/Kconfig
814 --- linux-3.6/arch/x86/Kconfig 2012-10-04 15:27:00.000000000 +0200
815 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/x86/Kconfig 2012-10-04 18:47:00.000000000 +0200
816 @@ -2228,6 +2228,8 @@ source "fs/Kconfig"
818 source "arch/x86/Kconfig.debug"
820 +source "kernel/vserver/Kconfig"
822 source "security/Kconfig"
824 source "crypto/Kconfig"
825 diff -NurpP --minimal linux-3.6/arch/x86/syscalls/syscall_32.tbl linux-3.6-vs2.3.4.3-noxfs-nocow/arch/x86/syscalls/syscall_32.tbl
826 --- linux-3.6/arch/x86/syscalls/syscall_32.tbl 2012-07-22 23:39:02.000000000 +0200
827 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/x86/syscalls/syscall_32.tbl 2012-10-04 18:47:00.000000000 +0200
829 270 i386 tgkill sys_tgkill
830 271 i386 utimes sys_utimes compat_sys_utimes
831 272 i386 fadvise64_64 sys_fadvise64_64 sys32_fadvise64_64
833 +273 i386 vserver sys_vserver sys32_vserver
834 274 i386 mbind sys_mbind
835 275 i386 get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy
836 276 i386 set_mempolicy sys_set_mempolicy
837 diff -NurpP --minimal linux-3.6/arch/x86/syscalls/syscall_64.tbl linux-3.6-vs2.3.4.3-noxfs-nocow/arch/x86/syscalls/syscall_64.tbl
838 --- linux-3.6/arch/x86/syscalls/syscall_64.tbl 2012-10-04 15:27:01.000000000 +0200
839 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/arch/x86/syscalls/syscall_64.tbl 2012-10-04 18:47:00.000000000 +0200
841 233 common epoll_ctl sys_epoll_ctl
842 234 common tgkill sys_tgkill
843 235 common utimes sys_utimes
845 +236 64 vserver sys_vserver
846 237 common mbind sys_mbind
847 238 common set_mempolicy sys_set_mempolicy
848 239 common get_mempolicy sys_get_mempolicy
849 diff -NurpP --minimal linux-3.6/drivers/block/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/block/Kconfig
850 --- linux-3.6/drivers/block/Kconfig 2012-05-21 18:06:43.000000000 +0200
851 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/block/Kconfig 2012-10-04 18:47:00.000000000 +0200
852 @@ -290,6 +290,13 @@ config BLK_DEV_CRYPTOLOOP
854 source "drivers/block/drbd/Kconfig"
856 +config BLK_DEV_VROOT
857 + tristate "Virtual Root device support"
858 + depends on QUOTACTL
860 + Saying Y here will allow you to use quota/fs ioctls on a shared
861 + partition within a virtual server without compromising security.
864 tristate "Network block device support"
866 diff -NurpP --minimal linux-3.6/drivers/block/Makefile linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/block/Makefile
867 --- linux-3.6/drivers/block/Makefile 2012-03-19 19:46:52.000000000 +0100
868 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/block/Makefile 2012-10-04 18:47:00.000000000 +0200
869 @@ -35,6 +35,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
870 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
871 obj-$(CONFIG_BLK_DEV_UB) += ub.o
872 obj-$(CONFIG_BLK_DEV_HD) += hd.o
873 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
875 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
876 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
877 diff -NurpP --minimal linux-3.6/drivers/block/loop.c linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/block/loop.c
878 --- linux-3.6/drivers/block/loop.c 2012-07-22 23:39:02.000000000 +0200
879 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/block/loop.c 2012-10-04 18:47:00.000000000 +0200
881 #include <linux/sysfs.h>
882 #include <linux/miscdevice.h>
883 #include <linux/falloc.h>
884 +#include <linux/vs_context.h>
886 #include <asm/uaccess.h>
888 @@ -869,6 +870,7 @@ static int loop_set_fd(struct loop_devic
889 lo->lo_blocksize = lo_blocksize;
890 lo->lo_device = bdev;
891 lo->lo_flags = lo_flags;
892 + lo->lo_xid = vx_current_xid();
893 lo->lo_backing_file = file;
894 lo->transfer = transfer_none;
896 @@ -1001,6 +1003,7 @@ static int loop_clr_fd(struct loop_devic
897 lo->lo_sizelimit = 0;
898 lo->lo_encrypt_key_size = 0;
899 lo->lo_thread = NULL;
901 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
902 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
903 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
904 @@ -1042,7 +1045,7 @@ loop_set_status(struct loop_device *lo,
906 if (lo->lo_encrypt_key_size &&
907 lo->lo_key_owner != uid &&
908 - !capable(CAP_SYS_ADMIN))
909 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
911 if (lo->lo_state != Lo_bound)
913 @@ -1132,7 +1135,8 @@ loop_get_status(struct loop_device *lo,
914 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
915 info->lo_encrypt_type =
916 lo->lo_encryption ? lo->lo_encryption->number : 0;
917 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
918 + if (lo->lo_encrypt_key_size &&
919 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
920 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
921 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
922 lo->lo_encrypt_key_size);
923 @@ -1492,6 +1496,11 @@ static int lo_open(struct block_device *
927 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P)) {
932 mutex_lock(&lo->lo_ctl_mutex);
934 mutex_unlock(&lo->lo_ctl_mutex);
935 diff -NurpP --minimal linux-3.6/drivers/block/vroot.c linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/block/vroot.c
936 --- linux-3.6/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
937 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/block/vroot.c 2012-10-04 18:47:00.000000000 +0200
940 + * linux/drivers/block/vroot.c
942 + * written by Herbert Pötzl, 9/11/2002
943 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
945 + * based on the loop.c code by Theodore Ts'o.
947 + * Copyright (C) 2002-2007 by Herbert Pötzl.
948 + * Redistribution of this file is permitted under the
949 + * GNU General Public License.
953 +#include <linux/module.h>
954 +#include <linux/moduleparam.h>
955 +#include <linux/file.h>
956 +#include <linux/major.h>
957 +#include <linux/blkdev.h>
958 +#include <linux/slab.h>
960 +#include <linux/vroot.h>
961 +#include <linux/vs_context.h>
964 +static int max_vroot = 8;
966 +static struct vroot_device *vroot_dev;
967 +static struct gendisk **disks;
970 +static int vroot_set_dev(
971 + struct vroot_device *vr,
972 + struct block_device *bdev,
975 + struct block_device *real_bdev;
977 + struct inode *inode;
981 + if (vr->vr_state != Vr_unbound)
990 + inode = file->f_dentry->d_inode;
993 + if (S_ISBLK(inode->i_mode)) {
994 + real_bdev = inode->i_bdev;
995 + vr->vr_device = real_bdev;
996 + __iget(real_bdev->bd_inode);
1000 + vxdprintk(VXD_CBIT(misc, 0),
1001 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1002 + vr->vr_number, VXD_DEV(real_bdev));
1004 + vr->vr_state = Vr_bound;
1013 +static int vroot_clr_dev(
1014 + struct vroot_device *vr,
1015 + struct block_device *bdev)
1017 + struct block_device *real_bdev;
1019 + if (vr->vr_state != Vr_bound)
1021 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1024 + real_bdev = vr->vr_device;
1026 + vxdprintk(VXD_CBIT(misc, 0),
1027 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1028 + vr->vr_number, VXD_DEV(real_bdev));
1031 + vr->vr_state = Vr_unbound;
1032 + vr->vr_device = NULL;
1037 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1038 + unsigned int cmd, unsigned long arg)
1040 + struct vroot_device *vr = bdev->bd_disk->private_data;
1043 + down(&vr->vr_ctl_mutex);
1045 + case VROOT_SET_DEV:
1046 + err = vroot_set_dev(vr, bdev, arg);
1048 + case VROOT_CLR_DEV:
1049 + err = vroot_clr_dev(vr, bdev);
1055 + up(&vr->vr_ctl_mutex);
1059 +static int vr_open(struct block_device *bdev, fmode_t mode)
1061 + struct vroot_device *vr = bdev->bd_disk->private_data;
1063 + down(&vr->vr_ctl_mutex);
1065 + up(&vr->vr_ctl_mutex);
1069 +static int vr_release(struct gendisk *disk, fmode_t mode)
1071 + struct vroot_device *vr = disk->private_data;
1073 + down(&vr->vr_ctl_mutex);
1075 + up(&vr->vr_ctl_mutex);
1079 +static struct block_device_operations vr_fops = {
1080 + .owner = THIS_MODULE,
1082 + .release = vr_release,
1083 + .ioctl = vr_ioctl,
1086 +static void vroot_make_request(struct request_queue *q, struct bio *bio)
1088 + printk("vroot_make_request %p, %p\n", q, bio);
1089 + bio_io_error(bio);
1092 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1094 + struct inode *inode = bdev->bd_inode;
1095 + struct vroot_device *vr;
1096 + struct block_device *real_bdev;
1097 + int minor = iminor(inode);
1099 + vr = &vroot_dev[minor];
1100 + real_bdev = vr->vr_device;
1102 + vxdprintk(VXD_CBIT(misc, 0),
1103 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1104 + vr->vr_number, VXD_DEV(real_bdev));
1106 + if (vr->vr_state != Vr_bound)
1107 + return ERR_PTR(-ENXIO);
1109 + __iget(real_bdev->bd_inode);
1116 + * And now the modules code and kernel interface.
1119 +module_param(max_vroot, int, 0);
1121 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1122 +MODULE_LICENSE("GPL");
1123 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1125 +MODULE_AUTHOR ("Herbert Pötzl");
1126 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1129 +int __init vroot_init(void)
1133 + if (max_vroot < 1 || max_vroot > 256) {
1134 + max_vroot = MAX_VROOT_DEFAULT;
1135 + printk(KERN_WARNING "vroot: invalid max_vroot "
1136 + "(must be between 1 and 256), "
1137 + "using default (%d)\n", max_vroot);
1140 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1144 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1147 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1149 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1153 + for (i = 0; i < max_vroot; i++) {
1154 + disks[i] = alloc_disk(1);
1157 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1158 + if (!disks[i]->queue)
1160 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1163 + for (i = 0; i < max_vroot; i++) {
1164 + struct vroot_device *vr = &vroot_dev[i];
1165 + struct gendisk *disk = disks[i];
1167 + memset(vr, 0, sizeof(*vr));
1168 + sema_init(&vr->vr_ctl_mutex, 1);
1169 + vr->vr_number = i;
1170 + disk->major = VROOT_MAJOR;
1171 + disk->first_minor = i;
1172 + disk->fops = &vr_fops;
1173 + sprintf(disk->disk_name, "vroot%d", i);
1174 + disk->private_data = vr;
1177 + err = register_vroot_grb(&__vroot_get_real_bdev);
1181 + for (i = 0; i < max_vroot; i++)
1182 + add_disk(disks[i]);
1183 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1188 + put_disk(disks[i]);
1193 + unregister_blkdev(VROOT_MAJOR, "vroot");
1194 + printk(KERN_ERR "vroot: ran out of memory\n");
1198 +void vroot_exit(void)
1202 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1203 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1205 + for (i = 0; i < max_vroot; i++) {
1206 + del_gendisk(disks[i]);
1207 + put_disk(disks[i]);
1209 + unregister_blkdev(VROOT_MAJOR, "vroot");
1215 +module_init(vroot_init);
1216 +module_exit(vroot_exit);
1220 +static int __init max_vroot_setup(char *str)
1222 + max_vroot = simple_strtol(str, NULL, 0);
1226 +__setup("max_vroot=", max_vroot_setup);
1230 diff -NurpP --minimal linux-3.6/drivers/infiniband/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/infiniband/Kconfig
1231 --- linux-3.6/drivers/infiniband/Kconfig 2012-07-22 23:39:06.000000000 +0200
1232 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/infiniband/Kconfig 2012-10-04 18:47:00.000000000 +0200
1233 @@ -39,7 +39,7 @@ config INFINIBAND_USER_MEM
1234 config INFINIBAND_ADDR_TRANS
1237 - depends on !(INFINIBAND = y && IPV6 = m)
1238 + depends on !(INFINIBAND = y && IPV6 = y)
1241 source "drivers/infiniband/hw/mthca/Kconfig"
1242 diff -NurpP --minimal linux-3.6/drivers/infiniband/core/addr.c linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/infiniband/core/addr.c
1243 --- linux-3.6/drivers/infiniband/core/addr.c 2012-10-04 15:27:10.000000000 +0200
1244 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/infiniband/core/addr.c 2012-10-04 18:47:00.000000000 +0200
1245 @@ -263,7 +263,7 @@ static int addr6_resolve(struct sockaddr
1247 if (ipv6_addr_any(&fl6.saddr)) {
1248 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1249 - &fl6.daddr, 0, &fl6.saddr);
1250 + &fl6.daddr, 0, &fl6.saddr, NULL);
1254 diff -NurpP --minimal linux-3.6/drivers/md/dm-ioctl.c linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/md/dm-ioctl.c
1255 --- linux-3.6/drivers/md/dm-ioctl.c 2012-10-04 15:27:11.000000000 +0200
1256 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/md/dm-ioctl.c 2012-10-04 18:47:00.000000000 +0200
1258 #include <linux/dm-ioctl.h>
1259 #include <linux/hdreg.h>
1260 #include <linux/compat.h>
1261 +#include <linux/vs_context.h>
1263 #include <asm/uaccess.h>
1265 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1266 unsigned int h = hash_str(str);
1268 list_for_each_entry (hc, _name_buckets + h, name_list)
1269 - if (!strcmp(hc->name, str)) {
1270 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1271 + !strcmp(hc->name, str)) {
1275 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1276 unsigned int h = hash_str(str);
1278 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1279 - if (!strcmp(hc->uuid, str)) {
1280 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1281 + !strcmp(hc->uuid, str)) {
1285 @@ -131,13 +134,15 @@ static struct hash_cell *__get_uuid_cell
1286 static struct hash_cell *__get_dev_cell(uint64_t dev)
1288 struct mapped_device *md;
1289 - struct hash_cell *hc;
1290 + struct hash_cell *hc = NULL;
1292 md = dm_get_md(huge_decode_dev(dev));
1296 - hc = dm_get_mdptr(md);
1297 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1298 + hc = dm_get_mdptr(md);
1303 @@ -445,6 +450,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1305 static int remove_all(struct dm_ioctl *param, size_t param_size)
1307 + if (!vx_check(0, VS_ADMIN))
1310 dm_hash_remove_all(1);
1311 param->data_size = 0;
1313 @@ -492,6 +500,8 @@ static int list_devices(struct dm_ioctl
1315 for (i = 0; i < NUM_BUCKETS; i++) {
1316 list_for_each_entry (hc, _name_buckets + i, name_list) {
1317 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1319 needed += sizeof(struct dm_name_list);
1320 needed += strlen(hc->name) + 1;
1321 needed += ALIGN_MASK;
1322 @@ -515,6 +525,8 @@ static int list_devices(struct dm_ioctl
1324 for (i = 0; i < NUM_BUCKETS; i++) {
1325 list_for_each_entry (hc, _name_buckets + i, name_list) {
1326 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1329 old_nl->next = (uint32_t) ((void *) nl -
1331 @@ -1619,8 +1631,8 @@ static int ctl_ioctl(uint command, struc
1333 size_t input_param_size;
1335 - /* only root can play with this */
1336 - if (!capable(CAP_SYS_ADMIN))
1337 + /* only root and certain contexts can play with this */
1338 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1341 if (_IOC_TYPE(command) != DM_IOCTL)
1342 diff -NurpP --minimal linux-3.6/drivers/md/dm.c linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/md/dm.c
1343 --- linux-3.6/drivers/md/dm.c 2012-10-04 15:27:11.000000000 +0200
1344 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/md/dm.c 2012-10-04 18:47:00.000000000 +0200
1346 #include <linux/idr.h>
1347 #include <linux/hdreg.h>
1348 #include <linux/delay.h>
1349 +#include <linux/vs_base.h>
1351 #include <trace/events/block.h>
1353 @@ -131,6 +132,7 @@ struct mapped_device {
1356 atomic_t open_count;
1359 unsigned long flags;
1361 @@ -343,6 +345,7 @@ int dm_deleting_md(struct mapped_device
1362 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1364 struct mapped_device *md;
1367 spin_lock(&_minor_lock);
1369 @@ -351,18 +354,19 @@ static int dm_blk_open(struct block_devi
1372 if (test_bit(DMF_FREEING, &md->flags) ||
1373 - dm_deleting_md(md)) {
1375 + dm_deleting_md(md))
1379 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1384 atomic_inc(&md->open_count);
1388 spin_unlock(&_minor_lock);
1390 - return md ? 0 : -ENXIO;
1394 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1395 @@ -583,6 +587,14 @@ int dm_set_geometry(struct mapped_device
1400 + * Get the xid associated with a dm device
1402 +xid_t dm_get_xid(struct mapped_device *md)
1407 /*-----------------------------------------------------------------
1409 * A more elegant soln is in the works that uses the queue
1410 @@ -1892,6 +1904,7 @@ static struct mapped_device *alloc_dev(i
1411 INIT_LIST_HEAD(&md->uevent_list);
1412 spin_lock_init(&md->uevent_lock);
1414 + md->xid = vx_current_xid();
1415 md->queue = blk_alloc_queue(GFP_KERNEL);
1418 diff -NurpP --minimal linux-3.6/drivers/md/dm.h linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/md/dm.h
1419 --- linux-3.6/drivers/md/dm.h 2012-10-04 15:27:11.000000000 +0200
1420 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/md/dm.h 2012-10-04 18:47:00.000000000 +0200
1421 @@ -46,6 +46,8 @@ struct dm_dev_internal {
1423 struct dm_md_mempools;
1425 +xid_t dm_get_xid(struct mapped_device *md);
1427 /*-----------------------------------------------------------------
1428 * Internal table functions.
1429 *---------------------------------------------------------------*/
1430 diff -NurpP --minimal linux-3.6/drivers/net/tun.c linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/net/tun.c
1431 --- linux-3.6/drivers/net/tun.c 2012-10-04 15:27:20.000000000 +0200
1432 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/net/tun.c 2012-10-04 18:47:00.000000000 +0200
1434 #include <linux/nsproxy.h>
1435 #include <linux/virtio_net.h>
1436 #include <linux/rcupdate.h>
1437 +#include <linux/vs_network.h>
1438 #include <net/net_namespace.h>
1439 #include <net/netns/generic.h>
1440 #include <net/rtnetlink.h>
1441 @@ -122,6 +123,7 @@ struct tun_struct {
1447 struct net_device *dev;
1448 netdev_features_t set_features;
1449 @@ -1033,6 +1035,7 @@ static void tun_setup(struct net_device
1453 + tun->nid = current->nid;
1455 dev->ethtool_ops = &tun_ethtool_ops;
1456 dev->destructor = tun_free_netdev;
1457 @@ -1191,7 +1194,7 @@ static int tun_set_iff(struct net *net,
1459 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1460 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1461 - !capable(CAP_NET_ADMIN))
1462 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1464 err = security_tun_dev_attach(tun->socket.sk);
1466 @@ -1205,7 +1208,7 @@ static int tun_set_iff(struct net *net,
1468 unsigned long flags = 0;
1470 - if (!capable(CAP_NET_ADMIN))
1471 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1473 err = security_tun_dev_create();
1475 @@ -1276,6 +1279,9 @@ static int tun_set_iff(struct net *net,
1477 sk->sk_destruct = tun_sock_destruct;
1479 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1482 err = tun_attach(tun, file);
1485 @@ -1459,6 +1465,16 @@ static long __tun_chr_ioctl(struct file
1486 tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
1490 + if (!capable(CAP_CONTEXT))
1493 + /* Set nid owner of the device */
1494 + tun->nid = (nid_t) arg;
1496 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
1500 /* Only allow setting the type when the interface is down */
1501 if (tun->dev->flags & IFF_UP) {
1502 diff -NurpP --minimal linux-3.6/drivers/tty/sysrq.c linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/tty/sysrq.c
1503 --- linux-3.6/drivers/tty/sysrq.c 2012-05-21 18:07:16.000000000 +0200
1504 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/tty/sysrq.c 2012-10-04 18:47:00.000000000 +0200
1506 #include <linux/slab.h>
1507 #include <linux/input.h>
1508 #include <linux/uaccess.h>
1509 +#include <linux/vserver/debug.h>
1511 #include <asm/ptrace.h>
1512 #include <asm/irq_regs.h>
1513 @@ -398,6 +399,21 @@ static struct sysrq_key_op sysrq_unrt_op
1514 .enable_mask = SYSRQ_ENABLE_RTNICE,
1518 +#ifdef CONFIG_VSERVER_DEBUG
1519 +static void sysrq_handle_vxinfo(int key)
1521 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1524 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1525 + .handler = sysrq_handle_vxinfo,
1526 + .help_msg = "conteXt",
1527 + .action_msg = "Show Context Info",
1528 + .enable_mask = SYSRQ_ENABLE_DUMP,
1532 /* Key Operations table and lock */
1533 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1535 @@ -452,7 +468,11 @@ static struct sysrq_key_op *sysrq_key_ta
1537 &sysrq_showstate_blocked_op, /* w */
1538 /* x: May be registered on ppc/powerpc for xmon */
1539 +#ifdef CONFIG_VSERVER_DEBUG
1540 + &sysrq_showvxinfo_op, /* x */
1544 /* y: May be registered on sparc64 for global register dump */
1546 &sysrq_ftrace_dump_op, /* z */
1547 @@ -467,6 +487,8 @@ static int sysrq_key_table_key2index(int
1549 else if ((key >= 'a') && (key <= 'z'))
1550 retval = key + 10 - 'a';
1551 + else if ((key >= 'A') && (key <= 'Z'))
1552 + retval = key + 10 - 'A';
1556 diff -NurpP --minimal linux-3.6/drivers/tty/tty_io.c linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/tty/tty_io.c
1557 --- linux-3.6/drivers/tty/tty_io.c 2012-07-22 23:39:32.000000000 +0200
1558 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/drivers/tty/tty_io.c 2012-10-04 18:47:00.000000000 +0200
1561 #include <linux/kmod.h>
1562 #include <linux/nsproxy.h>
1563 +#include <linux/vs_pid.h>
1565 #undef TTY_DEBUG_HANGUP
1567 @@ -2123,7 +2124,8 @@ static int tiocsti(struct tty_struct *tt
1569 struct tty_ldisc *ld;
1571 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1572 + if (((current->signal->tty != tty) &&
1573 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1575 if (get_user(ch, p))
1577 @@ -2411,6 +2413,7 @@ static int tiocspgrp(struct tty_struct *
1579 if (get_user(pgrp_nr, p))
1581 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1585 diff -NurpP --minimal linux-3.6/fs/attr.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/attr.c
1586 --- linux-3.6/fs/attr.c 2012-10-04 15:27:39.000000000 +0200
1587 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/attr.c 2012-10-04 18:47:00.000000000 +0200
1589 #include <linux/fcntl.h>
1590 #include <linux/security.h>
1591 #include <linux/evm.h>
1592 +#include <linux/proc_fs.h>
1593 +#include <linux/devpts_fs.h>
1594 +#include <linux/vs_tag.h>
1597 * inode_change_ok - check if attribute changes to an inode are allowed
1598 @@ -74,6 +77,10 @@ int inode_change_ok(const struct inode *
1602 + /* check for inode tag permission */
1603 + if (dx_permission(inode, MAY_WRITE))
1608 EXPORT_SYMBOL(inode_change_ok);
1609 @@ -144,6 +151,8 @@ void setattr_copy(struct inode *inode, c
1610 inode->i_uid = attr->ia_uid;
1611 if (ia_valid & ATTR_GID)
1612 inode->i_gid = attr->ia_gid;
1613 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1614 + inode->i_tag = attr->ia_tag;
1615 if (ia_valid & ATTR_ATIME)
1616 inode->i_atime = timespec_trunc(attr->ia_atime,
1617 inode->i_sb->s_time_gran);
1618 @@ -173,7 +182,8 @@ int notify_change(struct dentry * dentry
1620 WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
1622 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
1623 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
1624 + ATTR_TAG | ATTR_TIMES_SET)) {
1625 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1628 diff -NurpP --minimal linux-3.6/fs/block_dev.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/block_dev.c
1629 --- linux-3.6/fs/block_dev.c 2012-10-04 15:27:39.000000000 +0200
1630 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/block_dev.c 2012-10-04 18:47:00.000000000 +0200
1632 #include <linux/namei.h>
1633 #include <linux/log2.h>
1634 #include <linux/cleancache.h>
1635 +#include <linux/vs_device.h>
1636 #include <asm/uaccess.h>
1637 #include "internal.h"
1639 @@ -581,6 +582,7 @@ struct block_device *bdget(dev_t dev)
1640 bdev->bd_invalidated = 0;
1641 inode->i_mode = S_IFBLK;
1642 inode->i_rdev = dev;
1643 + inode->i_mdev = dev;
1644 inode->i_bdev = bdev;
1645 inode->i_data.a_ops = &def_blk_aops;
1646 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1647 @@ -627,6 +629,11 @@ EXPORT_SYMBOL(bdput);
1648 static struct block_device *bd_acquire(struct inode *inode)
1650 struct block_device *bdev;
1653 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1655 + inode->i_mdev = mdev;
1657 spin_lock(&bdev_lock);
1658 bdev = inode->i_bdev;
1659 @@ -637,7 +644,7 @@ static struct block_device *bd_acquire(s
1661 spin_unlock(&bdev_lock);
1663 - bdev = bdget(inode->i_rdev);
1664 + bdev = bdget(mdev);
1666 spin_lock(&bdev_lock);
1667 if (!inode->i_bdev) {
1668 diff -NurpP --minimal linux-3.6/fs/btrfs/ctree.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/btrfs/ctree.h
1669 --- linux-3.6/fs/btrfs/ctree.h 2012-10-04 15:27:39.000000000 +0200
1670 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/btrfs/ctree.h 2012-10-04 18:47:00.000000000 +0200
1671 @@ -674,11 +674,14 @@ struct btrfs_inode_item {
1672 /* modification sequence number for NFS */
1677 * a little future expansion, for more than this we can
1678 * just grow the inode item and version it
1680 - __le64 reserved[4];
1681 + __le16 reserved16;
1682 + __le32 reserved32;
1683 + __le64 reserved[3];
1684 struct btrfs_timespec atime;
1685 struct btrfs_timespec ctime;
1686 struct btrfs_timespec mtime;
1687 @@ -1727,6 +1730,8 @@ struct btrfs_ioctl_defrag_range_args {
1688 #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21)
1689 #define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22)
1691 +#define BTRFS_MOUNT_TAGGED (1 << 24)
1693 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1694 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1695 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
1696 @@ -1988,6 +1993,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
1697 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
1698 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
1699 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
1700 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
1701 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
1702 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
1703 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
1704 @@ -2041,6 +2047,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
1706 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
1708 +#define BTRFS_INODE_IXUNLINK (1 << 24)
1709 +#define BTRFS_INODE_BARRIER (1 << 25)
1710 +#define BTRFS_INODE_COW (1 << 26)
1713 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
1715 @@ -3305,6 +3315,7 @@ extern const struct dentry_operations bt
1716 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1717 void btrfs_update_iflags(struct inode *inode);
1718 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
1719 +int btrfs_sync_flags(struct inode *inode, int, int);
1720 int btrfs_defrag_file(struct inode *inode, struct file *file,
1721 struct btrfs_ioctl_defrag_range_args *range,
1722 u64 newer_than, unsigned long max_pages);
1723 diff -NurpP --minimal linux-3.6/fs/btrfs/disk-io.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/btrfs/disk-io.c
1724 --- linux-3.6/fs/btrfs/disk-io.c 2012-10-04 15:27:39.000000000 +0200
1725 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/btrfs/disk-io.c 2012-10-04 18:47:00.000000000 +0200
1726 @@ -2187,6 +2187,9 @@ int open_ctree(struct super_block *sb,
1730 + if (btrfs_test_opt(tree_root, TAGGED))
1731 + sb->s_flags |= MS_TAGGED;
1733 features = btrfs_super_incompat_flags(disk_super) &
1734 ~BTRFS_FEATURE_INCOMPAT_SUPP;
1736 diff -NurpP --minimal linux-3.6/fs/btrfs/inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/btrfs/inode.c
1737 --- linux-3.6/fs/btrfs/inode.c 2012-10-04 15:27:39.000000000 +0200
1738 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/btrfs/inode.c 2012-10-04 18:47:00.000000000 +0200
1740 #include <linux/slab.h>
1741 #include <linux/ratelimit.h>
1742 #include <linux/mount.h>
1743 +#include <linux/vs_tag.h>
1746 #include "disk-io.h"
1747 @@ -2545,6 +2546,8 @@ static void btrfs_read_locked_inode(stru
1748 struct btrfs_key location;
1754 bool filled = false;
1756 @@ -2572,8 +2575,13 @@ static void btrfs_read_locked_inode(stru
1757 struct btrfs_inode_item);
1758 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
1759 set_nlink(inode, btrfs_inode_nlink(leaf, inode_item));
1760 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
1761 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
1763 + uid = btrfs_inode_uid(leaf, inode_item);
1764 + gid = btrfs_inode_gid(leaf, inode_item);
1765 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
1766 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
1767 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
1768 + btrfs_inode_tag(leaf, inode_item));
1769 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
1771 tspec = btrfs_inode_atime(inode_item);
1772 @@ -2651,8 +2659,14 @@ static void fill_inode_item(struct btrfs
1773 struct btrfs_inode_item *item,
1774 struct inode *inode)
1776 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
1777 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
1778 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
1779 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
1781 + btrfs_set_inode_uid(leaf, item, uid);
1782 + btrfs_set_inode_gid(leaf, item, gid);
1783 +#ifdef CONFIG_TAGGING_INTERN
1784 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
1786 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
1787 btrfs_set_inode_mode(leaf, item, inode->i_mode);
1788 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
1789 @@ -7636,11 +7650,13 @@ static const struct inode_operations btr
1790 .listxattr = btrfs_listxattr,
1791 .removexattr = btrfs_removexattr,
1792 .permission = btrfs_permission,
1793 + .sync_flags = btrfs_sync_flags,
1794 .get_acl = btrfs_get_acl,
1796 static const struct inode_operations btrfs_dir_ro_inode_operations = {
1797 .lookup = btrfs_lookup,
1798 .permission = btrfs_permission,
1799 + .sync_flags = btrfs_sync_flags,
1800 .get_acl = btrfs_get_acl,
1803 diff -NurpP --minimal linux-3.6/fs/btrfs/ioctl.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/btrfs/ioctl.c
1804 --- linux-3.6/fs/btrfs/ioctl.c 2012-10-04 15:27:39.000000000 +0200
1805 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/btrfs/ioctl.c 2012-10-04 18:47:00.000000000 +0200
1806 @@ -74,10 +74,13 @@ static unsigned int btrfs_flags_to_ioctl
1808 unsigned int iflags = 0;
1810 - if (flags & BTRFS_INODE_SYNC)
1811 - iflags |= FS_SYNC_FL;
1812 if (flags & BTRFS_INODE_IMMUTABLE)
1813 iflags |= FS_IMMUTABLE_FL;
1814 + if (flags & BTRFS_INODE_IXUNLINK)
1815 + iflags |= FS_IXUNLINK_FL;
1817 + if (flags & BTRFS_INODE_SYNC)
1818 + iflags |= FS_SYNC_FL;
1819 if (flags & BTRFS_INODE_APPEND)
1820 iflags |= FS_APPEND_FL;
1821 if (flags & BTRFS_INODE_NODUMP)
1822 @@ -94,28 +97,78 @@ static unsigned int btrfs_flags_to_ioctl
1823 else if (flags & BTRFS_INODE_NOCOMPRESS)
1824 iflags |= FS_NOCOMP_FL;
1826 + if (flags & BTRFS_INODE_BARRIER)
1827 + iflags |= FS_BARRIER_FL;
1828 + if (flags & BTRFS_INODE_COW)
1829 + iflags |= FS_COW_FL;
1834 - * Update inode->i_flags based on the btrfs internal flags.
1835 + * Update inode->i_(v)flags based on the btrfs internal flags.
1837 void btrfs_update_iflags(struct inode *inode)
1839 struct btrfs_inode *ip = BTRFS_I(inode);
1841 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
1842 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
1843 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
1845 - if (ip->flags & BTRFS_INODE_SYNC)
1846 - inode->i_flags |= S_SYNC;
1847 if (ip->flags & BTRFS_INODE_IMMUTABLE)
1848 inode->i_flags |= S_IMMUTABLE;
1849 + if (ip->flags & BTRFS_INODE_IXUNLINK)
1850 + inode->i_flags |= S_IXUNLINK;
1852 + if (ip->flags & BTRFS_INODE_SYNC)
1853 + inode->i_flags |= S_SYNC;
1854 if (ip->flags & BTRFS_INODE_APPEND)
1855 inode->i_flags |= S_APPEND;
1856 if (ip->flags & BTRFS_INODE_NOATIME)
1857 inode->i_flags |= S_NOATIME;
1858 if (ip->flags & BTRFS_INODE_DIRSYNC)
1859 inode->i_flags |= S_DIRSYNC;
1861 + inode->i_vflags &= ~(V_BARRIER | V_COW);
1863 + if (ip->flags & BTRFS_INODE_BARRIER)
1864 + inode->i_vflags |= V_BARRIER;
1865 + if (ip->flags & BTRFS_INODE_COW)
1866 + inode->i_vflags |= V_COW;
1870 + * Update btrfs internal flags from inode->i_(v)flags.
1872 +void btrfs_update_flags(struct inode *inode)
1874 + struct btrfs_inode *ip = BTRFS_I(inode);
1876 + unsigned int flags = inode->i_flags;
1877 + unsigned int vflags = inode->i_vflags;
1879 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
1880 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
1881 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
1882 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
1884 + if (flags & S_IMMUTABLE)
1885 + ip->flags |= BTRFS_INODE_IMMUTABLE;
1886 + if (flags & S_IXUNLINK)
1887 + ip->flags |= BTRFS_INODE_IXUNLINK;
1889 + if (flags & S_SYNC)
1890 + ip->flags |= BTRFS_INODE_SYNC;
1891 + if (flags & S_APPEND)
1892 + ip->flags |= BTRFS_INODE_APPEND;
1893 + if (flags & S_NOATIME)
1894 + ip->flags |= BTRFS_INODE_NOATIME;
1895 + if (flags & S_DIRSYNC)
1896 + ip->flags |= BTRFS_INODE_DIRSYNC;
1898 + if (vflags & V_BARRIER)
1899 + ip->flags |= BTRFS_INODE_BARRIER;
1900 + if (vflags & V_COW)
1901 + ip->flags |= BTRFS_INODE_COW;
1905 @@ -131,6 +184,7 @@ void btrfs_inherit_iflags(struct inode *
1908 flags = BTRFS_I(dir)->flags;
1909 + flags &= ~BTRFS_INODE_BARRIER;
1911 if (flags & BTRFS_INODE_NOCOMPRESS) {
1912 BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
1913 @@ -146,6 +200,30 @@ void btrfs_inherit_iflags(struct inode *
1914 btrfs_update_iflags(inode);
1917 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
1919 + struct btrfs_inode *ip = BTRFS_I(inode);
1920 + struct btrfs_root *root = ip->root;
1921 + struct btrfs_trans_handle *trans;
1924 + trans = btrfs_join_transaction(root);
1927 + inode->i_flags = flags;
1928 + inode->i_vflags = vflags;
1929 + btrfs_update_flags(inode);
1931 + ret = btrfs_update_inode(trans, root, inode);
1934 + btrfs_update_iflags(inode);
1935 + inode->i_ctime = CURRENT_TIME;
1936 + btrfs_end_transaction(trans, root);
1941 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
1943 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
1944 @@ -206,21 +284,27 @@ static int btrfs_ioctl_setflags(struct f
1946 flags = btrfs_mask_flags(inode->i_mode, flags);
1947 oldflags = btrfs_flags_to_ioctl(ip->flags);
1948 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
1949 + if ((flags ^ oldflags) & (FS_APPEND_FL |
1950 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
1951 if (!capable(CAP_LINUX_IMMUTABLE)) {
1957 - if (flags & FS_SYNC_FL)
1958 - ip->flags |= BTRFS_INODE_SYNC;
1960 - ip->flags &= ~BTRFS_INODE_SYNC;
1961 if (flags & FS_IMMUTABLE_FL)
1962 ip->flags |= BTRFS_INODE_IMMUTABLE;
1964 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
1965 + if (flags & FS_IXUNLINK_FL)
1966 + ip->flags |= BTRFS_INODE_IXUNLINK;
1968 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
1970 + if (flags & FS_SYNC_FL)
1971 + ip->flags |= BTRFS_INODE_SYNC;
1973 + ip->flags &= ~BTRFS_INODE_SYNC;
1974 if (flags & FS_APPEND_FL)
1975 ip->flags |= BTRFS_INODE_APPEND;
1977 diff -NurpP --minimal linux-3.6/fs/btrfs/super.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/btrfs/super.c
1978 --- linux-3.6/fs/btrfs/super.c 2012-10-04 15:27:39.000000000 +0200
1979 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/btrfs/super.c 2012-10-04 18:47:00.000000000 +0200
1980 @@ -306,7 +306,7 @@ enum {
1981 Opt_no_space_cache, Opt_recovery, Opt_skip_balance,
1982 Opt_check_integrity, Opt_check_integrity_including_extent_data,
1983 Opt_check_integrity_print_mask, Opt_fatal_errors,
1985 + Opt_tag, Opt_notag, Opt_tagid, Opt_err,
1988 static match_table_t tokens = {
1989 @@ -346,6 +346,9 @@ static match_table_t tokens = {
1990 {Opt_check_integrity_including_extent_data, "check_int_data"},
1991 {Opt_check_integrity_print_mask, "check_int_print_mask=%d"},
1992 {Opt_fatal_errors, "fatal_errors=%s"},
1994 + {Opt_notag, "notag"},
1995 + {Opt_tagid, "tagid=%u"},
1999 @@ -596,6 +599,22 @@ int btrfs_parse_options(struct btrfs_roo
2003 +#ifndef CONFIG_TAGGING_NONE
2005 + printk(KERN_INFO "btrfs: use tagging\n");
2006 + btrfs_set_opt(info->mount_opt, TAGGED);
2009 + printk(KERN_INFO "btrfs: disabled tagging\n");
2010 + btrfs_clear_opt(info->mount_opt, TAGGED);
2013 +#ifdef CONFIG_PROPAGATE
2016 + btrfs_set_opt(info->mount_opt, TAGGED);
2020 printk(KERN_INFO "btrfs: unrecognized mount option "
2022 @@ -1196,6 +1215,12 @@ static int btrfs_remount(struct super_bl
2023 btrfs_resize_thread_pool(fs_info,
2024 fs_info->thread_pool_size, old_thread_pool_size);
2026 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2027 + printk("btrfs: %s: tagging not permitted on remount.\n",
2032 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2035 diff -NurpP --minimal linux-3.6/fs/char_dev.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/char_dev.c
2036 --- linux-3.6/fs/char_dev.c 2012-03-19 19:47:25.000000000 +0100
2037 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/char_dev.c 2012-10-04 18:47:00.000000000 +0200
2039 #include <linux/mutex.h>
2040 #include <linux/backing-dev.h>
2041 #include <linux/tty.h>
2042 +#include <linux/vs_context.h>
2043 +#include <linux/vs_device.h>
2045 #include "internal.h"
2047 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2049 struct cdev *new = NULL;
2053 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2055 + inode->i_mdev = mdev;
2057 spin_lock(&cdev_lock);
2060 struct kobject *kobj;
2063 spin_unlock(&cdev_lock);
2064 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2066 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2069 new = container_of(kobj, struct cdev, kobj);
2070 diff -NurpP --minimal linux-3.6/fs/dcache.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/dcache.c
2071 --- linux-3.6/fs/dcache.c 2012-10-04 15:27:39.000000000 +0200
2072 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/dcache.c 2012-10-04 18:47:00.000000000 +0200
2074 #include <linux/rculist_bl.h>
2075 #include <linux/prefetch.h>
2076 #include <linux/ratelimit.h>
2077 +#include <linux/vs_limit.h>
2078 #include "internal.h"
2081 @@ -617,6 +618,8 @@ int d_invalidate(struct dentry * dentry)
2082 spin_lock(&dentry->d_lock);
2085 + vx_dentry_dec(dentry);
2088 * Somebody else still using it?
2090 @@ -646,6 +649,7 @@ EXPORT_SYMBOL(d_invalidate);
2091 static inline void __dget_dlock(struct dentry *dentry)
2094 + vx_dentry_inc(dentry);
2097 static inline void __dget(struct dentry *dentry)
2098 @@ -1276,6 +1280,9 @@ struct dentry *__d_alloc(struct super_bl
2099 struct dentry *dentry;
2102 + if (!vx_dentry_avail(1))
2105 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2108 @@ -1308,6 +1315,7 @@ struct dentry *__d_alloc(struct super_bl
2110 dentry->d_count = 1;
2111 dentry->d_flags = 0;
2112 + vx_dentry_inc(dentry);
2113 spin_lock_init(&dentry->d_lock);
2114 seqcount_init(&dentry->d_seq);
2115 dentry->d_inode = NULL;
2116 @@ -2012,6 +2020,7 @@ struct dentry *__d_lookup(struct dentry
2120 + vx_dentry_inc(dentry);
2122 spin_unlock(&dentry->d_lock);
2124 diff -NurpP --minimal linux-3.6/fs/devpts/inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/devpts/inode.c
2125 --- linux-3.6/fs/devpts/inode.c 2012-10-04 15:27:39.000000000 +0200
2126 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/devpts/inode.c 2012-10-04 18:47:00.000000000 +0200
2128 #include <linux/parser.h>
2129 #include <linux/fsnotify.h>
2130 #include <linux/seq_file.h>
2131 +#include <linux/vs_base.h>
2133 #define DEVPTS_DEFAULT_MODE 0600
2136 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2137 #define PTMX_MINOR 2
2139 +static int devpts_permission(struct inode *inode, int mask)
2141 + int ret = -EACCES;
2143 + /* devpts is xid tagged */
2144 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2145 + ret = generic_permission(inode, mask);
2149 +static struct inode_operations devpts_file_inode_operations = {
2150 + .permission = devpts_permission,
2155 * sysctl support for setting limits on the number of Unix98 ptys allocated.
2156 * Otherwise one can eat up all kernel memory by opening /dev/ptmx repeatedly.
2157 @@ -336,6 +352,34 @@ static int devpts_show_options(struct se
2161 +static int devpts_filter(struct dentry *de)
2165 + /* devpts is xid tagged */
2166 + if (de && de->d_inode)
2167 + xid = (xid_t)de->d_inode->i_tag;
2168 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2170 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2171 + de->d_name.len, de->d_name.name);
2173 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2176 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2178 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2181 +static struct file_operations devpts_dir_operations = {
2182 + .open = dcache_dir_open,
2183 + .release = dcache_dir_close,
2184 + .llseek = dcache_dir_lseek,
2185 + .read = generic_read_dir,
2186 + .readdir = devpts_readdir,
2189 static const struct super_operations devpts_sops = {
2190 .statfs = simple_statfs,
2191 .remount_fs = devpts_remount,
2192 @@ -379,8 +423,10 @@ devpts_fill_super(struct super_block *s,
2193 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2194 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2195 inode->i_op = &simple_dir_inode_operations;
2196 - inode->i_fop = &simple_dir_operations;
2197 + inode->i_fop = &devpts_dir_operations;
2198 set_nlink(inode, 2);
2199 + /* devpts is xid tagged */
2200 + inode->i_tag = (tag_t)vx_current_xid();
2202 s->s_root = d_make_root(inode);
2204 @@ -572,6 +618,9 @@ int devpts_pty_new(struct inode *ptmx_in
2205 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2206 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2207 init_special_inode(inode, S_IFCHR|opts->mode, device);
2208 + /* devpts is xid tagged */
2209 + inode->i_tag = (tag_t)vx_current_xid();
2210 + inode->i_op = &devpts_file_inode_operations;
2211 inode->i_private = tty;
2212 tty->driver_data = inode;
2214 diff -NurpP --minimal linux-3.6/fs/ext2/balloc.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/balloc.c
2215 --- linux-3.6/fs/ext2/balloc.c 2012-10-04 15:27:39.000000000 +0200
2216 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/balloc.c 2012-10-04 18:47:00.000000000 +0200
2217 @@ -699,7 +699,6 @@ ext2_try_to_allocate(struct super_block
2219 end = EXT2_BLOCKS_PER_GROUP(sb);
2222 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2225 diff -NurpP --minimal linux-3.6/fs/ext2/ext2.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/ext2.h
2226 --- linux-3.6/fs/ext2/ext2.h 2012-07-22 23:39:39.000000000 +0200
2227 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/ext2.h 2012-10-04 18:47:00.000000000 +0200
2228 @@ -244,8 +244,12 @@ struct ext2_group_desc
2229 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
2230 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
2231 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
2232 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
2233 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
2235 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
2236 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
2238 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
2239 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
2241 @@ -329,7 +333,8 @@ struct ext2_inode {
2243 __le16 l_i_uid_high; /* these 2 fields */
2244 __le16 l_i_gid_high; /* were reserved2[0] */
2245 - __u32 l_i_reserved2;
2246 + __le16 l_i_tag; /* Context Tag */
2247 + __u16 l_i_reserved2;
2250 __u8 h_i_frag; /* Fragment number */
2251 @@ -357,6 +362,7 @@ struct ext2_inode {
2252 #define i_gid_low i_gid
2253 #define i_uid_high osd2.linux2.l_i_uid_high
2254 #define i_gid_high osd2.linux2.l_i_gid_high
2255 +#define i_raw_tag osd2.linux2.l_i_tag
2256 #define i_reserved2 osd2.linux2.l_i_reserved2
2259 @@ -384,6 +390,7 @@ struct ext2_inode {
2260 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
2261 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
2262 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
2263 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2266 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
2267 @@ -757,6 +764,7 @@ extern void ext2_set_inode_flags(struct
2268 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2269 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2270 u64 start, u64 len);
2271 +extern int ext2_sync_flags(struct inode *, int, int);
2274 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2275 diff -NurpP --minimal linux-3.6/fs/ext2/file.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/file.c
2276 --- linux-3.6/fs/ext2/file.c 2011-10-24 18:45:27.000000000 +0200
2277 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/file.c 2012-10-04 18:47:00.000000000 +0200
2278 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2279 .setattr = ext2_setattr,
2280 .get_acl = ext2_get_acl,
2281 .fiemap = ext2_fiemap,
2282 + .sync_flags = ext2_sync_flags,
2284 diff -NurpP --minimal linux-3.6/fs/ext2/ialloc.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/ialloc.c
2285 --- linux-3.6/fs/ext2/ialloc.c 2012-10-04 15:27:39.000000000 +0200
2286 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/ialloc.c 2012-10-04 18:47:00.000000000 +0200
2288 #include <linux/backing-dev.h>
2289 #include <linux/buffer_head.h>
2290 #include <linux/random.h>
2291 +#include <linux/vs_tag.h>
2295 @@ -547,6 +548,7 @@ got:
2296 inode->i_mode = mode;
2297 inode->i_uid = current_fsuid();
2298 inode->i_gid = dir->i_gid;
2299 + inode->i_tag = dx_current_fstag(sb);
2301 inode_init_owner(inode, dir, mode);
2303 diff -NurpP --minimal linux-3.6/fs/ext2/inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/inode.c
2304 --- linux-3.6/fs/ext2/inode.c 2012-10-04 15:27:39.000000000 +0200
2305 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/inode.c 2012-10-04 18:47:00.000000000 +0200
2307 #include <linux/mpage.h>
2308 #include <linux/fiemap.h>
2309 #include <linux/namei.h>
2310 +#include <linux/vs_tag.h>
2314 @@ -1165,7 +1166,7 @@ static void ext2_truncate_blocks(struct
2316 if (ext2_inode_is_fast_symlink(inode))
2318 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2319 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2321 __ext2_truncate_blocks(inode, offset);
2323 @@ -1256,36 +1257,61 @@ void ext2_set_inode_flags(struct inode *
2325 unsigned int flags = EXT2_I(inode)->i_flags;
2327 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2328 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2329 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2332 + if (flags & EXT2_IMMUTABLE_FL)
2333 + inode->i_flags |= S_IMMUTABLE;
2334 + if (flags & EXT2_IXUNLINK_FL)
2335 + inode->i_flags |= S_IXUNLINK;
2337 if (flags & EXT2_SYNC_FL)
2338 inode->i_flags |= S_SYNC;
2339 if (flags & EXT2_APPEND_FL)
2340 inode->i_flags |= S_APPEND;
2341 - if (flags & EXT2_IMMUTABLE_FL)
2342 - inode->i_flags |= S_IMMUTABLE;
2343 if (flags & EXT2_NOATIME_FL)
2344 inode->i_flags |= S_NOATIME;
2345 if (flags & EXT2_DIRSYNC_FL)
2346 inode->i_flags |= S_DIRSYNC;
2348 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2350 + if (flags & EXT2_BARRIER_FL)
2351 + inode->i_vflags |= V_BARRIER;
2352 + if (flags & EXT2_COW_FL)
2353 + inode->i_vflags |= V_COW;
2356 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2357 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2359 unsigned int flags = ei->vfs_inode.i_flags;
2360 + unsigned int vflags = ei->vfs_inode.i_vflags;
2362 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2363 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2364 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2365 + EXT2_BARRIER_FL | EXT2_COW_FL);
2367 + if (flags & S_IMMUTABLE)
2368 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2369 + if (flags & S_IXUNLINK)
2370 + ei->i_flags |= EXT2_IXUNLINK_FL;
2372 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2373 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2375 ei->i_flags |= EXT2_SYNC_FL;
2376 if (flags & S_APPEND)
2377 ei->i_flags |= EXT2_APPEND_FL;
2378 - if (flags & S_IMMUTABLE)
2379 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2380 if (flags & S_NOATIME)
2381 ei->i_flags |= EXT2_NOATIME_FL;
2382 if (flags & S_DIRSYNC)
2383 ei->i_flags |= EXT2_DIRSYNC_FL;
2385 + if (vflags & V_BARRIER)
2386 + ei->i_flags |= EXT2_BARRIER_FL;
2387 + if (vflags & V_COW)
2388 + ei->i_flags |= EXT2_COW_FL;
2391 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2392 @@ -1321,8 +1347,10 @@ struct inode *ext2_iget (struct super_bl
2393 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2394 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2396 - i_uid_write(inode, i_uid);
2397 - i_gid_write(inode, i_gid);
2398 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
2399 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
2400 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
2401 + le16_to_cpu(raw_inode->i_raw_tag));
2402 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2403 inode->i_size = le32_to_cpu(raw_inode->i_size);
2404 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2405 @@ -1420,8 +1448,8 @@ static int __ext2_write_inode(struct ino
2406 struct ext2_inode_info *ei = EXT2_I(inode);
2407 struct super_block *sb = inode->i_sb;
2408 ino_t ino = inode->i_ino;
2409 - uid_t uid = i_uid_read(inode);
2410 - gid_t gid = i_gid_read(inode);
2411 + uid_t uid = TAGINO_UID(DX_TAG(inode), i_uid_read(inode), inode->i_tag);
2412 + gid_t gid = TAGINO_GID(DX_TAG(inode), i_gid_read(inode), inode->i_tag);
2413 struct buffer_head * bh;
2414 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2416 @@ -1457,6 +1485,9 @@ static int __ext2_write_inode(struct ino
2417 raw_inode->i_uid_high = 0;
2418 raw_inode->i_gid_high = 0;
2420 +#ifdef CONFIG_TAGGING_INTERN
2421 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2423 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2424 raw_inode->i_size = cpu_to_le32(inode->i_size);
2425 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2426 @@ -1537,7 +1568,8 @@ int ext2_setattr(struct dentry *dentry,
2427 if (is_quota_modification(inode, iattr))
2428 dquot_initialize(inode);
2429 if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) ||
2430 - (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) {
2431 + (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid)) ||
2432 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2433 error = dquot_transfer(inode, iattr);
2436 diff -NurpP --minimal linux-3.6/fs/ext2/ioctl.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/ioctl.c
2437 --- linux-3.6/fs/ext2/ioctl.c 2012-03-19 19:47:25.000000000 +0100
2438 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/ioctl.c 2012-10-04 18:47:00.000000000 +0200
2440 #include <asm/uaccess.h>
2443 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2445 + inode->i_flags = flags;
2446 + inode->i_vflags = vflags;
2447 + ext2_get_inode_flags(EXT2_I(inode));
2448 + inode->i_ctime = CURRENT_TIME_SEC;
2449 + mark_inode_dirty(inode);
2453 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2455 struct inode *inode = filp->f_dentry->d_inode;
2456 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2458 flags = ext2_mask_flags(inode->i_mode, flags);
2460 + if (IS_BARRIER(inode)) {
2461 + vxwprintk_task(1, "messing with the barrier.");
2465 mutex_lock(&inode->i_mutex);
2466 /* Is it quota file? Do not allow user to mess with it */
2467 if (IS_NOQUOTA(inode)) {
2468 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2470 * This test looks nicer. Thanks to Pauline Middelink
2472 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2473 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2474 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2475 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2476 if (!capable(CAP_LINUX_IMMUTABLE)) {
2477 mutex_unlock(&inode->i_mutex);
2479 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2483 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2484 + flags &= EXT2_FL_USER_MODIFIABLE;
2485 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2486 ei->i_flags = flags;
2488 diff -NurpP --minimal linux-3.6/fs/ext2/namei.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/namei.c
2489 --- linux-3.6/fs/ext2/namei.c 2012-10-04 15:27:39.000000000 +0200
2490 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/namei.c 2012-10-04 18:47:00.000000000 +0200
2493 #include <linux/pagemap.h>
2494 #include <linux/quotaops.h>
2495 +#include <linux/vs_tag.h>
2499 @@ -73,6 +74,7 @@ static struct dentry *ext2_lookup(struct
2500 (unsigned long) ino);
2501 return ERR_PTR(-EIO);
2503 + dx_propagate_tag(nd, inode);
2505 return d_splice_alias(inode, dentry);
2507 @@ -397,6 +399,7 @@ const struct inode_operations ext2_dir_i
2508 .removexattr = generic_removexattr,
2510 .setattr = ext2_setattr,
2511 + .sync_flags = ext2_sync_flags,
2512 .get_acl = ext2_get_acl,
2515 diff -NurpP --minimal linux-3.6/fs/ext2/super.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/super.c
2516 --- linux-3.6/fs/ext2/super.c 2012-10-04 15:27:39.000000000 +0200
2517 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext2/super.c 2012-10-04 18:47:00.000000000 +0200
2518 @@ -390,7 +390,8 @@ enum {
2519 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2520 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2521 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2522 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2523 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2524 + Opt_tag, Opt_notag, Opt_tagid
2527 static const match_table_t tokens = {
2528 @@ -418,6 +419,9 @@ static const match_table_t tokens = {
2530 {Opt_noacl, "noacl"},
2533 + {Opt_notag, "notag"},
2534 + {Opt_tagid, "tagid=%u"},
2535 {Opt_grpquota, "grpquota"},
2536 {Opt_ignore, "noquota"},
2537 {Opt_quota, "quota"},
2538 @@ -501,6 +505,20 @@ static int parse_options(char *options,
2540 set_opt (sbi->s_mount_opt, NO_UID32);
2542 +#ifndef CONFIG_TAGGING_NONE
2544 + set_opt (sbi->s_mount_opt, TAGGED);
2547 + clear_opt (sbi->s_mount_opt, TAGGED);
2550 +#ifdef CONFIG_PROPAGATE
2553 + set_opt (sbi->s_mount_opt, TAGGED);
2557 clear_opt (sbi->s_mount_opt, CHECK);
2559 @@ -859,6 +877,8 @@ static int ext2_fill_super(struct super_
2560 if (!parse_options((char *) data, sb))
2563 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2564 + sb->s_flags |= MS_TAGGED;
2565 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2566 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2568 @@ -1265,6 +1285,14 @@ static int ext2_remount (struct super_bl
2572 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2573 + !(sb->s_flags & MS_TAGGED)) {
2574 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2577 + goto restore_opts;
2580 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2581 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2583 diff -NurpP --minimal linux-3.6/fs/ext3/ext3.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/ext3.h
2584 --- linux-3.6/fs/ext3/ext3.h 2012-07-22 23:39:39.000000000 +0200
2585 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/ext3.h 2012-10-04 18:47:00.000000000 +0200
2586 @@ -151,10 +151,14 @@ struct ext3_group_desc
2587 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
2588 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
2589 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
2590 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2591 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
2593 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
2594 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
2595 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2596 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
2598 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
2599 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
2601 /* Flags that should be inherited by new inodes from their parent. */
2602 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
2603 @@ -290,7 +294,8 @@ struct ext3_inode {
2605 __le16 l_i_uid_high; /* these 2 fields */
2606 __le16 l_i_gid_high; /* were reserved2[0] */
2607 - __u32 l_i_reserved2;
2608 + __le16 l_i_tag; /* Context Tag */
2609 + __u16 l_i_reserved2;
2612 __u8 h_i_frag; /* Fragment number */
2613 @@ -320,6 +325,7 @@ struct ext3_inode {
2614 #define i_gid_low i_gid
2615 #define i_uid_high osd2.linux2.l_i_uid_high
2616 #define i_gid_high osd2.linux2.l_i_gid_high
2617 +#define i_raw_tag osd2.linux2.l_i_tag
2618 #define i_reserved2 osd2.linux2.l_i_reserved2
2621 @@ -364,6 +370,7 @@ struct ext3_inode {
2622 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
2623 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
2624 * error in ordered mode */
2625 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2627 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
2628 #ifndef _LINUX_EXT2_FS_H
2629 @@ -1061,6 +1068,7 @@ extern void ext3_get_inode_flags(struct
2630 extern void ext3_set_aops(struct inode *inode);
2631 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2632 u64 start, u64 len);
2633 +extern int ext3_sync_flags(struct inode *, int, int);
2636 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
2637 diff -NurpP --minimal linux-3.6/fs/ext3/file.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/file.c
2638 --- linux-3.6/fs/ext3/file.c 2012-05-21 18:07:20.000000000 +0200
2639 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/file.c 2012-10-04 18:47:00.000000000 +0200
2640 @@ -76,5 +76,6 @@ const struct inode_operations ext3_file_
2642 .get_acl = ext3_get_acl,
2643 .fiemap = ext3_fiemap,
2644 + .sync_flags = ext3_sync_flags,
2647 diff -NurpP --minimal linux-3.6/fs/ext3/ialloc.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/ialloc.c
2648 --- linux-3.6/fs/ext3/ialloc.c 2012-07-22 23:39:39.000000000 +0200
2649 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/ialloc.c 2012-10-04 18:47:00.000000000 +0200
2652 #include <linux/quotaops.h>
2653 #include <linux/random.h>
2654 +#include <linux/vs_tag.h>
2658 @@ -469,6 +470,7 @@ got:
2659 inode->i_mode = mode;
2660 inode->i_uid = current_fsuid();
2661 inode->i_gid = dir->i_gid;
2662 + inode->i_tag = dx_current_fstag(sb);
2664 inode_init_owner(inode, dir, mode);
2666 diff -NurpP --minimal linux-3.6/fs/ext3/inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/inode.c
2667 --- linux-3.6/fs/ext3/inode.c 2012-10-04 15:27:39.000000000 +0200
2668 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/inode.c 2012-10-04 18:47:00.000000000 +0200
2670 #include <linux/writeback.h>
2671 #include <linux/mpage.h>
2672 #include <linux/namei.h>
2673 +#include <linux/vs_tag.h>
2678 @@ -2848,36 +2850,60 @@ void ext3_set_inode_flags(struct inode *
2680 unsigned int flags = EXT3_I(inode)->i_flags;
2682 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2683 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2684 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2686 + if (flags & EXT3_IMMUTABLE_FL)
2687 + inode->i_flags |= S_IMMUTABLE;
2688 + if (flags & EXT3_IXUNLINK_FL)
2689 + inode->i_flags |= S_IXUNLINK;
2691 if (flags & EXT3_SYNC_FL)
2692 inode->i_flags |= S_SYNC;
2693 if (flags & EXT3_APPEND_FL)
2694 inode->i_flags |= S_APPEND;
2695 - if (flags & EXT3_IMMUTABLE_FL)
2696 - inode->i_flags |= S_IMMUTABLE;
2697 if (flags & EXT3_NOATIME_FL)
2698 inode->i_flags |= S_NOATIME;
2699 if (flags & EXT3_DIRSYNC_FL)
2700 inode->i_flags |= S_DIRSYNC;
2702 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2704 + if (flags & EXT3_BARRIER_FL)
2705 + inode->i_vflags |= V_BARRIER;
2706 + if (flags & EXT3_COW_FL)
2707 + inode->i_vflags |= V_COW;
2710 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2711 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2713 unsigned int flags = ei->vfs_inode.i_flags;
2714 + unsigned int vflags = ei->vfs_inode.i_vflags;
2716 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2717 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2718 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2719 + EXT3_BARRIER_FL | EXT3_COW_FL);
2721 + if (flags & S_IMMUTABLE)
2722 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2723 + if (flags & S_IXUNLINK)
2724 + ei->i_flags |= EXT3_IXUNLINK_FL;
2726 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2727 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2729 ei->i_flags |= EXT3_SYNC_FL;
2730 if (flags & S_APPEND)
2731 ei->i_flags |= EXT3_APPEND_FL;
2732 - if (flags & S_IMMUTABLE)
2733 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2734 if (flags & S_NOATIME)
2735 ei->i_flags |= EXT3_NOATIME_FL;
2736 if (flags & S_DIRSYNC)
2737 ei->i_flags |= EXT3_DIRSYNC_FL;
2739 + if (vflags & V_BARRIER)
2740 + ei->i_flags |= EXT3_BARRIER_FL;
2741 + if (vflags & V_COW)
2742 + ei->i_flags |= EXT3_COW_FL;
2745 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2746 @@ -2915,8 +2941,10 @@ struct inode *ext3_iget(struct super_blo
2747 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2748 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2750 - i_uid_write(inode, i_uid);
2751 - i_gid_write(inode, i_gid);
2752 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
2753 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
2754 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
2755 + le16_to_cpu(raw_inode->i_raw_tag));
2756 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2757 inode->i_size = le32_to_cpu(raw_inode->i_size);
2758 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2759 @@ -3088,8 +3116,8 @@ again:
2761 ext3_get_inode_flags(ei);
2762 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2763 - i_uid = i_uid_read(inode);
2764 - i_gid = i_gid_read(inode);
2765 + i_uid = TAGINO_UID(DX_TAG(inode), i_uid_read(inode), inode->i_tag);
2766 + i_gid = TAGINO_GID(DX_TAG(inode), i_gid_read(inode), inode->i_tag);
2767 if(!(test_opt(inode->i_sb, NO_UID32))) {
2768 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
2769 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
2770 @@ -3114,6 +3142,9 @@ again:
2771 raw_inode->i_uid_high = 0;
2772 raw_inode->i_gid_high = 0;
2774 +#ifdef CONFIG_TAGGING_INTERN
2775 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2777 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2778 disksize = cpu_to_le32(ei->i_disksize);
2779 if (disksize != raw_inode->i_size) {
2780 @@ -3282,7 +3313,8 @@ int ext3_setattr(struct dentry *dentry,
2781 if (is_quota_modification(inode, attr))
2782 dquot_initialize(inode);
2783 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
2784 - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
2785 + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
2786 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
2789 /* (user+group)*(old+new) structure, inode write (sb,
2790 @@ -3304,6 +3336,8 @@ int ext3_setattr(struct dentry *dentry,
2791 inode->i_uid = attr->ia_uid;
2792 if (attr->ia_valid & ATTR_GID)
2793 inode->i_gid = attr->ia_gid;
2794 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2795 + inode->i_tag = attr->ia_tag;
2796 error = ext3_mark_inode_dirty(handle, inode);
2797 ext3_journal_stop(handle);
2799 diff -NurpP --minimal linux-3.6/fs/ext3/ioctl.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/ioctl.c
2800 --- linux-3.6/fs/ext3/ioctl.c 2012-05-21 18:07:20.000000000 +0200
2801 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/ioctl.c 2012-10-04 18:47:00.000000000 +0200
2803 #include <asm/uaccess.h>
2807 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
2809 + handle_t *handle = NULL;
2810 + struct ext3_iloc iloc;
2813 + handle = ext3_journal_start(inode, 1);
2814 + if (IS_ERR(handle))
2815 + return PTR_ERR(handle);
2817 + if (IS_SYNC(inode))
2818 + handle->h_sync = 1;
2819 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2823 + inode->i_flags = flags;
2824 + inode->i_vflags = vflags;
2825 + ext3_get_inode_flags(EXT3_I(inode));
2826 + inode->i_ctime = CURRENT_TIME_SEC;
2828 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2830 + ext3_journal_stop(handle);
2834 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2836 struct inode *inode = filp->f_dentry->d_inode;
2837 @@ -45,6 +73,11 @@ long ext3_ioctl(struct file *filp, unsig
2839 flags = ext3_mask_flags(inode->i_mode, flags);
2841 + if (IS_BARRIER(inode)) {
2842 + vxwprintk_task(1, "messing with the barrier.");
2846 mutex_lock(&inode->i_mutex);
2848 /* Is it quota file? Do not allow user to mess with it */
2849 @@ -63,7 +96,9 @@ long ext3_ioctl(struct file *filp, unsig
2851 * This test looks nicer. Thanks to Pauline Middelink
2853 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
2854 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
2855 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
2856 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
2857 if (!capable(CAP_LINUX_IMMUTABLE))
2860 @@ -88,7 +123,7 @@ long ext3_ioctl(struct file *filp, unsig
2864 - flags = flags & EXT3_FL_USER_MODIFIABLE;
2865 + flags &= EXT3_FL_USER_MODIFIABLE;
2866 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
2867 ei->i_flags = flags;
2869 diff -NurpP --minimal linux-3.6/fs/ext3/namei.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/namei.c
2870 --- linux-3.6/fs/ext3/namei.c 2012-10-04 15:27:39.000000000 +0200
2871 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/namei.c 2012-10-04 18:47:00.000000000 +0200
2875 #include <linux/quotaops.h>
2876 +#include <linux/vs_tag.h>
2881 @@ -915,6 +917,7 @@ restart:
2882 submit_bh(READ | REQ_META | REQ_PRIO,
2885 + dx_propagate_tag(nd, inode);
2888 if ((bh = bh_use[ra_ptr++]) == NULL)
2889 @@ -2526,6 +2529,7 @@ const struct inode_operations ext3_dir_i
2890 .listxattr = ext3_listxattr,
2891 .removexattr = generic_removexattr,
2893 + .sync_flags = ext3_sync_flags,
2894 .get_acl = ext3_get_acl,
2897 diff -NurpP --minimal linux-3.6/fs/ext3/super.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/super.c
2898 --- linux-3.6/fs/ext3/super.c 2012-10-04 15:27:39.000000000 +0200
2899 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext3/super.c 2012-10-04 18:47:00.000000000 +0200
2900 @@ -811,7 +811,8 @@ enum {
2901 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
2902 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
2903 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
2904 - Opt_resize, Opt_usrquota, Opt_grpquota
2905 + Opt_resize, Opt_usrquota, Opt_grpquota,
2906 + Opt_tag, Opt_notag, Opt_tagid
2909 static const match_table_t tokens = {
2910 @@ -868,6 +869,9 @@ static const match_table_t tokens = {
2911 {Opt_barrier, "barrier"},
2912 {Opt_nobarrier, "nobarrier"},
2913 {Opt_resize, "resize"},
2915 + {Opt_notag, "notag"},
2916 + {Opt_tagid, "tagid=%u"},
2920 @@ -1033,6 +1037,20 @@ static int parse_options (char *options,
2922 set_opt (sbi->s_mount_opt, NO_UID32);
2924 +#ifndef CONFIG_TAGGING_NONE
2926 + set_opt (sbi->s_mount_opt, TAGGED);
2929 + clear_opt (sbi->s_mount_opt, TAGGED);
2932 +#ifdef CONFIG_PROPAGATE
2935 + set_opt (sbi->s_mount_opt, TAGGED);
2939 clear_opt (sbi->s_mount_opt, CHECK);
2941 @@ -1731,6 +1749,9 @@ static int ext3_fill_super (struct super
2945 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
2946 + sb->s_flags |= MS_TAGGED;
2948 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2949 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2951 @@ -2618,6 +2639,14 @@ static int ext3_remount (struct super_bl
2952 if (test_opt(sb, ABORT))
2953 ext3_abort(sb, __func__, "Abort forced by user");
2955 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
2956 + !(sb->s_flags & MS_TAGGED)) {
2957 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
2960 + goto restore_opts;
2963 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2964 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2966 diff -NurpP --minimal linux-3.6/fs/ext4/ext4.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/ext4.h
2967 --- linux-3.6/fs/ext4/ext4.h 2012-10-04 15:27:39.000000000 +0200
2968 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/ext4.h 2012-10-04 18:47:00.000000000 +0200
2969 @@ -393,8 +393,12 @@ struct flex_groups {
2970 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
2971 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
2972 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
2973 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2974 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
2976 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2977 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
2979 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
2980 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
2982 @@ -666,7 +670,7 @@ struct ext4_inode {
2983 __le16 l_i_uid_high; /* these 2 fields */
2984 __le16 l_i_gid_high; /* were reserved2[0] */
2985 __le16 l_i_checksum_lo;/* crc32c(uuid+inum+inode) LE */
2986 - __le16 l_i_reserved;
2987 + __le16 l_i_tag; /* Context Tag */
2990 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
2991 @@ -784,6 +788,7 @@ do { \
2992 #define i_gid_low i_gid
2993 #define i_uid_high osd2.linux2.l_i_uid_high
2994 #define i_gid_high osd2.linux2.l_i_gid_high
2995 +#define i_raw_tag osd2.linux2.l_i_tag
2996 #define i_checksum_lo osd2.linux2.l_i_checksum_lo
2998 #elif defined(__GNU__)
2999 @@ -964,6 +969,7 @@ struct ext4_inode_info {
3000 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3001 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3002 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3003 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3004 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3005 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3006 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3007 @@ -2393,6 +2399,7 @@ extern int ext4_map_blocks(handle_t *han
3008 struct ext4_map_blocks *map, int flags);
3009 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3010 __u64 start, __u64 len);
3011 +extern int ext4_sync_flags(struct inode *, int, int);
3013 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3014 __u64 start_orig, __u64 start_donor,
3015 diff -NurpP --minimal linux-3.6/fs/ext4/file.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/file.c
3016 --- linux-3.6/fs/ext4/file.c 2012-10-04 15:27:39.000000000 +0200
3017 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/file.c 2012-10-04 18:47:00.000000000 +0200
3018 @@ -334,5 +334,6 @@ const struct inode_operations ext4_file_
3020 .get_acl = ext4_get_acl,
3021 .fiemap = ext4_fiemap,
3022 + .sync_flags = ext4_sync_flags,
3025 diff -NurpP --minimal linux-3.6/fs/ext4/ialloc.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/ialloc.c
3026 --- linux-3.6/fs/ext4/ialloc.c 2012-10-04 15:27:39.000000000 +0200
3027 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/ialloc.c 2012-10-04 18:47:00.000000000 +0200
3029 #include <linux/random.h>
3030 #include <linux/bitops.h>
3031 #include <linux/blkdev.h>
3032 +#include <linux/vs_tag.h>
3033 #include <asm/byteorder.h>
3036 @@ -842,6 +843,7 @@ got:
3037 inode->i_mode = mode;
3038 inode->i_uid = current_fsuid();
3039 inode->i_gid = dir->i_gid;
3040 + inode->i_tag = dx_current_fstag(sb);
3042 inode_init_owner(inode, dir, mode);
3044 diff -NurpP --minimal linux-3.6/fs/ext4/inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/inode.c
3045 --- linux-3.6/fs/ext4/inode.c 2012-10-04 15:27:39.000000000 +0200
3046 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/inode.c 2012-10-04 18:47:00.000000000 +0200
3048 #include <linux/printk.h>
3049 #include <linux/slab.h>
3050 #include <linux/ratelimit.h>
3051 +#include <linux/vs_tag.h>
3053 #include "ext4_jbd2.h"
3055 @@ -3712,41 +3713,64 @@ void ext4_set_inode_flags(struct inode *
3057 unsigned int flags = EXT4_I(inode)->i_flags;
3059 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3060 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3061 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3063 + if (flags & EXT4_IMMUTABLE_FL)
3064 + inode->i_flags |= S_IMMUTABLE;
3065 + if (flags & EXT4_IXUNLINK_FL)
3066 + inode->i_flags |= S_IXUNLINK;
3068 if (flags & EXT4_SYNC_FL)
3069 inode->i_flags |= S_SYNC;
3070 if (flags & EXT4_APPEND_FL)
3071 inode->i_flags |= S_APPEND;
3072 - if (flags & EXT4_IMMUTABLE_FL)
3073 - inode->i_flags |= S_IMMUTABLE;
3074 if (flags & EXT4_NOATIME_FL)
3075 inode->i_flags |= S_NOATIME;
3076 if (flags & EXT4_DIRSYNC_FL)
3077 inode->i_flags |= S_DIRSYNC;
3079 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3081 + if (flags & EXT4_BARRIER_FL)
3082 + inode->i_vflags |= V_BARRIER;
3083 + if (flags & EXT4_COW_FL)
3084 + inode->i_vflags |= V_COW;
3087 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3088 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3090 - unsigned int vfs_fl;
3091 + unsigned int vfs_fl, vfs_vf;
3092 unsigned long old_fl, new_fl;
3095 vfs_fl = ei->vfs_inode.i_flags;
3096 + vfs_vf = ei->vfs_inode.i_vflags;
3097 old_fl = ei->i_flags;
3098 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3099 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3101 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3104 + if (vfs_fl & S_IMMUTABLE)
3105 + new_fl |= EXT4_IMMUTABLE_FL;
3106 + if (vfs_fl & S_IXUNLINK)
3107 + new_fl |= EXT4_IXUNLINK_FL;
3109 if (vfs_fl & S_SYNC)
3110 new_fl |= EXT4_SYNC_FL;
3111 if (vfs_fl & S_APPEND)
3112 new_fl |= EXT4_APPEND_FL;
3113 - if (vfs_fl & S_IMMUTABLE)
3114 - new_fl |= EXT4_IMMUTABLE_FL;
3115 if (vfs_fl & S_NOATIME)
3116 new_fl |= EXT4_NOATIME_FL;
3117 if (vfs_fl & S_DIRSYNC)
3118 new_fl |= EXT4_DIRSYNC_FL;
3120 + if (vfs_vf & V_BARRIER)
3121 + new_fl |= EXT4_BARRIER_FL;
3122 + if (vfs_vf & V_COW)
3123 + new_fl |= EXT4_COW_FL;
3124 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3127 @@ -3838,8 +3862,10 @@ struct inode *ext4_iget(struct super_blo
3128 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3129 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3131 - i_uid_write(inode, i_uid);
3132 - i_gid_write(inode, i_gid);
3133 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
3134 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
3135 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
3136 + le16_to_cpu(raw_inode->i_raw_tag));
3137 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
3139 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3140 @@ -4062,8 +4088,8 @@ static int ext4_do_update_inode(handle_t
3142 ext4_get_inode_flags(ei);
3143 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3144 - i_uid = i_uid_read(inode);
3145 - i_gid = i_gid_read(inode);
3146 + i_uid = TAGINO_UID(DX_TAG(inode), i_uid_read(inode), inode->i_tag);
3147 + i_gid = TAGINO_GID(DX_TAG(inode), i_gid_read(inode), inode->i_tag);
3148 if (!(test_opt(inode->i_sb, NO_UID32))) {
3149 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
3150 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
3151 @@ -4086,6 +4112,9 @@ static int ext4_do_update_inode(handle_t
3152 raw_inode->i_uid_high = 0;
3153 raw_inode->i_gid_high = 0;
3155 +#ifdef CONFIG_TAGGING_INTERN
3156 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3158 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3160 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3161 @@ -4271,7 +4300,8 @@ int ext4_setattr(struct dentry *dentry,
3162 if (is_quota_modification(inode, attr))
3163 dquot_initialize(inode);
3164 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
3165 - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
3166 + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
3167 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3170 /* (user+group)*(old+new) structure, inode write (sb,
3171 @@ -4293,6 +4323,8 @@ int ext4_setattr(struct dentry *dentry,
3172 inode->i_uid = attr->ia_uid;
3173 if (attr->ia_valid & ATTR_GID)
3174 inode->i_gid = attr->ia_gid;
3175 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3176 + inode->i_tag = attr->ia_tag;
3177 error = ext4_mark_inode_dirty(handle, inode);
3178 ext4_journal_stop(handle);
3180 diff -NurpP --minimal linux-3.6/fs/ext4/ioctl.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/ioctl.c
3181 --- linux-3.6/fs/ext4/ioctl.c 2012-10-04 15:27:39.000000000 +0200
3182 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/ioctl.c 2012-10-04 18:47:00.000000000 +0200
3184 #include <linux/compat.h>
3185 #include <linux/mount.h>
3186 #include <linux/file.h>
3187 +#include <linux/vs_tag.h>
3188 #include <asm/uaccess.h>
3189 #include "ext4_jbd2.h"
3192 #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1)
3194 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3196 + handle_t *handle = NULL;
3197 + struct ext4_iloc iloc;
3200 + handle = ext4_journal_start(inode, 1);
3201 + if (IS_ERR(handle))
3202 + return PTR_ERR(handle);
3204 + if (IS_SYNC(inode))
3205 + ext4_handle_sync(handle);
3206 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3210 + inode->i_flags = flags;
3211 + inode->i_vflags = vflags;
3212 + ext4_get_inode_flags(EXT4_I(inode));
3213 + inode->i_ctime = ext4_current_time(inode);
3215 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3217 + ext4_journal_stop(handle);
3221 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3223 struct inode *inode = filp->f_dentry->d_inode;
3224 @@ -53,6 +81,11 @@ long ext4_ioctl(struct file *filp, unsig
3226 flags = ext4_mask_flags(inode->i_mode, flags);
3228 + if (IS_BARRIER(inode)) {
3229 + vxwprintk_task(1, "messing with the barrier.");
3234 mutex_lock(&inode->i_mutex);
3235 /* Is it quota file? Do not allow user to mess with it */
3236 @@ -70,7 +103,9 @@ long ext4_ioctl(struct file *filp, unsig
3238 * This test looks nicer. Thanks to Pauline Middelink
3240 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3241 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3242 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3243 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3244 if (!capable(CAP_LINUX_IMMUTABLE))
3247 diff -NurpP --minimal linux-3.6/fs/ext4/namei.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/namei.c
3248 --- linux-3.6/fs/ext4/namei.c 2012-10-04 15:27:39.000000000 +0200
3249 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/namei.c 2012-10-04 18:47:00.000000000 +0200
3251 #include <linux/quotaops.h>
3252 #include <linux/buffer_head.h>
3253 #include <linux/bio.h>
3254 +#include <linux/vs_tag.h>
3256 #include "ext4_jbd2.h"
3258 @@ -1199,6 +1200,7 @@ restart:
3259 ll_rw_block(READ | REQ_META | REQ_PRIO,
3262 + dx_propagate_tag(nd, inode);
3264 if ((bh = bh_use[ra_ptr++]) == NULL)
3266 @@ -2984,6 +2986,7 @@ const struct inode_operations ext4_dir_i
3268 .get_acl = ext4_get_acl,
3269 .fiemap = ext4_fiemap,
3270 + .sync_flags = ext4_sync_flags,
3273 const struct inode_operations ext4_special_inode_operations = {
3274 diff -NurpP --minimal linux-3.6/fs/ext4/super.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/super.c
3275 --- linux-3.6/fs/ext4/super.c 2012-10-04 15:27:39.000000000 +0200
3276 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ext4/super.c 2012-10-04 18:47:00.000000000 +0200
3277 @@ -1219,6 +1219,7 @@ enum {
3278 Opt_inode_readahead_blks, Opt_journal_ioprio,
3279 Opt_dioread_nolock, Opt_dioread_lock,
3280 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
3281 + Opt_tag, Opt_notag, Opt_tagid
3284 static const match_table_t tokens = {
3285 @@ -1297,6 +1298,9 @@ static const match_table_t tokens = {
3286 {Opt_removed, "reservation"}, /* mount option from ext2/3 */
3287 {Opt_removed, "noreservation"}, /* mount option from ext2/3 */
3288 {Opt_removed, "journal=%u"}, /* mount option from ext2/3 */
3290 + {Opt_notag, "notag"},
3291 + {Opt_tagid, "tagid=%u"},
3295 @@ -1543,6 +1547,20 @@ static int handle_mount_opt(struct super
3297 *journal_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, arg);
3299 +#ifndef CONFIG_TAGGING_NONE
3301 + set_opt(sb, TAGGED);
3304 + clear_opt(sb, TAGGED);
3307 +#ifdef CONFIG_PROPAGATE
3310 + set_opt(sb, TAGGED);
3315 for (m = ext4_mount_opts; m->token != Opt_err; m++) {
3316 @@ -3417,6 +3435,9 @@ static int ext4_fill_super(struct super_
3320 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3321 + sb->s_flags |= MS_TAGGED;
3323 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3324 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3326 @@ -4582,6 +4603,14 @@ static int ext4_remount(struct super_blo
3327 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3328 ext4_abort(sb, "Abort forced by user");
3330 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3331 + !(sb->s_flags & MS_TAGGED)) {
3332 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3335 + goto restore_opts;
3338 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3339 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3341 diff -NurpP --minimal linux-3.6/fs/fcntl.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/fcntl.c
3342 --- linux-3.6/fs/fcntl.c 2012-10-04 15:27:39.000000000 +0200
3343 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/fcntl.c 2012-10-04 19:05:02.000000000 +0200
3345 #include <linux/rcupdate.h>
3346 #include <linux/pid_namespace.h>
3347 #include <linux/user_namespace.h>
3348 +#include <linux/vs_limit.h>
3350 #include <asm/poll.h>
3351 #include <asm/siginfo.h>
3352 @@ -104,6 +105,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3355 filp_close(tofree, files);
3357 + vx_openfd_inc(newfd); /* fd was unused */
3361 @@ -477,6 +480,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3362 filp = fget_raw_light(fd, &fput_needed);
3365 + if (!vx_files_avail(1))
3368 if (unlikely(filp->f_mode & FMODE_PATH)) {
3369 if (!check_fcntl_cmd(cmd))
3370 diff -NurpP --minimal linux-3.6/fs/file.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/file.c
3371 --- linux-3.6/fs/file.c 2012-05-21 18:07:20.000000000 +0200
3372 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/file.c 2012-10-04 18:47:00.000000000 +0200
3374 #include <linux/spinlock.h>
3375 #include <linux/rcupdate.h>
3376 #include <linux/workqueue.h>
3377 +#include <linux/vs_limit.h>
3379 struct fdtable_defer {
3381 @@ -358,6 +359,8 @@ struct files_struct *dup_fd(struct files
3382 struct file *f = *old_fds++;
3385 + /* TODO: sum it first for check and performance */
3386 + vx_openfd_inc(open_files - i);
3389 * The fd may be claimed in the fd bitmap but not yet
3390 @@ -464,6 +467,7 @@ repeat:
3392 __clear_close_on_exec(fd, fdt);
3394 + vx_openfd_inc(fd);
3397 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3398 diff -NurpP --minimal linux-3.6/fs/file_table.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/file_table.c
3399 --- linux-3.6/fs/file_table.c 2012-10-04 15:27:39.000000000 +0200
3400 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/file_table.c 2012-10-04 19:10:21.000000000 +0200
3402 #include <linux/hardirq.h>
3403 #include <linux/task_work.h>
3404 #include <linux/ima.h>
3405 +#include <linux/vs_limit.h>
3406 +#include <linux/vs_context.h>
3408 #include <linux/atomic.h>
3410 @@ -136,6 +138,8 @@ struct file *get_empty_filp(void)
3411 spin_lock_init(&f->f_lock);
3412 eventpoll_init_file(f);
3413 /* f->f_version: 0 */
3414 + f->f_xid = vx_current_xid();
3419 @@ -257,6 +261,8 @@ static void __fput(struct file *file)
3420 i_readcount_dec(inode);
3421 if (file->f_mode & FMODE_WRITE)
3422 drop_file_write_access(file);
3423 + vx_files_dec(file);
3425 file->f_path.dentry = NULL;
3426 file->f_path.mnt = NULL;
3428 @@ -449,6 +455,8 @@ void put_filp(struct file *file)
3430 if (atomic_long_dec_and_test(&file->f_count)) {
3431 security_file_free(file);
3432 + vx_files_dec(file);
3434 file_sb_list_del(file);
3437 diff -NurpP --minimal linux-3.6/fs/fs_struct.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/fs_struct.c
3438 --- linux-3.6/fs/fs_struct.c 2012-10-04 15:27:39.000000000 +0200
3439 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/fs_struct.c 2012-10-04 19:08:56.000000000 +0200
3441 #include <linux/path.h>
3442 #include <linux/slab.h>
3443 #include <linux/fs_struct.h>
3444 +#include <linux/vserver/global.h>
3445 #include "internal.h"
3448 @@ -87,6 +88,7 @@ void free_fs_struct(struct fs_struct *fs
3450 path_put(&fs->root);
3452 + atomic_dec(&vs_global_fs);
3453 kmem_cache_free(fs_cachep, fs);
3456 @@ -124,6 +126,7 @@ struct fs_struct *copy_fs_struct(struct
3459 spin_unlock(&old->lock);
3460 + atomic_inc(&vs_global_fs);
3464 diff -NurpP --minimal linux-3.6/fs/gfs2/file.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/gfs2/file.c
3465 --- linux-3.6/fs/gfs2/file.c 2012-10-04 15:27:40.000000000 +0200
3466 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/gfs2/file.c 2012-10-04 19:05:34.000000000 +0200
3467 @@ -143,6 +143,9 @@ static const u32 fsflags_to_gfs2[32] = {
3468 [12] = GFS2_DIF_EXHASH,
3469 [14] = GFS2_DIF_INHERIT_JDATA,
3470 [17] = GFS2_DIF_TOPDIR,
3471 + [27] = GFS2_DIF_IXUNLINK,
3472 + [26] = GFS2_DIF_BARRIER,
3473 + [29] = GFS2_DIF_COW,
3476 static const u32 gfs2_to_fsflags[32] = {
3477 @@ -153,6 +156,9 @@ static const u32 gfs2_to_fsflags[32] = {
3478 [gfs2fl_ExHash] = FS_INDEX_FL,
3479 [gfs2fl_TopLevel] = FS_TOPDIR_FL,
3480 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
3481 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
3482 + [gfs2fl_Barrier] = FS_BARRIER_FL,
3483 + [gfs2fl_Cow] = FS_COW_FL,
3486 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
3487 @@ -183,12 +189,18 @@ void gfs2_set_inode_flags(struct inode *
3489 struct gfs2_inode *ip = GFS2_I(inode);
3490 unsigned int flags = inode->i_flags;
3491 + unsigned int vflags = inode->i_vflags;
3493 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3494 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC | S_NOSEC);
3496 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
3497 if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
3498 inode->i_flags |= S_NOSEC;
3499 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
3500 flags |= S_IMMUTABLE;
3501 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
3502 + flags |= S_IXUNLINK;
3504 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
3506 if (ip->i_diskflags & GFS2_DIF_NOATIME)
3507 @@ -196,6 +208,43 @@ void gfs2_set_inode_flags(struct inode *
3508 if (ip->i_diskflags & GFS2_DIF_SYNC)
3510 inode->i_flags = flags;
3512 + vflags &= ~(V_BARRIER | V_COW);
3514 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
3515 + vflags |= V_BARRIER;
3516 + if (ip->i_diskflags & GFS2_DIF_COW)
3518 + inode->i_vflags = vflags;
3521 +void gfs2_get_inode_flags(struct inode *inode)
3523 + struct gfs2_inode *ip = GFS2_I(inode);
3524 + unsigned int flags = inode->i_flags;
3525 + unsigned int vflags = inode->i_vflags;
3527 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
3528 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
3529 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
3530 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
3532 + if (flags & S_IMMUTABLE)
3533 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
3534 + if (flags & S_IXUNLINK)
3535 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
3537 + if (flags & S_APPEND)
3538 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
3539 + if (flags & S_NOATIME)
3540 + ip->i_diskflags |= GFS2_DIF_NOATIME;
3541 + if (flags & S_SYNC)
3542 + ip->i_diskflags |= GFS2_DIF_SYNC;
3544 + if (vflags & V_BARRIER)
3545 + ip->i_diskflags |= GFS2_DIF_BARRIER;
3546 + if (vflags & V_COW)
3547 + ip->i_diskflags |= GFS2_DIF_COW;
3550 /* Flags that can be set by user space */
3551 @@ -309,6 +358,37 @@ static int gfs2_set_flags(struct file *f
3552 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
3555 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
3557 + struct gfs2_inode *ip = GFS2_I(inode);
3558 + struct gfs2_sbd *sdp = GFS2_SB(inode);
3559 + struct buffer_head *bh;
3560 + struct gfs2_holder gh;
3563 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
3566 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
3569 + error = gfs2_meta_inode_buffer(ip, &bh);
3571 + goto out_trans_end;
3572 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
3573 + inode->i_flags = flags;
3574 + inode->i_vflags = vflags;
3575 + gfs2_get_inode_flags(inode);
3576 + gfs2_dinode_out(ip, bh->b_data);
3578 + gfs2_set_aops(inode);
3580 + gfs2_trans_end(sdp);
3582 + gfs2_glock_dq_uninit(&gh);
3586 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3589 diff -NurpP --minimal linux-3.6/fs/gfs2/inode.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/gfs2/inode.h
3590 --- linux-3.6/fs/gfs2/inode.h 2012-07-22 23:39:40.000000000 +0200
3591 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/gfs2/inode.h 2012-10-04 18:47:00.000000000 +0200
3592 @@ -117,6 +117,7 @@ extern const struct file_operations gfs2
3593 extern const struct file_operations gfs2_dir_fops_nolock;
3595 extern void gfs2_set_inode_flags(struct inode *inode);
3596 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
3598 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
3599 extern const struct file_operations gfs2_file_fops;
3600 diff -NurpP --minimal linux-3.6/fs/inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/inode.c
3601 --- linux-3.6/fs/inode.c 2012-10-04 15:27:40.000000000 +0200
3602 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/inode.c 2012-10-04 18:47:00.000000000 +0200
3604 #include <linux/prefetch.h>
3605 #include <linux/buffer_head.h> /* for inode_has_buffers */
3606 #include <linux/ratelimit.h>
3607 +#include <linux/vs_tag.h>
3608 #include "internal.h"
3611 @@ -128,6 +129,9 @@ int inode_init_always(struct super_block
3612 struct address_space *const mapping = &inode->i_data;
3616 + /* essential because of inode slab reuse */
3618 inode->i_blkbits = sb->s_blocksize_bits;
3620 atomic_set(&inode->i_count, 1);
3621 @@ -149,6 +153,7 @@ int inode_init_always(struct super_block
3622 inode->i_bdev = NULL;
3623 inode->i_cdev = NULL;
3625 + inode->i_mdev = 0;
3626 inode->dirtied_when = 0;
3628 if (security_inode_alloc(inode))
3629 @@ -470,6 +475,8 @@ void __insert_inode_hash(struct inode *i
3631 EXPORT_SYMBOL(__insert_inode_hash);
3633 +EXPORT_SYMBOL_GPL(__iget);
3636 * __remove_inode_hash - remove an inode from the hash
3637 * @inode: inode to unhash
3638 @@ -1792,9 +1799,11 @@ void init_special_inode(struct inode *in
3639 if (S_ISCHR(mode)) {
3640 inode->i_fop = &def_chr_fops;
3641 inode->i_rdev = rdev;
3642 + inode->i_mdev = rdev;
3643 } else if (S_ISBLK(mode)) {
3644 inode->i_fop = &def_blk_fops;
3645 inode->i_rdev = rdev;
3646 + inode->i_mdev = rdev;
3647 } else if (S_ISFIFO(mode))
3648 inode->i_fop = &def_fifo_fops;
3649 else if (S_ISSOCK(mode))
3650 @@ -1823,6 +1832,7 @@ void inode_init_owner(struct inode *inod
3652 inode->i_gid = current_fsgid();
3653 inode->i_mode = mode;
3654 + inode->i_tag = dx_current_fstag(inode->i_sb);
3656 EXPORT_SYMBOL(inode_init_owner);
3658 diff -NurpP --minimal linux-3.6/fs/ioctl.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ioctl.c
3659 --- linux-3.6/fs/ioctl.c 2012-05-21 18:07:24.000000000 +0200
3660 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ioctl.c 2012-10-04 18:47:00.000000000 +0200
3662 #include <linux/writeback.h>
3663 #include <linux/buffer_head.h>
3664 #include <linux/falloc.h>
3665 +#include <linux/proc_fs.h>
3666 +#include <linux/vserver/inode.h>
3667 +#include <linux/vs_tag.h>
3669 #include <asm/ioctls.h>
3671 diff -NurpP --minimal linux-3.6/fs/ioprio.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ioprio.c
3672 --- linux-3.6/fs/ioprio.c 2012-07-22 23:39:40.000000000 +0200
3673 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ioprio.c 2012-10-04 18:47:00.000000000 +0200
3675 #include <linux/syscalls.h>
3676 #include <linux/security.h>
3677 #include <linux/pid_namespace.h>
3678 +#include <linux/vs_base.h>
3680 int set_task_ioprio(struct task_struct *task, int ioprio)
3682 @@ -105,6 +106,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3684 pgrp = find_vpid(who);
3685 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3686 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3688 ret = set_task_ioprio(p, ioprio);
3691 @@ -198,6 +201,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3693 pgrp = find_vpid(who);
3694 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3695 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3697 tmpio = get_task_ioprio(p);
3700 diff -NurpP --minimal linux-3.6/fs/jfs/file.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/file.c
3701 --- linux-3.6/fs/jfs/file.c 2011-10-24 18:45:27.000000000 +0200
3702 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/file.c 2012-10-04 18:47:00.000000000 +0200
3703 @@ -109,7 +109,8 @@ int jfs_setattr(struct dentry *dentry, s
3704 if (is_quota_modification(inode, iattr))
3705 dquot_initialize(inode);
3706 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3707 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3708 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3709 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3710 rc = dquot_transfer(inode, iattr);
3713 @@ -142,6 +143,7 @@ const struct inode_operations jfs_file_i
3714 #ifdef CONFIG_JFS_POSIX_ACL
3715 .get_acl = jfs_get_acl,
3717 + .sync_flags = jfs_sync_flags,
3720 const struct file_operations jfs_file_operations = {
3721 diff -NurpP --minimal linux-3.6/fs/jfs/ioctl.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/ioctl.c
3722 --- linux-3.6/fs/jfs/ioctl.c 2012-03-19 19:47:25.000000000 +0100
3723 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/ioctl.c 2012-10-04 18:47:00.000000000 +0200
3725 #include <linux/mount.h>
3726 #include <linux/time.h>
3727 #include <linux/sched.h>
3728 +#include <linux/mount.h>
3729 #include <asm/current.h>
3730 #include <asm/uaccess.h>
3732 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
3736 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
3738 + inode->i_flags = flags;
3739 + inode->i_vflags = vflags;
3740 + jfs_get_inode_flags(JFS_IP(inode));
3741 + inode->i_ctime = CURRENT_TIME_SEC;
3742 + mark_inode_dirty(inode);
3746 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3748 struct inode *inode = filp->f_dentry->d_inode;
3749 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
3750 if (!S_ISDIR(inode->i_mode))
3751 flags &= ~JFS_DIRSYNC_FL;
3753 + if (IS_BARRIER(inode)) {
3754 + vxwprintk_task(1, "messing with the barrier.");
3758 /* Is it quota file? Do not allow user to mess with it */
3759 if (IS_NOQUOTA(inode)) {
3761 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
3762 * the relevant capability.
3764 if ((oldflags & JFS_IMMUTABLE_FL) ||
3765 - ((flags ^ oldflags) &
3766 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3767 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3768 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3769 if (!capable(CAP_LINUX_IMMUTABLE)) {
3770 mutex_unlock(&inode->i_mutex);
3772 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
3776 - flags = flags & JFS_FL_USER_MODIFIABLE;
3777 + flags &= JFS_FL_USER_MODIFIABLE;
3778 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
3779 jfs_inode->mode2 = flags;
3781 diff -NurpP --minimal linux-3.6/fs/jfs/jfs_dinode.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/jfs_dinode.h
3782 --- linux-3.6/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
3783 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/jfs_dinode.h 2012-10-04 18:47:00.000000000 +0200
3784 @@ -161,9 +161,13 @@ struct dinode {
3786 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3787 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3788 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3790 -#define JFS_FL_USER_VISIBLE 0x03F80000
3791 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3792 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3793 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3795 +#define JFS_FL_USER_VISIBLE 0x07F80000
3796 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3797 #define JFS_FL_INHERIT 0x03C80000
3799 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3800 diff -NurpP --minimal linux-3.6/fs/jfs/jfs_filsys.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/jfs_filsys.h
3801 --- linux-3.6/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
3802 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/jfs_filsys.h 2012-10-04 18:47:00.000000000 +0200
3804 #define JFS_NAME_MAX 255
3805 #define JFS_PATH_MAX BPSIZE
3807 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
3810 * file system state (superblock state)
3811 diff -NurpP --minimal linux-3.6/fs/jfs/jfs_imap.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/jfs_imap.c
3812 --- linux-3.6/fs/jfs/jfs_imap.c 2012-01-09 16:14:54.000000000 +0100
3813 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/jfs_imap.c 2012-10-04 18:47:00.000000000 +0200
3815 #include <linux/pagemap.h>
3816 #include <linux/quotaops.h>
3817 #include <linux/slab.h>
3818 +#include <linux/vs_tag.h>
3820 #include "jfs_incore.h"
3821 #include "jfs_inode.h"
3822 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
3824 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3825 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
3829 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
3830 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
3831 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
3833 set_nlink(ip, le32_to_cpu(dip->di_nlink));
3835 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
3836 + uid = le32_to_cpu(dip->di_uid);
3837 + gid = le32_to_cpu(dip->di_gid);
3838 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
3840 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
3842 ip->i_uid = jfs_ip->saved_uid;
3844 ip->i_uid = sbi->uid;
3847 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
3848 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
3850 ip->i_gid = jfs_ip->saved_gid;
3852 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
3853 dip->di_size = cpu_to_le64(ip->i_size);
3854 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
3855 dip->di_nlink = cpu_to_le32(ip->i_nlink);
3856 - if (sbi->uid == -1)
3857 - dip->di_uid = cpu_to_le32(ip->i_uid);
3859 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
3860 - if (sbi->gid == -1)
3861 - dip->di_gid = cpu_to_le32(ip->i_gid);
3863 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
3865 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
3866 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
3867 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
3868 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
3870 jfs_get_inode_flags(jfs_ip);
3872 * mode2 is only needed for storing the higher order bits.
3873 diff -NurpP --minimal linux-3.6/fs/jfs/jfs_inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/jfs_inode.c
3874 --- linux-3.6/fs/jfs/jfs_inode.c 2012-01-09 16:14:54.000000000 +0100
3875 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/jfs_inode.c 2012-10-04 18:47:00.000000000 +0200
3878 #include <linux/fs.h>
3879 #include <linux/quotaops.h>
3880 +#include <linux/vs_tag.h>
3881 #include "jfs_incore.h"
3882 #include "jfs_inode.h"
3883 #include "jfs_filsys.h"
3884 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
3886 unsigned int flags = JFS_IP(inode)->mode2;
3888 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
3889 - S_NOATIME | S_DIRSYNC | S_SYNC);
3890 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3891 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3893 if (flags & JFS_IMMUTABLE_FL)
3894 inode->i_flags |= S_IMMUTABLE;
3895 + if (flags & JFS_IXUNLINK_FL)
3896 + inode->i_flags |= S_IXUNLINK;
3898 + if (flags & JFS_SYNC_FL)
3899 + inode->i_flags |= S_SYNC;
3900 if (flags & JFS_APPEND_FL)
3901 inode->i_flags |= S_APPEND;
3902 if (flags & JFS_NOATIME_FL)
3903 inode->i_flags |= S_NOATIME;
3904 if (flags & JFS_DIRSYNC_FL)
3905 inode->i_flags |= S_DIRSYNC;
3906 - if (flags & JFS_SYNC_FL)
3907 - inode->i_flags |= S_SYNC;
3909 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3911 + if (flags & JFS_BARRIER_FL)
3912 + inode->i_vflags |= V_BARRIER;
3913 + if (flags & JFS_COW_FL)
3914 + inode->i_vflags |= V_COW;
3917 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
3919 unsigned int flags = jfs_ip->vfs_inode.i_flags;
3920 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
3922 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
3923 + JFS_APPEND_FL | JFS_NOATIME_FL |
3924 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
3925 + JFS_BARRIER_FL | JFS_COW_FL);
3927 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
3928 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
3929 if (flags & S_IMMUTABLE)
3930 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
3931 + if (flags & S_IXUNLINK)
3932 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
3934 if (flags & S_APPEND)
3935 jfs_ip->mode2 |= JFS_APPEND_FL;
3936 if (flags & S_NOATIME)
3937 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
3938 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
3940 jfs_ip->mode2 |= JFS_SYNC_FL;
3942 + if (vflags & V_BARRIER)
3943 + jfs_ip->mode2 |= JFS_BARRIER_FL;
3944 + if (vflags & V_COW)
3945 + jfs_ip->mode2 |= JFS_COW_FL;
3949 diff -NurpP --minimal linux-3.6/fs/jfs/jfs_inode.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/jfs_inode.h
3950 --- linux-3.6/fs/jfs/jfs_inode.h 2011-10-24 18:45:27.000000000 +0200
3951 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/jfs_inode.h 2012-10-04 18:47:00.000000000 +0200
3952 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
3953 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
3954 int fh_len, int fh_type);
3955 extern void jfs_set_inode_flags(struct inode *);
3956 +extern int jfs_sync_flags(struct inode *, int, int);
3957 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
3958 extern int jfs_setattr(struct dentry *, struct iattr *);
3960 diff -NurpP --minimal linux-3.6/fs/jfs/namei.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/namei.c
3961 --- linux-3.6/fs/jfs/namei.c 2012-10-04 15:27:40.000000000 +0200
3962 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/namei.c 2012-10-04 18:47:00.000000000 +0200
3964 #include <linux/ctype.h>
3965 #include <linux/quotaops.h>
3966 #include <linux/exportfs.h>
3967 +#include <linux/vs_tag.h>
3968 #include "jfs_incore.h"
3969 #include "jfs_superblock.h"
3970 #include "jfs_inode.h"
3971 @@ -1461,6 +1462,7 @@ static struct dentry *jfs_lookup(struct
3972 jfs_err("jfs_lookup: iget failed on inum %d", (uint)inum);
3975 + dx_propagate_tag(nd, ip);
3976 return d_splice_alias(ip, dentry);
3979 @@ -1525,6 +1527,7 @@ const struct inode_operations jfs_dir_in
3980 #ifdef CONFIG_JFS_POSIX_ACL
3981 .get_acl = jfs_get_acl,
3983 + .sync_flags = jfs_sync_flags,
3986 const struct file_operations jfs_dir_operations = {
3987 diff -NurpP --minimal linux-3.6/fs/jfs/super.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/super.c
3988 --- linux-3.6/fs/jfs/super.c 2012-10-04 15:27:40.000000000 +0200
3989 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/jfs/super.c 2012-10-04 18:47:00.000000000 +0200
3990 @@ -197,7 +197,8 @@ static void jfs_put_super(struct super_b
3992 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
3993 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
3994 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
3995 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
3996 + Opt_tag, Opt_notag, Opt_tagid
3999 static const match_table_t tokens = {
4000 @@ -207,6 +208,10 @@ static const match_table_t tokens = {
4001 {Opt_resize, "resize=%u"},
4002 {Opt_resize_nosize, "resize"},
4003 {Opt_errors, "errors=%s"},
4005 + {Opt_notag, "notag"},
4006 + {Opt_tagid, "tagid=%u"},
4007 + {Opt_tag, "tagxid"},
4008 {Opt_ignore, "noquota"},
4009 {Opt_ignore, "quota"},
4010 {Opt_usrquota, "usrquota"},
4011 @@ -341,6 +346,20 @@ static int parse_options(char *options,
4015 +#ifndef CONFIG_TAGGING_NONE
4017 + *flag |= JFS_TAGGED;
4020 + *flag &= JFS_TAGGED;
4023 +#ifdef CONFIG_PROPAGATE
4026 + *flag |= JFS_TAGGED;
4030 printk("jfs: Unrecognized mount option \"%s\" "
4031 " or missing value\n", p);
4032 @@ -372,6 +391,12 @@ static int jfs_remount(struct super_bloc
4036 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4037 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4043 if (sb->s_flags & MS_RDONLY) {
4045 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
4046 #ifdef CONFIG_JFS_POSIX_ACL
4047 sb->s_flags |= MS_POSIXACL;
4049 + /* map mount option tagxid */
4050 + if (sbi->flag & JFS_TAGGED)
4051 + sb->s_flags |= MS_TAGGED;
4054 printk(KERN_ERR "resize option for remount only\n");
4055 diff -NurpP --minimal linux-3.6/fs/libfs.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/libfs.c
4056 --- linux-3.6/fs/libfs.c 2012-10-04 15:27:40.000000000 +0200
4057 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/libfs.c 2012-10-04 18:47:00.000000000 +0200
4058 @@ -135,7 +135,8 @@ static inline unsigned char dt_type(stru
4059 * both impossible due to the lock on directory.
4062 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4063 +static inline int do_dcache_readdir_filter(struct file *filp,
4064 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4066 struct dentry *dentry = filp->f_path.dentry;
4067 struct dentry *cursor = filp->private_data;
4068 @@ -166,6 +167,8 @@ int dcache_readdir(struct file * filp, v
4069 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4070 struct dentry *next;
4071 next = list_entry(p, struct dentry, d_u.d_child);
4072 + if (filter && !filter(next))
4074 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4075 if (!simple_positive(next)) {
4076 spin_unlock(&next->d_lock);
4077 @@ -192,6 +195,17 @@ int dcache_readdir(struct file * filp, v
4081 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4083 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4086 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4087 + int (*filter)(struct dentry *))
4089 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4092 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4095 @@ -983,6 +997,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4096 EXPORT_SYMBOL(dcache_dir_lseek);
4097 EXPORT_SYMBOL(dcache_dir_open);
4098 EXPORT_SYMBOL(dcache_readdir);
4099 +EXPORT_SYMBOL(dcache_readdir_filter);
4100 EXPORT_SYMBOL(generic_read_dir);
4101 EXPORT_SYMBOL(mount_pseudo);
4102 EXPORT_SYMBOL(simple_write_begin);
4103 diff -NurpP --minimal linux-3.6/fs/locks.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/locks.c
4104 --- linux-3.6/fs/locks.c 2012-10-04 15:27:40.000000000 +0200
4105 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/locks.c 2012-10-04 18:47:00.000000000 +0200
4107 #include <linux/time.h>
4108 #include <linux/rcupdate.h>
4109 #include <linux/pid_namespace.h>
4110 +#include <linux/vs_base.h>
4111 +#include <linux/vs_limit.h>
4113 #include <asm/uaccess.h>
4115 @@ -184,11 +186,17 @@ static void locks_init_lock_heads(struct
4116 /* Allocate an empty lock structure. */
4117 struct file_lock *locks_alloc_lock(void)
4119 - struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4120 + struct file_lock *fl;
4123 - locks_init_lock_heads(fl);
4124 + if (!vx_locks_avail(1))
4127 + fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4130 + locks_init_lock_heads(fl);
4135 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4136 @@ -212,6 +220,7 @@ void locks_free_lock(struct file_lock *f
4137 BUG_ON(!list_empty(&fl->fl_block));
4138 BUG_ON(!list_empty(&fl->fl_link));
4141 locks_release_private(fl);
4142 kmem_cache_free(filelock_cache, fl);
4144 @@ -221,6 +230,7 @@ void locks_init_lock(struct file_lock *f
4146 memset(fl, 0, sizeof(struct file_lock));
4147 locks_init_lock_heads(fl);
4151 EXPORT_SYMBOL(locks_init_lock);
4152 @@ -261,6 +271,7 @@ void locks_copy_lock(struct file_lock *n
4153 new->fl_file = fl->fl_file;
4154 new->fl_ops = fl->fl_ops;
4155 new->fl_lmops = fl->fl_lmops;
4156 + new->fl_xid = fl->fl_xid;
4158 locks_copy_private(new, fl);
4160 @@ -299,6 +310,11 @@ static int flock_make_lock(struct file *
4161 fl->fl_flags = FL_FLOCK;
4163 fl->fl_end = OFFSET_MAX;
4165 + vxd_assert(filp->f_xid == vx_current_xid(),
4166 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4167 + fl->fl_xid = filp->f_xid;
4172 @@ -438,6 +454,7 @@ static int lease_init(struct file *filp,
4174 fl->fl_owner = current->files;
4175 fl->fl_pid = current->tgid;
4176 + fl->fl_xid = vx_current_xid();
4179 fl->fl_flags = FL_LEASE;
4180 @@ -457,6 +474,11 @@ static struct file_lock *lease_alloc(str
4182 return ERR_PTR(error);
4184 + fl->fl_xid = vx_current_xid();
4186 + vxd_assert(filp->f_xid == fl->fl_xid,
4187 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4189 error = lease_init(filp, type, fl);
4191 locks_free_lock(fl);
4192 @@ -753,6 +775,7 @@ static int flock_lock_file(struct file *
4196 + new_fl->fl_xid = -1;
4198 for_each_lock(inode, before) {
4199 struct file_lock *fl = *before;
4200 @@ -773,6 +796,7 @@ find_conflict:
4202 locks_copy_lock(new_fl, request);
4203 locks_insert_lock(before, new_fl);
4204 + vx_locks_inc(new_fl);
4208 @@ -783,7 +807,8 @@ out:
4212 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4213 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4214 + struct file_lock *conflock, xid_t xid)
4216 struct file_lock *fl;
4217 struct file_lock *new_fl = NULL;
4218 @@ -793,6 +818,8 @@ static int __posix_lock_file(struct inod
4219 struct file_lock **before;
4220 int error, added = 0;
4222 + vxd_assert(xid == vx_current_xid(),
4223 + "xid(%d) == current(%d)", xid, vx_current_xid());
4225 * We may need two file_lock structures for this operation,
4226 * so we get them in advance to avoid races.
4227 @@ -803,7 +830,11 @@ static int __posix_lock_file(struct inod
4228 (request->fl_type != F_UNLCK ||
4229 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4230 new_fl = locks_alloc_lock();
4231 + new_fl->fl_xid = xid;
4232 + vx_locks_inc(new_fl);
4233 new_fl2 = locks_alloc_lock();
4234 + new_fl2->fl_xid = xid;
4235 + vx_locks_inc(new_fl2);
4239 @@ -1002,7 +1033,8 @@ static int __posix_lock_file(struct inod
4240 int posix_lock_file(struct file *filp, struct file_lock *fl,
4241 struct file_lock *conflock)
4243 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4244 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4245 + fl, conflock, filp->f_xid);
4247 EXPORT_SYMBOL(posix_lock_file);
4249 @@ -1092,7 +1124,7 @@ int locks_mandatory_area(int read_write,
4250 fl.fl_end = offset + count - 1;
4253 - error = __posix_lock_file(inode, &fl, NULL);
4254 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4255 if (error != FILE_LOCK_DEFERRED)
4257 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4258 @@ -1397,6 +1429,7 @@ int generic_add_lease(struct file *filp,
4261 locks_insert_lock(before, lease);
4262 + vx_locks_inc(lease);
4266 @@ -1838,6 +1871,11 @@ int fcntl_setlk(unsigned int fd, struct
4267 if (file_lock == NULL)
4270 + vxd_assert(filp->f_xid == vx_current_xid(),
4271 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4272 + file_lock->fl_xid = filp->f_xid;
4273 + vx_locks_inc(file_lock);
4276 * This might block, so we do it before checking the inode.
4278 @@ -1956,6 +1994,11 @@ int fcntl_setlk64(unsigned int fd, struc
4279 if (file_lock == NULL)
4282 + vxd_assert(filp->f_xid == vx_current_xid(),
4283 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4284 + file_lock->fl_xid = filp->f_xid;
4285 + vx_locks_inc(file_lock);
4288 * This might block, so we do it before checking the inode.
4290 @@ -2221,8 +2264,11 @@ static int locks_show(struct seq_file *f
4292 lock_get_status(f, fl, *((loff_t *)f->private), "");
4294 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4295 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4296 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4298 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4303 diff -NurpP --minimal linux-3.6/fs/mount.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/mount.h
4304 --- linux-3.6/fs/mount.h 2012-10-04 15:27:40.000000000 +0200
4305 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/mount.h 2012-10-04 18:47:00.000000000 +0200
4306 @@ -46,6 +46,7 @@ struct mount {
4307 int mnt_expiry_mark; /* true if marked for expiry */
4310 + tag_t mnt_tag; /* tagging used for vfsmount */
4313 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
4314 diff -NurpP --minimal linux-3.6/fs/namei.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/namei.c
4315 --- linux-3.6/fs/namei.c 2012-10-04 15:27:40.000000000 +0200
4316 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/namei.c 2012-10-04 19:08:15.000000000 +0200
4318 #include <linux/device_cgroup.h>
4319 #include <linux/fs_struct.h>
4320 #include <linux/posix_acl.h>
4321 +#include <linux/proc_fs.h>
4322 +#include <linux/vserver/inode.h>
4323 +#include <linux/vs_base.h>
4324 +#include <linux/vs_tag.h>
4325 +#include <linux/vs_cowbl.h>
4326 +#include <linux/vs_device.h>
4327 +#include <linux/vs_context.h>
4328 +#include <linux/pid_namespace.h>
4329 #include <asm/uaccess.h>
4331 #include "internal.h"
4332 @@ -212,6 +220,89 @@ static int check_acl(struct inode *inode
4336 +static inline int dx_barrier(const struct inode *inode)
4338 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4339 + vxwprintk_task(1, "did hit the barrier.");
4345 +static int __dx_permission(const struct inode *inode, int mask)
4347 + if (dx_barrier(inode))
4350 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4351 + /* devpts is xid tagged */
4352 + if (S_ISDIR(inode->i_mode) ||
4353 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4356 + /* just pretend we didn't find anything */
4359 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4360 + struct proc_dir_entry *de = PDE(inode);
4362 + if (de && !vx_hide_check(0, de->vx_flags))
4365 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4367 + struct task_struct *tsk;
4369 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4370 + vx_flags(VXF_STATE_SETUP, 0))
4373 + pid = PROC_I(inode)->pid;
4378 + tsk = pid_task(pid, PIDTYPE_PID);
4379 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4380 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4382 + vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P)) {
4383 + rcu_read_unlock();
4386 + rcu_read_unlock();
4389 + /* FIXME: Should we block some entries here? */
4394 + if (dx_notagcheck(inode->i_sb) ||
4395 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4404 +int dx_permission(const struct inode *inode, int mask)
4406 + int ret = __dx_permission(inode, mask);
4407 + if (unlikely(ret)) {
4408 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4409 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4412 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4413 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4420 * This does the basic permission checking
4422 @@ -334,10 +425,14 @@ int __inode_permission(struct inode *ino
4424 * Nobody gets write access to an immutable file.
4426 - if (IS_IMMUTABLE(inode))
4427 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4431 + retval = dx_permission(inode, mask);
4435 retval = do_inode_permission(inode, mask);
4438 @@ -1189,7 +1284,8 @@ static void follow_dotdot(struct nameida
4440 if (nd->path.dentry == nd->root.dentry &&
4441 nd->path.mnt == nd->root.mnt) {
4443 + /* for sane '/' avoid follow_mount() */
4446 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4447 /* rare case of legitimate dget_parent()... */
4448 @@ -1338,6 +1434,9 @@ static int lookup_fast(struct nameidata
4453 + /* FIXME: check dx permission */
4456 path->dentry = dentry;
4457 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
4458 @@ -1373,6 +1472,8 @@ unlazy:
4462 + /* FIXME: check dx permission */
4465 path->dentry = dentry;
4466 err = follow_managed(path, nd->flags);
4467 @@ -2192,7 +2293,7 @@ static int may_delete(struct inode *dir,
4470 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4471 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4472 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4475 if (!S_ISDIR(victim->d_inode->i_mode))
4476 @@ -2271,19 +2372,25 @@ int vfs_create(struct inode *dir, struct
4479 int error = may_create(dir, dentry);
4483 + vxdprintk(VXD_CBIT(misc, 3), "may_create failed with %d", error);
4487 if (!dir->i_op->create)
4488 return -EACCES; /* shouldn't it be ENOSYS? */
4491 error = security_inode_create(dir, dentry, mode);
4495 + vxdprintk(VXD_CBIT(misc, 3), "security_inode_create failed with %d", error);
4498 error = dir->i_op->create(dir, dentry, mode, want_excl);
4500 fsnotify_create(dir, dentry);
4502 + vxdprintk(VXD_CBIT(misc, 3), "i_op->create failed with %d", error);
4506 @@ -2318,6 +2425,15 @@ static int may_open(struct path *path, i
4510 +#ifdef CONFIG_VSERVER_COWBL
4511 + if (IS_COW(inode) &&
4512 + ((flag & O_ACCMODE) != O_RDONLY)) {
4513 + if (IS_COW_LINK(inode))
4515 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4516 + mark_inode_dirty(inode);
4519 error = inode_permission(inode, acc_mode);
4522 @@ -2820,6 +2936,16 @@ finish_open:
4524 finish_open_created:
4525 error = may_open(&nd->path, acc_mode, open_flag);
4526 +#ifdef CONFIG_VSERVER_COWBL
4527 + if (error == -EMLINK) {
4528 + struct dentry *dentry;
4529 + dentry = cow_break_link(pathname);
4530 + if (IS_ERR(dentry))
4531 + error = PTR_ERR(dentry);
4538 file->f_path.mnt = nd->path.mnt;
4539 @@ -2884,6 +3010,7 @@ static struct file *path_openat(int dfd,
4544 file = get_empty_filp();
4546 return ERR_PTR(-ENFILE);
4547 @@ -2920,6 +3047,17 @@ static struct file *path_openat(int dfd,
4548 error = do_last(nd, &path, file, op, &opened, pathname);
4549 put_link(nd, &link, cookie);
4552 +#ifdef CONFIG_VSERVER_COWBL
4553 + if (filp == ERR_PTR(-EMLINK)) {
4554 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4555 + path_put(&nd->root);
4558 + release_open_intent(nd);
4563 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4564 path_put(&nd->root);
4565 @@ -3023,6 +3161,11 @@ struct dentry *kern_path_create(int dfd,
4569 + vxdprintk(VXD_CBIT(misc, 3), "kern_path_create path.dentry = %p (%.*s), dentry = %p (%.*s), d_inode = %p",
4570 + path->dentry, path->dentry->d_name.len,
4571 + path->dentry->d_name.name, dentry,
4572 + dentry->d_name.len, dentry->d_name.name,
4573 + path->dentry->d_inode);
4577 @@ -3489,7 +3632,7 @@ int vfs_link(struct dentry *old_dentry,
4579 * A link to an append-only or immutable file cannot be created.
4581 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4582 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4584 if (!dir->i_op->link)
4586 @@ -3874,6 +4017,253 @@ int vfs_follow_link(struct nameidata *nd
4587 return __vfs_follow_link(nd, link);
4591 +#ifdef CONFIG_VSERVER_COWBL
4594 +long do_cow_splice(struct file *in, struct file *out, size_t len)
4598 + return do_splice_direct(in, &ppos, out, len, 0);
4601 +extern unsigned int mnt_get_count(struct mount *mnt);
4603 +struct dentry *cow_break_link(const char *pathname)
4605 + int ret, mode, pathlen, redo = 0;
4606 + struct nameidata old_nd, dir_nd;
4607 + struct path old_path, dir_path;
4608 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
4609 + struct file *old_file;
4610 + struct file *new_file;
4611 + char *to, *path, pad='\251';
4614 + vxdprintk(VXD_CBIT(misc, 1),
4615 + "cow_break_link(" VS_Q("%s") ")", pathname);
4616 + path = kmalloc(PATH_MAX, GFP_KERNEL);
4621 + /* old_nd will have refs to dentry and mnt */
4622 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4623 + vxdprintk(VXD_CBIT(misc, 2),
4624 + "do_path_lookup(old): %d [r=%d]",
4625 + ret, mnt_get_count(real_mount(old_nd.path.mnt)));
4627 + goto out_free_path;
4629 + old_path = old_nd.path;
4630 + old_dentry = old_path.dentry;
4631 + mode = old_dentry->d_inode->i_mode;
4633 + to = d_path(&old_path, path, PATH_MAX-2);
4634 + pathlen = strlen(to);
4635 + vxdprintk(VXD_CBIT(misc, 2),
4636 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
4638 + old_dentry->d_name.len, old_dentry->d_name.name,
4639 + old_dentry->d_name.len);
4641 + to[pathlen + 1] = 0;
4643 + new_dentry = NULL;
4644 + to[pathlen] = pad--;
4646 + if (pad <= '\240')
4649 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
4650 + /* dir_nd will have refs to dentry and mnt */
4651 + ret = do_path_lookup(AT_FDCWD, to,
4652 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
4653 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
4657 + /* this puppy downs the dir inode mutex if successful */
4658 + new_dentry = kern_path_create(AT_FDCWD, to, &dir_path, 0);
4659 + if (!new_dentry || IS_ERR(new_dentry)) {
4660 + path_put(&dir_nd.path);
4661 + vxdprintk(VXD_CBIT(misc, 2),
4662 + "kern_path_create(new) failed with %ld",
4663 + PTR_ERR(new_dentry));
4666 + path_put(&dir_path);
4667 + vxdprintk(VXD_CBIT(misc, 2),
4668 + "kern_path_create(new): %p [" VS_Q("%.*s") ":%d]",
4670 + new_dentry->d_name.len, new_dentry->d_name.name,
4671 + new_dentry->d_name.len);
4673 + dir = dir_nd.path.dentry;
4675 + ret = vfs_create(dir->d_inode, new_dentry, mode, &dir_nd);
4676 + vxdprintk(VXD_CBIT(misc, 2),
4677 + "vfs_create(new): %d", ret);
4678 + if (ret == -EEXIST) {
4679 + mutex_unlock(&dir->d_inode->i_mutex);
4680 + path_put(&dir_nd.path);
4685 + goto out_unlock_new;
4687 + /* drop out early, ret passes ENOENT */
4689 + if ((redo = d_unhashed(old_dentry)))
4690 + goto out_unlock_new;
4692 + path_get(&old_path);
4693 + /* this one cleans up the dentry/mnt in case of failure */
4694 + old_file = dentry_open(old_dentry, old_path.mnt,
4695 + O_RDONLY, current_cred());
4696 + vxdprintk(VXD_CBIT(misc, 2),
4697 + "dentry_open(old): %p", old_file);
4698 + if (IS_ERR(old_file)) {
4699 + ret = PTR_ERR(old_file);
4700 + goto out_unlock_new;
4704 + mntget(old_path.mnt);
4705 + /* this one cleans up the dentry/mnt in case of failure */
4706 + new_file = dentry_open(new_dentry, old_path.mnt,
4707 + O_WRONLY, current_cred());
4708 + vxdprintk(VXD_CBIT(misc, 2),
4709 + "dentry_open(new): %p", new_file);
4710 + if (IS_ERR(new_file)) {
4711 + ret = PTR_ERR(new_file);
4712 + goto out_fput_old;
4715 + size = i_size_read(old_file->f_dentry->d_inode);
4716 + ret = do_cow_splice(old_file, new_file, size);
4717 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
4719 + goto out_fput_both;
4720 + } else if (ret < size) {
4722 + goto out_fput_both;
4724 + struct inode *old_inode = old_dentry->d_inode;
4725 + struct inode *new_inode = new_dentry->d_inode;
4726 + struct iattr attr = {
4727 + .ia_uid = old_inode->i_uid,
4728 + .ia_gid = old_inode->i_gid,
4729 + .ia_valid = ATTR_UID | ATTR_GID
4732 + setattr_copy(new_inode, &attr);
4733 + mark_inode_dirty(new_inode);
4736 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4738 + /* drop out late */
4740 + if ((redo = d_unhashed(old_dentry)))
4743 + vxdprintk(VXD_CBIT(misc, 2),
4744 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
4745 + new_dentry->d_name.len, new_dentry->d_name.name,
4746 + new_dentry->d_name.len,
4747 + old_dentry->d_name.len, old_dentry->d_name.name,
4748 + old_dentry->d_name.len);
4749 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
4750 + old_dentry->d_parent->d_inode, old_dentry);
4751 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
4754 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4757 + vxdprintk(VXD_CBIT(misc, 3),
4758 + "fput(new_file=%p[#%ld])", new_file,
4759 + atomic_long_read(&new_file->f_count));
4763 + vxdprintk(VXD_CBIT(misc, 3),
4764 + "fput(old_file=%p[#%ld])", old_file,
4765 + atomic_long_read(&old_file->f_count));
4769 + mutex_unlock(&dir->d_inode->i_mutex);
4773 + /* error path cleanup */
4774 + vfs_unlink(dir->d_inode, new_dentry);
4778 + goto out_rel_both;
4779 + /* lookup dentry once again */
4780 + /* old_nd.path is freed as old_path in out_rel_old */
4781 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4783 + goto out_rel_both;
4786 + new_dentry = old_nd.path.dentry;
4787 + vxdprintk(VXD_CBIT(misc, 2),
4788 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
4790 + new_dentry->d_name.len, new_dentry->d_name.name,
4791 + new_dentry->d_name.len);
4795 + path_put(&dir_nd.path);
4797 + path_put(&old_path);
4803 + new_dentry = ERR_PTR(ret);
4805 + vxdprintk(VXD_CBIT(misc, 3),
4806 + "cow_break_link returning with %p [r=%d]",
4807 + new_dentry, mnt_get_count(real_mount(old_nd.path.mnt)));
4808 + return new_dentry;
4813 +int vx_info_mnt_namespace(struct mnt_namespace *ns, char *buffer)
4816 + struct vfsmount *vmnt;
4817 + char *pstr, *root;
4820 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
4824 + vmnt = &ns->root->mnt;
4826 + path.dentry = vmnt->mnt_root;
4827 + root = d_path(&path, pstr, PATH_MAX - 2);
4828 + length = sprintf(buffer + length,
4829 + "Namespace:\t%p [#%u]\n"
4830 + "RootPath:\t%s\n",
4831 + ns, atomic_read(&ns->count),
4837 /* get the link contents into pagecache */
4838 static char *page_getlink(struct dentry * dentry, struct page **ppage)
4840 @@ -3998,3 +4388,4 @@ EXPORT_SYMBOL(vfs_symlink);
4841 EXPORT_SYMBOL(vfs_unlink);
4842 EXPORT_SYMBOL(dentry_unhash);
4843 EXPORT_SYMBOL(generic_readlink);
4844 +EXPORT_SYMBOL(vx_info_mnt_namespace);
4845 diff -NurpP --minimal linux-3.6/fs/namespace.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/namespace.c
4846 --- linux-3.6/fs/namespace.c 2012-10-04 15:27:40.000000000 +0200
4847 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/namespace.c 2012-10-04 18:47:00.000000000 +0200
4849 #include <linux/fs_struct.h> /* get_fs_root et.al. */
4850 #include <linux/fsnotify.h> /* fsnotify_vfsmount_delete */
4851 #include <linux/uaccess.h>
4852 +#include <linux/vs_base.h>
4853 +#include <linux/vs_context.h>
4854 +#include <linux/vs_tag.h>
4855 +#include <linux/vserver/space.h>
4856 +#include <linux/vserver/global.h>
4858 #include "internal.h"
4860 @@ -749,6 +754,10 @@ vfs_kern_mount(struct file_system_type *
4862 return ERR_PTR(-ENODEV);
4864 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
4865 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
4866 + return ERR_PTR(-EPERM);
4868 mnt = alloc_vfsmnt(name);
4870 return ERR_PTR(-ENOMEM);
4871 @@ -801,6 +810,7 @@ static struct mount *clone_mnt(struct mo
4872 mnt->mnt.mnt_root = dget(root);
4873 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
4874 mnt->mnt_parent = mnt;
4875 + mnt->mnt_tag = old->mnt_tag;
4876 br_write_lock(&vfsmount_lock);
4877 list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
4878 br_write_unlock(&vfsmount_lock);
4879 @@ -1266,7 +1276,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
4883 - if (!capable(CAP_SYS_ADMIN))
4884 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
4887 retval = do_umount(mnt, flags);
4888 @@ -1292,7 +1302,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
4890 static int mount_is_safe(struct path *path)
4892 - if (capable(CAP_SYS_ADMIN))
4893 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
4897 @@ -1610,7 +1620,7 @@ static int do_change_type(struct path *p
4901 - if (!capable(CAP_SYS_ADMIN))
4902 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
4905 if (path->dentry != path->mnt->mnt_root)
4906 @@ -1626,6 +1636,7 @@ static int do_change_type(struct path *p
4910 + // mnt->mnt_flags = mnt_flags;
4912 br_write_lock(&vfsmount_lock);
4913 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
4914 @@ -1641,12 +1652,14 @@ static int do_change_type(struct path *p
4915 * do loopback mount.
4917 static int do_loopback(struct path *path, char *old_name,
4919 + tag_t tag, unsigned long flags, int mnt_flags)
4921 LIST_HEAD(umount_list);
4922 struct path old_path;
4923 struct mount *mnt = NULL, *old;
4924 int err = mount_is_safe(path);
4925 + int recurse = flags & MS_REC;
4929 if (!old_name || !*old_name)
4930 @@ -1715,13 +1728,13 @@ static int change_mount_flags(struct vfs
4931 * on it - tough luck.
4933 static int do_remount(struct path *path, int flags, int mnt_flags,
4935 + void *data, xid_t xid)
4938 struct super_block *sb = path->mnt->mnt_sb;
4939 struct mount *mnt = real_mount(path->mnt);
4941 - if (!capable(CAP_SYS_ADMIN))
4942 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
4945 if (!check_mnt(mnt))
4946 @@ -1770,7 +1783,7 @@ static int do_move_mount(struct path *pa
4950 - if (!capable(CAP_SYS_ADMIN))
4951 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
4953 if (!old_name || !*old_name)
4955 @@ -1927,7 +1940,7 @@ static int do_new_mount(struct path *pat
4958 /* we need capabilities... */
4959 - if (!capable(CAP_SYS_ADMIN))
4960 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
4963 mnt = do_kern_mount(type, flags, name, data);
4964 @@ -2197,6 +2210,7 @@ long do_mount(char *dev_name, char *dir_
4971 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
4972 @@ -2224,6 +2238,12 @@ long do_mount(char *dev_name, char *dir_
4973 if (!(flags & MS_NOATIME))
4974 mnt_flags |= MNT_RELATIME;
4976 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
4977 + /* FIXME: bind and re-mounts get the tag flag? */
4978 + if (flags & (MS_BIND|MS_REMOUNT))
4979 + flags |= MS_TAGID;
4982 /* Separate the per-mountpoint flags */
4983 if (flags & MS_NOSUID)
4984 mnt_flags |= MNT_NOSUID;
4985 @@ -2240,15 +2260,17 @@ long do_mount(char *dev_name, char *dir_
4986 if (flags & MS_RDONLY)
4987 mnt_flags |= MNT_READONLY;
4989 + if (!capable(CAP_SYS_ADMIN))
4990 + mnt_flags |= MNT_NODEV;
4991 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
4992 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
4995 if (flags & MS_REMOUNT)
4996 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
4999 else if (flags & MS_BIND)
5000 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5001 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5002 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5003 retval = do_change_type(&path, flags);
5004 else if (flags & MS_MOVE)
5005 @@ -2329,6 +2351,7 @@ static struct mnt_namespace *dup_mnt_ns(
5006 q = next_mnt(q, new);
5008 up_write(&namespace_sem);
5009 + atomic_inc(&vs_global_mnt_ns);
5013 @@ -2524,9 +2547,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5015 new_mnt = real_mount(new.mnt);
5016 root_mnt = real_mount(root.mnt);
5017 - if (IS_MNT_SHARED(real_mount(old.mnt)) ||
5018 + if ((IS_MNT_SHARED(real_mount(old.mnt)) ||
5019 IS_MNT_SHARED(new_mnt->mnt_parent) ||
5020 - IS_MNT_SHARED(root_mnt->mnt_parent))
5021 + IS_MNT_SHARED(root_mnt->mnt_parent)) &&
5022 + !vx_flags(VXF_STATE_SETUP, 0))
5024 if (!check_mnt(root_mnt) || !check_mnt(new_mnt))
5026 @@ -2647,6 +2671,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5027 br_write_unlock(&vfsmount_lock);
5028 up_write(&namespace_sem);
5029 release_mounts(&umount_list);
5030 + atomic_dec(&vs_global_mnt_ns);
5034 diff -NurpP --minimal linux-3.6/fs/nfs/client.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfs/client.c
5035 --- linux-3.6/fs/nfs/client.c 2012-10-04 15:27:40.000000000 +0200
5036 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfs/client.c 2012-10-04 18:47:00.000000000 +0200
5037 @@ -692,6 +692,9 @@ int nfs_init_server_rpcclient(struct nfs
5038 if (server->flags & NFS_MOUNT_SOFT)
5039 server->client->cl_softrtry = 1;
5041 + server->client->cl_tag = 0;
5042 + if (server->flags & NFS_MOUNT_TAGGED)
5043 + server->client->cl_tag = 1;
5046 EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient);
5047 @@ -870,6 +873,10 @@ static void nfs_server_set_fsinfo(struct
5048 server->acdirmin = server->acdirmax = 0;
5051 + /* FIXME: needs fsinfo
5052 + if (server->flags & NFS_MOUNT_TAGGED)
5053 + sb->s_flags |= MS_TAGGED; */
5055 server->maxfilesize = fsinfo->maxfilesize;
5057 server->time_delta = fsinfo->time_delta;
5058 diff -NurpP --minimal linux-3.6/fs/nfs/dir.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfs/dir.c
5059 --- linux-3.6/fs/nfs/dir.c 2012-10-04 15:27:40.000000000 +0200
5060 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfs/dir.c 2012-10-04 18:47:00.000000000 +0200
5062 #include <linux/sched.h>
5063 #include <linux/kmemleak.h>
5064 #include <linux/xattr.h>
5065 +#include <linux/vs_tag.h>
5067 #include "delegation.h"
5069 @@ -1251,6 +1252,7 @@ struct dentry *nfs_lookup(struct inode *
5070 /* Success: notify readdir to use READDIRPLUS */
5071 nfs_advise_use_readdirplus(dir);
5073 + dx_propagate_tag(nd, inode);
5075 res = d_materialise_unique(dentry, inode);
5077 diff -NurpP --minimal linux-3.6/fs/nfs/inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfs/inode.c
5078 --- linux-3.6/fs/nfs/inode.c 2012-10-04 15:27:40.000000000 +0200
5079 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfs/inode.c 2012-10-04 18:47:00.000000000 +0200
5081 #include <linux/compat.h>
5082 #include <linux/freezer.h>
5083 #include <linux/crc32.h>
5084 +#include <linux/vs_tag.h>
5086 #include <asm/uaccess.h>
5088 @@ -279,6 +280,8 @@ nfs_fhget(struct super_block *sb, struct
5089 if (inode->i_state & I_NEW) {
5090 struct nfs_inode *nfsi = NFS_I(inode);
5091 unsigned long now = jiffies;
5095 /* We set i_ino for the few things that still rely on it,
5096 * such as stat(2) */
5097 @@ -323,8 +326,8 @@ nfs_fhget(struct super_block *sb, struct
5098 inode->i_version = 0;
5101 - inode->i_uid = -2;
5102 - inode->i_gid = -2;
5105 inode->i_blocks = 0;
5106 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5108 @@ -358,11 +361,11 @@ nfs_fhget(struct super_block *sb, struct
5109 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5110 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5111 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5112 - inode->i_uid = fattr->uid;
5114 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5115 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5116 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5117 - inode->i_gid = fattr->gid;
5119 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5120 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5121 if (fattr->valid & NFS_ATTR_FATTR_BLOCKS_USED)
5122 @@ -373,6 +376,11 @@ nfs_fhget(struct super_block *sb, struct
5124 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5126 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5127 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5128 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5129 + /* maybe fattr->xid someday */
5131 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5132 nfsi->attrtimeo_timestamp = now;
5133 nfsi->access_cache = RB_ROOT;
5134 @@ -494,6 +502,8 @@ void nfs_setattr_update_inode(struct ino
5135 inode->i_uid = attr->ia_uid;
5136 if ((attr->ia_valid & ATTR_GID) != 0)
5137 inode->i_gid = attr->ia_gid;
5138 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5139 + inode->i_tag = attr->ia_tag;
5140 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5141 spin_unlock(&inode->i_lock);
5143 @@ -965,6 +975,9 @@ static int nfs_check_inode_attributes(st
5144 struct nfs_inode *nfsi = NFS_I(inode);
5145 loff_t cur_size, new_isize;
5146 unsigned long invalid = 0;
5152 if (nfs_have_delegated_attributes(inode))
5153 @@ -990,13 +1003,18 @@ static int nfs_check_inode_attributes(st
5154 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5157 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5158 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5159 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5161 /* Have any file permissions changed? */
5162 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5163 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5164 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5165 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5166 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5167 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5168 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5169 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5170 + /* maybe check for tag too? */
5172 /* Has the link count changed? */
5173 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5174 @@ -1300,6 +1318,9 @@ static int nfs_update_inode(struct inode
5175 unsigned long invalid = 0;
5176 unsigned long now = jiffies;
5177 unsigned long save_cache_validity;
5182 dfprintk(VFS, "NFS: %s(%s/%ld fh_crc=0x%08x ct=%d info=0x%x)\n",
5183 __func__, inode->i_sb->s_id, inode->i_ino,
5184 @@ -1401,6 +1422,9 @@ static int nfs_update_inode(struct inode
5185 | NFS_INO_REVAL_PAGECACHE
5186 | NFS_INO_REVAL_FORCED);
5188 + uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5189 + gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5190 + tag = inode->i_tag;
5192 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5193 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5194 @@ -1422,9 +1446,9 @@ static int nfs_update_inode(struct inode
5195 | NFS_INO_REVAL_FORCED);
5197 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5198 - if (inode->i_uid != fattr->uid) {
5199 + if (uid != fattr->uid) {
5200 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5201 - inode->i_uid = fattr->uid;
5204 } else if (server->caps & NFS_CAP_OWNER)
5205 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5206 @@ -1433,9 +1457,9 @@ static int nfs_update_inode(struct inode
5207 | NFS_INO_REVAL_FORCED);
5209 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5210 - if (inode->i_gid != fattr->gid) {
5211 + if (gid != fattr->gid) {
5212 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5213 - inode->i_gid = fattr->gid;
5216 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5217 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5218 @@ -1443,6 +1467,10 @@ static int nfs_update_inode(struct inode
5219 | NFS_INO_INVALID_ACL
5220 | NFS_INO_REVAL_FORCED);
5222 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5223 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5224 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, tag);
5226 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5227 if (inode->i_nlink != fattr->nlink) {
5228 invalid |= NFS_INO_INVALID_ATTR;
5229 diff -NurpP --minimal linux-3.6/fs/nfs/nfs3xdr.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfs/nfs3xdr.c
5230 --- linux-3.6/fs/nfs/nfs3xdr.c 2012-10-04 15:27:40.000000000 +0200
5231 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfs/nfs3xdr.c 2012-10-04 18:47:00.000000000 +0200
5233 #include <linux/nfs3.h>
5234 #include <linux/nfs_fs.h>
5235 #include <linux/nfsacl.h>
5236 +#include <linux/vs_tag.h>
5237 #include "internal.h"
5239 #define NFSDBG_FACILITY NFSDBG_XDR
5240 @@ -560,7 +561,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5244 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5245 +static void encode_sattr3(struct xdr_stream *xdr,
5246 + const struct iattr *attr, int tag)
5250 @@ -592,15 +594,19 @@ static void encode_sattr3(struct xdr_str
5254 - if (attr->ia_valid & ATTR_UID) {
5255 + if (attr->ia_valid & ATTR_UID ||
5256 + (tag && (attr->ia_valid & ATTR_TAG))) {
5258 - *p++ = cpu_to_be32(attr->ia_uid);
5259 + *p++ = cpu_to_be32(TAGINO_UID(tag,
5260 + attr->ia_uid, attr->ia_tag));
5264 - if (attr->ia_valid & ATTR_GID) {
5265 + if (attr->ia_valid & ATTR_GID ||
5266 + (tag && (attr->ia_valid & ATTR_TAG))) {
5268 - *p++ = cpu_to_be32(attr->ia_gid);
5269 + *p++ = cpu_to_be32(TAGINO_GID(tag,
5270 + attr->ia_gid, attr->ia_tag));
5274 @@ -879,7 +885,7 @@ static void nfs3_xdr_enc_setattr3args(st
5275 const struct nfs3_sattrargs *args)
5277 encode_nfs_fh3(xdr, args->fh);
5278 - encode_sattr3(xdr, args->sattr);
5279 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5280 encode_sattrguard3(xdr, args);
5283 @@ -1029,13 +1035,13 @@ static void nfs3_xdr_enc_write3args(stru
5286 static void encode_createhow3(struct xdr_stream *xdr,
5287 - const struct nfs3_createargs *args)
5288 + const struct nfs3_createargs *args, int tag)
5290 encode_uint32(xdr, args->createmode);
5291 switch (args->createmode) {
5292 case NFS3_CREATE_UNCHECKED:
5293 case NFS3_CREATE_GUARDED:
5294 - encode_sattr3(xdr, args->sattr);
5295 + encode_sattr3(xdr, args->sattr, tag);
5297 case NFS3_CREATE_EXCLUSIVE:
5298 encode_createverf3(xdr, args->verifier);
5299 @@ -1050,7 +1056,7 @@ static void nfs3_xdr_enc_create3args(str
5300 const struct nfs3_createargs *args)
5302 encode_diropargs3(xdr, args->fh, args->name, args->len);
5303 - encode_createhow3(xdr, args);
5304 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5308 @@ -1066,7 +1072,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5309 const struct nfs3_mkdirargs *args)
5311 encode_diropargs3(xdr, args->fh, args->name, args->len);
5312 - encode_sattr3(xdr, args->sattr);
5313 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5317 @@ -1083,9 +1089,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5320 static void encode_symlinkdata3(struct xdr_stream *xdr,
5321 - const struct nfs3_symlinkargs *args)
5322 + const struct nfs3_symlinkargs *args, int tag)
5324 - encode_sattr3(xdr, args->sattr);
5325 + encode_sattr3(xdr, args->sattr, tag);
5326 encode_nfspath3(xdr, args->pages, args->pathlen);
5329 @@ -1094,7 +1100,7 @@ static void nfs3_xdr_enc_symlink3args(st
5330 const struct nfs3_symlinkargs *args)
5332 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5333 - encode_symlinkdata3(xdr, args);
5334 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5338 @@ -1122,24 +1128,24 @@ static void nfs3_xdr_enc_symlink3args(st
5341 static void encode_devicedata3(struct xdr_stream *xdr,
5342 - const struct nfs3_mknodargs *args)
5343 + const struct nfs3_mknodargs *args, int tag)
5345 - encode_sattr3(xdr, args->sattr);
5346 + encode_sattr3(xdr, args->sattr, tag);
5347 encode_specdata3(xdr, args->rdev);
5350 static void encode_mknoddata3(struct xdr_stream *xdr,
5351 - const struct nfs3_mknodargs *args)
5352 + const struct nfs3_mknodargs *args, int tag)
5354 encode_ftype3(xdr, args->type);
5355 switch (args->type) {
5358 - encode_devicedata3(xdr, args);
5359 + encode_devicedata3(xdr, args, tag);
5363 - encode_sattr3(xdr, args->sattr);
5364 + encode_sattr3(xdr, args->sattr, tag);
5368 @@ -1154,7 +1160,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5369 const struct nfs3_mknodargs *args)
5371 encode_diropargs3(xdr, args->fh, args->name, args->len);
5372 - encode_mknoddata3(xdr, args);
5373 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5377 diff -NurpP --minimal linux-3.6/fs/nfs/super.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfs/super.c
5378 --- linux-3.6/fs/nfs/super.c 2012-10-04 15:27:40.000000000 +0200
5379 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfs/super.c 2012-10-04 18:47:00.000000000 +0200
5381 #include <linux/parser.h>
5382 #include <linux/nsproxy.h>
5383 #include <linux/rcupdate.h>
5384 +#include <linux/vs_tag.h>
5386 #include <asm/uaccess.h>
5388 @@ -88,6 +89,7 @@ enum {
5389 Opt_sharecache, Opt_nosharecache,
5390 Opt_resvport, Opt_noresvport,
5391 Opt_fscache, Opt_nofscache,
5392 + Opt_tag, Opt_notag,
5394 /* Mount options that take integer arguments */
5396 @@ -100,6 +102,7 @@ enum {
5402 /* Mount options that take string arguments */
5404 @@ -182,6 +185,10 @@ static const match_table_t nfs_mount_opt
5405 /* The following needs to be listed after all other options */
5406 { Opt_nfsvers, "v%s" },
5408 + { Opt_tag, "tag" },
5409 + { Opt_notag, "notag" },
5410 + { Opt_tagid, "tagid=%u" },
5415 @@ -626,6 +633,7 @@ static void nfs_show_mount_options(struc
5416 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5417 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5418 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5419 + { NFS_MOUNT_TAGGED, ",tag", "" },
5422 const struct proc_nfs_info *nfs_infop;
5423 @@ -1243,6 +1251,14 @@ static int nfs_parse_mount_options(char
5424 kfree(mnt->fscache_uniq);
5425 mnt->fscache_uniq = NULL;
5427 +#ifndef CONFIG_TAGGING_NONE
5429 + mnt->flags |= NFS_MOUNT_TAGGED;
5432 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5437 * options that take numeric values
5438 @@ -1329,6 +1345,12 @@ static int nfs_parse_mount_options(char
5439 goto out_invalid_value;
5440 mnt->minorversion = option;
5442 +#ifdef CONFIG_PROPAGATE
5445 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5450 * options that take text values
5451 diff -NurpP --minimal linux-3.6/fs/nfsd/auth.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfsd/auth.c
5452 --- linux-3.6/fs/nfsd/auth.c 2012-07-22 23:39:41.000000000 +0200
5453 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfsd/auth.c 2012-10-04 18:47:00.000000000 +0200
5456 #include <linux/sched.h>
5457 #include <linux/user_namespace.h>
5458 +#include <linux/vs_tag.h>
5462 @@ -37,6 +38,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5464 new->fsuid = rqstp->rq_cred.cr_uid;
5465 new->fsgid = rqstp->rq_cred.cr_gid;
5466 + /* FIXME: this desperately needs a tag :)
5467 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5470 rqgi = rqstp->rq_cred.cr_group_info;
5472 diff -NurpP --minimal linux-3.6/fs/nfsd/nfs3xdr.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfsd/nfs3xdr.c
5473 --- linux-3.6/fs/nfsd/nfs3xdr.c 2012-05-21 18:07:26.000000000 +0200
5474 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfsd/nfs3xdr.c 2012-10-04 18:47:00.000000000 +0200
5478 #include <linux/namei.h>
5479 +#include <linux/vs_tag.h>
5483 @@ -95,6 +96,8 @@ static __be32 *
5484 decode_sattr3(__be32 *p, struct iattr *iap)
5492 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
5495 iap->ia_valid |= ATTR_UID;
5496 - iap->ia_uid = ntohl(*p++);
5497 + uid = ntohl(*p++);
5500 iap->ia_valid |= ATTR_GID;
5501 - iap->ia_gid = ntohl(*p++);
5502 + gid = ntohl(*p++);
5504 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5505 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5506 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5510 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5511 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5512 *p++ = htonl((u32) stat->mode);
5513 *p++ = htonl((u32) stat->nlink);
5514 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5515 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5516 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5517 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5518 + stat->uid, stat->tag)));
5519 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5520 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5521 + stat->gid, stat->tag)));
5522 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5523 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5525 diff -NurpP --minimal linux-3.6/fs/nfsd/nfs4xdr.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfsd/nfs4xdr.c
5526 --- linux-3.6/fs/nfsd/nfs4xdr.c 2012-10-04 15:27:40.000000000 +0200
5527 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfsd/nfs4xdr.c 2012-10-04 18:47:00.000000000 +0200
5529 #include <linux/utsname.h>
5530 #include <linux/pagemap.h>
5531 #include <linux/sunrpc/svcauth_gss.h>
5532 +#include <linux/vs_tag.h>
5536 @@ -2351,14 +2352,18 @@ out_acl:
5537 WRITE32(stat.nlink);
5539 if (bmval1 & FATTR4_WORD1_OWNER) {
5540 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5541 + status = nfsd4_encode_user(rqstp,
5542 + TAGINO_UID(DX_TAG(dentry->d_inode),
5543 + stat.uid, stat.tag), &p, &buflen);
5544 if (status == nfserr_resource)
5549 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5550 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5551 + status = nfsd4_encode_group(rqstp,
5552 + TAGINO_GID(DX_TAG(dentry->d_inode),
5553 + stat.gid, stat.tag), &p, &buflen);
5554 if (status == nfserr_resource)
5557 diff -NurpP --minimal linux-3.6/fs/nfsd/nfsxdr.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfsd/nfsxdr.c
5558 --- linux-3.6/fs/nfsd/nfsxdr.c 2011-05-22 16:17:53.000000000 +0200
5559 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/nfsd/nfsxdr.c 2012-10-04 18:47:00.000000000 +0200
5564 +#include <linux/vs_tag.h>
5566 #define NFSDDBG_FACILITY NFSDDBG_XDR
5568 @@ -88,6 +89,8 @@ static __be32 *
5569 decode_sattr(__be32 *p, struct iattr *iap)
5577 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
5579 if ((tmp = ntohl(*p++)) != (u32)-1) {
5580 iap->ia_valid |= ATTR_UID;
5581 - iap->ia_uid = tmp;
5584 if ((tmp = ntohl(*p++)) != (u32)-1) {
5585 iap->ia_valid |= ATTR_GID;
5586 - iap->ia_gid = tmp;
5589 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5590 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5591 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5592 if ((tmp = ntohl(*p++)) != (u32)-1) {
5593 iap->ia_valid |= ATTR_SIZE;
5595 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
5596 *p++ = htonl(nfs_ftypes[type >> 12]);
5597 *p++ = htonl((u32) stat->mode);
5598 *p++ = htonl((u32) stat->nlink);
5599 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5600 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5601 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5602 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
5603 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5604 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
5606 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
5607 *p++ = htonl(NFS_MAXPATHLEN);
5608 diff -NurpP --minimal linux-3.6/fs/ocfs2/dlmglue.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/dlmglue.c
5609 --- linux-3.6/fs/ocfs2/dlmglue.c 2012-07-22 23:39:41.000000000 +0200
5610 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/dlmglue.c 2012-10-04 18:47:00.000000000 +0200
5611 @@ -2047,6 +2047,7 @@ static void __ocfs2_stuff_meta_lvb(struc
5612 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
5613 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
5614 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
5615 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
5616 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
5617 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
5618 lvb->lvb_iatime_packed =
5619 @@ -2097,6 +2098,7 @@ static void ocfs2_refresh_inode_from_lvb
5621 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
5622 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
5623 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
5624 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
5625 set_nlink(inode, be16_to_cpu(lvb->lvb_inlink));
5626 ocfs2_unpack_timespec(&inode->i_atime,
5627 diff -NurpP --minimal linux-3.6/fs/ocfs2/dlmglue.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/dlmglue.h
5628 --- linux-3.6/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
5629 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/dlmglue.h 2012-10-04 18:47:00.000000000 +0200
5630 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
5633 __be32 lvb_igeneration;
5634 - __be32 lvb_reserved2;
5636 + __be16 lvb_reserved2;
5639 #define OCFS2_QINFO_LVB_VERSION 1
5640 diff -NurpP --minimal linux-3.6/fs/ocfs2/file.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/file.c
5641 --- linux-3.6/fs/ocfs2/file.c 2012-10-04 15:27:41.000000000 +0200
5642 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/file.c 2012-10-04 18:47:00.000000000 +0200
5643 @@ -1123,7 +1123,7 @@ int ocfs2_setattr(struct dentry *dentry,
5644 attr->ia_valid &= ~ATTR_SIZE;
5646 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
5647 - | ATTR_GID | ATTR_UID | ATTR_MODE)
5648 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
5649 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
5652 diff -NurpP --minimal linux-3.6/fs/ocfs2/inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/inode.c
5653 --- linux-3.6/fs/ocfs2/inode.c 2012-07-22 23:39:41.000000000 +0200
5654 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/inode.c 2012-10-04 18:47:00.000000000 +0200
5656 #include <linux/highmem.h>
5657 #include <linux/pagemap.h>
5658 #include <linux/quotaops.h>
5659 +#include <linux/vs_tag.h>
5661 #include <asm/byteorder.h>
5663 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
5665 unsigned int flags = OCFS2_I(inode)->ip_attr;
5667 - inode->i_flags &= ~(S_IMMUTABLE |
5668 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5669 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5671 if (flags & OCFS2_IMMUTABLE_FL)
5672 inode->i_flags |= S_IMMUTABLE;
5673 + if (flags & OCFS2_IXUNLINK_FL)
5674 + inode->i_flags |= S_IXUNLINK;
5676 if (flags & OCFS2_SYNC_FL)
5677 inode->i_flags |= S_SYNC;
5678 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
5679 inode->i_flags |= S_NOATIME;
5680 if (flags & OCFS2_DIRSYNC_FL)
5681 inode->i_flags |= S_DIRSYNC;
5683 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5685 + if (flags & OCFS2_BARRIER_FL)
5686 + inode->i_vflags |= V_BARRIER;
5687 + if (flags & OCFS2_COW_FL)
5688 + inode->i_vflags |= V_COW;
5691 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
5692 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
5694 unsigned int flags = oi->vfs_inode.i_flags;
5695 + unsigned int vflags = oi->vfs_inode.i_vflags;
5697 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
5698 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
5699 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
5700 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
5702 + if (flags & S_IMMUTABLE)
5703 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5704 + if (flags & S_IXUNLINK)
5705 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
5707 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
5708 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
5710 oi->ip_attr |= OCFS2_SYNC_FL;
5711 if (flags & S_APPEND)
5712 oi->ip_attr |= OCFS2_APPEND_FL;
5713 - if (flags & S_IMMUTABLE)
5714 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5715 if (flags & S_NOATIME)
5716 oi->ip_attr |= OCFS2_NOATIME_FL;
5717 if (flags & S_DIRSYNC)
5718 oi->ip_attr |= OCFS2_DIRSYNC_FL;
5720 + if (vflags & V_BARRIER)
5721 + oi->ip_attr |= OCFS2_BARRIER_FL;
5722 + if (vflags & V_COW)
5723 + oi->ip_attr |= OCFS2_COW_FL;
5726 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
5727 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
5728 struct super_block *sb;
5729 struct ocfs2_super *osb;
5736 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
5737 inode->i_generation = le32_to_cpu(fe->i_generation);
5738 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
5739 inode->i_mode = le16_to_cpu(fe->i_mode);
5740 - inode->i_uid = le32_to_cpu(fe->i_uid);
5741 - inode->i_gid = le32_to_cpu(fe->i_gid);
5742 + uid = le32_to_cpu(fe->i_uid);
5743 + gid = le32_to_cpu(fe->i_gid);
5744 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5745 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5746 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5747 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
5749 /* Fast symlinks will have i_size but no allocated clusters. */
5750 if (S_ISLNK(inode->i_mode) && !fe->i_clusters) {
5751 diff -NurpP --minimal linux-3.6/fs/ocfs2/inode.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/inode.h
5752 --- linux-3.6/fs/ocfs2/inode.h 2012-01-09 16:14:55.000000000 +0100
5753 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/inode.h 2012-10-04 18:47:00.000000000 +0200
5754 @@ -154,6 +154,7 @@ struct buffer_head *ocfs2_bread(struct i
5756 void ocfs2_set_inode_flags(struct inode *inode);
5757 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
5758 +int ocfs2_sync_flags(struct inode *inode, int, int);
5760 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
5762 diff -NurpP --minimal linux-3.6/fs/ocfs2/ioctl.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/ioctl.c
5763 --- linux-3.6/fs/ocfs2/ioctl.c 2012-10-04 15:27:41.000000000 +0200
5764 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/ioctl.c 2012-10-04 18:47:00.000000000 +0200
5765 @@ -76,7 +76,41 @@ static int ocfs2_get_inode_attr(struct i
5769 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5770 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
5772 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5773 + struct buffer_head *bh = NULL;
5774 + handle_t *handle = NULL;
5777 + status = ocfs2_inode_lock(inode, &bh, 1);
5779 + mlog_errno(status);
5782 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5783 + if (IS_ERR(handle)) {
5784 + status = PTR_ERR(handle);
5785 + mlog_errno(status);
5789 + inode->i_flags = flags;
5790 + inode->i_vflags = vflags;
5791 + ocfs2_get_inode_flags(OCFS2_I(inode));
5793 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
5795 + mlog_errno(status);
5797 + ocfs2_commit_trans(osb, handle);
5799 + ocfs2_inode_unlock(inode, 1);
5804 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5807 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
5808 @@ -101,6 +135,11 @@ static int ocfs2_set_inode_attr(struct i
5809 if (!S_ISDIR(inode->i_mode))
5810 flags &= ~OCFS2_DIRSYNC_FL;
5812 + if (IS_BARRIER(inode)) {
5813 + vxwprintk_task(1, "messing with the barrier.");
5817 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5818 if (IS_ERR(handle)) {
5819 status = PTR_ERR(handle);
5820 @@ -879,6 +918,7 @@ bail:
5825 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5827 struct inode *inode = filp->f_path.dentry->d_inode;
5828 diff -NurpP --minimal linux-3.6/fs/ocfs2/namei.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/namei.c
5829 --- linux-3.6/fs/ocfs2/namei.c 2012-10-04 15:27:41.000000000 +0200
5830 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/namei.c 2012-10-04 18:47:00.000000000 +0200
5832 #include <linux/slab.h>
5833 #include <linux/highmem.h>
5834 #include <linux/quotaops.h>
5835 +#include <linux/vs_tag.h>
5837 #include <cluster/masklog.h>
5839 @@ -475,6 +476,7 @@ static int __ocfs2_mknod_locked(struct i
5840 struct ocfs2_dinode *fe = NULL;
5841 struct ocfs2_extent_list *fel;
5847 @@ -512,8 +514,11 @@ static int __ocfs2_mknod_locked(struct i
5848 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
5849 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
5850 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
5851 - fe->i_uid = cpu_to_le32(inode->i_uid);
5852 - fe->i_gid = cpu_to_le32(inode->i_gid);
5854 + tag = dx_current_fstag(osb->sb);
5855 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
5856 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
5857 + inode->i_tag = tag;
5858 fe->i_mode = cpu_to_le16(inode->i_mode);
5859 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
5860 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
5861 diff -NurpP --minimal linux-3.6/fs/ocfs2/ocfs2.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/ocfs2.h
5862 --- linux-3.6/fs/ocfs2/ocfs2.h 2012-01-09 16:14:55.000000000 +0100
5863 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/ocfs2.h 2012-10-04 18:47:00.000000000 +0200
5864 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
5866 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
5867 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
5868 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
5871 #define OCFS2_OSB_SOFT_RO 0x0001
5872 diff -NurpP --minimal linux-3.6/fs/ocfs2/ocfs2_fs.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/ocfs2_fs.h
5873 --- linux-3.6/fs/ocfs2/ocfs2_fs.h 2011-05-22 16:17:53.000000000 +0200
5874 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/ocfs2_fs.h 2012-10-04 18:47:00.000000000 +0200
5875 @@ -266,6 +266,11 @@
5876 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
5877 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
5879 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
5881 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
5882 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
5884 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
5885 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
5887 diff -NurpP --minimal linux-3.6/fs/ocfs2/super.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/super.c
5888 --- linux-3.6/fs/ocfs2/super.c 2012-05-21 18:07:26.000000000 +0200
5889 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/ocfs2/super.c 2012-10-04 18:47:00.000000000 +0200
5890 @@ -185,6 +185,7 @@ enum {
5894 + Opt_tag, Opt_notag, Opt_tagid,
5898 @@ -216,6 +217,9 @@ static const match_table_t tokens = {
5899 {Opt_coherency_full, "coherency=full"},
5900 {Opt_resv_level, "resv_level=%u"},
5901 {Opt_dir_resv_level, "dir_resv_level=%u"},
5903 + {Opt_notag, "notag"},
5904 + {Opt_tagid, "tagid=%u"},
5908 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
5912 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
5913 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
5915 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
5919 /* We're going to/from readonly mode. */
5920 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
5921 /* Disable quota accounting before remounting RO */
5922 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
5924 ocfs2_complete_mount_recovery(osb);
5926 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
5927 + sb->s_flags |= MS_TAGGED;
5929 if (ocfs2_mount_local(osb))
5930 snprintf(nodestr, sizeof(nodestr), "local");
5932 @@ -1503,6 +1517,20 @@ static int ocfs2_parse_options(struct su
5933 option < OCFS2_MAX_RESV_LEVEL)
5934 mopt->dir_resv_level = option;
5936 +#ifndef CONFIG_TAGGING_NONE
5938 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
5941 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
5944 +#ifdef CONFIG_PROPAGATE
5947 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
5952 "Unrecognized mount option \"%s\" "
5953 diff -NurpP --minimal linux-3.6/fs/open.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/open.c
5954 --- linux-3.6/fs/open.c 2012-10-04 15:27:41.000000000 +0200
5955 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/open.c 2012-10-04 18:47:00.000000000 +0200
5957 #include <linux/fs_struct.h>
5958 #include <linux/ima.h>
5959 #include <linux/dnotify.h>
5960 +#include <linux/vs_base.h>
5961 +#include <linux/vs_limit.h>
5962 +#include <linux/vs_tag.h>
5963 +#include <linux/vs_cowbl.h>
5964 +#include <linux/vserver/dlimit.h>
5966 #include "internal.h"
5968 @@ -74,6 +79,12 @@ static long do_sys_truncate(const char _
5969 error = user_path(pathname, &path);
5973 +#ifdef CONFIG_VSERVER_COWBL
5974 + error = cow_check_and_break(&path);
5976 + goto dput_and_out;
5978 inode = path.dentry->d_inode;
5980 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
5981 @@ -495,6 +506,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
5983 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
5985 +#ifdef CONFIG_VSERVER_COWBL
5986 + error = cow_check_and_break(&path);
5989 error = chmod_common(&path, mode);
5992 @@ -522,13 +537,13 @@ static int chown_common(struct path *pat
5993 if (!uid_valid(uid))
5995 newattrs.ia_valid |= ATTR_UID;
5996 - newattrs.ia_uid = uid;
5997 + newattrs.ia_uid = dx_map_uid(user);
5999 if (group != (gid_t) -1) {
6000 if (!gid_valid(gid))
6002 newattrs.ia_valid |= ATTR_GID;
6003 - newattrs.ia_gid = gid;
6004 + newattrs.ia_gid = dx_map_gid(group);
6006 if (!S_ISDIR(inode->i_mode))
6007 newattrs.ia_valid |=
6008 @@ -561,6 +576,18 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6009 error = mnt_want_write(path.mnt);
6012 +#ifdef CONFIG_VSERVER_COWBL
6013 + error = cow_check_and_break(&path);
6016 +#ifdef CONFIG_VSERVER_COWBL
6017 + error = cow_check_and_break(&path);
6020 +#ifdef CONFIG_VSERVER_COWBL
6021 + error = cow_check_and_break(&path);
6024 error = chown_common(&path, user, group);
6025 mnt_drop_write(path.mnt);
6027 @@ -809,6 +836,7 @@ static void __put_unused_fd(struct files
6028 __clear_open_fd(fd, fdt);
6029 if (fd < files->next_fd)
6030 files->next_fd = fd;
6031 + vx_openfd_dec(fd);
6034 void put_unused_fd(unsigned int fd)
6035 diff -NurpP --minimal linux-3.6/fs/proc/array.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/array.c
6036 --- linux-3.6/fs/proc/array.c 2012-07-22 23:39:42.000000000 +0200
6037 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/array.c 2012-10-04 18:47:00.000000000 +0200
6039 #include <linux/ptrace.h>
6040 #include <linux/tracehook.h>
6041 #include <linux/user_namespace.h>
6042 +#include <linux/vs_context.h>
6043 +#include <linux/vs_network.h>
6045 #include <asm/pgtable.h>
6046 #include <asm/processor.h>
6047 @@ -172,6 +174,9 @@ static inline void task_state(struct seq
6049 ppid = pid_alive(p) ?
6050 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6051 + if (unlikely(vx_current_initpid(p->pid)))
6056 struct task_struct *tracer = ptrace_parent(p);
6057 @@ -296,7 +301,7 @@ static inline void task_sig(struct seq_f
6060 static void render_cap_t(struct seq_file *m, const char *header,
6062 + struct vx_info *vxi, kernel_cap_t *a)
6066 @@ -321,10 +326,11 @@ static inline void task_cap(struct seq_f
6067 cap_bset = cred->cap_bset;
6070 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6071 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6072 - render_cap_t(m, "CapEff:\t", &cap_effective);
6073 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6074 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6075 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6076 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6077 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6078 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6081 static inline void task_context_switch_counts(struct seq_file *m,
6082 @@ -346,6 +352,42 @@ static void task_cpus_allowed(struct seq
6086 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6087 + struct pid *pid, struct task_struct *task)
6089 + seq_printf(m, "Proxy:\t%p(%c)\n"
6097 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6098 + atomic_read(&task->nsproxy->count),
6099 + task->nsproxy->uts_ns,
6100 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6101 + task->nsproxy->ipc_ns,
6102 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6103 + task->nsproxy->mnt_ns,
6104 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6105 + task->nsproxy->pid_ns,
6106 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6107 + task->nsproxy->net_ns,
6108 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6112 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6114 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6117 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6118 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6122 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6123 struct pid *pid, struct task_struct *task)
6125 @@ -362,6 +404,7 @@ int proc_pid_status(struct seq_file *m,
6127 task_cpus_allowed(m, task);
6128 cpuset_task_status_allowed(m, task);
6129 + task_vs_id(m, task);
6130 task_context_switch_counts(m, task);
6133 @@ -471,6 +514,17 @@ static int do_task_stat(struct seq_file
6134 /* convert nsec -> ticks */
6135 start_time = nsec_to_clock_t(start_time);
6137 + /* fixup start time for virt uptime */
6138 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6139 + unsigned long long bias =
6140 + current->vx_info->cvirt.bias_clock;
6142 + if (start_time > bias)
6143 + start_time -= bias;
6148 seq_printf(m, "%d (%s) %c", pid_nr_ns(pid, ns), tcomm, state);
6149 seq_put_decimal_ll(m, ' ', ppid);
6150 seq_put_decimal_ll(m, ' ', pgid);
6151 diff -NurpP --minimal linux-3.6/fs/proc/base.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/base.c
6152 --- linux-3.6/fs/proc/base.c 2012-10-04 15:27:41.000000000 +0200
6153 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/base.c 2012-10-04 18:47:00.000000000 +0200
6155 #include <linux/fs_struct.h>
6156 #include <linux/slab.h>
6157 #include <linux/flex_array.h>
6158 +#include <linux/vs_context.h>
6159 +#include <linux/vs_network.h>
6160 #ifdef CONFIG_HARDWALL
6161 #include <asm/hardwall.h>
6163 @@ -941,11 +943,16 @@ static ssize_t oom_adjust_write(struct f
6167 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6168 + if (oom_adjust < task->signal->oom_adj &&
6169 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6174 + /* prevent guest processes from circumventing the oom killer */
6175 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6176 + oom_adjust = OOM_ADJUST_MIN;
6179 * Warn that /proc/pid/oom_adj is deprecated, see
6180 * Documentation/feature-removal-schedule.txt.
6181 @@ -1548,6 +1555,8 @@ struct inode *proc_pid_make_inode(struct
6182 inode->i_gid = cred->egid;
6185 + /* procfs is xid tagged */
6186 + inode->i_tag = (tag_t)vx_task_xid(task);
6187 security_task_to_inode(task, inode);
6190 @@ -1593,6 +1602,8 @@ int pid_getattr(struct vfsmount *mnt, st
6194 +static unsigned name_to_int(struct dentry *dentry);
6197 * Exceptional case: normally we are not allowed to unhash a busy
6198 * directory. In this case, however, we can do it - no aliasing problems
6199 @@ -1621,6 +1632,12 @@ int pid_revalidate(struct dentry *dentry
6200 task = get_proc_task(inode);
6203 + unsigned pid = name_to_int(dentry);
6205 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6206 + put_task_struct(task);
6209 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6210 task_dumpable(task)) {
6212 @@ -1637,6 +1654,7 @@ int pid_revalidate(struct dentry *dentry
6213 put_task_struct(task);
6220 @@ -2457,6 +2475,13 @@ static struct dentry *proc_pident_lookup
6224 + /* TODO: maybe we can come up with a generic approach? */
6225 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6226 + (dentry->d_name.len == 5) &&
6227 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6228 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6232 * Yes, it does not scale. And it should not. Don't add
6233 * new entries into /proc/<tgid>/ without very good reasons.
6234 @@ -2842,7 +2867,7 @@ out_iput:
6235 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6237 struct dentry *error;
6238 - struct task_struct *task = get_proc_task(dir);
6239 + struct task_struct *task = get_proc_task_real(dir);
6240 const struct pid_entry *p, *last;
6242 error = ERR_PTR(-ENOENT);
6243 @@ -3017,6 +3042,9 @@ static int proc_pid_personality(struct s
6244 static const struct file_operations proc_task_operations;
6245 static const struct inode_operations proc_task_inode_operations;
6247 +extern int proc_pid_vx_info(struct task_struct *, char *);
6248 +extern int proc_pid_nx_info(struct task_struct *, char *);
6250 static const struct pid_entry tgid_base_stuff[] = {
6251 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6252 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6253 @@ -3083,6 +3111,8 @@ static const struct pid_entry tgid_base_
6254 #ifdef CONFIG_CGROUPS
6255 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6257 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6258 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6259 INF("oom_score", S_IRUGO, proc_oom_score),
6260 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6261 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6262 @@ -3106,6 +3136,7 @@ static const struct pid_entry tgid_base_
6263 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
6264 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
6266 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6269 static int proc_tgid_base_readdir(struct file * filp,
6270 @@ -3300,7 +3331,7 @@ retry:
6272 pid = find_ge_pid(iter.tgid, ns);
6274 - iter.tgid = pid_nr_ns(pid, ns);
6275 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6276 iter.task = pid_task(pid, PIDTYPE_PID);
6277 /* What we to know is if the pid we have find is the
6278 * pid of a thread_group_leader. Testing for task
6279 @@ -3330,7 +3361,7 @@ static int proc_pid_fill_cache(struct fi
6280 struct tgid_iter iter)
6282 char name[PROC_NUMBUF];
6283 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6284 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6285 return proc_fill_cache(filp, dirent, filldir, name, len,
6286 proc_pid_instantiate, iter.task, NULL);
6288 @@ -3354,7 +3385,7 @@ int proc_pid_readdir(struct file * filp,
6290 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6292 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
6293 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6297 @@ -3376,6 +3407,8 @@ int proc_pid_readdir(struct file * filp,
6298 __filldir = fake_filldir;
6300 filp->f_pos = iter.tgid + TGID_OFFSET;
6301 + if (!vx_proc_task_visible(iter.task))
6303 if (proc_pid_fill_cache(filp, dirent, __filldir, iter) < 0) {
6304 put_task_struct(iter.task);
6306 @@ -3537,6 +3570,8 @@ static struct dentry *proc_task_lookup(s
6307 tid = name_to_int(dentry);
6310 + if (vx_current_initpid(tid))
6313 ns = dentry->d_sb->s_fs_info;
6315 diff -NurpP --minimal linux-3.6/fs/proc/generic.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/generic.c
6316 --- linux-3.6/fs/proc/generic.c 2012-10-04 15:27:41.000000000 +0200
6317 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/generic.c 2012-10-04 18:47:00.000000000 +0200
6319 #include <linux/bitops.h>
6320 #include <linux/spinlock.h>
6321 #include <linux/completion.h>
6322 +#include <linux/vserver/inode.h>
6323 #include <asm/uaccess.h>
6325 #include "internal.h"
6326 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
6327 for (de = de->subdir; de ; de = de->next) {
6328 if (de->namelen != dentry->d_name.len)
6330 + if (!vx_hide_check(0, de->vx_flags))
6332 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6334 spin_unlock(&proc_subdir_lock);
6336 inode = proc_get_inode(dir->i_sb, de);
6337 + /* generic proc entries belong to the host */
6342 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
6344 /* filldir passes info to user space */
6346 + if (!vx_hide_check(0, de->vx_flags))
6348 spin_unlock(&proc_subdir_lock);
6349 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6350 de->low_ino, de->mode >> 12) < 0) {
6351 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
6354 spin_lock(&proc_subdir_lock);
6359 @@ -626,6 +634,7 @@ static struct proc_dir_entry *__proc_cre
6361 atomic_set(&ent->count, 1);
6363 + ent->vx_flags = IATTR_PROC_DEFAULT;
6364 spin_lock_init(&ent->pde_unload_lock);
6365 ent->pde_unload_completion = NULL;
6366 INIT_LIST_HEAD(&ent->pde_openers);
6367 @@ -649,7 +658,8 @@ struct proc_dir_entry *proc_symlink(cons
6373 + ent->vx_flags = IATTR_PROC_SYMLINK;
6377 diff -NurpP --minimal linux-3.6/fs/proc/inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/inode.c
6378 --- linux-3.6/fs/proc/inode.c 2012-07-22 23:39:42.000000000 +0200
6379 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/inode.c 2012-10-04 18:47:00.000000000 +0200
6380 @@ -458,6 +458,8 @@ struct inode *proc_get_inode(struct supe
6381 inode->i_uid = de->uid;
6382 inode->i_gid = de->gid;
6385 + PROC_I(inode)->vx_flags = de->vx_flags;
6387 inode->i_size = de->size;
6389 diff -NurpP --minimal linux-3.6/fs/proc/internal.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/internal.h
6390 --- linux-3.6/fs/proc/internal.h 2012-10-04 15:27:41.000000000 +0200
6391 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/internal.h 2012-10-04 18:47:00.000000000 +0200
6395 #include <linux/proc_fs.h>
6396 +#include <linux/vs_pid.h>
6398 struct ctl_table_header;
6400 extern struct proc_dir_entry proc_root;
6401 @@ -52,6 +54,9 @@ extern int proc_pid_status(struct seq_fi
6402 struct pid *pid, struct task_struct *task);
6403 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6404 struct pid *pid, struct task_struct *task);
6405 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6406 + struct pid *pid, struct task_struct *task);
6408 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6410 extern const struct file_operations proc_tid_children_operations;
6411 @@ -81,11 +86,16 @@ static inline struct pid *proc_pid(struc
6412 return PROC_I(inode)->pid;
6415 -static inline struct task_struct *get_proc_task(struct inode *inode)
6416 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6418 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6421 +static inline struct task_struct *get_proc_task(struct inode *inode)
6423 + return vx_get_proc_task(inode, proc_pid(inode));
6426 static inline int proc_fd(struct inode *inode)
6428 return PROC_I(inode)->fd;
6429 diff -NurpP --minimal linux-3.6/fs/proc/loadavg.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/loadavg.c
6430 --- linux-3.6/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
6431 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/loadavg.c 2012-10-04 18:47:00.000000000 +0200
6434 static int loadavg_proc_show(struct seq_file *m, void *v)
6436 + unsigned long running;
6437 + unsigned int threads;
6438 unsigned long avnrun[3];
6440 get_avenrun(avnrun, FIXED_1/200, 0);
6442 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6443 + struct vx_info *vxi = current_vx_info();
6445 + running = atomic_read(&vxi->cvirt.nr_running);
6446 + threads = atomic_read(&vxi->cvirt.nr_threads);
6448 + running = nr_running();
6449 + threads = nr_threads;
6452 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6453 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6454 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6455 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6456 - nr_running(), nr_threads,
6458 task_active_pid_ns(current)->last_pid);
6461 diff -NurpP --minimal linux-3.6/fs/proc/meminfo.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/meminfo.c
6462 --- linux-3.6/fs/proc/meminfo.c 2012-01-09 16:14:55.000000000 +0100
6463 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/meminfo.c 2012-10-04 18:47:00.000000000 +0200
6464 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
6465 allowed = ((totalram_pages - hugetlb_total_pages())
6466 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6468 - cached = global_page_state(NR_FILE_PAGES) -
6469 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6470 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6471 total_swapcache_pages - i.bufferram;
6474 diff -NurpP --minimal linux-3.6/fs/proc/root.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/root.c
6475 --- linux-3.6/fs/proc/root.c 2012-10-04 15:27:41.000000000 +0200
6476 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/root.c 2012-10-04 18:47:00.000000000 +0200
6478 #include <linux/mount.h>
6479 #include <linux/pid_namespace.h>
6480 #include <linux/parser.h>
6481 +#include <linux/vserver/inode.h>
6483 #include "internal.h"
6485 +struct proc_dir_entry *proc_virtual;
6487 +extern void proc_vx_init(void);
6489 static int proc_test_super(struct super_block *sb, void *data)
6491 return sb->s_fs_info == data;
6492 @@ -189,6 +194,7 @@ void __init proc_root_init(void)
6494 proc_mkdir("bus", NULL);
6499 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
6500 @@ -255,6 +261,7 @@ struct proc_dir_entry proc_root = {
6501 .proc_iops = &proc_root_inode_operations,
6502 .proc_fops = &proc_root_operations,
6503 .parent = &proc_root,
6504 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
6508 diff -NurpP --minimal linux-3.6/fs/proc/stat.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/stat.c
6509 --- linux-3.6/fs/proc/stat.c 2012-05-21 18:07:26.000000000 +0200
6510 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/stat.c 2012-10-04 18:47:00.000000000 +0200
6512 #include <linux/slab.h>
6513 #include <linux/time.h>
6514 #include <linux/irqnr.h>
6515 +#include <linux/vserver/cvirt.h>
6516 #include <asm/cputime.h>
6517 #include <linux/tick.h>
6519 @@ -86,6 +87,10 @@ static int show_stat(struct seq_file *p,
6520 irq = softirq = steal = 0;
6521 guest = guest_nice = 0;
6522 getboottime(&boottime);
6524 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6525 + vx_vsi_boottime(&boottime);
6527 jif = boottime.tv_sec;
6529 for_each_possible_cpu(i) {
6530 diff -NurpP --minimal linux-3.6/fs/proc/uptime.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/uptime.c
6531 --- linux-3.6/fs/proc/uptime.c 2012-03-19 19:47:26.000000000 +0100
6532 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc/uptime.c 2012-10-04 18:47:00.000000000 +0200
6534 #include <linux/seq_file.h>
6535 #include <linux/time.h>
6536 #include <linux/kernel_stat.h>
6537 +#include <linux/vserver/cvirt.h>
6538 #include <asm/cputime.h>
6540 static int uptime_proc_show(struct seq_file *m, void *v)
6541 @@ -25,6 +26,10 @@ static int uptime_proc_show(struct seq_f
6542 nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
6543 idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
6546 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6547 + vx_vsi_uptime(&uptime, &idle);
6549 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
6550 (unsigned long) uptime.tv_sec,
6551 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
6552 diff -NurpP --minimal linux-3.6/fs/proc_namespace.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc_namespace.c
6553 --- linux-3.6/fs/proc_namespace.c 2012-10-04 15:27:41.000000000 +0200
6554 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/proc_namespace.c 2012-10-04 18:47:00.000000000 +0200
6555 @@ -44,6 +44,8 @@ static int show_sb_opts(struct seq_file
6556 { MS_SYNCHRONOUS, ",sync" },
6557 { MS_DIRSYNC, ",dirsync" },
6558 { MS_MANDLOCK, ",mand" },
6559 + { MS_TAGGED, ",tag" },
6560 + { MS_NOTAGCHECK, ",notagcheck" },
6563 const struct proc_fs_info *fs_infop;
6564 @@ -80,6 +82,34 @@ static inline void mangle(struct seq_fil
6565 seq_escape(m, s, " \t\n\\");
6568 +static int mnt_is_reachable(struct vfsmount *vfsmnt)
6571 + struct dentry *point;
6572 + struct mount *mnt = real_mount(vfsmnt);
6573 + struct mount *root_mnt;
6576 + if (mnt == mnt->mnt_ns->root)
6579 + br_read_lock(&vfsmount_lock);
6580 + root = current->fs->root;
6581 + root_mnt = real_mount(root.mnt);
6582 + point = root.dentry;
6584 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
6585 + point = mnt->mnt_mountpoint;
6586 + mnt = mnt->mnt_parent;
6589 + ret = (mnt == root_mnt) && is_subdir(point, root.dentry);
6591 + br_read_unlock(&vfsmount_lock);
6596 static void show_type(struct seq_file *m, struct super_block *sb)
6598 mangle(m, sb->s_type->name);
6599 @@ -96,6 +126,17 @@ static int show_vfsmnt(struct seq_file *
6600 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6601 struct super_block *sb = mnt_path.dentry->d_sb;
6603 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6605 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6608 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6609 + mnt == current->fs->root.mnt) {
6610 + seq_puts(m, "/dev/root / ");
6614 if (sb->s_op->show_devname) {
6615 err = sb->s_op->show_devname(m, mnt_path.dentry);
6617 @@ -106,6 +147,7 @@ static int show_vfsmnt(struct seq_file *
6619 seq_path(m, &mnt_path, " \t\n\\");
6623 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
6624 err = show_sb_opts(m, sb);
6625 @@ -128,6 +170,11 @@ static int show_mountinfo(struct seq_fil
6626 struct path root = p->root;
6629 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6631 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6634 seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
6635 MAJOR(sb->s_dev), MINOR(sb->s_dev));
6636 if (sb->s_op->show_path)
6637 @@ -187,6 +234,17 @@ static int show_vfsstat(struct seq_file
6638 struct super_block *sb = mnt_path.dentry->d_sb;
6641 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6643 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6646 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6647 + mnt == current->fs->root.mnt) {
6648 + seq_puts(m, "device /dev/root mounted on / ");
6653 if (sb->s_op->show_devname) {
6654 seq_puts(m, "device ");
6655 @@ -203,7 +261,7 @@ static int show_vfsstat(struct seq_file
6656 seq_puts(m, " mounted on ");
6657 seq_path(m, &mnt_path, " \t\n\\");
6661 /* file system type */
6662 seq_puts(m, "with fstype ");
6664 diff -NurpP --minimal linux-3.6/fs/quota/dquot.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/quota/dquot.c
6665 --- linux-3.6/fs/quota/dquot.c 2012-10-04 15:27:41.000000000 +0200
6666 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/quota/dquot.c 2012-10-04 18:47:00.000000000 +0200
6667 @@ -1580,6 +1580,9 @@ int __dquot_alloc_space(struct inode *in
6668 struct dquot **dquots = inode->i_dquot;
6669 int reserve = flags & DQUOT_SPACE_RESERVE;
6671 + if ((ret = dl_alloc_space(inode, number)))
6675 * First test before acquiring mutex - solves deadlocks when we
6676 * re-enter the quota code and are already holding the mutex
6677 @@ -1635,6 +1638,9 @@ int dquot_alloc_inode(const struct inode
6678 struct dquot_warn warn[MAXQUOTAS];
6679 struct dquot * const *dquots = inode->i_dquot;
6681 + if ((ret = dl_alloc_inode(inode)))
6684 /* First test before acquiring mutex - solves deadlocks when we
6685 * re-enter the quota code and are already holding the mutex */
6686 if (!dquot_active(inode))
6687 @@ -1706,6 +1712,8 @@ void __dquot_free_space(struct inode *in
6688 struct dquot **dquots = inode->i_dquot;
6689 int reserve = flags & DQUOT_SPACE_RESERVE;
6691 + dl_free_space(inode, number);
6693 /* First test before acquiring mutex - solves deadlocks when we
6694 * re-enter the quota code and are already holding the mutex */
6695 if (!dquot_active(inode)) {
6696 @@ -1750,6 +1758,8 @@ void dquot_free_inode(const struct inode
6697 struct dquot_warn warn[MAXQUOTAS];
6698 struct dquot * const *dquots = inode->i_dquot;
6700 + dl_free_inode(inode);
6702 /* First test before acquiring mutex - solves deadlocks when we
6703 * re-enter the quota code and are already holding the mutex */
6704 if (!dquot_active(inode))
6705 diff -NurpP --minimal linux-3.6/fs/quota/quota.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/quota/quota.c
6706 --- linux-3.6/fs/quota/quota.c 2012-10-04 15:27:41.000000000 +0200
6707 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/quota/quota.c 2012-10-04 18:47:00.000000000 +0200
6709 #include <linux/fs.h>
6710 #include <linux/namei.h>
6711 #include <linux/slab.h>
6712 +#include <linux/vs_context.h>
6713 #include <asm/current.h>
6714 #include <linux/uaccess.h>
6715 #include <linux/kernel.h>
6716 @@ -37,7 +38,7 @@ static int check_quotactl_permission(str
6720 - if (!capable(CAP_SYS_ADMIN))
6721 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
6725 @@ -291,6 +292,46 @@ static int do_quotactl(struct super_bloc
6729 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6731 +#include <linux/vroot.h>
6732 +#include <linux/major.h>
6733 +#include <linux/module.h>
6734 +#include <linux/kallsyms.h>
6735 +#include <linux/vserver/debug.h>
6737 +static vroot_grb_func *vroot_get_real_bdev = NULL;
6739 +static DEFINE_SPINLOCK(vroot_grb_lock);
6741 +int register_vroot_grb(vroot_grb_func *func) {
6744 + spin_lock(&vroot_grb_lock);
6745 + if (!vroot_get_real_bdev) {
6746 + vroot_get_real_bdev = func;
6749 + spin_unlock(&vroot_grb_lock);
6752 +EXPORT_SYMBOL(register_vroot_grb);
6754 +int unregister_vroot_grb(vroot_grb_func *func) {
6755 + int ret = -EINVAL;
6757 + spin_lock(&vroot_grb_lock);
6758 + if (vroot_get_real_bdev) {
6759 + vroot_get_real_bdev = NULL;
6762 + spin_unlock(&vroot_grb_lock);
6765 +EXPORT_SYMBOL(unregister_vroot_grb);
6769 /* Return 1 if 'cmd' will block on frozen filesystem */
6770 static int quotactl_cmd_write(int cmd)
6772 @@ -323,6 +364,22 @@ static struct super_block *quotactl_bloc
6775 return ERR_CAST(bdev);
6776 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6777 + if (bdev && bdev->bd_inode &&
6778 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
6779 + struct block_device *bdnew = (void *)-EINVAL;
6781 + if (vroot_get_real_bdev)
6782 + bdnew = vroot_get_real_bdev(bdev);
6784 + vxdprintk(VXD_CBIT(misc, 0),
6785 + "vroot_get_real_bdev not set");
6787 + if (IS_ERR(bdnew))
6788 + return ERR_PTR(PTR_ERR(bdnew));
6792 if (quotactl_cmd_write(cmd))
6793 sb = get_super_thawed(bdev);
6795 diff -NurpP --minimal linux-3.6/fs/reiserfs/file.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/file.c
6796 --- linux-3.6/fs/reiserfs/file.c 2012-05-21 18:07:26.000000000 +0200
6797 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/file.c 2012-10-04 18:47:00.000000000 +0200
6798 @@ -319,5 +319,6 @@ const struct inode_operations reiserfs_f
6799 .listxattr = reiserfs_listxattr,
6800 .removexattr = reiserfs_removexattr,
6801 .permission = reiserfs_permission,
6802 + .sync_flags = reiserfs_sync_flags,
6803 .get_acl = reiserfs_get_acl,
6805 diff -NurpP --minimal linux-3.6/fs/reiserfs/inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/inode.c
6806 --- linux-3.6/fs/reiserfs/inode.c 2012-10-04 15:27:41.000000000 +0200
6807 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/inode.c 2012-10-04 18:47:00.000000000 +0200
6809 #include <linux/writeback.h>
6810 #include <linux/quotaops.h>
6811 #include <linux/swap.h>
6812 +#include <linux/vs_tag.h>
6814 int reiserfs_commit_write(struct file *f, struct page *page,
6815 unsigned from, unsigned to);
6816 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
6817 struct buffer_head *bh;
6818 struct item_head *ih;
6822 //int version = ITEM_VERSION_1;
6824 bh = PATH_PLAST_BUFFER(path);
6825 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
6826 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
6827 unsigned long blocks;
6829 + uid = sd_v1_uid(sd);
6830 + gid = sd_v1_gid(sd);
6832 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
6833 set_inode_sd_version(inode, STAT_DATA_V1);
6834 inode->i_mode = sd_v1_mode(sd);
6835 set_nlink(inode, sd_v1_nlink(sd));
6836 - inode->i_uid = sd_v1_uid(sd);
6837 - inode->i_gid = sd_v1_gid(sd);
6838 inode->i_size = sd_v1_size(sd);
6839 inode->i_atime.tv_sec = sd_v1_atime(sd);
6840 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
6841 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
6842 // (directories and symlinks)
6843 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
6845 + uid = sd_v2_uid(sd);
6846 + gid = sd_v2_gid(sd);
6848 inode->i_mode = sd_v2_mode(sd);
6849 set_nlink(inode, sd_v2_nlink(sd));
6850 - inode->i_uid = sd_v2_uid(sd);
6851 inode->i_size = sd_v2_size(sd);
6852 - inode->i_gid = sd_v2_gid(sd);
6853 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
6854 inode->i_atime.tv_sec = sd_v2_atime(sd);
6855 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
6856 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
6857 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
6860 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6861 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6862 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
6865 if (S_ISREG(inode->i_mode)) {
6866 inode->i_op = &reiserfs_file_inode_operations;
6867 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
6868 static void inode2sd(void *sd, struct inode *inode, loff_t size)
6870 struct stat_data *sd_v2 = (struct stat_data *)sd;
6871 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
6872 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
6875 + set_sd_v2_uid(sd_v2, uid);
6876 + set_sd_v2_gid(sd_v2, gid);
6877 set_sd_v2_mode(sd_v2, inode->i_mode);
6878 set_sd_v2_nlink(sd_v2, inode->i_nlink);
6879 - set_sd_v2_uid(sd_v2, inode->i_uid);
6880 set_sd_v2_size(sd_v2, size);
6881 - set_sd_v2_gid(sd_v2, inode->i_gid);
6882 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
6883 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
6884 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
6885 @@ -2862,14 +2873,19 @@ int reiserfs_commit_write(struct file *f
6886 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
6888 if (reiserfs_attrs(inode->i_sb)) {
6889 - if (sd_attrs & REISERFS_SYNC_FL)
6890 - inode->i_flags |= S_SYNC;
6892 - inode->i_flags &= ~S_SYNC;
6893 if (sd_attrs & REISERFS_IMMUTABLE_FL)
6894 inode->i_flags |= S_IMMUTABLE;
6896 inode->i_flags &= ~S_IMMUTABLE;
6897 + if (sd_attrs & REISERFS_IXUNLINK_FL)
6898 + inode->i_flags |= S_IXUNLINK;
6900 + inode->i_flags &= ~S_IXUNLINK;
6902 + if (sd_attrs & REISERFS_SYNC_FL)
6903 + inode->i_flags |= S_SYNC;
6905 + inode->i_flags &= ~S_SYNC;
6906 if (sd_attrs & REISERFS_APPEND_FL)
6907 inode->i_flags |= S_APPEND;
6909 @@ -2882,6 +2898,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
6910 REISERFS_I(inode)->i_flags |= i_nopack_mask;
6912 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
6914 + if (sd_attrs & REISERFS_BARRIER_FL)
6915 + inode->i_vflags |= V_BARRIER;
6917 + inode->i_vflags &= ~V_BARRIER;
6918 + if (sd_attrs & REISERFS_COW_FL)
6919 + inode->i_vflags |= V_COW;
6921 + inode->i_vflags &= ~V_COW;
6925 @@ -2892,6 +2917,11 @@ void i_attrs_to_sd_attrs(struct inode *i
6926 *sd_attrs |= REISERFS_IMMUTABLE_FL;
6928 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
6929 + if (inode->i_flags & S_IXUNLINK)
6930 + *sd_attrs |= REISERFS_IXUNLINK_FL;
6932 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
6934 if (inode->i_flags & S_SYNC)
6935 *sd_attrs |= REISERFS_SYNC_FL;
6937 @@ -2904,6 +2934,15 @@ void i_attrs_to_sd_attrs(struct inode *i
6938 *sd_attrs |= REISERFS_NOTAIL_FL;
6940 *sd_attrs &= ~REISERFS_NOTAIL_FL;
6942 + if (inode->i_vflags & V_BARRIER)
6943 + *sd_attrs |= REISERFS_BARRIER_FL;
6945 + *sd_attrs &= ~REISERFS_BARRIER_FL;
6946 + if (inode->i_vflags & V_COW)
6947 + *sd_attrs |= REISERFS_COW_FL;
6949 + *sd_attrs &= ~REISERFS_COW_FL;
6953 @@ -3149,7 +3188,8 @@ int reiserfs_setattr(struct dentry *dent
6956 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
6957 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
6958 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
6959 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
6960 struct reiserfs_transaction_handle th;
6963 @@ -3178,6 +3218,9 @@ int reiserfs_setattr(struct dentry *dent
6964 inode->i_uid = attr->ia_uid;
6965 if (attr->ia_valid & ATTR_GID)
6966 inode->i_gid = attr->ia_gid;
6967 + if ((attr->ia_valid & ATTR_TAG) &&
6969 + inode->i_tag = attr->ia_tag;
6970 mark_inode_dirty(inode);
6971 error = journal_end(&th, inode->i_sb, jbegin_count);
6973 diff -NurpP --minimal linux-3.6/fs/reiserfs/ioctl.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/ioctl.c
6974 --- linux-3.6/fs/reiserfs/ioctl.c 2012-05-21 18:07:27.000000000 +0200
6975 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/ioctl.c 2012-10-04 18:47:00.000000000 +0200
6977 #include <linux/pagemap.h>
6978 #include <linux/compat.h>
6981 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
6983 + __u16 sd_attrs = 0;
6985 + inode->i_flags = flags;
6986 + inode->i_vflags = vflags;
6988 + i_attrs_to_sd_attrs(inode, &sd_attrs);
6989 + REISERFS_I(inode)->i_attrs = sd_attrs;
6990 + inode->i_ctime = CURRENT_TIME_SEC;
6991 + mark_inode_dirty(inode);
6996 * reiserfs_ioctl - handler for ioctl for inode
6997 * supported commands:
6999 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7001 struct inode *inode = filp->f_path.dentry->d_inode;
7002 - unsigned int flags;
7003 + unsigned int flags, oldflags;
7006 reiserfs_write_lock(inode->i_sb);
7007 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7009 flags = REISERFS_I(inode)->i_attrs;
7010 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7011 + flags &= REISERFS_FL_USER_VISIBLE;
7012 err = put_user(flags, (int __user *)arg);
7014 case REISERFS_IOC_SETFLAGS:{
7015 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7019 + if (IS_BARRIER(inode)) {
7020 + vxwprintk_task(1, "messing with the barrier.");
7024 * Is it quota file? Do not allow user to mess with it
7026 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7031 + oldflags = REISERFS_I(inode)->i_attrs;
7032 + flags &= REISERFS_FL_USER_MODIFIABLE;
7033 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7034 sd_attrs_to_i_attrs(flags, inode);
7035 REISERFS_I(inode)->i_attrs = flags;
7036 inode->i_ctime = CURRENT_TIME_SEC;
7037 diff -NurpP --minimal linux-3.6/fs/reiserfs/namei.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/namei.c
7038 --- linux-3.6/fs/reiserfs/namei.c 2012-10-04 15:27:41.000000000 +0200
7039 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/namei.c 2012-10-04 18:47:00.000000000 +0200
7043 #include <linux/quotaops.h>
7044 +#include <linux/vs_tag.h>
7046 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) set_nlink(i, 1); }
7047 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7048 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7049 if (retval == IO_ERROR) {
7050 return ERR_PTR(-EIO);
7052 + dx_propagate_tag(nd, inode);
7054 return d_splice_alias(inode, dentry);
7056 diff -NurpP --minimal linux-3.6/fs/reiserfs/reiserfs.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/reiserfs.h
7057 --- linux-3.6/fs/reiserfs/reiserfs.h 2012-07-22 23:39:42.000000000 +0200
7058 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/reiserfs.h 2012-10-04 18:47:00.000000000 +0200
7059 @@ -549,6 +549,7 @@ enum reiserfs_mount_options {
7060 REISERFS_EXPOSE_PRIVROOT,
7061 REISERFS_BARRIER_NONE,
7062 REISERFS_BARRIER_FLUSH,
7065 /* Actions on error */
7066 REISERFS_ERROR_PANIC,
7067 @@ -1548,6 +1549,11 @@ struct stat_data_v1 {
7068 #define REISERFS_COMPR_FL FS_COMPR_FL
7069 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
7071 +/* unfortunately reiserfs sdattr is only 16 bit */
7072 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
7073 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
7074 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
7076 /* persistent flags that file inherits from the parent directory */
7077 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
7078 REISERFS_SYNC_FL | \
7079 @@ -1557,6 +1563,9 @@ struct stat_data_v1 {
7080 REISERFS_COMPR_FL | \
7081 REISERFS_NOTAIL_FL )
7083 +#define REISERFS_FL_USER_VISIBLE 0x80FF
7084 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
7086 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
7089 @@ -2647,6 +2656,7 @@ static inline void reiserfs_update_sd(st
7090 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
7091 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
7092 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
7093 +int reiserfs_sync_flags(struct inode *inode, int, int);
7095 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
7097 diff -NurpP --minimal linux-3.6/fs/reiserfs/super.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/super.c
7098 --- linux-3.6/fs/reiserfs/super.c 2012-10-04 15:27:41.000000000 +0200
7099 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/super.c 2012-10-04 18:47:00.000000000 +0200
7100 @@ -1018,6 +1018,14 @@ static int reiserfs_parse_options(struct
7101 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7102 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7104 +#ifndef CONFIG_TAGGING_NONE
7105 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7106 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7107 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7109 +#ifdef CONFIG_PROPAGATE
7110 + {"tag",.arg_required = 'T',.values = NULL},
7112 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7113 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7114 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7115 @@ -1336,6 +1344,14 @@ static int reiserfs_remount(struct super
7116 handle_quota_files(s, qf_names, &qfmt);
7119 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7120 + !(s->s_flags & MS_TAGGED)) {
7121 + reiserfs_warning(s, "super-vs01",
7122 + "reiserfs: tagging not permitted on remount.");
7129 /* Add options that are safe here */
7130 @@ -1816,6 +1832,10 @@ static int reiserfs_fill_super(struct su
7131 goto error_unlocked;
7134 + /* map mount option tagxid */
7135 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7136 + s->s_flags |= MS_TAGGED;
7138 rs = SB_DISK_SUPER_BLOCK(s);
7139 /* Let's do basic sanity check to verify that underlying device is not
7140 smaller than the filesystem. If the check fails then abort and scream,
7141 diff -NurpP --minimal linux-3.6/fs/reiserfs/xattr.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/xattr.c
7142 --- linux-3.6/fs/reiserfs/xattr.c 2012-10-04 15:27:41.000000000 +0200
7143 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/reiserfs/xattr.c 2012-10-04 18:47:00.000000000 +0200
7145 #include <linux/errno.h>
7146 #include <linux/gfp.h>
7147 #include <linux/fs.h>
7148 +#include <linux/mount.h>
7149 #include <linux/file.h>
7150 #include <linux/pagemap.h>
7151 #include <linux/xattr.h>
7152 diff -NurpP --minimal linux-3.6/fs/stat.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/stat.c
7153 --- linux-3.6/fs/stat.c 2012-10-04 15:27:41.000000000 +0200
7154 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/stat.c 2012-10-04 18:47:00.000000000 +0200
7155 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7156 stat->nlink = inode->i_nlink;
7157 stat->uid = inode->i_uid;
7158 stat->gid = inode->i_gid;
7159 + stat->tag = inode->i_tag;
7160 stat->rdev = inode->i_rdev;
7161 stat->size = i_size_read(inode);
7162 stat->atime = inode->i_atime;
7163 diff -NurpP --minimal linux-3.6/fs/statfs.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/statfs.c
7164 --- linux-3.6/fs/statfs.c 2012-07-22 23:39:42.000000000 +0200
7165 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/statfs.c 2012-10-04 18:47:00.000000000 +0200
7167 #include <linux/statfs.h>
7168 #include <linux/security.h>
7169 #include <linux/uaccess.h>
7170 +#include <linux/vs_base.h>
7171 +#include <linux/vs_dlimit.h>
7172 #include "internal.h"
7174 static int flags_by_mnt(int mnt_flags)
7175 @@ -60,6 +62,8 @@ static int statfs_by_dentry(struct dentr
7176 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7177 if (retval == 0 && buf->f_frsize == 0)
7178 buf->f_frsize = buf->f_bsize;
7179 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7180 + vx_vsi_statfs(dentry->d_sb, buf);
7184 diff -NurpP --minimal linux-3.6/fs/super.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/super.c
7185 --- linux-3.6/fs/super.c 2012-10-04 15:27:41.000000000 +0200
7186 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/super.c 2012-10-04 19:06:05.000000000 +0200
7188 #include <linux/cleancache.h>
7189 #include <linux/fsnotify.h>
7190 #include <linux/lockdep.h>
7191 +#include <linux/magic.h>
7192 +#include <linux/vs_context.h>
7193 #include "internal.h"
7196 @@ -1148,6 +1150,13 @@ mount_fs(struct file_system_type *type,
7197 WARN_ON(sb->s_bdi == &default_backing_dev_info);
7198 sb->s_flags |= MS_BORN;
7201 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
7203 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7204 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7207 error = security_sb_kern_mount(sb, flags, secdata);
7210 diff -NurpP --minimal linux-3.6/fs/sysfs/mount.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/sysfs/mount.c
7211 --- linux-3.6/fs/sysfs/mount.c 2012-10-04 15:27:41.000000000 +0200
7212 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/sysfs/mount.c 2012-10-04 18:47:00.000000000 +0200
7213 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7215 sb->s_blocksize = PAGE_CACHE_SIZE;
7216 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7217 - sb->s_magic = SYSFS_MAGIC;
7218 + sb->s_magic = SYSFS_SUPER_MAGIC;
7219 sb->s_op = &sysfs_ops;
7220 sb->s_time_gran = 1;
7222 diff -NurpP --minimal linux-3.6/fs/utimes.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/utimes.c
7223 --- linux-3.6/fs/utimes.c 2012-07-22 23:39:42.000000000 +0200
7224 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/utimes.c 2012-10-04 18:47:00.000000000 +0200
7226 #include <linux/stat.h>
7227 #include <linux/utime.h>
7228 #include <linux/syscalls.h>
7229 +#include <linux/mount.h>
7230 +#include <linux/vs_cowbl.h>
7231 #include <asm/uaccess.h>
7232 #include <asm/unistd.h>
7234 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7237 struct iattr newattrs;
7238 - struct inode *inode = path->dentry->d_inode;
7239 + struct inode *inode;
7241 error = mnt_want_write(path->mnt);
7245 + error = cow_check_and_break(path);
7247 + goto mnt_drop_write_and_out;
7249 + inode = path->dentry->d_inode;
7251 if (times && times[0].tv_nsec == UTIME_NOW &&
7252 times[1].tv_nsec == UTIME_NOW)
7254 diff -NurpP --minimal linux-3.6/fs/xattr.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xattr.c
7255 --- linux-3.6/fs/xattr.c 2012-10-04 15:27:44.000000000 +0200
7256 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xattr.c 2012-10-04 18:47:00.000000000 +0200
7258 #include <linux/fsnotify.h>
7259 #include <linux/audit.h>
7260 #include <linux/vmalloc.h>
7261 +#include <linux/mount.h>
7263 #include <asm/uaccess.h>
7265 @@ -51,7 +52,7 @@ xattr_permission(struct inode *inode, co
7266 * The trusted.* namespace can only be accessed by privileged users.
7268 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
7269 - if (!capable(CAP_SYS_ADMIN))
7270 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
7271 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
7274 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_dinode.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_dinode.h
7275 --- linux-3.6/fs/xfs/xfs_dinode.h 2012-10-04 15:27:44.000000000 +0200
7276 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_dinode.h 2012-10-04 18:47:00.000000000 +0200
7277 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
7278 __be32 di_nlink; /* number of links to file */
7279 __be16 di_projid_lo; /* lower part of owner's project id */
7280 __be16 di_projid_hi; /* higher part owner's project id */
7281 - __u8 di_pad[6]; /* unused, zeroed space */
7282 + __u8 di_pad[2]; /* unused, zeroed space */
7283 + __be16 di_tag; /* context tagging */
7284 + __be16 di_vflags; /* vserver specific flags */
7285 __be16 di_flushiter; /* incremented on flush */
7286 xfs_timestamp_t di_atime; /* time last accessed */
7287 xfs_timestamp_t di_mtime; /* time last modified */
7288 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
7289 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7290 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7291 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7292 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7294 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7295 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7296 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7297 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
7298 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7299 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7300 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7301 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7303 #ifdef CONFIG_XFS_RT
7304 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
7305 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
7306 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
7307 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
7308 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
7309 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
7310 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
7311 + XFS_DIFLAG_IXUNLINK)
7313 +#define XFS_DIVFLAG_BARRIER 0x01
7314 +#define XFS_DIVFLAG_COW 0x02
7316 #endif /* __XFS_DINODE_H__ */
7317 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_fs.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_fs.h
7318 --- linux-3.6/fs/xfs/xfs_fs.h 2011-10-24 18:45:31.000000000 +0200
7319 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_fs.h 2012-10-04 18:47:00.000000000 +0200
7320 @@ -67,6 +67,9 @@ struct fsxattr {
7321 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
7322 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
7323 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
7324 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
7325 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
7326 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
7327 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
7330 @@ -302,7 +305,8 @@ typedef struct xfs_bstat {
7331 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
7332 __u16 bs_forkoff; /* inode fork offset in bytes */
7333 __u16 bs_projid_hi; /* higher part of project id */
7334 - unsigned char bs_pad[10]; /* pad space, unused */
7335 + unsigned char bs_pad[8]; /* pad space, unused */
7336 + __u16 bs_tag; /* context tagging */
7337 __u32 bs_dmevmask; /* DMIG event mask */
7338 __u16 bs_dmstate; /* DMIG state info */
7339 __u16 bs_aextents; /* attribute number of extents */
7340 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_ialloc.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_ialloc.c
7341 --- linux-3.6/fs/xfs/xfs_ialloc.c 2012-10-04 15:27:44.000000000 +0200
7342 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_ialloc.c 2012-10-04 18:47:00.000000000 +0200
7344 #include "xfs_error.h"
7345 #include "xfs_bmap.h"
7349 * Allocation group level functions.
7351 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_inode.c
7352 --- linux-3.6/fs/xfs/xfs_inode.c 2012-10-04 15:27:44.000000000 +0200
7353 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_inode.c 2012-10-04 18:47:00.000000000 +0200
7354 @@ -1833,6 +1833,7 @@ xfs_iroot_realloc(
7358 +#include <linux/vs_tag.h>
7361 * This is called when the amount of space needed for if_data
7362 @@ -2521,7 +2522,8 @@ xfs_iflush_int(
7363 * because if the inode is dirty at all the core must
7366 - xfs_dinode_to_disk(dip, &ip->i_d);
7367 + xfs_dinode_to_disk(dip, &ip->i_d,
7368 + mp->m_flags & XFS_MOUNT_TAGGED);
7370 /* Wrap, we never let the log put out DI_MAX_FLUSH */
7371 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
7372 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_inode.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_inode.h
7373 --- linux-3.6/fs/xfs/xfs_inode.h 2012-10-04 15:27:44.000000000 +0200
7374 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_inode.h 2012-10-04 18:47:00.000000000 +0200
7375 @@ -134,7 +134,9 @@ typedef struct xfs_icdinode {
7376 __uint32_t di_nlink; /* number of links to file */
7377 __uint16_t di_projid_lo; /* lower part of owner's project id */
7378 __uint16_t di_projid_hi; /* higher part of owner's project id */
7379 - __uint8_t di_pad[6]; /* unused, zeroed space */
7380 + __uint8_t di_pad[2]; /* unused, zeroed space */
7381 + __uint16_t di_tag; /* context tagging */
7382 + __uint16_t di_vflags; /* vserver specific flags */
7383 __uint16_t di_flushiter; /* incremented on flush */
7384 xfs_ictimestamp_t di_atime; /* time last accessed */
7385 xfs_ictimestamp_t di_mtime; /* time last modified */
7386 @@ -561,7 +563,7 @@ int xfs_imap_to_bp(struct xfs_mount *,
7387 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
7388 struct xfs_inode *, uint);
7389 void xfs_dinode_to_disk(struct xfs_dinode *,
7390 - struct xfs_icdinode *);
7391 + struct xfs_icdinode *, int);
7392 void xfs_idestroy_fork(struct xfs_inode *, int);
7393 void xfs_idata_realloc(struct xfs_inode *, int, int);
7394 void xfs_iroot_realloc(struct xfs_inode *, int, int);
7395 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_ioctl.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_ioctl.c
7396 --- linux-3.6/fs/xfs/xfs_ioctl.c 2012-10-04 15:27:44.000000000 +0200
7397 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_ioctl.c 2012-10-04 18:47:00.000000000 +0200
7399 #include "xfs_bmap_btree.h"
7400 #include "xfs_dinode.h"
7401 #include "xfs_inode.h"
7402 -#include "xfs_ioctl.h"
7403 +// #include "xfs_ioctl.h"
7404 #include "xfs_rtalloc.h"
7405 #include "xfs_itable.h"
7406 #include "xfs_error.h"
7407 @@ -762,6 +762,10 @@ xfs_merge_ioc_xflags(
7408 xflags |= XFS_XFLAG_IMMUTABLE;
7410 xflags &= ~XFS_XFLAG_IMMUTABLE;
7411 + if (flags & FS_IXUNLINK_FL)
7412 + xflags |= XFS_XFLAG_IXUNLINK;
7414 + xflags &= ~XFS_XFLAG_IXUNLINK;
7415 if (flags & FS_APPEND_FL)
7416 xflags |= XFS_XFLAG_APPEND;
7418 @@ -790,6 +794,8 @@ xfs_di2lxflags(
7420 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7421 flags |= FS_IMMUTABLE_FL;
7422 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7423 + flags |= FS_IXUNLINK_FL;
7424 if (di_flags & XFS_DIFLAG_APPEND)
7425 flags |= FS_APPEND_FL;
7426 if (di_flags & XFS_DIFLAG_SYNC)
7427 @@ -850,6 +856,8 @@ xfs_set_diflags(
7428 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7429 if (xflags & XFS_XFLAG_IMMUTABLE)
7430 di_flags |= XFS_DIFLAG_IMMUTABLE;
7431 + if (xflags & XFS_XFLAG_IXUNLINK)
7432 + di_flags |= XFS_DIFLAG_IXUNLINK;
7433 if (xflags & XFS_XFLAG_APPEND)
7434 di_flags |= XFS_DIFLAG_APPEND;
7435 if (xflags & XFS_XFLAG_SYNC)
7436 @@ -892,6 +900,10 @@ xfs_diflags_to_linux(
7437 inode->i_flags |= S_IMMUTABLE;
7439 inode->i_flags &= ~S_IMMUTABLE;
7440 + if (xflags & XFS_XFLAG_IXUNLINK)
7441 + inode->i_flags |= S_IXUNLINK;
7443 + inode->i_flags &= ~S_IXUNLINK;
7444 if (xflags & XFS_XFLAG_APPEND)
7445 inode->i_flags |= S_APPEND;
7447 @@ -1396,10 +1408,18 @@ xfs_file_ioctl(
7448 case XFS_IOC_FSGETXATTRA:
7449 return xfs_ioc_fsgetxattr(ip, 1, arg);
7450 case XFS_IOC_FSSETXATTR:
7451 + if (IS_BARRIER(inode)) {
7452 + vxwprintk_task(1, "messing with the barrier.");
7453 + return -XFS_ERROR(EACCES);
7455 return xfs_ioc_fssetxattr(ip, filp, arg);
7456 case XFS_IOC_GETXFLAGS:
7457 return xfs_ioc_getxflags(ip, arg);
7458 case XFS_IOC_SETXFLAGS:
7459 + if (IS_BARRIER(inode)) {
7460 + vxwprintk_task(1, "messing with the barrier.");
7461 + return -XFS_ERROR(EACCES);
7463 return xfs_ioc_setxflags(ip, filp, arg);
7465 case XFS_IOC_FSSETDM: {
7466 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_ioctl.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_ioctl.h
7467 --- linux-3.6/fs/xfs/xfs_ioctl.h 2011-10-24 18:45:31.000000000 +0200
7468 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_ioctl.h 2012-10-04 18:47:00.000000000 +0200
7469 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7470 void __user *uhandle,
7475 + struct inode *inode,
7482 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_iops.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_iops.c
7483 --- linux-3.6/fs/xfs/xfs_iops.c 2012-10-04 15:27:44.000000000 +0200
7484 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_iops.c 2012-10-04 18:47:00.000000000 +0200
7486 #include "xfs_bmap_btree.h"
7487 #include "xfs_dinode.h"
7488 #include "xfs_inode.h"
7489 +#include "xfs_ioctl.h"
7490 #include "xfs_bmap.h"
7491 #include "xfs_rtalloc.h"
7492 #include "xfs_error.h"
7494 #include <linux/security.h>
7495 #include <linux/fiemap.h>
7496 #include <linux/slab.h>
7497 +#include <linux/vs_tag.h>
7501 @@ -421,6 +423,7 @@ xfs_vn_getattr(
7502 stat->nlink = ip->i_d.di_nlink;
7503 stat->uid = ip->i_d.di_uid;
7504 stat->gid = ip->i_d.di_gid;
7505 + stat->tag = ip->i_d.di_tag;
7506 stat->ino = ip->i_ino;
7507 stat->atime = inode->i_atime;
7508 stat->mtime = inode->i_mtime;
7509 @@ -1110,6 +1113,10 @@ xfs_diflags_to_iflags(
7510 inode->i_flags |= S_IMMUTABLE;
7512 inode->i_flags &= ~S_IMMUTABLE;
7513 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7514 + inode->i_flags |= S_IXUNLINK;
7516 + inode->i_flags &= ~S_IXUNLINK;
7517 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7518 inode->i_flags |= S_APPEND;
7520 @@ -1122,6 +1129,15 @@ xfs_diflags_to_iflags(
7521 inode->i_flags |= S_NOATIME;
7523 inode->i_flags &= ~S_NOATIME;
7525 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7526 + inode->i_vflags |= V_BARRIER;
7528 + inode->i_vflags &= ~V_BARRIER;
7529 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7530 + inode->i_vflags |= V_COW;
7532 + inode->i_vflags &= ~V_COW;
7536 @@ -1153,6 +1169,7 @@ xfs_setup_inode(
7537 set_nlink(inode, ip->i_d.di_nlink);
7538 inode->i_uid = ip->i_d.di_uid;
7539 inode->i_gid = ip->i_d.di_gid;
7540 + inode->i_tag = ip->i_d.di_tag;
7542 switch (inode->i_mode & S_IFMT) {
7544 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_itable.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_itable.c
7545 --- linux-3.6/fs/xfs/xfs_itable.c 2012-10-04 15:27:44.000000000 +0200
7546 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_itable.c 2012-10-04 18:47:00.000000000 +0200
7547 @@ -96,6 +96,7 @@ xfs_bulkstat_one_int(
7548 buf->bs_mode = dic->di_mode;
7549 buf->bs_uid = dic->di_uid;
7550 buf->bs_gid = dic->di_gid;
7551 + buf->bs_tag = dic->di_tag;
7552 buf->bs_size = dic->di_size;
7553 buf->bs_atime.tv_sec = dic->di_atime.t_sec;
7554 buf->bs_atime.tv_nsec = dic->di_atime.t_nsec;
7555 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_linux.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_linux.h
7556 --- linux-3.6/fs/xfs/xfs_linux.h 2011-10-24 18:45:31.000000000 +0200
7557 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_linux.h 2012-10-04 18:47:00.000000000 +0200
7560 #define current_cpu() (raw_smp_processor_id())
7561 #define current_pid() (current->pid)
7562 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7563 #define current_test_flags(f) (current->flags & (f))
7564 #define current_set_flags_nested(sp, f) \
7565 (*(sp) = current->flags, current->flags |= (f))
7566 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_log_recover.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_log_recover.c
7567 --- linux-3.6/fs/xfs/xfs_log_recover.c 2012-10-04 15:27:44.000000000 +0200
7568 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_log_recover.c 2012-10-04 18:47:00.000000000 +0200
7569 @@ -2359,7 +2359,8 @@ xlog_recover_inode_pass2(
7572 /* The core is in in-core format */
7573 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
7574 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
7575 + mp->m_flags & XFS_MOUNT_TAGGED);
7577 /* the rest is in on-disk format */
7578 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
7579 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_mount.h linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_mount.h
7580 --- linux-3.6/fs/xfs/xfs_mount.h 2012-10-04 15:27:44.000000000 +0200
7581 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_mount.h 2012-10-04 18:47:00.000000000 +0200
7582 @@ -251,6 +251,7 @@ typedef struct xfs_mount {
7584 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
7586 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
7589 * Default minimum read and write sizes.
7590 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_super.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_super.c
7591 --- linux-3.6/fs/xfs/xfs_super.c 2012-10-04 15:27:44.000000000 +0200
7592 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_super.c 2012-10-04 18:47:00.000000000 +0200
7593 @@ -112,6 +112,9 @@ mempool_t *xfs_ioend_pool;
7594 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7595 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7596 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7597 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7598 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7599 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7602 * Table driven mount option parser.
7603 @@ -120,10 +123,14 @@ mempool_t *xfs_ioend_pool;
7604 * in the future, too.
7607 + Opt_tag, Opt_notag,
7608 Opt_barrier, Opt_nobarrier, Opt_err
7611 static const match_table_t tokens = {
7612 + {Opt_tag, "tagxid"},
7614 + {Opt_notag, "notag"},
7615 {Opt_barrier, "barrier"},
7616 {Opt_nobarrier, "nobarrier"},
7618 @@ -371,6 +378,19 @@ xfs_parseargs(
7619 } else if (!strcmp(this_char, "irixsgid")) {
7621 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7622 +#ifndef CONFIG_TAGGING_NONE
7623 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7624 + mp->m_flags |= XFS_MOUNT_TAGGED;
7625 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7626 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7627 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7628 + mp->m_flags |= XFS_MOUNT_TAGGED;
7630 +#ifdef CONFIG_PROPAGATE
7631 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7633 + mp->m_flags |= XFS_MOUNT_TAGGED;
7636 xfs_warn(mp, "unknown mount option [%s].", this_char);
7638 @@ -1056,6 +1076,16 @@ xfs_fs_remount(
7640 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7643 + if (!(sb->s_flags & MS_TAGGED)) {
7645 + "XFS: %s: tagging not permitted on remount.\n",
7654 * Logically we would return an error here to prevent
7655 @@ -1275,6 +1305,9 @@ xfs_fs_fill_super(
7659 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7660 + sb->s_flags |= MS_TAGGED;
7663 * we must configure the block size in the superblock before we run the
7664 * full mount process as the mount process can lookup and cache inodes.
7665 diff -NurpP --minimal linux-3.6/fs/xfs/xfs_vnodeops.c linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_vnodeops.c
7666 --- linux-3.6/fs/xfs/xfs_vnodeops.c 2012-10-04 15:27:44.000000000 +0200
7667 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/fs/xfs/xfs_vnodeops.c 2012-10-04 18:47:00.000000000 +0200
7668 @@ -103,6 +103,77 @@ xfs_readlink_bmap(
7674 +xfs_get_inode_flags(
7677 + struct inode *inode = VFS_I(ip);
7678 + unsigned int flags = inode->i_flags;
7679 + unsigned int vflags = inode->i_vflags;
7681 + if (flags & S_IMMUTABLE)
7682 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
7684 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
7685 + if (flags & S_IXUNLINK)
7686 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
7688 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
7690 + if (vflags & V_BARRIER)
7691 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
7693 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
7694 + if (vflags & V_COW)
7695 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
7697 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
7702 + struct inode *inode,
7706 + struct xfs_inode *ip = XFS_I(inode);
7707 + struct xfs_mount *mp = ip->i_mount;
7708 + struct xfs_trans *tp;
7709 + unsigned int lock_flags = 0;
7712 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
7713 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
7717 + xfs_ilock(ip, XFS_ILOCK_EXCL);
7718 + xfs_trans_ijoin(tp, ip, 0);
7720 + inode->i_flags = flags;
7721 + inode->i_vflags = vflags;
7722 + xfs_get_inode_flags(ip);
7724 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
7725 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
7727 + XFS_STATS_INC(xs_ig_attrchg);
7729 + if (mp->m_flags & XFS_MOUNT_WSYNC)
7730 + xfs_trans_set_sync(tp);
7731 + code = xfs_trans_commit(tp, 0);
7732 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7736 + xfs_trans_cancel(tp, 0);
7738 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7746 diff -NurpP --minimal linux-3.6/include/linux/Kbuild linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/Kbuild
7747 --- linux-3.6/include/linux/Kbuild 2012-10-04 15:27:45.000000000 +0200
7748 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/Kbuild 2012-10-04 18:47:00.000000000 +0200
7749 @@ -18,6 +18,7 @@ header-y += netfilter_bridge/
7750 header-y += netfilter_ipv4/
7751 header-y += netfilter_ipv6/
7753 +header-y += vserver/
7756 objhdr-y += version.h
7757 diff -NurpP --minimal linux-3.6/include/linux/capability.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/capability.h
7758 --- linux-3.6/include/linux/capability.h 2012-07-22 23:39:43.000000000 +0200
7759 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/capability.h 2012-10-04 18:47:00.000000000 +0200
7760 @@ -280,6 +280,7 @@ struct cpu_vfs_cap_data {
7761 arbitrary SCSI commands */
7762 /* Allow setting encryption key on loopback filesystem */
7763 /* Allow setting zone reclaim policy */
7764 +/* Allow the selection of a security context */
7766 #define CAP_SYS_ADMIN 21
7768 @@ -366,7 +367,12 @@ struct cpu_vfs_cap_data {
7770 #define CAP_LAST_CAP CAP_BLOCK_SUSPEND
7772 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
7773 +/* Allow context manipulations */
7774 +/* Allow changing context info on files */
7776 +#define CAP_CONTEXT 63
7778 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
7781 * Bit location of each capability (used by user-space library and kernel)
7782 diff -NurpP --minimal linux-3.6/include/linux/cred.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/cred.h
7783 --- linux-3.6/include/linux/cred.h 2012-07-22 23:39:43.000000000 +0200
7784 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/cred.h 2012-10-04 18:47:00.000000000 +0200
7785 @@ -157,6 +157,7 @@ extern void exit_creds(struct task_struc
7786 extern int copy_creds(struct task_struct *, unsigned long);
7787 extern const struct cred *get_task_cred(struct task_struct *);
7788 extern struct cred *cred_alloc_blank(void);
7789 +extern struct cred *__prepare_creds(const struct cred *);
7790 extern struct cred *prepare_creds(void);
7791 extern struct cred *prepare_exec_creds(void);
7792 extern int commit_creds(struct cred *);
7793 @@ -210,6 +211,31 @@ static inline void validate_process_cred
7797 +static inline void set_cred_subscribers(struct cred *cred, int n)
7799 +#ifdef CONFIG_DEBUG_CREDENTIALS
7800 + atomic_set(&cred->subscribers, n);
7804 +static inline int read_cred_subscribers(const struct cred *cred)
7806 +#ifdef CONFIG_DEBUG_CREDENTIALS
7807 + return atomic_read(&cred->subscribers);
7813 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
7815 +#ifdef CONFIG_DEBUG_CREDENTIALS
7816 + struct cred *cred = (struct cred *) _cred;
7818 + atomic_add(n, &cred->subscribers);
7823 * get_new_cred - Get a reference on a new set of credentials
7824 * @cred: The new credentials to reference
7825 diff -NurpP --minimal linux-3.6/include/linux/devpts_fs.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/devpts_fs.h
7826 --- linux-3.6/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
7827 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/devpts_fs.h 2012-10-04 18:47:00.000000000 +0200
7828 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
7833 #endif /* _LINUX_DEVPTS_FS_H */
7834 diff -NurpP --minimal linux-3.6/include/linux/fs.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/fs.h
7835 --- linux-3.6/include/linux/fs.h 2012-10-04 15:27:45.000000000 +0200
7836 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/fs.h 2012-10-04 18:47:00.000000000 +0200
7837 @@ -225,6 +225,9 @@ struct inodes_stat_t {
7838 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
7839 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
7840 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
7841 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
7842 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
7843 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
7844 #define MS_NOSEC (1<<28)
7845 #define MS_BORN (1<<29)
7846 #define MS_ACTIVE (1<<30)
7847 @@ -256,6 +259,14 @@ struct inodes_stat_t {
7848 #define S_IMA 1024 /* Inode has an associated IMA struct */
7849 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
7850 #define S_NOSEC 4096 /* no suid or xattr security attributes */
7851 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
7853 +/* Linux-VServer related Inode flags */
7857 +#define V_BARRIER 4 /* Barrier for chroot() */
7858 +#define V_COW 8 /* Copy on Write */
7861 * Note that nosuid etc flags are inode-specific: setting some file-system
7862 @@ -278,12 +289,15 @@ struct inodes_stat_t {
7863 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
7864 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
7865 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
7866 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
7867 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
7868 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
7869 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
7870 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
7872 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
7873 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
7874 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
7875 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
7876 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
7877 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
7879 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
7880 @@ -294,6 +308,16 @@ struct inodes_stat_t {
7881 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
7882 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
7884 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
7886 +#ifdef CONFIG_VSERVER_COWBL
7887 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
7888 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
7890 +# define IS_COW(inode) (0)
7891 +# define IS_COW_LINK(inode) (0)
7894 /* the read-only stuff doesn't really belong here, but any other place is
7895 probably as bad and I don't want to create yet another include file. */
7897 @@ -380,11 +404,14 @@ struct inodes_stat_t {
7898 #define FS_EXTENT_FL 0x00080000 /* Extents */
7899 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
7900 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
7901 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
7902 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
7904 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
7905 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
7906 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
7907 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
7909 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
7910 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
7912 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
7913 #define SYNC_FILE_RANGE_WRITE 2
7914 @@ -472,6 +499,7 @@ typedef void (dio_iodone_t)(struct kiocb
7915 #define ATTR_KILL_PRIV (1 << 14)
7916 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
7917 #define ATTR_TIMES_SET (1 << 16)
7918 +#define ATTR_TAG (1 << 17)
7921 * This is the Inode Attributes structure, used for notify_change(). It
7922 @@ -487,6 +515,7 @@ struct iattr {
7928 struct timespec ia_atime;
7929 struct timespec ia_mtime;
7930 @@ -500,6 +529,9 @@ struct iattr {
7931 struct file *ia_file;
7934 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
7935 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
7938 * Includes for diskquotas.
7940 @@ -784,7 +816,9 @@ struct inode {
7941 unsigned short i_opflags;
7944 - unsigned int i_flags;
7946 + unsigned short i_flags;
7947 + unsigned short i_vflags;
7949 #ifdef CONFIG_FS_POSIX_ACL
7950 struct posix_acl *i_acl;
7951 @@ -813,6 +847,7 @@ struct inode {
7952 unsigned int __i_nlink;
7957 struct timespec i_atime;
7958 struct timespec i_mtime;
7959 @@ -975,12 +1010,12 @@ static inline void i_gid_write(struct in
7961 static inline unsigned iminor(const struct inode *inode)
7963 - return MINOR(inode->i_rdev);
7964 + return MINOR(inode->i_mdev);
7967 static inline unsigned imajor(const struct inode *inode)
7969 - return MAJOR(inode->i_rdev);
7970 + return MAJOR(inode->i_mdev);
7973 extern struct block_device *I_BDEV(struct inode *inode);
7974 @@ -1047,6 +1082,7 @@ struct file {
7976 struct fown_struct f_owner;
7977 const struct cred *f_cred;
7979 struct file_ra_state f_ra;
7982 @@ -1194,6 +1230,7 @@ struct file_lock {
7983 struct file *fl_file;
7988 struct fasync_struct * fl_fasync; /* for lease break notifications */
7989 /* for lease breaks: */
7990 @@ -1829,6 +1866,7 @@ struct inode_operations {
7991 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
7992 ssize_t (*listxattr) (struct dentry *, char *, size_t);
7993 int (*removexattr) (struct dentry *, const char *);
7994 + int (*sync_flags) (struct inode *, int, int);
7995 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
7997 int (*update_time)(struct inode *, struct timespec *, int);
7998 @@ -1850,6 +1888,7 @@ extern ssize_t vfs_readv(struct file *,
7999 unsigned long, loff_t *);
8000 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8001 unsigned long, loff_t *);
8002 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8004 struct super_operations {
8005 struct inode *(*alloc_inode)(struct super_block *sb);
8006 @@ -2692,6 +2731,7 @@ extern int dcache_dir_open(struct inode
8007 extern int dcache_dir_close(struct inode *, struct file *);
8008 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8009 extern int dcache_readdir(struct file *, void *, filldir_t);
8010 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8011 extern int simple_setattr(struct dentry *, struct iattr *);
8012 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8013 extern int simple_statfs(struct dentry *, struct kstatfs *);
8014 diff -NurpP --minimal linux-3.6/include/linux/gfs2_ondisk.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/gfs2_ondisk.h
8015 --- linux-3.6/include/linux/gfs2_ondisk.h 2012-10-04 15:27:45.000000000 +0200
8016 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/gfs2_ondisk.h 2012-10-04 18:54:29.000000000 +0200
8017 @@ -225,6 +225,9 @@ enum {
8020 gfs2fl_TopLevel = 10,
8021 + gfs2fl_IXUnlink = 16,
8022 + gfs2fl_Barrier = 17,
8024 gfs2fl_TruncInProg = 29,
8025 gfs2fl_InheritDirectio = 30,
8026 gfs2fl_InheritJdata = 31,
8027 @@ -242,6 +245,9 @@ enum {
8028 #define GFS2_DIF_SYNC 0x00000100
8029 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8030 #define GFS2_DIF_TOPDIR 0x00000400 /* New in gfs2 */
8031 +#define GFS2_DIF_IXUNLINK 0x00010000
8032 +#define GFS2_DIF_BARRIER 0x00020000
8033 +#define GFS2_DIF_COW 0x00040000
8034 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8035 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000 /* only in gfs1 */
8036 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8037 diff -NurpP --minimal linux-3.6/include/linux/if_tun.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/if_tun.h
8038 --- linux-3.6/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8039 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/if_tun.h 2012-10-04 18:47:00.000000000 +0200
8041 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8042 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8043 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8044 +#define TUNSETNID _IOW('T', 217, int)
8046 /* TUNSETIFF ifr flags */
8047 #define IFF_TUN 0x0001
8048 diff -NurpP --minimal linux-3.6/include/linux/init_task.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/init_task.h
8049 --- linux-3.6/include/linux/init_task.h 2012-10-04 15:27:45.000000000 +0200
8050 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/init_task.h 2012-10-04 18:47:00.000000000 +0200
8051 @@ -210,6 +210,10 @@ extern struct task_group root_task_group
8052 INIT_TRACE_RECURSION \
8053 INIT_TASK_RCU_PREEMPT(tsk) \
8056 + .vx_info = NULL, \
8058 + .nx_info = NULL, \
8062 diff -NurpP --minimal linux-3.6/include/linux/ipc.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/ipc.h
8063 --- linux-3.6/include/linux/ipc.h 2012-03-19 19:47:28.000000000 +0100
8064 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/ipc.h 2012-10-04 18:47:00.000000000 +0200
8065 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8073 diff -NurpP --minimal linux-3.6/include/linux/ipc_namespace.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/ipc_namespace.h
8074 --- linux-3.6/include/linux/ipc_namespace.h 2012-07-22 23:39:43.000000000 +0200
8075 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/ipc_namespace.h 2012-10-04 18:47:00.000000000 +0200
8076 @@ -133,7 +133,8 @@ static inline int mq_init_ns(struct ipc_
8078 #if defined(CONFIG_IPC_NS)
8079 extern struct ipc_namespace *copy_ipcs(unsigned long flags,
8080 - struct task_struct *tsk);
8081 + struct ipc_namespace *old_ns,
8082 + struct user_namespace *user_ns);
8083 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8086 @@ -144,12 +145,13 @@ static inline struct ipc_namespace *get_
8087 extern void put_ipc_ns(struct ipc_namespace *ns);
8089 static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
8090 - struct task_struct *tsk)
8091 + struct ipc_namespace *old_ns,
8092 + struct user_namespace *user_ns)
8094 if (flags & CLONE_NEWIPC)
8095 return ERR_PTR(-EINVAL);
8097 - return tsk->nsproxy->ipc_ns;
8101 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8102 diff -NurpP --minimal linux-3.6/include/linux/loop.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/loop.h
8103 --- linux-3.6/include/linux/loop.h 2012-01-09 16:14:58.000000000 +0100
8104 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/loop.h 2012-10-04 18:47:00.000000000 +0200
8105 @@ -45,6 +45,7 @@ struct loop_device {
8106 struct loop_func_table *lo_encryption;
8108 uid_t lo_key_owner; /* Who set the key */
8110 int (*ioctl)(struct loop_device *, int cmd,
8113 diff -NurpP --minimal linux-3.6/include/linux/magic.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/magic.h
8114 --- linux-3.6/include/linux/magic.h 2012-05-21 18:07:31.000000000 +0200
8115 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/magic.h 2012-10-04 18:47:00.000000000 +0200
8118 #define ADFS_SUPER_MAGIC 0xadf5
8119 #define AFFS_SUPER_MAGIC 0xadff
8120 -#define AFS_SUPER_MAGIC 0x5346414F
8121 +#define AFS_SUPER_MAGIC 0x5346414F
8122 #define AUTOFS_SUPER_MAGIC 0x0187
8123 #define CODA_SUPER_MAGIC 0x73757245
8124 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8125 diff -NurpP --minimal linux-3.6/include/linux/major.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/major.h
8126 --- linux-3.6/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8127 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/major.h 2012-10-04 18:47:00.000000000 +0200
8129 #define HD_MAJOR IDE0_MAJOR
8130 #define PTY_SLAVE_MAJOR 3
8132 +#define VROOT_MAJOR 4
8133 #define TTYAUX_MAJOR 5
8136 diff -NurpP --minimal linux-3.6/include/linux/memcontrol.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/memcontrol.h
8137 --- linux-3.6/include/linux/memcontrol.h 2012-10-04 15:27:45.000000000 +0200
8138 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/memcontrol.h 2012-10-04 18:47:00.000000000 +0200
8139 @@ -83,6 +83,13 @@ extern struct mem_cgroup *try_get_mem_cg
8140 extern struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg);
8141 extern struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont);
8143 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8144 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8146 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8147 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8148 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8151 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8153 diff -NurpP --minimal linux-3.6/include/linux/mm_types.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/mm_types.h
8154 --- linux-3.6/include/linux/mm_types.h 2012-10-04 15:27:46.000000000 +0200
8155 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/mm_types.h 2012-10-04 18:47:00.000000000 +0200
8156 @@ -370,6 +370,7 @@ struct mm_struct {
8158 /* Architecture-specific MM context */
8159 mm_context_t context;
8160 + struct vx_info *mm_vx_info;
8162 unsigned long flags; /* Must use atomic bitops to access the bits */
8164 diff -NurpP --minimal linux-3.6/include/linux/mmzone.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/mmzone.h
8165 --- linux-3.6/include/linux/mmzone.h 2012-10-04 15:27:46.000000000 +0200
8166 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/mmzone.h 2012-10-04 18:47:00.000000000 +0200
8167 @@ -727,6 +727,13 @@ typedef struct pglist_data {
8168 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8171 +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
8173 +#define node_end_pfn(nid) ({\
8174 + pg_data_t *__pgdat = NODE_DATA(nid);\
8175 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8178 #include <linux/memory_hotplug.h>
8180 extern struct mutex zonelists_mutex;
8181 diff -NurpP --minimal linux-3.6/include/linux/mount.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/mount.h
8182 --- linux-3.6/include/linux/mount.h 2012-03-19 19:47:28.000000000 +0100
8183 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/mount.h 2012-10-04 18:47:00.000000000 +0200
8184 @@ -47,6 +47,9 @@ struct mnt_namespace;
8186 #define MNT_INTERNAL 0x4000
8188 +#define MNT_TAGID 0x10000
8189 +#define MNT_NOTAG 0x20000
8192 struct dentry *mnt_root; /* root of the mounted tree */
8193 struct super_block *mnt_sb; /* pointer to superblock */
8194 diff -NurpP --minimal linux-3.6/include/linux/net.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/net.h
8195 --- linux-3.6/include/linux/net.h 2012-10-04 15:27:46.000000000 +0200
8196 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/net.h 2012-10-04 18:47:00.000000000 +0200
8197 @@ -73,6 +73,7 @@ struct net;
8198 #define SOCK_PASSCRED 3
8199 #define SOCK_PASSSEC 4
8200 #define SOCK_EXTERNALLY_ALLOCATED 5
8201 +#define SOCK_USER_SOCKET 6
8203 #ifndef ARCH_HAS_SOCKET_TYPES
8205 diff -NurpP --minimal linux-3.6/include/linux/netdevice.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/netdevice.h
8206 --- linux-3.6/include/linux/netdevice.h 2012-10-04 15:27:46.000000000 +0200
8207 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/netdevice.h 2012-10-04 18:47:00.000000000 +0200
8208 @@ -1651,6 +1651,7 @@ extern void netdev_resync_ops(struct ne
8210 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
8211 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
8212 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
8213 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
8214 extern int dev_restart(struct net_device *dev);
8215 #ifdef CONFIG_NETPOLL_TRAP
8216 diff -NurpP --minimal linux-3.6/include/linux/nfs_mount.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/nfs_mount.h
8217 --- linux-3.6/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
8218 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/nfs_mount.h 2012-10-04 18:47:00.000000000 +0200
8219 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8220 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8221 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8222 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8223 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8224 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8225 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8227 /* The following are for internal use only */
8228 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8229 diff -NurpP --minimal linux-3.6/include/linux/nsproxy.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/nsproxy.h
8230 --- linux-3.6/include/linux/nsproxy.h 2011-10-24 18:45:32.000000000 +0200
8231 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/nsproxy.h 2012-10-04 18:47:00.000000000 +0200
8234 #include <linux/spinlock.h>
8235 #include <linux/sched.h>
8236 +#include <linux/vserver/debug.h>
8238 struct mnt_namespace;
8239 struct uts_namespace;
8240 @@ -63,6 +64,7 @@ static inline struct nsproxy *task_nspro
8243 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8244 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8245 void exit_task_namespaces(struct task_struct *tsk);
8246 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8247 void free_nsproxy(struct nsproxy *ns);
8248 @@ -70,16 +72,26 @@ int unshare_nsproxy_namespaces(unsigned
8249 struct fs_struct *);
8250 int __init nsproxy_cache_init(void);
8252 -static inline void put_nsproxy(struct nsproxy *ns)
8253 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8255 +static inline void __get_nsproxy(struct nsproxy *ns,
8256 + const char *_file, int _line)
8258 - if (atomic_dec_and_test(&ns->count)) {
8261 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8262 + ns, atomic_read(&ns->count), _file, _line);
8263 + atomic_inc(&ns->count);
8266 -static inline void get_nsproxy(struct nsproxy *ns)
8267 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8269 +static inline void __put_nsproxy(struct nsproxy *ns,
8270 + const char *_file, int _line)
8272 - atomic_inc(&ns->count);
8273 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8274 + ns, atomic_read(&ns->count), _file, _line);
8275 + if (atomic_dec_and_test(&ns->count)) {
8281 diff -NurpP --minimal linux-3.6/include/linux/pid.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/pid.h
8282 --- linux-3.6/include/linux/pid.h 2011-07-22 11:18:11.000000000 +0200
8283 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/pid.h 2012-10-04 18:47:00.000000000 +0200
8284 @@ -8,7 +8,8 @@ enum pid_type
8294 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
8297 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8298 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8299 pid_t pid_vnr(struct pid *pid);
8301 #define do_each_pid_task(pid, type, task) \
8302 diff -NurpP --minimal linux-3.6/include/linux/proc_fs.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/proc_fs.h
8303 --- linux-3.6/include/linux/proc_fs.h 2012-07-22 23:39:44.000000000 +0200
8304 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/proc_fs.h 2012-10-04 18:47:00.000000000 +0200
8305 @@ -54,6 +54,7 @@ struct proc_dir_entry {
8311 const struct inode_operations *proc_iops;
8313 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
8314 extern const struct proc_ns_operations utsns_operations;
8315 extern const struct proc_ns_operations ipcns_operations;
8321 int (*proc_get_link)(struct dentry *, struct path *);
8322 int (*proc_read)(struct task_struct *task, char *page);
8323 int (*proc_show)(struct seq_file *m,
8324 struct pid_namespace *ns, struct pid *pid,
8325 struct task_struct *task);
8326 + int (*proc_vs_read)(char *page);
8327 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
8328 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
8331 struct ctl_table_header;
8332 @@ -265,6 +272,7 @@ struct ctl_table;
8339 struct proc_dir_entry *pde;
8340 diff -NurpP --minimal linux-3.6/include/linux/quotaops.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/quotaops.h
8341 --- linux-3.6/include/linux/quotaops.h 2012-10-04 15:27:46.000000000 +0200
8342 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/quotaops.h 2012-10-04 18:47:00.000000000 +0200
8344 #define _LINUX_QUOTAOPS_
8346 #include <linux/fs.h>
8347 +#include <linux/vs_dlimit.h>
8349 #define DQUOT_SPACE_WARN 0x1
8350 #define DQUOT_SPACE_RESERVE 0x2
8351 @@ -205,11 +206,12 @@ static inline void dquot_drop(struct ino
8353 static inline int dquot_alloc_inode(const struct inode *inode)
8356 + return dl_alloc_inode(inode);
8359 static inline void dquot_free_inode(const struct inode *inode)
8361 + dl_free_inode(inode);
8364 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
8365 @@ -220,6 +222,10 @@ static inline int dquot_transfer(struct
8366 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
8371 + if ((ret = dl_alloc_space(inode, number)))
8373 if (!(flags & DQUOT_SPACE_RESERVE))
8374 inode_add_bytes(inode, number);
8376 @@ -230,6 +236,7 @@ static inline void __dquot_free_space(st
8378 if (!(flags & DQUOT_SPACE_RESERVE))
8379 inode_sub_bytes(inode, number);
8380 + dl_free_space(inode, number);
8383 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
8384 diff -NurpP --minimal linux-3.6/include/linux/reboot.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/reboot.h
8385 --- linux-3.6/include/linux/reboot.h 2011-10-24 18:45:32.000000000 +0200
8386 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/reboot.h 2012-10-04 18:47:00.000000000 +0200
8388 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
8389 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
8390 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
8391 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
8395 diff -NurpP --minimal linux-3.6/include/linux/sched.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/sched.h
8396 --- linux-3.6/include/linux/sched.h 2012-10-04 15:27:46.000000000 +0200
8397 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/sched.h 2012-10-04 18:47:00.000000000 +0200
8398 @@ -1422,6 +1422,14 @@ struct task_struct {
8400 struct seccomp seccomp;
8402 +/* vserver context data */
8403 + struct vx_info *vx_info;
8404 + struct nx_info *nx_info;
8410 /* Thread group tracking */
8413 @@ -1668,6 +1676,11 @@ struct pid_namespace;
8414 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
8415 struct pid_namespace *ns);
8417 +#include <linux/vserver/base.h>
8418 +#include <linux/vserver/context.h>
8419 +#include <linux/vserver/debug.h>
8420 +#include <linux/vserver/pid.h>
8422 static inline pid_t task_pid_nr(struct task_struct *tsk)
8425 @@ -1681,7 +1694,8 @@ static inline pid_t task_pid_nr_ns(struc
8427 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8429 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8430 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8431 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
8435 @@ -1694,7 +1708,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8437 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8439 - return pid_vnr(task_tgid(tsk));
8440 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8444 diff -NurpP --minimal linux-3.6/include/linux/shmem_fs.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/shmem_fs.h
8445 --- linux-3.6/include/linux/shmem_fs.h 2012-07-22 23:39:44.000000000 +0200
8446 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/shmem_fs.h 2012-10-04 18:47:00.000000000 +0200
8449 /* inode in-kernel data */
8451 +#define TMPFS_SUPER_MAGIC 0x01021994
8454 struct shmem_inode_info {
8456 unsigned long flags;
8457 diff -NurpP --minimal linux-3.6/include/linux/stat.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/stat.h
8458 --- linux-3.6/include/linux/stat.h 2012-07-22 23:39:44.000000000 +0200
8459 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/stat.h 2012-10-04 18:47:00.000000000 +0200
8460 @@ -67,6 +67,7 @@ struct kstat {
8467 struct timespec atime;
8468 diff -NurpP --minimal linux-3.6/include/linux/sunrpc/auth.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/sunrpc/auth.h
8469 --- linux-3.6/include/linux/sunrpc/auth.h 2012-10-04 15:27:46.000000000 +0200
8470 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/sunrpc/auth.h 2012-10-04 18:47:00.000000000 +0200
8476 struct group_info *group_info;
8477 const char *principal;
8478 unsigned char machine_cred : 1;
8479 diff -NurpP --minimal linux-3.6/include/linux/sunrpc/clnt.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/sunrpc/clnt.h
8480 --- linux-3.6/include/linux/sunrpc/clnt.h 2012-05-21 18:07:32.000000000 +0200
8481 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/sunrpc/clnt.h 2012-10-04 18:47:00.000000000 +0200
8482 @@ -49,7 +49,8 @@ struct rpc_clnt {
8483 unsigned int cl_softrtry : 1,/* soft timeouts */
8484 cl_discrtry : 1,/* disconnect before retry */
8485 cl_autobind : 1,/* use getport() */
8486 - cl_chatty : 1;/* be verbose */
8487 + cl_chatty : 1,/* be verbose */
8488 + cl_tag : 1;/* context tagging */
8490 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8491 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8492 diff -NurpP --minimal linux-3.6/include/linux/sysctl.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/sysctl.h
8493 --- linux-3.6/include/linux/sysctl.h 2012-05-21 18:07:32.000000000 +0200
8494 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/sysctl.h 2012-10-04 18:47:00.000000000 +0200
8495 @@ -60,6 +60,7 @@ enum
8496 CTL_ABI=9, /* Binary emulation */
8497 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
8498 CTL_ARLAN=254, /* arlan wireless driver */
8499 + CTL_VSERVER=4242, /* Linux-VServer debug */
8500 CTL_S390DBF=5677, /* s390 debug */
8501 CTL_SUNRPC=7249, /* sunrpc debug */
8502 CTL_PM=9899, /* frv power management */
8503 @@ -94,6 +95,7 @@ enum
8505 KERN_PANIC=15, /* int: panic timeout */
8506 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
8507 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
8509 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
8510 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
8511 diff -NurpP --minimal linux-3.6/include/linux/sysfs.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/sysfs.h
8512 --- linux-3.6/include/linux/sysfs.h 2012-07-22 23:39:44.000000000 +0200
8513 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/sysfs.h 2012-10-04 18:47:00.000000000 +0200
8515 #include <linux/kobject_ns.h>
8516 #include <linux/atomic.h>
8518 +#define SYSFS_SUPER_MAGIC 0x62656572
8523 diff -NurpP --minimal linux-3.6/include/linux/time.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/time.h
8524 --- linux-3.6/include/linux/time.h 2012-10-04 15:27:46.000000000 +0200
8525 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/time.h 2012-10-04 18:47:00.000000000 +0200
8526 @@ -280,6 +280,8 @@ static __always_inline void timespec_add
8530 +#include <linux/vs_time.h>
8532 #endif /* __KERNEL__ */
8535 diff -NurpP --minimal linux-3.6/include/linux/types.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/types.h
8536 --- linux-3.6/include/linux/types.h 2012-10-04 15:27:47.000000000 +0200
8537 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/types.h 2012-10-04 18:47:00.000000000 +0200
8538 @@ -41,6 +41,9 @@ typedef __kernel_uid32_t uid_t;
8539 typedef __kernel_gid32_t gid_t;
8540 typedef __kernel_uid16_t uid16_t;
8541 typedef __kernel_gid16_t gid16_t;
8542 +typedef unsigned int xid_t;
8543 +typedef unsigned int nid_t;
8544 +typedef unsigned int tag_t;
8546 typedef unsigned long uintptr_t;
8548 diff -NurpP --minimal linux-3.6/include/linux/utsname.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/utsname.h
8549 --- linux-3.6/include/linux/utsname.h 2012-01-09 16:14:59.000000000 +0100
8550 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/utsname.h 2012-10-04 18:47:00.000000000 +0200
8551 @@ -62,7 +62,8 @@ static inline void get_uts_ns(struct uts
8554 extern struct uts_namespace *copy_utsname(unsigned long flags,
8555 - struct task_struct *tsk);
8556 + struct uts_namespace *old_ns,
8557 + struct user_namespace *user_ns);
8558 extern void free_uts_ns(struct kref *kref);
8560 static inline void put_uts_ns(struct uts_namespace *ns)
8561 @@ -79,12 +80,13 @@ static inline void put_uts_ns(struct uts
8564 static inline struct uts_namespace *copy_utsname(unsigned long flags,
8565 - struct task_struct *tsk)
8566 + struct uts_namespace *old_ns,
8567 + struct user_namespace *user_ns)
8569 if (flags & CLONE_NEWUTS)
8570 return ERR_PTR(-EINVAL);
8572 - return tsk->nsproxy->uts_ns;
8577 diff -NurpP --minimal linux-3.6/include/linux/vroot.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vroot.h
8578 --- linux-3.6/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
8579 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vroot.h 2012-10-04 18:47:00.000000000 +0200
8583 + * include/linux/vroot.h
8585 + * written by Herbert Pötzl, 9/11/2002
8586 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
8588 + * Copyright (C) 2002-2007 by Herbert Pötzl.
8589 + * Redistribution of this file is permitted under the
8590 + * GNU General Public License.
8593 +#ifndef _LINUX_VROOT_H
8594 +#define _LINUX_VROOT_H
8599 +/* Possible states of device */
8605 +struct vroot_device {
8609 + struct semaphore vr_ctl_mutex;
8610 + struct block_device *vr_device;
8615 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
8617 +extern int register_vroot_grb(vroot_grb_func *);
8618 +extern int unregister_vroot_grb(vroot_grb_func *);
8620 +#endif /* __KERNEL__ */
8622 +#define MAX_VROOT_DEFAULT 8
8625 + * IOCTL commands --- we will commandeer 0x56 ('V')
8628 +#define VROOT_SET_DEV 0x5600
8629 +#define VROOT_CLR_DEV 0x5601
8631 +#endif /* _LINUX_VROOT_H */
8632 diff -NurpP --minimal linux-3.6/include/linux/vs_base.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_base.h
8633 --- linux-3.6/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
8634 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_base.h 2012-10-04 18:47:00.000000000 +0200
8639 +#include "vserver/base.h"
8640 +#include "vserver/check.h"
8641 +#include "vserver/debug.h"
8644 +#warning duplicate inclusion
8646 diff -NurpP --minimal linux-3.6/include/linux/vs_context.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_context.h
8647 --- linux-3.6/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
8648 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_context.h 2012-10-04 18:47:00.000000000 +0200
8650 +#ifndef _VS_CONTEXT_H
8651 +#define _VS_CONTEXT_H
8653 +#include "vserver/base.h"
8654 +#include "vserver/check.h"
8655 +#include "vserver/context.h"
8656 +#include "vserver/history.h"
8657 +#include "vserver/debug.h"
8659 +#include <linux/sched.h>
8662 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
8664 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
8665 + const char *_file, int _line, void *_here)
8670 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
8671 + vxi, vxi ? vxi->vx_id : 0,
8672 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8674 + __vxh_get_vx_info(vxi, _here);
8676 + atomic_inc(&vxi->vx_usecnt);
8681 +extern void free_vx_info(struct vx_info *);
8683 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
8685 +static inline void __put_vx_info(struct vx_info *vxi,
8686 + const char *_file, int _line, void *_here)
8691 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
8692 + vxi, vxi ? vxi->vx_id : 0,
8693 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8695 + __vxh_put_vx_info(vxi, _here);
8697 + if (atomic_dec_and_test(&vxi->vx_usecnt))
8698 + free_vx_info(vxi);
8702 +#define init_vx_info(p, i) \
8703 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8705 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8706 + const char *_file, int _line, void *_here)
8709 + vxlprintk(VXD_CBIT(xid, 3),
8710 + "init_vx_info(%p[#%d.%d])",
8711 + vxi, vxi ? vxi->vx_id : 0,
8712 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8714 + __vxh_init_vx_info(vxi, vxp, _here);
8716 + atomic_inc(&vxi->vx_usecnt);
8722 +#define set_vx_info(p, i) \
8723 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8725 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8726 + const char *_file, int _line, void *_here)
8728 + struct vx_info *vxo;
8733 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
8734 + vxi, vxi ? vxi->vx_id : 0,
8735 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8737 + __vxh_set_vx_info(vxi, vxp, _here);
8739 + atomic_inc(&vxi->vx_usecnt);
8740 + vxo = xchg(vxp, vxi);
8745 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
8747 +static inline void __clr_vx_info(struct vx_info **vxp,
8748 + const char *_file, int _line, void *_here)
8750 + struct vx_info *vxo;
8752 + vxo = xchg(vxp, NULL);
8756 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
8757 + vxo, vxo ? vxo->vx_id : 0,
8758 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
8760 + __vxh_clr_vx_info(vxo, vxp, _here);
8762 + if (atomic_dec_and_test(&vxo->vx_usecnt))
8763 + free_vx_info(vxo);
8767 +#define claim_vx_info(v, p) \
8768 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
8770 +static inline void __claim_vx_info(struct vx_info *vxi,
8771 + struct task_struct *task,
8772 + const char *_file, int _line, void *_here)
8774 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
8775 + vxi, vxi ? vxi->vx_id : 0,
8776 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8777 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
8778 + task, _file, _line);
8779 + __vxh_claim_vx_info(vxi, task, _here);
8781 + atomic_inc(&vxi->vx_tasks);
8785 +extern void unhash_vx_info(struct vx_info *);
8787 +#define release_vx_info(v, p) \
8788 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
8790 +static inline void __release_vx_info(struct vx_info *vxi,
8791 + struct task_struct *task,
8792 + const char *_file, int _line, void *_here)
8794 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
8795 + vxi, vxi ? vxi->vx_id : 0,
8796 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8797 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
8798 + task, _file, _line);
8799 + __vxh_release_vx_info(vxi, task, _here);
8803 + if (atomic_dec_and_test(&vxi->vx_tasks))
8804 + unhash_vx_info(vxi);
8808 +#define task_get_vx_info(p) \
8809 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
8811 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
8812 + const char *_file, int _line, void *_here)
8814 + struct vx_info *vxi;
8817 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
8819 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
8825 +static inline void __wakeup_vx_info(struct vx_info *vxi)
8827 + if (waitqueue_active(&vxi->vx_wait))
8828 + wake_up_interruptible(&vxi->vx_wait);
8832 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
8834 +static inline void __enter_vx_info(struct vx_info *vxi,
8835 + struct vx_info_save *vxis, const char *_file, int _line)
8837 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
8838 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
8839 + current->xid, current->vx_info, _file, _line);
8840 + vxis->vxi = xchg(¤t->vx_info, vxi);
8841 + vxis->xid = current->xid;
8842 + current->xid = vxi ? vxi->vx_id : 0;
8845 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
8847 +static inline void __leave_vx_info(struct vx_info_save *vxis,
8848 + const char *_file, int _line)
8850 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
8851 + vxis, vxis->xid, vxis->vxi, current,
8852 + current->xid, current->vx_info, _file, _line);
8853 + (void)xchg(¤t->vx_info, vxis->vxi);
8854 + current->xid = vxis->xid;
8858 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
8860 + vxis->vxi = xchg(¤t->vx_info, NULL);
8861 + vxis->xid = xchg(¤t->xid, (xid_t)0);
8864 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
8866 + (void)xchg(¤t->xid, vxis->xid);
8867 + (void)xchg(¤t->vx_info, vxis->vxi);
8870 +#define task_is_init(p) \
8871 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
8873 +static inline int __task_is_init(struct task_struct *p,
8874 + const char *_file, int _line, void *_here)
8876 + int is_init = is_global_init(p);
8880 + is_init = p->vx_info->vx_initpid == p->pid;
8885 +extern void exit_vx_info(struct task_struct *, int);
8886 +extern void exit_vx_info_early(struct task_struct *, int);
8890 +#warning duplicate inclusion
8892 diff -NurpP --minimal linux-3.6/include/linux/vs_cowbl.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_cowbl.h
8893 --- linux-3.6/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
8894 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_cowbl.h 2012-10-04 18:47:00.000000000 +0200
8896 +#ifndef _VS_COWBL_H
8897 +#define _VS_COWBL_H
8899 +#include <linux/fs.h>
8900 +#include <linux/dcache.h>
8901 +#include <linux/namei.h>
8902 +#include <linux/slab.h>
8904 +extern struct dentry *cow_break_link(const char *pathname);
8906 +static inline int cow_check_and_break(struct path *path)
8908 + struct inode *inode = path->dentry->d_inode;
8911 + /* do we need this check? */
8912 + if (IS_RDONLY(inode))
8915 + if (IS_COW(inode)) {
8916 + if (IS_COW_LINK(inode)) {
8917 + struct dentry *new_dentry, *old_dentry = path->dentry;
8920 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
8924 + pp = d_path(path, buf, PATH_MAX);
8925 + new_dentry = cow_break_link(pp);
8927 + if (!IS_ERR(new_dentry)) {
8928 + path->dentry = new_dentry;
8931 + error = PTR_ERR(new_dentry);
8933 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
8934 + inode->i_ctime = CURRENT_TIME;
8935 + mark_inode_dirty(inode);
8942 +#warning duplicate inclusion
8944 diff -NurpP --minimal linux-3.6/include/linux/vs_cvirt.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_cvirt.h
8945 --- linux-3.6/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
8946 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_cvirt.h 2012-10-04 18:47:00.000000000 +0200
8948 +#ifndef _VS_CVIRT_H
8949 +#define _VS_CVIRT_H
8951 +#include "vserver/cvirt.h"
8952 +#include "vserver/context.h"
8953 +#include "vserver/base.h"
8954 +#include "vserver/check.h"
8955 +#include "vserver/debug.h"
8958 +static inline void vx_activate_task(struct task_struct *p)
8960 + struct vx_info *vxi;
8962 + if ((vxi = p->vx_info)) {
8963 + vx_update_load(vxi);
8964 + atomic_inc(&vxi->cvirt.nr_running);
8968 +static inline void vx_deactivate_task(struct task_struct *p)
8970 + struct vx_info *vxi;
8972 + if ((vxi = p->vx_info)) {
8973 + vx_update_load(vxi);
8974 + atomic_dec(&vxi->cvirt.nr_running);
8978 +static inline void vx_uninterruptible_inc(struct task_struct *p)
8980 + struct vx_info *vxi;
8982 + if ((vxi = p->vx_info))
8983 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
8986 +static inline void vx_uninterruptible_dec(struct task_struct *p)
8988 + struct vx_info *vxi;
8990 + if ((vxi = p->vx_info))
8991 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
8996 +#warning duplicate inclusion
8998 diff -NurpP --minimal linux-3.6/include/linux/vs_device.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_device.h
8999 --- linux-3.6/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9000 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_device.h 2012-10-04 18:47:00.000000000 +0200
9002 +#ifndef _VS_DEVICE_H
9003 +#define _VS_DEVICE_H
9005 +#include "vserver/base.h"
9006 +#include "vserver/device.h"
9007 +#include "vserver/debug.h"
9010 +#ifdef CONFIG_VSERVER_DEVICE
9012 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9014 +#define vs_device_perm(v, d, m, p) \
9015 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9020 +int vs_map_device(struct vx_info *vxi,
9021 + dev_t device, dev_t *target, umode_t mode)
9028 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9033 +#define vs_map_chrdev(d, t, p) \
9034 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9035 +#define vs_map_blkdev(d, t, p) \
9036 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9038 +#define vs_chrdev_perm(d, p) \
9039 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9040 +#define vs_blkdev_perm(d, p) \
9041 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9045 +#warning duplicate inclusion
9047 diff -NurpP --minimal linux-3.6/include/linux/vs_dlimit.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_dlimit.h
9048 --- linux-3.6/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9049 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_dlimit.h 2012-10-04 18:47:00.000000000 +0200
9051 +#ifndef _VS_DLIMIT_H
9052 +#define _VS_DLIMIT_H
9054 +#include <linux/fs.h>
9056 +#include "vserver/dlimit.h"
9057 +#include "vserver/base.h"
9058 +#include "vserver/debug.h"
9061 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9063 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9064 + const char *_file, int _line)
9068 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9069 + dli, dli ? dli->dl_tag : 0,
9070 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9072 + atomic_inc(&dli->dl_usecnt);
9077 +#define free_dl_info(i) \
9078 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9080 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9082 +static inline void __put_dl_info(struct dl_info *dli,
9083 + const char *_file, int _line)
9087 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9088 + dli, dli ? dli->dl_tag : 0,
9089 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9091 + if (atomic_dec_and_test(&dli->dl_usecnt))
9092 + free_dl_info(dli);
9096 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9098 +static inline int __dl_alloc_space(struct super_block *sb,
9099 + tag_t tag, dlsize_t nr, const char *file, int line)
9101 + struct dl_info *dli = NULL;
9106 + dli = locate_dl_info(sb, tag);
9110 + spin_lock(&dli->dl_lock);
9111 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9113 + dli->dl_space_used += nr;
9114 + spin_unlock(&dli->dl_lock);
9117 + vxlprintk(VXD_CBIT(dlim, 1),
9118 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9119 + sb, tag, __dlimit_char(dli), (long long)nr,
9121 + return ret ? -ENOSPC : 0;
9124 +static inline void __dl_free_space(struct super_block *sb,
9125 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9127 + struct dl_info *dli = NULL;
9131 + dli = locate_dl_info(sb, tag);
9135 + spin_lock(&dli->dl_lock);
9136 + if (dli->dl_space_used > nr)
9137 + dli->dl_space_used -= nr;
9139 + dli->dl_space_used = 0;
9140 + spin_unlock(&dli->dl_lock);
9143 + vxlprintk(VXD_CBIT(dlim, 1),
9144 + "FREE (%p,#%d)%c %lld bytes",
9145 + sb, tag, __dlimit_char(dli), (long long)nr,
9149 +static inline int __dl_alloc_inode(struct super_block *sb,
9150 + tag_t tag, const char *_file, int _line)
9152 + struct dl_info *dli;
9155 + dli = locate_dl_info(sb, tag);
9159 + spin_lock(&dli->dl_lock);
9160 + dli->dl_inodes_used++;
9161 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9162 + spin_unlock(&dli->dl_lock);
9165 + vxlprintk(VXD_CBIT(dlim, 0),
9166 + "ALLOC (%p,#%d)%c inode (%d)",
9167 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9168 + return ret ? -ENOSPC : 0;
9171 +static inline void __dl_free_inode(struct super_block *sb,
9172 + tag_t tag, const char *_file, int _line)
9174 + struct dl_info *dli;
9176 + dli = locate_dl_info(sb, tag);
9180 + spin_lock(&dli->dl_lock);
9181 + if (dli->dl_inodes_used > 1)
9182 + dli->dl_inodes_used--;
9184 + dli->dl_inodes_used = 0;
9185 + spin_unlock(&dli->dl_lock);
9188 + vxlprintk(VXD_CBIT(dlim, 0),
9189 + "FREE (%p,#%d)%c inode",
9190 + sb, tag, __dlimit_char(dli), _file, _line);
9193 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
9194 + unsigned long long *free_blocks, unsigned long long *root_blocks,
9195 + const char *_file, int _line)
9197 + struct dl_info *dli;
9198 + uint64_t broot, bfree;
9200 + dli = locate_dl_info(sb, tag);
9204 + spin_lock(&dli->dl_lock);
9205 + broot = (dli->dl_space_total -
9206 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
9207 + >> sb->s_blocksize_bits;
9208 + bfree = (dli->dl_space_total - dli->dl_space_used)
9209 + >> sb->s_blocksize_bits;
9210 + spin_unlock(&dli->dl_lock);
9212 + vxlprintk(VXD_CBIT(dlim, 2),
9213 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
9214 + (long long)bfree, (long long)broot,
9215 + *free_blocks, *root_blocks, dli->dl_nrlmult,
9217 + if (free_blocks) {
9218 + if (*free_blocks > bfree)
9219 + *free_blocks = bfree;
9221 + if (root_blocks) {
9222 + if (*root_blocks > broot)
9223 + *root_blocks = broot;
9228 +#define dl_prealloc_space(in, bytes) \
9229 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9230 + __FILE__, __LINE__ )
9232 +#define dl_alloc_space(in, bytes) \
9233 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9234 + __FILE__, __LINE__ )
9236 +#define dl_reserve_space(in, bytes) \
9237 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9238 + __FILE__, __LINE__ )
9240 +#define dl_claim_space(in, bytes) (0)
9242 +#define dl_release_space(in, bytes) \
9243 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9244 + __FILE__, __LINE__ )
9246 +#define dl_free_space(in, bytes) \
9247 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9248 + __FILE__, __LINE__ )
9252 +#define dl_alloc_inode(in) \
9253 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9255 +#define dl_free_inode(in) \
9256 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9259 +#define dl_adjust_block(sb, tag, fb, rb) \
9260 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
9264 +#warning duplicate inclusion
9266 diff -NurpP --minimal linux-3.6/include/linux/vs_inet.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_inet.h
9267 --- linux-3.6/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
9268 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_inet.h 2012-10-04 18:47:00.000000000 +0200
9273 +#include "vserver/base.h"
9274 +#include "vserver/network.h"
9275 +#include "vserver/debug.h"
9277 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
9279 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
9280 + NIPQUAD((a)->mask), (a)->type
9281 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
9283 +#define NIPQUAD(addr) \
9284 + ((unsigned char *)&addr)[0], \
9285 + ((unsigned char *)&addr)[1], \
9286 + ((unsigned char *)&addr)[2], \
9287 + ((unsigned char *)&addr)[3]
9289 +#define NIPQUAD_FMT "%u.%u.%u.%u"
9293 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
9295 + __be32 ip = nxa->ip[0].s_addr;
9296 + __be32 mask = nxa->mask.s_addr;
9297 + __be32 bcast = ip | ~mask;
9300 + switch (nxa->type & tmask) {
9301 + case NXA_TYPE_MASK:
9302 + ret = (ip == (addr & mask));
9304 + case NXA_TYPE_ADDR:
9308 + /* fall through to broadcast */
9309 + case NXA_MOD_BCAST:
9310 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
9312 + case NXA_TYPE_RANGE:
9313 + ret = ((nxa->ip[0].s_addr <= addr) &&
9314 + (nxa->ip[1].s_addr > addr));
9316 + case NXA_TYPE_ANY:
9321 + vxdprintk(VXD_CBIT(net, 0),
9322 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
9323 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
9328 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
9330 + struct nx_addr_v4 *nxa;
9337 + /* allow 127.0.0.1 when remapping lback */
9338 + if ((tmask & NXA_LOOPBACK) &&
9339 + (addr == IPI_LOOPBACK) &&
9340 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9343 + /* check for lback address */
9344 + if ((tmask & NXA_MOD_LBACK) &&
9345 + (nxi->v4_lback.s_addr == addr))
9348 + /* check for broadcast address */
9349 + if ((tmask & NXA_MOD_BCAST) &&
9350 + (nxi->v4_bcast.s_addr == addr))
9353 + /* check for v4 addresses */
9354 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
9355 + if (v4_addr_match(nxa, addr, tmask))
9359 + vxdprintk(VXD_CBIT(net, 0),
9360 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
9361 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
9366 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
9368 + /* FIXME: needs full range checks */
9369 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
9373 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
9375 + struct nx_addr_v4 *ptr;
9377 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
9378 + if (v4_nx_addr_match(ptr, nxa, mask))
9383 +#include <net/inet_sock.h>
9386 + * Check if a given address matches for a socket
9388 + * nxi: the socket's nx_info if any
9389 + * addr: to be verified address
9392 +int v4_sock_addr_match (
9393 + struct nx_info *nxi,
9394 + struct inet_sock *inet,
9397 + __be32 saddr = inet->inet_rcv_saddr;
9398 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
9400 + if (addr && (saddr == addr || bcast == addr))
9403 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
9408 +/* inet related checks and helpers */
9417 +#include <linux/netdevice.h>
9418 +#include <linux/inetdevice.h>
9419 +#include <net/inet_sock.h>
9420 +#include <net/inet_timewait_sock.h>
9423 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9424 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
9425 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
9429 + * check if address is covered by socket
9431 + * sk: the socket to check against
9432 + * addr: the address in question (must be != 0)
9436 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
9438 + struct nx_info *nxi = sk->sk_nx_info;
9439 + __be32 saddr = sk_rcv_saddr(sk);
9441 + vxdprintk(VXD_CBIT(net, 5),
9442 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
9443 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
9444 + (sk->sk_socket?sk->sk_socket->flags:0));
9446 + if (saddr) { /* direct address match */
9447 + return v4_addr_match(nxa, saddr, -1);
9448 + } else if (nxi) { /* match against nx_info */
9449 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
9450 + } else { /* unrestricted any socket */
9458 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
9460 + vxdprintk(VXD_CBIT(net, 1),
9461 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
9462 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
9463 + nxi ? dev_in_nx_info(dev, nxi) : 0);
9465 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9467 + if (dev_in_nx_info(dev, nxi))
9474 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
9480 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
9484 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
9486 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
9487 + nxi, nxi ? nxi->nx_id : 0, ifa,
9488 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
9490 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9492 + if (v4_ifa_in_nx_info(ifa, nxi))
9498 +struct nx_v4_sock_addr {
9499 + __be32 saddr; /* Address used for validation */
9500 + __be32 baddr; /* Address used for socket bind */
9504 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
9505 + struct nx_v4_sock_addr *nsa)
9507 + struct sock *sk = &inet->sk;
9508 + struct nx_info *nxi = sk->sk_nx_info;
9509 + __be32 saddr = addr->sin_addr.s_addr;
9510 + __be32 baddr = saddr;
9512 + vxdprintk(VXD_CBIT(net, 3),
9513 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
9514 + sk, sk->sk_nx_info, sk->sk_socket,
9515 + (sk->sk_socket ? sk->sk_socket->flags : 0),
9519 + if (saddr == INADDR_ANY) {
9520 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
9521 + baddr = nxi->v4.ip[0].s_addr;
9522 + } else if (saddr == IPI_LOOPBACK) {
9523 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9524 + baddr = nxi->v4_lback.s_addr;
9525 + } else if (!ipv4_is_multicast(saddr) ||
9526 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
9527 + /* normal address bind */
9528 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
9529 + return -EADDRNOTAVAIL;
9533 + vxdprintk(VXD_CBIT(net, 3),
9534 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
9535 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
9537 + nsa->saddr = saddr;
9538 + nsa->baddr = baddr;
9543 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
9545 + inet->inet_saddr = nsa->baddr;
9546 + inet->inet_rcv_saddr = nsa->baddr;
9551 + * helper to simplify inet_lookup_listener
9553 + * nxi: the socket's nx_info if any
9554 + * addr: to be verified address
9555 + * saddr: socket address
9557 +static inline int v4_inet_addr_match (
9558 + struct nx_info *nxi,
9562 + if (addr && (saddr == addr))
9565 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
9569 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
9571 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
9572 + (addr == nxi->v4_lback.s_addr))
9573 + return IPI_LOOPBACK;
9578 +int nx_info_has_v4(struct nx_info *nxi)
9584 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9589 +#else /* CONFIG_INET */
9592 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
9598 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9604 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9610 +int nx_info_has_v4(struct nx_info *nxi)
9615 +#endif /* CONFIG_INET */
9617 +#define current_nx_info_has_v4() \
9618 + nx_info_has_v4(current_nx_info())
9621 +// #warning duplicate inclusion
9623 diff -NurpP --minimal linux-3.6/include/linux/vs_inet6.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_inet6.h
9624 --- linux-3.6/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
9625 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_inet6.h 2012-10-04 18:47:00.000000000 +0200
9627 +#ifndef _VS_INET6_H
9628 +#define _VS_INET6_H
9630 +#include "vserver/base.h"
9631 +#include "vserver/network.h"
9632 +#include "vserver/debug.h"
9634 +#include <net/ipv6.h>
9636 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
9637 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
9643 +int v6_addr_match(struct nx_addr_v6 *nxa,
9644 + const struct in6_addr *addr, uint16_t mask)
9648 + switch (nxa->type & mask) {
9649 + case NXA_TYPE_MASK:
9650 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
9652 + case NXA_TYPE_ADDR:
9653 + ret = ipv6_addr_equal(&nxa->ip, addr);
9655 + case NXA_TYPE_ANY:
9659 + vxdprintk(VXD_CBIT(net, 0),
9660 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
9661 + nxa, NXAV6(nxa), addr, mask, ret);
9666 +int v6_addr_in_nx_info(struct nx_info *nxi,
9667 + const struct in6_addr *addr, uint16_t mask)
9669 + struct nx_addr_v6 *nxa;
9674 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
9675 + if (v6_addr_match(nxa, addr, mask))
9679 + vxdprintk(VXD_CBIT(net, 0),
9680 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
9681 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
9686 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
9688 + /* FIXME: needs full range checks */
9689 + return v6_addr_match(nxa, &addr->ip, mask);
9693 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
9695 + struct nx_addr_v6 *ptr;
9697 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
9698 + if (v6_nx_addr_match(ptr, nxa, mask))
9705 + * Check if a given address matches for a socket
9707 + * nxi: the socket's nx_info if any
9708 + * addr: to be verified address
9711 +int v6_sock_addr_match (
9712 + struct nx_info *nxi,
9713 + struct inet_sock *inet,
9714 + struct in6_addr *addr)
9716 + struct sock *sk = &inet->sk;
9717 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
9719 + if (!ipv6_addr_any(addr) &&
9720 + ipv6_addr_equal(saddr, addr))
9722 + if (ipv6_addr_any(saddr))
9723 + return v6_addr_in_nx_info(nxi, addr, -1);
9728 + * check if address is covered by socket
9730 + * sk: the socket to check against
9731 + * addr: the address in question (must be != 0)
9735 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
9737 + struct nx_info *nxi = sk->sk_nx_info;
9738 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
9740 + vxdprintk(VXD_CBIT(net, 5),
9741 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
9742 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
9743 + (sk->sk_socket?sk->sk_socket->flags:0));
9745 + if (!ipv6_addr_any(saddr)) { /* direct address match */
9746 + return v6_addr_match(nxa, saddr, -1);
9747 + } else if (nxi) { /* match against nx_info */
9748 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
9749 + } else { /* unrestricted any socket */
9755 +/* inet related checks and helpers */
9763 +#include <linux/netdevice.h>
9764 +#include <linux/inetdevice.h>
9765 +#include <net/inet_timewait_sock.h>
9768 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9769 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
9770 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
9775 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
9781 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
9785 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
9787 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
9788 + nxi, nxi ? nxi->nx_id : 0, ifa,
9789 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
9791 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9793 + if (v6_ifa_in_nx_info(ifa, nxi))
9799 +struct nx_v6_sock_addr {
9800 + struct in6_addr saddr; /* Address used for validation */
9801 + struct in6_addr baddr; /* Address used for socket bind */
9805 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
9806 + struct nx_v6_sock_addr *nsa)
9808 + // struct sock *sk = &inet->sk;
9809 + // struct nx_info *nxi = sk->sk_nx_info;
9810 + struct in6_addr saddr = addr->sin6_addr;
9811 + struct in6_addr baddr = saddr;
9813 + nsa->saddr = saddr;
9814 + nsa->baddr = baddr;
9819 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
9821 + // struct sock *sk = &inet->sk;
9822 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
9824 + // *saddr = nsa->baddr;
9825 + // inet->inet_saddr = nsa->baddr;
9829 +int nx_info_has_v6(struct nx_info *nxi)
9838 +#else /* CONFIG_IPV6 */
9841 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
9848 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9854 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9860 +int nx_info_has_v6(struct nx_info *nxi)
9865 +#endif /* CONFIG_IPV6 */
9867 +#define current_nx_info_has_v6() \
9868 + nx_info_has_v6(current_nx_info())
9871 +#warning duplicate inclusion
9873 diff -NurpP --minimal linux-3.6/include/linux/vs_limit.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_limit.h
9874 --- linux-3.6/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
9875 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_limit.h 2012-10-04 18:47:00.000000000 +0200
9877 +#ifndef _VS_LIMIT_H
9878 +#define _VS_LIMIT_H
9880 +#include "vserver/limit.h"
9881 +#include "vserver/base.h"
9882 +#include "vserver/context.h"
9883 +#include "vserver/debug.h"
9884 +#include "vserver/context.h"
9885 +#include "vserver/limit_int.h"
9888 +#define vx_acc_cres(v, d, p, r) \
9889 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
9891 +#define vx_acc_cres_cond(x, d, p, r) \
9892 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
9893 + r, d, p, __FILE__, __LINE__)
9896 +#define vx_add_cres(v, a, p, r) \
9897 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
9898 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
9900 +#define vx_add_cres_cond(x, a, p, r) \
9901 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
9902 + r, a, p, __FILE__, __LINE__)
9903 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
9906 +/* process and file limits */
9908 +#define vx_nproc_inc(p) \
9909 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
9911 +#define vx_nproc_dec(p) \
9912 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
9914 +#define vx_files_inc(f) \
9915 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
9917 +#define vx_files_dec(f) \
9918 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
9920 +#define vx_locks_inc(l) \
9921 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
9923 +#define vx_locks_dec(l) \
9924 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
9926 +#define vx_openfd_inc(f) \
9927 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
9929 +#define vx_openfd_dec(f) \
9930 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
9933 +#define vx_cres_avail(v, n, r) \
9934 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
9937 +#define vx_nproc_avail(n) \
9938 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
9940 +#define vx_files_avail(n) \
9941 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
9943 +#define vx_locks_avail(n) \
9944 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
9946 +#define vx_openfd_avail(n) \
9947 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
9950 +/* dentry limits */
9952 +#define vx_dentry_inc(d) do { \
9953 + if ((d)->d_count == 1) \
9954 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
9957 +#define vx_dentry_dec(d) do { \
9958 + if ((d)->d_count == 0) \
9959 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
9962 +#define vx_dentry_avail(n) \
9963 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
9966 +/* socket limits */
9968 +#define vx_sock_inc(s) \
9969 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
9971 +#define vx_sock_dec(s) \
9972 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
9974 +#define vx_sock_avail(n) \
9975 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
9978 +/* ipc resource limits */
9980 +#define vx_ipcmsg_add(v, u, a) \
9981 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
9983 +#define vx_ipcmsg_sub(v, u, a) \
9984 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
9986 +#define vx_ipcmsg_avail(v, a) \
9987 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
9990 +#define vx_ipcshm_add(v, k, a) \
9991 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
9993 +#define vx_ipcshm_sub(v, k, a) \
9994 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
9996 +#define vx_ipcshm_avail(v, a) \
9997 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10000 +#define vx_semary_inc(a) \
10001 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10003 +#define vx_semary_dec(a) \
10004 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10007 +#define vx_nsems_add(a,n) \
10008 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10010 +#define vx_nsems_sub(a,n) \
10011 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10015 +#warning duplicate inclusion
10017 diff -NurpP --minimal linux-3.6/include/linux/vs_network.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_network.h
10018 --- linux-3.6/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
10019 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_network.h 2012-10-04 18:47:00.000000000 +0200
10021 +#ifndef _NX_VS_NETWORK_H
10022 +#define _NX_VS_NETWORK_H
10024 +#include "vserver/context.h"
10025 +#include "vserver/network.h"
10026 +#include "vserver/base.h"
10027 +#include "vserver/check.h"
10028 +#include "vserver/debug.h"
10030 +#include <linux/sched.h>
10033 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
10035 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
10036 + const char *_file, int _line)
10041 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
10042 + nxi, nxi ? nxi->nx_id : 0,
10043 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10046 + atomic_inc(&nxi->nx_usecnt);
10051 +extern void free_nx_info(struct nx_info *);
10053 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
10055 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
10060 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
10061 + nxi, nxi ? nxi->nx_id : 0,
10062 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10065 + if (atomic_dec_and_test(&nxi->nx_usecnt))
10066 + free_nx_info(nxi);
10070 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
10072 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10073 + const char *_file, int _line)
10076 + vxlprintk(VXD_CBIT(nid, 3),
10077 + "init_nx_info(%p[#%d.%d])",
10078 + nxi, nxi ? nxi->nx_id : 0,
10079 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10082 + atomic_inc(&nxi->nx_usecnt);
10088 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
10090 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10091 + const char *_file, int _line)
10093 + struct nx_info *nxo;
10098 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
10099 + nxi, nxi ? nxi->nx_id : 0,
10100 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10103 + atomic_inc(&nxi->nx_usecnt);
10104 + nxo = xchg(nxp, nxi);
10108 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
10110 +static inline void __clr_nx_info(struct nx_info **nxp,
10111 + const char *_file, int _line)
10113 + struct nx_info *nxo;
10115 + nxo = xchg(nxp, NULL);
10119 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
10120 + nxo, nxo ? nxo->nx_id : 0,
10121 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
10124 + if (atomic_dec_and_test(&nxo->nx_usecnt))
10125 + free_nx_info(nxo);
10129 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
10131 +static inline void __claim_nx_info(struct nx_info *nxi,
10132 + struct task_struct *task, const char *_file, int _line)
10134 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
10135 + nxi, nxi ? nxi->nx_id : 0,
10136 + nxi?atomic_read(&nxi->nx_usecnt):0,
10137 + nxi?atomic_read(&nxi->nx_tasks):0,
10138 + task, _file, _line);
10140 + atomic_inc(&nxi->nx_tasks);
10144 +extern void unhash_nx_info(struct nx_info *);
10146 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
10148 +static inline void __release_nx_info(struct nx_info *nxi,
10149 + struct task_struct *task, const char *_file, int _line)
10151 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
10152 + nxi, nxi ? nxi->nx_id : 0,
10153 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10154 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
10155 + task, _file, _line);
10159 + if (atomic_dec_and_test(&nxi->nx_tasks))
10160 + unhash_nx_info(nxi);
10164 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
10166 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
10167 + const char *_file, int _line)
10169 + struct nx_info *nxi;
10172 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
10173 + p, _file, _line);
10174 + nxi = __get_nx_info(p->nx_info, _file, _line);
10180 +static inline void exit_nx_info(struct task_struct *p)
10183 + release_nx_info(p->nx_info, p);
10188 +#warning duplicate inclusion
10190 diff -NurpP --minimal linux-3.6/include/linux/vs_pid.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_pid.h
10191 --- linux-3.6/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
10192 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_pid.h 2012-10-04 18:47:00.000000000 +0200
10197 +#include "vserver/base.h"
10198 +#include "vserver/check.h"
10199 +#include "vserver/context.h"
10200 +#include "vserver/debug.h"
10201 +#include "vserver/pid.h"
10202 +#include <linux/pid_namespace.h>
10205 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
10208 +int vx_proc_task_visible(struct task_struct *task)
10210 + if ((task->pid == 1) &&
10211 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
10212 + /* show a blend through init */
10214 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
10221 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
10225 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
10227 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
10229 + if (task && !vx_proc_task_visible(task)) {
10230 + vxdprintk(VXD_CBIT(misc, 6),
10231 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
10232 + task, task->xid, task->pid,
10233 + current, current->xid, current->pid);
10234 + put_task_struct(task);
10242 +#warning duplicate inclusion
10244 diff -NurpP --minimal linux-3.6/include/linux/vs_sched.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_sched.h
10245 --- linux-3.6/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
10246 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_sched.h 2012-10-04 18:47:00.000000000 +0200
10248 +#ifndef _VS_SCHED_H
10249 +#define _VS_SCHED_H
10251 +#include "vserver/base.h"
10252 +#include "vserver/context.h"
10253 +#include "vserver/sched.h"
10256 +#define MAX_PRIO_BIAS 20
10257 +#define MIN_PRIO_BIAS -20
10260 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
10262 + struct vx_info *vxi = p->vx_info;
10265 + prio += vx_cpu(vxi, sched_pc).prio_bias;
10269 +static inline void vx_account_user(struct vx_info *vxi,
10270 + cputime_t cputime, int nice)
10274 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
10277 +static inline void vx_account_system(struct vx_info *vxi,
10278 + cputime_t cputime, int idle)
10282 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
10286 +#warning duplicate inclusion
10288 diff -NurpP --minimal linux-3.6/include/linux/vs_socket.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_socket.h
10289 --- linux-3.6/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
10290 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_socket.h 2012-10-04 18:47:00.000000000 +0200
10292 +#ifndef _VS_SOCKET_H
10293 +#define _VS_SOCKET_H
10295 +#include "vserver/debug.h"
10296 +#include "vserver/base.h"
10297 +#include "vserver/cacct.h"
10298 +#include "vserver/context.h"
10299 +#include "vserver/tag.h"
10302 +/* socket accounting */
10304 +#include <linux/socket.h>
10306 +static inline int vx_sock_type(int family)
10308 + switch (family) {
10310 + return VXA_SOCK_UNSPEC;
10312 + return VXA_SOCK_UNIX;
10314 + return VXA_SOCK_INET;
10316 + return VXA_SOCK_INET6;
10318 + return VXA_SOCK_PACKET;
10320 + return VXA_SOCK_OTHER;
10324 +#define vx_acc_sock(v, f, p, s) \
10325 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
10327 +static inline void __vx_acc_sock(struct vx_info *vxi,
10328 + int family, int pos, int size, char *file, int line)
10331 + int type = vx_sock_type(family);
10333 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
10334 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
10338 +#define vx_sock_recv(sk, s) \
10339 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
10340 +#define vx_sock_send(sk, s) \
10341 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
10342 +#define vx_sock_fail(sk, s) \
10343 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
10346 +#define sock_vx_init(s) do { \
10347 + (s)->sk_xid = 0; \
10348 + (s)->sk_vx_info = NULL; \
10351 +#define sock_nx_init(s) do { \
10352 + (s)->sk_nid = 0; \
10353 + (s)->sk_nx_info = NULL; \
10357 +#warning duplicate inclusion
10359 diff -NurpP --minimal linux-3.6/include/linux/vs_tag.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_tag.h
10360 --- linux-3.6/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
10361 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_tag.h 2012-10-04 18:47:00.000000000 +0200
10366 +#include <linux/vserver/tag.h>
10368 +/* check conditions */
10370 +#define DX_ADMIN 0x0001
10371 +#define DX_WATCH 0x0002
10372 +#define DX_HOSTID 0x0008
10374 +#define DX_IDENT 0x0010
10376 +#define DX_ARG_MASK 0x0010
10379 +#define dx_task_tag(t) ((t)->tag)
10381 +#define dx_current_tag() dx_task_tag(current)
10383 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
10385 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
10389 + * check current context for ADMIN/WATCH and
10390 + * optionally against supplied argument
10392 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
10394 + if (mode & DX_ARG_MASK) {
10395 + if ((mode & DX_IDENT) && (id == cid))
10398 + return (((mode & DX_ADMIN) && (cid == 0)) ||
10399 + ((mode & DX_WATCH) && (cid == 1)) ||
10400 + ((mode & DX_HOSTID) && (id == 0)));
10404 +int dx_permission(const struct inode *inode, int mask);
10408 +#warning duplicate inclusion
10410 diff -NurpP --minimal linux-3.6/include/linux/vs_time.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_time.h
10411 --- linux-3.6/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
10412 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vs_time.h 2012-10-04 18:47:00.000000000 +0200
10414 +#ifndef _VS_TIME_H
10415 +#define _VS_TIME_H
10418 +/* time faking stuff */
10420 +#ifdef CONFIG_VSERVER_VTIME
10422 +extern void vx_adjust_timespec(struct timespec *ts);
10423 +extern int vx_settimeofday(const struct timespec *ts);
10426 +#define vx_adjust_timespec(t) do { } while (0)
10427 +#define vx_settimeofday(t) do_settimeofday(t)
10431 +#warning duplicate inclusion
10433 diff -NurpP --minimal linux-3.6/include/linux/vserver/Kbuild linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/Kbuild
10434 --- linux-3.6/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
10435 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/Kbuild 2012-10-04 18:47:00.000000000 +0200
10438 +header-y += context_cmd.h network_cmd.h space_cmd.h \
10439 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
10440 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
10441 + debug_cmd.h device_cmd.h
10443 +header-y += switch.h network.h monitor.h inode.h device.h
10445 diff -NurpP --minimal linux-3.6/include/linux/vserver/base.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/base.h
10446 --- linux-3.6/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10447 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/base.h 2012-10-04 18:47:00.000000000 +0200
10449 +#ifndef _VX_BASE_H
10450 +#define _VX_BASE_H
10453 +/* context state changes */
10465 +#define vx_task_xid(t) ((t)->xid)
10467 +#define vx_current_xid() vx_task_xid(current)
10469 +#define current_vx_info() (current->vx_info)
10472 +#define nx_task_nid(t) ((t)->nid)
10474 +#define nx_current_nid() nx_task_nid(current)
10476 +#define current_nx_info() (current->nx_info)
10479 +/* generic flag merging */
10481 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10483 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10485 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10487 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10490 +/* context flags */
10492 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10494 +#define vx_current_flags() __vx_flags(current_vx_info())
10496 +#define vx_info_flags(v, m, f) \
10497 + vs_check_flags(__vx_flags(v), m, f)
10499 +#define task_vx_flags(t, m, f) \
10500 + ((t) && vx_info_flags((t)->vx_info, m, f))
10502 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10505 +/* context caps */
10507 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10509 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10511 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10513 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10517 +/* network flags */
10519 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10521 +#define nx_current_flags() __nx_flags(current_nx_info())
10523 +#define nx_info_flags(n, m, f) \
10524 + vs_check_flags(__nx_flags(n), m, f)
10526 +#define task_nx_flags(t, m, f) \
10527 + ((t) && nx_info_flags((t)->nx_info, m, f))
10529 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10532 +/* network caps */
10534 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10536 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10538 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10540 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10543 +/* context mask capabilities */
10545 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10547 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10549 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10552 +/* context bcap mask */
10554 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10556 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10559 +/* mask given bcaps */
10561 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10563 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10566 +/* masked cap_bset */
10568 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10570 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10573 +#define vx_info_mbcap(v, b) \
10574 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10575 + vx_info_bcaps(v, b) : (b))
10577 +#define task_vx_mbcap(t, b) \
10578 + vx_info_mbcap((t)->vx_info, (t)->b)
10580 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10583 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10585 +#define vx_capable(b, c) (capable(b) || \
10586 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10588 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
10589 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10591 +#define nx_capable(b, c) (capable(b) || \
10592 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10594 +#define vx_task_initpid(t, n) \
10595 + ((t)->vx_info && \
10596 + ((t)->vx_info->vx_initpid == (n)))
10598 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10601 +/* context unshare mask */
10603 +#define __vx_umask(v) ((v)->vx_umask)
10605 +#define vx_current_umask() __vx_umask(current_vx_info())
10607 +#define vx_can_unshare(b, f) (capable(b) || \
10608 + (cap_raised(current_cap(), b) && \
10609 + !((f) & ~vx_current_umask())))
10612 +#define __vx_wmask(v) ((v)->vx_wmask)
10614 +#define vx_current_wmask() __vx_wmask(current_vx_info())
10617 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10619 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10622 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10624 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10627 diff -NurpP --minimal linux-3.6/include/linux/vserver/cacct.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cacct.h
10628 --- linux-3.6/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10629 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cacct.h 2012-10-04 18:47:00.000000000 +0200
10631 +#ifndef _VX_CACCT_H
10632 +#define _VX_CACCT_H
10635 +enum sock_acc_field {
10636 + VXA_SOCK_UNSPEC = 0,
10642 + VXA_SOCK_SIZE /* array size */
10645 +#endif /* _VX_CACCT_H */
10646 diff -NurpP --minimal linux-3.6/include/linux/vserver/cacct_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cacct_cmd.h
10647 --- linux-3.6/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10648 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cacct_cmd.h 2012-10-04 18:47:00.000000000 +0200
10650 +#ifndef _VX_CACCT_CMD_H
10651 +#define _VX_CACCT_CMD_H
10654 +/* virtual host info name commands */
10656 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10658 +struct vcmd_sock_stat_v0 {
10660 + uint32_t count[3];
10661 + uint64_t total[3];
10667 +#include <linux/compiler.h>
10669 +extern int vc_sock_stat(struct vx_info *, void __user *);
10671 +#endif /* __KERNEL__ */
10672 +#endif /* _VX_CACCT_CMD_H */
10673 diff -NurpP --minimal linux-3.6/include/linux/vserver/cacct_def.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cacct_def.h
10674 --- linux-3.6/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10675 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cacct_def.h 2012-10-04 18:47:00.000000000 +0200
10677 +#ifndef _VX_CACCT_DEF_H
10678 +#define _VX_CACCT_DEF_H
10680 +#include <asm/atomic.h>
10681 +#include <linux/vserver/cacct.h>
10684 +struct _vx_sock_acc {
10685 + atomic_long_t count;
10686 + atomic_long_t total;
10689 +/* context sub struct */
10691 +struct _vx_cacct {
10692 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10693 + atomic_t slab[8];
10694 + atomic_t page[6][8];
10697 +#ifdef CONFIG_VSERVER_DEBUG
10699 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10703 + printk("\t_vx_cacct:");
10704 + for (i = 0; i < 6; i++) {
10705 + struct _vx_sock_acc *ptr = cacct->sock[i];
10707 + printk("\t [%d] =", i);
10708 + for (j = 0; j < 3; j++) {
10709 + printk(" [%d] = %8lu, %8lu", j,
10710 + atomic_long_read(&ptr[j].count),
10711 + atomic_long_read(&ptr[j].total));
10719 +#endif /* _VX_CACCT_DEF_H */
10720 diff -NurpP --minimal linux-3.6/include/linux/vserver/cacct_int.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cacct_int.h
10721 --- linux-3.6/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10722 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cacct_int.h 2012-10-04 18:47:00.000000000 +0200
10724 +#ifndef _VX_CACCT_INT_H
10725 +#define _VX_CACCT_INT_H
10731 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10733 + return atomic_long_read(&cacct->sock[type][pos].count);
10738 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10740 + return atomic_long_read(&cacct->sock[type][pos].total);
10743 +#endif /* __KERNEL__ */
10744 +#endif /* _VX_CACCT_INT_H */
10745 diff -NurpP --minimal linux-3.6/include/linux/vserver/check.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/check.h
10746 --- linux-3.6/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10747 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/check.h 2012-10-04 18:47:00.000000000 +0200
10749 +#ifndef _VS_CHECK_H
10750 +#define _VS_CHECK_H
10753 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10755 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10756 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10758 +#define MIN_D_CONTEXT 65536
10761 +/* check conditions */
10763 +#define VS_ADMIN 0x0001
10764 +#define VS_WATCH 0x0002
10765 +#define VS_HIDE 0x0004
10766 +#define VS_HOSTID 0x0008
10768 +#define VS_IDENT 0x0010
10769 +#define VS_EQUIV 0x0020
10770 +#define VS_PARENT 0x0040
10771 +#define VS_CHILD 0x0080
10773 +#define VS_ARG_MASK 0x00F0
10775 +#define VS_DYNAMIC 0x0100
10776 +#define VS_STATIC 0x0200
10778 +#define VS_ATR_MASK 0x0F00
10780 +#ifdef CONFIG_VSERVER_PRIVACY
10781 +#define VS_ADMIN_P (0)
10782 +#define VS_WATCH_P (0)
10784 +#define VS_ADMIN_P VS_ADMIN
10785 +#define VS_WATCH_P VS_WATCH
10788 +#define VS_HARDIRQ 0x1000
10789 +#define VS_SOFTIRQ 0x2000
10790 +#define VS_IRQ 0x4000
10792 +#define VS_IRQ_MASK 0xF000
10794 +#include <linux/hardirq.h>
10797 + * check current context for ADMIN/WATCH and
10798 + * optionally against supplied argument
10800 +static inline int __vs_check(int cid, int id, unsigned int mode)
10802 + if (mode & VS_ARG_MASK) {
10803 + if ((mode & VS_IDENT) && (id == cid))
10806 + if (mode & VS_ATR_MASK) {
10807 + if ((mode & VS_DYNAMIC) &&
10808 + (id >= MIN_D_CONTEXT) &&
10809 + (id <= MAX_S_CONTEXT))
10811 + if ((mode & VS_STATIC) &&
10812 + (id > 1) && (id < MIN_D_CONTEXT))
10815 + if (mode & VS_IRQ_MASK) {
10816 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10818 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10820 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10823 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10824 + ((mode & VS_WATCH) && (cid == 1)) ||
10825 + ((mode & VS_HOSTID) && (id == 0)));
10828 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10830 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10833 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10835 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10838 diff -NurpP --minimal linux-3.6/include/linux/vserver/context.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/context.h
10839 --- linux-3.6/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10840 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/context.h 2012-10-04 18:47:00.000000000 +0200
10842 +#ifndef _VX_CONTEXT_H
10843 +#define _VX_CONTEXT_H
10845 +#include <linux/types.h>
10846 +#include <linux/capability.h>
10849 +/* context flags */
10851 +#define VXF_INFO_SCHED 0x00000002
10852 +#define VXF_INFO_NPROC 0x00000004
10853 +#define VXF_INFO_PRIVATE 0x00000008
10855 +#define VXF_INFO_INIT 0x00000010
10856 +#define VXF_INFO_HIDE 0x00000020
10857 +#define VXF_INFO_ULIMIT 0x00000040
10858 +#define VXF_INFO_NSPACE 0x00000080
10860 +#define VXF_SCHED_HARD 0x00000100
10861 +#define VXF_SCHED_PRIO 0x00000200
10862 +#define VXF_SCHED_PAUSE 0x00000400
10864 +#define VXF_VIRT_MEM 0x00010000
10865 +#define VXF_VIRT_UPTIME 0x00020000
10866 +#define VXF_VIRT_CPU 0x00040000
10867 +#define VXF_VIRT_LOAD 0x00080000
10868 +#define VXF_VIRT_TIME 0x00100000
10870 +#define VXF_HIDE_MOUNT 0x01000000
10871 +/* was VXF_HIDE_NETIF 0x02000000 */
10872 +#define VXF_HIDE_VINFO 0x04000000
10874 +#define VXF_STATE_SETUP (1ULL << 32)
10875 +#define VXF_STATE_INIT (1ULL << 33)
10876 +#define VXF_STATE_ADMIN (1ULL << 34)
10878 +#define VXF_SC_HELPER (1ULL << 36)
10879 +#define VXF_REBOOT_KILL (1ULL << 37)
10880 +#define VXF_PERSISTENT (1ULL << 38)
10882 +#define VXF_FORK_RSS (1ULL << 48)
10883 +#define VXF_PROLIFIC (1ULL << 49)
10885 +#define VXF_IGNEG_NICE (1ULL << 52)
10887 +#define VXF_ONE_TIME (0x0007ULL << 32)
10889 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10892 +/* context migration */
10894 +#define VXM_SET_INIT 0x00000001
10895 +#define VXM_SET_REAPER 0x00000002
10897 +/* context caps */
10899 +#define VXC_SET_UTSNAME 0x00000001
10900 +#define VXC_SET_RLIMIT 0x00000002
10901 +#define VXC_FS_SECURITY 0x00000004
10902 +#define VXC_FS_TRUSTED 0x00000008
10903 +#define VXC_TIOCSTI 0x00000010
10905 +/* was VXC_RAW_ICMP 0x00000100 */
10906 +#define VXC_SYSLOG 0x00001000
10907 +#define VXC_OOM_ADJUST 0x00002000
10908 +#define VXC_AUDIT_CONTROL 0x00004000
10910 +#define VXC_SECURE_MOUNT 0x00010000
10911 +#define VXC_SECURE_REMOUNT 0x00020000
10912 +#define VXC_BINARY_MOUNT 0x00040000
10914 +#define VXC_QUOTA_CTL 0x00100000
10915 +#define VXC_ADMIN_MAPPER 0x00200000
10916 +#define VXC_ADMIN_CLOOP 0x00400000
10918 +#define VXC_KTHREAD 0x01000000
10919 +#define VXC_NAMESPACE 0x02000000
10924 +#include <linux/list.h>
10925 +#include <linux/spinlock.h>
10926 +#include <linux/rcupdate.h>
10928 +#include "limit_def.h"
10929 +#include "sched_def.h"
10930 +#include "cvirt_def.h"
10931 +#include "cacct_def.h"
10932 +#include "device_def.h"
10934 +#define VX_SPACES 2
10936 +struct _vx_info_pc {
10937 + struct _vx_sched_pc sched_pc;
10938 + struct _vx_cvirt_pc cvirt_pc;
10941 +struct _vx_space {
10942 + unsigned long vx_nsmask; /* assignment mask */
10943 + struct nsproxy *vx_nsproxy; /* private namespaces */
10944 + struct fs_struct *vx_fs; /* private namespace fs */
10945 + const struct cred *vx_cred; /* task credentials */
10949 + struct hlist_node vx_hlist; /* linked list of contexts */
10950 + xid_t vx_id; /* context id */
10951 + atomic_t vx_usecnt; /* usage count */
10952 + atomic_t vx_tasks; /* tasks count */
10953 + struct vx_info *vx_parent; /* parent context */
10954 + int vx_state; /* context state */
10956 + struct _vx_space space[VX_SPACES]; /* namespace store */
10958 + uint64_t vx_flags; /* context flags */
10959 + uint64_t vx_ccaps; /* context caps (vserver) */
10960 + uint64_t vx_umask; /* unshare mask (guest) */
10961 + uint64_t vx_wmask; /* warn mask (guest) */
10962 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10964 + struct task_struct *vx_reaper; /* guest reaper process */
10965 + pid_t vx_initpid; /* PID of guest init */
10966 + int64_t vx_badness_bias; /* OOM points bias */
10968 + struct _vx_limit limit; /* vserver limits */
10969 + struct _vx_sched sched; /* vserver scheduler */
10970 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10971 + struct _vx_cacct cacct; /* context accounting */
10973 + struct _vx_device dmap; /* default device map targets */
10975 +#ifndef CONFIG_SMP
10976 + struct _vx_info_pc info_pc; /* per cpu data */
10978 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10981 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10982 + int reboot_cmd; /* last sys_reboot() cmd */
10983 + int exit_code; /* last process exit code */
10985 + char vx_name[65]; /* vserver name */
10988 +#ifndef CONFIG_SMP
10989 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10990 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10992 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10993 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10996 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10999 +struct vx_info_save {
11000 + struct vx_info *vxi;
11005 +/* status flags */
11007 +#define VXS_HASHED 0x0001
11008 +#define VXS_PAUSED 0x0010
11009 +#define VXS_SHUTDOWN 0x0100
11010 +#define VXS_HELPER 0x1000
11011 +#define VXS_RELEASED 0x8000
11014 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11015 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11017 +extern struct vx_info *lookup_vx_info(int);
11018 +extern struct vx_info *lookup_or_create_vx_info(int);
11020 +extern int get_xid_list(int, unsigned int *, int);
11021 +extern int xid_is_hashed(xid_t);
11023 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11025 +extern long vs_state_change(struct vx_info *, unsigned int);
11028 +#endif /* __KERNEL__ */
11029 +#endif /* _VX_CONTEXT_H */
11030 diff -NurpP --minimal linux-3.6/include/linux/vserver/context_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/context_cmd.h
11031 --- linux-3.6/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
11032 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/context_cmd.h 2012-10-04 18:47:00.000000000 +0200
11034 +#ifndef _VX_CONTEXT_CMD_H
11035 +#define _VX_CONTEXT_CMD_H
11038 +/* vinfo commands */
11040 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
11043 +extern int vc_task_xid(uint32_t);
11045 +#endif /* __KERNEL__ */
11047 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
11049 +struct vcmd_vx_info_v0 {
11051 + uint32_t initpid;
11052 + /* more to come */
11056 +extern int vc_vx_info(struct vx_info *, void __user *);
11058 +#endif /* __KERNEL__ */
11060 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
11062 +struct vcmd_ctx_stat_v0 {
11065 + /* more to come */
11069 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11071 +#endif /* __KERNEL__ */
11073 +/* context commands */
11075 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
11076 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
11078 +struct vcmd_ctx_create {
11079 + uint64_t flagword;
11082 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
11083 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
11085 +struct vcmd_ctx_migrate {
11086 + uint64_t flagword;
11090 +extern int vc_ctx_create(uint32_t, void __user *);
11091 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11093 +#endif /* __KERNEL__ */
11096 +/* flag commands */
11098 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
11099 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
11101 +struct vcmd_ctx_flags_v0 {
11102 + uint64_t flagword;
11107 +extern int vc_get_cflags(struct vx_info *, void __user *);
11108 +extern int vc_set_cflags(struct vx_info *, void __user *);
11110 +#endif /* __KERNEL__ */
11113 +/* context caps commands */
11115 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
11116 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
11118 +struct vcmd_ctx_caps_v1 {
11124 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11125 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11127 +#endif /* __KERNEL__ */
11130 +/* bcaps commands */
11132 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
11133 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
11135 +struct vcmd_bcaps {
11141 +extern int vc_get_bcaps(struct vx_info *, void __user *);
11142 +extern int vc_set_bcaps(struct vx_info *, void __user *);
11144 +#endif /* __KERNEL__ */
11147 +/* umask commands */
11149 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
11150 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
11152 +struct vcmd_umask {
11158 +extern int vc_get_umask(struct vx_info *, void __user *);
11159 +extern int vc_set_umask(struct vx_info *, void __user *);
11161 +#endif /* __KERNEL__ */
11164 +/* wmask commands */
11166 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
11167 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
11169 +struct vcmd_wmask {
11175 +extern int vc_get_wmask(struct vx_info *, void __user *);
11176 +extern int vc_set_wmask(struct vx_info *, void __user *);
11178 +#endif /* __KERNEL__ */
11183 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
11184 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
11186 +struct vcmd_badness_v0 {
11191 +extern int vc_get_badness(struct vx_info *, void __user *);
11192 +extern int vc_set_badness(struct vx_info *, void __user *);
11194 +#endif /* __KERNEL__ */
11195 +#endif /* _VX_CONTEXT_CMD_H */
11196 diff -NurpP --minimal linux-3.6/include/linux/vserver/cvirt.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cvirt.h
11197 --- linux-3.6/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11198 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cvirt.h 2012-10-04 18:47:00.000000000 +0200
11200 +#ifndef _VX_CVIRT_H
11201 +#define _VX_CVIRT_H
11208 +void vx_vsi_boottime(struct timespec *);
11210 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11215 +void vx_update_load(struct vx_info *);
11218 +int vx_do_syslog(int, char __user *, int);
11220 +#endif /* __KERNEL__ */
11221 +#endif /* _VX_CVIRT_H */
11222 diff -NurpP --minimal linux-3.6/include/linux/vserver/cvirt_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cvirt_cmd.h
11223 --- linux-3.6/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
11224 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cvirt_cmd.h 2012-10-04 18:47:00.000000000 +0200
11226 +#ifndef _VX_CVIRT_CMD_H
11227 +#define _VX_CVIRT_CMD_H
11230 +/* virtual host info name commands */
11232 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11233 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11235 +struct vcmd_vhi_name_v0 {
11241 +enum vhi_name_field {
11242 + VHIN_CONTEXT = 0,
11254 +#include <linux/compiler.h>
11256 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11257 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11259 +#endif /* __KERNEL__ */
11261 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11263 +struct vcmd_virt_stat_v0 {
11266 + uint32_t nr_threads;
11267 + uint32_t nr_running;
11268 + uint32_t nr_uninterruptible;
11269 + uint32_t nr_onhold;
11270 + uint32_t nr_forks;
11271 + uint32_t load[3];
11275 +extern int vc_virt_stat(struct vx_info *, void __user *);
11277 +#endif /* __KERNEL__ */
11278 +#endif /* _VX_CVIRT_CMD_H */
11279 diff -NurpP --minimal linux-3.6/include/linux/vserver/cvirt_def.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cvirt_def.h
11280 --- linux-3.6/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
11281 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/cvirt_def.h 2012-10-04 18:47:00.000000000 +0200
11283 +#ifndef _VX_CVIRT_DEF_H
11284 +#define _VX_CVIRT_DEF_H
11286 +#include <linux/jiffies.h>
11287 +#include <linux/spinlock.h>
11288 +#include <linux/wait.h>
11289 +#include <linux/time.h>
11290 +#include <asm/atomic.h>
11293 +struct _vx_usage_stat {
11297 + uint64_t softirq;
11303 +struct _vx_syslog {
11304 + wait_queue_head_t log_wait;
11305 + spinlock_t logbuf_lock; /* lock for the log buffer */
11307 + unsigned long log_start; /* next char to be read by syslog() */
11308 + unsigned long con_start; /* next char to be sent to consoles */
11309 + unsigned long log_end; /* most-recently-written-char + 1 */
11310 + unsigned long logged_chars; /* #chars since last read+clear operation */
11312 + char log_buf[1024];
11316 +/* context sub struct */
11318 +struct _vx_cvirt {
11319 + atomic_t nr_threads; /* number of current threads */
11320 + atomic_t nr_running; /* number of running threads */
11321 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11323 + atomic_t nr_onhold; /* processes on hold */
11324 + uint32_t onhold_last; /* jiffies when put on hold */
11326 + struct timespec bias_ts; /* time offset to the host */
11327 + struct timespec bias_idle;
11328 + struct timespec bias_uptime; /* context creation point */
11329 + uint64_t bias_clock; /* offset in clock_t */
11331 + spinlock_t load_lock; /* lock for the load averages */
11332 + atomic_t load_updates; /* nr of load updates done so far */
11333 + uint32_t load_last; /* last time load was calculated */
11334 + uint32_t load[3]; /* load averages 1,5,15 */
11336 + atomic_t total_forks; /* number of forks so far */
11338 + struct _vx_syslog syslog;
11341 +struct _vx_cvirt_pc {
11342 + struct _vx_usage_stat cpustat;
11346 +#ifdef CONFIG_VSERVER_DEBUG
11348 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11350 + printk("\t_vx_cvirt:\n");
11351 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11352 + atomic_read(&cvirt->nr_threads),
11353 + atomic_read(&cvirt->nr_running),
11354 + atomic_read(&cvirt->nr_uninterruptible),
11355 + atomic_read(&cvirt->nr_onhold));
11356 + /* add rest here */
11357 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11362 +#endif /* _VX_CVIRT_DEF_H */
11363 diff -NurpP --minimal linux-3.6/include/linux/vserver/debug.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/debug.h
11364 --- linux-3.6/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11365 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/debug.h 2012-10-04 18:47:00.000000000 +0200
11367 +#ifndef _VX_DEBUG_H
11368 +#define _VX_DEBUG_H
11371 +#define VXD_CBIT(n, m) (vs_debug_ ## n & (1 << (m)))
11372 +#define VXD_CMIN(n, m) (vs_debug_ ## n > (m))
11373 +#define VXD_MASK(n, m) (vs_debug_ ## n & (m))
11375 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11376 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11377 +#define VXF_DEV "%p[%lu,%d:%d]"
11379 +#if defined(CONFIG_QUOTES_UTF8)
11380 +#define VS_Q_LQM "\xc2\xbb"
11381 +#define VS_Q_RQM "\xc2\xab"
11382 +#elif defined(CONFIG_QUOTES_ASCII)
11383 +#define VS_Q_LQM "\x27"
11384 +#define VS_Q_RQM "\x27"
11386 +#define VS_Q_LQM "\xbb"
11387 +#define VS_Q_RQM "\xab"
11390 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
11393 +#define vxd_path(p) \
11394 + ({ static char _buffer[PATH_MAX]; \
11395 + d_path(p, _buffer, sizeof(_buffer)); })
11397 +#define vxd_cond_path(n) \
11398 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11401 +#ifdef CONFIG_VSERVER_DEBUG
11403 +extern unsigned int vs_debug_switch;
11404 +extern unsigned int vs_debug_xid;
11405 +extern unsigned int vs_debug_nid;
11406 +extern unsigned int vs_debug_tag;
11407 +extern unsigned int vs_debug_net;
11408 +extern unsigned int vs_debug_limit;
11409 +extern unsigned int vs_debug_cres;
11410 +extern unsigned int vs_debug_dlim;
11411 +extern unsigned int vs_debug_quota;
11412 +extern unsigned int vs_debug_cvirt;
11413 +extern unsigned int vs_debug_space;
11414 +extern unsigned int vs_debug_perm;
11415 +extern unsigned int vs_debug_misc;
11418 +#define VX_LOGLEVEL "vxD: "
11419 +#define VX_PROC_FMT "%p: "
11420 +#define VX_PROCESS current
11422 +#define vxdprintk(c, f, x...) \
11425 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11426 + VX_PROCESS , ##x); \
11429 +#define vxlprintk(c, f, x...) \
11432 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11435 +#define vxfprintk(c, f, x...) \
11438 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11444 +void dump_vx_info(struct vx_info *, int);
11445 +void dump_vx_info_inactive(int);
11447 +#else /* CONFIG_VSERVER_DEBUG */
11449 +#define vs_debug_switch 0
11450 +#define vs_debug_xid 0
11451 +#define vs_debug_nid 0
11452 +#define vs_debug_tag 0
11453 +#define vs_debug_net 0
11454 +#define vs_debug_limit 0
11455 +#define vs_debug_cres 0
11456 +#define vs_debug_dlim 0
11457 +#define vs_debug_quota 0
11458 +#define vs_debug_cvirt 0
11459 +#define vs_debug_space 0
11460 +#define vs_debug_perm 0
11461 +#define vs_debug_misc 0
11463 +#define vxdprintk(x...) do { } while (0)
11464 +#define vxlprintk(x...) do { } while (0)
11465 +#define vxfprintk(x...) do { } while (0)
11467 +#endif /* CONFIG_VSERVER_DEBUG */
11470 +#ifdef CONFIG_VSERVER_WARN
11472 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11473 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
11474 +#define VX_WARN_XID "[xid #%u] "
11475 +#define VX_WARN_NID "[nid #%u] "
11476 +#define VX_WARN_TAG "[tag #%u] "
11478 +#define vxwprintk(c, f, x...) \
11481 + printk(VX_WARNLEVEL f "\n", ##x); \
11484 +#else /* CONFIG_VSERVER_WARN */
11486 +#define vxwprintk(x...) do { } while (0)
11488 +#endif /* CONFIG_VSERVER_WARN */
11490 +#define vxwprintk_task(c, f, x...) \
11491 + vxwprintk(c, VX_WARN_TASK f, \
11492 + current->comm, current->pid, \
11493 + current->xid, current->nid, current->tag, ##x)
11494 +#define vxwprintk_xid(c, f, x...) \
11495 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11496 +#define vxwprintk_nid(c, f, x...) \
11497 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11498 +#define vxwprintk_tag(c, f, x...) \
11499 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11501 +#ifdef CONFIG_VSERVER_DEBUG
11502 +#define vxd_assert_lock(l) assert_spin_locked(l)
11503 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11504 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11506 +#define vxd_assert_lock(l) do { } while (0)
11507 +#define vxd_assert(c, f, x...) do { } while (0)
11511 +#endif /* _VX_DEBUG_H */
11512 diff -NurpP --minimal linux-3.6/include/linux/vserver/debug_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/debug_cmd.h
11513 --- linux-3.6/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11514 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/debug_cmd.h 2012-10-04 18:47:00.000000000 +0200
11516 +#ifndef _VX_DEBUG_CMD_H
11517 +#define _VX_DEBUG_CMD_H
11520 +/* debug commands */
11522 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11524 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11525 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11527 +struct vcmd_read_history_v0 {
11530 + char __user *data;
11533 +struct vcmd_read_monitor_v0 {
11536 + char __user *data;
11542 +#ifdef CONFIG_COMPAT
11544 +#include <asm/compat.h>
11546 +struct vcmd_read_history_v0_x32 {
11549 + compat_uptr_t data_ptr;
11552 +struct vcmd_read_monitor_v0_x32 {
11555 + compat_uptr_t data_ptr;
11558 +#endif /* CONFIG_COMPAT */
11560 +extern int vc_dump_history(uint32_t);
11562 +extern int vc_read_history(uint32_t, void __user *);
11563 +extern int vc_read_monitor(uint32_t, void __user *);
11565 +#ifdef CONFIG_COMPAT
11567 +extern int vc_read_history_x32(uint32_t, void __user *);
11568 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11570 +#endif /* CONFIG_COMPAT */
11572 +#endif /* __KERNEL__ */
11573 +#endif /* _VX_DEBUG_CMD_H */
11574 diff -NurpP --minimal linux-3.6/include/linux/vserver/device.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/device.h
11575 --- linux-3.6/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11576 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/device.h 2012-10-04 18:47:00.000000000 +0200
11578 +#ifndef _VX_DEVICE_H
11579 +#define _VX_DEVICE_H
11582 +#define DATTR_CREATE 0x00000001
11583 +#define DATTR_OPEN 0x00000002
11585 +#define DATTR_REMAP 0x00000010
11587 +#define DATTR_MASK 0x00000013
11590 +#else /* _VX_DEVICE_H */
11591 +#warning duplicate inclusion
11592 +#endif /* _VX_DEVICE_H */
11593 diff -NurpP --minimal linux-3.6/include/linux/vserver/device_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/device_cmd.h
11594 --- linux-3.6/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11595 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/device_cmd.h 2012-10-04 18:47:00.000000000 +0200
11597 +#ifndef _VX_DEVICE_CMD_H
11598 +#define _VX_DEVICE_CMD_H
11601 +/* device vserver commands */
11603 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11604 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11606 +struct vcmd_set_mapping_v0 {
11607 + const char __user *device;
11608 + const char __user *target;
11615 +#ifdef CONFIG_COMPAT
11617 +#include <asm/compat.h>
11619 +struct vcmd_set_mapping_v0_x32 {
11620 + compat_uptr_t device_ptr;
11621 + compat_uptr_t target_ptr;
11625 +#endif /* CONFIG_COMPAT */
11627 +#include <linux/compiler.h>
11629 +extern int vc_set_mapping(struct vx_info *, void __user *);
11630 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11632 +#ifdef CONFIG_COMPAT
11634 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11635 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11637 +#endif /* CONFIG_COMPAT */
11639 +#endif /* __KERNEL__ */
11640 +#endif /* _VX_DEVICE_CMD_H */
11641 diff -NurpP --minimal linux-3.6/include/linux/vserver/device_def.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/device_def.h
11642 --- linux-3.6/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11643 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/device_def.h 2012-10-04 18:47:00.000000000 +0200
11645 +#ifndef _VX_DEVICE_DEF_H
11646 +#define _VX_DEVICE_DEF_H
11648 +#include <linux/types.h>
11650 +struct vx_dmap_target {
11655 +struct _vx_device {
11656 +#ifdef CONFIG_VSERVER_DEVICE
11657 + struct vx_dmap_target targets[2];
11661 +#endif /* _VX_DEVICE_DEF_H */
11662 diff -NurpP --minimal linux-3.6/include/linux/vserver/dlimit.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/dlimit.h
11663 --- linux-3.6/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11664 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/dlimit.h 2012-10-04 18:47:00.000000000 +0200
11666 +#ifndef _VX_DLIMIT_H
11667 +#define _VX_DLIMIT_H
11669 +#include "switch.h"
11674 +/* keep in sync with CDLIM_INFINITY */
11676 +#define DLIM_INFINITY (~0ULL)
11678 +#include <linux/spinlock.h>
11679 +#include <linux/rcupdate.h>
11681 +struct super_block;
11684 + struct hlist_node dl_hlist; /* linked list of contexts */
11685 + struct rcu_head dl_rcu; /* the rcu head */
11686 + tag_t dl_tag; /* context tag */
11687 + atomic_t dl_usecnt; /* usage count */
11688 + atomic_t dl_refcnt; /* reference count */
11690 + struct super_block *dl_sb; /* associated superblock */
11692 + spinlock_t dl_lock; /* protect the values */
11694 + unsigned long long dl_space_used; /* used space in bytes */
11695 + unsigned long long dl_space_total; /* maximum space in bytes */
11696 + unsigned long dl_inodes_used; /* used inodes */
11697 + unsigned long dl_inodes_total; /* maximum inodes */
11699 + unsigned int dl_nrlmult; /* non root limit mult */
11704 +extern void rcu_free_dl_info(struct rcu_head *);
11705 +extern void unhash_dl_info(struct dl_info *);
11707 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11712 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11714 +typedef uint64_t dlsize_t;
11716 +#endif /* __KERNEL__ */
11717 +#else /* _VX_DLIMIT_H */
11718 +#warning duplicate inclusion
11719 +#endif /* _VX_DLIMIT_H */
11720 diff -NurpP --minimal linux-3.6/include/linux/vserver/dlimit_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/dlimit_cmd.h
11721 --- linux-3.6/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11722 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/dlimit_cmd.h 2012-10-04 18:47:00.000000000 +0200
11724 +#ifndef _VX_DLIMIT_CMD_H
11725 +#define _VX_DLIMIT_CMD_H
11728 +/* dlimit vserver commands */
11730 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11731 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11733 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11734 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11736 +struct vcmd_ctx_dlimit_base_v0 {
11737 + const char __user *name;
11741 +struct vcmd_ctx_dlimit_v0 {
11742 + const char __user *name;
11743 + uint32_t space_used; /* used space in kbytes */
11744 + uint32_t space_total; /* maximum space in kbytes */
11745 + uint32_t inodes_used; /* used inodes */
11746 + uint32_t inodes_total; /* maximum inodes */
11747 + uint32_t reserved; /* reserved for root in % */
11751 +#define CDLIM_UNSET ((uint32_t)0UL)
11752 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11753 +#define CDLIM_KEEP ((uint32_t)~1UL)
11755 +#define DLIME_UNIT 0
11756 +#define DLIME_KILO 1
11757 +#define DLIME_MEGA 2
11758 +#define DLIME_GIGA 3
11760 +#define DLIMF_SHIFT 0x10
11762 +#define DLIMS_USED 0
11763 +#define DLIMS_TOTAL 2
11766 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
11768 + int exp = (flags & DLIMF_SHIFT) ?
11769 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
11770 + return ((uint64_t)val) << (10 * exp);
11774 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
11778 + if (*flags & DLIMF_SHIFT) {
11779 + while (val > (1LL << 32) && (exp < 3)) {
11783 + *flags &= ~(DLIME_GIGA << shift);
11784 + *flags |= exp << shift;
11792 +#ifdef CONFIG_COMPAT
11794 +#include <asm/compat.h>
11796 +struct vcmd_ctx_dlimit_base_v0_x32 {
11797 + compat_uptr_t name_ptr;
11801 +struct vcmd_ctx_dlimit_v0_x32 {
11802 + compat_uptr_t name_ptr;
11803 + uint32_t space_used; /* used space in kbytes */
11804 + uint32_t space_total; /* maximum space in kbytes */
11805 + uint32_t inodes_used; /* used inodes */
11806 + uint32_t inodes_total; /* maximum inodes */
11807 + uint32_t reserved; /* reserved for root in % */
11811 +#endif /* CONFIG_COMPAT */
11813 +#include <linux/compiler.h>
11815 +extern int vc_add_dlimit(uint32_t, void __user *);
11816 +extern int vc_rem_dlimit(uint32_t, void __user *);
11818 +extern int vc_set_dlimit(uint32_t, void __user *);
11819 +extern int vc_get_dlimit(uint32_t, void __user *);
11821 +#ifdef CONFIG_COMPAT
11823 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11824 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11826 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11827 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11829 +#endif /* CONFIG_COMPAT */
11831 +#endif /* __KERNEL__ */
11832 +#endif /* _VX_DLIMIT_CMD_H */
11833 diff -NurpP --minimal linux-3.6/include/linux/vserver/global.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/global.h
11834 --- linux-3.6/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11835 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/global.h 2012-10-04 18:47:00.000000000 +0200
11837 +#ifndef _VX_GLOBAL_H
11838 +#define _VX_GLOBAL_H
11841 +extern atomic_t vx_global_ctotal;
11842 +extern atomic_t vx_global_cactive;
11844 +extern atomic_t nx_global_ctotal;
11845 +extern atomic_t nx_global_cactive;
11847 +extern atomic_t vs_global_nsproxy;
11848 +extern atomic_t vs_global_fs;
11849 +extern atomic_t vs_global_mnt_ns;
11850 +extern atomic_t vs_global_uts_ns;
11851 +extern atomic_t vs_global_user_ns;
11852 +extern atomic_t vs_global_pid_ns;
11855 +#endif /* _VX_GLOBAL_H */
11856 diff -NurpP --minimal linux-3.6/include/linux/vserver/history.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/history.h
11857 --- linux-3.6/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11858 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/history.h 2012-10-04 18:47:00.000000000 +0200
11860 +#ifndef _VX_HISTORY_H
11861 +#define _VX_HISTORY_H
11866 + VXH_THROW_OOPS = 1,
11870 + VXH_INIT_VX_INFO,
11873 + VXH_CLAIM_VX_INFO,
11874 + VXH_RELEASE_VX_INFO,
11875 + VXH_ALLOC_VX_INFO,
11876 + VXH_DEALLOC_VX_INFO,
11877 + VXH_HASH_VX_INFO,
11878 + VXH_UNHASH_VX_INFO,
11880 + VXH_LOOKUP_VX_INFO,
11881 + VXH_CREATE_VX_INFO,
11884 +struct _vxhe_vxi {
11885 + struct vx_info *ptr;
11891 +struct _vxhe_set_clr {
11895 +struct _vxhe_loc_lookup {
11899 +struct _vx_hist_entry {
11901 + unsigned short seq;
11902 + unsigned short type;
11903 + struct _vxhe_vxi vxi;
11905 + struct _vxhe_set_clr sc;
11906 + struct _vxhe_loc_lookup ll;
11910 +#ifdef CONFIG_VSERVER_HISTORY
11912 +extern unsigned volatile int vxh_active;
11914 +struct _vx_hist_entry *vxh_advance(void *loc);
11918 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11920 + entry->vxi.ptr = vxi;
11922 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11923 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11924 + entry->vxi.xid = vxi->vx_id;
11929 +#define __HERE__ current_text_addr()
11931 +#define __VXH_BODY(__type, __data, __here) \
11932 + struct _vx_hist_entry *entry; \
11934 + preempt_disable(); \
11935 + entry = vxh_advance(__here); \
11937 + entry->type = __type; \
11938 + preempt_enable();
11941 + /* pass vxi only */
11943 +#define __VXH_SMPL \
11944 + __vxh_copy_vxi(entry, vxi)
11947 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11949 + __VXH_BODY(__type, __VXH_SMPL, __here)
11952 + /* pass vxi and data (void *) */
11954 +#define __VXH_DATA \
11955 + __vxh_copy_vxi(entry, vxi); \
11956 + entry->sc.data = data
11959 +void __vxh_data(struct vx_info *vxi, void *data,
11960 + int __type, void *__here)
11962 + __VXH_BODY(__type, __VXH_DATA, __here)
11965 + /* pass vxi and arg (long) */
11967 +#define __VXH_LONG \
11968 + __vxh_copy_vxi(entry, vxi); \
11969 + entry->ll.arg = arg
11972 +void __vxh_long(struct vx_info *vxi, long arg,
11973 + int __type, void *__here)
11975 + __VXH_BODY(__type, __VXH_LONG, __here)
11980 +void __vxh_throw_oops(void *__here)
11982 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11983 + /* prevent further acquisition */
11988 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11990 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11991 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11993 +#define __vxh_init_vx_info(v, d, h) \
11994 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11995 +#define __vxh_set_vx_info(v, d, h) \
11996 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11997 +#define __vxh_clr_vx_info(v, d, h) \
11998 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12000 +#define __vxh_claim_vx_info(v, d, h) \
12001 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12002 +#define __vxh_release_vx_info(v, d, h) \
12003 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12005 +#define vxh_alloc_vx_info(v) \
12006 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12007 +#define vxh_dealloc_vx_info(v) \
12008 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12010 +#define vxh_hash_vx_info(v) \
12011 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12012 +#define vxh_unhash_vx_info(v) \
12013 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12015 +#define vxh_loc_vx_info(v, l) \
12016 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
12017 +#define vxh_lookup_vx_info(v, l) \
12018 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
12019 +#define vxh_create_vx_info(v, l) \
12020 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
12022 +extern void vxh_dump_history(void);
12025 +#else /* CONFIG_VSERVER_HISTORY */
12027 +#define __HERE__ 0
12029 +#define vxh_throw_oops() do { } while (0)
12031 +#define __vxh_get_vx_info(v, h) do { } while (0)
12032 +#define __vxh_put_vx_info(v, h) do { } while (0)
12034 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
12035 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
12036 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
12038 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
12039 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
12041 +#define vxh_alloc_vx_info(v) do { } while (0)
12042 +#define vxh_dealloc_vx_info(v) do { } while (0)
12044 +#define vxh_hash_vx_info(v) do { } while (0)
12045 +#define vxh_unhash_vx_info(v) do { } while (0)
12047 +#define vxh_loc_vx_info(v, l) do { } while (0)
12048 +#define vxh_lookup_vx_info(v, l) do { } while (0)
12049 +#define vxh_create_vx_info(v, l) do { } while (0)
12051 +#define vxh_dump_history() do { } while (0)
12054 +#endif /* CONFIG_VSERVER_HISTORY */
12056 +#endif /* _VX_HISTORY_H */
12057 diff -NurpP --minimal linux-3.6/include/linux/vserver/inode.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/inode.h
12058 --- linux-3.6/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
12059 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/inode.h 2012-10-04 18:47:00.000000000 +0200
12061 +#ifndef _VX_INODE_H
12062 +#define _VX_INODE_H
12065 +#define IATTR_TAG 0x01000000
12067 +#define IATTR_ADMIN 0x00000001
12068 +#define IATTR_WATCH 0x00000002
12069 +#define IATTR_HIDE 0x00000004
12070 +#define IATTR_FLAGS 0x00000007
12072 +#define IATTR_BARRIER 0x00010000
12073 +#define IATTR_IXUNLINK 0x00020000
12074 +#define IATTR_IMMUTABLE 0x00040000
12075 +#define IATTR_COW 0x00080000
12080 +#ifdef CONFIG_VSERVER_PROC_SECURE
12081 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12082 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12084 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12085 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12088 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12090 +#endif /* __KERNEL__ */
12092 +/* inode ioctls */
12094 +#define FIOC_GETXFLG _IOR('x', 5, long)
12095 +#define FIOC_SETXFLG _IOW('x', 6, long)
12097 +#else /* _VX_INODE_H */
12098 +#warning duplicate inclusion
12099 +#endif /* _VX_INODE_H */
12100 diff -NurpP --minimal linux-3.6/include/linux/vserver/inode_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/inode_cmd.h
12101 --- linux-3.6/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
12102 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/inode_cmd.h 2012-10-04 18:47:00.000000000 +0200
12104 +#ifndef _VX_INODE_CMD_H
12105 +#define _VX_INODE_CMD_H
12108 +/* inode vserver commands */
12110 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
12111 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
12113 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
12114 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
12116 +struct vcmd_ctx_iattr_v1 {
12117 + const char __user *name;
12123 +struct vcmd_ctx_fiattr_v0 {
12133 +#ifdef CONFIG_COMPAT
12135 +#include <asm/compat.h>
12137 +struct vcmd_ctx_iattr_v1_x32 {
12138 + compat_uptr_t name_ptr;
12144 +#endif /* CONFIG_COMPAT */
12146 +#include <linux/compiler.h>
12148 +extern int vc_get_iattr(void __user *);
12149 +extern int vc_set_iattr(void __user *);
12151 +extern int vc_fget_iattr(uint32_t, void __user *);
12152 +extern int vc_fset_iattr(uint32_t, void __user *);
12154 +#ifdef CONFIG_COMPAT
12156 +extern int vc_get_iattr_x32(void __user *);
12157 +extern int vc_set_iattr_x32(void __user *);
12159 +#endif /* CONFIG_COMPAT */
12161 +#endif /* __KERNEL__ */
12162 +#endif /* _VX_INODE_CMD_H */
12163 diff -NurpP --minimal linux-3.6/include/linux/vserver/limit.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/limit.h
12164 --- linux-3.6/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12165 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/limit.h 2012-10-04 18:47:00.000000000 +0200
12167 +#ifndef _VX_LIMIT_H
12168 +#define _VX_LIMIT_H
12170 +#define VLIMIT_NSOCK 16
12171 +#define VLIMIT_OPENFD 17
12172 +#define VLIMIT_ANON 18
12173 +#define VLIMIT_SHMEM 19
12174 +#define VLIMIT_SEMARY 20
12175 +#define VLIMIT_NSEMS 21
12176 +#define VLIMIT_DENTRY 22
12177 +#define VLIMIT_MAPPED 23
12182 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12184 +/* keep in sync with CRLIM_INFINITY */
12186 +#define VLIM_INFINITY (~0ULL)
12188 +#include <asm/atomic.h>
12189 +#include <asm/resource.h>
12191 +#ifndef RLIM_INFINITY
12192 +#warning RLIM_INFINITY is undefined
12195 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12197 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12198 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12200 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12201 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12202 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12204 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12205 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12207 +typedef atomic_long_t rlim_atomic_t;
12208 +typedef unsigned long rlim_t;
12210 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12211 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12212 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12213 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12214 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12215 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12218 +#if (RLIM_INFINITY == VLIM_INFINITY)
12219 +#define VX_VLIM(r) ((long long)(long)(r))
12220 +#define VX_RLIM(v) ((rlim_t)(v))
12222 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12223 + ? VLIM_INFINITY : (long long)(r))
12224 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12225 + ? RLIM_INFINITY : (rlim_t)(v))
12230 +void vx_vsi_meminfo(struct sysinfo *);
12231 +void vx_vsi_swapinfo(struct sysinfo *);
12232 +long vx_vsi_cached(struct sysinfo *);
12234 +#define NUM_LIMITS 24
12236 +#endif /* __KERNEL__ */
12237 +#endif /* _VX_LIMIT_H */
12238 diff -NurpP --minimal linux-3.6/include/linux/vserver/limit_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/limit_cmd.h
12239 --- linux-3.6/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12240 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/limit_cmd.h 2012-10-04 18:47:00.000000000 +0200
12242 +#ifndef _VX_LIMIT_CMD_H
12243 +#define _VX_LIMIT_CMD_H
12246 +/* rlimit vserver commands */
12248 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12249 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12250 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12251 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
12252 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12254 +struct vcmd_ctx_rlimit_v0 {
12256 + uint64_t minimum;
12257 + uint64_t softlimit;
12258 + uint64_t maximum;
12261 +struct vcmd_ctx_rlimit_mask_v0 {
12262 + uint32_t minimum;
12263 + uint32_t softlimit;
12264 + uint32_t maximum;
12267 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12269 +struct vcmd_rlimit_stat_v0 {
12273 + uint64_t minimum;
12274 + uint64_t maximum;
12277 +#define CRLIM_UNSET (0ULL)
12278 +#define CRLIM_INFINITY (~0ULL)
12279 +#define CRLIM_KEEP (~1ULL)
12283 +#ifdef CONFIG_IA32_EMULATION
12285 +struct vcmd_ctx_rlimit_v0_x32 {
12287 + uint64_t minimum;
12288 + uint64_t softlimit;
12289 + uint64_t maximum;
12290 +} __attribute__ ((packed));
12292 +#endif /* CONFIG_IA32_EMULATION */
12294 +#include <linux/compiler.h>
12296 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12297 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12298 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12299 +extern int vc_reset_hits(struct vx_info *, void __user *);
12300 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12302 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12304 +#ifdef CONFIG_IA32_EMULATION
12306 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12307 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12309 +#endif /* CONFIG_IA32_EMULATION */
12311 +#endif /* __KERNEL__ */
12312 +#endif /* _VX_LIMIT_CMD_H */
12313 diff -NurpP --minimal linux-3.6/include/linux/vserver/limit_def.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/limit_def.h
12314 --- linux-3.6/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
12315 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/limit_def.h 2012-10-04 18:47:00.000000000 +0200
12317 +#ifndef _VX_LIMIT_DEF_H
12318 +#define _VX_LIMIT_DEF_H
12320 +#include <asm/atomic.h>
12321 +#include <asm/resource.h>
12323 +#include "limit.h"
12326 +struct _vx_res_limit {
12327 + rlim_t soft; /* Context soft limit */
12328 + rlim_t hard; /* Context hard limit */
12330 + rlim_atomic_t rcur; /* Current value */
12331 + rlim_t rmin; /* Context minimum */
12332 + rlim_t rmax; /* Context maximum */
12334 + atomic_t lhit; /* Limit hits */
12337 +/* context sub struct */
12339 +struct _vx_limit {
12340 + struct _vx_res_limit res[NUM_LIMITS];
12343 +#ifdef CONFIG_VSERVER_DEBUG
12345 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12349 + printk("\t_vx_limit:");
12350 + for (i = 0; i < NUM_LIMITS; i++) {
12351 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12352 + i, (unsigned long)__rlim_get(limit, i),
12353 + (unsigned long)__rlim_rmin(limit, i),
12354 + (unsigned long)__rlim_rmax(limit, i),
12355 + (long)__rlim_soft(limit, i),
12356 + (long)__rlim_hard(limit, i),
12357 + atomic_read(&__rlim_lhit(limit, i)));
12363 +#endif /* _VX_LIMIT_DEF_H */
12364 diff -NurpP --minimal linux-3.6/include/linux/vserver/limit_int.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/limit_int.h
12365 --- linux-3.6/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12366 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/limit_int.h 2012-10-04 18:47:00.000000000 +0200
12368 +#ifndef _VX_LIMIT_INT_H
12369 +#define _VX_LIMIT_INT_H
12371 +#include "context.h"
12375 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12376 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12378 +extern const char *vlimit_name[NUM_LIMITS];
12380 +static inline void __vx_acc_cres(struct vx_info *vxi,
12381 + int res, int dir, void *_data, char *_file, int _line)
12383 + if (VXD_RCRES_COND(res))
12384 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12385 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12386 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12387 + (dir > 0) ? "++" : "--", _data, _file, _line);
12392 + __rlim_inc(&vxi->limit, res);
12394 + __rlim_dec(&vxi->limit, res);
12397 +static inline void __vx_add_cres(struct vx_info *vxi,
12398 + int res, int amount, void *_data, char *_file, int _line)
12400 + if (VXD_RCRES_COND(res))
12401 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12402 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12403 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12404 + amount, _data, _file, _line);
12409 + __rlim_add(&vxi->limit, res, amount);
12413 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12415 + int cond = (value > __rlim_rmax(limit, res));
12418 + __rlim_rmax(limit, res) = value;
12423 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12425 + int cond = (value < __rlim_rmin(limit, res));
12428 + __rlim_rmin(limit, res) = value;
12433 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12435 + if (!__vx_cres_adjust_max(limit, res, value))
12436 + __vx_cres_adjust_min(limit, res, value);
12441 + +1 ... no limit hit
12442 + -1 ... over soft limit
12443 + 0 ... over hard limit */
12445 +static inline int __vx_cres_avail(struct vx_info *vxi,
12446 + int res, int num, char *_file, int _line)
12448 + struct _vx_limit *limit;
12451 + if (VXD_RLIMIT_COND(res))
12452 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12453 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12454 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12455 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12456 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12457 + num, _file, _line);
12461 + limit = &vxi->limit;
12462 + value = __rlim_get(limit, res);
12464 + if (!__vx_cres_adjust_max(limit, res, value))
12465 + __vx_cres_adjust_min(limit, res, value);
12470 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12472 + if (value + num <= __rlim_soft(limit, res))
12475 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12477 + if (value + num <= __rlim_hard(limit, res))
12480 + __rlim_hit(limit, res);
12485 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12488 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12490 + rlim_t value, sum = 0;
12493 + while ((res = *array++)) {
12494 + value = __rlim_get(limit, res);
12495 + __vx_cres_fixup(limit, res, value);
12502 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12504 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12505 + int res = *array;
12507 + if (value == __rlim_get(limit, res))
12510 + __rlim_set(limit, res, value);
12511 + /* now adjust min/max */
12512 + if (!__vx_cres_adjust_max(limit, res, value))
12513 + __vx_cres_adjust_min(limit, res, value);
12518 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12519 + const int *array, int num, char *_file, int _line)
12521 + struct _vx_limit *limit;
12522 + rlim_t value = 0;
12530 + limit = &vxi->limit;
12532 + value = __vx_cres_array_sum(limit, array + 1);
12534 + __rlim_set(limit, res, value);
12535 + __vx_cres_fixup(limit, res, value);
12537 + return __vx_cres_avail(vxi, res, num, _file, _line);
12541 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12546 + /* complex resources first */
12547 + if ((id < 0) || (id == RLIMIT_RSS))
12548 + __vx_cres_array_fixup(limit, VLA_RSS);
12550 + for (res = 0; res < NUM_LIMITS; res++) {
12551 + if ((id > 0) && (res != id))
12554 + value = __rlim_get(limit, res);
12555 + __vx_cres_fixup(limit, res, value);
12557 + /* not supposed to happen, maybe warn? */
12558 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12559 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12564 +#endif /* __KERNEL__ */
12565 +#endif /* _VX_LIMIT_INT_H */
12566 diff -NurpP --minimal linux-3.6/include/linux/vserver/monitor.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/monitor.h
12567 --- linux-3.6/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12568 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/monitor.h 2012-10-04 18:47:00.000000000 +0200
12570 +#ifndef _VX_MONITOR_H
12571 +#define _VX_MONITOR_H
12573 +#include <linux/types.h>
12580 + VXM_UPDATE = 0x20,
12584 + VXM_RQINFO_1 = 0x24,
12587 + VXM_ACTIVATE = 0x40,
12594 + VXM_MIGRATE = 0x48,
12597 + /* all other bits are flags */
12598 + VXM_SCHED = 0x80,
12601 +struct _vxm_update_1 {
12602 + uint32_t tokens_max;
12603 + uint32_t fill_rate;
12604 + uint32_t interval;
12607 +struct _vxm_update_2 {
12608 + uint32_t tokens_min;
12609 + uint32_t fill_rate;
12610 + uint32_t interval;
12613 +struct _vxm_rqinfo_1 {
12614 + uint16_t running;
12618 + uint32_t idle_tokens;
12621 +struct _vxm_rqinfo_2 {
12622 + uint32_t norm_time;
12623 + uint32_t idle_time;
12624 + uint32_t idle_skip;
12627 +struct _vxm_sched {
12629 + uint32_t norm_time;
12630 + uint32_t idle_time;
12633 +struct _vxm_task {
12638 +struct _vxm_event {
12647 + struct _vxm_task tsk;
12651 +struct _vx_mon_entry {
12655 + struct _vxm_event ev;
12656 + struct _vxm_sched sd;
12657 + struct _vxm_update_1 u1;
12658 + struct _vxm_update_2 u2;
12659 + struct _vxm_rqinfo_1 q1;
12660 + struct _vxm_rqinfo_2 q2;
12665 +#endif /* _VX_MONITOR_H */
12666 diff -NurpP --minimal linux-3.6/include/linux/vserver/network.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/network.h
12667 --- linux-3.6/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12668 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/network.h 2012-10-04 18:47:00.000000000 +0200
12670 +#ifndef _VX_NETWORK_H
12671 +#define _VX_NETWORK_H
12673 +#include <linux/types.h>
12676 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12679 +/* network flags */
12681 +#define NXF_INFO_PRIVATE 0x00000008
12683 +#define NXF_SINGLE_IP 0x00000100
12684 +#define NXF_LBACK_REMAP 0x00000200
12685 +#define NXF_LBACK_ALLOW 0x00000400
12687 +#define NXF_HIDE_NETIF 0x02000000
12688 +#define NXF_HIDE_LBACK 0x04000000
12690 +#define NXF_STATE_SETUP (1ULL << 32)
12691 +#define NXF_STATE_ADMIN (1ULL << 34)
12693 +#define NXF_SC_HELPER (1ULL << 36)
12694 +#define NXF_PERSISTENT (1ULL << 38)
12696 +#define NXF_ONE_TIME (0x0005ULL << 32)
12699 +#define NXF_INIT_SET (__nxf_init_set())
12701 +static inline uint64_t __nxf_init_set(void) {
12702 + return NXF_STATE_ADMIN
12703 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12704 + | NXF_LBACK_REMAP
12707 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12710 + | NXF_HIDE_NETIF;
12714 +/* network caps */
12716 +#define NXC_TUN_CREATE 0x00000001
12718 +#define NXC_RAW_ICMP 0x00000100
12720 +#define NXC_MULTICAST 0x00001000
12723 +/* address types */
12725 +#define NXA_TYPE_IPV4 0x0001
12726 +#define NXA_TYPE_IPV6 0x0002
12728 +#define NXA_TYPE_NONE 0x0000
12729 +#define NXA_TYPE_ANY 0x00FF
12731 +#define NXA_TYPE_ADDR 0x0010
12732 +#define NXA_TYPE_MASK 0x0020
12733 +#define NXA_TYPE_RANGE 0x0040
12735 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12737 +#define NXA_MOD_BCAST 0x0100
12738 +#define NXA_MOD_LBACK 0x0200
12740 +#define NXA_LOOPBACK 0x1000
12742 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12743 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12747 +#include <linux/list.h>
12748 +#include <linux/spinlock.h>
12749 +#include <linux/rcupdate.h>
12750 +#include <linux/in.h>
12751 +#include <linux/in6.h>
12752 +#include <asm/atomic.h>
12754 +struct nx_addr_v4 {
12755 + struct nx_addr_v4 *next;
12756 + struct in_addr ip[2];
12757 + struct in_addr mask;
12762 +struct nx_addr_v6 {
12763 + struct nx_addr_v6 *next;
12764 + struct in6_addr ip;
12765 + struct in6_addr mask;
12772 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12773 + nid_t nx_id; /* vnet id */
12774 + atomic_t nx_usecnt; /* usage count */
12775 + atomic_t nx_tasks; /* tasks count */
12776 + int nx_state; /* context state */
12778 + uint64_t nx_flags; /* network flag word */
12779 + uint64_t nx_ncaps; /* network capabilities */
12781 + struct in_addr v4_lback; /* Loopback address */
12782 + struct in_addr v4_bcast; /* Broadcast address */
12783 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12784 +#ifdef CONFIG_IPV6
12785 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12787 + char nx_name[65]; /* network context name */
12791 +/* status flags */
12793 +#define NXS_HASHED 0x0001
12794 +#define NXS_SHUTDOWN 0x0100
12795 +#define NXS_RELEASED 0x8000
12797 +extern struct nx_info *lookup_nx_info(int);
12799 +extern int get_nid_list(int, unsigned int *, int);
12800 +extern int nid_is_hashed(nid_t);
12802 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12804 +extern long vs_net_change(struct nx_info *, unsigned int);
12809 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12810 +#ifdef CONFIG_IPV6
12811 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12813 +#define NX_IPV6(n) (0)
12816 +#endif /* __KERNEL__ */
12817 +#endif /* _VX_NETWORK_H */
12818 diff -NurpP --minimal linux-3.6/include/linux/vserver/network_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/network_cmd.h
12819 --- linux-3.6/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12820 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/network_cmd.h 2012-10-04 18:47:00.000000000 +0200
12822 +#ifndef _VX_NETWORK_CMD_H
12823 +#define _VX_NETWORK_CMD_H
12826 +/* vinfo commands */
12828 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12831 +extern int vc_task_nid(uint32_t);
12833 +#endif /* __KERNEL__ */
12835 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12837 +struct vcmd_nx_info_v0 {
12839 + /* more to come */
12843 +extern int vc_nx_info(struct nx_info *, void __user *);
12845 +#endif /* __KERNEL__ */
12847 +#include <linux/in.h>
12848 +#include <linux/in6.h>
12850 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12851 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12853 +struct vcmd_net_create {
12854 + uint64_t flagword;
12857 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12859 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12860 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12862 +struct vcmd_net_addr_v0 {
12865 + struct in_addr ip[4];
12866 + struct in_addr mask[4];
12869 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
12870 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
12872 +struct vcmd_net_addr_ipv4_v1 {
12875 + struct in_addr ip;
12876 + struct in_addr mask;
12879 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
12880 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
12882 +struct vcmd_net_addr_ipv4_v2 {
12885 + struct in_addr ip;
12886 + struct in_addr ip2;
12887 + struct in_addr mask;
12890 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12891 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12893 +struct vcmd_net_addr_ipv6_v1 {
12897 + struct in6_addr ip;
12898 + struct in6_addr mask;
12901 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12902 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12904 +struct vcmd_match_ipv4_v0 {
12909 + struct in_addr ip;
12910 + struct in_addr ip2;
12911 + struct in_addr mask;
12914 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12915 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12917 +struct vcmd_match_ipv6_v0 {
12922 + struct in6_addr ip;
12923 + struct in6_addr ip2;
12924 + struct in6_addr mask;
12929 +extern int vc_net_create(uint32_t, void __user *);
12930 +extern int vc_net_migrate(struct nx_info *, void __user *);
12932 +extern int vc_net_add(struct nx_info *, void __user *);
12933 +extern int vc_net_remove(struct nx_info *, void __user *);
12935 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
12936 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12938 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
12939 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
12941 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12942 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12944 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12945 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12947 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12948 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12950 +#endif /* __KERNEL__ */
12953 +/* flag commands */
12955 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12956 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12958 +struct vcmd_net_flags_v0 {
12959 + uint64_t flagword;
12964 +extern int vc_get_nflags(struct nx_info *, void __user *);
12965 +extern int vc_set_nflags(struct nx_info *, void __user *);
12967 +#endif /* __KERNEL__ */
12970 +/* network caps commands */
12972 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12973 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12975 +struct vcmd_net_caps_v0 {
12981 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12982 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12984 +#endif /* __KERNEL__ */
12985 +#endif /* _VX_CONTEXT_CMD_H */
12986 diff -NurpP --minimal linux-3.6/include/linux/vserver/percpu.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/percpu.h
12987 --- linux-3.6/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12988 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/percpu.h 2012-10-04 18:47:00.000000000 +0200
12990 +#ifndef _VX_PERCPU_H
12991 +#define _VX_PERCPU_H
12993 +#include "cvirt_def.h"
12994 +#include "sched_def.h"
12996 +struct _vx_percpu {
12997 + struct _vx_cvirt_pc cvirt;
12998 + struct _vx_sched_pc sched;
13001 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13003 +#endif /* _VX_PERCPU_H */
13004 diff -NurpP --minimal linux-3.6/include/linux/vserver/pid.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/pid.h
13005 --- linux-3.6/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
13006 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/pid.h 2012-10-04 18:47:00.000000000 +0200
13008 +#ifndef _VSERVER_PID_H
13009 +#define _VSERVER_PID_H
13011 +/* pid faking stuff */
13013 +#define vx_info_map_pid(v, p) \
13014 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13015 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13016 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13017 +#define vx_map_tgid(p) vx_map_pid(p)
13019 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13020 + const char *func, const char *file, int line)
13022 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13023 + vxfprintk(VXD_CBIT(cvirt, 2),
13024 + "vx_map_tgid: %p/%llx: %d -> %d",
13025 + vxi, (long long)vxi->vx_flags, pid,
13026 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13027 + func, file, line);
13030 + if (pid == vxi->vx_initpid)
13036 +#define vx_info_rmap_pid(v, p) \
13037 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
13038 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
13039 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13041 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13042 + const char *func, const char *file, int line)
13044 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13045 + vxfprintk(VXD_CBIT(cvirt, 2),
13046 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13047 + vxi, (long long)vxi->vx_flags, pid,
13048 + (pid == 1) ? vxi->vx_initpid : pid,
13049 + func, file, line);
13050 + if ((pid == 1) && vxi->vx_initpid)
13051 + return vxi->vx_initpid;
13052 + if (pid == vxi->vx_initpid)
13059 diff -NurpP --minimal linux-3.6/include/linux/vserver/sched.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/sched.h
13060 --- linux-3.6/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13061 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/sched.h 2012-10-04 18:47:00.000000000 +0200
13063 +#ifndef _VX_SCHED_H
13064 +#define _VX_SCHED_H
13071 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13076 +void vx_update_load(struct vx_info *);
13079 +void vx_update_sched_param(struct _vx_sched *sched,
13080 + struct _vx_sched_pc *sched_pc);
13082 +#endif /* __KERNEL__ */
13083 +#else /* _VX_SCHED_H */
13084 +#warning duplicate inclusion
13085 +#endif /* _VX_SCHED_H */
13086 diff -NurpP --minimal linux-3.6/include/linux/vserver/sched_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/sched_cmd.h
13087 --- linux-3.6/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
13088 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/sched_cmd.h 2012-10-04 18:47:00.000000000 +0200
13090 +#ifndef _VX_SCHED_CMD_H
13091 +#define _VX_SCHED_CMD_H
13094 +struct vcmd_prio_bias {
13096 + int32_t prio_bias;
13099 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13100 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13104 +#include <linux/compiler.h>
13106 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
13107 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
13109 +#endif /* __KERNEL__ */
13110 +#endif /* _VX_SCHED_CMD_H */
13111 diff -NurpP --minimal linux-3.6/include/linux/vserver/sched_def.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/sched_def.h
13112 --- linux-3.6/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
13113 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/sched_def.h 2012-10-04 18:47:00.000000000 +0200
13115 +#ifndef _VX_SCHED_DEF_H
13116 +#define _VX_SCHED_DEF_H
13118 +#include <linux/spinlock.h>
13119 +#include <linux/jiffies.h>
13120 +#include <linux/cpumask.h>
13121 +#include <asm/atomic.h>
13122 +#include <asm/param.h>
13125 +/* context sub struct */
13127 +struct _vx_sched {
13128 + int prio_bias; /* bias offset for priority */
13130 + cpumask_t update; /* CPUs which should update */
13133 +struct _vx_sched_pc {
13134 + int prio_bias; /* bias offset for priority */
13136 + uint64_t user_ticks; /* token tick events */
13137 + uint64_t sys_ticks; /* token tick events */
13138 + uint64_t hold_ticks; /* token ticks paused */
13142 +#ifdef CONFIG_VSERVER_DEBUG
13144 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13146 + printk("\t_vx_sched:\n");
13147 + printk("\t priority = %4d\n", sched->prio_bias);
13152 +#endif /* _VX_SCHED_DEF_H */
13153 diff -NurpP --minimal linux-3.6/include/linux/vserver/signal.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/signal.h
13154 --- linux-3.6/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13155 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/signal.h 2012-10-04 18:47:00.000000000 +0200
13157 +#ifndef _VX_SIGNAL_H
13158 +#define _VX_SIGNAL_H
13165 +int vx_info_kill(struct vx_info *, int, int);
13167 +#endif /* __KERNEL__ */
13168 +#else /* _VX_SIGNAL_H */
13169 +#warning duplicate inclusion
13170 +#endif /* _VX_SIGNAL_H */
13171 diff -NurpP --minimal linux-3.6/include/linux/vserver/signal_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/signal_cmd.h
13172 --- linux-3.6/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13173 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/signal_cmd.h 2012-10-04 18:47:00.000000000 +0200
13175 +#ifndef _VX_SIGNAL_CMD_H
13176 +#define _VX_SIGNAL_CMD_H
13179 +/* signalling vserver commands */
13181 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13182 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13184 +struct vcmd_ctx_kill_v0 {
13189 +struct vcmd_wait_exit_v0 {
13190 + int32_t reboot_cmd;
13191 + int32_t exit_code;
13196 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13197 +extern int vc_wait_exit(struct vx_info *, void __user *);
13199 +#endif /* __KERNEL__ */
13201 +/* process alteration commands */
13203 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13204 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13206 +struct vcmd_pflags_v0 {
13207 + uint32_t flagword;
13213 +extern int vc_get_pflags(uint32_t pid, void __user *);
13214 +extern int vc_set_pflags(uint32_t pid, void __user *);
13216 +#endif /* __KERNEL__ */
13217 +#endif /* _VX_SIGNAL_CMD_H */
13218 diff -NurpP --minimal linux-3.6/include/linux/vserver/space.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/space.h
13219 --- linux-3.6/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13220 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/space.h 2012-10-04 18:47:00.000000000 +0200
13222 +#ifndef _VX_SPACE_H
13223 +#define _VX_SPACE_H
13225 +#include <linux/types.h>
13229 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13231 +#else /* _VX_SPACE_H */
13232 +#warning duplicate inclusion
13233 +#endif /* _VX_SPACE_H */
13234 diff -NurpP --minimal linux-3.6/include/linux/vserver/space_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/space_cmd.h
13235 --- linux-3.6/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13236 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/space_cmd.h 2012-10-04 18:47:00.000000000 +0200
13238 +#ifndef _VX_SPACE_CMD_H
13239 +#define _VX_SPACE_CMD_H
13242 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13243 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13244 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13246 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13247 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13248 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13250 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13252 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13253 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13256 +struct vcmd_space_mask_v1 {
13260 +struct vcmd_space_mask_v2 {
13268 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13269 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13270 +extern int vc_enter_space(struct vx_info *, void __user *);
13271 +extern int vc_set_space(struct vx_info *, void __user *);
13272 +extern int vc_get_space_mask(void __user *, int);
13274 +#endif /* __KERNEL__ */
13275 +#endif /* _VX_SPACE_CMD_H */
13276 diff -NurpP --minimal linux-3.6/include/linux/vserver/switch.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/switch.h
13277 --- linux-3.6/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13278 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/switch.h 2012-10-04 18:47:00.000000000 +0200
13280 +#ifndef _VX_SWITCH_H
13281 +#define _VX_SWITCH_H
13283 +#include <linux/types.h>
13286 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13287 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13288 +#define VC_VERSION(c) ((c) & 0xFFF)
13290 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13291 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13295 + Syscall Matrix V2.8
13297 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13298 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13299 + |INFO |SETUP | |MOVE | | | | | |
13300 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13301 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13302 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13303 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13304 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13305 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13306 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13307 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13308 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13309 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13310 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13311 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13312 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13313 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13314 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13315 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13316 + OTHER |VSTAT | | | | | | |VINFO | |
13317 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13318 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13319 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13320 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13321 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13322 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13323 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13324 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13328 +#define VC_CAT_VERSION 0
13330 +#define VC_CAT_VSETUP 1
13331 +#define VC_CAT_VHOST 2
13333 +#define VC_CAT_DEVICE 6
13335 +#define VC_CAT_VPROC 9
13336 +#define VC_CAT_PROCALT 10
13337 +#define VC_CAT_PROCMIG 11
13338 +#define VC_CAT_PROCTRL 12
13340 +#define VC_CAT_SCHED 14
13341 +#define VC_CAT_MEMCTRL 20
13343 +#define VC_CAT_VNET 25
13344 +#define VC_CAT_NETALT 26
13345 +#define VC_CAT_NETMIG 27
13346 +#define VC_CAT_NETCTRL 28
13348 +#define VC_CAT_TAGMIG 35
13349 +#define VC_CAT_DLIMIT 36
13350 +#define VC_CAT_INODE 38
13352 +#define VC_CAT_VSTAT 40
13353 +#define VC_CAT_VINFO 46
13354 +#define VC_CAT_EVENT 48
13356 +#define VC_CAT_FLAGS 52
13357 +#define VC_CAT_VSPACE 54
13358 +#define VC_CAT_DEBUG 56
13359 +#define VC_CAT_RLIMIT 60
13361 +#define VC_CAT_SYSTEST 61
13362 +#define VC_CAT_COMPAT 63
13364 +/* query version */
13366 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13367 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13372 +#include <linux/errno.h>
13374 +#endif /* __KERNEL__ */
13376 +#endif /* _VX_SWITCH_H */
13378 diff -NurpP --minimal linux-3.6/include/linux/vserver/tag.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/tag.h
13379 --- linux-3.6/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13380 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/tag.h 2012-10-04 18:47:00.000000000 +0200
13385 +#include <linux/types.h>
13388 +#define DX_TAG(in) (IS_TAGGED(in))
13391 +#ifdef CONFIG_TAG_NFSD
13392 +#define DX_TAG_NFSD 1
13394 +#define DX_TAG_NFSD 0
13398 +#ifdef CONFIG_TAGGING_NONE
13400 +#define MAX_UID 0xFFFFFFFF
13401 +#define MAX_GID 0xFFFFFFFF
13403 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13405 +#define TAGINO_UID(cond, uid, tag) (uid)
13406 +#define TAGINO_GID(cond, gid, tag) (gid)
13411 +#ifdef CONFIG_TAGGING_GID16
13413 +#define MAX_UID 0xFFFFFFFF
13414 +#define MAX_GID 0x0000FFFF
13416 +#define INOTAG_TAG(cond, uid, gid, tag) \
13417 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13419 +#define TAGINO_UID(cond, uid, tag) (uid)
13420 +#define TAGINO_GID(cond, gid, tag) \
13421 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13426 +#ifdef CONFIG_TAGGING_ID24
13428 +#define MAX_UID 0x00FFFFFF
13429 +#define MAX_GID 0x00FFFFFF
13431 +#define INOTAG_TAG(cond, uid, gid, tag) \
13432 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13434 +#define TAGINO_UID(cond, uid, tag) \
13435 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13436 +#define TAGINO_GID(cond, gid, tag) \
13437 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13442 +#ifdef CONFIG_TAGGING_UID16
13444 +#define MAX_UID 0x0000FFFF
13445 +#define MAX_GID 0xFFFFFFFF
13447 +#define INOTAG_TAG(cond, uid, gid, tag) \
13448 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13450 +#define TAGINO_UID(cond, uid, tag) \
13451 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13452 +#define TAGINO_GID(cond, gid, tag) (gid)
13457 +#ifdef CONFIG_TAGGING_INTERN
13459 +#define MAX_UID 0xFFFFFFFF
13460 +#define MAX_GID 0xFFFFFFFF
13462 +#define INOTAG_TAG(cond, uid, gid, tag) \
13463 + ((cond) ? (tag) : 0)
13465 +#define TAGINO_UID(cond, uid, tag) (uid)
13466 +#define TAGINO_GID(cond, gid, tag) (gid)
13471 +#ifndef CONFIG_TAGGING_NONE
13472 +#define dx_current_fstag(sb) \
13473 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13475 +#define dx_current_fstag(sb) (0)
13478 +#ifndef CONFIG_TAGGING_INTERN
13479 +#define TAGINO_TAG(cond, tag) (0)
13481 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13484 +#define INOTAG_UID(cond, uid, gid) \
13485 + ((cond) ? ((uid) & MAX_UID) : (uid))
13486 +#define INOTAG_GID(cond, uid, gid) \
13487 + ((cond) ? ((gid) & MAX_GID) : (gid))
13490 +static inline uid_t dx_map_uid(uid_t uid)
13492 + if ((uid > MAX_UID) && (uid != -1))
13494 + return (uid & MAX_UID);
13497 +static inline gid_t dx_map_gid(gid_t gid)
13499 + if ((gid > MAX_GID) && (gid != -1))
13501 + return (gid & MAX_GID);
13509 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13511 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13512 + unsigned long *flags);
13514 +#ifdef CONFIG_PROPAGATE
13516 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13518 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13521 +#define dx_propagate_tag(n, i) do { } while (0)
13524 +#endif /* _DX_TAG_H */
13525 diff -NurpP --minimal linux-3.6/include/linux/vserver/tag_cmd.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/tag_cmd.h
13526 --- linux-3.6/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13527 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/linux/vserver/tag_cmd.h 2012-10-04 18:47:00.000000000 +0200
13529 +#ifndef _VX_TAG_CMD_H
13530 +#define _VX_TAG_CMD_H
13533 +/* vinfo commands */
13535 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13538 +extern int vc_task_tag(uint32_t);
13540 +#endif /* __KERNEL__ */
13542 +/* context commands */
13544 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13547 +extern int vc_tag_migrate(uint32_t);
13549 +#endif /* __KERNEL__ */
13550 +#endif /* _VX_TAG_CMD_H */
13551 diff -NurpP --minimal linux-3.6/include/net/addrconf.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/net/addrconf.h
13552 --- linux-3.6/include/net/addrconf.h 2012-10-04 15:27:47.000000000 +0200
13553 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/net/addrconf.h 2012-10-04 18:47:00.000000000 +0200
13554 @@ -81,7 +81,8 @@ extern int ipv6_dev_get_saddr(struct n
13555 struct net_device *dev,
13556 const struct in6_addr *daddr,
13557 unsigned int srcprefs,
13558 - struct in6_addr *saddr);
13559 + struct in6_addr *saddr,
13560 + struct nx_info *nxi);
13561 extern int ipv6_get_lladdr(struct net_device *dev,
13562 struct in6_addr *addr,
13563 unsigned char banned_flags);
13564 diff -NurpP --minimal linux-3.6/include/net/af_unix.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/net/af_unix.h
13565 --- linux-3.6/include/net/af_unix.h 2012-10-04 15:27:47.000000000 +0200
13566 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/net/af_unix.h 2012-10-04 18:47:00.000000000 +0200
13568 #include <linux/socket.h>
13569 #include <linux/un.h>
13570 #include <linux/mutex.h>
13571 +#include <linux/vs_base.h>
13572 #include <net/sock.h>
13574 extern void unix_inflight(struct file *fp);
13575 diff -NurpP --minimal linux-3.6/include/net/inet_timewait_sock.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/net/inet_timewait_sock.h
13576 --- linux-3.6/include/net/inet_timewait_sock.h 2012-03-19 19:47:29.000000000 +0100
13577 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/net/inet_timewait_sock.h 2012-10-04 18:47:00.000000000 +0200
13578 @@ -112,6 +112,10 @@ struct inet_timewait_sock {
13579 #define tw_net __tw_common.skc_net
13580 #define tw_daddr __tw_common.skc_daddr
13581 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
13582 +#define tw_xid __tw_common.skc_xid
13583 +#define tw_vx_info __tw_common.skc_vx_info
13584 +#define tw_nid __tw_common.skc_nid
13585 +#define tw_nx_info __tw_common.skc_nx_info
13587 volatile unsigned char tw_substate;
13588 unsigned char tw_rcv_wscale;
13589 diff -NurpP --minimal linux-3.6/include/net/ip6_route.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/net/ip6_route.h
13590 --- linux-3.6/include/net/ip6_route.h 2012-10-04 15:27:47.000000000 +0200
13591 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/net/ip6_route.h 2012-10-04 18:47:00.000000000 +0200
13592 @@ -97,7 +97,8 @@ extern int ip6_route_get_saddr(struct
13593 struct rt6_info *rt,
13594 const struct in6_addr *daddr,
13595 unsigned int prefs,
13596 - struct in6_addr *saddr);
13597 + struct in6_addr *saddr,
13598 + struct nx_info *nxi);
13600 extern struct rt6_info *rt6_lookup(struct net *net,
13601 const struct in6_addr *daddr,
13602 diff -NurpP --minimal linux-3.6/include/net/route.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/net/route.h
13603 --- linux-3.6/include/net/route.h 2012-10-04 15:27:47.000000000 +0200
13604 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/net/route.h 2012-10-04 18:47:00.000000000 +0200
13605 @@ -203,6 +203,9 @@ static inline void ip_rt_put(struct rtab
13606 dst_release(&rt->dst);
13609 +#include <linux/vs_base.h>
13610 +#include <linux/vs_inet.h>
13612 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
13614 extern const __u8 ip_tos2prio[16];
13615 @@ -252,6 +255,9 @@ static inline void ip_route_connect_init
13616 protocol, flow_flags, dst, src, dport, sport);
13619 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
13620 + struct flowi4 *);
13622 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
13623 __be32 dst, __be32 src, u32 tos,
13624 int oif, u8 protocol,
13625 @@ -260,11 +266,25 @@ static inline struct rtable *ip_route_co
13627 struct net *net = sock_net(sk);
13629 + struct nx_info *nx_info = current_nx_info();
13631 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
13632 sport, dport, sk, can_sleep);
13634 - if (!dst || !src) {
13636 + nx_info = sk->sk_nx_info;
13638 + vxdprintk(VXD_CBIT(net, 4),
13639 + "ip_route_connect(%p) %p,%p;%lx",
13640 + sk, nx_info, sk->sk_socket,
13641 + (sk->sk_socket?sk->sk_socket->flags:0));
13643 + rt = ip_v4_find_src(net, nx_info, fl4);
13648 + if (!fl4->daddr || !fl4->saddr) {
13649 rt = __ip_route_output_key(net, fl4);
13652 diff -NurpP --minimal linux-3.6/include/net/sock.h linux-3.6-vs2.3.4.3-noxfs-nocow/include/net/sock.h
13653 --- linux-3.6/include/net/sock.h 2012-10-04 15:27:47.000000000 +0200
13654 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/include/net/sock.h 2012-10-04 18:47:00.000000000 +0200
13655 @@ -171,6 +171,10 @@ struct sock_common {
13656 #ifdef CONFIG_NET_NS
13657 struct net *skc_net;
13660 + struct vx_info *skc_vx_info;
13662 + struct nx_info *skc_nx_info;
13664 * fields between dontcopy_begin/dontcopy_end
13665 * are not copied in sock_copy()
13666 @@ -284,6 +288,10 @@ struct sock {
13667 #define sk_bind_node __sk_common.skc_bind_node
13668 #define sk_prot __sk_common.skc_prot
13669 #define sk_net __sk_common.skc_net
13670 +#define sk_xid __sk_common.skc_xid
13671 +#define sk_vx_info __sk_common.skc_vx_info
13672 +#define sk_nid __sk_common.skc_nid
13673 +#define sk_nx_info __sk_common.skc_nx_info
13674 socket_lock_t sk_lock;
13675 struct sk_buff_head sk_receive_queue;
13677 diff -NurpP --minimal linux-3.6/init/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/init/Kconfig
13678 --- linux-3.6/init/Kconfig 2012-10-04 15:27:48.000000000 +0200
13679 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/init/Kconfig 2012-10-04 18:47:00.000000000 +0200
13680 @@ -624,6 +624,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
13682 boolean "Control Group support"
13686 This option adds support for grouping sets of processes together, for
13687 use with process control subsystems such as Cpusets, CFS, memory
13688 @@ -889,6 +890,7 @@ config USER_NS
13689 bool "User namespace (EXPERIMENTAL)"
13690 depends on EXPERIMENTAL
13691 depends on UIDGID_CONVERTED
13692 + depends on VSERVER_DISABLED
13693 select UIDGID_STRICT_TYPE_CHECKS
13696 diff -NurpP --minimal linux-3.6/init/main.c linux-3.6-vs2.3.4.3-noxfs-nocow/init/main.c
13697 --- linux-3.6/init/main.c 2012-10-04 15:27:48.000000000 +0200
13698 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/init/main.c 2012-10-04 18:51:41.000000000 +0200
13700 #include <linux/slab.h>
13701 #include <linux/perf_event.h>
13702 #include <linux/file.h>
13703 +#include <linux/vserver/percpu.h>
13705 #include <asm/io.h>
13706 #include <asm/bugs.h>
13707 diff -NurpP --minimal linux-3.6/ipc/mqueue.c linux-3.6-vs2.3.4.3-noxfs-nocow/ipc/mqueue.c
13708 --- linux-3.6/ipc/mqueue.c 2012-10-04 15:27:48.000000000 +0200
13709 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/ipc/mqueue.c 2012-10-04 18:47:00.000000000 +0200
13711 #include <linux/ipc_namespace.h>
13712 #include <linux/user_namespace.h>
13713 #include <linux/slab.h>
13714 +#include <linux/vs_context.h>
13715 +#include <linux/vs_limit.h>
13717 #include <net/sock.h>
13719 @@ -76,6 +78,7 @@ struct mqueue_inode_info {
13720 struct pid* notify_owner;
13721 struct user_namespace *notify_user_ns;
13722 struct user_struct *user; /* user who created, for accounting */
13723 + struct vx_info *vxi;
13724 struct sock *notify_sock;
13725 struct sk_buff *notify_cookie;
13727 @@ -235,6 +238,7 @@ static struct inode *mqueue_get_inode(st
13728 if (S_ISREG(mode)) {
13729 struct mqueue_inode_info *info;
13730 unsigned long mq_bytes, mq_treesize;
13731 + struct vx_info *vxi = current_vx_info();
13733 inode->i_fop = &mqueue_file_operations;
13734 inode->i_size = FILENT_SIZE;
13735 @@ -248,6 +252,7 @@ static struct inode *mqueue_get_inode(st
13736 info->notify_user_ns = NULL;
13738 info->user = NULL; /* set when all is ok */
13739 + info->vxi = NULL;
13740 info->msg_tree = RB_ROOT;
13741 info->node_cache = NULL;
13742 memset(&info->attr, 0, sizeof(info->attr));
13743 @@ -281,17 +286,20 @@ static struct inode *mqueue_get_inode(st
13745 spin_lock(&mq_lock);
13746 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
13747 - u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
13748 + u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE) ||
13749 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
13750 spin_unlock(&mq_lock);
13751 /* mqueue_evict_inode() releases info->messages */
13755 u->mq_bytes += mq_bytes;
13756 + vx_ipcmsg_add(vxi, u, mq_bytes);
13757 spin_unlock(&mq_lock);
13760 info->user = get_uid(u);
13761 + info->vxi = get_vx_info(vxi);
13762 } else if (S_ISDIR(mode)) {
13764 /* Some things misbehave if size == 0 on a directory */
13765 @@ -395,8 +403,11 @@ static void mqueue_evict_inode(struct in
13769 + struct vx_info *vxi = info->vxi;
13771 spin_lock(&mq_lock);
13772 user->mq_bytes -= mq_bytes;
13773 + vx_ipcmsg_sub(vxi, user, mq_bytes);
13775 * get_ns_from_inode() ensures that the
13776 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
13777 @@ -406,6 +417,7 @@ static void mqueue_evict_inode(struct in
13779 ipc_ns->mq_queues_count--;
13780 spin_unlock(&mq_lock);
13781 + put_vx_info(vxi);
13785 diff -NurpP --minimal linux-3.6/ipc/msg.c linux-3.6-vs2.3.4.3-noxfs-nocow/ipc/msg.c
13786 --- linux-3.6/ipc/msg.c 2011-05-22 16:17:59.000000000 +0200
13787 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/ipc/msg.c 2012-10-04 18:47:00.000000000 +0200
13789 #include <linux/rwsem.h>
13790 #include <linux/nsproxy.h>
13791 #include <linux/ipc_namespace.h>
13792 +#include <linux/vs_base.h>
13794 #include <asm/current.h>
13795 #include <asm/uaccess.h>
13796 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
13798 msq->q_perm.mode = msgflg & S_IRWXUGO;
13799 msq->q_perm.key = key;
13800 + msq->q_perm.xid = vx_current_xid();
13802 msq->q_perm.security = NULL;
13803 retval = security_msg_queue_alloc(msq);
13804 diff -NurpP --minimal linux-3.6/ipc/namespace.c linux-3.6-vs2.3.4.3-noxfs-nocow/ipc/namespace.c
13805 --- linux-3.6/ipc/namespace.c 2012-07-22 23:39:46.000000000 +0200
13806 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/ipc/namespace.c 2012-10-04 18:47:00.000000000 +0200
13807 @@ -13,11 +13,12 @@
13808 #include <linux/mount.h>
13809 #include <linux/user_namespace.h>
13810 #include <linux/proc_fs.h>
13811 +#include <linux/vs_base.h>
13812 +#include <linux/vserver/global.h>
13816 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
13817 - struct ipc_namespace *old_ns)
13818 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
13820 struct ipc_namespace *ns;
13822 @@ -46,19 +47,19 @@ static struct ipc_namespace *create_ipc_
13823 ipcns_notify(IPCNS_CREATED);
13824 register_ipcns_notifier(ns);
13826 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user_ns));
13827 + // ns->user_ns = get_user_ns(task_cred_xxx(tsk, user_ns));
13828 + ns->user_ns = get_user_ns(user_ns);
13833 struct ipc_namespace *copy_ipcs(unsigned long flags,
13834 - struct task_struct *tsk)
13835 + struct ipc_namespace *old_ns,
13836 + struct user_namespace *user_ns)
13838 - struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
13840 if (!(flags & CLONE_NEWIPC))
13841 - return get_ipc_ns(ns);
13842 - return create_ipc_ns(tsk, ns);
13843 + return get_ipc_ns(old_ns);
13844 + return create_ipc_ns(user_ns);
13848 diff -NurpP --minimal linux-3.6/ipc/sem.c linux-3.6-vs2.3.4.3-noxfs-nocow/ipc/sem.c
13849 --- linux-3.6/ipc/sem.c 2012-01-09 16:14:59.000000000 +0100
13850 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/ipc/sem.c 2012-10-04 18:47:00.000000000 +0200
13852 #include <linux/rwsem.h>
13853 #include <linux/nsproxy.h>
13854 #include <linux/ipc_namespace.h>
13855 +#include <linux/vs_base.h>
13856 +#include <linux/vs_limit.h>
13858 #include <asm/uaccess.h>
13860 @@ -306,6 +308,7 @@ static int newary(struct ipc_namespace *
13862 sma->sem_perm.mode = (semflg & S_IRWXUGO);
13863 sma->sem_perm.key = key;
13864 + sma->sem_perm.xid = vx_current_xid();
13866 sma->sem_perm.security = NULL;
13867 retval = security_sem_alloc(sma);
13868 @@ -321,6 +324,9 @@ static int newary(struct ipc_namespace *
13871 ns->used_sems += nsems;
13872 + /* FIXME: obsoleted? */
13873 + vx_semary_inc(sma);
13874 + vx_nsems_add(sma, nsems);
13876 sma->sem_base = (struct sem *) &sma[1];
13878 @@ -770,6 +776,9 @@ static void freeary(struct ipc_namespace
13880 wake_up_sem_queue_do(&tasks);
13881 ns->used_sems -= sma->sem_nsems;
13882 + /* FIXME: obsoleted? */
13883 + vx_nsems_sub(sma, sma->sem_nsems);
13884 + vx_semary_dec(sma);
13885 security_sem_free(sma);
13886 ipc_rcu_putref(sma);
13888 diff -NurpP --minimal linux-3.6/ipc/shm.c linux-3.6-vs2.3.4.3-noxfs-nocow/ipc/shm.c
13889 --- linux-3.6/ipc/shm.c 2012-10-04 15:27:48.000000000 +0200
13890 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/ipc/shm.c 2012-10-04 18:47:00.000000000 +0200
13892 #include <linux/nsproxy.h>
13893 #include <linux/mount.h>
13894 #include <linux/ipc_namespace.h>
13895 +#include <linux/vs_context.h>
13896 +#include <linux/vs_limit.h>
13898 #include <asm/uaccess.h>
13900 @@ -187,7 +189,12 @@ static void shm_open(struct vm_area_stru
13902 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
13904 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
13905 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
13906 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
13908 + vx_ipcshm_sub(vxi, shp, numpages);
13909 + ns->shm_tot -= numpages;
13913 if (!is_file_hugepages(shp->shm_file))
13914 @@ -197,6 +204,7 @@ static void shm_destroy(struct ipc_names
13916 fput (shp->shm_file);
13917 security_shm_free(shp);
13918 + put_vx_info(vxi);
13919 ipc_rcu_putref(shp);
13922 @@ -474,11 +482,15 @@ static int newseg(struct ipc_namespace *
13923 if (ns->shm_tot + numpages > ns->shm_ctlall)
13926 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
13929 shp = ipc_rcu_alloc(sizeof(*shp));
13933 shp->shm_perm.key = key;
13934 + shp->shm_perm.xid = vx_current_xid();
13935 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
13936 shp->mlock_user = NULL;
13938 @@ -533,6 +545,7 @@ static int newseg(struct ipc_namespace *
13939 ns->shm_tot += numpages;
13940 error = shp->shm_perm.id;
13942 + vx_ipcshm_add(current_vx_info(), key, numpages);
13946 diff -NurpP --minimal linux-3.6/kernel/Makefile linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/Makefile
13947 --- linux-3.6/kernel/Makefile 2012-07-22 23:39:46.000000000 +0200
13948 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/Makefile 2012-10-04 18:47:00.000000000 +0200
13949 @@ -24,6 +24,7 @@ endif
13955 ifeq ($(CONFIG_CHECKPOINT_RESTORE),y)
13956 obj-$(CONFIG_X86) += kcmp.o
13957 diff -NurpP --minimal linux-3.6/kernel/auditsc.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/auditsc.c
13958 --- linux-3.6/kernel/auditsc.c 2012-07-22 23:39:46.000000000 +0200
13959 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/auditsc.c 2012-10-04 18:47:00.000000000 +0200
13960 @@ -2309,7 +2309,7 @@ int audit_set_loginuid(uid_t loginuid)
13961 if (task->loginuid != -1)
13963 #else /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
13964 - if (!capable(CAP_AUDIT_CONTROL))
13965 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
13967 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
13969 diff -NurpP --minimal linux-3.6/kernel/capability.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/capability.c
13970 --- linux-3.6/kernel/capability.c 2012-07-22 23:39:46.000000000 +0200
13971 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/capability.c 2012-10-04 18:47:00.000000000 +0200
13973 #include <linux/syscalls.h>
13974 #include <linux/pid_namespace.h>
13975 #include <linux/user_namespace.h>
13976 +#include <linux/vs_context.h>
13977 #include <asm/uaccess.h>
13980 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
13986 * The only thing that can change the capabilities of the current
13987 * process is the current process. As such, we can't be in this code
13988 @@ -349,6 +351,8 @@ bool has_ns_capability_noaudit(struct ta
13992 +#include <linux/vserver/base.h>
13995 * has_capability_noaudit - Does a task have a capability (unaudited) in the
13997 diff -NurpP --minimal linux-3.6/kernel/compat.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/compat.c
13998 --- linux-3.6/kernel/compat.c 2012-07-22 23:39:46.000000000 +0200
13999 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/compat.c 2012-10-04 18:47:00.000000000 +0200
14000 @@ -1054,7 +1054,7 @@ asmlinkage long compat_sys_stime(compat_
14004 - do_settimeofday(&tv);
14005 + vx_settimeofday(&tv);
14009 diff -NurpP --minimal linux-3.6/kernel/cred.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/cred.c
14010 --- linux-3.6/kernel/cred.c 2012-07-22 23:39:46.000000000 +0200
14011 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/cred.c 2012-10-04 18:47:00.000000000 +0200
14012 @@ -70,31 +70,6 @@ struct cred init_cred = {
14016 -static inline void set_cred_subscribers(struct cred *cred, int n)
14018 -#ifdef CONFIG_DEBUG_CREDENTIALS
14019 - atomic_set(&cred->subscribers, n);
14023 -static inline int read_cred_subscribers(const struct cred *cred)
14025 -#ifdef CONFIG_DEBUG_CREDENTIALS
14026 - return atomic_read(&cred->subscribers);
14032 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14034 -#ifdef CONFIG_DEBUG_CREDENTIALS
14035 - struct cred *cred = (struct cred *) _cred;
14037 - atomic_add(n, &cred->subscribers);
14042 * Dispose of the shared task group credentials
14044 @@ -284,21 +259,16 @@ error:
14046 * Call commit_creds() or abort_creds() to clean up.
14048 -struct cred *prepare_creds(void)
14049 +struct cred *__prepare_creds(const struct cred *old)
14051 - struct task_struct *task = current;
14052 - const struct cred *old;
14055 - validate_process_creds();
14057 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14061 kdebug("prepare_creds() alloc %p", new);
14063 - old = task->cred;
14064 memcpy(new, old, sizeof(struct cred));
14066 atomic_set(&new->usage, 1);
14067 @@ -326,6 +296,13 @@ error:
14072 +struct cred *prepare_creds(void)
14074 + validate_process_creds();
14076 + return __prepare_creds(current->cred);
14078 EXPORT_SYMBOL(prepare_creds);
14081 diff -NurpP --minimal linux-3.6/kernel/exit.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/exit.c
14082 --- linux-3.6/kernel/exit.c 2012-10-04 15:27:48.000000000 +0200
14083 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/exit.c 2012-10-04 18:47:00.000000000 +0200
14085 #include <linux/fs_struct.h>
14086 #include <linux/init_task.h>
14087 #include <linux/perf_event.h>
14088 +#include <linux/vs_limit.h>
14089 +#include <linux/vs_context.h>
14090 +#include <linux/vs_network.h>
14091 +#include <linux/vs_pid.h>
14092 #include <trace/events/sched.h>
14093 #include <linux/hw_breakpoint.h>
14094 #include <linux/oom.h>
14095 @@ -494,9 +498,11 @@ static void close_files(struct files_str
14096 filp_close(file, files);
14099 + vx_openfd_dec(i);
14107 @@ -1018,6 +1024,9 @@ void do_exit(long code)
14109 ptrace_put_breakpoints(tsk);
14111 + /* needs to stay before exit_notify() */
14112 + exit_vx_info_early(tsk, code);
14114 exit_notify(tsk, group_dead);
14117 @@ -1068,10 +1077,15 @@ void do_exit(long code)
14119 raw_spin_unlock_wait(&tsk->pi_lock);
14121 + /* needs to stay after exit_notify() */
14122 + exit_vx_info(tsk, code);
14123 + exit_nx_info(tsk);
14125 /* causes final put_task_struct in finish_task_switch(). */
14126 tsk->state = TASK_DEAD;
14127 tsk->flags |= PF_NOFREEZE; /* tell freezer to ignore us */
14129 + printk("bad task: %p [%lx]\n", current, current->state);
14131 /* Avoid "noreturn function does return". */
14133 diff -NurpP --minimal linux-3.6/kernel/fork.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/fork.c
14134 --- linux-3.6/kernel/fork.c 2012-10-04 15:27:48.000000000 +0200
14135 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/fork.c 2012-10-04 18:47:00.000000000 +0200
14137 #include <linux/khugepaged.h>
14138 #include <linux/signalfd.h>
14139 #include <linux/uprobes.h>
14140 +#include <linux/vs_context.h>
14141 +#include <linux/vs_network.h>
14142 +#include <linux/vs_limit.h>
14144 #include <asm/pgtable.h>
14145 #include <asm/pgalloc.h>
14146 @@ -210,6 +213,8 @@ void free_task(struct task_struct *tsk)
14147 arch_release_thread_info(tsk->stack);
14148 free_thread_info(tsk->stack);
14149 rt_mutex_debug_task_free(tsk);
14150 + clr_vx_info(&tsk->vx_info);
14151 + clr_nx_info(&tsk->nx_info);
14152 ftrace_graph_exit_task(tsk);
14153 put_seccomp_filter(tsk);
14154 arch_release_task_struct(tsk);
14155 @@ -541,6 +546,7 @@ static struct mm_struct *mm_init(struct
14156 if (likely(!mm_alloc_pgd(mm))) {
14158 mmu_notifier_mm_init(mm);
14159 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14163 @@ -593,6 +599,7 @@ void __mmdrop(struct mm_struct *mm)
14164 destroy_context(mm);
14165 mmu_notifier_mm_destroy(mm);
14167 + clr_vx_info(&mm->mm_vx_info);
14170 EXPORT_SYMBOL_GPL(__mmdrop);
14171 @@ -834,6 +841,7 @@ struct mm_struct *dup_mm(struct task_str
14174 memcpy(mm, oldmm, sizeof(*mm));
14175 + mm->mm_vx_info = NULL;
14176 mm_init_cpumask(mm);
14178 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14179 @@ -874,6 +882,7 @@ fail_nocontext:
14180 * If init_new_context() failed, we cannot use mmput() to free the mm
14181 * because it calls destroy_context()
14183 + clr_vx_info(&mm->mm_vx_info);
14187 @@ -1157,6 +1166,8 @@ static struct task_struct *copy_process(
14189 struct task_struct *p;
14190 int cgroup_callbacks_done = 0;
14191 + struct vx_info *vxi;
14192 + struct nx_info *nxi;
14194 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14195 return ERR_PTR(-EINVAL);
14196 @@ -1204,7 +1215,12 @@ static struct task_struct *copy_process(
14197 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14198 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14200 + init_vx_info(&p->vx_info, current_vx_info());
14201 + init_nx_info(&p->nx_info, current_nx_info());
14204 + if (!vx_nproc_avail(1))
14205 + goto bad_fork_free;
14206 if (atomic_read(&p->real_cred->user->processes) >=
14207 task_rlimit(p, RLIMIT_NPROC)) {
14208 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14209 @@ -1483,6 +1499,18 @@ static struct task_struct *copy_process(
14212 spin_unlock(¤t->sighand->siglock);
14214 + /* p is copy of current */
14215 + vxi = p->vx_info;
14217 + claim_vx_info(vxi, p);
14218 + atomic_inc(&vxi->cvirt.nr_threads);
14219 + atomic_inc(&vxi->cvirt.total_forks);
14222 + nxi = p->nx_info;
14224 + claim_nx_info(nxi, p);
14225 write_unlock_irq(&tasklist_lock);
14226 proc_fork_connector(p);
14227 cgroup_post_fork(p);
14228 diff -NurpP --minimal linux-3.6/kernel/kthread.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/kthread.c
14229 --- linux-3.6/kernel/kthread.c 2012-10-04 15:27:48.000000000 +0200
14230 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/kthread.c 2012-10-04 18:47:00.000000000 +0200
14232 #include <linux/mutex.h>
14233 #include <linux/slab.h>
14234 #include <linux/freezer.h>
14235 +#include <linux/vs_pid.h>
14236 #include <trace/events/sched.h>
14238 static DEFINE_SPINLOCK(kthread_create_lock);
14239 diff -NurpP --minimal linux-3.6/kernel/nsproxy.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/nsproxy.c
14240 --- linux-3.6/kernel/nsproxy.c 2012-01-09 16:15:00.000000000 +0100
14241 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/nsproxy.c 2012-10-04 18:47:00.000000000 +0200
14242 @@ -20,11 +20,14 @@
14243 #include <linux/mnt_namespace.h>
14244 #include <linux/utsname.h>
14245 #include <linux/pid_namespace.h>
14246 +#include <linux/vserver/global.h>
14247 +#include <linux/vserver/debug.h>
14248 #include <net/net_namespace.h>
14249 #include <linux/ipc_namespace.h>
14250 #include <linux/proc_fs.h>
14251 #include <linux/file.h>
14252 #include <linux/syscalls.h>
14253 +#include "../fs/mount.h"
14255 static struct kmem_cache *nsproxy_cachep;
14257 @@ -46,8 +49,11 @@ static inline struct nsproxy *create_nsp
14258 struct nsproxy *nsproxy;
14260 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14263 atomic_set(&nsproxy->count, 1);
14264 + atomic_inc(&vs_global_nsproxy);
14266 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14270 @@ -56,8 +62,11 @@ static inline struct nsproxy *create_nsp
14271 * Return the newly created nsproxy. Do not attach this to the task,
14272 * leave it to the caller to do proper locking and attach it to task.
14274 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14275 - struct task_struct *tsk, struct fs_struct *new_fs)
14276 +static struct nsproxy *unshare_namespaces(unsigned long flags,
14277 + struct nsproxy *orig,
14278 + struct fs_struct *new_fs,
14279 + struct user_namespace *new_user,
14280 + struct pid_namespace *new_pid)
14282 struct nsproxy *new_nsp;
14284 @@ -66,31 +75,31 @@ static struct nsproxy *create_new_namesp
14286 return ERR_PTR(-ENOMEM);
14288 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
14289 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
14290 if (IS_ERR(new_nsp->mnt_ns)) {
14291 err = PTR_ERR(new_nsp->mnt_ns);
14295 - new_nsp->uts_ns = copy_utsname(flags, tsk);
14296 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
14297 if (IS_ERR(new_nsp->uts_ns)) {
14298 err = PTR_ERR(new_nsp->uts_ns);
14302 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
14303 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
14304 if (IS_ERR(new_nsp->ipc_ns)) {
14305 err = PTR_ERR(new_nsp->ipc_ns);
14309 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
14310 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
14311 if (IS_ERR(new_nsp->pid_ns)) {
14312 err = PTR_ERR(new_nsp->pid_ns);
14316 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
14317 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
14318 if (IS_ERR(new_nsp->net_ns)) {
14319 err = PTR_ERR(new_nsp->net_ns);
14321 @@ -115,6 +124,40 @@ out_ns:
14322 return ERR_PTR(err);
14325 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14326 + struct task_struct *tsk, struct fs_struct *new_fs)
14328 + return unshare_namespaces(flags, tsk->nsproxy,
14329 + new_fs, task_cred_xxx(tsk, user_ns),
14330 + task_active_pid_ns(tsk));
14334 + * copies the nsproxy, setting refcount to 1, and grabbing a
14335 + * reference to all contained namespaces.
14337 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14339 + struct nsproxy *ns = create_nsproxy();
14342 + memcpy(ns, orig, sizeof(struct nsproxy));
14343 + atomic_set(&ns->count, 1);
14346 + get_mnt_ns(ns->mnt_ns);
14348 + get_uts_ns(ns->uts_ns);
14350 + get_ipc_ns(ns->ipc_ns);
14352 + get_pid_ns(ns->pid_ns);
14354 + get_net(ns->net_ns);
14360 * called from clone. This now handles copy for nsproxy and all
14361 * namespaces therein.
14362 @@ -122,9 +165,12 @@ out_ns:
14363 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
14365 struct nsproxy *old_ns = tsk->nsproxy;
14366 - struct nsproxy *new_ns;
14367 + struct nsproxy *new_ns = NULL;
14370 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14371 + flags, tsk, old_ns);
14376 @@ -134,7 +180,7 @@ int copy_namespaces(unsigned long flags,
14377 CLONE_NEWPID | CLONE_NEWNET)))
14380 - if (!capable(CAP_SYS_ADMIN)) {
14381 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
14385 @@ -161,6 +207,9 @@ int copy_namespaces(unsigned long flags,
14388 put_nsproxy(old_ns);
14389 + vxdprintk(VXD_CBIT(space, 3),
14390 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14391 + flags, tsk, old_ns, err, new_ns);
14395 @@ -174,7 +223,9 @@ void free_nsproxy(struct nsproxy *ns)
14396 put_ipc_ns(ns->ipc_ns);
14398 put_pid_ns(ns->pid_ns);
14399 - put_net(ns->net_ns);
14401 + put_net(ns->net_ns);
14402 + atomic_dec(&vs_global_nsproxy);
14403 kmem_cache_free(nsproxy_cachep, ns);
14406 @@ -187,11 +238,15 @@ int unshare_nsproxy_namespaces(unsigned
14410 + vxdprintk(VXD_CBIT(space, 4),
14411 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14412 + unshare_flags, current->nsproxy);
14414 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14418 - if (!capable(CAP_SYS_ADMIN))
14419 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
14422 *new_nsp = create_new_namespaces(unshare_flags, current,
14423 diff -NurpP --minimal linux-3.6/kernel/pid.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/pid.c
14424 --- linux-3.6/kernel/pid.c 2012-07-22 23:39:46.000000000 +0200
14425 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/pid.c 2012-10-04 18:47:00.000000000 +0200
14427 #include <linux/pid_namespace.h>
14428 #include <linux/init_task.h>
14429 #include <linux/syscalls.h>
14430 +#include <linux/vs_pid.h>
14432 #define pid_hashfn(nr, ns) \
14433 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14434 @@ -344,7 +345,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14436 struct pid *find_vpid(int nr)
14438 - return find_pid_ns(nr, current->nsproxy->pid_ns);
14439 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
14441 EXPORT_SYMBOL_GPL(find_vpid);
14443 @@ -404,6 +405,9 @@ void transfer_pid(struct task_struct *ol
14444 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14446 struct task_struct *result = NULL;
14448 + if (type == PIDTYPE_REALPID)
14449 + type = PIDTYPE_PID;
14451 struct hlist_node *first;
14452 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
14453 @@ -423,7 +427,7 @@ struct task_struct *find_task_by_pid_ns(
14454 rcu_lockdep_assert(rcu_read_lock_held(),
14455 "find_task_by_pid_ns() needs rcu_read_lock()"
14457 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
14458 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
14461 struct task_struct *find_task_by_vpid(pid_t vnr)
14462 @@ -467,7 +471,7 @@ struct pid *find_get_pid(pid_t nr)
14464 EXPORT_SYMBOL_GPL(find_get_pid);
14466 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14467 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
14471 @@ -480,6 +484,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
14475 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14477 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
14480 pid_t pid_vnr(struct pid *pid)
14482 return pid_nr_ns(pid, current->nsproxy->pid_ns);
14483 diff -NurpP --minimal linux-3.6/kernel/pid_namespace.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/pid_namespace.c
14484 --- linux-3.6/kernel/pid_namespace.c 2012-10-04 15:27:48.000000000 +0200
14485 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/pid_namespace.c 2012-10-04 18:47:00.000000000 +0200
14487 #include <linux/slab.h>
14488 #include <linux/proc_fs.h>
14489 #include <linux/reboot.h>
14490 +#include <linux/vserver/global.h>
14492 #define BITS_PER_PAGE (PAGE_SIZE*8)
14494 @@ -89,6 +90,7 @@ static struct pid_namespace *create_pid_
14497 kref_init(&ns->kref);
14498 + atomic_inc(&vs_global_pid_ns);
14500 ns->parent = get_pid_ns(parent_pid_ns);
14502 @@ -120,6 +122,7 @@ static void destroy_pid_namespace(struct
14504 for (i = 0; i < PIDMAP_ENTRIES; i++)
14505 kfree(ns->pidmap[i].page);
14506 + atomic_dec(&vs_global_pid_ns);
14507 kmem_cache_free(pid_ns_cachep, ns);
14510 diff -NurpP --minimal linux-3.6/kernel/posix-timers.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/posix-timers.c
14511 --- linux-3.6/kernel/posix-timers.c 2012-01-09 16:15:00.000000000 +0100
14512 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/posix-timers.c 2012-10-04 18:47:00.000000000 +0200
14514 #include <linux/wait.h>
14515 #include <linux/workqueue.h>
14516 #include <linux/export.h>
14517 +#include <linux/vs_context.h>
14520 * Management arrays for POSIX timers. Timers are kept in slab memory
14521 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
14523 struct task_struct *task;
14524 int shared, ret = -1;
14527 * FIXME: if ->sigq is queued we can race with
14528 * dequeue_signal()->do_schedule_next_timer().
14529 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
14531 task = pid_task(timr->it_pid, PIDTYPE_PID);
14533 + struct vx_info_save vxis;
14534 + struct vx_info *vxi;
14536 + vxi = get_vx_info(task->vx_info);
14537 + enter_vx_info(vxi, &vxis);
14538 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
14539 ret = send_sigqueue(timr->sigq, task, shared);
14540 + leave_vx_info(&vxis);
14541 + put_vx_info(vxi);
14545 /* If we failed to send the signal the timer stops. */
14548 diff -NurpP --minimal linux-3.6/kernel/printk.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/printk.c
14549 --- linux-3.6/kernel/printk.c 2012-10-04 15:27:48.000000000 +0200
14550 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/printk.c 2012-10-04 18:47:00.000000000 +0200
14552 #include <linux/notifier.h>
14553 #include <linux/rculist.h>
14554 #include <linux/poll.h>
14555 +#include <linux/vs_cvirt.h>
14557 #include <asm/uaccess.h>
14559 @@ -818,7 +819,7 @@ static int check_syslog_permissions(int
14562 if (syslog_action_restricted(type)) {
14563 - if (capable(CAP_SYSLOG))
14564 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
14566 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
14567 if (capable(CAP_SYS_ADMIN)) {
14568 @@ -1111,12 +1112,9 @@ int do_syslog(int type, char __user *buf
14573 - case SYSLOG_ACTION_CLOSE: /* Close log */
14575 - case SYSLOG_ACTION_OPEN: /* Open log */
14577 - case SYSLOG_ACTION_READ: /* Read from log */
14578 + if ((type == SYSLOG_ACTION_READ) ||
14579 + (type == SYSLOG_ACTION_READ_ALL) ||
14580 + (type == SYSLOG_ACTION_READ_CLEAR)) {
14582 if (!buf || len < 0)
14584 @@ -1127,6 +1125,16 @@ int do_syslog(int type, char __user *buf
14589 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14590 + return vx_do_syslog(type, buf, len);
14593 + case SYSLOG_ACTION_CLOSE: /* Close log */
14595 + case SYSLOG_ACTION_OPEN: /* Open log */
14597 + case SYSLOG_ACTION_READ: /* Read from log */
14598 error = wait_event_interruptible(log_wait,
14599 syslog_seq != log_next_seq);
14601 @@ -1139,16 +1147,6 @@ int do_syslog(int type, char __user *buf
14603 /* Read last kernel messages */
14604 case SYSLOG_ACTION_READ_ALL:
14606 - if (!buf || len < 0)
14611 - if (!access_ok(VERIFY_WRITE, buf, len)) {
14615 error = syslog_print_all(buf, len, clear);
14617 /* Clear ring buffer */
14618 diff -NurpP --minimal linux-3.6/kernel/ptrace.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/ptrace.c
14619 --- linux-3.6/kernel/ptrace.c 2012-07-22 23:39:46.000000000 +0200
14620 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/ptrace.c 2012-10-04 18:47:00.000000000 +0200
14622 #include <linux/syscalls.h>
14623 #include <linux/uaccess.h>
14624 #include <linux/regset.h>
14625 +#include <linux/vs_context.h>
14626 #include <linux/hw_breakpoint.h>
14627 #include <linux/cn_proc.h>
14629 @@ -216,6 +217,11 @@ ok:
14630 dumpable = get_dumpable(task->mm);
14631 if (!dumpable && !ptrace_has_cap(task_user_ns(task), mode))
14633 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
14635 + if (!vx_check(task->xid, VS_IDENT) &&
14636 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
14639 return security_ptrace_access_check(task, mode);
14641 diff -NurpP --minimal linux-3.6/kernel/sched/core.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/sched/core.c
14642 --- linux-3.6/kernel/sched/core.c 2012-10-04 15:27:48.000000000 +0200
14643 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/sched/core.c 2012-10-04 18:47:00.000000000 +0200
14645 #include <linux/slab.h>
14646 #include <linux/init_task.h>
14647 #include <linux/binfmts.h>
14648 +#include <linux/vs_sched.h>
14649 +#include <linux/vs_cvirt.h>
14651 #include <asm/switch_to.h>
14652 #include <asm/tlb.h>
14653 @@ -2223,9 +2225,17 @@ EXPORT_SYMBOL(avenrun); /* should be rem
14655 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
14657 - loads[0] = (avenrun[0] + offset) << shift;
14658 - loads[1] = (avenrun[1] + offset) << shift;
14659 - loads[2] = (avenrun[2] + offset) << shift;
14660 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
14661 + struct vx_info *vxi = current_vx_info();
14663 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
14664 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
14665 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
14667 + loads[0] = (avenrun[0] + offset) << shift;
14668 + loads[1] = (avenrun[1] + offset) << shift;
14669 + loads[2] = (avenrun[2] + offset) << shift;
14673 static long calc_load_fold_active(struct rq *this_rq)
14674 @@ -2854,14 +2864,17 @@ static inline void task_group_account_fi
14675 void account_user_time(struct task_struct *p, cputime_t cputime,
14676 cputime_t cputime_scaled)
14678 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14679 + int nice = (TASK_NICE(p) > 0);
14682 /* Add user time to process. */
14683 p->utime += cputime;
14684 p->utimescaled += cputime_scaled;
14685 + vx_account_user(vxi, cputime, nice);
14686 account_group_user_time(p, cputime);
14688 - index = (TASK_NICE(p) > 0) ? CPUTIME_NICE : CPUTIME_USER;
14689 + index = (nice) ? CPUTIME_NICE : CPUTIME_USER;
14691 /* Add user time to cpustat. */
14692 task_group_account_field(p, index, (__force u64) cputime);
14693 @@ -2908,9 +2921,12 @@ static inline
14694 void __account_system_time(struct task_struct *p, cputime_t cputime,
14695 cputime_t cputime_scaled, int index)
14697 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14699 /* Add system time to process. */
14700 p->stime += cputime;
14701 p->stimescaled += cputime_scaled;
14702 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
14703 account_group_system_time(p, cputime);
14705 /* Add system time to cpustat. */
14706 @@ -4137,7 +4153,7 @@ SYSCALL_DEFINE1(nice, int, increment)
14709 if (increment < 0 && !can_nice(current, nice))
14711 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
14713 retval = security_task_setnice(current, nice);
14715 diff -NurpP --minimal linux-3.6/kernel/sched/fair.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/sched/fair.c
14716 --- linux-3.6/kernel/sched/fair.c 2012-10-04 15:27:48.000000000 +0200
14717 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/sched/fair.c 2012-10-04 18:47:00.000000000 +0200
14719 #include <linux/slab.h>
14720 #include <linux/profile.h>
14721 #include <linux/interrupt.h>
14722 +#include <linux/vs_cvirt.h>
14724 #include <trace/events/sched.h>
14726 @@ -1111,6 +1112,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
14727 __enqueue_entity(cfs_rq, se);
14730 + if (entity_is_task(se))
14731 + vx_activate_task(task_of(se));
14732 if (cfs_rq->nr_running == 1) {
14733 list_add_leaf_cfs_rq(cfs_rq);
14734 check_enqueue_throttle(cfs_rq);
14735 @@ -1191,6 +1194,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
14736 if (se != cfs_rq->curr)
14737 __dequeue_entity(cfs_rq, se);
14739 + if (entity_is_task(se))
14740 + vx_deactivate_task(task_of(se));
14741 update_cfs_load(cfs_rq, 0);
14742 account_entity_dequeue(cfs_rq, se);
14744 diff -NurpP --minimal linux-3.6/kernel/signal.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/signal.c
14745 --- linux-3.6/kernel/signal.c 2012-10-04 15:27:48.000000000 +0200
14746 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/signal.c 2012-10-04 18:47:00.000000000 +0200
14748 #include <linux/nsproxy.h>
14749 #include <linux/user_namespace.h>
14750 #include <linux/uprobes.h>
14751 +#include <linux/vs_context.h>
14752 +#include <linux/vs_pid.h>
14753 #define CREATE_TRACE_POINTS
14754 #include <trace/events/signal.h>
14756 @@ -790,9 +792,18 @@ static int check_kill_permission(int sig
14760 + vxdprintk(VXD_CBIT(misc, 7),
14761 + "check_kill_permission(%d,%p,%p[#%u,%u])",
14762 + sig, info, t, vx_task_xid(t), t->pid);
14764 if (!valid_signal(sig))
14767 +/* FIXME: needed? if so, why?
14768 + if ((info != SEND_SIG_NOINFO) &&
14769 + (is_si_special(info) || !si_fromuser(info)))
14772 if (!si_fromuser(info))
14775 @@ -816,6 +827,20 @@ static int check_kill_permission(int sig
14780 + if (t->pid == 1 && current->xid)
14784 + /* FIXME: we shouldn't return ESRCH ever, to avoid
14785 + loops, maybe ENOENT or EACCES? */
14786 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
14787 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
14788 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
14789 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
14793 return security_task_kill(t, info, sig, 0);
14796 @@ -1351,7 +1376,7 @@ int kill_pid_info(int sig, struct siginf
14799 p = pid_task(pid, PIDTYPE_PID);
14801 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
14802 error = group_send_sig_info(sig, info, p);
14803 if (unlikely(error == -ESRCH))
14805 @@ -1399,7 +1424,7 @@ int kill_pid_info_as_cred(int sig, struc
14808 p = pid_task(pid, PIDTYPE_PID);
14810 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
14814 @@ -1451,8 +1476,10 @@ static int kill_something_info(int sig,
14815 struct task_struct * p;
14817 for_each_process(p) {
14818 - if (task_pid_vnr(p) > 1 &&
14819 - !same_thread_group(p, current)) {
14820 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
14821 + task_pid_vnr(p) > 1 &&
14822 + !same_thread_group(p, current) &&
14823 + !vx_current_initpid(p->pid)) {
14824 int err = group_send_sig_info(sig, info, p);
14827 @@ -2317,6 +2344,11 @@ relock:
14828 !sig_kernel_only(signr))
14831 + /* virtual init is protected against user signals */
14832 + if ((info->si_code == SI_USER) &&
14833 + vx_current_initpid(current->pid))
14836 if (sig_kernel_stop(signr)) {
14838 * The default action is to stop all threads in
14839 diff -NurpP --minimal linux-3.6/kernel/softirq.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/softirq.c
14840 --- linux-3.6/kernel/softirq.c 2012-10-04 15:27:48.000000000 +0200
14841 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/softirq.c 2012-10-04 18:47:00.000000000 +0200
14843 #include <linux/ftrace.h>
14844 #include <linux/smp.h>
14845 #include <linux/tick.h>
14846 +#include <linux/vs_context.h>
14848 #define CREATE_TRACE_POINTS
14849 #include <trace/events/irq.h>
14850 diff -NurpP --minimal linux-3.6/kernel/sys.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/sys.c
14851 --- linux-3.6/kernel/sys.c 2012-10-04 15:27:48.000000000 +0200
14852 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/sys.c 2012-10-04 18:47:00.000000000 +0200
14854 #include <linux/syscalls.h>
14855 #include <linux/kprobes.h>
14856 #include <linux/user_namespace.h>
14857 +#include <linux/vs_pid.h>
14859 #include <linux/kmsg_dump.h>
14860 /* Move somewhere else to avoid recompiling? */
14861 @@ -154,7 +155,10 @@ static int set_one_prio(struct task_stru
14864 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
14866 + if (vx_flags(VXF_IGNEG_NICE, 0))
14872 no_nice = security_task_setnice(p, niceval);
14873 @@ -205,6 +209,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
14875 pgrp = task_pgrp(current);
14876 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
14877 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
14879 error = set_one_prio(p, niceval, error);
14880 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
14882 @@ -270,6 +276,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
14884 pgrp = task_pgrp(current);
14885 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
14886 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
14888 niceval = 20 - task_nice(p);
14889 if (niceval > retval)
14891 @@ -421,6 +429,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
14893 static DEFINE_MUTEX(reboot_mutex);
14895 +long vs_reboot(unsigned int, void __user *);
14898 * Reboot system call: for obvious reasons only root may call it,
14899 * and even root needs to set up some magic numbers in the registers
14900 @@ -462,6 +472,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
14901 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
14902 cmd = LINUX_REBOOT_CMD_HALT;
14904 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14905 + return vs_reboot(cmd, arg);
14907 mutex_lock(&reboot_mutex);
14909 case LINUX_REBOOT_CMD_RESTART:
14910 @@ -1367,7 +1380,8 @@ SYSCALL_DEFINE2(sethostname, char __user
14912 char tmp[__NEW_UTS_LEN];
14914 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
14915 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
14916 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
14919 if (len < 0 || len > __NEW_UTS_LEN)
14920 @@ -1418,7 +1432,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
14922 char tmp[__NEW_UTS_LEN];
14924 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
14925 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
14926 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
14928 if (len < 0 || len > __NEW_UTS_LEN)
14930 @@ -1537,7 +1552,7 @@ int do_prlimit(struct task_struct *tsk,
14931 /* Keep the capable check against init_user_ns until
14932 cgroups can contain all limits */
14933 if (new_rlim->rlim_max > rlim->rlim_max &&
14934 - !capable(CAP_SYS_RESOURCE))
14935 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
14938 retval = security_task_setrlimit(tsk->group_leader,
14939 @@ -1590,7 +1605,8 @@ static int check_prlimit_permission(stru
14940 gid_eq(cred->gid, tcred->sgid) &&
14941 gid_eq(cred->gid, tcred->gid))
14943 - if (ns_capable(tcred->user_ns, CAP_SYS_RESOURCE))
14944 + if (vx_ns_capable(tcred->user_ns,
14945 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
14949 diff -NurpP --minimal linux-3.6/kernel/sysctl.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/sysctl.c
14950 --- linux-3.6/kernel/sysctl.c 2012-10-04 15:27:48.000000000 +0200
14951 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/sysctl.c 2012-10-04 18:47:00.000000000 +0200
14953 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
14954 #include <linux/lockdep.h>
14956 +extern char vshelper_path[];
14957 #ifdef CONFIG_CHR_DEV_SG
14958 #include <scsi/sg.h>
14960 @@ -568,6 +569,13 @@ static struct ctl_table kern_table[] = {
14961 .proc_handler = proc_dostring,
14965 + .procname = "vshelper",
14966 + .data = &vshelper_path,
14969 + .proc_handler = &proc_dostring,
14971 #ifdef CONFIG_CHR_DEV_SG
14973 .procname = "sg-big-buff",
14974 diff -NurpP --minimal linux-3.6/kernel/sysctl_binary.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/sysctl_binary.c
14975 --- linux-3.6/kernel/sysctl_binary.c 2012-10-04 15:27:48.000000000 +0200
14976 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/sysctl_binary.c 2012-10-04 18:47:00.000000000 +0200
14977 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
14979 { CTL_INT, KERN_PANIC, "panic" },
14980 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
14981 + { CTL_STR, KERN_VSHELPER, "vshelper" },
14983 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
14984 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
14985 diff -NurpP --minimal linux-3.6/kernel/time/timekeeping.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/time/timekeeping.c
14986 --- linux-3.6/kernel/time/timekeeping.c 2012-10-04 15:27:48.000000000 +0200
14987 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/time/timekeeping.c 2012-10-04 18:47:00.000000000 +0200
14988 @@ -309,6 +309,7 @@ void getnstimeofday(struct timespec *ts)
14991 timespec_add_ns(ts, nsecs);
14992 + vx_adjust_timespec(ts);
14994 EXPORT_SYMBOL(getnstimeofday);
14996 diff -NurpP --minimal linux-3.6/kernel/time.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/time.c
14997 --- linux-3.6/kernel/time.c 2012-05-21 18:07:34.000000000 +0200
14998 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/time.c 2012-10-04 18:47:00.000000000 +0200
14999 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15003 - do_settimeofday(&tv);
15004 + vx_settimeofday(&tv);
15008 @@ -172,7 +172,7 @@ int do_sys_settimeofday(const struct tim
15012 - return do_settimeofday(tv);
15013 + return vx_settimeofday(tv);
15017 diff -NurpP --minimal linux-3.6/kernel/timer.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/timer.c
15018 --- linux-3.6/kernel/timer.c 2012-10-04 15:27:48.000000000 +0200
15019 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/timer.c 2012-10-09 14:02:12.000000000 +0200
15021 #include <linux/irq_work.h>
15022 #include <linux/sched.h>
15023 #include <linux/slab.h>
15024 +#include <linux/vs_base.h>
15025 +#include <linux/vs_cvirt.h>
15026 +#include <linux/vs_pid.h>
15027 +#include <linux/vserver/sched.h>
15029 #include <asm/uaccess.h>
15030 #include <asm/unistd.h>
15031 diff -NurpP --minimal linux-3.6/kernel/user_namespace.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/user_namespace.c
15032 --- linux-3.6/kernel/user_namespace.c 2012-07-22 23:39:47.000000000 +0200
15033 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/user_namespace.c 2012-10-04 18:47:00.000000000 +0200
15035 #include <linux/fs.h>
15036 #include <linux/uaccess.h>
15037 #include <linux/ctype.h>
15038 +#include <linux/vserver/global.h>
15040 static struct kmem_cache *user_ns_cachep __read_mostly;
15042 @@ -52,6 +53,7 @@ int create_user_ns(struct cred *new)
15045 kref_init(&ns->kref);
15046 + atomic_inc(&vs_global_user_ns);
15047 ns->parent = parent_ns;
15050 @@ -84,6 +86,9 @@ void free_user_ns(struct kref *kref)
15052 parent = ns->parent;
15053 kmem_cache_free(user_ns_cachep, ns);
15055 + /* FIXME: maybe move into destroyer? */
15056 + atomic_dec(&vs_global_user_ns);
15057 put_user_ns(parent);
15059 EXPORT_SYMBOL(free_user_ns);
15060 diff -NurpP --minimal linux-3.6/kernel/utsname.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/utsname.c
15061 --- linux-3.6/kernel/utsname.c 2012-07-22 23:39:47.000000000 +0200
15062 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/utsname.c 2012-10-04 18:47:00.000000000 +0200
15063 @@ -16,14 +16,17 @@
15064 #include <linux/slab.h>
15065 #include <linux/user_namespace.h>
15066 #include <linux/proc_fs.h>
15067 +#include <linux/vserver/global.h>
15069 static struct uts_namespace *create_uts_ns(void)
15071 struct uts_namespace *uts_ns;
15073 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15076 kref_init(&uts_ns->kref);
15077 + atomic_inc(&vs_global_uts_ns);
15082 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
15083 * @old_ns: namespace to clone
15084 * Return NULL on error (failure to kmalloc), new ns otherwise
15086 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
15087 - struct uts_namespace *old_ns)
15088 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
15089 + struct user_namespace *old_user)
15091 struct uts_namespace *ns;
15093 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
15095 down_read(&uts_sem);
15096 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
15097 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user_ns));
15098 + ns->user_ns = get_user_ns(old_user);
15102 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
15105 struct uts_namespace *copy_utsname(unsigned long flags,
15106 - struct task_struct *tsk)
15107 + struct uts_namespace *old_ns,
15108 + struct user_namespace *user_ns)
15110 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
15111 struct uts_namespace *new_ns;
15114 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
15115 if (!(flags & CLONE_NEWUTS))
15118 - new_ns = clone_uts_ns(tsk, old_ns);
15119 + new_ns = clone_uts_ns(old_ns, user_ns);
15121 put_uts_ns(old_ns);
15123 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
15125 ns = container_of(kref, struct uts_namespace, kref);
15126 put_user_ns(ns->user_ns);
15127 + atomic_dec(&vs_global_uts_ns);
15131 diff -NurpP --minimal linux-3.6/kernel/vserver/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/Kconfig
15132 --- linux-3.6/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
15133 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/Kconfig 2012-10-04 18:47:00.000000000 +0200
15136 +# Linux VServer configuration
15139 +menu "Linux VServer"
15141 +config VSERVER_AUTO_LBACK
15142 + bool "Automatically Assign Loopback IP"
15145 + Automatically assign a guest specific loopback
15146 + IP and add it to the kernel network stack on
15149 +config VSERVER_AUTO_SINGLE
15150 + bool "Automatic Single IP Special Casing"
15151 + depends on EXPERIMENTAL
15154 + This allows network contexts with a single IP to
15155 + automatically remap 0.0.0.0 bindings to that IP,
15156 + avoiding further network checks and improving
15159 + (note: such guests do not allow to change the ip
15160 + on the fly and do not show loopback addresses)
15162 +config VSERVER_COWBL
15163 + bool "Enable COW Immutable Link Breaking"
15166 + This enables the COW (Copy-On-Write) link break code.
15167 + It allows you to treat unified files like normal files
15168 + when writing to them (which will implicitely break the
15169 + link and create a copy of the unified file)
15171 +config VSERVER_VTIME
15172 + bool "Enable Virtualized Guest Time"
15173 + depends on EXPERIMENTAL
15176 + This enables per guest time offsets to allow for
15177 + adjusting the system clock individually per guest.
15178 + this adds some overhead to the time functions and
15179 + therefore should not be enabled without good reason.
15181 +config VSERVER_DEVICE
15182 + bool "Enable Guest Device Mapping"
15183 + depends on EXPERIMENTAL
15186 + This enables generic device remapping.
15188 +config VSERVER_PROC_SECURE
15189 + bool "Enable Proc Security"
15190 + depends on PROC_FS
15193 + This configures ProcFS security to initially hide
15194 + non-process entries for all contexts except the main and
15195 + spectator context (i.e. for all guests), which is a secure
15198 + (note: on 1.2x the entries were visible by default)
15201 + prompt "Persistent Inode Tagging"
15202 + default TAGGING_ID24
15204 + This adds persistent context information to filesystems
15205 + mounted with the tagxid option. Tagging is a requirement
15206 + for per-context disk limits and per-context quota.
15209 +config TAGGING_NONE
15212 + do not store per-context information in inodes.
15214 +config TAGGING_UID16
15215 + bool "UID16/GID32"
15217 + reduces UID to 16 bit, but leaves GID at 32 bit.
15219 +config TAGGING_GID16
15220 + bool "UID32/GID16"
15222 + reduces GID to 16 bit, but leaves UID at 32 bit.
15224 +config TAGGING_ID24
15225 + bool "UID24/GID24"
15227 + uses the upper 8bit from UID and GID for XID tagging
15228 + which leaves 24bit for UID/GID each, which should be
15229 + more than sufficient for normal use.
15231 +config TAGGING_INTERN
15232 + bool "UID32/GID32"
15234 + this uses otherwise reserved inode fields in the on
15235 + disk representation, which limits the use to a few
15236 + filesystems (currently ext2 and ext3)
15241 + bool "Tag NFSD User Auth and Files"
15244 + Enable this if you do want the in-kernel NFS
15245 + Server to use the tagging specified above.
15246 + (will require patched clients too)
15248 +config VSERVER_PRIVACY
15249 + bool "Honor Privacy Aspects of Guests"
15252 + When enabled, most context checks will disallow
15253 + access to structures assigned to a specific context,
15254 + like ptys or loop devices.
15256 +config VSERVER_CONTEXTS
15257 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15259 + default "768" if 64BIT
15262 + This setting will optimize certain data structures
15263 + and memory allocations according to the expected
15266 + note: this is not a strict upper limit.
15268 +config VSERVER_WARN
15269 + bool "VServer Warnings"
15272 + This enables various runtime warnings, which will
15273 + notify about potential manipulation attempts or
15274 + resource shortage. It is generally considered to
15275 + be a good idea to have that enabled.
15277 +config VSERVER_WARN_DEVPTS
15278 + bool "VServer DevPTS Warnings"
15279 + depends on VSERVER_WARN
15282 + This enables DevPTS related warnings, issued when a
15283 + process inside a context tries to lookup or access
15284 + a dynamic pts from the host or a different context.
15286 +config VSERVER_DEBUG
15287 + bool "VServer Debugging Code"
15290 + Set this to yes if you want to be able to activate
15291 + debugging output at runtime. It adds a very small
15292 + overhead to all vserver related functions and
15293 + increases the kernel size by about 20k.
15295 +config VSERVER_HISTORY
15296 + bool "VServer History Tracing"
15297 + depends on VSERVER_DEBUG
15300 + Set this to yes if you want to record the history of
15301 + linux-vserver activities, so they can be replayed in
15302 + the event of a kernel panic or oops.
15304 +config VSERVER_HISTORY_SIZE
15305 + int "Per-CPU History Size (32-65536)"
15306 + depends on VSERVER_HISTORY
15310 + This allows you to specify the number of entries in
15311 + the per-CPU history buffer.
15314 + prompt "Quotes used in debug and warn messages"
15315 + default QUOTES_ISO8859
15317 +config QUOTES_ISO8859
15318 + bool "Extended ASCII (ISO 8859) angle quotes"
15320 + This uses the extended ASCII characters \xbb
15321 + and \xab for quoting file and process names.
15323 +config QUOTES_UTF8
15324 + bool "UTF-8 angle quotes"
15326 + This uses the the UTF-8 sequences for angle
15327 + quotes to quote file and process names.
15329 +config QUOTES_ASCII
15330 + bool "ASCII single quotes"
15332 + This uses the ASCII single quote character
15333 + (\x27) to quote file and process names.
15343 + select NAMESPACES
15349 +config VSERVER_SECURITY
15351 + depends on SECURITY
15353 + select SECURITY_CAPABILITIES
15355 +config VSERVER_DISABLED
15359 diff -NurpP --minimal linux-3.6/kernel/vserver/Makefile linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/Makefile
15360 --- linux-3.6/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
15361 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/Makefile 2012-10-04 18:47:00.000000000 +0200
15364 +# Makefile for the Linux vserver routines.
15368 +obj-y += vserver.o
15370 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15371 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15374 +vserver-$(CONFIG_INET) += inet.o
15375 +vserver-$(CONFIG_PROC_FS) += proc.o
15376 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15377 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15378 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
15379 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
15381 diff -NurpP --minimal linux-3.6/kernel/vserver/cacct.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/cacct.c
15382 --- linux-3.6/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
15383 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/cacct.c 2012-10-04 18:47:00.000000000 +0200
15386 + * linux/kernel/vserver/cacct.c
15388 + * Virtual Server: Context Accounting
15390 + * Copyright (C) 2006-2007 Herbert Pötzl
15392 + * V0.01 added accounting stats
15396 +#include <linux/types.h>
15397 +#include <linux/vs_context.h>
15398 +#include <linux/vserver/cacct_cmd.h>
15399 +#include <linux/vserver/cacct_int.h>
15401 +#include <asm/errno.h>
15402 +#include <asm/uaccess.h>
15405 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
15407 + struct vcmd_sock_stat_v0 vc_data;
15410 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
15413 + field = vc_data.field;
15414 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
15417 + for (j = 0; j < 3; j++) {
15418 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
15419 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
15422 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
15427 diff -NurpP --minimal linux-3.6/kernel/vserver/cacct_init.h linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/cacct_init.h
15428 --- linux-3.6/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
15429 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/cacct_init.h 2012-10-04 18:47:00.000000000 +0200
15433 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
15438 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15439 + for (j = 0; j < 3; j++) {
15440 + atomic_long_set(&cacct->sock[i][j].count, 0);
15441 + atomic_long_set(&cacct->sock[i][j].total, 0);
15444 + for (i = 0; i < 8; i++)
15445 + atomic_set(&cacct->slab[i], 0);
15446 + for (i = 0; i < 5; i++)
15447 + for (j = 0; j < 4; j++)
15448 + atomic_set(&cacct->page[i][j], 0);
15451 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
15456 diff -NurpP --minimal linux-3.6/kernel/vserver/cacct_proc.h linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/cacct_proc.h
15457 --- linux-3.6/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
15458 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/cacct_proc.h 2012-10-04 18:47:00.000000000 +0200
15460 +#ifndef _VX_CACCT_PROC_H
15461 +#define _VX_CACCT_PROC_H
15463 +#include <linux/vserver/cacct_int.h>
15466 +#define VX_SOCKA_TOP \
15467 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
15469 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
15471 + int i, j, length = 0;
15472 + static char *type[VXA_SOCK_SIZE] = {
15473 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
15476 + length += sprintf(buffer + length, VX_SOCKA_TOP);
15477 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15478 + length += sprintf(buffer + length, "%s:", type[i]);
15479 + for (j = 0; j < 3; j++) {
15480 + length += sprintf(buffer + length,
15481 + "\t%10lu/%-10lu",
15482 + vx_sock_count(cacct, i, j),
15483 + vx_sock_total(cacct, i, j));
15485 + buffer[length++] = '\n';
15488 + length += sprintf(buffer + length, "\n");
15489 + length += sprintf(buffer + length,
15490 + "slab:\t %8u %8u %8u %8u\n",
15491 + atomic_read(&cacct->slab[1]),
15492 + atomic_read(&cacct->slab[4]),
15493 + atomic_read(&cacct->slab[0]),
15494 + atomic_read(&cacct->slab[2]));
15496 + length += sprintf(buffer + length, "\n");
15497 + for (i = 0; i < 5; i++) {
15498 + length += sprintf(buffer + length,
15499 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
15500 + atomic_read(&cacct->page[i][0]),
15501 + atomic_read(&cacct->page[i][1]),
15502 + atomic_read(&cacct->page[i][2]),
15503 + atomic_read(&cacct->page[i][3]),
15504 + atomic_read(&cacct->page[i][4]),
15505 + atomic_read(&cacct->page[i][5]),
15506 + atomic_read(&cacct->page[i][6]),
15507 + atomic_read(&cacct->page[i][7]));
15512 +#endif /* _VX_CACCT_PROC_H */
15513 diff -NurpP --minimal linux-3.6/kernel/vserver/context.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/context.c
15514 --- linux-3.6/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
15515 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/context.c 2012-10-04 18:47:00.000000000 +0200
15518 + * linux/kernel/vserver/context.c
15520 + * Virtual Server: Context Support
15522 + * Copyright (C) 2003-2011 Herbert Pötzl
15524 + * V0.01 context helper
15525 + * V0.02 vx_ctx_kill syscall command
15526 + * V0.03 replaced context_info calls
15527 + * V0.04 redesign of struct (de)alloc
15528 + * V0.05 rlimit basic implementation
15529 + * V0.06 task_xid and info commands
15530 + * V0.07 context flags and caps
15531 + * V0.08 switch to RCU based hash
15532 + * V0.09 revert to non RCU for now
15533 + * V0.10 and back to working RCU hash
15534 + * V0.11 and back to locking again
15535 + * V0.12 referenced context store
15536 + * V0.13 separate per cpu data
15537 + * V0.14 changed vcmds to vxi arg
15538 + * V0.15 added context stat
15539 + * V0.16 have __create claim() the vxi
15540 + * V0.17 removed older and legacy stuff
15541 + * V0.18 added user credentials
15542 + * V0.19 added warn mask
15546 +#include <linux/slab.h>
15547 +#include <linux/types.h>
15548 +#include <linux/security.h>
15549 +#include <linux/pid_namespace.h>
15550 +#include <linux/capability.h>
15552 +#include <linux/vserver/context.h>
15553 +#include <linux/vserver/network.h>
15554 +#include <linux/vserver/debug.h>
15555 +#include <linux/vserver/limit.h>
15556 +#include <linux/vserver/limit_int.h>
15557 +#include <linux/vserver/space.h>
15558 +#include <linux/init_task.h>
15559 +#include <linux/fs_struct.h>
15560 +#include <linux/cred.h>
15562 +#include <linux/vs_context.h>
15563 +#include <linux/vs_limit.h>
15564 +#include <linux/vs_pid.h>
15565 +#include <linux/vserver/context_cmd.h>
15567 +#include "cvirt_init.h"
15568 +#include "cacct_init.h"
15569 +#include "limit_init.h"
15570 +#include "sched_init.h"
15573 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
15574 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
15577 +/* now inactive context structures */
15579 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
15581 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
15584 +/* __alloc_vx_info()
15586 + * allocate an initialized vx_info struct
15587 + * doesn't make it visible (hash) */
15589 +static struct vx_info *__alloc_vx_info(xid_t xid)
15591 + struct vx_info *new = NULL;
15594 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
15596 + /* would this benefit from a slab cache? */
15597 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
15601 + memset(new, 0, sizeof(struct vx_info));
15603 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
15604 + if (!new->ptr_pc)
15607 + new->vx_id = xid;
15608 + INIT_HLIST_NODE(&new->vx_hlist);
15609 + atomic_set(&new->vx_usecnt, 0);
15610 + atomic_set(&new->vx_tasks, 0);
15611 + new->vx_parent = NULL;
15612 + new->vx_state = 0;
15613 + init_waitqueue_head(&new->vx_wait);
15615 + /* prepare reaper */
15616 + get_task_struct(init_pid_ns.child_reaper);
15617 + new->vx_reaper = init_pid_ns.child_reaper;
15618 + new->vx_badness_bias = 0;
15620 + /* rest of init goes here */
15621 + vx_info_init_limit(&new->limit);
15622 + vx_info_init_sched(&new->sched);
15623 + vx_info_init_cvirt(&new->cvirt);
15624 + vx_info_init_cacct(&new->cacct);
15626 + /* per cpu data structures */
15627 + for_each_possible_cpu(cpu) {
15628 + vx_info_init_sched_pc(
15629 + &vx_per_cpu(new, sched_pc, cpu), cpu);
15630 + vx_info_init_cvirt_pc(
15631 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
15634 + new->vx_flags = VXF_INIT_SET;
15635 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
15636 + new->vx_ccaps = 0;
15637 + new->vx_umask = 0;
15638 + new->vx_wmask = 0;
15640 + new->reboot_cmd = 0;
15641 + new->exit_code = 0;
15643 + // preconfig spaces
15644 + for (index = 0; index < VX_SPACES; index++) {
15645 + struct _vx_space *space = &new->space[index];
15648 + spin_lock(&init_fs.lock);
15650 + spin_unlock(&init_fs.lock);
15651 + space->vx_fs = &init_fs;
15653 + /* FIXME: do we want defaults? */
15654 + // space->vx_real_cred = 0;
15655 + // space->vx_cred = 0;
15659 + vxdprintk(VXD_CBIT(xid, 0),
15660 + "alloc_vx_info(%d) = %p", xid, new);
15661 + vxh_alloc_vx_info(new);
15662 + atomic_inc(&vx_global_ctotal);
15671 +/* __dealloc_vx_info()
15673 + * final disposal of vx_info */
15675 +static void __dealloc_vx_info(struct vx_info *vxi)
15677 +#ifdef CONFIG_VSERVER_WARN
15678 + struct vx_info_save vxis;
15681 + vxdprintk(VXD_CBIT(xid, 0),
15682 + "dealloc_vx_info(%p)", vxi);
15683 + vxh_dealloc_vx_info(vxi);
15685 +#ifdef CONFIG_VSERVER_WARN
15686 + enter_vx_info(vxi, &vxis);
15687 + vx_info_exit_limit(&vxi->limit);
15688 + vx_info_exit_sched(&vxi->sched);
15689 + vx_info_exit_cvirt(&vxi->cvirt);
15690 + vx_info_exit_cacct(&vxi->cacct);
15692 + for_each_possible_cpu(cpu) {
15693 + vx_info_exit_sched_pc(
15694 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
15695 + vx_info_exit_cvirt_pc(
15696 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
15698 + leave_vx_info(&vxis);
15702 + vxi->vx_state |= VXS_RELEASED;
15705 + free_percpu(vxi->ptr_pc);
15708 + atomic_dec(&vx_global_ctotal);
15711 +static void __shutdown_vx_info(struct vx_info *vxi)
15713 + struct nsproxy *nsproxy;
15714 + struct fs_struct *fs;
15715 + struct cred *cred;
15720 + vxi->vx_state |= VXS_SHUTDOWN;
15721 + vs_state_change(vxi, VSC_SHUTDOWN);
15723 + for (index = 0; index < VX_SPACES; index++) {
15724 + struct _vx_space *space = &vxi->space[index];
15726 + nsproxy = xchg(&space->vx_nsproxy, NULL);
15728 + put_nsproxy(nsproxy);
15730 + fs = xchg(&space->vx_fs, NULL);
15731 + spin_lock(&fs->lock);
15732 + kill = !--fs->users;
15733 + spin_unlock(&fs->lock);
15735 + free_fs_struct(fs);
15737 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
15739 + abort_creds(cred);
15743 +/* exported stuff */
15745 +void free_vx_info(struct vx_info *vxi)
15747 + unsigned long flags;
15750 + /* check for reference counts first */
15751 + BUG_ON(atomic_read(&vxi->vx_usecnt));
15752 + BUG_ON(atomic_read(&vxi->vx_tasks));
15754 + /* context must not be hashed */
15755 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
15757 + /* context shutdown is mandatory */
15758 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
15760 + /* spaces check */
15761 + for (index = 0; index < VX_SPACES; index++) {
15762 + struct _vx_space *space = &vxi->space[index];
15764 + BUG_ON(space->vx_nsproxy);
15765 + BUG_ON(space->vx_fs);
15766 + // BUG_ON(space->vx_real_cred);
15767 + // BUG_ON(space->vx_cred);
15770 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
15771 + hlist_del(&vxi->vx_hlist);
15772 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
15774 + __dealloc_vx_info(vxi);
15778 +/* hash table for vx_info hash */
15780 +#define VX_HASH_SIZE 13
15782 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
15783 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
15785 +static DEFINE_SPINLOCK(vx_info_hash_lock);
15788 +static inline unsigned int __hashval(xid_t xid)
15790 + return (xid % VX_HASH_SIZE);
15795 +/* __hash_vx_info()
15797 + * add the vxi to the global hash table
15798 + * requires the hash_lock to be held */
15800 +static inline void __hash_vx_info(struct vx_info *vxi)
15802 + struct hlist_head *head;
15804 + vxd_assert_lock(&vx_info_hash_lock);
15805 + vxdprintk(VXD_CBIT(xid, 4),
15806 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
15807 + vxh_hash_vx_info(vxi);
15809 + /* context must not be hashed */
15810 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
15812 + vxi->vx_state |= VXS_HASHED;
15813 + head = &vx_info_hash[__hashval(vxi->vx_id)];
15814 + hlist_add_head(&vxi->vx_hlist, head);
15815 + atomic_inc(&vx_global_cactive);
15818 +/* __unhash_vx_info()
15820 + * remove the vxi from the global hash table
15821 + * requires the hash_lock to be held */
15823 +static inline void __unhash_vx_info(struct vx_info *vxi)
15825 + unsigned long flags;
15827 + vxd_assert_lock(&vx_info_hash_lock);
15828 + vxdprintk(VXD_CBIT(xid, 4),
15829 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
15830 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
15831 + vxh_unhash_vx_info(vxi);
15833 + /* context must be hashed */
15834 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
15835 + /* but without tasks */
15836 + BUG_ON(atomic_read(&vxi->vx_tasks));
15838 + vxi->vx_state &= ~VXS_HASHED;
15839 + hlist_del_init(&vxi->vx_hlist);
15840 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
15841 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
15842 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
15843 + atomic_dec(&vx_global_cactive);
15847 +/* __lookup_vx_info()
15849 + * requires the hash_lock to be held
15850 + * doesn't increment the vx_refcnt */
15852 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
15854 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
15855 + struct hlist_node *pos;
15856 + struct vx_info *vxi;
15858 + vxd_assert_lock(&vx_info_hash_lock);
15859 + hlist_for_each(pos, head) {
15860 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
15862 + if (vxi->vx_id == xid)
15867 + vxdprintk(VXD_CBIT(xid, 0),
15868 + "__lookup_vx_info(#%u): %p[#%u]",
15869 + xid, vxi, vxi ? vxi->vx_id : 0);
15870 + vxh_lookup_vx_info(vxi, xid);
15875 +/* __create_vx_info()
15877 + * create the requested context
15878 + * get(), claim() and hash it */
15880 +static struct vx_info *__create_vx_info(int id)
15882 + struct vx_info *new, *vxi = NULL;
15884 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
15886 + if (!(new = __alloc_vx_info(id)))
15887 + return ERR_PTR(-ENOMEM);
15889 + /* required to make dynamic xids unique */
15890 + spin_lock(&vx_info_hash_lock);
15892 + /* static context requested */
15893 + if ((vxi = __lookup_vx_info(id))) {
15894 + vxdprintk(VXD_CBIT(xid, 0),
15895 + "create_vx_info(%d) = %p (already there)", id, vxi);
15896 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
15897 + vxi = ERR_PTR(-EBUSY);
15899 + vxi = ERR_PTR(-EEXIST);
15902 + /* new context */
15903 + vxdprintk(VXD_CBIT(xid, 0),
15904 + "create_vx_info(%d) = %p (new)", id, new);
15905 + claim_vx_info(new, NULL);
15906 + __hash_vx_info(get_vx_info(new));
15907 + vxi = new, new = NULL;
15910 + spin_unlock(&vx_info_hash_lock);
15911 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
15913 + __dealloc_vx_info(new);
15918 +/* exported stuff */
15921 +void unhash_vx_info(struct vx_info *vxi)
15923 + spin_lock(&vx_info_hash_lock);
15924 + __unhash_vx_info(vxi);
15925 + spin_unlock(&vx_info_hash_lock);
15926 + __shutdown_vx_info(vxi);
15927 + __wakeup_vx_info(vxi);
15931 +/* lookup_vx_info()
15933 + * search for a vx_info and get() it
15934 + * negative id means current */
15936 +struct vx_info *lookup_vx_info(int id)
15938 + struct vx_info *vxi = NULL;
15941 + vxi = get_vx_info(current_vx_info());
15942 + } else if (id > 1) {
15943 + spin_lock(&vx_info_hash_lock);
15944 + vxi = get_vx_info(__lookup_vx_info(id));
15945 + spin_unlock(&vx_info_hash_lock);
15950 +/* xid_is_hashed()
15952 + * verify that xid is still hashed */
15954 +int xid_is_hashed(xid_t xid)
15958 + spin_lock(&vx_info_hash_lock);
15959 + hashed = (__lookup_vx_info(xid) != NULL);
15960 + spin_unlock(&vx_info_hash_lock);
15964 +#ifdef CONFIG_PROC_FS
15968 + * get a subset of hashed xids for proc
15969 + * assumes size is at least one */
15971 +int get_xid_list(int index, unsigned int *xids, int size)
15973 + int hindex, nr_xids = 0;
15975 + /* only show current and children */
15976 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
15979 + xids[nr_xids] = vx_current_xid();
15983 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
15984 + struct hlist_head *head = &vx_info_hash[hindex];
15985 + struct hlist_node *pos;
15987 + spin_lock(&vx_info_hash_lock);
15988 + hlist_for_each(pos, head) {
15989 + struct vx_info *vxi;
15994 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
15995 + xids[nr_xids] = vxi->vx_id;
15996 + if (++nr_xids >= size) {
15997 + spin_unlock(&vx_info_hash_lock);
16001 + /* keep the lock time short */
16002 + spin_unlock(&vx_info_hash_lock);
16009 +#ifdef CONFIG_VSERVER_DEBUG
16011 +void dump_vx_info_inactive(int level)
16013 + struct hlist_node *entry, *next;
16015 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16016 + struct vx_info *vxi =
16017 + list_entry(entry, struct vx_info, vx_hlist);
16019 + dump_vx_info(vxi, level);
16026 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16028 + struct user_struct *new_user, *old_user;
16033 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16036 + new_user = alloc_uid(vxi->vx_id, p->uid);
16040 + old_user = p->user;
16041 + if (new_user != old_user) {
16042 + atomic_inc(&new_user->processes);
16043 + atomic_dec(&old_user->processes);
16044 + p->user = new_user;
16046 + free_uid(old_user);
16052 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16054 + // p->cap_effective &= vxi->vx_cap_bset;
16055 + p->cap_effective =
16056 + cap_intersect(p->cap_effective, vxi->cap_bset);
16057 + // p->cap_inheritable &= vxi->vx_cap_bset;
16058 + p->cap_inheritable =
16059 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16060 + // p->cap_permitted &= vxi->vx_cap_bset;
16061 + p->cap_permitted =
16062 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16067 +#include <linux/file.h>
16068 +#include <linux/fdtable.h>
16070 +static int vx_openfd_task(struct task_struct *tsk)
16072 + struct files_struct *files = tsk->files;
16073 + struct fdtable *fdt;
16074 + const unsigned long *bptr;
16075 + int count, total;
16077 + /* no rcu_read_lock() because of spin_lock() */
16078 + spin_lock(&files->file_lock);
16079 + fdt = files_fdtable(files);
16080 + bptr = fdt->open_fds;
16081 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16082 + for (total = 0; count > 0; count--) {
16084 + total += hweight_long(*bptr);
16087 + spin_unlock(&files->file_lock);
16092 +/* for *space compatibility */
16094 +asmlinkage long sys_unshare(unsigned long);
16097 + * migrate task to new context
16098 + * gets vxi, puts old_vxi on change
16099 + * optionally unshares namespaces (hack)
16102 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16104 + struct vx_info *old_vxi;
16110 + vxdprintk(VXD_CBIT(xid, 5),
16111 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16112 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16114 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16115 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16118 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16121 + old_vxi = task_get_vx_info(p);
16122 + if (old_vxi == vxi)
16125 +// if (!(ret = vx_migrate_user(p, vxi))) {
16130 + openfd = vx_openfd_task(p);
16133 + atomic_dec(&old_vxi->cvirt.nr_threads);
16134 + atomic_dec(&old_vxi->cvirt.nr_running);
16135 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16136 + /* FIXME: what about the struct files here? */
16137 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16138 + /* account for the executable */
16139 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16141 + atomic_inc(&vxi->cvirt.nr_threads);
16142 + atomic_inc(&vxi->cvirt.nr_running);
16143 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16144 + /* FIXME: what about the struct files here? */
16145 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16146 + /* account for the executable */
16147 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16150 + release_vx_info(old_vxi, p);
16151 + clr_vx_info(&p->vx_info);
16153 + claim_vx_info(vxi, p);
16154 + set_vx_info(&p->vx_info, vxi);
16155 + p->xid = vxi->vx_id;
16157 + vxdprintk(VXD_CBIT(xid, 5),
16158 + "moved task %p into vxi:%p[#%d]",
16159 + p, vxi, vxi->vx_id);
16161 + // vx_mask_cap_bset(vxi, p);
16164 + /* hack for *spaces to provide compatibility */
16166 + struct nsproxy *old_nsp, *new_nsp;
16168 + ret = unshare_nsproxy_namespaces(
16169 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16174 + old_nsp = xchg(&p->nsproxy, new_nsp);
16175 + vx_set_space(vxi,
16176 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16177 + put_nsproxy(old_nsp);
16181 + put_vx_info(old_vxi);
16185 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16187 + struct task_struct *old_reaper;
16188 + struct vx_info *reaper_vxi;
16193 + vxdprintk(VXD_CBIT(xid, 6),
16194 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16195 + vxi, vxi->vx_id, p, p->xid, p->pid);
16197 + old_reaper = vxi->vx_reaper;
16198 + if (old_reaper == p)
16201 + reaper_vxi = task_get_vx_info(p);
16202 + if (reaper_vxi && reaper_vxi != vxi) {
16204 + "Unsuitable reaper [" VS_Q("%s") ",%u:#%u] "
16206 + p->comm, p->pid, p->xid, vx_current_xid());
16210 + /* set new child reaper */
16211 + get_task_struct(p);
16212 + vxi->vx_reaper = p;
16213 + put_task_struct(old_reaper);
16215 + put_vx_info(reaper_vxi);
16219 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16224 + vxdprintk(VXD_CBIT(xid, 6),
16225 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16226 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16228 + vxi->vx_flags &= ~VXF_STATE_INIT;
16229 + // vxi->vx_initpid = p->tgid;
16230 + vxi->vx_initpid = p->pid;
16234 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16236 + vxdprintk(VXD_CBIT(xid, 6),
16237 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16238 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16240 + vxi->exit_code = code;
16241 + vxi->vx_initpid = 0;
16245 +void vx_set_persistent(struct vx_info *vxi)
16247 + vxdprintk(VXD_CBIT(xid, 6),
16248 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16250 + get_vx_info(vxi);
16251 + claim_vx_info(vxi, NULL);
16254 +void vx_clear_persistent(struct vx_info *vxi)
16256 + vxdprintk(VXD_CBIT(xid, 6),
16257 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16259 + release_vx_info(vxi, NULL);
16260 + put_vx_info(vxi);
16263 +void vx_update_persistent(struct vx_info *vxi)
16265 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16266 + vx_set_persistent(vxi);
16268 + vx_clear_persistent(vxi);
16272 +/* task must be current or locked */
16274 +void exit_vx_info(struct task_struct *p, int code)
16276 + struct vx_info *vxi = p->vx_info;
16279 + atomic_dec(&vxi->cvirt.nr_threads);
16282 + vxi->exit_code = code;
16283 + release_vx_info(vxi, p);
16287 +void exit_vx_info_early(struct task_struct *p, int code)
16289 + struct vx_info *vxi = p->vx_info;
16292 + if (vxi->vx_initpid == p->pid)
16293 + vx_exit_init(vxi, p, code);
16294 + if (vxi->vx_reaper == p)
16295 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16300 +/* vserver syscall commands below here */
16302 +/* taks xid and vx_info functions */
16304 +#include <asm/uaccess.h>
16307 +int vc_task_xid(uint32_t id)
16312 + struct task_struct *tsk;
16315 + tsk = find_task_by_real_pid(id);
16316 + xid = (tsk) ? tsk->xid : -ESRCH;
16317 + rcu_read_unlock();
16319 + xid = vx_current_xid();
16324 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16326 + struct vcmd_vx_info_v0 vc_data;
16328 + vc_data.xid = vxi->vx_id;
16329 + vc_data.initpid = vxi->vx_initpid;
16331 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16337 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16339 + struct vcmd_ctx_stat_v0 vc_data;
16341 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16342 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16344 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16350 +/* context functions */
16352 +int vc_ctx_create(uint32_t xid, void __user *data)
16354 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16355 + struct vx_info *new_vxi;
16358 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16361 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16364 + new_vxi = __create_vx_info(xid);
16365 + if (IS_ERR(new_vxi))
16366 + return PTR_ERR(new_vxi);
16368 + /* initial flags */
16369 + new_vxi->vx_flags = vc_data.flagword;
16372 + if (vs_state_change(new_vxi, VSC_STARTUP))
16375 + ret = vx_migrate_task(current, new_vxi, (!data));
16379 + /* return context id on success */
16380 + ret = new_vxi->vx_id;
16382 + /* get a reference for persistent contexts */
16383 + if ((vc_data.flagword & VXF_PERSISTENT))
16384 + vx_set_persistent(new_vxi);
16386 + release_vx_info(new_vxi, NULL);
16387 + put_vx_info(new_vxi);
16392 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16394 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16397 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16400 + ret = vx_migrate_task(current, vxi, 0);
16403 + if (vc_data.flagword & VXM_SET_INIT)
16404 + ret = vx_set_init(vxi, current);
16407 + if (vc_data.flagword & VXM_SET_REAPER)
16408 + ret = vx_set_reaper(vxi, current);
16413 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
16415 + struct vcmd_ctx_flags_v0 vc_data;
16417 + vc_data.flagword = vxi->vx_flags;
16419 + /* special STATE flag handling */
16420 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
16422 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16427 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
16429 + struct vcmd_ctx_flags_v0 vc_data;
16430 + uint64_t mask, trigger;
16432 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16435 + /* special STATE flag handling */
16436 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
16437 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
16439 + if (vxi == current_vx_info()) {
16440 + /* if (trigger & VXF_STATE_SETUP)
16441 + vx_mask_cap_bset(vxi, current); */
16442 + if (trigger & VXF_STATE_INIT) {
16445 + ret = vx_set_init(vxi, current);
16448 + ret = vx_set_reaper(vxi, current);
16454 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
16455 + vc_data.flagword, mask);
16456 + if (trigger & VXF_PERSISTENT)
16457 + vx_update_persistent(vxi);
16463 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
16465 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
16467 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
16471 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
16473 + kernel_cap_t c = __cap_empty_set;
16475 + c.cap[0] = v & 0xFFFFFFFF;
16476 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
16478 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
16483 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
16486 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
16488 + *ccaps = vxi->vx_ccaps;
16493 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
16495 + struct vcmd_ctx_caps_v1 vc_data;
16498 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
16501 + vc_data.cmask = ~0ULL;
16503 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16508 +static int do_set_caps(struct vx_info *vxi,
16509 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
16511 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
16514 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
16515 + bcaps, bmask, ccaps, cmask);
16517 + vxi->vx_bcaps = cap_t_from_caps(
16518 + vs_mask_flags(bcold, bcaps, bmask));
16519 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
16524 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
16526 + struct vcmd_ctx_caps_v1 vc_data;
16528 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16531 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
16534 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
16536 + struct vcmd_bcaps vc_data;
16539 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
16542 + vc_data.bmask = ~0ULL;
16544 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16549 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
16551 + struct vcmd_bcaps vc_data;
16553 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16556 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
16560 +int vc_get_umask(struct vx_info *vxi, void __user *data)
16562 + struct vcmd_umask vc_data;
16564 + vc_data.umask = vxi->vx_umask;
16565 + vc_data.mask = ~0ULL;
16567 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16572 +int vc_set_umask(struct vx_info *vxi, void __user *data)
16574 + struct vcmd_umask vc_data;
16576 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16579 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
16580 + vc_data.umask, vc_data.mask);
16585 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
16587 + struct vcmd_wmask vc_data;
16589 + vc_data.wmask = vxi->vx_wmask;
16590 + vc_data.mask = ~0ULL;
16592 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16597 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
16599 + struct vcmd_wmask vc_data;
16601 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16604 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
16605 + vc_data.wmask, vc_data.mask);
16610 +int vc_get_badness(struct vx_info *vxi, void __user *data)
16612 + struct vcmd_badness_v0 vc_data;
16614 + vc_data.bias = vxi->vx_badness_bias;
16616 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16621 +int vc_set_badness(struct vx_info *vxi, void __user *data)
16623 + struct vcmd_badness_v0 vc_data;
16625 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16628 + vxi->vx_badness_bias = vc_data.bias;
16632 +#include <linux/module.h>
16634 +EXPORT_SYMBOL_GPL(free_vx_info);
16636 diff -NurpP --minimal linux-3.6/kernel/vserver/cvirt.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/cvirt.c
16637 --- linux-3.6/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
16638 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/cvirt.c 2012-10-04 18:47:00.000000000 +0200
16641 + * linux/kernel/vserver/cvirt.c
16643 + * Virtual Server: Context Virtualization
16645 + * Copyright (C) 2004-2007 Herbert Pötzl
16647 + * V0.01 broken out from limit.c
16648 + * V0.02 added utsname stuff
16649 + * V0.03 changed vcmds to vxi arg
16653 +#include <linux/types.h>
16654 +#include <linux/utsname.h>
16655 +#include <linux/vs_cvirt.h>
16656 +#include <linux/vserver/switch.h>
16657 +#include <linux/vserver/cvirt_cmd.h>
16659 +#include <asm/uaccess.h>
16662 +void vx_vsi_boottime(struct timespec *boottime)
16664 + struct vx_info *vxi = current_vx_info();
16666 + set_normalized_timespec(boottime,
16667 + boottime->tv_sec + vxi->cvirt.bias_uptime.tv_sec,
16668 + boottime->tv_nsec + vxi->cvirt.bias_uptime.tv_nsec);
16672 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
16674 + struct vx_info *vxi = current_vx_info();
16676 + set_normalized_timespec(uptime,
16677 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
16678 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
16681 + set_normalized_timespec(idle,
16682 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
16683 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
16687 +uint64_t vx_idle_jiffies(void)
16689 + return init_task.utime + init_task.stime;
16694 +static inline uint32_t __update_loadavg(uint32_t load,
16695 + int wsize, int delta, int n)
16697 + unsigned long long calc, prev;
16699 + /* just set it to n */
16700 + if (unlikely(delta >= wsize))
16701 + return (n << FSHIFT);
16703 + calc = delta * n;
16705 + prev = (wsize - delta);
16708 + do_div(calc, wsize);
16713 +void vx_update_load(struct vx_info *vxi)
16715 + uint32_t now, last, delta;
16716 + unsigned int nr_running, nr_uninterruptible;
16717 + unsigned int total;
16718 + unsigned long flags;
16720 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
16723 + last = vxi->cvirt.load_last;
16724 + delta = now - last;
16726 + if (delta < 5*HZ)
16729 + nr_running = atomic_read(&vxi->cvirt.nr_running);
16730 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
16731 + total = nr_running + nr_uninterruptible;
16733 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
16734 + 60*HZ, delta, total);
16735 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
16736 + 5*60*HZ, delta, total);
16737 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
16738 + 15*60*HZ, delta, total);
16740 + vxi->cvirt.load_last = now;
16742 + atomic_inc(&vxi->cvirt.load_updates);
16743 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
16748 + * Commands to do_syslog:
16750 + * 0 -- Close the log. Currently a NOP.
16751 + * 1 -- Open the log. Currently a NOP.
16752 + * 2 -- Read from the log.
16753 + * 3 -- Read all messages remaining in the ring buffer.
16754 + * 4 -- Read and clear all messages remaining in the ring buffer
16755 + * 5 -- Clear ring buffer.
16756 + * 6 -- Disable printk's to console
16757 + * 7 -- Enable printk's to console
16758 + * 8 -- Set level of messages printed to console
16759 + * 9 -- Return number of unread characters in the log buffer
16760 + * 10 -- Return size of the log buffer
16762 +int vx_do_syslog(int type, char __user *buf, int len)
16765 + int do_clear = 0;
16766 + struct vx_info *vxi = current_vx_info();
16767 + struct _vx_syslog *log;
16771 + log = &vxi->cvirt.syslog;
16774 + case 0: /* Close log */
16775 + case 1: /* Open log */
16777 + case 2: /* Read from log */
16778 + error = wait_event_interruptible(log->log_wait,
16779 + (log->log_start - log->log_end));
16782 + spin_lock_irq(&log->logbuf_lock);
16783 + spin_unlock_irq(&log->logbuf_lock);
16785 + case 4: /* Read/clear last kernel messages */
16787 + /* fall through */
16788 + case 3: /* Read last kernel messages */
16791 + case 5: /* Clear ring buffer */
16794 + case 6: /* Disable logging to console */
16795 + case 7: /* Enable logging to console */
16796 + case 8: /* Set level of messages printed to console */
16799 + case 9: /* Number of chars in the log buffer */
16801 + case 10: /* Size of the log buffer */
16811 +/* virtual host info names */
16813 +static char *vx_vhi_name(struct vx_info *vxi, int id)
16815 + struct nsproxy *nsproxy;
16816 + struct uts_namespace *uts;
16818 + if (id == VHIN_CONTEXT)
16819 + return vxi->vx_name;
16821 + nsproxy = vxi->space[0].vx_nsproxy;
16825 + uts = nsproxy->uts_ns;
16830 + case VHIN_SYSNAME:
16831 + return uts->name.sysname;
16832 + case VHIN_NODENAME:
16833 + return uts->name.nodename;
16834 + case VHIN_RELEASE:
16835 + return uts->name.release;
16836 + case VHIN_VERSION:
16837 + return uts->name.version;
16838 + case VHIN_MACHINE:
16839 + return uts->name.machine;
16840 + case VHIN_DOMAINNAME:
16841 + return uts->name.domainname;
16848 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
16850 + struct vcmd_vhi_name_v0 vc_data;
16853 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16856 + name = vx_vhi_name(vxi, vc_data.field);
16860 + memcpy(name, vc_data.name, 65);
16864 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
16866 + struct vcmd_vhi_name_v0 vc_data;
16869 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16872 + name = vx_vhi_name(vxi, vc_data.field);
16876 + memcpy(vc_data.name, name, 65);
16877 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16883 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
16885 + struct vcmd_virt_stat_v0 vc_data;
16886 + struct _vx_cvirt *cvirt = &vxi->cvirt;
16887 + struct timespec uptime;
16889 + do_posix_clock_monotonic_gettime(&uptime);
16890 + set_normalized_timespec(&uptime,
16891 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
16892 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
16894 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
16895 + vc_data.uptime = timespec_to_ns(&uptime);
16896 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
16897 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
16898 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
16899 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
16900 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
16901 + vc_data.load[0] = cvirt->load[0];
16902 + vc_data.load[1] = cvirt->load[1];
16903 + vc_data.load[2] = cvirt->load[2];
16905 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16911 +#ifdef CONFIG_VSERVER_VTIME
16913 +/* virtualized time base */
16915 +void vx_adjust_timespec(struct timespec *ts)
16917 + struct vx_info *vxi;
16919 + if (!vx_flags(VXF_VIRT_TIME, 0))
16922 + vxi = current_vx_info();
16923 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
16924 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
16926 + if (ts->tv_nsec >= NSEC_PER_SEC) {
16928 + ts->tv_nsec -= NSEC_PER_SEC;
16929 + } else if (ts->tv_nsec < 0) {
16931 + ts->tv_nsec += NSEC_PER_SEC;
16935 +int vx_settimeofday(const struct timespec *ts)
16937 + struct timespec ats, delta;
16938 + struct vx_info *vxi;
16940 + if (!vx_flags(VXF_VIRT_TIME, 0))
16941 + return do_settimeofday(ts);
16943 + getnstimeofday(&ats);
16944 + delta = timespec_sub(*ts, ats);
16946 + vxi = current_vx_info();
16947 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
16953 diff -NurpP --minimal linux-3.6/kernel/vserver/cvirt_init.h linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/cvirt_init.h
16954 --- linux-3.6/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
16955 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/cvirt_init.h 2012-10-04 18:47:00.000000000 +0200
16959 +extern uint64_t vx_idle_jiffies(void);
16961 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
16963 + uint64_t idle_jiffies = vx_idle_jiffies();
16964 + uint64_t nsuptime;
16966 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
16967 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
16968 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
16969 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
16970 + cvirt->bias_ts.tv_sec = 0;
16971 + cvirt->bias_ts.tv_nsec = 0;
16973 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
16974 + atomic_set(&cvirt->nr_threads, 0);
16975 + atomic_set(&cvirt->nr_running, 0);
16976 + atomic_set(&cvirt->nr_uninterruptible, 0);
16977 + atomic_set(&cvirt->nr_onhold, 0);
16979 + spin_lock_init(&cvirt->load_lock);
16980 + cvirt->load_last = jiffies;
16981 + atomic_set(&cvirt->load_updates, 0);
16982 + cvirt->load[0] = 0;
16983 + cvirt->load[1] = 0;
16984 + cvirt->load[2] = 0;
16985 + atomic_set(&cvirt->total_forks, 0);
16987 + spin_lock_init(&cvirt->syslog.logbuf_lock);
16988 + init_waitqueue_head(&cvirt->syslog.log_wait);
16989 + cvirt->syslog.log_start = 0;
16990 + cvirt->syslog.log_end = 0;
16991 + cvirt->syslog.con_start = 0;
16992 + cvirt->syslog.logged_chars = 0;
16996 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
16998 + // cvirt_pc->cpustat = { 0 };
17001 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17003 +#ifdef CONFIG_VSERVER_WARN
17006 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17007 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17009 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17010 + "!!! cvirt: %p[nr_running] = %d on exit.",
17012 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17013 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17015 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17016 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17022 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17027 diff -NurpP --minimal linux-3.6/kernel/vserver/cvirt_proc.h linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/cvirt_proc.h
17028 --- linux-3.6/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17029 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/cvirt_proc.h 2012-10-04 18:47:00.000000000 +0200
17031 +#ifndef _VX_CVIRT_PROC_H
17032 +#define _VX_CVIRT_PROC_H
17034 +#include <linux/nsproxy.h>
17035 +#include <linux/mnt_namespace.h>
17036 +#include <linux/ipc_namespace.h>
17037 +#include <linux/utsname.h>
17038 +#include <linux/ipc.h>
17040 +extern int vx_info_mnt_namespace(struct mnt_namespace *, char *);
17043 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17045 + struct mnt_namespace *ns;
17046 + struct uts_namespace *uts;
17047 + struct ipc_namespace *ipc;
17053 + length += sprintf(buffer + length,
17054 + "NSProxy:\t%p [%p,%p,%p]\n",
17055 + nsproxy, nsproxy->mnt_ns,
17056 + nsproxy->uts_ns, nsproxy->ipc_ns);
17058 + ns = nsproxy->mnt_ns;
17062 + length += vx_info_mnt_namespace(ns, buffer + length);
17066 + uts = nsproxy->uts_ns;
17070 + length += sprintf(buffer + length,
17071 + "SysName:\t%.*s\n"
17072 + "NodeName:\t%.*s\n"
17073 + "Release:\t%.*s\n"
17074 + "Version:\t%.*s\n"
17075 + "Machine:\t%.*s\n"
17076 + "DomainName:\t%.*s\n",
17077 + __NEW_UTS_LEN, uts->name.sysname,
17078 + __NEW_UTS_LEN, uts->name.nodename,
17079 + __NEW_UTS_LEN, uts->name.release,
17080 + __NEW_UTS_LEN, uts->name.version,
17081 + __NEW_UTS_LEN, uts->name.machine,
17082 + __NEW_UTS_LEN, uts->name.domainname);
17085 + ipc = nsproxy->ipc_ns;
17089 + length += sprintf(buffer + length,
17090 + "SEMS:\t\t%d %d %d %d %d\n"
17091 + "MSG:\t\t%d %d %d\n"
17092 + "SHM:\t\t%lu %lu %d %d\n",
17093 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17094 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17096 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17097 + (unsigned long)ipc->shm_ctlmax,
17098 + (unsigned long)ipc->shm_ctlall,
17099 + ipc->shm_ctlmni, ipc->shm_tot);
17106 +#include <linux/sched.h>
17108 +#define LOAD_INT(x) ((x) >> FSHIFT)
17109 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17112 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17117 + length += sprintf(buffer + length,
17118 + "BiasUptime:\t%lu.%02lu\n",
17119 + (unsigned long)cvirt->bias_uptime.tv_sec,
17120 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17122 + a = cvirt->load[0] + (FIXED_1 / 200);
17123 + b = cvirt->load[1] + (FIXED_1 / 200);
17124 + c = cvirt->load[2] + (FIXED_1 / 200);
17125 + length += sprintf(buffer + length,
17126 + "nr_threads:\t%d\n"
17127 + "nr_running:\t%d\n"
17128 + "nr_unintr:\t%d\n"
17129 + "nr_onhold:\t%d\n"
17130 + "load_updates:\t%d\n"
17131 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17132 + "total_forks:\t%d\n",
17133 + atomic_read(&cvirt->nr_threads),
17134 + atomic_read(&cvirt->nr_running),
17135 + atomic_read(&cvirt->nr_uninterruptible),
17136 + atomic_read(&cvirt->nr_onhold),
17137 + atomic_read(&cvirt->load_updates),
17138 + LOAD_INT(a), LOAD_FRAC(a),
17139 + LOAD_INT(b), LOAD_FRAC(b),
17140 + LOAD_INT(c), LOAD_FRAC(c),
17141 + atomic_read(&cvirt->total_forks));
17146 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17147 + char *buffer, int cpu)
17153 +#endif /* _VX_CVIRT_PROC_H */
17154 diff -NurpP --minimal linux-3.6/kernel/vserver/debug.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/debug.c
17155 --- linux-3.6/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17156 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/debug.c 2012-10-04 18:47:00.000000000 +0200
17159 + * kernel/vserver/debug.c
17161 + * Copyright (C) 2005-2007 Herbert Pötzl
17163 + * V0.01 vx_info dump support
17167 +#include <linux/module.h>
17169 +#include <linux/vserver/context.h>
17172 +void dump_vx_info(struct vx_info *vxi, int level)
17174 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17175 + atomic_read(&vxi->vx_usecnt),
17176 + atomic_read(&vxi->vx_tasks),
17179 + __dump_vx_limit(&vxi->limit);
17180 + __dump_vx_sched(&vxi->sched);
17181 + __dump_vx_cvirt(&vxi->cvirt);
17182 + __dump_vx_cacct(&vxi->cacct);
17188 +EXPORT_SYMBOL_GPL(dump_vx_info);
17190 diff -NurpP --minimal linux-3.6/kernel/vserver/device.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/device.c
17191 --- linux-3.6/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17192 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/device.c 2012-10-04 18:47:00.000000000 +0200
17195 + * linux/kernel/vserver/device.c
17197 + * Linux-VServer: Device Support
17199 + * Copyright (C) 2006 Herbert Pötzl
17200 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17202 + * V0.01 device mapping basics
17203 + * V0.02 added defaults
17207 +#include <linux/slab.h>
17208 +#include <linux/rcupdate.h>
17209 +#include <linux/fs.h>
17210 +#include <linux/namei.h>
17211 +#include <linux/hash.h>
17213 +#include <asm/errno.h>
17214 +#include <asm/uaccess.h>
17215 +#include <linux/vserver/base.h>
17216 +#include <linux/vserver/debug.h>
17217 +#include <linux/vserver/context.h>
17218 +#include <linux/vserver/device.h>
17219 +#include <linux/vserver/device_cmd.h>
17222 +#define DMAP_HASH_BITS 4
17225 +struct vs_mapping {
17227 + struct hlist_node hlist;
17228 + struct list_head list;
17230 +#define dm_hlist u.hlist
17231 +#define dm_list u.list
17234 + struct vx_dmap_target target;
17238 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17240 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17242 +static struct vx_dmap_target dmap_defaults[2] = {
17243 + { .flags = DATTR_OPEN },
17244 + { .flags = DATTR_OPEN },
17248 +struct kmem_cache *dmap_cachep __read_mostly;
17250 +int __init dmap_cache_init(void)
17252 + dmap_cachep = kmem_cache_create("dmap_cache",
17253 + sizeof(struct vs_mapping), 0,
17254 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17258 +__initcall(dmap_cache_init);
17261 +static inline unsigned int __hashval(dev_t dev, int bits)
17263 + return hash_long((unsigned long)dev, bits);
17267 +/* __hash_mapping()
17268 + * add the mapping to the hash table
17270 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17272 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17273 + struct hlist_head *head, *hash = dmap_main_hash;
17274 + int device = vdm->device;
17276 + spin_lock(hash_lock);
17277 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17278 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17280 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17281 + hlist_add_head(&vdm->dm_hlist, head);
17282 + spin_unlock(hash_lock);
17286 +static inline int __mode_to_default(umode_t mode)
17299 +/* __set_default()
17302 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17303 + struct vx_dmap_target *vdmt)
17305 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17306 + spin_lock(hash_lock);
17309 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17311 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17314 + spin_unlock(hash_lock);
17316 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17317 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17321 +/* __remove_default()
17322 + * remove a default
17324 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17326 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17327 + spin_lock(hash_lock);
17330 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17331 + else /* remove == reset */
17332 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17334 + spin_unlock(hash_lock);
17339 +/* __find_mapping()
17340 + * find a mapping in the hash table
17342 + * caller must hold hash_lock
17344 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17345 + struct vs_mapping **local, struct vs_mapping **global)
17347 + struct hlist_head *hash = dmap_main_hash;
17348 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17349 + struct hlist_node *pos;
17350 + struct vs_mapping *vdm;
17356 + hlist_for_each(pos, head) {
17357 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17359 + if ((vdm->device == device) &&
17360 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17361 + if (vdm->xid == xid) {
17364 + } else if (global && vdm->xid == 0)
17369 + if (global && *global)
17376 +/* __lookup_mapping()
17377 + * find a mapping and store the result in target and flags
17379 +static inline int __lookup_mapping(struct vx_info *vxi,
17380 + dev_t device, dev_t *target, int *flags, umode_t mode)
17382 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17383 + struct vs_mapping *vdm, *global;
17384 + struct vx_dmap_target *vdmt;
17386 + xid_t xid = vxi->vx_id;
17389 + spin_lock(hash_lock);
17390 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17392 + vdmt = &vdm->target;
17396 + index = __mode_to_default(mode);
17397 + if (vxi && vxi->dmap.targets[index].flags) {
17399 + vdmt = &vxi->dmap.targets[index];
17400 + } else if (global) {
17402 + vdmt = &global->target;
17406 + vdmt = &dmap_defaults[index];
17410 + if (target && (vdmt->flags & DATTR_REMAP))
17411 + *target = vdmt->target;
17413 + *target = device;
17415 + *flags = vdmt->flags;
17417 + spin_unlock(hash_lock);
17423 +/* __remove_mapping()
17424 + * remove a mapping from the hash table
17426 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17429 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17430 + struct vs_mapping *vdm = NULL;
17433 + spin_lock(hash_lock);
17435 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17437 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
17438 + vxi, vxi ? vxi->vx_id : 0, device, mode);
17441 + hlist_del(&vdm->dm_hlist);
17444 + spin_unlock(hash_lock);
17446 + kmem_cache_free(dmap_cachep, vdm);
17452 +int vs_map_device(struct vx_info *vxi,
17453 + dev_t device, dev_t *target, umode_t mode)
17455 + int ret, flags = DATTR_MASK;
17459 + *target = device;
17462 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
17463 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
17464 + device, target ? *target : 0, flags, mode, ret);
17466 + return (flags & DATTR_MASK);
17471 +static int do_set_mapping(struct vx_info *vxi,
17472 + dev_t device, dev_t target, int flags, umode_t mode)
17475 + struct vs_mapping *new;
17477 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
17481 + INIT_HLIST_NODE(&new->dm_hlist);
17482 + new->device = device;
17483 + new->target.target = target;
17484 + new->target.flags = flags | mode;
17485 + new->xid = (vxi ? vxi->vx_id : 0);
17487 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
17488 + __hash_mapping(vxi, new);
17490 + struct vx_dmap_target new = {
17491 + .target = target,
17492 + .flags = flags | mode,
17494 + __set_default(vxi, mode, &new);
17500 +static int do_unset_mapping(struct vx_info *vxi,
17501 + dev_t device, dev_t target, int flags, umode_t mode)
17503 + int ret = -EINVAL;
17506 + ret = __remove_mapping(vxi, device, mode);
17510 + ret = __remove_default(vxi, mode);
17520 +static inline int __user_device(const char __user *name, dev_t *dev,
17523 + struct nameidata nd;
17530 + ret = user_lpath(name, &nd.path);
17533 + if (nd.path.dentry->d_inode) {
17534 + *dev = nd.path.dentry->d_inode->i_rdev;
17535 + *mode = nd.path.dentry->d_inode->i_mode;
17537 + path_put(&nd.path);
17541 +static inline int __mapping_mode(dev_t device, dev_t target,
17542 + umode_t device_mode, umode_t target_mode, umode_t *mode)
17545 + *mode = device_mode & S_IFMT;
17547 + *mode = target_mode & S_IFMT;
17551 + /* if both given, device and target mode have to match */
17552 + if (device && target &&
17553 + ((device_mode ^ target_mode) & S_IFMT))
17559 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
17560 + const char __user *target_path, int flags, int set)
17562 + dev_t device = ~0, target = ~0;
17563 + umode_t device_mode = 0, target_mode = 0, mode;
17566 + ret = __user_device(device_path, &device, &device_mode);
17569 + ret = __user_device(target_path, &target, &target_mode);
17573 + ret = __mapping_mode(device, target,
17574 + device_mode, target_mode, &mode);
17579 + return do_set_mapping(vxi, device, target,
17582 + return do_unset_mapping(vxi, device, target,
17587 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
17589 + struct vcmd_set_mapping_v0 vc_data;
17591 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17594 + return do_mapping(vxi, vc_data.device, vc_data.target,
17595 + vc_data.flags, 1);
17598 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
17600 + struct vcmd_set_mapping_v0 vc_data;
17602 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17605 + return do_mapping(vxi, vc_data.device, vc_data.target,
17606 + vc_data.flags, 0);
17610 +#ifdef CONFIG_COMPAT
17612 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
17614 + struct vcmd_set_mapping_v0_x32 vc_data;
17616 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17619 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17620 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
17623 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
17625 + struct vcmd_set_mapping_v0_x32 vc_data;
17627 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17630 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17631 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
17634 +#endif /* CONFIG_COMPAT */
17637 diff -NurpP --minimal linux-3.6/kernel/vserver/dlimit.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/dlimit.c
17638 --- linux-3.6/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
17639 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/dlimit.c 2012-10-04 18:47:00.000000000 +0200
17642 + * linux/kernel/vserver/dlimit.c
17644 + * Virtual Server: Context Disk Limits
17646 + * Copyright (C) 2004-2009 Herbert Pötzl
17648 + * V0.01 initial version
17649 + * V0.02 compat32 splitup
17650 + * V0.03 extended interface
17654 +#include <linux/statfs.h>
17655 +#include <linux/sched.h>
17656 +#include <linux/namei.h>
17657 +#include <linux/vs_tag.h>
17658 +#include <linux/vs_dlimit.h>
17659 +#include <linux/vserver/dlimit_cmd.h>
17660 +#include <linux/slab.h>
17661 +// #include <linux/gfp.h>
17663 +#include <asm/uaccess.h>
17665 +/* __alloc_dl_info()
17667 + * allocate an initialized dl_info struct
17668 + * doesn't make it visible (hash) */
17670 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
17672 + struct dl_info *new = NULL;
17674 + vxdprintk(VXD_CBIT(dlim, 5),
17675 + "alloc_dl_info(%p,%d)*", sb, tag);
17677 + /* would this benefit from a slab cache? */
17678 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
17682 + memset(new, 0, sizeof(struct dl_info));
17683 + new->dl_tag = tag;
17685 + // INIT_RCU_HEAD(&new->dl_rcu);
17686 + INIT_HLIST_NODE(&new->dl_hlist);
17687 + spin_lock_init(&new->dl_lock);
17688 + atomic_set(&new->dl_refcnt, 0);
17689 + atomic_set(&new->dl_usecnt, 0);
17691 + /* rest of init goes here */
17693 + vxdprintk(VXD_CBIT(dlim, 4),
17694 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
17698 +/* __dealloc_dl_info()
17700 + * final disposal of dl_info */
17702 +static void __dealloc_dl_info(struct dl_info *dli)
17704 + vxdprintk(VXD_CBIT(dlim, 4),
17705 + "dealloc_dl_info(%p)", dli);
17707 + dli->dl_hlist.next = LIST_POISON1;
17708 + dli->dl_tag = -1;
17711 + BUG_ON(atomic_read(&dli->dl_usecnt));
17712 + BUG_ON(atomic_read(&dli->dl_refcnt));
17718 +/* hash table for dl_info hash */
17720 +#define DL_HASH_SIZE 13
17722 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
17724 +static DEFINE_SPINLOCK(dl_info_hash_lock);
17727 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
17729 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
17734 +/* __hash_dl_info()
17736 + * add the dli to the global hash table
17737 + * requires the hash_lock to be held */
17739 +static inline void __hash_dl_info(struct dl_info *dli)
17741 + struct hlist_head *head;
17743 + vxdprintk(VXD_CBIT(dlim, 6),
17744 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
17745 + get_dl_info(dli);
17746 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
17747 + hlist_add_head_rcu(&dli->dl_hlist, head);
17750 +/* __unhash_dl_info()
17752 + * remove the dli from the global hash table
17753 + * requires the hash_lock to be held */
17755 +static inline void __unhash_dl_info(struct dl_info *dli)
17757 + vxdprintk(VXD_CBIT(dlim, 6),
17758 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
17759 + hlist_del_rcu(&dli->dl_hlist);
17760 + put_dl_info(dli);
17764 +/* __lookup_dl_info()
17766 + * requires the rcu_read_lock()
17767 + * doesn't increment the dl_refcnt */
17769 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
17771 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
17772 + struct hlist_node *pos;
17773 + struct dl_info *dli;
17775 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
17777 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
17785 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
17787 + struct dl_info *dli;
17790 + dli = get_dl_info(__lookup_dl_info(sb, tag));
17791 + vxdprintk(VXD_CBIT(dlim, 7),
17792 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
17793 + rcu_read_unlock();
17797 +void rcu_free_dl_info(struct rcu_head *head)
17799 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
17800 + int usecnt, refcnt;
17802 + BUG_ON(!dli || !head);
17804 + usecnt = atomic_read(&dli->dl_usecnt);
17805 + BUG_ON(usecnt < 0);
17807 + refcnt = atomic_read(&dli->dl_refcnt);
17808 + BUG_ON(refcnt < 0);
17810 + vxdprintk(VXD_CBIT(dlim, 3),
17811 + "rcu_free_dl_info(%p)", dli);
17813 + __dealloc_dl_info(dli);
17815 + printk("!!! rcu didn't free\n");
17821 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
17822 + uint32_t flags, int add)
17824 + struct path path;
17827 + ret = user_lpath(name, &path);
17829 + struct super_block *sb;
17830 + struct dl_info *dli;
17833 + if (!path.dentry->d_inode)
17834 + goto out_release;
17835 + if (!(sb = path.dentry->d_inode->i_sb))
17836 + goto out_release;
17839 + dli = __alloc_dl_info(sb, id);
17840 + spin_lock(&dl_info_hash_lock);
17843 + if (__lookup_dl_info(sb, id))
17845 + __hash_dl_info(dli);
17848 + spin_lock(&dl_info_hash_lock);
17849 + dli = __lookup_dl_info(sb, id);
17854 + __unhash_dl_info(dli);
17858 + spin_unlock(&dl_info_hash_lock);
17860 + __dealloc_dl_info(dli);
17867 +int vc_add_dlimit(uint32_t id, void __user *data)
17869 + struct vcmd_ctx_dlimit_base_v0 vc_data;
17871 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17874 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
17877 +int vc_rem_dlimit(uint32_t id, void __user *data)
17879 + struct vcmd_ctx_dlimit_base_v0 vc_data;
17881 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17884 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
17887 +#ifdef CONFIG_COMPAT
17889 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
17891 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
17893 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17896 + return do_addrem_dlimit(id,
17897 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
17900 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
17902 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
17904 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17907 + return do_addrem_dlimit(id,
17908 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
17911 +#endif /* CONFIG_COMPAT */
17915 +int do_set_dlimit(uint32_t id, const char __user *name,
17916 + uint32_t space_used, uint32_t space_total,
17917 + uint32_t inodes_used, uint32_t inodes_total,
17918 + uint32_t reserved, uint32_t flags)
17920 + struct path path;
17923 + ret = user_lpath(name, &path);
17925 + struct super_block *sb;
17926 + struct dl_info *dli;
17929 + if (!path.dentry->d_inode)
17930 + goto out_release;
17931 + if (!(sb = path.dentry->d_inode->i_sb))
17932 + goto out_release;
17934 + /* sanity checks */
17935 + if ((reserved != CDLIM_KEEP &&
17936 + reserved > 100) ||
17937 + (inodes_used != CDLIM_KEEP &&
17938 + inodes_used > inodes_total) ||
17939 + (space_used != CDLIM_KEEP &&
17940 + space_used > space_total))
17941 + goto out_release;
17944 + dli = locate_dl_info(sb, id);
17946 + goto out_release;
17948 + spin_lock(&dli->dl_lock);
17950 + if (inodes_used != CDLIM_KEEP)
17951 + dli->dl_inodes_used = inodes_used;
17952 + if (inodes_total != CDLIM_KEEP)
17953 + dli->dl_inodes_total = inodes_total;
17954 + if (space_used != CDLIM_KEEP)
17955 + dli->dl_space_used = dlimit_space_32to64(
17956 + space_used, flags, DLIMS_USED);
17958 + if (space_total == CDLIM_INFINITY)
17959 + dli->dl_space_total = DLIM_INFINITY;
17960 + else if (space_total != CDLIM_KEEP)
17961 + dli->dl_space_total = dlimit_space_32to64(
17962 + space_total, flags, DLIMS_TOTAL);
17964 + if (reserved != CDLIM_KEEP)
17965 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
17967 + spin_unlock(&dli->dl_lock);
17969 + put_dl_info(dli);
17978 +int vc_set_dlimit(uint32_t id, void __user *data)
17980 + struct vcmd_ctx_dlimit_v0 vc_data;
17982 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17985 + return do_set_dlimit(id, vc_data.name,
17986 + vc_data.space_used, vc_data.space_total,
17987 + vc_data.inodes_used, vc_data.inodes_total,
17988 + vc_data.reserved, vc_data.flags);
17991 +#ifdef CONFIG_COMPAT
17993 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
17995 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
17997 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18000 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18001 + vc_data.space_used, vc_data.space_total,
18002 + vc_data.inodes_used, vc_data.inodes_total,
18003 + vc_data.reserved, vc_data.flags);
18006 +#endif /* CONFIG_COMPAT */
18010 +int do_get_dlimit(uint32_t id, const char __user *name,
18011 + uint32_t *space_used, uint32_t *space_total,
18012 + uint32_t *inodes_used, uint32_t *inodes_total,
18013 + uint32_t *reserved, uint32_t *flags)
18015 + struct path path;
18018 + ret = user_lpath(name, &path);
18020 + struct super_block *sb;
18021 + struct dl_info *dli;
18024 + if (!path.dentry->d_inode)
18025 + goto out_release;
18026 + if (!(sb = path.dentry->d_inode->i_sb))
18027 + goto out_release;
18030 + dli = locate_dl_info(sb, id);
18032 + goto out_release;
18034 + spin_lock(&dli->dl_lock);
18035 + *inodes_used = dli->dl_inodes_used;
18036 + *inodes_total = dli->dl_inodes_total;
18038 + *space_used = dlimit_space_64to32(
18039 + dli->dl_space_used, flags, DLIMS_USED);
18041 + if (dli->dl_space_total == DLIM_INFINITY)
18042 + *space_total = CDLIM_INFINITY;
18044 + *space_total = dlimit_space_64to32(
18045 + dli->dl_space_total, flags, DLIMS_TOTAL);
18047 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18048 + spin_unlock(&dli->dl_lock);
18050 + put_dl_info(dli);
18061 +int vc_get_dlimit(uint32_t id, void __user *data)
18063 + struct vcmd_ctx_dlimit_v0 vc_data;
18066 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18069 + ret = do_get_dlimit(id, vc_data.name,
18070 + &vc_data.space_used, &vc_data.space_total,
18071 + &vc_data.inodes_used, &vc_data.inodes_total,
18072 + &vc_data.reserved, &vc_data.flags);
18076 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18081 +#ifdef CONFIG_COMPAT
18083 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18085 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18088 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18091 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18092 + &vc_data.space_used, &vc_data.space_total,
18093 + &vc_data.inodes_used, &vc_data.inodes_total,
18094 + &vc_data.reserved, &vc_data.flags);
18098 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18103 +#endif /* CONFIG_COMPAT */
18106 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18108 + struct dl_info *dli;
18109 + __u64 blimit, bfree, bavail;
18112 + dli = locate_dl_info(sb, dx_current_tag());
18116 + spin_lock(&dli->dl_lock);
18117 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18120 + /* reduce max inodes available to limit */
18121 + if (buf->f_files > dli->dl_inodes_total)
18122 + buf->f_files = dli->dl_inodes_total;
18124 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18125 + /* reduce free inodes to min */
18126 + if (ifree < buf->f_ffree)
18127 + buf->f_ffree = ifree;
18130 + if (dli->dl_space_total == DLIM_INFINITY)
18133 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18135 + if (dli->dl_space_total < dli->dl_space_used)
18138 + bfree = (dli->dl_space_total - dli->dl_space_used)
18139 + >> sb->s_blocksize_bits;
18141 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18142 + if (bavail < dli->dl_space_used)
18145 + bavail = (bavail - dli->dl_space_used)
18146 + >> sb->s_blocksize_bits;
18148 + /* reduce max space available to limit */
18149 + if (buf->f_blocks > blimit)
18150 + buf->f_blocks = blimit;
18152 + /* reduce free space to min */
18153 + if (bfree < buf->f_bfree)
18154 + buf->f_bfree = bfree;
18156 + /* reduce avail space to min */
18157 + if (bavail < buf->f_bavail)
18158 + buf->f_bavail = bavail;
18161 + spin_unlock(&dli->dl_lock);
18162 + put_dl_info(dli);
18167 +#include <linux/module.h>
18169 +EXPORT_SYMBOL_GPL(locate_dl_info);
18170 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18172 diff -NurpP --minimal linux-3.6/kernel/vserver/helper.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/helper.c
18173 --- linux-3.6/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18174 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/helper.c 2012-10-04 18:47:00.000000000 +0200
18177 + * linux/kernel/vserver/helper.c
18179 + * Virtual Context Support
18181 + * Copyright (C) 2004-2007 Herbert Pötzl
18183 + * V0.01 basic helper
18187 +#include <linux/kmod.h>
18188 +#include <linux/reboot.h>
18189 +#include <linux/vs_context.h>
18190 +#include <linux/vs_network.h>
18191 +#include <linux/vserver/signal.h>
18194 +char vshelper_path[255] = "/sbin/vshelper";
18196 +static int vshelper_init(struct subprocess_info *info, struct cred *new_cred)
18198 + current->flags &= ~PF_THREAD_BOUND;
18202 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18206 + if ((ret = call_usermodehelper_fns(name, argv, envp,
18207 + sync ? UMH_WAIT_PROC : UMH_WAIT_EXEC,
18208 + vshelper_init, NULL, NULL))) {
18209 + printk(KERN_WARNING "%s: (%s %s) returned %s with %d\n",
18210 + name, argv[1], argv[2],
18211 + sync ? "sync" : "async", ret);
18213 + vxdprintk(VXD_CBIT(switch, 4),
18214 + "%s: (%s %s) returned %s with %d",
18215 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18220 + * vshelper path is set via /proc/sys
18221 + * invoked by vserver sys_reboot(), with
18222 + * the following arguments
18224 + * argv [0] = vshelper_path;
18225 + * argv [1] = action: "restart", "halt", "poweroff", ...
18226 + * argv [2] = context identifier
18228 + * envp [*] = type-specific parameters
18231 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18233 + char id_buf[8], cmd_buf[16];
18234 + char uid_buf[16], pid_buf[16];
18237 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18238 + char *envp[] = {"HOME=/", "TERM=linux",
18239 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18240 + uid_buf, pid_buf, cmd_buf, 0};
18242 + if (vx_info_state(vxi, VXS_HELPER))
18244 + vxi->vx_state |= VXS_HELPER;
18246 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18248 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18249 + snprintf(uid_buf, sizeof(uid_buf), "VS_UID=%d", current_uid());
18250 + snprintf(pid_buf, sizeof(pid_buf), "VS_PID=%d", current->pid);
18253 + case LINUX_REBOOT_CMD_RESTART:
18254 + argv[1] = "restart";
18257 + case LINUX_REBOOT_CMD_HALT:
18258 + argv[1] = "halt";
18261 + case LINUX_REBOOT_CMD_POWER_OFF:
18262 + argv[1] = "poweroff";
18265 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18266 + argv[1] = "swsusp";
18269 + case LINUX_REBOOT_CMD_OOM:
18274 + vxi->vx_state &= ~VXS_HELPER;
18278 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18279 + vxi->vx_state &= ~VXS_HELPER;
18280 + __wakeup_vx_info(vxi);
18281 + return (ret) ? -EPERM : 0;
18285 +long vs_reboot(unsigned int cmd, void __user *arg)
18287 + struct vx_info *vxi = current_vx_info();
18290 + vxdprintk(VXD_CBIT(misc, 5),
18291 + "vs_reboot(%p[#%d],%u)",
18292 + vxi, vxi ? vxi->vx_id : 0, cmd);
18294 + ret = vs_reboot_helper(vxi, cmd, arg);
18298 + vxi->reboot_cmd = cmd;
18299 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18301 + case LINUX_REBOOT_CMD_RESTART:
18302 + case LINUX_REBOOT_CMD_HALT:
18303 + case LINUX_REBOOT_CMD_POWER_OFF:
18304 + vx_info_kill(vxi, 0, SIGKILL);
18305 + vx_info_kill(vxi, 1, SIGKILL);
18313 +long vs_oom_action(unsigned int cmd)
18315 + struct vx_info *vxi = current_vx_info();
18318 + vxdprintk(VXD_CBIT(misc, 5),
18319 + "vs_oom_action(%p[#%d],%u)",
18320 + vxi, vxi ? vxi->vx_id : 0, cmd);
18322 + ret = vs_reboot_helper(vxi, cmd, NULL);
18326 + vxi->reboot_cmd = cmd;
18327 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18328 + vx_info_kill(vxi, 0, SIGKILL);
18329 + vx_info_kill(vxi, 1, SIGKILL);
18335 + * argv [0] = vshelper_path;
18336 + * argv [1] = action: "startup", "shutdown"
18337 + * argv [2] = context identifier
18339 + * envp [*] = type-specific parameters
18342 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18344 + char id_buf[8], cmd_buf[16];
18345 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18346 + char *envp[] = {"HOME=/", "TERM=linux",
18347 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18349 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18352 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18353 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18356 + case VSC_STARTUP:
18357 + argv[1] = "startup";
18359 + case VSC_SHUTDOWN:
18360 + argv[1] = "shutdown";
18366 + return do_vshelper(vshelper_path, argv, envp, 1);
18371 + * argv [0] = vshelper_path;
18372 + * argv [1] = action: "netup", "netdown"
18373 + * argv [2] = context identifier
18375 + * envp [*] = type-specific parameters
18378 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18380 + char id_buf[8], cmd_buf[16];
18381 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18382 + char *envp[] = {"HOME=/", "TERM=linux",
18383 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18385 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18388 + snprintf(id_buf, sizeof(id_buf), "%d", nxi->nx_id);
18389 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18393 + argv[1] = "netup";
18395 + case VSC_NETDOWN:
18396 + argv[1] = "netdown";
18402 + return do_vshelper(vshelper_path, argv, envp, 1);
18405 diff -NurpP --minimal linux-3.6/kernel/vserver/history.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/history.c
18406 --- linux-3.6/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
18407 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/history.c 2012-10-04 18:47:00.000000000 +0200
18410 + * kernel/vserver/history.c
18412 + * Virtual Context History Backtrace
18414 + * Copyright (C) 2004-2007 Herbert Pötzl
18416 + * V0.01 basic structure
18417 + * V0.02 hash/unhash and trace
18418 + * V0.03 preemption fixes
18422 +#include <linux/module.h>
18423 +#include <asm/uaccess.h>
18425 +#include <linux/vserver/context.h>
18426 +#include <linux/vserver/debug.h>
18427 +#include <linux/vserver/debug_cmd.h>
18428 +#include <linux/vserver/history.h>
18431 +#ifdef CONFIG_VSERVER_HISTORY
18432 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18434 +#define VXH_SIZE 64
18437 +struct _vx_history {
18438 + unsigned int counter;
18440 + struct _vx_hist_entry entry[VXH_SIZE + 1];
18444 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
18446 +unsigned volatile int vxh_active = 1;
18448 +static atomic_t sequence = ATOMIC_INIT(0);
18453 + * requires disabled preemption */
18455 +struct _vx_hist_entry *vxh_advance(void *loc)
18457 + unsigned int cpu = smp_processor_id();
18458 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18459 + struct _vx_hist_entry *entry;
18460 + unsigned int index;
18462 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
18463 + entry = &hist->entry[index];
18465 + entry->seq = atomic_inc_return(&sequence);
18466 + entry->loc = loc;
18470 +EXPORT_SYMBOL_GPL(vxh_advance);
18473 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
18475 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
18478 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
18480 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
18481 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
18482 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
18483 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
18485 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
18487 + switch (e->type) {
18488 + case VXH_THROW_OOPS:
18489 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
18492 + case VXH_GET_VX_INFO:
18493 + case VXH_PUT_VX_INFO:
18494 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18496 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
18497 + VXH_VXI_ARGS(e));
18500 + case VXH_INIT_VX_INFO:
18501 + case VXH_SET_VX_INFO:
18502 + case VXH_CLR_VX_INFO:
18503 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18505 + (e->type == VXH_INIT_VX_INFO) ? "init" :
18506 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
18507 + VXH_VXI_ARGS(e), e->sc.data);
18510 + case VXH_CLAIM_VX_INFO:
18511 + case VXH_RELEASE_VX_INFO:
18512 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18514 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
18515 + VXH_VXI_ARGS(e), e->sc.data);
18518 + case VXH_ALLOC_VX_INFO:
18519 + case VXH_DEALLOC_VX_INFO:
18520 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18522 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
18523 + VXH_VXI_ARGS(e));
18526 + case VXH_HASH_VX_INFO:
18527 + case VXH_UNHASH_VX_INFO:
18528 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
18530 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
18531 + VXH_VXI_ARGS(e));
18534 + case VXH_LOC_VX_INFO:
18535 + case VXH_LOOKUP_VX_INFO:
18536 + case VXH_CREATE_VX_INFO:
18537 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
18539 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
18540 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
18541 + e->ll.arg, VXH_VXI_ARGS(e));
18546 +static void __vxh_dump_history(void)
18548 + unsigned int i, cpu;
18550 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
18551 + atomic_read(&sequence), NR_CPUS);
18553 + for (i = 0; i < VXH_SIZE; i++) {
18554 + for_each_online_cpu(cpu) {
18555 + struct _vx_history *hist =
18556 + &per_cpu(vx_history_buffer, cpu);
18557 + unsigned int index = (hist->counter - i) % VXH_SIZE;
18558 + struct _vx_hist_entry *entry = &hist->entry[index];
18560 + vxh_dump_entry(entry, cpu);
18565 +void vxh_dump_history(void)
18569 + local_irq_enable();
18571 + local_irq_disable();
18573 + __vxh_dump_history();
18577 +/* vserver syscall commands below here */
18580 +int vc_dump_history(uint32_t id)
18583 + __vxh_dump_history();
18590 +int do_read_history(struct __user _vx_hist_entry *data,
18591 + int cpu, uint32_t *index, uint32_t *count)
18593 + int pos, ret = 0;
18594 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18595 + int end = hist->counter;
18596 + int start = end - VXH_SIZE + 2;
18597 + int idx = *index;
18599 + /* special case: get current pos */
18605 + /* have we lost some data? */
18609 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
18610 + struct _vx_hist_entry *entry =
18611 + &hist->entry[idx % VXH_SIZE];
18613 + /* send entry to userspace */
18614 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
18618 + /* save new index and count */
18621 + return ret ? ret : (*index < end);
18624 +int vc_read_history(uint32_t id, void __user *data)
18626 + struct vcmd_read_history_v0 vc_data;
18629 + if (id >= NR_CPUS)
18632 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18635 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
18636 + id, &vc_data.index, &vc_data.count);
18638 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18643 +#ifdef CONFIG_COMPAT
18645 +int vc_read_history_x32(uint32_t id, void __user *data)
18647 + struct vcmd_read_history_v0_x32 vc_data;
18650 + if (id >= NR_CPUS)
18653 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18656 + ret = do_read_history((struct __user _vx_hist_entry *)
18657 + compat_ptr(vc_data.data_ptr),
18658 + id, &vc_data.index, &vc_data.count);
18660 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18665 +#endif /* CONFIG_COMPAT */
18667 diff -NurpP --minimal linux-3.6/kernel/vserver/inet.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/inet.c
18668 --- linux-3.6/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
18669 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/inet.c 2012-10-04 18:47:00.000000000 +0200
18672 +#include <linux/in.h>
18673 +#include <linux/inetdevice.h>
18674 +#include <linux/export.h>
18675 +#include <linux/vs_inet.h>
18676 +#include <linux/vs_inet6.h>
18677 +#include <linux/vserver/debug.h>
18678 +#include <net/route.h>
18679 +#include <net/addrconf.h>
18682 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
18686 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
18689 + struct nx_addr_v4 *ptr;
18691 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
18692 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
18699 + vxdprintk(VXD_CBIT(net, 2),
18700 + "nx_v4_addr_conflict(%p,%p): %d",
18701 + nxi1, nxi2, ret);
18707 +#ifdef CONFIG_IPV6
18709 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
18713 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
18716 + struct nx_addr_v6 *ptr;
18718 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
18719 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
18726 + vxdprintk(VXD_CBIT(net, 2),
18727 + "nx_v6_addr_conflict(%p,%p): %d",
18728 + nxi1, nxi2, ret);
18735 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18737 + struct in_device *in_dev;
18738 + struct in_ifaddr **ifap;
18739 + struct in_ifaddr *ifa;
18744 + in_dev = in_dev_get(dev);
18748 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
18749 + ifap = &ifa->ifa_next) {
18750 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
18755 + in_dev_put(in_dev);
18761 +#ifdef CONFIG_IPV6
18763 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18765 + struct inet6_dev *in_dev;
18766 + struct inet6_ifaddr *ifa;
18771 + in_dev = in6_dev_get(dev);
18775 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
18776 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
18777 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
18782 + in6_dev_put(in_dev);
18789 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18795 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
18797 +#ifdef CONFIG_IPV6
18799 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
18804 + vxdprintk(VXD_CBIT(net, 3),
18805 + "dev_in_nx_info(%p,%p[#%d]) = %d",
18806 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
18810 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
18811 + struct flowi4 *fl4)
18813 + struct rtable *rt;
18818 + /* FIXME: handle lback only case */
18819 + if (!NX_IPV4(nxi))
18820 + return ERR_PTR(-EPERM);
18822 + vxdprintk(VXD_CBIT(net, 4),
18823 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
18824 + nxi, nxi ? nxi->nx_id : 0,
18825 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
18827 + /* single IP is unconditional */
18828 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
18829 + (fl4->saddr == INADDR_ANY))
18830 + fl4->saddr = nxi->v4.ip[0].s_addr;
18832 + if (fl4->saddr == INADDR_ANY) {
18833 + struct nx_addr_v4 *ptr;
18834 + __be32 found = 0;
18836 + rt = __ip_route_output_key(net, fl4);
18837 + if (!IS_ERR(rt)) {
18838 + found = fl4->saddr;
18840 + vxdprintk(VXD_CBIT(net, 4),
18841 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
18842 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
18843 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
18847 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
18848 + __be32 primary = ptr->ip[0].s_addr;
18849 + __be32 mask = ptr->mask.s_addr;
18850 + __be32 neta = primary & mask;
18852 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
18853 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
18854 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
18855 + NIPQUAD(mask), NIPQUAD(neta));
18856 + if ((found & mask) != neta)
18859 + fl4->saddr = primary;
18860 + rt = __ip_route_output_key(net, fl4);
18861 + vxdprintk(VXD_CBIT(net, 4),
18862 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
18863 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
18864 + if (!IS_ERR(rt)) {
18865 + found = fl4->saddr;
18867 + if (found == primary)
18871 + /* still no source ip? */
18872 + found = ipv4_is_loopback(fl4->daddr)
18873 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
18875 + /* assign src ip to flow */
18876 + fl4->saddr = found;
18879 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
18880 + return ERR_PTR(-EPERM);
18883 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
18884 + if (ipv4_is_loopback(fl4->daddr))
18885 + fl4->daddr = nxi->v4_lback.s_addr;
18886 + if (ipv4_is_loopback(fl4->saddr))
18887 + fl4->saddr = nxi->v4_lback.s_addr;
18888 + } else if (ipv4_is_loopback(fl4->daddr) &&
18889 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
18890 + return ERR_PTR(-EPERM);
18895 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
18897 diff -NurpP --minimal linux-3.6/kernel/vserver/init.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/init.c
18898 --- linux-3.6/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
18899 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/init.c 2012-10-04 18:47:00.000000000 +0200
18902 + * linux/kernel/init.c
18904 + * Virtual Server Init
18906 + * Copyright (C) 2004-2007 Herbert Pötzl
18908 + * V0.01 basic structure
18912 +#include <linux/init.h>
18914 +int vserver_register_sysctl(void);
18915 +void vserver_unregister_sysctl(void);
18918 +static int __init init_vserver(void)
18922 +#ifdef CONFIG_VSERVER_DEBUG
18923 + vserver_register_sysctl();
18929 +static void __exit exit_vserver(void)
18932 +#ifdef CONFIG_VSERVER_DEBUG
18933 + vserver_unregister_sysctl();
18938 +/* FIXME: GFP_ZONETYPES gone
18939 +long vx_slab[GFP_ZONETYPES]; */
18943 +module_init(init_vserver);
18944 +module_exit(exit_vserver);
18946 diff -NurpP --minimal linux-3.6/kernel/vserver/inode.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/inode.c
18947 --- linux-3.6/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
18948 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/inode.c 2012-10-04 18:47:00.000000000 +0200
18951 + * linux/kernel/vserver/inode.c
18953 + * Virtual Server: File System Support
18955 + * Copyright (C) 2004-2007 Herbert Pötzl
18957 + * V0.01 separated from vcontext V0.05
18958 + * V0.02 moved to tag (instead of xid)
18962 +#include <linux/tty.h>
18963 +#include <linux/proc_fs.h>
18964 +#include <linux/devpts_fs.h>
18965 +#include <linux/fs.h>
18966 +#include <linux/file.h>
18967 +#include <linux/mount.h>
18968 +#include <linux/parser.h>
18969 +#include <linux/namei.h>
18970 +#include <linux/vserver/inode.h>
18971 +#include <linux/vserver/inode_cmd.h>
18972 +#include <linux/vs_base.h>
18973 +#include <linux/vs_tag.h>
18975 +#include <asm/uaccess.h>
18978 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
18980 + struct proc_dir_entry *entry;
18982 + if (!in || !in->i_sb)
18985 + *flags = IATTR_TAG
18986 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
18987 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
18988 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
18989 + | (IS_COW(in) ? IATTR_COW : 0);
18990 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
18992 + if (S_ISDIR(in->i_mode))
18993 + *mask |= IATTR_BARRIER;
18995 + if (IS_TAGGED(in)) {
18996 + *tag = in->i_tag;
18997 + *mask |= IATTR_TAG;
19000 + switch (in->i_sb->s_magic) {
19001 + case PROC_SUPER_MAGIC:
19002 + entry = PROC_I(in)->pde;
19004 + /* check for specific inodes? */
19006 + *mask |= IATTR_FLAGS;
19008 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19010 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19013 + case DEVPTS_SUPER_MAGIC:
19014 + *tag = in->i_tag;
19015 + *mask |= IATTR_TAG;
19024 +int vc_get_iattr(void __user *data)
19026 + struct path path;
19027 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19030 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19033 + ret = user_lpath(vc_data.name, &path);
19035 + ret = __vc_get_iattr(path.dentry->d_inode,
19036 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19042 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19047 +#ifdef CONFIG_COMPAT
19049 +int vc_get_iattr_x32(void __user *data)
19051 + struct path path;
19052 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19055 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19058 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19060 + ret = __vc_get_iattr(path.dentry->d_inode,
19061 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19067 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19072 +#endif /* CONFIG_COMPAT */
19075 +int vc_fget_iattr(uint32_t fd, void __user *data)
19077 + struct file *filp;
19078 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19081 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19085 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19088 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19089 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19093 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19099 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19101 + struct inode *in = de->d_inode;
19102 + int error = 0, is_proc = 0, has_tag = 0;
19103 + struct iattr attr = { 0 };
19105 + if (!in || !in->i_sb)
19108 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19109 + if ((*mask & IATTR_FLAGS) && !is_proc)
19112 + has_tag = IS_TAGGED(in) ||
19113 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19114 + if ((*mask & IATTR_TAG) && !has_tag)
19117 + mutex_lock(&in->i_mutex);
19118 + if (*mask & IATTR_TAG) {
19119 + attr.ia_tag = *tag;
19120 + attr.ia_valid |= ATTR_TAG;
19123 + if (*mask & IATTR_FLAGS) {
19124 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19125 + unsigned int iflags = PROC_I(in)->vx_flags;
19127 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19128 + | (*flags & IATTR_FLAGS);
19129 + PROC_I(in)->vx_flags = iflags;
19131 + entry->vx_flags = iflags;
19134 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19135 + IATTR_BARRIER | IATTR_COW)) {
19136 + int iflags = in->i_flags;
19137 + int vflags = in->i_vflags;
19139 + if (*mask & IATTR_IMMUTABLE) {
19140 + if (*flags & IATTR_IMMUTABLE)
19141 + iflags |= S_IMMUTABLE;
19143 + iflags &= ~S_IMMUTABLE;
19145 + if (*mask & IATTR_IXUNLINK) {
19146 + if (*flags & IATTR_IXUNLINK)
19147 + iflags |= S_IXUNLINK;
19149 + iflags &= ~S_IXUNLINK;
19151 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19152 + if (*flags & IATTR_BARRIER)
19153 + vflags |= V_BARRIER;
19155 + vflags &= ~V_BARRIER;
19157 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19158 + if (*flags & IATTR_COW)
19161 + vflags &= ~V_COW;
19163 + if (in->i_op && in->i_op->sync_flags) {
19164 + error = in->i_op->sync_flags(in, iflags, vflags);
19170 + if (attr.ia_valid) {
19171 + if (in->i_op && in->i_op->setattr)
19172 + error = in->i_op->setattr(de, &attr);
19174 + error = inode_change_ok(in, &attr);
19176 + setattr_copy(in, &attr);
19177 + mark_inode_dirty(in);
19183 + mutex_unlock(&in->i_mutex);
19187 +int vc_set_iattr(void __user *data)
19189 + struct path path;
19190 + struct vcmd_ctx_iattr_v1 vc_data;
19193 + if (!capable(CAP_LINUX_IMMUTABLE))
19195 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19198 + ret = user_lpath(vc_data.name, &path);
19200 + ret = __vc_set_iattr(path.dentry,
19201 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19205 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19210 +#ifdef CONFIG_COMPAT
19212 +int vc_set_iattr_x32(void __user *data)
19214 + struct path path;
19215 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19218 + if (!capable(CAP_LINUX_IMMUTABLE))
19220 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19223 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19225 + ret = __vc_set_iattr(path.dentry,
19226 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19230 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19235 +#endif /* CONFIG_COMPAT */
19237 +int vc_fset_iattr(uint32_t fd, void __user *data)
19239 + struct file *filp;
19240 + struct vcmd_ctx_fiattr_v0 vc_data;
19243 + if (!capable(CAP_LINUX_IMMUTABLE))
19245 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19249 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19252 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19253 + &vc_data.flags, &vc_data.mask);
19257 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19263 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19265 +static match_table_t tokens = {
19266 + {Opt_notagcheck, "notagcheck"},
19267 +#ifdef CONFIG_PROPAGATE
19268 + {Opt_notag, "notag"},
19269 + {Opt_tag, "tag"},
19270 + {Opt_tagid, "tagid=%u"},
19276 +static void __dx_parse_remove(char *string, char *opt)
19278 + char *p = strstr(string, opt);
19282 + while (*q != '\0' && *q != ',')
19291 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19292 + unsigned long *flags)
19295 + substring_t args[MAX_OPT_ARGS];
19297 + char *s, *p, *opts;
19298 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_DEBUG)
19304 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19309 + while ((p = strsep(&opts, ",")) != NULL) {
19310 + token = match_token(p, tokens, args);
19313 +#ifdef CONFIG_PROPAGATE
19318 + __dx_parse_remove(s, "tag");
19319 + *mnt_flags |= MNT_TAGID;
19320 + set |= MNT_TAGID;
19324 + __dx_parse_remove(s, "notag");
19325 + *mnt_flags |= MNT_NOTAG;
19326 + set |= MNT_NOTAG;
19329 + if (tag && !match_int(args, &option))
19332 + __dx_parse_remove(s, "tagid");
19333 + *mnt_flags |= MNT_TAGID;
19334 + set |= MNT_TAGID;
19336 +#endif /* CONFIG_PROPAGATE */
19337 + case Opt_notagcheck:
19339 + __dx_parse_remove(s, "notagcheck");
19340 + *flags |= MS_NOTAGCHECK;
19341 + set |= MS_NOTAGCHECK;
19344 + vxdprintk(VXD_CBIT(tag, 7),
19345 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19346 + p, token, option);
19349 + strcpy(string, s);
19354 +#ifdef CONFIG_PROPAGATE
19356 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19358 + tag_t new_tag = 0;
19359 + struct vfsmount *mnt;
19364 + mnt = nd->path.mnt;
19368 + propagate = (mnt->mnt_flags & MNT_TAGID);
19370 + new_tag = mnt->mnt_tag;
19372 + vxdprintk(VXD_CBIT(tag, 7),
19373 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19374 + inode, inode->i_ino, inode->i_tag,
19375 + new_tag, (propagate) ? 1 : 0);
19378 + inode->i_tag = new_tag;
19381 +#include <linux/module.h>
19383 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19385 +#endif /* CONFIG_PROPAGATE */
19387 diff -NurpP --minimal linux-3.6/kernel/vserver/limit.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/limit.c
19388 --- linux-3.6/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
19389 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/limit.c 2012-10-04 18:47:00.000000000 +0200
19392 + * linux/kernel/vserver/limit.c
19394 + * Virtual Server: Context Limits
19396 + * Copyright (C) 2004-2010 Herbert Pötzl
19398 + * V0.01 broken out from vcontext V0.05
19399 + * V0.02 changed vcmds to vxi arg
19400 + * V0.03 added memory cgroup support
19404 +#include <linux/sched.h>
19405 +#include <linux/module.h>
19406 +#include <linux/memcontrol.h>
19407 +#include <linux/res_counter.h>
19408 +#include <linux/vs_limit.h>
19409 +#include <linux/vserver/limit.h>
19410 +#include <linux/vserver/limit_cmd.h>
19412 +#include <asm/uaccess.h>
19415 +const char *vlimit_name[NUM_LIMITS] = {
19416 + [RLIMIT_CPU] = "CPU",
19417 + [RLIMIT_NPROC] = "NPROC",
19418 + [RLIMIT_NOFILE] = "NOFILE",
19419 + [RLIMIT_LOCKS] = "LOCKS",
19420 + [RLIMIT_SIGPENDING] = "SIGP",
19421 + [RLIMIT_MSGQUEUE] = "MSGQ",
19423 + [VLIMIT_NSOCK] = "NSOCK",
19424 + [VLIMIT_OPENFD] = "OPENFD",
19425 + [VLIMIT_SHMEM] = "SHMEM",
19426 + [VLIMIT_DENTRY] = "DENTRY",
19429 +EXPORT_SYMBOL_GPL(vlimit_name);
19431 +#define MASK_ENTRY(x) (1 << (x))
19433 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
19436 + , /* softlimit */
19439 + MASK_ENTRY( RLIMIT_NPROC ) |
19440 + MASK_ENTRY( RLIMIT_NOFILE ) |
19441 + MASK_ENTRY( RLIMIT_LOCKS ) |
19442 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
19444 + MASK_ENTRY( VLIMIT_NSOCK ) |
19445 + MASK_ENTRY( VLIMIT_OPENFD ) |
19446 + MASK_ENTRY( VLIMIT_SHMEM ) |
19447 + MASK_ENTRY( VLIMIT_DENTRY ) |
19450 + /* accounting only */
19451 +uint32_t account_mask =
19452 + MASK_ENTRY( VLIMIT_SEMARY ) |
19453 + MASK_ENTRY( VLIMIT_NSEMS ) |
19454 + MASK_ENTRY( VLIMIT_MAPPED ) |
19458 +static int is_valid_vlimit(int id)
19460 + uint32_t mask = vlimit_mask.minimum |
19461 + vlimit_mask.softlimit | vlimit_mask.maximum;
19462 + return mask & (1 << id);
19465 +static int is_accounted_vlimit(int id)
19467 + if (is_valid_vlimit(id))
19469 + return account_mask & (1 << id);
19473 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
19475 + rlim_t limit = __rlim_soft(&vxi->limit, id);
19476 + return VX_VLIM(limit);
19479 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
19481 + rlim_t limit = __rlim_hard(&vxi->limit, id);
19482 + return VX_VLIM(limit);
19485 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
19486 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
19488 + if (!is_valid_vlimit(id))
19492 + *minimum = CRLIM_UNSET;
19494 + *softlimit = vc_get_soft(vxi, id);
19496 + *maximum = vc_get_hard(vxi, id);
19500 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
19502 + struct vcmd_ctx_rlimit_v0 vc_data;
19505 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19508 + ret = do_get_rlimit(vxi, vc_data.id,
19509 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19513 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19518 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
19519 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
19521 + if (!is_valid_vlimit(id))
19524 + if (maximum != CRLIM_KEEP)
19525 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
19526 + if (softlimit != CRLIM_KEEP)
19527 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
19529 + /* clamp soft limit */
19530 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
19531 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
19536 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
19538 + struct vcmd_ctx_rlimit_v0 vc_data;
19540 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19543 + return do_set_rlimit(vxi, vc_data.id,
19544 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19547 +#ifdef CONFIG_IA32_EMULATION
19549 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
19551 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19553 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19556 + return do_set_rlimit(vxi, vc_data.id,
19557 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19560 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
19562 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19565 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19568 + ret = do_get_rlimit(vxi, vc_data.id,
19569 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19573 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19578 +#endif /* CONFIG_IA32_EMULATION */
19581 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
19583 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
19589 +static inline void vx_reset_hits(struct _vx_limit *limit)
19593 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19594 + atomic_set(&__rlim_lhit(limit, lim), 0);
19598 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
19600 + vx_reset_hits(&vxi->limit);
19604 +static inline void vx_reset_minmax(struct _vx_limit *limit)
19609 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19610 + value = __rlim_get(limit, lim);
19611 + __rlim_rmax(limit, lim) = value;
19612 + __rlim_rmin(limit, lim) = value;
19616 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
19618 + vx_reset_minmax(&vxi->limit);
19623 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
19625 + struct vcmd_rlimit_stat_v0 vc_data;
19626 + struct _vx_limit *limit = &vxi->limit;
19629 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19633 + if (!is_accounted_vlimit(id))
19636 + vx_limit_fixup(limit, id);
19637 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
19638 + vc_data.value = __rlim_get(limit, id);
19639 + vc_data.minimum = __rlim_rmin(limit, id);
19640 + vc_data.maximum = __rlim_rmax(limit, id);
19642 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19648 +void vx_vsi_meminfo(struct sysinfo *val)
19650 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
19651 + struct mem_cgroup *mcg;
19652 + u64 res_limit, res_usage;
19655 + mcg = mem_cgroup_from_task(current);
19656 + rcu_read_unlock();
19660 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19661 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19663 + if (res_limit != RESOURCE_MAX)
19664 + val->totalram = (res_limit >> PAGE_SHIFT);
19665 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
19666 + val->bufferram = 0;
19667 + val->totalhigh = 0;
19668 + val->freehigh = 0;
19670 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
19674 +void vx_vsi_swapinfo(struct sysinfo *val)
19676 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
19677 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
19678 + struct mem_cgroup *mcg;
19679 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
19680 + s64 swap_limit, swap_usage;
19683 + mcg = mem_cgroup_from_task(current);
19684 + rcu_read_unlock();
19688 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19689 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19690 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
19691 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
19693 + /* memory unlimited */
19694 + if (res_limit == RESOURCE_MAX)
19697 + swap_limit = memsw_limit - res_limit;
19698 + /* we have a swap limit? */
19699 + if (memsw_limit != RESOURCE_MAX)
19700 + val->totalswap = swap_limit >> PAGE_SHIFT;
19702 + /* calculate swap part */
19703 + swap_usage = (memsw_usage > res_usage) ?
19704 + memsw_usage - res_usage : 0;
19706 + /* total shown minus usage gives free swap */
19707 + val->freeswap = (swap_usage < swap_limit) ?
19708 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
19710 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
19711 + val->totalswap = 0;
19712 + val->freeswap = 0;
19713 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
19714 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
19718 +long vx_vsi_cached(struct sysinfo *val)
19721 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
19722 + struct mem_cgroup *mcg;
19725 + mcg = mem_cgroup_from_task(current);
19726 + rcu_read_unlock();
19730 + cache = mem_cgroup_stat_read_cache(mcg);
19736 diff -NurpP --minimal linux-3.6/kernel/vserver/limit_init.h linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/limit_init.h
19737 --- linux-3.6/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
19738 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/limit_init.h 2012-10-04 18:47:00.000000000 +0200
19742 +static inline void vx_info_init_limit(struct _vx_limit *limit)
19746 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19747 + __rlim_soft(limit, lim) = RLIM_INFINITY;
19748 + __rlim_hard(limit, lim) = RLIM_INFINITY;
19749 + __rlim_set(limit, lim, 0);
19750 + atomic_set(&__rlim_lhit(limit, lim), 0);
19751 + __rlim_rmin(limit, lim) = 0;
19752 + __rlim_rmax(limit, lim) = 0;
19756 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
19761 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19762 + if ((1 << lim) & VLIM_NOCHECK)
19764 + value = __rlim_get(limit, lim);
19765 + vxwprintk_xid(value,
19766 + "!!! limit: %p[%s,%d] = %ld on exit.",
19767 + limit, vlimit_name[lim], lim, (long)value);
19771 diff -NurpP --minimal linux-3.6/kernel/vserver/limit_proc.h linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/limit_proc.h
19772 --- linux-3.6/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
19773 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/limit_proc.h 2012-10-04 18:47:00.000000000 +0200
19775 +#ifndef _VX_LIMIT_PROC_H
19776 +#define _VX_LIMIT_PROC_H
19778 +#include <linux/vserver/limit_int.h>
19781 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
19782 +#define VX_LIMIT_TOP \
19783 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
19785 +#define VX_LIMIT_ARG(r) \
19786 + (unsigned long)__rlim_get(limit, r), \
19787 + (unsigned long)__rlim_rmin(limit, r), \
19788 + (unsigned long)__rlim_rmax(limit, r), \
19789 + VX_VLIM(__rlim_soft(limit, r)), \
19790 + VX_VLIM(__rlim_hard(limit, r)), \
19791 + atomic_read(&__rlim_lhit(limit, r))
19793 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
19795 + vx_limit_fixup(limit, -1);
19796 + return sprintf(buffer, VX_LIMIT_TOP
19797 + "PROC" VX_LIMIT_FMT
19798 + "VM" VX_LIMIT_FMT
19799 + "VML" VX_LIMIT_FMT
19800 + "RSS" VX_LIMIT_FMT
19801 + "ANON" VX_LIMIT_FMT
19802 + "RMAP" VX_LIMIT_FMT
19803 + "FILES" VX_LIMIT_FMT
19804 + "OFD" VX_LIMIT_FMT
19805 + "LOCKS" VX_LIMIT_FMT
19806 + "SOCK" VX_LIMIT_FMT
19807 + "MSGQ" VX_LIMIT_FMT
19808 + "SHM" VX_LIMIT_FMT
19809 + "SEMA" VX_LIMIT_FMT
19810 + "SEMS" VX_LIMIT_FMT
19811 + "DENT" VX_LIMIT_FMT,
19812 + VX_LIMIT_ARG(RLIMIT_NPROC),
19813 + VX_LIMIT_ARG(RLIMIT_AS),
19814 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
19815 + VX_LIMIT_ARG(RLIMIT_RSS),
19816 + VX_LIMIT_ARG(VLIMIT_ANON),
19817 + VX_LIMIT_ARG(VLIMIT_MAPPED),
19818 + VX_LIMIT_ARG(RLIMIT_NOFILE),
19819 + VX_LIMIT_ARG(VLIMIT_OPENFD),
19820 + VX_LIMIT_ARG(RLIMIT_LOCKS),
19821 + VX_LIMIT_ARG(VLIMIT_NSOCK),
19822 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
19823 + VX_LIMIT_ARG(VLIMIT_SHMEM),
19824 + VX_LIMIT_ARG(VLIMIT_SEMARY),
19825 + VX_LIMIT_ARG(VLIMIT_NSEMS),
19826 + VX_LIMIT_ARG(VLIMIT_DENTRY));
19829 +#endif /* _VX_LIMIT_PROC_H */
19832 diff -NurpP --minimal linux-3.6/kernel/vserver/network.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/network.c
19833 --- linux-3.6/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
19834 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/network.c 2012-10-04 18:47:00.000000000 +0200
19837 + * linux/kernel/vserver/network.c
19839 + * Virtual Server: Network Support
19841 + * Copyright (C) 2003-2007 Herbert Pötzl
19843 + * V0.01 broken out from vcontext V0.05
19844 + * V0.02 cleaned up implementation
19845 + * V0.03 added equiv nx commands
19846 + * V0.04 switch to RCU based hash
19847 + * V0.05 and back to locking again
19848 + * V0.06 changed vcmds to nxi arg
19849 + * V0.07 have __create claim() the nxi
19853 +#include <linux/err.h>
19854 +#include <linux/slab.h>
19855 +#include <linux/rcupdate.h>
19857 +#include <linux/vs_network.h>
19858 +#include <linux/vs_pid.h>
19859 +#include <linux/vserver/network_cmd.h>
19862 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
19863 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
19865 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
19866 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
19869 +static int __init init_network(void)
19871 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
19872 + sizeof(struct nx_addr_v4), 0,
19873 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19874 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
19875 + sizeof(struct nx_addr_v6), 0,
19876 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19881 +/* __alloc_nx_addr_v4() */
19883 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
19885 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
19886 + nx_addr_v4_cachep, GFP_KERNEL);
19888 + if (!IS_ERR(nxa))
19889 + memset(nxa, 0, sizeof(*nxa));
19893 +/* __dealloc_nx_addr_v4() */
19895 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
19897 + kmem_cache_free(nx_addr_v4_cachep, nxa);
19900 +/* __dealloc_nx_addr_v4_all() */
19902 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
19905 + struct nx_addr_v4 *next = nxa->next;
19907 + __dealloc_nx_addr_v4(nxa);
19913 +#ifdef CONFIG_IPV6
19915 +/* __alloc_nx_addr_v6() */
19917 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
19919 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
19920 + nx_addr_v6_cachep, GFP_KERNEL);
19922 + if (!IS_ERR(nxa))
19923 + memset(nxa, 0, sizeof(*nxa));
19927 +/* __dealloc_nx_addr_v6() */
19929 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
19931 + kmem_cache_free(nx_addr_v6_cachep, nxa);
19934 +/* __dealloc_nx_addr_v6_all() */
19936 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
19939 + struct nx_addr_v6 *next = nxa->next;
19941 + __dealloc_nx_addr_v6(nxa);
19946 +#endif /* CONFIG_IPV6 */
19948 +/* __alloc_nx_info()
19950 + * allocate an initialized nx_info struct
19951 + * doesn't make it visible (hash) */
19953 +static struct nx_info *__alloc_nx_info(nid_t nid)
19955 + struct nx_info *new = NULL;
19957 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
19959 + /* would this benefit from a slab cache? */
19960 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
19964 + memset(new, 0, sizeof(struct nx_info));
19965 + new->nx_id = nid;
19966 + INIT_HLIST_NODE(&new->nx_hlist);
19967 + atomic_set(&new->nx_usecnt, 0);
19968 + atomic_set(&new->nx_tasks, 0);
19969 + new->nx_state = 0;
19971 + new->nx_flags = NXF_INIT_SET;
19973 + /* rest of init goes here */
19975 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
19976 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
19978 + vxdprintk(VXD_CBIT(nid, 0),
19979 + "alloc_nx_info(%d) = %p", nid, new);
19980 + atomic_inc(&nx_global_ctotal);
19984 +/* __dealloc_nx_info()
19986 + * final disposal of nx_info */
19988 +static void __dealloc_nx_info(struct nx_info *nxi)
19990 + vxdprintk(VXD_CBIT(nid, 0),
19991 + "dealloc_nx_info(%p)", nxi);
19993 + nxi->nx_hlist.next = LIST_POISON1;
19996 + BUG_ON(atomic_read(&nxi->nx_usecnt));
19997 + BUG_ON(atomic_read(&nxi->nx_tasks));
19999 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20001 + nxi->nx_state |= NXS_RELEASED;
20003 + atomic_dec(&nx_global_ctotal);
20006 +static void __shutdown_nx_info(struct nx_info *nxi)
20008 + nxi->nx_state |= NXS_SHUTDOWN;
20009 + vs_net_change(nxi, VSC_NETDOWN);
20012 +/* exported stuff */
20014 +void free_nx_info(struct nx_info *nxi)
20016 + /* context shutdown is mandatory */
20017 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20019 + /* context must not be hashed */
20020 + BUG_ON(nxi->nx_state & NXS_HASHED);
20022 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20023 + BUG_ON(atomic_read(&nxi->nx_tasks));
20025 + __dealloc_nx_info(nxi);
20029 +void __nx_set_lback(struct nx_info *nxi)
20031 + int nid = nxi->nx_id;
20032 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20034 + nxi->v4_lback.s_addr = lback;
20037 +extern int __nx_inet_add_lback(__be32 addr);
20038 +extern int __nx_inet_del_lback(__be32 addr);
20041 +/* hash table for nx_info hash */
20043 +#define NX_HASH_SIZE 13
20045 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20047 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20050 +static inline unsigned int __hashval(nid_t nid)
20052 + return (nid % NX_HASH_SIZE);
20057 +/* __hash_nx_info()
20059 + * add the nxi to the global hash table
20060 + * requires the hash_lock to be held */
20062 +static inline void __hash_nx_info(struct nx_info *nxi)
20064 + struct hlist_head *head;
20066 + vxd_assert_lock(&nx_info_hash_lock);
20067 + vxdprintk(VXD_CBIT(nid, 4),
20068 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20070 + /* context must not be hashed */
20071 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20073 + nxi->nx_state |= NXS_HASHED;
20074 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20075 + hlist_add_head(&nxi->nx_hlist, head);
20076 + atomic_inc(&nx_global_cactive);
20079 +/* __unhash_nx_info()
20081 + * remove the nxi from the global hash table
20082 + * requires the hash_lock to be held */
20084 +static inline void __unhash_nx_info(struct nx_info *nxi)
20086 + vxd_assert_lock(&nx_info_hash_lock);
20087 + vxdprintk(VXD_CBIT(nid, 4),
20088 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20089 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20091 + /* context must be hashed */
20092 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20093 + /* but without tasks */
20094 + BUG_ON(atomic_read(&nxi->nx_tasks));
20096 + nxi->nx_state &= ~NXS_HASHED;
20097 + hlist_del(&nxi->nx_hlist);
20098 + atomic_dec(&nx_global_cactive);
20102 +/* __lookup_nx_info()
20104 + * requires the hash_lock to be held
20105 + * doesn't increment the nx_refcnt */
20107 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20109 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20110 + struct hlist_node *pos;
20111 + struct nx_info *nxi;
20113 + vxd_assert_lock(&nx_info_hash_lock);
20114 + hlist_for_each(pos, head) {
20115 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20117 + if (nxi->nx_id == nid)
20122 + vxdprintk(VXD_CBIT(nid, 0),
20123 + "__lookup_nx_info(#%u): %p[#%u]",
20124 + nid, nxi, nxi ? nxi->nx_id : 0);
20129 +/* __create_nx_info()
20131 + * create the requested context
20132 + * get(), claim() and hash it */
20134 +static struct nx_info *__create_nx_info(int id)
20136 + struct nx_info *new, *nxi = NULL;
20138 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20140 + if (!(new = __alloc_nx_info(id)))
20141 + return ERR_PTR(-ENOMEM);
20143 + /* required to make dynamic xids unique */
20144 + spin_lock(&nx_info_hash_lock);
20146 + /* static context requested */
20147 + if ((nxi = __lookup_nx_info(id))) {
20148 + vxdprintk(VXD_CBIT(nid, 0),
20149 + "create_nx_info(%d) = %p (already there)", id, nxi);
20150 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20151 + nxi = ERR_PTR(-EBUSY);
20153 + nxi = ERR_PTR(-EEXIST);
20156 + /* new context */
20157 + vxdprintk(VXD_CBIT(nid, 0),
20158 + "create_nx_info(%d) = %p (new)", id, new);
20159 + claim_nx_info(new, NULL);
20160 + __nx_set_lback(new);
20161 + __hash_nx_info(get_nx_info(new));
20162 + nxi = new, new = NULL;
20165 + spin_unlock(&nx_info_hash_lock);
20167 + __dealloc_nx_info(new);
20173 +/* exported stuff */
20176 +void unhash_nx_info(struct nx_info *nxi)
20178 + __shutdown_nx_info(nxi);
20179 + spin_lock(&nx_info_hash_lock);
20180 + __unhash_nx_info(nxi);
20181 + spin_unlock(&nx_info_hash_lock);
20184 +/* lookup_nx_info()
20186 + * search for a nx_info and get() it
20187 + * negative id means current */
20189 +struct nx_info *lookup_nx_info(int id)
20191 + struct nx_info *nxi = NULL;
20194 + nxi = get_nx_info(current_nx_info());
20195 + } else if (id > 1) {
20196 + spin_lock(&nx_info_hash_lock);
20197 + nxi = get_nx_info(__lookup_nx_info(id));
20198 + spin_unlock(&nx_info_hash_lock);
20203 +/* nid_is_hashed()
20205 + * verify that nid is still hashed */
20207 +int nid_is_hashed(nid_t nid)
20211 + spin_lock(&nx_info_hash_lock);
20212 + hashed = (__lookup_nx_info(nid) != NULL);
20213 + spin_unlock(&nx_info_hash_lock);
20218 +#ifdef CONFIG_PROC_FS
20222 + * get a subset of hashed nids for proc
20223 + * assumes size is at least one */
20225 +int get_nid_list(int index, unsigned int *nids, int size)
20227 + int hindex, nr_nids = 0;
20229 + /* only show current and children */
20230 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20233 + nids[nr_nids] = nx_current_nid();
20237 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20238 + struct hlist_head *head = &nx_info_hash[hindex];
20239 + struct hlist_node *pos;
20241 + spin_lock(&nx_info_hash_lock);
20242 + hlist_for_each(pos, head) {
20243 + struct nx_info *nxi;
20248 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20249 + nids[nr_nids] = nxi->nx_id;
20250 + if (++nr_nids >= size) {
20251 + spin_unlock(&nx_info_hash_lock);
20255 + /* keep the lock time short */
20256 + spin_unlock(&nx_info_hash_lock);
20265 + * migrate task to new network
20266 + * gets nxi, puts old_nxi on change
20269 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20271 + struct nx_info *old_nxi;
20277 + vxdprintk(VXD_CBIT(nid, 5),
20278 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20279 + p, nxi, nxi->nx_id,
20280 + atomic_read(&nxi->nx_usecnt),
20281 + atomic_read(&nxi->nx_tasks));
20283 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20284 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20287 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20290 + /* maybe disallow this completely? */
20291 + old_nxi = task_get_nx_info(p);
20292 + if (old_nxi == nxi)
20297 + clr_nx_info(&p->nx_info);
20298 + claim_nx_info(nxi, p);
20299 + set_nx_info(&p->nx_info, nxi);
20300 + p->nid = nxi->nx_id;
20303 + vxdprintk(VXD_CBIT(nid, 5),
20304 + "moved task %p into nxi:%p[#%d]",
20305 + p, nxi, nxi->nx_id);
20308 + release_nx_info(old_nxi, p);
20311 + put_nx_info(old_nxi);
20316 +void nx_set_persistent(struct nx_info *nxi)
20318 + vxdprintk(VXD_CBIT(nid, 6),
20319 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20321 + get_nx_info(nxi);
20322 + claim_nx_info(nxi, NULL);
20325 +void nx_clear_persistent(struct nx_info *nxi)
20327 + vxdprintk(VXD_CBIT(nid, 6),
20328 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20330 + release_nx_info(nxi, NULL);
20331 + put_nx_info(nxi);
20334 +void nx_update_persistent(struct nx_info *nxi)
20336 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20337 + nx_set_persistent(nxi);
20339 + nx_clear_persistent(nxi);
20342 +/* vserver syscall commands below here */
20344 +/* taks nid and nx_info functions */
20346 +#include <asm/uaccess.h>
20349 +int vc_task_nid(uint32_t id)
20354 + struct task_struct *tsk;
20357 + tsk = find_task_by_real_pid(id);
20358 + nid = (tsk) ? tsk->nid : -ESRCH;
20359 + rcu_read_unlock();
20361 + nid = nx_current_nid();
20366 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20368 + struct vcmd_nx_info_v0 vc_data;
20370 + vc_data.nid = nxi->nx_id;
20372 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20378 +/* network functions */
20380 +int vc_net_create(uint32_t nid, void __user *data)
20382 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
20383 + struct nx_info *new_nxi;
20386 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20389 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
20392 + new_nxi = __create_nx_info(nid);
20393 + if (IS_ERR(new_nxi))
20394 + return PTR_ERR(new_nxi);
20396 + /* initial flags */
20397 + new_nxi->nx_flags = vc_data.flagword;
20400 + if (vs_net_change(new_nxi, VSC_NETUP))
20403 + ret = nx_migrate_task(current, new_nxi);
20407 + /* return context id on success */
20408 + ret = new_nxi->nx_id;
20410 + /* get a reference for persistent contexts */
20411 + if ((vc_data.flagword & NXF_PERSISTENT))
20412 + nx_set_persistent(new_nxi);
20414 + release_nx_info(new_nxi, NULL);
20415 + put_nx_info(new_nxi);
20420 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
20422 + return nx_migrate_task(current, nxi);
20427 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20428 + uint16_t type, uint16_t flags)
20430 + struct nx_addr_v4 *nxa = &nxi->v4;
20432 + if (NX_IPV4(nxi)) {
20433 + /* locate last entry */
20434 + for (; nxa->next; nxa = nxa->next);
20435 + nxa->next = __alloc_nx_addr_v4();
20439 + return PTR_ERR(nxa);
20442 + if (nxi->v4.next)
20443 + /* remove single ip for ip list */
20444 + nxi->nx_flags &= ~NXF_SINGLE_IP;
20446 + nxa->ip[0].s_addr = ip;
20447 + nxa->ip[1].s_addr = ip2;
20448 + nxa->mask.s_addr = mask;
20449 + nxa->type = type;
20450 + nxa->flags = flags;
20454 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20455 + uint16_t type, uint16_t flags)
20457 + struct nx_addr_v4 *nxa = &nxi->v4;
20460 +/* case NXA_TYPE_ADDR:
20463 + case NXA_TYPE_ANY:
20464 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
20465 + memset(nxa, 0, sizeof(*nxa));
20475 +int vc_net_add(struct nx_info *nxi, void __user *data)
20477 + struct vcmd_net_addr_v0 vc_data;
20478 + int index, ret = 0;
20480 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20483 + switch (vc_data.type) {
20484 + case NXA_TYPE_IPV4:
20485 + if ((vc_data.count < 1) || (vc_data.count > 4))
20489 + while (index < vc_data.count) {
20490 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
20491 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
20499 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
20500 + nxi->v4_bcast = vc_data.ip[0];
20504 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
20505 + nxi->v4_lback = vc_data.ip[0];
20516 +int vc_net_remove(struct nx_info *nxi, void __user *data)
20518 + struct vcmd_net_addr_v0 vc_data;
20520 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20523 + switch (vc_data.type) {
20524 + case NXA_TYPE_ANY:
20525 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
20526 + memset(&nxi->v4, 0, sizeof(nxi->v4));
20536 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
20538 + struct vcmd_net_addr_ipv4_v1 vc_data;
20540 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20543 + switch (vc_data.type) {
20544 + case NXA_TYPE_ADDR:
20545 + case NXA_TYPE_MASK:
20546 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
20547 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20549 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20550 + nxi->v4_bcast = vc_data.ip;
20553 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20554 + nxi->v4_lback = vc_data.ip;
20563 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
20565 + struct vcmd_net_addr_ipv4_v2 vc_data;
20567 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20570 + switch (vc_data.type) {
20571 + case NXA_TYPE_ADDR:
20572 + case NXA_TYPE_MASK:
20573 + case NXA_TYPE_RANGE:
20574 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20575 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20577 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20578 + nxi->v4_bcast = vc_data.ip;
20581 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20582 + nxi->v4_lback = vc_data.ip;
20591 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
20593 + struct vcmd_net_addr_ipv4_v1 vc_data;
20595 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20598 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
20599 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20602 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
20604 + struct vcmd_net_addr_ipv4_v2 vc_data;
20606 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20609 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20610 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20613 +#ifdef CONFIG_IPV6
20615 +int do_add_v6_addr(struct nx_info *nxi,
20616 + struct in6_addr *ip, struct in6_addr *mask,
20617 + uint32_t prefix, uint16_t type, uint16_t flags)
20619 + struct nx_addr_v6 *nxa = &nxi->v6;
20621 + if (NX_IPV6(nxi)) {
20622 + /* locate last entry */
20623 + for (; nxa->next; nxa = nxa->next);
20624 + nxa->next = __alloc_nx_addr_v6();
20628 + return PTR_ERR(nxa);
20632 + nxa->mask = *mask;
20633 + nxa->prefix = prefix;
20634 + nxa->type = type;
20635 + nxa->flags = flags;
20640 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
20642 + struct vcmd_net_addr_ipv6_v1 vc_data;
20644 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20647 + switch (vc_data.type) {
20648 + case NXA_TYPE_ADDR:
20649 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
20650 + /* fallthrough */
20651 + case NXA_TYPE_MASK:
20652 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
20653 + vc_data.prefix, vc_data.type, vc_data.flags);
20660 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
20662 + struct vcmd_net_addr_ipv6_v1 vc_data;
20664 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20667 + switch (vc_data.type) {
20668 + case NXA_TYPE_ANY:
20669 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
20670 + memset(&nxi->v6, 0, sizeof(nxi->v6));
20679 +#endif /* CONFIG_IPV6 */
20682 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
20684 + struct vcmd_net_flags_v0 vc_data;
20686 + vc_data.flagword = nxi->nx_flags;
20688 + /* special STATE flag handling */
20689 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
20691 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20696 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
20698 + struct vcmd_net_flags_v0 vc_data;
20699 + uint64_t mask, trigger;
20701 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20704 + /* special STATE flag handling */
20705 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
20706 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
20708 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
20709 + vc_data.flagword, mask);
20710 + if (trigger & NXF_PERSISTENT)
20711 + nx_update_persistent(nxi);
20716 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
20718 + struct vcmd_net_caps_v0 vc_data;
20720 + vc_data.ncaps = nxi->nx_ncaps;
20721 + vc_data.cmask = ~0ULL;
20723 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20728 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
20730 + struct vcmd_net_caps_v0 vc_data;
20732 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20735 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
20736 + vc_data.ncaps, vc_data.cmask);
20741 +#include <linux/module.h>
20743 +module_init(init_network);
20745 +EXPORT_SYMBOL_GPL(free_nx_info);
20746 +EXPORT_SYMBOL_GPL(unhash_nx_info);
20748 diff -NurpP --minimal linux-3.6/kernel/vserver/proc.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/proc.c
20749 --- linux-3.6/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
20750 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/proc.c 2012-10-09 14:19:59.000000000 +0200
20753 + * linux/kernel/vserver/proc.c
20755 + * Virtual Context Support
20757 + * Copyright (C) 2003-2011 Herbert Pötzl
20759 + * V0.01 basic structure
20760 + * V0.02 adaptation vs1.3.0
20761 + * V0.03 proc permissions
20762 + * V0.04 locking/generic
20763 + * V0.05 next generation procfs
20764 + * V0.06 inode validation
20765 + * V0.07 generic rewrite vid
20766 + * V0.08 remove inode type
20767 + * V0.09 added u/wmask info
20771 +#include <linux/proc_fs.h>
20772 +#include <linux/fs_struct.h>
20773 +#include <linux/mount.h>
20774 +#include <linux/namei.h>
20775 +#include <asm/unistd.h>
20777 +#include <linux/vs_context.h>
20778 +#include <linux/vs_network.h>
20779 +#include <linux/vs_cvirt.h>
20781 +#include <linux/in.h>
20782 +#include <linux/inetdevice.h>
20783 +#include <linux/vs_inet.h>
20784 +#include <linux/vs_inet6.h>
20786 +#include <linux/vserver/global.h>
20788 +#include "cvirt_proc.h"
20789 +#include "cacct_proc.h"
20790 +#include "limit_proc.h"
20791 +#include "sched_proc.h"
20792 +#include "vci_config.h"
20795 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
20799 + CAP_FOR_EACH_U32(__capi) {
20800 + buffer += sprintf(buffer, "%08x",
20801 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
20807 +static struct proc_dir_entry *proc_virtual;
20809 +static struct proc_dir_entry *proc_virtnet;
20812 +/* first the actual feeds */
20815 +static int proc_vci(char *buffer)
20817 + return sprintf(buffer,
20818 + "VCIVersion:\t%04x:%04x\n"
20819 + "VCISyscall:\t%d\n"
20820 + "VCIKernel:\t%08x\n",
20821 + VCI_VERSION >> 16,
20822 + VCI_VERSION & 0xFFFF,
20824 + vci_kernel_config());
20827 +static int proc_virtual_info(char *buffer)
20829 + return proc_vci(buffer);
20832 +static int proc_virtual_status(char *buffer)
20834 + return sprintf(buffer,
20836 + "#CActive:\t%d\n"
20837 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
20838 + "#InitTask:\t%d\t%d %d\n",
20839 + atomic_read(&vx_global_ctotal),
20840 + atomic_read(&vx_global_cactive),
20841 + atomic_read(&vs_global_nsproxy),
20842 + atomic_read(&vs_global_fs),
20843 + atomic_read(&vs_global_mnt_ns),
20844 + atomic_read(&vs_global_uts_ns),
20845 + atomic_read(&nr_ipc_ns),
20846 + atomic_read(&vs_global_user_ns),
20847 + atomic_read(&vs_global_pid_ns),
20848 + atomic_read(&init_task.usage),
20849 + atomic_read(&init_task.nsproxy->count),
20850 + init_task.fs->users);
20854 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
20858 + length = sprintf(buffer,
20866 + vxi->vx_badness_bias);
20870 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
20872 + char *orig = buffer;
20874 + buffer += sprintf(buffer,
20877 + "Flags:\t%016llx\n",
20878 + atomic_read(&vxi->vx_usecnt),
20879 + atomic_read(&vxi->vx_tasks),
20880 + (unsigned long long)vxi->vx_flags);
20882 + buffer += sprintf(buffer, "BCaps:\t");
20883 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
20884 + buffer += sprintf(buffer, "\n");
20886 + buffer += sprintf(buffer,
20887 + "CCaps:\t%016llx\n"
20888 + "Umask:\t%16llx\n"
20889 + "Wmask:\t%16llx\n"
20890 + "Spaces:\t%08lx %08lx\n",
20891 + (unsigned long long)vxi->vx_ccaps,
20892 + (unsigned long long)vxi->vx_umask,
20893 + (unsigned long long)vxi->vx_wmask,
20894 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
20895 + return buffer - orig;
20898 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
20900 + return vx_info_proc_limit(&vxi->limit, buffer);
20903 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
20907 + length = vx_info_proc_sched(&vxi->sched, buffer);
20908 + for_each_online_cpu(cpu) {
20909 + length += vx_info_proc_sched_pc(
20910 + &vx_per_cpu(vxi, sched_pc, cpu),
20911 + buffer + length, cpu);
20916 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
20918 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
20921 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
20923 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
20926 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
20930 + vx_update_load(vxi);
20931 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
20932 + for_each_online_cpu(cpu) {
20933 + length += vx_info_proc_cvirt_pc(
20934 + &vx_per_cpu(vxi, cvirt_pc, cpu),
20935 + buffer + length, cpu);
20940 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
20942 + return vx_info_proc_cacct(&vxi->cacct, buffer);
20946 +static int proc_virtnet_info(char *buffer)
20948 + return proc_vci(buffer);
20951 +static int proc_virtnet_status(char *buffer)
20953 + return sprintf(buffer,
20955 + "#CActive:\t%d\n",
20956 + atomic_read(&nx_global_ctotal),
20957 + atomic_read(&nx_global_cactive));
20960 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
20962 + struct nx_addr_v4 *v4a;
20963 +#ifdef CONFIG_IPV6
20964 + struct nx_addr_v6 *v6a;
20968 + length = sprintf(buffer,
20971 + "Bcast:\t" NIPQUAD_FMT "\n"
20972 + "Lback:\t" NIPQUAD_FMT "\n",
20975 + NIPQUAD(nxi->v4_bcast.s_addr),
20976 + NIPQUAD(nxi->v4_lback.s_addr));
20978 + if (!NX_IPV4(nxi))
20980 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
20981 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
20984 +#ifdef CONFIG_IPV6
20985 + if (!NX_IPV6(nxi))
20987 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
20988 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
20995 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
20999 + length = sprintf(buffer,
21002 + "Flags:\t%016llx\n"
21003 + "NCaps:\t%016llx\n",
21004 + atomic_read(&nxi->nx_usecnt),
21005 + atomic_read(&nxi->nx_tasks),
21006 + (unsigned long long)nxi->nx_flags,
21007 + (unsigned long long)nxi->nx_ncaps);
21013 +/* here the inode helpers */
21019 + struct inode_operations *iop;
21020 + struct file_operations *fop;
21021 + union proc_op op;
21024 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21026 + struct inode *inode = new_inode(sb);
21031 + inode->i_mode = p->mode;
21033 + inode->i_op = p->iop;
21035 + inode->i_fop = p->fop;
21037 + set_nlink(inode, (p->mode & S_IFDIR) ? 2 : 1);
21038 + inode->i_flags |= S_IMMUTABLE;
21040 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21042 + inode->i_uid = 0;
21043 + inode->i_gid = 0;
21044 + inode->i_tag = 0;
21049 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21050 + struct dentry *dentry, int id, void *ptr)
21052 + struct vs_entry *p = ptr;
21053 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21054 + struct dentry *error = ERR_PTR(-EINVAL);
21059 + PROC_I(inode)->op = p->op;
21060 + PROC_I(inode)->fd = id;
21061 + d_add(dentry, inode);
21069 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21072 + * Fill a directory entry.
21074 + * If possible create the dcache entry and derive our inode number and
21075 + * file type from dcache entry.
21077 + * Since all of the proc inode numbers are dynamically generated, the inode
21078 + * numbers do not exist until the inode is cache. This means creating the
21079 + * the dcache entry in readdir is necessary to keep the inode numbers
21080 + * reported by readdir in sync with the inode numbers reported
21083 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21084 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21086 + struct dentry *child, *dir = filp->f_dentry;
21087 + struct inode *inode;
21088 + struct qstr qname;
21090 + unsigned type = DT_UNKNOWN;
21092 + qname.name = name;
21094 + qname.hash = full_name_hash(name, len);
21096 + child = d_lookup(dir, &qname);
21098 + struct dentry *new;
21099 + new = d_alloc(dir, &qname);
21101 + child = instantiate(dir->d_inode, new, id, ptr);
21108 + if (!child || IS_ERR(child) || !child->d_inode)
21109 + goto end_instantiate;
21110 + inode = child->d_inode;
21112 + ino = inode->i_ino;
21113 + type = inode->i_mode >> 12;
21118 + ino = find_inode_number(dir, &qname);
21121 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21126 +/* get and revalidate vx_info/xid */
21129 +struct vx_info *get_proc_vx_info(struct inode *inode)
21131 + return lookup_vx_info(PROC_I(inode)->fd);
21134 +static int proc_xid_revalidate(struct dentry *dentry, unsigned int flags)
21136 + struct inode *inode = dentry->d_inode;
21137 + xid_t xid = PROC_I(inode)->fd;
21139 + if (flags & LOOKUP_RCU) /* FIXME: can be dropped? */
21142 + if (!xid || xid_is_hashed(xid))
21149 +/* get and revalidate nx_info/nid */
21151 +static int proc_nid_revalidate(struct dentry *dentry, unsigned int flags)
21153 + struct inode *inode = dentry->d_inode;
21154 + nid_t nid = PROC_I(inode)->fd;
21156 + if (flags & LOOKUP_RCU) /* FIXME: can be dropped? */
21159 + if (!nid || nid_is_hashed(nid))
21167 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21169 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21170 + size_t count, loff_t *ppos)
21172 + struct inode *inode = file->f_dentry->d_inode;
21173 + unsigned long page;
21174 + ssize_t length = 0;
21176 + if (count > PROC_BLOCK_SIZE)
21177 + count = PROC_BLOCK_SIZE;
21179 + /* fade that out as soon as stable */
21180 + WARN_ON(PROC_I(inode)->fd);
21182 + if (!(page = __get_free_page(GFP_KERNEL)))
21185 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21186 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21189 + length = simple_read_from_buffer(buf, count, ppos,
21190 + (char *)page, length);
21196 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21197 + size_t count, loff_t *ppos)
21199 + struct inode *inode = file->f_dentry->d_inode;
21200 + struct vx_info *vxi = NULL;
21201 + xid_t xid = PROC_I(inode)->fd;
21202 + unsigned long page;
21203 + ssize_t length = 0;
21205 + if (count > PROC_BLOCK_SIZE)
21206 + count = PROC_BLOCK_SIZE;
21208 + /* fade that out as soon as stable */
21210 + vxi = lookup_vx_info(xid);
21214 + length = -ENOMEM;
21215 + if (!(page = __get_free_page(GFP_KERNEL)))
21218 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21219 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21222 + length = simple_read_from_buffer(buf, count, ppos,
21223 + (char *)page, length);
21227 + put_vx_info(vxi);
21232 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21233 + size_t count, loff_t *ppos)
21235 + struct inode *inode = file->f_dentry->d_inode;
21236 + struct nx_info *nxi = NULL;
21237 + nid_t nid = PROC_I(inode)->fd;
21238 + unsigned long page;
21239 + ssize_t length = 0;
21241 + if (count > PROC_BLOCK_SIZE)
21242 + count = PROC_BLOCK_SIZE;
21244 + /* fade that out as soon as stable */
21246 + nxi = lookup_nx_info(nid);
21250 + length = -ENOMEM;
21251 + if (!(page = __get_free_page(GFP_KERNEL)))
21254 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21255 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21258 + length = simple_read_from_buffer(buf, count, ppos,
21259 + (char *)page, length);
21263 + put_nx_info(nxi);
21270 +/* here comes the lower level */
21273 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21274 + .len = sizeof(NAME) - 1, \
21275 + .name = (NAME), \
21283 +#define DIR(NAME, MODE, OTYPE) \
21284 + NOD(NAME, (S_IFDIR | (MODE)), \
21285 + &proc_ ## OTYPE ## _inode_operations, \
21286 + &proc_ ## OTYPE ## _file_operations, { } )
21288 +#define INF(NAME, MODE, OTYPE) \
21289 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21290 + &proc_vs_info_file_operations, \
21291 + { .proc_vs_read = &proc_##OTYPE } )
21293 +#define VINF(NAME, MODE, OTYPE) \
21294 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21295 + &proc_vx_info_file_operations, \
21296 + { .proc_vxi_read = &proc_##OTYPE } )
21298 +#define NINF(NAME, MODE, OTYPE) \
21299 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21300 + &proc_nx_info_file_operations, \
21301 + { .proc_nxi_read = &proc_##OTYPE } )
21304 +static struct file_operations proc_vs_info_file_operations = {
21305 + .read = proc_vs_info_read,
21308 +static struct file_operations proc_vx_info_file_operations = {
21309 + .read = proc_vx_info_read,
21312 +static struct dentry_operations proc_xid_dentry_operations = {
21313 + .d_revalidate = proc_xid_revalidate,
21316 +static struct vs_entry vx_base_stuff[] = {
21317 + VINF("info", S_IRUGO, vxi_info),
21318 + VINF("status", S_IRUGO, vxi_status),
21319 + VINF("limit", S_IRUGO, vxi_limit),
21320 + VINF("sched", S_IRUGO, vxi_sched),
21321 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21322 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21323 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21324 + VINF("cacct", S_IRUGO, vxi_cacct),
21331 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21332 + struct dentry *dentry, int id, void *ptr)
21334 + dentry->d_op = &proc_xid_dentry_operations;
21335 + return vs_proc_instantiate(dir, dentry, id, ptr);
21338 +static struct dentry *proc_xid_lookup(struct inode *dir,
21339 + struct dentry *dentry, unsigned int flags)
21341 + struct vs_entry *p = vx_base_stuff;
21342 + struct dentry *error = ERR_PTR(-ENOENT);
21344 + for (; p->name; p++) {
21345 + if (p->len != dentry->d_name.len)
21347 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21353 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21358 +static int proc_xid_readdir(struct file *filp,
21359 + void *dirent, filldir_t filldir)
21361 + struct dentry *dentry = filp->f_dentry;
21362 + struct inode *inode = dentry->d_inode;
21363 + struct vs_entry *p = vx_base_stuff;
21364 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21368 + pos = filp->f_pos;
21371 + ino = inode->i_ino;
21372 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21375 + /* fall through */
21377 + ino = parent_ino(dentry);
21378 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21381 + /* fall through */
21384 + if (index >= size)
21386 + for (p += index; p->name; p++) {
21387 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21388 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21394 + filp->f_pos = pos;
21400 +static struct file_operations proc_nx_info_file_operations = {
21401 + .read = proc_nx_info_read,
21404 +static struct dentry_operations proc_nid_dentry_operations = {
21405 + .d_revalidate = proc_nid_revalidate,
21408 +static struct vs_entry nx_base_stuff[] = {
21409 + NINF("info", S_IRUGO, nxi_info),
21410 + NINF("status", S_IRUGO, nxi_status),
21415 +static struct dentry *proc_nid_instantiate(struct inode *dir,
21416 + struct dentry *dentry, int id, void *ptr)
21418 + dentry->d_op = &proc_nid_dentry_operations;
21419 + return vs_proc_instantiate(dir, dentry, id, ptr);
21422 +static struct dentry *proc_nid_lookup(struct inode *dir,
21423 + struct dentry *dentry, unsigned int flags)
21425 + struct vs_entry *p = nx_base_stuff;
21426 + struct dentry *error = ERR_PTR(-ENOENT);
21428 + for (; p->name; p++) {
21429 + if (p->len != dentry->d_name.len)
21431 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21437 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21442 +static int proc_nid_readdir(struct file *filp,
21443 + void *dirent, filldir_t filldir)
21445 + struct dentry *dentry = filp->f_dentry;
21446 + struct inode *inode = dentry->d_inode;
21447 + struct vs_entry *p = nx_base_stuff;
21448 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
21452 + pos = filp->f_pos;
21455 + ino = inode->i_ino;
21456 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21459 + /* fall through */
21461 + ino = parent_ino(dentry);
21462 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21465 + /* fall through */
21468 + if (index >= size)
21470 + for (p += index; p->name; p++) {
21471 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21472 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21478 + filp->f_pos = pos;
21483 +#define MAX_MULBY10 ((~0U - 9) / 10)
21485 +static inline int atovid(const char *str, int len)
21490 + while (len-- > 0) {
21495 + if (vid >= MAX_MULBY10)
21505 +/* now the upper level (virtual) */
21508 +static struct file_operations proc_xid_file_operations = {
21509 + .read = generic_read_dir,
21510 + .readdir = proc_xid_readdir,
21513 +static struct inode_operations proc_xid_inode_operations = {
21514 + .lookup = proc_xid_lookup,
21517 +static struct vs_entry vx_virtual_stuff[] = {
21518 + INF("info", S_IRUGO, virtual_info),
21519 + INF("status", S_IRUGO, virtual_status),
21520 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
21524 +static struct dentry *proc_virtual_lookup(struct inode *dir,
21525 + struct dentry *dentry, unsigned int flags)
21527 + struct vs_entry *p = vx_virtual_stuff;
21528 + struct dentry *error = ERR_PTR(-ENOENT);
21531 + for (; p->name; p++) {
21532 + if (p->len != dentry->d_name.len)
21534 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21538 + goto instantiate;
21540 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21541 + if ((id < 0) || !xid_is_hashed(id))
21545 + error = proc_xid_instantiate(dir, dentry, id, p);
21550 +static struct file_operations proc_nid_file_operations = {
21551 + .read = generic_read_dir,
21552 + .readdir = proc_nid_readdir,
21555 +static struct inode_operations proc_nid_inode_operations = {
21556 + .lookup = proc_nid_lookup,
21559 +static struct vs_entry nx_virtnet_stuff[] = {
21560 + INF("info", S_IRUGO, virtnet_info),
21561 + INF("status", S_IRUGO, virtnet_status),
21562 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
21566 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
21567 + struct dentry *dentry, unsigned int flags)
21569 + struct vs_entry *p = nx_virtnet_stuff;
21570 + struct dentry *error = ERR_PTR(-ENOENT);
21573 + for (; p->name; p++) {
21574 + if (p->len != dentry->d_name.len)
21576 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21580 + goto instantiate;
21582 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21583 + if ((id < 0) || !nid_is_hashed(id))
21587 + error = proc_nid_instantiate(dir, dentry, id, p);
21593 +#define PROC_MAXVIDS 32
21595 +int proc_virtual_readdir(struct file *filp,
21596 + void *dirent, filldir_t filldir)
21598 + struct dentry *dentry = filp->f_dentry;
21599 + struct inode *inode = dentry->d_inode;
21600 + struct vs_entry *p = vx_virtual_stuff;
21601 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
21603 + unsigned int xid_array[PROC_MAXVIDS];
21604 + char buf[PROC_NUMBUF];
21605 + unsigned int nr_xids, i;
21608 + pos = filp->f_pos;
21611 + ino = inode->i_ino;
21612 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21615 + /* fall through */
21617 + ino = parent_ino(dentry);
21618 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21621 + /* fall through */
21624 + if (index >= size)
21626 + for (p += index; p->name; p++) {
21627 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21628 + vs_proc_instantiate, 0, p))
21633 + index = pos - size;
21634 + p = &vx_virtual_stuff[size - 1];
21635 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
21636 + for (i = 0; i < nr_xids; i++) {
21637 + int n, xid = xid_array[i];
21638 + unsigned int j = PROC_NUMBUF;
21642 + buf[--j] = '0' + (n % 10);
21645 + if (proc_fill_cache(filp, dirent, filldir,
21646 + buf + j, PROC_NUMBUF - j,
21647 + vs_proc_instantiate, xid, p))
21653 + filp->f_pos = pos;
21657 +static int proc_virtual_getattr(struct vfsmount *mnt,
21658 + struct dentry *dentry, struct kstat *stat)
21660 + struct inode *inode = dentry->d_inode;
21662 + generic_fillattr(inode, stat);
21663 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
21667 +static struct file_operations proc_virtual_dir_operations = {
21668 + .read = generic_read_dir,
21669 + .readdir = proc_virtual_readdir,
21672 +static struct inode_operations proc_virtual_dir_inode_operations = {
21673 + .getattr = proc_virtual_getattr,
21674 + .lookup = proc_virtual_lookup,
21681 +int proc_virtnet_readdir(struct file *filp,
21682 + void *dirent, filldir_t filldir)
21684 + struct dentry *dentry = filp->f_dentry;
21685 + struct inode *inode = dentry->d_inode;
21686 + struct vs_entry *p = nx_virtnet_stuff;
21687 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
21689 + unsigned int nid_array[PROC_MAXVIDS];
21690 + char buf[PROC_NUMBUF];
21691 + unsigned int nr_nids, i;
21694 + pos = filp->f_pos;
21697 + ino = inode->i_ino;
21698 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21701 + /* fall through */
21703 + ino = parent_ino(dentry);
21704 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21707 + /* fall through */
21710 + if (index >= size)
21712 + for (p += index; p->name; p++) {
21713 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21714 + vs_proc_instantiate, 0, p))
21719 + index = pos - size;
21720 + p = &nx_virtnet_stuff[size - 1];
21721 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
21722 + for (i = 0; i < nr_nids; i++) {
21723 + int n, nid = nid_array[i];
21724 + unsigned int j = PROC_NUMBUF;
21728 + buf[--j] = '0' + (n % 10);
21731 + if (proc_fill_cache(filp, dirent, filldir,
21732 + buf + j, PROC_NUMBUF - j,
21733 + vs_proc_instantiate, nid, p))
21739 + filp->f_pos = pos;
21743 +static int proc_virtnet_getattr(struct vfsmount *mnt,
21744 + struct dentry *dentry, struct kstat *stat)
21746 + struct inode *inode = dentry->d_inode;
21748 + generic_fillattr(inode, stat);
21749 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
21753 +static struct file_operations proc_virtnet_dir_operations = {
21754 + .read = generic_read_dir,
21755 + .readdir = proc_virtnet_readdir,
21758 +static struct inode_operations proc_virtnet_dir_inode_operations = {
21759 + .getattr = proc_virtnet_getattr,
21760 + .lookup = proc_virtnet_lookup,
21765 +void proc_vx_init(void)
21767 + struct proc_dir_entry *ent;
21769 + ent = proc_mkdir("virtual", 0);
21771 + ent->proc_fops = &proc_virtual_dir_operations;
21772 + ent->proc_iops = &proc_virtual_dir_inode_operations;
21774 + proc_virtual = ent;
21776 + ent = proc_mkdir("virtnet", 0);
21778 + ent->proc_fops = &proc_virtnet_dir_operations;
21779 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
21781 + proc_virtnet = ent;
21787 +/* per pid info */
21790 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
21792 + struct vx_info *vxi;
21793 + char *orig = buffer;
21795 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
21797 + vxi = task_get_vx_info(p);
21801 + buffer += sprintf(buffer, "BCaps:\t");
21802 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21803 + buffer += sprintf(buffer, "\n");
21804 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
21805 + (unsigned long long)vxi->vx_ccaps);
21806 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
21807 + (unsigned long long)vxi->vx_flags);
21808 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
21810 + put_vx_info(vxi);
21812 + return buffer - orig;
21816 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
21818 + struct nx_info *nxi;
21819 + struct nx_addr_v4 *v4a;
21820 +#ifdef CONFIG_IPV6
21821 + struct nx_addr_v6 *v6a;
21823 + char *orig = buffer;
21826 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
21828 + nxi = task_get_nx_info(p);
21832 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
21833 + (unsigned long long)nxi->nx_ncaps);
21834 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
21835 + (unsigned long long)nxi->nx_flags);
21837 + buffer += sprintf(buffer,
21838 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
21839 + NIPQUAD(nxi->v4_bcast.s_addr));
21840 + buffer += sprintf (buffer,
21841 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
21842 + NIPQUAD(nxi->v4_lback.s_addr));
21843 + if (!NX_IPV4(nxi))
21845 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21846 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
21849 +#ifdef CONFIG_IPV6
21850 + if (!NX_IPV6(nxi))
21852 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21853 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
21857 + put_nx_info(nxi);
21859 + return buffer - orig;
21862 diff -NurpP --minimal linux-3.6/kernel/vserver/sched.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/sched.c
21863 --- linux-3.6/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
21864 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/sched.c 2012-10-04 18:47:00.000000000 +0200
21867 + * linux/kernel/vserver/sched.c
21869 + * Virtual Server: Scheduler Support
21871 + * Copyright (C) 2004-2010 Herbert Pötzl
21873 + * V0.01 adapted Sam Vilains version to 2.6.3
21874 + * V0.02 removed legacy interface
21875 + * V0.03 changed vcmds to vxi arg
21876 + * V0.04 removed older and legacy interfaces
21877 + * V0.05 removed scheduler code/commands
21881 +#include <linux/vs_context.h>
21882 +#include <linux/vs_sched.h>
21883 +#include <linux/cpumask.h>
21884 +#include <linux/vserver/sched_cmd.h>
21886 +#include <asm/uaccess.h>
21889 +void vx_update_sched_param(struct _vx_sched *sched,
21890 + struct _vx_sched_pc *sched_pc)
21892 + sched_pc->prio_bias = sched->prio_bias;
21895 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
21899 + if (data->prio_bias > MAX_PRIO_BIAS)
21900 + data->prio_bias = MAX_PRIO_BIAS;
21901 + if (data->prio_bias < MIN_PRIO_BIAS)
21902 + data->prio_bias = MIN_PRIO_BIAS;
21904 + if (data->cpu_id != ~0) {
21905 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
21906 + cpumask_and(&vxi->sched.update, &vxi->sched.update,
21907 + cpu_online_mask);
21909 + cpumask_copy(&vxi->sched.update, cpu_online_mask);
21911 + for_each_cpu_mask(cpu, vxi->sched.update)
21912 + vx_update_sched_param(&vxi->sched,
21913 + &vx_per_cpu(vxi, sched_pc, cpu));
21917 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
21919 + struct vcmd_prio_bias vc_data;
21921 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21924 + return do_set_prio_bias(vxi, &vc_data);
21927 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
21929 + struct vcmd_prio_bias vc_data;
21930 + struct _vx_sched_pc *pcd;
21933 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21936 + cpu = vc_data.cpu_id;
21938 + if (!cpu_possible(cpu))
21941 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
21942 + vc_data.prio_bias = pcd->prio_bias;
21944 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21949 diff -NurpP --minimal linux-3.6/kernel/vserver/sched_init.h linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/sched_init.h
21950 --- linux-3.6/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
21951 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/sched_init.h 2012-10-04 18:47:00.000000000 +0200
21954 +static inline void vx_info_init_sched(struct _vx_sched *sched)
21956 + /* scheduling; hard code starting values as constants */
21957 + sched->prio_bias = 0;
21961 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
21963 + sched_pc->prio_bias = 0;
21965 + sched_pc->user_ticks = 0;
21966 + sched_pc->sys_ticks = 0;
21967 + sched_pc->hold_ticks = 0;
21970 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
21976 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
21980 diff -NurpP --minimal linux-3.6/kernel/vserver/sched_proc.h linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/sched_proc.h
21981 --- linux-3.6/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
21982 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/sched_proc.h 2012-10-04 18:47:00.000000000 +0200
21984 +#ifndef _VX_SCHED_PROC_H
21985 +#define _VX_SCHED_PROC_H
21989 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
21993 + length += sprintf(buffer,
21994 + "PrioBias:\t%8d\n",
21995 + sched->prio_bias);
22000 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22001 + char *buffer, int cpu)
22005 + length += sprintf(buffer + length,
22006 + "cpu %d: %lld %lld %lld", cpu,
22007 + (unsigned long long)sched_pc->user_ticks,
22008 + (unsigned long long)sched_pc->sys_ticks,
22009 + (unsigned long long)sched_pc->hold_ticks);
22010 + length += sprintf(buffer + length,
22011 + " %d\n", sched_pc->prio_bias);
22015 +#endif /* _VX_SCHED_PROC_H */
22016 diff -NurpP --minimal linux-3.6/kernel/vserver/signal.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/signal.c
22017 --- linux-3.6/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22018 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/signal.c 2012-10-04 18:47:00.000000000 +0200
22021 + * linux/kernel/vserver/signal.c
22023 + * Virtual Server: Signal Support
22025 + * Copyright (C) 2003-2007 Herbert Pötzl
22027 + * V0.01 broken out from vcontext V0.05
22028 + * V0.02 changed vcmds to vxi arg
22029 + * V0.03 adjusted siginfo for kill
22033 +#include <asm/uaccess.h>
22035 +#include <linux/vs_context.h>
22036 +#include <linux/vs_pid.h>
22037 +#include <linux/vserver/signal_cmd.h>
22040 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22042 + int retval, count = 0;
22043 + struct task_struct *p;
22044 + struct siginfo *sip = SEND_SIG_PRIV;
22047 + vxdprintk(VXD_CBIT(misc, 4),
22048 + "vx_info_kill(%p[#%d],%d,%d)*",
22049 + vxi, vxi->vx_id, pid, sig);
22050 + read_lock(&tasklist_lock);
22054 + for_each_process(p) {
22057 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22058 + (pid && vxi->vx_initpid == p->pid))
22061 + err = group_send_sig_info(sig, sip, p);
22063 + if (err != -EPERM)
22069 + if (vxi->vx_initpid) {
22070 + pid = vxi->vx_initpid;
22071 + /* for now, only SIGINT to private init ... */
22072 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22073 + /* ... as long as there are tasks left */
22074 + (atomic_read(&vxi->vx_tasks) > 1))
22077 + /* fallthrough */
22080 + p = find_task_by_real_pid(pid);
22081 + rcu_read_unlock();
22083 + if (vx_task_xid(p) == vxi->vx_id)
22084 + retval = group_send_sig_info(sig, sip, p);
22088 + read_unlock(&tasklist_lock);
22089 + vxdprintk(VXD_CBIT(misc, 4),
22090 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22091 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22095 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22097 + struct vcmd_ctx_kill_v0 vc_data;
22099 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22102 + /* special check to allow guest shutdown */
22103 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22104 + /* forbid killall pid=0 when init is present */
22105 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22106 + (vc_data.pid > 1)))
22109 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22113 +static int __wait_exit(struct vx_info *vxi)
22115 + DECLARE_WAITQUEUE(wait, current);
22118 + add_wait_queue(&vxi->vx_wait, &wait);
22119 + set_current_state(TASK_INTERRUPTIBLE);
22122 + if (vx_info_state(vxi,
22123 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22125 + if (signal_pending(current)) {
22126 + ret = -ERESTARTSYS;
22133 + set_current_state(TASK_RUNNING);
22134 + remove_wait_queue(&vxi->vx_wait, &wait);
22140 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22142 + struct vcmd_wait_exit_v0 vc_data;
22145 + ret = __wait_exit(vxi);
22146 + vc_data.reboot_cmd = vxi->reboot_cmd;
22147 + vc_data.exit_code = vxi->exit_code;
22149 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22154 diff -NurpP --minimal linux-3.6/kernel/vserver/space.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/space.c
22155 --- linux-3.6/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22156 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/space.c 2012-10-04 18:47:00.000000000 +0200
22159 + * linux/kernel/vserver/space.c
22161 + * Virtual Server: Context Space Support
22163 + * Copyright (C) 2003-2010 Herbert Pötzl
22165 + * V0.01 broken out from context.c 0.07
22166 + * V0.02 added task locking for namespace
22167 + * V0.03 broken out vx_enter_namespace
22168 + * V0.04 added *space support and commands
22169 + * V0.05 added credential support
22173 +#include <linux/utsname.h>
22174 +#include <linux/nsproxy.h>
22175 +#include <linux/err.h>
22176 +#include <linux/fs_struct.h>
22177 +#include <linux/cred.h>
22178 +#include <asm/uaccess.h>
22180 +#include <linux/vs_context.h>
22181 +#include <linux/vserver/space.h>
22182 +#include <linux/vserver/space_cmd.h>
22184 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22185 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22186 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22187 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22188 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22189 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22192 +/* namespace functions */
22194 +#include <linux/mnt_namespace.h>
22195 +#include <linux/user_namespace.h>
22196 +#include <linux/pid_namespace.h>
22197 +#include <linux/ipc_namespace.h>
22198 +#include <net/net_namespace.h>
22199 +#include "../fs/mount.h"
22202 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22203 + .mask = CLONE_FS |
22205 +#ifdef CONFIG_UTS_NS
22208 +#ifdef CONFIG_IPC_NS
22211 +#ifdef CONFIG_USER_NS
22217 +static const struct vcmd_space_mask_v1 space_mask = {
22218 + .mask = CLONE_FS |
22220 +#ifdef CONFIG_UTS_NS
22223 +#ifdef CONFIG_IPC_NS
22226 +#ifdef CONFIG_USER_NS
22229 +#ifdef CONFIG_PID_NS
22232 +#ifdef CONFIG_NET_NS
22238 +static const struct vcmd_space_mask_v1 default_space_mask = {
22239 + .mask = CLONE_FS |
22241 +#ifdef CONFIG_UTS_NS
22244 +#ifdef CONFIG_IPC_NS
22247 +#ifdef CONFIG_USER_NS
22250 +#ifdef CONFIG_PID_NS
22257 + * build a new nsproxy mix
22258 + * assumes that both proxies are 'const'
22259 + * does not touch nsproxy refcounts
22260 + * will hold a reference on the result.
22263 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22264 + struct nsproxy *new_nsproxy, unsigned long mask)
22266 + struct mnt_namespace *old_ns;
22267 + struct uts_namespace *old_uts;
22268 + struct ipc_namespace *old_ipc;
22269 +#ifdef CONFIG_PID_NS
22270 + struct pid_namespace *old_pid;
22272 +#ifdef CONFIG_NET_NS
22273 + struct net *old_net;
22275 + struct nsproxy *nsproxy;
22277 + nsproxy = copy_nsproxy(old_nsproxy);
22281 + if (mask & CLONE_NEWNS) {
22282 + old_ns = nsproxy->mnt_ns;
22283 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22284 + if (nsproxy->mnt_ns)
22285 + get_mnt_ns(nsproxy->mnt_ns);
22289 + if (mask & CLONE_NEWUTS) {
22290 + old_uts = nsproxy->uts_ns;
22291 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22292 + if (nsproxy->uts_ns)
22293 + get_uts_ns(nsproxy->uts_ns);
22297 + if (mask & CLONE_NEWIPC) {
22298 + old_ipc = nsproxy->ipc_ns;
22299 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22300 + if (nsproxy->ipc_ns)
22301 + get_ipc_ns(nsproxy->ipc_ns);
22305 +#ifdef CONFIG_PID_NS
22306 + if (mask & CLONE_NEWPID) {
22307 + old_pid = nsproxy->pid_ns;
22308 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22309 + if (nsproxy->pid_ns)
22310 + get_pid_ns(nsproxy->pid_ns);
22314 +#ifdef CONFIG_NET_NS
22315 + if (mask & CLONE_NEWNET) {
22316 + old_net = nsproxy->net_ns;
22317 + nsproxy->net_ns = new_nsproxy->net_ns;
22318 + if (nsproxy->net_ns)
22319 + get_net(nsproxy->net_ns);
22324 + put_mnt_ns(old_ns);
22326 + put_uts_ns(old_uts);
22328 + put_ipc_ns(old_ipc);
22329 +#ifdef CONFIG_PID_NS
22331 + put_pid_ns(old_pid);
22333 +#ifdef CONFIG_NET_NS
22335 + put_net(old_net);
22343 + * merge two nsproxy structs into a new one.
22344 + * will hold a reference on the result.
22348 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22349 + struct nsproxy *proxy, unsigned long mask)
22351 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22357 + /* vs_mix_nsproxy returns with reference */
22358 + return vs_mix_nsproxy(old ? old : &null_proxy,
22361 + get_nsproxy(proxy);
22366 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22368 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22369 + struct fs_struct *fs_cur, *fs = NULL;
22370 + struct _vx_space *space;
22371 + int ret, kill = 0;
22373 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22374 + vxi, vxi->vx_id, mask, index);
22376 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22379 + if (index >= VX_SPACES)
22382 + space = &vxi->space[index];
22385 + mask = space->vx_nsmask;
22387 + if ((mask & space->vx_nsmask) != mask)
22390 + if (mask & CLONE_FS) {
22391 + fs = copy_fs_struct(space->vx_fs);
22395 + proxy = space->vx_nsproxy;
22397 + vxdprintk(VXD_CBIT(space, 9),
22398 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
22399 + vxi, vxi->vx_id, mask, index, proxy, fs);
22401 + task_lock(current);
22402 + fs_cur = current->fs;
22404 + if (mask & CLONE_FS) {
22405 + spin_lock(&fs_cur->lock);
22406 + current->fs = fs;
22407 + kill = !--fs_cur->users;
22408 + spin_unlock(&fs_cur->lock);
22411 + proxy_cur = current->nsproxy;
22412 + get_nsproxy(proxy_cur);
22413 + task_unlock(current);
22416 + free_fs_struct(fs_cur);
22418 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
22419 + if (IS_ERR(proxy_new)) {
22420 + ret = PTR_ERR(proxy_new);
22424 + proxy_new = xchg(¤t->nsproxy, proxy_new);
22426 + if (mask & CLONE_NEWUSER) {
22427 + struct cred *cred;
22429 + vxdprintk(VXD_CBIT(space, 10),
22430 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
22431 + vxi, vxi->vx_id, space->vx_cred,
22432 + current->real_cred, current->cred);
22434 + if (space->vx_cred) {
22435 + cred = __prepare_creds(space->vx_cred);
22437 + commit_creds(cred);
22444 + put_nsproxy(proxy_new);
22447 + put_nsproxy(proxy_cur);
22452 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22454 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
22455 + struct fs_struct *fs_vxi, *fs;
22456 + struct _vx_space *space;
22457 + int ret, kill = 0;
22459 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
22460 + vxi, vxi->vx_id, mask, index);
22462 + if ((mask & space_mask.mask) != mask)
22465 + if (index >= VX_SPACES)
22468 + space = &vxi->space[index];
22470 + proxy_vxi = space->vx_nsproxy;
22471 + fs_vxi = space->vx_fs;
22473 + if (mask & CLONE_FS) {
22474 + fs = copy_fs_struct(current->fs);
22479 + task_lock(current);
22481 + if (mask & CLONE_FS) {
22482 + spin_lock(&fs_vxi->lock);
22483 + space->vx_fs = fs;
22484 + kill = !--fs_vxi->users;
22485 + spin_unlock(&fs_vxi->lock);
22488 + proxy_cur = current->nsproxy;
22489 + get_nsproxy(proxy_cur);
22490 + task_unlock(current);
22493 + free_fs_struct(fs_vxi);
22495 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
22496 + if (IS_ERR(proxy_new)) {
22497 + ret = PTR_ERR(proxy_new);
22501 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
22502 + space->vx_nsmask |= mask;
22504 + if (mask & CLONE_NEWUSER) {
22505 + struct cred *cred;
22507 + vxdprintk(VXD_CBIT(space, 10),
22508 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
22509 + vxi, vxi->vx_id, space->vx_cred,
22510 + current->real_cred, current->cred);
22512 + cred = prepare_creds();
22513 + cred = (struct cred *)xchg(&space->vx_cred, cred);
22515 + abort_creds(cred);
22521 + put_nsproxy(proxy_new);
22524 + put_nsproxy(proxy_cur);
22529 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
22531 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22533 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22536 + return vx_enter_space(vxi, vc_data.mask, 0);
22539 +int vc_enter_space(struct vx_info *vxi, void __user *data)
22541 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22543 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22546 + if (vc_data.index >= VX_SPACES)
22549 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
22552 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
22554 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22556 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22559 + return vx_set_space(vxi, vc_data.mask, 0);
22562 +int vc_set_space(struct vx_info *vxi, void __user *data)
22564 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22566 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22569 + if (vc_data.index >= VX_SPACES)
22572 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
22575 +int vc_get_space_mask(void __user *data, int type)
22577 + const struct vcmd_space_mask_v1 *mask;
22580 + mask = &space_mask_v0;
22581 + else if (type == 1)
22582 + mask = &space_mask;
22584 + mask = &default_space_mask;
22586 + vxdprintk(VXD_CBIT(space, 10),
22587 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
22589 + if (copy_to_user(data, mask, sizeof(*mask)))
22594 diff -NurpP --minimal linux-3.6/kernel/vserver/switch.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/switch.c
22595 --- linux-3.6/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
22596 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/switch.c 2012-10-04 18:47:00.000000000 +0200
22599 + * linux/kernel/vserver/switch.c
22601 + * Virtual Server: Syscall Switch
22603 + * Copyright (C) 2003-2011 Herbert Pötzl
22605 + * V0.01 syscall switch
22606 + * V0.02 added signal to context
22607 + * V0.03 added rlimit functions
22608 + * V0.04 added iattr, task/xid functions
22609 + * V0.05 added debug/history stuff
22610 + * V0.06 added compat32 layer
22611 + * V0.07 vcmd args and perms
22612 + * V0.08 added status commands
22613 + * V0.09 added tag commands
22614 + * V0.10 added oom bias
22615 + * V0.11 added device commands
22616 + * V0.12 added warn mask
22620 +#include <linux/vs_context.h>
22621 +#include <linux/vs_network.h>
22622 +#include <linux/vserver/switch.h>
22624 +#include "vci_config.h"
22628 +int vc_get_version(uint32_t id)
22630 + return VCI_VERSION;
22634 +int vc_get_vci(uint32_t id)
22636 + return vci_kernel_config();
22639 +#include <linux/vserver/context_cmd.h>
22640 +#include <linux/vserver/cvirt_cmd.h>
22641 +#include <linux/vserver/cacct_cmd.h>
22642 +#include <linux/vserver/limit_cmd.h>
22643 +#include <linux/vserver/network_cmd.h>
22644 +#include <linux/vserver/sched_cmd.h>
22645 +#include <linux/vserver/debug_cmd.h>
22646 +#include <linux/vserver/inode_cmd.h>
22647 +#include <linux/vserver/dlimit_cmd.h>
22648 +#include <linux/vserver/signal_cmd.h>
22649 +#include <linux/vserver/space_cmd.h>
22650 +#include <linux/vserver/tag_cmd.h>
22651 +#include <linux/vserver/device_cmd.h>
22653 +#include <linux/vserver/inode.h>
22654 +#include <linux/vserver/dlimit.h>
22657 +#ifdef CONFIG_COMPAT
22658 +#define __COMPAT(name, id, data, compat) \
22659 + (compat) ? name ## _x32(id, data) : name(id, data)
22660 +#define __COMPAT_NO_ID(name, data, compat) \
22661 + (compat) ? name ## _x32(data) : name(data)
22663 +#define __COMPAT(name, id, data, compat) \
22665 +#define __COMPAT_NO_ID(name, data, compat) \
22671 +long do_vcmd(uint32_t cmd, uint32_t id,
22672 + struct vx_info *vxi, struct nx_info *nxi,
22673 + void __user *data, int compat)
22677 + case VCMD_get_version:
22678 + return vc_get_version(id);
22679 + case VCMD_get_vci:
22680 + return vc_get_vci(id);
22682 + case VCMD_task_xid:
22683 + return vc_task_xid(id);
22684 + case VCMD_vx_info:
22685 + return vc_vx_info(vxi, data);
22687 + case VCMD_task_nid:
22688 + return vc_task_nid(id);
22689 + case VCMD_nx_info:
22690 + return vc_nx_info(nxi, data);
22692 + case VCMD_task_tag:
22693 + return vc_task_tag(id);
22695 + case VCMD_set_space_v1:
22696 + return vc_set_space_v1(vxi, data);
22697 + /* this is version 2 */
22698 + case VCMD_set_space:
22699 + return vc_set_space(vxi, data);
22701 + case VCMD_get_space_mask_v0:
22702 + return vc_get_space_mask(data, 0);
22703 + /* this is version 1 */
22704 + case VCMD_get_space_mask:
22705 + return vc_get_space_mask(data, 1);
22707 + case VCMD_get_space_default:
22708 + return vc_get_space_mask(data, -1);
22710 + case VCMD_set_umask:
22711 + return vc_set_umask(vxi, data);
22713 + case VCMD_get_umask:
22714 + return vc_get_umask(vxi, data);
22716 + case VCMD_set_wmask:
22717 + return vc_set_wmask(vxi, data);
22719 + case VCMD_get_wmask:
22720 + return vc_get_wmask(vxi, data);
22721 +#ifdef CONFIG_IA32_EMULATION
22722 + case VCMD_get_rlimit:
22723 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
22724 + case VCMD_set_rlimit:
22725 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
22727 + case VCMD_get_rlimit:
22728 + return vc_get_rlimit(vxi, data);
22729 + case VCMD_set_rlimit:
22730 + return vc_set_rlimit(vxi, data);
22732 + case VCMD_get_rlimit_mask:
22733 + return vc_get_rlimit_mask(id, data);
22734 + case VCMD_reset_hits:
22735 + return vc_reset_hits(vxi, data);
22736 + case VCMD_reset_minmax:
22737 + return vc_reset_minmax(vxi, data);
22739 + case VCMD_get_vhi_name:
22740 + return vc_get_vhi_name(vxi, data);
22741 + case VCMD_set_vhi_name:
22742 + return vc_set_vhi_name(vxi, data);
22744 + case VCMD_ctx_stat:
22745 + return vc_ctx_stat(vxi, data);
22746 + case VCMD_virt_stat:
22747 + return vc_virt_stat(vxi, data);
22748 + case VCMD_sock_stat:
22749 + return vc_sock_stat(vxi, data);
22750 + case VCMD_rlimit_stat:
22751 + return vc_rlimit_stat(vxi, data);
22753 + case VCMD_set_cflags:
22754 + return vc_set_cflags(vxi, data);
22755 + case VCMD_get_cflags:
22756 + return vc_get_cflags(vxi, data);
22758 + /* this is version 1 */
22759 + case VCMD_set_ccaps:
22760 + return vc_set_ccaps(vxi, data);
22761 + /* this is version 1 */
22762 + case VCMD_get_ccaps:
22763 + return vc_get_ccaps(vxi, data);
22764 + case VCMD_set_bcaps:
22765 + return vc_set_bcaps(vxi, data);
22766 + case VCMD_get_bcaps:
22767 + return vc_get_bcaps(vxi, data);
22769 + case VCMD_set_badness:
22770 + return vc_set_badness(vxi, data);
22771 + case VCMD_get_badness:
22772 + return vc_get_badness(vxi, data);
22774 + case VCMD_set_nflags:
22775 + return vc_set_nflags(nxi, data);
22776 + case VCMD_get_nflags:
22777 + return vc_get_nflags(nxi, data);
22779 + case VCMD_set_ncaps:
22780 + return vc_set_ncaps(nxi, data);
22781 + case VCMD_get_ncaps:
22782 + return vc_get_ncaps(nxi, data);
22784 + case VCMD_set_prio_bias:
22785 + return vc_set_prio_bias(vxi, data);
22786 + case VCMD_get_prio_bias:
22787 + return vc_get_prio_bias(vxi, data);
22788 + case VCMD_add_dlimit:
22789 + return __COMPAT(vc_add_dlimit, id, data, compat);
22790 + case VCMD_rem_dlimit:
22791 + return __COMPAT(vc_rem_dlimit, id, data, compat);
22792 + case VCMD_set_dlimit:
22793 + return __COMPAT(vc_set_dlimit, id, data, compat);
22794 + case VCMD_get_dlimit:
22795 + return __COMPAT(vc_get_dlimit, id, data, compat);
22797 + case VCMD_ctx_kill:
22798 + return vc_ctx_kill(vxi, data);
22800 + case VCMD_wait_exit:
22801 + return vc_wait_exit(vxi, data);
22803 + case VCMD_get_iattr:
22804 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
22805 + case VCMD_set_iattr:
22806 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
22808 + case VCMD_fget_iattr:
22809 + return vc_fget_iattr(id, data);
22810 + case VCMD_fset_iattr:
22811 + return vc_fset_iattr(id, data);
22813 + case VCMD_enter_space_v0:
22814 + return vc_enter_space_v1(vxi, NULL);
22815 + case VCMD_enter_space_v1:
22816 + return vc_enter_space_v1(vxi, data);
22817 + /* this is version 2 */
22818 + case VCMD_enter_space:
22819 + return vc_enter_space(vxi, data);
22821 + case VCMD_ctx_create_v0:
22822 + return vc_ctx_create(id, NULL);
22823 + case VCMD_ctx_create:
22824 + return vc_ctx_create(id, data);
22825 + case VCMD_ctx_migrate_v0:
22826 + return vc_ctx_migrate(vxi, NULL);
22827 + case VCMD_ctx_migrate:
22828 + return vc_ctx_migrate(vxi, data);
22830 + case VCMD_net_create_v0:
22831 + return vc_net_create(id, NULL);
22832 + case VCMD_net_create:
22833 + return vc_net_create(id, data);
22834 + case VCMD_net_migrate:
22835 + return vc_net_migrate(nxi, data);
22837 + case VCMD_tag_migrate:
22838 + return vc_tag_migrate(id);
22840 + case VCMD_net_add:
22841 + return vc_net_add(nxi, data);
22842 + case VCMD_net_remove:
22843 + return vc_net_remove(nxi, data);
22845 + case VCMD_net_add_ipv4_v1:
22846 + return vc_net_add_ipv4_v1(nxi, data);
22847 + /* this is version 2 */
22848 + case VCMD_net_add_ipv4:
22849 + return vc_net_add_ipv4(nxi, data);
22851 + case VCMD_net_rem_ipv4_v1:
22852 + return vc_net_rem_ipv4_v1(nxi, data);
22853 + /* this is version 2 */
22854 + case VCMD_net_rem_ipv4:
22855 + return vc_net_rem_ipv4(nxi, data);
22856 +#ifdef CONFIG_IPV6
22857 + case VCMD_net_add_ipv6:
22858 + return vc_net_add_ipv6(nxi, data);
22859 + case VCMD_net_remove_ipv6:
22860 + return vc_net_remove_ipv6(nxi, data);
22862 +/* case VCMD_add_match_ipv4:
22863 + return vc_add_match_ipv4(nxi, data);
22864 + case VCMD_get_match_ipv4:
22865 + return vc_get_match_ipv4(nxi, data);
22866 +#ifdef CONFIG_IPV6
22867 + case VCMD_add_match_ipv6:
22868 + return vc_add_match_ipv6(nxi, data);
22869 + case VCMD_get_match_ipv6:
22870 + return vc_get_match_ipv6(nxi, data);
22873 +#ifdef CONFIG_VSERVER_DEVICE
22874 + case VCMD_set_mapping:
22875 + return __COMPAT(vc_set_mapping, vxi, data, compat);
22876 + case VCMD_unset_mapping:
22877 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
22879 +#ifdef CONFIG_VSERVER_HISTORY
22880 + case VCMD_dump_history:
22881 + return vc_dump_history(id);
22882 + case VCMD_read_history:
22883 + return __COMPAT(vc_read_history, id, data, compat);
22886 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
22887 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
22893 +#define __VCMD(vcmd, _perm, _args, _flags) \
22894 + case VCMD_ ## vcmd: perm = _perm; \
22895 + args = _args; flags = _flags; break
22898 +#define VCA_NONE 0x00
22899 +#define VCA_VXI 0x01
22900 +#define VCA_NXI 0x02
22902 +#define VCF_NONE 0x00
22903 +#define VCF_INFO 0x01
22904 +#define VCF_ADMIN 0x02
22905 +#define VCF_ARES 0x06 /* includes admin */
22906 +#define VCF_SETUP 0x08
22908 +#define VCF_ZIDOK 0x10 /* zero id okay */
22912 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
22915 + int permit = -1, state = 0;
22916 + int perm = -1, args = 0, flags = 0;
22917 + struct vx_info *vxi = NULL;
22918 + struct nx_info *nxi = NULL;
22921 + /* unpriviledged commands */
22922 + __VCMD(get_version, 0, VCA_NONE, 0);
22923 + __VCMD(get_vci, 0, VCA_NONE, 0);
22924 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
22925 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
22926 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
22927 + __VCMD(get_space_default,0, VCA_NONE, 0);
22929 + /* info commands */
22930 + __VCMD(task_xid, 2, VCA_NONE, 0);
22931 + __VCMD(reset_hits, 2, VCA_VXI, 0);
22932 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
22933 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
22934 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
22935 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
22936 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
22937 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
22938 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
22939 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
22940 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
22941 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
22943 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
22944 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
22945 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
22946 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
22948 + __VCMD(task_nid, 2, VCA_NONE, 0);
22949 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
22950 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
22951 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
22953 + __VCMD(task_tag, 2, VCA_NONE, 0);
22955 + __VCMD(get_iattr, 2, VCA_NONE, 0);
22956 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
22957 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
22958 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
22960 + /* lower admin commands */
22961 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
22962 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
22963 + __VCMD(ctx_create, 5, VCA_NONE, 0);
22964 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
22965 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
22966 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
22967 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
22968 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
22970 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
22971 + __VCMD(net_create, 5, VCA_NONE, 0);
22972 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
22974 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
22976 + /* higher admin commands */
22977 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
22978 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
22979 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
22981 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
22982 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
22983 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
22984 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
22985 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
22986 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
22988 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
22989 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
22990 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
22992 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
22993 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
22994 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
22995 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
22996 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
22997 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
22998 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
22999 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23000 +#ifdef CONFIG_IPV6
23001 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23002 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23004 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23005 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23006 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23007 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23008 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23010 +#ifdef CONFIG_VSERVER_DEVICE
23011 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23012 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23014 + /* debug level admin commands */
23015 +#ifdef CONFIG_VSERVER_HISTORY
23016 + __VCMD(dump_history, 9, VCA_NONE, 0);
23017 + __VCMD(read_history, 9, VCA_NONE, 0);
23024 + vxdprintk(VXD_CBIT(switch, 0),
23025 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23026 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23027 + VC_VERSION(cmd), id, data, compat,
23028 + perm, args, flags);
23035 + if (!capable(CAP_CONTEXT))
23039 + /* moved here from the individual commands */
23041 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23045 + /* vcmd involves resource management */
23047 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23051 + /* various legacy exceptions */
23053 + /* will go away when spectator is a cap */
23054 + case VCMD_ctx_migrate_v0:
23055 + case VCMD_ctx_migrate:
23057 + current->xid = 1;
23063 + /* will go away when spectator is a cap */
23064 + case VCMD_net_migrate:
23066 + current->nid = 1;
23073 + /* vcmds are fine by default */
23076 + /* admin type vcmds require admin ... */
23077 + if (flags & VCF_ADMIN)
23078 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23080 + /* ... but setup type vcmds override that */
23081 + if (!permit && (flags & VCF_SETUP))
23082 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23090 + if (!id && (flags & VCF_ZIDOK))
23094 + if (args & VCA_VXI) {
23095 + vxi = lookup_vx_info(id);
23099 + if ((flags & VCF_ADMIN) &&
23100 + /* special case kill for shutdown */
23101 + (cmd != VCMD_ctx_kill) &&
23102 + /* can context be administrated? */
23103 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23109 + if (args & VCA_NXI) {
23110 + nxi = lookup_nx_info(id);
23114 + if ((flags & VCF_ADMIN) &&
23115 + /* can context be administrated? */
23116 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23123 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23126 + if ((args & VCA_NXI) && nxi)
23127 + put_nx_info(nxi);
23129 + if ((args & VCA_VXI) && vxi)
23130 + put_vx_info(vxi);
23132 + vxdprintk(VXD_CBIT(switch, 1),
23133 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23134 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23135 + VC_VERSION(cmd), ret, ret, state, permit);
23140 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23142 + return do_vserver(cmd, id, data, 0);
23145 +#ifdef CONFIG_COMPAT
23148 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23150 + return do_vserver(cmd, id, data, 1);
23153 +#endif /* CONFIG_COMPAT */
23154 diff -NurpP --minimal linux-3.6/kernel/vserver/sysctl.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/sysctl.c
23155 --- linux-3.6/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23156 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/sysctl.c 2012-10-04 18:47:00.000000000 +0200
23159 + * kernel/vserver/sysctl.c
23161 + * Virtual Context Support
23163 + * Copyright (C) 2004-2007 Herbert Pötzl
23165 + * V0.01 basic structure
23169 +#include <linux/module.h>
23170 +#include <linux/ctype.h>
23171 +#include <linux/sysctl.h>
23172 +#include <linux/parser.h>
23173 +#include <asm/uaccess.h>
23176 + CTL_DEBUG_ERROR = 0,
23177 + CTL_DEBUG_SWITCH = 1,
23193 +unsigned int vs_debug_switch = 0;
23194 +unsigned int vs_debug_xid = 0;
23195 +unsigned int vs_debug_nid = 0;
23196 +unsigned int vs_debug_tag = 0;
23197 +unsigned int vs_debug_net = 0;
23198 +unsigned int vs_debug_limit = 0;
23199 +unsigned int vs_debug_cres = 0;
23200 +unsigned int vs_debug_dlim = 0;
23201 +unsigned int vs_debug_quota = 0;
23202 +unsigned int vs_debug_cvirt = 0;
23203 +unsigned int vs_debug_space = 0;
23204 +unsigned int vs_debug_perm = 0;
23205 +unsigned int vs_debug_misc = 0;
23208 +static struct ctl_table_header *vserver_table_header;
23209 +static ctl_table vserver_root_table[];
23212 +void vserver_register_sysctl(void)
23214 + if (!vserver_table_header) {
23215 + vserver_table_header = register_sysctl_table(vserver_root_table);
23220 +void vserver_unregister_sysctl(void)
23222 + if (vserver_table_header) {
23223 + unregister_sysctl_table(vserver_table_header);
23224 + vserver_table_header = NULL;
23229 +static int proc_dodebug(ctl_table *table, int write,
23230 + void __user *buffer, size_t *lenp, loff_t *ppos)
23232 + char tmpbuf[20], *p, c;
23233 + unsigned int value;
23234 + size_t left, len;
23236 + if ((*ppos && !write) || !*lenp) {
23244 + if (!access_ok(VERIFY_READ, buffer, left))
23246 + p = (char *)buffer;
23247 + while (left && __get_user(c, p) >= 0 && isspace(c))
23252 + if (left > sizeof(tmpbuf) - 1)
23254 + if (copy_from_user(tmpbuf, p, left))
23256 + tmpbuf[left] = '\0';
23258 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23259 + value = 10 * value + (*p - '0');
23260 + if (*p && !isspace(*p))
23262 + while (left && isspace(*p))
23264 + *(unsigned int *)table->data = value;
23266 + if (!access_ok(VERIFY_WRITE, buffer, left))
23268 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23271 + if (__copy_to_user(buffer, tmpbuf, len))
23273 + if ((left -= len) > 0) {
23274 + if (put_user('\n', (char *)buffer + len))
23288 +#define CTL_ENTRY(ctl, name) \
23290 + .procname = #name, \
23291 + .data = &vs_ ## name, \
23292 + .maxlen = sizeof(int), \
23294 + .proc_handler = &proc_dodebug, \
23295 + .extra1 = &zero, \
23296 + .extra2 = &zero, \
23299 +static ctl_table vserver_debug_table[] = {
23300 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23301 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23302 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23303 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23304 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23305 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23306 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23307 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23308 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23309 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23310 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23311 + CTL_ENTRY(CTL_DEBUG_PERM, debug_perm),
23312 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23316 +static ctl_table vserver_root_table[] = {
23318 + .procname = "vserver",
23320 + .child = vserver_debug_table
23326 +static match_table_t tokens = {
23327 + { CTL_DEBUG_SWITCH, "switch=%x" },
23328 + { CTL_DEBUG_XID, "xid=%x" },
23329 + { CTL_DEBUG_NID, "nid=%x" },
23330 + { CTL_DEBUG_TAG, "tag=%x" },
23331 + { CTL_DEBUG_NET, "net=%x" },
23332 + { CTL_DEBUG_LIMIT, "limit=%x" },
23333 + { CTL_DEBUG_CRES, "cres=%x" },
23334 + { CTL_DEBUG_DLIM, "dlim=%x" },
23335 + { CTL_DEBUG_QUOTA, "quota=%x" },
23336 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23337 + { CTL_DEBUG_SPACE, "space=%x" },
23338 + { CTL_DEBUG_PERM, "perm=%x" },
23339 + { CTL_DEBUG_MISC, "misc=%x" },
23340 + { CTL_DEBUG_ERROR, NULL }
23343 +#define HANDLE_CASE(id, name, val) \
23344 + case CTL_DEBUG_ ## id: \
23345 + vs_debug_ ## name = val; \
23346 + printk("vs_debug_" #name "=0x%x\n", val); \
23350 +static int __init vs_debug_setup(char *str)
23355 + printk("vs_debug_setup(%s)\n", str);
23356 + while ((p = strsep(&str, ",")) != NULL) {
23357 + substring_t args[MAX_OPT_ARGS];
23358 + unsigned int value;
23363 + token = match_token(p, tokens, args);
23364 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23367 + HANDLE_CASE(SWITCH, switch, value);
23368 + HANDLE_CASE(XID, xid, value);
23369 + HANDLE_CASE(NID, nid, value);
23370 + HANDLE_CASE(TAG, tag, value);
23371 + HANDLE_CASE(NET, net, value);
23372 + HANDLE_CASE(LIMIT, limit, value);
23373 + HANDLE_CASE(CRES, cres, value);
23374 + HANDLE_CASE(DLIM, dlim, value);
23375 + HANDLE_CASE(QUOTA, quota, value);
23376 + HANDLE_CASE(CVIRT, cvirt, value);
23377 + HANDLE_CASE(SPACE, space, value);
23378 + HANDLE_CASE(PERM, perm, value);
23379 + HANDLE_CASE(MISC, misc, value);
23388 +__setup("vsdebug=", vs_debug_setup);
23392 +EXPORT_SYMBOL_GPL(vs_debug_switch);
23393 +EXPORT_SYMBOL_GPL(vs_debug_xid);
23394 +EXPORT_SYMBOL_GPL(vs_debug_nid);
23395 +EXPORT_SYMBOL_GPL(vs_debug_net);
23396 +EXPORT_SYMBOL_GPL(vs_debug_limit);
23397 +EXPORT_SYMBOL_GPL(vs_debug_cres);
23398 +EXPORT_SYMBOL_GPL(vs_debug_dlim);
23399 +EXPORT_SYMBOL_GPL(vs_debug_quota);
23400 +EXPORT_SYMBOL_GPL(vs_debug_cvirt);
23401 +EXPORT_SYMBOL_GPL(vs_debug_space);
23402 +EXPORT_SYMBOL_GPL(vs_debug_perm);
23403 +EXPORT_SYMBOL_GPL(vs_debug_misc);
23405 diff -NurpP --minimal linux-3.6/kernel/vserver/tag.c linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/tag.c
23406 --- linux-3.6/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
23407 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/tag.c 2012-10-04 18:47:00.000000000 +0200
23410 + * linux/kernel/vserver/tag.c
23412 + * Virtual Server: Shallow Tag Space
23414 + * Copyright (C) 2007 Herbert Pötzl
23416 + * V0.01 basic implementation
23420 +#include <linux/sched.h>
23421 +#include <linux/vserver/debug.h>
23422 +#include <linux/vs_pid.h>
23423 +#include <linux/vs_tag.h>
23425 +#include <linux/vserver/tag_cmd.h>
23428 +int dx_migrate_task(struct task_struct *p, tag_t tag)
23433 + vxdprintk(VXD_CBIT(tag, 5),
23434 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
23440 + vxdprintk(VXD_CBIT(tag, 5),
23441 + "moved task %p into [#%d]", p, tag);
23445 +/* vserver syscall commands below here */
23447 +/* taks xid and vx_info functions */
23450 +int vc_task_tag(uint32_t id)
23455 + struct task_struct *tsk;
23457 + tsk = find_task_by_real_pid(id);
23458 + tag = (tsk) ? tsk->tag : -ESRCH;
23459 + rcu_read_unlock();
23461 + tag = dx_current_tag();
23466 +int vc_tag_migrate(uint32_t tag)
23468 + return dx_migrate_task(current, tag & 0xFFFF);
23472 diff -NurpP --minimal linux-3.6/kernel/vserver/vci_config.h linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/vci_config.h
23473 --- linux-3.6/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
23474 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/kernel/vserver/vci_config.h 2012-10-04 18:47:00.000000000 +0200
23477 +/* interface version */
23479 +#define VCI_VERSION 0x00020308
23483 + VCI_KCBIT_NO_DYNAMIC = 0,
23485 + VCI_KCBIT_PROC_SECURE = 4,
23486 + /* VCI_KCBIT_HARDCPU = 5, */
23487 + /* VCI_KCBIT_IDLELIMIT = 6, */
23488 + /* VCI_KCBIT_IDLETIME = 7, */
23490 + VCI_KCBIT_COWBL = 8,
23491 + VCI_KCBIT_FULLCOWBL = 9,
23492 + VCI_KCBIT_SPACES = 10,
23493 + VCI_KCBIT_NETV2 = 11,
23494 + VCI_KCBIT_MEMCG = 12,
23496 + VCI_KCBIT_DEBUG = 16,
23497 + VCI_KCBIT_HISTORY = 20,
23498 + VCI_KCBIT_TAGGED = 24,
23499 + VCI_KCBIT_PPTAG = 28,
23501 + VCI_KCBIT_MORE = 31,
23505 +static inline uint32_t vci_kernel_config(void)
23508 + (1 << VCI_KCBIT_NO_DYNAMIC) |
23510 + /* configured features */
23511 +#ifdef CONFIG_VSERVER_PROC_SECURE
23512 + (1 << VCI_KCBIT_PROC_SECURE) |
23514 +#ifdef CONFIG_VSERVER_COWBL
23515 + (1 << VCI_KCBIT_COWBL) |
23516 + (1 << VCI_KCBIT_FULLCOWBL) |
23518 + (1 << VCI_KCBIT_SPACES) |
23519 + (1 << VCI_KCBIT_NETV2) |
23520 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
23521 + (1 << VCI_KCBIT_MEMCG) |
23524 + /* debug options */
23525 +#ifdef CONFIG_VSERVER_DEBUG
23526 + (1 << VCI_KCBIT_DEBUG) |
23528 +#ifdef CONFIG_VSERVER_HISTORY
23529 + (1 << VCI_KCBIT_HISTORY) |
23532 + /* inode context tagging */
23533 +#if defined(CONFIG_TAGGING_NONE)
23534 + (0 << VCI_KCBIT_TAGGED) |
23535 +#elif defined(CONFIG_TAGGING_UID16)
23536 + (1 << VCI_KCBIT_TAGGED) |
23537 +#elif defined(CONFIG_TAGGING_GID16)
23538 + (2 << VCI_KCBIT_TAGGED) |
23539 +#elif defined(CONFIG_TAGGING_ID24)
23540 + (3 << VCI_KCBIT_TAGGED) |
23541 +#elif defined(CONFIG_TAGGING_INTERN)
23542 + (4 << VCI_KCBIT_TAGGED) |
23543 +#elif defined(CONFIG_TAGGING_RUNTIME)
23544 + (5 << VCI_KCBIT_TAGGED) |
23546 + (7 << VCI_KCBIT_TAGGED) |
23548 + (1 << VCI_KCBIT_PPTAG) |
23552 diff -NurpP --minimal linux-3.6/mm/memcontrol.c linux-3.6-vs2.3.4.3-noxfs-nocow/mm/memcontrol.c
23553 --- linux-3.6/mm/memcontrol.c 2012-10-04 15:27:48.000000000 +0200
23554 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/mm/memcontrol.c 2012-10-04 18:47:00.000000000 +0200
23555 @@ -885,6 +885,31 @@ struct mem_cgroup *mem_cgroup_from_task(
23556 return mem_cgroup_from_css(task_subsys_state(p, mem_cgroup_subsys_id));
23559 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
23561 + return res_counter_read_u64(&mem->res, member);
23564 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
23566 + return res_counter_read_u64(&mem->memsw, member);
23569 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
23571 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
23574 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
23576 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
23579 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
23581 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
23584 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
23586 struct mem_cgroup *memcg = NULL;
23587 diff -NurpP --minimal linux-3.6/mm/oom_kill.c linux-3.6-vs2.3.4.3-noxfs-nocow/mm/oom_kill.c
23588 --- linux-3.6/mm/oom_kill.c 2012-10-04 15:27:48.000000000 +0200
23589 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/mm/oom_kill.c 2012-10-04 18:53:46.000000000 +0200
23591 #include <linux/freezer.h>
23592 #include <linux/ftrace.h>
23593 #include <linux/ratelimit.h>
23594 +#include <linux/reboot.h>
23595 +#include <linux/vs_context.h>
23597 #define CREATE_TRACE_POINTS
23598 #include <trace/events/oom.h>
23599 @@ -155,11 +157,18 @@ struct task_struct *find_lock_task_mm(st
23600 static bool oom_unkillable_task(struct task_struct *p,
23601 const struct mem_cgroup *memcg, const nodemask_t *nodemask)
23603 - if (is_global_init(p))
23604 + unsigned xid = vx_current_xid();
23606 + /* skip the init task, global and per guest */
23607 + if (task_is_init(p))
23609 if (p->flags & PF_KTHREAD)
23612 + /* skip other guest and host processes if oom in guest */
23613 + if (xid && vx_task_xid(p) != xid)
23616 /* When mem_cgroup_out_of_memory() and p is not member of the group */
23617 if (memcg && !task_in_mem_cgroup(p, memcg))
23619 @@ -472,8 +481,8 @@ void oom_kill_process(struct task_struct
23620 dump_header(p, gfp_mask, order, memcg, nodemask);
23623 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
23624 - message, task_pid_nr(p), p->comm, points);
23625 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
23626 + message, task_pid_nr(p), p->xid, p->comm, points);
23630 @@ -518,8 +527,8 @@ void oom_kill_process(struct task_struct
23632 /* mm cannot safely be dereferenced after task_unlock(victim) */
23634 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23635 - task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
23636 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23637 + task_pid_nr(victim), victim->xid, victim->comm, K(victim->mm->total_vm),
23638 K(get_mm_counter(victim->mm, MM_ANONPAGES)),
23639 K(get_mm_counter(victim->mm, MM_FILEPAGES)));
23640 task_unlock(victim);
23641 @@ -589,6 +598,8 @@ int unregister_oom_notifier(struct notif
23643 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
23645 +long vs_oom_action(unsigned int);
23648 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
23649 * if a parallel OOM killing is already taking place that includes a zone in
23650 @@ -738,7 +749,12 @@ void out_of_memory(struct zonelist *zone
23651 /* Found nothing?!?! Either we hang forever, or we panic. */
23653 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
23654 - panic("Out of memory and no killable processes...\n");
23656 + /* avoid panic for guest OOM */
23657 + if (current->xid)
23658 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
23660 + panic("Out of memory and no killable processes...\n");
23662 if (PTR_ERR(p) != -1UL) {
23663 oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
23664 diff -NurpP --minimal linux-3.6/mm/page_alloc.c linux-3.6-vs2.3.4.3-noxfs-nocow/mm/page_alloc.c
23665 --- linux-3.6/mm/page_alloc.c 2012-10-04 15:27:48.000000000 +0200
23666 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/mm/page_alloc.c 2012-10-04 18:47:00.000000000 +0200
23668 #include <linux/prefetch.h>
23669 #include <linux/migrate.h>
23670 #include <linux/page-debug-flags.h>
23671 +#include <linux/vs_base.h>
23672 +#include <linux/vs_limit.h>
23674 #include <asm/tlbflush.h>
23675 #include <asm/div64.h>
23676 @@ -2773,6 +2775,9 @@ void si_meminfo(struct sysinfo *val)
23677 val->totalhigh = totalhigh_pages;
23678 val->freehigh = nr_free_highpages();
23679 val->mem_unit = PAGE_SIZE;
23681 + if (vx_flags(VXF_VIRT_MEM, 0))
23682 + vx_vsi_meminfo(val);
23685 EXPORT_SYMBOL(si_meminfo);
23686 @@ -2793,6 +2798,9 @@ void si_meminfo_node(struct sysinfo *val
23689 val->mem_unit = PAGE_SIZE;
23691 + if (vx_flags(VXF_VIRT_MEM, 0))
23692 + vx_vsi_meminfo(val);
23696 diff -NurpP --minimal linux-3.6/mm/pgtable-generic.c linux-3.6-vs2.3.4.3-noxfs-nocow/mm/pgtable-generic.c
23697 --- linux-3.6/mm/pgtable-generic.c 2012-07-22 23:39:47.000000000 +0200
23698 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/mm/pgtable-generic.c 2012-10-04 18:47:00.000000000 +0200
23700 * Copyright (C) 2010 Linus Torvalds
23703 +#include <linux/mm.h>
23705 #include <linux/pagemap.h>
23706 #include <asm/tlb.h>
23707 #include <asm-generic/pgtable.h>
23708 diff -NurpP --minimal linux-3.6/mm/shmem.c linux-3.6-vs2.3.4.3-noxfs-nocow/mm/shmem.c
23709 --- linux-3.6/mm/shmem.c 2012-10-04 15:27:48.000000000 +0200
23710 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/mm/shmem.c 2012-10-04 18:47:00.000000000 +0200
23711 @@ -1814,7 +1814,7 @@ static int shmem_statfs(struct dentry *d
23713 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
23715 - buf->f_type = TMPFS_MAGIC;
23716 + buf->f_type = TMPFS_SUPER_MAGIC;
23717 buf->f_bsize = PAGE_CACHE_SIZE;
23718 buf->f_namelen = NAME_MAX;
23719 if (sbinfo->max_blocks) {
23720 @@ -2630,7 +2630,7 @@ int shmem_fill_super(struct super_block
23721 sb->s_maxbytes = MAX_LFS_FILESIZE;
23722 sb->s_blocksize = PAGE_CACHE_SIZE;
23723 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
23724 - sb->s_magic = TMPFS_MAGIC;
23725 + sb->s_magic = TMPFS_SUPER_MAGIC;
23726 sb->s_op = &shmem_ops;
23727 sb->s_time_gran = 1;
23728 #ifdef CONFIG_TMPFS_XATTR
23729 diff -NurpP --minimal linux-3.6/mm/slab.c linux-3.6-vs2.3.4.3-noxfs-nocow/mm/slab.c
23730 --- linux-3.6/mm/slab.c 2012-10-04 15:27:48.000000000 +0200
23731 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/mm/slab.c 2012-10-04 18:47:00.000000000 +0200
23732 @@ -445,6 +445,8 @@ static void kmem_list3_init(struct kmem_
23733 #define STATS_INC_FREEMISS(x) do { } while (0)
23736 +#include "slab_vs.h"
23741 @@ -3539,6 +3541,7 @@ retry:
23743 obj = slab_get_obj(cachep, slabp, nodeid);
23744 check_slabp(cachep, slabp);
23745 + vx_slab_alloc(cachep, flags);
23746 l3->free_objects--;
23747 /* move slabp to correct slabp list: */
23748 list_del(&slabp->list);
23749 @@ -3616,6 +3619,7 @@ __cache_alloc_node(struct kmem_cache *ca
23750 /* ___cache_alloc_node can fall back to other nodes */
23751 ptr = ____cache_alloc_node(cachep, flags, nodeid);
23753 + vx_slab_alloc(cachep, flags);
23754 local_irq_restore(save_flags);
23755 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
23756 kmemleak_alloc_recursive(ptr, cachep->object_size, 1, cachep->flags,
23757 @@ -3806,6 +3810,7 @@ static inline void __cache_free(struct k
23759 kmemleak_free_recursive(objp, cachep->flags);
23760 objp = cache_free_debugcheck(cachep, objp, caller);
23761 + vx_slab_free(cachep);
23763 kmemcheck_slab_free(cachep, objp, cachep->object_size);
23765 diff -NurpP --minimal linux-3.6/mm/slab_vs.h linux-3.6-vs2.3.4.3-noxfs-nocow/mm/slab_vs.h
23766 --- linux-3.6/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
23767 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/mm/slab_vs.h 2012-10-04 18:47:00.000000000 +0200
23770 +#include <linux/vserver/context.h>
23772 +#include <linux/vs_context.h>
23775 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
23777 + int what = gfp_zone(cachep->gfpflags);
23778 + struct vx_info *vxi = current_vx_info();
23783 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
23787 +void vx_slab_free(struct kmem_cache *cachep)
23789 + int what = gfp_zone(cachep->gfpflags);
23790 + struct vx_info *vxi = current_vx_info();
23795 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
23798 diff -NurpP --minimal linux-3.6/mm/swapfile.c linux-3.6-vs2.3.4.3-noxfs-nocow/mm/swapfile.c
23799 --- linux-3.6/mm/swapfile.c 2012-10-04 15:27:48.000000000 +0200
23800 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/mm/swapfile.c 2012-10-04 18:47:00.000000000 +0200
23802 #include <asm/tlbflush.h>
23803 #include <linux/swapops.h>
23804 #include <linux/page_cgroup.h>
23805 +#include <linux/vs_base.h>
23807 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
23809 @@ -1686,6 +1687,16 @@ static int swap_show(struct seq_file *sw
23811 if (si == SEQ_START_TOKEN) {
23812 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
23813 + if (vx_flags(VXF_VIRT_MEM, 0)) {
23814 + struct sysinfo si;
23816 + vx_vsi_swapinfo(&si);
23817 + if (si.totalswap < (1 << 10))
23819 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
23820 + "hdv0", "partition", si.totalswap >> 10,
23821 + (si.totalswap - si.freeswap) >> 10, -1);
23826 @@ -2113,6 +2124,8 @@ void si_swapinfo(struct sysinfo *val)
23827 val->freeswap = nr_swap_pages + nr_to_be_unused;
23828 val->totalswap = total_swap_pages + nr_to_be_unused;
23829 spin_unlock(&swap_lock);
23830 + if (vx_flags(VXF_VIRT_MEM, 0))
23831 + vx_vsi_swapinfo(val);
23835 diff -NurpP --minimal linux-3.6/net/bridge/br_multicast.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/bridge/br_multicast.c
23836 --- linux-3.6/net/bridge/br_multicast.c 2012-10-04 15:27:49.000000000 +0200
23837 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/bridge/br_multicast.c 2012-10-04 18:47:00.000000000 +0200
23838 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
23839 ip6h->hop_limit = 1;
23840 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
23841 if (ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
23843 + &ip6h->saddr, NULL)) {
23847 diff -NurpP --minimal linux-3.6/net/core/dev.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/core/dev.c
23848 --- linux-3.6/net/core/dev.c 2012-10-04 15:27:49.000000000 +0200
23849 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/core/dev.c 2012-10-04 18:47:00.000000000 +0200
23850 @@ -126,6 +126,7 @@
23851 #include <linux/in.h>
23852 #include <linux/jhash.h>
23853 #include <linux/random.h>
23854 +#include <linux/vs_inet.h>
23855 #include <trace/events/napi.h>
23856 #include <trace/events/net.h>
23857 #include <trace/events/skb.h>
23858 @@ -620,7 +621,8 @@ struct net_device *__dev_get_by_name(str
23859 struct hlist_head *head = dev_name_hash(net, name);
23861 hlist_for_each_entry(dev, p, head, name_hlist)
23862 - if (!strncmp(dev->name, name, IFNAMSIZ))
23863 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
23864 + nx_dev_visible(current_nx_info(), dev))
23868 @@ -646,7 +648,8 @@ struct net_device *dev_get_by_name_rcu(s
23869 struct hlist_head *head = dev_name_hash(net, name);
23871 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
23872 - if (!strncmp(dev->name, name, IFNAMSIZ))
23873 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
23874 + nx_dev_visible(current_nx_info(), dev))
23878 @@ -697,7 +700,8 @@ struct net_device *__dev_get_by_index(st
23879 struct hlist_head *head = dev_index_hash(net, ifindex);
23881 hlist_for_each_entry(dev, p, head, index_hlist)
23882 - if (dev->ifindex == ifindex)
23883 + if ((dev->ifindex == ifindex) &&
23884 + nx_dev_visible(current_nx_info(), dev))
23888 @@ -715,7 +719,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
23889 * about locking. The caller must hold RCU lock.
23892 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
23893 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
23895 struct hlist_node *p;
23896 struct net_device *dev;
23897 @@ -727,6 +731,16 @@ struct net_device *dev_get_by_index_rcu(
23901 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
23903 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
23905 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
23907 + if (nx_dev_visible(current_nx_info(), dev))
23911 EXPORT_SYMBOL(dev_get_by_index_rcu);
23914 @@ -775,7 +789,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
23916 for_each_netdev_rcu(net, dev)
23917 if (dev->type == type &&
23918 - !memcmp(dev->dev_addr, ha, dev->addr_len))
23919 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
23920 + nx_dev_visible(current_nx_info(), dev))
23924 @@ -787,9 +802,11 @@ struct net_device *__dev_getfirstbyhwtyp
23925 struct net_device *dev;
23928 - for_each_netdev(net, dev)
23929 - if (dev->type == type)
23930 + for_each_netdev(net, dev) {
23931 + if ((dev->type == type) &&
23932 + nx_dev_visible(current_nx_info(), dev))
23938 @@ -907,6 +924,8 @@ static int __dev_alloc_name(struct net *
23940 if (i < 0 || i >= max_netdevices)
23942 + if (!nx_dev_visible(current_nx_info(), d))
23945 /* avoid cases where sscanf is not exact inverse of printf */
23946 snprintf(buf, IFNAMSIZ, name, i);
23947 @@ -4071,6 +4090,8 @@ static int dev_ifconf(struct net *net, c
23950 for_each_netdev(net, dev) {
23951 + if (!nx_dev_visible(current_nx_info(), dev))
23953 for (i = 0; i < NPROTO; i++) {
23954 if (gifconf_list[i]) {
23956 @@ -4173,6 +4194,10 @@ static void dev_seq_printf_stats(struct
23957 struct rtnl_link_stats64 temp;
23958 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
23960 + /* device visible inside network context? */
23961 + if (!nx_dev_visible(current_nx_info(), dev))
23964 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
23965 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
23966 dev->name, stats->rx_bytes, stats->rx_packets,
23967 diff -NurpP --minimal linux-3.6/net/core/rtnetlink.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/core/rtnetlink.c
23968 --- linux-3.6/net/core/rtnetlink.c 2012-10-04 15:27:49.000000000 +0200
23969 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/core/rtnetlink.c 2012-10-04 18:47:00.000000000 +0200
23970 @@ -1080,6 +1080,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
23971 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
23974 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
23976 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
23977 NETLINK_CB(cb->skb).pid,
23978 cb->nlh->nlmsg_seq, 0,
23979 @@ -1969,6 +1971,9 @@ void rtmsg_ifinfo(int type, struct net_d
23980 int err = -ENOBUFS;
23981 size_t if_info_size;
23983 + if (!nx_dev_visible(current_nx_info(), dev))
23986 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev, 0)), GFP_KERNEL);
23989 diff -NurpP --minimal linux-3.6/net/core/sock.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/core/sock.c
23990 --- linux-3.6/net/core/sock.c 2012-10-04 15:27:49.000000000 +0200
23991 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/core/sock.c 2012-10-04 18:47:00.000000000 +0200
23992 @@ -132,6 +132,10 @@
23993 #include <net/netprio_cgroup.h>
23995 #include <linux/filter.h>
23996 +#include <linux/vs_socket.h>
23997 +#include <linux/vs_limit.h>
23998 +#include <linux/vs_context.h>
23999 +#include <linux/vs_network.h>
24001 #include <trace/events/sock.h>
24003 @@ -1194,6 +1198,8 @@ static struct sock *sk_prot_alloc(struct
24005 sk_tx_queue_clear(sk);
24007 + sock_vx_init(sk);
24008 + sock_nx_init(sk);
24012 @@ -1302,6 +1308,11 @@ static void __sk_free(struct sock *sk)
24013 put_cred(sk->sk_peer_cred);
24014 put_pid(sk->sk_peer_pid);
24015 put_net(sock_net(sk));
24017 + clr_vx_info(&sk->sk_vx_info);
24019 + clr_nx_info(&sk->sk_nx_info);
24021 sk_prot_free(sk->sk_prot_creator, sk);
24024 @@ -1362,6 +1373,8 @@ struct sock *sk_clone_lock(const struct
24027 get_net(sock_net(newsk));
24028 + sock_vx_init(newsk);
24029 + sock_nx_init(newsk);
24030 sk_node_init(&newsk->sk_node);
24031 sock_lock_init(newsk);
24032 bh_lock_sock(newsk);
24033 @@ -1418,6 +1431,12 @@ struct sock *sk_clone_lock(const struct
24035 atomic_set(&newsk->sk_refcnt, 2);
24037 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24038 + newsk->sk_xid = sk->sk_xid;
24039 + vx_sock_inc(newsk);
24040 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24041 + newsk->sk_nid = sk->sk_nid;
24044 * Increment the counter in the same struct proto as the master
24045 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24046 @@ -2187,6 +2206,12 @@ void sock_init_data(struct socket *sock,
24048 sk->sk_stamp = ktime_set(-1L, 0);
24050 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24051 + sk->sk_xid = vx_current_xid();
24053 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24054 + sk->sk_nid = nx_current_nid();
24057 * Before updating sk_refcnt, we must commit prior changes to memory
24058 * (Documentation/RCU/rculist_nulls.txt for details)
24059 diff -NurpP --minimal linux-3.6/net/ipv4/af_inet.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/af_inet.c
24060 --- linux-3.6/net/ipv4/af_inet.c 2012-10-04 15:27:49.000000000 +0200
24061 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/af_inet.c 2012-10-04 18:47:00.000000000 +0200
24062 @@ -118,6 +118,7 @@
24063 #ifdef CONFIG_IP_MROUTE
24064 #include <linux/mroute.h>
24066 +#include <linux/vs_limit.h>
24069 /* The inetsw table contains everything that inet_create needs to
24070 @@ -326,9 +327,13 @@ lookup_protocol:
24074 + if ((protocol == IPPROTO_ICMP) &&
24075 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24078 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24079 goto out_rcu_unlock;
24082 err = -EAFNOSUPPORT;
24083 if (!inet_netns_ok(net, protocol))
24084 goto out_rcu_unlock;
24085 @@ -453,6 +458,7 @@ int inet_bind(struct socket *sock, struc
24086 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24087 struct sock *sk = sock->sk;
24088 struct inet_sock *inet = inet_sk(sk);
24089 + struct nx_v4_sock_addr nsa;
24090 unsigned short snum;
24093 @@ -476,7 +482,11 @@ int inet_bind(struct socket *sock, struc
24097 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24098 + err = v4_map_sock_addr(inet, addr, &nsa);
24102 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24104 /* Not specified by any standard per-se, however it breaks too
24105 * many applications when removed. It is unfortunate since
24106 @@ -488,7 +498,7 @@ int inet_bind(struct socket *sock, struc
24107 err = -EADDRNOTAVAIL;
24108 if (!sysctl_ip_nonlocal_bind &&
24109 !(inet->freebind || inet->transparent) &&
24110 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24111 + nsa.saddr != htonl(INADDR_ANY) &&
24112 chk_addr_ret != RTN_LOCAL &&
24113 chk_addr_ret != RTN_MULTICAST &&
24114 chk_addr_ret != RTN_BROADCAST)
24115 @@ -513,7 +523,7 @@ int inet_bind(struct socket *sock, struc
24116 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24117 goto out_release_sock;
24119 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24120 + v4_set_sock_addr(inet, &nsa);
24121 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24122 inet->inet_saddr = 0; /* Use device */
24124 @@ -731,11 +741,13 @@ int inet_getname(struct socket *sock, st
24127 sin->sin_port = inet->inet_dport;
24128 - sin->sin_addr.s_addr = inet->inet_daddr;
24129 + sin->sin_addr.s_addr =
24130 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24132 __be32 addr = inet->inet_rcv_saddr;
24134 addr = inet->inet_saddr;
24135 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24136 sin->sin_port = inet->inet_sport;
24137 sin->sin_addr.s_addr = addr;
24139 diff -NurpP --minimal linux-3.6/net/ipv4/arp.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/arp.c
24140 --- linux-3.6/net/ipv4/arp.c 2012-10-04 15:27:49.000000000 +0200
24141 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/arp.c 2012-10-04 18:47:00.000000000 +0200
24142 @@ -1318,6 +1318,7 @@ static void arp_format_neigh_entry(struc
24143 struct net_device *dev = n->dev;
24144 int hatype = dev->type;
24146 + /* FIXME: check for network context */
24147 read_lock(&n->lock);
24148 /* Convert hardware address to XX:XX:XX:XX ... form. */
24149 #if IS_ENABLED(CONFIG_AX25)
24150 @@ -1349,6 +1350,7 @@ static void arp_format_pneigh_entry(stru
24151 int hatype = dev ? dev->type : 0;
24154 + /* FIXME: check for network context */
24155 sprintf(tbuf, "%pI4", n->key);
24156 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24157 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24158 diff -NurpP --minimal linux-3.6/net/ipv4/devinet.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/devinet.c
24159 --- linux-3.6/net/ipv4/devinet.c 2012-10-04 15:27:49.000000000 +0200
24160 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/devinet.c 2012-10-04 18:47:00.000000000 +0200
24161 @@ -516,6 +516,7 @@ struct in_device *inetdev_by_index(struc
24163 EXPORT_SYMBOL(inetdev_by_index);
24166 /* Called only from RTNL semaphored context. No locks. */
24168 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24169 @@ -757,6 +758,8 @@ int devinet_ioctl(struct net *net, unsig
24171 in_dev = __in_dev_get_rtnl(dev);
24173 + struct nx_info *nxi = current_nx_info();
24175 if (tryaddrmatch) {
24176 /* Matthias Andree */
24177 /* compare label and address (4.4BSD style) */
24178 @@ -765,6 +768,8 @@ int devinet_ioctl(struct net *net, unsig
24179 This is checked above. */
24180 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24181 ifap = &ifa->ifa_next) {
24182 + if (!nx_v4_ifa_visible(nxi, ifa))
24184 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24185 sin_orig.sin_addr.s_addr ==
24187 @@ -777,9 +782,12 @@ int devinet_ioctl(struct net *net, unsig
24188 comparing just the label */
24190 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24191 - ifap = &ifa->ifa_next)
24192 + ifap = &ifa->ifa_next) {
24193 + if (!nx_v4_ifa_visible(nxi, ifa))
24195 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24201 @@ -932,6 +940,8 @@ static int inet_gifconf(struct net_devic
24204 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24205 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24208 done += sizeof(ifr);
24210 @@ -1291,6 +1301,7 @@ static int inet_dump_ifaddr(struct sk_bu
24211 struct net_device *dev;
24212 struct in_device *in_dev;
24213 struct in_ifaddr *ifa;
24214 + struct sock *sk = skb->sk;
24215 struct hlist_head *head;
24216 struct hlist_node *node;
24218 @@ -1313,6 +1324,8 @@ static int inet_dump_ifaddr(struct sk_bu
24220 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24221 ifa = ifa->ifa_next, ip_idx++) {
24222 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24224 if (ip_idx < s_ip_idx)
24226 if (inet_fill_ifaddr(skb, ifa,
24227 diff -NurpP --minimal linux-3.6/net/ipv4/fib_trie.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/fib_trie.c
24228 --- linux-3.6/net/ipv4/fib_trie.c 2012-10-04 15:27:49.000000000 +0200
24229 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/fib_trie.c 2012-10-04 18:47:00.000000000 +0200
24230 @@ -2554,6 +2554,7 @@ static int fib_route_seq_show(struct seq
24231 || fa->fa_type == RTN_MULTICAST)
24234 + /* FIXME: check for network context? */
24237 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24238 diff -NurpP --minimal linux-3.6/net/ipv4/inet_connection_sock.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/inet_connection_sock.c
24239 --- linux-3.6/net/ipv4/inet_connection_sock.c 2012-10-04 15:27:49.000000000 +0200
24240 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/inet_connection_sock.c 2012-10-04 18:47:00.000000000 +0200
24241 @@ -53,6 +53,37 @@ void inet_get_local_port_range(int *low,
24243 EXPORT_SYMBOL(inet_get_local_port_range);
24245 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24247 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24248 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24250 + if (inet_v6_ipv6only(sk2))
24253 + if (sk1_rcv_saddr &&
24255 + sk1_rcv_saddr == sk2_rcv_saddr)
24258 + if (sk1_rcv_saddr &&
24259 + !sk2_rcv_saddr &&
24260 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24263 + if (sk2_rcv_saddr &&
24264 + !sk1_rcv_saddr &&
24265 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24268 + if (!sk1_rcv_saddr &&
24269 + !sk2_rcv_saddr &&
24270 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24276 int inet_csk_bind_conflict(const struct sock *sk,
24277 const struct inet_bind_bucket *tb, bool relax)
24279 @@ -75,9 +106,7 @@ int inet_csk_bind_conflict(const struct
24280 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
24281 if (!reuse || !sk2->sk_reuse ||
24282 sk2->sk_state == TCP_LISTEN) {
24283 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24284 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24285 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24286 + if (ipv4_rcv_saddr_equal(sk, sk2))
24289 if (!relax && reuse && sk2->sk_reuse &&
24290 diff -NurpP --minimal linux-3.6/net/ipv4/inet_diag.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/inet_diag.c
24291 --- linux-3.6/net/ipv4/inet_diag.c 2012-10-04 15:27:49.000000000 +0200
24292 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/inet_diag.c 2012-10-04 19:02:16.000000000 +0200
24295 #include <linux/inet.h>
24296 #include <linux/stddef.h>
24297 +#include <linux/vs_network.h>
24298 +#include <linux/vs_inet.h>
24300 #include <linux/inet_diag.h>
24301 #include <linux/sock_diag.h>
24302 @@ -101,8 +103,10 @@ int inet_sk_diag_fill(struct sock *sk, s
24304 r->id.idiag_sport = inet->inet_sport;
24305 r->id.idiag_dport = inet->inet_dport;
24306 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
24307 - r->id.idiag_dst[0] = inet->inet_daddr;
24308 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
24309 + inet->inet_rcv_saddr);
24310 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
24311 + inet->inet_daddr);
24313 /* IPv6 dual-stack sockets use inet->tos for IPv4 connections,
24314 * hence this needs to be included regardless of socket family.
24315 @@ -233,8 +237,8 @@ static int inet_twsk_diag_fill(struct in
24316 sock_diag_save_cookie(tw, r->id.idiag_cookie);
24317 r->id.idiag_sport = tw->tw_sport;
24318 r->id.idiag_dport = tw->tw_dport;
24319 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
24320 - r->id.idiag_dst[0] = tw->tw_daddr;
24321 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
24322 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
24323 r->idiag_state = tw->tw_substate;
24324 r->idiag_timer = 3;
24325 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
24326 @@ -276,12 +280,14 @@ int inet_diag_dump_one_icsk(struct inet_
24329 if (req->sdiag_family == AF_INET) {
24330 + /* TODO: lback */
24331 sk = inet_lookup(net, hashinfo, req->id.idiag_dst[0],
24332 req->id.idiag_dport, req->id.idiag_src[0],
24333 req->id.idiag_sport, req->id.idiag_if);
24335 #if IS_ENABLED(CONFIG_IPV6)
24336 else if (req->sdiag_family == AF_INET6) {
24337 + /* TODO: lback */
24338 sk = inet6_lookup(net, hashinfo,
24339 (struct in6_addr *)req->id.idiag_dst,
24340 req->id.idiag_dport,
24341 @@ -476,6 +482,7 @@ int inet_diag_bc_sk(const struct nlattr
24345 + /* TODO: lback */
24346 entry.saddr = &inet->inet_rcv_saddr;
24347 entry.daddr = &inet->inet_daddr;
24349 @@ -574,6 +581,7 @@ static int inet_twsk_diag_dump(struct in
24353 + /* TODO: lback */
24354 entry.saddr = &tw->tw_rcv_saddr;
24355 entry.daddr = &tw->tw_daddr;
24357 @@ -620,8 +628,8 @@ static int inet_diag_fill_req(struct sk_
24359 r->id.idiag_sport = inet->inet_sport;
24360 r->id.idiag_dport = ireq->rmt_port;
24361 - r->id.idiag_src[0] = ireq->loc_addr;
24362 - r->id.idiag_dst[0] = ireq->rmt_addr;
24363 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
24364 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
24365 r->idiag_expires = jiffies_to_msecs(tmo);
24366 r->idiag_rqueue = 0;
24367 r->idiag_wqueue = 0;
24368 @@ -683,6 +691,7 @@ static int inet_diag_dump_reqs(struct sk
24372 + /* TODO: lback */
24374 #if IS_ENABLED(CONFIG_IPV6)
24375 (entry.family == AF_INET6) ?
24376 @@ -748,6 +757,8 @@ void inet_diag_dump_icsk(struct inet_has
24377 if (!net_eq(sock_net(sk), net))
24380 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24385 @@ -820,6 +831,8 @@ skip_listen_ht:
24387 if (!net_eq(sock_net(sk), net))
24389 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24393 if (!(r->idiag_states & (1 << sk->sk_state)))
24394 @@ -848,7 +861,8 @@ next_normal:
24396 if (!net_eq(twsk_net(tw), net))
24399 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24403 if (r->sdiag_family != AF_UNSPEC &&
24404 diff -NurpP --minimal linux-3.6/net/ipv4/inet_hashtables.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/inet_hashtables.c
24405 --- linux-3.6/net/ipv4/inet_hashtables.c 2012-07-22 23:39:48.000000000 +0200
24406 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/inet_hashtables.c 2012-10-04 18:47:00.000000000 +0200
24408 #include <net/inet_connection_sock.h>
24409 #include <net/inet_hashtables.h>
24410 #include <net/secure_seq.h>
24411 +#include <net/route.h>
24412 #include <net/ip.h>
24415 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
24416 if (rcv_saddr != daddr)
24420 + /* block non nx_info ips */
24421 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24422 + daddr, NXA_MASK_BIND))
24425 if (sk->sk_bound_dev_if) {
24426 if (sk->sk_bound_dev_if != dif)
24427 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
24428 * wildcarded during the search since they can never be otherwise.
24432 struct sock *__inet_lookup_listener(struct net *net,
24433 struct inet_hashinfo *hashinfo,
24434 const __be32 daddr, const unsigned short hnum,
24435 @@ -196,6 +201,7 @@ begin:
24441 * if the nulls value we got at the end of this lookup is
24442 * not the expected one, we must restart lookup.
24443 diff -NurpP --minimal linux-3.6/net/ipv4/netfilter/nf_nat_helper.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/netfilter/nf_nat_helper.c
24444 --- linux-3.6/net/ipv4/netfilter/nf_nat_helper.c 2012-10-04 15:27:50.000000000 +0200
24445 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/netfilter/nf_nat_helper.c 2012-10-04 18:47:00.000000000 +0200
24447 #include <net/route.h>
24449 #include <linux/netfilter_ipv4.h>
24450 +#include <net/route.h>
24451 #include <net/netfilter/nf_conntrack.h>
24452 #include <net/netfilter/nf_conntrack_helper.h>
24453 #include <net/netfilter/nf_conntrack_ecache.h>
24454 diff -NurpP --minimal linux-3.6/net/ipv4/netfilter.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/netfilter.c
24455 --- linux-3.6/net/ipv4/netfilter.c 2012-07-22 23:39:48.000000000 +0200
24456 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/netfilter.c 2012-10-04 18:47:00.000000000 +0200
24458 #include <linux/skbuff.h>
24459 #include <linux/gfp.h>
24460 #include <linux/export.h>
24461 -#include <net/route.h>
24462 +// #include <net/route.h>
24463 #include <net/xfrm.h>
24464 #include <net/ip.h>
24465 #include <net/netfilter/nf_queue.h>
24466 diff -NurpP --minimal linux-3.6/net/ipv4/raw.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/raw.c
24467 --- linux-3.6/net/ipv4/raw.c 2012-10-04 15:27:50.000000000 +0200
24468 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/raw.c 2012-10-04 18:47:00.000000000 +0200
24469 @@ -118,7 +118,7 @@ static struct sock *__raw_v4_lookup(stru
24471 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
24472 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
24473 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
24474 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
24475 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
24476 goto found; /* gotcha */
24478 @@ -397,6 +397,12 @@ static int raw_send_hdrinc(struct sock *
24479 icmp_out_count(net, ((struct icmphdr *)
24480 skb_transport_header(skb))->type);
24483 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
24484 + sk->sk_nx_info &&
24485 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
24488 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
24489 rt->dst.dev, dst_output);
24491 @@ -582,6 +588,16 @@ static int raw_sendmsg(struct kiocb *ioc
24495 + if (sk->sk_nx_info) {
24496 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
24497 + if (IS_ERR(rt)) {
24498 + err = PTR_ERR(rt);
24505 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
24506 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
24508 @@ -658,17 +674,19 @@ static int raw_bind(struct sock *sk, str
24510 struct inet_sock *inet = inet_sk(sk);
24511 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
24512 + struct nx_v4_sock_addr nsa = { 0 };
24516 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
24518 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24519 + v4_map_sock_addr(inet, addr, &nsa);
24520 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24521 ret = -EADDRNOTAVAIL;
24522 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
24523 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
24524 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
24526 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24527 + v4_set_sock_addr(inet, &nsa);
24528 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24529 inet->inet_saddr = 0; /* Use device */
24531 @@ -720,7 +738,8 @@ static int raw_recvmsg(struct kiocb *ioc
24532 /* Copy the address. */
24534 sin->sin_family = AF_INET;
24535 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
24536 + sin->sin_addr.s_addr =
24537 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
24539 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
24541 @@ -916,7 +935,8 @@ static struct sock *raw_get_first(struct
24542 struct hlist_node *node;
24544 sk_for_each(sk, node, &state->h->ht[state->bucket])
24545 - if (sock_net(sk) == seq_file_net(seq))
24546 + if ((sock_net(sk) == seq_file_net(seq)) &&
24547 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24551 @@ -932,7 +952,8 @@ static struct sock *raw_get_next(struct
24555 - } while (sk && sock_net(sk) != seq_file_net(seq));
24556 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
24557 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
24559 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
24560 sk = sk_head(&state->h->ht[state->bucket]);
24561 diff -NurpP --minimal linux-3.6/net/ipv4/route.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/route.c
24562 --- linux-3.6/net/ipv4/route.c 2012-10-04 15:27:50.000000000 +0200
24563 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/route.c 2012-10-04 18:47:00.000000000 +0200
24564 @@ -1928,7 +1928,7 @@ struct rtable *__ip_route_output_key(str
24567 if (fl4->flowi4_oif) {
24568 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
24569 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
24570 rth = ERR_PTR(-ENODEV);
24571 if (dev_out == NULL)
24573 diff -NurpP --minimal linux-3.6/net/ipv4/tcp.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/tcp.c
24574 --- linux-3.6/net/ipv4/tcp.c 2012-10-04 15:27:50.000000000 +0200
24575 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/tcp.c 2012-10-04 18:47:00.000000000 +0200
24576 @@ -268,6 +268,7 @@
24577 #include <linux/crypto.h>
24578 #include <linux/time.h>
24579 #include <linux/slab.h>
24580 +#include <linux/in.h>
24582 #include <net/icmp.h>
24583 #include <net/inet_common.h>
24584 diff -NurpP --minimal linux-3.6/net/ipv4/tcp_ipv4.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/tcp_ipv4.c
24585 --- linux-3.6/net/ipv4/tcp_ipv4.c 2012-10-04 15:27:50.000000000 +0200
24586 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/tcp_ipv4.c 2012-10-04 18:47:00.000000000 +0200
24587 @@ -2033,6 +2033,12 @@ static void *listening_get_next(struct s
24588 req = req->dl_next;
24591 + vxdprintk(VXD_CBIT(net, 6),
24592 + "sk,req: %p [#%d] (from %d)", req->sk,
24593 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
24595 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
24597 if (req->rsk_ops->family == st->family) {
24600 @@ -2057,6 +2063,10 @@ get_req:
24603 sk_nulls_for_each_from(sk, node) {
24604 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
24605 + sk, sk->sk_nid, nx_current_nid());
24606 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24608 if (!net_eq(sock_net(sk), net))
24610 if (sk->sk_family == st->family) {
24611 @@ -2133,6 +2143,11 @@ static void *established_get_first(struc
24613 spin_lock_bh(lock);
24614 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
24615 + vxdprintk(VXD_CBIT(net, 6),
24616 + "sk,egf: %p [#%d] (from %d)",
24617 + sk, sk->sk_nid, nx_current_nid());
24618 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24620 if (sk->sk_family != st->family ||
24621 !net_eq(sock_net(sk), net)) {
24623 @@ -2143,6 +2158,11 @@ static void *established_get_first(struc
24624 st->state = TCP_SEQ_STATE_TIME_WAIT;
24625 inet_twsk_for_each(tw, node,
24626 &tcp_hashinfo.ehash[st->bucket].twchain) {
24627 + vxdprintk(VXD_CBIT(net, 6),
24628 + "tw: %p [#%d] (from %d)",
24629 + tw, tw->tw_nid, nx_current_nid());
24630 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24632 if (tw->tw_family != st->family ||
24633 !net_eq(twsk_net(tw), net)) {
24635 @@ -2172,7 +2192,9 @@ static void *established_get_next(struct
24639 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
24640 + while (tw && (tw->tw_family != st->family ||
24641 + !net_eq(twsk_net(tw), net) ||
24642 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
24646 @@ -2196,6 +2218,11 @@ get_tw:
24647 sk = sk_nulls_next(sk);
24649 sk_nulls_for_each_from(sk, node) {
24650 + vxdprintk(VXD_CBIT(net, 6),
24651 + "sk,egn: %p [#%d] (from %d)",
24652 + sk, sk->sk_nid, nx_current_nid());
24653 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24655 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
24658 @@ -2401,9 +2428,9 @@ static void get_openreq4(const struct so
24659 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
24660 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
24663 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
24664 ntohs(inet_sk(sk)->inet_sport),
24666 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
24667 ntohs(ireq->rmt_port),
24669 0, 0, /* could print option size, but that is af dependent. */
24670 @@ -2425,8 +2452,8 @@ static void get_tcp4_sock(struct sock *s
24671 const struct tcp_sock *tp = tcp_sk(sk);
24672 const struct inet_connection_sock *icsk = inet_csk(sk);
24673 const struct inet_sock *inet = inet_sk(sk);
24674 - __be32 dest = inet->inet_daddr;
24675 - __be32 src = inet->inet_rcv_saddr;
24676 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
24677 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
24678 __u16 destp = ntohs(inet->inet_dport);
24679 __u16 srcp = ntohs(inet->inet_sport);
24681 @@ -2483,8 +2510,8 @@ static void get_timewait4_sock(const str
24685 - dest = tw->tw_daddr;
24686 - src = tw->tw_rcv_saddr;
24687 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
24688 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
24689 destp = ntohs(tw->tw_dport);
24690 srcp = ntohs(tw->tw_sport);
24692 diff -NurpP --minimal linux-3.6/net/ipv4/tcp_minisocks.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/tcp_minisocks.c
24693 --- linux-3.6/net/ipv4/tcp_minisocks.c 2012-10-04 15:27:50.000000000 +0200
24694 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/tcp_minisocks.c 2012-10-04 18:47:00.000000000 +0200
24696 #include <linux/slab.h>
24697 #include <linux/sysctl.h>
24698 #include <linux/workqueue.h>
24699 +#include <linux/vs_limit.h>
24700 +#include <linux/vs_socket.h>
24701 +#include <linux/vs_context.h>
24702 #include <net/tcp.h>
24703 #include <net/inet_common.h>
24704 #include <net/xfrm.h>
24705 @@ -287,6 +290,11 @@ void tcp_time_wait(struct sock *sk, int
24706 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
24707 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
24709 + tw->tw_xid = sk->sk_xid;
24710 + tw->tw_vx_info = NULL;
24711 + tw->tw_nid = sk->sk_nid;
24712 + tw->tw_nx_info = NULL;
24714 #if IS_ENABLED(CONFIG_IPV6)
24715 if (tw->tw_family == PF_INET6) {
24716 struct ipv6_pinfo *np = inet6_sk(sk);
24717 diff -NurpP --minimal linux-3.6/net/ipv4/udp.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/udp.c
24718 --- linux-3.6/net/ipv4/udp.c 2012-10-04 15:27:50.000000000 +0200
24719 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv4/udp.c 2012-10-04 18:47:00.000000000 +0200
24720 @@ -300,14 +300,7 @@ fail:
24722 EXPORT_SYMBOL(udp_lib_get_port);
24724 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24726 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
24728 - return (!ipv6_only_sock(sk2) &&
24729 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
24730 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
24732 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
24734 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
24736 @@ -342,6 +335,11 @@ static inline int compute_score(struct s
24737 if (inet->inet_rcv_saddr != daddr)
24741 + /* block non nx_info ips */
24742 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24743 + daddr, NXA_MASK_BIND))
24746 if (inet->inet_daddr) {
24747 if (inet->inet_daddr != saddr)
24748 @@ -445,6 +443,7 @@ exact_match:
24753 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
24754 * harder than this. -DaveM
24756 @@ -490,6 +489,11 @@ begin:
24757 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
24758 score = compute_score(sk, net, saddr, hnum, sport,
24759 daddr, dport, dif);
24760 + /* FIXME: disabled?
24761 + if (score == 9) {
24765 if (score > badness) {
24768 @@ -503,6 +507,7 @@ begin:
24769 if (get_nulls_value(node) != slot)
24774 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
24776 @@ -512,6 +517,7 @@ begin:
24784 @@ -555,8 +561,7 @@ static inline struct sock *udp_v4_mcast_
24785 udp_sk(s)->udp_port_hash != hnum ||
24786 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
24787 (inet->inet_dport != rmt_port && inet->inet_dport) ||
24788 - (inet->inet_rcv_saddr &&
24789 - inet->inet_rcv_saddr != loc_addr) ||
24790 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
24791 ipv6_only_sock(s) ||
24792 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
24794 @@ -939,6 +944,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
24795 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
24796 faddr, saddr, dport, inet->inet_sport);
24798 + if (sk->sk_nx_info) {
24799 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
24800 + if (IS_ERR(rt)) {
24801 + err = PTR_ERR(rt);
24808 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
24809 rt = ip_route_output_flow(net, fl4, sk);
24811 @@ -1244,7 +1259,8 @@ try_again:
24813 sin->sin_family = AF_INET;
24814 sin->sin_port = udp_hdr(skb)->source;
24815 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
24816 + sin->sin_addr.s_addr = nx_map_sock_lback(
24817 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
24818 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
24820 if (inet->cmsg_flags)
24821 @@ -1992,6 +2008,8 @@ static struct sock *udp_get_first(struct
24822 sk_nulls_for_each(sk, node, &hslot->head) {
24823 if (!net_eq(sock_net(sk), net))
24825 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24827 if (sk->sk_family == state->family)
24830 @@ -2009,7 +2027,9 @@ static struct sock *udp_get_next(struct
24833 sk = sk_nulls_next(sk);
24834 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
24835 + } while (sk && (!net_eq(sock_net(sk), net) ||
24836 + sk->sk_family != state->family ||
24837 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
24840 if (state->bucket <= state->udp_table->mask)
24841 @@ -2105,8 +2125,8 @@ static void udp4_format_sock(struct sock
24842 int bucket, int *len)
24844 struct inet_sock *inet = inet_sk(sp);
24845 - __be32 dest = inet->inet_daddr;
24846 - __be32 src = inet->inet_rcv_saddr;
24847 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
24848 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
24849 __u16 destp = ntohs(inet->inet_dport);
24850 __u16 srcp = ntohs(inet->inet_sport);
24852 diff -NurpP --minimal linux-3.6/net/ipv6/Kconfig linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/Kconfig
24853 --- linux-3.6/net/ipv6/Kconfig 2012-07-22 23:39:48.000000000 +0200
24854 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/Kconfig 2012-10-04 18:47:00.000000000 +0200
24857 # IPv6 as module will cause a CRASH if you try to unload it
24859 - tristate "The IPv6 protocol"
24861 + bool "The IPv6 protocol"
24864 This is complemental support for the IP version 6.
24865 You will still be able to do traditional IPv4 networking as well.
24866 diff -NurpP --minimal linux-3.6/net/ipv6/addrconf.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/addrconf.c
24867 --- linux-3.6/net/ipv6/addrconf.c 2012-10-04 15:27:50.000000000 +0200
24868 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/addrconf.c 2012-10-04 18:47:00.000000000 +0200
24870 #include <linux/proc_fs.h>
24871 #include <linux/seq_file.h>
24872 #include <linux/export.h>
24873 +#include <linux/vs_network.h>
24874 +#include <linux/vs_inet6.h>
24876 /* Set to 3 to get tracing... */
24877 #define ACONF_DEBUG 2
24878 @@ -1095,7 +1097,7 @@ out:
24880 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
24881 const struct in6_addr *daddr, unsigned int prefs,
24882 - struct in6_addr *saddr)
24883 + struct in6_addr *saddr, struct nx_info *nxi)
24885 struct ipv6_saddr_score scores[2],
24886 *score = &scores[0], *hiscore = &scores[1];
24887 @@ -1167,6 +1169,8 @@ int ipv6_dev_get_saddr(struct net *net,
24891 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
24895 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
24896 @@ -3150,7 +3154,10 @@ static void if6_seq_stop(struct seq_file
24897 static int if6_seq_show(struct seq_file *seq, void *v)
24899 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
24900 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
24902 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
24903 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
24904 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
24906 ifp->idev->dev->ifindex,
24908 @@ -3656,6 +3663,11 @@ static int in6_dump_addrs(struct inet6_d
24909 struct ifacaddr6 *ifaca;
24911 int ip_idx = *p_ip_idx;
24912 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
24914 + /* disable ipv6 on non v6 guests */
24915 + if (nxi && !nx_info_has_v6(nxi))
24918 read_lock_bh(&idev->lock);
24920 @@ -3666,6 +3678,8 @@ static int in6_dump_addrs(struct inet6_d
24921 list_for_each_entry(ifa, &idev->addr_list, if_list) {
24922 if (++ip_idx < s_ip_idx)
24924 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
24926 err = inet6_fill_ifaddr(skb, ifa,
24927 NETLINK_CB(cb->skb).pid,
24928 cb->nlh->nlmsg_seq,
24929 @@ -3682,6 +3696,8 @@ static int in6_dump_addrs(struct inet6_d
24930 ifmca = ifmca->next, ip_idx++) {
24931 if (ip_idx < s_ip_idx)
24933 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
24935 err = inet6_fill_ifmcaddr(skb, ifmca,
24936 NETLINK_CB(cb->skb).pid,
24937 cb->nlh->nlmsg_seq,
24938 @@ -3697,6 +3713,8 @@ static int in6_dump_addrs(struct inet6_d
24939 ifaca = ifaca->aca_next, ip_idx++) {
24940 if (ip_idx < s_ip_idx)
24942 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
24944 err = inet6_fill_ifacaddr(skb, ifaca,
24945 NETLINK_CB(cb->skb).pid,
24946 cb->nlh->nlmsg_seq,
24947 @@ -4080,6 +4098,11 @@ static int inet6_dump_ifinfo(struct sk_b
24948 struct inet6_dev *idev;
24949 struct hlist_head *head;
24950 struct hlist_node *node;
24951 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
24953 + /* FIXME: maybe disable ipv6 on non v6 guests?
24954 + if (skb->sk && skb->sk->sk_vx_info)
24955 + return skb->len; */
24958 s_idx = cb->args[1];
24959 @@ -4091,6 +4114,8 @@ static int inet6_dump_ifinfo(struct sk_b
24960 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
24963 + if (!v6_dev_in_nx_info(dev, nxi))
24965 idev = __in6_dev_get(dev);
24968 diff -NurpP --minimal linux-3.6/net/ipv6/af_inet6.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/af_inet6.c
24969 --- linux-3.6/net/ipv6/af_inet6.c 2012-07-22 23:39:48.000000000 +0200
24970 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/af_inet6.c 2012-10-04 18:47:00.000000000 +0200
24972 #include <linux/netdevice.h>
24973 #include <linux/icmpv6.h>
24974 #include <linux/netfilter_ipv6.h>
24975 +#include <linux/vs_inet.h>
24976 +#include <linux/vs_inet6.h>
24978 #include <net/ip.h>
24979 #include <net/ipv6.h>
24980 @@ -160,9 +162,12 @@ lookup_protocol:
24984 + if ((protocol == IPPROTO_ICMPV6) &&
24985 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24987 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24988 goto out_rcu_unlock;
24991 sock->ops = answer->ops;
24992 answer_prot = answer->prot;
24993 answer_no_check = answer->no_check;
24994 @@ -262,6 +267,7 @@ int inet6_bind(struct socket *sock, stru
24995 struct inet_sock *inet = inet_sk(sk);
24996 struct ipv6_pinfo *np = inet6_sk(sk);
24997 struct net *net = sock_net(sk);
24998 + struct nx_v6_sock_addr nsa;
25000 unsigned short snum;
25002 @@ -277,6 +283,10 @@ int inet6_bind(struct socket *sock, stru
25003 if (addr->sin6_family != AF_INET6)
25004 return -EAFNOSUPPORT;
25006 + err = v6_map_sock_addr(inet, addr, &nsa);
25010 addr_type = ipv6_addr_type(&addr->sin6_addr);
25011 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25013 @@ -308,6 +318,7 @@ int inet6_bind(struct socket *sock, stru
25014 /* Reproduce AF_INET checks to make the bindings consistent */
25015 v4addr = addr->sin6_addr.s6_addr32[3];
25016 chk_addr_ret = inet_addr_type(net, v4addr);
25018 if (!sysctl_ip_nonlocal_bind &&
25019 !(inet->freebind || inet->transparent) &&
25020 v4addr != htonl(INADDR_ANY) &&
25021 @@ -317,6 +328,10 @@ int inet6_bind(struct socket *sock, stru
25022 err = -EADDRNOTAVAIL;
25025 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25026 + err = -EADDRNOTAVAIL;
25030 if (addr_type != IPV6_ADDR_ANY) {
25031 struct net_device *dev = NULL;
25032 @@ -343,6 +358,11 @@ int inet6_bind(struct socket *sock, stru
25036 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25037 + err = -EADDRNOTAVAIL;
25041 /* ipv4 addr of the socket is invalid. Only the
25042 * unspecified and mapped address have a v4 equivalent.
25044 @@ -359,6 +379,9 @@ int inet6_bind(struct socket *sock, stru
25048 + /* what's that for? */
25049 + v6_set_sock_addr(inet, &nsa);
25051 inet->inet_rcv_saddr = v4addr;
25052 inet->inet_saddr = v4addr;
25054 @@ -460,9 +483,11 @@ int inet6_getname(struct socket *sock, s
25056 sin->sin6_port = inet->inet_dport;
25057 sin->sin6_addr = np->daddr;
25058 + /* FIXME: remap lback? */
25060 sin->sin6_flowinfo = np->flow_label;
25062 + /* FIXME: remap lback? */
25063 if (ipv6_addr_any(&np->rcv_saddr))
25064 sin->sin6_addr = np->saddr;
25066 diff -NurpP --minimal linux-3.6/net/ipv6/datagram.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/datagram.c
25067 --- linux-3.6/net/ipv6/datagram.c 2012-07-22 23:39:48.000000000 +0200
25068 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/datagram.c 2012-10-04 18:47:00.000000000 +0200
25069 @@ -645,7 +645,7 @@ int datagram_send_ctl(struct net *net, s
25072 if (fl6->flowi6_oif) {
25073 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25074 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25078 diff -NurpP --minimal linux-3.6/net/ipv6/fib6_rules.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/fib6_rules.c
25079 --- linux-3.6/net/ipv6/fib6_rules.c 2012-07-22 23:39:48.000000000 +0200
25080 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/fib6_rules.c 2012-10-04 18:47:00.000000000 +0200
25081 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
25082 ip6_dst_idev(&rt->dst)->dev,
25084 rt6_flags2srcprefs(flags),
25088 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25090 diff -NurpP --minimal linux-3.6/net/ipv6/inet6_hashtables.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/inet6_hashtables.c
25091 --- linux-3.6/net/ipv6/inet6_hashtables.c 2011-10-24 18:45:34.000000000 +0200
25092 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/inet6_hashtables.c 2012-10-04 18:47:00.000000000 +0200
25095 #include <linux/module.h>
25096 #include <linux/random.h>
25097 +#include <linux/vs_inet6.h>
25099 #include <net/inet_connection_sock.h>
25100 #include <net/inet_hashtables.h>
25101 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25102 unsigned int slot = hash & hashinfo->ehash_mask;
25103 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25108 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25109 @@ -95,7 +95,7 @@ begin:
25117 if (get_nulls_value(node) != slot)
25118 @@ -141,6 +141,9 @@ static inline int compute_score(struct s
25119 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25123 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25126 if (sk->sk_bound_dev_if) {
25127 if (sk->sk_bound_dev_if != dif)
25128 diff -NurpP --minimal linux-3.6/net/ipv6/ip6_output.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/ip6_output.c
25129 --- linux-3.6/net/ipv6/ip6_output.c 2012-10-04 15:27:50.000000000 +0200
25130 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/ip6_output.c 2012-10-04 18:47:00.000000000 +0200
25131 @@ -966,7 +966,8 @@ static int ip6_dst_lookup_tail(struct so
25132 struct rt6_info *rt = (struct rt6_info *) *dst;
25133 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25134 sk ? inet6_sk(sk)->srcprefs : 0,
25137 + sk ? sk->sk_nx_info : NULL);
25139 goto out_err_release;
25141 diff -NurpP --minimal linux-3.6/net/ipv6/ndisc.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/ndisc.c
25142 --- linux-3.6/net/ipv6/ndisc.c 2012-10-04 15:27:50.000000000 +0200
25143 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/ndisc.c 2012-10-04 18:47:00.000000000 +0200
25144 @@ -517,7 +517,7 @@ static void ndisc_send_na(struct net_dev
25146 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25147 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25151 src_addr = &tmpaddr;
25153 diff -NurpP --minimal linux-3.6/net/ipv6/raw.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/raw.c
25154 --- linux-3.6/net/ipv6/raw.c 2012-10-04 15:27:50.000000000 +0200
25155 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/raw.c 2012-10-04 18:47:00.000000000 +0200
25157 #include <linux/icmpv6.h>
25158 #include <linux/netfilter.h>
25159 #include <linux/netfilter_ipv6.h>
25160 +#include <linux/vs_inet6.h>
25161 #include <linux/skbuff.h>
25162 #include <linux/compat.h>
25163 #include <asm/uaccess.h>
25164 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
25168 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25169 + err = -EADDRNOTAVAIL;
25175 /* ipv4 addr of the socket is invalid. Only the
25176 * unspecified and mapped address have a v4 equivalent.
25178 diff -NurpP --minimal linux-3.6/net/ipv6/route.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/route.c
25179 --- linux-3.6/net/ipv6/route.c 2012-10-04 15:27:50.000000000 +0200
25180 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/route.c 2012-10-04 18:47:00.000000000 +0200
25182 #include <net/xfrm.h>
25183 #include <net/netevent.h>
25184 #include <net/netlink.h>
25185 +#include <linux/vs_inet6.h>
25187 #include <asm/uaccess.h>
25189 @@ -2111,15 +2112,17 @@ int ip6_route_get_saddr(struct net *net,
25190 struct rt6_info *rt,
25191 const struct in6_addr *daddr,
25192 unsigned int prefs,
25193 - struct in6_addr *saddr)
25194 + struct in6_addr *saddr,
25195 + struct nx_info *nxi)
25197 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25199 - if (rt->rt6i_prefsrc.plen)
25200 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25201 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25202 *saddr = rt->rt6i_prefsrc.addr;
25204 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25205 - daddr, prefs, saddr);
25206 + daddr, prefs, saddr, nxi);
25210 @@ -2455,7 +2458,8 @@ static int rt6_fill_node(struct net *net
25211 goto nla_put_failure;
25213 struct in6_addr saddr_buf;
25214 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0 &&
25215 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25216 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0 &&
25217 nla_put(skb, RTA_PREFSRC, 16, &saddr_buf))
25218 goto nla_put_failure;
25220 @@ -2673,6 +2677,7 @@ static int rt6_info_route(struct rt6_inf
25221 struct seq_file *m = p_arg;
25222 struct neighbour *n;
25224 + /* FIXME: check for network context? */
25225 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25227 #ifdef CONFIG_IPV6_SUBTREES
25228 diff -NurpP --minimal linux-3.6/net/ipv6/tcp_ipv6.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/tcp_ipv6.c
25229 --- linux-3.6/net/ipv6/tcp_ipv6.c 2012-10-04 15:27:50.000000000 +0200
25230 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/tcp_ipv6.c 2012-10-04 18:47:00.000000000 +0200
25233 #include <linux/crypto.h>
25234 #include <linux/scatterlist.h>
25235 +#include <linux/vs_inet6.h>
25237 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25238 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25239 @@ -175,8 +176,15 @@ static int tcp_v6_connect(struct sock *s
25240 * connect() to INADDR_ANY means loopback (BSD'ism).
25243 - if(ipv6_addr_any(&usin->sin6_addr))
25244 - usin->sin6_addr.s6_addr[15] = 0x1;
25245 + if(ipv6_addr_any(&usin->sin6_addr)) {
25246 + struct nx_info *nxi = sk->sk_nx_info;
25248 + if (nxi && nx_info_has_v6(nxi))
25249 + /* FIXME: remap lback? */
25250 + usin->sin6_addr = nxi->v6.ip;
25252 + usin->sin6_addr.s6_addr[15] = 0x1;
25255 addr_type = ipv6_addr_type(&usin->sin6_addr);
25257 diff -NurpP --minimal linux-3.6/net/ipv6/udp.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/udp.c
25258 --- linux-3.6/net/ipv6/udp.c 2012-10-04 15:27:50.000000000 +0200
25259 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/udp.c 2012-10-04 18:56:03.000000000 +0200
25260 @@ -45,42 +45,68 @@
25261 #include <net/tcp_states.h>
25262 #include <net/ip6_checksum.h>
25263 #include <net/xfrm.h>
25264 +#include <linux/vs_inet6.h>
25266 #include <linux/proc_fs.h>
25267 #include <linux/seq_file.h>
25268 #include <trace/events/skb.h>
25269 #include "udp_impl.h"
25271 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25272 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25274 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25275 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25276 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25277 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25278 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25279 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25280 - int sk_ipv6only = ipv6_only_sock(sk);
25281 + int sk1_ipv6only = ipv6_only_sock(sk1);
25282 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25283 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25284 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25285 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25287 /* if both are mapped, treat as IPv4 */
25288 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25289 - return (!sk2_ipv6only &&
25290 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25291 + if (!sk2_ipv6only &&
25292 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25293 - sk1_rcv_saddr == sk2_rcv_saddr));
25294 + sk1_rcv_saddr == sk2_rcv_saddr))
25300 if (addr_type2 == IPV6_ADDR_ANY &&
25301 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25305 if (addr_type == IPV6_ADDR_ANY &&
25306 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25308 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25311 if (sk2_rcv_saddr6 &&
25312 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25314 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
25320 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
25321 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25322 + if (!sk2_rcv_saddr)
25323 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
25324 + if (!sk1_rcv_saddr)
25325 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
25328 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25329 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25330 + else if (addr_type2 == IPV6_ADDR_ANY)
25331 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
25332 + else if (addr_type == IPV6_ADDR_ANY) {
25333 + if (addr_type2 == IPV6_ADDR_MAPPED)
25334 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25336 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
25341 static unsigned int udp6_portaddr_hash(struct net *net,
25342 @@ -144,6 +170,10 @@ static inline int compute_score(struct s
25343 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25347 + /* block non nx_info ips */
25348 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25351 if (!ipv6_addr_any(&np->daddr)) {
25352 if (!ipv6_addr_equal(&np->daddr, saddr))
25353 diff -NurpP --minimal linux-3.6/net/ipv6/xfrm6_policy.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/xfrm6_policy.c
25354 --- linux-3.6/net/ipv6/xfrm6_policy.c 2012-10-04 15:27:50.000000000 +0200
25355 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/ipv6/xfrm6_policy.c 2012-10-04 18:47:00.000000000 +0200
25356 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
25357 dev = ip6_dst_idev(dst)->dev;
25358 ipv6_dev_get_saddr(dev_net(dev), dev,
25359 (struct in6_addr *)&daddr->a6, 0,
25360 - (struct in6_addr *)&saddr->a6);
25361 + (struct in6_addr *)&saddr->a6, NULL);
25365 diff -NurpP --minimal linux-3.6/net/netfilter/ipvs/ip_vs_xmit.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/netfilter/ipvs/ip_vs_xmit.c
25366 --- linux-3.6/net/netfilter/ipvs/ip_vs_xmit.c 2012-10-04 15:27:50.000000000 +0200
25367 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/netfilter/ipvs/ip_vs_xmit.c 2012-10-04 18:47:00.000000000 +0200
25368 @@ -226,7 +226,7 @@ __ip_vs_route_output_v6(struct net *net,
25370 if (ipv6_addr_any(&fl6.saddr) &&
25371 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
25372 - &fl6.daddr, 0, &fl6.saddr) < 0)
25373 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
25376 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
25377 diff -NurpP --minimal linux-3.6/net/netlink/af_netlink.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/netlink/af_netlink.c
25378 --- linux-3.6/net/netlink/af_netlink.c 2012-10-04 15:27:50.000000000 +0200
25379 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/netlink/af_netlink.c 2012-10-04 18:47:00.000000000 +0200
25381 #include <linux/types.h>
25382 #include <linux/audit.h>
25383 #include <linux/mutex.h>
25384 +#include <linux/vs_context.h>
25385 +#include <linux/vs_network.h>
25386 +#include <linux/vs_limit.h>
25388 #include <net/net_namespace.h>
25389 #include <net/sock.h>
25390 @@ -1959,6 +1962,8 @@ static struct sock *netlink_seq_socket_i
25391 sk_for_each(s, node, &hash->table[j]) {
25392 if (sock_net(s) != seq_file_net(seq))
25394 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25398 iter->hash_idx = j;
25399 @@ -1993,7 +1998,8 @@ static void *netlink_seq_next(struct seq
25403 - } while (s && sock_net(s) != seq_file_net(seq));
25404 + } while (s && (sock_net(s) != seq_file_net(seq) ||
25405 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
25409 @@ -2005,7 +2011,8 @@ static void *netlink_seq_next(struct seq
25411 for (; j <= hash->mask; j++) {
25412 s = sk_head(&hash->table[j]);
25413 - while (s && sock_net(s) != seq_file_net(seq))
25414 + while (s && (sock_net(s) != seq_file_net(seq) ||
25415 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
25419 diff -NurpP --minimal linux-3.6/net/socket.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/socket.c
25420 --- linux-3.6/net/socket.c 2012-10-04 15:27:51.000000000 +0200
25421 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/socket.c 2012-10-04 18:47:00.000000000 +0200
25424 #include <net/sock.h>
25425 #include <linux/netfilter.h>
25426 +#include <linux/vs_base.h>
25427 +#include <linux/vs_socket.h>
25428 +#include <linux/vs_inet.h>
25429 +#include <linux/vs_inet6.h>
25431 #include <linux/if_tun.h>
25432 #include <linux/ipv6_route.h>
25433 @@ -552,6 +556,7 @@ static inline int __sock_sendmsg_nosec(s
25434 struct msghdr *msg, size_t size)
25436 struct sock_iocb *si = kiocb_to_siocb(iocb);
25439 sock_update_classid(sock->sk);
25441 @@ -560,7 +565,22 @@ static inline int __sock_sendmsg_nosec(s
25445 - return sock->ops->sendmsg(iocb, sock, msg, size);
25446 + len = sock->ops->sendmsg(iocb, sock, msg, size);
25449 + vx_sock_send(sock->sk, size);
25451 + vx_sock_fail(sock->sk, size);
25453 + vxdprintk(VXD_CBIT(net, 7),
25454 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
25456 + (sock->sk)?sock->sk->sk_nx_info:0,
25457 + (sock->sk)?sock->sk->sk_vx_info:0,
25458 + (sock->sk)?sock->sk->sk_xid:0,
25459 + (sock->sk)?sock->sk->sk_nid:0,
25460 + (unsigned int)size, len);
25464 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
25465 @@ -716,6 +736,7 @@ static inline int __sock_recvmsg_nosec(s
25466 struct msghdr *msg, size_t size, int flags)
25468 struct sock_iocb *si = kiocb_to_siocb(iocb);
25471 sock_update_classid(sock->sk);
25473 @@ -725,7 +746,18 @@ static inline int __sock_recvmsg_nosec(s
25477 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
25478 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
25479 + if ((len >= 0) && sock->sk)
25480 + vx_sock_recv(sock->sk, len);
25481 + vxdprintk(VXD_CBIT(net, 7),
25482 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
25484 + (sock->sk)?sock->sk->sk_nx_info:0,
25485 + (sock->sk)?sock->sk->sk_vx_info:0,
25486 + (sock->sk)?sock->sk->sk_xid:0,
25487 + (sock->sk)?sock->sk->sk_nid:0,
25488 + (unsigned int)size, len);
25492 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
25493 @@ -1210,6 +1242,13 @@ int __sock_create(struct net *net, int f
25494 if (type < 0 || type >= SOCK_MAX)
25497 + if (!nx_check(0, VS_ADMIN)) {
25498 + if (family == PF_INET && !current_nx_info_has_v4())
25499 + return -EAFNOSUPPORT;
25500 + if (family == PF_INET6 && !current_nx_info_has_v6())
25501 + return -EAFNOSUPPORT;
25506 This uglymoron is moved from INET layer to here to avoid
25507 @@ -1344,6 +1383,7 @@ SYSCALL_DEFINE3(socket, int, family, int
25511 + set_bit(SOCK_USER_SOCKET, &sock->flags);
25512 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
25515 @@ -1385,10 +1425,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
25516 err = sock_create(family, type, protocol, &sock1);
25519 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
25521 err = sock_create(family, type, protocol, &sock2);
25523 goto out_release_1;
25524 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
25526 err = sock1->ops->socketpair(sock1, sock2);
25528 diff -NurpP --minimal linux-3.6/net/sunrpc/auth.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/sunrpc/auth.c
25529 --- linux-3.6/net/sunrpc/auth.c 2012-10-04 15:27:51.000000000 +0200
25530 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/sunrpc/auth.c 2012-10-04 18:47:00.000000000 +0200
25532 #include <linux/sunrpc/clnt.h>
25533 #include <linux/sunrpc/gss_api.h>
25534 #include <linux/spinlock.h>
25535 +#include <linux/vs_tag.h>
25538 # define RPCDBG_FACILITY RPCDBG_AUTH
25539 @@ -481,6 +482,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
25540 memset(&acred, 0, sizeof(acred));
25541 acred.uid = cred->fsuid;
25542 acred.gid = cred->fsgid;
25543 + acred.tag = dx_current_tag();
25544 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
25546 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
25547 @@ -521,6 +523,7 @@ rpcauth_bind_root_cred(struct rpc_task *
25548 struct auth_cred acred = {
25551 + .tag = dx_current_tag(),
25554 dprintk("RPC: %5u looking up %s cred\n",
25555 diff -NurpP --minimal linux-3.6/net/sunrpc/auth_unix.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/sunrpc/auth_unix.c
25556 --- linux-3.6/net/sunrpc/auth_unix.c 2012-07-22 23:39:49.000000000 +0200
25557 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/sunrpc/auth_unix.c 2012-10-04 18:47:00.000000000 +0200
25558 @@ -13,11 +13,13 @@
25559 #include <linux/sunrpc/clnt.h>
25560 #include <linux/sunrpc/auth.h>
25561 #include <linux/user_namespace.h>
25562 +#include <linux/vs_tag.h>
25564 #define NFS_NGROUPS 16
25567 struct rpc_cred uc_base;
25570 gid_t uc_gids[NFS_NGROUPS];
25572 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
25573 groups = NFS_NGROUPS;
25575 cred->uc_gid = acred->gid;
25576 + cred->uc_tag = acred->tag;
25577 for (i = 0; i < groups; i++) {
25579 gid = from_kgid(&init_user_ns, GROUP_AT(acred->group_info, i));
25580 @@ -123,7 +126,9 @@ unx_match(struct auth_cred *acred, struc
25584 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
25585 + if (cred->uc_uid != acred->uid ||
25586 + cred->uc_gid != acred->gid ||
25587 + cred->uc_tag != acred->tag)
25590 if (acred->group_info != NULL)
25591 @@ -152,7 +157,7 @@ unx_marshal(struct rpc_task *task, __be3
25592 struct rpc_clnt *clnt = task->tk_client;
25593 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
25594 __be32 *base, *hold;
25598 *p++ = htonl(RPC_AUTH_UNIX);
25600 @@ -162,9 +167,12 @@ unx_marshal(struct rpc_task *task, __be3
25601 * Copy the UTS nodename captured when the client was created.
25603 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
25604 + tag = task->tk_client->cl_tag;
25606 - *p++ = htonl((u32) cred->uc_uid);
25607 - *p++ = htonl((u32) cred->uc_gid);
25608 + *p++ = htonl((u32) TAGINO_UID(tag,
25609 + cred->uc_uid, cred->uc_tag));
25610 + *p++ = htonl((u32) TAGINO_GID(tag,
25611 + cred->uc_gid, cred->uc_tag));
25613 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
25614 *p++ = htonl((u32) cred->uc_gids[i]);
25615 diff -NurpP --minimal linux-3.6/net/sunrpc/clnt.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/sunrpc/clnt.c
25616 --- linux-3.6/net/sunrpc/clnt.c 2012-10-04 15:27:51.000000000 +0200
25617 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/sunrpc/clnt.c 2012-10-04 18:47:00.000000000 +0200
25619 #include <linux/in6.h>
25620 #include <linux/un.h>
25621 #include <linux/rcupdate.h>
25622 +#include <linux/vs_cvirt.h>
25624 #include <linux/sunrpc/clnt.h>
25625 #include <linux/sunrpc/rpc_pipe_fs.h>
25626 @@ -481,6 +482,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
25627 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
25628 clnt->cl_chatty = 1;
25630 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
25631 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
25632 + clnt->cl_tag = 1; */
25635 EXPORT_SYMBOL_GPL(rpc_create);
25636 diff -NurpP --minimal linux-3.6/net/unix/af_unix.c linux-3.6-vs2.3.4.3-noxfs-nocow/net/unix/af_unix.c
25637 --- linux-3.6/net/unix/af_unix.c 2012-10-04 15:27:51.000000000 +0200
25638 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/net/unix/af_unix.c 2012-10-04 18:59:36.000000000 +0200
25639 @@ -114,6 +114,8 @@
25640 #include <linux/mount.h>
25641 #include <net/checksum.h>
25642 #include <linux/security.h>
25643 +#include <linux/vs_context.h>
25644 +#include <linux/vs_limit.h>
25646 struct hlist_head unix_socket_table[2 * UNIX_HASH_SIZE];
25647 EXPORT_SYMBOL_GPL(unix_socket_table);
25648 @@ -271,6 +273,8 @@ static struct sock *__unix_find_socket_b
25649 if (!net_eq(sock_net(s), net))
25652 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25654 if (u->addr->len == len &&
25655 !memcmp(u->addr->name, sunname, len))
25657 @@ -2258,6 +2262,8 @@ static struct sock *unix_from_bucket(str
25658 for (sk = sk_head(&unix_socket_table[bucket]); sk; sk = sk_next(sk)) {
25659 if (sock_net(sk) != seq_file_net(seq))
25661 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25663 if (++count == offset)
25666 @@ -2275,6 +2281,8 @@ static struct sock *unix_next_socket(str
25670 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25672 if (sock_net(sk) == seq_file_net(seq))
25675 diff -NurpP --minimal linux-3.6/scripts/checksyscalls.sh linux-3.6-vs2.3.4.3-noxfs-nocow/scripts/checksyscalls.sh
25676 --- linux-3.6/scripts/checksyscalls.sh 2012-10-04 15:27:51.000000000 +0200
25677 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/scripts/checksyscalls.sh 2012-10-04 18:47:00.000000000 +0200
25678 @@ -193,7 +193,6 @@ cat << EOF
25679 #define __IGNORE_afs_syscall
25680 #define __IGNORE_getpmsg
25681 #define __IGNORE_putpmsg
25682 -#define __IGNORE_vserver
25686 diff -NurpP --minimal linux-3.6/security/commoncap.c linux-3.6-vs2.3.4.3-noxfs-nocow/security/commoncap.c
25687 --- linux-3.6/security/commoncap.c 2012-07-22 23:39:51.000000000 +0200
25688 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/security/commoncap.c 2012-10-04 18:47:00.000000000 +0200
25689 @@ -76,14 +76,20 @@ int cap_netlink_send(struct sock *sk, st
25690 int cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
25691 int cap, int audit)
25693 + struct vx_info *vxi = current_vx_info(); /* FIXME: get vxi from cred? */
25696 /* The owner of the user namespace has all caps. */
25697 if (targ_ns != &init_user_ns && uid_eq(targ_ns->owner, cred->euid))
25700 /* Do we have the necessary capabilities? */
25701 - if (targ_ns == cred->user_ns)
25702 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
25703 + if (targ_ns == cred->user_ns) {
25704 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
25705 + cap_raised(cred->cap_effective, cap))
25707 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
25710 /* Have we tried all of the parent namespaces? */
25711 if (targ_ns == &init_user_ns)
25712 @@ -619,7 +625,7 @@ int cap_inode_setxattr(struct dentry *de
25714 if (!strncmp(name, XATTR_SECURITY_PREFIX,
25715 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
25716 - !capable(CAP_SYS_ADMIN))
25717 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
25721 @@ -645,7 +651,7 @@ int cap_inode_removexattr(struct dentry
25723 if (!strncmp(name, XATTR_SECURITY_PREFIX,
25724 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
25725 - !capable(CAP_SYS_ADMIN))
25726 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
25730 diff -NurpP --minimal linux-3.6/security/selinux/hooks.c linux-3.6-vs2.3.4.3-noxfs-nocow/security/selinux/hooks.c
25731 --- linux-3.6/security/selinux/hooks.c 2012-10-04 15:27:53.000000000 +0200
25732 +++ linux-3.6-vs2.3.4.3-noxfs-nocow/security/selinux/hooks.c 2012-10-04 18:47:00.000000000 +0200
25734 #include <linux/dccp.h>
25735 #include <linux/quota.h>
25736 #include <linux/un.h> /* for Unix socket types */
25737 -#include <net/af_unix.h> /* for Unix socket types */
25738 #include <linux/parser.h>
25739 #include <linux/nfs_mount.h>
25740 #include <net/ipv6.h>