1 diff -NurpP --minimal linux-2.6.35.7/arch/alpha/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/alpha/Kconfig
2 --- linux-2.6.35.7/arch/alpha/Kconfig 2010-08-02 16:51:53.000000000 +0200
3 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/alpha/Kconfig 2010-08-02 17:05:05.000000000 +0200
4 @@ -681,6 +681,8 @@ config DUMMY_CONSOLE
8 +source "kernel/vserver/Kconfig"
10 source "security/Kconfig"
12 source "crypto/Kconfig"
13 diff -NurpP --minimal linux-2.6.35.7/arch/alpha/kernel/entry.S linux-2.6.35.7-vs2.3.0.36.33/arch/alpha/kernel/entry.S
14 --- linux-2.6.35.7/arch/alpha/kernel/entry.S 2009-06-11 17:11:46.000000000 +0200
15 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/alpha/kernel/entry.S 2010-08-02 17:05:05.000000000 +0200
16 @@ -874,24 +874,15 @@ sys_getxgid:
25 - /* See linux/kernel/timer.c sys_getppid for discussion
27 - ldq $3, TASK_GROUP_LEADER($2)
28 - ldq $4, TASK_REAL_PARENT($3)
29 - ldl $0, TASK_TGID($2)
30 -1: ldl $1, TASK_TGID($4)
34 - ldq $3, TASK_GROUP_LEADER($2)
35 - ldq $4, TASK_REAL_PARENT($3)
48 diff -NurpP --minimal linux-2.6.35.7/arch/alpha/kernel/osf_sys.c linux-2.6.35.7-vs2.3.0.36.33/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.35.7/arch/alpha/kernel/osf_sys.c 2010-07-07 18:30:51.000000000 +0200
50 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/alpha/kernel/osf_sys.c 2010-08-02 17:05:05.000000000 +0200
51 @@ -866,7 +866,7 @@ SYSCALL_DEFINE2(osf_gettimeofday, struct
55 - do_gettimeofday(&ktv);
56 + vx_gettimeofday(&ktv);
57 if (put_tv32(tv, &ktv))
60 diff -NurpP --minimal linux-2.6.35.7/arch/alpha/kernel/ptrace.c linux-2.6.35.7-vs2.3.0.36.33/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.35.7/arch/alpha/kernel/ptrace.c 2010-07-07 18:30:51.000000000 +0200
62 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/alpha/kernel/ptrace.c 2010-08-02 17:05:05.000000000 +0200
64 #include <linux/user.h>
65 #include <linux/security.h>
66 #include <linux/signal.h>
67 +#include <linux/vs_base.h>
69 #include <asm/uaccess.h>
70 #include <asm/pgtable.h>
71 diff -NurpP --minimal linux-2.6.35.7/arch/alpha/kernel/systbls.S linux-2.6.35.7-vs2.3.0.36.33/arch/alpha/kernel/systbls.S
72 --- linux-2.6.35.7/arch/alpha/kernel/systbls.S 2010-02-25 11:51:19.000000000 +0100
73 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/alpha/kernel/systbls.S 2010-08-02 17:05:05.000000000 +0200
74 @@ -446,7 +446,7 @@ sys_call_table:
75 .quad sys_stat64 /* 425 */
78 - .quad sys_ni_syscall /* sys_vserver */
79 + .quad sys_vserver /* sys_vserver */
80 .quad sys_ni_syscall /* sys_mbind */
81 .quad sys_ni_syscall /* sys_get_mempolicy */
82 .quad sys_ni_syscall /* sys_set_mempolicy */
83 diff -NurpP --minimal linux-2.6.35.7/arch/alpha/kernel/traps.c linux-2.6.35.7-vs2.3.0.36.33/arch/alpha/kernel/traps.c
84 --- linux-2.6.35.7/arch/alpha/kernel/traps.c 2010-07-07 18:30:51.000000000 +0200
85 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/alpha/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
86 @@ -184,7 +184,8 @@ die_if_kernel(char * str, struct pt_regs
88 printk("CPU %d ", hard_smp_processor_id());
90 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
91 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
92 + task_pid_nr(current), current->xid, str, err);
93 dik_show_regs(regs, r9_15);
95 dik_show_trace((unsigned long *)(regs+1));
96 diff -NurpP --minimal linux-2.6.35.7/arch/arm/include/asm/tlb.h linux-2.6.35.7-vs2.3.0.36.33/arch/arm/include/asm/tlb.h
97 --- linux-2.6.35.7/arch/arm/include/asm/tlb.h 2009-09-10 15:25:15.000000000 +0200
98 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/arm/include/asm/tlb.h 2010-08-02 17:05:05.000000000 +0200
101 #else /* !CONFIG_MMU */
103 +#include <linux/vs_memory.h>
104 #include <asm/pgalloc.h>
107 diff -NurpP --minimal linux-2.6.35.7/arch/arm/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/arm/Kconfig
108 --- linux-2.6.35.7/arch/arm/Kconfig 2010-10-04 08:57:30.000000000 +0200
109 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/arm/Kconfig 2010-08-14 18:19:32.000000000 +0200
110 @@ -1685,6 +1685,8 @@ source "fs/Kconfig"
112 source "arch/arm/Kconfig.debug"
114 +source "kernel/vserver/Kconfig"
116 source "security/Kconfig"
118 source "crypto/Kconfig"
119 diff -NurpP --minimal linux-2.6.35.7/arch/arm/kernel/calls.S linux-2.6.35.7-vs2.3.0.36.33/arch/arm/kernel/calls.S
120 --- linux-2.6.35.7/arch/arm/kernel/calls.S 2010-07-07 18:30:52.000000000 +0200
121 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/arm/kernel/calls.S 2010-08-02 17:05:05.000000000 +0200
123 /* 310 */ CALL(sys_request_key)
125 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
126 -/* vserver */ CALL(sys_ni_syscall)
129 /* 315 */ CALL(sys_ioprio_get)
130 CALL(sys_inotify_init)
131 diff -NurpP --minimal linux-2.6.35.7/arch/arm/kernel/process.c linux-2.6.35.7-vs2.3.0.36.33/arch/arm/kernel/process.c
132 --- linux-2.6.35.7/arch/arm/kernel/process.c 2010-08-02 16:51:55.000000000 +0200
133 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/arm/kernel/process.c 2010-08-02 17:05:05.000000000 +0200
134 @@ -269,7 +269,8 @@ void __show_regs(struct pt_regs *regs)
135 void show_regs(struct pt_regs * regs)
138 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
139 + printk("Pid: %d[#%u], comm: %20s\n",
140 + task_pid_nr(current), current->xid, current->comm);
144 diff -NurpP --minimal linux-2.6.35.7/arch/arm/kernel/traps.c linux-2.6.35.7-vs2.3.0.36.33/arch/arm/kernel/traps.c
145 --- linux-2.6.35.7/arch/arm/kernel/traps.c 2010-07-07 18:30:52.000000000 +0200
146 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/arm/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
147 @@ -243,8 +243,8 @@ static int __die(const char *str, int er
151 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
152 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
153 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
154 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
156 if (!user_mode(regs) || in_interrupt()) {
157 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
158 diff -NurpP --minimal linux-2.6.35.7/arch/avr32/mm/fault.c linux-2.6.35.7-vs2.3.0.36.33/arch/avr32/mm/fault.c
159 --- linux-2.6.35.7/arch/avr32/mm/fault.c 2009-09-10 15:25:20.000000000 +0200
160 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/avr32/mm/fault.c 2010-08-02 17:05:05.000000000 +0200
161 @@ -216,7 +216,8 @@ out_of_memory:
162 down_read(&mm->mmap_sem);
165 - printk("VM: Killing process %s\n", tsk->comm);
166 + printk("VM: Killing process %s(%d:#%u)\n",
167 + tsk->comm, task_pid_nr(tsk), tsk->xid);
169 do_group_exit(SIGKILL);
171 diff -NurpP --minimal linux-2.6.35.7/arch/cris/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/cris/Kconfig
172 --- linux-2.6.35.7/arch/cris/Kconfig 2010-08-02 16:52:03.000000000 +0200
173 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/cris/Kconfig 2010-08-02 17:05:05.000000000 +0200
174 @@ -694,6 +694,8 @@ source "drivers/staging/Kconfig"
176 source "arch/cris/Kconfig.debug"
178 +source "kernel/vserver/Kconfig"
180 source "security/Kconfig"
182 source "crypto/Kconfig"
183 diff -NurpP --minimal linux-2.6.35.7/arch/cris/mm/fault.c linux-2.6.35.7-vs2.3.0.36.33/arch/cris/mm/fault.c
184 --- linux-2.6.35.7/arch/cris/mm/fault.c 2010-02-25 11:51:26.000000000 +0100
185 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/cris/mm/fault.c 2010-08-02 17:05:05.000000000 +0200
186 @@ -245,7 +245,8 @@ do_page_fault(unsigned long address, str
189 up_read(&mm->mmap_sem);
190 - printk("VM: killing process %s\n", tsk->comm);
191 + printk("VM: killing process %s(%d:#%u)\n",
192 + tsk->comm, task_pid_nr(tsk), tsk->xid);
196 diff -NurpP --minimal linux-2.6.35.7/arch/frv/kernel/kernel_thread.S linux-2.6.35.7-vs2.3.0.36.33/arch/frv/kernel/kernel_thread.S
197 --- linux-2.6.35.7/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
198 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/frv/kernel/kernel_thread.S 2010-08-02 17:05:05.000000000 +0200
199 @@ -37,7 +37,7 @@ kernel_thread:
201 # start by forking the current process, but with shared VM
202 setlos.p #__NR_clone,gr7 ; syscall number
203 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
204 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
205 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
207 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
208 diff -NurpP --minimal linux-2.6.35.7/arch/h8300/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/h8300/Kconfig
209 --- linux-2.6.35.7/arch/h8300/Kconfig 2010-02-25 11:51:26.000000000 +0100
210 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/h8300/Kconfig 2010-08-02 17:05:05.000000000 +0200
211 @@ -230,6 +230,8 @@ source "fs/Kconfig"
213 source "arch/h8300/Kconfig.debug"
215 +source "kernel/vserver/Kconfig"
217 source "security/Kconfig"
219 source "crypto/Kconfig"
220 diff -NurpP --minimal linux-2.6.35.7/arch/ia64/include/asm/tlb.h linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/include/asm/tlb.h
221 --- linux-2.6.35.7/arch/ia64/include/asm/tlb.h 2010-02-25 11:51:26.000000000 +0100
222 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/include/asm/tlb.h 2010-08-02 17:05:05.000000000 +0200
224 #include <linux/mm.h>
225 #include <linux/pagemap.h>
226 #include <linux/swap.h>
227 +#include <linux/vs_memory.h>
229 #include <asm/pgalloc.h>
230 #include <asm/processor.h>
231 diff -NurpP --minimal linux-2.6.35.7/arch/ia64/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/Kconfig
232 --- linux-2.6.35.7/arch/ia64/Kconfig 2010-08-02 16:52:03.000000000 +0200
233 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/Kconfig 2010-08-02 17:05:05.000000000 +0200
234 @@ -676,6 +676,8 @@ source "fs/Kconfig"
236 source "arch/ia64/Kconfig.debug"
238 +source "kernel/vserver/Kconfig"
240 source "security/Kconfig"
242 source "crypto/Kconfig"
243 diff -NurpP --minimal linux-2.6.35.7/arch/ia64/kernel/entry.S linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/kernel/entry.S
244 --- linux-2.6.35.7/arch/ia64/kernel/entry.S 2010-07-07 18:31:01.000000000 +0200
245 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/kernel/entry.S 2010-08-02 17:05:05.000000000 +0200
246 @@ -1714,7 +1714,7 @@ sys_call_table:
248 data8 sys_mq_getsetattr
250 - data8 sys_ni_syscall // reserved for vserver
252 data8 sys_waitid // 1270
254 data8 sys_request_key
255 diff -NurpP --minimal linux-2.6.35.7/arch/ia64/kernel/perfmon.c linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/kernel/perfmon.c
256 --- linux-2.6.35.7/arch/ia64/kernel/perfmon.c 2010-07-07 18:31:01.000000000 +0200
257 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/kernel/perfmon.c 2010-08-02 17:05:05.000000000 +0200
259 #include <linux/completion.h>
260 #include <linux/tracehook.h>
261 #include <linux/slab.h>
262 +#include <linux/vs_memory.h>
264 #include <asm/errno.h>
265 #include <asm/intrinsics.h>
266 diff -NurpP --minimal linux-2.6.35.7/arch/ia64/kernel/process.c linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/kernel/process.c
267 --- linux-2.6.35.7/arch/ia64/kernel/process.c 2010-07-07 18:31:01.000000000 +0200
268 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/kernel/process.c 2010-08-02 17:05:05.000000000 +0200
269 @@ -113,8 +113,8 @@ show_regs (struct pt_regs *regs)
270 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
273 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
274 - smp_processor_id(), current->comm);
275 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
276 + current->xid, smp_processor_id(), current->comm);
277 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
278 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
279 init_utsname()->release);
280 diff -NurpP --minimal linux-2.6.35.7/arch/ia64/kernel/ptrace.c linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/kernel/ptrace.c
281 --- linux-2.6.35.7/arch/ia64/kernel/ptrace.c 2010-08-02 16:52:04.000000000 +0200
282 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/kernel/ptrace.c 2010-08-02 17:05:05.000000000 +0200
284 #include <linux/regset.h>
285 #include <linux/elf.h>
286 #include <linux/tracehook.h>
287 +#include <linux/vs_base.h>
289 #include <asm/pgtable.h>
290 #include <asm/processor.h>
291 diff -NurpP --minimal linux-2.6.35.7/arch/ia64/kernel/traps.c linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/kernel/traps.c
292 --- linux-2.6.35.7/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
293 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
294 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
297 if (++die.lock_owner_depth < 3) {
298 - printk("%s[%d]: %s %ld [%d]\n",
299 - current->comm, task_pid_nr(current), str, err, ++die_counter);
300 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
301 + current->comm, task_pid_nr(current), current->xid,
302 + str, err, ++die_counter);
303 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
306 @@ -323,8 +324,9 @@ handle_fpu_swa (int fp_fault, struct pt_
307 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
308 last.time = current_jiffies + 5 * HZ;
310 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
311 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
312 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
313 + current->comm, task_pid_nr(current), current->xid,
314 + regs->cr_iip + ia64_psr(regs)->ri, isr);
318 diff -NurpP --minimal linux-2.6.35.7/arch/ia64/mm/fault.c linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/mm/fault.c
319 --- linux-2.6.35.7/arch/ia64/mm/fault.c 2010-08-02 16:52:04.000000000 +0200
320 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/ia64/mm/fault.c 2010-08-02 17:05:05.000000000 +0200
322 #include <linux/interrupt.h>
323 #include <linux/kprobes.h>
324 #include <linux/kdebug.h>
325 +#include <linux/vs_memory.h>
327 #include <asm/pgtable.h>
328 #include <asm/processor.h>
329 diff -NurpP --minimal linux-2.6.35.7/arch/m32r/kernel/traps.c linux-2.6.35.7-vs2.3.0.36.33/arch/m32r/kernel/traps.c
330 --- linux-2.6.35.7/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
331 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/m32r/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
332 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
334 printk("SPI: %08lx\n", sp);
336 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
337 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
338 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
339 + current->comm, task_pid_nr(current), current->xid,
340 + 0xffff & i, 4096+(unsigned long)current);
343 * When in-kernel, we also print out the stack and code at the
344 diff -NurpP --minimal linux-2.6.35.7/arch/m68k/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/m68k/Kconfig
345 --- linux-2.6.35.7/arch/m68k/Kconfig 2010-08-02 16:52:04.000000000 +0200
346 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/m68k/Kconfig 2010-08-02 17:05:05.000000000 +0200
347 @@ -619,6 +619,8 @@ source "fs/Kconfig"
349 source "arch/m68k/Kconfig.debug"
351 +source "kernel/vserver/Kconfig"
353 source "security/Kconfig"
355 source "crypto/Kconfig"
356 diff -NurpP --minimal linux-2.6.35.7/arch/m68k/kernel/ptrace.c linux-2.6.35.7-vs2.3.0.36.33/arch/m68k/kernel/ptrace.c
357 --- linux-2.6.35.7/arch/m68k/kernel/ptrace.c 2010-07-07 18:31:02.000000000 +0200
358 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/m68k/kernel/ptrace.c 2010-08-02 17:05:05.000000000 +0200
360 #include <linux/ptrace.h>
361 #include <linux/user.h>
362 #include <linux/signal.h>
363 +#include <linux/vs_base.h>
365 #include <asm/uaccess.h>
366 #include <asm/page.h>
367 @@ -254,6 +255,8 @@ long arch_ptrace(struct task_struct *chi
368 ret = ptrace_request(child, request, addr, data);
371 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
376 diff -NurpP --minimal linux-2.6.35.7/arch/m68k/kernel/traps.c linux-2.6.35.7-vs2.3.0.36.33/arch/m68k/kernel/traps.c
377 --- linux-2.6.35.7/arch/m68k/kernel/traps.c 2010-08-02 16:52:04.000000000 +0200
378 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/m68k/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
379 @@ -906,8 +906,8 @@ void show_registers(struct pt_regs *regs
380 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
381 regs->d4, regs->d5, regs->a0, regs->a1);
383 - printk("Process %s (pid: %d, task=%p)\n",
384 - current->comm, task_pid_nr(current), current);
385 + printk("Process %s (pid: %d[#%u], task=%p)\n",
386 + current->comm, task_pid_nr(current), current->xid, current);
387 addr = (unsigned long)&fp->un;
388 printk("Frame format=%X ", regs->format);
389 switch (regs->format) {
390 diff -NurpP --minimal linux-2.6.35.7/arch/m68knommu/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/m68knommu/Kconfig
391 --- linux-2.6.35.7/arch/m68knommu/Kconfig 2010-08-02 16:52:04.000000000 +0200
392 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/m68knommu/Kconfig 2010-08-02 17:05:05.000000000 +0200
393 @@ -734,6 +734,8 @@ source "fs/Kconfig"
395 source "arch/m68knommu/Kconfig.debug"
397 +source "kernel/vserver/Kconfig"
399 source "security/Kconfig"
401 source "crypto/Kconfig"
402 diff -NurpP --minimal linux-2.6.35.7/arch/m68knommu/kernel/traps.c linux-2.6.35.7-vs2.3.0.36.33/arch/m68knommu/kernel/traps.c
403 --- linux-2.6.35.7/arch/m68knommu/kernel/traps.c 2009-09-10 15:25:23.000000000 +0200
404 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/m68knommu/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
405 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
406 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
407 fp->d4, fp->d5, fp->a0, fp->a1);
409 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
410 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
411 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
412 + current->comm, task_pid_nr(current), current->xid,
413 + PAGE_SIZE+(unsigned long)current);
414 show_stack(NULL, (unsigned long *)(fp + 1));
415 add_taint(TAINT_DIE);
417 diff -NurpP --minimal linux-2.6.35.7/arch/mips/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/mips/Kconfig
418 --- linux-2.6.35.7/arch/mips/Kconfig 2010-08-02 16:52:05.000000000 +0200
419 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/mips/Kconfig 2010-08-02 17:05:05.000000000 +0200
420 @@ -2253,6 +2253,8 @@ source "fs/Kconfig"
422 source "arch/mips/Kconfig.debug"
424 +source "kernel/vserver/Kconfig"
426 source "security/Kconfig"
428 source "crypto/Kconfig"
429 diff -NurpP --minimal linux-2.6.35.7/arch/mips/kernel/ptrace.c linux-2.6.35.7-vs2.3.0.36.33/arch/mips/kernel/ptrace.c
430 --- linux-2.6.35.7/arch/mips/kernel/ptrace.c 2010-07-07 18:31:04.000000000 +0200
431 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/mips/kernel/ptrace.c 2010-08-02 17:05:05.000000000 +0200
433 #include <linux/security.h>
434 #include <linux/audit.h>
435 #include <linux/seccomp.h>
436 +#include <linux/vs_base.h>
438 #include <asm/byteorder.h>
440 @@ -259,6 +260,9 @@ long arch_ptrace(struct task_struct *chi
444 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
448 /* when I and D space are separate, these will need to be fixed. */
449 case PTRACE_PEEKTEXT: /* read word at location addr. */
450 diff -NurpP --minimal linux-2.6.35.7/arch/mips/kernel/scall32-o32.S linux-2.6.35.7-vs2.3.0.36.33/arch/mips/kernel/scall32-o32.S
451 --- linux-2.6.35.7/arch/mips/kernel/scall32-o32.S 2010-02-25 11:51:28.000000000 +0100
452 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/mips/kernel/scall32-o32.S 2010-08-02 17:05:05.000000000 +0200
453 @@ -525,7 +525,7 @@ einval: li v0, -ENOSYS
454 sys sys_mq_timedreceive 5
455 sys sys_mq_notify 2 /* 4275 */
456 sys sys_mq_getsetattr 3
457 - sys sys_ni_syscall 0 /* sys_vserver */
460 sys sys_ni_syscall 0 /* available, was setaltroot */
461 sys sys_add_key 5 /* 4280 */
462 diff -NurpP --minimal linux-2.6.35.7/arch/mips/kernel/scall64-64.S linux-2.6.35.7-vs2.3.0.36.33/arch/mips/kernel/scall64-64.S
463 --- linux-2.6.35.7/arch/mips/kernel/scall64-64.S 2010-02-25 11:51:28.000000000 +0100
464 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/mips/kernel/scall64-64.S 2010-08-02 17:05:05.000000000 +0200
465 @@ -362,7 +362,7 @@ sys_call_table:
466 PTR sys_mq_timedreceive
468 PTR sys_mq_getsetattr /* 5235 */
469 - PTR sys_ni_syscall /* sys_vserver */
472 PTR sys_ni_syscall /* available, was setaltroot */
474 diff -NurpP --minimal linux-2.6.35.7/arch/mips/kernel/scall64-n32.S linux-2.6.35.7-vs2.3.0.36.33/arch/mips/kernel/scall64-n32.S
475 --- linux-2.6.35.7/arch/mips/kernel/scall64-n32.S 2010-08-02 16:52:05.000000000 +0200
476 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/mips/kernel/scall64-n32.S 2010-08-02 17:05:05.000000000 +0200
477 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
478 PTR compat_sys_mq_timedreceive
479 PTR compat_sys_mq_notify
480 PTR compat_sys_mq_getsetattr
481 - PTR sys_ni_syscall /* 6240, sys_vserver */
482 + PTR sys32_vserver /* 6240 */
483 PTR compat_sys_waitid
484 PTR sys_ni_syscall /* available, was setaltroot */
486 diff -NurpP --minimal linux-2.6.35.7/arch/mips/kernel/scall64-o32.S linux-2.6.35.7-vs2.3.0.36.33/arch/mips/kernel/scall64-o32.S
487 --- linux-2.6.35.7/arch/mips/kernel/scall64-o32.S 2010-07-07 18:31:04.000000000 +0200
488 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/mips/kernel/scall64-o32.S 2010-08-02 17:05:05.000000000 +0200
489 @@ -480,7 +480,7 @@ sys_call_table:
490 PTR compat_sys_mq_timedreceive
491 PTR compat_sys_mq_notify /* 4275 */
492 PTR compat_sys_mq_getsetattr
493 - PTR sys_ni_syscall /* sys_vserver */
496 PTR sys_ni_syscall /* available, was setaltroot */
497 PTR sys_add_key /* 4280 */
498 diff -NurpP --minimal linux-2.6.35.7/arch/mips/kernel/traps.c linux-2.6.35.7-vs2.3.0.36.33/arch/mips/kernel/traps.c
499 --- linux-2.6.35.7/arch/mips/kernel/traps.c 2010-08-02 16:52:05.000000000 +0200
500 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/mips/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
501 @@ -340,9 +340,10 @@ void show_registers(const struct pt_regs
505 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
506 - current->comm, current->pid, current_thread_info(), current,
507 - field, current_thread_info()->tp_value);
508 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
509 + current->comm, task_pid_nr(current), current->xid,
510 + current_thread_info(), current,
511 + field, current_thread_info()->tp_value);
512 if (cpu_has_userlocal) {
515 diff -NurpP --minimal linux-2.6.35.7/arch/parisc/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/parisc/Kconfig
516 --- linux-2.6.35.7/arch/parisc/Kconfig 2010-08-02 16:52:06.000000000 +0200
517 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/parisc/Kconfig 2010-08-02 17:05:05.000000000 +0200
518 @@ -299,6 +299,8 @@ source "fs/Kconfig"
520 source "arch/parisc/Kconfig.debug"
522 +source "kernel/vserver/Kconfig"
524 source "security/Kconfig"
526 source "crypto/Kconfig"
527 diff -NurpP --minimal linux-2.6.35.7/arch/parisc/kernel/syscall_table.S linux-2.6.35.7-vs2.3.0.36.33/arch/parisc/kernel/syscall_table.S
528 --- linux-2.6.35.7/arch/parisc/kernel/syscall_table.S 2010-07-07 18:31:04.000000000 +0200
529 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/parisc/kernel/syscall_table.S 2010-08-02 17:05:05.000000000 +0200
531 ENTRY_COMP(mbind) /* 260 */
532 ENTRY_COMP(get_mempolicy)
533 ENTRY_COMP(set_mempolicy)
534 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
535 + ENTRY_DIFF(vserver)
537 ENTRY_SAME(request_key) /* 265 */
539 diff -NurpP --minimal linux-2.6.35.7/arch/parisc/kernel/traps.c linux-2.6.35.7-vs2.3.0.36.33/arch/parisc/kernel/traps.c
540 --- linux-2.6.35.7/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
541 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/parisc/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
542 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
546 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
547 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
548 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
549 + current->comm, task_pid_nr(current), current->xid,
550 + str, err, regs->iaoq[0]);
551 #ifdef PRINT_USER_FAULTS
552 /* XXX for debugging only */
554 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
555 pdc_console_restart();
558 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
559 - current->comm, task_pid_nr(current), str, err);
560 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
561 + current->comm, task_pid_nr(current), current->xid, str, err);
563 /* Wot's wrong wif bein' racy? */
564 if (current->thread.flags & PARISC_KERNEL_DEATH) {
565 diff -NurpP --minimal linux-2.6.35.7/arch/parisc/mm/fault.c linux-2.6.35.7-vs2.3.0.36.33/arch/parisc/mm/fault.c
566 --- linux-2.6.35.7/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
567 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/parisc/mm/fault.c 2010-08-02 17:05:05.000000000 +0200
568 @@ -237,8 +237,9 @@ bad_area:
570 #ifdef PRINT_USER_FAULTS
571 printk(KERN_DEBUG "\n");
572 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
573 - task_pid_nr(tsk), tsk->comm, code, address);
574 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
575 + "command='%s' type=%lu address=0x%08lx\n",
576 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
578 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
579 vma->vm_start, vma->vm_end);
580 diff -NurpP --minimal linux-2.6.35.7/arch/powerpc/include/asm/unistd.h linux-2.6.35.7-vs2.3.0.36.33/arch/powerpc/include/asm/unistd.h
581 --- linux-2.6.35.7/arch/powerpc/include/asm/unistd.h 2010-07-07 18:31:05.000000000 +0200
582 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/powerpc/include/asm/unistd.h 2010-08-02 17:05:05.000000000 +0200
585 #define __NR_rtas 255
586 #define __NR_sys_debug_setcontext 256
587 -/* Number 257 is reserved for vserver */
588 +#define __NR_vserver 257
589 #define __NR_migrate_pages 258
590 #define __NR_mbind 259
591 #define __NR_get_mempolicy 260
592 diff -NurpP --minimal linux-2.6.35.7/arch/powerpc/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/powerpc/Kconfig
593 --- linux-2.6.35.7/arch/powerpc/Kconfig 2010-08-02 16:52:06.000000000 +0200
594 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/powerpc/Kconfig 2010-08-02 17:05:05.000000000 +0200
595 @@ -990,6 +990,8 @@ source "lib/Kconfig"
597 source "arch/powerpc/Kconfig.debug"
599 +source "kernel/vserver/Kconfig"
601 source "security/Kconfig"
604 diff -NurpP --minimal linux-2.6.35.7/arch/powerpc/kernel/process.c linux-2.6.35.7-vs2.3.0.36.33/arch/powerpc/kernel/process.c
605 --- linux-2.6.35.7/arch/powerpc/kernel/process.c 2010-08-02 16:52:07.000000000 +0200
606 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/powerpc/kernel/process.c 2010-08-02 17:05:05.000000000 +0200
607 @@ -605,8 +605,9 @@ void show_regs(struct pt_regs * regs)
609 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
611 - printk("TASK = %p[%d] '%s' THREAD: %p",
612 - current, task_pid_nr(current), current->comm, task_thread_info(current));
613 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
614 + current, task_pid_nr(current), current->xid,
615 + current->comm, task_thread_info(current));
618 printk(" CPU: %d", raw_smp_processor_id());
619 diff -NurpP --minimal linux-2.6.35.7/arch/powerpc/kernel/traps.c linux-2.6.35.7-vs2.3.0.36.33/arch/powerpc/kernel/traps.c
620 --- linux-2.6.35.7/arch/powerpc/kernel/traps.c 2010-08-02 16:52:07.000000000 +0200
621 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/powerpc/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
622 @@ -1053,8 +1053,9 @@ void nonrecoverable_exception(struct pt_
624 void trace_syscall(struct pt_regs *regs)
626 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
627 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
628 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
629 + current, task_pid_nr(current), current->xid,
630 + regs->nip, regs->link, regs->gpr[0],
631 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
634 diff -NurpP --minimal linux-2.6.35.7/arch/powerpc/kernel/vdso.c linux-2.6.35.7-vs2.3.0.36.33/arch/powerpc/kernel/vdso.c
635 --- linux-2.6.35.7/arch/powerpc/kernel/vdso.c 2010-08-02 16:52:07.000000000 +0200
636 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/powerpc/kernel/vdso.c 2010-08-02 17:43:41.000000000 +0200
638 #include <linux/security.h>
639 #include <linux/bootmem.h>
640 #include <linux/memblock.h>
641 +#include <linux/vs_memory.h>
643 #include <asm/pgtable.h>
644 #include <asm/system.h>
645 diff -NurpP --minimal linux-2.6.35.7/arch/s390/include/asm/tlb.h linux-2.6.35.7-vs2.3.0.36.33/arch/s390/include/asm/tlb.h
646 --- linux-2.6.35.7/arch/s390/include/asm/tlb.h 2009-09-10 15:25:43.000000000 +0200
647 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/s390/include/asm/tlb.h 2010-08-02 17:05:05.000000000 +0200
650 #include <linux/mm.h>
651 #include <linux/swap.h>
652 +#include <linux/vs_memory.h>
654 #include <asm/processor.h>
655 #include <asm/pgalloc.h>
657 diff -NurpP --minimal linux-2.6.35.7/arch/s390/include/asm/unistd.h linux-2.6.35.7-vs2.3.0.36.33/arch/s390/include/asm/unistd.h
658 --- linux-2.6.35.7/arch/s390/include/asm/unistd.h 2010-07-07 18:31:06.000000000 +0200
659 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/s390/include/asm/unistd.h 2010-08-02 17:05:05.000000000 +0200
661 #define __NR_clock_gettime (__NR_timer_create+6)
662 #define __NR_clock_getres (__NR_timer_create+7)
663 #define __NR_clock_nanosleep (__NR_timer_create+8)
664 -/* Number 263 is reserved for vserver */
665 +#define __NR_vserver 263
666 #define __NR_statfs64 265
667 #define __NR_fstatfs64 266
668 #define __NR_remap_file_pages 267
669 diff -NurpP --minimal linux-2.6.35.7/arch/s390/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/s390/Kconfig
670 --- linux-2.6.35.7/arch/s390/Kconfig 2010-08-02 16:52:08.000000000 +0200
671 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/s390/Kconfig 2010-08-02 17:05:05.000000000 +0200
672 @@ -623,6 +623,8 @@ source "fs/Kconfig"
674 source "arch/s390/Kconfig.debug"
676 +source "kernel/vserver/Kconfig"
678 source "security/Kconfig"
680 source "crypto/Kconfig"
681 diff -NurpP --minimal linux-2.6.35.7/arch/s390/kernel/ptrace.c linux-2.6.35.7-vs2.3.0.36.33/arch/s390/kernel/ptrace.c
682 --- linux-2.6.35.7/arch/s390/kernel/ptrace.c 2010-08-02 16:52:09.000000000 +0200
683 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/s390/kernel/ptrace.c 2010-08-02 17:05:05.000000000 +0200
685 #include <linux/regset.h>
686 #include <linux/tracehook.h>
687 #include <linux/seccomp.h>
688 +#include <linux/vs_base.h>
689 #include <trace/syscall.h>
690 #include <asm/compat.h>
691 #include <asm/segment.h>
692 diff -NurpP --minimal linux-2.6.35.7/arch/s390/kernel/syscalls.S linux-2.6.35.7-vs2.3.0.36.33/arch/s390/kernel/syscalls.S
693 --- linux-2.6.35.7/arch/s390/kernel/syscalls.S 2010-07-07 18:31:07.000000000 +0200
694 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/s390/kernel/syscalls.S 2010-08-02 17:05:05.000000000 +0200
695 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
696 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
697 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
698 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
699 -NI_SYSCALL /* reserved for vserver */
700 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
701 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
702 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
703 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
704 diff -NurpP --minimal linux-2.6.35.7/arch/sh/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/sh/Kconfig
705 --- linux-2.6.35.7/arch/sh/Kconfig 2010-08-02 16:52:09.000000000 +0200
706 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/sh/Kconfig 2010-08-02 17:05:05.000000000 +0200
707 @@ -881,6 +881,8 @@ source "fs/Kconfig"
709 source "arch/sh/Kconfig.debug"
711 +source "kernel/vserver/Kconfig"
713 source "security/Kconfig"
715 source "crypto/Kconfig"
716 diff -NurpP --minimal linux-2.6.35.7/arch/sh/kernel/irq.c linux-2.6.35.7-vs2.3.0.36.33/arch/sh/kernel/irq.c
717 --- linux-2.6.35.7/arch/sh/kernel/irq.c 2010-08-02 16:52:10.000000000 +0200
718 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/sh/kernel/irq.c 2010-08-02 17:41:50.000000000 +0200
720 #include <linux/seq_file.h>
721 #include <linux/ftrace.h>
722 #include <linux/delay.h>
723 +// #include <linux/vs_context.h>
724 #include <asm/processor.h>
725 #include <asm/machvec.h>
726 #include <asm/uaccess.h>
727 diff -NurpP --minimal linux-2.6.35.7/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.35.7-vs2.3.0.36.33/arch/sh/kernel/vsyscall/vsyscall.c
728 --- linux-2.6.35.7/arch/sh/kernel/vsyscall/vsyscall.c 2010-07-07 18:31:10.000000000 +0200
729 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/sh/kernel/vsyscall/vsyscall.c 2010-08-02 17:05:05.000000000 +0200
731 #include <linux/elf.h>
732 #include <linux/sched.h>
733 #include <linux/err.h>
734 +#include <linux/vs_memory.h>
737 * Should the kernel map a VDSO page into processes and pass its
738 diff -NurpP --minimal linux-2.6.35.7/arch/sparc/include/asm/tlb_64.h linux-2.6.35.7-vs2.3.0.36.33/arch/sparc/include/asm/tlb_64.h
739 --- linux-2.6.35.7/arch/sparc/include/asm/tlb_64.h 2009-09-10 15:25:45.000000000 +0200
740 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/sparc/include/asm/tlb_64.h 2010-08-02 17:05:05.000000000 +0200
743 #include <linux/swap.h>
744 #include <linux/pagemap.h>
745 +#include <linux/vs_memory.h>
746 #include <asm/pgalloc.h>
747 #include <asm/tlbflush.h>
748 #include <asm/mmu_context.h>
749 diff -NurpP --minimal linux-2.6.35.7/arch/sparc/include/asm/unistd.h linux-2.6.35.7-vs2.3.0.36.33/arch/sparc/include/asm/unistd.h
750 --- linux-2.6.35.7/arch/sparc/include/asm/unistd.h 2010-07-07 18:31:10.000000000 +0200
751 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/sparc/include/asm/unistd.h 2010-08-02 17:05:05.000000000 +0200
753 #define __NR_timer_getoverrun 264
754 #define __NR_timer_delete 265
755 #define __NR_timer_create 266
756 -/* #define __NR_vserver 267 Reserved for VSERVER */
757 +#define __NR_vserver 267
758 #define __NR_io_setup 268
759 #define __NR_io_destroy 269
760 #define __NR_io_submit 270
761 diff -NurpP --minimal linux-2.6.35.7/arch/sparc/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/sparc/Kconfig
762 --- linux-2.6.35.7/arch/sparc/Kconfig 2010-08-02 16:52:10.000000000 +0200
763 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/sparc/Kconfig 2010-08-02 17:05:05.000000000 +0200
764 @@ -570,6 +570,8 @@ source "fs/Kconfig"
766 source "arch/sparc/Kconfig.debug"
768 +source "kernel/vserver/Kconfig"
770 source "security/Kconfig"
772 source "crypto/Kconfig"
773 diff -NurpP --minimal linux-2.6.35.7/arch/sparc/kernel/systbls_32.S linux-2.6.35.7-vs2.3.0.36.33/arch/sparc/kernel/systbls_32.S
774 --- linux-2.6.35.7/arch/sparc/kernel/systbls_32.S 2010-02-25 11:51:34.000000000 +0100
775 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/sparc/kernel/systbls_32.S 2010-08-02 17:05:05.000000000 +0200
776 @@ -70,7 +70,7 @@ sys_call_table:
777 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
778 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
779 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
780 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
781 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
782 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
783 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
784 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
785 diff -NurpP --minimal linux-2.6.35.7/arch/sparc/kernel/systbls_64.S linux-2.6.35.7-vs2.3.0.36.33/arch/sparc/kernel/systbls_64.S
786 --- linux-2.6.35.7/arch/sparc/kernel/systbls_64.S 2010-07-07 18:31:10.000000000 +0200
787 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/sparc/kernel/systbls_64.S 2010-08-02 17:05:05.000000000 +0200
788 @@ -71,7 +71,7 @@ sys_call_table32:
789 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
790 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
791 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
792 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
793 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
794 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
795 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
796 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
797 @@ -146,7 +146,7 @@ sys_call_table:
798 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
799 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
800 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
801 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
802 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
803 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
804 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
805 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
806 diff -NurpP --minimal linux-2.6.35.7/arch/um/include/asm/tlb.h linux-2.6.35.7-vs2.3.0.36.33/arch/um/include/asm/tlb.h
807 --- linux-2.6.35.7/arch/um/include/asm/tlb.h 2009-09-10 15:25:46.000000000 +0200
808 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/um/include/asm/tlb.h 2010-08-02 17:05:05.000000000 +0200
811 #include <linux/pagemap.h>
812 #include <linux/swap.h>
813 +#include <linux/vs_memory.h>
814 #include <asm/percpu.h>
815 #include <asm/pgalloc.h>
816 #include <asm/tlbflush.h>
817 diff -NurpP --minimal linux-2.6.35.7/arch/um/include/shared/kern_constants.h linux-2.6.35.7-vs2.3.0.36.33/arch/um/include/shared/kern_constants.h
818 --- linux-2.6.35.7/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
819 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/um/include/shared/kern_constants.h 2010-08-02 17:05:05.000000000 +0200
821 +#include "../../../../include/generated/asm-offsets.h"
822 diff -NurpP --minimal linux-2.6.35.7/arch/um/include/shared/user_constants.h linux-2.6.35.7-vs2.3.0.36.33/arch/um/include/shared/user_constants.h
823 --- linux-2.6.35.7/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
824 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/um/include/shared/user_constants.h 2010-08-02 17:05:05.000000000 +0200
829 + * This file was generated by arch/um/Makefile
833 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2) # */
834 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err) # */
835 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno) # */
836 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long) # */
837 +#define HOST_RBX 5 /* RBX # */
838 +#define HOST_RCX 11 /* RCX # */
839 +#define HOST_RDI 14 /* RDI # */
840 +#define HOST_RSI 13 /* RSI # */
841 +#define HOST_RDX 12 /* RDX # */
842 +#define HOST_RBP 4 /* RBP # */
843 +#define HOST_RAX 10 /* RAX # */
844 +#define HOST_R8 9 /* R8 # */
845 +#define HOST_R9 8 /* R9 # */
846 +#define HOST_R10 7 /* R10 # */
847 +#define HOST_R11 6 /* R11 # */
848 +#define HOST_R12 3 /* R12 # */
849 +#define HOST_R13 2 /* R13 # */
850 +#define HOST_R14 1 /* R14 # */
851 +#define HOST_R15 0 /* R15 # */
852 +#define HOST_ORIG_RAX 15 /* ORIG_RAX # */
853 +#define HOST_CS 17 /* CS # */
854 +#define HOST_SS 20 /* SS # */
855 +#define HOST_EFLAGS 18 /* EFLAGS # */
856 +#define HOST_IP 16 /* RIP # */
857 +#define HOST_SP 19 /* RSP # */
858 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct) # */
859 +#define UM_POLLIN 1 /* POLLIN # */
860 +#define UM_POLLPRI 2 /* POLLPRI # */
861 +#define UM_POLLOUT 4 /* POLLOUT # */
862 +#define UM_PROT_READ 1 /* PROT_READ # */
863 +#define UM_PROT_WRITE 2 /* PROT_WRITE # */
864 +#define UM_PROT_EXEC 4 /* PROT_EXEC # */
866 diff -NurpP --minimal linux-2.6.35.7/arch/um/Kconfig.rest linux-2.6.35.7-vs2.3.0.36.33/arch/um/Kconfig.rest
867 --- linux-2.6.35.7/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
868 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/um/Kconfig.rest 2010-08-02 17:05:05.000000000 +0200
869 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
873 +source "kernel/vserver/Kconfig"
875 source "security/Kconfig"
877 source "crypto/Kconfig"
878 diff -NurpP --minimal linux-2.6.35.7/arch/x86/ia32/ia32entry.S linux-2.6.35.7-vs2.3.0.36.33/arch/x86/ia32/ia32entry.S
879 --- linux-2.6.35.7/arch/x86/ia32/ia32entry.S 2010-10-04 08:57:32.000000000 +0200
880 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/x86/ia32/ia32entry.S 2010-09-22 02:52:29.000000000 +0200
881 @@ -783,7 +783,7 @@ ia32_sys_call_table:
882 .quad sys_tgkill /* 270 */
883 .quad compat_sys_utimes
884 .quad sys32_fadvise64_64
885 - .quad quiet_ni_syscall /* sys_vserver */
886 + .quad sys32_vserver
888 .quad compat_sys_get_mempolicy /* 275 */
889 .quad sys_set_mempolicy
890 diff -NurpP --minimal linux-2.6.35.7/arch/x86/include/asm/unistd_64.h linux-2.6.35.7-vs2.3.0.36.33/arch/x86/include/asm/unistd_64.h
891 --- linux-2.6.35.7/arch/x86/include/asm/unistd_64.h 2010-07-07 18:31:11.000000000 +0200
892 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/x86/include/asm/unistd_64.h 2010-08-02 17:05:05.000000000 +0200
893 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
894 #define __NR_utimes 235
895 __SYSCALL(__NR_utimes, sys_utimes)
896 #define __NR_vserver 236
897 -__SYSCALL(__NR_vserver, sys_ni_syscall)
898 +__SYSCALL(__NR_vserver, sys_vserver)
899 #define __NR_mbind 237
900 __SYSCALL(__NR_mbind, sys_mbind)
901 #define __NR_set_mempolicy 238
902 diff -NurpP --minimal linux-2.6.35.7/arch/x86/Kconfig linux-2.6.35.7-vs2.3.0.36.33/arch/x86/Kconfig
903 --- linux-2.6.35.7/arch/x86/Kconfig 2010-10-04 08:57:32.000000000 +0200
904 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/x86/Kconfig 2010-09-06 02:59:52.000000000 +0200
905 @@ -2128,6 +2128,8 @@ source "fs/Kconfig"
907 source "arch/x86/Kconfig.debug"
909 +source "kernel/vserver/Kconfig"
911 source "security/Kconfig"
913 source "crypto/Kconfig"
914 diff -NurpP --minimal linux-2.6.35.7/arch/x86/kernel/syscall_table_32.S linux-2.6.35.7-vs2.3.0.36.33/arch/x86/kernel/syscall_table_32.S
915 --- linux-2.6.35.7/arch/x86/kernel/syscall_table_32.S 2010-07-07 18:31:12.000000000 +0200
916 +++ linux-2.6.35.7-vs2.3.0.36.33/arch/x86/kernel/syscall_table_32.S 2010-08-02 17:05:05.000000000 +0200
917 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
918 .long sys_tgkill /* 270 */
920 .long sys_fadvise64_64
921 - .long sys_ni_syscall /* sys_vserver */
924 .long sys_get_mempolicy
925 .long sys_set_mempolicy
926 diff -NurpP --minimal linux-2.6.35.7/Documentation/vserver/debug.txt linux-2.6.35.7-vs2.3.0.36.33/Documentation/vserver/debug.txt
927 --- linux-2.6.35.7/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
928 +++ linux-2.6.35.7-vs2.3.0.36.33/Documentation/vserver/debug.txt 2010-08-02 17:05:05.000000000 +0200
933 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
934 + "vx_rmap_tgid: %p/%llx: %d -> %d"
938 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
939 + "FREE (%p,#%d)%c inode"
940 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
941 + "FREE (%p,#%d)%c %lld bytes"
942 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
943 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
944 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
945 + "rcu_free_dl_info(%p)"
946 + 4 10 "alloc_dl_info(%p,%d) = %p"
947 + "dealloc_dl_info(%p)"
948 + "get_dl_info(%p[#%d.%d])"
949 + "put_dl_info(%p[#%d.%d])"
950 + 5 20 "alloc_dl_info(%p,%d)*"
951 + 6 40 "__hash_dl_info: %p[#%d]"
952 + "__unhash_dl_info: %p[#%d]"
953 + 7 80 "locate_dl_info(%p,#%d) = %p"
957 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
958 + "new_dqhash: %p [#0x%08x]"
959 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
960 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
961 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
962 + "vroot_get_real_bdev not set"
963 + 1 2 "cow_break_link(»%s«)"
965 + 2 4 "dentry_open(new): %p"
966 + "dentry_open(old): %p"
967 + "lookup_create(new): %p"
969 + "path_lookup(old): %d"
970 + "vfs_create(new): %d"
973 + 3 8 "fput(new_file=%p[#%d])"
974 + "fput(old_file=%p[#%d])"
975 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
976 + "vx_info_kill(%p[#%d],%d,%d)*"
977 + 5 20 "vs_reboot(%p[#%d],%d)"
978 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
982 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
983 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
984 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
985 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
986 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
987 + 6 40 "sk,egf: %p [#%d] (from %d)"
988 + "sk,egn: %p [#%d] (from %d)"
989 + "sk,req: %p [#%d] (from %d)"
990 + "sk: %p [#%d] (from %d)"
991 + "tw: %p [#%d] (from %d)"
992 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
993 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
997 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
998 + "alloc_nx_info(%d) = %p"
999 + "create_nx_info(%d) (dynamic rejected)"
1000 + "create_nx_info(%d) = %p (already there)"
1001 + "create_nx_info(%d) = %p (new)"
1002 + "dealloc_nx_info(%p)"
1003 + 1 2 "alloc_nx_info(%d)*"
1004 + "create_nx_info(%d)*"
1005 + 2 4 "get_nx_info(%p[#%d.%d])"
1006 + "put_nx_info(%p[#%d.%d])"
1007 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
1008 + "clr_nx_info(%p[#%d.%d])"
1009 + "init_nx_info(%p[#%d.%d])"
1010 + "release_nx_info(%p[#%d.%d.%d]) %p"
1011 + "set_nx_info(%p[#%d.%d])"
1012 + 4 10 "__hash_nx_info: %p[#%d]"
1013 + "__nx_dynamic_id: [#%d]"
1014 + "__unhash_nx_info: %p[#%d.%d.%d]"
1015 + 5 20 "moved task %p into nxi:%p[#%d]"
1016 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
1017 + "task_get_nx_info(%p)"
1018 + 6 40 "nx_clear_persistent(%p[#%d])"
1022 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
1023 + 1 2 "quota_sync_dqh(%p,%d)"
1024 + "sync_dquots(%p,%d)"
1025 + "sync_dquots_dqh(%p,%d)"
1026 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
1030 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
1031 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
1032 + 4 10 "%s: (%s %s) returned %s with %d"
1036 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
1037 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
1041 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
1042 + "alloc_vx_info(%d) = %p"
1043 + "alloc_vx_info(%d)*"
1044 + "create_vx_info(%d) (dynamic rejected)"
1045 + "create_vx_info(%d) = %p (already there)"
1046 + "create_vx_info(%d) = %p (new)"
1047 + "dealloc_vx_info(%p)"
1048 + "loc_vx_info(%d) = %p (found)"
1049 + "loc_vx_info(%d) = %p (new)"
1050 + "loc_vx_info(%d) = %p (not available)"
1051 + 1 2 "create_vx_info(%d)*"
1052 + "loc_vx_info(%d)*"
1053 + 2 4 "get_vx_info(%p[#%d.%d])"
1054 + "put_vx_info(%p[#%d.%d])"
1055 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
1056 + "clr_vx_info(%p[#%d.%d])"
1057 + "init_vx_info(%p[#%d.%d])"
1058 + "release_vx_info(%p[#%d.%d.%d]) %p"
1059 + "set_vx_info(%p[#%d.%d])"
1060 + 4 10 "__hash_vx_info: %p[#%d]"
1061 + "__unhash_vx_info: %p[#%d.%d.%d]"
1062 + "__vx_dynamic_id: [#%d]"
1063 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
1064 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
1065 + "moved task %p into vxi:%p[#%d]"
1066 + "task_get_vx_info(%p)"
1067 + "vx_migrate_task(%p,%p[#%d.%d])"
1068 + 6 40 "vx_clear_persistent(%p[#%d])"
1069 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
1070 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
1071 + "vx_set_persistent(%p[#%d])"
1072 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
1073 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
1078 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
1079 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1081 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
1082 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
1083 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1084 diff -NurpP --minimal linux-2.6.35.7/drivers/block/Kconfig linux-2.6.35.7-vs2.3.0.36.33/drivers/block/Kconfig
1085 --- linux-2.6.35.7/drivers/block/Kconfig 2010-08-02 16:52:14.000000000 +0200
1086 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/block/Kconfig 2010-08-02 17:05:05.000000000 +0200
1087 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
1089 source "drivers/block/drbd/Kconfig"
1091 +config BLK_DEV_VROOT
1092 + tristate "Virtual Root device support"
1093 + depends on QUOTACTL
1095 + Saying Y here will allow you to use quota/fs ioctls on a shared
1096 + partition within a virtual server without compromising security.
1099 tristate "Network block device support"
1101 diff -NurpP --minimal linux-2.6.35.7/drivers/block/loop.c linux-2.6.35.7-vs2.3.0.36.33/drivers/block/loop.c
1102 --- linux-2.6.35.7/drivers/block/loop.c 2010-08-02 16:52:14.000000000 +0200
1103 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/block/loop.c 2010-08-02 17:05:05.000000000 +0200
1105 #include <linux/highmem.h>
1106 #include <linux/kthread.h>
1107 #include <linux/splice.h>
1108 +#include <linux/vs_context.h>
1110 #include <asm/uaccess.h>
1112 @@ -813,6 +814,7 @@ static int loop_set_fd(struct loop_devic
1113 lo->lo_blocksize = lo_blocksize;
1114 lo->lo_device = bdev;
1115 lo->lo_flags = lo_flags;
1116 + lo->lo_xid = vx_current_xid();
1117 lo->lo_backing_file = file;
1118 lo->transfer = transfer_none;
1120 @@ -941,6 +943,7 @@ static int loop_clr_fd(struct loop_devic
1121 lo->lo_encrypt_key_size = 0;
1123 lo->lo_thread = NULL;
1125 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1126 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1127 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1128 @@ -978,7 +981,7 @@ loop_set_status(struct loop_device *lo,
1130 if (lo->lo_encrypt_key_size &&
1131 lo->lo_key_owner != uid &&
1132 - !capable(CAP_SYS_ADMIN))
1133 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1135 if (lo->lo_state != Lo_bound)
1137 @@ -1062,7 +1065,8 @@ loop_get_status(struct loop_device *lo,
1138 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1139 info->lo_encrypt_type =
1140 lo->lo_encryption ? lo->lo_encryption->number : 0;
1141 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1142 + if (lo->lo_encrypt_key_size &&
1143 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1144 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1145 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1146 lo->lo_encrypt_key_size);
1147 @@ -1408,6 +1412,9 @@ static int lo_open(struct block_device *
1149 struct loop_device *lo = bdev->bd_disk->private_data;
1151 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1154 mutex_lock(&lo->lo_ctl_mutex);
1156 mutex_unlock(&lo->lo_ctl_mutex);
1157 diff -NurpP --minimal linux-2.6.35.7/drivers/block/Makefile linux-2.6.35.7-vs2.3.0.36.33/drivers/block/Makefile
1158 --- linux-2.6.35.7/drivers/block/Makefile 2010-02-25 11:51:36.000000000 +0100
1159 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/block/Makefile 2010-08-02 17:05:05.000000000 +0200
1160 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1161 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1162 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1163 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1164 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1166 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1167 obj-$(CONFIG_BLK_DEV_DRBD) += drbd/
1168 diff -NurpP --minimal linux-2.6.35.7/drivers/block/vroot.c linux-2.6.35.7-vs2.3.0.36.33/drivers/block/vroot.c
1169 --- linux-2.6.35.7/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1170 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/block/vroot.c 2010-08-02 17:05:05.000000000 +0200
1173 + * linux/drivers/block/vroot.c
1175 + * written by Herbert Pötzl, 9/11/2002
1176 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1178 + * based on the loop.c code by Theodore Ts'o.
1180 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1181 + * Redistribution of this file is permitted under the
1182 + * GNU General Public License.
1186 +#include <linux/module.h>
1187 +#include <linux/moduleparam.h>
1188 +#include <linux/file.h>
1189 +#include <linux/major.h>
1190 +#include <linux/blkdev.h>
1191 +#include <linux/slab.h>
1193 +#include <linux/vroot.h>
1194 +#include <linux/vs_context.h>
1197 +static int max_vroot = 8;
1199 +static struct vroot_device *vroot_dev;
1200 +static struct gendisk **disks;
1203 +static int vroot_set_dev(
1204 + struct vroot_device *vr,
1205 + struct block_device *bdev,
1208 + struct block_device *real_bdev;
1209 + struct file *file;
1210 + struct inode *inode;
1214 + if (vr->vr_state != Vr_unbound)
1223 + inode = file->f_dentry->d_inode;
1226 + if (S_ISBLK(inode->i_mode)) {
1227 + real_bdev = inode->i_bdev;
1228 + vr->vr_device = real_bdev;
1229 + __iget(real_bdev->bd_inode);
1233 + vxdprintk(VXD_CBIT(misc, 0),
1234 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1235 + vr->vr_number, VXD_DEV(real_bdev));
1237 + vr->vr_state = Vr_bound;
1246 +static int vroot_clr_dev(
1247 + struct vroot_device *vr,
1248 + struct block_device *bdev)
1250 + struct block_device *real_bdev;
1252 + if (vr->vr_state != Vr_bound)
1254 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1257 + real_bdev = vr->vr_device;
1259 + vxdprintk(VXD_CBIT(misc, 0),
1260 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1261 + vr->vr_number, VXD_DEV(real_bdev));
1264 + vr->vr_state = Vr_unbound;
1265 + vr->vr_device = NULL;
1270 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1271 + unsigned int cmd, unsigned long arg)
1273 + struct vroot_device *vr = bdev->bd_disk->private_data;
1276 + down(&vr->vr_ctl_mutex);
1278 + case VROOT_SET_DEV:
1279 + err = vroot_set_dev(vr, bdev, arg);
1281 + case VROOT_CLR_DEV:
1282 + err = vroot_clr_dev(vr, bdev);
1288 + up(&vr->vr_ctl_mutex);
1292 +static int vr_open(struct block_device *bdev, fmode_t mode)
1294 + struct vroot_device *vr = bdev->bd_disk->private_data;
1296 + down(&vr->vr_ctl_mutex);
1298 + up(&vr->vr_ctl_mutex);
1302 +static int vr_release(struct gendisk *disk, fmode_t mode)
1304 + struct vroot_device *vr = disk->private_data;
1306 + down(&vr->vr_ctl_mutex);
1308 + up(&vr->vr_ctl_mutex);
1312 +static struct block_device_operations vr_fops = {
1313 + .owner = THIS_MODULE,
1315 + .release = vr_release,
1316 + .ioctl = vr_ioctl,
1319 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1321 + struct inode *inode = bdev->bd_inode;
1322 + struct vroot_device *vr;
1323 + struct block_device *real_bdev;
1324 + int minor = iminor(inode);
1326 + vr = &vroot_dev[minor];
1327 + real_bdev = vr->vr_device;
1329 + vxdprintk(VXD_CBIT(misc, 0),
1330 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1331 + vr->vr_number, VXD_DEV(real_bdev));
1333 + if (vr->vr_state != Vr_bound)
1334 + return ERR_PTR(-ENXIO);
1336 + __iget(real_bdev->bd_inode);
1341 + * And now the modules code and kernel interface.
1344 +module_param(max_vroot, int, 0);
1346 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1347 +MODULE_LICENSE("GPL");
1348 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1350 +MODULE_AUTHOR ("Herbert Pötzl");
1351 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1354 +int __init vroot_init(void)
1358 + if (max_vroot < 1 || max_vroot > 256) {
1359 + max_vroot = MAX_VROOT_DEFAULT;
1360 + printk(KERN_WARNING "vroot: invalid max_vroot "
1361 + "(must be between 1 and 256), "
1362 + "using default (%d)\n", max_vroot);
1365 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1369 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1372 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1374 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1378 + for (i = 0; i < max_vroot; i++) {
1379 + disks[i] = alloc_disk(1);
1382 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1383 + if (!disks[i]->queue)
1387 + for (i = 0; i < max_vroot; i++) {
1388 + struct vroot_device *vr = &vroot_dev[i];
1389 + struct gendisk *disk = disks[i];
1391 + memset(vr, 0, sizeof(*vr));
1392 + init_MUTEX(&vr->vr_ctl_mutex);
1393 + vr->vr_number = i;
1394 + disk->major = VROOT_MAJOR;
1395 + disk->first_minor = i;
1396 + disk->fops = &vr_fops;
1397 + sprintf(disk->disk_name, "vroot%d", i);
1398 + disk->private_data = vr;
1401 + err = register_vroot_grb(&__vroot_get_real_bdev);
1405 + for (i = 0; i < max_vroot; i++)
1406 + add_disk(disks[i]);
1407 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1412 + put_disk(disks[i]);
1417 + unregister_blkdev(VROOT_MAJOR, "vroot");
1418 + printk(KERN_ERR "vroot: ran out of memory\n");
1422 +void vroot_exit(void)
1426 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1427 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1429 + for (i = 0; i < max_vroot; i++) {
1430 + del_gendisk(disks[i]);
1431 + put_disk(disks[i]);
1433 + unregister_blkdev(VROOT_MAJOR, "vroot");
1439 +module_init(vroot_init);
1440 +module_exit(vroot_exit);
1444 +static int __init max_vroot_setup(char *str)
1446 + max_vroot = simple_strtol(str, NULL, 0);
1450 +__setup("max_vroot=", max_vroot_setup);
1454 diff -NurpP --minimal linux-2.6.35.7/drivers/char/sysrq.c linux-2.6.35.7-vs2.3.0.36.33/drivers/char/sysrq.c
1455 --- linux-2.6.35.7/drivers/char/sysrq.c 2010-08-02 16:52:15.000000000 +0200
1456 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/char/sysrq.c 2010-08-02 17:39:50.000000000 +0200
1458 #include <linux/oom.h>
1459 #include <linux/slab.h>
1460 #include <linux/input.h>
1461 +#include <linux/vserver/debug.h>
1463 #include <asm/ptrace.h>
1464 #include <asm/irq_regs.h>
1465 @@ -396,6 +397,21 @@ static struct sysrq_key_op sysrq_unrt_op
1466 .enable_mask = SYSRQ_ENABLE_RTNICE,
1470 +#ifdef CONFIG_VSERVER_DEBUG
1471 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
1473 + dump_vx_info_inactive((key == 'x')?0:1);
1476 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1477 + .handler = sysrq_handle_vxinfo,
1478 + .help_msg = "conteXt",
1479 + .action_msg = "Show Context Info",
1480 + .enable_mask = SYSRQ_ENABLE_DUMP,
1484 /* Key Operations table and lock */
1485 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1487 @@ -450,7 +466,11 @@ static struct sysrq_key_op *sysrq_key_ta
1489 &sysrq_showstate_blocked_op, /* w */
1490 /* x: May be registered on ppc/powerpc for xmon */
1491 +#ifdef CONFIG_VSERVER_DEBUG
1492 + &sysrq_showvxinfo_op, /* x */
1496 /* y: May be registered on sparc64 for global register dump */
1498 &sysrq_ftrace_dump_op, /* z */
1499 @@ -465,6 +485,8 @@ static int sysrq_key_table_key2index(int
1501 else if ((key >= 'a') && (key <= 'z'))
1502 retval = key + 10 - 'a';
1503 + else if ((key >= 'A') && (key <= 'Z'))
1504 + retval = key + 10 - 'A';
1508 diff -NurpP --minimal linux-2.6.35.7/drivers/char/tty_io.c linux-2.6.35.7-vs2.3.0.36.33/drivers/char/tty_io.c
1509 --- linux-2.6.35.7/drivers/char/tty_io.c 2010-10-04 08:57:33.000000000 +0200
1510 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/char/tty_io.c 2010-09-06 02:59:52.000000000 +0200
1513 #include <linux/kmod.h>
1514 #include <linux/nsproxy.h>
1515 +#include <linux/vs_pid.h>
1517 #undef TTY_DEBUG_HANGUP
1519 @@ -1992,7 +1993,8 @@ static int tiocsti(struct tty_struct *tt
1521 struct tty_ldisc *ld;
1523 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1524 + if (((current->signal->tty != tty) &&
1525 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1527 if (get_user(ch, p))
1529 @@ -2280,6 +2282,7 @@ static int tiocspgrp(struct tty_struct *
1531 if (get_user(pgrp_nr, p))
1533 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1537 diff -NurpP --minimal linux-2.6.35.7/drivers/gpu/drm/radeon/r100_reg_safe.h linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/r100_reg_safe.h
1538 --- linux-2.6.35.7/drivers/gpu/drm/radeon/r100_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1539 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/r100_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
1541 +static const unsigned r100_reg_safe_bm[102] = {
1542 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1543 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1544 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1545 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1546 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1547 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1548 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1549 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1550 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1551 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1552 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1553 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1554 + 0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1555 + 0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1556 + 0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
1557 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1558 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
1559 + 0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
1560 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1561 + 0xFFFFFFFF, 0xFFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1562 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1563 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1564 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1565 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1566 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1567 + 0xFFFFFFFF, 0xFFFFFFEF,
1569 diff -NurpP --minimal linux-2.6.35.7/drivers/gpu/drm/radeon/r200_reg_safe.h linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/r200_reg_safe.h
1570 --- linux-2.6.35.7/drivers/gpu/drm/radeon/r200_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1571 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/r200_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
1573 +static const unsigned r200_reg_safe_bm[102] = {
1574 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1575 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1576 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1577 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1578 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1579 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1580 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1581 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1582 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1583 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1584 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1585 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1586 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1587 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1588 + 0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
1589 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1590 + 0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
1591 + 0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
1592 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1593 + 0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1594 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1595 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1596 + 0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
1597 + 0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
1598 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1599 + 0xFFFFFE3F, 0xFFFFFFEF,
1601 diff -NurpP --minimal linux-2.6.35.7/drivers/gpu/drm/radeon/r300_reg_safe.h linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/r300_reg_safe.h
1602 --- linux-2.6.35.7/drivers/gpu/drm/radeon/r300_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1603 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/r300_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
1605 +static const unsigned r300_reg_safe_bm[159] = {
1606 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1607 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1608 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1609 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1610 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1611 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1612 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1613 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1614 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1615 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1616 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1617 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1618 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1619 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1620 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1621 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1622 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1623 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1624 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1625 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1626 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1627 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1628 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1629 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1630 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1631 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1632 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1633 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1634 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1635 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1636 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1637 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1638 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1639 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1640 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1641 + 0x00000000, 0x0000C100, 0x00000000, 0x00000000,
1642 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1643 + 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
1644 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1645 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1647 diff -NurpP --minimal linux-2.6.35.7/drivers/gpu/drm/radeon/r420_reg_safe.h linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/r420_reg_safe.h
1648 --- linux-2.6.35.7/drivers/gpu/drm/radeon/r420_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1649 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/r420_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
1651 +static const unsigned r420_reg_safe_bm[159] = {
1652 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1653 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1654 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1655 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1656 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1657 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1658 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1659 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1660 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1661 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1662 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1663 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1664 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1665 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1666 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1667 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1668 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1669 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1670 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1671 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1672 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1673 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1674 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1675 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1676 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1677 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1678 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1679 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1680 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1681 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1682 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1683 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1684 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1685 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1686 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1687 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1688 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1689 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1690 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1691 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1693 diff -NurpP --minimal linux-2.6.35.7/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/rn50_reg_safe.h
1694 --- linux-2.6.35.7/drivers/gpu/drm/radeon/rn50_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1695 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/rn50_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
1697 +static const unsigned rn50_reg_safe_bm[102] = {
1698 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1699 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1700 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1701 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1702 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1703 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1704 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1705 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1706 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1707 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1708 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1709 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1710 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1711 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1712 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1713 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1714 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1715 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1716 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1717 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1718 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1719 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1720 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1721 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1722 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1723 + 0xFFFFFFFF, 0xFFFFFFFF,
1725 diff -NurpP --minimal linux-2.6.35.7/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/rs600_reg_safe.h
1726 --- linux-2.6.35.7/drivers/gpu/drm/radeon/rs600_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1727 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/rs600_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
1729 +static const unsigned rs600_reg_safe_bm[219] = {
1730 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1731 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1732 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1733 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1734 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1735 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1736 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1737 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1738 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1739 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1740 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1741 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1742 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1743 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1744 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1745 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1746 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1747 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1748 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1749 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1750 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1751 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1752 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1753 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1754 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1755 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1756 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1757 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1758 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1759 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1760 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1761 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1762 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1763 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1764 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1765 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1766 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1767 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1768 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1769 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
1770 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1771 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1772 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1773 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1774 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1775 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1776 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1777 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1778 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1779 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1780 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1781 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1782 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1783 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1784 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1786 diff -NurpP --minimal linux-2.6.35.7/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/rv515_reg_safe.h
1787 --- linux-2.6.35.7/drivers/gpu/drm/radeon/rv515_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1788 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/gpu/drm/radeon/rv515_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
1790 +static const unsigned rv515_reg_safe_bm[219] = {
1791 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1792 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1793 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1794 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1795 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1796 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1797 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1798 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1799 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1800 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1801 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1802 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1803 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1804 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1805 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1806 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1807 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1808 + 0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1809 + 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
1810 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1811 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1812 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1813 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1814 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1815 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1816 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1817 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1818 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1819 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1820 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1821 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1822 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1823 + 0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
1824 + 0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
1825 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1826 + 0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
1827 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1828 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
1829 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1830 + 0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
1831 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1832 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1833 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1834 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1835 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1836 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1837 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1838 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1839 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1840 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1841 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1842 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1843 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1844 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1845 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1847 diff -NurpP --minimal linux-2.6.35.7/drivers/infiniband/core/addr.c linux-2.6.35.7-vs2.3.0.36.33/drivers/infiniband/core/addr.c
1848 --- linux-2.6.35.7/drivers/infiniband/core/addr.c 2010-07-07 18:31:18.000000000 +0200
1849 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/infiniband/core/addr.c 2010-08-02 17:05:05.000000000 +0200
1850 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
1852 if (ipv6_addr_any(&fl.fl6_src)) {
1853 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1854 - &fl.fl6_dst, 0, &fl.fl6_src);
1855 + &fl.fl6_dst, 0, &fl.fl6_src, NULL);
1859 diff -NurpP --minimal linux-2.6.35.7/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.35.7-vs2.3.0.36.33/drivers/infiniband/hw/ipath/ipath_user_pages.c
1860 --- linux-2.6.35.7/drivers/infiniband/hw/ipath/ipath_user_pages.c 2010-07-07 18:31:19.000000000 +0200
1861 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/infiniband/hw/ipath/ipath_user_pages.c 2010-08-02 17:05:05.000000000 +0200
1863 #include <linux/device.h>
1864 #include <linux/slab.h>
1865 #include <linux/sched.h>
1866 +#include <linux/vs_memory.h>
1868 #include "ipath_kernel.h"
1870 diff -NurpP --minimal linux-2.6.35.7/drivers/md/dm.c linux-2.6.35.7-vs2.3.0.36.33/drivers/md/dm.c
1871 --- linux-2.6.35.7/drivers/md/dm.c 2010-10-04 08:57:35.000000000 +0200
1872 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/md/dm.c 2010-09-06 03:00:12.000000000 +0200
1874 #include <linux/idr.h>
1875 #include <linux/hdreg.h>
1876 #include <linux/delay.h>
1877 +#include <linux/vs_base.h>
1879 #include <trace/events/block.h>
1881 @@ -120,6 +121,7 @@ struct mapped_device {
1884 atomic_t open_count;
1887 unsigned long flags;
1889 @@ -338,6 +340,7 @@ int dm_deleting_md(struct mapped_device
1890 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1892 struct mapped_device *md;
1895 spin_lock(&_minor_lock);
1897 @@ -346,18 +349,19 @@ static int dm_blk_open(struct block_devi
1900 if (test_bit(DMF_FREEING, &md->flags) ||
1901 - dm_deleting_md(md)) {
1903 + dm_deleting_md(md))
1907 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1912 atomic_inc(&md->open_count);
1916 spin_unlock(&_minor_lock);
1918 - return md ? 0 : -ENXIO;
1922 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1923 @@ -575,6 +579,14 @@ int dm_set_geometry(struct mapped_device
1928 + * Get the xid associated with a dm device
1930 +xid_t dm_get_xid(struct mapped_device *md)
1935 /*-----------------------------------------------------------------
1937 * A more elegant soln is in the works that uses the queue
1938 @@ -1887,6 +1899,7 @@ static struct mapped_device *alloc_dev(i
1939 INIT_LIST_HEAD(&md->uevent_list);
1940 spin_lock_init(&md->uevent_lock);
1942 + md->xid = vx_current_xid();
1943 md->queue = blk_init_queue(dm_request_fn, NULL);
1946 diff -NurpP --minimal linux-2.6.35.7/drivers/md/dm.h linux-2.6.35.7-vs2.3.0.36.33/drivers/md/dm.h
1947 --- linux-2.6.35.7/drivers/md/dm.h 2010-10-04 08:57:35.000000000 +0200
1948 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/md/dm.h 2010-09-06 02:59:52.000000000 +0200
1949 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1951 struct dm_md_mempools;
1953 +xid_t dm_get_xid(struct mapped_device *md);
1955 /*-----------------------------------------------------------------
1956 * Internal table functions.
1957 *---------------------------------------------------------------*/
1958 diff -NurpP --minimal linux-2.6.35.7/drivers/md/dm-ioctl.c linux-2.6.35.7-vs2.3.0.36.33/drivers/md/dm-ioctl.c
1959 --- linux-2.6.35.7/drivers/md/dm-ioctl.c 2010-10-04 08:57:35.000000000 +0200
1960 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/md/dm-ioctl.c 2010-09-06 02:59:52.000000000 +0200
1962 #include <linux/dm-ioctl.h>
1963 #include <linux/hdreg.h>
1964 #include <linux/compat.h>
1965 +#include <linux/vs_context.h>
1967 #include <asm/uaccess.h>
1969 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1970 unsigned int h = hash_str(str);
1972 list_for_each_entry (hc, _name_buckets + h, name_list)
1973 - if (!strcmp(hc->name, str)) {
1974 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1975 + !strcmp(hc->name, str)) {
1979 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1980 unsigned int h = hash_str(str);
1982 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1983 - if (!strcmp(hc->uuid, str)) {
1984 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1985 + !strcmp(hc->uuid, str)) {
1989 @@ -375,6 +378,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1991 static int remove_all(struct dm_ioctl *param, size_t param_size)
1993 + if (!vx_check(0, VS_ADMIN))
1996 dm_hash_remove_all(1);
1997 param->data_size = 0;
1999 @@ -422,6 +428,8 @@ static int list_devices(struct dm_ioctl
2001 for (i = 0; i < NUM_BUCKETS; i++) {
2002 list_for_each_entry (hc, _name_buckets + i, name_list) {
2003 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2005 needed += sizeof(struct dm_name_list);
2006 needed += strlen(hc->name) + 1;
2007 needed += ALIGN_MASK;
2008 @@ -445,6 +453,8 @@ static int list_devices(struct dm_ioctl
2010 for (i = 0; i < NUM_BUCKETS; i++) {
2011 list_for_each_entry (hc, _name_buckets + i, name_list) {
2012 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2015 old_nl->next = (uint32_t) ((void *) nl -
2017 @@ -680,10 +690,11 @@ static struct hash_cell *__find_device_h
2021 - mdptr = dm_get_mdptr(md);
2022 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
2023 + mdptr = dm_get_mdptr(md);
2031 @@ -1526,8 +1537,8 @@ static int ctl_ioctl(uint command, struc
2035 - /* only root can play with this */
2036 - if (!capable(CAP_SYS_ADMIN))
2037 + /* only root and certain contexts can play with this */
2038 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
2041 if (_IOC_TYPE(command) != DM_IOCTL)
2042 diff -NurpP --minimal linux-2.6.35.7/drivers/net/tun.c linux-2.6.35.7-vs2.3.0.36.33/drivers/net/tun.c
2043 --- linux-2.6.35.7/drivers/net/tun.c 2010-08-02 16:52:27.000000000 +0200
2044 +++ linux-2.6.35.7-vs2.3.0.36.33/drivers/net/tun.c 2010-08-02 17:05:05.000000000 +0200
2046 #include <linux/nsproxy.h>
2047 #include <linux/virtio_net.h>
2048 #include <linux/rcupdate.h>
2049 +#include <linux/vs_network.h>
2050 #include <net/net_namespace.h>
2051 #include <net/netns/generic.h>
2052 #include <net/rtnetlink.h>
2053 @@ -103,6 +104,7 @@ struct tun_struct {
2059 struct net_device *dev;
2060 struct fasync_struct *fasync;
2061 @@ -851,6 +853,7 @@ static void tun_setup(struct net_device
2065 + tun->nid = current->nid;
2067 dev->ethtool_ops = &tun_ethtool_ops;
2068 dev->destructor = tun_free_netdev;
2069 @@ -1001,7 +1004,7 @@ static int tun_set_iff(struct net *net,
2071 if (((tun->owner != -1 && cred->euid != tun->owner) ||
2072 (tun->group != -1 && !in_egroup_p(tun->group))) &&
2073 - !capable(CAP_NET_ADMIN))
2074 + !cap_raised(current_cap(), CAP_NET_ADMIN))
2076 err = security_tun_dev_attach(tun->socket.sk);
2078 @@ -1015,7 +1018,7 @@ static int tun_set_iff(struct net *net,
2080 unsigned long flags = 0;
2082 - if (!capable(CAP_NET_ADMIN))
2083 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
2085 err = security_tun_dev_create();
2087 @@ -1085,6 +1088,9 @@ static int tun_set_iff(struct net *net,
2089 sk->sk_destruct = tun_sock_destruct;
2091 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
2094 err = tun_attach(tun, file);
2097 @@ -1276,6 +1282,16 @@ static long __tun_chr_ioctl(struct file
2098 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
2102 + if (!capable(CAP_CONTEXT))
2105 + /* Set nid owner of the device */
2106 + tun->nid = (nid_t) arg;
2108 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
2112 /* Only allow setting the type when the interface is down */
2113 if (tun->dev->flags & IFF_UP) {
2114 diff -NurpP --minimal linux-2.6.35.7/fs/attr.c linux-2.6.35.7-vs2.3.0.36.33/fs/attr.c
2115 --- linux-2.6.35.7/fs/attr.c 2010-08-02 16:52:47.000000000 +0200
2116 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/attr.c 2010-08-02 21:00:32.000000000 +0200
2118 #include <linux/fsnotify.h>
2119 #include <linux/fcntl.h>
2120 #include <linux/security.h>
2121 +#include <linux/proc_fs.h>
2122 +#include <linux/devpts_fs.h>
2123 +#include <linux/vs_tag.h>
2125 /* Taken over from the old code... */
2127 @@ -54,6 +57,10 @@ int inode_change_ok(const struct inode *
2128 if (!is_owner_or_cap(inode))
2132 + if (dx_permission(inode, MAY_WRITE))
2138 @@ -127,6 +134,8 @@ void generic_setattr(struct inode *inode
2139 inode->i_uid = attr->ia_uid;
2140 if (ia_valid & ATTR_GID)
2141 inode->i_gid = attr->ia_gid;
2142 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2143 + inode->i_tag = attr->ia_tag;
2144 if (ia_valid & ATTR_ATIME)
2145 inode->i_atime = timespec_trunc(attr->ia_atime,
2146 inode->i_sb->s_time_gran);
2147 @@ -179,7 +188,8 @@ int notify_change(struct dentry * dentry
2148 struct timespec now;
2149 unsigned int ia_valid = attr->ia_valid;
2151 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
2152 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
2153 + ATTR_TAG | ATTR_TIMES_SET)) {
2154 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
2157 diff -NurpP --minimal linux-2.6.35.7/fs/binfmt_aout.c linux-2.6.35.7-vs2.3.0.36.33/fs/binfmt_aout.c
2158 --- linux-2.6.35.7/fs/binfmt_aout.c 2010-07-07 18:31:50.000000000 +0200
2159 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/binfmt_aout.c 2010-08-02 17:05:05.000000000 +0200
2161 #include <linux/init.h>
2162 #include <linux/coredump.h>
2163 #include <linux/slab.h>
2164 +#include <linux/vs_memory.h>
2166 #include <asm/system.h>
2167 #include <asm/uaccess.h>
2168 diff -NurpP --minimal linux-2.6.35.7/fs/binfmt_elf.c linux-2.6.35.7-vs2.3.0.36.33/fs/binfmt_elf.c
2169 --- linux-2.6.35.7/fs/binfmt_elf.c 2010-07-07 18:31:50.000000000 +0200
2170 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/binfmt_elf.c 2010-08-02 17:05:05.000000000 +0200
2172 #include <linux/elf.h>
2173 #include <linux/utsname.h>
2174 #include <linux/coredump.h>
2175 +#include <linux/vs_memory.h>
2176 #include <asm/uaccess.h>
2177 #include <asm/param.h>
2178 #include <asm/page.h>
2179 diff -NurpP --minimal linux-2.6.35.7/fs/binfmt_flat.c linux-2.6.35.7-vs2.3.0.36.33/fs/binfmt_flat.c
2180 --- linux-2.6.35.7/fs/binfmt_flat.c 2010-08-02 16:52:47.000000000 +0200
2181 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/binfmt_flat.c 2010-08-02 17:05:05.000000000 +0200
2183 #include <linux/init.h>
2184 #include <linux/flat.h>
2185 #include <linux/syscalls.h>
2186 +#include <linux/vs_memory.h>
2188 #include <asm/byteorder.h>
2189 #include <asm/system.h>
2190 diff -NurpP --minimal linux-2.6.35.7/fs/binfmt_som.c linux-2.6.35.7-vs2.3.0.36.33/fs/binfmt_som.c
2191 --- linux-2.6.35.7/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
2192 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/binfmt_som.c 2010-08-02 17:05:05.000000000 +0200
2194 #include <linux/shm.h>
2195 #include <linux/personality.h>
2196 #include <linux/init.h>
2197 +#include <linux/vs_memory.h>
2199 #include <asm/uaccess.h>
2200 #include <asm/pgtable.h>
2201 diff -NurpP --minimal linux-2.6.35.7/fs/block_dev.c linux-2.6.35.7-vs2.3.0.36.33/fs/block_dev.c
2202 --- linux-2.6.35.7/fs/block_dev.c 2010-10-04 08:57:38.000000000 +0200
2203 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/block_dev.c 2010-08-14 18:19:32.000000000 +0200
2205 #include <linux/namei.h>
2206 #include <linux/log2.h>
2207 #include <linux/kmemleak.h>
2208 +#include <linux/vs_device.h>
2209 #include <asm/uaccess.h>
2210 #include "internal.h"
2212 @@ -529,6 +530,7 @@ struct block_device *bdget(dev_t dev)
2213 bdev->bd_invalidated = 0;
2214 inode->i_mode = S_IFBLK;
2215 inode->i_rdev = dev;
2216 + inode->i_mdev = dev;
2217 inode->i_bdev = bdev;
2218 inode->i_data.a_ops = &def_blk_aops;
2219 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2220 @@ -575,6 +577,11 @@ EXPORT_SYMBOL(bdput);
2221 static struct block_device *bd_acquire(struct inode *inode)
2223 struct block_device *bdev;
2226 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2228 + inode->i_mdev = mdev;
2230 spin_lock(&bdev_lock);
2231 bdev = inode->i_bdev;
2232 @@ -585,7 +592,7 @@ static struct block_device *bd_acquire(s
2234 spin_unlock(&bdev_lock);
2236 - bdev = bdget(inode->i_rdev);
2237 + bdev = bdget(mdev);
2239 spin_lock(&bdev_lock);
2240 if (!inode->i_bdev) {
2241 diff -NurpP --minimal linux-2.6.35.7/fs/btrfs/ctree.h linux-2.6.35.7-vs2.3.0.36.33/fs/btrfs/ctree.h
2242 --- linux-2.6.35.7/fs/btrfs/ctree.h 2010-08-02 16:52:47.000000000 +0200
2243 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/btrfs/ctree.h 2010-08-02 17:05:05.000000000 +0200
2244 @@ -551,11 +551,14 @@ struct btrfs_inode_item {
2245 /* modification sequence number for NFS */
2250 * a little future expansion, for more than this we can
2251 * just grow the inode item and version it
2253 - __le64 reserved[4];
2254 + __le16 reserved16;
2255 + __le32 reserved32;
2256 + __le64 reserved[3];
2257 struct btrfs_timespec atime;
2258 struct btrfs_timespec ctime;
2259 struct btrfs_timespec mtime;
2260 @@ -1193,6 +1196,8 @@ struct btrfs_root {
2261 #define BTRFS_MOUNT_DISCARD (1 << 10)
2262 #define BTRFS_MOUNT_FORCE_COMPRESS (1 << 11)
2264 +#define BTRFS_MOUNT_TAGGED (1 << 24)
2266 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
2267 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
2268 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
2269 @@ -1413,6 +1418,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
2270 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
2271 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
2272 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
2273 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
2274 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
2275 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
2276 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
2277 @@ -1474,6 +1480,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
2279 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
2281 +#define BTRFS_INODE_IXUNLINK (1 << 24)
2282 +#define BTRFS_INODE_BARRIER (1 << 25)
2283 +#define BTRFS_INODE_COW (1 << 26)
2286 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
2288 @@ -2432,6 +2442,7 @@ extern const struct dentry_operations bt
2289 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2290 void btrfs_update_iflags(struct inode *inode);
2291 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2292 +int btrfs_sync_flags(struct inode *inode, int, int);
2295 int btrfs_sync_file(struct file *file, int datasync);
2296 diff -NurpP --minimal linux-2.6.35.7/fs/btrfs/disk-io.c linux-2.6.35.7-vs2.3.0.36.33/fs/btrfs/disk-io.c
2297 --- linux-2.6.35.7/fs/btrfs/disk-io.c 2010-08-02 16:52:47.000000000 +0200
2298 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/btrfs/disk-io.c 2010-08-02 17:05:05.000000000 +0200
2299 @@ -1707,6 +1707,9 @@ struct btrfs_root *open_ctree(struct sup
2303 + if (btrfs_test_opt(tree_root, TAGGED))
2304 + sb->s_flags |= MS_TAGGED;
2306 features = btrfs_super_incompat_flags(disk_super) &
2307 ~BTRFS_FEATURE_INCOMPAT_SUPP;
2309 diff -NurpP --minimal linux-2.6.35.7/fs/btrfs/inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/btrfs/inode.c
2310 --- linux-2.6.35.7/fs/btrfs/inode.c 2010-08-02 16:52:47.000000000 +0200
2311 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/btrfs/inode.c 2010-08-02 17:05:05.000000000 +0200
2313 #include <linux/posix_acl.h>
2314 #include <linux/falloc.h>
2315 #include <linux/slab.h>
2316 +#include <linux/vs_tag.h>
2320 #include "disk-io.h"
2321 @@ -2415,6 +2417,8 @@ static void btrfs_read_locked_inode(stru
2323 u64 alloc_group_block;
2329 path = btrfs_alloc_path();
2330 @@ -2431,8 +2435,13 @@ static void btrfs_read_locked_inode(stru
2332 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
2333 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
2334 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
2335 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
2337 + uid = btrfs_inode_uid(leaf, inode_item);
2338 + gid = btrfs_inode_gid(leaf, inode_item);
2339 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2340 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2341 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2342 + btrfs_inode_tag(leaf, inode_item));
2343 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
2345 tspec = btrfs_inode_atime(inode_item);
2346 @@ -2514,8 +2523,15 @@ static void fill_inode_item(struct btrfs
2347 struct btrfs_inode_item *item,
2348 struct inode *inode)
2350 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
2351 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
2352 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2353 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2355 + btrfs_set_inode_uid(leaf, item, uid);
2356 + btrfs_set_inode_gid(leaf, item, gid);
2357 +#ifdef CONFIG_TAGGING_INTERN
2358 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
2361 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
2362 btrfs_set_inode_mode(leaf, item, inode->i_mode);
2363 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
2364 @@ -6940,6 +6956,7 @@ static const struct inode_operations btr
2365 .listxattr = btrfs_listxattr,
2366 .removexattr = btrfs_removexattr,
2367 .permission = btrfs_permission,
2368 + .sync_flags = btrfs_sync_flags,
2370 static const struct inode_operations btrfs_dir_ro_inode_operations = {
2371 .lookup = btrfs_lookup,
2372 @@ -7015,6 +7032,7 @@ static const struct inode_operations btr
2373 .permission = btrfs_permission,
2374 .fallocate = btrfs_fallocate,
2375 .fiemap = btrfs_fiemap,
2376 + .sync_flags = btrfs_sync_flags,
2378 static const struct inode_operations btrfs_special_inode_operations = {
2379 .getattr = btrfs_getattr,
2380 diff -NurpP --minimal linux-2.6.35.7/fs/btrfs/ioctl.c linux-2.6.35.7-vs2.3.0.36.33/fs/btrfs/ioctl.c
2381 --- linux-2.6.35.7/fs/btrfs/ioctl.c 2010-08-02 16:52:47.000000000 +0200
2382 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/btrfs/ioctl.c 2010-08-02 17:05:05.000000000 +0200
2383 @@ -68,10 +68,13 @@ static unsigned int btrfs_flags_to_ioctl
2385 unsigned int iflags = 0;
2387 - if (flags & BTRFS_INODE_SYNC)
2388 - iflags |= FS_SYNC_FL;
2389 if (flags & BTRFS_INODE_IMMUTABLE)
2390 iflags |= FS_IMMUTABLE_FL;
2391 + if (flags & BTRFS_INODE_IXUNLINK)
2392 + iflags |= FS_IXUNLINK_FL;
2394 + if (flags & BTRFS_INODE_SYNC)
2395 + iflags |= FS_SYNC_FL;
2396 if (flags & BTRFS_INODE_APPEND)
2397 iflags |= FS_APPEND_FL;
2398 if (flags & BTRFS_INODE_NODUMP)
2399 @@ -81,28 +84,78 @@ static unsigned int btrfs_flags_to_ioctl
2400 if (flags & BTRFS_INODE_DIRSYNC)
2401 iflags |= FS_DIRSYNC_FL;
2403 + if (flags & BTRFS_INODE_BARRIER)
2404 + iflags |= FS_BARRIER_FL;
2405 + if (flags & BTRFS_INODE_COW)
2406 + iflags |= FS_COW_FL;
2411 - * Update inode->i_flags based on the btrfs internal flags.
2412 + * Update inode->i_(v)flags based on the btrfs internal flags.
2414 void btrfs_update_iflags(struct inode *inode)
2416 struct btrfs_inode *ip = BTRFS_I(inode);
2418 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2419 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2420 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2422 - if (ip->flags & BTRFS_INODE_SYNC)
2423 - inode->i_flags |= S_SYNC;
2424 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2425 inode->i_flags |= S_IMMUTABLE;
2426 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2427 + inode->i_flags |= S_IXUNLINK;
2429 + if (ip->flags & BTRFS_INODE_SYNC)
2430 + inode->i_flags |= S_SYNC;
2431 if (ip->flags & BTRFS_INODE_APPEND)
2432 inode->i_flags |= S_APPEND;
2433 if (ip->flags & BTRFS_INODE_NOATIME)
2434 inode->i_flags |= S_NOATIME;
2435 if (ip->flags & BTRFS_INODE_DIRSYNC)
2436 inode->i_flags |= S_DIRSYNC;
2438 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2440 + if (ip->flags & BTRFS_INODE_BARRIER)
2441 + inode->i_vflags |= V_BARRIER;
2442 + if (ip->flags & BTRFS_INODE_COW)
2443 + inode->i_vflags |= V_COW;
2447 + * Update btrfs internal flags from inode->i_(v)flags.
2449 +void btrfs_update_flags(struct inode *inode)
2451 + struct btrfs_inode *ip = BTRFS_I(inode);
2453 + unsigned int flags = inode->i_flags;
2454 + unsigned int vflags = inode->i_vflags;
2456 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2457 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2458 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2459 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2461 + if (flags & S_IMMUTABLE)
2462 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2463 + if (flags & S_IXUNLINK)
2464 + ip->flags |= BTRFS_INODE_IXUNLINK;
2466 + if (flags & S_SYNC)
2467 + ip->flags |= BTRFS_INODE_SYNC;
2468 + if (flags & S_APPEND)
2469 + ip->flags |= BTRFS_INODE_APPEND;
2470 + if (flags & S_NOATIME)
2471 + ip->flags |= BTRFS_INODE_NOATIME;
2472 + if (flags & S_DIRSYNC)
2473 + ip->flags |= BTRFS_INODE_DIRSYNC;
2475 + if (vflags & V_BARRIER)
2476 + ip->flags |= BTRFS_INODE_BARRIER;
2477 + if (vflags & V_COW)
2478 + ip->flags |= BTRFS_INODE_COW;
2482 @@ -120,7 +173,7 @@ void btrfs_inherit_iflags(struct inode *
2483 flags = BTRFS_I(dir)->flags;
2485 if (S_ISREG(inode->i_mode))
2486 - flags &= ~BTRFS_INODE_DIRSYNC;
2487 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2488 else if (!S_ISDIR(inode->i_mode))
2489 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2491 @@ -128,6 +181,30 @@ void btrfs_inherit_iflags(struct inode *
2492 btrfs_update_iflags(inode);
2495 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2497 + struct btrfs_inode *ip = BTRFS_I(inode);
2498 + struct btrfs_root *root = ip->root;
2499 + struct btrfs_trans_handle *trans;
2502 + trans = btrfs_join_transaction(root, 1);
2505 + inode->i_flags = flags;
2506 + inode->i_vflags = vflags;
2507 + btrfs_update_flags(inode);
2509 + ret = btrfs_update_inode(trans, root, inode);
2512 + btrfs_update_iflags(inode);
2513 + inode->i_ctime = CURRENT_TIME;
2514 + btrfs_end_transaction(trans, root);
2519 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2521 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2522 @@ -150,6 +227,7 @@ static int btrfs_ioctl_setflags(struct f
2523 if (copy_from_user(&flags, arg, sizeof(flags)))
2526 + /* maybe add FS_IXUNLINK_FL ? */
2527 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
2528 FS_NOATIME_FL | FS_NODUMP_FL | \
2529 FS_SYNC_FL | FS_DIRSYNC_FL))
2530 @@ -162,7 +240,8 @@ static int btrfs_ioctl_setflags(struct f
2532 flags = btrfs_mask_flags(inode->i_mode, flags);
2533 oldflags = btrfs_flags_to_ioctl(ip->flags);
2534 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2535 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2536 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2537 if (!capable(CAP_LINUX_IMMUTABLE)) {
2540 @@ -173,14 +252,19 @@ static int btrfs_ioctl_setflags(struct f
2544 - if (flags & FS_SYNC_FL)
2545 - ip->flags |= BTRFS_INODE_SYNC;
2547 - ip->flags &= ~BTRFS_INODE_SYNC;
2548 if (flags & FS_IMMUTABLE_FL)
2549 ip->flags |= BTRFS_INODE_IMMUTABLE;
2551 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2552 + if (flags & FS_IXUNLINK_FL)
2553 + ip->flags |= BTRFS_INODE_IXUNLINK;
2555 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2557 + if (flags & FS_SYNC_FL)
2558 + ip->flags |= BTRFS_INODE_SYNC;
2560 + ip->flags &= ~BTRFS_INODE_SYNC;
2561 if (flags & FS_APPEND_FL)
2562 ip->flags |= BTRFS_INODE_APPEND;
2564 diff -NurpP --minimal linux-2.6.35.7/fs/btrfs/super.c linux-2.6.35.7-vs2.3.0.36.33/fs/btrfs/super.c
2565 --- linux-2.6.35.7/fs/btrfs/super.c 2010-08-02 16:52:47.000000000 +0200
2566 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/btrfs/super.c 2010-08-02 17:05:05.000000000 +0200
2567 @@ -68,7 +68,7 @@ enum {
2568 Opt_nodatacow, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, Opt_ssd,
2569 Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress,
2570 Opt_compress_force, Opt_notreelog, Opt_ratio, Opt_flushoncommit,
2571 - Opt_discard, Opt_err,
2572 + Opt_tag, Opt_notag, Opt_tagid, Opt_discard, Opt_err,
2575 static match_table_t tokens = {
2576 @@ -92,6 +92,9 @@ static match_table_t tokens = {
2577 {Opt_flushoncommit, "flushoncommit"},
2578 {Opt_ratio, "metadata_ratio=%d"},
2579 {Opt_discard, "discard"},
2581 + {Opt_notag, "notag"},
2582 + {Opt_tagid, "tagid=%u"},
2586 @@ -235,6 +238,22 @@ int btrfs_parse_options(struct btrfs_roo
2588 btrfs_set_opt(info->mount_opt, DISCARD);
2590 +#ifndef CONFIG_TAGGING_NONE
2592 + printk(KERN_INFO "btrfs: use tagging\n");
2593 + btrfs_set_opt(info->mount_opt, TAGGED);
2596 + printk(KERN_INFO "btrfs: disabled tagging\n");
2597 + btrfs_clear_opt(info->mount_opt, TAGGED);
2600 +#ifdef CONFIG_PROPAGATE
2603 + btrfs_set_opt(info->mount_opt, TAGGED);
2607 printk(KERN_INFO "btrfs: unrecognized mount option "
2609 @@ -681,6 +700,12 @@ static int btrfs_remount(struct super_bl
2613 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2614 + printk("btrfs: %s: tagging not permitted on remount.\n",
2619 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2622 diff -NurpP --minimal linux-2.6.35.7/fs/char_dev.c linux-2.6.35.7-vs2.3.0.36.33/fs/char_dev.c
2623 --- linux-2.6.35.7/fs/char_dev.c 2010-10-04 08:57:38.000000000 +0200
2624 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/char_dev.c 2010-10-05 19:23:43.000000000 +0200
2626 #include <linux/mutex.h>
2627 #include <linux/backing-dev.h>
2628 #include <linux/tty.h>
2629 +#include <linux/vs_context.h>
2630 +#include <linux/vs_device.h>
2632 #include "internal.h"
2634 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2636 struct cdev *new = NULL;
2640 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2642 + inode->i_mdev = mdev;
2644 spin_lock(&cdev_lock);
2647 struct kobject *kobj;
2650 spin_unlock(&cdev_lock);
2651 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2653 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2656 new = container_of(kobj, struct cdev, kobj);
2657 diff -NurpP --minimal linux-2.6.35.7/fs/dcache.c linux-2.6.35.7-vs2.3.0.36.33/fs/dcache.c
2658 --- linux-2.6.35.7/fs/dcache.c 2010-08-02 16:52:48.000000000 +0200
2659 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/dcache.c 2010-08-02 17:05:05.000000000 +0200
2661 #include <linux/bootmem.h>
2662 #include <linux/fs_struct.h>
2663 #include <linux/hardirq.h>
2664 +#include <linux/vs_limit.h>
2665 #include "internal.h"
2667 int sysctl_vfs_cache_pressure __read_mostly = 100;
2668 @@ -230,6 +231,8 @@ repeat:
2672 + vx_dentry_dec(dentry);
2675 * AV: ->d_delete() is _NOT_ allowed to block now.
2677 @@ -323,6 +326,7 @@ static inline struct dentry * __dget_loc
2679 atomic_inc(&dentry->d_count);
2680 dentry_lru_del_init(dentry);
2681 + vx_dentry_inc(dentry);
2685 @@ -926,6 +930,9 @@ struct dentry *d_alloc(struct dentry * p
2686 struct dentry *dentry;
2689 + if (!vx_dentry_avail(1))
2692 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2695 @@ -971,6 +978,7 @@ struct dentry *d_alloc(struct dentry * p
2697 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
2698 dentry_stat.nr_dentry++;
2699 + vx_dentry_inc(dentry);
2700 spin_unlock(&dcache_lock);
2703 @@ -1420,6 +1428,7 @@ struct dentry * __d_lookup(struct dentry
2706 atomic_inc(&dentry->d_count);
2707 + vx_dentry_inc(dentry);
2709 spin_unlock(&dentry->d_lock);
2711 diff -NurpP --minimal linux-2.6.35.7/fs/devpts/inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/devpts/inode.c
2712 --- linux-2.6.35.7/fs/devpts/inode.c 2010-08-02 16:52:48.000000000 +0200
2713 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/devpts/inode.c 2010-08-02 17:05:05.000000000 +0200
2715 #include <linux/parser.h>
2716 #include <linux/fsnotify.h>
2717 #include <linux/seq_file.h>
2718 +#include <linux/vs_base.h>
2720 #define DEVPTS_DEFAULT_MODE 0600
2723 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2724 #define PTMX_MINOR 2
2726 +static int devpts_permission(struct inode *inode, int mask)
2728 + int ret = -EACCES;
2730 + /* devpts is xid tagged */
2731 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2732 + ret = generic_permission(inode, mask, NULL);
2736 +static struct inode_operations devpts_file_inode_operations = {
2737 + .permission = devpts_permission,
2740 extern int pty_limit; /* Config limit on Unix98 ptys */
2741 static DEFINE_MUTEX(allocated_ptys_lock);
2743 @@ -263,6 +278,25 @@ static int devpts_show_options(struct se
2747 +static int devpts_filter(struct dentry *de)
2749 + /* devpts is xid tagged */
2750 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
2753 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2755 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2758 +static struct file_operations devpts_dir_operations = {
2759 + .open = dcache_dir_open,
2760 + .release = dcache_dir_close,
2761 + .llseek = dcache_dir_lseek,
2762 + .read = generic_read_dir,
2763 + .readdir = devpts_readdir,
2766 static const struct super_operations devpts_sops = {
2767 .statfs = simple_statfs,
2768 .remount_fs = devpts_remount,
2769 @@ -302,12 +336,15 @@ devpts_fill_super(struct super_block *s,
2770 inode = new_inode(s);
2775 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2776 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2777 inode->i_op = &simple_dir_inode_operations;
2778 - inode->i_fop = &simple_dir_operations;
2779 + inode->i_fop = &devpts_dir_operations;
2781 + /* devpts is xid tagged */
2782 + inode->i_tag = (tag_t)vx_current_xid();
2784 s->s_root = d_alloc_root(inode);
2786 @@ -495,6 +532,9 @@ int devpts_pty_new(struct inode *ptmx_in
2787 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2788 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2789 init_special_inode(inode, S_IFCHR|opts->mode, device);
2790 + /* devpts is xid tagged */
2791 + inode->i_tag = (tag_t)vx_current_xid();
2792 + inode->i_op = &devpts_file_inode_operations;
2793 inode->i_private = tty;
2794 tty->driver_data = inode;
2796 diff -NurpP --minimal linux-2.6.35.7/fs/exec.c linux-2.6.35.7-vs2.3.0.36.33/fs/exec.c
2797 --- linux-2.6.35.7/fs/exec.c 2010-08-02 16:52:48.000000000 +0200
2798 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/exec.c 2010-08-02 17:05:05.000000000 +0200
2799 @@ -1506,7 +1506,7 @@ static int format_corename(char *corenam
2800 /* UNIX time of coredump */
2803 - do_gettimeofday(&tv);
2804 + vx_gettimeofday(&tv);
2805 rc = snprintf(out_ptr, out_end - out_ptr,
2807 if (rc > out_end - out_ptr)
2808 diff -NurpP --minimal linux-2.6.35.7/fs/ext2/balloc.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/balloc.c
2809 --- linux-2.6.35.7/fs/ext2/balloc.c 2010-08-02 16:52:48.000000000 +0200
2810 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/balloc.c 2010-08-02 17:05:05.000000000 +0200
2811 @@ -702,7 +702,6 @@ ext2_try_to_allocate(struct super_block
2813 end = EXT2_BLOCKS_PER_GROUP(sb);
2816 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2819 diff -NurpP --minimal linux-2.6.35.7/fs/ext2/ext2.h linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/ext2.h
2820 --- linux-2.6.35.7/fs/ext2/ext2.h 2010-08-02 16:52:48.000000000 +0200
2821 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/ext2.h 2010-08-02 17:05:05.000000000 +0200
2822 @@ -130,6 +130,7 @@ extern int ext2_fiemap(struct inode *ino
2823 int __ext2_write_begin(struct file *file, struct address_space *mapping,
2824 loff_t pos, unsigned len, unsigned flags,
2825 struct page **pagep, void **fsdata);
2826 +extern int ext2_sync_flags(struct inode *, int, int);
2829 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2830 diff -NurpP --minimal linux-2.6.35.7/fs/ext2/file.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/file.c
2831 --- linux-2.6.35.7/fs/ext2/file.c 2010-08-02 16:52:48.000000000 +0200
2832 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/file.c 2010-08-02 17:05:05.000000000 +0200
2833 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2834 .setattr = ext2_setattr,
2835 .check_acl = ext2_check_acl,
2836 .fiemap = ext2_fiemap,
2837 + .sync_flags = ext2_sync_flags,
2839 diff -NurpP --minimal linux-2.6.35.7/fs/ext2/ialloc.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/ialloc.c
2840 --- linux-2.6.35.7/fs/ext2/ialloc.c 2010-08-02 16:52:48.000000000 +0200
2841 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/ialloc.c 2010-08-02 18:15:12.000000000 +0200
2843 #include <linux/backing-dev.h>
2844 #include <linux/buffer_head.h>
2845 #include <linux/random.h>
2846 +#include <linux/vs_tag.h>
2850 @@ -553,6 +554,7 @@ got:
2851 inode->i_mode = mode;
2852 inode->i_uid = current_fsuid();
2853 inode->i_gid = dir->i_gid;
2854 + inode->i_tag = dx_current_fstag(sb);
2856 inode_init_owner(inode, dir, mode);
2858 diff -NurpP --minimal linux-2.6.35.7/fs/ext2/inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/inode.c
2859 --- linux-2.6.35.7/fs/ext2/inode.c 2010-08-02 16:52:48.000000000 +0200
2860 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/inode.c 2010-08-02 17:05:05.000000000 +0200
2862 #include <linux/mpage.h>
2863 #include <linux/fiemap.h>
2864 #include <linux/namei.h>
2865 +#include <linux/vs_tag.h>
2869 @@ -1164,7 +1165,7 @@ static void ext2_truncate_blocks(struct
2871 if (ext2_inode_is_fast_symlink(inode))
2873 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2874 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2876 __ext2_truncate_blocks(inode, offset);
2878 @@ -1261,36 +1262,61 @@ void ext2_set_inode_flags(struct inode *
2880 unsigned int flags = EXT2_I(inode)->i_flags;
2882 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2883 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2884 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2887 + if (flags & EXT2_IMMUTABLE_FL)
2888 + inode->i_flags |= S_IMMUTABLE;
2889 + if (flags & EXT2_IXUNLINK_FL)
2890 + inode->i_flags |= S_IXUNLINK;
2892 if (flags & EXT2_SYNC_FL)
2893 inode->i_flags |= S_SYNC;
2894 if (flags & EXT2_APPEND_FL)
2895 inode->i_flags |= S_APPEND;
2896 - if (flags & EXT2_IMMUTABLE_FL)
2897 - inode->i_flags |= S_IMMUTABLE;
2898 if (flags & EXT2_NOATIME_FL)
2899 inode->i_flags |= S_NOATIME;
2900 if (flags & EXT2_DIRSYNC_FL)
2901 inode->i_flags |= S_DIRSYNC;
2903 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2905 + if (flags & EXT2_BARRIER_FL)
2906 + inode->i_vflags |= V_BARRIER;
2907 + if (flags & EXT2_COW_FL)
2908 + inode->i_vflags |= V_COW;
2911 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2912 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2914 unsigned int flags = ei->vfs_inode.i_flags;
2915 + unsigned int vflags = ei->vfs_inode.i_vflags;
2917 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2918 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2919 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2920 + EXT2_BARRIER_FL | EXT2_COW_FL);
2922 + if (flags & S_IMMUTABLE)
2923 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2924 + if (flags & S_IXUNLINK)
2925 + ei->i_flags |= EXT2_IXUNLINK_FL;
2927 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2928 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2930 ei->i_flags |= EXT2_SYNC_FL;
2931 if (flags & S_APPEND)
2932 ei->i_flags |= EXT2_APPEND_FL;
2933 - if (flags & S_IMMUTABLE)
2934 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2935 if (flags & S_NOATIME)
2936 ei->i_flags |= EXT2_NOATIME_FL;
2937 if (flags & S_DIRSYNC)
2938 ei->i_flags |= EXT2_DIRSYNC_FL;
2940 + if (vflags & V_BARRIER)
2941 + ei->i_flags |= EXT2_BARRIER_FL;
2942 + if (vflags & V_COW)
2943 + ei->i_flags |= EXT2_COW_FL;
2946 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2947 @@ -1300,6 +1326,8 @@ struct inode *ext2_iget (struct super_bl
2948 struct ext2_inode *raw_inode;
2949 struct inode *inode;
2955 inode = iget_locked(sb, ino);
2956 @@ -1318,12 +1346,17 @@ struct inode *ext2_iget (struct super_bl
2959 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2960 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2961 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2962 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2963 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2964 if (!(test_opt (inode->i_sb, NO_UID32))) {
2965 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2966 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2967 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2968 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2970 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2971 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2972 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2973 + le16_to_cpu(raw_inode->i_raw_tag));
2975 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2976 inode->i_size = le32_to_cpu(raw_inode->i_size);
2977 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2978 @@ -1421,8 +1454,8 @@ static int __ext2_write_inode(struct ino
2979 struct ext2_inode_info *ei = EXT2_I(inode);
2980 struct super_block *sb = inode->i_sb;
2981 ino_t ino = inode->i_ino;
2982 - uid_t uid = inode->i_uid;
2983 - gid_t gid = inode->i_gid;
2984 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2985 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2986 struct buffer_head * bh;
2987 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2989 @@ -1458,6 +1491,9 @@ static int __ext2_write_inode(struct ino
2990 raw_inode->i_uid_high = 0;
2991 raw_inode->i_gid_high = 0;
2993 +#ifdef CONFIG_TAGGING_INTERN
2994 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2996 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2997 raw_inode->i_size = cpu_to_le32(inode->i_size);
2998 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2999 @@ -1547,7 +1583,8 @@ int ext2_setattr(struct dentry *dentry,
3000 if (is_quota_modification(inode, iattr))
3001 dquot_initialize(inode);
3002 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3003 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3004 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3005 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3006 error = dquot_transfer(inode, iattr);
3009 diff -NurpP --minimal linux-2.6.35.7/fs/ext2/ioctl.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/ioctl.c
3010 --- linux-2.6.35.7/fs/ext2/ioctl.c 2009-09-10 15:26:21.000000000 +0200
3011 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/ioctl.c 2010-08-02 17:05:05.000000000 +0200
3013 #include <asm/uaccess.h>
3016 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
3018 + inode->i_flags = flags;
3019 + inode->i_vflags = vflags;
3020 + ext2_get_inode_flags(EXT2_I(inode));
3021 + inode->i_ctime = CURRENT_TIME_SEC;
3022 + mark_inode_dirty(inode);
3026 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3028 struct inode *inode = filp->f_dentry->d_inode;
3029 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
3031 flags = ext2_mask_flags(inode->i_mode, flags);
3033 + if (IS_BARRIER(inode)) {
3034 + vxwprintk_task(1, "messing with the barrier.");
3038 mutex_lock(&inode->i_mutex);
3039 /* Is it quota file? Do not allow user to mess with it */
3040 if (IS_NOQUOTA(inode)) {
3041 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
3043 * This test looks nicer. Thanks to Pauline Middelink
3045 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
3046 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
3047 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
3048 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
3049 if (!capable(CAP_LINUX_IMMUTABLE)) {
3050 mutex_unlock(&inode->i_mutex);
3052 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
3056 - flags = flags & EXT2_FL_USER_MODIFIABLE;
3057 + flags &= EXT2_FL_USER_MODIFIABLE;
3058 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
3059 ei->i_flags = flags;
3060 mutex_unlock(&inode->i_mutex);
3061 diff -NurpP --minimal linux-2.6.35.7/fs/ext2/namei.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/namei.c
3062 --- linux-2.6.35.7/fs/ext2/namei.c 2010-07-07 18:31:51.000000000 +0200
3063 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/namei.c 2010-08-02 17:05:05.000000000 +0200
3066 #include <linux/pagemap.h>
3067 #include <linux/quotaops.h>
3068 +#include <linux/vs_tag.h>
3072 @@ -75,6 +76,7 @@ static struct dentry *ext2_lookup(struct
3073 return ERR_PTR(-EIO);
3075 return ERR_CAST(inode);
3076 + dx_propagate_tag(nd, inode);
3080 @@ -418,6 +420,7 @@ const struct inode_operations ext2_dir_i
3082 .setattr = ext2_setattr,
3083 .check_acl = ext2_check_acl,
3084 + .sync_flags = ext2_sync_flags,
3087 const struct inode_operations ext2_special_inode_operations = {
3088 diff -NurpP --minimal linux-2.6.35.7/fs/ext2/super.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/super.c
3089 --- linux-2.6.35.7/fs/ext2/super.c 2010-08-02 16:52:48.000000000 +0200
3090 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext2/super.c 2010-08-02 17:05:05.000000000 +0200
3091 @@ -390,7 +390,8 @@ enum {
3092 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3093 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3094 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3095 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
3096 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
3097 + Opt_tag, Opt_notag, Opt_tagid
3100 static const match_table_t tokens = {
3101 @@ -418,6 +419,9 @@ static const match_table_t tokens = {
3103 {Opt_noacl, "noacl"},
3106 + {Opt_notag, "notag"},
3107 + {Opt_tagid, "tagid=%u"},
3108 {Opt_grpquota, "grpquota"},
3109 {Opt_ignore, "noquota"},
3110 {Opt_quota, "quota"},
3111 @@ -488,6 +492,20 @@ static int parse_options(char *options,
3113 set_opt (sbi->s_mount_opt, NO_UID32);
3115 +#ifndef CONFIG_TAGGING_NONE
3117 + set_opt (sbi->s_mount_opt, TAGGED);
3120 + clear_opt (sbi->s_mount_opt, TAGGED);
3123 +#ifdef CONFIG_PROPAGATE
3126 + set_opt (sbi->s_mount_opt, TAGGED);
3130 clear_opt (sbi->s_mount_opt, CHECK);
3132 @@ -845,6 +863,8 @@ static int ext2_fill_super(struct super_
3133 if (!parse_options((char *) data, sb))
3136 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3137 + sb->s_flags |= MS_TAGGED;
3138 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3139 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3141 @@ -1217,6 +1237,14 @@ static int ext2_remount (struct super_bl
3145 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3146 + !(sb->s_flags & MS_TAGGED)) {
3147 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3150 + goto restore_opts;
3153 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3154 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3156 diff -NurpP --minimal linux-2.6.35.7/fs/ext3/file.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext3/file.c
3157 --- linux-2.6.35.7/fs/ext3/file.c 2010-07-07 18:31:51.000000000 +0200
3158 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext3/file.c 2010-08-02 17:05:05.000000000 +0200
3159 @@ -81,5 +81,6 @@ const struct inode_operations ext3_file_
3161 .check_acl = ext3_check_acl,
3162 .fiemap = ext3_fiemap,
3163 + .sync_flags = ext3_sync_flags,
3166 diff -NurpP --minimal linux-2.6.35.7/fs/ext3/ialloc.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext3/ialloc.c
3167 --- linux-2.6.35.7/fs/ext3/ialloc.c 2010-08-02 16:52:48.000000000 +0200
3168 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext3/ialloc.c 2010-08-02 18:14:48.000000000 +0200
3170 #include <linux/buffer_head.h>
3171 #include <linux/random.h>
3172 #include <linux/bitops.h>
3173 +#include <linux/vs_tag.h>
3175 #include <asm/byteorder.h>
3177 @@ -543,6 +544,7 @@ got:
3178 inode->i_mode = mode;
3179 inode->i_uid = current_fsuid();
3180 inode->i_gid = dir->i_gid;
3181 + inode->i_tag = dx_current_fstag(sb);
3183 inode_init_owner(inode, dir, mode);
3185 diff -NurpP --minimal linux-2.6.35.7/fs/ext3/inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext3/inode.c
3186 --- linux-2.6.35.7/fs/ext3/inode.c 2010-08-02 16:52:48.000000000 +0200
3187 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext3/inode.c 2010-08-02 17:05:05.000000000 +0200
3189 #include <linux/bio.h>
3190 #include <linux/fiemap.h>
3191 #include <linux/namei.h>
3192 +#include <linux/vs_tag.h>
3196 @@ -2354,7 +2355,7 @@ static void ext3_free_branches(handle_t
3198 int ext3_can_truncate(struct inode *inode)
3200 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3201 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3203 if (S_ISREG(inode->i_mode))
3205 @@ -2739,36 +2740,60 @@ void ext3_set_inode_flags(struct inode *
3207 unsigned int flags = EXT3_I(inode)->i_flags;
3209 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3210 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3211 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3213 + if (flags & EXT3_IMMUTABLE_FL)
3214 + inode->i_flags |= S_IMMUTABLE;
3215 + if (flags & EXT3_IXUNLINK_FL)
3216 + inode->i_flags |= S_IXUNLINK;
3218 if (flags & EXT3_SYNC_FL)
3219 inode->i_flags |= S_SYNC;
3220 if (flags & EXT3_APPEND_FL)
3221 inode->i_flags |= S_APPEND;
3222 - if (flags & EXT3_IMMUTABLE_FL)
3223 - inode->i_flags |= S_IMMUTABLE;
3224 if (flags & EXT3_NOATIME_FL)
3225 inode->i_flags |= S_NOATIME;
3226 if (flags & EXT3_DIRSYNC_FL)
3227 inode->i_flags |= S_DIRSYNC;
3229 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3231 + if (flags & EXT3_BARRIER_FL)
3232 + inode->i_vflags |= V_BARRIER;
3233 + if (flags & EXT3_COW_FL)
3234 + inode->i_vflags |= V_COW;
3237 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
3238 void ext3_get_inode_flags(struct ext3_inode_info *ei)
3240 unsigned int flags = ei->vfs_inode.i_flags;
3241 + unsigned int vflags = ei->vfs_inode.i_vflags;
3243 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
3244 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
3245 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
3246 + EXT3_BARRIER_FL | EXT3_COW_FL);
3248 + if (flags & S_IMMUTABLE)
3249 + ei->i_flags |= EXT3_IMMUTABLE_FL;
3250 + if (flags & S_IXUNLINK)
3251 + ei->i_flags |= EXT3_IXUNLINK_FL;
3253 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
3254 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
3256 ei->i_flags |= EXT3_SYNC_FL;
3257 if (flags & S_APPEND)
3258 ei->i_flags |= EXT3_APPEND_FL;
3259 - if (flags & S_IMMUTABLE)
3260 - ei->i_flags |= EXT3_IMMUTABLE_FL;
3261 if (flags & S_NOATIME)
3262 ei->i_flags |= EXT3_NOATIME_FL;
3263 if (flags & S_DIRSYNC)
3264 ei->i_flags |= EXT3_DIRSYNC_FL;
3266 + if (vflags & V_BARRIER)
3267 + ei->i_flags |= EXT3_BARRIER_FL;
3268 + if (vflags & V_COW)
3269 + ei->i_flags |= EXT3_COW_FL;
3272 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3273 @@ -2782,6 +2807,8 @@ struct inode *ext3_iget(struct super_blo
3274 transaction_t *transaction;
3280 inode = iget_locked(sb, ino);
3282 @@ -2798,12 +2825,17 @@ struct inode *ext3_iget(struct super_blo
3284 raw_inode = ext3_raw_inode(&iloc);
3285 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3286 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3287 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3288 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3289 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3290 if(!(test_opt (inode->i_sb, NO_UID32))) {
3291 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3292 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3293 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3294 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3296 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3297 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3298 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3299 + le16_to_cpu(raw_inode->i_raw_tag));
3301 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3302 inode->i_size = le32_to_cpu(raw_inode->i_size);
3303 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3304 @@ -2958,6 +2990,8 @@ static int ext3_do_update_inode(handle_t
3305 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3306 struct ext3_inode_info *ei = EXT3_I(inode);
3307 struct buffer_head *bh = iloc->bh;
3308 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3309 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3310 int err = 0, rc, block;
3313 @@ -2972,29 +3006,32 @@ again:
3314 ext3_get_inode_flags(ei);
3315 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3316 if(!(test_opt(inode->i_sb, NO_UID32))) {
3317 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3318 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3319 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3320 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3322 * Fix up interoperability with old kernels. Otherwise, old inodes get
3323 * re-used with the upper 16 bits of the uid/gid intact
3326 raw_inode->i_uid_high =
3327 - cpu_to_le16(high_16_bits(inode->i_uid));
3328 + cpu_to_le16(high_16_bits(uid));
3329 raw_inode->i_gid_high =
3330 - cpu_to_le16(high_16_bits(inode->i_gid));
3331 + cpu_to_le16(high_16_bits(gid));
3333 raw_inode->i_uid_high = 0;
3334 raw_inode->i_gid_high = 0;
3337 raw_inode->i_uid_low =
3338 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3339 + cpu_to_le16(fs_high2lowuid(uid));
3340 raw_inode->i_gid_low =
3341 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3342 + cpu_to_le16(fs_high2lowgid(gid));
3343 raw_inode->i_uid_high = 0;
3344 raw_inode->i_gid_high = 0;
3346 +#ifdef CONFIG_TAGGING_INTERN
3347 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3349 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3350 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3351 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3352 @@ -3154,7 +3191,8 @@ int ext3_setattr(struct dentry *dentry,
3353 if (is_quota_modification(inode, attr))
3354 dquot_initialize(inode);
3355 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3356 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3357 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3358 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3361 /* (user+group)*(old+new) structure, inode write (sb,
3362 @@ -3176,6 +3214,8 @@ int ext3_setattr(struct dentry *dentry,
3363 inode->i_uid = attr->ia_uid;
3364 if (attr->ia_valid & ATTR_GID)
3365 inode->i_gid = attr->ia_gid;
3366 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3367 + inode->i_tag = attr->ia_tag;
3368 error = ext3_mark_inode_dirty(handle, inode);
3369 ext3_journal_stop(handle);
3371 diff -NurpP --minimal linux-2.6.35.7/fs/ext3/ioctl.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext3/ioctl.c
3372 --- linux-2.6.35.7/fs/ext3/ioctl.c 2009-06-11 17:13:03.000000000 +0200
3373 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext3/ioctl.c 2010-08-02 17:05:05.000000000 +0200
3377 #include <linux/fs.h>
3378 +#include <linux/mount.h>
3379 #include <linux/jbd.h>
3380 #include <linux/capability.h>
3381 #include <linux/ext3_fs.h>
3383 #include <linux/compat.h>
3384 #include <asm/uaccess.h>
3387 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
3389 + handle_t *handle = NULL;
3390 + struct ext3_iloc iloc;
3393 + handle = ext3_journal_start(inode, 1);
3394 + if (IS_ERR(handle))
3395 + return PTR_ERR(handle);
3397 + if (IS_SYNC(inode))
3398 + handle->h_sync = 1;
3399 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3403 + inode->i_flags = flags;
3404 + inode->i_vflags = vflags;
3405 + ext3_get_inode_flags(EXT3_I(inode));
3406 + inode->i_ctime = CURRENT_TIME_SEC;
3408 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3410 + ext3_journal_stop(handle);
3414 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3416 struct inode *inode = filp->f_dentry->d_inode;
3417 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
3419 flags = ext3_mask_flags(inode->i_mode, flags);
3421 + if (IS_BARRIER(inode)) {
3422 + vxwprintk_task(1, "messing with the barrier.");
3426 mutex_lock(&inode->i_mutex);
3428 /* Is it quota file? Do not allow user to mess with it */
3429 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3431 * This test looks nicer. Thanks to Pauline Middelink
3433 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3434 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3435 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3436 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3437 if (!capable(CAP_LINUX_IMMUTABLE))
3440 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3444 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3445 + flags &= EXT3_FL_USER_MODIFIABLE;
3446 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3447 ei->i_flags = flags;
3449 diff -NurpP --minimal linux-2.6.35.7/fs/ext3/namei.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext3/namei.c
3450 --- linux-2.6.35.7/fs/ext3/namei.c 2010-07-07 18:31:51.000000000 +0200
3451 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext3/namei.c 2010-08-02 17:05:05.000000000 +0200
3453 #include <linux/quotaops.h>
3454 #include <linux/buffer_head.h>
3455 #include <linux/bio.h>
3456 +#include <linux/vs_tag.h>
3460 @@ -912,6 +913,7 @@ restart:
3462 ll_rw_block(READ_META, 1, &bh);
3464 + dx_propagate_tag(nd, inode);
3466 if ((bh = bh_use[ra_ptr++]) == NULL)
3468 @@ -2466,6 +2468,7 @@ const struct inode_operations ext3_dir_i
3469 .removexattr = generic_removexattr,
3471 .check_acl = ext3_check_acl,
3472 + .sync_flags = ext3_sync_flags,
3475 const struct inode_operations ext3_special_inode_operations = {
3476 diff -NurpP --minimal linux-2.6.35.7/fs/ext3/super.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext3/super.c
3477 --- linux-2.6.35.7/fs/ext3/super.c 2010-08-02 16:52:48.000000000 +0200
3478 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext3/super.c 2010-08-02 18:14:19.000000000 +0200
3479 @@ -817,7 +817,8 @@ enum {
3480 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3481 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
3482 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
3483 - Opt_resize, Opt_usrquota, Opt_grpquota
3484 + Opt_resize, Opt_usrquota, Opt_grpquota,
3485 + Opt_tag, Opt_notag, Opt_tagid
3488 static const match_table_t tokens = {
3489 @@ -874,6 +875,9 @@ static const match_table_t tokens = {
3490 {Opt_barrier, "barrier"},
3491 {Opt_nobarrier, "nobarrier"},
3492 {Opt_resize, "resize"},
3494 + {Opt_notag, "notag"},
3495 + {Opt_tagid, "tagid=%u"},
3499 @@ -1026,6 +1030,20 @@ static int parse_options (char *options,
3501 set_opt (sbi->s_mount_opt, NO_UID32);
3503 +#ifndef CONFIG_TAGGING_NONE
3505 + set_opt (sbi->s_mount_opt, TAGGED);
3508 + clear_opt (sbi->s_mount_opt, TAGGED);
3511 +#ifdef CONFIG_PROPAGATE
3514 + set_opt (sbi->s_mount_opt, TAGGED);
3518 clear_opt (sbi->s_mount_opt, CHECK);
3520 @@ -1712,6 +1730,9 @@ static int ext3_fill_super (struct super
3524 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3525 + sb->s_flags |= MS_TAGGED;
3527 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3528 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3530 @@ -2585,6 +2606,14 @@ static int ext3_remount (struct super_bl
3531 if (test_opt(sb, ABORT))
3532 ext3_abort(sb, __func__, "Abort forced by user");
3534 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3535 + !(sb->s_flags & MS_TAGGED)) {
3536 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3539 + goto restore_opts;
3542 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3543 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3545 diff -NurpP --minimal linux-2.6.35.7/fs/ext4/ext4.h linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/ext4.h
3546 --- linux-2.6.35.7/fs/ext4/ext4.h 2010-10-04 08:57:38.000000000 +0200
3547 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/ext4.h 2010-09-22 02:52:29.000000000 +0200
3548 @@ -320,8 +320,12 @@ struct flex_groups {
3549 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3550 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
3551 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
3552 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3553 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3555 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3556 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3558 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3559 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3561 @@ -590,7 +594,8 @@ struct ext4_inode {
3562 __le16 l_i_file_acl_high;
3563 __le16 l_i_uid_high; /* these 2 fields */
3564 __le16 l_i_gid_high; /* were reserved2[0] */
3565 - __u32 l_i_reserved2;
3566 + __le16 l_i_tag; /* Context Tag */
3567 + __u16 l_i_reserved2;
3570 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3571 @@ -704,6 +709,7 @@ do { \
3572 #define i_gid_low i_gid
3573 #define i_uid_high osd2.linux2.l_i_uid_high
3574 #define i_gid_high osd2.linux2.l_i_gid_high
3575 +#define i_raw_tag osd2.linux2.l_i_tag
3576 #define i_reserved2 osd2.linux2.l_i_reserved2
3578 #elif defined(__GNU__)
3579 @@ -883,6 +889,7 @@ struct ext4_inode_info {
3580 #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
3581 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
3582 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
3583 +#define EXT4_MOUNT_TAGGED 0x4000000 /* Enable Context Tags */
3584 #define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */
3585 #define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000 /* Abort on file data write */
3586 #define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000 /* Block validity checking */
3587 @@ -1912,6 +1919,7 @@ extern int ext4_get_blocks(handle_t *han
3588 struct buffer_head *bh, int flags);
3589 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3590 __u64 start, __u64 len);
3591 +extern int ext4_sync_flags(struct inode *, int, int);
3593 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3594 __u64 start_orig, __u64 start_donor,
3595 diff -NurpP --minimal linux-2.6.35.7/fs/ext4/file.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/file.c
3596 --- linux-2.6.35.7/fs/ext4/file.c 2010-08-02 16:52:48.000000000 +0200
3597 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/file.c 2010-08-02 17:05:05.000000000 +0200
3598 @@ -160,5 +160,6 @@ const struct inode_operations ext4_file_
3599 .check_acl = ext4_check_acl,
3600 .fallocate = ext4_fallocate,
3601 .fiemap = ext4_fiemap,
3602 + .sync_flags = ext4_sync_flags,
3605 diff -NurpP --minimal linux-2.6.35.7/fs/ext4/ialloc.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/ialloc.c
3606 --- linux-2.6.35.7/fs/ext4/ialloc.c 2010-08-02 16:52:48.000000000 +0200
3607 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/ialloc.c 2010-08-02 18:12:48.000000000 +0200
3609 #include <linux/random.h>
3610 #include <linux/bitops.h>
3611 #include <linux/blkdev.h>
3612 +#include <linux/vs_tag.h>
3613 #include <asm/byteorder.h>
3616 @@ -976,6 +977,7 @@ got:
3617 inode->i_mode = mode;
3618 inode->i_uid = current_fsuid();
3619 inode->i_gid = dir->i_gid;
3620 + inode->i_tag = dx_current_fstag(sb);
3622 inode_init_owner(inode, dir, mode);
3624 diff -NurpP --minimal linux-2.6.35.7/fs/ext4/inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/inode.c
3625 --- linux-2.6.35.7/fs/ext4/inode.c 2010-10-04 08:57:38.000000000 +0200
3626 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/inode.c 2010-09-22 02:52:29.000000000 +0200
3628 #include <linux/workqueue.h>
3629 #include <linux/kernel.h>
3630 #include <linux/slab.h>
3631 +#include <linux/vs_tag.h>
3633 #include "ext4_jbd2.h"
3635 @@ -4586,7 +4587,7 @@ static void ext4_free_branches(handle_t
3637 int ext4_can_truncate(struct inode *inode)
3639 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3640 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3642 if (S_ISREG(inode->i_mode))
3644 @@ -4937,41 +4938,64 @@ void ext4_set_inode_flags(struct inode *
3646 unsigned int flags = EXT4_I(inode)->i_flags;
3648 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3649 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3650 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3652 + if (flags & EXT4_IMMUTABLE_FL)
3653 + inode->i_flags |= S_IMMUTABLE;
3654 + if (flags & EXT4_IXUNLINK_FL)
3655 + inode->i_flags |= S_IXUNLINK;
3657 if (flags & EXT4_SYNC_FL)
3658 inode->i_flags |= S_SYNC;
3659 if (flags & EXT4_APPEND_FL)
3660 inode->i_flags |= S_APPEND;
3661 - if (flags & EXT4_IMMUTABLE_FL)
3662 - inode->i_flags |= S_IMMUTABLE;
3663 if (flags & EXT4_NOATIME_FL)
3664 inode->i_flags |= S_NOATIME;
3665 if (flags & EXT4_DIRSYNC_FL)
3666 inode->i_flags |= S_DIRSYNC;
3668 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3670 + if (flags & EXT4_BARRIER_FL)
3671 + inode->i_vflags |= V_BARRIER;
3672 + if (flags & EXT4_COW_FL)
3673 + inode->i_vflags |= V_COW;
3676 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3677 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3679 - unsigned int vfs_fl;
3680 + unsigned int vfs_fl, vfs_vf;
3681 unsigned long old_fl, new_fl;
3684 vfs_fl = ei->vfs_inode.i_flags;
3685 + vfs_vf = ei->vfs_inode.i_vflags;
3686 old_fl = ei->i_flags;
3687 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3688 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3690 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3693 + if (vfs_fl & S_IMMUTABLE)
3694 + new_fl |= EXT4_IMMUTABLE_FL;
3695 + if (vfs_fl & S_IXUNLINK)
3696 + new_fl |= EXT4_IXUNLINK_FL;
3698 if (vfs_fl & S_SYNC)
3699 new_fl |= EXT4_SYNC_FL;
3700 if (vfs_fl & S_APPEND)
3701 new_fl |= EXT4_APPEND_FL;
3702 - if (vfs_fl & S_IMMUTABLE)
3703 - new_fl |= EXT4_IMMUTABLE_FL;
3704 if (vfs_fl & S_NOATIME)
3705 new_fl |= EXT4_NOATIME_FL;
3706 if (vfs_fl & S_DIRSYNC)
3707 new_fl |= EXT4_DIRSYNC_FL;
3709 + if (vfs_vf & V_BARRIER)
3710 + new_fl |= EXT4_BARRIER_FL;
3711 + if (vfs_vf & V_COW)
3712 + new_fl |= EXT4_COW_FL;
3713 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3716 @@ -5007,6 +5031,8 @@ struct inode *ext4_iget(struct super_blo
3717 journal_t *journal = EXT4_SB(sb)->s_journal;
3723 inode = iget_locked(sb, ino);
3725 @@ -5022,12 +5048,16 @@ struct inode *ext4_iget(struct super_blo
3727 raw_inode = ext4_raw_inode(&iloc);
3728 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3729 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3730 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3731 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3732 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3733 if (!(test_opt(inode->i_sb, NO_UID32))) {
3734 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3735 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3736 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3737 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3739 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3740 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3741 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3742 + le16_to_cpu(raw_inode->i_raw_tag));
3743 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3745 ei->i_state_flags = 0;
3746 @@ -5246,6 +5276,8 @@ static int ext4_do_update_inode(handle_t
3747 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3748 struct ext4_inode_info *ei = EXT4_I(inode);
3749 struct buffer_head *bh = iloc->bh;
3750 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3751 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3752 int err = 0, rc, block;
3754 /* For fields not not tracking in the in-memory inode,
3755 @@ -5256,29 +5288,32 @@ static int ext4_do_update_inode(handle_t
3756 ext4_get_inode_flags(ei);
3757 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3758 if (!(test_opt(inode->i_sb, NO_UID32))) {
3759 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3760 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3761 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3762 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3764 * Fix up interoperability with old kernels. Otherwise, old inodes get
3765 * re-used with the upper 16 bits of the uid/gid intact
3768 raw_inode->i_uid_high =
3769 - cpu_to_le16(high_16_bits(inode->i_uid));
3770 + cpu_to_le16(high_16_bits(uid));
3771 raw_inode->i_gid_high =
3772 - cpu_to_le16(high_16_bits(inode->i_gid));
3773 + cpu_to_le16(high_16_bits(gid));
3775 raw_inode->i_uid_high = 0;
3776 raw_inode->i_gid_high = 0;
3779 raw_inode->i_uid_low =
3780 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3781 + cpu_to_le16(fs_high2lowuid(uid));
3782 raw_inode->i_gid_low =
3783 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3784 + cpu_to_le16(fs_high2lowgid(gid));
3785 raw_inode->i_uid_high = 0;
3786 raw_inode->i_gid_high = 0;
3788 +#ifdef CONFIG_TAGGING_INTERN
3789 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3791 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3793 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3794 @@ -5464,7 +5499,8 @@ int ext4_setattr(struct dentry *dentry,
3795 if (is_quota_modification(inode, attr))
3796 dquot_initialize(inode);
3797 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3798 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3799 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3800 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3803 /* (user+group)*(old+new) structure, inode write (sb,
3804 @@ -5486,6 +5522,8 @@ int ext4_setattr(struct dentry *dentry,
3805 inode->i_uid = attr->ia_uid;
3806 if (attr->ia_valid & ATTR_GID)
3807 inode->i_gid = attr->ia_gid;
3808 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3809 + inode->i_tag = attr->ia_tag;
3810 error = ext4_mark_inode_dirty(handle, inode);
3811 ext4_journal_stop(handle);
3813 diff -NurpP --minimal linux-2.6.35.7/fs/ext4/ioctl.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/ioctl.c
3814 --- linux-2.6.35.7/fs/ext4/ioctl.c 2010-08-02 16:52:48.000000000 +0200
3815 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/ioctl.c 2010-08-02 17:05:05.000000000 +0200
3817 #include <linux/compat.h>
3818 #include <linux/mount.h>
3819 #include <linux/file.h>
3820 +#include <linux/vs_tag.h>
3821 #include <asm/uaccess.h>
3822 #include "ext4_jbd2.h"
3826 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3828 + handle_t *handle = NULL;
3829 + struct ext4_iloc iloc;
3832 + handle = ext4_journal_start(inode, 1);
3833 + if (IS_ERR(handle))
3834 + return PTR_ERR(handle);
3836 + if (IS_SYNC(inode))
3837 + ext4_handle_sync(handle);
3838 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3842 + inode->i_flags = flags;
3843 + inode->i_vflags = vflags;
3844 + ext4_get_inode_flags(EXT4_I(inode));
3845 + inode->i_ctime = ext4_current_time(inode);
3847 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3849 + ext4_journal_stop(handle);
3853 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3855 struct inode *inode = filp->f_dentry->d_inode;
3856 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3858 flags = ext4_mask_flags(inode->i_mode, flags);
3860 + if (IS_BARRIER(inode)) {
3861 + vxwprintk_task(1, "messing with the barrier.");
3866 mutex_lock(&inode->i_mutex);
3867 /* Is it quota file? Do not allow user to mess with it */
3868 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3870 * This test looks nicer. Thanks to Pauline Middelink
3872 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3873 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3874 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3875 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3876 if (!capable(CAP_LINUX_IMMUTABLE))
3879 diff -NurpP --minimal linux-2.6.35.7/fs/ext4/namei.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/namei.c
3880 --- linux-2.6.35.7/fs/ext4/namei.c 2010-08-02 16:52:48.000000000 +0200
3881 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/namei.c 2010-08-02 17:05:05.000000000 +0200
3883 #include <linux/quotaops.h>
3884 #include <linux/buffer_head.h>
3885 #include <linux/bio.h>
3886 +#include <linux/vs_tag.h>
3888 #include "ext4_jbd2.h"
3890 @@ -937,6 +938,7 @@ restart:
3892 ll_rw_block(READ_META, 1, &bh);
3894 + dx_propagate_tag(nd, inode);
3896 if ((bh = bh_use[ra_ptr++]) == NULL)
3898 @@ -2550,6 +2552,7 @@ const struct inode_operations ext4_dir_i
3900 .check_acl = ext4_check_acl,
3901 .fiemap = ext4_fiemap,
3902 + .sync_flags = ext4_sync_flags,
3905 const struct inode_operations ext4_special_inode_operations = {
3906 diff -NurpP --minimal linux-2.6.35.7/fs/ext4/super.c linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/super.c
3907 --- linux-2.6.35.7/fs/ext4/super.c 2010-10-04 08:57:38.000000000 +0200
3908 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ext4/super.c 2010-08-14 18:19:32.000000000 +0200
3909 @@ -1161,6 +1161,7 @@ enum {
3910 Opt_inode_readahead_blks, Opt_journal_ioprio,
3911 Opt_dioread_nolock, Opt_dioread_lock,
3912 Opt_discard, Opt_nodiscard,
3913 + Opt_tag, Opt_notag, Opt_tagid
3916 static const match_table_t tokens = {
3917 @@ -1231,6 +1232,9 @@ static const match_table_t tokens = {
3918 {Opt_dioread_lock, "dioread_lock"},
3919 {Opt_discard, "discard"},
3920 {Opt_nodiscard, "nodiscard"},
3922 + {Opt_notag, "notag"},
3923 + {Opt_tagid, "tagid=%u"},
3927 @@ -1399,6 +1403,20 @@ static int parse_options(char *options,
3929 set_opt(sbi->s_mount_opt, NO_UID32);
3931 +#ifndef CONFIG_TAGGING_NONE
3933 + set_opt (sbi->s_mount_opt, TAGGED);
3936 + clear_opt (sbi->s_mount_opt, TAGGED);
3939 +#ifdef CONFIG_PROPAGATE
3942 + set_opt (sbi->s_mount_opt, TAGGED);
3946 set_opt(sbi->s_mount_opt, DEBUG);
3948 @@ -2566,6 +2584,9 @@ static int ext4_fill_super(struct super_
3949 &journal_ioprio, NULL, 0))
3952 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3953 + sb->s_flags |= MS_TAGGED;
3955 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3956 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3958 @@ -3618,6 +3639,14 @@ static int ext4_remount(struct super_blo
3959 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3960 ext4_abort(sb, __func__, "Abort forced by user");
3962 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3963 + !(sb->s_flags & MS_TAGGED)) {
3964 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3967 + goto restore_opts;
3970 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3971 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3973 diff -NurpP --minimal linux-2.6.35.7/fs/fcntl.c linux-2.6.35.7-vs2.3.0.36.33/fs/fcntl.c
3974 --- linux-2.6.35.7/fs/fcntl.c 2010-08-02 16:52:49.000000000 +0200
3975 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/fcntl.c 2010-08-02 17:05:06.000000000 +0200
3977 #include <linux/signal.h>
3978 #include <linux/rcupdate.h>
3979 #include <linux/pid_namespace.h>
3980 +#include <linux/vs_limit.h>
3982 #include <asm/poll.h>
3983 #include <asm/siginfo.h>
3984 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3987 filp_close(tofree, files);
3989 + vx_openfd_inc(newfd); /* fd was unused */
3993 @@ -434,6 +437,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3997 + if (!vx_files_avail(1))
4000 err = security_file_fcntl(filp, cmd, arg);
4002 diff -NurpP --minimal linux-2.6.35.7/fs/file.c linux-2.6.35.7-vs2.3.0.36.33/fs/file.c
4003 --- linux-2.6.35.7/fs/file.c 2010-07-07 18:31:51.000000000 +0200
4004 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/file.c 2010-08-02 17:05:06.000000000 +0200
4006 #include <linux/spinlock.h>
4007 #include <linux/rcupdate.h>
4008 #include <linux/workqueue.h>
4009 +#include <linux/vs_limit.h>
4011 struct fdtable_defer {
4013 @@ -368,6 +369,8 @@ struct files_struct *dup_fd(struct files
4014 struct file *f = *old_fds++;
4017 + /* TODO: sum it first for check and performance */
4018 + vx_openfd_inc(open_files - i);
4021 * The fd may be claimed in the fd bitmap but not yet
4022 @@ -476,6 +479,7 @@ repeat:
4024 FD_CLR(fd, fdt->close_on_exec);
4026 + vx_openfd_inc(fd);
4029 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
4030 diff -NurpP --minimal linux-2.6.35.7/fs/file_table.c linux-2.6.35.7-vs2.3.0.36.33/fs/file_table.c
4031 --- linux-2.6.35.7/fs/file_table.c 2010-08-02 16:52:49.000000000 +0200
4032 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/file_table.c 2010-08-02 17:05:06.000000000 +0200
4034 #include <linux/sysctl.h>
4035 #include <linux/percpu_counter.h>
4036 #include <linux/ima.h>
4037 +#include <linux/vs_limit.h>
4038 +#include <linux/vs_context.h>
4040 #include <asm/atomic.h>
4042 @@ -133,6 +135,8 @@ struct file *get_empty_filp(void)
4043 spin_lock_init(&f->f_lock);
4044 eventpoll_init_file(f);
4045 /* f->f_version: 0 */
4046 + f->f_xid = vx_current_xid();
4051 @@ -249,6 +253,8 @@ static void __fput(struct file *file)
4052 cdev_put(inode->i_cdev);
4053 fops_put(file->f_op);
4054 put_pid(file->f_owner.pid);
4055 + vx_files_dec(file);
4058 if (file->f_mode & FMODE_WRITE)
4059 drop_file_write_access(file);
4060 @@ -324,6 +330,8 @@ void put_filp(struct file *file)
4062 if (atomic_long_dec_and_test(&file->f_count)) {
4063 security_file_free(file);
4064 + vx_files_dec(file);
4069 diff -NurpP --minimal linux-2.6.35.7/fs/fs_struct.c linux-2.6.35.7-vs2.3.0.36.33/fs/fs_struct.c
4070 --- linux-2.6.35.7/fs/fs_struct.c 2009-06-11 17:13:04.000000000 +0200
4071 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/fs_struct.c 2010-08-02 17:05:06.000000000 +0200
4073 #include <linux/path.h>
4074 #include <linux/slab.h>
4075 #include <linux/fs_struct.h>
4076 +#include <linux/vserver/global.h>
4079 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
4080 @@ -77,6 +78,7 @@ void free_fs_struct(struct fs_struct *fs
4082 path_put(&fs->root);
4084 + atomic_dec(&vs_global_fs);
4085 kmem_cache_free(fs_cachep, fs);
4088 @@ -112,6 +114,7 @@ struct fs_struct *copy_fs_struct(struct
4090 path_get(&old->pwd);
4091 read_unlock(&old->lock);
4092 + atomic_inc(&vs_global_fs);
4096 diff -NurpP --minimal linux-2.6.35.7/fs/gfs2/file.c linux-2.6.35.7-vs2.3.0.36.33/fs/gfs2/file.c
4097 --- linux-2.6.35.7/fs/gfs2/file.c 2010-08-02 16:52:49.000000000 +0200
4098 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/gfs2/file.c 2010-08-02 17:05:06.000000000 +0200
4099 @@ -132,6 +132,9 @@ static const u32 fsflags_to_gfs2[32] = {
4100 [7] = GFS2_DIF_NOATIME,
4101 [12] = GFS2_DIF_EXHASH,
4102 [14] = GFS2_DIF_INHERIT_JDATA,
4103 + [27] = GFS2_DIF_IXUNLINK,
4104 + [26] = GFS2_DIF_BARRIER,
4105 + [29] = GFS2_DIF_COW,
4108 static const u32 gfs2_to_fsflags[32] = {
4109 @@ -141,6 +144,9 @@ static const u32 gfs2_to_fsflags[32] = {
4110 [gfs2fl_NoAtime] = FS_NOATIME_FL,
4111 [gfs2fl_ExHash] = FS_INDEX_FL,
4112 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
4113 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
4114 + [gfs2fl_Barrier] = FS_BARRIER_FL,
4115 + [gfs2fl_Cow] = FS_COW_FL,
4118 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
4119 @@ -171,10 +177,16 @@ void gfs2_set_inode_flags(struct inode *
4121 struct gfs2_inode *ip = GFS2_I(inode);
4122 unsigned int flags = inode->i_flags;
4123 + unsigned int vflags = inode->i_vflags;
4125 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4126 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4128 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4129 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
4130 flags |= S_IMMUTABLE;
4131 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
4132 + flags |= S_IXUNLINK;
4134 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
4136 if (ip->i_diskflags & GFS2_DIF_NOATIME)
4137 @@ -182,6 +194,43 @@ void gfs2_set_inode_flags(struct inode *
4138 if (ip->i_diskflags & GFS2_DIF_SYNC)
4140 inode->i_flags = flags;
4142 + vflags &= ~(V_BARRIER | V_COW);
4144 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
4145 + vflags |= V_BARRIER;
4146 + if (ip->i_diskflags & GFS2_DIF_COW)
4148 + inode->i_vflags = vflags;
4151 +void gfs2_get_inode_flags(struct inode *inode)
4153 + struct gfs2_inode *ip = GFS2_I(inode);
4154 + unsigned int flags = inode->i_flags;
4155 + unsigned int vflags = inode->i_vflags;
4157 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
4158 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
4159 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
4160 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
4162 + if (flags & S_IMMUTABLE)
4163 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
4164 + if (flags & S_IXUNLINK)
4165 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
4167 + if (flags & S_APPEND)
4168 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
4169 + if (flags & S_NOATIME)
4170 + ip->i_diskflags |= GFS2_DIF_NOATIME;
4171 + if (flags & S_SYNC)
4172 + ip->i_diskflags |= GFS2_DIF_SYNC;
4174 + if (vflags & V_BARRIER)
4175 + ip->i_diskflags |= GFS2_DIF_BARRIER;
4176 + if (vflags & V_COW)
4177 + ip->i_diskflags |= GFS2_DIF_COW;
4180 /* Flags that can be set by user space */
4181 @@ -293,6 +342,37 @@ static int gfs2_set_flags(struct file *f
4182 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
4185 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
4187 + struct gfs2_inode *ip = GFS2_I(inode);
4188 + struct gfs2_sbd *sdp = GFS2_SB(inode);
4189 + struct buffer_head *bh;
4190 + struct gfs2_holder gh;
4193 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
4196 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
4199 + error = gfs2_meta_inode_buffer(ip, &bh);
4201 + goto out_trans_end;
4202 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
4203 + inode->i_flags = flags;
4204 + inode->i_vflags = vflags;
4205 + gfs2_get_inode_flags(inode);
4206 + gfs2_dinode_out(ip, bh->b_data);
4208 + gfs2_set_aops(inode);
4210 + gfs2_trans_end(sdp);
4212 + gfs2_glock_dq_uninit(&gh);
4216 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4219 diff -NurpP --minimal linux-2.6.35.7/fs/gfs2/inode.h linux-2.6.35.7-vs2.3.0.36.33/fs/gfs2/inode.h
4220 --- linux-2.6.35.7/fs/gfs2/inode.h 2010-08-02 16:52:49.000000000 +0200
4221 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/gfs2/inode.h 2010-08-02 17:05:06.000000000 +0200
4222 @@ -109,6 +109,7 @@ extern const struct file_operations gfs2
4223 extern const struct file_operations gfs2_dir_fops_nolock;
4225 extern void gfs2_set_inode_flags(struct inode *inode);
4226 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
4228 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
4229 extern const struct file_operations gfs2_file_fops;
4230 diff -NurpP --minimal linux-2.6.35.7/fs/gfs2/ops_inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/gfs2/ops_inode.c
4231 --- linux-2.6.35.7/fs/gfs2/ops_inode.c 2010-08-02 16:52:49.000000000 +0200
4232 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/gfs2/ops_inode.c 2010-08-02 17:05:06.000000000 +0200
4233 @@ -1346,6 +1346,7 @@ const struct inode_operations gfs2_file_
4234 .listxattr = gfs2_listxattr,
4235 .removexattr = gfs2_removexattr,
4236 .fiemap = gfs2_fiemap,
4237 + .sync_flags = gfs2_sync_flags,
4240 const struct inode_operations gfs2_dir_iops = {
4241 @@ -1366,6 +1367,7 @@ const struct inode_operations gfs2_dir_i
4242 .listxattr = gfs2_listxattr,
4243 .removexattr = gfs2_removexattr,
4244 .fiemap = gfs2_fiemap,
4245 + .sync_flags = gfs2_sync_flags,
4248 const struct inode_operations gfs2_symlink_iops = {
4249 diff -NurpP --minimal linux-2.6.35.7/fs/hfsplus/ioctl.c linux-2.6.35.7-vs2.3.0.36.33/fs/hfsplus/ioctl.c
4250 --- linux-2.6.35.7/fs/hfsplus/ioctl.c 2010-08-02 16:52:49.000000000 +0200
4251 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/hfsplus/ioctl.c 2010-08-02 17:48:55.000000000 +0200
4253 #include <linux/sched.h>
4254 #include <linux/xattr.h>
4255 #include <linux/smp_lock.h>
4256 +// #include <linux/mount.h>
4257 #include <asm/uaccess.h>
4258 #include "hfsplus_fs.h"
4260 diff -NurpP --minimal linux-2.6.35.7/fs/inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/inode.c
4261 --- linux-2.6.35.7/fs/inode.c 2010-08-02 16:52:49.000000000 +0200
4262 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/inode.c 2010-08-02 19:08:57.000000000 +0200
4264 #include <linux/mount.h>
4265 #include <linux/async.h>
4266 #include <linux/posix_acl.h>
4267 +#include <linux/vs_tag.h>
4270 * This is needed for the following functions:
4271 @@ -131,6 +132,9 @@ int inode_init_always(struct super_block
4272 struct address_space *const mapping = &inode->i_data;
4276 + /* essential because of inode slab reuse */
4278 inode->i_blkbits = sb->s_blocksize_bits;
4280 atomic_set(&inode->i_count, 1);
4281 @@ -151,6 +155,7 @@ int inode_init_always(struct super_block
4282 inode->i_bdev = NULL;
4283 inode->i_cdev = NULL;
4285 + inode->i_mdev = 0;
4286 inode->dirtied_when = 0;
4288 if (security_inode_alloc(inode))
4289 @@ -294,6 +299,8 @@ void __iget(struct inode *inode)
4290 inodes_stat.nr_unused--;
4293 +EXPORT_SYMBOL_GPL(__iget);
4296 * clear_inode - clear an inode
4297 * @inode: inode to clear
4298 @@ -1593,9 +1600,11 @@ void init_special_inode(struct inode *in
4299 if (S_ISCHR(mode)) {
4300 inode->i_fop = &def_chr_fops;
4301 inode->i_rdev = rdev;
4302 + inode->i_mdev = rdev;
4303 } else if (S_ISBLK(mode)) {
4304 inode->i_fop = &def_blk_fops;
4305 inode->i_rdev = rdev;
4306 + inode->i_mdev = rdev;
4307 } else if (S_ISFIFO(mode))
4308 inode->i_fop = &def_fifo_fops;
4309 else if (S_ISSOCK(mode))
4310 @@ -1624,5 +1633,6 @@ void inode_init_owner(struct inode *inod
4312 inode->i_gid = current_fsgid();
4313 inode->i_mode = mode;
4314 + inode->i_tag = dx_current_fstag(inode->i_sb);
4316 EXPORT_SYMBOL(inode_init_owner);
4317 diff -NurpP --minimal linux-2.6.35.7/fs/ioctl.c linux-2.6.35.7-vs2.3.0.36.33/fs/ioctl.c
4318 --- linux-2.6.35.7/fs/ioctl.c 2010-08-02 16:52:49.000000000 +0200
4319 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ioctl.c 2010-08-02 17:05:06.000000000 +0200
4321 #include <linux/writeback.h>
4322 #include <linux/buffer_head.h>
4323 #include <linux/falloc.h>
4324 +#include <linux/proc_fs.h>
4325 +#include <linux/vserver/inode.h>
4326 +#include <linux/vs_tag.h>
4328 #include <asm/ioctls.h>
4330 diff -NurpP --minimal linux-2.6.35.7/fs/ioprio.c linux-2.6.35.7-vs2.3.0.36.33/fs/ioprio.c
4331 --- linux-2.6.35.7/fs/ioprio.c 2010-07-07 18:31:52.000000000 +0200
4332 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ioprio.c 2010-08-02 17:05:06.000000000 +0200
4334 #include <linux/syscalls.h>
4335 #include <linux/security.h>
4336 #include <linux/pid_namespace.h>
4337 +#include <linux/vs_base.h>
4339 int set_task_ioprio(struct task_struct *task, int ioprio)
4341 @@ -124,6 +125,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4343 pgrp = find_vpid(who);
4344 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4345 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4347 ret = set_task_ioprio(p, ioprio);
4350 @@ -213,6 +216,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
4352 pgrp = find_vpid(who);
4353 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4354 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4356 tmpio = get_task_ioprio(p);
4359 diff -NurpP --minimal linux-2.6.35.7/fs/jfs/file.c linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/file.c
4360 --- linux-2.6.35.7/fs/jfs/file.c 2010-08-02 16:52:49.000000000 +0200
4361 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/file.c 2010-08-02 17:05:06.000000000 +0200
4362 @@ -101,7 +101,8 @@ int jfs_setattr(struct dentry *dentry, s
4363 if (is_quota_modification(inode, iattr))
4364 dquot_initialize(inode);
4365 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4366 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4367 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4368 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4369 rc = dquot_transfer(inode, iattr);
4372 @@ -125,6 +126,7 @@ const struct inode_operations jfs_file_i
4373 #ifdef CONFIG_JFS_POSIX_ACL
4374 .check_acl = jfs_check_acl,
4376 + .sync_flags = jfs_sync_flags,
4379 const struct file_operations jfs_file_operations = {
4380 diff -NurpP --minimal linux-2.6.35.7/fs/jfs/ioctl.c linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/ioctl.c
4381 --- linux-2.6.35.7/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4382 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/ioctl.c 2010-08-02 17:05:06.000000000 +0200
4384 #include <linux/mount.h>
4385 #include <linux/time.h>
4386 #include <linux/sched.h>
4387 +#include <linux/mount.h>
4388 #include <asm/current.h>
4389 #include <asm/uaccess.h>
4391 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
4395 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
4397 + inode->i_flags = flags;
4398 + inode->i_vflags = vflags;
4399 + jfs_get_inode_flags(JFS_IP(inode));
4400 + inode->i_ctime = CURRENT_TIME_SEC;
4401 + mark_inode_dirty(inode);
4405 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4407 struct inode *inode = filp->f_dentry->d_inode;
4408 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
4409 if (!S_ISDIR(inode->i_mode))
4410 flags &= ~JFS_DIRSYNC_FL;
4412 + if (IS_BARRIER(inode)) {
4413 + vxwprintk_task(1, "messing with the barrier.");
4417 /* Is it quota file? Do not allow user to mess with it */
4418 if (IS_NOQUOTA(inode)) {
4420 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
4421 * the relevant capability.
4423 if ((oldflags & JFS_IMMUTABLE_FL) ||
4424 - ((flags ^ oldflags) &
4425 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4426 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4427 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4428 if (!capable(CAP_LINUX_IMMUTABLE)) {
4429 mutex_unlock(&inode->i_mutex);
4431 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
4435 - flags = flags & JFS_FL_USER_MODIFIABLE;
4436 + flags &= JFS_FL_USER_MODIFIABLE;
4437 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
4438 jfs_inode->mode2 = flags;
4440 diff -NurpP --minimal linux-2.6.35.7/fs/jfs/jfs_dinode.h linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/jfs_dinode.h
4441 --- linux-2.6.35.7/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
4442 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/jfs_dinode.h 2010-08-02 17:05:06.000000000 +0200
4443 @@ -161,9 +161,13 @@ struct dinode {
4445 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4446 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4447 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4449 -#define JFS_FL_USER_VISIBLE 0x03F80000
4450 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4451 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4452 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4454 +#define JFS_FL_USER_VISIBLE 0x07F80000
4455 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4456 #define JFS_FL_INHERIT 0x03C80000
4458 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4459 diff -NurpP --minimal linux-2.6.35.7/fs/jfs/jfs_filsys.h linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/jfs_filsys.h
4460 --- linux-2.6.35.7/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4461 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/jfs_filsys.h 2010-08-02 17:05:06.000000000 +0200
4463 #define JFS_NAME_MAX 255
4464 #define JFS_PATH_MAX BPSIZE
4466 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4469 * file system state (superblock state)
4470 diff -NurpP --minimal linux-2.6.35.7/fs/jfs/jfs_imap.c linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/jfs_imap.c
4471 --- linux-2.6.35.7/fs/jfs/jfs_imap.c 2010-07-07 18:31:52.000000000 +0200
4472 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/jfs_imap.c 2010-08-02 17:05:06.000000000 +0200
4474 #include <linux/pagemap.h>
4475 #include <linux/quotaops.h>
4476 #include <linux/slab.h>
4477 +#include <linux/vs_tag.h>
4479 #include "jfs_incore.h"
4480 #include "jfs_inode.h"
4481 @@ -3060,6 +3061,8 @@ static int copy_from_dinode(struct dinod
4483 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4484 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4488 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4489 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4490 @@ -3080,14 +3083,18 @@ static int copy_from_dinode(struct dinod
4492 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4494 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4495 + uid = le32_to_cpu(dip->di_uid);
4496 + gid = le32_to_cpu(dip->di_gid);
4497 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4499 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4501 ip->i_uid = jfs_ip->saved_uid;
4503 ip->i_uid = sbi->uid;
4506 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4507 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4509 ip->i_gid = jfs_ip->saved_gid;
4511 @@ -3152,14 +3159,12 @@ static void copy_to_dinode(struct dinode
4512 dip->di_size = cpu_to_le64(ip->i_size);
4513 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4514 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4515 - if (sbi->uid == -1)
4516 - dip->di_uid = cpu_to_le32(ip->i_uid);
4518 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4519 - if (sbi->gid == -1)
4520 - dip->di_gid = cpu_to_le32(ip->i_gid);
4522 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4524 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4525 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4526 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4527 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4529 jfs_get_inode_flags(jfs_ip);
4531 * mode2 is only needed for storing the higher order bits.
4532 diff -NurpP --minimal linux-2.6.35.7/fs/jfs/jfs_inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/jfs_inode.c
4533 --- linux-2.6.35.7/fs/jfs/jfs_inode.c 2010-08-02 16:52:49.000000000 +0200
4534 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/jfs_inode.c 2010-08-02 17:05:06.000000000 +0200
4537 #include <linux/fs.h>
4538 #include <linux/quotaops.h>
4539 +#include <linux/vs_tag.h>
4540 #include "jfs_incore.h"
4541 #include "jfs_inode.h"
4542 #include "jfs_filsys.h"
4543 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4545 unsigned int flags = JFS_IP(inode)->mode2;
4547 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4548 - S_NOATIME | S_DIRSYNC | S_SYNC);
4549 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4550 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4552 if (flags & JFS_IMMUTABLE_FL)
4553 inode->i_flags |= S_IMMUTABLE;
4554 + if (flags & JFS_IXUNLINK_FL)
4555 + inode->i_flags |= S_IXUNLINK;
4557 + if (flags & JFS_SYNC_FL)
4558 + inode->i_flags |= S_SYNC;
4559 if (flags & JFS_APPEND_FL)
4560 inode->i_flags |= S_APPEND;
4561 if (flags & JFS_NOATIME_FL)
4562 inode->i_flags |= S_NOATIME;
4563 if (flags & JFS_DIRSYNC_FL)
4564 inode->i_flags |= S_DIRSYNC;
4565 - if (flags & JFS_SYNC_FL)
4566 - inode->i_flags |= S_SYNC;
4568 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4570 + if (flags & JFS_BARRIER_FL)
4571 + inode->i_vflags |= V_BARRIER;
4572 + if (flags & JFS_COW_FL)
4573 + inode->i_vflags |= V_COW;
4576 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4578 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4579 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4581 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4582 + JFS_APPEND_FL | JFS_NOATIME_FL |
4583 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4584 + JFS_BARRIER_FL | JFS_COW_FL);
4586 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4587 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4588 if (flags & S_IMMUTABLE)
4589 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4590 + if (flags & S_IXUNLINK)
4591 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4593 if (flags & S_APPEND)
4594 jfs_ip->mode2 |= JFS_APPEND_FL;
4595 if (flags & S_NOATIME)
4596 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4597 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4599 jfs_ip->mode2 |= JFS_SYNC_FL;
4601 + if (vflags & V_BARRIER)
4602 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4603 + if (vflags & V_COW)
4604 + jfs_ip->mode2 |= JFS_COW_FL;
4608 diff -NurpP --minimal linux-2.6.35.7/fs/jfs/jfs_inode.h linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/jfs_inode.h
4609 --- linux-2.6.35.7/fs/jfs/jfs_inode.h 2010-08-02 16:52:49.000000000 +0200
4610 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/jfs_inode.h 2010-08-02 17:05:06.000000000 +0200
4611 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4612 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4613 int fh_len, int fh_type);
4614 extern void jfs_set_inode_flags(struct inode *);
4615 +extern int jfs_sync_flags(struct inode *, int, int);
4616 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4617 extern int jfs_setattr(struct dentry *, struct iattr *);
4619 diff -NurpP --minimal linux-2.6.35.7/fs/jfs/namei.c linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/namei.c
4620 --- linux-2.6.35.7/fs/jfs/namei.c 2010-07-07 18:31:52.000000000 +0200
4621 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/namei.c 2010-08-02 17:05:06.000000000 +0200
4623 #include <linux/ctype.h>
4624 #include <linux/quotaops.h>
4625 #include <linux/exportfs.h>
4626 +#include <linux/vs_tag.h>
4627 #include "jfs_incore.h"
4628 #include "jfs_superblock.h"
4629 #include "jfs_inode.h"
4630 @@ -1491,6 +1492,7 @@ static struct dentry *jfs_lookup(struct
4631 return ERR_CAST(ip);
4634 + dx_propagate_tag(nd, ip);
4635 dentry = d_splice_alias(ip, dentry);
4637 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4638 @@ -1560,6 +1562,7 @@ const struct inode_operations jfs_dir_in
4639 #ifdef CONFIG_JFS_POSIX_ACL
4640 .check_acl = jfs_check_acl,
4642 + .sync_flags = jfs_sync_flags,
4645 const struct file_operations jfs_dir_operations = {
4646 diff -NurpP --minimal linux-2.6.35.7/fs/jfs/super.c linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/super.c
4647 --- linux-2.6.35.7/fs/jfs/super.c 2010-08-02 16:52:49.000000000 +0200
4648 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/jfs/super.c 2010-08-02 17:05:06.000000000 +0200
4649 @@ -200,7 +200,8 @@ static void jfs_put_super(struct super_b
4651 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4652 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4653 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4654 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4655 + Opt_tag, Opt_notag, Opt_tagid
4658 static const match_table_t tokens = {
4659 @@ -210,6 +211,10 @@ static const match_table_t tokens = {
4660 {Opt_resize, "resize=%u"},
4661 {Opt_resize_nosize, "resize"},
4662 {Opt_errors, "errors=%s"},
4664 + {Opt_notag, "notag"},
4665 + {Opt_tagid, "tagid=%u"},
4666 + {Opt_tag, "tagxid"},
4667 {Opt_ignore, "noquota"},
4668 {Opt_ignore, "quota"},
4669 {Opt_usrquota, "usrquota"},
4670 @@ -344,6 +349,20 @@ static int parse_options(char *options,
4674 +#ifndef CONFIG_TAGGING_NONE
4676 + *flag |= JFS_TAGGED;
4679 + *flag &= JFS_TAGGED;
4682 +#ifdef CONFIG_PROPAGATE
4685 + *flag |= JFS_TAGGED;
4689 printk("jfs: Unrecognized mount option \"%s\" "
4690 " or missing value\n", p);
4691 @@ -374,6 +393,12 @@ static int jfs_remount(struct super_bloc
4692 if (!parse_options(data, sb, &newLVSize, &flag)) {
4695 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4696 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4703 if (sb->s_flags & MS_RDONLY) {
4704 @@ -465,6 +490,9 @@ static int jfs_fill_super(struct super_b
4705 #ifdef CONFIG_JFS_POSIX_ACL
4706 sb->s_flags |= MS_POSIXACL;
4708 + /* map mount option tagxid */
4709 + if (sbi->flag & JFS_TAGGED)
4710 + sb->s_flags |= MS_TAGGED;
4713 printk(KERN_ERR "resize option for remount only\n");
4714 diff -NurpP --minimal linux-2.6.35.7/fs/libfs.c linux-2.6.35.7-vs2.3.0.36.33/fs/libfs.c
4715 --- linux-2.6.35.7/fs/libfs.c 2010-08-02 16:52:49.000000000 +0200
4716 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/libfs.c 2010-08-02 17:05:06.000000000 +0200
4717 @@ -124,7 +124,8 @@ static inline unsigned char dt_type(stru
4718 * both impossible due to the lock on directory.
4721 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4722 +static inline int do_dcache_readdir_filter(struct file *filp,
4723 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4725 struct dentry *dentry = filp->f_path.dentry;
4726 struct dentry *cursor = filp->private_data;
4727 @@ -157,6 +158,8 @@ int dcache_readdir(struct file * filp, v
4728 next = list_entry(p, struct dentry, d_u.d_child);
4729 if (d_unhashed(next) || !next->d_inode)
4731 + if (filter && !filter(next))
4734 spin_unlock(&dcache_lock);
4735 if (filldir(dirent, next->d_name.name,
4736 @@ -175,6 +178,18 @@ int dcache_readdir(struct file * filp, v
4740 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4742 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4745 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4746 + int (*filter)(struct dentry *))
4748 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4752 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4755 @@ -967,6 +982,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4756 EXPORT_SYMBOL(dcache_dir_lseek);
4757 EXPORT_SYMBOL(dcache_dir_open);
4758 EXPORT_SYMBOL(dcache_readdir);
4759 +EXPORT_SYMBOL(dcache_readdir_filter);
4760 EXPORT_SYMBOL(generic_read_dir);
4761 EXPORT_SYMBOL(get_sb_pseudo);
4762 EXPORT_SYMBOL(simple_write_begin);
4763 diff -NurpP --minimal linux-2.6.35.7/fs/locks.c linux-2.6.35.7-vs2.3.0.36.33/fs/locks.c
4764 --- linux-2.6.35.7/fs/locks.c 2010-07-07 18:31:52.000000000 +0200
4765 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/locks.c 2010-08-02 17:05:06.000000000 +0200
4767 #include <linux/time.h>
4768 #include <linux/rcupdate.h>
4769 #include <linux/pid_namespace.h>
4770 +#include <linux/vs_base.h>
4771 +#include <linux/vs_limit.h>
4773 #include <asm/uaccess.h>
4775 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
4776 /* Allocate an empty lock structure. */
4777 static struct file_lock *locks_alloc_lock(void)
4779 + if (!vx_locks_avail(1))
4781 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4784 @@ -174,6 +178,7 @@ static void locks_free_lock(struct file_
4785 BUG_ON(!list_empty(&fl->fl_block));
4786 BUG_ON(!list_empty(&fl->fl_link));
4789 locks_release_private(fl);
4790 kmem_cache_free(filelock_cache, fl);
4792 @@ -194,6 +199,7 @@ void locks_init_lock(struct file_lock *f
4793 fl->fl_start = fl->fl_end = 0;
4795 fl->fl_lmops = NULL;
4799 EXPORT_SYMBOL(locks_init_lock);
4800 @@ -248,6 +254,7 @@ void locks_copy_lock(struct file_lock *n
4801 new->fl_file = fl->fl_file;
4802 new->fl_ops = fl->fl_ops;
4803 new->fl_lmops = fl->fl_lmops;
4804 + new->fl_xid = fl->fl_xid;
4806 locks_copy_private(new, fl);
4808 @@ -286,6 +293,11 @@ static int flock_make_lock(struct file *
4809 fl->fl_flags = FL_FLOCK;
4811 fl->fl_end = OFFSET_MAX;
4813 + vxd_assert(filp->f_xid == vx_current_xid(),
4814 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4815 + fl->fl_xid = filp->f_xid;
4820 @@ -451,6 +463,7 @@ static int lease_init(struct file *filp,
4822 fl->fl_owner = current->files;
4823 fl->fl_pid = current->tgid;
4824 + fl->fl_xid = vx_current_xid();
4827 fl->fl_flags = FL_LEASE;
4828 @@ -470,6 +483,11 @@ static struct file_lock *lease_alloc(str
4830 return ERR_PTR(error);
4832 + fl->fl_xid = vx_current_xid();
4834 + vxd_assert(filp->f_xid == fl->fl_xid,
4835 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4837 error = lease_init(filp, type, fl);
4839 locks_free_lock(fl);
4840 @@ -770,6 +788,7 @@ static int flock_lock_file(struct file *
4844 + new_fl->fl_xid = -1;
4846 for_each_lock(inode, before) {
4847 struct file_lock *fl = *before;
4848 @@ -790,6 +809,7 @@ find_conflict:
4850 locks_copy_lock(new_fl, request);
4851 locks_insert_lock(before, new_fl);
4852 + vx_locks_inc(new_fl);
4856 @@ -800,7 +820,8 @@ out:
4860 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4861 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4862 + struct file_lock *conflock, xid_t xid)
4864 struct file_lock *fl;
4865 struct file_lock *new_fl = NULL;
4866 @@ -810,6 +831,8 @@ static int __posix_lock_file(struct inod
4867 struct file_lock **before;
4868 int error, added = 0;
4870 + vxd_assert(xid == vx_current_xid(),
4871 + "xid(%d) == current(%d)", xid, vx_current_xid());
4873 * We may need two file_lock structures for this operation,
4874 * so we get them in advance to avoid races.
4875 @@ -820,7 +843,11 @@ static int __posix_lock_file(struct inod
4876 (request->fl_type != F_UNLCK ||
4877 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4878 new_fl = locks_alloc_lock();
4879 + new_fl->fl_xid = xid;
4880 + vx_locks_inc(new_fl);
4881 new_fl2 = locks_alloc_lock();
4882 + new_fl2->fl_xid = xid;
4883 + vx_locks_inc(new_fl2);
4887 @@ -1019,7 +1046,8 @@ static int __posix_lock_file(struct inod
4888 int posix_lock_file(struct file *filp, struct file_lock *fl,
4889 struct file_lock *conflock)
4891 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4892 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4893 + fl, conflock, filp->f_xid);
4895 EXPORT_SYMBOL(posix_lock_file);
4897 @@ -1109,7 +1137,7 @@ int locks_mandatory_area(int read_write,
4898 fl.fl_end = offset + count - 1;
4901 - error = __posix_lock_file(inode, &fl, NULL);
4902 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4903 if (error != FILE_LOCK_DEFERRED)
4905 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4906 @@ -1425,6 +1453,7 @@ int generic_setlease(struct file *filp,
4908 locks_copy_lock(new_fl, lease);
4909 locks_insert_lock(before, new_fl);
4910 + vx_locks_inc(new_fl);
4914 @@ -1780,6 +1809,11 @@ int fcntl_setlk(unsigned int fd, struct
4915 if (file_lock == NULL)
4918 + vxd_assert(filp->f_xid == vx_current_xid(),
4919 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4920 + file_lock->fl_xid = filp->f_xid;
4921 + vx_locks_inc(file_lock);
4924 * This might block, so we do it before checking the inode.
4926 @@ -1898,6 +1932,11 @@ int fcntl_setlk64(unsigned int fd, struc
4927 if (file_lock == NULL)
4930 + vxd_assert(filp->f_xid == vx_current_xid(),
4931 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4932 + file_lock->fl_xid = filp->f_xid;
4933 + vx_locks_inc(file_lock);
4936 * This might block, so we do it before checking the inode.
4938 @@ -2163,8 +2202,11 @@ static int locks_show(struct seq_file *f
4940 lock_get_status(f, fl, (long)f->private, "");
4942 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4943 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4944 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4946 lock_get_status(f, bfl, (long)f->private, " ->");
4951 diff -NurpP --minimal linux-2.6.35.7/fs/namei.c linux-2.6.35.7-vs2.3.0.36.33/fs/namei.c
4952 --- linux-2.6.35.7/fs/namei.c 2010-08-02 16:52:50.000000000 +0200
4953 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/namei.c 2010-08-14 17:03:20.000000000 +0200
4955 #include <linux/fcntl.h>
4956 #include <linux/device_cgroup.h>
4957 #include <linux/fs_struct.h>
4958 +#include <linux/proc_fs.h>
4959 +#include <linux/vserver/inode.h>
4960 +#include <linux/vs_base.h>
4961 +#include <linux/vs_tag.h>
4962 +#include <linux/vs_cowbl.h>
4963 +#include <linux/vs_device.h>
4964 +#include <linux/vs_context.h>
4965 +#include <linux/pid_namespace.h>
4966 #include <asm/uaccess.h>
4968 #include "internal.h"
4969 @@ -166,6 +174,77 @@ void putname(const char *name)
4970 EXPORT_SYMBOL(putname);
4973 +static inline int dx_barrier(const struct inode *inode)
4975 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4976 + vxwprintk_task(1, "did hit the barrier.");
4982 +static int __dx_permission(const struct inode *inode, int mask)
4984 + if (dx_barrier(inode))
4987 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4988 + /* devpts is xid tagged */
4989 + if (S_ISDIR(inode->i_mode) ||
4990 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4993 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4994 + struct proc_dir_entry *de = PDE(inode);
4996 + if (de && !vx_hide_check(0, de->vx_flags))
4999 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
5001 + struct task_struct *tsk;
5003 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
5004 + vx_flags(VXF_STATE_SETUP, 0))
5007 + pid = PROC_I(inode)->pid;
5011 + tsk = pid_task(pid, PIDTYPE_PID);
5012 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
5013 + tsk, (tsk ? vx_task_xid(tsk) : 0));
5014 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
5018 + /* FIXME: Should we block some entries here? */
5023 + if (dx_notagcheck(inode->i_sb) ||
5024 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
5033 +int dx_permission(const struct inode *inode, int mask)
5035 + int ret = __dx_permission(inode, mask);
5036 + if (unlikely(ret)) {
5037 + vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
5038 + mask, inode->i_sb->s_id, inode, inode->i_tag,
5045 * This does basic POSIX ACL permission checking
5047 @@ -266,10 +345,14 @@ int inode_permission(struct inode *inode
5049 * Nobody gets write access to an immutable file.
5051 - if (IS_IMMUTABLE(inode))
5052 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
5056 + retval = dx_permission(inode, mask);
5060 if (inode->i_op->permission)
5061 retval = inode->i_op->permission(inode, mask);
5063 @@ -464,6 +547,9 @@ static int exec_permission(struct inode
5067 + if (dx_barrier(inode))
5070 if (inode->i_op->permission) {
5071 ret = inode->i_op->permission(inode, MAY_EXEC);
5073 @@ -677,7 +763,8 @@ static __always_inline void follow_dotdo
5075 if (nd->path.dentry == nd->root.dentry &&
5076 nd->path.mnt == nd->root.mnt) {
5078 + /* for sane '/' avoid follow_mount() */
5081 if (nd->path.dentry != nd->path.mnt->mnt_root) {
5082 /* rare case of legitimate dget_parent()... */
5083 @@ -701,7 +788,7 @@ static int do_lookup(struct nameidata *n
5085 struct vfsmount *mnt = nd->path.mnt;
5086 struct dentry *dentry, *parent;
5087 - struct inode *dir;
5088 + struct inode *dir, *inode;
5090 * See if the low-level filesystem might want
5091 * to use its own hash..
5092 @@ -717,12 +804,26 @@ static int do_lookup(struct nameidata *n
5094 if (dentry->d_op && dentry->d_op->d_revalidate)
5095 goto need_revalidate;
5097 + inode = dentry->d_inode;
5101 + if (__dx_permission(inode, MAY_ACCESS))
5105 path->dentry = dentry;
5106 __follow_mount(path);
5110 + vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] »%s/%.*s«.",
5111 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
5112 + vxd_path(&nd->path), name->len, name->name);
5117 parent = nd->path.dentry;
5118 dir = parent->d_inode;
5119 @@ -1326,7 +1427,7 @@ static int may_delete(struct inode *dir,
5122 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5123 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5124 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5127 if (!S_ISDIR(victim->d_inode->i_mode))
5128 @@ -1449,6 +1550,14 @@ int may_open(struct path *path, int acc_
5132 +#ifdef CONFIG_VSERVER_COWBL
5133 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5134 + if (IS_COW_LINK(inode))
5136 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5137 + mark_inode_dirty(inode);
5140 error = inode_permission(inode, acc_mode);
5143 @@ -1558,7 +1667,8 @@ static int open_will_truncate(int flag,
5146 static struct file *finish_open(struct nameidata *nd,
5147 - int open_flag, int acc_mode)
5148 + int open_flag, int acc_mode,
5149 + const char *pathname)
5153 @@ -1571,6 +1681,23 @@ static struct file *finish_open(struct n
5156 error = may_open(&nd->path, acc_mode, open_flag);
5157 +#ifdef CONFIG_VSERVER_COWBL
5158 + if (error == -EMLINK) {
5159 + struct dentry *dentry;
5160 + dentry = cow_break_link(pathname);
5161 + if (IS_ERR(dentry)) {
5162 + error = PTR_ERR(dentry);
5166 + if (will_truncate)
5167 + mnt_drop_write(nd->path.mnt);
5168 + release_open_intent(nd);
5169 + path_put(&nd->path);
5170 + return ERR_PTR(-EMLINK);
5176 mnt_drop_write(nd->path.mnt);
5177 @@ -1739,7 +1866,7 @@ static struct file *do_last(struct namei
5178 if (S_ISDIR(path->dentry->d_inode->i_mode))
5181 - filp = finish_open(nd, open_flag, acc_mode);
5182 + filp = finish_open(nd, open_flag, acc_mode, pathname);
5186 @@ -1768,7 +1895,11 @@ struct file *do_filp_open(int dfd, const
5188 int flag = open_to_namei_flags(open_flag);
5189 int force_reval = 0;
5191 +#ifdef CONFIG_VSERVER_COWBL
5196 if (!(open_flag & O_CREAT))
5199 @@ -1834,6 +1965,13 @@ reval:
5200 if (!(open_flag & O_NOFOLLOW))
5201 nd.flags |= LOOKUP_FOLLOW;
5202 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
5203 +#ifdef CONFIG_VSERVER_COWBL
5204 + if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
5210 while (unlikely(!filp)) { /* trailing symlink */
5212 struct inode *inode = path.dentry->d_inode;
5213 @@ -1872,6 +2010,13 @@ reval:
5215 nd.flags &= ~LOOKUP_PARENT;
5216 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
5217 +#ifdef CONFIG_VSERVER_COWBL
5218 + if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
5224 if (inode->i_op->put_link)
5225 inode->i_op->put_link(holder.dentry, &nd, cookie);
5227 @@ -1972,9 +2117,17 @@ int vfs_mknod(struct inode *dir, struct
5231 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5232 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5235 + if (!capable(CAP_MKNOD))
5238 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5240 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5243 if (!dir->i_op->mknod)
5246 @@ -2439,7 +2592,7 @@ int vfs_link(struct dentry *old_dentry,
5248 * A link to an append-only or immutable file cannot be created.
5250 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5251 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5253 if (!dir->i_op->link)
5255 @@ -2811,6 +2964,219 @@ int vfs_follow_link(struct nameidata *nd
5256 return __vfs_follow_link(nd, link);
5260 +#ifdef CONFIG_VSERVER_COWBL
5262 +#include <linux/file.h>
5265 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5269 + return do_splice_direct(in, &ppos, out, len, 0);
5272 +struct dentry *cow_break_link(const char *pathname)
5274 + int ret, mode, pathlen, redo = 0;
5275 + struct nameidata old_nd, dir_nd;
5276 + struct path old_path, new_path;
5277 + struct dentry *dir, *res = NULL;
5278 + struct file *old_file;
5279 + struct file *new_file;
5280 + char *to, *path, pad='\251';
5283 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
5284 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5289 + /* old_nd will have refs to dentry and mnt */
5290 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5291 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5293 + goto out_free_path;
5295 + old_path = old_nd.path;
5296 + mode = old_path.dentry->d_inode->i_mode;
5298 + to = d_path(&old_path, path, PATH_MAX-2);
5299 + pathlen = strlen(to);
5300 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
5301 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5302 + old_path.dentry->d_name.len);
5304 + to[pathlen + 1] = 0;
5306 + to[pathlen] = pad--;
5308 + if (pad <= '\240')
5311 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
5312 + /* dir_nd will have refs to dentry and mnt */
5313 + ret = path_lookup(to,
5314 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5315 + vxdprintk(VXD_CBIT(misc, 2),
5316 + "path_lookup(new): %d", ret);
5320 + /* this puppy downs the inode mutex */
5321 + new_path.dentry = lookup_create(&dir_nd, 0);
5322 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5323 + vxdprintk(VXD_CBIT(misc, 2),
5324 + "lookup_create(new): %p", new_path.dentry);
5325 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5326 + path_put(&dir_nd.path);
5329 + vxdprintk(VXD_CBIT(misc, 2),
5330 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
5331 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5332 + new_path.dentry->d_name.len);
5333 + dir = dir_nd.path.dentry;
5335 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5336 + vxdprintk(VXD_CBIT(misc, 2),
5337 + "vfs_create(new): %d", ret);
5338 + if (ret == -EEXIST) {
5339 + mutex_unlock(&dir->d_inode->i_mutex);
5340 + dput(new_path.dentry);
5341 + path_put(&dir_nd.path);
5345 + goto out_unlock_new;
5347 + /* drop out early, ret passes ENOENT */
5349 + if ((redo = d_unhashed(old_path.dentry)))
5350 + goto out_unlock_new;
5352 + new_path.mnt = dir_nd.path.mnt;
5353 + dget(old_path.dentry);
5354 + mntget(old_path.mnt);
5355 + /* this one cleans up the dentry/mnt in case of failure */
5356 + old_file = dentry_open(old_path.dentry, old_path.mnt,
5357 + O_RDONLY, current_cred());
5358 + vxdprintk(VXD_CBIT(misc, 2),
5359 + "dentry_open(old): %p", old_file);
5360 + if (!old_file || IS_ERR(old_file)) {
5361 + res = IS_ERR(old_file) ? (void *) old_file : res;
5362 + goto out_unlock_new;
5365 + dget(new_path.dentry);
5366 + mntget(new_path.mnt);
5367 + /* this one cleans up the dentry/mnt in case of failure */
5368 + new_file = dentry_open(new_path.dentry, new_path.mnt,
5369 + O_WRONLY, current_cred());
5370 + vxdprintk(VXD_CBIT(misc, 2),
5371 + "dentry_open(new): %p", new_file);
5373 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5374 + if (!new_file || IS_ERR(new_file))
5375 + goto out_fput_old;
5377 + size = i_size_read(old_file->f_dentry->d_inode);
5378 + ret = do_cow_splice(old_file, new_file, size);
5379 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5381 + goto out_fput_both;
5382 + } else if (ret < size) {
5384 + goto out_fput_both;
5386 + struct inode *old_inode = old_path.dentry->d_inode;
5387 + struct inode *new_inode = new_path.dentry->d_inode;
5388 + struct iattr attr = {
5389 + .ia_uid = old_inode->i_uid,
5390 + .ia_gid = old_inode->i_gid,
5391 + .ia_valid = ATTR_UID | ATTR_GID
5394 + ret = inode_setattr(new_inode, &attr);
5396 + goto out_fput_both;
5399 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5401 + /* drop out late */
5403 + if ((redo = d_unhashed(old_path.dentry)))
5406 + vxdprintk(VXD_CBIT(misc, 2),
5407 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
5408 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5409 + new_path.dentry->d_name.len,
5410 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5411 + old_path.dentry->d_name.len);
5412 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5413 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5414 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5415 + res = new_path.dentry;
5418 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5421 + vxdprintk(VXD_CBIT(misc, 3),
5422 + "fput(new_file=%p[#%ld])", new_file,
5423 + atomic_long_read(&new_file->f_count));
5427 + vxdprintk(VXD_CBIT(misc, 3),
5428 + "fput(old_file=%p[#%ld])", old_file,
5429 + atomic_long_read(&old_file->f_count));
5433 + mutex_unlock(&dir->d_inode->i_mutex);
5437 + /* error path cleanup */
5438 + vfs_unlink(dir->d_inode, new_path.dentry);
5439 + dput(new_path.dentry);
5443 + goto out_rel_both;
5444 + /* lookup dentry once again */
5445 + path_put(&old_nd.path);
5446 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5448 + goto out_rel_both;
5450 + new_path.dentry = old_nd.path.dentry;
5451 + vxdprintk(VXD_CBIT(misc, 2),
5452 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
5453 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5454 + new_path.dentry->d_name.len);
5455 + dget(new_path.dentry);
5456 + res = new_path.dentry;
5459 + path_put(&dir_nd.path);
5461 + path_put(&old_nd.path);
5466 + res = ERR_PTR(ret);
5472 /* get the link contents into pagecache */
5473 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5475 diff -NurpP --minimal linux-2.6.35.7/fs/namespace.c linux-2.6.35.7-vs2.3.0.36.33/fs/namespace.c
5476 --- linux-2.6.35.7/fs/namespace.c 2010-10-04 08:57:39.000000000 +0200
5477 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/namespace.c 2010-08-14 18:21:13.000000000 +0200
5479 #include <linux/log2.h>
5480 #include <linux/idr.h>
5481 #include <linux/fs_struct.h>
5482 +#include <linux/vs_base.h>
5483 +#include <linux/vs_context.h>
5484 +#include <linux/vs_tag.h>
5485 +#include <linux/vserver/space.h>
5486 +#include <linux/vserver/global.h>
5487 #include <asm/uaccess.h>
5488 #include <asm/unistd.h>
5490 @@ -567,6 +572,7 @@ static struct vfsmount *clone_mnt(struct
5491 mnt->mnt_root = dget(root);
5492 mnt->mnt_mountpoint = mnt->mnt_root;
5493 mnt->mnt_parent = mnt;
5494 + mnt->mnt_tag = old->mnt_tag;
5496 if (flag & CL_SLAVE) {
5497 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5498 @@ -660,6 +666,31 @@ static inline void mangle(struct seq_fil
5499 seq_escape(m, s, " \t\n\\");
5502 +static int mnt_is_reachable(struct vfsmount *mnt)
5505 + struct dentry *point;
5508 + if (mnt == mnt->mnt_ns->root)
5511 + spin_lock(&vfsmount_lock);
5512 + root = current->fs->root;
5513 + point = root.dentry;
5515 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5516 + point = mnt->mnt_mountpoint;
5517 + mnt = mnt->mnt_parent;
5520 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5522 + spin_unlock(&vfsmount_lock);
5528 * Simple .show_options callback for filesystems which don't want to
5529 * implement more complex mount option showing.
5530 @@ -762,6 +793,8 @@ static int show_sb_opts(struct seq_file
5531 { MS_SYNCHRONOUS, ",sync" },
5532 { MS_DIRSYNC, ",dirsync" },
5533 { MS_MANDLOCK, ",mand" },
5534 + { MS_TAGGED, ",tag" },
5535 + { MS_NOTAGCHECK, ",notagcheck" },
5538 const struct proc_fs_info *fs_infop;
5539 @@ -809,10 +842,20 @@ static int show_vfsmnt(struct seq_file *
5541 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5543 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5545 - seq_path(m, &mnt_path, " \t\n\\");
5547 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5549 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5552 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5553 + mnt == current->fs->root.mnt) {
5554 + seq_puts(m, "/dev/root / ");
5556 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5558 + seq_path(m, &mnt_path, " \t\n\\");
5561 show_type(m, mnt->mnt_sb);
5562 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5563 err = show_sb_opts(m, mnt->mnt_sb);
5564 @@ -842,6 +885,11 @@ static int show_mountinfo(struct seq_fil
5565 struct path root = p->root;
5568 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5570 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5573 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5574 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5575 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5576 @@ -900,17 +948,27 @@ static int show_vfsstat(struct seq_file
5577 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5581 - if (mnt->mnt_devname) {
5582 - seq_puts(m, "device ");
5583 - mangle(m, mnt->mnt_devname);
5585 - seq_puts(m, "no device");
5586 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5588 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5592 - seq_puts(m, " mounted on ");
5593 - seq_path(m, &mnt_path, " \t\n\\");
5595 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5596 + mnt == current->fs->root.mnt) {
5597 + seq_puts(m, "device /dev/root mounted on / ");
5600 + if (mnt->mnt_devname) {
5601 + seq_puts(m, "device ");
5602 + mangle(m, mnt->mnt_devname);
5604 + seq_puts(m, "no device");
5607 + seq_puts(m, " mounted on ");
5608 + seq_path(m, &mnt_path, " \t\n\\");
5612 /* file system type */
5613 seq_puts(m, "with fstype ");
5614 @@ -1151,7 +1209,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5618 - if (!capable(CAP_SYS_ADMIN))
5619 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5622 retval = do_umount(path.mnt, flags);
5623 @@ -1177,7 +1235,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5625 static int mount_is_safe(struct path *path)
5627 - if (capable(CAP_SYS_ADMIN))
5628 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5632 @@ -1449,7 +1507,7 @@ static int do_change_type(struct path *p
5633 int type = flag & ~MS_REC;
5636 - if (!capable(CAP_SYS_ADMIN))
5637 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5640 if (path->dentry != path->mnt->mnt_root)
5641 @@ -1476,11 +1534,13 @@ static int do_change_type(struct path *p
5642 * do loopback mount.
5644 static int do_loopback(struct path *path, char *old_name,
5646 + tag_t tag, unsigned long flags, int mnt_flags)
5648 struct path old_path;
5649 struct vfsmount *mnt = NULL;
5650 int err = mount_is_safe(path);
5651 + int recurse = flags & MS_REC;
5655 if (!old_name || !*old_name)
5656 @@ -1514,6 +1574,7 @@ static int do_loopback(struct path *path
5657 spin_unlock(&vfsmount_lock);
5658 release_mounts(&umount_list);
5660 + mnt->mnt_flags = mnt_flags;
5663 up_write(&namespace_sem);
5664 @@ -1544,12 +1605,12 @@ static int change_mount_flags(struct vfs
5665 * on it - tough luck.
5667 static int do_remount(struct path *path, int flags, int mnt_flags,
5669 + void *data, xid_t xid)
5672 struct super_block *sb = path->mnt->mnt_sb;
5674 - if (!capable(CAP_SYS_ADMIN))
5675 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5678 if (!check_mnt(path->mnt))
5679 @@ -1593,7 +1654,7 @@ static int do_move_mount(struct path *pa
5680 struct path old_path, parent_path;
5683 - if (!capable(CAP_SYS_ADMIN))
5684 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5686 if (!old_name || !*old_name)
5688 @@ -1675,7 +1736,7 @@ static int do_new_mount(struct path *pat
5691 /* we need capabilities... */
5692 - if (!capable(CAP_SYS_ADMIN))
5693 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5697 @@ -1941,6 +2002,7 @@ long do_mount(char *dev_name, char *dir_
5704 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5705 @@ -1968,6 +2030,12 @@ long do_mount(char *dev_name, char *dir_
5706 if (!(flags & MS_NOATIME))
5707 mnt_flags |= MNT_RELATIME;
5709 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5710 + /* FIXME: bind and re-mounts get the tag flag? */
5711 + if (flags & (MS_BIND|MS_REMOUNT))
5712 + flags |= MS_TAGID;
5715 /* Separate the per-mountpoint flags */
5716 if (flags & MS_NOSUID)
5717 mnt_flags |= MNT_NOSUID;
5718 @@ -1984,15 +2052,17 @@ long do_mount(char *dev_name, char *dir_
5719 if (flags & MS_RDONLY)
5720 mnt_flags |= MNT_READONLY;
5722 + if (!capable(CAP_SYS_ADMIN))
5723 + mnt_flags |= MNT_NODEV;
5724 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5725 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5728 if (flags & MS_REMOUNT)
5729 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5732 else if (flags & MS_BIND)
5733 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5734 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5735 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5736 retval = do_change_type(&path, flags);
5737 else if (flags & MS_MOVE)
5738 @@ -2071,6 +2141,7 @@ static struct mnt_namespace *dup_mnt_ns(
5739 q = next_mnt(q, new_ns->root);
5741 up_write(&namespace_sem);
5742 + atomic_inc(&vs_global_mnt_ns);
5746 @@ -2215,9 +2286,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5747 down_write(&namespace_sem);
5748 mutex_lock(&old.dentry->d_inode->i_mutex);
5750 - if (IS_MNT_SHARED(old.mnt) ||
5751 + if ((IS_MNT_SHARED(old.mnt) ||
5752 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5753 - IS_MNT_SHARED(root.mnt->mnt_parent))
5754 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5755 + !vx_flags(VXF_STATE_SETUP, 0))
5757 if (!check_mnt(root.mnt))
5759 @@ -2348,6 +2420,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5760 spin_unlock(&vfsmount_lock);
5761 up_write(&namespace_sem);
5762 release_mounts(&umount_list);
5763 + atomic_dec(&vs_global_mnt_ns);
5766 EXPORT_SYMBOL(put_mnt_ns);
5767 diff -NurpP --minimal linux-2.6.35.7/fs/nfs/client.c linux-2.6.35.7-vs2.3.0.36.33/fs/nfs/client.c
5768 --- linux-2.6.35.7/fs/nfs/client.c 2010-10-04 08:57:39.000000000 +0200
5769 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/nfs/client.c 2010-09-22 02:52:29.000000000 +0200
5770 @@ -739,6 +739,9 @@ static int nfs_init_server_rpcclient(str
5771 if (server->flags & NFS_MOUNT_SOFT)
5772 server->client->cl_softrtry = 1;
5774 + server->client->cl_tag = 0;
5775 + if (server->flags & NFS_MOUNT_TAGGED)
5776 + server->client->cl_tag = 1;
5780 @@ -910,6 +913,10 @@ static void nfs_server_set_fsinfo(struct
5781 server->acdirmin = server->acdirmax = 0;
5784 + /* FIXME: needs fsinfo
5785 + if (server->flags & NFS_MOUNT_TAGGED)
5786 + sb->s_flags |= MS_TAGGED; */
5788 server->maxfilesize = fsinfo->maxfilesize;
5790 /* We're airborne Set socket buffersize */
5791 diff -NurpP --minimal linux-2.6.35.7/fs/nfs/dir.c linux-2.6.35.7-vs2.3.0.36.33/fs/nfs/dir.c
5792 --- linux-2.6.35.7/fs/nfs/dir.c 2010-10-04 08:57:39.000000000 +0200
5793 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/nfs/dir.c 2010-09-06 02:59:52.000000000 +0200
5795 #include <linux/namei.h>
5796 #include <linux/mount.h>
5797 #include <linux/sched.h>
5798 +#include <linux/vs_tag.h>
5800 #include "nfs4_fs.h"
5801 #include "delegation.h"
5802 @@ -979,6 +980,7 @@ static struct dentry *nfs_lookup(struct
5804 goto out_unblock_sillyrename;
5806 + dx_propagate_tag(nd, inode);
5808 res = d_materialise_unique(dentry, inode);
5810 diff -NurpP --minimal linux-2.6.35.7/fs/nfs/inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/nfs/inode.c
5811 --- linux-2.6.35.7/fs/nfs/inode.c 2010-08-02 16:52:50.000000000 +0200
5812 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/nfs/inode.c 2010-08-02 17:05:06.000000000 +0200
5814 #include <linux/inet.h>
5815 #include <linux/nfs_xdr.h>
5816 #include <linux/slab.h>
5817 +#include <linux/vs_tag.h>
5819 #include <asm/system.h>
5820 #include <asm/uaccess.h>
5821 @@ -260,6 +261,8 @@ nfs_fhget(struct super_block *sb, struct
5822 if (inode->i_state & I_NEW) {
5823 struct nfs_inode *nfsi = NFS_I(inode);
5824 unsigned long now = jiffies;
5828 /* We set i_ino for the few things that still rely on it,
5829 * such as stat(2) */
5830 @@ -308,8 +311,8 @@ nfs_fhget(struct super_block *sb, struct
5831 nfsi->change_attr = 0;
5834 - inode->i_uid = -2;
5835 - inode->i_gid = -2;
5838 inode->i_blocks = 0;
5839 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5841 @@ -346,13 +349,13 @@ nfs_fhget(struct super_block *sb, struct
5842 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5843 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5844 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5845 - inode->i_uid = fattr->uid;
5847 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5848 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5849 | NFS_INO_INVALID_ACCESS
5850 | NFS_INO_INVALID_ACL;
5851 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5852 - inode->i_gid = fattr->gid;
5854 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5855 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5856 | NFS_INO_INVALID_ACCESS
5857 @@ -365,6 +368,11 @@ nfs_fhget(struct super_block *sb, struct
5859 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5861 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5862 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5863 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5864 + /* maybe fattr->xid someday */
5866 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5867 nfsi->attrtimeo_timestamp = now;
5868 nfsi->access_cache = RB_ROOT;
5869 @@ -483,6 +491,8 @@ void nfs_setattr_update_inode(struct ino
5870 inode->i_uid = attr->ia_uid;
5871 if ((attr->ia_valid & ATTR_GID) != 0)
5872 inode->i_gid = attr->ia_gid;
5873 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5874 + inode->i_tag = attr->ia_tag;
5875 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5876 spin_unlock(&inode->i_lock);
5878 @@ -856,6 +866,9 @@ static int nfs_check_inode_attributes(st
5879 struct nfs_inode *nfsi = NFS_I(inode);
5880 loff_t cur_size, new_isize;
5881 unsigned long invalid = 0;
5887 /* Has the inode gone and changed behind our back? */
5888 @@ -879,13 +892,18 @@ static int nfs_check_inode_attributes(st
5889 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5892 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5893 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5894 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5896 /* Have any file permissions changed? */
5897 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5898 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5899 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5900 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5901 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5902 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5903 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5904 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5905 + /* maybe check for tag too? */
5907 /* Has the link count changed? */
5908 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5909 @@ -1120,6 +1138,9 @@ static int nfs_update_inode(struct inode
5910 unsigned long invalid = 0;
5911 unsigned long now = jiffies;
5912 unsigned long save_cache_validity;
5917 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5918 __func__, inode->i_sb->s_id, inode->i_ino,
5919 @@ -1222,6 +1243,9 @@ static int nfs_update_inode(struct inode
5920 | NFS_INO_REVAL_PAGECACHE
5921 | NFS_INO_REVAL_FORCED);
5923 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5924 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5925 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5927 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5928 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5929 @@ -1243,9 +1267,9 @@ static int nfs_update_inode(struct inode
5930 | NFS_INO_REVAL_FORCED);
5932 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5933 - if (inode->i_uid != fattr->uid) {
5934 + if (uid != fattr->uid) {
5935 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5936 - inode->i_uid = fattr->uid;
5939 } else if (server->caps & NFS_CAP_OWNER)
5940 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5941 @@ -1254,9 +1278,9 @@ static int nfs_update_inode(struct inode
5942 | NFS_INO_REVAL_FORCED);
5944 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5945 - if (inode->i_gid != fattr->gid) {
5946 + if (gid != fattr->gid) {
5947 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5948 - inode->i_gid = fattr->gid;
5951 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5952 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5953 @@ -1264,6 +1288,10 @@ static int nfs_update_inode(struct inode
5954 | NFS_INO_INVALID_ACL
5955 | NFS_INO_REVAL_FORCED);
5957 + inode->i_uid = uid;
5958 + inode->i_gid = gid;
5959 + inode->i_tag = tag;
5961 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5962 if (inode->i_nlink != fattr->nlink) {
5963 invalid |= NFS_INO_INVALID_ATTR;
5964 diff -NurpP --minimal linux-2.6.35.7/fs/nfs/nfs3xdr.c linux-2.6.35.7-vs2.3.0.36.33/fs/nfs/nfs3xdr.c
5965 --- linux-2.6.35.7/fs/nfs/nfs3xdr.c 2010-08-02 16:52:50.000000000 +0200
5966 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/nfs/nfs3xdr.c 2010-08-02 17:05:06.000000000 +0200
5968 #include <linux/nfs3.h>
5969 #include <linux/nfs_fs.h>
5970 #include <linux/nfsacl.h>
5971 +#include <linux/vs_tag.h>
5972 #include "internal.h"
5974 #define NFSDBG_FACILITY NFSDBG_XDR
5975 @@ -175,7 +176,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5978 static inline __be32 *
5979 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5980 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5982 if (attr->ia_valid & ATTR_MODE) {
5984 @@ -183,15 +184,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5988 - if (attr->ia_valid & ATTR_UID) {
5989 + if (attr->ia_valid & ATTR_UID ||
5990 + (tag && (attr->ia_valid & ATTR_TAG))) {
5992 - *p++ = htonl(attr->ia_uid);
5993 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5997 - if (attr->ia_valid & ATTR_GID) {
5998 + if (attr->ia_valid & ATTR_GID ||
5999 + (tag && (attr->ia_valid & ATTR_TAG))) {
6001 - *p++ = htonl(attr->ia_gid);
6002 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
6006 @@ -278,7 +281,8 @@ static int
6007 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
6009 p = xdr_encode_fhandle(p, args->fh);
6010 - p = xdr_encode_sattr(p, args->sattr);
6011 + p = xdr_encode_sattr(p, args->sattr,
6012 + req->rq_task->tk_client->cl_tag);
6013 *p++ = htonl(args->guard);
6015 p = xdr_encode_time3(p, &args->guardtime);
6016 @@ -383,7 +387,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
6017 *p++ = args->verifier[0];
6018 *p++ = args->verifier[1];
6020 - p = xdr_encode_sattr(p, args->sattr);
6021 + p = xdr_encode_sattr(p, args->sattr,
6022 + req->rq_task->tk_client->cl_tag);
6024 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6026 @@ -397,7 +402,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
6028 p = xdr_encode_fhandle(p, args->fh);
6029 p = xdr_encode_array(p, args->name, args->len);
6030 - p = xdr_encode_sattr(p, args->sattr);
6031 + p = xdr_encode_sattr(p, args->sattr,
6032 + req->rq_task->tk_client->cl_tag);
6033 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6036 @@ -410,7 +416,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
6038 p = xdr_encode_fhandle(p, args->fromfh);
6039 p = xdr_encode_array(p, args->fromname, args->fromlen);
6040 - p = xdr_encode_sattr(p, args->sattr);
6041 + p = xdr_encode_sattr(p, args->sattr,
6042 + req->rq_task->tk_client->cl_tag);
6043 *p++ = htonl(args->pathlen);
6044 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6046 @@ -428,7 +435,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
6047 p = xdr_encode_fhandle(p, args->fh);
6048 p = xdr_encode_array(p, args->name, args->len);
6049 *p++ = htonl(args->type);
6050 - p = xdr_encode_sattr(p, args->sattr);
6051 + p = xdr_encode_sattr(p, args->sattr,
6052 + req->rq_task->tk_client->cl_tag);
6053 if (args->type == NF3CHR || args->type == NF3BLK) {
6054 *p++ = htonl(MAJOR(args->rdev));
6055 *p++ = htonl(MINOR(args->rdev));
6056 diff -NurpP --minimal linux-2.6.35.7/fs/nfs/nfsroot.c linux-2.6.35.7-vs2.3.0.36.33/fs/nfs/nfsroot.c
6057 --- linux-2.6.35.7/fs/nfs/nfsroot.c 2010-08-02 16:52:50.000000000 +0200
6058 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/nfs/nfsroot.c 2010-08-02 17:05:06.000000000 +0200
6059 @@ -122,12 +122,12 @@ static int mount_port __initdata = 0; /
6061 /* Options that take integer arguments */
6062 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
6063 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
6064 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
6065 /* Options that take no arguments */
6066 Opt_soft, Opt_hard, Opt_intr,
6067 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
6068 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
6069 - Opt_acl, Opt_noacl,
6070 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
6074 @@ -164,6 +164,9 @@ static const match_table_t tokens __init
6077 {Opt_noacl, "noacl"},
6079 + {Opt_notag, "notag"},
6080 + {Opt_tagid, "tagid=%u"},
6084 @@ -275,6 +278,20 @@ static int __init root_nfs_parse(char *n
6086 nfs_data.flags |= NFS_MOUNT_NOACL;
6088 +#ifndef CONFIG_TAGGING_NONE
6090 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6093 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
6096 +#ifdef CONFIG_PROPAGATE
6099 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6103 printk(KERN_WARNING "Root-NFS: unknown "
6105 diff -NurpP --minimal linux-2.6.35.7/fs/nfs/super.c linux-2.6.35.7-vs2.3.0.36.33/fs/nfs/super.c
6106 --- linux-2.6.35.7/fs/nfs/super.c 2010-10-04 08:57:39.000000000 +0200
6107 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/nfs/super.c 2010-09-22 02:52:29.000000000 +0200
6109 #include <linux/nfs_xdr.h>
6110 #include <linux/magic.h>
6111 #include <linux/parser.h>
6112 +#include <linux/vs_tag.h>
6114 #include <asm/system.h>
6115 #include <asm/uaccess.h>
6116 @@ -614,6 +615,7 @@ static void nfs_show_mount_options(struc
6117 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
6118 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
6119 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
6120 + { NFS_MOUNT_TAGGED, ",tag", "" },
6123 const struct proc_nfs_info *nfs_infop;
6124 diff -NurpP --minimal linux-2.6.35.7/fs/nfsd/auth.c linux-2.6.35.7-vs2.3.0.36.33/fs/nfsd/auth.c
6125 --- linux-2.6.35.7/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
6126 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/nfsd/auth.c 2010-08-02 17:05:06.000000000 +0200
6128 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
6130 #include <linux/sched.h>
6131 +#include <linux/vs_tag.h>
6135 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6137 new->fsuid = rqstp->rq_cred.cr_uid;
6138 new->fsgid = rqstp->rq_cred.cr_gid;
6139 + /* FIXME: this desperately needs a tag :)
6140 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6143 rqgi = rqstp->rq_cred.cr_group_info;
6145 diff -NurpP --minimal linux-2.6.35.7/fs/nfsd/nfs3xdr.c linux-2.6.35.7-vs2.3.0.36.33/fs/nfsd/nfs3xdr.c
6146 --- linux-2.6.35.7/fs/nfsd/nfs3xdr.c 2010-02-25 11:52:05.000000000 +0100
6147 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/nfsd/nfs3xdr.c 2010-08-02 17:05:06.000000000 +0200
6151 #include <linux/namei.h>
6152 +#include <linux/vs_tag.h>
6156 @@ -95,6 +96,8 @@ static __be32 *
6157 decode_sattr3(__be32 *p, struct iattr *iap)
6165 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6168 iap->ia_valid |= ATTR_UID;
6169 - iap->ia_uid = ntohl(*p++);
6170 + uid = ntohl(*p++);
6173 iap->ia_valid |= ATTR_GID;
6174 - iap->ia_gid = ntohl(*p++);
6175 + gid = ntohl(*p++);
6177 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6178 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6179 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6183 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6184 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6185 *p++ = htonl((u32) stat->mode);
6186 *p++ = htonl((u32) stat->nlink);
6187 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6188 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6189 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6190 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6191 + stat->uid, stat->tag)));
6192 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6193 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6194 + stat->gid, stat->tag)));
6195 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6196 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6198 diff -NurpP --minimal linux-2.6.35.7/fs/nfsd/nfs4xdr.c linux-2.6.35.7-vs2.3.0.36.33/fs/nfsd/nfs4xdr.c
6199 --- linux-2.6.35.7/fs/nfsd/nfs4xdr.c 2010-08-02 16:52:50.000000000 +0200
6200 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/nfsd/nfs4xdr.c 2010-08-02 17:05:06.000000000 +0200
6202 #include <linux/nfsd_idmap.h>
6203 #include <linux/nfs4_acl.h>
6204 #include <linux/sunrpc/svcauth_gss.h>
6205 +#include <linux/vs_tag.h>
6209 @@ -2053,14 +2054,18 @@ out_acl:
6210 WRITE32(stat.nlink);
6212 if (bmval1 & FATTR4_WORD1_OWNER) {
6213 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6214 + status = nfsd4_encode_user(rqstp,
6215 + TAGINO_UID(DX_TAG(dentry->d_inode),
6216 + stat.uid, stat.tag), &p, &buflen);
6217 if (status == nfserr_resource)
6222 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6223 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6224 + status = nfsd4_encode_group(rqstp,
6225 + TAGINO_GID(DX_TAG(dentry->d_inode),
6226 + stat.gid, stat.tag), &p, &buflen);
6227 if (status == nfserr_resource)
6230 diff -NurpP --minimal linux-2.6.35.7/fs/nfsd/nfsxdr.c linux-2.6.35.7-vs2.3.0.36.33/fs/nfsd/nfsxdr.c
6231 --- linux-2.6.35.7/fs/nfsd/nfsxdr.c 2010-02-25 11:52:05.000000000 +0100
6232 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/nfsd/nfsxdr.c 2010-08-02 17:05:06.000000000 +0200
6237 +#include <linux/vs_tag.h>
6239 #define NFSDDBG_FACILITY NFSDDBG_XDR
6241 @@ -88,6 +89,8 @@ static __be32 *
6242 decode_sattr(__be32 *p, struct iattr *iap)
6250 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6252 if ((tmp = ntohl(*p++)) != (u32)-1) {
6253 iap->ia_valid |= ATTR_UID;
6254 - iap->ia_uid = tmp;
6257 if ((tmp = ntohl(*p++)) != (u32)-1) {
6258 iap->ia_valid |= ATTR_GID;
6259 - iap->ia_gid = tmp;
6262 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6263 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6264 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6265 if ((tmp = ntohl(*p++)) != (u32)-1) {
6266 iap->ia_valid |= ATTR_SIZE;
6268 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6269 *p++ = htonl(nfs_ftypes[type >> 12]);
6270 *p++ = htonl((u32) stat->mode);
6271 *p++ = htonl((u32) stat->nlink);
6272 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6273 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6274 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6275 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6276 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6277 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6279 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6280 *p++ = htonl(NFS_MAXPATHLEN);
6281 diff -NurpP --minimal linux-2.6.35.7/fs/ocfs2/dlmglue.c linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/dlmglue.c
6282 --- linux-2.6.35.7/fs/ocfs2/dlmglue.c 2010-08-02 16:52:51.000000000 +0200
6283 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/dlmglue.c 2010-08-02 17:05:06.000000000 +0200
6284 @@ -2114,6 +2114,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6285 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6286 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6287 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6288 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6289 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6290 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6291 lvb->lvb_iatime_packed =
6292 @@ -2168,6 +2169,7 @@ static void ocfs2_refresh_inode_from_lvb
6294 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6295 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6296 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6297 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6298 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6299 ocfs2_unpack_timespec(&inode->i_atime,
6300 diff -NurpP --minimal linux-2.6.35.7/fs/ocfs2/dlmglue.h linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/dlmglue.h
6301 --- linux-2.6.35.7/fs/ocfs2/dlmglue.h 2009-12-03 20:02:53.000000000 +0100
6302 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/dlmglue.h 2010-08-02 17:05:06.000000000 +0200
6303 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6306 __be32 lvb_igeneration;
6307 - __be32 lvb_reserved2;
6309 + __be16 lvb_reserved2;
6312 #define OCFS2_QINFO_LVB_VERSION 1
6313 diff -NurpP --minimal linux-2.6.35.7/fs/ocfs2/file.c linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/file.c
6314 --- linux-2.6.35.7/fs/ocfs2/file.c 2010-08-02 16:52:51.000000000 +0200
6315 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/file.c 2010-08-02 17:05:06.000000000 +0200
6316 @@ -1129,13 +1129,15 @@ int ocfs2_setattr(struct dentry *dentry,
6317 mlog(0, "uid change: %d\n", attr->ia_uid);
6318 if (attr->ia_valid & ATTR_GID)
6319 mlog(0, "gid change: %d\n", attr->ia_gid);
6320 + if (attr->ia_valid & ATTR_TAG)
6321 + mlog(0, "tag change: %d\n", attr->ia_tag);
6322 if (attr->ia_valid & ATTR_SIZE)
6323 mlog(0, "size change...\n");
6324 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6325 mlog(0, "time change...\n");
6327 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6328 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6329 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6330 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6331 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6333 diff -NurpP --minimal linux-2.6.35.7/fs/ocfs2/inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/inode.c
6334 --- linux-2.6.35.7/fs/ocfs2/inode.c 2010-10-04 08:57:39.000000000 +0200
6335 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/inode.c 2010-09-22 02:52:29.000000000 +0200
6337 #include <linux/highmem.h>
6338 #include <linux/pagemap.h>
6339 #include <linux/quotaops.h>
6340 +#include <linux/vs_tag.h>
6342 #include <asm/byteorder.h>
6344 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
6346 unsigned int flags = OCFS2_I(inode)->ip_attr;
6348 - inode->i_flags &= ~(S_IMMUTABLE |
6349 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6350 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6352 if (flags & OCFS2_IMMUTABLE_FL)
6353 inode->i_flags |= S_IMMUTABLE;
6354 + if (flags & OCFS2_IXUNLINK_FL)
6355 + inode->i_flags |= S_IXUNLINK;
6357 if (flags & OCFS2_SYNC_FL)
6358 inode->i_flags |= S_SYNC;
6359 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
6360 inode->i_flags |= S_NOATIME;
6361 if (flags & OCFS2_DIRSYNC_FL)
6362 inode->i_flags |= S_DIRSYNC;
6364 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6366 + if (flags & OCFS2_BARRIER_FL)
6367 + inode->i_vflags |= V_BARRIER;
6368 + if (flags & OCFS2_COW_FL)
6369 + inode->i_vflags |= V_COW;
6372 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6373 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6375 unsigned int flags = oi->vfs_inode.i_flags;
6376 + unsigned int vflags = oi->vfs_inode.i_vflags;
6378 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6379 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6380 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6381 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6383 + if (flags & S_IMMUTABLE)
6384 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6385 + if (flags & S_IXUNLINK)
6386 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6388 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6389 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6391 oi->ip_attr |= OCFS2_SYNC_FL;
6392 if (flags & S_APPEND)
6393 oi->ip_attr |= OCFS2_APPEND_FL;
6394 - if (flags & S_IMMUTABLE)
6395 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6396 if (flags & S_NOATIME)
6397 oi->ip_attr |= OCFS2_NOATIME_FL;
6398 if (flags & S_DIRSYNC)
6399 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6401 + if (vflags & V_BARRIER)
6402 + oi->ip_attr |= OCFS2_BARRIER_FL;
6403 + if (vflags & V_COW)
6404 + oi->ip_attr |= OCFS2_COW_FL;
6407 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
6408 @@ -245,6 +267,8 @@ void ocfs2_populate_inode(struct inode *
6409 struct super_block *sb;
6410 struct ocfs2_super *osb;
6415 mlog_entry("(0x%p, size:%llu)\n", inode,
6416 (unsigned long long)le64_to_cpu(fe->i_size));
6417 @@ -276,8 +300,12 @@ void ocfs2_populate_inode(struct inode *
6418 inode->i_generation = le32_to_cpu(fe->i_generation);
6419 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6420 inode->i_mode = le16_to_cpu(fe->i_mode);
6421 - inode->i_uid = le32_to_cpu(fe->i_uid);
6422 - inode->i_gid = le32_to_cpu(fe->i_gid);
6423 + uid = le32_to_cpu(fe->i_uid);
6424 + gid = le32_to_cpu(fe->i_gid);
6425 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6426 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6427 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6428 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6430 /* Fast symlinks will have i_size but no allocated clusters. */
6431 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6432 diff -NurpP --minimal linux-2.6.35.7/fs/ocfs2/inode.h linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/inode.h
6433 --- linux-2.6.35.7/fs/ocfs2/inode.h 2010-08-02 16:52:51.000000000 +0200
6434 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/inode.h 2010-08-02 17:05:06.000000000 +0200
6435 @@ -154,6 +154,7 @@ struct buffer_head *ocfs2_bread(struct i
6437 void ocfs2_set_inode_flags(struct inode *inode);
6438 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6439 +int ocfs2_sync_flags(struct inode *inode, int, int);
6441 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6443 diff -NurpP --minimal linux-2.6.35.7/fs/ocfs2/ioctl.c linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/ioctl.c
6444 --- linux-2.6.35.7/fs/ocfs2/ioctl.c 2010-02-25 11:52:06.000000000 +0100
6445 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/ioctl.c 2010-08-02 17:05:06.000000000 +0200
6446 @@ -43,7 +43,41 @@ static int ocfs2_get_inode_attr(struct i
6450 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6451 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6453 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6454 + struct buffer_head *bh = NULL;
6455 + handle_t *handle = NULL;
6458 + status = ocfs2_inode_lock(inode, &bh, 1);
6460 + mlog_errno(status);
6463 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6464 + if (IS_ERR(handle)) {
6465 + status = PTR_ERR(handle);
6466 + mlog_errno(status);
6470 + inode->i_flags = flags;
6471 + inode->i_vflags = vflags;
6472 + ocfs2_get_inode_flags(OCFS2_I(inode));
6474 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6476 + mlog_errno(status);
6478 + ocfs2_commit_trans(osb, handle);
6480 + ocfs2_inode_unlock(inode, 1);
6485 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6488 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6489 @@ -68,6 +102,11 @@ static int ocfs2_set_inode_attr(struct i
6490 if (!S_ISDIR(inode->i_mode))
6491 flags &= ~OCFS2_DIRSYNC_FL;
6493 + if (IS_BARRIER(inode)) {
6494 + vxwprintk_task(1, "messing with the barrier.");
6498 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6499 if (IS_ERR(handle)) {
6500 status = PTR_ERR(handle);
6501 @@ -109,6 +148,7 @@ bail:
6506 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6508 struct inode *inode = filp->f_path.dentry->d_inode;
6509 diff -NurpP --minimal linux-2.6.35.7/fs/ocfs2/namei.c linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/namei.c
6510 --- linux-2.6.35.7/fs/ocfs2/namei.c 2010-08-02 16:52:51.000000000 +0200
6511 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/namei.c 2010-08-02 17:05:06.000000000 +0200
6513 #include <linux/slab.h>
6514 #include <linux/highmem.h>
6515 #include <linux/quotaops.h>
6516 +#include <linux/vs_tag.h>
6518 #define MLOG_MASK_PREFIX ML_NAMEI
6519 #include <cluster/masklog.h>
6520 @@ -487,6 +488,7 @@ static int ocfs2_mknod_locked(struct ocf
6521 u64 suballoc_loc, fe_blkno = 0;
6528 @@ -532,8 +534,11 @@ static int ocfs2_mknod_locked(struct ocf
6529 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
6530 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6531 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6532 - fe->i_uid = cpu_to_le32(inode->i_uid);
6533 - fe->i_gid = cpu_to_le32(inode->i_gid);
6535 + tag = dx_current_fstag(osb->sb);
6536 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6537 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6538 + inode->i_tag = tag;
6539 fe->i_mode = cpu_to_le16(inode->i_mode);
6540 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6541 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6542 diff -NurpP --minimal linux-2.6.35.7/fs/ocfs2/ocfs2_fs.h linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/ocfs2_fs.h
6543 --- linux-2.6.35.7/fs/ocfs2/ocfs2_fs.h 2010-08-02 16:52:51.000000000 +0200
6544 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/ocfs2_fs.h 2010-08-02 17:05:06.000000000 +0200
6545 @@ -235,18 +235,23 @@
6546 #define OCFS2_HAS_REFCOUNT_FL (0x0010)
6548 /* Inode attributes, keep in sync with EXT2 */
6549 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
6550 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
6551 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
6552 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
6553 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
6554 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
6555 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
6556 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
6557 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
6558 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
6559 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
6560 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
6561 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
6562 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
6563 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
6564 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
6565 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
6567 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
6568 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
6569 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
6570 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6572 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6573 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6575 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
6576 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
6579 * Extent record flags (e_node.leaf.flags)
6580 diff -NurpP --minimal linux-2.6.35.7/fs/ocfs2/ocfs2.h linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/ocfs2.h
6581 --- linux-2.6.35.7/fs/ocfs2/ocfs2.h 2010-08-02 16:52:51.000000000 +0200
6582 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/ocfs2.h 2010-08-02 17:05:06.000000000 +0200
6583 @@ -256,6 +256,7 @@ enum ocfs2_mount_options
6585 OCFS2_MOUNT_USRQUOTA = 1 << 10, /* We support user quotas */
6586 OCFS2_MOUNT_GRPQUOTA = 1 << 11, /* We support group quotas */
6587 + OCFS2_MOUNT_TAGGED = 1 << 12, /* use tagging */
6590 #define OCFS2_OSB_SOFT_RO 0x0001
6591 diff -NurpP --minimal linux-2.6.35.7/fs/ocfs2/super.c linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/super.c
6592 --- linux-2.6.35.7/fs/ocfs2/super.c 2010-08-02 16:52:51.000000000 +0200
6593 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/ocfs2/super.c 2010-08-02 18:00:11.000000000 +0200
6594 @@ -180,6 +180,7 @@ enum {
6598 + Opt_tag, Opt_notag, Opt_tagid,
6602 @@ -208,6 +209,9 @@ static const match_table_t tokens = {
6603 {Opt_grpquota, "grpquota"},
6604 {Opt_resv_level, "resv_level=%u"},
6605 {Opt_dir_resv_level, "dir_resv_level=%u"},
6607 + {Opt_notag, "notag"},
6608 + {Opt_tagid, "tagid=%u"},
6612 @@ -618,6 +622,13 @@ static int ocfs2_remount(struct super_bl
6616 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6617 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6619 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6623 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6624 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6626 @@ -1154,6 +1165,9 @@ static int ocfs2_fill_super(struct super
6628 ocfs2_complete_mount_recovery(osb);
6630 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6631 + sb->s_flags |= MS_TAGGED;
6633 if (ocfs2_mount_local(osb))
6634 snprintf(nodestr, sizeof(nodestr), "local");
6636 @@ -1469,6 +1483,20 @@ static int ocfs2_parse_options(struct su
6637 option < OCFS2_MAX_RESV_LEVEL)
6638 mopt->dir_resv_level = option;
6640 +#ifndef CONFIG_TAGGING_NONE
6642 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6645 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6648 +#ifdef CONFIG_PROPAGATE
6651 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6656 "Unrecognized mount option \"%s\" "
6657 diff -NurpP --minimal linux-2.6.35.7/fs/open.c linux-2.6.35.7-vs2.3.0.36.33/fs/open.c
6658 --- linux-2.6.35.7/fs/open.c 2010-08-02 16:52:51.000000000 +0200
6659 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/open.c 2010-08-02 21:36:22.000000000 +0200
6661 #include <linux/falloc.h>
6662 #include <linux/fs_struct.h>
6663 #include <linux/ima.h>
6664 +#include <linux/vs_base.h>
6665 +#include <linux/vs_limit.h>
6666 +#include <linux/vs_tag.h>
6667 +#include <linux/vs_cowbl.h>
6668 +#include <linux/vserver/dlimit.h>
6670 #include "internal.h"
6672 @@ -481,6 +486,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6673 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6677 +#ifdef CONFIG_VSERVER_COWBL
6678 + error = cow_check_and_break(&path);
6680 + goto dput_and_out;
6682 inode = path.dentry->d_inode;
6684 error = mnt_want_write(path.mnt);
6685 @@ -518,11 +529,11 @@ static int chown_common(struct path *pat
6686 newattrs.ia_valid = ATTR_CTIME;
6687 if (user != (uid_t) -1) {
6688 newattrs.ia_valid |= ATTR_UID;
6689 - newattrs.ia_uid = user;
6690 + newattrs.ia_uid = dx_map_uid(user);
6692 if (group != (gid_t) -1) {
6693 newattrs.ia_valid |= ATTR_GID;
6694 - newattrs.ia_gid = group;
6695 + newattrs.ia_gid = dx_map_gid(group);
6697 if (!S_ISDIR(inode->i_mode))
6698 newattrs.ia_valid |=
6699 @@ -547,6 +558,10 @@ SYSCALL_DEFINE3(chown, const char __user
6700 error = mnt_want_write(path.mnt);
6703 +#ifdef CONFIG_VSERVER_COWBL
6704 + error = cow_check_and_break(&path);
6707 error = chown_common(&path, user, group);
6708 mnt_drop_write(path.mnt);
6710 @@ -572,6 +587,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6711 error = mnt_want_write(path.mnt);
6714 +#ifdef CONFIG_VSERVER_COWBL
6715 + error = cow_check_and_break(&path);
6718 error = chown_common(&path, user, group);
6719 mnt_drop_write(path.mnt);
6721 @@ -591,6 +610,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6722 error = mnt_want_write(path.mnt);
6725 +#ifdef CONFIG_VSERVER_COWBL
6726 + error = cow_check_and_break(&path);
6729 error = chown_common(&path, user, group);
6730 mnt_drop_write(path.mnt);
6732 @@ -837,6 +860,7 @@ static void __put_unused_fd(struct files
6733 __FD_CLR(fd, fdt->open_fds);
6734 if (fd < files->next_fd)
6735 files->next_fd = fd;
6736 + vx_openfd_dec(fd);
6739 void put_unused_fd(unsigned int fd)
6740 diff -NurpP --minimal linux-2.6.35.7/fs/proc/array.c linux-2.6.35.7-vs2.3.0.36.33/fs/proc/array.c
6741 --- linux-2.6.35.7/fs/proc/array.c 2010-08-02 16:52:51.000000000 +0200
6742 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/proc/array.c 2010-08-02 17:05:06.000000000 +0200
6744 #include <linux/pid_namespace.h>
6745 #include <linux/ptrace.h>
6746 #include <linux/tracehook.h>
6747 +#include <linux/vs_context.h>
6748 +#include <linux/vs_network.h>
6750 #include <asm/pgtable.h>
6751 #include <asm/processor.h>
6752 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
6754 ppid = pid_alive(p) ?
6755 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6756 + if (unlikely(vx_current_initpid(p->pid)))
6761 struct task_struct *tracer = tracehook_tracer_task(p);
6762 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6765 static void render_cap_t(struct seq_file *m, const char *header,
6767 + struct vx_info *vxi, kernel_cap_t *a)
6771 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6772 cap_bset = cred->cap_bset;
6775 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6776 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6777 - render_cap_t(m, "CapEff:\t", &cap_effective);
6778 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6779 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6780 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6781 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6782 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6783 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6786 static inline void task_context_switch_counts(struct seq_file *m,
6787 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6788 seq_printf(m, "\n");
6791 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6792 + struct pid *pid, struct task_struct *task)
6794 + seq_printf(m, "Proxy:\t%p(%c)\n"
6802 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6803 + atomic_read(&task->nsproxy->count),
6804 + task->nsproxy->uts_ns,
6805 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6806 + task->nsproxy->ipc_ns,
6807 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6808 + task->nsproxy->mnt_ns,
6809 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6810 + task->nsproxy->pid_ns,
6811 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6812 + task->nsproxy->net_ns,
6813 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6817 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6819 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6822 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6823 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6827 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6828 struct pid *pid, struct task_struct *task)
6830 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6832 task_cpus_allowed(m, task);
6833 cpuset_task_status_allowed(m, task);
6834 + task_vs_id(m, task);
6835 #if defined(CONFIG_S390)
6836 task_show_regs(m, task);
6838 @@ -465,6 +508,17 @@ static int do_task_stat(struct seq_file
6839 /* convert nsec -> ticks */
6840 start_time = nsec_to_clock_t(start_time);
6842 + /* fixup start time for virt uptime */
6843 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6844 + unsigned long long bias =
6845 + current->vx_info->cvirt.bias_clock;
6847 + if (start_time > bias)
6848 + start_time -= bias;
6853 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6854 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6855 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6856 diff -NurpP --minimal linux-2.6.35.7/fs/proc/base.c linux-2.6.35.7-vs2.3.0.36.33/fs/proc/base.c
6857 --- linux-2.6.35.7/fs/proc/base.c 2010-08-02 16:52:51.000000000 +0200
6858 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/proc/base.c 2010-08-02 17:05:06.000000000 +0200
6860 #include <linux/pid_namespace.h>
6861 #include <linux/fs_struct.h>
6862 #include <linux/slab.h>
6863 +#include <linux/vs_context.h>
6864 +#include <linux/vs_network.h>
6865 #include "internal.h"
6868 @@ -1033,12 +1035,17 @@ static ssize_t oom_adjust_write(struct f
6872 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6873 + if (oom_adjust < task->signal->oom_adj &&
6874 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6875 unlock_task_sighand(task, &flags);
6876 put_task_struct(task);
6880 + /* prevent guest processes from circumventing the oom killer */
6881 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6882 + oom_adjust = OOM_ADJUST_MIN;
6884 task->signal->oom_adj = oom_adjust;
6886 unlock_task_sighand(task, &flags);
6887 @@ -1079,7 +1086,7 @@ static ssize_t proc_loginuid_write(struc
6891 - if (!capable(CAP_AUDIT_CONTROL))
6892 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6896 @@ -1517,6 +1524,8 @@ static struct inode *proc_pid_make_inode
6897 inode->i_gid = cred->egid;
6900 + /* procfs is xid tagged */
6901 + inode->i_tag = (tag_t)vx_task_xid(task);
6902 security_task_to_inode(task, inode);
6905 @@ -2067,6 +2076,13 @@ static struct dentry *proc_pident_lookup
6909 + /* TODO: maybe we can come up with a generic approach? */
6910 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6911 + (dentry->d_name.len == 5) &&
6912 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6913 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6917 * Yes, it does not scale. And it should not. Don't add
6918 * new entries into /proc/<tgid>/ without very good reasons.
6919 @@ -2474,7 +2490,7 @@ out_iput:
6920 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6922 struct dentry *error;
6923 - struct task_struct *task = get_proc_task(dir);
6924 + struct task_struct *task = get_proc_task_real(dir);
6925 const struct pid_entry *p, *last;
6927 error = ERR_PTR(-ENOENT);
6928 @@ -2564,6 +2580,9 @@ static int proc_pid_personality(struct s
6929 static const struct file_operations proc_task_operations;
6930 static const struct inode_operations proc_task_inode_operations;
6932 +extern int proc_pid_vx_info(struct task_struct *, char *);
6933 +extern int proc_pid_nx_info(struct task_struct *, char *);
6935 static const struct pid_entry tgid_base_stuff[] = {
6936 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6937 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6938 @@ -2623,6 +2642,8 @@ static const struct pid_entry tgid_base_
6939 #ifdef CONFIG_CGROUPS
6940 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6942 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6943 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6944 INF("oom_score", S_IRUGO, proc_oom_score),
6945 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6946 #ifdef CONFIG_AUDITSYSCALL
6947 @@ -2638,6 +2659,7 @@ static const struct pid_entry tgid_base_
6948 #ifdef CONFIG_TASK_IO_ACCOUNTING
6949 INF("io", S_IRUGO, proc_tgid_io_accounting),
6951 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6954 static int proc_tgid_base_readdir(struct file * filp,
6955 @@ -2829,7 +2851,7 @@ retry:
6957 pid = find_ge_pid(iter.tgid, ns);
6959 - iter.tgid = pid_nr_ns(pid, ns);
6960 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6961 iter.task = pid_task(pid, PIDTYPE_PID);
6962 /* What we to know is if the pid we have find is the
6963 * pid of a thread_group_leader. Testing for task
6964 @@ -2859,7 +2881,7 @@ static int proc_pid_fill_cache(struct fi
6965 struct tgid_iter iter)
6967 char name[PROC_NUMBUF];
6968 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6969 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6970 return proc_fill_cache(filp, dirent, filldir, name, len,
6971 proc_pid_instantiate, iter.task, NULL);
6973 @@ -2868,7 +2890,7 @@ static int proc_pid_fill_cache(struct fi
6974 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
6976 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6977 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
6978 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6979 struct tgid_iter iter;
6980 struct pid_namespace *ns;
6982 @@ -2888,6 +2910,8 @@ int proc_pid_readdir(struct file * filp,
6984 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6985 filp->f_pos = iter.tgid + TGID_OFFSET;
6986 + if (!vx_proc_task_visible(iter.task))
6988 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6989 put_task_struct(iter.task);
6991 @@ -3035,6 +3059,8 @@ static struct dentry *proc_task_lookup(s
6992 tid = name_to_int(dentry);
6995 + if (vx_current_initpid(tid))
6998 ns = dentry->d_sb->s_fs_info;
7000 diff -NurpP --minimal linux-2.6.35.7/fs/proc/generic.c linux-2.6.35.7-vs2.3.0.36.33/fs/proc/generic.c
7001 --- linux-2.6.35.7/fs/proc/generic.c 2010-08-02 16:52:51.000000000 +0200
7002 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/proc/generic.c 2010-08-02 17:05:06.000000000 +0200
7004 #include <linux/bitops.h>
7005 #include <linux/spinlock.h>
7006 #include <linux/completion.h>
7007 +#include <linux/vserver/inode.h>
7008 #include <asm/uaccess.h>
7010 #include "internal.h"
7011 @@ -418,6 +419,8 @@ struct dentry *proc_lookup_de(struct pro
7012 for (de = de->subdir; de ; de = de->next) {
7013 if (de->namelen != dentry->d_name.len)
7015 + if (!vx_hide_check(0, de->vx_flags))
7017 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
7020 @@ -426,6 +429,8 @@ struct dentry *proc_lookup_de(struct pro
7021 spin_unlock(&proc_subdir_lock);
7023 inode = proc_get_inode(dir->i_sb, ino, de);
7024 + /* generic proc entries belong to the host */
7029 @@ -503,6 +508,8 @@ int proc_readdir_de(struct proc_dir_entr
7031 /* filldir passes info to user space */
7033 + if (!vx_hide_check(0, de->vx_flags))
7035 spin_unlock(&proc_subdir_lock);
7036 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
7037 de->low_ino, de->mode >> 12) < 0) {
7038 @@ -510,6 +517,7 @@ int proc_readdir_de(struct proc_dir_entr
7041 spin_lock(&proc_subdir_lock);
7046 @@ -624,6 +632,7 @@ static struct proc_dir_entry *__proc_cre
7048 atomic_set(&ent->count, 1);
7050 + ent->vx_flags = IATTR_PROC_DEFAULT;
7051 spin_lock_init(&ent->pde_unload_lock);
7052 ent->pde_unload_completion = NULL;
7053 INIT_LIST_HEAD(&ent->pde_openers);
7054 @@ -647,7 +656,8 @@ struct proc_dir_entry *proc_symlink(cons
7060 + ent->vx_flags = IATTR_PROC_SYMLINK;
7064 diff -NurpP --minimal linux-2.6.35.7/fs/proc/inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/proc/inode.c
7065 --- linux-2.6.35.7/fs/proc/inode.c 2010-08-02 16:52:51.000000000 +0200
7066 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/proc/inode.c 2010-08-02 17:05:06.000000000 +0200
7067 @@ -437,6 +437,8 @@ struct inode *proc_get_inode(struct supe
7068 inode->i_uid = de->uid;
7069 inode->i_gid = de->gid;
7072 + PROC_I(inode)->vx_flags = de->vx_flags;
7074 inode->i_size = de->size;
7076 diff -NurpP --minimal linux-2.6.35.7/fs/proc/internal.h linux-2.6.35.7-vs2.3.0.36.33/fs/proc/internal.h
7077 --- linux-2.6.35.7/fs/proc/internal.h 2010-02-25 11:52:06.000000000 +0100
7078 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/proc/internal.h 2010-08-02 17:05:06.000000000 +0200
7082 #include <linux/proc_fs.h>
7083 +#include <linux/vs_pid.h>
7085 extern struct proc_dir_entry proc_root;
7086 #ifdef CONFIG_PROC_SYSCTL
7087 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
7088 struct pid *pid, struct task_struct *task);
7089 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7090 struct pid *pid, struct task_struct *task);
7091 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7092 + struct pid *pid, struct task_struct *task);
7094 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7096 extern const struct file_operations proc_maps_operations;
7097 @@ -68,11 +72,16 @@ static inline struct pid *proc_pid(struc
7098 return PROC_I(inode)->pid;
7101 -static inline struct task_struct *get_proc_task(struct inode *inode)
7102 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7104 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7107 +static inline struct task_struct *get_proc_task(struct inode *inode)
7109 + return vx_get_proc_task(inode, proc_pid(inode));
7112 static inline int proc_fd(struct inode *inode)
7114 return PROC_I(inode)->fd;
7115 diff -NurpP --minimal linux-2.6.35.7/fs/proc/loadavg.c linux-2.6.35.7-vs2.3.0.36.33/fs/proc/loadavg.c
7116 --- linux-2.6.35.7/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
7117 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/proc/loadavg.c 2010-08-02 17:05:06.000000000 +0200
7120 static int loadavg_proc_show(struct seq_file *m, void *v)
7122 + unsigned long running;
7123 + unsigned int threads;
7124 unsigned long avnrun[3];
7126 get_avenrun(avnrun, FIXED_1/200, 0);
7128 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7129 + struct vx_info *vxi = current_vx_info();
7131 + running = atomic_read(&vxi->cvirt.nr_running);
7132 + threads = atomic_read(&vxi->cvirt.nr_threads);
7134 + running = nr_running();
7135 + threads = nr_threads;
7138 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
7139 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
7140 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
7141 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
7142 - nr_running(), nr_threads,
7144 task_active_pid_ns(current)->last_pid);
7147 diff -NurpP --minimal linux-2.6.35.7/fs/proc/meminfo.c linux-2.6.35.7-vs2.3.0.36.33/fs/proc/meminfo.c
7148 --- linux-2.6.35.7/fs/proc/meminfo.c 2009-12-03 20:02:53.000000000 +0100
7149 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/proc/meminfo.c 2010-08-02 17:05:06.000000000 +0200
7150 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
7151 allowed = ((totalram_pages - hugetlb_total_pages())
7152 * sysctl_overcommit_ratio / 100) + total_swap_pages;
7154 - cached = global_page_state(NR_FILE_PAGES) -
7155 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
7156 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
7157 total_swapcache_pages - i.bufferram;
7160 diff -NurpP --minimal linux-2.6.35.7/fs/proc/root.c linux-2.6.35.7-vs2.3.0.36.33/fs/proc/root.c
7161 --- linux-2.6.35.7/fs/proc/root.c 2010-08-02 16:52:51.000000000 +0200
7162 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/proc/root.c 2010-08-02 17:05:06.000000000 +0200
7164 #include <linux/bitops.h>
7165 #include <linux/mount.h>
7166 #include <linux/pid_namespace.h>
7167 +#include <linux/vserver/inode.h>
7169 #include "internal.h"
7171 +struct proc_dir_entry *proc_virtual;
7173 +extern void proc_vx_init(void);
7175 static int proc_test_super(struct super_block *sb, void *data)
7177 return sb->s_fs_info == data;
7178 @@ -135,6 +140,7 @@ void __init proc_root_init(void)
7180 proc_mkdir("bus", NULL);
7185 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7186 @@ -202,6 +208,7 @@ struct proc_dir_entry proc_root = {
7187 .proc_iops = &proc_root_inode_operations,
7188 .proc_fops = &proc_root_operations,
7189 .parent = &proc_root,
7190 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7193 int pid_ns_prepare_proc(struct pid_namespace *ns)
7194 diff -NurpP --minimal linux-2.6.35.7/fs/proc/uptime.c linux-2.6.35.7-vs2.3.0.36.33/fs/proc/uptime.c
7195 --- linux-2.6.35.7/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
7196 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/proc/uptime.c 2010-08-02 17:05:06.000000000 +0200
7198 #include <linux/sched.h>
7199 #include <linux/seq_file.h>
7200 #include <linux/time.h>
7201 -#include <linux/kernel_stat.h>
7202 +#include <linux/vserver/cvirt.h>
7203 #include <asm/cputime.h>
7205 static int uptime_proc_show(struct seq_file *m, void *v)
7207 struct timespec uptime;
7208 struct timespec idle;
7210 - cputime_t idletime = cputime_zero;
7212 - for_each_possible_cpu(i)
7213 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
7214 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
7216 do_posix_clock_monotonic_gettime(&uptime);
7217 monotonic_to_bootbased(&uptime);
7218 cputime_to_timespec(idletime, &idle);
7220 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7221 + vx_vsi_uptime(&uptime, &idle);
7223 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
7224 (unsigned long) uptime.tv_sec,
7225 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7226 diff -NurpP --minimal linux-2.6.35.7/fs/quota/dquot.c linux-2.6.35.7-vs2.3.0.36.33/fs/quota/dquot.c
7227 --- linux-2.6.35.7/fs/quota/dquot.c 2010-08-02 16:52:51.000000000 +0200
7228 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/quota/dquot.c 2010-08-02 22:36:48.000000000 +0200
7229 @@ -1503,6 +1503,9 @@ int __dquot_alloc_space(struct inode *in
7230 int reserve = flags & DQUOT_SPACE_RESERVE;
7231 int nofail = flags & DQUOT_SPACE_NOFAIL;
7233 + if ((ret = dl_alloc_space(inode, number)))
7237 * First test before acquiring mutex - solves deadlocks when we
7238 * re-enter the quota code and are already holding the mutex
7239 @@ -1557,6 +1560,9 @@ int dquot_alloc_inode(const struct inode
7241 char warntype[MAXQUOTAS];
7243 + if ((ret = dl_alloc_inode(inode)))
7246 /* First test before acquiring mutex - solves deadlocks when we
7247 * re-enter the quota code and are already holding the mutex */
7248 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
7249 @@ -1627,6 +1633,8 @@ void __dquot_free_space(struct inode *in
7250 char warntype[MAXQUOTAS];
7251 int reserve = flags & DQUOT_SPACE_RESERVE;
7253 + dl_free_space(inode, number);
7255 /* First test before acquiring mutex - solves deadlocks when we
7256 * re-enter the quota code and are already holding the mutex */
7257 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
7258 @@ -1665,6 +1673,8 @@ void dquot_free_inode(const struct inode
7260 char warntype[MAXQUOTAS];
7262 + dl_free_inode(inode);
7264 /* First test before acquiring mutex - solves deadlocks when we
7265 * re-enter the quota code and are already holding the mutex */
7266 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
7267 diff -NurpP --minimal linux-2.6.35.7/fs/quota/quota.c linux-2.6.35.7-vs2.3.0.36.33/fs/quota/quota.c
7268 --- linux-2.6.35.7/fs/quota/quota.c 2010-08-02 16:52:51.000000000 +0200
7269 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/quota/quota.c 2010-08-02 17:05:06.000000000 +0200
7271 #include <linux/fs.h>
7272 #include <linux/namei.h>
7273 #include <linux/slab.h>
7274 +#include <linux/vs_context.h>
7275 #include <asm/current.h>
7276 #include <asm/uaccess.h>
7277 #include <linux/kernel.h>
7278 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
7282 - if (!capable(CAP_SYS_ADMIN))
7283 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7287 @@ -296,6 +297,46 @@ static int do_quotactl(struct super_bloc
7291 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7293 +#include <linux/vroot.h>
7294 +#include <linux/major.h>
7295 +#include <linux/module.h>
7296 +#include <linux/kallsyms.h>
7297 +#include <linux/vserver/debug.h>
7299 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7301 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7303 +int register_vroot_grb(vroot_grb_func *func) {
7306 + spin_lock(&vroot_grb_lock);
7307 + if (!vroot_get_real_bdev) {
7308 + vroot_get_real_bdev = func;
7311 + spin_unlock(&vroot_grb_lock);
7314 +EXPORT_SYMBOL(register_vroot_grb);
7316 +int unregister_vroot_grb(vroot_grb_func *func) {
7317 + int ret = -EINVAL;
7319 + spin_lock(&vroot_grb_lock);
7320 + if (vroot_get_real_bdev) {
7321 + vroot_get_real_bdev = NULL;
7324 + spin_unlock(&vroot_grb_lock);
7327 +EXPORT_SYMBOL(unregister_vroot_grb);
7332 * look up a superblock on which quota ops will be performed
7333 * - use the name of a block device to find the superblock thereon
7334 @@ -313,6 +354,22 @@ static struct super_block *quotactl_bloc
7337 return ERR_CAST(bdev);
7338 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7339 + if (bdev && bdev->bd_inode &&
7340 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7341 + struct block_device *bdnew = (void *)-EINVAL;
7343 + if (vroot_get_real_bdev)
7344 + bdnew = vroot_get_real_bdev(bdev);
7346 + vxdprintk(VXD_CBIT(misc, 0),
7347 + "vroot_get_real_bdev not set");
7349 + if (IS_ERR(bdnew))
7350 + return ERR_PTR(PTR_ERR(bdnew));
7354 sb = get_super(bdev);
7357 diff -NurpP --minimal linux-2.6.35.7/fs/reiserfs/file.c linux-2.6.35.7-vs2.3.0.36.33/fs/reiserfs/file.c
7358 --- linux-2.6.35.7/fs/reiserfs/file.c 2010-08-02 16:52:52.000000000 +0200
7359 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/reiserfs/file.c 2010-08-02 17:05:06.000000000 +0200
7360 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
7361 .listxattr = reiserfs_listxattr,
7362 .removexattr = reiserfs_removexattr,
7363 .permission = reiserfs_permission,
7364 + .sync_flags = reiserfs_sync_flags,
7366 diff -NurpP --minimal linux-2.6.35.7/fs/reiserfs/inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/reiserfs/inode.c
7367 --- linux-2.6.35.7/fs/reiserfs/inode.c 2010-08-02 16:52:52.000000000 +0200
7368 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/reiserfs/inode.c 2010-08-02 17:05:06.000000000 +0200
7370 #include <linux/writeback.h>
7371 #include <linux/quotaops.h>
7372 #include <linux/swap.h>
7373 +#include <linux/vs_tag.h>
7375 int reiserfs_commit_write(struct file *f, struct page *page,
7376 unsigned from, unsigned to);
7377 @@ -1125,6 +1126,8 @@ static void init_inode(struct inode *ino
7378 struct buffer_head *bh;
7379 struct item_head *ih;
7383 //int version = ITEM_VERSION_1;
7385 bh = PATH_PLAST_BUFFER(path);
7386 @@ -1146,12 +1149,13 @@ static void init_inode(struct inode *ino
7387 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7388 unsigned long blocks;
7390 + uid = sd_v1_uid(sd);
7391 + gid = sd_v1_gid(sd);
7393 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7394 set_inode_sd_version(inode, STAT_DATA_V1);
7395 inode->i_mode = sd_v1_mode(sd);
7396 inode->i_nlink = sd_v1_nlink(sd);
7397 - inode->i_uid = sd_v1_uid(sd);
7398 - inode->i_gid = sd_v1_gid(sd);
7399 inode->i_size = sd_v1_size(sd);
7400 inode->i_atime.tv_sec = sd_v1_atime(sd);
7401 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7402 @@ -1193,11 +1197,12 @@ static void init_inode(struct inode *ino
7403 // (directories and symlinks)
7404 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7406 + uid = sd_v2_uid(sd);
7407 + gid = sd_v2_gid(sd);
7409 inode->i_mode = sd_v2_mode(sd);
7410 inode->i_nlink = sd_v2_nlink(sd);
7411 - inode->i_uid = sd_v2_uid(sd);
7412 inode->i_size = sd_v2_size(sd);
7413 - inode->i_gid = sd_v2_gid(sd);
7414 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7415 inode->i_atime.tv_sec = sd_v2_atime(sd);
7416 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7417 @@ -1227,6 +1232,10 @@ static void init_inode(struct inode *ino
7418 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7421 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7422 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7423 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7426 if (S_ISREG(inode->i_mode)) {
7427 inode->i_op = &reiserfs_file_inode_operations;
7428 @@ -1249,13 +1258,15 @@ static void init_inode(struct inode *ino
7429 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7431 struct stat_data *sd_v2 = (struct stat_data *)sd;
7432 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7433 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7436 + set_sd_v2_uid(sd_v2, uid);
7437 + set_sd_v2_gid(sd_v2, gid);
7438 set_sd_v2_mode(sd_v2, inode->i_mode);
7439 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7440 - set_sd_v2_uid(sd_v2, inode->i_uid);
7441 set_sd_v2_size(sd_v2, size);
7442 - set_sd_v2_gid(sd_v2, inode->i_gid);
7443 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7444 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7445 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7446 @@ -2856,14 +2867,19 @@ int reiserfs_commit_write(struct file *f
7447 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7449 if (reiserfs_attrs(inode->i_sb)) {
7450 - if (sd_attrs & REISERFS_SYNC_FL)
7451 - inode->i_flags |= S_SYNC;
7453 - inode->i_flags &= ~S_SYNC;
7454 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7455 inode->i_flags |= S_IMMUTABLE;
7457 inode->i_flags &= ~S_IMMUTABLE;
7458 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7459 + inode->i_flags |= S_IXUNLINK;
7461 + inode->i_flags &= ~S_IXUNLINK;
7463 + if (sd_attrs & REISERFS_SYNC_FL)
7464 + inode->i_flags |= S_SYNC;
7466 + inode->i_flags &= ~S_SYNC;
7467 if (sd_attrs & REISERFS_APPEND_FL)
7468 inode->i_flags |= S_APPEND;
7470 @@ -2876,6 +2892,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7471 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7473 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7475 + if (sd_attrs & REISERFS_BARRIER_FL)
7476 + inode->i_vflags |= V_BARRIER;
7478 + inode->i_vflags &= ~V_BARRIER;
7479 + if (sd_attrs & REISERFS_COW_FL)
7480 + inode->i_vflags |= V_COW;
7482 + inode->i_vflags &= ~V_COW;
7486 @@ -2886,6 +2911,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7487 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7489 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7490 + if (inode->i_flags & S_IXUNLINK)
7491 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7493 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7495 if (inode->i_flags & S_SYNC)
7496 *sd_attrs |= REISERFS_SYNC_FL;
7498 @@ -2898,6 +2928,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7499 *sd_attrs |= REISERFS_NOTAIL_FL;
7501 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7503 + if (inode->i_vflags & V_BARRIER)
7504 + *sd_attrs |= REISERFS_BARRIER_FL;
7506 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7507 + if (inode->i_vflags & V_COW)
7508 + *sd_attrs |= REISERFS_COW_FL;
7510 + *sd_attrs &= ~REISERFS_COW_FL;
7514 @@ -3122,9 +3161,11 @@ int reiserfs_setattr(struct dentry *dent
7517 error = inode_change_ok(inode, attr);
7520 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7521 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7522 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7523 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7524 error = reiserfs_chown_xattrs(inode, attr);
7527 @@ -3153,6 +3194,9 @@ int reiserfs_setattr(struct dentry *dent
7528 inode->i_uid = attr->ia_uid;
7529 if (attr->ia_valid & ATTR_GID)
7530 inode->i_gid = attr->ia_gid;
7531 + if ((attr->ia_valid & ATTR_TAG) &&
7533 + inode->i_tag = attr->ia_tag;
7534 mark_inode_dirty(inode);
7536 journal_end(&th, inode->i_sb, jbegin_count);
7537 diff -NurpP --minimal linux-2.6.35.7/fs/reiserfs/ioctl.c linux-2.6.35.7-vs2.3.0.36.33/fs/reiserfs/ioctl.c
7538 --- linux-2.6.35.7/fs/reiserfs/ioctl.c 2010-02-25 11:52:06.000000000 +0100
7539 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/reiserfs/ioctl.c 2010-08-02 17:05:06.000000000 +0200
7541 #include <linux/mount.h>
7542 #include <linux/reiserfs_fs.h>
7543 #include <linux/time.h>
7544 +#include <linux/mount.h>
7545 #include <asm/uaccess.h>
7546 #include <linux/pagemap.h>
7547 #include <linux/smp_lock.h>
7548 #include <linux/compat.h>
7551 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7553 + __u16 sd_attrs = 0;
7555 + inode->i_flags = flags;
7556 + inode->i_vflags = vflags;
7558 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7559 + REISERFS_I(inode)->i_attrs = sd_attrs;
7560 + inode->i_ctime = CURRENT_TIME_SEC;
7561 + mark_inode_dirty(inode);
7566 * reiserfs_ioctl - handler for ioctl for inode
7567 * supported commands:
7569 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7571 struct inode *inode = filp->f_path.dentry->d_inode;
7572 - unsigned int flags;
7573 + unsigned int flags, oldflags;
7576 reiserfs_write_lock(inode->i_sb);
7577 @@ -48,6 +64,7 @@ long reiserfs_ioctl(struct file *filp, u
7579 flags = REISERFS_I(inode)->i_attrs;
7580 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7581 + flags &= REISERFS_FL_USER_VISIBLE;
7582 err = put_user(flags, (int __user *)arg);
7584 case REISERFS_IOC_SETFLAGS:{
7585 @@ -68,6 +85,10 @@ long reiserfs_ioctl(struct file *filp, u
7589 + if (IS_BARRIER(inode)) {
7590 + vxwprintk_task(1, "messing with the barrier.");
7594 * Is it quota file? Do not allow user to mess with it
7596 @@ -92,6 +113,10 @@ long reiserfs_ioctl(struct file *filp, u
7601 + oldflags = REISERFS_I(inode)->i_attrs;
7602 + flags &= REISERFS_FL_USER_MODIFIABLE;
7603 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7604 sd_attrs_to_i_attrs(flags, inode);
7605 REISERFS_I(inode)->i_attrs = flags;
7606 inode->i_ctime = CURRENT_TIME_SEC;
7607 diff -NurpP --minimal linux-2.6.35.7/fs/reiserfs/namei.c linux-2.6.35.7-vs2.3.0.36.33/fs/reiserfs/namei.c
7608 --- linux-2.6.35.7/fs/reiserfs/namei.c 2010-08-02 16:52:52.000000000 +0200
7609 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/reiserfs/namei.c 2010-08-02 17:05:06.000000000 +0200
7611 #include <linux/reiserfs_acl.h>
7612 #include <linux/reiserfs_xattr.h>
7613 #include <linux/quotaops.h>
7614 +#include <linux/vs_tag.h>
7616 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; }
7617 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7618 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7619 if (retval == IO_ERROR) {
7620 return ERR_PTR(-EIO);
7622 + dx_propagate_tag(nd, inode);
7624 return d_splice_alias(inode, dentry);
7626 @@ -1532,6 +1534,7 @@ const struct inode_operations reiserfs_d
7627 .listxattr = reiserfs_listxattr,
7628 .removexattr = reiserfs_removexattr,
7629 .permission = reiserfs_permission,
7630 + .sync_flags = reiserfs_sync_flags,
7634 diff -NurpP --minimal linux-2.6.35.7/fs/reiserfs/super.c linux-2.6.35.7-vs2.3.0.36.33/fs/reiserfs/super.c
7635 --- linux-2.6.35.7/fs/reiserfs/super.c 2010-08-02 16:52:52.000000000 +0200
7636 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/reiserfs/super.c 2010-08-02 17:05:06.000000000 +0200
7637 @@ -897,6 +897,14 @@ static int reiserfs_parse_options(struct
7638 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7639 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7641 +#ifndef CONFIG_TAGGING_NONE
7642 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7643 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7644 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7646 +#ifdef CONFIG_PROPAGATE
7647 + {"tag",.arg_required = 'T',.values = NULL},
7649 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7650 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7651 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7652 @@ -1206,6 +1214,14 @@ static int reiserfs_remount(struct super
7653 handle_quota_files(s, qf_names, &qfmt);
7656 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7657 + !(s->s_flags & MS_TAGGED)) {
7658 + reiserfs_warning(s, "super-vs01",
7659 + "reiserfs: tagging not permitted on remount.");
7666 /* Add options that are safe here */
7667 @@ -1688,6 +1704,10 @@ static int reiserfs_fill_super(struct su
7671 + /* map mount option tagxid */
7672 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7673 + s->s_flags |= MS_TAGGED;
7675 rs = SB_DISK_SUPER_BLOCK(s);
7676 /* Let's do basic sanity check to verify that underlying device is not
7677 smaller than the filesystem. If the check fails then abort and scream,
7678 diff -NurpP --minimal linux-2.6.35.7/fs/reiserfs/xattr.c linux-2.6.35.7-vs2.3.0.36.33/fs/reiserfs/xattr.c
7679 --- linux-2.6.35.7/fs/reiserfs/xattr.c 2010-08-02 16:52:52.000000000 +0200
7680 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/reiserfs/xattr.c 2010-08-02 17:05:06.000000000 +0200
7682 #include <linux/errno.h>
7683 #include <linux/gfp.h>
7684 #include <linux/fs.h>
7685 +#include <linux/mount.h>
7686 #include <linux/file.h>
7687 #include <linux/pagemap.h>
7688 #include <linux/xattr.h>
7689 diff -NurpP --minimal linux-2.6.35.7/fs/stat.c linux-2.6.35.7-vs2.3.0.36.33/fs/stat.c
7690 --- linux-2.6.35.7/fs/stat.c 2010-02-25 11:52:06.000000000 +0100
7691 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/stat.c 2010-08-02 17:05:06.000000000 +0200
7692 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7693 stat->nlink = inode->i_nlink;
7694 stat->uid = inode->i_uid;
7695 stat->gid = inode->i_gid;
7696 + stat->tag = inode->i_tag;
7697 stat->rdev = inode->i_rdev;
7698 stat->atime = inode->i_atime;
7699 stat->mtime = inode->i_mtime;
7700 diff -NurpP --minimal linux-2.6.35.7/fs/statfs.c linux-2.6.35.7-vs2.3.0.36.33/fs/statfs.c
7701 --- linux-2.6.35.7/fs/statfs.c 2010-08-02 16:52:52.000000000 +0200
7702 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/statfs.c 2010-08-02 19:10:27.000000000 +0200
7704 #include <linux/statfs.h>
7705 #include <linux/security.h>
7706 #include <linux/uaccess.h>
7707 +#include <linux/vs_base.h>
7708 +#include <linux/vs_dlimit.h>
7710 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
7712 int retval = -ENODEV;
7715 + struct super_block *sb = dentry->d_sb;
7718 - if (dentry->d_sb->s_op->statfs) {
7719 + if (sb->s_op->statfs) {
7720 memset(buf, 0, sizeof(*buf));
7721 retval = security_sb_statfs(dentry);
7724 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
7725 + retval = sb->s_op->statfs(dentry, buf);
7726 if (retval == 0 && buf->f_frsize == 0)
7727 buf->f_frsize = buf->f_bsize;
7729 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7730 + vx_vsi_statfs(sb, buf);
7734 diff -NurpP --minimal linux-2.6.35.7/fs/super.c linux-2.6.35.7-vs2.3.0.36.33/fs/super.c
7735 --- linux-2.6.35.7/fs/super.c 2010-10-04 08:57:39.000000000 +0200
7736 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/super.c 2010-08-14 18:20:34.000000000 +0200
7738 #include <linux/idr.h>
7739 #include <linux/mutex.h>
7740 #include <linux/backing-dev.h>
7741 +#include <linux/devpts_fs.h>
7742 +#include <linux/proc_fs.h>
7743 +#include <linux/vs_context.h>
7744 #include "internal.h"
7747 @@ -885,12 +888,18 @@ struct vfsmount *
7748 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
7750 struct vfsmount *mnt;
7751 + struct super_block *sb;
7752 char *secdata = NULL;
7756 return ERR_PTR(-ENODEV);
7759 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
7760 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
7764 mnt = alloc_vfsmnt(name);
7766 @@ -912,11 +921,19 @@ vfs_kern_mount(struct file_system_type *
7767 error = type->get_sb(type, flags, name, data, mnt);
7769 goto out_free_secdata;
7770 - BUG_ON(!mnt->mnt_sb);
7771 - WARN_ON(!mnt->mnt_sb->s_bdi);
7775 + WARN_ON(!sb->s_bdi);
7776 mnt->mnt_sb->s_flags |= MS_BORN;
7778 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
7780 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
7781 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7782 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7785 + error = security_sb_kern_mount(sb, flags, secdata);
7789 diff -NurpP --minimal linux-2.6.35.7/fs/sysfs/mount.c linux-2.6.35.7-vs2.3.0.36.33/fs/sysfs/mount.c
7790 --- linux-2.6.35.7/fs/sysfs/mount.c 2010-08-02 16:52:52.000000000 +0200
7791 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/sysfs/mount.c 2010-08-02 17:05:06.000000000 +0200
7792 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7794 sb->s_blocksize = PAGE_CACHE_SIZE;
7795 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7796 - sb->s_magic = SYSFS_MAGIC;
7797 + sb->s_magic = SYSFS_SUPER_MAGIC;
7798 sb->s_op = &sysfs_ops;
7799 sb->s_time_gran = 1;
7801 diff -NurpP --minimal linux-2.6.35.7/fs/utimes.c linux-2.6.35.7-vs2.3.0.36.33/fs/utimes.c
7802 --- linux-2.6.35.7/fs/utimes.c 2009-03-24 14:22:37.000000000 +0100
7803 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/utimes.c 2010-08-02 22:52:28.000000000 +0200
7805 #include <linux/stat.h>
7806 #include <linux/utime.h>
7807 #include <linux/syscalls.h>
7808 +#include <linux/mount.h>
7809 +#include <linux/vs_cowbl.h>
7810 #include <asm/uaccess.h>
7811 #include <asm/unistd.h>
7813 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7816 struct iattr newattrs;
7817 - struct inode *inode = path->dentry->d_inode;
7818 + struct inode *inode;
7820 error = mnt_want_write(path->mnt);
7824 + error = cow_check_and_break(path);
7826 + goto mnt_drop_write_and_out;
7828 + inode = path->dentry->d_inode;
7830 if (times && times[0].tv_nsec == UTIME_NOW &&
7831 times[1].tv_nsec == UTIME_NOW)
7833 diff -NurpP --minimal linux-2.6.35.7/fs/xattr.c linux-2.6.35.7-vs2.3.0.36.33/fs/xattr.c
7834 --- linux-2.6.35.7/fs/xattr.c 2010-08-02 16:52:52.000000000 +0200
7835 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xattr.c 2010-08-02 17:05:06.000000000 +0200
7837 #include <linux/module.h>
7838 #include <linux/fsnotify.h>
7839 #include <linux/audit.h>
7840 +#include <linux/mount.h>
7841 #include <asm/uaccess.h>
7844 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
7845 * The trusted.* namespace can only be accessed by a privileged user.
7847 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
7848 - return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
7849 + return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
7851 /* In user.* namespace, only regular files and directories can have
7852 * extended attributes. For sticky directories, only the owner and
7853 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/linux-2.6/xfs_ioctl.c
7854 --- linux-2.6.35.7/fs/xfs/linux-2.6/xfs_ioctl.c 2010-10-04 08:57:39.000000000 +0200
7855 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/linux-2.6/xfs_ioctl.c 2010-10-05 19:23:43.000000000 +0200
7857 #include "xfs_dir2_sf.h"
7858 #include "xfs_dinode.h"
7859 #include "xfs_inode.h"
7860 -#include "xfs_ioctl.h"
7861 #include "xfs_btree.h"
7862 #include "xfs_ialloc.h"
7863 #include "xfs_rtalloc.h"
7864 @@ -747,6 +746,10 @@ xfs_merge_ioc_xflags(
7865 xflags |= XFS_XFLAG_IMMUTABLE;
7867 xflags &= ~XFS_XFLAG_IMMUTABLE;
7868 + if (flags & FS_IXUNLINK_FL)
7869 + xflags |= XFS_XFLAG_IXUNLINK;
7871 + xflags &= ~XFS_XFLAG_IXUNLINK;
7872 if (flags & FS_APPEND_FL)
7873 xflags |= XFS_XFLAG_APPEND;
7875 @@ -775,6 +778,8 @@ xfs_di2lxflags(
7877 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7878 flags |= FS_IMMUTABLE_FL;
7879 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7880 + flags |= FS_IXUNLINK_FL;
7881 if (di_flags & XFS_DIFLAG_APPEND)
7882 flags |= FS_APPEND_FL;
7883 if (di_flags & XFS_DIFLAG_SYNC)
7884 @@ -835,6 +840,8 @@ xfs_set_diflags(
7885 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7886 if (xflags & XFS_XFLAG_IMMUTABLE)
7887 di_flags |= XFS_DIFLAG_IMMUTABLE;
7888 + if (xflags & XFS_XFLAG_IXUNLINK)
7889 + di_flags |= XFS_DIFLAG_IXUNLINK;
7890 if (xflags & XFS_XFLAG_APPEND)
7891 di_flags |= XFS_DIFLAG_APPEND;
7892 if (xflags & XFS_XFLAG_SYNC)
7893 @@ -877,6 +884,10 @@ xfs_diflags_to_linux(
7894 inode->i_flags |= S_IMMUTABLE;
7896 inode->i_flags &= ~S_IMMUTABLE;
7897 + if (xflags & XFS_XFLAG_IXUNLINK)
7898 + inode->i_flags |= S_IXUNLINK;
7900 + inode->i_flags &= ~S_IXUNLINK;
7901 if (xflags & XFS_XFLAG_APPEND)
7902 inode->i_flags |= S_APPEND;
7904 @@ -1353,10 +1364,18 @@ xfs_file_ioctl(
7905 case XFS_IOC_FSGETXATTRA:
7906 return xfs_ioc_fsgetxattr(ip, 1, arg);
7907 case XFS_IOC_FSSETXATTR:
7908 + if (IS_BARRIER(inode)) {
7909 + vxwprintk_task(1, "messing with the barrier.");
7910 + return -XFS_ERROR(EACCES);
7912 return xfs_ioc_fssetxattr(ip, filp, arg);
7913 case XFS_IOC_GETXFLAGS:
7914 return xfs_ioc_getxflags(ip, arg);
7915 case XFS_IOC_SETXFLAGS:
7916 + if (IS_BARRIER(inode)) {
7917 + vxwprintk_task(1, "messing with the barrier.");
7918 + return -XFS_ERROR(EACCES);
7920 return xfs_ioc_setxflags(ip, filp, arg);
7922 case XFS_IOC_FSSETDM: {
7923 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/linux-2.6/xfs_ioctl.h
7924 --- linux-2.6.35.7/fs/xfs/linux-2.6/xfs_ioctl.h 2010-07-07 18:31:54.000000000 +0200
7925 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/linux-2.6/xfs_ioctl.h 2010-08-02 17:05:06.000000000 +0200
7926 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7927 void __user *uhandle,
7932 + struct inode *inode,
7939 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/linux-2.6/xfs_iops.c
7940 --- linux-2.6.35.7/fs/xfs/linux-2.6/xfs_iops.c 2010-08-02 16:52:52.000000000 +0200
7941 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/linux-2.6/xfs_iops.c 2010-08-02 17:05:06.000000000 +0200
7943 #include "xfs_attr_sf.h"
7944 #include "xfs_dinode.h"
7945 #include "xfs_inode.h"
7946 +#include "xfs_ioctl.h"
7947 #include "xfs_bmap.h"
7948 #include "xfs_btree.h"
7949 #include "xfs_ialloc.h"
7951 #include <linux/falloc.h>
7952 #include <linux/fiemap.h>
7953 #include <linux/slab.h>
7954 +#include <linux/vs_tag.h>
7957 * Bring the timestamps in the XFS inode uptodate.
7958 @@ -507,6 +509,7 @@ xfs_vn_getattr(
7959 stat->nlink = ip->i_d.di_nlink;
7960 stat->uid = ip->i_d.di_uid;
7961 stat->gid = ip->i_d.di_gid;
7962 + stat->tag = ip->i_d.di_tag;
7963 stat->ino = ip->i_ino;
7964 stat->atime = inode->i_atime;
7965 stat->mtime = inode->i_mtime;
7966 @@ -711,6 +714,7 @@ static const struct inode_operations xfs
7967 .listxattr = xfs_vn_listxattr,
7968 .fallocate = xfs_vn_fallocate,
7969 .fiemap = xfs_vn_fiemap,
7970 + .sync_flags = xfs_sync_flags,
7973 static const struct inode_operations xfs_dir_inode_operations = {
7974 @@ -736,6 +740,7 @@ static const struct inode_operations xfs
7975 .getxattr = generic_getxattr,
7976 .removexattr = generic_removexattr,
7977 .listxattr = xfs_vn_listxattr,
7978 + .sync_flags = xfs_sync_flags,
7981 static const struct inode_operations xfs_dir_ci_inode_operations = {
7982 @@ -785,6 +790,10 @@ xfs_diflags_to_iflags(
7983 inode->i_flags |= S_IMMUTABLE;
7985 inode->i_flags &= ~S_IMMUTABLE;
7986 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7987 + inode->i_flags |= S_IXUNLINK;
7989 + inode->i_flags &= ~S_IXUNLINK;
7990 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7991 inode->i_flags |= S_APPEND;
7993 @@ -797,6 +806,15 @@ xfs_diflags_to_iflags(
7994 inode->i_flags |= S_NOATIME;
7996 inode->i_flags &= ~S_NOATIME;
7998 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7999 + inode->i_vflags |= V_BARRIER;
8001 + inode->i_vflags &= ~V_BARRIER;
8002 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
8003 + inode->i_vflags |= V_COW;
8005 + inode->i_vflags &= ~V_COW;
8009 @@ -825,6 +843,7 @@ xfs_setup_inode(
8010 inode->i_nlink = ip->i_d.di_nlink;
8011 inode->i_uid = ip->i_d.di_uid;
8012 inode->i_gid = ip->i_d.di_gid;
8013 + inode->i_tag = ip->i_d.di_tag;
8015 switch (inode->i_mode & S_IFMT) {
8017 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/linux-2.6/xfs_linux.h
8018 --- linux-2.6.35.7/fs/xfs/linux-2.6/xfs_linux.h 2010-07-07 18:31:54.000000000 +0200
8019 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/linux-2.6/xfs_linux.h 2010-08-02 17:05:06.000000000 +0200
8022 #define current_cpu() (raw_smp_processor_id())
8023 #define current_pid() (current->pid)
8024 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
8025 #define current_test_flags(f) (current->flags & (f))
8026 #define current_set_flags_nested(sp, f) \
8027 (*(sp) = current->flags, current->flags |= (f))
8028 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/linux-2.6/xfs_super.c linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/linux-2.6/xfs_super.c
8029 --- linux-2.6.35.7/fs/xfs/linux-2.6/xfs_super.c 2010-08-02 16:52:52.000000000 +0200
8030 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/linux-2.6/xfs_super.c 2010-08-02 18:00:35.000000000 +0200
8031 @@ -121,6 +121,9 @@ mempool_t *xfs_ioend_pool;
8032 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
8033 #define MNTOPT_DELAYLOG "delaylog" /* Delayed loging enabled */
8034 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed loging disabled */
8035 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
8036 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
8037 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
8040 * Table driven mount option parser.
8041 @@ -129,10 +132,14 @@ mempool_t *xfs_ioend_pool;
8042 * in the future, too.
8045 + Opt_tag, Opt_notag,
8046 Opt_barrier, Opt_nobarrier, Opt_err
8049 static const match_table_t tokens = {
8050 + {Opt_tag, "tagxid"},
8052 + {Opt_notag, "notag"},
8053 {Opt_barrier, "barrier"},
8054 {Opt_nobarrier, "nobarrier"},
8056 @@ -393,6 +400,19 @@ xfs_parseargs(
8057 } else if (!strcmp(this_char, "irixsgid")) {
8059 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
8060 +#ifndef CONFIG_TAGGING_NONE
8061 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8062 + mp->m_flags |= XFS_MOUNT_TAGGED;
8063 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
8064 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
8065 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
8066 + mp->m_flags |= XFS_MOUNT_TAGGED;
8068 +#ifdef CONFIG_PROPAGATE
8069 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8071 + mp->m_flags |= XFS_MOUNT_TAGGED;
8075 "XFS: unknown mount option [%s].", this_char);
8076 @@ -1376,6 +1396,16 @@ xfs_fs_remount(
8078 mp->m_flags &= ~XFS_MOUNT_BARRIER;
8081 + if (!(sb->s_flags & MS_TAGGED)) {
8083 + "XFS: %s: tagging not permitted on remount.\n",
8092 * Logically we would return an error here to prevent
8093 @@ -1610,6 +1640,9 @@ xfs_fs_fill_super(
8095 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
8097 + if (mp->m_flags & XFS_MOUNT_TAGGED)
8098 + sb->s_flags |= MS_TAGGED;
8100 sb->s_magic = XFS_SB_MAGIC;
8101 sb->s_blocksize = mp->m_sb.sb_blocksize;
8102 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
8103 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/xfs_dinode.h linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_dinode.h
8104 --- linux-2.6.35.7/fs/xfs/xfs_dinode.h 2009-06-11 17:13:09.000000000 +0200
8105 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_dinode.h 2010-08-02 17:05:06.000000000 +0200
8106 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
8107 __be32 di_gid; /* owner's group id */
8108 __be32 di_nlink; /* number of links to file */
8109 __be16 di_projid; /* owner's project id */
8110 - __u8 di_pad[8]; /* unused, zeroed space */
8111 + __be16 di_tag; /* context tagging */
8112 + __be16 di_vflags; /* vserver specific flags */
8113 + __u8 di_pad[4]; /* unused, zeroed space */
8114 __be16 di_flushiter; /* incremented on flush */
8115 xfs_timestamp_t di_atime; /* time last accessed */
8116 xfs_timestamp_t di_mtime; /* time last modified */
8117 @@ -183,6 +185,8 @@ static inline void xfs_dinode_put_rdev(s
8118 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
8119 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
8120 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
8121 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
8123 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
8124 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
8125 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
8126 @@ -198,6 +202,7 @@ static inline void xfs_dinode_put_rdev(s
8127 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8128 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8129 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8130 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8132 #ifdef CONFIG_XFS_RT
8133 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8134 @@ -210,6 +215,10 @@ static inline void xfs_dinode_put_rdev(s
8135 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8136 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8137 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8138 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8139 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8140 + XFS_DIFLAG_IXUNLINK)
8142 +#define XFS_DIVFLAG_BARRIER 0x01
8143 +#define XFS_DIVFLAG_COW 0x02
8145 #endif /* __XFS_DINODE_H__ */
8146 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/xfs_fs.h linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_fs.h
8147 --- linux-2.6.35.7/fs/xfs/xfs_fs.h 2010-07-07 18:31:54.000000000 +0200
8148 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_fs.h 2010-08-02 17:05:06.000000000 +0200
8149 @@ -67,6 +67,9 @@ struct fsxattr {
8150 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8151 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8152 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8153 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8154 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8155 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8156 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8159 @@ -293,7 +296,8 @@ typedef struct xfs_bstat {
8160 __u32 bs_gen; /* generation count */
8161 __u16 bs_projid; /* project id */
8162 __u16 bs_forkoff; /* inode fork offset in bytes */
8163 - unsigned char bs_pad[12]; /* pad space, unused */
8164 + __u16 bs_tag; /* context tagging */
8165 + unsigned char bs_pad[10]; /* pad space, unused */
8166 __u32 bs_dmevmask; /* DMIG event mask */
8167 __u16 bs_dmstate; /* DMIG state info */
8168 __u16 bs_aextents; /* attribute number of extents */
8169 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/xfs_ialloc.c linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_ialloc.c
8170 --- linux-2.6.35.7/fs/xfs/xfs_ialloc.c 2010-10-04 08:57:39.000000000 +0200
8171 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_ialloc.c 2010-09-22 02:52:29.000000000 +0200
8173 #include "xfs_error.h"
8174 #include "xfs_bmap.h"
8178 * Allocation group level functions.
8180 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/xfs_inode.c linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_inode.c
8181 --- linux-2.6.35.7/fs/xfs/xfs_inode.c 2010-10-04 08:57:39.000000000 +0200
8182 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_inode.c 2010-09-22 02:52:29.000000000 +0200
8183 @@ -249,6 +249,7 @@ xfs_inotobp(
8187 +#include <linux/vs_tag.h>
8190 * This routine is called to map an inode to the buffer containing
8191 @@ -654,15 +655,25 @@ xfs_iformat_btree(
8193 xfs_dinode_from_disk(
8195 - xfs_dinode_t *from)
8196 + xfs_dinode_t *from,
8199 + uint32_t uid, gid, tag;
8201 to->di_magic = be16_to_cpu(from->di_magic);
8202 to->di_mode = be16_to_cpu(from->di_mode);
8203 to->di_version = from ->di_version;
8204 to->di_format = from->di_format;
8205 to->di_onlink = be16_to_cpu(from->di_onlink);
8206 - to->di_uid = be32_to_cpu(from->di_uid);
8207 - to->di_gid = be32_to_cpu(from->di_gid);
8209 + uid = be32_to_cpu(from->di_uid);
8210 + gid = be32_to_cpu(from->di_gid);
8211 + tag = be16_to_cpu(from->di_tag);
8213 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8214 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8215 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8217 to->di_nlink = be32_to_cpu(from->di_nlink);
8218 to->di_projid = be16_to_cpu(from->di_projid);
8219 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8220 @@ -683,21 +694,26 @@ xfs_dinode_from_disk(
8221 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8222 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8223 to->di_flags = be16_to_cpu(from->di_flags);
8224 + to->di_vflags = be16_to_cpu(from->di_vflags);
8225 to->di_gen = be32_to_cpu(from->di_gen);
8231 - xfs_icdinode_t *from)
8232 + xfs_icdinode_t *from,
8235 to->di_magic = cpu_to_be16(from->di_magic);
8236 to->di_mode = cpu_to_be16(from->di_mode);
8237 to->di_version = from ->di_version;
8238 to->di_format = from->di_format;
8239 to->di_onlink = cpu_to_be16(from->di_onlink);
8240 - to->di_uid = cpu_to_be32(from->di_uid);
8241 - to->di_gid = cpu_to_be32(from->di_gid);
8243 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8244 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8245 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8247 to->di_nlink = cpu_to_be32(from->di_nlink);
8248 to->di_projid = cpu_to_be16(from->di_projid);
8249 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8250 @@ -718,12 +734,14 @@ xfs_dinode_to_disk(
8251 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8252 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8253 to->di_flags = cpu_to_be16(from->di_flags);
8254 + to->di_vflags = cpu_to_be16(from->di_vflags);
8255 to->di_gen = cpu_to_be32(from->di_gen);
8260 - __uint16_t di_flags)
8261 + __uint16_t di_flags,
8262 + __uint16_t di_vflags)
8266 @@ -734,6 +752,8 @@ _xfs_dic2xflags(
8267 flags |= XFS_XFLAG_PREALLOC;
8268 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8269 flags |= XFS_XFLAG_IMMUTABLE;
8270 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8271 + flags |= XFS_XFLAG_IXUNLINK;
8272 if (di_flags & XFS_DIFLAG_APPEND)
8273 flags |= XFS_XFLAG_APPEND;
8274 if (di_flags & XFS_DIFLAG_SYNC)
8275 @@ -758,6 +778,10 @@ _xfs_dic2xflags(
8276 flags |= XFS_XFLAG_FILESTREAM;
8279 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8280 + flags |= FS_BARRIER_FL;
8281 + if (di_vflags & XFS_DIVFLAG_COW)
8282 + flags |= FS_COW_FL;
8286 @@ -767,7 +791,7 @@ xfs_ip2xflags(
8288 xfs_icdinode_t *dic = &ip->i_d;
8290 - return _xfs_dic2xflags(dic->di_flags) |
8291 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8292 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8295 @@ -775,7 +799,8 @@ uint
8299 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8300 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8301 + be16_to_cpu(dip->di_vflags)) |
8302 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8305 @@ -808,7 +833,6 @@ xfs_iread(
8308 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8311 * If we got something that isn't an inode it means someone
8312 * (nfs or dmi) has a stale handle.
8313 @@ -833,7 +857,8 @@ xfs_iread(
8314 * Otherwise, just get the truly permanent information.
8317 - xfs_dinode_from_disk(&ip->i_d, dip);
8318 + xfs_dinode_from_disk(&ip->i_d, dip,
8319 + mp->m_flags & XFS_MOUNT_TAGGED);
8320 error = xfs_iformat(ip, dip);
8323 @@ -1033,6 +1058,7 @@ xfs_ialloc(
8324 ASSERT(ip->i_d.di_nlink == nlink);
8325 ip->i_d.di_uid = current_fsuid();
8326 ip->i_d.di_gid = current_fsgid();
8327 + ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
8328 ip->i_d.di_projid = prid;
8329 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8331 @@ -1093,6 +1119,7 @@ xfs_ialloc(
8332 ip->i_d.di_dmevmask = 0;
8333 ip->i_d.di_dmstate = 0;
8334 ip->i_d.di_flags = 0;
8335 + ip->i_d.di_vflags = 0;
8336 flags = XFS_ILOG_CORE;
8337 switch (mode & S_IFMT) {
8339 @@ -2119,6 +2146,7 @@ xfs_ifree(
8341 ip->i_d.di_mode = 0; /* mark incore inode as free */
8342 ip->i_d.di_flags = 0;
8343 + ip->i_d.di_vflags = 0;
8344 ip->i_d.di_dmevmask = 0;
8345 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8346 ip->i_df.if_ext_max =
8347 @@ -2988,7 +3016,8 @@ xfs_iflush_int(
8348 * because if the inode is dirty at all the core must
8351 - xfs_dinode_to_disk(dip, &ip->i_d);
8352 + xfs_dinode_to_disk(dip, &ip->i_d,
8353 + mp->m_flags & XFS_MOUNT_TAGGED);
8355 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8356 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8357 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/xfs_inode.h linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_inode.h
8358 --- linux-2.6.35.7/fs/xfs/xfs_inode.h 2010-08-02 16:52:53.000000000 +0200
8359 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_inode.h 2010-08-02 17:05:06.000000000 +0200
8360 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
8361 __uint32_t di_gid; /* owner's group id */
8362 __uint32_t di_nlink; /* number of links to file */
8363 __uint16_t di_projid; /* owner's project id */
8364 - __uint8_t di_pad[8]; /* unused, zeroed space */
8365 + __uint16_t di_tag; /* context tagging */
8366 + __uint16_t di_vflags; /* vserver specific flags */
8367 + __uint8_t di_pad[4]; /* unused, zeroed space */
8368 __uint16_t di_flushiter; /* incremented on flush */
8369 xfs_ictimestamp_t di_atime; /* time last accessed */
8370 xfs_ictimestamp_t di_mtime; /* time last modified */
8371 @@ -511,7 +513,7 @@ int xfs_itobp(struct xfs_mount *, struc
8372 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8373 struct xfs_inode *, uint);
8374 void xfs_dinode_to_disk(struct xfs_dinode *,
8375 - struct xfs_icdinode *);
8376 + struct xfs_icdinode *, int);
8377 void xfs_idestroy_fork(struct xfs_inode *, int);
8378 void xfs_idata_realloc(struct xfs_inode *, int, int);
8379 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8380 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/xfs_itable.c linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_itable.c
8381 --- linux-2.6.35.7/fs/xfs/xfs_itable.c 2010-08-02 16:52:53.000000000 +0200
8382 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_itable.c 2010-08-02 17:05:06.000000000 +0200
8383 @@ -100,6 +100,7 @@ xfs_bulkstat_one_int(
8384 buf->bs_mode = dic->di_mode;
8385 buf->bs_uid = dic->di_uid;
8386 buf->bs_gid = dic->di_gid;
8387 + buf->bs_tag = dic->di_tag;
8388 buf->bs_size = dic->di_size;
8391 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/xfs_log_recover.c linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_log_recover.c
8392 --- linux-2.6.35.7/fs/xfs/xfs_log_recover.c 2010-08-02 16:52:53.000000000 +0200
8393 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_log_recover.c 2010-08-02 17:05:06.000000000 +0200
8394 @@ -2461,7 +2461,8 @@ xlog_recover_do_inode_trans(
8397 /* The core is in in-core format */
8398 - xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
8399 + xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
8400 + mp->m_flags & XFS_MOUNT_TAGGED);
8402 /* the rest is in on-disk format */
8403 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8404 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/xfs_mount.h linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_mount.h
8405 --- linux-2.6.35.7/fs/xfs/xfs_mount.h 2010-08-02 16:52:53.000000000 +0200
8406 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_mount.h 2010-08-02 17:05:06.000000000 +0200
8407 @@ -302,6 +302,7 @@ typedef struct xfs_mount {
8409 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8411 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8414 * Default minimum read and write sizes.
8415 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/xfs_vnodeops.c linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_vnodeops.c
8416 --- linux-2.6.35.7/fs/xfs/xfs_vnodeops.c 2010-08-02 16:52:53.000000000 +0200
8417 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_vnodeops.c 2010-08-02 17:05:06.000000000 +0200
8419 #include "xfs_vnodeops.h"
8420 #include "xfs_trace.h"
8424 +xfs_get_inode_flags(
8427 + struct inode *inode = VFS_I(ip);
8428 + unsigned int flags = inode->i_flags;
8429 + unsigned int vflags = inode->i_vflags;
8431 + if (flags & S_IMMUTABLE)
8432 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8434 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8435 + if (flags & S_IXUNLINK)
8436 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8438 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8440 + if (vflags & V_BARRIER)
8441 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8443 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8444 + if (vflags & V_COW)
8445 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8447 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8452 + struct inode *inode,
8456 + struct xfs_inode *ip = XFS_I(inode);
8457 + struct xfs_mount *mp = ip->i_mount;
8458 + struct xfs_trans *tp;
8459 + unsigned int lock_flags = 0;
8462 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8463 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8467 + lock_flags = XFS_ILOCK_EXCL;
8468 + xfs_ilock(ip, lock_flags);
8470 + xfs_trans_ijoin(tp, ip, lock_flags);
8471 + xfs_trans_ihold(tp, ip);
8473 + inode->i_flags = flags;
8474 + inode->i_vflags = vflags;
8475 + xfs_get_inode_flags(ip);
8477 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8478 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
8480 + XFS_STATS_INC(xs_ig_attrchg);
8482 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8483 + xfs_trans_set_sync(tp);
8484 + code = xfs_trans_commit(tp, 0);
8485 + xfs_iunlock(ip, lock_flags);
8489 + xfs_trans_cancel(tp, 0);
8491 + xfs_iunlock(ip, lock_flags);
8498 struct xfs_inode *ip,
8499 @@ -70,6 +144,7 @@ xfs_setattr(
8500 uint commit_flags=0;
8501 uid_t uid=0, iuid=0;
8502 gid_t gid=0, igid=0;
8503 + tag_t tag=0, itag=0;
8504 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8505 int need_iolock = 1;
8507 @@ -162,7 +237,7 @@ xfs_setattr(
8509 * Change file ownership. Must be the owner or privileged.
8511 - if (mask & (ATTR_UID|ATTR_GID)) {
8512 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8514 * These IDs could have changed since we last looked at them.
8515 * But, we're assured that if the ownership did change
8516 @@ -171,8 +246,10 @@ xfs_setattr(
8518 iuid = ip->i_d.di_uid;
8519 igid = ip->i_d.di_gid;
8520 + itag = ip->i_d.di_tag;
8521 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8522 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8523 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8526 * Do a quota reservation only if uid/gid is actually
8527 @@ -180,7 +257,8 @@ xfs_setattr(
8529 if (XFS_IS_QUOTA_RUNNING(mp) &&
8530 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8531 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
8532 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8533 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
8535 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
8536 capable(CAP_FOWNER) ?
8537 @@ -341,7 +419,7 @@ xfs_setattr(
8539 * Change file ownership. Must be the owner or privileged.
8541 - if (mask & (ATTR_UID|ATTR_GID)) {
8542 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8544 * CAP_FSETID overrides the following restrictions:
8546 @@ -357,6 +435,10 @@ xfs_setattr(
8547 * Change the ownerships and register quota modifications
8548 * in the transaction.
8550 + if (itag != tag) {
8551 + ip->i_d.di_tag = tag;
8552 + inode->i_tag = tag;
8555 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
8556 ASSERT(mask & ATTR_UID);
8557 diff -NurpP --minimal linux-2.6.35.7/fs/xfs/xfs_vnodeops.h linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_vnodeops.h
8558 --- linux-2.6.35.7/fs/xfs/xfs_vnodeops.h 2010-07-07 18:31:54.000000000 +0200
8559 +++ linux-2.6.35.7-vs2.3.0.36.33/fs/xfs/xfs_vnodeops.h 2010-08-02 17:05:06.000000000 +0200
8560 @@ -14,6 +14,7 @@ struct xfs_inode;
8564 +int xfs_sync_xflags(struct xfs_inode *ip);
8565 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8566 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8567 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8568 diff -NurpP --minimal linux-2.6.35.7/include/asm-generic/tlb.h linux-2.6.35.7-vs2.3.0.36.33/include/asm-generic/tlb.h
8569 --- linux-2.6.35.7/include/asm-generic/tlb.h 2009-09-10 15:26:24.000000000 +0200
8570 +++ linux-2.6.35.7-vs2.3.0.36.33/include/asm-generic/tlb.h 2010-08-02 17:05:06.000000000 +0200
8572 #define _ASM_GENERIC__TLB_H
8574 #include <linux/swap.h>
8575 +#include <linux/vs_memory.h>
8576 #include <asm/pgalloc.h>
8577 #include <asm/tlbflush.h>
8579 diff -NurpP --minimal linux-2.6.35.7/include/linux/capability.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/capability.h
8580 --- linux-2.6.35.7/include/linux/capability.h 2010-02-25 11:52:07.000000000 +0100
8581 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/capability.h 2010-08-02 17:05:06.000000000 +0200
8582 @@ -283,6 +283,7 @@ struct cpu_vfs_cap_data {
8583 arbitrary SCSI commands */
8584 /* Allow setting encryption key on loopback filesystem */
8585 /* Allow setting zone reclaim policy */
8586 +/* Allow the selection of a security context */
8588 #define CAP_SYS_ADMIN 21
8590 @@ -355,7 +356,13 @@ struct cpu_vfs_cap_data {
8592 #define CAP_MAC_ADMIN 33
8594 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8595 +/* Allow context manipulations */
8596 +/* Allow changing context info on files */
8598 +#define CAP_CONTEXT 34
8601 +#define CAP_LAST_CAP CAP_CONTEXT
8603 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8605 diff -NurpP --minimal linux-2.6.35.7/include/linux/devpts_fs.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/devpts_fs.h
8606 --- linux-2.6.35.7/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8607 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/devpts_fs.h 2010-08-02 17:05:06.000000000 +0200
8608 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8613 #endif /* _LINUX_DEVPTS_FS_H */
8614 diff -NurpP --minimal linux-2.6.35.7/include/linux/ext2_fs.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/ext2_fs.h
8615 --- linux-2.6.35.7/include/linux/ext2_fs.h 2010-02-25 11:52:07.000000000 +0100
8616 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/ext2_fs.h 2010-08-02 17:05:06.000000000 +0200
8617 @@ -189,8 +189,12 @@ struct ext2_group_desc
8618 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8619 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8620 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8621 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8622 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8624 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8625 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8627 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8628 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8630 @@ -274,7 +278,8 @@ struct ext2_inode {
8632 __le16 l_i_uid_high; /* these 2 fields */
8633 __le16 l_i_gid_high; /* were reserved2[0] */
8634 - __u32 l_i_reserved2;
8635 + __le16 l_i_tag; /* Context Tag */
8636 + __u16 l_i_reserved2;
8639 __u8 h_i_frag; /* Fragment number */
8640 @@ -303,6 +308,7 @@ struct ext2_inode {
8641 #define i_gid_low i_gid
8642 #define i_uid_high osd2.linux2.l_i_uid_high
8643 #define i_gid_high osd2.linux2.l_i_gid_high
8644 +#define i_raw_tag osd2.linux2.l_i_tag
8645 #define i_reserved2 osd2.linux2.l_i_reserved2
8648 @@ -347,6 +353,7 @@ struct ext2_inode {
8649 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8650 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8651 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8652 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8655 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8656 diff -NurpP --minimal linux-2.6.35.7/include/linux/ext3_fs.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/ext3_fs.h
8657 --- linux-2.6.35.7/include/linux/ext3_fs.h 2010-08-02 16:52:54.000000000 +0200
8658 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/ext3_fs.h 2010-08-02 17:05:06.000000000 +0200
8659 @@ -173,10 +173,14 @@ struct ext3_group_desc
8660 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8661 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8662 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8663 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8664 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8666 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8667 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8668 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8669 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8671 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8672 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8674 /* Flags that should be inherited by new inodes from their parent. */
8675 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8676 @@ -312,7 +316,8 @@ struct ext3_inode {
8678 __le16 l_i_uid_high; /* these 2 fields */
8679 __le16 l_i_gid_high; /* were reserved2[0] */
8680 - __u32 l_i_reserved2;
8681 + __le16 l_i_tag; /* Context Tag */
8682 + __u16 l_i_reserved2;
8685 __u8 h_i_frag; /* Fragment number */
8686 @@ -343,6 +348,7 @@ struct ext3_inode {
8687 #define i_gid_low i_gid
8688 #define i_uid_high osd2.linux2.l_i_uid_high
8689 #define i_gid_high osd2.linux2.l_i_gid_high
8690 +#define i_raw_tag osd2.linux2.l_i_tag
8691 #define i_reserved2 osd2.linux2.l_i_reserved2
8693 #elif defined(__GNU__)
8694 @@ -406,6 +412,7 @@ struct ext3_inode {
8695 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8696 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8697 * error in ordered mode */
8698 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8700 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8701 #ifndef _LINUX_EXT2_FS_H
8702 @@ -909,6 +916,7 @@ extern void ext3_get_inode_flags(struct
8703 extern void ext3_set_aops(struct inode *inode);
8704 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8705 u64 start, u64 len);
8706 +extern int ext3_sync_flags(struct inode *, int, int);
8709 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8710 diff -NurpP --minimal linux-2.6.35.7/include/linux/fs.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/fs.h
8711 --- linux-2.6.35.7/include/linux/fs.h 2010-10-04 08:57:39.000000000 +0200
8712 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/fs.h 2010-09-22 02:52:29.000000000 +0200
8713 @@ -209,6 +209,9 @@ struct inodes_stat_t {
8714 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8715 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8716 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8717 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8718 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8719 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8720 #define MS_BORN (1<<29)
8721 #define MS_ACTIVE (1<<30)
8722 #define MS_NOUSER (1<<31)
8723 @@ -236,6 +239,14 @@ struct inodes_stat_t {
8724 #define S_NOCMTIME 128 /* Do not update file c/mtime */
8725 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
8726 #define S_PRIVATE 512 /* Inode is fs-internal */
8727 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
8729 +/* Linux-VServer related Inode flags */
8733 +#define V_BARRIER 4 /* Barrier for chroot() */
8734 +#define V_COW 8 /* Copy on Write */
8737 * Note that nosuid etc flags are inode-specific: setting some file-system
8738 @@ -258,12 +269,15 @@ struct inodes_stat_t {
8739 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8740 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8741 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8742 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8743 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8744 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8745 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8746 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8748 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8749 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8750 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8751 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8752 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8753 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8755 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8756 @@ -271,6 +285,16 @@ struct inodes_stat_t {
8757 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
8758 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
8760 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8762 +#ifdef CONFIG_VSERVER_COWBL
8763 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8764 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8766 +# define IS_COW(inode) (0)
8767 +# define IS_COW_LINK(inode) (0)
8770 /* the read-only stuff doesn't really belong here, but any other place is
8771 probably as bad and I don't want to create yet another include file. */
8773 @@ -353,11 +377,14 @@ struct inodes_stat_t {
8774 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8775 #define FS_EXTENT_FL 0x00080000 /* Extents */
8776 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8777 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8778 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8780 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8781 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8782 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8783 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8785 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8786 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8788 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8789 #define SYNC_FILE_RANGE_WRITE 2
8790 @@ -440,6 +467,7 @@ typedef void (dio_iodone_t)(struct kiocb
8791 #define ATTR_KILL_PRIV (1 << 14)
8792 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8793 #define ATTR_TIMES_SET (1 << 16)
8794 +#define ATTR_TAG (1 << 17)
8797 * This is the Inode Attributes structure, used for notify_change(). It
8798 @@ -455,6 +483,7 @@ struct iattr {
8804 struct timespec ia_atime;
8805 struct timespec ia_mtime;
8806 @@ -468,6 +497,9 @@ struct iattr {
8807 struct file *ia_file;
8810 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8811 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8814 * Includes for diskquotas.
8816 @@ -734,7 +766,9 @@ struct inode {
8817 unsigned int i_nlink;
8823 unsigned int i_blkbits;
8826 @@ -781,7 +815,8 @@ struct inode {
8827 unsigned long i_state;
8828 unsigned long dirtied_when; /* jiffies of first dirtying */
8830 - unsigned int i_flags;
8831 + unsigned short i_flags;
8832 + unsigned short i_vflags;
8834 atomic_t i_writecount;
8835 #ifdef CONFIG_SECURITY
8836 @@ -869,12 +904,12 @@ static inline void i_size_write(struct i
8838 static inline unsigned iminor(const struct inode *inode)
8840 - return MINOR(inode->i_rdev);
8841 + return MINOR(inode->i_mdev);
8844 static inline unsigned imajor(const struct inode *inode)
8846 - return MAJOR(inode->i_rdev);
8847 + return MAJOR(inode->i_mdev);
8850 extern struct block_device *I_BDEV(struct inode *inode);
8851 @@ -933,6 +968,7 @@ struct file {
8853 struct fown_struct f_owner;
8854 const struct cred *f_cred;
8856 struct file_ra_state f_ra;
8859 @@ -1075,6 +1111,7 @@ struct file_lock {
8860 struct file *fl_file;
8865 struct fasync_struct * fl_fasync; /* for lease break notifications */
8866 unsigned long fl_break_time; /* for nonblocking lease breaks */
8867 @@ -1536,6 +1573,7 @@ struct inode_operations {
8868 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8869 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8870 int (*removexattr) (struct dentry *, const char *);
8871 + int (*sync_flags) (struct inode *, int, int);
8872 void (*truncate_range)(struct inode *, loff_t, loff_t);
8873 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
8875 @@ -1556,6 +1594,7 @@ extern ssize_t vfs_readv(struct file *,
8876 unsigned long, loff_t *);
8877 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8878 unsigned long, loff_t *);
8879 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8881 struct super_operations {
8882 struct inode *(*alloc_inode)(struct super_block *sb);
8883 @@ -2379,6 +2418,7 @@ extern int dcache_dir_open(struct inode
8884 extern int dcache_dir_close(struct inode *, struct file *);
8885 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8886 extern int dcache_readdir(struct file *, void *, filldir_t);
8887 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8888 extern int simple_setattr(struct dentry *, struct iattr *);
8889 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8890 extern int simple_statfs(struct dentry *, struct kstatfs *);
8891 diff -NurpP --minimal linux-2.6.35.7/include/linux/gfs2_ondisk.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/gfs2_ondisk.h
8892 --- linux-2.6.35.7/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
8893 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/gfs2_ondisk.h 2010-08-02 17:05:06.000000000 +0200
8894 @@ -211,6 +211,9 @@ enum {
8898 + gfs2fl_IXUnlink = 16,
8899 + gfs2fl_Barrier = 17,
8901 gfs2fl_TruncInProg = 29,
8902 gfs2fl_InheritDirectio = 30,
8903 gfs2fl_InheritJdata = 31,
8904 @@ -227,6 +230,9 @@ enum {
8905 #define GFS2_DIF_NOATIME 0x00000080
8906 #define GFS2_DIF_SYNC 0x00000100
8907 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8908 +#define GFS2_DIF_IXUNLINK 0x00010000
8909 +#define GFS2_DIF_BARRIER 0x00020000
8910 +#define GFS2_DIF_COW 0x00040000
8911 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8912 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8913 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8914 diff -NurpP --minimal linux-2.6.35.7/include/linux/if_tun.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/if_tun.h
8915 --- linux-2.6.35.7/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8916 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/if_tun.h 2010-08-02 18:17:46.000000000 +0200
8918 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8919 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8920 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8921 +#define TUNSETNID _IOW('T', 217, int)
8923 /* TUNSETIFF ifr flags */
8924 #define IFF_TUN 0x0001
8925 diff -NurpP --minimal linux-2.6.35.7/include/linux/init_task.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/init_task.h
8926 --- linux-2.6.35.7/include/linux/init_task.h 2010-08-02 16:52:54.000000000 +0200
8927 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/init_task.h 2010-08-02 17:05:06.000000000 +0200
8928 @@ -172,6 +172,10 @@ extern struct cred init_cred;
8930 INIT_TRACE_RECURSION \
8931 INIT_TASK_RCU_PREEMPT(tsk) \
8933 + .vx_info = NULL, \
8935 + .nx_info = NULL, \
8939 diff -NurpP --minimal linux-2.6.35.7/include/linux/ipc.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/ipc.h
8940 --- linux-2.6.35.7/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8941 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/ipc.h 2010-08-02 17:05:06.000000000 +0200
8942 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8950 diff -NurpP --minimal linux-2.6.35.7/include/linux/Kbuild linux-2.6.35.7-vs2.3.0.36.33/include/linux/Kbuild
8951 --- linux-2.6.35.7/include/linux/Kbuild 2010-10-04 08:57:39.000000000 +0200
8952 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/Kbuild 2010-08-14 18:19:32.000000000 +0200
8953 @@ -388,5 +388,8 @@ unifdef-y += xattr.h
8956 objhdr-y += version.h
8958 +header-y += vserver/
8962 diff -NurpP --minimal linux-2.6.35.7/include/linux/loop.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/loop.h
8963 --- linux-2.6.35.7/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
8964 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/loop.h 2010-08-02 17:05:06.000000000 +0200
8965 @@ -45,6 +45,7 @@ struct loop_device {
8966 struct loop_func_table *lo_encryption;
8968 uid_t lo_key_owner; /* Who set the key */
8970 int (*ioctl)(struct loop_device *, int cmd,
8973 diff -NurpP --minimal linux-2.6.35.7/include/linux/magic.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/magic.h
8974 --- linux-2.6.35.7/include/linux/magic.h 2010-07-07 18:31:55.000000000 +0200
8975 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/magic.h 2010-08-02 17:05:06.000000000 +0200
8978 #define ADFS_SUPER_MAGIC 0xadf5
8979 #define AFFS_SUPER_MAGIC 0xadff
8980 -#define AFS_SUPER_MAGIC 0x5346414F
8981 +#define AFS_SUPER_MAGIC 0x5346414F
8982 #define AUTOFS_SUPER_MAGIC 0x0187
8983 #define CODA_SUPER_MAGIC 0x73757245
8984 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8986 #define NFS_SUPER_MAGIC 0x6969
8987 #define OPENPROM_SUPER_MAGIC 0x9fa1
8988 #define PROC_SUPER_MAGIC 0x9fa0
8989 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8990 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8992 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8993 diff -NurpP --minimal linux-2.6.35.7/include/linux/major.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/major.h
8994 --- linux-2.6.35.7/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8995 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/major.h 2010-08-02 17:05:06.000000000 +0200
8997 #define HD_MAJOR IDE0_MAJOR
8998 #define PTY_SLAVE_MAJOR 3
9000 +#define VROOT_MAJOR 4
9001 #define TTYAUX_MAJOR 5
9004 diff -NurpP --minimal linux-2.6.35.7/include/linux/memcontrol.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/memcontrol.h
9005 --- linux-2.6.35.7/include/linux/memcontrol.h 2010-08-02 16:52:54.000000000 +0200
9006 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/memcontrol.h 2010-10-08 11:20:18.000000000 +0200
9007 @@ -77,6 +77,13 @@ int task_in_mem_cgroup(struct task_struc
9008 extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
9009 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
9011 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
9012 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
9014 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
9015 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
9016 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
9019 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
9021 diff -NurpP --minimal linux-2.6.35.7/include/linux/mm_types.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/mm_types.h
9022 --- linux-2.6.35.7/include/linux/mm_types.h 2010-10-04 08:57:40.000000000 +0200
9023 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/mm_types.h 2010-09-06 02:59:52.000000000 +0200
9024 @@ -269,6 +269,7 @@ struct mm_struct {
9026 /* Architecture-specific MM context */
9027 mm_context_t context;
9028 + struct vx_info *mm_vx_info;
9030 /* Swap token stuff */
9032 diff -NurpP --minimal linux-2.6.35.7/include/linux/mount.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/mount.h
9033 --- linux-2.6.35.7/include/linux/mount.h 2010-07-07 18:31:56.000000000 +0200
9034 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/mount.h 2010-08-02 17:05:06.000000000 +0200
9035 @@ -47,6 +47,9 @@ struct mnt_namespace;
9037 #define MNT_INTERNAL 0x4000
9039 +#define MNT_TAGID 0x10000
9040 +#define MNT_NOTAG 0x20000
9043 struct list_head mnt_hash;
9044 struct vfsmount *mnt_parent; /* fs we are mounted on */
9045 @@ -81,6 +84,7 @@ struct vfsmount {
9049 + tag_t mnt_tag; /* tagging used for vfsmount */
9052 static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
9053 diff -NurpP --minimal linux-2.6.35.7/include/linux/net.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/net.h
9054 --- linux-2.6.35.7/include/linux/net.h 2010-08-02 16:52:55.000000000 +0200
9055 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/net.h 2010-08-02 17:05:06.000000000 +0200
9056 @@ -71,6 +71,7 @@ struct net;
9057 #define SOCK_NOSPACE 2
9058 #define SOCK_PASSCRED 3
9059 #define SOCK_PASSSEC 4
9060 +#define SOCK_USER_SOCKET 5
9062 #ifndef ARCH_HAS_SOCKET_TYPES
9064 diff -NurpP --minimal linux-2.6.35.7/include/linux/nfs_mount.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/nfs_mount.h
9065 --- linux-2.6.35.7/include/linux/nfs_mount.h 2009-03-24 14:22:43.000000000 +0100
9066 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/nfs_mount.h 2010-08-02 17:05:06.000000000 +0200
9067 @@ -63,7 +63,8 @@ struct nfs_mount_data {
9068 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
9069 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
9070 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
9071 -#define NFS_MOUNT_FLAGMASK 0xFFFF
9072 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
9073 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
9075 /* The following are for internal use only */
9076 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
9077 diff -NurpP --minimal linux-2.6.35.7/include/linux/nsproxy.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/nsproxy.h
9078 --- linux-2.6.35.7/include/linux/nsproxy.h 2009-06-11 17:13:17.000000000 +0200
9079 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/nsproxy.h 2010-08-02 17:05:06.000000000 +0200
9082 #include <linux/spinlock.h>
9083 #include <linux/sched.h>
9084 +#include <linux/vserver/debug.h>
9086 struct mnt_namespace;
9087 struct uts_namespace;
9088 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
9091 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
9092 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
9093 void exit_task_namespaces(struct task_struct *tsk);
9094 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
9095 void free_nsproxy(struct nsproxy *ns);
9096 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
9097 struct fs_struct *);
9099 -static inline void put_nsproxy(struct nsproxy *ns)
9100 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
9102 +static inline void __get_nsproxy(struct nsproxy *ns,
9103 + const char *_file, int _line)
9105 - if (atomic_dec_and_test(&ns->count)) {
9108 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
9109 + ns, atomic_read(&ns->count), _file, _line);
9110 + atomic_inc(&ns->count);
9113 -static inline void get_nsproxy(struct nsproxy *ns)
9114 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
9116 +static inline void __put_nsproxy(struct nsproxy *ns,
9117 + const char *_file, int _line)
9119 - atomic_inc(&ns->count);
9120 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
9121 + ns, atomic_read(&ns->count), _file, _line);
9122 + if (atomic_dec_and_test(&ns->count)) {
9127 #ifdef CONFIG_CGROUP_NS
9128 diff -NurpP --minimal linux-2.6.35.7/include/linux/pid.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/pid.h
9129 --- linux-2.6.35.7/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
9130 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/pid.h 2010-08-02 17:05:06.000000000 +0200
9131 @@ -8,7 +8,8 @@ enum pid_type
9141 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
9144 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9145 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9146 pid_t pid_vnr(struct pid *pid);
9148 #define do_each_pid_task(pid, type, task) \
9149 diff -NurpP --minimal linux-2.6.35.7/include/linux/proc_fs.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/proc_fs.h
9150 --- linux-2.6.35.7/include/linux/proc_fs.h 2009-12-03 20:02:56.000000000 +0100
9151 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/proc_fs.h 2010-08-02 17:05:06.000000000 +0200
9152 @@ -56,6 +56,7 @@ struct proc_dir_entry {
9158 const struct inode_operations *proc_iops;
9160 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void
9161 extern void kclist_add(struct kcore_list *, void *, size_t, int type);
9168 int (*proc_get_link)(struct inode *, struct path *);
9169 int (*proc_read)(struct task_struct *task, char *page);
9170 int (*proc_show)(struct seq_file *m,
9171 struct pid_namespace *ns, struct pid *pid,
9172 struct task_struct *task);
9173 + int (*proc_vs_read)(char *page);
9174 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9175 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9178 struct ctl_table_header;
9179 @@ -263,6 +270,7 @@ struct ctl_table;
9186 struct proc_dir_entry *pde;
9187 diff -NurpP --minimal linux-2.6.35.7/include/linux/quotaops.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/quotaops.h
9188 --- linux-2.6.35.7/include/linux/quotaops.h 2010-08-02 16:52:55.000000000 +0200
9189 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/quotaops.h 2010-08-02 22:35:47.000000000 +0200
9191 #define _LINUX_QUOTAOPS_
9193 #include <linux/fs.h>
9194 +#include <linux/vs_dlimit.h>
9196 #define DQUOT_SPACE_WARN 0x1
9197 #define DQUOT_SPACE_RESERVE 0x2
9198 @@ -209,11 +210,12 @@ static inline void dquot_drop(struct ino
9200 static inline int dquot_alloc_inode(const struct inode *inode)
9203 + return dl_alloc_inode(inode);
9206 static inline void dquot_free_inode(const struct inode *inode)
9208 + dl_free_inode(inode);
9211 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
9212 @@ -224,6 +226,10 @@ static inline int dquot_transfer(struct
9213 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
9218 + if ((ret = dl_alloc_space(inode, number)))
9220 if (!(flags & DQUOT_SPACE_RESERVE))
9221 inode_add_bytes(inode, number);
9223 @@ -234,6 +240,7 @@ static inline void __dquot_free_space(st
9225 if (!(flags & DQUOT_SPACE_RESERVE))
9226 inode_sub_bytes(inode, number);
9227 + dl_free_space(inode, number);
9230 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
9231 diff -NurpP --minimal linux-2.6.35.7/include/linux/reboot.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/reboot.h
9232 --- linux-2.6.35.7/include/linux/reboot.h 2010-07-07 18:31:56.000000000 +0200
9233 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/reboot.h 2010-08-02 17:05:06.000000000 +0200
9235 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
9236 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
9237 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
9238 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
9242 diff -NurpP --minimal linux-2.6.35.7/include/linux/reiserfs_fs.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/reiserfs_fs.h
9243 --- linux-2.6.35.7/include/linux/reiserfs_fs.h 2010-07-07 18:31:56.000000000 +0200
9244 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/reiserfs_fs.h 2010-08-02 17:05:06.000000000 +0200
9245 @@ -977,6 +977,11 @@ struct stat_data_v1 {
9246 #define REISERFS_COMPR_FL FS_COMPR_FL
9247 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9249 +/* unfortunately reiserfs sdattr is only 16 bit */
9250 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9251 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9252 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9254 /* persistent flags that file inherits from the parent directory */
9255 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9256 REISERFS_SYNC_FL | \
9257 @@ -986,6 +991,9 @@ struct stat_data_v1 {
9258 REISERFS_COMPR_FL | \
9259 REISERFS_NOTAIL_FL )
9261 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9262 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9264 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9267 @@ -2071,6 +2079,7 @@ static inline void reiserfs_update_sd(st
9268 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9269 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9270 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9271 +int reiserfs_sync_flags(struct inode *inode, int, int);
9274 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
9275 diff -NurpP --minimal linux-2.6.35.7/include/linux/reiserfs_fs_sb.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/reiserfs_fs_sb.h
9276 --- linux-2.6.35.7/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
9277 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/reiserfs_fs_sb.h 2010-08-02 17:05:06.000000000 +0200
9278 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
9279 REISERFS_EXPOSE_PRIVROOT,
9280 REISERFS_BARRIER_NONE,
9281 REISERFS_BARRIER_FLUSH,
9284 /* Actions on error */
9285 REISERFS_ERROR_PANIC,
9286 diff -NurpP --minimal linux-2.6.35.7/include/linux/sched.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/sched.h
9287 --- linux-2.6.35.7/include/linux/sched.h 2010-10-04 08:57:40.000000000 +0200
9288 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/sched.h 2010-08-14 18:19:32.000000000 +0200
9289 @@ -1343,6 +1343,14 @@ struct task_struct {
9293 +/* vserver context data */
9294 + struct vx_info *vx_info;
9295 + struct nx_info *nx_info;
9301 /* Thread group tracking */
9304 @@ -1577,6 +1585,11 @@ struct pid_namespace;
9305 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9306 struct pid_namespace *ns);
9308 +#include <linux/vserver/base.h>
9309 +#include <linux/vserver/context.h>
9310 +#include <linux/vserver/debug.h>
9311 +#include <linux/vserver/pid.h>
9313 static inline pid_t task_pid_nr(struct task_struct *tsk)
9316 @@ -1590,7 +1603,8 @@ static inline pid_t task_pid_nr_ns(struc
9318 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9320 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9321 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9322 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
9326 @@ -1603,7 +1617,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9328 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9330 - return pid_vnr(task_tgid(tsk));
9331 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9335 diff -NurpP --minimal linux-2.6.35.7/include/linux/shmem_fs.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/shmem_fs.h
9336 --- linux-2.6.35.7/include/linux/shmem_fs.h 2010-02-25 11:52:08.000000000 +0100
9337 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/shmem_fs.h 2010-08-02 17:05:06.000000000 +0200
9340 #define SHMEM_NR_DIRECT 16
9342 +#define TMPFS_SUPER_MAGIC 0x01021994
9345 struct shmem_inode_info {
9347 unsigned long flags;
9348 diff -NurpP --minimal linux-2.6.35.7/include/linux/stat.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/stat.h
9349 --- linux-2.6.35.7/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9350 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/stat.h 2010-08-02 17:05:06.000000000 +0200
9351 @@ -66,6 +66,7 @@ struct kstat {
9358 struct timespec atime;
9359 diff -NurpP --minimal linux-2.6.35.7/include/linux/sunrpc/auth.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/sunrpc/auth.h
9360 --- linux-2.6.35.7/include/linux/sunrpc/auth.h 2010-08-02 16:52:56.000000000 +0200
9361 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/sunrpc/auth.h 2010-08-02 17:05:06.000000000 +0200
9367 struct group_info *group_info;
9368 unsigned char machine_cred : 1;
9370 diff -NurpP --minimal linux-2.6.35.7/include/linux/sunrpc/clnt.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/sunrpc/clnt.h
9371 --- linux-2.6.35.7/include/linux/sunrpc/clnt.h 2009-12-03 20:02:56.000000000 +0100
9372 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/sunrpc/clnt.h 2010-08-02 17:05:06.000000000 +0200
9373 @@ -49,7 +49,8 @@ struct rpc_clnt {
9374 unsigned int cl_softrtry : 1,/* soft timeouts */
9375 cl_discrtry : 1,/* disconnect before retry */
9376 cl_autobind : 1,/* use getport() */
9377 - cl_chatty : 1;/* be verbose */
9378 + cl_chatty : 1,/* be verbose */
9379 + cl_tag : 1;/* context tagging */
9381 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9382 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9383 diff -NurpP --minimal linux-2.6.35.7/include/linux/syscalls.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/syscalls.h
9384 --- linux-2.6.35.7/include/linux/syscalls.h 2010-08-02 16:52:56.000000000 +0200
9385 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/syscalls.h 2010-08-02 17:05:06.000000000 +0200
9386 @@ -479,6 +479,8 @@ asmlinkage long sys_symlink(const char _
9387 asmlinkage long sys_unlink(const char __user *pathname);
9388 asmlinkage long sys_rename(const char __user *oldname,
9389 const char __user *newname);
9390 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9392 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9393 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9395 diff -NurpP --minimal linux-2.6.35.7/include/linux/sysctl.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/sysctl.h
9396 --- linux-2.6.35.7/include/linux/sysctl.h 2010-08-02 16:52:56.000000000 +0200
9397 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/sysctl.h 2010-08-02 17:05:06.000000000 +0200
9398 @@ -60,6 +60,7 @@ enum
9399 CTL_ABI=9, /* Binary emulation */
9400 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9401 CTL_ARLAN=254, /* arlan wireless driver */
9402 + CTL_VSERVER=4242, /* Linux-VServer debug */
9403 CTL_S390DBF=5677, /* s390 debug */
9404 CTL_SUNRPC=7249, /* sunrpc debug */
9405 CTL_PM=9899, /* frv power management */
9406 @@ -94,6 +95,7 @@ enum
9408 KERN_PANIC=15, /* int: panic timeout */
9409 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9410 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9412 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9413 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9414 diff -NurpP --minimal linux-2.6.35.7/include/linux/sysfs.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/sysfs.h
9415 --- linux-2.6.35.7/include/linux/sysfs.h 2010-08-02 16:52:56.000000000 +0200
9416 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/sysfs.h 2010-08-02 17:05:06.000000000 +0200
9418 #include <linux/lockdep.h>
9419 #include <asm/atomic.h>
9421 +#define SYSFS_SUPER_MAGIC 0x62656572
9426 diff -NurpP --minimal linux-2.6.35.7/include/linux/time.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/time.h
9427 --- linux-2.6.35.7/include/linux/time.h 2010-08-02 16:52:56.000000000 +0200
9428 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/time.h 2010-08-02 17:05:06.000000000 +0200
9429 @@ -237,6 +237,9 @@ static __always_inline void timespec_add
9430 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9434 +#include <linux/vs_time.h>
9436 #endif /* __KERNEL__ */
9438 #define NFDBITS __NFDBITS
9439 diff -NurpP --minimal linux-2.6.35.7/include/linux/types.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/types.h
9440 --- linux-2.6.35.7/include/linux/types.h 2010-08-02 16:52:56.000000000 +0200
9441 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/types.h 2010-08-02 17:05:06.000000000 +0200
9442 @@ -37,6 +37,9 @@ typedef __kernel_uid32_t uid_t;
9443 typedef __kernel_gid32_t gid_t;
9444 typedef __kernel_uid16_t uid16_t;
9445 typedef __kernel_gid16_t gid16_t;
9446 +typedef unsigned int xid_t;
9447 +typedef unsigned int nid_t;
9448 +typedef unsigned int tag_t;
9450 typedef unsigned long uintptr_t;
9452 diff -NurpP --minimal linux-2.6.35.7/include/linux/vroot.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vroot.h
9453 --- linux-2.6.35.7/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9454 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vroot.h 2010-08-02 17:05:06.000000000 +0200
9458 + * include/linux/vroot.h
9460 + * written by Herbert Pötzl, 9/11/2002
9461 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9463 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9464 + * Redistribution of this file is permitted under the
9465 + * GNU General Public License.
9468 +#ifndef _LINUX_VROOT_H
9469 +#define _LINUX_VROOT_H
9474 +/* Possible states of device */
9480 +struct vroot_device {
9484 + struct semaphore vr_ctl_mutex;
9485 + struct block_device *vr_device;
9490 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9492 +extern int register_vroot_grb(vroot_grb_func *);
9493 +extern int unregister_vroot_grb(vroot_grb_func *);
9495 +#endif /* __KERNEL__ */
9497 +#define MAX_VROOT_DEFAULT 8
9500 + * IOCTL commands --- we will commandeer 0x56 ('V')
9503 +#define VROOT_SET_DEV 0x5600
9504 +#define VROOT_CLR_DEV 0x5601
9506 +#endif /* _LINUX_VROOT_H */
9507 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_base.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_base.h
9508 --- linux-2.6.35.7/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9509 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_base.h 2010-08-02 17:05:06.000000000 +0200
9514 +#include "vserver/base.h"
9515 +#include "vserver/check.h"
9516 +#include "vserver/debug.h"
9519 +#warning duplicate inclusion
9521 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_context.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_context.h
9522 --- linux-2.6.35.7/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9523 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_context.h 2010-08-02 17:05:06.000000000 +0200
9525 +#ifndef _VS_CONTEXT_H
9526 +#define _VS_CONTEXT_H
9528 +#include "vserver/base.h"
9529 +#include "vserver/check.h"
9530 +#include "vserver/context.h"
9531 +#include "vserver/history.h"
9532 +#include "vserver/debug.h"
9534 +#include <linux/sched.h>
9537 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9539 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9540 + const char *_file, int _line, void *_here)
9545 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9546 + vxi, vxi ? vxi->vx_id : 0,
9547 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9549 + __vxh_get_vx_info(vxi, _here);
9551 + atomic_inc(&vxi->vx_usecnt);
9556 +extern void free_vx_info(struct vx_info *);
9558 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9560 +static inline void __put_vx_info(struct vx_info *vxi,
9561 + const char *_file, int _line, void *_here)
9566 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9567 + vxi, vxi ? vxi->vx_id : 0,
9568 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9570 + __vxh_put_vx_info(vxi, _here);
9572 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9573 + free_vx_info(vxi);
9577 +#define init_vx_info(p, i) \
9578 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9580 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9581 + const char *_file, int _line, void *_here)
9584 + vxlprintk(VXD_CBIT(xid, 3),
9585 + "init_vx_info(%p[#%d.%d])",
9586 + vxi, vxi ? vxi->vx_id : 0,
9587 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9589 + __vxh_init_vx_info(vxi, vxp, _here);
9591 + atomic_inc(&vxi->vx_usecnt);
9597 +#define set_vx_info(p, i) \
9598 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9600 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9601 + const char *_file, int _line, void *_here)
9603 + struct vx_info *vxo;
9608 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9609 + vxi, vxi ? vxi->vx_id : 0,
9610 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9612 + __vxh_set_vx_info(vxi, vxp, _here);
9614 + atomic_inc(&vxi->vx_usecnt);
9615 + vxo = xchg(vxp, vxi);
9620 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9622 +static inline void __clr_vx_info(struct vx_info **vxp,
9623 + const char *_file, int _line, void *_here)
9625 + struct vx_info *vxo;
9627 + vxo = xchg(vxp, NULL);
9631 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9632 + vxo, vxo ? vxo->vx_id : 0,
9633 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9635 + __vxh_clr_vx_info(vxo, vxp, _here);
9637 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9638 + free_vx_info(vxo);
9642 +#define claim_vx_info(v, p) \
9643 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9645 +static inline void __claim_vx_info(struct vx_info *vxi,
9646 + struct task_struct *task,
9647 + const char *_file, int _line, void *_here)
9649 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9650 + vxi, vxi ? vxi->vx_id : 0,
9651 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9652 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9653 + task, _file, _line);
9654 + __vxh_claim_vx_info(vxi, task, _here);
9656 + atomic_inc(&vxi->vx_tasks);
9660 +extern void unhash_vx_info(struct vx_info *);
9662 +#define release_vx_info(v, p) \
9663 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9665 +static inline void __release_vx_info(struct vx_info *vxi,
9666 + struct task_struct *task,
9667 + const char *_file, int _line, void *_here)
9669 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9670 + vxi, vxi ? vxi->vx_id : 0,
9671 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9672 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9673 + task, _file, _line);
9674 + __vxh_release_vx_info(vxi, task, _here);
9678 + if (atomic_dec_and_test(&vxi->vx_tasks))
9679 + unhash_vx_info(vxi);
9683 +#define task_get_vx_info(p) \
9684 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9686 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9687 + const char *_file, int _line, void *_here)
9689 + struct vx_info *vxi;
9692 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9694 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9700 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9702 + if (waitqueue_active(&vxi->vx_wait))
9703 + wake_up_interruptible(&vxi->vx_wait);
9707 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9709 +static inline void __enter_vx_info(struct vx_info *vxi,
9710 + struct vx_info_save *vxis, const char *_file, int _line)
9712 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9713 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9714 + current->xid, current->vx_info, _file, _line);
9715 + vxis->vxi = xchg(¤t->vx_info, vxi);
9716 + vxis->xid = current->xid;
9717 + current->xid = vxi ? vxi->vx_id : 0;
9720 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9722 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9723 + const char *_file, int _line)
9725 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9726 + vxis, vxis->xid, vxis->vxi, current,
9727 + current->xid, current->vx_info, _file, _line);
9728 + (void)xchg(¤t->vx_info, vxis->vxi);
9729 + current->xid = vxis->xid;
9733 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9735 + vxis->vxi = xchg(¤t->vx_info, NULL);
9736 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9739 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9741 + (void)xchg(¤t->xid, vxis->xid);
9742 + (void)xchg(¤t->vx_info, vxis->vxi);
9745 +#define task_is_init(p) \
9746 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9748 +static inline int __task_is_init(struct task_struct *p,
9749 + const char *_file, int _line, void *_here)
9751 + int is_init = is_global_init(p);
9755 + is_init = p->vx_info->vx_initpid == p->pid;
9760 +extern void exit_vx_info(struct task_struct *, int);
9761 +extern void exit_vx_info_early(struct task_struct *, int);
9765 +#warning duplicate inclusion
9767 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_cowbl.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_cowbl.h
9768 --- linux-2.6.35.7/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9769 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_cowbl.h 2010-08-02 21:01:17.000000000 +0200
9771 +#ifndef _VS_COWBL_H
9772 +#define _VS_COWBL_H
9774 +#include <linux/fs.h>
9775 +#include <linux/dcache.h>
9776 +#include <linux/namei.h>
9777 +#include <linux/slab.h>
9779 +extern struct dentry *cow_break_link(const char *pathname);
9781 +static inline int cow_check_and_break(struct path *path)
9783 + struct inode *inode = path->dentry->d_inode;
9786 + /* do we need this check? */
9787 + if (IS_RDONLY(inode))
9790 + if (IS_COW(inode)) {
9791 + if (IS_COW_LINK(inode)) {
9792 + struct dentry *new_dentry, *old_dentry = path->dentry;
9795 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9799 + pp = d_path(path, buf, PATH_MAX);
9800 + new_dentry = cow_break_link(pp);
9802 + if (!IS_ERR(new_dentry)) {
9803 + path->dentry = new_dentry;
9806 + error = PTR_ERR(new_dentry);
9808 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9809 + inode->i_ctime = CURRENT_TIME;
9810 + mark_inode_dirty(inode);
9817 +#warning duplicate inclusion
9819 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_cvirt.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_cvirt.h
9820 --- linux-2.6.35.7/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9821 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_cvirt.h 2010-08-02 17:05:06.000000000 +0200
9823 +#ifndef _VS_CVIRT_H
9824 +#define _VS_CVIRT_H
9826 +#include "vserver/cvirt.h"
9827 +#include "vserver/context.h"
9828 +#include "vserver/base.h"
9829 +#include "vserver/check.h"
9830 +#include "vserver/debug.h"
9833 +static inline void vx_activate_task(struct task_struct *p)
9835 + struct vx_info *vxi;
9837 + if ((vxi = p->vx_info)) {
9838 + vx_update_load(vxi);
9839 + atomic_inc(&vxi->cvirt.nr_running);
9843 +static inline void vx_deactivate_task(struct task_struct *p)
9845 + struct vx_info *vxi;
9847 + if ((vxi = p->vx_info)) {
9848 + vx_update_load(vxi);
9849 + atomic_dec(&vxi->cvirt.nr_running);
9853 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9855 + struct vx_info *vxi;
9857 + if ((vxi = p->vx_info))
9858 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9861 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9863 + struct vx_info *vxi;
9865 + if ((vxi = p->vx_info))
9866 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9871 +#warning duplicate inclusion
9873 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_device.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_device.h
9874 --- linux-2.6.35.7/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9875 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_device.h 2010-08-02 17:05:06.000000000 +0200
9877 +#ifndef _VS_DEVICE_H
9878 +#define _VS_DEVICE_H
9880 +#include "vserver/base.h"
9881 +#include "vserver/device.h"
9882 +#include "vserver/debug.h"
9885 +#ifdef CONFIG_VSERVER_DEVICE
9887 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9889 +#define vs_device_perm(v, d, m, p) \
9890 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9895 +int vs_map_device(struct vx_info *vxi,
9896 + dev_t device, dev_t *target, umode_t mode)
9903 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9908 +#define vs_map_chrdev(d, t, p) \
9909 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9910 +#define vs_map_blkdev(d, t, p) \
9911 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9913 +#define vs_chrdev_perm(d, p) \
9914 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9915 +#define vs_blkdev_perm(d, p) \
9916 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9920 +#warning duplicate inclusion
9922 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_dlimit.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_dlimit.h
9923 --- linux-2.6.35.7/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9924 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_dlimit.h 2010-08-02 22:21:17.000000000 +0200
9926 +#ifndef _VS_DLIMIT_H
9927 +#define _VS_DLIMIT_H
9929 +#include <linux/fs.h>
9931 +#include "vserver/dlimit.h"
9932 +#include "vserver/base.h"
9933 +#include "vserver/debug.h"
9936 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9938 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9939 + const char *_file, int _line)
9943 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9944 + dli, dli ? dli->dl_tag : 0,
9945 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9947 + atomic_inc(&dli->dl_usecnt);
9952 +#define free_dl_info(i) \
9953 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9955 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9957 +static inline void __put_dl_info(struct dl_info *dli,
9958 + const char *_file, int _line)
9962 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9963 + dli, dli ? dli->dl_tag : 0,
9964 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9966 + if (atomic_dec_and_test(&dli->dl_usecnt))
9967 + free_dl_info(dli);
9971 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9973 +static inline int __dl_alloc_space(struct super_block *sb,
9974 + tag_t tag, dlsize_t nr, const char *file, int line)
9976 + struct dl_info *dli = NULL;
9981 + dli = locate_dl_info(sb, tag);
9985 + spin_lock(&dli->dl_lock);
9986 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9988 + dli->dl_space_used += nr;
9989 + spin_unlock(&dli->dl_lock);
9992 + vxlprintk(VXD_CBIT(dlim, 1),
9993 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9994 + sb, tag, __dlimit_char(dli), (long long)nr,
9996 + return ret ? -ENOSPC : 0;
9999 +static inline void __dl_free_space(struct super_block *sb,
10000 + tag_t tag, dlsize_t nr, const char *_file, int _line)
10002 + struct dl_info *dli = NULL;
10006 + dli = locate_dl_info(sb, tag);
10010 + spin_lock(&dli->dl_lock);
10011 + if (dli->dl_space_used > nr)
10012 + dli->dl_space_used -= nr;
10014 + dli->dl_space_used = 0;
10015 + spin_unlock(&dli->dl_lock);
10016 + put_dl_info(dli);
10018 + vxlprintk(VXD_CBIT(dlim, 1),
10019 + "FREE (%p,#%d)%c %lld bytes",
10020 + sb, tag, __dlimit_char(dli), (long long)nr,
10024 +static inline int __dl_alloc_inode(struct super_block *sb,
10025 + tag_t tag, const char *_file, int _line)
10027 + struct dl_info *dli;
10030 + dli = locate_dl_info(sb, tag);
10034 + spin_lock(&dli->dl_lock);
10035 + dli->dl_inodes_used++;
10036 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
10037 + spin_unlock(&dli->dl_lock);
10038 + put_dl_info(dli);
10040 + vxlprintk(VXD_CBIT(dlim, 0),
10041 + "ALLOC (%p,#%d)%c inode (%d)",
10042 + sb, tag, __dlimit_char(dli), ret, _file, _line);
10043 + return ret ? -ENOSPC : 0;
10046 +static inline void __dl_free_inode(struct super_block *sb,
10047 + tag_t tag, const char *_file, int _line)
10049 + struct dl_info *dli;
10051 + dli = locate_dl_info(sb, tag);
10055 + spin_lock(&dli->dl_lock);
10056 + if (dli->dl_inodes_used > 1)
10057 + dli->dl_inodes_used--;
10059 + dli->dl_inodes_used = 0;
10060 + spin_unlock(&dli->dl_lock);
10061 + put_dl_info(dli);
10063 + vxlprintk(VXD_CBIT(dlim, 0),
10064 + "FREE (%p,#%d)%c inode",
10065 + sb, tag, __dlimit_char(dli), _file, _line);
10068 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10069 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10070 + const char *_file, int _line)
10072 + struct dl_info *dli;
10073 + uint64_t broot, bfree;
10075 + dli = locate_dl_info(sb, tag);
10079 + spin_lock(&dli->dl_lock);
10080 + broot = (dli->dl_space_total -
10081 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10082 + >> sb->s_blocksize_bits;
10083 + bfree = (dli->dl_space_total - dli->dl_space_used)
10084 + >> sb->s_blocksize_bits;
10085 + spin_unlock(&dli->dl_lock);
10087 + vxlprintk(VXD_CBIT(dlim, 2),
10088 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10089 + (long long)bfree, (long long)broot,
10090 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10092 + if (free_blocks) {
10093 + if (*free_blocks > bfree)
10094 + *free_blocks = bfree;
10096 + if (root_blocks) {
10097 + if (*root_blocks > broot)
10098 + *root_blocks = broot;
10100 + put_dl_info(dli);
10103 +#define dl_prealloc_space(in, bytes) \
10104 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10105 + __FILE__, __LINE__ )
10107 +#define dl_alloc_space(in, bytes) \
10108 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10109 + __FILE__, __LINE__ )
10111 +#define dl_reserve_space(in, bytes) \
10112 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10113 + __FILE__, __LINE__ )
10115 +#define dl_claim_space(in, bytes) (0)
10117 +#define dl_release_space(in, bytes) \
10118 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10119 + __FILE__, __LINE__ )
10121 +#define dl_free_space(in, bytes) \
10122 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10123 + __FILE__, __LINE__ )
10127 +#define dl_alloc_inode(in) \
10128 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10130 +#define dl_free_inode(in) \
10131 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10134 +#define dl_adjust_block(sb, tag, fb, rb) \
10135 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10139 +#warning duplicate inclusion
10141 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/base.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/base.h
10142 --- linux-2.6.35.7/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10143 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/base.h 2010-08-02 17:05:06.000000000 +0200
10145 +#ifndef _VX_BASE_H
10146 +#define _VX_BASE_H
10149 +/* context state changes */
10161 +#define vx_task_xid(t) ((t)->xid)
10163 +#define vx_current_xid() vx_task_xid(current)
10165 +#define current_vx_info() (current->vx_info)
10168 +#define nx_task_nid(t) ((t)->nid)
10170 +#define nx_current_nid() nx_task_nid(current)
10172 +#define current_nx_info() (current->nx_info)
10175 +/* generic flag merging */
10177 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10179 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10181 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10183 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10186 +/* context flags */
10188 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10190 +#define vx_current_flags() __vx_flags(current_vx_info())
10192 +#define vx_info_flags(v, m, f) \
10193 + vs_check_flags(__vx_flags(v), m, f)
10195 +#define task_vx_flags(t, m, f) \
10196 + ((t) && vx_info_flags((t)->vx_info, m, f))
10198 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10201 +/* context caps */
10203 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10205 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10207 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10209 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10213 +/* network flags */
10215 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10217 +#define nx_current_flags() __nx_flags(current_nx_info())
10219 +#define nx_info_flags(n, m, f) \
10220 + vs_check_flags(__nx_flags(n), m, f)
10222 +#define task_nx_flags(t, m, f) \
10223 + ((t) && nx_info_flags((t)->nx_info, m, f))
10225 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10228 +/* network caps */
10230 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10232 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10234 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10236 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10239 +/* context mask capabilities */
10241 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10243 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10245 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10248 +/* context bcap mask */
10250 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10252 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10255 +/* mask given bcaps */
10257 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10259 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10262 +/* masked cap_bset */
10264 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10266 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10269 +#define vx_info_mbcap(v, b) \
10270 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10271 + vx_info_bcaps(v, b) : (b))
10273 +#define task_vx_mbcap(t, b) \
10274 + vx_info_mbcap((t)->vx_info, (t)->b)
10276 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10279 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10281 +#define vx_capable(b, c) (capable(b) || \
10282 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10284 +#define nx_capable(b, c) (capable(b) || \
10285 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10287 +#define vx_task_initpid(t, n) \
10288 + ((t)->vx_info && \
10289 + ((t)->vx_info->vx_initpid == (n)))
10291 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10294 +/* context unshare mask */
10296 +#define __vx_umask(v) ((v)->vx_umask)
10298 +#define vx_current_umask() __vx_umask(current_vx_info())
10300 +#define vx_can_unshare(b, f) (capable(b) || \
10301 + (cap_raised(current_cap(), b) && \
10302 + !((f) & ~vx_current_umask())))
10305 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10307 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10310 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10312 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10315 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/cacct_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cacct_cmd.h
10316 --- linux-2.6.35.7/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10317 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cacct_cmd.h 2010-08-02 17:05:06.000000000 +0200
10319 +#ifndef _VX_CACCT_CMD_H
10320 +#define _VX_CACCT_CMD_H
10323 +/* virtual host info name commands */
10325 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10327 +struct vcmd_sock_stat_v0 {
10329 + uint32_t count[3];
10330 + uint64_t total[3];
10336 +#include <linux/compiler.h>
10338 +extern int vc_sock_stat(struct vx_info *, void __user *);
10340 +#endif /* __KERNEL__ */
10341 +#endif /* _VX_CACCT_CMD_H */
10342 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/cacct_def.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cacct_def.h
10343 --- linux-2.6.35.7/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10344 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cacct_def.h 2010-08-02 17:05:06.000000000 +0200
10346 +#ifndef _VX_CACCT_DEF_H
10347 +#define _VX_CACCT_DEF_H
10349 +#include <asm/atomic.h>
10350 +#include <linux/vserver/cacct.h>
10353 +struct _vx_sock_acc {
10354 + atomic_long_t count;
10355 + atomic_long_t total;
10358 +/* context sub struct */
10360 +struct _vx_cacct {
10361 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10362 + atomic_t slab[8];
10363 + atomic_t page[6][8];
10366 +#ifdef CONFIG_VSERVER_DEBUG
10368 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10372 + printk("\t_vx_cacct:");
10373 + for (i = 0; i < 6; i++) {
10374 + struct _vx_sock_acc *ptr = cacct->sock[i];
10376 + printk("\t [%d] =", i);
10377 + for (j = 0; j < 3; j++) {
10378 + printk(" [%d] = %8lu, %8lu", j,
10379 + atomic_long_read(&ptr[j].count),
10380 + atomic_long_read(&ptr[j].total));
10388 +#endif /* _VX_CACCT_DEF_H */
10389 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/cacct.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cacct.h
10390 --- linux-2.6.35.7/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10391 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cacct.h 2010-08-02 17:05:06.000000000 +0200
10393 +#ifndef _VX_CACCT_H
10394 +#define _VX_CACCT_H
10397 +enum sock_acc_field {
10398 + VXA_SOCK_UNSPEC = 0,
10404 + VXA_SOCK_SIZE /* array size */
10407 +#endif /* _VX_CACCT_H */
10408 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/cacct_int.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cacct_int.h
10409 --- linux-2.6.35.7/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10410 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cacct_int.h 2010-08-02 17:05:06.000000000 +0200
10412 +#ifndef _VX_CACCT_INT_H
10413 +#define _VX_CACCT_INT_H
10419 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10421 + return atomic_long_read(&cacct->sock[type][pos].count);
10426 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10428 + return atomic_long_read(&cacct->sock[type][pos].total);
10431 +#endif /* __KERNEL__ */
10432 +#endif /* _VX_CACCT_INT_H */
10433 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/check.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/check.h
10434 --- linux-2.6.35.7/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10435 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/check.h 2010-08-02 17:05:06.000000000 +0200
10437 +#ifndef _VS_CHECK_H
10438 +#define _VS_CHECK_H
10441 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10443 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10444 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10446 +#define MIN_D_CONTEXT 65536
10449 +/* check conditions */
10451 +#define VS_ADMIN 0x0001
10452 +#define VS_WATCH 0x0002
10453 +#define VS_HIDE 0x0004
10454 +#define VS_HOSTID 0x0008
10456 +#define VS_IDENT 0x0010
10457 +#define VS_EQUIV 0x0020
10458 +#define VS_PARENT 0x0040
10459 +#define VS_CHILD 0x0080
10461 +#define VS_ARG_MASK 0x00F0
10463 +#define VS_DYNAMIC 0x0100
10464 +#define VS_STATIC 0x0200
10466 +#define VS_ATR_MASK 0x0F00
10468 +#ifdef CONFIG_VSERVER_PRIVACY
10469 +#define VS_ADMIN_P (0)
10470 +#define VS_WATCH_P (0)
10472 +#define VS_ADMIN_P VS_ADMIN
10473 +#define VS_WATCH_P VS_WATCH
10476 +#define VS_HARDIRQ 0x1000
10477 +#define VS_SOFTIRQ 0x2000
10478 +#define VS_IRQ 0x4000
10480 +#define VS_IRQ_MASK 0xF000
10482 +#include <linux/hardirq.h>
10485 + * check current context for ADMIN/WATCH and
10486 + * optionally against supplied argument
10488 +static inline int __vs_check(int cid, int id, unsigned int mode)
10490 + if (mode & VS_ARG_MASK) {
10491 + if ((mode & VS_IDENT) && (id == cid))
10494 + if (mode & VS_ATR_MASK) {
10495 + if ((mode & VS_DYNAMIC) &&
10496 + (id >= MIN_D_CONTEXT) &&
10497 + (id <= MAX_S_CONTEXT))
10499 + if ((mode & VS_STATIC) &&
10500 + (id > 1) && (id < MIN_D_CONTEXT))
10503 + if (mode & VS_IRQ_MASK) {
10504 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10506 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10508 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10511 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10512 + ((mode & VS_WATCH) && (cid == 1)) ||
10513 + ((mode & VS_HOSTID) && (id == 0)));
10516 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10518 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10521 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10523 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10526 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/context_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/context_cmd.h
10527 --- linux-2.6.35.7/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10528 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/context_cmd.h 2010-08-02 17:05:06.000000000 +0200
10530 +#ifndef _VX_CONTEXT_CMD_H
10531 +#define _VX_CONTEXT_CMD_H
10534 +/* vinfo commands */
10536 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10539 +extern int vc_task_xid(uint32_t);
10541 +#endif /* __KERNEL__ */
10543 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10545 +struct vcmd_vx_info_v0 {
10547 + uint32_t initpid;
10548 + /* more to come */
10552 +extern int vc_vx_info(struct vx_info *, void __user *);
10554 +#endif /* __KERNEL__ */
10556 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10558 +struct vcmd_ctx_stat_v0 {
10561 + /* more to come */
10565 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10567 +#endif /* __KERNEL__ */
10569 +/* context commands */
10571 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10572 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10574 +struct vcmd_ctx_create {
10575 + uint64_t flagword;
10578 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10579 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10581 +struct vcmd_ctx_migrate {
10582 + uint64_t flagword;
10586 +extern int vc_ctx_create(uint32_t, void __user *);
10587 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10589 +#endif /* __KERNEL__ */
10592 +/* flag commands */
10594 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10595 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10597 +struct vcmd_ctx_flags_v0 {
10598 + uint64_t flagword;
10603 +extern int vc_get_cflags(struct vx_info *, void __user *);
10604 +extern int vc_set_cflags(struct vx_info *, void __user *);
10606 +#endif /* __KERNEL__ */
10609 +/* context caps commands */
10611 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10612 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10614 +struct vcmd_ctx_caps_v1 {
10620 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10621 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10623 +#endif /* __KERNEL__ */
10626 +/* bcaps commands */
10628 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10629 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10631 +struct vcmd_bcaps {
10637 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10638 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10640 +#endif /* __KERNEL__ */
10643 +/* umask commands */
10645 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
10646 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
10648 +struct vcmd_umask {
10654 +extern int vc_get_umask(struct vx_info *, void __user *);
10655 +extern int vc_set_umask(struct vx_info *, void __user *);
10657 +#endif /* __KERNEL__ */
10662 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10663 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10665 +struct vcmd_badness_v0 {
10670 +extern int vc_get_badness(struct vx_info *, void __user *);
10671 +extern int vc_set_badness(struct vx_info *, void __user *);
10673 +#endif /* __KERNEL__ */
10674 +#endif /* _VX_CONTEXT_CMD_H */
10675 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/context.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/context.h
10676 --- linux-2.6.35.7/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10677 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/context.h 2010-08-02 17:05:06.000000000 +0200
10679 +#ifndef _VX_CONTEXT_H
10680 +#define _VX_CONTEXT_H
10682 +#include <linux/types.h>
10683 +#include <linux/capability.h>
10686 +/* context flags */
10688 +#define VXF_INFO_SCHED 0x00000002
10689 +#define VXF_INFO_NPROC 0x00000004
10690 +#define VXF_INFO_PRIVATE 0x00000008
10692 +#define VXF_INFO_INIT 0x00000010
10693 +#define VXF_INFO_HIDE 0x00000020
10694 +#define VXF_INFO_ULIMIT 0x00000040
10695 +#define VXF_INFO_NSPACE 0x00000080
10697 +#define VXF_SCHED_HARD 0x00000100
10698 +#define VXF_SCHED_PRIO 0x00000200
10699 +#define VXF_SCHED_PAUSE 0x00000400
10701 +#define VXF_VIRT_MEM 0x00010000
10702 +#define VXF_VIRT_UPTIME 0x00020000
10703 +#define VXF_VIRT_CPU 0x00040000
10704 +#define VXF_VIRT_LOAD 0x00080000
10705 +#define VXF_VIRT_TIME 0x00100000
10707 +#define VXF_HIDE_MOUNT 0x01000000
10708 +/* was VXF_HIDE_NETIF 0x02000000 */
10709 +#define VXF_HIDE_VINFO 0x04000000
10711 +#define VXF_STATE_SETUP (1ULL << 32)
10712 +#define VXF_STATE_INIT (1ULL << 33)
10713 +#define VXF_STATE_ADMIN (1ULL << 34)
10715 +#define VXF_SC_HELPER (1ULL << 36)
10716 +#define VXF_REBOOT_KILL (1ULL << 37)
10717 +#define VXF_PERSISTENT (1ULL << 38)
10719 +#define VXF_FORK_RSS (1ULL << 48)
10720 +#define VXF_PROLIFIC (1ULL << 49)
10722 +#define VXF_IGNEG_NICE (1ULL << 52)
10724 +#define VXF_ONE_TIME (0x0007ULL << 32)
10726 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10729 +/* context migration */
10731 +#define VXM_SET_INIT 0x00000001
10732 +#define VXM_SET_REAPER 0x00000002
10734 +/* context caps */
10736 +#define VXC_CAP_MASK 0x00000000
10738 +#define VXC_SET_UTSNAME 0x00000001
10739 +#define VXC_SET_RLIMIT 0x00000002
10740 +#define VXC_FS_SECURITY 0x00000004
10741 +#define VXC_FS_TRUSTED 0x00000008
10742 +#define VXC_TIOCSTI 0x00000010
10744 +/* was VXC_RAW_ICMP 0x00000100 */
10745 +#define VXC_SYSLOG 0x00001000
10746 +#define VXC_OOM_ADJUST 0x00002000
10747 +#define VXC_AUDIT_CONTROL 0x00004000
10749 +#define VXC_SECURE_MOUNT 0x00010000
10750 +#define VXC_SECURE_REMOUNT 0x00020000
10751 +#define VXC_BINARY_MOUNT 0x00040000
10753 +#define VXC_QUOTA_CTL 0x00100000
10754 +#define VXC_ADMIN_MAPPER 0x00200000
10755 +#define VXC_ADMIN_CLOOP 0x00400000
10757 +#define VXC_KTHREAD 0x01000000
10758 +#define VXC_NAMESPACE 0x02000000
10763 +#include <linux/list.h>
10764 +#include <linux/spinlock.h>
10765 +#include <linux/rcupdate.h>
10767 +#include "limit_def.h"
10768 +#include "sched_def.h"
10769 +#include "cvirt_def.h"
10770 +#include "cacct_def.h"
10771 +#include "device_def.h"
10773 +#define VX_SPACES 2
10775 +struct _vx_info_pc {
10776 + struct _vx_sched_pc sched_pc;
10777 + struct _vx_cvirt_pc cvirt_pc;
10781 + struct hlist_node vx_hlist; /* linked list of contexts */
10782 + xid_t vx_id; /* context id */
10783 + atomic_t vx_usecnt; /* usage count */
10784 + atomic_t vx_tasks; /* tasks count */
10785 + struct vx_info *vx_parent; /* parent context */
10786 + int vx_state; /* context state */
10788 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
10789 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
10790 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
10792 + uint64_t vx_flags; /* context flags */
10793 + uint64_t vx_ccaps; /* context caps (vserver) */
10794 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10795 + unsigned long vx_umask; /* unshare mask (guest) */
10797 + struct task_struct *vx_reaper; /* guest reaper process */
10798 + pid_t vx_initpid; /* PID of guest init */
10799 + int64_t vx_badness_bias; /* OOM points bias */
10801 + struct _vx_limit limit; /* vserver limits */
10802 + struct _vx_sched sched; /* vserver scheduler */
10803 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10804 + struct _vx_cacct cacct; /* context accounting */
10806 + struct _vx_device dmap; /* default device map targets */
10808 +#ifndef CONFIG_SMP
10809 + struct _vx_info_pc info_pc; /* per cpu data */
10811 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10814 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10815 + int reboot_cmd; /* last sys_reboot() cmd */
10816 + int exit_code; /* last process exit code */
10818 + char vx_name[65]; /* vserver name */
10821 +#ifndef CONFIG_SMP
10822 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10823 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10825 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10826 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10829 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10832 +struct vx_info_save {
10833 + struct vx_info *vxi;
10838 +/* status flags */
10840 +#define VXS_HASHED 0x0001
10841 +#define VXS_PAUSED 0x0010
10842 +#define VXS_SHUTDOWN 0x0100
10843 +#define VXS_HELPER 0x1000
10844 +#define VXS_RELEASED 0x8000
10847 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
10848 +extern void release_vx_info(struct vx_info *, struct task_struct *);
10850 +extern struct vx_info *lookup_vx_info(int);
10851 +extern struct vx_info *lookup_or_create_vx_info(int);
10853 +extern int get_xid_list(int, unsigned int *, int);
10854 +extern int xid_is_hashed(xid_t);
10856 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
10858 +extern long vs_state_change(struct vx_info *, unsigned int);
10861 +#endif /* __KERNEL__ */
10862 +#endif /* _VX_CONTEXT_H */
10863 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/cvirt_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cvirt_cmd.h
10864 --- linux-2.6.35.7/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
10865 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cvirt_cmd.h 2010-08-02 17:05:06.000000000 +0200
10867 +#ifndef _VX_CVIRT_CMD_H
10868 +#define _VX_CVIRT_CMD_H
10871 +/* virtual host info name commands */
10873 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
10874 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
10876 +struct vcmd_vhi_name_v0 {
10882 +enum vhi_name_field {
10883 + VHIN_CONTEXT = 0,
10895 +#include <linux/compiler.h>
10897 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
10898 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
10900 +#endif /* __KERNEL__ */
10902 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
10904 +struct vcmd_virt_stat_v0 {
10907 + uint32_t nr_threads;
10908 + uint32_t nr_running;
10909 + uint32_t nr_uninterruptible;
10910 + uint32_t nr_onhold;
10911 + uint32_t nr_forks;
10912 + uint32_t load[3];
10916 +extern int vc_virt_stat(struct vx_info *, void __user *);
10918 +#endif /* __KERNEL__ */
10919 +#endif /* _VX_CVIRT_CMD_H */
10920 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/cvirt_def.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cvirt_def.h
10921 --- linux-2.6.35.7/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
10922 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cvirt_def.h 2010-08-02 17:05:06.000000000 +0200
10924 +#ifndef _VX_CVIRT_DEF_H
10925 +#define _VX_CVIRT_DEF_H
10927 +#include <linux/jiffies.h>
10928 +#include <linux/spinlock.h>
10929 +#include <linux/wait.h>
10930 +#include <linux/time.h>
10931 +#include <asm/atomic.h>
10934 +struct _vx_usage_stat {
10938 + uint64_t softirq;
10944 +struct _vx_syslog {
10945 + wait_queue_head_t log_wait;
10946 + spinlock_t logbuf_lock; /* lock for the log buffer */
10948 + unsigned long log_start; /* next char to be read by syslog() */
10949 + unsigned long con_start; /* next char to be sent to consoles */
10950 + unsigned long log_end; /* most-recently-written-char + 1 */
10951 + unsigned long logged_chars; /* #chars since last read+clear operation */
10953 + char log_buf[1024];
10957 +/* context sub struct */
10959 +struct _vx_cvirt {
10960 + atomic_t nr_threads; /* number of current threads */
10961 + atomic_t nr_running; /* number of running threads */
10962 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
10964 + atomic_t nr_onhold; /* processes on hold */
10965 + uint32_t onhold_last; /* jiffies when put on hold */
10967 + struct timeval bias_tv; /* time offset to the host */
10968 + struct timespec bias_idle;
10969 + struct timespec bias_uptime; /* context creation point */
10970 + uint64_t bias_clock; /* offset in clock_t */
10972 + spinlock_t load_lock; /* lock for the load averages */
10973 + atomic_t load_updates; /* nr of load updates done so far */
10974 + uint32_t load_last; /* last time load was calculated */
10975 + uint32_t load[3]; /* load averages 1,5,15 */
10977 + atomic_t total_forks; /* number of forks so far */
10979 + struct _vx_syslog syslog;
10982 +struct _vx_cvirt_pc {
10983 + struct _vx_usage_stat cpustat;
10987 +#ifdef CONFIG_VSERVER_DEBUG
10989 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
10991 + printk("\t_vx_cvirt:\n");
10992 + printk("\t threads: %4d, %4d, %4d, %4d\n",
10993 + atomic_read(&cvirt->nr_threads),
10994 + atomic_read(&cvirt->nr_running),
10995 + atomic_read(&cvirt->nr_uninterruptible),
10996 + atomic_read(&cvirt->nr_onhold));
10997 + /* add rest here */
10998 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11003 +#endif /* _VX_CVIRT_DEF_H */
11004 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/cvirt.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cvirt.h
11005 --- linux-2.6.35.7/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11006 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/cvirt.h 2010-08-02 17:05:06.000000000 +0200
11008 +#ifndef _VX_CVIRT_H
11009 +#define _VX_CVIRT_H
11016 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11021 +void vx_update_load(struct vx_info *);
11024 +int vx_do_syslog(int, char __user *, int);
11026 +#endif /* __KERNEL__ */
11027 +#endif /* _VX_CVIRT_H */
11028 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/debug_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/debug_cmd.h
11029 --- linux-2.6.35.7/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11030 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/debug_cmd.h 2010-08-02 17:05:06.000000000 +0200
11032 +#ifndef _VX_DEBUG_CMD_H
11033 +#define _VX_DEBUG_CMD_H
11036 +/* debug commands */
11038 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11040 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11041 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11043 +struct vcmd_read_history_v0 {
11046 + char __user *data;
11049 +struct vcmd_read_monitor_v0 {
11052 + char __user *data;
11058 +#ifdef CONFIG_COMPAT
11060 +#include <asm/compat.h>
11062 +struct vcmd_read_history_v0_x32 {
11065 + compat_uptr_t data_ptr;
11068 +struct vcmd_read_monitor_v0_x32 {
11071 + compat_uptr_t data_ptr;
11074 +#endif /* CONFIG_COMPAT */
11076 +extern int vc_dump_history(uint32_t);
11078 +extern int vc_read_history(uint32_t, void __user *);
11079 +extern int vc_read_monitor(uint32_t, void __user *);
11081 +#ifdef CONFIG_COMPAT
11083 +extern int vc_read_history_x32(uint32_t, void __user *);
11084 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11086 +#endif /* CONFIG_COMPAT */
11088 +#endif /* __KERNEL__ */
11089 +#endif /* _VX_DEBUG_CMD_H */
11090 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/debug.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/debug.h
11091 --- linux-2.6.35.7/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11092 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/debug.h 2010-08-02 17:05:06.000000000 +0200
11094 +#ifndef _VX_DEBUG_H
11095 +#define _VX_DEBUG_H
11098 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11099 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11100 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11102 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11103 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11104 +#define VXF_DEV "%p[%lu,%d:%d]"
11107 +#define vxd_path(p) \
11108 + ({ static char _buffer[PATH_MAX]; \
11109 + d_path(p, _buffer, sizeof(_buffer)); })
11111 +#define vxd_cond_path(n) \
11112 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11115 +#ifdef CONFIG_VSERVER_DEBUG
11117 +extern unsigned int vx_debug_switch;
11118 +extern unsigned int vx_debug_xid;
11119 +extern unsigned int vx_debug_nid;
11120 +extern unsigned int vx_debug_tag;
11121 +extern unsigned int vx_debug_net;
11122 +extern unsigned int vx_debug_limit;
11123 +extern unsigned int vx_debug_cres;
11124 +extern unsigned int vx_debug_dlim;
11125 +extern unsigned int vx_debug_quota;
11126 +extern unsigned int vx_debug_cvirt;
11127 +extern unsigned int vx_debug_space;
11128 +extern unsigned int vx_debug_misc;
11131 +#define VX_LOGLEVEL "vxD: "
11132 +#define VX_PROC_FMT "%p: "
11133 +#define VX_PROCESS current
11135 +#define vxdprintk(c, f, x...) \
11138 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11139 + VX_PROCESS , ##x); \
11142 +#define vxlprintk(c, f, x...) \
11145 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11148 +#define vxfprintk(c, f, x...) \
11151 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11157 +void dump_vx_info(struct vx_info *, int);
11158 +void dump_vx_info_inactive(int);
11160 +#else /* CONFIG_VSERVER_DEBUG */
11162 +#define vx_debug_switch 0
11163 +#define vx_debug_xid 0
11164 +#define vx_debug_nid 0
11165 +#define vx_debug_tag 0
11166 +#define vx_debug_net 0
11167 +#define vx_debug_limit 0
11168 +#define vx_debug_cres 0
11169 +#define vx_debug_dlim 0
11170 +#define vx_debug_cvirt 0
11172 +#define vxdprintk(x...) do { } while (0)
11173 +#define vxlprintk(x...) do { } while (0)
11174 +#define vxfprintk(x...) do { } while (0)
11176 +#endif /* CONFIG_VSERVER_DEBUG */
11179 +#ifdef CONFIG_VSERVER_WARN
11181 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11182 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
11183 +#define VX_WARN_XID "[xid #%u] "
11184 +#define VX_WARN_NID "[nid #%u] "
11185 +#define VX_WARN_TAG "[tag #%u] "
11187 +#define vxwprintk(c, f, x...) \
11190 + printk(VX_WARNLEVEL f "\n", ##x); \
11193 +#else /* CONFIG_VSERVER_WARN */
11195 +#define vxwprintk(x...) do { } while (0)
11197 +#endif /* CONFIG_VSERVER_WARN */
11199 +#define vxwprintk_task(c, f, x...) \
11200 + vxwprintk(c, VX_WARN_TASK f, \
11201 + current->comm, current->pid, \
11202 + current->xid, current->nid, current->tag, ##x)
11203 +#define vxwprintk_xid(c, f, x...) \
11204 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11205 +#define vxwprintk_nid(c, f, x...) \
11206 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11207 +#define vxwprintk_tag(c, f, x...) \
11208 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11210 +#ifdef CONFIG_VSERVER_DEBUG
11211 +#define vxd_assert_lock(l) assert_spin_locked(l)
11212 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11213 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11215 +#define vxd_assert_lock(l) do { } while (0)
11216 +#define vxd_assert(c, f, x...) do { } while (0)
11220 +#endif /* _VX_DEBUG_H */
11221 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/device_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/device_cmd.h
11222 --- linux-2.6.35.7/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11223 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/device_cmd.h 2010-08-02 17:05:06.000000000 +0200
11225 +#ifndef _VX_DEVICE_CMD_H
11226 +#define _VX_DEVICE_CMD_H
11229 +/* device vserver commands */
11231 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11232 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11234 +struct vcmd_set_mapping_v0 {
11235 + const char __user *device;
11236 + const char __user *target;
11243 +#ifdef CONFIG_COMPAT
11245 +#include <asm/compat.h>
11247 +struct vcmd_set_mapping_v0_x32 {
11248 + compat_uptr_t device_ptr;
11249 + compat_uptr_t target_ptr;
11253 +#endif /* CONFIG_COMPAT */
11255 +#include <linux/compiler.h>
11257 +extern int vc_set_mapping(struct vx_info *, void __user *);
11258 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11260 +#ifdef CONFIG_COMPAT
11262 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11263 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11265 +#endif /* CONFIG_COMPAT */
11267 +#endif /* __KERNEL__ */
11268 +#endif /* _VX_DEVICE_CMD_H */
11269 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/device_def.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/device_def.h
11270 --- linux-2.6.35.7/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11271 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/device_def.h 2010-08-02 17:05:06.000000000 +0200
11273 +#ifndef _VX_DEVICE_DEF_H
11274 +#define _VX_DEVICE_DEF_H
11276 +#include <linux/types.h>
11278 +struct vx_dmap_target {
11283 +struct _vx_device {
11284 +#ifdef CONFIG_VSERVER_DEVICE
11285 + struct vx_dmap_target targets[2];
11289 +#endif /* _VX_DEVICE_DEF_H */
11290 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/device.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/device.h
11291 --- linux-2.6.35.7/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11292 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/device.h 2010-08-02 17:05:06.000000000 +0200
11294 +#ifndef _VX_DEVICE_H
11295 +#define _VX_DEVICE_H
11298 +#define DATTR_CREATE 0x00000001
11299 +#define DATTR_OPEN 0x00000002
11301 +#define DATTR_REMAP 0x00000010
11303 +#define DATTR_MASK 0x00000013
11306 +#else /* _VX_DEVICE_H */
11307 +#warning duplicate inclusion
11308 +#endif /* _VX_DEVICE_H */
11309 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/dlimit_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/dlimit_cmd.h
11310 --- linux-2.6.35.7/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11311 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/dlimit_cmd.h 2010-08-02 17:05:06.000000000 +0200
11313 +#ifndef _VX_DLIMIT_CMD_H
11314 +#define _VX_DLIMIT_CMD_H
11317 +/* dlimit vserver commands */
11319 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11320 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11322 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11323 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11325 +struct vcmd_ctx_dlimit_base_v0 {
11326 + const char __user *name;
11330 +struct vcmd_ctx_dlimit_v0 {
11331 + const char __user *name;
11332 + uint32_t space_used; /* used space in kbytes */
11333 + uint32_t space_total; /* maximum space in kbytes */
11334 + uint32_t inodes_used; /* used inodes */
11335 + uint32_t inodes_total; /* maximum inodes */
11336 + uint32_t reserved; /* reserved for root in % */
11340 +#define CDLIM_UNSET ((uint32_t)0UL)
11341 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11342 +#define CDLIM_KEEP ((uint32_t)~1UL)
11344 +#define DLIME_UNIT 0
11345 +#define DLIME_KILO 1
11346 +#define DLIME_MEGA 2
11347 +#define DLIME_GIGA 3
11349 +#define DLIMF_SHIFT 0x10
11351 +#define DLIMS_USED 0
11352 +#define DLIMS_TOTAL 2
11355 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
11357 + int exp = (flags & DLIMF_SHIFT) ?
11358 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
11359 + return ((uint64_t)val) << (10 * exp);
11363 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
11367 + if (*flags & DLIMF_SHIFT) {
11368 + while (val > (1LL << 32) && (exp < 3)) {
11372 + *flags &= ~(DLIME_GIGA << shift);
11373 + *flags |= exp << shift;
11381 +#ifdef CONFIG_COMPAT
11383 +#include <asm/compat.h>
11385 +struct vcmd_ctx_dlimit_base_v0_x32 {
11386 + compat_uptr_t name_ptr;
11390 +struct vcmd_ctx_dlimit_v0_x32 {
11391 + compat_uptr_t name_ptr;
11392 + uint32_t space_used; /* used space in kbytes */
11393 + uint32_t space_total; /* maximum space in kbytes */
11394 + uint32_t inodes_used; /* used inodes */
11395 + uint32_t inodes_total; /* maximum inodes */
11396 + uint32_t reserved; /* reserved for root in % */
11400 +#endif /* CONFIG_COMPAT */
11402 +#include <linux/compiler.h>
11404 +extern int vc_add_dlimit(uint32_t, void __user *);
11405 +extern int vc_rem_dlimit(uint32_t, void __user *);
11407 +extern int vc_set_dlimit(uint32_t, void __user *);
11408 +extern int vc_get_dlimit(uint32_t, void __user *);
11410 +#ifdef CONFIG_COMPAT
11412 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11413 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11415 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11416 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11418 +#endif /* CONFIG_COMPAT */
11420 +#endif /* __KERNEL__ */
11421 +#endif /* _VX_DLIMIT_CMD_H */
11422 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/dlimit.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/dlimit.h
11423 --- linux-2.6.35.7/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11424 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/dlimit.h 2010-08-02 17:05:06.000000000 +0200
11426 +#ifndef _VX_DLIMIT_H
11427 +#define _VX_DLIMIT_H
11429 +#include "switch.h"
11434 +/* keep in sync with CDLIM_INFINITY */
11436 +#define DLIM_INFINITY (~0ULL)
11438 +#include <linux/spinlock.h>
11439 +#include <linux/rcupdate.h>
11441 +struct super_block;
11444 + struct hlist_node dl_hlist; /* linked list of contexts */
11445 + struct rcu_head dl_rcu; /* the rcu head */
11446 + tag_t dl_tag; /* context tag */
11447 + atomic_t dl_usecnt; /* usage count */
11448 + atomic_t dl_refcnt; /* reference count */
11450 + struct super_block *dl_sb; /* associated superblock */
11452 + spinlock_t dl_lock; /* protect the values */
11454 + unsigned long long dl_space_used; /* used space in bytes */
11455 + unsigned long long dl_space_total; /* maximum space in bytes */
11456 + unsigned long dl_inodes_used; /* used inodes */
11457 + unsigned long dl_inodes_total; /* maximum inodes */
11459 + unsigned int dl_nrlmult; /* non root limit mult */
11464 +extern void rcu_free_dl_info(struct rcu_head *);
11465 +extern void unhash_dl_info(struct dl_info *);
11467 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11472 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11474 +typedef uint64_t dlsize_t;
11476 +#endif /* __KERNEL__ */
11477 +#else /* _VX_DLIMIT_H */
11478 +#warning duplicate inclusion
11479 +#endif /* _VX_DLIMIT_H */
11480 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/global.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/global.h
11481 --- linux-2.6.35.7/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11482 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/global.h 2010-08-02 17:05:06.000000000 +0200
11484 +#ifndef _VX_GLOBAL_H
11485 +#define _VX_GLOBAL_H
11488 +extern atomic_t vx_global_ctotal;
11489 +extern atomic_t vx_global_cactive;
11491 +extern atomic_t nx_global_ctotal;
11492 +extern atomic_t nx_global_cactive;
11494 +extern atomic_t vs_global_nsproxy;
11495 +extern atomic_t vs_global_fs;
11496 +extern atomic_t vs_global_mnt_ns;
11497 +extern atomic_t vs_global_uts_ns;
11498 +extern atomic_t vs_global_user_ns;
11499 +extern atomic_t vs_global_pid_ns;
11502 +#endif /* _VX_GLOBAL_H */
11503 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/history.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/history.h
11504 --- linux-2.6.35.7/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11505 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/history.h 2010-08-02 17:05:06.000000000 +0200
11507 +#ifndef _VX_HISTORY_H
11508 +#define _VX_HISTORY_H
11513 + VXH_THROW_OOPS = 1,
11517 + VXH_INIT_VX_INFO,
11520 + VXH_CLAIM_VX_INFO,
11521 + VXH_RELEASE_VX_INFO,
11522 + VXH_ALLOC_VX_INFO,
11523 + VXH_DEALLOC_VX_INFO,
11524 + VXH_HASH_VX_INFO,
11525 + VXH_UNHASH_VX_INFO,
11527 + VXH_LOOKUP_VX_INFO,
11528 + VXH_CREATE_VX_INFO,
11531 +struct _vxhe_vxi {
11532 + struct vx_info *ptr;
11538 +struct _vxhe_set_clr {
11542 +struct _vxhe_loc_lookup {
11546 +struct _vx_hist_entry {
11548 + unsigned short seq;
11549 + unsigned short type;
11550 + struct _vxhe_vxi vxi;
11552 + struct _vxhe_set_clr sc;
11553 + struct _vxhe_loc_lookup ll;
11557 +#ifdef CONFIG_VSERVER_HISTORY
11559 +extern unsigned volatile int vxh_active;
11561 +struct _vx_hist_entry *vxh_advance(void *loc);
11565 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11567 + entry->vxi.ptr = vxi;
11569 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11570 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11571 + entry->vxi.xid = vxi->vx_id;
11576 +#define __HERE__ current_text_addr()
11578 +#define __VXH_BODY(__type, __data, __here) \
11579 + struct _vx_hist_entry *entry; \
11581 + preempt_disable(); \
11582 + entry = vxh_advance(__here); \
11584 + entry->type = __type; \
11585 + preempt_enable();
11588 + /* pass vxi only */
11590 +#define __VXH_SMPL \
11591 + __vxh_copy_vxi(entry, vxi)
11594 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11596 + __VXH_BODY(__type, __VXH_SMPL, __here)
11599 + /* pass vxi and data (void *) */
11601 +#define __VXH_DATA \
11602 + __vxh_copy_vxi(entry, vxi); \
11603 + entry->sc.data = data
11606 +void __vxh_data(struct vx_info *vxi, void *data,
11607 + int __type, void *__here)
11609 + __VXH_BODY(__type, __VXH_DATA, __here)
11612 + /* pass vxi and arg (long) */
11614 +#define __VXH_LONG \
11615 + __vxh_copy_vxi(entry, vxi); \
11616 + entry->ll.arg = arg
11619 +void __vxh_long(struct vx_info *vxi, long arg,
11620 + int __type, void *__here)
11622 + __VXH_BODY(__type, __VXH_LONG, __here)
11627 +void __vxh_throw_oops(void *__here)
11629 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11630 + /* prevent further acquisition */
11635 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11637 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11638 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11640 +#define __vxh_init_vx_info(v, d, h) \
11641 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11642 +#define __vxh_set_vx_info(v, d, h) \
11643 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11644 +#define __vxh_clr_vx_info(v, d, h) \
11645 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11647 +#define __vxh_claim_vx_info(v, d, h) \
11648 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11649 +#define __vxh_release_vx_info(v, d, h) \
11650 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11652 +#define vxh_alloc_vx_info(v) \
11653 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11654 +#define vxh_dealloc_vx_info(v) \
11655 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11657 +#define vxh_hash_vx_info(v) \
11658 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11659 +#define vxh_unhash_vx_info(v) \
11660 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11662 +#define vxh_loc_vx_info(v, l) \
11663 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11664 +#define vxh_lookup_vx_info(v, l) \
11665 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11666 +#define vxh_create_vx_info(v, l) \
11667 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11669 +extern void vxh_dump_history(void);
11672 +#else /* CONFIG_VSERVER_HISTORY */
11674 +#define __HERE__ 0
11676 +#define vxh_throw_oops() do { } while (0)
11678 +#define __vxh_get_vx_info(v, h) do { } while (0)
11679 +#define __vxh_put_vx_info(v, h) do { } while (0)
11681 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11682 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11683 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11685 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11686 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11688 +#define vxh_alloc_vx_info(v) do { } while (0)
11689 +#define vxh_dealloc_vx_info(v) do { } while (0)
11691 +#define vxh_hash_vx_info(v) do { } while (0)
11692 +#define vxh_unhash_vx_info(v) do { } while (0)
11694 +#define vxh_loc_vx_info(v, l) do { } while (0)
11695 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11696 +#define vxh_create_vx_info(v, l) do { } while (0)
11698 +#define vxh_dump_history() do { } while (0)
11701 +#endif /* CONFIG_VSERVER_HISTORY */
11703 +#endif /* _VX_HISTORY_H */
11704 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/inode_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/inode_cmd.h
11705 --- linux-2.6.35.7/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
11706 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/inode_cmd.h 2010-08-02 17:05:06.000000000 +0200
11708 +#ifndef _VX_INODE_CMD_H
11709 +#define _VX_INODE_CMD_H
11712 +/* inode vserver commands */
11714 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
11715 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
11717 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
11718 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
11720 +struct vcmd_ctx_iattr_v1 {
11721 + const char __user *name;
11727 +struct vcmd_ctx_fiattr_v0 {
11737 +#ifdef CONFIG_COMPAT
11739 +#include <asm/compat.h>
11741 +struct vcmd_ctx_iattr_v1_x32 {
11742 + compat_uptr_t name_ptr;
11748 +#endif /* CONFIG_COMPAT */
11750 +#include <linux/compiler.h>
11752 +extern int vc_get_iattr(void __user *);
11753 +extern int vc_set_iattr(void __user *);
11755 +extern int vc_fget_iattr(uint32_t, void __user *);
11756 +extern int vc_fset_iattr(uint32_t, void __user *);
11758 +#ifdef CONFIG_COMPAT
11760 +extern int vc_get_iattr_x32(void __user *);
11761 +extern int vc_set_iattr_x32(void __user *);
11763 +#endif /* CONFIG_COMPAT */
11765 +#endif /* __KERNEL__ */
11766 +#endif /* _VX_INODE_CMD_H */
11767 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/inode.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/inode.h
11768 --- linux-2.6.35.7/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
11769 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/inode.h 2010-08-02 17:05:06.000000000 +0200
11771 +#ifndef _VX_INODE_H
11772 +#define _VX_INODE_H
11775 +#define IATTR_TAG 0x01000000
11777 +#define IATTR_ADMIN 0x00000001
11778 +#define IATTR_WATCH 0x00000002
11779 +#define IATTR_HIDE 0x00000004
11780 +#define IATTR_FLAGS 0x00000007
11782 +#define IATTR_BARRIER 0x00010000
11783 +#define IATTR_IXUNLINK 0x00020000
11784 +#define IATTR_IMMUTABLE 0x00040000
11785 +#define IATTR_COW 0x00080000
11790 +#ifdef CONFIG_VSERVER_PROC_SECURE
11791 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11792 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11794 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11795 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11798 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11800 +#endif /* __KERNEL__ */
11802 +/* inode ioctls */
11804 +#define FIOC_GETXFLG _IOR('x', 5, long)
11805 +#define FIOC_SETXFLG _IOW('x', 6, long)
11807 +#else /* _VX_INODE_H */
11808 +#warning duplicate inclusion
11809 +#endif /* _VX_INODE_H */
11810 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/Kbuild linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/Kbuild
11811 --- linux-2.6.35.7/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11812 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/Kbuild 2010-08-02 17:05:06.000000000 +0200
11815 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11816 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11817 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11818 + debug_cmd.h device_cmd.h
11820 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11822 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/limit_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/limit_cmd.h
11823 --- linux-2.6.35.7/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11824 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/limit_cmd.h 2010-08-02 17:05:06.000000000 +0200
11826 +#ifndef _VX_LIMIT_CMD_H
11827 +#define _VX_LIMIT_CMD_H
11830 +/* rlimit vserver commands */
11832 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
11833 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
11834 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
11835 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
11836 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
11838 +struct vcmd_ctx_rlimit_v0 {
11840 + uint64_t minimum;
11841 + uint64_t softlimit;
11842 + uint64_t maximum;
11845 +struct vcmd_ctx_rlimit_mask_v0 {
11846 + uint32_t minimum;
11847 + uint32_t softlimit;
11848 + uint32_t maximum;
11851 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
11853 +struct vcmd_rlimit_stat_v0 {
11857 + uint64_t minimum;
11858 + uint64_t maximum;
11861 +#define CRLIM_UNSET (0ULL)
11862 +#define CRLIM_INFINITY (~0ULL)
11863 +#define CRLIM_KEEP (~1ULL)
11867 +#ifdef CONFIG_IA32_EMULATION
11869 +struct vcmd_ctx_rlimit_v0_x32 {
11871 + uint64_t minimum;
11872 + uint64_t softlimit;
11873 + uint64_t maximum;
11874 +} __attribute__ ((packed));
11876 +#endif /* CONFIG_IA32_EMULATION */
11878 +#include <linux/compiler.h>
11880 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
11881 +extern int vc_get_rlimit(struct vx_info *, void __user *);
11882 +extern int vc_set_rlimit(struct vx_info *, void __user *);
11883 +extern int vc_reset_hits(struct vx_info *, void __user *);
11884 +extern int vc_reset_minmax(struct vx_info *, void __user *);
11886 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
11888 +#ifdef CONFIG_IA32_EMULATION
11890 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
11891 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
11893 +#endif /* CONFIG_IA32_EMULATION */
11895 +#endif /* __KERNEL__ */
11896 +#endif /* _VX_LIMIT_CMD_H */
11897 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/limit_def.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/limit_def.h
11898 --- linux-2.6.35.7/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
11899 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/limit_def.h 2010-08-02 17:05:06.000000000 +0200
11901 +#ifndef _VX_LIMIT_DEF_H
11902 +#define _VX_LIMIT_DEF_H
11904 +#include <asm/atomic.h>
11905 +#include <asm/resource.h>
11907 +#include "limit.h"
11910 +struct _vx_res_limit {
11911 + rlim_t soft; /* Context soft limit */
11912 + rlim_t hard; /* Context hard limit */
11914 + rlim_atomic_t rcur; /* Current value */
11915 + rlim_t rmin; /* Context minimum */
11916 + rlim_t rmax; /* Context maximum */
11918 + atomic_t lhit; /* Limit hits */
11921 +/* context sub struct */
11923 +struct _vx_limit {
11924 + struct _vx_res_limit res[NUM_LIMITS];
11927 +#ifdef CONFIG_VSERVER_DEBUG
11929 +static inline void __dump_vx_limit(struct _vx_limit *limit)
11933 + printk("\t_vx_limit:");
11934 + for (i = 0; i < NUM_LIMITS; i++) {
11935 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
11936 + i, (unsigned long)__rlim_get(limit, i),
11937 + (unsigned long)__rlim_rmin(limit, i),
11938 + (unsigned long)__rlim_rmax(limit, i),
11939 + (long)__rlim_soft(limit, i),
11940 + (long)__rlim_hard(limit, i),
11941 + atomic_read(&__rlim_lhit(limit, i)));
11947 +#endif /* _VX_LIMIT_DEF_H */
11948 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/limit.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/limit.h
11949 --- linux-2.6.35.7/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
11950 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/limit.h 2010-08-02 17:05:06.000000000 +0200
11952 +#ifndef _VX_LIMIT_H
11953 +#define _VX_LIMIT_H
11955 +#define VLIMIT_NSOCK 16
11956 +#define VLIMIT_OPENFD 17
11957 +#define VLIMIT_ANON 18
11958 +#define VLIMIT_SHMEM 19
11959 +#define VLIMIT_SEMARY 20
11960 +#define VLIMIT_NSEMS 21
11961 +#define VLIMIT_DENTRY 22
11962 +#define VLIMIT_MAPPED 23
11967 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
11969 +/* keep in sync with CRLIM_INFINITY */
11971 +#define VLIM_INFINITY (~0ULL)
11973 +#include <asm/atomic.h>
11974 +#include <asm/resource.h>
11976 +#ifndef RLIM_INFINITY
11977 +#warning RLIM_INFINITY is undefined
11980 +#define __rlim_val(l, r, v) ((l)->res[r].v)
11982 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
11983 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
11985 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
11986 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
11987 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
11989 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
11990 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
11992 +typedef atomic_long_t rlim_atomic_t;
11993 +typedef unsigned long rlim_t;
11995 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
11996 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
11997 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
11998 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
11999 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12000 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12003 +#if (RLIM_INFINITY == VLIM_INFINITY)
12004 +#define VX_VLIM(r) ((long long)(long)(r))
12005 +#define VX_RLIM(v) ((rlim_t)(v))
12007 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12008 + ? VLIM_INFINITY : (long long)(r))
12009 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12010 + ? RLIM_INFINITY : (rlim_t)(v))
12015 +void vx_vsi_meminfo(struct sysinfo *);
12016 +void vx_vsi_swapinfo(struct sysinfo *);
12017 +long vx_vsi_cached(struct sysinfo *);
12019 +#define NUM_LIMITS 24
12021 +#endif /* __KERNEL__ */
12022 +#endif /* _VX_LIMIT_H */
12023 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/limit_int.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/limit_int.h
12024 --- linux-2.6.35.7/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12025 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/limit_int.h 2010-08-02 17:05:06.000000000 +0200
12027 +#ifndef _VX_LIMIT_INT_H
12028 +#define _VX_LIMIT_INT_H
12030 +#include "context.h"
12034 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12035 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12037 +extern const char *vlimit_name[NUM_LIMITS];
12039 +static inline void __vx_acc_cres(struct vx_info *vxi,
12040 + int res, int dir, void *_data, char *_file, int _line)
12042 + if (VXD_RCRES_COND(res))
12043 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12044 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12045 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12046 + (dir > 0) ? "++" : "--", _data, _file, _line);
12051 + __rlim_inc(&vxi->limit, res);
12053 + __rlim_dec(&vxi->limit, res);
12056 +static inline void __vx_add_cres(struct vx_info *vxi,
12057 + int res, int amount, void *_data, char *_file, int _line)
12059 + if (VXD_RCRES_COND(res))
12060 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12061 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12062 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12063 + amount, _data, _file, _line);
12068 + __rlim_add(&vxi->limit, res, amount);
12072 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12074 + int cond = (value > __rlim_rmax(limit, res));
12077 + __rlim_rmax(limit, res) = value;
12082 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12084 + int cond = (value < __rlim_rmin(limit, res));
12087 + __rlim_rmin(limit, res) = value;
12092 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12094 + if (!__vx_cres_adjust_max(limit, res, value))
12095 + __vx_cres_adjust_min(limit, res, value);
12100 + +1 ... no limit hit
12101 + -1 ... over soft limit
12102 + 0 ... over hard limit */
12104 +static inline int __vx_cres_avail(struct vx_info *vxi,
12105 + int res, int num, char *_file, int _line)
12107 + struct _vx_limit *limit;
12110 + if (VXD_RLIMIT_COND(res))
12111 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12112 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12113 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12114 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12115 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12116 + num, _file, _line);
12120 + limit = &vxi->limit;
12121 + value = __rlim_get(limit, res);
12123 + if (!__vx_cres_adjust_max(limit, res, value))
12124 + __vx_cres_adjust_min(limit, res, value);
12129 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12131 + if (value + num <= __rlim_soft(limit, res))
12134 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12136 + if (value + num <= __rlim_hard(limit, res))
12139 + __rlim_hit(limit, res);
12144 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12147 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12149 + rlim_t value, sum = 0;
12152 + while ((res = *array++)) {
12153 + value = __rlim_get(limit, res);
12154 + __vx_cres_fixup(limit, res, value);
12161 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12163 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12164 + int res = *array;
12166 + if (value == __rlim_get(limit, res))
12169 + __rlim_set(limit, res, value);
12170 + /* now adjust min/max */
12171 + if (!__vx_cres_adjust_max(limit, res, value))
12172 + __vx_cres_adjust_min(limit, res, value);
12177 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12178 + const int *array, int num, char *_file, int _line)
12180 + struct _vx_limit *limit;
12181 + rlim_t value = 0;
12189 + limit = &vxi->limit;
12191 + value = __vx_cres_array_sum(limit, array + 1);
12193 + __rlim_set(limit, res, value);
12194 + __vx_cres_fixup(limit, res, value);
12196 + return __vx_cres_avail(vxi, res, num, _file, _line);
12200 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12205 + /* complex resources first */
12206 + if ((id < 0) || (id == RLIMIT_RSS))
12207 + __vx_cres_array_fixup(limit, VLA_RSS);
12209 + for (res = 0; res < NUM_LIMITS; res++) {
12210 + if ((id > 0) && (res != id))
12213 + value = __rlim_get(limit, res);
12214 + __vx_cres_fixup(limit, res, value);
12216 + /* not supposed to happen, maybe warn? */
12217 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12218 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12223 +#endif /* __KERNEL__ */
12224 +#endif /* _VX_LIMIT_INT_H */
12225 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/monitor.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/monitor.h
12226 --- linux-2.6.35.7/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12227 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/monitor.h 2010-08-02 17:05:06.000000000 +0200
12229 +#ifndef _VX_MONITOR_H
12230 +#define _VX_MONITOR_H
12232 +#include <linux/types.h>
12239 + VXM_UPDATE = 0x20,
12243 + VXM_RQINFO_1 = 0x24,
12246 + VXM_ACTIVATE = 0x40,
12253 + VXM_MIGRATE = 0x48,
12256 + /* all other bits are flags */
12257 + VXM_SCHED = 0x80,
12260 +struct _vxm_update_1 {
12261 + uint32_t tokens_max;
12262 + uint32_t fill_rate;
12263 + uint32_t interval;
12266 +struct _vxm_update_2 {
12267 + uint32_t tokens_min;
12268 + uint32_t fill_rate;
12269 + uint32_t interval;
12272 +struct _vxm_rqinfo_1 {
12273 + uint16_t running;
12277 + uint32_t idle_tokens;
12280 +struct _vxm_rqinfo_2 {
12281 + uint32_t norm_time;
12282 + uint32_t idle_time;
12283 + uint32_t idle_skip;
12286 +struct _vxm_sched {
12288 + uint32_t norm_time;
12289 + uint32_t idle_time;
12292 +struct _vxm_task {
12297 +struct _vxm_event {
12306 + struct _vxm_task tsk;
12310 +struct _vx_mon_entry {
12314 + struct _vxm_event ev;
12315 + struct _vxm_sched sd;
12316 + struct _vxm_update_1 u1;
12317 + struct _vxm_update_2 u2;
12318 + struct _vxm_rqinfo_1 q1;
12319 + struct _vxm_rqinfo_2 q2;
12324 +#endif /* _VX_MONITOR_H */
12325 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/network_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/network_cmd.h
12326 --- linux-2.6.35.7/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12327 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/network_cmd.h 2010-08-02 17:05:06.000000000 +0200
12329 +#ifndef _VX_NETWORK_CMD_H
12330 +#define _VX_NETWORK_CMD_H
12333 +/* vinfo commands */
12335 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12338 +extern int vc_task_nid(uint32_t);
12340 +#endif /* __KERNEL__ */
12342 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12344 +struct vcmd_nx_info_v0 {
12346 + /* more to come */
12350 +extern int vc_nx_info(struct nx_info *, void __user *);
12352 +#endif /* __KERNEL__ */
12354 +#include <linux/in.h>
12355 +#include <linux/in6.h>
12357 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12358 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12360 +struct vcmd_net_create {
12361 + uint64_t flagword;
12364 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12366 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12367 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12369 +struct vcmd_net_addr_v0 {
12372 + struct in_addr ip[4];
12373 + struct in_addr mask[4];
12376 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
12377 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
12379 +struct vcmd_net_addr_ipv4_v1 {
12382 + struct in_addr ip;
12383 + struct in_addr mask;
12386 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12387 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12389 +struct vcmd_net_addr_ipv6_v1 {
12393 + struct in6_addr ip;
12394 + struct in6_addr mask;
12397 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12398 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12400 +struct vcmd_match_ipv4_v0 {
12405 + struct in_addr ip;
12406 + struct in_addr ip2;
12407 + struct in_addr mask;
12410 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12411 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12413 +struct vcmd_match_ipv6_v0 {
12418 + struct in6_addr ip;
12419 + struct in6_addr ip2;
12420 + struct in6_addr mask;
12425 +extern int vc_net_create(uint32_t, void __user *);
12426 +extern int vc_net_migrate(struct nx_info *, void __user *);
12428 +extern int vc_net_add(struct nx_info *, void __user *);
12429 +extern int vc_net_remove(struct nx_info *, void __user *);
12431 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12432 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
12434 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12435 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12437 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12438 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12440 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12441 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12443 +#endif /* __KERNEL__ */
12446 +/* flag commands */
12448 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12449 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12451 +struct vcmd_net_flags_v0 {
12452 + uint64_t flagword;
12457 +extern int vc_get_nflags(struct nx_info *, void __user *);
12458 +extern int vc_set_nflags(struct nx_info *, void __user *);
12460 +#endif /* __KERNEL__ */
12463 +/* network caps commands */
12465 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12466 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12468 +struct vcmd_net_caps_v0 {
12474 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12475 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12477 +#endif /* __KERNEL__ */
12478 +#endif /* _VX_CONTEXT_CMD_H */
12479 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/network.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/network.h
12480 --- linux-2.6.35.7/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12481 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/network.h 2010-08-02 17:05:06.000000000 +0200
12483 +#ifndef _VX_NETWORK_H
12484 +#define _VX_NETWORK_H
12486 +#include <linux/types.h>
12489 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12492 +/* network flags */
12494 +#define NXF_INFO_PRIVATE 0x00000008
12496 +#define NXF_SINGLE_IP 0x00000100
12497 +#define NXF_LBACK_REMAP 0x00000200
12498 +#define NXF_LBACK_ALLOW 0x00000400
12500 +#define NXF_HIDE_NETIF 0x02000000
12501 +#define NXF_HIDE_LBACK 0x04000000
12503 +#define NXF_STATE_SETUP (1ULL << 32)
12504 +#define NXF_STATE_ADMIN (1ULL << 34)
12506 +#define NXF_SC_HELPER (1ULL << 36)
12507 +#define NXF_PERSISTENT (1ULL << 38)
12509 +#define NXF_ONE_TIME (0x0005ULL << 32)
12512 +#define NXF_INIT_SET (__nxf_init_set())
12514 +static inline uint64_t __nxf_init_set(void) {
12515 + return NXF_STATE_ADMIN
12516 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12517 + | NXF_LBACK_REMAP
12520 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12523 + | NXF_HIDE_NETIF;
12527 +/* network caps */
12529 +#define NXC_TUN_CREATE 0x00000001
12531 +#define NXC_RAW_ICMP 0x00000100
12534 +/* address types */
12536 +#define NXA_TYPE_IPV4 0x0001
12537 +#define NXA_TYPE_IPV6 0x0002
12539 +#define NXA_TYPE_NONE 0x0000
12540 +#define NXA_TYPE_ANY 0x00FF
12542 +#define NXA_TYPE_ADDR 0x0010
12543 +#define NXA_TYPE_MASK 0x0020
12544 +#define NXA_TYPE_RANGE 0x0040
12546 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12548 +#define NXA_MOD_BCAST 0x0100
12549 +#define NXA_MOD_LBACK 0x0200
12551 +#define NXA_LOOPBACK 0x1000
12553 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12554 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12558 +#include <linux/list.h>
12559 +#include <linux/spinlock.h>
12560 +#include <linux/rcupdate.h>
12561 +#include <linux/in.h>
12562 +#include <linux/in6.h>
12563 +#include <asm/atomic.h>
12565 +struct nx_addr_v4 {
12566 + struct nx_addr_v4 *next;
12567 + struct in_addr ip[2];
12568 + struct in_addr mask;
12573 +struct nx_addr_v6 {
12574 + struct nx_addr_v6 *next;
12575 + struct in6_addr ip;
12576 + struct in6_addr mask;
12583 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12584 + nid_t nx_id; /* vnet id */
12585 + atomic_t nx_usecnt; /* usage count */
12586 + atomic_t nx_tasks; /* tasks count */
12587 + int nx_state; /* context state */
12589 + uint64_t nx_flags; /* network flag word */
12590 + uint64_t nx_ncaps; /* network capabilities */
12592 + struct in_addr v4_lback; /* Loopback address */
12593 + struct in_addr v4_bcast; /* Broadcast address */
12594 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12595 +#ifdef CONFIG_IPV6
12596 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12598 + char nx_name[65]; /* network context name */
12602 +/* status flags */
12604 +#define NXS_HASHED 0x0001
12605 +#define NXS_SHUTDOWN 0x0100
12606 +#define NXS_RELEASED 0x8000
12608 +extern struct nx_info *lookup_nx_info(int);
12610 +extern int get_nid_list(int, unsigned int *, int);
12611 +extern int nid_is_hashed(nid_t);
12613 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12615 +extern long vs_net_change(struct nx_info *, unsigned int);
12620 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12621 +#ifdef CONFIG_IPV6
12622 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12624 +#define NX_IPV6(n) (0)
12627 +#endif /* __KERNEL__ */
12628 +#endif /* _VX_NETWORK_H */
12629 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/percpu.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/percpu.h
12630 --- linux-2.6.35.7/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12631 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/percpu.h 2010-08-02 17:05:06.000000000 +0200
12633 +#ifndef _VX_PERCPU_H
12634 +#define _VX_PERCPU_H
12636 +#include "cvirt_def.h"
12637 +#include "sched_def.h"
12639 +struct _vx_percpu {
12640 + struct _vx_cvirt_pc cvirt;
12641 + struct _vx_sched_pc sched;
12644 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12646 +#endif /* _VX_PERCPU_H */
12647 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/pid.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/pid.h
12648 --- linux-2.6.35.7/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12649 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/pid.h 2010-08-02 17:05:06.000000000 +0200
12651 +#ifndef _VSERVER_PID_H
12652 +#define _VSERVER_PID_H
12654 +/* pid faking stuff */
12656 +#define vx_info_map_pid(v, p) \
12657 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12658 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12659 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
12660 +#define vx_map_tgid(p) vx_map_pid(p)
12662 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12663 + const char *func, const char *file, int line)
12665 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12666 + vxfprintk(VXD_CBIT(cvirt, 2),
12667 + "vx_map_tgid: %p/%llx: %d -> %d",
12668 + vxi, (long long)vxi->vx_flags, pid,
12669 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12670 + func, file, line);
12673 + if (pid == vxi->vx_initpid)
12679 +#define vx_info_rmap_pid(v, p) \
12680 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12681 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
12682 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12684 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12685 + const char *func, const char *file, int line)
12687 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12688 + vxfprintk(VXD_CBIT(cvirt, 2),
12689 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12690 + vxi, (long long)vxi->vx_flags, pid,
12691 + (pid == 1) ? vxi->vx_initpid : pid,
12692 + func, file, line);
12693 + if ((pid == 1) && vxi->vx_initpid)
12694 + return vxi->vx_initpid;
12695 + if (pid == vxi->vx_initpid)
12702 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/sched_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/sched_cmd.h
12703 --- linux-2.6.35.7/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12704 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/sched_cmd.h 2010-08-02 17:05:06.000000000 +0200
12706 +#ifndef _VX_SCHED_CMD_H
12707 +#define _VX_SCHED_CMD_H
12710 +/* sched vserver commands */
12712 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
12713 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
12714 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
12716 +struct vcmd_set_sched_v2 {
12717 + int32_t fill_rate;
12718 + int32_t interval;
12720 + int32_t tokens_min;
12721 + int32_t tokens_max;
12722 + uint64_t cpu_mask;
12725 +struct vcmd_set_sched_v3 {
12726 + uint32_t set_mask;
12727 + int32_t fill_rate;
12728 + int32_t interval;
12730 + int32_t tokens_min;
12731 + int32_t tokens_max;
12732 + int32_t priority_bias;
12735 +struct vcmd_set_sched_v4 {
12736 + uint32_t set_mask;
12737 + int32_t fill_rate;
12738 + int32_t interval;
12740 + int32_t tokens_min;
12741 + int32_t tokens_max;
12742 + int32_t prio_bias;
12744 + int32_t bucket_id;
12747 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
12748 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
12750 +struct vcmd_sched_v5 {
12753 + int32_t bucket_id;
12754 + int32_t fill_rate[2];
12755 + int32_t interval[2];
12757 + int32_t tokens_min;
12758 + int32_t tokens_max;
12759 + int32_t prio_bias;
12762 +#define VXSM_FILL_RATE 0x0001
12763 +#define VXSM_INTERVAL 0x0002
12764 +#define VXSM_FILL_RATE2 0x0004
12765 +#define VXSM_INTERVAL2 0x0008
12766 +#define VXSM_TOKENS 0x0010
12767 +#define VXSM_TOKENS_MIN 0x0020
12768 +#define VXSM_TOKENS_MAX 0x0040
12769 +#define VXSM_PRIO_BIAS 0x0100
12771 +#define VXSM_IDLE_TIME 0x0200
12772 +#define VXSM_FORCE 0x0400
12774 +#define VXSM_V3_MASK 0x0173
12775 +#define VXSM_SET_MASK 0x01FF
12777 +#define VXSM_CPU_ID 0x1000
12778 +#define VXSM_BUCKET_ID 0x2000
12780 +#define VXSM_MSEC 0x4000
12782 +#define SCHED_KEEP (-2) /* only for v2 */
12786 +#include <linux/compiler.h>
12788 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
12789 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
12790 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
12791 +extern int vc_set_sched(struct vx_info *, void __user *);
12792 +extern int vc_get_sched(struct vx_info *, void __user *);
12794 +#endif /* __KERNEL__ */
12796 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
12798 +struct vcmd_sched_info {
12800 + int32_t bucket_id;
12801 + uint64_t user_msec;
12802 + uint64_t sys_msec;
12803 + uint64_t hold_msec;
12804 + uint32_t token_usec;
12805 + int32_t vavavoom;
12810 +extern int vc_sched_info(struct vx_info *, void __user *);
12812 +#endif /* __KERNEL__ */
12813 +#endif /* _VX_SCHED_CMD_H */
12814 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/sched_def.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/sched_def.h
12815 --- linux-2.6.35.7/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
12816 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/sched_def.h 2010-08-02 17:05:06.000000000 +0200
12818 +#ifndef _VX_SCHED_DEF_H
12819 +#define _VX_SCHED_DEF_H
12821 +#include <linux/spinlock.h>
12822 +#include <linux/jiffies.h>
12823 +#include <linux/cpumask.h>
12824 +#include <asm/atomic.h>
12825 +#include <asm/param.h>
12828 +/* context sub struct */
12830 +struct _vx_sched {
12831 + spinlock_t tokens_lock; /* lock for token bucket */
12833 + int tokens; /* number of CPU tokens */
12834 + int fill_rate[2]; /* Fill rate: add X tokens... */
12835 + int interval[2]; /* Divisor: per Y jiffies */
12836 + int tokens_min; /* Limit: minimum for unhold */
12837 + int tokens_max; /* Limit: no more than N tokens */
12839 + int prio_bias; /* bias offset for priority */
12841 + unsigned update_mask; /* which features should be updated */
12842 + cpumask_t update; /* CPUs which should update */
12845 +struct _vx_sched_pc {
12846 + int tokens; /* number of CPU tokens */
12847 + int flags; /* bucket flags */
12849 + int fill_rate[2]; /* Fill rate: add X tokens... */
12850 + int interval[2]; /* Divisor: per Y jiffies */
12851 + int tokens_min; /* Limit: minimum for unhold */
12852 + int tokens_max; /* Limit: no more than N tokens */
12854 + int prio_bias; /* bias offset for priority */
12855 + int vavavoom; /* last calculated vavavoom */
12857 + unsigned long norm_time; /* last time accounted */
12858 + unsigned long idle_time; /* non linear time for fair sched */
12859 + unsigned long token_time; /* token time for accounting */
12860 + unsigned long onhold; /* jiffies when put on hold */
12862 + uint64_t user_ticks; /* token tick events */
12863 + uint64_t sys_ticks; /* token tick events */
12864 + uint64_t hold_ticks; /* token ticks paused */
12868 +#define VXSF_ONHOLD 0x0001
12869 +#define VXSF_IDLE_TIME 0x0100
12871 +#ifdef CONFIG_VSERVER_DEBUG
12873 +static inline void __dump_vx_sched(struct _vx_sched *sched)
12875 + printk("\t_vx_sched:\n");
12876 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
12877 + sched->fill_rate[0], sched->interval[0],
12878 + sched->fill_rate[1], sched->interval[1],
12879 + sched->tokens_min, sched->tokens_max);
12880 + printk("\t priority = %4d\n", sched->prio_bias);
12885 +#endif /* _VX_SCHED_DEF_H */
12886 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/sched.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/sched.h
12887 --- linux-2.6.35.7/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
12888 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/sched.h 2010-08-02 17:05:06.000000000 +0200
12890 +#ifndef _VX_SCHED_H
12891 +#define _VX_SCHED_H
12898 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12903 +void vx_update_load(struct vx_info *);
12906 +int vx_tokens_recalc(struct _vx_sched_pc *,
12907 + unsigned long *, unsigned long *, int [2]);
12909 +void vx_update_sched_param(struct _vx_sched *sched,
12910 + struct _vx_sched_pc *sched_pc);
12912 +#endif /* __KERNEL__ */
12913 +#else /* _VX_SCHED_H */
12914 +#warning duplicate inclusion
12915 +#endif /* _VX_SCHED_H */
12916 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/signal_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/signal_cmd.h
12917 --- linux-2.6.35.7/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
12918 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/signal_cmd.h 2010-08-02 17:05:06.000000000 +0200
12920 +#ifndef _VX_SIGNAL_CMD_H
12921 +#define _VX_SIGNAL_CMD_H
12924 +/* signalling vserver commands */
12926 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
12927 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
12929 +struct vcmd_ctx_kill_v0 {
12934 +struct vcmd_wait_exit_v0 {
12935 + int32_t reboot_cmd;
12936 + int32_t exit_code;
12941 +extern int vc_ctx_kill(struct vx_info *, void __user *);
12942 +extern int vc_wait_exit(struct vx_info *, void __user *);
12944 +#endif /* __KERNEL__ */
12946 +/* process alteration commands */
12948 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
12949 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
12951 +struct vcmd_pflags_v0 {
12952 + uint32_t flagword;
12958 +extern int vc_get_pflags(uint32_t pid, void __user *);
12959 +extern int vc_set_pflags(uint32_t pid, void __user *);
12961 +#endif /* __KERNEL__ */
12962 +#endif /* _VX_SIGNAL_CMD_H */
12963 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/signal.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/signal.h
12964 --- linux-2.6.35.7/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
12965 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/signal.h 2010-08-02 17:05:06.000000000 +0200
12967 +#ifndef _VX_SIGNAL_H
12968 +#define _VX_SIGNAL_H
12975 +int vx_info_kill(struct vx_info *, int, int);
12977 +#endif /* __KERNEL__ */
12978 +#else /* _VX_SIGNAL_H */
12979 +#warning duplicate inclusion
12980 +#endif /* _VX_SIGNAL_H */
12981 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/space_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/space_cmd.h
12982 --- linux-2.6.35.7/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
12983 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/space_cmd.h 2010-08-02 17:05:06.000000000 +0200
12985 +#ifndef _VX_SPACE_CMD_H
12986 +#define _VX_SPACE_CMD_H
12989 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
12990 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
12991 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
12993 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
12994 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
12995 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
12997 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
12999 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13000 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13003 +struct vcmd_space_mask_v1 {
13007 +struct vcmd_space_mask_v2 {
13015 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13016 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13017 +extern int vc_enter_space(struct vx_info *, void __user *);
13018 +extern int vc_set_space(struct vx_info *, void __user *);
13019 +extern int vc_get_space_mask(void __user *, int);
13021 +#endif /* __KERNEL__ */
13022 +#endif /* _VX_SPACE_CMD_H */
13023 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/space.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/space.h
13024 --- linux-2.6.35.7/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13025 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/space.h 2010-08-02 17:05:06.000000000 +0200
13027 +#ifndef _VX_SPACE_H
13028 +#define _VX_SPACE_H
13030 +#include <linux/types.h>
13034 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13036 +#else /* _VX_SPACE_H */
13037 +#warning duplicate inclusion
13038 +#endif /* _VX_SPACE_H */
13039 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/switch.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/switch.h
13040 --- linux-2.6.35.7/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13041 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/switch.h 2010-08-02 17:05:06.000000000 +0200
13043 +#ifndef _VX_SWITCH_H
13044 +#define _VX_SWITCH_H
13046 +#include <linux/types.h>
13049 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13050 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13051 +#define VC_VERSION(c) ((c) & 0xFFF)
13053 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13054 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13058 + Syscall Matrix V2.8
13060 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13061 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13062 + |INFO |SETUP | |MOVE | | | | | |
13063 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13064 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13065 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13066 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13067 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13068 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13069 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13070 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13071 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13072 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13073 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13074 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13075 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13076 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13077 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13078 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13079 + OTHER |VSTAT | | | | | | |VINFO | |
13080 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13081 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13082 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13083 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13084 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13085 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13086 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13087 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13091 +#define VC_CAT_VERSION 0
13093 +#define VC_CAT_VSETUP 1
13094 +#define VC_CAT_VHOST 2
13096 +#define VC_CAT_DEVICE 6
13098 +#define VC_CAT_VPROC 9
13099 +#define VC_CAT_PROCALT 10
13100 +#define VC_CAT_PROCMIG 11
13101 +#define VC_CAT_PROCTRL 12
13103 +#define VC_CAT_SCHED 14
13104 +#define VC_CAT_MEMCTRL 20
13106 +#define VC_CAT_VNET 25
13107 +#define VC_CAT_NETALT 26
13108 +#define VC_CAT_NETMIG 27
13109 +#define VC_CAT_NETCTRL 28
13111 +#define VC_CAT_TAGMIG 35
13112 +#define VC_CAT_DLIMIT 36
13113 +#define VC_CAT_INODE 38
13115 +#define VC_CAT_VSTAT 40
13116 +#define VC_CAT_VINFO 46
13117 +#define VC_CAT_EVENT 48
13119 +#define VC_CAT_FLAGS 52
13120 +#define VC_CAT_VSPACE 54
13121 +#define VC_CAT_DEBUG 56
13122 +#define VC_CAT_RLIMIT 60
13124 +#define VC_CAT_SYSTEST 61
13125 +#define VC_CAT_COMPAT 63
13127 +/* query version */
13129 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13130 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13135 +#include <linux/errno.h>
13137 +#endif /* __KERNEL__ */
13139 +#endif /* _VX_SWITCH_H */
13141 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/tag_cmd.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/tag_cmd.h
13142 --- linux-2.6.35.7/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13143 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/tag_cmd.h 2010-08-02 17:05:06.000000000 +0200
13145 +#ifndef _VX_TAG_CMD_H
13146 +#define _VX_TAG_CMD_H
13149 +/* vinfo commands */
13151 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13154 +extern int vc_task_tag(uint32_t);
13156 +#endif /* __KERNEL__ */
13158 +/* context commands */
13160 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13163 +extern int vc_tag_migrate(uint32_t);
13165 +#endif /* __KERNEL__ */
13166 +#endif /* _VX_TAG_CMD_H */
13167 diff -NurpP --minimal linux-2.6.35.7/include/linux/vserver/tag.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/tag.h
13168 --- linux-2.6.35.7/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13169 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vserver/tag.h 2010-08-02 17:05:06.000000000 +0200
13174 +#include <linux/types.h>
13177 +#define DX_TAG(in) (IS_TAGGED(in))
13180 +#ifdef CONFIG_TAG_NFSD
13181 +#define DX_TAG_NFSD 1
13183 +#define DX_TAG_NFSD 0
13187 +#ifdef CONFIG_TAGGING_NONE
13189 +#define MAX_UID 0xFFFFFFFF
13190 +#define MAX_GID 0xFFFFFFFF
13192 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13194 +#define TAGINO_UID(cond, uid, tag) (uid)
13195 +#define TAGINO_GID(cond, gid, tag) (gid)
13200 +#ifdef CONFIG_TAGGING_GID16
13202 +#define MAX_UID 0xFFFFFFFF
13203 +#define MAX_GID 0x0000FFFF
13205 +#define INOTAG_TAG(cond, uid, gid, tag) \
13206 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13208 +#define TAGINO_UID(cond, uid, tag) (uid)
13209 +#define TAGINO_GID(cond, gid, tag) \
13210 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13215 +#ifdef CONFIG_TAGGING_ID24
13217 +#define MAX_UID 0x00FFFFFF
13218 +#define MAX_GID 0x00FFFFFF
13220 +#define INOTAG_TAG(cond, uid, gid, tag) \
13221 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13223 +#define TAGINO_UID(cond, uid, tag) \
13224 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13225 +#define TAGINO_GID(cond, gid, tag) \
13226 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13231 +#ifdef CONFIG_TAGGING_UID16
13233 +#define MAX_UID 0x0000FFFF
13234 +#define MAX_GID 0xFFFFFFFF
13236 +#define INOTAG_TAG(cond, uid, gid, tag) \
13237 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13239 +#define TAGINO_UID(cond, uid, tag) \
13240 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13241 +#define TAGINO_GID(cond, gid, tag) (gid)
13246 +#ifdef CONFIG_TAGGING_INTERN
13248 +#define MAX_UID 0xFFFFFFFF
13249 +#define MAX_GID 0xFFFFFFFF
13251 +#define INOTAG_TAG(cond, uid, gid, tag) \
13252 + ((cond) ? (tag) : 0)
13254 +#define TAGINO_UID(cond, uid, tag) (uid)
13255 +#define TAGINO_GID(cond, gid, tag) (gid)
13260 +#ifndef CONFIG_TAGGING_NONE
13261 +#define dx_current_fstag(sb) \
13262 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13264 +#define dx_current_fstag(sb) (0)
13267 +#ifndef CONFIG_TAGGING_INTERN
13268 +#define TAGINO_TAG(cond, tag) (0)
13270 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13273 +#define INOTAG_UID(cond, uid, gid) \
13274 + ((cond) ? ((uid) & MAX_UID) : (uid))
13275 +#define INOTAG_GID(cond, uid, gid) \
13276 + ((cond) ? ((gid) & MAX_GID) : (gid))
13279 +static inline uid_t dx_map_uid(uid_t uid)
13281 + if ((uid > MAX_UID) && (uid != -1))
13283 + return (uid & MAX_UID);
13286 +static inline gid_t dx_map_gid(gid_t gid)
13288 + if ((gid > MAX_GID) && (gid != -1))
13290 + return (gid & MAX_GID);
13298 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13300 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13301 + unsigned long *flags);
13303 +#ifdef CONFIG_PROPAGATE
13305 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13307 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13310 +#define dx_propagate_tag(n, i) do { } while (0)
13313 +#endif /* _DX_TAG_H */
13314 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_inet6.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_inet6.h
13315 --- linux-2.6.35.7/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
13316 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_inet6.h 2010-08-02 17:05:06.000000000 +0200
13318 +#ifndef _VS_INET6_H
13319 +#define _VS_INET6_H
13321 +#include "vserver/base.h"
13322 +#include "vserver/network.h"
13323 +#include "vserver/debug.h"
13325 +#include <net/ipv6.h>
13327 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
13328 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
13331 +#ifdef CONFIG_IPV6
13334 +int v6_addr_match(struct nx_addr_v6 *nxa,
13335 + const struct in6_addr *addr, uint16_t mask)
13339 + switch (nxa->type & mask) {
13340 + case NXA_TYPE_MASK:
13341 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
13343 + case NXA_TYPE_ADDR:
13344 + ret = ipv6_addr_equal(&nxa->ip, addr);
13346 + case NXA_TYPE_ANY:
13350 + vxdprintk(VXD_CBIT(net, 0),
13351 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
13352 + nxa, NXAV6(nxa), addr, mask, ret);
13357 +int v6_addr_in_nx_info(struct nx_info *nxi,
13358 + const struct in6_addr *addr, uint16_t mask)
13360 + struct nx_addr_v6 *nxa;
13365 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
13366 + if (v6_addr_match(nxa, addr, mask))
13370 + vxdprintk(VXD_CBIT(net, 0),
13371 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
13372 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
13377 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
13379 + /* FIXME: needs full range checks */
13380 + return v6_addr_match(nxa, &addr->ip, mask);
13384 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
13386 + struct nx_addr_v6 *ptr;
13388 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
13389 + if (v6_nx_addr_match(ptr, nxa, mask))
13396 + * Check if a given address matches for a socket
13398 + * nxi: the socket's nx_info if any
13399 + * addr: to be verified address
13402 +int v6_sock_addr_match (
13403 + struct nx_info *nxi,
13404 + struct inet_sock *inet,
13405 + struct in6_addr *addr)
13407 + struct sock *sk = &inet->sk;
13408 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13410 + if (!ipv6_addr_any(addr) &&
13411 + ipv6_addr_equal(saddr, addr))
13413 + if (ipv6_addr_any(saddr))
13414 + return v6_addr_in_nx_info(nxi, addr, -1);
13419 + * check if address is covered by socket
13421 + * sk: the socket to check against
13422 + * addr: the address in question (must be != 0)
13426 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13428 + struct nx_info *nxi = sk->sk_nx_info;
13429 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13431 + vxdprintk(VXD_CBIT(net, 5),
13432 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
13433 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
13434 + (sk->sk_socket?sk->sk_socket->flags:0));
13436 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13437 + return v6_addr_match(nxa, saddr, -1);
13438 + } else if (nxi) { /* match against nx_info */
13439 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13440 + } else { /* unrestricted any socket */
13446 +/* inet related checks and helpers */
13450 +struct net_device;
13454 +#include <linux/netdevice.h>
13455 +#include <linux/inetdevice.h>
13456 +#include <net/inet_timewait_sock.h>
13459 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13460 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13461 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13466 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13472 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13476 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13478 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
13479 + nxi, nxi ? nxi->nx_id : 0, ifa,
13480 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
13482 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13484 + if (v6_ifa_in_nx_info(ifa, nxi))
13490 +struct nx_v6_sock_addr {
13491 + struct in6_addr saddr; /* Address used for validation */
13492 + struct in6_addr baddr; /* Address used for socket bind */
13496 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13497 + struct nx_v6_sock_addr *nsa)
13499 + // struct sock *sk = &inet->sk;
13500 + // struct nx_info *nxi = sk->sk_nx_info;
13501 + struct in6_addr saddr = addr->sin6_addr;
13502 + struct in6_addr baddr = saddr;
13504 + nsa->saddr = saddr;
13505 + nsa->baddr = baddr;
13510 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13512 + // struct sock *sk = &inet->sk;
13513 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13515 + // *saddr = nsa->baddr;
13516 + // inet->inet_saddr = nsa->baddr;
13520 +int nx_info_has_v6(struct nx_info *nxi)
13524 + if (NX_IPV6(nxi))
13529 +#else /* CONFIG_IPV6 */
13532 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13539 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13545 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13551 +int nx_info_has_v6(struct nx_info *nxi)
13556 +#endif /* CONFIG_IPV6 */
13558 +#define current_nx_info_has_v6() \
13559 + nx_info_has_v6(current_nx_info())
13562 +#warning duplicate inclusion
13564 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_inet.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_inet.h
13565 --- linux-2.6.35.7/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13566 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_inet.h 2010-08-02 17:05:06.000000000 +0200
13568 +#ifndef _VS_INET_H
13569 +#define _VS_INET_H
13571 +#include "vserver/base.h"
13572 +#include "vserver/network.h"
13573 +#include "vserver/debug.h"
13575 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13577 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13578 + NIPQUAD((a)->mask), (a)->type
13579 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13583 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13585 + __be32 ip = nxa->ip[0].s_addr;
13586 + __be32 mask = nxa->mask.s_addr;
13587 + __be32 bcast = ip | ~mask;
13590 + switch (nxa->type & tmask) {
13591 + case NXA_TYPE_MASK:
13592 + ret = (ip == (addr & mask));
13594 + case NXA_TYPE_ADDR:
13598 + /* fall through to broadcast */
13599 + case NXA_MOD_BCAST:
13600 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13602 + case NXA_TYPE_RANGE:
13603 + ret = ((nxa->ip[0].s_addr <= addr) &&
13604 + (nxa->ip[1].s_addr > addr));
13606 + case NXA_TYPE_ANY:
13611 + vxdprintk(VXD_CBIT(net, 0),
13612 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13613 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13618 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13620 + struct nx_addr_v4 *nxa;
13627 + /* allow 127.0.0.1 when remapping lback */
13628 + if ((tmask & NXA_LOOPBACK) &&
13629 + (addr == IPI_LOOPBACK) &&
13630 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13633 + /* check for lback address */
13634 + if ((tmask & NXA_MOD_LBACK) &&
13635 + (nxi->v4_lback.s_addr == addr))
13638 + /* check for broadcast address */
13639 + if ((tmask & NXA_MOD_BCAST) &&
13640 + (nxi->v4_bcast.s_addr == addr))
13643 + /* check for v4 addresses */
13644 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13645 + if (v4_addr_match(nxa, addr, tmask))
13649 + vxdprintk(VXD_CBIT(net, 0),
13650 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13651 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13656 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13658 + /* FIXME: needs full range checks */
13659 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13663 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13665 + struct nx_addr_v4 *ptr;
13667 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13668 + if (v4_nx_addr_match(ptr, nxa, mask))
13673 +#include <net/inet_sock.h>
13676 + * Check if a given address matches for a socket
13678 + * nxi: the socket's nx_info if any
13679 + * addr: to be verified address
13682 +int v4_sock_addr_match (
13683 + struct nx_info *nxi,
13684 + struct inet_sock *inet,
13687 + __be32 saddr = inet->inet_rcv_saddr;
13688 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13690 + if (addr && (saddr == addr || bcast == addr))
13693 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13698 +/* inet related checks and helpers */
13702 +struct net_device;
13705 +#ifdef CONFIG_INET
13707 +#include <linux/netdevice.h>
13708 +#include <linux/inetdevice.h>
13709 +#include <net/inet_sock.h>
13710 +#include <net/inet_timewait_sock.h>
13713 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13714 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
13715 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
13719 + * check if address is covered by socket
13721 + * sk: the socket to check against
13722 + * addr: the address in question (must be != 0)
13726 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
13728 + struct nx_info *nxi = sk->sk_nx_info;
13729 + __be32 saddr = inet_rcv_saddr(sk);
13731 + vxdprintk(VXD_CBIT(net, 5),
13732 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
13733 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
13734 + (sk->sk_socket?sk->sk_socket->flags:0));
13736 + if (saddr) { /* direct address match */
13737 + return v4_addr_match(nxa, saddr, -1);
13738 + } else if (nxi) { /* match against nx_info */
13739 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
13740 + } else { /* unrestricted any socket */
13748 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
13750 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
13751 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
13752 + nxi ? dev_in_nx_info(dev, nxi) : 0);
13754 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13756 + if (dev_in_nx_info(dev, nxi))
13763 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13769 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
13773 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
13775 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
13776 + nxi, nxi ? nxi->nx_id : 0, ifa,
13777 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
13779 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13781 + if (v4_ifa_in_nx_info(ifa, nxi))
13787 +struct nx_v4_sock_addr {
13788 + __be32 saddr; /* Address used for validation */
13789 + __be32 baddr; /* Address used for socket bind */
13793 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
13794 + struct nx_v4_sock_addr *nsa)
13796 + struct sock *sk = &inet->sk;
13797 + struct nx_info *nxi = sk->sk_nx_info;
13798 + __be32 saddr = addr->sin_addr.s_addr;
13799 + __be32 baddr = saddr;
13801 + vxdprintk(VXD_CBIT(net, 3),
13802 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
13803 + sk, sk->sk_nx_info, sk->sk_socket,
13804 + (sk->sk_socket ? sk->sk_socket->flags : 0),
13808 + if (saddr == INADDR_ANY) {
13809 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
13810 + baddr = nxi->v4.ip[0].s_addr;
13811 + } else if (saddr == IPI_LOOPBACK) {
13812 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13813 + baddr = nxi->v4_lback.s_addr;
13814 + } else { /* normal address bind */
13815 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
13816 + return -EADDRNOTAVAIL;
13820 + vxdprintk(VXD_CBIT(net, 3),
13821 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
13822 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
13824 + nsa->saddr = saddr;
13825 + nsa->baddr = baddr;
13830 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
13832 + inet->inet_saddr = nsa->baddr;
13833 + inet->inet_rcv_saddr = nsa->baddr;
13838 + * helper to simplify inet_lookup_listener
13840 + * nxi: the socket's nx_info if any
13841 + * addr: to be verified address
13842 + * saddr: socket address
13844 +static inline int v4_inet_addr_match (
13845 + struct nx_info *nxi,
13849 + if (addr && (saddr == addr))
13852 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
13856 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
13858 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
13859 + (addr == nxi->v4_lback.s_addr))
13860 + return IPI_LOOPBACK;
13865 +int nx_info_has_v4(struct nx_info *nxi)
13869 + if (NX_IPV4(nxi))
13871 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13876 +#else /* CONFIG_INET */
13879 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
13885 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13891 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13897 +int nx_info_has_v4(struct nx_info *nxi)
13902 +#endif /* CONFIG_INET */
13904 +#define current_nx_info_has_v4() \
13905 + nx_info_has_v4(current_nx_info())
13908 +// #warning duplicate inclusion
13910 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_limit.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_limit.h
13911 --- linux-2.6.35.7/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
13912 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_limit.h 2010-08-02 17:05:06.000000000 +0200
13914 +#ifndef _VS_LIMIT_H
13915 +#define _VS_LIMIT_H
13917 +#include "vserver/limit.h"
13918 +#include "vserver/base.h"
13919 +#include "vserver/context.h"
13920 +#include "vserver/debug.h"
13921 +#include "vserver/context.h"
13922 +#include "vserver/limit_int.h"
13925 +#define vx_acc_cres(v, d, p, r) \
13926 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
13928 +#define vx_acc_cres_cond(x, d, p, r) \
13929 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
13930 + r, d, p, __FILE__, __LINE__)
13933 +#define vx_add_cres(v, a, p, r) \
13934 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
13935 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
13937 +#define vx_add_cres_cond(x, a, p, r) \
13938 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
13939 + r, a, p, __FILE__, __LINE__)
13940 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
13943 +/* process and file limits */
13945 +#define vx_nproc_inc(p) \
13946 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
13948 +#define vx_nproc_dec(p) \
13949 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
13951 +#define vx_files_inc(f) \
13952 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
13954 +#define vx_files_dec(f) \
13955 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
13957 +#define vx_locks_inc(l) \
13958 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
13960 +#define vx_locks_dec(l) \
13961 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
13963 +#define vx_openfd_inc(f) \
13964 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
13966 +#define vx_openfd_dec(f) \
13967 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
13970 +#define vx_cres_avail(v, n, r) \
13971 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
13974 +#define vx_nproc_avail(n) \
13975 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
13977 +#define vx_files_avail(n) \
13978 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
13980 +#define vx_locks_avail(n) \
13981 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
13983 +#define vx_openfd_avail(n) \
13984 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
13987 +/* dentry limits */
13989 +#define vx_dentry_inc(d) do { \
13990 + if (atomic_read(&d->d_count) == 1) \
13991 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
13994 +#define vx_dentry_dec(d) do { \
13995 + if (atomic_read(&d->d_count) == 0) \
13996 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
13999 +#define vx_dentry_avail(n) \
14000 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
14003 +/* socket limits */
14005 +#define vx_sock_inc(s) \
14006 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
14008 +#define vx_sock_dec(s) \
14009 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
14011 +#define vx_sock_avail(n) \
14012 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
14015 +/* ipc resource limits */
14017 +#define vx_ipcmsg_add(v, u, a) \
14018 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
14020 +#define vx_ipcmsg_sub(v, u, a) \
14021 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
14023 +#define vx_ipcmsg_avail(v, a) \
14024 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
14027 +#define vx_ipcshm_add(v, k, a) \
14028 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14030 +#define vx_ipcshm_sub(v, k, a) \
14031 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14033 +#define vx_ipcshm_avail(v, a) \
14034 + vx_cres_avail(v, a, VLIMIT_SHMEM)
14037 +#define vx_semary_inc(a) \
14038 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
14040 +#define vx_semary_dec(a) \
14041 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
14044 +#define vx_nsems_add(a,n) \
14045 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
14047 +#define vx_nsems_sub(a,n) \
14048 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
14052 +#warning duplicate inclusion
14054 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_memory.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_memory.h
14055 --- linux-2.6.35.7/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
14056 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_memory.h 2010-08-02 17:05:06.000000000 +0200
14058 +#ifndef _VS_MEMORY_H
14059 +#define _VS_MEMORY_H
14061 +#include "vserver/limit.h"
14062 +#include "vserver/base.h"
14063 +#include "vserver/context.h"
14064 +#include "vserver/debug.h"
14065 +#include "vserver/context.h"
14066 +#include "vserver/limit_int.h"
14069 + VXPT_UNKNOWN = 0,
14078 +#define vx_page_fault(mm, vma, type, ret)
14082 +void __vx_page_fault(struct mm_struct *mm,
14083 + struct vm_area_struct *vma, int type, int ret)
14085 + struct vx_info *vxi = mm->mm_vx_info;
14088 + static char *page_type[6] =
14089 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
14090 + static char *page_what[4] =
14091 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
14097 + what = (ret & 0x3);
14099 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
14100 + type, what, ret, page_type[type], page_what[what]);
14102 + if (ret & VM_FAULT_WRITE)
14104 + atomic_inc(&vxi->cacct.page[type][what]);
14107 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
14111 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
14114 +#warning duplicate inclusion
14116 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_network.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_network.h
14117 --- linux-2.6.35.7/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
14118 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_network.h 2010-08-02 17:05:06.000000000 +0200
14120 +#ifndef _NX_VS_NETWORK_H
14121 +#define _NX_VS_NETWORK_H
14123 +#include "vserver/context.h"
14124 +#include "vserver/network.h"
14125 +#include "vserver/base.h"
14126 +#include "vserver/check.h"
14127 +#include "vserver/debug.h"
14129 +#include <linux/sched.h>
14132 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
14134 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
14135 + const char *_file, int _line)
14140 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
14141 + nxi, nxi ? nxi->nx_id : 0,
14142 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14145 + atomic_inc(&nxi->nx_usecnt);
14150 +extern void free_nx_info(struct nx_info *);
14152 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
14154 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
14159 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
14160 + nxi, nxi ? nxi->nx_id : 0,
14161 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14164 + if (atomic_dec_and_test(&nxi->nx_usecnt))
14165 + free_nx_info(nxi);
14169 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
14171 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14172 + const char *_file, int _line)
14175 + vxlprintk(VXD_CBIT(nid, 3),
14176 + "init_nx_info(%p[#%d.%d])",
14177 + nxi, nxi ? nxi->nx_id : 0,
14178 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14181 + atomic_inc(&nxi->nx_usecnt);
14187 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
14189 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14190 + const char *_file, int _line)
14192 + struct nx_info *nxo;
14197 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
14198 + nxi, nxi ? nxi->nx_id : 0,
14199 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14202 + atomic_inc(&nxi->nx_usecnt);
14203 + nxo = xchg(nxp, nxi);
14207 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
14209 +static inline void __clr_nx_info(struct nx_info **nxp,
14210 + const char *_file, int _line)
14212 + struct nx_info *nxo;
14214 + nxo = xchg(nxp, NULL);
14218 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
14219 + nxo, nxo ? nxo->nx_id : 0,
14220 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
14223 + if (atomic_dec_and_test(&nxo->nx_usecnt))
14224 + free_nx_info(nxo);
14228 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
14230 +static inline void __claim_nx_info(struct nx_info *nxi,
14231 + struct task_struct *task, const char *_file, int _line)
14233 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
14234 + nxi, nxi ? nxi->nx_id : 0,
14235 + nxi?atomic_read(&nxi->nx_usecnt):0,
14236 + nxi?atomic_read(&nxi->nx_tasks):0,
14237 + task, _file, _line);
14239 + atomic_inc(&nxi->nx_tasks);
14243 +extern void unhash_nx_info(struct nx_info *);
14245 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
14247 +static inline void __release_nx_info(struct nx_info *nxi,
14248 + struct task_struct *task, const char *_file, int _line)
14250 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
14251 + nxi, nxi ? nxi->nx_id : 0,
14252 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14253 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
14254 + task, _file, _line);
14258 + if (atomic_dec_and_test(&nxi->nx_tasks))
14259 + unhash_nx_info(nxi);
14263 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
14265 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
14266 + const char *_file, int _line)
14268 + struct nx_info *nxi;
14271 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
14272 + p, _file, _line);
14273 + nxi = __get_nx_info(p->nx_info, _file, _line);
14279 +static inline void exit_nx_info(struct task_struct *p)
14282 + release_nx_info(p->nx_info, p);
14287 +#warning duplicate inclusion
14289 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_pid.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_pid.h
14290 --- linux-2.6.35.7/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
14291 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_pid.h 2010-08-02 17:05:06.000000000 +0200
14296 +#include "vserver/base.h"
14297 +#include "vserver/check.h"
14298 +#include "vserver/context.h"
14299 +#include "vserver/debug.h"
14300 +#include "vserver/pid.h"
14301 +#include <linux/pid_namespace.h>
14304 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
14307 +int vx_proc_task_visible(struct task_struct *task)
14309 + if ((task->pid == 1) &&
14310 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
14311 + /* show a blend through init */
14313 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
14320 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
14325 +struct task_struct *vx_find_proc_task_by_pid(int pid)
14327 + struct task_struct *task = find_task_by_real_pid(pid);
14329 + if (task && !vx_proc_task_visible(task)) {
14330 + vxdprintk(VXD_CBIT(misc, 6),
14331 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
14332 + task, task->xid, task->pid,
14333 + current, current->xid, current->pid);
14342 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
14344 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
14346 + if (task && !vx_proc_task_visible(task)) {
14347 + vxdprintk(VXD_CBIT(misc, 6),
14348 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
14349 + task, task->xid, task->pid,
14350 + current, current->xid, current->pid);
14351 + put_task_struct(task);
14360 +struct task_struct *vx_child_reaper(struct task_struct *p)
14362 + struct vx_info *vxi = p->vx_info;
14363 + struct task_struct *reaper = child_reaper(p);
14368 + BUG_ON(!p->vx_info->vx_reaper);
14370 + /* child reaper for the guest reaper */
14371 + if (vxi->vx_reaper == p)
14374 + reaper = vxi->vx_reaper;
14376 + vxdprintk(VXD_CBIT(xid, 7),
14377 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
14378 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
14386 +#warning duplicate inclusion
14388 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_sched.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_sched.h
14389 --- linux-2.6.35.7/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
14390 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_sched.h 2010-08-02 17:05:06.000000000 +0200
14392 +#ifndef _VS_SCHED_H
14393 +#define _VS_SCHED_H
14395 +#include "vserver/base.h"
14396 +#include "vserver/context.h"
14397 +#include "vserver/sched.h"
14400 +#define VAVAVOOM_RATIO 50
14402 +#define MAX_PRIO_BIAS 20
14403 +#define MIN_PRIO_BIAS -20
14406 +#ifdef CONFIG_VSERVER_HARDCPU
14409 + * effective_prio - return the priority that is based on the static
14410 + * priority but is modified by bonuses/penalties.
14412 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
14413 + * into a -4 ... 0 ... +4 bonus/penalty range.
14415 + * Additionally, we scale another amount based on the number of
14416 + * CPU tokens currently held by the context, if the process is
14417 + * part of a context (and the appropriate SCHED flag is set).
14418 + * This ranges from -5 ... 0 ... +15, quadratically.
14420 + * So, the total bonus is -9 .. 0 .. +19
14421 + * We use ~50% of the full 0...39 priority range so that:
14423 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
14424 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
14425 + * unless that context is far exceeding its CPU allocation.
14427 + * Both properties are important to certain workloads.
14430 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
14432 + int vavavoom, max;
14434 + /* lots of tokens = lots of vavavoom
14435 + * no tokens = no vavavoom */
14436 + if ((vavavoom = sched_pc->tokens) >= 0) {
14437 + max = sched_pc->tokens_max;
14438 + vavavoom = max - vavavoom;
14440 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
14441 + * (vavavoom*vavavoom - (max >> 2)) / max;
14449 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14451 + struct vx_info *vxi = p->vx_info;
14452 + struct _vx_sched_pc *sched_pc;
14457 + sched_pc = &vx_cpu(vxi, sched_pc);
14458 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
14459 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
14461 + sched_pc->vavavoom = vavavoom;
14462 + prio += vavavoom;
14464 + prio += sched_pc->prio_bias;
14468 +#else /* !CONFIG_VSERVER_HARDCPU */
14471 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14473 + struct vx_info *vxi = p->vx_info;
14476 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14480 +#endif /* CONFIG_VSERVER_HARDCPU */
14483 +static inline void vx_account_user(struct vx_info *vxi,
14484 + cputime_t cputime, int nice)
14488 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14491 +static inline void vx_account_system(struct vx_info *vxi,
14492 + cputime_t cputime, int idle)
14496 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14500 +#warning duplicate inclusion
14502 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_socket.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_socket.h
14503 --- linux-2.6.35.7/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14504 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_socket.h 2010-08-02 17:05:06.000000000 +0200
14506 +#ifndef _VS_SOCKET_H
14507 +#define _VS_SOCKET_H
14509 +#include "vserver/debug.h"
14510 +#include "vserver/base.h"
14511 +#include "vserver/cacct.h"
14512 +#include "vserver/context.h"
14513 +#include "vserver/tag.h"
14516 +/* socket accounting */
14518 +#include <linux/socket.h>
14520 +static inline int vx_sock_type(int family)
14522 + switch (family) {
14524 + return VXA_SOCK_UNSPEC;
14526 + return VXA_SOCK_UNIX;
14528 + return VXA_SOCK_INET;
14530 + return VXA_SOCK_INET6;
14532 + return VXA_SOCK_PACKET;
14534 + return VXA_SOCK_OTHER;
14538 +#define vx_acc_sock(v, f, p, s) \
14539 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14541 +static inline void __vx_acc_sock(struct vx_info *vxi,
14542 + int family, int pos, int size, char *file, int line)
14545 + int type = vx_sock_type(family);
14547 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14548 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14552 +#define vx_sock_recv(sk, s) \
14553 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14554 +#define vx_sock_send(sk, s) \
14555 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14556 +#define vx_sock_fail(sk, s) \
14557 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14560 +#define sock_vx_init(s) do { \
14561 + (s)->sk_xid = 0; \
14562 + (s)->sk_vx_info = NULL; \
14565 +#define sock_nx_init(s) do { \
14566 + (s)->sk_nid = 0; \
14567 + (s)->sk_nx_info = NULL; \
14571 +#warning duplicate inclusion
14573 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_tag.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_tag.h
14574 --- linux-2.6.35.7/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14575 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_tag.h 2010-08-02 17:05:06.000000000 +0200
14580 +#include <linux/vserver/tag.h>
14582 +/* check conditions */
14584 +#define DX_ADMIN 0x0001
14585 +#define DX_WATCH 0x0002
14586 +#define DX_HOSTID 0x0008
14588 +#define DX_IDENT 0x0010
14590 +#define DX_ARG_MASK 0x0010
14593 +#define dx_task_tag(t) ((t)->tag)
14595 +#define dx_current_tag() dx_task_tag(current)
14597 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14599 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14603 + * check current context for ADMIN/WATCH and
14604 + * optionally against supplied argument
14606 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14608 + if (mode & DX_ARG_MASK) {
14609 + if ((mode & DX_IDENT) && (id == cid))
14612 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14613 + ((mode & DX_WATCH) && (cid == 1)) ||
14614 + ((mode & DX_HOSTID) && (id == 0)));
14618 +int dx_permission(const struct inode *inode, int mask);
14622 +#warning duplicate inclusion
14624 diff -NurpP --minimal linux-2.6.35.7/include/linux/vs_time.h linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_time.h
14625 --- linux-2.6.35.7/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
14626 +++ linux-2.6.35.7-vs2.3.0.36.33/include/linux/vs_time.h 2010-08-02 17:05:06.000000000 +0200
14628 +#ifndef _VS_TIME_H
14629 +#define _VS_TIME_H
14632 +/* time faking stuff */
14634 +#ifdef CONFIG_VSERVER_VTIME
14636 +extern void vx_gettimeofday(struct timeval *tv);
14637 +extern int vx_settimeofday(struct timespec *ts);
14640 +#define vx_gettimeofday(t) do_gettimeofday(t)
14641 +#define vx_settimeofday(t) do_settimeofday(t)
14645 +#warning duplicate inclusion
14647 diff -NurpP --minimal linux-2.6.35.7/include/net/addrconf.h linux-2.6.35.7-vs2.3.0.36.33/include/net/addrconf.h
14648 --- linux-2.6.35.7/include/net/addrconf.h 2010-07-07 18:31:56.000000000 +0200
14649 +++ linux-2.6.35.7-vs2.3.0.36.33/include/net/addrconf.h 2010-08-02 17:05:06.000000000 +0200
14650 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14651 struct net_device *dev,
14652 const struct in6_addr *daddr,
14653 unsigned int srcprefs,
14654 - struct in6_addr *saddr);
14655 + struct in6_addr *saddr,
14656 + struct nx_info *nxi);
14657 extern int ipv6_get_lladdr(struct net_device *dev,
14658 struct in6_addr *addr,
14659 unsigned char banned_flags);
14660 diff -NurpP --minimal linux-2.6.35.7/include/net/af_unix.h linux-2.6.35.7-vs2.3.0.36.33/include/net/af_unix.h
14661 --- linux-2.6.35.7/include/net/af_unix.h 2010-08-02 16:52:56.000000000 +0200
14662 +++ linux-2.6.35.7-vs2.3.0.36.33/include/net/af_unix.h 2010-08-02 17:05:06.000000000 +0200
14664 #include <linux/socket.h>
14665 #include <linux/un.h>
14666 #include <linux/mutex.h>
14667 +#include <linux/vs_base.h>
14668 #include <net/sock.h>
14670 extern void unix_inflight(struct file *fp);
14671 diff -NurpP --minimal linux-2.6.35.7/include/net/inet_timewait_sock.h linux-2.6.35.7-vs2.3.0.36.33/include/net/inet_timewait_sock.h
14672 --- linux-2.6.35.7/include/net/inet_timewait_sock.h 2010-08-02 16:52:56.000000000 +0200
14673 +++ linux-2.6.35.7-vs2.3.0.36.33/include/net/inet_timewait_sock.h 2010-08-02 17:05:06.000000000 +0200
14674 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
14675 #define tw_hash __tw_common.skc_hash
14676 #define tw_prot __tw_common.skc_prot
14677 #define tw_net __tw_common.skc_net
14678 +#define tw_xid __tw_common.skc_xid
14679 +#define tw_vx_info __tw_common.skc_vx_info
14680 +#define tw_nid __tw_common.skc_nid
14681 +#define tw_nx_info __tw_common.skc_nx_info
14683 volatile unsigned char tw_substate;
14684 /* 3 bits hole, try to pack */
14685 diff -NurpP --minimal linux-2.6.35.7/include/net/route.h linux-2.6.35.7-vs2.3.0.36.33/include/net/route.h
14686 --- linux-2.6.35.7/include/net/route.h 2010-08-02 16:52:57.000000000 +0200
14687 +++ linux-2.6.35.7-vs2.3.0.36.33/include/net/route.h 2010-08-02 17:05:06.000000000 +0200
14688 @@ -147,6 +147,9 @@ static inline void ip_rt_put(struct rtab
14689 dst_release(&rt->u.dst);
14692 +#include <linux/vs_base.h>
14693 +#include <linux/vs_inet.h>
14695 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14697 extern const __u8 ip_tos2prio[16];
14698 @@ -156,6 +159,9 @@ static inline char rt_tos2priority(u8 to
14699 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14702 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14703 + struct rtable **, struct flowi *);
14705 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14706 __be32 src, u32 tos, int oif, u8 protocol,
14707 __be16 sport, __be16 dport, struct sock *sk,
14708 @@ -173,11 +179,24 @@ static inline int ip_route_connect(struc
14711 struct net *net = sock_net(sk);
14712 + struct nx_info *nx_info = current_nx_info();
14714 if (inet_sk(sk)->transparent)
14715 fl.flags |= FLOWI_FLAG_ANYSRC;
14717 - if (!dst || !src) {
14719 + nx_info = sk->sk_nx_info;
14721 + vxdprintk(VXD_CBIT(net, 4),
14722 + "ip_route_connect(%p) %p,%p;%lx",
14723 + sk, nx_info, sk->sk_socket,
14724 + (sk->sk_socket?sk->sk_socket->flags:0));
14726 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14730 + if (!fl.fl4_dst || !fl.fl4_src) {
14731 err = __ip_route_output_key(net, rp, &fl);
14734 diff -NurpP --minimal linux-2.6.35.7/include/net/sock.h linux-2.6.35.7-vs2.3.0.36.33/include/net/sock.h
14735 --- linux-2.6.35.7/include/net/sock.h 2010-10-04 08:57:40.000000000 +0200
14736 +++ linux-2.6.35.7-vs2.3.0.36.33/include/net/sock.h 2010-10-05 19:23:43.000000000 +0200
14737 @@ -150,6 +150,10 @@ struct sock_common {
14738 #ifdef CONFIG_NET_NS
14739 struct net *skc_net;
14742 + struct vx_info *skc_vx_info;
14744 + struct nx_info *skc_nx_info;
14748 @@ -239,6 +243,10 @@ struct sock {
14749 #define sk_bind_node __sk_common.skc_bind_node
14750 #define sk_prot __sk_common.skc_prot
14751 #define sk_net __sk_common.skc_net
14752 +#define sk_xid __sk_common.skc_xid
14753 +#define sk_vx_info __sk_common.skc_vx_info
14754 +#define sk_nid __sk_common.skc_nid
14755 +#define sk_nx_info __sk_common.skc_nx_info
14756 kmemcheck_bitfield_begin(flags);
14757 unsigned int sk_shutdown : 2,
14759 diff -NurpP --minimal linux-2.6.35.7/init/Kconfig linux-2.6.35.7-vs2.3.0.36.33/init/Kconfig
14760 --- linux-2.6.35.7/init/Kconfig 2010-08-02 16:52:57.000000000 +0200
14761 +++ linux-2.6.35.7-vs2.3.0.36.33/init/Kconfig 2010-08-02 17:05:06.000000000 +0200
14762 @@ -472,6 +472,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
14764 boolean "Control Group support"
14768 This option adds support for grouping sets of processes together, for
14769 use with process control subsystems such as Cpusets, CFS, memory
14770 @@ -499,6 +500,7 @@ config CGROUP_DEBUG
14772 bool "Namespace cgroup subsystem"
14776 Provides a simple namespace cgroup subsystem to
14777 provide hierarchical naming of sets of namespaces,
14778 diff -NurpP --minimal linux-2.6.35.7/init/main.c linux-2.6.35.7-vs2.3.0.36.33/init/main.c
14779 --- linux-2.6.35.7/init/main.c 2010-08-02 16:52:57.000000000 +0200
14780 +++ linux-2.6.35.7-vs2.3.0.36.33/init/main.c 2010-08-02 17:05:06.000000000 +0200
14782 #include <linux/shmem_fs.h>
14783 #include <linux/slab.h>
14784 #include <trace/boot.h>
14785 +#include <linux/vserver/percpu.h>
14787 #include <asm/io.h>
14788 #include <asm/bugs.h>
14789 diff -NurpP --minimal linux-2.6.35.7/ipc/mqueue.c linux-2.6.35.7-vs2.3.0.36.33/ipc/mqueue.c
14790 --- linux-2.6.35.7/ipc/mqueue.c 2010-08-02 16:52:57.000000000 +0200
14791 +++ linux-2.6.35.7-vs2.3.0.36.33/ipc/mqueue.c 2010-08-02 17:05:06.000000000 +0200
14793 #include <linux/pid.h>
14794 #include <linux/ipc_namespace.h>
14795 #include <linux/slab.h>
14796 +#include <linux/vs_context.h>
14797 +#include <linux/vs_limit.h>
14799 #include <net/sock.h>
14801 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14802 struct sigevent notify;
14803 struct pid* notify_owner;
14804 struct user_struct *user; /* user who created, for accounting */
14805 + struct vx_info *vxi;
14806 struct sock *notify_sock;
14807 struct sk_buff *notify_cookie;
14809 @@ -125,6 +128,7 @@ static struct inode *mqueue_get_inode(st
14810 if (S_ISREG(mode)) {
14811 struct mqueue_inode_info *info;
14812 struct task_struct *p = current;
14813 + struct vx_info *vxi = p->vx_info;
14814 unsigned long mq_bytes, mq_msg_tblsz;
14816 inode->i_fop = &mqueue_file_operations;
14817 @@ -138,6 +142,7 @@ static struct inode *mqueue_get_inode(st
14818 info->notify_owner = NULL;
14820 info->user = NULL; /* set when all is ok */
14821 + info->vxi = NULL;
14822 memset(&info->attr, 0, sizeof(info->attr));
14823 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14824 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14825 @@ -156,16 +161,19 @@ static struct inode *mqueue_get_inode(st
14826 spin_lock(&mq_lock);
14827 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14828 u->mq_bytes + mq_bytes >
14829 - task_rlimit(p, RLIMIT_MSGQUEUE)) {
14830 + task_rlimit(p, RLIMIT_MSGQUEUE) ||
14831 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14832 spin_unlock(&mq_lock);
14833 /* mqueue_delete_inode() releases info->messages */
14836 u->mq_bytes += mq_bytes;
14837 + vx_ipcmsg_add(vxi, u, mq_bytes);
14838 spin_unlock(&mq_lock);
14841 info->user = get_uid(u);
14842 + info->vxi = get_vx_info(vxi);
14843 } else if (S_ISDIR(mode)) {
14845 /* Some things misbehave if size == 0 on a directory */
14846 @@ -268,8 +276,11 @@ static void mqueue_delete_inode(struct i
14847 + info->attr.mq_msgsize);
14850 + struct vx_info *vxi = info->vxi;
14852 spin_lock(&mq_lock);
14853 user->mq_bytes -= mq_bytes;
14854 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14856 * get_ns_from_inode() ensures that the
14857 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14858 @@ -279,6 +290,7 @@ static void mqueue_delete_inode(struct i
14860 ipc_ns->mq_queues_count--;
14861 spin_unlock(&mq_lock);
14862 + put_vx_info(vxi);
14866 diff -NurpP --minimal linux-2.6.35.7/ipc/msg.c linux-2.6.35.7-vs2.3.0.36.33/ipc/msg.c
14867 --- linux-2.6.35.7/ipc/msg.c 2010-08-02 16:52:57.000000000 +0200
14868 +++ linux-2.6.35.7-vs2.3.0.36.33/ipc/msg.c 2010-08-02 17:05:06.000000000 +0200
14870 #include <linux/rwsem.h>
14871 #include <linux/nsproxy.h>
14872 #include <linux/ipc_namespace.h>
14873 +#include <linux/vs_base.h>
14875 #include <asm/current.h>
14876 #include <asm/uaccess.h>
14877 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14879 msq->q_perm.mode = msgflg & S_IRWXUGO;
14880 msq->q_perm.key = key;
14881 + msq->q_perm.xid = vx_current_xid();
14883 msq->q_perm.security = NULL;
14884 retval = security_msg_queue_alloc(msq);
14885 diff -NurpP --minimal linux-2.6.35.7/ipc/namespace.c linux-2.6.35.7-vs2.3.0.36.33/ipc/namespace.c
14886 --- linux-2.6.35.7/ipc/namespace.c 2009-09-10 15:26:27.000000000 +0200
14887 +++ linux-2.6.35.7-vs2.3.0.36.33/ipc/namespace.c 2010-08-02 17:05:06.000000000 +0200
14889 #include <linux/slab.h>
14890 #include <linux/fs.h>
14891 #include <linux/mount.h>
14892 +#include <linux/vs_base.h>
14893 +#include <linux/vserver/global.h>
14897 diff -NurpP --minimal linux-2.6.35.7/ipc/sem.c linux-2.6.35.7-vs2.3.0.36.33/ipc/sem.c
14898 --- linux-2.6.35.7/ipc/sem.c 2010-08-02 16:52:57.000000000 +0200
14899 +++ linux-2.6.35.7-vs2.3.0.36.33/ipc/sem.c 2010-08-02 17:05:06.000000000 +0200
14901 #include <linux/rwsem.h>
14902 #include <linux/nsproxy.h>
14903 #include <linux/ipc_namespace.h>
14904 +#include <linux/vs_base.h>
14905 +#include <linux/vs_limit.h>
14907 #include <asm/uaccess.h>
14909 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
14911 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14912 sma->sem_perm.key = key;
14913 + sma->sem_perm.xid = vx_current_xid();
14915 sma->sem_perm.security = NULL;
14916 retval = security_sem_alloc(sma);
14917 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
14920 ns->used_sems += nsems;
14921 + /* FIXME: obsoleted? */
14922 + vx_semary_inc(sma);
14923 + vx_nsems_add(sma, nsems);
14925 sma->sem_base = (struct sem *) &sma[1];
14927 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
14929 wake_up_sem_queue_do(&tasks);
14930 ns->used_sems -= sma->sem_nsems;
14931 + /* FIXME: obsoleted? */
14932 + vx_nsems_sub(sma, sma->sem_nsems);
14933 + vx_semary_dec(sma);
14934 security_sem_free(sma);
14935 ipc_rcu_putref(sma);
14937 diff -NurpP --minimal linux-2.6.35.7/ipc/shm.c linux-2.6.35.7-vs2.3.0.36.33/ipc/shm.c
14938 --- linux-2.6.35.7/ipc/shm.c 2010-08-02 16:52:57.000000000 +0200
14939 +++ linux-2.6.35.7-vs2.3.0.36.33/ipc/shm.c 2010-08-02 17:05:06.000000000 +0200
14941 #include <linux/nsproxy.h>
14942 #include <linux/mount.h>
14943 #include <linux/ipc_namespace.h>
14944 +#include <linux/vs_context.h>
14945 +#include <linux/vs_limit.h>
14947 #include <asm/uaccess.h>
14949 @@ -169,7 +171,12 @@ static void shm_open(struct vm_area_stru
14951 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14953 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14954 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14955 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14957 + vx_ipcshm_sub(vxi, shp, numpages);
14958 + ns->shm_tot -= numpages;
14962 if (!is_file_hugepages(shp->shm_file))
14963 @@ -179,6 +186,7 @@ static void shm_destroy(struct ipc_names
14965 fput (shp->shm_file);
14966 security_shm_free(shp);
14967 + put_vx_info(vxi);
14968 ipc_rcu_putref(shp);
14971 @@ -349,11 +357,15 @@ static int newseg(struct ipc_namespace *
14972 if (ns->shm_tot + numpages > ns->shm_ctlall)
14975 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14978 shp = ipc_rcu_alloc(sizeof(*shp));
14982 shp->shm_perm.key = key;
14983 + shp->shm_perm.xid = vx_current_xid();
14984 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14985 shp->mlock_user = NULL;
14987 @@ -407,6 +419,7 @@ static int newseg(struct ipc_namespace *
14988 ns->shm_tot += numpages;
14989 error = shp->shm_perm.id;
14991 + vx_ipcshm_add(current_vx_info(), key, numpages);
14995 diff -NurpP --minimal linux-2.6.35.7/kernel/capability.c linux-2.6.35.7-vs2.3.0.36.33/kernel/capability.c
14996 --- linux-2.6.35.7/kernel/capability.c 2010-08-02 16:52:57.000000000 +0200
14997 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/capability.c 2010-08-02 17:05:06.000000000 +0200
14999 #include <linux/security.h>
15000 #include <linux/syscalls.h>
15001 #include <linux/pid_namespace.h>
15002 +#include <linux/vs_context.h>
15003 #include <asm/uaccess.h>
15006 @@ -119,6 +120,7 @@ static int cap_validate_magic(cap_user_h
15012 * The only thing that can change the capabilities of the current
15013 * process is the current process. As such, we can't be in this code
15014 @@ -289,6 +291,8 @@ error:
15018 +#include <linux/vserver/base.h>
15021 * capable - Determine if the current task has a superior capability in effect
15022 * @cap: The capability to be tested for
15023 @@ -301,6 +305,9 @@ error:
15025 int capable(int cap)
15027 + /* here for now so we don't require task locking */
15028 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15030 if (unlikely(!cap_valid(cap))) {
15031 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
15033 diff -NurpP --minimal linux-2.6.35.7/kernel/compat.c linux-2.6.35.7-vs2.3.0.36.33/kernel/compat.c
15034 --- linux-2.6.35.7/kernel/compat.c 2010-10-04 08:57:40.000000000 +0200
15035 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/compat.c 2010-09-22 02:52:29.000000000 +0200
15036 @@ -900,7 +900,7 @@ asmlinkage long compat_sys_time(compat_t
15040 - do_gettimeofday(&tv);
15041 + vx_gettimeofday(&tv);
15045 @@ -925,7 +925,7 @@ asmlinkage long compat_sys_stime(compat_
15049 - do_settimeofday(&tv);
15050 + vx_settimeofday(&tv);
15054 diff -NurpP --minimal linux-2.6.35.7/kernel/exit.c linux-2.6.35.7-vs2.3.0.36.33/kernel/exit.c
15055 --- linux-2.6.35.7/kernel/exit.c 2010-10-04 08:57:40.000000000 +0200
15056 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/exit.c 2010-10-05 19:23:43.000000000 +0200
15058 #include <linux/fs_struct.h>
15059 #include <linux/init_task.h>
15060 #include <linux/perf_event.h>
15061 +#include <linux/vs_limit.h>
15062 +#include <linux/vs_context.h>
15063 +#include <linux/vs_network.h>
15064 +#include <linux/vs_pid.h>
15065 #include <trace/events/sched.h>
15066 #include <linux/hw_breakpoint.h>
15068 @@ -487,9 +491,11 @@ static void close_files(struct files_str
15069 filp_close(file, files);
15072 + vx_openfd_dec(i);
15080 @@ -1020,11 +1026,16 @@ NORET_TYPE void do_exit(long code)
15082 validate_creds_for_do_exit(tsk);
15084 + /* needs to stay after exit_notify() */
15085 + exit_vx_info(tsk, code);
15086 + exit_nx_info(tsk);
15090 /* causes final put_task_struct in finish_task_switch(). */
15091 tsk->state = TASK_DEAD;
15093 + printk("bad task: %p [%lx]\n", current, current->state);
15095 /* Avoid "noreturn function does return". */
15097 diff -NurpP --minimal linux-2.6.35.7/kernel/fork.c linux-2.6.35.7-vs2.3.0.36.33/kernel/fork.c
15098 --- linux-2.6.35.7/kernel/fork.c 2010-10-04 08:57:40.000000000 +0200
15099 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/fork.c 2010-09-06 02:59:52.000000000 +0200
15101 #include <linux/perf_event.h>
15102 #include <linux/posix-timers.h>
15103 #include <linux/user-return-notifier.h>
15104 +#include <linux/vs_context.h>
15105 +#include <linux/vs_network.h>
15106 +#include <linux/vs_limit.h>
15107 +#include <linux/vs_memory.h>
15109 #include <asm/pgtable.h>
15110 #include <asm/pgalloc.h>
15111 @@ -160,6 +164,8 @@ void free_task(struct task_struct *tsk)
15112 account_kernel_stack(tsk->stack, -1);
15113 free_thread_info(tsk->stack);
15114 rt_mutex_debug_task_free(tsk);
15115 + clr_vx_info(&tsk->vx_info);
15116 + clr_nx_info(&tsk->nx_info);
15117 ftrace_graph_exit_task(tsk);
15118 free_task_struct(tsk);
15120 @@ -492,6 +498,7 @@ static struct mm_struct * mm_init(struct
15121 if (likely(!mm_alloc_pgd(mm))) {
15123 mmu_notifier_mm_init(mm);
15124 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15128 @@ -525,6 +532,7 @@ void __mmdrop(struct mm_struct *mm)
15130 destroy_context(mm);
15131 mmu_notifier_mm_destroy(mm);
15132 + clr_vx_info(&mm->mm_vx_info);
15135 EXPORT_SYMBOL_GPL(__mmdrop);
15136 @@ -660,6 +668,7 @@ struct mm_struct *dup_mm(struct task_str
15139 memcpy(mm, oldmm, sizeof(*mm));
15140 + mm->mm_vx_info = NULL;
15142 /* Initializing for Swap token stuff */
15143 mm->token_priority = 0;
15144 @@ -698,6 +707,7 @@ fail_nocontext:
15145 * If init_new_context() failed, we cannot use mmput() to free the mm
15146 * because it calls destroy_context()
15148 + clr_vx_info(&mm->mm_vx_info);
15152 @@ -972,6 +982,8 @@ static struct task_struct *copy_process(
15154 struct task_struct *p;
15155 int cgroup_callbacks_done = 0;
15156 + struct vx_info *vxi;
15157 + struct nx_info *nxi;
15159 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15160 return ERR_PTR(-EINVAL);
15161 @@ -1018,7 +1030,12 @@ static struct task_struct *copy_process(
15162 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15163 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15165 + init_vx_info(&p->vx_info, current_vx_info());
15166 + init_nx_info(&p->nx_info, current_nx_info());
15169 + if (!vx_nproc_avail(1))
15170 + goto bad_fork_free;
15171 if (atomic_read(&p->real_cred->user->processes) >=
15172 task_rlimit(p, RLIMIT_NPROC)) {
15173 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15174 @@ -1283,6 +1300,18 @@ static struct task_struct *copy_process(
15177 spin_unlock(¤t->sighand->siglock);
15179 + /* p is copy of current */
15180 + vxi = p->vx_info;
15182 + claim_vx_info(vxi, p);
15183 + atomic_inc(&vxi->cvirt.nr_threads);
15184 + atomic_inc(&vxi->cvirt.total_forks);
15187 + nxi = p->nx_info;
15189 + claim_nx_info(nxi, p);
15190 write_unlock_irq(&tasklist_lock);
15191 proc_fork_connector(p);
15192 cgroup_post_fork(p);
15193 diff -NurpP --minimal linux-2.6.35.7/kernel/kthread.c linux-2.6.35.7-vs2.3.0.36.33/kernel/kthread.c
15194 --- linux-2.6.35.7/kernel/kthread.c 2010-07-07 18:31:57.000000000 +0200
15195 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/kthread.c 2010-08-02 17:05:06.000000000 +0200
15197 #include <linux/file.h>
15198 #include <linux/module.h>
15199 #include <linux/mutex.h>
15200 +#include <linux/vs_pid.h>
15201 #include <trace/events/sched.h>
15203 static DEFINE_SPINLOCK(kthread_create_lock);
15204 diff -NurpP --minimal linux-2.6.35.7/kernel/Makefile linux-2.6.35.7-vs2.3.0.36.33/kernel/Makefile
15205 --- linux-2.6.35.7/kernel/Makefile 2010-08-02 16:52:57.000000000 +0200
15206 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/Makefile 2010-08-02 17:05:06.000000000 +0200
15207 @@ -25,6 +25,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
15208 CFLAGS_REMOVE_perf_event.o = -pg
15212 obj-$(CONFIG_FREEZER) += freezer.o
15213 obj-$(CONFIG_PROFILING) += profile.o
15214 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15215 diff -NurpP --minimal linux-2.6.35.7/kernel/nsproxy.c linux-2.6.35.7-vs2.3.0.36.33/kernel/nsproxy.c
15216 --- linux-2.6.35.7/kernel/nsproxy.c 2010-07-07 18:31:57.000000000 +0200
15217 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/nsproxy.c 2010-08-02 17:05:06.000000000 +0200
15219 #include <linux/mnt_namespace.h>
15220 #include <linux/utsname.h>
15221 #include <linux/pid_namespace.h>
15222 +#include <linux/vserver/global.h>
15223 +#include <linux/vserver/debug.h>
15224 #include <net/net_namespace.h>
15225 #include <linux/ipc_namespace.h>
15227 @@ -43,8 +45,11 @@ static inline struct nsproxy *create_nsp
15228 struct nsproxy *nsproxy;
15230 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
15233 atomic_set(&nsproxy->count, 1);
15234 + atomic_inc(&vs_global_nsproxy);
15236 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
15240 @@ -53,41 +58,52 @@ static inline struct nsproxy *create_nsp
15241 * Return the newly created nsproxy. Do not attach this to the task,
15242 * leave it to the caller to do proper locking and attach it to task.
15244 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15245 - struct task_struct *tsk, struct fs_struct *new_fs)
15246 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15247 + struct nsproxy *orig, struct fs_struct *new_fs)
15249 struct nsproxy *new_nsp;
15252 + vxdprintk(VXD_CBIT(space, 4),
15253 + "unshare_namespaces(0x%08lx,%p,%p)",
15254 + flags, orig, new_fs);
15256 new_nsp = create_nsproxy();
15258 return ERR_PTR(-ENOMEM);
15260 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15261 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15262 if (IS_ERR(new_nsp->mnt_ns)) {
15263 err = PTR_ERR(new_nsp->mnt_ns);
15267 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15268 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15269 if (IS_ERR(new_nsp->uts_ns)) {
15270 err = PTR_ERR(new_nsp->uts_ns);
15274 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15275 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15276 if (IS_ERR(new_nsp->ipc_ns)) {
15277 err = PTR_ERR(new_nsp->ipc_ns);
15281 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15282 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15283 if (IS_ERR(new_nsp->pid_ns)) {
15284 err = PTR_ERR(new_nsp->pid_ns);
15288 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15290 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15291 + if (IS_ERR(new_nsp->user_ns)) {
15292 + err = PTR_ERR(new_nsp->user_ns);
15296 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15297 if (IS_ERR(new_nsp->net_ns)) {
15298 err = PTR_ERR(new_nsp->net_ns);
15300 @@ -112,6 +128,38 @@ out_ns:
15301 return ERR_PTR(err);
15304 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15305 + struct fs_struct *new_fs)
15307 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15311 + * copies the nsproxy, setting refcount to 1, and grabbing a
15312 + * reference to all contained namespaces.
15314 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15316 + struct nsproxy *ns = create_nsproxy();
15319 + memcpy(ns, orig, sizeof(struct nsproxy));
15320 + atomic_set(&ns->count, 1);
15323 + get_mnt_ns(ns->mnt_ns);
15325 + get_uts_ns(ns->uts_ns);
15327 + get_ipc_ns(ns->ipc_ns);
15329 + get_pid_ns(ns->pid_ns);
15331 + get_net(ns->net_ns);
15337 * called from clone. This now handles copy for nsproxy and all
15338 * namespaces therein.
15339 @@ -119,9 +167,12 @@ out_ns:
15340 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15342 struct nsproxy *old_ns = tsk->nsproxy;
15343 - struct nsproxy *new_ns;
15344 + struct nsproxy *new_ns = NULL;
15347 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15348 + flags, tsk, old_ns);
15353 @@ -131,7 +182,7 @@ int copy_namespaces(unsigned long flags,
15354 CLONE_NEWPID | CLONE_NEWNET)))
15357 - if (!capable(CAP_SYS_ADMIN)) {
15358 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
15362 @@ -158,6 +209,9 @@ int copy_namespaces(unsigned long flags,
15365 put_nsproxy(old_ns);
15366 + vxdprintk(VXD_CBIT(space, 3),
15367 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15368 + flags, tsk, old_ns, err, new_ns);
15372 @@ -171,7 +225,9 @@ void free_nsproxy(struct nsproxy *ns)
15373 put_ipc_ns(ns->ipc_ns);
15375 put_pid_ns(ns->pid_ns);
15376 - put_net(ns->net_ns);
15378 + put_net(ns->net_ns);
15379 + atomic_dec(&vs_global_nsproxy);
15380 kmem_cache_free(nsproxy_cachep, ns);
15383 @@ -184,11 +240,15 @@ int unshare_nsproxy_namespaces(unsigned
15387 + vxdprintk(VXD_CBIT(space, 4),
15388 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15389 + unshare_flags, current->nsproxy);
15391 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15395 - if (!capable(CAP_SYS_ADMIN))
15396 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
15399 *new_nsp = create_new_namespaces(unshare_flags, current,
15400 diff -NurpP --minimal linux-2.6.35.7/kernel/pid.c linux-2.6.35.7-vs2.3.0.36.33/kernel/pid.c
15401 --- linux-2.6.35.7/kernel/pid.c 2010-08-02 16:52:57.000000000 +0200
15402 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/pid.c 2010-08-02 17:05:06.000000000 +0200
15404 #include <linux/pid_namespace.h>
15405 #include <linux/init_task.h>
15406 #include <linux/syscalls.h>
15407 +#include <linux/vs_pid.h>
15409 #define pid_hashfn(nr, ns) \
15410 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15411 @@ -305,7 +306,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15413 struct pid *find_vpid(int nr)
15415 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15416 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15418 EXPORT_SYMBOL_GPL(find_vpid);
15420 @@ -365,6 +366,9 @@ void transfer_pid(struct task_struct *ol
15421 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15423 struct task_struct *result = NULL;
15425 + if (type == PIDTYPE_REALPID)
15426 + type = PIDTYPE_PID;
15428 struct hlist_node *first;
15429 first = rcu_dereference_check(pid->tasks[type].first,
15430 @@ -382,7 +386,7 @@ EXPORT_SYMBOL(pid_task);
15432 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15434 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15435 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15438 struct task_struct *find_task_by_vpid(pid_t vnr)
15439 @@ -424,7 +428,7 @@ struct pid *find_get_pid(pid_t nr)
15441 EXPORT_SYMBOL_GPL(find_get_pid);
15443 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15444 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15448 @@ -437,6 +441,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15452 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15454 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15457 pid_t pid_vnr(struct pid *pid)
15459 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15460 diff -NurpP --minimal linux-2.6.35.7/kernel/pid_namespace.c linux-2.6.35.7-vs2.3.0.36.33/kernel/pid_namespace.c
15461 --- linux-2.6.35.7/kernel/pid_namespace.c 2010-07-07 18:31:57.000000000 +0200
15462 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/pid_namespace.c 2010-08-02 17:05:06.000000000 +0200
15464 #include <linux/err.h>
15465 #include <linux/acct.h>
15466 #include <linux/slab.h>
15467 +#include <linux/vserver/global.h>
15469 #define BITS_PER_PAGE (PAGE_SIZE*8)
15471 @@ -87,6 +88,7 @@ static struct pid_namespace *create_pid_
15474 kref_init(&ns->kref);
15475 + atomic_inc(&vs_global_pid_ns);
15477 ns->parent = get_pid_ns(parent_pid_ns);
15479 @@ -112,6 +114,7 @@ static void destroy_pid_namespace(struct
15481 for (i = 0; i < PIDMAP_ENTRIES; i++)
15482 kfree(ns->pidmap[i].page);
15483 + atomic_dec(&vs_global_pid_ns);
15484 kmem_cache_free(pid_ns_cachep, ns);
15487 diff -NurpP --minimal linux-2.6.35.7/kernel/posix-timers.c linux-2.6.35.7-vs2.3.0.36.33/kernel/posix-timers.c
15488 --- linux-2.6.35.7/kernel/posix-timers.c 2010-08-02 16:52:57.000000000 +0200
15489 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/posix-timers.c 2010-08-02 17:05:06.000000000 +0200
15491 #include <linux/wait.h>
15492 #include <linux/workqueue.h>
15493 #include <linux/module.h>
15494 +#include <linux/vs_context.h>
15497 * Management arrays for POSIX timers. Timers are kept in slab memory
15498 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
15500 struct task_struct *task;
15501 int shared, ret = -1;
15504 * FIXME: if ->sigq is queued we can race with
15505 * dequeue_signal()->do_schedule_next_timer().
15506 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
15508 task = pid_task(timr->it_pid, PIDTYPE_PID);
15510 + struct vx_info_save vxis;
15511 + struct vx_info *vxi;
15513 + vxi = get_vx_info(task->vx_info);
15514 + enter_vx_info(vxi, &vxis);
15515 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15516 ret = send_sigqueue(timr->sigq, task, shared);
15517 + leave_vx_info(&vxis);
15518 + put_vx_info(vxi);
15522 /* If we failed to send the signal the timer stops. */
15525 diff -NurpP --minimal linux-2.6.35.7/kernel/printk.c linux-2.6.35.7-vs2.3.0.36.33/kernel/printk.c
15526 --- linux-2.6.35.7/kernel/printk.c 2010-08-02 16:52:57.000000000 +0200
15527 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/printk.c 2010-08-02 17:05:06.000000000 +0200
15529 #include <linux/ratelimit.h>
15530 #include <linux/kmsg_dump.h>
15531 #include <linux/syslog.h>
15532 +#include <linux/vs_cvirt.h>
15534 #include <asm/uaccess.h>
15536 @@ -264,18 +265,15 @@ int do_syslog(int type, char __user *buf
15537 unsigned i, j, limit, count;
15543 error = security_syslog(type, from_file);
15548 - case SYSLOG_ACTION_CLOSE: /* Close log */
15550 - case SYSLOG_ACTION_OPEN: /* Open log */
15552 - case SYSLOG_ACTION_READ: /* Read from log */
15553 + if ((type == SYSLOG_ACTION_READ) ||
15554 + (type == SYSLOG_ACTION_READ_ALL) ||
15555 + (type == SYSLOG_ACTION_READ_CLEAR)) {
15557 if (!buf || len < 0)
15559 @@ -286,6 +284,16 @@ int do_syslog(int type, char __user *buf
15564 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15565 + return vx_do_syslog(type, buf, len);
15568 + case SYSLOG_ACTION_CLOSE: /* Close log */
15570 + case SYSLOG_ACTION_OPEN: /* Open log */
15572 + case SYSLOG_ACTION_READ: /* Read from log */
15573 error = wait_event_interruptible(log_wait,
15574 (log_start - log_end));
15576 @@ -312,16 +320,6 @@ int do_syslog(int type, char __user *buf
15578 /* Read last kernel messages */
15579 case SYSLOG_ACTION_READ_ALL:
15581 - if (!buf || len < 0)
15586 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15591 if (count > log_buf_len)
15592 count = log_buf_len;
15593 diff -NurpP --minimal linux-2.6.35.7/kernel/ptrace.c linux-2.6.35.7-vs2.3.0.36.33/kernel/ptrace.c
15594 --- linux-2.6.35.7/kernel/ptrace.c 2010-08-02 16:52:57.000000000 +0200
15595 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/ptrace.c 2010-08-02 17:05:06.000000000 +0200
15597 #include <linux/syscalls.h>
15598 #include <linux/uaccess.h>
15599 #include <linux/regset.h>
15600 +#include <linux/vs_context.h>
15604 @@ -150,6 +151,11 @@ int __ptrace_may_access(struct task_stru
15605 dumpable = get_dumpable(task->mm);
15606 if (!dumpable && !capable(CAP_SYS_PTRACE))
15608 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
15610 + if (!vx_check(task->xid, VS_IDENT) &&
15611 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15614 return security_ptrace_access_check(task, mode);
15616 @@ -703,6 +709,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
15621 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
15622 + goto out_put_task_struct;
15624 if (request == PTRACE_ATTACH) {
15625 ret = ptrace_attach(child);
15627 diff -NurpP --minimal linux-2.6.35.7/kernel/sched.c linux-2.6.35.7-vs2.3.0.36.33/kernel/sched.c
15628 --- linux-2.6.35.7/kernel/sched.c 2010-10-04 08:57:40.000000000 +0200
15629 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/sched.c 2010-10-05 19:23:43.000000000 +0200
15631 #include <linux/ctype.h>
15632 #include <linux/ftrace.h>
15633 #include <linux/slab.h>
15634 +#include <linux/vs_sched.h>
15635 +#include <linux/vs_cvirt.h>
15637 #include <asm/tlb.h>
15638 #include <asm/irq_regs.h>
15639 @@ -2947,9 +2949,17 @@ static inline long calc_load_fold_idle(v
15641 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
15643 - loads[0] = (avenrun[0] + offset) << shift;
15644 - loads[1] = (avenrun[1] + offset) << shift;
15645 - loads[2] = (avenrun[2] + offset) << shift;
15646 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
15647 + struct vx_info *vxi = current_vx_info();
15649 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
15650 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
15651 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
15653 + loads[0] = (avenrun[0] + offset) << shift;
15654 + loads[1] = (avenrun[1] + offset) << shift;
15655 + loads[2] = (avenrun[2] + offset) << shift;
15659 static unsigned long
15660 @@ -3157,16 +3167,19 @@ void account_user_time(struct task_struc
15661 cputime_t cputime_scaled)
15663 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15664 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15666 + int nice = (TASK_NICE(p) > 0);
15668 /* Add user time to process. */
15669 p->utime = cputime_add(p->utime, cputime);
15670 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15671 + vx_account_user(vxi, cputime, nice);
15672 account_group_user_time(p, cputime);
15674 /* Add user time to cpustat. */
15675 tmp = cputime_to_cputime64(cputime);
15676 - if (TASK_NICE(p) > 0)
15678 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15680 cpustat->user = cputime64_add(cpustat->user, tmp);
15681 @@ -3217,6 +3230,7 @@ void account_system_time(struct task_str
15682 cputime_t cputime, cputime_t cputime_scaled)
15684 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15685 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15688 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
15689 @@ -3227,6 +3241,7 @@ void account_system_time(struct task_str
15690 /* Add system time to process. */
15691 p->stime = cputime_add(p->stime, cputime);
15692 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15693 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15694 account_group_system_time(p, cputime);
15696 /* Add system time to cpustat. */
15697 @@ -4300,7 +4315,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15700 if (increment < 0 && !can_nice(current, nice))
15702 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15704 retval = security_task_setnice(current, nice);
15706 diff -NurpP --minimal linux-2.6.35.7/kernel/sched_fair.c linux-2.6.35.7-vs2.3.0.36.33/kernel/sched_fair.c
15707 --- linux-2.6.35.7/kernel/sched_fair.c 2010-08-02 16:52:57.000000000 +0200
15708 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/sched_fair.c 2010-08-02 17:05:06.000000000 +0200
15709 @@ -782,6 +782,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15710 check_spread(cfs_rq, se);
15711 if (se != cfs_rq->curr)
15712 __enqueue_entity(cfs_rq, se);
15714 + if (entity_is_task(se))
15715 + vx_activate_task(task_of(se));
15718 static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
15719 @@ -825,6 +828,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15721 if (se != cfs_rq->curr)
15722 __dequeue_entity(cfs_rq, se);
15723 + if (entity_is_task(se))
15724 + vx_deactivate_task(task_of(se));
15725 account_entity_dequeue(cfs_rq, se);
15726 update_min_vruntime(cfs_rq);
15728 diff -NurpP --minimal linux-2.6.35.7/kernel/signal.c linux-2.6.35.7-vs2.3.0.36.33/kernel/signal.c
15729 --- linux-2.6.35.7/kernel/signal.c 2010-10-04 08:57:40.000000000 +0200
15730 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/signal.c 2010-08-14 18:19:32.000000000 +0200
15732 #include <linux/freezer.h>
15733 #include <linux/pid_namespace.h>
15734 #include <linux/nsproxy.h>
15735 +#include <linux/vs_context.h>
15736 +#include <linux/vs_pid.h>
15737 #define CREATE_TRACE_POINTS
15738 #include <trace/events/signal.h>
15740 @@ -646,9 +648,18 @@ static int check_kill_permission(int sig
15744 + vxdprintk(VXD_CBIT(misc, 7),
15745 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15746 + sig, info, t, vx_task_xid(t), t->pid);
15748 if (!valid_signal(sig))
15751 +/* FIXME: needed? if so, why?
15752 + if ((info != SEND_SIG_NOINFO) &&
15753 + (is_si_special(info) || !si_fromuser(info)))
15756 if (!si_fromuser(info))
15759 @@ -678,6 +689,20 @@ static int check_kill_permission(int sig
15764 + if (t->pid == 1 && current->xid)
15768 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15769 + loops, maybe ENOENT or EACCES? */
15770 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15771 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15772 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15773 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15777 return security_task_kill(t, info, sig, 0);
15780 @@ -1170,7 +1195,7 @@ int kill_pid_info(int sig, struct siginf
15783 p = pid_task(pid, PIDTYPE_PID);
15785 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15786 error = group_send_sig_info(sig, info, p);
15787 if (unlikely(error == -ESRCH))
15789 @@ -1210,7 +1235,7 @@ int kill_pid_info_as_uid(int sig, struct
15792 p = pid_task(pid, PIDTYPE_PID);
15794 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15798 @@ -1265,8 +1290,10 @@ static int kill_something_info(int sig,
15799 struct task_struct * p;
15801 for_each_process(p) {
15802 - if (task_pid_vnr(p) > 1 &&
15803 - !same_thread_group(p, current)) {
15804 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15805 + task_pid_vnr(p) > 1 &&
15806 + !same_thread_group(p, current) &&
15807 + !vx_current_initpid(p->pid)) {
15808 int err = group_send_sig_info(sig, info, p);
15811 @@ -1933,6 +1960,11 @@ relock:
15812 !sig_kernel_only(signr))
15815 + /* virtual init is protected against user signals */
15816 + if ((info->si_code == SI_USER) &&
15817 + vx_current_initpid(current->pid))
15820 if (sig_kernel_stop(signr)) {
15822 * The default action is to stop all threads in
15823 diff -NurpP --minimal linux-2.6.35.7/kernel/softirq.c linux-2.6.35.7-vs2.3.0.36.33/kernel/softirq.c
15824 --- linux-2.6.35.7/kernel/softirq.c 2010-08-02 16:52:57.000000000 +0200
15825 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/softirq.c 2010-08-02 17:05:06.000000000 +0200
15827 #include <linux/ftrace.h>
15828 #include <linux/smp.h>
15829 #include <linux/tick.h>
15830 +#include <linux/vs_context.h>
15832 #define CREATE_TRACE_POINTS
15833 #include <trace/events/irq.h>
15834 diff -NurpP --minimal linux-2.6.35.7/kernel/sys.c linux-2.6.35.7-vs2.3.0.36.33/kernel/sys.c
15835 --- linux-2.6.35.7/kernel/sys.c 2010-10-04 08:57:40.000000000 +0200
15836 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/sys.c 2010-10-05 19:23:43.000000000 +0200
15838 #include <linux/syscalls.h>
15839 #include <linux/kprobes.h>
15840 #include <linux/user_namespace.h>
15841 +#include <linux/vs_pid.h>
15843 #include <asm/uaccess.h>
15844 #include <asm/io.h>
15845 @@ -131,7 +132,10 @@ static int set_one_prio(struct task_stru
15848 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15850 + if (vx_flags(VXF_IGNEG_NICE, 0))
15856 no_nice = security_task_setnice(p, niceval);
15857 @@ -181,6 +185,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15859 pgrp = task_pgrp(current);
15860 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15861 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15863 error = set_one_prio(p, niceval, error);
15864 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15866 @@ -244,6 +250,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15868 pgrp = task_pgrp(current);
15869 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15870 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15872 niceval = 20 - task_nice(p);
15873 if (niceval > retval)
15875 @@ -357,6 +365,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15877 static DEFINE_MUTEX(reboot_mutex);
15879 +long vs_reboot(unsigned int, void __user *);
15882 * Reboot system call: for obvious reasons only root may call it,
15883 * and even root needs to set up some magic numbers in the registers
15884 @@ -389,6 +399,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15885 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15886 cmd = LINUX_REBOOT_CMD_HALT;
15888 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15889 + return vs_reboot(cmd, arg);
15891 mutex_lock(&reboot_mutex);
15893 case LINUX_REBOOT_CMD_RESTART:
15894 @@ -1169,7 +1182,7 @@ SYSCALL_DEFINE2(sethostname, char __user
15896 char tmp[__NEW_UTS_LEN];
15898 - if (!capable(CAP_SYS_ADMIN))
15899 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15901 if (len < 0 || len > __NEW_UTS_LEN)
15903 @@ -1218,7 +1231,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
15905 char tmp[__NEW_UTS_LEN];
15907 - if (!capable(CAP_SYS_ADMIN))
15908 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15910 if (len < 0 || len > __NEW_UTS_LEN)
15912 @@ -1287,7 +1300,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
15914 old_rlim = current->signal->rlim + resource;
15915 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
15916 - !capable(CAP_SYS_RESOURCE))
15917 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15919 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
15921 diff -NurpP --minimal linux-2.6.35.7/kernel/sysctl_binary.c linux-2.6.35.7-vs2.3.0.36.33/kernel/sysctl_binary.c
15922 --- linux-2.6.35.7/kernel/sysctl_binary.c 2010-08-02 16:52:57.000000000 +0200
15923 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/sysctl_binary.c 2010-08-02 17:05:06.000000000 +0200
15924 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15926 { CTL_INT, KERN_PANIC, "panic" },
15927 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15928 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15930 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15931 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15932 diff -NurpP --minimal linux-2.6.35.7/kernel/sysctl.c linux-2.6.35.7-vs2.3.0.36.33/kernel/sysctl.c
15933 --- linux-2.6.35.7/kernel/sysctl.c 2010-08-02 16:52:57.000000000 +0200
15934 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/sysctl.c 2010-08-02 17:05:06.000000000 +0200
15936 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15937 #include <linux/lockdep.h>
15939 +extern char vshelper_path[];
15940 #ifdef CONFIG_CHR_DEV_SG
15941 #include <scsi/sg.h>
15943 @@ -571,6 +572,13 @@ static struct ctl_table kern_table[] = {
15944 .proc_handler = proc_dostring,
15948 + .procname = "vshelper",
15949 + .data = &vshelper_path,
15952 + .proc_handler = &proc_dostring,
15954 #ifdef CONFIG_CHR_DEV_SG
15956 .procname = "sg-big-buff",
15957 diff -NurpP --minimal linux-2.6.35.7/kernel/time.c linux-2.6.35.7-vs2.3.0.36.33/kernel/time.c
15958 --- linux-2.6.35.7/kernel/time.c 2010-08-02 16:52:57.000000000 +0200
15959 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/time.c 2010-08-02 17:05:06.000000000 +0200
15960 @@ -62,6 +62,7 @@ EXPORT_SYMBOL(sys_tz);
15961 SYSCALL_DEFINE1(time, time_t __user *, tloc)
15963 time_t i = get_seconds();
15964 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
15967 if (put_user(i,tloc))
15968 @@ -92,7 +93,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15972 - do_settimeofday(&tv);
15973 + vx_settimeofday(&tv);
15977 @@ -103,7 +104,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
15979 if (likely(tv != NULL)) {
15980 struct timeval ktv;
15981 - do_gettimeofday(&ktv);
15982 + vx_gettimeofday(&ktv);
15983 if (copy_to_user(tv, &ktv, sizeof(ktv)))
15986 @@ -177,7 +178,7 @@ int do_sys_settimeofday(struct timespec
15987 /* SMP safe, again the code in arch/foo/time.c should
15988 * globally block out interrupts when it runs.
15990 - return do_settimeofday(tv);
15991 + return vx_settimeofday(tv);
15995 @@ -309,7 +310,7 @@ void getnstimeofday(struct timespec *tv)
15999 - do_gettimeofday(&x);
16000 + vx_gettimeofday(&x);
16001 tv->tv_sec = x.tv_sec;
16002 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
16004 diff -NurpP --minimal linux-2.6.35.7/kernel/timer.c linux-2.6.35.7-vs2.3.0.36.33/kernel/timer.c
16005 --- linux-2.6.35.7/kernel/timer.c 2010-08-02 16:52:58.000000000 +0200
16006 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/timer.c 2010-08-02 17:05:06.000000000 +0200
16008 #include <linux/perf_event.h>
16009 #include <linux/sched.h>
16010 #include <linux/slab.h>
16011 +#include <linux/vs_base.h>
16012 +#include <linux/vs_cvirt.h>
16013 +#include <linux/vs_pid.h>
16014 +#include <linux/vserver/sched.h>
16016 #include <asm/uaccess.h>
16017 #include <asm/unistd.h>
16018 @@ -1318,12 +1322,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
16025 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
16026 - * should be moved into arch/i386 instead?
16030 * sys_getpid - return the thread group id of the current process
16031 @@ -1352,10 +1350,23 @@ SYSCALL_DEFINE0(getppid)
16033 pid = task_tgid_vnr(current->real_parent);
16035 + return vx_map_pid(pid);
16042 + * The Alpha uses getxpid, getxuid, and getxgid instead.
16045 +asmlinkage long do_getxpid(long *ppid)
16047 + *ppid = sys_getppid();
16048 + return sys_getpid();
16051 +#else /* _alpha_ */
16053 SYSCALL_DEFINE0(getuid)
16055 /* Only we change this so SMP safe */
16056 diff -NurpP --minimal linux-2.6.35.7/kernel/user_namespace.c linux-2.6.35.7-vs2.3.0.36.33/kernel/user_namespace.c
16057 --- linux-2.6.35.7/kernel/user_namespace.c 2010-08-02 16:52:58.000000000 +0200
16058 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/user_namespace.c 2010-08-02 17:05:06.000000000 +0200
16060 #include <linux/slab.h>
16061 #include <linux/user_namespace.h>
16062 #include <linux/cred.h>
16063 +#include <linux/vserver/global.h>
16066 * Create a new user namespace, deriving the creator from the user in the
16067 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
16070 kref_init(&ns->kref);
16071 + atomic_inc(&vs_global_user_ns);
16073 for (n = 0; n < UIDHASH_SZ; ++n)
16074 INIT_HLIST_HEAD(ns->uidhash_table + n);
16075 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
16076 struct user_namespace *ns =
16077 container_of(kref, struct user_namespace, kref);
16079 + /* FIXME: maybe move into destroyer? */
16080 + atomic_dec(&vs_global_user_ns);
16081 INIT_WORK(&ns->destroyer, free_user_ns_work);
16082 schedule_work(&ns->destroyer);
16084 diff -NurpP --minimal linux-2.6.35.7/kernel/utsname.c linux-2.6.35.7-vs2.3.0.36.33/kernel/utsname.c
16085 --- linux-2.6.35.7/kernel/utsname.c 2009-09-10 15:26:28.000000000 +0200
16086 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/utsname.c 2010-08-02 17:05:06.000000000 +0200
16087 @@ -14,14 +14,17 @@
16088 #include <linux/utsname.h>
16089 #include <linux/err.h>
16090 #include <linux/slab.h>
16091 +#include <linux/vserver/global.h>
16093 static struct uts_namespace *create_uts_ns(void)
16095 struct uts_namespace *uts_ns;
16097 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
16100 kref_init(&uts_ns->kref);
16101 + atomic_inc(&vs_global_uts_ns);
16106 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
16107 struct uts_namespace *ns;
16109 ns = container_of(kref, struct uts_namespace, kref);
16110 + atomic_dec(&vs_global_uts_ns);
16113 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/cacct.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/cacct.c
16114 --- linux-2.6.35.7/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
16115 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/cacct.c 2010-08-02 17:05:06.000000000 +0200
16118 + * linux/kernel/vserver/cacct.c
16120 + * Virtual Server: Context Accounting
16122 + * Copyright (C) 2006-2007 Herbert Pötzl
16124 + * V0.01 added accounting stats
16128 +#include <linux/types.h>
16129 +#include <linux/vs_context.h>
16130 +#include <linux/vserver/cacct_cmd.h>
16131 +#include <linux/vserver/cacct_int.h>
16133 +#include <asm/errno.h>
16134 +#include <asm/uaccess.h>
16137 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
16139 + struct vcmd_sock_stat_v0 vc_data;
16142 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16145 + field = vc_data.field;
16146 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
16149 + for (j = 0; j < 3; j++) {
16150 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
16151 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
16154 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16159 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/cacct_init.h linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/cacct_init.h
16160 --- linux-2.6.35.7/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16161 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/cacct_init.h 2010-08-02 17:05:06.000000000 +0200
16165 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16170 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16171 + for (j = 0; j < 3; j++) {
16172 + atomic_long_set(&cacct->sock[i][j].count, 0);
16173 + atomic_long_set(&cacct->sock[i][j].total, 0);
16176 + for (i = 0; i < 8; i++)
16177 + atomic_set(&cacct->slab[i], 0);
16178 + for (i = 0; i < 5; i++)
16179 + for (j = 0; j < 4; j++)
16180 + atomic_set(&cacct->page[i][j], 0);
16183 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16188 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/cacct_proc.h linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/cacct_proc.h
16189 --- linux-2.6.35.7/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
16190 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/cacct_proc.h 2010-08-02 17:05:06.000000000 +0200
16192 +#ifndef _VX_CACCT_PROC_H
16193 +#define _VX_CACCT_PROC_H
16195 +#include <linux/vserver/cacct_int.h>
16198 +#define VX_SOCKA_TOP \
16199 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
16201 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
16203 + int i, j, length = 0;
16204 + static char *type[VXA_SOCK_SIZE] = {
16205 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
16208 + length += sprintf(buffer + length, VX_SOCKA_TOP);
16209 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16210 + length += sprintf(buffer + length, "%s:", type[i]);
16211 + for (j = 0; j < 3; j++) {
16212 + length += sprintf(buffer + length,
16213 + "\t%10lu/%-10lu",
16214 + vx_sock_count(cacct, i, j),
16215 + vx_sock_total(cacct, i, j));
16217 + buffer[length++] = '\n';
16220 + length += sprintf(buffer + length, "\n");
16221 + length += sprintf(buffer + length,
16222 + "slab:\t %8u %8u %8u %8u\n",
16223 + atomic_read(&cacct->slab[1]),
16224 + atomic_read(&cacct->slab[4]),
16225 + atomic_read(&cacct->slab[0]),
16226 + atomic_read(&cacct->slab[2]));
16228 + length += sprintf(buffer + length, "\n");
16229 + for (i = 0; i < 5; i++) {
16230 + length += sprintf(buffer + length,
16231 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
16232 + atomic_read(&cacct->page[i][0]),
16233 + atomic_read(&cacct->page[i][1]),
16234 + atomic_read(&cacct->page[i][2]),
16235 + atomic_read(&cacct->page[i][3]),
16236 + atomic_read(&cacct->page[i][4]),
16237 + atomic_read(&cacct->page[i][5]),
16238 + atomic_read(&cacct->page[i][6]),
16239 + atomic_read(&cacct->page[i][7]));
16244 +#endif /* _VX_CACCT_PROC_H */
16245 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/context.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/context.c
16246 --- linux-2.6.35.7/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
16247 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/context.c 2010-08-02 17:05:06.000000000 +0200
16250 + * linux/kernel/vserver/context.c
16252 + * Virtual Server: Context Support
16254 + * Copyright (C) 2003-2007 Herbert Pötzl
16256 + * V0.01 context helper
16257 + * V0.02 vx_ctx_kill syscall command
16258 + * V0.03 replaced context_info calls
16259 + * V0.04 redesign of struct (de)alloc
16260 + * V0.05 rlimit basic implementation
16261 + * V0.06 task_xid and info commands
16262 + * V0.07 context flags and caps
16263 + * V0.08 switch to RCU based hash
16264 + * V0.09 revert to non RCU for now
16265 + * V0.10 and back to working RCU hash
16266 + * V0.11 and back to locking again
16267 + * V0.12 referenced context store
16268 + * V0.13 separate per cpu data
16269 + * V0.14 changed vcmds to vxi arg
16270 + * V0.15 added context stat
16271 + * V0.16 have __create claim() the vxi
16272 + * V0.17 removed older and legacy stuff
16276 +#include <linux/slab.h>
16277 +#include <linux/types.h>
16278 +#include <linux/security.h>
16279 +#include <linux/pid_namespace.h>
16281 +#include <linux/vserver/context.h>
16282 +#include <linux/vserver/network.h>
16283 +#include <linux/vserver/debug.h>
16284 +#include <linux/vserver/limit.h>
16285 +#include <linux/vserver/limit_int.h>
16286 +#include <linux/vserver/space.h>
16287 +#include <linux/init_task.h>
16288 +#include <linux/fs_struct.h>
16290 +#include <linux/vs_context.h>
16291 +#include <linux/vs_limit.h>
16292 +#include <linux/vs_pid.h>
16293 +#include <linux/vserver/context_cmd.h>
16295 +#include "cvirt_init.h"
16296 +#include "cacct_init.h"
16297 +#include "limit_init.h"
16298 +#include "sched_init.h"
16301 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
16302 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
16305 +/* now inactive context structures */
16307 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
16309 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
16312 +/* __alloc_vx_info()
16314 + * allocate an initialized vx_info struct
16315 + * doesn't make it visible (hash) */
16317 +static struct vx_info *__alloc_vx_info(xid_t xid)
16319 + struct vx_info *new = NULL;
16322 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
16324 + /* would this benefit from a slab cache? */
16325 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
16329 + memset(new, 0, sizeof(struct vx_info));
16331 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
16332 + if (!new->ptr_pc)
16335 + new->vx_id = xid;
16336 + INIT_HLIST_NODE(&new->vx_hlist);
16337 + atomic_set(&new->vx_usecnt, 0);
16338 + atomic_set(&new->vx_tasks, 0);
16339 + new->vx_parent = NULL;
16340 + new->vx_state = 0;
16341 + init_waitqueue_head(&new->vx_wait);
16343 + /* prepare reaper */
16344 + get_task_struct(init_pid_ns.child_reaper);
16345 + new->vx_reaper = init_pid_ns.child_reaper;
16346 + new->vx_badness_bias = 0;
16348 + /* rest of init goes here */
16349 + vx_info_init_limit(&new->limit);
16350 + vx_info_init_sched(&new->sched);
16351 + vx_info_init_cvirt(&new->cvirt);
16352 + vx_info_init_cacct(&new->cacct);
16354 + /* per cpu data structures */
16355 + for_each_possible_cpu(cpu) {
16356 + vx_info_init_sched_pc(
16357 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16358 + vx_info_init_cvirt_pc(
16359 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16362 + new->vx_flags = VXF_INIT_SET;
16363 + cap_set_init_eff(new->vx_bcaps);
16364 + new->vx_ccaps = 0;
16365 + new->vx_umask = 0;
16367 + new->reboot_cmd = 0;
16368 + new->exit_code = 0;
16370 + // preconfig fs entries
16371 + for (index = 0; index < VX_SPACES; index++) {
16372 + write_lock(&init_fs.lock);
16374 + write_unlock(&init_fs.lock);
16375 + new->vx_fs[index] = &init_fs;
16378 + vxdprintk(VXD_CBIT(xid, 0),
16379 + "alloc_vx_info(%d) = %p", xid, new);
16380 + vxh_alloc_vx_info(new);
16381 + atomic_inc(&vx_global_ctotal);
16390 +/* __dealloc_vx_info()
16392 + * final disposal of vx_info */
16394 +static void __dealloc_vx_info(struct vx_info *vxi)
16396 +#ifdef CONFIG_VSERVER_WARN
16397 + struct vx_info_save vxis;
16400 + vxdprintk(VXD_CBIT(xid, 0),
16401 + "dealloc_vx_info(%p)", vxi);
16402 + vxh_dealloc_vx_info(vxi);
16404 +#ifdef CONFIG_VSERVER_WARN
16405 + enter_vx_info(vxi, &vxis);
16406 + vx_info_exit_limit(&vxi->limit);
16407 + vx_info_exit_sched(&vxi->sched);
16408 + vx_info_exit_cvirt(&vxi->cvirt);
16409 + vx_info_exit_cacct(&vxi->cacct);
16411 + for_each_possible_cpu(cpu) {
16412 + vx_info_exit_sched_pc(
16413 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16414 + vx_info_exit_cvirt_pc(
16415 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16417 + leave_vx_info(&vxis);
16421 + vxi->vx_state |= VXS_RELEASED;
16424 + free_percpu(vxi->ptr_pc);
16427 + atomic_dec(&vx_global_ctotal);
16430 +static void __shutdown_vx_info(struct vx_info *vxi)
16432 + struct nsproxy *nsproxy;
16433 + struct fs_struct *fs;
16438 + vxi->vx_state |= VXS_SHUTDOWN;
16439 + vs_state_change(vxi, VSC_SHUTDOWN);
16441 + for (index = 0; index < VX_SPACES; index++) {
16442 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
16444 + put_nsproxy(nsproxy);
16446 + fs = xchg(&vxi->vx_fs[index], NULL);
16447 + write_lock(&fs->lock);
16448 + kill = !--fs->users;
16449 + write_unlock(&fs->lock);
16451 + free_fs_struct(fs);
16455 +/* exported stuff */
16457 +void free_vx_info(struct vx_info *vxi)
16459 + unsigned long flags;
16462 + /* check for reference counts first */
16463 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16464 + BUG_ON(atomic_read(&vxi->vx_tasks));
16466 + /* context must not be hashed */
16467 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16469 + /* context shutdown is mandatory */
16470 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16472 + /* nsproxy and fs check */
16473 + for (index = 0; index < VX_SPACES; index++) {
16474 + BUG_ON(vxi->vx_nsproxy[index]);
16475 + BUG_ON(vxi->vx_fs[index]);
16478 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16479 + hlist_del(&vxi->vx_hlist);
16480 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16482 + __dealloc_vx_info(vxi);
16486 +/* hash table for vx_info hash */
16488 +#define VX_HASH_SIZE 13
16490 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16491 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16493 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
16496 +static inline unsigned int __hashval(xid_t xid)
16498 + return (xid % VX_HASH_SIZE);
16503 +/* __hash_vx_info()
16505 + * add the vxi to the global hash table
16506 + * requires the hash_lock to be held */
16508 +static inline void __hash_vx_info(struct vx_info *vxi)
16510 + struct hlist_head *head;
16512 + vxd_assert_lock(&vx_info_hash_lock);
16513 + vxdprintk(VXD_CBIT(xid, 4),
16514 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16515 + vxh_hash_vx_info(vxi);
16517 + /* context must not be hashed */
16518 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16520 + vxi->vx_state |= VXS_HASHED;
16521 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16522 + hlist_add_head(&vxi->vx_hlist, head);
16523 + atomic_inc(&vx_global_cactive);
16526 +/* __unhash_vx_info()
16528 + * remove the vxi from the global hash table
16529 + * requires the hash_lock to be held */
16531 +static inline void __unhash_vx_info(struct vx_info *vxi)
16533 + unsigned long flags;
16535 + vxd_assert_lock(&vx_info_hash_lock);
16536 + vxdprintk(VXD_CBIT(xid, 4),
16537 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16538 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16539 + vxh_unhash_vx_info(vxi);
16541 + /* context must be hashed */
16542 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16543 + /* but without tasks */
16544 + BUG_ON(atomic_read(&vxi->vx_tasks));
16546 + vxi->vx_state &= ~VXS_HASHED;
16547 + hlist_del_init(&vxi->vx_hlist);
16548 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16549 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16550 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16551 + atomic_dec(&vx_global_cactive);
16555 +/* __lookup_vx_info()
16557 + * requires the hash_lock to be held
16558 + * doesn't increment the vx_refcnt */
16560 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16562 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16563 + struct hlist_node *pos;
16564 + struct vx_info *vxi;
16566 + vxd_assert_lock(&vx_info_hash_lock);
16567 + hlist_for_each(pos, head) {
16568 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16570 + if (vxi->vx_id == xid)
16575 + vxdprintk(VXD_CBIT(xid, 0),
16576 + "__lookup_vx_info(#%u): %p[#%u]",
16577 + xid, vxi, vxi ? vxi->vx_id : 0);
16578 + vxh_lookup_vx_info(vxi, xid);
16583 +/* __create_vx_info()
16585 + * create the requested context
16586 + * get(), claim() and hash it */
16588 +static struct vx_info *__create_vx_info(int id)
16590 + struct vx_info *new, *vxi = NULL;
16592 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16594 + if (!(new = __alloc_vx_info(id)))
16595 + return ERR_PTR(-ENOMEM);
16597 + /* required to make dynamic xids unique */
16598 + spin_lock(&vx_info_hash_lock);
16600 + /* static context requested */
16601 + if ((vxi = __lookup_vx_info(id))) {
16602 + vxdprintk(VXD_CBIT(xid, 0),
16603 + "create_vx_info(%d) = %p (already there)", id, vxi);
16604 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16605 + vxi = ERR_PTR(-EBUSY);
16607 + vxi = ERR_PTR(-EEXIST);
16610 + /* new context */
16611 + vxdprintk(VXD_CBIT(xid, 0),
16612 + "create_vx_info(%d) = %p (new)", id, new);
16613 + claim_vx_info(new, NULL);
16614 + __hash_vx_info(get_vx_info(new));
16615 + vxi = new, new = NULL;
16618 + spin_unlock(&vx_info_hash_lock);
16619 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16621 + __dealloc_vx_info(new);
16626 +/* exported stuff */
16629 +void unhash_vx_info(struct vx_info *vxi)
16631 + __shutdown_vx_info(vxi);
16632 + spin_lock(&vx_info_hash_lock);
16633 + __unhash_vx_info(vxi);
16634 + spin_unlock(&vx_info_hash_lock);
16635 + __wakeup_vx_info(vxi);
16639 +/* lookup_vx_info()
16641 + * search for a vx_info and get() it
16642 + * negative id means current */
16644 +struct vx_info *lookup_vx_info(int id)
16646 + struct vx_info *vxi = NULL;
16649 + vxi = get_vx_info(current_vx_info());
16650 + } else if (id > 1) {
16651 + spin_lock(&vx_info_hash_lock);
16652 + vxi = get_vx_info(__lookup_vx_info(id));
16653 + spin_unlock(&vx_info_hash_lock);
16658 +/* xid_is_hashed()
16660 + * verify that xid is still hashed */
16662 +int xid_is_hashed(xid_t xid)
16666 + spin_lock(&vx_info_hash_lock);
16667 + hashed = (__lookup_vx_info(xid) != NULL);
16668 + spin_unlock(&vx_info_hash_lock);
16672 +#ifdef CONFIG_PROC_FS
16676 + * get a subset of hashed xids for proc
16677 + * assumes size is at least one */
16679 +int get_xid_list(int index, unsigned int *xids, int size)
16681 + int hindex, nr_xids = 0;
16683 + /* only show current and children */
16684 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16687 + xids[nr_xids] = vx_current_xid();
16691 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16692 + struct hlist_head *head = &vx_info_hash[hindex];
16693 + struct hlist_node *pos;
16695 + spin_lock(&vx_info_hash_lock);
16696 + hlist_for_each(pos, head) {
16697 + struct vx_info *vxi;
16702 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16703 + xids[nr_xids] = vxi->vx_id;
16704 + if (++nr_xids >= size) {
16705 + spin_unlock(&vx_info_hash_lock);
16709 + /* keep the lock time short */
16710 + spin_unlock(&vx_info_hash_lock);
16717 +#ifdef CONFIG_VSERVER_DEBUG
16719 +void dump_vx_info_inactive(int level)
16721 + struct hlist_node *entry, *next;
16723 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16724 + struct vx_info *vxi =
16725 + list_entry(entry, struct vx_info, vx_hlist);
16727 + dump_vx_info(vxi, level);
16734 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16736 + struct user_struct *new_user, *old_user;
16741 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16744 + new_user = alloc_uid(vxi->vx_id, p->uid);
16748 + old_user = p->user;
16749 + if (new_user != old_user) {
16750 + atomic_inc(&new_user->processes);
16751 + atomic_dec(&old_user->processes);
16752 + p->user = new_user;
16754 + free_uid(old_user);
16760 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16762 + // p->cap_effective &= vxi->vx_cap_bset;
16763 + p->cap_effective =
16764 + cap_intersect(p->cap_effective, vxi->cap_bset);
16765 + // p->cap_inheritable &= vxi->vx_cap_bset;
16766 + p->cap_inheritable =
16767 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16768 + // p->cap_permitted &= vxi->vx_cap_bset;
16769 + p->cap_permitted =
16770 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16775 +#include <linux/file.h>
16776 +#include <linux/fdtable.h>
16778 +static int vx_openfd_task(struct task_struct *tsk)
16780 + struct files_struct *files = tsk->files;
16781 + struct fdtable *fdt;
16782 + const unsigned long *bptr;
16783 + int count, total;
16785 + /* no rcu_read_lock() because of spin_lock() */
16786 + spin_lock(&files->file_lock);
16787 + fdt = files_fdtable(files);
16788 + bptr = fdt->open_fds->fds_bits;
16789 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16790 + for (total = 0; count > 0; count--) {
16792 + total += hweight_long(*bptr);
16795 + spin_unlock(&files->file_lock);
16800 +/* for *space compatibility */
16802 +asmlinkage long sys_unshare(unsigned long);
16805 + * migrate task to new context
16806 + * gets vxi, puts old_vxi on change
16807 + * optionally unshares namespaces (hack)
16810 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16812 + struct vx_info *old_vxi;
16818 + vxdprintk(VXD_CBIT(xid, 5),
16819 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16820 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16822 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16823 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16826 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16829 + old_vxi = task_get_vx_info(p);
16830 + if (old_vxi == vxi)
16833 +// if (!(ret = vx_migrate_user(p, vxi))) {
16838 + openfd = vx_openfd_task(p);
16841 + atomic_dec(&old_vxi->cvirt.nr_threads);
16842 + atomic_dec(&old_vxi->cvirt.nr_running);
16843 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16844 + /* FIXME: what about the struct files here? */
16845 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16846 + /* account for the executable */
16847 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16849 + atomic_inc(&vxi->cvirt.nr_threads);
16850 + atomic_inc(&vxi->cvirt.nr_running);
16851 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16852 + /* FIXME: what about the struct files here? */
16853 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16854 + /* account for the executable */
16855 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16858 + release_vx_info(old_vxi, p);
16859 + clr_vx_info(&p->vx_info);
16861 + claim_vx_info(vxi, p);
16862 + set_vx_info(&p->vx_info, vxi);
16863 + p->xid = vxi->vx_id;
16865 + vxdprintk(VXD_CBIT(xid, 5),
16866 + "moved task %p into vxi:%p[#%d]",
16867 + p, vxi, vxi->vx_id);
16869 + // vx_mask_cap_bset(vxi, p);
16872 + /* hack for *spaces to provide compatibility */
16874 + struct nsproxy *old_nsp, *new_nsp;
16876 + ret = unshare_nsproxy_namespaces(
16877 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16882 + old_nsp = xchg(&p->nsproxy, new_nsp);
16883 + vx_set_space(vxi,
16884 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16885 + put_nsproxy(old_nsp);
16889 + put_vx_info(old_vxi);
16893 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16895 + struct task_struct *old_reaper;
16900 + vxdprintk(VXD_CBIT(xid, 6),
16901 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16902 + vxi, vxi->vx_id, p, p->xid, p->pid);
16904 + old_reaper = vxi->vx_reaper;
16905 + if (old_reaper == p)
16908 + /* set new child reaper */
16909 + get_task_struct(p);
16910 + vxi->vx_reaper = p;
16911 + put_task_struct(old_reaper);
16915 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16920 + vxdprintk(VXD_CBIT(xid, 6),
16921 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16922 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16924 + vxi->vx_flags &= ~VXF_STATE_INIT;
16925 + // vxi->vx_initpid = p->tgid;
16926 + vxi->vx_initpid = p->pid;
16930 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16932 + vxdprintk(VXD_CBIT(xid, 6),
16933 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16934 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16936 + vxi->exit_code = code;
16937 + vxi->vx_initpid = 0;
16941 +void vx_set_persistent(struct vx_info *vxi)
16943 + vxdprintk(VXD_CBIT(xid, 6),
16944 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16946 + get_vx_info(vxi);
16947 + claim_vx_info(vxi, NULL);
16950 +void vx_clear_persistent(struct vx_info *vxi)
16952 + vxdprintk(VXD_CBIT(xid, 6),
16953 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16955 + release_vx_info(vxi, NULL);
16956 + put_vx_info(vxi);
16959 +void vx_update_persistent(struct vx_info *vxi)
16961 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16962 + vx_set_persistent(vxi);
16964 + vx_clear_persistent(vxi);
16968 +/* task must be current or locked */
16970 +void exit_vx_info(struct task_struct *p, int code)
16972 + struct vx_info *vxi = p->vx_info;
16975 + atomic_dec(&vxi->cvirt.nr_threads);
16978 + vxi->exit_code = code;
16979 + release_vx_info(vxi, p);
16983 +void exit_vx_info_early(struct task_struct *p, int code)
16985 + struct vx_info *vxi = p->vx_info;
16988 + if (vxi->vx_initpid == p->pid)
16989 + vx_exit_init(vxi, p, code);
16990 + if (vxi->vx_reaper == p)
16991 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16996 +/* vserver syscall commands below here */
16998 +/* taks xid and vx_info functions */
17000 +#include <asm/uaccess.h>
17003 +int vc_task_xid(uint32_t id)
17008 + struct task_struct *tsk;
17010 + read_lock(&tasklist_lock);
17011 + tsk = find_task_by_real_pid(id);
17012 + xid = (tsk) ? tsk->xid : -ESRCH;
17013 + read_unlock(&tasklist_lock);
17015 + xid = vx_current_xid();
17020 +int vc_vx_info(struct vx_info *vxi, void __user *data)
17022 + struct vcmd_vx_info_v0 vc_data;
17024 + vc_data.xid = vxi->vx_id;
17025 + vc_data.initpid = vxi->vx_initpid;
17027 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17033 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
17035 + struct vcmd_ctx_stat_v0 vc_data;
17037 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
17038 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
17040 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17046 +/* context functions */
17048 +int vc_ctx_create(uint32_t xid, void __user *data)
17050 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
17051 + struct vx_info *new_vxi;
17054 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17057 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
17060 + new_vxi = __create_vx_info(xid);
17061 + if (IS_ERR(new_vxi))
17062 + return PTR_ERR(new_vxi);
17064 + /* initial flags */
17065 + new_vxi->vx_flags = vc_data.flagword;
17068 + if (vs_state_change(new_vxi, VSC_STARTUP))
17071 + ret = vx_migrate_task(current, new_vxi, (!data));
17075 + /* return context id on success */
17076 + ret = new_vxi->vx_id;
17078 + /* get a reference for persistent contexts */
17079 + if ((vc_data.flagword & VXF_PERSISTENT))
17080 + vx_set_persistent(new_vxi);
17082 + release_vx_info(new_vxi, NULL);
17083 + put_vx_info(new_vxi);
17088 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
17090 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
17093 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17096 + ret = vx_migrate_task(current, vxi, 0);
17099 + if (vc_data.flagword & VXM_SET_INIT)
17100 + ret = vx_set_init(vxi, current);
17103 + if (vc_data.flagword & VXM_SET_REAPER)
17104 + ret = vx_set_reaper(vxi, current);
17109 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
17111 + struct vcmd_ctx_flags_v0 vc_data;
17113 + vc_data.flagword = vxi->vx_flags;
17115 + /* special STATE flag handling */
17116 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
17118 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17123 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
17125 + struct vcmd_ctx_flags_v0 vc_data;
17126 + uint64_t mask, trigger;
17128 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17131 + /* special STATE flag handling */
17132 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
17133 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
17135 + if (vxi == current_vx_info()) {
17136 + /* if (trigger & VXF_STATE_SETUP)
17137 + vx_mask_cap_bset(vxi, current); */
17138 + if (trigger & VXF_STATE_INIT) {
17141 + ret = vx_set_init(vxi, current);
17144 + ret = vx_set_reaper(vxi, current);
17150 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17151 + vc_data.flagword, mask);
17152 + if (trigger & VXF_PERSISTENT)
17153 + vx_update_persistent(vxi);
17159 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17161 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17163 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17167 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17169 + kernel_cap_t c = __cap_empty_set;
17171 + c.cap[0] = v & 0xFFFFFFFF;
17172 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17174 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17179 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17182 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17184 + *ccaps = vxi->vx_ccaps;
17189 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17191 + struct vcmd_ctx_caps_v1 vc_data;
17194 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17197 + vc_data.cmask = ~0ULL;
17199 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17204 +static int do_set_caps(struct vx_info *vxi,
17205 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
17207 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
17210 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
17211 + bcaps, bmask, ccaps, cmask);
17213 + vxi->vx_bcaps = cap_t_from_caps(
17214 + vs_mask_flags(bcold, bcaps, bmask));
17215 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
17220 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
17222 + struct vcmd_ctx_caps_v1 vc_data;
17224 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17227 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
17230 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
17232 + struct vcmd_bcaps vc_data;
17235 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
17238 + vc_data.bmask = ~0ULL;
17240 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17245 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
17247 + struct vcmd_bcaps vc_data;
17249 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17252 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
17256 +int vc_get_umask(struct vx_info *vxi, void __user *data)
17258 + struct vcmd_umask vc_data;
17260 + vc_data.umask = vxi->vx_umask;
17261 + vc_data.mask = ~0ULL;
17263 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17268 +int vc_set_umask(struct vx_info *vxi, void __user *data)
17270 + struct vcmd_umask vc_data;
17272 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17275 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
17276 + vc_data.umask, vc_data.mask);
17281 +int vc_get_badness(struct vx_info *vxi, void __user *data)
17283 + struct vcmd_badness_v0 vc_data;
17285 + vc_data.bias = vxi->vx_badness_bias;
17287 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17292 +int vc_set_badness(struct vx_info *vxi, void __user *data)
17294 + struct vcmd_badness_v0 vc_data;
17296 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17299 + vxi->vx_badness_bias = vc_data.bias;
17303 +#include <linux/module.h>
17305 +EXPORT_SYMBOL_GPL(free_vx_info);
17307 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/cvirt.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/cvirt.c
17308 --- linux-2.6.35.7/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
17309 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/cvirt.c 2010-08-02 17:05:06.000000000 +0200
17312 + * linux/kernel/vserver/cvirt.c
17314 + * Virtual Server: Context Virtualization
17316 + * Copyright (C) 2004-2007 Herbert Pötzl
17318 + * V0.01 broken out from limit.c
17319 + * V0.02 added utsname stuff
17320 + * V0.03 changed vcmds to vxi arg
17324 +#include <linux/types.h>
17325 +#include <linux/utsname.h>
17326 +#include <linux/vs_cvirt.h>
17327 +#include <linux/vserver/switch.h>
17328 +#include <linux/vserver/cvirt_cmd.h>
17330 +#include <asm/uaccess.h>
17333 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17335 + struct vx_info *vxi = current_vx_info();
17337 + set_normalized_timespec(uptime,
17338 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17339 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17342 + set_normalized_timespec(idle,
17343 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17344 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17348 +uint64_t vx_idle_jiffies(void)
17350 + return init_task.utime + init_task.stime;
17355 +static inline uint32_t __update_loadavg(uint32_t load,
17356 + int wsize, int delta, int n)
17358 + unsigned long long calc, prev;
17360 + /* just set it to n */
17361 + if (unlikely(delta >= wsize))
17362 + return (n << FSHIFT);
17364 + calc = delta * n;
17366 + prev = (wsize - delta);
17369 + do_div(calc, wsize);
17374 +void vx_update_load(struct vx_info *vxi)
17376 + uint32_t now, last, delta;
17377 + unsigned int nr_running, nr_uninterruptible;
17378 + unsigned int total;
17379 + unsigned long flags;
17381 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17384 + last = vxi->cvirt.load_last;
17385 + delta = now - last;
17387 + if (delta < 5*HZ)
17390 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17391 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17392 + total = nr_running + nr_uninterruptible;
17394 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17395 + 60*HZ, delta, total);
17396 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17397 + 5*60*HZ, delta, total);
17398 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17399 + 15*60*HZ, delta, total);
17401 + vxi->cvirt.load_last = now;
17403 + atomic_inc(&vxi->cvirt.load_updates);
17404 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17409 + * Commands to do_syslog:
17411 + * 0 -- Close the log. Currently a NOP.
17412 + * 1 -- Open the log. Currently a NOP.
17413 + * 2 -- Read from the log.
17414 + * 3 -- Read all messages remaining in the ring buffer.
17415 + * 4 -- Read and clear all messages remaining in the ring buffer
17416 + * 5 -- Clear ring buffer.
17417 + * 6 -- Disable printk's to console
17418 + * 7 -- Enable printk's to console
17419 + * 8 -- Set level of messages printed to console
17420 + * 9 -- Return number of unread characters in the log buffer
17421 + * 10 -- Return size of the log buffer
17423 +int vx_do_syslog(int type, char __user *buf, int len)
17426 + int do_clear = 0;
17427 + struct vx_info *vxi = current_vx_info();
17428 + struct _vx_syslog *log;
17432 + log = &vxi->cvirt.syslog;
17435 + case 0: /* Close log */
17436 + case 1: /* Open log */
17438 + case 2: /* Read from log */
17439 + error = wait_event_interruptible(log->log_wait,
17440 + (log->log_start - log->log_end));
17443 + spin_lock_irq(&log->logbuf_lock);
17444 + spin_unlock_irq(&log->logbuf_lock);
17446 + case 4: /* Read/clear last kernel messages */
17448 + /* fall through */
17449 + case 3: /* Read last kernel messages */
17452 + case 5: /* Clear ring buffer */
17455 + case 6: /* Disable logging to console */
17456 + case 7: /* Enable logging to console */
17457 + case 8: /* Set level of messages printed to console */
17460 + case 9: /* Number of chars in the log buffer */
17462 + case 10: /* Size of the log buffer */
17472 +/* virtual host info names */
17474 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17476 + struct nsproxy *nsproxy;
17477 + struct uts_namespace *uts;
17479 + if (id == VHIN_CONTEXT)
17480 + return vxi->vx_name;
17482 + nsproxy = vxi->vx_nsproxy[0];
17486 + uts = nsproxy->uts_ns;
17491 + case VHIN_SYSNAME:
17492 + return uts->name.sysname;
17493 + case VHIN_NODENAME:
17494 + return uts->name.nodename;
17495 + case VHIN_RELEASE:
17496 + return uts->name.release;
17497 + case VHIN_VERSION:
17498 + return uts->name.version;
17499 + case VHIN_MACHINE:
17500 + return uts->name.machine;
17501 + case VHIN_DOMAINNAME:
17502 + return uts->name.domainname;
17509 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17511 + struct vcmd_vhi_name_v0 vc_data;
17514 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17517 + name = vx_vhi_name(vxi, vc_data.field);
17521 + memcpy(name, vc_data.name, 65);
17525 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17527 + struct vcmd_vhi_name_v0 vc_data;
17530 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17533 + name = vx_vhi_name(vxi, vc_data.field);
17537 + memcpy(vc_data.name, name, 65);
17538 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17544 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17546 + struct vcmd_virt_stat_v0 vc_data;
17547 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17548 + struct timespec uptime;
17550 + do_posix_clock_monotonic_gettime(&uptime);
17551 + set_normalized_timespec(&uptime,
17552 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17553 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17555 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
17556 + vc_data.uptime = timespec_to_ns(&uptime);
17557 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17558 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17559 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17560 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17561 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17562 + vc_data.load[0] = cvirt->load[0];
17563 + vc_data.load[1] = cvirt->load[1];
17564 + vc_data.load[2] = cvirt->load[2];
17566 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17572 +#ifdef CONFIG_VSERVER_VTIME
17574 +/* virtualized time base */
17576 +void vx_gettimeofday(struct timeval *tv)
17578 + struct vx_info *vxi;
17580 + do_gettimeofday(tv);
17581 + if (!vx_flags(VXF_VIRT_TIME, 0))
17584 + vxi = current_vx_info();
17585 + tv->tv_sec += vxi->cvirt.bias_tv.tv_sec;
17586 + tv->tv_usec += vxi->cvirt.bias_tv.tv_usec;
17588 + if (tv->tv_usec >= USEC_PER_SEC) {
17590 + tv->tv_usec -= USEC_PER_SEC;
17591 + } else if (tv->tv_usec < 0) {
17593 + tv->tv_usec += USEC_PER_SEC;
17597 +int vx_settimeofday(struct timespec *ts)
17599 + struct timeval tv;
17600 + struct vx_info *vxi;
17602 + if (!vx_flags(VXF_VIRT_TIME, 0))
17603 + return do_settimeofday(ts);
17605 + do_gettimeofday(&tv);
17606 + vxi = current_vx_info();
17607 + vxi->cvirt.bias_tv.tv_sec = ts->tv_sec - tv.tv_sec;
17608 + vxi->cvirt.bias_tv.tv_usec =
17609 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
17615 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/cvirt_init.h linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/cvirt_init.h
17616 --- linux-2.6.35.7/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17617 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/cvirt_init.h 2010-08-02 17:05:06.000000000 +0200
17621 +extern uint64_t vx_idle_jiffies(void);
17623 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17625 + uint64_t idle_jiffies = vx_idle_jiffies();
17626 + uint64_t nsuptime;
17628 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17629 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17630 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17631 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17632 + cvirt->bias_tv.tv_sec = 0;
17633 + cvirt->bias_tv.tv_usec = 0;
17635 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17636 + atomic_set(&cvirt->nr_threads, 0);
17637 + atomic_set(&cvirt->nr_running, 0);
17638 + atomic_set(&cvirt->nr_uninterruptible, 0);
17639 + atomic_set(&cvirt->nr_onhold, 0);
17641 + spin_lock_init(&cvirt->load_lock);
17642 + cvirt->load_last = jiffies;
17643 + atomic_set(&cvirt->load_updates, 0);
17644 + cvirt->load[0] = 0;
17645 + cvirt->load[1] = 0;
17646 + cvirt->load[2] = 0;
17647 + atomic_set(&cvirt->total_forks, 0);
17649 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17650 + init_waitqueue_head(&cvirt->syslog.log_wait);
17651 + cvirt->syslog.log_start = 0;
17652 + cvirt->syslog.log_end = 0;
17653 + cvirt->syslog.con_start = 0;
17654 + cvirt->syslog.logged_chars = 0;
17658 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17660 + // cvirt_pc->cpustat = { 0 };
17663 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17667 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17668 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17670 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17671 + "!!! cvirt: %p[nr_running] = %d on exit.",
17673 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17674 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17676 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17677 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17683 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17688 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/cvirt_proc.h linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/cvirt_proc.h
17689 --- linux-2.6.35.7/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17690 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/cvirt_proc.h 2010-08-02 17:05:06.000000000 +0200
17692 +#ifndef _VX_CVIRT_PROC_H
17693 +#define _VX_CVIRT_PROC_H
17695 +#include <linux/nsproxy.h>
17696 +#include <linux/mnt_namespace.h>
17697 +#include <linux/ipc_namespace.h>
17698 +#include <linux/utsname.h>
17699 +#include <linux/ipc.h>
17703 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17705 + struct mnt_namespace *ns;
17706 + struct uts_namespace *uts;
17707 + struct ipc_namespace *ipc;
17708 + struct path path;
17709 + char *pstr, *root;
17715 + length += sprintf(buffer + length,
17716 + "NSProxy:\t%p [%p,%p,%p]\n",
17717 + nsproxy, nsproxy->mnt_ns,
17718 + nsproxy->uts_ns, nsproxy->ipc_ns);
17720 + ns = nsproxy->mnt_ns;
17724 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17728 + path.mnt = ns->root;
17729 + path.dentry = ns->root->mnt_root;
17730 + root = d_path(&path, pstr, PATH_MAX - 2);
17731 + length += sprintf(buffer + length,
17732 + "Namespace:\t%p [#%u]\n"
17733 + "RootPath:\t%s\n",
17734 + ns, atomic_read(&ns->count),
17739 + uts = nsproxy->uts_ns;
17743 + length += sprintf(buffer + length,
17744 + "SysName:\t%.*s\n"
17745 + "NodeName:\t%.*s\n"
17746 + "Release:\t%.*s\n"
17747 + "Version:\t%.*s\n"
17748 + "Machine:\t%.*s\n"
17749 + "DomainName:\t%.*s\n",
17750 + __NEW_UTS_LEN, uts->name.sysname,
17751 + __NEW_UTS_LEN, uts->name.nodename,
17752 + __NEW_UTS_LEN, uts->name.release,
17753 + __NEW_UTS_LEN, uts->name.version,
17754 + __NEW_UTS_LEN, uts->name.machine,
17755 + __NEW_UTS_LEN, uts->name.domainname);
17758 + ipc = nsproxy->ipc_ns;
17762 + length += sprintf(buffer + length,
17763 + "SEMS:\t\t%d %d %d %d %d\n"
17764 + "MSG:\t\t%d %d %d\n"
17765 + "SHM:\t\t%lu %lu %d %d\n",
17766 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17767 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17769 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17770 + (unsigned long)ipc->shm_ctlmax,
17771 + (unsigned long)ipc->shm_ctlall,
17772 + ipc->shm_ctlmni, ipc->shm_tot);
17779 +#include <linux/sched.h>
17781 +#define LOAD_INT(x) ((x) >> FSHIFT)
17782 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17785 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17790 + length += sprintf(buffer + length,
17791 + "BiasUptime:\t%lu.%02lu\n",
17792 + (unsigned long)cvirt->bias_uptime.tv_sec,
17793 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17795 + a = cvirt->load[0] + (FIXED_1 / 200);
17796 + b = cvirt->load[1] + (FIXED_1 / 200);
17797 + c = cvirt->load[2] + (FIXED_1 / 200);
17798 + length += sprintf(buffer + length,
17799 + "nr_threads:\t%d\n"
17800 + "nr_running:\t%d\n"
17801 + "nr_unintr:\t%d\n"
17802 + "nr_onhold:\t%d\n"
17803 + "load_updates:\t%d\n"
17804 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17805 + "total_forks:\t%d\n",
17806 + atomic_read(&cvirt->nr_threads),
17807 + atomic_read(&cvirt->nr_running),
17808 + atomic_read(&cvirt->nr_uninterruptible),
17809 + atomic_read(&cvirt->nr_onhold),
17810 + atomic_read(&cvirt->load_updates),
17811 + LOAD_INT(a), LOAD_FRAC(a),
17812 + LOAD_INT(b), LOAD_FRAC(b),
17813 + LOAD_INT(c), LOAD_FRAC(c),
17814 + atomic_read(&cvirt->total_forks));
17819 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17820 + char *buffer, int cpu)
17826 +#endif /* _VX_CVIRT_PROC_H */
17827 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/debug.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/debug.c
17828 --- linux-2.6.35.7/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17829 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/debug.c 2010-08-02 17:05:06.000000000 +0200
17832 + * kernel/vserver/debug.c
17834 + * Copyright (C) 2005-2007 Herbert Pötzl
17836 + * V0.01 vx_info dump support
17840 +#include <linux/module.h>
17842 +#include <linux/vserver/context.h>
17845 +void dump_vx_info(struct vx_info *vxi, int level)
17847 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17848 + atomic_read(&vxi->vx_usecnt),
17849 + atomic_read(&vxi->vx_tasks),
17852 + __dump_vx_limit(&vxi->limit);
17853 + __dump_vx_sched(&vxi->sched);
17854 + __dump_vx_cvirt(&vxi->cvirt);
17855 + __dump_vx_cacct(&vxi->cacct);
17861 +EXPORT_SYMBOL_GPL(dump_vx_info);
17863 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/device.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/device.c
17864 --- linux-2.6.35.7/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17865 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/device.c 2010-08-02 17:05:06.000000000 +0200
17868 + * linux/kernel/vserver/device.c
17870 + * Linux-VServer: Device Support
17872 + * Copyright (C) 2006 Herbert Pötzl
17873 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17875 + * V0.01 device mapping basics
17876 + * V0.02 added defaults
17880 +#include <linux/slab.h>
17881 +#include <linux/rcupdate.h>
17882 +#include <linux/fs.h>
17883 +#include <linux/namei.h>
17884 +#include <linux/hash.h>
17886 +#include <asm/errno.h>
17887 +#include <asm/uaccess.h>
17888 +#include <linux/vserver/base.h>
17889 +#include <linux/vserver/debug.h>
17890 +#include <linux/vserver/context.h>
17891 +#include <linux/vserver/device.h>
17892 +#include <linux/vserver/device_cmd.h>
17895 +#define DMAP_HASH_BITS 4
17898 +struct vs_mapping {
17900 + struct hlist_node hlist;
17901 + struct list_head list;
17903 +#define dm_hlist u.hlist
17904 +#define dm_list u.list
17907 + struct vx_dmap_target target;
17911 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17913 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
17915 +static struct vx_dmap_target dmap_defaults[2] = {
17916 + { .flags = DATTR_OPEN },
17917 + { .flags = DATTR_OPEN },
17921 +struct kmem_cache *dmap_cachep __read_mostly;
17923 +int __init dmap_cache_init(void)
17925 + dmap_cachep = kmem_cache_create("dmap_cache",
17926 + sizeof(struct vs_mapping), 0,
17927 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17931 +__initcall(dmap_cache_init);
17934 +static inline unsigned int __hashval(dev_t dev, int bits)
17936 + return hash_long((unsigned long)dev, bits);
17940 +/* __hash_mapping()
17941 + * add the mapping to the hash table
17943 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17945 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17946 + struct hlist_head *head, *hash = dmap_main_hash;
17947 + int device = vdm->device;
17949 + spin_lock(hash_lock);
17950 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17951 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17953 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17954 + hlist_add_head(&vdm->dm_hlist, head);
17955 + spin_unlock(hash_lock);
17959 +static inline int __mode_to_default(umode_t mode)
17972 +/* __set_default()
17975 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17976 + struct vx_dmap_target *vdmt)
17978 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17979 + spin_lock(hash_lock);
17982 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17984 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17987 + spin_unlock(hash_lock);
17989 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17990 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17994 +/* __remove_default()
17995 + * remove a default
17997 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17999 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18000 + spin_lock(hash_lock);
18003 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
18004 + else /* remove == reset */
18005 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
18007 + spin_unlock(hash_lock);
18012 +/* __find_mapping()
18013 + * find a mapping in the hash table
18015 + * caller must hold hash_lock
18017 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
18018 + struct vs_mapping **local, struct vs_mapping **global)
18020 + struct hlist_head *hash = dmap_main_hash;
18021 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
18022 + struct hlist_node *pos;
18023 + struct vs_mapping *vdm;
18029 + hlist_for_each(pos, head) {
18030 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
18032 + if ((vdm->device == device) &&
18033 + !((vdm->target.flags ^ mode) & S_IFMT)) {
18034 + if (vdm->xid == xid) {
18037 + } else if (global && vdm->xid == 0)
18042 + if (global && *global)
18049 +/* __lookup_mapping()
18050 + * find a mapping and store the result in target and flags
18052 +static inline int __lookup_mapping(struct vx_info *vxi,
18053 + dev_t device, dev_t *target, int *flags, umode_t mode)
18055 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18056 + struct vs_mapping *vdm, *global;
18057 + struct vx_dmap_target *vdmt;
18059 + xid_t xid = vxi->vx_id;
18062 + spin_lock(hash_lock);
18063 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
18065 + vdmt = &vdm->target;
18069 + index = __mode_to_default(mode);
18070 + if (vxi && vxi->dmap.targets[index].flags) {
18072 + vdmt = &vxi->dmap.targets[index];
18073 + } else if (global) {
18075 + vdmt = &global->target;
18079 + vdmt = &dmap_defaults[index];
18083 + if (target && (vdmt->flags & DATTR_REMAP))
18084 + *target = vdmt->target;
18086 + *target = device;
18088 + *flags = vdmt->flags;
18090 + spin_unlock(hash_lock);
18096 +/* __remove_mapping()
18097 + * remove a mapping from the hash table
18099 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
18102 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18103 + struct vs_mapping *vdm = NULL;
18106 + spin_lock(hash_lock);
18108 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
18110 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18111 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18114 + hlist_del(&vdm->dm_hlist);
18117 + spin_unlock(hash_lock);
18119 + kmem_cache_free(dmap_cachep, vdm);
18125 +int vs_map_device(struct vx_info *vxi,
18126 + dev_t device, dev_t *target, umode_t mode)
18128 + int ret, flags = DATTR_MASK;
18132 + *target = device;
18135 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18136 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18137 + device, target ? *target : 0, flags, mode, ret);
18139 + return (flags & DATTR_MASK);
18144 +static int do_set_mapping(struct vx_info *vxi,
18145 + dev_t device, dev_t target, int flags, umode_t mode)
18148 + struct vs_mapping *new;
18150 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18154 + INIT_HLIST_NODE(&new->dm_hlist);
18155 + new->device = device;
18156 + new->target.target = target;
18157 + new->target.flags = flags | mode;
18158 + new->xid = (vxi ? vxi->vx_id : 0);
18160 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18161 + __hash_mapping(vxi, new);
18163 + struct vx_dmap_target new = {
18164 + .target = target,
18165 + .flags = flags | mode,
18167 + __set_default(vxi, mode, &new);
18173 +static int do_unset_mapping(struct vx_info *vxi,
18174 + dev_t device, dev_t target, int flags, umode_t mode)
18176 + int ret = -EINVAL;
18179 + ret = __remove_mapping(vxi, device, mode);
18183 + ret = __remove_default(vxi, mode);
18193 +static inline int __user_device(const char __user *name, dev_t *dev,
18196 + struct nameidata nd;
18203 + ret = user_lpath(name, &nd.path);
18206 + if (nd.path.dentry->d_inode) {
18207 + *dev = nd.path.dentry->d_inode->i_rdev;
18208 + *mode = nd.path.dentry->d_inode->i_mode;
18210 + path_put(&nd.path);
18214 +static inline int __mapping_mode(dev_t device, dev_t target,
18215 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18218 + *mode = device_mode & S_IFMT;
18220 + *mode = target_mode & S_IFMT;
18224 + /* if both given, device and target mode have to match */
18225 + if (device && target &&
18226 + ((device_mode ^ target_mode) & S_IFMT))
18232 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18233 + const char __user *target_path, int flags, int set)
18235 + dev_t device = ~0, target = ~0;
18236 + umode_t device_mode = 0, target_mode = 0, mode;
18239 + ret = __user_device(device_path, &device, &device_mode);
18242 + ret = __user_device(target_path, &target, &target_mode);
18246 + ret = __mapping_mode(device, target,
18247 + device_mode, target_mode, &mode);
18252 + return do_set_mapping(vxi, device, target,
18255 + return do_unset_mapping(vxi, device, target,
18260 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
18262 + struct vcmd_set_mapping_v0 vc_data;
18264 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18267 + return do_mapping(vxi, vc_data.device, vc_data.target,
18268 + vc_data.flags, 1);
18271 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
18273 + struct vcmd_set_mapping_v0 vc_data;
18275 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18278 + return do_mapping(vxi, vc_data.device, vc_data.target,
18279 + vc_data.flags, 0);
18283 +#ifdef CONFIG_COMPAT
18285 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
18287 + struct vcmd_set_mapping_v0_x32 vc_data;
18289 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18292 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18293 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
18296 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18298 + struct vcmd_set_mapping_v0_x32 vc_data;
18300 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18303 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18304 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18307 +#endif /* CONFIG_COMPAT */
18310 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/dlimit.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/dlimit.c
18311 --- linux-2.6.35.7/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
18312 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/dlimit.c 2010-08-02 17:05:06.000000000 +0200
18315 + * linux/kernel/vserver/dlimit.c
18317 + * Virtual Server: Context Disk Limits
18319 + * Copyright (C) 2004-2009 Herbert Pötzl
18321 + * V0.01 initial version
18322 + * V0.02 compat32 splitup
18323 + * V0.03 extended interface
18327 +#include <linux/statfs.h>
18328 +#include <linux/sched.h>
18329 +#include <linux/namei.h>
18330 +#include <linux/vs_tag.h>
18331 +#include <linux/vs_dlimit.h>
18332 +#include <linux/vserver/dlimit_cmd.h>
18333 +#include <linux/slab.h>
18334 +// #include <linux/gfp.h>
18336 +#include <asm/uaccess.h>
18338 +/* __alloc_dl_info()
18340 + * allocate an initialized dl_info struct
18341 + * doesn't make it visible (hash) */
18343 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18345 + struct dl_info *new = NULL;
18347 + vxdprintk(VXD_CBIT(dlim, 5),
18348 + "alloc_dl_info(%p,%d)*", sb, tag);
18350 + /* would this benefit from a slab cache? */
18351 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18355 + memset(new, 0, sizeof(struct dl_info));
18356 + new->dl_tag = tag;
18358 + INIT_RCU_HEAD(&new->dl_rcu);
18359 + INIT_HLIST_NODE(&new->dl_hlist);
18360 + spin_lock_init(&new->dl_lock);
18361 + atomic_set(&new->dl_refcnt, 0);
18362 + atomic_set(&new->dl_usecnt, 0);
18364 + /* rest of init goes here */
18366 + vxdprintk(VXD_CBIT(dlim, 4),
18367 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18371 +/* __dealloc_dl_info()
18373 + * final disposal of dl_info */
18375 +static void __dealloc_dl_info(struct dl_info *dli)
18377 + vxdprintk(VXD_CBIT(dlim, 4),
18378 + "dealloc_dl_info(%p)", dli);
18380 + dli->dl_hlist.next = LIST_POISON1;
18381 + dli->dl_tag = -1;
18384 + BUG_ON(atomic_read(&dli->dl_usecnt));
18385 + BUG_ON(atomic_read(&dli->dl_refcnt));
18391 +/* hash table for dl_info hash */
18393 +#define DL_HASH_SIZE 13
18395 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18397 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
18400 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18402 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18407 +/* __hash_dl_info()
18409 + * add the dli to the global hash table
18410 + * requires the hash_lock to be held */
18412 +static inline void __hash_dl_info(struct dl_info *dli)
18414 + struct hlist_head *head;
18416 + vxdprintk(VXD_CBIT(dlim, 6),
18417 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18418 + get_dl_info(dli);
18419 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18420 + hlist_add_head_rcu(&dli->dl_hlist, head);
18423 +/* __unhash_dl_info()
18425 + * remove the dli from the global hash table
18426 + * requires the hash_lock to be held */
18428 +static inline void __unhash_dl_info(struct dl_info *dli)
18430 + vxdprintk(VXD_CBIT(dlim, 6),
18431 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18432 + hlist_del_rcu(&dli->dl_hlist);
18433 + put_dl_info(dli);
18437 +/* __lookup_dl_info()
18439 + * requires the rcu_read_lock()
18440 + * doesn't increment the dl_refcnt */
18442 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18444 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18445 + struct hlist_node *pos;
18446 + struct dl_info *dli;
18448 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18450 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18458 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18460 + struct dl_info *dli;
18463 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18464 + vxdprintk(VXD_CBIT(dlim, 7),
18465 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18466 + rcu_read_unlock();
18470 +void rcu_free_dl_info(struct rcu_head *head)
18472 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18473 + int usecnt, refcnt;
18475 + BUG_ON(!dli || !head);
18477 + usecnt = atomic_read(&dli->dl_usecnt);
18478 + BUG_ON(usecnt < 0);
18480 + refcnt = atomic_read(&dli->dl_refcnt);
18481 + BUG_ON(refcnt < 0);
18483 + vxdprintk(VXD_CBIT(dlim, 3),
18484 + "rcu_free_dl_info(%p)", dli);
18486 + __dealloc_dl_info(dli);
18488 + printk("!!! rcu didn't free\n");
18494 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18495 + uint32_t flags, int add)
18497 + struct path path;
18500 + ret = user_lpath(name, &path);
18502 + struct super_block *sb;
18503 + struct dl_info *dli;
18506 + if (!path.dentry->d_inode)
18507 + goto out_release;
18508 + if (!(sb = path.dentry->d_inode->i_sb))
18509 + goto out_release;
18512 + dli = __alloc_dl_info(sb, id);
18513 + spin_lock(&dl_info_hash_lock);
18516 + if (__lookup_dl_info(sb, id))
18518 + __hash_dl_info(dli);
18521 + spin_lock(&dl_info_hash_lock);
18522 + dli = __lookup_dl_info(sb, id);
18527 + __unhash_dl_info(dli);
18531 + spin_unlock(&dl_info_hash_lock);
18533 + __dealloc_dl_info(dli);
18540 +int vc_add_dlimit(uint32_t id, void __user *data)
18542 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18544 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18547 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18550 +int vc_rem_dlimit(uint32_t id, void __user *data)
18552 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18554 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18557 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18560 +#ifdef CONFIG_COMPAT
18562 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18564 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18566 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18569 + return do_addrem_dlimit(id,
18570 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18573 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18575 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18577 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18580 + return do_addrem_dlimit(id,
18581 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18584 +#endif /* CONFIG_COMPAT */
18588 +int do_set_dlimit(uint32_t id, const char __user *name,
18589 + uint32_t space_used, uint32_t space_total,
18590 + uint32_t inodes_used, uint32_t inodes_total,
18591 + uint32_t reserved, uint32_t flags)
18593 + struct path path;
18596 + ret = user_lpath(name, &path);
18598 + struct super_block *sb;
18599 + struct dl_info *dli;
18602 + if (!path.dentry->d_inode)
18603 + goto out_release;
18604 + if (!(sb = path.dentry->d_inode->i_sb))
18605 + goto out_release;
18607 + /* sanity checks */
18608 + if ((reserved != CDLIM_KEEP &&
18609 + reserved > 100) ||
18610 + (inodes_used != CDLIM_KEEP &&
18611 + inodes_used > inodes_total) ||
18612 + (space_used != CDLIM_KEEP &&
18613 + space_used > space_total))
18614 + goto out_release;
18617 + dli = locate_dl_info(sb, id);
18619 + goto out_release;
18621 + spin_lock(&dli->dl_lock);
18623 + if (inodes_used != CDLIM_KEEP)
18624 + dli->dl_inodes_used = inodes_used;
18625 + if (inodes_total != CDLIM_KEEP)
18626 + dli->dl_inodes_total = inodes_total;
18627 + if (space_used != CDLIM_KEEP)
18628 + dli->dl_space_used = dlimit_space_32to64(
18629 + space_used, flags, DLIMS_USED);
18631 + if (space_total == CDLIM_INFINITY)
18632 + dli->dl_space_total = DLIM_INFINITY;
18633 + else if (space_total != CDLIM_KEEP)
18634 + dli->dl_space_total = dlimit_space_32to64(
18635 + space_total, flags, DLIMS_TOTAL);
18637 + if (reserved != CDLIM_KEEP)
18638 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18640 + spin_unlock(&dli->dl_lock);
18642 + put_dl_info(dli);
18651 +int vc_set_dlimit(uint32_t id, void __user *data)
18653 + struct vcmd_ctx_dlimit_v0 vc_data;
18655 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18658 + return do_set_dlimit(id, vc_data.name,
18659 + vc_data.space_used, vc_data.space_total,
18660 + vc_data.inodes_used, vc_data.inodes_total,
18661 + vc_data.reserved, vc_data.flags);
18664 +#ifdef CONFIG_COMPAT
18666 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18668 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18670 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18673 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18674 + vc_data.space_used, vc_data.space_total,
18675 + vc_data.inodes_used, vc_data.inodes_total,
18676 + vc_data.reserved, vc_data.flags);
18679 +#endif /* CONFIG_COMPAT */
18683 +int do_get_dlimit(uint32_t id, const char __user *name,
18684 + uint32_t *space_used, uint32_t *space_total,
18685 + uint32_t *inodes_used, uint32_t *inodes_total,
18686 + uint32_t *reserved, uint32_t *flags)
18688 + struct path path;
18691 + ret = user_lpath(name, &path);
18693 + struct super_block *sb;
18694 + struct dl_info *dli;
18697 + if (!path.dentry->d_inode)
18698 + goto out_release;
18699 + if (!(sb = path.dentry->d_inode->i_sb))
18700 + goto out_release;
18703 + dli = locate_dl_info(sb, id);
18705 + goto out_release;
18707 + spin_lock(&dli->dl_lock);
18708 + *inodes_used = dli->dl_inodes_used;
18709 + *inodes_total = dli->dl_inodes_total;
18711 + *space_used = dlimit_space_64to32(
18712 + dli->dl_space_used, flags, DLIMS_USED);
18714 + if (dli->dl_space_total == DLIM_INFINITY)
18715 + *space_total = CDLIM_INFINITY;
18717 + *space_total = dlimit_space_64to32(
18718 + dli->dl_space_total, flags, DLIMS_TOTAL);
18720 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18721 + spin_unlock(&dli->dl_lock);
18723 + put_dl_info(dli);
18734 +int vc_get_dlimit(uint32_t id, void __user *data)
18736 + struct vcmd_ctx_dlimit_v0 vc_data;
18739 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18742 + ret = do_get_dlimit(id, vc_data.name,
18743 + &vc_data.space_used, &vc_data.space_total,
18744 + &vc_data.inodes_used, &vc_data.inodes_total,
18745 + &vc_data.reserved, &vc_data.flags);
18749 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18754 +#ifdef CONFIG_COMPAT
18756 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18758 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18761 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18764 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18765 + &vc_data.space_used, &vc_data.space_total,
18766 + &vc_data.inodes_used, &vc_data.inodes_total,
18767 + &vc_data.reserved, &vc_data.flags);
18771 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18776 +#endif /* CONFIG_COMPAT */
18779 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18781 + struct dl_info *dli;
18782 + __u64 blimit, bfree, bavail;
18785 + dli = locate_dl_info(sb, dx_current_tag());
18789 + spin_lock(&dli->dl_lock);
18790 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18793 + /* reduce max inodes available to limit */
18794 + if (buf->f_files > dli->dl_inodes_total)
18795 + buf->f_files = dli->dl_inodes_total;
18797 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18798 + /* reduce free inodes to min */
18799 + if (ifree < buf->f_ffree)
18800 + buf->f_ffree = ifree;
18803 + if (dli->dl_space_total == DLIM_INFINITY)
18806 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18808 + if (dli->dl_space_total < dli->dl_space_used)
18811 + bfree = (dli->dl_space_total - dli->dl_space_used)
18812 + >> sb->s_blocksize_bits;
18814 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18815 + if (bavail < dli->dl_space_used)
18818 + bavail = (bavail - dli->dl_space_used)
18819 + >> sb->s_blocksize_bits;
18821 + /* reduce max space available to limit */
18822 + if (buf->f_blocks > blimit)
18823 + buf->f_blocks = blimit;
18825 + /* reduce free space to min */
18826 + if (bfree < buf->f_bfree)
18827 + buf->f_bfree = bfree;
18829 + /* reduce avail space to min */
18830 + if (bavail < buf->f_bavail)
18831 + buf->f_bavail = bavail;
18834 + spin_unlock(&dli->dl_lock);
18835 + put_dl_info(dli);
18840 +#include <linux/module.h>
18842 +EXPORT_SYMBOL_GPL(locate_dl_info);
18843 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18845 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/helper.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/helper.c
18846 --- linux-2.6.35.7/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18847 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/helper.c 2010-08-02 17:05:06.000000000 +0200
18850 + * linux/kernel/vserver/helper.c
18852 + * Virtual Context Support
18854 + * Copyright (C) 2004-2007 Herbert Pötzl
18856 + * V0.01 basic helper
18860 +#include <linux/kmod.h>
18861 +#include <linux/reboot.h>
18862 +#include <linux/vs_context.h>
18863 +#include <linux/vs_network.h>
18864 +#include <linux/vserver/signal.h>
18867 +char vshelper_path[255] = "/sbin/vshelper";
18870 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18874 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
18875 + printk( KERN_WARNING
18876 + "%s: (%s %s) returned %s with %d\n",
18877 + name, argv[1], argv[2],
18878 + sync ? "sync" : "async", ret);
18880 + vxdprintk(VXD_CBIT(switch, 4),
18881 + "%s: (%s %s) returned %s with %d",
18882 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18887 + * vshelper path is set via /proc/sys
18888 + * invoked by vserver sys_reboot(), with
18889 + * the following arguments
18891 + * argv [0] = vshelper_path;
18892 + * argv [1] = action: "restart", "halt", "poweroff", ...
18893 + * argv [2] = context identifier
18895 + * envp [*] = type-specific parameters
18898 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18900 + char id_buf[8], cmd_buf[16];
18901 + char uid_buf[16], pid_buf[16];
18904 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18905 + char *envp[] = {"HOME=/", "TERM=linux",
18906 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18907 + uid_buf, pid_buf, cmd_buf, 0};
18909 + if (vx_info_state(vxi, VXS_HELPER))
18911 + vxi->vx_state |= VXS_HELPER;
18913 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18915 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18916 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
18917 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
18920 + case LINUX_REBOOT_CMD_RESTART:
18921 + argv[1] = "restart";
18924 + case LINUX_REBOOT_CMD_HALT:
18925 + argv[1] = "halt";
18928 + case LINUX_REBOOT_CMD_POWER_OFF:
18929 + argv[1] = "poweroff";
18932 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18933 + argv[1] = "swsusp";
18936 + case LINUX_REBOOT_CMD_OOM:
18941 + vxi->vx_state &= ~VXS_HELPER;
18945 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18946 + vxi->vx_state &= ~VXS_HELPER;
18947 + __wakeup_vx_info(vxi);
18948 + return (ret) ? -EPERM : 0;
18952 +long vs_reboot(unsigned int cmd, void __user *arg)
18954 + struct vx_info *vxi = current_vx_info();
18957 + vxdprintk(VXD_CBIT(misc, 5),
18958 + "vs_reboot(%p[#%d],%u)",
18959 + vxi, vxi ? vxi->vx_id : 0, cmd);
18961 + ret = vs_reboot_helper(vxi, cmd, arg);
18965 + vxi->reboot_cmd = cmd;
18966 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18968 + case LINUX_REBOOT_CMD_RESTART:
18969 + case LINUX_REBOOT_CMD_HALT:
18970 + case LINUX_REBOOT_CMD_POWER_OFF:
18971 + vx_info_kill(vxi, 0, SIGKILL);
18972 + vx_info_kill(vxi, 1, SIGKILL);
18980 +long vs_oom_action(unsigned int cmd)
18982 + struct vx_info *vxi = current_vx_info();
18985 + vxdprintk(VXD_CBIT(misc, 5),
18986 + "vs_oom_action(%p[#%d],%u)",
18987 + vxi, vxi ? vxi->vx_id : 0, cmd);
18989 + ret = vs_reboot_helper(vxi, cmd, NULL);
18993 + vxi->reboot_cmd = cmd;
18994 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18995 + vx_info_kill(vxi, 0, SIGKILL);
18996 + vx_info_kill(vxi, 1, SIGKILL);
19002 + * argv [0] = vshelper_path;
19003 + * argv [1] = action: "startup", "shutdown"
19004 + * argv [2] = context identifier
19006 + * envp [*] = type-specific parameters
19009 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
19011 + char id_buf[8], cmd_buf[16];
19012 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19013 + char *envp[] = {"HOME=/", "TERM=linux",
19014 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19016 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
19019 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19020 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19023 + case VSC_STARTUP:
19024 + argv[1] = "startup";
19026 + case VSC_SHUTDOWN:
19027 + argv[1] = "shutdown";
19033 + return do_vshelper(vshelper_path, argv, envp, 1);
19038 + * argv [0] = vshelper_path;
19039 + * argv [1] = action: "netup", "netdown"
19040 + * argv [2] = context identifier
19042 + * envp [*] = type-specific parameters
19045 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
19047 + char id_buf[8], cmd_buf[16];
19048 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19049 + char *envp[] = {"HOME=/", "TERM=linux",
19050 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19052 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
19055 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
19056 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19060 + argv[1] = "netup";
19062 + case VSC_NETDOWN:
19063 + argv[1] = "netdown";
19069 + return do_vshelper(vshelper_path, argv, envp, 1);
19072 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/history.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/history.c
19073 --- linux-2.6.35.7/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
19074 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/history.c 2010-08-02 17:05:06.000000000 +0200
19077 + * kernel/vserver/history.c
19079 + * Virtual Context History Backtrace
19081 + * Copyright (C) 2004-2007 Herbert Pötzl
19083 + * V0.01 basic structure
19084 + * V0.02 hash/unhash and trace
19085 + * V0.03 preemption fixes
19089 +#include <linux/module.h>
19090 +#include <asm/uaccess.h>
19092 +#include <linux/vserver/context.h>
19093 +#include <linux/vserver/debug.h>
19094 +#include <linux/vserver/debug_cmd.h>
19095 +#include <linux/vserver/history.h>
19098 +#ifdef CONFIG_VSERVER_HISTORY
19099 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
19101 +#define VXH_SIZE 64
19104 +struct _vx_history {
19105 + unsigned int counter;
19107 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19111 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19113 +unsigned volatile int vxh_active = 1;
19115 +static atomic_t sequence = ATOMIC_INIT(0);
19120 + * requires disabled preemption */
19122 +struct _vx_hist_entry *vxh_advance(void *loc)
19124 + unsigned int cpu = smp_processor_id();
19125 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19126 + struct _vx_hist_entry *entry;
19127 + unsigned int index;
19129 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19130 + entry = &hist->entry[index];
19132 + entry->seq = atomic_inc_return(&sequence);
19133 + entry->loc = loc;
19137 +EXPORT_SYMBOL_GPL(vxh_advance);
19140 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19142 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19145 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19147 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19148 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19149 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19150 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19152 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19154 + switch (e->type) {
19155 + case VXH_THROW_OOPS:
19156 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19159 + case VXH_GET_VX_INFO:
19160 + case VXH_PUT_VX_INFO:
19161 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19163 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19164 + VXH_VXI_ARGS(e));
19167 + case VXH_INIT_VX_INFO:
19168 + case VXH_SET_VX_INFO:
19169 + case VXH_CLR_VX_INFO:
19170 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19172 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19173 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19174 + VXH_VXI_ARGS(e), e->sc.data);
19177 + case VXH_CLAIM_VX_INFO:
19178 + case VXH_RELEASE_VX_INFO:
19179 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19181 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19182 + VXH_VXI_ARGS(e), e->sc.data);
19185 + case VXH_ALLOC_VX_INFO:
19186 + case VXH_DEALLOC_VX_INFO:
19187 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19189 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19190 + VXH_VXI_ARGS(e));
19193 + case VXH_HASH_VX_INFO:
19194 + case VXH_UNHASH_VX_INFO:
19195 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19197 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19198 + VXH_VXI_ARGS(e));
19201 + case VXH_LOC_VX_INFO:
19202 + case VXH_LOOKUP_VX_INFO:
19203 + case VXH_CREATE_VX_INFO:
19204 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19206 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19207 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19208 + e->ll.arg, VXH_VXI_ARGS(e));
19213 +static void __vxh_dump_history(void)
19215 + unsigned int i, cpu;
19217 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19218 + atomic_read(&sequence), NR_CPUS);
19220 + for (i = 0; i < VXH_SIZE; i++) {
19221 + for_each_online_cpu(cpu) {
19222 + struct _vx_history *hist =
19223 + &per_cpu(vx_history_buffer, cpu);
19224 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19225 + struct _vx_hist_entry *entry = &hist->entry[index];
19227 + vxh_dump_entry(entry, cpu);
19232 +void vxh_dump_history(void)
19236 + local_irq_enable();
19238 + local_irq_disable();
19240 + __vxh_dump_history();
19244 +/* vserver syscall commands below here */
19247 +int vc_dump_history(uint32_t id)
19250 + __vxh_dump_history();
19257 +int do_read_history(struct __user _vx_hist_entry *data,
19258 + int cpu, uint32_t *index, uint32_t *count)
19260 + int pos, ret = 0;
19261 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19262 + int end = hist->counter;
19263 + int start = end - VXH_SIZE + 2;
19264 + int idx = *index;
19266 + /* special case: get current pos */
19272 + /* have we lost some data? */
19276 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
19277 + struct _vx_hist_entry *entry =
19278 + &hist->entry[idx % VXH_SIZE];
19280 + /* send entry to userspace */
19281 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
19285 + /* save new index and count */
19288 + return ret ? ret : (*index < end);
19291 +int vc_read_history(uint32_t id, void __user *data)
19293 + struct vcmd_read_history_v0 vc_data;
19296 + if (id >= NR_CPUS)
19299 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19302 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19303 + id, &vc_data.index, &vc_data.count);
19305 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19310 +#ifdef CONFIG_COMPAT
19312 +int vc_read_history_x32(uint32_t id, void __user *data)
19314 + struct vcmd_read_history_v0_x32 vc_data;
19317 + if (id >= NR_CPUS)
19320 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19323 + ret = do_read_history((struct __user _vx_hist_entry *)
19324 + compat_ptr(vc_data.data_ptr),
19325 + id, &vc_data.index, &vc_data.count);
19327 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19332 +#endif /* CONFIG_COMPAT */
19334 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/inet.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/inet.c
19335 --- linux-2.6.35.7/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19336 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/inet.c 2010-08-02 18:54:03.000000000 +0200
19339 +#include <linux/in.h>
19340 +#include <linux/inetdevice.h>
19341 +#include <linux/vs_inet.h>
19342 +#include <linux/vs_inet6.h>
19343 +#include <linux/vserver/debug.h>
19344 +#include <net/route.h>
19345 +#include <net/addrconf.h>
19348 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19352 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19355 + struct nx_addr_v4 *ptr;
19357 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19358 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19365 + vxdprintk(VXD_CBIT(net, 2),
19366 + "nx_v4_addr_conflict(%p,%p): %d",
19367 + nxi1, nxi2, ret);
19373 +#ifdef CONFIG_IPV6
19375 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19379 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19382 + struct nx_addr_v6 *ptr;
19384 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19385 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19392 + vxdprintk(VXD_CBIT(net, 2),
19393 + "nx_v6_addr_conflict(%p,%p): %d",
19394 + nxi1, nxi2, ret);
19401 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19403 + struct in_device *in_dev;
19404 + struct in_ifaddr **ifap;
19405 + struct in_ifaddr *ifa;
19410 + in_dev = in_dev_get(dev);
19414 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19415 + ifap = &ifa->ifa_next) {
19416 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19421 + in_dev_put(in_dev);
19427 +#ifdef CONFIG_IPV6
19429 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19431 + struct inet6_dev *in_dev;
19432 + struct inet6_ifaddr *ifa;
19437 + in_dev = in6_dev_get(dev);
19441 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19442 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19443 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19448 + in6_dev_put(in_dev);
19455 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19461 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19463 +#ifdef CONFIG_IPV6
19465 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19470 + vxdprintk(VXD_CBIT(net, 3),
19471 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19472 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19476 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
19477 + struct rtable **rp, struct flowi *fl)
19482 + /* FIXME: handle lback only case */
19483 + if (!NX_IPV4(nxi))
19486 + vxdprintk(VXD_CBIT(net, 4),
19487 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19488 + nxi, nxi ? nxi->nx_id : 0,
19489 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
19491 + /* single IP is unconditional */
19492 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19493 + (fl->fl4_src == INADDR_ANY))
19494 + fl->fl4_src = nxi->v4.ip[0].s_addr;
19496 + if (fl->fl4_src == INADDR_ANY) {
19497 + struct nx_addr_v4 *ptr;
19498 + __be32 found = 0;
19501 + err = __ip_route_output_key(net, rp, fl);
19503 + found = (*rp)->rt_src;
19505 + vxdprintk(VXD_CBIT(net, 4),
19506 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19507 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
19508 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19512 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19513 + __be32 primary = ptr->ip[0].s_addr;
19514 + __be32 mask = ptr->mask.s_addr;
19515 + __be32 neta = primary & mask;
19517 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19518 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19519 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19520 + NIPQUAD(mask), NIPQUAD(neta));
19521 + if ((found & mask) != neta)
19524 + fl->fl4_src = primary;
19525 + err = __ip_route_output_key(net, rp, fl);
19526 + vxdprintk(VXD_CBIT(net, 4),
19527 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19528 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
19530 + found = (*rp)->rt_src;
19532 + if (found == primary)
19536 + /* still no source ip? */
19537 + found = ipv4_is_loopback(fl->fl4_dst)
19538 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19540 + /* assign src ip to flow */
19541 + fl->fl4_src = found;
19544 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
19548 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19549 + if (ipv4_is_loopback(fl->fl4_dst))
19550 + fl->fl4_dst = nxi->v4_lback.s_addr;
19551 + if (ipv4_is_loopback(fl->fl4_src))
19552 + fl->fl4_src = nxi->v4_lback.s_addr;
19553 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
19554 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19560 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19562 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/init.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/init.c
19563 --- linux-2.6.35.7/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19564 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/init.c 2010-08-02 17:05:06.000000000 +0200
19567 + * linux/kernel/init.c
19569 + * Virtual Server Init
19571 + * Copyright (C) 2004-2007 Herbert Pötzl
19573 + * V0.01 basic structure
19577 +#include <linux/init.h>
19579 +int vserver_register_sysctl(void);
19580 +void vserver_unregister_sysctl(void);
19583 +static int __init init_vserver(void)
19587 +#ifdef CONFIG_VSERVER_DEBUG
19588 + vserver_register_sysctl();
19594 +static void __exit exit_vserver(void)
19597 +#ifdef CONFIG_VSERVER_DEBUG
19598 + vserver_unregister_sysctl();
19603 +/* FIXME: GFP_ZONETYPES gone
19604 +long vx_slab[GFP_ZONETYPES]; */
19608 +module_init(init_vserver);
19609 +module_exit(exit_vserver);
19611 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/inode.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/inode.c
19612 --- linux-2.6.35.7/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19613 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/inode.c 2010-08-02 17:05:06.000000000 +0200
19616 + * linux/kernel/vserver/inode.c
19618 + * Virtual Server: File System Support
19620 + * Copyright (C) 2004-2007 Herbert Pötzl
19622 + * V0.01 separated from vcontext V0.05
19623 + * V0.02 moved to tag (instead of xid)
19627 +#include <linux/tty.h>
19628 +#include <linux/proc_fs.h>
19629 +#include <linux/devpts_fs.h>
19630 +#include <linux/fs.h>
19631 +#include <linux/file.h>
19632 +#include <linux/mount.h>
19633 +#include <linux/parser.h>
19634 +#include <linux/namei.h>
19635 +#include <linux/vserver/inode.h>
19636 +#include <linux/vserver/inode_cmd.h>
19637 +#include <linux/vs_base.h>
19638 +#include <linux/vs_tag.h>
19640 +#include <asm/uaccess.h>
19643 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19645 + struct proc_dir_entry *entry;
19647 + if (!in || !in->i_sb)
19650 + *flags = IATTR_TAG
19651 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19652 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19653 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19654 + | (IS_COW(in) ? IATTR_COW : 0);
19655 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19657 + if (S_ISDIR(in->i_mode))
19658 + *mask |= IATTR_BARRIER;
19660 + if (IS_TAGGED(in)) {
19661 + *tag = in->i_tag;
19662 + *mask |= IATTR_TAG;
19665 + switch (in->i_sb->s_magic) {
19666 + case PROC_SUPER_MAGIC:
19667 + entry = PROC_I(in)->pde;
19669 + /* check for specific inodes? */
19671 + *mask |= IATTR_FLAGS;
19673 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19675 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19678 + case DEVPTS_SUPER_MAGIC:
19679 + *tag = in->i_tag;
19680 + *mask |= IATTR_TAG;
19689 +int vc_get_iattr(void __user *data)
19691 + struct path path;
19692 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19695 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19698 + ret = user_lpath(vc_data.name, &path);
19700 + ret = __vc_get_iattr(path.dentry->d_inode,
19701 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19707 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19712 +#ifdef CONFIG_COMPAT
19714 +int vc_get_iattr_x32(void __user *data)
19716 + struct path path;
19717 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19720 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19723 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19725 + ret = __vc_get_iattr(path.dentry->d_inode,
19726 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19732 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19737 +#endif /* CONFIG_COMPAT */
19740 +int vc_fget_iattr(uint32_t fd, void __user *data)
19742 + struct file *filp;
19743 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19746 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19750 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19753 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19754 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19758 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19764 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19766 + struct inode *in = de->d_inode;
19767 + int error = 0, is_proc = 0, has_tag = 0;
19768 + struct iattr attr = { 0 };
19770 + if (!in || !in->i_sb)
19773 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19774 + if ((*mask & IATTR_FLAGS) && !is_proc)
19777 + has_tag = IS_TAGGED(in) ||
19778 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19779 + if ((*mask & IATTR_TAG) && !has_tag)
19782 + mutex_lock(&in->i_mutex);
19783 + if (*mask & IATTR_TAG) {
19784 + attr.ia_tag = *tag;
19785 + attr.ia_valid |= ATTR_TAG;
19788 + if (*mask & IATTR_FLAGS) {
19789 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19790 + unsigned int iflags = PROC_I(in)->vx_flags;
19792 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19793 + | (*flags & IATTR_FLAGS);
19794 + PROC_I(in)->vx_flags = iflags;
19796 + entry->vx_flags = iflags;
19799 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19800 + IATTR_BARRIER | IATTR_COW)) {
19801 + int iflags = in->i_flags;
19802 + int vflags = in->i_vflags;
19804 + if (*mask & IATTR_IMMUTABLE) {
19805 + if (*flags & IATTR_IMMUTABLE)
19806 + iflags |= S_IMMUTABLE;
19808 + iflags &= ~S_IMMUTABLE;
19810 + if (*mask & IATTR_IXUNLINK) {
19811 + if (*flags & IATTR_IXUNLINK)
19812 + iflags |= S_IXUNLINK;
19814 + iflags &= ~S_IXUNLINK;
19816 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19817 + if (*flags & IATTR_BARRIER)
19818 + vflags |= V_BARRIER;
19820 + vflags &= ~V_BARRIER;
19822 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19823 + if (*flags & IATTR_COW)
19826 + vflags &= ~V_COW;
19828 + if (in->i_op && in->i_op->sync_flags) {
19829 + error = in->i_op->sync_flags(in, iflags, vflags);
19835 + if (attr.ia_valid) {
19836 + if (in->i_op && in->i_op->setattr)
19837 + error = in->i_op->setattr(de, &attr);
19839 + error = inode_change_ok(in, &attr);
19841 + error = inode_setattr(in, &attr);
19846 + mutex_unlock(&in->i_mutex);
19850 +int vc_set_iattr(void __user *data)
19852 + struct path path;
19853 + struct vcmd_ctx_iattr_v1 vc_data;
19856 + if (!capable(CAP_LINUX_IMMUTABLE))
19858 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19861 + ret = user_lpath(vc_data.name, &path);
19863 + ret = __vc_set_iattr(path.dentry,
19864 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19868 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19873 +#ifdef CONFIG_COMPAT
19875 +int vc_set_iattr_x32(void __user *data)
19877 + struct path path;
19878 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19881 + if (!capable(CAP_LINUX_IMMUTABLE))
19883 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19886 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19888 + ret = __vc_set_iattr(path.dentry,
19889 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19893 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19898 +#endif /* CONFIG_COMPAT */
19900 +int vc_fset_iattr(uint32_t fd, void __user *data)
19902 + struct file *filp;
19903 + struct vcmd_ctx_fiattr_v0 vc_data;
19906 + if (!capable(CAP_LINUX_IMMUTABLE))
19908 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19912 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19915 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19916 + &vc_data.flags, &vc_data.mask);
19920 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19926 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19928 +static match_table_t tokens = {
19929 + {Opt_notagcheck, "notagcheck"},
19930 +#ifdef CONFIG_PROPAGATE
19931 + {Opt_notag, "notag"},
19932 + {Opt_tag, "tag"},
19933 + {Opt_tagid, "tagid=%u"},
19939 +static void __dx_parse_remove(char *string, char *opt)
19941 + char *p = strstr(string, opt);
19945 + while (*q != '\0' && *q != ',')
19954 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19955 + unsigned long *flags)
19958 + substring_t args[MAX_OPT_ARGS];
19959 + int token, option = 0;
19960 + char *s, *p, *opts;
19964 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19969 + while ((p = strsep(&opts, ",")) != NULL) {
19970 + token = match_token(p, tokens, args);
19972 + vxdprintk(VXD_CBIT(tag, 7),
19973 + "dx_parse_tag(»%s«): %d:#%d",
19974 + p, token, option);
19977 +#ifdef CONFIG_PROPAGATE
19982 + __dx_parse_remove(s, "tag");
19983 + *mnt_flags |= MNT_TAGID;
19984 + set |= MNT_TAGID;
19988 + __dx_parse_remove(s, "notag");
19989 + *mnt_flags |= MNT_NOTAG;
19990 + set |= MNT_NOTAG;
19993 + if (tag && !match_int(args, &option))
19996 + __dx_parse_remove(s, "tagid");
19997 + *mnt_flags |= MNT_TAGID;
19998 + set |= MNT_TAGID;
20001 + case Opt_notagcheck:
20003 + __dx_parse_remove(s, "notagcheck");
20004 + *flags |= MS_NOTAGCHECK;
20005 + set |= MS_NOTAGCHECK;
20010 + strcpy(string, s);
20015 +#ifdef CONFIG_PROPAGATE
20017 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
20019 + tag_t new_tag = 0;
20020 + struct vfsmount *mnt;
20025 + mnt = nd->path.mnt;
20029 + propagate = (mnt->mnt_flags & MNT_TAGID);
20031 + new_tag = mnt->mnt_tag;
20033 + vxdprintk(VXD_CBIT(tag, 7),
20034 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
20035 + inode, inode->i_ino, inode->i_tag,
20036 + new_tag, (propagate) ? 1 : 0);
20039 + inode->i_tag = new_tag;
20042 +#include <linux/module.h>
20044 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
20046 +#endif /* CONFIG_PROPAGATE */
20048 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/Kconfig linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/Kconfig
20049 --- linux-2.6.35.7/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
20050 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/Kconfig 2010-08-02 17:05:06.000000000 +0200
20053 +# Linux VServer configuration
20056 +menu "Linux VServer"
20058 +config VSERVER_AUTO_LBACK
20059 + bool "Automatically Assign Loopback IP"
20062 + Automatically assign a guest specific loopback
20063 + IP and add it to the kernel network stack on
20066 +config VSERVER_AUTO_SINGLE
20067 + bool "Automatic Single IP Special Casing"
20068 + depends on EXPERIMENTAL
20071 + This allows network contexts with a single IP to
20072 + automatically remap 0.0.0.0 bindings to that IP,
20073 + avoiding further network checks and improving
20076 + (note: such guests do not allow to change the ip
20077 + on the fly and do not show loopback addresses)
20079 +config VSERVER_COWBL
20080 + bool "Enable COW Immutable Link Breaking"
20083 + This enables the COW (Copy-On-Write) link break code.
20084 + It allows you to treat unified files like normal files
20085 + when writing to them (which will implicitely break the
20086 + link and create a copy of the unified file)
20088 +config VSERVER_VTIME
20089 + bool "Enable Virtualized Guest Time"
20090 + depends on EXPERIMENTAL
20093 + This enables per guest time offsets to allow for
20094 + adjusting the system clock individually per guest.
20095 + this adds some overhead to the time functions and
20096 + therefore should not be enabled without good reason.
20098 +config VSERVER_DEVICE
20099 + bool "Enable Guest Device Mapping"
20100 + depends on EXPERIMENTAL
20103 + This enables generic device remapping.
20105 +config VSERVER_PROC_SECURE
20106 + bool "Enable Proc Security"
20107 + depends on PROC_FS
20110 + This configures ProcFS security to initially hide
20111 + non-process entries for all contexts except the main and
20112 + spectator context (i.e. for all guests), which is a secure
20115 + (note: on 1.2x the entries were visible by default)
20117 +config VSERVER_HARDCPU
20118 + bool "Enable Hard CPU Limits"
20121 + Activate the Hard CPU Limits
20123 + This will compile in code that allows the Token Bucket
20124 + Scheduler to put processes on hold when a context's
20125 + tokens are depleted (provided that its per-context
20126 + sched_hard flag is set).
20128 + Processes belonging to that context will not be able
20129 + to consume CPU resources again until a per-context
20130 + configured minimum of tokens has been reached.
20132 +config VSERVER_IDLETIME
20133 + bool "Avoid idle CPUs by skipping Time"
20134 + depends on VSERVER_HARDCPU
20137 + This option allows the scheduler to artificially
20138 + advance time (per cpu) when otherwise the idle
20139 + task would be scheduled, thus keeping the cpu
20140 + busy and sharing the available resources among
20141 + certain contexts.
20143 +config VSERVER_IDLELIMIT
20144 + bool "Limit the IDLE task"
20145 + depends on VSERVER_HARDCPU
20148 + Limit the idle slices, so the the next context
20149 + will be scheduled as soon as possible.
20151 + This might improve interactivity and latency, but
20152 + will also marginally increase scheduling overhead.
20155 + prompt "Persistent Inode Tagging"
20156 + default TAGGING_ID24
20158 + This adds persistent context information to filesystems
20159 + mounted with the tagxid option. Tagging is a requirement
20160 + for per-context disk limits and per-context quota.
20163 +config TAGGING_NONE
20166 + do not store per-context information in inodes.
20168 +config TAGGING_UID16
20169 + bool "UID16/GID32"
20171 + reduces UID to 16 bit, but leaves GID at 32 bit.
20173 +config TAGGING_GID16
20174 + bool "UID32/GID16"
20176 + reduces GID to 16 bit, but leaves UID at 32 bit.
20178 +config TAGGING_ID24
20179 + bool "UID24/GID24"
20181 + uses the upper 8bit from UID and GID for XID tagging
20182 + which leaves 24bit for UID/GID each, which should be
20183 + more than sufficient for normal use.
20185 +config TAGGING_INTERN
20186 + bool "UID32/GID32"
20188 + this uses otherwise reserved inode fields in the on
20189 + disk representation, which limits the use to a few
20190 + filesystems (currently ext2 and ext3)
20195 + bool "Tag NFSD User Auth and Files"
20198 + Enable this if you do want the in-kernel NFS
20199 + Server to use the tagging specified above.
20200 + (will require patched clients too)
20202 +config VSERVER_PRIVACY
20203 + bool "Honor Privacy Aspects of Guests"
20206 + When enabled, most context checks will disallow
20207 + access to structures assigned to a specific context,
20208 + like ptys or loop devices.
20210 +config VSERVER_CONTEXTS
20211 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
20213 + default "768" if 64BIT
20216 + This setting will optimize certain data structures
20217 + and memory allocations according to the expected
20220 + note: this is not a strict upper limit.
20222 +config VSERVER_WARN
20223 + bool "VServer Warnings"
20226 + This enables various runtime warnings, which will
20227 + notify about potential manipulation attempts or
20228 + resource shortage. It is generally considered to
20229 + be a good idea to have that enabled.
20231 +config VSERVER_DEBUG
20232 + bool "VServer Debugging Code"
20235 + Set this to yes if you want to be able to activate
20236 + debugging output at runtime. It adds a very small
20237 + overhead to all vserver related functions and
20238 + increases the kernel size by about 20k.
20240 +config VSERVER_HISTORY
20241 + bool "VServer History Tracing"
20242 + depends on VSERVER_DEBUG
20245 + Set this to yes if you want to record the history of
20246 + linux-vserver activities, so they can be replayed in
20247 + the event of a kernel panic or oops.
20249 +config VSERVER_HISTORY_SIZE
20250 + int "Per-CPU History Size (32-65536)"
20251 + depends on VSERVER_HISTORY
20255 + This allows you to specify the number of entries in
20256 + the per-CPU history buffer.
20258 +config VSERVER_MONITOR
20259 + bool "VServer Scheduling Monitor"
20260 + depends on VSERVER_DISABLED
20263 + Set this to yes if you want to record the scheduling
20264 + decisions, so that they can be relayed to userspace
20265 + for detailed analysis.
20267 +config VSERVER_MONITOR_SIZE
20268 + int "Per-CPU Monitor Queue Size (32-65536)"
20269 + depends on VSERVER_MONITOR
20273 + This allows you to specify the number of entries in
20274 + the per-CPU scheduling monitor buffer.
20276 +config VSERVER_MONITOR_SYNC
20277 + int "Per-CPU Monitor Sync Interval (0-65536)"
20278 + depends on VSERVER_MONITOR
20282 + This allows you to specify the interval in ticks
20283 + when a time sync entry is inserted.
20285 +config VSERVER_LEGACY_MEM
20286 + bool "Legacy Memory Limits"
20289 + This provides fake memory limits to keep
20290 + older tools happy in the face of memory
20300 + select NAMESPACES
20306 +config VSERVER_SECURITY
20308 + depends on SECURITY
20310 + select SECURITY_CAPABILITIES
20312 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/limit.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/limit.c
20313 --- linux-2.6.35.7/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
20314 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/limit.c 2010-08-02 17:05:06.000000000 +0200
20317 + * linux/kernel/vserver/limit.c
20319 + * Virtual Server: Context Limits
20321 + * Copyright (C) 2004-2010 Herbert Pötzl
20323 + * V0.01 broken out from vcontext V0.05
20324 + * V0.02 changed vcmds to vxi arg
20325 + * V0.03 added memory cgroup support
20329 +#include <linux/sched.h>
20330 +#include <linux/module.h>
20331 +#include <linux/memcontrol.h>
20332 +#include <linux/res_counter.h>
20333 +#include <linux/vs_limit.h>
20334 +#include <linux/vserver/limit.h>
20335 +#include <linux/vserver/limit_cmd.h>
20337 +#include <asm/uaccess.h>
20340 +const char *vlimit_name[NUM_LIMITS] = {
20341 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20342 + [RLIMIT_RSS] = "RSS",
20343 + [RLIMIT_AS] = "VM",
20344 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20345 + [RLIMIT_CPU] = "CPU",
20346 + [RLIMIT_NPROC] = "NPROC",
20347 + [RLIMIT_NOFILE] = "NOFILE",
20348 + [RLIMIT_LOCKS] = "LOCKS",
20349 + [RLIMIT_SIGPENDING] = "SIGP",
20350 + [RLIMIT_MSGQUEUE] = "MSGQ",
20352 + [VLIMIT_NSOCK] = "NSOCK",
20353 + [VLIMIT_OPENFD] = "OPENFD",
20354 + [VLIMIT_SHMEM] = "SHMEM",
20355 + [VLIMIT_DENTRY] = "DENTRY",
20358 +EXPORT_SYMBOL_GPL(vlimit_name);
20360 +#define MASK_ENTRY(x) (1 << (x))
20362 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
20365 + , /* softlimit */
20366 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20367 + MASK_ENTRY( RLIMIT_RSS ) |
20368 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20371 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20372 + MASK_ENTRY( RLIMIT_RSS ) |
20373 + MASK_ENTRY( RLIMIT_AS ) |
20374 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20375 + MASK_ENTRY( RLIMIT_NPROC ) |
20376 + MASK_ENTRY( RLIMIT_NOFILE ) |
20377 + MASK_ENTRY( RLIMIT_LOCKS ) |
20378 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
20380 + MASK_ENTRY( VLIMIT_NSOCK ) |
20381 + MASK_ENTRY( VLIMIT_OPENFD ) |
20382 + MASK_ENTRY( VLIMIT_SHMEM ) |
20383 + MASK_ENTRY( VLIMIT_DENTRY ) |
20386 + /* accounting only */
20387 +uint32_t account_mask =
20388 + MASK_ENTRY( VLIMIT_SEMARY ) |
20389 + MASK_ENTRY( VLIMIT_NSEMS ) |
20390 + MASK_ENTRY( VLIMIT_MAPPED ) |
20394 +static int is_valid_vlimit(int id)
20396 + uint32_t mask = vlimit_mask.minimum |
20397 + vlimit_mask.softlimit | vlimit_mask.maximum;
20398 + return mask & (1 << id);
20401 +static int is_accounted_vlimit(int id)
20403 + if (is_valid_vlimit(id))
20405 + return account_mask & (1 << id);
20409 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
20411 + rlim_t limit = __rlim_soft(&vxi->limit, id);
20412 + return VX_VLIM(limit);
20415 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
20417 + rlim_t limit = __rlim_hard(&vxi->limit, id);
20418 + return VX_VLIM(limit);
20421 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
20422 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
20424 + if (!is_valid_vlimit(id))
20428 + *minimum = CRLIM_UNSET;
20430 + *softlimit = vc_get_soft(vxi, id);
20432 + *maximum = vc_get_hard(vxi, id);
20436 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
20438 + struct vcmd_ctx_rlimit_v0 vc_data;
20441 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20444 + ret = do_get_rlimit(vxi, vc_data.id,
20445 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20449 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20454 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
20455 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
20457 + if (!is_valid_vlimit(id))
20460 + if (maximum != CRLIM_KEEP)
20461 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
20462 + if (softlimit != CRLIM_KEEP)
20463 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
20465 + /* clamp soft limit */
20466 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
20467 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
20472 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
20474 + struct vcmd_ctx_rlimit_v0 vc_data;
20476 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20479 + return do_set_rlimit(vxi, vc_data.id,
20480 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20483 +#ifdef CONFIG_IA32_EMULATION
20485 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
20487 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20489 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20492 + return do_set_rlimit(vxi, vc_data.id,
20493 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20496 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
20498 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20501 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20504 + ret = do_get_rlimit(vxi, vc_data.id,
20505 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20509 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20514 +#endif /* CONFIG_IA32_EMULATION */
20517 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
20519 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
20525 +static inline void vx_reset_hits(struct _vx_limit *limit)
20529 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20530 + atomic_set(&__rlim_lhit(limit, lim), 0);
20534 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
20536 + vx_reset_hits(&vxi->limit);
20540 +static inline void vx_reset_minmax(struct _vx_limit *limit)
20545 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20546 + value = __rlim_get(limit, lim);
20547 + __rlim_rmax(limit, lim) = value;
20548 + __rlim_rmin(limit, lim) = value;
20552 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
20554 + vx_reset_minmax(&vxi->limit);
20559 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20561 + struct vcmd_rlimit_stat_v0 vc_data;
20562 + struct _vx_limit *limit = &vxi->limit;
20565 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20569 + if (!is_accounted_vlimit(id))
20572 + vx_limit_fixup(limit, id);
20573 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20574 + vc_data.value = __rlim_get(limit, id);
20575 + vc_data.minimum = __rlim_rmin(limit, id);
20576 + vc_data.maximum = __rlim_rmax(limit, id);
20578 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20584 +void vx_vsi_meminfo(struct sysinfo *val)
20586 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20587 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20588 + u64 res_limit, res_usage;
20593 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20594 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20596 + if (res_limit != RESOURCE_MAX)
20597 + val->totalram = (res_limit >> PAGE_SHIFT);
20598 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
20599 + val->bufferram = 0;
20600 + val->totalhigh = 0;
20601 + val->freehigh = 0;
20602 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20606 +void vx_vsi_swapinfo(struct sysinfo *val)
20608 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20609 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20610 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20611 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20612 + s64 swap_limit, swap_usage;
20617 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20618 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20619 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20620 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20622 + if (res_limit == RESOURCE_MAX)
20625 + swap_limit = memsw_limit - res_limit;
20626 + if (memsw_limit != RESOURCE_MAX)
20627 + val->totalswap = swap_limit >> PAGE_SHIFT;
20629 + swap_usage = memsw_usage - res_usage;
20630 + val->freeswap = (swap_usage < swap_limit) ?
20631 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20632 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20633 + val->totalswap = 0;
20634 + val->freeswap = 0;
20635 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20636 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20640 +long vx_vsi_cached(struct sysinfo *val)
20642 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20643 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20645 + return mem_cgroup_stat_read_cache(mcg);
20652 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
20654 + struct vx_info *vxi = mm->mm_vx_info;
20655 + unsigned long points;
20661 + points = vxi->vx_badness_bias;
20663 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20664 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20665 + points += (v > w) ? (v - w) : 0;
20670 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/limit_init.h linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/limit_init.h
20671 --- linux-2.6.35.7/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20672 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/limit_init.h 2010-08-02 17:05:06.000000000 +0200
20676 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20680 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20681 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20682 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20683 + __rlim_set(limit, lim, 0);
20684 + atomic_set(&__rlim_lhit(limit, lim), 0);
20685 + __rlim_rmin(limit, lim) = 0;
20686 + __rlim_rmax(limit, lim) = 0;
20690 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20695 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20696 + if ((1 << lim) & VLIM_NOCHECK)
20698 + value = __rlim_get(limit, lim);
20699 + vxwprintk_xid(value,
20700 + "!!! limit: %p[%s,%d] = %ld on exit.",
20701 + limit, vlimit_name[lim], lim, (long)value);
20705 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/limit_proc.h linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/limit_proc.h
20706 --- linux-2.6.35.7/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20707 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/limit_proc.h 2010-08-02 17:05:06.000000000 +0200
20709 +#ifndef _VX_LIMIT_PROC_H
20710 +#define _VX_LIMIT_PROC_H
20712 +#include <linux/vserver/limit_int.h>
20715 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20716 +#define VX_LIMIT_TOP \
20717 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20719 +#define VX_LIMIT_ARG(r) \
20720 + (unsigned long)__rlim_get(limit, r), \
20721 + (unsigned long)__rlim_rmin(limit, r), \
20722 + (unsigned long)__rlim_rmax(limit, r), \
20723 + VX_VLIM(__rlim_soft(limit, r)), \
20724 + VX_VLIM(__rlim_hard(limit, r)), \
20725 + atomic_read(&__rlim_lhit(limit, r))
20727 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20729 + vx_limit_fixup(limit, -1);
20730 + return sprintf(buffer, VX_LIMIT_TOP
20731 + "PROC" VX_LIMIT_FMT
20732 + "VM" VX_LIMIT_FMT
20733 + "VML" VX_LIMIT_FMT
20734 + "RSS" VX_LIMIT_FMT
20735 + "ANON" VX_LIMIT_FMT
20736 + "RMAP" VX_LIMIT_FMT
20737 + "FILES" VX_LIMIT_FMT
20738 + "OFD" VX_LIMIT_FMT
20739 + "LOCKS" VX_LIMIT_FMT
20740 + "SOCK" VX_LIMIT_FMT
20741 + "MSGQ" VX_LIMIT_FMT
20742 + "SHM" VX_LIMIT_FMT
20743 + "SEMA" VX_LIMIT_FMT
20744 + "SEMS" VX_LIMIT_FMT
20745 + "DENT" VX_LIMIT_FMT,
20746 + VX_LIMIT_ARG(RLIMIT_NPROC),
20747 + VX_LIMIT_ARG(RLIMIT_AS),
20748 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20749 + VX_LIMIT_ARG(RLIMIT_RSS),
20750 + VX_LIMIT_ARG(VLIMIT_ANON),
20751 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20752 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20753 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20754 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20755 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20756 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20757 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20758 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20759 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20760 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20763 +#endif /* _VX_LIMIT_PROC_H */
20766 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/Makefile linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/Makefile
20767 --- linux-2.6.35.7/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
20768 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/Makefile 2010-08-02 17:05:06.000000000 +0200
20771 +# Makefile for the Linux vserver routines.
20775 +obj-y += vserver.o
20777 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
20778 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
20781 +vserver-$(CONFIG_INET) += inet.o
20782 +vserver-$(CONFIG_PROC_FS) += proc.o
20783 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
20784 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
20785 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
20786 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
20788 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/monitor.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/monitor.c
20789 --- linux-2.6.35.7/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
20790 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/monitor.c 2010-08-02 17:05:06.000000000 +0200
20793 + * kernel/vserver/monitor.c
20795 + * Virtual Context Scheduler Monitor
20797 + * Copyright (C) 2006-2007 Herbert Pötzl
20799 + * V0.01 basic design
20803 +#include <linux/module.h>
20804 +#include <linux/jiffies.h>
20805 +#include <asm/uaccess.h>
20806 +#include <asm/atomic.h>
20808 +#include <linux/vserver/monitor.h>
20809 +#include <linux/vserver/debug_cmd.h>
20812 +#ifdef CONFIG_VSERVER_MONITOR
20813 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
20815 +#define VXM_SIZE 64
20818 +struct _vx_monitor {
20819 + unsigned int counter;
20821 + struct _vx_mon_entry entry[VXM_SIZE+1];
20825 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
20827 +unsigned volatile int vxm_active = 1;
20829 +static atomic_t sequence = ATOMIC_INIT(0);
20834 + * requires disabled preemption */
20836 +struct _vx_mon_entry *vxm_advance(int cpu)
20838 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
20839 + struct _vx_mon_entry *entry;
20840 + unsigned int index;
20842 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
20843 + entry = &mon->entry[index];
20845 + entry->ev.seq = atomic_inc_return(&sequence);
20846 + entry->ev.jif = jiffies;
20850 +EXPORT_SYMBOL_GPL(vxm_advance);
20853 +int do_read_monitor(struct __user _vx_mon_entry *data,
20854 + int cpu, uint32_t *index, uint32_t *count)
20856 + int pos, ret = 0;
20857 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
20858 + int end = mon->counter;
20859 + int start = end - VXM_SIZE + 2;
20860 + int idx = *index;
20862 + /* special case: get current pos */
20868 + /* have we lost some data? */
20872 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20873 + struct _vx_mon_entry *entry =
20874 + &mon->entry[idx % VXM_SIZE];
20876 + /* send entry to userspace */
20877 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20881 + /* save new index and count */
20884 + return ret ? ret : (*index < end);
20887 +int vc_read_monitor(uint32_t id, void __user *data)
20889 + struct vcmd_read_monitor_v0 vc_data;
20892 + if (id >= NR_CPUS)
20895 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20898 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
20899 + id, &vc_data.index, &vc_data.count);
20901 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20906 +#ifdef CONFIG_COMPAT
20908 +int vc_read_monitor_x32(uint32_t id, void __user *data)
20910 + struct vcmd_read_monitor_v0_x32 vc_data;
20913 + if (id >= NR_CPUS)
20916 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20919 + ret = do_read_monitor((struct __user _vx_mon_entry *)
20920 + compat_ptr(vc_data.data_ptr),
20921 + id, &vc_data.index, &vc_data.count);
20923 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20928 +#endif /* CONFIG_COMPAT */
20930 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/network.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/network.c
20931 --- linux-2.6.35.7/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20932 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/network.c 2010-08-02 17:05:06.000000000 +0200
20935 + * linux/kernel/vserver/network.c
20937 + * Virtual Server: Network Support
20939 + * Copyright (C) 2003-2007 Herbert Pötzl
20941 + * V0.01 broken out from vcontext V0.05
20942 + * V0.02 cleaned up implementation
20943 + * V0.03 added equiv nx commands
20944 + * V0.04 switch to RCU based hash
20945 + * V0.05 and back to locking again
20946 + * V0.06 changed vcmds to nxi arg
20947 + * V0.07 have __create claim() the nxi
20951 +#include <linux/err.h>
20952 +#include <linux/slab.h>
20953 +#include <linux/rcupdate.h>
20955 +#include <linux/vs_network.h>
20956 +#include <linux/vs_pid.h>
20957 +#include <linux/vserver/network_cmd.h>
20960 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20961 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20963 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20964 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20967 +static int __init init_network(void)
20969 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20970 + sizeof(struct nx_addr_v4), 0,
20971 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20972 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20973 + sizeof(struct nx_addr_v6), 0,
20974 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20979 +/* __alloc_nx_addr_v4() */
20981 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20983 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20984 + nx_addr_v4_cachep, GFP_KERNEL);
20986 + if (!IS_ERR(nxa))
20987 + memset(nxa, 0, sizeof(*nxa));
20991 +/* __dealloc_nx_addr_v4() */
20993 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20995 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20998 +/* __dealloc_nx_addr_v4_all() */
21000 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
21003 + struct nx_addr_v4 *next = nxa->next;
21005 + __dealloc_nx_addr_v4(nxa);
21011 +#ifdef CONFIG_IPV6
21013 +/* __alloc_nx_addr_v6() */
21015 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
21017 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
21018 + nx_addr_v6_cachep, GFP_KERNEL);
21020 + if (!IS_ERR(nxa))
21021 + memset(nxa, 0, sizeof(*nxa));
21025 +/* __dealloc_nx_addr_v6() */
21027 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
21029 + kmem_cache_free(nx_addr_v6_cachep, nxa);
21032 +/* __dealloc_nx_addr_v6_all() */
21034 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
21037 + struct nx_addr_v6 *next = nxa->next;
21039 + __dealloc_nx_addr_v6(nxa);
21044 +#endif /* CONFIG_IPV6 */
21046 +/* __alloc_nx_info()
21048 + * allocate an initialized nx_info struct
21049 + * doesn't make it visible (hash) */
21051 +static struct nx_info *__alloc_nx_info(nid_t nid)
21053 + struct nx_info *new = NULL;
21055 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
21057 + /* would this benefit from a slab cache? */
21058 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
21062 + memset(new, 0, sizeof(struct nx_info));
21063 + new->nx_id = nid;
21064 + INIT_HLIST_NODE(&new->nx_hlist);
21065 + atomic_set(&new->nx_usecnt, 0);
21066 + atomic_set(&new->nx_tasks, 0);
21067 + new->nx_state = 0;
21069 + new->nx_flags = NXF_INIT_SET;
21071 + /* rest of init goes here */
21073 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
21074 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
21076 + vxdprintk(VXD_CBIT(nid, 0),
21077 + "alloc_nx_info(%d) = %p", nid, new);
21078 + atomic_inc(&nx_global_ctotal);
21082 +/* __dealloc_nx_info()
21084 + * final disposal of nx_info */
21086 +static void __dealloc_nx_info(struct nx_info *nxi)
21088 + vxdprintk(VXD_CBIT(nid, 0),
21089 + "dealloc_nx_info(%p)", nxi);
21091 + nxi->nx_hlist.next = LIST_POISON1;
21094 + BUG_ON(atomic_read(&nxi->nx_usecnt));
21095 + BUG_ON(atomic_read(&nxi->nx_tasks));
21097 + __dealloc_nx_addr_v4_all(nxi->v4.next);
21099 + nxi->nx_state |= NXS_RELEASED;
21101 + atomic_dec(&nx_global_ctotal);
21104 +static void __shutdown_nx_info(struct nx_info *nxi)
21106 + nxi->nx_state |= NXS_SHUTDOWN;
21107 + vs_net_change(nxi, VSC_NETDOWN);
21110 +/* exported stuff */
21112 +void free_nx_info(struct nx_info *nxi)
21114 + /* context shutdown is mandatory */
21115 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
21117 + /* context must not be hashed */
21118 + BUG_ON(nxi->nx_state & NXS_HASHED);
21120 + BUG_ON(atomic_read(&nxi->nx_usecnt));
21121 + BUG_ON(atomic_read(&nxi->nx_tasks));
21123 + __dealloc_nx_info(nxi);
21127 +void __nx_set_lback(struct nx_info *nxi)
21129 + int nid = nxi->nx_id;
21130 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
21132 + nxi->v4_lback.s_addr = lback;
21135 +extern int __nx_inet_add_lback(__be32 addr);
21136 +extern int __nx_inet_del_lback(__be32 addr);
21139 +/* hash table for nx_info hash */
21141 +#define NX_HASH_SIZE 13
21143 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
21145 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
21148 +static inline unsigned int __hashval(nid_t nid)
21150 + return (nid % NX_HASH_SIZE);
21155 +/* __hash_nx_info()
21157 + * add the nxi to the global hash table
21158 + * requires the hash_lock to be held */
21160 +static inline void __hash_nx_info(struct nx_info *nxi)
21162 + struct hlist_head *head;
21164 + vxd_assert_lock(&nx_info_hash_lock);
21165 + vxdprintk(VXD_CBIT(nid, 4),
21166 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
21168 + /* context must not be hashed */
21169 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
21171 + nxi->nx_state |= NXS_HASHED;
21172 + head = &nx_info_hash[__hashval(nxi->nx_id)];
21173 + hlist_add_head(&nxi->nx_hlist, head);
21174 + atomic_inc(&nx_global_cactive);
21177 +/* __unhash_nx_info()
21179 + * remove the nxi from the global hash table
21180 + * requires the hash_lock to be held */
21182 +static inline void __unhash_nx_info(struct nx_info *nxi)
21184 + vxd_assert_lock(&nx_info_hash_lock);
21185 + vxdprintk(VXD_CBIT(nid, 4),
21186 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
21187 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
21189 + /* context must be hashed */
21190 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
21191 + /* but without tasks */
21192 + BUG_ON(atomic_read(&nxi->nx_tasks));
21194 + nxi->nx_state &= ~NXS_HASHED;
21195 + hlist_del(&nxi->nx_hlist);
21196 + atomic_dec(&nx_global_cactive);
21200 +/* __lookup_nx_info()
21202 + * requires the hash_lock to be held
21203 + * doesn't increment the nx_refcnt */
21205 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
21207 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
21208 + struct hlist_node *pos;
21209 + struct nx_info *nxi;
21211 + vxd_assert_lock(&nx_info_hash_lock);
21212 + hlist_for_each(pos, head) {
21213 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21215 + if (nxi->nx_id == nid)
21220 + vxdprintk(VXD_CBIT(nid, 0),
21221 + "__lookup_nx_info(#%u): %p[#%u]",
21222 + nid, nxi, nxi ? nxi->nx_id : 0);
21227 +/* __create_nx_info()
21229 + * create the requested context
21230 + * get(), claim() and hash it */
21232 +static struct nx_info *__create_nx_info(int id)
21234 + struct nx_info *new, *nxi = NULL;
21236 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
21238 + if (!(new = __alloc_nx_info(id)))
21239 + return ERR_PTR(-ENOMEM);
21241 + /* required to make dynamic xids unique */
21242 + spin_lock(&nx_info_hash_lock);
21244 + /* static context requested */
21245 + if ((nxi = __lookup_nx_info(id))) {
21246 + vxdprintk(VXD_CBIT(nid, 0),
21247 + "create_nx_info(%d) = %p (already there)", id, nxi);
21248 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21249 + nxi = ERR_PTR(-EBUSY);
21251 + nxi = ERR_PTR(-EEXIST);
21254 + /* new context */
21255 + vxdprintk(VXD_CBIT(nid, 0),
21256 + "create_nx_info(%d) = %p (new)", id, new);
21257 + claim_nx_info(new, NULL);
21258 + __nx_set_lback(new);
21259 + __hash_nx_info(get_nx_info(new));
21260 + nxi = new, new = NULL;
21263 + spin_unlock(&nx_info_hash_lock);
21265 + __dealloc_nx_info(new);
21271 +/* exported stuff */
21274 +void unhash_nx_info(struct nx_info *nxi)
21276 + __shutdown_nx_info(nxi);
21277 + spin_lock(&nx_info_hash_lock);
21278 + __unhash_nx_info(nxi);
21279 + spin_unlock(&nx_info_hash_lock);
21282 +/* lookup_nx_info()
21284 + * search for a nx_info and get() it
21285 + * negative id means current */
21287 +struct nx_info *lookup_nx_info(int id)
21289 + struct nx_info *nxi = NULL;
21292 + nxi = get_nx_info(current_nx_info());
21293 + } else if (id > 1) {
21294 + spin_lock(&nx_info_hash_lock);
21295 + nxi = get_nx_info(__lookup_nx_info(id));
21296 + spin_unlock(&nx_info_hash_lock);
21301 +/* nid_is_hashed()
21303 + * verify that nid is still hashed */
21305 +int nid_is_hashed(nid_t nid)
21309 + spin_lock(&nx_info_hash_lock);
21310 + hashed = (__lookup_nx_info(nid) != NULL);
21311 + spin_unlock(&nx_info_hash_lock);
21316 +#ifdef CONFIG_PROC_FS
21320 + * get a subset of hashed nids for proc
21321 + * assumes size is at least one */
21323 +int get_nid_list(int index, unsigned int *nids, int size)
21325 + int hindex, nr_nids = 0;
21327 + /* only show current and children */
21328 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
21331 + nids[nr_nids] = nx_current_nid();
21335 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
21336 + struct hlist_head *head = &nx_info_hash[hindex];
21337 + struct hlist_node *pos;
21339 + spin_lock(&nx_info_hash_lock);
21340 + hlist_for_each(pos, head) {
21341 + struct nx_info *nxi;
21346 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21347 + nids[nr_nids] = nxi->nx_id;
21348 + if (++nr_nids >= size) {
21349 + spin_unlock(&nx_info_hash_lock);
21353 + /* keep the lock time short */
21354 + spin_unlock(&nx_info_hash_lock);
21363 + * migrate task to new network
21364 + * gets nxi, puts old_nxi on change
21367 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
21369 + struct nx_info *old_nxi;
21375 + vxdprintk(VXD_CBIT(nid, 5),
21376 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
21377 + p, nxi, nxi->nx_id,
21378 + atomic_read(&nxi->nx_usecnt),
21379 + atomic_read(&nxi->nx_tasks));
21381 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
21382 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21385 + if (nx_info_state(nxi, NXS_SHUTDOWN))
21388 + /* maybe disallow this completely? */
21389 + old_nxi = task_get_nx_info(p);
21390 + if (old_nxi == nxi)
21395 + clr_nx_info(&p->nx_info);
21396 + claim_nx_info(nxi, p);
21397 + set_nx_info(&p->nx_info, nxi);
21398 + p->nid = nxi->nx_id;
21401 + vxdprintk(VXD_CBIT(nid, 5),
21402 + "moved task %p into nxi:%p[#%d]",
21403 + p, nxi, nxi->nx_id);
21406 + release_nx_info(old_nxi, p);
21409 + put_nx_info(old_nxi);
21414 +void nx_set_persistent(struct nx_info *nxi)
21416 + vxdprintk(VXD_CBIT(nid, 6),
21417 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
21419 + get_nx_info(nxi);
21420 + claim_nx_info(nxi, NULL);
21423 +void nx_clear_persistent(struct nx_info *nxi)
21425 + vxdprintk(VXD_CBIT(nid, 6),
21426 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
21428 + release_nx_info(nxi, NULL);
21429 + put_nx_info(nxi);
21432 +void nx_update_persistent(struct nx_info *nxi)
21434 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
21435 + nx_set_persistent(nxi);
21437 + nx_clear_persistent(nxi);
21440 +/* vserver syscall commands below here */
21442 +/* taks nid and nx_info functions */
21444 +#include <asm/uaccess.h>
21447 +int vc_task_nid(uint32_t id)
21452 + struct task_struct *tsk;
21454 + read_lock(&tasklist_lock);
21455 + tsk = find_task_by_real_pid(id);
21456 + nid = (tsk) ? tsk->nid : -ESRCH;
21457 + read_unlock(&tasklist_lock);
21459 + nid = nx_current_nid();
21464 +int vc_nx_info(struct nx_info *nxi, void __user *data)
21466 + struct vcmd_nx_info_v0 vc_data;
21468 + vc_data.nid = nxi->nx_id;
21470 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21476 +/* network functions */
21478 +int vc_net_create(uint32_t nid, void __user *data)
21480 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
21481 + struct nx_info *new_nxi;
21484 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21487 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
21490 + new_nxi = __create_nx_info(nid);
21491 + if (IS_ERR(new_nxi))
21492 + return PTR_ERR(new_nxi);
21494 + /* initial flags */
21495 + new_nxi->nx_flags = vc_data.flagword;
21498 + if (vs_net_change(new_nxi, VSC_NETUP))
21501 + ret = nx_migrate_task(current, new_nxi);
21505 + /* return context id on success */
21506 + ret = new_nxi->nx_id;
21508 + /* get a reference for persistent contexts */
21509 + if ((vc_data.flagword & NXF_PERSISTENT))
21510 + nx_set_persistent(new_nxi);
21512 + release_nx_info(new_nxi, NULL);
21513 + put_nx_info(new_nxi);
21518 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
21520 + return nx_migrate_task(current, nxi);
21525 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21526 + uint16_t type, uint16_t flags)
21528 + struct nx_addr_v4 *nxa = &nxi->v4;
21530 + if (NX_IPV4(nxi)) {
21531 + /* locate last entry */
21532 + for (; nxa->next; nxa = nxa->next);
21533 + nxa->next = __alloc_nx_addr_v4();
21537 + return PTR_ERR(nxa);
21540 + if (nxi->v4.next)
21541 + /* remove single ip for ip list */
21542 + nxi->nx_flags &= ~NXF_SINGLE_IP;
21544 + nxa->ip[0].s_addr = ip;
21545 + nxa->ip[1].s_addr = ip2;
21546 + nxa->mask.s_addr = mask;
21547 + nxa->type = type;
21548 + nxa->flags = flags;
21553 +int vc_net_add(struct nx_info *nxi, void __user *data)
21555 + struct vcmd_net_addr_v0 vc_data;
21556 + int index, ret = 0;
21558 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21561 + switch (vc_data.type) {
21562 + case NXA_TYPE_IPV4:
21563 + if ((vc_data.count < 1) || (vc_data.count > 4))
21567 + while (index < vc_data.count) {
21568 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
21569 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
21577 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
21578 + nxi->v4_bcast = vc_data.ip[0];
21582 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
21583 + nxi->v4_lback = vc_data.ip[0];
21594 +int vc_net_remove(struct nx_info *nxi, void __user *data)
21596 + struct vcmd_net_addr_v0 vc_data;
21598 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21601 + switch (vc_data.type) {
21602 + case NXA_TYPE_ANY:
21603 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21604 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21614 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
21616 + struct vcmd_net_addr_ipv4_v1 vc_data;
21618 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21621 + switch (vc_data.type) {
21622 + case NXA_TYPE_ADDR:
21623 + case NXA_TYPE_RANGE:
21624 + case NXA_TYPE_MASK:
21625 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
21626 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21628 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21629 + nxi->v4_bcast = vc_data.ip;
21632 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21633 + nxi->v4_lback = vc_data.ip;
21642 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
21644 + struct vcmd_net_addr_ipv4_v1 vc_data;
21646 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21649 + switch (vc_data.type) {
21650 +/* case NXA_TYPE_ADDR:
21653 + case NXA_TYPE_ANY:
21654 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21655 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21665 +#ifdef CONFIG_IPV6
21667 +int do_add_v6_addr(struct nx_info *nxi,
21668 + struct in6_addr *ip, struct in6_addr *mask,
21669 + uint32_t prefix, uint16_t type, uint16_t flags)
21671 + struct nx_addr_v6 *nxa = &nxi->v6;
21673 + if (NX_IPV6(nxi)) {
21674 + /* locate last entry */
21675 + for (; nxa->next; nxa = nxa->next);
21676 + nxa->next = __alloc_nx_addr_v6();
21680 + return PTR_ERR(nxa);
21684 + nxa->mask = *mask;
21685 + nxa->prefix = prefix;
21686 + nxa->type = type;
21687 + nxa->flags = flags;
21692 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21694 + struct vcmd_net_addr_ipv6_v1 vc_data;
21696 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21699 + switch (vc_data.type) {
21700 + case NXA_TYPE_ADDR:
21701 + case NXA_TYPE_MASK:
21702 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21703 + vc_data.prefix, vc_data.type, vc_data.flags);
21710 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21712 + struct vcmd_net_addr_ipv6_v1 vc_data;
21714 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21717 + switch (vc_data.type) {
21718 + case NXA_TYPE_ANY:
21719 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21720 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21729 +#endif /* CONFIG_IPV6 */
21732 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21734 + struct vcmd_net_flags_v0 vc_data;
21736 + vc_data.flagword = nxi->nx_flags;
21738 + /* special STATE flag handling */
21739 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21741 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21746 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21748 + struct vcmd_net_flags_v0 vc_data;
21749 + uint64_t mask, trigger;
21751 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21754 + /* special STATE flag handling */
21755 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21756 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21758 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21759 + vc_data.flagword, mask);
21760 + if (trigger & NXF_PERSISTENT)
21761 + nx_update_persistent(nxi);
21766 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21768 + struct vcmd_net_caps_v0 vc_data;
21770 + vc_data.ncaps = nxi->nx_ncaps;
21771 + vc_data.cmask = ~0ULL;
21773 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21778 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21780 + struct vcmd_net_caps_v0 vc_data;
21782 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21785 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21786 + vc_data.ncaps, vc_data.cmask);
21791 +#include <linux/module.h>
21793 +module_init(init_network);
21795 +EXPORT_SYMBOL_GPL(free_nx_info);
21796 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21798 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/proc.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/proc.c
21799 --- linux-2.6.35.7/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21800 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/proc.c 2010-08-02 17:05:06.000000000 +0200
21803 + * linux/kernel/vserver/proc.c
21805 + * Virtual Context Support
21807 + * Copyright (C) 2003-2007 Herbert Pötzl
21809 + * V0.01 basic structure
21810 + * V0.02 adaptation vs1.3.0
21811 + * V0.03 proc permissions
21812 + * V0.04 locking/generic
21813 + * V0.05 next generation procfs
21814 + * V0.06 inode validation
21815 + * V0.07 generic rewrite vid
21816 + * V0.08 remove inode type
21820 +#include <linux/proc_fs.h>
21821 +#include <linux/fs_struct.h>
21822 +#include <linux/mount.h>
21823 +#include <asm/unistd.h>
21825 +#include <linux/vs_context.h>
21826 +#include <linux/vs_network.h>
21827 +#include <linux/vs_cvirt.h>
21829 +#include <linux/in.h>
21830 +#include <linux/inetdevice.h>
21831 +#include <linux/vs_inet.h>
21832 +#include <linux/vs_inet6.h>
21834 +#include <linux/vserver/global.h>
21836 +#include "cvirt_proc.h"
21837 +#include "cacct_proc.h"
21838 +#include "limit_proc.h"
21839 +#include "sched_proc.h"
21840 +#include "vci_config.h"
21843 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21847 + CAP_FOR_EACH_U32(__capi) {
21848 + buffer += sprintf(buffer, "%08x",
21849 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21855 +static struct proc_dir_entry *proc_virtual;
21857 +static struct proc_dir_entry *proc_virtnet;
21860 +/* first the actual feeds */
21863 +static int proc_vci(char *buffer)
21865 + return sprintf(buffer,
21866 + "VCIVersion:\t%04x:%04x\n"
21867 + "VCISyscall:\t%d\n"
21868 + "VCIKernel:\t%08x\n",
21869 + VCI_VERSION >> 16,
21870 + VCI_VERSION & 0xFFFF,
21872 + vci_kernel_config());
21875 +static int proc_virtual_info(char *buffer)
21877 + return proc_vci(buffer);
21880 +static int proc_virtual_status(char *buffer)
21882 + return sprintf(buffer,
21884 + "#CActive:\t%d\n"
21885 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21886 + "#InitTask:\t%d\t%d %d\n",
21887 + atomic_read(&vx_global_ctotal),
21888 + atomic_read(&vx_global_cactive),
21889 + atomic_read(&vs_global_nsproxy),
21890 + atomic_read(&vs_global_fs),
21891 + atomic_read(&vs_global_mnt_ns),
21892 + atomic_read(&vs_global_uts_ns),
21893 + atomic_read(&nr_ipc_ns),
21894 + atomic_read(&vs_global_user_ns),
21895 + atomic_read(&vs_global_pid_ns),
21896 + atomic_read(&init_task.usage),
21897 + atomic_read(&init_task.nsproxy->count),
21898 + init_task.fs->users);
21902 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21906 + length = sprintf(buffer,
21914 + vxi->vx_badness_bias);
21918 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21920 + char *orig = buffer;
21922 + buffer += sprintf(buffer,
21925 + "Flags:\t%016llx\n",
21926 + atomic_read(&vxi->vx_usecnt),
21927 + atomic_read(&vxi->vx_tasks),
21928 + (unsigned long long)vxi->vx_flags);
21930 + buffer += sprintf(buffer, "BCaps:\t");
21931 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21932 + buffer += sprintf(buffer, "\n");
21934 + buffer += sprintf(buffer,
21935 + "CCaps:\t%016llx\n"
21936 + "Spaces:\t%08lx %08lx\n",
21937 + (unsigned long long)vxi->vx_ccaps,
21938 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
21939 + return buffer - orig;
21942 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21944 + return vx_info_proc_limit(&vxi->limit, buffer);
21947 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21951 + length = vx_info_proc_sched(&vxi->sched, buffer);
21952 + for_each_online_cpu(cpu) {
21953 + length += vx_info_proc_sched_pc(
21954 + &vx_per_cpu(vxi, sched_pc, cpu),
21955 + buffer + length, cpu);
21960 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21962 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
21965 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21967 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
21970 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21974 + vx_update_load(vxi);
21975 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21976 + for_each_online_cpu(cpu) {
21977 + length += vx_info_proc_cvirt_pc(
21978 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21979 + buffer + length, cpu);
21984 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21986 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21990 +static int proc_virtnet_info(char *buffer)
21992 + return proc_vci(buffer);
21995 +static int proc_virtnet_status(char *buffer)
21997 + return sprintf(buffer,
21999 + "#CActive:\t%d\n",
22000 + atomic_read(&nx_global_ctotal),
22001 + atomic_read(&nx_global_cactive));
22004 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
22006 + struct nx_addr_v4 *v4a;
22007 +#ifdef CONFIG_IPV6
22008 + struct nx_addr_v6 *v6a;
22012 + length = sprintf(buffer,
22015 + "Bcast:\t" NIPQUAD_FMT "\n"
22016 + "Lback:\t" NIPQUAD_FMT "\n",
22019 + NIPQUAD(nxi->v4_bcast.s_addr),
22020 + NIPQUAD(nxi->v4_lback.s_addr));
22022 + if (!NX_IPV4(nxi))
22024 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22025 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
22028 +#ifdef CONFIG_IPV6
22029 + if (!NX_IPV6(nxi))
22031 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22032 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
22039 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
22043 + length = sprintf(buffer,
22046 + "Flags:\t%016llx\n"
22047 + "NCaps:\t%016llx\n",
22048 + atomic_read(&nxi->nx_usecnt),
22049 + atomic_read(&nxi->nx_tasks),
22050 + (unsigned long long)nxi->nx_flags,
22051 + (unsigned long long)nxi->nx_ncaps);
22057 +/* here the inode helpers */
22063 + struct inode_operations *iop;
22064 + struct file_operations *fop;
22065 + union proc_op op;
22068 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
22070 + struct inode *inode = new_inode(sb);
22075 + inode->i_mode = p->mode;
22077 + inode->i_op = p->iop;
22079 + inode->i_fop = p->fop;
22081 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
22082 + inode->i_flags |= S_IMMUTABLE;
22084 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
22086 + inode->i_uid = 0;
22087 + inode->i_gid = 0;
22088 + inode->i_tag = 0;
22093 +static struct dentry *vs_proc_instantiate(struct inode *dir,
22094 + struct dentry *dentry, int id, void *ptr)
22096 + struct vs_entry *p = ptr;
22097 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
22098 + struct dentry *error = ERR_PTR(-EINVAL);
22103 + PROC_I(inode)->op = p->op;
22104 + PROC_I(inode)->fd = id;
22105 + d_add(dentry, inode);
22113 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
22116 + * Fill a directory entry.
22118 + * If possible create the dcache entry and derive our inode number and
22119 + * file type from dcache entry.
22121 + * Since all of the proc inode numbers are dynamically generated, the inode
22122 + * numbers do not exist until the inode is cache. This means creating the
22123 + * the dcache entry in readdir is necessary to keep the inode numbers
22124 + * reported by readdir in sync with the inode numbers reported
22127 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
22128 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
22130 + struct dentry *child, *dir = filp->f_dentry;
22131 + struct inode *inode;
22132 + struct qstr qname;
22134 + unsigned type = DT_UNKNOWN;
22136 + qname.name = name;
22138 + qname.hash = full_name_hash(name, len);
22140 + child = d_lookup(dir, &qname);
22142 + struct dentry *new;
22143 + new = d_alloc(dir, &qname);
22145 + child = instantiate(dir->d_inode, new, id, ptr);
22152 + if (!child || IS_ERR(child) || !child->d_inode)
22153 + goto end_instantiate;
22154 + inode = child->d_inode;
22156 + ino = inode->i_ino;
22157 + type = inode->i_mode >> 12;
22162 + ino = find_inode_number(dir, &qname);
22165 + return filldir(dirent, name, len, filp->f_pos, ino, type);
22170 +/* get and revalidate vx_info/xid */
22173 +struct vx_info *get_proc_vx_info(struct inode *inode)
22175 + return lookup_vx_info(PROC_I(inode)->fd);
22178 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
22180 + struct inode *inode = dentry->d_inode;
22181 + xid_t xid = PROC_I(inode)->fd;
22183 + if (!xid || xid_is_hashed(xid))
22190 +/* get and revalidate nx_info/nid */
22192 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
22194 + struct inode *inode = dentry->d_inode;
22195 + nid_t nid = PROC_I(inode)->fd;
22197 + if (!nid || nid_is_hashed(nid))
22205 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
22207 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
22208 + size_t count, loff_t *ppos)
22210 + struct inode *inode = file->f_dentry->d_inode;
22211 + unsigned long page;
22212 + ssize_t length = 0;
22214 + if (count > PROC_BLOCK_SIZE)
22215 + count = PROC_BLOCK_SIZE;
22217 + /* fade that out as soon as stable */
22218 + WARN_ON(PROC_I(inode)->fd);
22220 + if (!(page = __get_free_page(GFP_KERNEL)))
22223 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
22224 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
22227 + length = simple_read_from_buffer(buf, count, ppos,
22228 + (char *)page, length);
22234 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
22235 + size_t count, loff_t *ppos)
22237 + struct inode *inode = file->f_dentry->d_inode;
22238 + struct vx_info *vxi = NULL;
22239 + xid_t xid = PROC_I(inode)->fd;
22240 + unsigned long page;
22241 + ssize_t length = 0;
22243 + if (count > PROC_BLOCK_SIZE)
22244 + count = PROC_BLOCK_SIZE;
22246 + /* fade that out as soon as stable */
22248 + vxi = lookup_vx_info(xid);
22252 + length = -ENOMEM;
22253 + if (!(page = __get_free_page(GFP_KERNEL)))
22256 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
22257 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
22260 + length = simple_read_from_buffer(buf, count, ppos,
22261 + (char *)page, length);
22265 + put_vx_info(vxi);
22270 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
22271 + size_t count, loff_t *ppos)
22273 + struct inode *inode = file->f_dentry->d_inode;
22274 + struct nx_info *nxi = NULL;
22275 + nid_t nid = PROC_I(inode)->fd;
22276 + unsigned long page;
22277 + ssize_t length = 0;
22279 + if (count > PROC_BLOCK_SIZE)
22280 + count = PROC_BLOCK_SIZE;
22282 + /* fade that out as soon as stable */
22284 + nxi = lookup_nx_info(nid);
22288 + length = -ENOMEM;
22289 + if (!(page = __get_free_page(GFP_KERNEL)))
22292 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
22293 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
22296 + length = simple_read_from_buffer(buf, count, ppos,
22297 + (char *)page, length);
22301 + put_nx_info(nxi);
22308 +/* here comes the lower level */
22311 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
22312 + .len = sizeof(NAME) - 1, \
22313 + .name = (NAME), \
22321 +#define DIR(NAME, MODE, OTYPE) \
22322 + NOD(NAME, (S_IFDIR | (MODE)), \
22323 + &proc_ ## OTYPE ## _inode_operations, \
22324 + &proc_ ## OTYPE ## _file_operations, { } )
22326 +#define INF(NAME, MODE, OTYPE) \
22327 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22328 + &proc_vs_info_file_operations, \
22329 + { .proc_vs_read = &proc_##OTYPE } )
22331 +#define VINF(NAME, MODE, OTYPE) \
22332 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22333 + &proc_vx_info_file_operations, \
22334 + { .proc_vxi_read = &proc_##OTYPE } )
22336 +#define NINF(NAME, MODE, OTYPE) \
22337 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22338 + &proc_nx_info_file_operations, \
22339 + { .proc_nxi_read = &proc_##OTYPE } )
22342 +static struct file_operations proc_vs_info_file_operations = {
22343 + .read = proc_vs_info_read,
22346 +static struct file_operations proc_vx_info_file_operations = {
22347 + .read = proc_vx_info_read,
22350 +static struct dentry_operations proc_xid_dentry_operations = {
22351 + .d_revalidate = proc_xid_revalidate,
22354 +static struct vs_entry vx_base_stuff[] = {
22355 + VINF("info", S_IRUGO, vxi_info),
22356 + VINF("status", S_IRUGO, vxi_status),
22357 + VINF("limit", S_IRUGO, vxi_limit),
22358 + VINF("sched", S_IRUGO, vxi_sched),
22359 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
22360 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
22361 + VINF("cvirt", S_IRUGO, vxi_cvirt),
22362 + VINF("cacct", S_IRUGO, vxi_cacct),
22369 +static struct dentry *proc_xid_instantiate(struct inode *dir,
22370 + struct dentry *dentry, int id, void *ptr)
22372 + dentry->d_op = &proc_xid_dentry_operations;
22373 + return vs_proc_instantiate(dir, dentry, id, ptr);
22376 +static struct dentry *proc_xid_lookup(struct inode *dir,
22377 + struct dentry *dentry, struct nameidata *nd)
22379 + struct vs_entry *p = vx_base_stuff;
22380 + struct dentry *error = ERR_PTR(-ENOENT);
22382 + for (; p->name; p++) {
22383 + if (p->len != dentry->d_name.len)
22385 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22391 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22396 +static int proc_xid_readdir(struct file *filp,
22397 + void *dirent, filldir_t filldir)
22399 + struct dentry *dentry = filp->f_dentry;
22400 + struct inode *inode = dentry->d_inode;
22401 + struct vs_entry *p = vx_base_stuff;
22402 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
22406 + pos = filp->f_pos;
22409 + ino = inode->i_ino;
22410 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22413 + /* fall through */
22415 + ino = parent_ino(dentry);
22416 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22419 + /* fall through */
22422 + if (index >= size)
22424 + for (p += index; p->name; p++) {
22425 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22426 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22432 + filp->f_pos = pos;
22438 +static struct file_operations proc_nx_info_file_operations = {
22439 + .read = proc_nx_info_read,
22442 +static struct dentry_operations proc_nid_dentry_operations = {
22443 + .d_revalidate = proc_nid_revalidate,
22446 +static struct vs_entry nx_base_stuff[] = {
22447 + NINF("info", S_IRUGO, nxi_info),
22448 + NINF("status", S_IRUGO, nxi_status),
22453 +static struct dentry *proc_nid_instantiate(struct inode *dir,
22454 + struct dentry *dentry, int id, void *ptr)
22456 + dentry->d_op = &proc_nid_dentry_operations;
22457 + return vs_proc_instantiate(dir, dentry, id, ptr);
22460 +static struct dentry *proc_nid_lookup(struct inode *dir,
22461 + struct dentry *dentry, struct nameidata *nd)
22463 + struct vs_entry *p = nx_base_stuff;
22464 + struct dentry *error = ERR_PTR(-ENOENT);
22466 + for (; p->name; p++) {
22467 + if (p->len != dentry->d_name.len)
22469 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22475 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22480 +static int proc_nid_readdir(struct file *filp,
22481 + void *dirent, filldir_t filldir)
22483 + struct dentry *dentry = filp->f_dentry;
22484 + struct inode *inode = dentry->d_inode;
22485 + struct vs_entry *p = nx_base_stuff;
22486 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
22490 + pos = filp->f_pos;
22493 + ino = inode->i_ino;
22494 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22497 + /* fall through */
22499 + ino = parent_ino(dentry);
22500 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22503 + /* fall through */
22506 + if (index >= size)
22508 + for (p += index; p->name; p++) {
22509 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22510 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22516 + filp->f_pos = pos;
22521 +#define MAX_MULBY10 ((~0U - 9) / 10)
22523 +static inline int atovid(const char *str, int len)
22528 + while (len-- > 0) {
22533 + if (vid >= MAX_MULBY10)
22543 +/* now the upper level (virtual) */
22546 +static struct file_operations proc_xid_file_operations = {
22547 + .read = generic_read_dir,
22548 + .readdir = proc_xid_readdir,
22551 +static struct inode_operations proc_xid_inode_operations = {
22552 + .lookup = proc_xid_lookup,
22555 +static struct vs_entry vx_virtual_stuff[] = {
22556 + INF("info", S_IRUGO, virtual_info),
22557 + INF("status", S_IRUGO, virtual_status),
22558 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
22562 +static struct dentry *proc_virtual_lookup(struct inode *dir,
22563 + struct dentry *dentry, struct nameidata *nd)
22565 + struct vs_entry *p = vx_virtual_stuff;
22566 + struct dentry *error = ERR_PTR(-ENOENT);
22569 + for (; p->name; p++) {
22570 + if (p->len != dentry->d_name.len)
22572 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22576 + goto instantiate;
22578 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22579 + if ((id < 0) || !xid_is_hashed(id))
22583 + error = proc_xid_instantiate(dir, dentry, id, p);
22588 +static struct file_operations proc_nid_file_operations = {
22589 + .read = generic_read_dir,
22590 + .readdir = proc_nid_readdir,
22593 +static struct inode_operations proc_nid_inode_operations = {
22594 + .lookup = proc_nid_lookup,
22597 +static struct vs_entry nx_virtnet_stuff[] = {
22598 + INF("info", S_IRUGO, virtnet_info),
22599 + INF("status", S_IRUGO, virtnet_status),
22600 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
22604 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
22605 + struct dentry *dentry, struct nameidata *nd)
22607 + struct vs_entry *p = nx_virtnet_stuff;
22608 + struct dentry *error = ERR_PTR(-ENOENT);
22611 + for (; p->name; p++) {
22612 + if (p->len != dentry->d_name.len)
22614 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22618 + goto instantiate;
22620 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22621 + if ((id < 0) || !nid_is_hashed(id))
22625 + error = proc_nid_instantiate(dir, dentry, id, p);
22631 +#define PROC_MAXVIDS 32
22633 +int proc_virtual_readdir(struct file *filp,
22634 + void *dirent, filldir_t filldir)
22636 + struct dentry *dentry = filp->f_dentry;
22637 + struct inode *inode = dentry->d_inode;
22638 + struct vs_entry *p = vx_virtual_stuff;
22639 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
22641 + unsigned int xid_array[PROC_MAXVIDS];
22642 + char buf[PROC_NUMBUF];
22643 + unsigned int nr_xids, i;
22646 + pos = filp->f_pos;
22649 + ino = inode->i_ino;
22650 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22653 + /* fall through */
22655 + ino = parent_ino(dentry);
22656 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22659 + /* fall through */
22662 + if (index >= size)
22664 + for (p += index; p->name; p++) {
22665 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22666 + vs_proc_instantiate, 0, p))
22671 + index = pos - size;
22672 + p = &vx_virtual_stuff[size - 1];
22673 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22674 + for (i = 0; i < nr_xids; i++) {
22675 + int n, xid = xid_array[i];
22676 + unsigned int j = PROC_NUMBUF;
22680 + buf[--j] = '0' + (n % 10);
22683 + if (proc_fill_cache(filp, dirent, filldir,
22684 + buf + j, PROC_NUMBUF - j,
22685 + vs_proc_instantiate, xid, p))
22691 + filp->f_pos = pos;
22695 +static int proc_virtual_getattr(struct vfsmount *mnt,
22696 + struct dentry *dentry, struct kstat *stat)
22698 + struct inode *inode = dentry->d_inode;
22700 + generic_fillattr(inode, stat);
22701 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22705 +static struct file_operations proc_virtual_dir_operations = {
22706 + .read = generic_read_dir,
22707 + .readdir = proc_virtual_readdir,
22710 +static struct inode_operations proc_virtual_dir_inode_operations = {
22711 + .getattr = proc_virtual_getattr,
22712 + .lookup = proc_virtual_lookup,
22719 +int proc_virtnet_readdir(struct file *filp,
22720 + void *dirent, filldir_t filldir)
22722 + struct dentry *dentry = filp->f_dentry;
22723 + struct inode *inode = dentry->d_inode;
22724 + struct vs_entry *p = nx_virtnet_stuff;
22725 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22727 + unsigned int nid_array[PROC_MAXVIDS];
22728 + char buf[PROC_NUMBUF];
22729 + unsigned int nr_nids, i;
22732 + pos = filp->f_pos;
22735 + ino = inode->i_ino;
22736 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22739 + /* fall through */
22741 + ino = parent_ino(dentry);
22742 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22745 + /* fall through */
22748 + if (index >= size)
22750 + for (p += index; p->name; p++) {
22751 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22752 + vs_proc_instantiate, 0, p))
22757 + index = pos - size;
22758 + p = &nx_virtnet_stuff[size - 1];
22759 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22760 + for (i = 0; i < nr_nids; i++) {
22761 + int n, nid = nid_array[i];
22762 + unsigned int j = PROC_NUMBUF;
22766 + buf[--j] = '0' + (n % 10);
22769 + if (proc_fill_cache(filp, dirent, filldir,
22770 + buf + j, PROC_NUMBUF - j,
22771 + vs_proc_instantiate, nid, p))
22777 + filp->f_pos = pos;
22781 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22782 + struct dentry *dentry, struct kstat *stat)
22784 + struct inode *inode = dentry->d_inode;
22786 + generic_fillattr(inode, stat);
22787 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22791 +static struct file_operations proc_virtnet_dir_operations = {
22792 + .read = generic_read_dir,
22793 + .readdir = proc_virtnet_readdir,
22796 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22797 + .getattr = proc_virtnet_getattr,
22798 + .lookup = proc_virtnet_lookup,
22803 +void proc_vx_init(void)
22805 + struct proc_dir_entry *ent;
22807 + ent = proc_mkdir("virtual", 0);
22809 + ent->proc_fops = &proc_virtual_dir_operations;
22810 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22812 + proc_virtual = ent;
22814 + ent = proc_mkdir("virtnet", 0);
22816 + ent->proc_fops = &proc_virtnet_dir_operations;
22817 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22819 + proc_virtnet = ent;
22825 +/* per pid info */
22828 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22830 + struct vx_info *vxi;
22831 + char *orig = buffer;
22833 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22835 + vxi = task_get_vx_info(p);
22839 + buffer += sprintf(buffer, "BCaps:\t");
22840 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22841 + buffer += sprintf(buffer, "\n");
22842 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22843 + (unsigned long long)vxi->vx_ccaps);
22844 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22845 + (unsigned long long)vxi->vx_flags);
22846 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22848 + put_vx_info(vxi);
22850 + return buffer - orig;
22854 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22856 + struct nx_info *nxi;
22857 + struct nx_addr_v4 *v4a;
22858 +#ifdef CONFIG_IPV6
22859 + struct nx_addr_v6 *v6a;
22861 + char *orig = buffer;
22864 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22866 + nxi = task_get_nx_info(p);
22870 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22871 + (unsigned long long)nxi->nx_ncaps);
22872 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22873 + (unsigned long long)nxi->nx_flags);
22875 + buffer += sprintf(buffer,
22876 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22877 + NIPQUAD(nxi->v4_bcast.s_addr));
22878 + buffer += sprintf (buffer,
22879 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22880 + NIPQUAD(nxi->v4_lback.s_addr));
22881 + if (!NX_IPV4(nxi))
22883 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22884 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22887 +#ifdef CONFIG_IPV6
22888 + if (!NX_IPV6(nxi))
22890 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22891 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22895 + put_nx_info(nxi);
22897 + return buffer - orig;
22900 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/sched.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/sched.c
22901 --- linux-2.6.35.7/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22902 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/sched.c 2010-08-02 17:05:06.000000000 +0200
22905 + * linux/kernel/vserver/sched.c
22907 + * Virtual Server: Scheduler Support
22909 + * Copyright (C) 2004-2007 Herbert Pötzl
22911 + * V0.01 adapted Sam Vilains version to 2.6.3
22912 + * V0.02 removed legacy interface
22913 + * V0.03 changed vcmds to vxi arg
22914 + * V0.04 removed older and legacy interfaces
22918 +#include <linux/vs_context.h>
22919 +#include <linux/vs_sched.h>
22920 +#include <linux/vserver/sched_cmd.h>
22922 +#include <asm/uaccess.h>
22925 +#define vxd_check_range(val, min, max) do { \
22926 + vxlprintk((val < min) || (val > max), \
22927 + "check_range(%ld,%ld,%ld)", \
22928 + (long)val, (long)min, (long)max, \
22929 + __FILE__, __LINE__); \
22933 +void vx_update_sched_param(struct _vx_sched *sched,
22934 + struct _vx_sched_pc *sched_pc)
22936 + unsigned int set_mask = sched->update_mask;
22938 + if (set_mask & VXSM_FILL_RATE)
22939 + sched_pc->fill_rate[0] = sched->fill_rate[0];
22940 + if (set_mask & VXSM_INTERVAL)
22941 + sched_pc->interval[0] = sched->interval[0];
22942 + if (set_mask & VXSM_FILL_RATE2)
22943 + sched_pc->fill_rate[1] = sched->fill_rate[1];
22944 + if (set_mask & VXSM_INTERVAL2)
22945 + sched_pc->interval[1] = sched->interval[1];
22946 + if (set_mask & VXSM_TOKENS)
22947 + sched_pc->tokens = sched->tokens;
22948 + if (set_mask & VXSM_TOKENS_MIN)
22949 + sched_pc->tokens_min = sched->tokens_min;
22950 + if (set_mask & VXSM_TOKENS_MAX)
22951 + sched_pc->tokens_max = sched->tokens_max;
22952 + if (set_mask & VXSM_PRIO_BIAS)
22953 + sched_pc->prio_bias = sched->prio_bias;
22955 + if (set_mask & VXSM_IDLE_TIME)
22956 + sched_pc->flags |= VXSF_IDLE_TIME;
22958 + sched_pc->flags &= ~VXSF_IDLE_TIME;
22961 + sched_pc->norm_time = jiffies;
22966 + * recalculate the context's scheduling tokens
22968 + * ret > 0 : number of tokens available
22969 + * ret < 0 : on hold, check delta_min[]
22970 + * -1 only jiffies
22971 + * -2 also idle time
22974 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
22975 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
22979 + int flags = sched_pc->flags;
22981 + /* how much time did pass? */
22982 + delta = *norm_time - sched_pc->norm_time;
22983 + // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
22984 + vxd_check_range(delta, 0, INT_MAX);
22986 + if (delta >= sched_pc->interval[0]) {
22987 + long tokens, integral;
22989 + /* calc integral token part */
22990 + tokens = delta / sched_pc->interval[0];
22991 + integral = tokens * sched_pc->interval[0];
22992 + tokens *= sched_pc->fill_rate[0];
22993 +#ifdef CONFIG_VSERVER_HARDCPU
22994 + delta_min[0] = delta - integral;
22995 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
22997 + /* advance time */
22998 + sched_pc->norm_time += delta;
23001 + sched_pc->tokens += tokens;
23002 + sched_pc->token_time += tokens;
23004 + delta_min[0] = delta;
23006 +#ifdef CONFIG_VSERVER_IDLETIME
23007 + if (!(flags & VXSF_IDLE_TIME))
23010 + /* how much was the idle skip? */
23011 + delta = *idle_time - sched_pc->idle_time;
23012 + vxd_check_range(delta, 0, INT_MAX);
23014 + if (delta >= sched_pc->interval[1]) {
23015 + long tokens, integral;
23017 + /* calc fair share token part */
23018 + tokens = delta / sched_pc->interval[1];
23019 + integral = tokens * sched_pc->interval[1];
23020 + tokens *= sched_pc->fill_rate[1];
23021 + delta_min[1] = delta - integral;
23022 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
23024 + /* advance idle time */
23025 + sched_pc->idle_time += integral;
23028 + sched_pc->tokens += tokens;
23029 + sched_pc->token_time += tokens;
23031 + delta_min[1] = delta;
23035 + /* clip at maximum */
23036 + if (sched_pc->tokens > sched_pc->tokens_max)
23037 + sched_pc->tokens = sched_pc->tokens_max;
23038 + tokens = sched_pc->tokens;
23040 + if ((flags & VXSF_ONHOLD)) {
23041 + /* can we unhold? */
23042 + if (tokens >= sched_pc->tokens_min) {
23043 + flags &= ~VXSF_ONHOLD;
23044 + sched_pc->hold_ticks +=
23045 + *norm_time - sched_pc->onhold;
23049 + /* put on hold? */
23050 + if (tokens <= 0) {
23051 + flags |= VXSF_ONHOLD;
23052 + sched_pc->onhold = *norm_time;
23056 + sched_pc->flags = flags;
23060 + tokens = sched_pc->tokens_min - tokens;
23061 + sched_pc->flags = flags;
23062 + // BUG_ON(tokens < 0); probably doesn't hold anymore
23064 +#ifdef CONFIG_VSERVER_HARDCPU
23065 + /* next interval? */
23066 + if (!sched_pc->fill_rate[0])
23067 + delta_min[0] = HZ;
23068 + else if (tokens > sched_pc->fill_rate[0])
23069 + delta_min[0] += sched_pc->interval[0] *
23070 + tokens / sched_pc->fill_rate[0];
23072 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
23073 + vxd_check_range(delta_min[0], 0, INT_MAX);
23075 +#ifdef CONFIG_VSERVER_IDLETIME
23076 + if (!(flags & VXSF_IDLE_TIME))
23079 + /* next interval? */
23080 + if (!sched_pc->fill_rate[1])
23081 + delta_min[1] = HZ;
23082 + else if (tokens > sched_pc->fill_rate[1])
23083 + delta_min[1] += sched_pc->interval[1] *
23084 + tokens / sched_pc->fill_rate[1];
23086 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
23087 + vxd_check_range(delta_min[1], 0, INT_MAX);
23092 +#endif /* CONFIG_VSERVER_IDLETIME */
23095 +#endif /* CONFIG_VSERVER_HARDCPU */
23098 +static inline unsigned long msec_to_ticks(unsigned long msec)
23100 + return msecs_to_jiffies(msec);
23103 +static inline unsigned long ticks_to_msec(unsigned long ticks)
23105 + return jiffies_to_msecs(ticks);
23108 +static inline unsigned long ticks_to_usec(unsigned long ticks)
23110 + return jiffies_to_usecs(ticks);
23114 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
23116 + unsigned int set_mask = data->mask;
23117 + unsigned int update_mask;
23120 + /* Sanity check data values */
23121 + if (data->tokens_max <= 0)
23122 + data->tokens_max = HZ;
23123 + if (data->tokens_min < 0)
23124 + data->tokens_min = HZ / 3;
23125 + if (data->tokens_min >= data->tokens_max)
23126 + data->tokens_min = data->tokens_max;
23128 + if (data->prio_bias > MAX_PRIO_BIAS)
23129 + data->prio_bias = MAX_PRIO_BIAS;
23130 + if (data->prio_bias < MIN_PRIO_BIAS)
23131 + data->prio_bias = MIN_PRIO_BIAS;
23133 + spin_lock(&vxi->sched.tokens_lock);
23135 + /* sync up on delayed updates */
23136 + for_each_cpu_mask(cpu, vxi->sched.update)
23137 + vx_update_sched_param(&vxi->sched,
23138 + &vx_per_cpu(vxi, sched_pc, cpu));
23140 + if (set_mask & VXSM_FILL_RATE)
23141 + vxi->sched.fill_rate[0] = data->fill_rate[0];
23142 + if (set_mask & VXSM_FILL_RATE2)
23143 + vxi->sched.fill_rate[1] = data->fill_rate[1];
23144 + if (set_mask & VXSM_INTERVAL)
23145 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
23146 + msec_to_ticks(data->interval[0]) : data->interval[0];
23147 + if (set_mask & VXSM_INTERVAL2)
23148 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
23149 + msec_to_ticks(data->interval[1]) : data->interval[1];
23150 + if (set_mask & VXSM_TOKENS)
23151 + vxi->sched.tokens = data->tokens;
23152 + if (set_mask & VXSM_TOKENS_MIN)
23153 + vxi->sched.tokens_min = data->tokens_min;
23154 + if (set_mask & VXSM_TOKENS_MAX)
23155 + vxi->sched.tokens_max = data->tokens_max;
23156 + if (set_mask & VXSM_PRIO_BIAS)
23157 + vxi->sched.prio_bias = data->prio_bias;
23159 + /* Sanity check rate/interval */
23160 + for (i = 0; i < 2; i++) {
23161 + if (data->fill_rate[i] < 0)
23162 + data->fill_rate[i] = 0;
23163 + if (data->interval[i] <= 0)
23164 + data->interval[i] = HZ;
23167 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
23168 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
23169 + vxi->sched.update_mask = update_mask;
23173 + if (set_mask & VXSM_CPU_ID) {
23174 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
23175 + cpus_and(vxi->sched.update, cpu_online_map,
23176 + vxi->sched.update);
23178 + vxi->sched.update = cpu_online_map;
23180 + /* forced reload? */
23181 + if (set_mask & VXSM_FORCE) {
23182 + for_each_cpu_mask(cpu, vxi->sched.update)
23183 + vx_update_sched_param(&vxi->sched,
23184 + &vx_per_cpu(vxi, sched_pc, cpu));
23185 + vxi->sched.update = CPU_MASK_NONE;
23188 + /* on UP we update immediately */
23189 + vx_update_sched_param(&vxi->sched,
23190 + &vx_per_cpu(vxi, sched_pc, 0));
23193 + spin_unlock(&vxi->sched.tokens_lock);
23198 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
23199 +#define COPY_PRI(C) C(prio_bias)
23200 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
23201 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
23202 + C(fill_rate[1]); C(interval[1]);
23204 +#define COPY_VALUE(name) vc_data.name = data->name
23206 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
23208 + struct vcmd_sched_v5 vc_data;
23210 + vc_data.mask = data->set_mask;
23211 + COPY_IDS(COPY_VALUE);
23212 + COPY_PRI(COPY_VALUE);
23213 + COPY_TOK(COPY_VALUE);
23214 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
23215 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
23216 + return do_set_sched(vxi, &vc_data);
23219 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
23221 + struct vcmd_set_sched_v4 vc_data;
23223 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23226 + return do_set_sched_v4(vxi, &vc_data);
23229 + /* latest interface is v5 */
23231 +int vc_set_sched(struct vx_info *vxi, void __user *data)
23233 + struct vcmd_sched_v5 vc_data;
23235 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23238 + return do_set_sched(vxi, &vc_data);
23242 +#define COPY_PRI(C) C(prio_bias)
23243 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
23244 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
23245 + C(fill_rate[1]); C(interval[1]);
23247 +#define COPY_VALUE(name) vc_data.name = data->name
23250 +int vc_get_sched(struct vx_info *vxi, void __user *data)
23252 + struct vcmd_sched_v5 vc_data;
23254 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23257 + if (vc_data.mask & VXSM_CPU_ID) {
23258 + int cpu = vc_data.cpu_id;
23259 + struct _vx_sched_pc *data;
23261 + if (!cpu_possible(cpu))
23264 + data = &vx_per_cpu(vxi, sched_pc, cpu);
23265 + COPY_TOK(COPY_VALUE);
23266 + COPY_PRI(COPY_VALUE);
23267 + COPY_FRI(COPY_VALUE);
23269 + if (data->flags & VXSF_IDLE_TIME)
23270 + vc_data.mask |= VXSM_IDLE_TIME;
23272 + struct _vx_sched *data = &vxi->sched;
23274 + COPY_TOK(COPY_VALUE);
23275 + COPY_PRI(COPY_VALUE);
23276 + COPY_FRI(COPY_VALUE);
23279 + if (vc_data.mask & VXSM_MSEC) {
23280 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
23281 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
23284 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23290 +int vc_sched_info(struct vx_info *vxi, void __user *data)
23292 + struct vcmd_sched_info vc_data;
23295 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23298 + cpu = vc_data.cpu_id;
23299 + if (!cpu_possible(cpu))
23303 + struct _vx_sched_pc *sched_pc =
23304 + &vx_per_cpu(vxi, sched_pc, cpu);
23306 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
23307 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
23308 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
23309 + vc_data.vavavoom = sched_pc->vavavoom;
23311 + vc_data.token_usec = ticks_to_usec(1);
23313 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23318 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/sched_init.h linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/sched_init.h
23319 --- linux-2.6.35.7/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
23320 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/sched_init.h 2010-08-02 17:05:06.000000000 +0200
23323 +static inline void vx_info_init_sched(struct _vx_sched *sched)
23325 + static struct lock_class_key tokens_lock_key;
23327 + /* scheduling; hard code starting values as constants */
23328 + sched->fill_rate[0] = 1;
23329 + sched->interval[0] = 4;
23330 + sched->fill_rate[1] = 1;
23331 + sched->interval[1] = 8;
23332 + sched->tokens = HZ >> 2;
23333 + sched->tokens_min = HZ >> 4;
23334 + sched->tokens_max = HZ >> 1;
23335 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
23336 + sched->prio_bias = 0;
23338 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
23342 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
23344 + sched_pc->fill_rate[0] = 1;
23345 + sched_pc->interval[0] = 4;
23346 + sched_pc->fill_rate[1] = 1;
23347 + sched_pc->interval[1] = 8;
23348 + sched_pc->tokens = HZ >> 2;
23349 + sched_pc->tokens_min = HZ >> 4;
23350 + sched_pc->tokens_max = HZ >> 1;
23351 + sched_pc->prio_bias = 0;
23352 + sched_pc->vavavoom = 0;
23353 + sched_pc->token_time = 0;
23354 + sched_pc->idle_time = 0;
23355 + sched_pc->norm_time = jiffies;
23357 + sched_pc->user_ticks = 0;
23358 + sched_pc->sys_ticks = 0;
23359 + sched_pc->hold_ticks = 0;
23362 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
23368 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
23372 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/sched_proc.h linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/sched_proc.h
23373 --- linux-2.6.35.7/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
23374 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/sched_proc.h 2010-08-02 17:05:06.000000000 +0200
23376 +#ifndef _VX_SCHED_PROC_H
23377 +#define _VX_SCHED_PROC_H
23381 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
23385 + length += sprintf(buffer,
23386 + "FillRate:\t%8d,%d\n"
23387 + "Interval:\t%8d,%d\n"
23388 + "TokensMin:\t%8d\n"
23389 + "TokensMax:\t%8d\n"
23390 + "PrioBias:\t%8d\n",
23391 + sched->fill_rate[0],
23392 + sched->fill_rate[1],
23393 + sched->interval[0],
23394 + sched->interval[1],
23395 + sched->tokens_min,
23396 + sched->tokens_max,
23397 + sched->prio_bias);
23402 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
23403 + char *buffer, int cpu)
23407 + length += sprintf(buffer + length,
23408 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
23409 + (unsigned long long)sched_pc->user_ticks,
23410 + (unsigned long long)sched_pc->sys_ticks,
23411 + (unsigned long long)sched_pc->hold_ticks,
23412 + sched_pc->token_time,
23413 + sched_pc->idle_time);
23414 + length += sprintf(buffer + length,
23415 + " %c%c %d %d %d %d/%d %d/%d",
23416 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
23417 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
23418 + sched_pc->tokens,
23419 + sched_pc->tokens_min,
23420 + sched_pc->tokens_max,
23421 + sched_pc->fill_rate[0],
23422 + sched_pc->interval[0],
23423 + sched_pc->fill_rate[1],
23424 + sched_pc->interval[1]);
23425 + length += sprintf(buffer + length,
23427 + sched_pc->prio_bias,
23428 + sched_pc->vavavoom);
23432 +#endif /* _VX_SCHED_PROC_H */
23433 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/signal.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/signal.c
23434 --- linux-2.6.35.7/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
23435 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/signal.c 2010-08-02 17:05:06.000000000 +0200
23438 + * linux/kernel/vserver/signal.c
23440 + * Virtual Server: Signal Support
23442 + * Copyright (C) 2003-2007 Herbert Pötzl
23444 + * V0.01 broken out from vcontext V0.05
23445 + * V0.02 changed vcmds to vxi arg
23446 + * V0.03 adjusted siginfo for kill
23450 +#include <asm/uaccess.h>
23452 +#include <linux/vs_context.h>
23453 +#include <linux/vs_pid.h>
23454 +#include <linux/vserver/signal_cmd.h>
23457 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
23459 + int retval, count = 0;
23460 + struct task_struct *p;
23461 + struct siginfo *sip = SEND_SIG_PRIV;
23464 + vxdprintk(VXD_CBIT(misc, 4),
23465 + "vx_info_kill(%p[#%d],%d,%d)*",
23466 + vxi, vxi->vx_id, pid, sig);
23467 + read_lock(&tasklist_lock);
23471 + for_each_process(p) {
23474 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
23475 + (pid && vxi->vx_initpid == p->pid))
23478 + err = group_send_sig_info(sig, sip, p);
23480 + if (err != -EPERM)
23486 + if (vxi->vx_initpid) {
23487 + pid = vxi->vx_initpid;
23488 + /* for now, only SIGINT to private init ... */
23489 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
23490 + /* ... as long as there are tasks left */
23491 + (atomic_read(&vxi->vx_tasks) > 1))
23494 + /* fallthrough */
23496 + p = find_task_by_real_pid(pid);
23498 + if (vx_task_xid(p) == vxi->vx_id)
23499 + retval = group_send_sig_info(sig, sip, p);
23503 + read_unlock(&tasklist_lock);
23504 + vxdprintk(VXD_CBIT(misc, 4),
23505 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
23506 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
23510 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
23512 + struct vcmd_ctx_kill_v0 vc_data;
23514 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23517 + /* special check to allow guest shutdown */
23518 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
23519 + /* forbid killall pid=0 when init is present */
23520 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
23521 + (vc_data.pid > 1)))
23524 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
23528 +static int __wait_exit(struct vx_info *vxi)
23530 + DECLARE_WAITQUEUE(wait, current);
23533 + add_wait_queue(&vxi->vx_wait, &wait);
23534 + set_current_state(TASK_INTERRUPTIBLE);
23537 + if (vx_info_state(vxi,
23538 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
23540 + if (signal_pending(current)) {
23541 + ret = -ERESTARTSYS;
23548 + set_current_state(TASK_RUNNING);
23549 + remove_wait_queue(&vxi->vx_wait, &wait);
23555 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
23557 + struct vcmd_wait_exit_v0 vc_data;
23560 + ret = __wait_exit(vxi);
23561 + vc_data.reboot_cmd = vxi->reboot_cmd;
23562 + vc_data.exit_code = vxi->exit_code;
23564 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23569 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/space.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/space.c
23570 --- linux-2.6.35.7/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
23571 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/space.c 2010-08-02 17:05:06.000000000 +0200
23574 + * linux/kernel/vserver/space.c
23576 + * Virtual Server: Context Space Support
23578 + * Copyright (C) 2003-2007 Herbert Pötzl
23580 + * V0.01 broken out from context.c 0.07
23581 + * V0.02 added task locking for namespace
23582 + * V0.03 broken out vx_enter_namespace
23583 + * V0.04 added *space support and commands
23587 +#include <linux/utsname.h>
23588 +#include <linux/nsproxy.h>
23589 +#include <linux/err.h>
23590 +#include <linux/fs_struct.h>
23591 +#include <asm/uaccess.h>
23593 +#include <linux/vs_context.h>
23594 +#include <linux/vserver/space.h>
23595 +#include <linux/vserver/space_cmd.h>
23597 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
23598 +atomic_t vs_global_fs = ATOMIC_INIT(0);
23599 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
23600 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
23601 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
23602 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
23605 +/* namespace functions */
23607 +#include <linux/mnt_namespace.h>
23608 +#include <linux/user_namespace.h>
23609 +#include <linux/pid_namespace.h>
23610 +#include <linux/ipc_namespace.h>
23611 +#include <net/net_namespace.h>
23614 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
23615 + .mask = CLONE_FS |
23623 +static const struct vcmd_space_mask_v1 space_mask = {
23624 + .mask = CLONE_FS |
23629 +#ifdef CONFIG_PID_NS
23632 +#ifdef CONFIG_NET_NS
23638 +static const struct vcmd_space_mask_v1 default_space_mask = {
23639 + .mask = CLONE_FS |
23644 +#ifdef CONFIG_PID_NS
23651 + * build a new nsproxy mix
23652 + * assumes that both proxies are 'const'
23653 + * does not touch nsproxy refcounts
23654 + * will hold a reference on the result.
23657 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
23658 + struct nsproxy *new_nsproxy, unsigned long mask)
23660 + struct mnt_namespace *old_ns;
23661 + struct uts_namespace *old_uts;
23662 + struct ipc_namespace *old_ipc;
23663 +#ifdef CONFIG_PID_NS
23664 + struct pid_namespace *old_pid;
23666 +#ifdef CONFIG_NET_NS
23667 + struct net *old_net;
23669 + struct nsproxy *nsproxy;
23671 + nsproxy = copy_nsproxy(old_nsproxy);
23675 + if (mask & CLONE_NEWNS) {
23676 + old_ns = nsproxy->mnt_ns;
23677 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
23678 + if (nsproxy->mnt_ns)
23679 + get_mnt_ns(nsproxy->mnt_ns);
23683 + if (mask & CLONE_NEWUTS) {
23684 + old_uts = nsproxy->uts_ns;
23685 + nsproxy->uts_ns = new_nsproxy->uts_ns;
23686 + if (nsproxy->uts_ns)
23687 + get_uts_ns(nsproxy->uts_ns);
23691 + if (mask & CLONE_NEWIPC) {
23692 + old_ipc = nsproxy->ipc_ns;
23693 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
23694 + if (nsproxy->ipc_ns)
23695 + get_ipc_ns(nsproxy->ipc_ns);
23699 +#ifdef CONFIG_PID_NS
23700 + if (mask & CLONE_NEWPID) {
23701 + old_pid = nsproxy->pid_ns;
23702 + nsproxy->pid_ns = new_nsproxy->pid_ns;
23703 + if (nsproxy->pid_ns)
23704 + get_pid_ns(nsproxy->pid_ns);
23708 +#ifdef CONFIG_NET_NS
23709 + if (mask & CLONE_NEWNET) {
23710 + old_net = nsproxy->net_ns;
23711 + nsproxy->net_ns = new_nsproxy->net_ns;
23712 + if (nsproxy->net_ns)
23713 + get_net(nsproxy->net_ns);
23718 + put_mnt_ns(old_ns);
23720 + put_uts_ns(old_uts);
23722 + put_ipc_ns(old_ipc);
23723 +#ifdef CONFIG_PID_NS
23725 + put_pid_ns(old_pid);
23727 +#ifdef CONFIG_NET_NS
23729 + put_net(old_net);
23737 + * merge two nsproxy structs into a new one.
23738 + * will hold a reference on the result.
23742 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
23743 + struct nsproxy *proxy, unsigned long mask)
23745 + struct nsproxy null_proxy = { .mnt_ns = NULL };
23751 + /* vs_mix_nsproxy returns with reference */
23752 + return vs_mix_nsproxy(old ? old : &null_proxy,
23755 + get_nsproxy(proxy);
23760 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23762 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
23763 + struct fs_struct *fs_cur, *fs = NULL;
23764 + int ret, kill = 0;
23766 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
23767 + vxi, vxi->vx_id, mask, index);
23769 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
23773 + mask = vxi->vx_nsmask[index];
23775 + if ((mask & vxi->vx_nsmask[index]) != mask)
23778 + if (mask & CLONE_FS) {
23779 + fs = copy_fs_struct(vxi->vx_fs[index]);
23783 + proxy = vxi->vx_nsproxy[index];
23785 + vxdprintk(VXD_CBIT(space, 9),
23786 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
23787 + vxi, vxi->vx_id, mask, index, proxy, fs);
23789 + task_lock(current);
23790 + fs_cur = current->fs;
23792 + if (mask & CLONE_FS) {
23793 + write_lock(&fs_cur->lock);
23794 + current->fs = fs;
23795 + kill = !--fs_cur->users;
23796 + write_unlock(&fs_cur->lock);
23799 + proxy_cur = current->nsproxy;
23800 + get_nsproxy(proxy_cur);
23801 + task_unlock(current);
23804 + free_fs_struct(fs_cur);
23806 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
23807 + if (IS_ERR(proxy_new)) {
23808 + ret = PTR_ERR(proxy_new);
23812 + proxy_new = xchg(¤t->nsproxy, proxy_new);
23816 + put_nsproxy(proxy_new);
23819 + put_nsproxy(proxy_cur);
23824 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23826 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
23827 + struct fs_struct *fs_vxi, *fs;
23828 + int ret, kill = 0;
23830 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
23831 + vxi, vxi->vx_id, mask, index);
23834 + mask = default_space_mask.mask;
23836 + if ((mask & space_mask.mask) != mask)
23839 + proxy_vxi = vxi->vx_nsproxy[index];
23840 + fs_vxi = vxi->vx_fs[index];
23842 + if (mask & CLONE_FS) {
23843 + fs = copy_fs_struct(current->fs);
23848 + task_lock(current);
23850 + if (mask & CLONE_FS) {
23851 + write_lock(&fs_vxi->lock);
23852 + vxi->vx_fs[index] = fs;
23853 + kill = !--fs_vxi->users;
23854 + write_unlock(&fs_vxi->lock);
23857 + proxy_cur = current->nsproxy;
23858 + get_nsproxy(proxy_cur);
23859 + task_unlock(current);
23862 + free_fs_struct(fs_vxi);
23864 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
23865 + if (IS_ERR(proxy_new)) {
23866 + ret = PTR_ERR(proxy_new);
23870 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
23871 + vxi->vx_nsmask[index] |= mask;
23875 + put_nsproxy(proxy_new);
23878 + put_nsproxy(proxy_cur);
23883 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
23885 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23887 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23890 + return vx_enter_space(vxi, vc_data.mask, 0);
23893 +int vc_enter_space(struct vx_info *vxi, void __user *data)
23895 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23897 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23900 + if (vc_data.index >= VX_SPACES)
23903 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
23906 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
23908 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23910 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23913 + return vx_set_space(vxi, vc_data.mask, 0);
23916 +int vc_set_space(struct vx_info *vxi, void __user *data)
23918 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23920 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23923 + if (vc_data.index >= VX_SPACES)
23926 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
23929 +int vc_get_space_mask(void __user *data, int type)
23931 + const struct vcmd_space_mask_v1 *mask;
23934 + mask = &space_mask_v0;
23935 + else if (type == 1)
23936 + mask = &space_mask;
23938 + mask = &default_space_mask;
23940 + vxdprintk(VXD_CBIT(space, 10),
23941 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
23943 + if (copy_to_user(data, mask, sizeof(*mask)))
23948 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/switch.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/switch.c
23949 --- linux-2.6.35.7/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
23950 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/switch.c 2010-08-02 17:05:06.000000000 +0200
23953 + * linux/kernel/vserver/switch.c
23955 + * Virtual Server: Syscall Switch
23957 + * Copyright (C) 2003-2007 Herbert Pötzl
23959 + * V0.01 syscall switch
23960 + * V0.02 added signal to context
23961 + * V0.03 added rlimit functions
23962 + * V0.04 added iattr, task/xid functions
23963 + * V0.05 added debug/history stuff
23964 + * V0.06 added compat32 layer
23965 + * V0.07 vcmd args and perms
23966 + * V0.08 added status commands
23967 + * V0.09 added tag commands
23968 + * V0.10 added oom bias
23969 + * V0.11 added device commands
23973 +#include <linux/vs_context.h>
23974 +#include <linux/vs_network.h>
23975 +#include <linux/vserver/switch.h>
23977 +#include "vci_config.h"
23981 +int vc_get_version(uint32_t id)
23983 + return VCI_VERSION;
23987 +int vc_get_vci(uint32_t id)
23989 + return vci_kernel_config();
23992 +#include <linux/vserver/context_cmd.h>
23993 +#include <linux/vserver/cvirt_cmd.h>
23994 +#include <linux/vserver/cacct_cmd.h>
23995 +#include <linux/vserver/limit_cmd.h>
23996 +#include <linux/vserver/network_cmd.h>
23997 +#include <linux/vserver/sched_cmd.h>
23998 +#include <linux/vserver/debug_cmd.h>
23999 +#include <linux/vserver/inode_cmd.h>
24000 +#include <linux/vserver/dlimit_cmd.h>
24001 +#include <linux/vserver/signal_cmd.h>
24002 +#include <linux/vserver/space_cmd.h>
24003 +#include <linux/vserver/tag_cmd.h>
24004 +#include <linux/vserver/device_cmd.h>
24006 +#include <linux/vserver/inode.h>
24007 +#include <linux/vserver/dlimit.h>
24010 +#ifdef CONFIG_COMPAT
24011 +#define __COMPAT(name, id, data, compat) \
24012 + (compat) ? name ## _x32(id, data) : name(id, data)
24013 +#define __COMPAT_NO_ID(name, data, compat) \
24014 + (compat) ? name ## _x32(data) : name(data)
24016 +#define __COMPAT(name, id, data, compat) \
24018 +#define __COMPAT_NO_ID(name, data, compat) \
24024 +long do_vcmd(uint32_t cmd, uint32_t id,
24025 + struct vx_info *vxi, struct nx_info *nxi,
24026 + void __user *data, int compat)
24030 + case VCMD_get_version:
24031 + return vc_get_version(id);
24032 + case VCMD_get_vci:
24033 + return vc_get_vci(id);
24035 + case VCMD_task_xid:
24036 + return vc_task_xid(id);
24037 + case VCMD_vx_info:
24038 + return vc_vx_info(vxi, data);
24040 + case VCMD_task_nid:
24041 + return vc_task_nid(id);
24042 + case VCMD_nx_info:
24043 + return vc_nx_info(nxi, data);
24045 + case VCMD_task_tag:
24046 + return vc_task_tag(id);
24048 + case VCMD_set_space_v1:
24049 + return vc_set_space_v1(vxi, data);
24050 + /* this is version 2 */
24051 + case VCMD_set_space:
24052 + return vc_set_space(vxi, data);
24054 + case VCMD_get_space_mask_v0:
24055 + return vc_get_space_mask(data, 0);
24056 + /* this is version 1 */
24057 + case VCMD_get_space_mask:
24058 + return vc_get_space_mask(data, 1);
24060 + case VCMD_get_space_default:
24061 + return vc_get_space_mask(data, -1);
24063 +#ifdef CONFIG_IA32_EMULATION
24064 + case VCMD_get_rlimit:
24065 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
24066 + case VCMD_set_rlimit:
24067 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
24069 + case VCMD_get_rlimit:
24070 + return vc_get_rlimit(vxi, data);
24071 + case VCMD_set_rlimit:
24072 + return vc_set_rlimit(vxi, data);
24074 + case VCMD_get_rlimit_mask:
24075 + return vc_get_rlimit_mask(id, data);
24076 + case VCMD_reset_hits:
24077 + return vc_reset_hits(vxi, data);
24078 + case VCMD_reset_minmax:
24079 + return vc_reset_minmax(vxi, data);
24081 + case VCMD_get_vhi_name:
24082 + return vc_get_vhi_name(vxi, data);
24083 + case VCMD_set_vhi_name:
24084 + return vc_set_vhi_name(vxi, data);
24086 + case VCMD_ctx_stat:
24087 + return vc_ctx_stat(vxi, data);
24088 + case VCMD_virt_stat:
24089 + return vc_virt_stat(vxi, data);
24090 + case VCMD_sock_stat:
24091 + return vc_sock_stat(vxi, data);
24092 + case VCMD_rlimit_stat:
24093 + return vc_rlimit_stat(vxi, data);
24095 + case VCMD_set_cflags:
24096 + return vc_set_cflags(vxi, data);
24097 + case VCMD_get_cflags:
24098 + return vc_get_cflags(vxi, data);
24100 + /* this is version 1 */
24101 + case VCMD_set_ccaps:
24102 + return vc_set_ccaps(vxi, data);
24103 + /* this is version 1 */
24104 + case VCMD_get_ccaps:
24105 + return vc_get_ccaps(vxi, data);
24106 + case VCMD_set_bcaps:
24107 + return vc_set_bcaps(vxi, data);
24108 + case VCMD_get_bcaps:
24109 + return vc_get_bcaps(vxi, data);
24111 + case VCMD_set_badness:
24112 + return vc_set_badness(vxi, data);
24113 + case VCMD_get_badness:
24114 + return vc_get_badness(vxi, data);
24116 + case VCMD_set_nflags:
24117 + return vc_set_nflags(nxi, data);
24118 + case VCMD_get_nflags:
24119 + return vc_get_nflags(nxi, data);
24121 + case VCMD_set_ncaps:
24122 + return vc_set_ncaps(nxi, data);
24123 + case VCMD_get_ncaps:
24124 + return vc_get_ncaps(nxi, data);
24126 + case VCMD_set_sched_v4:
24127 + return vc_set_sched_v4(vxi, data);
24128 + /* this is version 5 */
24129 + case VCMD_set_sched:
24130 + return vc_set_sched(vxi, data);
24131 + case VCMD_get_sched:
24132 + return vc_get_sched(vxi, data);
24133 + case VCMD_sched_info:
24134 + return vc_sched_info(vxi, data);
24136 + case VCMD_add_dlimit:
24137 + return __COMPAT(vc_add_dlimit, id, data, compat);
24138 + case VCMD_rem_dlimit:
24139 + return __COMPAT(vc_rem_dlimit, id, data, compat);
24140 + case VCMD_set_dlimit:
24141 + return __COMPAT(vc_set_dlimit, id, data, compat);
24142 + case VCMD_get_dlimit:
24143 + return __COMPAT(vc_get_dlimit, id, data, compat);
24145 + case VCMD_ctx_kill:
24146 + return vc_ctx_kill(vxi, data);
24148 + case VCMD_wait_exit:
24149 + return vc_wait_exit(vxi, data);
24151 + case VCMD_get_iattr:
24152 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
24153 + case VCMD_set_iattr:
24154 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
24156 + case VCMD_fget_iattr:
24157 + return vc_fget_iattr(id, data);
24158 + case VCMD_fset_iattr:
24159 + return vc_fset_iattr(id, data);
24161 + case VCMD_enter_space_v0:
24162 + return vc_enter_space_v1(vxi, NULL);
24163 + case VCMD_enter_space_v1:
24164 + return vc_enter_space_v1(vxi, data);
24165 + /* this is version 2 */
24166 + case VCMD_enter_space:
24167 + return vc_enter_space(vxi, data);
24169 + case VCMD_ctx_create_v0:
24170 + return vc_ctx_create(id, NULL);
24171 + case VCMD_ctx_create:
24172 + return vc_ctx_create(id, data);
24173 + case VCMD_ctx_migrate_v0:
24174 + return vc_ctx_migrate(vxi, NULL);
24175 + case VCMD_ctx_migrate:
24176 + return vc_ctx_migrate(vxi, data);
24178 + case VCMD_net_create_v0:
24179 + return vc_net_create(id, NULL);
24180 + case VCMD_net_create:
24181 + return vc_net_create(id, data);
24182 + case VCMD_net_migrate:
24183 + return vc_net_migrate(nxi, data);
24185 + case VCMD_tag_migrate:
24186 + return vc_tag_migrate(id);
24188 + case VCMD_net_add:
24189 + return vc_net_add(nxi, data);
24190 + case VCMD_net_remove:
24191 + return vc_net_remove(nxi, data);
24193 + case VCMD_net_add_ipv4:
24194 + return vc_net_add_ipv4(nxi, data);
24195 + case VCMD_net_remove_ipv4:
24196 + return vc_net_remove_ipv4(nxi, data);
24197 +#ifdef CONFIG_IPV6
24198 + case VCMD_net_add_ipv6:
24199 + return vc_net_add_ipv6(nxi, data);
24200 + case VCMD_net_remove_ipv6:
24201 + return vc_net_remove_ipv6(nxi, data);
24203 +/* case VCMD_add_match_ipv4:
24204 + return vc_add_match_ipv4(nxi, data);
24205 + case VCMD_get_match_ipv4:
24206 + return vc_get_match_ipv4(nxi, data);
24207 +#ifdef CONFIG_IPV6
24208 + case VCMD_add_match_ipv6:
24209 + return vc_add_match_ipv6(nxi, data);
24210 + case VCMD_get_match_ipv6:
24211 + return vc_get_match_ipv6(nxi, data);
24214 +#ifdef CONFIG_VSERVER_DEVICE
24215 + case VCMD_set_mapping:
24216 + return __COMPAT(vc_set_mapping, vxi, data, compat);
24217 + case VCMD_unset_mapping:
24218 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
24220 +#ifdef CONFIG_VSERVER_HISTORY
24221 + case VCMD_dump_history:
24222 + return vc_dump_history(id);
24223 + case VCMD_read_history:
24224 + return __COMPAT(vc_read_history, id, data, compat);
24226 +#ifdef CONFIG_VSERVER_MONITOR
24227 + case VCMD_read_monitor:
24228 + return __COMPAT(vc_read_monitor, id, data, compat);
24231 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
24232 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
24238 +#define __VCMD(vcmd, _perm, _args, _flags) \
24239 + case VCMD_ ## vcmd: perm = _perm; \
24240 + args = _args; flags = _flags; break
24243 +#define VCA_NONE 0x00
24244 +#define VCA_VXI 0x01
24245 +#define VCA_NXI 0x02
24247 +#define VCF_NONE 0x00
24248 +#define VCF_INFO 0x01
24249 +#define VCF_ADMIN 0x02
24250 +#define VCF_ARES 0x06 /* includes admin */
24251 +#define VCF_SETUP 0x08
24253 +#define VCF_ZIDOK 0x10 /* zero id okay */
24257 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
24260 + int permit = -1, state = 0;
24261 + int perm = -1, args = 0, flags = 0;
24262 + struct vx_info *vxi = NULL;
24263 + struct nx_info *nxi = NULL;
24266 + /* unpriviledged commands */
24267 + __VCMD(get_version, 0, VCA_NONE, 0);
24268 + __VCMD(get_vci, 0, VCA_NONE, 0);
24269 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
24270 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
24271 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
24272 + __VCMD(get_space_default,0, VCA_NONE, 0);
24274 + /* info commands */
24275 + __VCMD(task_xid, 2, VCA_NONE, 0);
24276 + __VCMD(reset_hits, 2, VCA_VXI, 0);
24277 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
24278 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
24279 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
24280 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
24281 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
24282 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
24283 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
24284 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
24286 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
24287 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
24288 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
24289 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
24291 + __VCMD(task_nid, 2, VCA_NONE, 0);
24292 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
24293 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
24294 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
24296 + __VCMD(task_tag, 2, VCA_NONE, 0);
24298 + __VCMD(get_iattr, 2, VCA_NONE, 0);
24299 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
24300 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
24301 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
24302 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
24304 + /* lower admin commands */
24305 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
24306 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
24307 + __VCMD(ctx_create, 5, VCA_NONE, 0);
24308 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
24309 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
24310 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
24311 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
24312 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
24314 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
24315 + __VCMD(net_create, 5, VCA_NONE, 0);
24316 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
24318 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
24320 + /* higher admin commands */
24321 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
24322 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24323 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24325 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24326 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24327 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24328 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24330 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24331 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24332 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24333 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24335 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
24336 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
24337 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24338 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24339 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24340 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24341 +#ifdef CONFIG_IPV6
24342 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24343 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24345 + __VCMD(set_iattr, 7, VCA_NONE, 0);
24346 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
24347 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
24348 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
24349 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
24351 +#ifdef CONFIG_VSERVER_DEVICE
24352 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
24353 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
24355 + /* debug level admin commands */
24356 +#ifdef CONFIG_VSERVER_HISTORY
24357 + __VCMD(dump_history, 9, VCA_NONE, 0);
24358 + __VCMD(read_history, 9, VCA_NONE, 0);
24360 +#ifdef CONFIG_VSERVER_MONITOR
24361 + __VCMD(read_monitor, 9, VCA_NONE, 0);
24368 + vxdprintk(VXD_CBIT(switch, 0),
24369 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
24370 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
24371 + VC_VERSION(cmd), id, data, compat,
24372 + perm, args, flags);
24379 + if (!capable(CAP_CONTEXT))
24383 + /* moved here from the individual commands */
24385 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
24389 + /* vcmd involves resource management */
24391 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
24395 + /* various legacy exceptions */
24397 + /* will go away when spectator is a cap */
24398 + case VCMD_ctx_migrate_v0:
24399 + case VCMD_ctx_migrate:
24401 + current->xid = 1;
24407 + /* will go away when spectator is a cap */
24408 + case VCMD_net_migrate:
24410 + current->nid = 1;
24417 + /* vcmds are fine by default */
24420 + /* admin type vcmds require admin ... */
24421 + if (flags & VCF_ADMIN)
24422 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
24424 + /* ... but setup type vcmds override that */
24425 + if (!permit && (flags & VCF_SETUP))
24426 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
24434 + if (!id && (flags & VCF_ZIDOK))
24438 + if (args & VCA_VXI) {
24439 + vxi = lookup_vx_info(id);
24443 + if ((flags & VCF_ADMIN) &&
24444 + /* special case kill for shutdown */
24445 + (cmd != VCMD_ctx_kill) &&
24446 + /* can context be administrated? */
24447 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
24453 + if (args & VCA_NXI) {
24454 + nxi = lookup_nx_info(id);
24458 + if ((flags & VCF_ADMIN) &&
24459 + /* can context be administrated? */
24460 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
24467 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
24470 + if ((args & VCA_NXI) && nxi)
24471 + put_nx_info(nxi);
24473 + if ((args & VCA_VXI) && vxi)
24474 + put_vx_info(vxi);
24476 + vxdprintk(VXD_CBIT(switch, 1),
24477 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
24478 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
24479 + VC_VERSION(cmd), ret, ret, state, permit);
24484 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
24486 + return do_vserver(cmd, id, data, 0);
24489 +#ifdef CONFIG_COMPAT
24492 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
24494 + return do_vserver(cmd, id, data, 1);
24497 +#endif /* CONFIG_COMPAT */
24498 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/sysctl.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/sysctl.c
24499 --- linux-2.6.35.7/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
24500 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/sysctl.c 2010-08-02 17:05:06.000000000 +0200
24503 + * kernel/vserver/sysctl.c
24505 + * Virtual Context Support
24507 + * Copyright (C) 2004-2007 Herbert Pötzl
24509 + * V0.01 basic structure
24513 +#include <linux/module.h>
24514 +#include <linux/ctype.h>
24515 +#include <linux/sysctl.h>
24516 +#include <linux/parser.h>
24517 +#include <asm/uaccess.h>
24520 + CTL_DEBUG_ERROR = 0,
24521 + CTL_DEBUG_SWITCH = 1,
24536 +unsigned int vx_debug_switch = 0;
24537 +unsigned int vx_debug_xid = 0;
24538 +unsigned int vx_debug_nid = 0;
24539 +unsigned int vx_debug_tag = 0;
24540 +unsigned int vx_debug_net = 0;
24541 +unsigned int vx_debug_limit = 0;
24542 +unsigned int vx_debug_cres = 0;
24543 +unsigned int vx_debug_dlim = 0;
24544 +unsigned int vx_debug_quota = 0;
24545 +unsigned int vx_debug_cvirt = 0;
24546 +unsigned int vx_debug_space = 0;
24547 +unsigned int vx_debug_misc = 0;
24550 +static struct ctl_table_header *vserver_table_header;
24551 +static ctl_table vserver_root_table[];
24554 +void vserver_register_sysctl(void)
24556 + if (!vserver_table_header) {
24557 + vserver_table_header = register_sysctl_table(vserver_root_table);
24562 +void vserver_unregister_sysctl(void)
24564 + if (vserver_table_header) {
24565 + unregister_sysctl_table(vserver_table_header);
24566 + vserver_table_header = NULL;
24571 +static int proc_dodebug(ctl_table *table, int write,
24572 + void __user *buffer, size_t *lenp, loff_t *ppos)
24574 + char tmpbuf[20], *p, c;
24575 + unsigned int value;
24576 + size_t left, len;
24578 + if ((*ppos && !write) || !*lenp) {
24586 + if (!access_ok(VERIFY_READ, buffer, left))
24588 + p = (char *)buffer;
24589 + while (left && __get_user(c, p) >= 0 && isspace(c))
24594 + if (left > sizeof(tmpbuf) - 1)
24596 + if (copy_from_user(tmpbuf, p, left))
24598 + tmpbuf[left] = '\0';
24600 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
24601 + value = 10 * value + (*p - '0');
24602 + if (*p && !isspace(*p))
24604 + while (left && isspace(*p))
24606 + *(unsigned int *)table->data = value;
24608 + if (!access_ok(VERIFY_WRITE, buffer, left))
24610 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
24613 + if (__copy_to_user(buffer, tmpbuf, len))
24615 + if ((left -= len) > 0) {
24616 + if (put_user('\n', (char *)buffer + len))
24630 +#define CTL_ENTRY(ctl, name) \
24632 + .procname = #name, \
24633 + .data = &vx_ ## name, \
24634 + .maxlen = sizeof(int), \
24636 + .proc_handler = &proc_dodebug, \
24637 + .extra1 = &zero, \
24638 + .extra2 = &zero, \
24641 +static ctl_table vserver_debug_table[] = {
24642 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
24643 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
24644 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
24645 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
24646 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
24647 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
24648 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
24649 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
24650 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
24651 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
24652 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
24653 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
24657 +static ctl_table vserver_root_table[] = {
24659 + .procname = "vserver",
24661 + .child = vserver_debug_table
24667 +static match_table_t tokens = {
24668 + { CTL_DEBUG_SWITCH, "switch=%x" },
24669 + { CTL_DEBUG_XID, "xid=%x" },
24670 + { CTL_DEBUG_NID, "nid=%x" },
24671 + { CTL_DEBUG_TAG, "tag=%x" },
24672 + { CTL_DEBUG_NET, "net=%x" },
24673 + { CTL_DEBUG_LIMIT, "limit=%x" },
24674 + { CTL_DEBUG_CRES, "cres=%x" },
24675 + { CTL_DEBUG_DLIM, "dlim=%x" },
24676 + { CTL_DEBUG_QUOTA, "quota=%x" },
24677 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
24678 + { CTL_DEBUG_SPACE, "space=%x" },
24679 + { CTL_DEBUG_MISC, "misc=%x" },
24680 + { CTL_DEBUG_ERROR, NULL }
24683 +#define HANDLE_CASE(id, name, val) \
24684 + case CTL_DEBUG_ ## id: \
24685 + vx_debug_ ## name = val; \
24686 + printk("vs_debug_" #name "=0x%x\n", val); \
24690 +static int __init vs_debug_setup(char *str)
24695 + printk("vs_debug_setup(%s)\n", str);
24696 + while ((p = strsep(&str, ",")) != NULL) {
24697 + substring_t args[MAX_OPT_ARGS];
24698 + unsigned int value;
24703 + token = match_token(p, tokens, args);
24704 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
24707 + HANDLE_CASE(SWITCH, switch, value);
24708 + HANDLE_CASE(XID, xid, value);
24709 + HANDLE_CASE(NID, nid, value);
24710 + HANDLE_CASE(TAG, tag, value);
24711 + HANDLE_CASE(NET, net, value);
24712 + HANDLE_CASE(LIMIT, limit, value);
24713 + HANDLE_CASE(CRES, cres, value);
24714 + HANDLE_CASE(DLIM, dlim, value);
24715 + HANDLE_CASE(QUOTA, quota, value);
24716 + HANDLE_CASE(CVIRT, cvirt, value);
24717 + HANDLE_CASE(SPACE, space, value);
24718 + HANDLE_CASE(MISC, misc, value);
24727 +__setup("vsdebug=", vs_debug_setup);
24731 +EXPORT_SYMBOL_GPL(vx_debug_switch);
24732 +EXPORT_SYMBOL_GPL(vx_debug_xid);
24733 +EXPORT_SYMBOL_GPL(vx_debug_nid);
24734 +EXPORT_SYMBOL_GPL(vx_debug_net);
24735 +EXPORT_SYMBOL_GPL(vx_debug_limit);
24736 +EXPORT_SYMBOL_GPL(vx_debug_cres);
24737 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
24738 +EXPORT_SYMBOL_GPL(vx_debug_quota);
24739 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
24740 +EXPORT_SYMBOL_GPL(vx_debug_space);
24741 +EXPORT_SYMBOL_GPL(vx_debug_misc);
24743 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/tag.c linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/tag.c
24744 --- linux-2.6.35.7/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
24745 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/tag.c 2010-08-02 17:05:06.000000000 +0200
24748 + * linux/kernel/vserver/tag.c
24750 + * Virtual Server: Shallow Tag Space
24752 + * Copyright (C) 2007 Herbert Pötzl
24754 + * V0.01 basic implementation
24758 +#include <linux/sched.h>
24759 +#include <linux/vserver/debug.h>
24760 +#include <linux/vs_pid.h>
24761 +#include <linux/vs_tag.h>
24763 +#include <linux/vserver/tag_cmd.h>
24766 +int dx_migrate_task(struct task_struct *p, tag_t tag)
24771 + vxdprintk(VXD_CBIT(tag, 5),
24772 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
24778 + vxdprintk(VXD_CBIT(tag, 5),
24779 + "moved task %p into [#%d]", p, tag);
24783 +/* vserver syscall commands below here */
24785 +/* taks xid and vx_info functions */
24788 +int vc_task_tag(uint32_t id)
24793 + struct task_struct *tsk;
24794 + read_lock(&tasklist_lock);
24795 + tsk = find_task_by_real_pid(id);
24796 + tag = (tsk) ? tsk->tag : -ESRCH;
24797 + read_unlock(&tasklist_lock);
24799 + tag = dx_current_tag();
24804 +int vc_tag_migrate(uint32_t tag)
24806 + return dx_migrate_task(current, tag & 0xFFFF);
24810 diff -NurpP --minimal linux-2.6.35.7/kernel/vserver/vci_config.h linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/vci_config.h
24811 --- linux-2.6.35.7/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
24812 +++ linux-2.6.35.7-vs2.3.0.36.33/kernel/vserver/vci_config.h 2010-08-02 17:05:06.000000000 +0200
24815 +/* interface version */
24817 +#define VCI_VERSION 0x00020306
24821 + VCI_KCBIT_NO_DYNAMIC = 0,
24823 + VCI_KCBIT_PROC_SECURE = 4,
24824 + VCI_KCBIT_HARDCPU = 5,
24825 + VCI_KCBIT_IDLELIMIT = 6,
24826 + VCI_KCBIT_IDLETIME = 7,
24828 + VCI_KCBIT_COWBL = 8,
24829 + VCI_KCBIT_FULLCOWBL = 9,
24830 + VCI_KCBIT_SPACES = 10,
24831 + VCI_KCBIT_NETV2 = 11,
24832 + VCI_KCBIT_MEMCG = 12,
24834 + VCI_KCBIT_DEBUG = 16,
24835 + VCI_KCBIT_HISTORY = 20,
24836 + VCI_KCBIT_TAGGED = 24,
24837 + VCI_KCBIT_PPTAG = 28,
24839 + VCI_KCBIT_MORE = 31,
24843 +static inline uint32_t vci_kernel_config(void)
24846 + (1 << VCI_KCBIT_NO_DYNAMIC) |
24848 + /* configured features */
24849 +#ifdef CONFIG_VSERVER_PROC_SECURE
24850 + (1 << VCI_KCBIT_PROC_SECURE) |
24852 +#ifdef CONFIG_VSERVER_HARDCPU
24853 + (1 << VCI_KCBIT_HARDCPU) |
24855 +#ifdef CONFIG_VSERVER_IDLELIMIT
24856 + (1 << VCI_KCBIT_IDLELIMIT) |
24858 +#ifdef CONFIG_VSERVER_IDLETIME
24859 + (1 << VCI_KCBIT_IDLETIME) |
24861 +#ifdef CONFIG_VSERVER_COWBL
24862 + (1 << VCI_KCBIT_COWBL) |
24863 + (1 << VCI_KCBIT_FULLCOWBL) |
24865 + (1 << VCI_KCBIT_SPACES) |
24866 + (1 << VCI_KCBIT_NETV2) |
24867 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
24868 + (1 << VCI_KCBIT_MEMCG) |
24871 + /* debug options */
24872 +#ifdef CONFIG_VSERVER_DEBUG
24873 + (1 << VCI_KCBIT_DEBUG) |
24875 +#ifdef CONFIG_VSERVER_HISTORY
24876 + (1 << VCI_KCBIT_HISTORY) |
24879 + /* inode context tagging */
24880 +#if defined(CONFIG_TAGGING_NONE)
24881 + (0 << VCI_KCBIT_TAGGED) |
24882 +#elif defined(CONFIG_TAGGING_UID16)
24883 + (1 << VCI_KCBIT_TAGGED) |
24884 +#elif defined(CONFIG_TAGGING_GID16)
24885 + (2 << VCI_KCBIT_TAGGED) |
24886 +#elif defined(CONFIG_TAGGING_ID24)
24887 + (3 << VCI_KCBIT_TAGGED) |
24888 +#elif defined(CONFIG_TAGGING_INTERN)
24889 + (4 << VCI_KCBIT_TAGGED) |
24890 +#elif defined(CONFIG_TAGGING_RUNTIME)
24891 + (5 << VCI_KCBIT_TAGGED) |
24893 + (7 << VCI_KCBIT_TAGGED) |
24895 + (1 << VCI_KCBIT_PPTAG) |
24899 diff -NurpP --minimal linux-2.6.35.7/mm/filemap_xip.c linux-2.6.35.7-vs2.3.0.36.33/mm/filemap_xip.c
24900 --- linux-2.6.35.7/mm/filemap_xip.c 2010-07-07 18:31:58.000000000 +0200
24901 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/filemap_xip.c 2010-08-02 17:05:06.000000000 +0200
24903 #include <linux/seqlock.h>
24904 #include <linux/mutex.h>
24905 #include <linux/gfp.h>
24906 +#include <linux/vs_memory.h>
24907 #include <asm/tlbflush.h>
24908 #include <asm/io.h>
24910 diff -NurpP --minimal linux-2.6.35.7/mm/fremap.c linux-2.6.35.7-vs2.3.0.36.33/mm/fremap.c
24911 --- linux-2.6.35.7/mm/fremap.c 2010-07-07 18:31:58.000000000 +0200
24912 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/fremap.c 2010-08-02 17:05:06.000000000 +0200
24914 #include <linux/module.h>
24915 #include <linux/syscalls.h>
24916 #include <linux/mmu_notifier.h>
24917 +#include <linux/vs_memory.h>
24919 #include <asm/mmu_context.h>
24920 #include <asm/cacheflush.h>
24921 diff -NurpP --minimal linux-2.6.35.7/mm/hugetlb.c linux-2.6.35.7-vs2.3.0.36.33/mm/hugetlb.c
24922 --- linux-2.6.35.7/mm/hugetlb.c 2010-08-02 16:52:58.000000000 +0200
24923 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/hugetlb.c 2010-08-02 17:05:06.000000000 +0200
24926 #include <linux/hugetlb.h>
24927 #include <linux/node.h>
24928 +#include <linux/vs_memory.h>
24929 #include "internal.h"
24931 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
24932 diff -NurpP --minimal linux-2.6.35.7/mm/memcontrol.c linux-2.6.35.7-vs2.3.0.36.33/mm/memcontrol.c
24933 --- linux-2.6.35.7/mm/memcontrol.c 2010-08-02 16:52:58.000000000 +0200
24934 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/memcontrol.c 2010-10-08 11:20:18.000000000 +0200
24935 @@ -635,6 +635,31 @@ struct mem_cgroup *mem_cgroup_from_task(
24936 struct mem_cgroup, css);
24939 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
24941 + return res_counter_read_u64(&mem->res, member);
24944 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
24946 + return res_counter_read_u64(&mem->memsw, member);
24949 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
24951 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
24954 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
24956 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
24959 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
24961 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
24964 static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
24966 struct mem_cgroup *mem = NULL;
24967 diff -NurpP --minimal linux-2.6.35.7/mm/memory.c linux-2.6.35.7-vs2.3.0.36.33/mm/memory.c
24968 --- linux-2.6.35.7/mm/memory.c 2010-10-04 08:57:41.000000000 +0200
24969 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/memory.c 2010-10-05 19:23:43.000000000 +0200
24970 @@ -3145,6 +3145,7 @@ static inline int handle_pte_fault(struc
24974 + int ret = 0, type = VXPT_UNKNOWN;
24977 if (!pte_present(entry)) {
24978 @@ -3169,9 +3170,12 @@ static inline int handle_pte_fault(struc
24979 if (unlikely(!pte_same(*pte, entry)))
24981 if (flags & FAULT_FLAG_WRITE) {
24982 - if (!pte_write(entry))
24983 - return do_wp_page(mm, vma, address,
24984 + if (!pte_write(entry)) {
24985 + ret = do_wp_page(mm, vma, address,
24986 pte, pmd, ptl, entry);
24987 + type = VXPT_WRITE;
24990 entry = pte_mkdirty(entry);
24992 entry = pte_mkyoung(entry);
24993 @@ -3189,7 +3193,10 @@ static inline int handle_pte_fault(struc
24996 pte_unmap_unlock(pte, ptl);
25000 + vx_page_fault(mm, vma, type, ret);
25005 diff -NurpP --minimal linux-2.6.35.7/mm/mlock.c linux-2.6.35.7-vs2.3.0.36.33/mm/mlock.c
25006 --- linux-2.6.35.7/mm/mlock.c 2010-10-04 08:57:41.000000000 +0200
25007 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/mlock.c 2010-09-06 02:59:52.000000000 +0200
25009 #include <linux/rmap.h>
25010 #include <linux/mmzone.h>
25011 #include <linux/hugetlb.h>
25012 +#include <linux/vs_memory.h>
25014 #include "internal.h"
25016 @@ -490,7 +491,7 @@ static int do_mlock(unsigned long start,
25018 SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
25020 - unsigned long locked;
25021 + unsigned long locked, grow;
25022 unsigned long lock_limit;
25023 int error = -ENOMEM;
25025 @@ -512,6 +513,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
25026 /* check against resource limits */
25027 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
25028 error = do_mlock(start, len, 1);
25030 up_write(¤t->mm->mmap_sem);
25033 diff -NurpP --minimal linux-2.6.35.7/mm/mremap.c linux-2.6.35.7-vs2.3.0.36.33/mm/mremap.c
25034 --- linux-2.6.35.7/mm/mremap.c 2010-07-07 18:31:58.000000000 +0200
25035 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/mremap.c 2010-08-02 17:05:06.000000000 +0200
25037 #include <linux/security.h>
25038 #include <linux/syscalls.h>
25039 #include <linux/mmu_notifier.h>
25040 +#include <linux/vs_memory.h>
25042 #include <asm/uaccess.h>
25043 #include <asm/cacheflush.h>
25044 diff -NurpP --minimal linux-2.6.35.7/mm/oom_kill.c linux-2.6.35.7-vs2.3.0.36.33/mm/oom_kill.c
25045 --- linux-2.6.35.7/mm/oom_kill.c 2010-08-02 16:52:58.000000000 +0200
25046 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/oom_kill.c 2010-10-08 11:20:18.000000000 +0200
25048 #include <linux/notifier.h>
25049 #include <linux/memcontrol.h>
25050 #include <linux/security.h>
25051 +#include <linux/reboot.h>
25052 +#include <linux/vs_memory.h>
25053 +#include <linux/vs_context.h>
25055 int sysctl_panic_on_oom;
25056 int sysctl_oom_kill_allocating_task;
25057 @@ -187,9 +190,21 @@ unsigned long badness(struct task_struct
25058 points >>= -(oom_adj);
25062 + * add points for context badness and
25063 + * reduce badness for processes belonging to
25064 + * a different context
25067 + points += vx_badness(p, mm);
25069 + if ((vx_current_xid() > 1) &&
25070 + vx_current_xid() != vx_task_xid(p))
25074 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
25075 - p->pid, p->comm, points);
25076 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
25077 + task_pid_nr(p), p->xid, p->comm, points);
25081 @@ -250,6 +265,7 @@ static struct task_struct *select_bad_pr
25082 struct task_struct *p;
25083 struct task_struct *chosen = NULL;
25084 struct timespec uptime;
25085 + unsigned xid = vx_current_xid();
25088 do_posix_clock_monotonic_gettime(&uptime);
25089 @@ -262,11 +278,14 @@ static struct task_struct *select_bad_pr
25093 - /* skip the init task */
25094 - if (is_global_init(p))
25095 + /* skip the init task, global and per guest */
25096 + if (task_is_init(p))
25098 if (mem && !task_in_mem_cgroup(p, mem))
25100 + /* skip other guest and host processes if oom in guest */
25101 + if (xid && vx_task_xid(p) != xid)
25105 * This task already has access to memory reserves and is
25106 @@ -398,9 +417,9 @@ static void __oom_kill_task(struct task_
25110 - printk(KERN_ERR "Killed process %d (%s) "
25111 + printk(KERN_ERR "Killed process %s(%d:#%u) "
25112 "vsz:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
25113 - task_pid_nr(p), p->comm,
25114 + p->comm, task_pid_nr(p), p->xid,
25115 K(p->mm->total_vm),
25116 K(get_mm_counter(p->mm, MM_ANONPAGES)),
25117 K(get_mm_counter(p->mm, MM_FILEPAGES)));
25118 @@ -453,8 +472,8 @@ static int oom_kill_process(struct task_
25122 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
25123 - message, task_pid_nr(p), p->comm, points);
25124 + printk(KERN_ERR "%s: kill process %s(%d:#%u) score %li or a child\n",
25125 + message, p->comm, task_pid_nr(p), p->xid, points);
25127 /* Try to kill a child first */
25128 list_for_each_entry(c, &p->children, sibling) {
25129 @@ -554,6 +573,8 @@ void clear_zonelist_oom(struct zonelist
25130 spin_unlock(&zone_scan_lock);
25133 +long vs_oom_action(unsigned int);
25136 * Must be called with tasklist_lock held for read.
25138 @@ -580,7 +601,11 @@ retry:
25140 read_unlock(&tasklist_lock);
25141 dump_header(NULL, gfp_mask, order, NULL);
25142 - panic("Out of memory and no killable processes...\n");
25143 + /* avoid panic for guest OOM */
25144 + if (current->xid)
25145 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
25147 + panic("Out of memory and no killable processes...\n");
25150 if (oom_kill_process(p, gfp_mask, order, points, NULL,
25151 diff -NurpP --minimal linux-2.6.35.7/mm/page_alloc.c linux-2.6.35.7-vs2.3.0.36.33/mm/page_alloc.c
25152 --- linux-2.6.35.7/mm/page_alloc.c 2010-10-04 08:57:41.000000000 +0200
25153 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/page_alloc.c 2010-10-05 19:23:43.000000000 +0200
25155 #include <linux/compaction.h>
25156 #include <trace/events/kmem.h>
25157 #include <linux/ftrace_event.h>
25158 +#include <linux/vs_base.h>
25159 +#include <linux/vs_limit.h>
25161 #include <asm/tlbflush.h>
25162 #include <asm/div64.h>
25163 @@ -2318,6 +2320,9 @@ void si_meminfo(struct sysinfo *val)
25164 val->totalhigh = totalhigh_pages;
25165 val->freehigh = nr_free_highpages();
25166 val->mem_unit = PAGE_SIZE;
25168 + if (vx_flags(VXF_VIRT_MEM, 0))
25169 + vx_vsi_meminfo(val);
25172 EXPORT_SYMBOL(si_meminfo);
25173 @@ -2338,6 +2343,9 @@ void si_meminfo_node(struct sysinfo *val
25176 val->mem_unit = PAGE_SIZE;
25178 + if (vx_flags(VXF_VIRT_MEM, 0))
25179 + vx_vsi_meminfo(val);
25183 diff -NurpP --minimal linux-2.6.35.7/mm/rmap.c linux-2.6.35.7-vs2.3.0.36.33/mm/rmap.c
25184 --- linux-2.6.35.7/mm/rmap.c 2010-08-02 16:52:58.000000000 +0200
25185 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/rmap.c 2010-08-02 17:05:06.000000000 +0200
25187 #include <linux/memcontrol.h>
25188 #include <linux/mmu_notifier.h>
25189 #include <linux/migrate.h>
25190 +#include <linux/vs_memory.h>
25192 #include <asm/tlbflush.h>
25194 diff -NurpP --minimal linux-2.6.35.7/mm/shmem.c linux-2.6.35.7-vs2.3.0.36.33/mm/shmem.c
25195 --- linux-2.6.35.7/mm/shmem.c 2010-08-02 16:52:58.000000000 +0200
25196 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/shmem.c 2010-08-02 17:05:06.000000000 +0200
25197 @@ -1788,7 +1788,7 @@ static int shmem_statfs(struct dentry *d
25199 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
25201 - buf->f_type = TMPFS_MAGIC;
25202 + buf->f_type = TMPFS_SUPER_MAGIC;
25203 buf->f_bsize = PAGE_CACHE_SIZE;
25204 buf->f_namelen = NAME_MAX;
25205 spin_lock(&sbinfo->stat_lock);
25206 @@ -2350,7 +2350,7 @@ int shmem_fill_super(struct super_block
25207 sb->s_maxbytes = SHMEM_MAX_BYTES;
25208 sb->s_blocksize = PAGE_CACHE_SIZE;
25209 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
25210 - sb->s_magic = TMPFS_MAGIC;
25211 + sb->s_magic = TMPFS_SUPER_MAGIC;
25212 sb->s_op = &shmem_ops;
25213 sb->s_time_gran = 1;
25214 #ifdef CONFIG_TMPFS_POSIX_ACL
25215 diff -NurpP --minimal linux-2.6.35.7/mm/slab.c linux-2.6.35.7-vs2.3.0.36.33/mm/slab.c
25216 --- linux-2.6.35.7/mm/slab.c 2010-10-04 08:57:41.000000000 +0200
25217 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/slab.c 2010-09-06 02:59:52.000000000 +0200
25218 @@ -408,6 +408,8 @@ static void kmem_list3_init(struct kmem_
25219 #define STATS_INC_FREEMISS(x) do { } while (0)
25222 +#include "slab_vs.h"
25227 @@ -3347,6 +3349,7 @@ retry:
25229 obj = slab_get_obj(cachep, slabp, nodeid);
25230 check_slabp(cachep, slabp);
25231 + vx_slab_alloc(cachep, flags);
25232 l3->free_objects--;
25233 /* move slabp to correct slabp list: */
25234 list_del(&slabp->list);
25235 @@ -3424,6 +3427,7 @@ __cache_alloc_node(struct kmem_cache *ca
25236 /* ___cache_alloc_node can fall back to other nodes */
25237 ptr = ____cache_alloc_node(cachep, flags, nodeid);
25239 + vx_slab_alloc(cachep, flags);
25240 local_irq_restore(save_flags);
25241 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
25242 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
25243 @@ -3610,6 +3614,7 @@ static inline void __cache_free(struct k
25245 kmemleak_free_recursive(objp, cachep->flags);
25246 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
25247 + vx_slab_free(cachep);
25249 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
25251 diff -NurpP --minimal linux-2.6.35.7/mm/slab_vs.h linux-2.6.35.7-vs2.3.0.36.33/mm/slab_vs.h
25252 --- linux-2.6.35.7/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
25253 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/slab_vs.h 2010-08-02 17:05:06.000000000 +0200
25256 +#include <linux/vserver/context.h>
25258 +#include <linux/vs_context.h>
25261 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
25263 + int what = gfp_zone(cachep->gfpflags);
25264 + struct vx_info *vxi = current_vx_info();
25269 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
25273 +void vx_slab_free(struct kmem_cache *cachep)
25275 + int what = gfp_zone(cachep->gfpflags);
25276 + struct vx_info *vxi = current_vx_info();
25281 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
25284 diff -NurpP --minimal linux-2.6.35.7/mm/swapfile.c linux-2.6.35.7-vs2.3.0.36.33/mm/swapfile.c
25285 --- linux-2.6.35.7/mm/swapfile.c 2010-10-04 08:57:41.000000000 +0200
25286 +++ linux-2.6.35.7-vs2.3.0.36.33/mm/swapfile.c 2010-09-22 02:52:29.000000000 +0200
25288 #include <asm/tlbflush.h>
25289 #include <linux/swapops.h>
25290 #include <linux/page_cgroup.h>
25291 +#include <linux/vs_base.h>
25292 +#include <linux/vs_memory.h>
25294 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
25296 @@ -1747,6 +1749,16 @@ static int swap_show(struct seq_file *sw
25298 if (si == SEQ_START_TOKEN) {
25299 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
25300 + if (vx_flags(VXF_VIRT_MEM, 0)) {
25301 + struct sysinfo si;
25303 + vx_vsi_swapinfo(&si);
25304 + if (si.totalswap < (1 << 10))
25306 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
25307 + "hdv0", "partition", si.totalswap >> 10,
25308 + (si.totalswap - si.freeswap) >> 10, -1);
25313 @@ -2131,6 +2143,8 @@ void si_swapinfo(struct sysinfo *val)
25314 val->freeswap = nr_swap_pages + nr_to_be_unused;
25315 val->totalswap = total_swap_pages + nr_to_be_unused;
25316 spin_unlock(&swap_lock);
25317 + if (vx_flags(VXF_VIRT_MEM, 0))
25318 + vx_vsi_swapinfo(val);
25322 diff -NurpP --minimal linux-2.6.35.7/net/core/dev.c linux-2.6.35.7-vs2.3.0.36.33/net/core/dev.c
25323 --- linux-2.6.35.7/net/core/dev.c 2010-10-04 08:57:41.000000000 +0200
25324 +++ linux-2.6.35.7-vs2.3.0.36.33/net/core/dev.c 2010-09-06 02:59:52.000000000 +0200
25325 @@ -129,6 +129,7 @@
25326 #include <linux/in.h>
25327 #include <linux/jhash.h>
25328 #include <linux/random.h>
25329 +#include <linux/vs_inet.h>
25330 #include <trace/events/napi.h>
25331 #include <linux/pci.h>
25333 @@ -609,7 +610,8 @@ struct net_device *__dev_get_by_name(str
25334 struct hlist_head *head = dev_name_hash(net, name);
25336 hlist_for_each_entry(dev, p, head, name_hlist)
25337 - if (!strncmp(dev->name, name, IFNAMSIZ))
25338 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
25339 + nx_dev_visible(current_nx_info(), dev))
25343 @@ -635,7 +637,8 @@ struct net_device *dev_get_by_name_rcu(s
25344 struct hlist_head *head = dev_name_hash(net, name);
25346 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
25347 - if (!strncmp(dev->name, name, IFNAMSIZ))
25348 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
25349 + nx_dev_visible(current_nx_info(), dev))
25353 @@ -686,7 +689,8 @@ struct net_device *__dev_get_by_index(st
25354 struct hlist_head *head = dev_index_hash(net, ifindex);
25356 hlist_for_each_entry(dev, p, head, index_hlist)
25357 - if (dev->ifindex == ifindex)
25358 + if ((dev->ifindex == ifindex) &&
25359 + nx_dev_visible(current_nx_info(), dev))
25363 @@ -711,7 +715,8 @@ struct net_device *dev_get_by_index_rcu(
25364 struct hlist_head *head = dev_index_hash(net, ifindex);
25366 hlist_for_each_entry_rcu(dev, p, head, index_hlist)
25367 - if (dev->ifindex == ifindex)
25368 + if ((dev->ifindex == ifindex) &&
25369 + nx_dev_visible(current_nx_info(), dev))
25373 @@ -764,10 +769,12 @@ struct net_device *dev_getbyhwaddr(struc
25377 - for_each_netdev(net, dev)
25378 + for_each_netdev(net, dev) {
25379 if (dev->type == type &&
25380 - !memcmp(dev->dev_addr, ha, dev->addr_len))
25381 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
25382 + nx_dev_visible(current_nx_info(), dev))
25388 @@ -778,9 +785,11 @@ struct net_device *__dev_getfirstbyhwtyp
25389 struct net_device *dev;
25392 - for_each_netdev(net, dev)
25393 - if (dev->type == type)
25394 + for_each_netdev(net, dev) {
25395 + if ((dev->type == type) &&
25396 + nx_dev_visible(current_nx_info(), dev))
25402 @@ -902,6 +911,8 @@ static int __dev_alloc_name(struct net *
25404 if (i < 0 || i >= max_netdevices)
25406 + if (!nx_dev_visible(current_nx_info(), d))
25409 /* avoid cases where sscanf is not exact inverse of printf */
25410 snprintf(buf, IFNAMSIZ, name, i);
25411 @@ -3650,6 +3661,8 @@ static int dev_ifconf(struct net *net, c
25414 for_each_netdev(net, dev) {
25415 + if (!nx_dev_visible(current_nx_info(), dev))
25417 for (i = 0; i < NPROTO; i++) {
25418 if (gifconf_list[i]) {
25420 @@ -3720,6 +3733,9 @@ static void dev_seq_printf_stats(struct
25422 const struct net_device_stats *stats = dev_get_stats(dev);
25424 + if (!nx_dev_visible(current_nx_info(), dev))
25427 seq_printf(seq, "%6s: %7lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
25428 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
25429 dev->name, stats->rx_bytes, stats->rx_packets,
25430 diff -NurpP --minimal linux-2.6.35.7/net/core/rtnetlink.c linux-2.6.35.7-vs2.3.0.36.33/net/core/rtnetlink.c
25431 --- linux-2.6.35.7/net/core/rtnetlink.c 2010-08-02 16:52:59.000000000 +0200
25432 +++ linux-2.6.35.7-vs2.3.0.36.33/net/core/rtnetlink.c 2010-08-02 17:05:06.000000000 +0200
25433 @@ -926,6 +926,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
25434 hlist_for_each_entry(dev, node, head, index_hlist) {
25437 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
25439 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
25440 NETLINK_CB(cb->skb).pid,
25441 cb->nlh->nlmsg_seq, 0,
25442 @@ -1642,6 +1644,9 @@ void rtmsg_ifinfo(int type, struct net_d
25443 struct sk_buff *skb;
25444 int err = -ENOBUFS;
25446 + if (!nx_dev_visible(current_nx_info(), dev))
25449 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
25452 diff -NurpP --minimal linux-2.6.35.7/net/core/sock.c linux-2.6.35.7-vs2.3.0.36.33/net/core/sock.c
25453 --- linux-2.6.35.7/net/core/sock.c 2010-08-02 16:52:59.000000000 +0200
25454 +++ linux-2.6.35.7-vs2.3.0.36.33/net/core/sock.c 2010-08-02 17:05:06.000000000 +0200
25455 @@ -126,6 +126,10 @@
25456 #include <net/cls_cgroup.h>
25458 #include <linux/filter.h>
25459 +#include <linux/vs_socket.h>
25460 +#include <linux/vs_limit.h>
25461 +#include <linux/vs_context.h>
25462 +#include <linux/vs_network.h>
25465 #include <net/tcp.h>
25466 @@ -1027,6 +1031,8 @@ static struct sock *sk_prot_alloc(struct
25468 sk_tx_queue_clear(sk);
25470 + sock_vx_init(sk);
25471 + sock_nx_init(sk);
25475 @@ -1120,6 +1126,11 @@ static void __sk_free(struct sock *sk)
25476 __func__, atomic_read(&sk->sk_omem_alloc));
25478 put_net(sock_net(sk));
25480 + clr_vx_info(&sk->sk_vx_info);
25482 + clr_nx_info(&sk->sk_nx_info);
25484 sk_prot_free(sk->sk_prot_creator, sk);
25487 @@ -1167,6 +1178,8 @@ struct sock *sk_clone(const struct sock
25490 get_net(sock_net(newsk));
25491 + sock_vx_init(newsk);
25492 + sock_nx_init(newsk);
25493 sk_node_init(&newsk->sk_node);
25494 sock_lock_init(newsk);
25495 bh_lock_sock(newsk);
25496 @@ -1222,6 +1235,12 @@ struct sock *sk_clone(const struct sock
25498 atomic_set(&newsk->sk_refcnt, 2);
25500 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
25501 + newsk->sk_xid = sk->sk_xid;
25502 + vx_sock_inc(newsk);
25503 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
25504 + newsk->sk_nid = sk->sk_nid;
25507 * Increment the counter in the same struct proto as the master
25508 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
25509 @@ -1964,6 +1983,12 @@ void sock_init_data(struct socket *sock,
25511 sk->sk_stamp = ktime_set(-1L, 0);
25513 + set_vx_info(&sk->sk_vx_info, current_vx_info());
25514 + sk->sk_xid = vx_current_xid();
25516 + set_nx_info(&sk->sk_nx_info, current_nx_info());
25517 + sk->sk_nid = nx_current_nid();
25520 * Before updating sk_refcnt, we must commit prior changes to memory
25521 * (Documentation/RCU/rculist_nulls.txt for details)
25522 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/af_inet.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/af_inet.c
25523 --- linux-2.6.35.7/net/ipv4/af_inet.c 2010-08-02 16:52:59.000000000 +0200
25524 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/af_inet.c 2010-08-02 17:05:06.000000000 +0200
25525 @@ -116,6 +116,7 @@
25526 #ifdef CONFIG_IP_MROUTE
25527 #include <linux/mroute.h>
25529 +#include <linux/vs_limit.h>
25532 /* The inetsw table contains everything that inet_create needs to
25533 @@ -327,9 +328,13 @@ lookup_protocol:
25537 + if ((protocol == IPPROTO_ICMP) &&
25538 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25541 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25542 goto out_rcu_unlock;
25545 err = -EAFNOSUPPORT;
25546 if (!inet_netns_ok(net, protocol))
25547 goto out_rcu_unlock;
25548 @@ -451,6 +456,7 @@ int inet_bind(struct socket *sock, struc
25549 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
25550 struct sock *sk = sock->sk;
25551 struct inet_sock *inet = inet_sk(sk);
25552 + struct nx_v4_sock_addr nsa;
25553 unsigned short snum;
25556 @@ -464,7 +470,11 @@ int inet_bind(struct socket *sock, struc
25557 if (addr_len < sizeof(struct sockaddr_in))
25560 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25561 + err = v4_map_sock_addr(inet, addr, &nsa);
25565 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25567 /* Not specified by any standard per-se, however it breaks too
25568 * many applications when removed. It is unfortunate since
25569 @@ -476,7 +486,7 @@ int inet_bind(struct socket *sock, struc
25570 err = -EADDRNOTAVAIL;
25571 if (!sysctl_ip_nonlocal_bind &&
25572 !(inet->freebind || inet->transparent) &&
25573 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
25574 + nsa.saddr != htonl(INADDR_ANY) &&
25575 chk_addr_ret != RTN_LOCAL &&
25576 chk_addr_ret != RTN_MULTICAST &&
25577 chk_addr_ret != RTN_BROADCAST)
25578 @@ -501,7 +511,7 @@ int inet_bind(struct socket *sock, struc
25579 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
25580 goto out_release_sock;
25582 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
25583 + v4_set_sock_addr(inet, &nsa);
25584 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25585 inet->inet_saddr = 0; /* Use device */
25587 @@ -703,11 +713,13 @@ int inet_getname(struct socket *sock, st
25590 sin->sin_port = inet->inet_dport;
25591 - sin->sin_addr.s_addr = inet->inet_daddr;
25592 + sin->sin_addr.s_addr =
25593 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
25595 __be32 addr = inet->inet_rcv_saddr;
25597 addr = inet->inet_saddr;
25598 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
25599 sin->sin_port = inet->inet_sport;
25600 sin->sin_addr.s_addr = addr;
25602 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/devinet.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/devinet.c
25603 --- linux-2.6.35.7/net/ipv4/devinet.c 2010-10-04 08:57:41.000000000 +0200
25604 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/devinet.c 2010-08-14 18:19:32.000000000 +0200
25605 @@ -417,6 +417,7 @@ struct in_device *inetdev_by_index(struc
25607 EXPORT_SYMBOL(inetdev_by_index);
25610 /* Called only from RTNL semaphored context. No locks. */
25612 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
25613 @@ -659,6 +660,8 @@ int devinet_ioctl(struct net *net, unsig
25615 in_dev = __in_dev_get_rtnl(dev);
25617 + struct nx_info *nxi = current_nx_info();
25619 if (tryaddrmatch) {
25620 /* Matthias Andree */
25621 /* compare label and address (4.4BSD style) */
25622 @@ -667,6 +670,8 @@ int devinet_ioctl(struct net *net, unsig
25623 This is checked above. */
25624 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
25625 ifap = &ifa->ifa_next) {
25626 + if (!nx_v4_ifa_visible(nxi, ifa))
25628 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
25629 sin_orig.sin_addr.s_addr ==
25630 ifa->ifa_address) {
25631 @@ -679,9 +684,12 @@ int devinet_ioctl(struct net *net, unsig
25632 comparing just the label */
25634 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
25635 - ifap = &ifa->ifa_next)
25636 + ifap = &ifa->ifa_next) {
25637 + if (!nx_v4_ifa_visible(nxi, ifa))
25639 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
25645 @@ -833,6 +841,8 @@ static int inet_gifconf(struct net_devic
25648 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
25649 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
25652 done += sizeof(ifr);
25654 @@ -1182,6 +1192,7 @@ static int inet_dump_ifaddr(struct sk_bu
25655 struct net_device *dev;
25656 struct in_device *in_dev;
25657 struct in_ifaddr *ifa;
25658 + struct sock *sk = skb->sk;
25659 struct hlist_head *head;
25660 struct hlist_node *node;
25662 @@ -1204,6 +1215,8 @@ static int inet_dump_ifaddr(struct sk_bu
25664 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
25665 ifa = ifa->ifa_next, ip_idx++) {
25666 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
25668 if (ip_idx < s_ip_idx)
25670 if (inet_fill_ifaddr(skb, ifa,
25671 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/fib_hash.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/fib_hash.c
25672 --- linux-2.6.35.7/net/ipv4/fib_hash.c 2010-07-07 18:31:59.000000000 +0200
25673 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/fib_hash.c 2010-08-02 17:05:06.000000000 +0200
25674 @@ -1017,7 +1017,7 @@ static int fib_seq_show(struct seq_file
25675 prefix = f->fn_key;
25676 mask = FZ_MASK(iter->zone);
25677 flags = fib_flag_trans(fa->fa_type, mask, fi);
25679 + if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
25681 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
25682 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
25683 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/inet_connection_sock.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/inet_connection_sock.c
25684 --- linux-2.6.35.7/net/ipv4/inet_connection_sock.c 2010-08-02 16:52:59.000000000 +0200
25685 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/inet_connection_sock.c 2010-08-02 17:05:06.000000000 +0200
25686 @@ -52,10 +52,40 @@ void inet_get_local_port_range(int *low,
25688 EXPORT_SYMBOL(inet_get_local_port_range);
25690 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25692 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
25693 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
25695 + if (inet_v6_ipv6only(sk2))
25698 + if (sk1_rcv_saddr &&
25700 + sk1_rcv_saddr == sk2_rcv_saddr)
25703 + if (sk1_rcv_saddr &&
25704 + !sk2_rcv_saddr &&
25705 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
25708 + if (sk2_rcv_saddr &&
25709 + !sk1_rcv_saddr &&
25710 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
25713 + if (!sk1_rcv_saddr &&
25714 + !sk2_rcv_saddr &&
25715 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
25721 int inet_csk_bind_conflict(const struct sock *sk,
25722 const struct inet_bind_bucket *tb)
25724 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
25726 struct hlist_node *node;
25727 int reuse = sk->sk_reuse;
25728 @@ -75,9 +105,7 @@ int inet_csk_bind_conflict(const struct
25729 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
25730 if (!reuse || !sk2->sk_reuse ||
25731 sk2->sk_state == TCP_LISTEN) {
25732 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
25733 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
25734 - sk2_rcv_saddr == sk_rcv_saddr)
25735 + if (ipv4_rcv_saddr_equal(sk, sk2))
25739 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/inet_diag.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/inet_diag.c
25740 --- linux-2.6.35.7/net/ipv4/inet_diag.c 2010-07-07 18:31:59.000000000 +0200
25741 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/inet_diag.c 2010-08-02 17:05:06.000000000 +0200
25743 #include <linux/stddef.h>
25745 #include <linux/inet_diag.h>
25746 +#include <linux/vs_network.h>
25747 +#include <linux/vs_inet.h>
25749 static const struct inet_diag_handler **inet_diag_table;
25751 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
25753 r->id.idiag_sport = inet->inet_sport;
25754 r->id.idiag_dport = inet->inet_dport;
25755 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
25756 - r->id.idiag_dst[0] = inet->inet_daddr;
25757 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
25758 + inet->inet_rcv_saddr);
25759 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
25760 + inet->inet_daddr);
25762 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25763 if (r->idiag_family == AF_INET6) {
25764 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
25765 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
25766 r->id.idiag_sport = tw->tw_sport;
25767 r->id.idiag_dport = tw->tw_dport;
25768 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
25769 - r->id.idiag_dst[0] = tw->tw_daddr;
25770 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
25771 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
25772 r->idiag_state = tw->tw_substate;
25773 r->idiag_timer = 3;
25774 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
25775 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
25778 if (req->idiag_family == AF_INET) {
25779 + /* TODO: lback */
25780 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
25781 req->id.idiag_dport, req->id.idiag_src[0],
25782 req->id.idiag_sport, req->id.idiag_if);
25783 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
25787 + /* TODO: lback */
25788 entry.saddr = &inet->inet_rcv_saddr;
25789 entry.daddr = &inet->inet_daddr;
25791 @@ -541,6 +547,7 @@ static int inet_twsk_diag_dump(struct in
25795 + /* TODO: lback */
25796 entry.saddr = &tw->tw_rcv_saddr;
25797 entry.daddr = &tw->tw_daddr;
25799 @@ -587,8 +594,8 @@ static int inet_diag_fill_req(struct sk_
25801 r->id.idiag_sport = inet->inet_sport;
25802 r->id.idiag_dport = ireq->rmt_port;
25803 - r->id.idiag_src[0] = ireq->loc_addr;
25804 - r->id.idiag_dst[0] = ireq->rmt_addr;
25805 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
25806 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
25807 r->idiag_expires = jiffies_to_msecs(tmo);
25808 r->idiag_rqueue = 0;
25809 r->idiag_wqueue = 0;
25810 @@ -658,6 +665,7 @@ static int inet_diag_dump_reqs(struct sk
25814 + /* TODO: lback */
25816 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25817 (entry.family == AF_INET6) ?
25818 @@ -728,6 +736,8 @@ static int inet_diag_dump(struct sk_buff
25819 sk_nulls_for_each(sk, node, &ilb->head) {
25820 struct inet_sock *inet = inet_sk(sk);
25822 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25827 @@ -794,6 +804,8 @@ skip_listen_ht:
25828 sk_nulls_for_each(sk, node, &head->chain) {
25829 struct inet_sock *inet = inet_sk(sk);
25831 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25835 if (!(r->idiag_states & (1 << sk->sk_state)))
25836 @@ -818,6 +830,8 @@ next_normal:
25837 inet_twsk_for_each(tw, node,
25840 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25844 if (r->id.idiag_sport != tw->tw_sport &&
25845 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/inet_hashtables.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/inet_hashtables.c
25846 --- linux-2.6.35.7/net/ipv4/inet_hashtables.c 2010-08-02 16:52:59.000000000 +0200
25847 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/inet_hashtables.c 2010-08-02 17:05:06.000000000 +0200
25850 #include <net/inet_connection_sock.h>
25851 #include <net/inet_hashtables.h>
25852 +#include <net/route.h>
25853 #include <net/ip.h>
25856 @@ -134,6 +135,11 @@ static inline int compute_score(struct s
25857 if (rcv_saddr != daddr)
25861 + /* block non nx_info ips */
25862 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25863 + daddr, NXA_MASK_BIND))
25866 if (sk->sk_bound_dev_if) {
25867 if (sk->sk_bound_dev_if != dif)
25868 @@ -151,7 +157,6 @@ static inline int compute_score(struct s
25869 * wildcarded during the search since they can never be otherwise.
25873 struct sock *__inet_lookup_listener(struct net *net,
25874 struct inet_hashinfo *hashinfo,
25875 const __be32 daddr, const unsigned short hnum,
25876 @@ -174,6 +179,7 @@ begin:
25882 * if the nulls value we got at the end of this lookup is
25883 * not the expected one, we must restart lookup.
25884 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/netfilter/nf_nat_helper.c
25885 --- linux-2.6.35.7/net/ipv4/netfilter/nf_nat_helper.c 2010-07-07 18:31:59.000000000 +0200
25886 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/netfilter/nf_nat_helper.c 2010-08-02 17:05:06.000000000 +0200
25888 #include <net/route.h>
25890 #include <linux/netfilter_ipv4.h>
25891 +#include <net/route.h>
25892 #include <net/netfilter/nf_conntrack.h>
25893 #include <net/netfilter/nf_conntrack_helper.h>
25894 #include <net/netfilter/nf_conntrack_ecache.h>
25895 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/netfilter.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/netfilter.c
25896 --- linux-2.6.35.7/net/ipv4/netfilter.c 2010-08-02 16:52:59.000000000 +0200
25897 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/netfilter.c 2010-08-02 17:05:06.000000000 +0200
25899 #include <linux/ip.h>
25900 #include <linux/skbuff.h>
25901 #include <linux/gfp.h>
25902 -#include <net/route.h>
25903 +// #include <net/route.h>
25904 #include <net/xfrm.h>
25905 #include <net/ip.h>
25906 #include <net/netfilter/nf_queue.h>
25907 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/raw.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/raw.c
25908 --- linux-2.6.35.7/net/ipv4/raw.c 2010-08-02 16:52:59.000000000 +0200
25909 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/raw.c 2010-08-02 18:19:23.000000000 +0200
25910 @@ -116,7 +116,7 @@ static struct sock *__raw_v4_lookup(stru
25912 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
25913 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
25914 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
25915 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
25916 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
25917 goto found; /* gotcha */
25919 @@ -381,6 +381,12 @@ static int raw_send_hdrinc(struct sock *
25920 icmp_out_count(net, ((struct icmphdr *)
25921 skb_transport_header(skb))->type);
25924 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
25925 + sk->sk_nx_info &&
25926 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
25929 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
25930 rt->u.dst.dev, dst_output);
25932 @@ -561,6 +567,13 @@ static int raw_sendmsg(struct kiocb *ioc
25935 security_sk_classify_flow(sk, &fl);
25936 + if (sk->sk_nx_info) {
25937 + err = ip_v4_find_src(sock_net(sk),
25938 + sk->sk_nx_info, &rt, &fl);
25943 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
25946 @@ -633,17 +646,19 @@ static int raw_bind(struct sock *sk, str
25948 struct inet_sock *inet = inet_sk(sk);
25949 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
25950 + struct nx_v4_sock_addr nsa = { 0 };
25954 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
25956 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25957 + v4_map_sock_addr(inet, addr, &nsa);
25958 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25959 ret = -EADDRNOTAVAIL;
25960 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
25961 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
25962 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
25964 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
25965 + v4_set_sock_addr(inet, &nsa);
25966 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25967 inet->inet_saddr = 0; /* Use device */
25969 @@ -695,7 +710,8 @@ static int raw_recvmsg(struct kiocb *ioc
25970 /* Copy the address. */
25972 sin->sin_family = AF_INET;
25973 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25974 + sin->sin_addr.s_addr =
25975 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
25977 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
25979 @@ -873,7 +889,8 @@ static struct sock *raw_get_first(struct
25980 struct hlist_node *node;
25982 sk_for_each(sk, node, &state->h->ht[state->bucket])
25983 - if (sock_net(sk) == seq_file_net(seq))
25984 + if ((sock_net(sk) == seq_file_net(seq)) &&
25985 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25989 @@ -889,7 +906,8 @@ static struct sock *raw_get_next(struct
25993 - } while (sk && sock_net(sk) != seq_file_net(seq));
25994 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
25995 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25997 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
25998 sk = sk_head(&state->h->ht[state->bucket]);
25999 @@ -948,7 +966,10 @@ static void raw_sock_seq_show(struct seq
26001 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
26002 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
26003 - i, src, srcp, dest, destp, sp->sk_state,
26005 + nx_map_sock_lback(current_nx_info(), src), srcp,
26006 + nx_map_sock_lback(current_nx_info(), dest), destp,
26008 sk_wmem_alloc_get(sp),
26009 sk_rmem_alloc_get(sp),
26010 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
26011 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/tcp.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/tcp.c
26012 --- linux-2.6.35.7/net/ipv4/tcp.c 2010-10-04 08:57:41.000000000 +0200
26013 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/tcp.c 2010-10-05 19:23:43.000000000 +0200
26014 @@ -266,6 +266,7 @@
26015 #include <linux/crypto.h>
26016 #include <linux/time.h>
26017 #include <linux/slab.h>
26018 +#include <linux/in.h>
26020 #include <net/icmp.h>
26021 #include <net/tcp.h>
26022 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/tcp_ipv4.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/tcp_ipv4.c
26023 --- linux-2.6.35.7/net/ipv4/tcp_ipv4.c 2010-08-02 16:52:59.000000000 +0200
26024 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/tcp_ipv4.c 2010-08-02 17:05:06.000000000 +0200
26025 @@ -2004,6 +2004,12 @@ static void *listening_get_next(struct s
26026 req = req->dl_next;
26029 + vxdprintk(VXD_CBIT(net, 6),
26030 + "sk,req: %p [#%d] (from %d)", req->sk,
26031 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
26033 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
26035 if (req->rsk_ops->family == st->family) {
26038 @@ -2028,6 +2034,10 @@ get_req:
26041 sk_nulls_for_each_from(sk, node) {
26042 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
26043 + sk, sk->sk_nid, nx_current_nid());
26044 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26046 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
26049 @@ -2091,6 +2101,11 @@ static void *established_get_first(struc
26051 spin_lock_bh(lock);
26052 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
26053 + vxdprintk(VXD_CBIT(net, 6),
26054 + "sk,egf: %p [#%d] (from %d)",
26055 + sk, sk->sk_nid, nx_current_nid());
26056 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26058 if (sk->sk_family != st->family ||
26059 !net_eq(sock_net(sk), net)) {
26061 @@ -2101,6 +2116,11 @@ static void *established_get_first(struc
26062 st->state = TCP_SEQ_STATE_TIME_WAIT;
26063 inet_twsk_for_each(tw, node,
26064 &tcp_hashinfo.ehash[st->bucket].twchain) {
26065 + vxdprintk(VXD_CBIT(net, 6),
26066 + "tw: %p [#%d] (from %d)",
26067 + tw, tw->tw_nid, nx_current_nid());
26068 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26070 if (tw->tw_family != st->family ||
26071 !net_eq(twsk_net(tw), net)) {
26073 @@ -2129,7 +2149,9 @@ static void *established_get_next(struct
26077 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
26078 + while (tw && (tw->tw_family != st->family ||
26079 + !net_eq(twsk_net(tw), net) ||
26080 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
26084 @@ -2152,6 +2174,11 @@ get_tw:
26085 sk = sk_nulls_next(sk);
26087 sk_nulls_for_each_from(sk, node) {
26088 + vxdprintk(VXD_CBIT(net, 6),
26089 + "sk,egn: %p [#%d] (from %d)",
26090 + sk, sk->sk_nid, nx_current_nid());
26091 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26093 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
26096 @@ -2303,9 +2330,9 @@ static void get_openreq4(struct sock *sk
26097 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
26098 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
26101 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
26102 ntohs(inet_sk(sk)->inet_sport),
26104 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
26105 ntohs(ireq->rmt_port),
26107 0, 0, /* could print option size, but that is af dependent. */
26108 @@ -2357,7 +2384,10 @@ static void get_tcp4_sock(struct sock *s
26110 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
26111 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
26112 - i, src, srcp, dest, destp, sk->sk_state,
26114 + nx_map_sock_lback(current_nx_info(), src), srcp,
26115 + nx_map_sock_lback(current_nx_info(), dest), destp,
26117 tp->write_seq - tp->snd_una,
26120 @@ -2392,7 +2422,10 @@ static void get_timewait4_sock(struct in
26122 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
26123 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
26124 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
26126 + nx_map_sock_lback(current_nx_info(), src), srcp,
26127 + nx_map_sock_lback(current_nx_info(), dest), destp,
26128 + tw->tw_substate, 0, 0,
26129 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
26130 atomic_read(&tw->tw_refcnt), tw, len);
26132 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/tcp_minisocks.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/tcp_minisocks.c
26133 --- linux-2.6.35.7/net/ipv4/tcp_minisocks.c 2010-08-02 16:52:59.000000000 +0200
26134 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/tcp_minisocks.c 2010-08-02 17:05:06.000000000 +0200
26136 #include <linux/slab.h>
26137 #include <linux/sysctl.h>
26138 #include <linux/workqueue.h>
26139 +#include <linux/vs_limit.h>
26140 +#include <linux/vs_socket.h>
26141 +#include <linux/vs_context.h>
26142 #include <net/tcp.h>
26143 #include <net/inet_common.h>
26144 #include <net/xfrm.h>
26145 @@ -290,6 +293,11 @@ void tcp_time_wait(struct sock *sk, int
26146 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
26147 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
26149 + tw->tw_xid = sk->sk_xid;
26150 + tw->tw_vx_info = NULL;
26151 + tw->tw_nid = sk->sk_nid;
26152 + tw->tw_nx_info = NULL;
26154 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
26155 if (tw->tw_family == PF_INET6) {
26156 struct ipv6_pinfo *np = inet6_sk(sk);
26157 diff -NurpP --minimal linux-2.6.35.7/net/ipv4/udp.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/udp.c
26158 --- linux-2.6.35.7/net/ipv4/udp.c 2010-10-04 08:57:41.000000000 +0200
26159 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv4/udp.c 2010-10-05 19:23:43.000000000 +0200
26160 @@ -296,14 +296,7 @@ fail:
26162 EXPORT_SYMBOL(udp_lib_get_port);
26164 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26166 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
26168 - return (!ipv6_only_sock(sk2) &&
26169 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
26170 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
26172 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
26174 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
26176 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
26177 if (inet->inet_rcv_saddr != daddr)
26181 + /* block non nx_info ips */
26182 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
26183 + daddr, NXA_MASK_BIND))
26186 if (inet->inet_daddr) {
26187 if (inet->inet_daddr != saddr)
26188 @@ -441,6 +439,7 @@ exact_match:
26193 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
26194 * harder than this. -DaveM
26196 @@ -486,6 +485,11 @@ begin:
26197 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
26198 score = compute_score(sk, net, saddr, hnum, sport,
26199 daddr, dport, dif);
26200 + /* FIXME: disabled?
26201 + if (score == 9) {
26205 if (score > badness) {
26208 @@ -499,6 +503,7 @@ begin:
26209 if (get_nulls_value(node) != slot)
26214 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
26216 @@ -508,6 +513,7 @@ begin:
26224 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
26225 udp_sk(s)->udp_port_hash != hnum ||
26226 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
26227 (inet->inet_dport != rmt_port && inet->inet_dport) ||
26228 - (inet->inet_rcv_saddr &&
26229 - inet->inet_rcv_saddr != loc_addr) ||
26230 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
26231 ipv6_only_sock(s) ||
26232 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
26234 @@ -900,8 +905,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
26235 { .sport = inet->inet_sport,
26236 .dport = dport } } };
26237 struct net *net = sock_net(sk);
26238 + struct nx_info *nxi = sk->sk_nx_info;
26240 security_sk_classify_flow(sk, &fl);
26241 + err = ip_v4_find_src(net, nxi, &rt, &fl);
26245 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
26247 if (err == -ENETUNREACH)
26248 @@ -1183,7 +1193,8 @@ try_again:
26250 sin->sin_family = AF_INET;
26251 sin->sin_port = udp_hdr(skb)->source;
26252 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
26253 + sin->sin_addr.s_addr = nx_map_sock_lback(
26254 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
26255 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
26257 if (inet->cmsg_flags)
26258 @@ -1923,6 +1934,8 @@ static struct sock *udp_get_first(struct
26259 sk_nulls_for_each(sk, node, &hslot->head) {
26260 if (!net_eq(sock_net(sk), net))
26262 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26264 if (sk->sk_family == state->family)
26267 @@ -1940,7 +1953,9 @@ static struct sock *udp_get_next(struct
26270 sk = sk_nulls_next(sk);
26271 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
26272 + } while (sk && (!net_eq(sock_net(sk), net) ||
26273 + sk->sk_family != state->family ||
26274 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
26277 if (state->bucket <= state->udp_table->mask)
26278 @@ -2047,7 +2062,10 @@ static void udp4_format_sock(struct sock
26280 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
26281 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
26282 - bucket, src, srcp, dest, destp, sp->sk_state,
26284 + nx_map_sock_lback(current_nx_info(), src), srcp,
26285 + nx_map_sock_lback(current_nx_info(), dest), destp,
26287 sk_wmem_alloc_get(sp),
26288 sk_rmem_alloc_get(sp),
26289 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
26290 diff -NurpP --minimal linux-2.6.35.7/net/ipv6/addrconf.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/addrconf.c
26291 --- linux-2.6.35.7/net/ipv6/addrconf.c 2010-08-02 16:52:59.000000000 +0200
26292 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/addrconf.c 2010-08-02 17:05:06.000000000 +0200
26295 #include <linux/proc_fs.h>
26296 #include <linux/seq_file.h>
26297 +#include <linux/vs_network.h>
26298 +#include <linux/vs_inet6.h>
26300 /* Set to 3 to get tracing... */
26301 #define ACONF_DEBUG 2
26302 @@ -1117,7 +1119,7 @@ out:
26304 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
26305 const struct in6_addr *daddr, unsigned int prefs,
26306 - struct in6_addr *saddr)
26307 + struct in6_addr *saddr, struct nx_info *nxi)
26309 struct ipv6_saddr_score scores[2],
26310 *score = &scores[0], *hiscore = &scores[1];
26311 @@ -1189,6 +1191,8 @@ int ipv6_dev_get_saddr(struct net *net,
26315 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
26319 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
26320 @@ -3074,7 +3078,10 @@ static void if6_seq_stop(struct seq_file
26321 static int if6_seq_show(struct seq_file *seq, void *v)
26323 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
26324 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
26326 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
26327 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
26328 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
26330 ifp->idev->dev->ifindex,
26332 @@ -3578,6 +3585,11 @@ static int in6_dump_addrs(struct inet6_d
26333 struct ifacaddr6 *ifaca;
26335 int ip_idx = *p_ip_idx;
26336 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
26338 + /* disable ipv6 on non v6 guests */
26339 + if (nxi && !nx_info_has_v6(nxi))
26342 read_lock_bh(&idev->lock);
26344 @@ -3588,6 +3600,8 @@ static int in6_dump_addrs(struct inet6_d
26345 list_for_each_entry(ifa, &idev->addr_list, if_list) {
26346 if (++ip_idx < s_ip_idx)
26348 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
26350 err = inet6_fill_ifaddr(skb, ifa,
26351 NETLINK_CB(cb->skb).pid,
26352 cb->nlh->nlmsg_seq,
26353 @@ -3604,6 +3618,8 @@ static int in6_dump_addrs(struct inet6_d
26354 ifmca = ifmca->next, ip_idx++) {
26355 if (ip_idx < s_ip_idx)
26357 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
26359 err = inet6_fill_ifmcaddr(skb, ifmca,
26360 NETLINK_CB(cb->skb).pid,
26361 cb->nlh->nlmsg_seq,
26362 @@ -3619,6 +3635,8 @@ static int in6_dump_addrs(struct inet6_d
26363 ifaca = ifaca->aca_next, ip_idx++) {
26364 if (ip_idx < s_ip_idx)
26366 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
26368 err = inet6_fill_ifacaddr(skb, ifaca,
26369 NETLINK_CB(cb->skb).pid,
26370 cb->nlh->nlmsg_seq,
26371 @@ -3950,6 +3968,11 @@ static int inet6_dump_ifinfo(struct sk_b
26372 struct inet6_dev *idev;
26373 struct hlist_head *head;
26374 struct hlist_node *node;
26375 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
26377 + /* FIXME: maybe disable ipv6 on non v6 guests?
26378 + if (skb->sk && skb->sk->sk_vx_info)
26379 + return skb->len; */
26382 s_idx = cb->args[1];
26383 @@ -3961,6 +3984,8 @@ static int inet6_dump_ifinfo(struct sk_b
26384 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
26387 + if (!v6_dev_in_nx_info(dev, nxi))
26389 idev = __in6_dev_get(dev);
26392 diff -NurpP --minimal linux-2.6.35.7/net/ipv6/af_inet6.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/af_inet6.c
26393 --- linux-2.6.35.7/net/ipv6/af_inet6.c 2010-08-02 16:52:59.000000000 +0200
26394 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/af_inet6.c 2010-08-02 17:05:06.000000000 +0200
26396 #include <linux/netdevice.h>
26397 #include <linux/icmpv6.h>
26398 #include <linux/netfilter_ipv6.h>
26399 +#include <linux/vs_inet.h>
26400 +#include <linux/vs_inet6.h>
26402 #include <net/ip.h>
26403 #include <net/ipv6.h>
26404 @@ -160,9 +162,12 @@ lookup_protocol:
26408 + if ((protocol == IPPROTO_ICMPV6) &&
26409 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
26411 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
26412 goto out_rcu_unlock;
26415 sock->ops = answer->ops;
26416 answer_prot = answer->prot;
26417 answer_no_check = answer->no_check;
26418 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
26419 struct inet_sock *inet = inet_sk(sk);
26420 struct ipv6_pinfo *np = inet6_sk(sk);
26421 struct net *net = sock_net(sk);
26422 + struct nx_v6_sock_addr nsa;
26424 unsigned short snum;
26426 @@ -272,6 +278,11 @@ int inet6_bind(struct socket *sock, stru
26428 if (addr_len < SIN6_LEN_RFC2133)
26431 + err = v6_map_sock_addr(inet, addr, &nsa);
26435 addr_type = ipv6_addr_type(&addr->sin6_addr);
26436 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
26438 @@ -303,6 +314,7 @@ int inet6_bind(struct socket *sock, stru
26439 /* Reproduce AF_INET checks to make the bindings consitant */
26440 v4addr = addr->sin6_addr.s6_addr32[3];
26441 chk_addr_ret = inet_addr_type(net, v4addr);
26443 if (!sysctl_ip_nonlocal_bind &&
26444 !(inet->freebind || inet->transparent) &&
26445 v4addr != htonl(INADDR_ANY) &&
26446 @@ -312,6 +324,10 @@ int inet6_bind(struct socket *sock, stru
26447 err = -EADDRNOTAVAIL;
26450 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
26451 + err = -EADDRNOTAVAIL;
26455 if (addr_type != IPV6_ADDR_ANY) {
26456 struct net_device *dev = NULL;
26457 @@ -338,6 +354,11 @@ int inet6_bind(struct socket *sock, stru
26461 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
26462 + err = -EADDRNOTAVAIL;
26466 /* ipv4 addr of the socket is invalid. Only the
26467 * unspecified and mapped address have a v4 equivalent.
26469 @@ -353,6 +374,9 @@ int inet6_bind(struct socket *sock, stru
26473 + /* what's that for? */
26474 + v6_set_sock_addr(inet, &nsa);
26476 inet->inet_rcv_saddr = v4addr;
26477 inet->inet_saddr = v4addr;
26479 @@ -454,9 +478,11 @@ int inet6_getname(struct socket *sock, s
26481 sin->sin6_port = inet->inet_dport;
26482 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
26483 + /* FIXME: remap lback? */
26485 sin->sin6_flowinfo = np->flow_label;
26487 + /* FIXME: remap lback? */
26488 if (ipv6_addr_any(&np->rcv_saddr))
26489 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
26491 diff -NurpP --minimal linux-2.6.35.7/net/ipv6/fib6_rules.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/fib6_rules.c
26492 --- linux-2.6.35.7/net/ipv6/fib6_rules.c 2010-08-02 16:52:59.000000000 +0200
26493 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/fib6_rules.c 2010-08-02 17:05:06.000000000 +0200
26494 @@ -89,7 +89,7 @@ static int fib6_rule_action(struct fib_r
26495 ip6_dst_idev(&rt->u.dst)->dev,
26497 rt6_flags2srcprefs(flags),
26501 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
26503 diff -NurpP --minimal linux-2.6.35.7/net/ipv6/inet6_hashtables.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/inet6_hashtables.c
26504 --- linux-2.6.35.7/net/ipv6/inet6_hashtables.c 2010-02-25 11:52:10.000000000 +0100
26505 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/inet6_hashtables.c 2010-08-02 17:05:06.000000000 +0200
26508 #include <linux/module.h>
26509 #include <linux/random.h>
26510 +#include <linux/vs_inet6.h>
26512 #include <net/inet_connection_sock.h>
26513 #include <net/inet_hashtables.h>
26514 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
26515 unsigned int slot = hash & hashinfo->ehash_mask;
26516 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
26521 sk_nulls_for_each_rcu(sk, node, &head->chain) {
26522 @@ -94,7 +94,7 @@ begin:
26530 if (get_nulls_value(node) != slot)
26531 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
26532 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
26536 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
26539 if (sk->sk_bound_dev_if) {
26540 if (sk->sk_bound_dev_if != dif)
26541 diff -NurpP --minimal linux-2.6.35.7/net/ipv6/ip6_output.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/ip6_output.c
26542 --- linux-2.6.35.7/net/ipv6/ip6_output.c 2010-08-02 16:52:59.000000000 +0200
26543 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/ip6_output.c 2010-08-02 17:05:06.000000000 +0200
26544 @@ -930,7 +930,7 @@ static int ip6_dst_lookup_tail(struct so
26545 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
26547 sk ? inet6_sk(sk)->srcprefs : 0,
26549 + &fl->fl6_src, sk->sk_nx_info);
26551 goto out_err_release;
26553 diff -NurpP --minimal linux-2.6.35.7/net/ipv6/Kconfig linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/Kconfig
26554 --- linux-2.6.35.7/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
26555 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/Kconfig 2010-08-02 17:05:06.000000000 +0200
26558 # IPv6 as module will cause a CRASH if you try to unload it
26560 - tristate "The IPv6 protocol"
26562 + bool "The IPv6 protocol"
26565 This is complemental support for the IP version 6.
26566 You will still be able to do traditional IPv4 networking as well.
26567 diff -NurpP --minimal linux-2.6.35.7/net/ipv6/ndisc.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/ndisc.c
26568 --- linux-2.6.35.7/net/ipv6/ndisc.c 2010-08-02 16:53:00.000000000 +0200
26569 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/ndisc.c 2010-08-02 17:05:06.000000000 +0200
26570 @@ -591,7 +591,7 @@ static void ndisc_send_na(struct net_dev
26572 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
26573 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
26575 + &tmpaddr, NULL /* FIXME: ? */ ))
26577 src_addr = &tmpaddr;
26579 diff -NurpP --minimal linux-2.6.35.7/net/ipv6/raw.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/raw.c
26580 --- linux-2.6.35.7/net/ipv6/raw.c 2010-08-02 16:53:00.000000000 +0200
26581 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/raw.c 2010-08-02 17:05:06.000000000 +0200
26583 #include <linux/icmpv6.h>
26584 #include <linux/netfilter.h>
26585 #include <linux/netfilter_ipv6.h>
26586 +#include <linux/vs_inet6.h>
26587 #include <linux/skbuff.h>
26588 #include <asm/uaccess.h>
26589 #include <asm/ioctls.h>
26590 @@ -283,6 +284,13 @@ static int rawv6_bind(struct sock *sk, s
26594 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
26595 + err = -EADDRNOTAVAIL;
26601 /* ipv4 addr of the socket is invalid. Only the
26602 * unspecified and mapped address have a v4 equivalent.
26604 diff -NurpP --minimal linux-2.6.35.7/net/ipv6/route.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/route.c
26605 --- linux-2.6.35.7/net/ipv6/route.c 2010-08-02 16:53:00.000000000 +0200
26606 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/route.c 2010-08-02 17:05:06.000000000 +0200
26607 @@ -2255,7 +2255,8 @@ static int rt6_fill_node(struct net *net
26608 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
26609 struct in6_addr saddr_buf;
26610 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
26611 - dst, 0, &saddr_buf) == 0)
26612 + dst, 0, &saddr_buf,
26613 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
26614 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
26617 diff -NurpP --minimal linux-2.6.35.7/net/ipv6/tcp_ipv6.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/tcp_ipv6.c
26618 --- linux-2.6.35.7/net/ipv6/tcp_ipv6.c 2010-08-02 16:53:00.000000000 +0200
26619 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/tcp_ipv6.c 2010-08-02 17:05:06.000000000 +0200
26622 #include <linux/crypto.h>
26623 #include <linux/scatterlist.h>
26624 +#include <linux/vs_inet6.h>
26626 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
26627 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
26628 @@ -160,8 +161,15 @@ static int tcp_v6_connect(struct sock *s
26629 * connect() to INADDR_ANY means loopback (BSD'ism).
26632 - if(ipv6_addr_any(&usin->sin6_addr))
26633 - usin->sin6_addr.s6_addr[15] = 0x1;
26634 + if(ipv6_addr_any(&usin->sin6_addr)) {
26635 + struct nx_info *nxi = sk->sk_nx_info;
26637 + if (nxi && nx_info_has_v6(nxi))
26638 + /* FIXME: remap lback? */
26639 + usin->sin6_addr = nxi->v6.ip;
26641 + usin->sin6_addr.s6_addr[15] = 0x1;
26644 addr_type = ipv6_addr_type(&usin->sin6_addr);
26646 diff -NurpP --minimal linux-2.6.35.7/net/ipv6/udp.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/udp.c
26647 --- linux-2.6.35.7/net/ipv6/udp.c 2010-10-04 08:57:41.000000000 +0200
26648 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/udp.c 2010-10-05 19:23:43.000000000 +0200
26649 @@ -48,13 +48,14 @@
26651 #include <linux/proc_fs.h>
26652 #include <linux/seq_file.h>
26653 +#include <linux/vs_inet6.h>
26654 #include "udp_impl.h"
26656 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
26658 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
26659 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
26660 - __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
26661 + __be32 sk_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
26662 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
26663 int sk_ipv6only = ipv6_only_sock(sk);
26664 int sk2_ipv6only = inet_v6_ipv6only(sk2);
26665 @@ -62,24 +63,49 @@ int ipv6_rcv_saddr_equal(const struct so
26666 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
26668 /* if both are mapped, treat as IPv4 */
26669 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
26670 - return (!sk2_ipv6only &&
26671 - (!sk1_rcv_saddr || !sk2_rcv_saddr ||
26672 - sk1_rcv_saddr == sk2_rcv_saddr));
26673 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
26674 + if (!sk2_ipv6only &&
26675 + (!sk_rcv_saddr || !sk2_rcv_saddr ||
26676 + sk_rcv_saddr == sk2_rcv_saddr))
26682 if (addr_type2 == IPV6_ADDR_ANY &&
26683 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
26687 if (addr_type == IPV6_ADDR_ANY &&
26688 !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
26692 if (sk2_rcv_saddr6 &&
26693 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
26700 + if (!sk_rcv_saddr && !sk2_rcv_saddr)
26701 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
26702 + if (!sk2_rcv_saddr)
26703 + return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
26704 + if (!sk_rcv_saddr)
26705 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
26708 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
26709 + return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
26710 + else if (addr_type2 == IPV6_ADDR_ANY)
26711 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
26712 + else if (addr_type == IPV6_ADDR_ANY) {
26713 + if (addr_type2 == IPV6_ADDR_MAPPED)
26714 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
26716 + return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
26721 static unsigned int udp6_portaddr_hash(struct net *net,
26722 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
26723 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
26727 + /* block non nx_info ips */
26728 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
26731 if (!ipv6_addr_any(&np->daddr)) {
26732 if (!ipv6_addr_equal(&np->daddr, saddr))
26733 diff -NurpP --minimal linux-2.6.35.7/net/ipv6/xfrm6_policy.c linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/xfrm6_policy.c
26734 --- linux-2.6.35.7/net/ipv6/xfrm6_policy.c 2010-08-02 16:53:00.000000000 +0200
26735 +++ linux-2.6.35.7-vs2.3.0.36.33/net/ipv6/xfrm6_policy.c 2010-08-02 17:05:06.000000000 +0200
26736 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
26737 dev = ip6_dst_idev(dst)->dev;
26738 ipv6_dev_get_saddr(dev_net(dev), dev,
26739 (struct in6_addr *)&daddr->a6, 0,
26740 - (struct in6_addr *)&saddr->a6);
26741 + (struct in6_addr *)&saddr->a6, NULL);
26745 diff -NurpP --minimal linux-2.6.35.7/net/netlink/af_netlink.c linux-2.6.35.7-vs2.3.0.36.33/net/netlink/af_netlink.c
26746 --- linux-2.6.35.7/net/netlink/af_netlink.c 2010-10-04 08:57:41.000000000 +0200
26747 +++ linux-2.6.35.7-vs2.3.0.36.33/net/netlink/af_netlink.c 2010-09-06 02:59:52.000000000 +0200
26749 #include <linux/types.h>
26750 #include <linux/audit.h>
26751 #include <linux/mutex.h>
26752 +#include <linux/vs_context.h>
26753 +#include <linux/vs_network.h>
26754 +#include <linux/vs_limit.h>
26756 #include <net/net_namespace.h>
26757 #include <net/sock.h>
26758 @@ -1922,6 +1925,8 @@ static struct sock *netlink_seq_socket_i
26759 sk_for_each(s, node, &hash->table[j]) {
26760 if (sock_net(s) != seq_file_net(seq))
26762 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26766 iter->hash_idx = j;
26767 @@ -1956,7 +1961,8 @@ static void *netlink_seq_next(struct seq
26771 - } while (s && sock_net(s) != seq_file_net(seq));
26772 + } while (s && (sock_net(s) != seq_file_net(seq) ||
26773 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
26777 @@ -1968,7 +1974,8 @@ static void *netlink_seq_next(struct seq
26779 for (; j <= hash->mask; j++) {
26780 s = sk_head(&hash->table[j]);
26781 - while (s && sock_net(s) != seq_file_net(seq))
26782 + while (s && (sock_net(s) != seq_file_net(seq) ||
26783 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
26787 diff -NurpP --minimal linux-2.6.35.7/net/sctp/ipv6.c linux-2.6.35.7-vs2.3.0.36.33/net/sctp/ipv6.c
26788 --- linux-2.6.35.7/net/sctp/ipv6.c 2010-08-02 16:53:01.000000000 +0200
26789 +++ linux-2.6.35.7-vs2.3.0.36.33/net/sctp/ipv6.c 2010-08-02 17:05:06.000000000 +0200
26790 @@ -304,7 +304,8 @@ static void sctp_v6_get_saddr(struct sct
26791 dst ? ip6_dst_idev(dst)->dev : NULL,
26792 &daddr->v6.sin6_addr,
26793 inet6_sk(&sk->inet.sk)->srcprefs,
26794 - &saddr->v6.sin6_addr);
26795 + &saddr->v6.sin6_addr,
26796 + asoc->base.sk->sk_nx_info);
26797 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
26798 &saddr->v6.sin6_addr);
26800 diff -NurpP --minimal linux-2.6.35.7/net/socket.c linux-2.6.35.7-vs2.3.0.36.33/net/socket.c
26801 --- linux-2.6.35.7/net/socket.c 2010-08-02 16:53:02.000000000 +0200
26802 +++ linux-2.6.35.7-vs2.3.0.36.33/net/socket.c 2010-08-02 17:05:06.000000000 +0200
26805 #include <net/sock.h>
26806 #include <linux/netfilter.h>
26807 +#include <linux/vs_base.h>
26808 +#include <linux/vs_socket.h>
26809 +#include <linux/vs_inet.h>
26810 +#include <linux/vs_inet6.h>
26812 #include <linux/if_tun.h>
26813 #include <linux/ipv6_route.h>
26814 @@ -557,7 +561,7 @@ static inline int __sock_sendmsg(struct
26815 struct msghdr *msg, size_t size)
26817 struct sock_iocb *si = kiocb_to_siocb(iocb);
26821 sock_update_classid(sock->sk);
26823 @@ -570,7 +574,22 @@ static inline int __sock_sendmsg(struct
26827 - return sock->ops->sendmsg(iocb, sock, msg, size);
26828 + len = sock->ops->sendmsg(iocb, sock, msg, size);
26831 + vx_sock_send(sock->sk, size);
26833 + vx_sock_fail(sock->sk, size);
26835 + vxdprintk(VXD_CBIT(net, 7),
26836 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26838 + (sock->sk)?sock->sk->sk_nx_info:0,
26839 + (sock->sk)?sock->sk->sk_vx_info:0,
26840 + (sock->sk)?sock->sk->sk_xid:0,
26841 + (sock->sk)?sock->sk->sk_nid:0,
26842 + (unsigned int)size, len);
26846 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
26847 @@ -686,6 +705,7 @@ static inline int __sock_recvmsg_nosec(s
26848 struct msghdr *msg, size_t size, int flags)
26850 struct sock_iocb *si = kiocb_to_siocb(iocb);
26853 sock_update_classid(sock->sk);
26855 @@ -695,7 +715,18 @@ static inline int __sock_recvmsg_nosec(s
26859 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
26860 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
26861 + if ((len >= 0) && sock->sk)
26862 + vx_sock_recv(sock->sk, len);
26863 + vxdprintk(VXD_CBIT(net, 7),
26864 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26866 + (sock->sk)?sock->sk->sk_nx_info:0,
26867 + (sock->sk)?sock->sk->sk_vx_info:0,
26868 + (sock->sk)?sock->sk->sk_xid:0,
26869 + (sock->sk)?sock->sk->sk_nid:0,
26870 + (unsigned int)size, len);
26874 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
26875 @@ -1163,6 +1194,13 @@ static int __sock_create(struct net *net
26876 if (type < 0 || type >= SOCK_MAX)
26879 + if (!nx_check(0, VS_ADMIN)) {
26880 + if (family == PF_INET && !current_nx_info_has_v4())
26881 + return -EAFNOSUPPORT;
26882 + if (family == PF_INET6 && !current_nx_info_has_v6())
26883 + return -EAFNOSUPPORT;
26888 This uglymoron is moved from INET layer to here to avoid
26889 @@ -1295,6 +1333,7 @@ SYSCALL_DEFINE3(socket, int, family, int
26893 + set_bit(SOCK_USER_SOCKET, &sock->flags);
26894 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
26897 @@ -1336,10 +1375,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
26898 err = sock_create(family, type, protocol, &sock1);
26901 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
26903 err = sock_create(family, type, protocol, &sock2);
26905 goto out_release_1;
26906 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
26908 err = sock1->ops->socketpair(sock1, sock2);
26910 diff -NurpP --minimal linux-2.6.35.7/net/sunrpc/auth.c linux-2.6.35.7-vs2.3.0.36.33/net/sunrpc/auth.c
26911 --- linux-2.6.35.7/net/sunrpc/auth.c 2010-08-02 16:53:02.000000000 +0200
26912 +++ linux-2.6.35.7-vs2.3.0.36.33/net/sunrpc/auth.c 2010-08-02 17:05:06.000000000 +0200
26914 #include <linux/hash.h>
26915 #include <linux/sunrpc/clnt.h>
26916 #include <linux/spinlock.h>
26917 +#include <linux/vs_tag.h>
26920 # define RPCDBG_FACILITY RPCDBG_AUTH
26921 @@ -366,6 +367,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
26922 memset(&acred, 0, sizeof(acred));
26923 acred.uid = cred->fsuid;
26924 acred.gid = cred->fsgid;
26925 + acred.tag = dx_current_tag();
26926 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
26928 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
26929 @@ -406,6 +408,7 @@ rpcauth_bind_root_cred(struct rpc_task *
26930 struct auth_cred acred = {
26933 + .tag = dx_current_tag(),
26935 struct rpc_cred *ret;
26937 diff -NurpP --minimal linux-2.6.35.7/net/sunrpc/auth_unix.c linux-2.6.35.7-vs2.3.0.36.33/net/sunrpc/auth_unix.c
26938 --- linux-2.6.35.7/net/sunrpc/auth_unix.c 2010-07-07 18:32:01.000000000 +0200
26939 +++ linux-2.6.35.7-vs2.3.0.36.33/net/sunrpc/auth_unix.c 2010-08-02 17:05:06.000000000 +0200
26940 @@ -12,12 +12,14 @@
26941 #include <linux/module.h>
26942 #include <linux/sunrpc/clnt.h>
26943 #include <linux/sunrpc/auth.h>
26944 +#include <linux/vs_tag.h>
26946 #define NFS_NGROUPS 16
26949 struct rpc_cred uc_base;
26952 gid_t uc_gids[NFS_NGROUPS];
26954 #define uc_uid uc_base.cr_uid
26955 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
26956 groups = NFS_NGROUPS;
26958 cred->uc_gid = acred->gid;
26959 + cred->uc_tag = acred->tag;
26960 for (i = 0; i < groups; i++)
26961 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
26962 if (i < NFS_NGROUPS)
26963 @@ -120,7 +123,9 @@ unx_match(struct auth_cred *acred, struc
26967 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
26968 + if (cred->uc_uid != acred->uid ||
26969 + cred->uc_gid != acred->gid ||
26970 + cred->uc_tag != acred->tag)
26973 if (acred->group_info != NULL)
26974 @@ -143,7 +148,7 @@ unx_marshal(struct rpc_task *task, __be3
26975 struct rpc_clnt *clnt = task->tk_client;
26976 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
26977 __be32 *base, *hold;
26981 *p++ = htonl(RPC_AUTH_UNIX);
26983 @@ -153,9 +158,12 @@ unx_marshal(struct rpc_task *task, __be3
26984 * Copy the UTS nodename captured when the client was created.
26986 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
26987 + tag = task->tk_client->cl_tag;
26989 - *p++ = htonl((u32) cred->uc_uid);
26990 - *p++ = htonl((u32) cred->uc_gid);
26991 + *p++ = htonl((u32) TAGINO_UID(tag,
26992 + cred->uc_uid, cred->uc_tag));
26993 + *p++ = htonl((u32) TAGINO_GID(tag,
26994 + cred->uc_gid, cred->uc_tag));
26996 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
26997 *p++ = htonl((u32) cred->uc_gids[i]);
26998 diff -NurpP --minimal linux-2.6.35.7/net/sunrpc/clnt.c linux-2.6.35.7-vs2.3.0.36.33/net/sunrpc/clnt.c
26999 --- linux-2.6.35.7/net/sunrpc/clnt.c 2010-08-02 16:53:02.000000000 +0200
27000 +++ linux-2.6.35.7-vs2.3.0.36.33/net/sunrpc/clnt.c 2010-08-02 17:05:06.000000000 +0200
27002 #include <linux/utsname.h>
27003 #include <linux/workqueue.h>
27004 #include <linux/in6.h>
27005 +#include <linux/vs_cvirt.h>
27007 #include <linux/sunrpc/clnt.h>
27008 #include <linux/sunrpc/rpc_pipe_fs.h>
27009 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
27010 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
27011 clnt->cl_chatty = 1;
27013 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
27014 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
27015 + clnt->cl_tag = 1; */
27018 EXPORT_SYMBOL_GPL(rpc_create);
27019 diff -NurpP --minimal linux-2.6.35.7/net/unix/af_unix.c linux-2.6.35.7-vs2.3.0.36.33/net/unix/af_unix.c
27020 --- linux-2.6.35.7/net/unix/af_unix.c 2010-10-04 08:57:42.000000000 +0200
27021 +++ linux-2.6.35.7-vs2.3.0.36.33/net/unix/af_unix.c 2010-10-05 19:23:43.000000000 +0200
27022 @@ -114,6 +114,8 @@
27023 #include <linux/mount.h>
27024 #include <net/checksum.h>
27025 #include <linux/security.h>
27026 +#include <linux/vs_context.h>
27027 +#include <linux/vs_limit.h>
27029 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
27030 static DEFINE_SPINLOCK(unix_table_lock);
27031 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
27032 if (!net_eq(sock_net(s), net))
27035 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27037 if (u->addr->len == len &&
27038 !memcmp(u->addr->name, sunname, len))
27040 @@ -2123,6 +2127,8 @@ static struct sock *unix_seq_idx(struct
27041 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
27042 if (sock_net(s) != seq_file_net(seq))
27044 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27049 @@ -2147,7 +2153,8 @@ static void *unix_seq_next(struct seq_fi
27050 sk = first_unix_socket(&iter->i);
27052 sk = next_unix_socket(&iter->i, sk);
27053 - while (sk && (sock_net(sk) != seq_file_net(seq)))
27054 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
27055 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
27056 sk = next_unix_socket(&iter->i, sk);
27059 diff -NurpP --minimal linux-2.6.35.7/scripts/checksyscalls.sh linux-2.6.35.7-vs2.3.0.36.33/scripts/checksyscalls.sh
27060 --- linux-2.6.35.7/scripts/checksyscalls.sh 2009-09-10 15:26:31.000000000 +0200
27061 +++ linux-2.6.35.7-vs2.3.0.36.33/scripts/checksyscalls.sh 2010-08-02 17:05:06.000000000 +0200
27062 @@ -194,7 +194,6 @@ cat << EOF
27063 #define __IGNORE_afs_syscall
27064 #define __IGNORE_getpmsg
27065 #define __IGNORE_putpmsg
27066 -#define __IGNORE_vserver
27070 diff -NurpP --minimal linux-2.6.35.7/security/commoncap.c linux-2.6.35.7-vs2.3.0.36.33/security/commoncap.c
27071 --- linux-2.6.35.7/security/commoncap.c 2010-08-02 16:53:03.000000000 +0200
27072 +++ linux-2.6.35.7-vs2.3.0.36.33/security/commoncap.c 2010-08-02 17:05:06.000000000 +0200
27074 #include <linux/prctl.h>
27075 #include <linux/securebits.h>
27076 #include <linux/syslog.h>
27077 +#include <linux/vs_context.h>
27080 * If a non-root user executes a setuid-root binary in
27081 @@ -53,7 +54,7 @@ static void warn_setuid_and_fcaps_mixed(
27083 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
27085 - NETLINK_CB(skb).eff_cap = current_cap();
27086 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
27090 @@ -63,6 +64,7 @@ int cap_netlink_recv(struct sk_buff *skb
27095 EXPORT_SYMBOL(cap_netlink_recv);
27098 @@ -83,7 +85,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
27099 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
27102 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
27103 + struct vx_info *vxi = tsk->vx_info;
27106 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
27107 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
27108 + cap_raised(tsk->cap_effective, cap),
27109 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
27112 + /* special case SETUP */
27113 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
27114 + /* FIXME: maybe use cred instead? */
27115 + cap_raised(tsk->cred->cap_effective, cap))
27118 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
27122 @@ -571,7 +588,7 @@ int cap_inode_setxattr(struct dentry *de
27124 if (!strncmp(name, XATTR_SECURITY_PREFIX,
27125 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
27126 - !capable(CAP_SYS_ADMIN))
27127 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
27131 @@ -597,7 +614,7 @@ int cap_inode_removexattr(struct dentry
27133 if (!strncmp(name, XATTR_SECURITY_PREFIX,
27134 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
27135 - !capable(CAP_SYS_ADMIN))
27136 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
27140 @@ -899,7 +916,8 @@ int cap_syslog(int type, bool from_file)
27141 if (type != SYSLOG_ACTION_OPEN && from_file)
27143 if ((type != SYSLOG_ACTION_READ_ALL &&
27144 - type != SYSLOG_ACTION_SIZE_BUFFER) && !capable(CAP_SYS_ADMIN))
27145 + type != SYSLOG_ACTION_SIZE_BUFFER) &&
27146 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
27150 @@ -951,3 +969,4 @@ int cap_file_mmap(struct file *file, uns
27155 diff -NurpP --minimal linux-2.6.35.7/security/selinux/av_permissions.h linux-2.6.35.7-vs2.3.0.36.33/security/selinux/av_permissions.h
27156 --- linux-2.6.35.7/security/selinux/av_permissions.h 1970-01-01 01:00:00.000000000 +0100
27157 +++ linux-2.6.35.7-vs2.3.0.36.33/security/selinux/av_permissions.h 2010-08-02 17:05:06.000000000 +0200
27159 +/* This file is automatically generated. Do not edit. */
27160 +#ifndef _SELINUX_AV_PERMISSIONS_H_
27161 +#define _SELINUX_AV_PERMISSIONS_H_
27163 +#define SECURITY__COMPUTE_AV 0x00000001UL
27164 +#define SECURITY__COMPUTE_CREATE 0x00000002UL
27165 +#define SECURITY__COMPUTE_MEMBER 0x00000004UL
27166 +#define SECURITY__CHECK_CONTEXT 0x00000008UL
27167 +#define SECURITY__LOAD_POLICY 0x00000010UL
27168 +#define SECURITY__COMPUTE_RELABEL 0x00000020UL
27169 +#define SECURITY__COMPUTE_USER 0x00000040UL
27170 +#define SECURITY__SETENFORCE 0x00000080UL
27171 +#define SECURITY__SETBOOL 0x00000100UL
27172 +#define SECURITY__SETSECPARAM 0x00000200UL
27173 +#define SECURITY__SETCHECKREQPROT 0x00000400UL
27174 +#define PROCESS__FORK 0x00000001UL
27175 +#define PROCESS__TRANSITION 0x00000002UL
27176 +#define PROCESS__SIGCHLD 0x00000004UL
27177 +#define PROCESS__SIGKILL 0x00000008UL
27178 +#define PROCESS__SIGSTOP 0x00000010UL
27179 +#define PROCESS__SIGNULL 0x00000020UL
27180 +#define PROCESS__SIGNAL 0x00000040UL
27181 +#define PROCESS__PTRACE 0x00000080UL
27182 +#define PROCESS__GETSCHED 0x00000100UL
27183 +#define PROCESS__SETSCHED 0x00000200UL
27184 +#define PROCESS__GETSESSION 0x00000400UL
27185 +#define PROCESS__GETPGID 0x00000800UL
27186 +#define PROCESS__SETPGID 0x00001000UL
27187 +#define PROCESS__GETCAP 0x00002000UL
27188 +#define PROCESS__SETCAP 0x00004000UL
27189 +#define PROCESS__SHARE 0x00008000UL
27190 +#define PROCESS__GETATTR 0x00010000UL
27191 +#define PROCESS__SETEXEC 0x00020000UL
27192 +#define PROCESS__SETFSCREATE 0x00040000UL
27193 +#define PROCESS__NOATSECURE 0x00080000UL
27194 +#define PROCESS__SIGINH 0x00100000UL
27195 +#define PROCESS__SETRLIMIT 0x00200000UL
27196 +#define PROCESS__RLIMITINH 0x00400000UL
27197 +#define PROCESS__DYNTRANSITION 0x00800000UL
27198 +#define PROCESS__SETCURRENT 0x01000000UL
27199 +#define PROCESS__EXECMEM 0x02000000UL
27200 +#define PROCESS__EXECSTACK 0x04000000UL
27201 +#define PROCESS__EXECHEAP 0x08000000UL
27202 +#define PROCESS__SETKEYCREATE 0x10000000UL
27203 +#define PROCESS__SETSOCKCREATE 0x20000000UL
27204 +#define SYSTEM__IPC_INFO 0x00000001UL
27205 +#define SYSTEM__SYSLOG_READ 0x00000002UL
27206 +#define SYSTEM__SYSLOG_MOD 0x00000004UL
27207 +#define SYSTEM__SYSLOG_CONSOLE 0x00000008UL
27208 +#define SYSTEM__MODULE_REQUEST 0x00000010UL
27209 +#define CAPABILITY__CHOWN 0x00000001UL
27210 +#define CAPABILITY__DAC_OVERRIDE 0x00000002UL
27211 +#define CAPABILITY__DAC_READ_SEARCH 0x00000004UL
27212 +#define CAPABILITY__FOWNER 0x00000008UL
27213 +#define CAPABILITY__FSETID 0x00000010UL
27214 +#define CAPABILITY__KILL 0x00000020UL
27215 +#define CAPABILITY__SETGID 0x00000040UL
27216 +#define CAPABILITY__SETUID 0x00000080UL
27217 +#define CAPABILITY__SETPCAP 0x00000100UL
27218 +#define CAPABILITY__LINUX_IMMUTABLE 0x00000200UL
27219 +#define CAPABILITY__NET_BIND_SERVICE 0x00000400UL
27220 +#define CAPABILITY__NET_BROADCAST 0x00000800UL
27221 +#define CAPABILITY__NET_ADMIN 0x00001000UL
27222 +#define CAPABILITY__NET_RAW 0x00002000UL
27223 +#define CAPABILITY__IPC_LOCK 0x00004000UL
27224 +#define CAPABILITY__IPC_OWNER 0x00008000UL
27225 +#define CAPABILITY__SYS_MODULE 0x00010000UL
27226 +#define CAPABILITY__SYS_RAWIO 0x00020000UL
27227 +#define CAPABILITY__SYS_CHROOT 0x00040000UL
27228 +#define CAPABILITY__SYS_PTRACE 0x00080000UL
27229 +#define CAPABILITY__SYS_PACCT 0x00100000UL
27230 +#define CAPABILITY__SYS_ADMIN 0x00200000UL
27231 +#define CAPABILITY__SYS_BOOT 0x00400000UL
27232 +#define CAPABILITY__SYS_NICE 0x00800000UL
27233 +#define CAPABILITY__SYS_RESOURCE 0x01000000UL
27234 +#define CAPABILITY__SYS_TIME 0x02000000UL
27235 +#define CAPABILITY__SYS_TTY_CONFIG 0x04000000UL
27236 +#define CAPABILITY__MKNOD 0x08000000UL
27237 +#define CAPABILITY__LEASE 0x10000000UL
27238 +#define CAPABILITY__AUDIT_WRITE 0x20000000UL
27239 +#define CAPABILITY__AUDIT_CONTROL 0x40000000UL
27240 +#define CAPABILITY__SETFCAP 0x80000000UL
27241 +#define FILESYSTEM__MOUNT 0x00000001UL
27242 +#define FILESYSTEM__REMOUNT 0x00000002UL
27243 +#define FILESYSTEM__UNMOUNT 0x00000004UL
27244 +#define FILESYSTEM__GETATTR 0x00000008UL
27245 +#define FILESYSTEM__RELABELFROM 0x00000010UL
27246 +#define FILESYSTEM__RELABELTO 0x00000020UL
27247 +#define FILESYSTEM__TRANSITION 0x00000040UL
27248 +#define FILESYSTEM__ASSOCIATE 0x00000080UL
27249 +#define FILESYSTEM__QUOTAMOD 0x00000100UL
27250 +#define FILESYSTEM__QUOTAGET 0x00000200UL
27251 +#define FILE__IOCTL 0x00000001UL
27252 +#define FILE__READ 0x00000002UL
27253 +#define FILE__WRITE 0x00000004UL
27254 +#define FILE__CREATE 0x00000008UL
27255 +#define FILE__GETATTR 0x00000010UL
27256 +#define FILE__SETATTR 0x00000020UL
27257 +#define FILE__LOCK 0x00000040UL
27258 +#define FILE__RELABELFROM 0x00000080UL
27259 +#define FILE__RELABELTO 0x00000100UL
27260 +#define FILE__APPEND 0x00000200UL
27261 +#define FILE__UNLINK 0x00000400UL
27262 +#define FILE__LINK 0x00000800UL
27263 +#define FILE__RENAME 0x00001000UL
27264 +#define FILE__EXECUTE 0x00002000UL
27265 +#define FILE__SWAPON 0x00004000UL
27266 +#define FILE__QUOTAON 0x00008000UL
27267 +#define FILE__MOUNTON 0x00010000UL
27268 +#define FILE__EXECUTE_NO_TRANS 0x00020000UL
27269 +#define FILE__ENTRYPOINT 0x00040000UL
27270 +#define FILE__EXECMOD 0x00080000UL
27271 +#define FILE__OPEN 0x00100000UL
27272 +#define DIR__IOCTL 0x00000001UL
27273 +#define DIR__READ 0x00000002UL
27274 +#define DIR__WRITE 0x00000004UL
27275 +#define DIR__CREATE 0x00000008UL
27276 +#define DIR__GETATTR 0x00000010UL
27277 +#define DIR__SETATTR 0x00000020UL
27278 +#define DIR__LOCK 0x00000040UL
27279 +#define DIR__RELABELFROM 0x00000080UL
27280 +#define DIR__RELABELTO 0x00000100UL
27281 +#define DIR__APPEND 0x00000200UL
27282 +#define DIR__UNLINK 0x00000400UL
27283 +#define DIR__LINK 0x00000800UL
27284 +#define DIR__RENAME 0x00001000UL
27285 +#define DIR__EXECUTE 0x00002000UL
27286 +#define DIR__SWAPON 0x00004000UL
27287 +#define DIR__QUOTAON 0x00008000UL
27288 +#define DIR__MOUNTON 0x00010000UL
27289 +#define DIR__ADD_NAME 0x00020000UL
27290 +#define DIR__REMOVE_NAME 0x00040000UL
27291 +#define DIR__REPARENT 0x00080000UL
27292 +#define DIR__SEARCH 0x00100000UL
27293 +#define DIR__RMDIR 0x00200000UL
27294 +#define DIR__OPEN 0x00400000UL
27295 +#define FD__USE 0x00000001UL
27296 +#define LNK_FILE__IOCTL 0x00000001UL
27297 +#define LNK_FILE__READ 0x00000002UL
27298 +#define LNK_FILE__WRITE 0x00000004UL
27299 +#define LNK_FILE__CREATE 0x00000008UL
27300 +#define LNK_FILE__GETATTR 0x00000010UL
27301 +#define LNK_FILE__SETATTR 0x00000020UL
27302 +#define LNK_FILE__LOCK 0x00000040UL
27303 +#define LNK_FILE__RELABELFROM 0x00000080UL
27304 +#define LNK_FILE__RELABELTO 0x00000100UL
27305 +#define LNK_FILE__APPEND 0x00000200UL
27306 +#define LNK_FILE__UNLINK 0x00000400UL
27307 +#define LNK_FILE__LINK 0x00000800UL
27308 +#define LNK_FILE__RENAME 0x00001000UL
27309 +#define LNK_FILE__EXECUTE 0x00002000UL
27310 +#define LNK_FILE__SWAPON 0x00004000UL
27311 +#define LNK_FILE__QUOTAON 0x00008000UL
27312 +#define LNK_FILE__MOUNTON 0x00010000UL
27313 +#define CHR_FILE__IOCTL 0x00000001UL
27314 +#define CHR_FILE__READ 0x00000002UL
27315 +#define CHR_FILE__WRITE 0x00000004UL
27316 +#define CHR_FILE__CREATE 0x00000008UL
27317 +#define CHR_FILE__GETATTR 0x00000010UL
27318 +#define CHR_FILE__SETATTR 0x00000020UL
27319 +#define CHR_FILE__LOCK 0x00000040UL
27320 +#define CHR_FILE__RELABELFROM 0x00000080UL
27321 +#define CHR_FILE__RELABELTO 0x00000100UL
27322 +#define CHR_FILE__APPEND 0x00000200UL
27323 +#define CHR_FILE__UNLINK 0x00000400UL
27324 +#define CHR_FILE__LINK 0x00000800UL
27325 +#define CHR_FILE__RENAME 0x00001000UL
27326 +#define CHR_FILE__EXECUTE 0x00002000UL
27327 +#define CHR_FILE__SWAPON 0x00004000UL
27328 +#define CHR_FILE__QUOTAON 0x00008000UL
27329 +#define CHR_FILE__MOUNTON 0x00010000UL
27330 +#define CHR_FILE__EXECUTE_NO_TRANS 0x00020000UL
27331 +#define CHR_FILE__ENTRYPOINT 0x00040000UL
27332 +#define CHR_FILE__EXECMOD 0x00080000UL
27333 +#define CHR_FILE__OPEN 0x00100000UL
27334 +#define BLK_FILE__IOCTL 0x00000001UL
27335 +#define BLK_FILE__READ 0x00000002UL
27336 +#define BLK_FILE__WRITE 0x00000004UL
27337 +#define BLK_FILE__CREATE 0x00000008UL
27338 +#define BLK_FILE__GETATTR 0x00000010UL
27339 +#define BLK_FILE__SETATTR 0x00000020UL
27340 +#define BLK_FILE__LOCK 0x00000040UL
27341 +#define BLK_FILE__RELABELFROM 0x00000080UL
27342 +#define BLK_FILE__RELABELTO 0x00000100UL
27343 +#define BLK_FILE__APPEND 0x00000200UL
27344 +#define BLK_FILE__UNLINK 0x00000400UL
27345 +#define BLK_FILE__LINK 0x00000800UL
27346 +#define BLK_FILE__RENAME 0x00001000UL
27347 +#define BLK_FILE__EXECUTE 0x00002000UL
27348 +#define BLK_FILE__SWAPON 0x00004000UL
27349 +#define BLK_FILE__QUOTAON 0x00008000UL
27350 +#define BLK_FILE__MOUNTON 0x00010000UL
27351 +#define BLK_FILE__OPEN 0x00020000UL
27352 +#define SOCK_FILE__IOCTL 0x00000001UL
27353 +#define SOCK_FILE__READ 0x00000002UL
27354 +#define SOCK_FILE__WRITE 0x00000004UL
27355 +#define SOCK_FILE__CREATE 0x00000008UL
27356 +#define SOCK_FILE__GETATTR 0x00000010UL
27357 +#define SOCK_FILE__SETATTR 0x00000020UL
27358 +#define SOCK_FILE__LOCK 0x00000040UL
27359 +#define SOCK_FILE__RELABELFROM 0x00000080UL
27360 +#define SOCK_FILE__RELABELTO 0x00000100UL
27361 +#define SOCK_FILE__APPEND 0x00000200UL
27362 +#define SOCK_FILE__UNLINK 0x00000400UL
27363 +#define SOCK_FILE__LINK 0x00000800UL
27364 +#define SOCK_FILE__RENAME 0x00001000UL
27365 +#define SOCK_FILE__EXECUTE 0x00002000UL
27366 +#define SOCK_FILE__SWAPON 0x00004000UL
27367 +#define SOCK_FILE__QUOTAON 0x00008000UL
27368 +#define SOCK_FILE__MOUNTON 0x00010000UL
27369 +#define SOCK_FILE__OPEN 0x00020000UL
27370 +#define FIFO_FILE__IOCTL 0x00000001UL
27371 +#define FIFO_FILE__READ 0x00000002UL
27372 +#define FIFO_FILE__WRITE 0x00000004UL
27373 +#define FIFO_FILE__CREATE 0x00000008UL
27374 +#define FIFO_FILE__GETATTR 0x00000010UL
27375 +#define FIFO_FILE__SETATTR 0x00000020UL
27376 +#define FIFO_FILE__LOCK 0x00000040UL
27377 +#define FIFO_FILE__RELABELFROM 0x00000080UL
27378 +#define FIFO_FILE__RELABELTO 0x00000100UL
27379 +#define FIFO_FILE__APPEND 0x00000200UL
27380 +#define FIFO_FILE__UNLINK 0x00000400UL
27381 +#define FIFO_FILE__LINK 0x00000800UL
27382 +#define FIFO_FILE__RENAME 0x00001000UL
27383 +#define FIFO_FILE__EXECUTE 0x00002000UL
27384 +#define FIFO_FILE__SWAPON 0x00004000UL
27385 +#define FIFO_FILE__QUOTAON 0x00008000UL
27386 +#define FIFO_FILE__MOUNTON 0x00010000UL
27387 +#define FIFO_FILE__OPEN 0x00020000UL
27388 +#define SOCKET__IOCTL 0x00000001UL
27389 +#define SOCKET__READ 0x00000002UL
27390 +#define SOCKET__WRITE 0x00000004UL
27391 +#define SOCKET__CREATE 0x00000008UL
27392 +#define SOCKET__GETATTR 0x00000010UL
27393 +#define SOCKET__SETATTR 0x00000020UL
27394 +#define SOCKET__LOCK 0x00000040UL
27395 +#define SOCKET__RELABELFROM 0x00000080UL
27396 +#define SOCKET__RELABELTO 0x00000100UL
27397 +#define SOCKET__APPEND 0x00000200UL
27398 +#define SOCKET__BIND 0x00000400UL
27399 +#define SOCKET__CONNECT 0x00000800UL
27400 +#define SOCKET__LISTEN 0x00001000UL
27401 +#define SOCKET__ACCEPT 0x00002000UL
27402 +#define SOCKET__GETOPT 0x00004000UL
27403 +#define SOCKET__SETOPT 0x00008000UL
27404 +#define SOCKET__SHUTDOWN 0x00010000UL
27405 +#define SOCKET__RECVFROM 0x00020000UL
27406 +#define SOCKET__SENDTO 0x00040000UL
27407 +#define SOCKET__RECV_MSG 0x00080000UL
27408 +#define SOCKET__SEND_MSG 0x00100000UL
27409 +#define SOCKET__NAME_BIND 0x00200000UL
27410 +#define TCP_SOCKET__IOCTL 0x00000001UL
27411 +#define TCP_SOCKET__READ 0x00000002UL
27412 +#define TCP_SOCKET__WRITE 0x00000004UL
27413 +#define TCP_SOCKET__CREATE 0x00000008UL
27414 +#define TCP_SOCKET__GETATTR 0x00000010UL
27415 +#define TCP_SOCKET__SETATTR 0x00000020UL
27416 +#define TCP_SOCKET__LOCK 0x00000040UL
27417 +#define TCP_SOCKET__RELABELFROM 0x00000080UL
27418 +#define TCP_SOCKET__RELABELTO 0x00000100UL
27419 +#define TCP_SOCKET__APPEND 0x00000200UL
27420 +#define TCP_SOCKET__BIND 0x00000400UL
27421 +#define TCP_SOCKET__CONNECT 0x00000800UL
27422 +#define TCP_SOCKET__LISTEN 0x00001000UL
27423 +#define TCP_SOCKET__ACCEPT 0x00002000UL
27424 +#define TCP_SOCKET__GETOPT 0x00004000UL
27425 +#define TCP_SOCKET__SETOPT 0x00008000UL
27426 +#define TCP_SOCKET__SHUTDOWN 0x00010000UL
27427 +#define TCP_SOCKET__RECVFROM 0x00020000UL
27428 +#define TCP_SOCKET__SENDTO 0x00040000UL
27429 +#define TCP_SOCKET__RECV_MSG 0x00080000UL
27430 +#define TCP_SOCKET__SEND_MSG 0x00100000UL
27431 +#define TCP_SOCKET__NAME_BIND 0x00200000UL
27432 +#define TCP_SOCKET__CONNECTTO 0x00400000UL
27433 +#define TCP_SOCKET__NEWCONN 0x00800000UL
27434 +#define TCP_SOCKET__ACCEPTFROM 0x01000000UL
27435 +#define TCP_SOCKET__NODE_BIND 0x02000000UL
27436 +#define TCP_SOCKET__NAME_CONNECT 0x04000000UL
27437 +#define UDP_SOCKET__IOCTL 0x00000001UL
27438 +#define UDP_SOCKET__READ 0x00000002UL
27439 +#define UDP_SOCKET__WRITE 0x00000004UL
27440 +#define UDP_SOCKET__CREATE 0x00000008UL
27441 +#define UDP_SOCKET__GETATTR 0x00000010UL
27442 +#define UDP_SOCKET__SETATTR 0x00000020UL
27443 +#define UDP_SOCKET__LOCK 0x00000040UL
27444 +#define UDP_SOCKET__RELABELFROM 0x00000080UL
27445 +#define UDP_SOCKET__RELABELTO 0x00000100UL
27446 +#define UDP_SOCKET__APPEND 0x00000200UL
27447 +#define UDP_SOCKET__BIND 0x00000400UL
27448 +#define UDP_SOCKET__CONNECT 0x00000800UL
27449 +#define UDP_SOCKET__LISTEN 0x00001000UL
27450 +#define UDP_SOCKET__ACCEPT 0x00002000UL
27451 +#define UDP_SOCKET__GETOPT 0x00004000UL
27452 +#define UDP_SOCKET__SETOPT 0x00008000UL
27453 +#define UDP_SOCKET__SHUTDOWN 0x00010000UL
27454 +#define UDP_SOCKET__RECVFROM 0x00020000UL
27455 +#define UDP_SOCKET__SENDTO 0x00040000UL
27456 +#define UDP_SOCKET__RECV_MSG 0x00080000UL
27457 +#define UDP_SOCKET__SEND_MSG 0x00100000UL
27458 +#define UDP_SOCKET__NAME_BIND 0x00200000UL
27459 +#define UDP_SOCKET__NODE_BIND 0x00400000UL
27460 +#define RAWIP_SOCKET__IOCTL 0x00000001UL
27461 +#define RAWIP_SOCKET__READ 0x00000002UL
27462 +#define RAWIP_SOCKET__WRITE 0x00000004UL
27463 +#define RAWIP_SOCKET__CREATE 0x00000008UL
27464 +#define RAWIP_SOCKET__GETATTR 0x00000010UL
27465 +#define RAWIP_SOCKET__SETATTR 0x00000020UL
27466 +#define RAWIP_SOCKET__LOCK 0x00000040UL
27467 +#define RAWIP_SOCKET__RELABELFROM 0x00000080UL
27468 +#define RAWIP_SOCKET__RELABELTO 0x00000100UL
27469 +#define RAWIP_SOCKET__APPEND 0x00000200UL
27470 +#define RAWIP_SOCKET__BIND 0x00000400UL
27471 +#define RAWIP_SOCKET__CONNECT 0x00000800UL
27472 +#define RAWIP_SOCKET__LISTEN 0x00001000UL
27473 +#define RAWIP_SOCKET__ACCEPT 0x00002000UL
27474 +#define RAWIP_SOCKET__GETOPT 0x00004000UL
27475 +#define RAWIP_SOCKET__SETOPT 0x00008000UL
27476 +#define RAWIP_SOCKET__SHUTDOWN 0x00010000UL
27477 +#define RAWIP_SOCKET__RECVFROM 0x00020000UL
27478 +#define RAWIP_SOCKET__SENDTO 0x00040000UL
27479 +#define RAWIP_SOCKET__RECV_MSG 0x00080000UL
27480 +#define RAWIP_SOCKET__SEND_MSG 0x00100000UL
27481 +#define RAWIP_SOCKET__NAME_BIND 0x00200000UL
27482 +#define RAWIP_SOCKET__NODE_BIND 0x00400000UL
27483 +#define NODE__TCP_RECV 0x00000001UL
27484 +#define NODE__TCP_SEND 0x00000002UL
27485 +#define NODE__UDP_RECV 0x00000004UL
27486 +#define NODE__UDP_SEND 0x00000008UL
27487 +#define NODE__RAWIP_RECV 0x00000010UL
27488 +#define NODE__RAWIP_SEND 0x00000020UL
27489 +#define NODE__ENFORCE_DEST 0x00000040UL
27490 +#define NODE__DCCP_RECV 0x00000080UL
27491 +#define NODE__DCCP_SEND 0x00000100UL
27492 +#define NODE__RECVFROM 0x00000200UL
27493 +#define NODE__SENDTO 0x00000400UL
27494 +#define NETIF__TCP_RECV 0x00000001UL
27495 +#define NETIF__TCP_SEND 0x00000002UL
27496 +#define NETIF__UDP_RECV 0x00000004UL
27497 +#define NETIF__UDP_SEND 0x00000008UL
27498 +#define NETIF__RAWIP_RECV 0x00000010UL
27499 +#define NETIF__RAWIP_SEND 0x00000020UL
27500 +#define NETIF__DCCP_RECV 0x00000040UL
27501 +#define NETIF__DCCP_SEND 0x00000080UL
27502 +#define NETIF__INGRESS 0x00000100UL
27503 +#define NETIF__EGRESS 0x00000200UL
27504 +#define NETLINK_SOCKET__IOCTL 0x00000001UL
27505 +#define NETLINK_SOCKET__READ 0x00000002UL
27506 +#define NETLINK_SOCKET__WRITE 0x00000004UL
27507 +#define NETLINK_SOCKET__CREATE 0x00000008UL
27508 +#define NETLINK_SOCKET__GETATTR 0x00000010UL
27509 +#define NETLINK_SOCKET__SETATTR 0x00000020UL
27510 +#define NETLINK_SOCKET__LOCK 0x00000040UL
27511 +#define NETLINK_SOCKET__RELABELFROM 0x00000080UL
27512 +#define NETLINK_SOCKET__RELABELTO 0x00000100UL
27513 +#define NETLINK_SOCKET__APPEND 0x00000200UL
27514 +#define NETLINK_SOCKET__BIND 0x00000400UL
27515 +#define NETLINK_SOCKET__CONNECT 0x00000800UL
27516 +#define NETLINK_SOCKET__LISTEN 0x00001000UL
27517 +#define NETLINK_SOCKET__ACCEPT 0x00002000UL
27518 +#define NETLINK_SOCKET__GETOPT 0x00004000UL
27519 +#define NETLINK_SOCKET__SETOPT 0x00008000UL
27520 +#define NETLINK_SOCKET__SHUTDOWN 0x00010000UL
27521 +#define NETLINK_SOCKET__RECVFROM 0x00020000UL
27522 +#define NETLINK_SOCKET__SENDTO 0x00040000UL
27523 +#define NETLINK_SOCKET__RECV_MSG 0x00080000UL
27524 +#define NETLINK_SOCKET__SEND_MSG 0x00100000UL
27525 +#define NETLINK_SOCKET__NAME_BIND 0x00200000UL
27526 +#define PACKET_SOCKET__IOCTL 0x00000001UL
27527 +#define PACKET_SOCKET__READ 0x00000002UL
27528 +#define PACKET_SOCKET__WRITE 0x00000004UL
27529 +#define PACKET_SOCKET__CREATE 0x00000008UL
27530 +#define PACKET_SOCKET__GETATTR 0x00000010UL
27531 +#define PACKET_SOCKET__SETATTR 0x00000020UL
27532 +#define PACKET_SOCKET__LOCK 0x00000040UL
27533 +#define PACKET_SOCKET__RELABELFROM 0x00000080UL
27534 +#define PACKET_SOCKET__RELABELTO 0x00000100UL
27535 +#define PACKET_SOCKET__APPEND 0x00000200UL
27536 +#define PACKET_SOCKET__BIND 0x00000400UL
27537 +#define PACKET_SOCKET__CONNECT 0x00000800UL
27538 +#define PACKET_SOCKET__LISTEN 0x00001000UL
27539 +#define PACKET_SOCKET__ACCEPT 0x00002000UL
27540 +#define PACKET_SOCKET__GETOPT 0x00004000UL
27541 +#define PACKET_SOCKET__SETOPT 0x00008000UL
27542 +#define PACKET_SOCKET__SHUTDOWN 0x00010000UL
27543 +#define PACKET_SOCKET__RECVFROM 0x00020000UL
27544 +#define PACKET_SOCKET__SENDTO 0x00040000UL
27545 +#define PACKET_SOCKET__RECV_MSG 0x00080000UL
27546 +#define PACKET_SOCKET__SEND_MSG 0x00100000UL
27547 +#define PACKET_SOCKET__NAME_BIND 0x00200000UL
27548 +#define KEY_SOCKET__IOCTL 0x00000001UL
27549 +#define KEY_SOCKET__READ 0x00000002UL
27550 +#define KEY_SOCKET__WRITE 0x00000004UL
27551 +#define KEY_SOCKET__CREATE 0x00000008UL
27552 +#define KEY_SOCKET__GETATTR 0x00000010UL
27553 +#define KEY_SOCKET__SETATTR 0x00000020UL
27554 +#define KEY_SOCKET__LOCK 0x00000040UL
27555 +#define KEY_SOCKET__RELABELFROM 0x00000080UL
27556 +#define KEY_SOCKET__RELABELTO 0x00000100UL
27557 +#define KEY_SOCKET__APPEND 0x00000200UL
27558 +#define KEY_SOCKET__BIND 0x00000400UL
27559 +#define KEY_SOCKET__CONNECT 0x00000800UL
27560 +#define KEY_SOCKET__LISTEN 0x00001000UL
27561 +#define KEY_SOCKET__ACCEPT 0x00002000UL
27562 +#define KEY_SOCKET__GETOPT 0x00004000UL
27563 +#define KEY_SOCKET__SETOPT 0x00008000UL
27564 +#define KEY_SOCKET__SHUTDOWN 0x00010000UL
27565 +#define KEY_SOCKET__RECVFROM 0x00020000UL
27566 +#define KEY_SOCKET__SENDTO 0x00040000UL
27567 +#define KEY_SOCKET__RECV_MSG 0x00080000UL
27568 +#define KEY_SOCKET__SEND_MSG 0x00100000UL
27569 +#define KEY_SOCKET__NAME_BIND 0x00200000UL
27570 +#define UNIX_STREAM_SOCKET__IOCTL 0x00000001UL
27571 +#define UNIX_STREAM_SOCKET__READ 0x00000002UL
27572 +#define UNIX_STREAM_SOCKET__WRITE 0x00000004UL
27573 +#define UNIX_STREAM_SOCKET__CREATE 0x00000008UL
27574 +#define UNIX_STREAM_SOCKET__GETATTR 0x00000010UL
27575 +#define UNIX_STREAM_SOCKET__SETATTR 0x00000020UL
27576 +#define UNIX_STREAM_SOCKET__LOCK 0x00000040UL
27577 +#define UNIX_STREAM_SOCKET__RELABELFROM 0x00000080UL
27578 +#define UNIX_STREAM_SOCKET__RELABELTO 0x00000100UL
27579 +#define UNIX_STREAM_SOCKET__APPEND 0x00000200UL
27580 +#define UNIX_STREAM_SOCKET__BIND 0x00000400UL
27581 +#define UNIX_STREAM_SOCKET__CONNECT 0x00000800UL
27582 +#define UNIX_STREAM_SOCKET__LISTEN 0x00001000UL
27583 +#define UNIX_STREAM_SOCKET__ACCEPT 0x00002000UL
27584 +#define UNIX_STREAM_SOCKET__GETOPT 0x00004000UL
27585 +#define UNIX_STREAM_SOCKET__SETOPT 0x00008000UL
27586 +#define UNIX_STREAM_SOCKET__SHUTDOWN 0x00010000UL
27587 +#define UNIX_STREAM_SOCKET__RECVFROM 0x00020000UL
27588 +#define UNIX_STREAM_SOCKET__SENDTO 0x00040000UL
27589 +#define UNIX_STREAM_SOCKET__RECV_MSG 0x00080000UL
27590 +#define UNIX_STREAM_SOCKET__SEND_MSG 0x00100000UL
27591 +#define UNIX_STREAM_SOCKET__NAME_BIND 0x00200000UL
27592 +#define UNIX_STREAM_SOCKET__CONNECTTO 0x00400000UL
27593 +#define UNIX_STREAM_SOCKET__NEWCONN 0x00800000UL
27594 +#define UNIX_STREAM_SOCKET__ACCEPTFROM 0x01000000UL
27595 +#define UNIX_DGRAM_SOCKET__IOCTL 0x00000001UL
27596 +#define UNIX_DGRAM_SOCKET__READ 0x00000002UL
27597 +#define UNIX_DGRAM_SOCKET__WRITE 0x00000004UL
27598 +#define UNIX_DGRAM_SOCKET__CREATE 0x00000008UL
27599 +#define UNIX_DGRAM_SOCKET__GETATTR 0x00000010UL
27600 +#define UNIX_DGRAM_SOCKET__SETATTR 0x00000020UL
27601 +#define UNIX_DGRAM_SOCKET__LOCK 0x00000040UL
27602 +#define UNIX_DGRAM_SOCKET__RELABELFROM 0x00000080UL
27603 +#define UNIX_DGRAM_SOCKET__RELABELTO 0x00000100UL
27604 +#define UNIX_DGRAM_SOCKET__APPEND 0x00000200UL
27605 +#define UNIX_DGRAM_SOCKET__BIND 0x00000400UL
27606 +#define UNIX_DGRAM_SOCKET__CONNECT 0x00000800UL
27607 +#define UNIX_DGRAM_SOCKET__LISTEN 0x00001000UL
27608 +#define UNIX_DGRAM_SOCKET__ACCEPT 0x00002000UL
27609 +#define UNIX_DGRAM_SOCKET__GETOPT 0x00004000UL
27610 +#define UNIX_DGRAM_SOCKET__SETOPT 0x00008000UL
27611 +#define UNIX_DGRAM_SOCKET__SHUTDOWN 0x00010000UL
27612 +#define UNIX_DGRAM_SOCKET__RECVFROM 0x00020000UL
27613 +#define UNIX_DGRAM_SOCKET__SENDTO 0x00040000UL
27614 +#define UNIX_DGRAM_SOCKET__RECV_MSG 0x00080000UL
27615 +#define UNIX_DGRAM_SOCKET__SEND_MSG 0x00100000UL
27616 +#define UNIX_DGRAM_SOCKET__NAME_BIND 0x00200000UL
27617 +#define SEM__CREATE 0x00000001UL
27618 +#define SEM__DESTROY 0x00000002UL
27619 +#define SEM__GETATTR 0x00000004UL
27620 +#define SEM__SETATTR 0x00000008UL
27621 +#define SEM__READ 0x00000010UL
27622 +#define SEM__WRITE 0x00000020UL
27623 +#define SEM__ASSOCIATE 0x00000040UL
27624 +#define SEM__UNIX_READ 0x00000080UL
27625 +#define SEM__UNIX_WRITE 0x00000100UL
27626 +#define MSG__SEND 0x00000001UL
27627 +#define MSG__RECEIVE 0x00000002UL
27628 +#define MSGQ__CREATE 0x00000001UL
27629 +#define MSGQ__DESTROY 0x00000002UL
27630 +#define MSGQ__GETATTR 0x00000004UL
27631 +#define MSGQ__SETATTR 0x00000008UL
27632 +#define MSGQ__READ 0x00000010UL
27633 +#define MSGQ__WRITE 0x00000020UL
27634 +#define MSGQ__ASSOCIATE 0x00000040UL
27635 +#define MSGQ__UNIX_READ 0x00000080UL
27636 +#define MSGQ__UNIX_WRITE 0x00000100UL
27637 +#define MSGQ__ENQUEUE 0x00000200UL
27638 +#define SHM__CREATE 0x00000001UL
27639 +#define SHM__DESTROY 0x00000002UL
27640 +#define SHM__GETATTR 0x00000004UL
27641 +#define SHM__SETATTR 0x00000008UL
27642 +#define SHM__READ 0x00000010UL
27643 +#define SHM__WRITE 0x00000020UL
27644 +#define SHM__ASSOCIATE 0x00000040UL
27645 +#define SHM__UNIX_READ 0x00000080UL
27646 +#define SHM__UNIX_WRITE 0x00000100UL
27647 +#define SHM__LOCK 0x00000200UL
27648 +#define IPC__CREATE 0x00000001UL
27649 +#define IPC__DESTROY 0x00000002UL
27650 +#define IPC__GETATTR 0x00000004UL
27651 +#define IPC__SETATTR 0x00000008UL
27652 +#define IPC__READ 0x00000010UL
27653 +#define IPC__WRITE 0x00000020UL
27654 +#define IPC__ASSOCIATE 0x00000040UL
27655 +#define IPC__UNIX_READ 0x00000080UL
27656 +#define IPC__UNIX_WRITE 0x00000100UL
27657 +#define NETLINK_ROUTE_SOCKET__IOCTL 0x00000001UL
27658 +#define NETLINK_ROUTE_SOCKET__READ 0x00000002UL
27659 +#define NETLINK_ROUTE_SOCKET__WRITE 0x00000004UL
27660 +#define NETLINK_ROUTE_SOCKET__CREATE 0x00000008UL
27661 +#define NETLINK_ROUTE_SOCKET__GETATTR 0x00000010UL
27662 +#define NETLINK_ROUTE_SOCKET__SETATTR 0x00000020UL
27663 +#define NETLINK_ROUTE_SOCKET__LOCK 0x00000040UL
27664 +#define NETLINK_ROUTE_SOCKET__RELABELFROM 0x00000080UL
27665 +#define NETLINK_ROUTE_SOCKET__RELABELTO 0x00000100UL
27666 +#define NETLINK_ROUTE_SOCKET__APPEND 0x00000200UL
27667 +#define NETLINK_ROUTE_SOCKET__BIND 0x00000400UL
27668 +#define NETLINK_ROUTE_SOCKET__CONNECT 0x00000800UL
27669 +#define NETLINK_ROUTE_SOCKET__LISTEN 0x00001000UL
27670 +#define NETLINK_ROUTE_SOCKET__ACCEPT 0x00002000UL
27671 +#define NETLINK_ROUTE_SOCKET__GETOPT 0x00004000UL
27672 +#define NETLINK_ROUTE_SOCKET__SETOPT 0x00008000UL
27673 +#define NETLINK_ROUTE_SOCKET__SHUTDOWN 0x00010000UL
27674 +#define NETLINK_ROUTE_SOCKET__RECVFROM 0x00020000UL
27675 +#define NETLINK_ROUTE_SOCKET__SENDTO 0x00040000UL
27676 +#define NETLINK_ROUTE_SOCKET__RECV_MSG 0x00080000UL
27677 +#define NETLINK_ROUTE_SOCKET__SEND_MSG 0x00100000UL
27678 +#define NETLINK_ROUTE_SOCKET__NAME_BIND 0x00200000UL
27679 +#define NETLINK_ROUTE_SOCKET__NLMSG_READ 0x00400000UL
27680 +#define NETLINK_ROUTE_SOCKET__NLMSG_WRITE 0x00800000UL
27681 +#define NETLINK_FIREWALL_SOCKET__IOCTL 0x00000001UL
27682 +#define NETLINK_FIREWALL_SOCKET__READ 0x00000002UL
27683 +#define NETLINK_FIREWALL_SOCKET__WRITE 0x00000004UL
27684 +#define NETLINK_FIREWALL_SOCKET__CREATE 0x00000008UL
27685 +#define NETLINK_FIREWALL_SOCKET__GETATTR 0x00000010UL
27686 +#define NETLINK_FIREWALL_SOCKET__SETATTR 0x00000020UL
27687 +#define NETLINK_FIREWALL_SOCKET__LOCK 0x00000040UL
27688 +#define NETLINK_FIREWALL_SOCKET__RELABELFROM 0x00000080UL
27689 +#define NETLINK_FIREWALL_SOCKET__RELABELTO 0x00000100UL
27690 +#define NETLINK_FIREWALL_SOCKET__APPEND 0x00000200UL
27691 +#define NETLINK_FIREWALL_SOCKET__BIND 0x00000400UL
27692 +#define NETLINK_FIREWALL_SOCKET__CONNECT 0x00000800UL
27693 +#define NETLINK_FIREWALL_SOCKET__LISTEN 0x00001000UL
27694 +#define NETLINK_FIREWALL_SOCKET__ACCEPT 0x00002000UL
27695 +#define NETLINK_FIREWALL_SOCKET__GETOPT 0x00004000UL
27696 +#define NETLINK_FIREWALL_SOCKET__SETOPT 0x00008000UL
27697 +#define NETLINK_FIREWALL_SOCKET__SHUTDOWN 0x00010000UL
27698 +#define NETLINK_FIREWALL_SOCKET__RECVFROM 0x00020000UL
27699 +#define NETLINK_FIREWALL_SOCKET__SENDTO 0x00040000UL
27700 +#define NETLINK_FIREWALL_SOCKET__RECV_MSG 0x00080000UL
27701 +#define NETLINK_FIREWALL_SOCKET__SEND_MSG 0x00100000UL
27702 +#define NETLINK_FIREWALL_SOCKET__NAME_BIND 0x00200000UL
27703 +#define NETLINK_FIREWALL_SOCKET__NLMSG_READ 0x00400000UL
27704 +#define NETLINK_FIREWALL_SOCKET__NLMSG_WRITE 0x00800000UL
27705 +#define NETLINK_TCPDIAG_SOCKET__IOCTL 0x00000001UL
27706 +#define NETLINK_TCPDIAG_SOCKET__READ 0x00000002UL
27707 +#define NETLINK_TCPDIAG_SOCKET__WRITE 0x00000004UL
27708 +#define NETLINK_TCPDIAG_SOCKET__CREATE 0x00000008UL
27709 +#define NETLINK_TCPDIAG_SOCKET__GETATTR 0x00000010UL
27710 +#define NETLINK_TCPDIAG_SOCKET__SETATTR 0x00000020UL
27711 +#define NETLINK_TCPDIAG_SOCKET__LOCK 0x00000040UL
27712 +#define NETLINK_TCPDIAG_SOCKET__RELABELFROM 0x00000080UL
27713 +#define NETLINK_TCPDIAG_SOCKET__RELABELTO 0x00000100UL
27714 +#define NETLINK_TCPDIAG_SOCKET__APPEND 0x00000200UL
27715 +#define NETLINK_TCPDIAG_SOCKET__BIND 0x00000400UL
27716 +#define NETLINK_TCPDIAG_SOCKET__CONNECT 0x00000800UL
27717 +#define NETLINK_TCPDIAG_SOCKET__LISTEN 0x00001000UL
27718 +#define NETLINK_TCPDIAG_SOCKET__ACCEPT 0x00002000UL
27719 +#define NETLINK_TCPDIAG_SOCKET__GETOPT 0x00004000UL
27720 +#define NETLINK_TCPDIAG_SOCKET__SETOPT 0x00008000UL
27721 +#define NETLINK_TCPDIAG_SOCKET__SHUTDOWN 0x00010000UL
27722 +#define NETLINK_TCPDIAG_SOCKET__RECVFROM 0x00020000UL
27723 +#define NETLINK_TCPDIAG_SOCKET__SENDTO 0x00040000UL
27724 +#define NETLINK_TCPDIAG_SOCKET__RECV_MSG 0x00080000UL
27725 +#define NETLINK_TCPDIAG_SOCKET__SEND_MSG 0x00100000UL
27726 +#define NETLINK_TCPDIAG_SOCKET__NAME_BIND 0x00200000UL
27727 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_READ 0x00400000UL
27728 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_WRITE 0x00800000UL
27729 +#define NETLINK_NFLOG_SOCKET__IOCTL 0x00000001UL
27730 +#define NETLINK_NFLOG_SOCKET__READ 0x00000002UL
27731 +#define NETLINK_NFLOG_SOCKET__WRITE 0x00000004UL
27732 +#define NETLINK_NFLOG_SOCKET__CREATE 0x00000008UL
27733 +#define NETLINK_NFLOG_SOCKET__GETATTR 0x00000010UL
27734 +#define NETLINK_NFLOG_SOCKET__SETATTR 0x00000020UL
27735 +#define NETLINK_NFLOG_SOCKET__LOCK 0x00000040UL
27736 +#define NETLINK_NFLOG_SOCKET__RELABELFROM 0x00000080UL
27737 +#define NETLINK_NFLOG_SOCKET__RELABELTO 0x00000100UL
27738 +#define NETLINK_NFLOG_SOCKET__APPEND 0x00000200UL
27739 +#define NETLINK_NFLOG_SOCKET__BIND 0x00000400UL
27740 +#define NETLINK_NFLOG_SOCKET__CONNECT 0x00000800UL
27741 +#define NETLINK_NFLOG_SOCKET__LISTEN 0x00001000UL
27742 +#define NETLINK_NFLOG_SOCKET__ACCEPT 0x00002000UL
27743 +#define NETLINK_NFLOG_SOCKET__GETOPT 0x00004000UL
27744 +#define NETLINK_NFLOG_SOCKET__SETOPT 0x00008000UL
27745 +#define NETLINK_NFLOG_SOCKET__SHUTDOWN 0x00010000UL
27746 +#define NETLINK_NFLOG_SOCKET__RECVFROM 0x00020000UL
27747 +#define NETLINK_NFLOG_SOCKET__SENDTO 0x00040000UL
27748 +#define NETLINK_NFLOG_SOCKET__RECV_MSG 0x00080000UL
27749 +#define NETLINK_NFLOG_SOCKET__SEND_MSG 0x00100000UL
27750 +#define NETLINK_NFLOG_SOCKET__NAME_BIND 0x00200000UL
27751 +#define NETLINK_XFRM_SOCKET__IOCTL 0x00000001UL
27752 +#define NETLINK_XFRM_SOCKET__READ 0x00000002UL
27753 +#define NETLINK_XFRM_SOCKET__WRITE 0x00000004UL
27754 +#define NETLINK_XFRM_SOCKET__CREATE 0x00000008UL
27755 +#define NETLINK_XFRM_SOCKET__GETATTR 0x00000010UL
27756 +#define NETLINK_XFRM_SOCKET__SETATTR 0x00000020UL
27757 +#define NETLINK_XFRM_SOCKET__LOCK 0x00000040UL
27758 +#define NETLINK_XFRM_SOCKET__RELABELFROM 0x00000080UL
27759 +#define NETLINK_XFRM_SOCKET__RELABELTO 0x00000100UL
27760 +#define NETLINK_XFRM_SOCKET__APPEND 0x00000200UL
27761 +#define NETLINK_XFRM_SOCKET__BIND 0x00000400UL
27762 +#define NETLINK_XFRM_SOCKET__CONNECT 0x00000800UL
27763 +#define NETLINK_XFRM_SOCKET__LISTEN 0x00001000UL
27764 +#define NETLINK_XFRM_SOCKET__ACCEPT 0x00002000UL
27765 +#define NETLINK_XFRM_SOCKET__GETOPT 0x00004000UL
27766 +#define NETLINK_XFRM_SOCKET__SETOPT 0x00008000UL
27767 +#define NETLINK_XFRM_SOCKET__SHUTDOWN 0x00010000UL
27768 +#define NETLINK_XFRM_SOCKET__RECVFROM 0x00020000UL
27769 +#define NETLINK_XFRM_SOCKET__SENDTO 0x00040000UL
27770 +#define NETLINK_XFRM_SOCKET__RECV_MSG 0x00080000UL
27771 +#define NETLINK_XFRM_SOCKET__SEND_MSG 0x00100000UL
27772 +#define NETLINK_XFRM_SOCKET__NAME_BIND 0x00200000UL
27773 +#define NETLINK_XFRM_SOCKET__NLMSG_READ 0x00400000UL
27774 +#define NETLINK_XFRM_SOCKET__NLMSG_WRITE 0x00800000UL
27775 +#define NETLINK_SELINUX_SOCKET__IOCTL 0x00000001UL
27776 +#define NETLINK_SELINUX_SOCKET__READ 0x00000002UL
27777 +#define NETLINK_SELINUX_SOCKET__WRITE 0x00000004UL
27778 +#define NETLINK_SELINUX_SOCKET__CREATE 0x00000008UL
27779 +#define NETLINK_SELINUX_SOCKET__GETATTR 0x00000010UL
27780 +#define NETLINK_SELINUX_SOCKET__SETATTR 0x00000020UL
27781 +#define NETLINK_SELINUX_SOCKET__LOCK 0x00000040UL
27782 +#define NETLINK_SELINUX_SOCKET__RELABELFROM 0x00000080UL
27783 +#define NETLINK_SELINUX_SOCKET__RELABELTO 0x00000100UL
27784 +#define NETLINK_SELINUX_SOCKET__APPEND 0x00000200UL
27785 +#define NETLINK_SELINUX_SOCKET__BIND 0x00000400UL
27786 +#define NETLINK_SELINUX_SOCKET__CONNECT 0x00000800UL
27787 +#define NETLINK_SELINUX_SOCKET__LISTEN 0x00001000UL
27788 +#define NETLINK_SELINUX_SOCKET__ACCEPT 0x00002000UL
27789 +#define NETLINK_SELINUX_SOCKET__GETOPT 0x00004000UL
27790 +#define NETLINK_SELINUX_SOCKET__SETOPT 0x00008000UL
27791 +#define NETLINK_SELINUX_SOCKET__SHUTDOWN 0x00010000UL
27792 +#define NETLINK_SELINUX_SOCKET__RECVFROM 0x00020000UL
27793 +#define NETLINK_SELINUX_SOCKET__SENDTO 0x00040000UL
27794 +#define NETLINK_SELINUX_SOCKET__RECV_MSG 0x00080000UL
27795 +#define NETLINK_SELINUX_SOCKET__SEND_MSG 0x00100000UL
27796 +#define NETLINK_SELINUX_SOCKET__NAME_BIND 0x00200000UL
27797 +#define NETLINK_AUDIT_SOCKET__IOCTL 0x00000001UL
27798 +#define NETLINK_AUDIT_SOCKET__READ 0x00000002UL
27799 +#define NETLINK_AUDIT_SOCKET__WRITE 0x00000004UL
27800 +#define NETLINK_AUDIT_SOCKET__CREATE 0x00000008UL
27801 +#define NETLINK_AUDIT_SOCKET__GETATTR 0x00000010UL
27802 +#define NETLINK_AUDIT_SOCKET__SETATTR 0x00000020UL
27803 +#define NETLINK_AUDIT_SOCKET__LOCK 0x00000040UL
27804 +#define NETLINK_AUDIT_SOCKET__RELABELFROM 0x00000080UL
27805 +#define NETLINK_AUDIT_SOCKET__RELABELTO 0x00000100UL
27806 +#define NETLINK_AUDIT_SOCKET__APPEND 0x00000200UL
27807 +#define NETLINK_AUDIT_SOCKET__BIND 0x00000400UL
27808 +#define NETLINK_AUDIT_SOCKET__CONNECT 0x00000800UL
27809 +#define NETLINK_AUDIT_SOCKET__LISTEN 0x00001000UL
27810 +#define NETLINK_AUDIT_SOCKET__ACCEPT 0x00002000UL
27811 +#define NETLINK_AUDIT_SOCKET__GETOPT 0x00004000UL
27812 +#define NETLINK_AUDIT_SOCKET__SETOPT 0x00008000UL
27813 +#define NETLINK_AUDIT_SOCKET__SHUTDOWN 0x00010000UL
27814 +#define NETLINK_AUDIT_SOCKET__RECVFROM 0x00020000UL
27815 +#define NETLINK_AUDIT_SOCKET__SENDTO 0x00040000UL
27816 +#define NETLINK_AUDIT_SOCKET__RECV_MSG 0x00080000UL
27817 +#define NETLINK_AUDIT_SOCKET__SEND_MSG 0x00100000UL
27818 +#define NETLINK_AUDIT_SOCKET__NAME_BIND 0x00200000UL
27819 +#define NETLINK_AUDIT_SOCKET__NLMSG_READ 0x00400000UL
27820 +#define NETLINK_AUDIT_SOCKET__NLMSG_WRITE 0x00800000UL
27821 +#define NETLINK_AUDIT_SOCKET__NLMSG_RELAY 0x01000000UL
27822 +#define NETLINK_AUDIT_SOCKET__NLMSG_READPRIV 0x02000000UL
27823 +#define NETLINK_AUDIT_SOCKET__NLMSG_TTY_AUDIT 0x04000000UL
27824 +#define NETLINK_IP6FW_SOCKET__IOCTL 0x00000001UL
27825 +#define NETLINK_IP6FW_SOCKET__READ 0x00000002UL
27826 +#define NETLINK_IP6FW_SOCKET__WRITE 0x00000004UL
27827 +#define NETLINK_IP6FW_SOCKET__CREATE 0x00000008UL
27828 +#define NETLINK_IP6FW_SOCKET__GETATTR 0x00000010UL
27829 +#define NETLINK_IP6FW_SOCKET__SETATTR 0x00000020UL
27830 +#define NETLINK_IP6FW_SOCKET__LOCK 0x00000040UL
27831 +#define NETLINK_IP6FW_SOCKET__RELABELFROM 0x00000080UL
27832 +#define NETLINK_IP6FW_SOCKET__RELABELTO 0x00000100UL
27833 +#define NETLINK_IP6FW_SOCKET__APPEND 0x00000200UL
27834 +#define NETLINK_IP6FW_SOCKET__BIND 0x00000400UL
27835 +#define NETLINK_IP6FW_SOCKET__CONNECT 0x00000800UL
27836 +#define NETLINK_IP6FW_SOCKET__LISTEN 0x00001000UL
27837 +#define NETLINK_IP6FW_SOCKET__ACCEPT 0x00002000UL
27838 +#define NETLINK_IP6FW_SOCKET__GETOPT 0x00004000UL
27839 +#define NETLINK_IP6FW_SOCKET__SETOPT 0x00008000UL
27840 +#define NETLINK_IP6FW_SOCKET__SHUTDOWN 0x00010000UL
27841 +#define NETLINK_IP6FW_SOCKET__RECVFROM 0x00020000UL
27842 +#define NETLINK_IP6FW_SOCKET__SENDTO 0x00040000UL
27843 +#define NETLINK_IP6FW_SOCKET__RECV_MSG 0x00080000UL
27844 +#define NETLINK_IP6FW_SOCKET__SEND_MSG 0x00100000UL
27845 +#define NETLINK_IP6FW_SOCKET__NAME_BIND 0x00200000UL
27846 +#define NETLINK_IP6FW_SOCKET__NLMSG_READ 0x00400000UL
27847 +#define NETLINK_IP6FW_SOCKET__NLMSG_WRITE 0x00800000UL
27848 +#define NETLINK_DNRT_SOCKET__IOCTL 0x00000001UL
27849 +#define NETLINK_DNRT_SOCKET__READ 0x00000002UL
27850 +#define NETLINK_DNRT_SOCKET__WRITE 0x00000004UL
27851 +#define NETLINK_DNRT_SOCKET__CREATE 0x00000008UL
27852 +#define NETLINK_DNRT_SOCKET__GETATTR 0x00000010UL
27853 +#define NETLINK_DNRT_SOCKET__SETATTR 0x00000020UL
27854 +#define NETLINK_DNRT_SOCKET__LOCK 0x00000040UL
27855 +#define NETLINK_DNRT_SOCKET__RELABELFROM 0x00000080UL
27856 +#define NETLINK_DNRT_SOCKET__RELABELTO 0x00000100UL
27857 +#define NETLINK_DNRT_SOCKET__APPEND 0x00000200UL
27858 +#define NETLINK_DNRT_SOCKET__BIND 0x00000400UL
27859 +#define NETLINK_DNRT_SOCKET__CONNECT 0x00000800UL
27860 +#define NETLINK_DNRT_SOCKET__LISTEN 0x00001000UL
27861 +#define NETLINK_DNRT_SOCKET__ACCEPT 0x00002000UL
27862 +#define NETLINK_DNRT_SOCKET__GETOPT 0x00004000UL
27863 +#define NETLINK_DNRT_SOCKET__SETOPT 0x00008000UL
27864 +#define NETLINK_DNRT_SOCKET__SHUTDOWN 0x00010000UL
27865 +#define NETLINK_DNRT_SOCKET__RECVFROM 0x00020000UL
27866 +#define NETLINK_DNRT_SOCKET__SENDTO 0x00040000UL
27867 +#define NETLINK_DNRT_SOCKET__RECV_MSG 0x00080000UL
27868 +#define NETLINK_DNRT_SOCKET__SEND_MSG 0x00100000UL
27869 +#define NETLINK_DNRT_SOCKET__NAME_BIND 0x00200000UL
27870 +#define ASSOCIATION__SENDTO 0x00000001UL
27871 +#define ASSOCIATION__RECVFROM 0x00000002UL
27872 +#define ASSOCIATION__SETCONTEXT 0x00000004UL
27873 +#define ASSOCIATION__POLMATCH 0x00000008UL
27874 +#define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL 0x00000001UL
27875 +#define NETLINK_KOBJECT_UEVENT_SOCKET__READ 0x00000002UL
27876 +#define NETLINK_KOBJECT_UEVENT_SOCKET__WRITE 0x00000004UL
27877 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CREATE 0x00000008UL
27878 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETATTR 0x00000010UL
27879 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETATTR 0x00000020UL
27880 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LOCK 0x00000040UL
27881 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELFROM 0x00000080UL
27882 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELTO 0x00000100UL
27883 +#define NETLINK_KOBJECT_UEVENT_SOCKET__APPEND 0x00000200UL
27884 +#define NETLINK_KOBJECT_UEVENT_SOCKET__BIND 0x00000400UL
27885 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CONNECT 0x00000800UL
27886 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LISTEN 0x00001000UL
27887 +#define NETLINK_KOBJECT_UEVENT_SOCKET__ACCEPT 0x00002000UL
27888 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETOPT 0x00004000UL
27889 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETOPT 0x00008000UL
27890 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SHUTDOWN 0x00010000UL
27891 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECVFROM 0x00020000UL
27892 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SENDTO 0x00040000UL
27893 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECV_MSG 0x00080000UL
27894 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SEND_MSG 0x00100000UL
27895 +#define NETLINK_KOBJECT_UEVENT_SOCKET__NAME_BIND 0x00200000UL
27896 +#define APPLETALK_SOCKET__IOCTL 0x00000001UL
27897 +#define APPLETALK_SOCKET__READ 0x00000002UL
27898 +#define APPLETALK_SOCKET__WRITE 0x00000004UL
27899 +#define APPLETALK_SOCKET__CREATE 0x00000008UL
27900 +#define APPLETALK_SOCKET__GETATTR 0x00000010UL
27901 +#define APPLETALK_SOCKET__SETATTR 0x00000020UL
27902 +#define APPLETALK_SOCKET__LOCK 0x00000040UL
27903 +#define APPLETALK_SOCKET__RELABELFROM 0x00000080UL
27904 +#define APPLETALK_SOCKET__RELABELTO 0x00000100UL
27905 +#define APPLETALK_SOCKET__APPEND 0x00000200UL
27906 +#define APPLETALK_SOCKET__BIND 0x00000400UL
27907 +#define APPLETALK_SOCKET__CONNECT 0x00000800UL
27908 +#define APPLETALK_SOCKET__LISTEN 0x00001000UL
27909 +#define APPLETALK_SOCKET__ACCEPT 0x00002000UL
27910 +#define APPLETALK_SOCKET__GETOPT 0x00004000UL
27911 +#define APPLETALK_SOCKET__SETOPT 0x00008000UL
27912 +#define APPLETALK_SOCKET__SHUTDOWN 0x00010000UL
27913 +#define APPLETALK_SOCKET__RECVFROM 0x00020000UL
27914 +#define APPLETALK_SOCKET__SENDTO 0x00040000UL
27915 +#define APPLETALK_SOCKET__RECV_MSG 0x00080000UL
27916 +#define APPLETALK_SOCKET__SEND_MSG 0x00100000UL
27917 +#define APPLETALK_SOCKET__NAME_BIND 0x00200000UL
27918 +#define PACKET__SEND 0x00000001UL
27919 +#define PACKET__RECV 0x00000002UL
27920 +#define PACKET__RELABELTO 0x00000004UL
27921 +#define PACKET__FLOW_IN 0x00000008UL
27922 +#define PACKET__FLOW_OUT 0x00000010UL
27923 +#define PACKET__FORWARD_IN 0x00000020UL
27924 +#define PACKET__FORWARD_OUT 0x00000040UL
27925 +#define KEY__VIEW 0x00000001UL
27926 +#define KEY__READ 0x00000002UL
27927 +#define KEY__WRITE 0x00000004UL
27928 +#define KEY__SEARCH 0x00000008UL
27929 +#define KEY__LINK 0x00000010UL
27930 +#define KEY__SETATTR 0x00000020UL
27931 +#define KEY__CREATE 0x00000040UL
27932 +#define DCCP_SOCKET__IOCTL 0x00000001UL
27933 +#define DCCP_SOCKET__READ 0x00000002UL
27934 +#define DCCP_SOCKET__WRITE 0x00000004UL
27935 +#define DCCP_SOCKET__CREATE 0x00000008UL
27936 +#define DCCP_SOCKET__GETATTR 0x00000010UL
27937 +#define DCCP_SOCKET__SETATTR 0x00000020UL
27938 +#define DCCP_SOCKET__LOCK 0x00000040UL
27939 +#define DCCP_SOCKET__RELABELFROM 0x00000080UL
27940 +#define DCCP_SOCKET__RELABELTO 0x00000100UL
27941 +#define DCCP_SOCKET__APPEND 0x00000200UL
27942 +#define DCCP_SOCKET__BIND 0x00000400UL
27943 +#define DCCP_SOCKET__CONNECT 0x00000800UL
27944 +#define DCCP_SOCKET__LISTEN 0x00001000UL
27945 +#define DCCP_SOCKET__ACCEPT 0x00002000UL
27946 +#define DCCP_SOCKET__GETOPT 0x00004000UL
27947 +#define DCCP_SOCKET__SETOPT 0x00008000UL
27948 +#define DCCP_SOCKET__SHUTDOWN 0x00010000UL
27949 +#define DCCP_SOCKET__RECVFROM 0x00020000UL
27950 +#define DCCP_SOCKET__SENDTO 0x00040000UL
27951 +#define DCCP_SOCKET__RECV_MSG 0x00080000UL
27952 +#define DCCP_SOCKET__SEND_MSG 0x00100000UL
27953 +#define DCCP_SOCKET__NAME_BIND 0x00200000UL
27954 +#define DCCP_SOCKET__NODE_BIND 0x00400000UL
27955 +#define DCCP_SOCKET__NAME_CONNECT 0x00800000UL
27956 +#define MEMPROTECT__MMAP_ZERO 0x00000001UL
27957 +#define PEER__RECV 0x00000001UL
27958 +#define CAPABILITY2__MAC_OVERRIDE 0x00000001UL
27959 +#define CAPABILITY2__MAC_ADMIN 0x00000002UL
27960 +#define KERNEL_SERVICE__USE_AS_OVERRIDE 0x00000001UL
27961 +#define KERNEL_SERVICE__CREATE_FILES_AS 0x00000002UL
27962 +#define TUN_SOCKET__IOCTL 0x00000001UL
27963 +#define TUN_SOCKET__READ 0x00000002UL
27964 +#define TUN_SOCKET__WRITE 0x00000004UL
27965 +#define TUN_SOCKET__CREATE 0x00000008UL
27966 +#define TUN_SOCKET__GETATTR 0x00000010UL
27967 +#define TUN_SOCKET__SETATTR 0x00000020UL
27968 +#define TUN_SOCKET__LOCK 0x00000040UL
27969 +#define TUN_SOCKET__RELABELFROM 0x00000080UL
27970 +#define TUN_SOCKET__RELABELTO 0x00000100UL
27971 +#define TUN_SOCKET__APPEND 0x00000200UL
27972 +#define TUN_SOCKET__BIND 0x00000400UL
27973 +#define TUN_SOCKET__CONNECT 0x00000800UL
27974 +#define TUN_SOCKET__LISTEN 0x00001000UL
27975 +#define TUN_SOCKET__ACCEPT 0x00002000UL
27976 +#define TUN_SOCKET__GETOPT 0x00004000UL
27977 +#define TUN_SOCKET__SETOPT 0x00008000UL
27978 +#define TUN_SOCKET__SHUTDOWN 0x00010000UL
27979 +#define TUN_SOCKET__RECVFROM 0x00020000UL
27980 +#define TUN_SOCKET__SENDTO 0x00040000UL
27981 +#define TUN_SOCKET__RECV_MSG 0x00080000UL
27982 +#define TUN_SOCKET__SEND_MSG 0x00100000UL
27983 +#define TUN_SOCKET__NAME_BIND 0x00200000UL
27986 diff -NurpP --minimal linux-2.6.35.7/security/selinux/hooks.c linux-2.6.35.7-vs2.3.0.36.33/security/selinux/hooks.c
27987 --- linux-2.6.35.7/security/selinux/hooks.c 2010-08-02 16:53:03.000000000 +0200
27988 +++ linux-2.6.35.7-vs2.3.0.36.33/security/selinux/hooks.c 2010-08-02 17:05:06.000000000 +0200
27990 #include <linux/dccp.h>
27991 #include <linux/quota.h>
27992 #include <linux/un.h> /* for Unix socket types */
27993 -#include <net/af_unix.h> /* for Unix socket types */
27994 #include <linux/parser.h>
27995 #include <linux/nfs_mount.h>
27996 #include <net/ipv6.h>