1 diff -NurpP --minimal linux-2.6.35/arch/alpha/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/alpha/Kconfig
2 --- linux-2.6.35/arch/alpha/Kconfig 2010-08-02 16:51:53.000000000 +0200
3 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/alpha/kernel/entry.S linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/entry.S
14 --- linux-2.6.35/arch/alpha/kernel/entry.S 2009-06-11 17:11:46.000000000 +0200
15 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/alpha/kernel/osf_sys.c linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.35/arch/alpha/kernel/osf_sys.c 2010-07-07 18:30:51.000000000 +0200
50 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/alpha/kernel/ptrace.c linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.35/arch/alpha/kernel/ptrace.c 2010-07-07 18:30:51.000000000 +0200
62 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/alpha/kernel/systbls.S linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/systbls.S
72 --- linux-2.6.35/arch/alpha/kernel/systbls.S 2010-02-25 11:51:19.000000000 +0100
73 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/alpha/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/traps.c
84 --- linux-2.6.35/arch/alpha/kernel/traps.c 2010-07-07 18:30:51.000000000 +0200
85 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/arm/include/asm/tlb.h linux-2.6.35-vs2.3.0.36.31/arch/arm/include/asm/tlb.h
97 --- linux-2.6.35/arch/arm/include/asm/tlb.h 2009-09-10 15:25:15.000000000 +0200
98 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/arm/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/arm/Kconfig
108 --- linux-2.6.35/arch/arm/Kconfig 2010-08-02 16:51:53.000000000 +0200
109 +++ linux-2.6.35-vs2.3.0.36.31/arch/arm/Kconfig 2010-08-02 17:05:05.000000000 +0200
110 @@ -1673,6 +1673,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/arch/arm/kernel/calls.S linux-2.6.35-vs2.3.0.36.31/arch/arm/kernel/calls.S
120 --- linux-2.6.35/arch/arm/kernel/calls.S 2010-07-07 18:30:52.000000000 +0200
121 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/arm/kernel/process.c linux-2.6.35-vs2.3.0.36.31/arch/arm/kernel/process.c
132 --- linux-2.6.35/arch/arm/kernel/process.c 2010-08-02 16:51:55.000000000 +0200
133 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/arm/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/arm/kernel/traps.c
145 --- linux-2.6.35/arch/arm/kernel/traps.c 2010-07-07 18:30:52.000000000 +0200
146 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/avr32/mm/fault.c linux-2.6.35-vs2.3.0.36.31/arch/avr32/mm/fault.c
159 --- linux-2.6.35/arch/avr32/mm/fault.c 2009-09-10 15:25:20.000000000 +0200
160 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/cris/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/cris/Kconfig
172 --- linux-2.6.35/arch/cris/Kconfig 2010-08-02 16:52:03.000000000 +0200
173 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/cris/mm/fault.c linux-2.6.35-vs2.3.0.36.31/arch/cris/mm/fault.c
184 --- linux-2.6.35/arch/cris/mm/fault.c 2010-02-25 11:51:26.000000000 +0100
185 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/frv/kernel/kernel_thread.S linux-2.6.35-vs2.3.0.36.31/arch/frv/kernel/kernel_thread.S
197 --- linux-2.6.35/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
198 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/h8300/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/h8300/Kconfig
209 --- linux-2.6.35/arch/h8300/Kconfig 2010-02-25 11:51:26.000000000 +0100
210 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/ia64/include/asm/tlb.h linux-2.6.35-vs2.3.0.36.31/arch/ia64/include/asm/tlb.h
221 --- linux-2.6.35/arch/ia64/include/asm/tlb.h 2010-02-25 11:51:26.000000000 +0100
222 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/ia64/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/ia64/Kconfig
232 --- linux-2.6.35/arch/ia64/Kconfig 2010-08-02 16:52:03.000000000 +0200
233 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/ia64/kernel/entry.S linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/entry.S
244 --- linux-2.6.35/arch/ia64/kernel/entry.S 2010-07-07 18:31:01.000000000 +0200
245 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/ia64/kernel/perfmon.c linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/perfmon.c
256 --- linux-2.6.35/arch/ia64/kernel/perfmon.c 2010-07-07 18:31:01.000000000 +0200
257 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/ia64/kernel/process.c linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/process.c
267 --- linux-2.6.35/arch/ia64/kernel/process.c 2010-07-07 18:31:01.000000000 +0200
268 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/ia64/kernel/ptrace.c linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/ptrace.c
281 --- linux-2.6.35/arch/ia64/kernel/ptrace.c 2010-08-02 16:52:04.000000000 +0200
282 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/ia64/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/traps.c
292 --- linux-2.6.35/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
293 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/ia64/mm/fault.c linux-2.6.35-vs2.3.0.36.31/arch/ia64/mm/fault.c
319 --- linux-2.6.35/arch/ia64/mm/fault.c 2010-08-02 16:52:04.000000000 +0200
320 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/m32r/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/m32r/kernel/traps.c
330 --- linux-2.6.35/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
331 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/m68k/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/m68k/Kconfig
345 --- linux-2.6.35/arch/m68k/Kconfig 2010-08-02 16:52:04.000000000 +0200
346 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/m68k/kernel/ptrace.c linux-2.6.35-vs2.3.0.36.31/arch/m68k/kernel/ptrace.c
357 --- linux-2.6.35/arch/m68k/kernel/ptrace.c 2010-07-07 18:31:02.000000000 +0200
358 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/m68k/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/m68k/kernel/traps.c
377 --- linux-2.6.35/arch/m68k/kernel/traps.c 2010-08-02 16:52:04.000000000 +0200
378 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/m68knommu/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/m68knommu/Kconfig
391 --- linux-2.6.35/arch/m68knommu/Kconfig 2010-08-02 16:52:04.000000000 +0200
392 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/m68knommu/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/m68knommu/kernel/traps.c
403 --- linux-2.6.35/arch/m68knommu/kernel/traps.c 2009-09-10 15:25:23.000000000 +0200
404 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/mips/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/mips/Kconfig
418 --- linux-2.6.35/arch/mips/Kconfig 2010-08-02 16:52:05.000000000 +0200
419 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/mips/kernel/ptrace.c linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/ptrace.c
430 --- linux-2.6.35/arch/mips/kernel/ptrace.c 2010-07-07 18:31:04.000000000 +0200
431 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/mips/kernel/scall32-o32.S linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/scall32-o32.S
451 --- linux-2.6.35/arch/mips/kernel/scall32-o32.S 2010-02-25 11:51:28.000000000 +0100
452 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/mips/kernel/scall64-64.S linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/scall64-64.S
463 --- linux-2.6.35/arch/mips/kernel/scall64-64.S 2010-02-25 11:51:28.000000000 +0100
464 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/mips/kernel/scall64-n32.S linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/scall64-n32.S
475 --- linux-2.6.35/arch/mips/kernel/scall64-n32.S 2010-08-02 16:52:05.000000000 +0200
476 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/mips/kernel/scall64-o32.S linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/scall64-o32.S
487 --- linux-2.6.35/arch/mips/kernel/scall64-o32.S 2010-07-07 18:31:04.000000000 +0200
488 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/mips/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/traps.c
499 --- linux-2.6.35/arch/mips/kernel/traps.c 2010-08-02 16:52:05.000000000 +0200
500 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/parisc/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/parisc/Kconfig
516 --- linux-2.6.35/arch/parisc/Kconfig 2010-08-02 16:52:06.000000000 +0200
517 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/parisc/kernel/syscall_table.S linux-2.6.35-vs2.3.0.36.31/arch/parisc/kernel/syscall_table.S
528 --- linux-2.6.35/arch/parisc/kernel/syscall_table.S 2010-07-07 18:31:04.000000000 +0200
529 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/parisc/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/parisc/kernel/traps.c
540 --- linux-2.6.35/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
541 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/parisc/mm/fault.c linux-2.6.35-vs2.3.0.36.31/arch/parisc/mm/fault.c
566 --- linux-2.6.35/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
567 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/powerpc/include/asm/unistd.h linux-2.6.35-vs2.3.0.36.31/arch/powerpc/include/asm/unistd.h
581 --- linux-2.6.35/arch/powerpc/include/asm/unistd.h 2010-07-07 18:31:05.000000000 +0200
582 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/powerpc/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/powerpc/Kconfig
593 --- linux-2.6.35/arch/powerpc/Kconfig 2010-08-02 16:52:06.000000000 +0200
594 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/powerpc/kernel/process.c linux-2.6.35-vs2.3.0.36.31/arch/powerpc/kernel/process.c
605 --- linux-2.6.35/arch/powerpc/kernel/process.c 2010-08-02 16:52:07.000000000 +0200
606 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/powerpc/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/powerpc/kernel/traps.c
620 --- linux-2.6.35/arch/powerpc/kernel/traps.c 2010-08-02 16:52:07.000000000 +0200
621 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/powerpc/kernel/vdso.c linux-2.6.35-vs2.3.0.36.31/arch/powerpc/kernel/vdso.c
635 --- linux-2.6.35/arch/powerpc/kernel/vdso.c 2010-08-02 16:52:07.000000000 +0200
636 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/s390/include/asm/tlb.h linux-2.6.35-vs2.3.0.36.31/arch/s390/include/asm/tlb.h
646 --- linux-2.6.35/arch/s390/include/asm/tlb.h 2009-09-10 15:25:43.000000000 +0200
647 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/s390/include/asm/unistd.h linux-2.6.35-vs2.3.0.36.31/arch/s390/include/asm/unistd.h
658 --- linux-2.6.35/arch/s390/include/asm/unistd.h 2010-07-07 18:31:06.000000000 +0200
659 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/s390/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/s390/Kconfig
670 --- linux-2.6.35/arch/s390/Kconfig 2010-08-02 16:52:08.000000000 +0200
671 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/s390/kernel/ptrace.c linux-2.6.35-vs2.3.0.36.31/arch/s390/kernel/ptrace.c
682 --- linux-2.6.35/arch/s390/kernel/ptrace.c 2010-08-02 16:52:09.000000000 +0200
683 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/s390/kernel/syscalls.S linux-2.6.35-vs2.3.0.36.31/arch/s390/kernel/syscalls.S
693 --- linux-2.6.35/arch/s390/kernel/syscalls.S 2010-07-07 18:31:07.000000000 +0200
694 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/sh/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/sh/Kconfig
705 --- linux-2.6.35/arch/sh/Kconfig 2010-08-02 16:52:09.000000000 +0200
706 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/sh/kernel/irq.c linux-2.6.35-vs2.3.0.36.31/arch/sh/kernel/irq.c
717 --- linux-2.6.35/arch/sh/kernel/irq.c 2010-08-02 16:52:10.000000000 +0200
718 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.35-vs2.3.0.36.31/arch/sh/kernel/vsyscall/vsyscall.c
728 --- linux-2.6.35/arch/sh/kernel/vsyscall/vsyscall.c 2010-07-07 18:31:10.000000000 +0200
729 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/sparc/include/asm/tlb_64.h linux-2.6.35-vs2.3.0.36.31/arch/sparc/include/asm/tlb_64.h
739 --- linux-2.6.35/arch/sparc/include/asm/tlb_64.h 2009-09-10 15:25:45.000000000 +0200
740 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/sparc/include/asm/unistd.h linux-2.6.35-vs2.3.0.36.31/arch/sparc/include/asm/unistd.h
750 --- linux-2.6.35/arch/sparc/include/asm/unistd.h 2010-07-07 18:31:10.000000000 +0200
751 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/sparc/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/sparc/Kconfig
762 --- linux-2.6.35/arch/sparc/Kconfig 2010-08-02 16:52:10.000000000 +0200
763 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/sparc/kernel/systbls_32.S linux-2.6.35-vs2.3.0.36.31/arch/sparc/kernel/systbls_32.S
774 --- linux-2.6.35/arch/sparc/kernel/systbls_32.S 2010-02-25 11:51:34.000000000 +0100
775 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/sparc/kernel/systbls_64.S linux-2.6.35-vs2.3.0.36.31/arch/sparc/kernel/systbls_64.S
786 --- linux-2.6.35/arch/sparc/kernel/systbls_64.S 2010-07-07 18:31:10.000000000 +0200
787 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/um/include/asm/tlb.h linux-2.6.35-vs2.3.0.36.31/arch/um/include/asm/tlb.h
807 --- linux-2.6.35/arch/um/include/asm/tlb.h 2009-09-10 15:25:46.000000000 +0200
808 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/um/include/shared/kern_constants.h linux-2.6.35-vs2.3.0.36.31/arch/um/include/shared/kern_constants.h
818 --- linux-2.6.35/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
819 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/um/include/shared/user_constants.h linux-2.6.35-vs2.3.0.36.31/arch/um/include/shared/user_constants.h
823 --- linux-2.6.35/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
824 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/um/Kconfig.rest linux-2.6.35-vs2.3.0.36.31/arch/um/Kconfig.rest
867 --- linux-2.6.35/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
868 +++ linux-2.6.35-vs2.3.0.36.31/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/arch/um/kernel/config.c linux-2.6.35-vs2.3.0.36.31/arch/um/kernel/config.c
879 --- linux-2.6.35/arch/um/kernel/config.c 1970-01-01 01:00:00.000000000 +0100
880 +++ linux-2.6.35-vs2.3.0.36.31/arch/um/kernel/config.c 2010-08-02 17:05:05.000000000 +0200
883 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
884 + * Licensed under the GPL
891 +static __initdata const char *config[] = {
894 +"# Automatically generated make config: don't edit\n",
895 +"# Linux kernel version: 2.6.33-vs2.3.0.36.29.1\n",
896 +"# Wed Mar 10 20:29:46 2010\n",
898 +"CONFIG_DEFCONFIG_LIST=\"arch/$ARCH/defconfig\"\n",
899 +"CONFIG_GENERIC_HARDIRQS=y\n",
902 +"CONFIG_NO_IOMEM=y\n",
903 +"# CONFIG_TRACE_IRQFLAGS_SUPPORT is not set\n",
904 +"CONFIG_LOCKDEP_SUPPORT=y\n",
905 +"# CONFIG_STACKTRACE_SUPPORT is not set\n",
906 +"CONFIG_GENERIC_CALIBRATE_DELAY=y\n",
907 +"CONFIG_GENERIC_BUG=y\n",
908 +"CONFIG_GENERIC_TIME=y\n",
909 +"CONFIG_GENERIC_CLOCKEVENTS=y\n",
910 +"CONFIG_IRQ_RELEASE_METHOD=y\n",
914 +"# UML-specific options\n",
918 +"# Host processor type and features\n",
920 +"# CONFIG_M386 is not set\n",
921 +"# CONFIG_M486 is not set\n",
922 +"# CONFIG_M586 is not set\n",
923 +"# CONFIG_M586TSC is not set\n",
924 +"# CONFIG_M586MMX is not set\n",
925 +"# CONFIG_M686 is not set\n",
926 +"# CONFIG_MPENTIUMII is not set\n",
927 +"# CONFIG_MPENTIUMIII is not set\n",
928 +"# CONFIG_MPENTIUMM is not set\n",
929 +"# CONFIG_MPENTIUM4 is not set\n",
930 +"# CONFIG_MK6 is not set\n",
931 +"# CONFIG_MK7 is not set\n",
933 +"# CONFIG_MCRUSOE is not set\n",
934 +"# CONFIG_MEFFICEON is not set\n",
935 +"# CONFIG_MWINCHIPC6 is not set\n",
936 +"# CONFIG_MWINCHIP3D is not set\n",
937 +"# CONFIG_MGEODEGX1 is not set\n",
938 +"# CONFIG_MGEODE_LX is not set\n",
939 +"# CONFIG_MCYRIXIII is not set\n",
940 +"# CONFIG_MVIAC3_2 is not set\n",
941 +"# CONFIG_MVIAC7 is not set\n",
942 +"# CONFIG_MPSC is not set\n",
943 +"# CONFIG_MCORE2 is not set\n",
944 +"# CONFIG_MATOM is not set\n",
945 +"# CONFIG_GENERIC_CPU is not set\n",
946 +"CONFIG_X86_CPU=y\n",
947 +"CONFIG_X86_INTERNODE_CACHE_SHIFT=6\n",
948 +"# CONFIG_X86_CMPXCHG is not set\n",
949 +"CONFIG_X86_L1_CACHE_SHIFT=6\n",
950 +"CONFIG_X86_WP_WORKS_OK=y\n",
951 +"CONFIG_X86_INTEL_USERCOPY=y\n",
952 +"CONFIG_X86_USE_PPRO_CHECKSUM=y\n",
953 +"CONFIG_X86_TSC=y\n",
954 +"CONFIG_X86_CMOV=y\n",
955 +"CONFIG_X86_MINIMUM_CPU_FAMILY=3\n",
956 +"CONFIG_CPU_SUP_INTEL=y\n",
957 +"CONFIG_CPU_SUP_AMD=y\n",
958 +"CONFIG_CPU_SUP_CENTAUR=y\n",
959 +"CONFIG_UML_X86=y\n",
961 +"# CONFIG_X86_32 is not set\n",
962 +"# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set\n",
963 +"CONFIG_RWSEM_GENERIC_SPINLOCK=y\n",
964 +"# CONFIG_ARCH_HAS_SC_SIGNALS is not set\n",
965 +"# CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA is not set\n",
966 +"CONFIG_SMP_BROKEN=y\n",
967 +"CONFIG_GENERIC_HWEIGHT=y\n",
968 +"# CONFIG_STATIC_LINK is not set\n",
969 +"CONFIG_FLATMEM=y\n",
970 +"CONFIG_FLAT_NODE_MEM_MAP=y\n",
971 +"CONFIG_PAGEFLAGS_EXTENDED=y\n",
972 +"CONFIG_SPLIT_PTLOCK_CPUS=4\n",
973 +"CONFIG_PHYS_ADDR_T_64BIT=y\n",
974 +"CONFIG_ZONE_DMA_FLAG=0\n",
975 +"CONFIG_VIRT_TO_BUS=y\n",
976 +"# CONFIG_KSM is not set\n",
977 +"CONFIG_DEFAULT_MMAP_MIN_ADDR=4096\n",
978 +"# CONFIG_NO_HZ is not set\n",
979 +"# CONFIG_HIGH_RES_TIMERS is not set\n",
980 +"CONFIG_GENERIC_CLOCKEVENTS_BUILD=y\n",
981 +"CONFIG_LD_SCRIPT_DYN=y\n",
982 +"# CONFIG_BINFMT_ELF is not set\n",
983 +"# CONFIG_HAVE_AOUT is not set\n",
984 +"# CONFIG_BINFMT_MISC is not set\n",
985 +"# CONFIG_HOSTFS is not set\n",
986 +"# CONFIG_MCONSOLE is not set\n",
987 +"CONFIG_KERNEL_STACK_ORDER=1\n",
990 +"# General setup\n",
992 +"# CONFIG_EXPERIMENTAL is not set\n",
993 +"CONFIG_BROKEN_ON_SMP=y\n",
994 +"CONFIG_INIT_ENV_ARG_LIMIT=128\n",
995 +"CONFIG_LOCALVERSION=\"\"\n",
996 +"# CONFIG_LOCALVERSION_AUTO is not set\n",
997 +"# CONFIG_SWAP is not set\n",
998 +"CONFIG_SYSVIPC=y\n",
999 +"CONFIG_SYSVIPC_SYSCTL=y\n",
1000 +"# CONFIG_BSD_PROCESS_ACCT is not set\n",
1003 +"# RCU Subsystem\n",
1005 +"CONFIG_TREE_RCU=y\n",
1006 +"# CONFIG_TREE_PREEMPT_RCU is not set\n",
1007 +"# CONFIG_TINY_RCU is not set\n",
1008 +"# CONFIG_RCU_TRACE is not set\n",
1009 +"CONFIG_RCU_FANOUT=64\n",
1010 +"# CONFIG_RCU_FANOUT_EXACT is not set\n",
1011 +"# CONFIG_TREE_RCU_TRACE is not set\n",
1012 +"# CONFIG_IKCONFIG is not set\n",
1013 +"CONFIG_LOG_BUF_SHIFT=17\n",
1014 +"# CONFIG_CGROUPS is not set\n",
1015 +"# CONFIG_SYSFS_DEPRECATED_V2 is not set\n",
1016 +"# CONFIG_RELAY is not set\n",
1017 +"CONFIG_NAMESPACES=y\n",
1018 +"CONFIG_UTS_NS=y\n",
1019 +"CONFIG_IPC_NS=y\n",
1020 +"CONFIG_USER_NS=y\n",
1021 +"# CONFIG_BLK_DEV_INITRD is not set\n",
1022 +"# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set\n",
1023 +"CONFIG_SYSCTL=y\n",
1024 +"CONFIG_ANON_INODES=y\n",
1025 +"# CONFIG_EMBEDDED is not set\n",
1026 +"CONFIG_UID16=y\n",
1027 +"CONFIG_SYSCTL_SYSCALL=y\n",
1028 +"CONFIG_KALLSYMS=y\n",
1029 +"# CONFIG_KALLSYMS_EXTRA_PASS is not set\n",
1030 +"CONFIG_HOTPLUG=y\n",
1031 +"CONFIG_PRINTK=y\n",
1033 +"CONFIG_ELF_CORE=y\n",
1034 +"CONFIG_BASE_FULL=y\n",
1035 +"CONFIG_FUTEX=y\n",
1036 +"CONFIG_EPOLL=y\n",
1037 +"CONFIG_SIGNALFD=y\n",
1038 +"CONFIG_TIMERFD=y\n",
1039 +"CONFIG_EVENTFD=y\n",
1040 +"CONFIG_SHMEM=y\n",
1044 +"# Kernel Performance Events And Counters\n",
1046 +"CONFIG_VM_EVENT_COUNTERS=y\n",
1047 +"CONFIG_SLUB_DEBUG=y\n",
1048 +"# CONFIG_COMPAT_BRK is not set\n",
1049 +"# CONFIG_SLAB is not set\n",
1051 +"# CONFIG_SLOB is not set\n",
1052 +"# CONFIG_PROFILING is not set\n",
1055 +"# GCOV-based kernel profiling\n",
1057 +"# CONFIG_SLOW_WORK is not set\n",
1058 +"# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set\n",
1059 +"CONFIG_SLABINFO=y\n",
1060 +"CONFIG_RT_MUTEXES=y\n",
1061 +"CONFIG_BASE_SMALL=0\n",
1062 +"# CONFIG_MODULES is not set\n",
1063 +"CONFIG_BLOCK=y\n",
1064 +"# CONFIG_BLK_DEV_BSG is not set\n",
1065 +"# CONFIG_BLK_DEV_INTEGRITY is not set\n",
1068 +"# IO Schedulers\n",
1070 +"CONFIG_IOSCHED_NOOP=y\n",
1071 +"# CONFIG_IOSCHED_DEADLINE is not set\n",
1072 +"# CONFIG_IOSCHED_CFQ is not set\n",
1073 +"# CONFIG_DEFAULT_DEADLINE is not set\n",
1074 +"# CONFIG_DEFAULT_CFQ is not set\n",
1075 +"CONFIG_DEFAULT_NOOP=y\n",
1076 +"CONFIG_DEFAULT_IOSCHED=\"noop\"\n",
1077 +"# CONFIG_INLINE_SPIN_TRYLOCK is not set\n",
1078 +"# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set\n",
1079 +"# CONFIG_INLINE_SPIN_LOCK is not set\n",
1080 +"# CONFIG_INLINE_SPIN_LOCK_BH is not set\n",
1081 +"# CONFIG_INLINE_SPIN_LOCK_IRQ is not set\n",
1082 +"# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set\n",
1083 +"CONFIG_INLINE_SPIN_UNLOCK=y\n",
1084 +"# CONFIG_INLINE_SPIN_UNLOCK_BH is not set\n",
1085 +"CONFIG_INLINE_SPIN_UNLOCK_IRQ=y\n",
1086 +"# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set\n",
1087 +"# CONFIG_INLINE_READ_TRYLOCK is not set\n",
1088 +"# CONFIG_INLINE_READ_LOCK is not set\n",
1089 +"# CONFIG_INLINE_READ_LOCK_BH is not set\n",
1090 +"# CONFIG_INLINE_READ_LOCK_IRQ is not set\n",
1091 +"# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set\n",
1092 +"CONFIG_INLINE_READ_UNLOCK=y\n",
1093 +"# CONFIG_INLINE_READ_UNLOCK_BH is not set\n",
1094 +"CONFIG_INLINE_READ_UNLOCK_IRQ=y\n",
1095 +"# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set\n",
1096 +"# CONFIG_INLINE_WRITE_TRYLOCK is not set\n",
1097 +"# CONFIG_INLINE_WRITE_LOCK is not set\n",
1098 +"# CONFIG_INLINE_WRITE_LOCK_BH is not set\n",
1099 +"# CONFIG_INLINE_WRITE_LOCK_IRQ is not set\n",
1100 +"# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set\n",
1101 +"CONFIG_INLINE_WRITE_UNLOCK=y\n",
1102 +"# CONFIG_INLINE_WRITE_UNLOCK_BH is not set\n",
1103 +"CONFIG_INLINE_WRITE_UNLOCK_IRQ=y\n",
1104 +"# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set\n",
1105 +"# CONFIG_MUTEX_SPIN_ON_OWNER is not set\n",
1106 +"# CONFIG_FREEZER is not set\n",
1107 +"# CONFIG_BLK_DEV is not set\n",
1110 +"# Character Devices\n",
1112 +"# CONFIG_STDERR_CONSOLE is not set\n",
1113 +"CONFIG_STDIO_CONSOLE=y\n",
1114 +"# CONFIG_SSL is not set\n",
1115 +"# CONFIG_NULL_CHAN is not set\n",
1116 +"# CONFIG_PORT_CHAN is not set\n",
1117 +"# CONFIG_PTY_CHAN is not set\n",
1118 +"# CONFIG_TTY_CHAN is not set\n",
1119 +"# CONFIG_XTERM_CHAN is not set\n",
1120 +"CONFIG_NOCONFIG_CHAN=y\n",
1121 +"CONFIG_CON_ZERO_CHAN=\"fd:0,fd:1\"\n",
1122 +"CONFIG_CON_CHAN=\"xterm\"\n",
1123 +"CONFIG_SSL_CHAN=\"pty\"\n",
1124 +"# CONFIG_UNIX98_PTYS is not set\n",
1125 +"# CONFIG_LEGACY_PTYS is not set\n",
1126 +"# CONFIG_RAW_DRIVER is not set\n",
1127 +"# CONFIG_WATCHDOG is not set\n",
1128 +"# CONFIG_UML_SOUND is not set\n",
1129 +"# CONFIG_SOUND is not set\n",
1130 +"# CONFIG_SOUND_OSS_CORE is not set\n",
1131 +"# CONFIG_HOSTAUDIO is not set\n",
1132 +"# CONFIG_HW_RANDOM is not set\n",
1133 +"# CONFIG_UML_RANDOM is not set\n",
1134 +"# CONFIG_MMAPPER is not set\n",
1137 +"# Generic Driver Options\n",
1139 +"CONFIG_UEVENT_HELPER_PATH=\"/sbin/hotplug\"\n",
1140 +"CONFIG_STANDALONE=y\n",
1141 +"# CONFIG_PREVENT_FIRMWARE_BUILD is not set\n",
1142 +"CONFIG_FW_LOADER=y\n",
1143 +"# CONFIG_FIRMWARE_IN_KERNEL is not set\n",
1144 +"CONFIG_EXTRA_FIRMWARE=\"\"\n",
1145 +"# CONFIG_SYS_HYPERVISOR is not set\n",
1146 +"# CONFIG_NET is not set\n",
1149 +"# File systems\n",
1151 +"# CONFIG_EXT2_FS is not set\n",
1152 +"# CONFIG_EXT3_FS is not set\n",
1153 +"# CONFIG_EXT4_FS is not set\n",
1154 +"# CONFIG_REISERFS_FS is not set\n",
1155 +"# CONFIG_JFS_FS is not set\n",
1156 +"# CONFIG_FS_POSIX_ACL is not set\n",
1157 +"# CONFIG_XFS_FS is not set\n",
1158 +"CONFIG_FILE_LOCKING=y\n",
1159 +"# CONFIG_FSNOTIFY is not set\n",
1160 +"# CONFIG_DNOTIFY is not set\n",
1161 +"# CONFIG_INOTIFY is not set\n",
1162 +"# CONFIG_INOTIFY_USER is not set\n",
1163 +"# CONFIG_QUOTA is not set\n",
1164 +"# CONFIG_AUTOFS_FS is not set\n",
1165 +"# CONFIG_AUTOFS4_FS is not set\n",
1166 +"# CONFIG_FUSE_FS is not set\n",
1173 +"# CD-ROM/DVD Filesystems\n",
1175 +"# CONFIG_ISO9660_FS is not set\n",
1176 +"# CONFIG_UDF_FS is not set\n",
1179 +"# DOS/FAT/NT Filesystems\n",
1181 +"# CONFIG_MSDOS_FS is not set\n",
1182 +"# CONFIG_VFAT_FS is not set\n",
1183 +"# CONFIG_NTFS_FS is not set\n",
1186 +"# Pseudo filesystems\n",
1188 +"CONFIG_PROC_FS=y\n",
1189 +"# CONFIG_PROC_KCORE is not set\n",
1190 +"CONFIG_PROC_SYSCTL=y\n",
1191 +"CONFIG_PROC_PAGE_MONITOR=y\n",
1192 +"CONFIG_SYSFS=y\n",
1193 +"# CONFIG_TMPFS is not set\n",
1194 +"# CONFIG_HUGETLB_PAGE is not set\n",
1195 +"# CONFIG_CONFIGFS_FS is not set\n",
1196 +"# CONFIG_MISC_FILESYSTEMS is not set\n",
1199 +"# Partition Types\n",
1201 +"# CONFIG_PARTITION_ADVANCED is not set\n",
1202 +"CONFIG_MSDOS_PARTITION=y\n",
1203 +"# CONFIG_NLS is not set\n",
1206 +"# Linux VServer\n",
1208 +"# CONFIG_VSERVER_AUTO_LBACK is not set\n",
1209 +"# CONFIG_VSERVER_COWBL is not set\n",
1210 +"# CONFIG_VSERVER_PROC_SECURE is not set\n",
1211 +"# CONFIG_VSERVER_HARDCPU is not set\n",
1212 +"# CONFIG_TAGGING_NONE is not set\n",
1213 +"# CONFIG_TAGGING_UID16 is not set\n",
1214 +"# CONFIG_TAGGING_GID16 is not set\n",
1215 +"CONFIG_TAGGING_ID24=y\n",
1216 +"# CONFIG_TAGGING_INTERN is not set\n",
1217 +"# CONFIG_TAG_NFSD is not set\n",
1218 +"# CONFIG_VSERVER_PRIVACY is not set\n",
1219 +"CONFIG_VSERVER_CONTEXTS=768\n",
1220 +"# CONFIG_VSERVER_WARN is not set\n",
1221 +"# CONFIG_VSERVER_DEBUG is not set\n",
1222 +"CONFIG_VSERVER=y\n",
1225 +"# Security options\n",
1227 +"# CONFIG_KEYS is not set\n",
1228 +"# CONFIG_SECURITY is not set\n",
1229 +"# CONFIG_SECURITYFS is not set\n",
1230 +"# CONFIG_DEFAULT_SECURITY_SELINUX is not set\n",
1231 +"# CONFIG_DEFAULT_SECURITY_SMACK is not set\n",
1232 +"# CONFIG_DEFAULT_SECURITY_TOMOYO is not set\n",
1233 +"CONFIG_DEFAULT_SECURITY_DAC=y\n",
1234 +"CONFIG_DEFAULT_SECURITY=\"\"\n",
1235 +"# CONFIG_CRYPTO is not set\n",
1236 +"# CONFIG_BINARY_PRINTF is not set\n",
1239 +"# Library routines\n",
1241 +"CONFIG_GENERIC_FIND_FIRST_BIT=y\n",
1242 +"CONFIG_GENERIC_FIND_NEXT_BIT=y\n",
1243 +"CONFIG_GENERIC_FIND_LAST_BIT=y\n",
1244 +"# CONFIG_CRC_CCITT is not set\n",
1245 +"# CONFIG_CRC16 is not set\n",
1246 +"# CONFIG_CRC_T10DIF is not set\n",
1247 +"# CONFIG_CRC_ITU_T is not set\n",
1248 +"# CONFIG_CRC32 is not set\n",
1249 +"# CONFIG_CRC7 is not set\n",
1250 +"# CONFIG_LIBCRC32C is not set\n",
1251 +"CONFIG_HAS_DMA=y\n",
1254 +"# SCSI device support\n",
1256 +"# CONFIG_RAID_ATTRS is not set\n",
1257 +"# CONFIG_SCSI is not set\n",
1258 +"# CONFIG_SCSI_DMA is not set\n",
1259 +"# CONFIG_SCSI_NETLINK is not set\n",
1260 +"# CONFIG_MD is not set\n",
1261 +"# CONFIG_NEW_LEDS is not set\n",
1262 +"# CONFIG_INPUT is not set\n",
1265 +"# Kernel hacking\n",
1267 +"# CONFIG_PRINTK_TIME is not set\n",
1268 +"# CONFIG_ENABLE_WARN_DEPRECATED is not set\n",
1269 +"# CONFIG_ENABLE_MUST_CHECK is not set\n",
1270 +"CONFIG_FRAME_WARN=2048\n",
1271 +"# CONFIG_STRIP_ASM_SYMS is not set\n",
1272 +"# CONFIG_UNUSED_SYMBOLS is not set\n",
1273 +"# CONFIG_DEBUG_FS is not set\n",
1274 +"# CONFIG_DEBUG_KERNEL is not set\n",
1275 +"# CONFIG_SLUB_DEBUG_ON is not set\n",
1276 +"# CONFIG_SLUB_STATS is not set\n",
1277 +"CONFIG_DEBUG_BUGVERBOSE=y\n",
1278 +"CONFIG_DEBUG_MEMORY_INIT=y\n",
1279 +"# CONFIG_RCU_CPU_STALL_DETECTOR is not set\n",
1280 +"# CONFIG_SYSCTL_SYSCALL_CHECK is not set\n",
1281 +"# CONFIG_SAMPLES is not set\n",
1282 +"# CONFIG_DEBUG_STACK_USAGE is not set\n",
1286 +static int __init print_config(char *line, int *add)
1289 + for (i = 0; i < sizeof(config)/sizeof(config[0]); i++)
1290 + printf("%s", config[i]);
1294 +__uml_setup("--showconfig", print_config,
1296 +" Prints the config file that this UML binary was generated from.\n\n"
1299 diff -NurpP --minimal linux-2.6.35/arch/um/kernel/config.tmp linux-2.6.35-vs2.3.0.36.31/arch/um/kernel/config.tmp
1300 --- linux-2.6.35/arch/um/kernel/config.tmp 1970-01-01 01:00:00.000000000 +0100
1301 +++ linux-2.6.35-vs2.3.0.36.31/arch/um/kernel/config.tmp 2010-08-02 17:05:05.000000000 +0200
1304 +"# Automatically generated make config: don't edit\n",
1305 +"# Linux kernel version: 2.6.33-vs2.3.0.36.29.1\n",
1306 +"# Wed Mar 10 20:29:46 2010\n",
1308 +"CONFIG_DEFCONFIG_LIST=\"arch/$ARCH/defconfig\"\n",
1309 +"CONFIG_GENERIC_HARDIRQS=y\n",
1312 +"CONFIG_NO_IOMEM=y\n",
1313 +"# CONFIG_TRACE_IRQFLAGS_SUPPORT is not set\n",
1314 +"CONFIG_LOCKDEP_SUPPORT=y\n",
1315 +"# CONFIG_STACKTRACE_SUPPORT is not set\n",
1316 +"CONFIG_GENERIC_CALIBRATE_DELAY=y\n",
1317 +"CONFIG_GENERIC_BUG=y\n",
1318 +"CONFIG_GENERIC_TIME=y\n",
1319 +"CONFIG_GENERIC_CLOCKEVENTS=y\n",
1320 +"CONFIG_IRQ_RELEASE_METHOD=y\n",
1324 +"# UML-specific options\n",
1328 +"# Host processor type and features\n",
1330 +"# CONFIG_M386 is not set\n",
1331 +"# CONFIG_M486 is not set\n",
1332 +"# CONFIG_M586 is not set\n",
1333 +"# CONFIG_M586TSC is not set\n",
1334 +"# CONFIG_M586MMX is not set\n",
1335 +"# CONFIG_M686 is not set\n",
1336 +"# CONFIG_MPENTIUMII is not set\n",
1337 +"# CONFIG_MPENTIUMIII is not set\n",
1338 +"# CONFIG_MPENTIUMM is not set\n",
1339 +"# CONFIG_MPENTIUM4 is not set\n",
1340 +"# CONFIG_MK6 is not set\n",
1341 +"# CONFIG_MK7 is not set\n",
1343 +"# CONFIG_MCRUSOE is not set\n",
1344 +"# CONFIG_MEFFICEON is not set\n",
1345 +"# CONFIG_MWINCHIPC6 is not set\n",
1346 +"# CONFIG_MWINCHIP3D is not set\n",
1347 +"# CONFIG_MGEODEGX1 is not set\n",
1348 +"# CONFIG_MGEODE_LX is not set\n",
1349 +"# CONFIG_MCYRIXIII is not set\n",
1350 +"# CONFIG_MVIAC3_2 is not set\n",
1351 +"# CONFIG_MVIAC7 is not set\n",
1352 +"# CONFIG_MPSC is not set\n",
1353 +"# CONFIG_MCORE2 is not set\n",
1354 +"# CONFIG_MATOM is not set\n",
1355 +"# CONFIG_GENERIC_CPU is not set\n",
1356 +"CONFIG_X86_CPU=y\n",
1357 +"CONFIG_X86_INTERNODE_CACHE_SHIFT=6\n",
1358 +"# CONFIG_X86_CMPXCHG is not set\n",
1359 +"CONFIG_X86_L1_CACHE_SHIFT=6\n",
1360 +"CONFIG_X86_WP_WORKS_OK=y\n",
1361 +"CONFIG_X86_INTEL_USERCOPY=y\n",
1362 +"CONFIG_X86_USE_PPRO_CHECKSUM=y\n",
1363 +"CONFIG_X86_TSC=y\n",
1364 +"CONFIG_X86_CMOV=y\n",
1365 +"CONFIG_X86_MINIMUM_CPU_FAMILY=3\n",
1366 +"CONFIG_CPU_SUP_INTEL=y\n",
1367 +"CONFIG_CPU_SUP_AMD=y\n",
1368 +"CONFIG_CPU_SUP_CENTAUR=y\n",
1369 +"CONFIG_UML_X86=y\n",
1370 +"CONFIG_64BIT=y\n",
1371 +"# CONFIG_X86_32 is not set\n",
1372 +"# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set\n",
1373 +"CONFIG_RWSEM_GENERIC_SPINLOCK=y\n",
1374 +"# CONFIG_ARCH_HAS_SC_SIGNALS is not set\n",
1375 +"# CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA is not set\n",
1376 +"CONFIG_SMP_BROKEN=y\n",
1377 +"CONFIG_GENERIC_HWEIGHT=y\n",
1378 +"# CONFIG_STATIC_LINK is not set\n",
1379 +"CONFIG_FLATMEM=y\n",
1380 +"CONFIG_FLAT_NODE_MEM_MAP=y\n",
1381 +"CONFIG_PAGEFLAGS_EXTENDED=y\n",
1382 +"CONFIG_SPLIT_PTLOCK_CPUS=4\n",
1383 +"CONFIG_PHYS_ADDR_T_64BIT=y\n",
1384 +"CONFIG_ZONE_DMA_FLAG=0\n",
1385 +"CONFIG_VIRT_TO_BUS=y\n",
1386 +"# CONFIG_KSM is not set\n",
1387 +"CONFIG_DEFAULT_MMAP_MIN_ADDR=4096\n",
1388 +"# CONFIG_NO_HZ is not set\n",
1389 +"# CONFIG_HIGH_RES_TIMERS is not set\n",
1390 +"CONFIG_GENERIC_CLOCKEVENTS_BUILD=y\n",
1391 +"CONFIG_LD_SCRIPT_DYN=y\n",
1392 +"# CONFIG_BINFMT_ELF is not set\n",
1393 +"# CONFIG_HAVE_AOUT is not set\n",
1394 +"# CONFIG_BINFMT_MISC is not set\n",
1395 +"# CONFIG_HOSTFS is not set\n",
1396 +"# CONFIG_MCONSOLE is not set\n",
1397 +"CONFIG_KERNEL_STACK_ORDER=1\n",
1400 +"# General setup\n",
1402 +"# CONFIG_EXPERIMENTAL is not set\n",
1403 +"CONFIG_BROKEN_ON_SMP=y\n",
1404 +"CONFIG_INIT_ENV_ARG_LIMIT=128\n",
1405 +"CONFIG_LOCALVERSION=\"\"\n",
1406 +"# CONFIG_LOCALVERSION_AUTO is not set\n",
1407 +"# CONFIG_SWAP is not set\n",
1408 +"CONFIG_SYSVIPC=y\n",
1409 +"CONFIG_SYSVIPC_SYSCTL=y\n",
1410 +"# CONFIG_BSD_PROCESS_ACCT is not set\n",
1413 +"# RCU Subsystem\n",
1415 +"CONFIG_TREE_RCU=y\n",
1416 +"# CONFIG_TREE_PREEMPT_RCU is not set\n",
1417 +"# CONFIG_TINY_RCU is not set\n",
1418 +"# CONFIG_RCU_TRACE is not set\n",
1419 +"CONFIG_RCU_FANOUT=64\n",
1420 +"# CONFIG_RCU_FANOUT_EXACT is not set\n",
1421 +"# CONFIG_TREE_RCU_TRACE is not set\n",
1422 +"# CONFIG_IKCONFIG is not set\n",
1423 +"CONFIG_LOG_BUF_SHIFT=17\n",
1424 +"# CONFIG_CGROUPS is not set\n",
1425 +"# CONFIG_SYSFS_DEPRECATED_V2 is not set\n",
1426 +"# CONFIG_RELAY is not set\n",
1427 +"CONFIG_NAMESPACES=y\n",
1428 +"CONFIG_UTS_NS=y\n",
1429 +"CONFIG_IPC_NS=y\n",
1430 +"CONFIG_USER_NS=y\n",
1431 +"# CONFIG_BLK_DEV_INITRD is not set\n",
1432 +"# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set\n",
1433 +"CONFIG_SYSCTL=y\n",
1434 +"CONFIG_ANON_INODES=y\n",
1435 +"# CONFIG_EMBEDDED is not set\n",
1436 +"CONFIG_UID16=y\n",
1437 +"CONFIG_SYSCTL_SYSCALL=y\n",
1438 +"CONFIG_KALLSYMS=y\n",
1439 +"# CONFIG_KALLSYMS_EXTRA_PASS is not set\n",
1440 +"CONFIG_HOTPLUG=y\n",
1441 +"CONFIG_PRINTK=y\n",
1443 +"CONFIG_ELF_CORE=y\n",
1444 +"CONFIG_BASE_FULL=y\n",
1445 +"CONFIG_FUTEX=y\n",
1446 +"CONFIG_EPOLL=y\n",
1447 +"CONFIG_SIGNALFD=y\n",
1448 +"CONFIG_TIMERFD=y\n",
1449 +"CONFIG_EVENTFD=y\n",
1450 +"CONFIG_SHMEM=y\n",
1454 +"# Kernel Performance Events And Counters\n",
1456 +"CONFIG_VM_EVENT_COUNTERS=y\n",
1457 +"CONFIG_SLUB_DEBUG=y\n",
1458 +"# CONFIG_COMPAT_BRK is not set\n",
1459 +"# CONFIG_SLAB is not set\n",
1461 +"# CONFIG_SLOB is not set\n",
1462 +"# CONFIG_PROFILING is not set\n",
1465 +"# GCOV-based kernel profiling\n",
1467 +"# CONFIG_SLOW_WORK is not set\n",
1468 +"# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set\n",
1469 +"CONFIG_SLABINFO=y\n",
1470 +"CONFIG_RT_MUTEXES=y\n",
1471 +"CONFIG_BASE_SMALL=0\n",
1472 +"# CONFIG_MODULES is not set\n",
1473 +"CONFIG_BLOCK=y\n",
1474 +"# CONFIG_BLK_DEV_BSG is not set\n",
1475 +"# CONFIG_BLK_DEV_INTEGRITY is not set\n",
1478 +"# IO Schedulers\n",
1480 +"CONFIG_IOSCHED_NOOP=y\n",
1481 +"# CONFIG_IOSCHED_DEADLINE is not set\n",
1482 +"# CONFIG_IOSCHED_CFQ is not set\n",
1483 +"# CONFIG_DEFAULT_DEADLINE is not set\n",
1484 +"# CONFIG_DEFAULT_CFQ is not set\n",
1485 +"CONFIG_DEFAULT_NOOP=y\n",
1486 +"CONFIG_DEFAULT_IOSCHED=\"noop\"\n",
1487 +"# CONFIG_INLINE_SPIN_TRYLOCK is not set\n",
1488 +"# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set\n",
1489 +"# CONFIG_INLINE_SPIN_LOCK is not set\n",
1490 +"# CONFIG_INLINE_SPIN_LOCK_BH is not set\n",
1491 +"# CONFIG_INLINE_SPIN_LOCK_IRQ is not set\n",
1492 +"# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set\n",
1493 +"CONFIG_INLINE_SPIN_UNLOCK=y\n",
1494 +"# CONFIG_INLINE_SPIN_UNLOCK_BH is not set\n",
1495 +"CONFIG_INLINE_SPIN_UNLOCK_IRQ=y\n",
1496 +"# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set\n",
1497 +"# CONFIG_INLINE_READ_TRYLOCK is not set\n",
1498 +"# CONFIG_INLINE_READ_LOCK is not set\n",
1499 +"# CONFIG_INLINE_READ_LOCK_BH is not set\n",
1500 +"# CONFIG_INLINE_READ_LOCK_IRQ is not set\n",
1501 +"# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set\n",
1502 +"CONFIG_INLINE_READ_UNLOCK=y\n",
1503 +"# CONFIG_INLINE_READ_UNLOCK_BH is not set\n",
1504 +"CONFIG_INLINE_READ_UNLOCK_IRQ=y\n",
1505 +"# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set\n",
1506 +"# CONFIG_INLINE_WRITE_TRYLOCK is not set\n",
1507 +"# CONFIG_INLINE_WRITE_LOCK is not set\n",
1508 +"# CONFIG_INLINE_WRITE_LOCK_BH is not set\n",
1509 +"# CONFIG_INLINE_WRITE_LOCK_IRQ is not set\n",
1510 +"# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set\n",
1511 +"CONFIG_INLINE_WRITE_UNLOCK=y\n",
1512 +"# CONFIG_INLINE_WRITE_UNLOCK_BH is not set\n",
1513 +"CONFIG_INLINE_WRITE_UNLOCK_IRQ=y\n",
1514 +"# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set\n",
1515 +"# CONFIG_MUTEX_SPIN_ON_OWNER is not set\n",
1516 +"# CONFIG_FREEZER is not set\n",
1517 +"# CONFIG_BLK_DEV is not set\n",
1520 +"# Character Devices\n",
1522 +"# CONFIG_STDERR_CONSOLE is not set\n",
1523 +"CONFIG_STDIO_CONSOLE=y\n",
1524 +"# CONFIG_SSL is not set\n",
1525 +"# CONFIG_NULL_CHAN is not set\n",
1526 +"# CONFIG_PORT_CHAN is not set\n",
1527 +"# CONFIG_PTY_CHAN is not set\n",
1528 +"# CONFIG_TTY_CHAN is not set\n",
1529 +"# CONFIG_XTERM_CHAN is not set\n",
1530 +"CONFIG_NOCONFIG_CHAN=y\n",
1531 +"CONFIG_CON_ZERO_CHAN=\"fd:0,fd:1\"\n",
1532 +"CONFIG_CON_CHAN=\"xterm\"\n",
1533 +"CONFIG_SSL_CHAN=\"pty\"\n",
1534 +"# CONFIG_UNIX98_PTYS is not set\n",
1535 +"# CONFIG_LEGACY_PTYS is not set\n",
1536 +"# CONFIG_RAW_DRIVER is not set\n",
1537 +"# CONFIG_WATCHDOG is not set\n",
1538 +"# CONFIG_UML_SOUND is not set\n",
1539 +"# CONFIG_SOUND is not set\n",
1540 +"# CONFIG_SOUND_OSS_CORE is not set\n",
1541 +"# CONFIG_HOSTAUDIO is not set\n",
1542 +"# CONFIG_HW_RANDOM is not set\n",
1543 +"# CONFIG_UML_RANDOM is not set\n",
1544 +"# CONFIG_MMAPPER is not set\n",
1547 +"# Generic Driver Options\n",
1549 +"CONFIG_UEVENT_HELPER_PATH=\"/sbin/hotplug\"\n",
1550 +"CONFIG_STANDALONE=y\n",
1551 +"# CONFIG_PREVENT_FIRMWARE_BUILD is not set\n",
1552 +"CONFIG_FW_LOADER=y\n",
1553 +"# CONFIG_FIRMWARE_IN_KERNEL is not set\n",
1554 +"CONFIG_EXTRA_FIRMWARE=\"\"\n",
1555 +"# CONFIG_SYS_HYPERVISOR is not set\n",
1556 +"# CONFIG_NET is not set\n",
1559 +"# File systems\n",
1561 +"# CONFIG_EXT2_FS is not set\n",
1562 +"# CONFIG_EXT3_FS is not set\n",
1563 +"# CONFIG_EXT4_FS is not set\n",
1564 +"# CONFIG_REISERFS_FS is not set\n",
1565 +"# CONFIG_JFS_FS is not set\n",
1566 +"# CONFIG_FS_POSIX_ACL is not set\n",
1567 +"# CONFIG_XFS_FS is not set\n",
1568 +"CONFIG_FILE_LOCKING=y\n",
1569 +"# CONFIG_FSNOTIFY is not set\n",
1570 +"# CONFIG_DNOTIFY is not set\n",
1571 +"# CONFIG_INOTIFY is not set\n",
1572 +"# CONFIG_INOTIFY_USER is not set\n",
1573 +"# CONFIG_QUOTA is not set\n",
1574 +"# CONFIG_AUTOFS_FS is not set\n",
1575 +"# CONFIG_AUTOFS4_FS is not set\n",
1576 +"# CONFIG_FUSE_FS is not set\n",
1583 +"# CD-ROM/DVD Filesystems\n",
1585 +"# CONFIG_ISO9660_FS is not set\n",
1586 +"# CONFIG_UDF_FS is not set\n",
1589 +"# DOS/FAT/NT Filesystems\n",
1591 +"# CONFIG_MSDOS_FS is not set\n",
1592 +"# CONFIG_VFAT_FS is not set\n",
1593 +"# CONFIG_NTFS_FS is not set\n",
1596 +"# Pseudo filesystems\n",
1598 +"CONFIG_PROC_FS=y\n",
1599 +"# CONFIG_PROC_KCORE is not set\n",
1600 +"CONFIG_PROC_SYSCTL=y\n",
1601 +"CONFIG_PROC_PAGE_MONITOR=y\n",
1602 +"CONFIG_SYSFS=y\n",
1603 +"# CONFIG_TMPFS is not set\n",
1604 +"# CONFIG_HUGETLB_PAGE is not set\n",
1605 +"# CONFIG_CONFIGFS_FS is not set\n",
1606 +"# CONFIG_MISC_FILESYSTEMS is not set\n",
1609 +"# Partition Types\n",
1611 +"# CONFIG_PARTITION_ADVANCED is not set\n",
1612 +"CONFIG_MSDOS_PARTITION=y\n",
1613 +"# CONFIG_NLS is not set\n",
1616 +"# Linux VServer\n",
1618 +"# CONFIG_VSERVER_AUTO_LBACK is not set\n",
1619 +"# CONFIG_VSERVER_COWBL is not set\n",
1620 +"# CONFIG_VSERVER_PROC_SECURE is not set\n",
1621 +"# CONFIG_VSERVER_HARDCPU is not set\n",
1622 +"# CONFIG_TAGGING_NONE is not set\n",
1623 +"# CONFIG_TAGGING_UID16 is not set\n",
1624 +"# CONFIG_TAGGING_GID16 is not set\n",
1625 +"CONFIG_TAGGING_ID24=y\n",
1626 +"# CONFIG_TAGGING_INTERN is not set\n",
1627 +"# CONFIG_TAG_NFSD is not set\n",
1628 +"# CONFIG_VSERVER_PRIVACY is not set\n",
1629 +"CONFIG_VSERVER_CONTEXTS=768\n",
1630 +"# CONFIG_VSERVER_WARN is not set\n",
1631 +"# CONFIG_VSERVER_DEBUG is not set\n",
1632 +"CONFIG_VSERVER=y\n",
1635 +"# Security options\n",
1637 +"# CONFIG_KEYS is not set\n",
1638 +"# CONFIG_SECURITY is not set\n",
1639 +"# CONFIG_SECURITYFS is not set\n",
1640 +"# CONFIG_DEFAULT_SECURITY_SELINUX is not set\n",
1641 +"# CONFIG_DEFAULT_SECURITY_SMACK is not set\n",
1642 +"# CONFIG_DEFAULT_SECURITY_TOMOYO is not set\n",
1643 +"CONFIG_DEFAULT_SECURITY_DAC=y\n",
1644 +"CONFIG_DEFAULT_SECURITY=\"\"\n",
1645 +"# CONFIG_CRYPTO is not set\n",
1646 +"# CONFIG_BINARY_PRINTF is not set\n",
1649 +"# Library routines\n",
1651 +"CONFIG_GENERIC_FIND_FIRST_BIT=y\n",
1652 +"CONFIG_GENERIC_FIND_NEXT_BIT=y\n",
1653 +"CONFIG_GENERIC_FIND_LAST_BIT=y\n",
1654 +"# CONFIG_CRC_CCITT is not set\n",
1655 +"# CONFIG_CRC16 is not set\n",
1656 +"# CONFIG_CRC_T10DIF is not set\n",
1657 +"# CONFIG_CRC_ITU_T is not set\n",
1658 +"# CONFIG_CRC32 is not set\n",
1659 +"# CONFIG_CRC7 is not set\n",
1660 +"# CONFIG_LIBCRC32C is not set\n",
1661 +"CONFIG_HAS_DMA=y\n",
1664 +"# SCSI device support\n",
1666 +"# CONFIG_RAID_ATTRS is not set\n",
1667 +"# CONFIG_SCSI is not set\n",
1668 +"# CONFIG_SCSI_DMA is not set\n",
1669 +"# CONFIG_SCSI_NETLINK is not set\n",
1670 +"# CONFIG_MD is not set\n",
1671 +"# CONFIG_NEW_LEDS is not set\n",
1672 +"# CONFIG_INPUT is not set\n",
1675 +"# Kernel hacking\n",
1677 +"# CONFIG_PRINTK_TIME is not set\n",
1678 +"# CONFIG_ENABLE_WARN_DEPRECATED is not set\n",
1679 +"# CONFIG_ENABLE_MUST_CHECK is not set\n",
1680 +"CONFIG_FRAME_WARN=2048\n",
1681 +"# CONFIG_STRIP_ASM_SYMS is not set\n",
1682 +"# CONFIG_UNUSED_SYMBOLS is not set\n",
1683 +"# CONFIG_DEBUG_FS is not set\n",
1684 +"# CONFIG_DEBUG_KERNEL is not set\n",
1685 +"# CONFIG_SLUB_DEBUG_ON is not set\n",
1686 +"# CONFIG_SLUB_STATS is not set\n",
1687 +"CONFIG_DEBUG_BUGVERBOSE=y\n",
1688 +"CONFIG_DEBUG_MEMORY_INIT=y\n",
1689 +"# CONFIG_RCU_CPU_STALL_DETECTOR is not set\n",
1690 +"# CONFIG_SYSCTL_SYSCALL_CHECK is not set\n",
1691 +"# CONFIG_SAMPLES is not set\n",
1692 +"# CONFIG_DEBUG_STACK_USAGE is not set\n",
1693 diff -NurpP --minimal linux-2.6.35/arch/um/kernel/vmlinux.lds linux-2.6.35-vs2.3.0.36.31/arch/um/kernel/vmlinux.lds
1694 --- linux-2.6.35/arch/um/kernel/vmlinux.lds 1970-01-01 01:00:00.000000000 +0100
1695 +++ linux-2.6.35-vs2.3.0.36.31/arch/um/kernel/vmlinux.lds 2010-08-02 17:05:05.000000000 +0200
1700 + * Automatically generated C config: don't edit
1701 + * Linux kernel version: 2.6.33-vs2.3.0.36.29.1
1702 + * Wed Mar 10 20:12:10 2010
1704 +KERNEL_STACK_SIZE = 4096 * (1 << 1);
1706 + * Helper macros to support writing architecture specific
1709 + * A minimal linker scripts has following content:
1710 + * [This is a sample, architectures may have special requiriements]
1712 + * OUTPUT_FORMAT(...)
1713 + * OUTPUT_ARCH(...)
1718 + * __init_begin = .;
1719 + * HEAD_TEXT_SECTION
1720 + * INIT_TEXT_SECTION(PAGE_SIZE)
1721 + * INIT_DATA_SECTION(...)
1722 + * PERCPU(PAGE_SIZE)
1726 + * TEXT_SECTION = 0
1730 + * RO_DATA_SECTION(PAGE_SIZE)
1731 + * RW_DATA_SECTION(...)
1734 + * EXCEPTION_TABLE(...)
1737 + * BSS_SECTION(0, 0, 0)
1743 + * DISCARDS // must be the last
1746 + * [__init_begin, __init_end] is the init section that may be freed after init
1747 + * [_stext, _etext] is the text section
1748 + * [_sdata, _edata] is the data section
1750 + * Some of the included output section have their own set of constants.
1751 + * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
1752 + * [__nosave_begin, __nosave_end] for the nosave data
1761 +/* Align . to a 8 byte boundary equals to maximum function alignment. */
1764 +/* The actual configuration determine if the init/exit sections
1765 + * are handled as text/data or they can be discarded (which
1766 + * often happens at runtime)
1768 +/* .data section */
1770 + * Data section helpers
1775 +/* RODATA & RO_DATA provided for backward compatibility.
1776 + * All archs are supposed to use RO_DATA() */
1777 +/* .text section. Map to function alignment to avoid address changes
1778 + * during second ld run in second ld pass when generating System.map */
1779 +/* sched.text is aling to function alignment to secure we have same
1780 + * address even at second ld pass when generating System.map */
1781 +/* spinlock.text is aling to function alignment to secure we have same
1782 + * address even at second ld pass when generating System.map */
1783 +/* Section used for early init (in .S files) */
1790 +/* init and exit section handling */
1792 + * bss (Block Started by Symbol) - uninitialized data
1793 + * zeroed during startup
1796 + * DWARF debug sections.
1797 + * Symbols in the DWARF debugging sections are relative to
1798 + * the beginning of the section so we begin them at 0.
1800 + /* Stabs debugging sections. */
1802 + * Default discarded sections.
1804 + * Some archs want to discard exit text/data at runtime rather than
1805 + * link time due to cross-section references such as alt instructions,
1806 + * bug table, eh_frame, etc. DISCARDS must be the last of output
1807 + * section definitions so that such archs put those in earlier section
1811 + * PERCPU_VADDR - define output section for percpu area
1812 + * @vaddr: explicit base address (optional)
1813 + * @phdr: destination PHDR (optional)
1815 + * Macro which expands to output section for percpu area. If @vaddr
1816 + * is not blank, it specifies explicit base address and all percpu
1817 + * symbols will be offset from the given address. If blank, @vaddr
1818 + * always equals @laddr + LOAD_OFFSET.
1820 + * @phdr defines the output PHDR to use if not blank. Be warned that
1821 + * output PHDR is sticky. If @phdr is specified, the next output
1822 + * section in the linker script will go there too. @phdr should have
1823 + * a leading colon.
1825 + * Note that this macros defines __per_cpu_load as an absolute symbol.
1826 + * If there is no need to put the percpu section at a predetermined
1827 + * address, use PERCPU().
1830 + * PERCPU - define output section for percpu area, simple version
1831 + * @align: required alignment
1833 + * Align to @align and outputs output section for percpu area. This
1834 + * macro doesn't maniuplate @vaddr or @phdr and __per_cpu_load and
1835 + * __per_cpu_start will be identical.
1837 + * This macro is equivalent to ALIGN(align); PERCPU_VADDR( , ) except
1838 + * that __per_cpu_load is defined as a relative symbol against
1839 + * .data.percpu which is required for relocatable x86_32
1843 + * Definition of the high level *_SECTION macros
1844 + * They will fit only a subset of the architectures
1848 + * All sections are combined in a single .data section.
1849 + * The sections following CONSTRUCTORS are arranged so their
1850 + * typical alignment matches.
1851 + * A cacheline is typical/always less than a PAGE_SIZE so
1852 + * the sections that has this restriction (or similar)
1853 + * is located before the ones requiring PAGE_SIZE alignment.
1854 + * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
1855 + * matches the requirment of PAGE_ALIGNED_DATA.
1857 + * use 0 as page_align if page_aligned data is not used */
1859 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
1860 + * Copyright 2003 PathScale, Inc.
1861 + * Licensed under the GPL
1863 +/* const.h: Macros for dealing with constants. */
1864 +/* Some constant macros are used in both assembler and
1865 + * C code. Therefore we cannot annotate them always with
1866 + * 'UL' and other type specifiers unilaterally. We
1867 + * use the following macros to deal with this.
1869 + * Similarly, _AT() will cast an expression with a type in C, but
1870 + * leave it unchanged in asm.
1872 +/* PAGE_SHIFT determines the page size */
1873 +OUTPUT_FORMAT(elf64-x86-64)
1874 +OUTPUT_ARCH(i386:x86-64)
1876 +jiffies = jiffies_64;
1879 + PROVIDE (__executable_start = 0x60000000);
1880 + . = 0x60000000 + SIZEOF_HEADERS;
1881 + .interp : { *(.interp) }
1882 + __binary_start = .;
1883 + . = ALIGN(4096); /* Init code and data */
1887 + . = ALIGN((1 << 12)); .init.text : AT(ADDR(.init.text) - 0) { _sinittext = .; *(.init.text) *(.cpuinit.text) *(.meminit.text) _einittext = .; }
1888 + . = ALIGN((1 << 12));
1889 + /* Read-only sections, merged into text segment: */
1890 + .hash : { *(.hash) }
1891 + .gnu.hash : { *(.gnu.hash) }
1892 + .dynsym : { *(.dynsym) }
1893 + .dynstr : { *(.dynstr) }
1894 + .gnu.version : { *(.gnu.version) }
1895 + .gnu.version_d : { *(.gnu.version_d) }
1896 + .gnu.version_r : { *(.gnu.version_r) }
1897 + .rel.init : { *(.rel.init) }
1898 + .rela.init : { *(.rela.init) }
1899 + .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
1900 + .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
1901 + .rel.fini : { *(.rel.fini) }
1902 + .rela.fini : { *(.rela.fini) }
1903 + .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
1904 + .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
1905 + .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
1906 + .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
1907 + .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
1908 + .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
1909 + .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
1910 + .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
1911 + .rel.ctors : { *(.rel.ctors) }
1912 + .rela.ctors : { *(.rela.ctors) }
1913 + .rel.dtors : { *(.rel.dtors) }
1914 + .rela.dtors : { *(.rela.dtors) }
1915 + .rel.got : { *(.rel.got) }
1916 + .rela.got : { *(.rela.got) }
1917 + .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
1918 + .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
1919 + .rel.plt : { *(.rel.plt) }
1920 + .rela.plt : { *(.rela.plt) }
1924 + .plt : { *(.plt) }
1926 + . = ALIGN(8); *(.text.hot) *(.text) *(.ref.text) *(.devinit.text) *(.devexit.text) *(.text.unlikely)
1927 + . = ALIGN(8); __sched_text_start = .; *(.sched.text) __sched_text_end = .;
1928 + . = ALIGN(8); __lock_text_start = .; *(.spinlock.text) __lock_text_end = .;
1930 + *(.stub .text.* .gnu.linkonce.t.*)
1931 + /* .gnu.warning sections are handled specially by elf32.em. */
1933 + . = ALIGN((1 << 12));
1935 + . = ALIGN((1 << 12));
1937 + __syscall_stub_start = .;
1938 + *(.__syscall_stub*)
1939 + __syscall_stub_end = .;
1944 + .kstrtab : { *(.kstrtab) }
1946 + * Helper macros to support writing architecture specific
1949 + * A minimal linker scripts has following content:
1950 + * [This is a sample, architectures may have special requiriements]
1952 + * OUTPUT_FORMAT(...)
1953 + * OUTPUT_ARCH(...)
1958 + * __init_begin = .;
1959 + * HEAD_TEXT_SECTION
1960 + * INIT_TEXT_SECTION(PAGE_SIZE)
1961 + * INIT_DATA_SECTION(...)
1962 + * PERCPU(PAGE_SIZE)
1966 + * TEXT_SECTION = 0
1970 + * RO_DATA_SECTION(PAGE_SIZE)
1971 + * RW_DATA_SECTION(...)
1974 + * EXCEPTION_TABLE(...)
1977 + * BSS_SECTION(0, 0, 0)
1983 + * DISCARDS // must be the last
1986 + * [__init_begin, __init_end] is the init section that may be freed after init
1987 + * [_stext, _etext] is the text section
1988 + * [_sdata, _edata] is the data section
1990 + * Some of the included output section have their own set of constants.
1991 + * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
1992 + * [__nosave_begin, __nosave_end] for the nosave data
1994 +/* Align . to a 8 byte boundary equals to maximum function alignment. */
1995 +/* The actual configuration determine if the init/exit sections
1996 + * are handled as text/data or they can be discarded (which
1997 + * often happens at runtime)
1999 +/* .data section */
2001 + * Data section helpers
2006 +/* RODATA & RO_DATA provided for backward compatibility.
2007 + * All archs are supposed to use RO_DATA() */
2008 +/* .text section. Map to function alignment to avoid address changes
2009 + * during second ld run in second ld pass when generating System.map */
2010 +/* sched.text is aling to function alignment to secure we have same
2011 + * address even at second ld pass when generating System.map */
2012 +/* spinlock.text is aling to function alignment to secure we have same
2013 + * address even at second ld pass when generating System.map */
2014 +/* Section used for early init (in .S files) */
2021 +/* init and exit section handling */
2023 + * bss (Block Started by Symbol) - uninitialized data
2024 + * zeroed during startup
2027 + * DWARF debug sections.
2028 + * Symbols in the DWARF debugging sections are relative to
2029 + * the beginning of the section so we begin them at 0.
2031 + /* Stabs debugging sections. */
2033 + * Default discarded sections.
2035 + * Some archs want to discard exit text/data at runtime rather than
2036 + * link time due to cross-section references such as alt instructions,
2037 + * bug table, eh_frame, etc. DISCARDS must be the last of output
2038 + * section definitions so that such archs put those in earlier section
2042 + * PERCPU_VADDR - define output section for percpu area
2043 + * @vaddr: explicit base address (optional)
2044 + * @phdr: destination PHDR (optional)
2046 + * Macro which expands to output section for percpu area. If @vaddr
2047 + * is not blank, it specifies explicit base address and all percpu
2048 + * symbols will be offset from the given address. If blank, @vaddr
2049 + * always equals @laddr + LOAD_OFFSET.
2051 + * @phdr defines the output PHDR to use if not blank. Be warned that
2052 + * output PHDR is sticky. If @phdr is specified, the next output
2053 + * section in the linker script will go there too. @phdr should have
2054 + * a leading colon.
2056 + * Note that this macros defines __per_cpu_load as an absolute symbol.
2057 + * If there is no need to put the percpu section at a predetermined
2058 + * address, use PERCPU().
2061 + * PERCPU - define output section for percpu area, simple version
2062 + * @align: required alignment
2064 + * Align to @align and outputs output section for percpu area. This
2065 + * macro doesn't maniuplate @vaddr or @phdr and __per_cpu_load and
2066 + * __per_cpu_start will be identical.
2068 + * This macro is equivalent to ALIGN(align); PERCPU_VADDR( , ) except
2069 + * that __per_cpu_load is defined as a relative symbol against
2070 + * .data.percpu which is required for relocatable x86_32
2074 + * Definition of the high level *_SECTION macros
2075 + * They will fit only a subset of the architectures
2079 + * All sections are combined in a single .data section.
2080 + * The sections following CONSTRUCTORS are arranged so their
2081 + * typical alignment matches.
2082 + * A cacheline is typical/always less than a PAGE_SIZE so
2083 + * the sections that has this restriction (or similar)
2084 + * is located before the ones requiring PAGE_SIZE alignment.
2085 + * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
2086 + * matches the requirment of PAGE_ALIGNED_DATA.
2088 + * use 0 as page_align if page_aligned data is not used */
2089 + .fini : { *(.fini) } =0x9090
2091 + PROVIDE (etext = .);
2094 + PROVIDE (sdata = .);
2095 + . = ALIGN((4096)); .rodata : AT(ADDR(.rodata) - 0) { __start_rodata = .; *(.rodata) *(.rodata.*) *(__vermagic) *(__markers_strings) *(__tracepoints_strings) } .rodata1 : AT(ADDR(.rodata1) - 0) { *(.rodata1) } . = ALIGN(8); __bug_table : AT(ADDR(__bug_table) - 0) { __start___bug_table = .; *(__bug_table) __stop___bug_table = .; } .pci_fixup : AT(ADDR(.pci_fixup) - 0) { __start_pci_fixups_early = .; *(.pci_fixup_early) __end_pci_fixups_early = .; __start_pci_fixups_header = .; *(.pci_fixup_header) __end_pci_fixups_header = .; __start_pci_fixups_final = .; *(.pci_fixup_final) __end_pci_fixups_final = .; __start_pci_fixups_enable = .; *(.pci_fixup_enable) __end_pci_fixups_enable = .; __start_pci_fixups_resume = .; *(.pci_fixup_resume) __end_pci_fixups_resume = .; __start_pci_fixups_resume_early = .; *(.pci_fixup_resume_early) __end_pci_fixups_resume_early = .; __start_pci_fixups_suspend = .; *(.pci_fixup_suspend) __end_pci_fixups_suspend = .; } .builtin_fw : AT(ADDR(.builtin_fw) - 0) { __start_builtin_fw = .; *(.builtin_fw) __end_builtin_fw = .; } .rio_route : AT(ADDR(.rio_route) - 0) { __start_rio_route_ops = .; *(.rio_route_ops) __end_rio_route_ops = .; } __ksymtab : AT(ADDR(__ksymtab) - 0) { __start___ksymtab = .; *(__ksymtab) __stop___ksymtab = .; } __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - 0) { __start___ksymtab_gpl = .; *(__ksymtab_gpl) __stop___ksymtab_gpl = .; } __ksymtab_unused : AT(ADDR(__ksymtab_unused) - 0) { __start___ksymtab_unused = .; *(__ksymtab_unused) __stop___ksymtab_unused = .; } __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - 0) { __start___ksymtab_unused_gpl = .; *(__ksymtab_unused_gpl) __stop___ksymtab_unused_gpl = .; } __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - 0) { __start___ksymtab_gpl_future = .; *(__ksymtab_gpl_future) __stop___ksymtab_gpl_future = .; } __kcrctab : AT(ADDR(__kcrctab) - 0) { __start___kcrctab = .; *(__kcrctab) __stop___kcrctab = .; } __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - 0) { __start___kcrctab_gpl = .; *(__kcrctab_gpl) __stop___kcrctab_gpl = .; } __kcrctab_unused : AT(ADDR(__kcrctab_unused) - 0) { __start___kcrctab_unused = .; *(__kcrctab_unused) __stop___kcrctab_unused = .; } __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - 0) { __start___kcrctab_unused_gpl = .; *(__kcrctab_unused_gpl) __stop___kcrctab_unused_gpl = .; } __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - 0) { __start___kcrctab_gpl_future = .; *(__kcrctab_gpl_future) __stop___kcrctab_gpl_future = .; } __ksymtab_strings : AT(ADDR(__ksymtab_strings) - 0) { *(__ksymtab_strings) } __init_rodata : AT(ADDR(__init_rodata) - 0) { *(.ref.rodata) *(.devinit.rodata) *(.devexit.rodata) } __param : AT(ADDR(__param) - 0) { __start___param = .; *(__param) __stop___param = .; . = ALIGN((4096)); __end_rodata = .; } . = ALIGN((4096));
2096 + .unprotected : { *(.unprotected) }
2098 + PROVIDE (_unprotected_end = .);
2100 + .note : { *(.note.*) }
2101 + . = ALIGN(0); __ex_table : AT(ADDR(__ex_table) - 0) { __start___ex_table = .; *(__ex_table) __stop___ex_table = .; }
2102 + . = ALIGN(8); __bug_table : AT(ADDR(__bug_table) - 0) { __start___bug_table = .; *(__bug_table) __stop___bug_table = .; }
2103 + .uml.setup.init : {
2104 + __uml_setup_start = .;
2105 + *(.uml.setup.init)
2106 + __uml_setup_end = .;
2108 + .uml.help.init : {
2109 + __uml_help_start = .;
2111 + __uml_help_end = .;
2113 + .uml.postsetup.init : {
2114 + __uml_postsetup_start = .;
2115 + *(.uml.postsetup.init)
2116 + __uml_postsetup_end = .;
2119 + . = ALIGN(0); __setup_start = .; *(.init.setup) __setup_end = .;
2121 + . = ALIGN(32); .data.percpu : AT(ADDR(.data.percpu) - 0) { __per_cpu_load = .; __per_cpu_start = .; *(.data.percpu.first) *(.data.percpu.page_aligned) *(.data.percpu) *(.data.percpu.shared_aligned) __per_cpu_end = .; }
2122 + .initcall.init : {
2123 + __initcall_start = .; *(.initcallearly.init) __early_initcall_end = .; *(.initcall0.init) *(.initcall0s.init) *(.initcall1.init) *(.initcall1s.init) *(.initcall2.init) *(.initcall2s.init) *(.initcall3.init) *(.initcall3s.init) *(.initcall4.init) *(.initcall4s.init) *(.initcall5.init) *(.initcall5s.init) *(.initcallrootfs.init) *(.initcall6.init) *(.initcall6s.init) *(.initcall7.init) *(.initcall7s.init) __initcall_end = .;
2125 + .con_initcall.init : {
2126 + __con_initcall_start = .; *(.con_initcall.init) __con_initcall_end = .;
2128 + .uml.initcall.init : {
2129 + __uml_initcall_start = .;
2130 + *(.uml.initcall.init)
2131 + __uml_initcall_end = .;
2134 + .security_initcall.init : AT(ADDR(.security_initcall.init) - 0) { __security_initcall_start = .; *(.security_initcall.init) __security_initcall_end = .; }
2136 + __exitcall_begin = .;
2138 + __exitcall_end = .;
2141 + __uml_exitcall_begin = .;
2142 + *(.uml.exitcall.exit)
2143 + __uml_exitcall_end = .;
2146 + .altinstructions : {
2147 + __alt_instructions = .;
2148 + *(.altinstructions)
2149 + __alt_instructions_end = .;
2151 + .altinstr_replacement : { *(.altinstr_replacement) }
2152 + /* .exit.text is discard at runtime, not link time, to deal with references
2153 + from .altinstructions and .eh_frame */
2154 + .exit.text : { *(.exit.text) }
2155 + .exit.data : { *(.exit.data) }
2156 + .preinit_array : {
2157 + __preinit_array_start = .;
2159 + __preinit_array_end = .;
2162 + __init_array_start = .;
2164 + __init_array_end = .;
2167 + __fini_array_start = .;
2169 + __fini_array_end = .;
2175 + init.data : { *(.init.data) *(.cpuinit.data) *(.meminit.data) *(.init.rodata) *(.cpuinit.rodata) *(.meminit.rodata) }
2176 + /* Ensure the __preinit_array_start label is properly aligned. We
2177 + could instead move the label definition inside the section, but
2178 + the linker would then create the section even if it turns out to
2179 + be empty, which isn't pretty. */
2180 + . = ALIGN(32 / 8);
2181 + .preinit_array : { *(.preinit_array) }
2182 + .init_array : { *(.init_array) }
2183 + .fini_array : { *(.fini_array) }
2185 + . = ALIGN(KERNEL_STACK_SIZE); *(.data.init_task)
2186 + . = ALIGN(KERNEL_STACK_SIZE);
2187 + *(.data.init_irqstack)
2188 + *(.data) *(.ref.data) *(.devinit.data) *(.devexit.data) . = ALIGN(8); __start___markers = .; *(__markers) __stop___markers = .; . = ALIGN(32); __start___tracepoints = .; *(__tracepoints) __stop___tracepoints = .; . = ALIGN(8); __start___verbose = .; *(__verbose) __stop___verbose = .;
2189 + *(.data.* .gnu.linkonce.d.*)
2190 + SORT(CONSTRUCTORS)
2192 + .data1 : { *(.data1) }
2193 + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
2194 + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
2195 + .eh_frame : { KEEP (*(.eh_frame)) }
2196 + .gcc_except_table : { *(.gcc_except_table) }
2197 + .dynamic : { *(.dynamic) }
2199 + /* gcc uses crtbegin.o to find the start of
2200 + the constructors, so we make sure it is
2201 + first. Because this is a wildcard, it
2202 + doesn't matter if the user does not
2203 + actually link against crtbegin.o; the
2204 + linker won't look for a file to match a
2205 + wildcard. The wildcard also means that it
2206 + doesn't matter which directory crtbegin.o
2208 + KEEP (*crtbegin.o(.ctors))
2209 + /* We don't want to include the .ctor section from
2210 + from the crtend.o file until after the sorted ctors.
2211 + The .ctor section from the crtend file contains the
2212 + end of ctors marker and it must be last */
2213 + KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
2214 + KEEP (*(SORT(.ctors.*)))
2218 + KEEP (*crtbegin.o(.dtors))
2219 + KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
2220 + KEEP (*(SORT(.dtors.*)))
2223 + .jcr : { KEEP (*(.jcr)) }
2224 + .got : { *(.got.plt) *(.got) }
2226 + PROVIDE (edata = .);
2230 + *(.bss .bss.* .gnu.linkonce.b.*)
2232 + /* Align here to ensure that the .bss section occupies space up to
2233 + _end. Align after .bss to ensure correct alignment even if the
2234 + .bss section disappears because there are no input sections. */
2235 + . = ALIGN(32 / 8);
2236 + . = ALIGN(32 / 8);
2239 + PROVIDE (end = .);
2240 + .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) }
2241 + .debug 0 : { *(.debug) } .line 0 : { *(.line) } .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) }
2242 + /DISCARD/ : { *(.exit.text) *(.cpuexit.text) *(.memexit.text) *(.exit.data) *(.cpuexit.data) *(.cpuexit.rodata) *(.memexit.data) *(.memexit.rodata) *(.exitcall.exit) *(.discard) }
2244 diff -NurpP --minimal linux-2.6.35/arch/x86/ia32/ia32entry.S linux-2.6.35-vs2.3.0.36.31/arch/x86/ia32/ia32entry.S
2245 --- linux-2.6.35/arch/x86/ia32/ia32entry.S 2010-07-07 18:31:11.000000000 +0200
2246 +++ linux-2.6.35-vs2.3.0.36.31/arch/x86/ia32/ia32entry.S 2010-08-02 17:05:05.000000000 +0200
2247 @@ -777,7 +777,7 @@ ia32_sys_call_table:
2248 .quad sys_tgkill /* 270 */
2249 .quad compat_sys_utimes
2250 .quad sys32_fadvise64_64
2251 - .quad quiet_ni_syscall /* sys_vserver */
2252 + .quad sys32_vserver
2254 .quad compat_sys_get_mempolicy /* 275 */
2255 .quad sys_set_mempolicy
2256 diff -NurpP --minimal linux-2.6.35/arch/x86/include/asm/unistd_64.h linux-2.6.35-vs2.3.0.36.31/arch/x86/include/asm/unistd_64.h
2257 --- linux-2.6.35/arch/x86/include/asm/unistd_64.h 2010-07-07 18:31:11.000000000 +0200
2258 +++ linux-2.6.35-vs2.3.0.36.31/arch/x86/include/asm/unistd_64.h 2010-08-02 17:05:05.000000000 +0200
2259 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
2260 #define __NR_utimes 235
2261 __SYSCALL(__NR_utimes, sys_utimes)
2262 #define __NR_vserver 236
2263 -__SYSCALL(__NR_vserver, sys_ni_syscall)
2264 +__SYSCALL(__NR_vserver, sys_vserver)
2265 #define __NR_mbind 237
2266 __SYSCALL(__NR_mbind, sys_mbind)
2267 #define __NR_set_mempolicy 238
2268 diff -NurpP --minimal linux-2.6.35/arch/x86/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/x86/Kconfig
2269 --- linux-2.6.35/arch/x86/Kconfig 2010-08-02 16:52:11.000000000 +0200
2270 +++ linux-2.6.35-vs2.3.0.36.31/arch/x86/Kconfig 2010-08-02 17:05:05.000000000 +0200
2271 @@ -2123,6 +2123,8 @@ source "fs/Kconfig"
2273 source "arch/x86/Kconfig.debug"
2275 +source "kernel/vserver/Kconfig"
2277 source "security/Kconfig"
2279 source "crypto/Kconfig"
2280 diff -NurpP --minimal linux-2.6.35/arch/x86/kernel/syscall_table_32.S linux-2.6.35-vs2.3.0.36.31/arch/x86/kernel/syscall_table_32.S
2281 --- linux-2.6.35/arch/x86/kernel/syscall_table_32.S 2010-07-07 18:31:12.000000000 +0200
2282 +++ linux-2.6.35-vs2.3.0.36.31/arch/x86/kernel/syscall_table_32.S 2010-08-02 17:05:05.000000000 +0200
2283 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
2284 .long sys_tgkill /* 270 */
2286 .long sys_fadvise64_64
2287 - .long sys_ni_syscall /* sys_vserver */
2290 .long sys_get_mempolicy
2291 .long sys_set_mempolicy
2292 diff -NurpP --minimal linux-2.6.35/Documentation/vserver/debug.txt linux-2.6.35-vs2.3.0.36.31/Documentation/vserver/debug.txt
2293 --- linux-2.6.35/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
2294 +++ linux-2.6.35-vs2.3.0.36.31/Documentation/vserver/debug.txt 2010-08-02 17:05:05.000000000 +0200
2299 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
2300 + "vx_rmap_tgid: %p/%llx: %d -> %d"
2304 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
2305 + "FREE (%p,#%d)%c inode"
2306 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
2307 + "FREE (%p,#%d)%c %lld bytes"
2308 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
2309 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
2310 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
2311 + "rcu_free_dl_info(%p)"
2312 + 4 10 "alloc_dl_info(%p,%d) = %p"
2313 + "dealloc_dl_info(%p)"
2314 + "get_dl_info(%p[#%d.%d])"
2315 + "put_dl_info(%p[#%d.%d])"
2316 + 5 20 "alloc_dl_info(%p,%d)*"
2317 + 6 40 "__hash_dl_info: %p[#%d]"
2318 + "__unhash_dl_info: %p[#%d]"
2319 + 7 80 "locate_dl_info(%p,#%d) = %p"
2323 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
2324 + "new_dqhash: %p [#0x%08x]"
2325 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
2326 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
2327 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
2328 + "vroot_get_real_bdev not set"
2329 + 1 2 "cow_break_link(»%s«)"
2330 + "temp copy »%s«"
2331 + 2 4 "dentry_open(new): %p"
2332 + "dentry_open(old): %p"
2333 + "lookup_create(new): %p"
2335 + "path_lookup(old): %d"
2336 + "vfs_create(new): %d"
2338 + "vfs_sendfile: %d"
2339 + 3 8 "fput(new_file=%p[#%d])"
2340 + "fput(old_file=%p[#%d])"
2341 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
2342 + "vx_info_kill(%p[#%d],%d,%d)*"
2343 + 5 20 "vs_reboot(%p[#%d],%d)"
2344 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
2348 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
2349 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
2350 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
2351 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
2352 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
2353 + 6 40 "sk,egf: %p [#%d] (from %d)"
2354 + "sk,egn: %p [#%d] (from %d)"
2355 + "sk,req: %p [#%d] (from %d)"
2356 + "sk: %p [#%d] (from %d)"
2357 + "tw: %p [#%d] (from %d)"
2358 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
2359 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
2363 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
2364 + "alloc_nx_info(%d) = %p"
2365 + "create_nx_info(%d) (dynamic rejected)"
2366 + "create_nx_info(%d) = %p (already there)"
2367 + "create_nx_info(%d) = %p (new)"
2368 + "dealloc_nx_info(%p)"
2369 + 1 2 "alloc_nx_info(%d)*"
2370 + "create_nx_info(%d)*"
2371 + 2 4 "get_nx_info(%p[#%d.%d])"
2372 + "put_nx_info(%p[#%d.%d])"
2373 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
2374 + "clr_nx_info(%p[#%d.%d])"
2375 + "init_nx_info(%p[#%d.%d])"
2376 + "release_nx_info(%p[#%d.%d.%d]) %p"
2377 + "set_nx_info(%p[#%d.%d])"
2378 + 4 10 "__hash_nx_info: %p[#%d]"
2379 + "__nx_dynamic_id: [#%d]"
2380 + "__unhash_nx_info: %p[#%d.%d.%d]"
2381 + 5 20 "moved task %p into nxi:%p[#%d]"
2382 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
2383 + "task_get_nx_info(%p)"
2384 + 6 40 "nx_clear_persistent(%p[#%d])"
2388 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
2389 + 1 2 "quota_sync_dqh(%p,%d)"
2390 + "sync_dquots(%p,%d)"
2391 + "sync_dquots_dqh(%p,%d)"
2392 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
2396 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
2397 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
2398 + 4 10 "%s: (%s %s) returned %s with %d"
2402 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
2403 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
2407 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
2408 + "alloc_vx_info(%d) = %p"
2409 + "alloc_vx_info(%d)*"
2410 + "create_vx_info(%d) (dynamic rejected)"
2411 + "create_vx_info(%d) = %p (already there)"
2412 + "create_vx_info(%d) = %p (new)"
2413 + "dealloc_vx_info(%p)"
2414 + "loc_vx_info(%d) = %p (found)"
2415 + "loc_vx_info(%d) = %p (new)"
2416 + "loc_vx_info(%d) = %p (not available)"
2417 + 1 2 "create_vx_info(%d)*"
2418 + "loc_vx_info(%d)*"
2419 + 2 4 "get_vx_info(%p[#%d.%d])"
2420 + "put_vx_info(%p[#%d.%d])"
2421 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
2422 + "clr_vx_info(%p[#%d.%d])"
2423 + "init_vx_info(%p[#%d.%d])"
2424 + "release_vx_info(%p[#%d.%d.%d]) %p"
2425 + "set_vx_info(%p[#%d.%d])"
2426 + 4 10 "__hash_vx_info: %p[#%d]"
2427 + "__unhash_vx_info: %p[#%d.%d.%d]"
2428 + "__vx_dynamic_id: [#%d]"
2429 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
2430 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
2431 + "moved task %p into vxi:%p[#%d]"
2432 + "task_get_vx_info(%p)"
2433 + "vx_migrate_task(%p,%p[#%d.%d])"
2434 + 6 40 "vx_clear_persistent(%p[#%d])"
2435 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
2436 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
2437 + "vx_set_persistent(%p[#%d])"
2438 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
2439 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
2444 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
2445 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
2447 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
2448 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
2449 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
2450 diff -NurpP --minimal linux-2.6.35/drivers/block/Kconfig linux-2.6.35-vs2.3.0.36.31/drivers/block/Kconfig
2451 --- linux-2.6.35/drivers/block/Kconfig 2010-08-02 16:52:14.000000000 +0200
2452 +++ linux-2.6.35-vs2.3.0.36.31/drivers/block/Kconfig 2010-08-02 17:05:05.000000000 +0200
2453 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
2455 source "drivers/block/drbd/Kconfig"
2457 +config BLK_DEV_VROOT
2458 + tristate "Virtual Root device support"
2459 + depends on QUOTACTL
2461 + Saying Y here will allow you to use quota/fs ioctls on a shared
2462 + partition within a virtual server without compromising security.
2465 tristate "Network block device support"
2467 diff -NurpP --minimal linux-2.6.35/drivers/block/loop.c linux-2.6.35-vs2.3.0.36.31/drivers/block/loop.c
2468 --- linux-2.6.35/drivers/block/loop.c 2010-08-02 16:52:14.000000000 +0200
2469 +++ linux-2.6.35-vs2.3.0.36.31/drivers/block/loop.c 2010-08-02 17:05:05.000000000 +0200
2471 #include <linux/highmem.h>
2472 #include <linux/kthread.h>
2473 #include <linux/splice.h>
2474 +#include <linux/vs_context.h>
2476 #include <asm/uaccess.h>
2478 @@ -813,6 +814,7 @@ static int loop_set_fd(struct loop_devic
2479 lo->lo_blocksize = lo_blocksize;
2480 lo->lo_device = bdev;
2481 lo->lo_flags = lo_flags;
2482 + lo->lo_xid = vx_current_xid();
2483 lo->lo_backing_file = file;
2484 lo->transfer = transfer_none;
2486 @@ -941,6 +943,7 @@ static int loop_clr_fd(struct loop_devic
2487 lo->lo_encrypt_key_size = 0;
2489 lo->lo_thread = NULL;
2491 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
2492 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
2493 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
2494 @@ -978,7 +981,7 @@ loop_set_status(struct loop_device *lo,
2496 if (lo->lo_encrypt_key_size &&
2497 lo->lo_key_owner != uid &&
2498 - !capable(CAP_SYS_ADMIN))
2499 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
2501 if (lo->lo_state != Lo_bound)
2503 @@ -1062,7 +1065,8 @@ loop_get_status(struct loop_device *lo,
2504 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
2505 info->lo_encrypt_type =
2506 lo->lo_encryption ? lo->lo_encryption->number : 0;
2507 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
2508 + if (lo->lo_encrypt_key_size &&
2509 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
2510 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
2511 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
2512 lo->lo_encrypt_key_size);
2513 @@ -1408,6 +1412,9 @@ static int lo_open(struct block_device *
2515 struct loop_device *lo = bdev->bd_disk->private_data;
2517 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
2520 mutex_lock(&lo->lo_ctl_mutex);
2522 mutex_unlock(&lo->lo_ctl_mutex);
2523 diff -NurpP --minimal linux-2.6.35/drivers/block/Makefile linux-2.6.35-vs2.3.0.36.31/drivers/block/Makefile
2524 --- linux-2.6.35/drivers/block/Makefile 2010-02-25 11:51:36.000000000 +0100
2525 +++ linux-2.6.35-vs2.3.0.36.31/drivers/block/Makefile 2010-08-02 17:05:05.000000000 +0200
2526 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
2527 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
2528 obj-$(CONFIG_BLK_DEV_UB) += ub.o
2529 obj-$(CONFIG_BLK_DEV_HD) += hd.o
2530 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
2532 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
2533 obj-$(CONFIG_BLK_DEV_DRBD) += drbd/
2534 diff -NurpP --minimal linux-2.6.35/drivers/block/vroot.c linux-2.6.35-vs2.3.0.36.31/drivers/block/vroot.c
2535 --- linux-2.6.35/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
2536 +++ linux-2.6.35-vs2.3.0.36.31/drivers/block/vroot.c 2010-08-02 17:05:05.000000000 +0200
2539 + * linux/drivers/block/vroot.c
2541 + * written by Herbert Pötzl, 9/11/2002
2542 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
2544 + * based on the loop.c code by Theodore Ts'o.
2546 + * Copyright (C) 2002-2007 by Herbert Pötzl.
2547 + * Redistribution of this file is permitted under the
2548 + * GNU General Public License.
2552 +#include <linux/module.h>
2553 +#include <linux/moduleparam.h>
2554 +#include <linux/file.h>
2555 +#include <linux/major.h>
2556 +#include <linux/blkdev.h>
2557 +#include <linux/slab.h>
2559 +#include <linux/vroot.h>
2560 +#include <linux/vs_context.h>
2563 +static int max_vroot = 8;
2565 +static struct vroot_device *vroot_dev;
2566 +static struct gendisk **disks;
2569 +static int vroot_set_dev(
2570 + struct vroot_device *vr,
2571 + struct block_device *bdev,
2574 + struct block_device *real_bdev;
2575 + struct file *file;
2576 + struct inode *inode;
2580 + if (vr->vr_state != Vr_unbound)
2589 + inode = file->f_dentry->d_inode;
2592 + if (S_ISBLK(inode->i_mode)) {
2593 + real_bdev = inode->i_bdev;
2594 + vr->vr_device = real_bdev;
2595 + __iget(real_bdev->bd_inode);
2599 + vxdprintk(VXD_CBIT(misc, 0),
2600 + "vroot[%d]_set_dev: dev=" VXF_DEV,
2601 + vr->vr_number, VXD_DEV(real_bdev));
2603 + vr->vr_state = Vr_bound;
2612 +static int vroot_clr_dev(
2613 + struct vroot_device *vr,
2614 + struct block_device *bdev)
2616 + struct block_device *real_bdev;
2618 + if (vr->vr_state != Vr_bound)
2620 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
2623 + real_bdev = vr->vr_device;
2625 + vxdprintk(VXD_CBIT(misc, 0),
2626 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
2627 + vr->vr_number, VXD_DEV(real_bdev));
2630 + vr->vr_state = Vr_unbound;
2631 + vr->vr_device = NULL;
2636 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
2637 + unsigned int cmd, unsigned long arg)
2639 + struct vroot_device *vr = bdev->bd_disk->private_data;
2642 + down(&vr->vr_ctl_mutex);
2644 + case VROOT_SET_DEV:
2645 + err = vroot_set_dev(vr, bdev, arg);
2647 + case VROOT_CLR_DEV:
2648 + err = vroot_clr_dev(vr, bdev);
2654 + up(&vr->vr_ctl_mutex);
2658 +static int vr_open(struct block_device *bdev, fmode_t mode)
2660 + struct vroot_device *vr = bdev->bd_disk->private_data;
2662 + down(&vr->vr_ctl_mutex);
2664 + up(&vr->vr_ctl_mutex);
2668 +static int vr_release(struct gendisk *disk, fmode_t mode)
2670 + struct vroot_device *vr = disk->private_data;
2672 + down(&vr->vr_ctl_mutex);
2674 + up(&vr->vr_ctl_mutex);
2678 +static struct block_device_operations vr_fops = {
2679 + .owner = THIS_MODULE,
2681 + .release = vr_release,
2682 + .ioctl = vr_ioctl,
2685 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
2687 + struct inode *inode = bdev->bd_inode;
2688 + struct vroot_device *vr;
2689 + struct block_device *real_bdev;
2690 + int minor = iminor(inode);
2692 + vr = &vroot_dev[minor];
2693 + real_bdev = vr->vr_device;
2695 + vxdprintk(VXD_CBIT(misc, 0),
2696 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
2697 + vr->vr_number, VXD_DEV(real_bdev));
2699 + if (vr->vr_state != Vr_bound)
2700 + return ERR_PTR(-ENXIO);
2702 + __iget(real_bdev->bd_inode);
2707 + * And now the modules code and kernel interface.
2710 +module_param(max_vroot, int, 0);
2712 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
2713 +MODULE_LICENSE("GPL");
2714 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
2716 +MODULE_AUTHOR ("Herbert Pötzl");
2717 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
2720 +int __init vroot_init(void)
2724 + if (max_vroot < 1 || max_vroot > 256) {
2725 + max_vroot = MAX_VROOT_DEFAULT;
2726 + printk(KERN_WARNING "vroot: invalid max_vroot "
2727 + "(must be between 1 and 256), "
2728 + "using default (%d)\n", max_vroot);
2731 + if (register_blkdev(VROOT_MAJOR, "vroot"))
2735 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
2738 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
2740 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
2744 + for (i = 0; i < max_vroot; i++) {
2745 + disks[i] = alloc_disk(1);
2748 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
2749 + if (!disks[i]->queue)
2753 + for (i = 0; i < max_vroot; i++) {
2754 + struct vroot_device *vr = &vroot_dev[i];
2755 + struct gendisk *disk = disks[i];
2757 + memset(vr, 0, sizeof(*vr));
2758 + init_MUTEX(&vr->vr_ctl_mutex);
2759 + vr->vr_number = i;
2760 + disk->major = VROOT_MAJOR;
2761 + disk->first_minor = i;
2762 + disk->fops = &vr_fops;
2763 + sprintf(disk->disk_name, "vroot%d", i);
2764 + disk->private_data = vr;
2767 + err = register_vroot_grb(&__vroot_get_real_bdev);
2771 + for (i = 0; i < max_vroot; i++)
2772 + add_disk(disks[i]);
2773 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
2778 + put_disk(disks[i]);
2783 + unregister_blkdev(VROOT_MAJOR, "vroot");
2784 + printk(KERN_ERR "vroot: ran out of memory\n");
2788 +void vroot_exit(void)
2792 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
2793 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
2795 + for (i = 0; i < max_vroot; i++) {
2796 + del_gendisk(disks[i]);
2797 + put_disk(disks[i]);
2799 + unregister_blkdev(VROOT_MAJOR, "vroot");
2805 +module_init(vroot_init);
2806 +module_exit(vroot_exit);
2810 +static int __init max_vroot_setup(char *str)
2812 + max_vroot = simple_strtol(str, NULL, 0);
2816 +__setup("max_vroot=", max_vroot_setup);
2820 diff -NurpP --minimal linux-2.6.35/drivers/char/sysrq.c linux-2.6.35-vs2.3.0.36.31/drivers/char/sysrq.c
2821 --- linux-2.6.35/drivers/char/sysrq.c 2010-08-02 16:52:15.000000000 +0200
2822 +++ linux-2.6.35-vs2.3.0.36.31/drivers/char/sysrq.c 2010-08-02 17:39:50.000000000 +0200
2824 #include <linux/oom.h>
2825 #include <linux/slab.h>
2826 #include <linux/input.h>
2827 +#include <linux/vserver/debug.h>
2829 #include <asm/ptrace.h>
2830 #include <asm/irq_regs.h>
2831 @@ -396,6 +397,21 @@ static struct sysrq_key_op sysrq_unrt_op
2832 .enable_mask = SYSRQ_ENABLE_RTNICE,
2836 +#ifdef CONFIG_VSERVER_DEBUG
2837 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
2839 + dump_vx_info_inactive((key == 'x')?0:1);
2842 +static struct sysrq_key_op sysrq_showvxinfo_op = {
2843 + .handler = sysrq_handle_vxinfo,
2844 + .help_msg = "conteXt",
2845 + .action_msg = "Show Context Info",
2846 + .enable_mask = SYSRQ_ENABLE_DUMP,
2850 /* Key Operations table and lock */
2851 static DEFINE_SPINLOCK(sysrq_key_table_lock);
2853 @@ -450,7 +466,11 @@ static struct sysrq_key_op *sysrq_key_ta
2855 &sysrq_showstate_blocked_op, /* w */
2856 /* x: May be registered on ppc/powerpc for xmon */
2857 +#ifdef CONFIG_VSERVER_DEBUG
2858 + &sysrq_showvxinfo_op, /* x */
2862 /* y: May be registered on sparc64 for global register dump */
2864 &sysrq_ftrace_dump_op, /* z */
2865 @@ -465,6 +485,8 @@ static int sysrq_key_table_key2index(int
2867 else if ((key >= 'a') && (key <= 'z'))
2868 retval = key + 10 - 'a';
2869 + else if ((key >= 'A') && (key <= 'Z'))
2870 + retval = key + 10 - 'A';
2874 diff -NurpP --minimal linux-2.6.35/drivers/char/tty_io.c linux-2.6.35-vs2.3.0.36.31/drivers/char/tty_io.c
2875 --- linux-2.6.35/drivers/char/tty_io.c 2010-07-07 18:31:15.000000000 +0200
2876 +++ linux-2.6.35-vs2.3.0.36.31/drivers/char/tty_io.c 2010-08-02 17:05:05.000000000 +0200
2879 #include <linux/kmod.h>
2880 #include <linux/nsproxy.h>
2881 +#include <linux/vs_pid.h>
2883 #undef TTY_DEBUG_HANGUP
2885 @@ -1992,7 +1993,8 @@ static int tiocsti(struct tty_struct *tt
2887 struct tty_ldisc *ld;
2889 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
2890 + if (((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN)) ||
2891 + !vx_ccaps(VXC_TIOCSTI))
2893 if (get_user(ch, p))
2895 @@ -2280,6 +2282,7 @@ static int tiocspgrp(struct tty_struct *
2897 if (get_user(pgrp_nr, p))
2899 + pgrp_nr = vx_rmap_pid(pgrp_nr);
2903 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/r100_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r100_reg_safe.h
2904 --- linux-2.6.35/drivers/gpu/drm/radeon/r100_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
2905 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r100_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
2907 +static const unsigned r100_reg_safe_bm[102] = {
2908 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2909 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2910 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2911 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2912 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2913 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2914 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2915 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2916 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2917 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2918 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
2919 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
2920 + 0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2921 + 0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2922 + 0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
2923 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2924 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
2925 + 0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
2926 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2927 + 0xFFFFFFFF, 0xFFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2928 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2929 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2930 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2931 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2932 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2933 + 0xFFFFFFFF, 0xFFFFFFEF,
2935 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/r200_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r200_reg_safe.h
2936 --- linux-2.6.35/drivers/gpu/drm/radeon/r200_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
2937 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r200_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
2939 +static const unsigned r200_reg_safe_bm[102] = {
2940 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2941 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2942 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2943 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2944 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2945 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2946 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2947 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2948 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2949 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2950 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
2951 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
2952 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2953 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2954 + 0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
2955 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2956 + 0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
2957 + 0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
2958 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2959 + 0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2960 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2961 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2962 + 0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
2963 + 0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
2964 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2965 + 0xFFFFFE3F, 0xFFFFFFEF,
2967 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/r300_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r300_reg_safe.h
2968 --- linux-2.6.35/drivers/gpu/drm/radeon/r300_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
2969 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r300_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
2971 +static const unsigned r300_reg_safe_bm[159] = {
2972 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2973 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2974 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2975 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2976 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2977 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2978 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2979 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2980 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2981 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2982 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
2983 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
2984 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2985 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2986 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
2987 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2988 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
2989 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
2990 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2991 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2992 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2993 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2994 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2995 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2996 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2997 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2998 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2999 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3000 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3001 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3002 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3003 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3004 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3005 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3006 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3007 + 0x00000000, 0x0000C100, 0x00000000, 0x00000000,
3008 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3009 + 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
3010 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3011 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
3013 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/r420_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r420_reg_safe.h
3014 --- linux-2.6.35/drivers/gpu/drm/radeon/r420_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3015 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r420_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
3017 +static const unsigned r420_reg_safe_bm[159] = {
3018 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3019 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3020 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3021 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3022 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3023 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3024 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3025 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3026 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3027 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3028 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3029 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3030 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3031 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3032 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3033 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3034 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3035 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3036 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3037 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3038 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3039 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3040 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3041 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3042 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3043 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3044 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3045 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3046 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3047 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3048 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3049 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3050 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3051 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3052 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3053 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
3054 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3055 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
3056 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3057 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
3059 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/rn50_reg_safe.h
3060 --- linux-2.6.35/drivers/gpu/drm/radeon/rn50_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3061 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/rn50_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
3063 +static const unsigned rn50_reg_safe_bm[102] = {
3064 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3065 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3066 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3067 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3068 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3069 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3070 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3071 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3072 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3073 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3074 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3075 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3076 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3077 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3078 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3079 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3080 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3081 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3082 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3083 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3084 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3085 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3086 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3087 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3088 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3089 + 0xFFFFFFFF, 0xFFFFFFFF,
3091 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/rs600_reg_safe.h
3092 --- linux-2.6.35/drivers/gpu/drm/radeon/rs600_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3093 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/rs600_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
3095 +static const unsigned rs600_reg_safe_bm[219] = {
3096 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3097 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3098 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3099 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3100 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3101 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3102 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3103 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3104 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3105 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3106 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3107 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3108 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3109 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3110 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3111 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3112 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3113 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3114 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3115 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3116 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3117 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3118 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3119 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3120 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3121 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3122 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3123 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3124 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3125 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3126 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3127 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3128 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3129 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3130 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3131 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
3132 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3133 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
3134 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3135 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
3136 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3137 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3138 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3139 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3140 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3141 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3142 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3143 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3144 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3145 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3146 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3147 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3148 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3149 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3150 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3152 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/rv515_reg_safe.h
3153 --- linux-2.6.35/drivers/gpu/drm/radeon/rv515_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3154 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/rv515_reg_safe.h 2010-08-02 17:05:05.000000000 +0200
3156 +static const unsigned rv515_reg_safe_bm[219] = {
3157 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3158 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3159 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3160 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3161 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3162 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3163 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3164 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3165 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3166 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3167 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3168 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3169 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3170 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3171 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3172 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3173 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3174 + 0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3175 + 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
3176 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3177 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3178 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3179 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3180 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3181 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3182 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3183 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3184 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3185 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3186 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3187 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3188 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3189 + 0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
3190 + 0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
3191 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3192 + 0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
3193 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3194 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
3195 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3196 + 0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
3197 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3198 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3199 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3200 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3201 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3202 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3203 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3204 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3205 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3206 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3207 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3208 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3209 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3210 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3211 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3213 diff -NurpP --minimal linux-2.6.35/drivers/infiniband/core/addr.c linux-2.6.35-vs2.3.0.36.31/drivers/infiniband/core/addr.c
3214 --- linux-2.6.35/drivers/infiniband/core/addr.c 2010-07-07 18:31:18.000000000 +0200
3215 +++ linux-2.6.35-vs2.3.0.36.31/drivers/infiniband/core/addr.c 2010-08-02 17:05:05.000000000 +0200
3216 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
3218 if (ipv6_addr_any(&fl.fl6_src)) {
3219 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
3220 - &fl.fl6_dst, 0, &fl.fl6_src);
3221 + &fl.fl6_dst, 0, &fl.fl6_src, NULL);
3225 diff -NurpP --minimal linux-2.6.35/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.35-vs2.3.0.36.31/drivers/infiniband/hw/ipath/ipath_user_pages.c
3226 --- linux-2.6.35/drivers/infiniband/hw/ipath/ipath_user_pages.c 2010-07-07 18:31:19.000000000 +0200
3227 +++ linux-2.6.35-vs2.3.0.36.31/drivers/infiniband/hw/ipath/ipath_user_pages.c 2010-08-02 17:05:05.000000000 +0200
3229 #include <linux/device.h>
3230 #include <linux/slab.h>
3231 #include <linux/sched.h>
3232 +#include <linux/vs_memory.h>
3234 #include "ipath_kernel.h"
3236 diff -NurpP --minimal linux-2.6.35/drivers/md/dm.c linux-2.6.35-vs2.3.0.36.31/drivers/md/dm.c
3237 --- linux-2.6.35/drivers/md/dm.c 2010-07-07 18:31:21.000000000 +0200
3238 +++ linux-2.6.35-vs2.3.0.36.31/drivers/md/dm.c 2010-08-02 17:05:05.000000000 +0200
3240 #include <linux/slab.h>
3241 #include <linux/idr.h>
3242 #include <linux/hdreg.h>
3243 +#include <linux/vs_base.h>
3245 #include <trace/events/block.h>
3247 @@ -119,6 +120,7 @@ struct mapped_device {
3250 atomic_t open_count;
3253 unsigned long flags;
3255 @@ -337,6 +339,7 @@ int dm_deleting_md(struct mapped_device
3256 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
3258 struct mapped_device *md;
3261 spin_lock(&_minor_lock);
3263 @@ -345,18 +348,19 @@ static int dm_blk_open(struct block_devi
3266 if (test_bit(DMF_FREEING, &md->flags) ||
3267 - dm_deleting_md(md)) {
3269 + dm_deleting_md(md))
3273 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
3278 atomic_inc(&md->open_count);
3282 spin_unlock(&_minor_lock);
3284 - return md ? 0 : -ENXIO;
3288 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
3289 @@ -574,6 +578,14 @@ int dm_set_geometry(struct mapped_device
3294 + * Get the xid associated with a dm device
3296 +xid_t dm_get_xid(struct mapped_device *md)
3301 /*-----------------------------------------------------------------
3303 * A more elegant soln is in the works that uses the queue
3304 @@ -1886,6 +1898,7 @@ static struct mapped_device *alloc_dev(i
3305 INIT_LIST_HEAD(&md->uevent_list);
3306 spin_lock_init(&md->uevent_lock);
3308 + md->xid = vx_current_xid();
3309 md->queue = blk_init_queue(dm_request_fn, NULL);
3312 diff -NurpP --minimal linux-2.6.35/drivers/md/dm.h linux-2.6.35-vs2.3.0.36.31/drivers/md/dm.h
3313 --- linux-2.6.35/drivers/md/dm.h 2010-07-07 18:31:21.000000000 +0200
3314 +++ linux-2.6.35-vs2.3.0.36.31/drivers/md/dm.h 2010-08-02 17:05:05.000000000 +0200
3315 @@ -41,6 +41,8 @@ struct dm_dev_internal {
3317 struct dm_md_mempools;
3319 +xid_t dm_get_xid(struct mapped_device *md);
3321 /*-----------------------------------------------------------------
3322 * Internal table functions.
3323 *---------------------------------------------------------------*/
3324 diff -NurpP --minimal linux-2.6.35/drivers/md/dm-ioctl.c linux-2.6.35-vs2.3.0.36.31/drivers/md/dm-ioctl.c
3325 --- linux-2.6.35/drivers/md/dm-ioctl.c 2010-07-07 18:31:21.000000000 +0200
3326 +++ linux-2.6.35-vs2.3.0.36.31/drivers/md/dm-ioctl.c 2010-08-02 17:05:05.000000000 +0200
3328 #include <linux/dm-ioctl.h>
3329 #include <linux/hdreg.h>
3330 #include <linux/compat.h>
3331 +#include <linux/vs_context.h>
3333 #include <asm/uaccess.h>
3335 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
3336 unsigned int h = hash_str(str);
3338 list_for_each_entry (hc, _name_buckets + h, name_list)
3339 - if (!strcmp(hc->name, str)) {
3340 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3341 + !strcmp(hc->name, str)) {
3345 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
3346 unsigned int h = hash_str(str);
3348 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
3349 - if (!strcmp(hc->uuid, str)) {
3350 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3351 + !strcmp(hc->uuid, str)) {
3355 @@ -365,6 +368,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
3357 static int remove_all(struct dm_ioctl *param, size_t param_size)
3359 + if (!vx_check(0, VS_ADMIN))
3362 dm_hash_remove_all(1);
3363 param->data_size = 0;
3365 @@ -412,6 +418,8 @@ static int list_devices(struct dm_ioctl
3367 for (i = 0; i < NUM_BUCKETS; i++) {
3368 list_for_each_entry (hc, _name_buckets + i, name_list) {
3369 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3371 needed += sizeof(struct dm_name_list);
3372 needed += strlen(hc->name) + 1;
3373 needed += ALIGN_MASK;
3374 @@ -435,6 +443,8 @@ static int list_devices(struct dm_ioctl
3376 for (i = 0; i < NUM_BUCKETS; i++) {
3377 list_for_each_entry (hc, _name_buckets + i, name_list) {
3378 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3381 old_nl->next = (uint32_t) ((void *) nl -
3383 @@ -669,10 +679,11 @@ static struct hash_cell *__find_device_h
3387 - mdptr = dm_get_mdptr(md);
3388 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
3389 + mdptr = dm_get_mdptr(md);
3397 @@ -1514,8 +1525,8 @@ static int ctl_ioctl(uint command, struc
3401 - /* only root can play with this */
3402 - if (!capable(CAP_SYS_ADMIN))
3403 + /* only root and certain contexts can play with this */
3404 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
3407 if (_IOC_TYPE(command) != DM_IOCTL)
3408 diff -NurpP --minimal linux-2.6.35/drivers/net/tun.c linux-2.6.35-vs2.3.0.36.31/drivers/net/tun.c
3409 --- linux-2.6.35/drivers/net/tun.c 2010-08-02 16:52:27.000000000 +0200
3410 +++ linux-2.6.35-vs2.3.0.36.31/drivers/net/tun.c 2010-08-02 17:05:05.000000000 +0200
3412 #include <linux/nsproxy.h>
3413 #include <linux/virtio_net.h>
3414 #include <linux/rcupdate.h>
3415 +#include <linux/vs_network.h>
3416 #include <net/net_namespace.h>
3417 #include <net/netns/generic.h>
3418 #include <net/rtnetlink.h>
3419 @@ -103,6 +104,7 @@ struct tun_struct {
3425 struct net_device *dev;
3426 struct fasync_struct *fasync;
3427 @@ -851,6 +853,7 @@ static void tun_setup(struct net_device
3431 + tun->nid = current->nid;
3433 dev->ethtool_ops = &tun_ethtool_ops;
3434 dev->destructor = tun_free_netdev;
3435 @@ -1001,7 +1004,7 @@ static int tun_set_iff(struct net *net,
3437 if (((tun->owner != -1 && cred->euid != tun->owner) ||
3438 (tun->group != -1 && !in_egroup_p(tun->group))) &&
3439 - !capable(CAP_NET_ADMIN))
3440 + !cap_raised(current_cap(), CAP_NET_ADMIN))
3442 err = security_tun_dev_attach(tun->socket.sk);
3444 @@ -1015,7 +1018,7 @@ static int tun_set_iff(struct net *net,
3446 unsigned long flags = 0;
3448 - if (!capable(CAP_NET_ADMIN))
3449 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
3451 err = security_tun_dev_create();
3453 @@ -1085,6 +1088,9 @@ static int tun_set_iff(struct net *net,
3455 sk->sk_destruct = tun_sock_destruct;
3457 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
3460 err = tun_attach(tun, file);
3463 @@ -1276,6 +1282,16 @@ static long __tun_chr_ioctl(struct file
3464 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
3468 + if (!capable(CAP_CONTEXT))
3471 + /* Set nid owner of the device */
3472 + tun->nid = (nid_t) arg;
3474 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
3478 /* Only allow setting the type when the interface is down */
3479 if (tun->dev->flags & IFF_UP) {
3480 diff -NurpP --minimal linux-2.6.35/fs/attr.c linux-2.6.35-vs2.3.0.36.31/fs/attr.c
3481 --- linux-2.6.35/fs/attr.c 2010-08-02 16:52:47.000000000 +0200
3482 +++ linux-2.6.35-vs2.3.0.36.31/fs/attr.c 2010-08-02 21:00:32.000000000 +0200
3484 #include <linux/fsnotify.h>
3485 #include <linux/fcntl.h>
3486 #include <linux/security.h>
3487 +#include <linux/proc_fs.h>
3488 +#include <linux/devpts_fs.h>
3489 +#include <linux/vs_tag.h>
3491 /* Taken over from the old code... */
3493 @@ -54,6 +57,10 @@ int inode_change_ok(const struct inode *
3494 if (!is_owner_or_cap(inode))
3498 + if (dx_permission(inode, MAY_WRITE))
3504 @@ -127,6 +134,8 @@ void generic_setattr(struct inode *inode
3505 inode->i_uid = attr->ia_uid;
3506 if (ia_valid & ATTR_GID)
3507 inode->i_gid = attr->ia_gid;
3508 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3509 + inode->i_tag = attr->ia_tag;
3510 if (ia_valid & ATTR_ATIME)
3511 inode->i_atime = timespec_trunc(attr->ia_atime,
3512 inode->i_sb->s_time_gran);
3513 @@ -179,7 +188,8 @@ int notify_change(struct dentry * dentry
3514 struct timespec now;
3515 unsigned int ia_valid = attr->ia_valid;
3517 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
3518 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
3519 + ATTR_TAG | ATTR_TIMES_SET)) {
3520 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
3523 diff -NurpP --minimal linux-2.6.35/fs/binfmt_aout.c linux-2.6.35-vs2.3.0.36.31/fs/binfmt_aout.c
3524 --- linux-2.6.35/fs/binfmt_aout.c 2010-07-07 18:31:50.000000000 +0200
3525 +++ linux-2.6.35-vs2.3.0.36.31/fs/binfmt_aout.c 2010-08-02 17:05:05.000000000 +0200
3527 #include <linux/init.h>
3528 #include <linux/coredump.h>
3529 #include <linux/slab.h>
3530 +#include <linux/vs_memory.h>
3532 #include <asm/system.h>
3533 #include <asm/uaccess.h>
3534 diff -NurpP --minimal linux-2.6.35/fs/binfmt_elf.c linux-2.6.35-vs2.3.0.36.31/fs/binfmt_elf.c
3535 --- linux-2.6.35/fs/binfmt_elf.c 2010-07-07 18:31:50.000000000 +0200
3536 +++ linux-2.6.35-vs2.3.0.36.31/fs/binfmt_elf.c 2010-08-02 17:05:05.000000000 +0200
3538 #include <linux/elf.h>
3539 #include <linux/utsname.h>
3540 #include <linux/coredump.h>
3541 +#include <linux/vs_memory.h>
3542 #include <asm/uaccess.h>
3543 #include <asm/param.h>
3544 #include <asm/page.h>
3545 diff -NurpP --minimal linux-2.6.35/fs/binfmt_flat.c linux-2.6.35-vs2.3.0.36.31/fs/binfmt_flat.c
3546 --- linux-2.6.35/fs/binfmt_flat.c 2010-08-02 16:52:47.000000000 +0200
3547 +++ linux-2.6.35-vs2.3.0.36.31/fs/binfmt_flat.c 2010-08-02 17:05:05.000000000 +0200
3549 #include <linux/init.h>
3550 #include <linux/flat.h>
3551 #include <linux/syscalls.h>
3552 +#include <linux/vs_memory.h>
3554 #include <asm/byteorder.h>
3555 #include <asm/system.h>
3556 diff -NurpP --minimal linux-2.6.35/fs/binfmt_som.c linux-2.6.35-vs2.3.0.36.31/fs/binfmt_som.c
3557 --- linux-2.6.35/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
3558 +++ linux-2.6.35-vs2.3.0.36.31/fs/binfmt_som.c 2010-08-02 17:05:05.000000000 +0200
3560 #include <linux/shm.h>
3561 #include <linux/personality.h>
3562 #include <linux/init.h>
3563 +#include <linux/vs_memory.h>
3565 #include <asm/uaccess.h>
3566 #include <asm/pgtable.h>
3567 diff -NurpP --minimal linux-2.6.35/fs/block_dev.c linux-2.6.35-vs2.3.0.36.31/fs/block_dev.c
3568 --- linux-2.6.35/fs/block_dev.c 2010-08-02 16:52:47.000000000 +0200
3569 +++ linux-2.6.35-vs2.3.0.36.31/fs/block_dev.c 2010-08-02 17:05:05.000000000 +0200
3571 #include <linux/namei.h>
3572 #include <linux/log2.h>
3573 #include <linux/kmemleak.h>
3574 +#include <linux/vs_device.h>
3575 #include <asm/uaccess.h>
3576 #include "internal.h"
3578 @@ -529,6 +530,7 @@ struct block_device *bdget(dev_t dev)
3579 bdev->bd_invalidated = 0;
3580 inode->i_mode = S_IFBLK;
3581 inode->i_rdev = dev;
3582 + inode->i_mdev = dev;
3583 inode->i_bdev = bdev;
3584 inode->i_data.a_ops = &def_blk_aops;
3585 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
3586 @@ -575,6 +577,11 @@ EXPORT_SYMBOL(bdput);
3587 static struct block_device *bd_acquire(struct inode *inode)
3589 struct block_device *bdev;
3592 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
3594 + inode->i_mdev = mdev;
3596 spin_lock(&bdev_lock);
3597 bdev = inode->i_bdev;
3598 @@ -585,7 +592,7 @@ static struct block_device *bd_acquire(s
3600 spin_unlock(&bdev_lock);
3602 - bdev = bdget(inode->i_rdev);
3603 + bdev = bdget(mdev);
3605 spin_lock(&bdev_lock);
3606 if (!inode->i_bdev) {
3607 diff -NurpP --minimal linux-2.6.35/fs/btrfs/ctree.h linux-2.6.35-vs2.3.0.36.31/fs/btrfs/ctree.h
3608 --- linux-2.6.35/fs/btrfs/ctree.h 2010-08-02 16:52:47.000000000 +0200
3609 +++ linux-2.6.35-vs2.3.0.36.31/fs/btrfs/ctree.h 2010-08-02 17:05:05.000000000 +0200
3610 @@ -551,11 +551,14 @@ struct btrfs_inode_item {
3611 /* modification sequence number for NFS */
3616 * a little future expansion, for more than this we can
3617 * just grow the inode item and version it
3619 - __le64 reserved[4];
3620 + __le16 reserved16;
3621 + __le32 reserved32;
3622 + __le64 reserved[3];
3623 struct btrfs_timespec atime;
3624 struct btrfs_timespec ctime;
3625 struct btrfs_timespec mtime;
3626 @@ -1193,6 +1196,8 @@ struct btrfs_root {
3627 #define BTRFS_MOUNT_DISCARD (1 << 10)
3628 #define BTRFS_MOUNT_FORCE_COMPRESS (1 << 11)
3630 +#define BTRFS_MOUNT_TAGGED (1 << 24)
3632 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
3633 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
3634 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
3635 @@ -1413,6 +1418,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
3636 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
3637 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
3638 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
3639 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
3640 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
3641 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
3642 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
3643 @@ -1474,6 +1480,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
3645 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
3647 +#define BTRFS_INODE_IXUNLINK (1 << 24)
3648 +#define BTRFS_INODE_BARRIER (1 << 25)
3649 +#define BTRFS_INODE_COW (1 << 26)
3652 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
3654 @@ -2432,6 +2442,7 @@ extern const struct dentry_operations bt
3655 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
3656 void btrfs_update_iflags(struct inode *inode);
3657 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
3658 +int btrfs_sync_flags(struct inode *inode, int, int);
3661 int btrfs_sync_file(struct file *file, int datasync);
3662 diff -NurpP --minimal linux-2.6.35/fs/btrfs/disk-io.c linux-2.6.35-vs2.3.0.36.31/fs/btrfs/disk-io.c
3663 --- linux-2.6.35/fs/btrfs/disk-io.c 2010-08-02 16:52:47.000000000 +0200
3664 +++ linux-2.6.35-vs2.3.0.36.31/fs/btrfs/disk-io.c 2010-08-02 17:05:05.000000000 +0200
3665 @@ -1707,6 +1707,9 @@ struct btrfs_root *open_ctree(struct sup
3669 + if (btrfs_test_opt(tree_root, TAGGED))
3670 + sb->s_flags |= MS_TAGGED;
3672 features = btrfs_super_incompat_flags(disk_super) &
3673 ~BTRFS_FEATURE_INCOMPAT_SUPP;
3675 diff -NurpP --minimal linux-2.6.35/fs/btrfs/inode.c linux-2.6.35-vs2.3.0.36.31/fs/btrfs/inode.c
3676 --- linux-2.6.35/fs/btrfs/inode.c 2010-08-02 16:52:47.000000000 +0200
3677 +++ linux-2.6.35-vs2.3.0.36.31/fs/btrfs/inode.c 2010-08-02 17:05:05.000000000 +0200
3679 #include <linux/posix_acl.h>
3680 #include <linux/falloc.h>
3681 #include <linux/slab.h>
3682 +#include <linux/vs_tag.h>
3686 #include "disk-io.h"
3687 @@ -2415,6 +2417,8 @@ static void btrfs_read_locked_inode(stru
3689 u64 alloc_group_block;
3695 path = btrfs_alloc_path();
3696 @@ -2431,8 +2435,13 @@ static void btrfs_read_locked_inode(stru
3698 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
3699 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
3700 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
3701 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
3703 + uid = btrfs_inode_uid(leaf, inode_item);
3704 + gid = btrfs_inode_gid(leaf, inode_item);
3705 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3706 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3707 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3708 + btrfs_inode_tag(leaf, inode_item));
3709 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
3711 tspec = btrfs_inode_atime(inode_item);
3712 @@ -2514,8 +2523,15 @@ static void fill_inode_item(struct btrfs
3713 struct btrfs_inode_item *item,
3714 struct inode *inode)
3716 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
3717 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
3718 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3719 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3721 + btrfs_set_inode_uid(leaf, item, uid);
3722 + btrfs_set_inode_gid(leaf, item, gid);
3723 +#ifdef CONFIG_TAGGING_INTERN
3724 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
3727 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
3728 btrfs_set_inode_mode(leaf, item, inode->i_mode);
3729 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
3730 @@ -6940,6 +6956,7 @@ static const struct inode_operations btr
3731 .listxattr = btrfs_listxattr,
3732 .removexattr = btrfs_removexattr,
3733 .permission = btrfs_permission,
3734 + .sync_flags = btrfs_sync_flags,
3736 static const struct inode_operations btrfs_dir_ro_inode_operations = {
3737 .lookup = btrfs_lookup,
3738 @@ -7015,6 +7032,7 @@ static const struct inode_operations btr
3739 .permission = btrfs_permission,
3740 .fallocate = btrfs_fallocate,
3741 .fiemap = btrfs_fiemap,
3742 + .sync_flags = btrfs_sync_flags,
3744 static const struct inode_operations btrfs_special_inode_operations = {
3745 .getattr = btrfs_getattr,
3746 diff -NurpP --minimal linux-2.6.35/fs/btrfs/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/btrfs/ioctl.c
3747 --- linux-2.6.35/fs/btrfs/ioctl.c 2010-08-02 16:52:47.000000000 +0200
3748 +++ linux-2.6.35-vs2.3.0.36.31/fs/btrfs/ioctl.c 2010-08-02 17:05:05.000000000 +0200
3749 @@ -68,10 +68,13 @@ static unsigned int btrfs_flags_to_ioctl
3751 unsigned int iflags = 0;
3753 - if (flags & BTRFS_INODE_SYNC)
3754 - iflags |= FS_SYNC_FL;
3755 if (flags & BTRFS_INODE_IMMUTABLE)
3756 iflags |= FS_IMMUTABLE_FL;
3757 + if (flags & BTRFS_INODE_IXUNLINK)
3758 + iflags |= FS_IXUNLINK_FL;
3760 + if (flags & BTRFS_INODE_SYNC)
3761 + iflags |= FS_SYNC_FL;
3762 if (flags & BTRFS_INODE_APPEND)
3763 iflags |= FS_APPEND_FL;
3764 if (flags & BTRFS_INODE_NODUMP)
3765 @@ -81,28 +84,78 @@ static unsigned int btrfs_flags_to_ioctl
3766 if (flags & BTRFS_INODE_DIRSYNC)
3767 iflags |= FS_DIRSYNC_FL;
3769 + if (flags & BTRFS_INODE_BARRIER)
3770 + iflags |= FS_BARRIER_FL;
3771 + if (flags & BTRFS_INODE_COW)
3772 + iflags |= FS_COW_FL;
3777 - * Update inode->i_flags based on the btrfs internal flags.
3778 + * Update inode->i_(v)flags based on the btrfs internal flags.
3780 void btrfs_update_iflags(struct inode *inode)
3782 struct btrfs_inode *ip = BTRFS_I(inode);
3784 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3785 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3786 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3788 - if (ip->flags & BTRFS_INODE_SYNC)
3789 - inode->i_flags |= S_SYNC;
3790 if (ip->flags & BTRFS_INODE_IMMUTABLE)
3791 inode->i_flags |= S_IMMUTABLE;
3792 + if (ip->flags & BTRFS_INODE_IXUNLINK)
3793 + inode->i_flags |= S_IXUNLINK;
3795 + if (ip->flags & BTRFS_INODE_SYNC)
3796 + inode->i_flags |= S_SYNC;
3797 if (ip->flags & BTRFS_INODE_APPEND)
3798 inode->i_flags |= S_APPEND;
3799 if (ip->flags & BTRFS_INODE_NOATIME)
3800 inode->i_flags |= S_NOATIME;
3801 if (ip->flags & BTRFS_INODE_DIRSYNC)
3802 inode->i_flags |= S_DIRSYNC;
3804 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3806 + if (ip->flags & BTRFS_INODE_BARRIER)
3807 + inode->i_vflags |= V_BARRIER;
3808 + if (ip->flags & BTRFS_INODE_COW)
3809 + inode->i_vflags |= V_COW;
3813 + * Update btrfs internal flags from inode->i_(v)flags.
3815 +void btrfs_update_flags(struct inode *inode)
3817 + struct btrfs_inode *ip = BTRFS_I(inode);
3819 + unsigned int flags = inode->i_flags;
3820 + unsigned int vflags = inode->i_vflags;
3822 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
3823 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
3824 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
3825 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
3827 + if (flags & S_IMMUTABLE)
3828 + ip->flags |= BTRFS_INODE_IMMUTABLE;
3829 + if (flags & S_IXUNLINK)
3830 + ip->flags |= BTRFS_INODE_IXUNLINK;
3832 + if (flags & S_SYNC)
3833 + ip->flags |= BTRFS_INODE_SYNC;
3834 + if (flags & S_APPEND)
3835 + ip->flags |= BTRFS_INODE_APPEND;
3836 + if (flags & S_NOATIME)
3837 + ip->flags |= BTRFS_INODE_NOATIME;
3838 + if (flags & S_DIRSYNC)
3839 + ip->flags |= BTRFS_INODE_DIRSYNC;
3841 + if (vflags & V_BARRIER)
3842 + ip->flags |= BTRFS_INODE_BARRIER;
3843 + if (vflags & V_COW)
3844 + ip->flags |= BTRFS_INODE_COW;
3848 @@ -120,7 +173,7 @@ void btrfs_inherit_iflags(struct inode *
3849 flags = BTRFS_I(dir)->flags;
3851 if (S_ISREG(inode->i_mode))
3852 - flags &= ~BTRFS_INODE_DIRSYNC;
3853 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
3854 else if (!S_ISDIR(inode->i_mode))
3855 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
3857 @@ -128,6 +181,30 @@ void btrfs_inherit_iflags(struct inode *
3858 btrfs_update_iflags(inode);
3861 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
3863 + struct btrfs_inode *ip = BTRFS_I(inode);
3864 + struct btrfs_root *root = ip->root;
3865 + struct btrfs_trans_handle *trans;
3868 + trans = btrfs_join_transaction(root, 1);
3871 + inode->i_flags = flags;
3872 + inode->i_vflags = vflags;
3873 + btrfs_update_flags(inode);
3875 + ret = btrfs_update_inode(trans, root, inode);
3878 + btrfs_update_iflags(inode);
3879 + inode->i_ctime = CURRENT_TIME;
3880 + btrfs_end_transaction(trans, root);
3885 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
3887 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
3888 @@ -150,6 +227,7 @@ static int btrfs_ioctl_setflags(struct f
3889 if (copy_from_user(&flags, arg, sizeof(flags)))
3892 + /* maybe add FS_IXUNLINK_FL ? */
3893 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
3894 FS_NOATIME_FL | FS_NODUMP_FL | \
3895 FS_SYNC_FL | FS_DIRSYNC_FL))
3896 @@ -162,7 +240,8 @@ static int btrfs_ioctl_setflags(struct f
3898 flags = btrfs_mask_flags(inode->i_mode, flags);
3899 oldflags = btrfs_flags_to_ioctl(ip->flags);
3900 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
3901 + if ((flags ^ oldflags) & (FS_APPEND_FL |
3902 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
3903 if (!capable(CAP_LINUX_IMMUTABLE)) {
3906 @@ -173,14 +252,19 @@ static int btrfs_ioctl_setflags(struct f
3910 - if (flags & FS_SYNC_FL)
3911 - ip->flags |= BTRFS_INODE_SYNC;
3913 - ip->flags &= ~BTRFS_INODE_SYNC;
3914 if (flags & FS_IMMUTABLE_FL)
3915 ip->flags |= BTRFS_INODE_IMMUTABLE;
3917 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
3918 + if (flags & FS_IXUNLINK_FL)
3919 + ip->flags |= BTRFS_INODE_IXUNLINK;
3921 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
3923 + if (flags & FS_SYNC_FL)
3924 + ip->flags |= BTRFS_INODE_SYNC;
3926 + ip->flags &= ~BTRFS_INODE_SYNC;
3927 if (flags & FS_APPEND_FL)
3928 ip->flags |= BTRFS_INODE_APPEND;
3930 diff -NurpP --minimal linux-2.6.35/fs/btrfs/super.c linux-2.6.35-vs2.3.0.36.31/fs/btrfs/super.c
3931 --- linux-2.6.35/fs/btrfs/super.c 2010-08-02 16:52:47.000000000 +0200
3932 +++ linux-2.6.35-vs2.3.0.36.31/fs/btrfs/super.c 2010-08-02 17:05:05.000000000 +0200
3933 @@ -68,7 +68,7 @@ enum {
3934 Opt_nodatacow, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, Opt_ssd,
3935 Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress,
3936 Opt_compress_force, Opt_notreelog, Opt_ratio, Opt_flushoncommit,
3937 - Opt_discard, Opt_err,
3938 + Opt_tag, Opt_notag, Opt_tagid, Opt_discard, Opt_err,
3941 static match_table_t tokens = {
3942 @@ -92,6 +92,9 @@ static match_table_t tokens = {
3943 {Opt_flushoncommit, "flushoncommit"},
3944 {Opt_ratio, "metadata_ratio=%d"},
3945 {Opt_discard, "discard"},
3947 + {Opt_notag, "notag"},
3948 + {Opt_tagid, "tagid=%u"},
3952 @@ -235,6 +238,22 @@ int btrfs_parse_options(struct btrfs_roo
3954 btrfs_set_opt(info->mount_opt, DISCARD);
3956 +#ifndef CONFIG_TAGGING_NONE
3958 + printk(KERN_INFO "btrfs: use tagging\n");
3959 + btrfs_set_opt(info->mount_opt, TAGGED);
3962 + printk(KERN_INFO "btrfs: disabled tagging\n");
3963 + btrfs_clear_opt(info->mount_opt, TAGGED);
3966 +#ifdef CONFIG_PROPAGATE
3969 + btrfs_set_opt(info->mount_opt, TAGGED);
3973 printk(KERN_INFO "btrfs: unrecognized mount option "
3975 @@ -681,6 +700,12 @@ static int btrfs_remount(struct super_bl
3979 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
3980 + printk("btrfs: %s: tagging not permitted on remount.\n",
3985 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
3988 diff -NurpP --minimal linux-2.6.35/fs/char_dev.c linux-2.6.35-vs2.3.0.36.31/fs/char_dev.c
3989 --- linux-2.6.35/fs/char_dev.c 2009-12-03 20:02:51.000000000 +0100
3990 +++ linux-2.6.35-vs2.3.0.36.31/fs/char_dev.c 2010-08-02 17:05:05.000000000 +0200
3992 #include <linux/cdev.h>
3993 #include <linux/mutex.h>
3994 #include <linux/backing-dev.h>
3995 +#include <linux/vs_context.h>
3996 +#include <linux/vs_device.h>
3998 #include "internal.h"
4000 @@ -368,14 +370,21 @@ static int chrdev_open(struct inode *ino
4002 struct cdev *new = NULL;
4006 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
4008 + inode->i_mdev = mdev;
4010 spin_lock(&cdev_lock);
4013 struct kobject *kobj;
4016 spin_unlock(&cdev_lock);
4017 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
4019 + kobj = kobj_lookup(cdev_map, mdev, &idx);
4022 new = container_of(kobj, struct cdev, kobj);
4023 diff -NurpP --minimal linux-2.6.35/fs/dcache.c linux-2.6.35-vs2.3.0.36.31/fs/dcache.c
4024 --- linux-2.6.35/fs/dcache.c 2010-08-02 16:52:48.000000000 +0200
4025 +++ linux-2.6.35-vs2.3.0.36.31/fs/dcache.c 2010-08-02 17:05:05.000000000 +0200
4027 #include <linux/bootmem.h>
4028 #include <linux/fs_struct.h>
4029 #include <linux/hardirq.h>
4030 +#include <linux/vs_limit.h>
4031 #include "internal.h"
4033 int sysctl_vfs_cache_pressure __read_mostly = 100;
4034 @@ -230,6 +231,8 @@ repeat:
4038 + vx_dentry_dec(dentry);
4041 * AV: ->d_delete() is _NOT_ allowed to block now.
4043 @@ -323,6 +326,7 @@ static inline struct dentry * __dget_loc
4045 atomic_inc(&dentry->d_count);
4046 dentry_lru_del_init(dentry);
4047 + vx_dentry_inc(dentry);
4051 @@ -926,6 +930,9 @@ struct dentry *d_alloc(struct dentry * p
4052 struct dentry *dentry;
4055 + if (!vx_dentry_avail(1))
4058 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
4061 @@ -971,6 +978,7 @@ struct dentry *d_alloc(struct dentry * p
4063 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
4064 dentry_stat.nr_dentry++;
4065 + vx_dentry_inc(dentry);
4066 spin_unlock(&dcache_lock);
4069 @@ -1420,6 +1428,7 @@ struct dentry * __d_lookup(struct dentry
4072 atomic_inc(&dentry->d_count);
4073 + vx_dentry_inc(dentry);
4075 spin_unlock(&dentry->d_lock);
4077 diff -NurpP --minimal linux-2.6.35/fs/devpts/inode.c linux-2.6.35-vs2.3.0.36.31/fs/devpts/inode.c
4078 --- linux-2.6.35/fs/devpts/inode.c 2010-08-02 16:52:48.000000000 +0200
4079 +++ linux-2.6.35-vs2.3.0.36.31/fs/devpts/inode.c 2010-08-02 17:05:05.000000000 +0200
4081 #include <linux/parser.h>
4082 #include <linux/fsnotify.h>
4083 #include <linux/seq_file.h>
4084 +#include <linux/vs_base.h>
4086 #define DEVPTS_DEFAULT_MODE 0600
4089 #define DEVPTS_DEFAULT_PTMX_MODE 0000
4090 #define PTMX_MINOR 2
4092 +static int devpts_permission(struct inode *inode, int mask)
4094 + int ret = -EACCES;
4096 + /* devpts is xid tagged */
4097 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
4098 + ret = generic_permission(inode, mask, NULL);
4102 +static struct inode_operations devpts_file_inode_operations = {
4103 + .permission = devpts_permission,
4106 extern int pty_limit; /* Config limit on Unix98 ptys */
4107 static DEFINE_MUTEX(allocated_ptys_lock);
4109 @@ -263,6 +278,25 @@ static int devpts_show_options(struct se
4113 +static int devpts_filter(struct dentry *de)
4115 + /* devpts is xid tagged */
4116 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
4119 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
4121 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
4124 +static struct file_operations devpts_dir_operations = {
4125 + .open = dcache_dir_open,
4126 + .release = dcache_dir_close,
4127 + .llseek = dcache_dir_lseek,
4128 + .read = generic_read_dir,
4129 + .readdir = devpts_readdir,
4132 static const struct super_operations devpts_sops = {
4133 .statfs = simple_statfs,
4134 .remount_fs = devpts_remount,
4135 @@ -302,12 +336,15 @@ devpts_fill_super(struct super_block *s,
4136 inode = new_inode(s);
4141 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4142 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
4143 inode->i_op = &simple_dir_inode_operations;
4144 - inode->i_fop = &simple_dir_operations;
4145 + inode->i_fop = &devpts_dir_operations;
4147 + /* devpts is xid tagged */
4148 + inode->i_tag = (tag_t)vx_current_xid();
4150 s->s_root = d_alloc_root(inode);
4152 @@ -495,6 +532,9 @@ int devpts_pty_new(struct inode *ptmx_in
4153 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
4154 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4155 init_special_inode(inode, S_IFCHR|opts->mode, device);
4156 + /* devpts is xid tagged */
4157 + inode->i_tag = (tag_t)vx_current_xid();
4158 + inode->i_op = &devpts_file_inode_operations;
4159 inode->i_private = tty;
4160 tty->driver_data = inode;
4162 diff -NurpP --minimal linux-2.6.35/fs/exec.c linux-2.6.35-vs2.3.0.36.31/fs/exec.c
4163 --- linux-2.6.35/fs/exec.c 2010-08-02 16:52:48.000000000 +0200
4164 +++ linux-2.6.35-vs2.3.0.36.31/fs/exec.c 2010-08-02 17:05:05.000000000 +0200
4165 @@ -1506,7 +1506,7 @@ static int format_corename(char *corenam
4166 /* UNIX time of coredump */
4169 - do_gettimeofday(&tv);
4170 + vx_gettimeofday(&tv);
4171 rc = snprintf(out_ptr, out_end - out_ptr,
4173 if (rc > out_end - out_ptr)
4174 diff -NurpP --minimal linux-2.6.35/fs/ext2/balloc.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/balloc.c
4175 --- linux-2.6.35/fs/ext2/balloc.c 2010-08-02 16:52:48.000000000 +0200
4176 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/balloc.c 2010-08-02 17:05:05.000000000 +0200
4177 @@ -702,7 +702,6 @@ ext2_try_to_allocate(struct super_block
4179 end = EXT2_BLOCKS_PER_GROUP(sb);
4182 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
4185 diff -NurpP --minimal linux-2.6.35/fs/ext2/ext2.h linux-2.6.35-vs2.3.0.36.31/fs/ext2/ext2.h
4186 --- linux-2.6.35/fs/ext2/ext2.h 2010-08-02 16:52:48.000000000 +0200
4187 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/ext2.h 2010-08-02 17:05:05.000000000 +0200
4188 @@ -130,6 +130,7 @@ extern int ext2_fiemap(struct inode *ino
4189 int __ext2_write_begin(struct file *file, struct address_space *mapping,
4190 loff_t pos, unsigned len, unsigned flags,
4191 struct page **pagep, void **fsdata);
4192 +extern int ext2_sync_flags(struct inode *, int, int);
4195 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
4196 diff -NurpP --minimal linux-2.6.35/fs/ext2/file.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/file.c
4197 --- linux-2.6.35/fs/ext2/file.c 2010-08-02 16:52:48.000000000 +0200
4198 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/file.c 2010-08-02 17:05:05.000000000 +0200
4199 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
4200 .setattr = ext2_setattr,
4201 .check_acl = ext2_check_acl,
4202 .fiemap = ext2_fiemap,
4203 + .sync_flags = ext2_sync_flags,
4205 diff -NurpP --minimal linux-2.6.35/fs/ext2/ialloc.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/ialloc.c
4206 --- linux-2.6.35/fs/ext2/ialloc.c 2010-08-02 16:52:48.000000000 +0200
4207 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/ialloc.c 2010-08-02 18:15:12.000000000 +0200
4209 #include <linux/backing-dev.h>
4210 #include <linux/buffer_head.h>
4211 #include <linux/random.h>
4212 +#include <linux/vs_tag.h>
4216 @@ -553,6 +554,7 @@ got:
4217 inode->i_mode = mode;
4218 inode->i_uid = current_fsuid();
4219 inode->i_gid = dir->i_gid;
4220 + inode->i_tag = dx_current_fstag(sb);
4222 inode_init_owner(inode, dir, mode);
4224 diff -NurpP --minimal linux-2.6.35/fs/ext2/inode.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/inode.c
4225 --- linux-2.6.35/fs/ext2/inode.c 2010-08-02 16:52:48.000000000 +0200
4226 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/inode.c 2010-08-02 17:05:05.000000000 +0200
4228 #include <linux/mpage.h>
4229 #include <linux/fiemap.h>
4230 #include <linux/namei.h>
4231 +#include <linux/vs_tag.h>
4235 @@ -1164,7 +1165,7 @@ static void ext2_truncate_blocks(struct
4237 if (ext2_inode_is_fast_symlink(inode))
4239 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4240 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4242 __ext2_truncate_blocks(inode, offset);
4244 @@ -1261,36 +1262,61 @@ void ext2_set_inode_flags(struct inode *
4246 unsigned int flags = EXT2_I(inode)->i_flags;
4248 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4249 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4250 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4253 + if (flags & EXT2_IMMUTABLE_FL)
4254 + inode->i_flags |= S_IMMUTABLE;
4255 + if (flags & EXT2_IXUNLINK_FL)
4256 + inode->i_flags |= S_IXUNLINK;
4258 if (flags & EXT2_SYNC_FL)
4259 inode->i_flags |= S_SYNC;
4260 if (flags & EXT2_APPEND_FL)
4261 inode->i_flags |= S_APPEND;
4262 - if (flags & EXT2_IMMUTABLE_FL)
4263 - inode->i_flags |= S_IMMUTABLE;
4264 if (flags & EXT2_NOATIME_FL)
4265 inode->i_flags |= S_NOATIME;
4266 if (flags & EXT2_DIRSYNC_FL)
4267 inode->i_flags |= S_DIRSYNC;
4269 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4271 + if (flags & EXT2_BARRIER_FL)
4272 + inode->i_vflags |= V_BARRIER;
4273 + if (flags & EXT2_COW_FL)
4274 + inode->i_vflags |= V_COW;
4277 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
4278 void ext2_get_inode_flags(struct ext2_inode_info *ei)
4280 unsigned int flags = ei->vfs_inode.i_flags;
4281 + unsigned int vflags = ei->vfs_inode.i_vflags;
4283 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
4284 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
4285 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
4286 + EXT2_BARRIER_FL | EXT2_COW_FL);
4288 + if (flags & S_IMMUTABLE)
4289 + ei->i_flags |= EXT2_IMMUTABLE_FL;
4290 + if (flags & S_IXUNLINK)
4291 + ei->i_flags |= EXT2_IXUNLINK_FL;
4293 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
4294 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
4296 ei->i_flags |= EXT2_SYNC_FL;
4297 if (flags & S_APPEND)
4298 ei->i_flags |= EXT2_APPEND_FL;
4299 - if (flags & S_IMMUTABLE)
4300 - ei->i_flags |= EXT2_IMMUTABLE_FL;
4301 if (flags & S_NOATIME)
4302 ei->i_flags |= EXT2_NOATIME_FL;
4303 if (flags & S_DIRSYNC)
4304 ei->i_flags |= EXT2_DIRSYNC_FL;
4306 + if (vflags & V_BARRIER)
4307 + ei->i_flags |= EXT2_BARRIER_FL;
4308 + if (vflags & V_COW)
4309 + ei->i_flags |= EXT2_COW_FL;
4312 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
4313 @@ -1300,6 +1326,8 @@ struct inode *ext2_iget (struct super_bl
4314 struct ext2_inode *raw_inode;
4315 struct inode *inode;
4321 inode = iget_locked(sb, ino);
4322 @@ -1318,12 +1346,17 @@ struct inode *ext2_iget (struct super_bl
4325 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4326 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4327 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4328 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4329 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4330 if (!(test_opt (inode->i_sb, NO_UID32))) {
4331 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4332 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4333 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4334 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4336 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4337 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4338 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4339 + le16_to_cpu(raw_inode->i_raw_tag));
4341 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4342 inode->i_size = le32_to_cpu(raw_inode->i_size);
4343 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4344 @@ -1421,8 +1454,8 @@ static int __ext2_write_inode(struct ino
4345 struct ext2_inode_info *ei = EXT2_I(inode);
4346 struct super_block *sb = inode->i_sb;
4347 ino_t ino = inode->i_ino;
4348 - uid_t uid = inode->i_uid;
4349 - gid_t gid = inode->i_gid;
4350 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4351 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4352 struct buffer_head * bh;
4353 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
4355 @@ -1458,6 +1491,9 @@ static int __ext2_write_inode(struct ino
4356 raw_inode->i_uid_high = 0;
4357 raw_inode->i_gid_high = 0;
4359 +#ifdef CONFIG_TAGGING_INTERN
4360 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4362 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4363 raw_inode->i_size = cpu_to_le32(inode->i_size);
4364 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4365 @@ -1547,7 +1583,8 @@ int ext2_setattr(struct dentry *dentry,
4366 if (is_quota_modification(inode, iattr))
4367 dquot_initialize(inode);
4368 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4369 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4370 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4371 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4372 error = dquot_transfer(inode, iattr);
4375 diff -NurpP --minimal linux-2.6.35/fs/ext2/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/ioctl.c
4376 --- linux-2.6.35/fs/ext2/ioctl.c 2009-09-10 15:26:21.000000000 +0200
4377 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/ioctl.c 2010-08-02 17:05:05.000000000 +0200
4379 #include <asm/uaccess.h>
4382 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
4384 + inode->i_flags = flags;
4385 + inode->i_vflags = vflags;
4386 + ext2_get_inode_flags(EXT2_I(inode));
4387 + inode->i_ctime = CURRENT_TIME_SEC;
4388 + mark_inode_dirty(inode);
4392 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4394 struct inode *inode = filp->f_dentry->d_inode;
4395 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
4397 flags = ext2_mask_flags(inode->i_mode, flags);
4399 + if (IS_BARRIER(inode)) {
4400 + vxwprintk_task(1, "messing with the barrier.");
4404 mutex_lock(&inode->i_mutex);
4405 /* Is it quota file? Do not allow user to mess with it */
4406 if (IS_NOQUOTA(inode)) {
4407 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
4409 * This test looks nicer. Thanks to Pauline Middelink
4411 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
4412 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
4413 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
4414 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
4415 if (!capable(CAP_LINUX_IMMUTABLE)) {
4416 mutex_unlock(&inode->i_mutex);
4418 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
4422 - flags = flags & EXT2_FL_USER_MODIFIABLE;
4423 + flags &= EXT2_FL_USER_MODIFIABLE;
4424 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
4425 ei->i_flags = flags;
4426 mutex_unlock(&inode->i_mutex);
4427 diff -NurpP --minimal linux-2.6.35/fs/ext2/namei.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/namei.c
4428 --- linux-2.6.35/fs/ext2/namei.c 2010-07-07 18:31:51.000000000 +0200
4429 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/namei.c 2010-08-02 17:05:05.000000000 +0200
4432 #include <linux/pagemap.h>
4433 #include <linux/quotaops.h>
4434 +#include <linux/vs_tag.h>
4438 @@ -75,6 +76,7 @@ static struct dentry *ext2_lookup(struct
4439 return ERR_PTR(-EIO);
4441 return ERR_CAST(inode);
4442 + dx_propagate_tag(nd, inode);
4446 @@ -418,6 +420,7 @@ const struct inode_operations ext2_dir_i
4448 .setattr = ext2_setattr,
4449 .check_acl = ext2_check_acl,
4450 + .sync_flags = ext2_sync_flags,
4453 const struct inode_operations ext2_special_inode_operations = {
4454 diff -NurpP --minimal linux-2.6.35/fs/ext2/super.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/super.c
4455 --- linux-2.6.35/fs/ext2/super.c 2010-08-02 16:52:48.000000000 +0200
4456 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/super.c 2010-08-02 17:05:05.000000000 +0200
4457 @@ -390,7 +390,8 @@ enum {
4458 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
4459 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
4460 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
4461 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
4462 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
4463 + Opt_tag, Opt_notag, Opt_tagid
4466 static const match_table_t tokens = {
4467 @@ -418,6 +419,9 @@ static const match_table_t tokens = {
4469 {Opt_noacl, "noacl"},
4472 + {Opt_notag, "notag"},
4473 + {Opt_tagid, "tagid=%u"},
4474 {Opt_grpquota, "grpquota"},
4475 {Opt_ignore, "noquota"},
4476 {Opt_quota, "quota"},
4477 @@ -488,6 +492,20 @@ static int parse_options(char *options,
4479 set_opt (sbi->s_mount_opt, NO_UID32);
4481 +#ifndef CONFIG_TAGGING_NONE
4483 + set_opt (sbi->s_mount_opt, TAGGED);
4486 + clear_opt (sbi->s_mount_opt, TAGGED);
4489 +#ifdef CONFIG_PROPAGATE
4492 + set_opt (sbi->s_mount_opt, TAGGED);
4496 clear_opt (sbi->s_mount_opt, CHECK);
4498 @@ -845,6 +863,8 @@ static int ext2_fill_super(struct super_
4499 if (!parse_options((char *) data, sb))
4502 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
4503 + sb->s_flags |= MS_TAGGED;
4504 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4505 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
4507 @@ -1217,6 +1237,14 @@ static int ext2_remount (struct super_bl
4511 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
4512 + !(sb->s_flags & MS_TAGGED)) {
4513 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
4516 + goto restore_opts;
4519 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4520 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4522 diff -NurpP --minimal linux-2.6.35/fs/ext3/file.c linux-2.6.35-vs2.3.0.36.31/fs/ext3/file.c
4523 --- linux-2.6.35/fs/ext3/file.c 2010-07-07 18:31:51.000000000 +0200
4524 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext3/file.c 2010-08-02 17:05:05.000000000 +0200
4525 @@ -81,5 +81,6 @@ const struct inode_operations ext3_file_
4527 .check_acl = ext3_check_acl,
4528 .fiemap = ext3_fiemap,
4529 + .sync_flags = ext3_sync_flags,
4532 diff -NurpP --minimal linux-2.6.35/fs/ext3/ialloc.c linux-2.6.35-vs2.3.0.36.31/fs/ext3/ialloc.c
4533 --- linux-2.6.35/fs/ext3/ialloc.c 2010-08-02 16:52:48.000000000 +0200
4534 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext3/ialloc.c 2010-08-02 18:14:48.000000000 +0200
4536 #include <linux/buffer_head.h>
4537 #include <linux/random.h>
4538 #include <linux/bitops.h>
4539 +#include <linux/vs_tag.h>
4541 #include <asm/byteorder.h>
4543 @@ -543,6 +544,7 @@ got:
4544 inode->i_mode = mode;
4545 inode->i_uid = current_fsuid();
4546 inode->i_gid = dir->i_gid;
4547 + inode->i_tag = dx_current_fstag(sb);
4549 inode_init_owner(inode, dir, mode);
4551 diff -NurpP --minimal linux-2.6.35/fs/ext3/inode.c linux-2.6.35-vs2.3.0.36.31/fs/ext3/inode.c
4552 --- linux-2.6.35/fs/ext3/inode.c 2010-08-02 16:52:48.000000000 +0200
4553 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext3/inode.c 2010-08-02 17:05:05.000000000 +0200
4555 #include <linux/bio.h>
4556 #include <linux/fiemap.h>
4557 #include <linux/namei.h>
4558 +#include <linux/vs_tag.h>
4562 @@ -2354,7 +2355,7 @@ static void ext3_free_branches(handle_t
4564 int ext3_can_truncate(struct inode *inode)
4566 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4567 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4569 if (S_ISREG(inode->i_mode))
4571 @@ -2739,36 +2740,60 @@ void ext3_set_inode_flags(struct inode *
4573 unsigned int flags = EXT3_I(inode)->i_flags;
4575 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4576 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4577 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4579 + if (flags & EXT3_IMMUTABLE_FL)
4580 + inode->i_flags |= S_IMMUTABLE;
4581 + if (flags & EXT3_IXUNLINK_FL)
4582 + inode->i_flags |= S_IXUNLINK;
4584 if (flags & EXT3_SYNC_FL)
4585 inode->i_flags |= S_SYNC;
4586 if (flags & EXT3_APPEND_FL)
4587 inode->i_flags |= S_APPEND;
4588 - if (flags & EXT3_IMMUTABLE_FL)
4589 - inode->i_flags |= S_IMMUTABLE;
4590 if (flags & EXT3_NOATIME_FL)
4591 inode->i_flags |= S_NOATIME;
4592 if (flags & EXT3_DIRSYNC_FL)
4593 inode->i_flags |= S_DIRSYNC;
4595 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4597 + if (flags & EXT3_BARRIER_FL)
4598 + inode->i_vflags |= V_BARRIER;
4599 + if (flags & EXT3_COW_FL)
4600 + inode->i_vflags |= V_COW;
4603 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
4604 void ext3_get_inode_flags(struct ext3_inode_info *ei)
4606 unsigned int flags = ei->vfs_inode.i_flags;
4607 + unsigned int vflags = ei->vfs_inode.i_vflags;
4609 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
4610 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
4611 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
4612 + EXT3_BARRIER_FL | EXT3_COW_FL);
4614 + if (flags & S_IMMUTABLE)
4615 + ei->i_flags |= EXT3_IMMUTABLE_FL;
4616 + if (flags & S_IXUNLINK)
4617 + ei->i_flags |= EXT3_IXUNLINK_FL;
4619 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
4620 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
4622 ei->i_flags |= EXT3_SYNC_FL;
4623 if (flags & S_APPEND)
4624 ei->i_flags |= EXT3_APPEND_FL;
4625 - if (flags & S_IMMUTABLE)
4626 - ei->i_flags |= EXT3_IMMUTABLE_FL;
4627 if (flags & S_NOATIME)
4628 ei->i_flags |= EXT3_NOATIME_FL;
4629 if (flags & S_DIRSYNC)
4630 ei->i_flags |= EXT3_DIRSYNC_FL;
4632 + if (vflags & V_BARRIER)
4633 + ei->i_flags |= EXT3_BARRIER_FL;
4634 + if (vflags & V_COW)
4635 + ei->i_flags |= EXT3_COW_FL;
4638 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
4639 @@ -2782,6 +2807,8 @@ struct inode *ext3_iget(struct super_blo
4640 transaction_t *transaction;
4646 inode = iget_locked(sb, ino);
4648 @@ -2798,12 +2825,17 @@ struct inode *ext3_iget(struct super_blo
4650 raw_inode = ext3_raw_inode(&iloc);
4651 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4652 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4653 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4654 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4655 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4656 if(!(test_opt (inode->i_sb, NO_UID32))) {
4657 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4658 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4659 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4660 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4662 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4663 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4664 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4665 + le16_to_cpu(raw_inode->i_raw_tag));
4667 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4668 inode->i_size = le32_to_cpu(raw_inode->i_size);
4669 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4670 @@ -2958,6 +2990,8 @@ static int ext3_do_update_inode(handle_t
4671 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
4672 struct ext3_inode_info *ei = EXT3_I(inode);
4673 struct buffer_head *bh = iloc->bh;
4674 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4675 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4676 int err = 0, rc, block;
4679 @@ -2972,29 +3006,32 @@ again:
4680 ext3_get_inode_flags(ei);
4681 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4682 if(!(test_opt(inode->i_sb, NO_UID32))) {
4683 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4684 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4685 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4686 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4688 * Fix up interoperability with old kernels. Otherwise, old inodes get
4689 * re-used with the upper 16 bits of the uid/gid intact
4692 raw_inode->i_uid_high =
4693 - cpu_to_le16(high_16_bits(inode->i_uid));
4694 + cpu_to_le16(high_16_bits(uid));
4695 raw_inode->i_gid_high =
4696 - cpu_to_le16(high_16_bits(inode->i_gid));
4697 + cpu_to_le16(high_16_bits(gid));
4699 raw_inode->i_uid_high = 0;
4700 raw_inode->i_gid_high = 0;
4703 raw_inode->i_uid_low =
4704 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
4705 + cpu_to_le16(fs_high2lowuid(uid));
4706 raw_inode->i_gid_low =
4707 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4708 + cpu_to_le16(fs_high2lowgid(gid));
4709 raw_inode->i_uid_high = 0;
4710 raw_inode->i_gid_high = 0;
4712 +#ifdef CONFIG_TAGGING_INTERN
4713 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4715 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4716 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4717 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4718 @@ -3154,7 +3191,8 @@ int ext3_setattr(struct dentry *dentry,
4719 if (is_quota_modification(inode, attr))
4720 dquot_initialize(inode);
4721 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4722 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4723 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4724 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4727 /* (user+group)*(old+new) structure, inode write (sb,
4728 @@ -3176,6 +3214,8 @@ int ext3_setattr(struct dentry *dentry,
4729 inode->i_uid = attr->ia_uid;
4730 if (attr->ia_valid & ATTR_GID)
4731 inode->i_gid = attr->ia_gid;
4732 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4733 + inode->i_tag = attr->ia_tag;
4734 error = ext3_mark_inode_dirty(handle, inode);
4735 ext3_journal_stop(handle);
4737 diff -NurpP --minimal linux-2.6.35/fs/ext3/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/ext3/ioctl.c
4738 --- linux-2.6.35/fs/ext3/ioctl.c 2009-06-11 17:13:03.000000000 +0200
4739 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext3/ioctl.c 2010-08-02 17:05:05.000000000 +0200
4743 #include <linux/fs.h>
4744 +#include <linux/mount.h>
4745 #include <linux/jbd.h>
4746 #include <linux/capability.h>
4747 #include <linux/ext3_fs.h>
4749 #include <linux/compat.h>
4750 #include <asm/uaccess.h>
4753 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
4755 + handle_t *handle = NULL;
4756 + struct ext3_iloc iloc;
4759 + handle = ext3_journal_start(inode, 1);
4760 + if (IS_ERR(handle))
4761 + return PTR_ERR(handle);
4763 + if (IS_SYNC(inode))
4764 + handle->h_sync = 1;
4765 + err = ext3_reserve_inode_write(handle, inode, &iloc);
4769 + inode->i_flags = flags;
4770 + inode->i_vflags = vflags;
4771 + ext3_get_inode_flags(EXT3_I(inode));
4772 + inode->i_ctime = CURRENT_TIME_SEC;
4774 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
4776 + ext3_journal_stop(handle);
4780 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4782 struct inode *inode = filp->f_dentry->d_inode;
4783 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
4785 flags = ext3_mask_flags(inode->i_mode, flags);
4787 + if (IS_BARRIER(inode)) {
4788 + vxwprintk_task(1, "messing with the barrier.");
4792 mutex_lock(&inode->i_mutex);
4794 /* Is it quota file? Do not allow user to mess with it */
4795 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
4797 * This test looks nicer. Thanks to Pauline Middelink
4799 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
4800 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
4801 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
4802 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
4803 if (!capable(CAP_LINUX_IMMUTABLE))
4806 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
4810 - flags = flags & EXT3_FL_USER_MODIFIABLE;
4811 + flags &= EXT3_FL_USER_MODIFIABLE;
4812 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
4813 ei->i_flags = flags;
4815 diff -NurpP --minimal linux-2.6.35/fs/ext3/namei.c linux-2.6.35-vs2.3.0.36.31/fs/ext3/namei.c
4816 --- linux-2.6.35/fs/ext3/namei.c 2010-07-07 18:31:51.000000000 +0200
4817 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext3/namei.c 2010-08-02 17:05:05.000000000 +0200
4819 #include <linux/quotaops.h>
4820 #include <linux/buffer_head.h>
4821 #include <linux/bio.h>
4822 +#include <linux/vs_tag.h>
4826 @@ -912,6 +913,7 @@ restart:
4828 ll_rw_block(READ_META, 1, &bh);
4830 + dx_propagate_tag(nd, inode);
4832 if ((bh = bh_use[ra_ptr++]) == NULL)
4834 @@ -2466,6 +2468,7 @@ const struct inode_operations ext3_dir_i
4835 .removexattr = generic_removexattr,
4837 .check_acl = ext3_check_acl,
4838 + .sync_flags = ext3_sync_flags,
4841 const struct inode_operations ext3_special_inode_operations = {
4842 diff -NurpP --minimal linux-2.6.35/fs/ext3/super.c linux-2.6.35-vs2.3.0.36.31/fs/ext3/super.c
4843 --- linux-2.6.35/fs/ext3/super.c 2010-08-02 16:52:48.000000000 +0200
4844 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext3/super.c 2010-08-02 18:14:19.000000000 +0200
4845 @@ -817,7 +817,8 @@ enum {
4846 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4847 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
4848 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
4849 - Opt_resize, Opt_usrquota, Opt_grpquota
4850 + Opt_resize, Opt_usrquota, Opt_grpquota,
4851 + Opt_tag, Opt_notag, Opt_tagid
4854 static const match_table_t tokens = {
4855 @@ -874,6 +875,9 @@ static const match_table_t tokens = {
4856 {Opt_barrier, "barrier"},
4857 {Opt_nobarrier, "nobarrier"},
4858 {Opt_resize, "resize"},
4860 + {Opt_notag, "notag"},
4861 + {Opt_tagid, "tagid=%u"},
4865 @@ -1026,6 +1030,20 @@ static int parse_options (char *options,
4867 set_opt (sbi->s_mount_opt, NO_UID32);
4869 +#ifndef CONFIG_TAGGING_NONE
4871 + set_opt (sbi->s_mount_opt, TAGGED);
4874 + clear_opt (sbi->s_mount_opt, TAGGED);
4877 +#ifdef CONFIG_PROPAGATE
4880 + set_opt (sbi->s_mount_opt, TAGGED);
4884 clear_opt (sbi->s_mount_opt, CHECK);
4886 @@ -1712,6 +1730,9 @@ static int ext3_fill_super (struct super
4890 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
4891 + sb->s_flags |= MS_TAGGED;
4893 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4894 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
4896 @@ -2585,6 +2606,14 @@ static int ext3_remount (struct super_bl
4897 if (test_opt(sb, ABORT))
4898 ext3_abort(sb, __func__, "Abort forced by user");
4900 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
4901 + !(sb->s_flags & MS_TAGGED)) {
4902 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
4905 + goto restore_opts;
4908 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4909 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
4911 diff -NurpP --minimal linux-2.6.35/fs/ext4/ext4.h linux-2.6.35-vs2.3.0.36.31/fs/ext4/ext4.h
4912 --- linux-2.6.35/fs/ext4/ext4.h 2010-08-02 16:52:48.000000000 +0200
4913 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/ext4.h 2010-08-02 17:05:05.000000000 +0200
4914 @@ -318,8 +318,12 @@ struct flex_groups {
4915 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
4916 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
4917 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
4918 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4919 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
4921 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4922 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
4924 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
4925 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
4927 @@ -588,7 +592,8 @@ struct ext4_inode {
4928 __le16 l_i_file_acl_high;
4929 __le16 l_i_uid_high; /* these 2 fields */
4930 __le16 l_i_gid_high; /* were reserved2[0] */
4931 - __u32 l_i_reserved2;
4932 + __le16 l_i_tag; /* Context Tag */
4933 + __u16 l_i_reserved2;
4936 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
4937 @@ -702,6 +707,7 @@ do { \
4938 #define i_gid_low i_gid
4939 #define i_uid_high osd2.linux2.l_i_uid_high
4940 #define i_gid_high osd2.linux2.l_i_gid_high
4941 +#define i_raw_tag osd2.linux2.l_i_tag
4942 #define i_reserved2 osd2.linux2.l_i_reserved2
4944 #elif defined(__GNU__)
4945 @@ -881,6 +887,7 @@ struct ext4_inode_info {
4946 #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
4947 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
4948 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
4949 +#define EXT4_MOUNT_TAGGED 0x4000000 /* Enable Context Tags */
4950 #define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */
4951 #define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000 /* Abort on file data write */
4952 #define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000 /* Block validity checking */
4953 @@ -1910,6 +1917,7 @@ extern int ext4_get_blocks(handle_t *han
4954 struct buffer_head *bh, int flags);
4955 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4956 __u64 start, __u64 len);
4957 +extern int ext4_sync_flags(struct inode *, int, int);
4959 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
4960 __u64 start_orig, __u64 start_donor,
4961 diff -NurpP --minimal linux-2.6.35/fs/ext4/file.c linux-2.6.35-vs2.3.0.36.31/fs/ext4/file.c
4962 --- linux-2.6.35/fs/ext4/file.c 2010-08-02 16:52:48.000000000 +0200
4963 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/file.c 2010-08-02 17:05:05.000000000 +0200
4964 @@ -160,5 +160,6 @@ const struct inode_operations ext4_file_
4965 .check_acl = ext4_check_acl,
4966 .fallocate = ext4_fallocate,
4967 .fiemap = ext4_fiemap,
4968 + .sync_flags = ext4_sync_flags,
4971 diff -NurpP --minimal linux-2.6.35/fs/ext4/ialloc.c linux-2.6.35-vs2.3.0.36.31/fs/ext4/ialloc.c
4972 --- linux-2.6.35/fs/ext4/ialloc.c 2010-08-02 16:52:48.000000000 +0200
4973 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/ialloc.c 2010-08-02 18:12:48.000000000 +0200
4975 #include <linux/random.h>
4976 #include <linux/bitops.h>
4977 #include <linux/blkdev.h>
4978 +#include <linux/vs_tag.h>
4979 #include <asm/byteorder.h>
4982 @@ -976,6 +977,7 @@ got:
4983 inode->i_mode = mode;
4984 inode->i_uid = current_fsuid();
4985 inode->i_gid = dir->i_gid;
4986 + inode->i_tag = dx_current_fstag(sb);
4988 inode_init_owner(inode, dir, mode);
4990 diff -NurpP --minimal linux-2.6.35/fs/ext4/inode.c linux-2.6.35-vs2.3.0.36.31/fs/ext4/inode.c
4991 --- linux-2.6.35/fs/ext4/inode.c 2010-08-02 16:52:48.000000000 +0200
4992 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/inode.c 2010-08-02 18:11:10.000000000 +0200
4994 #include <linux/workqueue.h>
4995 #include <linux/kernel.h>
4996 #include <linux/slab.h>
4997 +#include <linux/vs_tag.h>
4999 #include "ext4_jbd2.h"
5001 @@ -4575,7 +4576,7 @@ static void ext4_free_branches(handle_t
5003 int ext4_can_truncate(struct inode *inode)
5005 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5006 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5008 if (S_ISREG(inode->i_mode))
5010 @@ -4926,41 +4927,64 @@ void ext4_set_inode_flags(struct inode *
5012 unsigned int flags = EXT4_I(inode)->i_flags;
5014 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
5015 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5016 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5018 + if (flags & EXT4_IMMUTABLE_FL)
5019 + inode->i_flags |= S_IMMUTABLE;
5020 + if (flags & EXT4_IXUNLINK_FL)
5021 + inode->i_flags |= S_IXUNLINK;
5023 if (flags & EXT4_SYNC_FL)
5024 inode->i_flags |= S_SYNC;
5025 if (flags & EXT4_APPEND_FL)
5026 inode->i_flags |= S_APPEND;
5027 - if (flags & EXT4_IMMUTABLE_FL)
5028 - inode->i_flags |= S_IMMUTABLE;
5029 if (flags & EXT4_NOATIME_FL)
5030 inode->i_flags |= S_NOATIME;
5031 if (flags & EXT4_DIRSYNC_FL)
5032 inode->i_flags |= S_DIRSYNC;
5034 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5036 + if (flags & EXT4_BARRIER_FL)
5037 + inode->i_vflags |= V_BARRIER;
5038 + if (flags & EXT4_COW_FL)
5039 + inode->i_vflags |= V_COW;
5042 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
5043 void ext4_get_inode_flags(struct ext4_inode_info *ei)
5045 - unsigned int vfs_fl;
5046 + unsigned int vfs_fl, vfs_vf;
5047 unsigned long old_fl, new_fl;
5050 vfs_fl = ei->vfs_inode.i_flags;
5051 + vfs_vf = ei->vfs_inode.i_vflags;
5052 old_fl = ei->i_flags;
5053 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
5054 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
5056 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
5059 + if (vfs_fl & S_IMMUTABLE)
5060 + new_fl |= EXT4_IMMUTABLE_FL;
5061 + if (vfs_fl & S_IXUNLINK)
5062 + new_fl |= EXT4_IXUNLINK_FL;
5064 if (vfs_fl & S_SYNC)
5065 new_fl |= EXT4_SYNC_FL;
5066 if (vfs_fl & S_APPEND)
5067 new_fl |= EXT4_APPEND_FL;
5068 - if (vfs_fl & S_IMMUTABLE)
5069 - new_fl |= EXT4_IMMUTABLE_FL;
5070 if (vfs_fl & S_NOATIME)
5071 new_fl |= EXT4_NOATIME_FL;
5072 if (vfs_fl & S_DIRSYNC)
5073 new_fl |= EXT4_DIRSYNC_FL;
5075 + if (vfs_vf & V_BARRIER)
5076 + new_fl |= EXT4_BARRIER_FL;
5077 + if (vfs_vf & V_COW)
5078 + new_fl |= EXT4_COW_FL;
5079 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
5082 @@ -4996,6 +5020,8 @@ struct inode *ext4_iget(struct super_blo
5083 journal_t *journal = EXT4_SB(sb)->s_journal;
5089 inode = iget_locked(sb, ino);
5091 @@ -5011,12 +5037,16 @@ struct inode *ext4_iget(struct super_blo
5093 raw_inode = ext4_raw_inode(&iloc);
5094 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
5095 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
5096 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
5097 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
5098 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
5099 if (!(test_opt(inode->i_sb, NO_UID32))) {
5100 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
5101 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
5102 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
5103 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
5105 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5106 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5107 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5108 + le16_to_cpu(raw_inode->i_raw_tag));
5109 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
5111 ei->i_state_flags = 0;
5112 @@ -5235,6 +5265,8 @@ static int ext4_do_update_inode(handle_t
5113 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
5114 struct ext4_inode_info *ei = EXT4_I(inode);
5115 struct buffer_head *bh = iloc->bh;
5116 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5117 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5118 int err = 0, rc, block;
5120 /* For fields not not tracking in the in-memory inode,
5121 @@ -5245,29 +5277,32 @@ static int ext4_do_update_inode(handle_t
5122 ext4_get_inode_flags(ei);
5123 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
5124 if (!(test_opt(inode->i_sb, NO_UID32))) {
5125 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
5126 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
5127 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
5128 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
5130 * Fix up interoperability with old kernels. Otherwise, old inodes get
5131 * re-used with the upper 16 bits of the uid/gid intact
5134 raw_inode->i_uid_high =
5135 - cpu_to_le16(high_16_bits(inode->i_uid));
5136 + cpu_to_le16(high_16_bits(uid));
5137 raw_inode->i_gid_high =
5138 - cpu_to_le16(high_16_bits(inode->i_gid));
5139 + cpu_to_le16(high_16_bits(gid));
5141 raw_inode->i_uid_high = 0;
5142 raw_inode->i_gid_high = 0;
5145 raw_inode->i_uid_low =
5146 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
5147 + cpu_to_le16(fs_high2lowuid(uid));
5148 raw_inode->i_gid_low =
5149 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
5150 + cpu_to_le16(fs_high2lowgid(gid));
5151 raw_inode->i_uid_high = 0;
5152 raw_inode->i_gid_high = 0;
5154 +#ifdef CONFIG_TAGGING_INTERN
5155 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
5157 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
5159 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
5160 @@ -5453,7 +5488,8 @@ int ext4_setattr(struct dentry *dentry,
5161 if (is_quota_modification(inode, attr))
5162 dquot_initialize(inode);
5163 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
5164 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
5165 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
5166 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
5169 /* (user+group)*(old+new) structure, inode write (sb,
5170 @@ -5475,6 +5511,8 @@ int ext4_setattr(struct dentry *dentry,
5171 inode->i_uid = attr->ia_uid;
5172 if (attr->ia_valid & ATTR_GID)
5173 inode->i_gid = attr->ia_gid;
5174 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5175 + inode->i_tag = attr->ia_tag;
5176 error = ext4_mark_inode_dirty(handle, inode);
5177 ext4_journal_stop(handle);
5179 diff -NurpP --minimal linux-2.6.35/fs/ext4/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/ext4/ioctl.c
5180 --- linux-2.6.35/fs/ext4/ioctl.c 2010-08-02 16:52:48.000000000 +0200
5181 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/ioctl.c 2010-08-02 17:05:05.000000000 +0200
5183 #include <linux/compat.h>
5184 #include <linux/mount.h>
5185 #include <linux/file.h>
5186 +#include <linux/vs_tag.h>
5187 #include <asm/uaccess.h>
5188 #include "ext4_jbd2.h"
5192 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
5194 + handle_t *handle = NULL;
5195 + struct ext4_iloc iloc;
5198 + handle = ext4_journal_start(inode, 1);
5199 + if (IS_ERR(handle))
5200 + return PTR_ERR(handle);
5202 + if (IS_SYNC(inode))
5203 + ext4_handle_sync(handle);
5204 + err = ext4_reserve_inode_write(handle, inode, &iloc);
5208 + inode->i_flags = flags;
5209 + inode->i_vflags = vflags;
5210 + ext4_get_inode_flags(EXT4_I(inode));
5211 + inode->i_ctime = ext4_current_time(inode);
5213 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
5215 + ext4_journal_stop(handle);
5219 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5221 struct inode *inode = filp->f_dentry->d_inode;
5222 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
5224 flags = ext4_mask_flags(inode->i_mode, flags);
5226 + if (IS_BARRIER(inode)) {
5227 + vxwprintk_task(1, "messing with the barrier.");
5232 mutex_lock(&inode->i_mutex);
5233 /* Is it quota file? Do not allow user to mess with it */
5234 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
5236 * This test looks nicer. Thanks to Pauline Middelink
5238 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
5239 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
5240 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
5241 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
5242 if (!capable(CAP_LINUX_IMMUTABLE))
5245 diff -NurpP --minimal linux-2.6.35/fs/ext4/namei.c linux-2.6.35-vs2.3.0.36.31/fs/ext4/namei.c
5246 --- linux-2.6.35/fs/ext4/namei.c 2010-08-02 16:52:48.000000000 +0200
5247 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/namei.c 2010-08-02 17:05:05.000000000 +0200
5249 #include <linux/quotaops.h>
5250 #include <linux/buffer_head.h>
5251 #include <linux/bio.h>
5252 +#include <linux/vs_tag.h>
5254 #include "ext4_jbd2.h"
5256 @@ -937,6 +938,7 @@ restart:
5258 ll_rw_block(READ_META, 1, &bh);
5260 + dx_propagate_tag(nd, inode);
5262 if ((bh = bh_use[ra_ptr++]) == NULL)
5264 @@ -2550,6 +2552,7 @@ const struct inode_operations ext4_dir_i
5266 .check_acl = ext4_check_acl,
5267 .fiemap = ext4_fiemap,
5268 + .sync_flags = ext4_sync_flags,
5271 const struct inode_operations ext4_special_inode_operations = {
5272 diff -NurpP --minimal linux-2.6.35/fs/ext4/super.c linux-2.6.35-vs2.3.0.36.31/fs/ext4/super.c
5273 --- linux-2.6.35/fs/ext4/super.c 2010-08-02 16:52:49.000000000 +0200
5274 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/super.c 2010-08-02 17:05:05.000000000 +0200
5275 @@ -1161,6 +1161,7 @@ enum {
5276 Opt_inode_readahead_blks, Opt_journal_ioprio,
5277 Opt_dioread_nolock, Opt_dioread_lock,
5278 Opt_discard, Opt_nodiscard,
5279 + Opt_tag, Opt_notag, Opt_tagid
5282 static const match_table_t tokens = {
5283 @@ -1231,6 +1232,9 @@ static const match_table_t tokens = {
5284 {Opt_dioread_lock, "dioread_lock"},
5285 {Opt_discard, "discard"},
5286 {Opt_nodiscard, "nodiscard"},
5288 + {Opt_notag, "notag"},
5289 + {Opt_tagid, "tagid=%u"},
5293 @@ -1399,6 +1403,20 @@ static int parse_options(char *options,
5295 set_opt(sbi->s_mount_opt, NO_UID32);
5297 +#ifndef CONFIG_TAGGING_NONE
5299 + set_opt (sbi->s_mount_opt, TAGGED);
5302 + clear_opt (sbi->s_mount_opt, TAGGED);
5305 +#ifdef CONFIG_PROPAGATE
5308 + set_opt (sbi->s_mount_opt, TAGGED);
5312 set_opt(sbi->s_mount_opt, DEBUG);
5314 @@ -2566,6 +2584,9 @@ static int ext4_fill_super(struct super_
5315 &journal_ioprio, NULL, 0))
5318 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
5319 + sb->s_flags |= MS_TAGGED;
5321 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5322 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5324 @@ -3618,6 +3639,14 @@ static int ext4_remount(struct super_blo
5325 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
5326 ext4_abort(sb, __func__, "Abort forced by user");
5328 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
5329 + !(sb->s_flags & MS_TAGGED)) {
5330 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
5333 + goto restore_opts;
5336 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5337 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5339 diff -NurpP --minimal linux-2.6.35/fs/fcntl.c linux-2.6.35-vs2.3.0.36.31/fs/fcntl.c
5340 --- linux-2.6.35/fs/fcntl.c 2010-08-02 16:52:49.000000000 +0200
5341 +++ linux-2.6.35-vs2.3.0.36.31/fs/fcntl.c 2010-08-02 17:05:06.000000000 +0200
5343 #include <linux/signal.h>
5344 #include <linux/rcupdate.h>
5345 #include <linux/pid_namespace.h>
5346 +#include <linux/vs_limit.h>
5348 #include <asm/poll.h>
5349 #include <asm/siginfo.h>
5350 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
5353 filp_close(tofree, files);
5355 + vx_openfd_inc(newfd); /* fd was unused */
5359 @@ -434,6 +437,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
5363 + if (!vx_files_avail(1))
5366 err = security_file_fcntl(filp, cmd, arg);
5368 diff -NurpP --minimal linux-2.6.35/fs/file.c linux-2.6.35-vs2.3.0.36.31/fs/file.c
5369 --- linux-2.6.35/fs/file.c 2010-07-07 18:31:51.000000000 +0200
5370 +++ linux-2.6.35-vs2.3.0.36.31/fs/file.c 2010-08-02 17:05:06.000000000 +0200
5372 #include <linux/spinlock.h>
5373 #include <linux/rcupdate.h>
5374 #include <linux/workqueue.h>
5375 +#include <linux/vs_limit.h>
5377 struct fdtable_defer {
5379 @@ -368,6 +369,8 @@ struct files_struct *dup_fd(struct files
5380 struct file *f = *old_fds++;
5383 + /* TODO: sum it first for check and performance */
5384 + vx_openfd_inc(open_files - i);
5387 * The fd may be claimed in the fd bitmap but not yet
5388 @@ -476,6 +479,7 @@ repeat:
5390 FD_CLR(fd, fdt->close_on_exec);
5392 + vx_openfd_inc(fd);
5395 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
5396 diff -NurpP --minimal linux-2.6.35/fs/file_table.c linux-2.6.35-vs2.3.0.36.31/fs/file_table.c
5397 --- linux-2.6.35/fs/file_table.c 2010-08-02 16:52:49.000000000 +0200
5398 +++ linux-2.6.35-vs2.3.0.36.31/fs/file_table.c 2010-08-02 17:05:06.000000000 +0200
5400 #include <linux/sysctl.h>
5401 #include <linux/percpu_counter.h>
5402 #include <linux/ima.h>
5403 +#include <linux/vs_limit.h>
5404 +#include <linux/vs_context.h>
5406 #include <asm/atomic.h>
5408 @@ -133,6 +135,8 @@ struct file *get_empty_filp(void)
5409 spin_lock_init(&f->f_lock);
5410 eventpoll_init_file(f);
5411 /* f->f_version: 0 */
5412 + f->f_xid = vx_current_xid();
5417 @@ -249,6 +253,8 @@ static void __fput(struct file *file)
5418 cdev_put(inode->i_cdev);
5419 fops_put(file->f_op);
5420 put_pid(file->f_owner.pid);
5421 + vx_files_dec(file);
5424 if (file->f_mode & FMODE_WRITE)
5425 drop_file_write_access(file);
5426 @@ -324,6 +330,8 @@ void put_filp(struct file *file)
5428 if (atomic_long_dec_and_test(&file->f_count)) {
5429 security_file_free(file);
5430 + vx_files_dec(file);
5435 diff -NurpP --minimal linux-2.6.35/fs/fs_struct.c linux-2.6.35-vs2.3.0.36.31/fs/fs_struct.c
5436 --- linux-2.6.35/fs/fs_struct.c 2009-06-11 17:13:04.000000000 +0200
5437 +++ linux-2.6.35-vs2.3.0.36.31/fs/fs_struct.c 2010-08-02 17:05:06.000000000 +0200
5439 #include <linux/path.h>
5440 #include <linux/slab.h>
5441 #include <linux/fs_struct.h>
5442 +#include <linux/vserver/global.h>
5445 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
5446 @@ -77,6 +78,7 @@ void free_fs_struct(struct fs_struct *fs
5448 path_put(&fs->root);
5450 + atomic_dec(&vs_global_fs);
5451 kmem_cache_free(fs_cachep, fs);
5454 @@ -112,6 +114,7 @@ struct fs_struct *copy_fs_struct(struct
5456 path_get(&old->pwd);
5457 read_unlock(&old->lock);
5458 + atomic_inc(&vs_global_fs);
5462 diff -NurpP --minimal linux-2.6.35/fs/gfs2/file.c linux-2.6.35-vs2.3.0.36.31/fs/gfs2/file.c
5463 --- linux-2.6.35/fs/gfs2/file.c 2010-08-02 16:52:49.000000000 +0200
5464 +++ linux-2.6.35-vs2.3.0.36.31/fs/gfs2/file.c 2010-08-02 17:05:06.000000000 +0200
5465 @@ -132,6 +132,9 @@ static const u32 fsflags_to_gfs2[32] = {
5466 [7] = GFS2_DIF_NOATIME,
5467 [12] = GFS2_DIF_EXHASH,
5468 [14] = GFS2_DIF_INHERIT_JDATA,
5469 + [27] = GFS2_DIF_IXUNLINK,
5470 + [26] = GFS2_DIF_BARRIER,
5471 + [29] = GFS2_DIF_COW,
5474 static const u32 gfs2_to_fsflags[32] = {
5475 @@ -141,6 +144,9 @@ static const u32 gfs2_to_fsflags[32] = {
5476 [gfs2fl_NoAtime] = FS_NOATIME_FL,
5477 [gfs2fl_ExHash] = FS_INDEX_FL,
5478 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
5479 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
5480 + [gfs2fl_Barrier] = FS_BARRIER_FL,
5481 + [gfs2fl_Cow] = FS_COW_FL,
5484 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
5485 @@ -171,10 +177,16 @@ void gfs2_set_inode_flags(struct inode *
5487 struct gfs2_inode *ip = GFS2_I(inode);
5488 unsigned int flags = inode->i_flags;
5489 + unsigned int vflags = inode->i_vflags;
5491 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5492 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5494 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
5495 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
5496 flags |= S_IMMUTABLE;
5497 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
5498 + flags |= S_IXUNLINK;
5500 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
5502 if (ip->i_diskflags & GFS2_DIF_NOATIME)
5503 @@ -182,6 +194,43 @@ void gfs2_set_inode_flags(struct inode *
5504 if (ip->i_diskflags & GFS2_DIF_SYNC)
5506 inode->i_flags = flags;
5508 + vflags &= ~(V_BARRIER | V_COW);
5510 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
5511 + vflags |= V_BARRIER;
5512 + if (ip->i_diskflags & GFS2_DIF_COW)
5514 + inode->i_vflags = vflags;
5517 +void gfs2_get_inode_flags(struct inode *inode)
5519 + struct gfs2_inode *ip = GFS2_I(inode);
5520 + unsigned int flags = inode->i_flags;
5521 + unsigned int vflags = inode->i_vflags;
5523 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
5524 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
5525 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
5526 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
5528 + if (flags & S_IMMUTABLE)
5529 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
5530 + if (flags & S_IXUNLINK)
5531 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
5533 + if (flags & S_APPEND)
5534 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
5535 + if (flags & S_NOATIME)
5536 + ip->i_diskflags |= GFS2_DIF_NOATIME;
5537 + if (flags & S_SYNC)
5538 + ip->i_diskflags |= GFS2_DIF_SYNC;
5540 + if (vflags & V_BARRIER)
5541 + ip->i_diskflags |= GFS2_DIF_BARRIER;
5542 + if (vflags & V_COW)
5543 + ip->i_diskflags |= GFS2_DIF_COW;
5546 /* Flags that can be set by user space */
5547 @@ -293,6 +342,37 @@ static int gfs2_set_flags(struct file *f
5548 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
5551 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
5553 + struct gfs2_inode *ip = GFS2_I(inode);
5554 + struct gfs2_sbd *sdp = GFS2_SB(inode);
5555 + struct buffer_head *bh;
5556 + struct gfs2_holder gh;
5559 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
5562 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
5565 + error = gfs2_meta_inode_buffer(ip, &bh);
5567 + goto out_trans_end;
5568 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
5569 + inode->i_flags = flags;
5570 + inode->i_vflags = vflags;
5571 + gfs2_get_inode_flags(inode);
5572 + gfs2_dinode_out(ip, bh->b_data);
5574 + gfs2_set_aops(inode);
5576 + gfs2_trans_end(sdp);
5578 + gfs2_glock_dq_uninit(&gh);
5582 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5585 diff -NurpP --minimal linux-2.6.35/fs/gfs2/inode.h linux-2.6.35-vs2.3.0.36.31/fs/gfs2/inode.h
5586 --- linux-2.6.35/fs/gfs2/inode.h 2010-08-02 16:52:49.000000000 +0200
5587 +++ linux-2.6.35-vs2.3.0.36.31/fs/gfs2/inode.h 2010-08-02 17:05:06.000000000 +0200
5588 @@ -109,6 +109,7 @@ extern const struct file_operations gfs2
5589 extern const struct file_operations gfs2_dir_fops_nolock;
5591 extern void gfs2_set_inode_flags(struct inode *inode);
5592 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
5594 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
5595 extern const struct file_operations gfs2_file_fops;
5596 diff -NurpP --minimal linux-2.6.35/fs/gfs2/ops_inode.c linux-2.6.35-vs2.3.0.36.31/fs/gfs2/ops_inode.c
5597 --- linux-2.6.35/fs/gfs2/ops_inode.c 2010-08-02 16:52:49.000000000 +0200
5598 +++ linux-2.6.35-vs2.3.0.36.31/fs/gfs2/ops_inode.c 2010-08-02 17:05:06.000000000 +0200
5599 @@ -1346,6 +1346,7 @@ const struct inode_operations gfs2_file_
5600 .listxattr = gfs2_listxattr,
5601 .removexattr = gfs2_removexattr,
5602 .fiemap = gfs2_fiemap,
5603 + .sync_flags = gfs2_sync_flags,
5606 const struct inode_operations gfs2_dir_iops = {
5607 @@ -1366,6 +1367,7 @@ const struct inode_operations gfs2_dir_i
5608 .listxattr = gfs2_listxattr,
5609 .removexattr = gfs2_removexattr,
5610 .fiemap = gfs2_fiemap,
5611 + .sync_flags = gfs2_sync_flags,
5614 const struct inode_operations gfs2_symlink_iops = {
5615 diff -NurpP --minimal linux-2.6.35/fs/hfsplus/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/hfsplus/ioctl.c
5616 --- linux-2.6.35/fs/hfsplus/ioctl.c 2010-08-02 16:52:49.000000000 +0200
5617 +++ linux-2.6.35-vs2.3.0.36.31/fs/hfsplus/ioctl.c 2010-08-02 17:48:55.000000000 +0200
5619 #include <linux/sched.h>
5620 #include <linux/xattr.h>
5621 #include <linux/smp_lock.h>
5622 +// #include <linux/mount.h>
5623 #include <asm/uaccess.h>
5624 #include "hfsplus_fs.h"
5626 diff -NurpP --minimal linux-2.6.35/fs/inode.c linux-2.6.35-vs2.3.0.36.31/fs/inode.c
5627 --- linux-2.6.35/fs/inode.c 2010-08-02 16:52:49.000000000 +0200
5628 +++ linux-2.6.35-vs2.3.0.36.31/fs/inode.c 2010-08-02 19:08:57.000000000 +0200
5630 #include <linux/mount.h>
5631 #include <linux/async.h>
5632 #include <linux/posix_acl.h>
5633 +#include <linux/vs_tag.h>
5636 * This is needed for the following functions:
5637 @@ -131,6 +132,9 @@ int inode_init_always(struct super_block
5638 struct address_space *const mapping = &inode->i_data;
5642 + /* essential because of inode slab reuse */
5644 inode->i_blkbits = sb->s_blocksize_bits;
5646 atomic_set(&inode->i_count, 1);
5647 @@ -151,6 +155,7 @@ int inode_init_always(struct super_block
5648 inode->i_bdev = NULL;
5649 inode->i_cdev = NULL;
5651 + inode->i_mdev = 0;
5652 inode->dirtied_when = 0;
5654 if (security_inode_alloc(inode))
5655 @@ -294,6 +299,8 @@ void __iget(struct inode *inode)
5656 inodes_stat.nr_unused--;
5659 +EXPORT_SYMBOL_GPL(__iget);
5662 * clear_inode - clear an inode
5663 * @inode: inode to clear
5664 @@ -1593,9 +1600,11 @@ void init_special_inode(struct inode *in
5665 if (S_ISCHR(mode)) {
5666 inode->i_fop = &def_chr_fops;
5667 inode->i_rdev = rdev;
5668 + inode->i_mdev = rdev;
5669 } else if (S_ISBLK(mode)) {
5670 inode->i_fop = &def_blk_fops;
5671 inode->i_rdev = rdev;
5672 + inode->i_mdev = rdev;
5673 } else if (S_ISFIFO(mode))
5674 inode->i_fop = &def_fifo_fops;
5675 else if (S_ISSOCK(mode))
5676 @@ -1624,5 +1633,6 @@ void inode_init_owner(struct inode *inod
5678 inode->i_gid = current_fsgid();
5679 inode->i_mode = mode;
5680 + inode->i_tag = dx_current_fstag(inode->i_sb);
5682 EXPORT_SYMBOL(inode_init_owner);
5683 diff -NurpP --minimal linux-2.6.35/fs/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/ioctl.c
5684 --- linux-2.6.35/fs/ioctl.c 2010-08-02 16:52:49.000000000 +0200
5685 +++ linux-2.6.35-vs2.3.0.36.31/fs/ioctl.c 2010-08-02 17:05:06.000000000 +0200
5687 #include <linux/writeback.h>
5688 #include <linux/buffer_head.h>
5689 #include <linux/falloc.h>
5690 +#include <linux/proc_fs.h>
5691 +#include <linux/vserver/inode.h>
5692 +#include <linux/vs_tag.h>
5694 #include <asm/ioctls.h>
5696 diff -NurpP --minimal linux-2.6.35/fs/ioprio.c linux-2.6.35-vs2.3.0.36.31/fs/ioprio.c
5697 --- linux-2.6.35/fs/ioprio.c 2010-07-07 18:31:52.000000000 +0200
5698 +++ linux-2.6.35-vs2.3.0.36.31/fs/ioprio.c 2010-08-02 17:05:06.000000000 +0200
5700 #include <linux/syscalls.h>
5701 #include <linux/security.h>
5702 #include <linux/pid_namespace.h>
5703 +#include <linux/vs_base.h>
5705 int set_task_ioprio(struct task_struct *task, int ioprio)
5707 @@ -124,6 +125,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
5709 pgrp = find_vpid(who);
5710 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5711 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5713 ret = set_task_ioprio(p, ioprio);
5716 @@ -213,6 +216,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
5718 pgrp = find_vpid(who);
5719 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5720 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5722 tmpio = get_task_ioprio(p);
5725 diff -NurpP --minimal linux-2.6.35/fs/jfs/file.c linux-2.6.35-vs2.3.0.36.31/fs/jfs/file.c
5726 --- linux-2.6.35/fs/jfs/file.c 2010-08-02 16:52:49.000000000 +0200
5727 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/file.c 2010-08-02 17:05:06.000000000 +0200
5728 @@ -101,7 +101,8 @@ int jfs_setattr(struct dentry *dentry, s
5729 if (is_quota_modification(inode, iattr))
5730 dquot_initialize(inode);
5731 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
5732 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
5733 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
5734 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
5735 rc = dquot_transfer(inode, iattr);
5738 @@ -125,6 +126,7 @@ const struct inode_operations jfs_file_i
5739 #ifdef CONFIG_JFS_POSIX_ACL
5740 .check_acl = jfs_check_acl,
5742 + .sync_flags = jfs_sync_flags,
5745 const struct file_operations jfs_file_operations = {
5746 diff -NurpP --minimal linux-2.6.35/fs/jfs/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/jfs/ioctl.c
5747 --- linux-2.6.35/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
5748 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/ioctl.c 2010-08-02 17:05:06.000000000 +0200
5750 #include <linux/mount.h>
5751 #include <linux/time.h>
5752 #include <linux/sched.h>
5753 +#include <linux/mount.h>
5754 #include <asm/current.h>
5755 #include <asm/uaccess.h>
5757 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
5761 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
5763 + inode->i_flags = flags;
5764 + inode->i_vflags = vflags;
5765 + jfs_get_inode_flags(JFS_IP(inode));
5766 + inode->i_ctime = CURRENT_TIME_SEC;
5767 + mark_inode_dirty(inode);
5771 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5773 struct inode *inode = filp->f_dentry->d_inode;
5774 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
5775 if (!S_ISDIR(inode->i_mode))
5776 flags &= ~JFS_DIRSYNC_FL;
5778 + if (IS_BARRIER(inode)) {
5779 + vxwprintk_task(1, "messing with the barrier.");
5783 /* Is it quota file? Do not allow user to mess with it */
5784 if (IS_NOQUOTA(inode)) {
5786 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
5787 * the relevant capability.
5789 if ((oldflags & JFS_IMMUTABLE_FL) ||
5790 - ((flags ^ oldflags) &
5791 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
5792 + ((flags ^ oldflags) & (JFS_APPEND_FL |
5793 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
5794 if (!capable(CAP_LINUX_IMMUTABLE)) {
5795 mutex_unlock(&inode->i_mutex);
5797 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
5801 - flags = flags & JFS_FL_USER_MODIFIABLE;
5802 + flags &= JFS_FL_USER_MODIFIABLE;
5803 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
5804 jfs_inode->mode2 = flags;
5806 diff -NurpP --minimal linux-2.6.35/fs/jfs/jfs_dinode.h linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_dinode.h
5807 --- linux-2.6.35/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
5808 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_dinode.h 2010-08-02 17:05:06.000000000 +0200
5809 @@ -161,9 +161,13 @@ struct dinode {
5811 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
5812 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
5813 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
5815 -#define JFS_FL_USER_VISIBLE 0x03F80000
5816 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
5817 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
5818 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
5820 +#define JFS_FL_USER_VISIBLE 0x07F80000
5821 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
5822 #define JFS_FL_INHERIT 0x03C80000
5824 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
5825 diff -NurpP --minimal linux-2.6.35/fs/jfs/jfs_filsys.h linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_filsys.h
5826 --- linux-2.6.35/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
5827 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_filsys.h 2010-08-02 17:05:06.000000000 +0200
5829 #define JFS_NAME_MAX 255
5830 #define JFS_PATH_MAX BPSIZE
5832 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
5835 * file system state (superblock state)
5836 diff -NurpP --minimal linux-2.6.35/fs/jfs/jfs_imap.c linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_imap.c
5837 --- linux-2.6.35/fs/jfs/jfs_imap.c 2010-07-07 18:31:52.000000000 +0200
5838 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_imap.c 2010-08-02 17:05:06.000000000 +0200
5840 #include <linux/pagemap.h>
5841 #include <linux/quotaops.h>
5842 #include <linux/slab.h>
5843 +#include <linux/vs_tag.h>
5845 #include "jfs_incore.h"
5846 #include "jfs_inode.h"
5847 @@ -3060,6 +3061,8 @@ static int copy_from_dinode(struct dinod
5849 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
5850 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
5854 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
5855 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
5856 @@ -3080,14 +3083,18 @@ static int copy_from_dinode(struct dinod
5858 ip->i_nlink = le32_to_cpu(dip->di_nlink);
5860 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
5861 + uid = le32_to_cpu(dip->di_uid);
5862 + gid = le32_to_cpu(dip->di_gid);
5863 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
5865 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
5867 ip->i_uid = jfs_ip->saved_uid;
5869 ip->i_uid = sbi->uid;
5872 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
5873 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
5875 ip->i_gid = jfs_ip->saved_gid;
5877 @@ -3152,14 +3159,12 @@ static void copy_to_dinode(struct dinode
5878 dip->di_size = cpu_to_le64(ip->i_size);
5879 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
5880 dip->di_nlink = cpu_to_le32(ip->i_nlink);
5881 - if (sbi->uid == -1)
5882 - dip->di_uid = cpu_to_le32(ip->i_uid);
5884 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
5885 - if (sbi->gid == -1)
5886 - dip->di_gid = cpu_to_le32(ip->i_gid);
5888 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
5890 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
5891 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
5892 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
5893 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
5895 jfs_get_inode_flags(jfs_ip);
5897 * mode2 is only needed for storing the higher order bits.
5898 diff -NurpP --minimal linux-2.6.35/fs/jfs/jfs_inode.c linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_inode.c
5899 --- linux-2.6.35/fs/jfs/jfs_inode.c 2010-08-02 16:52:49.000000000 +0200
5900 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_inode.c 2010-08-02 17:05:06.000000000 +0200
5903 #include <linux/fs.h>
5904 #include <linux/quotaops.h>
5905 +#include <linux/vs_tag.h>
5906 #include "jfs_incore.h"
5907 #include "jfs_inode.h"
5908 #include "jfs_filsys.h"
5909 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
5911 unsigned int flags = JFS_IP(inode)->mode2;
5913 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
5914 - S_NOATIME | S_DIRSYNC | S_SYNC);
5915 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5916 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5918 if (flags & JFS_IMMUTABLE_FL)
5919 inode->i_flags |= S_IMMUTABLE;
5920 + if (flags & JFS_IXUNLINK_FL)
5921 + inode->i_flags |= S_IXUNLINK;
5923 + if (flags & JFS_SYNC_FL)
5924 + inode->i_flags |= S_SYNC;
5925 if (flags & JFS_APPEND_FL)
5926 inode->i_flags |= S_APPEND;
5927 if (flags & JFS_NOATIME_FL)
5928 inode->i_flags |= S_NOATIME;
5929 if (flags & JFS_DIRSYNC_FL)
5930 inode->i_flags |= S_DIRSYNC;
5931 - if (flags & JFS_SYNC_FL)
5932 - inode->i_flags |= S_SYNC;
5934 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5936 + if (flags & JFS_BARRIER_FL)
5937 + inode->i_vflags |= V_BARRIER;
5938 + if (flags & JFS_COW_FL)
5939 + inode->i_vflags |= V_COW;
5942 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
5944 unsigned int flags = jfs_ip->vfs_inode.i_flags;
5945 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
5947 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
5948 + JFS_APPEND_FL | JFS_NOATIME_FL |
5949 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
5950 + JFS_BARRIER_FL | JFS_COW_FL);
5952 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
5953 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
5954 if (flags & S_IMMUTABLE)
5955 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
5956 + if (flags & S_IXUNLINK)
5957 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
5959 if (flags & S_APPEND)
5960 jfs_ip->mode2 |= JFS_APPEND_FL;
5961 if (flags & S_NOATIME)
5962 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
5963 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
5965 jfs_ip->mode2 |= JFS_SYNC_FL;
5967 + if (vflags & V_BARRIER)
5968 + jfs_ip->mode2 |= JFS_BARRIER_FL;
5969 + if (vflags & V_COW)
5970 + jfs_ip->mode2 |= JFS_COW_FL;
5974 diff -NurpP --minimal linux-2.6.35/fs/jfs/jfs_inode.h linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_inode.h
5975 --- linux-2.6.35/fs/jfs/jfs_inode.h 2010-08-02 16:52:49.000000000 +0200
5976 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_inode.h 2010-08-02 17:05:06.000000000 +0200
5977 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
5978 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
5979 int fh_len, int fh_type);
5980 extern void jfs_set_inode_flags(struct inode *);
5981 +extern int jfs_sync_flags(struct inode *, int, int);
5982 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
5983 extern int jfs_setattr(struct dentry *, struct iattr *);
5985 diff -NurpP --minimal linux-2.6.35/fs/jfs/namei.c linux-2.6.35-vs2.3.0.36.31/fs/jfs/namei.c
5986 --- linux-2.6.35/fs/jfs/namei.c 2010-07-07 18:31:52.000000000 +0200
5987 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/namei.c 2010-08-02 17:05:06.000000000 +0200
5989 #include <linux/ctype.h>
5990 #include <linux/quotaops.h>
5991 #include <linux/exportfs.h>
5992 +#include <linux/vs_tag.h>
5993 #include "jfs_incore.h"
5994 #include "jfs_superblock.h"
5995 #include "jfs_inode.h"
5996 @@ -1491,6 +1492,7 @@ static struct dentry *jfs_lookup(struct
5997 return ERR_CAST(ip);
6000 + dx_propagate_tag(nd, ip);
6001 dentry = d_splice_alias(ip, dentry);
6003 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
6004 @@ -1560,6 +1562,7 @@ const struct inode_operations jfs_dir_in
6005 #ifdef CONFIG_JFS_POSIX_ACL
6006 .check_acl = jfs_check_acl,
6008 + .sync_flags = jfs_sync_flags,
6011 const struct file_operations jfs_dir_operations = {
6012 diff -NurpP --minimal linux-2.6.35/fs/jfs/super.c linux-2.6.35-vs2.3.0.36.31/fs/jfs/super.c
6013 --- linux-2.6.35/fs/jfs/super.c 2010-08-02 16:52:49.000000000 +0200
6014 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/super.c 2010-08-02 17:05:06.000000000 +0200
6015 @@ -200,7 +200,8 @@ static void jfs_put_super(struct super_b
6017 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
6018 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
6019 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
6020 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
6021 + Opt_tag, Opt_notag, Opt_tagid
6024 static const match_table_t tokens = {
6025 @@ -210,6 +211,10 @@ static const match_table_t tokens = {
6026 {Opt_resize, "resize=%u"},
6027 {Opt_resize_nosize, "resize"},
6028 {Opt_errors, "errors=%s"},
6030 + {Opt_notag, "notag"},
6031 + {Opt_tagid, "tagid=%u"},
6032 + {Opt_tag, "tagxid"},
6033 {Opt_ignore, "noquota"},
6034 {Opt_ignore, "quota"},
6035 {Opt_usrquota, "usrquota"},
6036 @@ -344,6 +349,20 @@ static int parse_options(char *options,
6040 +#ifndef CONFIG_TAGGING_NONE
6042 + *flag |= JFS_TAGGED;
6045 + *flag &= JFS_TAGGED;
6048 +#ifdef CONFIG_PROPAGATE
6051 + *flag |= JFS_TAGGED;
6055 printk("jfs: Unrecognized mount option \"%s\" "
6056 " or missing value\n", p);
6057 @@ -374,6 +393,12 @@ static int jfs_remount(struct super_bloc
6058 if (!parse_options(data, sb, &newLVSize, &flag)) {
6061 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
6062 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
6069 if (sb->s_flags & MS_RDONLY) {
6070 @@ -465,6 +490,9 @@ static int jfs_fill_super(struct super_b
6071 #ifdef CONFIG_JFS_POSIX_ACL
6072 sb->s_flags |= MS_POSIXACL;
6074 + /* map mount option tagxid */
6075 + if (sbi->flag & JFS_TAGGED)
6076 + sb->s_flags |= MS_TAGGED;
6079 printk(KERN_ERR "resize option for remount only\n");
6080 diff -NurpP --minimal linux-2.6.35/fs/libfs.c linux-2.6.35-vs2.3.0.36.31/fs/libfs.c
6081 --- linux-2.6.35/fs/libfs.c 2010-08-02 16:52:49.000000000 +0200
6082 +++ linux-2.6.35-vs2.3.0.36.31/fs/libfs.c 2010-08-02 17:05:06.000000000 +0200
6083 @@ -124,7 +124,8 @@ static inline unsigned char dt_type(stru
6084 * both impossible due to the lock on directory.
6087 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
6088 +static inline int do_dcache_readdir_filter(struct file *filp,
6089 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
6091 struct dentry *dentry = filp->f_path.dentry;
6092 struct dentry *cursor = filp->private_data;
6093 @@ -157,6 +158,8 @@ int dcache_readdir(struct file * filp, v
6094 next = list_entry(p, struct dentry, d_u.d_child);
6095 if (d_unhashed(next) || !next->d_inode)
6097 + if (filter && !filter(next))
6100 spin_unlock(&dcache_lock);
6101 if (filldir(dirent, next->d_name.name,
6102 @@ -175,6 +178,18 @@ int dcache_readdir(struct file * filp, v
6106 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
6108 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
6111 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
6112 + int (*filter)(struct dentry *))
6114 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
6118 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
6121 @@ -967,6 +982,7 @@ EXPORT_SYMBOL(dcache_dir_close);
6122 EXPORT_SYMBOL(dcache_dir_lseek);
6123 EXPORT_SYMBOL(dcache_dir_open);
6124 EXPORT_SYMBOL(dcache_readdir);
6125 +EXPORT_SYMBOL(dcache_readdir_filter);
6126 EXPORT_SYMBOL(generic_read_dir);
6127 EXPORT_SYMBOL(get_sb_pseudo);
6128 EXPORT_SYMBOL(simple_write_begin);
6129 diff -NurpP --minimal linux-2.6.35/fs/locks.c linux-2.6.35-vs2.3.0.36.31/fs/locks.c
6130 --- linux-2.6.35/fs/locks.c 2010-07-07 18:31:52.000000000 +0200
6131 +++ linux-2.6.35-vs2.3.0.36.31/fs/locks.c 2010-08-02 17:05:06.000000000 +0200
6133 #include <linux/time.h>
6134 #include <linux/rcupdate.h>
6135 #include <linux/pid_namespace.h>
6136 +#include <linux/vs_base.h>
6137 +#include <linux/vs_limit.h>
6139 #include <asm/uaccess.h>
6141 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
6142 /* Allocate an empty lock structure. */
6143 static struct file_lock *locks_alloc_lock(void)
6145 + if (!vx_locks_avail(1))
6147 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6150 @@ -174,6 +178,7 @@ static void locks_free_lock(struct file_
6151 BUG_ON(!list_empty(&fl->fl_block));
6152 BUG_ON(!list_empty(&fl->fl_link));
6155 locks_release_private(fl);
6156 kmem_cache_free(filelock_cache, fl);
6158 @@ -194,6 +199,7 @@ void locks_init_lock(struct file_lock *f
6159 fl->fl_start = fl->fl_end = 0;
6161 fl->fl_lmops = NULL;
6165 EXPORT_SYMBOL(locks_init_lock);
6166 @@ -248,6 +254,7 @@ void locks_copy_lock(struct file_lock *n
6167 new->fl_file = fl->fl_file;
6168 new->fl_ops = fl->fl_ops;
6169 new->fl_lmops = fl->fl_lmops;
6170 + new->fl_xid = fl->fl_xid;
6172 locks_copy_private(new, fl);
6174 @@ -286,6 +293,11 @@ static int flock_make_lock(struct file *
6175 fl->fl_flags = FL_FLOCK;
6177 fl->fl_end = OFFSET_MAX;
6179 + vxd_assert(filp->f_xid == vx_current_xid(),
6180 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6181 + fl->fl_xid = filp->f_xid;
6186 @@ -451,6 +463,7 @@ static int lease_init(struct file *filp,
6188 fl->fl_owner = current->files;
6189 fl->fl_pid = current->tgid;
6190 + fl->fl_xid = vx_current_xid();
6193 fl->fl_flags = FL_LEASE;
6194 @@ -470,6 +483,11 @@ static struct file_lock *lease_alloc(str
6196 return ERR_PTR(error);
6198 + fl->fl_xid = vx_current_xid();
6200 + vxd_assert(filp->f_xid == fl->fl_xid,
6201 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
6203 error = lease_init(filp, type, fl);
6205 locks_free_lock(fl);
6206 @@ -770,6 +788,7 @@ static int flock_lock_file(struct file *
6210 + new_fl->fl_xid = -1;
6212 for_each_lock(inode, before) {
6213 struct file_lock *fl = *before;
6214 @@ -790,6 +809,7 @@ find_conflict:
6216 locks_copy_lock(new_fl, request);
6217 locks_insert_lock(before, new_fl);
6218 + vx_locks_inc(new_fl);
6222 @@ -800,7 +820,8 @@ out:
6226 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
6227 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
6228 + struct file_lock *conflock, xid_t xid)
6230 struct file_lock *fl;
6231 struct file_lock *new_fl = NULL;
6232 @@ -810,6 +831,8 @@ static int __posix_lock_file(struct inod
6233 struct file_lock **before;
6234 int error, added = 0;
6236 + vxd_assert(xid == vx_current_xid(),
6237 + "xid(%d) == current(%d)", xid, vx_current_xid());
6239 * We may need two file_lock structures for this operation,
6240 * so we get them in advance to avoid races.
6241 @@ -820,7 +843,11 @@ static int __posix_lock_file(struct inod
6242 (request->fl_type != F_UNLCK ||
6243 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
6244 new_fl = locks_alloc_lock();
6245 + new_fl->fl_xid = xid;
6246 + vx_locks_inc(new_fl);
6247 new_fl2 = locks_alloc_lock();
6248 + new_fl2->fl_xid = xid;
6249 + vx_locks_inc(new_fl2);
6253 @@ -1019,7 +1046,8 @@ static int __posix_lock_file(struct inod
6254 int posix_lock_file(struct file *filp, struct file_lock *fl,
6255 struct file_lock *conflock)
6257 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
6258 + return __posix_lock_file(filp->f_path.dentry->d_inode,
6259 + fl, conflock, filp->f_xid);
6261 EXPORT_SYMBOL(posix_lock_file);
6263 @@ -1109,7 +1137,7 @@ int locks_mandatory_area(int read_write,
6264 fl.fl_end = offset + count - 1;
6267 - error = __posix_lock_file(inode, &fl, NULL);
6268 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
6269 if (error != FILE_LOCK_DEFERRED)
6271 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
6272 @@ -1425,6 +1453,7 @@ int generic_setlease(struct file *filp,
6274 locks_copy_lock(new_fl, lease);
6275 locks_insert_lock(before, new_fl);
6276 + vx_locks_inc(new_fl);
6280 @@ -1780,6 +1809,11 @@ int fcntl_setlk(unsigned int fd, struct
6281 if (file_lock == NULL)
6284 + vxd_assert(filp->f_xid == vx_current_xid(),
6285 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6286 + file_lock->fl_xid = filp->f_xid;
6287 + vx_locks_inc(file_lock);
6290 * This might block, so we do it before checking the inode.
6292 @@ -1898,6 +1932,11 @@ int fcntl_setlk64(unsigned int fd, struc
6293 if (file_lock == NULL)
6296 + vxd_assert(filp->f_xid == vx_current_xid(),
6297 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6298 + file_lock->fl_xid = filp->f_xid;
6299 + vx_locks_inc(file_lock);
6302 * This might block, so we do it before checking the inode.
6304 @@ -2163,8 +2202,11 @@ static int locks_show(struct seq_file *f
6306 lock_get_status(f, fl, (long)f->private, "");
6308 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
6309 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
6310 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6312 lock_get_status(f, bfl, (long)f->private, " ->");
6317 diff -NurpP --minimal linux-2.6.35/fs/namei.c linux-2.6.35-vs2.3.0.36.31/fs/namei.c
6318 --- linux-2.6.35/fs/namei.c 2010-08-02 16:52:50.000000000 +0200
6319 +++ linux-2.6.35-vs2.3.0.36.31/fs/namei.c 2010-08-02 20:33:11.000000000 +0200
6321 #include <linux/fcntl.h>
6322 #include <linux/device_cgroup.h>
6323 #include <linux/fs_struct.h>
6324 +#include <linux/proc_fs.h>
6325 +#include <linux/vserver/inode.h>
6326 +#include <linux/vs_base.h>
6327 +#include <linux/vs_tag.h>
6328 +#include <linux/vs_cowbl.h>
6329 +#include <linux/vs_device.h>
6330 +#include <linux/vs_context.h>
6331 +#include <linux/pid_namespace.h>
6332 #include <asm/uaccess.h>
6334 #include "internal.h"
6335 @@ -166,6 +174,77 @@ void putname(const char *name)
6336 EXPORT_SYMBOL(putname);
6339 +static inline int dx_barrier(const struct inode *inode)
6341 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
6342 + vxwprintk_task(1, "did hit the barrier.");
6348 +static int __dx_permission(const struct inode *inode, int mask)
6350 + if (dx_barrier(inode))
6353 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
6354 + /* devpts is xid tagged */
6355 + if (S_ISDIR(inode->i_mode) ||
6356 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
6359 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6360 + struct proc_dir_entry *de = PDE(inode);
6362 + if (de && !vx_hide_check(0, de->vx_flags))
6365 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
6367 + struct task_struct *tsk;
6369 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
6370 + vx_flags(VXF_STATE_SETUP, 0))
6373 + pid = PROC_I(inode)->pid;
6377 + tsk = pid_task(pid, PIDTYPE_PID);
6378 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
6379 + tsk, (tsk ? vx_task_xid(tsk) : 0));
6380 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
6384 + /* FIXME: Should we block some entries here? */
6389 + if (dx_notagcheck(inode->i_sb) ||
6390 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
6399 +int dx_permission(const struct inode *inode, int mask)
6401 + int ret = __dx_permission(inode, mask);
6402 + if (unlikely(ret)) {
6403 + vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
6404 + mask, inode->i_sb->s_id, inode, inode->i_tag,
6411 * This does basic POSIX ACL permission checking
6413 @@ -266,10 +345,14 @@ int inode_permission(struct inode *inode
6415 * Nobody gets write access to an immutable file.
6417 - if (IS_IMMUTABLE(inode))
6418 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6422 + retval = dx_permission(inode, mask);
6426 if (inode->i_op->permission)
6427 retval = inode->i_op->permission(inode, mask);
6429 @@ -464,6 +547,9 @@ static int exec_permission(struct inode
6433 + if (dx_barrier(inode))
6436 if (inode->i_op->permission) {
6437 ret = inode->i_op->permission(inode, MAY_EXEC);
6439 @@ -677,7 +763,8 @@ static __always_inline void follow_dotdo
6441 if (nd->path.dentry == nd->root.dentry &&
6442 nd->path.mnt == nd->root.mnt) {
6444 + /* for sane '/' avoid follow_mount() */
6447 if (nd->path.dentry != nd->path.mnt->mnt_root) {
6448 /* rare case of legitimate dget_parent()... */
6449 @@ -701,7 +788,7 @@ static int do_lookup(struct nameidata *n
6451 struct vfsmount *mnt = nd->path.mnt;
6452 struct dentry *dentry, *parent;
6453 - struct inode *dir;
6454 + struct inode *dir, *inode;
6456 * See if the low-level filesystem might want
6457 * to use its own hash..
6458 @@ -717,12 +804,26 @@ static int do_lookup(struct nameidata *n
6460 if (dentry->d_op && dentry->d_op->d_revalidate)
6461 goto need_revalidate;
6463 + inode = dentry->d_inode;
6467 + if (__dx_permission(inode, MAY_ACCESS))
6471 path->dentry = dentry;
6472 __follow_mount(path);
6476 + vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] »%s/%.*s«.",
6477 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
6478 + vxd_path(&nd->path), name->len, name->name);
6483 parent = nd->path.dentry;
6484 dir = parent->d_inode;
6485 @@ -1326,7 +1427,7 @@ static int may_delete(struct inode *dir,
6488 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6489 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6490 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6493 if (!S_ISDIR(victim->d_inode->i_mode))
6494 @@ -1449,6 +1550,16 @@ int may_open(struct path *path, int acc_
6498 +#ifdef CONFIG_VSERVER_COWBL
6499 + if (IS_COW(inode))
6500 + printk("cow inode: %p, flag=%x\n", inode, flag);
6501 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
6502 + if (IS_COW_LINK(inode))
6504 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
6505 + mark_inode_dirty(inode);
6508 error = inode_permission(inode, acc_mode);
6511 @@ -1558,7 +1669,8 @@ static int open_will_truncate(int flag,
6514 static struct file *finish_open(struct nameidata *nd,
6515 - int open_flag, int acc_mode)
6516 + int open_flag, int acc_mode,
6517 + const char *pathname)
6521 @@ -1571,6 +1683,23 @@ static struct file *finish_open(struct n
6524 error = may_open(&nd->path, acc_mode, open_flag);
6525 +#ifdef CONFIG_VSERVER_COWBL
6526 + if (error == -EMLINK) {
6527 + struct dentry *dentry;
6528 + dentry = cow_break_link(pathname);
6529 + if (IS_ERR(dentry)) {
6530 + error = PTR_ERR(dentry);
6534 + if (will_truncate)
6535 + mnt_drop_write(nd->path.mnt);
6536 + release_open_intent(nd);
6537 + path_put(&nd->path);
6538 + return ERR_PTR(-EMLINK);
6544 mnt_drop_write(nd->path.mnt);
6545 @@ -1739,7 +1868,7 @@ static struct file *do_last(struct namei
6546 if (S_ISDIR(path->dentry->d_inode->i_mode))
6549 - filp = finish_open(nd, open_flag, acc_mode);
6550 + filp = finish_open(nd, open_flag, acc_mode, pathname);
6554 @@ -1768,7 +1897,11 @@ struct file *do_filp_open(int dfd, const
6556 int flag = open_to_namei_flags(open_flag);
6557 int force_reval = 0;
6559 +#ifdef CONFIG_VSERVER_COWBL
6564 if (!(open_flag & O_CREAT))
6567 @@ -1834,6 +1967,13 @@ reval:
6568 if (!(open_flag & O_NOFOLLOW))
6569 nd.flags |= LOOKUP_FOLLOW;
6570 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
6571 +#ifdef CONFIG_VSERVER_COWBL
6572 + if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
6578 while (unlikely(!filp)) { /* trailing symlink */
6580 struct inode *inode = path.dentry->d_inode;
6581 @@ -1872,6 +2012,13 @@ reval:
6583 nd.flags &= ~LOOKUP_PARENT;
6584 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
6585 +#ifdef CONFIG_VSERVER_COWBL
6586 + if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
6592 if (inode->i_op->put_link)
6593 inode->i_op->put_link(holder.dentry, &nd, cookie);
6595 @@ -1972,9 +2119,17 @@ int vfs_mknod(struct inode *dir, struct
6599 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
6600 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
6603 + if (!capable(CAP_MKNOD))
6606 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
6608 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
6611 if (!dir->i_op->mknod)
6614 @@ -2439,7 +2594,7 @@ int vfs_link(struct dentry *old_dentry,
6616 * A link to an append-only or immutable file cannot be created.
6618 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6619 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6621 if (!dir->i_op->link)
6623 @@ -2811,6 +2966,219 @@ int vfs_follow_link(struct nameidata *nd
6624 return __vfs_follow_link(nd, link);
6628 +#ifdef CONFIG_VSERVER_COWBL
6630 +#include <linux/file.h>
6633 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6637 + return do_splice_direct(in, &ppos, out, len, 0);
6640 +struct dentry *cow_break_link(const char *pathname)
6642 + int ret, mode, pathlen, redo = 0;
6643 + struct nameidata old_nd, dir_nd;
6644 + struct path old_path, new_path;
6645 + struct dentry *dir, *res = NULL;
6646 + struct file *old_file;
6647 + struct file *new_file;
6648 + char *to, *path, pad='\251';
6651 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
6652 + path = kmalloc(PATH_MAX, GFP_KERNEL);
6657 + /* old_nd will have refs to dentry and mnt */
6658 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6659 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
6661 + goto out_free_path;
6663 + old_path = old_nd.path;
6664 + mode = old_path.dentry->d_inode->i_mode;
6666 + to = d_path(&old_path, path, PATH_MAX-2);
6667 + pathlen = strlen(to);
6668 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
6669 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6670 + old_path.dentry->d_name.len);
6672 + to[pathlen + 1] = 0;
6674 + to[pathlen] = pad--;
6676 + if (pad <= '\240')
6679 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
6680 + /* dir_nd will have refs to dentry and mnt */
6681 + ret = path_lookup(to,
6682 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
6683 + vxdprintk(VXD_CBIT(misc, 2),
6684 + "path_lookup(new): %d", ret);
6688 + /* this puppy downs the inode mutex */
6689 + new_path.dentry = lookup_create(&dir_nd, 0);
6690 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
6691 + vxdprintk(VXD_CBIT(misc, 2),
6692 + "lookup_create(new): %p", new_path.dentry);
6693 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
6694 + path_put(&dir_nd.path);
6697 + vxdprintk(VXD_CBIT(misc, 2),
6698 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
6699 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6700 + new_path.dentry->d_name.len);
6701 + dir = dir_nd.path.dentry;
6703 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
6704 + vxdprintk(VXD_CBIT(misc, 2),
6705 + "vfs_create(new): %d", ret);
6706 + if (ret == -EEXIST) {
6707 + mutex_unlock(&dir->d_inode->i_mutex);
6708 + dput(new_path.dentry);
6709 + path_put(&dir_nd.path);
6713 + goto out_unlock_new;
6715 + /* drop out early, ret passes ENOENT */
6717 + if ((redo = d_unhashed(old_path.dentry)))
6718 + goto out_unlock_new;
6720 + new_path.mnt = dir_nd.path.mnt;
6721 + dget(old_path.dentry);
6722 + mntget(old_path.mnt);
6723 + /* this one cleans up the dentry/mnt in case of failure */
6724 + old_file = dentry_open(old_path.dentry, old_path.mnt,
6725 + O_RDONLY, current_cred());
6726 + vxdprintk(VXD_CBIT(misc, 2),
6727 + "dentry_open(old): %p", old_file);
6728 + if (!old_file || IS_ERR(old_file)) {
6729 + res = IS_ERR(old_file) ? (void *) old_file : res;
6730 + goto out_unlock_new;
6733 + dget(new_path.dentry);
6734 + mntget(new_path.mnt);
6735 + /* this one cleans up the dentry/mnt in case of failure */
6736 + new_file = dentry_open(new_path.dentry, new_path.mnt,
6737 + O_WRONLY, current_cred());
6738 + vxdprintk(VXD_CBIT(misc, 2),
6739 + "dentry_open(new): %p", new_file);
6741 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
6742 + if (!new_file || IS_ERR(new_file))
6743 + goto out_fput_old;
6745 + size = i_size_read(old_file->f_dentry->d_inode);
6746 + ret = do_cow_splice(old_file, new_file, size);
6747 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
6749 + goto out_fput_both;
6750 + } else if (ret < size) {
6752 + goto out_fput_both;
6754 + struct inode *old_inode = old_path.dentry->d_inode;
6755 + struct inode *new_inode = new_path.dentry->d_inode;
6756 + struct iattr attr = {
6757 + .ia_uid = old_inode->i_uid,
6758 + .ia_gid = old_inode->i_gid,
6759 + .ia_valid = ATTR_UID | ATTR_GID
6762 + ret = inode_setattr(new_inode, &attr);
6764 + goto out_fput_both;
6767 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6769 + /* drop out late */
6771 + if ((redo = d_unhashed(old_path.dentry)))
6774 + vxdprintk(VXD_CBIT(misc, 2),
6775 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
6776 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6777 + new_path.dentry->d_name.len,
6778 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6779 + old_path.dentry->d_name.len);
6780 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
6781 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
6782 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
6783 + res = new_path.dentry;
6786 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6789 + vxdprintk(VXD_CBIT(misc, 3),
6790 + "fput(new_file=%p[#%ld])", new_file,
6791 + atomic_long_read(&new_file->f_count));
6795 + vxdprintk(VXD_CBIT(misc, 3),
6796 + "fput(old_file=%p[#%ld])", old_file,
6797 + atomic_long_read(&old_file->f_count));
6801 + mutex_unlock(&dir->d_inode->i_mutex);
6805 + /* error path cleanup */
6806 + vfs_unlink(dir->d_inode, new_path.dentry);
6807 + dput(new_path.dentry);
6811 + goto out_rel_both;
6812 + /* lookup dentry once again */
6813 + path_put(&old_nd.path);
6814 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6816 + goto out_rel_both;
6818 + new_path.dentry = old_nd.path.dentry;
6819 + vxdprintk(VXD_CBIT(misc, 2),
6820 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
6821 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6822 + new_path.dentry->d_name.len);
6823 + dget(new_path.dentry);
6824 + res = new_path.dentry;
6827 + path_put(&dir_nd.path);
6829 + path_put(&old_nd.path);
6834 + res = ERR_PTR(ret);
6840 /* get the link contents into pagecache */
6841 static char *page_getlink(struct dentry * dentry, struct page **ppage)
6843 diff -NurpP --minimal linux-2.6.35/fs/namespace.c linux-2.6.35-vs2.3.0.36.31/fs/namespace.c
6844 --- linux-2.6.35/fs/namespace.c 2010-08-02 16:52:50.000000000 +0200
6845 +++ linux-2.6.35-vs2.3.0.36.31/fs/namespace.c 2010-08-02 17:05:06.000000000 +0200
6847 #include <linux/log2.h>
6848 #include <linux/idr.h>
6849 #include <linux/fs_struct.h>
6850 +#include <linux/vs_base.h>
6851 +#include <linux/vs_context.h>
6852 +#include <linux/vs_tag.h>
6853 +#include <linux/vserver/space.h>
6854 +#include <linux/vserver/global.h>
6855 #include <asm/uaccess.h>
6856 #include <asm/unistd.h>
6858 @@ -567,6 +572,7 @@ static struct vfsmount *clone_mnt(struct
6859 mnt->mnt_root = dget(root);
6860 mnt->mnt_mountpoint = mnt->mnt_root;
6861 mnt->mnt_parent = mnt;
6862 + mnt->mnt_tag = old->mnt_tag;
6864 if (flag & CL_SLAVE) {
6865 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
6866 @@ -660,6 +666,31 @@ static inline void mangle(struct seq_fil
6867 seq_escape(m, s, " \t\n\\");
6870 +static int mnt_is_reachable(struct vfsmount *mnt)
6873 + struct dentry *point;
6876 + if (mnt == mnt->mnt_ns->root)
6879 + spin_lock(&vfsmount_lock);
6880 + root = current->fs->root;
6881 + point = root.dentry;
6883 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
6884 + point = mnt->mnt_mountpoint;
6885 + mnt = mnt->mnt_parent;
6888 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
6890 + spin_unlock(&vfsmount_lock);
6896 * Simple .show_options callback for filesystems which don't want to
6897 * implement more complex mount option showing.
6898 @@ -762,6 +793,8 @@ static int show_sb_opts(struct seq_file
6899 { MS_SYNCHRONOUS, ",sync" },
6900 { MS_DIRSYNC, ",dirsync" },
6901 { MS_MANDLOCK, ",mand" },
6902 + { MS_TAGGED, ",tag" },
6903 + { MS_NOTAGCHECK, ",notagcheck" },
6906 const struct proc_fs_info *fs_infop;
6907 @@ -809,10 +842,20 @@ static int show_vfsmnt(struct seq_file *
6909 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6911 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6913 - seq_path(m, &mnt_path, " \t\n\\");
6915 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6917 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6920 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6921 + mnt == current->fs->root.mnt) {
6922 + seq_puts(m, "/dev/root / ");
6924 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6926 + seq_path(m, &mnt_path, " \t\n\\");
6929 show_type(m, mnt->mnt_sb);
6930 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
6931 err = show_sb_opts(m, mnt->mnt_sb);
6932 @@ -842,6 +885,11 @@ static int show_mountinfo(struct seq_fil
6933 struct path root = p->root;
6936 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6938 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6941 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
6942 MAJOR(sb->s_dev), MINOR(sb->s_dev));
6943 seq_dentry(m, mnt->mnt_root, " \t\n\\");
6944 @@ -900,17 +948,27 @@ static int show_vfsstat(struct seq_file
6945 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6949 - if (mnt->mnt_devname) {
6950 - seq_puts(m, "device ");
6951 - mangle(m, mnt->mnt_devname);
6953 - seq_puts(m, "no device");
6954 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6956 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6960 - seq_puts(m, " mounted on ");
6961 - seq_path(m, &mnt_path, " \t\n\\");
6963 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6964 + mnt == current->fs->root.mnt) {
6965 + seq_puts(m, "device /dev/root mounted on / ");
6968 + if (mnt->mnt_devname) {
6969 + seq_puts(m, "device ");
6970 + mangle(m, mnt->mnt_devname);
6972 + seq_puts(m, "no device");
6975 + seq_puts(m, " mounted on ");
6976 + seq_path(m, &mnt_path, " \t\n\\");
6980 /* file system type */
6981 seq_puts(m, "with fstype ");
6982 @@ -1151,7 +1209,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
6986 - if (!capable(CAP_SYS_ADMIN))
6987 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6990 retval = do_umount(path.mnt, flags);
6991 @@ -1177,7 +1235,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
6993 static int mount_is_safe(struct path *path)
6995 - if (capable(CAP_SYS_ADMIN))
6996 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7000 @@ -1449,7 +1507,7 @@ static int do_change_type(struct path *p
7001 int type = flag & ~MS_REC;
7004 - if (!capable(CAP_SYS_ADMIN))
7005 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
7008 if (path->dentry != path->mnt->mnt_root)
7009 @@ -1476,11 +1534,13 @@ static int do_change_type(struct path *p
7010 * do loopback mount.
7012 static int do_loopback(struct path *path, char *old_name,
7014 + tag_t tag, unsigned long flags, int mnt_flags)
7016 struct path old_path;
7017 struct vfsmount *mnt = NULL;
7018 int err = mount_is_safe(path);
7019 + int recurse = flags & MS_REC;
7023 if (!old_name || !*old_name)
7024 @@ -1514,6 +1574,7 @@ static int do_loopback(struct path *path
7025 spin_unlock(&vfsmount_lock);
7026 release_mounts(&umount_list);
7028 + mnt->mnt_flags = mnt_flags;
7031 up_write(&namespace_sem);
7032 @@ -1544,12 +1605,12 @@ static int change_mount_flags(struct vfs
7033 * on it - tough luck.
7035 static int do_remount(struct path *path, int flags, int mnt_flags,
7037 + void *data, xid_t xid)
7040 struct super_block *sb = path->mnt->mnt_sb;
7042 - if (!capable(CAP_SYS_ADMIN))
7043 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
7046 if (!check_mnt(path->mnt))
7047 @@ -1593,7 +1654,7 @@ static int do_move_mount(struct path *pa
7048 struct path old_path, parent_path;
7051 - if (!capable(CAP_SYS_ADMIN))
7052 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7054 if (!old_name || !*old_name)
7056 @@ -1675,7 +1736,7 @@ static int do_new_mount(struct path *pat
7059 /* we need capabilities... */
7060 - if (!capable(CAP_SYS_ADMIN))
7061 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7065 @@ -1941,6 +2002,7 @@ long do_mount(char *dev_name, char *dir_
7072 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
7073 @@ -1968,6 +2030,12 @@ long do_mount(char *dev_name, char *dir_
7074 if (!(flags & MS_NOATIME))
7075 mnt_flags |= MNT_RELATIME;
7077 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
7078 + /* FIXME: bind and re-mounts get the tag flag? */
7079 + if (flags & (MS_BIND|MS_REMOUNT))
7080 + flags |= MS_TAGID;
7083 /* Separate the per-mountpoint flags */
7084 if (flags & MS_NOSUID)
7085 mnt_flags |= MNT_NOSUID;
7086 @@ -1984,15 +2052,17 @@ long do_mount(char *dev_name, char *dir_
7087 if (flags & MS_RDONLY)
7088 mnt_flags |= MNT_READONLY;
7090 + if (!capable(CAP_SYS_ADMIN))
7091 + mnt_flags |= MNT_NODEV;
7092 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
7093 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
7096 if (flags & MS_REMOUNT)
7097 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
7100 else if (flags & MS_BIND)
7101 - retval = do_loopback(&path, dev_name, flags & MS_REC);
7102 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
7103 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
7104 retval = do_change_type(&path, flags);
7105 else if (flags & MS_MOVE)
7106 @@ -2071,6 +2141,7 @@ static struct mnt_namespace *dup_mnt_ns(
7107 q = next_mnt(q, new_ns->root);
7109 up_write(&namespace_sem);
7110 + atomic_inc(&vs_global_mnt_ns);
7114 @@ -2215,9 +2286,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
7115 down_write(&namespace_sem);
7116 mutex_lock(&old.dentry->d_inode->i_mutex);
7118 - if (IS_MNT_SHARED(old.mnt) ||
7119 + if ((IS_MNT_SHARED(old.mnt) ||
7120 IS_MNT_SHARED(new.mnt->mnt_parent) ||
7121 - IS_MNT_SHARED(root.mnt->mnt_parent))
7122 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
7123 + !vx_flags(VXF_STATE_SETUP, 0))
7125 if (!check_mnt(root.mnt))
7127 @@ -2348,6 +2420,7 @@ void put_mnt_ns(struct mnt_namespace *ns
7128 spin_unlock(&vfsmount_lock);
7129 up_write(&namespace_sem);
7130 release_mounts(&umount_list);
7131 + atomic_dec(&vs_global_mnt_ns);
7134 EXPORT_SYMBOL(put_mnt_ns);
7135 diff -NurpP --minimal linux-2.6.35/fs/nfs/client.c linux-2.6.35-vs2.3.0.36.31/fs/nfs/client.c
7136 --- linux-2.6.35/fs/nfs/client.c 2010-08-02 16:52:50.000000000 +0200
7137 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfs/client.c 2010-08-02 17:05:06.000000000 +0200
7138 @@ -739,6 +739,9 @@ static int nfs_init_server_rpcclient(str
7139 if (server->flags & NFS_MOUNT_SOFT)
7140 server->client->cl_softrtry = 1;
7142 + server->client->cl_tag = 0;
7143 + if (server->flags & NFS_MOUNT_TAGGED)
7144 + server->client->cl_tag = 1;
7148 @@ -910,6 +913,10 @@ static void nfs_server_set_fsinfo(struct
7149 server->acdirmin = server->acdirmax = 0;
7152 + /* FIXME: needs fsinfo
7153 + if (server->flags & NFS_MOUNT_TAGGED)
7154 + sb->s_flags |= MS_TAGGED; */
7156 server->maxfilesize = fsinfo->maxfilesize;
7158 /* We're airborne Set socket buffersize */
7159 diff -NurpP --minimal linux-2.6.35/fs/nfs/dir.c linux-2.6.35-vs2.3.0.36.31/fs/nfs/dir.c
7160 --- linux-2.6.35/fs/nfs/dir.c 2010-08-02 16:52:50.000000000 +0200
7161 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfs/dir.c 2010-08-02 17:05:06.000000000 +0200
7163 #include <linux/namei.h>
7164 #include <linux/mount.h>
7165 #include <linux/sched.h>
7166 +#include <linux/vs_tag.h>
7168 #include "nfs4_fs.h"
7169 #include "delegation.h"
7170 @@ -979,6 +980,7 @@ static struct dentry *nfs_lookup(struct
7172 goto out_unblock_sillyrename;
7174 + dx_propagate_tag(nd, inode);
7176 res = d_materialise_unique(dentry, inode);
7178 diff -NurpP --minimal linux-2.6.35/fs/nfs/inode.c linux-2.6.35-vs2.3.0.36.31/fs/nfs/inode.c
7179 --- linux-2.6.35/fs/nfs/inode.c 2010-08-02 16:52:50.000000000 +0200
7180 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfs/inode.c 2010-08-02 17:05:06.000000000 +0200
7182 #include <linux/inet.h>
7183 #include <linux/nfs_xdr.h>
7184 #include <linux/slab.h>
7185 +#include <linux/vs_tag.h>
7187 #include <asm/system.h>
7188 #include <asm/uaccess.h>
7189 @@ -260,6 +261,8 @@ nfs_fhget(struct super_block *sb, struct
7190 if (inode->i_state & I_NEW) {
7191 struct nfs_inode *nfsi = NFS_I(inode);
7192 unsigned long now = jiffies;
7196 /* We set i_ino for the few things that still rely on it,
7197 * such as stat(2) */
7198 @@ -308,8 +311,8 @@ nfs_fhget(struct super_block *sb, struct
7199 nfsi->change_attr = 0;
7202 - inode->i_uid = -2;
7203 - inode->i_gid = -2;
7206 inode->i_blocks = 0;
7207 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
7209 @@ -346,13 +349,13 @@ nfs_fhget(struct super_block *sb, struct
7210 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
7211 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
7212 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
7213 - inode->i_uid = fattr->uid;
7215 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
7216 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7217 | NFS_INO_INVALID_ACCESS
7218 | NFS_INO_INVALID_ACL;
7219 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
7220 - inode->i_gid = fattr->gid;
7222 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
7223 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7224 | NFS_INO_INVALID_ACCESS
7225 @@ -365,6 +368,11 @@ nfs_fhget(struct super_block *sb, struct
7227 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
7229 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7230 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7231 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7232 + /* maybe fattr->xid someday */
7234 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
7235 nfsi->attrtimeo_timestamp = now;
7236 nfsi->access_cache = RB_ROOT;
7237 @@ -483,6 +491,8 @@ void nfs_setattr_update_inode(struct ino
7238 inode->i_uid = attr->ia_uid;
7239 if ((attr->ia_valid & ATTR_GID) != 0)
7240 inode->i_gid = attr->ia_gid;
7241 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7242 + inode->i_tag = attr->ia_tag;
7243 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7244 spin_unlock(&inode->i_lock);
7246 @@ -856,6 +866,9 @@ static int nfs_check_inode_attributes(st
7247 struct nfs_inode *nfsi = NFS_I(inode);
7248 loff_t cur_size, new_isize;
7249 unsigned long invalid = 0;
7255 /* Has the inode gone and changed behind our back? */
7256 @@ -879,13 +892,18 @@ static int nfs_check_inode_attributes(st
7257 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7260 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7261 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7262 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7264 /* Have any file permissions changed? */
7265 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
7266 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7267 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
7268 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
7269 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7270 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
7271 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
7272 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7273 + /* maybe check for tag too? */
7275 /* Has the link count changed? */
7276 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
7277 @@ -1120,6 +1138,9 @@ static int nfs_update_inode(struct inode
7278 unsigned long invalid = 0;
7279 unsigned long now = jiffies;
7280 unsigned long save_cache_validity;
7285 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7286 __func__, inode->i_sb->s_id, inode->i_ino,
7287 @@ -1222,6 +1243,9 @@ static int nfs_update_inode(struct inode
7288 | NFS_INO_REVAL_PAGECACHE
7289 | NFS_INO_REVAL_FORCED);
7291 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7292 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7293 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7295 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
7296 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7297 @@ -1243,9 +1267,9 @@ static int nfs_update_inode(struct inode
7298 | NFS_INO_REVAL_FORCED);
7300 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
7301 - if (inode->i_uid != fattr->uid) {
7302 + if (uid != fattr->uid) {
7303 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7304 - inode->i_uid = fattr->uid;
7307 } else if (server->caps & NFS_CAP_OWNER)
7308 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7309 @@ -1254,9 +1278,9 @@ static int nfs_update_inode(struct inode
7310 | NFS_INO_REVAL_FORCED);
7312 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
7313 - if (inode->i_gid != fattr->gid) {
7314 + if (gid != fattr->gid) {
7315 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7316 - inode->i_gid = fattr->gid;
7319 } else if (server->caps & NFS_CAP_OWNER_GROUP)
7320 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7321 @@ -1264,6 +1288,10 @@ static int nfs_update_inode(struct inode
7322 | NFS_INO_INVALID_ACL
7323 | NFS_INO_REVAL_FORCED);
7325 + inode->i_uid = uid;
7326 + inode->i_gid = gid;
7327 + inode->i_tag = tag;
7329 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
7330 if (inode->i_nlink != fattr->nlink) {
7331 invalid |= NFS_INO_INVALID_ATTR;
7332 diff -NurpP --minimal linux-2.6.35/fs/nfs/nfs3xdr.c linux-2.6.35-vs2.3.0.36.31/fs/nfs/nfs3xdr.c
7333 --- linux-2.6.35/fs/nfs/nfs3xdr.c 2010-08-02 16:52:50.000000000 +0200
7334 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfs/nfs3xdr.c 2010-08-02 17:05:06.000000000 +0200
7336 #include <linux/nfs3.h>
7337 #include <linux/nfs_fs.h>
7338 #include <linux/nfsacl.h>
7339 +#include <linux/vs_tag.h>
7340 #include "internal.h"
7342 #define NFSDBG_FACILITY NFSDBG_XDR
7343 @@ -175,7 +176,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
7346 static inline __be32 *
7347 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
7348 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
7350 if (attr->ia_valid & ATTR_MODE) {
7352 @@ -183,15 +184,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
7356 - if (attr->ia_valid & ATTR_UID) {
7357 + if (attr->ia_valid & ATTR_UID ||
7358 + (tag && (attr->ia_valid & ATTR_TAG))) {
7360 - *p++ = htonl(attr->ia_uid);
7361 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
7365 - if (attr->ia_valid & ATTR_GID) {
7366 + if (attr->ia_valid & ATTR_GID ||
7367 + (tag && (attr->ia_valid & ATTR_TAG))) {
7369 - *p++ = htonl(attr->ia_gid);
7370 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
7374 @@ -278,7 +281,8 @@ static int
7375 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
7377 p = xdr_encode_fhandle(p, args->fh);
7378 - p = xdr_encode_sattr(p, args->sattr);
7379 + p = xdr_encode_sattr(p, args->sattr,
7380 + req->rq_task->tk_client->cl_tag);
7381 *p++ = htonl(args->guard);
7383 p = xdr_encode_time3(p, &args->guardtime);
7384 @@ -383,7 +387,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
7385 *p++ = args->verifier[0];
7386 *p++ = args->verifier[1];
7388 - p = xdr_encode_sattr(p, args->sattr);
7389 + p = xdr_encode_sattr(p, args->sattr,
7390 + req->rq_task->tk_client->cl_tag);
7392 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7394 @@ -397,7 +402,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
7396 p = xdr_encode_fhandle(p, args->fh);
7397 p = xdr_encode_array(p, args->name, args->len);
7398 - p = xdr_encode_sattr(p, args->sattr);
7399 + p = xdr_encode_sattr(p, args->sattr,
7400 + req->rq_task->tk_client->cl_tag);
7401 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7404 @@ -410,7 +416,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
7406 p = xdr_encode_fhandle(p, args->fromfh);
7407 p = xdr_encode_array(p, args->fromname, args->fromlen);
7408 - p = xdr_encode_sattr(p, args->sattr);
7409 + p = xdr_encode_sattr(p, args->sattr,
7410 + req->rq_task->tk_client->cl_tag);
7411 *p++ = htonl(args->pathlen);
7412 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7414 @@ -428,7 +435,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
7415 p = xdr_encode_fhandle(p, args->fh);
7416 p = xdr_encode_array(p, args->name, args->len);
7417 *p++ = htonl(args->type);
7418 - p = xdr_encode_sattr(p, args->sattr);
7419 + p = xdr_encode_sattr(p, args->sattr,
7420 + req->rq_task->tk_client->cl_tag);
7421 if (args->type == NF3CHR || args->type == NF3BLK) {
7422 *p++ = htonl(MAJOR(args->rdev));
7423 *p++ = htonl(MINOR(args->rdev));
7424 diff -NurpP --minimal linux-2.6.35/fs/nfs/nfsroot.c linux-2.6.35-vs2.3.0.36.31/fs/nfs/nfsroot.c
7425 --- linux-2.6.35/fs/nfs/nfsroot.c 2010-08-02 16:52:50.000000000 +0200
7426 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfs/nfsroot.c 2010-08-02 17:05:06.000000000 +0200
7427 @@ -122,12 +122,12 @@ static int mount_port __initdata = 0; /
7429 /* Options that take integer arguments */
7430 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
7431 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
7432 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
7433 /* Options that take no arguments */
7434 Opt_soft, Opt_hard, Opt_intr,
7435 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
7436 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
7437 - Opt_acl, Opt_noacl,
7438 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
7442 @@ -164,6 +164,9 @@ static const match_table_t tokens __init
7445 {Opt_noacl, "noacl"},
7447 + {Opt_notag, "notag"},
7448 + {Opt_tagid, "tagid=%u"},
7452 @@ -275,6 +278,20 @@ static int __init root_nfs_parse(char *n
7454 nfs_data.flags |= NFS_MOUNT_NOACL;
7456 +#ifndef CONFIG_TAGGING_NONE
7458 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7461 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
7464 +#ifdef CONFIG_PROPAGATE
7467 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7471 printk(KERN_WARNING "Root-NFS: unknown "
7473 diff -NurpP --minimal linux-2.6.35/fs/nfs/super.c linux-2.6.35-vs2.3.0.36.31/fs/nfs/super.c
7474 --- linux-2.6.35/fs/nfs/super.c 2010-08-02 16:52:50.000000000 +0200
7475 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfs/super.c 2010-08-02 17:05:06.000000000 +0200
7477 #include <linux/nfs_xdr.h>
7478 #include <linux/magic.h>
7479 #include <linux/parser.h>
7480 +#include <linux/vs_tag.h>
7482 #include <asm/system.h>
7483 #include <asm/uaccess.h>
7484 @@ -606,6 +607,7 @@ static void nfs_show_mount_options(struc
7485 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7486 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
7487 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
7488 + { NFS_MOUNT_TAGGED, ",tag", "" },
7491 const struct proc_nfs_info *nfs_infop;
7492 diff -NurpP --minimal linux-2.6.35/fs/nfsd/auth.c linux-2.6.35-vs2.3.0.36.31/fs/nfsd/auth.c
7493 --- linux-2.6.35/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
7494 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfsd/auth.c 2010-08-02 17:05:06.000000000 +0200
7496 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
7498 #include <linux/sched.h>
7499 +#include <linux/vs_tag.h>
7503 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7505 new->fsuid = rqstp->rq_cred.cr_uid;
7506 new->fsgid = rqstp->rq_cred.cr_gid;
7507 + /* FIXME: this desperately needs a tag :)
7508 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7511 rqgi = rqstp->rq_cred.cr_group_info;
7513 diff -NurpP --minimal linux-2.6.35/fs/nfsd/nfs3xdr.c linux-2.6.35-vs2.3.0.36.31/fs/nfsd/nfs3xdr.c
7514 --- linux-2.6.35/fs/nfsd/nfs3xdr.c 2010-02-25 11:52:05.000000000 +0100
7515 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfsd/nfs3xdr.c 2010-08-02 17:05:06.000000000 +0200
7519 #include <linux/namei.h>
7520 +#include <linux/vs_tag.h>
7524 @@ -95,6 +96,8 @@ static __be32 *
7525 decode_sattr3(__be32 *p, struct iattr *iap)
7533 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7536 iap->ia_valid |= ATTR_UID;
7537 - iap->ia_uid = ntohl(*p++);
7538 + uid = ntohl(*p++);
7541 iap->ia_valid |= ATTR_GID;
7542 - iap->ia_gid = ntohl(*p++);
7543 + gid = ntohl(*p++);
7545 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7546 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7547 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7551 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
7552 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7553 *p++ = htonl((u32) stat->mode);
7554 *p++ = htonl((u32) stat->nlink);
7555 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7556 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7557 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7558 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7559 + stat->uid, stat->tag)));
7560 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7561 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7562 + stat->gid, stat->tag)));
7563 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7564 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7566 diff -NurpP --minimal linux-2.6.35/fs/nfsd/nfs4xdr.c linux-2.6.35-vs2.3.0.36.31/fs/nfsd/nfs4xdr.c
7567 --- linux-2.6.35/fs/nfsd/nfs4xdr.c 2010-08-02 16:52:50.000000000 +0200
7568 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfsd/nfs4xdr.c 2010-08-02 17:05:06.000000000 +0200
7570 #include <linux/nfsd_idmap.h>
7571 #include <linux/nfs4_acl.h>
7572 #include <linux/sunrpc/svcauth_gss.h>
7573 +#include <linux/vs_tag.h>
7577 @@ -2053,14 +2054,18 @@ out_acl:
7578 WRITE32(stat.nlink);
7580 if (bmval1 & FATTR4_WORD1_OWNER) {
7581 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7582 + status = nfsd4_encode_user(rqstp,
7583 + TAGINO_UID(DX_TAG(dentry->d_inode),
7584 + stat.uid, stat.tag), &p, &buflen);
7585 if (status == nfserr_resource)
7590 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7591 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7592 + status = nfsd4_encode_group(rqstp,
7593 + TAGINO_GID(DX_TAG(dentry->d_inode),
7594 + stat.gid, stat.tag), &p, &buflen);
7595 if (status == nfserr_resource)
7598 diff -NurpP --minimal linux-2.6.35/fs/nfsd/nfsxdr.c linux-2.6.35-vs2.3.0.36.31/fs/nfsd/nfsxdr.c
7599 --- linux-2.6.35/fs/nfsd/nfsxdr.c 2010-02-25 11:52:05.000000000 +0100
7600 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfsd/nfsxdr.c 2010-08-02 17:05:06.000000000 +0200
7605 +#include <linux/vs_tag.h>
7607 #define NFSDDBG_FACILITY NFSDDBG_XDR
7609 @@ -88,6 +89,8 @@ static __be32 *
7610 decode_sattr(__be32 *p, struct iattr *iap)
7618 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7620 if ((tmp = ntohl(*p++)) != (u32)-1) {
7621 iap->ia_valid |= ATTR_UID;
7622 - iap->ia_uid = tmp;
7625 if ((tmp = ntohl(*p++)) != (u32)-1) {
7626 iap->ia_valid |= ATTR_GID;
7627 - iap->ia_gid = tmp;
7630 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7631 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7632 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7633 if ((tmp = ntohl(*p++)) != (u32)-1) {
7634 iap->ia_valid |= ATTR_SIZE;
7636 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7637 *p++ = htonl(nfs_ftypes[type >> 12]);
7638 *p++ = htonl((u32) stat->mode);
7639 *p++ = htonl((u32) stat->nlink);
7640 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7641 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7642 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7643 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7644 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7645 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7647 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7648 *p++ = htonl(NFS_MAXPATHLEN);
7649 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/dlmglue.c linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/dlmglue.c
7650 --- linux-2.6.35/fs/ocfs2/dlmglue.c 2010-08-02 16:52:51.000000000 +0200
7651 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/dlmglue.c 2010-08-02 17:05:06.000000000 +0200
7652 @@ -2114,6 +2114,7 @@ static void __ocfs2_stuff_meta_lvb(struc
7653 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
7654 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
7655 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
7656 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
7657 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
7658 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
7659 lvb->lvb_iatime_packed =
7660 @@ -2168,6 +2169,7 @@ static void ocfs2_refresh_inode_from_lvb
7662 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
7663 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
7664 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
7665 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
7666 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
7667 ocfs2_unpack_timespec(&inode->i_atime,
7668 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/dlmglue.h linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/dlmglue.h
7669 --- linux-2.6.35/fs/ocfs2/dlmglue.h 2009-12-03 20:02:53.000000000 +0100
7670 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/dlmglue.h 2010-08-02 17:05:06.000000000 +0200
7671 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
7674 __be32 lvb_igeneration;
7675 - __be32 lvb_reserved2;
7677 + __be16 lvb_reserved2;
7680 #define OCFS2_QINFO_LVB_VERSION 1
7681 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/file.c linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/file.c
7682 --- linux-2.6.35/fs/ocfs2/file.c 2010-08-02 16:52:51.000000000 +0200
7683 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/file.c 2010-08-02 17:05:06.000000000 +0200
7684 @@ -1129,13 +1129,15 @@ int ocfs2_setattr(struct dentry *dentry,
7685 mlog(0, "uid change: %d\n", attr->ia_uid);
7686 if (attr->ia_valid & ATTR_GID)
7687 mlog(0, "gid change: %d\n", attr->ia_gid);
7688 + if (attr->ia_valid & ATTR_TAG)
7689 + mlog(0, "tag change: %d\n", attr->ia_tag);
7690 if (attr->ia_valid & ATTR_SIZE)
7691 mlog(0, "size change...\n");
7692 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
7693 mlog(0, "time change...\n");
7695 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
7696 - | ATTR_GID | ATTR_UID | ATTR_MODE)
7697 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
7698 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
7699 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
7701 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/inode.c linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/inode.c
7702 --- linux-2.6.35/fs/ocfs2/inode.c 2010-08-02 16:52:51.000000000 +0200
7703 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/inode.c 2010-08-02 17:05:06.000000000 +0200
7705 #include <linux/highmem.h>
7706 #include <linux/pagemap.h>
7707 #include <linux/quotaops.h>
7708 +#include <linux/vs_tag.h>
7710 #include <asm/byteorder.h>
7712 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
7714 unsigned int flags = OCFS2_I(inode)->ip_attr;
7716 - inode->i_flags &= ~(S_IMMUTABLE |
7717 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
7718 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
7720 if (flags & OCFS2_IMMUTABLE_FL)
7721 inode->i_flags |= S_IMMUTABLE;
7722 + if (flags & OCFS2_IXUNLINK_FL)
7723 + inode->i_flags |= S_IXUNLINK;
7725 if (flags & OCFS2_SYNC_FL)
7726 inode->i_flags |= S_SYNC;
7727 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
7728 inode->i_flags |= S_NOATIME;
7729 if (flags & OCFS2_DIRSYNC_FL)
7730 inode->i_flags |= S_DIRSYNC;
7732 + inode->i_vflags &= ~(V_BARRIER | V_COW);
7734 + if (flags & OCFS2_BARRIER_FL)
7735 + inode->i_vflags |= V_BARRIER;
7736 + if (flags & OCFS2_COW_FL)
7737 + inode->i_vflags |= V_COW;
7740 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
7741 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
7743 unsigned int flags = oi->vfs_inode.i_flags;
7744 + unsigned int vflags = oi->vfs_inode.i_vflags;
7746 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
7747 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
7748 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
7749 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
7751 + if (flags & S_IMMUTABLE)
7752 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7753 + if (flags & S_IXUNLINK)
7754 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
7756 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
7757 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
7759 oi->ip_attr |= OCFS2_SYNC_FL;
7760 if (flags & S_APPEND)
7761 oi->ip_attr |= OCFS2_APPEND_FL;
7762 - if (flags & S_IMMUTABLE)
7763 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7764 if (flags & S_NOATIME)
7765 oi->ip_attr |= OCFS2_NOATIME_FL;
7766 if (flags & S_DIRSYNC)
7767 oi->ip_attr |= OCFS2_DIRSYNC_FL;
7769 + if (vflags & V_BARRIER)
7770 + oi->ip_attr |= OCFS2_BARRIER_FL;
7771 + if (vflags & V_COW)
7772 + oi->ip_attr |= OCFS2_COW_FL;
7775 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
7776 @@ -245,6 +267,8 @@ void ocfs2_populate_inode(struct inode *
7777 struct super_block *sb;
7778 struct ocfs2_super *osb;
7783 mlog_entry("(0x%p, size:%llu)\n", inode,
7784 (unsigned long long)le64_to_cpu(fe->i_size));
7785 @@ -276,8 +300,12 @@ void ocfs2_populate_inode(struct inode *
7786 inode->i_generation = le32_to_cpu(fe->i_generation);
7787 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
7788 inode->i_mode = le16_to_cpu(fe->i_mode);
7789 - inode->i_uid = le32_to_cpu(fe->i_uid);
7790 - inode->i_gid = le32_to_cpu(fe->i_gid);
7791 + uid = le32_to_cpu(fe->i_uid);
7792 + gid = le32_to_cpu(fe->i_gid);
7793 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7794 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7795 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
7796 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
7798 /* Fast symlinks will have i_size but no allocated clusters. */
7799 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
7800 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/inode.h linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/inode.h
7801 --- linux-2.6.35/fs/ocfs2/inode.h 2010-08-02 16:52:51.000000000 +0200
7802 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/inode.h 2010-08-02 17:05:06.000000000 +0200
7803 @@ -154,6 +154,7 @@ struct buffer_head *ocfs2_bread(struct i
7805 void ocfs2_set_inode_flags(struct inode *inode);
7806 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
7807 +int ocfs2_sync_flags(struct inode *inode, int, int);
7809 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
7811 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/ioctl.c
7812 --- linux-2.6.35/fs/ocfs2/ioctl.c 2010-02-25 11:52:06.000000000 +0100
7813 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/ioctl.c 2010-08-02 17:05:06.000000000 +0200
7814 @@ -43,7 +43,41 @@ static int ocfs2_get_inode_attr(struct i
7818 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7819 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
7821 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7822 + struct buffer_head *bh = NULL;
7823 + handle_t *handle = NULL;
7826 + status = ocfs2_inode_lock(inode, &bh, 1);
7828 + mlog_errno(status);
7831 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7832 + if (IS_ERR(handle)) {
7833 + status = PTR_ERR(handle);
7834 + mlog_errno(status);
7838 + inode->i_flags = flags;
7839 + inode->i_vflags = vflags;
7840 + ocfs2_get_inode_flags(OCFS2_I(inode));
7842 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
7844 + mlog_errno(status);
7846 + ocfs2_commit_trans(osb, handle);
7848 + ocfs2_inode_unlock(inode, 1);
7853 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7856 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
7857 @@ -68,6 +102,11 @@ static int ocfs2_set_inode_attr(struct i
7858 if (!S_ISDIR(inode->i_mode))
7859 flags &= ~OCFS2_DIRSYNC_FL;
7861 + if (IS_BARRIER(inode)) {
7862 + vxwprintk_task(1, "messing with the barrier.");
7866 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7867 if (IS_ERR(handle)) {
7868 status = PTR_ERR(handle);
7869 @@ -109,6 +148,7 @@ bail:
7874 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7876 struct inode *inode = filp->f_path.dentry->d_inode;
7877 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/namei.c linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/namei.c
7878 --- linux-2.6.35/fs/ocfs2/namei.c 2010-08-02 16:52:51.000000000 +0200
7879 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/namei.c 2010-08-02 17:05:06.000000000 +0200
7881 #include <linux/slab.h>
7882 #include <linux/highmem.h>
7883 #include <linux/quotaops.h>
7884 +#include <linux/vs_tag.h>
7886 #define MLOG_MASK_PREFIX ML_NAMEI
7887 #include <cluster/masklog.h>
7888 @@ -487,6 +488,7 @@ static int ocfs2_mknod_locked(struct ocf
7889 u64 suballoc_loc, fe_blkno = 0;
7896 @@ -532,8 +534,11 @@ static int ocfs2_mknod_locked(struct ocf
7897 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
7898 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
7899 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
7900 - fe->i_uid = cpu_to_le32(inode->i_uid);
7901 - fe->i_gid = cpu_to_le32(inode->i_gid);
7903 + tag = dx_current_fstag(osb->sb);
7904 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
7905 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
7906 + inode->i_tag = tag;
7907 fe->i_mode = cpu_to_le16(inode->i_mode);
7908 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
7909 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
7910 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/ocfs2_fs.h linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/ocfs2_fs.h
7911 --- linux-2.6.35/fs/ocfs2/ocfs2_fs.h 2010-08-02 16:52:51.000000000 +0200
7912 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/ocfs2_fs.h 2010-08-02 17:05:06.000000000 +0200
7913 @@ -235,18 +235,23 @@
7914 #define OCFS2_HAS_REFCOUNT_FL (0x0010)
7916 /* Inode attributes, keep in sync with EXT2 */
7917 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
7918 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
7919 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
7920 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
7921 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
7922 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
7923 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
7924 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
7925 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
7926 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
7927 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
7928 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
7929 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
7930 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
7931 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
7932 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
7933 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
7935 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
7936 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
7937 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
7938 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
7940 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
7941 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
7943 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
7944 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
7947 * Extent record flags (e_node.leaf.flags)
7948 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/ocfs2.h linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/ocfs2.h
7949 --- linux-2.6.35/fs/ocfs2/ocfs2.h 2010-08-02 16:52:51.000000000 +0200
7950 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/ocfs2.h 2010-08-02 17:05:06.000000000 +0200
7951 @@ -256,6 +256,7 @@ enum ocfs2_mount_options
7953 OCFS2_MOUNT_USRQUOTA = 1 << 10, /* We support user quotas */
7954 OCFS2_MOUNT_GRPQUOTA = 1 << 11, /* We support group quotas */
7955 + OCFS2_MOUNT_TAGGED = 1 << 12, /* use tagging */
7958 #define OCFS2_OSB_SOFT_RO 0x0001
7959 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/super.c linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/super.c
7960 --- linux-2.6.35/fs/ocfs2/super.c 2010-08-02 16:52:51.000000000 +0200
7961 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/super.c 2010-08-02 18:00:11.000000000 +0200
7962 @@ -180,6 +180,7 @@ enum {
7966 + Opt_tag, Opt_notag, Opt_tagid,
7970 @@ -208,6 +209,9 @@ static const match_table_t tokens = {
7971 {Opt_grpquota, "grpquota"},
7972 {Opt_resv_level, "resv_level=%u"},
7973 {Opt_dir_resv_level, "dir_resv_level=%u"},
7975 + {Opt_notag, "notag"},
7976 + {Opt_tagid, "tagid=%u"},
7980 @@ -618,6 +622,13 @@ static int ocfs2_remount(struct super_bl
7984 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
7985 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
7987 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
7991 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
7992 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
7994 @@ -1154,6 +1165,9 @@ static int ocfs2_fill_super(struct super
7996 ocfs2_complete_mount_recovery(osb);
7998 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
7999 + sb->s_flags |= MS_TAGGED;
8001 if (ocfs2_mount_local(osb))
8002 snprintf(nodestr, sizeof(nodestr), "local");
8004 @@ -1469,6 +1483,20 @@ static int ocfs2_parse_options(struct su
8005 option < OCFS2_MAX_RESV_LEVEL)
8006 mopt->dir_resv_level = option;
8008 +#ifndef CONFIG_TAGGING_NONE
8010 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8013 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
8016 +#ifdef CONFIG_PROPAGATE
8019 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8024 "Unrecognized mount option \"%s\" "
8025 diff -NurpP --minimal linux-2.6.35/fs/open.c linux-2.6.35-vs2.3.0.36.31/fs/open.c
8026 --- linux-2.6.35/fs/open.c 2010-08-02 16:52:51.000000000 +0200
8027 +++ linux-2.6.35-vs2.3.0.36.31/fs/open.c 2010-08-02 21:36:22.000000000 +0200
8029 #include <linux/falloc.h>
8030 #include <linux/fs_struct.h>
8031 #include <linux/ima.h>
8032 +#include <linux/vs_base.h>
8033 +#include <linux/vs_limit.h>
8034 +#include <linux/vs_tag.h>
8035 +#include <linux/vs_cowbl.h>
8036 +#include <linux/vserver/dlimit.h>
8038 #include "internal.h"
8040 @@ -481,6 +486,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
8041 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
8045 +#ifdef CONFIG_VSERVER_COWBL
8046 + error = cow_check_and_break(&path);
8048 + goto dput_and_out;
8050 inode = path.dentry->d_inode;
8052 error = mnt_want_write(path.mnt);
8053 @@ -518,11 +529,11 @@ static int chown_common(struct path *pat
8054 newattrs.ia_valid = ATTR_CTIME;
8055 if (user != (uid_t) -1) {
8056 newattrs.ia_valid |= ATTR_UID;
8057 - newattrs.ia_uid = user;
8058 + newattrs.ia_uid = dx_map_uid(user);
8060 if (group != (gid_t) -1) {
8061 newattrs.ia_valid |= ATTR_GID;
8062 - newattrs.ia_gid = group;
8063 + newattrs.ia_gid = dx_map_gid(group);
8065 if (!S_ISDIR(inode->i_mode))
8066 newattrs.ia_valid |=
8067 @@ -547,6 +558,10 @@ SYSCALL_DEFINE3(chown, const char __user
8068 error = mnt_want_write(path.mnt);
8071 +#ifdef CONFIG_VSERVER_COWBL
8072 + error = cow_check_and_break(&path);
8075 error = chown_common(&path, user, group);
8076 mnt_drop_write(path.mnt);
8078 @@ -572,6 +587,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
8079 error = mnt_want_write(path.mnt);
8082 +#ifdef CONFIG_VSERVER_COWBL
8083 + error = cow_check_and_break(&path);
8086 error = chown_common(&path, user, group);
8087 mnt_drop_write(path.mnt);
8089 @@ -591,6 +610,10 @@ SYSCALL_DEFINE3(lchown, const char __use
8090 error = mnt_want_write(path.mnt);
8093 +#ifdef CONFIG_VSERVER_COWBL
8094 + error = cow_check_and_break(&path);
8097 error = chown_common(&path, user, group);
8098 mnt_drop_write(path.mnt);
8100 @@ -837,6 +860,7 @@ static void __put_unused_fd(struct files
8101 __FD_CLR(fd, fdt->open_fds);
8102 if (fd < files->next_fd)
8103 files->next_fd = fd;
8104 + vx_openfd_dec(fd);
8107 void put_unused_fd(unsigned int fd)
8108 diff -NurpP --minimal linux-2.6.35/fs/proc/array.c linux-2.6.35-vs2.3.0.36.31/fs/proc/array.c
8109 --- linux-2.6.35/fs/proc/array.c 2010-08-02 16:52:51.000000000 +0200
8110 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/array.c 2010-08-02 17:05:06.000000000 +0200
8112 #include <linux/pid_namespace.h>
8113 #include <linux/ptrace.h>
8114 #include <linux/tracehook.h>
8115 +#include <linux/vs_context.h>
8116 +#include <linux/vs_network.h>
8118 #include <asm/pgtable.h>
8119 #include <asm/processor.h>
8120 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
8122 ppid = pid_alive(p) ?
8123 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
8124 + if (unlikely(vx_current_initpid(p->pid)))
8129 struct task_struct *tracer = tracehook_tracer_task(p);
8130 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
8133 static void render_cap_t(struct seq_file *m, const char *header,
8135 + struct vx_info *vxi, kernel_cap_t *a)
8139 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
8140 cap_bset = cred->cap_bset;
8143 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
8144 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
8145 - render_cap_t(m, "CapEff:\t", &cap_effective);
8146 - render_cap_t(m, "CapBnd:\t", &cap_bset);
8147 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
8148 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
8149 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
8150 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
8151 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
8154 static inline void task_context_switch_counts(struct seq_file *m,
8155 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
8156 seq_printf(m, "\n");
8159 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8160 + struct pid *pid, struct task_struct *task)
8162 + seq_printf(m, "Proxy:\t%p(%c)\n"
8170 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
8171 + atomic_read(&task->nsproxy->count),
8172 + task->nsproxy->uts_ns,
8173 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
8174 + task->nsproxy->ipc_ns,
8175 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
8176 + task->nsproxy->mnt_ns,
8177 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
8178 + task->nsproxy->pid_ns,
8179 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
8180 + task->nsproxy->net_ns,
8181 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
8185 +void task_vs_id(struct seq_file *m, struct task_struct *task)
8187 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8190 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
8191 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
8195 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
8196 struct pid *pid, struct task_struct *task)
8198 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
8200 task_cpus_allowed(m, task);
8201 cpuset_task_status_allowed(m, task);
8202 + task_vs_id(m, task);
8203 #if defined(CONFIG_S390)
8204 task_show_regs(m, task);
8206 @@ -465,6 +508,17 @@ static int do_task_stat(struct seq_file
8207 /* convert nsec -> ticks */
8208 start_time = nsec_to_clock_t(start_time);
8210 + /* fixup start time for virt uptime */
8211 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8212 + unsigned long long bias =
8213 + current->vx_info->cvirt.bias_clock;
8215 + if (start_time > bias)
8216 + start_time -= bias;
8221 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
8222 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8223 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
8224 diff -NurpP --minimal linux-2.6.35/fs/proc/base.c linux-2.6.35-vs2.3.0.36.31/fs/proc/base.c
8225 --- linux-2.6.35/fs/proc/base.c 2010-08-02 16:52:51.000000000 +0200
8226 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/base.c 2010-08-02 17:05:06.000000000 +0200
8228 #include <linux/pid_namespace.h>
8229 #include <linux/fs_struct.h>
8230 #include <linux/slab.h>
8231 +#include <linux/vs_context.h>
8232 +#include <linux/vs_network.h>
8233 #include "internal.h"
8236 @@ -1033,12 +1035,17 @@ static ssize_t oom_adjust_write(struct f
8240 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
8241 + if (oom_adjust < task->signal->oom_adj &&
8242 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
8243 unlock_task_sighand(task, &flags);
8244 put_task_struct(task);
8248 + /* prevent guest processes from circumventing the oom killer */
8249 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
8250 + oom_adjust = OOM_ADJUST_MIN;
8252 task->signal->oom_adj = oom_adjust;
8254 unlock_task_sighand(task, &flags);
8255 @@ -1079,7 +1086,7 @@ static ssize_t proc_loginuid_write(struc
8259 - if (!capable(CAP_AUDIT_CONTROL))
8260 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
8264 @@ -1517,6 +1524,8 @@ static struct inode *proc_pid_make_inode
8265 inode->i_gid = cred->egid;
8268 + /* procfs is xid tagged */
8269 + inode->i_tag = (tag_t)vx_task_xid(task);
8270 security_task_to_inode(task, inode);
8273 @@ -2067,6 +2076,13 @@ static struct dentry *proc_pident_lookup
8277 + /* TODO: maybe we can come up with a generic approach? */
8278 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8279 + (dentry->d_name.len == 5) &&
8280 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8281 + !memcmp(dentry->d_name.name, "ninfo", 5)))
8285 * Yes, it does not scale. And it should not. Don't add
8286 * new entries into /proc/<tgid>/ without very good reasons.
8287 @@ -2474,7 +2490,7 @@ out_iput:
8288 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8290 struct dentry *error;
8291 - struct task_struct *task = get_proc_task(dir);
8292 + struct task_struct *task = get_proc_task_real(dir);
8293 const struct pid_entry *p, *last;
8295 error = ERR_PTR(-ENOENT);
8296 @@ -2564,6 +2580,9 @@ static int proc_pid_personality(struct s
8297 static const struct file_operations proc_task_operations;
8298 static const struct inode_operations proc_task_inode_operations;
8300 +extern int proc_pid_vx_info(struct task_struct *, char *);
8301 +extern int proc_pid_nx_info(struct task_struct *, char *);
8303 static const struct pid_entry tgid_base_stuff[] = {
8304 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
8305 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
8306 @@ -2623,6 +2642,8 @@ static const struct pid_entry tgid_base_
8307 #ifdef CONFIG_CGROUPS
8308 REG("cgroup", S_IRUGO, proc_cgroup_operations),
8310 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
8311 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
8312 INF("oom_score", S_IRUGO, proc_oom_score),
8313 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
8314 #ifdef CONFIG_AUDITSYSCALL
8315 @@ -2638,6 +2659,7 @@ static const struct pid_entry tgid_base_
8316 #ifdef CONFIG_TASK_IO_ACCOUNTING
8317 INF("io", S_IRUGO, proc_tgid_io_accounting),
8319 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
8322 static int proc_tgid_base_readdir(struct file * filp,
8323 @@ -2829,7 +2851,7 @@ retry:
8325 pid = find_ge_pid(iter.tgid, ns);
8327 - iter.tgid = pid_nr_ns(pid, ns);
8328 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
8329 iter.task = pid_task(pid, PIDTYPE_PID);
8330 /* What we to know is if the pid we have find is the
8331 * pid of a thread_group_leader. Testing for task
8332 @@ -2859,7 +2881,7 @@ static int proc_pid_fill_cache(struct fi
8333 struct tgid_iter iter)
8335 char name[PROC_NUMBUF];
8336 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
8337 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
8338 return proc_fill_cache(filp, dirent, filldir, name, len,
8339 proc_pid_instantiate, iter.task, NULL);
8341 @@ -2868,7 +2890,7 @@ static int proc_pid_fill_cache(struct fi
8342 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
8344 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8345 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
8346 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8347 struct tgid_iter iter;
8348 struct pid_namespace *ns;
8350 @@ -2888,6 +2910,8 @@ int proc_pid_readdir(struct file * filp,
8352 iter.tgid += 1, iter = next_tgid(ns, iter)) {
8353 filp->f_pos = iter.tgid + TGID_OFFSET;
8354 + if (!vx_proc_task_visible(iter.task))
8356 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
8357 put_task_struct(iter.task);
8359 @@ -3035,6 +3059,8 @@ static struct dentry *proc_task_lookup(s
8360 tid = name_to_int(dentry);
8363 + if (vx_current_initpid(tid))
8366 ns = dentry->d_sb->s_fs_info;
8368 diff -NurpP --minimal linux-2.6.35/fs/proc/generic.c linux-2.6.35-vs2.3.0.36.31/fs/proc/generic.c
8369 --- linux-2.6.35/fs/proc/generic.c 2010-08-02 16:52:51.000000000 +0200
8370 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/generic.c 2010-08-02 17:05:06.000000000 +0200
8372 #include <linux/bitops.h>
8373 #include <linux/spinlock.h>
8374 #include <linux/completion.h>
8375 +#include <linux/vserver/inode.h>
8376 #include <asm/uaccess.h>
8378 #include "internal.h"
8379 @@ -418,6 +419,8 @@ struct dentry *proc_lookup_de(struct pro
8380 for (de = de->subdir; de ; de = de->next) {
8381 if (de->namelen != dentry->d_name.len)
8383 + if (!vx_hide_check(0, de->vx_flags))
8385 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
8388 @@ -426,6 +429,8 @@ struct dentry *proc_lookup_de(struct pro
8389 spin_unlock(&proc_subdir_lock);
8391 inode = proc_get_inode(dir->i_sb, ino, de);
8392 + /* generic proc entries belong to the host */
8397 @@ -503,6 +508,8 @@ int proc_readdir_de(struct proc_dir_entr
8399 /* filldir passes info to user space */
8401 + if (!vx_hide_check(0, de->vx_flags))
8403 spin_unlock(&proc_subdir_lock);
8404 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8405 de->low_ino, de->mode >> 12) < 0) {
8406 @@ -510,6 +517,7 @@ int proc_readdir_de(struct proc_dir_entr
8409 spin_lock(&proc_subdir_lock);
8414 @@ -624,6 +632,7 @@ static struct proc_dir_entry *__proc_cre
8416 atomic_set(&ent->count, 1);
8418 + ent->vx_flags = IATTR_PROC_DEFAULT;
8419 spin_lock_init(&ent->pde_unload_lock);
8420 ent->pde_unload_completion = NULL;
8421 INIT_LIST_HEAD(&ent->pde_openers);
8422 @@ -647,7 +656,8 @@ struct proc_dir_entry *proc_symlink(cons
8428 + ent->vx_flags = IATTR_PROC_SYMLINK;
8432 diff -NurpP --minimal linux-2.6.35/fs/proc/inode.c linux-2.6.35-vs2.3.0.36.31/fs/proc/inode.c
8433 --- linux-2.6.35/fs/proc/inode.c 2010-08-02 16:52:51.000000000 +0200
8434 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/inode.c 2010-08-02 17:05:06.000000000 +0200
8435 @@ -437,6 +437,8 @@ struct inode *proc_get_inode(struct supe
8436 inode->i_uid = de->uid;
8437 inode->i_gid = de->gid;
8440 + PROC_I(inode)->vx_flags = de->vx_flags;
8442 inode->i_size = de->size;
8444 diff -NurpP --minimal linux-2.6.35/fs/proc/internal.h linux-2.6.35-vs2.3.0.36.31/fs/proc/internal.h
8445 --- linux-2.6.35/fs/proc/internal.h 2010-02-25 11:52:06.000000000 +0100
8446 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/internal.h 2010-08-02 17:05:06.000000000 +0200
8450 #include <linux/proc_fs.h>
8451 +#include <linux/vs_pid.h>
8453 extern struct proc_dir_entry proc_root;
8454 #ifdef CONFIG_PROC_SYSCTL
8455 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
8456 struct pid *pid, struct task_struct *task);
8457 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
8458 struct pid *pid, struct task_struct *task);
8459 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8460 + struct pid *pid, struct task_struct *task);
8462 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
8464 extern const struct file_operations proc_maps_operations;
8465 @@ -68,11 +72,16 @@ static inline struct pid *proc_pid(struc
8466 return PROC_I(inode)->pid;
8469 -static inline struct task_struct *get_proc_task(struct inode *inode)
8470 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
8472 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
8475 +static inline struct task_struct *get_proc_task(struct inode *inode)
8477 + return vx_get_proc_task(inode, proc_pid(inode));
8480 static inline int proc_fd(struct inode *inode)
8482 return PROC_I(inode)->fd;
8483 diff -NurpP --minimal linux-2.6.35/fs/proc/loadavg.c linux-2.6.35-vs2.3.0.36.31/fs/proc/loadavg.c
8484 --- linux-2.6.35/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
8485 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/loadavg.c 2010-08-02 17:05:06.000000000 +0200
8488 static int loadavg_proc_show(struct seq_file *m, void *v)
8490 + unsigned long running;
8491 + unsigned int threads;
8492 unsigned long avnrun[3];
8494 get_avenrun(avnrun, FIXED_1/200, 0);
8496 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
8497 + struct vx_info *vxi = current_vx_info();
8499 + running = atomic_read(&vxi->cvirt.nr_running);
8500 + threads = atomic_read(&vxi->cvirt.nr_threads);
8502 + running = nr_running();
8503 + threads = nr_threads;
8506 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
8507 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
8508 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
8509 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
8510 - nr_running(), nr_threads,
8512 task_active_pid_ns(current)->last_pid);
8515 diff -NurpP --minimal linux-2.6.35/fs/proc/meminfo.c linux-2.6.35-vs2.3.0.36.31/fs/proc/meminfo.c
8516 --- linux-2.6.35/fs/proc/meminfo.c 2009-12-03 20:02:53.000000000 +0100
8517 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/meminfo.c 2010-08-02 17:05:06.000000000 +0200
8518 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
8519 allowed = ((totalram_pages - hugetlb_total_pages())
8520 * sysctl_overcommit_ratio / 100) + total_swap_pages;
8522 - cached = global_page_state(NR_FILE_PAGES) -
8523 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
8524 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
8525 total_swapcache_pages - i.bufferram;
8528 diff -NurpP --minimal linux-2.6.35/fs/proc/root.c linux-2.6.35-vs2.3.0.36.31/fs/proc/root.c
8529 --- linux-2.6.35/fs/proc/root.c 2010-08-02 16:52:51.000000000 +0200
8530 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/root.c 2010-08-02 17:05:06.000000000 +0200
8532 #include <linux/bitops.h>
8533 #include <linux/mount.h>
8534 #include <linux/pid_namespace.h>
8535 +#include <linux/vserver/inode.h>
8537 #include "internal.h"
8539 +struct proc_dir_entry *proc_virtual;
8541 +extern void proc_vx_init(void);
8543 static int proc_test_super(struct super_block *sb, void *data)
8545 return sb->s_fs_info == data;
8546 @@ -135,6 +140,7 @@ void __init proc_root_init(void)
8548 proc_mkdir("bus", NULL);
8553 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
8554 @@ -202,6 +208,7 @@ struct proc_dir_entry proc_root = {
8555 .proc_iops = &proc_root_inode_operations,
8556 .proc_fops = &proc_root_operations,
8557 .parent = &proc_root,
8558 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
8561 int pid_ns_prepare_proc(struct pid_namespace *ns)
8562 diff -NurpP --minimal linux-2.6.35/fs/proc/uptime.c linux-2.6.35-vs2.3.0.36.31/fs/proc/uptime.c
8563 --- linux-2.6.35/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
8564 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/uptime.c 2010-08-02 17:05:06.000000000 +0200
8566 #include <linux/sched.h>
8567 #include <linux/seq_file.h>
8568 #include <linux/time.h>
8569 -#include <linux/kernel_stat.h>
8570 +#include <linux/vserver/cvirt.h>
8571 #include <asm/cputime.h>
8573 static int uptime_proc_show(struct seq_file *m, void *v)
8575 struct timespec uptime;
8576 struct timespec idle;
8578 - cputime_t idletime = cputime_zero;
8580 - for_each_possible_cpu(i)
8581 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
8582 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
8584 do_posix_clock_monotonic_gettime(&uptime);
8585 monotonic_to_bootbased(&uptime);
8586 cputime_to_timespec(idletime, &idle);
8588 + if (vx_flags(VXF_VIRT_UPTIME, 0))
8589 + vx_vsi_uptime(&uptime, &idle);
8591 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
8592 (unsigned long) uptime.tv_sec,
8593 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
8594 diff -NurpP --minimal linux-2.6.35/fs/quota/dquot.c linux-2.6.35-vs2.3.0.36.31/fs/quota/dquot.c
8595 --- linux-2.6.35/fs/quota/dquot.c 2010-08-02 16:52:51.000000000 +0200
8596 +++ linux-2.6.35-vs2.3.0.36.31/fs/quota/dquot.c 2010-08-02 22:36:48.000000000 +0200
8597 @@ -1503,6 +1503,9 @@ int __dquot_alloc_space(struct inode *in
8598 int reserve = flags & DQUOT_SPACE_RESERVE;
8599 int nofail = flags & DQUOT_SPACE_NOFAIL;
8601 + if ((ret = dl_alloc_space(inode, number)))
8605 * First test before acquiring mutex - solves deadlocks when we
8606 * re-enter the quota code and are already holding the mutex
8607 @@ -1557,6 +1560,9 @@ int dquot_alloc_inode(const struct inode
8609 char warntype[MAXQUOTAS];
8611 + if ((ret = dl_alloc_inode(inode)))
8614 /* First test before acquiring mutex - solves deadlocks when we
8615 * re-enter the quota code and are already holding the mutex */
8616 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
8617 @@ -1627,6 +1633,8 @@ void __dquot_free_space(struct inode *in
8618 char warntype[MAXQUOTAS];
8619 int reserve = flags & DQUOT_SPACE_RESERVE;
8621 + dl_free_space(inode, number);
8623 /* First test before acquiring mutex - solves deadlocks when we
8624 * re-enter the quota code and are already holding the mutex */
8625 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
8626 @@ -1665,6 +1673,8 @@ void dquot_free_inode(const struct inode
8628 char warntype[MAXQUOTAS];
8630 + dl_free_inode(inode);
8632 /* First test before acquiring mutex - solves deadlocks when we
8633 * re-enter the quota code and are already holding the mutex */
8634 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
8635 diff -NurpP --minimal linux-2.6.35/fs/quota/quota.c linux-2.6.35-vs2.3.0.36.31/fs/quota/quota.c
8636 --- linux-2.6.35/fs/quota/quota.c 2010-08-02 16:52:51.000000000 +0200
8637 +++ linux-2.6.35-vs2.3.0.36.31/fs/quota/quota.c 2010-08-02 17:05:06.000000000 +0200
8639 #include <linux/fs.h>
8640 #include <linux/namei.h>
8641 #include <linux/slab.h>
8642 +#include <linux/vs_context.h>
8643 #include <asm/current.h>
8644 #include <asm/uaccess.h>
8645 #include <linux/kernel.h>
8646 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
8650 - if (!capable(CAP_SYS_ADMIN))
8651 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8655 @@ -296,6 +297,46 @@ static int do_quotactl(struct super_bloc
8659 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8661 +#include <linux/vroot.h>
8662 +#include <linux/major.h>
8663 +#include <linux/module.h>
8664 +#include <linux/kallsyms.h>
8665 +#include <linux/vserver/debug.h>
8667 +static vroot_grb_func *vroot_get_real_bdev = NULL;
8669 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
8671 +int register_vroot_grb(vroot_grb_func *func) {
8674 + spin_lock(&vroot_grb_lock);
8675 + if (!vroot_get_real_bdev) {
8676 + vroot_get_real_bdev = func;
8679 + spin_unlock(&vroot_grb_lock);
8682 +EXPORT_SYMBOL(register_vroot_grb);
8684 +int unregister_vroot_grb(vroot_grb_func *func) {
8685 + int ret = -EINVAL;
8687 + spin_lock(&vroot_grb_lock);
8688 + if (vroot_get_real_bdev) {
8689 + vroot_get_real_bdev = NULL;
8692 + spin_unlock(&vroot_grb_lock);
8695 +EXPORT_SYMBOL(unregister_vroot_grb);
8700 * look up a superblock on which quota ops will be performed
8701 * - use the name of a block device to find the superblock thereon
8702 @@ -313,6 +354,22 @@ static struct super_block *quotactl_bloc
8705 return ERR_CAST(bdev);
8706 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8707 + if (bdev && bdev->bd_inode &&
8708 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
8709 + struct block_device *bdnew = (void *)-EINVAL;
8711 + if (vroot_get_real_bdev)
8712 + bdnew = vroot_get_real_bdev(bdev);
8714 + vxdprintk(VXD_CBIT(misc, 0),
8715 + "vroot_get_real_bdev not set");
8717 + if (IS_ERR(bdnew))
8718 + return ERR_PTR(PTR_ERR(bdnew));
8722 sb = get_super(bdev);
8725 diff -NurpP --minimal linux-2.6.35/fs/reiserfs/file.c linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/file.c
8726 --- linux-2.6.35/fs/reiserfs/file.c 2010-08-02 16:52:52.000000000 +0200
8727 +++ linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/file.c 2010-08-02 17:05:06.000000000 +0200
8728 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
8729 .listxattr = reiserfs_listxattr,
8730 .removexattr = reiserfs_removexattr,
8731 .permission = reiserfs_permission,
8732 + .sync_flags = reiserfs_sync_flags,
8734 diff -NurpP --minimal linux-2.6.35/fs/reiserfs/inode.c linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/inode.c
8735 --- linux-2.6.35/fs/reiserfs/inode.c 2010-08-02 16:52:52.000000000 +0200
8736 +++ linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/inode.c 2010-08-02 17:05:06.000000000 +0200
8738 #include <linux/writeback.h>
8739 #include <linux/quotaops.h>
8740 #include <linux/swap.h>
8741 +#include <linux/vs_tag.h>
8743 int reiserfs_commit_write(struct file *f, struct page *page,
8744 unsigned from, unsigned to);
8745 @@ -1125,6 +1126,8 @@ static void init_inode(struct inode *ino
8746 struct buffer_head *bh;
8747 struct item_head *ih;
8751 //int version = ITEM_VERSION_1;
8753 bh = PATH_PLAST_BUFFER(path);
8754 @@ -1146,12 +1149,13 @@ static void init_inode(struct inode *ino
8755 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
8756 unsigned long blocks;
8758 + uid = sd_v1_uid(sd);
8759 + gid = sd_v1_gid(sd);
8761 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
8762 set_inode_sd_version(inode, STAT_DATA_V1);
8763 inode->i_mode = sd_v1_mode(sd);
8764 inode->i_nlink = sd_v1_nlink(sd);
8765 - inode->i_uid = sd_v1_uid(sd);
8766 - inode->i_gid = sd_v1_gid(sd);
8767 inode->i_size = sd_v1_size(sd);
8768 inode->i_atime.tv_sec = sd_v1_atime(sd);
8769 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
8770 @@ -1193,11 +1197,12 @@ static void init_inode(struct inode *ino
8771 // (directories and symlinks)
8772 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
8774 + uid = sd_v2_uid(sd);
8775 + gid = sd_v2_gid(sd);
8777 inode->i_mode = sd_v2_mode(sd);
8778 inode->i_nlink = sd_v2_nlink(sd);
8779 - inode->i_uid = sd_v2_uid(sd);
8780 inode->i_size = sd_v2_size(sd);
8781 - inode->i_gid = sd_v2_gid(sd);
8782 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
8783 inode->i_atime.tv_sec = sd_v2_atime(sd);
8784 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
8785 @@ -1227,6 +1232,10 @@ static void init_inode(struct inode *ino
8786 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
8789 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8790 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8791 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
8794 if (S_ISREG(inode->i_mode)) {
8795 inode->i_op = &reiserfs_file_inode_operations;
8796 @@ -1249,13 +1258,15 @@ static void init_inode(struct inode *ino
8797 static void inode2sd(void *sd, struct inode *inode, loff_t size)
8799 struct stat_data *sd_v2 = (struct stat_data *)sd;
8800 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
8801 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
8804 + set_sd_v2_uid(sd_v2, uid);
8805 + set_sd_v2_gid(sd_v2, gid);
8806 set_sd_v2_mode(sd_v2, inode->i_mode);
8807 set_sd_v2_nlink(sd_v2, inode->i_nlink);
8808 - set_sd_v2_uid(sd_v2, inode->i_uid);
8809 set_sd_v2_size(sd_v2, size);
8810 - set_sd_v2_gid(sd_v2, inode->i_gid);
8811 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
8812 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
8813 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
8814 @@ -2856,14 +2867,19 @@ int reiserfs_commit_write(struct file *f
8815 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
8817 if (reiserfs_attrs(inode->i_sb)) {
8818 - if (sd_attrs & REISERFS_SYNC_FL)
8819 - inode->i_flags |= S_SYNC;
8821 - inode->i_flags &= ~S_SYNC;
8822 if (sd_attrs & REISERFS_IMMUTABLE_FL)
8823 inode->i_flags |= S_IMMUTABLE;
8825 inode->i_flags &= ~S_IMMUTABLE;
8826 + if (sd_attrs & REISERFS_IXUNLINK_FL)
8827 + inode->i_flags |= S_IXUNLINK;
8829 + inode->i_flags &= ~S_IXUNLINK;
8831 + if (sd_attrs & REISERFS_SYNC_FL)
8832 + inode->i_flags |= S_SYNC;
8834 + inode->i_flags &= ~S_SYNC;
8835 if (sd_attrs & REISERFS_APPEND_FL)
8836 inode->i_flags |= S_APPEND;
8838 @@ -2876,6 +2892,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
8839 REISERFS_I(inode)->i_flags |= i_nopack_mask;
8841 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
8843 + if (sd_attrs & REISERFS_BARRIER_FL)
8844 + inode->i_vflags |= V_BARRIER;
8846 + inode->i_vflags &= ~V_BARRIER;
8847 + if (sd_attrs & REISERFS_COW_FL)
8848 + inode->i_vflags |= V_COW;
8850 + inode->i_vflags &= ~V_COW;
8854 @@ -2886,6 +2911,11 @@ void i_attrs_to_sd_attrs(struct inode *i
8855 *sd_attrs |= REISERFS_IMMUTABLE_FL;
8857 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
8858 + if (inode->i_flags & S_IXUNLINK)
8859 + *sd_attrs |= REISERFS_IXUNLINK_FL;
8861 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
8863 if (inode->i_flags & S_SYNC)
8864 *sd_attrs |= REISERFS_SYNC_FL;
8866 @@ -2898,6 +2928,15 @@ void i_attrs_to_sd_attrs(struct inode *i
8867 *sd_attrs |= REISERFS_NOTAIL_FL;
8869 *sd_attrs &= ~REISERFS_NOTAIL_FL;
8871 + if (inode->i_vflags & V_BARRIER)
8872 + *sd_attrs |= REISERFS_BARRIER_FL;
8874 + *sd_attrs &= ~REISERFS_BARRIER_FL;
8875 + if (inode->i_vflags & V_COW)
8876 + *sd_attrs |= REISERFS_COW_FL;
8878 + *sd_attrs &= ~REISERFS_COW_FL;
8882 @@ -3122,9 +3161,11 @@ int reiserfs_setattr(struct dentry *dent
8885 error = inode_change_ok(inode, attr);
8888 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
8889 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
8890 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
8891 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
8892 error = reiserfs_chown_xattrs(inode, attr);
8895 @@ -3153,6 +3194,9 @@ int reiserfs_setattr(struct dentry *dent
8896 inode->i_uid = attr->ia_uid;
8897 if (attr->ia_valid & ATTR_GID)
8898 inode->i_gid = attr->ia_gid;
8899 + if ((attr->ia_valid & ATTR_TAG) &&
8901 + inode->i_tag = attr->ia_tag;
8902 mark_inode_dirty(inode);
8904 journal_end(&th, inode->i_sb, jbegin_count);
8905 diff -NurpP --minimal linux-2.6.35/fs/reiserfs/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/ioctl.c
8906 --- linux-2.6.35/fs/reiserfs/ioctl.c 2010-02-25 11:52:06.000000000 +0100
8907 +++ linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/ioctl.c 2010-08-02 17:05:06.000000000 +0200
8909 #include <linux/mount.h>
8910 #include <linux/reiserfs_fs.h>
8911 #include <linux/time.h>
8912 +#include <linux/mount.h>
8913 #include <asm/uaccess.h>
8914 #include <linux/pagemap.h>
8915 #include <linux/smp_lock.h>
8916 #include <linux/compat.h>
8919 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
8921 + __u16 sd_attrs = 0;
8923 + inode->i_flags = flags;
8924 + inode->i_vflags = vflags;
8926 + i_attrs_to_sd_attrs(inode, &sd_attrs);
8927 + REISERFS_I(inode)->i_attrs = sd_attrs;
8928 + inode->i_ctime = CURRENT_TIME_SEC;
8929 + mark_inode_dirty(inode);
8934 * reiserfs_ioctl - handler for ioctl for inode
8935 * supported commands:
8937 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
8939 struct inode *inode = filp->f_path.dentry->d_inode;
8940 - unsigned int flags;
8941 + unsigned int flags, oldflags;
8944 reiserfs_write_lock(inode->i_sb);
8945 @@ -48,6 +64,7 @@ long reiserfs_ioctl(struct file *filp, u
8947 flags = REISERFS_I(inode)->i_attrs;
8948 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
8949 + flags &= REISERFS_FL_USER_VISIBLE;
8950 err = put_user(flags, (int __user *)arg);
8952 case REISERFS_IOC_SETFLAGS:{
8953 @@ -68,6 +85,10 @@ long reiserfs_ioctl(struct file *filp, u
8957 + if (IS_BARRIER(inode)) {
8958 + vxwprintk_task(1, "messing with the barrier.");
8962 * Is it quota file? Do not allow user to mess with it
8964 @@ -92,6 +113,10 @@ long reiserfs_ioctl(struct file *filp, u
8969 + oldflags = REISERFS_I(inode)->i_attrs;
8970 + flags &= REISERFS_FL_USER_MODIFIABLE;
8971 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
8972 sd_attrs_to_i_attrs(flags, inode);
8973 REISERFS_I(inode)->i_attrs = flags;
8974 inode->i_ctime = CURRENT_TIME_SEC;
8975 diff -NurpP --minimal linux-2.6.35/fs/reiserfs/namei.c linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/namei.c
8976 --- linux-2.6.35/fs/reiserfs/namei.c 2010-08-02 16:52:52.000000000 +0200
8977 +++ linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/namei.c 2010-08-02 17:05:06.000000000 +0200
8979 #include <linux/reiserfs_acl.h>
8980 #include <linux/reiserfs_xattr.h>
8981 #include <linux/quotaops.h>
8982 +#include <linux/vs_tag.h>
8984 #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; }
8985 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
8986 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
8987 if (retval == IO_ERROR) {
8988 return ERR_PTR(-EIO);
8990 + dx_propagate_tag(nd, inode);
8992 return d_splice_alias(inode, dentry);
8994 @@ -1532,6 +1534,7 @@ const struct inode_operations reiserfs_d
8995 .listxattr = reiserfs_listxattr,
8996 .removexattr = reiserfs_removexattr,
8997 .permission = reiserfs_permission,
8998 + .sync_flags = reiserfs_sync_flags,
9002 diff -NurpP --minimal linux-2.6.35/fs/reiserfs/super.c linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/super.c
9003 --- linux-2.6.35/fs/reiserfs/super.c 2010-08-02 16:52:52.000000000 +0200
9004 +++ linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/super.c 2010-08-02 17:05:06.000000000 +0200
9005 @@ -897,6 +897,14 @@ static int reiserfs_parse_options(struct
9006 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9007 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9009 +#ifndef CONFIG_TAGGING_NONE
9010 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9011 + {"tag",.setmask = 1 << REISERFS_TAGGED},
9012 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
9014 +#ifdef CONFIG_PROPAGATE
9015 + {"tag",.arg_required = 'T',.values = NULL},
9017 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9018 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9019 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9020 @@ -1206,6 +1214,14 @@ static int reiserfs_remount(struct super
9021 handle_quota_files(s, qf_names, &qfmt);
9024 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
9025 + !(s->s_flags & MS_TAGGED)) {
9026 + reiserfs_warning(s, "super-vs01",
9027 + "reiserfs: tagging not permitted on remount.");
9034 /* Add options that are safe here */
9035 @@ -1688,6 +1704,10 @@ static int reiserfs_fill_super(struct su
9039 + /* map mount option tagxid */
9040 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9041 + s->s_flags |= MS_TAGGED;
9043 rs = SB_DISK_SUPER_BLOCK(s);
9044 /* Let's do basic sanity check to verify that underlying device is not
9045 smaller than the filesystem. If the check fails then abort and scream,
9046 diff -NurpP --minimal linux-2.6.35/fs/reiserfs/xattr.c linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/xattr.c
9047 --- linux-2.6.35/fs/reiserfs/xattr.c 2010-08-02 16:52:52.000000000 +0200
9048 +++ linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/xattr.c 2010-08-02 17:05:06.000000000 +0200
9050 #include <linux/errno.h>
9051 #include <linux/gfp.h>
9052 #include <linux/fs.h>
9053 +#include <linux/mount.h>
9054 #include <linux/file.h>
9055 #include <linux/pagemap.h>
9056 #include <linux/xattr.h>
9057 diff -NurpP --minimal linux-2.6.35/fs/stat.c linux-2.6.35-vs2.3.0.36.31/fs/stat.c
9058 --- linux-2.6.35/fs/stat.c 2010-02-25 11:52:06.000000000 +0100
9059 +++ linux-2.6.35-vs2.3.0.36.31/fs/stat.c 2010-08-02 17:05:06.000000000 +0200
9060 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9061 stat->nlink = inode->i_nlink;
9062 stat->uid = inode->i_uid;
9063 stat->gid = inode->i_gid;
9064 + stat->tag = inode->i_tag;
9065 stat->rdev = inode->i_rdev;
9066 stat->atime = inode->i_atime;
9067 stat->mtime = inode->i_mtime;
9068 diff -NurpP --minimal linux-2.6.35/fs/statfs.c linux-2.6.35-vs2.3.0.36.31/fs/statfs.c
9069 --- linux-2.6.35/fs/statfs.c 2010-08-02 16:52:52.000000000 +0200
9070 +++ linux-2.6.35-vs2.3.0.36.31/fs/statfs.c 2010-08-02 19:10:27.000000000 +0200
9072 #include <linux/statfs.h>
9073 #include <linux/security.h>
9074 #include <linux/uaccess.h>
9075 +#include <linux/vs_base.h>
9076 +#include <linux/vs_dlimit.h>
9078 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
9080 int retval = -ENODEV;
9083 + struct super_block *sb = dentry->d_sb;
9086 - if (dentry->d_sb->s_op->statfs) {
9087 + if (sb->s_op->statfs) {
9088 memset(buf, 0, sizeof(*buf));
9089 retval = security_sb_statfs(dentry);
9092 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
9093 + retval = sb->s_op->statfs(dentry, buf);
9094 if (retval == 0 && buf->f_frsize == 0)
9095 buf->f_frsize = buf->f_bsize;
9097 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
9098 + vx_vsi_statfs(sb, buf);
9102 diff -NurpP --minimal linux-2.6.35/fs/super.c linux-2.6.35-vs2.3.0.36.31/fs/super.c
9103 --- linux-2.6.35/fs/super.c 2010-08-02 16:52:52.000000000 +0200
9104 +++ linux-2.6.35-vs2.3.0.36.31/fs/super.c 2010-08-02 17:59:27.000000000 +0200
9106 #include <linux/idr.h>
9107 #include <linux/mutex.h>
9108 #include <linux/backing-dev.h>
9109 +#include <linux/devpts_fs.h>
9110 +#include <linux/proc_fs.h>
9111 +#include <linux/vs_context.h>
9112 #include "internal.h"
9115 @@ -880,12 +883,18 @@ struct vfsmount *
9116 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
9118 struct vfsmount *mnt;
9119 + struct super_block *sb;
9120 char *secdata = NULL;
9124 return ERR_PTR(-ENODEV);
9127 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
9128 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
9132 mnt = alloc_vfsmnt(name);
9134 @@ -907,10 +916,18 @@ vfs_kern_mount(struct file_system_type *
9135 error = type->get_sb(type, flags, name, data, mnt);
9137 goto out_free_secdata;
9138 - BUG_ON(!mnt->mnt_sb);
9139 - WARN_ON(!mnt->mnt_sb->s_bdi);
9141 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
9144 + WARN_ON(!sb->s_bdi);
9147 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
9148 + (sb->s_magic != PROC_SUPER_MAGIC) &&
9149 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
9152 + error = security_sb_kern_mount(sb, flags, secdata);
9156 diff -NurpP --minimal linux-2.6.35/fs/sysfs/mount.c linux-2.6.35-vs2.3.0.36.31/fs/sysfs/mount.c
9157 --- linux-2.6.35/fs/sysfs/mount.c 2010-08-02 16:52:52.000000000 +0200
9158 +++ linux-2.6.35-vs2.3.0.36.31/fs/sysfs/mount.c 2010-08-02 17:05:06.000000000 +0200
9159 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
9161 sb->s_blocksize = PAGE_CACHE_SIZE;
9162 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9163 - sb->s_magic = SYSFS_MAGIC;
9164 + sb->s_magic = SYSFS_SUPER_MAGIC;
9165 sb->s_op = &sysfs_ops;
9166 sb->s_time_gran = 1;
9168 diff -NurpP --minimal linux-2.6.35/fs/utimes.c linux-2.6.35-vs2.3.0.36.31/fs/utimes.c
9169 --- linux-2.6.35/fs/utimes.c 2009-03-24 14:22:37.000000000 +0100
9170 +++ linux-2.6.35-vs2.3.0.36.31/fs/utimes.c 2010-08-02 22:52:28.000000000 +0200
9172 #include <linux/stat.h>
9173 #include <linux/utime.h>
9174 #include <linux/syscalls.h>
9175 +#include <linux/mount.h>
9176 +#include <linux/vs_cowbl.h>
9177 #include <asm/uaccess.h>
9178 #include <asm/unistd.h>
9180 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
9183 struct iattr newattrs;
9184 - struct inode *inode = path->dentry->d_inode;
9185 + struct inode *inode;
9187 error = mnt_want_write(path->mnt);
9191 + error = cow_check_and_break(path);
9193 + goto mnt_drop_write_and_out;
9195 + inode = path->dentry->d_inode;
9197 if (times && times[0].tv_nsec == UTIME_NOW &&
9198 times[1].tv_nsec == UTIME_NOW)
9200 diff -NurpP --minimal linux-2.6.35/fs/xattr.c linux-2.6.35-vs2.3.0.36.31/fs/xattr.c
9201 --- linux-2.6.35/fs/xattr.c 2010-08-02 16:52:52.000000000 +0200
9202 +++ linux-2.6.35-vs2.3.0.36.31/fs/xattr.c 2010-08-02 17:05:06.000000000 +0200
9204 #include <linux/module.h>
9205 #include <linux/fsnotify.h>
9206 #include <linux/audit.h>
9207 +#include <linux/mount.h>
9208 #include <asm/uaccess.h>
9211 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
9212 * The trusted.* namespace can only be accessed by a privileged user.
9214 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
9215 - return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
9216 + return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
9218 /* In user.* namespace, only regular files and directories can have
9219 * extended attributes. For sticky directories, only the owner and
9220 diff -NurpP --minimal linux-2.6.35/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_ioctl.c
9221 --- linux-2.6.35/fs/xfs/linux-2.6/xfs_ioctl.c 2010-08-02 16:52:52.000000000 +0200
9222 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_ioctl.c 2010-08-02 17:05:06.000000000 +0200
9224 #include "xfs_dir2_sf.h"
9225 #include "xfs_dinode.h"
9226 #include "xfs_inode.h"
9227 -#include "xfs_ioctl.h"
9228 #include "xfs_btree.h"
9229 #include "xfs_ialloc.h"
9230 #include "xfs_rtalloc.h"
9231 @@ -747,6 +746,10 @@ xfs_merge_ioc_xflags(
9232 xflags |= XFS_XFLAG_IMMUTABLE;
9234 xflags &= ~XFS_XFLAG_IMMUTABLE;
9235 + if (flags & FS_IXUNLINK_FL)
9236 + xflags |= XFS_XFLAG_IXUNLINK;
9238 + xflags &= ~XFS_XFLAG_IXUNLINK;
9239 if (flags & FS_APPEND_FL)
9240 xflags |= XFS_XFLAG_APPEND;
9242 @@ -775,6 +778,8 @@ xfs_di2lxflags(
9244 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9245 flags |= FS_IMMUTABLE_FL;
9246 + if (di_flags & XFS_DIFLAG_IXUNLINK)
9247 + flags |= FS_IXUNLINK_FL;
9248 if (di_flags & XFS_DIFLAG_APPEND)
9249 flags |= FS_APPEND_FL;
9250 if (di_flags & XFS_DIFLAG_SYNC)
9251 @@ -833,6 +838,8 @@ xfs_set_diflags(
9252 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
9253 if (xflags & XFS_XFLAG_IMMUTABLE)
9254 di_flags |= XFS_DIFLAG_IMMUTABLE;
9255 + if (xflags & XFS_XFLAG_IXUNLINK)
9256 + di_flags |= XFS_DIFLAG_IXUNLINK;
9257 if (xflags & XFS_XFLAG_APPEND)
9258 di_flags |= XFS_DIFLAG_APPEND;
9259 if (xflags & XFS_XFLAG_SYNC)
9260 @@ -875,6 +882,10 @@ xfs_diflags_to_linux(
9261 inode->i_flags |= S_IMMUTABLE;
9263 inode->i_flags &= ~S_IMMUTABLE;
9264 + if (xflags & XFS_XFLAG_IXUNLINK)
9265 + inode->i_flags |= S_IXUNLINK;
9267 + inode->i_flags &= ~S_IXUNLINK;
9268 if (xflags & XFS_XFLAG_APPEND)
9269 inode->i_flags |= S_APPEND;
9271 @@ -1351,10 +1362,18 @@ xfs_file_ioctl(
9272 case XFS_IOC_FSGETXATTRA:
9273 return xfs_ioc_fsgetxattr(ip, 1, arg);
9274 case XFS_IOC_FSSETXATTR:
9275 + if (IS_BARRIER(inode)) {
9276 + vxwprintk_task(1, "messing with the barrier.");
9277 + return -XFS_ERROR(EACCES);
9279 return xfs_ioc_fssetxattr(ip, filp, arg);
9280 case XFS_IOC_GETXFLAGS:
9281 return xfs_ioc_getxflags(ip, arg);
9282 case XFS_IOC_SETXFLAGS:
9283 + if (IS_BARRIER(inode)) {
9284 + vxwprintk_task(1, "messing with the barrier.");
9285 + return -XFS_ERROR(EACCES);
9287 return xfs_ioc_setxflags(ip, filp, arg);
9289 case XFS_IOC_FSSETDM: {
9290 diff -NurpP --minimal linux-2.6.35/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_ioctl.h
9291 --- linux-2.6.35/fs/xfs/linux-2.6/xfs_ioctl.h 2010-07-07 18:31:54.000000000 +0200
9292 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_ioctl.h 2010-08-02 17:05:06.000000000 +0200
9293 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
9294 void __user *uhandle,
9299 + struct inode *inode,
9306 diff -NurpP --minimal linux-2.6.35/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_iops.c
9307 --- linux-2.6.35/fs/xfs/linux-2.6/xfs_iops.c 2010-08-02 16:52:52.000000000 +0200
9308 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_iops.c 2010-08-02 17:05:06.000000000 +0200
9310 #include "xfs_attr_sf.h"
9311 #include "xfs_dinode.h"
9312 #include "xfs_inode.h"
9313 +#include "xfs_ioctl.h"
9314 #include "xfs_bmap.h"
9315 #include "xfs_btree.h"
9316 #include "xfs_ialloc.h"
9318 #include <linux/falloc.h>
9319 #include <linux/fiemap.h>
9320 #include <linux/slab.h>
9321 +#include <linux/vs_tag.h>
9324 * Bring the timestamps in the XFS inode uptodate.
9325 @@ -507,6 +509,7 @@ xfs_vn_getattr(
9326 stat->nlink = ip->i_d.di_nlink;
9327 stat->uid = ip->i_d.di_uid;
9328 stat->gid = ip->i_d.di_gid;
9329 + stat->tag = ip->i_d.di_tag;
9330 stat->ino = ip->i_ino;
9331 stat->atime = inode->i_atime;
9332 stat->mtime = inode->i_mtime;
9333 @@ -711,6 +714,7 @@ static const struct inode_operations xfs
9334 .listxattr = xfs_vn_listxattr,
9335 .fallocate = xfs_vn_fallocate,
9336 .fiemap = xfs_vn_fiemap,
9337 + .sync_flags = xfs_sync_flags,
9340 static const struct inode_operations xfs_dir_inode_operations = {
9341 @@ -736,6 +740,7 @@ static const struct inode_operations xfs
9342 .getxattr = generic_getxattr,
9343 .removexattr = generic_removexattr,
9344 .listxattr = xfs_vn_listxattr,
9345 + .sync_flags = xfs_sync_flags,
9348 static const struct inode_operations xfs_dir_ci_inode_operations = {
9349 @@ -785,6 +790,10 @@ xfs_diflags_to_iflags(
9350 inode->i_flags |= S_IMMUTABLE;
9352 inode->i_flags &= ~S_IMMUTABLE;
9353 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
9354 + inode->i_flags |= S_IXUNLINK;
9356 + inode->i_flags &= ~S_IXUNLINK;
9357 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
9358 inode->i_flags |= S_APPEND;
9360 @@ -797,6 +806,15 @@ xfs_diflags_to_iflags(
9361 inode->i_flags |= S_NOATIME;
9363 inode->i_flags &= ~S_NOATIME;
9365 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
9366 + inode->i_vflags |= V_BARRIER;
9368 + inode->i_vflags &= ~V_BARRIER;
9369 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
9370 + inode->i_vflags |= V_COW;
9372 + inode->i_vflags &= ~V_COW;
9376 @@ -825,6 +843,7 @@ xfs_setup_inode(
9377 inode->i_nlink = ip->i_d.di_nlink;
9378 inode->i_uid = ip->i_d.di_uid;
9379 inode->i_gid = ip->i_d.di_gid;
9380 + inode->i_tag = ip->i_d.di_tag;
9382 switch (inode->i_mode & S_IFMT) {
9384 diff -NurpP --minimal linux-2.6.35/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_linux.h
9385 --- linux-2.6.35/fs/xfs/linux-2.6/xfs_linux.h 2010-07-07 18:31:54.000000000 +0200
9386 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_linux.h 2010-08-02 17:05:06.000000000 +0200
9389 #define current_cpu() (raw_smp_processor_id())
9390 #define current_pid() (current->pid)
9391 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
9392 #define current_test_flags(f) (current->flags & (f))
9393 #define current_set_flags_nested(sp, f) \
9394 (*(sp) = current->flags, current->flags |= (f))
9395 diff -NurpP --minimal linux-2.6.35/fs/xfs/linux-2.6/xfs_super.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_super.c
9396 --- linux-2.6.35/fs/xfs/linux-2.6/xfs_super.c 2010-08-02 16:52:52.000000000 +0200
9397 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_super.c 2010-08-02 18:00:35.000000000 +0200
9398 @@ -121,6 +121,9 @@ mempool_t *xfs_ioend_pool;
9399 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
9400 #define MNTOPT_DELAYLOG "delaylog" /* Delayed loging enabled */
9401 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed loging disabled */
9402 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
9403 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
9404 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
9407 * Table driven mount option parser.
9408 @@ -129,10 +132,14 @@ mempool_t *xfs_ioend_pool;
9409 * in the future, too.
9412 + Opt_tag, Opt_notag,
9413 Opt_barrier, Opt_nobarrier, Opt_err
9416 static const match_table_t tokens = {
9417 + {Opt_tag, "tagxid"},
9419 + {Opt_notag, "notag"},
9420 {Opt_barrier, "barrier"},
9421 {Opt_nobarrier, "nobarrier"},
9423 @@ -393,6 +400,19 @@ xfs_parseargs(
9424 } else if (!strcmp(this_char, "irixsgid")) {
9426 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
9427 +#ifndef CONFIG_TAGGING_NONE
9428 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9429 + mp->m_flags |= XFS_MOUNT_TAGGED;
9430 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
9431 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
9432 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
9433 + mp->m_flags |= XFS_MOUNT_TAGGED;
9435 +#ifdef CONFIG_PROPAGATE
9436 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9438 + mp->m_flags |= XFS_MOUNT_TAGGED;
9442 "XFS: unknown mount option [%s].", this_char);
9443 @@ -1376,6 +1396,16 @@ xfs_fs_remount(
9445 mp->m_flags &= ~XFS_MOUNT_BARRIER;
9448 + if (!(sb->s_flags & MS_TAGGED)) {
9450 + "XFS: %s: tagging not permitted on remount.\n",
9459 * Logically we would return an error here to prevent
9460 @@ -1610,6 +1640,9 @@ xfs_fs_fill_super(
9462 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
9464 + if (mp->m_flags & XFS_MOUNT_TAGGED)
9465 + sb->s_flags |= MS_TAGGED;
9467 sb->s_magic = XFS_SB_MAGIC;
9468 sb->s_blocksize = mp->m_sb.sb_blocksize;
9469 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
9470 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_dinode.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_dinode.h
9471 --- linux-2.6.35/fs/xfs/xfs_dinode.h 2009-06-11 17:13:09.000000000 +0200
9472 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_dinode.h 2010-08-02 17:05:06.000000000 +0200
9473 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
9474 __be32 di_gid; /* owner's group id */
9475 __be32 di_nlink; /* number of links to file */
9476 __be16 di_projid; /* owner's project id */
9477 - __u8 di_pad[8]; /* unused, zeroed space */
9478 + __be16 di_tag; /* context tagging */
9479 + __be16 di_vflags; /* vserver specific flags */
9480 + __u8 di_pad[4]; /* unused, zeroed space */
9481 __be16 di_flushiter; /* incremented on flush */
9482 xfs_timestamp_t di_atime; /* time last accessed */
9483 xfs_timestamp_t di_mtime; /* time last modified */
9484 @@ -183,6 +185,8 @@ static inline void xfs_dinode_put_rdev(s
9485 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
9486 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
9487 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
9488 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
9490 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
9491 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
9492 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
9493 @@ -198,6 +202,7 @@ static inline void xfs_dinode_put_rdev(s
9494 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
9495 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
9496 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
9497 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
9499 #ifdef CONFIG_XFS_RT
9500 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
9501 @@ -210,6 +215,10 @@ static inline void xfs_dinode_put_rdev(s
9502 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
9503 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
9504 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
9505 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
9506 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
9507 + XFS_DIFLAG_IXUNLINK)
9509 +#define XFS_DIVFLAG_BARRIER 0x01
9510 +#define XFS_DIVFLAG_COW 0x02
9512 #endif /* __XFS_DINODE_H__ */
9513 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_fs.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_fs.h
9514 --- linux-2.6.35/fs/xfs/xfs_fs.h 2010-07-07 18:31:54.000000000 +0200
9515 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_fs.h 2010-08-02 17:05:06.000000000 +0200
9516 @@ -67,6 +67,9 @@ struct fsxattr {
9517 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
9518 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
9519 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
9520 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
9521 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
9522 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
9523 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
9526 @@ -293,7 +296,8 @@ typedef struct xfs_bstat {
9527 __u32 bs_gen; /* generation count */
9528 __u16 bs_projid; /* project id */
9529 __u16 bs_forkoff; /* inode fork offset in bytes */
9530 - unsigned char bs_pad[12]; /* pad space, unused */
9531 + __u16 bs_tag; /* context tagging */
9532 + unsigned char bs_pad[10]; /* pad space, unused */
9533 __u32 bs_dmevmask; /* DMIG event mask */
9534 __u16 bs_dmstate; /* DMIG state info */
9535 __u16 bs_aextents; /* attribute number of extents */
9536 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_ialloc.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_ialloc.c
9537 --- linux-2.6.35/fs/xfs/xfs_ialloc.c 2010-08-02 16:52:53.000000000 +0200
9538 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_ialloc.c 2010-08-02 17:05:06.000000000 +0200
9540 #include "xfs_error.h"
9541 #include "xfs_bmap.h"
9545 * Allocation group level functions.
9547 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_inode.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_inode.c
9548 --- linux-2.6.35/fs/xfs/xfs_inode.c 2010-08-02 16:52:53.000000000 +0200
9549 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_inode.c 2010-08-02 17:05:06.000000000 +0200
9550 @@ -249,6 +249,7 @@ xfs_inotobp(
9554 +#include <linux/vs_tag.h>
9557 * This routine is called to map an inode to the buffer containing
9558 @@ -654,15 +655,25 @@ xfs_iformat_btree(
9560 xfs_dinode_from_disk(
9562 - xfs_dinode_t *from)
9563 + xfs_dinode_t *from,
9566 + uint32_t uid, gid, tag;
9568 to->di_magic = be16_to_cpu(from->di_magic);
9569 to->di_mode = be16_to_cpu(from->di_mode);
9570 to->di_version = from ->di_version;
9571 to->di_format = from->di_format;
9572 to->di_onlink = be16_to_cpu(from->di_onlink);
9573 - to->di_uid = be32_to_cpu(from->di_uid);
9574 - to->di_gid = be32_to_cpu(from->di_gid);
9576 + uid = be32_to_cpu(from->di_uid);
9577 + gid = be32_to_cpu(from->di_gid);
9578 + tag = be16_to_cpu(from->di_tag);
9580 + to->di_uid = INOTAG_UID(tagged, uid, gid);
9581 + to->di_gid = INOTAG_GID(tagged, uid, gid);
9582 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
9584 to->di_nlink = be32_to_cpu(from->di_nlink);
9585 to->di_projid = be16_to_cpu(from->di_projid);
9586 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
9587 @@ -683,21 +694,26 @@ xfs_dinode_from_disk(
9588 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
9589 to->di_dmstate = be16_to_cpu(from->di_dmstate);
9590 to->di_flags = be16_to_cpu(from->di_flags);
9591 + to->di_vflags = be16_to_cpu(from->di_vflags);
9592 to->di_gen = be32_to_cpu(from->di_gen);
9598 - xfs_icdinode_t *from)
9599 + xfs_icdinode_t *from,
9602 to->di_magic = cpu_to_be16(from->di_magic);
9603 to->di_mode = cpu_to_be16(from->di_mode);
9604 to->di_version = from ->di_version;
9605 to->di_format = from->di_format;
9606 to->di_onlink = cpu_to_be16(from->di_onlink);
9607 - to->di_uid = cpu_to_be32(from->di_uid);
9608 - to->di_gid = cpu_to_be32(from->di_gid);
9610 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
9611 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
9612 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
9614 to->di_nlink = cpu_to_be32(from->di_nlink);
9615 to->di_projid = cpu_to_be16(from->di_projid);
9616 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
9617 @@ -718,12 +734,14 @@ xfs_dinode_to_disk(
9618 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
9619 to->di_dmstate = cpu_to_be16(from->di_dmstate);
9620 to->di_flags = cpu_to_be16(from->di_flags);
9621 + to->di_vflags = cpu_to_be16(from->di_vflags);
9622 to->di_gen = cpu_to_be32(from->di_gen);
9627 - __uint16_t di_flags)
9628 + __uint16_t di_flags,
9629 + __uint16_t di_vflags)
9633 @@ -734,6 +752,8 @@ _xfs_dic2xflags(
9634 flags |= XFS_XFLAG_PREALLOC;
9635 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9636 flags |= XFS_XFLAG_IMMUTABLE;
9637 + if (di_flags & XFS_DIFLAG_IXUNLINK)
9638 + flags |= XFS_XFLAG_IXUNLINK;
9639 if (di_flags & XFS_DIFLAG_APPEND)
9640 flags |= XFS_XFLAG_APPEND;
9641 if (di_flags & XFS_DIFLAG_SYNC)
9642 @@ -758,6 +778,10 @@ _xfs_dic2xflags(
9643 flags |= XFS_XFLAG_FILESTREAM;
9646 + if (di_vflags & XFS_DIVFLAG_BARRIER)
9647 + flags |= FS_BARRIER_FL;
9648 + if (di_vflags & XFS_DIVFLAG_COW)
9649 + flags |= FS_COW_FL;
9653 @@ -767,7 +791,7 @@ xfs_ip2xflags(
9655 xfs_icdinode_t *dic = &ip->i_d;
9657 - return _xfs_dic2xflags(dic->di_flags) |
9658 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
9659 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
9662 @@ -775,7 +799,8 @@ uint
9666 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
9667 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
9668 + be16_to_cpu(dip->di_vflags)) |
9669 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
9672 @@ -808,7 +833,6 @@ xfs_iread(
9675 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
9678 * If we got something that isn't an inode it means someone
9679 * (nfs or dmi) has a stale handle.
9680 @@ -833,7 +857,8 @@ xfs_iread(
9681 * Otherwise, just get the truly permanent information.
9684 - xfs_dinode_from_disk(&ip->i_d, dip);
9685 + xfs_dinode_from_disk(&ip->i_d, dip,
9686 + mp->m_flags & XFS_MOUNT_TAGGED);
9687 error = xfs_iformat(ip, dip);
9690 @@ -1033,6 +1058,7 @@ xfs_ialloc(
9691 ASSERT(ip->i_d.di_nlink == nlink);
9692 ip->i_d.di_uid = current_fsuid();
9693 ip->i_d.di_gid = current_fsgid();
9694 + ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
9695 ip->i_d.di_projid = prid;
9696 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
9698 @@ -1093,6 +1119,7 @@ xfs_ialloc(
9699 ip->i_d.di_dmevmask = 0;
9700 ip->i_d.di_dmstate = 0;
9701 ip->i_d.di_flags = 0;
9702 + ip->i_d.di_vflags = 0;
9703 flags = XFS_ILOG_CORE;
9704 switch (mode & S_IFMT) {
9706 @@ -2116,6 +2143,7 @@ xfs_ifree(
9708 ip->i_d.di_mode = 0; /* mark incore inode as free */
9709 ip->i_d.di_flags = 0;
9710 + ip->i_d.di_vflags = 0;
9711 ip->i_d.di_dmevmask = 0;
9712 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
9713 ip->i_df.if_ext_max =
9714 @@ -2985,7 +3013,8 @@ xfs_iflush_int(
9715 * because if the inode is dirty at all the core must
9718 - xfs_dinode_to_disk(dip, &ip->i_d);
9719 + xfs_dinode_to_disk(dip, &ip->i_d,
9720 + mp->m_flags & XFS_MOUNT_TAGGED);
9722 /* Wrap, we never let the log put out DI_MAX_FLUSH */
9723 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
9724 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_inode.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_inode.h
9725 --- linux-2.6.35/fs/xfs/xfs_inode.h 2010-08-02 16:52:53.000000000 +0200
9726 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_inode.h 2010-08-02 17:05:06.000000000 +0200
9727 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
9728 __uint32_t di_gid; /* owner's group id */
9729 __uint32_t di_nlink; /* number of links to file */
9730 __uint16_t di_projid; /* owner's project id */
9731 - __uint8_t di_pad[8]; /* unused, zeroed space */
9732 + __uint16_t di_tag; /* context tagging */
9733 + __uint16_t di_vflags; /* vserver specific flags */
9734 + __uint8_t di_pad[4]; /* unused, zeroed space */
9735 __uint16_t di_flushiter; /* incremented on flush */
9736 xfs_ictimestamp_t di_atime; /* time last accessed */
9737 xfs_ictimestamp_t di_mtime; /* time last modified */
9738 @@ -511,7 +513,7 @@ int xfs_itobp(struct xfs_mount *, struc
9739 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
9740 struct xfs_inode *, uint);
9741 void xfs_dinode_to_disk(struct xfs_dinode *,
9742 - struct xfs_icdinode *);
9743 + struct xfs_icdinode *, int);
9744 void xfs_idestroy_fork(struct xfs_inode *, int);
9745 void xfs_idata_realloc(struct xfs_inode *, int, int);
9746 void xfs_iroot_realloc(struct xfs_inode *, int, int);
9747 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_itable.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_itable.c
9748 --- linux-2.6.35/fs/xfs/xfs_itable.c 2010-08-02 16:52:53.000000000 +0200
9749 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_itable.c 2010-08-02 17:05:06.000000000 +0200
9750 @@ -100,6 +100,7 @@ xfs_bulkstat_one_int(
9751 buf->bs_mode = dic->di_mode;
9752 buf->bs_uid = dic->di_uid;
9753 buf->bs_gid = dic->di_gid;
9754 + buf->bs_tag = dic->di_tag;
9755 buf->bs_size = dic->di_size;
9758 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_log_recover.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_log_recover.c
9759 --- linux-2.6.35/fs/xfs/xfs_log_recover.c 2010-08-02 16:52:53.000000000 +0200
9760 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_log_recover.c 2010-08-02 17:05:06.000000000 +0200
9761 @@ -2461,7 +2461,8 @@ xlog_recover_do_inode_trans(
9764 /* The core is in in-core format */
9765 - xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
9766 + xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
9767 + mp->m_flags & XFS_MOUNT_TAGGED);
9769 /* the rest is in on-disk format */
9770 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
9771 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_mount.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_mount.h
9772 --- linux-2.6.35/fs/xfs/xfs_mount.h 2010-08-02 16:52:53.000000000 +0200
9773 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_mount.h 2010-08-02 17:05:06.000000000 +0200
9774 @@ -302,6 +302,7 @@ typedef struct xfs_mount {
9776 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
9778 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
9781 * Default minimum read and write sizes.
9782 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_vnodeops.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_vnodeops.c
9783 --- linux-2.6.35/fs/xfs/xfs_vnodeops.c 2010-08-02 16:52:53.000000000 +0200
9784 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_vnodeops.c 2010-08-02 17:05:06.000000000 +0200
9786 #include "xfs_vnodeops.h"
9787 #include "xfs_trace.h"
9791 +xfs_get_inode_flags(
9794 + struct inode *inode = VFS_I(ip);
9795 + unsigned int flags = inode->i_flags;
9796 + unsigned int vflags = inode->i_vflags;
9798 + if (flags & S_IMMUTABLE)
9799 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
9801 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
9802 + if (flags & S_IXUNLINK)
9803 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
9805 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
9807 + if (vflags & V_BARRIER)
9808 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
9810 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
9811 + if (vflags & V_COW)
9812 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
9814 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
9819 + struct inode *inode,
9823 + struct xfs_inode *ip = XFS_I(inode);
9824 + struct xfs_mount *mp = ip->i_mount;
9825 + struct xfs_trans *tp;
9826 + unsigned int lock_flags = 0;
9829 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
9830 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
9834 + lock_flags = XFS_ILOCK_EXCL;
9835 + xfs_ilock(ip, lock_flags);
9837 + xfs_trans_ijoin(tp, ip, lock_flags);
9838 + xfs_trans_ihold(tp, ip);
9840 + inode->i_flags = flags;
9841 + inode->i_vflags = vflags;
9842 + xfs_get_inode_flags(ip);
9844 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
9845 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
9847 + XFS_STATS_INC(xs_ig_attrchg);
9849 + if (mp->m_flags & XFS_MOUNT_WSYNC)
9850 + xfs_trans_set_sync(tp);
9851 + code = xfs_trans_commit(tp, 0);
9852 + xfs_iunlock(ip, lock_flags);
9856 + xfs_trans_cancel(tp, 0);
9858 + xfs_iunlock(ip, lock_flags);
9865 struct xfs_inode *ip,
9866 @@ -70,6 +144,7 @@ xfs_setattr(
9867 uint commit_flags=0;
9868 uid_t uid=0, iuid=0;
9869 gid_t gid=0, igid=0;
9870 + tag_t tag=0, itag=0;
9871 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
9872 int need_iolock = 1;
9874 @@ -162,7 +237,7 @@ xfs_setattr(
9876 * Change file ownership. Must be the owner or privileged.
9878 - if (mask & (ATTR_UID|ATTR_GID)) {
9879 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
9881 * These IDs could have changed since we last looked at them.
9882 * But, we're assured that if the ownership did change
9883 @@ -171,8 +246,10 @@ xfs_setattr(
9885 iuid = ip->i_d.di_uid;
9886 igid = ip->i_d.di_gid;
9887 + itag = ip->i_d.di_tag;
9888 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
9889 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
9890 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
9893 * Do a quota reservation only if uid/gid is actually
9894 @@ -180,7 +257,8 @@ xfs_setattr(
9896 if (XFS_IS_QUOTA_RUNNING(mp) &&
9897 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
9898 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
9899 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
9900 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
9902 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
9903 capable(CAP_FOWNER) ?
9904 @@ -341,7 +419,7 @@ xfs_setattr(
9906 * Change file ownership. Must be the owner or privileged.
9908 - if (mask & (ATTR_UID|ATTR_GID)) {
9909 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
9911 * CAP_FSETID overrides the following restrictions:
9913 @@ -357,6 +435,10 @@ xfs_setattr(
9914 * Change the ownerships and register quota modifications
9915 * in the transaction.
9917 + if (itag != tag) {
9918 + ip->i_d.di_tag = tag;
9919 + inode->i_tag = tag;
9922 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
9923 ASSERT(mask & ATTR_UID);
9924 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_vnodeops.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_vnodeops.h
9925 --- linux-2.6.35/fs/xfs/xfs_vnodeops.h 2010-07-07 18:31:54.000000000 +0200
9926 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_vnodeops.h 2010-08-02 17:05:06.000000000 +0200
9927 @@ -14,6 +14,7 @@ struct xfs_inode;
9931 +int xfs_sync_xflags(struct xfs_inode *ip);
9932 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
9933 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
9934 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
9935 diff -NurpP --minimal linux-2.6.35/include/asm-generic/tlb.h linux-2.6.35-vs2.3.0.36.31/include/asm-generic/tlb.h
9936 --- linux-2.6.35/include/asm-generic/tlb.h 2009-09-10 15:26:24.000000000 +0200
9937 +++ linux-2.6.35-vs2.3.0.36.31/include/asm-generic/tlb.h 2010-08-02 17:05:06.000000000 +0200
9939 #define _ASM_GENERIC__TLB_H
9941 #include <linux/swap.h>
9942 +#include <linux/vs_memory.h>
9943 #include <asm/pgalloc.h>
9944 #include <asm/tlbflush.h>
9946 diff -NurpP --minimal linux-2.6.35/include/linux/capability.h linux-2.6.35-vs2.3.0.36.31/include/linux/capability.h
9947 --- linux-2.6.35/include/linux/capability.h 2010-02-25 11:52:07.000000000 +0100
9948 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/capability.h 2010-08-02 17:05:06.000000000 +0200
9949 @@ -283,6 +283,7 @@ struct cpu_vfs_cap_data {
9950 arbitrary SCSI commands */
9951 /* Allow setting encryption key on loopback filesystem */
9952 /* Allow setting zone reclaim policy */
9953 +/* Allow the selection of a security context */
9955 #define CAP_SYS_ADMIN 21
9957 @@ -355,7 +356,13 @@ struct cpu_vfs_cap_data {
9959 #define CAP_MAC_ADMIN 33
9961 -#define CAP_LAST_CAP CAP_MAC_ADMIN
9962 +/* Allow context manipulations */
9963 +/* Allow changing context info on files */
9965 +#define CAP_CONTEXT 34
9968 +#define CAP_LAST_CAP CAP_CONTEXT
9970 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
9972 diff -NurpP --minimal linux-2.6.35/include/linux/devpts_fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/devpts_fs.h
9973 --- linux-2.6.35/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
9974 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/devpts_fs.h 2010-08-02 17:05:06.000000000 +0200
9975 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
9980 #endif /* _LINUX_DEVPTS_FS_H */
9981 diff -NurpP --minimal linux-2.6.35/include/linux/ext2_fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/ext2_fs.h
9982 --- linux-2.6.35/include/linux/ext2_fs.h 2010-02-25 11:52:07.000000000 +0100
9983 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/ext2_fs.h 2010-08-02 17:05:06.000000000 +0200
9984 @@ -189,8 +189,12 @@ struct ext2_group_desc
9985 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
9986 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
9987 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
9988 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
9989 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
9991 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
9992 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
9994 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
9995 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
9997 @@ -274,7 +278,8 @@ struct ext2_inode {
9999 __le16 l_i_uid_high; /* these 2 fields */
10000 __le16 l_i_gid_high; /* were reserved2[0] */
10001 - __u32 l_i_reserved2;
10002 + __le16 l_i_tag; /* Context Tag */
10003 + __u16 l_i_reserved2;
10006 __u8 h_i_frag; /* Fragment number */
10007 @@ -303,6 +308,7 @@ struct ext2_inode {
10008 #define i_gid_low i_gid
10009 #define i_uid_high osd2.linux2.l_i_uid_high
10010 #define i_gid_high osd2.linux2.l_i_gid_high
10011 +#define i_raw_tag osd2.linux2.l_i_tag
10012 #define i_reserved2 osd2.linux2.l_i_reserved2
10015 @@ -347,6 +353,7 @@ struct ext2_inode {
10016 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
10017 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
10018 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
10019 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
10022 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
10023 diff -NurpP --minimal linux-2.6.35/include/linux/ext3_fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/ext3_fs.h
10024 --- linux-2.6.35/include/linux/ext3_fs.h 2010-08-02 16:52:54.000000000 +0200
10025 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/ext3_fs.h 2010-08-02 17:05:06.000000000 +0200
10026 @@ -173,10 +173,14 @@ struct ext3_group_desc
10027 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
10028 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
10029 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
10030 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
10031 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
10033 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
10034 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
10035 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
10036 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
10038 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
10039 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
10041 /* Flags that should be inherited by new inodes from their parent. */
10042 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
10043 @@ -312,7 +316,8 @@ struct ext3_inode {
10045 __le16 l_i_uid_high; /* these 2 fields */
10046 __le16 l_i_gid_high; /* were reserved2[0] */
10047 - __u32 l_i_reserved2;
10048 + __le16 l_i_tag; /* Context Tag */
10049 + __u16 l_i_reserved2;
10052 __u8 h_i_frag; /* Fragment number */
10053 @@ -343,6 +348,7 @@ struct ext3_inode {
10054 #define i_gid_low i_gid
10055 #define i_uid_high osd2.linux2.l_i_uid_high
10056 #define i_gid_high osd2.linux2.l_i_gid_high
10057 +#define i_raw_tag osd2.linux2.l_i_tag
10058 #define i_reserved2 osd2.linux2.l_i_reserved2
10060 #elif defined(__GNU__)
10061 @@ -406,6 +412,7 @@ struct ext3_inode {
10062 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
10063 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
10064 * error in ordered mode */
10065 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
10067 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
10068 #ifndef _LINUX_EXT2_FS_H
10069 @@ -909,6 +916,7 @@ extern void ext3_get_inode_flags(struct
10070 extern void ext3_set_aops(struct inode *inode);
10071 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
10072 u64 start, u64 len);
10073 +extern int ext3_sync_flags(struct inode *, int, int);
10076 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
10077 diff -NurpP --minimal linux-2.6.35/include/linux/fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/fs.h
10078 --- linux-2.6.35/include/linux/fs.h 2010-08-02 16:52:54.000000000 +0200
10079 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/fs.h 2010-08-02 18:15:53.000000000 +0200
10080 @@ -209,6 +209,9 @@ struct inodes_stat_t {
10081 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
10082 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
10083 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
10084 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
10085 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
10086 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
10087 #define MS_ACTIVE (1<<30)
10088 #define MS_NOUSER (1<<31)
10090 @@ -235,6 +238,14 @@ struct inodes_stat_t {
10091 #define S_NOCMTIME 128 /* Do not update file c/mtime */
10092 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
10093 #define S_PRIVATE 512 /* Inode is fs-internal */
10094 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
10096 +/* Linux-VServer related Inode flags */
10100 +#define V_BARRIER 4 /* Barrier for chroot() */
10101 +#define V_COW 8 /* Copy on Write */
10104 * Note that nosuid etc flags are inode-specific: setting some file-system
10105 @@ -257,12 +268,15 @@ struct inodes_stat_t {
10106 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
10107 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
10108 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
10109 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10110 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
10111 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10112 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
10113 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
10115 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
10116 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
10117 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
10118 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
10119 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
10120 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
10122 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
10123 @@ -270,6 +284,16 @@ struct inodes_stat_t {
10124 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
10125 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
10127 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
10129 +#ifdef CONFIG_VSERVER_COWBL
10130 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
10131 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
10133 +# define IS_COW(inode) (0)
10134 +# define IS_COW_LINK(inode) (0)
10137 /* the read-only stuff doesn't really belong here, but any other place is
10138 probably as bad and I don't want to create yet another include file. */
10140 @@ -352,11 +376,14 @@ struct inodes_stat_t {
10141 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
10142 #define FS_EXTENT_FL 0x00080000 /* Extents */
10143 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
10144 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
10145 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
10147 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
10148 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
10149 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
10150 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
10152 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
10153 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
10155 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
10156 #define SYNC_FILE_RANGE_WRITE 2
10157 @@ -438,6 +465,7 @@ typedef void (dio_iodone_t)(struct kiocb
10158 #define ATTR_KILL_PRIV (1 << 14)
10159 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
10160 #define ATTR_TIMES_SET (1 << 16)
10161 +#define ATTR_TAG (1 << 17)
10164 * This is the Inode Attributes structure, used for notify_change(). It
10165 @@ -453,6 +481,7 @@ struct iattr {
10171 struct timespec ia_atime;
10172 struct timespec ia_mtime;
10173 @@ -466,6 +495,9 @@ struct iattr {
10174 struct file *ia_file;
10177 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
10178 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
10181 * Includes for diskquotas.
10183 @@ -732,7 +764,9 @@ struct inode {
10184 unsigned int i_nlink;
10190 unsigned int i_blkbits;
10193 @@ -779,7 +813,8 @@ struct inode {
10194 unsigned long i_state;
10195 unsigned long dirtied_when; /* jiffies of first dirtying */
10197 - unsigned int i_flags;
10198 + unsigned short i_flags;
10199 + unsigned short i_vflags;
10201 atomic_t i_writecount;
10202 #ifdef CONFIG_SECURITY
10203 @@ -867,12 +902,12 @@ static inline void i_size_write(struct i
10205 static inline unsigned iminor(const struct inode *inode)
10207 - return MINOR(inode->i_rdev);
10208 + return MINOR(inode->i_mdev);
10211 static inline unsigned imajor(const struct inode *inode)
10213 - return MAJOR(inode->i_rdev);
10214 + return MAJOR(inode->i_mdev);
10217 extern struct block_device *I_BDEV(struct inode *inode);
10218 @@ -931,6 +966,7 @@ struct file {
10220 struct fown_struct f_owner;
10221 const struct cred *f_cred;
10223 struct file_ra_state f_ra;
10226 @@ -1073,6 +1109,7 @@ struct file_lock {
10227 struct file *fl_file;
10232 struct fasync_struct * fl_fasync; /* for lease break notifications */
10233 unsigned long fl_break_time; /* for nonblocking lease breaks */
10234 @@ -1534,6 +1571,7 @@ struct inode_operations {
10235 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
10236 ssize_t (*listxattr) (struct dentry *, char *, size_t);
10237 int (*removexattr) (struct dentry *, const char *);
10238 + int (*sync_flags) (struct inode *, int, int);
10239 void (*truncate_range)(struct inode *, loff_t, loff_t);
10240 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
10242 @@ -1554,6 +1592,7 @@ extern ssize_t vfs_readv(struct file *,
10243 unsigned long, loff_t *);
10244 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
10245 unsigned long, loff_t *);
10246 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
10248 struct super_operations {
10249 struct inode *(*alloc_inode)(struct super_block *sb);
10250 @@ -2377,6 +2416,7 @@ extern int dcache_dir_open(struct inode
10251 extern int dcache_dir_close(struct inode *, struct file *);
10252 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
10253 extern int dcache_readdir(struct file *, void *, filldir_t);
10254 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
10255 extern int simple_setattr(struct dentry *, struct iattr *);
10256 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
10257 extern int simple_statfs(struct dentry *, struct kstatfs *);
10258 diff -NurpP --minimal linux-2.6.35/include/linux/gfs2_ondisk.h linux-2.6.35-vs2.3.0.36.31/include/linux/gfs2_ondisk.h
10259 --- linux-2.6.35/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
10260 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/gfs2_ondisk.h 2010-08-02 17:05:06.000000000 +0200
10261 @@ -211,6 +211,9 @@ enum {
10262 gfs2fl_NoAtime = 7,
10265 + gfs2fl_IXUnlink = 16,
10266 + gfs2fl_Barrier = 17,
10268 gfs2fl_TruncInProg = 29,
10269 gfs2fl_InheritDirectio = 30,
10270 gfs2fl_InheritJdata = 31,
10271 @@ -227,6 +230,9 @@ enum {
10272 #define GFS2_DIF_NOATIME 0x00000080
10273 #define GFS2_DIF_SYNC 0x00000100
10274 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
10275 +#define GFS2_DIF_IXUNLINK 0x00010000
10276 +#define GFS2_DIF_BARRIER 0x00020000
10277 +#define GFS2_DIF_COW 0x00040000
10278 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
10279 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
10280 #define GFS2_DIF_INHERIT_JDATA 0x80000000
10281 diff -NurpP --minimal linux-2.6.35/include/linux/if_tun.h linux-2.6.35-vs2.3.0.36.31/include/linux/if_tun.h
10282 --- linux-2.6.35/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
10283 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/if_tun.h 2010-08-02 18:17:46.000000000 +0200
10285 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
10286 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
10287 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
10288 +#define TUNSETNID _IOW('T', 217, int)
10290 /* TUNSETIFF ifr flags */
10291 #define IFF_TUN 0x0001
10292 diff -NurpP --minimal linux-2.6.35/include/linux/init_task.h linux-2.6.35-vs2.3.0.36.31/include/linux/init_task.h
10293 --- linux-2.6.35/include/linux/init_task.h 2010-08-02 16:52:54.000000000 +0200
10294 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/init_task.h 2010-08-02 17:05:06.000000000 +0200
10295 @@ -172,6 +172,10 @@ extern struct cred init_cred;
10296 INIT_FTRACE_GRAPH \
10297 INIT_TRACE_RECURSION \
10298 INIT_TASK_RCU_PREEMPT(tsk) \
10300 + .vx_info = NULL, \
10302 + .nx_info = NULL, \
10306 diff -NurpP --minimal linux-2.6.35/include/linux/ipc.h linux-2.6.35-vs2.3.0.36.31/include/linux/ipc.h
10307 --- linux-2.6.35/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
10308 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/ipc.h 2010-08-02 17:05:06.000000000 +0200
10309 @@ -91,6 +91,7 @@ struct kern_ipc_perm
10317 diff -NurpP --minimal linux-2.6.35/include/linux/Kbuild linux-2.6.35-vs2.3.0.36.31/include/linux/Kbuild
10318 --- linux-2.6.35/include/linux/Kbuild 2010-08-02 16:52:53.000000000 +0200
10319 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/Kbuild 2010-08-02 17:05:06.000000000 +0200
10320 @@ -387,5 +387,8 @@ unifdef-y += xattr.h
10321 unifdef-y += xfrm.h
10323 objhdr-y += version.h
10325 +header-y += vserver/
10326 header-y += wimax.h
10329 diff -NurpP --minimal linux-2.6.35/include/linux/loop.h linux-2.6.35-vs2.3.0.36.31/include/linux/loop.h
10330 --- linux-2.6.35/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
10331 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/loop.h 2010-08-02 17:05:06.000000000 +0200
10332 @@ -45,6 +45,7 @@ struct loop_device {
10333 struct loop_func_table *lo_encryption;
10335 uid_t lo_key_owner; /* Who set the key */
10337 int (*ioctl)(struct loop_device *, int cmd,
10338 unsigned long arg);
10340 diff -NurpP --minimal linux-2.6.35/include/linux/magic.h linux-2.6.35-vs2.3.0.36.31/include/linux/magic.h
10341 --- linux-2.6.35/include/linux/magic.h 2010-07-07 18:31:55.000000000 +0200
10342 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/magic.h 2010-08-02 17:05:06.000000000 +0200
10345 #define ADFS_SUPER_MAGIC 0xadf5
10346 #define AFFS_SUPER_MAGIC 0xadff
10347 -#define AFS_SUPER_MAGIC 0x5346414F
10348 +#define AFS_SUPER_MAGIC 0x5346414F
10349 #define AUTOFS_SUPER_MAGIC 0x0187
10350 #define CODA_SUPER_MAGIC 0x73757245
10351 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
10353 #define NFS_SUPER_MAGIC 0x6969
10354 #define OPENPROM_SUPER_MAGIC 0x9fa1
10355 #define PROC_SUPER_MAGIC 0x9fa0
10356 +#define DEVPTS_SUPER_MAGIC 0x1cd1
10357 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
10359 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
10360 diff -NurpP --minimal linux-2.6.35/include/linux/major.h linux-2.6.35-vs2.3.0.36.31/include/linux/major.h
10361 --- linux-2.6.35/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
10362 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/major.h 2010-08-02 17:05:06.000000000 +0200
10364 #define HD_MAJOR IDE0_MAJOR
10365 #define PTY_SLAVE_MAJOR 3
10366 #define TTY_MAJOR 4
10367 +#define VROOT_MAJOR 4
10368 #define TTYAUX_MAJOR 5
10370 #define VCS_MAJOR 7
10371 diff -NurpP --minimal linux-2.6.35/include/linux/memcontrol.h linux-2.6.35-vs2.3.0.36.31/include/linux/memcontrol.h
10372 --- linux-2.6.35/include/linux/memcontrol.h 2010-08-02 16:52:54.000000000 +0200
10373 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/memcontrol.h 2010-08-02 17:05:06.000000000 +0200
10374 @@ -77,6 +77,13 @@ int task_in_mem_cgroup(struct task_struc
10375 extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
10376 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
10378 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
10379 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
10381 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
10382 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
10383 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
10386 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
10388 diff -NurpP --minimal linux-2.6.35/include/linux/mm_types.h linux-2.6.35-vs2.3.0.36.31/include/linux/mm_types.h
10389 --- linux-2.6.35/include/linux/mm_types.h 2010-07-07 18:31:55.000000000 +0200
10390 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/mm_types.h 2010-08-02 17:05:06.000000000 +0200
10391 @@ -269,6 +269,7 @@ struct mm_struct {
10393 /* Architecture-specific MM context */
10394 mm_context_t context;
10395 + struct vx_info *mm_vx_info;
10397 /* Swap token stuff */
10399 diff -NurpP --minimal linux-2.6.35/include/linux/mount.h linux-2.6.35-vs2.3.0.36.31/include/linux/mount.h
10400 --- linux-2.6.35/include/linux/mount.h 2010-07-07 18:31:56.000000000 +0200
10401 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/mount.h 2010-08-02 17:05:06.000000000 +0200
10402 @@ -47,6 +47,9 @@ struct mnt_namespace;
10404 #define MNT_INTERNAL 0x4000
10406 +#define MNT_TAGID 0x10000
10407 +#define MNT_NOTAG 0x20000
10410 struct list_head mnt_hash;
10411 struct vfsmount *mnt_parent; /* fs we are mounted on */
10412 @@ -81,6 +84,7 @@ struct vfsmount {
10416 + tag_t mnt_tag; /* tagging used for vfsmount */
10419 static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
10420 diff -NurpP --minimal linux-2.6.35/include/linux/net.h linux-2.6.35-vs2.3.0.36.31/include/linux/net.h
10421 --- linux-2.6.35/include/linux/net.h 2010-08-02 16:52:55.000000000 +0200
10422 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/net.h 2010-08-02 17:05:06.000000000 +0200
10423 @@ -71,6 +71,7 @@ struct net;
10424 #define SOCK_NOSPACE 2
10425 #define SOCK_PASSCRED 3
10426 #define SOCK_PASSSEC 4
10427 +#define SOCK_USER_SOCKET 5
10429 #ifndef ARCH_HAS_SOCKET_TYPES
10431 diff -NurpP --minimal linux-2.6.35/include/linux/nfs_mount.h linux-2.6.35-vs2.3.0.36.31/include/linux/nfs_mount.h
10432 --- linux-2.6.35/include/linux/nfs_mount.h 2009-03-24 14:22:43.000000000 +0100
10433 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/nfs_mount.h 2010-08-02 17:05:06.000000000 +0200
10434 @@ -63,7 +63,8 @@ struct nfs_mount_data {
10435 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
10436 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
10437 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
10438 -#define NFS_MOUNT_FLAGMASK 0xFFFF
10439 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
10440 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
10442 /* The following are for internal use only */
10443 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
10444 diff -NurpP --minimal linux-2.6.35/include/linux/nsproxy.h linux-2.6.35-vs2.3.0.36.31/include/linux/nsproxy.h
10445 --- linux-2.6.35/include/linux/nsproxy.h 2009-06-11 17:13:17.000000000 +0200
10446 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/nsproxy.h 2010-08-02 17:05:06.000000000 +0200
10449 #include <linux/spinlock.h>
10450 #include <linux/sched.h>
10451 +#include <linux/vserver/debug.h>
10453 struct mnt_namespace;
10454 struct uts_namespace;
10455 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
10458 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
10459 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
10460 void exit_task_namespaces(struct task_struct *tsk);
10461 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
10462 void free_nsproxy(struct nsproxy *ns);
10463 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
10464 struct fs_struct *);
10466 -static inline void put_nsproxy(struct nsproxy *ns)
10467 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
10469 +static inline void __get_nsproxy(struct nsproxy *ns,
10470 + const char *_file, int _line)
10472 - if (atomic_dec_and_test(&ns->count)) {
10473 - free_nsproxy(ns);
10475 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
10476 + ns, atomic_read(&ns->count), _file, _line);
10477 + atomic_inc(&ns->count);
10480 -static inline void get_nsproxy(struct nsproxy *ns)
10481 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
10483 +static inline void __put_nsproxy(struct nsproxy *ns,
10484 + const char *_file, int _line)
10486 - atomic_inc(&ns->count);
10487 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
10488 + ns, atomic_read(&ns->count), _file, _line);
10489 + if (atomic_dec_and_test(&ns->count)) {
10490 + free_nsproxy(ns);
10494 #ifdef CONFIG_CGROUP_NS
10495 diff -NurpP --minimal linux-2.6.35/include/linux/pid.h linux-2.6.35-vs2.3.0.36.31/include/linux/pid.h
10496 --- linux-2.6.35/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
10497 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/pid.h 2010-08-02 17:05:06.000000000 +0200
10498 @@ -8,7 +8,8 @@ enum pid_type
10508 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
10511 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
10512 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
10513 pid_t pid_vnr(struct pid *pid);
10515 #define do_each_pid_task(pid, type, task) \
10516 diff -NurpP --minimal linux-2.6.35/include/linux/proc_fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/proc_fs.h
10517 --- linux-2.6.35/include/linux/proc_fs.h 2009-12-03 20:02:56.000000000 +0100
10518 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/proc_fs.h 2010-08-02 17:05:06.000000000 +0200
10519 @@ -56,6 +56,7 @@ struct proc_dir_entry {
10525 const struct inode_operations *proc_iops;
10527 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void
10528 extern void kclist_add(struct kcore_list *, void *, size_t, int type);
10535 int (*proc_get_link)(struct inode *, struct path *);
10536 int (*proc_read)(struct task_struct *task, char *page);
10537 int (*proc_show)(struct seq_file *m,
10538 struct pid_namespace *ns, struct pid *pid,
10539 struct task_struct *task);
10540 + int (*proc_vs_read)(char *page);
10541 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
10542 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
10545 struct ctl_table_header;
10546 @@ -263,6 +270,7 @@ struct ctl_table;
10548 struct proc_inode {
10553 struct proc_dir_entry *pde;
10554 diff -NurpP --minimal linux-2.6.35/include/linux/quotaops.h linux-2.6.35-vs2.3.0.36.31/include/linux/quotaops.h
10555 --- linux-2.6.35/include/linux/quotaops.h 2010-08-02 16:52:55.000000000 +0200
10556 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/quotaops.h 2010-08-02 22:35:47.000000000 +0200
10558 #define _LINUX_QUOTAOPS_
10560 #include <linux/fs.h>
10561 +#include <linux/vs_dlimit.h>
10563 #define DQUOT_SPACE_WARN 0x1
10564 #define DQUOT_SPACE_RESERVE 0x2
10565 @@ -209,11 +210,12 @@ static inline void dquot_drop(struct ino
10567 static inline int dquot_alloc_inode(const struct inode *inode)
10570 + return dl_alloc_inode(inode);
10573 static inline void dquot_free_inode(const struct inode *inode)
10575 + dl_free_inode(inode);
10578 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
10579 @@ -224,6 +226,10 @@ static inline int dquot_transfer(struct
10580 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
10585 + if ((ret = dl_alloc_space(inode, number)))
10587 if (!(flags & DQUOT_SPACE_RESERVE))
10588 inode_add_bytes(inode, number);
10590 @@ -234,6 +240,7 @@ static inline void __dquot_free_space(st
10592 if (!(flags & DQUOT_SPACE_RESERVE))
10593 inode_sub_bytes(inode, number);
10594 + dl_free_space(inode, number);
10597 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
10598 diff -NurpP --minimal linux-2.6.35/include/linux/reboot.h linux-2.6.35-vs2.3.0.36.31/include/linux/reboot.h
10599 --- linux-2.6.35/include/linux/reboot.h 2010-07-07 18:31:56.000000000 +0200
10600 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/reboot.h 2010-08-02 17:05:06.000000000 +0200
10602 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
10603 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
10604 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
10605 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
10609 diff -NurpP --minimal linux-2.6.35/include/linux/reiserfs_fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/reiserfs_fs.h
10610 --- linux-2.6.35/include/linux/reiserfs_fs.h 2010-07-07 18:31:56.000000000 +0200
10611 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/reiserfs_fs.h 2010-08-02 17:05:06.000000000 +0200
10612 @@ -977,6 +977,11 @@ struct stat_data_v1 {
10613 #define REISERFS_COMPR_FL FS_COMPR_FL
10614 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
10616 +/* unfortunately reiserfs sdattr is only 16 bit */
10617 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
10618 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
10619 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
10621 /* persistent flags that file inherits from the parent directory */
10622 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
10623 REISERFS_SYNC_FL | \
10624 @@ -986,6 +991,9 @@ struct stat_data_v1 {
10625 REISERFS_COMPR_FL | \
10626 REISERFS_NOTAIL_FL )
10628 +#define REISERFS_FL_USER_VISIBLE 0x80FF
10629 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
10631 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
10634 @@ -2071,6 +2079,7 @@ static inline void reiserfs_update_sd(st
10635 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
10636 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
10637 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
10638 +int reiserfs_sync_flags(struct inode *inode, int, int);
10641 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
10642 diff -NurpP --minimal linux-2.6.35/include/linux/reiserfs_fs_sb.h linux-2.6.35-vs2.3.0.36.31/include/linux/reiserfs_fs_sb.h
10643 --- linux-2.6.35/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
10644 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/reiserfs_fs_sb.h 2010-08-02 17:05:06.000000000 +0200
10645 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
10646 REISERFS_EXPOSE_PRIVROOT,
10647 REISERFS_BARRIER_NONE,
10648 REISERFS_BARRIER_FLUSH,
10651 /* Actions on error */
10652 REISERFS_ERROR_PANIC,
10653 diff -NurpP --minimal linux-2.6.35/include/linux/sched.h linux-2.6.35-vs2.3.0.36.31/include/linux/sched.h
10654 --- linux-2.6.35/include/linux/sched.h 2010-08-02 16:52:55.000000000 +0200
10655 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/sched.h 2010-08-02 17:05:06.000000000 +0200
10656 @@ -1349,6 +1349,14 @@ struct task_struct {
10660 +/* vserver context data */
10661 + struct vx_info *vx_info;
10662 + struct nx_info *nx_info;
10668 /* Thread group tracking */
10669 u32 parent_exec_id;
10671 @@ -1583,6 +1591,11 @@ struct pid_namespace;
10672 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
10673 struct pid_namespace *ns);
10675 +#include <linux/vserver/base.h>
10676 +#include <linux/vserver/context.h>
10677 +#include <linux/vserver/debug.h>
10678 +#include <linux/vserver/pid.h>
10680 static inline pid_t task_pid_nr(struct task_struct *tsk)
10683 @@ -1596,7 +1609,8 @@ static inline pid_t task_pid_nr_ns(struc
10685 static inline pid_t task_pid_vnr(struct task_struct *tsk)
10687 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10688 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10689 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
10693 @@ -1609,7 +1623,7 @@ pid_t task_tgid_nr_ns(struct task_struct
10695 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
10697 - return pid_vnr(task_tgid(tsk));
10698 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
10702 diff -NurpP --minimal linux-2.6.35/include/linux/shmem_fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/shmem_fs.h
10703 --- linux-2.6.35/include/linux/shmem_fs.h 2010-02-25 11:52:08.000000000 +0100
10704 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/shmem_fs.h 2010-08-02 17:05:06.000000000 +0200
10707 #define SHMEM_NR_DIRECT 16
10709 +#define TMPFS_SUPER_MAGIC 0x01021994
10712 struct shmem_inode_info {
10714 unsigned long flags;
10715 diff -NurpP --minimal linux-2.6.35/include/linux/stat.h linux-2.6.35-vs2.3.0.36.31/include/linux/stat.h
10716 --- linux-2.6.35/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
10717 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/stat.h 2010-08-02 17:05:06.000000000 +0200
10718 @@ -66,6 +66,7 @@ struct kstat {
10719 unsigned int nlink;
10725 struct timespec atime;
10726 diff -NurpP --minimal linux-2.6.35/include/linux/sunrpc/auth.h linux-2.6.35-vs2.3.0.36.31/include/linux/sunrpc/auth.h
10727 --- linux-2.6.35/include/linux/sunrpc/auth.h 2010-08-02 16:52:56.000000000 +0200
10728 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/sunrpc/auth.h 2010-08-02 17:05:06.000000000 +0200
10734 struct group_info *group_info;
10735 unsigned char machine_cred : 1;
10737 diff -NurpP --minimal linux-2.6.35/include/linux/sunrpc/clnt.h linux-2.6.35-vs2.3.0.36.31/include/linux/sunrpc/clnt.h
10738 --- linux-2.6.35/include/linux/sunrpc/clnt.h 2009-12-03 20:02:56.000000000 +0100
10739 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/sunrpc/clnt.h 2010-08-02 17:05:06.000000000 +0200
10740 @@ -49,7 +49,8 @@ struct rpc_clnt {
10741 unsigned int cl_softrtry : 1,/* soft timeouts */
10742 cl_discrtry : 1,/* disconnect before retry */
10743 cl_autobind : 1,/* use getport() */
10744 - cl_chatty : 1;/* be verbose */
10745 + cl_chatty : 1,/* be verbose */
10746 + cl_tag : 1;/* context tagging */
10748 struct rpc_rtt * cl_rtt; /* RTO estimator data */
10749 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
10750 diff -NurpP --minimal linux-2.6.35/include/linux/syscalls.h linux-2.6.35-vs2.3.0.36.31/include/linux/syscalls.h
10751 --- linux-2.6.35/include/linux/syscalls.h 2010-08-02 16:52:56.000000000 +0200
10752 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/syscalls.h 2010-08-02 17:05:06.000000000 +0200
10753 @@ -479,6 +479,8 @@ asmlinkage long sys_symlink(const char _
10754 asmlinkage long sys_unlink(const char __user *pathname);
10755 asmlinkage long sys_rename(const char __user *oldname,
10756 const char __user *newname);
10757 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
10759 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
10760 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
10762 diff -NurpP --minimal linux-2.6.35/include/linux/sysctl.h linux-2.6.35-vs2.3.0.36.31/include/linux/sysctl.h
10763 --- linux-2.6.35/include/linux/sysctl.h 2010-08-02 16:52:56.000000000 +0200
10764 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/sysctl.h 2010-08-02 17:05:06.000000000 +0200
10765 @@ -60,6 +60,7 @@ enum
10766 CTL_ABI=9, /* Binary emulation */
10767 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
10768 CTL_ARLAN=254, /* arlan wireless driver */
10769 + CTL_VSERVER=4242, /* Linux-VServer debug */
10770 CTL_S390DBF=5677, /* s390 debug */
10771 CTL_SUNRPC=7249, /* sunrpc debug */
10772 CTL_PM=9899, /* frv power management */
10773 @@ -94,6 +95,7 @@ enum
10775 KERN_PANIC=15, /* int: panic timeout */
10776 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
10777 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
10779 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
10780 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
10781 diff -NurpP --minimal linux-2.6.35/include/linux/sysfs.h linux-2.6.35-vs2.3.0.36.31/include/linux/sysfs.h
10782 --- linux-2.6.35/include/linux/sysfs.h 2010-08-02 16:52:56.000000000 +0200
10783 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/sysfs.h 2010-08-02 17:05:06.000000000 +0200
10785 #include <linux/lockdep.h>
10786 #include <asm/atomic.h>
10788 +#define SYSFS_SUPER_MAGIC 0x62656572
10793 diff -NurpP --minimal linux-2.6.35/include/linux/time.h linux-2.6.35-vs2.3.0.36.31/include/linux/time.h
10794 --- linux-2.6.35/include/linux/time.h 2010-08-02 16:52:56.000000000 +0200
10795 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/time.h 2010-08-02 17:05:06.000000000 +0200
10796 @@ -237,6 +237,9 @@ static __always_inline void timespec_add
10797 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
10801 +#include <linux/vs_time.h>
10803 #endif /* __KERNEL__ */
10805 #define NFDBITS __NFDBITS
10806 diff -NurpP --minimal linux-2.6.35/include/linux/types.h linux-2.6.35-vs2.3.0.36.31/include/linux/types.h
10807 --- linux-2.6.35/include/linux/types.h 2010-08-02 16:52:56.000000000 +0200
10808 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/types.h 2010-08-02 17:05:06.000000000 +0200
10809 @@ -37,6 +37,9 @@ typedef __kernel_uid32_t uid_t;
10810 typedef __kernel_gid32_t gid_t;
10811 typedef __kernel_uid16_t uid16_t;
10812 typedef __kernel_gid16_t gid16_t;
10813 +typedef unsigned int xid_t;
10814 +typedef unsigned int nid_t;
10815 +typedef unsigned int tag_t;
10817 typedef unsigned long uintptr_t;
10819 diff -NurpP --minimal linux-2.6.35/include/linux/vroot.h linux-2.6.35-vs2.3.0.36.31/include/linux/vroot.h
10820 --- linux-2.6.35/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
10821 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vroot.h 2010-08-02 17:05:06.000000000 +0200
10825 + * include/linux/vroot.h
10827 + * written by Herbert Pötzl, 9/11/2002
10828 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
10830 + * Copyright (C) 2002-2007 by Herbert Pötzl.
10831 + * Redistribution of this file is permitted under the
10832 + * GNU General Public License.
10835 +#ifndef _LINUX_VROOT_H
10836 +#define _LINUX_VROOT_H
10841 +/* Possible states of device */
10847 +struct vroot_device {
10851 + struct semaphore vr_ctl_mutex;
10852 + struct block_device *vr_device;
10857 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
10859 +extern int register_vroot_grb(vroot_grb_func *);
10860 +extern int unregister_vroot_grb(vroot_grb_func *);
10862 +#endif /* __KERNEL__ */
10864 +#define MAX_VROOT_DEFAULT 8
10867 + * IOCTL commands --- we will commandeer 0x56 ('V')
10870 +#define VROOT_SET_DEV 0x5600
10871 +#define VROOT_CLR_DEV 0x5601
10873 +#endif /* _LINUX_VROOT_H */
10874 diff -NurpP --minimal linux-2.6.35/include/linux/vs_base.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_base.h
10875 --- linux-2.6.35/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
10876 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_base.h 2010-08-02 17:05:06.000000000 +0200
10878 +#ifndef _VS_BASE_H
10879 +#define _VS_BASE_H
10881 +#include "vserver/base.h"
10882 +#include "vserver/check.h"
10883 +#include "vserver/debug.h"
10886 +#warning duplicate inclusion
10888 diff -NurpP --minimal linux-2.6.35/include/linux/vs_context.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_context.h
10889 --- linux-2.6.35/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
10890 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_context.h 2010-08-02 17:05:06.000000000 +0200
10892 +#ifndef _VS_CONTEXT_H
10893 +#define _VS_CONTEXT_H
10895 +#include "vserver/base.h"
10896 +#include "vserver/check.h"
10897 +#include "vserver/context.h"
10898 +#include "vserver/history.h"
10899 +#include "vserver/debug.h"
10901 +#include <linux/sched.h>
10904 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
10906 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
10907 + const char *_file, int _line, void *_here)
10912 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
10913 + vxi, vxi ? vxi->vx_id : 0,
10914 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10916 + __vxh_get_vx_info(vxi, _here);
10918 + atomic_inc(&vxi->vx_usecnt);
10923 +extern void free_vx_info(struct vx_info *);
10925 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
10927 +static inline void __put_vx_info(struct vx_info *vxi,
10928 + const char *_file, int _line, void *_here)
10933 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
10934 + vxi, vxi ? vxi->vx_id : 0,
10935 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10937 + __vxh_put_vx_info(vxi, _here);
10939 + if (atomic_dec_and_test(&vxi->vx_usecnt))
10940 + free_vx_info(vxi);
10944 +#define init_vx_info(p, i) \
10945 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
10947 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
10948 + const char *_file, int _line, void *_here)
10951 + vxlprintk(VXD_CBIT(xid, 3),
10952 + "init_vx_info(%p[#%d.%d])",
10953 + vxi, vxi ? vxi->vx_id : 0,
10954 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10956 + __vxh_init_vx_info(vxi, vxp, _here);
10958 + atomic_inc(&vxi->vx_usecnt);
10964 +#define set_vx_info(p, i) \
10965 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
10967 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
10968 + const char *_file, int _line, void *_here)
10970 + struct vx_info *vxo;
10975 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
10976 + vxi, vxi ? vxi->vx_id : 0,
10977 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10979 + __vxh_set_vx_info(vxi, vxp, _here);
10981 + atomic_inc(&vxi->vx_usecnt);
10982 + vxo = xchg(vxp, vxi);
10987 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
10989 +static inline void __clr_vx_info(struct vx_info **vxp,
10990 + const char *_file, int _line, void *_here)
10992 + struct vx_info *vxo;
10994 + vxo = xchg(vxp, NULL);
10998 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
10999 + vxo, vxo ? vxo->vx_id : 0,
11000 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
11002 + __vxh_clr_vx_info(vxo, vxp, _here);
11004 + if (atomic_dec_and_test(&vxo->vx_usecnt))
11005 + free_vx_info(vxo);
11009 +#define claim_vx_info(v, p) \
11010 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11012 +static inline void __claim_vx_info(struct vx_info *vxi,
11013 + struct task_struct *task,
11014 + const char *_file, int _line, void *_here)
11016 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
11017 + vxi, vxi ? vxi->vx_id : 0,
11018 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11019 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
11020 + task, _file, _line);
11021 + __vxh_claim_vx_info(vxi, task, _here);
11023 + atomic_inc(&vxi->vx_tasks);
11027 +extern void unhash_vx_info(struct vx_info *);
11029 +#define release_vx_info(v, p) \
11030 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11032 +static inline void __release_vx_info(struct vx_info *vxi,
11033 + struct task_struct *task,
11034 + const char *_file, int _line, void *_here)
11036 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
11037 + vxi, vxi ? vxi->vx_id : 0,
11038 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11039 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
11040 + task, _file, _line);
11041 + __vxh_release_vx_info(vxi, task, _here);
11045 + if (atomic_dec_and_test(&vxi->vx_tasks))
11046 + unhash_vx_info(vxi);
11050 +#define task_get_vx_info(p) \
11051 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
11053 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
11054 + const char *_file, int _line, void *_here)
11056 + struct vx_info *vxi;
11059 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
11060 + p, _file, _line);
11061 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
11067 +static inline void __wakeup_vx_info(struct vx_info *vxi)
11069 + if (waitqueue_active(&vxi->vx_wait))
11070 + wake_up_interruptible(&vxi->vx_wait);
11074 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
11076 +static inline void __enter_vx_info(struct vx_info *vxi,
11077 + struct vx_info_save *vxis, const char *_file, int _line)
11079 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
11080 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
11081 + current->xid, current->vx_info, _file, _line);
11082 + vxis->vxi = xchg(¤t->vx_info, vxi);
11083 + vxis->xid = current->xid;
11084 + current->xid = vxi ? vxi->vx_id : 0;
11087 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
11089 +static inline void __leave_vx_info(struct vx_info_save *vxis,
11090 + const char *_file, int _line)
11092 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
11093 + vxis, vxis->xid, vxis->vxi, current,
11094 + current->xid, current->vx_info, _file, _line);
11095 + (void)xchg(¤t->vx_info, vxis->vxi);
11096 + current->xid = vxis->xid;
11100 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
11102 + vxis->vxi = xchg(¤t->vx_info, NULL);
11103 + vxis->xid = xchg(¤t->xid, (xid_t)0);
11106 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
11108 + (void)xchg(¤t->xid, vxis->xid);
11109 + (void)xchg(¤t->vx_info, vxis->vxi);
11112 +#define task_is_init(p) \
11113 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
11115 +static inline int __task_is_init(struct task_struct *p,
11116 + const char *_file, int _line, void *_here)
11118 + int is_init = is_global_init(p);
11122 + is_init = p->vx_info->vx_initpid == p->pid;
11127 +extern void exit_vx_info(struct task_struct *, int);
11128 +extern void exit_vx_info_early(struct task_struct *, int);
11132 +#warning duplicate inclusion
11134 diff -NurpP --minimal linux-2.6.35/include/linux/vs_cowbl.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_cowbl.h
11135 --- linux-2.6.35/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
11136 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_cowbl.h 2010-08-02 21:01:17.000000000 +0200
11138 +#ifndef _VS_COWBL_H
11139 +#define _VS_COWBL_H
11141 +#include <linux/fs.h>
11142 +#include <linux/dcache.h>
11143 +#include <linux/namei.h>
11144 +#include <linux/slab.h>
11146 +extern struct dentry *cow_break_link(const char *pathname);
11148 +static inline int cow_check_and_break(struct path *path)
11150 + struct inode *inode = path->dentry->d_inode;
11153 + /* do we need this check? */
11154 + if (IS_RDONLY(inode))
11157 + if (IS_COW(inode)) {
11158 + if (IS_COW_LINK(inode)) {
11159 + struct dentry *new_dentry, *old_dentry = path->dentry;
11162 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
11166 + pp = d_path(path, buf, PATH_MAX);
11167 + new_dentry = cow_break_link(pp);
11169 + if (!IS_ERR(new_dentry)) {
11170 + path->dentry = new_dentry;
11171 + dput(old_dentry);
11173 + error = PTR_ERR(new_dentry);
11175 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
11176 + inode->i_ctime = CURRENT_TIME;
11177 + mark_inode_dirty(inode);
11184 +#warning duplicate inclusion
11186 diff -NurpP --minimal linux-2.6.35/include/linux/vs_cvirt.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_cvirt.h
11187 --- linux-2.6.35/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
11188 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_cvirt.h 2010-08-02 17:05:06.000000000 +0200
11190 +#ifndef _VS_CVIRT_H
11191 +#define _VS_CVIRT_H
11193 +#include "vserver/cvirt.h"
11194 +#include "vserver/context.h"
11195 +#include "vserver/base.h"
11196 +#include "vserver/check.h"
11197 +#include "vserver/debug.h"
11200 +static inline void vx_activate_task(struct task_struct *p)
11202 + struct vx_info *vxi;
11204 + if ((vxi = p->vx_info)) {
11205 + vx_update_load(vxi);
11206 + atomic_inc(&vxi->cvirt.nr_running);
11210 +static inline void vx_deactivate_task(struct task_struct *p)
11212 + struct vx_info *vxi;
11214 + if ((vxi = p->vx_info)) {
11215 + vx_update_load(vxi);
11216 + atomic_dec(&vxi->cvirt.nr_running);
11220 +static inline void vx_uninterruptible_inc(struct task_struct *p)
11222 + struct vx_info *vxi;
11224 + if ((vxi = p->vx_info))
11225 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
11228 +static inline void vx_uninterruptible_dec(struct task_struct *p)
11230 + struct vx_info *vxi;
11232 + if ((vxi = p->vx_info))
11233 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
11238 +#warning duplicate inclusion
11240 diff -NurpP --minimal linux-2.6.35/include/linux/vs_device.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_device.h
11241 --- linux-2.6.35/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
11242 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_device.h 2010-08-02 17:05:06.000000000 +0200
11244 +#ifndef _VS_DEVICE_H
11245 +#define _VS_DEVICE_H
11247 +#include "vserver/base.h"
11248 +#include "vserver/device.h"
11249 +#include "vserver/debug.h"
11252 +#ifdef CONFIG_VSERVER_DEVICE
11254 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
11256 +#define vs_device_perm(v, d, m, p) \
11257 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
11262 +int vs_map_device(struct vx_info *vxi,
11263 + dev_t device, dev_t *target, umode_t mode)
11266 + *target = device;
11270 +#define vs_device_perm(v, d, m, p) ((p) == (p))
11275 +#define vs_map_chrdev(d, t, p) \
11276 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
11277 +#define vs_map_blkdev(d, t, p) \
11278 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
11280 +#define vs_chrdev_perm(d, p) \
11281 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
11282 +#define vs_blkdev_perm(d, p) \
11283 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
11287 +#warning duplicate inclusion
11289 diff -NurpP --minimal linux-2.6.35/include/linux/vs_dlimit.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_dlimit.h
11290 --- linux-2.6.35/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
11291 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_dlimit.h 2010-08-02 22:21:17.000000000 +0200
11293 +#ifndef _VS_DLIMIT_H
11294 +#define _VS_DLIMIT_H
11296 +#include <linux/fs.h>
11298 +#include "vserver/dlimit.h"
11299 +#include "vserver/base.h"
11300 +#include "vserver/debug.h"
11303 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
11305 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
11306 + const char *_file, int _line)
11310 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
11311 + dli, dli ? dli->dl_tag : 0,
11312 + dli ? atomic_read(&dli->dl_usecnt) : 0,
11314 + atomic_inc(&dli->dl_usecnt);
11319 +#define free_dl_info(i) \
11320 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
11322 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
11324 +static inline void __put_dl_info(struct dl_info *dli,
11325 + const char *_file, int _line)
11329 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
11330 + dli, dli ? dli->dl_tag : 0,
11331 + dli ? atomic_read(&dli->dl_usecnt) : 0,
11333 + if (atomic_dec_and_test(&dli->dl_usecnt))
11334 + free_dl_info(dli);
11338 +#define __dlimit_char(d) ((d) ? '*' : ' ')
11340 +static inline int __dl_alloc_space(struct super_block *sb,
11341 + tag_t tag, dlsize_t nr, const char *file, int line)
11343 + struct dl_info *dli = NULL;
11348 + dli = locate_dl_info(sb, tag);
11352 + spin_lock(&dli->dl_lock);
11353 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
11355 + dli->dl_space_used += nr;
11356 + spin_unlock(&dli->dl_lock);
11357 + put_dl_info(dli);
11359 + vxlprintk(VXD_CBIT(dlim, 1),
11360 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
11361 + sb, tag, __dlimit_char(dli), (long long)nr,
11362 + ret, file, line);
11363 + return ret ? -ENOSPC : 0;
11366 +static inline void __dl_free_space(struct super_block *sb,
11367 + tag_t tag, dlsize_t nr, const char *_file, int _line)
11369 + struct dl_info *dli = NULL;
11373 + dli = locate_dl_info(sb, tag);
11377 + spin_lock(&dli->dl_lock);
11378 + if (dli->dl_space_used > nr)
11379 + dli->dl_space_used -= nr;
11381 + dli->dl_space_used = 0;
11382 + spin_unlock(&dli->dl_lock);
11383 + put_dl_info(dli);
11385 + vxlprintk(VXD_CBIT(dlim, 1),
11386 + "FREE (%p,#%d)%c %lld bytes",
11387 + sb, tag, __dlimit_char(dli), (long long)nr,
11391 +static inline int __dl_alloc_inode(struct super_block *sb,
11392 + tag_t tag, const char *_file, int _line)
11394 + struct dl_info *dli;
11397 + dli = locate_dl_info(sb, tag);
11401 + spin_lock(&dli->dl_lock);
11402 + dli->dl_inodes_used++;
11403 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
11404 + spin_unlock(&dli->dl_lock);
11405 + put_dl_info(dli);
11407 + vxlprintk(VXD_CBIT(dlim, 0),
11408 + "ALLOC (%p,#%d)%c inode (%d)",
11409 + sb, tag, __dlimit_char(dli), ret, _file, _line);
11410 + return ret ? -ENOSPC : 0;
11413 +static inline void __dl_free_inode(struct super_block *sb,
11414 + tag_t tag, const char *_file, int _line)
11416 + struct dl_info *dli;
11418 + dli = locate_dl_info(sb, tag);
11422 + spin_lock(&dli->dl_lock);
11423 + if (dli->dl_inodes_used > 1)
11424 + dli->dl_inodes_used--;
11426 + dli->dl_inodes_used = 0;
11427 + spin_unlock(&dli->dl_lock);
11428 + put_dl_info(dli);
11430 + vxlprintk(VXD_CBIT(dlim, 0),
11431 + "FREE (%p,#%d)%c inode",
11432 + sb, tag, __dlimit_char(dli), _file, _line);
11435 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
11436 + unsigned long long *free_blocks, unsigned long long *root_blocks,
11437 + const char *_file, int _line)
11439 + struct dl_info *dli;
11440 + uint64_t broot, bfree;
11442 + dli = locate_dl_info(sb, tag);
11446 + spin_lock(&dli->dl_lock);
11447 + broot = (dli->dl_space_total -
11448 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
11449 + >> sb->s_blocksize_bits;
11450 + bfree = (dli->dl_space_total - dli->dl_space_used)
11451 + >> sb->s_blocksize_bits;
11452 + spin_unlock(&dli->dl_lock);
11454 + vxlprintk(VXD_CBIT(dlim, 2),
11455 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
11456 + (long long)bfree, (long long)broot,
11457 + *free_blocks, *root_blocks, dli->dl_nrlmult,
11459 + if (free_blocks) {
11460 + if (*free_blocks > bfree)
11461 + *free_blocks = bfree;
11463 + if (root_blocks) {
11464 + if (*root_blocks > broot)
11465 + *root_blocks = broot;
11467 + put_dl_info(dli);
11470 +#define dl_prealloc_space(in, bytes) \
11471 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11472 + __FILE__, __LINE__ )
11474 +#define dl_alloc_space(in, bytes) \
11475 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11476 + __FILE__, __LINE__ )
11478 +#define dl_reserve_space(in, bytes) \
11479 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11480 + __FILE__, __LINE__ )
11482 +#define dl_claim_space(in, bytes) (0)
11484 +#define dl_release_space(in, bytes) \
11485 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11486 + __FILE__, __LINE__ )
11488 +#define dl_free_space(in, bytes) \
11489 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11490 + __FILE__, __LINE__ )
11494 +#define dl_alloc_inode(in) \
11495 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11497 +#define dl_free_inode(in) \
11498 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11501 +#define dl_adjust_block(sb, tag, fb, rb) \
11502 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
11506 +#warning duplicate inclusion
11508 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/base.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/base.h
11509 --- linux-2.6.35/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
11510 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/base.h 2010-08-02 17:05:06.000000000 +0200
11512 +#ifndef _VX_BASE_H
11513 +#define _VX_BASE_H
11516 +/* context state changes */
11528 +#define vx_task_xid(t) ((t)->xid)
11530 +#define vx_current_xid() vx_task_xid(current)
11532 +#define current_vx_info() (current->vx_info)
11535 +#define nx_task_nid(t) ((t)->nid)
11537 +#define nx_current_nid() nx_task_nid(current)
11539 +#define current_nx_info() (current->nx_info)
11542 +/* generic flag merging */
11544 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
11546 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11548 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
11550 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
11553 +/* context flags */
11555 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
11557 +#define vx_current_flags() __vx_flags(current_vx_info())
11559 +#define vx_info_flags(v, m, f) \
11560 + vs_check_flags(__vx_flags(v), m, f)
11562 +#define task_vx_flags(t, m, f) \
11563 + ((t) && vx_info_flags((t)->vx_info, m, f))
11565 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11568 +/* context caps */
11570 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
11572 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
11574 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
11576 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
11580 +/* network flags */
11582 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
11584 +#define nx_current_flags() __nx_flags(current_nx_info())
11586 +#define nx_info_flags(n, m, f) \
11587 + vs_check_flags(__nx_flags(n), m, f)
11589 +#define task_nx_flags(t, m, f) \
11590 + ((t) && nx_info_flags((t)->nx_info, m, f))
11592 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11595 +/* network caps */
11597 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
11599 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
11601 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
11603 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
11606 +/* context mask capabilities */
11608 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11610 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
11612 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
11615 +/* context bcap mask */
11617 +#define __vx_bcaps(v) ((v)->vx_bcaps)
11619 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
11622 +/* mask given bcaps */
11624 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11626 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
11629 +/* masked cap_bset */
11631 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
11633 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
11636 +#define vx_info_mbcap(v, b) \
11637 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11638 + vx_info_bcaps(v, b) : (b))
11640 +#define task_vx_mbcap(t, b) \
11641 + vx_info_mbcap((t)->vx_info, (t)->b)
11643 +#define vx_mbcap(b) task_vx_mbcap(current, b)
11646 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11648 +#define vx_capable(b, c) (capable(b) || \
11649 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
11651 +#define nx_capable(b, c) (capable(b) || \
11652 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
11654 +#define vx_task_initpid(t, n) \
11655 + ((t)->vx_info && \
11656 + ((t)->vx_info->vx_initpid == (n)))
11658 +#define vx_current_initpid(n) vx_task_initpid(current, n)
11661 +/* context unshare mask */
11663 +#define __vx_umask(v) ((v)->vx_umask)
11665 +#define vx_current_umask() __vx_umask(current_vx_info())
11667 +#define vx_can_unshare(b, f) (capable(b) || \
11668 + (cap_raised(current_cap(), b) && \
11669 + !((f) & ~vx_current_umask())))
11672 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
11674 +#define vx_info_state(v, m) (__vx_state(v) & (m))
11677 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
11679 +#define nx_info_state(n, m) (__nx_state(n) & (m))
11682 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cacct_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct_cmd.h
11683 --- linux-2.6.35/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
11684 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct_cmd.h 2010-08-02 17:05:06.000000000 +0200
11686 +#ifndef _VX_CACCT_CMD_H
11687 +#define _VX_CACCT_CMD_H
11690 +/* virtual host info name commands */
11692 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
11694 +struct vcmd_sock_stat_v0 {
11696 + uint32_t count[3];
11697 + uint64_t total[3];
11703 +#include <linux/compiler.h>
11705 +extern int vc_sock_stat(struct vx_info *, void __user *);
11707 +#endif /* __KERNEL__ */
11708 +#endif /* _VX_CACCT_CMD_H */
11709 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cacct_def.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct_def.h
11710 --- linux-2.6.35/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
11711 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct_def.h 2010-08-02 17:05:06.000000000 +0200
11713 +#ifndef _VX_CACCT_DEF_H
11714 +#define _VX_CACCT_DEF_H
11716 +#include <asm/atomic.h>
11717 +#include <linux/vserver/cacct.h>
11720 +struct _vx_sock_acc {
11721 + atomic_long_t count;
11722 + atomic_long_t total;
11725 +/* context sub struct */
11727 +struct _vx_cacct {
11728 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11729 + atomic_t slab[8];
11730 + atomic_t page[6][8];
11733 +#ifdef CONFIG_VSERVER_DEBUG
11735 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11739 + printk("\t_vx_cacct:");
11740 + for (i = 0; i < 6; i++) {
11741 + struct _vx_sock_acc *ptr = cacct->sock[i];
11743 + printk("\t [%d] =", i);
11744 + for (j = 0; j < 3; j++) {
11745 + printk(" [%d] = %8lu, %8lu", j,
11746 + atomic_long_read(&ptr[j].count),
11747 + atomic_long_read(&ptr[j].total));
11755 +#endif /* _VX_CACCT_DEF_H */
11756 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cacct.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct.h
11757 --- linux-2.6.35/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
11758 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct.h 2010-08-02 17:05:06.000000000 +0200
11760 +#ifndef _VX_CACCT_H
11761 +#define _VX_CACCT_H
11764 +enum sock_acc_field {
11765 + VXA_SOCK_UNSPEC = 0,
11771 + VXA_SOCK_SIZE /* array size */
11774 +#endif /* _VX_CACCT_H */
11775 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cacct_int.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct_int.h
11776 --- linux-2.6.35/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
11777 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct_int.h 2010-08-02 17:05:06.000000000 +0200
11779 +#ifndef _VX_CACCT_INT_H
11780 +#define _VX_CACCT_INT_H
11786 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11788 + return atomic_long_read(&cacct->sock[type][pos].count);
11793 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11795 + return atomic_long_read(&cacct->sock[type][pos].total);
11798 +#endif /* __KERNEL__ */
11799 +#endif /* _VX_CACCT_INT_H */
11800 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/check.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/check.h
11801 --- linux-2.6.35/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
11802 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/check.h 2010-08-02 17:05:06.000000000 +0200
11804 +#ifndef _VS_CHECK_H
11805 +#define _VS_CHECK_H
11808 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
11810 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11811 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
11813 +#define MIN_D_CONTEXT 65536
11816 +/* check conditions */
11818 +#define VS_ADMIN 0x0001
11819 +#define VS_WATCH 0x0002
11820 +#define VS_HIDE 0x0004
11821 +#define VS_HOSTID 0x0008
11823 +#define VS_IDENT 0x0010
11824 +#define VS_EQUIV 0x0020
11825 +#define VS_PARENT 0x0040
11826 +#define VS_CHILD 0x0080
11828 +#define VS_ARG_MASK 0x00F0
11830 +#define VS_DYNAMIC 0x0100
11831 +#define VS_STATIC 0x0200
11833 +#define VS_ATR_MASK 0x0F00
11835 +#ifdef CONFIG_VSERVER_PRIVACY
11836 +#define VS_ADMIN_P (0)
11837 +#define VS_WATCH_P (0)
11839 +#define VS_ADMIN_P VS_ADMIN
11840 +#define VS_WATCH_P VS_WATCH
11843 +#define VS_HARDIRQ 0x1000
11844 +#define VS_SOFTIRQ 0x2000
11845 +#define VS_IRQ 0x4000
11847 +#define VS_IRQ_MASK 0xF000
11849 +#include <linux/hardirq.h>
11852 + * check current context for ADMIN/WATCH and
11853 + * optionally against supplied argument
11855 +static inline int __vs_check(int cid, int id, unsigned int mode)
11857 + if (mode & VS_ARG_MASK) {
11858 + if ((mode & VS_IDENT) && (id == cid))
11861 + if (mode & VS_ATR_MASK) {
11862 + if ((mode & VS_DYNAMIC) &&
11863 + (id >= MIN_D_CONTEXT) &&
11864 + (id <= MAX_S_CONTEXT))
11866 + if ((mode & VS_STATIC) &&
11867 + (id > 1) && (id < MIN_D_CONTEXT))
11870 + if (mode & VS_IRQ_MASK) {
11871 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11873 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11875 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11878 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11879 + ((mode & VS_WATCH) && (cid == 1)) ||
11880 + ((mode & VS_HOSTID) && (id == 0)));
11883 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11885 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11888 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11890 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11893 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/context_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/context_cmd.h
11894 --- linux-2.6.35/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
11895 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/context_cmd.h 2010-08-02 17:05:06.000000000 +0200
11897 +#ifndef _VX_CONTEXT_CMD_H
11898 +#define _VX_CONTEXT_CMD_H
11901 +/* vinfo commands */
11903 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
11906 +extern int vc_task_xid(uint32_t);
11908 +#endif /* __KERNEL__ */
11910 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
11912 +struct vcmd_vx_info_v0 {
11914 + uint32_t initpid;
11915 + /* more to come */
11919 +extern int vc_vx_info(struct vx_info *, void __user *);
11921 +#endif /* __KERNEL__ */
11923 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
11925 +struct vcmd_ctx_stat_v0 {
11928 + /* more to come */
11932 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11934 +#endif /* __KERNEL__ */
11936 +/* context commands */
11938 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
11939 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
11941 +struct vcmd_ctx_create {
11942 + uint64_t flagword;
11945 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
11946 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
11948 +struct vcmd_ctx_migrate {
11949 + uint64_t flagword;
11953 +extern int vc_ctx_create(uint32_t, void __user *);
11954 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11956 +#endif /* __KERNEL__ */
11959 +/* flag commands */
11961 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
11962 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
11964 +struct vcmd_ctx_flags_v0 {
11965 + uint64_t flagword;
11970 +extern int vc_get_cflags(struct vx_info *, void __user *);
11971 +extern int vc_set_cflags(struct vx_info *, void __user *);
11973 +#endif /* __KERNEL__ */
11976 +/* context caps commands */
11978 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
11979 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
11981 +struct vcmd_ctx_caps_v1 {
11987 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11988 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11990 +#endif /* __KERNEL__ */
11993 +/* bcaps commands */
11995 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
11996 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
11998 +struct vcmd_bcaps {
12004 +extern int vc_get_bcaps(struct vx_info *, void __user *);
12005 +extern int vc_set_bcaps(struct vx_info *, void __user *);
12007 +#endif /* __KERNEL__ */
12010 +/* umask commands */
12012 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
12013 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
12015 +struct vcmd_umask {
12021 +extern int vc_get_umask(struct vx_info *, void __user *);
12022 +extern int vc_set_umask(struct vx_info *, void __user *);
12024 +#endif /* __KERNEL__ */
12029 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
12030 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
12032 +struct vcmd_badness_v0 {
12037 +extern int vc_get_badness(struct vx_info *, void __user *);
12038 +extern int vc_set_badness(struct vx_info *, void __user *);
12040 +#endif /* __KERNEL__ */
12041 +#endif /* _VX_CONTEXT_CMD_H */
12042 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/context.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/context.h
12043 --- linux-2.6.35/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
12044 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/context.h 2010-08-02 17:05:06.000000000 +0200
12046 +#ifndef _VX_CONTEXT_H
12047 +#define _VX_CONTEXT_H
12049 +#include <linux/types.h>
12050 +#include <linux/capability.h>
12053 +/* context flags */
12055 +#define VXF_INFO_SCHED 0x00000002
12056 +#define VXF_INFO_NPROC 0x00000004
12057 +#define VXF_INFO_PRIVATE 0x00000008
12059 +#define VXF_INFO_INIT 0x00000010
12060 +#define VXF_INFO_HIDE 0x00000020
12061 +#define VXF_INFO_ULIMIT 0x00000040
12062 +#define VXF_INFO_NSPACE 0x00000080
12064 +#define VXF_SCHED_HARD 0x00000100
12065 +#define VXF_SCHED_PRIO 0x00000200
12066 +#define VXF_SCHED_PAUSE 0x00000400
12068 +#define VXF_VIRT_MEM 0x00010000
12069 +#define VXF_VIRT_UPTIME 0x00020000
12070 +#define VXF_VIRT_CPU 0x00040000
12071 +#define VXF_VIRT_LOAD 0x00080000
12072 +#define VXF_VIRT_TIME 0x00100000
12074 +#define VXF_HIDE_MOUNT 0x01000000
12075 +/* was VXF_HIDE_NETIF 0x02000000 */
12076 +#define VXF_HIDE_VINFO 0x04000000
12078 +#define VXF_STATE_SETUP (1ULL << 32)
12079 +#define VXF_STATE_INIT (1ULL << 33)
12080 +#define VXF_STATE_ADMIN (1ULL << 34)
12082 +#define VXF_SC_HELPER (1ULL << 36)
12083 +#define VXF_REBOOT_KILL (1ULL << 37)
12084 +#define VXF_PERSISTENT (1ULL << 38)
12086 +#define VXF_FORK_RSS (1ULL << 48)
12087 +#define VXF_PROLIFIC (1ULL << 49)
12089 +#define VXF_IGNEG_NICE (1ULL << 52)
12091 +#define VXF_ONE_TIME (0x0007ULL << 32)
12093 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
12096 +/* context migration */
12098 +#define VXM_SET_INIT 0x00000001
12099 +#define VXM_SET_REAPER 0x00000002
12101 +/* context caps */
12103 +#define VXC_CAP_MASK 0x00000000
12105 +#define VXC_SET_UTSNAME 0x00000001
12106 +#define VXC_SET_RLIMIT 0x00000002
12107 +#define VXC_FS_SECURITY 0x00000004
12108 +#define VXC_FS_TRUSTED 0x00000008
12109 +#define VXC_TIOCSTI 0x00000010
12111 +/* was VXC_RAW_ICMP 0x00000100 */
12112 +#define VXC_SYSLOG 0x00001000
12113 +#define VXC_OOM_ADJUST 0x00002000
12114 +#define VXC_AUDIT_CONTROL 0x00004000
12116 +#define VXC_SECURE_MOUNT 0x00010000
12117 +#define VXC_SECURE_REMOUNT 0x00020000
12118 +#define VXC_BINARY_MOUNT 0x00040000
12120 +#define VXC_QUOTA_CTL 0x00100000
12121 +#define VXC_ADMIN_MAPPER 0x00200000
12122 +#define VXC_ADMIN_CLOOP 0x00400000
12124 +#define VXC_KTHREAD 0x01000000
12125 +#define VXC_NAMESPACE 0x02000000
12130 +#include <linux/list.h>
12131 +#include <linux/spinlock.h>
12132 +#include <linux/rcupdate.h>
12134 +#include "limit_def.h"
12135 +#include "sched_def.h"
12136 +#include "cvirt_def.h"
12137 +#include "cacct_def.h"
12138 +#include "device_def.h"
12140 +#define VX_SPACES 2
12142 +struct _vx_info_pc {
12143 + struct _vx_sched_pc sched_pc;
12144 + struct _vx_cvirt_pc cvirt_pc;
12148 + struct hlist_node vx_hlist; /* linked list of contexts */
12149 + xid_t vx_id; /* context id */
12150 + atomic_t vx_usecnt; /* usage count */
12151 + atomic_t vx_tasks; /* tasks count */
12152 + struct vx_info *vx_parent; /* parent context */
12153 + int vx_state; /* context state */
12155 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
12156 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
12157 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
12159 + uint64_t vx_flags; /* context flags */
12160 + uint64_t vx_ccaps; /* context caps (vserver) */
12161 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
12162 + unsigned long vx_umask; /* unshare mask (guest) */
12164 + struct task_struct *vx_reaper; /* guest reaper process */
12165 + pid_t vx_initpid; /* PID of guest init */
12166 + int64_t vx_badness_bias; /* OOM points bias */
12168 + struct _vx_limit limit; /* vserver limits */
12169 + struct _vx_sched sched; /* vserver scheduler */
12170 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
12171 + struct _vx_cacct cacct; /* context accounting */
12173 + struct _vx_device dmap; /* default device map targets */
12175 +#ifndef CONFIG_SMP
12176 + struct _vx_info_pc info_pc; /* per cpu data */
12178 + struct _vx_info_pc *ptr_pc; /* per cpu array */
12181 + wait_queue_head_t vx_wait; /* context exit waitqueue */
12182 + int reboot_cmd; /* last sys_reboot() cmd */
12183 + int exit_code; /* last process exit code */
12185 + char vx_name[65]; /* vserver name */
12188 +#ifndef CONFIG_SMP
12189 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
12190 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
12192 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
12193 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
12196 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
12199 +struct vx_info_save {
12200 + struct vx_info *vxi;
12205 +/* status flags */
12207 +#define VXS_HASHED 0x0001
12208 +#define VXS_PAUSED 0x0010
12209 +#define VXS_SHUTDOWN 0x0100
12210 +#define VXS_HELPER 0x1000
12211 +#define VXS_RELEASED 0x8000
12214 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
12215 +extern void release_vx_info(struct vx_info *, struct task_struct *);
12217 +extern struct vx_info *lookup_vx_info(int);
12218 +extern struct vx_info *lookup_or_create_vx_info(int);
12220 +extern int get_xid_list(int, unsigned int *, int);
12221 +extern int xid_is_hashed(xid_t);
12223 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
12225 +extern long vs_state_change(struct vx_info *, unsigned int);
12228 +#endif /* __KERNEL__ */
12229 +#endif /* _VX_CONTEXT_H */
12230 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cvirt_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cvirt_cmd.h
12231 --- linux-2.6.35/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
12232 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cvirt_cmd.h 2010-08-02 17:05:06.000000000 +0200
12234 +#ifndef _VX_CVIRT_CMD_H
12235 +#define _VX_CVIRT_CMD_H
12238 +/* virtual host info name commands */
12240 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
12241 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
12243 +struct vcmd_vhi_name_v0 {
12249 +enum vhi_name_field {
12250 + VHIN_CONTEXT = 0,
12262 +#include <linux/compiler.h>
12264 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
12265 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
12267 +#endif /* __KERNEL__ */
12269 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
12271 +struct vcmd_virt_stat_v0 {
12274 + uint32_t nr_threads;
12275 + uint32_t nr_running;
12276 + uint32_t nr_uninterruptible;
12277 + uint32_t nr_onhold;
12278 + uint32_t nr_forks;
12279 + uint32_t load[3];
12283 +extern int vc_virt_stat(struct vx_info *, void __user *);
12285 +#endif /* __KERNEL__ */
12286 +#endif /* _VX_CVIRT_CMD_H */
12287 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cvirt_def.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cvirt_def.h
12288 --- linux-2.6.35/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
12289 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cvirt_def.h 2010-08-02 17:05:06.000000000 +0200
12291 +#ifndef _VX_CVIRT_DEF_H
12292 +#define _VX_CVIRT_DEF_H
12294 +#include <linux/jiffies.h>
12295 +#include <linux/spinlock.h>
12296 +#include <linux/wait.h>
12297 +#include <linux/time.h>
12298 +#include <asm/atomic.h>
12301 +struct _vx_usage_stat {
12305 + uint64_t softirq;
12311 +struct _vx_syslog {
12312 + wait_queue_head_t log_wait;
12313 + spinlock_t logbuf_lock; /* lock for the log buffer */
12315 + unsigned long log_start; /* next char to be read by syslog() */
12316 + unsigned long con_start; /* next char to be sent to consoles */
12317 + unsigned long log_end; /* most-recently-written-char + 1 */
12318 + unsigned long logged_chars; /* #chars since last read+clear operation */
12320 + char log_buf[1024];
12324 +/* context sub struct */
12326 +struct _vx_cvirt {
12327 + atomic_t nr_threads; /* number of current threads */
12328 + atomic_t nr_running; /* number of running threads */
12329 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
12331 + atomic_t nr_onhold; /* processes on hold */
12332 + uint32_t onhold_last; /* jiffies when put on hold */
12334 + struct timeval bias_tv; /* time offset to the host */
12335 + struct timespec bias_idle;
12336 + struct timespec bias_uptime; /* context creation point */
12337 + uint64_t bias_clock; /* offset in clock_t */
12339 + spinlock_t load_lock; /* lock for the load averages */
12340 + atomic_t load_updates; /* nr of load updates done so far */
12341 + uint32_t load_last; /* last time load was calculated */
12342 + uint32_t load[3]; /* load averages 1,5,15 */
12344 + atomic_t total_forks; /* number of forks so far */
12346 + struct _vx_syslog syslog;
12349 +struct _vx_cvirt_pc {
12350 + struct _vx_usage_stat cpustat;
12354 +#ifdef CONFIG_VSERVER_DEBUG
12356 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
12358 + printk("\t_vx_cvirt:\n");
12359 + printk("\t threads: %4d, %4d, %4d, %4d\n",
12360 + atomic_read(&cvirt->nr_threads),
12361 + atomic_read(&cvirt->nr_running),
12362 + atomic_read(&cvirt->nr_uninterruptible),
12363 + atomic_read(&cvirt->nr_onhold));
12364 + /* add rest here */
12365 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
12370 +#endif /* _VX_CVIRT_DEF_H */
12371 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cvirt.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cvirt.h
12372 --- linux-2.6.35/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
12373 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cvirt.h 2010-08-02 17:05:06.000000000 +0200
12375 +#ifndef _VX_CVIRT_H
12376 +#define _VX_CVIRT_H
12383 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12388 +void vx_update_load(struct vx_info *);
12391 +int vx_do_syslog(int, char __user *, int);
12393 +#endif /* __KERNEL__ */
12394 +#endif /* _VX_CVIRT_H */
12395 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/debug_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/debug_cmd.h
12396 --- linux-2.6.35/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
12397 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/debug_cmd.h 2010-08-02 17:05:06.000000000 +0200
12399 +#ifndef _VX_DEBUG_CMD_H
12400 +#define _VX_DEBUG_CMD_H
12403 +/* debug commands */
12405 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
12407 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
12408 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
12410 +struct vcmd_read_history_v0 {
12413 + char __user *data;
12416 +struct vcmd_read_monitor_v0 {
12419 + char __user *data;
12425 +#ifdef CONFIG_COMPAT
12427 +#include <asm/compat.h>
12429 +struct vcmd_read_history_v0_x32 {
12432 + compat_uptr_t data_ptr;
12435 +struct vcmd_read_monitor_v0_x32 {
12438 + compat_uptr_t data_ptr;
12441 +#endif /* CONFIG_COMPAT */
12443 +extern int vc_dump_history(uint32_t);
12445 +extern int vc_read_history(uint32_t, void __user *);
12446 +extern int vc_read_monitor(uint32_t, void __user *);
12448 +#ifdef CONFIG_COMPAT
12450 +extern int vc_read_history_x32(uint32_t, void __user *);
12451 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12453 +#endif /* CONFIG_COMPAT */
12455 +#endif /* __KERNEL__ */
12456 +#endif /* _VX_DEBUG_CMD_H */
12457 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/debug.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/debug.h
12458 --- linux-2.6.35/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
12459 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/debug.h 2010-08-02 17:05:06.000000000 +0200
12461 +#ifndef _VX_DEBUG_H
12462 +#define _VX_DEBUG_H
12465 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
12466 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
12467 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
12469 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
12470 + imajor((d)->bd_inode), iminor((d)->bd_inode)
12471 +#define VXF_DEV "%p[%lu,%d:%d]"
12474 +#define vxd_path(p) \
12475 + ({ static char _buffer[PATH_MAX]; \
12476 + d_path(p, _buffer, sizeof(_buffer)); })
12478 +#define vxd_cond_path(n) \
12479 + ((n) ? vxd_path(&(n)->path) : "<null>" )
12482 +#ifdef CONFIG_VSERVER_DEBUG
12484 +extern unsigned int vx_debug_switch;
12485 +extern unsigned int vx_debug_xid;
12486 +extern unsigned int vx_debug_nid;
12487 +extern unsigned int vx_debug_tag;
12488 +extern unsigned int vx_debug_net;
12489 +extern unsigned int vx_debug_limit;
12490 +extern unsigned int vx_debug_cres;
12491 +extern unsigned int vx_debug_dlim;
12492 +extern unsigned int vx_debug_quota;
12493 +extern unsigned int vx_debug_cvirt;
12494 +extern unsigned int vx_debug_space;
12495 +extern unsigned int vx_debug_misc;
12498 +#define VX_LOGLEVEL "vxD: "
12499 +#define VX_PROC_FMT "%p: "
12500 +#define VX_PROCESS current
12502 +#define vxdprintk(c, f, x...) \
12505 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
12506 + VX_PROCESS , ##x); \
12509 +#define vxlprintk(c, f, x...) \
12512 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
12515 +#define vxfprintk(c, f, x...) \
12518 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
12524 +void dump_vx_info(struct vx_info *, int);
12525 +void dump_vx_info_inactive(int);
12527 +#else /* CONFIG_VSERVER_DEBUG */
12529 +#define vx_debug_switch 0
12530 +#define vx_debug_xid 0
12531 +#define vx_debug_nid 0
12532 +#define vx_debug_tag 0
12533 +#define vx_debug_net 0
12534 +#define vx_debug_limit 0
12535 +#define vx_debug_cres 0
12536 +#define vx_debug_dlim 0
12537 +#define vx_debug_cvirt 0
12539 +#define vxdprintk(x...) do { } while (0)
12540 +#define vxlprintk(x...) do { } while (0)
12541 +#define vxfprintk(x...) do { } while (0)
12543 +#endif /* CONFIG_VSERVER_DEBUG */
12546 +#ifdef CONFIG_VSERVER_WARN
12548 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
12549 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
12550 +#define VX_WARN_XID "[xid #%u] "
12551 +#define VX_WARN_NID "[nid #%u] "
12552 +#define VX_WARN_TAG "[tag #%u] "
12554 +#define vxwprintk(c, f, x...) \
12557 + printk(VX_WARNLEVEL f "\n", ##x); \
12560 +#else /* CONFIG_VSERVER_WARN */
12562 +#define vxwprintk(x...) do { } while (0)
12564 +#endif /* CONFIG_VSERVER_WARN */
12566 +#define vxwprintk_task(c, f, x...) \
12567 + vxwprintk(c, VX_WARN_TASK f, \
12568 + current->comm, current->pid, \
12569 + current->xid, current->nid, current->tag, ##x)
12570 +#define vxwprintk_xid(c, f, x...) \
12571 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
12572 +#define vxwprintk_nid(c, f, x...) \
12573 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
12574 +#define vxwprintk_tag(c, f, x...) \
12575 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12577 +#ifdef CONFIG_VSERVER_DEBUG
12578 +#define vxd_assert_lock(l) assert_spin_locked(l)
12579 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12580 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12582 +#define vxd_assert_lock(l) do { } while (0)
12583 +#define vxd_assert(c, f, x...) do { } while (0)
12587 +#endif /* _VX_DEBUG_H */
12588 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/device_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/device_cmd.h
12589 --- linux-2.6.35/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
12590 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/device_cmd.h 2010-08-02 17:05:06.000000000 +0200
12592 +#ifndef _VX_DEVICE_CMD_H
12593 +#define _VX_DEVICE_CMD_H
12596 +/* device vserver commands */
12598 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
12599 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
12601 +struct vcmd_set_mapping_v0 {
12602 + const char __user *device;
12603 + const char __user *target;
12610 +#ifdef CONFIG_COMPAT
12612 +#include <asm/compat.h>
12614 +struct vcmd_set_mapping_v0_x32 {
12615 + compat_uptr_t device_ptr;
12616 + compat_uptr_t target_ptr;
12620 +#endif /* CONFIG_COMPAT */
12622 +#include <linux/compiler.h>
12624 +extern int vc_set_mapping(struct vx_info *, void __user *);
12625 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12627 +#ifdef CONFIG_COMPAT
12629 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12630 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12632 +#endif /* CONFIG_COMPAT */
12634 +#endif /* __KERNEL__ */
12635 +#endif /* _VX_DEVICE_CMD_H */
12636 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/device_def.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/device_def.h
12637 --- linux-2.6.35/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
12638 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/device_def.h 2010-08-02 17:05:06.000000000 +0200
12640 +#ifndef _VX_DEVICE_DEF_H
12641 +#define _VX_DEVICE_DEF_H
12643 +#include <linux/types.h>
12645 +struct vx_dmap_target {
12650 +struct _vx_device {
12651 +#ifdef CONFIG_VSERVER_DEVICE
12652 + struct vx_dmap_target targets[2];
12656 +#endif /* _VX_DEVICE_DEF_H */
12657 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/device.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/device.h
12658 --- linux-2.6.35/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
12659 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/device.h 2010-08-02 17:05:06.000000000 +0200
12661 +#ifndef _VX_DEVICE_H
12662 +#define _VX_DEVICE_H
12665 +#define DATTR_CREATE 0x00000001
12666 +#define DATTR_OPEN 0x00000002
12668 +#define DATTR_REMAP 0x00000010
12670 +#define DATTR_MASK 0x00000013
12673 +#else /* _VX_DEVICE_H */
12674 +#warning duplicate inclusion
12675 +#endif /* _VX_DEVICE_H */
12676 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/dlimit_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/dlimit_cmd.h
12677 --- linux-2.6.35/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12678 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/dlimit_cmd.h 2010-08-02 17:05:06.000000000 +0200
12680 +#ifndef _VX_DLIMIT_CMD_H
12681 +#define _VX_DLIMIT_CMD_H
12684 +/* dlimit vserver commands */
12686 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12687 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12689 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12690 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12692 +struct vcmd_ctx_dlimit_base_v0 {
12693 + const char __user *name;
12697 +struct vcmd_ctx_dlimit_v0 {
12698 + const char __user *name;
12699 + uint32_t space_used; /* used space in kbytes */
12700 + uint32_t space_total; /* maximum space in kbytes */
12701 + uint32_t inodes_used; /* used inodes */
12702 + uint32_t inodes_total; /* maximum inodes */
12703 + uint32_t reserved; /* reserved for root in % */
12707 +#define CDLIM_UNSET ((uint32_t)0UL)
12708 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12709 +#define CDLIM_KEEP ((uint32_t)~1UL)
12711 +#define DLIME_UNIT 0
12712 +#define DLIME_KILO 1
12713 +#define DLIME_MEGA 2
12714 +#define DLIME_GIGA 3
12716 +#define DLIMF_SHIFT 0x10
12718 +#define DLIMS_USED 0
12719 +#define DLIMS_TOTAL 2
12722 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12724 + int exp = (flags & DLIMF_SHIFT) ?
12725 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12726 + return ((uint64_t)val) << (10 * exp);
12730 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12734 + if (*flags & DLIMF_SHIFT) {
12735 + while (val > (1LL << 32) && (exp < 3)) {
12739 + *flags &= ~(DLIME_GIGA << shift);
12740 + *flags |= exp << shift;
12748 +#ifdef CONFIG_COMPAT
12750 +#include <asm/compat.h>
12752 +struct vcmd_ctx_dlimit_base_v0_x32 {
12753 + compat_uptr_t name_ptr;
12757 +struct vcmd_ctx_dlimit_v0_x32 {
12758 + compat_uptr_t name_ptr;
12759 + uint32_t space_used; /* used space in kbytes */
12760 + uint32_t space_total; /* maximum space in kbytes */
12761 + uint32_t inodes_used; /* used inodes */
12762 + uint32_t inodes_total; /* maximum inodes */
12763 + uint32_t reserved; /* reserved for root in % */
12767 +#endif /* CONFIG_COMPAT */
12769 +#include <linux/compiler.h>
12771 +extern int vc_add_dlimit(uint32_t, void __user *);
12772 +extern int vc_rem_dlimit(uint32_t, void __user *);
12774 +extern int vc_set_dlimit(uint32_t, void __user *);
12775 +extern int vc_get_dlimit(uint32_t, void __user *);
12777 +#ifdef CONFIG_COMPAT
12779 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12780 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12782 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12783 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12785 +#endif /* CONFIG_COMPAT */
12787 +#endif /* __KERNEL__ */
12788 +#endif /* _VX_DLIMIT_CMD_H */
12789 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/dlimit.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/dlimit.h
12790 --- linux-2.6.35/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
12791 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/dlimit.h 2010-08-02 17:05:06.000000000 +0200
12793 +#ifndef _VX_DLIMIT_H
12794 +#define _VX_DLIMIT_H
12796 +#include "switch.h"
12801 +/* keep in sync with CDLIM_INFINITY */
12803 +#define DLIM_INFINITY (~0ULL)
12805 +#include <linux/spinlock.h>
12806 +#include <linux/rcupdate.h>
12808 +struct super_block;
12811 + struct hlist_node dl_hlist; /* linked list of contexts */
12812 + struct rcu_head dl_rcu; /* the rcu head */
12813 + tag_t dl_tag; /* context tag */
12814 + atomic_t dl_usecnt; /* usage count */
12815 + atomic_t dl_refcnt; /* reference count */
12817 + struct super_block *dl_sb; /* associated superblock */
12819 + spinlock_t dl_lock; /* protect the values */
12821 + unsigned long long dl_space_used; /* used space in bytes */
12822 + unsigned long long dl_space_total; /* maximum space in bytes */
12823 + unsigned long dl_inodes_used; /* used inodes */
12824 + unsigned long dl_inodes_total; /* maximum inodes */
12826 + unsigned int dl_nrlmult; /* non root limit mult */
12831 +extern void rcu_free_dl_info(struct rcu_head *);
12832 +extern void unhash_dl_info(struct dl_info *);
12834 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12839 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12841 +typedef uint64_t dlsize_t;
12843 +#endif /* __KERNEL__ */
12844 +#else /* _VX_DLIMIT_H */
12845 +#warning duplicate inclusion
12846 +#endif /* _VX_DLIMIT_H */
12847 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/global.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/global.h
12848 --- linux-2.6.35/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12849 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/global.h 2010-08-02 17:05:06.000000000 +0200
12851 +#ifndef _VX_GLOBAL_H
12852 +#define _VX_GLOBAL_H
12855 +extern atomic_t vx_global_ctotal;
12856 +extern atomic_t vx_global_cactive;
12858 +extern atomic_t nx_global_ctotal;
12859 +extern atomic_t nx_global_cactive;
12861 +extern atomic_t vs_global_nsproxy;
12862 +extern atomic_t vs_global_fs;
12863 +extern atomic_t vs_global_mnt_ns;
12864 +extern atomic_t vs_global_uts_ns;
12865 +extern atomic_t vs_global_user_ns;
12866 +extern atomic_t vs_global_pid_ns;
12869 +#endif /* _VX_GLOBAL_H */
12870 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/history.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/history.h
12871 --- linux-2.6.35/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12872 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/history.h 2010-08-02 17:05:06.000000000 +0200
12874 +#ifndef _VX_HISTORY_H
12875 +#define _VX_HISTORY_H
12880 + VXH_THROW_OOPS = 1,
12884 + VXH_INIT_VX_INFO,
12887 + VXH_CLAIM_VX_INFO,
12888 + VXH_RELEASE_VX_INFO,
12889 + VXH_ALLOC_VX_INFO,
12890 + VXH_DEALLOC_VX_INFO,
12891 + VXH_HASH_VX_INFO,
12892 + VXH_UNHASH_VX_INFO,
12894 + VXH_LOOKUP_VX_INFO,
12895 + VXH_CREATE_VX_INFO,
12898 +struct _vxhe_vxi {
12899 + struct vx_info *ptr;
12905 +struct _vxhe_set_clr {
12909 +struct _vxhe_loc_lookup {
12913 +struct _vx_hist_entry {
12915 + unsigned short seq;
12916 + unsigned short type;
12917 + struct _vxhe_vxi vxi;
12919 + struct _vxhe_set_clr sc;
12920 + struct _vxhe_loc_lookup ll;
12924 +#ifdef CONFIG_VSERVER_HISTORY
12926 +extern unsigned volatile int vxh_active;
12928 +struct _vx_hist_entry *vxh_advance(void *loc);
12932 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12934 + entry->vxi.ptr = vxi;
12936 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12937 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12938 + entry->vxi.xid = vxi->vx_id;
12943 +#define __HERE__ current_text_addr()
12945 +#define __VXH_BODY(__type, __data, __here) \
12946 + struct _vx_hist_entry *entry; \
12948 + preempt_disable(); \
12949 + entry = vxh_advance(__here); \
12951 + entry->type = __type; \
12952 + preempt_enable();
12955 + /* pass vxi only */
12957 +#define __VXH_SMPL \
12958 + __vxh_copy_vxi(entry, vxi)
12961 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12963 + __VXH_BODY(__type, __VXH_SMPL, __here)
12966 + /* pass vxi and data (void *) */
12968 +#define __VXH_DATA \
12969 + __vxh_copy_vxi(entry, vxi); \
12970 + entry->sc.data = data
12973 +void __vxh_data(struct vx_info *vxi, void *data,
12974 + int __type, void *__here)
12976 + __VXH_BODY(__type, __VXH_DATA, __here)
12979 + /* pass vxi and arg (long) */
12981 +#define __VXH_LONG \
12982 + __vxh_copy_vxi(entry, vxi); \
12983 + entry->ll.arg = arg
12986 +void __vxh_long(struct vx_info *vxi, long arg,
12987 + int __type, void *__here)
12989 + __VXH_BODY(__type, __VXH_LONG, __here)
12994 +void __vxh_throw_oops(void *__here)
12996 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12997 + /* prevent further acquisition */
13002 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
13004 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
13005 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
13007 +#define __vxh_init_vx_info(v, d, h) \
13008 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
13009 +#define __vxh_set_vx_info(v, d, h) \
13010 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
13011 +#define __vxh_clr_vx_info(v, d, h) \
13012 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
13014 +#define __vxh_claim_vx_info(v, d, h) \
13015 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
13016 +#define __vxh_release_vx_info(v, d, h) \
13017 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
13019 +#define vxh_alloc_vx_info(v) \
13020 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
13021 +#define vxh_dealloc_vx_info(v) \
13022 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
13024 +#define vxh_hash_vx_info(v) \
13025 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
13026 +#define vxh_unhash_vx_info(v) \
13027 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
13029 +#define vxh_loc_vx_info(v, l) \
13030 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
13031 +#define vxh_lookup_vx_info(v, l) \
13032 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
13033 +#define vxh_create_vx_info(v, l) \
13034 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
13036 +extern void vxh_dump_history(void);
13039 +#else /* CONFIG_VSERVER_HISTORY */
13041 +#define __HERE__ 0
13043 +#define vxh_throw_oops() do { } while (0)
13045 +#define __vxh_get_vx_info(v, h) do { } while (0)
13046 +#define __vxh_put_vx_info(v, h) do { } while (0)
13048 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
13049 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
13050 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
13052 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
13053 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
13055 +#define vxh_alloc_vx_info(v) do { } while (0)
13056 +#define vxh_dealloc_vx_info(v) do { } while (0)
13058 +#define vxh_hash_vx_info(v) do { } while (0)
13059 +#define vxh_unhash_vx_info(v) do { } while (0)
13061 +#define vxh_loc_vx_info(v, l) do { } while (0)
13062 +#define vxh_lookup_vx_info(v, l) do { } while (0)
13063 +#define vxh_create_vx_info(v, l) do { } while (0)
13065 +#define vxh_dump_history() do { } while (0)
13068 +#endif /* CONFIG_VSERVER_HISTORY */
13070 +#endif /* _VX_HISTORY_H */
13071 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/inode_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/inode_cmd.h
13072 --- linux-2.6.35/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
13073 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/inode_cmd.h 2010-08-02 17:05:06.000000000 +0200
13075 +#ifndef _VX_INODE_CMD_H
13076 +#define _VX_INODE_CMD_H
13079 +/* inode vserver commands */
13081 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
13082 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
13084 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
13085 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
13087 +struct vcmd_ctx_iattr_v1 {
13088 + const char __user *name;
13094 +struct vcmd_ctx_fiattr_v0 {
13104 +#ifdef CONFIG_COMPAT
13106 +#include <asm/compat.h>
13108 +struct vcmd_ctx_iattr_v1_x32 {
13109 + compat_uptr_t name_ptr;
13115 +#endif /* CONFIG_COMPAT */
13117 +#include <linux/compiler.h>
13119 +extern int vc_get_iattr(void __user *);
13120 +extern int vc_set_iattr(void __user *);
13122 +extern int vc_fget_iattr(uint32_t, void __user *);
13123 +extern int vc_fset_iattr(uint32_t, void __user *);
13125 +#ifdef CONFIG_COMPAT
13127 +extern int vc_get_iattr_x32(void __user *);
13128 +extern int vc_set_iattr_x32(void __user *);
13130 +#endif /* CONFIG_COMPAT */
13132 +#endif /* __KERNEL__ */
13133 +#endif /* _VX_INODE_CMD_H */
13134 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/inode.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/inode.h
13135 --- linux-2.6.35/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
13136 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/inode.h 2010-08-02 17:05:06.000000000 +0200
13138 +#ifndef _VX_INODE_H
13139 +#define _VX_INODE_H
13142 +#define IATTR_TAG 0x01000000
13144 +#define IATTR_ADMIN 0x00000001
13145 +#define IATTR_WATCH 0x00000002
13146 +#define IATTR_HIDE 0x00000004
13147 +#define IATTR_FLAGS 0x00000007
13149 +#define IATTR_BARRIER 0x00010000
13150 +#define IATTR_IXUNLINK 0x00020000
13151 +#define IATTR_IMMUTABLE 0x00040000
13152 +#define IATTR_COW 0x00080000
13157 +#ifdef CONFIG_VSERVER_PROC_SECURE
13158 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
13159 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
13161 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
13162 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
13165 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
13167 +#endif /* __KERNEL__ */
13169 +/* inode ioctls */
13171 +#define FIOC_GETXFLG _IOR('x', 5, long)
13172 +#define FIOC_SETXFLG _IOW('x', 6, long)
13174 +#else /* _VX_INODE_H */
13175 +#warning duplicate inclusion
13176 +#endif /* _VX_INODE_H */
13177 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/Kbuild linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/Kbuild
13178 --- linux-2.6.35/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
13179 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/Kbuild 2010-08-02 17:05:06.000000000 +0200
13182 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
13183 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
13184 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
13185 + debug_cmd.h device_cmd.h
13187 +unifdef-y += switch.h network.h monitor.h inode.h device.h
13189 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/limit_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit_cmd.h
13190 --- linux-2.6.35/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
13191 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit_cmd.h 2010-08-02 17:05:06.000000000 +0200
13193 +#ifndef _VX_LIMIT_CMD_H
13194 +#define _VX_LIMIT_CMD_H
13197 +/* rlimit vserver commands */
13199 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
13200 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
13201 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
13202 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
13203 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
13205 +struct vcmd_ctx_rlimit_v0 {
13207 + uint64_t minimum;
13208 + uint64_t softlimit;
13209 + uint64_t maximum;
13212 +struct vcmd_ctx_rlimit_mask_v0 {
13213 + uint32_t minimum;
13214 + uint32_t softlimit;
13215 + uint32_t maximum;
13218 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
13220 +struct vcmd_rlimit_stat_v0 {
13224 + uint64_t minimum;
13225 + uint64_t maximum;
13228 +#define CRLIM_UNSET (0ULL)
13229 +#define CRLIM_INFINITY (~0ULL)
13230 +#define CRLIM_KEEP (~1ULL)
13234 +#ifdef CONFIG_IA32_EMULATION
13236 +struct vcmd_ctx_rlimit_v0_x32 {
13238 + uint64_t minimum;
13239 + uint64_t softlimit;
13240 + uint64_t maximum;
13241 +} __attribute__ ((packed));
13243 +#endif /* CONFIG_IA32_EMULATION */
13245 +#include <linux/compiler.h>
13247 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
13248 +extern int vc_get_rlimit(struct vx_info *, void __user *);
13249 +extern int vc_set_rlimit(struct vx_info *, void __user *);
13250 +extern int vc_reset_hits(struct vx_info *, void __user *);
13251 +extern int vc_reset_minmax(struct vx_info *, void __user *);
13253 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
13255 +#ifdef CONFIG_IA32_EMULATION
13257 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
13258 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
13260 +#endif /* CONFIG_IA32_EMULATION */
13262 +#endif /* __KERNEL__ */
13263 +#endif /* _VX_LIMIT_CMD_H */
13264 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/limit_def.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit_def.h
13265 --- linux-2.6.35/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
13266 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit_def.h 2010-08-02 17:05:06.000000000 +0200
13268 +#ifndef _VX_LIMIT_DEF_H
13269 +#define _VX_LIMIT_DEF_H
13271 +#include <asm/atomic.h>
13272 +#include <asm/resource.h>
13274 +#include "limit.h"
13277 +struct _vx_res_limit {
13278 + rlim_t soft; /* Context soft limit */
13279 + rlim_t hard; /* Context hard limit */
13281 + rlim_atomic_t rcur; /* Current value */
13282 + rlim_t rmin; /* Context minimum */
13283 + rlim_t rmax; /* Context maximum */
13285 + atomic_t lhit; /* Limit hits */
13288 +/* context sub struct */
13290 +struct _vx_limit {
13291 + struct _vx_res_limit res[NUM_LIMITS];
13294 +#ifdef CONFIG_VSERVER_DEBUG
13296 +static inline void __dump_vx_limit(struct _vx_limit *limit)
13300 + printk("\t_vx_limit:");
13301 + for (i = 0; i < NUM_LIMITS; i++) {
13302 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
13303 + i, (unsigned long)__rlim_get(limit, i),
13304 + (unsigned long)__rlim_rmin(limit, i),
13305 + (unsigned long)__rlim_rmax(limit, i),
13306 + (long)__rlim_soft(limit, i),
13307 + (long)__rlim_hard(limit, i),
13308 + atomic_read(&__rlim_lhit(limit, i)));
13314 +#endif /* _VX_LIMIT_DEF_H */
13315 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/limit.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit.h
13316 --- linux-2.6.35/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
13317 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit.h 2010-08-02 17:05:06.000000000 +0200
13319 +#ifndef _VX_LIMIT_H
13320 +#define _VX_LIMIT_H
13322 +#define VLIMIT_NSOCK 16
13323 +#define VLIMIT_OPENFD 17
13324 +#define VLIMIT_ANON 18
13325 +#define VLIMIT_SHMEM 19
13326 +#define VLIMIT_SEMARY 20
13327 +#define VLIMIT_NSEMS 21
13328 +#define VLIMIT_DENTRY 22
13329 +#define VLIMIT_MAPPED 23
13334 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
13336 +/* keep in sync with CRLIM_INFINITY */
13338 +#define VLIM_INFINITY (~0ULL)
13340 +#include <asm/atomic.h>
13341 +#include <asm/resource.h>
13343 +#ifndef RLIM_INFINITY
13344 +#warning RLIM_INFINITY is undefined
13347 +#define __rlim_val(l, r, v) ((l)->res[r].v)
13349 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
13350 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
13352 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
13353 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
13354 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
13356 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
13357 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
13359 +typedef atomic_long_t rlim_atomic_t;
13360 +typedef unsigned long rlim_t;
13362 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
13363 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
13364 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
13365 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
13366 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
13367 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
13370 +#if (RLIM_INFINITY == VLIM_INFINITY)
13371 +#define VX_VLIM(r) ((long long)(long)(r))
13372 +#define VX_RLIM(v) ((rlim_t)(v))
13374 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
13375 + ? VLIM_INFINITY : (long long)(r))
13376 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
13377 + ? RLIM_INFINITY : (rlim_t)(v))
13382 +void vx_vsi_meminfo(struct sysinfo *);
13383 +void vx_vsi_swapinfo(struct sysinfo *);
13384 +long vx_vsi_cached(struct sysinfo *);
13386 +#define NUM_LIMITS 24
13388 +#endif /* __KERNEL__ */
13389 +#endif /* _VX_LIMIT_H */
13390 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/limit_int.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit_int.h
13391 --- linux-2.6.35/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
13392 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit_int.h 2010-08-02 17:05:06.000000000 +0200
13394 +#ifndef _VX_LIMIT_INT_H
13395 +#define _VX_LIMIT_INT_H
13397 +#include "context.h"
13401 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
13402 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
13404 +extern const char *vlimit_name[NUM_LIMITS];
13406 +static inline void __vx_acc_cres(struct vx_info *vxi,
13407 + int res, int dir, void *_data, char *_file, int _line)
13409 + if (VXD_RCRES_COND(res))
13410 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
13411 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13412 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13413 + (dir > 0) ? "++" : "--", _data, _file, _line);
13418 + __rlim_inc(&vxi->limit, res);
13420 + __rlim_dec(&vxi->limit, res);
13423 +static inline void __vx_add_cres(struct vx_info *vxi,
13424 + int res, int amount, void *_data, char *_file, int _line)
13426 + if (VXD_RCRES_COND(res))
13427 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
13428 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13429 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13430 + amount, _data, _file, _line);
13435 + __rlim_add(&vxi->limit, res, amount);
13439 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
13441 + int cond = (value > __rlim_rmax(limit, res));
13444 + __rlim_rmax(limit, res) = value;
13449 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13451 + int cond = (value < __rlim_rmin(limit, res));
13454 + __rlim_rmin(limit, res) = value;
13459 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13461 + if (!__vx_cres_adjust_max(limit, res, value))
13462 + __vx_cres_adjust_min(limit, res, value);
13467 + +1 ... no limit hit
13468 + -1 ... over soft limit
13469 + 0 ... over hard limit */
13471 +static inline int __vx_cres_avail(struct vx_info *vxi,
13472 + int res, int num, char *_file, int _line)
13474 + struct _vx_limit *limit;
13477 + if (VXD_RLIMIT_COND(res))
13478 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13479 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13480 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13481 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13482 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13483 + num, _file, _line);
13487 + limit = &vxi->limit;
13488 + value = __rlim_get(limit, res);
13490 + if (!__vx_cres_adjust_max(limit, res, value))
13491 + __vx_cres_adjust_min(limit, res, value);
13496 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
13498 + if (value + num <= __rlim_soft(limit, res))
13501 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
13503 + if (value + num <= __rlim_hard(limit, res))
13506 + __rlim_hit(limit, res);
13511 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13514 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13516 + rlim_t value, sum = 0;
13519 + while ((res = *array++)) {
13520 + value = __rlim_get(limit, res);
13521 + __vx_cres_fixup(limit, res, value);
13528 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13530 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
13531 + int res = *array;
13533 + if (value == __rlim_get(limit, res))
13536 + __rlim_set(limit, res, value);
13537 + /* now adjust min/max */
13538 + if (!__vx_cres_adjust_max(limit, res, value))
13539 + __vx_cres_adjust_min(limit, res, value);
13544 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13545 + const int *array, int num, char *_file, int _line)
13547 + struct _vx_limit *limit;
13548 + rlim_t value = 0;
13556 + limit = &vxi->limit;
13558 + value = __vx_cres_array_sum(limit, array + 1);
13560 + __rlim_set(limit, res, value);
13561 + __vx_cres_fixup(limit, res, value);
13563 + return __vx_cres_avail(vxi, res, num, _file, _line);
13567 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13572 + /* complex resources first */
13573 + if ((id < 0) || (id == RLIMIT_RSS))
13574 + __vx_cres_array_fixup(limit, VLA_RSS);
13576 + for (res = 0; res < NUM_LIMITS; res++) {
13577 + if ((id > 0) && (res != id))
13580 + value = __rlim_get(limit, res);
13581 + __vx_cres_fixup(limit, res, value);
13583 + /* not supposed to happen, maybe warn? */
13584 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13585 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13590 +#endif /* __KERNEL__ */
13591 +#endif /* _VX_LIMIT_INT_H */
13592 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/monitor.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/monitor.h
13593 --- linux-2.6.35/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
13594 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/monitor.h 2010-08-02 17:05:06.000000000 +0200
13596 +#ifndef _VX_MONITOR_H
13597 +#define _VX_MONITOR_H
13599 +#include <linux/types.h>
13606 + VXM_UPDATE = 0x20,
13610 + VXM_RQINFO_1 = 0x24,
13613 + VXM_ACTIVATE = 0x40,
13620 + VXM_MIGRATE = 0x48,
13623 + /* all other bits are flags */
13624 + VXM_SCHED = 0x80,
13627 +struct _vxm_update_1 {
13628 + uint32_t tokens_max;
13629 + uint32_t fill_rate;
13630 + uint32_t interval;
13633 +struct _vxm_update_2 {
13634 + uint32_t tokens_min;
13635 + uint32_t fill_rate;
13636 + uint32_t interval;
13639 +struct _vxm_rqinfo_1 {
13640 + uint16_t running;
13644 + uint32_t idle_tokens;
13647 +struct _vxm_rqinfo_2 {
13648 + uint32_t norm_time;
13649 + uint32_t idle_time;
13650 + uint32_t idle_skip;
13653 +struct _vxm_sched {
13655 + uint32_t norm_time;
13656 + uint32_t idle_time;
13659 +struct _vxm_task {
13664 +struct _vxm_event {
13673 + struct _vxm_task tsk;
13677 +struct _vx_mon_entry {
13681 + struct _vxm_event ev;
13682 + struct _vxm_sched sd;
13683 + struct _vxm_update_1 u1;
13684 + struct _vxm_update_2 u2;
13685 + struct _vxm_rqinfo_1 q1;
13686 + struct _vxm_rqinfo_2 q2;
13691 +#endif /* _VX_MONITOR_H */
13692 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/network_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/network_cmd.h
13693 --- linux-2.6.35/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13694 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/network_cmd.h 2010-08-02 17:05:06.000000000 +0200
13696 +#ifndef _VX_NETWORK_CMD_H
13697 +#define _VX_NETWORK_CMD_H
13700 +/* vinfo commands */
13702 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13705 +extern int vc_task_nid(uint32_t);
13707 +#endif /* __KERNEL__ */
13709 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13711 +struct vcmd_nx_info_v0 {
13713 + /* more to come */
13717 +extern int vc_nx_info(struct nx_info *, void __user *);
13719 +#endif /* __KERNEL__ */
13721 +#include <linux/in.h>
13722 +#include <linux/in6.h>
13724 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13725 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13727 +struct vcmd_net_create {
13728 + uint64_t flagword;
13731 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13733 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13734 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13736 +struct vcmd_net_addr_v0 {
13739 + struct in_addr ip[4];
13740 + struct in_addr mask[4];
13743 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
13744 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
13746 +struct vcmd_net_addr_ipv4_v1 {
13749 + struct in_addr ip;
13750 + struct in_addr mask;
13753 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13754 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13756 +struct vcmd_net_addr_ipv6_v1 {
13760 + struct in6_addr ip;
13761 + struct in6_addr mask;
13764 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13765 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13767 +struct vcmd_match_ipv4_v0 {
13772 + struct in_addr ip;
13773 + struct in_addr ip2;
13774 + struct in_addr mask;
13777 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13778 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13780 +struct vcmd_match_ipv6_v0 {
13785 + struct in6_addr ip;
13786 + struct in6_addr ip2;
13787 + struct in6_addr mask;
13792 +extern int vc_net_create(uint32_t, void __user *);
13793 +extern int vc_net_migrate(struct nx_info *, void __user *);
13795 +extern int vc_net_add(struct nx_info *, void __user *);
13796 +extern int vc_net_remove(struct nx_info *, void __user *);
13798 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13799 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
13801 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13802 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13804 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13805 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13807 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13808 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13810 +#endif /* __KERNEL__ */
13813 +/* flag commands */
13815 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13816 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13818 +struct vcmd_net_flags_v0 {
13819 + uint64_t flagword;
13824 +extern int vc_get_nflags(struct nx_info *, void __user *);
13825 +extern int vc_set_nflags(struct nx_info *, void __user *);
13827 +#endif /* __KERNEL__ */
13830 +/* network caps commands */
13832 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13833 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13835 +struct vcmd_net_caps_v0 {
13841 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13842 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13844 +#endif /* __KERNEL__ */
13845 +#endif /* _VX_CONTEXT_CMD_H */
13846 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/network.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/network.h
13847 --- linux-2.6.35/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
13848 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/network.h 2010-08-02 17:05:06.000000000 +0200
13850 +#ifndef _VX_NETWORK_H
13851 +#define _VX_NETWORK_H
13853 +#include <linux/types.h>
13856 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13859 +/* network flags */
13861 +#define NXF_INFO_PRIVATE 0x00000008
13863 +#define NXF_SINGLE_IP 0x00000100
13864 +#define NXF_LBACK_REMAP 0x00000200
13865 +#define NXF_LBACK_ALLOW 0x00000400
13867 +#define NXF_HIDE_NETIF 0x02000000
13868 +#define NXF_HIDE_LBACK 0x04000000
13870 +#define NXF_STATE_SETUP (1ULL << 32)
13871 +#define NXF_STATE_ADMIN (1ULL << 34)
13873 +#define NXF_SC_HELPER (1ULL << 36)
13874 +#define NXF_PERSISTENT (1ULL << 38)
13876 +#define NXF_ONE_TIME (0x0005ULL << 32)
13879 +#define NXF_INIT_SET (__nxf_init_set())
13881 +static inline uint64_t __nxf_init_set(void) {
13882 + return NXF_STATE_ADMIN
13883 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13884 + | NXF_LBACK_REMAP
13887 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13890 + | NXF_HIDE_NETIF;
13894 +/* network caps */
13896 +#define NXC_TUN_CREATE 0x00000001
13898 +#define NXC_RAW_ICMP 0x00000100
13901 +/* address types */
13903 +#define NXA_TYPE_IPV4 0x0001
13904 +#define NXA_TYPE_IPV6 0x0002
13906 +#define NXA_TYPE_NONE 0x0000
13907 +#define NXA_TYPE_ANY 0x00FF
13909 +#define NXA_TYPE_ADDR 0x0010
13910 +#define NXA_TYPE_MASK 0x0020
13911 +#define NXA_TYPE_RANGE 0x0040
13913 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13915 +#define NXA_MOD_BCAST 0x0100
13916 +#define NXA_MOD_LBACK 0x0200
13918 +#define NXA_LOOPBACK 0x1000
13920 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13921 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13925 +#include <linux/list.h>
13926 +#include <linux/spinlock.h>
13927 +#include <linux/rcupdate.h>
13928 +#include <linux/in.h>
13929 +#include <linux/in6.h>
13930 +#include <asm/atomic.h>
13932 +struct nx_addr_v4 {
13933 + struct nx_addr_v4 *next;
13934 + struct in_addr ip[2];
13935 + struct in_addr mask;
13940 +struct nx_addr_v6 {
13941 + struct nx_addr_v6 *next;
13942 + struct in6_addr ip;
13943 + struct in6_addr mask;
13950 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13951 + nid_t nx_id; /* vnet id */
13952 + atomic_t nx_usecnt; /* usage count */
13953 + atomic_t nx_tasks; /* tasks count */
13954 + int nx_state; /* context state */
13956 + uint64_t nx_flags; /* network flag word */
13957 + uint64_t nx_ncaps; /* network capabilities */
13959 + struct in_addr v4_lback; /* Loopback address */
13960 + struct in_addr v4_bcast; /* Broadcast address */
13961 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13962 +#ifdef CONFIG_IPV6
13963 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13965 + char nx_name[65]; /* network context name */
13969 +/* status flags */
13971 +#define NXS_HASHED 0x0001
13972 +#define NXS_SHUTDOWN 0x0100
13973 +#define NXS_RELEASED 0x8000
13975 +extern struct nx_info *lookup_nx_info(int);
13977 +extern int get_nid_list(int, unsigned int *, int);
13978 +extern int nid_is_hashed(nid_t);
13980 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13982 +extern long vs_net_change(struct nx_info *, unsigned int);
13987 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13988 +#ifdef CONFIG_IPV6
13989 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13991 +#define NX_IPV6(n) (0)
13994 +#endif /* __KERNEL__ */
13995 +#endif /* _VX_NETWORK_H */
13996 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/percpu.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/percpu.h
13997 --- linux-2.6.35/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13998 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/percpu.h 2010-08-02 17:05:06.000000000 +0200
14000 +#ifndef _VX_PERCPU_H
14001 +#define _VX_PERCPU_H
14003 +#include "cvirt_def.h"
14004 +#include "sched_def.h"
14006 +struct _vx_percpu {
14007 + struct _vx_cvirt_pc cvirt;
14008 + struct _vx_sched_pc sched;
14011 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
14013 +#endif /* _VX_PERCPU_H */
14014 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/pid.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/pid.h
14015 --- linux-2.6.35/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
14016 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/pid.h 2010-08-02 17:05:06.000000000 +0200
14018 +#ifndef _VSERVER_PID_H
14019 +#define _VSERVER_PID_H
14021 +/* pid faking stuff */
14023 +#define vx_info_map_pid(v, p) \
14024 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
14025 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
14026 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
14027 +#define vx_map_tgid(p) vx_map_pid(p)
14029 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
14030 + const char *func, const char *file, int line)
14032 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14033 + vxfprintk(VXD_CBIT(cvirt, 2),
14034 + "vx_map_tgid: %p/%llx: %d -> %d",
14035 + vxi, (long long)vxi->vx_flags, pid,
14036 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
14037 + func, file, line);
14040 + if (pid == vxi->vx_initpid)
14046 +#define vx_info_rmap_pid(v, p) \
14047 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
14048 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
14049 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
14051 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
14052 + const char *func, const char *file, int line)
14054 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14055 + vxfprintk(VXD_CBIT(cvirt, 2),
14056 + "vx_rmap_tgid: %p/%llx: %d -> %d",
14057 + vxi, (long long)vxi->vx_flags, pid,
14058 + (pid == 1) ? vxi->vx_initpid : pid,
14059 + func, file, line);
14060 + if ((pid == 1) && vxi->vx_initpid)
14061 + return vxi->vx_initpid;
14062 + if (pid == vxi->vx_initpid)
14069 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/sched_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/sched_cmd.h
14070 --- linux-2.6.35/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
14071 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/sched_cmd.h 2010-08-02 17:05:06.000000000 +0200
14073 +#ifndef _VX_SCHED_CMD_H
14074 +#define _VX_SCHED_CMD_H
14077 +/* sched vserver commands */
14079 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
14080 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
14081 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
14083 +struct vcmd_set_sched_v2 {
14084 + int32_t fill_rate;
14085 + int32_t interval;
14087 + int32_t tokens_min;
14088 + int32_t tokens_max;
14089 + uint64_t cpu_mask;
14092 +struct vcmd_set_sched_v3 {
14093 + uint32_t set_mask;
14094 + int32_t fill_rate;
14095 + int32_t interval;
14097 + int32_t tokens_min;
14098 + int32_t tokens_max;
14099 + int32_t priority_bias;
14102 +struct vcmd_set_sched_v4 {
14103 + uint32_t set_mask;
14104 + int32_t fill_rate;
14105 + int32_t interval;
14107 + int32_t tokens_min;
14108 + int32_t tokens_max;
14109 + int32_t prio_bias;
14111 + int32_t bucket_id;
14114 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
14115 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
14117 +struct vcmd_sched_v5 {
14120 + int32_t bucket_id;
14121 + int32_t fill_rate[2];
14122 + int32_t interval[2];
14124 + int32_t tokens_min;
14125 + int32_t tokens_max;
14126 + int32_t prio_bias;
14129 +#define VXSM_FILL_RATE 0x0001
14130 +#define VXSM_INTERVAL 0x0002
14131 +#define VXSM_FILL_RATE2 0x0004
14132 +#define VXSM_INTERVAL2 0x0008
14133 +#define VXSM_TOKENS 0x0010
14134 +#define VXSM_TOKENS_MIN 0x0020
14135 +#define VXSM_TOKENS_MAX 0x0040
14136 +#define VXSM_PRIO_BIAS 0x0100
14138 +#define VXSM_IDLE_TIME 0x0200
14139 +#define VXSM_FORCE 0x0400
14141 +#define VXSM_V3_MASK 0x0173
14142 +#define VXSM_SET_MASK 0x01FF
14144 +#define VXSM_CPU_ID 0x1000
14145 +#define VXSM_BUCKET_ID 0x2000
14147 +#define VXSM_MSEC 0x4000
14149 +#define SCHED_KEEP (-2) /* only for v2 */
14153 +#include <linux/compiler.h>
14155 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
14156 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
14157 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
14158 +extern int vc_set_sched(struct vx_info *, void __user *);
14159 +extern int vc_get_sched(struct vx_info *, void __user *);
14161 +#endif /* __KERNEL__ */
14163 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
14165 +struct vcmd_sched_info {
14167 + int32_t bucket_id;
14168 + uint64_t user_msec;
14169 + uint64_t sys_msec;
14170 + uint64_t hold_msec;
14171 + uint32_t token_usec;
14172 + int32_t vavavoom;
14177 +extern int vc_sched_info(struct vx_info *, void __user *);
14179 +#endif /* __KERNEL__ */
14180 +#endif /* _VX_SCHED_CMD_H */
14181 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/sched_def.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/sched_def.h
14182 --- linux-2.6.35/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
14183 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/sched_def.h 2010-08-02 17:05:06.000000000 +0200
14185 +#ifndef _VX_SCHED_DEF_H
14186 +#define _VX_SCHED_DEF_H
14188 +#include <linux/spinlock.h>
14189 +#include <linux/jiffies.h>
14190 +#include <linux/cpumask.h>
14191 +#include <asm/atomic.h>
14192 +#include <asm/param.h>
14195 +/* context sub struct */
14197 +struct _vx_sched {
14198 + spinlock_t tokens_lock; /* lock for token bucket */
14200 + int tokens; /* number of CPU tokens */
14201 + int fill_rate[2]; /* Fill rate: add X tokens... */
14202 + int interval[2]; /* Divisor: per Y jiffies */
14203 + int tokens_min; /* Limit: minimum for unhold */
14204 + int tokens_max; /* Limit: no more than N tokens */
14206 + int prio_bias; /* bias offset for priority */
14208 + unsigned update_mask; /* which features should be updated */
14209 + cpumask_t update; /* CPUs which should update */
14212 +struct _vx_sched_pc {
14213 + int tokens; /* number of CPU tokens */
14214 + int flags; /* bucket flags */
14216 + int fill_rate[2]; /* Fill rate: add X tokens... */
14217 + int interval[2]; /* Divisor: per Y jiffies */
14218 + int tokens_min; /* Limit: minimum for unhold */
14219 + int tokens_max; /* Limit: no more than N tokens */
14221 + int prio_bias; /* bias offset for priority */
14222 + int vavavoom; /* last calculated vavavoom */
14224 + unsigned long norm_time; /* last time accounted */
14225 + unsigned long idle_time; /* non linear time for fair sched */
14226 + unsigned long token_time; /* token time for accounting */
14227 + unsigned long onhold; /* jiffies when put on hold */
14229 + uint64_t user_ticks; /* token tick events */
14230 + uint64_t sys_ticks; /* token tick events */
14231 + uint64_t hold_ticks; /* token ticks paused */
14235 +#define VXSF_ONHOLD 0x0001
14236 +#define VXSF_IDLE_TIME 0x0100
14238 +#ifdef CONFIG_VSERVER_DEBUG
14240 +static inline void __dump_vx_sched(struct _vx_sched *sched)
14242 + printk("\t_vx_sched:\n");
14243 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
14244 + sched->fill_rate[0], sched->interval[0],
14245 + sched->fill_rate[1], sched->interval[1],
14246 + sched->tokens_min, sched->tokens_max);
14247 + printk("\t priority = %4d\n", sched->prio_bias);
14252 +#endif /* _VX_SCHED_DEF_H */
14253 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/sched.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/sched.h
14254 --- linux-2.6.35/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
14255 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/sched.h 2010-08-02 17:05:06.000000000 +0200
14257 +#ifndef _VX_SCHED_H
14258 +#define _VX_SCHED_H
14265 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14270 +void vx_update_load(struct vx_info *);
14273 +int vx_tokens_recalc(struct _vx_sched_pc *,
14274 + unsigned long *, unsigned long *, int [2]);
14276 +void vx_update_sched_param(struct _vx_sched *sched,
14277 + struct _vx_sched_pc *sched_pc);
14279 +#endif /* __KERNEL__ */
14280 +#else /* _VX_SCHED_H */
14281 +#warning duplicate inclusion
14282 +#endif /* _VX_SCHED_H */
14283 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/signal_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/signal_cmd.h
14284 --- linux-2.6.35/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
14285 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/signal_cmd.h 2010-08-02 17:05:06.000000000 +0200
14287 +#ifndef _VX_SIGNAL_CMD_H
14288 +#define _VX_SIGNAL_CMD_H
14291 +/* signalling vserver commands */
14293 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
14294 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
14296 +struct vcmd_ctx_kill_v0 {
14301 +struct vcmd_wait_exit_v0 {
14302 + int32_t reboot_cmd;
14303 + int32_t exit_code;
14308 +extern int vc_ctx_kill(struct vx_info *, void __user *);
14309 +extern int vc_wait_exit(struct vx_info *, void __user *);
14311 +#endif /* __KERNEL__ */
14313 +/* process alteration commands */
14315 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
14316 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
14318 +struct vcmd_pflags_v0 {
14319 + uint32_t flagword;
14325 +extern int vc_get_pflags(uint32_t pid, void __user *);
14326 +extern int vc_set_pflags(uint32_t pid, void __user *);
14328 +#endif /* __KERNEL__ */
14329 +#endif /* _VX_SIGNAL_CMD_H */
14330 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/signal.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/signal.h
14331 --- linux-2.6.35/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
14332 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/signal.h 2010-08-02 17:05:06.000000000 +0200
14334 +#ifndef _VX_SIGNAL_H
14335 +#define _VX_SIGNAL_H
14342 +int vx_info_kill(struct vx_info *, int, int);
14344 +#endif /* __KERNEL__ */
14345 +#else /* _VX_SIGNAL_H */
14346 +#warning duplicate inclusion
14347 +#endif /* _VX_SIGNAL_H */
14348 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/space_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/space_cmd.h
14349 --- linux-2.6.35/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
14350 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/space_cmd.h 2010-08-02 17:05:06.000000000 +0200
14352 +#ifndef _VX_SPACE_CMD_H
14353 +#define _VX_SPACE_CMD_H
14356 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
14357 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
14358 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
14360 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
14361 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
14362 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
14364 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
14366 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
14367 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
14370 +struct vcmd_space_mask_v1 {
14374 +struct vcmd_space_mask_v2 {
14382 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
14383 +extern int vc_set_space_v1(struct vx_info *, void __user *);
14384 +extern int vc_enter_space(struct vx_info *, void __user *);
14385 +extern int vc_set_space(struct vx_info *, void __user *);
14386 +extern int vc_get_space_mask(void __user *, int);
14388 +#endif /* __KERNEL__ */
14389 +#endif /* _VX_SPACE_CMD_H */
14390 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/space.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/space.h
14391 --- linux-2.6.35/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
14392 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/space.h 2010-08-02 17:05:06.000000000 +0200
14394 +#ifndef _VX_SPACE_H
14395 +#define _VX_SPACE_H
14397 +#include <linux/types.h>
14401 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
14403 +#else /* _VX_SPACE_H */
14404 +#warning duplicate inclusion
14405 +#endif /* _VX_SPACE_H */
14406 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/switch.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/switch.h
14407 --- linux-2.6.35/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
14408 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/switch.h 2010-08-02 17:05:06.000000000 +0200
14410 +#ifndef _VX_SWITCH_H
14411 +#define _VX_SWITCH_H
14413 +#include <linux/types.h>
14416 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
14417 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
14418 +#define VC_VERSION(c) ((c) & 0xFFF)
14420 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
14421 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
14425 + Syscall Matrix V2.8
14427 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
14428 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
14429 + |INFO |SETUP | |MOVE | | | | | |
14430 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14431 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
14432 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
14433 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14434 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
14435 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
14436 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14437 + MEMORY | | | | |MEMCTRL| | |SWAP | |
14438 + | 16| 17| 18| 19| 20| 21| | 22| 23|
14439 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14440 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
14441 + | 24| 25| 26| 27| 28| 29| | 30| 31|
14442 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14443 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
14444 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
14445 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14446 + OTHER |VSTAT | | | | | | |VINFO | |
14447 + | 40| 41| 42| 43| 44| 45| | 46| 47|
14448 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
14449 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
14450 + | 48| 49| 50| 51| 52| 53| | 54| 55|
14451 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14452 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
14453 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
14454 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14458 +#define VC_CAT_VERSION 0
14460 +#define VC_CAT_VSETUP 1
14461 +#define VC_CAT_VHOST 2
14463 +#define VC_CAT_DEVICE 6
14465 +#define VC_CAT_VPROC 9
14466 +#define VC_CAT_PROCALT 10
14467 +#define VC_CAT_PROCMIG 11
14468 +#define VC_CAT_PROCTRL 12
14470 +#define VC_CAT_SCHED 14
14471 +#define VC_CAT_MEMCTRL 20
14473 +#define VC_CAT_VNET 25
14474 +#define VC_CAT_NETALT 26
14475 +#define VC_CAT_NETMIG 27
14476 +#define VC_CAT_NETCTRL 28
14478 +#define VC_CAT_TAGMIG 35
14479 +#define VC_CAT_DLIMIT 36
14480 +#define VC_CAT_INODE 38
14482 +#define VC_CAT_VSTAT 40
14483 +#define VC_CAT_VINFO 46
14484 +#define VC_CAT_EVENT 48
14486 +#define VC_CAT_FLAGS 52
14487 +#define VC_CAT_VSPACE 54
14488 +#define VC_CAT_DEBUG 56
14489 +#define VC_CAT_RLIMIT 60
14491 +#define VC_CAT_SYSTEST 61
14492 +#define VC_CAT_COMPAT 63
14494 +/* query version */
14496 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
14497 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
14502 +#include <linux/errno.h>
14504 +#endif /* __KERNEL__ */
14506 +#endif /* _VX_SWITCH_H */
14508 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/tag_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/tag_cmd.h
14509 --- linux-2.6.35/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
14510 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/tag_cmd.h 2010-08-02 17:05:06.000000000 +0200
14512 +#ifndef _VX_TAG_CMD_H
14513 +#define _VX_TAG_CMD_H
14516 +/* vinfo commands */
14518 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
14521 +extern int vc_task_tag(uint32_t);
14523 +#endif /* __KERNEL__ */
14525 +/* context commands */
14527 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
14530 +extern int vc_tag_migrate(uint32_t);
14532 +#endif /* __KERNEL__ */
14533 +#endif /* _VX_TAG_CMD_H */
14534 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/tag.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/tag.h
14535 --- linux-2.6.35/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
14536 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/tag.h 2010-08-02 17:05:06.000000000 +0200
14541 +#include <linux/types.h>
14544 +#define DX_TAG(in) (IS_TAGGED(in))
14547 +#ifdef CONFIG_TAG_NFSD
14548 +#define DX_TAG_NFSD 1
14550 +#define DX_TAG_NFSD 0
14554 +#ifdef CONFIG_TAGGING_NONE
14556 +#define MAX_UID 0xFFFFFFFF
14557 +#define MAX_GID 0xFFFFFFFF
14559 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
14561 +#define TAGINO_UID(cond, uid, tag) (uid)
14562 +#define TAGINO_GID(cond, gid, tag) (gid)
14567 +#ifdef CONFIG_TAGGING_GID16
14569 +#define MAX_UID 0xFFFFFFFF
14570 +#define MAX_GID 0x0000FFFF
14572 +#define INOTAG_TAG(cond, uid, gid, tag) \
14573 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
14575 +#define TAGINO_UID(cond, uid, tag) (uid)
14576 +#define TAGINO_GID(cond, gid, tag) \
14577 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14582 +#ifdef CONFIG_TAGGING_ID24
14584 +#define MAX_UID 0x00FFFFFF
14585 +#define MAX_GID 0x00FFFFFF
14587 +#define INOTAG_TAG(cond, uid, gid, tag) \
14588 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14590 +#define TAGINO_UID(cond, uid, tag) \
14591 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14592 +#define TAGINO_GID(cond, gid, tag) \
14593 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14598 +#ifdef CONFIG_TAGGING_UID16
14600 +#define MAX_UID 0x0000FFFF
14601 +#define MAX_GID 0xFFFFFFFF
14603 +#define INOTAG_TAG(cond, uid, gid, tag) \
14604 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14606 +#define TAGINO_UID(cond, uid, tag) \
14607 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14608 +#define TAGINO_GID(cond, gid, tag) (gid)
14613 +#ifdef CONFIG_TAGGING_INTERN
14615 +#define MAX_UID 0xFFFFFFFF
14616 +#define MAX_GID 0xFFFFFFFF
14618 +#define INOTAG_TAG(cond, uid, gid, tag) \
14619 + ((cond) ? (tag) : 0)
14621 +#define TAGINO_UID(cond, uid, tag) (uid)
14622 +#define TAGINO_GID(cond, gid, tag) (gid)
14627 +#ifndef CONFIG_TAGGING_NONE
14628 +#define dx_current_fstag(sb) \
14629 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14631 +#define dx_current_fstag(sb) (0)
14634 +#ifndef CONFIG_TAGGING_INTERN
14635 +#define TAGINO_TAG(cond, tag) (0)
14637 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
14640 +#define INOTAG_UID(cond, uid, gid) \
14641 + ((cond) ? ((uid) & MAX_UID) : (uid))
14642 +#define INOTAG_GID(cond, uid, gid) \
14643 + ((cond) ? ((gid) & MAX_GID) : (gid))
14646 +static inline uid_t dx_map_uid(uid_t uid)
14648 + if ((uid > MAX_UID) && (uid != -1))
14650 + return (uid & MAX_UID);
14653 +static inline gid_t dx_map_gid(gid_t gid)
14655 + if ((gid > MAX_GID) && (gid != -1))
14657 + return (gid & MAX_GID);
14665 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14667 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14668 + unsigned long *flags);
14670 +#ifdef CONFIG_PROPAGATE
14672 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14674 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14677 +#define dx_propagate_tag(n, i) do { } while (0)
14680 +#endif /* _DX_TAG_H */
14681 diff -NurpP --minimal linux-2.6.35/include/linux/vs_inet6.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_inet6.h
14682 --- linux-2.6.35/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
14683 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_inet6.h 2010-08-02 17:05:06.000000000 +0200
14685 +#ifndef _VS_INET6_H
14686 +#define _VS_INET6_H
14688 +#include "vserver/base.h"
14689 +#include "vserver/network.h"
14690 +#include "vserver/debug.h"
14692 +#include <net/ipv6.h>
14694 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
14695 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
14698 +#ifdef CONFIG_IPV6
14701 +int v6_addr_match(struct nx_addr_v6 *nxa,
14702 + const struct in6_addr *addr, uint16_t mask)
14706 + switch (nxa->type & mask) {
14707 + case NXA_TYPE_MASK:
14708 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
14710 + case NXA_TYPE_ADDR:
14711 + ret = ipv6_addr_equal(&nxa->ip, addr);
14713 + case NXA_TYPE_ANY:
14717 + vxdprintk(VXD_CBIT(net, 0),
14718 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
14719 + nxa, NXAV6(nxa), addr, mask, ret);
14724 +int v6_addr_in_nx_info(struct nx_info *nxi,
14725 + const struct in6_addr *addr, uint16_t mask)
14727 + struct nx_addr_v6 *nxa;
14732 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
14733 + if (v6_addr_match(nxa, addr, mask))
14737 + vxdprintk(VXD_CBIT(net, 0),
14738 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
14739 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
14744 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
14746 + /* FIXME: needs full range checks */
14747 + return v6_addr_match(nxa, &addr->ip, mask);
14751 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
14753 + struct nx_addr_v6 *ptr;
14755 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
14756 + if (v6_nx_addr_match(ptr, nxa, mask))
14763 + * Check if a given address matches for a socket
14765 + * nxi: the socket's nx_info if any
14766 + * addr: to be verified address
14769 +int v6_sock_addr_match (
14770 + struct nx_info *nxi,
14771 + struct inet_sock *inet,
14772 + struct in6_addr *addr)
14774 + struct sock *sk = &inet->sk;
14775 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
14777 + if (!ipv6_addr_any(addr) &&
14778 + ipv6_addr_equal(saddr, addr))
14780 + if (ipv6_addr_any(saddr))
14781 + return v6_addr_in_nx_info(nxi, addr, -1);
14786 + * check if address is covered by socket
14788 + * sk: the socket to check against
14789 + * addr: the address in question (must be != 0)
14793 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
14795 + struct nx_info *nxi = sk->sk_nx_info;
14796 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
14798 + vxdprintk(VXD_CBIT(net, 5),
14799 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
14800 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
14801 + (sk->sk_socket?sk->sk_socket->flags:0));
14803 + if (!ipv6_addr_any(saddr)) { /* direct address match */
14804 + return v6_addr_match(nxa, saddr, -1);
14805 + } else if (nxi) { /* match against nx_info */
14806 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
14807 + } else { /* unrestricted any socket */
14813 +/* inet related checks and helpers */
14817 +struct net_device;
14821 +#include <linux/netdevice.h>
14822 +#include <linux/inetdevice.h>
14823 +#include <net/inet_timewait_sock.h>
14826 +int dev_in_nx_info(struct net_device *, struct nx_info *);
14827 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
14828 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
14833 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
14839 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
14843 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
14845 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
14846 + nxi, nxi ? nxi->nx_id : 0, ifa,
14847 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
14849 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
14851 + if (v6_ifa_in_nx_info(ifa, nxi))
14857 +struct nx_v6_sock_addr {
14858 + struct in6_addr saddr; /* Address used for validation */
14859 + struct in6_addr baddr; /* Address used for socket bind */
14863 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
14864 + struct nx_v6_sock_addr *nsa)
14866 + // struct sock *sk = &inet->sk;
14867 + // struct nx_info *nxi = sk->sk_nx_info;
14868 + struct in6_addr saddr = addr->sin6_addr;
14869 + struct in6_addr baddr = saddr;
14871 + nsa->saddr = saddr;
14872 + nsa->baddr = baddr;
14877 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
14879 + // struct sock *sk = &inet->sk;
14880 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
14882 + // *saddr = nsa->baddr;
14883 + // inet->inet_saddr = nsa->baddr;
14887 +int nx_info_has_v6(struct nx_info *nxi)
14891 + if (NX_IPV6(nxi))
14896 +#else /* CONFIG_IPV6 */
14899 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
14906 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
14912 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
14918 +int nx_info_has_v6(struct nx_info *nxi)
14923 +#endif /* CONFIG_IPV6 */
14925 +#define current_nx_info_has_v6() \
14926 + nx_info_has_v6(current_nx_info())
14929 +#warning duplicate inclusion
14931 diff -NurpP --minimal linux-2.6.35/include/linux/vs_inet.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_inet.h
14932 --- linux-2.6.35/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
14933 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_inet.h 2010-08-02 17:05:06.000000000 +0200
14935 +#ifndef _VS_INET_H
14936 +#define _VS_INET_H
14938 +#include "vserver/base.h"
14939 +#include "vserver/network.h"
14940 +#include "vserver/debug.h"
14942 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
14944 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
14945 + NIPQUAD((a)->mask), (a)->type
14946 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
14950 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
14952 + __be32 ip = nxa->ip[0].s_addr;
14953 + __be32 mask = nxa->mask.s_addr;
14954 + __be32 bcast = ip | ~mask;
14957 + switch (nxa->type & tmask) {
14958 + case NXA_TYPE_MASK:
14959 + ret = (ip == (addr & mask));
14961 + case NXA_TYPE_ADDR:
14965 + /* fall through to broadcast */
14966 + case NXA_MOD_BCAST:
14967 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
14969 + case NXA_TYPE_RANGE:
14970 + ret = ((nxa->ip[0].s_addr <= addr) &&
14971 + (nxa->ip[1].s_addr > addr));
14973 + case NXA_TYPE_ANY:
14978 + vxdprintk(VXD_CBIT(net, 0),
14979 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
14980 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
14985 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
14987 + struct nx_addr_v4 *nxa;
14994 + /* allow 127.0.0.1 when remapping lback */
14995 + if ((tmask & NXA_LOOPBACK) &&
14996 + (addr == IPI_LOOPBACK) &&
14997 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15000 + /* check for lback address */
15001 + if ((tmask & NXA_MOD_LBACK) &&
15002 + (nxi->v4_lback.s_addr == addr))
15005 + /* check for broadcast address */
15006 + if ((tmask & NXA_MOD_BCAST) &&
15007 + (nxi->v4_bcast.s_addr == addr))
15010 + /* check for v4 addresses */
15011 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
15012 + if (v4_addr_match(nxa, addr, tmask))
15016 + vxdprintk(VXD_CBIT(net, 0),
15017 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
15018 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
15023 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
15025 + /* FIXME: needs full range checks */
15026 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
15030 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
15032 + struct nx_addr_v4 *ptr;
15034 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
15035 + if (v4_nx_addr_match(ptr, nxa, mask))
15040 +#include <net/inet_sock.h>
15043 + * Check if a given address matches for a socket
15045 + * nxi: the socket's nx_info if any
15046 + * addr: to be verified address
15049 +int v4_sock_addr_match (
15050 + struct nx_info *nxi,
15051 + struct inet_sock *inet,
15054 + __be32 saddr = inet->inet_rcv_saddr;
15055 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
15057 + if (addr && (saddr == addr || bcast == addr))
15060 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
15065 +/* inet related checks and helpers */
15069 +struct net_device;
15072 +#ifdef CONFIG_INET
15074 +#include <linux/netdevice.h>
15075 +#include <linux/inetdevice.h>
15076 +#include <net/inet_sock.h>
15077 +#include <net/inet_timewait_sock.h>
15080 +int dev_in_nx_info(struct net_device *, struct nx_info *);
15081 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
15082 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
15086 + * check if address is covered by socket
15088 + * sk: the socket to check against
15089 + * addr: the address in question (must be != 0)
15093 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
15095 + struct nx_info *nxi = sk->sk_nx_info;
15096 + __be32 saddr = inet_rcv_saddr(sk);
15098 + vxdprintk(VXD_CBIT(net, 5),
15099 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
15100 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
15101 + (sk->sk_socket?sk->sk_socket->flags:0));
15103 + if (saddr) { /* direct address match */
15104 + return v4_addr_match(nxa, saddr, -1);
15105 + } else if (nxi) { /* match against nx_info */
15106 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
15107 + } else { /* unrestricted any socket */
15115 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
15117 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
15118 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
15119 + nxi ? dev_in_nx_info(dev, nxi) : 0);
15121 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15123 + if (dev_in_nx_info(dev, nxi))
15130 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
15136 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
15140 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
15142 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
15143 + nxi, nxi ? nxi->nx_id : 0, ifa,
15144 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
15146 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15148 + if (v4_ifa_in_nx_info(ifa, nxi))
15154 +struct nx_v4_sock_addr {
15155 + __be32 saddr; /* Address used for validation */
15156 + __be32 baddr; /* Address used for socket bind */
15160 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
15161 + struct nx_v4_sock_addr *nsa)
15163 + struct sock *sk = &inet->sk;
15164 + struct nx_info *nxi = sk->sk_nx_info;
15165 + __be32 saddr = addr->sin_addr.s_addr;
15166 + __be32 baddr = saddr;
15168 + vxdprintk(VXD_CBIT(net, 3),
15169 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
15170 + sk, sk->sk_nx_info, sk->sk_socket,
15171 + (sk->sk_socket ? sk->sk_socket->flags : 0),
15175 + if (saddr == INADDR_ANY) {
15176 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
15177 + baddr = nxi->v4.ip[0].s_addr;
15178 + } else if (saddr == IPI_LOOPBACK) {
15179 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15180 + baddr = nxi->v4_lback.s_addr;
15181 + } else { /* normal address bind */
15182 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
15183 + return -EADDRNOTAVAIL;
15187 + vxdprintk(VXD_CBIT(net, 3),
15188 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
15189 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
15191 + nsa->saddr = saddr;
15192 + nsa->baddr = baddr;
15197 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
15199 + inet->inet_saddr = nsa->baddr;
15200 + inet->inet_rcv_saddr = nsa->baddr;
15205 + * helper to simplify inet_lookup_listener
15207 + * nxi: the socket's nx_info if any
15208 + * addr: to be verified address
15209 + * saddr: socket address
15211 +static inline int v4_inet_addr_match (
15212 + struct nx_info *nxi,
15216 + if (addr && (saddr == addr))
15219 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
15223 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
15225 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
15226 + (addr == nxi->v4_lback.s_addr))
15227 + return IPI_LOOPBACK;
15232 +int nx_info_has_v4(struct nx_info *nxi)
15236 + if (NX_IPV4(nxi))
15238 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15243 +#else /* CONFIG_INET */
15246 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
15252 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
15258 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
15264 +int nx_info_has_v4(struct nx_info *nxi)
15269 +#endif /* CONFIG_INET */
15271 +#define current_nx_info_has_v4() \
15272 + nx_info_has_v4(current_nx_info())
15275 +// #warning duplicate inclusion
15277 diff -NurpP --minimal linux-2.6.35/include/linux/vs_limit.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_limit.h
15278 --- linux-2.6.35/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
15279 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_limit.h 2010-08-02 17:05:06.000000000 +0200
15281 +#ifndef _VS_LIMIT_H
15282 +#define _VS_LIMIT_H
15284 +#include "vserver/limit.h"
15285 +#include "vserver/base.h"
15286 +#include "vserver/context.h"
15287 +#include "vserver/debug.h"
15288 +#include "vserver/context.h"
15289 +#include "vserver/limit_int.h"
15292 +#define vx_acc_cres(v, d, p, r) \
15293 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
15295 +#define vx_acc_cres_cond(x, d, p, r) \
15296 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
15297 + r, d, p, __FILE__, __LINE__)
15300 +#define vx_add_cres(v, a, p, r) \
15301 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
15302 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
15304 +#define vx_add_cres_cond(x, a, p, r) \
15305 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
15306 + r, a, p, __FILE__, __LINE__)
15307 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
15310 +/* process and file limits */
15312 +#define vx_nproc_inc(p) \
15313 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
15315 +#define vx_nproc_dec(p) \
15316 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
15318 +#define vx_files_inc(f) \
15319 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
15321 +#define vx_files_dec(f) \
15322 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
15324 +#define vx_locks_inc(l) \
15325 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
15327 +#define vx_locks_dec(l) \
15328 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
15330 +#define vx_openfd_inc(f) \
15331 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
15333 +#define vx_openfd_dec(f) \
15334 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
15337 +#define vx_cres_avail(v, n, r) \
15338 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
15341 +#define vx_nproc_avail(n) \
15342 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
15344 +#define vx_files_avail(n) \
15345 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
15347 +#define vx_locks_avail(n) \
15348 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
15350 +#define vx_openfd_avail(n) \
15351 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
15354 +/* dentry limits */
15356 +#define vx_dentry_inc(d) do { \
15357 + if (atomic_read(&d->d_count) == 1) \
15358 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
15361 +#define vx_dentry_dec(d) do { \
15362 + if (atomic_read(&d->d_count) == 0) \
15363 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
15366 +#define vx_dentry_avail(n) \
15367 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
15370 +/* socket limits */
15372 +#define vx_sock_inc(s) \
15373 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
15375 +#define vx_sock_dec(s) \
15376 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
15378 +#define vx_sock_avail(n) \
15379 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
15382 +/* ipc resource limits */
15384 +#define vx_ipcmsg_add(v, u, a) \
15385 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
15387 +#define vx_ipcmsg_sub(v, u, a) \
15388 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
15390 +#define vx_ipcmsg_avail(v, a) \
15391 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
15394 +#define vx_ipcshm_add(v, k, a) \
15395 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
15397 +#define vx_ipcshm_sub(v, k, a) \
15398 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
15400 +#define vx_ipcshm_avail(v, a) \
15401 + vx_cres_avail(v, a, VLIMIT_SHMEM)
15404 +#define vx_semary_inc(a) \
15405 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
15407 +#define vx_semary_dec(a) \
15408 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
15411 +#define vx_nsems_add(a,n) \
15412 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
15414 +#define vx_nsems_sub(a,n) \
15415 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
15419 +#warning duplicate inclusion
15421 diff -NurpP --minimal linux-2.6.35/include/linux/vs_memory.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_memory.h
15422 --- linux-2.6.35/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
15423 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_memory.h 2010-08-02 17:05:06.000000000 +0200
15425 +#ifndef _VS_MEMORY_H
15426 +#define _VS_MEMORY_H
15428 +#include "vserver/limit.h"
15429 +#include "vserver/base.h"
15430 +#include "vserver/context.h"
15431 +#include "vserver/debug.h"
15432 +#include "vserver/context.h"
15433 +#include "vserver/limit_int.h"
15436 + VXPT_UNKNOWN = 0,
15445 +#define vx_page_fault(mm, vma, type, ret)
15449 +void __vx_page_fault(struct mm_struct *mm,
15450 + struct vm_area_struct *vma, int type, int ret)
15452 + struct vx_info *vxi = mm->mm_vx_info;
15455 + static char *page_type[6] =
15456 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
15457 + static char *page_what[4] =
15458 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
15464 + what = (ret & 0x3);
15466 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
15467 + type, what, ret, page_type[type], page_what[what]);
15469 + if (ret & VM_FAULT_WRITE)
15471 + atomic_inc(&vxi->cacct.page[type][what]);
15474 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
15478 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
15481 +#warning duplicate inclusion
15483 diff -NurpP --minimal linux-2.6.35/include/linux/vs_network.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_network.h
15484 --- linux-2.6.35/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
15485 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_network.h 2010-08-02 17:05:06.000000000 +0200
15487 +#ifndef _NX_VS_NETWORK_H
15488 +#define _NX_VS_NETWORK_H
15490 +#include "vserver/context.h"
15491 +#include "vserver/network.h"
15492 +#include "vserver/base.h"
15493 +#include "vserver/check.h"
15494 +#include "vserver/debug.h"
15496 +#include <linux/sched.h>
15499 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
15501 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
15502 + const char *_file, int _line)
15507 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
15508 + nxi, nxi ? nxi->nx_id : 0,
15509 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15512 + atomic_inc(&nxi->nx_usecnt);
15517 +extern void free_nx_info(struct nx_info *);
15519 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
15521 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
15526 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
15527 + nxi, nxi ? nxi->nx_id : 0,
15528 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15531 + if (atomic_dec_and_test(&nxi->nx_usecnt))
15532 + free_nx_info(nxi);
15536 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
15538 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
15539 + const char *_file, int _line)
15542 + vxlprintk(VXD_CBIT(nid, 3),
15543 + "init_nx_info(%p[#%d.%d])",
15544 + nxi, nxi ? nxi->nx_id : 0,
15545 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15548 + atomic_inc(&nxi->nx_usecnt);
15554 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
15556 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
15557 + const char *_file, int _line)
15559 + struct nx_info *nxo;
15564 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
15565 + nxi, nxi ? nxi->nx_id : 0,
15566 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15569 + atomic_inc(&nxi->nx_usecnt);
15570 + nxo = xchg(nxp, nxi);
15574 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
15576 +static inline void __clr_nx_info(struct nx_info **nxp,
15577 + const char *_file, int _line)
15579 + struct nx_info *nxo;
15581 + nxo = xchg(nxp, NULL);
15585 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
15586 + nxo, nxo ? nxo->nx_id : 0,
15587 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
15590 + if (atomic_dec_and_test(&nxo->nx_usecnt))
15591 + free_nx_info(nxo);
15595 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
15597 +static inline void __claim_nx_info(struct nx_info *nxi,
15598 + struct task_struct *task, const char *_file, int _line)
15600 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
15601 + nxi, nxi ? nxi->nx_id : 0,
15602 + nxi?atomic_read(&nxi->nx_usecnt):0,
15603 + nxi?atomic_read(&nxi->nx_tasks):0,
15604 + task, _file, _line);
15606 + atomic_inc(&nxi->nx_tasks);
15610 +extern void unhash_nx_info(struct nx_info *);
15612 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
15614 +static inline void __release_nx_info(struct nx_info *nxi,
15615 + struct task_struct *task, const char *_file, int _line)
15617 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
15618 + nxi, nxi ? nxi->nx_id : 0,
15619 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15620 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
15621 + task, _file, _line);
15625 + if (atomic_dec_and_test(&nxi->nx_tasks))
15626 + unhash_nx_info(nxi);
15630 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
15632 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
15633 + const char *_file, int _line)
15635 + struct nx_info *nxi;
15638 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
15639 + p, _file, _line);
15640 + nxi = __get_nx_info(p->nx_info, _file, _line);
15646 +static inline void exit_nx_info(struct task_struct *p)
15649 + release_nx_info(p->nx_info, p);
15654 +#warning duplicate inclusion
15656 diff -NurpP --minimal linux-2.6.35/include/linux/vs_pid.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_pid.h
15657 --- linux-2.6.35/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
15658 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_pid.h 2010-08-02 17:05:06.000000000 +0200
15663 +#include "vserver/base.h"
15664 +#include "vserver/check.h"
15665 +#include "vserver/context.h"
15666 +#include "vserver/debug.h"
15667 +#include "vserver/pid.h"
15668 +#include <linux/pid_namespace.h>
15671 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
15674 +int vx_proc_task_visible(struct task_struct *task)
15676 + if ((task->pid == 1) &&
15677 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
15678 + /* show a blend through init */
15680 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
15687 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
15692 +struct task_struct *vx_find_proc_task_by_pid(int pid)
15694 + struct task_struct *task = find_task_by_real_pid(pid);
15696 + if (task && !vx_proc_task_visible(task)) {
15697 + vxdprintk(VXD_CBIT(misc, 6),
15698 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
15699 + task, task->xid, task->pid,
15700 + current, current->xid, current->pid);
15709 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
15711 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
15713 + if (task && !vx_proc_task_visible(task)) {
15714 + vxdprintk(VXD_CBIT(misc, 6),
15715 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
15716 + task, task->xid, task->pid,
15717 + current, current->xid, current->pid);
15718 + put_task_struct(task);
15727 +struct task_struct *vx_child_reaper(struct task_struct *p)
15729 + struct vx_info *vxi = p->vx_info;
15730 + struct task_struct *reaper = child_reaper(p);
15735 + BUG_ON(!p->vx_info->vx_reaper);
15737 + /* child reaper for the guest reaper */
15738 + if (vxi->vx_reaper == p)
15741 + reaper = vxi->vx_reaper;
15743 + vxdprintk(VXD_CBIT(xid, 7),
15744 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
15745 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
15753 +#warning duplicate inclusion
15755 diff -NurpP --minimal linux-2.6.35/include/linux/vs_sched.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_sched.h
15756 --- linux-2.6.35/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
15757 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_sched.h 2010-08-02 17:05:06.000000000 +0200
15759 +#ifndef _VS_SCHED_H
15760 +#define _VS_SCHED_H
15762 +#include "vserver/base.h"
15763 +#include "vserver/context.h"
15764 +#include "vserver/sched.h"
15767 +#define VAVAVOOM_RATIO 50
15769 +#define MAX_PRIO_BIAS 20
15770 +#define MIN_PRIO_BIAS -20
15773 +#ifdef CONFIG_VSERVER_HARDCPU
15776 + * effective_prio - return the priority that is based on the static
15777 + * priority but is modified by bonuses/penalties.
15779 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
15780 + * into a -4 ... 0 ... +4 bonus/penalty range.
15782 + * Additionally, we scale another amount based on the number of
15783 + * CPU tokens currently held by the context, if the process is
15784 + * part of a context (and the appropriate SCHED flag is set).
15785 + * This ranges from -5 ... 0 ... +15, quadratically.
15787 + * So, the total bonus is -9 .. 0 .. +19
15788 + * We use ~50% of the full 0...39 priority range so that:
15790 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
15791 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
15792 + * unless that context is far exceeding its CPU allocation.
15794 + * Both properties are important to certain workloads.
15797 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
15799 + int vavavoom, max;
15801 + /* lots of tokens = lots of vavavoom
15802 + * no tokens = no vavavoom */
15803 + if ((vavavoom = sched_pc->tokens) >= 0) {
15804 + max = sched_pc->tokens_max;
15805 + vavavoom = max - vavavoom;
15807 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
15808 + * (vavavoom*vavavoom - (max >> 2)) / max;
15816 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
15818 + struct vx_info *vxi = p->vx_info;
15819 + struct _vx_sched_pc *sched_pc;
15824 + sched_pc = &vx_cpu(vxi, sched_pc);
15825 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
15826 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
15828 + sched_pc->vavavoom = vavavoom;
15829 + prio += vavavoom;
15831 + prio += sched_pc->prio_bias;
15835 +#else /* !CONFIG_VSERVER_HARDCPU */
15838 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
15840 + struct vx_info *vxi = p->vx_info;
15843 + prio += vx_cpu(vxi, sched_pc).prio_bias;
15847 +#endif /* CONFIG_VSERVER_HARDCPU */
15850 +static inline void vx_account_user(struct vx_info *vxi,
15851 + cputime_t cputime, int nice)
15855 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
15858 +static inline void vx_account_system(struct vx_info *vxi,
15859 + cputime_t cputime, int idle)
15863 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
15867 +#warning duplicate inclusion
15869 diff -NurpP --minimal linux-2.6.35/include/linux/vs_socket.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_socket.h
15870 --- linux-2.6.35/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
15871 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_socket.h 2010-08-02 17:05:06.000000000 +0200
15873 +#ifndef _VS_SOCKET_H
15874 +#define _VS_SOCKET_H
15876 +#include "vserver/debug.h"
15877 +#include "vserver/base.h"
15878 +#include "vserver/cacct.h"
15879 +#include "vserver/context.h"
15880 +#include "vserver/tag.h"
15883 +/* socket accounting */
15885 +#include <linux/socket.h>
15887 +static inline int vx_sock_type(int family)
15889 + switch (family) {
15891 + return VXA_SOCK_UNSPEC;
15893 + return VXA_SOCK_UNIX;
15895 + return VXA_SOCK_INET;
15897 + return VXA_SOCK_INET6;
15899 + return VXA_SOCK_PACKET;
15901 + return VXA_SOCK_OTHER;
15905 +#define vx_acc_sock(v, f, p, s) \
15906 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
15908 +static inline void __vx_acc_sock(struct vx_info *vxi,
15909 + int family, int pos, int size, char *file, int line)
15912 + int type = vx_sock_type(family);
15914 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
15915 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
15919 +#define vx_sock_recv(sk, s) \
15920 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
15921 +#define vx_sock_send(sk, s) \
15922 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
15923 +#define vx_sock_fail(sk, s) \
15924 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
15927 +#define sock_vx_init(s) do { \
15928 + (s)->sk_xid = 0; \
15929 + (s)->sk_vx_info = NULL; \
15932 +#define sock_nx_init(s) do { \
15933 + (s)->sk_nid = 0; \
15934 + (s)->sk_nx_info = NULL; \
15938 +#warning duplicate inclusion
15940 diff -NurpP --minimal linux-2.6.35/include/linux/vs_tag.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_tag.h
15941 --- linux-2.6.35/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
15942 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_tag.h 2010-08-02 17:05:06.000000000 +0200
15947 +#include <linux/vserver/tag.h>
15949 +/* check conditions */
15951 +#define DX_ADMIN 0x0001
15952 +#define DX_WATCH 0x0002
15953 +#define DX_HOSTID 0x0008
15955 +#define DX_IDENT 0x0010
15957 +#define DX_ARG_MASK 0x0010
15960 +#define dx_task_tag(t) ((t)->tag)
15962 +#define dx_current_tag() dx_task_tag(current)
15964 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
15966 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
15970 + * check current context for ADMIN/WATCH and
15971 + * optionally against supplied argument
15973 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
15975 + if (mode & DX_ARG_MASK) {
15976 + if ((mode & DX_IDENT) && (id == cid))
15979 + return (((mode & DX_ADMIN) && (cid == 0)) ||
15980 + ((mode & DX_WATCH) && (cid == 1)) ||
15981 + ((mode & DX_HOSTID) && (id == 0)));
15985 +int dx_permission(const struct inode *inode, int mask);
15989 +#warning duplicate inclusion
15991 diff -NurpP --minimal linux-2.6.35/include/linux/vs_time.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_time.h
15992 --- linux-2.6.35/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
15993 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_time.h 2010-08-02 17:05:06.000000000 +0200
15995 +#ifndef _VS_TIME_H
15996 +#define _VS_TIME_H
15999 +/* time faking stuff */
16001 +#ifdef CONFIG_VSERVER_VTIME
16003 +extern void vx_gettimeofday(struct timeval *tv);
16004 +extern int vx_settimeofday(struct timespec *ts);
16007 +#define vx_gettimeofday(t) do_gettimeofday(t)
16008 +#define vx_settimeofday(t) do_settimeofday(t)
16012 +#warning duplicate inclusion
16014 diff -NurpP --minimal linux-2.6.35/include/net/addrconf.h linux-2.6.35-vs2.3.0.36.31/include/net/addrconf.h
16015 --- linux-2.6.35/include/net/addrconf.h 2010-07-07 18:31:56.000000000 +0200
16016 +++ linux-2.6.35-vs2.3.0.36.31/include/net/addrconf.h 2010-08-02 17:05:06.000000000 +0200
16017 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
16018 struct net_device *dev,
16019 const struct in6_addr *daddr,
16020 unsigned int srcprefs,
16021 - struct in6_addr *saddr);
16022 + struct in6_addr *saddr,
16023 + struct nx_info *nxi);
16024 extern int ipv6_get_lladdr(struct net_device *dev,
16025 struct in6_addr *addr,
16026 unsigned char banned_flags);
16027 diff -NurpP --minimal linux-2.6.35/include/net/af_unix.h linux-2.6.35-vs2.3.0.36.31/include/net/af_unix.h
16028 --- linux-2.6.35/include/net/af_unix.h 2010-08-02 16:52:56.000000000 +0200
16029 +++ linux-2.6.35-vs2.3.0.36.31/include/net/af_unix.h 2010-08-02 17:05:06.000000000 +0200
16031 #include <linux/socket.h>
16032 #include <linux/un.h>
16033 #include <linux/mutex.h>
16034 +#include <linux/vs_base.h>
16035 #include <net/sock.h>
16037 extern void unix_inflight(struct file *fp);
16038 diff -NurpP --minimal linux-2.6.35/include/net/inet_timewait_sock.h linux-2.6.35-vs2.3.0.36.31/include/net/inet_timewait_sock.h
16039 --- linux-2.6.35/include/net/inet_timewait_sock.h 2010-08-02 16:52:56.000000000 +0200
16040 +++ linux-2.6.35-vs2.3.0.36.31/include/net/inet_timewait_sock.h 2010-08-02 17:05:06.000000000 +0200
16041 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
16042 #define tw_hash __tw_common.skc_hash
16043 #define tw_prot __tw_common.skc_prot
16044 #define tw_net __tw_common.skc_net
16045 +#define tw_xid __tw_common.skc_xid
16046 +#define tw_vx_info __tw_common.skc_vx_info
16047 +#define tw_nid __tw_common.skc_nid
16048 +#define tw_nx_info __tw_common.skc_nx_info
16050 volatile unsigned char tw_substate;
16051 /* 3 bits hole, try to pack */
16052 diff -NurpP --minimal linux-2.6.35/include/net/route.h linux-2.6.35-vs2.3.0.36.31/include/net/route.h
16053 --- linux-2.6.35/include/net/route.h 2010-08-02 16:52:57.000000000 +0200
16054 +++ linux-2.6.35-vs2.3.0.36.31/include/net/route.h 2010-08-02 17:05:06.000000000 +0200
16055 @@ -147,6 +147,9 @@ static inline void ip_rt_put(struct rtab
16056 dst_release(&rt->u.dst);
16059 +#include <linux/vs_base.h>
16060 +#include <linux/vs_inet.h>
16062 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
16064 extern const __u8 ip_tos2prio[16];
16065 @@ -156,6 +159,9 @@ static inline char rt_tos2priority(u8 to
16066 return ip_tos2prio[IPTOS_TOS(tos)>>1];
16069 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
16070 + struct rtable **, struct flowi *);
16072 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
16073 __be32 src, u32 tos, int oif, u8 protocol,
16074 __be16 sport, __be16 dport, struct sock *sk,
16075 @@ -173,11 +179,24 @@ static inline int ip_route_connect(struc
16078 struct net *net = sock_net(sk);
16079 + struct nx_info *nx_info = current_nx_info();
16081 if (inet_sk(sk)->transparent)
16082 fl.flags |= FLOWI_FLAG_ANYSRC;
16084 - if (!dst || !src) {
16086 + nx_info = sk->sk_nx_info;
16088 + vxdprintk(VXD_CBIT(net, 4),
16089 + "ip_route_connect(%p) %p,%p;%lx",
16090 + sk, nx_info, sk->sk_socket,
16091 + (sk->sk_socket?sk->sk_socket->flags:0));
16093 + err = ip_v4_find_src(net, nx_info, rp, &fl);
16097 + if (!fl.fl4_dst || !fl.fl4_src) {
16098 err = __ip_route_output_key(net, rp, &fl);
16101 diff -NurpP --minimal linux-2.6.35/include/net/sock.h linux-2.6.35-vs2.3.0.36.31/include/net/sock.h
16102 --- linux-2.6.35/include/net/sock.h 2010-08-02 16:52:57.000000000 +0200
16103 +++ linux-2.6.35-vs2.3.0.36.31/include/net/sock.h 2010-08-02 17:05:06.000000000 +0200
16104 @@ -150,6 +150,10 @@ struct sock_common {
16105 #ifdef CONFIG_NET_NS
16106 struct net *skc_net;
16109 + struct vx_info *skc_vx_info;
16111 + struct nx_info *skc_nx_info;
16115 @@ -239,6 +243,10 @@ struct sock {
16116 #define sk_bind_node __sk_common.skc_bind_node
16117 #define sk_prot __sk_common.skc_prot
16118 #define sk_net __sk_common.skc_net
16119 +#define sk_xid __sk_common.skc_xid
16120 +#define sk_vx_info __sk_common.skc_vx_info
16121 +#define sk_nid __sk_common.skc_nid
16122 +#define sk_nx_info __sk_common.skc_nx_info
16123 kmemcheck_bitfield_begin(flags);
16124 unsigned int sk_shutdown : 2,
16126 diff -NurpP --minimal linux-2.6.35/init/Kconfig linux-2.6.35-vs2.3.0.36.31/init/Kconfig
16127 --- linux-2.6.35/init/Kconfig 2010-08-02 16:52:57.000000000 +0200
16128 +++ linux-2.6.35-vs2.3.0.36.31/init/Kconfig 2010-08-02 17:05:06.000000000 +0200
16129 @@ -472,6 +472,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
16131 boolean "Control Group support"
16135 This option adds support for grouping sets of processes together, for
16136 use with process control subsystems such as Cpusets, CFS, memory
16137 @@ -499,6 +500,7 @@ config CGROUP_DEBUG
16139 bool "Namespace cgroup subsystem"
16143 Provides a simple namespace cgroup subsystem to
16144 provide hierarchical naming of sets of namespaces,
16145 diff -NurpP --minimal linux-2.6.35/init/main.c linux-2.6.35-vs2.3.0.36.31/init/main.c
16146 --- linux-2.6.35/init/main.c 2010-08-02 16:52:57.000000000 +0200
16147 +++ linux-2.6.35-vs2.3.0.36.31/init/main.c 2010-08-02 17:05:06.000000000 +0200
16149 #include <linux/shmem_fs.h>
16150 #include <linux/slab.h>
16151 #include <trace/boot.h>
16152 +#include <linux/vserver/percpu.h>
16154 #include <asm/io.h>
16155 #include <asm/bugs.h>
16156 diff -NurpP --minimal linux-2.6.35/ipc/mqueue.c linux-2.6.35-vs2.3.0.36.31/ipc/mqueue.c
16157 --- linux-2.6.35/ipc/mqueue.c 2010-08-02 16:52:57.000000000 +0200
16158 +++ linux-2.6.35-vs2.3.0.36.31/ipc/mqueue.c 2010-08-02 17:05:06.000000000 +0200
16160 #include <linux/pid.h>
16161 #include <linux/ipc_namespace.h>
16162 #include <linux/slab.h>
16163 +#include <linux/vs_context.h>
16164 +#include <linux/vs_limit.h>
16166 #include <net/sock.h>
16168 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
16169 struct sigevent notify;
16170 struct pid* notify_owner;
16171 struct user_struct *user; /* user who created, for accounting */
16172 + struct vx_info *vxi;
16173 struct sock *notify_sock;
16174 struct sk_buff *notify_cookie;
16176 @@ -125,6 +128,7 @@ static struct inode *mqueue_get_inode(st
16177 if (S_ISREG(mode)) {
16178 struct mqueue_inode_info *info;
16179 struct task_struct *p = current;
16180 + struct vx_info *vxi = p->vx_info;
16181 unsigned long mq_bytes, mq_msg_tblsz;
16183 inode->i_fop = &mqueue_file_operations;
16184 @@ -138,6 +142,7 @@ static struct inode *mqueue_get_inode(st
16185 info->notify_owner = NULL;
16187 info->user = NULL; /* set when all is ok */
16188 + info->vxi = NULL;
16189 memset(&info->attr, 0, sizeof(info->attr));
16190 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
16191 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
16192 @@ -156,16 +161,19 @@ static struct inode *mqueue_get_inode(st
16193 spin_lock(&mq_lock);
16194 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
16195 u->mq_bytes + mq_bytes >
16196 - task_rlimit(p, RLIMIT_MSGQUEUE)) {
16197 + task_rlimit(p, RLIMIT_MSGQUEUE) ||
16198 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
16199 spin_unlock(&mq_lock);
16200 /* mqueue_delete_inode() releases info->messages */
16203 u->mq_bytes += mq_bytes;
16204 + vx_ipcmsg_add(vxi, u, mq_bytes);
16205 spin_unlock(&mq_lock);
16208 info->user = get_uid(u);
16209 + info->vxi = get_vx_info(vxi);
16210 } else if (S_ISDIR(mode)) {
16212 /* Some things misbehave if size == 0 on a directory */
16213 @@ -268,8 +276,11 @@ static void mqueue_delete_inode(struct i
16214 + info->attr.mq_msgsize);
16217 + struct vx_info *vxi = info->vxi;
16219 spin_lock(&mq_lock);
16220 user->mq_bytes -= mq_bytes;
16221 + vx_ipcmsg_sub(vxi, user, mq_bytes);
16223 * get_ns_from_inode() ensures that the
16224 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
16225 @@ -279,6 +290,7 @@ static void mqueue_delete_inode(struct i
16227 ipc_ns->mq_queues_count--;
16228 spin_unlock(&mq_lock);
16229 + put_vx_info(vxi);
16233 diff -NurpP --minimal linux-2.6.35/ipc/msg.c linux-2.6.35-vs2.3.0.36.31/ipc/msg.c
16234 --- linux-2.6.35/ipc/msg.c 2010-08-02 16:52:57.000000000 +0200
16235 +++ linux-2.6.35-vs2.3.0.36.31/ipc/msg.c 2010-08-02 17:05:06.000000000 +0200
16237 #include <linux/rwsem.h>
16238 #include <linux/nsproxy.h>
16239 #include <linux/ipc_namespace.h>
16240 +#include <linux/vs_base.h>
16242 #include <asm/current.h>
16243 #include <asm/uaccess.h>
16244 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
16246 msq->q_perm.mode = msgflg & S_IRWXUGO;
16247 msq->q_perm.key = key;
16248 + msq->q_perm.xid = vx_current_xid();
16250 msq->q_perm.security = NULL;
16251 retval = security_msg_queue_alloc(msq);
16252 diff -NurpP --minimal linux-2.6.35/ipc/namespace.c linux-2.6.35-vs2.3.0.36.31/ipc/namespace.c
16253 --- linux-2.6.35/ipc/namespace.c 2009-09-10 15:26:27.000000000 +0200
16254 +++ linux-2.6.35-vs2.3.0.36.31/ipc/namespace.c 2010-08-02 17:05:06.000000000 +0200
16256 #include <linux/slab.h>
16257 #include <linux/fs.h>
16258 #include <linux/mount.h>
16259 +#include <linux/vs_base.h>
16260 +#include <linux/vserver/global.h>
16264 diff -NurpP --minimal linux-2.6.35/ipc/sem.c linux-2.6.35-vs2.3.0.36.31/ipc/sem.c
16265 --- linux-2.6.35/ipc/sem.c 2010-08-02 16:52:57.000000000 +0200
16266 +++ linux-2.6.35-vs2.3.0.36.31/ipc/sem.c 2010-08-02 17:05:06.000000000 +0200
16268 #include <linux/rwsem.h>
16269 #include <linux/nsproxy.h>
16270 #include <linux/ipc_namespace.h>
16271 +#include <linux/vs_base.h>
16272 +#include <linux/vs_limit.h>
16274 #include <asm/uaccess.h>
16276 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
16278 sma->sem_perm.mode = (semflg & S_IRWXUGO);
16279 sma->sem_perm.key = key;
16280 + sma->sem_perm.xid = vx_current_xid();
16282 sma->sem_perm.security = NULL;
16283 retval = security_sem_alloc(sma);
16284 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
16287 ns->used_sems += nsems;
16288 + /* FIXME: obsoleted? */
16289 + vx_semary_inc(sma);
16290 + vx_nsems_add(sma, nsems);
16292 sma->sem_base = (struct sem *) &sma[1];
16294 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
16296 wake_up_sem_queue_do(&tasks);
16297 ns->used_sems -= sma->sem_nsems;
16298 + /* FIXME: obsoleted? */
16299 + vx_nsems_sub(sma, sma->sem_nsems);
16300 + vx_semary_dec(sma);
16301 security_sem_free(sma);
16302 ipc_rcu_putref(sma);
16304 diff -NurpP --minimal linux-2.6.35/ipc/shm.c linux-2.6.35-vs2.3.0.36.31/ipc/shm.c
16305 --- linux-2.6.35/ipc/shm.c 2010-08-02 16:52:57.000000000 +0200
16306 +++ linux-2.6.35-vs2.3.0.36.31/ipc/shm.c 2010-08-02 17:05:06.000000000 +0200
16308 #include <linux/nsproxy.h>
16309 #include <linux/mount.h>
16310 #include <linux/ipc_namespace.h>
16311 +#include <linux/vs_context.h>
16312 +#include <linux/vs_limit.h>
16314 #include <asm/uaccess.h>
16316 @@ -169,7 +171,12 @@ static void shm_open(struct vm_area_stru
16318 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
16320 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16321 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
16322 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16324 + vx_ipcshm_sub(vxi, shp, numpages);
16325 + ns->shm_tot -= numpages;
16329 if (!is_file_hugepages(shp->shm_file))
16330 @@ -179,6 +186,7 @@ static void shm_destroy(struct ipc_names
16332 fput (shp->shm_file);
16333 security_shm_free(shp);
16334 + put_vx_info(vxi);
16335 ipc_rcu_putref(shp);
16338 @@ -349,11 +357,15 @@ static int newseg(struct ipc_namespace *
16339 if (ns->shm_tot + numpages > ns->shm_ctlall)
16342 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
16345 shp = ipc_rcu_alloc(sizeof(*shp));
16349 shp->shm_perm.key = key;
16350 + shp->shm_perm.xid = vx_current_xid();
16351 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
16352 shp->mlock_user = NULL;
16354 @@ -407,6 +419,7 @@ static int newseg(struct ipc_namespace *
16355 ns->shm_tot += numpages;
16356 error = shp->shm_perm.id;
16358 + vx_ipcshm_add(current_vx_info(), key, numpages);
16362 diff -NurpP --minimal linux-2.6.35/kernel/capability.c linux-2.6.35-vs2.3.0.36.31/kernel/capability.c
16363 --- linux-2.6.35/kernel/capability.c 2010-08-02 16:52:57.000000000 +0200
16364 +++ linux-2.6.35-vs2.3.0.36.31/kernel/capability.c 2010-08-02 17:05:06.000000000 +0200
16366 #include <linux/security.h>
16367 #include <linux/syscalls.h>
16368 #include <linux/pid_namespace.h>
16369 +#include <linux/vs_context.h>
16370 #include <asm/uaccess.h>
16373 @@ -119,6 +120,7 @@ static int cap_validate_magic(cap_user_h
16379 * The only thing that can change the capabilities of the current
16380 * process is the current process. As such, we can't be in this code
16381 @@ -289,6 +291,8 @@ error:
16385 +#include <linux/vserver/base.h>
16388 * capable - Determine if the current task has a superior capability in effect
16389 * @cap: The capability to be tested for
16390 @@ -301,6 +305,9 @@ error:
16392 int capable(int cap)
16394 + /* here for now so we don't require task locking */
16395 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
16397 if (unlikely(!cap_valid(cap))) {
16398 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
16400 diff -NurpP --minimal linux-2.6.35/kernel/compat.c linux-2.6.35-vs2.3.0.36.31/kernel/compat.c
16401 --- linux-2.6.35/kernel/compat.c 2010-08-02 16:52:57.000000000 +0200
16402 +++ linux-2.6.35-vs2.3.0.36.31/kernel/compat.c 2010-08-02 17:05:06.000000000 +0200
16403 @@ -900,7 +900,7 @@ asmlinkage long compat_sys_time(compat_t
16407 - do_gettimeofday(&tv);
16408 + vx_gettimeofday(&tv);
16412 @@ -925,7 +925,7 @@ asmlinkage long compat_sys_stime(compat_
16416 - do_settimeofday(&tv);
16417 + vx_settimeofday(&tv);
16421 diff -NurpP --minimal linux-2.6.35/kernel/exit.c linux-2.6.35-vs2.3.0.36.31/kernel/exit.c
16422 --- linux-2.6.35/kernel/exit.c 2010-08-02 16:52:57.000000000 +0200
16423 +++ linux-2.6.35-vs2.3.0.36.31/kernel/exit.c 2010-08-02 17:05:06.000000000 +0200
16425 #include <linux/fs_struct.h>
16426 #include <linux/init_task.h>
16427 #include <linux/perf_event.h>
16428 +#include <linux/vs_limit.h>
16429 +#include <linux/vs_context.h>
16430 +#include <linux/vs_network.h>
16431 +#include <linux/vs_pid.h>
16432 #include <trace/events/sched.h>
16433 #include <linux/hw_breakpoint.h>
16435 @@ -487,9 +491,11 @@ static void close_files(struct files_str
16436 filp_close(file, files);
16439 + vx_openfd_dec(i);
16447 @@ -1020,11 +1026,16 @@ NORET_TYPE void do_exit(long code)
16449 validate_creds_for_do_exit(tsk);
16451 + /* needs to stay after exit_notify() */
16452 + exit_vx_info(tsk, code);
16453 + exit_nx_info(tsk);
16457 /* causes final put_task_struct in finish_task_switch(). */
16458 tsk->state = TASK_DEAD;
16460 + printk("bad task: %p [%lx]\n", current, current->state);
16462 /* Avoid "noreturn function does return". */
16464 diff -NurpP --minimal linux-2.6.35/kernel/fork.c linux-2.6.35-vs2.3.0.36.31/kernel/fork.c
16465 --- linux-2.6.35/kernel/fork.c 2010-08-02 16:52:57.000000000 +0200
16466 +++ linux-2.6.35-vs2.3.0.36.31/kernel/fork.c 2010-08-02 17:05:06.000000000 +0200
16468 #include <linux/perf_event.h>
16469 #include <linux/posix-timers.h>
16470 #include <linux/user-return-notifier.h>
16471 +#include <linux/vs_context.h>
16472 +#include <linux/vs_network.h>
16473 +#include <linux/vs_limit.h>
16474 +#include <linux/vs_memory.h>
16476 #include <asm/pgtable.h>
16477 #include <asm/pgalloc.h>
16478 @@ -160,6 +164,8 @@ void free_task(struct task_struct *tsk)
16479 account_kernel_stack(tsk->stack, -1);
16480 free_thread_info(tsk->stack);
16481 rt_mutex_debug_task_free(tsk);
16482 + clr_vx_info(&tsk->vx_info);
16483 + clr_nx_info(&tsk->nx_info);
16484 ftrace_graph_exit_task(tsk);
16485 free_task_struct(tsk);
16487 @@ -489,6 +495,7 @@ static struct mm_struct * mm_init(struct
16488 if (likely(!mm_alloc_pgd(mm))) {
16490 mmu_notifier_mm_init(mm);
16491 + set_vx_info(&mm->mm_vx_info, p->vx_info);
16495 @@ -522,6 +529,7 @@ void __mmdrop(struct mm_struct *mm)
16497 destroy_context(mm);
16498 mmu_notifier_mm_destroy(mm);
16499 + clr_vx_info(&mm->mm_vx_info);
16502 EXPORT_SYMBOL_GPL(__mmdrop);
16503 @@ -657,6 +665,7 @@ struct mm_struct *dup_mm(struct task_str
16506 memcpy(mm, oldmm, sizeof(*mm));
16507 + mm->mm_vx_info = NULL;
16509 /* Initializing for Swap token stuff */
16510 mm->token_priority = 0;
16511 @@ -695,6 +704,7 @@ fail_nocontext:
16512 * If init_new_context() failed, we cannot use mmput() to free the mm
16513 * because it calls destroy_context()
16515 + clr_vx_info(&mm->mm_vx_info);
16519 @@ -969,6 +979,8 @@ static struct task_struct *copy_process(
16521 struct task_struct *p;
16522 int cgroup_callbacks_done = 0;
16523 + struct vx_info *vxi;
16524 + struct nx_info *nxi;
16526 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
16527 return ERR_PTR(-EINVAL);
16528 @@ -1015,7 +1027,12 @@ static struct task_struct *copy_process(
16529 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
16530 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
16532 + init_vx_info(&p->vx_info, current_vx_info());
16533 + init_nx_info(&p->nx_info, current_nx_info());
16536 + if (!vx_nproc_avail(1))
16537 + goto bad_fork_free;
16538 if (atomic_read(&p->real_cred->user->processes) >=
16539 task_rlimit(p, RLIMIT_NPROC)) {
16540 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
16541 @@ -1280,6 +1297,18 @@ static struct task_struct *copy_process(
16544 spin_unlock(¤t->sighand->siglock);
16546 + /* p is copy of current */
16547 + vxi = p->vx_info;
16549 + claim_vx_info(vxi, p);
16550 + atomic_inc(&vxi->cvirt.nr_threads);
16551 + atomic_inc(&vxi->cvirt.total_forks);
16554 + nxi = p->nx_info;
16556 + claim_nx_info(nxi, p);
16557 write_unlock_irq(&tasklist_lock);
16558 proc_fork_connector(p);
16559 cgroup_post_fork(p);
16560 diff -NurpP --minimal linux-2.6.35/kernel/kthread.c linux-2.6.35-vs2.3.0.36.31/kernel/kthread.c
16561 --- linux-2.6.35/kernel/kthread.c 2010-07-07 18:31:57.000000000 +0200
16562 +++ linux-2.6.35-vs2.3.0.36.31/kernel/kthread.c 2010-08-02 17:05:06.000000000 +0200
16564 #include <linux/file.h>
16565 #include <linux/module.h>
16566 #include <linux/mutex.h>
16567 +#include <linux/vs_pid.h>
16568 #include <trace/events/sched.h>
16570 static DEFINE_SPINLOCK(kthread_create_lock);
16571 diff -NurpP --minimal linux-2.6.35/kernel/Makefile linux-2.6.35-vs2.3.0.36.31/kernel/Makefile
16572 --- linux-2.6.35/kernel/Makefile 2010-08-02 16:52:57.000000000 +0200
16573 +++ linux-2.6.35-vs2.3.0.36.31/kernel/Makefile 2010-08-02 17:05:06.000000000 +0200
16574 @@ -25,6 +25,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
16575 CFLAGS_REMOVE_perf_event.o = -pg
16579 obj-$(CONFIG_FREEZER) += freezer.o
16580 obj-$(CONFIG_PROFILING) += profile.o
16581 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
16582 diff -NurpP --minimal linux-2.6.35/kernel/nsproxy.c linux-2.6.35-vs2.3.0.36.31/kernel/nsproxy.c
16583 --- linux-2.6.35/kernel/nsproxy.c 2010-07-07 18:31:57.000000000 +0200
16584 +++ linux-2.6.35-vs2.3.0.36.31/kernel/nsproxy.c 2010-08-02 17:05:06.000000000 +0200
16586 #include <linux/mnt_namespace.h>
16587 #include <linux/utsname.h>
16588 #include <linux/pid_namespace.h>
16589 +#include <linux/vserver/global.h>
16590 +#include <linux/vserver/debug.h>
16591 #include <net/net_namespace.h>
16592 #include <linux/ipc_namespace.h>
16594 @@ -43,8 +45,11 @@ static inline struct nsproxy *create_nsp
16595 struct nsproxy *nsproxy;
16597 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
16600 atomic_set(&nsproxy->count, 1);
16601 + atomic_inc(&vs_global_nsproxy);
16603 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
16607 @@ -53,41 +58,52 @@ static inline struct nsproxy *create_nsp
16608 * Return the newly created nsproxy. Do not attach this to the task,
16609 * leave it to the caller to do proper locking and attach it to task.
16611 -static struct nsproxy *create_new_namespaces(unsigned long flags,
16612 - struct task_struct *tsk, struct fs_struct *new_fs)
16613 +static struct nsproxy *unshare_namespaces(unsigned long flags,
16614 + struct nsproxy *orig, struct fs_struct *new_fs)
16616 struct nsproxy *new_nsp;
16619 + vxdprintk(VXD_CBIT(space, 4),
16620 + "unshare_namespaces(0x%08lx,%p,%p)",
16621 + flags, orig, new_fs);
16623 new_nsp = create_nsproxy();
16625 return ERR_PTR(-ENOMEM);
16627 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
16628 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
16629 if (IS_ERR(new_nsp->mnt_ns)) {
16630 err = PTR_ERR(new_nsp->mnt_ns);
16634 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
16635 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
16636 if (IS_ERR(new_nsp->uts_ns)) {
16637 err = PTR_ERR(new_nsp->uts_ns);
16641 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
16642 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
16643 if (IS_ERR(new_nsp->ipc_ns)) {
16644 err = PTR_ERR(new_nsp->ipc_ns);
16648 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
16649 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
16650 if (IS_ERR(new_nsp->pid_ns)) {
16651 err = PTR_ERR(new_nsp->pid_ns);
16655 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
16657 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
16658 + if (IS_ERR(new_nsp->user_ns)) {
16659 + err = PTR_ERR(new_nsp->user_ns);
16663 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
16664 if (IS_ERR(new_nsp->net_ns)) {
16665 err = PTR_ERR(new_nsp->net_ns);
16667 @@ -112,6 +128,38 @@ out_ns:
16668 return ERR_PTR(err);
16671 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
16672 + struct fs_struct *new_fs)
16674 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
16678 + * copies the nsproxy, setting refcount to 1, and grabbing a
16679 + * reference to all contained namespaces.
16681 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
16683 + struct nsproxy *ns = create_nsproxy();
16686 + memcpy(ns, orig, sizeof(struct nsproxy));
16687 + atomic_set(&ns->count, 1);
16690 + get_mnt_ns(ns->mnt_ns);
16692 + get_uts_ns(ns->uts_ns);
16694 + get_ipc_ns(ns->ipc_ns);
16696 + get_pid_ns(ns->pid_ns);
16698 + get_net(ns->net_ns);
16704 * called from clone. This now handles copy for nsproxy and all
16705 * namespaces therein.
16706 @@ -119,9 +167,12 @@ out_ns:
16707 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
16709 struct nsproxy *old_ns = tsk->nsproxy;
16710 - struct nsproxy *new_ns;
16711 + struct nsproxy *new_ns = NULL;
16714 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
16715 + flags, tsk, old_ns);
16720 @@ -131,7 +182,7 @@ int copy_namespaces(unsigned long flags,
16721 CLONE_NEWPID | CLONE_NEWNET)))
16724 - if (!capable(CAP_SYS_ADMIN)) {
16725 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
16729 @@ -158,6 +209,9 @@ int copy_namespaces(unsigned long flags,
16732 put_nsproxy(old_ns);
16733 + vxdprintk(VXD_CBIT(space, 3),
16734 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
16735 + flags, tsk, old_ns, err, new_ns);
16739 @@ -171,7 +225,9 @@ void free_nsproxy(struct nsproxy *ns)
16740 put_ipc_ns(ns->ipc_ns);
16742 put_pid_ns(ns->pid_ns);
16743 - put_net(ns->net_ns);
16745 + put_net(ns->net_ns);
16746 + atomic_dec(&vs_global_nsproxy);
16747 kmem_cache_free(nsproxy_cachep, ns);
16750 @@ -184,11 +240,15 @@ int unshare_nsproxy_namespaces(unsigned
16754 + vxdprintk(VXD_CBIT(space, 4),
16755 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
16756 + unshare_flags, current->nsproxy);
16758 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
16762 - if (!capable(CAP_SYS_ADMIN))
16763 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
16766 *new_nsp = create_new_namespaces(unshare_flags, current,
16767 diff -NurpP --minimal linux-2.6.35/kernel/pid.c linux-2.6.35-vs2.3.0.36.31/kernel/pid.c
16768 --- linux-2.6.35/kernel/pid.c 2010-08-02 16:52:57.000000000 +0200
16769 +++ linux-2.6.35-vs2.3.0.36.31/kernel/pid.c 2010-08-02 17:05:06.000000000 +0200
16771 #include <linux/pid_namespace.h>
16772 #include <linux/init_task.h>
16773 #include <linux/syscalls.h>
16774 +#include <linux/vs_pid.h>
16776 #define pid_hashfn(nr, ns) \
16777 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
16778 @@ -305,7 +306,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
16780 struct pid *find_vpid(int nr)
16782 - return find_pid_ns(nr, current->nsproxy->pid_ns);
16783 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
16785 EXPORT_SYMBOL_GPL(find_vpid);
16787 @@ -365,6 +366,9 @@ void transfer_pid(struct task_struct *ol
16788 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
16790 struct task_struct *result = NULL;
16792 + if (type == PIDTYPE_REALPID)
16793 + type = PIDTYPE_PID;
16795 struct hlist_node *first;
16796 first = rcu_dereference_check(pid->tasks[type].first,
16797 @@ -382,7 +386,7 @@ EXPORT_SYMBOL(pid_task);
16799 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
16801 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
16802 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
16805 struct task_struct *find_task_by_vpid(pid_t vnr)
16806 @@ -424,7 +428,7 @@ struct pid *find_get_pid(pid_t nr)
16808 EXPORT_SYMBOL_GPL(find_get_pid);
16810 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16811 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
16815 @@ -437,6 +441,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
16819 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16821 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
16824 pid_t pid_vnr(struct pid *pid)
16826 return pid_nr_ns(pid, current->nsproxy->pid_ns);
16827 diff -NurpP --minimal linux-2.6.35/kernel/pid_namespace.c linux-2.6.35-vs2.3.0.36.31/kernel/pid_namespace.c
16828 --- linux-2.6.35/kernel/pid_namespace.c 2010-07-07 18:31:57.000000000 +0200
16829 +++ linux-2.6.35-vs2.3.0.36.31/kernel/pid_namespace.c 2010-08-02 17:05:06.000000000 +0200
16831 #include <linux/err.h>
16832 #include <linux/acct.h>
16833 #include <linux/slab.h>
16834 +#include <linux/vserver/global.h>
16836 #define BITS_PER_PAGE (PAGE_SIZE*8)
16838 @@ -87,6 +88,7 @@ static struct pid_namespace *create_pid_
16841 kref_init(&ns->kref);
16842 + atomic_inc(&vs_global_pid_ns);
16844 ns->parent = get_pid_ns(parent_pid_ns);
16846 @@ -112,6 +114,7 @@ static void destroy_pid_namespace(struct
16848 for (i = 0; i < PIDMAP_ENTRIES; i++)
16849 kfree(ns->pidmap[i].page);
16850 + atomic_dec(&vs_global_pid_ns);
16851 kmem_cache_free(pid_ns_cachep, ns);
16854 diff -NurpP --minimal linux-2.6.35/kernel/posix-timers.c linux-2.6.35-vs2.3.0.36.31/kernel/posix-timers.c
16855 --- linux-2.6.35/kernel/posix-timers.c 2010-08-02 16:52:57.000000000 +0200
16856 +++ linux-2.6.35-vs2.3.0.36.31/kernel/posix-timers.c 2010-08-02 17:05:06.000000000 +0200
16858 #include <linux/wait.h>
16859 #include <linux/workqueue.h>
16860 #include <linux/module.h>
16861 +#include <linux/vs_context.h>
16864 * Management arrays for POSIX timers. Timers are kept in slab memory
16865 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
16867 struct task_struct *task;
16868 int shared, ret = -1;
16871 * FIXME: if ->sigq is queued we can race with
16872 * dequeue_signal()->do_schedule_next_timer().
16873 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
16875 task = pid_task(timr->it_pid, PIDTYPE_PID);
16877 + struct vx_info_save vxis;
16878 + struct vx_info *vxi;
16880 + vxi = get_vx_info(task->vx_info);
16881 + enter_vx_info(vxi, &vxis);
16882 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
16883 ret = send_sigqueue(timr->sigq, task, shared);
16884 + leave_vx_info(&vxis);
16885 + put_vx_info(vxi);
16889 /* If we failed to send the signal the timer stops. */
16892 diff -NurpP --minimal linux-2.6.35/kernel/printk.c linux-2.6.35-vs2.3.0.36.31/kernel/printk.c
16893 --- linux-2.6.35/kernel/printk.c 2010-08-02 16:52:57.000000000 +0200
16894 +++ linux-2.6.35-vs2.3.0.36.31/kernel/printk.c 2010-08-02 17:05:06.000000000 +0200
16896 #include <linux/ratelimit.h>
16897 #include <linux/kmsg_dump.h>
16898 #include <linux/syslog.h>
16899 +#include <linux/vs_cvirt.h>
16901 #include <asm/uaccess.h>
16903 @@ -264,18 +265,15 @@ int do_syslog(int type, char __user *buf
16904 unsigned i, j, limit, count;
16910 error = security_syslog(type, from_file);
16915 - case SYSLOG_ACTION_CLOSE: /* Close log */
16917 - case SYSLOG_ACTION_OPEN: /* Open log */
16919 - case SYSLOG_ACTION_READ: /* Read from log */
16920 + if ((type == SYSLOG_ACTION_READ) ||
16921 + (type == SYSLOG_ACTION_READ_ALL) ||
16922 + (type == SYSLOG_ACTION_READ_CLEAR)) {
16924 if (!buf || len < 0)
16926 @@ -286,6 +284,16 @@ int do_syslog(int type, char __user *buf
16931 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
16932 + return vx_do_syslog(type, buf, len);
16935 + case SYSLOG_ACTION_CLOSE: /* Close log */
16937 + case SYSLOG_ACTION_OPEN: /* Open log */
16939 + case SYSLOG_ACTION_READ: /* Read from log */
16940 error = wait_event_interruptible(log_wait,
16941 (log_start - log_end));
16943 @@ -312,16 +320,6 @@ int do_syslog(int type, char __user *buf
16945 /* Read last kernel messages */
16946 case SYSLOG_ACTION_READ_ALL:
16948 - if (!buf || len < 0)
16953 - if (!access_ok(VERIFY_WRITE, buf, len)) {
16958 if (count > log_buf_len)
16959 count = log_buf_len;
16960 diff -NurpP --minimal linux-2.6.35/kernel/ptrace.c linux-2.6.35-vs2.3.0.36.31/kernel/ptrace.c
16961 --- linux-2.6.35/kernel/ptrace.c 2010-08-02 16:52:57.000000000 +0200
16962 +++ linux-2.6.35-vs2.3.0.36.31/kernel/ptrace.c 2010-08-02 17:05:06.000000000 +0200
16964 #include <linux/syscalls.h>
16965 #include <linux/uaccess.h>
16966 #include <linux/regset.h>
16967 +#include <linux/vs_context.h>
16971 @@ -150,6 +151,11 @@ int __ptrace_may_access(struct task_stru
16972 dumpable = get_dumpable(task->mm);
16973 if (!dumpable && !capable(CAP_SYS_PTRACE))
16975 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
16977 + if (!vx_check(task->xid, VS_IDENT) &&
16978 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
16981 return security_ptrace_access_check(task, mode);
16983 @@ -703,6 +709,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
16988 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
16989 + goto out_put_task_struct;
16991 if (request == PTRACE_ATTACH) {
16992 ret = ptrace_attach(child);
16994 diff -NurpP --minimal linux-2.6.35/kernel/sched.c linux-2.6.35-vs2.3.0.36.31/kernel/sched.c
16995 --- linux-2.6.35/kernel/sched.c 2010-08-02 16:52:57.000000000 +0200
16996 +++ linux-2.6.35-vs2.3.0.36.31/kernel/sched.c 2010-08-02 17:05:06.000000000 +0200
16998 #include <linux/ctype.h>
16999 #include <linux/ftrace.h>
17000 #include <linux/slab.h>
17001 +#include <linux/vs_sched.h>
17002 +#include <linux/vs_cvirt.h>
17004 #include <asm/tlb.h>
17005 #include <asm/irq_regs.h>
17006 @@ -2957,9 +2959,17 @@ static inline long calc_load_fold_idle(v
17008 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
17010 - loads[0] = (avenrun[0] + offset) << shift;
17011 - loads[1] = (avenrun[1] + offset) << shift;
17012 - loads[2] = (avenrun[2] + offset) << shift;
17013 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
17014 + struct vx_info *vxi = current_vx_info();
17016 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
17017 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
17018 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
17020 + loads[0] = (avenrun[0] + offset) << shift;
17021 + loads[1] = (avenrun[1] + offset) << shift;
17022 + loads[2] = (avenrun[2] + offset) << shift;
17026 static unsigned long
17027 @@ -3167,16 +3177,19 @@ void account_user_time(struct task_struc
17028 cputime_t cputime_scaled)
17030 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17031 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
17033 + int nice = (TASK_NICE(p) > 0);
17035 /* Add user time to process. */
17036 p->utime = cputime_add(p->utime, cputime);
17037 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
17038 + vx_account_user(vxi, cputime, nice);
17039 account_group_user_time(p, cputime);
17041 /* Add user time to cpustat. */
17042 tmp = cputime_to_cputime64(cputime);
17043 - if (TASK_NICE(p) > 0)
17045 cpustat->nice = cputime64_add(cpustat->nice, tmp);
17047 cpustat->user = cputime64_add(cpustat->user, tmp);
17048 @@ -3227,6 +3240,7 @@ void account_system_time(struct task_str
17049 cputime_t cputime, cputime_t cputime_scaled)
17051 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17052 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
17055 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
17056 @@ -3237,6 +3251,7 @@ void account_system_time(struct task_str
17057 /* Add system time to process. */
17058 p->stime = cputime_add(p->stime, cputime);
17059 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
17060 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
17061 account_group_system_time(p, cputime);
17063 /* Add system time to cpustat. */
17064 @@ -4302,7 +4317,7 @@ SYSCALL_DEFINE1(nice, int, increment)
17067 if (increment < 0 && !can_nice(current, nice))
17069 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
17071 retval = security_task_setnice(current, nice);
17073 diff -NurpP --minimal linux-2.6.35/kernel/sched_fair.c linux-2.6.35-vs2.3.0.36.31/kernel/sched_fair.c
17074 --- linux-2.6.35/kernel/sched_fair.c 2010-08-02 16:52:57.000000000 +0200
17075 +++ linux-2.6.35-vs2.3.0.36.31/kernel/sched_fair.c 2010-08-02 17:05:06.000000000 +0200
17076 @@ -782,6 +782,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
17077 check_spread(cfs_rq, se);
17078 if (se != cfs_rq->curr)
17079 __enqueue_entity(cfs_rq, se);
17081 + if (entity_is_task(se))
17082 + vx_activate_task(task_of(se));
17085 static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
17086 @@ -825,6 +828,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
17088 if (se != cfs_rq->curr)
17089 __dequeue_entity(cfs_rq, se);
17090 + if (entity_is_task(se))
17091 + vx_deactivate_task(task_of(se));
17092 account_entity_dequeue(cfs_rq, se);
17093 update_min_vruntime(cfs_rq);
17095 diff -NurpP --minimal linux-2.6.35/kernel/signal.c linux-2.6.35-vs2.3.0.36.31/kernel/signal.c
17096 --- linux-2.6.35/kernel/signal.c 2010-08-02 16:52:57.000000000 +0200
17097 +++ linux-2.6.35-vs2.3.0.36.31/kernel/signal.c 2010-08-02 17:05:06.000000000 +0200
17099 #include <linux/freezer.h>
17100 #include <linux/pid_namespace.h>
17101 #include <linux/nsproxy.h>
17102 +#include <linux/vs_context.h>
17103 +#include <linux/vs_pid.h>
17104 #define CREATE_TRACE_POINTS
17105 #include <trace/events/signal.h>
17107 @@ -646,9 +648,18 @@ static int check_kill_permission(int sig
17111 + vxdprintk(VXD_CBIT(misc, 7),
17112 + "check_kill_permission(%d,%p,%p[#%u,%u])",
17113 + sig, info, t, vx_task_xid(t), t->pid);
17115 if (!valid_signal(sig))
17118 +/* FIXME: needed? if so, why?
17119 + if ((info != SEND_SIG_NOINFO) &&
17120 + (is_si_special(info) || !si_fromuser(info)))
17123 if (!si_fromuser(info))
17126 @@ -678,6 +689,20 @@ static int check_kill_permission(int sig
17131 + if (t->pid == 1 && current->xid)
17135 + /* FIXME: we shouldn't return ESRCH ever, to avoid
17136 + loops, maybe ENOENT or EACCES? */
17137 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
17138 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
17139 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
17140 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
17144 return security_task_kill(t, info, sig, 0);
17147 @@ -1167,7 +1192,7 @@ int kill_pid_info(int sig, struct siginf
17150 p = pid_task(pid, PIDTYPE_PID);
17152 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
17153 error = group_send_sig_info(sig, info, p);
17154 if (unlikely(error == -ESRCH))
17156 @@ -1207,7 +1232,7 @@ int kill_pid_info_as_uid(int sig, struct
17159 p = pid_task(pid, PIDTYPE_PID);
17161 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
17165 @@ -1262,8 +1287,10 @@ static int kill_something_info(int sig,
17166 struct task_struct * p;
17168 for_each_process(p) {
17169 - if (task_pid_vnr(p) > 1 &&
17170 - !same_thread_group(p, current)) {
17171 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
17172 + task_pid_vnr(p) > 1 &&
17173 + !same_thread_group(p, current) &&
17174 + !vx_current_initpid(p->pid)) {
17175 int err = group_send_sig_info(sig, info, p);
17178 @@ -1930,6 +1957,11 @@ relock:
17179 !sig_kernel_only(signr))
17182 + /* virtual init is protected against user signals */
17183 + if ((info->si_code == SI_USER) &&
17184 + vx_current_initpid(current->pid))
17187 if (sig_kernel_stop(signr)) {
17189 * The default action is to stop all threads in
17190 diff -NurpP --minimal linux-2.6.35/kernel/softirq.c linux-2.6.35-vs2.3.0.36.31/kernel/softirq.c
17191 --- linux-2.6.35/kernel/softirq.c 2010-08-02 16:52:57.000000000 +0200
17192 +++ linux-2.6.35-vs2.3.0.36.31/kernel/softirq.c 2010-08-02 17:05:06.000000000 +0200
17194 #include <linux/ftrace.h>
17195 #include <linux/smp.h>
17196 #include <linux/tick.h>
17197 +#include <linux/vs_context.h>
17199 #define CREATE_TRACE_POINTS
17200 #include <trace/events/irq.h>
17201 diff -NurpP --minimal linux-2.6.35/kernel/sys.c linux-2.6.35-vs2.3.0.36.31/kernel/sys.c
17202 --- linux-2.6.35/kernel/sys.c 2010-08-02 16:52:57.000000000 +0200
17203 +++ linux-2.6.35-vs2.3.0.36.31/kernel/sys.c 2010-08-02 17:48:19.000000000 +0200
17205 #include <linux/syscalls.h>
17206 #include <linux/kprobes.h>
17207 #include <linux/user_namespace.h>
17208 +#include <linux/vs_pid.h>
17210 #include <asm/uaccess.h>
17211 #include <asm/io.h>
17212 @@ -131,7 +132,10 @@ static int set_one_prio(struct task_stru
17215 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17217 + if (vx_flags(VXF_IGNEG_NICE, 0))
17223 no_nice = security_task_setnice(p, niceval);
17224 @@ -181,6 +185,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
17226 pgrp = task_pgrp(current);
17227 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17228 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17230 error = set_one_prio(p, niceval, error);
17231 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
17233 @@ -244,6 +250,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
17235 pgrp = task_pgrp(current);
17236 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17237 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17239 niceval = 20 - task_nice(p);
17240 if (niceval > retval)
17242 @@ -357,6 +365,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
17244 static DEFINE_MUTEX(reboot_mutex);
17246 +long vs_reboot(unsigned int, void __user *);
17249 * Reboot system call: for obvious reasons only root may call it,
17250 * and even root needs to set up some magic numbers in the registers
17251 @@ -389,6 +399,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
17252 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17253 cmd = LINUX_REBOOT_CMD_HALT;
17255 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
17256 + return vs_reboot(cmd, arg);
17258 mutex_lock(&reboot_mutex);
17260 case LINUX_REBOOT_CMD_RESTART:
17261 @@ -1167,7 +1180,7 @@ SYSCALL_DEFINE2(sethostname, char __user
17263 char tmp[__NEW_UTS_LEN];
17265 - if (!capable(CAP_SYS_ADMIN))
17266 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17268 if (len < 0 || len > __NEW_UTS_LEN)
17270 @@ -1216,7 +1229,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
17272 char tmp[__NEW_UTS_LEN];
17274 - if (!capable(CAP_SYS_ADMIN))
17275 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17277 if (len < 0 || len > __NEW_UTS_LEN)
17279 @@ -1285,7 +1298,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
17281 old_rlim = current->signal->rlim + resource;
17282 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
17283 - !capable(CAP_SYS_RESOURCE))
17284 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17286 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
17288 diff -NurpP --minimal linux-2.6.35/kernel/sysctl_binary.c linux-2.6.35-vs2.3.0.36.31/kernel/sysctl_binary.c
17289 --- linux-2.6.35/kernel/sysctl_binary.c 2010-08-02 16:52:57.000000000 +0200
17290 +++ linux-2.6.35-vs2.3.0.36.31/kernel/sysctl_binary.c 2010-08-02 17:05:06.000000000 +0200
17291 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
17293 { CTL_INT, KERN_PANIC, "panic" },
17294 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
17295 + { CTL_STR, KERN_VSHELPER, "vshelper" },
17297 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
17298 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
17299 diff -NurpP --minimal linux-2.6.35/kernel/sysctl.c linux-2.6.35-vs2.3.0.36.31/kernel/sysctl.c
17300 --- linux-2.6.35/kernel/sysctl.c 2010-08-02 16:52:57.000000000 +0200
17301 +++ linux-2.6.35-vs2.3.0.36.31/kernel/sysctl.c 2010-08-02 17:05:06.000000000 +0200
17303 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
17304 #include <linux/lockdep.h>
17306 +extern char vshelper_path[];
17307 #ifdef CONFIG_CHR_DEV_SG
17308 #include <scsi/sg.h>
17310 @@ -571,6 +572,13 @@ static struct ctl_table kern_table[] = {
17311 .proc_handler = proc_dostring,
17315 + .procname = "vshelper",
17316 + .data = &vshelper_path,
17319 + .proc_handler = &proc_dostring,
17321 #ifdef CONFIG_CHR_DEV_SG
17323 .procname = "sg-big-buff",
17324 diff -NurpP --minimal linux-2.6.35/kernel/time.c linux-2.6.35-vs2.3.0.36.31/kernel/time.c
17325 --- linux-2.6.35/kernel/time.c 2010-08-02 16:52:57.000000000 +0200
17326 +++ linux-2.6.35-vs2.3.0.36.31/kernel/time.c 2010-08-02 17:05:06.000000000 +0200
17327 @@ -62,6 +62,7 @@ EXPORT_SYMBOL(sys_tz);
17328 SYSCALL_DEFINE1(time, time_t __user *, tloc)
17330 time_t i = get_seconds();
17331 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
17334 if (put_user(i,tloc))
17335 @@ -92,7 +93,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
17339 - do_settimeofday(&tv);
17340 + vx_settimeofday(&tv);
17344 @@ -103,7 +104,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
17346 if (likely(tv != NULL)) {
17347 struct timeval ktv;
17348 - do_gettimeofday(&ktv);
17349 + vx_gettimeofday(&ktv);
17350 if (copy_to_user(tv, &ktv, sizeof(ktv)))
17353 @@ -177,7 +178,7 @@ int do_sys_settimeofday(struct timespec
17354 /* SMP safe, again the code in arch/foo/time.c should
17355 * globally block out interrupts when it runs.
17357 - return do_settimeofday(tv);
17358 + return vx_settimeofday(tv);
17362 @@ -309,7 +310,7 @@ void getnstimeofday(struct timespec *tv)
17366 - do_gettimeofday(&x);
17367 + vx_gettimeofday(&x);
17368 tv->tv_sec = x.tv_sec;
17369 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17371 diff -NurpP --minimal linux-2.6.35/kernel/timer.c linux-2.6.35-vs2.3.0.36.31/kernel/timer.c
17372 --- linux-2.6.35/kernel/timer.c 2010-08-02 16:52:58.000000000 +0200
17373 +++ linux-2.6.35-vs2.3.0.36.31/kernel/timer.c 2010-08-02 17:05:06.000000000 +0200
17375 #include <linux/perf_event.h>
17376 #include <linux/sched.h>
17377 #include <linux/slab.h>
17378 +#include <linux/vs_base.h>
17379 +#include <linux/vs_cvirt.h>
17380 +#include <linux/vs_pid.h>
17381 +#include <linux/vserver/sched.h>
17383 #include <asm/uaccess.h>
17384 #include <asm/unistd.h>
17385 @@ -1318,12 +1322,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17392 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
17393 - * should be moved into arch/i386 instead?
17397 * sys_getpid - return the thread group id of the current process
17398 @@ -1352,10 +1350,23 @@ SYSCALL_DEFINE0(getppid)
17400 pid = task_tgid_vnr(current->real_parent);
17402 + return vx_map_pid(pid);
17409 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17412 +asmlinkage long do_getxpid(long *ppid)
17414 + *ppid = sys_getppid();
17415 + return sys_getpid();
17418 +#else /* _alpha_ */
17420 SYSCALL_DEFINE0(getuid)
17422 /* Only we change this so SMP safe */
17423 diff -NurpP --minimal linux-2.6.35/kernel/user_namespace.c linux-2.6.35-vs2.3.0.36.31/kernel/user_namespace.c
17424 --- linux-2.6.35/kernel/user_namespace.c 2010-08-02 16:52:58.000000000 +0200
17425 +++ linux-2.6.35-vs2.3.0.36.31/kernel/user_namespace.c 2010-08-02 17:05:06.000000000 +0200
17427 #include <linux/slab.h>
17428 #include <linux/user_namespace.h>
17429 #include <linux/cred.h>
17430 +#include <linux/vserver/global.h>
17433 * Create a new user namespace, deriving the creator from the user in the
17434 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
17437 kref_init(&ns->kref);
17438 + atomic_inc(&vs_global_user_ns);
17440 for (n = 0; n < UIDHASH_SZ; ++n)
17441 INIT_HLIST_HEAD(ns->uidhash_table + n);
17442 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
17443 struct user_namespace *ns =
17444 container_of(kref, struct user_namespace, kref);
17446 + /* FIXME: maybe move into destroyer? */
17447 + atomic_dec(&vs_global_user_ns);
17448 INIT_WORK(&ns->destroyer, free_user_ns_work);
17449 schedule_work(&ns->destroyer);
17451 diff -NurpP --minimal linux-2.6.35/kernel/utsname.c linux-2.6.35-vs2.3.0.36.31/kernel/utsname.c
17452 --- linux-2.6.35/kernel/utsname.c 2009-09-10 15:26:28.000000000 +0200
17453 +++ linux-2.6.35-vs2.3.0.36.31/kernel/utsname.c 2010-08-02 17:05:06.000000000 +0200
17454 @@ -14,14 +14,17 @@
17455 #include <linux/utsname.h>
17456 #include <linux/err.h>
17457 #include <linux/slab.h>
17458 +#include <linux/vserver/global.h>
17460 static struct uts_namespace *create_uts_ns(void)
17462 struct uts_namespace *uts_ns;
17464 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
17467 kref_init(&uts_ns->kref);
17468 + atomic_inc(&vs_global_uts_ns);
17473 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
17474 struct uts_namespace *ns;
17476 ns = container_of(kref, struct uts_namespace, kref);
17477 + atomic_dec(&vs_global_uts_ns);
17480 diff -NurpP --minimal linux-2.6.35/kernel/vserver/cacct.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cacct.c
17481 --- linux-2.6.35/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
17482 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cacct.c 2010-08-02 17:05:06.000000000 +0200
17485 + * linux/kernel/vserver/cacct.c
17487 + * Virtual Server: Context Accounting
17489 + * Copyright (C) 2006-2007 Herbert Pötzl
17491 + * V0.01 added accounting stats
17495 +#include <linux/types.h>
17496 +#include <linux/vs_context.h>
17497 +#include <linux/vserver/cacct_cmd.h>
17498 +#include <linux/vserver/cacct_int.h>
17500 +#include <asm/errno.h>
17501 +#include <asm/uaccess.h>
17504 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17506 + struct vcmd_sock_stat_v0 vc_data;
17509 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17512 + field = vc_data.field;
17513 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
17516 + for (j = 0; j < 3; j++) {
17517 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17518 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17521 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17526 diff -NurpP --minimal linux-2.6.35/kernel/vserver/cacct_init.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cacct_init.h
17527 --- linux-2.6.35/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
17528 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cacct_init.h 2010-08-02 17:05:06.000000000 +0200
17532 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17537 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17538 + for (j = 0; j < 3; j++) {
17539 + atomic_long_set(&cacct->sock[i][j].count, 0);
17540 + atomic_long_set(&cacct->sock[i][j].total, 0);
17543 + for (i = 0; i < 8; i++)
17544 + atomic_set(&cacct->slab[i], 0);
17545 + for (i = 0; i < 5; i++)
17546 + for (j = 0; j < 4; j++)
17547 + atomic_set(&cacct->page[i][j], 0);
17550 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17555 diff -NurpP --minimal linux-2.6.35/kernel/vserver/cacct_proc.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cacct_proc.h
17556 --- linux-2.6.35/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
17557 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cacct_proc.h 2010-08-02 17:05:06.000000000 +0200
17559 +#ifndef _VX_CACCT_PROC_H
17560 +#define _VX_CACCT_PROC_H
17562 +#include <linux/vserver/cacct_int.h>
17565 +#define VX_SOCKA_TOP \
17566 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
17568 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17570 + int i, j, length = 0;
17571 + static char *type[VXA_SOCK_SIZE] = {
17572 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17575 + length += sprintf(buffer + length, VX_SOCKA_TOP);
17576 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17577 + length += sprintf(buffer + length, "%s:", type[i]);
17578 + for (j = 0; j < 3; j++) {
17579 + length += sprintf(buffer + length,
17580 + "\t%10lu/%-10lu",
17581 + vx_sock_count(cacct, i, j),
17582 + vx_sock_total(cacct, i, j));
17584 + buffer[length++] = '\n';
17587 + length += sprintf(buffer + length, "\n");
17588 + length += sprintf(buffer + length,
17589 + "slab:\t %8u %8u %8u %8u\n",
17590 + atomic_read(&cacct->slab[1]),
17591 + atomic_read(&cacct->slab[4]),
17592 + atomic_read(&cacct->slab[0]),
17593 + atomic_read(&cacct->slab[2]));
17595 + length += sprintf(buffer + length, "\n");
17596 + for (i = 0; i < 5; i++) {
17597 + length += sprintf(buffer + length,
17598 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17599 + atomic_read(&cacct->page[i][0]),
17600 + atomic_read(&cacct->page[i][1]),
17601 + atomic_read(&cacct->page[i][2]),
17602 + atomic_read(&cacct->page[i][3]),
17603 + atomic_read(&cacct->page[i][4]),
17604 + atomic_read(&cacct->page[i][5]),
17605 + atomic_read(&cacct->page[i][6]),
17606 + atomic_read(&cacct->page[i][7]));
17611 +#endif /* _VX_CACCT_PROC_H */
17612 diff -NurpP --minimal linux-2.6.35/kernel/vserver/context.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/context.c
17613 --- linux-2.6.35/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
17614 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/context.c 2010-08-02 17:05:06.000000000 +0200
17617 + * linux/kernel/vserver/context.c
17619 + * Virtual Server: Context Support
17621 + * Copyright (C) 2003-2007 Herbert Pötzl
17623 + * V0.01 context helper
17624 + * V0.02 vx_ctx_kill syscall command
17625 + * V0.03 replaced context_info calls
17626 + * V0.04 redesign of struct (de)alloc
17627 + * V0.05 rlimit basic implementation
17628 + * V0.06 task_xid and info commands
17629 + * V0.07 context flags and caps
17630 + * V0.08 switch to RCU based hash
17631 + * V0.09 revert to non RCU for now
17632 + * V0.10 and back to working RCU hash
17633 + * V0.11 and back to locking again
17634 + * V0.12 referenced context store
17635 + * V0.13 separate per cpu data
17636 + * V0.14 changed vcmds to vxi arg
17637 + * V0.15 added context stat
17638 + * V0.16 have __create claim() the vxi
17639 + * V0.17 removed older and legacy stuff
17643 +#include <linux/slab.h>
17644 +#include <linux/types.h>
17645 +#include <linux/security.h>
17646 +#include <linux/pid_namespace.h>
17648 +#include <linux/vserver/context.h>
17649 +#include <linux/vserver/network.h>
17650 +#include <linux/vserver/debug.h>
17651 +#include <linux/vserver/limit.h>
17652 +#include <linux/vserver/limit_int.h>
17653 +#include <linux/vserver/space.h>
17654 +#include <linux/init_task.h>
17655 +#include <linux/fs_struct.h>
17657 +#include <linux/vs_context.h>
17658 +#include <linux/vs_limit.h>
17659 +#include <linux/vs_pid.h>
17660 +#include <linux/vserver/context_cmd.h>
17662 +#include "cvirt_init.h"
17663 +#include "cacct_init.h"
17664 +#include "limit_init.h"
17665 +#include "sched_init.h"
17668 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
17669 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
17672 +/* now inactive context structures */
17674 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17676 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17679 +/* __alloc_vx_info()
17681 + * allocate an initialized vx_info struct
17682 + * doesn't make it visible (hash) */
17684 +static struct vx_info *__alloc_vx_info(xid_t xid)
17686 + struct vx_info *new = NULL;
17689 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17691 + /* would this benefit from a slab cache? */
17692 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17696 + memset(new, 0, sizeof(struct vx_info));
17698 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17699 + if (!new->ptr_pc)
17702 + new->vx_id = xid;
17703 + INIT_HLIST_NODE(&new->vx_hlist);
17704 + atomic_set(&new->vx_usecnt, 0);
17705 + atomic_set(&new->vx_tasks, 0);
17706 + new->vx_parent = NULL;
17707 + new->vx_state = 0;
17708 + init_waitqueue_head(&new->vx_wait);
17710 + /* prepare reaper */
17711 + get_task_struct(init_pid_ns.child_reaper);
17712 + new->vx_reaper = init_pid_ns.child_reaper;
17713 + new->vx_badness_bias = 0;
17715 + /* rest of init goes here */
17716 + vx_info_init_limit(&new->limit);
17717 + vx_info_init_sched(&new->sched);
17718 + vx_info_init_cvirt(&new->cvirt);
17719 + vx_info_init_cacct(&new->cacct);
17721 + /* per cpu data structures */
17722 + for_each_possible_cpu(cpu) {
17723 + vx_info_init_sched_pc(
17724 + &vx_per_cpu(new, sched_pc, cpu), cpu);
17725 + vx_info_init_cvirt_pc(
17726 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17729 + new->vx_flags = VXF_INIT_SET;
17730 + cap_set_init_eff(new->vx_bcaps);
17731 + new->vx_ccaps = 0;
17732 + new->vx_umask = 0;
17734 + new->reboot_cmd = 0;
17735 + new->exit_code = 0;
17737 + // preconfig fs entries
17738 + for (index = 0; index < VX_SPACES; index++) {
17739 + write_lock(&init_fs.lock);
17741 + write_unlock(&init_fs.lock);
17742 + new->vx_fs[index] = &init_fs;
17745 + vxdprintk(VXD_CBIT(xid, 0),
17746 + "alloc_vx_info(%d) = %p", xid, new);
17747 + vxh_alloc_vx_info(new);
17748 + atomic_inc(&vx_global_ctotal);
17757 +/* __dealloc_vx_info()
17759 + * final disposal of vx_info */
17761 +static void __dealloc_vx_info(struct vx_info *vxi)
17763 +#ifdef CONFIG_VSERVER_WARN
17764 + struct vx_info_save vxis;
17767 + vxdprintk(VXD_CBIT(xid, 0),
17768 + "dealloc_vx_info(%p)", vxi);
17769 + vxh_dealloc_vx_info(vxi);
17771 +#ifdef CONFIG_VSERVER_WARN
17772 + enter_vx_info(vxi, &vxis);
17773 + vx_info_exit_limit(&vxi->limit);
17774 + vx_info_exit_sched(&vxi->sched);
17775 + vx_info_exit_cvirt(&vxi->cvirt);
17776 + vx_info_exit_cacct(&vxi->cacct);
17778 + for_each_possible_cpu(cpu) {
17779 + vx_info_exit_sched_pc(
17780 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17781 + vx_info_exit_cvirt_pc(
17782 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17784 + leave_vx_info(&vxis);
17788 + vxi->vx_state |= VXS_RELEASED;
17791 + free_percpu(vxi->ptr_pc);
17794 + atomic_dec(&vx_global_ctotal);
17797 +static void __shutdown_vx_info(struct vx_info *vxi)
17799 + struct nsproxy *nsproxy;
17800 + struct fs_struct *fs;
17805 + vxi->vx_state |= VXS_SHUTDOWN;
17806 + vs_state_change(vxi, VSC_SHUTDOWN);
17808 + for (index = 0; index < VX_SPACES; index++) {
17809 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
17811 + put_nsproxy(nsproxy);
17813 + fs = xchg(&vxi->vx_fs[index], NULL);
17814 + write_lock(&fs->lock);
17815 + kill = !--fs->users;
17816 + write_unlock(&fs->lock);
17818 + free_fs_struct(fs);
17822 +/* exported stuff */
17824 +void free_vx_info(struct vx_info *vxi)
17826 + unsigned long flags;
17829 + /* check for reference counts first */
17830 + BUG_ON(atomic_read(&vxi->vx_usecnt));
17831 + BUG_ON(atomic_read(&vxi->vx_tasks));
17833 + /* context must not be hashed */
17834 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17836 + /* context shutdown is mandatory */
17837 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
17839 + /* nsproxy and fs check */
17840 + for (index = 0; index < VX_SPACES; index++) {
17841 + BUG_ON(vxi->vx_nsproxy[index]);
17842 + BUG_ON(vxi->vx_fs[index]);
17845 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17846 + hlist_del(&vxi->vx_hlist);
17847 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17849 + __dealloc_vx_info(vxi);
17853 +/* hash table for vx_info hash */
17855 +#define VX_HASH_SIZE 13
17857 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
17858 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
17860 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
17863 +static inline unsigned int __hashval(xid_t xid)
17865 + return (xid % VX_HASH_SIZE);
17870 +/* __hash_vx_info()
17872 + * add the vxi to the global hash table
17873 + * requires the hash_lock to be held */
17875 +static inline void __hash_vx_info(struct vx_info *vxi)
17877 + struct hlist_head *head;
17879 + vxd_assert_lock(&vx_info_hash_lock);
17880 + vxdprintk(VXD_CBIT(xid, 4),
17881 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
17882 + vxh_hash_vx_info(vxi);
17884 + /* context must not be hashed */
17885 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17887 + vxi->vx_state |= VXS_HASHED;
17888 + head = &vx_info_hash[__hashval(vxi->vx_id)];
17889 + hlist_add_head(&vxi->vx_hlist, head);
17890 + atomic_inc(&vx_global_cactive);
17893 +/* __unhash_vx_info()
17895 + * remove the vxi from the global hash table
17896 + * requires the hash_lock to be held */
17898 +static inline void __unhash_vx_info(struct vx_info *vxi)
17900 + unsigned long flags;
17902 + vxd_assert_lock(&vx_info_hash_lock);
17903 + vxdprintk(VXD_CBIT(xid, 4),
17904 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
17905 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
17906 + vxh_unhash_vx_info(vxi);
17908 + /* context must be hashed */
17909 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
17910 + /* but without tasks */
17911 + BUG_ON(atomic_read(&vxi->vx_tasks));
17913 + vxi->vx_state &= ~VXS_HASHED;
17914 + hlist_del_init(&vxi->vx_hlist);
17915 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17916 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
17917 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17918 + atomic_dec(&vx_global_cactive);
17922 +/* __lookup_vx_info()
17924 + * requires the hash_lock to be held
17925 + * doesn't increment the vx_refcnt */
17927 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
17929 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
17930 + struct hlist_node *pos;
17931 + struct vx_info *vxi;
17933 + vxd_assert_lock(&vx_info_hash_lock);
17934 + hlist_for_each(pos, head) {
17935 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17937 + if (vxi->vx_id == xid)
17942 + vxdprintk(VXD_CBIT(xid, 0),
17943 + "__lookup_vx_info(#%u): %p[#%u]",
17944 + xid, vxi, vxi ? vxi->vx_id : 0);
17945 + vxh_lookup_vx_info(vxi, xid);
17950 +/* __create_vx_info()
17952 + * create the requested context
17953 + * get(), claim() and hash it */
17955 +static struct vx_info *__create_vx_info(int id)
17957 + struct vx_info *new, *vxi = NULL;
17959 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
17961 + if (!(new = __alloc_vx_info(id)))
17962 + return ERR_PTR(-ENOMEM);
17964 + /* required to make dynamic xids unique */
17965 + spin_lock(&vx_info_hash_lock);
17967 + /* static context requested */
17968 + if ((vxi = __lookup_vx_info(id))) {
17969 + vxdprintk(VXD_CBIT(xid, 0),
17970 + "create_vx_info(%d) = %p (already there)", id, vxi);
17971 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17972 + vxi = ERR_PTR(-EBUSY);
17974 + vxi = ERR_PTR(-EEXIST);
17977 + /* new context */
17978 + vxdprintk(VXD_CBIT(xid, 0),
17979 + "create_vx_info(%d) = %p (new)", id, new);
17980 + claim_vx_info(new, NULL);
17981 + __hash_vx_info(get_vx_info(new));
17982 + vxi = new, new = NULL;
17985 + spin_unlock(&vx_info_hash_lock);
17986 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
17988 + __dealloc_vx_info(new);
17993 +/* exported stuff */
17996 +void unhash_vx_info(struct vx_info *vxi)
17998 + __shutdown_vx_info(vxi);
17999 + spin_lock(&vx_info_hash_lock);
18000 + __unhash_vx_info(vxi);
18001 + spin_unlock(&vx_info_hash_lock);
18002 + __wakeup_vx_info(vxi);
18006 +/* lookup_vx_info()
18008 + * search for a vx_info and get() it
18009 + * negative id means current */
18011 +struct vx_info *lookup_vx_info(int id)
18013 + struct vx_info *vxi = NULL;
18016 + vxi = get_vx_info(current_vx_info());
18017 + } else if (id > 1) {
18018 + spin_lock(&vx_info_hash_lock);
18019 + vxi = get_vx_info(__lookup_vx_info(id));
18020 + spin_unlock(&vx_info_hash_lock);
18025 +/* xid_is_hashed()
18027 + * verify that xid is still hashed */
18029 +int xid_is_hashed(xid_t xid)
18033 + spin_lock(&vx_info_hash_lock);
18034 + hashed = (__lookup_vx_info(xid) != NULL);
18035 + spin_unlock(&vx_info_hash_lock);
18039 +#ifdef CONFIG_PROC_FS
18043 + * get a subset of hashed xids for proc
18044 + * assumes size is at least one */
18046 +int get_xid_list(int index, unsigned int *xids, int size)
18048 + int hindex, nr_xids = 0;
18050 + /* only show current and children */
18051 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18054 + xids[nr_xids] = vx_current_xid();
18058 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18059 + struct hlist_head *head = &vx_info_hash[hindex];
18060 + struct hlist_node *pos;
18062 + spin_lock(&vx_info_hash_lock);
18063 + hlist_for_each(pos, head) {
18064 + struct vx_info *vxi;
18069 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18070 + xids[nr_xids] = vxi->vx_id;
18071 + if (++nr_xids >= size) {
18072 + spin_unlock(&vx_info_hash_lock);
18076 + /* keep the lock time short */
18077 + spin_unlock(&vx_info_hash_lock);
18084 +#ifdef CONFIG_VSERVER_DEBUG
18086 +void dump_vx_info_inactive(int level)
18088 + struct hlist_node *entry, *next;
18090 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
18091 + struct vx_info *vxi =
18092 + list_entry(entry, struct vx_info, vx_hlist);
18094 + dump_vx_info(vxi, level);
18101 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18103 + struct user_struct *new_user, *old_user;
18108 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18111 + new_user = alloc_uid(vxi->vx_id, p->uid);
18115 + old_user = p->user;
18116 + if (new_user != old_user) {
18117 + atomic_inc(&new_user->processes);
18118 + atomic_dec(&old_user->processes);
18119 + p->user = new_user;
18121 + free_uid(old_user);
18127 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18129 + // p->cap_effective &= vxi->vx_cap_bset;
18130 + p->cap_effective =
18131 + cap_intersect(p->cap_effective, vxi->cap_bset);
18132 + // p->cap_inheritable &= vxi->vx_cap_bset;
18133 + p->cap_inheritable =
18134 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
18135 + // p->cap_permitted &= vxi->vx_cap_bset;
18136 + p->cap_permitted =
18137 + cap_intersect(p->cap_permitted, vxi->cap_bset);
18142 +#include <linux/file.h>
18143 +#include <linux/fdtable.h>
18145 +static int vx_openfd_task(struct task_struct *tsk)
18147 + struct files_struct *files = tsk->files;
18148 + struct fdtable *fdt;
18149 + const unsigned long *bptr;
18150 + int count, total;
18152 + /* no rcu_read_lock() because of spin_lock() */
18153 + spin_lock(&files->file_lock);
18154 + fdt = files_fdtable(files);
18155 + bptr = fdt->open_fds->fds_bits;
18156 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
18157 + for (total = 0; count > 0; count--) {
18159 + total += hweight_long(*bptr);
18162 + spin_unlock(&files->file_lock);
18167 +/* for *space compatibility */
18169 +asmlinkage long sys_unshare(unsigned long);
18172 + * migrate task to new context
18173 + * gets vxi, puts old_vxi on change
18174 + * optionally unshares namespaces (hack)
18177 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18179 + struct vx_info *old_vxi;
18185 + vxdprintk(VXD_CBIT(xid, 5),
18186 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18187 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18189 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18190 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18193 + if (vx_info_state(vxi, VXS_SHUTDOWN))
18196 + old_vxi = task_get_vx_info(p);
18197 + if (old_vxi == vxi)
18200 +// if (!(ret = vx_migrate_user(p, vxi))) {
18205 + openfd = vx_openfd_task(p);
18208 + atomic_dec(&old_vxi->cvirt.nr_threads);
18209 + atomic_dec(&old_vxi->cvirt.nr_running);
18210 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18211 + /* FIXME: what about the struct files here? */
18212 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18213 + /* account for the executable */
18214 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18216 + atomic_inc(&vxi->cvirt.nr_threads);
18217 + atomic_inc(&vxi->cvirt.nr_running);
18218 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18219 + /* FIXME: what about the struct files here? */
18220 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18221 + /* account for the executable */
18222 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18225 + release_vx_info(old_vxi, p);
18226 + clr_vx_info(&p->vx_info);
18228 + claim_vx_info(vxi, p);
18229 + set_vx_info(&p->vx_info, vxi);
18230 + p->xid = vxi->vx_id;
18232 + vxdprintk(VXD_CBIT(xid, 5),
18233 + "moved task %p into vxi:%p[#%d]",
18234 + p, vxi, vxi->vx_id);
18236 + // vx_mask_cap_bset(vxi, p);
18239 + /* hack for *spaces to provide compatibility */
18241 + struct nsproxy *old_nsp, *new_nsp;
18243 + ret = unshare_nsproxy_namespaces(
18244 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18249 + old_nsp = xchg(&p->nsproxy, new_nsp);
18250 + vx_set_space(vxi,
18251 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18252 + put_nsproxy(old_nsp);
18256 + put_vx_info(old_vxi);
18260 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18262 + struct task_struct *old_reaper;
18267 + vxdprintk(VXD_CBIT(xid, 6),
18268 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18269 + vxi, vxi->vx_id, p, p->xid, p->pid);
18271 + old_reaper = vxi->vx_reaper;
18272 + if (old_reaper == p)
18275 + /* set new child reaper */
18276 + get_task_struct(p);
18277 + vxi->vx_reaper = p;
18278 + put_task_struct(old_reaper);
18282 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18287 + vxdprintk(VXD_CBIT(xid, 6),
18288 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18289 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18291 + vxi->vx_flags &= ~VXF_STATE_INIT;
18292 + // vxi->vx_initpid = p->tgid;
18293 + vxi->vx_initpid = p->pid;
18297 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18299 + vxdprintk(VXD_CBIT(xid, 6),
18300 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18301 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18303 + vxi->exit_code = code;
18304 + vxi->vx_initpid = 0;
18308 +void vx_set_persistent(struct vx_info *vxi)
18310 + vxdprintk(VXD_CBIT(xid, 6),
18311 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18313 + get_vx_info(vxi);
18314 + claim_vx_info(vxi, NULL);
18317 +void vx_clear_persistent(struct vx_info *vxi)
18319 + vxdprintk(VXD_CBIT(xid, 6),
18320 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18322 + release_vx_info(vxi, NULL);
18323 + put_vx_info(vxi);
18326 +void vx_update_persistent(struct vx_info *vxi)
18328 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18329 + vx_set_persistent(vxi);
18331 + vx_clear_persistent(vxi);
18335 +/* task must be current or locked */
18337 +void exit_vx_info(struct task_struct *p, int code)
18339 + struct vx_info *vxi = p->vx_info;
18342 + atomic_dec(&vxi->cvirt.nr_threads);
18345 + vxi->exit_code = code;
18346 + release_vx_info(vxi, p);
18350 +void exit_vx_info_early(struct task_struct *p, int code)
18352 + struct vx_info *vxi = p->vx_info;
18355 + if (vxi->vx_initpid == p->pid)
18356 + vx_exit_init(vxi, p, code);
18357 + if (vxi->vx_reaper == p)
18358 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
18363 +/* vserver syscall commands below here */
18365 +/* taks xid and vx_info functions */
18367 +#include <asm/uaccess.h>
18370 +int vc_task_xid(uint32_t id)
18375 + struct task_struct *tsk;
18377 + read_lock(&tasklist_lock);
18378 + tsk = find_task_by_real_pid(id);
18379 + xid = (tsk) ? tsk->xid : -ESRCH;
18380 + read_unlock(&tasklist_lock);
18382 + xid = vx_current_xid();
18387 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18389 + struct vcmd_vx_info_v0 vc_data;
18391 + vc_data.xid = vxi->vx_id;
18392 + vc_data.initpid = vxi->vx_initpid;
18394 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18400 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18402 + struct vcmd_ctx_stat_v0 vc_data;
18404 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18405 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
18407 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18413 +/* context functions */
18415 +int vc_ctx_create(uint32_t xid, void __user *data)
18417 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18418 + struct vx_info *new_vxi;
18421 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18424 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
18427 + new_vxi = __create_vx_info(xid);
18428 + if (IS_ERR(new_vxi))
18429 + return PTR_ERR(new_vxi);
18431 + /* initial flags */
18432 + new_vxi->vx_flags = vc_data.flagword;
18435 + if (vs_state_change(new_vxi, VSC_STARTUP))
18438 + ret = vx_migrate_task(current, new_vxi, (!data));
18442 + /* return context id on success */
18443 + ret = new_vxi->vx_id;
18445 + /* get a reference for persistent contexts */
18446 + if ((vc_data.flagword & VXF_PERSISTENT))
18447 + vx_set_persistent(new_vxi);
18449 + release_vx_info(new_vxi, NULL);
18450 + put_vx_info(new_vxi);
18455 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18457 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18460 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18463 + ret = vx_migrate_task(current, vxi, 0);
18466 + if (vc_data.flagword & VXM_SET_INIT)
18467 + ret = vx_set_init(vxi, current);
18470 + if (vc_data.flagword & VXM_SET_REAPER)
18471 + ret = vx_set_reaper(vxi, current);
18476 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18478 + struct vcmd_ctx_flags_v0 vc_data;
18480 + vc_data.flagword = vxi->vx_flags;
18482 + /* special STATE flag handling */
18483 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18485 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18490 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18492 + struct vcmd_ctx_flags_v0 vc_data;
18493 + uint64_t mask, trigger;
18495 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18498 + /* special STATE flag handling */
18499 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18500 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18502 + if (vxi == current_vx_info()) {
18503 + /* if (trigger & VXF_STATE_SETUP)
18504 + vx_mask_cap_bset(vxi, current); */
18505 + if (trigger & VXF_STATE_INIT) {
18508 + ret = vx_set_init(vxi, current);
18511 + ret = vx_set_reaper(vxi, current);
18517 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18518 + vc_data.flagword, mask);
18519 + if (trigger & VXF_PERSISTENT)
18520 + vx_update_persistent(vxi);
18526 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
18528 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
18530 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
18534 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
18536 + kernel_cap_t c = __cap_empty_set;
18538 + c.cap[0] = v & 0xFFFFFFFF;
18539 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
18541 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
18546 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18549 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
18551 + *ccaps = vxi->vx_ccaps;
18556 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18558 + struct vcmd_ctx_caps_v1 vc_data;
18561 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18564 + vc_data.cmask = ~0ULL;
18566 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18571 +static int do_set_caps(struct vx_info *vxi,
18572 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18574 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18577 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18578 + bcaps, bmask, ccaps, cmask);
18580 + vxi->vx_bcaps = cap_t_from_caps(
18581 + vs_mask_flags(bcold, bcaps, bmask));
18582 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18587 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18589 + struct vcmd_ctx_caps_v1 vc_data;
18591 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18594 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18597 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18599 + struct vcmd_bcaps vc_data;
18602 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18605 + vc_data.bmask = ~0ULL;
18607 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18612 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18614 + struct vcmd_bcaps vc_data;
18616 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18619 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18623 +int vc_get_umask(struct vx_info *vxi, void __user *data)
18625 + struct vcmd_umask vc_data;
18627 + vc_data.umask = vxi->vx_umask;
18628 + vc_data.mask = ~0ULL;
18630 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18635 +int vc_set_umask(struct vx_info *vxi, void __user *data)
18637 + struct vcmd_umask vc_data;
18639 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18642 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
18643 + vc_data.umask, vc_data.mask);
18648 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18650 + struct vcmd_badness_v0 vc_data;
18652 + vc_data.bias = vxi->vx_badness_bias;
18654 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18659 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18661 + struct vcmd_badness_v0 vc_data;
18663 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18666 + vxi->vx_badness_bias = vc_data.bias;
18670 +#include <linux/module.h>
18672 +EXPORT_SYMBOL_GPL(free_vx_info);
18674 diff -NurpP --minimal linux-2.6.35/kernel/vserver/cvirt.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cvirt.c
18675 --- linux-2.6.35/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
18676 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cvirt.c 2010-08-02 17:05:06.000000000 +0200
18679 + * linux/kernel/vserver/cvirt.c
18681 + * Virtual Server: Context Virtualization
18683 + * Copyright (C) 2004-2007 Herbert Pötzl
18685 + * V0.01 broken out from limit.c
18686 + * V0.02 added utsname stuff
18687 + * V0.03 changed vcmds to vxi arg
18691 +#include <linux/types.h>
18692 +#include <linux/utsname.h>
18693 +#include <linux/vs_cvirt.h>
18694 +#include <linux/vserver/switch.h>
18695 +#include <linux/vserver/cvirt_cmd.h>
18697 +#include <asm/uaccess.h>
18700 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18702 + struct vx_info *vxi = current_vx_info();
18704 + set_normalized_timespec(uptime,
18705 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18706 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18709 + set_normalized_timespec(idle,
18710 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18711 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18715 +uint64_t vx_idle_jiffies(void)
18717 + return init_task.utime + init_task.stime;
18722 +static inline uint32_t __update_loadavg(uint32_t load,
18723 + int wsize, int delta, int n)
18725 + unsigned long long calc, prev;
18727 + /* just set it to n */
18728 + if (unlikely(delta >= wsize))
18729 + return (n << FSHIFT);
18731 + calc = delta * n;
18733 + prev = (wsize - delta);
18736 + do_div(calc, wsize);
18741 +void vx_update_load(struct vx_info *vxi)
18743 + uint32_t now, last, delta;
18744 + unsigned int nr_running, nr_uninterruptible;
18745 + unsigned int total;
18746 + unsigned long flags;
18748 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18751 + last = vxi->cvirt.load_last;
18752 + delta = now - last;
18754 + if (delta < 5*HZ)
18757 + nr_running = atomic_read(&vxi->cvirt.nr_running);
18758 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18759 + total = nr_running + nr_uninterruptible;
18761 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18762 + 60*HZ, delta, total);
18763 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18764 + 5*60*HZ, delta, total);
18765 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18766 + 15*60*HZ, delta, total);
18768 + vxi->cvirt.load_last = now;
18770 + atomic_inc(&vxi->cvirt.load_updates);
18771 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
18776 + * Commands to do_syslog:
18778 + * 0 -- Close the log. Currently a NOP.
18779 + * 1 -- Open the log. Currently a NOP.
18780 + * 2 -- Read from the log.
18781 + * 3 -- Read all messages remaining in the ring buffer.
18782 + * 4 -- Read and clear all messages remaining in the ring buffer
18783 + * 5 -- Clear ring buffer.
18784 + * 6 -- Disable printk's to console
18785 + * 7 -- Enable printk's to console
18786 + * 8 -- Set level of messages printed to console
18787 + * 9 -- Return number of unread characters in the log buffer
18788 + * 10 -- Return size of the log buffer
18790 +int vx_do_syslog(int type, char __user *buf, int len)
18793 + int do_clear = 0;
18794 + struct vx_info *vxi = current_vx_info();
18795 + struct _vx_syslog *log;
18799 + log = &vxi->cvirt.syslog;
18802 + case 0: /* Close log */
18803 + case 1: /* Open log */
18805 + case 2: /* Read from log */
18806 + error = wait_event_interruptible(log->log_wait,
18807 + (log->log_start - log->log_end));
18810 + spin_lock_irq(&log->logbuf_lock);
18811 + spin_unlock_irq(&log->logbuf_lock);
18813 + case 4: /* Read/clear last kernel messages */
18815 + /* fall through */
18816 + case 3: /* Read last kernel messages */
18819 + case 5: /* Clear ring buffer */
18822 + case 6: /* Disable logging to console */
18823 + case 7: /* Enable logging to console */
18824 + case 8: /* Set level of messages printed to console */
18827 + case 9: /* Number of chars in the log buffer */
18829 + case 10: /* Size of the log buffer */
18839 +/* virtual host info names */
18841 +static char *vx_vhi_name(struct vx_info *vxi, int id)
18843 + struct nsproxy *nsproxy;
18844 + struct uts_namespace *uts;
18846 + if (id == VHIN_CONTEXT)
18847 + return vxi->vx_name;
18849 + nsproxy = vxi->vx_nsproxy[0];
18853 + uts = nsproxy->uts_ns;
18858 + case VHIN_SYSNAME:
18859 + return uts->name.sysname;
18860 + case VHIN_NODENAME:
18861 + return uts->name.nodename;
18862 + case VHIN_RELEASE:
18863 + return uts->name.release;
18864 + case VHIN_VERSION:
18865 + return uts->name.version;
18866 + case VHIN_MACHINE:
18867 + return uts->name.machine;
18868 + case VHIN_DOMAINNAME:
18869 + return uts->name.domainname;
18876 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
18878 + struct vcmd_vhi_name_v0 vc_data;
18881 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18884 + name = vx_vhi_name(vxi, vc_data.field);
18888 + memcpy(name, vc_data.name, 65);
18892 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
18894 + struct vcmd_vhi_name_v0 vc_data;
18897 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18900 + name = vx_vhi_name(vxi, vc_data.field);
18904 + memcpy(vc_data.name, name, 65);
18905 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18911 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
18913 + struct vcmd_virt_stat_v0 vc_data;
18914 + struct _vx_cvirt *cvirt = &vxi->cvirt;
18915 + struct timespec uptime;
18917 + do_posix_clock_monotonic_gettime(&uptime);
18918 + set_normalized_timespec(&uptime,
18919 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
18920 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
18922 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
18923 + vc_data.uptime = timespec_to_ns(&uptime);
18924 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
18925 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
18926 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
18927 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
18928 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
18929 + vc_data.load[0] = cvirt->load[0];
18930 + vc_data.load[1] = cvirt->load[1];
18931 + vc_data.load[2] = cvirt->load[2];
18933 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18939 +#ifdef CONFIG_VSERVER_VTIME
18941 +/* virtualized time base */
18943 +void vx_gettimeofday(struct timeval *tv)
18945 + struct vx_info *vxi;
18947 + do_gettimeofday(tv);
18948 + if (!vx_flags(VXF_VIRT_TIME, 0))
18951 + vxi = current_vx_info();
18952 + tv->tv_sec += vxi->cvirt.bias_tv.tv_sec;
18953 + tv->tv_usec += vxi->cvirt.bias_tv.tv_usec;
18955 + if (tv->tv_usec >= USEC_PER_SEC) {
18957 + tv->tv_usec -= USEC_PER_SEC;
18958 + } else if (tv->tv_usec < 0) {
18960 + tv->tv_usec += USEC_PER_SEC;
18964 +int vx_settimeofday(struct timespec *ts)
18966 + struct timeval tv;
18967 + struct vx_info *vxi;
18969 + if (!vx_flags(VXF_VIRT_TIME, 0))
18970 + return do_settimeofday(ts);
18972 + do_gettimeofday(&tv);
18973 + vxi = current_vx_info();
18974 + vxi->cvirt.bias_tv.tv_sec = ts->tv_sec - tv.tv_sec;
18975 + vxi->cvirt.bias_tv.tv_usec =
18976 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
18982 diff -NurpP --minimal linux-2.6.35/kernel/vserver/cvirt_init.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cvirt_init.h
18983 --- linux-2.6.35/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
18984 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cvirt_init.h 2010-08-02 17:05:06.000000000 +0200
18988 +extern uint64_t vx_idle_jiffies(void);
18990 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
18992 + uint64_t idle_jiffies = vx_idle_jiffies();
18993 + uint64_t nsuptime;
18995 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
18996 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
18997 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
18998 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
18999 + cvirt->bias_tv.tv_sec = 0;
19000 + cvirt->bias_tv.tv_usec = 0;
19002 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19003 + atomic_set(&cvirt->nr_threads, 0);
19004 + atomic_set(&cvirt->nr_running, 0);
19005 + atomic_set(&cvirt->nr_uninterruptible, 0);
19006 + atomic_set(&cvirt->nr_onhold, 0);
19008 + spin_lock_init(&cvirt->load_lock);
19009 + cvirt->load_last = jiffies;
19010 + atomic_set(&cvirt->load_updates, 0);
19011 + cvirt->load[0] = 0;
19012 + cvirt->load[1] = 0;
19013 + cvirt->load[2] = 0;
19014 + atomic_set(&cvirt->total_forks, 0);
19016 + spin_lock_init(&cvirt->syslog.logbuf_lock);
19017 + init_waitqueue_head(&cvirt->syslog.log_wait);
19018 + cvirt->syslog.log_start = 0;
19019 + cvirt->syslog.log_end = 0;
19020 + cvirt->syslog.con_start = 0;
19021 + cvirt->syslog.logged_chars = 0;
19025 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19027 + // cvirt_pc->cpustat = { 0 };
19030 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19034 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19035 + "!!! cvirt: %p[nr_threads] = %d on exit.",
19037 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19038 + "!!! cvirt: %p[nr_running] = %d on exit.",
19040 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19041 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19043 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19044 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
19050 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19055 diff -NurpP --minimal linux-2.6.35/kernel/vserver/cvirt_proc.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cvirt_proc.h
19056 --- linux-2.6.35/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
19057 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cvirt_proc.h 2010-08-02 17:05:06.000000000 +0200
19059 +#ifndef _VX_CVIRT_PROC_H
19060 +#define _VX_CVIRT_PROC_H
19062 +#include <linux/nsproxy.h>
19063 +#include <linux/mnt_namespace.h>
19064 +#include <linux/ipc_namespace.h>
19065 +#include <linux/utsname.h>
19066 +#include <linux/ipc.h>
19070 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19072 + struct mnt_namespace *ns;
19073 + struct uts_namespace *uts;
19074 + struct ipc_namespace *ipc;
19075 + struct path path;
19076 + char *pstr, *root;
19082 + length += sprintf(buffer + length,
19083 + "NSProxy:\t%p [%p,%p,%p]\n",
19084 + nsproxy, nsproxy->mnt_ns,
19085 + nsproxy->uts_ns, nsproxy->ipc_ns);
19087 + ns = nsproxy->mnt_ns;
19091 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
19095 + path.mnt = ns->root;
19096 + path.dentry = ns->root->mnt_root;
19097 + root = d_path(&path, pstr, PATH_MAX - 2);
19098 + length += sprintf(buffer + length,
19099 + "Namespace:\t%p [#%u]\n"
19100 + "RootPath:\t%s\n",
19101 + ns, atomic_read(&ns->count),
19106 + uts = nsproxy->uts_ns;
19110 + length += sprintf(buffer + length,
19111 + "SysName:\t%.*s\n"
19112 + "NodeName:\t%.*s\n"
19113 + "Release:\t%.*s\n"
19114 + "Version:\t%.*s\n"
19115 + "Machine:\t%.*s\n"
19116 + "DomainName:\t%.*s\n",
19117 + __NEW_UTS_LEN, uts->name.sysname,
19118 + __NEW_UTS_LEN, uts->name.nodename,
19119 + __NEW_UTS_LEN, uts->name.release,
19120 + __NEW_UTS_LEN, uts->name.version,
19121 + __NEW_UTS_LEN, uts->name.machine,
19122 + __NEW_UTS_LEN, uts->name.domainname);
19125 + ipc = nsproxy->ipc_ns;
19129 + length += sprintf(buffer + length,
19130 + "SEMS:\t\t%d %d %d %d %d\n"
19131 + "MSG:\t\t%d %d %d\n"
19132 + "SHM:\t\t%lu %lu %d %d\n",
19133 + ipc->sem_ctls[0], ipc->sem_ctls[1],
19134 + ipc->sem_ctls[2], ipc->sem_ctls[3],
19136 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19137 + (unsigned long)ipc->shm_ctlmax,
19138 + (unsigned long)ipc->shm_ctlall,
19139 + ipc->shm_ctlmni, ipc->shm_tot);
19146 +#include <linux/sched.h>
19148 +#define LOAD_INT(x) ((x) >> FSHIFT)
19149 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19152 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19157 + length += sprintf(buffer + length,
19158 + "BiasUptime:\t%lu.%02lu\n",
19159 + (unsigned long)cvirt->bias_uptime.tv_sec,
19160 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19162 + a = cvirt->load[0] + (FIXED_1 / 200);
19163 + b = cvirt->load[1] + (FIXED_1 / 200);
19164 + c = cvirt->load[2] + (FIXED_1 / 200);
19165 + length += sprintf(buffer + length,
19166 + "nr_threads:\t%d\n"
19167 + "nr_running:\t%d\n"
19168 + "nr_unintr:\t%d\n"
19169 + "nr_onhold:\t%d\n"
19170 + "load_updates:\t%d\n"
19171 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19172 + "total_forks:\t%d\n",
19173 + atomic_read(&cvirt->nr_threads),
19174 + atomic_read(&cvirt->nr_running),
19175 + atomic_read(&cvirt->nr_uninterruptible),
19176 + atomic_read(&cvirt->nr_onhold),
19177 + atomic_read(&cvirt->load_updates),
19178 + LOAD_INT(a), LOAD_FRAC(a),
19179 + LOAD_INT(b), LOAD_FRAC(b),
19180 + LOAD_INT(c), LOAD_FRAC(c),
19181 + atomic_read(&cvirt->total_forks));
19186 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19187 + char *buffer, int cpu)
19193 +#endif /* _VX_CVIRT_PROC_H */
19194 diff -NurpP --minimal linux-2.6.35/kernel/vserver/debug.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/debug.c
19195 --- linux-2.6.35/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
19196 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/debug.c 2010-08-02 17:05:06.000000000 +0200
19199 + * kernel/vserver/debug.c
19201 + * Copyright (C) 2005-2007 Herbert Pötzl
19203 + * V0.01 vx_info dump support
19207 +#include <linux/module.h>
19209 +#include <linux/vserver/context.h>
19212 +void dump_vx_info(struct vx_info *vxi, int level)
19214 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19215 + atomic_read(&vxi->vx_usecnt),
19216 + atomic_read(&vxi->vx_tasks),
19219 + __dump_vx_limit(&vxi->limit);
19220 + __dump_vx_sched(&vxi->sched);
19221 + __dump_vx_cvirt(&vxi->cvirt);
19222 + __dump_vx_cacct(&vxi->cacct);
19228 +EXPORT_SYMBOL_GPL(dump_vx_info);
19230 diff -NurpP --minimal linux-2.6.35/kernel/vserver/device.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/device.c
19231 --- linux-2.6.35/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
19232 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/device.c 2010-08-02 17:05:06.000000000 +0200
19235 + * linux/kernel/vserver/device.c
19237 + * Linux-VServer: Device Support
19239 + * Copyright (C) 2006 Herbert Pötzl
19240 + * Copyright (C) 2007 Daniel Hokka Zakrisson
19242 + * V0.01 device mapping basics
19243 + * V0.02 added defaults
19247 +#include <linux/slab.h>
19248 +#include <linux/rcupdate.h>
19249 +#include <linux/fs.h>
19250 +#include <linux/namei.h>
19251 +#include <linux/hash.h>
19253 +#include <asm/errno.h>
19254 +#include <asm/uaccess.h>
19255 +#include <linux/vserver/base.h>
19256 +#include <linux/vserver/debug.h>
19257 +#include <linux/vserver/context.h>
19258 +#include <linux/vserver/device.h>
19259 +#include <linux/vserver/device_cmd.h>
19262 +#define DMAP_HASH_BITS 4
19265 +struct vs_mapping {
19267 + struct hlist_node hlist;
19268 + struct list_head list;
19270 +#define dm_hlist u.hlist
19271 +#define dm_list u.list
19274 + struct vx_dmap_target target;
19278 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19280 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
19282 +static struct vx_dmap_target dmap_defaults[2] = {
19283 + { .flags = DATTR_OPEN },
19284 + { .flags = DATTR_OPEN },
19288 +struct kmem_cache *dmap_cachep __read_mostly;
19290 +int __init dmap_cache_init(void)
19292 + dmap_cachep = kmem_cache_create("dmap_cache",
19293 + sizeof(struct vs_mapping), 0,
19294 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19298 +__initcall(dmap_cache_init);
19301 +static inline unsigned int __hashval(dev_t dev, int bits)
19303 + return hash_long((unsigned long)dev, bits);
19307 +/* __hash_mapping()
19308 + * add the mapping to the hash table
19310 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19312 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19313 + struct hlist_head *head, *hash = dmap_main_hash;
19314 + int device = vdm->device;
19316 + spin_lock(hash_lock);
19317 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19318 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19320 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
19321 + hlist_add_head(&vdm->dm_hlist, head);
19322 + spin_unlock(hash_lock);
19326 +static inline int __mode_to_default(umode_t mode)
19339 +/* __set_default()
19342 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19343 + struct vx_dmap_target *vdmt)
19345 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19346 + spin_lock(hash_lock);
19349 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19351 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
19354 + spin_unlock(hash_lock);
19356 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19357 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19361 +/* __remove_default()
19362 + * remove a default
19364 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19366 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19367 + spin_lock(hash_lock);
19370 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19371 + else /* remove == reset */
19372 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19374 + spin_unlock(hash_lock);
19379 +/* __find_mapping()
19380 + * find a mapping in the hash table
19382 + * caller must hold hash_lock
19384 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19385 + struct vs_mapping **local, struct vs_mapping **global)
19387 + struct hlist_head *hash = dmap_main_hash;
19388 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19389 + struct hlist_node *pos;
19390 + struct vs_mapping *vdm;
19396 + hlist_for_each(pos, head) {
19397 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19399 + if ((vdm->device == device) &&
19400 + !((vdm->target.flags ^ mode) & S_IFMT)) {
19401 + if (vdm->xid == xid) {
19404 + } else if (global && vdm->xid == 0)
19409 + if (global && *global)
19416 +/* __lookup_mapping()
19417 + * find a mapping and store the result in target and flags
19419 +static inline int __lookup_mapping(struct vx_info *vxi,
19420 + dev_t device, dev_t *target, int *flags, umode_t mode)
19422 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19423 + struct vs_mapping *vdm, *global;
19424 + struct vx_dmap_target *vdmt;
19426 + xid_t xid = vxi->vx_id;
19429 + spin_lock(hash_lock);
19430 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19432 + vdmt = &vdm->target;
19436 + index = __mode_to_default(mode);
19437 + if (vxi && vxi->dmap.targets[index].flags) {
19439 + vdmt = &vxi->dmap.targets[index];
19440 + } else if (global) {
19442 + vdmt = &global->target;
19446 + vdmt = &dmap_defaults[index];
19450 + if (target && (vdmt->flags & DATTR_REMAP))
19451 + *target = vdmt->target;
19453 + *target = device;
19455 + *flags = vdmt->flags;
19457 + spin_unlock(hash_lock);
19463 +/* __remove_mapping()
19464 + * remove a mapping from the hash table
19466 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19469 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19470 + struct vs_mapping *vdm = NULL;
19473 + spin_lock(hash_lock);
19475 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19477 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19478 + vxi, vxi ? vxi->vx_id : 0, device, mode);
19481 + hlist_del(&vdm->dm_hlist);
19484 + spin_unlock(hash_lock);
19486 + kmem_cache_free(dmap_cachep, vdm);
19492 +int vs_map_device(struct vx_info *vxi,
19493 + dev_t device, dev_t *target, umode_t mode)
19495 + int ret, flags = DATTR_MASK;
19499 + *target = device;
19502 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
19503 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
19504 + device, target ? *target : 0, flags, mode, ret);
19506 + return (flags & DATTR_MASK);
19511 +static int do_set_mapping(struct vx_info *vxi,
19512 + dev_t device, dev_t target, int flags, umode_t mode)
19515 + struct vs_mapping *new;
19517 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
19521 + INIT_HLIST_NODE(&new->dm_hlist);
19522 + new->device = device;
19523 + new->target.target = target;
19524 + new->target.flags = flags | mode;
19525 + new->xid = (vxi ? vxi->vx_id : 0);
19527 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
19528 + __hash_mapping(vxi, new);
19530 + struct vx_dmap_target new = {
19531 + .target = target,
19532 + .flags = flags | mode,
19534 + __set_default(vxi, mode, &new);
19540 +static int do_unset_mapping(struct vx_info *vxi,
19541 + dev_t device, dev_t target, int flags, umode_t mode)
19543 + int ret = -EINVAL;
19546 + ret = __remove_mapping(vxi, device, mode);
19550 + ret = __remove_default(vxi, mode);
19560 +static inline int __user_device(const char __user *name, dev_t *dev,
19563 + struct nameidata nd;
19570 + ret = user_lpath(name, &nd.path);
19573 + if (nd.path.dentry->d_inode) {
19574 + *dev = nd.path.dentry->d_inode->i_rdev;
19575 + *mode = nd.path.dentry->d_inode->i_mode;
19577 + path_put(&nd.path);
19581 +static inline int __mapping_mode(dev_t device, dev_t target,
19582 + umode_t device_mode, umode_t target_mode, umode_t *mode)
19585 + *mode = device_mode & S_IFMT;
19587 + *mode = target_mode & S_IFMT;
19591 + /* if both given, device and target mode have to match */
19592 + if (device && target &&
19593 + ((device_mode ^ target_mode) & S_IFMT))
19599 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
19600 + const char __user *target_path, int flags, int set)
19602 + dev_t device = ~0, target = ~0;
19603 + umode_t device_mode = 0, target_mode = 0, mode;
19606 + ret = __user_device(device_path, &device, &device_mode);
19609 + ret = __user_device(target_path, &target, &target_mode);
19613 + ret = __mapping_mode(device, target,
19614 + device_mode, target_mode, &mode);
19619 + return do_set_mapping(vxi, device, target,
19622 + return do_unset_mapping(vxi, device, target,
19627 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19629 + struct vcmd_set_mapping_v0 vc_data;
19631 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19634 + return do_mapping(vxi, vc_data.device, vc_data.target,
19635 + vc_data.flags, 1);
19638 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19640 + struct vcmd_set_mapping_v0 vc_data;
19642 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19645 + return do_mapping(vxi, vc_data.device, vc_data.target,
19646 + vc_data.flags, 0);
19650 +#ifdef CONFIG_COMPAT
19652 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19654 + struct vcmd_set_mapping_v0_x32 vc_data;
19656 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19659 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19660 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19663 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19665 + struct vcmd_set_mapping_v0_x32 vc_data;
19667 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19670 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19671 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19674 +#endif /* CONFIG_COMPAT */
19677 diff -NurpP --minimal linux-2.6.35/kernel/vserver/dlimit.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/dlimit.c
19678 --- linux-2.6.35/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
19679 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/dlimit.c 2010-08-02 17:05:06.000000000 +0200
19682 + * linux/kernel/vserver/dlimit.c
19684 + * Virtual Server: Context Disk Limits
19686 + * Copyright (C) 2004-2009 Herbert Pötzl
19688 + * V0.01 initial version
19689 + * V0.02 compat32 splitup
19690 + * V0.03 extended interface
19694 +#include <linux/statfs.h>
19695 +#include <linux/sched.h>
19696 +#include <linux/namei.h>
19697 +#include <linux/vs_tag.h>
19698 +#include <linux/vs_dlimit.h>
19699 +#include <linux/vserver/dlimit_cmd.h>
19700 +#include <linux/slab.h>
19701 +// #include <linux/gfp.h>
19703 +#include <asm/uaccess.h>
19705 +/* __alloc_dl_info()
19707 + * allocate an initialized dl_info struct
19708 + * doesn't make it visible (hash) */
19710 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19712 + struct dl_info *new = NULL;
19714 + vxdprintk(VXD_CBIT(dlim, 5),
19715 + "alloc_dl_info(%p,%d)*", sb, tag);
19717 + /* would this benefit from a slab cache? */
19718 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19722 + memset(new, 0, sizeof(struct dl_info));
19723 + new->dl_tag = tag;
19725 + INIT_RCU_HEAD(&new->dl_rcu);
19726 + INIT_HLIST_NODE(&new->dl_hlist);
19727 + spin_lock_init(&new->dl_lock);
19728 + atomic_set(&new->dl_refcnt, 0);
19729 + atomic_set(&new->dl_usecnt, 0);
19731 + /* rest of init goes here */
19733 + vxdprintk(VXD_CBIT(dlim, 4),
19734 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19738 +/* __dealloc_dl_info()
19740 + * final disposal of dl_info */
19742 +static void __dealloc_dl_info(struct dl_info *dli)
19744 + vxdprintk(VXD_CBIT(dlim, 4),
19745 + "dealloc_dl_info(%p)", dli);
19747 + dli->dl_hlist.next = LIST_POISON1;
19748 + dli->dl_tag = -1;
19751 + BUG_ON(atomic_read(&dli->dl_usecnt));
19752 + BUG_ON(atomic_read(&dli->dl_refcnt));
19758 +/* hash table for dl_info hash */
19760 +#define DL_HASH_SIZE 13
19762 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19764 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19767 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19769 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19774 +/* __hash_dl_info()
19776 + * add the dli to the global hash table
19777 + * requires the hash_lock to be held */
19779 +static inline void __hash_dl_info(struct dl_info *dli)
19781 + struct hlist_head *head;
19783 + vxdprintk(VXD_CBIT(dlim, 6),
19784 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19785 + get_dl_info(dli);
19786 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19787 + hlist_add_head_rcu(&dli->dl_hlist, head);
19790 +/* __unhash_dl_info()
19792 + * remove the dli from the global hash table
19793 + * requires the hash_lock to be held */
19795 +static inline void __unhash_dl_info(struct dl_info *dli)
19797 + vxdprintk(VXD_CBIT(dlim, 6),
19798 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19799 + hlist_del_rcu(&dli->dl_hlist);
19800 + put_dl_info(dli);
19804 +/* __lookup_dl_info()
19806 + * requires the rcu_read_lock()
19807 + * doesn't increment the dl_refcnt */
19809 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19811 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19812 + struct hlist_node *pos;
19813 + struct dl_info *dli;
19815 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19817 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
19825 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19827 + struct dl_info *dli;
19830 + dli = get_dl_info(__lookup_dl_info(sb, tag));
19831 + vxdprintk(VXD_CBIT(dlim, 7),
19832 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19833 + rcu_read_unlock();
19837 +void rcu_free_dl_info(struct rcu_head *head)
19839 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19840 + int usecnt, refcnt;
19842 + BUG_ON(!dli || !head);
19844 + usecnt = atomic_read(&dli->dl_usecnt);
19845 + BUG_ON(usecnt < 0);
19847 + refcnt = atomic_read(&dli->dl_refcnt);
19848 + BUG_ON(refcnt < 0);
19850 + vxdprintk(VXD_CBIT(dlim, 3),
19851 + "rcu_free_dl_info(%p)", dli);
19853 + __dealloc_dl_info(dli);
19855 + printk("!!! rcu didn't free\n");
19861 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
19862 + uint32_t flags, int add)
19864 + struct path path;
19867 + ret = user_lpath(name, &path);
19869 + struct super_block *sb;
19870 + struct dl_info *dli;
19873 + if (!path.dentry->d_inode)
19874 + goto out_release;
19875 + if (!(sb = path.dentry->d_inode->i_sb))
19876 + goto out_release;
19879 + dli = __alloc_dl_info(sb, id);
19880 + spin_lock(&dl_info_hash_lock);
19883 + if (__lookup_dl_info(sb, id))
19885 + __hash_dl_info(dli);
19888 + spin_lock(&dl_info_hash_lock);
19889 + dli = __lookup_dl_info(sb, id);
19894 + __unhash_dl_info(dli);
19898 + spin_unlock(&dl_info_hash_lock);
19900 + __dealloc_dl_info(dli);
19907 +int vc_add_dlimit(uint32_t id, void __user *data)
19909 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19911 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19914 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
19917 +int vc_rem_dlimit(uint32_t id, void __user *data)
19919 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19921 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19924 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
19927 +#ifdef CONFIG_COMPAT
19929 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
19931 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19933 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19936 + return do_addrem_dlimit(id,
19937 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
19940 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
19942 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19944 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19947 + return do_addrem_dlimit(id,
19948 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
19951 +#endif /* CONFIG_COMPAT */
19955 +int do_set_dlimit(uint32_t id, const char __user *name,
19956 + uint32_t space_used, uint32_t space_total,
19957 + uint32_t inodes_used, uint32_t inodes_total,
19958 + uint32_t reserved, uint32_t flags)
19960 + struct path path;
19963 + ret = user_lpath(name, &path);
19965 + struct super_block *sb;
19966 + struct dl_info *dli;
19969 + if (!path.dentry->d_inode)
19970 + goto out_release;
19971 + if (!(sb = path.dentry->d_inode->i_sb))
19972 + goto out_release;
19974 + /* sanity checks */
19975 + if ((reserved != CDLIM_KEEP &&
19976 + reserved > 100) ||
19977 + (inodes_used != CDLIM_KEEP &&
19978 + inodes_used > inodes_total) ||
19979 + (space_used != CDLIM_KEEP &&
19980 + space_used > space_total))
19981 + goto out_release;
19984 + dli = locate_dl_info(sb, id);
19986 + goto out_release;
19988 + spin_lock(&dli->dl_lock);
19990 + if (inodes_used != CDLIM_KEEP)
19991 + dli->dl_inodes_used = inodes_used;
19992 + if (inodes_total != CDLIM_KEEP)
19993 + dli->dl_inodes_total = inodes_total;
19994 + if (space_used != CDLIM_KEEP)
19995 + dli->dl_space_used = dlimit_space_32to64(
19996 + space_used, flags, DLIMS_USED);
19998 + if (space_total == CDLIM_INFINITY)
19999 + dli->dl_space_total = DLIM_INFINITY;
20000 + else if (space_total != CDLIM_KEEP)
20001 + dli->dl_space_total = dlimit_space_32to64(
20002 + space_total, flags, DLIMS_TOTAL);
20004 + if (reserved != CDLIM_KEEP)
20005 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20007 + spin_unlock(&dli->dl_lock);
20009 + put_dl_info(dli);
20018 +int vc_set_dlimit(uint32_t id, void __user *data)
20020 + struct vcmd_ctx_dlimit_v0 vc_data;
20022 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20025 + return do_set_dlimit(id, vc_data.name,
20026 + vc_data.space_used, vc_data.space_total,
20027 + vc_data.inodes_used, vc_data.inodes_total,
20028 + vc_data.reserved, vc_data.flags);
20031 +#ifdef CONFIG_COMPAT
20033 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20035 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20037 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20040 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20041 + vc_data.space_used, vc_data.space_total,
20042 + vc_data.inodes_used, vc_data.inodes_total,
20043 + vc_data.reserved, vc_data.flags);
20046 +#endif /* CONFIG_COMPAT */
20050 +int do_get_dlimit(uint32_t id, const char __user *name,
20051 + uint32_t *space_used, uint32_t *space_total,
20052 + uint32_t *inodes_used, uint32_t *inodes_total,
20053 + uint32_t *reserved, uint32_t *flags)
20055 + struct path path;
20058 + ret = user_lpath(name, &path);
20060 + struct super_block *sb;
20061 + struct dl_info *dli;
20064 + if (!path.dentry->d_inode)
20065 + goto out_release;
20066 + if (!(sb = path.dentry->d_inode->i_sb))
20067 + goto out_release;
20070 + dli = locate_dl_info(sb, id);
20072 + goto out_release;
20074 + spin_lock(&dli->dl_lock);
20075 + *inodes_used = dli->dl_inodes_used;
20076 + *inodes_total = dli->dl_inodes_total;
20078 + *space_used = dlimit_space_64to32(
20079 + dli->dl_space_used, flags, DLIMS_USED);
20081 + if (dli->dl_space_total == DLIM_INFINITY)
20082 + *space_total = CDLIM_INFINITY;
20084 + *space_total = dlimit_space_64to32(
20085 + dli->dl_space_total, flags, DLIMS_TOTAL);
20087 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20088 + spin_unlock(&dli->dl_lock);
20090 + put_dl_info(dli);
20101 +int vc_get_dlimit(uint32_t id, void __user *data)
20103 + struct vcmd_ctx_dlimit_v0 vc_data;
20106 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20109 + ret = do_get_dlimit(id, vc_data.name,
20110 + &vc_data.space_used, &vc_data.space_total,
20111 + &vc_data.inodes_used, &vc_data.inodes_total,
20112 + &vc_data.reserved, &vc_data.flags);
20116 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20121 +#ifdef CONFIG_COMPAT
20123 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20125 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20128 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20131 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20132 + &vc_data.space_used, &vc_data.space_total,
20133 + &vc_data.inodes_used, &vc_data.inodes_total,
20134 + &vc_data.reserved, &vc_data.flags);
20138 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20143 +#endif /* CONFIG_COMPAT */
20146 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20148 + struct dl_info *dli;
20149 + __u64 blimit, bfree, bavail;
20152 + dli = locate_dl_info(sb, dx_current_tag());
20156 + spin_lock(&dli->dl_lock);
20157 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20160 + /* reduce max inodes available to limit */
20161 + if (buf->f_files > dli->dl_inodes_total)
20162 + buf->f_files = dli->dl_inodes_total;
20164 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20165 + /* reduce free inodes to min */
20166 + if (ifree < buf->f_ffree)
20167 + buf->f_ffree = ifree;
20170 + if (dli->dl_space_total == DLIM_INFINITY)
20173 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20175 + if (dli->dl_space_total < dli->dl_space_used)
20178 + bfree = (dli->dl_space_total - dli->dl_space_used)
20179 + >> sb->s_blocksize_bits;
20181 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20182 + if (bavail < dli->dl_space_used)
20185 + bavail = (bavail - dli->dl_space_used)
20186 + >> sb->s_blocksize_bits;
20188 + /* reduce max space available to limit */
20189 + if (buf->f_blocks > blimit)
20190 + buf->f_blocks = blimit;
20192 + /* reduce free space to min */
20193 + if (bfree < buf->f_bfree)
20194 + buf->f_bfree = bfree;
20196 + /* reduce avail space to min */
20197 + if (bavail < buf->f_bavail)
20198 + buf->f_bavail = bavail;
20201 + spin_unlock(&dli->dl_lock);
20202 + put_dl_info(dli);
20207 +#include <linux/module.h>
20209 +EXPORT_SYMBOL_GPL(locate_dl_info);
20210 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20212 diff -NurpP --minimal linux-2.6.35/kernel/vserver/helper.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/helper.c
20213 --- linux-2.6.35/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
20214 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/helper.c 2010-08-02 17:05:06.000000000 +0200
20217 + * linux/kernel/vserver/helper.c
20219 + * Virtual Context Support
20221 + * Copyright (C) 2004-2007 Herbert Pötzl
20223 + * V0.01 basic helper
20227 +#include <linux/kmod.h>
20228 +#include <linux/reboot.h>
20229 +#include <linux/vs_context.h>
20230 +#include <linux/vs_network.h>
20231 +#include <linux/vserver/signal.h>
20234 +char vshelper_path[255] = "/sbin/vshelper";
20237 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20241 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20242 + printk( KERN_WARNING
20243 + "%s: (%s %s) returned %s with %d\n",
20244 + name, argv[1], argv[2],
20245 + sync ? "sync" : "async", ret);
20247 + vxdprintk(VXD_CBIT(switch, 4),
20248 + "%s: (%s %s) returned %s with %d",
20249 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
20254 + * vshelper path is set via /proc/sys
20255 + * invoked by vserver sys_reboot(), with
20256 + * the following arguments
20258 + * argv [0] = vshelper_path;
20259 + * argv [1] = action: "restart", "halt", "poweroff", ...
20260 + * argv [2] = context identifier
20262 + * envp [*] = type-specific parameters
20265 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20267 + char id_buf[8], cmd_buf[16];
20268 + char uid_buf[16], pid_buf[16];
20271 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20272 + char *envp[] = {"HOME=/", "TERM=linux",
20273 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20274 + uid_buf, pid_buf, cmd_buf, 0};
20276 + if (vx_info_state(vxi, VXS_HELPER))
20278 + vxi->vx_state |= VXS_HELPER;
20280 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20282 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20283 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
20284 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20287 + case LINUX_REBOOT_CMD_RESTART:
20288 + argv[1] = "restart";
20291 + case LINUX_REBOOT_CMD_HALT:
20292 + argv[1] = "halt";
20295 + case LINUX_REBOOT_CMD_POWER_OFF:
20296 + argv[1] = "poweroff";
20299 + case LINUX_REBOOT_CMD_SW_SUSPEND:
20300 + argv[1] = "swsusp";
20303 + case LINUX_REBOOT_CMD_OOM:
20308 + vxi->vx_state &= ~VXS_HELPER;
20312 + ret = do_vshelper(vshelper_path, argv, envp, 0);
20313 + vxi->vx_state &= ~VXS_HELPER;
20314 + __wakeup_vx_info(vxi);
20315 + return (ret) ? -EPERM : 0;
20319 +long vs_reboot(unsigned int cmd, void __user *arg)
20321 + struct vx_info *vxi = current_vx_info();
20324 + vxdprintk(VXD_CBIT(misc, 5),
20325 + "vs_reboot(%p[#%d],%u)",
20326 + vxi, vxi ? vxi->vx_id : 0, cmd);
20328 + ret = vs_reboot_helper(vxi, cmd, arg);
20332 + vxi->reboot_cmd = cmd;
20333 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20335 + case LINUX_REBOOT_CMD_RESTART:
20336 + case LINUX_REBOOT_CMD_HALT:
20337 + case LINUX_REBOOT_CMD_POWER_OFF:
20338 + vx_info_kill(vxi, 0, SIGKILL);
20339 + vx_info_kill(vxi, 1, SIGKILL);
20347 +long vs_oom_action(unsigned int cmd)
20349 + struct vx_info *vxi = current_vx_info();
20352 + vxdprintk(VXD_CBIT(misc, 5),
20353 + "vs_oom_action(%p[#%d],%u)",
20354 + vxi, vxi ? vxi->vx_id : 0, cmd);
20356 + ret = vs_reboot_helper(vxi, cmd, NULL);
20360 + vxi->reboot_cmd = cmd;
20361 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20362 + vx_info_kill(vxi, 0, SIGKILL);
20363 + vx_info_kill(vxi, 1, SIGKILL);
20369 + * argv [0] = vshelper_path;
20370 + * argv [1] = action: "startup", "shutdown"
20371 + * argv [2] = context identifier
20373 + * envp [*] = type-specific parameters
20376 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20378 + char id_buf[8], cmd_buf[16];
20379 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20380 + char *envp[] = {"HOME=/", "TERM=linux",
20381 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20383 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20386 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20387 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20390 + case VSC_STARTUP:
20391 + argv[1] = "startup";
20393 + case VSC_SHUTDOWN:
20394 + argv[1] = "shutdown";
20400 + return do_vshelper(vshelper_path, argv, envp, 1);
20405 + * argv [0] = vshelper_path;
20406 + * argv [1] = action: "netup", "netdown"
20407 + * argv [2] = context identifier
20409 + * envp [*] = type-specific parameters
20412 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20414 + char id_buf[8], cmd_buf[16];
20415 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20416 + char *envp[] = {"HOME=/", "TERM=linux",
20417 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20419 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20422 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20423 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20427 + argv[1] = "netup";
20429 + case VSC_NETDOWN:
20430 + argv[1] = "netdown";
20436 + return do_vshelper(vshelper_path, argv, envp, 1);
20439 diff -NurpP --minimal linux-2.6.35/kernel/vserver/history.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/history.c
20440 --- linux-2.6.35/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
20441 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/history.c 2010-08-02 17:05:06.000000000 +0200
20444 + * kernel/vserver/history.c
20446 + * Virtual Context History Backtrace
20448 + * Copyright (C) 2004-2007 Herbert Pötzl
20450 + * V0.01 basic structure
20451 + * V0.02 hash/unhash and trace
20452 + * V0.03 preemption fixes
20456 +#include <linux/module.h>
20457 +#include <asm/uaccess.h>
20459 +#include <linux/vserver/context.h>
20460 +#include <linux/vserver/debug.h>
20461 +#include <linux/vserver/debug_cmd.h>
20462 +#include <linux/vserver/history.h>
20465 +#ifdef CONFIG_VSERVER_HISTORY
20466 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
20468 +#define VXH_SIZE 64
20471 +struct _vx_history {
20472 + unsigned int counter;
20474 + struct _vx_hist_entry entry[VXH_SIZE + 1];
20478 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20480 +unsigned volatile int vxh_active = 1;
20482 +static atomic_t sequence = ATOMIC_INIT(0);
20487 + * requires disabled preemption */
20489 +struct _vx_hist_entry *vxh_advance(void *loc)
20491 + unsigned int cpu = smp_processor_id();
20492 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20493 + struct _vx_hist_entry *entry;
20494 + unsigned int index;
20496 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20497 + entry = &hist->entry[index];
20499 + entry->seq = atomic_inc_return(&sequence);
20500 + entry->loc = loc;
20504 +EXPORT_SYMBOL_GPL(vxh_advance);
20507 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
20509 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
20512 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
20514 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
20515 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
20516 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
20517 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
20519 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20521 + switch (e->type) {
20522 + case VXH_THROW_OOPS:
20523 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20526 + case VXH_GET_VX_INFO:
20527 + case VXH_PUT_VX_INFO:
20528 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20530 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20531 + VXH_VXI_ARGS(e));
20534 + case VXH_INIT_VX_INFO:
20535 + case VXH_SET_VX_INFO:
20536 + case VXH_CLR_VX_INFO:
20537 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20539 + (e->type == VXH_INIT_VX_INFO) ? "init" :
20540 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20541 + VXH_VXI_ARGS(e), e->sc.data);
20544 + case VXH_CLAIM_VX_INFO:
20545 + case VXH_RELEASE_VX_INFO:
20546 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20548 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20549 + VXH_VXI_ARGS(e), e->sc.data);
20552 + case VXH_ALLOC_VX_INFO:
20553 + case VXH_DEALLOC_VX_INFO:
20554 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20556 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20557 + VXH_VXI_ARGS(e));
20560 + case VXH_HASH_VX_INFO:
20561 + case VXH_UNHASH_VX_INFO:
20562 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20564 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20565 + VXH_VXI_ARGS(e));
20568 + case VXH_LOC_VX_INFO:
20569 + case VXH_LOOKUP_VX_INFO:
20570 + case VXH_CREATE_VX_INFO:
20571 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20573 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
20574 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20575 + e->ll.arg, VXH_VXI_ARGS(e));
20580 +static void __vxh_dump_history(void)
20582 + unsigned int i, cpu;
20584 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20585 + atomic_read(&sequence), NR_CPUS);
20587 + for (i = 0; i < VXH_SIZE; i++) {
20588 + for_each_online_cpu(cpu) {
20589 + struct _vx_history *hist =
20590 + &per_cpu(vx_history_buffer, cpu);
20591 + unsigned int index = (hist->counter - i) % VXH_SIZE;
20592 + struct _vx_hist_entry *entry = &hist->entry[index];
20594 + vxh_dump_entry(entry, cpu);
20599 +void vxh_dump_history(void)
20603 + local_irq_enable();
20605 + local_irq_disable();
20607 + __vxh_dump_history();
20611 +/* vserver syscall commands below here */
20614 +int vc_dump_history(uint32_t id)
20617 + __vxh_dump_history();
20624 +int do_read_history(struct __user _vx_hist_entry *data,
20625 + int cpu, uint32_t *index, uint32_t *count)
20627 + int pos, ret = 0;
20628 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20629 + int end = hist->counter;
20630 + int start = end - VXH_SIZE + 2;
20631 + int idx = *index;
20633 + /* special case: get current pos */
20639 + /* have we lost some data? */
20643 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20644 + struct _vx_hist_entry *entry =
20645 + &hist->entry[idx % VXH_SIZE];
20647 + /* send entry to userspace */
20648 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20652 + /* save new index and count */
20655 + return ret ? ret : (*index < end);
20658 +int vc_read_history(uint32_t id, void __user *data)
20660 + struct vcmd_read_history_v0 vc_data;
20663 + if (id >= NR_CPUS)
20666 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20669 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20670 + id, &vc_data.index, &vc_data.count);
20672 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20677 +#ifdef CONFIG_COMPAT
20679 +int vc_read_history_x32(uint32_t id, void __user *data)
20681 + struct vcmd_read_history_v0_x32 vc_data;
20684 + if (id >= NR_CPUS)
20687 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20690 + ret = do_read_history((struct __user _vx_hist_entry *)
20691 + compat_ptr(vc_data.data_ptr),
20692 + id, &vc_data.index, &vc_data.count);
20694 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20699 +#endif /* CONFIG_COMPAT */
20701 diff -NurpP --minimal linux-2.6.35/kernel/vserver/inet.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/inet.c
20702 --- linux-2.6.35/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
20703 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/inet.c 2010-08-02 18:54:03.000000000 +0200
20706 +#include <linux/in.h>
20707 +#include <linux/inetdevice.h>
20708 +#include <linux/vs_inet.h>
20709 +#include <linux/vs_inet6.h>
20710 +#include <linux/vserver/debug.h>
20711 +#include <net/route.h>
20712 +#include <net/addrconf.h>
20715 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20719 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20722 + struct nx_addr_v4 *ptr;
20724 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20725 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20732 + vxdprintk(VXD_CBIT(net, 2),
20733 + "nx_v4_addr_conflict(%p,%p): %d",
20734 + nxi1, nxi2, ret);
20740 +#ifdef CONFIG_IPV6
20742 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20746 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20749 + struct nx_addr_v6 *ptr;
20751 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20752 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20759 + vxdprintk(VXD_CBIT(net, 2),
20760 + "nx_v6_addr_conflict(%p,%p): %d",
20761 + nxi1, nxi2, ret);
20768 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20770 + struct in_device *in_dev;
20771 + struct in_ifaddr **ifap;
20772 + struct in_ifaddr *ifa;
20777 + in_dev = in_dev_get(dev);
20781 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
20782 + ifap = &ifa->ifa_next) {
20783 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
20788 + in_dev_put(in_dev);
20794 +#ifdef CONFIG_IPV6
20796 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20798 + struct inet6_dev *in_dev;
20799 + struct inet6_ifaddr *ifa;
20804 + in_dev = in6_dev_get(dev);
20808 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
20809 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
20810 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
20815 + in6_dev_put(in_dev);
20822 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20828 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
20830 +#ifdef CONFIG_IPV6
20832 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
20837 + vxdprintk(VXD_CBIT(net, 3),
20838 + "dev_in_nx_info(%p,%p[#%d]) = %d",
20839 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
20843 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
20844 + struct rtable **rp, struct flowi *fl)
20849 + /* FIXME: handle lback only case */
20850 + if (!NX_IPV4(nxi))
20853 + vxdprintk(VXD_CBIT(net, 4),
20854 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
20855 + nxi, nxi ? nxi->nx_id : 0,
20856 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
20858 + /* single IP is unconditional */
20859 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
20860 + (fl->fl4_src == INADDR_ANY))
20861 + fl->fl4_src = nxi->v4.ip[0].s_addr;
20863 + if (fl->fl4_src == INADDR_ANY) {
20864 + struct nx_addr_v4 *ptr;
20865 + __be32 found = 0;
20868 + err = __ip_route_output_key(net, rp, fl);
20870 + found = (*rp)->rt_src;
20872 + vxdprintk(VXD_CBIT(net, 4),
20873 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20874 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
20875 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
20879 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
20880 + __be32 primary = ptr->ip[0].s_addr;
20881 + __be32 mask = ptr->mask.s_addr;
20882 + __be32 neta = primary & mask;
20884 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
20885 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
20886 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
20887 + NIPQUAD(mask), NIPQUAD(neta));
20888 + if ((found & mask) != neta)
20891 + fl->fl4_src = primary;
20892 + err = __ip_route_output_key(net, rp, fl);
20893 + vxdprintk(VXD_CBIT(net, 4),
20894 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20895 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
20897 + found = (*rp)->rt_src;
20899 + if (found == primary)
20903 + /* still no source ip? */
20904 + found = ipv4_is_loopback(fl->fl4_dst)
20905 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
20907 + /* assign src ip to flow */
20908 + fl->fl4_src = found;
20911 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
20915 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
20916 + if (ipv4_is_loopback(fl->fl4_dst))
20917 + fl->fl4_dst = nxi->v4_lback.s_addr;
20918 + if (ipv4_is_loopback(fl->fl4_src))
20919 + fl->fl4_src = nxi->v4_lback.s_addr;
20920 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
20921 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
20927 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
20929 diff -NurpP --minimal linux-2.6.35/kernel/vserver/init.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/init.c
20930 --- linux-2.6.35/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
20931 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/init.c 2010-08-02 17:05:06.000000000 +0200
20934 + * linux/kernel/init.c
20936 + * Virtual Server Init
20938 + * Copyright (C) 2004-2007 Herbert Pötzl
20940 + * V0.01 basic structure
20944 +#include <linux/init.h>
20946 +int vserver_register_sysctl(void);
20947 +void vserver_unregister_sysctl(void);
20950 +static int __init init_vserver(void)
20954 +#ifdef CONFIG_VSERVER_DEBUG
20955 + vserver_register_sysctl();
20961 +static void __exit exit_vserver(void)
20964 +#ifdef CONFIG_VSERVER_DEBUG
20965 + vserver_unregister_sysctl();
20970 +/* FIXME: GFP_ZONETYPES gone
20971 +long vx_slab[GFP_ZONETYPES]; */
20975 +module_init(init_vserver);
20976 +module_exit(exit_vserver);
20978 diff -NurpP --minimal linux-2.6.35/kernel/vserver/inode.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/inode.c
20979 --- linux-2.6.35/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
20980 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/inode.c 2010-08-02 17:05:06.000000000 +0200
20983 + * linux/kernel/vserver/inode.c
20985 + * Virtual Server: File System Support
20987 + * Copyright (C) 2004-2007 Herbert Pötzl
20989 + * V0.01 separated from vcontext V0.05
20990 + * V0.02 moved to tag (instead of xid)
20994 +#include <linux/tty.h>
20995 +#include <linux/proc_fs.h>
20996 +#include <linux/devpts_fs.h>
20997 +#include <linux/fs.h>
20998 +#include <linux/file.h>
20999 +#include <linux/mount.h>
21000 +#include <linux/parser.h>
21001 +#include <linux/namei.h>
21002 +#include <linux/vserver/inode.h>
21003 +#include <linux/vserver/inode_cmd.h>
21004 +#include <linux/vs_base.h>
21005 +#include <linux/vs_tag.h>
21007 +#include <asm/uaccess.h>
21010 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21012 + struct proc_dir_entry *entry;
21014 + if (!in || !in->i_sb)
21017 + *flags = IATTR_TAG
21018 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21019 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21020 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21021 + | (IS_COW(in) ? IATTR_COW : 0);
21022 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21024 + if (S_ISDIR(in->i_mode))
21025 + *mask |= IATTR_BARRIER;
21027 + if (IS_TAGGED(in)) {
21028 + *tag = in->i_tag;
21029 + *mask |= IATTR_TAG;
21032 + switch (in->i_sb->s_magic) {
21033 + case PROC_SUPER_MAGIC:
21034 + entry = PROC_I(in)->pde;
21036 + /* check for specific inodes? */
21038 + *mask |= IATTR_FLAGS;
21040 + *flags |= (entry->vx_flags & IATTR_FLAGS);
21042 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21045 + case DEVPTS_SUPER_MAGIC:
21046 + *tag = in->i_tag;
21047 + *mask |= IATTR_TAG;
21056 +int vc_get_iattr(void __user *data)
21058 + struct path path;
21059 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
21062 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21065 + ret = user_lpath(vc_data.name, &path);
21067 + ret = __vc_get_iattr(path.dentry->d_inode,
21068 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21074 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21079 +#ifdef CONFIG_COMPAT
21081 +int vc_get_iattr_x32(void __user *data)
21083 + struct path path;
21084 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
21087 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21090 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21092 + ret = __vc_get_iattr(path.dentry->d_inode,
21093 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21099 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21104 +#endif /* CONFIG_COMPAT */
21107 +int vc_fget_iattr(uint32_t fd, void __user *data)
21109 + struct file *filp;
21110 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
21113 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21117 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21120 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
21121 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21125 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21131 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21133 + struct inode *in = de->d_inode;
21134 + int error = 0, is_proc = 0, has_tag = 0;
21135 + struct iattr attr = { 0 };
21137 + if (!in || !in->i_sb)
21140 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21141 + if ((*mask & IATTR_FLAGS) && !is_proc)
21144 + has_tag = IS_TAGGED(in) ||
21145 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21146 + if ((*mask & IATTR_TAG) && !has_tag)
21149 + mutex_lock(&in->i_mutex);
21150 + if (*mask & IATTR_TAG) {
21151 + attr.ia_tag = *tag;
21152 + attr.ia_valid |= ATTR_TAG;
21155 + if (*mask & IATTR_FLAGS) {
21156 + struct proc_dir_entry *entry = PROC_I(in)->pde;
21157 + unsigned int iflags = PROC_I(in)->vx_flags;
21159 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
21160 + | (*flags & IATTR_FLAGS);
21161 + PROC_I(in)->vx_flags = iflags;
21163 + entry->vx_flags = iflags;
21166 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
21167 + IATTR_BARRIER | IATTR_COW)) {
21168 + int iflags = in->i_flags;
21169 + int vflags = in->i_vflags;
21171 + if (*mask & IATTR_IMMUTABLE) {
21172 + if (*flags & IATTR_IMMUTABLE)
21173 + iflags |= S_IMMUTABLE;
21175 + iflags &= ~S_IMMUTABLE;
21177 + if (*mask & IATTR_IXUNLINK) {
21178 + if (*flags & IATTR_IXUNLINK)
21179 + iflags |= S_IXUNLINK;
21181 + iflags &= ~S_IXUNLINK;
21183 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21184 + if (*flags & IATTR_BARRIER)
21185 + vflags |= V_BARRIER;
21187 + vflags &= ~V_BARRIER;
21189 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
21190 + if (*flags & IATTR_COW)
21193 + vflags &= ~V_COW;
21195 + if (in->i_op && in->i_op->sync_flags) {
21196 + error = in->i_op->sync_flags(in, iflags, vflags);
21202 + if (attr.ia_valid) {
21203 + if (in->i_op && in->i_op->setattr)
21204 + error = in->i_op->setattr(de, &attr);
21206 + error = inode_change_ok(in, &attr);
21208 + error = inode_setattr(in, &attr);
21213 + mutex_unlock(&in->i_mutex);
21217 +int vc_set_iattr(void __user *data)
21219 + struct path path;
21220 + struct vcmd_ctx_iattr_v1 vc_data;
21223 + if (!capable(CAP_LINUX_IMMUTABLE))
21225 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21228 + ret = user_lpath(vc_data.name, &path);
21230 + ret = __vc_set_iattr(path.dentry,
21231 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21235 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21240 +#ifdef CONFIG_COMPAT
21242 +int vc_set_iattr_x32(void __user *data)
21244 + struct path path;
21245 + struct vcmd_ctx_iattr_v1_x32 vc_data;
21248 + if (!capable(CAP_LINUX_IMMUTABLE))
21250 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21253 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21255 + ret = __vc_set_iattr(path.dentry,
21256 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21260 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21265 +#endif /* CONFIG_COMPAT */
21267 +int vc_fset_iattr(uint32_t fd, void __user *data)
21269 + struct file *filp;
21270 + struct vcmd_ctx_fiattr_v0 vc_data;
21273 + if (!capable(CAP_LINUX_IMMUTABLE))
21275 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21279 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21282 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21283 + &vc_data.flags, &vc_data.mask);
21287 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21293 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21295 +static match_table_t tokens = {
21296 + {Opt_notagcheck, "notagcheck"},
21297 +#ifdef CONFIG_PROPAGATE
21298 + {Opt_notag, "notag"},
21299 + {Opt_tag, "tag"},
21300 + {Opt_tagid, "tagid=%u"},
21306 +static void __dx_parse_remove(char *string, char *opt)
21308 + char *p = strstr(string, opt);
21312 + while (*q != '\0' && *q != ',')
21321 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21322 + unsigned long *flags)
21325 + substring_t args[MAX_OPT_ARGS];
21326 + int token, option = 0;
21327 + char *s, *p, *opts;
21331 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21336 + while ((p = strsep(&opts, ",")) != NULL) {
21337 + token = match_token(p, tokens, args);
21339 + vxdprintk(VXD_CBIT(tag, 7),
21340 + "dx_parse_tag(»%s«): %d:#%d",
21341 + p, token, option);
21344 +#ifdef CONFIG_PROPAGATE
21349 + __dx_parse_remove(s, "tag");
21350 + *mnt_flags |= MNT_TAGID;
21351 + set |= MNT_TAGID;
21355 + __dx_parse_remove(s, "notag");
21356 + *mnt_flags |= MNT_NOTAG;
21357 + set |= MNT_NOTAG;
21360 + if (tag && !match_int(args, &option))
21363 + __dx_parse_remove(s, "tagid");
21364 + *mnt_flags |= MNT_TAGID;
21365 + set |= MNT_TAGID;
21368 + case Opt_notagcheck:
21370 + __dx_parse_remove(s, "notagcheck");
21371 + *flags |= MS_NOTAGCHECK;
21372 + set |= MS_NOTAGCHECK;
21377 + strcpy(string, s);
21382 +#ifdef CONFIG_PROPAGATE
21384 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21386 + tag_t new_tag = 0;
21387 + struct vfsmount *mnt;
21392 + mnt = nd->path.mnt;
21396 + propagate = (mnt->mnt_flags & MNT_TAGID);
21398 + new_tag = mnt->mnt_tag;
21400 + vxdprintk(VXD_CBIT(tag, 7),
21401 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21402 + inode, inode->i_ino, inode->i_tag,
21403 + new_tag, (propagate) ? 1 : 0);
21406 + inode->i_tag = new_tag;
21409 +#include <linux/module.h>
21411 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21413 +#endif /* CONFIG_PROPAGATE */
21415 diff -NurpP --minimal linux-2.6.35/kernel/vserver/Kconfig linux-2.6.35-vs2.3.0.36.31/kernel/vserver/Kconfig
21416 --- linux-2.6.35/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
21417 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/Kconfig 2010-08-02 17:05:06.000000000 +0200
21420 +# Linux VServer configuration
21423 +menu "Linux VServer"
21425 +config VSERVER_AUTO_LBACK
21426 + bool "Automatically Assign Loopback IP"
21429 + Automatically assign a guest specific loopback
21430 + IP and add it to the kernel network stack on
21433 +config VSERVER_AUTO_SINGLE
21434 + bool "Automatic Single IP Special Casing"
21435 + depends on EXPERIMENTAL
21438 + This allows network contexts with a single IP to
21439 + automatically remap 0.0.0.0 bindings to that IP,
21440 + avoiding further network checks and improving
21443 + (note: such guests do not allow to change the ip
21444 + on the fly and do not show loopback addresses)
21446 +config VSERVER_COWBL
21447 + bool "Enable COW Immutable Link Breaking"
21450 + This enables the COW (Copy-On-Write) link break code.
21451 + It allows you to treat unified files like normal files
21452 + when writing to them (which will implicitely break the
21453 + link and create a copy of the unified file)
21455 +config VSERVER_VTIME
21456 + bool "Enable Virtualized Guest Time"
21457 + depends on EXPERIMENTAL
21460 + This enables per guest time offsets to allow for
21461 + adjusting the system clock individually per guest.
21462 + this adds some overhead to the time functions and
21463 + therefore should not be enabled without good reason.
21465 +config VSERVER_DEVICE
21466 + bool "Enable Guest Device Mapping"
21467 + depends on EXPERIMENTAL
21470 + This enables generic device remapping.
21472 +config VSERVER_PROC_SECURE
21473 + bool "Enable Proc Security"
21474 + depends on PROC_FS
21477 + This configures ProcFS security to initially hide
21478 + non-process entries for all contexts except the main and
21479 + spectator context (i.e. for all guests), which is a secure
21482 + (note: on 1.2x the entries were visible by default)
21484 +config VSERVER_HARDCPU
21485 + bool "Enable Hard CPU Limits"
21488 + Activate the Hard CPU Limits
21490 + This will compile in code that allows the Token Bucket
21491 + Scheduler to put processes on hold when a context's
21492 + tokens are depleted (provided that its per-context
21493 + sched_hard flag is set).
21495 + Processes belonging to that context will not be able
21496 + to consume CPU resources again until a per-context
21497 + configured minimum of tokens has been reached.
21499 +config VSERVER_IDLETIME
21500 + bool "Avoid idle CPUs by skipping Time"
21501 + depends on VSERVER_HARDCPU
21504 + This option allows the scheduler to artificially
21505 + advance time (per cpu) when otherwise the idle
21506 + task would be scheduled, thus keeping the cpu
21507 + busy and sharing the available resources among
21508 + certain contexts.
21510 +config VSERVER_IDLELIMIT
21511 + bool "Limit the IDLE task"
21512 + depends on VSERVER_HARDCPU
21515 + Limit the idle slices, so the the next context
21516 + will be scheduled as soon as possible.
21518 + This might improve interactivity and latency, but
21519 + will also marginally increase scheduling overhead.
21522 + prompt "Persistent Inode Tagging"
21523 + default TAGGING_ID24
21525 + This adds persistent context information to filesystems
21526 + mounted with the tagxid option. Tagging is a requirement
21527 + for per-context disk limits and per-context quota.
21530 +config TAGGING_NONE
21533 + do not store per-context information in inodes.
21535 +config TAGGING_UID16
21536 + bool "UID16/GID32"
21538 + reduces UID to 16 bit, but leaves GID at 32 bit.
21540 +config TAGGING_GID16
21541 + bool "UID32/GID16"
21543 + reduces GID to 16 bit, but leaves UID at 32 bit.
21545 +config TAGGING_ID24
21546 + bool "UID24/GID24"
21548 + uses the upper 8bit from UID and GID for XID tagging
21549 + which leaves 24bit for UID/GID each, which should be
21550 + more than sufficient for normal use.
21552 +config TAGGING_INTERN
21553 + bool "UID32/GID32"
21555 + this uses otherwise reserved inode fields in the on
21556 + disk representation, which limits the use to a few
21557 + filesystems (currently ext2 and ext3)
21562 + bool "Tag NFSD User Auth and Files"
21565 + Enable this if you do want the in-kernel NFS
21566 + Server to use the tagging specified above.
21567 + (will require patched clients too)
21569 +config VSERVER_PRIVACY
21570 + bool "Honor Privacy Aspects of Guests"
21573 + When enabled, most context checks will disallow
21574 + access to structures assigned to a specific context,
21575 + like ptys or loop devices.
21577 +config VSERVER_CONTEXTS
21578 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
21580 + default "768" if 64BIT
21583 + This setting will optimize certain data structures
21584 + and memory allocations according to the expected
21587 + note: this is not a strict upper limit.
21589 +config VSERVER_WARN
21590 + bool "VServer Warnings"
21593 + This enables various runtime warnings, which will
21594 + notify about potential manipulation attempts or
21595 + resource shortage. It is generally considered to
21596 + be a good idea to have that enabled.
21598 +config VSERVER_DEBUG
21599 + bool "VServer Debugging Code"
21602 + Set this to yes if you want to be able to activate
21603 + debugging output at runtime. It adds a very small
21604 + overhead to all vserver related functions and
21605 + increases the kernel size by about 20k.
21607 +config VSERVER_HISTORY
21608 + bool "VServer History Tracing"
21609 + depends on VSERVER_DEBUG
21612 + Set this to yes if you want to record the history of
21613 + linux-vserver activities, so they can be replayed in
21614 + the event of a kernel panic or oops.
21616 +config VSERVER_HISTORY_SIZE
21617 + int "Per-CPU History Size (32-65536)"
21618 + depends on VSERVER_HISTORY
21622 + This allows you to specify the number of entries in
21623 + the per-CPU history buffer.
21625 +config VSERVER_MONITOR
21626 + bool "VServer Scheduling Monitor"
21627 + depends on VSERVER_DISABLED
21630 + Set this to yes if you want to record the scheduling
21631 + decisions, so that they can be relayed to userspace
21632 + for detailed analysis.
21634 +config VSERVER_MONITOR_SIZE
21635 + int "Per-CPU Monitor Queue Size (32-65536)"
21636 + depends on VSERVER_MONITOR
21640 + This allows you to specify the number of entries in
21641 + the per-CPU scheduling monitor buffer.
21643 +config VSERVER_MONITOR_SYNC
21644 + int "Per-CPU Monitor Sync Interval (0-65536)"
21645 + depends on VSERVER_MONITOR
21649 + This allows you to specify the interval in ticks
21650 + when a time sync entry is inserted.
21652 +config VSERVER_LEGACY_MEM
21653 + bool "Legacy Memory Limits"
21656 + This provides fake memory limits to keep
21657 + older tools happy in the face of memory
21667 + select NAMESPACES
21673 +config VSERVER_SECURITY
21675 + depends on SECURITY
21677 + select SECURITY_CAPABILITIES
21679 diff -NurpP --minimal linux-2.6.35/kernel/vserver/limit.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/limit.c
21680 --- linux-2.6.35/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21681 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/limit.c 2010-08-02 17:05:06.000000000 +0200
21684 + * linux/kernel/vserver/limit.c
21686 + * Virtual Server: Context Limits
21688 + * Copyright (C) 2004-2010 Herbert Pötzl
21690 + * V0.01 broken out from vcontext V0.05
21691 + * V0.02 changed vcmds to vxi arg
21692 + * V0.03 added memory cgroup support
21696 +#include <linux/sched.h>
21697 +#include <linux/module.h>
21698 +#include <linux/memcontrol.h>
21699 +#include <linux/res_counter.h>
21700 +#include <linux/vs_limit.h>
21701 +#include <linux/vserver/limit.h>
21702 +#include <linux/vserver/limit_cmd.h>
21704 +#include <asm/uaccess.h>
21707 +const char *vlimit_name[NUM_LIMITS] = {
21708 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21709 + [RLIMIT_RSS] = "RSS",
21710 + [RLIMIT_AS] = "VM",
21711 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21712 + [RLIMIT_CPU] = "CPU",
21713 + [RLIMIT_NPROC] = "NPROC",
21714 + [RLIMIT_NOFILE] = "NOFILE",
21715 + [RLIMIT_LOCKS] = "LOCKS",
21716 + [RLIMIT_SIGPENDING] = "SIGP",
21717 + [RLIMIT_MSGQUEUE] = "MSGQ",
21719 + [VLIMIT_NSOCK] = "NSOCK",
21720 + [VLIMIT_OPENFD] = "OPENFD",
21721 + [VLIMIT_SHMEM] = "SHMEM",
21722 + [VLIMIT_DENTRY] = "DENTRY",
21725 +EXPORT_SYMBOL_GPL(vlimit_name);
21727 +#define MASK_ENTRY(x) (1 << (x))
21729 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21732 + , /* softlimit */
21733 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21734 + MASK_ENTRY( RLIMIT_RSS ) |
21735 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21738 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21739 + MASK_ENTRY( RLIMIT_RSS ) |
21740 + MASK_ENTRY( RLIMIT_AS ) |
21741 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21742 + MASK_ENTRY( RLIMIT_NPROC ) |
21743 + MASK_ENTRY( RLIMIT_NOFILE ) |
21744 + MASK_ENTRY( RLIMIT_LOCKS ) |
21745 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21747 + MASK_ENTRY( VLIMIT_NSOCK ) |
21748 + MASK_ENTRY( VLIMIT_OPENFD ) |
21749 + MASK_ENTRY( VLIMIT_SHMEM ) |
21750 + MASK_ENTRY( VLIMIT_DENTRY ) |
21753 + /* accounting only */
21754 +uint32_t account_mask =
21755 + MASK_ENTRY( VLIMIT_SEMARY ) |
21756 + MASK_ENTRY( VLIMIT_NSEMS ) |
21757 + MASK_ENTRY( VLIMIT_MAPPED ) |
21761 +static int is_valid_vlimit(int id)
21763 + uint32_t mask = vlimit_mask.minimum |
21764 + vlimit_mask.softlimit | vlimit_mask.maximum;
21765 + return mask & (1 << id);
21768 +static int is_accounted_vlimit(int id)
21770 + if (is_valid_vlimit(id))
21772 + return account_mask & (1 << id);
21776 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21778 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21779 + return VX_VLIM(limit);
21782 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21784 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21785 + return VX_VLIM(limit);
21788 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21789 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21791 + if (!is_valid_vlimit(id))
21795 + *minimum = CRLIM_UNSET;
21797 + *softlimit = vc_get_soft(vxi, id);
21799 + *maximum = vc_get_hard(vxi, id);
21803 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21805 + struct vcmd_ctx_rlimit_v0 vc_data;
21808 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21811 + ret = do_get_rlimit(vxi, vc_data.id,
21812 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21816 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21821 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21822 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21824 + if (!is_valid_vlimit(id))
21827 + if (maximum != CRLIM_KEEP)
21828 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21829 + if (softlimit != CRLIM_KEEP)
21830 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21832 + /* clamp soft limit */
21833 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21834 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21839 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21841 + struct vcmd_ctx_rlimit_v0 vc_data;
21843 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21846 + return do_set_rlimit(vxi, vc_data.id,
21847 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21850 +#ifdef CONFIG_IA32_EMULATION
21852 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21854 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21856 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21859 + return do_set_rlimit(vxi, vc_data.id,
21860 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21863 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21865 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21868 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21871 + ret = do_get_rlimit(vxi, vc_data.id,
21872 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21876 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21881 +#endif /* CONFIG_IA32_EMULATION */
21884 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21886 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21892 +static inline void vx_reset_hits(struct _vx_limit *limit)
21896 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21897 + atomic_set(&__rlim_lhit(limit, lim), 0);
21901 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
21903 + vx_reset_hits(&vxi->limit);
21907 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21912 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21913 + value = __rlim_get(limit, lim);
21914 + __rlim_rmax(limit, lim) = value;
21915 + __rlim_rmin(limit, lim) = value;
21919 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21921 + vx_reset_minmax(&vxi->limit);
21926 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21928 + struct vcmd_rlimit_stat_v0 vc_data;
21929 + struct _vx_limit *limit = &vxi->limit;
21932 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21936 + if (!is_accounted_vlimit(id))
21939 + vx_limit_fixup(limit, id);
21940 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21941 + vc_data.value = __rlim_get(limit, id);
21942 + vc_data.minimum = __rlim_rmin(limit, id);
21943 + vc_data.maximum = __rlim_rmax(limit, id);
21945 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21951 +void vx_vsi_meminfo(struct sysinfo *val)
21953 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21954 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21955 + u64 res_limit, res_usage;
21960 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21961 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21963 + if (res_limit != RESOURCE_MAX)
21964 + val->totalram = (res_limit >> PAGE_SHIFT);
21965 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
21966 + val->bufferram = 0;
21967 + val->totalhigh = 0;
21968 + val->freehigh = 0;
21969 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
21973 +void vx_vsi_swapinfo(struct sysinfo *val)
21975 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21976 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
21977 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21978 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
21979 + s64 swap_limit, swap_usage;
21984 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21985 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21986 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
21987 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
21989 + if (res_limit == RESOURCE_MAX)
21992 + swap_limit = memsw_limit - res_limit;
21993 + if (memsw_limit != RESOURCE_MAX)
21994 + val->totalswap = swap_limit >> PAGE_SHIFT;
21996 + swap_usage = memsw_usage - res_usage;
21997 + val->freeswap = (swap_usage < swap_limit) ?
21998 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
21999 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22000 + val->totalswap = 0;
22001 + val->freeswap = 0;
22002 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22003 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22007 +long vx_vsi_cached(struct sysinfo *val)
22009 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22010 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22012 + return mem_cgroup_stat_read_cache(mcg);
22019 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
22021 + struct vx_info *vxi = mm->mm_vx_info;
22022 + unsigned long points;
22028 + points = vxi->vx_badness_bias;
22030 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22031 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22032 + points += (v > w) ? (v - w) : 0;
22037 diff -NurpP --minimal linux-2.6.35/kernel/vserver/limit_init.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/limit_init.h
22038 --- linux-2.6.35/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
22039 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/limit_init.h 2010-08-02 17:05:06.000000000 +0200
22043 +static inline void vx_info_init_limit(struct _vx_limit *limit)
22047 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22048 + __rlim_soft(limit, lim) = RLIM_INFINITY;
22049 + __rlim_hard(limit, lim) = RLIM_INFINITY;
22050 + __rlim_set(limit, lim, 0);
22051 + atomic_set(&__rlim_lhit(limit, lim), 0);
22052 + __rlim_rmin(limit, lim) = 0;
22053 + __rlim_rmax(limit, lim) = 0;
22057 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
22062 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22063 + if ((1 << lim) & VLIM_NOCHECK)
22065 + value = __rlim_get(limit, lim);
22066 + vxwprintk_xid(value,
22067 + "!!! limit: %p[%s,%d] = %ld on exit.",
22068 + limit, vlimit_name[lim], lim, (long)value);
22072 diff -NurpP --minimal linux-2.6.35/kernel/vserver/limit_proc.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/limit_proc.h
22073 --- linux-2.6.35/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
22074 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/limit_proc.h 2010-08-02 17:05:06.000000000 +0200
22076 +#ifndef _VX_LIMIT_PROC_H
22077 +#define _VX_LIMIT_PROC_H
22079 +#include <linux/vserver/limit_int.h>
22082 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
22083 +#define VX_LIMIT_TOP \
22084 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
22086 +#define VX_LIMIT_ARG(r) \
22087 + (unsigned long)__rlim_get(limit, r), \
22088 + (unsigned long)__rlim_rmin(limit, r), \
22089 + (unsigned long)__rlim_rmax(limit, r), \
22090 + VX_VLIM(__rlim_soft(limit, r)), \
22091 + VX_VLIM(__rlim_hard(limit, r)), \
22092 + atomic_read(&__rlim_lhit(limit, r))
22094 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
22096 + vx_limit_fixup(limit, -1);
22097 + return sprintf(buffer, VX_LIMIT_TOP
22098 + "PROC" VX_LIMIT_FMT
22099 + "VM" VX_LIMIT_FMT
22100 + "VML" VX_LIMIT_FMT
22101 + "RSS" VX_LIMIT_FMT
22102 + "ANON" VX_LIMIT_FMT
22103 + "RMAP" VX_LIMIT_FMT
22104 + "FILES" VX_LIMIT_FMT
22105 + "OFD" VX_LIMIT_FMT
22106 + "LOCKS" VX_LIMIT_FMT
22107 + "SOCK" VX_LIMIT_FMT
22108 + "MSGQ" VX_LIMIT_FMT
22109 + "SHM" VX_LIMIT_FMT
22110 + "SEMA" VX_LIMIT_FMT
22111 + "SEMS" VX_LIMIT_FMT
22112 + "DENT" VX_LIMIT_FMT,
22113 + VX_LIMIT_ARG(RLIMIT_NPROC),
22114 + VX_LIMIT_ARG(RLIMIT_AS),
22115 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22116 + VX_LIMIT_ARG(RLIMIT_RSS),
22117 + VX_LIMIT_ARG(VLIMIT_ANON),
22118 + VX_LIMIT_ARG(VLIMIT_MAPPED),
22119 + VX_LIMIT_ARG(RLIMIT_NOFILE),
22120 + VX_LIMIT_ARG(VLIMIT_OPENFD),
22121 + VX_LIMIT_ARG(RLIMIT_LOCKS),
22122 + VX_LIMIT_ARG(VLIMIT_NSOCK),
22123 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22124 + VX_LIMIT_ARG(VLIMIT_SHMEM),
22125 + VX_LIMIT_ARG(VLIMIT_SEMARY),
22126 + VX_LIMIT_ARG(VLIMIT_NSEMS),
22127 + VX_LIMIT_ARG(VLIMIT_DENTRY));
22130 +#endif /* _VX_LIMIT_PROC_H */
22133 diff -NurpP --minimal linux-2.6.35/kernel/vserver/Makefile linux-2.6.35-vs2.3.0.36.31/kernel/vserver/Makefile
22134 --- linux-2.6.35/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
22135 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/Makefile 2010-08-02 17:05:06.000000000 +0200
22138 +# Makefile for the Linux vserver routines.
22142 +obj-y += vserver.o
22144 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
22145 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
22148 +vserver-$(CONFIG_INET) += inet.o
22149 +vserver-$(CONFIG_PROC_FS) += proc.o
22150 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
22151 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
22152 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
22153 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
22155 diff -NurpP --minimal linux-2.6.35/kernel/vserver/monitor.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/monitor.c
22156 --- linux-2.6.35/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
22157 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/monitor.c 2010-08-02 17:05:06.000000000 +0200
22160 + * kernel/vserver/monitor.c
22162 + * Virtual Context Scheduler Monitor
22164 + * Copyright (C) 2006-2007 Herbert Pötzl
22166 + * V0.01 basic design
22170 +#include <linux/module.h>
22171 +#include <linux/jiffies.h>
22172 +#include <asm/uaccess.h>
22173 +#include <asm/atomic.h>
22175 +#include <linux/vserver/monitor.h>
22176 +#include <linux/vserver/debug_cmd.h>
22179 +#ifdef CONFIG_VSERVER_MONITOR
22180 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
22182 +#define VXM_SIZE 64
22185 +struct _vx_monitor {
22186 + unsigned int counter;
22188 + struct _vx_mon_entry entry[VXM_SIZE+1];
22192 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
22194 +unsigned volatile int vxm_active = 1;
22196 +static atomic_t sequence = ATOMIC_INIT(0);
22201 + * requires disabled preemption */
22203 +struct _vx_mon_entry *vxm_advance(int cpu)
22205 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22206 + struct _vx_mon_entry *entry;
22207 + unsigned int index;
22209 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
22210 + entry = &mon->entry[index];
22212 + entry->ev.seq = atomic_inc_return(&sequence);
22213 + entry->ev.jif = jiffies;
22217 +EXPORT_SYMBOL_GPL(vxm_advance);
22220 +int do_read_monitor(struct __user _vx_mon_entry *data,
22221 + int cpu, uint32_t *index, uint32_t *count)
22223 + int pos, ret = 0;
22224 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22225 + int end = mon->counter;
22226 + int start = end - VXM_SIZE + 2;
22227 + int idx = *index;
22229 + /* special case: get current pos */
22235 + /* have we lost some data? */
22239 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22240 + struct _vx_mon_entry *entry =
22241 + &mon->entry[idx % VXM_SIZE];
22243 + /* send entry to userspace */
22244 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22248 + /* save new index and count */
22251 + return ret ? ret : (*index < end);
22254 +int vc_read_monitor(uint32_t id, void __user *data)
22256 + struct vcmd_read_monitor_v0 vc_data;
22259 + if (id >= NR_CPUS)
22262 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22265 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
22266 + id, &vc_data.index, &vc_data.count);
22268 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22273 +#ifdef CONFIG_COMPAT
22275 +int vc_read_monitor_x32(uint32_t id, void __user *data)
22277 + struct vcmd_read_monitor_v0_x32 vc_data;
22280 + if (id >= NR_CPUS)
22283 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22286 + ret = do_read_monitor((struct __user _vx_mon_entry *)
22287 + compat_ptr(vc_data.data_ptr),
22288 + id, &vc_data.index, &vc_data.count);
22290 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22295 +#endif /* CONFIG_COMPAT */
22297 diff -NurpP --minimal linux-2.6.35/kernel/vserver/network.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/network.c
22298 --- linux-2.6.35/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
22299 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/network.c 2010-08-02 17:05:06.000000000 +0200
22302 + * linux/kernel/vserver/network.c
22304 + * Virtual Server: Network Support
22306 + * Copyright (C) 2003-2007 Herbert Pötzl
22308 + * V0.01 broken out from vcontext V0.05
22309 + * V0.02 cleaned up implementation
22310 + * V0.03 added equiv nx commands
22311 + * V0.04 switch to RCU based hash
22312 + * V0.05 and back to locking again
22313 + * V0.06 changed vcmds to nxi arg
22314 + * V0.07 have __create claim() the nxi
22318 +#include <linux/err.h>
22319 +#include <linux/slab.h>
22320 +#include <linux/rcupdate.h>
22322 +#include <linux/vs_network.h>
22323 +#include <linux/vs_pid.h>
22324 +#include <linux/vserver/network_cmd.h>
22327 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
22328 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
22330 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22331 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22334 +static int __init init_network(void)
22336 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22337 + sizeof(struct nx_addr_v4), 0,
22338 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22339 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22340 + sizeof(struct nx_addr_v6), 0,
22341 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22346 +/* __alloc_nx_addr_v4() */
22348 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22350 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
22351 + nx_addr_v4_cachep, GFP_KERNEL);
22353 + if (!IS_ERR(nxa))
22354 + memset(nxa, 0, sizeof(*nxa));
22358 +/* __dealloc_nx_addr_v4() */
22360 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22362 + kmem_cache_free(nx_addr_v4_cachep, nxa);
22365 +/* __dealloc_nx_addr_v4_all() */
22367 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22370 + struct nx_addr_v4 *next = nxa->next;
22372 + __dealloc_nx_addr_v4(nxa);
22378 +#ifdef CONFIG_IPV6
22380 +/* __alloc_nx_addr_v6() */
22382 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22384 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
22385 + nx_addr_v6_cachep, GFP_KERNEL);
22387 + if (!IS_ERR(nxa))
22388 + memset(nxa, 0, sizeof(*nxa));
22392 +/* __dealloc_nx_addr_v6() */
22394 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22396 + kmem_cache_free(nx_addr_v6_cachep, nxa);
22399 +/* __dealloc_nx_addr_v6_all() */
22401 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22404 + struct nx_addr_v6 *next = nxa->next;
22406 + __dealloc_nx_addr_v6(nxa);
22411 +#endif /* CONFIG_IPV6 */
22413 +/* __alloc_nx_info()
22415 + * allocate an initialized nx_info struct
22416 + * doesn't make it visible (hash) */
22418 +static struct nx_info *__alloc_nx_info(nid_t nid)
22420 + struct nx_info *new = NULL;
22422 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22424 + /* would this benefit from a slab cache? */
22425 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22429 + memset(new, 0, sizeof(struct nx_info));
22430 + new->nx_id = nid;
22431 + INIT_HLIST_NODE(&new->nx_hlist);
22432 + atomic_set(&new->nx_usecnt, 0);
22433 + atomic_set(&new->nx_tasks, 0);
22434 + new->nx_state = 0;
22436 + new->nx_flags = NXF_INIT_SET;
22438 + /* rest of init goes here */
22440 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22441 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22443 + vxdprintk(VXD_CBIT(nid, 0),
22444 + "alloc_nx_info(%d) = %p", nid, new);
22445 + atomic_inc(&nx_global_ctotal);
22449 +/* __dealloc_nx_info()
22451 + * final disposal of nx_info */
22453 +static void __dealloc_nx_info(struct nx_info *nxi)
22455 + vxdprintk(VXD_CBIT(nid, 0),
22456 + "dealloc_nx_info(%p)", nxi);
22458 + nxi->nx_hlist.next = LIST_POISON1;
22461 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22462 + BUG_ON(atomic_read(&nxi->nx_tasks));
22464 + __dealloc_nx_addr_v4_all(nxi->v4.next);
22466 + nxi->nx_state |= NXS_RELEASED;
22468 + atomic_dec(&nx_global_ctotal);
22471 +static void __shutdown_nx_info(struct nx_info *nxi)
22473 + nxi->nx_state |= NXS_SHUTDOWN;
22474 + vs_net_change(nxi, VSC_NETDOWN);
22477 +/* exported stuff */
22479 +void free_nx_info(struct nx_info *nxi)
22481 + /* context shutdown is mandatory */
22482 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22484 + /* context must not be hashed */
22485 + BUG_ON(nxi->nx_state & NXS_HASHED);
22487 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22488 + BUG_ON(atomic_read(&nxi->nx_tasks));
22490 + __dealloc_nx_info(nxi);
22494 +void __nx_set_lback(struct nx_info *nxi)
22496 + int nid = nxi->nx_id;
22497 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22499 + nxi->v4_lback.s_addr = lback;
22502 +extern int __nx_inet_add_lback(__be32 addr);
22503 +extern int __nx_inet_del_lback(__be32 addr);
22506 +/* hash table for nx_info hash */
22508 +#define NX_HASH_SIZE 13
22510 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22512 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
22515 +static inline unsigned int __hashval(nid_t nid)
22517 + return (nid % NX_HASH_SIZE);
22522 +/* __hash_nx_info()
22524 + * add the nxi to the global hash table
22525 + * requires the hash_lock to be held */
22527 +static inline void __hash_nx_info(struct nx_info *nxi)
22529 + struct hlist_head *head;
22531 + vxd_assert_lock(&nx_info_hash_lock);
22532 + vxdprintk(VXD_CBIT(nid, 4),
22533 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22535 + /* context must not be hashed */
22536 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
22538 + nxi->nx_state |= NXS_HASHED;
22539 + head = &nx_info_hash[__hashval(nxi->nx_id)];
22540 + hlist_add_head(&nxi->nx_hlist, head);
22541 + atomic_inc(&nx_global_cactive);
22544 +/* __unhash_nx_info()
22546 + * remove the nxi from the global hash table
22547 + * requires the hash_lock to be held */
22549 +static inline void __unhash_nx_info(struct nx_info *nxi)
22551 + vxd_assert_lock(&nx_info_hash_lock);
22552 + vxdprintk(VXD_CBIT(nid, 4),
22553 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22554 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22556 + /* context must be hashed */
22557 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22558 + /* but without tasks */
22559 + BUG_ON(atomic_read(&nxi->nx_tasks));
22561 + nxi->nx_state &= ~NXS_HASHED;
22562 + hlist_del(&nxi->nx_hlist);
22563 + atomic_dec(&nx_global_cactive);
22567 +/* __lookup_nx_info()
22569 + * requires the hash_lock to be held
22570 + * doesn't increment the nx_refcnt */
22572 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22574 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22575 + struct hlist_node *pos;
22576 + struct nx_info *nxi;
22578 + vxd_assert_lock(&nx_info_hash_lock);
22579 + hlist_for_each(pos, head) {
22580 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22582 + if (nxi->nx_id == nid)
22587 + vxdprintk(VXD_CBIT(nid, 0),
22588 + "__lookup_nx_info(#%u): %p[#%u]",
22589 + nid, nxi, nxi ? nxi->nx_id : 0);
22594 +/* __create_nx_info()
22596 + * create the requested context
22597 + * get(), claim() and hash it */
22599 +static struct nx_info *__create_nx_info(int id)
22601 + struct nx_info *new, *nxi = NULL;
22603 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22605 + if (!(new = __alloc_nx_info(id)))
22606 + return ERR_PTR(-ENOMEM);
22608 + /* required to make dynamic xids unique */
22609 + spin_lock(&nx_info_hash_lock);
22611 + /* static context requested */
22612 + if ((nxi = __lookup_nx_info(id))) {
22613 + vxdprintk(VXD_CBIT(nid, 0),
22614 + "create_nx_info(%d) = %p (already there)", id, nxi);
22615 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22616 + nxi = ERR_PTR(-EBUSY);
22618 + nxi = ERR_PTR(-EEXIST);
22621 + /* new context */
22622 + vxdprintk(VXD_CBIT(nid, 0),
22623 + "create_nx_info(%d) = %p (new)", id, new);
22624 + claim_nx_info(new, NULL);
22625 + __nx_set_lback(new);
22626 + __hash_nx_info(get_nx_info(new));
22627 + nxi = new, new = NULL;
22630 + spin_unlock(&nx_info_hash_lock);
22632 + __dealloc_nx_info(new);
22638 +/* exported stuff */
22641 +void unhash_nx_info(struct nx_info *nxi)
22643 + __shutdown_nx_info(nxi);
22644 + spin_lock(&nx_info_hash_lock);
22645 + __unhash_nx_info(nxi);
22646 + spin_unlock(&nx_info_hash_lock);
22649 +/* lookup_nx_info()
22651 + * search for a nx_info and get() it
22652 + * negative id means current */
22654 +struct nx_info *lookup_nx_info(int id)
22656 + struct nx_info *nxi = NULL;
22659 + nxi = get_nx_info(current_nx_info());
22660 + } else if (id > 1) {
22661 + spin_lock(&nx_info_hash_lock);
22662 + nxi = get_nx_info(__lookup_nx_info(id));
22663 + spin_unlock(&nx_info_hash_lock);
22668 +/* nid_is_hashed()
22670 + * verify that nid is still hashed */
22672 +int nid_is_hashed(nid_t nid)
22676 + spin_lock(&nx_info_hash_lock);
22677 + hashed = (__lookup_nx_info(nid) != NULL);
22678 + spin_unlock(&nx_info_hash_lock);
22683 +#ifdef CONFIG_PROC_FS
22687 + * get a subset of hashed nids for proc
22688 + * assumes size is at least one */
22690 +int get_nid_list(int index, unsigned int *nids, int size)
22692 + int hindex, nr_nids = 0;
22694 + /* only show current and children */
22695 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22698 + nids[nr_nids] = nx_current_nid();
22702 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22703 + struct hlist_head *head = &nx_info_hash[hindex];
22704 + struct hlist_node *pos;
22706 + spin_lock(&nx_info_hash_lock);
22707 + hlist_for_each(pos, head) {
22708 + struct nx_info *nxi;
22713 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22714 + nids[nr_nids] = nxi->nx_id;
22715 + if (++nr_nids >= size) {
22716 + spin_unlock(&nx_info_hash_lock);
22720 + /* keep the lock time short */
22721 + spin_unlock(&nx_info_hash_lock);
22730 + * migrate task to new network
22731 + * gets nxi, puts old_nxi on change
22734 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22736 + struct nx_info *old_nxi;
22742 + vxdprintk(VXD_CBIT(nid, 5),
22743 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22744 + p, nxi, nxi->nx_id,
22745 + atomic_read(&nxi->nx_usecnt),
22746 + atomic_read(&nxi->nx_tasks));
22748 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22749 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22752 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22755 + /* maybe disallow this completely? */
22756 + old_nxi = task_get_nx_info(p);
22757 + if (old_nxi == nxi)
22762 + clr_nx_info(&p->nx_info);
22763 + claim_nx_info(nxi, p);
22764 + set_nx_info(&p->nx_info, nxi);
22765 + p->nid = nxi->nx_id;
22768 + vxdprintk(VXD_CBIT(nid, 5),
22769 + "moved task %p into nxi:%p[#%d]",
22770 + p, nxi, nxi->nx_id);
22773 + release_nx_info(old_nxi, p);
22776 + put_nx_info(old_nxi);
22781 +void nx_set_persistent(struct nx_info *nxi)
22783 + vxdprintk(VXD_CBIT(nid, 6),
22784 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22786 + get_nx_info(nxi);
22787 + claim_nx_info(nxi, NULL);
22790 +void nx_clear_persistent(struct nx_info *nxi)
22792 + vxdprintk(VXD_CBIT(nid, 6),
22793 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22795 + release_nx_info(nxi, NULL);
22796 + put_nx_info(nxi);
22799 +void nx_update_persistent(struct nx_info *nxi)
22801 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22802 + nx_set_persistent(nxi);
22804 + nx_clear_persistent(nxi);
22807 +/* vserver syscall commands below here */
22809 +/* taks nid and nx_info functions */
22811 +#include <asm/uaccess.h>
22814 +int vc_task_nid(uint32_t id)
22819 + struct task_struct *tsk;
22821 + read_lock(&tasklist_lock);
22822 + tsk = find_task_by_real_pid(id);
22823 + nid = (tsk) ? tsk->nid : -ESRCH;
22824 + read_unlock(&tasklist_lock);
22826 + nid = nx_current_nid();
22831 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22833 + struct vcmd_nx_info_v0 vc_data;
22835 + vc_data.nid = nxi->nx_id;
22837 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22843 +/* network functions */
22845 +int vc_net_create(uint32_t nid, void __user *data)
22847 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22848 + struct nx_info *new_nxi;
22851 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22854 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
22857 + new_nxi = __create_nx_info(nid);
22858 + if (IS_ERR(new_nxi))
22859 + return PTR_ERR(new_nxi);
22861 + /* initial flags */
22862 + new_nxi->nx_flags = vc_data.flagword;
22865 + if (vs_net_change(new_nxi, VSC_NETUP))
22868 + ret = nx_migrate_task(current, new_nxi);
22872 + /* return context id on success */
22873 + ret = new_nxi->nx_id;
22875 + /* get a reference for persistent contexts */
22876 + if ((vc_data.flagword & NXF_PERSISTENT))
22877 + nx_set_persistent(new_nxi);
22879 + release_nx_info(new_nxi, NULL);
22880 + put_nx_info(new_nxi);
22885 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22887 + return nx_migrate_task(current, nxi);
22892 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22893 + uint16_t type, uint16_t flags)
22895 + struct nx_addr_v4 *nxa = &nxi->v4;
22897 + if (NX_IPV4(nxi)) {
22898 + /* locate last entry */
22899 + for (; nxa->next; nxa = nxa->next);
22900 + nxa->next = __alloc_nx_addr_v4();
22904 + return PTR_ERR(nxa);
22907 + if (nxi->v4.next)
22908 + /* remove single ip for ip list */
22909 + nxi->nx_flags &= ~NXF_SINGLE_IP;
22911 + nxa->ip[0].s_addr = ip;
22912 + nxa->ip[1].s_addr = ip2;
22913 + nxa->mask.s_addr = mask;
22914 + nxa->type = type;
22915 + nxa->flags = flags;
22920 +int vc_net_add(struct nx_info *nxi, void __user *data)
22922 + struct vcmd_net_addr_v0 vc_data;
22923 + int index, ret = 0;
22925 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22928 + switch (vc_data.type) {
22929 + case NXA_TYPE_IPV4:
22930 + if ((vc_data.count < 1) || (vc_data.count > 4))
22934 + while (index < vc_data.count) {
22935 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22936 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
22944 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22945 + nxi->v4_bcast = vc_data.ip[0];
22949 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
22950 + nxi->v4_lback = vc_data.ip[0];
22961 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22963 + struct vcmd_net_addr_v0 vc_data;
22965 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22968 + switch (vc_data.type) {
22969 + case NXA_TYPE_ANY:
22970 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22971 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22981 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
22983 + struct vcmd_net_addr_ipv4_v1 vc_data;
22985 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22988 + switch (vc_data.type) {
22989 + case NXA_TYPE_ADDR:
22990 + case NXA_TYPE_RANGE:
22991 + case NXA_TYPE_MASK:
22992 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
22993 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22995 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
22996 + nxi->v4_bcast = vc_data.ip;
22999 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
23000 + nxi->v4_lback = vc_data.ip;
23009 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
23011 + struct vcmd_net_addr_ipv4_v1 vc_data;
23013 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23016 + switch (vc_data.type) {
23017 +/* case NXA_TYPE_ADDR:
23020 + case NXA_TYPE_ANY:
23021 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23022 + memset(&nxi->v4, 0, sizeof(nxi->v4));
23032 +#ifdef CONFIG_IPV6
23034 +int do_add_v6_addr(struct nx_info *nxi,
23035 + struct in6_addr *ip, struct in6_addr *mask,
23036 + uint32_t prefix, uint16_t type, uint16_t flags)
23038 + struct nx_addr_v6 *nxa = &nxi->v6;
23040 + if (NX_IPV6(nxi)) {
23041 + /* locate last entry */
23042 + for (; nxa->next; nxa = nxa->next);
23043 + nxa->next = __alloc_nx_addr_v6();
23047 + return PTR_ERR(nxa);
23051 + nxa->mask = *mask;
23052 + nxa->prefix = prefix;
23053 + nxa->type = type;
23054 + nxa->flags = flags;
23059 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
23061 + struct vcmd_net_addr_ipv6_v1 vc_data;
23063 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23066 + switch (vc_data.type) {
23067 + case NXA_TYPE_ADDR:
23068 + case NXA_TYPE_MASK:
23069 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
23070 + vc_data.prefix, vc_data.type, vc_data.flags);
23077 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
23079 + struct vcmd_net_addr_ipv6_v1 vc_data;
23081 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23084 + switch (vc_data.type) {
23085 + case NXA_TYPE_ANY:
23086 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
23087 + memset(&nxi->v6, 0, sizeof(nxi->v6));
23096 +#endif /* CONFIG_IPV6 */
23099 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
23101 + struct vcmd_net_flags_v0 vc_data;
23103 + vc_data.flagword = nxi->nx_flags;
23105 + /* special STATE flag handling */
23106 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
23108 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23113 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
23115 + struct vcmd_net_flags_v0 vc_data;
23116 + uint64_t mask, trigger;
23118 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23121 + /* special STATE flag handling */
23122 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
23123 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
23125 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
23126 + vc_data.flagword, mask);
23127 + if (trigger & NXF_PERSISTENT)
23128 + nx_update_persistent(nxi);
23133 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
23135 + struct vcmd_net_caps_v0 vc_data;
23137 + vc_data.ncaps = nxi->nx_ncaps;
23138 + vc_data.cmask = ~0ULL;
23140 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23145 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
23147 + struct vcmd_net_caps_v0 vc_data;
23149 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23152 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
23153 + vc_data.ncaps, vc_data.cmask);
23158 +#include <linux/module.h>
23160 +module_init(init_network);
23162 +EXPORT_SYMBOL_GPL(free_nx_info);
23163 +EXPORT_SYMBOL_GPL(unhash_nx_info);
23165 diff -NurpP --minimal linux-2.6.35/kernel/vserver/proc.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/proc.c
23166 --- linux-2.6.35/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
23167 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/proc.c 2010-08-02 17:05:06.000000000 +0200
23170 + * linux/kernel/vserver/proc.c
23172 + * Virtual Context Support
23174 + * Copyright (C) 2003-2007 Herbert Pötzl
23176 + * V0.01 basic structure
23177 + * V0.02 adaptation vs1.3.0
23178 + * V0.03 proc permissions
23179 + * V0.04 locking/generic
23180 + * V0.05 next generation procfs
23181 + * V0.06 inode validation
23182 + * V0.07 generic rewrite vid
23183 + * V0.08 remove inode type
23187 +#include <linux/proc_fs.h>
23188 +#include <linux/fs_struct.h>
23189 +#include <linux/mount.h>
23190 +#include <asm/unistd.h>
23192 +#include <linux/vs_context.h>
23193 +#include <linux/vs_network.h>
23194 +#include <linux/vs_cvirt.h>
23196 +#include <linux/in.h>
23197 +#include <linux/inetdevice.h>
23198 +#include <linux/vs_inet.h>
23199 +#include <linux/vs_inet6.h>
23201 +#include <linux/vserver/global.h>
23203 +#include "cvirt_proc.h"
23204 +#include "cacct_proc.h"
23205 +#include "limit_proc.h"
23206 +#include "sched_proc.h"
23207 +#include "vci_config.h"
23210 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
23214 + CAP_FOR_EACH_U32(__capi) {
23215 + buffer += sprintf(buffer, "%08x",
23216 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
23222 +static struct proc_dir_entry *proc_virtual;
23224 +static struct proc_dir_entry *proc_virtnet;
23227 +/* first the actual feeds */
23230 +static int proc_vci(char *buffer)
23232 + return sprintf(buffer,
23233 + "VCIVersion:\t%04x:%04x\n"
23234 + "VCISyscall:\t%d\n"
23235 + "VCIKernel:\t%08x\n",
23236 + VCI_VERSION >> 16,
23237 + VCI_VERSION & 0xFFFF,
23239 + vci_kernel_config());
23242 +static int proc_virtual_info(char *buffer)
23244 + return proc_vci(buffer);
23247 +static int proc_virtual_status(char *buffer)
23249 + return sprintf(buffer,
23251 + "#CActive:\t%d\n"
23252 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
23253 + "#InitTask:\t%d\t%d %d\n",
23254 + atomic_read(&vx_global_ctotal),
23255 + atomic_read(&vx_global_cactive),
23256 + atomic_read(&vs_global_nsproxy),
23257 + atomic_read(&vs_global_fs),
23258 + atomic_read(&vs_global_mnt_ns),
23259 + atomic_read(&vs_global_uts_ns),
23260 + atomic_read(&nr_ipc_ns),
23261 + atomic_read(&vs_global_user_ns),
23262 + atomic_read(&vs_global_pid_ns),
23263 + atomic_read(&init_task.usage),
23264 + atomic_read(&init_task.nsproxy->count),
23265 + init_task.fs->users);
23269 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23273 + length = sprintf(buffer,
23281 + vxi->vx_badness_bias);
23285 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23287 + char *orig = buffer;
23289 + buffer += sprintf(buffer,
23292 + "Flags:\t%016llx\n",
23293 + atomic_read(&vxi->vx_usecnt),
23294 + atomic_read(&vxi->vx_tasks),
23295 + (unsigned long long)vxi->vx_flags);
23297 + buffer += sprintf(buffer, "BCaps:\t");
23298 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23299 + buffer += sprintf(buffer, "\n");
23301 + buffer += sprintf(buffer,
23302 + "CCaps:\t%016llx\n"
23303 + "Spaces:\t%08lx %08lx\n",
23304 + (unsigned long long)vxi->vx_ccaps,
23305 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
23306 + return buffer - orig;
23309 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23311 + return vx_info_proc_limit(&vxi->limit, buffer);
23314 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23318 + length = vx_info_proc_sched(&vxi->sched, buffer);
23319 + for_each_online_cpu(cpu) {
23320 + length += vx_info_proc_sched_pc(
23321 + &vx_per_cpu(vxi, sched_pc, cpu),
23322 + buffer + length, cpu);
23327 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23329 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
23332 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23334 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
23337 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23341 + vx_update_load(vxi);
23342 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23343 + for_each_online_cpu(cpu) {
23344 + length += vx_info_proc_cvirt_pc(
23345 + &vx_per_cpu(vxi, cvirt_pc, cpu),
23346 + buffer + length, cpu);
23351 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23353 + return vx_info_proc_cacct(&vxi->cacct, buffer);
23357 +static int proc_virtnet_info(char *buffer)
23359 + return proc_vci(buffer);
23362 +static int proc_virtnet_status(char *buffer)
23364 + return sprintf(buffer,
23366 + "#CActive:\t%d\n",
23367 + atomic_read(&nx_global_ctotal),
23368 + atomic_read(&nx_global_cactive));
23371 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23373 + struct nx_addr_v4 *v4a;
23374 +#ifdef CONFIG_IPV6
23375 + struct nx_addr_v6 *v6a;
23379 + length = sprintf(buffer,
23382 + "Bcast:\t" NIPQUAD_FMT "\n"
23383 + "Lback:\t" NIPQUAD_FMT "\n",
23386 + NIPQUAD(nxi->v4_bcast.s_addr),
23387 + NIPQUAD(nxi->v4_lback.s_addr));
23389 + if (!NX_IPV4(nxi))
23391 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23392 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23395 +#ifdef CONFIG_IPV6
23396 + if (!NX_IPV6(nxi))
23398 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23399 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23406 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23410 + length = sprintf(buffer,
23413 + "Flags:\t%016llx\n"
23414 + "NCaps:\t%016llx\n",
23415 + atomic_read(&nxi->nx_usecnt),
23416 + atomic_read(&nxi->nx_tasks),
23417 + (unsigned long long)nxi->nx_flags,
23418 + (unsigned long long)nxi->nx_ncaps);
23424 +/* here the inode helpers */
23430 + struct inode_operations *iop;
23431 + struct file_operations *fop;
23432 + union proc_op op;
23435 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23437 + struct inode *inode = new_inode(sb);
23442 + inode->i_mode = p->mode;
23444 + inode->i_op = p->iop;
23446 + inode->i_fop = p->fop;
23448 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23449 + inode->i_flags |= S_IMMUTABLE;
23451 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23453 + inode->i_uid = 0;
23454 + inode->i_gid = 0;
23455 + inode->i_tag = 0;
23460 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23461 + struct dentry *dentry, int id, void *ptr)
23463 + struct vs_entry *p = ptr;
23464 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23465 + struct dentry *error = ERR_PTR(-EINVAL);
23470 + PROC_I(inode)->op = p->op;
23471 + PROC_I(inode)->fd = id;
23472 + d_add(dentry, inode);
23480 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23483 + * Fill a directory entry.
23485 + * If possible create the dcache entry and derive our inode number and
23486 + * file type from dcache entry.
23488 + * Since all of the proc inode numbers are dynamically generated, the inode
23489 + * numbers do not exist until the inode is cache. This means creating the
23490 + * the dcache entry in readdir is necessary to keep the inode numbers
23491 + * reported by readdir in sync with the inode numbers reported
23494 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23495 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
23497 + struct dentry *child, *dir = filp->f_dentry;
23498 + struct inode *inode;
23499 + struct qstr qname;
23501 + unsigned type = DT_UNKNOWN;
23503 + qname.name = name;
23505 + qname.hash = full_name_hash(name, len);
23507 + child = d_lookup(dir, &qname);
23509 + struct dentry *new;
23510 + new = d_alloc(dir, &qname);
23512 + child = instantiate(dir->d_inode, new, id, ptr);
23519 + if (!child || IS_ERR(child) || !child->d_inode)
23520 + goto end_instantiate;
23521 + inode = child->d_inode;
23523 + ino = inode->i_ino;
23524 + type = inode->i_mode >> 12;
23529 + ino = find_inode_number(dir, &qname);
23532 + return filldir(dirent, name, len, filp->f_pos, ino, type);
23537 +/* get and revalidate vx_info/xid */
23540 +struct vx_info *get_proc_vx_info(struct inode *inode)
23542 + return lookup_vx_info(PROC_I(inode)->fd);
23545 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23547 + struct inode *inode = dentry->d_inode;
23548 + xid_t xid = PROC_I(inode)->fd;
23550 + if (!xid || xid_is_hashed(xid))
23557 +/* get and revalidate nx_info/nid */
23559 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23561 + struct inode *inode = dentry->d_inode;
23562 + nid_t nid = PROC_I(inode)->fd;
23564 + if (!nid || nid_is_hashed(nid))
23572 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23574 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23575 + size_t count, loff_t *ppos)
23577 + struct inode *inode = file->f_dentry->d_inode;
23578 + unsigned long page;
23579 + ssize_t length = 0;
23581 + if (count > PROC_BLOCK_SIZE)
23582 + count = PROC_BLOCK_SIZE;
23584 + /* fade that out as soon as stable */
23585 + WARN_ON(PROC_I(inode)->fd);
23587 + if (!(page = __get_free_page(GFP_KERNEL)))
23590 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23591 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
23594 + length = simple_read_from_buffer(buf, count, ppos,
23595 + (char *)page, length);
23601 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23602 + size_t count, loff_t *ppos)
23604 + struct inode *inode = file->f_dentry->d_inode;
23605 + struct vx_info *vxi = NULL;
23606 + xid_t xid = PROC_I(inode)->fd;
23607 + unsigned long page;
23608 + ssize_t length = 0;
23610 + if (count > PROC_BLOCK_SIZE)
23611 + count = PROC_BLOCK_SIZE;
23613 + /* fade that out as soon as stable */
23615 + vxi = lookup_vx_info(xid);
23619 + length = -ENOMEM;
23620 + if (!(page = __get_free_page(GFP_KERNEL)))
23623 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23624 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23627 + length = simple_read_from_buffer(buf, count, ppos,
23628 + (char *)page, length);
23632 + put_vx_info(vxi);
23637 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23638 + size_t count, loff_t *ppos)
23640 + struct inode *inode = file->f_dentry->d_inode;
23641 + struct nx_info *nxi = NULL;
23642 + nid_t nid = PROC_I(inode)->fd;
23643 + unsigned long page;
23644 + ssize_t length = 0;
23646 + if (count > PROC_BLOCK_SIZE)
23647 + count = PROC_BLOCK_SIZE;
23649 + /* fade that out as soon as stable */
23651 + nxi = lookup_nx_info(nid);
23655 + length = -ENOMEM;
23656 + if (!(page = __get_free_page(GFP_KERNEL)))
23659 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23660 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23663 + length = simple_read_from_buffer(buf, count, ppos,
23664 + (char *)page, length);
23668 + put_nx_info(nxi);
23675 +/* here comes the lower level */
23678 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
23679 + .len = sizeof(NAME) - 1, \
23680 + .name = (NAME), \
23688 +#define DIR(NAME, MODE, OTYPE) \
23689 + NOD(NAME, (S_IFDIR | (MODE)), \
23690 + &proc_ ## OTYPE ## _inode_operations, \
23691 + &proc_ ## OTYPE ## _file_operations, { } )
23693 +#define INF(NAME, MODE, OTYPE) \
23694 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23695 + &proc_vs_info_file_operations, \
23696 + { .proc_vs_read = &proc_##OTYPE } )
23698 +#define VINF(NAME, MODE, OTYPE) \
23699 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23700 + &proc_vx_info_file_operations, \
23701 + { .proc_vxi_read = &proc_##OTYPE } )
23703 +#define NINF(NAME, MODE, OTYPE) \
23704 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23705 + &proc_nx_info_file_operations, \
23706 + { .proc_nxi_read = &proc_##OTYPE } )
23709 +static struct file_operations proc_vs_info_file_operations = {
23710 + .read = proc_vs_info_read,
23713 +static struct file_operations proc_vx_info_file_operations = {
23714 + .read = proc_vx_info_read,
23717 +static struct dentry_operations proc_xid_dentry_operations = {
23718 + .d_revalidate = proc_xid_revalidate,
23721 +static struct vs_entry vx_base_stuff[] = {
23722 + VINF("info", S_IRUGO, vxi_info),
23723 + VINF("status", S_IRUGO, vxi_status),
23724 + VINF("limit", S_IRUGO, vxi_limit),
23725 + VINF("sched", S_IRUGO, vxi_sched),
23726 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23727 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23728 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23729 + VINF("cacct", S_IRUGO, vxi_cacct),
23736 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23737 + struct dentry *dentry, int id, void *ptr)
23739 + dentry->d_op = &proc_xid_dentry_operations;
23740 + return vs_proc_instantiate(dir, dentry, id, ptr);
23743 +static struct dentry *proc_xid_lookup(struct inode *dir,
23744 + struct dentry *dentry, struct nameidata *nd)
23746 + struct vs_entry *p = vx_base_stuff;
23747 + struct dentry *error = ERR_PTR(-ENOENT);
23749 + for (; p->name; p++) {
23750 + if (p->len != dentry->d_name.len)
23752 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23758 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23763 +static int proc_xid_readdir(struct file *filp,
23764 + void *dirent, filldir_t filldir)
23766 + struct dentry *dentry = filp->f_dentry;
23767 + struct inode *inode = dentry->d_inode;
23768 + struct vs_entry *p = vx_base_stuff;
23769 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23773 + pos = filp->f_pos;
23776 + ino = inode->i_ino;
23777 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23780 + /* fall through */
23782 + ino = parent_ino(dentry);
23783 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23786 + /* fall through */
23789 + if (index >= size)
23791 + for (p += index; p->name; p++) {
23792 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23793 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23799 + filp->f_pos = pos;
23805 +static struct file_operations proc_nx_info_file_operations = {
23806 + .read = proc_nx_info_read,
23809 +static struct dentry_operations proc_nid_dentry_operations = {
23810 + .d_revalidate = proc_nid_revalidate,
23813 +static struct vs_entry nx_base_stuff[] = {
23814 + NINF("info", S_IRUGO, nxi_info),
23815 + NINF("status", S_IRUGO, nxi_status),
23820 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23821 + struct dentry *dentry, int id, void *ptr)
23823 + dentry->d_op = &proc_nid_dentry_operations;
23824 + return vs_proc_instantiate(dir, dentry, id, ptr);
23827 +static struct dentry *proc_nid_lookup(struct inode *dir,
23828 + struct dentry *dentry, struct nameidata *nd)
23830 + struct vs_entry *p = nx_base_stuff;
23831 + struct dentry *error = ERR_PTR(-ENOENT);
23833 + for (; p->name; p++) {
23834 + if (p->len != dentry->d_name.len)
23836 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23842 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23847 +static int proc_nid_readdir(struct file *filp,
23848 + void *dirent, filldir_t filldir)
23850 + struct dentry *dentry = filp->f_dentry;
23851 + struct inode *inode = dentry->d_inode;
23852 + struct vs_entry *p = nx_base_stuff;
23853 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23857 + pos = filp->f_pos;
23860 + ino = inode->i_ino;
23861 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23864 + /* fall through */
23866 + ino = parent_ino(dentry);
23867 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23870 + /* fall through */
23873 + if (index >= size)
23875 + for (p += index; p->name; p++) {
23876 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23877 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23883 + filp->f_pos = pos;
23888 +#define MAX_MULBY10 ((~0U - 9) / 10)
23890 +static inline int atovid(const char *str, int len)
23895 + while (len-- > 0) {
23900 + if (vid >= MAX_MULBY10)
23910 +/* now the upper level (virtual) */
23913 +static struct file_operations proc_xid_file_operations = {
23914 + .read = generic_read_dir,
23915 + .readdir = proc_xid_readdir,
23918 +static struct inode_operations proc_xid_inode_operations = {
23919 + .lookup = proc_xid_lookup,
23922 +static struct vs_entry vx_virtual_stuff[] = {
23923 + INF("info", S_IRUGO, virtual_info),
23924 + INF("status", S_IRUGO, virtual_status),
23925 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23929 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23930 + struct dentry *dentry, struct nameidata *nd)
23932 + struct vs_entry *p = vx_virtual_stuff;
23933 + struct dentry *error = ERR_PTR(-ENOENT);
23936 + for (; p->name; p++) {
23937 + if (p->len != dentry->d_name.len)
23939 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23943 + goto instantiate;
23945 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23946 + if ((id < 0) || !xid_is_hashed(id))
23950 + error = proc_xid_instantiate(dir, dentry, id, p);
23955 +static struct file_operations proc_nid_file_operations = {
23956 + .read = generic_read_dir,
23957 + .readdir = proc_nid_readdir,
23960 +static struct inode_operations proc_nid_inode_operations = {
23961 + .lookup = proc_nid_lookup,
23964 +static struct vs_entry nx_virtnet_stuff[] = {
23965 + INF("info", S_IRUGO, virtnet_info),
23966 + INF("status", S_IRUGO, virtnet_status),
23967 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
23971 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
23972 + struct dentry *dentry, struct nameidata *nd)
23974 + struct vs_entry *p = nx_virtnet_stuff;
23975 + struct dentry *error = ERR_PTR(-ENOENT);
23978 + for (; p->name; p++) {
23979 + if (p->len != dentry->d_name.len)
23981 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23985 + goto instantiate;
23987 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23988 + if ((id < 0) || !nid_is_hashed(id))
23992 + error = proc_nid_instantiate(dir, dentry, id, p);
23998 +#define PROC_MAXVIDS 32
24000 +int proc_virtual_readdir(struct file *filp,
24001 + void *dirent, filldir_t filldir)
24003 + struct dentry *dentry = filp->f_dentry;
24004 + struct inode *inode = dentry->d_inode;
24005 + struct vs_entry *p = vx_virtual_stuff;
24006 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
24008 + unsigned int xid_array[PROC_MAXVIDS];
24009 + char buf[PROC_NUMBUF];
24010 + unsigned int nr_xids, i;
24013 + pos = filp->f_pos;
24016 + ino = inode->i_ino;
24017 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24020 + /* fall through */
24022 + ino = parent_ino(dentry);
24023 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24026 + /* fall through */
24029 + if (index >= size)
24031 + for (p += index; p->name; p++) {
24032 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24033 + vs_proc_instantiate, 0, p))
24038 + index = pos - size;
24039 + p = &vx_virtual_stuff[size - 1];
24040 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
24041 + for (i = 0; i < nr_xids; i++) {
24042 + int n, xid = xid_array[i];
24043 + unsigned int j = PROC_NUMBUF;
24047 + buf[--j] = '0' + (n % 10);
24050 + if (proc_fill_cache(filp, dirent, filldir,
24051 + buf + j, PROC_NUMBUF - j,
24052 + vs_proc_instantiate, xid, p))
24058 + filp->f_pos = pos;
24062 +static int proc_virtual_getattr(struct vfsmount *mnt,
24063 + struct dentry *dentry, struct kstat *stat)
24065 + struct inode *inode = dentry->d_inode;
24067 + generic_fillattr(inode, stat);
24068 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
24072 +static struct file_operations proc_virtual_dir_operations = {
24073 + .read = generic_read_dir,
24074 + .readdir = proc_virtual_readdir,
24077 +static struct inode_operations proc_virtual_dir_inode_operations = {
24078 + .getattr = proc_virtual_getattr,
24079 + .lookup = proc_virtual_lookup,
24086 +int proc_virtnet_readdir(struct file *filp,
24087 + void *dirent, filldir_t filldir)
24089 + struct dentry *dentry = filp->f_dentry;
24090 + struct inode *inode = dentry->d_inode;
24091 + struct vs_entry *p = nx_virtnet_stuff;
24092 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
24094 + unsigned int nid_array[PROC_MAXVIDS];
24095 + char buf[PROC_NUMBUF];
24096 + unsigned int nr_nids, i;
24099 + pos = filp->f_pos;
24102 + ino = inode->i_ino;
24103 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24106 + /* fall through */
24108 + ino = parent_ino(dentry);
24109 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24112 + /* fall through */
24115 + if (index >= size)
24117 + for (p += index; p->name; p++) {
24118 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24119 + vs_proc_instantiate, 0, p))
24124 + index = pos - size;
24125 + p = &nx_virtnet_stuff[size - 1];
24126 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
24127 + for (i = 0; i < nr_nids; i++) {
24128 + int n, nid = nid_array[i];
24129 + unsigned int j = PROC_NUMBUF;
24133 + buf[--j] = '0' + (n % 10);
24136 + if (proc_fill_cache(filp, dirent, filldir,
24137 + buf + j, PROC_NUMBUF - j,
24138 + vs_proc_instantiate, nid, p))
24144 + filp->f_pos = pos;
24148 +static int proc_virtnet_getattr(struct vfsmount *mnt,
24149 + struct dentry *dentry, struct kstat *stat)
24151 + struct inode *inode = dentry->d_inode;
24153 + generic_fillattr(inode, stat);
24154 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
24158 +static struct file_operations proc_virtnet_dir_operations = {
24159 + .read = generic_read_dir,
24160 + .readdir = proc_virtnet_readdir,
24163 +static struct inode_operations proc_virtnet_dir_inode_operations = {
24164 + .getattr = proc_virtnet_getattr,
24165 + .lookup = proc_virtnet_lookup,
24170 +void proc_vx_init(void)
24172 + struct proc_dir_entry *ent;
24174 + ent = proc_mkdir("virtual", 0);
24176 + ent->proc_fops = &proc_virtual_dir_operations;
24177 + ent->proc_iops = &proc_virtual_dir_inode_operations;
24179 + proc_virtual = ent;
24181 + ent = proc_mkdir("virtnet", 0);
24183 + ent->proc_fops = &proc_virtnet_dir_operations;
24184 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
24186 + proc_virtnet = ent;
24192 +/* per pid info */
24195 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
24197 + struct vx_info *vxi;
24198 + char *orig = buffer;
24200 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
24202 + vxi = task_get_vx_info(p);
24206 + buffer += sprintf(buffer, "BCaps:\t");
24207 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
24208 + buffer += sprintf(buffer, "\n");
24209 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
24210 + (unsigned long long)vxi->vx_ccaps);
24211 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
24212 + (unsigned long long)vxi->vx_flags);
24213 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
24215 + put_vx_info(vxi);
24217 + return buffer - orig;
24221 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
24223 + struct nx_info *nxi;
24224 + struct nx_addr_v4 *v4a;
24225 +#ifdef CONFIG_IPV6
24226 + struct nx_addr_v6 *v6a;
24228 + char *orig = buffer;
24231 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24233 + nxi = task_get_nx_info(p);
24237 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24238 + (unsigned long long)nxi->nx_ncaps);
24239 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24240 + (unsigned long long)nxi->nx_flags);
24242 + buffer += sprintf(buffer,
24243 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24244 + NIPQUAD(nxi->v4_bcast.s_addr));
24245 + buffer += sprintf (buffer,
24246 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
24247 + NIPQUAD(nxi->v4_lback.s_addr));
24248 + if (!NX_IPV4(nxi))
24250 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24251 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
24254 +#ifdef CONFIG_IPV6
24255 + if (!NX_IPV6(nxi))
24257 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24258 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24262 + put_nx_info(nxi);
24264 + return buffer - orig;
24267 diff -NurpP --minimal linux-2.6.35/kernel/vserver/sched.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sched.c
24268 --- linux-2.6.35/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
24269 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sched.c 2010-08-02 17:05:06.000000000 +0200
24272 + * linux/kernel/vserver/sched.c
24274 + * Virtual Server: Scheduler Support
24276 + * Copyright (C) 2004-2007 Herbert Pötzl
24278 + * V0.01 adapted Sam Vilains version to 2.6.3
24279 + * V0.02 removed legacy interface
24280 + * V0.03 changed vcmds to vxi arg
24281 + * V0.04 removed older and legacy interfaces
24285 +#include <linux/vs_context.h>
24286 +#include <linux/vs_sched.h>
24287 +#include <linux/vserver/sched_cmd.h>
24289 +#include <asm/uaccess.h>
24292 +#define vxd_check_range(val, min, max) do { \
24293 + vxlprintk((val < min) || (val > max), \
24294 + "check_range(%ld,%ld,%ld)", \
24295 + (long)val, (long)min, (long)max, \
24296 + __FILE__, __LINE__); \
24300 +void vx_update_sched_param(struct _vx_sched *sched,
24301 + struct _vx_sched_pc *sched_pc)
24303 + unsigned int set_mask = sched->update_mask;
24305 + if (set_mask & VXSM_FILL_RATE)
24306 + sched_pc->fill_rate[0] = sched->fill_rate[0];
24307 + if (set_mask & VXSM_INTERVAL)
24308 + sched_pc->interval[0] = sched->interval[0];
24309 + if (set_mask & VXSM_FILL_RATE2)
24310 + sched_pc->fill_rate[1] = sched->fill_rate[1];
24311 + if (set_mask & VXSM_INTERVAL2)
24312 + sched_pc->interval[1] = sched->interval[1];
24313 + if (set_mask & VXSM_TOKENS)
24314 + sched_pc->tokens = sched->tokens;
24315 + if (set_mask & VXSM_TOKENS_MIN)
24316 + sched_pc->tokens_min = sched->tokens_min;
24317 + if (set_mask & VXSM_TOKENS_MAX)
24318 + sched_pc->tokens_max = sched->tokens_max;
24319 + if (set_mask & VXSM_PRIO_BIAS)
24320 + sched_pc->prio_bias = sched->prio_bias;
24322 + if (set_mask & VXSM_IDLE_TIME)
24323 + sched_pc->flags |= VXSF_IDLE_TIME;
24325 + sched_pc->flags &= ~VXSF_IDLE_TIME;
24328 + sched_pc->norm_time = jiffies;
24333 + * recalculate the context's scheduling tokens
24335 + * ret > 0 : number of tokens available
24336 + * ret < 0 : on hold, check delta_min[]
24337 + * -1 only jiffies
24338 + * -2 also idle time
24341 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
24342 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
24346 + int flags = sched_pc->flags;
24348 + /* how much time did pass? */
24349 + delta = *norm_time - sched_pc->norm_time;
24350 + // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
24351 + vxd_check_range(delta, 0, INT_MAX);
24353 + if (delta >= sched_pc->interval[0]) {
24354 + long tokens, integral;
24356 + /* calc integral token part */
24357 + tokens = delta / sched_pc->interval[0];
24358 + integral = tokens * sched_pc->interval[0];
24359 + tokens *= sched_pc->fill_rate[0];
24360 +#ifdef CONFIG_VSERVER_HARDCPU
24361 + delta_min[0] = delta - integral;
24362 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
24364 + /* advance time */
24365 + sched_pc->norm_time += delta;
24368 + sched_pc->tokens += tokens;
24369 + sched_pc->token_time += tokens;
24371 + delta_min[0] = delta;
24373 +#ifdef CONFIG_VSERVER_IDLETIME
24374 + if (!(flags & VXSF_IDLE_TIME))
24377 + /* how much was the idle skip? */
24378 + delta = *idle_time - sched_pc->idle_time;
24379 + vxd_check_range(delta, 0, INT_MAX);
24381 + if (delta >= sched_pc->interval[1]) {
24382 + long tokens, integral;
24384 + /* calc fair share token part */
24385 + tokens = delta / sched_pc->interval[1];
24386 + integral = tokens * sched_pc->interval[1];
24387 + tokens *= sched_pc->fill_rate[1];
24388 + delta_min[1] = delta - integral;
24389 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
24391 + /* advance idle time */
24392 + sched_pc->idle_time += integral;
24395 + sched_pc->tokens += tokens;
24396 + sched_pc->token_time += tokens;
24398 + delta_min[1] = delta;
24402 + /* clip at maximum */
24403 + if (sched_pc->tokens > sched_pc->tokens_max)
24404 + sched_pc->tokens = sched_pc->tokens_max;
24405 + tokens = sched_pc->tokens;
24407 + if ((flags & VXSF_ONHOLD)) {
24408 + /* can we unhold? */
24409 + if (tokens >= sched_pc->tokens_min) {
24410 + flags &= ~VXSF_ONHOLD;
24411 + sched_pc->hold_ticks +=
24412 + *norm_time - sched_pc->onhold;
24416 + /* put on hold? */
24417 + if (tokens <= 0) {
24418 + flags |= VXSF_ONHOLD;
24419 + sched_pc->onhold = *norm_time;
24423 + sched_pc->flags = flags;
24427 + tokens = sched_pc->tokens_min - tokens;
24428 + sched_pc->flags = flags;
24429 + // BUG_ON(tokens < 0); probably doesn't hold anymore
24431 +#ifdef CONFIG_VSERVER_HARDCPU
24432 + /* next interval? */
24433 + if (!sched_pc->fill_rate[0])
24434 + delta_min[0] = HZ;
24435 + else if (tokens > sched_pc->fill_rate[0])
24436 + delta_min[0] += sched_pc->interval[0] *
24437 + tokens / sched_pc->fill_rate[0];
24439 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
24440 + vxd_check_range(delta_min[0], 0, INT_MAX);
24442 +#ifdef CONFIG_VSERVER_IDLETIME
24443 + if (!(flags & VXSF_IDLE_TIME))
24446 + /* next interval? */
24447 + if (!sched_pc->fill_rate[1])
24448 + delta_min[1] = HZ;
24449 + else if (tokens > sched_pc->fill_rate[1])
24450 + delta_min[1] += sched_pc->interval[1] *
24451 + tokens / sched_pc->fill_rate[1];
24453 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
24454 + vxd_check_range(delta_min[1], 0, INT_MAX);
24459 +#endif /* CONFIG_VSERVER_IDLETIME */
24462 +#endif /* CONFIG_VSERVER_HARDCPU */
24465 +static inline unsigned long msec_to_ticks(unsigned long msec)
24467 + return msecs_to_jiffies(msec);
24470 +static inline unsigned long ticks_to_msec(unsigned long ticks)
24472 + return jiffies_to_msecs(ticks);
24475 +static inline unsigned long ticks_to_usec(unsigned long ticks)
24477 + return jiffies_to_usecs(ticks);
24481 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
24483 + unsigned int set_mask = data->mask;
24484 + unsigned int update_mask;
24487 + /* Sanity check data values */
24488 + if (data->tokens_max <= 0)
24489 + data->tokens_max = HZ;
24490 + if (data->tokens_min < 0)
24491 + data->tokens_min = HZ / 3;
24492 + if (data->tokens_min >= data->tokens_max)
24493 + data->tokens_min = data->tokens_max;
24495 + if (data->prio_bias > MAX_PRIO_BIAS)
24496 + data->prio_bias = MAX_PRIO_BIAS;
24497 + if (data->prio_bias < MIN_PRIO_BIAS)
24498 + data->prio_bias = MIN_PRIO_BIAS;
24500 + spin_lock(&vxi->sched.tokens_lock);
24502 + /* sync up on delayed updates */
24503 + for_each_cpu_mask(cpu, vxi->sched.update)
24504 + vx_update_sched_param(&vxi->sched,
24505 + &vx_per_cpu(vxi, sched_pc, cpu));
24507 + if (set_mask & VXSM_FILL_RATE)
24508 + vxi->sched.fill_rate[0] = data->fill_rate[0];
24509 + if (set_mask & VXSM_FILL_RATE2)
24510 + vxi->sched.fill_rate[1] = data->fill_rate[1];
24511 + if (set_mask & VXSM_INTERVAL)
24512 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
24513 + msec_to_ticks(data->interval[0]) : data->interval[0];
24514 + if (set_mask & VXSM_INTERVAL2)
24515 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
24516 + msec_to_ticks(data->interval[1]) : data->interval[1];
24517 + if (set_mask & VXSM_TOKENS)
24518 + vxi->sched.tokens = data->tokens;
24519 + if (set_mask & VXSM_TOKENS_MIN)
24520 + vxi->sched.tokens_min = data->tokens_min;
24521 + if (set_mask & VXSM_TOKENS_MAX)
24522 + vxi->sched.tokens_max = data->tokens_max;
24523 + if (set_mask & VXSM_PRIO_BIAS)
24524 + vxi->sched.prio_bias = data->prio_bias;
24526 + /* Sanity check rate/interval */
24527 + for (i = 0; i < 2; i++) {
24528 + if (data->fill_rate[i] < 0)
24529 + data->fill_rate[i] = 0;
24530 + if (data->interval[i] <= 0)
24531 + data->interval[i] = HZ;
24534 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
24535 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
24536 + vxi->sched.update_mask = update_mask;
24540 + if (set_mask & VXSM_CPU_ID) {
24541 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24542 + cpus_and(vxi->sched.update, cpu_online_map,
24543 + vxi->sched.update);
24545 + vxi->sched.update = cpu_online_map;
24547 + /* forced reload? */
24548 + if (set_mask & VXSM_FORCE) {
24549 + for_each_cpu_mask(cpu, vxi->sched.update)
24550 + vx_update_sched_param(&vxi->sched,
24551 + &vx_per_cpu(vxi, sched_pc, cpu));
24552 + vxi->sched.update = CPU_MASK_NONE;
24555 + /* on UP we update immediately */
24556 + vx_update_sched_param(&vxi->sched,
24557 + &vx_per_cpu(vxi, sched_pc, 0));
24560 + spin_unlock(&vxi->sched.tokens_lock);
24565 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
24566 +#define COPY_PRI(C) C(prio_bias)
24567 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24568 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24569 + C(fill_rate[1]); C(interval[1]);
24571 +#define COPY_VALUE(name) vc_data.name = data->name
24573 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
24575 + struct vcmd_sched_v5 vc_data;
24577 + vc_data.mask = data->set_mask;
24578 + COPY_IDS(COPY_VALUE);
24579 + COPY_PRI(COPY_VALUE);
24580 + COPY_TOK(COPY_VALUE);
24581 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
24582 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
24583 + return do_set_sched(vxi, &vc_data);
24586 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
24588 + struct vcmd_set_sched_v4 vc_data;
24590 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24593 + return do_set_sched_v4(vxi, &vc_data);
24596 + /* latest interface is v5 */
24598 +int vc_set_sched(struct vx_info *vxi, void __user *data)
24600 + struct vcmd_sched_v5 vc_data;
24602 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24605 + return do_set_sched(vxi, &vc_data);
24609 +#define COPY_PRI(C) C(prio_bias)
24610 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24611 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24612 + C(fill_rate[1]); C(interval[1]);
24614 +#define COPY_VALUE(name) vc_data.name = data->name
24617 +int vc_get_sched(struct vx_info *vxi, void __user *data)
24619 + struct vcmd_sched_v5 vc_data;
24621 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24624 + if (vc_data.mask & VXSM_CPU_ID) {
24625 + int cpu = vc_data.cpu_id;
24626 + struct _vx_sched_pc *data;
24628 + if (!cpu_possible(cpu))
24631 + data = &vx_per_cpu(vxi, sched_pc, cpu);
24632 + COPY_TOK(COPY_VALUE);
24633 + COPY_PRI(COPY_VALUE);
24634 + COPY_FRI(COPY_VALUE);
24636 + if (data->flags & VXSF_IDLE_TIME)
24637 + vc_data.mask |= VXSM_IDLE_TIME;
24639 + struct _vx_sched *data = &vxi->sched;
24641 + COPY_TOK(COPY_VALUE);
24642 + COPY_PRI(COPY_VALUE);
24643 + COPY_FRI(COPY_VALUE);
24646 + if (vc_data.mask & VXSM_MSEC) {
24647 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
24648 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
24651 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24657 +int vc_sched_info(struct vx_info *vxi, void __user *data)
24659 + struct vcmd_sched_info vc_data;
24662 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24665 + cpu = vc_data.cpu_id;
24666 + if (!cpu_possible(cpu))
24670 + struct _vx_sched_pc *sched_pc =
24671 + &vx_per_cpu(vxi, sched_pc, cpu);
24673 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
24674 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
24675 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
24676 + vc_data.vavavoom = sched_pc->vavavoom;
24678 + vc_data.token_usec = ticks_to_usec(1);
24680 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24685 diff -NurpP --minimal linux-2.6.35/kernel/vserver/sched_init.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sched_init.h
24686 --- linux-2.6.35/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
24687 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sched_init.h 2010-08-02 17:05:06.000000000 +0200
24690 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24692 + static struct lock_class_key tokens_lock_key;
24694 + /* scheduling; hard code starting values as constants */
24695 + sched->fill_rate[0] = 1;
24696 + sched->interval[0] = 4;
24697 + sched->fill_rate[1] = 1;
24698 + sched->interval[1] = 8;
24699 + sched->tokens = HZ >> 2;
24700 + sched->tokens_min = HZ >> 4;
24701 + sched->tokens_max = HZ >> 1;
24702 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
24703 + sched->prio_bias = 0;
24705 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24709 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24711 + sched_pc->fill_rate[0] = 1;
24712 + sched_pc->interval[0] = 4;
24713 + sched_pc->fill_rate[1] = 1;
24714 + sched_pc->interval[1] = 8;
24715 + sched_pc->tokens = HZ >> 2;
24716 + sched_pc->tokens_min = HZ >> 4;
24717 + sched_pc->tokens_max = HZ >> 1;
24718 + sched_pc->prio_bias = 0;
24719 + sched_pc->vavavoom = 0;
24720 + sched_pc->token_time = 0;
24721 + sched_pc->idle_time = 0;
24722 + sched_pc->norm_time = jiffies;
24724 + sched_pc->user_ticks = 0;
24725 + sched_pc->sys_ticks = 0;
24726 + sched_pc->hold_ticks = 0;
24729 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24735 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24739 diff -NurpP --minimal linux-2.6.35/kernel/vserver/sched_proc.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sched_proc.h
24740 --- linux-2.6.35/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
24741 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sched_proc.h 2010-08-02 17:05:06.000000000 +0200
24743 +#ifndef _VX_SCHED_PROC_H
24744 +#define _VX_SCHED_PROC_H
24748 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24752 + length += sprintf(buffer,
24753 + "FillRate:\t%8d,%d\n"
24754 + "Interval:\t%8d,%d\n"
24755 + "TokensMin:\t%8d\n"
24756 + "TokensMax:\t%8d\n"
24757 + "PrioBias:\t%8d\n",
24758 + sched->fill_rate[0],
24759 + sched->fill_rate[1],
24760 + sched->interval[0],
24761 + sched->interval[1],
24762 + sched->tokens_min,
24763 + sched->tokens_max,
24764 + sched->prio_bias);
24769 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24770 + char *buffer, int cpu)
24774 + length += sprintf(buffer + length,
24775 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
24776 + (unsigned long long)sched_pc->user_ticks,
24777 + (unsigned long long)sched_pc->sys_ticks,
24778 + (unsigned long long)sched_pc->hold_ticks,
24779 + sched_pc->token_time,
24780 + sched_pc->idle_time);
24781 + length += sprintf(buffer + length,
24782 + " %c%c %d %d %d %d/%d %d/%d",
24783 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24784 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24785 + sched_pc->tokens,
24786 + sched_pc->tokens_min,
24787 + sched_pc->tokens_max,
24788 + sched_pc->fill_rate[0],
24789 + sched_pc->interval[0],
24790 + sched_pc->fill_rate[1],
24791 + sched_pc->interval[1]);
24792 + length += sprintf(buffer + length,
24794 + sched_pc->prio_bias,
24795 + sched_pc->vavavoom);
24799 +#endif /* _VX_SCHED_PROC_H */
24800 diff -NurpP --minimal linux-2.6.35/kernel/vserver/signal.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/signal.c
24801 --- linux-2.6.35/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
24802 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/signal.c 2010-08-02 17:05:06.000000000 +0200
24805 + * linux/kernel/vserver/signal.c
24807 + * Virtual Server: Signal Support
24809 + * Copyright (C) 2003-2007 Herbert Pötzl
24811 + * V0.01 broken out from vcontext V0.05
24812 + * V0.02 changed vcmds to vxi arg
24813 + * V0.03 adjusted siginfo for kill
24817 +#include <asm/uaccess.h>
24819 +#include <linux/vs_context.h>
24820 +#include <linux/vs_pid.h>
24821 +#include <linux/vserver/signal_cmd.h>
24824 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24826 + int retval, count = 0;
24827 + struct task_struct *p;
24828 + struct siginfo *sip = SEND_SIG_PRIV;
24831 + vxdprintk(VXD_CBIT(misc, 4),
24832 + "vx_info_kill(%p[#%d],%d,%d)*",
24833 + vxi, vxi->vx_id, pid, sig);
24834 + read_lock(&tasklist_lock);
24838 + for_each_process(p) {
24841 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24842 + (pid && vxi->vx_initpid == p->pid))
24845 + err = group_send_sig_info(sig, sip, p);
24847 + if (err != -EPERM)
24853 + if (vxi->vx_initpid) {
24854 + pid = vxi->vx_initpid;
24855 + /* for now, only SIGINT to private init ... */
24856 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24857 + /* ... as long as there are tasks left */
24858 + (atomic_read(&vxi->vx_tasks) > 1))
24861 + /* fallthrough */
24863 + p = find_task_by_real_pid(pid);
24865 + if (vx_task_xid(p) == vxi->vx_id)
24866 + retval = group_send_sig_info(sig, sip, p);
24870 + read_unlock(&tasklist_lock);
24871 + vxdprintk(VXD_CBIT(misc, 4),
24872 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24873 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24877 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24879 + struct vcmd_ctx_kill_v0 vc_data;
24881 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24884 + /* special check to allow guest shutdown */
24885 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24886 + /* forbid killall pid=0 when init is present */
24887 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24888 + (vc_data.pid > 1)))
24891 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24895 +static int __wait_exit(struct vx_info *vxi)
24897 + DECLARE_WAITQUEUE(wait, current);
24900 + add_wait_queue(&vxi->vx_wait, &wait);
24901 + set_current_state(TASK_INTERRUPTIBLE);
24904 + if (vx_info_state(vxi,
24905 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24907 + if (signal_pending(current)) {
24908 + ret = -ERESTARTSYS;
24915 + set_current_state(TASK_RUNNING);
24916 + remove_wait_queue(&vxi->vx_wait, &wait);
24922 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24924 + struct vcmd_wait_exit_v0 vc_data;
24927 + ret = __wait_exit(vxi);
24928 + vc_data.reboot_cmd = vxi->reboot_cmd;
24929 + vc_data.exit_code = vxi->exit_code;
24931 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24936 diff -NurpP --minimal linux-2.6.35/kernel/vserver/space.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/space.c
24937 --- linux-2.6.35/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
24938 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/space.c 2010-08-02 17:05:06.000000000 +0200
24941 + * linux/kernel/vserver/space.c
24943 + * Virtual Server: Context Space Support
24945 + * Copyright (C) 2003-2007 Herbert Pötzl
24947 + * V0.01 broken out from context.c 0.07
24948 + * V0.02 added task locking for namespace
24949 + * V0.03 broken out vx_enter_namespace
24950 + * V0.04 added *space support and commands
24954 +#include <linux/utsname.h>
24955 +#include <linux/nsproxy.h>
24956 +#include <linux/err.h>
24957 +#include <linux/fs_struct.h>
24958 +#include <asm/uaccess.h>
24960 +#include <linux/vs_context.h>
24961 +#include <linux/vserver/space.h>
24962 +#include <linux/vserver/space_cmd.h>
24964 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
24965 +atomic_t vs_global_fs = ATOMIC_INIT(0);
24966 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
24967 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
24968 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
24969 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
24972 +/* namespace functions */
24974 +#include <linux/mnt_namespace.h>
24975 +#include <linux/user_namespace.h>
24976 +#include <linux/pid_namespace.h>
24977 +#include <linux/ipc_namespace.h>
24978 +#include <net/net_namespace.h>
24981 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
24982 + .mask = CLONE_FS |
24990 +static const struct vcmd_space_mask_v1 space_mask = {
24991 + .mask = CLONE_FS |
24996 +#ifdef CONFIG_PID_NS
24999 +#ifdef CONFIG_NET_NS
25005 +static const struct vcmd_space_mask_v1 default_space_mask = {
25006 + .mask = CLONE_FS |
25011 +#ifdef CONFIG_PID_NS
25018 + * build a new nsproxy mix
25019 + * assumes that both proxies are 'const'
25020 + * does not touch nsproxy refcounts
25021 + * will hold a reference on the result.
25024 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
25025 + struct nsproxy *new_nsproxy, unsigned long mask)
25027 + struct mnt_namespace *old_ns;
25028 + struct uts_namespace *old_uts;
25029 + struct ipc_namespace *old_ipc;
25030 +#ifdef CONFIG_PID_NS
25031 + struct pid_namespace *old_pid;
25033 +#ifdef CONFIG_NET_NS
25034 + struct net *old_net;
25036 + struct nsproxy *nsproxy;
25038 + nsproxy = copy_nsproxy(old_nsproxy);
25042 + if (mask & CLONE_NEWNS) {
25043 + old_ns = nsproxy->mnt_ns;
25044 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
25045 + if (nsproxy->mnt_ns)
25046 + get_mnt_ns(nsproxy->mnt_ns);
25050 + if (mask & CLONE_NEWUTS) {
25051 + old_uts = nsproxy->uts_ns;
25052 + nsproxy->uts_ns = new_nsproxy->uts_ns;
25053 + if (nsproxy->uts_ns)
25054 + get_uts_ns(nsproxy->uts_ns);
25058 + if (mask & CLONE_NEWIPC) {
25059 + old_ipc = nsproxy->ipc_ns;
25060 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
25061 + if (nsproxy->ipc_ns)
25062 + get_ipc_ns(nsproxy->ipc_ns);
25066 +#ifdef CONFIG_PID_NS
25067 + if (mask & CLONE_NEWPID) {
25068 + old_pid = nsproxy->pid_ns;
25069 + nsproxy->pid_ns = new_nsproxy->pid_ns;
25070 + if (nsproxy->pid_ns)
25071 + get_pid_ns(nsproxy->pid_ns);
25075 +#ifdef CONFIG_NET_NS
25076 + if (mask & CLONE_NEWNET) {
25077 + old_net = nsproxy->net_ns;
25078 + nsproxy->net_ns = new_nsproxy->net_ns;
25079 + if (nsproxy->net_ns)
25080 + get_net(nsproxy->net_ns);
25085 + put_mnt_ns(old_ns);
25087 + put_uts_ns(old_uts);
25089 + put_ipc_ns(old_ipc);
25090 +#ifdef CONFIG_PID_NS
25092 + put_pid_ns(old_pid);
25094 +#ifdef CONFIG_NET_NS
25096 + put_net(old_net);
25104 + * merge two nsproxy structs into a new one.
25105 + * will hold a reference on the result.
25109 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
25110 + struct nsproxy *proxy, unsigned long mask)
25112 + struct nsproxy null_proxy = { .mnt_ns = NULL };
25118 + /* vs_mix_nsproxy returns with reference */
25119 + return vs_mix_nsproxy(old ? old : &null_proxy,
25122 + get_nsproxy(proxy);
25127 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25129 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
25130 + struct fs_struct *fs_cur, *fs = NULL;
25131 + int ret, kill = 0;
25133 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
25134 + vxi, vxi->vx_id, mask, index);
25136 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
25140 + mask = vxi->vx_nsmask[index];
25142 + if ((mask & vxi->vx_nsmask[index]) != mask)
25145 + if (mask & CLONE_FS) {
25146 + fs = copy_fs_struct(vxi->vx_fs[index]);
25150 + proxy = vxi->vx_nsproxy[index];
25152 + vxdprintk(VXD_CBIT(space, 9),
25153 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
25154 + vxi, vxi->vx_id, mask, index, proxy, fs);
25156 + task_lock(current);
25157 + fs_cur = current->fs;
25159 + if (mask & CLONE_FS) {
25160 + write_lock(&fs_cur->lock);
25161 + current->fs = fs;
25162 + kill = !--fs_cur->users;
25163 + write_unlock(&fs_cur->lock);
25166 + proxy_cur = current->nsproxy;
25167 + get_nsproxy(proxy_cur);
25168 + task_unlock(current);
25171 + free_fs_struct(fs_cur);
25173 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
25174 + if (IS_ERR(proxy_new)) {
25175 + ret = PTR_ERR(proxy_new);
25179 + proxy_new = xchg(¤t->nsproxy, proxy_new);
25183 + put_nsproxy(proxy_new);
25186 + put_nsproxy(proxy_cur);
25191 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25193 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
25194 + struct fs_struct *fs_vxi, *fs;
25195 + int ret, kill = 0;
25197 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
25198 + vxi, vxi->vx_id, mask, index);
25201 + mask = default_space_mask.mask;
25203 + if ((mask & space_mask.mask) != mask)
25206 + proxy_vxi = vxi->vx_nsproxy[index];
25207 + fs_vxi = vxi->vx_fs[index];
25209 + if (mask & CLONE_FS) {
25210 + fs = copy_fs_struct(current->fs);
25215 + task_lock(current);
25217 + if (mask & CLONE_FS) {
25218 + write_lock(&fs_vxi->lock);
25219 + vxi->vx_fs[index] = fs;
25220 + kill = !--fs_vxi->users;
25221 + write_unlock(&fs_vxi->lock);
25224 + proxy_cur = current->nsproxy;
25225 + get_nsproxy(proxy_cur);
25226 + task_unlock(current);
25229 + free_fs_struct(fs_vxi);
25231 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
25232 + if (IS_ERR(proxy_new)) {
25233 + ret = PTR_ERR(proxy_new);
25237 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
25238 + vxi->vx_nsmask[index] |= mask;
25242 + put_nsproxy(proxy_new);
25245 + put_nsproxy(proxy_cur);
25250 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
25252 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25254 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25257 + return vx_enter_space(vxi, vc_data.mask, 0);
25260 +int vc_enter_space(struct vx_info *vxi, void __user *data)
25262 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25264 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25267 + if (vc_data.index >= VX_SPACES)
25270 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
25273 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
25275 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25277 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25280 + return vx_set_space(vxi, vc_data.mask, 0);
25283 +int vc_set_space(struct vx_info *vxi, void __user *data)
25285 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25287 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25290 + if (vc_data.index >= VX_SPACES)
25293 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
25296 +int vc_get_space_mask(void __user *data, int type)
25298 + const struct vcmd_space_mask_v1 *mask;
25301 + mask = &space_mask_v0;
25302 + else if (type == 1)
25303 + mask = &space_mask;
25305 + mask = &default_space_mask;
25307 + vxdprintk(VXD_CBIT(space, 10),
25308 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
25310 + if (copy_to_user(data, mask, sizeof(*mask)))
25315 diff -NurpP --minimal linux-2.6.35/kernel/vserver/switch.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/switch.c
25316 --- linux-2.6.35/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
25317 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/switch.c 2010-08-02 17:05:06.000000000 +0200
25320 + * linux/kernel/vserver/switch.c
25322 + * Virtual Server: Syscall Switch
25324 + * Copyright (C) 2003-2007 Herbert Pötzl
25326 + * V0.01 syscall switch
25327 + * V0.02 added signal to context
25328 + * V0.03 added rlimit functions
25329 + * V0.04 added iattr, task/xid functions
25330 + * V0.05 added debug/history stuff
25331 + * V0.06 added compat32 layer
25332 + * V0.07 vcmd args and perms
25333 + * V0.08 added status commands
25334 + * V0.09 added tag commands
25335 + * V0.10 added oom bias
25336 + * V0.11 added device commands
25340 +#include <linux/vs_context.h>
25341 +#include <linux/vs_network.h>
25342 +#include <linux/vserver/switch.h>
25344 +#include "vci_config.h"
25348 +int vc_get_version(uint32_t id)
25350 + return VCI_VERSION;
25354 +int vc_get_vci(uint32_t id)
25356 + return vci_kernel_config();
25359 +#include <linux/vserver/context_cmd.h>
25360 +#include <linux/vserver/cvirt_cmd.h>
25361 +#include <linux/vserver/cacct_cmd.h>
25362 +#include <linux/vserver/limit_cmd.h>
25363 +#include <linux/vserver/network_cmd.h>
25364 +#include <linux/vserver/sched_cmd.h>
25365 +#include <linux/vserver/debug_cmd.h>
25366 +#include <linux/vserver/inode_cmd.h>
25367 +#include <linux/vserver/dlimit_cmd.h>
25368 +#include <linux/vserver/signal_cmd.h>
25369 +#include <linux/vserver/space_cmd.h>
25370 +#include <linux/vserver/tag_cmd.h>
25371 +#include <linux/vserver/device_cmd.h>
25373 +#include <linux/vserver/inode.h>
25374 +#include <linux/vserver/dlimit.h>
25377 +#ifdef CONFIG_COMPAT
25378 +#define __COMPAT(name, id, data, compat) \
25379 + (compat) ? name ## _x32(id, data) : name(id, data)
25380 +#define __COMPAT_NO_ID(name, data, compat) \
25381 + (compat) ? name ## _x32(data) : name(data)
25383 +#define __COMPAT(name, id, data, compat) \
25385 +#define __COMPAT_NO_ID(name, data, compat) \
25391 +long do_vcmd(uint32_t cmd, uint32_t id,
25392 + struct vx_info *vxi, struct nx_info *nxi,
25393 + void __user *data, int compat)
25397 + case VCMD_get_version:
25398 + return vc_get_version(id);
25399 + case VCMD_get_vci:
25400 + return vc_get_vci(id);
25402 + case VCMD_task_xid:
25403 + return vc_task_xid(id);
25404 + case VCMD_vx_info:
25405 + return vc_vx_info(vxi, data);
25407 + case VCMD_task_nid:
25408 + return vc_task_nid(id);
25409 + case VCMD_nx_info:
25410 + return vc_nx_info(nxi, data);
25412 + case VCMD_task_tag:
25413 + return vc_task_tag(id);
25415 + case VCMD_set_space_v1:
25416 + return vc_set_space_v1(vxi, data);
25417 + /* this is version 2 */
25418 + case VCMD_set_space:
25419 + return vc_set_space(vxi, data);
25421 + case VCMD_get_space_mask_v0:
25422 + return vc_get_space_mask(data, 0);
25423 + /* this is version 1 */
25424 + case VCMD_get_space_mask:
25425 + return vc_get_space_mask(data, 1);
25427 + case VCMD_get_space_default:
25428 + return vc_get_space_mask(data, -1);
25430 +#ifdef CONFIG_IA32_EMULATION
25431 + case VCMD_get_rlimit:
25432 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
25433 + case VCMD_set_rlimit:
25434 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
25436 + case VCMD_get_rlimit:
25437 + return vc_get_rlimit(vxi, data);
25438 + case VCMD_set_rlimit:
25439 + return vc_set_rlimit(vxi, data);
25441 + case VCMD_get_rlimit_mask:
25442 + return vc_get_rlimit_mask(id, data);
25443 + case VCMD_reset_hits:
25444 + return vc_reset_hits(vxi, data);
25445 + case VCMD_reset_minmax:
25446 + return vc_reset_minmax(vxi, data);
25448 + case VCMD_get_vhi_name:
25449 + return vc_get_vhi_name(vxi, data);
25450 + case VCMD_set_vhi_name:
25451 + return vc_set_vhi_name(vxi, data);
25453 + case VCMD_ctx_stat:
25454 + return vc_ctx_stat(vxi, data);
25455 + case VCMD_virt_stat:
25456 + return vc_virt_stat(vxi, data);
25457 + case VCMD_sock_stat:
25458 + return vc_sock_stat(vxi, data);
25459 + case VCMD_rlimit_stat:
25460 + return vc_rlimit_stat(vxi, data);
25462 + case VCMD_set_cflags:
25463 + return vc_set_cflags(vxi, data);
25464 + case VCMD_get_cflags:
25465 + return vc_get_cflags(vxi, data);
25467 + /* this is version 1 */
25468 + case VCMD_set_ccaps:
25469 + return vc_set_ccaps(vxi, data);
25470 + /* this is version 1 */
25471 + case VCMD_get_ccaps:
25472 + return vc_get_ccaps(vxi, data);
25473 + case VCMD_set_bcaps:
25474 + return vc_set_bcaps(vxi, data);
25475 + case VCMD_get_bcaps:
25476 + return vc_get_bcaps(vxi, data);
25478 + case VCMD_set_badness:
25479 + return vc_set_badness(vxi, data);
25480 + case VCMD_get_badness:
25481 + return vc_get_badness(vxi, data);
25483 + case VCMD_set_nflags:
25484 + return vc_set_nflags(nxi, data);
25485 + case VCMD_get_nflags:
25486 + return vc_get_nflags(nxi, data);
25488 + case VCMD_set_ncaps:
25489 + return vc_set_ncaps(nxi, data);
25490 + case VCMD_get_ncaps:
25491 + return vc_get_ncaps(nxi, data);
25493 + case VCMD_set_sched_v4:
25494 + return vc_set_sched_v4(vxi, data);
25495 + /* this is version 5 */
25496 + case VCMD_set_sched:
25497 + return vc_set_sched(vxi, data);
25498 + case VCMD_get_sched:
25499 + return vc_get_sched(vxi, data);
25500 + case VCMD_sched_info:
25501 + return vc_sched_info(vxi, data);
25503 + case VCMD_add_dlimit:
25504 + return __COMPAT(vc_add_dlimit, id, data, compat);
25505 + case VCMD_rem_dlimit:
25506 + return __COMPAT(vc_rem_dlimit, id, data, compat);
25507 + case VCMD_set_dlimit:
25508 + return __COMPAT(vc_set_dlimit, id, data, compat);
25509 + case VCMD_get_dlimit:
25510 + return __COMPAT(vc_get_dlimit, id, data, compat);
25512 + case VCMD_ctx_kill:
25513 + return vc_ctx_kill(vxi, data);
25515 + case VCMD_wait_exit:
25516 + return vc_wait_exit(vxi, data);
25518 + case VCMD_get_iattr:
25519 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25520 + case VCMD_set_iattr:
25521 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25523 + case VCMD_fget_iattr:
25524 + return vc_fget_iattr(id, data);
25525 + case VCMD_fset_iattr:
25526 + return vc_fset_iattr(id, data);
25528 + case VCMD_enter_space_v0:
25529 + return vc_enter_space_v1(vxi, NULL);
25530 + case VCMD_enter_space_v1:
25531 + return vc_enter_space_v1(vxi, data);
25532 + /* this is version 2 */
25533 + case VCMD_enter_space:
25534 + return vc_enter_space(vxi, data);
25536 + case VCMD_ctx_create_v0:
25537 + return vc_ctx_create(id, NULL);
25538 + case VCMD_ctx_create:
25539 + return vc_ctx_create(id, data);
25540 + case VCMD_ctx_migrate_v0:
25541 + return vc_ctx_migrate(vxi, NULL);
25542 + case VCMD_ctx_migrate:
25543 + return vc_ctx_migrate(vxi, data);
25545 + case VCMD_net_create_v0:
25546 + return vc_net_create(id, NULL);
25547 + case VCMD_net_create:
25548 + return vc_net_create(id, data);
25549 + case VCMD_net_migrate:
25550 + return vc_net_migrate(nxi, data);
25552 + case VCMD_tag_migrate:
25553 + return vc_tag_migrate(id);
25555 + case VCMD_net_add:
25556 + return vc_net_add(nxi, data);
25557 + case VCMD_net_remove:
25558 + return vc_net_remove(nxi, data);
25560 + case VCMD_net_add_ipv4:
25561 + return vc_net_add_ipv4(nxi, data);
25562 + case VCMD_net_remove_ipv4:
25563 + return vc_net_remove_ipv4(nxi, data);
25564 +#ifdef CONFIG_IPV6
25565 + case VCMD_net_add_ipv6:
25566 + return vc_net_add_ipv6(nxi, data);
25567 + case VCMD_net_remove_ipv6:
25568 + return vc_net_remove_ipv6(nxi, data);
25570 +/* case VCMD_add_match_ipv4:
25571 + return vc_add_match_ipv4(nxi, data);
25572 + case VCMD_get_match_ipv4:
25573 + return vc_get_match_ipv4(nxi, data);
25574 +#ifdef CONFIG_IPV6
25575 + case VCMD_add_match_ipv6:
25576 + return vc_add_match_ipv6(nxi, data);
25577 + case VCMD_get_match_ipv6:
25578 + return vc_get_match_ipv6(nxi, data);
25581 +#ifdef CONFIG_VSERVER_DEVICE
25582 + case VCMD_set_mapping:
25583 + return __COMPAT(vc_set_mapping, vxi, data, compat);
25584 + case VCMD_unset_mapping:
25585 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
25587 +#ifdef CONFIG_VSERVER_HISTORY
25588 + case VCMD_dump_history:
25589 + return vc_dump_history(id);
25590 + case VCMD_read_history:
25591 + return __COMPAT(vc_read_history, id, data, compat);
25593 +#ifdef CONFIG_VSERVER_MONITOR
25594 + case VCMD_read_monitor:
25595 + return __COMPAT(vc_read_monitor, id, data, compat);
25598 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25599 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25605 +#define __VCMD(vcmd, _perm, _args, _flags) \
25606 + case VCMD_ ## vcmd: perm = _perm; \
25607 + args = _args; flags = _flags; break
25610 +#define VCA_NONE 0x00
25611 +#define VCA_VXI 0x01
25612 +#define VCA_NXI 0x02
25614 +#define VCF_NONE 0x00
25615 +#define VCF_INFO 0x01
25616 +#define VCF_ADMIN 0x02
25617 +#define VCF_ARES 0x06 /* includes admin */
25618 +#define VCF_SETUP 0x08
25620 +#define VCF_ZIDOK 0x10 /* zero id okay */
25624 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25627 + int permit = -1, state = 0;
25628 + int perm = -1, args = 0, flags = 0;
25629 + struct vx_info *vxi = NULL;
25630 + struct nx_info *nxi = NULL;
25633 + /* unpriviledged commands */
25634 + __VCMD(get_version, 0, VCA_NONE, 0);
25635 + __VCMD(get_vci, 0, VCA_NONE, 0);
25636 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
25637 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
25638 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
25639 + __VCMD(get_space_default,0, VCA_NONE, 0);
25641 + /* info commands */
25642 + __VCMD(task_xid, 2, VCA_NONE, 0);
25643 + __VCMD(reset_hits, 2, VCA_VXI, 0);
25644 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
25645 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
25646 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
25647 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
25648 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
25649 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
25650 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
25651 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
25653 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
25654 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
25655 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
25656 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
25658 + __VCMD(task_nid, 2, VCA_NONE, 0);
25659 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
25660 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
25661 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
25663 + __VCMD(task_tag, 2, VCA_NONE, 0);
25665 + __VCMD(get_iattr, 2, VCA_NONE, 0);
25666 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
25667 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
25668 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
25669 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
25671 + /* lower admin commands */
25672 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
25673 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
25674 + __VCMD(ctx_create, 5, VCA_NONE, 0);
25675 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
25676 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
25677 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
25678 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
25679 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
25681 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
25682 + __VCMD(net_create, 5, VCA_NONE, 0);
25683 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
25685 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
25687 + /* higher admin commands */
25688 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
25689 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25690 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25692 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25693 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25694 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25695 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25697 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25698 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25699 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25700 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25702 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25703 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25704 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25705 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25706 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25707 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25708 +#ifdef CONFIG_IPV6
25709 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25710 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25712 + __VCMD(set_iattr, 7, VCA_NONE, 0);
25713 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
25714 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
25715 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
25716 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
25718 +#ifdef CONFIG_VSERVER_DEVICE
25719 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25720 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25722 + /* debug level admin commands */
25723 +#ifdef CONFIG_VSERVER_HISTORY
25724 + __VCMD(dump_history, 9, VCA_NONE, 0);
25725 + __VCMD(read_history, 9, VCA_NONE, 0);
25727 +#ifdef CONFIG_VSERVER_MONITOR
25728 + __VCMD(read_monitor, 9, VCA_NONE, 0);
25735 + vxdprintk(VXD_CBIT(switch, 0),
25736 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25737 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25738 + VC_VERSION(cmd), id, data, compat,
25739 + perm, args, flags);
25746 + if (!capable(CAP_CONTEXT))
25750 + /* moved here from the individual commands */
25752 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25756 + /* vcmd involves resource management */
25758 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25762 + /* various legacy exceptions */
25764 + /* will go away when spectator is a cap */
25765 + case VCMD_ctx_migrate_v0:
25766 + case VCMD_ctx_migrate:
25768 + current->xid = 1;
25774 + /* will go away when spectator is a cap */
25775 + case VCMD_net_migrate:
25777 + current->nid = 1;
25784 + /* vcmds are fine by default */
25787 + /* admin type vcmds require admin ... */
25788 + if (flags & VCF_ADMIN)
25789 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25791 + /* ... but setup type vcmds override that */
25792 + if (!permit && (flags & VCF_SETUP))
25793 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25801 + if (!id && (flags & VCF_ZIDOK))
25805 + if (args & VCA_VXI) {
25806 + vxi = lookup_vx_info(id);
25810 + if ((flags & VCF_ADMIN) &&
25811 + /* special case kill for shutdown */
25812 + (cmd != VCMD_ctx_kill) &&
25813 + /* can context be administrated? */
25814 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25820 + if (args & VCA_NXI) {
25821 + nxi = lookup_nx_info(id);
25825 + if ((flags & VCF_ADMIN) &&
25826 + /* can context be administrated? */
25827 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25834 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25837 + if ((args & VCA_NXI) && nxi)
25838 + put_nx_info(nxi);
25840 + if ((args & VCA_VXI) && vxi)
25841 + put_vx_info(vxi);
25843 + vxdprintk(VXD_CBIT(switch, 1),
25844 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25845 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25846 + VC_VERSION(cmd), ret, ret, state, permit);
25851 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25853 + return do_vserver(cmd, id, data, 0);
25856 +#ifdef CONFIG_COMPAT
25859 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25861 + return do_vserver(cmd, id, data, 1);
25864 +#endif /* CONFIG_COMPAT */
25865 diff -NurpP --minimal linux-2.6.35/kernel/vserver/sysctl.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sysctl.c
25866 --- linux-2.6.35/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
25867 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sysctl.c 2010-08-02 17:05:06.000000000 +0200
25870 + * kernel/vserver/sysctl.c
25872 + * Virtual Context Support
25874 + * Copyright (C) 2004-2007 Herbert Pötzl
25876 + * V0.01 basic structure
25880 +#include <linux/module.h>
25881 +#include <linux/ctype.h>
25882 +#include <linux/sysctl.h>
25883 +#include <linux/parser.h>
25884 +#include <asm/uaccess.h>
25887 + CTL_DEBUG_ERROR = 0,
25888 + CTL_DEBUG_SWITCH = 1,
25903 +unsigned int vx_debug_switch = 0;
25904 +unsigned int vx_debug_xid = 0;
25905 +unsigned int vx_debug_nid = 0;
25906 +unsigned int vx_debug_tag = 0;
25907 +unsigned int vx_debug_net = 0;
25908 +unsigned int vx_debug_limit = 0;
25909 +unsigned int vx_debug_cres = 0;
25910 +unsigned int vx_debug_dlim = 0;
25911 +unsigned int vx_debug_quota = 0;
25912 +unsigned int vx_debug_cvirt = 0;
25913 +unsigned int vx_debug_space = 0;
25914 +unsigned int vx_debug_misc = 0;
25917 +static struct ctl_table_header *vserver_table_header;
25918 +static ctl_table vserver_root_table[];
25921 +void vserver_register_sysctl(void)
25923 + if (!vserver_table_header) {
25924 + vserver_table_header = register_sysctl_table(vserver_root_table);
25929 +void vserver_unregister_sysctl(void)
25931 + if (vserver_table_header) {
25932 + unregister_sysctl_table(vserver_table_header);
25933 + vserver_table_header = NULL;
25938 +static int proc_dodebug(ctl_table *table, int write,
25939 + void __user *buffer, size_t *lenp, loff_t *ppos)
25941 + char tmpbuf[20], *p, c;
25942 + unsigned int value;
25943 + size_t left, len;
25945 + if ((*ppos && !write) || !*lenp) {
25953 + if (!access_ok(VERIFY_READ, buffer, left))
25955 + p = (char *)buffer;
25956 + while (left && __get_user(c, p) >= 0 && isspace(c))
25961 + if (left > sizeof(tmpbuf) - 1)
25963 + if (copy_from_user(tmpbuf, p, left))
25965 + tmpbuf[left] = '\0';
25967 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25968 + value = 10 * value + (*p - '0');
25969 + if (*p && !isspace(*p))
25971 + while (left && isspace(*p))
25973 + *(unsigned int *)table->data = value;
25975 + if (!access_ok(VERIFY_WRITE, buffer, left))
25977 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25980 + if (__copy_to_user(buffer, tmpbuf, len))
25982 + if ((left -= len) > 0) {
25983 + if (put_user('\n', (char *)buffer + len))
25997 +#define CTL_ENTRY(ctl, name) \
25999 + .procname = #name, \
26000 + .data = &vx_ ## name, \
26001 + .maxlen = sizeof(int), \
26003 + .proc_handler = &proc_dodebug, \
26004 + .extra1 = &zero, \
26005 + .extra2 = &zero, \
26008 +static ctl_table vserver_debug_table[] = {
26009 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
26010 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
26011 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
26012 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
26013 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
26014 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
26015 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
26016 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
26017 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
26018 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
26019 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
26020 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
26024 +static ctl_table vserver_root_table[] = {
26026 + .procname = "vserver",
26028 + .child = vserver_debug_table
26034 +static match_table_t tokens = {
26035 + { CTL_DEBUG_SWITCH, "switch=%x" },
26036 + { CTL_DEBUG_XID, "xid=%x" },
26037 + { CTL_DEBUG_NID, "nid=%x" },
26038 + { CTL_DEBUG_TAG, "tag=%x" },
26039 + { CTL_DEBUG_NET, "net=%x" },
26040 + { CTL_DEBUG_LIMIT, "limit=%x" },
26041 + { CTL_DEBUG_CRES, "cres=%x" },
26042 + { CTL_DEBUG_DLIM, "dlim=%x" },
26043 + { CTL_DEBUG_QUOTA, "quota=%x" },
26044 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
26045 + { CTL_DEBUG_SPACE, "space=%x" },
26046 + { CTL_DEBUG_MISC, "misc=%x" },
26047 + { CTL_DEBUG_ERROR, NULL }
26050 +#define HANDLE_CASE(id, name, val) \
26051 + case CTL_DEBUG_ ## id: \
26052 + vx_debug_ ## name = val; \
26053 + printk("vs_debug_" #name "=0x%x\n", val); \
26057 +static int __init vs_debug_setup(char *str)
26062 + printk("vs_debug_setup(%s)\n", str);
26063 + while ((p = strsep(&str, ",")) != NULL) {
26064 + substring_t args[MAX_OPT_ARGS];
26065 + unsigned int value;
26070 + token = match_token(p, tokens, args);
26071 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
26074 + HANDLE_CASE(SWITCH, switch, value);
26075 + HANDLE_CASE(XID, xid, value);
26076 + HANDLE_CASE(NID, nid, value);
26077 + HANDLE_CASE(TAG, tag, value);
26078 + HANDLE_CASE(NET, net, value);
26079 + HANDLE_CASE(LIMIT, limit, value);
26080 + HANDLE_CASE(CRES, cres, value);
26081 + HANDLE_CASE(DLIM, dlim, value);
26082 + HANDLE_CASE(QUOTA, quota, value);
26083 + HANDLE_CASE(CVIRT, cvirt, value);
26084 + HANDLE_CASE(SPACE, space, value);
26085 + HANDLE_CASE(MISC, misc, value);
26094 +__setup("vsdebug=", vs_debug_setup);
26098 +EXPORT_SYMBOL_GPL(vx_debug_switch);
26099 +EXPORT_SYMBOL_GPL(vx_debug_xid);
26100 +EXPORT_SYMBOL_GPL(vx_debug_nid);
26101 +EXPORT_SYMBOL_GPL(vx_debug_net);
26102 +EXPORT_SYMBOL_GPL(vx_debug_limit);
26103 +EXPORT_SYMBOL_GPL(vx_debug_cres);
26104 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
26105 +EXPORT_SYMBOL_GPL(vx_debug_quota);
26106 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
26107 +EXPORT_SYMBOL_GPL(vx_debug_space);
26108 +EXPORT_SYMBOL_GPL(vx_debug_misc);
26110 diff -NurpP --minimal linux-2.6.35/kernel/vserver/tag.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/tag.c
26111 --- linux-2.6.35/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
26112 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/tag.c 2010-08-02 17:05:06.000000000 +0200
26115 + * linux/kernel/vserver/tag.c
26117 + * Virtual Server: Shallow Tag Space
26119 + * Copyright (C) 2007 Herbert Pötzl
26121 + * V0.01 basic implementation
26125 +#include <linux/sched.h>
26126 +#include <linux/vserver/debug.h>
26127 +#include <linux/vs_pid.h>
26128 +#include <linux/vs_tag.h>
26130 +#include <linux/vserver/tag_cmd.h>
26133 +int dx_migrate_task(struct task_struct *p, tag_t tag)
26138 + vxdprintk(VXD_CBIT(tag, 5),
26139 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
26145 + vxdprintk(VXD_CBIT(tag, 5),
26146 + "moved task %p into [#%d]", p, tag);
26150 +/* vserver syscall commands below here */
26152 +/* taks xid and vx_info functions */
26155 +int vc_task_tag(uint32_t id)
26160 + struct task_struct *tsk;
26161 + read_lock(&tasklist_lock);
26162 + tsk = find_task_by_real_pid(id);
26163 + tag = (tsk) ? tsk->tag : -ESRCH;
26164 + read_unlock(&tasklist_lock);
26166 + tag = dx_current_tag();
26171 +int vc_tag_migrate(uint32_t tag)
26173 + return dx_migrate_task(current, tag & 0xFFFF);
26177 diff -NurpP --minimal linux-2.6.35/kernel/vserver/vci_config.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/vci_config.h
26178 --- linux-2.6.35/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
26179 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/vci_config.h 2010-08-02 17:05:06.000000000 +0200
26182 +/* interface version */
26184 +#define VCI_VERSION 0x00020306
26188 + VCI_KCBIT_NO_DYNAMIC = 0,
26190 + VCI_KCBIT_PROC_SECURE = 4,
26191 + VCI_KCBIT_HARDCPU = 5,
26192 + VCI_KCBIT_IDLELIMIT = 6,
26193 + VCI_KCBIT_IDLETIME = 7,
26195 + VCI_KCBIT_COWBL = 8,
26196 + VCI_KCBIT_FULLCOWBL = 9,
26197 + VCI_KCBIT_SPACES = 10,
26198 + VCI_KCBIT_NETV2 = 11,
26199 + VCI_KCBIT_MEMCG = 12,
26201 + VCI_KCBIT_DEBUG = 16,
26202 + VCI_KCBIT_HISTORY = 20,
26203 + VCI_KCBIT_TAGGED = 24,
26204 + VCI_KCBIT_PPTAG = 28,
26206 + VCI_KCBIT_MORE = 31,
26210 +static inline uint32_t vci_kernel_config(void)
26213 + (1 << VCI_KCBIT_NO_DYNAMIC) |
26215 + /* configured features */
26216 +#ifdef CONFIG_VSERVER_PROC_SECURE
26217 + (1 << VCI_KCBIT_PROC_SECURE) |
26219 +#ifdef CONFIG_VSERVER_HARDCPU
26220 + (1 << VCI_KCBIT_HARDCPU) |
26222 +#ifdef CONFIG_VSERVER_IDLELIMIT
26223 + (1 << VCI_KCBIT_IDLELIMIT) |
26225 +#ifdef CONFIG_VSERVER_IDLETIME
26226 + (1 << VCI_KCBIT_IDLETIME) |
26228 +#ifdef CONFIG_VSERVER_COWBL
26229 + (1 << VCI_KCBIT_COWBL) |
26230 + (1 << VCI_KCBIT_FULLCOWBL) |
26232 + (1 << VCI_KCBIT_SPACES) |
26233 + (1 << VCI_KCBIT_NETV2) |
26234 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
26235 + (1 << VCI_KCBIT_MEMCG) |
26238 + /* debug options */
26239 +#ifdef CONFIG_VSERVER_DEBUG
26240 + (1 << VCI_KCBIT_DEBUG) |
26242 +#ifdef CONFIG_VSERVER_HISTORY
26243 + (1 << VCI_KCBIT_HISTORY) |
26246 + /* inode context tagging */
26247 +#if defined(CONFIG_TAGGING_NONE)
26248 + (0 << VCI_KCBIT_TAGGED) |
26249 +#elif defined(CONFIG_TAGGING_UID16)
26250 + (1 << VCI_KCBIT_TAGGED) |
26251 +#elif defined(CONFIG_TAGGING_GID16)
26252 + (2 << VCI_KCBIT_TAGGED) |
26253 +#elif defined(CONFIG_TAGGING_ID24)
26254 + (3 << VCI_KCBIT_TAGGED) |
26255 +#elif defined(CONFIG_TAGGING_INTERN)
26256 + (4 << VCI_KCBIT_TAGGED) |
26257 +#elif defined(CONFIG_TAGGING_RUNTIME)
26258 + (5 << VCI_KCBIT_TAGGED) |
26260 + (7 << VCI_KCBIT_TAGGED) |
26262 + (1 << VCI_KCBIT_PPTAG) |
26266 diff -NurpP --minimal linux-2.6.35/mm/filemap_xip.c linux-2.6.35-vs2.3.0.36.31/mm/filemap_xip.c
26267 --- linux-2.6.35/mm/filemap_xip.c 2010-07-07 18:31:58.000000000 +0200
26268 +++ linux-2.6.35-vs2.3.0.36.31/mm/filemap_xip.c 2010-08-02 17:05:06.000000000 +0200
26270 #include <linux/seqlock.h>
26271 #include <linux/mutex.h>
26272 #include <linux/gfp.h>
26273 +#include <linux/vs_memory.h>
26274 #include <asm/tlbflush.h>
26275 #include <asm/io.h>
26277 diff -NurpP --minimal linux-2.6.35/mm/fremap.c linux-2.6.35-vs2.3.0.36.31/mm/fremap.c
26278 --- linux-2.6.35/mm/fremap.c 2010-07-07 18:31:58.000000000 +0200
26279 +++ linux-2.6.35-vs2.3.0.36.31/mm/fremap.c 2010-08-02 17:05:06.000000000 +0200
26281 #include <linux/module.h>
26282 #include <linux/syscalls.h>
26283 #include <linux/mmu_notifier.h>
26284 +#include <linux/vs_memory.h>
26286 #include <asm/mmu_context.h>
26287 #include <asm/cacheflush.h>
26288 diff -NurpP --minimal linux-2.6.35/mm/hugetlb.c linux-2.6.35-vs2.3.0.36.31/mm/hugetlb.c
26289 --- linux-2.6.35/mm/hugetlb.c 2010-08-02 16:52:58.000000000 +0200
26290 +++ linux-2.6.35-vs2.3.0.36.31/mm/hugetlb.c 2010-08-02 17:05:06.000000000 +0200
26293 #include <linux/hugetlb.h>
26294 #include <linux/node.h>
26295 +#include <linux/vs_memory.h>
26296 #include "internal.h"
26298 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26299 diff -NurpP --minimal linux-2.6.35/mm/memcontrol.c linux-2.6.35-vs2.3.0.36.31/mm/memcontrol.c
26300 --- linux-2.6.35/mm/memcontrol.c 2010-08-02 16:52:58.000000000 +0200
26301 +++ linux-2.6.35-vs2.3.0.36.31/mm/memcontrol.c 2010-08-02 17:05:06.000000000 +0200
26302 @@ -635,6 +635,31 @@ struct mem_cgroup *mem_cgroup_from_task(
26303 struct mem_cgroup, css);
26306 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
26308 + return res_counter_read_u64(&mem->res, member);
26311 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
26313 + return res_counter_read_u64(&mem->memsw, member);
26316 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
26318 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
26321 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
26323 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
26326 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
26328 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
26331 static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
26333 struct mem_cgroup *mem = NULL;
26334 diff -NurpP --minimal linux-2.6.35/mm/memory.c linux-2.6.35-vs2.3.0.36.31/mm/memory.c
26335 --- linux-2.6.35/mm/memory.c 2010-08-02 16:52:58.000000000 +0200
26336 +++ linux-2.6.35-vs2.3.0.36.31/mm/memory.c 2010-08-02 17:05:06.000000000 +0200
26337 @@ -3076,6 +3076,7 @@ static inline int handle_pte_fault(struc
26341 + int ret = 0, type = VXPT_UNKNOWN;
26344 if (!pte_present(entry)) {
26345 @@ -3100,9 +3101,12 @@ static inline int handle_pte_fault(struc
26346 if (unlikely(!pte_same(*pte, entry)))
26348 if (flags & FAULT_FLAG_WRITE) {
26349 - if (!pte_write(entry))
26350 - return do_wp_page(mm, vma, address,
26351 + if (!pte_write(entry)) {
26352 + ret = do_wp_page(mm, vma, address,
26353 pte, pmd, ptl, entry);
26354 + type = VXPT_WRITE;
26357 entry = pte_mkdirty(entry);
26359 entry = pte_mkyoung(entry);
26360 @@ -3120,7 +3124,10 @@ static inline int handle_pte_fault(struc
26363 pte_unmap_unlock(pte, ptl);
26367 + vx_page_fault(mm, vma, type, ret);
26372 diff -NurpP --minimal linux-2.6.35/mm/mlock.c linux-2.6.35-vs2.3.0.36.31/mm/mlock.c
26373 --- linux-2.6.35/mm/mlock.c 2010-08-02 16:52:58.000000000 +0200
26374 +++ linux-2.6.35-vs2.3.0.36.31/mm/mlock.c 2010-08-02 17:05:06.000000000 +0200
26376 #include <linux/rmap.h>
26377 #include <linux/mmzone.h>
26378 #include <linux/hugetlb.h>
26379 +#include <linux/vs_memory.h>
26381 #include "internal.h"
26383 @@ -471,7 +472,7 @@ static int do_mlock(unsigned long start,
26385 SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
26387 - unsigned long locked;
26388 + unsigned long locked, grow;
26389 unsigned long lock_limit;
26390 int error = -ENOMEM;
26392 @@ -493,6 +494,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26393 /* check against resource limits */
26394 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
26395 error = do_mlock(start, len, 1);
26397 up_write(¤t->mm->mmap_sem);
26400 diff -NurpP --minimal linux-2.6.35/mm/mremap.c linux-2.6.35-vs2.3.0.36.31/mm/mremap.c
26401 --- linux-2.6.35/mm/mremap.c 2010-07-07 18:31:58.000000000 +0200
26402 +++ linux-2.6.35-vs2.3.0.36.31/mm/mremap.c 2010-08-02 17:05:06.000000000 +0200
26404 #include <linux/security.h>
26405 #include <linux/syscalls.h>
26406 #include <linux/mmu_notifier.h>
26407 +#include <linux/vs_memory.h>
26409 #include <asm/uaccess.h>
26410 #include <asm/cacheflush.h>
26411 diff -NurpP --minimal linux-2.6.35/mm/oom_kill.c linux-2.6.35-vs2.3.0.36.31/mm/oom_kill.c
26412 --- linux-2.6.35/mm/oom_kill.c 2010-08-02 16:52:58.000000000 +0200
26413 +++ linux-2.6.35-vs2.3.0.36.31/mm/oom_kill.c 2010-08-02 17:05:06.000000000 +0200
26415 #include <linux/notifier.h>
26416 #include <linux/memcontrol.h>
26417 #include <linux/security.h>
26418 +#include <linux/reboot.h>
26419 +#include <linux/vs_memory.h>
26420 +#include <linux/vs_context.h>
26422 int sysctl_panic_on_oom;
26423 int sysctl_oom_kill_allocating_task;
26424 @@ -187,9 +190,21 @@ unsigned long badness(struct task_struct
26425 points >>= -(oom_adj);
26429 + * add points for context badness and
26430 + * reduce badness for processes belonging to
26431 + * a different context
26434 + points += vx_badness(p, mm);
26436 + if ((vx_current_xid() > 1) &&
26437 + vx_current_xid() != vx_task_xid(p))
26441 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
26442 - p->pid, p->comm, points);
26443 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26444 + task_pid_nr(p), p->xid, p->comm, points);
26448 @@ -250,6 +265,7 @@ static struct task_struct *select_bad_pr
26449 struct task_struct *p;
26450 struct task_struct *chosen = NULL;
26451 struct timespec uptime;
26452 + unsigned xid = vx_current_xid();
26455 do_posix_clock_monotonic_gettime(&uptime);
26456 @@ -262,11 +278,14 @@ static struct task_struct *select_bad_pr
26460 - /* skip the init task */
26461 - if (is_global_init(p))
26462 + /* skip the init task, global and per guest */
26463 + if (task_is_init(p))
26465 if (mem && !task_in_mem_cgroup(p, mem))
26467 + /* skip other guest and host processes if oom in guest */
26468 + if (xid && vx_task_xid(p) != xid)
26472 * This task already has access to memory reserves and is
26473 @@ -398,9 +417,9 @@ static void __oom_kill_task(struct task_
26477 - printk(KERN_ERR "Killed process %d (%s) "
26478 + printk(KERN_ERR "Killed process %s(%d:#%u) "
26479 "vsz:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
26480 - task_pid_nr(p), p->comm,
26481 + p->comm, task_pid_nr(p), p->xid,
26482 K(p->mm->total_vm),
26483 K(get_mm_counter(p->mm, MM_ANONPAGES)),
26484 K(get_mm_counter(p->mm, MM_FILEPAGES)));
26485 @@ -453,8 +472,8 @@ static int oom_kill_process(struct task_
26489 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26490 - message, task_pid_nr(p), p->comm, points);
26491 + printk(KERN_ERR "%s: kill process %s(%d:#%u) score %li or a child\n",
26492 + message, p->comm, task_pid_nr(p), p->xid, points);
26494 /* Try to kill a child first */
26495 list_for_each_entry(c, &p->children, sibling) {
26496 @@ -554,6 +573,8 @@ void clear_zonelist_oom(struct zonelist
26497 spin_unlock(&zone_scan_lock);
26500 +long vs_oom_action(unsigned int);
26503 * Must be called with tasklist_lock held for read.
26505 @@ -580,7 +601,11 @@ retry:
26507 read_unlock(&tasklist_lock);
26508 dump_header(NULL, gfp_mask, order, NULL);
26509 - panic("Out of memory and no killable processes...\n");
26510 + /* avoid panic for guest OOM */
26511 + if (current->xid)
26512 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
26514 + panic("Out of memory and no killable processes...\n");
26517 if (oom_kill_process(p, gfp_mask, order, points, NULL,
26518 diff -NurpP --minimal linux-2.6.35/mm/page_alloc.c linux-2.6.35-vs2.3.0.36.31/mm/page_alloc.c
26519 --- linux-2.6.35/mm/page_alloc.c 2010-08-02 16:52:58.000000000 +0200
26520 +++ linux-2.6.35-vs2.3.0.36.31/mm/page_alloc.c 2010-08-02 17:46:11.000000000 +0200
26522 #include <linux/compaction.h>
26523 #include <trace/events/kmem.h>
26524 #include <linux/ftrace_event.h>
26525 +#include <linux/vs_base.h>
26526 +#include <linux/vs_limit.h>
26528 #include <asm/tlbflush.h>
26529 #include <asm/div64.h>
26530 @@ -2305,6 +2307,9 @@ void si_meminfo(struct sysinfo *val)
26531 val->totalhigh = totalhigh_pages;
26532 val->freehigh = nr_free_highpages();
26533 val->mem_unit = PAGE_SIZE;
26535 + if (vx_flags(VXF_VIRT_MEM, 0))
26536 + vx_vsi_meminfo(val);
26539 EXPORT_SYMBOL(si_meminfo);
26540 @@ -2325,6 +2330,9 @@ void si_meminfo_node(struct sysinfo *val
26543 val->mem_unit = PAGE_SIZE;
26545 + if (vx_flags(VXF_VIRT_MEM, 0))
26546 + vx_vsi_meminfo(val);
26550 diff -NurpP --minimal linux-2.6.35/mm/rmap.c linux-2.6.35-vs2.3.0.36.31/mm/rmap.c
26551 --- linux-2.6.35/mm/rmap.c 2010-08-02 16:52:58.000000000 +0200
26552 +++ linux-2.6.35-vs2.3.0.36.31/mm/rmap.c 2010-08-02 17:05:06.000000000 +0200
26554 #include <linux/memcontrol.h>
26555 #include <linux/mmu_notifier.h>
26556 #include <linux/migrate.h>
26557 +#include <linux/vs_memory.h>
26559 #include <asm/tlbflush.h>
26561 diff -NurpP --minimal linux-2.6.35/mm/shmem.c linux-2.6.35-vs2.3.0.36.31/mm/shmem.c
26562 --- linux-2.6.35/mm/shmem.c 2010-08-02 16:52:58.000000000 +0200
26563 +++ linux-2.6.35-vs2.3.0.36.31/mm/shmem.c 2010-08-02 17:05:06.000000000 +0200
26564 @@ -1788,7 +1788,7 @@ static int shmem_statfs(struct dentry *d
26566 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26568 - buf->f_type = TMPFS_MAGIC;
26569 + buf->f_type = TMPFS_SUPER_MAGIC;
26570 buf->f_bsize = PAGE_CACHE_SIZE;
26571 buf->f_namelen = NAME_MAX;
26572 spin_lock(&sbinfo->stat_lock);
26573 @@ -2350,7 +2350,7 @@ int shmem_fill_super(struct super_block
26574 sb->s_maxbytes = SHMEM_MAX_BYTES;
26575 sb->s_blocksize = PAGE_CACHE_SIZE;
26576 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26577 - sb->s_magic = TMPFS_MAGIC;
26578 + sb->s_magic = TMPFS_SUPER_MAGIC;
26579 sb->s_op = &shmem_ops;
26580 sb->s_time_gran = 1;
26581 #ifdef CONFIG_TMPFS_POSIX_ACL
26582 diff -NurpP --minimal linux-2.6.35/mm/slab.c linux-2.6.35-vs2.3.0.36.31/mm/slab.c
26583 --- linux-2.6.35/mm/slab.c 2010-08-02 16:52:58.000000000 +0200
26584 +++ linux-2.6.35-vs2.3.0.36.31/mm/slab.c 2010-08-02 17:05:06.000000000 +0200
26585 @@ -408,6 +408,8 @@ static void kmem_list3_init(struct kmem_
26586 #define STATS_INC_FREEMISS(x) do { } while (0)
26589 +#include "slab_vs.h"
26594 @@ -3347,6 +3349,7 @@ retry:
26596 obj = slab_get_obj(cachep, slabp, nodeid);
26597 check_slabp(cachep, slabp);
26598 + vx_slab_alloc(cachep, flags);
26599 l3->free_objects--;
26600 /* move slabp to correct slabp list: */
26601 list_del(&slabp->list);
26602 @@ -3424,6 +3427,7 @@ __cache_alloc_node(struct kmem_cache *ca
26603 /* ___cache_alloc_node can fall back to other nodes */
26604 ptr = ____cache_alloc_node(cachep, flags, nodeid);
26606 + vx_slab_alloc(cachep, flags);
26607 local_irq_restore(save_flags);
26608 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26609 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
26610 @@ -3610,6 +3614,7 @@ static inline void __cache_free(struct k
26612 kmemleak_free_recursive(objp, cachep->flags);
26613 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26614 + vx_slab_free(cachep);
26616 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
26618 diff -NurpP --minimal linux-2.6.35/mm/slab_vs.h linux-2.6.35-vs2.3.0.36.31/mm/slab_vs.h
26619 --- linux-2.6.35/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
26620 +++ linux-2.6.35-vs2.3.0.36.31/mm/slab_vs.h 2010-08-02 17:05:06.000000000 +0200
26623 +#include <linux/vserver/context.h>
26625 +#include <linux/vs_context.h>
26628 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26630 + int what = gfp_zone(cachep->gfpflags);
26631 + struct vx_info *vxi = current_vx_info();
26636 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
26640 +void vx_slab_free(struct kmem_cache *cachep)
26642 + int what = gfp_zone(cachep->gfpflags);
26643 + struct vx_info *vxi = current_vx_info();
26648 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
26651 diff -NurpP --minimal linux-2.6.35/mm/swapfile.c linux-2.6.35-vs2.3.0.36.31/mm/swapfile.c
26652 --- linux-2.6.35/mm/swapfile.c 2010-08-02 16:52:58.000000000 +0200
26653 +++ linux-2.6.35-vs2.3.0.36.31/mm/swapfile.c 2010-08-02 17:05:06.000000000 +0200
26655 #include <asm/tlbflush.h>
26656 #include <linux/swapops.h>
26657 #include <linux/page_cgroup.h>
26658 +#include <linux/vs_base.h>
26659 +#include <linux/vs_memory.h>
26661 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
26663 @@ -1732,6 +1734,16 @@ static int swap_show(struct seq_file *sw
26665 if (si == SEQ_START_TOKEN) {
26666 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
26667 + if (vx_flags(VXF_VIRT_MEM, 0)) {
26668 + struct sysinfo si;
26670 + vx_vsi_swapinfo(&si);
26671 + if (si.totalswap < (1 << 10))
26673 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
26674 + "hdv0", "partition", si.totalswap >> 10,
26675 + (si.totalswap - si.freeswap) >> 10, -1);
26680 @@ -2116,6 +2128,8 @@ void si_swapinfo(struct sysinfo *val)
26681 val->freeswap = nr_swap_pages + nr_to_be_unused;
26682 val->totalswap = total_swap_pages + nr_to_be_unused;
26683 spin_unlock(&swap_lock);
26684 + if (vx_flags(VXF_VIRT_MEM, 0))
26685 + vx_vsi_swapinfo(val);
26689 diff -NurpP --minimal linux-2.6.35/net/core/dev.c linux-2.6.35-vs2.3.0.36.31/net/core/dev.c
26690 --- linux-2.6.35/net/core/dev.c 2010-08-02 16:52:59.000000000 +0200
26691 +++ linux-2.6.35-vs2.3.0.36.31/net/core/dev.c 2010-08-02 17:05:06.000000000 +0200
26692 @@ -129,6 +129,7 @@
26693 #include <linux/in.h>
26694 #include <linux/jhash.h>
26695 #include <linux/random.h>
26696 +#include <linux/vs_inet.h>
26697 #include <trace/events/napi.h>
26698 #include <linux/pci.h>
26700 @@ -609,7 +610,8 @@ struct net_device *__dev_get_by_name(str
26701 struct hlist_head *head = dev_name_hash(net, name);
26703 hlist_for_each_entry(dev, p, head, name_hlist)
26704 - if (!strncmp(dev->name, name, IFNAMSIZ))
26705 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
26706 + nx_dev_visible(current_nx_info(), dev))
26710 @@ -635,7 +637,8 @@ struct net_device *dev_get_by_name_rcu(s
26711 struct hlist_head *head = dev_name_hash(net, name);
26713 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
26714 - if (!strncmp(dev->name, name, IFNAMSIZ))
26715 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
26716 + nx_dev_visible(current_nx_info(), dev))
26720 @@ -686,7 +689,8 @@ struct net_device *__dev_get_by_index(st
26721 struct hlist_head *head = dev_index_hash(net, ifindex);
26723 hlist_for_each_entry(dev, p, head, index_hlist)
26724 - if (dev->ifindex == ifindex)
26725 + if ((dev->ifindex == ifindex) &&
26726 + nx_dev_visible(current_nx_info(), dev))
26730 @@ -711,7 +715,8 @@ struct net_device *dev_get_by_index_rcu(
26731 struct hlist_head *head = dev_index_hash(net, ifindex);
26733 hlist_for_each_entry_rcu(dev, p, head, index_hlist)
26734 - if (dev->ifindex == ifindex)
26735 + if ((dev->ifindex == ifindex) &&
26736 + nx_dev_visible(current_nx_info(), dev))
26740 @@ -764,10 +769,12 @@ struct net_device *dev_getbyhwaddr(struc
26744 - for_each_netdev(net, dev)
26745 + for_each_netdev(net, dev) {
26746 if (dev->type == type &&
26747 - !memcmp(dev->dev_addr, ha, dev->addr_len))
26748 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
26749 + nx_dev_visible(current_nx_info(), dev))
26755 @@ -778,9 +785,11 @@ struct net_device *__dev_getfirstbyhwtyp
26756 struct net_device *dev;
26759 - for_each_netdev(net, dev)
26760 - if (dev->type == type)
26761 + for_each_netdev(net, dev) {
26762 + if ((dev->type == type) &&
26763 + nx_dev_visible(current_nx_info(), dev))
26769 @@ -902,6 +911,8 @@ static int __dev_alloc_name(struct net *
26771 if (i < 0 || i >= max_netdevices)
26773 + if (!nx_dev_visible(current_nx_info(), d))
26776 /* avoid cases where sscanf is not exact inverse of printf */
26777 snprintf(buf, IFNAMSIZ, name, i);
26778 @@ -3651,6 +3662,8 @@ static int dev_ifconf(struct net *net, c
26781 for_each_netdev(net, dev) {
26782 + if (!nx_dev_visible(current_nx_info(), dev))
26784 for (i = 0; i < NPROTO; i++) {
26785 if (gifconf_list[i]) {
26787 @@ -3721,6 +3734,9 @@ static void dev_seq_printf_stats(struct
26789 const struct net_device_stats *stats = dev_get_stats(dev);
26791 + if (!nx_dev_visible(current_nx_info(), dev))
26794 seq_printf(seq, "%6s: %7lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
26795 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
26796 dev->name, stats->rx_bytes, stats->rx_packets,
26797 diff -NurpP --minimal linux-2.6.35/net/core/rtnetlink.c linux-2.6.35-vs2.3.0.36.31/net/core/rtnetlink.c
26798 --- linux-2.6.35/net/core/rtnetlink.c 2010-08-02 16:52:59.000000000 +0200
26799 +++ linux-2.6.35-vs2.3.0.36.31/net/core/rtnetlink.c 2010-08-02 17:05:06.000000000 +0200
26800 @@ -926,6 +926,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
26801 hlist_for_each_entry(dev, node, head, index_hlist) {
26804 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
26806 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26807 NETLINK_CB(cb->skb).pid,
26808 cb->nlh->nlmsg_seq, 0,
26809 @@ -1642,6 +1644,9 @@ void rtmsg_ifinfo(int type, struct net_d
26810 struct sk_buff *skb;
26811 int err = -ENOBUFS;
26813 + if (!nx_dev_visible(current_nx_info(), dev))
26816 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
26819 diff -NurpP --minimal linux-2.6.35/net/core/sock.c linux-2.6.35-vs2.3.0.36.31/net/core/sock.c
26820 --- linux-2.6.35/net/core/sock.c 2010-08-02 16:52:59.000000000 +0200
26821 +++ linux-2.6.35-vs2.3.0.36.31/net/core/sock.c 2010-08-02 17:05:06.000000000 +0200
26822 @@ -126,6 +126,10 @@
26823 #include <net/cls_cgroup.h>
26825 #include <linux/filter.h>
26826 +#include <linux/vs_socket.h>
26827 +#include <linux/vs_limit.h>
26828 +#include <linux/vs_context.h>
26829 +#include <linux/vs_network.h>
26832 #include <net/tcp.h>
26833 @@ -1027,6 +1031,8 @@ static struct sock *sk_prot_alloc(struct
26835 sk_tx_queue_clear(sk);
26837 + sock_vx_init(sk);
26838 + sock_nx_init(sk);
26842 @@ -1120,6 +1126,11 @@ static void __sk_free(struct sock *sk)
26843 __func__, atomic_read(&sk->sk_omem_alloc));
26845 put_net(sock_net(sk));
26847 + clr_vx_info(&sk->sk_vx_info);
26849 + clr_nx_info(&sk->sk_nx_info);
26851 sk_prot_free(sk->sk_prot_creator, sk);
26854 @@ -1167,6 +1178,8 @@ struct sock *sk_clone(const struct sock
26857 get_net(sock_net(newsk));
26858 + sock_vx_init(newsk);
26859 + sock_nx_init(newsk);
26860 sk_node_init(&newsk->sk_node);
26861 sock_lock_init(newsk);
26862 bh_lock_sock(newsk);
26863 @@ -1222,6 +1235,12 @@ struct sock *sk_clone(const struct sock
26865 atomic_set(&newsk->sk_refcnt, 2);
26867 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26868 + newsk->sk_xid = sk->sk_xid;
26869 + vx_sock_inc(newsk);
26870 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26871 + newsk->sk_nid = sk->sk_nid;
26874 * Increment the counter in the same struct proto as the master
26875 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26876 @@ -1964,6 +1983,12 @@ void sock_init_data(struct socket *sock,
26878 sk->sk_stamp = ktime_set(-1L, 0);
26880 + set_vx_info(&sk->sk_vx_info, current_vx_info());
26881 + sk->sk_xid = vx_current_xid();
26883 + set_nx_info(&sk->sk_nx_info, current_nx_info());
26884 + sk->sk_nid = nx_current_nid();
26887 * Before updating sk_refcnt, we must commit prior changes to memory
26888 * (Documentation/RCU/rculist_nulls.txt for details)
26889 diff -NurpP --minimal linux-2.6.35/net/ipv4/af_inet.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/af_inet.c
26890 --- linux-2.6.35/net/ipv4/af_inet.c 2010-08-02 16:52:59.000000000 +0200
26891 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/af_inet.c 2010-08-02 17:05:06.000000000 +0200
26892 @@ -116,6 +116,7 @@
26893 #ifdef CONFIG_IP_MROUTE
26894 #include <linux/mroute.h>
26896 +#include <linux/vs_limit.h>
26899 /* The inetsw table contains everything that inet_create needs to
26900 @@ -327,9 +328,13 @@ lookup_protocol:
26904 + if ((protocol == IPPROTO_ICMP) &&
26905 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
26908 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
26909 goto out_rcu_unlock;
26912 err = -EAFNOSUPPORT;
26913 if (!inet_netns_ok(net, protocol))
26914 goto out_rcu_unlock;
26915 @@ -451,6 +456,7 @@ int inet_bind(struct socket *sock, struc
26916 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26917 struct sock *sk = sock->sk;
26918 struct inet_sock *inet = inet_sk(sk);
26919 + struct nx_v4_sock_addr nsa;
26920 unsigned short snum;
26923 @@ -464,7 +470,11 @@ int inet_bind(struct socket *sock, struc
26924 if (addr_len < sizeof(struct sockaddr_in))
26927 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26928 + err = v4_map_sock_addr(inet, addr, &nsa);
26932 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26934 /* Not specified by any standard per-se, however it breaks too
26935 * many applications when removed. It is unfortunate since
26936 @@ -476,7 +486,7 @@ int inet_bind(struct socket *sock, struc
26937 err = -EADDRNOTAVAIL;
26938 if (!sysctl_ip_nonlocal_bind &&
26939 !(inet->freebind || inet->transparent) &&
26940 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26941 + nsa.saddr != htonl(INADDR_ANY) &&
26942 chk_addr_ret != RTN_LOCAL &&
26943 chk_addr_ret != RTN_MULTICAST &&
26944 chk_addr_ret != RTN_BROADCAST)
26945 @@ -501,7 +511,7 @@ int inet_bind(struct socket *sock, struc
26946 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
26947 goto out_release_sock;
26949 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
26950 + v4_set_sock_addr(inet, &nsa);
26951 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26952 inet->inet_saddr = 0; /* Use device */
26954 @@ -703,11 +713,13 @@ int inet_getname(struct socket *sock, st
26957 sin->sin_port = inet->inet_dport;
26958 - sin->sin_addr.s_addr = inet->inet_daddr;
26959 + sin->sin_addr.s_addr =
26960 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
26962 __be32 addr = inet->inet_rcv_saddr;
26964 addr = inet->inet_saddr;
26965 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
26966 sin->sin_port = inet->inet_sport;
26967 sin->sin_addr.s_addr = addr;
26969 diff -NurpP --minimal linux-2.6.35/net/ipv4/devinet.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/devinet.c
26970 --- linux-2.6.35/net/ipv4/devinet.c 2010-08-02 16:52:59.000000000 +0200
26971 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/devinet.c 2010-08-02 17:05:06.000000000 +0200
26972 @@ -417,6 +417,7 @@ struct in_device *inetdev_by_index(struc
26974 EXPORT_SYMBOL(inetdev_by_index);
26977 /* Called only from RTNL semaphored context. No locks. */
26979 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
26980 @@ -659,6 +660,8 @@ int devinet_ioctl(struct net *net, unsig
26982 in_dev = __in_dev_get_rtnl(dev);
26984 + struct nx_info *nxi = current_nx_info();
26986 if (tryaddrmatch) {
26987 /* Matthias Andree */
26988 /* compare label and address (4.4BSD style) */
26989 @@ -667,6 +670,8 @@ int devinet_ioctl(struct net *net, unsig
26990 This is checked above. */
26991 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26992 ifap = &ifa->ifa_next) {
26993 + if (!nx_v4_ifa_visible(nxi, ifa))
26995 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26996 sin_orig.sin_addr.s_addr ==
26997 ifa->ifa_address) {
26998 @@ -679,9 +684,12 @@ int devinet_ioctl(struct net *net, unsig
26999 comparing just the label */
27001 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27002 - ifap = &ifa->ifa_next)
27003 + ifap = &ifa->ifa_next) {
27004 + if (!nx_v4_ifa_visible(nxi, ifa))
27006 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
27012 @@ -833,6 +841,8 @@ static int inet_gifconf(struct net_devic
27015 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
27016 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
27019 done += sizeof(ifr);
27021 @@ -1181,6 +1191,7 @@ static int inet_dump_ifaddr(struct sk_bu
27022 struct net_device *dev;
27023 struct in_device *in_dev;
27024 struct in_ifaddr *ifa;
27025 + struct sock *sk = skb->sk;
27026 struct hlist_head *head;
27027 struct hlist_node *node;
27029 @@ -1203,6 +1214,8 @@ static int inet_dump_ifaddr(struct sk_bu
27031 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
27032 ifa = ifa->ifa_next, ip_idx++) {
27033 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
27035 if (ip_idx < s_ip_idx)
27037 if (inet_fill_ifaddr(skb, ifa,
27038 diff -NurpP --minimal linux-2.6.35/net/ipv4/fib_hash.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/fib_hash.c
27039 --- linux-2.6.35/net/ipv4/fib_hash.c 2010-07-07 18:31:59.000000000 +0200
27040 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/fib_hash.c 2010-08-02 17:05:06.000000000 +0200
27041 @@ -1017,7 +1017,7 @@ static int fib_seq_show(struct seq_file
27042 prefix = f->fn_key;
27043 mask = FZ_MASK(iter->zone);
27044 flags = fib_flag_trans(fa->fa_type, mask, fi);
27046 + if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
27048 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
27049 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
27050 diff -NurpP --minimal linux-2.6.35/net/ipv4/inet_connection_sock.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/inet_connection_sock.c
27051 --- linux-2.6.35/net/ipv4/inet_connection_sock.c 2010-08-02 16:52:59.000000000 +0200
27052 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/inet_connection_sock.c 2010-08-02 17:05:06.000000000 +0200
27053 @@ -52,10 +52,40 @@ void inet_get_local_port_range(int *low,
27055 EXPORT_SYMBOL(inet_get_local_port_range);
27057 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27059 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
27060 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
27062 + if (inet_v6_ipv6only(sk2))
27065 + if (sk1_rcv_saddr &&
27067 + sk1_rcv_saddr == sk2_rcv_saddr)
27070 + if (sk1_rcv_saddr &&
27071 + !sk2_rcv_saddr &&
27072 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
27075 + if (sk2_rcv_saddr &&
27076 + !sk1_rcv_saddr &&
27077 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
27080 + if (!sk1_rcv_saddr &&
27081 + !sk2_rcv_saddr &&
27082 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
27088 int inet_csk_bind_conflict(const struct sock *sk,
27089 const struct inet_bind_bucket *tb)
27091 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
27093 struct hlist_node *node;
27094 int reuse = sk->sk_reuse;
27095 @@ -75,9 +105,7 @@ int inet_csk_bind_conflict(const struct
27096 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
27097 if (!reuse || !sk2->sk_reuse ||
27098 sk2->sk_state == TCP_LISTEN) {
27099 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27100 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
27101 - sk2_rcv_saddr == sk_rcv_saddr)
27102 + if (ipv4_rcv_saddr_equal(sk, sk2))
27106 diff -NurpP --minimal linux-2.6.35/net/ipv4/inet_diag.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/inet_diag.c
27107 --- linux-2.6.35/net/ipv4/inet_diag.c 2010-07-07 18:31:59.000000000 +0200
27108 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/inet_diag.c 2010-08-02 17:05:06.000000000 +0200
27110 #include <linux/stddef.h>
27112 #include <linux/inet_diag.h>
27113 +#include <linux/vs_network.h>
27114 +#include <linux/vs_inet.h>
27116 static const struct inet_diag_handler **inet_diag_table;
27118 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
27120 r->id.idiag_sport = inet->inet_sport;
27121 r->id.idiag_dport = inet->inet_dport;
27122 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
27123 - r->id.idiag_dst[0] = inet->inet_daddr;
27124 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
27125 + inet->inet_rcv_saddr);
27126 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
27127 + inet->inet_daddr);
27129 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27130 if (r->idiag_family == AF_INET6) {
27131 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
27132 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
27133 r->id.idiag_sport = tw->tw_sport;
27134 r->id.idiag_dport = tw->tw_dport;
27135 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
27136 - r->id.idiag_dst[0] = tw->tw_daddr;
27137 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
27138 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
27139 r->idiag_state = tw->tw_substate;
27140 r->idiag_timer = 3;
27141 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
27142 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
27145 if (req->idiag_family == AF_INET) {
27146 + /* TODO: lback */
27147 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
27148 req->id.idiag_dport, req->id.idiag_src[0],
27149 req->id.idiag_sport, req->id.idiag_if);
27150 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
27154 + /* TODO: lback */
27155 entry.saddr = &inet->inet_rcv_saddr;
27156 entry.daddr = &inet->inet_daddr;
27158 @@ -541,6 +547,7 @@ static int inet_twsk_diag_dump(struct in
27162 + /* TODO: lback */
27163 entry.saddr = &tw->tw_rcv_saddr;
27164 entry.daddr = &tw->tw_daddr;
27166 @@ -587,8 +594,8 @@ static int inet_diag_fill_req(struct sk_
27168 r->id.idiag_sport = inet->inet_sport;
27169 r->id.idiag_dport = ireq->rmt_port;
27170 - r->id.idiag_src[0] = ireq->loc_addr;
27171 - r->id.idiag_dst[0] = ireq->rmt_addr;
27172 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
27173 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
27174 r->idiag_expires = jiffies_to_msecs(tmo);
27175 r->idiag_rqueue = 0;
27176 r->idiag_wqueue = 0;
27177 @@ -658,6 +665,7 @@ static int inet_diag_dump_reqs(struct sk
27181 + /* TODO: lback */
27183 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27184 (entry.family == AF_INET6) ?
27185 @@ -728,6 +736,8 @@ static int inet_diag_dump(struct sk_buff
27186 sk_nulls_for_each(sk, node, &ilb->head) {
27187 struct inet_sock *inet = inet_sk(sk);
27189 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27194 @@ -794,6 +804,8 @@ skip_listen_ht:
27195 sk_nulls_for_each(sk, node, &head->chain) {
27196 struct inet_sock *inet = inet_sk(sk);
27198 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27202 if (!(r->idiag_states & (1 << sk->sk_state)))
27203 @@ -818,6 +830,8 @@ next_normal:
27204 inet_twsk_for_each(tw, node,
27207 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27211 if (r->id.idiag_sport != tw->tw_sport &&
27212 diff -NurpP --minimal linux-2.6.35/net/ipv4/inet_hashtables.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/inet_hashtables.c
27213 --- linux-2.6.35/net/ipv4/inet_hashtables.c 2010-08-02 16:52:59.000000000 +0200
27214 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/inet_hashtables.c 2010-08-02 17:05:06.000000000 +0200
27217 #include <net/inet_connection_sock.h>
27218 #include <net/inet_hashtables.h>
27219 +#include <net/route.h>
27220 #include <net/ip.h>
27223 @@ -134,6 +135,11 @@ static inline int compute_score(struct s
27224 if (rcv_saddr != daddr)
27228 + /* block non nx_info ips */
27229 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27230 + daddr, NXA_MASK_BIND))
27233 if (sk->sk_bound_dev_if) {
27234 if (sk->sk_bound_dev_if != dif)
27235 @@ -151,7 +157,6 @@ static inline int compute_score(struct s
27236 * wildcarded during the search since they can never be otherwise.
27240 struct sock *__inet_lookup_listener(struct net *net,
27241 struct inet_hashinfo *hashinfo,
27242 const __be32 daddr, const unsigned short hnum,
27243 @@ -174,6 +179,7 @@ begin:
27249 * if the nulls value we got at the end of this lookup is
27250 * not the expected one, we must restart lookup.
27251 diff -NurpP --minimal linux-2.6.35/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/netfilter/nf_nat_helper.c
27252 --- linux-2.6.35/net/ipv4/netfilter/nf_nat_helper.c 2010-07-07 18:31:59.000000000 +0200
27253 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/netfilter/nf_nat_helper.c 2010-08-02 17:05:06.000000000 +0200
27255 #include <net/route.h>
27257 #include <linux/netfilter_ipv4.h>
27258 +#include <net/route.h>
27259 #include <net/netfilter/nf_conntrack.h>
27260 #include <net/netfilter/nf_conntrack_helper.h>
27261 #include <net/netfilter/nf_conntrack_ecache.h>
27262 diff -NurpP --minimal linux-2.6.35/net/ipv4/netfilter.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/netfilter.c
27263 --- linux-2.6.35/net/ipv4/netfilter.c 2010-08-02 16:52:59.000000000 +0200
27264 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/netfilter.c 2010-08-02 17:05:06.000000000 +0200
27266 #include <linux/ip.h>
27267 #include <linux/skbuff.h>
27268 #include <linux/gfp.h>
27269 -#include <net/route.h>
27270 +// #include <net/route.h>
27271 #include <net/xfrm.h>
27272 #include <net/ip.h>
27273 #include <net/netfilter/nf_queue.h>
27274 diff -NurpP --minimal linux-2.6.35/net/ipv4/raw.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/raw.c
27275 --- linux-2.6.35/net/ipv4/raw.c 2010-08-02 16:52:59.000000000 +0200
27276 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/raw.c 2010-08-02 18:19:23.000000000 +0200
27277 @@ -116,7 +116,7 @@ static struct sock *__raw_v4_lookup(stru
27279 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
27280 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
27281 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
27282 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
27283 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
27284 goto found; /* gotcha */
27286 @@ -381,6 +381,12 @@ static int raw_send_hdrinc(struct sock *
27287 icmp_out_count(net, ((struct icmphdr *)
27288 skb_transport_header(skb))->type);
27291 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
27292 + sk->sk_nx_info &&
27293 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
27296 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
27297 rt->u.dst.dev, dst_output);
27299 @@ -561,6 +567,13 @@ static int raw_sendmsg(struct kiocb *ioc
27302 security_sk_classify_flow(sk, &fl);
27303 + if (sk->sk_nx_info) {
27304 + err = ip_v4_find_src(sock_net(sk),
27305 + sk->sk_nx_info, &rt, &fl);
27310 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
27313 @@ -633,17 +646,19 @@ static int raw_bind(struct sock *sk, str
27315 struct inet_sock *inet = inet_sk(sk);
27316 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
27317 + struct nx_v4_sock_addr nsa = { 0 };
27321 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
27323 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27324 + v4_map_sock_addr(inet, addr, &nsa);
27325 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27326 ret = -EADDRNOTAVAIL;
27327 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
27328 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
27329 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
27331 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
27332 + v4_set_sock_addr(inet, &nsa);
27333 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27334 inet->inet_saddr = 0; /* Use device */
27336 @@ -695,7 +710,8 @@ static int raw_recvmsg(struct kiocb *ioc
27337 /* Copy the address. */
27339 sin->sin_family = AF_INET;
27340 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27341 + sin->sin_addr.s_addr =
27342 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
27344 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
27346 @@ -873,7 +889,8 @@ static struct sock *raw_get_first(struct
27347 struct hlist_node *node;
27349 sk_for_each(sk, node, &state->h->ht[state->bucket])
27350 - if (sock_net(sk) == seq_file_net(seq))
27351 + if ((sock_net(sk) == seq_file_net(seq)) &&
27352 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27356 @@ -889,7 +906,8 @@ static struct sock *raw_get_next(struct
27360 - } while (sk && sock_net(sk) != seq_file_net(seq));
27361 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
27362 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27364 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
27365 sk = sk_head(&state->h->ht[state->bucket]);
27366 @@ -948,7 +966,10 @@ static void raw_sock_seq_show(struct seq
27368 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
27369 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
27370 - i, src, srcp, dest, destp, sp->sk_state,
27372 + nx_map_sock_lback(current_nx_info(), src), srcp,
27373 + nx_map_sock_lback(current_nx_info(), dest), destp,
27375 sk_wmem_alloc_get(sp),
27376 sk_rmem_alloc_get(sp),
27377 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27378 diff -NurpP --minimal linux-2.6.35/net/ipv4/tcp.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/tcp.c
27379 --- linux-2.6.35/net/ipv4/tcp.c 2010-08-02 16:52:59.000000000 +0200
27380 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/tcp.c 2010-08-02 17:05:06.000000000 +0200
27381 @@ -266,6 +266,7 @@
27382 #include <linux/crypto.h>
27383 #include <linux/time.h>
27384 #include <linux/slab.h>
27385 +#include <linux/in.h>
27387 #include <net/icmp.h>
27388 #include <net/tcp.h>
27389 diff -NurpP --minimal linux-2.6.35/net/ipv4/tcp_ipv4.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/tcp_ipv4.c
27390 --- linux-2.6.35/net/ipv4/tcp_ipv4.c 2010-08-02 16:52:59.000000000 +0200
27391 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/tcp_ipv4.c 2010-08-02 17:05:06.000000000 +0200
27392 @@ -2004,6 +2004,12 @@ static void *listening_get_next(struct s
27393 req = req->dl_next;
27396 + vxdprintk(VXD_CBIT(net, 6),
27397 + "sk,req: %p [#%d] (from %d)", req->sk,
27398 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27400 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27402 if (req->rsk_ops->family == st->family) {
27405 @@ -2028,6 +2034,10 @@ get_req:
27408 sk_nulls_for_each_from(sk, node) {
27409 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27410 + sk, sk->sk_nid, nx_current_nid());
27411 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27413 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
27416 @@ -2091,6 +2101,11 @@ static void *established_get_first(struc
27418 spin_lock_bh(lock);
27419 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27420 + vxdprintk(VXD_CBIT(net, 6),
27421 + "sk,egf: %p [#%d] (from %d)",
27422 + sk, sk->sk_nid, nx_current_nid());
27423 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27425 if (sk->sk_family != st->family ||
27426 !net_eq(sock_net(sk), net)) {
27428 @@ -2101,6 +2116,11 @@ static void *established_get_first(struc
27429 st->state = TCP_SEQ_STATE_TIME_WAIT;
27430 inet_twsk_for_each(tw, node,
27431 &tcp_hashinfo.ehash[st->bucket].twchain) {
27432 + vxdprintk(VXD_CBIT(net, 6),
27433 + "tw: %p [#%d] (from %d)",
27434 + tw, tw->tw_nid, nx_current_nid());
27435 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27437 if (tw->tw_family != st->family ||
27438 !net_eq(twsk_net(tw), net)) {
27440 @@ -2129,7 +2149,9 @@ static void *established_get_next(struct
27444 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
27445 + while (tw && (tw->tw_family != st->family ||
27446 + !net_eq(twsk_net(tw), net) ||
27447 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27451 @@ -2152,6 +2174,11 @@ get_tw:
27452 sk = sk_nulls_next(sk);
27454 sk_nulls_for_each_from(sk, node) {
27455 + vxdprintk(VXD_CBIT(net, 6),
27456 + "sk,egn: %p [#%d] (from %d)",
27457 + sk, sk->sk_nid, nx_current_nid());
27458 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27460 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
27463 @@ -2303,9 +2330,9 @@ static void get_openreq4(struct sock *sk
27464 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27465 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
27468 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
27469 ntohs(inet_sk(sk)->inet_sport),
27471 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
27472 ntohs(ireq->rmt_port),
27474 0, 0, /* could print option size, but that is af dependent. */
27475 @@ -2357,7 +2384,10 @@ static void get_tcp4_sock(struct sock *s
27477 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
27478 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
27479 - i, src, srcp, dest, destp, sk->sk_state,
27481 + nx_map_sock_lback(current_nx_info(), src), srcp,
27482 + nx_map_sock_lback(current_nx_info(), dest), destp,
27484 tp->write_seq - tp->snd_una,
27487 @@ -2392,7 +2422,10 @@ static void get_timewait4_sock(struct in
27489 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27490 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
27491 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
27493 + nx_map_sock_lback(current_nx_info(), src), srcp,
27494 + nx_map_sock_lback(current_nx_info(), dest), destp,
27495 + tw->tw_substate, 0, 0,
27496 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
27497 atomic_read(&tw->tw_refcnt), tw, len);
27499 diff -NurpP --minimal linux-2.6.35/net/ipv4/tcp_minisocks.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/tcp_minisocks.c
27500 --- linux-2.6.35/net/ipv4/tcp_minisocks.c 2010-08-02 16:52:59.000000000 +0200
27501 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/tcp_minisocks.c 2010-08-02 17:05:06.000000000 +0200
27503 #include <linux/slab.h>
27504 #include <linux/sysctl.h>
27505 #include <linux/workqueue.h>
27506 +#include <linux/vs_limit.h>
27507 +#include <linux/vs_socket.h>
27508 +#include <linux/vs_context.h>
27509 #include <net/tcp.h>
27510 #include <net/inet_common.h>
27511 #include <net/xfrm.h>
27512 @@ -290,6 +293,11 @@ void tcp_time_wait(struct sock *sk, int
27513 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
27514 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27516 + tw->tw_xid = sk->sk_xid;
27517 + tw->tw_vx_info = NULL;
27518 + tw->tw_nid = sk->sk_nid;
27519 + tw->tw_nx_info = NULL;
27521 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27522 if (tw->tw_family == PF_INET6) {
27523 struct ipv6_pinfo *np = inet6_sk(sk);
27524 diff -NurpP --minimal linux-2.6.35/net/ipv4/udp.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/udp.c
27525 --- linux-2.6.35/net/ipv4/udp.c 2010-08-02 16:52:59.000000000 +0200
27526 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/udp.c 2010-08-02 17:05:06.000000000 +0200
27527 @@ -296,14 +296,7 @@ fail:
27529 EXPORT_SYMBOL(udp_lib_get_port);
27531 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27533 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27535 - return (!ipv6_only_sock(sk2) &&
27536 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
27537 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
27539 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27541 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
27543 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
27544 if (inet->inet_rcv_saddr != daddr)
27548 + /* block non nx_info ips */
27549 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27550 + daddr, NXA_MASK_BIND))
27553 if (inet->inet_daddr) {
27554 if (inet->inet_daddr != saddr)
27555 @@ -441,6 +439,7 @@ exact_match:
27560 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27561 * harder than this. -DaveM
27563 @@ -486,6 +485,11 @@ begin:
27564 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
27565 score = compute_score(sk, net, saddr, hnum, sport,
27566 daddr, dport, dif);
27567 + /* FIXME: disabled?
27568 + if (score == 9) {
27572 if (score > badness) {
27575 @@ -499,6 +503,7 @@ begin:
27576 if (get_nulls_value(node) != slot)
27581 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
27583 @@ -508,6 +513,7 @@ begin:
27591 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
27592 udp_sk(s)->udp_port_hash != hnum ||
27593 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
27594 (inet->inet_dport != rmt_port && inet->inet_dport) ||
27595 - (inet->inet_rcv_saddr &&
27596 - inet->inet_rcv_saddr != loc_addr) ||
27597 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27598 ipv6_only_sock(s) ||
27599 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27601 @@ -900,8 +905,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
27602 { .sport = inet->inet_sport,
27603 .dport = dport } } };
27604 struct net *net = sock_net(sk);
27605 + struct nx_info *nxi = sk->sk_nx_info;
27607 security_sk_classify_flow(sk, &fl);
27608 + err = ip_v4_find_src(net, nxi, &rt, &fl);
27612 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
27614 if (err == -ENETUNREACH)
27615 @@ -1183,7 +1193,8 @@ try_again:
27617 sin->sin_family = AF_INET;
27618 sin->sin_port = udp_hdr(skb)->source;
27619 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27620 + sin->sin_addr.s_addr = nx_map_sock_lback(
27621 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27622 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27624 if (inet->cmsg_flags)
27625 @@ -1879,6 +1890,8 @@ static struct sock *udp_get_first(struct
27626 sk_nulls_for_each(sk, node, &hslot->head) {
27627 if (!net_eq(sock_net(sk), net))
27629 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27631 if (sk->sk_family == state->family)
27634 @@ -1896,7 +1909,9 @@ static struct sock *udp_get_next(struct
27637 sk = sk_nulls_next(sk);
27638 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27639 + } while (sk && (!net_eq(sock_net(sk), net) ||
27640 + sk->sk_family != state->family ||
27641 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27644 if (state->bucket <= state->udp_table->mask)
27645 @@ -2003,7 +2018,10 @@ static void udp4_format_sock(struct sock
27647 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
27648 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
27649 - bucket, src, srcp, dest, destp, sp->sk_state,
27651 + nx_map_sock_lback(current_nx_info(), src), srcp,
27652 + nx_map_sock_lback(current_nx_info(), dest), destp,
27654 sk_wmem_alloc_get(sp),
27655 sk_rmem_alloc_get(sp),
27656 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27657 diff -NurpP --minimal linux-2.6.35/net/ipv6/addrconf.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/addrconf.c
27658 --- linux-2.6.35/net/ipv6/addrconf.c 2010-08-02 16:52:59.000000000 +0200
27659 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/addrconf.c 2010-08-02 17:05:06.000000000 +0200
27662 #include <linux/proc_fs.h>
27663 #include <linux/seq_file.h>
27664 +#include <linux/vs_network.h>
27665 +#include <linux/vs_inet6.h>
27667 /* Set to 3 to get tracing... */
27668 #define ACONF_DEBUG 2
27669 @@ -1117,7 +1119,7 @@ out:
27671 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27672 const struct in6_addr *daddr, unsigned int prefs,
27673 - struct in6_addr *saddr)
27674 + struct in6_addr *saddr, struct nx_info *nxi)
27676 struct ipv6_saddr_score scores[2],
27677 *score = &scores[0], *hiscore = &scores[1];
27678 @@ -1189,6 +1191,8 @@ int ipv6_dev_get_saddr(struct net *net,
27682 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
27686 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
27687 @@ -3074,7 +3078,10 @@ static void if6_seq_stop(struct seq_file
27688 static int if6_seq_show(struct seq_file *seq, void *v)
27690 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27691 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27693 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27694 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27695 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27697 ifp->idev->dev->ifindex,
27699 @@ -3578,6 +3585,11 @@ static int in6_dump_addrs(struct inet6_d
27700 struct ifacaddr6 *ifaca;
27702 int ip_idx = *p_ip_idx;
27703 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27705 + /* disable ipv6 on non v6 guests */
27706 + if (nxi && !nx_info_has_v6(nxi))
27709 read_lock_bh(&idev->lock);
27711 @@ -3588,6 +3600,8 @@ static int in6_dump_addrs(struct inet6_d
27712 list_for_each_entry(ifa, &idev->addr_list, if_list) {
27713 if (++ip_idx < s_ip_idx)
27715 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27717 err = inet6_fill_ifaddr(skb, ifa,
27718 NETLINK_CB(cb->skb).pid,
27719 cb->nlh->nlmsg_seq,
27720 @@ -3604,6 +3618,8 @@ static int in6_dump_addrs(struct inet6_d
27721 ifmca = ifmca->next, ip_idx++) {
27722 if (ip_idx < s_ip_idx)
27724 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
27726 err = inet6_fill_ifmcaddr(skb, ifmca,
27727 NETLINK_CB(cb->skb).pid,
27728 cb->nlh->nlmsg_seq,
27729 @@ -3619,6 +3635,8 @@ static int in6_dump_addrs(struct inet6_d
27730 ifaca = ifaca->aca_next, ip_idx++) {
27731 if (ip_idx < s_ip_idx)
27733 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
27735 err = inet6_fill_ifacaddr(skb, ifaca,
27736 NETLINK_CB(cb->skb).pid,
27737 cb->nlh->nlmsg_seq,
27738 @@ -3950,6 +3968,11 @@ static int inet6_dump_ifinfo(struct sk_b
27739 struct inet6_dev *idev;
27740 struct hlist_head *head;
27741 struct hlist_node *node;
27742 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27744 + /* FIXME: maybe disable ipv6 on non v6 guests?
27745 + if (skb->sk && skb->sk->sk_vx_info)
27746 + return skb->len; */
27749 s_idx = cb->args[1];
27750 @@ -3961,6 +3984,8 @@ static int inet6_dump_ifinfo(struct sk_b
27751 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
27754 + if (!v6_dev_in_nx_info(dev, nxi))
27756 idev = __in6_dev_get(dev);
27759 diff -NurpP --minimal linux-2.6.35/net/ipv6/af_inet6.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/af_inet6.c
27760 --- linux-2.6.35/net/ipv6/af_inet6.c 2010-08-02 16:52:59.000000000 +0200
27761 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/af_inet6.c 2010-08-02 17:05:06.000000000 +0200
27763 #include <linux/netdevice.h>
27764 #include <linux/icmpv6.h>
27765 #include <linux/netfilter_ipv6.h>
27766 +#include <linux/vs_inet.h>
27767 +#include <linux/vs_inet6.h>
27769 #include <net/ip.h>
27770 #include <net/ipv6.h>
27771 @@ -160,9 +162,12 @@ lookup_protocol:
27775 + if ((protocol == IPPROTO_ICMPV6) &&
27776 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
27778 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
27779 goto out_rcu_unlock;
27782 sock->ops = answer->ops;
27783 answer_prot = answer->prot;
27784 answer_no_check = answer->no_check;
27785 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
27786 struct inet_sock *inet = inet_sk(sk);
27787 struct ipv6_pinfo *np = inet6_sk(sk);
27788 struct net *net = sock_net(sk);
27789 + struct nx_v6_sock_addr nsa;
27791 unsigned short snum;
27793 @@ -272,6 +278,11 @@ int inet6_bind(struct socket *sock, stru
27795 if (addr_len < SIN6_LEN_RFC2133)
27798 + err = v6_map_sock_addr(inet, addr, &nsa);
27802 addr_type = ipv6_addr_type(&addr->sin6_addr);
27803 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
27805 @@ -303,6 +314,7 @@ int inet6_bind(struct socket *sock, stru
27806 /* Reproduce AF_INET checks to make the bindings consitant */
27807 v4addr = addr->sin6_addr.s6_addr32[3];
27808 chk_addr_ret = inet_addr_type(net, v4addr);
27810 if (!sysctl_ip_nonlocal_bind &&
27811 !(inet->freebind || inet->transparent) &&
27812 v4addr != htonl(INADDR_ANY) &&
27813 @@ -312,6 +324,10 @@ int inet6_bind(struct socket *sock, stru
27814 err = -EADDRNOTAVAIL;
27817 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
27818 + err = -EADDRNOTAVAIL;
27822 if (addr_type != IPV6_ADDR_ANY) {
27823 struct net_device *dev = NULL;
27824 @@ -338,6 +354,11 @@ int inet6_bind(struct socket *sock, stru
27828 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27829 + err = -EADDRNOTAVAIL;
27833 /* ipv4 addr of the socket is invalid. Only the
27834 * unspecified and mapped address have a v4 equivalent.
27836 @@ -353,6 +374,9 @@ int inet6_bind(struct socket *sock, stru
27840 + /* what's that for? */
27841 + v6_set_sock_addr(inet, &nsa);
27843 inet->inet_rcv_saddr = v4addr;
27844 inet->inet_saddr = v4addr;
27846 @@ -454,9 +478,11 @@ int inet6_getname(struct socket *sock, s
27848 sin->sin6_port = inet->inet_dport;
27849 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27850 + /* FIXME: remap lback? */
27852 sin->sin6_flowinfo = np->flow_label;
27854 + /* FIXME: remap lback? */
27855 if (ipv6_addr_any(&np->rcv_saddr))
27856 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27858 diff -NurpP --minimal linux-2.6.35/net/ipv6/fib6_rules.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/fib6_rules.c
27859 --- linux-2.6.35/net/ipv6/fib6_rules.c 2010-08-02 16:52:59.000000000 +0200
27860 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/fib6_rules.c 2010-08-02 17:05:06.000000000 +0200
27861 @@ -89,7 +89,7 @@ static int fib6_rule_action(struct fib_r
27862 ip6_dst_idev(&rt->u.dst)->dev,
27864 rt6_flags2srcprefs(flags),
27868 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27870 diff -NurpP --minimal linux-2.6.35/net/ipv6/inet6_hashtables.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/inet6_hashtables.c
27871 --- linux-2.6.35/net/ipv6/inet6_hashtables.c 2010-02-25 11:52:10.000000000 +0100
27872 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/inet6_hashtables.c 2010-08-02 17:05:06.000000000 +0200
27875 #include <linux/module.h>
27876 #include <linux/random.h>
27877 +#include <linux/vs_inet6.h>
27879 #include <net/inet_connection_sock.h>
27880 #include <net/inet_hashtables.h>
27881 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
27882 unsigned int slot = hash & hashinfo->ehash_mask;
27883 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
27888 sk_nulls_for_each_rcu(sk, node, &head->chain) {
27889 @@ -94,7 +94,7 @@ begin:
27897 if (get_nulls_value(node) != slot)
27898 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
27899 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27903 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27906 if (sk->sk_bound_dev_if) {
27907 if (sk->sk_bound_dev_if != dif)
27908 diff -NurpP --minimal linux-2.6.35/net/ipv6/ip6_output.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/ip6_output.c
27909 --- linux-2.6.35/net/ipv6/ip6_output.c 2010-08-02 16:52:59.000000000 +0200
27910 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/ip6_output.c 2010-08-02 17:05:06.000000000 +0200
27911 @@ -930,7 +930,7 @@ static int ip6_dst_lookup_tail(struct so
27912 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
27914 sk ? inet6_sk(sk)->srcprefs : 0,
27916 + &fl->fl6_src, sk->sk_nx_info);
27918 goto out_err_release;
27920 diff -NurpP --minimal linux-2.6.35/net/ipv6/Kconfig linux-2.6.35-vs2.3.0.36.31/net/ipv6/Kconfig
27921 --- linux-2.6.35/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
27922 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/Kconfig 2010-08-02 17:05:06.000000000 +0200
27925 # IPv6 as module will cause a CRASH if you try to unload it
27927 - tristate "The IPv6 protocol"
27929 + bool "The IPv6 protocol"
27932 This is complemental support for the IP version 6.
27933 You will still be able to do traditional IPv4 networking as well.
27934 diff -NurpP --minimal linux-2.6.35/net/ipv6/ndisc.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/ndisc.c
27935 --- linux-2.6.35/net/ipv6/ndisc.c 2010-08-02 16:53:00.000000000 +0200
27936 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/ndisc.c 2010-08-02 17:05:06.000000000 +0200
27937 @@ -591,7 +591,7 @@ static void ndisc_send_na(struct net_dev
27939 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27940 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27942 + &tmpaddr, NULL /* FIXME: ? */ ))
27944 src_addr = &tmpaddr;
27946 diff -NurpP --minimal linux-2.6.35/net/ipv6/raw.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/raw.c
27947 --- linux-2.6.35/net/ipv6/raw.c 2010-08-02 16:53:00.000000000 +0200
27948 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/raw.c 2010-08-02 17:05:06.000000000 +0200
27950 #include <linux/icmpv6.h>
27951 #include <linux/netfilter.h>
27952 #include <linux/netfilter_ipv6.h>
27953 +#include <linux/vs_inet6.h>
27954 #include <linux/skbuff.h>
27955 #include <asm/uaccess.h>
27956 #include <asm/ioctls.h>
27957 @@ -283,6 +284,13 @@ static int rawv6_bind(struct sock *sk, s
27961 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27962 + err = -EADDRNOTAVAIL;
27968 /* ipv4 addr of the socket is invalid. Only the
27969 * unspecified and mapped address have a v4 equivalent.
27971 diff -NurpP --minimal linux-2.6.35/net/ipv6/route.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/route.c
27972 --- linux-2.6.35/net/ipv6/route.c 2010-08-02 16:53:00.000000000 +0200
27973 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/route.c 2010-08-02 17:05:06.000000000 +0200
27974 @@ -2255,7 +2255,8 @@ static int rt6_fill_node(struct net *net
27975 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
27976 struct in6_addr saddr_buf;
27977 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
27978 - dst, 0, &saddr_buf) == 0)
27979 + dst, 0, &saddr_buf,
27980 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
27981 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
27984 diff -NurpP --minimal linux-2.6.35/net/ipv6/tcp_ipv6.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/tcp_ipv6.c
27985 --- linux-2.6.35/net/ipv6/tcp_ipv6.c 2010-08-02 16:53:00.000000000 +0200
27986 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/tcp_ipv6.c 2010-08-02 17:05:06.000000000 +0200
27989 #include <linux/crypto.h>
27990 #include <linux/scatterlist.h>
27991 +#include <linux/vs_inet6.h>
27993 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
27994 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
27995 @@ -160,8 +161,15 @@ static int tcp_v6_connect(struct sock *s
27996 * connect() to INADDR_ANY means loopback (BSD'ism).
27999 - if(ipv6_addr_any(&usin->sin6_addr))
28000 - usin->sin6_addr.s6_addr[15] = 0x1;
28001 + if(ipv6_addr_any(&usin->sin6_addr)) {
28002 + struct nx_info *nxi = sk->sk_nx_info;
28004 + if (nxi && nx_info_has_v6(nxi))
28005 + /* FIXME: remap lback? */
28006 + usin->sin6_addr = nxi->v6.ip;
28008 + usin->sin6_addr.s6_addr[15] = 0x1;
28011 addr_type = ipv6_addr_type(&usin->sin6_addr);
28013 diff -NurpP --minimal linux-2.6.35/net/ipv6/udp.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/udp.c
28014 --- linux-2.6.35/net/ipv6/udp.c 2010-08-02 16:53:00.000000000 +0200
28015 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/udp.c 2010-08-02 17:05:06.000000000 +0200
28016 @@ -48,13 +48,14 @@
28018 #include <linux/proc_fs.h>
28019 #include <linux/seq_file.h>
28020 +#include <linux/vs_inet6.h>
28021 #include "udp_impl.h"
28023 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
28025 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
28026 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
28027 - __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
28028 + __be32 sk_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
28029 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
28030 int sk_ipv6only = ipv6_only_sock(sk);
28031 int sk2_ipv6only = inet_v6_ipv6only(sk2);
28032 @@ -62,24 +63,49 @@ int ipv6_rcv_saddr_equal(const struct so
28033 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
28035 /* if both are mapped, treat as IPv4 */
28036 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
28037 - return (!sk2_ipv6only &&
28038 - (!sk1_rcv_saddr || !sk2_rcv_saddr ||
28039 - sk1_rcv_saddr == sk2_rcv_saddr));
28040 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
28041 + if (!sk2_ipv6only &&
28042 + (!sk_rcv_saddr || !sk2_rcv_saddr ||
28043 + sk_rcv_saddr == sk2_rcv_saddr))
28049 if (addr_type2 == IPV6_ADDR_ANY &&
28050 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
28054 if (addr_type == IPV6_ADDR_ANY &&
28055 !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
28059 if (sk2_rcv_saddr6 &&
28060 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
28067 + if (!sk_rcv_saddr && !sk2_rcv_saddr)
28068 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28069 + if (!sk2_rcv_saddr)
28070 + return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
28071 + if (!sk_rcv_saddr)
28072 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
28075 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
28076 + return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28077 + else if (addr_type2 == IPV6_ADDR_ANY)
28078 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
28079 + else if (addr_type == IPV6_ADDR_ANY) {
28080 + if (addr_type2 == IPV6_ADDR_MAPPED)
28081 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28083 + return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
28088 static unsigned int udp6_portaddr_hash(struct net *net,
28089 @@ -134,6 +160,10 @@ static inline int compute_score(struct s
28090 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28094 + /* block non nx_info ips */
28095 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28098 if (!ipv6_addr_any(&np->daddr)) {
28099 if (!ipv6_addr_equal(&np->daddr, saddr))
28100 diff -NurpP --minimal linux-2.6.35/net/ipv6/xfrm6_policy.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/xfrm6_policy.c
28101 --- linux-2.6.35/net/ipv6/xfrm6_policy.c 2010-08-02 16:53:00.000000000 +0200
28102 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/xfrm6_policy.c 2010-08-02 17:05:06.000000000 +0200
28103 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
28104 dev = ip6_dst_idev(dst)->dev;
28105 ipv6_dev_get_saddr(dev_net(dev), dev,
28106 (struct in6_addr *)&daddr->a6, 0,
28107 - (struct in6_addr *)&saddr->a6);
28108 + (struct in6_addr *)&saddr->a6, NULL);
28112 diff -NurpP --minimal linux-2.6.35/net/netlink/af_netlink.c linux-2.6.35-vs2.3.0.36.31/net/netlink/af_netlink.c
28113 --- linux-2.6.35/net/netlink/af_netlink.c 2010-08-02 16:53:01.000000000 +0200
28114 +++ linux-2.6.35-vs2.3.0.36.31/net/netlink/af_netlink.c 2010-08-02 17:05:06.000000000 +0200
28116 #include <linux/types.h>
28117 #include <linux/audit.h>
28118 #include <linux/mutex.h>
28119 +#include <linux/vs_context.h>
28120 +#include <linux/vs_network.h>
28121 +#include <linux/vs_limit.h>
28123 #include <net/net_namespace.h>
28124 #include <net/sock.h>
28125 @@ -1936,6 +1939,8 @@ static struct sock *netlink_seq_socket_i
28126 sk_for_each(s, node, &hash->table[j]) {
28127 if (sock_net(s) != seq_file_net(seq))
28129 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28133 iter->hash_idx = j;
28134 @@ -1970,7 +1975,8 @@ static void *netlink_seq_next(struct seq
28138 - } while (s && sock_net(s) != seq_file_net(seq));
28139 + } while (s && (sock_net(s) != seq_file_net(seq) ||
28140 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
28144 @@ -1982,7 +1988,8 @@ static void *netlink_seq_next(struct seq
28146 for (; j <= hash->mask; j++) {
28147 s = sk_head(&hash->table[j]);
28148 - while (s && sock_net(s) != seq_file_net(seq))
28149 + while (s && (sock_net(s) != seq_file_net(seq) ||
28150 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
28154 diff -NurpP --minimal linux-2.6.35/net/sctp/ipv6.c linux-2.6.35-vs2.3.0.36.31/net/sctp/ipv6.c
28155 --- linux-2.6.35/net/sctp/ipv6.c 2010-08-02 16:53:01.000000000 +0200
28156 +++ linux-2.6.35-vs2.3.0.36.31/net/sctp/ipv6.c 2010-08-02 17:05:06.000000000 +0200
28157 @@ -304,7 +304,8 @@ static void sctp_v6_get_saddr(struct sct
28158 dst ? ip6_dst_idev(dst)->dev : NULL,
28159 &daddr->v6.sin6_addr,
28160 inet6_sk(&sk->inet.sk)->srcprefs,
28161 - &saddr->v6.sin6_addr);
28162 + &saddr->v6.sin6_addr,
28163 + asoc->base.sk->sk_nx_info);
28164 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
28165 &saddr->v6.sin6_addr);
28167 diff -NurpP --minimal linux-2.6.35/net/socket.c linux-2.6.35-vs2.3.0.36.31/net/socket.c
28168 --- linux-2.6.35/net/socket.c 2010-08-02 16:53:02.000000000 +0200
28169 +++ linux-2.6.35-vs2.3.0.36.31/net/socket.c 2010-08-02 17:05:06.000000000 +0200
28172 #include <net/sock.h>
28173 #include <linux/netfilter.h>
28174 +#include <linux/vs_base.h>
28175 +#include <linux/vs_socket.h>
28176 +#include <linux/vs_inet.h>
28177 +#include <linux/vs_inet6.h>
28179 #include <linux/if_tun.h>
28180 #include <linux/ipv6_route.h>
28181 @@ -557,7 +561,7 @@ static inline int __sock_sendmsg(struct
28182 struct msghdr *msg, size_t size)
28184 struct sock_iocb *si = kiocb_to_siocb(iocb);
28188 sock_update_classid(sock->sk);
28190 @@ -570,7 +574,22 @@ static inline int __sock_sendmsg(struct
28194 - return sock->ops->sendmsg(iocb, sock, msg, size);
28195 + len = sock->ops->sendmsg(iocb, sock, msg, size);
28198 + vx_sock_send(sock->sk, size);
28200 + vx_sock_fail(sock->sk, size);
28202 + vxdprintk(VXD_CBIT(net, 7),
28203 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28205 + (sock->sk)?sock->sk->sk_nx_info:0,
28206 + (sock->sk)?sock->sk->sk_vx_info:0,
28207 + (sock->sk)?sock->sk->sk_xid:0,
28208 + (sock->sk)?sock->sk->sk_nid:0,
28209 + (unsigned int)size, len);
28213 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
28214 @@ -686,6 +705,7 @@ static inline int __sock_recvmsg_nosec(s
28215 struct msghdr *msg, size_t size, int flags)
28217 struct sock_iocb *si = kiocb_to_siocb(iocb);
28220 sock_update_classid(sock->sk);
28222 @@ -695,7 +715,18 @@ static inline int __sock_recvmsg_nosec(s
28226 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
28227 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
28228 + if ((len >= 0) && sock->sk)
28229 + vx_sock_recv(sock->sk, len);
28230 + vxdprintk(VXD_CBIT(net, 7),
28231 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28233 + (sock->sk)?sock->sk->sk_nx_info:0,
28234 + (sock->sk)?sock->sk->sk_vx_info:0,
28235 + (sock->sk)?sock->sk->sk_xid:0,
28236 + (sock->sk)?sock->sk->sk_nid:0,
28237 + (unsigned int)size, len);
28241 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
28242 @@ -1163,6 +1194,13 @@ static int __sock_create(struct net *net
28243 if (type < 0 || type >= SOCK_MAX)
28246 + if (!nx_check(0, VS_ADMIN)) {
28247 + if (family == PF_INET && !current_nx_info_has_v4())
28248 + return -EAFNOSUPPORT;
28249 + if (family == PF_INET6 && !current_nx_info_has_v6())
28250 + return -EAFNOSUPPORT;
28255 This uglymoron is moved from INET layer to here to avoid
28256 @@ -1295,6 +1333,7 @@ SYSCALL_DEFINE3(socket, int, family, int
28260 + set_bit(SOCK_USER_SOCKET, &sock->flags);
28261 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
28264 @@ -1336,10 +1375,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
28265 err = sock_create(family, type, protocol, &sock1);
28268 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
28270 err = sock_create(family, type, protocol, &sock2);
28272 goto out_release_1;
28273 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
28275 err = sock1->ops->socketpair(sock1, sock2);
28277 diff -NurpP --minimal linux-2.6.35/net/sunrpc/auth.c linux-2.6.35-vs2.3.0.36.31/net/sunrpc/auth.c
28278 --- linux-2.6.35/net/sunrpc/auth.c 2010-08-02 16:53:02.000000000 +0200
28279 +++ linux-2.6.35-vs2.3.0.36.31/net/sunrpc/auth.c 2010-08-02 17:05:06.000000000 +0200
28281 #include <linux/hash.h>
28282 #include <linux/sunrpc/clnt.h>
28283 #include <linux/spinlock.h>
28284 +#include <linux/vs_tag.h>
28287 # define RPCDBG_FACILITY RPCDBG_AUTH
28288 @@ -366,6 +367,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
28289 memset(&acred, 0, sizeof(acred));
28290 acred.uid = cred->fsuid;
28291 acred.gid = cred->fsgid;
28292 + acred.tag = dx_current_tag();
28293 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
28295 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
28296 @@ -406,6 +408,7 @@ rpcauth_bind_root_cred(struct rpc_task *
28297 struct auth_cred acred = {
28300 + .tag = dx_current_tag(),
28302 struct rpc_cred *ret;
28304 diff -NurpP --minimal linux-2.6.35/net/sunrpc/auth_unix.c linux-2.6.35-vs2.3.0.36.31/net/sunrpc/auth_unix.c
28305 --- linux-2.6.35/net/sunrpc/auth_unix.c 2010-07-07 18:32:01.000000000 +0200
28306 +++ linux-2.6.35-vs2.3.0.36.31/net/sunrpc/auth_unix.c 2010-08-02 17:05:06.000000000 +0200
28307 @@ -12,12 +12,14 @@
28308 #include <linux/module.h>
28309 #include <linux/sunrpc/clnt.h>
28310 #include <linux/sunrpc/auth.h>
28311 +#include <linux/vs_tag.h>
28313 #define NFS_NGROUPS 16
28316 struct rpc_cred uc_base;
28319 gid_t uc_gids[NFS_NGROUPS];
28321 #define uc_uid uc_base.cr_uid
28322 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
28323 groups = NFS_NGROUPS;
28325 cred->uc_gid = acred->gid;
28326 + cred->uc_tag = acred->tag;
28327 for (i = 0; i < groups; i++)
28328 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
28329 if (i < NFS_NGROUPS)
28330 @@ -120,7 +123,9 @@ unx_match(struct auth_cred *acred, struc
28334 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
28335 + if (cred->uc_uid != acred->uid ||
28336 + cred->uc_gid != acred->gid ||
28337 + cred->uc_tag != acred->tag)
28340 if (acred->group_info != NULL)
28341 @@ -143,7 +148,7 @@ unx_marshal(struct rpc_task *task, __be3
28342 struct rpc_clnt *clnt = task->tk_client;
28343 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
28344 __be32 *base, *hold;
28348 *p++ = htonl(RPC_AUTH_UNIX);
28350 @@ -153,9 +158,12 @@ unx_marshal(struct rpc_task *task, __be3
28351 * Copy the UTS nodename captured when the client was created.
28353 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
28354 + tag = task->tk_client->cl_tag;
28356 - *p++ = htonl((u32) cred->uc_uid);
28357 - *p++ = htonl((u32) cred->uc_gid);
28358 + *p++ = htonl((u32) TAGINO_UID(tag,
28359 + cred->uc_uid, cred->uc_tag));
28360 + *p++ = htonl((u32) TAGINO_GID(tag,
28361 + cred->uc_gid, cred->uc_tag));
28363 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
28364 *p++ = htonl((u32) cred->uc_gids[i]);
28365 diff -NurpP --minimal linux-2.6.35/net/sunrpc/clnt.c linux-2.6.35-vs2.3.0.36.31/net/sunrpc/clnt.c
28366 --- linux-2.6.35/net/sunrpc/clnt.c 2010-08-02 16:53:02.000000000 +0200
28367 +++ linux-2.6.35-vs2.3.0.36.31/net/sunrpc/clnt.c 2010-08-02 17:05:06.000000000 +0200
28369 #include <linux/utsname.h>
28370 #include <linux/workqueue.h>
28371 #include <linux/in6.h>
28372 +#include <linux/vs_cvirt.h>
28374 #include <linux/sunrpc/clnt.h>
28375 #include <linux/sunrpc/rpc_pipe_fs.h>
28376 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
28377 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
28378 clnt->cl_chatty = 1;
28380 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
28381 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
28382 + clnt->cl_tag = 1; */
28385 EXPORT_SYMBOL_GPL(rpc_create);
28386 diff -NurpP --minimal linux-2.6.35/net/unix/af_unix.c linux-2.6.35-vs2.3.0.36.31/net/unix/af_unix.c
28387 --- linux-2.6.35/net/unix/af_unix.c 2010-08-02 16:53:02.000000000 +0200
28388 +++ linux-2.6.35-vs2.3.0.36.31/net/unix/af_unix.c 2010-08-02 17:05:06.000000000 +0200
28389 @@ -114,6 +114,8 @@
28390 #include <linux/mount.h>
28391 #include <net/checksum.h>
28392 #include <linux/security.h>
28393 +#include <linux/vs_context.h>
28394 +#include <linux/vs_limit.h>
28396 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
28397 static DEFINE_SPINLOCK(unix_table_lock);
28398 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
28399 if (!net_eq(sock_net(s), net))
28402 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28404 if (u->addr->len == len &&
28405 !memcmp(u->addr->name, sunname, len))
28407 @@ -2114,6 +2118,8 @@ static struct sock *unix_seq_idx(struct
28408 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
28409 if (sock_net(s) != seq_file_net(seq))
28411 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28416 @@ -2138,7 +2144,8 @@ static void *unix_seq_next(struct seq_fi
28417 sk = first_unix_socket(&iter->i);
28419 sk = next_unix_socket(&iter->i, sk);
28420 - while (sk && (sock_net(sk) != seq_file_net(seq)))
28421 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
28422 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
28423 sk = next_unix_socket(&iter->i, sk);
28426 diff -NurpP --minimal linux-2.6.35/net/x25/af_x25.c linux-2.6.35-vs2.3.0.36.31/net/x25/af_x25.c
28427 --- linux-2.6.35/net/x25/af_x25.c 2010-08-02 16:53:02.000000000 +0200
28428 +++ linux-2.6.35-vs2.3.0.36.31/net/x25/af_x25.c 2010-08-02 17:05:06.000000000 +0200
28429 @@ -568,7 +568,10 @@ static int x25_create(struct net *net, s
28433 - sock_init_data(sock, sk);
28434 + sk->sk_socket = sock;
28435 + sk->sk_type = sock->type;
28436 + sk->sk_sleep = &sock->wait;
28439 x25_init_timers(sk);
28441 diff -NurpP --minimal linux-2.6.35/scripts/checksyscalls.sh linux-2.6.35-vs2.3.0.36.31/scripts/checksyscalls.sh
28442 --- linux-2.6.35/scripts/checksyscalls.sh 2009-09-10 15:26:31.000000000 +0200
28443 +++ linux-2.6.35-vs2.3.0.36.31/scripts/checksyscalls.sh 2010-08-02 17:05:06.000000000 +0200
28444 @@ -194,7 +194,6 @@ cat << EOF
28445 #define __IGNORE_afs_syscall
28446 #define __IGNORE_getpmsg
28447 #define __IGNORE_putpmsg
28448 -#define __IGNORE_vserver
28452 diff -NurpP --minimal linux-2.6.35/security/commoncap.c linux-2.6.35-vs2.3.0.36.31/security/commoncap.c
28453 --- linux-2.6.35/security/commoncap.c 2010-08-02 16:53:03.000000000 +0200
28454 +++ linux-2.6.35-vs2.3.0.36.31/security/commoncap.c 2010-08-02 17:05:06.000000000 +0200
28456 #include <linux/prctl.h>
28457 #include <linux/securebits.h>
28458 #include <linux/syslog.h>
28459 +#include <linux/vs_context.h>
28462 * If a non-root user executes a setuid-root binary in
28463 @@ -53,7 +54,7 @@ static void warn_setuid_and_fcaps_mixed(
28465 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
28467 - NETLINK_CB(skb).eff_cap = current_cap();
28468 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
28472 @@ -63,6 +64,7 @@ int cap_netlink_recv(struct sk_buff *skb
28477 EXPORT_SYMBOL(cap_netlink_recv);
28480 @@ -83,7 +85,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
28481 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
28484 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
28485 + struct vx_info *vxi = tsk->vx_info;
28488 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
28489 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
28490 + cap_raised(tsk->cap_effective, cap),
28491 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
28494 + /* special case SETUP */
28495 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
28496 + /* FIXME: maybe use cred instead? */
28497 + cap_raised(tsk->cred->cap_effective, cap))
28500 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
28504 @@ -571,7 +588,7 @@ int cap_inode_setxattr(struct dentry *de
28506 if (!strncmp(name, XATTR_SECURITY_PREFIX,
28507 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28508 - !capable(CAP_SYS_ADMIN))
28509 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28513 @@ -597,7 +614,7 @@ int cap_inode_removexattr(struct dentry
28515 if (!strncmp(name, XATTR_SECURITY_PREFIX,
28516 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28517 - !capable(CAP_SYS_ADMIN))
28518 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28522 @@ -899,7 +916,8 @@ int cap_syslog(int type, bool from_file)
28523 if (type != SYSLOG_ACTION_OPEN && from_file)
28525 if ((type != SYSLOG_ACTION_READ_ALL &&
28526 - type != SYSLOG_ACTION_SIZE_BUFFER) && !capable(CAP_SYS_ADMIN))
28527 + type != SYSLOG_ACTION_SIZE_BUFFER) &&
28528 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
28532 @@ -951,3 +969,4 @@ int cap_file_mmap(struct file *file, uns
28537 diff -NurpP --minimal linux-2.6.35/security/selinux/av_permissions.h linux-2.6.35-vs2.3.0.36.31/security/selinux/av_permissions.h
28538 --- linux-2.6.35/security/selinux/av_permissions.h 1970-01-01 01:00:00.000000000 +0100
28539 +++ linux-2.6.35-vs2.3.0.36.31/security/selinux/av_permissions.h 2010-08-02 17:05:06.000000000 +0200
28541 +/* This file is automatically generated. Do not edit. */
28542 +#ifndef _SELINUX_AV_PERMISSIONS_H_
28543 +#define _SELINUX_AV_PERMISSIONS_H_
28545 +#define SECURITY__COMPUTE_AV 0x00000001UL
28546 +#define SECURITY__COMPUTE_CREATE 0x00000002UL
28547 +#define SECURITY__COMPUTE_MEMBER 0x00000004UL
28548 +#define SECURITY__CHECK_CONTEXT 0x00000008UL
28549 +#define SECURITY__LOAD_POLICY 0x00000010UL
28550 +#define SECURITY__COMPUTE_RELABEL 0x00000020UL
28551 +#define SECURITY__COMPUTE_USER 0x00000040UL
28552 +#define SECURITY__SETENFORCE 0x00000080UL
28553 +#define SECURITY__SETBOOL 0x00000100UL
28554 +#define SECURITY__SETSECPARAM 0x00000200UL
28555 +#define SECURITY__SETCHECKREQPROT 0x00000400UL
28556 +#define PROCESS__FORK 0x00000001UL
28557 +#define PROCESS__TRANSITION 0x00000002UL
28558 +#define PROCESS__SIGCHLD 0x00000004UL
28559 +#define PROCESS__SIGKILL 0x00000008UL
28560 +#define PROCESS__SIGSTOP 0x00000010UL
28561 +#define PROCESS__SIGNULL 0x00000020UL
28562 +#define PROCESS__SIGNAL 0x00000040UL
28563 +#define PROCESS__PTRACE 0x00000080UL
28564 +#define PROCESS__GETSCHED 0x00000100UL
28565 +#define PROCESS__SETSCHED 0x00000200UL
28566 +#define PROCESS__GETSESSION 0x00000400UL
28567 +#define PROCESS__GETPGID 0x00000800UL
28568 +#define PROCESS__SETPGID 0x00001000UL
28569 +#define PROCESS__GETCAP 0x00002000UL
28570 +#define PROCESS__SETCAP 0x00004000UL
28571 +#define PROCESS__SHARE 0x00008000UL
28572 +#define PROCESS__GETATTR 0x00010000UL
28573 +#define PROCESS__SETEXEC 0x00020000UL
28574 +#define PROCESS__SETFSCREATE 0x00040000UL
28575 +#define PROCESS__NOATSECURE 0x00080000UL
28576 +#define PROCESS__SIGINH 0x00100000UL
28577 +#define PROCESS__SETRLIMIT 0x00200000UL
28578 +#define PROCESS__RLIMITINH 0x00400000UL
28579 +#define PROCESS__DYNTRANSITION 0x00800000UL
28580 +#define PROCESS__SETCURRENT 0x01000000UL
28581 +#define PROCESS__EXECMEM 0x02000000UL
28582 +#define PROCESS__EXECSTACK 0x04000000UL
28583 +#define PROCESS__EXECHEAP 0x08000000UL
28584 +#define PROCESS__SETKEYCREATE 0x10000000UL
28585 +#define PROCESS__SETSOCKCREATE 0x20000000UL
28586 +#define SYSTEM__IPC_INFO 0x00000001UL
28587 +#define SYSTEM__SYSLOG_READ 0x00000002UL
28588 +#define SYSTEM__SYSLOG_MOD 0x00000004UL
28589 +#define SYSTEM__SYSLOG_CONSOLE 0x00000008UL
28590 +#define SYSTEM__MODULE_REQUEST 0x00000010UL
28591 +#define CAPABILITY__CHOWN 0x00000001UL
28592 +#define CAPABILITY__DAC_OVERRIDE 0x00000002UL
28593 +#define CAPABILITY__DAC_READ_SEARCH 0x00000004UL
28594 +#define CAPABILITY__FOWNER 0x00000008UL
28595 +#define CAPABILITY__FSETID 0x00000010UL
28596 +#define CAPABILITY__KILL 0x00000020UL
28597 +#define CAPABILITY__SETGID 0x00000040UL
28598 +#define CAPABILITY__SETUID 0x00000080UL
28599 +#define CAPABILITY__SETPCAP 0x00000100UL
28600 +#define CAPABILITY__LINUX_IMMUTABLE 0x00000200UL
28601 +#define CAPABILITY__NET_BIND_SERVICE 0x00000400UL
28602 +#define CAPABILITY__NET_BROADCAST 0x00000800UL
28603 +#define CAPABILITY__NET_ADMIN 0x00001000UL
28604 +#define CAPABILITY__NET_RAW 0x00002000UL
28605 +#define CAPABILITY__IPC_LOCK 0x00004000UL
28606 +#define CAPABILITY__IPC_OWNER 0x00008000UL
28607 +#define CAPABILITY__SYS_MODULE 0x00010000UL
28608 +#define CAPABILITY__SYS_RAWIO 0x00020000UL
28609 +#define CAPABILITY__SYS_CHROOT 0x00040000UL
28610 +#define CAPABILITY__SYS_PTRACE 0x00080000UL
28611 +#define CAPABILITY__SYS_PACCT 0x00100000UL
28612 +#define CAPABILITY__SYS_ADMIN 0x00200000UL
28613 +#define CAPABILITY__SYS_BOOT 0x00400000UL
28614 +#define CAPABILITY__SYS_NICE 0x00800000UL
28615 +#define CAPABILITY__SYS_RESOURCE 0x01000000UL
28616 +#define CAPABILITY__SYS_TIME 0x02000000UL
28617 +#define CAPABILITY__SYS_TTY_CONFIG 0x04000000UL
28618 +#define CAPABILITY__MKNOD 0x08000000UL
28619 +#define CAPABILITY__LEASE 0x10000000UL
28620 +#define CAPABILITY__AUDIT_WRITE 0x20000000UL
28621 +#define CAPABILITY__AUDIT_CONTROL 0x40000000UL
28622 +#define CAPABILITY__SETFCAP 0x80000000UL
28623 +#define FILESYSTEM__MOUNT 0x00000001UL
28624 +#define FILESYSTEM__REMOUNT 0x00000002UL
28625 +#define FILESYSTEM__UNMOUNT 0x00000004UL
28626 +#define FILESYSTEM__GETATTR 0x00000008UL
28627 +#define FILESYSTEM__RELABELFROM 0x00000010UL
28628 +#define FILESYSTEM__RELABELTO 0x00000020UL
28629 +#define FILESYSTEM__TRANSITION 0x00000040UL
28630 +#define FILESYSTEM__ASSOCIATE 0x00000080UL
28631 +#define FILESYSTEM__QUOTAMOD 0x00000100UL
28632 +#define FILESYSTEM__QUOTAGET 0x00000200UL
28633 +#define FILE__IOCTL 0x00000001UL
28634 +#define FILE__READ 0x00000002UL
28635 +#define FILE__WRITE 0x00000004UL
28636 +#define FILE__CREATE 0x00000008UL
28637 +#define FILE__GETATTR 0x00000010UL
28638 +#define FILE__SETATTR 0x00000020UL
28639 +#define FILE__LOCK 0x00000040UL
28640 +#define FILE__RELABELFROM 0x00000080UL
28641 +#define FILE__RELABELTO 0x00000100UL
28642 +#define FILE__APPEND 0x00000200UL
28643 +#define FILE__UNLINK 0x00000400UL
28644 +#define FILE__LINK 0x00000800UL
28645 +#define FILE__RENAME 0x00001000UL
28646 +#define FILE__EXECUTE 0x00002000UL
28647 +#define FILE__SWAPON 0x00004000UL
28648 +#define FILE__QUOTAON 0x00008000UL
28649 +#define FILE__MOUNTON 0x00010000UL
28650 +#define FILE__EXECUTE_NO_TRANS 0x00020000UL
28651 +#define FILE__ENTRYPOINT 0x00040000UL
28652 +#define FILE__EXECMOD 0x00080000UL
28653 +#define FILE__OPEN 0x00100000UL
28654 +#define DIR__IOCTL 0x00000001UL
28655 +#define DIR__READ 0x00000002UL
28656 +#define DIR__WRITE 0x00000004UL
28657 +#define DIR__CREATE 0x00000008UL
28658 +#define DIR__GETATTR 0x00000010UL
28659 +#define DIR__SETATTR 0x00000020UL
28660 +#define DIR__LOCK 0x00000040UL
28661 +#define DIR__RELABELFROM 0x00000080UL
28662 +#define DIR__RELABELTO 0x00000100UL
28663 +#define DIR__APPEND 0x00000200UL
28664 +#define DIR__UNLINK 0x00000400UL
28665 +#define DIR__LINK 0x00000800UL
28666 +#define DIR__RENAME 0x00001000UL
28667 +#define DIR__EXECUTE 0x00002000UL
28668 +#define DIR__SWAPON 0x00004000UL
28669 +#define DIR__QUOTAON 0x00008000UL
28670 +#define DIR__MOUNTON 0x00010000UL
28671 +#define DIR__ADD_NAME 0x00020000UL
28672 +#define DIR__REMOVE_NAME 0x00040000UL
28673 +#define DIR__REPARENT 0x00080000UL
28674 +#define DIR__SEARCH 0x00100000UL
28675 +#define DIR__RMDIR 0x00200000UL
28676 +#define DIR__OPEN 0x00400000UL
28677 +#define FD__USE 0x00000001UL
28678 +#define LNK_FILE__IOCTL 0x00000001UL
28679 +#define LNK_FILE__READ 0x00000002UL
28680 +#define LNK_FILE__WRITE 0x00000004UL
28681 +#define LNK_FILE__CREATE 0x00000008UL
28682 +#define LNK_FILE__GETATTR 0x00000010UL
28683 +#define LNK_FILE__SETATTR 0x00000020UL
28684 +#define LNK_FILE__LOCK 0x00000040UL
28685 +#define LNK_FILE__RELABELFROM 0x00000080UL
28686 +#define LNK_FILE__RELABELTO 0x00000100UL
28687 +#define LNK_FILE__APPEND 0x00000200UL
28688 +#define LNK_FILE__UNLINK 0x00000400UL
28689 +#define LNK_FILE__LINK 0x00000800UL
28690 +#define LNK_FILE__RENAME 0x00001000UL
28691 +#define LNK_FILE__EXECUTE 0x00002000UL
28692 +#define LNK_FILE__SWAPON 0x00004000UL
28693 +#define LNK_FILE__QUOTAON 0x00008000UL
28694 +#define LNK_FILE__MOUNTON 0x00010000UL
28695 +#define CHR_FILE__IOCTL 0x00000001UL
28696 +#define CHR_FILE__READ 0x00000002UL
28697 +#define CHR_FILE__WRITE 0x00000004UL
28698 +#define CHR_FILE__CREATE 0x00000008UL
28699 +#define CHR_FILE__GETATTR 0x00000010UL
28700 +#define CHR_FILE__SETATTR 0x00000020UL
28701 +#define CHR_FILE__LOCK 0x00000040UL
28702 +#define CHR_FILE__RELABELFROM 0x00000080UL
28703 +#define CHR_FILE__RELABELTO 0x00000100UL
28704 +#define CHR_FILE__APPEND 0x00000200UL
28705 +#define CHR_FILE__UNLINK 0x00000400UL
28706 +#define CHR_FILE__LINK 0x00000800UL
28707 +#define CHR_FILE__RENAME 0x00001000UL
28708 +#define CHR_FILE__EXECUTE 0x00002000UL
28709 +#define CHR_FILE__SWAPON 0x00004000UL
28710 +#define CHR_FILE__QUOTAON 0x00008000UL
28711 +#define CHR_FILE__MOUNTON 0x00010000UL
28712 +#define CHR_FILE__EXECUTE_NO_TRANS 0x00020000UL
28713 +#define CHR_FILE__ENTRYPOINT 0x00040000UL
28714 +#define CHR_FILE__EXECMOD 0x00080000UL
28715 +#define CHR_FILE__OPEN 0x00100000UL
28716 +#define BLK_FILE__IOCTL 0x00000001UL
28717 +#define BLK_FILE__READ 0x00000002UL
28718 +#define BLK_FILE__WRITE 0x00000004UL
28719 +#define BLK_FILE__CREATE 0x00000008UL
28720 +#define BLK_FILE__GETATTR 0x00000010UL
28721 +#define BLK_FILE__SETATTR 0x00000020UL
28722 +#define BLK_FILE__LOCK 0x00000040UL
28723 +#define BLK_FILE__RELABELFROM 0x00000080UL
28724 +#define BLK_FILE__RELABELTO 0x00000100UL
28725 +#define BLK_FILE__APPEND 0x00000200UL
28726 +#define BLK_FILE__UNLINK 0x00000400UL
28727 +#define BLK_FILE__LINK 0x00000800UL
28728 +#define BLK_FILE__RENAME 0x00001000UL
28729 +#define BLK_FILE__EXECUTE 0x00002000UL
28730 +#define BLK_FILE__SWAPON 0x00004000UL
28731 +#define BLK_FILE__QUOTAON 0x00008000UL
28732 +#define BLK_FILE__MOUNTON 0x00010000UL
28733 +#define BLK_FILE__OPEN 0x00020000UL
28734 +#define SOCK_FILE__IOCTL 0x00000001UL
28735 +#define SOCK_FILE__READ 0x00000002UL
28736 +#define SOCK_FILE__WRITE 0x00000004UL
28737 +#define SOCK_FILE__CREATE 0x00000008UL
28738 +#define SOCK_FILE__GETATTR 0x00000010UL
28739 +#define SOCK_FILE__SETATTR 0x00000020UL
28740 +#define SOCK_FILE__LOCK 0x00000040UL
28741 +#define SOCK_FILE__RELABELFROM 0x00000080UL
28742 +#define SOCK_FILE__RELABELTO 0x00000100UL
28743 +#define SOCK_FILE__APPEND 0x00000200UL
28744 +#define SOCK_FILE__UNLINK 0x00000400UL
28745 +#define SOCK_FILE__LINK 0x00000800UL
28746 +#define SOCK_FILE__RENAME 0x00001000UL
28747 +#define SOCK_FILE__EXECUTE 0x00002000UL
28748 +#define SOCK_FILE__SWAPON 0x00004000UL
28749 +#define SOCK_FILE__QUOTAON 0x00008000UL
28750 +#define SOCK_FILE__MOUNTON 0x00010000UL
28751 +#define SOCK_FILE__OPEN 0x00020000UL
28752 +#define FIFO_FILE__IOCTL 0x00000001UL
28753 +#define FIFO_FILE__READ 0x00000002UL
28754 +#define FIFO_FILE__WRITE 0x00000004UL
28755 +#define FIFO_FILE__CREATE 0x00000008UL
28756 +#define FIFO_FILE__GETATTR 0x00000010UL
28757 +#define FIFO_FILE__SETATTR 0x00000020UL
28758 +#define FIFO_FILE__LOCK 0x00000040UL
28759 +#define FIFO_FILE__RELABELFROM 0x00000080UL
28760 +#define FIFO_FILE__RELABELTO 0x00000100UL
28761 +#define FIFO_FILE__APPEND 0x00000200UL
28762 +#define FIFO_FILE__UNLINK 0x00000400UL
28763 +#define FIFO_FILE__LINK 0x00000800UL
28764 +#define FIFO_FILE__RENAME 0x00001000UL
28765 +#define FIFO_FILE__EXECUTE 0x00002000UL
28766 +#define FIFO_FILE__SWAPON 0x00004000UL
28767 +#define FIFO_FILE__QUOTAON 0x00008000UL
28768 +#define FIFO_FILE__MOUNTON 0x00010000UL
28769 +#define FIFO_FILE__OPEN 0x00020000UL
28770 +#define SOCKET__IOCTL 0x00000001UL
28771 +#define SOCKET__READ 0x00000002UL
28772 +#define SOCKET__WRITE 0x00000004UL
28773 +#define SOCKET__CREATE 0x00000008UL
28774 +#define SOCKET__GETATTR 0x00000010UL
28775 +#define SOCKET__SETATTR 0x00000020UL
28776 +#define SOCKET__LOCK 0x00000040UL
28777 +#define SOCKET__RELABELFROM 0x00000080UL
28778 +#define SOCKET__RELABELTO 0x00000100UL
28779 +#define SOCKET__APPEND 0x00000200UL
28780 +#define SOCKET__BIND 0x00000400UL
28781 +#define SOCKET__CONNECT 0x00000800UL
28782 +#define SOCKET__LISTEN 0x00001000UL
28783 +#define SOCKET__ACCEPT 0x00002000UL
28784 +#define SOCKET__GETOPT 0x00004000UL
28785 +#define SOCKET__SETOPT 0x00008000UL
28786 +#define SOCKET__SHUTDOWN 0x00010000UL
28787 +#define SOCKET__RECVFROM 0x00020000UL
28788 +#define SOCKET__SENDTO 0x00040000UL
28789 +#define SOCKET__RECV_MSG 0x00080000UL
28790 +#define SOCKET__SEND_MSG 0x00100000UL
28791 +#define SOCKET__NAME_BIND 0x00200000UL
28792 +#define TCP_SOCKET__IOCTL 0x00000001UL
28793 +#define TCP_SOCKET__READ 0x00000002UL
28794 +#define TCP_SOCKET__WRITE 0x00000004UL
28795 +#define TCP_SOCKET__CREATE 0x00000008UL
28796 +#define TCP_SOCKET__GETATTR 0x00000010UL
28797 +#define TCP_SOCKET__SETATTR 0x00000020UL
28798 +#define TCP_SOCKET__LOCK 0x00000040UL
28799 +#define TCP_SOCKET__RELABELFROM 0x00000080UL
28800 +#define TCP_SOCKET__RELABELTO 0x00000100UL
28801 +#define TCP_SOCKET__APPEND 0x00000200UL
28802 +#define TCP_SOCKET__BIND 0x00000400UL
28803 +#define TCP_SOCKET__CONNECT 0x00000800UL
28804 +#define TCP_SOCKET__LISTEN 0x00001000UL
28805 +#define TCP_SOCKET__ACCEPT 0x00002000UL
28806 +#define TCP_SOCKET__GETOPT 0x00004000UL
28807 +#define TCP_SOCKET__SETOPT 0x00008000UL
28808 +#define TCP_SOCKET__SHUTDOWN 0x00010000UL
28809 +#define TCP_SOCKET__RECVFROM 0x00020000UL
28810 +#define TCP_SOCKET__SENDTO 0x00040000UL
28811 +#define TCP_SOCKET__RECV_MSG 0x00080000UL
28812 +#define TCP_SOCKET__SEND_MSG 0x00100000UL
28813 +#define TCP_SOCKET__NAME_BIND 0x00200000UL
28814 +#define TCP_SOCKET__CONNECTTO 0x00400000UL
28815 +#define TCP_SOCKET__NEWCONN 0x00800000UL
28816 +#define TCP_SOCKET__ACCEPTFROM 0x01000000UL
28817 +#define TCP_SOCKET__NODE_BIND 0x02000000UL
28818 +#define TCP_SOCKET__NAME_CONNECT 0x04000000UL
28819 +#define UDP_SOCKET__IOCTL 0x00000001UL
28820 +#define UDP_SOCKET__READ 0x00000002UL
28821 +#define UDP_SOCKET__WRITE 0x00000004UL
28822 +#define UDP_SOCKET__CREATE 0x00000008UL
28823 +#define UDP_SOCKET__GETATTR 0x00000010UL
28824 +#define UDP_SOCKET__SETATTR 0x00000020UL
28825 +#define UDP_SOCKET__LOCK 0x00000040UL
28826 +#define UDP_SOCKET__RELABELFROM 0x00000080UL
28827 +#define UDP_SOCKET__RELABELTO 0x00000100UL
28828 +#define UDP_SOCKET__APPEND 0x00000200UL
28829 +#define UDP_SOCKET__BIND 0x00000400UL
28830 +#define UDP_SOCKET__CONNECT 0x00000800UL
28831 +#define UDP_SOCKET__LISTEN 0x00001000UL
28832 +#define UDP_SOCKET__ACCEPT 0x00002000UL
28833 +#define UDP_SOCKET__GETOPT 0x00004000UL
28834 +#define UDP_SOCKET__SETOPT 0x00008000UL
28835 +#define UDP_SOCKET__SHUTDOWN 0x00010000UL
28836 +#define UDP_SOCKET__RECVFROM 0x00020000UL
28837 +#define UDP_SOCKET__SENDTO 0x00040000UL
28838 +#define UDP_SOCKET__RECV_MSG 0x00080000UL
28839 +#define UDP_SOCKET__SEND_MSG 0x00100000UL
28840 +#define UDP_SOCKET__NAME_BIND 0x00200000UL
28841 +#define UDP_SOCKET__NODE_BIND 0x00400000UL
28842 +#define RAWIP_SOCKET__IOCTL 0x00000001UL
28843 +#define RAWIP_SOCKET__READ 0x00000002UL
28844 +#define RAWIP_SOCKET__WRITE 0x00000004UL
28845 +#define RAWIP_SOCKET__CREATE 0x00000008UL
28846 +#define RAWIP_SOCKET__GETATTR 0x00000010UL
28847 +#define RAWIP_SOCKET__SETATTR 0x00000020UL
28848 +#define RAWIP_SOCKET__LOCK 0x00000040UL
28849 +#define RAWIP_SOCKET__RELABELFROM 0x00000080UL
28850 +#define RAWIP_SOCKET__RELABELTO 0x00000100UL
28851 +#define RAWIP_SOCKET__APPEND 0x00000200UL
28852 +#define RAWIP_SOCKET__BIND 0x00000400UL
28853 +#define RAWIP_SOCKET__CONNECT 0x00000800UL
28854 +#define RAWIP_SOCKET__LISTEN 0x00001000UL
28855 +#define RAWIP_SOCKET__ACCEPT 0x00002000UL
28856 +#define RAWIP_SOCKET__GETOPT 0x00004000UL
28857 +#define RAWIP_SOCKET__SETOPT 0x00008000UL
28858 +#define RAWIP_SOCKET__SHUTDOWN 0x00010000UL
28859 +#define RAWIP_SOCKET__RECVFROM 0x00020000UL
28860 +#define RAWIP_SOCKET__SENDTO 0x00040000UL
28861 +#define RAWIP_SOCKET__RECV_MSG 0x00080000UL
28862 +#define RAWIP_SOCKET__SEND_MSG 0x00100000UL
28863 +#define RAWIP_SOCKET__NAME_BIND 0x00200000UL
28864 +#define RAWIP_SOCKET__NODE_BIND 0x00400000UL
28865 +#define NODE__TCP_RECV 0x00000001UL
28866 +#define NODE__TCP_SEND 0x00000002UL
28867 +#define NODE__UDP_RECV 0x00000004UL
28868 +#define NODE__UDP_SEND 0x00000008UL
28869 +#define NODE__RAWIP_RECV 0x00000010UL
28870 +#define NODE__RAWIP_SEND 0x00000020UL
28871 +#define NODE__ENFORCE_DEST 0x00000040UL
28872 +#define NODE__DCCP_RECV 0x00000080UL
28873 +#define NODE__DCCP_SEND 0x00000100UL
28874 +#define NODE__RECVFROM 0x00000200UL
28875 +#define NODE__SENDTO 0x00000400UL
28876 +#define NETIF__TCP_RECV 0x00000001UL
28877 +#define NETIF__TCP_SEND 0x00000002UL
28878 +#define NETIF__UDP_RECV 0x00000004UL
28879 +#define NETIF__UDP_SEND 0x00000008UL
28880 +#define NETIF__RAWIP_RECV 0x00000010UL
28881 +#define NETIF__RAWIP_SEND 0x00000020UL
28882 +#define NETIF__DCCP_RECV 0x00000040UL
28883 +#define NETIF__DCCP_SEND 0x00000080UL
28884 +#define NETIF__INGRESS 0x00000100UL
28885 +#define NETIF__EGRESS 0x00000200UL
28886 +#define NETLINK_SOCKET__IOCTL 0x00000001UL
28887 +#define NETLINK_SOCKET__READ 0x00000002UL
28888 +#define NETLINK_SOCKET__WRITE 0x00000004UL
28889 +#define NETLINK_SOCKET__CREATE 0x00000008UL
28890 +#define NETLINK_SOCKET__GETATTR 0x00000010UL
28891 +#define NETLINK_SOCKET__SETATTR 0x00000020UL
28892 +#define NETLINK_SOCKET__LOCK 0x00000040UL
28893 +#define NETLINK_SOCKET__RELABELFROM 0x00000080UL
28894 +#define NETLINK_SOCKET__RELABELTO 0x00000100UL
28895 +#define NETLINK_SOCKET__APPEND 0x00000200UL
28896 +#define NETLINK_SOCKET__BIND 0x00000400UL
28897 +#define NETLINK_SOCKET__CONNECT 0x00000800UL
28898 +#define NETLINK_SOCKET__LISTEN 0x00001000UL
28899 +#define NETLINK_SOCKET__ACCEPT 0x00002000UL
28900 +#define NETLINK_SOCKET__GETOPT 0x00004000UL
28901 +#define NETLINK_SOCKET__SETOPT 0x00008000UL
28902 +#define NETLINK_SOCKET__SHUTDOWN 0x00010000UL
28903 +#define NETLINK_SOCKET__RECVFROM 0x00020000UL
28904 +#define NETLINK_SOCKET__SENDTO 0x00040000UL
28905 +#define NETLINK_SOCKET__RECV_MSG 0x00080000UL
28906 +#define NETLINK_SOCKET__SEND_MSG 0x00100000UL
28907 +#define NETLINK_SOCKET__NAME_BIND 0x00200000UL
28908 +#define PACKET_SOCKET__IOCTL 0x00000001UL
28909 +#define PACKET_SOCKET__READ 0x00000002UL
28910 +#define PACKET_SOCKET__WRITE 0x00000004UL
28911 +#define PACKET_SOCKET__CREATE 0x00000008UL
28912 +#define PACKET_SOCKET__GETATTR 0x00000010UL
28913 +#define PACKET_SOCKET__SETATTR 0x00000020UL
28914 +#define PACKET_SOCKET__LOCK 0x00000040UL
28915 +#define PACKET_SOCKET__RELABELFROM 0x00000080UL
28916 +#define PACKET_SOCKET__RELABELTO 0x00000100UL
28917 +#define PACKET_SOCKET__APPEND 0x00000200UL
28918 +#define PACKET_SOCKET__BIND 0x00000400UL
28919 +#define PACKET_SOCKET__CONNECT 0x00000800UL
28920 +#define PACKET_SOCKET__LISTEN 0x00001000UL
28921 +#define PACKET_SOCKET__ACCEPT 0x00002000UL
28922 +#define PACKET_SOCKET__GETOPT 0x00004000UL
28923 +#define PACKET_SOCKET__SETOPT 0x00008000UL
28924 +#define PACKET_SOCKET__SHUTDOWN 0x00010000UL
28925 +#define PACKET_SOCKET__RECVFROM 0x00020000UL
28926 +#define PACKET_SOCKET__SENDTO 0x00040000UL
28927 +#define PACKET_SOCKET__RECV_MSG 0x00080000UL
28928 +#define PACKET_SOCKET__SEND_MSG 0x00100000UL
28929 +#define PACKET_SOCKET__NAME_BIND 0x00200000UL
28930 +#define KEY_SOCKET__IOCTL 0x00000001UL
28931 +#define KEY_SOCKET__READ 0x00000002UL
28932 +#define KEY_SOCKET__WRITE 0x00000004UL
28933 +#define KEY_SOCKET__CREATE 0x00000008UL
28934 +#define KEY_SOCKET__GETATTR 0x00000010UL
28935 +#define KEY_SOCKET__SETATTR 0x00000020UL
28936 +#define KEY_SOCKET__LOCK 0x00000040UL
28937 +#define KEY_SOCKET__RELABELFROM 0x00000080UL
28938 +#define KEY_SOCKET__RELABELTO 0x00000100UL
28939 +#define KEY_SOCKET__APPEND 0x00000200UL
28940 +#define KEY_SOCKET__BIND 0x00000400UL
28941 +#define KEY_SOCKET__CONNECT 0x00000800UL
28942 +#define KEY_SOCKET__LISTEN 0x00001000UL
28943 +#define KEY_SOCKET__ACCEPT 0x00002000UL
28944 +#define KEY_SOCKET__GETOPT 0x00004000UL
28945 +#define KEY_SOCKET__SETOPT 0x00008000UL
28946 +#define KEY_SOCKET__SHUTDOWN 0x00010000UL
28947 +#define KEY_SOCKET__RECVFROM 0x00020000UL
28948 +#define KEY_SOCKET__SENDTO 0x00040000UL
28949 +#define KEY_SOCKET__RECV_MSG 0x00080000UL
28950 +#define KEY_SOCKET__SEND_MSG 0x00100000UL
28951 +#define KEY_SOCKET__NAME_BIND 0x00200000UL
28952 +#define UNIX_STREAM_SOCKET__IOCTL 0x00000001UL
28953 +#define UNIX_STREAM_SOCKET__READ 0x00000002UL
28954 +#define UNIX_STREAM_SOCKET__WRITE 0x00000004UL
28955 +#define UNIX_STREAM_SOCKET__CREATE 0x00000008UL
28956 +#define UNIX_STREAM_SOCKET__GETATTR 0x00000010UL
28957 +#define UNIX_STREAM_SOCKET__SETATTR 0x00000020UL
28958 +#define UNIX_STREAM_SOCKET__LOCK 0x00000040UL
28959 +#define UNIX_STREAM_SOCKET__RELABELFROM 0x00000080UL
28960 +#define UNIX_STREAM_SOCKET__RELABELTO 0x00000100UL
28961 +#define UNIX_STREAM_SOCKET__APPEND 0x00000200UL
28962 +#define UNIX_STREAM_SOCKET__BIND 0x00000400UL
28963 +#define UNIX_STREAM_SOCKET__CONNECT 0x00000800UL
28964 +#define UNIX_STREAM_SOCKET__LISTEN 0x00001000UL
28965 +#define UNIX_STREAM_SOCKET__ACCEPT 0x00002000UL
28966 +#define UNIX_STREAM_SOCKET__GETOPT 0x00004000UL
28967 +#define UNIX_STREAM_SOCKET__SETOPT 0x00008000UL
28968 +#define UNIX_STREAM_SOCKET__SHUTDOWN 0x00010000UL
28969 +#define UNIX_STREAM_SOCKET__RECVFROM 0x00020000UL
28970 +#define UNIX_STREAM_SOCKET__SENDTO 0x00040000UL
28971 +#define UNIX_STREAM_SOCKET__RECV_MSG 0x00080000UL
28972 +#define UNIX_STREAM_SOCKET__SEND_MSG 0x00100000UL
28973 +#define UNIX_STREAM_SOCKET__NAME_BIND 0x00200000UL
28974 +#define UNIX_STREAM_SOCKET__CONNECTTO 0x00400000UL
28975 +#define UNIX_STREAM_SOCKET__NEWCONN 0x00800000UL
28976 +#define UNIX_STREAM_SOCKET__ACCEPTFROM 0x01000000UL
28977 +#define UNIX_DGRAM_SOCKET__IOCTL 0x00000001UL
28978 +#define UNIX_DGRAM_SOCKET__READ 0x00000002UL
28979 +#define UNIX_DGRAM_SOCKET__WRITE 0x00000004UL
28980 +#define UNIX_DGRAM_SOCKET__CREATE 0x00000008UL
28981 +#define UNIX_DGRAM_SOCKET__GETATTR 0x00000010UL
28982 +#define UNIX_DGRAM_SOCKET__SETATTR 0x00000020UL
28983 +#define UNIX_DGRAM_SOCKET__LOCK 0x00000040UL
28984 +#define UNIX_DGRAM_SOCKET__RELABELFROM 0x00000080UL
28985 +#define UNIX_DGRAM_SOCKET__RELABELTO 0x00000100UL
28986 +#define UNIX_DGRAM_SOCKET__APPEND 0x00000200UL
28987 +#define UNIX_DGRAM_SOCKET__BIND 0x00000400UL
28988 +#define UNIX_DGRAM_SOCKET__CONNECT 0x00000800UL
28989 +#define UNIX_DGRAM_SOCKET__LISTEN 0x00001000UL
28990 +#define UNIX_DGRAM_SOCKET__ACCEPT 0x00002000UL
28991 +#define UNIX_DGRAM_SOCKET__GETOPT 0x00004000UL
28992 +#define UNIX_DGRAM_SOCKET__SETOPT 0x00008000UL
28993 +#define UNIX_DGRAM_SOCKET__SHUTDOWN 0x00010000UL
28994 +#define UNIX_DGRAM_SOCKET__RECVFROM 0x00020000UL
28995 +#define UNIX_DGRAM_SOCKET__SENDTO 0x00040000UL
28996 +#define UNIX_DGRAM_SOCKET__RECV_MSG 0x00080000UL
28997 +#define UNIX_DGRAM_SOCKET__SEND_MSG 0x00100000UL
28998 +#define UNIX_DGRAM_SOCKET__NAME_BIND 0x00200000UL
28999 +#define SEM__CREATE 0x00000001UL
29000 +#define SEM__DESTROY 0x00000002UL
29001 +#define SEM__GETATTR 0x00000004UL
29002 +#define SEM__SETATTR 0x00000008UL
29003 +#define SEM__READ 0x00000010UL
29004 +#define SEM__WRITE 0x00000020UL
29005 +#define SEM__ASSOCIATE 0x00000040UL
29006 +#define SEM__UNIX_READ 0x00000080UL
29007 +#define SEM__UNIX_WRITE 0x00000100UL
29008 +#define MSG__SEND 0x00000001UL
29009 +#define MSG__RECEIVE 0x00000002UL
29010 +#define MSGQ__CREATE 0x00000001UL
29011 +#define MSGQ__DESTROY 0x00000002UL
29012 +#define MSGQ__GETATTR 0x00000004UL
29013 +#define MSGQ__SETATTR 0x00000008UL
29014 +#define MSGQ__READ 0x00000010UL
29015 +#define MSGQ__WRITE 0x00000020UL
29016 +#define MSGQ__ASSOCIATE 0x00000040UL
29017 +#define MSGQ__UNIX_READ 0x00000080UL
29018 +#define MSGQ__UNIX_WRITE 0x00000100UL
29019 +#define MSGQ__ENQUEUE 0x00000200UL
29020 +#define SHM__CREATE 0x00000001UL
29021 +#define SHM__DESTROY 0x00000002UL
29022 +#define SHM__GETATTR 0x00000004UL
29023 +#define SHM__SETATTR 0x00000008UL
29024 +#define SHM__READ 0x00000010UL
29025 +#define SHM__WRITE 0x00000020UL
29026 +#define SHM__ASSOCIATE 0x00000040UL
29027 +#define SHM__UNIX_READ 0x00000080UL
29028 +#define SHM__UNIX_WRITE 0x00000100UL
29029 +#define SHM__LOCK 0x00000200UL
29030 +#define IPC__CREATE 0x00000001UL
29031 +#define IPC__DESTROY 0x00000002UL
29032 +#define IPC__GETATTR 0x00000004UL
29033 +#define IPC__SETATTR 0x00000008UL
29034 +#define IPC__READ 0x00000010UL
29035 +#define IPC__WRITE 0x00000020UL
29036 +#define IPC__ASSOCIATE 0x00000040UL
29037 +#define IPC__UNIX_READ 0x00000080UL
29038 +#define IPC__UNIX_WRITE 0x00000100UL
29039 +#define NETLINK_ROUTE_SOCKET__IOCTL 0x00000001UL
29040 +#define NETLINK_ROUTE_SOCKET__READ 0x00000002UL
29041 +#define NETLINK_ROUTE_SOCKET__WRITE 0x00000004UL
29042 +#define NETLINK_ROUTE_SOCKET__CREATE 0x00000008UL
29043 +#define NETLINK_ROUTE_SOCKET__GETATTR 0x00000010UL
29044 +#define NETLINK_ROUTE_SOCKET__SETATTR 0x00000020UL
29045 +#define NETLINK_ROUTE_SOCKET__LOCK 0x00000040UL
29046 +#define NETLINK_ROUTE_SOCKET__RELABELFROM 0x00000080UL
29047 +#define NETLINK_ROUTE_SOCKET__RELABELTO 0x00000100UL
29048 +#define NETLINK_ROUTE_SOCKET__APPEND 0x00000200UL
29049 +#define NETLINK_ROUTE_SOCKET__BIND 0x00000400UL
29050 +#define NETLINK_ROUTE_SOCKET__CONNECT 0x00000800UL
29051 +#define NETLINK_ROUTE_SOCKET__LISTEN 0x00001000UL
29052 +#define NETLINK_ROUTE_SOCKET__ACCEPT 0x00002000UL
29053 +#define NETLINK_ROUTE_SOCKET__GETOPT 0x00004000UL
29054 +#define NETLINK_ROUTE_SOCKET__SETOPT 0x00008000UL
29055 +#define NETLINK_ROUTE_SOCKET__SHUTDOWN 0x00010000UL
29056 +#define NETLINK_ROUTE_SOCKET__RECVFROM 0x00020000UL
29057 +#define NETLINK_ROUTE_SOCKET__SENDTO 0x00040000UL
29058 +#define NETLINK_ROUTE_SOCKET__RECV_MSG 0x00080000UL
29059 +#define NETLINK_ROUTE_SOCKET__SEND_MSG 0x00100000UL
29060 +#define NETLINK_ROUTE_SOCKET__NAME_BIND 0x00200000UL
29061 +#define NETLINK_ROUTE_SOCKET__NLMSG_READ 0x00400000UL
29062 +#define NETLINK_ROUTE_SOCKET__NLMSG_WRITE 0x00800000UL
29063 +#define NETLINK_FIREWALL_SOCKET__IOCTL 0x00000001UL
29064 +#define NETLINK_FIREWALL_SOCKET__READ 0x00000002UL
29065 +#define NETLINK_FIREWALL_SOCKET__WRITE 0x00000004UL
29066 +#define NETLINK_FIREWALL_SOCKET__CREATE 0x00000008UL
29067 +#define NETLINK_FIREWALL_SOCKET__GETATTR 0x00000010UL
29068 +#define NETLINK_FIREWALL_SOCKET__SETATTR 0x00000020UL
29069 +#define NETLINK_FIREWALL_SOCKET__LOCK 0x00000040UL
29070 +#define NETLINK_FIREWALL_SOCKET__RELABELFROM 0x00000080UL
29071 +#define NETLINK_FIREWALL_SOCKET__RELABELTO 0x00000100UL
29072 +#define NETLINK_FIREWALL_SOCKET__APPEND 0x00000200UL
29073 +#define NETLINK_FIREWALL_SOCKET__BIND 0x00000400UL
29074 +#define NETLINK_FIREWALL_SOCKET__CONNECT 0x00000800UL
29075 +#define NETLINK_FIREWALL_SOCKET__LISTEN 0x00001000UL
29076 +#define NETLINK_FIREWALL_SOCKET__ACCEPT 0x00002000UL
29077 +#define NETLINK_FIREWALL_SOCKET__GETOPT 0x00004000UL
29078 +#define NETLINK_FIREWALL_SOCKET__SETOPT 0x00008000UL
29079 +#define NETLINK_FIREWALL_SOCKET__SHUTDOWN 0x00010000UL
29080 +#define NETLINK_FIREWALL_SOCKET__RECVFROM 0x00020000UL
29081 +#define NETLINK_FIREWALL_SOCKET__SENDTO 0x00040000UL
29082 +#define NETLINK_FIREWALL_SOCKET__RECV_MSG 0x00080000UL
29083 +#define NETLINK_FIREWALL_SOCKET__SEND_MSG 0x00100000UL
29084 +#define NETLINK_FIREWALL_SOCKET__NAME_BIND 0x00200000UL
29085 +#define NETLINK_FIREWALL_SOCKET__NLMSG_READ 0x00400000UL
29086 +#define NETLINK_FIREWALL_SOCKET__NLMSG_WRITE 0x00800000UL
29087 +#define NETLINK_TCPDIAG_SOCKET__IOCTL 0x00000001UL
29088 +#define NETLINK_TCPDIAG_SOCKET__READ 0x00000002UL
29089 +#define NETLINK_TCPDIAG_SOCKET__WRITE 0x00000004UL
29090 +#define NETLINK_TCPDIAG_SOCKET__CREATE 0x00000008UL
29091 +#define NETLINK_TCPDIAG_SOCKET__GETATTR 0x00000010UL
29092 +#define NETLINK_TCPDIAG_SOCKET__SETATTR 0x00000020UL
29093 +#define NETLINK_TCPDIAG_SOCKET__LOCK 0x00000040UL
29094 +#define NETLINK_TCPDIAG_SOCKET__RELABELFROM 0x00000080UL
29095 +#define NETLINK_TCPDIAG_SOCKET__RELABELTO 0x00000100UL
29096 +#define NETLINK_TCPDIAG_SOCKET__APPEND 0x00000200UL
29097 +#define NETLINK_TCPDIAG_SOCKET__BIND 0x00000400UL
29098 +#define NETLINK_TCPDIAG_SOCKET__CONNECT 0x00000800UL
29099 +#define NETLINK_TCPDIAG_SOCKET__LISTEN 0x00001000UL
29100 +#define NETLINK_TCPDIAG_SOCKET__ACCEPT 0x00002000UL
29101 +#define NETLINK_TCPDIAG_SOCKET__GETOPT 0x00004000UL
29102 +#define NETLINK_TCPDIAG_SOCKET__SETOPT 0x00008000UL
29103 +#define NETLINK_TCPDIAG_SOCKET__SHUTDOWN 0x00010000UL
29104 +#define NETLINK_TCPDIAG_SOCKET__RECVFROM 0x00020000UL
29105 +#define NETLINK_TCPDIAG_SOCKET__SENDTO 0x00040000UL
29106 +#define NETLINK_TCPDIAG_SOCKET__RECV_MSG 0x00080000UL
29107 +#define NETLINK_TCPDIAG_SOCKET__SEND_MSG 0x00100000UL
29108 +#define NETLINK_TCPDIAG_SOCKET__NAME_BIND 0x00200000UL
29109 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_READ 0x00400000UL
29110 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_WRITE 0x00800000UL
29111 +#define NETLINK_NFLOG_SOCKET__IOCTL 0x00000001UL
29112 +#define NETLINK_NFLOG_SOCKET__READ 0x00000002UL
29113 +#define NETLINK_NFLOG_SOCKET__WRITE 0x00000004UL
29114 +#define NETLINK_NFLOG_SOCKET__CREATE 0x00000008UL
29115 +#define NETLINK_NFLOG_SOCKET__GETATTR 0x00000010UL
29116 +#define NETLINK_NFLOG_SOCKET__SETATTR 0x00000020UL
29117 +#define NETLINK_NFLOG_SOCKET__LOCK 0x00000040UL
29118 +#define NETLINK_NFLOG_SOCKET__RELABELFROM 0x00000080UL
29119 +#define NETLINK_NFLOG_SOCKET__RELABELTO 0x00000100UL
29120 +#define NETLINK_NFLOG_SOCKET__APPEND 0x00000200UL
29121 +#define NETLINK_NFLOG_SOCKET__BIND 0x00000400UL
29122 +#define NETLINK_NFLOG_SOCKET__CONNECT 0x00000800UL
29123 +#define NETLINK_NFLOG_SOCKET__LISTEN 0x00001000UL
29124 +#define NETLINK_NFLOG_SOCKET__ACCEPT 0x00002000UL
29125 +#define NETLINK_NFLOG_SOCKET__GETOPT 0x00004000UL
29126 +#define NETLINK_NFLOG_SOCKET__SETOPT 0x00008000UL
29127 +#define NETLINK_NFLOG_SOCKET__SHUTDOWN 0x00010000UL
29128 +#define NETLINK_NFLOG_SOCKET__RECVFROM 0x00020000UL
29129 +#define NETLINK_NFLOG_SOCKET__SENDTO 0x00040000UL
29130 +#define NETLINK_NFLOG_SOCKET__RECV_MSG 0x00080000UL
29131 +#define NETLINK_NFLOG_SOCKET__SEND_MSG 0x00100000UL
29132 +#define NETLINK_NFLOG_SOCKET__NAME_BIND 0x00200000UL
29133 +#define NETLINK_XFRM_SOCKET__IOCTL 0x00000001UL
29134 +#define NETLINK_XFRM_SOCKET__READ 0x00000002UL
29135 +#define NETLINK_XFRM_SOCKET__WRITE 0x00000004UL
29136 +#define NETLINK_XFRM_SOCKET__CREATE 0x00000008UL
29137 +#define NETLINK_XFRM_SOCKET__GETATTR 0x00000010UL
29138 +#define NETLINK_XFRM_SOCKET__SETATTR 0x00000020UL
29139 +#define NETLINK_XFRM_SOCKET__LOCK 0x00000040UL
29140 +#define NETLINK_XFRM_SOCKET__RELABELFROM 0x00000080UL
29141 +#define NETLINK_XFRM_SOCKET__RELABELTO 0x00000100UL
29142 +#define NETLINK_XFRM_SOCKET__APPEND 0x00000200UL
29143 +#define NETLINK_XFRM_SOCKET__BIND 0x00000400UL
29144 +#define NETLINK_XFRM_SOCKET__CONNECT 0x00000800UL
29145 +#define NETLINK_XFRM_SOCKET__LISTEN 0x00001000UL
29146 +#define NETLINK_XFRM_SOCKET__ACCEPT 0x00002000UL
29147 +#define NETLINK_XFRM_SOCKET__GETOPT 0x00004000UL
29148 +#define NETLINK_XFRM_SOCKET__SETOPT 0x00008000UL
29149 +#define NETLINK_XFRM_SOCKET__SHUTDOWN 0x00010000UL
29150 +#define NETLINK_XFRM_SOCKET__RECVFROM 0x00020000UL
29151 +#define NETLINK_XFRM_SOCKET__SENDTO 0x00040000UL
29152 +#define NETLINK_XFRM_SOCKET__RECV_MSG 0x00080000UL
29153 +#define NETLINK_XFRM_SOCKET__SEND_MSG 0x00100000UL
29154 +#define NETLINK_XFRM_SOCKET__NAME_BIND 0x00200000UL
29155 +#define NETLINK_XFRM_SOCKET__NLMSG_READ 0x00400000UL
29156 +#define NETLINK_XFRM_SOCKET__NLMSG_WRITE 0x00800000UL
29157 +#define NETLINK_SELINUX_SOCKET__IOCTL 0x00000001UL
29158 +#define NETLINK_SELINUX_SOCKET__READ 0x00000002UL
29159 +#define NETLINK_SELINUX_SOCKET__WRITE 0x00000004UL
29160 +#define NETLINK_SELINUX_SOCKET__CREATE 0x00000008UL
29161 +#define NETLINK_SELINUX_SOCKET__GETATTR 0x00000010UL
29162 +#define NETLINK_SELINUX_SOCKET__SETATTR 0x00000020UL
29163 +#define NETLINK_SELINUX_SOCKET__LOCK 0x00000040UL
29164 +#define NETLINK_SELINUX_SOCKET__RELABELFROM 0x00000080UL
29165 +#define NETLINK_SELINUX_SOCKET__RELABELTO 0x00000100UL
29166 +#define NETLINK_SELINUX_SOCKET__APPEND 0x00000200UL
29167 +#define NETLINK_SELINUX_SOCKET__BIND 0x00000400UL
29168 +#define NETLINK_SELINUX_SOCKET__CONNECT 0x00000800UL
29169 +#define NETLINK_SELINUX_SOCKET__LISTEN 0x00001000UL
29170 +#define NETLINK_SELINUX_SOCKET__ACCEPT 0x00002000UL
29171 +#define NETLINK_SELINUX_SOCKET__GETOPT 0x00004000UL
29172 +#define NETLINK_SELINUX_SOCKET__SETOPT 0x00008000UL
29173 +#define NETLINK_SELINUX_SOCKET__SHUTDOWN 0x00010000UL
29174 +#define NETLINK_SELINUX_SOCKET__RECVFROM 0x00020000UL
29175 +#define NETLINK_SELINUX_SOCKET__SENDTO 0x00040000UL
29176 +#define NETLINK_SELINUX_SOCKET__RECV_MSG 0x00080000UL
29177 +#define NETLINK_SELINUX_SOCKET__SEND_MSG 0x00100000UL
29178 +#define NETLINK_SELINUX_SOCKET__NAME_BIND 0x00200000UL
29179 +#define NETLINK_AUDIT_SOCKET__IOCTL 0x00000001UL
29180 +#define NETLINK_AUDIT_SOCKET__READ 0x00000002UL
29181 +#define NETLINK_AUDIT_SOCKET__WRITE 0x00000004UL
29182 +#define NETLINK_AUDIT_SOCKET__CREATE 0x00000008UL
29183 +#define NETLINK_AUDIT_SOCKET__GETATTR 0x00000010UL
29184 +#define NETLINK_AUDIT_SOCKET__SETATTR 0x00000020UL
29185 +#define NETLINK_AUDIT_SOCKET__LOCK 0x00000040UL
29186 +#define NETLINK_AUDIT_SOCKET__RELABELFROM 0x00000080UL
29187 +#define NETLINK_AUDIT_SOCKET__RELABELTO 0x00000100UL
29188 +#define NETLINK_AUDIT_SOCKET__APPEND 0x00000200UL
29189 +#define NETLINK_AUDIT_SOCKET__BIND 0x00000400UL
29190 +#define NETLINK_AUDIT_SOCKET__CONNECT 0x00000800UL
29191 +#define NETLINK_AUDIT_SOCKET__LISTEN 0x00001000UL
29192 +#define NETLINK_AUDIT_SOCKET__ACCEPT 0x00002000UL
29193 +#define NETLINK_AUDIT_SOCKET__GETOPT 0x00004000UL
29194 +#define NETLINK_AUDIT_SOCKET__SETOPT 0x00008000UL
29195 +#define NETLINK_AUDIT_SOCKET__SHUTDOWN 0x00010000UL
29196 +#define NETLINK_AUDIT_SOCKET__RECVFROM 0x00020000UL
29197 +#define NETLINK_AUDIT_SOCKET__SENDTO 0x00040000UL
29198 +#define NETLINK_AUDIT_SOCKET__RECV_MSG 0x00080000UL
29199 +#define NETLINK_AUDIT_SOCKET__SEND_MSG 0x00100000UL
29200 +#define NETLINK_AUDIT_SOCKET__NAME_BIND 0x00200000UL
29201 +#define NETLINK_AUDIT_SOCKET__NLMSG_READ 0x00400000UL
29202 +#define NETLINK_AUDIT_SOCKET__NLMSG_WRITE 0x00800000UL
29203 +#define NETLINK_AUDIT_SOCKET__NLMSG_RELAY 0x01000000UL
29204 +#define NETLINK_AUDIT_SOCKET__NLMSG_READPRIV 0x02000000UL
29205 +#define NETLINK_AUDIT_SOCKET__NLMSG_TTY_AUDIT 0x04000000UL
29206 +#define NETLINK_IP6FW_SOCKET__IOCTL 0x00000001UL
29207 +#define NETLINK_IP6FW_SOCKET__READ 0x00000002UL
29208 +#define NETLINK_IP6FW_SOCKET__WRITE 0x00000004UL
29209 +#define NETLINK_IP6FW_SOCKET__CREATE 0x00000008UL
29210 +#define NETLINK_IP6FW_SOCKET__GETATTR 0x00000010UL
29211 +#define NETLINK_IP6FW_SOCKET__SETATTR 0x00000020UL
29212 +#define NETLINK_IP6FW_SOCKET__LOCK 0x00000040UL
29213 +#define NETLINK_IP6FW_SOCKET__RELABELFROM 0x00000080UL
29214 +#define NETLINK_IP6FW_SOCKET__RELABELTO 0x00000100UL
29215 +#define NETLINK_IP6FW_SOCKET__APPEND 0x00000200UL
29216 +#define NETLINK_IP6FW_SOCKET__BIND 0x00000400UL
29217 +#define NETLINK_IP6FW_SOCKET__CONNECT 0x00000800UL
29218 +#define NETLINK_IP6FW_SOCKET__LISTEN 0x00001000UL
29219 +#define NETLINK_IP6FW_SOCKET__ACCEPT 0x00002000UL
29220 +#define NETLINK_IP6FW_SOCKET__GETOPT 0x00004000UL
29221 +#define NETLINK_IP6FW_SOCKET__SETOPT 0x00008000UL
29222 +#define NETLINK_IP6FW_SOCKET__SHUTDOWN 0x00010000UL
29223 +#define NETLINK_IP6FW_SOCKET__RECVFROM 0x00020000UL
29224 +#define NETLINK_IP6FW_SOCKET__SENDTO 0x00040000UL
29225 +#define NETLINK_IP6FW_SOCKET__RECV_MSG 0x00080000UL
29226 +#define NETLINK_IP6FW_SOCKET__SEND_MSG 0x00100000UL
29227 +#define NETLINK_IP6FW_SOCKET__NAME_BIND 0x00200000UL
29228 +#define NETLINK_IP6FW_SOCKET__NLMSG_READ 0x00400000UL
29229 +#define NETLINK_IP6FW_SOCKET__NLMSG_WRITE 0x00800000UL
29230 +#define NETLINK_DNRT_SOCKET__IOCTL 0x00000001UL
29231 +#define NETLINK_DNRT_SOCKET__READ 0x00000002UL
29232 +#define NETLINK_DNRT_SOCKET__WRITE 0x00000004UL
29233 +#define NETLINK_DNRT_SOCKET__CREATE 0x00000008UL
29234 +#define NETLINK_DNRT_SOCKET__GETATTR 0x00000010UL
29235 +#define NETLINK_DNRT_SOCKET__SETATTR 0x00000020UL
29236 +#define NETLINK_DNRT_SOCKET__LOCK 0x00000040UL
29237 +#define NETLINK_DNRT_SOCKET__RELABELFROM 0x00000080UL
29238 +#define NETLINK_DNRT_SOCKET__RELABELTO 0x00000100UL
29239 +#define NETLINK_DNRT_SOCKET__APPEND 0x00000200UL
29240 +#define NETLINK_DNRT_SOCKET__BIND 0x00000400UL
29241 +#define NETLINK_DNRT_SOCKET__CONNECT 0x00000800UL
29242 +#define NETLINK_DNRT_SOCKET__LISTEN 0x00001000UL
29243 +#define NETLINK_DNRT_SOCKET__ACCEPT 0x00002000UL
29244 +#define NETLINK_DNRT_SOCKET__GETOPT 0x00004000UL
29245 +#define NETLINK_DNRT_SOCKET__SETOPT 0x00008000UL
29246 +#define NETLINK_DNRT_SOCKET__SHUTDOWN 0x00010000UL
29247 +#define NETLINK_DNRT_SOCKET__RECVFROM 0x00020000UL
29248 +#define NETLINK_DNRT_SOCKET__SENDTO 0x00040000UL
29249 +#define NETLINK_DNRT_SOCKET__RECV_MSG 0x00080000UL
29250 +#define NETLINK_DNRT_SOCKET__SEND_MSG 0x00100000UL
29251 +#define NETLINK_DNRT_SOCKET__NAME_BIND 0x00200000UL
29252 +#define ASSOCIATION__SENDTO 0x00000001UL
29253 +#define ASSOCIATION__RECVFROM 0x00000002UL
29254 +#define ASSOCIATION__SETCONTEXT 0x00000004UL
29255 +#define ASSOCIATION__POLMATCH 0x00000008UL
29256 +#define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL 0x00000001UL
29257 +#define NETLINK_KOBJECT_UEVENT_SOCKET__READ 0x00000002UL
29258 +#define NETLINK_KOBJECT_UEVENT_SOCKET__WRITE 0x00000004UL
29259 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CREATE 0x00000008UL
29260 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETATTR 0x00000010UL
29261 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETATTR 0x00000020UL
29262 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LOCK 0x00000040UL
29263 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELFROM 0x00000080UL
29264 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELTO 0x00000100UL
29265 +#define NETLINK_KOBJECT_UEVENT_SOCKET__APPEND 0x00000200UL
29266 +#define NETLINK_KOBJECT_UEVENT_SOCKET__BIND 0x00000400UL
29267 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CONNECT 0x00000800UL
29268 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LISTEN 0x00001000UL
29269 +#define NETLINK_KOBJECT_UEVENT_SOCKET__ACCEPT 0x00002000UL
29270 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETOPT 0x00004000UL
29271 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETOPT 0x00008000UL
29272 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SHUTDOWN 0x00010000UL
29273 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECVFROM 0x00020000UL
29274 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SENDTO 0x00040000UL
29275 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECV_MSG 0x00080000UL
29276 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SEND_MSG 0x00100000UL
29277 +#define NETLINK_KOBJECT_UEVENT_SOCKET__NAME_BIND 0x00200000UL
29278 +#define APPLETALK_SOCKET__IOCTL 0x00000001UL
29279 +#define APPLETALK_SOCKET__READ 0x00000002UL
29280 +#define APPLETALK_SOCKET__WRITE 0x00000004UL
29281 +#define APPLETALK_SOCKET__CREATE 0x00000008UL
29282 +#define APPLETALK_SOCKET__GETATTR 0x00000010UL
29283 +#define APPLETALK_SOCKET__SETATTR 0x00000020UL
29284 +#define APPLETALK_SOCKET__LOCK 0x00000040UL
29285 +#define APPLETALK_SOCKET__RELABELFROM 0x00000080UL
29286 +#define APPLETALK_SOCKET__RELABELTO 0x00000100UL
29287 +#define APPLETALK_SOCKET__APPEND 0x00000200UL
29288 +#define APPLETALK_SOCKET__BIND 0x00000400UL
29289 +#define APPLETALK_SOCKET__CONNECT 0x00000800UL
29290 +#define APPLETALK_SOCKET__LISTEN 0x00001000UL
29291 +#define APPLETALK_SOCKET__ACCEPT 0x00002000UL
29292 +#define APPLETALK_SOCKET__GETOPT 0x00004000UL
29293 +#define APPLETALK_SOCKET__SETOPT 0x00008000UL
29294 +#define APPLETALK_SOCKET__SHUTDOWN 0x00010000UL
29295 +#define APPLETALK_SOCKET__RECVFROM 0x00020000UL
29296 +#define APPLETALK_SOCKET__SENDTO 0x00040000UL
29297 +#define APPLETALK_SOCKET__RECV_MSG 0x00080000UL
29298 +#define APPLETALK_SOCKET__SEND_MSG 0x00100000UL
29299 +#define APPLETALK_SOCKET__NAME_BIND 0x00200000UL
29300 +#define PACKET__SEND 0x00000001UL
29301 +#define PACKET__RECV 0x00000002UL
29302 +#define PACKET__RELABELTO 0x00000004UL
29303 +#define PACKET__FLOW_IN 0x00000008UL
29304 +#define PACKET__FLOW_OUT 0x00000010UL
29305 +#define PACKET__FORWARD_IN 0x00000020UL
29306 +#define PACKET__FORWARD_OUT 0x00000040UL
29307 +#define KEY__VIEW 0x00000001UL
29308 +#define KEY__READ 0x00000002UL
29309 +#define KEY__WRITE 0x00000004UL
29310 +#define KEY__SEARCH 0x00000008UL
29311 +#define KEY__LINK 0x00000010UL
29312 +#define KEY__SETATTR 0x00000020UL
29313 +#define KEY__CREATE 0x00000040UL
29314 +#define DCCP_SOCKET__IOCTL 0x00000001UL
29315 +#define DCCP_SOCKET__READ 0x00000002UL
29316 +#define DCCP_SOCKET__WRITE 0x00000004UL
29317 +#define DCCP_SOCKET__CREATE 0x00000008UL
29318 +#define DCCP_SOCKET__GETATTR 0x00000010UL
29319 +#define DCCP_SOCKET__SETATTR 0x00000020UL
29320 +#define DCCP_SOCKET__LOCK 0x00000040UL
29321 +#define DCCP_SOCKET__RELABELFROM 0x00000080UL
29322 +#define DCCP_SOCKET__RELABELTO 0x00000100UL
29323 +#define DCCP_SOCKET__APPEND 0x00000200UL
29324 +#define DCCP_SOCKET__BIND 0x00000400UL
29325 +#define DCCP_SOCKET__CONNECT 0x00000800UL
29326 +#define DCCP_SOCKET__LISTEN 0x00001000UL
29327 +#define DCCP_SOCKET__ACCEPT 0x00002000UL
29328 +#define DCCP_SOCKET__GETOPT 0x00004000UL
29329 +#define DCCP_SOCKET__SETOPT 0x00008000UL
29330 +#define DCCP_SOCKET__SHUTDOWN 0x00010000UL
29331 +#define DCCP_SOCKET__RECVFROM 0x00020000UL
29332 +#define DCCP_SOCKET__SENDTO 0x00040000UL
29333 +#define DCCP_SOCKET__RECV_MSG 0x00080000UL
29334 +#define DCCP_SOCKET__SEND_MSG 0x00100000UL
29335 +#define DCCP_SOCKET__NAME_BIND 0x00200000UL
29336 +#define DCCP_SOCKET__NODE_BIND 0x00400000UL
29337 +#define DCCP_SOCKET__NAME_CONNECT 0x00800000UL
29338 +#define MEMPROTECT__MMAP_ZERO 0x00000001UL
29339 +#define PEER__RECV 0x00000001UL
29340 +#define CAPABILITY2__MAC_OVERRIDE 0x00000001UL
29341 +#define CAPABILITY2__MAC_ADMIN 0x00000002UL
29342 +#define KERNEL_SERVICE__USE_AS_OVERRIDE 0x00000001UL
29343 +#define KERNEL_SERVICE__CREATE_FILES_AS 0x00000002UL
29344 +#define TUN_SOCKET__IOCTL 0x00000001UL
29345 +#define TUN_SOCKET__READ 0x00000002UL
29346 +#define TUN_SOCKET__WRITE 0x00000004UL
29347 +#define TUN_SOCKET__CREATE 0x00000008UL
29348 +#define TUN_SOCKET__GETATTR 0x00000010UL
29349 +#define TUN_SOCKET__SETATTR 0x00000020UL
29350 +#define TUN_SOCKET__LOCK 0x00000040UL
29351 +#define TUN_SOCKET__RELABELFROM 0x00000080UL
29352 +#define TUN_SOCKET__RELABELTO 0x00000100UL
29353 +#define TUN_SOCKET__APPEND 0x00000200UL
29354 +#define TUN_SOCKET__BIND 0x00000400UL
29355 +#define TUN_SOCKET__CONNECT 0x00000800UL
29356 +#define TUN_SOCKET__LISTEN 0x00001000UL
29357 +#define TUN_SOCKET__ACCEPT 0x00002000UL
29358 +#define TUN_SOCKET__GETOPT 0x00004000UL
29359 +#define TUN_SOCKET__SETOPT 0x00008000UL
29360 +#define TUN_SOCKET__SHUTDOWN 0x00010000UL
29361 +#define TUN_SOCKET__RECVFROM 0x00020000UL
29362 +#define TUN_SOCKET__SENDTO 0x00040000UL
29363 +#define TUN_SOCKET__RECV_MSG 0x00080000UL
29364 +#define TUN_SOCKET__SEND_MSG 0x00100000UL
29365 +#define TUN_SOCKET__NAME_BIND 0x00200000UL
29368 diff -NurpP --minimal linux-2.6.35/security/selinux/hooks.c linux-2.6.35-vs2.3.0.36.31/security/selinux/hooks.c
29369 --- linux-2.6.35/security/selinux/hooks.c 2010-08-02 16:53:03.000000000 +0200
29370 +++ linux-2.6.35-vs2.3.0.36.31/security/selinux/hooks.c 2010-08-02 17:05:06.000000000 +0200
29372 #include <linux/dccp.h>
29373 #include <linux/quota.h>
29374 #include <linux/un.h> /* for Unix socket types */
29375 -#include <net/af_unix.h> /* for Unix socket types */
29376 #include <linux/parser.h>
29377 #include <linux/nfs_mount.h>
29378 #include <net/ipv6.h>